From 54d0ff131097a2cd9a91a0c1dd84deb8b1f7d0ac Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 15 Jun 2012 05:21:43 +0200 Subject: Fix Bug 583: Remove Android compile-time dependencies and exclude Android specific classes for non Android platforms. Adapt to GlueGen commits: b3c9951006f9bd863244f1db3d54ac7866d66f0a, 86c1df6fdca183454ff544857f4236b646c4730d Ensure same Java JAR content regardless of build target (fix). Separate Android compilation results: jogl.all-android.jar and jogl.test-android.jar avoiding generating different content w/ non android builds. Adding ${android.abi} to APK target name (jogl.all-android.apk -> jogl.all-android-armeabi-v7a.apk) if not generic. --- make/scripts/adb-install-all-armv7.sh | 8 ++++---- make/scripts/adb-launch-main.sh | 2 +- make/scripts/adb-uninstall-all.sh | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/adb-install-all-armv7.sh b/make/scripts/adb-install-all-armv7.sh index 503c6f2f7..fe9765541 100755 --- a/make/scripts/adb-install-all-armv7.sh +++ b/make/scripts/adb-install-all-armv7.sh @@ -1,4 +1,4 @@ -adb $* install ../../gluegen/build-android-armv7/jogamp.android-launcher.apk -adb $* install ../../gluegen/build-android-armv7/gluegen-rt.apk -adb $* install ../build-android-armv7/jar/jogl.all-android.apk -adb $* install ../build-android-armv7/jar/jogl.test.apk +#adb $* install ../../gluegen/build-android-armv7/jogamp.android-launcher.apk +#adb $* install ../../gluegen/build-android-armv7/gluegen-rt-android-armeabi-v7a.apk +adb $* install ../build-android-armv7/jar/jogl.all-android-armeabi-v7a.apk +adb $* install ../build-android-armv7/jar/jogl.test-android.apk diff --git a/make/scripts/adb-launch-main.sh b/make/scripts/adb-launch-main.sh index 0887c107f..ff47a7ab0 100644 --- a/make/scripts/adb-launch-main.sh +++ b/make/scripts/adb-launch-main.sh @@ -61,7 +61,7 @@ am start -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android # \ #dalvikvm \ # -Xjnigreflimit:2000 \ -# -cp ../../gluegen/make/$BUILD_DIR/jogamp.android-launcher.apk:../../gluegen/make/lib/ant-junit-all.apk:../../gluegen/make/$BUILD_DIR/gluegen-rt.apk:$BUILD_DIR/jar/jogl.all-android.apk:$BUILD_DIR/jar/jogl.test.apk:$BUILD_DIR/jar/jogl.android-launcher.apk \ +# -cp ../../gluegen/make/$BUILD_DIR/jogamp.android-launcher.apk:../../gluegen/make/lib/ant-junit-all.apk:../../gluegen/make/$BUILD_DIR/gluegen-rt-android-armeabi-v7a.apk:$BUILD_DIR/jar/jogl.all-android-armeabi-v7a.apk:$BUILD_DIR/jar/jogl.test.apk \ # -Dgluegen.root=../../gluegen \ # -Drootrel.build=build-android-armv7 \ # com.android.internal.util.WithFramework \ diff --git a/make/scripts/adb-uninstall-all.sh b/make/scripts/adb-uninstall-all.sh index 1605a0e35..a80c38f61 100755 --- a/make/scripts/adb-uninstall-all.sh +++ b/make/scripts/adb-uninstall-all.sh @@ -1,4 +1,4 @@ -adb $* uninstall jogamp.android.launcher -adb $* uninstall com.jogamp.common +#adb $* uninstall jogamp.android.launcher +#adb $* uninstall com.jogamp.common adb $* uninstall javax.media.opengl adb $* uninstall com.jogamp.opengl.test -- cgit v1.2.3 From ccdc2ce6805e330cc5555b138044829f4bc67df9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 16 Jun 2012 21:27:21 +0200 Subject: Fix Bug 590: Wrong GL2 and GLES2 aliasing of GL_ARB_half_float_pixel/GL_ARB_half_float_vertex and GL_OES_texture_half_float extensions We mistakenly aliase the GL2 and GLES2 extensions: - GL_ARB_half_float_pixel - GL_HALF_FLOAT_ARB 0x140B - GL_ARB_half_float_vertex - GL_HALF_FLOAT 0x140B - GL_OES_texture_half_float extensions - GL_HALF_FLOAT_OES 0x8D61 This also leads to adding GL_HALF_FLOAT_OES to com.jogamp.opengl.util.GLBuffers.sizeof(..). --- make/config/jogl/gl-common-extensions.cfg | 1 - make/config/jogl/gl-if-CustomJavaCode-gl.java | 3 ++ make/config/jogl/gl-if-gl-ignores.cfg | 44 ++++------------------ make/config/jogl/gl-if-gl2_es2.cfg | 2 + make/scripts/cmpOld2New.sh | 4 +- .../classes/com/jogamp/opengl/util/GLBuffers.java | 2 + 6 files changed, 17 insertions(+), 39 deletions(-) (limited to 'make/scripts') diff --git a/make/config/jogl/gl-common-extensions.cfg b/make/config/jogl/gl-common-extensions.cfg index 51edd9edd..6631e035d 100644 --- a/make/config/jogl/gl-common-extensions.cfg +++ b/make/config/jogl/gl-common-extensions.cfg @@ -70,7 +70,6 @@ RenameExtensionIntoCore GL_OES_stencil4 RenameExtensionIntoCore GL_OES_stencil8 RenameExtensionIntoCore GL_OES_stencil_wrap RenameExtensionIntoCore GL_OES_texture_cube_map -RenameExtensionIntoCore GL_OES_texture_half_float RenameExtensionIntoCore GL_OES_texture_mirrored_repeat RenameExtensionIntoCore GL_OES_vertex_type_10_10_10_2 RenameExtensionIntoCore GL_EXT_color_buffer_half_float diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl.java b/make/config/jogl/gl-if-CustomJavaCode-gl.java index 4741b2df5..77378aa45 100644 --- a/make/config/jogl/gl-if-CustomJavaCode-gl.java +++ b/make/config/jogl/gl-if-CustomJavaCode-gl.java @@ -53,6 +53,9 @@ public static final int GL_SMOOTH_POINT_SIZE_RANGE = 0x0B12; /** Common in ES1, GL2 and GL3 */ public static final int GL_XOR = 0x1506; + /** Part of GL_ARB_half_float_vertex; GL_NV_half_float; GL_ARB_half_float_pixel, + earmarked for ES 3.0 (hence kept in GL while fixing Bug 590) */ + public static final int GL_HALF_FLOAT = 0x140B; public void glClearDepth( double depth ); diff --git a/make/config/jogl/gl-if-gl-ignores.cfg b/make/config/jogl/gl-if-gl-ignores.cfg index 220bd74bf..25fbd5a6f 100644 --- a/make/config/jogl/gl-if-gl-ignores.cfg +++ b/make/config/jogl/gl-if-gl-ignores.cfg @@ -32,13 +32,19 @@ IgnoreExtension GL_EXT_debug_marker IgnoreExtension GL_EXT_debug_label IgnoreExtension GL_EXT_multisampled_render_to_texture IgnoreExtension GL_EXT_framebuffer_multisample - +IgnoreExtension GL_OES_texture_half_float +IgnoreExtension GL_OES_vertex_half_float # IgnoreExtension GL_EXT_texture_storage IgnoreExtension GL_NV_draw_buffers IgnoreExtension GL_NV_fbo_color_attachments IgnoreExtension GL_OES_vertex_array_object IgnoreExtension GL_OES_texture_3D -# above ext are subsumed, so ignore the aliased ones + +# includes GL_STATE_RESTORE, which hasn't the QCOM suffix +IgnoreExtension GL_QCOM_extended_get +Ignore GL_STATE_RESTORE + +# above ext mightbe subsumed, ignore the aliased ones Ignore GL_ACTIVE_PROGRAM Ignore GL_ALPHA16F Ignore GL_ALPHA32F @@ -156,10 +162,6 @@ Ignore glPushGroupMarkerEXT # isn't included in GL2 Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET -# includes GL_STATE_RESTORE, which hasn't the QCOM suffix -IgnoreExtension GL_QCOM_extended_get -Ignore GL_STATE_RESTORE - Ignore GL_ACTIVE_ATTRIBUTE_MAX_LENGTH Ignore GL_ACTIVE_ATTRIBUTES Ignore GL_ACTIVE_UNIFORM_MAX_LENGTH @@ -348,36 +350,6 @@ Ignore GL_NORMAL_ARRAY_TYPE Ignore GL_NORMALIZE Ignore GL_NORMAL_MAP_OES Ignore GL_NUM_SHADER_BINARY_FORMATS -Ignore GL_OES_blend_equation_separate -Ignore GL_OES_blend_func_separate -Ignore GL_OES_blend_subtract -Ignore GL_OES_byte_coordinates -Ignore GL_OES_compressed_ETC1_RGB8_texture -Ignore GL_OES_compressed_paletted_texture -Ignore GL_OES_depth24 -Ignore GL_OES_depth32 -Ignore GL_OES_draw_texture -Ignore GL_OES_element_index_uint -Ignore GL_OES_extended_matrix_palette -Ignore GL_OES_fbo_render_mipmap -Ignore GL_OES_fixed_point -Ignore GL_OES_framebuffer_object -Ignore GL_OES_matrix_get -Ignore GL_OES_matrix_palette -Ignore GL_OES_point_size_array -Ignore GL_OES_point_sprite -Ignore GL_OES_query_matrix -Ignore GL_OES_read_format -Ignore GL_OES_single_precision -Ignore GL_OES_stencil1 -Ignore GL_OES_stencil4 -Ignore GL_OES_stencil8 -Ignore GL_OES_stencil_wrap -Ignore GL_OES_texture_cube_map -Ignore GL_OES_texture_env_crossbar -Ignore GL_OES_texture_half_float -Ignore GL_OES_texture_mirrored_repeat -Ignore GL_OES_vertex_half_float Ignore GL_ONE_MINUS_CONSTANT_ALPHA Ignore GL_ONE_MINUS_CONSTANT_COLOR Ignore GL_OPERAND0_ALPHA diff --git a/make/config/jogl/gl-if-gl2_es2.cfg b/make/config/jogl/gl-if-gl2_es2.cfg index 6a8aef06b..85e799298 100644 --- a/make/config/jogl/gl-if-gl2_es2.cfg +++ b/make/config/jogl/gl-if-gl2_es2.cfg @@ -35,6 +35,8 @@ IgnoreExtension GL_EXT_discard_framebuffer IgnoreExtension GL_OES_compressed_paletted_texture IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture IgnoreExtension GL_OES_vertex_array_object +IgnoreExtension GL_OES_texture_half_float +IgnoreExtension GL_OES_vertex_half_float IgnoreExtension GL_OES_EGL_image_external IgnoreExtension GL_EXT_debug_marker IgnoreExtension GL_EXT_debug_label diff --git a/make/scripts/cmpOld2New.sh b/make/scripts/cmpOld2New.sh index 4394fe7b5..7d68cfc84 100755 --- a/make/scripts/cmpOld2New.sh +++ b/make/scripts/cmpOld2New.sh @@ -2,8 +2,8 @@ dirscript=`dirname $0` -dirold=../build-x86_64-old/jogl/gensrc/classes/javax/media/opengl/ -dirnew=../build-x86_64/jogl/gensrc/classes/javax/media/opengl/ +dirold=../build-old/jogl/gensrc/classes/javax/media/opengl/ +dirnew=../build/jogl/gensrc/classes/javax/media/opengl/ dircmp=cmp-old2new rm -rf $dircmp diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java index 32391c650..8401b9cd2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java @@ -43,6 +43,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLES2; import javax.media.opengl.GLException; import java.nio.*; @@ -456,6 +457,7 @@ public class GLBuffers extends Buffers { case GL.GL_SHORT: case GL.GL_UNSIGNED_SHORT: case GL.GL_HALF_FLOAT: + case GLES2.GL_HALF_FLOAT_OES: esize = 2; break; case GL2ES2.GL_INT: -- cgit v1.2.3 From 7f341c7bc0d0f5770191bb58f2c0053c3453bc8a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Jun 2012 18:21:59 +0200 Subject: Unit Test: Cleanup TextureSequence Demo Code and Tests, adding AWT Test 'launcher' --- make/scripts/tests.sh | 35 +- .../test/junit/jogl/demos/TestTextureSequence.java | 120 ----- .../junit/jogl/demos/TextureSequenceDemo01.java | 120 +++++ .../test/junit/jogl/demos/es2/TexCubeES2.java | 507 --------------------- .../jogl/demos/es2/TextureSequenceCubeES2.java | 456 ++++++++++++++++++ .../test/junit/jogl/demos/es2/av/MovieCube.java | 6 +- .../util/texture/TestTextureSequence01AWT.java | 112 +++++ .../util/texture/TestTextureSequence01NEWT.java | 99 ++++ 8 files changed, 815 insertions(+), 640 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTextureSequence01NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a678bdf05..da817d33b 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -209,6 +209,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* @@ -249,12 +250,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestGLReadBufferUtilTextureIOWrite01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestGLReadBufferUtilTextureIOWrite02NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 $* # # awt (testawt) @@ -280,9 +275,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* -#testawt com.jogamp.opengl.test.junit.jogl.texture.TestTexture01AWT #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT -#testawt com.jogamp.opengl.test.junit.jogl.texture.TestGrayTextureFromFileAWTBug417 #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* @@ -332,6 +325,23 @@ function testawtswt() { #testawt $* +# +# Texture / TextureUtils +# +#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGrayTextureFromFileAWTBug417 +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* +testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* + +# +# GLSL / FBO / .. +# #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT $* @@ -339,7 +349,10 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 $* -testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* +# +# Graph +# +#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* @@ -351,9 +364,11 @@ testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo02 $* +# +# Security +# #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* # # osx bugs diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java deleted file mode 100644 index 6dfb11855..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TestTextureSequence.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.jogamp.opengl.test.junit.jogl.demos; - -import java.net.URLConnection; - -import javax.media.opengl.GL; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; - -import jogamp.opengl.util.av.NullGLMediaPlayer; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureIO; -import com.jogamp.opengl.util.texture.TextureSequence; - -public class TestTextureSequence implements TextureSequence { - TextureSequence.TextureFrame frame = null; - int textureUnit = 0; - protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST }; - protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE }; - final boolean useBuildInTexLookup; - - public TestTextureSequence(boolean useBuildInTexLookup) { - this.useBuildInTexLookup = useBuildInTexLookup; - } - - public void initGLResources(GL gl) throws GLException { - if(null == frame) { - TextureData texData = null; - try { - URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", NullGLMediaPlayer.class.getClassLoader()); - if(null != urlConn) { - texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG); - } - } catch (Exception e) { - e.printStackTrace(); - } - final Texture tex = new Texture(gl, texData); - frame = new TextureSequence.TextureFrame(tex); - tex.bind(gl); - gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_MIN_FILTER, texMinMagFilter[0]); - gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_MAG_FILTER, texMinMagFilter[1]); - gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_WRAP_S, texWrapST[0]); - gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_WRAP_T, texWrapST[1]); - } - } - - public void destroyGLResources(GL gl) { - if(null != frame) { - frame.getTexture().destroy(gl); - frame = null; - } - } - - public void destroy(GL gl) throws GLException { - frame.getTexture().destroy(gl); - frame = null; - } - - @Override - public int getTextureUnit() { - return textureUnit; - } - - @Override - public int[] getTextureMinMagFilter() { - return texMinMagFilter; - } - - @Override - public int[] getTextureWrapST() { - return texWrapST; - } - - @Override - public TextureSequence.TextureFrame getLastTexture() throws IllegalStateException { - return frame; // may return null - } - - @Override - public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException { - return frame; - } - - @Override - public String getRequiredExtensionsShaderStub() throws IllegalStateException { - return "// TextTextureSequence: No extensions required\n"; - } - - @Override - public String getTextureSampler2DType() throws IllegalStateException { - return "sampler2D" ; - } - - private String textureLookupFunctionName = "myTexture2D"; - - @Override - public String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException { - if(useBuildInTexLookup) { - return "texture2D"; - } - if(null != desiredFuncName && desiredFuncName.length()>0) { - textureLookupFunctionName = desiredFuncName; - } - return textureLookupFunctionName; - } - - @Override - public String getTextureLookupFragmentShaderImpl() throws IllegalStateException { - if(useBuildInTexLookup) { - return ""; - } - return - "\n"+ - "vec4 "+textureLookupFunctionName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ - " return texture2D(image, texCoord);\n"+ - "}\n\n"; - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java new file mode 100644 index 000000000..a1d4b4466 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java @@ -0,0 +1,120 @@ +package com.jogamp.opengl.test.junit.jogl.demos; + +import java.net.URLConnection; + +import javax.media.opengl.GL; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + +import jogamp.opengl.util.av.NullGLMediaPlayer; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.texture.Texture; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.util.texture.TextureSequence; + +public class TextureSequenceDemo01 implements TextureSequence { + TextureSequence.TextureFrame frame = null; + int textureUnit = 0; + protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST }; + protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE }; + final boolean useBuildInTexLookup; + + public TextureSequenceDemo01(boolean useBuildInTexLookup) { + this.useBuildInTexLookup = useBuildInTexLookup; + } + + public void initGLResources(GL gl) throws GLException { + if(null == frame) { + TextureData texData = null; + try { + URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", NullGLMediaPlayer.class.getClassLoader()); + if(null != urlConn) { + texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG); + } + } catch (Exception e) { + e.printStackTrace(); + } + final Texture tex = new Texture(gl, texData); + frame = new TextureSequence.TextureFrame(tex); + tex.bind(gl); + gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_MIN_FILTER, texMinMagFilter[0]); + gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_MAG_FILTER, texMinMagFilter[1]); + gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_WRAP_S, texWrapST[0]); + gl.glTexParameteri(tex.getTarget(), GL.GL_TEXTURE_WRAP_T, texWrapST[1]); + } + } + + public void destroyGLResources(GL gl) { + if(null != frame) { + frame.getTexture().destroy(gl); + frame = null; + } + } + + public void destroy(GL gl) throws GLException { + frame.getTexture().destroy(gl); + frame = null; + } + + @Override + public int getTextureUnit() { + return textureUnit; + } + + @Override + public int[] getTextureMinMagFilter() { + return texMinMagFilter; + } + + @Override + public int[] getTextureWrapST() { + return texWrapST; + } + + @Override + public TextureSequence.TextureFrame getLastTexture() throws IllegalStateException { + return frame; // may return null + } + + @Override + public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException { + return frame; + } + + @Override + public String getRequiredExtensionsShaderStub() throws IllegalStateException { + return "// TextTextureSequence: No extensions required\n"; + } + + @Override + public String getTextureSampler2DType() throws IllegalStateException { + return "sampler2D" ; + } + + private String textureLookupFunctionName = "myTexture2D"; + + @Override + public String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException { + if(useBuildInTexLookup) { + return "texture2D"; + } + if(null != desiredFuncName && desiredFuncName.length()>0) { + textureLookupFunctionName = desiredFuncName; + } + return textureLookupFunctionName; + } + + @Override + public String getTextureLookupFragmentShaderImpl() throws IllegalStateException { + if(useBuildInTexLookup) { + return ""; + } + return + "\n"+ + "vec4 "+textureLookupFunctionName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + " return texture2D(image, texCoord);\n"+ + "}\n\n"; + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java deleted file mode 100644 index e85468bcb..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TexCubeES2.java +++ /dev/null @@ -1,507 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.jogl.demos.es2; - -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; - -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLES2; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; -import javax.media.opengl.GLUniformData; -import javax.media.opengl.fixedfunc.GLMatrixFunc; - -import com.jogamp.newt.Window; -import com.jogamp.newt.event.MouseAdapter; -import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.WindowAdapter; -import com.jogamp.newt.event.WindowEvent; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.test.junit.jogl.demos.TestTextureSequence; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLArrayDataServer; -import com.jogamp.opengl.util.PMVMatrix; -import com.jogamp.opengl.util.glsl.ShaderCode; -import com.jogamp.opengl.util.glsl.ShaderProgram; -import com.jogamp.opengl.util.glsl.ShaderState; -import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureCoords; -import com.jogamp.opengl.util.texture.TextureSequence; - -public class TexCubeES2 implements GLEventListener { - public TexCubeES2 (TextureSequence texSource, boolean innerCube, float zoom0, float rotx, float roty) { - this.texSeq = texSource; - this.innerCube = innerCube; - this.zoom0 = zoom0; - this.view_rotx = rotx; - this.view_roty = roty; - } - - private TextureSequence texSeq; - private ShaderState st; - private PMVMatrix pmvMatrix; - private GLUniformData pmvMatrixUniform; - // private TextureCoords[] textureCoords = null; - private float nearPlaneNormalized; - // private float zoom0=-5.0f, zoom=zoom0; - // private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; - private float zoom0=-2.3f, zoom=zoom0; - private float view_rotx = 0.0f, view_roty = 0.0f, view_rotz = 0.0f; - int[] vboNames = new int[4]; - boolean innerCube; - boolean initialized = false; - private ByteBuffer cubeIndices; - - private final MouseListener mouseAction = new MouseAdapter() { - int lx = 0; - int ly = 0; - boolean first = false; - - public void mousePressed(MouseEvent e) { - first = true; - } - public void mouseMoved(MouseEvent e) { - first = false; - } - public void mouseDragged(MouseEvent e) { - int width, height; - Object source = e.getSource(); - Window window = null; - if(source instanceof Window) { - window = (Window) source; - width=window.getWidth(); - height=window.getHeight(); - } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { - java.awt.Component comp = (java.awt.Component) source; - width=comp.getWidth(); - height=comp.getHeight(); - } else { - throw new RuntimeException("Event source neither Window nor Component: "+source); - } - if(e.getPointerCount()==2) { - // 2 pointers zoom .. - if(first) { - lx = Math.abs(e.getY(0)-e.getY(1)); - first=false; - return; - } - int nv = Math.abs(e.getY(0)-e.getY(1)); - int dy = nv - lx; - - zoom += 40f*Math.signum(dy)/(float)height; - - lx = nv; - } else { - // 1 pointer rotate - if(first) { - lx = e.getX(); - ly = e.getY(); - first=false; - return; - } - int nx = e.getX(); - int ny = e.getY(); - view_roty += 360f * ( (float)( nx - lx ) / (float)width ); - view_rotx += 360f * ( (float)( ny - ly ) / (float)height ); - lx = nx; - ly = ny; - } - } - public void mouseWheelMoved(MouseEvent e) { - zoom += e.getWheelRotation()/10f; - System.err.println("zoom: "+zoom); - } - }; - - static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; - static final String gl2_prelude = "#version 110\n"; - static final String shaderBasename = "texsequence_xxx"; - static final String myTextureLookupName = "myTexture2D"; - - private void initShader(GL2ES2 gl) { - // Create & Compile the shader objects - ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TexCubeES2.class, - "shader", "shader/bin", shaderBasename, true); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TexCubeES2.class, - "shader", "shader/bin", shaderBasename, true); - - // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ] - int rsFpPos; - if(gl.isGLES2()) { - rsVp.insertShaderSource(0, 0, es2_prelude[0]); - rsFpPos = rsFp.insertShaderSource(0, 0, es2_prelude[0]); - } else { - rsVp.insertShaderSource(0, 0, gl2_prelude); - rsFpPos = rsFp.insertShaderSource(0, 0, gl2_prelude); - } - rsFpPos = rsFp.insertShaderSource(0, rsFpPos, texSeq.getRequiredExtensionsShaderStub()); - if(gl.isGLES2()) { - rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]); - } - final String texLookupFuncName = texSeq.getTextureLookupFunctionName(myTextureLookupName); - rsFp.replaceInShaderSource(myTextureLookupName, texLookupFuncName); - - // Inject TextureSequence shader details - final StringBuilder sFpIns = new StringBuilder(); - sFpIns.append("uniform ").append(texSeq.getTextureSampler2DType()).append(" mgl_ActiveTexture;\n"); - sFpIns.append(texSeq.getTextureLookupFragmentShaderImpl()); - rsFp.insertShaderSource(0, "TEXTURE-SEQUENCE-CODE-BEGIN", 0, sFpIns); - - // Create & Link the shader program - ShaderProgram sp = new ShaderProgram(); - sp.add(rsVp); - sp.add(rsFp); - if(!sp.link(gl, System.err)) { - throw new GLException("Couldn't link program: "+sp); - } - - // Let's manage all our states using ShaderState. - st = new ShaderState(); - st.attachShaderProgram(gl, sp, false); - } - - GLArrayDataServer interleavedVBO; - - public void init(GLAutoDrawable drawable) { - GL2ES2 gl = drawable.getGL().getGL2ES2(); - System.err.println(JoglVersion.getGLInfo(gl, null)); - final Texture tex= texSeq.getLastTexture().getTexture(); - - final boolean useExternalTexture = GLES2.GL_TEXTURE_EXTERNAL_OES == tex.getTarget(); - if(useExternalTexture && !gl.isExtensionAvailable("GL_OES_EGL_image_external")) { - throw new GLException("GL_OES_EGL_image_external requested but not available"); - } - - initShader(gl); - - // Push the 1st uniform down the path - st.useProgram(gl, true); - - pmvMatrix = new PMVMatrix(); - reshapePMV(drawable.getWidth(), drawable.getHeight()); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); - if(!st.uniform(gl, pmvMatrixUniform)) { - throw new GLException("Error setting PMVMatrix in shader: "+st); - } - if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", texSeq.getTextureUnit()))) { - throw new GLException("Error setting mgl_ActiveTexture in shader: "+st); - } - - - { - final float aspect = tex.getAspectRatio(); - final TextureCoords tc = tex.getImageTexCoords(); - System.err.println("XXX0: aspect: "+aspect); - System.err.println("XXX0: y-flip: "+tex.getMustFlipVertically()); - System.err.println("XXX0: "+tc); - final float tc_x1 = Math.max(tc.left(), tc.right()); - final float tc_y1 = Math.max(tc.bottom(), tc.top()); - final float ss=1f, ts=aspect; // scale tex-coord - final float dy = ( 1f - aspect ) / 2f ; - for(int i=0; i Date: Mon, 18 Jun 2012 03:39:39 +0200 Subject: Texture Unit Tests: AWT/NEWT GL2/ES2 PNGJ/AWT-PNG-Loading and Rendering (TestPNGTextureFromFile[AWT/NEWT]) Properly test combinations of TextureIO usage w/ - NEWT / AWT usage - GL2 / ES2 usage - PNG implementations: PNGJ (internal) and AWT - adding screenshots of result for later analysis Misc: - IOUtil.getResource(..) usage CLASS.class.getClassLoader() -> this.getClass().getClassLoader() --- make/scripts/tests.sh | 15 +- .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 2 +- .../junit/jogl/demos/TextureDraw01Accessor.java | 35 +++ .../junit/jogl/demos/TextureSequenceDemo01.java | 4 +- .../jogl/demos/es2/TextureDraw01ES2Listener.java | 249 +++++++++++++++++++++ .../jogl/demos/es2/TextureSequenceCubeES2.java | 19 +- .../junit/jogl/demos/es2/shader/texture01_xxx.fp | 20 ++ .../junit/jogl/demos/es2/shader/texture01_xxx.vp | 17 ++ .../jogl/demos/gl2/TextureDraw01GL2Listener.java | 104 +++++++++ .../test/junit/jogl/util/TestPNGImage01NEWT.java | 2 +- .../texture/TestGrayTextureFromFileAWTBug417.java | 149 ------------ .../util/texture/TestPNGTextureFromFileAWT.java | 238 ++++++++++++++++++++ .../util/texture/TestPNGTextureFromFileNEWT.java | 173 ++++++++++++++ .../junit/jogl/util/texture/TestTexture01AWT.java | 3 +- .../util/texture/TestTextureSequence01NEWT.java | 2 - .../jogl/util/texture/TextureGL2ListenerDraw1.java | 112 --------- 16 files changed, 859 insertions(+), 285 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGrayTextureFromFileAWTBug417.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TextureGL2ListenerDraw1.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index da817d33b..c9db61564 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -53,16 +53,16 @@ function jrun() { swton=$1 shift - #D_ARGS="-Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.UseCurrentThreadLibLoader" - #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" - #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" - #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" - #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" + #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" + #D_ARGS="-Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.UseCurrentThreadLibLoader" + #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" + #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" + #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLArrayData" #D_ARGS="-Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" @@ -330,11 +330,12 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT -#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGrayTextureFromFileAWTBug417 +testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* -testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index 3d740d6b2..cd48c3962 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -110,7 +110,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { @Override protected void initGLStreamImpl(GL gl, int[] texNames) throws IOException { try { - URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", NullGLMediaPlayer.class.getClassLoader()); + URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader()); if(null != urlConn) { texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java new file mode 100644 index 000000000..b9ac9faad --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureDraw01Accessor.java @@ -0,0 +1,35 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.demos; + +import com.jogamp.opengl.util.texture.Texture; + +public interface TextureDraw01Accessor { + public Texture getTexture(); +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java index a1d4b4466..6fd47e63f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/TextureSequenceDemo01.java @@ -6,8 +6,6 @@ import javax.media.opengl.GL; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import jogamp.opengl.util.av.NullGLMediaPlayer; - import com.jogamp.common.util.IOUtil; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureData; @@ -29,7 +27,7 @@ public class TextureSequenceDemo01 implements TextureSequence { if(null == frame) { TextureData texData = null; try { - URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", NullGLMediaPlayer.class.getClassLoader()); + URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader()); if(null != urlConn) { texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java new file mode 100644 index 000000000..6e701658c --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java @@ -0,0 +1,249 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es2; + +import java.nio.FloatBuffer; + +import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; +import com.jogamp.opengl.util.texture.Texture; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLUniformData; +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01Accessor { + TextureData textureData; + Texture texture; + + ShaderState st; + PMVMatrix pmvMatrix; + GLUniformData pmvMatrixUniform; + GLArrayDataServer interleavedVBO; + + + public TextureDraw01ES2Listener(TextureData td) { + this.textureData = td; + } + + static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; + static final String gl2_prelude = "#version 110\n"; + static final String shaderBasename = "texture01_xxx"; + + private void initShader(GL2ES2 gl, boolean use_program) { + // Create & Compile the shader objects + ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), + "shader", "shader/bin", shaderBasename, true); + ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), + "shader", "shader/bin", shaderBasename, true); + + // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ] + int rsFpPos; + if(gl.isGLES2()) { + rsVp.insertShaderSource(0, 0, es2_prelude[0]); + rsFpPos = rsFp.insertShaderSource(0, 0, es2_prelude[0]); + } else { + rsVp.insertShaderSource(0, 0, gl2_prelude); + rsFpPos = rsFp.insertShaderSource(0, 0, gl2_prelude); + } + if(gl.isGLES2()) { + rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]); + } + + // Create & Link the shader program + ShaderProgram sp = new ShaderProgram(); + sp.add(rsVp); + sp.add(rsFp); + if(!sp.link(gl, System.err)) { + throw new GLException("Couldn't link program: "+sp); + } + + // Let's manage all our states using ShaderState. + st = new ShaderState(); + st.attachShaderProgram(gl, sp, use_program); + } + + public void init(GLAutoDrawable glad) { + if(null!=textureData) { + this.texture = TextureIO.newTexture(glad.getGL(), textureData); + } + GL2ES2 gl = glad.getGL().getGL2ES2(); + + initShader(gl, true); + + // setup mgl_PMVMatrix + pmvMatrix = new PMVMatrix(); + pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv + + st.ownUniform(pmvMatrixUniform); + if(!st.uniform(gl, pmvMatrixUniform)) { + throw new GLException("Error setting PMVMatrix in shader: "+st); + } + if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", 0))) { + throw new GLException("Error setting mgl_ActiveTexture in shader: "+st); + } + + // fetch the flipped texture coordinates + texture.getImageTexCoords().getST_LB_RB_LT_RT(s_quadTexCoords, 0, 1f, 1f); + + interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW); + { + interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER); + //interleavedVBO.addGLSLSubArray("mgl_Normal", 3, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER); + + FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer(); + + for(int i=0; i<4; i++) { + ib.put(s_quadVertices, i*3, 3); + ib.put(s_quadColors, i*4, 4); + //ib.put(s_cubeNormals, i*3, 3); + ib.put(s_quadTexCoords, i*2, 2); + } + } + interleavedVBO.seal(gl, true); + interleavedVBO.enableBuffer(gl, false); + st.ownAttribute(interleavedVBO, true); + + // OpenGL Render Settings + gl.glClearColor(0, 0, 0, 1); + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + st.useProgram(gl, false); + } + + public Texture getTexture( ) { + return this.texture; + } + + /** + public void setTextureData(GL gl, TextureData textureData ) { + if(null!=texture) { + texture.disable(gl); + texture.destroy(gl); + } + if(null!=this.textureData) { + this.textureData.destroy(); + } + this.textureData = textureData; + this.texture = TextureIO.newTexture(this.textureData); + + // fix VBO ! + } */ + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + GL2ES2 gl = drawable.getGL().getGL2ES2(); + + gl.glViewport(0, 0, width, height); + + // Clear background to white + gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f); + + if(null != st) { + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); + + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + + st.useProgram(gl, true); + st.uniform(gl, pmvMatrixUniform); + st.useProgram(gl, false); + } + } + + public void dispose(GLAutoDrawable drawable) { + GL2ES2 gl = drawable.getGL().getGL2ES2(); + if(null!=texture) { + texture.disable(gl); + texture.destroy(gl); + } + if(null!=textureData) { + textureData.destroy(); + } + + pmvMatrixUniform = null; + pmvMatrix.destroy(); + pmvMatrix=null; + st.destroy(gl); + st=null; + } + + public void display(GLAutoDrawable drawable) { + GL2ES2 gl = drawable.getGL().getGL2ES2(); + + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + st.useProgram(gl, true); + interleavedVBO.enableBuffer(gl, true); + gl.glActiveTexture(GL.GL_TEXTURE0); + texture.enable(gl); + texture.bind(gl); + + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); + + texture.disable(gl); + interleavedVBO.enableBuffer(gl, false); + st.useProgram(gl, false); + } + + private static final float[] s_quadVertices = { + -1f, -1f, 0f, // LB + 1f, -1f, 0f, // RB + -1f, 1f, 0f, // LT + 1f, 1f, 0f // RT + }; + private static final float[] s_quadColors = { + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f }; + private static final float[] s_quadTexCoords = { + 0f, 0f, // LB + 1f, 0f, // RB + 0f, 1f, // LT + 1f, 1f // RT + }; +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index c2fbc65af..b04bd07c1 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -146,9 +146,9 @@ public class TextureSequenceCubeES2 implements GLEventListener { private void initShader(GL2ES2 gl) { // Create & Compile the shader objects - ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TextureSequenceCubeES2.class, + ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader", "shader/bin", shaderBasename, true); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TextureSequenceCubeES2.class, + ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", "shader/bin", shaderBasename, true); // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ] @@ -205,7 +205,7 @@ public class TextureSequenceCubeES2 implements GLEventListener { pmvMatrix = new PMVMatrix(); reshapePMV(drawable.getWidth(), drawable.getHeight()); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv if(!st.uniform(gl, pmvMatrixUniform)) { throw new GLException("Error setting PMVMatrix in shader: "+st); } @@ -214,6 +214,8 @@ public class TextureSequenceCubeES2 implements GLEventListener { } + // calculate centered tex coords w/ aspect ratio + float[] fixedCubeTexCoords = new float[s_cubeTexCoords.length]; { final float aspect = tex.getAspectRatio(); final TextureCoords tc = tex.getImageTexCoords(); @@ -228,17 +230,16 @@ public class TextureSequenceCubeES2 implements GLEventListener { final float tx = s_cubeTexCoords[i+0]; final float ty = s_cubeTexCoords[i+1]; if(tx!=0) { - s_cubeTexCoords[i+0] = tc_x1 * ss; + fixedCubeTexCoords[i+0] = tc_x1 * ss; } if(ty==0 && !tex.getMustFlipVertically() || ty!=0 && tex.getMustFlipVertically()) { - s_cubeTexCoords[i+1] = 0f + dy; + fixedCubeTexCoords[i+1] = 0f + dy; } else { - s_cubeTexCoords[i+1] = tc_y1 * ts + dy; + fixedCubeTexCoords[i+1] = tc_y1 * ts + dy; } } } - - + interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*6*4, GL.GL_STATIC_DRAW); { interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER); @@ -252,7 +253,7 @@ public class TextureSequenceCubeES2 implements GLEventListener { ib.put(s_cubeVertices, i*3, 3); ib.put(s_cubeColors, i*4, 4); //ib.put(s_cubeNormals, i*3, 3); - ib.put(s_cubeTexCoords, i*2, 2); + ib.put(fixedCubeTexCoords, i*2, 2); } } interleavedVBO.seal(gl, true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp new file mode 100644 index 000000000..1a4254163 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp @@ -0,0 +1,20 @@ +// Copyright 2012 JogAmp Community. All rights reserved. + +varying vec2 mgl_texCoord; +varying vec4 frontColor; + +uniform sampler2D mgl_ActiveTexture; + +void main (void) +{ + vec4 texColor; + if(0.0 <= mgl_texCoord.t && mgl_texCoord.t<=1.0) { + texColor = texture2D(mgl_ActiveTexture, mgl_texCoord); + } else { + texColor = vec4(1, 1, 1, 1); + } + + // mix frontColor with texture .. + gl_FragColor = vec4(frontColor*texColor); +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp new file mode 100644 index 000000000..c521e3757 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.vp @@ -0,0 +1,17 @@ +// Copyright 2012 JogAmp Community. All rights reserved. + +uniform mat4 mgl_PMVMatrix[2]; +// uniform mat4 mgl_STMatrix; +attribute vec4 mgl_Vertex; +attribute vec4 mgl_Color; +attribute vec4 mgl_MultiTexCoord; +varying vec4 frontColor; +varying vec2 mgl_texCoord; + +void main(void) +{ + frontColor=mgl_Color; + // mgl_texCoord = (mgl_STMatrix * mgl_MultiTexCoord).st; + mgl_texCoord = mgl_MultiTexCoord.st; + gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex; +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java new file mode 100644 index 000000000..af30c265b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java @@ -0,0 +1,104 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.gl2; + +import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor; +import com.jogamp.opengl.util.texture.Texture; +import com.jogamp.opengl.util.texture.TextureCoords; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.glu.GLU; + +public class TextureDraw01GL2Listener implements GLEventListener, TextureDraw01Accessor { + private GLU glu = new GLU(); + private TextureData textureData; + private Texture texture; + + public TextureDraw01GL2Listener(TextureData td) { + this.textureData = td; + } + + public void init(GLAutoDrawable drawable) { + if(null!=textureData) { + this.texture = TextureIO.newTexture(drawable.getGL(), textureData); + } + } + + public Texture getTexture( ) { + return this.texture; + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + GL2 gl = drawable.getGL().getGL2(); + gl.glMatrixMode(GL2ES1.GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluOrtho2D(0, 1, 0, 1); + gl.glMatrixMode(GL2ES1.GL_MODELVIEW); + gl.glLoadIdentity(); + } + + public void dispose(GLAutoDrawable drawable) { + GL2 gl = drawable.getGL().getGL2(); + if(null!=texture) { + texture.disable(gl); + texture.destroy(gl); + } + if(null!=textureData) { + textureData.destroy(); + } + } + + public void display(GLAutoDrawable drawable) { + GL2 gl = drawable.getGL().getGL2(); + + // draw one quad with the texture + if(null!=texture) { + texture.enable(gl); + texture.bind(gl); + gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); + TextureCoords coords = texture.getImageTexCoords(); + gl.glBegin(GL2.GL_QUADS); + gl.glTexCoord2f(coords.left(), coords.bottom()); + gl.glVertex3f(0, 0, 0); + gl.glTexCoord2f(coords.right(), coords.bottom()); + gl.glVertex3f(1, 0, 0); + gl.glTexCoord2f(coords.right(), coords.top()); + gl.glVertex3f(1, 1, 0); + gl.glTexCoord2f(coords.left(), coords.top()); + gl.glVertex3f(0, 1, 0); + gl.glEnd(); + texture.disable(gl); + } + } +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java index 5a0c18de7..c7e975ff6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/TestPNGImage01NEWT.java @@ -18,7 +18,7 @@ public class TestPNGImage01NEWT extends UITestCase { final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png"); final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png"); final String url_s="jogl/util/data/av/test-ntsc01-160x90.png"; - URLConnection urlConn = IOUtil.getResource(url_s, PNGImage.class.getClassLoader()); + URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader()); PNGImage image0 = PNGImage.read(urlConn.getInputStream()); System.err.println("PNGImage - Orig: "+image0); image0.write(out1_f, true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGrayTextureFromFileAWTBug417.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGrayTextureFromFileAWTBug417.java deleted file mode 100644 index a1e453fda..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGrayTextureFromFileAWTBug417.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.util.texture; - - -import com.jogamp.opengl.test.junit.util.UITestCase; - -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.awt.GLCanvas; -import com.jogamp.opengl.util.texture.TextureIO; -import com.jogamp.opengl.util.Animator; - -import java.awt.Frame; - -import java.io.IOException; -import java.io.InputStream; - -import org.junit.Assert; -import org.junit.After; -import org.junit.Assume; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Unit test for bug 417, which shows a GLException when reading a grayscale texture. - * Couldn't duplicate the failure, so it must have been fixed unknowingly sometime - * after the bug was submitted. - * @author Wade Walker - */ -public class TestGrayTextureFromFileAWTBug417 extends UITestCase { - static GLProfile glp; - static GLCapabilities caps; - InputStream textureStream; - - @BeforeClass - public static void initClass() { - if(!GLProfile.isAvailable(GLProfile.GL2GL3)) { - UITestCase.setTestSupported(false); - return; - } - glp = GLProfile.getGL2GL3(); - Assert.assertNotNull(glp); - caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - } - - @Before - public void initTest() { - textureStream = TestGrayTextureFromFileAWTBug417.class.getResourceAsStream( "grayscale_texture.png" ); - Assert.assertNotNull(textureStream); - } - - @After - public void cleanupTest() { - textureStream=null; - } - - @Test - public void test1() throws InterruptedException { - final GLCanvas glCanvas = new GLCanvas(caps); - final Frame frame = new Frame("Texture Test"); - Assert.assertNotNull(frame); - frame.add(glCanvas); - frame.setSize( 256, 128 ); - - // load texture from file inside current GL context to match the way - // the bug submitter was doing it - glCanvas.addGLEventListener(new TextureGL2ListenerDraw1( null ) { - @Override - public void init(GLAutoDrawable drawable) { - try { - setTexture( TextureIO.newTexture( textureStream, true, TextureIO.PNG ) ); - } - catch(GLException glexception) { - glexception.printStackTrace(); - Assume.assumeNoException(glexception); - } - catch(IOException ioexception) { - ioexception.printStackTrace(); - Assume.assumeNoException(ioexception); - } - } - }); - - Animator animator = new Animator(glCanvas); - frame.setVisible(true); - animator.start(); - - Thread.sleep(500); // 500 ms - - animator.stop(); - try { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - frame.remove(glCanvas); - frame.dispose(); - }}); - } catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - } - - public static void main(String args[]) throws IOException { - String tstname = TestGrayTextureFromFileAWTBug417.class.getName(); - org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { - tstname, - "filtertrace=true", - "haltOnError=false", - "haltOnFailure=false", - "showoutput=true", - "outputtoformatters=true", - "logfailedtests=true", - "logtestlistenerevents=true", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java new file mode 100644 index 000000000..068732696 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java @@ -0,0 +1,238 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.util.texture; + + +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor; +import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.TextureDraw01GL2Listener; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.awt.GLCanvas; + +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.util.texture.spi.TextureProvider; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLReadBufferUtil; + +import java.awt.Dimension; +import java.awt.Frame; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URLConnection; + +import org.junit.Assert; +import org.junit.After; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Unit test for bug 417, which shows a GLException when reading a grayscale texture. + * Couldn't duplicate the failure, so it must have been fixed unknowingly sometime + * after the bug was submitted. + * @author Wade Walker, et.al. + */ +public class TestPNGTextureFromFileAWT extends UITestCase { + static boolean showFPS = false; + static long duration = 100; // ms + InputStream grayTextureStream; + InputStream testTextureStream; + + @BeforeClass + public static void initClass() { + } + + @Before + public void initTest() throws IOException { + grayTextureStream = TestPNGTextureFromFileAWT.class.getResourceAsStream( "grayscale_texture.png" ); + Assert.assertNotNull(grayTextureStream); + URLConnection testTextureUrlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader()); + Assert.assertNotNull(testTextureUrlConn); + testTextureStream = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStream); + } + + @After + public void cleanupTest() { + grayTextureStream = null; + testTextureStream = null; + } + + protected void snapshot(GLAutoDrawable drawable, String filename) { + GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + screenshot.write(new File(filename)); + } + } + + public void testImpl(boolean useFFP, final InputStream istream, final boolean useAWTIIOP) + throws InterruptedException, IOException + { + GLProfile glp; + if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) { + glp = GLProfile.getGL2GL3(); + } else if(!useFFP && GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.getGL2ES2(); + } else { + System.err.println(getSimpleTestName(".")+": GLProfile n/a, useFFP: "+useFFP); + return; + } + final GLCapabilities caps = new GLCapabilities(glp); + final TextureData texData; + if(useAWTIIOP) { + final TextureProvider texProvider = new com.jogamp.opengl.util.texture.spi.awt.IIOTextureProvider(); + texData = texProvider.newTextureData(glp, istream, 0 /* internalFormat */, 0 /* pixelFormat */, false /* mipmap */, TextureIO.PNG); + } else { + texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG); + } + System.err.println("TextureData: "+texData); + + final GLCanvas glc = new GLCanvas(caps); + Dimension glc_sz = new Dimension(texData.getWidth(), texData.getHeight()); + glc.setMinimumSize(glc_sz); + glc.setPreferredSize(glc_sz); + final Frame frame = new Frame("TestPNGTextureGL2FromFileAWT"); + Assert.assertNotNull(frame); + frame.add(glc); + + // load texture from file inside current GL context to match the way + // the bug submitter was doing it + final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ; + glc.addGLEventListener(gle); + glc.addGLEventListener(new GLEventListener() { + boolean shot = false; + + @Override public void init(GLAutoDrawable drawable) {} + + @Override + public void display(GLAutoDrawable drawable) { + // 1 snapshot + if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { + shot = true; + snapshot(drawable, getSimpleTestName(".")+".png"); + } + } + + @Override public void dispose(GLAutoDrawable drawable) { } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + Animator animator = new Animator(glc); + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + QuitAdapter quitAdapter = new QuitAdapter(); + new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter).addTo(glc); + new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter).addTo(glc); + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + animator.start(); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Mon, 25 Jun 2012 06:41:57 +0200 Subject: Tests [Multisample, Offscreen, ..]: Add Snapshots and store them in current directory instead of tempdir, so they get archived (CI/jenkins). Multisample/TestGLReadBufferUtilTextureIOWrite01NEWT: Add offscreen test --- make/scripts/tests.sh | 4 +- .../junit/jogl/caps/TestMultisampleES1AWT.java | 51 +++++++++---- .../junit/jogl/caps/TestMultisampleES1NEWT.java | 87 ++++++++++++++++++---- .../test/junit/jogl/demos/es2/RedSquareES2.java | 2 +- .../test/junit/jogl/offscreen/Surface2File.java | 25 +++++-- .../offscreen/TestOffscreen01GLPBufferNEWT.java | 14 +--- .../jogl/offscreen/TestOffscreen02BitmapNEWT.java | 13 +--- .../test/junit/jogl/offscreen/WindowUtilNEWT.java | 31 ++++---- .../TestGLReadBufferUtilTextureIOWrite01NEWT.java | 42 ++++++++--- .../TestGLReadBufferUtilTextureIOWrite02NEWT.java | 25 ++++--- 10 files changed, 197 insertions(+), 97 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c9db61564..71fa425d5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -314,7 +314,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* +testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT @@ -330,7 +330,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT -testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java index 517d12578..4b0caf898 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java @@ -40,23 +40,28 @@ package com.jogamp.opengl.test.junit.jogl.caps; +import java.io.File; import java.lang.reflect.InvocationTargetException; import java.awt.BorderLayout; import java.awt.Frame; +import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.GLReadBufferUtil; import org.junit.Test; public class TestMultisampleES1AWT extends UITestCase { - static long durationPerTest = 250; // ms + static long durationPerTest = 60; // ms private GLCanvas canvas; public static void main(String[] args) { @@ -70,33 +75,54 @@ public class TestMultisampleES1AWT extends UITestCase { org.junit.runner.JUnitCore.main(tstname); } + protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { + GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); + if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { + screenshot.write(new File(filename)); + } + } + + @Test + public void testOnscreenMultiSampleAA0() throws InterruptedException, InvocationTargetException { + testMultiSampleAAImpl(0); + } + @Test - public void testMultiSampleAA4() throws InterruptedException, InvocationTargetException { + public void testOnscreenMultiSampleAA4() throws InterruptedException, InvocationTargetException { testMultiSampleAAImpl(4); } @Test - public void testMultiSampleNone() throws InterruptedException, InvocationTargetException { - testMultiSampleAAImpl(0); + public void testOnscreenMultiSampleAA8() throws InterruptedException, InvocationTargetException { + testMultiSampleAAImpl(8); } - private void testMultiSampleAAImpl(int samples) throws InterruptedException, InvocationTargetException { + private void testMultiSampleAAImpl(int reqSamples) throws InterruptedException, InvocationTargetException { GLProfile glp = GLProfile.getMaxFixedFunc(true); GLCapabilities caps = new GLCapabilities(glp); GLCapabilitiesChooser chooser = new MultisampleChooser01(); - if(samples>0) { + if(reqSamples>0) { caps.setSampleBuffers(true); - caps.setNumSamples(samples); - // turns out we need to have alpha, - // otherwise no AA will be visible. - caps.setAlphaBits(1); + caps.setNumSamples(reqSamples); } canvas = new GLCanvas(caps, chooser, null, null); - canvas.addGLEventListener(new MultisampleDemoES1(samples>0?true:false)); + canvas.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false)); + canvas.addGLEventListener(new GLEventListener() { + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); + final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; + final String aaext = caps.getSampleExtension(); + final int samples = caps.getSampleBuffers() ? caps.getNumSamples() : 0 ; + snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-S"+samples+"-"+aaext+"-"+drawable.getGLProfile().getName()+".png"); + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); - final Frame frame = new Frame("Multi Samples "+samples); + final Frame frame = new Frame("Multi Samples "+reqSamples); frame.setLayout(new BorderLayout()); canvas.setSize(512, 512); frame.add(canvas, BorderLayout.CENTER); @@ -105,7 +131,6 @@ public class TestMultisampleES1AWT extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setVisible(true); - frame.setLocation(0, 0); canvas.requestFocus(); canvas.display(); }}); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java index cdfeb2bad..2e47b6841 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java @@ -40,17 +40,24 @@ package com.jogamp.opengl.test.junit.jogl.caps; +import java.io.File; + +import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import org.junit.Test; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.GLReadBufferUtil; -public class TestMultisampleES1NEWT { - static long durationPerTest = 500; // ms +public class TestMultisampleES1NEWT extends UITestCase { + static long durationPerTest = 60; // ms private GLWindow window; public static void main(String[] args) { @@ -64,36 +71,84 @@ public class TestMultisampleES1NEWT { org.junit.runner.JUnitCore.main(tstname); } + protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { + GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); + if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { + screenshot.write(new File(filename)); + } + } + + @Test + public void testOnscreenMultiSampleAA0() throws InterruptedException { + testMultiSampleAAImpl(true, 0); + } + + @Test + public void testOnscreenMultiSampleAA2() throws InterruptedException { + testMultiSampleAAImpl(true, 2); + } + + @Test + public void testOnscreenMultiSampleAA4() throws InterruptedException { + testMultiSampleAAImpl(true, 4); + } + @Test - public void testMultiSampleAA4() throws InterruptedException { - testMultiSampleAAImpl(4); + public void testOnscreenMultiSampleAA8() throws InterruptedException { + testMultiSampleAAImpl(true, 8); } - // @Test - public void testMultiSampleNone() throws InterruptedException { - testMultiSampleAAImpl(0); + @Test + public void testOffscreenMultiSampleAA0() throws InterruptedException { + testMultiSampleAAImpl(false, 0); } - private void testMultiSampleAAImpl(int samples) throws InterruptedException { + @Test + public void testOffscreenMultiSampleAA2() throws InterruptedException { + testMultiSampleAAImpl(false, 2); + } + + @Test + public void testOffscreenMultiSampleAA4() throws InterruptedException { + testMultiSampleAAImpl(false, 4); + } + + @Test + public void testOffsreenMultiSampleAA8() throws InterruptedException { + testMultiSampleAAImpl(false, 8); + } + + private void testMultiSampleAAImpl(boolean onscreen, int reqSamples) throws InterruptedException { GLProfile glp = GLProfile.getMaxFixedFunc(true); GLCapabilities caps = new GLCapabilities(glp); GLCapabilitiesChooser chooser = new MultisampleChooser01(); - if(samples>0) { + if(!onscreen) { + caps.setOnscreen(onscreen); + caps.setPBuffer(true); + } + if(reqSamples>0) { caps.setSampleBuffers(true); - caps.setNumSamples(4); + caps.setNumSamples(reqSamples); } - // turns out we need to have alpha, - // otherwise no AA will be visible. - // This is done implicit now .. - // caps.setAlphaBits(1); window = GLWindow.create(caps); window.setCapabilitiesChooser(chooser); - window.addGLEventListener(new MultisampleDemoES1(samples>0?true:false)); + window.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false)); + window.addGLEventListener(new GLEventListener() { + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); + final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; + final String aaext = caps.getSampleExtension(); + final int samples = caps.getSampleBuffers() ? caps.getNumSamples() : 0 ; + snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-S"+samples+"-"+aaext+"-"+drawable.getGLProfile().getName()+".png"); + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); window.setSize(512, 512); window.setVisible(true); - window.setPosition(0, 0); window.requestFocus(); Thread.sleep(durationPerTest); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 620267125..eceaa0637 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -118,7 +118,7 @@ public class RedSquareES2 implements GLEventListener { colors.enableBuffer(gl, false); // OpenGL Render Settings - gl.glClearColor(0, 0, 0, 1); + gl.glClearColor(0, 0, 0, 0); gl.glEnable(GL2ES2.GL_DEPTH_TEST); st.useProgram(gl, false); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java index d1297e034..b046df6af 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/Surface2File.java @@ -34,14 +34,24 @@ import com.jogamp.opengl.util.GLReadBufferUtil; import java.io.File; import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; import javax.media.nativewindow.*; public class Surface2File implements SurfaceUpdatedListener { - GLReadBufferUtil readBufferUtil = new GLReadBufferUtil(false, false); + final String filename; + final boolean alpha; + final GLReadBufferUtil readBufferUtil; int shotNum = 0; + public Surface2File(String filename, boolean alpha) { + this.filename = filename; + this.alpha = alpha; + this.readBufferUtil = new GLReadBufferUtil(alpha, false); + } + public void dispose(GL gl) { readBufferUtil.dispose(gl); } @@ -57,7 +67,7 @@ public class Surface2File implements SurfaceUpdatedListener { if(readBufferUtil.readPixels(gl, drawable, false)) { gl.glFinish(); try { - surface2File("shot"); + surface2File(); } catch (IOException ex) { throw new RuntimeException("can not write survace to file", ex); } @@ -66,14 +76,17 @@ public class Surface2File implements SurfaceUpdatedListener { } } - public void surface2File(String basename) throws IOException { + public void surface2File() throws IOException { if (!readBufferUtil.isValid()) { return; } - - File file = File.createTempFile(basename + shotNum + "-", ".tga"); + final StringWriter sw = new StringWriter(); + { + final String pfmt = alpha ? "rgba" : "rgb_" ; + new PrintWriter(sw).printf("%s-I_%s-%04d.png", filename, pfmt, shotNum); + } + File file = new File(sw.toString()); readBufferUtil.write(file); - System.err.println("Wrote: " + file.getAbsolutePath() + ", ..."); shotNum++; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java index 3f1fd144f..2ed471436 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java @@ -32,8 +32,6 @@ import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.opengl.GLWindow; import org.junit.AfterClass; import org.junit.Assert; @@ -42,7 +40,6 @@ import org.junit.BeforeClass; import org.junit.Test; import javax.media.opengl.*; -import javax.media.nativewindow.*; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -72,6 +69,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { public void init() { capsDefault = new GLCapabilities(glpDefault); Assert.assertNotNull(capsDefault); + capsDefault.setAlphaBits(1); // req. alpha channel } private void do01OffscreenWindowPBuffer(GLCapabilities caps) { @@ -280,14 +278,8 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { Assert.assertNotNull(glWindow); glWindow.setVisible(true); - WindowListener wl=null; - MouseListener ml=null; - SurfaceUpdatedListener ul=null; - - GLEventListener demo = new RedSquareES2(); - Assert.assertNotNull(demo); - - WindowUtilNEWT.run(glWindow, demo, null, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/); + WindowUtilNEWT.run(getSimpleTestName("."), glWindow, new RedSquareES2(), null, null, null, null, + 2 /* frames */, true /*snapshot*/, false /*debug*/); if(null!=glWindow) { glWindow.destroy(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java index 7898ddad9..0701d883c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen02BitmapNEWT.java @@ -33,14 +33,11 @@ import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; -import com.jogamp.newt.event.MouseListener; -import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.opengl.GLWindow; import org.junit.Assert; import org.junit.Test; import javax.media.opengl.*; -import javax.media.nativewindow.*; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; @@ -119,14 +116,8 @@ public class TestOffscreen02BitmapNEWT extends UITestCase { Assert.assertNotNull(glWindow); glWindow.setVisible(true); - WindowListener wl=null; - MouseListener ml=null; - SurfaceUpdatedListener ul=null; - - GLEventListener demo = new RedSquareES1(); - Assert.assertNotNull(demo); - - WindowUtilNEWT.run(glWindow, demo, null, wl, ml, ul, 2, true /*snapshot*/, false /*debug*/); + WindowUtilNEWT.run(getSimpleTestName("."), glWindow, new RedSquareES1(), null, null, null, null, + 2 /* frames */, true /*snapshot*/, false /*debug*/); if(null!=glWindow) { glWindow.destroy(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java index 1d1ee1e0c..efca752a1 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/WindowUtilNEWT.java @@ -60,8 +60,8 @@ public class WindowUtilNEWT { } } - public static void run(GLWindow windowOffScreen, GLEventListener demo, - GLWindow windowOnScreen, WindowListener wl, MouseListener ml, + public static void run(String testName, GLWindow windowOffScreen, GLEventListener demo, + GLWindow windowOnScreenBlit, WindowListener wl, MouseListener ml, SurfaceUpdatedListener ul, int frames, boolean snapshot, boolean debug) { Assert.assertNotNull(windowOffScreen); Assert.assertNotNull(demo); @@ -69,35 +69,34 @@ public class WindowUtilNEWT { setDemoFields(demo, windowOffScreen, windowOffScreen, debug); windowOffScreen.addGLEventListener(demo); - if ( null != windowOnScreen ) { + if ( null != windowOnScreenBlit ) { if(null!=wl) { - windowOnScreen.addWindowListener(wl); + windowOnScreenBlit.addWindowListener(wl); } if(null!=ml) { - windowOnScreen.addMouseListener(ml); + windowOnScreenBlit.addMouseListener(ml); } - windowOnScreen.setVisible(true); + windowOnScreenBlit.setVisible(true); } GLDrawable readDrawable = windowOffScreen.getContext().getGLDrawable() ; - - if ( null == windowOnScreen ) { - if(snapshot) { - Surface2File s2f = new Surface2File(); - windowOffScreen.addSurfaceUpdatedListener(s2f); - } - } else { + if ( null != windowOnScreenBlit ) { ReadBuffer2Screen readDemo = new ReadBuffer2Screen( readDrawable ) ; - windowOnScreen.addGLEventListener(readDemo); + windowOnScreenBlit.addGLEventListener(readDemo); + } + if(snapshot) { + final boolean alpha = windowOffScreen.getChosenGLCapabilities().getAlphaBits()>0; + Surface2File s2f = new Surface2File(testName, alpha); + windowOffScreen.addSurfaceUpdatedListener(s2f); } if(null!=ul) { windowOffScreen.addSurfaceUpdatedListener(ul); } if(debug) { - System.err.println("+++++++++++++++++++++++++++"); + System.err.println("+++++++++++++++++++++++++++ "+testName); System.err.println(windowOffScreen); - System.err.println("+++++++++++++++++++++++++++"); + System.err.println("+++++++++++++++++++++++++++ "+testName); } while ( windowOffScreen.getTotalFPSFrames() < frames) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java index 687465a5d..b5b12035d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java @@ -40,6 +40,7 @@ import com.jogamp.opengl.util.GLReadBufferUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.offscreen.WindowUtilNEWT; import org.junit.Assert; import org.junit.BeforeClass; @@ -56,6 +57,7 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase { Assert.assertNotNull(glp); caps = new GLCapabilities(glp); Assert.assertNotNull(caps); + caps.setAlphaBits(1); // req. alpha channel width = 256; height = 256; } @@ -68,7 +70,7 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase { } @Test - public void testWritePNG_TGA_PAM() throws InterruptedException { + public void testOnscreenWritePNG_TGA_PAM() throws InterruptedException { GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Shared Gears NEWT Test"); @@ -78,16 +80,38 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase { public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { + final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; // snapshot(drawable, false, true, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".ppm"); - snapshot(drawable, true, false, getSimpleTestName(".")+"-rgba-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, true, false, getSimpleTestName(".")+"-rgba-"+drawable.getGLProfile().getName()+".tga"); - snapshot(drawable, true, true, getSimpleTestName(".")+"-rgba-"+drawable.getGLProfile().getName()+".pam"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".tga"); - snapshot(drawable, false, true, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".pam"); + snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".tga"); + snapshot(drawable, true, true, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".pam"); + snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".tga"); + snapshot(drawable, false, true, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".pam"); } - public void reshape(GLAutoDrawable drawable, int x, int y, - int width, int height) { } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + glWindow.setVisible(true); + Thread.sleep(60); + glWindow.destroy(); + } + + @Test + public void testOffscreenWritePNG() throws InterruptedException { + final GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false); + GLWindow glWindow = GLWindow.create(caps2); + Assert.assertNotNull(glWindow); + glWindow.setSize(width, height); + glWindow.addGLEventListener(new GearsES2(1)); + glWindow.addGLEventListener(new GLEventListener() { + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; + snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); glWindow.setVisible(true); Thread.sleep(60); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java index 6bb7f3b73..25a773c6a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java @@ -58,6 +58,7 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase { Assert.assertNotNull(glp); caps = new GLCapabilities(glp); Assert.assertNotNull(caps); + caps.setAlphaBits(1); // req. alpha channel width = 256; height = 256; } @@ -81,19 +82,19 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase { public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - StringWriter filename = new StringWriter(); + final StringWriter filename = new StringWriter(); { - PrintWriter pw = new PrintWriter(filename); - pw.printf("%s-rgba-%s-%03dx%03d-n%03d.tga", - getSimpleTestName("."), drawable.getGLProfile().getName(), + final PrintWriter pw = new PrintWriter(filename); + final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; + pw.printf("%s-F_rgba-I_%s-%s-%03dx%03d-n%03d.tga", + getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), drawable.getWidth(), drawable.getHeight(), i++); } if(screenshot.readPixels(drawable.getGL(), drawable, false)) { screenshot.write(new File(filename.toString())); } } - public void reshape(GLAutoDrawable drawable, int x, int y, - int width, int height) { } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); glWindow.setVisible(true); Thread.sleep(60); @@ -117,19 +118,19 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase { public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - StringWriter filename = new StringWriter(); + final StringWriter filename = new StringWriter(); { - PrintWriter pw = new PrintWriter(filename); - pw.printf("%s-rgba-%s-%03dx%03d-n%03d.png", - getSimpleTestName("."), drawable.getGLProfile().getName(), + final PrintWriter pw = new PrintWriter(filename); + final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; + pw.printf("%s-F_rgba-I_%s-%s-%03dx%03d-n%03d.png", + getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), drawable.getWidth(), drawable.getHeight(), i++); } if(screenshot.readPixels(drawable.getGL(), drawable, false)) { screenshot.write(new File(filename.toString())); } } - public void reshape(GLAutoDrawable drawable, int x, int y, - int width, int height) { } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); glWindow.setVisible(true); Thread.sleep(60); -- cgit v1.2.3 From 7a6e924be7190685650d87c680635d7fe53963fd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 25 Jun 2012 22:09:00 +0200 Subject: Fix path derivation of J2RE_HOME and JAVA_HOME --- make/scripts/setenv-jogl.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh index 38fd8de38..2d91f278f 100755 --- a/make/scripts/setenv-jogl.sh +++ b/make/scripts/setenv-jogl.sh @@ -57,7 +57,7 @@ GLUEGEN_OS=$GLUEGEN_BUILDDIR/obj JUNIT_JAR=$GLUEGEN_DIR/make/lib/junit.jar if [ -z "$ANT_PATH" ] ; then - ANT_PATH=$(dirname `which ant`)/.. + ANT_PATH=$(dirname $(dirname $(which ant))) if [ -e $ANT_PATH/lib/ant.jar ] ; then export ANT_PATH echo autosetting ANT_PATH to $ANT_PATH @@ -76,8 +76,8 @@ echo JOGL BUILDDIR: $JOGL_BUILDDIR echo JOGL BUILDDIR BASE: $JOGL_BUILDDIR_BASE echo JOGL PROFILE: $JOGL_PROFILE -J2RE_HOME=$(which java) -JAVA_HOME=$(which javac) +J2RE_HOME=$(dirname $(dirname $(which java))) +JAVA_HOME=$(dirname $(dirname $(which javac))) CP_SEP=: . $JOGL_DIR/etc/profile.jogl $JOGL_PROFILE $JOGL_BUILDDIR -- cgit v1.2.3 From a1e299b0c376c0ac726125d929bab2f68fe667d1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 25 Jun 2012 22:09:11 +0200 Subject: test script --- make/scripts/tests.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 71fa425d5..702b0dc8c 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -314,7 +314,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* -testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT @@ -332,6 +332,7 @@ testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* +testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* -- cgit v1.2.3 From a393e45613d87101dbb13763df263c2f9291d2d0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 26 Jun 2012 10:44:08 +0200 Subject: Implement Bug #598 - JOGL ALL JAR File Change incl. it's Native Jar URL Derivation - Depends on GlueGen commit 9a71703904ebfec343fb2c7266343d37a2e4c3db JAR file name changes: ALL JARs: - jogl.all.jar -> jogl-all.jar - jogl.all-noawt.jar -> jogl-all-noawt.jar - jogl.all-mobile.jar -> jogl-all-mobile.jar - jogl.all-android.jar -> jogl-all-android.jar - jogl.all-android.apk -> jogl-all-android.apk Atomic JARs: - nativewindow.core.jar -> nativewindow-core.jar - nativewindow.awt.jar -> nativewindow-awt.jar - nativewindow.os.x11.jar -> nativewindow-os-x11.jar - nativewindow.os.win.jar -> nativewindow-os-win.jar - nativewindow.os.macosx.jar -> nativewindow-os-osx.jar - jogl.core.jar -> jogl-core.jar - jogl.sdk.jar -> jogl-sdk.jar - jogl.glmobile.jar -> jogl-glmobile.jar - jogl.glmobile.dbg.jar -> jogl-glmobile-dbg.jar - jogl.util.jar -> jogl-util.jar - jogl.glutess.jar -> jogl-glutess.jar - jogl.glumipmap.jar -> jogl-glumipmap.jar - jogl.util.fixedfuncemu.jar -> jogl-util-fixedfuncemu.jar - jogl.awt.jar -> jogl-awt.jar - jogl.swt.jar -> jogl-swt.jar - jogl.util.awt.jar -> jogl-util-awt.jar - jogl.os.x11.jar -> jogl-os-x11.jar - jogl.os.win.jar -> jogl-os-win.jar - jogl.os.osx.jar -> jogl-os-osx.jar - jogl.os.android.jar -> jogl-os-android.jar - jogl.gldesktop.jar -> jogl-gldesktop.jar - jogl.gldesktop.dbg.jar -> jogl-gldesktop-dbg.jar - jogl.glugldesktop.jar -> jogl-glu-gldesktop.jar - jogl.util.gldesktop.jar -> jogl-util-gldesktop.jar - jogl.omx.jar -> jogl-omx.jar - jogl.cg.jar -> jogl-cg.jar - newt.core.jar -> newt-core.jar - newt.ogl.jar -> newt-ogl.jar - newt.awt.jar -> newt-awt.jar - newt.event.jar -> newt-event.jar - newt.driver.x11.jar -> newt-driver-x11.jar - newt.driver.win.jar -> newt-driver-win.jar - newt.driver.macosx.jar -> newt-driver-osx.jar - newt.driver.android.jar -> newt-driver-android.jar - newt.driver.kd.jar -> newt-driver-kd.jar - newt.driver.intelgdl.jar -> newt-driver-intelgdl.jar - newt.driver.broadcomegl.jar -> newt-driver-broadcomegl.jar Test JARs: - jogl.test.jar -> jogl-test.jar - jogl.test-android.jar -> jogl-test-android.jar - jogl.test-android.apk -> jogl-test-android.apk --- etc/profile.jogl | 14 +- jnlp-files/atomic/jogl-awt.jnlp | 54 ++-- jnlp-files/atomic/jogl-noawt.jnlp | 50 ++-- jnlp-files/atomic/nativewindow-awt.jnlp | 19 +- jnlp-files/atomic/nativewindow-noawt.jnlp | 30 ++- jnlp-files/atomic/newt-awt-jogl.jnlp | 36 +-- jnlp-files/atomic/newt-awt.jnlp | 34 +-- jnlp-files/atomic/newt-noawt-jogl.jnlp | 36 +-- jnlp-files/atomic/newt-noawt.jnlp | 30 +-- jnlp-files/jogl-all-awt-cg.jnlp | 36 +-- jnlp-files/jogl-all-awt.jnlp | 2 +- jnlp-files/jogl-all-mobile.jnlp | 2 +- jnlp-files/jogl-all-noawt.jnlp | 2 +- ...nner-newt-ElektronenMultiplizierer-napplet.html | 8 +- ...pplet-runner-newt-ElektronenMultiplizierer.html | 8 +- ...applet-runner-newt-GraphTextDemo01-napplet.html | 8 +- .../jogl-applet-runner-newt-GraphTextDemo01.html | 8 +- ...let-runner-newt-GraphUISceneDemo01-napplet.html | 8 +- ...jogl-applet-runner-newt-GraphUISceneDemo01.html | 8 +- .../jogl-applet-runner-newt-MovieCube-napplet.html | 8 +- jnlp-files/jogl-applet-runner-newt-MovieCube.html | 8 +- ...plet-runner-newt-gears-normal-launcheronly.html | 16 +- ...gl-applet-runner-newt-gears-normal-napplet.html | 18 +- ...l-applet-runner-newt-gears-normal-napplet2.html | 18 +- .../jogl-applet-runner-newt-gears-normal.html | 20 +- ...l-applet-runner-newt-gears-special-napplet.html | 8 +- .../jogl-applet-runner-newt-gears-special.html | 8 +- jnlp-files/jogl-applet-runner-newt.jnlp | 2 +- jnlp-files/jogl-applet-version-lancheronly.html | 4 +- jnlp-files/jogl-applet-version-napplet.html | 8 +- jnlp-files/jogl-applet-version.html | 4 +- make/build-common.xml | 287 +++++++++++---------- make/build-jogl.xml | 50 ++-- make/build-nativewindow.xml | 10 +- make/build-newt.xml | 22 +- make/build-test.xml | 14 +- make/build.xml | 18 +- make/scripts/setenv-jogl.sh | 4 +- make/scripts/tests.sh | 16 +- .../opengl/cg/CgDynamicLibraryBundleInfo.java | 4 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 28 +- .../jogamp/nativewindow/NWJNILibLoader.java | 4 +- src/newt/classes/jogamp/newt/NEWTJNILibLoader.java | 7 +- 43 files changed, 511 insertions(+), 468 deletions(-) (limited to 'make/scripts') diff --git a/etc/profile.jogl b/etc/profile.jogl index 1177aaa49..4402adde6 100755 --- a/etc/profile.jogl +++ b/etc/profile.jogl @@ -30,12 +30,12 @@ uname -a | grep -i LINUX && OSS=x11 uname -a | grep -i Darwin && OSS=osx uname -a | grep -i CYGWIN && OSS=win -JOGL_TEST="jogl.test.jar" +JOGL_TEST="jogl-test.jar" -JOGL_JAR_ALL="jogl.all.jar" -JOGL_JAR_ALL_NOAWT="jogl.all-noawt.jar" -JOGL_JAR_ALL_MOBILE="jogl.all-mobile.jar" -JOGL_JAR_SWT="atomic/jogl.swt.jar" +JOGL_JAR_ALL="jogl-all.jar" +JOGL_JAR_ALL_NOAWT="jogl-all-noawt.jar" +JOGL_JAR_ALL_MOBILE="jogl-all-mobile.jar" +JOGL_JAR_SWT="atomic/jogl-swt.jar" JOGL_LIB_ALL="libnativewindow_x11.so libnativewindow_awt.so libjogl_desktop.so libjogl_mobile.so libjogl_cg.so libnewt.so" JOGL_LIB_ALL_NOAWT="libnativewindow_x11.so libjogl_desktop.so libjogl_mobile.so libjogl_cg.so libnewt.so" @@ -76,8 +76,8 @@ export JOGL_LIB_DIR JOGL_ALL_AWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL $JOGL_TEST) JOGL_ALL_NOAWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_NOAWT $JOGL_TEST) -JOGL_MOBILE_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_MOBILE) -JOGL_SWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_SWT) +JOGL_MOBILE_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_MOBILE $JOGL_TEST) +JOGL_SWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_SWT $JOGL_TEST) export JOGL_ALL_AWT_CLASSPATH JOGL_ALL_NOAWT_CLASSPATH JOGL_MOBILE_CLASSPATH JOGL_SWT_CLASSPATH if [ ! -z "$JOGL_PROFILE" ] ; then diff --git a/jnlp-files/atomic/jogl-awt.jnlp b/jnlp-files/atomic/jogl-awt.jnlp index a33eb35a6..8f15a6c58 100644 --- a/jnlp-files/atomic/jogl-awt.jnlp +++ b/jnlp-files/atomic/jogl-awt.jnlp @@ -14,83 +14,83 @@ - - - - - - - - - - - + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/jnlp-files/atomic/jogl-noawt.jnlp b/jnlp-files/atomic/jogl-noawt.jnlp index 3463a1965..91a1fe89b 100644 --- a/jnlp-files/atomic/jogl-noawt.jnlp +++ b/jnlp-files/atomic/jogl-noawt.jnlp @@ -14,81 +14,81 @@ - - - - - - - - - + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/jnlp-files/atomic/nativewindow-awt.jnlp b/jnlp-files/atomic/nativewindow-awt.jnlp index db80b644f..a993ab14a 100644 --- a/jnlp-files/atomic/nativewindow-awt.jnlp +++ b/jnlp-files/atomic/nativewindow-awt.jnlp @@ -14,57 +14,72 @@ - - + + + + + + + + + + + + + + + + + diff --git a/jnlp-files/atomic/nativewindow-noawt.jnlp b/jnlp-files/atomic/nativewindow-noawt.jnlp index fed731042..5cd4872dc 100644 --- a/jnlp-files/atomic/nativewindow-noawt.jnlp +++ b/jnlp-files/atomic/nativewindow-noawt.jnlp @@ -14,68 +14,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + diff --git a/jnlp-files/atomic/newt-awt-jogl.jnlp b/jnlp-files/atomic/newt-awt-jogl.jnlp index 69406e43c..0a43128bb 100644 --- a/jnlp-files/atomic/newt-awt-jogl.jnlp +++ b/jnlp-files/atomic/newt-awt-jogl.jnlp @@ -14,50 +14,50 @@ - - - + + + - + - + - + - + - + - + - + - + - + - + @@ -65,23 +65,23 @@ - + - + - + - + - + diff --git a/jnlp-files/atomic/newt-awt.jnlp b/jnlp-files/atomic/newt-awt.jnlp index 26e45e3fc..6e46b82a4 100644 --- a/jnlp-files/atomic/newt-awt.jnlp +++ b/jnlp-files/atomic/newt-awt.jnlp @@ -14,71 +14,73 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - + diff --git a/jnlp-files/atomic/newt-noawt-jogl.jnlp b/jnlp-files/atomic/newt-noawt-jogl.jnlp index ced8b29c7..5b671edcd 100644 --- a/jnlp-files/atomic/newt-noawt-jogl.jnlp +++ b/jnlp-files/atomic/newt-noawt-jogl.jnlp @@ -14,73 +14,73 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/jnlp-files/atomic/newt-noawt.jnlp b/jnlp-files/atomic/newt-noawt.jnlp index 1616dff88..1161d7a9c 100644 --- a/jnlp-files/atomic/newt-noawt.jnlp +++ b/jnlp-files/atomic/newt-noawt.jnlp @@ -14,56 +14,56 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -73,11 +73,11 @@ - + - + diff --git a/jnlp-files/jogl-all-awt-cg.jnlp b/jnlp-files/jogl-all-awt-cg.jnlp index 18f8f498e..24c22c290 100644 --- a/jnlp-files/jogl-all-awt-cg.jnlp +++ b/jnlp-files/jogl-all-awt-cg.jnlp @@ -14,75 +14,75 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/jnlp-files/jogl-all-awt.jnlp b/jnlp-files/jogl-all-awt.jnlp index 55ae21d2a..4e05f8dac 100644 --- a/jnlp-files/jogl-all-awt.jnlp +++ b/jnlp-files/jogl-all-awt.jnlp @@ -14,7 +14,7 @@ - + diff --git a/jnlp-files/jogl-all-mobile.jnlp b/jnlp-files/jogl-all-mobile.jnlp index 5f96137c2..43b9b3b09 100644 --- a/jnlp-files/jogl-all-mobile.jnlp +++ b/jnlp-files/jogl-all-mobile.jnlp @@ -14,7 +14,7 @@ - + diff --git a/jnlp-files/jogl-all-noawt.jnlp b/jnlp-files/jogl-all-noawt.jnlp index 63f558d38..eed6749c1 100644 --- a/jnlp-files/jogl-all-noawt.jnlp +++ b/jnlp-files/jogl-all-noawt.jnlp @@ -14,7 +14,7 @@ - + diff --git a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html index 3b77157c6..19a3b2965 100644 --- a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer-napplet.html @@ -14,8 +14,8 @@ Demoscene Passivist's Elektronen-Multiplizierer width="640" height="480"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -28,8 +28,8 @@ Demoscene Passivist's Elektronen-Multiplizierer type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.ElektronenMultiplizierer" diff --git a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html index 2a500c9e6..71c9baff8 100644 --- a/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html +++ b/jnlp-files/jogl-applet-runner-newt-ElektronenMultiplizierer.html @@ -15,8 +15,8 @@ Demoscene Passivist's Elektronen-Multiplizierer + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -38,8 +38,8 @@ Demoscene Passivist's Elektronen-Multiplizierer pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="ElektronenMultiplizierer" diff --git a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01-napplet.html b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01-napplet.html index 59115ca36..9648b57da 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01-napplet.html @@ -14,8 +14,8 @@ JOGL Graph Text Demo 01 width="800" height="400"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -31,8 +31,8 @@ JOGL Graph Text Demo 01 type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.graph.demos.GPUTextGLListener0A" gl_profile="GL2ES2" diff --git a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01.html b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01.html index 1c7d3472b..489984b4f 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01.html @@ -15,8 +15,8 @@ JOGL Graph Text Demo 01 + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -41,8 +41,8 @@ JOGL Graph Text Demo 01 pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL Graph Text Demo01" diff --git a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html index 6efeefc10..8f9783f03 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01-napplet.html @@ -14,8 +14,8 @@ JOGL Graph UI-Scene Demo 01 width="640" height="480"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -30,8 +30,8 @@ JOGL Graph UI-Scene Demo 01 type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A" gl_profile="GL2ES2" diff --git a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html index 6b32b11e7..429e80311 100644 --- a/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html +++ b/jnlp-files/jogl-applet-runner-newt-GraphUISceneDemo01.html @@ -15,8 +15,8 @@ JOGL Graph UI-Scene Demo 01 + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -40,8 +40,8 @@ JOGL Graph UI-Scene Demo 01 pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL Graph UI Demo01" diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html index def7b72b9..f569c7c96 100644 --- a/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-MovieCube-napplet.html @@ -14,8 +14,8 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 width="510" height="300"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -28,8 +28,8 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube" diff --git a/jnlp-files/jogl-applet-runner-newt-MovieCube.html b/jnlp-files/jogl-applet-runner-newt-MovieCube.html index 6b1654ed7..7cb00244e 100644 --- a/jnlp-files/jogl-applet-runner-newt-MovieCube.html +++ b/jnlp-files/jogl-applet-runner-newt-MovieCube.html @@ -15,8 +15,8 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -38,8 +38,8 @@ JogAmp's MovieCube - GLMediaPlayer Demo 01 pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="MovieCube" diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html index 91e989346..a9e42d342 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-launcheronly.html @@ -21,8 +21,8 @@ JOGL NEWT JNLP Applet Runner Special Keys:
+ jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -43,8 +43,8 @@ JOGL NEWT JNLP Applet Runner Special Keys:
pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet" @@ -75,8 +75,8 @@ The applet above is instantiated with the following code: <param name="code" value="org.jdesktop.applet.util.JNLPAppletLauncher"> <param name="archive" value="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar"> + jar/jogl-all.jar, + jar/jogl-test.jar"> <param name="codebase_lookup" value="false"> <param name="subapplet.classname" value="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run"> <param name="subapplet.displayname" value="JOGL GearsES2 Applet"> @@ -97,8 +97,8 @@ The applet above is instantiated with the following code: pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet" diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html index 9db6d8cc2..37473befe 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet.html @@ -20,8 +20,8 @@ JOGL NEWT Applet Runner Special Keys:
width="200" height="200"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -34,8 +34,8 @@ JOGL NEWT Applet Runner Special Keys:
type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" @@ -58,8 +58,8 @@ The applet above is instantiated with the following code: width="200" height="200"> <param name="code" value="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run"> <param name="archive" value="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar"> + jar/jogl-all.jar, + jar/jogl-test.jar"> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2"> <param name="gl_profile" value="GL2ES2"> @@ -72,8 +72,8 @@ The applet above is instantiated with the following code: type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" @@ -90,7 +90,7 @@ The applet above is instantiated with the following code:

-Note that the jogl.test.jar, which contains the test applet class, +Note that the jogl-test.jar, which contains the test applet class, does not need to be signed! JogAmp Community signs jogl.jar and gluegen-rt.jar, which contain JOGL's supporting classes; this is the only diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html index ba2f69ef4..63df4ed60 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal-napplet2.html @@ -21,8 +21,8 @@ If Applet is out of browser window, it is closeable. width="200" height="200"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -36,8 +36,8 @@ If Applet is out of browser window, it is closeable. type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" @@ -61,8 +61,8 @@ The applet above is instantiated with the following code: width="200" height="200"> <param name="code" value="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run"> <param name="archive" value="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar"> + jar/jogl-all.jar, + jar/jogl-test.jar"> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> <param name="gl_event_listener_class" value="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2"> <param name="gl_profile" value="GL2ES2"> @@ -76,8 +76,8 @@ The applet above is instantiated with the following code: type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" @@ -95,7 +95,7 @@ The applet above is instantiated with the following code:

-Note that the jogl.test.jar, which contains the test applet class, +Note that the jogl-test.jar, which contains the test applet class, does not need to be signed! JogAmp Community signs jogl.jar and gluegen-rt.jar, which contain JOGL's supporting classes; this is the only diff --git a/jnlp-files/jogl-applet-runner-newt-gears-normal.html b/jnlp-files/jogl-applet-runner-newt-gears-normal.html index c8d654dbc..a6dd16a0c 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-normal.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-normal.html @@ -35,8 +35,8 @@ JOGL NEWT JNLP Applet Runner Special Keys:
+ jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -58,8 +58,8 @@ JOGL NEWT JNLP Applet Runner Special Keys:
pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet" @@ -91,8 +91,8 @@ The applet above is instantiated with the following code: <param name="code" value="org.jdesktop.applet.util.JNLPAppletLauncher"> <param name="archive" value="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar"> + jar/jogl-all.jar, + jar/jogl-test.jar"> <param name="codebase_lookup" value="false"> <param name="subapplet.classname" value="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run"> <param name="subapplet.displayname" value="JOGL GearsES2 Applet"> @@ -114,8 +114,8 @@ The applet above is instantiated with the following code: pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet" @@ -154,7 +154,7 @@ Where the referenced JNLP file jogl-applet-runner-newt.jnlp looks as fo <resources> <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/> <property name="sun.java2d.noddraw" value="true"/> - <jar href="jar/jogl.test.jar" main="true"/> + <jar href="jar/jogl-test.jar" main="true"/> <extension name="jogl-all-awt" href="http://jogamp.org/deployment/jogamp-current/jogl-all-awt.jnlp" /> </resources> @@ -170,7 +170,7 @@ Where the referenced JNLP file jogl-applet-runner-newt.jnlp looks as fo

-Note that the jogl.test.jar, which contains the test applet class, +Note that the jogl-test.jar, which contains the test applet class, does not need to be signed! JogAmp Community signs applet-launcher.jar, jogl.jar and gluegen-rt.jar, which contain the JNLPAppletLauncher and JOGL's supporting classes; this is the only diff --git a/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html b/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html index 3c1895b45..7df167844 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-special-napplet.html @@ -11,8 +11,8 @@ JOGL NEWT JNLP Applet Runner Special Keys: width="1" height="1"> + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -32,8 +32,8 @@ JOGL NEWT JNLP Applet Runner Special Keys: type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" java_arguments="-Dsun.java2d.noddraw=true" gl_event_listener_class="com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2" gl_profile="GL2ES2" diff --git a/jnlp-files/jogl-applet-runner-newt-gears-special.html b/jnlp-files/jogl-applet-runner-newt-gears-special.html index dcbe898e2..0f5911414 100644 --- a/jnlp-files/jogl-applet-runner-newt-gears-special.html +++ b/jnlp-files/jogl-applet-runner-newt-gears-special.html @@ -12,8 +12,8 @@ JOGL NEWT JNLP Applet Runner Special Keys: + jar/jogl-all.jar, + jar/jogl-test.jar"> @@ -42,8 +42,8 @@ JOGL NEWT JNLP Applet Runner Special Keys: pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar, - jar/jogl.test.jar" + jar/jogl-all.jar, + jar/jogl-test.jar" codebase_lookup" value="false" subapplet.classname="com.jogamp.newt.awt.applet.JOGLNewtApplet1Run" subapplet.displayname="JOGL GearsES2 Applet Transparent" diff --git a/jnlp-files/jogl-applet-runner-newt.jnlp b/jnlp-files/jogl-applet-runner-newt.jnlp index 259e39f18..c33e1b761 100644 --- a/jnlp-files/jogl-applet-runner-newt.jnlp +++ b/jnlp-files/jogl-applet-runner-newt.jnlp @@ -12,7 +12,7 @@ - + diff --git a/jnlp-files/jogl-applet-version-lancheronly.html b/jnlp-files/jogl-applet-version-lancheronly.html index 685d9115c..6880152fc 100644 --- a/jnlp-files/jogl-applet-version-lancheronly.html +++ b/jnlp-files/jogl-applet-version-lancheronly.html @@ -20,7 +20,7 @@ and your platform. + jar/jogl-all.jar"> @@ -36,7 +36,7 @@ and your platform. pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar" + jar/jogl-all.jar" codebase_lookup" value="false" subapplet.classname="jogamp.opengl.awt.VersionApplet" subapplet.displayname="JOGL Applet Version" diff --git a/jnlp-files/jogl-applet-version-napplet.html b/jnlp-files/jogl-applet-version-napplet.html index e8104cb60..aeccb710a 100644 --- a/jnlp-files/jogl-applet-version-napplet.html +++ b/jnlp-files/jogl-applet-version-napplet.html @@ -16,7 +16,7 @@ and your platform. width="800" height="600"> + jar/jogl-all.jar"> Sorry, no Java support detected. @@ -41,7 +41,7 @@ The applet above is instantiated with the following code: width="800" height="600"> <param name="code" value="jogamp.opengl.awt.VersionApplet"> <param name="archive" value="jar/gluegen-rt.jar, - jar/jogl.all.jar"> + jar/jogl-all.jar"> <param name="java_arguments" value="-Dsun.java2d.noddraw=true"> <comment> <embed code="jogamp.opengl.awt.VersionApplet" @@ -49,7 +49,7 @@ The applet above is instantiated with the following code: type="application/x-java-applet;version=1.6" pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/gluegen-rt.jar, - jar/jogl.all.jar" + jar/jogl-all.jar" java_arguments="-Dsun.java2d.noddraw=true"> <noembed>Sorry, no Java support detected.</noembed> </embed> diff --git a/jnlp-files/jogl-applet-version.html b/jnlp-files/jogl-applet-version.html index 5b738964e..948e63095 100644 --- a/jnlp-files/jogl-applet-version.html +++ b/jnlp-files/jogl-applet-version.html @@ -22,7 +22,7 @@ otherwise it shall fallback to + jar/jogl-all.jar"> @@ -39,7 +39,7 @@ otherwise it shall fallback to pluginspage="http://java.sun.com/javase/downloads/ea.jsp" archive="jar/applet-launcher.jar, jar/gluegen-rt.jar, - jar/jogl.all.jar" + jar/jogl-all.jar" codebase_lookup" value="false" subapplet.classname="jogamp.opengl.awt.VersionApplet" subapplet.displayname="JOGL Applet Version" diff --git a/make/build-common.xml b/make/build-common.xml index 93835e0f1..b2885c8af 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -250,167 +250,168 @@ - - - - - + + + + + - - - - - + + + + + - - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - + ${jogl-core.jar} ${jogl-glutess.jar} ${jogl-glumipmap.jar} ${jogl-glu-gldesktop.jar} ${jogl-os-x11.jar} ${jogl-os-win.jar} ${jogl-os-osx.jar} ${jogl-gldesktop.jar} ${jogl-gldesktop-dbg.jar} ${jogl-glmobile.jar} ${jogl-glmobile-dbg.jar} ${jogl-omx.jar} ${jogl-util.jar} ${jogl-util-gldesktop.jar} ${jogl-util-awt.jar} ${jogl-util-fixedfuncemu.jar} ${jogl-sdk.jar} --> + + + + + + + + + + + + - - - - - - + + + + + + - - - - - + + + + + - - - - + + + + - - - + + + - - - + + + - + - - - - + + + + @@ -477,7 +478,7 @@ - + @@ -486,12 +487,12 @@ - - + + - + value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${jogl-all.jar}${path.separator}${jogl-test.jar}"/> + @@ -499,12 +500,12 @@ - - + + - + value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${jogl-all-noawt.jar}${path.separator}${jogl-test.jar}"/> + @@ -513,11 +514,11 @@ - - + + + value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt.jar}${path.separator}${swt.jar}${path.separator}${jogl-all.jar}${path.separator}${jogl-test.jar}"/> @@ -526,13 +527,13 @@ - - + + + value="${junit.jar}${path.separator}${ant.jar}${path.separator}${ant-junit.jar}${path.separator}${gluegen-rt-android.jar}${path.separator}${jogl-all-android.jar}${path.separator}${jogl-test.jar}"/> + value="${gluegen.root}/${rootrel.build}/jogamp.android-launcher.apk${path.separator}${ant-junit-all.apk}${path.separator}${gluegen.root}/${rootrel.build}/gluegen-rt-android-${android.abi}.apk${path.separator}${jogl-all-android.apk}${path.separator}${jogl-test.apk}"/> diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 0c7328c4a..6845354f6 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1550,7 +1550,7 @@ + includes="${jogl-util.jar} ${jogl-util-fixedfuncemu.jar}" /> @@ -1570,48 +1570,48 @@ - + - + - + - + - + - + - + - + - + @@ -1619,22 +1619,22 @@ - + - + - + - + @@ -1643,50 +1643,50 @@ - + - + - + - + - + - + - + - + - + - + - + diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index 233108823..c77558d6b 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -820,7 +820,7 @@ - + @@ -828,28 +828,28 @@ - + - + - + - + diff --git a/make/build-newt.xml b/make/build-newt.xml index 695c86d19..a6be5042e 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -701,52 +701,52 @@ - + - + - + - + - + - + - + - + - + - + @@ -759,7 +759,7 @@ - + diff --git a/make/build-test.xml b/make/build-test.xml index f5437902e..51eadfebd 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -51,7 +51,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -121,7 +121,7 @@ - + @@ -134,7 +134,7 @@ assetsdir="resources/assets-test" jarsrcdir="${src}/test" jarbuilddir="${jar}" - jarbasename="jogl.test-android" + jarbasename="jogl-test-android" nativebuilddir="${lib}" nativebasename="non-existing" androidmanifest.path="resources/android/AndroidManifest-test.xml" @@ -149,8 +149,8 @@ - - + + @@ -159,7 +159,7 @@ - + diff --git a/make/build.xml b/make/build.xml index 9258df0e9..23aa218b4 100644 --- a/make/build.xml +++ b/make/build.xml @@ -99,7 +99,7 @@ - + @@ -111,7 +111,7 @@ - + @@ -120,7 +120,7 @@ - + @@ -129,7 +129,7 @@ - + @@ -147,8 +147,8 @@ - - + + @@ -158,7 +158,7 @@ assetsdir="resources/assets" jarsrcdir="${src}/jogl/classes" jarbuilddir="${jar}" - jarbasename="jogl.all-android" + jarbasename="jogl-all-android" nativebuilddir="${lib}" nativebasename="" android.abi="${android.abi}" @@ -173,12 +173,12 @@ - + - + diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh index 2d91f278f..4067e65c9 100755 --- a/make/scripts/setenv-jogl.sh +++ b/make/scripts/setenv-jogl.sh @@ -93,8 +93,8 @@ CLASSPATH=.:$GLUEGEN_JAR:$JOGL_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS export CLASSPATH # We use TempJarCache per default now! -#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR -#export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR +export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR echo JOGAMP_ALL_AWT_CLASSPATH: $CLASSPATH echo JOGAMP_ALL_NOAWT_CLASSPATH: $CLASSPATH diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 702b0dc8c..8f4237012 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -69,11 +69,11 @@ function jrun() { #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=600000" #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" - #D_ARGS="-Djogl.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" @@ -120,11 +120,9 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" - #D_ARGS="-Djogamp.debug.JARUtil" - #D_ARGS="-Djogamp.debug.TempFileCache" - #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.JARUtil" - #D_ARGS="-Djogamp.debug.JNILibLoader" - #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.gluegen.UseTempJarCache=false -Djogamp.debug.JARUtil" + #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.gluegen.UseTempJarCache=false" #D_ARGS="-Dnewt.test.EDTMainThread -Dnewt.debug.MainThread" #C_ARG="com.jogamp.newt.util.MainThread" #D_ARGS="-Dnewt.debug.MainThread" @@ -143,6 +141,8 @@ function jrun() { X_ARGS="-Djava.awt.headless=false $X_ARGS" else export CLASSPATH=$JOGAMP_ALL_NOAWT_CLASSPATH + #export CLASSPATH=$JOGAMP_MOBILE_CLASSPATH + #export CLASSPATH=.:$GLUEGEN_JAR:$JOGL_BUILD_DIR/jar/atomic/jogl-core.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-gldesktop.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-os-x11.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-util.jar:$JOGL_BUILD_DIR/jar/atomic/nativewindow-core.jar:$JOGL_BUILD_DIR/jar/atomic/nativewindow-os-x11.jar:$JOGL_BUILD_DIR/jar/atomic/newt-core.jar:$JOGL_BUILD_DIR/jar/atomic/newt-driver-x11.jar:$JOGL_BUILD_DIR/jar/atomic/newt-ogl.jar:$JOGL_BUILD_DIR/jar/jogl-test.jar:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS X_ARGS="-Djava.awt.headless=true $X_ARGS" fi if [ $swton -eq 1 ] ; then @@ -332,8 +332,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* -testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java index d901096bc..d160eccff 100644 --- a/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/com/jogamp/opengl/cg/CgDynamicLibraryBundleInfo.java @@ -47,8 +47,8 @@ public class CgDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { Platform.initSingleton(); if(TempJarCache.isInitialized()) { - // Cg class and natives are available in their single atomic JAR files only - JNILibLoaderBase.addNativeJarLibs(CgDynamicLibraryBundleInfo.class, "jogl_cg", null); + // only: jogl-cg.jar -> jogl-cg-natives-.jar [atomic JAR files only] + JNILibLoaderBase.addNativeJarLibs(new Class[] { CgDynamicLibraryBundleInfo.class }, null, null ); } return null; } diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index f85c6ba23..ed457b0ea 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -37,6 +37,7 @@ package javax.media.opengl; +import jogamp.nativewindow.NWJNILibLoader; import jogamp.opengl.Debug; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.DesktopGLDynamicLookupHelper; @@ -133,11 +134,17 @@ public class GLProfile { Platform.initSingleton(); if(TempJarCache.isInitialized()) { - String[] atomicNativeJarBaseNames = new String[] { "nativewindow", "jogl", null }; - if( ReflectionUtil.isClassAvailable("com.jogamp.newt.NewtFactory", GLProfile.class.getClassLoader()) ) { - atomicNativeJarBaseNames[2] = "newt"; + final ClassLoader cl = GLProfile.class.getClassLoader(); + // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar + // or: nativewindow-core.jar -> nativewindow-natives-.jar, + // jogl-core.jar -> jogl-natives-.jar, + // (newt-core.jar -> newt-natives-.jar)? (if available) + final String newtFactoryClassName = "com.jogamp.newt.NewtFactory"; + final Class[] classesFromJavaJars = new Class[] { NWJNILibLoader.class, GLProfile.class, null }; + if( ReflectionUtil.isClassAvailable(newtFactoryClassName, cl) ) { + classesFromJavaJars[2] = ReflectionUtil.getClass(newtFactoryClassName, false, cl); } - JNILibLoaderBase.addNativeJarLibs(GLProfile.class, "jogl-all", atomicNativeJarBaseNames); + JNILibLoaderBase.addNativeJarLibs(classesFromJavaJars, "-all", new String[] { "-noawt", "-mobile", "-core" } ); } initProfilesForDefaultDevices(firstUIActionOnProcess); return null; @@ -1497,8 +1504,10 @@ public class GLProfile { System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl); System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl); System.err.println("GLProfile.init defaultDevice "+defaultDevice); - System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL)); - System.err.println(JoglVersion.getDefaultOpenGLInfo(null)); + System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL)); + if(hasGL234Impl || hasGLES1Impl || hasGLES2Impl) { // avoid deadlock + System.err.println(JoglVersion.getDefaultOpenGLInfo(null)); + } } } @@ -1527,7 +1536,7 @@ public class GLProfile { boolean isSet = GLContext.getAvailableGLVersionsSet(device); if(DEBUG) { - System.err.println("Info: GLProfile.initProfilesForDevice: "+device+", isSet "+isSet); + System.err.println("Info: GLProfile.initProfilesForDevice: "+device+" ("+device.getClass().getName()+"), isSet "+isSet+", hasDesktopGLFactory "+hasDesktopGLFactory+", hasEGLFactory "+hasEGLFactory); } if(isSet) { // Avoid recursion and check whether impl. is sane! @@ -1901,9 +1910,14 @@ public class GLProfile { { initSingleton(); + if(null==defaultDevice) { // avoid NPE and notify of incomplete initialization + throw new GLException("No default device available"); + } + if(null==device) { device = defaultDevice; } + final String deviceKey = device.getUniqueID(); HashMap map = deviceConn2ProfileMap.get(deviceKey); if( null != map ) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java index 99bc71c4a..6c15f9a2b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NWJNILibLoader.java @@ -44,7 +44,9 @@ public class NWJNILibLoader extends JNILibLoaderBase { Platform.initSingleton(); final String libName = "nativewindow_"+ossuffix ; if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) { - addNativeJarLibs(NWJNILibLoader.class, "jogl-all", new String[] { "nativewindow" } ); + // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar + // or: nativewindow-core.jar -> nativewindow-natives-.jar + addNativeJarLibs(new Class[] { NWJNILibLoader.class }, "-all", new String[] { "-noawt", "-mobile", "-core" } ); } return new Boolean(loadLibrary(libName, false, NWJNILibLoader.class.getClassLoader())); } diff --git a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java index 2db9d8d05..bc0eb7531 100644 --- a/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java +++ b/src/newt/classes/jogamp/newt/NEWTJNILibLoader.java @@ -42,6 +42,8 @@ package jogamp.newt; import java.security.AccessController; import java.security.PrivilegedAction; +import jogamp.nativewindow.NWJNILibLoader; + import com.jogamp.common.jvm.JNILibLoaderBase; import com.jogamp.common.os.Platform; import com.jogamp.common.util.cache.TempJarCache; @@ -54,7 +56,10 @@ public class NEWTJNILibLoader extends JNILibLoaderBase { Platform.initSingleton(); final String libName = "newt"; if(TempJarCache.isInitialized() && null == TempJarCache.findLibrary(libName)) { - addNativeJarLibs(NEWTJNILibLoader.class, "jogl-all", new String[] { "nativewindow", "newt" } ); + // either: [jogl-all.jar, jogl-all-noawt.jar, jogl-all-mobile.jar] -> jogl-all-natives-.jar + // or: nativewindow-core.jar -> nativewindow-natives-.jar, + // newt-core.jar -> newt-natives-.jar + JNILibLoaderBase.addNativeJarLibs(new Class[] { NWJNILibLoader.class, NEWTJNILibLoader.class }, "-all", new String[] { "-noawt", "-mobile", "-core" } ); } loadLibrary(libName, false, NEWTJNILibLoader.class.getClassLoader()); return null; -- cgit v1.2.3 From e51542375c4f736c396fd5a38288dd5129a09268 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 26 Jun 2012 12:36:58 +0200 Subject: Complete Bug #598 - Commit a393e45613d87101dbb13763df263c2f9291d2d0 --- make/build-common.xml | 2 +- make/scripts/adb-install-all-armv7.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/build-common.xml b/make/build-common.xml index b2885c8af..8d440a766 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -470,7 +470,7 @@ - + diff --git a/make/scripts/adb-install-all-armv7.sh b/make/scripts/adb-install-all-armv7.sh index fe9765541..f0a1dc522 100755 --- a/make/scripts/adb-install-all-armv7.sh +++ b/make/scripts/adb-install-all-armv7.sh @@ -1,4 +1,4 @@ -#adb $* install ../../gluegen/build-android-armv7/jogamp.android-launcher.apk +#adb $* install ../../gluegen/build-android-armv7/jogamp-android-launcher.apk #adb $* install ../../gluegen/build-android-armv7/gluegen-rt-android-armeabi-v7a.apk -adb $* install ../build-android-armv7/jar/jogl.all-android-armeabi-v7a.apk -adb $* install ../build-android-armv7/jar/jogl.test-android.apk +adb $* install ../build-android-armv7/jar/jogl-all-android-armeabi-v7a.apk +adb $* install ../build-android-armv7/jar/jogl-test-android.apk -- cgit v1.2.3 From 1a91ec5c8b6fd9d9db7bc115569c369fe7b38e9b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Jun 2012 21:22:30 +0200 Subject: SWT GLCanvas: Fix destroy(), Remove local concurrency hack & out-of-process locking ; Revise threading code; Proper name for SWT unit tests. SWT GLCanvas: - Fix destroy() drawable.setRealized(false); is being called within dispose() method - Remove local concurrency hack [MT-0] The hack: 'final GLContext ctx = getContext(); a = null != ctx ? ctx.something() : 0;' is thread safe locally, however, w/o covering the hole use case of the caller it makes no sense to add thread safe code here - would be only an illusion. In case any of the methods are called outside of a locked state extra care should be added. Maybe we shall expose locking facilities to the user. However, since the user shall stick to the GLEventListener model while utilizing GLAutoDrawable implementations, she is safe due to the implicit locked state. - Removing out-of-process locking [MT-1] Claiming the recursive lock in the dispose/display/.. methods and _then_ issuing a complex off-thread GL task could lead to deadlock. The GL task could involve calling GLEventListener methods, which itself could try to manipulate the GLCanvas -> deadlock. Similar to [MT-0] we may need to either find a proper locking mechanism or simply ignore it and reduce functionality. TBH .. the number of scenarious of the mentioned deadlock are very limited and exotic. - Revise threading code [MT-2] Besides the other MT-* remarks, the logic whether to spawn off the GL task and determination which thread to use is too complex and redundant. (See isRenderThread(), runInGLThread() and runInDesignatedGLThread()) - Proper name for SWT unit tests. Reflect the semantics. --- make/scripts/tests.sh | 13 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 216 +++++++++++---------- .../test/junit/jogl/swt/TestSWTAWT01GLn.java | 195 ------------------- .../junit/jogl/swt/TestSWTAccessor03AWTGLn.java | 195 +++++++++++++++++++ .../junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java | 174 +++++++++++++++++ .../jogl/swt/TestSWTJOGLGLCanvas01GLnAWT.java | 174 ----------------- 6 files changed, 488 insertions(+), 479 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLnAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8f4237012..7a3e74558 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -86,8 +86,8 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.X11Util.TraceDisplayLifecycle=true -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" + D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" - #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnativewindow.debug.X11Util" #D_ARGS="-Dnewt.debug.EDT -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator -Dnewt.debug.Display -Dnewt.debug.Screen" @@ -282,16 +282,14 @@ function testawtswt() { # # swt (testswt) # -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn $* -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn $* -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTGLCanvas01GLn $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* +testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $* # # awtswt (testawtswt) # -#testawt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT01GLn $* -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLnAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* # # newt.awt (testawt) @@ -333,7 +331,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 73ad97f5c..6fe9e33f6 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -63,17 +63,22 @@ import org.eclipse.swt.widgets.Shell; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.opengl.JoglVersion; /** * Native SWT Canvas implementing GLAutoDrawable *

- * FIXME: Still needs AWT for threading impl., + * FIXME: Still needs AWT for threading impl., * ie. will issue a 'wrong thread' error if runs in headless mode! *

+ *

+ * FIXME: If this instance runs in multithreading mode, see {@link Threading#isSingleThreaded()} (impossible), + * proper recursive locking is required for drawable/context @ destroy and display. + * Recreation etc could pull those instances while animating! + * Simply locking before using drawable/context offthread + * would allow a deadlock situation! + *

*/ public class GLCanvas extends Canvas implements GLAutoDrawable { @@ -81,17 +86,17 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * Flag for whether the SWT thread should be used for OpenGL calls when in single-threaded mode. This is controlled * by the setting of the threading mode to worker (do not use SWT thread), awt (use SWT thread), or false (always use * calling thread). - * + * * @see Threading - * + * * Now done dynamically to avoid early loading of gluegen library. */ //private static final boolean useSWTThread = ThreadingImpl.getMode() != ThreadingImpl.WORKER; /* GL Stuff */ private final GLDrawableHelper drawableHelper = new GLDrawableHelper(); - private GLDrawable drawable; - private GLContext context; + private volatile GLDrawable drawable; // volatile avoids locking all accessors. FIXME still need to sync destroy/display + private volatile GLContext context; // volatile avoids locking all accessors. FIXME still need to sync destroy/display /* Native window surface */ private AbstractGraphicsDevice device; @@ -100,13 +105,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* Construction parameters stored for GLAutoDrawable accessor methods */ private int ctxCreationFlags = 0; - - private final GLCapabilitiesImmutable glCapsRequested; - /* - * Lock for access to GLDrawable, as used in GLCanvas, - */ - private final RecursiveLock lock = LockFactory.createRecursiveLock(); + private final GLCapabilitiesImmutable glCapsRequested; /* Flag indicating whether an unprocessed reshape is pending. */ private volatile boolean sendReshape; @@ -115,6 +115,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * Invokes init(...) on all GLEventListeners. Assumes context is current when run. */ private final Runnable initAction = new Runnable() { + @Override public void run() { drawableHelper.init(GLCanvas.this); } @@ -122,10 +123,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* * Action to handle display in OpenGL, also processes reshape since they should be done at the same time. - * + * * Assumes GLContext is current when run. */ private final Runnable displayAction = new Runnable() { + @Override public void run() { if (sendReshape) { drawableHelper.reshape(GLCanvas.this, 0, 0, getWidth(), getHeight()); @@ -137,6 +139,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* Action to make specified context current prior to running displayAction */ private final Runnable makeCurrentAndDisplayAction = new Runnable() { + @Override public void run() { drawableHelper.invokeGL(drawable, context, displayAction, initAction); } @@ -144,6 +147,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* Swaps buffers, assuming the GLContext is current */ private final Runnable swapBuffersAction = new Runnable() { + @Override public void run() { drawable.swapBuffers(); } @@ -151,6 +155,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* Swaps buffers, making the GLContext current first */ private final Runnable makeCurrentAndSwapBuffersAction = new Runnable() { + @Override public void run() { drawableHelper.invokeGL(drawable, context, swapBuffersAction, initAction); } @@ -160,8 +165,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * Disposes of OpenGL resources */ private final Runnable postDisposeGLAction = new Runnable() { + @Override public void run() { - context = null; + context = null; if (null != drawable) { drawable.setRealized(false); drawable = null; @@ -170,12 +176,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }; private final Runnable disposeOnEDTGLAction = new Runnable() { + @Override public void run() { drawableHelper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); } }; private final Runnable disposeGraphicsDeviceAction = new Runnable() { + @Override public void run() { if (null != device) { device.close(); @@ -191,7 +199,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /** * Creates a new SWT GLCanvas. - * + * * @param parent * Required (non-null) parent Composite. * @param style @@ -211,7 +219,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final GLCapabilitiesChooser chooser, final GLContext shareWith) { /* NO_BACKGROUND required to avoid clearing bg in native SWT widget (we do this in the GL display) */ super(parent, style | SWT.NO_BACKGROUND); - + GLProfile.initSingleton(); // ensure JOGL is completly initialized SWTAccessor.setRealized(this, true); @@ -228,7 +236,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { caps = new GLCapabilities(GLProfile.getDefault(device)); } glCapsRequested = caps; - + final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile()); /* Create a NativeWindow proxy for the SWT canvas */ @@ -239,17 +247,18 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { drawable.setRealized(true); context = drawable.createContext(shareWith); - + /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ addPaintListener(new PaintListener() { - public void paintControl(final PaintEvent arg0) { + @Override + public void paintControl(final PaintEvent arg0) { if (!drawableHelper.isExternalAnimatorAnimating()) { display(); } } }); - + addControlListener(new ControlAdapter() { @Override public void controlResized(final ControlEvent arg0) { @@ -260,211 +269,206 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }); } + @Override public void addGLEventListener(final GLEventListener arg0) { drawableHelper.addGLEventListener(arg0); } + @Override public void addGLEventListener(final int arg0, final GLEventListener arg1) throws IndexOutOfBoundsException { drawableHelper.addGLEventListener(arg0, arg1); } /** * {@inheritDoc} + * *

- * Also disposes of the SWT component. + * This impl. calls this class's {@link #dispose()} SWT override, + * where the actual implementation resides. + *

*/ + @Override public void destroy() { - drawable.setRealized(false); dispose(); } + @Override public void display() { runInGLThread(makeCurrentAndDisplayAction, displayAction); } + @Override public GLAnimatorControl getAnimator() { return drawableHelper.getAnimator(); } + @Override public boolean getAutoSwapBufferMode() { return drawableHelper.getAutoSwapBufferMode(); } + @Override public GLContext getContext() { return context; } + @Override public int getContextCreationFlags() { return ctxCreationFlags; } + @Override public GL getGL() { - final GLContext ctx = getContext(); - return (ctx == null) ? null : ctx.getGL(); + return (null == context) ? null : context.getGL(); } + @Override public void invoke(final boolean wait, final GLRunnable run) { /* Queue task for running during the next display(). */ drawableHelper.invoke(this, wait, run); } + @Override public void removeGLEventListener(final GLEventListener arg0) { drawableHelper.removeGLEventListener(arg0); } + @Override public void setAnimator(final GLAnimatorControl arg0) throws GLException { drawableHelper.setAnimator(arg0); } + @Override public void setAutoSwapBufferMode(final boolean arg0) { drawableHelper.setAutoSwapBufferMode(arg0); } + @Override public void setContext(final GLContext ctx) { - this.context = ctx; if (ctx instanceof GLContextImpl) { ((GLContextImpl) ctx).setContextCreationFlags(ctxCreationFlags); } + this.context = ctx; } + @Override public void setContextCreationFlags(final int arg0) { ctxCreationFlags = arg0; } + @Override public GL setGL(final GL arg0) { - final GLContext ctx = getContext(); - if (ctx != null) { - ctx.setGL(arg0); + if (null != context) { + context.setGL(arg0); return arg0; } return null; } + @Override public GLContext createContext(final GLContext arg0) { - lock.lock(); - try { - final GLDrawable drawable = this.drawable; - return (drawable != null) ? drawable.createContext(arg0) : null; - } finally { - lock.unlock(); - } + return (drawable != null) ? drawable.createContext(arg0) : null; } + @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { return (GLCapabilitiesImmutable)proxySurface.getGraphicsConfiguration().getChosenCapabilities(); } /** * Accessor for the GLCapabilities that were requested (via the constructor parameter). - * + * * @return Non-null GLCapabilities. */ public GLCapabilitiesImmutable getRequestedGLCapabilities() { return (GLCapabilitiesImmutable)proxySurface.getGraphicsConfiguration().getRequestedCapabilities(); } + @Override public GLDrawableFactory getFactory() { - lock.lock(); - try { - final GLDrawable drawable = this.drawable; - return (drawable != null) ? drawable.getFactory() : null; - } finally { - lock.unlock(); - } + return (drawable != null) ? drawable.getFactory() : null; } + @Override public GLProfile getGLProfile() { return glCapsRequested.getGLProfile(); } + @Override public long getHandle() { - lock.lock(); - try { - final GLDrawable drawable = this.drawable; - return (drawable != null) ? drawable.getHandle() : 0; - } finally { - lock.unlock(); - } + return (drawable != null) ? drawable.getHandle() : 0; } + @Override public int getHeight() { final Rectangle clientArea = this.clientArea; if (clientArea == null) return 0; return clientArea.height; } + @Override public NativeSurface getNativeSurface() { - lock.lock(); - try { - final GLDrawable drawable = this.drawable; - return (drawable != null) ? drawable.getNativeSurface() : null; - } finally { - lock.unlock(); - } + return (drawable != null) ? drawable.getNativeSurface() : null; } + @Override public int getWidth() { final Rectangle clientArea = this.clientArea; if (clientArea == null) return 0; return clientArea.width; } + @Override public boolean isRealized() { - lock.lock(); - try { - final GLDrawable drawable = this.drawable; - return (drawable != null) ? drawable.isRealized() : false; - } finally { - lock.unlock(); - } + return (drawable != null) ? drawable.isRealized() : false; } + @Override public void setRealized(final boolean arg0) { /* Intentionally empty */ } + @Override public void swapBuffers() throws GLException { runInGLThread(makeCurrentAndSwapBuffersAction, swapBuffersAction); } // FIXME: API of update() method ? + @Override public void update() { // FIXME: display(); } + @Override public void dispose() { - lock.lock(); - try { - final Display display = getDisplay(); - - if (null != context) { - boolean animatorPaused = false; - final GLAnimatorControl animator = getAnimator(); - if (null != animator) { - // can't remove us from animator for recreational addNotify() - animatorPaused = animator.pause(); - } - if(context.isCreated()) { - if (Threading.isSingleThreaded() && !Threading.isOpenGLThread()) { - runInDesignatedGLThread(disposeOnEDTGLAction); - } else if (context.isCreated()) { - drawableHelper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); - } + if (null != context) { + boolean animatorPaused = false; + final GLAnimatorControl animator = getAnimator(); + if (null != animator) { + // can't remove us from animator for recreational addNotify() + animatorPaused = animator.pause(); + } + + if(context.isCreated()) { + if (Threading.isSingleThreaded() && !Threading.isOpenGLThread()) { + runInDesignatedGLThread(disposeOnEDTGLAction); + } else if (context.isCreated()) { + drawableHelper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); } + } - if (animatorPaused) { - animator.resume(); - } - } - if (display.getThread() == Thread.currentThread()) { - disposeGraphicsDeviceAction.run(); - } else { - display.syncExec(disposeGraphicsDeviceAction); - } - } finally { - lock.unlock(); - } - super.dispose(); + if (animatorPaused) { + animator.resume(); + } + } + final Display display = getDisplay(); + + if (display.getThread() == Thread.currentThread()) { + disposeGraphicsDeviceAction.run(); + } else { + display.syncExec(disposeGraphicsDeviceAction); + } + super.dispose(); } /** @@ -473,8 +477,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * OpenGL worker thread depending on the state of {@link #useSWTThread}. Otherwise this always returns true because * the threading model is user defined. *

- * TODO: should this be moved to {@link Threading}? - * + * FIXME: Redundant .. remove! Merge isRenderThread, runInGLThread and runInDesignatedGLThread + * * @return true if the calling thread is the correct thread to execute OpenGL calls in, false otherwise. */ protected boolean isRenderThread() { @@ -494,13 +498,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /** * Runs the specified action in the designated OpenGL thread. If the current thread is designated, then the * syncAction is run synchronously, otherwise the asyncAction is dispatched to the appropriate worker thread. - * + * * @param asyncAction * The non-null action to dispatch to an OpenGL worker thread. This action should not assume that a * GLContext is current when invoked. * @param syncAction * The non-null action to run synchronously if the current thread is designated to handle OpenGL calls. * This action may assume the GLContext is current. + * FIXME: Redundant .. remove! Merge isRenderThread, runInGLThread and runInDesignatedGLThread */ private void runInGLThread(final Runnable asyncAction, final Runnable syncAction) { if (Threading.isSingleThreaded() && !isRenderThread()) { @@ -515,9 +520,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /** * Dispatches the specified runnable to the appropriate OpenGL worker thread (either the SWT event dispatch thread, * or the OpenGL worker thread depending on the state of {@link #useSWTThread}). - * + * * @param makeCurrentAndRunAction * The non-null action to dispatch. + * FIXME: Redundant .. remove! Merge isRenderThread, runInGLThread and runInDesignatedGLThread */ private void runInDesignatedGLThread(final Runnable makeCurrentAndRunAction) { if (ThreadingImpl.getMode() != ThreadingImpl.Mode.ST_WORKER) { @@ -529,7 +535,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } } - + public static void main(final String[] args) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); @@ -537,7 +543,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { System.err.println(JoglVersion.getInstance()); System.err.println(JoglVersion.getDefaultOpenGLInfo(null).toString()); - + final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDevice()) ); final Display display = new Display(); final Shell shell = new Shell(display); @@ -547,13 +553,17 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final GLCanvas canvas = new GLCanvas(shell, 0, caps, null, null); canvas.addGLEventListener(new GLEventListener() { + @Override public void init(final GLAutoDrawable drawable) { GL gl = drawable.getGL(); System.err.println(JoglVersion.getGLInfo(gl, null)); } - public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {} + @Override + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) {} + @Override public void display(final GLAutoDrawable drawable) {} - public void dispose(final GLAutoDrawable drawable) {} + @Override + public void dispose(final GLAutoDrawable drawable) {} }); shell.open(); canvas.display(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java deleted file mode 100644 index 021e1178a..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAWT01GLn.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.swt; - -import java.awt.Frame; -import java.lang.reflect.InvocationTargetException; - -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; -import javax.media.opengl.awt.GLCanvas; - - -import org.eclipse.swt.SWT; -import org.eclipse.swt.awt.SWT_AWT; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -import org.junit.Assert; -import org.junit.Assume; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.After; -import org.junit.Test; - -import com.jogamp.nativewindow.swt.SWTAccessor; -import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle; -import com.jogamp.opengl.test.junit.util.UITestCase; - -/** - * Tests that a basic SWT app can open without crashing under different GL profiles. Uses the AWT GL canvas with - * the SWT_AWT bridge. - * @author Wade Walker, et.al. - */ -public class TestSWTAWT01GLn extends UITestCase { - - static final int duration = 250; - - Display display = null; - Shell shell = null; - Composite composite = null; - Frame frame = null; - GLCanvas glcanvas = null; - - @BeforeClass - public static void startup() { - System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); - if(!GLProfile.isAvailable(GLProfile.GL2)) { - setTestSupported(false); - } - } - - @Before - public void init() throws InterruptedException, InvocationTargetException { - SWTAccessor.invoke(true, new Runnable() { - public void run() { - display = new Display(); - Assert.assertNotNull( display ); - shell = new Shell( display ); - Assert.assertNotNull( shell ); - shell.setLayout( new FillLayout() ); - composite = new Composite( shell, SWT.EMBEDDED | SWT.NO_BACKGROUND ); - composite.setLayout( new FillLayout() ); - Assert.assertNotNull( composite ); - frame = SWT_AWT.new_Frame( composite ); - Assert.assertNotNull( frame ); - }}); - } - - @After - public void release() throws InterruptedException, InvocationTargetException { - Assert.assertNotNull( display ); - Assert.assertNotNull( shell ); - Assert.assertNotNull( composite ); - Assert.assertNotNull( glcanvas ); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - frame.remove(glcanvas); - frame.dispose(); - frame = null; - glcanvas = null; - }}); - - SWTAccessor.invoke(true, new Runnable() { - public void run() { - composite.dispose(); - shell.close(); - shell.dispose(); - display.dispose(); - display = null; - shell = null; - composite = null; - }}); - } - - protected void runTestGL( GLProfile glprofile ) throws InterruptedException { - GLCapabilities glcapabilities = new GLCapabilities( glprofile ); - glcanvas = new GLCanvas( glcapabilities ); - Assert.assertNotNull( glcanvas ); - frame.add( glcanvas ); - - glcanvas.addGLEventListener( new GLEventListener() { - /* @Override */ - public void init( GLAutoDrawable glautodrawable ) { - } - - /* @Override */ - public void dispose( GLAutoDrawable glautodrawable ) { - } - - /* @Override */ - public void display( GLAutoDrawable glautodrawable ) { - Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() ); - GL2ES1 gl = glautodrawable.getGL().getGL2ES1(); - OneTriangle.render( gl, rectangle.width, rectangle.height ); - } - - /* @Override */ - public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) { - Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() ); - GL2ES1 gl = glautodrawable.getGL().getGL2ES1(); - OneTriangle.setup( gl, rectangle.width, rectangle.height ); - } - }); - - SWTAccessor.invoke(true, new Runnable() { - public void run() { - shell.setText( getClass().getName() ); - shell.setSize( 640, 480 ); - shell.open(); - }}); - - long lStartTime = System.currentTimeMillis(); - long lEndTime = lStartTime + duration; - try { - while( (System.currentTimeMillis() < lEndTime) && !composite.isDisposed() ) { - SWTAccessor.invoke(true, new Runnable() { - public void run() { - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - try { - Thread.sleep(10); - } catch (InterruptedException e) { } - } - }}); - } - } - catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - } - - @Test - public void test() throws InterruptedException { - GLProfile glprofile = GLProfile.getGL2ES1(); - runTestGL( glprofile ); - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main( TestSWTAWT01GLn.class.getName() ); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java new file mode 100644 index 000000000..966b39c57 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java @@ -0,0 +1,195 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.swt; + +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; + + +import org.eclipse.swt.SWT; +import org.eclipse.swt.awt.SWT_AWT; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Test; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Tests that a basic SWT app can open without crashing under different GL profiles. Uses the AWT GL canvas with + * the SWT_AWT bridge. + * @author Wade Walker, et.al. + */ +public class TestSWTAccessor03AWTGLn extends UITestCase { + + static final int duration = 250; + + Display display = null; + Shell shell = null; + Composite composite = null; + Frame frame = null; + GLCanvas glcanvas = null; + + @BeforeClass + public static void startup() { + System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); + if(!GLProfile.isAvailable(GLProfile.GL2)) { + setTestSupported(false); + } + } + + @Before + public void init() throws InterruptedException, InvocationTargetException { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite = new Composite( shell, SWT.EMBEDDED | SWT.NO_BACKGROUND ); + composite.setLayout( new FillLayout() ); + Assert.assertNotNull( composite ); + frame = SWT_AWT.new_Frame( composite ); + Assert.assertNotNull( frame ); + }}); + } + + @After + public void release() throws InterruptedException, InvocationTargetException { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite ); + Assert.assertNotNull( glcanvas ); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.remove(glcanvas); + frame.dispose(); + frame = null; + glcanvas = null; + }}); + + SWTAccessor.invoke(true, new Runnable() { + public void run() { + composite.dispose(); + shell.close(); + shell.dispose(); + display.dispose(); + display = null; + shell = null; + composite = null; + }}); + } + + protected void runTestGL( GLProfile glprofile ) throws InterruptedException { + GLCapabilities glcapabilities = new GLCapabilities( glprofile ); + glcanvas = new GLCanvas( glcapabilities ); + Assert.assertNotNull( glcanvas ); + frame.add( glcanvas ); + + glcanvas.addGLEventListener( new GLEventListener() { + /* @Override */ + public void init( GLAutoDrawable glautodrawable ) { + } + + /* @Override */ + public void dispose( GLAutoDrawable glautodrawable ) { + } + + /* @Override */ + public void display( GLAutoDrawable glautodrawable ) { + Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() ); + GL2ES1 gl = glautodrawable.getGL().getGL2ES1(); + OneTriangle.render( gl, rectangle.width, rectangle.height ); + } + + /* @Override */ + public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) { + Rectangle rectangle = new Rectangle( 0, 0, glautodrawable.getWidth(), glautodrawable.getHeight() ); + GL2ES1 gl = glautodrawable.getGL().getGL2ES1(); + OneTriangle.setup( gl, rectangle.width, rectangle.height ); + } + }); + + SWTAccessor.invoke(true, new Runnable() { + public void run() { + shell.setText( getClass().getName() ); + shell.setSize( 640, 480 ); + shell.open(); + }}); + + long lStartTime = System.currentTimeMillis(); + long lEndTime = lStartTime + duration; + try { + while( (System.currentTimeMillis() < lEndTime) && !composite.isDisposed() ) { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + if( !display.readAndDispatch() ) { + // blocks on linux .. display.sleep(); + try { + Thread.sleep(10); + } catch (InterruptedException e) { } + } + }}); + } + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + @Test + public void test() throws InterruptedException { + GLProfile glprofile = GLProfile.getGL2ES1(); + runTestGL( glprofile ); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main( TestSWTAccessor03AWTGLn.class.getName() ); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java new file mode 100644 index 000000000..addb14ce5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java @@ -0,0 +1,174 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.swt; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Test; + +import com.jogamp.opengl.swt.GLCanvas; +import com.jogamp.opengl.test.junit.jogl.demos.es1.OneTriangle; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Tests that a basic SWT app can open without crashing under different GL profiles. + *

+ * Uses JOGL's new SWT GLCanvas. + *

+ *

+ * Holds AWT in it's test name, since our impl. still needs the AWT threading, + * see {@link GLCanvas}. + *

+ * @author Wade Walker, et.al. + */ +public class TestSWTJOGLGLCanvas01GLn extends UITestCase { + + static int duration = 250; + + static final int iwidth = 640; + static final int iheight = 480; + + Display display = null; + Shell shell = null; + Composite composite = null; + + @BeforeClass + public static void startup() { + System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); + } + + @Before + public void init() { + display = new Display(); + Assert.assertNotNull( display ); + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite = new Composite( shell, SWT.NONE ); + composite.setLayout( new FillLayout() ); + Assert.assertNotNull( composite ); + } + + @After + public void release() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite ); + try { + composite.dispose(); + shell.dispose(); + display.dispose(); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + display = null; + shell = null; + composite = null; + } + + protected void runTestAGL( GLProfile glprofile ) throws InterruptedException { + // need SWT.NO_BACKGROUND to prevent SWT from clearing the window + // at the wrong times (we use glClear for this instead) + final GLCapabilitiesImmutable caps = new GLCapabilities( glprofile ); + + final GLCanvas canvas = new GLCanvas( composite, SWT.NO_BACKGROUND, caps, null, null); + Assert.assertNotNull( canvas ); + + canvas.addGLEventListener(new GLEventListener() { + public void init(final GLAutoDrawable drawable) { } + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { + OneTriangle.setup( drawable.getGL().getGL2(), width, height ); + } + public void display(final GLAutoDrawable drawable) { + OneTriangle.render( drawable.getGL().getGL2(), drawable.getWidth(), drawable.getHeight()); + } + public void dispose(final GLAutoDrawable drawable) {} + }); + + shell.setText( getClass().getName() ); + shell.setSize( 640, 480 ); + shell.open(); + + long lStartTime = System.currentTimeMillis(); + long lEndTime = lStartTime + duration; + try { + while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) { + if( !display.readAndDispatch() ) { + // blocks on linux .. display.sleep(); + Thread.sleep(10); + } + } + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + canvas.dispose(); + } + + @Test + public void test() throws InterruptedException { + GLProfile glprofile = GLProfile.getGL2ES1(); + runTestAGL( glprofile ); + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) { + for(int i=0; i - * Uses JOGL's new SWT GLCanvas. - *

- *

- * Holds AWT in it's test name, since our impl. still needs the AWT threading, - * see {@link GLCanvas}. - *

- * @author Wade Walker, et.al. - */ -public class TestSWTJOGLGLCanvas01GLnAWT extends UITestCase { - - static int duration = 250; - - static final int iwidth = 640; - static final int iheight = 480; - - Display display = null; - Shell shell = null; - Composite composite = null; - - @BeforeClass - public static void startup() { - System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); - } - - @Before - public void init() { - display = new Display(); - Assert.assertNotNull( display ); - shell = new Shell( display ); - Assert.assertNotNull( shell ); - shell.setLayout( new FillLayout() ); - composite = new Composite( shell, SWT.NONE ); - composite.setLayout( new FillLayout() ); - Assert.assertNotNull( composite ); - } - - @After - public void release() { - Assert.assertNotNull( display ); - Assert.assertNotNull( shell ); - Assert.assertNotNull( composite ); - try { - composite.dispose(); - shell.dispose(); - display.dispose(); - } - catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - display = null; - shell = null; - composite = null; - } - - protected void runTestAGL( GLProfile glprofile ) throws InterruptedException { - // need SWT.NO_BACKGROUND to prevent SWT from clearing the window - // at the wrong times (we use glClear for this instead) - final GLCapabilitiesImmutable caps = new GLCapabilities( glprofile ); - - final GLCanvas canvas = new GLCanvas( composite, SWT.NO_BACKGROUND, caps, null, null); - Assert.assertNotNull( canvas ); - - canvas.addGLEventListener(new GLEventListener() { - public void init(final GLAutoDrawable drawable) { } - public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { - OneTriangle.setup( drawable.getGL().getGL2(), width, height ); - } - public void display(final GLAutoDrawable drawable) { - OneTriangle.render( drawable.getGL().getGL2(), drawable.getWidth(), drawable.getHeight()); - } - public void dispose(final GLAutoDrawable drawable) {} - }); - - shell.setText( getClass().getName() ); - shell.setSize( 640, 480 ); - shell.open(); - - long lStartTime = System.currentTimeMillis(); - long lEndTime = lStartTime + duration; - try { - while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) { - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } - } - } catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - canvas.dispose(); - } - - @Test - public void test() throws InterruptedException { - GLProfile glprofile = GLProfile.getGL2ES1(); - runTestAGL( glprofile ); - } - - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - - public static void main(String args[]) { - for(int i=0; i Date: Thu, 28 Jun 2012 21:59:00 +0200 Subject: Bug #589 - Enhance snapshot/textIO test: Add offscreen mode; Add AWT onscreen/offscreen-layer resize test. --- make/scripts/tests.sh | 7 +- .../TestGLReadBufferUtilTextureIOWrite01AWT.java | 29 ++- .../TestGLReadBufferUtilTextureIOWrite02AWT.java | 197 +++++++++++++++++++++ .../TestGLReadBufferUtilTextureIOWrite02NEWT.java | 122 +++++++------ .../TestParentingOffscreenLayer01GLCanvasAWT.java | 33 ++-- 5 files changed, 301 insertions(+), 87 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7a3e74558..646ff2249 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -86,7 +86,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.X11Util.TraceDisplayLifecycle=true -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" - D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" + #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnativewindow.debug.X11Util" @@ -283,7 +283,7 @@ function testawtswt() { # swt (testswt) # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* -testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $* # @@ -332,7 +332,7 @@ testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* +testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* @@ -388,7 +388,6 @@ testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* # osx: -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLnAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01AWT.java index 0abbd7edd..f79a73040 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01AWT.java @@ -38,9 +38,12 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; +import jogamp.nativewindow.jawt.JAWTUtil; + import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -72,9 +75,17 @@ public class TestGLReadBufferUtilTextureIOWrite01AWT extends UITestCase { } } - @Test - public void testOnscreenWritePNG() throws InterruptedException { + protected void testWritePNG_Impl(boolean offscreenLayer) throws InterruptedException { + if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { + System.err.println("onscreen layer n/a"); + return; + } + if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + System.err.println("offscreen layer n/a"); + return; + } final GLCanvas glc = new GLCanvas(caps); + glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported Dimension glc_sz = new Dimension(width, height); glc.setMinimumSize(glc_sz); glc.setPreferredSize(glc_sz); @@ -108,6 +119,10 @@ public class TestGLReadBufferUtilTextureIOWrite01AWT extends UITestCase { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glc, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glc, true)); + Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, + glc.isOffscreenLayerSurfaceEnabled()); animator.start(); while(animator.getTotalFPSFrames() < 2) { @@ -128,6 +143,16 @@ public class TestGLReadBufferUtilTextureIOWrite01AWT extends UITestCase { } } + @Test + public void testOnscreenWritePNG() throws InterruptedException { + testWritePNG_Impl(false); + } + + @Test + public void testOffscreenWritePNG() throws InterruptedException { + testWritePNG_Impl(true); + } + public static void main(String args[]) { org.junit.runner.JUnitCore.main(TestGLReadBufferUtilTextureIOWrite01AWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java new file mode 100644 index 000000000..10dd4ea70 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java @@ -0,0 +1,197 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.util.texture; + +import java.awt.Dimension; +import java.awt.Frame; +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.Threading; +import javax.media.opengl.awt.GLCanvas; + +import jogamp.nativewindow.jawt.JAWTUtil; + +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLReadBufferUtil; + +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.Test; + +public class TestGLReadBufferUtilTextureIOWrite02AWT extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getDefault(); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + caps.setAlphaBits(1); // req. alpha channel + width = 64; + height = 64; + } + + protected void snapshot(GLAutoDrawable drawable, GLReadBufferUtil screenshot, int i) { + final StringWriter filename = new StringWriter(); + { + final PrintWriter pw = new PrintWriter(filename); + final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; + pw.printf("%s-F_rgba-I_%s-%s-n%03d-%04dx%04d.png", + getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), i, drawable.getWidth(), drawable.getHeight()); + } + drawable.getGL().glFinish(); // poor mans sync .. + if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + screenshot.write(new File(filename.toString())); + } + } + + protected void testWritePNGWithResizeImpl(boolean offscreenLayer) throws InterruptedException { + if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { + System.err.println("onscreen layer n/a"); + return; + } + if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + System.err.println("offscreen layer n/a"); + return; + } + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + final GLCanvas glc = new GLCanvas(caps); + glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported + Dimension glc_sz = new Dimension(width, height); + glc.setMinimumSize(glc_sz); + glc.setPreferredSize(glc_sz); + glc.setSize(glc_sz); + final Frame frame = new Frame(getSimpleTestName(".")); + Assert.assertNotNull(frame); + frame.add(glc); + + glc.addGLEventListener(new GearsES2(1)); + glc.addGLEventListener(new GLEventListener() { + int i=0, fw_old=0, dw_old=0, c=0; + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + final int fw = frame.getWidth(); + final int fh = frame.getHeight(); + final int dw = drawable.getWidth(); + final int dh = drawable.getHeight(); + final boolean sz_changed = fw_old != fw && dw_old != dw && dw <= 512; // need to check both sizes [frame + drawable], due to async resize of AWT! + final boolean snap; + if(sz_changed) { + c++; + snap = c>3; // only snap the 3rd image .. + } else { + snap = false; + } + + if(snap) { + System.err.println("XXX: ["+fw_old+", "+dw_old+"], "+fw+"x"+fh+", "+dw+"x"+dh+", sz_changed "+sz_changed+", snap "+snap); + c=0; + snapshot(drawable, screenshot, i++); + dw_old = dw; + fw_old = fw; + Threading.invoke(true, new Runnable() { + public void run() { + final Dimension new_sz = new Dimension(2*dw, 2*dh); + glc.setMinimumSize(new_sz); + glc.setPreferredSize(new_sz); + glc.setSize(new_sz); + frame.pack(); + frame.validate(); + } }, glc.getTreeLock()); + } + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + Animator animator = new Animator(glc); + animator.setUpdateFPSFrames(60, null); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glc, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glc, true)); + Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, + glc.isOffscreenLayerSurfaceEnabled()); + animator.start(); + + while(animator.getTotalFPSFrames() < 30) { + Thread.sleep(60); + } + + animator.stop(); + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.remove(glc); + frame.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + @Test + public void testOnscreenWritePNGWithResize() throws InterruptedException { + testWritePNGWithResizeImpl(false); + } + + @Test + public void testOffscreenWritePNGWithResize() throws InterruptedException { + testWritePNGWithResizeImpl(true); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestGLReadBufferUtilTextureIOWrite02AWT.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java index 25a773c6a..ed0791f7c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java @@ -38,10 +38,13 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.offscreen.WindowUtilNEWT; import org.junit.Assert; import org.junit.BeforeClass; @@ -59,86 +62,87 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase { caps = new GLCapabilities(glp); Assert.assertNotNull(caps); caps.setAlphaBits(1); // req. alpha channel - width = 256; - height = 256; + width = 64; + height = 64; } - protected void snapshot(GLAutoDrawable drawable, GLReadBufferUtil screenshot, String filename) { + protected void snapshot(GLAutoDrawable drawable, GLReadBufferUtil screenshot, int i) { + final StringWriter filename = new StringWriter(); + { + final PrintWriter pw = new PrintWriter(filename); + final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; + pw.printf("%s-F_rgba-I_%s-%s-n%03d-%04dx%04d.png", + getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), i, drawable.getWidth(), drawable.getHeight()); + } if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename)); + screenshot.write(new File(filename.toString())); } } - @Test - public void testWriteTGAWithResize() throws InterruptedException { + private void testWritePNGWithResizeImpl(boolean offscreen) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); - GLWindow glWindow = GLWindow.create(caps); + final GLCapabilities caps2 = offscreen ? WindowUtilNEWT.fixCaps(caps, false, true, false) : caps; + final GLWindow glWindow = GLWindow.create(caps2); Assert.assertNotNull(glWindow); glWindow.setTitle("Shared Gears NEWT Test"); glWindow.setSize(width, height); glWindow.addGLEventListener(new GearsES2(1)); glWindow.addGLEventListener(new GLEventListener() { - int i=0; - public void init(GLAutoDrawable drawable) {} - public void dispose(GLAutoDrawable drawable) {} + int i=0, dw_old=0, c=0; + public void init(GLAutoDrawable drawable) { + System.err.println("XXX: init"); + } + public void dispose(GLAutoDrawable drawable) { + System.err.println("XXX: dispose"); + } public void display(GLAutoDrawable drawable) { - final StringWriter filename = new StringWriter(); - { - final PrintWriter pw = new PrintWriter(filename); - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - pw.printf("%s-F_rgba-I_%s-%s-%03dx%03d-n%03d.tga", - getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), - drawable.getWidth(), drawable.getHeight(), i++); + final int dw = drawable.getWidth(); + final int dh = drawable.getHeight(); + final boolean sz_changed = dw_old != dw && dw <= 512; + final boolean snap; + if(sz_changed) { + c++; + snap = c>1; // only snap the 3rd image .. + } else { + snap = false; + } + + if(snap) { + System.err.println("XXX: ["+dw_old+"], "+dw+"x"+dh+", sz_changed "+sz_changed+", snap "+snap); + c=0; + snapshot(drawable, screenshot, i++); + dw_old = dw; + new Thread() { + @Override + public void run() { + glWindow.setSize(2*dw, 2*dh); + } }.start(); } - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename.toString())); - } } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); + Animator animator = new Animator(glWindow); + animator.setUpdateFPSFrames(60, null); + glWindow.setVisible(true); - Thread.sleep(60); - glWindow.setSize(300, 300); - Thread.sleep(60); - glWindow.setSize(400, 400); - Thread.sleep(60); - glWindow.destroy(); + animator.start(); + + while(animator.getTotalFPSFrames() < 50) { + Thread.sleep(60); + } + + animator.stop(); + glWindow.destroy(); + } + + @Test + public void testOnscreenWritePNGWithResize() throws InterruptedException { + testWritePNGWithResizeImpl(false); } @Test - public void testWritePNGWithResize() throws InterruptedException { - final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); - GLWindow glWindow = GLWindow.create(caps); - Assert.assertNotNull(glWindow); - glWindow.setTitle("Shared Gears NEWT Test"); - glWindow.setSize(width, height); - glWindow.addGLEventListener(new GearsES2(1)); - glWindow.addGLEventListener(new GLEventListener() { - int i=0; - public void init(GLAutoDrawable drawable) {} - public void dispose(GLAutoDrawable drawable) {} - public void display(GLAutoDrawable drawable) { - final StringWriter filename = new StringWriter(); - { - final PrintWriter pw = new PrintWriter(filename); - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - pw.printf("%s-F_rgba-I_%s-%s-%03dx%03d-n%03d.png", - getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), - drawable.getWidth(), drawable.getHeight(), i++); - } - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename.toString())); - } - } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } - }); - glWindow.setVisible(true); - Thread.sleep(60); - glWindow.setSize(300, 300); - Thread.sleep(60); - glWindow.setSize(400, 400); - Thread.sleep(60); - glWindow.destroy(); + public void testOffscreenWritePNGWithResize() throws InterruptedException { + testWritePNGWithResizeImpl(true); } public static void main(String args[]) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java index 8ec65bf50..4542fa47e 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java @@ -115,37 +115,26 @@ public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase { @Test public void testOnscreenLayerGLCanvas_Onscreen() throws InterruptedException, InvocationTargetException { - if(!JAWTUtil.isOffscreenLayerRequired()) { - testOffscreenLayerGLCanvas_Impl(false, false); - } else { - System.err.println("onscreen layer n/a"); - } + testOffscreenLayerGLCanvas_Impl(false); } - /** We have no GLCanvas OffscreenWindow as we have for NEWT .. test disabled. - @Test - public void testOffscreenLayerGLCanvas_OffscreenLayerWithOffscreenClass() throws InterruptedException, InvocationTargetException { - testOffscreenLayerGLCanvas_Impl(true, true); - } */ - @Test public void testOffscreenLayerGLCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException { - if(JAWTUtil.isOffscreenLayerSupported()) { - testOffscreenLayerGLCanvas_Impl(true, false); - } else { - System.err.println("offscreen layer n/a"); - } + testOffscreenLayerGLCanvas_Impl(true); } - private void testOffscreenLayerGLCanvas_Impl(boolean offscreenLayer, boolean offscreenClass) throws InterruptedException, InvocationTargetException { + private void testOffscreenLayerGLCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException { + if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { + System.err.println("onscreen layer n/a"); + return; + } + if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + System.err.println("offscreen layer n/a"); + return; + } final Frame frame1 = new Frame("AWT Parent Frame"); GLCapabilities glCaps = new GLCapabilities(null); - if(offscreenClass) { - glCaps.setOnscreen(false); - glCaps.setPBuffer(true); - } - final GLCanvas glc = new GLCanvas(glCaps); glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported glc.setPreferredSize(preferredGLSize); -- cgit v1.2.3 From 9a7c8896fe38ebcd42ed5238b09a7a36d46db9dc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 30 Jun 2012 05:14:34 +0200 Subject: Fix Bug #589 (JAWT Offscreen-Layer resize) and Offscreen-Layer setSwapInterval() deadlock; Reuse JAWT instance; Cleanup - Fixes - OSXUtil.CreateCALayer*(..): Pass layer target size (if known). This fixes Bug #589 - MacOSXWindowSystemInterface-pbuffer.m: - ALL: displayLink NULL check - setSwapInterval(..): lock only for variable setting, could deadlock when start/stop CVDisplayLink - JAWTWindow.destroy(): use 'surfaceLock' instead of 'synchronized' - Cleanup / Performance - JAWTWindow.lockSurface(): Reuse JAWT instance - MacOSXJAWTWindow: AttachJAWTSurfaceLayer0(..) -> SetJAWTRootSurfaceLayer0(..) Reflects semantic better. - DEBUG - JAWTWindow.updateBounds(..) notify of bounds change --- make/scripts/tests.sh | 4 +- .../macosx/MacOSXWindowSystemInterface-pbuffer.m | 83 +++++++++++----------- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 26 +++++-- .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 10 +-- .../jogamp/nativewindow/macosx/OSXUtil.java | 6 +- src/nativewindow/native/macosx/OSXmisc.m | 29 ++++---- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 27 ++++++- 7 files changed, 112 insertions(+), 73 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 646ff2249..55fbc5378 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -271,7 +271,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* @@ -332,7 +332,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* -testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m index 3fc6ea0f6..776284cfc 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m @@ -171,7 +171,7 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, #endif [self setAsynchronous: YES]; - [self setNeedsDisplayOnBoundsChange: YES]; // FIXME: learn how to recreate on size change! + [self setNeedsDisplayOnBoundsChange: YES]; [self setOpaque: opaque ? YES : NO]; @@ -192,10 +192,8 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, [displayLink setPaused: YES]; [displayLink release]; #else - if(NULL!=displayLink) { - CVDisplayLinkStop(displayLink); - CVDisplayLinkRelease(displayLink); - } + CVDisplayLinkStop(displayLink); + CVDisplayLinkRelease(displayLink); #endif displayLink = NULL; } @@ -267,18 +265,6 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, { [context makeCurrentContext]; - /** - * v-sync doesn't works w/ NSOpenGLLayer's context .. well :( - * Using CVDisplayLink .. see setSwapInterval() below. - * - if(0 <= swapInterval) { - GLint si; - [context getValues: &si forParameter: NSOpenGLCPSwapInterval]; - if(si != swapInterval) { - DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p setSwapInterval: %d -> %d\n", self, si, swapInterval); - [context setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval]; - } - } */ GLenum textureTarget = [pbuffer textureTarget]; GLfloat texCoordWidth, texCoordHeight; { @@ -359,33 +345,50 @@ static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, - (void)setSwapInterval:(int)interval { - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval: %d\n", interval); + /** + * v-sync doesn't works w/ NSOpenGLLayer's context .. well :( + * Using CVDisplayLink .. see setSwapInterval() below. + * + GLint si; + [context getValues: &si forParameter: NSOpenGLCPSwapInterval]; + if(si != swapInterval) { + DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p setSwapInterval: %d -> %d\n", self, si, swapInterval); + [context setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval]; + } + } */ + + pthread_mutex_lock(&renderLock); + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0: %d - displayLink %p\n", interval, displayLink); swapInterval = interval; swapIntervalCounter = 0; - if(0 < swapInterval) { - tc = 0; - timespec_now(&t0); - - [self setAsynchronous: NO]; - #ifdef HAS_CADisplayLink - [displayLink setPaused: NO]; - [displayLink setFrameInterval: interval]; - #else - if(NULL!=displayLink) { + pthread_mutex_unlock(&renderLock); + + if(NULL!=displayLink) { + if(0 < swapInterval) { + tc = 0; + timespec_now(&t0); + + [self setAsynchronous: NO]; + #ifdef HAS_CADisplayLink + [displayLink setPaused: NO]; + [displayLink setFrameInterval: interval]; + #else + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.1.b.1\n"); CVDisplayLinkStart(displayLink); - // FIXME: doesn't support interval .. - } - #endif - } else { - #ifdef HAS_CADisplayLink - [displayLink setPaused: YES]; - #else - if(NULL!=displayLink) { + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.1.b.X\n"); + #endif + } else { + #ifdef HAS_CADisplayLink + [displayLink setPaused: YES]; + #else + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0.b.1\n"); CVDisplayLinkStop(displayLink); - } - #endif - [self setAsynchronous: YES]; + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0.b.X\n"); + #endif + [self setAsynchronous: YES]; + } } + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.X: %d\n", interval); } -(void)tick @@ -414,9 +417,7 @@ NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fm void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval) { MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; - pthread_mutex_lock(&l->renderLock); [l setSwapInterval: interval]; - pthread_mutex_unlock(&l->renderLock); } void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 3815189ef..cffe495f7 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -135,6 +135,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected abstract void invalidateNative(); protected final void updateBounds(JAWT_Rectangle jawtBounds) { + if(DEBUG) { + final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); + if(!bounds.equals(jb)) { + System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); + Thread.dumpStack(); + } + } bounds.setX(jawtBounds.getX()); bounds.setY(jawtBounds.getY()); bounds.setWidth(jawtBounds.getWidth()); @@ -186,7 +193,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } try { if(DEBUG) { - System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle)); + System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle) + ", bounds "+bounds); } attachSurfaceLayerImpl(layerHandle); } finally { @@ -288,8 +295,10 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); adevice.lock(); try { - jawt = fetchJAWTImpl(); - isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt); + if(null == jawt) { // no need to re-fetch for each frame + jawt = fetchJAWTImpl(); + isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt); + } res = lockSurfaceImpl(); if(LOCK_SUCCESS == res && drawable_old != drawable) { res = LOCK_SURFACE_CHANGED; @@ -386,9 +395,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, // @Override - public synchronized void destroy() { - invalidate(); - component = null; // don't dispose the AWT component, since we are merely an immutable uplink + public void destroy() { + surfaceLock.lock(); + try { + invalidate(); + component = null; // don't dispose the AWT component, since we are merely an immutable uplink + } finally { + surfaceLock.unlock(); + } } @Override diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 0ca5cd297..42fd08df1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -207,20 +207,20 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps); } if(0 == rootSurfaceLayerHandle) { - rootSurfaceLayerHandle = OSXUtil.CreateCALayer(); + rootSurfaceLayerHandle = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); if(0 == rootSurfaceLayerHandle) { OSXUtil.DestroyNSWindow(drawable); drawable = 0; unlockSurfaceImpl(); throw new NativeWindowException("Could not create root CALayer: "+this); } - if(!AttachJAWTSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { + if(!SetJAWTRootSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); rootSurfaceLayerHandle = 0; OSXUtil.DestroyNSWindow(drawable); drawable = 0; unlockSurfaceImpl(); - throw new NativeWindowException("Could not attach JAWT surfaceLayerHandle: "+this); + throw new NativeWindowException("Could not set JAWT rootSurfaceLayerHandle: "+this); } } ret = NativeWindow.LOCK_SUCCESS; @@ -267,8 +267,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { } protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; } - private static native boolean AttachJAWTSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); - // private static native boolean DetachJAWTSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); + private static native boolean SetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); + // private static native boolean UnsetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 3ca76a84a..94f949ea3 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -77,8 +77,8 @@ public class OSXUtil { DestroyNSWindow0(nsWindow); } - public static long CreateCALayer() { - return CreateCALayer0(); + public static long CreateCALayer(int x, int y, int width, int height) { + return CreateCALayer0(x, y, width, height); } public static void AddCASublayer(long rootCALayer, long subCALayer) { if(0==rootCALayer || 0==subCALayer) { @@ -117,7 +117,7 @@ public class OSXUtil { private static native void DestroyNSView0(long nsView); private static native long CreateNSWindow0(int x, int y, int width, int height); private static native void DestroyNSWindow0(long nsWindow); - private static native long CreateCALayer0(); + private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 38ffde98b..e010fc440 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -225,22 +225,25 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSWindow0 /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateCALayer0 - * Signature: (V)J + * Signature: (IIII)J */ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 - (JNIEnv *env, jclass unused) + (JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; CALayer* layer = [[CALayer alloc] init]; - DBG_PRINT("CALayer::CreateCALayer.0: %p (refcnt %d)\n", layer, (int)[layer retainCount]); + DBG_PRINT("CALayer::CreateCALayer.0: %p %d/%d %dx%d (refcnt %d)\n", layer, x, y, width, height, (int)[layer retainCount]); + // avoid zero size + if(0 == width) { width = 32; } + if(0 == height) { height = 32; } // initial dummy size ! CGRect lRect = [layer frame]; - lRect.origin.x = 0; - lRect.origin.y = 0; - lRect.size.width = 32; - lRect.size.height = 32; + lRect.origin.x = x; + lRect.origin.y = y; + lRect.size.width = width; + lRect.size.height = height; [layer setFrame: lRect]; // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] @@ -422,10 +425,10 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_IsMainThread0 /* * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow - * Method: AttachJAWTSurfaceLayer + * Method: SetJAWTRootSurfaceLayer0 * Signature: (JJ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_AttachJAWTSurfaceLayer0 +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_SetJAWTRootSurfaceLayer0 (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) { JNF_COCOA_ENTER(env); @@ -437,9 +440,9 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow CALayer* layer = (CALayer*) (intptr_t) caLayer; [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ id surfaceLayers = (id )dsi->platformInfo; - DBG_PRINT("CALayer::attachJAWTSurfaceLayer: %p -> %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); + DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: %p -> %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); surfaceLayers.layer = layer; // already incr. retain count - DBG_PRINT("CALayer::attachJAWTSurfaceLayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); + DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); }]; JNF_COCOA_EXIT(env); return JNI_TRUE; @@ -447,9 +450,9 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow /* * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow - * Method: DetachJAWTSurfaceLayer + * Method: UnsetJAWTRootSurfaceLayer0 * Signature: (JJ)Z -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_DetachJAWTSurfaceLayer0 +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_UnsetJAWTRootSurfaceLayer0 (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) { JNF_COCOA_ENTER(env); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index c6e224548..ba9113af5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -32,6 +32,8 @@ import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; import javax.media.opengl.awt.GLCanvas; + +import com.jogamp.common.os.Platform; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; import com.jogamp.newt.event.TraceKeyAdapter; @@ -41,7 +43,11 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; + +import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.Frame; +import java.awt.TextArea; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -57,6 +63,7 @@ public class TestGearsES2AWT extends UITestCase { static boolean firstUIActionOnProcess = false; static boolean forceES2 = false; static boolean shallUseOffscreenLayer = false; + static boolean addComp = true; static int swapInterval = 1; static boolean showFPS = false; @@ -77,8 +84,19 @@ public class TestGearsES2AWT extends UITestCase { final GLCanvas glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); glCanvas.setShallUseOffscreenLayer(shallUseOffscreenLayer); - frame.add(glCanvas); - frame.setSize(512, 512); + Dimension glc_sz = new Dimension(width, height); + glCanvas.setMinimumSize(glc_sz); + glCanvas.setPreferredSize(glc_sz); + glCanvas.setSize(glc_sz); + if(addComp) { + final TextArea ta = new TextArea(2, 20); + ta.append("0123456789"); + ta.append(Platform.getNewline()); + ta.append("Some Text"); + ta.append(Platform.getNewline()); + frame.add(ta, BorderLayout.SOUTH); + } + frame.add(glCanvas, BorderLayout.CENTER); frame.setTitle("Gears AWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); glCanvas.addGLEventListener(new GearsES2(swapInterval)); @@ -91,12 +109,13 @@ public class TestGearsES2AWT extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { + frame.pack(); frame.setVisible(true); }}); animator.setUpdateFPSFrames(60, System.err); animator.start(); - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Thu, 5 Jul 2012 14:57:18 +0200 Subject: GLContext adds FBO availability to profile mapping; Fix GL[Auto]Drawable/GLContext re-association (switch) incl. unit test. - GLContext adds FBO availability to profile mapping - GLContext added 'GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly)' allowing to set the write GLDrawable. This method enables switching context/drawable. Fix GL[Auto]Drawable/GLContext re-association (switch) incl. unit test Commit eed8508ae1132e5f45f788e9cb3f3d5a1050ac70 impl. of GLAutoDrawable's setContext(..) enabled proper setting of the GLAutoDrawable context incl. updating the context's drawables. Test covers: - remove/set (GLContext, GLEventListener) of GL[Auto]Drawable - switch (GLContext, GLEventListener) of 2 GLAutoDrawables --- make/scripts/tests.sh | 28 +- src/jogl/classes/javax/media/opengl/GLContext.java | 249 ++++++++++++---- .../javax/media/opengl/GLDrawableFactory.java | 17 ++ src/jogl/classes/javax/media/opengl/GLProfile.java | 9 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 97 +++++-- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 10 +- .../jogamp/opengl/egl/EGLExternalContext.java | 2 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 2 +- src/newt/classes/jogamp/newt/WindowImpl.java | 2 + .../acore/TestGLContextDrawableSwitchNEWT.java | 322 +++++++++++++++++++++ .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 17 +- .../test/junit/jogl/demos/es2/RedSquareES2.java | 15 +- .../newt/parenting/TestParenting01cSwingAWT.java | 57 +++- 13 files changed, 695 insertions(+), 132 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 55fbc5378..852dd6f25 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -53,6 +53,10 @@ function jrun() { swton=$1 shift + #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" + #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL" @@ -68,11 +72,8 @@ function jrun() { #D_ARGS="-Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" - #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=600000" #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnewt.debug.Window" - #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" @@ -83,8 +84,10 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" - #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.X11Util.TraceDisplayLifecycle=true -Dnativewindow.debug.X11Util" + #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.XSync" + #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" @@ -100,9 +103,6 @@ function jrun() { #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.EDT -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GraphicsConfiguration" #D_ARGS="-Dnewt.debug.EDT" - #D_ARGS="-Djogamp.debug=all -Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" @@ -211,7 +211,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* @@ -226,6 +225,15 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* + +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* + + +#testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* @@ -271,7 +279,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* @@ -384,8 +392,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index bf6ee31df..ecfa230d2 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -46,13 +46,13 @@ import java.util.HashSet; import javax.media.nativewindow.AbstractGraphicsDevice; +import jogamp.opengl.Debug; +import jogamp.opengl.GLContextImpl; + import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; -import jogamp.opengl.Debug; -import jogamp.opengl.GLContextImpl; - /** Abstraction for an OpenGL rendering context. In order to perform OpenGL rendering, a context must be "made current" on the current thread. OpenGL rendering semantics specify that only one context @@ -70,9 +70,9 @@ public abstract class GLContext { public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */ - public final static boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true); + public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true); /** Reflects property jogl.debug.TraceGL. If true, the trace pipeline is enabled at context creation. */ - public final static boolean TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true); + public static final boolean TRACE_GL = Debug.isPropertyDefined("jogl.debug.TraceGL", true); /** Indicates that the context was not made current during the last call to {@link #makeCurrent makeCurrent}. */ public static final int CONTEXT_NOT_CURRENT = 0; @@ -81,32 +81,49 @@ public abstract class GLContext { /** Indicates that a newly-created context was made current during the last call to {@link #makeCurrent makeCurrent}. */ public static final int CONTEXT_CURRENT_NEW = 2; - /** ARB_create_context related: created via ARB_create_context. Cache key value. */ + /** ARB_create_context related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IS_ARB_CREATED = 1 << 0; - /** ARB_create_context related: compatibility profile. Cache key value. */ + /** ARB_create_context related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_PROFILE_COMPAT = 1 << 1; - /** ARB_create_context related: core profile. Cache key value. */ + /** ARB_create_context related: desktop core profile. Cache key value. See {@link #isGLCoreProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_PROFILE_CORE = 1 << 2; - /** ARB_create_context related: ES profile. Cache key value. */ + /** ARB_create_context related: ES profile. Cache key value. See {@link #isGLES()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_PROFILE_ES = 1 << 3; - /** ARB_create_context related: flag forward compatible. Cache key value. */ + /** ARB_create_context related: flag forward compatible. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_OPTION_FORWARD = 1 << 4; - /** ARB_create_context related: flag debug. Not a cache key. */ + /** ARB_create_context related: flag debug. Not a cache key. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ public static final int CTX_OPTION_DEBUG = 1 << 5; - /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. */ + /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 8; - /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. */ - protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 15; + /** Context supports FBO, details see {@link #hasFBO()}. + * Not a cache key. + * @see #hasFBO() + * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) + */ + protected static final int CTX_IMPL_FBO = 1 << 9; - private static ThreadLocal currentContext = new ThreadLocal(); + /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ + protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 15; - private HashMap attachedObjectsByString = new HashMap(); - private IntObjectHashMap attachedObjectsByInt = new IntObjectHashMap(); + protected static final String GL_ARB_ES2_compatibility = "GL_ARB_ES2_compatibility"; + protected static final String GL_ARB_framebuffer_object = "GL_ARB_framebuffer_object"; + protected static final String GL_EXT_framebuffer_object = "GL_EXT_framebuffer_object"; + protected static final String GL_EXT_framebuffer_blit = "GL_EXT_framebuffer_blit"; + protected static final String GL_EXT_framebuffer_multisample = "GL_EXT_framebuffer_multisample"; + protected static final String GL_EXT_packed_depth_stencil = "GL_EXT_packed_depth_stencil"; + protected static final String GL_ARB_texture_non_power_of_two = "GL_ARB_texture_non_power_of_two"; + protected static final String GL_EXT_texture_format_BGRA8888 = "GL_EXT_texture_format_BGRA8888"; + protected static final String GL_IMG_texture_format_BGRA8888 = "GL_IMG_texture_format_BGRA8888"; + + private static final ThreadLocal currentContext = new ThreadLocal(); + + private final HashMap attachedObjectsByString = new HashMap(); + private final IntObjectHashMap attachedObjectsByInt = new IntObjectHashMap(); // RecursiveLock maintains a queue of waiting Threads, ensuring the longest waiting thread will be notified at unlock. - protected RecursiveLock lock = LockFactory.createRecursiveLock(); + protected final RecursiveLock lock = LockFactory.createRecursiveLock(); /** The underlying native OpenGL context */ protected long contextHandle; @@ -137,36 +154,74 @@ public abstract class GLContext { } /** - * Returns the GLDrawable to which this context may be used to - * draw. + * Sets the read/write drawable for framebuffer operations. + *

+ * If the context was current on this thread, it is being released before switching the drawable + * and made current afterwards. However the user shall take extra care that not other thread + * attempts to make this context current. Otherwise a race condition may happen. + *

+ *

+ * Disclaimer: Even though the API may allows this functionality in theory, your mileage may vary + * switching the drawable of an already established GLContext, i.e. which is already made current once. + * FIXME: Validate functionality! + *

+ * @param readWrite the read/write drawable for framebuffer operations. + * @param setWriteOnly if true and if the current read-drawable differs + * from the write-drawable ({@link #setGLReadDrawable(GLDrawable)}), + * only change the write-drawable. Otherwise set both drawables. + * @return the replaced read/write drawable + * + * @throws GLException in case null is being passed or + * this context is made current on another thread. + * + * @see #isGLReadDrawableAvailable() + * @see #getGLReadDrawable() + * @see #setGLReadDrawable() + * @see #getGLDrawable() + */ + public abstract GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly); + + /** + * Returns the write-drawable this context uses for framebuffer operations. */ public abstract GLDrawable getGLDrawable(); /** - * Return availability of GL read drawable. - * @return true if a GL read drawable is supported with your driver, otherwise false. + * Query whether using a distinguished read-drawable is supported. + * @return true if using a read-drawable is supported with your driver/OS, otherwise false. */ public abstract boolean isGLReadDrawableAvailable(); /** - * Set the read GLDrawable for read framebuffer operations.
+ * Set the read-Drawable for read framebuffer operations.
* The caller should query if this feature is supported via {@link #isGLReadDrawableAvailable()}. + *

+ * If the context was current on this thread, it is being released before switching the drawable + * and made current afterwards. However the user shall take extra care that not other thread + * attempts to make this context current. Otherwise a race condition may happen. + *

* - * @param read the read GLDrawable for read framebuffer operations. - * If null is passed, the default write drawable will be set. + * @param read the read-drawable for read framebuffer operations. + * If null is passed, the default write drawable will be set. + * @return the replaced read-drawable * - * @throws GLException in case a read drawable is not supported - * and the given drawable is not null and not equal to the internal write drawable. + * @throws GLException in case a read drawable is not supported or + * this context is made current on another thread. * * @see #isGLReadDrawableAvailable() * @see #getGLReadDrawable() */ - public abstract void setGLReadDrawable(GLDrawable read); + public abstract GLDrawable setGLReadDrawable(GLDrawable read); /** - * Returns the read GLDrawable this context uses for read framebuffer operations. + * Returns the read-Drawable this context uses for read framebuffer operations. + *

+ * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, + * it equals to the write-drawable (default). + *

* @see #isGLReadDrawableAvailable() * @see #setGLReadDrawable(javax.media.opengl.GLDrawable) + * @see #getGLDrawable() */ public abstract GLDrawable getGLReadDrawable(); @@ -190,7 +245,7 @@ public abstract class GLContext { *

*

* This method is blocking, i.e. waits until another thread has - * released the context. + * released the context. *

*

* The drawable's surface is being locked at entry @@ -547,6 +602,28 @@ public abstract class GLContext { return 0 != ( ctxOptions & CTX_IMPL_ES2_COMPAT ) ; } + /** + * @return true if impl. is a hardware rasterizer, otherwise false. + * @see GLProfile#isHardwareRasterizer() + */ + public final boolean isHardwareRasterizer() { + return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ; + } + + /** Returns whether the context supports FBO, hence is either GL-ES >= 2.0, >= core GL 3.0 or implements the extensions + * GL_ARB_ES2_compatibility, ARB_framebuffer_object or all of + * EXT_framebuffer_object, EXT_framebuffer_multisample, + * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. + * @see #CTX_IMPL_FBO + */ + public final boolean hasFBO() { + return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; + } + + /** + * @return true if context supports GLSL + * @see GLProfile#hasGLSL() + */ public final boolean hasGLSL() { return isGL2ES2() ; } @@ -555,60 +632,70 @@ public abstract class GLContext { public boolean isNPOTTextureAvailable() { return isGL3() || isGLES2Compatible() || isExtensionAvailable(GL_ARB_texture_non_power_of_two); } - private static final String GL_ARB_texture_non_power_of_two = "GL_ARB_texture_non_power_of_two"; public boolean isTextureFormatBGRA8888Available() { return isGL2GL3() || - isExtensionAvailable("GL_EXT_texture_format_BGRA8888") || - isExtensionAvailable("GL_IMG_texture_format_BGRA8888") ; + isExtensionAvailable(GL_EXT_texture_format_BGRA8888) || + isExtensionAvailable(GL_IMG_texture_format_BGRA8888) ; } + /** @see GLProfile#isGL4bc() */ public final boolean isGL4bc() { return ctxMajorVersion>=4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_COMPAT); } + /** @see GLProfile#isGL4() */ public final boolean isGL4() { return ctxMajorVersion>=4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); } + /** @see GLProfile#isGL3bc() */ public final boolean isGL3bc() { return ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_COMPAT); } + /** @see GLProfile#isGL3() */ public final boolean isGL3() { return ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); } - + + /** @see GLProfile#isGL2() */ public final boolean isGL2() { return ctxMajorVersion>=1 && 0!=(ctxOptions & CTX_PROFILE_COMPAT); } + /** @see GLProfile#isGL2GL3() */ public final boolean isGL2GL3() { return isGL2() || isGL3(); } + /** @see GLProfile#isGLES1() */ public final boolean isGLES1() { return ctxMajorVersion==1 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; } + /** @see GLProfile#isGLES2() */ public final boolean isGLES2() { return ctxMajorVersion==2 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; } + /** @see GLProfile#isGLES() */ public final boolean isGLES() { return 0 != ( CTX_PROFILE_ES & ctxOptions ) ; } + /** @see GLProfile#isGL2ES1() */ public final boolean isGL2ES1() { return isGL2() || isGLES1() ; } + /** @see GLProfile#isGL2ES2() */ public final boolean isGL2ES2() { return isGL2GL3() || isGLES2() ; } @@ -846,8 +933,11 @@ public abstract class GLContext { */ private static /*final*/ HashSet deviceVersionsAvailableSet = new HashSet(); - protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) { - return device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0)); + /** clears the device/context mappings as well as the GL/GLX proc address tables. */ + protected static void shutdown() { + deviceVersionAvailable.clear(); + deviceVersionsAvailableSet.clear(); + GLContextImpl.shutdownImpl(); // well .. } protected static boolean getAvailableGLVersionsSet(AbstractGraphicsDevice device) { @@ -869,11 +959,8 @@ public abstract class GLContext { } } - /** clears the device/context mappings as well as the GL/GLX proc address tables. */ - protected static void shutdown() { - deviceVersionAvailable.clear(); - deviceVersionsAvailableSet.clear(); - GLContextImpl.shutdownImpl(); // well .. + protected static String getDeviceVersionAvailableKey(AbstractGraphicsDevice device, int major, int profile) { + return device.getUniqueID() + "-" + toHexString(composeBits(major, profile, 0)); } /** @@ -967,18 +1054,71 @@ public abstract class GLContext { } /** + * Returns the GLProfile's major version number and it's context property (CTP) for availability mapping request. + */ + protected static final void getRequestMajorAndCompat(final GLProfile glp, int[/*2*/] reqMajorCTP) { + final GLProfile glpImpl = glp.getImpl(); + if(glpImpl.isGL4()) { + reqMajorCTP[0]=4; + } else if (glpImpl.isGL3()) { + reqMajorCTP[0]=3; + } else /* if (glpImpl.isGL2()) */ { + reqMajorCTP[0]=2; + } + if( glpImpl.isGL2() ) { // incl GL3bc and GL4bc + reqMajorCTP[1]=CTX_PROFILE_COMPAT; + } else { + reqMajorCTP[1]=CTX_PROFILE_CORE; + } + } + + /** + * @param device the device the context profile is being requested for + * @param GLProfile the GLProfile the context profile is being requested for + * @return the GLProfile's context property (CTP) if available, otherwise 0 + */ + protected static final int getAvailableContextProperties(final AbstractGraphicsDevice device, final GLProfile glp) { + final int[] reqMajorCTP = new int[] { 0, 0 }; + getRequestMajorAndCompat(glp, reqMajorCTP); + + int _major[] = { 0 }; + int _minor[] = { 0 }; + int _ctp[] = { 0 }; + if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], + _major, _minor, _ctp)) { + return _ctp[0]; + } + return 0; // n/a + } + + /** + * @param device the device the profile is being requested * @param major Key Value either 1, 2, 3 or 4 * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} - * @return the highest GLProfile string regarding the version and profile bits. - * @throws GLException if version and context profile bits could not be mapped to a GLProfile + * @return the highest GLProfile regarding availability, version and profile bits. */ - public static String getAvailableGLProfile(AbstractGraphicsDevice device, int reqMajor, int reqProfile) + protected static GLProfile getAvailableGLProfile(AbstractGraphicsDevice device, int reqMajor, int reqProfile) throws GLException { int major[] = { 0 }; int minor[] = { 0 }; int ctp[] = { 0 }; if(GLContext.getAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp)) { - return GLContext.getGLProfile(major[0], minor[0], ctp[0]); + return GLProfile.get(GLContext.getGLProfile(major[0], minor[0], ctp[0])); + } + return null; + } + + /** + * @param device the device the profile is being requested + * @param major Key Value either 1, 2, 3 or 4 + * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} + */ + protected static String getAvailableGLVersionAsString(AbstractGraphicsDevice device, int major, int profile) { + int _major[] = { 0 }; + int _minor[] = { 0 }; + int _ctp[] = { 0 }; + if(getAvailableGLVersion(device, major, profile, _major, _minor, _ctp)) { + return getGLVersion(_major[0], _minor[0], _ctp[0], null); } return null; } @@ -990,7 +1130,7 @@ public abstract class GLContext { * @param isHardware return value of one boolean, whether the profile is a hardware rasterizer or not * @return true if the requested GL version is available regardless of a software or hardware rasterizer, otherwise false. */ - public static boolean isGLVersionAvailable(AbstractGraphicsDevice device, int reqMajor, int reqProfile, boolean isHardware[]) { + protected static boolean isGLVersionAvailable(AbstractGraphicsDevice device, int reqMajor, int reqProfile, boolean isHardware[]) { Integer valI = getAvailableGLVersion(device, reqMajor, reqProfile); if(null==valI) { return false; @@ -1027,21 +1167,7 @@ public abstract class GLContext { return isGLVersionAvailable(device, 2, CTX_PROFILE_COMPAT, isHardware); } - /** - * @param major Key Value either 1, 2, 3 or 4 - * @param profile Key Value either {@link #CTX_PROFILE_COMPAT}, {@link #CTX_PROFILE_CORE} or {@link #CTX_PROFILE_ES} - */ - public static String getAvailableGLVersionAsString(AbstractGraphicsDevice device, int major, int profile) { - int _major[] = { 0 }; - int _minor[] = { 0 }; - int _ctp[] = { 0 }; - if(getAvailableGLVersion(device, major, profile, _major, _minor, _ctp)) { - return getGLVersion(_major[0], _minor[0], _ctp[0], null); - } - return null; - } - - public static String getGLVersion(int major, int minor, int ctp, String gl_version) { + protected static String getGLVersion(int major, int minor, int ctp, String gl_version) { boolean needColon = false; StringBuilder sb = new StringBuilder(); sb.append(major); @@ -1055,6 +1181,7 @@ public abstract class GLContext { needColon = appendString(sb, "arb", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp )); needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp )); needColon = appendString(sb, "ES2 compatible", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp )); + needColon = appendString(sb, "FBO", needColon, 0 != ( CTX_IMPL_FBO & ctp )); if( 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { needColon = appendString(sb, "software", needColon, true); } else { diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 1093685d6..d6480e7aa 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -492,6 +492,23 @@ public abstract class GLDrawableFactory { GLContext shareWith) throws GLException; + /** + * Returns true if it is possible to create an framebuffer object (FBO). + *

+ * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. + *

+ *

+ * FBO support is queried as described in {@link GLContext#hasFBO()}. + *

+ * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + * @param glp {@link GLProfile} to check for FBO capabilities + * @see GLContext#hasFBO() + */ + public final boolean canCreateFBO(AbstractGraphicsDevice device, GLProfile glp) { + return 0 != ( GLContext.CTX_IMPL_FBO & GLContext.getAvailableContextProperties(device, glp) ); + } + //---------------------------------------------------------------------- // Methods for interacting with third-party OpenGL libraries diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index ed457b0ea..cc4f6c517 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -113,9 +113,7 @@ public class GLProfile { * @param firstUIActionOnProcess Should be true if called before the first UI action of the running program, * otherwise false. * - * @deprecated This method shall not need to be called for other reasons than having a defined initialization sequence. - * To ensure homogeneous behavior with application not calling this method, you shall pass firstUIActionOnProcess=false. - * This method is subject to be removed in future versions of JOGL. + * @deprecated Use {@link #initSingleton()}. This method is subject to be removed in future versions of JOGL. */ public static void initSingleton(final boolean firstUIActionOnProcess) { initLock.lock(); @@ -1003,6 +1001,11 @@ public class GLProfile { public final boolean isGLES2() { return GLES2 == profile; } + + /** Indicates whether this profile is capable of GLES.

Includes [ GLES1, GLES2 ].

*/ + public final boolean isGLES() { + return GLES2 == profile || GLES1 == profile; + } /** Indicates whether this profile is capable of GL2ES1.

Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].

*/ public final boolean isGL2ES1() { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 4ef8b9750..7362a2bd8 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -161,18 +161,22 @@ public abstract class GLContextImpl extends GLContext { } @Override - public final void setGLReadDrawable(GLDrawable read) { - if(null!=read && drawable!=read && !isGLReadDrawableAvailable()) { - throw new GLException("GL Read Drawable not available"); + public final GLDrawable setGLReadDrawable(GLDrawable read) { + if(!isGLReadDrawableAvailable()) { + throw new GLException("Setting read drawable feature not available"); } final boolean lockHeld = lock.isOwner(Thread.currentThread()); if(lockHeld) { release(); + } else if(lock.isLockedByOtherThread()) { // still could glitch .. + throw new GLException("GLContext current by other thread ("+lock.getOwner()+"), operation not allowed."); } + final GLDrawable old = drawableRead; drawableRead = ( null != read ) ? (GLDrawableImpl) read : drawable; if(lockHeld) { makeCurrent(); } + return old; } @Override @@ -180,6 +184,28 @@ public abstract class GLContextImpl extends GLContext { return drawableRead; } + @Override + public final GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly) { + if(null==readWrite) { + throw new GLException("Null read/write drawable not allowed"); + } + final boolean lockHeld = lock.isOwner(Thread.currentThread()); + if(lockHeld) { + release(); + } else if(lock.isLockedByOtherThread()) { // still could glitch .. + throw new GLException("GLContext current by other thread ("+lock.getOwner()+"), operation not allowed."); + } + if(!setWriteOnly || drawableRead==drawable) { // if !setWriteOnly || !explicitReadDrawable + drawableRead = (GLDrawableImpl) readWrite; + } + final GLDrawable old = drawable; + drawable = ( null != readWrite ) ? (GLDrawableImpl) readWrite : null; + if(lockHeld) { + makeCurrent(); + } + return old; + } + @Override public final GLDrawable getGLDrawable() { return drawable; @@ -630,13 +656,10 @@ public abstract class GLContextImpl extends GLContext { * @see #createContextARBImpl * @see #destroyContextARBImpl */ - protected final long createContextARB(long share, boolean direct) + protected final long createContextARB(final long share, final boolean direct) { - AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); - AbstractGraphicsDevice device = config.getScreen().getDevice(); - GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - GLProfile glp = glCaps.getGLProfile(); - GLProfile glpImpl = glp.getImpl(); + final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); + final AbstractGraphicsDevice device = config.getScreen().getDevice(); if (DEBUG) { System.err.println(getThreadName() + ": createContextARB: mappedVersionsAvailableSet("+device.getConnection()+"): "+ @@ -650,22 +673,15 @@ public abstract class GLContextImpl extends GLContext { } } - int reqMajor; - if(glpImpl.isGL4()) { - reqMajor=4; - } else if (glpImpl.isGL3()) { - reqMajor=3; - } else /* if (glpImpl.isGL2()) */ { - reqMajor=2; - } - - boolean compat = glpImpl.isGL2(); // incl GL3bc and GL4bc + final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final int[] reqMajorCTP = new int[] { 0, 0 }; + getRequestMajorAndCompat(glCaps.getGLProfile(), reqMajorCTP); + int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; long _ctx = 0; - - if( GLContext.getAvailableGLVersion(device, reqMajor, compat?CTX_PROFILE_COMPAT:CTX_PROFILE_CORE, + if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], _major, _minor, _ctp)) { _ctp[0] |= additionalCtxCreationFlags; _ctx = createContextARBImpl(share, direct, _ctp[0], _major[0], _minor[0]); @@ -675,7 +691,7 @@ public abstract class GLContextImpl extends GLContext { } return _ctx; } - + private final boolean mapGLVersions(AbstractGraphicsDevice device) { synchronized (GLContext.deviceVersionAvailable) { boolean success = false; @@ -698,10 +714,11 @@ public abstract class GLContextImpl extends GLContext { private final boolean createContextARBMapVersionsAvailable(int reqMajor, boolean compat) { long _context; int reqProfile = compat ? CTX_PROFILE_COMPAT : CTX_PROFILE_CORE ; - int ctp = CTX_IS_ARB_CREATED | CTX_PROFILE_CORE; // default + int ctp = CTX_IS_ARB_CREATED; if(compat) { - ctp &= ~CTX_PROFILE_CORE ; - ctp |= CTX_PROFILE_COMPAT ; + ctp |= CTX_PROFILE_COMPAT ; + } else { + ctp |= CTX_PROFILE_CORE ; } // To ensure GL profile compatibility within the JOGL application @@ -1070,10 +1087,15 @@ public abstract class GLContextImpl extends GLContext { } } } - if( isExtensionAvailable("GL_ARB_ES2_compatibility") ) { + + if( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && ctxMajorVersion >= 2 || + isExtensionAvailable(GL_ARB_ES2_compatibility) ) { ctxProfileBits |= CTX_IMPL_ES2_COMPAT; + ctxProfileBits |= CTX_IMPL_FBO; + } else if( hasFBOImpl(ctxMajorVersion, ctxProfileBits, extensionAvailability) ) { + ctxProfileBits |= CTX_IMPL_FBO; } - + // // Set GL Version (complete w/ version string) // @@ -1081,7 +1103,24 @@ public abstract class GLContextImpl extends GLContext { setDefaultSwapInterval(); } - + + protected static final boolean hasFBOImpl(int ctxMajorVersion, int ctxProfileBits, ExtensionAvailabilityCache extCache) { + return ( ctxMajorVersion >= 3 ) || // any >= 3.0 GL ctx + + ( 0 != (ctxProfileBits & CTX_PROFILE_ES) && ctxMajorVersion >= 2 ) || // ES >= 2.0 + + ( null != extCache && + + ( extCache.isExtensionAvailable(GL_ARB_ES2_compatibility) ) || // ES 2.0 compatible + + ( extCache.isExtensionAvailable(GL_ARB_framebuffer_object) ) || // ARB_framebuffer_object + + ( extCache.isExtensionAvailable(GL_EXT_framebuffer_object) && // EXT_framebuffer_object* + extCache.isExtensionAvailable(GL_EXT_framebuffer_multisample) && + extCache.isExtensionAvailable(GL_EXT_framebuffer_blit) && + extCache.isExtensionAvailable(GL_EXT_packed_depth_stencil) ) ); + } + protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) { if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; @@ -1212,7 +1251,7 @@ public abstract class GLContextImpl extends GLContext { protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) { // remove non-key values - ctxProfileBits &= ~( GLContext.CTX_OPTION_DEBUG | GLContext.CTX_IMPL_ES2_COMPAT ) ; + ctxProfileBits &= ~( GLContext.CTX_OPTION_DEBUG | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) ; return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 06cd550b4..65a4c3ece 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -224,15 +224,7 @@ public abstract class EGLContext extends GLContextImpl { throw new GLException("Error making context 0x" + Long.toHexString(contextHandle) + " current: error code " + EGL.eglGetError()); } - int ctp = CTX_PROFILE_ES; - int major; - if(glProfile.usesNativeGLES2()) { - ctp |= CTX_IMPL_ES2_COMPAT; - major = 2; - } else { - major = 1; - } - setGLFunctionAvailability(true, major, 0, ctp); + setGLFunctionAvailability(true, glProfile.usesNativeGLES2() ? 2 : 1, 0, CTX_PROFILE_ES); return true; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java index 0a451e5eb..585638d21 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java @@ -45,7 +45,7 @@ public class EGLExternalContext extends EGLContext { public EGLExternalContext(AbstractGraphicsScreen screen) { super(null, null); GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_IS_ARB_CREATED|CTX_PROFILE_ES); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES); getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 96baab3ae..5cc0d765c 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -531,7 +531,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return; } - window.lockWindow(); // sync: context/drawable could been recreated/destroyed while animating + window.lockWindow(); // sync: context/drawable could have been recreated/destroyed while animating try { if( null == context && 0 s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + animator.pause(); + + if(0 == s%2) { + glad1.addGLEventListener(0, glad2.removeGLEventListener(0)); + GLContext ctx1 = glad1.setContext(glad2.getContext()); + glad2.setContext(ctx1); + } else { + glad2.addGLEventListener(0, glad1.removeGLEventListener(0)); + GLContext ctx2 = glad2.setContext(glad1.getContext()); + glad1.setContext(ctx2); + } + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + animator.resume(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glad1.destroy(); + glad2.destroy(); + } + + @Test(timeout=30000) + public void testSwitch2GLWindowOneDemo() throws InterruptedException { + GearsES2 gears = new GearsES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + animator.pause(); + + if(0 == s%2) { + glWindow1.addGLEventListener(0, glWindow2.removeGLEventListener(0)); + GLContext ctx1 = glWindow1.setContext(glWindow2.getContext()); + glWindow2.setContext(ctx1); + } else { + glWindow2.addGLEventListener(0, glWindow1.removeGLEventListener(0)); + GLContext ctx2 = glWindow2.setContext(glWindow1.getContext()); + glWindow1.setContext(ctx2); + } + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + animator.resume(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glWindow1.destroy(); + glWindow2.destroy(); + + } + + @Test(timeout=30000) + public void testSwitch2GLWindowEachWithOwnDemo() throws InterruptedException { + GearsES2 gears = new GearsES2(1); + RedSquareES2 rsquare = new RedSquareES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addGLEventListener(0, rsquare); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + animator.pause(); + + GLEventListener demo1 = glWindow1.removeGLEventListener(0); + GLEventListener demo2 = glWindow2.removeGLEventListener(0); + + GLContext ctx1 = glWindow1.setContext(glWindow2.getContext()); + glWindow1.addGLEventListener(0, demo2); + + glWindow2.setContext(ctx1); + glWindow2.addGLEventListener(0, demo1); + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + animator.resume(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glWindow1.destroy(); + glWindow2.destroy(); + + } + + // default timing for 2 switches + static long duration = 2200; // ms + static long period = 1000; // ms + + public static void main(String args[]) throws IOException { + for(int i=0; i XAWT related). + * Or ensure old/new parent is visible, see below. + * SwingUtilities.invokeAndWait(new Runnable() { public void run() { + System.err.println("Demos: 1 - X Container 1"); + container1.remove(newtCanvasAWT); + jFrame1.validate(); + System.err.println("Demos: 1 - X Container 2"); + jPanel2.remove(newtCanvasAWT); + jFrame2.validate(); + } }); */ + /* + * Invisible X11 windows may also case BadMatch (-> XAWT related) + */ + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + System.err.println("Demos: 2 - !visible"); jFrame1.setVisible(false); + System.err.println("Demos: 3 - !visible"); jFrame2.setVisible(false); } }); Assert.assertEquals(true, glWindow1.isNativeValid()); SwingUtilities.invokeAndWait(new Runnable() { public void run() { + System.err.println("Demos: 4 - X frame"); jFrame1.dispose(); + System.err.println("Demos: 5 - X frame"); jFrame2.dispose(); } }); Assert.assertEquals(true, glWindow1.isNativeValid()); + System.err.println("Demos: 6 - X GLWindow"); glWindow1.destroy(); Assert.assertEquals(false, glWindow1.isNativeValid()); + + System.err.println("Demos: 7 - X DisturbanceThread"); + disturbanceAction.stopAndWaitUntilDone(); } public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { @@ -393,8 +424,10 @@ public class TestParenting01cSwingAWT extends UITestCase { waitReparent = atoi(args[++i]); } } - System.out.println("durationPerTest "+durationPerTest); - System.out.println("waitReparent "+waitReparent); + System.err.println("durationPerTest "+durationPerTest); + System.err.println("waitReparent "+waitReparent); + org.junit.runner.JUnitCore.main(TestParenting01cSwingAWT.class.getName()); + /** String tstname = TestParenting01cSwingAWT.class.getName(); org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { tstname, @@ -406,7 +439,7 @@ public class TestParenting01cSwingAWT extends UITestCase { "logfailedtests=true", "logtestlistenerevents=true", "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); + "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); */ } } -- cgit v1.2.3 From e85e3ec2a73ac35aaf911f0b1e34b234be1622da Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 6 Jul 2012 01:20:48 +0200 Subject: Enhance Bootsrapping of JOGL around 37% - 40% (1st start in new JVM) - GLProfile and GLContext* GLProfile: Enhance bootsrapping performance of loading GL*Impl class - Offthread classloading of all GL*Impl via reflection at startup reduces startup time here around 12% (800ms down to 700ms). GLContext*: Enhance bootsrapping performance of querying available GL profiles - Add PROFILE_ALIASING mode, defaults to true - can be disabled w/ property 'jogl.debug.GLContext.NoProfileAliasing' - PROFILE_ALIASING: If true (default), bootstrapping the available GL profiles will use the highest compatible GL context for each profile, hence skipping querying lower profiles if a compatible higher one is found. Linux x86_64 - Nvidia: 28%, 700ms down to 500ms Linux x86_64 - AMD : 40%, 1500ms down to 900ms - GL*Impl: - make fields final: glProfile, _context, buffer*Tracker and glStateTracker - allow null _context/glProfile in initialization (bootstrapping) - JoglVersion.getDefaultOpenGLInfo(..) - add arg: 'boolean withCapabilitiesInfo', allowing to suppres the list of caps --- .../config/jogl/gl-impl-CustomJavaCode-common.java | 4 +- make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 18 ++-- make/config/jogl/gl-impl-CustomJavaCode-gles1.java | 18 ++-- make/config/jogl/gl-impl-CustomJavaCode-gles2.java | 18 ++-- make/scripts/tests.sh | 5 +- .../classes/com/jogamp/opengl/JoglVersion.java | 16 ++-- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 2 +- src/jogl/classes/javax/media/opengl/GLContext.java | 71 +++++++++++++-- src/jogl/classes/javax/media/opengl/GLProfile.java | 81 +++++++++-------- .../classes/javax/media/opengl/awt/GLCanvas.java | 2 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 100 +++++++++++++++++---- .../jogamp/opengl/x11/glx/X11GLXContext.java | 10 +-- .../classes/com/jogamp/newt/opengl/GLWindow.java | 2 +- .../classes/jogamp/newt/driver/android/MD.java | 2 +- .../test/junit/jogl/acore/TestGLProfile01NEWT.java | 2 +- .../junit/jogl/acore/TestShutdownCompleteNEWT.java | 19 ++-- 16 files changed, 261 insertions(+), 109 deletions(-) (limited to 'make/scripts') diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index 2c3227ee5..d552bc6e4 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -1,7 +1,7 @@ public GLProfile getGLProfile() { return this.glProfile; } - private GLProfile glProfile; + private final GLProfile glProfile; public int glGetBoundBuffer(int target) { return bufferStateTracker.getBoundBufferObject(target, this); @@ -46,7 +46,7 @@ return _context; } - private GLContextImpl _context; + private final GLContextImpl _context; /** * @see javax.media.opengl.GLContext#setSwapInterval(int) diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index dc4f898e6..95aa7cc2c 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -17,9 +17,15 @@ public void setObjectTracker(GLObjectTracker tracker) { public GL4bcImpl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); + if(null != context) { + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); + } else { + this.bufferSizeTracker = null; + this.bufferStateTracker = null; + this.glStateTracker = null; + } this.glProfile = glp; } @@ -35,9 +41,9 @@ public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, // Helpers for ensuring the correct amount of texture data // -private GLBufferSizeTracker bufferSizeTracker; -private GLBufferStateTracker bufferStateTracker; -private GLStateTracker glStateTracker; +private final GLBufferSizeTracker bufferSizeTracker; +private final GLBufferStateTracker bufferStateTracker; +private final GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveARBPixelBufferObject; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index 9b0d98fe9..dff33cf81 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -1,8 +1,14 @@ public GLES1Impl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); + if(null != context) { + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); + } else { + this.bufferSizeTracker = null; + this.bufferStateTracker = null; + this.glStateTracker = null; + } this.glProfile = glp; } @@ -106,9 +112,9 @@ public final GL2GL3 getGL2GL3() throws GLException { // Helpers for ensuring the correct amount of texture data // -private GLBufferSizeTracker bufferSizeTracker; -private GLBufferStateTracker bufferStateTracker; -private GLStateTracker glStateTracker; +private final GLBufferSizeTracker bufferSizeTracker; +private final GLBufferStateTracker bufferStateTracker; +private final GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveOESFramebufferObject; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java index ea6544d29..a4976f5ea 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java @@ -4,9 +4,15 @@ private boolean inBeginEndPair; public GLES2Impl(GLProfile glp, GLContextImpl context) { this._context = context; - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); + if(null != context) { + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); + } else { + this.bufferSizeTracker = null; + this.bufferStateTracker = null; + this.glStateTracker = null; + } this.glProfile = glp; } @@ -110,9 +116,9 @@ public final GL2GL3 getGL2GL3() throws GLException { // Helpers for ensuring the correct amount of texture data // -private GLBufferSizeTracker bufferSizeTracker; -private GLBufferStateTracker bufferStateTracker; -private GLStateTracker glStateTracker; +private final GLBufferSizeTracker bufferSizeTracker; +private final GLBufferStateTracker bufferStateTracker; +private final GLStateTracker glStateTracker; private boolean bufferObjectExtensionsInitialized = false; private boolean haveOESFramebufferObject; diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 852dd6f25..10890c786 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -53,6 +53,7 @@ function jrun() { swton=$1 shift + #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" @@ -214,7 +215,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* @@ -226,7 +227,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java index c8e5d212b..75785fd86 100644 --- a/src/jogl/classes/com/jogamp/opengl/JoglVersion.java +++ b/src/jogl/classes/com/jogamp/opengl/JoglVersion.java @@ -93,22 +93,24 @@ public class JoglVersion extends JogampVersion { return sb; } - public static StringBuilder getDefaultOpenGLInfo(StringBuilder sb) { + public static StringBuilder getDefaultOpenGLInfo(StringBuilder sb, boolean withCapabilitiesInfo) { if(null==sb) { sb = new StringBuilder(); } final AbstractGraphicsDevice device = GLProfile.getDefaultDevice(); - sb.append("Default Profiles ").append(Platform.getNewline()); + sb.append("Default Profiles on device ").append(device).append(Platform.getNewline()); if(null!=device) { GLProfile.glAvailabilityToString(device, sb, "\t", 1); } else { sb.append("none"); } - sb.append(Platform.getNewline()).append(Platform.getNewline()); - sb.append("Desktop Capabilities: ").append(Platform.getNewline()); - getAvailableCapabilitiesInfo(GLDrawableFactory.getDesktopFactory(), device, sb); - sb.append("EGL Capabilities: ").append(Platform.getNewline()); - getAvailableCapabilitiesInfo(GLDrawableFactory.getEGLFactory(), device, sb); + if(withCapabilitiesInfo) { + sb.append(Platform.getNewline()).append(Platform.getNewline()); + sb.append("Desktop Capabilities: ").append(Platform.getNewline()); + getAvailableCapabilitiesInfo(GLDrawableFactory.getDesktopFactory(), device, sb); + sb.append("EGL Capabilities: ").append(Platform.getNewline()); + getAvailableCapabilitiesInfo(GLDrawableFactory.getEGLFactory(), device, sb); + } return sb; } diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 62b496891..571f5c5b2 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -570,7 +570,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { // System.err.println(NativeWindowVersion.getInstance()); System.err.println(JoglVersion.getInstance()); - System.err.println(JoglVersion.getDefaultOpenGLInfo(null).toString()); + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, true).toString()); final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDevice()) ); final Display display = new Display(); diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index ecfa230d2..351f90027 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -43,12 +43,15 @@ package javax.media.opengl; import java.nio.IntBuffer; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; import javax.media.nativewindow.AbstractGraphicsDevice; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; @@ -66,6 +69,32 @@ import com.jogamp.common.util.locks.RecursiveLock; abstraction provides a stable object which clients can use to refer to a given context. */ public abstract class GLContext { + /** + * If true (default), bootstrapping the available GL profiles + * will use the highest compatible GL context for each profile, + * hence skipping querying lower profiles if a compatible higher one is found: + *
    + *
  • 4.2-core -> 4.2-core, 3.3-core
  • + *
  • 4.2-comp -> 4.2-comp, 3.3-comp, 2
  • + *
+ * Otherwise the dedicated GL context would be queried and used: + *
    + *
  • 4.2-core -> 4.2-core
  • + *
  • 3.3-core -> 3.3-core
  • + *
  • 4.2-comp -> 4.2-comp
  • + *
  • 3.3-comp -> 3.3-comp
  • + *
  • 3.0-comp -> 2
  • + *
+ * Using aliasing speeds up initialization about: + *

- +

+

Another implementation detail is the drawable reconfiguration. One use case is where a window is being dragged to another screen with a different pixel configuration, ie {@link GLCapabilities}. The implementation - shall be able to detect such cases in conjunction with the associated {@link javax.media.nativewindow.NativeSurface NativeSurface}.
+ shall be able to detect such cases in conjunction with the associated {@link javax.media.nativewindow.NativeSurface NativeSurface}.
For example, AWT's {@link java.awt.Canvas} 's {@link java.awt.Canvas#getGraphicsConfiguration getGraphicsConfiguration()} is capable to determine a display device change. This is demonstrated within {@link javax.media.opengl.awt.GLCanvas}'s and NEWT's AWTCanvas {@link javax.media.opengl.awt.GLCanvas#getGraphicsConfiguration getGraphicsConfiguration()} specialization. Another demonstration is NEWT's {@link javax.media.nativewindow.NativeWindow NativeWindow} - implementation on the Windows platform, which utilizes the native platform's MonitorFromWindow(HWND) function.
+ implementation on the Windows platform, which utilizes the native platform's MonitorFromWindow(HWND) function.
All OpenGL resources shall be regenerated, while the drawable's {@link GLCapabilities} has - to be choosen again. The following protocol shall be satisfied. + to be chosen again. The following protocol shall be satisfied.

  • Controlled disposal:
    • @@ -97,16 +97,16 @@ import jogamp.opengl.Debug;
    Note: Current graphics driver keep the surface configuration for a given window, even if the window is moved to a monitor with a different pixel configuration, ie 32bpp to 16bpp. However, it is best to not assume such behavior - and make your application comply with the above protocol.

    - - However, to not introduce to much breakage with older applications and because of the situation + and make your application comply with the above protocol. +

    + Avoiding breakage with older applications and because of the situation mentioned above, the boolean system property jogl.screenchange.action will control the - screen change action as follows:
    - + screen change action as follows:

         -Djogl.screenchange.action=false Disable the drawable reconfiguration (the default)
         -Djogl.screenchange.action=true  Enable  the drawable reconfiguration
         
    +

    */ public interface GLAutoDrawable extends GLDrawable { /** Flag reflecting wheather the drawable reconfiguration will be issued in @@ -362,5 +362,29 @@ public interface GLAutoDrawable extends GLDrawable { demos for examples. @return the set GL pipeline or null if not successful */ public GL setGL(GL gl); + + /** + * Method may return the upstream UI toolkit object + * holding this {@link GLAutoDrawable} instance, if exist. + *

    + * Currently known Java UI toolkits and it's known return types are: + * + * + *
    Toolkit GLAutoDrawable Implementation ~ Return Type of getUpstreamWidget() + *
    NEWT {@link com.jogamp.newt.opengl.GLWindow} has a {@link com.jogamp.newt.Window} + *
    SWT {@link com.jogamp.opengl.swt.GLCanvas} is a {@link org.eclipse.swt.widgets.Canvas} + *
    AWT {@link javax.media.opengl.awt.GLCanvas} is a {@link java.awt.Canvas} + *
    AWT {@link javax.media.opengl.awt.GLJPanel} is a {@link javax.swing.JPanel} + *
    + * However, the result may be other object types than the listed above + * due to new supported toolkits. + *

    + *

    + * This method may also return null if no UI toolkit is being used, + * as common for offscreen rendering. + *

    + * @return + */ + public Object getUpstreamWidget(); } diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java index 89d5cc4cb..1f6166719 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java @@ -56,8 +56,14 @@ import jogamp.opengl.GLDrawableImpl; public class GLAutoDrawableDelegate extends GLAutoDrawableBase { public static final boolean DEBUG = Debug.debug("GLAutoDrawableDelegate"); - public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context) { + /** + * @param drawable + * @param context + * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + */ + public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget) { super((GLDrawableImpl)drawable, (GLContextImpl)context); + this.upstreamWidget = null; } // @@ -80,8 +86,14 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { // Complete GLAutoDrawable // - private RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock - + private final RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock + private final Object upstreamWidget; + + @Override + public final Object getUpstreamWidget() { + return upstreamWidget; + } + /** * {@inheritDoc} *

    diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index bd24b15bc..f5831a72d 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -340,5 +340,60 @@ public interface GLBase { * completeness. */ public Object getExtension(String extensionName); + + /** Aliased entrypoint of void {@native glClearDepth}(GLclampd depth); and void {@native glClearDepthf}(GLclampf depth); . */ + public void glClearDepth( double depth ); + + /** Aliased entrypoint of void {@native glDepthRange}(GLclampd depth); and void {@native glDepthRangef}(GLclampf depth); . */ + public void glDepthRange(double zNear, double zFar); + + /** + * @param target a GL buffer (VBO) target as used in {@link GL#glBindBuffer(int, int)}, ie {@link GL#GL_ELEMENT_ARRAY_BUFFER}, {@link GL#GL_ARRAY_BUFFER}, .. + * @return the GL buffer (VBO) name bound to a target via {@link GL#glBindBuffer(int, int)} or 0 if unbound. + */ + public int glGetBoundBuffer(int target); + + /** + * @param buffer a GL buffer name, generated with {@link GL#glGenBuffers(int, int[], int)} and used in {@link GL#glBindBuffer(int, int)}, {@link GL#glBufferData(int, long, java.nio.Buffer, int)} or {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} for example. + * @return the size of the given GL buffer + */ + public long glGetBufferSize(int buffer); + + /** + * @return true if a VBO is bound to {@link GL.GL_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false + */ + public boolean glIsVBOArrayEnabled(); + + /** + * @return true if a VBO is bound to {@link GL.GL_ELEMENT_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false + */ + public boolean glIsVBOElementArrayEnabled(); + + /** + * Return the framebuffer name bound to this context, + * see {@link GL#glBindFramebuffer(int, int)}. + */ + public int getBoundFramebuffer(int target); + + /** + * Return the default draw framebuffer name. + *

    + * May differ from it's default zero + * in case an framebuffer object ({@link FBObject}) based drawable + * is being used. + *

    + */ + public int getDefaultDrawFramebuffer(); + + /** + * Return the default read framebuffer name. + *

    + * May differ from it's default zero + * in case an framebuffer object ({@link FBObject}) based drawable + * is being used. + *

    + */ + public int getDefaultReadFramebuffer(); + } diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java index e5258bcfd..8845ec665 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java @@ -183,8 +183,8 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil return -1; } - final int ms = sampleBuffers ? numSamples : 0; - final int xms = caps.getSampleBuffers() ? caps.getNumSamples() : 0; + final int ms = getNumSamples(); + final int xms = caps.getNumSamples() ; if(ms > xms) { return 1; @@ -231,15 +231,13 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil /** * Enables or disables pbuffer usage. *

    - * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)} - * and {@link #setFBO(int) setFBO(false)}
    + * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)}. *

    * Defaults to false. */ public void setPBuffer(boolean enable) { if(enable) { setOnscreen(false); - setFBO(false); } isPBuffer = enable; } @@ -252,28 +250,28 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil /** * Enables or disables FBO usage. *

    - * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)} - * and {@link #setPBuffer(int) setPBuffer(false)}
    + * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)}. *

    * Defaults to false. */ public void setFBO(boolean enable) { if(enable) { setOnscreen(false); - setPBuffer(false); } isFBO = enable; } /** * Sets whether the drawable surface supports onscreen.
    - * If enabled this method also invokes {@link #setPBuffer(int) setPBuffer(false)}
    + * If enabled this method also invokes {@link #setPBuffer(int) setPBuffer(false)} + * and {@link #setFBO(int) setFBO(false)}
    * Defaults to true. */ @Override public void setOnscreen(boolean onscreen) { if(onscreen) { setPBuffer(false); + setFBO(false); } super.setOnscreen(onscreen); } @@ -413,15 +411,18 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil return sampleBuffers; } - /** If sample buffers are enabled, indicates the number of buffers - to be allocated. Defaults to 2. */ + /** + * If sample buffers are enabled, indicates the number of buffers + * to be allocated. Defaults to 2. + * @see #getNumSamples() + */ public void setNumSamples(int numSamples) { this.numSamples = numSamples; } @Override public final int getNumSamples() { - return numSamples; + return sampleBuffers ? numSamples : 0; } /** For pbuffers only, indicates whether floating-point buffers @@ -492,12 +493,14 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil if(!isOnscreen()) { if(isFBO) { sink.append(", fbo"); - } else if(isPBuffer) { + } + if(isPBuffer) { sink.append(", pbuffer [r2t ").append(pbufferRenderToTexture?1:0) .append(", r2tr ").append(pbufferRenderToTextureRectangle?1:0) .append(", float ").append(pbufferFloatingPointBuffers?1:0) .append("]"); - } else { + } + if(!isFBO && !isPBuffer) { sink.append(", pixmap"); } } diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java index 883f3912e..7e0459b2d 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java @@ -111,7 +111,7 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { /** * Returns the number of sample buffers to be allocated if sample - * buffers are enabled. Defaults to 2. + * buffers are enabled, otherwise returns 0. Defaults to 2. */ int getNumSamples(); @@ -144,12 +144,12 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { boolean getStereo(); /** - * Indicates whether pbuffer is used/requested. + * Indicates whether pbuffer offscreen is used/requested. */ boolean isPBuffer(); /** - * Indicates whether FBO is used/requested. + * Indicates whether FBO offscreen is used/requested. */ boolean isFBO(); diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 351f90027..63a02ad9c 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -55,6 +55,7 @@ import com.jogamp.common.os.Platform; import com.jogamp.common.util.IntObjectHashMap; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.opengl.GLExtensions; /** Abstraction for an OpenGL rendering context. In order to perform OpenGL rendering, a context must be "made current" on the current @@ -69,6 +70,7 @@ import com.jogamp.common.util.locks.RecursiveLock; abstraction provides a stable object which clients can use to refer to a given context. */ public abstract class GLContext { + /** * If true (default), bootstrapping the available GL profiles * will use the highest compatible GL context for each profile, @@ -120,13 +122,13 @@ public abstract class GLContext { protected static final int CTX_PROFILE_ES = 1 << 3; /** ARB_create_context related: flag forward compatible. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_OPTION_FORWARD = 1 << 4; - /** ARB_create_context related: flag debug. Not a cache key. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ + /** ARB_create_context related: flag debug. Cache key value. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ public static final int CTX_OPTION_DEBUG = 1 << 5; /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 8; - /** Context supports FBO, details see {@link #hasFBO()}. + /** Context supports basic FBO, details see {@link #hasFBO()}. * Not a cache key. * @see #hasFBO() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) @@ -136,16 +138,6 @@ public abstract class GLContext { /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 15; - protected static final String GL_ARB_ES2_compatibility = "GL_ARB_ES2_compatibility"; - protected static final String GL_ARB_framebuffer_object = "GL_ARB_framebuffer_object"; - protected static final String GL_EXT_framebuffer_object = "GL_EXT_framebuffer_object"; - protected static final String GL_EXT_framebuffer_blit = "GL_EXT_framebuffer_blit"; - protected static final String GL_EXT_framebuffer_multisample = "GL_EXT_framebuffer_multisample"; - protected static final String GL_EXT_packed_depth_stencil = "GL_EXT_packed_depth_stencil"; - protected static final String GL_ARB_texture_non_power_of_two = "GL_ARB_texture_non_power_of_two"; - protected static final String GL_EXT_texture_format_BGRA8888 = "GL_EXT_texture_format_BGRA8888"; - protected static final String GL_IMG_texture_format_BGRA8888 = "GL_IMG_texture_format_BGRA8888"; - private static final ThreadLocal currentContext = new ThreadLocal(); private final HashMap attachedObjectsByString = new HashMap(); @@ -639,11 +631,19 @@ public abstract class GLContext { return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ; } - /** Returns whether the context supports FBO, hence is either GL-ES >= 2.0, >= core GL 3.0 or implements the extensions - * GL_ARB_ES2_compatibility, ARB_framebuffer_object or all of - * EXT_framebuffer_object, EXT_framebuffer_multisample, - * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. + /** + * Returns true if basic FBO support is available, otherwise false. + *

    + * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions + * GL_ARB_ES2_compatibility, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object or GL_OES_framebuffer_object. + *

    + *

    + * Basic FBO support may only include one color attachment and no multisampling, + * as well as limited internal formats for renderbuffer. + *

    * @see #CTX_IMPL_FBO + * @see com.jogamp.opengl.FBObject#supportsBasicFBO(GL) + * @see com.jogamp.opengl.FBObject#supportsFullFBO(GL) */ public final boolean hasFBO() { return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; @@ -659,13 +659,13 @@ public abstract class GLContext { /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returns true. */ public boolean isNPOTTextureAvailable() { - return isGL3() || isGLES2Compatible() || isExtensionAvailable(GL_ARB_texture_non_power_of_two); + return isGL3() || isGLES2Compatible() || isExtensionAvailable(GLExtensions.ARB_texture_non_power_of_two); } public boolean isTextureFormatBGRA8888Available() { return isGL2GL3() || - isExtensionAvailable(GL_EXT_texture_format_BGRA8888) || - isExtensionAvailable(GL_IMG_texture_format_BGRA8888) ; + isExtensionAvailable(GLExtensions.EXT_texture_format_BGRA8888) || + isExtensionAvailable(GLExtensions.IMG_texture_format_BGRA8888) ; } /** @see GLProfile#isGL4bc() */ @@ -798,7 +798,32 @@ public abstract class GLContext { } protected boolean bindSwapBarrierImpl(int group, int barrier) { /** nop per default .. **/ return false; } - + /** + * Return the framebuffer name bound to this context, + * see {@link GL#glBindFramebuffer(int, int)}. + */ + public abstract int getBoundFramebuffer(int target); + + /** + * Return the default draw framebuffer name. + *

    + * May differ from it's default zero + * in case an framebuffer object ({@link FBObject}) based drawable + * is being used. + *

    + */ + public abstract int getDefaultDrawFramebuffer(); + + /** + * Return the default read framebuffer name. + *

    + * May differ from it's default zero + * in case an framebuffer object ({@link FBObject}) based drawable + * is being used. + *

    + */ + public abstract int getDefaultReadFramebuffer(); + /** * @return The extension implementing the GLDebugOutput feature, * either GL_ARB_debug_output or GL_AMD_debug_output. @@ -984,6 +1009,7 @@ public abstract class GLContext { deviceVersionsAvailableSet.add(devKey); if (DEBUG) { System.err.println(getThreadName() + ": createContextARB: SET mappedVersionsAvailableSet "+devKey); + System.err.println(GLContext.dumpAvailableGLVersions(null).toString()); } } } @@ -1010,6 +1036,10 @@ public abstract class GLContext { validateProfileBits(profile, "profile"); validateProfileBits(resCtp, "resCtp"); + if(DEBUG) { + System.err.println("GLContext.mapAvailableGLVersion: "+device+": "+getGLVersion(reqMajor, 0, profile, null)+" -> "+getGLVersion(resMajor, resMinor, resCtp, null)); + // Thread.dumpStack(); + } final String key = getDeviceVersionAvailableKey(device, reqMajor, profile); final Integer val = new Integer(composeBits(resMajor, resMinor, resCtp)); synchronized(deviceVersionAvailable) { @@ -1122,7 +1152,9 @@ public abstract class GLContext { } else /* if (glpImpl.isGL2()) */ { reqMajorCTP[0]=2; } - if( glpImpl.isGL2() ) { // incl GL3bc and GL4bc + if( glpImpl.isGLES() ) { + reqMajorCTP[1]=CTX_PROFILE_ES; + } else if( glpImpl.isGL2() ) { // incl GL3bc and GL4bc reqMajorCTP[1]=CTX_PROFILE_COMPAT; } else { reqMajorCTP[1]=CTX_PROFILE_CORE; @@ -1141,8 +1173,7 @@ public abstract class GLContext { int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; - if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], - _major, _minor, _ctp)) { + if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], _major, _minor, _ctp)) { return _ctp[0]; } return 0; // n/a @@ -1180,6 +1211,23 @@ public abstract class GLContext { return null; } + /** + * Returns true if it is possible to create an framebuffer object (FBO). + *

    + * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. + *

    + *

    + * FBO support is queried as described in {@link #hasFBO()}. + *

    + * + * @param device the device to request whether FBO is available for + * @param glp {@link GLProfile} to check for FBO capabilities + * @see GLContext#hasFBO() + */ + public static final boolean isFBOAvailable(AbstractGraphicsDevice device, GLProfile glp) { + return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) ); + } + /** * @param device the device to request whether the profile is available for * @param reqMajor Key Value either 1, 2, 3 or 4 diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index d6480e7aa..612a02f14 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -50,9 +50,11 @@ import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; import javax.media.opengl.GLProfile.ShutdownType; import jogamp.opengl.Debug; @@ -398,9 +400,18 @@ public abstract class GLDrawableFactory { /** * Creates a Offscreen GLDrawable incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. *

    - * A Pbuffer drawable/surface is created if both {@link javax.media.opengl.GLCapabilities#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(javax.media.nativewindow.AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true.
    - * Otherwise a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated.
    + * It's {@link AbstractGraphicsConfiguration} is properly set according to the given {@link GLCapabilitiesImmutable}, see below. + *

    + *

    + * A FBO drawable is created if both {@link javax.media.opengl.GLCapabilities#isFBO() caps.isFBO()} + * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. + *

    + *

    + * A Pbuffer drawable is created if both {@link javax.media.opengl.GLCapabilities#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(javax.media.nativewindow.AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + *

    + *

    + * If neither FBO nor Pbuffer is available, a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated. *

    * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. @@ -421,42 +432,31 @@ public abstract class GLDrawableFactory { throws GLException; /** - * Creates an offscreen NativeSurface.
    - * A Pbuffer surface is created if both {@link javax.media.opengl.GLCapabilities#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(javax.media.nativewindow.AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true.
    - * Otherwise a simple pixmap/bitmap surface is created. The latter is unlikely to be hardware accelerated.
    - * - * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. - * @param caps the requested GLCapabilties - * @param chooser the custom chooser, may be null for default - * @param width the requested offscreen width - * @param height the requested offscreen height - * @return the created offscreen native surface - * - * @throws GLException if any window system-specific errors caused - * the creation of the GLDrawable to fail. - */ - public abstract NativeSurface createOffscreenSurface(AbstractGraphicsDevice device, - GLCapabilitiesImmutable caps, - GLCapabilitiesChooser chooser, - int width, int height); - - /** - * Highly experimental API entry, allowing developer of new windowing system bindings - * to leverage the native window handle to produce a NativeSurface implementation (ProxySurface), having the required GLCapabilities.
    - * Such surface can be used to instantiate a GLDrawable and hence test your new binding w/o the - * costs of providing a full set of abstraction like the AWT GLCanvas or even the native NEWT bindings. + * Creates a proxy {@link NativeSurface} w/ defined surface handle, i.e. a {@link WrappedSurface} or {@link GDISurface} instance. + *

    + * It's {@link AbstractGraphicsConfiguration} is properly set according to the given {@link GLCapabilitiesImmutable}. + *

    + *

    + * Lifecycle (destruction) of the given surface handle shall be handled by the caller. + *

    + *

    + * Such surface can be used to instantiate a GLDrawable. With the help of {@link GLAutoDrawableDelegate} + * you will be able to implement a new native windowing system binding almost on-the-fly, see {@link com.jogamp.opengl.swt.GLCanvas}. + *

    * - * @param device the platform's target device, shall not be null + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + * Caller has to ensure it is compatible w/ the given windowHandle + * @param screenIdx matching screen index of given windowHandle * @param windowHandle the native window handle * @param caps the requested GLCapabilties * @param chooser the custom chooser, may be null for default - * @return The proxy surface wrapping the windowHandle on the device + * @param upstream optional {@link ProxySurface.UpstreamSurfaceHook} allowing control of the {@link ProxySurface}'s lifecycle and data it presents. + * @return the created {@link ProxySurface} instance w/ defined surface handle. */ - public abstract ProxySurface createProxySurface(AbstractGraphicsDevice device, + public abstract ProxySurface createProxySurface(AbstractGraphicsDevice device, + int screenIdx, long windowHandle, - GLCapabilitiesImmutable caps, - GLCapabilitiesChooser chooser); + GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream); /** * Returns true if it is possible to create a GLPbuffer. Some older @@ -492,23 +492,7 @@ public abstract class GLDrawableFactory { GLContext shareWith) throws GLException; - /** - * Returns true if it is possible to create an framebuffer object (FBO). - *

    - * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. - *

    - *

    - * FBO support is queried as described in {@link GLContext#hasFBO()}. - *

    - * - * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. - * @param glp {@link GLProfile} to check for FBO capabilities - * @see GLContext#hasFBO() - */ - public final boolean canCreateFBO(AbstractGraphicsDevice device, GLProfile glp) { - return 0 != ( GLContext.CTX_IMPL_FBO & GLContext.getAvailableContextProperties(device, glp) ); - } - + //---------------------------------------------------------------------- // Methods for interacting with third-party OpenGL libraries diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index a7200b560..73d13a387 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -117,10 +117,12 @@ public class GLProfile { * @deprecated Use {@link #initSingleton()}. This method is subject to be removed in future versions of JOGL. */ public static void initSingleton(final boolean firstUIActionOnProcess) { + final boolean justInitialized; initLock.lock(); try { if(!initialized) { // volatile: ok initialized = true; + justInitialized = true; if(DEBUG) { System.err.println("GLProfile.initSingleton(firstUIActionOnProcess: "+firstUIActionOnProcess+") - thread "+Thread.currentThread().getName()); Thread.dumpStack(); @@ -166,10 +168,17 @@ public class GLProfile { return null; } }); + } else { + justInitialized = false; } } finally { initLock.unlock(); } + if(DEBUG) { + if( justInitialized && ( hasGL234Impl || hasGLES1Impl || hasGLES2Impl ) ) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(defaultDevice, null, true)); + } + } } /** @@ -1532,18 +1541,17 @@ public class GLProfile { if(DEBUG) { // System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")"); - System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile); - System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable); - System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory); - System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl); - System.err.println("GLProfile.init hasEGLFactory "+hasEGLFactory); - System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl); - System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl); - System.err.println("GLProfile.init defaultDevice "+defaultDevice); - System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL)); - if(hasGL234Impl || hasGLES1Impl || hasGLES2Impl) { // avoid deadlock - System.err.println(JoglVersion.getDefaultOpenGLInfo(null, true)); - } + System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile); + System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable); + System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory); + System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl); + System.err.println("GLProfile.init hasEGLFactory "+hasEGLFactory); + System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl); + System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl); + System.err.println("GLProfile.init defaultDevice "+defaultDevice); + System.err.println("GLProfile.init defaultDevice Desktop "+defaultDesktopDevice); + System.err.println("GLProfile.init defaultDevice EGL "+defaultEGLDevice); + System.err.println("GLProfile.init profile order "+array2String(GL_PROFILE_LIST_ALL)); } } @@ -1642,24 +1650,6 @@ public class GLProfile { if (DEBUG) { System.err.println("GLProfile.initProfilesForDevice: "+device+": egl Shared Ctx "+eglSharedCtxAvail); } - if( hasGLES2Impl ) { - // The native ES2 impl. overwrites a previous mapping using 'ES2 compatibility' by a desktop profile - GLContext.mapAvailableGLVersion(device, - 2, GLContext.CTX_PROFILE_ES, - 2, 0, GLContext.CTX_PROFILE_ES|GLContext.CTX_IMPL_ES2_COMPAT); - if (DEBUG) { - System.err.println(GLContext.getThreadName() + ": initProfilesForDeviceCritical-MapVersionsAvailable HAVE: ES2 -> ES 2.0"); - } - } - if( hasGLES1Impl ) { - // Always favor the native ES1 impl. - GLContext.mapAvailableGLVersion(device, - 1, GLContext.CTX_PROFILE_ES, - 1, 0, GLContext.CTX_PROFILE_ES); - if (DEBUG) { - System.err.println(GLContext.getThreadName() + ": initProfilesForDeviceCritical-MapVersionsAvailable HAVE: ES1 -> ES 1.0"); - } - } addedEGLProfile = computeProfileMap(device, false /* desktopCtxUndef*/, false /* esCtxUndef */); } @@ -1767,7 +1757,7 @@ public class GLProfile { } _mappedProfiles.put(profile, glProfile); if (DEBUG) { - System.err.println("GLProfile.init map "+glProfile+" on devide "+device.getConnection()); + System.err.println("GLProfile.init map "+glProfile+" on device "+device.getConnection()); } if(null==defaultGLProfileHW && isHardwareRasterizer[0]) { defaultGLProfileHW=glProfile; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 48f7ea24a..c2e36ef9b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -261,6 +261,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing this.device = device; } + @Override + public final Object getUpstreamWidget() { + return this; + } + @Override public void setShallUseOffscreenLayer(boolean v) { shallUseOffscreenLayer = v; @@ -1070,7 +1075,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // System.err.println(NativeWindowVersion.getInstance()); System.err.println(JoglVersion.getInstance()); - System.err.println(JoglVersion.getDefaultOpenGLInfo(null, true).toString()); + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, true).toString()); final GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault(GLProfile.getDefaultDevice()) ); final Frame frame = new Frame("JOGL AWT Test"); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index cd18c5098..acb8f2183 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -87,7 +87,7 @@ import jogamp.opengl.awt.Java2D; import jogamp.opengl.awt.Java2DGLContext; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; -import com.jogamp.opengl.util.FBObject; +import com.jogamp.opengl.FBObject; import com.jogamp.opengl.util.GLBuffers; // FIXME: Subclasses need to call resetGLFunctionAvailability() on their @@ -250,6 +250,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.shareWith = shareWith; } + @Override + public final Object getUpstreamWidget() { + return this; + } + @Override public void display() { if (EventQueue.isDispatchThread()) { diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java index 804e9ee14..aabef29b0 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/VBORegion2PES2.java @@ -32,7 +32,6 @@ import java.nio.FloatBuffer; import javax.media.opengl.GL2ES2; // FIXME: Subsume GL2GL3.GL_DRAW_FRAMEBUFFER -> GL2ES2.GL_DRAW_FRAMEBUFFER ! import javax.media.opengl.GL; -import javax.media.opengl.GLException; import javax.media.opengl.GLUniformData; import javax.media.opengl.fixedfunc.GLMatrixFunc; @@ -45,7 +44,9 @@ import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; -import com.jogamp.opengl.util.FBObject; +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.FBObject.TextureAttachment; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderState; @@ -60,6 +61,7 @@ public class VBORegion2PES2 extends GLRegion { private FBObject fbo; + private TextureAttachment texA; private PMVMatrix fboPMVMatrix; GLUniformData mgl_fboPMVMatrix; @@ -72,7 +74,7 @@ public class VBORegion2PES2 extends GLRegion { super(renderModes); fboPMVMatrix = new PMVMatrix(); mgl_fboPMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, fboPMVMatrix.glGetPMvMatrixf()); - mgl_ActiveTexture = new GLUniformData(UniformNames.gcu_TextureUnit, textureEngine); + mgl_ActiveTexture = new GLUniformData(UniformNames.gcu_TextureUnit, textureEngine); } public void update(GL2ES2 gl, RenderState rs) { @@ -214,8 +216,9 @@ public class VBORegion2PES2 extends GLRegion { final ShaderState st = rs.getShaderState(); gl.glViewport(0, 0, width, hight); - st.uniform(gl, mgl_ActiveTexture); - fbo.use(gl, 0); + st.uniform(gl, mgl_ActiveTexture); + gl.glActiveTexture(GL.GL_TEXTURE0 + mgl_ActiveTexture.intValue()); + fbo.use(gl, texA); verticeFboAttr.enableBuffer(gl, true); texCoordFboAttr.enableBuffer(gl, true); indicesFbo.enableBuffer(gl, true); @@ -244,20 +247,16 @@ public class VBORegion2PES2 extends GLRegion { // System.out.println("FBO Scale: " + m.glGetMatrixf().get(0) +" " + m.glGetMatrixf().get(5)); if(null != fbo && fbo.getWidth() != tex_width_c && fbo.getHeight() != tex_height_c ) { - fbo.destroy(gl); - fbo = null; + fbo.reset(gl, tex_width_c, tex_height_c); } - if(null == fbo) { - fbo = new FBObject(tex_width_c, tex_height_c); - fbo.init(gl); + if(null == fbo) { + fbo = new FBObject(); + fbo.reset(gl, tex_width_c, tex_height_c); // FIXME: shall not use bilinear, due to own AA ? However, w/o bilinear result is not smooth - fbo.attachTexture2D(gl, mgl_ActiveTexture.intValue(), GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); - // fbo.attachTexture2D(gl, mgl_ActiveTexture.intValue(), GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); - fbo.attachDepthBuffer(gl, GL.GL_DEPTH_COMPONENT16); // FIXME: or shall we use 24 or 32 bit depth ? - if(!fbo.isStatusValid()) { - throw new GLException("FBO invalid: "+fbo); - } + texA = fbo.attachTexture2D(gl, 0, true, GL2ES2.GL_LINEAR, GL2ES2.GL_LINEAR, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); + // texA = fbo.attachTexture2D(gl, 0, GL2ES2.GL_NEAREST, GL2ES2.GL_NEAREST, GL2ES2.GL_CLAMP_TO_EDGE, GL2ES2.GL_CLAMP_TO_EDGE); + fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); } else { fbo.bind(gl); } @@ -305,6 +304,7 @@ public class VBORegion2PES2 extends GLRegion { if(null != fbo) { fbo.destroy(gl); fbo = null; + texA = null; } if(null != verticeTxtAttr) { st.ownAttribute(verticeTxtAttr, false); diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 4dd8806fa..e730bc62e 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -49,8 +49,9 @@ import com.jogamp.common.os.DynamicLookupHelper; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.gluegen.runtime.ProcAddressTable; -import com.jogamp.gluegen.runtime.opengl.GLExtensionNames; +import com.jogamp.gluegen.runtime.opengl.GLNameResolver; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.opengl.GLExtensions; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -88,13 +89,14 @@ public abstract class GLContextImpl extends GLContext { // Tracks creation and initialization of buffer objects to avoid // repeated glGet calls upon glMapBuffer operations private GLBufferSizeTracker bufferSizeTracker; // Singleton - Set by GLContextShareSet - private GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); - private GLStateTracker glStateTracker = new GLStateTracker(); + private final GLBufferStateTracker bufferStateTracker = new GLBufferStateTracker(); + private final GLStateTracker glStateTracker = new GLStateTracker(); private GLDebugMessageHandler glDebugHandler = null; + private final int[] boundFBOTarget = new int[] { 0, 0 }; // { draw, read } protected GLDrawableImpl drawable; protected GLDrawableImpl drawableRead; - + protected GL gl; protected static final Object mappedContextTypeObjectLock; @@ -140,11 +142,11 @@ public abstract class GLContextImpl extends GLContext { bufferSizeTracker.clearCachedBufferSizes(); } - if (bufferStateTracker != null) { + if (bufferStateTracker != null) { // bufferStateTracker.clearBufferObjectState(); } - if (glStateTracker != null) { + if (glStateTracker != null) { // glStateTracker.clearStates(false); } @@ -156,6 +158,11 @@ public abstract class GLContextImpl extends GLContext { glRenderer = ""; glRendererLowerCase = glRenderer; + + if (boundFBOTarget != null) { // + boundFBOTarget[0] = 0; // draw + boundFBOTarget[1] = 0; // read + } super.resetStates(); } @@ -199,7 +206,7 @@ public abstract class GLContextImpl extends GLContext { drawableRead = (GLDrawableImpl) readWrite; } final GLDrawable old = drawable; - drawable = ( null != readWrite ) ? (GLDrawableImpl) readWrite : null; + drawable = (GLDrawableImpl) readWrite ; if(lockHeld) { makeCurrent(); } @@ -252,16 +259,19 @@ public abstract class GLContextImpl extends GLContext { public void release() throws GLException { release(false); } - private void release(boolean force) throws GLException { + private void release(boolean inDestruction) throws GLException { if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - release() - force: "+force+", "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - release() - force: "+inDestruction+", "+lock); } if ( !lock.isOwner(Thread.currentThread()) ) { throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this); } - final boolean actualRelease = ( force || lock.getHoldCount() == 1 ) && 0 != contextHandle; + final boolean actualRelease = ( inDestruction || lock.getHoldCount() == 1 ) && 0 != contextHandle; try { if( actualRelease ) { + if( !inDestruction ) { + drawable.contextMadeCurrent(this, false); + } releaseImpl(); } } finally { @@ -306,13 +316,12 @@ public abstract class GLContextImpl extends GLContext { } try { // release current context - if(null != glDebugHandler) { - if(lock.getHoldCount() == 1) { - // needs current context to disable debug handler - makeCurrent(); - } - glDebugHandler.enable(false); + if(lock.getHoldCount() == 1) { + // needs current context to disable debug handler + makeCurrent(); } + drawable.contextRealized(this, false); + glDebugHandler.enable(false); if(lock.getHoldCount() > 1) { // pending release() after makeCurrent() release(true); @@ -488,11 +497,18 @@ public abstract class GLContextImpl extends GLContext { if(TRACE_GL) { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); } + + drawable.contextRealized(this, true); + if(DEBUG || TRACE_SWITCH) { System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT_NEW - "+lock); } - } else if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock); + } else { + drawable.contextMadeCurrent(this, true); + + if(TRACE_SWITCH) { + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock); + } } /* FIXME: refactor dependence on Java 2D / JOGL bridge @@ -543,14 +559,11 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice device = config.getScreen().getDevice(); - if( !GLContext.getAvailableGLVersionsSet(device) ) { - final int reqMajor; - final int reqProfile; - if( 0 != ( ctxOptions & GLContext.CTX_PROFILE_ES) ) { - // ES1 or ES2 - reqMajor = ctxMajorVersion; - reqProfile = GLContext.CTX_PROFILE_ES; - } else { + // Non ARB desktop profiles may not have been registered + if( !GLContext.getAvailableGLVersionsSet(device) ) { // not yet set + if( 0 == ( ctxOptions & GLContext.CTX_PROFILE_ES) ) { // not ES profile + final int reqMajor; + final int reqProfile; if(ctxMajorVersion<3 || ctxMajorVersion==3 && ctxMinorVersion==0) { reqMajor = 2; } else { @@ -561,12 +574,13 @@ public abstract class GLContextImpl extends GLContext { } else { reqProfile = GLContext.CTX_PROFILE_COMPAT; } - } - GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, - ctxMajorVersion, ctxMinorVersion, ctxOptions); - GLContext.setAvailableGLVersionsSet(device); - if (DEBUG) { - System.err.println(getThreadName() + ": createContextOLD-MapVersionsAvailable HAVE: " + device+" -> "+reqMajor+"."+reqProfile+ " -> "+getGLVersion()); + GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, + ctxMajorVersion, ctxMinorVersion, ctxOptions); + GLContext.setAvailableGLVersionsSet(device); + + if (DEBUG) { + System.err.println(getThreadName() + ": createContextOLD-MapVersionsAvailable HAVE: " + device+" -> "+reqMajor+"."+reqProfile+ " -> "+getGLVersion()); + } } } } @@ -776,7 +790,7 @@ public abstract class GLContextImpl extends GLContext { } /** - * Note: Since context creation is temproary, caller need to issue {@link #resetStates()}, if creation was successful, i.e. returns true. + * Note: Since context creation is temporary, caller need to issue {@link #resetStates()}, if creation was successful, i.e. returns true. * This method does not reset the states, allowing the caller to utilize the state variables. **/ private final boolean createContextARBMapVersionsAvailable(int reqMajor, int reqProfile) { @@ -1034,22 +1048,29 @@ public abstract class GLContextImpl extends GLContext { table.reset(getDrawableImpl().getGLDynamicLookupHelper() ); } - private final void initGLRendererStrings() { + private final boolean initGLRendererStrings() { final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper(); final long _glGetString = glDynLookupHelper.dynamicLookupFunction("glGetString"); if(0 == _glGetString) { // FIXME System.err.println("Warning: Entry point to 'glGetString' is NULL."); - Thread.dumpStack(); + if(DEBUG) { + Thread.dumpStack(); + } + return false; } else { final String _glRenderer = glGetStringInt(GL.GL_RENDERER, _glGetString); if(null == _glRenderer) { // FIXME - System.err.println("Warning: GL_RENDERER is NULL."); - Thread.dumpStack(); + if(DEBUG) { + System.err.println("Warning: GL_RENDERER is NULL."); + Thread.dumpStack(); + } + return false; } else { glRenderer = _glRenderer; glRendererLowerCase = glRenderer.toLowerCase(); + return true; } } } @@ -1088,17 +1109,20 @@ public abstract class GLContextImpl extends GLContext { } updateGLXProcAddressTable(); - initGLRendererStrings(); + final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); + final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); + + if( !initGLRendererStrings() && DEBUG) { + System.err.println("Warning: intialization of GL renderer strings failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + } if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; } - final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); - final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { - System.err.println(getThreadName() + ": Context FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } // @@ -1154,11 +1178,10 @@ public abstract class GLContextImpl extends GLContext { } } - if( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && ctxMajorVersion >= 2 || - isExtensionAvailable(GL_ARB_ES2_compatibility) ) { + if( ( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && major >= 2 ) || isExtensionAvailable(GLExtensions.ARB_ES2_compatibility) ) { ctxProfileBits |= CTX_IMPL_ES2_COMPAT; ctxProfileBits |= CTX_IMPL_FBO; - } else if( hasFBOImpl(ctxMajorVersion, ctxProfileBits, extensionAvailability) ) { + } else if( hasFBOImpl(major, ctxProfileBits, extensionAvailability) ) { ctxProfileBits |= CTX_IMPL_FBO; } @@ -1168,23 +1191,26 @@ public abstract class GLContextImpl extends GLContext { setContextVersion(major, minor, ctxProfileBits, true); setDefaultSwapInterval(); + + if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: "+contextFQN+" - "+GLContext.getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, null)); + } } - protected static final boolean hasFBOImpl(int ctxMajorVersion, int ctxProfileBits, ExtensionAvailabilityCache extCache) { - return ( ctxMajorVersion >= 3 ) || // any >= 3.0 GL ctx + protected static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) { + return ( 0 != (ctp & CTX_PROFILE_ES) && major >= 2 ) || // ES >= 2.0 - ( 0 != (ctxProfileBits & CTX_PROFILE_ES) && ctxMajorVersion >= 2 ) || // ES >= 2.0 + major >= 3 || // any >= 3.0 GL ctx ( null != extCache && - ( extCache.isExtensionAvailable(GL_ARB_ES2_compatibility) ) || // ES 2.0 compatible + extCache.isExtensionAvailable(GLExtensions.ARB_ES2_compatibility) || // ES 2.0 compatible - ( extCache.isExtensionAvailable(GL_ARB_framebuffer_object) ) || // ARB_framebuffer_object + extCache.isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object - ( extCache.isExtensionAvailable(GL_EXT_framebuffer_object) && // EXT_framebuffer_object* - extCache.isExtensionAvailable(GL_EXT_framebuffer_multisample) && - extCache.isExtensionAvailable(GL_EXT_framebuffer_blit) && - extCache.isExtensionAvailable(GL_EXT_packed_depth_stencil) ) ); + extCache.isExtensionAvailable(GLExtensions.EXT_framebuffer_object) || // EXT_framebuffer_object + + extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object) ) ; // OES_framebuffer_object excluded } protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) { @@ -1259,11 +1285,11 @@ public abstract class GLContextImpl extends GLContext { // dynamic function lookup at last incl name aliasing (not cached) DynamicLookupHelper dynLookup = getDrawableImpl().getGLDynamicLookupHelper(); - String tmpBase = GLExtensionNames.normalizeVEN(GLExtensionNames.normalizeARB(glFunctionName, true), true); + String tmpBase = GLNameResolver.normalizeVEN(GLNameResolver.normalizeARB(glFunctionName, true), true); long addr = 0; - int variants = GLExtensionNames.getFuncNamePermutationNumber(tmpBase); + int variants = GLNameResolver.getFuncNamePermutationNumber(tmpBase); for(int i = 0; 0==addr && i < variants; i++) { - String tmp = GLExtensionNames.getFuncNamePermutation(tmpBase, i); + String tmp = GLNameResolver.getFuncNamePermutation(tmpBase, i); try { addr = dynLookup.dynamicLookupFunction(tmp); } catch (Exception e) { } @@ -1317,7 +1343,7 @@ public abstract class GLContextImpl extends GLContext { protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) { // remove non-key values - ctxProfileBits &= ~( GLContext.CTX_OPTION_DEBUG | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) ; + ctxProfileBits &= ~( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) ; return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); } @@ -1371,6 +1397,56 @@ public abstract class GLContextImpl extends GLContext { return lock.getQueueLength()>0; } + //--------------------------------------------------------------------------- + // Special FBO hook + // + + /** + * Tracks {@link GL#GL_FRAMEBUFFER}, {@link GL2GL3#GL_DRAW_FRAMEBUFFER} and {@link GL2GL3#GL_READ_FRAMEBUFFER} + * to be returned via {@link #getBoundFramebuffer(int)}. + * + *

    Invoked by {@link GL#glBindFramebuffer(int, int)}.

    + * + *

    Assumes valid framebufferName range of [0..{@link Integer#MAX_VALUE}]

    + * + *

    Does not throw an exception if target is unknown or framebufferName invalid.

    + */ + public final void setBoundFramebuffer(int target, int framebufferName) { + if(0 > framebufferName) { + return; // ignore invalid name + } + switch(target) { + case GL.GL_FRAMEBUFFER: + boundFBOTarget[0] = framebufferName; // draw + boundFBOTarget[1] = framebufferName; // read + break; + case GL2GL3.GL_DRAW_FRAMEBUFFER: + boundFBOTarget[0] = framebufferName; // draw + break; + case GL2GL3.GL_READ_FRAMEBUFFER: + boundFBOTarget[1] = framebufferName; // read + break; + default: // ignore untracked target + } + } + @Override + public final int getBoundFramebuffer(int target) { + switch(target) { + case GL.GL_FRAMEBUFFER: + case GL2GL3.GL_DRAW_FRAMEBUFFER: + return boundFBOTarget[0]; // draw + case GL2GL3.GL_READ_FRAMEBUFFER: + return boundFBOTarget[1]; // read + default: + throw new InternalError("Invalid FBO target name: "+toHexString(target)); + } + } + + @Override + public final int getDefaultDrawFramebuffer() { return drawable.getDefaultDrawFramebuffer(); } + @Override + public final int getDefaultReadFramebuffer() { return drawable.getDefaultReadFramebuffer(); } + //--------------------------------------------------------------------------- // GL_ARB_debug_output, GL_AMD_debug_output helpers // diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java index b950c2fdf..0000e6199 100644 --- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java +++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java @@ -37,6 +37,8 @@ import javax.media.opengl.GLException; import com.jogamp.common.os.Platform; import com.jogamp.gluegen.runtime.ProcAddressTable; +import com.jogamp.opengl.GLExtensions; + import jogamp.opengl.gl4.GL4bcProcAddressTable; /** @@ -54,12 +56,6 @@ import jogamp.opengl.gl4.GL4bcProcAddressTable; * the messages are translated to ARB {@link GLDebugMessage}, using {@link GLDebugMessage#translateAMDEvent(javax.media.opengl.GLContext, long, int, int, int, String)}.

    */ public class GLDebugMessageHandler { - /** Extension GL_ARB_debug_output implementing GLDebugMessage */ - public static final String GL_ARB_debug_output = "GL_ARB_debug_output".intern(); - - /** Extension GL_AMD_debug_output implementing GLDebugMessage */ - public static final String GL_AMD_debug_output = "GL_AMD_debug_output".intern(); - private static final boolean DEBUG = Debug.debug("GLDebugMessageHandler"); private static final int EXT_ARB = 1; @@ -131,11 +127,11 @@ public class GLDebugMessageHandler { } return; } - if( ctx.isExtensionAvailable(GL_ARB_debug_output) ) { - extName = GL_ARB_debug_output; + if( ctx.isExtensionAvailable(GLExtensions.ARB_debug_output) ) { + extName = GLExtensions.ARB_debug_output; extType = EXT_ARB; - } else if( ctx.isExtensionAvailable(GL_AMD_debug_output) ) { - extName = GL_AMD_debug_output; + } else if( ctx.isExtensionAvailable(GLExtensions.AMD_debug_output) ) { + extName = GLExtensions.AMD_debug_output; extType = EXT_AMD; } if(DEBUG) { @@ -145,6 +141,8 @@ public class GLDebugMessageHandler { if(0 == extType) { if(DEBUG) { System.err.println("GLDebugMessageHandler: No extension available! "+ctx.getGLVersion()); + System.err.println("GL_EXTENSIONS "+ctx.getGLExtensionCount()); + System.err.println(ctx.getGLExtensionsString()); } return; } @@ -190,11 +188,11 @@ public class GLDebugMessageHandler { } public final boolean isExtensionARB() { - return extName == GL_ARB_debug_output; + return extName == GLExtensions.ARB_debug_output; } public final boolean isExtensionAMD() { - return extName == GL_AMD_debug_output; + return extName == GLExtensions.AMD_debug_output; } /** diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index e5c44a8d4..897d3fcaf 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -47,7 +47,8 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; @@ -88,7 +89,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { return null; } protected abstract GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device); - + /** * Returns the shared device mapped to the device {@link AbstractGraphicsDevice#getConnection()}, * either a preexisting or newly created, or null if creation failed or not supported.
    @@ -115,7 +116,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } protected abstract AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device); - /** + /** * Returns the GLDynamicLookupHelper * @param profile if EGL/ES, profile 1 refers to ES1 and 2 to ES2, * otherwise the profile is ignored. @@ -125,6 +126,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // Dispatching GLDrawable construction in respect to the NativeSurface Capabilities // + @Override public GLDrawable createGLDrawable(NativeSurface target) { if (target == null) { throw new IllegalArgumentException("Null target"); @@ -132,23 +134,37 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final MutableGraphicsConfiguration config = (MutableGraphicsConfiguration) target.getGraphicsConfiguration(); final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); final AbstractGraphicsDevice adevice = config.getScreen().getDevice(); + final boolean isFBOAvailable = GLContext.isFBOAvailable(adevice, chosenCaps.getGLProfile()); GLDrawable result = null; adevice.lock(); try { final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true); if(null != ols) { - // layered surface -> Offscreen/PBuffer + // layered surface -> Offscreen/[FBO|PBuffer] final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); chosenCapsMod.setOnscreen(false); - chosenCapsMod.setPBuffer(canCreateGLPbuffer(adevice)); + if( isFBOAvailable ) { + chosenCapsMod.setFBO(true); + } else if(canCreateGLPbuffer(adevice)) { + chosenCapsMod.setPBuffer(true); + } else { + chosenCapsMod.setFBO(false); + chosenCapsMod.setPBuffer(false); + } config.setChosenCapabilities(chosenCapsMod); if(DEBUG) { System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable -> Offscreen-Layer: "+target); } - if( ! ( target instanceof SurfaceChangeable ) ) { + if( ! ( target instanceof MutableSurface ) ) { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target); + } + if( ((GLCapabilitiesImmutable)config.getRequestedCapabilities()).isFBO() && isFBOAvailable ) { + // FIXME JAU: Need to revise passed MutableSurface to work w/ FBO .. + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(target); + result = new GLFBODrawableImpl(this, dummyDrawable, target, target.getWidth(), target.getHeight(), 0 /* textureUnit */); + } else { + result = createOffscreenDrawableImpl(target); } - result = createOffscreenDrawableImpl(target); } else if(chosenCaps.isOnscreen()) { // onscreen if(DEBUG) { @@ -158,12 +174,18 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } else { // offscreen if(DEBUG) { - System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable (PBuffer: "+chosenCaps.isPBuffer()+"): "+target); + System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable, FBO-chosen(-avail)/PBuffer: "+chosenCaps.isFBO()+"("+isFBOAvailable+")/"+chosenCaps.isPBuffer()+": "+target); } - if( ! ( target instanceof SurfaceChangeable ) ) { + if( ! ( target instanceof MutableSurface ) ) { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target); } - result = createOffscreenDrawableImpl(target); + if( ((GLCapabilitiesImmutable)config.getRequestedCapabilities()).isFBO() && isFBOAvailable ) { + // FIXME JAU: Need to revise passed MutableSurface to work w/ FBO .. + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(target); + result = new GLFBODrawableImpl(this, dummyDrawable, target, target.getWidth(), target.getHeight(), 0 /* textureUnit */); + } else { + result = createOffscreenDrawableImpl(target); + } } } finally { adevice.unlock(); @@ -176,43 +198,42 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // - // Onscreen GLDrawable construction + // Onscreen GLDrawable construction // protected abstract GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target); //--------------------------------------------------------------------------- // - // PBuffer Offscreen GLDrawable construction + // PBuffer Offscreen GLDrawable construction // - + + @Override public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device); + @Override public GLPbuffer createGLPbuffer(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height, GLContext shareWith) { - if(height<=0 || height<=0) { - throw new GLException("Width and height of pbuffer must be positive (were (" + - width + ", " + height + "))"); + if(width<=0 || height<=0) { + throw new GLException("initial size must be positive (were (" + width + " x " + height + "))"); } - AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - - if (!canCreateGLPbuffer(device)) { - throw new GLException("Pbuffer support not available with device: "+device); + if ( !canCreateGLPbuffer(device) ) { + throw new GLException("Pbuffer not available with device: "+device); } - - GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(capsRequested); + + final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(capsRequested); GLDrawableImpl drawable = null; device.lock(); try { - drawable = (GLDrawableImpl) createGLDrawable( createOffscreenSurfaceImpl(device, capsChosen, capsRequested, chooser, width, height) ); + drawable = (GLDrawableImpl) createGLDrawable( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, width, height, null) ); if(null != drawable) { drawable.setRealized(true); } @@ -228,75 +249,155 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // - // Offscreen GLDrawable construction + // Offscreen GLDrawable construction // - protected abstract GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) ; - + @Override public GLDrawable createOffscreenDrawable(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, - int width, - int height) { + int width, int height) { if(width<=0 || height<=0) { - throw new GLException("Width and height of pbuffer must be positive (were (" + - width + ", " + height + "))"); + throw new GLException("initial size must be positive (were (" + width + " x " + height + "))"); } - AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); + final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffScreenGLCapabilities(capsRequested, canCreateGLPbuffer(deviceReq)); - + + if( capsRequested.isFBO() && GLContext.isFBOAvailable(device, capsRequested.getGLProfile()) ) { + device.lock(); + try { + return createFBODrawableImpl(device, capsRequested, chooser, width, height); + } finally { + device.unlock(); + } + } + + final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, false, canCreateGLPbuffer(device)); device.lock(); try { - return createGLDrawable( createOffscreenSurfaceImpl(device, capsChosen, capsRequested, chooser, width, height) ); + return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, width, height, null) ); } finally { device.unlock(); } } - public NativeSurface createOffscreenSurface(AbstractGraphicsDevice deviceReq, - GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, - int width, int height) { - AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); + /** Creates a platform independent offscreen FBO GLDrawable implementation */ + protected GLDrawable createFBODrawableImpl(AbstractGraphicsDevice device, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, + int initialWidth, int initialHeight) { + final GLCapabilitiesImmutable dummyCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + final NativeSurface dummySurface = createDummySurfaceImpl(device, true, dummyCaps, null, 64, 64); + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); + + return new GLFBODrawableImpl(this, dummyDrawable, dummySurface, initialWidth, initialHeight, 0 /* textureUnit */); + } + + /** Creates a platform dependent offscreen pbuffer/pixmap GLDrawable implementation */ + protected abstract GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) ; + + /** + * Creates a mutable {@link ProxySurface} w/o defined surface handle. + *

    + * It's {@link AbstractGraphicsConfiguration} is properly set according to the given {@link GLCapabilitiesImmutable}. + *

    + *

    + * Lifecycle (destruction) of the TBD surface handle shall be handled by the caller. + *

    + * @param device a valid platform dependent target device. + * @param createNewDevice if true a new device instance is created using device details, + * otherwise device instance is used as-is. + * @param capsChosen + * @param capsRequested + * @param chooser the custom chooser, may be null for default + * @param width the initial width + * @param height the initial height + * @param lifecycleHook optional control of the surface's lifecycle + * @return the created {@link MutableSurface} instance w/o defined surface handle + */ + protected abstract ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, + GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook); + + /** + * A dummy surface is not visible on screen and will not be used to render directly to, + * it maybe on- or offscreen. + *

    + * It is used to allow the creation of a {@link GLDrawable} and {@link GLContext} to query information. + * It also allows creation of framebuffer objects which are used for rendering. + *

    + * @param deviceReq which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. + * @param requestedCaps + * @param chooser the custom chooser, may be null for default + * @param width the initial width + * @param height the initial height + * + * @return the created {@link MutableSurface} instance w/o defined surface handle + */ + public NativeSurface createDummySurface(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, + int width, int height) { + final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffScreenGLCapabilities(capsRequested, canCreateGLPbuffer(deviceReq)); - device.lock(); try { - return createOffscreenSurfaceImpl(device, capsChosen, capsRequested, chooser, width, height); + return createDummySurfaceImpl(device, true, requestedCaps, chooser, width, height); } finally { device.unlock(); } } - + /** - * creates an offscreen NativeSurface, which must implement SurfaceChangeable as well, - * so the windowing system related implementation is able to set the surface handle. + * A dummy surface is not visible on screen and will not be used to render directly to, + * it maybe on- or offscreen. + *

    + * It is used to allow the creation of a {@link GLDrawable} and {@link GLContext} to query information. + * It also allows creation of framebuffer objects which are used for rendering. + *

    + * @param device a valid platform dependent target device. + * @param createNewDevice if true a new device instance is created using device details, + * otherwise device instance is used as-is. + * @param requestedCaps + * @param chooser the custom chooser, may be null for default + * @param width the initial width + * @param height the initial height + * @return the created {@link MutableSurface} instance w/o defined surface handle */ - protected abstract NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device, - GLCapabilitiesImmutable capabilities, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, - int width, int height); + public abstract ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); - public ProxySurface createProxySurface(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { + //--------------------------------------------------------------------------- + // + // ProxySurface (Wrapped pre-existing native surface) construction + // + + @Override + public ProxySurface createProxySurface(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, + GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { - throw new GLException("No shared device for requested: "+device); + throw new GLException("No shared device for requested: "+deviceReq); } device.lock(); try { - return createProxySurfaceImpl(device, windowHandle, capsRequested, chooser); + return createProxySurfaceImpl(device, screenIdx, windowHandle, capsRequested, chooser, upstream); } finally { device.unlock(); } - } - - protected abstract ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser); + } + + /** + * Creates a {@link ProxySurface} with a set surface handle. + *

    + * Implementation is also required to allocate it's own {@link AbstractGraphicsDevice} instance. + *

    + * @param upstream TODO + */ + protected abstract ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, + GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream); //--------------------------------------------------------------------------- // @@ -304,7 +405,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // protected abstract GLContext createExternalGLContextImpl(); - + + @Override public GLContext createExternalGLContext() { NativeWindowFactory.getDefaultToolkitLock().lock(); try { @@ -316,6 +418,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { protected abstract GLDrawable createExternalGLDrawableImpl(); + @Override public GLDrawable createExternalGLDrawable() { NativeWindowFactory.getDefaultToolkitLock().lock(); try { @@ -398,7 +501,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * normal ahead of time, use resetDisplayGamma(). Throws * IllegalArgumentException if any of the parameters were * out-of-bounds. - * + * * @param gamma The gamma value, typically > 1.0 (default value is * 1.0) * @param brightness The brightness value between -1.0 and 1.0, @@ -484,7 +587,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { return; if (gammaShutdownHook == null) { gammaShutdownHook = new Thread(new Runnable() { - public void run() { + @Override + public void run() { synchronized (GLDrawableFactoryImpl.this) { resetGammaRamp(originalGammaRamp); } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index 58a4ac6b4..abf2bf557 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -42,6 +42,7 @@ package jogamp.opengl; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; @@ -75,7 +76,7 @@ public abstract class GLDrawableImpl implements GLDrawable { if( !realized ) { return; // destroyed already } - GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); if ( caps.getDoubleBuffered() ) { if(!surface.surfaceSwap()) { int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] @@ -149,6 +150,9 @@ public abstract class GLDrawableImpl implements GLDrawable { realized = realizedArg; AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice(); if(realizedArg) { + if(surface instanceof ProxySurface) { + ((ProxySurface)surface).createNotify(); + } if(NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) { throw new GLException("GLDrawableImpl.setRealized(true): Surface not ready (lockSurface)"); } @@ -156,17 +160,21 @@ public abstract class GLDrawableImpl implements GLDrawable { aDevice.lock(); } try { - setRealizedImpl(); if(realizedArg) { + setRealizedImpl(); updateHandle(); } else { destroyHandle(); + setRealizedImpl(); } } finally { if(realizedArg) { unlockSurface(); } else { aDevice.unlock(); + if(surface instanceof ProxySurface) { + ((ProxySurface)surface).destroyNotify(); + } } } } else if(DEBUG) { @@ -175,6 +183,39 @@ public abstract class GLDrawableImpl implements GLDrawable { } protected abstract void setRealizedImpl(); + /** + * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: construct, destroy. + *

    + * If realized is true, the context has just been created and made current. + *

    + *

    + * If realized is false, the context is still current and will be release and destroyed after this method returns. + *

    + *

    + * @see #contextMadeCurrent(GLContext, boolean) + */ + protected void contextRealized(GLContext glc, boolean realized) {} + + /** + * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: makeCurrent, release. + *

    + * Will not be called if {@link #contextRealized(GLContext, boolean)} has been triggered. + *

    + *

    + * If current is true, the context has just been made current. + *

    + *

    + * If current is false, the context is still current and will be release after this method returns. + *

    + * @see #contextRealized(GLContext, boolean) + */ + protected void contextMadeCurrent(GLContext glc, boolean current) { } + + /** Callback for special implementations, allowing GLContext to fetch a custom default render framebuffer. Defaults to zero.*/ + protected int getDefaultDrawFramebuffer() { return 0; } + /** Callback for special implementations, allowing GLContext to fetch a custom default read framebuffer. Defaults to zero. */ + protected int getDefaultReadFramebuffer() { return 0; } + @Override public final synchronized boolean isRealized() { return realized; @@ -190,10 +231,12 @@ public abstract class GLDrawableImpl implements GLDrawable { return surface.getHeight(); } + /** @see NativeSurface#lockSurface() */ public final int lockSurface() throws GLException { return surface.lockSurface(); } + /** @see NativeSurface#unlockSurface() */ public final void unlockSurface() { surface.unlockSurface(); } diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java new file mode 100644 index 000000000..b7ea4f826 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -0,0 +1,138 @@ +package jogamp.opengl; + +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.GL; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLException; + +import com.jogamp.nativewindow.MutableGraphicsConfiguration; +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.FBObject.TextureAttachment; + +/** + * Offscreen GLDrawable implementation using framebuffer object (FBO) + * as it's offscreen rendering mechanism. + * + * @see GLDrawableImpl#contextRealized(GLContext, boolean) + * @see GLDrawableImpl#contextMadeCurrent(GLContext, boolean) + * @see GLDrawableImpl#getDefaultDrawFramebuffer() + * @see GLDrawableImpl#getDefaultReadFramebuffer() + */ +public class GLFBODrawableImpl extends GLDrawableImpl { + final GLDrawableImpl parent; + final FBObject fbo; + int texUnit; + int samplesTexUnit = 0; + int width=0, height=0, samples=0; + + protected GLFBODrawableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, + NativeSurface surface, int initialWidth, int initialHeight, int textureUnit) { + super(factory, surface, false); + this.parent = parent; + this.texUnit = textureUnit; + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); + this.width = initialWidth; + this.height = initialHeight; + this.samples = caps.getNumSamples(); + this.fbo = new FBObject(); + } + + @Override + protected void contextRealized(GLContext glc, boolean realized) { + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); + final GL gl = glc.getGL(); + if(realized) { + fbo.reset(gl, width, height, samples); + samples = fbo.getNumSamples(); // update, maybe capped + if(samples > 0) { + fbo.attachColorbuffer(gl, 0, caps.getAlphaBits()>0); + } else { + fbo.attachTexture2D(gl, 0, caps.getAlphaBits()>0); + } + if( caps.getStencilBits() > 0 ) { + fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24); + } else { + fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); + } + } else if(null != fbo) { + fbo.destroy(gl); + } + } + + @Override + protected void contextMadeCurrent(GLContext glc, boolean current) { + final GL gl = glc.getGL(); + if(current) { + fbo.bind(gl); + } else { + fbo.unbind(gl); + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit); + fbo.use(gl, samples > 0 ? fbo.getSamplingSink() : (TextureAttachment) fbo.getColorbuffer(0) ); + if( samples > 0) { + gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbo.getReadFramebuffer()); + } + } + } + + @Override + protected int getDefaultDrawFramebuffer() { return fbo.getWriteFramebuffer(); } + + @Override + protected int getDefaultReadFramebuffer() { return fbo.getReadFramebuffer(); } + + public FBObject getFBObject() { return fbo; } + + public void setSize(GL gl, int newWidth, int newHeight) throws GLException { + width = newWidth; + height = newHeight; + fbo.reset(gl, width, height, samples); + samples = fbo.getNumSamples(); // update, maybe capped + } + + public void setSamples(GL gl, int newSamples) throws GLException { + samples = newSamples; + fbo.reset(gl, width, height, samples); + samples = fbo.getNumSamples(); // update, maybe capped + } + + + @Override + public GLContext createContext(GLContext shareWith) { + final GLContext ctx = parent.createContext(shareWith); + ctx.setGLDrawable(this, false); + return ctx; + } + + @Override + public GLDynamicLookupHelper getGLDynamicLookupHelper() { + return parent.getGLDynamicLookupHelper(); + } + + @Override + protected void swapBuffersImpl() { + } + + @Override + protected void setRealizedImpl() { + parent.setRealized(realized); + if(realized) { + final MutableGraphicsConfiguration msConfig = (MutableGraphicsConfiguration) surface.getGraphicsConfiguration(); + final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) msConfig.getChosenCapabilities(); + final GLCapabilitiesImmutable chosenFBOCaps = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, true /*FBO*/, false /*PBO*/); + msConfig.setChosenCapabilities(chosenFBOCaps); + } + } + + @Override + public int getWidth() { + return width; + } + + @Override + public int getHeight() { + return height; + } +} diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java index b7c15bfda..900d6a2a0 100644 --- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java +++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java @@ -38,7 +38,8 @@ public class GLGraphicsConfigurationUtil { public static final int WINDOW_BIT = 1 << 0; public static final int BITMAP_BIT = 1 << 1; public static final int PBUFFER_BIT = 1 << 2; - public static final int ALL_BITS = WINDOW_BIT | BITMAP_BIT | PBUFFER_BIT ; + public static final int FBO_BIT = 1 << 3; + public static final int ALL_BITS = WINDOW_BIT | BITMAP_BIT | PBUFFER_BIT | FBO_BIT ; public static final StringBuilder winAttributeBits2String(StringBuilder sb, int winattrbits) { if(null==sb) { @@ -61,30 +62,43 @@ public class GLGraphicsConfigurationUtil { sb.append(", "); } sb.append("PBUFFER"); + seperator=true; + } + if( 0 != ( FBO_BIT & winattrbits ) ) { + if(seperator) { + sb.append(", "); + } + sb.append("FBO"); } return sb; } /** + * @param isFBO TODO * @return bitmask representing the input boolean in exclusive or logic, ie only one bit will be set */ - public static final int getWinAttributeBits(boolean isOnscreen, boolean isPBuffer) { + public static final int getWinAttributeBits(boolean isOnscreen, boolean isPBuffer, boolean isFBO) { int winattrbits = 0; if(isOnscreen) { winattrbits |= WINDOW_BIT; - } else if (!isPBuffer) { - winattrbits |= BITMAP_BIT; } else { - winattrbits |= PBUFFER_BIT; + if(isFBO) { + winattrbits |= FBO_BIT; + } + if (!isPBuffer) { + winattrbits |= BITMAP_BIT; + } else { + winattrbits |= PBUFFER_BIT; + } } return winattrbits; } /** - * @see #getWinAttributeBits(boolean, boolean) + * @see #getWinAttributeBits(boolean, boolean, boolean) */ public static final int getWinAttributeBits(GLCapabilitiesImmutable caps) { - return getWinAttributeBits(caps.isOnscreen(), caps.isPBuffer()); + return getWinAttributeBits(caps.isOnscreen(), caps.isPBuffer(), false); } public static final boolean addGLCapabilitiesPermutations(List capsBucket, GLCapabilitiesImmutable temp, int winattrbits) { @@ -92,43 +106,58 @@ public class GLGraphicsConfigurationUtil { if( 0 != ( WINDOW_BIT & winattrbits ) ) { GLCapabilities cpy = (GLCapabilities) temp.cloneMutable(); cpy.setOnscreen(true); + cpy.setPBuffer(false); + cpy.setFBO(false); capsBucket.add(cpy); } - if( 0 != ( PBUFFER_BIT & winattrbits ) ) { + if( 0 != ( PBUFFER_BIT & winattrbits ) || 0 != ( FBO_BIT & winattrbits ) ) { GLCapabilities cpy = (GLCapabilities) temp.cloneMutable(); - cpy.setPBuffer(true); + cpy.setFBO(0 != ( FBO_BIT & winattrbits )); + cpy.setPBuffer(0 != ( PBUFFER_BIT & winattrbits )); capsBucket.add(cpy); } if( 0 != ( BITMAP_BIT & winattrbits ) ) { GLCapabilities cpy = (GLCapabilities) temp.cloneMutable(); cpy.setOnscreen(false); cpy.setPBuffer(false); + cpy.setFBO(false); capsBucket.add(cpy); } return capsBucket.size() > preSize; } - public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean pbufferAvailable) + public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { if( !capsRequested.isOnscreen() ) { - return fixOffScreenGLCapabilities(capsRequested, pbufferAvailable); + return fixOffscreenGLCapabilities(capsRequested, fboAvailable, pbufferAvailable); } - return capsRequested; + return fixOnscreenGLCapabilities(capsRequested); } - public static GLCapabilitiesImmutable fixOffScreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean pbufferAvailable) + public static GLCapabilitiesImmutable fixOnscreenGLCapabilities(GLCapabilitiesImmutable capsRequested) + { + if( !capsRequested.isOnscreen() ) { + // fix caps .. + GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); + caps2.setOnscreen(true); + return caps2; + } + return capsRequested; + } + + public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || - ( !pbufferAvailable && capsRequested.isPBuffer() ) ) + ( fboAvailable != capsRequested.isFBO() ) || + ( pbufferAvailable != capsRequested.isPBuffer() ) ) { // fix caps .. GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN caps2.setOnscreen(false); - if(caps2.isPBuffer() && !pbufferAvailable) { - caps2.setPBuffer(false); - } + caps2.setFBO( fboAvailable ); + caps2.setPBuffer( pbufferAvailable ); return caps2; } return capsRequested; @@ -136,12 +165,13 @@ public class GLGraphicsConfigurationUtil { public static GLCapabilitiesImmutable fixGLPBufferGLCapabilities(GLCapabilitiesImmutable capsRequested) { - if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || !capsRequested.isPBuffer()) { + if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || !capsRequested.isPBuffer() || capsRequested.isFBO() ) { // fix caps .. GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN - we don't need to be single buffered .. caps2.setOnscreen(false); caps2.setPBuffer(true); + caps2.setFBO(false); return caps2; } return capsRequested; diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index a8277fd71..bbc28e283 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -54,8 +54,7 @@ import javax.media.opengl.GLPbuffer; public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { private int floatMode; - public GLPbufferImpl(GLDrawableImpl pbufferDrawable, - GLContext sharedContext) { + public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext sharedContext) { super(pbufferDrawable, null); // drawable := pbufferDrawable GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) @@ -111,6 +110,11 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { // GLAutoDrawable completion // + @Override + public final Object getUpstreamWidget() { + return null; + } + @Override public void destroy() { defaultDestroyOp(); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 65a4c3ece..c5d0df645 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -110,14 +110,8 @@ public abstract class EGLContext extends GLContextImpl { @Override protected void makeCurrentImpl() throws GLException { - if(EGL.EGL_NO_DISPLAY==((EGLDrawable)drawable).getDisplay() ) { - throw new GLException("drawable not properly initialized, NO DISPLAY: "+drawable); - } if (EGL.eglGetCurrentContext() != contextHandle) { - if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(), - drawable.getHandle(), - drawableRead.getHandle(), - contextHandle)) { + if (!EGL.eglMakeCurrent(drawable.getNativeSurface().getDisplayHandle(), drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { throw new GLException("Error making context 0x" + Long.toHexString(contextHandle) + " current: error code 0x" + Integer.toHexString(EGL.eglGetError())); } @@ -126,10 +120,7 @@ public abstract class EGLContext extends GLContextImpl { @Override protected void releaseImpl() throws GLException { - if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(), - EGL.EGL_NO_SURFACE, - EGL.EGL_NO_SURFACE, - EGL.EGL_NO_CONTEXT)) { + if (!EGL.eglMakeCurrent(drawable.getNativeSurface().getDisplayHandle(), EGL.EGL_NO_SURFACE, EGL.EGL_NO_SURFACE, EGL.EGL_NO_CONTEXT)) { throw new GLException("Error freeing OpenGL context 0x" + Long.toHexString(contextHandle) + ": error code 0x" + Integer.toHexString(EGL.eglGetError())); } @@ -137,7 +128,7 @@ public abstract class EGLContext extends GLContextImpl { @Override protected void destroyImpl() throws GLException { - if (!EGL.eglDestroyContext(((EGLDrawable)drawable).getDisplay(), contextHandle)) { + if (!EGL.eglDestroyContext(drawable.getNativeSurface().getDisplayHandle(), contextHandle)) { final int eglError = EGL.eglGetError(); if(EGL.EGL_SUCCESS != eglError) { /* oops, Mesa EGL impl. may return false, but has no EGL error */ throw new GLException("Error destroying OpenGL context 0x" + @@ -158,16 +149,16 @@ public abstract class EGLContext extends GLContextImpl { @Override protected boolean createImpl(GLContextImpl shareWith) throws GLException { - long eglDisplay = ((EGLDrawable)drawable).getDisplay(); - EGLGraphicsConfiguration config = ((EGLDrawable)drawable).getGraphicsConfiguration(); - GLProfile glProfile = drawable.getGLProfile(); - long eglConfig = config.getNativeConfig(); + final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); + final long eglDisplay = config.getScreen().getDevice().getHandle(); + final GLProfile glProfile = drawable.getGLProfile(); + final long eglConfig = config.getNativeConfig(); long shareWithHandle = EGL.EGL_NO_CONTEXT; - if (eglDisplay == 0) { + if ( 0 == eglDisplay ) { throw new GLException("Error: attempted to create an OpenGL context without a display connection"); } - if (eglConfig == 0) { + if ( 0 == eglConfig ) { throw new GLException("Error: attempted to create an OpenGL context without a graphics configuration"); } @@ -217,10 +208,7 @@ public abstract class EGLContext extends GLContextImpl { ",\n\t"+this+ ",\n\tsharing with 0x" + Long.toHexString(shareWithHandle)); } - if (!EGL.eglMakeCurrent(((EGLDrawable)drawable).getDisplay(), - drawable.getHandle(), - drawableRead.getHandle(), - contextHandle)) { + if (!EGL.eglMakeCurrent(eglDisplay, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { throw new GLException("Error making context 0x" + Long.toHexString(contextHandle) + " current: error code " + EGL.eglGetError()); } @@ -269,8 +257,7 @@ public abstract class EGLContext extends GLContextImpl { eglQueryStringInitialized = true; } if (eglQueryStringAvailable) { - final String ret = EGL.eglQueryString(((EGLDrawable)drawable).getDisplay(), - EGL.EGL_EXTENSIONS); + final String ret = EGL.eglQueryString(drawable.getNativeSurface().getDisplayHandle(), EGL.EGL_EXTENSIONS); if (DEBUG) { System.err.println("EGL extensions: " + ret); } @@ -291,7 +278,7 @@ public abstract class EGLContext extends GLContextImpl { } return false; } - return EGL.eglSwapInterval(((EGLDrawable)drawable).getDisplay(), interval); + return EGL.eglSwapInterval(drawable.getNativeSurface().getDisplayHandle(), interval); } @Override @@ -300,6 +287,45 @@ public abstract class EGLContext extends GLContextImpl { @Override public abstract void releasePbufferFromTexture(); + // + // Accessible .. + // + + /** + * If context is an ES profile, map it to the given device + * via {@link GLContext#mapAvailableGLVersion(AbstractGraphicsDevice, int, int, int, int, int)}. + *

    + * We intentionally override a non native EGL device ES profile mapping, + * i.e. this will override/modify an already 'set' X11/WGL/.. mapping. + *

    + * + * @param device + */ + protected void mapCurrentAvailableGLVersion(AbstractGraphicsDevice device) { + mapCurrentAvailableGLVersionImpl(device, ctxMajorVersion, ctxMinorVersion, ctxOptions); + } + + protected static void mapStaticGLESVersion(AbstractGraphicsDevice device, int major) { + int ctp = ( 2 == major ) ? ( GLContext.CTX_PROFILE_ES | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) : ( GLContext.CTX_PROFILE_ES ); + mapCurrentAvailableGLVersionImpl(device, major, 0, ctp); + } + private static void mapCurrentAvailableGLVersionImpl(AbstractGraphicsDevice device, int major, int minor, int ctp) { + if( 0 != ( ctp & GLContext.CTX_PROFILE_ES) ) { + // ES1 or ES2 + final int reqMajor = major; + final int reqProfile = GLContext.CTX_PROFILE_ES; + GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, + major, minor, ctp); + } + } + + protected static boolean getAvailableGLVersionsSet(AbstractGraphicsDevice device) { + return GLContext.getAvailableGLVersionsSet(device); + } + protected static void setAvailableGLVersionsSet(AbstractGraphicsDevice device) { + GLContext.setAvailableGLVersionsSet(device); + } + protected static String toHexString(int hex) { return GLContext.toHexString(hex); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index 7f10d3bd9..432010f49 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -136,7 +136,17 @@ public class EGLDisplayUtil { return res; } - public static final EGLGraphicsDevice.EGLTerminateCallback eglTerminateCallback = new EGLGraphicsDevice.EGLTerminateCallback() { + public static final EGLGraphicsDevice.EGLDisplayLifecycleCallback eglLifecycleCallback = new EGLGraphicsDevice.EGLDisplayLifecycleCallback() { + public long eglGetAndInitDisplay(long nativeDisplayID) { + long eglDisplay = EGLDisplayUtil.eglGetDisplay(nativeDisplayID); + if (eglDisplay == EGL.EGL_NO_DISPLAY) { + throw new GLException("Failed to created EGL display: 0x"+Long.toHexString(nativeDisplayID)+", error 0x"+Integer.toHexString(EGL.eglGetError())); + } + if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) { + throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError())); + } + return eglDisplay; + } public void eglTerminate(long eglDisplayHandle) { EGLDisplayUtil.eglTerminate(eglDisplayHandle); } @@ -148,17 +158,12 @@ public class EGLDisplayUtil { * @param unitID * @return an initialized EGLGraphicsDevice * @throws GLException if {@link EGL#eglGetDisplay(long)} or {@link EGL#eglInitialize(long, int[], int, int[], int)} fails - * @see EGLGraphicsDevice#EGLGraphicsDevice(long, long, String, int, com.jogamp.nativewindow.egl.EGLGraphicsDevice.EGLTerminateCallback) + * @see EGLGraphicsDevice#EGLGraphicsDevice(long, long, String, int, com.jogamp.nativewindow.egl.EGLGraphicsDevice.EGLDisplayLifecycleCallback) */ public static EGLGraphicsDevice eglCreateEGLGraphicsDevice(long nativeDisplayID, String connection, int unitID) { - long eglDisplay = EGLDisplayUtil.eglGetDisplay(nativeDisplayID); - if (eglDisplay == EGL.EGL_NO_DISPLAY) { - throw new GLException("Failed to created EGL display: 0x"+Long.toHexString(nativeDisplayID)+", error 0x"+Integer.toHexString(EGL.eglGetError())); - } - if (!EGLDisplayUtil.eglInitialize(eglDisplay, null, null)) { - throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError())); - } - return new EGLGraphicsDevice(nativeDisplayID, eglDisplay, connection, unitID, eglTerminateCallback); + final EGLGraphicsDevice eglDisplay = new EGLGraphicsDevice(nativeDisplayID, 0, connection, unitID, eglLifecycleCallback); + eglDisplay.open(); + return eglDisplay; } /** @@ -189,6 +194,6 @@ public class EGLDisplayUtil { throw new GLException("eglInitialize failed"+", error 0x"+Integer.toHexString(EGL.eglGetError())); } final AbstractGraphicsDevice adevice = surface.getGraphicsConfiguration().getScreen().getDevice(); - return new EGLGraphicsDevice(nativeDisplayID, eglDisplay, adevice.getConnection(), adevice.getUnitID(), eglTerminateCallback); + return new EGLGraphicsDevice(nativeDisplayID, eglDisplay, adevice.getConnection(), adevice.getUnitID(), eglLifecycleCallback); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index d777c4f04..383b61f88 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -36,82 +36,65 @@ package jogamp.opengl.egl; -import jogamp.opengl.GLDynamicLookupHelper; -import jogamp.opengl.GLDrawableImpl; +import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.ProxySurface; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLException; -import javax.media.nativewindow.*; -import javax.media.nativewindow.VisualIDHolder.VIDType; -import javax.media.opengl.*; +import jogamp.opengl.GLDrawableImpl; +import jogamp.opengl.GLDynamicLookupHelper; -import com.jogamp.nativewindow.egl.*; +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public abstract class EGLDrawable extends GLDrawableImpl { - private boolean ownEGLDisplay = false; // for destruction private boolean ownEGLSurface = false; // for destruction - private EGLGraphicsConfiguration eglConfig; - private EGLGraphicsDevice eglDevice; - private long eglSurface; - protected EGLDrawable(EGLDrawableFactory factory, - NativeSurface component) throws GLException { + protected EGLDrawable(EGLDrawableFactory factory, NativeSurface component) throws GLException { super(factory, component, false); - eglSurface=EGL.EGL_NO_SURFACE; - eglDevice=null; - } - - public final long getDisplay() { - return null != eglDevice ? eglDevice.getHandle() : 0; - } - - @Override - public final long getHandle() { - return eglSurface; - } - - public final EGLGraphicsConfiguration getGraphicsConfiguration() { - return eglConfig; - } - - @Override - public final GLCapabilitiesImmutable getChosenGLCapabilities() { - return (null==eglConfig)?super.getChosenGLCapabilities():(GLCapabilitiesImmutable)eglConfig.getChosenCapabilities(); } @Override public abstract GLContext createContext(GLContext shareWith); - protected abstract long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle); + protected abstract long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle); private final void recreateSurface() { - // create a new EGLSurface .. - if(EGL.EGL_NO_SURFACE!=eglSurface) { - EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface); - } - + final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) surface.getGraphicsConfiguration(); + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglConfig.getScreen().getDevice(); if(DEBUG) { - System.err.println(getThreadName() + ": createSurface using "+eglDevice+", "+eglConfig); + System.err.println(getThreadName() + ": createSurface using "+eglConfig); + } + if( EGL.EGL_NO_SURFACE != surface.getSurfaceHandle() ) { + EGL.eglDestroySurface(eglDevice.getHandle(), surface.getSurfaceHandle()); } - - eglSurface = createSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), surface.getSurfaceHandle()); - int eglError0 = EGL.EGL_SUCCESS; + + final EGLUpstreamSurfaceHook upstreamHook = (EGLUpstreamSurfaceHook) ((ProxySurface)surface).getUpstreamSurfaceHook(); + final NativeSurface upstreamSurface = upstreamHook.getUpstreamSurface(); + long eglSurface = createSurface(eglConfig, upstreamSurface.getSurfaceHandle()); + + int eglError0; if (EGL.EGL_NO_SURFACE == eglSurface) { eglError0 = EGL.eglGetError(); if(EGL.EGL_BAD_NATIVE_WINDOW == eglError0) { // Try window handle if available and differs (Windows HDC / HWND). // ANGLE impl. required HWND on Windows. - if(surface instanceof NativeWindow) { - final NativeWindow nw = (NativeWindow) surface; + if(upstreamSurface instanceof NativeWindow) { + final NativeWindow nw = (NativeWindow) upstreamSurface; if(nw.getWindowHandle() != nw.getSurfaceHandle()) { if(DEBUG) { System.err.println(getThreadName() + ": Info: Creation of window surface w/ surface handle failed: "+eglConfig+", error "+toHexString(eglError0)+", retry w/ windowHandle"); } - eglSurface = createSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), nw.getWindowHandle()); + eglSurface = createSurface(eglConfig, nw.getWindowHandle()); if (EGL.EGL_NO_SURFACE == eglSurface) { eglError0 = EGL.eglGetError(); } } } } + } else { + eglError0 = EGL.EGL_SUCCESS; } if (EGL.EGL_NO_SURFACE == eglSurface) { throw new GLException("Creation of window surface failed: "+eglConfig+", "+surface+", error "+toHexString(eglError0)); @@ -120,6 +103,8 @@ public abstract class EGLDrawable extends GLDrawableImpl { if(DEBUG) { System.err.println(getThreadName() + ": setSurface using component: handle "+toHexString(surface.getSurfaceHandle())+" -> "+toHexString(eglSurface)); } + + ((MutableSurface)surface).setSurfaceHandle(eglSurface); } @Override @@ -131,123 +116,71 @@ public abstract class EGLDrawable extends GLDrawableImpl { @Override protected final void setRealizedImpl() { + final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) surface.getGraphicsConfiguration(); + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglConfig.getScreen().getDevice(); if (realized) { - AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration(); - AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); - if(aDevice instanceof EGLGraphicsDevice) { + final long eglDisplayHandle = eglDevice.getHandle(); + if (EGL.EGL_NO_DISPLAY == eglDisplayHandle) { + throw new GLException("Invalid EGL display in EGLGraphicsDevice "+eglDevice); + } + int[] tmp = new int[1]; + boolean eglSurfaceValid = 0 != surface.getSurfaceHandle(); + if(eglSurfaceValid) { + eglSurfaceValid = EGL.eglQuerySurface(eglDisplayHandle, surface.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0); + if(!eglSurfaceValid) { + if(DEBUG) { + System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl eglQuerySuface failed: "+toHexString(EGL.eglGetError())+", "+surface); + } + } + } + if(eglSurfaceValid) { + // surface holds valid EGLSurface if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): using existing EGL config - START"); + System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl re-using component's EGLSurface: handle "+toHexString(surface.getSurfaceHandle())); + } + ownEGLSurface=false; + } else { + // EGLSurface is ours - subsequent updateHandle() will issue recreateSurface(); + // However .. let's validate the surface object first + if( ! (surface instanceof ProxySurface) ) { + throw new InternalError("surface not ProxySurface: "+surface.getClass().getName()+", "+surface); } - // just fetch the data .. trust but verify .. - ownEGLDisplay = false; - eglDevice = (EGLGraphicsDevice) aDevice; - if (eglDevice.getHandle() == EGL.EGL_NO_DISPLAY) { - throw new GLException("Invalid EGL display in EGLGraphicsDevice "+eglDevice); + final ProxySurface.UpstreamSurfaceHook upstreamHook = ((ProxySurface)surface).getUpstreamSurfaceHook(); + if( null == upstreamHook ) { + throw new InternalError("null upstreamHook of: "+surface); } - if(aConfig instanceof EGLGraphicsConfiguration) { - eglConfig = (EGLGraphicsConfiguration) aConfig; // done .. - if (null == eglConfig) { - throw new GLException("Null EGLGraphicsConfiguration from "+aConfig); - } - - int[] tmp = new int[1]; - if ( 0 != surface.getSurfaceHandle() && - EGL.eglQuerySurface(eglDevice.getHandle(), surface.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0) ) { - // surface holds static EGLSurface - eglSurface = surface.getSurfaceHandle(); - if(DEBUG) { - System.err.println(getThreadName() + ": setSurface re-using component's EGLSurface: handle "+toHexString(eglSurface)); - } - ownEGLSurface=false; - } else { - // EGLSurface is ours - subsequent updateHandle() will issue recreateSurface(); - ownEGLSurface=true; - } - } else { - throw new GLException("EGLGraphicsDevice hold by non EGLGraphicsConfiguration: "+aConfig); + if( ! (upstreamHook instanceof EGLUpstreamSurfaceHook) ) { + throw new InternalError("upstreamHook not EGLUpstreamSurfaceHook: Surface: "+surface.getClass().getName()+", "+surface+"; UpstreamHook: "+upstreamHook.getClass().getName()+", "+upstreamHook); } - } else { - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): creating new EGL config - START"); + if( null == ((EGLUpstreamSurfaceHook)upstreamHook).getUpstreamSurface() ) { + throw new InternalError("null upstream surface"); } - // create a new EGL config .. - ownEGLDisplay=true; - // EGLSurface is ours .. ownEGLSurface=true; - - eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface, true); - AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); - final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); - if(aConfig instanceof EGLGraphicsConfiguration) { - final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities(); - if(0 == capsChosen.getEGLConfig()) { - // 'refresh' the native EGLConfig handle - capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDevice.getHandle(), capsChosen.getEGLConfigID())); - if(0 == capsChosen.getEGLConfig()) { - throw new GLException("Refreshing native EGLConfig handle failed: "+capsChosen+" of "+aConfig); - } - } - eglConfig = new EGLGraphicsConfiguration(eglScreen, capsChosen, capsRequested, null); - if(DEBUG) { - System.err.println(getThreadName() + ": Reusing chosenCaps: "+eglConfig); - } - } else { - eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false); - - if (null == eglConfig) { - throw new GLException("Couldn't create EGLGraphicsConfiguration from "+eglScreen); - } else if(DEBUG) { - System.err.println(getThreadName() + ": Chosen eglConfig: "+eglConfig); - } + if(DEBUG) { + System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl owning EGLSurface"); } - // subsequent updateHandle() will issue recreateSurface(); - } - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(true): END: ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface); } - } else if (ownEGLSurface && eglSurface != EGL.EGL_NO_SURFACE) { + } else if (ownEGLSurface && surface.getSurfaceHandle() != EGL.EGL_NO_SURFACE) { if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(false): ownDisplay "+ownEGLDisplay+", ownSurface "+ownEGLSurface+", "+eglDevice+", eglSurface: "+toHexString(eglSurface)); + System.err.println(getThreadName() + ": EGLDrawable.setRealized(false): ownSurface "+ownEGLSurface+", "+eglDevice+", eglSurface: "+toHexString(surface.getSurfaceHandle())); } // Destroy the window surface - if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) { + if (!EGL.eglDestroySurface(eglDevice.getHandle(), surface.getSurfaceHandle())) { throw new GLException("Error destroying window surface (eglDestroySurface)"); } - eglSurface = EGL.EGL_NO_SURFACE; - eglConfig=null; - eglDevice.close(); - eglDevice=null; + ((MutableSurface)surface).setSurfaceHandle(EGL.EGL_NO_SURFACE); } } @Override protected final void swapBuffersImpl() { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - if(!EGL.eglSwapBuffers(eglDevice.getHandle(), eglSurface)) { + if(!EGL.eglSwapBuffers(eglDevice.getHandle(), surface.getSurfaceHandle())) { throw new GLException("Error swapping buffers, eglError "+toHexString(EGL.eglGetError())+", "+this); } } - /** - * Surface not realizes yet (onscreen) .. Quering EGL surface size only makes sense for external drawable. - * Leave it here for later impl. of an EGLExternalDrawable. - public int getWidth() { - int[] tmp = new int[1]; - if (!EGL.eglQuerySurface(eglDisplay, eglSurface, EGL.EGL_WIDTH, tmp, 0)) { - throw new GLException("Error querying surface width, eglError "+toHexString(EGL.eglGetError())); - } - return tmp[0]; - } - - public int getHeight() { - int[] tmp = new int[1]; - if (!EGL.eglQuerySurface(eglDisplay, eglSurface, EGL.EGL_HEIGHT, tmp, 0)) { - throw new GLException("Error querying surface height, eglError "+toHexString(EGL.eglGetError())); - } - return tmp[0]; - } */ - @Override public GLDynamicLookupHelper getGLDynamicLookupHelper() { if (getGLProfile().usesNativeGLES2()) { @@ -263,10 +196,9 @@ public abstract class EGLDrawable extends GLDrawableImpl { public String toString() { return getClass().getName()+"[realized "+isRealized()+ ",\n\tfactory "+getFactory()+ - ",\n\tdevice "+eglDevice+ ",\n\tsurface "+getNativeSurface()+ - ",\n\teglSurface "+toHexString(eglSurface)+ - ",\n\teglConfig "+eglConfig+ + ",\n\teglSurface "+toHexString(surface.getSurfaceHandle())+ + ",\n\teglConfig "+surface.getGraphicsConfiguration()+ ",\n\trequested "+getRequestedGLCapabilities()+ ",\n\tchosen "+getChosenGLCapabilities()+"]"; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index f4fa1f13f..c848e3e5c 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -46,21 +46,29 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.VisualIDHolder; +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLProfile.ShutdownType; +import jogamp.opengl.Debug; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import jogamp.opengl.GLGraphicsConfigurationUtil; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.os.Platform; @@ -69,6 +77,9 @@ import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public class EGLDrawableFactory extends GLDrawableFactoryImpl { + /* package */ static final boolean QUERY_EGL_ES = !Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.DontQuery", true); + /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); + private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null; private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null; private static boolean isANGLE = false; @@ -231,7 +242,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // final EGLContext getContextES1() { return contextES1; } // final EGLContext getContextES2() { return contextES2; } final boolean wasES1ContextAvailable() { return wasES1ContextCreated; } - final boolean wasES2ContextAvailable() { return wasES2ContextCreated; } + final boolean wasES2ContextAvailable() { return wasES2ContextCreated; } } @Override @@ -245,35 +256,98 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return null!=eglES2DynamicLookupHelper || null!=eglES1DynamicLookupHelper; } - /** - private boolean isEGLContextAvailable(EGLGraphicsDevice sharedDevice, String profile) { - boolean madeCurrent = false; - final GLCapabilities caps = new GLCapabilities(GLProfile.get(profile)); - caps.setRedBits(5); caps.setGreenBits(5); caps.setBlueBits(5); caps.setAlphaBits(0); - caps.setDoubleBuffered(false); - caps.setOnscreen(false); - caps.setPBuffer(true); - final EGLDrawable drawable = (EGLDrawable) createGLDrawable( createOffscreenSurfaceImpl(sharedDevice, caps, caps, null, 64, 64) ); - if(null!=drawable) { + private boolean isEGLContextAvailable(AbstractGraphicsDevice adevice, EGLGraphicsDevice sharedEGLDevice, String profileString) { + if( !GLProfile.isAvailable(adevice, profileString) ) { + return false; + } + final GLProfile glp = GLProfile.get(adevice, profileString) ; + final GLDrawableFactoryImpl desktopFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory(); + EGLGraphicsDevice eglDevice = null; + NativeSurface surface = null; + ProxySurface upstreamSurface = null; // X11, GLX, .. + boolean success = false; + boolean deviceFromUpstreamSurface = false; + try { + final GLCapabilities caps = new GLCapabilities(glp); + caps.setRedBits(5); caps.setGreenBits(5); caps.setBlueBits(5); caps.setAlphaBits(0); + if(adevice instanceof EGLGraphicsDevice || null == desktopFactory || !QUERY_EGL_ES_NATIVE_TK) { + eglDevice = sharedEGLDevice; // reuse + surface = createDummySurfaceImpl(eglDevice, false, caps, null, 64, 64); // egl pbuffer offscreen + upstreamSurface = (ProxySurface)surface; + upstreamSurface.createNotify(); + deviceFromUpstreamSurface = false; + } else { + surface = desktopFactory.createDummySurface(adevice, caps, null, 64, 64); // X11, WGL, .. dummy window + upstreamSurface = ( surface instanceof ProxySurface ) ? (ProxySurface)surface : null ; + if(null != upstreamSurface) { + upstreamSurface.createNotify(); + } + eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface, true); + deviceFromUpstreamSurface = true; + } + + final EGLDrawable drawable = (EGLDrawable) createOnscreenDrawableImpl ( surface ); + drawable.setRealized(true); final EGLContext context = (EGLContext) drawable.createContext(null); if (null != context) { - context.setSynchronized(true); try { context.makeCurrent(); // could cause exception - madeCurrent = context.isCurrent(); + success = context.isCurrent(); + if(success) { + final String glVersion = context.getGL().glGetString(GL.GL_VERSION); + if(null == glVersion) { + // Oops .. something is wrong + if(DEBUG) { + System.err.println("EGLDrawableFactory.isEGLContextAvailable: "+eglDevice+", "+context.getGLVersion()+" - VERSION is null, dropping availability!"); + } + success = false; + } + } + if(success) { + context.mapCurrentAvailableGLVersion(eglDevice); + if(eglDevice != adevice) { + context.mapCurrentAvailableGLVersion(adevice); + } + } } catch (GLException gle) { if (DEBUG) { - System.err.println("EGLDrawableFactory.createShared: INFO: makeCurrent failed"); + System.err.println("EGLDrawableFactory.createShared: INFO: context create/makeCurrent failed"); gle.printStackTrace(); } } finally { context.destroy(); } } - drawable.destroy(); + drawable.setRealized(false); + } catch (Throwable t) { + if(DEBUG) { + System.err.println("Catched Exception:"); + t.printStackTrace(); + } + success = false; + } finally { + if(eglDevice == sharedEGLDevice) { + if(null != upstreamSurface) { + upstreamSurface.destroyNotify(); + } + } else if( deviceFromUpstreamSurface ) { + if(null != eglDevice) { + eglDevice.close(); + } + if(null != upstreamSurface) { + upstreamSurface.destroyNotify(); + } + } else { + if(null != upstreamSurface) { + upstreamSurface.destroyNotify(); + } + if(null != eglDevice) { + eglDevice.close(); + } + } } - return madeCurrent; - } */ + return success; + } /* package */ SharedResource getOrCreateEGLSharedResource(AbstractGraphicsDevice adevice) { if(null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper) { @@ -285,18 +359,41 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { sr = sharedMap.get(connection); } if(null==sr) { - final EGLGraphicsDevice sharedDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, connection, adevice.getUnitID()); + final boolean madeCurrentES1; + final boolean madeCurrentES2; + final EGLGraphicsDevice sharedDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - // final boolean madeCurrentES1 = isEGLContextAvailable(sharedDevice, GLProfile.GLES1); - // final boolean madeCurrentES2 = isEGLContextAvailable(sharedDevice, GLProfile.GLES2); - final boolean madeCurrentES1 = true; // FIXME - final boolean madeCurrentES2 = true; // FIXME + if(QUERY_EGL_ES) { + madeCurrentES1 = isEGLContextAvailable(adevice, sharedDevice, GLProfile.GLES1); + madeCurrentES2 = isEGLContextAvailable(adevice, sharedDevice, GLProfile.GLES2); + } else { + madeCurrentES1 = true; + madeCurrentES2 = true; + EGLContext.mapStaticGLESVersion(sharedDevice, 1); + if(sharedDevice != adevice) { + EGLContext.mapStaticGLESVersion(adevice, 1); + } + EGLContext.mapStaticGLESVersion(sharedDevice, 2); + if(sharedDevice != adevice) { + EGLContext.mapStaticGLESVersion(adevice, 2); + } + } + + if( !EGLContext.getAvailableGLVersionsSet(adevice) ) { + // Even though we override the non EGL native mapping intentionally, + // avoid exception due to double 'set' - carefull exception of the rule. + EGLContext.setAvailableGLVersionsSet(adevice); + } sr = new SharedResource(sharedDevice, madeCurrentES1, madeCurrentES2); + synchronized(sharedMap) { sharedMap.put(connection, sr); + if(adevice != sharedDevice) { + sharedMap.put(sharedDevice.getConnection(), sr); + } } if (DEBUG) { - System.err.println("EGLDrawableFactory.createShared: device: " + sharedDevice); + System.err.println("EGLDrawableFactory.createShared: devices: queried " + QUERY_EGL_ES + "[nativeTK "+QUERY_EGL_ES_NATIVE_TK+"], " + adevice + ", " + sharedDevice); System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1); System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2); } @@ -367,8 +464,51 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - return new EGLOnscreenDrawable(this, target); + return new EGLOnscreenDrawable(this, getEGLSurface(target)); + } + + protected static NativeSurface getEGLSurface(NativeSurface surface) { + AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration(); + AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); + if( aDevice instanceof EGLGraphicsDevice && aConfig instanceof EGLGraphicsConfiguration ) { + // already in native EGL format + if(DEBUG) { + System.err.println(getThreadName() + ": getEGLSurface - already in EGL format - use as-is: "+aConfig); + } + return surface; + } + // create EGL instance out of platform native types + final EGLGraphicsDevice eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface, true); + final AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); + final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); + final EGLGraphicsConfiguration eglConfig; + if( aConfig instanceof EGLGraphicsConfiguration ) { + // Config is already in EGL type - reuse .. + final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities(); + if( 0 == capsChosen.getEGLConfig() ) { + // 'refresh' the native EGLConfig handle + capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDevice.getHandle(), capsChosen.getEGLConfigID())); + if( 0 == capsChosen.getEGLConfig() ) { + throw new GLException("Refreshing native EGLConfig handle failed: "+capsChosen+" of "+aConfig); + } + } + eglConfig = new EGLGraphicsConfiguration(eglScreen, capsChosen, capsRequested, null); + if(DEBUG) { + System.err.println(getThreadName() + ": getEGLSurface - Reusing chosenCaps: "+eglConfig); + } + } else { + eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( + capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false); + + if (null == eglConfig) { + throw new GLException("Couldn't create EGLGraphicsConfiguration from "+eglScreen); + } else if(DEBUG) { + System.err.println(getThreadName() + ": getEGLSurface - Chosen eglConfig: "+eglConfig); + } + } + return new WrappedSurface(eglConfig, EGL.EGL_NO_SURFACE, surface.getWidth(), surface.getHeight(), new EGLUpstreamSurfaceHook(surface)); } + static String getThreadName() { return Thread.currentThread().getName(); } @Override protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) { @@ -390,22 +530,115 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { - final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; - final EGLGraphicsDevice device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); - WrappedSurface ns = new WrappedSurface(EGLGraphicsConfigurationFactory.createOffscreenGraphicsConfiguration(device, capsChosen, capsRequested, chooser)); - ns.surfaceSizeChanged(width, height); - return ns; + protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + final EGLGraphicsDevice device; + if(createNewDevice) { + final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; + device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); + } else { + device = (EGLGraphicsDevice) deviceReq; + } + final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + final EGLGraphicsConfiguration config = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); + } + return new WrappedSurface(config, 0, width, height, lifecycleHook); + } + + @Override + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + } + private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { + @Override + public final void create(ProxySurface s) { + if( EGL.EGL_NO_SURFACE == s.getSurfaceHandle() ) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); + if(0 == eglDevice.getHandle()) { + eglDevice.open(); + s.setImplBitfield(ProxySurface.OWN_DEVICE); + } + createPBufferSurfaceImpl(s, false); + if(DEBUG) { + System.err.println("EGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); + } + } + } + @Override + public final void destroy(ProxySurface s) { + if( EGL.EGL_NO_SURFACE != s.getSurfaceHandle() ) { + final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) s.getGraphicsConfiguration(); + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) config.getScreen().getDevice(); + EGL.eglDestroySurface(eglDevice.getHandle(), s.getSurfaceHandle()); + s.setSurfaceHandle(EGL.EGL_NO_SURFACE); + if( 0 != ( ProxySurface.OWN_DEVICE & s.getImplBitfield() ) ) { + eglDevice.close(); + } + if(DEBUG) { + System.err.println("EGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); + } + } + } + @Override + public final int getWidth(ProxySurface s) { + return s.initialWidth; + } + @Override + public final int getHeight(ProxySurface s) { + return s.initialHeight; + } + @Override + public String toString() { + return "EGLSurfaceLifecycleHook[]"; + } + + }; + + /** + * @param ms {@link MutableSurface} which dimensions and config are being used to create the pbuffer surface. + * It will also hold the resulting pbuffer surface handle. + * @param useTexture + * @return the passed {@link MutableSurface} which now has the EGL pbuffer surface set as it's handle + */ + protected static MutableSurface createPBufferSurfaceImpl(MutableSurface ms, boolean useTexture) { + final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) ms.getGraphicsConfiguration(); + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) config.getScreen().getDevice(); + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final int texFormat; + + if(useTexture) { + texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ; + } else { + texFormat = EGL.EGL_NO_TEXTURE; + } + + if (DEBUG) { + System.out.println("Pbuffer config: " + config); + } + + final int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(ms.getWidth(), ms.getHeight(), texFormat); + final long surf = EGL.eglCreatePbufferSurface(eglDevice.getHandle(), config.getNativeConfig(), attrs, 0); + if (EGL.EGL_NO_SURFACE==surf) { + throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+ms.getWidth()+"x"+ms.getHeight()+", error 0x"+Integer.toHexString(EGL.eglGetError())); + } else if(DEBUG) { + System.err.println("PBuffer setSurface result: eglSurface 0x"+Long.toHexString(surf)); + } + ms.setSurfaceHandle(surf); + return ms; } @Override - protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice adevice, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { - // FIXME device/windowHandle -> screen ?! - EGLGraphicsDevice device = (EGLGraphicsDevice) adevice; - DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); - EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); - WrappedSurface ns = new WrappedSurface(cfg, windowHandle); - return ns; + protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; + final EGLGraphicsDevice device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); + final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); + final EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); + return new WrappedSurface(cfg, windowHandle, 0, 0, upstream); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 56e7a4d22..214b36493 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -151,7 +151,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple public static EGLGLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, long config, boolean relaxed, boolean onscreen, boolean usePBuffer, boolean forceTransparentFlag) { List bucket = new ArrayList(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); if( EGLConfig2Capabilities(bucket, glp, display, config, winattrmask, forceTransparentFlag) ) { return (EGLGLCapabilities) bucket.get(0); } else if ( relaxed && EGLConfig2Capabilities(bucket, glp, display, config, GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag) ) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 809e2b688..6be9cb547 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -38,7 +38,6 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.VisualIDHolder.VIDType; @@ -47,6 +46,7 @@ import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLDrawableFactory; @@ -180,6 +180,9 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } EGLGraphicsDevice eglDevice = sharedResource.getDevice(); long eglDisplay = eglDevice.getHandle(); + if(0 == eglDisplay) { + throw new GLException("null eglDisplay"); + } List availableCaps = null; IntBuffer numConfigs = Buffers.newDirectIntBuffer(1); @@ -236,11 +239,9 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact ownEGLDisplay = true; } - EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getEGLFactory(); - capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory.canCreateGLPbuffer(absDevice) ); - - GLProfile glp = capsChosen.getGLProfile(); - GLCapabilities fixedCaps; + final GLProfile glp = capsChosen.getGLProfile(); + final EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getEGLFactory(); + capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(absDevice, glp), factory.canCreateGLPbuffer(absDevice) ); EGLGraphicsConfiguration res = eglChooseConfig(eglDevice.getHandle(), capsChosen, capsReq, chooser, absScreen, nativeVisualID, forceTransparentFlag); if(null==res) { @@ -251,13 +252,18 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact // Last try .. add a fixed embedded profile [ATI, Nokia, Intel, ..] // // rgb888 - d16, s4 - fixedCaps = new GLCapabilities(glp); + final GLCapabilities fixedCaps = new GLCapabilities(glp); fixedCaps.setRedBits(8); fixedCaps.setGreenBits(8); fixedCaps.setBlueBits(8); fixedCaps.setDepthBits(16); fixedCaps.setSampleBuffers(true); fixedCaps.setNumSamples(4); + if( !capsChosen.isOnscreen() ) { + fixedCaps.setOnscreen(false); + fixedCaps.setPBuffer(capsChosen.isPBuffer()); + fixedCaps.setFBO(capsChosen.isFBO()); + } if(DEBUG) { System.err.println("trying fixed caps (1): "+fixedCaps); } @@ -266,11 +272,16 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(null==res) { // // rgb565 - d16, s0 - fixedCaps = new GLCapabilities(glp); + final GLCapabilities fixedCaps = new GLCapabilities(glp); fixedCaps.setRedBits(5); fixedCaps.setGreenBits(6); fixedCaps.setBlueBits(5); fixedCaps.setDepthBits(16); + if( !capsChosen.isOnscreen() ) { + fixedCaps.setOnscreen(false); + fixedCaps.setPBuffer(capsChosen.isPBuffer()); + fixedCaps.setFBO(capsChosen.isFBO()); + } if(DEBUG) { System.err.println("trying fixed caps (2): "+fixedCaps); } @@ -279,13 +290,18 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(null==res) { // // rgb565 - d16, s4 - fixedCaps = new GLCapabilities(glp); + final GLCapabilities fixedCaps = new GLCapabilities(glp); fixedCaps.setRedBits(5); fixedCaps.setGreenBits(6); fixedCaps.setBlueBits(5); fixedCaps.setDepthBits(16); fixedCaps.setSampleBuffers(true); fixedCaps.setNumSamples(4); + if( !capsChosen.isOnscreen() ) { + fixedCaps.setOnscreen(false); + fixedCaps.setPBuffer(capsChosen.isPBuffer()); + fixedCaps.setFBO(capsChosen.isFBO()); + } if(DEBUG) { System.err.println("trying fixed caps (3): "+fixedCaps); } @@ -309,7 +325,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact final GLProfile glp = capsChosen.getGLProfile(); final boolean onscreen = capsChosen.isOnscreen(); final boolean usePBuffer = capsChosen.isPBuffer(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); List availableCaps = null; int recommendedIndex = -1; long recommendedEGLConfig = -1; @@ -322,8 +338,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: Get maxConfigs (eglGetConfigs) no configs"); } if (DEBUG) { - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig maxConfigs: "+numConfigs.get(0)); - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglDisplay "+toHexString(eglDisplay)+", "+capsChosen+", nativeVisualID "+toHexString(nativeVisualID)); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig eglDisplay "+toHexString(eglDisplay)+", nativeVisualID "+toHexString(nativeVisualID)+", onscreen "+onscreen+", usePBuffer "+usePBuffer+", "+capsChosen+", numConfigs "+numConfigs.get(0)); } final IntBuffer attrs = Buffers.newDirectIntBuffer(EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen)); @@ -362,7 +377,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: #2 Get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError())); } if (numConfigs.get(0) > 0) { - availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); + availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); } } @@ -370,6 +385,8 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(DEBUG) { // FIXME: this happens on a ATI PC Emulation .. System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #2 Graphics configuration 1st choice and 2nd choice failed - no configs"); + availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag); + printCaps("AllCaps", availableCaps, System.err); } return null; } @@ -428,27 +445,5 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact out.println(prefix+"["+i+"] "+caps.get(i)); } } - - static EGLGraphicsConfiguration createOffscreenGraphicsConfiguration(AbstractGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsReq, GLCapabilitiesChooser chooser) { - if(capsChosen.isOnscreen()) { - throw new GLException("Error: Onscreen set: "+capsChosen); - } - - if(capsChosen.getDoubleBuffered()) { - // OFFSCREEN !DOUBLE_BUFFER // FIXME DBLBUFOFFSCRN - GLCapabilities caps2 = (GLCapabilities) capsChosen.cloneMutable(); - caps2.setDoubleBuffered(false); - capsChosen = caps2; - } - - DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); - EGLGraphicsConfiguration eglConfig = chooseGraphicsConfigurationStatic(capsChosen, capsReq, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); - if (null == eglConfig) { - throw new GLException("Couldn't create EGLGraphicsConfiguration from "+screen); - } else if(DEBUG) { - System.err.println("Chosen eglConfig: "+eglConfig); - } - return eglConfig; - } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java index 3768f1588..d54057775 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java @@ -54,8 +54,8 @@ public class EGLOnscreenDrawable extends EGLDrawable { } @Override - protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) { - return EGL.eglCreateWindowSurface(eglDpy, eglNativeCfg, surfaceHandle, null); + protected long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle) { + return EGL.eglCreateWindowSurface(config.getScreen().getDevice().getHandle(), config.getNativeConfig(), nativeSurfaceHandle, null); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java index b2217c095..4a36625bd 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java @@ -40,15 +40,11 @@ package jogamp.opengl.egl; -import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; -import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GLContext; -import javax.media.opengl.GLException; public class EGLPbufferDrawable extends EGLDrawable { - private int texFormat; protected static final boolean useTexture = false; // No yet .. protected EGLPbufferDrawable(EGLDrawableFactory factory, NativeSurface target) { @@ -56,30 +52,12 @@ public class EGLPbufferDrawable extends EGLDrawable { } @Override - protected long createSurface(long eglDpy, long eglNativeCfg, long surfaceHandle) { - final AbstractGraphicsConfiguration config = getNativeSurface().getGraphicsConfiguration(); - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - - if(useTexture) { - texFormat = caps.getAlphaBits() > 0 ? EGL.EGL_TEXTURE_RGBA : EGL.EGL_TEXTURE_RGB ; - } else { - texFormat = EGL.EGL_NO_TEXTURE; - } - - if (DEBUG) { - System.out.println("Pbuffer config: " + config); - } - - NativeSurface nw = getNativeSurface(); - int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(nw.getWidth(), nw.getHeight(), texFormat); - long surf = EGL.eglCreatePbufferSurface(eglDpy, eglNativeCfg, attrs, 0); - if (EGL.EGL_NO_SURFACE==surf) { - throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+nw.getWidth()+"x"+nw.getHeight()+", error 0x"+Integer.toHexString(EGL.eglGetError())); - } else if(DEBUG) { - System.err.println("PBuffer setSurface result: eglSurface 0x"+Long.toHexString(surf)); + protected long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle) { + final MutableSurface ms = (MutableSurface)getNativeSurface(); + if(config != ms.getGraphicsConfiguration()) { + throw new InternalError("Not same: "+config.hashCode()+", "+ms.getGraphicsConfiguration()+": "+config+", "+ms.getGraphicsConfiguration()); } - ((SurfaceChangeable)nw).setSurfaceHandle(surf); - return surf; + return EGLDrawableFactory.createPBufferSurfaceImpl(ms, useTexture).getSurfaceHandle(); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java new file mode 100644 index 000000000..42c6e100e --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java @@ -0,0 +1,56 @@ +package jogamp.opengl.egl; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; +import javax.media.opengl.GLException; + +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + +public class EGLUpstreamSurfaceHook implements ProxySurface.UpstreamSurfaceHook { + private final NativeSurface upstreamSurface; + + public EGLUpstreamSurfaceHook(NativeSurface upstream) { + upstreamSurface = upstream; + } + + public final NativeSurface getUpstreamSurface() { return upstreamSurface; } + + @Override + public final void create(ProxySurface surface) { + if(upstreamSurface instanceof ProxySurface) { + ((ProxySurface)upstreamSurface).createNotify(); + if(NativeSurface.LOCK_SURFACE_NOT_READY >= upstreamSurface.lockSurface()) { + throw new GLException("Could not lock: "+upstreamSurface); + } + } + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); + eglDevice.open(); + } + + @Override + public final void destroy(ProxySurface surface) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); + eglDevice.close(); + if(upstreamSurface instanceof ProxySurface) { + upstreamSurface.unlockSurface(); + ((ProxySurface)upstreamSurface).destroyNotify(); + } + } + + @Override + public final int getWidth(ProxySurface s) { + return upstreamSurface.getWidth(); + } + + @Override + public final int getHeight(ProxySurface s) { + return upstreamSurface.getHeight(); + } + + @Override + public String toString() { + final String us_s = null != upstreamSurface ? ( upstreamSurface.getClass().getName() + ": " + upstreamSurface ) : "nil"; + return "EGLUpstreamSurfaceHook[upstream: "+us_s+"]"; + } + +} diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index aa66aa9d1..4bf2a3c9d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -48,6 +48,7 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; +import javax.media.nativewindow.ProxySurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; @@ -63,6 +64,7 @@ import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.opengl.GLExtensions; public abstract class MacOSXCGLContext extends GLContextImpl { @@ -252,9 +254,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override protected void makeCurrentImpl() throws GLException { + /** FIXME: won't work w/ special drawables (like FBO) - check for CGL mode regressions! + * if (getOpenGLMode() != ((MacOSXCGLDrawable)drawable).getOpenGLMode()) { setOpenGLMode(((MacOSXCGLDrawable)drawable).getOpenGLMode()); - } + } */ if (!impl.makeCurrent(contextHandle)) { throw new GLException("Error making Context current: "+this); } @@ -338,8 +342,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override public boolean isExtensionAvailable(String glExtensionName) { - if (glExtensionName.equals("GL_ARB_pbuffer") || - glExtensionName.equals("GL_ARB_pixel_format")) { + if (glExtensionName.equals(GLExtensions.ARB_pbuffer) || + glExtensionName.equals(GLExtensions.ARB_pixel_format)) { return true; } return super.isExtensionAvailable(glExtensionName); @@ -426,10 +430,13 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override public long create(long share, int ctp, int major, int minor) { long ctx = 0; - final MacOSXCGLDrawable drawable = (MacOSXCGLDrawable) MacOSXCGLContext.this.drawable; final NativeSurface surface = drawable.getNativeSurface(); final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); + boolean allowIncompleteView = null != backingLayerHost; + if( !allowIncompleteView && surface instanceof ProxySurface ) { + allowIncompleteView = 0 != ( ProxySurface.INVISIBLE_WINDOW & ((ProxySurface)surface).getImplBitfield() ) ; + } final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor); if (pixelFormat == 0) { @@ -443,13 +450,12 @@ public abstract class MacOSXCGLContext extends GLContextImpl screenVSyncTimeout = 1000000f / sRefreshRate; if(DEBUG) { System.err.println("NS create OSX>=lion "+isLionOrLater); - System.err.println("NS create backendType: "+drawable.getOpenGLMode()); + System.err.println("NS create allowIncompleteView: "+allowIncompleteView); System.err.println("NS create backingLayerHost: "+backingLayerHost); System.err.println("NS create share: "+share); System.err.println("NS create chosenCaps: "+chosenCaps); System.err.println("NS create pixelFormat: "+toHexString(pixelFormat)); System.err.println("NS create drawable native-handle: "+toHexString(drawable.getHandle())); - System.err.println("NS create drawable NSView-handle: "+toHexString(drawable.getNSViewHandle())); System.err.println("NS create screen refresh-rate: "+sRefreshRate+" hz, "+screenVSyncTimeout+" micros"); // Thread.dumpStack(); } @@ -457,7 +463,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl int[] viewNotReady = new int[1]; // Try to allocate a context with this ctx = CGL.createContext(share, - drawable.getNSViewHandle(), null!=backingLayerHost, + drawable.getHandle(), allowIncompleteView, pixelFormat, chosenCaps.isBackgroundOpaque(), viewNotReady, 0); @@ -473,10 +479,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl CGL.setContextOpacity(ctx, 0); } - if(DEBUG) { - GLCapabilitiesImmutable caps0 = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(null, pixelFormat); - System.err.println("NS create pixelformat2GLCaps: "+caps0); - } GLCapabilitiesImmutable fixedCaps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(chosenCaps.getGLProfile(), pixelFormat); fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); config.setChosenCapabilities(fixedCaps); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index 257635b8c..841edb2b0 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -106,10 +106,6 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { protected void setRealizedImpl() { } - protected long getNSViewHandle() { - return GLBackendType.NSOPENGL == openGLMode ? getHandle() : 0; - } - protected void registerContext(MacOSXCGLContext ctx) { // NOTE: we need to keep track of the created contexts in order to // implement swapBuffers() because of how Mac OS X implements its diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 4e9d18fed..9689d9f64 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -50,8 +50,8 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -62,15 +62,19 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLProfile.ShutdownType; +import jogamp.nativewindow.macosx.OSXUtil; import jogamp.opengl.DesktopGLDynamicLookupHelper; +import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import jogamp.opengl.GLGraphicsConfigurationUtil; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; +import com.jogamp.opengl.GLExtensions; public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { private static DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper = null; @@ -214,44 +218,39 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - final GLCapabilities caps = new GLCapabilities(glp); - caps.setRedBits(5); caps.setGreenBits(5); caps.setBlueBits(5); caps.setAlphaBits(0); - caps.setDepthBits(5); - caps.setDoubleBuffered(false); - caps.setOnscreen(false); - caps.setPBuffer(true); - final MacOSXCGLDrawable drawable = (MacOSXCGLDrawable) createGLDrawable( createOffscreenSurfaceImpl(sharedDevice, caps, caps, null, 64, 64) ); - if(null!=drawable) { - drawable.setRealized(true); - final GLContext context = drawable.createContext(null); - if (null != context) { - try { - context.makeCurrent(); // could cause exception - madeCurrent = context.isCurrent(); - if(madeCurrent) { - GL gl = context.getGL(); - hasNPOTTextures = gl.isNPOTTextureAvailable(); - hasRECTTextures = gl.isExtensionAvailable("GL_EXT_texture_rectangle"); - hasAppleFloatPixels = gl.isExtensionAvailable("GL_APPLE_float_pixels"); - } - } catch (GLException gle) { - if (DEBUG) { - System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: makeCurrent catched exception:"); - gle.printStackTrace(); - } - } finally { - try { - context.destroy(); - } catch (GLException gle) { - if (DEBUG) { - System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: destroy catched exception:"); - gle.printStackTrace(); - } - } + final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); + sharedDrawable.setRealized(true); + + final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); + if (null == sharedContext) { + throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); + } + + try { + sharedContext.makeCurrent(); // could cause exception + madeCurrent = sharedContext.isCurrent(); + if(madeCurrent) { + GL gl = sharedContext.getGL(); + hasNPOTTextures = gl.isNPOTTextureAvailable(); + hasRECTTextures = gl.isExtensionAvailable(GLExtensions.EXT_texture_rectangle); + hasAppleFloatPixels = gl.isExtensionAvailable(GLExtensions.APPLE_float_pixels); + } + } catch (GLException gle) { + if (DEBUG) { + System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: makeCurrent catched exception:"); + gle.printStackTrace(); + } + } finally { + try { + sharedContext.destroy(); + } catch (GLException gle) { + if (DEBUG) { + System.err.println("MacOSXCGLDrawableFactory.createShared: INFO: destroy catched exception:"); + gle.printStackTrace(); } } - drawable.setRealized(false); } + sharedDrawable.setRealized(false); } sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppleFloatPixels); synchronized(sharedMap) { @@ -332,18 +331,82 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device,GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { - AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_MACOSX); - WrappedSurface ns = new WrappedSurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, true)); - ns.surfaceSizeChanged(width, height); - return ns; + protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + final MacOSXGraphicsDevice device; + if(createNewDevice) { + device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); + } else { + device = (MacOSXGraphicsDevice)deviceReq; + } + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + final MacOSXCGLGraphicsConfiguration config = MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, true); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); + } + return new WrappedSurface(config, 0, width, height, lifecycleHook); } @Override - protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice device, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { - AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); - WrappedSurface ns = new WrappedSurface(MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, true), windowHandle); - return ns; + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + } + private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { + long nsWindow = 0; + @Override + public final void create(ProxySurface s) { + if(0 == nsWindow && 0 == s.getSurfaceHandle()) { + nsWindow = OSXUtil.CreateNSWindow(0, 0, s.getWidth(), s.getHeight()); + if(0 == nsWindow) { + throw new GLException("Error NS window 0"); + } + long nsView = OSXUtil.GetNSView(nsWindow); + if(0 == nsView) { + throw new GLException("Error NS view 0"); + } + s.setSurfaceHandle(nsView); + s.setImplBitfield(ProxySurface.INVISIBLE_WINDOW); + if(DEBUG) { + System.err.println("MacOSXCGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); + } + } + } + @Override + public final void destroy(ProxySurface s) { + if(0 != nsWindow && 0 != s.getSurfaceHandle()) { + OSXUtil.DestroyNSWindow(nsWindow); + nsWindow = 0; + s.setSurfaceHandle(0); + if(DEBUG) { + System.err.println("MacOSXCGLDrawableFactory.dummySurfaceLifecycleHook.destroy: "+s); + } + } + } + @Override + public final int getWidth(ProxySurface s) { + return s.initialWidth; + } + @Override + public final int getHeight(ProxySurface s) { + return s.initialHeight; + } + + @Override + public String toString() { + return "MacOSXLSurfaceLifecycleHook[]"; + } + + }; + + @Override + protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final MacOSXGraphicsDevice device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); + final MacOSXCGLGraphicsConfiguration config = MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, true); + return new WrappedSurface(config, windowHandle, 0, 0, upstream); } @Override diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index 8393a688e..421e1ef96 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -154,7 +154,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration break; case CGL.NSOpenGLPFASamples: - ivalues[idx] = caps.getSampleBuffers() ? ivalues[idx] = caps.getNumSamples() : 0; + ivalues[idx] = caps.getNumSamples() ; break; default: @@ -233,7 +233,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration return fmt.get(0); } - static GLCapabilitiesImmutable CGLPixelFormat2GLCapabilities(long pixelFormat) { + static GLCapabilitiesImmutable CGLPixelFormat2GLCapabilities(long pixelFormat) { return PixelFormat2GLCapabilities(null, pixelFormat, false); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index ad4c06af2..6be9e386d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -114,8 +114,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { // set a fake marker stating a valid drawable currentDrawable = 1; } - WrappedSurface ns = new WrappedSurface(cfg); - ns.setSurfaceHandle(currentDrawable); + WrappedSurface ns = new WrappedSurface(cfg, currentDrawable, 64, 64, null); return new MacOSXExternalCGLContext(new Drawable(factory, ns), isNSContext, contextHandle); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 242cea068..b144c020d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -42,7 +42,7 @@ package jogamp.opengl.macosx.cgl; import javax.media.nativewindow.DefaultGraphicsConfiguration; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GL; import javax.media.opengl.GL2; import javax.media.opengl.GL2GL3; @@ -95,12 +95,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { return ctx; } - @Override - protected long getNSViewHandle() { - // pbuffer handle is NSOpenGLPixelBuffer - return 0; - } - @Override public long getHandle() { return pBuffer; @@ -115,7 +109,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { NativeSurface ns = getNativeSurface(); impl.destroy(pBuffer); this.pBuffer = 0; - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); } } @@ -174,7 +168,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { throw new GLException("pbuffer creation error: CGL.createPBuffer() failed"); } - ((SurfaceChangeable)ns).setSurfaceHandle(pBuffer); + ((MutableSurface)ns).setSurfaceHandle(pBuffer); } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java index 31f13297b..6bf8839af 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java @@ -113,7 +113,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { // create EGLImage from texture clientBuffer = null; // FIXME nioTmp.put(0, EGL.EGL_NONE); - image = eglExt.eglCreateImageKHR( eglDrawable.getDisplay(), eglCtx.getHandle(), + image = eglExt.eglCreateImageKHR( eglDrawable.getNativeSurface().getDisplayHandle(), eglCtx.getHandle(), EGLExt.EGL_GL_TEXTURE_2D_KHR, clientBuffer, nioTmp); if (0==image) { @@ -130,7 +130,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { // rendering the EGLImage texture before we tell OpenMAX to fill // it with a new frame. tmp[0] = EGL.EGL_NONE; - sync = eglExt.eglCreateSyncKHR(eglDrawable.getDisplay(), EGLExt.EGL_SYNC_FENCE_KHR, tmp, 0); + sync = eglExt.eglCreateSyncKHR(eglDrawable.getNativeSurface().getDisplayHandle(), EGLExt.EGL_SYNC_FENCE_KHR, tmp, 0); if (0==sync) { throw new RuntimeException("EGLSync creation failed: "+EGL.eglGetError()+", ctx "+eglCtx+", err "+toHexString(EGL.eglGetError())); } @@ -159,10 +159,10 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { final EGLTextureFrame eglTex = (EGLTextureFrame) imgTex; if(0!=eglTex.getImage()) { - eglExt.eglDestroyImageKHR(eglDrawable.getDisplay(), eglTex.getImage()); + eglExt.eglDestroyImageKHR(eglDrawable.getNativeSurface().getDisplayHandle(), eglTex.getImage()); } if(0!=eglTex.getSync()) { - eglExt.eglDestroySyncKHR(eglDrawable.getDisplay(), eglTex.getSync()); + eglExt.eglDestroySyncKHR(eglDrawable.getNativeSurface().getDisplayHandle(), eglTex.getSync()); } super.destroyTexImage(gl, imgTex); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java index 296d53ce3..cf6f43b1c 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java @@ -41,7 +41,7 @@ package jogamp.opengl.windows.wgl; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; @@ -139,7 +139,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { hbitmap = 0; throw new GLException("Error creating device context for offscreen OpenGL context, werr "+werr); } - ((SurfaceChangeable)ns).setSurfaceHandle(hdc); + ((MutableSurface)ns).setSurfaceHandle(hdc); if(DEBUG) { System.err.println("WindowsBitmapWGLDrawable (2): "+ns); } @@ -164,7 +164,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { GDI.DeleteDC(ns.getSurfaceHandle()); origbitmap = 0; hbitmap = 0; - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); } } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java deleted file mode 100644 index 05d6d9862..000000000 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package jogamp.opengl.windows.wgl; - -import javax.media.nativewindow.AbstractGraphicsScreen; -import javax.media.nativewindow.NativeSurface; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; - -import jogamp.nativewindow.windows.GDI; -import jogamp.nativewindow.windows.GDISurface; -import jogamp.nativewindow.windows.GDIUtil; - -public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { - private long hwnd; - private boolean handleHwndLifecycle; - - private WindowsDummyWGLDrawable(GLDrawableFactory factory, GDISurface ns, boolean handleHwndLifecycle) { - super(factory, ns, true); - this.handleHwndLifecycle = handleHwndLifecycle; - - if(NativeSurface.LOCK_SURFACE_NOT_READY >= ns.lockSurface()) { - throw new GLException("WindowsDummyWGLDrawable: surface not ready (lockSurface)"); - } - try { - WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration(); - config.updateGraphicsConfiguration(factory, ns, null); - if (DEBUG) { - System.err.println("WindowsDummyWGLDrawable: "+config); - } - } catch (Throwable t) { - setRealized(false); - throw new GLException(t); - } finally { - unlockSurface(); - } - } - - public static WindowsDummyWGLDrawable create(GLDrawableFactory factory, GLProfile glp, AbstractGraphicsScreen absScreen, - long windowHandle, int width, int height, boolean handleWindowLifecycle) { - if(0 == windowHandle) { - throw new GLException("Error windowHandle 0, werr: "+GDI.GetLastError()); - } - GLCapabilities caps = new GLCapabilities(glp); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(caps, absScreen); - GDISurface ns = new GDISurface(cfg, windowHandle); - ns.surfaceSizeChanged(width, height); - return new WindowsDummyWGLDrawable(factory, ns, handleWindowLifecycle); - } - - @Override - public GLContext createContext(GLContext shareWith) { - // FIXME: figure out how to hook back in the Java 2D / JOGL bridge - return new WindowsWGLContext(this, shareWith); - } - - @Override - protected void setRealizedImpl() { - super.setRealizedImpl(); - if(!realized) { - if (handleHwndLifecycle && hwnd != 0) { - GDI.ShowWindow(hwnd, GDI.SW_HIDE); - GDIUtil.DestroyDummyWindow(hwnd); - hwnd = 0; - } - } - } -} diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index 86441c688..96c1187d3 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -55,7 +55,6 @@ import com.jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; import jogamp.opengl.GLContextShareSet; - public class WindowsExternalWGLContext extends WindowsWGLContext { private GLContext lastContext; @@ -103,7 +102,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { System.err.println("WindowsExternalWGLContext valid hdc/pfd, retrieved cfg: " + cfg); } } - return new WindowsExternalWGLContext(new Drawable(factory, new WrappedSurface(cfg, hdc)), ctx, cfg); + return new WindowsExternalWGLContext(new Drawable(factory, new WrappedSurface(cfg, hdc, 64, 64, null)), ctx, cfg); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java index 8f22aa60e..15bd005dc 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java @@ -50,6 +50,7 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import jogamp.nativewindow.windows.GDI; +import jogamp.nativewindow.windows.GDIUtil; import com.jogamp.nativewindow.WrappedSurface; @@ -69,9 +70,9 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { throw new GLException("Error: attempted to make an external GLContext without a valid pixelformat, werr " + GDI.GetLastError()); } - AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromExternal(factory, hdc, pfdID, glp, aScreen, true); - return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc)); + final AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); + final WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromExternal(factory, hdc, pfdID, glp, aScreen, true); + return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc, 64, 64, null)); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java index a11d6e78e..7dda6a1f1 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLContext.java @@ -42,6 +42,8 @@ package jogamp.opengl.windows.wgl; import javax.media.opengl.*; +import com.jogamp.opengl.GLExtensions; + import jogamp.opengl.GLContextImpl; public class WindowsPbufferWGLContext extends WindowsWGLContext { @@ -112,7 +114,7 @@ public class WindowsPbufferWGLContext extends WindowsWGLContext { } else { hasRTT = true; - if (rect && !gl.isExtensionAvailable("GL_NV_texture_rectangle")) { + if (rect && !gl.isExtensionAvailable(GLExtensions.NV_texture_rectangle)) { System.err.println("WindowsPbufferWGLContext: WARNING: GL_NV_texture_rectangle extension not " + "supported; skipping requested render_to_texture_rectangle support for pbuffer"); rect = false; diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java index b00c796ec..175622343 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -42,7 +42,7 @@ package jogamp.opengl.windows.wgl; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -92,7 +92,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { if (wglExt.wglReleasePbufferDCARB(buffer, ns.getSurfaceHandle()) == 0) { throw new GLException("Error releasing pbuffer device context: error code " + GDI.GetLastError()); } - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); } if (!wglExt.wglDestroyPbufferARB(buffer)) { throw new GLException("Error destroying pbuffer: error code " + GDI.GetLastError()); @@ -121,7 +121,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { } try { long sharedHdc = sharedSurface.getSurfaceHandle(); - WGLExt wglExt = sharedResource.getContext().getWGLExt(); + WGLExt wglExt = ((WindowsWGLContext)sharedResource.getContext()).getWGLExt(); if (DEBUG) { System.out.println("Pbuffer config: " + config); @@ -131,7 +131,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { float[] fattributes = new float[1]; int[] floatModeTmp = new int[1]; int niattribs = 0; - int width, height; GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); GLProfile glProfile = chosenCaps.getGLProfile(); @@ -206,7 +205,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { iattributes[niattribs++] = WGLExt.WGL_MIPMAP_TEXTURE_ARB; iattributes[niattribs++] = GL.GL_FALSE; - iattributes[niattribs++] = WGLExt.WGL_PBUFFER_LARGEST_ARB; + iattributes[niattribs++] = WGLExt.WGL_PBUFFER_LARGEST_ARB; // exact iattributes[niattribs++] = GL.GL_FALSE; } @@ -235,7 +234,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { NativeSurface ns = getNativeSurface(); // Set up instance variables buffer = tmpBuffer; - ((SurfaceChangeable)ns).setSurfaceHandle(tmpHdc); + ((MutableSurface)ns).setSurfaceHandle(tmpHdc); cachedWGLExt = wglExt; // Re-query chosen pixel format @@ -249,14 +248,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { } config.setCapsPFD(newCaps); } - - // Determine the actual width and height we were able to create. - int[] tmp = new int[1]; - wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_WIDTH_ARB, tmp, 0 ); - width = tmp[0]; - wglExt.wglQueryPbufferARB( buffer, WGLExt.WGL_PBUFFER_HEIGHT_ARB, tmp, 0 ); - height = tmp[0]; - ((SurfaceChangeable)ns).surfaceSizeChanged(width, height); } finally { sharedSurface.unlockSurface(); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index f143c158b..8825bad0a 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -53,6 +53,8 @@ import javax.media.opengl.GLCapabilitiesImmutable; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.opengl.GLExtensions; + import jogamp.nativewindow.windows.GDI; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; @@ -77,8 +79,8 @@ public class WindowsWGLContext extends GLContextImpl { functionNameMap.put("glFreeMemoryNV", "wglFreeMemoryNV"); extensionNameMap = new HashMap(); - extensionNameMap.put("GL_ARB_pbuffer", "WGL_ARB_pbuffer"); - extensionNameMap.put("GL_ARB_pixel_format", "WGL_ARB_pixel_format"); + extensionNameMap.put(GLExtensions.ARB_pbuffer, WindowsWGLDrawableFactory.WGL_ARB_pbuffer); + extensionNameMap.put(GLExtensions.ARB_pixel_format, WindowsWGLDrawableFactory.WGL_ARB_pixel_format); } // FIXME: figure out how to hook back in the Java 2D / JOGL bridge diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 176d27a71..09e97ff79 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -51,9 +51,10 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -67,9 +68,11 @@ import jogamp.nativewindow.windows.GDISurface; import jogamp.nativewindow.windows.GDIUtil; import jogamp.nativewindow.windows.RegisteredClassFactory; import jogamp.opengl.DesktopGLDynamicLookupHelper; +import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.SharedResourceRunner; import com.jogamp.common.JogampRuntimeException; @@ -79,6 +82,7 @@ import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; +import com.jogamp.opengl.GLExtensions; public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { private static DesktopGLDynamicLookupHelper windowsWGLDynamicLookupHelper = null; @@ -203,8 +207,8 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { static class SharedResource implements SharedResourceRunner.Resource { private WindowsGraphicsDevice device; private AbstractGraphicsScreen screen; - private WindowsDummyWGLDrawable drawable; - private WindowsWGLContext context; + private GLDrawableImpl drawable; + private GLContextImpl context; private boolean hasARBPixelFormat; private boolean hasARBMultisample; private boolean hasARBPBuffer; @@ -214,7 +218,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { private boolean isVendorNVIDIA; private boolean needsCurrenContext4ARBPFDQueries; - SharedResource(WindowsGraphicsDevice dev, AbstractGraphicsScreen scrn, WindowsDummyWGLDrawable draw, WindowsWGLContext ctx, + SharedResource(WindowsGraphicsDevice dev, AbstractGraphicsScreen scrn, GLDrawableImpl draw, GLContextImpl ctx, boolean arbPixelFormat, boolean arbMultisample, boolean arbPBuffer, boolean arbReadDrawable, String glVendor) { device = dev; screen = scrn; @@ -250,9 +254,9 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { @Override final public AbstractGraphicsScreen getScreen() { return screen; } @Override - final public WindowsWGLDrawable getDrawable() { return drawable; } + final public GLDrawableImpl getDrawable() { return drawable; } @Override - final public WindowsWGLContext getContext() { return context; } + final public GLContextImpl getContext() { return context; } final boolean hasARBPixelFormat() { return hasARBPixelFormat; } final boolean hasARBMultisample() { return hasARBMultisample; } @@ -302,21 +306,18 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { @Override public SharedResourceRunner.Resource createSharedResource(String connection) { - WindowsGraphicsDevice sharedDevice = new WindowsGraphicsDevice(connection, AbstractGraphicsDevice.DEFAULT_UNIT); + final WindowsGraphicsDevice sharedDevice = new WindowsGraphicsDevice(connection, AbstractGraphicsDevice.DEFAULT_UNIT); sharedDevice.lock(); try { - AbstractGraphicsScreen absScreen = new DefaultGraphicsScreen(sharedDevice, 0); - GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); + final AbstractGraphicsScreen absScreen = new DefaultGraphicsScreen(sharedDevice, 0); + final GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - final int f_dim = 64; - long hwnd = GDIUtil.CreateDummyWindow(0, 0, f_dim, f_dim); - WindowsDummyWGLDrawable sharedDrawable = WindowsDummyWGLDrawable.create(WindowsWGLDrawableFactory.this, glp, absScreen, hwnd, f_dim, f_dim, true); - if (null == sharedDrawable) { - throw new GLException("Couldn't create shared drawable for screen: "+absScreen+", "+glp); - } - WindowsWGLContext sharedContext = (WindowsWGLContext) sharedDrawable.createContext(null); + final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); + sharedDrawable.setRealized(true); + + final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); if (null == sharedContext) { throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); } @@ -329,7 +330,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { try { hasARBPixelFormat = sharedContext.isExtensionAvailable(WGL_ARB_pixel_format); hasARBMultisample = sharedContext.isExtensionAvailable(WGL_ARB_multisample); - hasARBPBuffer = sharedContext.isExtensionAvailable(GL_ARB_pbuffer); + hasARBPBuffer = sharedContext.isExtensionAvailable(GLExtensions.ARB_pbuffer); hasARBReadDrawableAvailable = sharedContext.isExtensionAvailable(WGL_ARB_make_current_read) && sharedContext.isFunctionAvailable(wglMakeContextCurrent); vendor = sharedContext.getGL().glGetString(GL.GL_VENDOR); @@ -401,7 +402,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { return false; } - final static String GL_ARB_pbuffer = "GL_ARB_pbuffer"; + final static String WGL_ARB_pbuffer = "WGL_ARB_pbuffer"; final static String WGL_ARB_pixel_format = "WGL_ARB_pixel_format"; final static String WGL_ARB_multisample = "WGL_ARB_multisample"; final static String WGL_NV_float_buffer = "WGL_NV_float_buffer"; @@ -534,22 +535,89 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { - AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); - WrappedSurface ns = new WrappedSurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - capsChosen, capsRequested, chooser, screen) ); - ns.surfaceSizeChanged(width, height); - return ns; + protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + final WindowsGraphicsDevice device; + if(createNewDevice) { + device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); + } else { + device = (WindowsGraphicsDevice)deviceReq; + } + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + final WindowsWGLGraphicsConfiguration config = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); + } + return new WrappedSurface(config, 0, width, height, lifecycleHook); } @Override - protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice adevice, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { - // FIXME device/windowHandle -> screen ?! - WindowsGraphicsDevice device = (WindowsGraphicsDevice) adevice; - AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); - WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); - GDISurface ns = new GDISurface(cfg, windowHandle); - return ns; + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + final WindowsGraphicsDevice device; + if(createNewDevice) { + device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); + } else { + device = (WindowsGraphicsDevice)deviceReq; + } + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); + final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + final WindowsWGLGraphicsConfiguration config = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(chosenCaps, requestedCaps, chooser, screen); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+requestedCaps+" on "+screen); + } + return new GDISurface(config, 0, width, height, dummySurfaceLifecycleHook); + } + private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { + @Override + public final void create(ProxySurface s) { + final GDISurface ms = (GDISurface)s; + if(0 == ms.getWindowHandle()) { + final long windowHandle = GDIUtil.CreateDummyWindow(0, 0, s.getWidth(), s.getHeight()); + if(0 == windowHandle) { + throw new GLException("Error windowHandle 0, werr: "+GDI.GetLastError()); + } + ms.setWindowHandle(windowHandle); + if(DEBUG) { + System.err.println("WindowsWGLDrawableFactory.dummySurfaceLifecycleHook.create: "+ms); + } + } + } + @Override + public final void destroy(ProxySurface s) { + final GDISurface ms = (GDISurface)s; + if(0 != ms.getWindowHandle()) { + GDI.ShowWindow(ms.getWindowHandle(), GDI.SW_HIDE); + GDIUtil.DestroyDummyWindow(ms.getWindowHandle()); + ms.setWindowHandle(0); + if(DEBUG) { + System.err.println("WindowsWGLDrawableFactory.dummySurfaceLifecycleHook.destroy: "+ms); + } + } + } + @Override + public final int getWidth(ProxySurface s) { + return s.initialWidth; + } + @Override + public final int getHeight(ProxySurface s) { + return s.initialHeight; + } + + @Override + public String toString() { + return "GDISurfaceLifecycleHook[]"; + } + }; + + + @Override + protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final WindowsGraphicsDevice device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); + final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); + final WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); + return new GDISurface(cfg, windowHandle, 0, 0, upstream); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 408d8b074..209589b29 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -48,11 +48,13 @@ import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import com.jogamp.nativewindow.MutableGraphicsConfiguration; +import com.jogamp.opengl.GLExtensions; import jogamp.nativewindow.windows.DWM_BLURBEHIND; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.MARGINS; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; +import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLGraphicsConfigurationUtil; public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { @@ -160,7 +162,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } if (!WGLUtil.SetPixelFormat(hdc, caps.getPFDID(), caps.getPFD())) { - throw new GLException("Unable to set pixel format " + caps + + throw new GLException("Unable to set pixel format " + caps.getPFDID() + " of " + caps + " for device context " + toHexString(hdc) + ": error code " + GDI.GetLastError()); } @@ -250,7 +252,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } if(sharedResource.hasARBPBuffer()) { - WindowsWGLContext sharedCtx = sharedResource.getContext(); + GLContextImpl sharedCtx = sharedResource.getContext(); if(null != sharedCtx && sharedCtx.isExtensionAvailable(WindowsWGLDrawableFactory.WGL_NV_float_buffer)) { // pbo float buffer iattributes[niattribs++] = WGLExt.WGL_FLOAT_COMPONENTS_NV; // nvidia @@ -313,12 +315,12 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio int niattribs = fillAttribsForGeneralWGLARBQuery(sharedResource, iattributes); - if (!sharedResource.getContext().getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, 0, iresults, 0)) { + if (!((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdID, 0, niattribs, iattributes, 0, iresults, 0)) { throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID + " of device context " + toHexString(hdc) + ", werr " + GDI.GetLastError()); } List bucket = new ArrayList(1); - final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); + final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); if(AttribList2GLCapabilities(bucket, glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits)) { return (WGLGLCapabilities) bucket.get(0); } @@ -342,7 +344,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio int[] pformatsTmp = new int[WindowsWGLGraphicsConfiguration.MAX_PFORMATS]; int[] numFormatsTmp = new int[1]; - if ( !sharedResource.getContext().getWGLExt().wglChoosePixelFormatARB(hdc, iattributes, 0, + if ( !((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglChoosePixelFormatARB(hdc, iattributes, 0, fattributes, 0, WindowsWGLGraphicsConfiguration.MAX_PFORMATS, pformatsTmp, 0, numFormatsTmp, 0)) @@ -374,7 +376,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio static List wglARBPFIDs2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource, long hdc, int[] pfdIDs, GLProfile glp, boolean onscreen, boolean usePBuffer) { - final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); + final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); return wglARBPFIDs2GLCapabilitiesImpl(sharedResource, hdc, pfdIDs, glp, winattrbits); } @@ -398,7 +400,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio for(int i = 0; i= 1 && - sharedResource.getContext().getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, 0, iresults, 0) ) { + ((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, 0, iresults, 0) ) { AttribList2GLCapabilities(bucket, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits); } else if (DEBUG) { System.err.println("wglARBPFIDs2GLCapabilities: Cannot get pixel format attributes for pixel format " + @@ -507,9 +509,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio throw new GLException("Render-to-texture-rectangle requires render-to-texture to be specified"); } - WindowsWGLContext sharedCtx = sharedResource.getContext(); + GLContextImpl sharedCtx = sharedResource.getContext(); if (rect) { - if (!sharedCtx.isExtensionAvailable("GL_NV_texture_rectangle")) { + if (!sharedCtx.isExtensionAvailable(GLExtensions.NV_texture_rectangle)) { throw new GLException("Render-to-texture-rectangle requires GL_NV_texture_rectangle extension"); } } @@ -658,7 +660,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } static WGLGLCapabilities PFD2GLCapabilities(GLProfile glp, long hdc, int pfdID, boolean onscreen) { - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false, false); List capsBucket = new ArrayList(1); if( PFD2GLCapabilities(capsBucket, glp, hdc, pfdID, winattrmask) ) { return (WGLGLCapabilities) capsBucket.get(0); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 850b64aa8..943c7fec4 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -52,6 +52,7 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; +import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLGraphicsConfigurationFactory; import jogamp.opengl.GLGraphicsConfigurationUtil; @@ -99,10 +100,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if(null==absScreen) { absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); } - AbstractGraphicsDevice absDevice = absScreen.getDevice(); - + final AbstractGraphicsDevice absDevice = absScreen.getDevice(); + final GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory(); capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( - capsChosen, GLDrawableFactory.getDesktopFactory().canCreateGLPbuffer(absDevice) ); + capsChosen, GLContext.isFBOAvailable(absDevice, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(absDevice) ); return new WindowsWGLGraphicsConfiguration( absScreen, capsChosen, capsReq, (GLCapabilitiesChooser)chooser ); } @@ -112,9 +113,9 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if(null == sharedResource) { throw new GLException("Shared resource for device n/a: "+device); } - WindowsWGLDrawable sharedDrawable = sharedResource.getDrawable(); + GLDrawableImpl sharedDrawable = sharedResource.getDrawable(); GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities(); - WindowsWGLContext sharedContext = sharedResource.getContext(); + GLContext sharedContext = sharedResource.getContext(); List availableCaps = null; if ( sharedResource.needsCurrentContext4ARBPFDQueries() ) { @@ -150,7 +151,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } static List getAvailableGLCapabilitiesARB(long hdc, WindowsWGLDrawableFactory.SharedResource sharedResource, GLProfile glProfile) { - int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs(sharedResource.getContext(), hdc); + int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs((WindowsWGLContext)sharedResource.getContext(), hdc); return WindowsWGLGraphicsConfiguration.wglARBPFIDs2AllGLCapabilities(sharedResource, hdc, pformats, glProfile); } @@ -265,7 +266,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } AbstractGraphicsDevice device = config.getScreen().getDevice(); WindowsWGLDrawableFactory.SharedResource sharedResource = ((WindowsWGLDrawableFactory)factory).getOrCreateSharedResource(device); - WindowsWGLContext sharedContext = null; + GLContext sharedContext = null; if (null != sharedResource && sharedResource.needsCurrentContext4ARBPFDQueries()) { sharedContext = sharedResource.getContext(); if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) { @@ -355,7 +356,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat System.err.println("updateGraphicsConfigurationARB: wglChoosePixelFormatARB failed with: "+capsChosen); } // 2nd choice: get all GLCapabilities available, no preferred recommendedIndex available - pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs(sharedResource.getContext(), hdc); + pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs((WindowsWGLContext)sharedResource.getContext(), hdc); if (DEBUG) { final int len = ( null != pformats ) ? pformats.length : 0; System.err.println("updateGraphicsConfigurationARB: NumFormats (wglAllARBPFIDs) " + len); @@ -451,7 +452,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if(null == pformats) { pformats = WindowsWGLGraphicsConfiguration.wglAllGDIPFIDs(hdc); } - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false, false); for (int i = 0; i < pformats.length; i++) { WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(availableCaps, glProfile, hdc, pformats[i], winattrmask); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java deleted file mode 100644 index 8914e2db9..000000000 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11DummyGLXDrawable.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.opengl.x11.glx; - -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLProfile; - -import jogamp.nativewindow.x11.X11Lib; - -import com.jogamp.nativewindow.WrappedSurface; -import com.jogamp.nativewindow.x11.X11GraphicsDevice; -import com.jogamp.nativewindow.x11.X11GraphicsScreen; - -public class X11DummyGLXDrawable extends X11OnscreenGLXDrawable { - private static final int f_dim = 64; - private long dummyWindow = 0; - - /** - * Due to the ATI Bug https://bugzilla.mozilla.org/show_bug.cgi?id=486277, - * we cannot switch the Display as we please, - * hence we reuse the target's screen configuration. - */ - public X11DummyGLXDrawable(X11GraphicsScreen screen, GLDrawableFactory factory, GLCapabilitiesImmutable caps) { - super(factory, - new WrappedSurface(X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - caps, caps, null, screen))); - this.realized = true; - - WrappedSurface ns = (WrappedSurface) getNativeSurface(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)ns.getGraphicsConfiguration(); - - X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice(); - long dpy = device.getHandle(); - int scrn = screen.getIndex(); - int visualID = config.getXVisualID(); - - dummyWindow = X11Lib.CreateDummyWindow(dpy, scrn, visualID, f_dim, f_dim); - ns.setSurfaceHandle( dummyWindow ); - ns.surfaceSizeChanged(f_dim, f_dim); - - updateHandle(); - } - - public static X11DummyGLXDrawable create(X11GraphicsScreen screen, GLDrawableFactory factory, GLProfile glp) { - GLCapabilities caps = new GLCapabilities(glp); - return new X11DummyGLXDrawable(screen, factory, caps); - } - - public void setSize(int width, int height) { - } - - @Override - public int getWidth() { - return 1; - } - - @Override - public int getHeight() { - return 1; - } - - - @Override - protected void setRealizedImpl() { - super.setRealizedImpl(); - if(!realized) { - if(0!=dummyWindow) { - destroyHandle(); - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)getNativeSurface().getGraphicsConfiguration(); - X11Lib.DestroyDummyWindow(config.getScreen().getDevice().getHandle(), dummyWindow); - } - } - } -} diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index 53776386c..b847363e0 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -76,8 +76,15 @@ public class X11ExternalGLXContext extends X11GLXContext { long drawable = GLX.glXGetCurrentDrawable(); if (drawable == 0) { throw new GLException("Error: attempted to make an external GLDrawable without a drawable/context current"); - } + } int[] val = new int[1]; + + int w, h; + GLX.glXQueryDrawable(display, drawable, GLX.GLX_WIDTH, val, 0); + w=val[0]; + GLX.glXQueryDrawable(display, drawable, GLX.GLX_HEIGHT, val, 0); + h=val[0]; + GLX.glXQueryContext(display, ctx, GLX.GLX_SCREEN, val, 0); X11GraphicsScreen x11Screen = (X11GraphicsScreen) X11GraphicsScreen.createScreenDevice(display, val[0], false); @@ -97,8 +104,7 @@ public class X11ExternalGLXContext extends X11GLXContext { cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]); } - WrappedSurface ns = new WrappedSurface(cfg); - ns.setSurfaceHandle(drawable); + final WrappedSurface ns = new WrappedSurface(cfg, drawable, w, h, null); return new X11ExternalGLXContext(new Drawable(factory, ns), ctx); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java index 3fabe7a13..8652e2d4a 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java @@ -87,10 +87,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")"); } } - WrappedSurface ns = new WrappedSurface(cfg); - ns.setSurfaceHandle(drawable); - ns.surfaceSizeChanged(w, h); - return new X11ExternalGLXDrawable(factory, ns); + return new X11ExternalGLXDrawable(factory, new WrappedSurface(cfg, drawable, w, h, null)); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 0afadc677..e6b74a769 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -61,6 +61,7 @@ import jogamp.opengl.GLDrawableImpl; import com.jogamp.common.nio.Buffers; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.opengl.GLExtensions; public abstract class X11GLXContext extends GLContextImpl { private static final Map functionNameMap; @@ -83,8 +84,8 @@ public abstract class X11GLXContext extends GLContextImpl { functionNameMap.put("glFreeMemoryNV", "glXFreeMemoryNV"); extensionNameMap = new HashMap(); - extensionNameMap.put("GL_ARB_pbuffer", "GLX_SGIX_pbuffer"); - extensionNameMap.put("GL_ARB_pixel_format", "GLX_SGIX_pbuffer"); // good enough + extensionNameMap.put(GLExtensions.ARB_pbuffer, X11GLXDrawableFactory.GLX_SGIX_pbuffer); + extensionNameMap.put(GLExtensions.ARB_pixel_format, X11GLXDrawableFactory.GLX_SGIX_pbuffer); // good enough } X11GLXContext(GLDrawableImpl drawable, @@ -508,8 +509,8 @@ public abstract class X11GLXContext extends GLContextImpl { @Override public boolean isExtensionAvailable(String glExtensionName) { - if (glExtensionName.equals("GL_ARB_pbuffer") || - glExtensionName.equals("GL_ARB_pixel_format")) { + if (glExtensionName.equals(GLExtensions.ARB_pbuffer) || + glExtensionName.equals(GLExtensions.ARB_pixel_format)) { return getGLDrawable().getFactory().canCreateGLPbuffer( drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice() ); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 9a563bdb8..8ffbf3951 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -49,6 +49,8 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -64,6 +66,7 @@ import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.SharedResourceRunner; import com.jogamp.common.util.VersionNumber; @@ -79,6 +82,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { public static final VersionNumber versionOneThree = new VersionNumber(1, 3, 0); public static final VersionNumber versionOneFour = new VersionNumber(1, 4, 0); + static final String GLX_SGIX_pbuffer = "GLX_SGIX_pbuffer"; + private static DesktopGLDynamicLookupHelper x11GLXDynamicLookupHelper = null; public X11GLXDrawableFactory() { @@ -153,8 +158,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { static class SharedResource implements SharedResourceRunner.Resource { X11GraphicsDevice device; X11GraphicsScreen screen; - X11DummyGLXDrawable drawable; - X11GLXContext context; + GLDrawableImpl drawable; + GLContextImpl context; String glXServerVendorName; boolean isGLXServerVendorATI; boolean isGLXServerVendorNVIDIA; @@ -164,7 +169,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { boolean glXMultisampleAvailable; SharedResource(X11GraphicsDevice dev, X11GraphicsScreen scrn, - X11DummyGLXDrawable draw, X11GLXContext ctx, + GLDrawableImpl draw, GLContextImpl ctx, VersionNumber glXServerVer, String glXServerVendor, boolean glXServerMultisampleAvail) { device = dev; screen = scrn; @@ -224,13 +229,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { @Override public SharedResourceRunner.Resource createSharedResource(String connection) { - X11GraphicsDevice sharedDevice = + final X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, - true); // own non-shared display connection, no locking + true); // own non-shared display connection, w/ locking // new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, - // NativeWindowFactory.getNullToolkitLock(), true); // own non-shared display connection, no locking + // NativeWindowFactory.getNullToolkitLock(), true); // own non-shared display connection, w/o locking sharedDevice.lock(); try { + final X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, 0); + if(!GLXUtil.isGLXAvailableOnServer(sharedDevice)) { throw new GLException("GLX not available on device/server: "+sharedDevice); } @@ -242,20 +249,20 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { X11Util.setMarkAllDisplaysUnclosable(true); X11Util.markDisplayUncloseable(sharedDevice.getHandle()); } - X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, 0); - - GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); + + final GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - X11DummyGLXDrawable sharedDrawable = X11DummyGLXDrawable.create(sharedScreen, X11GLXDrawableFactory.this, glp); - if (null == sharedDrawable) { - throw new GLException("Couldn't create shared drawable for screen: "+sharedScreen+", "+glp); - } - X11GLXContext sharedContext = (X11GLXContext) sharedDrawable.createContext(null); + + final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); + sharedDrawable.setRealized(true); + + final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); if (null == sharedContext) { throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); } + boolean madeCurrent = false; sharedContext.makeCurrent(); try { @@ -298,7 +305,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (null != sr.context) { // may cause JVM SIGSEGV: - sr.context.destroy(); + sr.context.destroy(); // will also pull the dummy MutuableSurface sr.context = null; } @@ -394,7 +401,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - return new X11OnscreenGLXDrawable(this, target); + return new X11OnscreenGLXDrawable(this, target, false); } @Override @@ -495,40 +502,88 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice deviceReq, - GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, - int width, int height) { - if(null == deviceReq) { - throw new InternalError("deviceReq is null"); - } - final SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(deviceReq); - if(null==sr) { - throw new InternalError("No SharedResource for: "+deviceReq); + protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable capsChosen, + GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + final X11GraphicsDevice device; + if(createNewDevice) { + // Null X11 locking, due to private non-shared Display handle + device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), NativeWindowFactory.getNullToolkitLock(), true); + } else { + device = (X11GraphicsDevice)deviceReq; } - final X11GraphicsScreen sharedScreen = (X11GraphicsScreen) sr.getScreen(); - final AbstractGraphicsDevice sharedDevice = sharedScreen.getDevice(); // should be same .. - - // create screen/device pair - Null X11 locking, due to private non-shared Display handle - final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(sharedDevice.getConnection()), AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), true); - final X11GraphicsScreen screen = new X11GraphicsScreen(device, sharedScreen.getIndex()); - - WrappedSurface ns = new WrappedSurface( - X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen) ); - if(ns != null) { - ns.surfaceSizeChanged(width, height); + final X11GraphicsScreen screen = new X11GraphicsScreen(device, 0); + final X11GLXGraphicsConfiguration config = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen); + if(null == config) { + throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return ns; + return new WrappedSurface( config, 0, width, height, lifecycleHook); } @Override - protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice adevice, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { - // FIXME device/windowHandle -> screen ?! - X11GraphicsDevice device = (X11GraphicsDevice) adevice; - X11GraphicsScreen screen = new X11GraphicsScreen(device, 0); - X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); - WrappedSurface ns = new WrappedSurface(cfg, windowHandle); - return ns; + public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, + GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { + final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + } + private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { + @Override + public final void create(ProxySurface s) { + if( 0 == s.getSurfaceHandle() ) { + final X11GLXGraphicsConfiguration cfg = (X11GLXGraphicsConfiguration) s.getGraphicsConfiguration(); + final X11GraphicsScreen screen = (X11GraphicsScreen) cfg.getScreen(); + final X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice(); + if(0 == device.getHandle()) { + device.open(); + s.setImplBitfield(ProxySurface.OWN_DEVICE); + } + final long windowHandle = X11Lib.CreateDummyWindow(device.getHandle(), screen.getIndex(), cfg.getXVisualID(), s.getWidth(), s.getHeight()); + if(0 == windowHandle) { + throw new GLException("Creating dummy window failed w/ "+cfg+", "+s.getWidth()+"x"+s.getHeight()); + } + s.setSurfaceHandle(windowHandle); + if(DEBUG) { + System.err.println("X11GLXDrawableFactory.dummySurfaceLifecycleHook.create: "+s); + } + } + } + @Override + public final void destroy(ProxySurface s) { + if(0 != s.getSurfaceHandle()) { + final X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) s.getGraphicsConfiguration(); + final X11GraphicsDevice device = (X11GraphicsDevice) config.getScreen().getDevice(); + X11Lib.DestroyDummyWindow(device.getHandle(), s.getSurfaceHandle()); + s.setSurfaceHandle(0); + if( 0 != ( ProxySurface.OWN_DEVICE & s.getImplBitfield() ) ) { + device.close(); + } + if(DEBUG) { + System.err.println("X11GLXDrawableFactory.dummySurfaceLifecycleHook.destroy: "+s); + } + } + } + @Override + public final int getWidth(ProxySurface s) { + return s.initialWidth; + } + @Override + public final int getHeight(ProxySurface s) { + return s.initialHeight; + } + @Override + public String toString() { + return "X11SurfaceLifecycleHook[]"; + } + }; + + + @Override + protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { + final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), NativeWindowFactory.getNullToolkitLock(), true); + final X11GraphicsScreen screen = new X11GraphicsScreen(device, screenIdx); + final X11GLXGraphicsConfiguration cfg = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); + return new WrappedSurface(cfg, windowHandle, 0, 0, upstream); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java index b54b5150c..b5b80e0b3 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java @@ -36,12 +36,14 @@ package jogamp.opengl.x11.glx; import java.util.ArrayList; import java.util.List; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -67,7 +69,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem } static X11GLXGraphicsConfiguration create(GLProfile glp, X11GraphicsScreen x11Screen, int fbcfgID) { - final long display = x11Screen.getDevice().getHandle(); + final AbstractGraphicsDevice device = x11Screen.getDevice(); + final long display = device.getHandle(); if(0==display) { throw new GLException("Display null of "+x11Screen); } @@ -80,7 +83,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem glp = GLProfile.getDefault(x11Screen.getDevice()); } final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - final X11GLCapabilities caps = GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(x11Screen.getDevice())); + final X11GLCapabilities caps = GLXFBConfig2GLCapabilities(glp, device, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(device)); if(null==caps) { throw new GLException("GLCapabilities null of "+toHexString(fbcfg)); } @@ -233,11 +236,11 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return true; } - static int FBCfgDrawableTypeBits(final long display, final long fbcfg) { + static int FBCfgDrawableTypeBits(final AbstractGraphicsDevice device, GLProfile glp, final long fbcfg) { int val = 0; int[] tmp = new int[1]; - int fbtype = glXGetFBConfig(display, fbcfg, GLX.GLX_DRAWABLE_TYPE, tmp, 0); + int fbtype = glXGetFBConfig(device.getHandle(), fbcfg, GLX.GLX_DRAWABLE_TYPE, tmp, 0); if ( 0 != ( fbtype & GLX.GLX_WINDOW_BIT ) ) { val |= GLGraphicsConfigurationUtil.WINDOW_BIT; @@ -248,17 +251,20 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem if ( 0 != ( fbtype & GLX.GLX_PBUFFER_BIT ) ) { val |= GLGraphicsConfigurationUtil.PBUFFER_BIT; } + if ( GLContext.isFBOAvailable(device, glp) ) { + val |= GLGraphicsConfigurationUtil.FBO_BIT; + } return val; } - static X11GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, long display, long fbcfg, + static X11GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, AbstractGraphicsDevice device, long fbcfg, boolean relaxed, boolean onscreen, boolean usePBuffer, boolean isMultisampleAvailable) { ArrayList bucket = new ArrayList(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); - if( GLXFBConfig2GLCapabilities(bucket, glp, display, fbcfg, winattrmask, isMultisampleAvailable) ) { + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); + if( GLXFBConfig2GLCapabilities(bucket, glp, device, fbcfg, winattrmask, isMultisampleAvailable) ) { return (X11GLCapabilities) bucket.get(0); - } else if ( relaxed && GLXFBConfig2GLCapabilities(bucket, glp, display, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { + } else if ( relaxed && GLXFBConfig2GLCapabilities(bucket, glp, device, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { return (X11GLCapabilities) bucket.get(0); } return null; @@ -273,11 +279,12 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem } static boolean GLXFBConfig2GLCapabilities(List capsBucket, - GLProfile glp, long display, long fbcfg, + GLProfile glp, AbstractGraphicsDevice device, long fbcfg, int winattrmask, boolean isMultisampleAvailable) { - final int allDrawableTypeBits = FBCfgDrawableTypeBits(display, fbcfg); + final int allDrawableTypeBits = FBCfgDrawableTypeBits(device, glp, fbcfg); int drawableTypeBits = winattrmask & allDrawableTypeBits; - + + final long display = device.getHandle(); int fbcfgid = X11GLXGraphicsConfiguration.glXFBConfig2FBConfigID(display, fbcfg); XVisualInfo visualInfo = GLX.glXGetVisualFromFBConfig(display, fbcfg); if(null == visualInfo) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index 8377d2453..331401c06 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -44,6 +44,7 @@ import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -161,7 +162,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF return null; } for (int i = 0; i < fbcfgsL.limit(); i++) { - if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, display, fbcfgsL.get(i), GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { + if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { if(DEBUG) { System.err.println("X11GLXGraphicsConfiguration.getAvailableGLCapabilitiesFBConfig: FBConfig invalid (2): ("+x11Screen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); } @@ -209,7 +210,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF X11GraphicsDevice x11Device = (X11GraphicsDevice) x11Screen.getDevice(); X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory.canCreateGLPbuffer(x11Device) ); + capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(x11Device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(x11Device) ); boolean usePBuffer = capsChosen.isPBuffer(); X11GLXGraphicsConfiguration res = null; @@ -245,7 +246,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - final X11GLCapabilities caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glp, display, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(absDevice)); + final X11GLCapabilities caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glp, absDevice, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(absDevice)); return new X11GLXGraphicsConfiguration(x11Screen, caps, caps, new DefaultGLCapabilitiesChooser()); } @@ -258,6 +259,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF GLProfile glProfile = capsChosen.getGLProfile(); boolean onscreen = capsChosen.isOnscreen(); boolean usePBuffer = capsChosen.isPBuffer(); + boolean useFBO = capsChosen.isFBO(); // Utilizing FBConfig // @@ -270,13 +272,12 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, true, isMultisampleAvailable, display, screen); int[] count = { -1 }; List availableCaps = new ArrayList(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer); - + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, useFBO); // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice fbcfgsL = GLX.glXChooseFBConfig(display, screen, attribs, 0, count, 0); if (fbcfgsL != null && fbcfgsL.limit()>0) { for (int i = 0; i < fbcfgsL.limit(); i++) { - if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, display, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { + if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { if(DEBUG) { System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid (1): ("+x11Screen+","+capsChosen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); } @@ -309,7 +310,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } for (int i = 0; i < fbcfgsL.limit(); i++) { - if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, display, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { + if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { if(DEBUG) { System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid (2): ("+x11Screen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); } @@ -338,7 +339,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } GLProfile glProfile = capsChosen.getGLProfile(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(capsChosen.isOnscreen(), false /* pbuffer */); + final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(capsChosen.isOnscreen(), false /* pbuffer */, false); List availableCaps = new ArrayList(); int recommendedIndex = -1; diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java index 9e22afa6d..363299321 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11OnscreenGLXDrawable.java @@ -51,10 +51,13 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable { long glXWindow; // GLXWindow, a GLXDrawable representation boolean useGLXWindow; - protected X11OnscreenGLXDrawable(GLDrawableFactory factory, NativeSurface component) { - super(factory, component, false); + protected X11OnscreenGLXDrawable(GLDrawableFactory factory, NativeSurface component, boolean realized) { + super(factory, component, realized); glXWindow=0; useGLXWindow=false; + if(realized) { + updateHandle(); + } } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java index cdf81ebd3..e1fe2f27e 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java @@ -43,7 +43,7 @@ package jogamp.opengl.x11.glx; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; @@ -77,7 +77,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { if (ns.getSurfaceHandle() != 0) { GLX.glXDestroyPbuffer(ns.getDisplayHandle(), ns.getSurfaceHandle()); } - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); } private void createPbuffer() { @@ -108,12 +108,14 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { // Create the p-buffer. int niattribs = 0; - int[] iattributes = new int[5]; + int[] iattributes = new int[7]; iattributes[niattribs++] = GLX.GLX_PBUFFER_WIDTH; iattributes[niattribs++] = ns.getWidth(); iattributes[niattribs++] = GLX.GLX_PBUFFER_HEIGHT; iattributes[niattribs++] = ns.getHeight(); + iattributes[niattribs++] = GLX.GLX_LARGEST_PBUFFER; // exact + iattributes[niattribs++] = 0; iattributes[niattribs++] = 0; long pbuffer = GLX.glXCreatePbuffer(display, config.getFBConfig(), iattributes, 0); @@ -123,15 +125,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } // Set up instance variables - ((SurfaceChangeable)ns).setSurfaceHandle(pbuffer); - - // Determine the actual width and height we were able to create. - int[] tmp = new int[1]; - GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_WIDTH, tmp, 0); - int width = tmp[0]; - GLX.glXQueryDrawable(display, pbuffer, GLX.GLX_HEIGHT, tmp, 0); - int height = tmp[0]; - ((SurfaceChangeable)ns).surfaceSizeChanged(width, height); + ((MutableSurface)ns).setSurfaceHandle(pbuffer); if (DEBUG) { System.err.println("Created pbuffer " + this); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java index 1e7b89828..04627724c 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java @@ -43,7 +43,7 @@ package jogamp.opengl.x11.glx; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; @@ -93,7 +93,7 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable { pixmap = 0; throw new GLException("glXCreateGLXPixmap failed"); } - ((SurfaceChangeable)ns).setSurfaceHandle(drawable); + ((MutableSurface)ns).setSurfaceHandle(drawable); if (DEBUG) { System.err.println("Created pixmap " + toHexString(pixmap) + ", GLXPixmap " + toHexString(drawable) + @@ -133,7 +133,7 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable { X11Lib.XFreePixmap(display, pixmap); drawable = 0; pixmap = 0; - ((SurfaceChangeable)ns).setSurfaceHandle(0); + ((MutableSurface)ns).setSurfaceHandle(0); display = 0; } } diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m index 776284cfc..b81b43e54 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m @@ -32,7 +32,6 @@ int texWidth; int texHeight; GLuint textureID; - struct timespec lastWaitTime; #ifdef HAS_CADisplayLink CADisplayLink* displayLink; #else @@ -41,6 +40,7 @@ int tc; struct timespec t0; @public + struct timespec lastWaitTime; GLint swapInterval; GLint swapIntervalCounter; pthread_mutex_t renderLock; diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index 8ac9f4700..d3f703142 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -503,7 +503,7 @@ NSView* getNSView(NSOpenGLContext* ctx) { NSOpenGLContext* createContext(NSOpenGLContext* share, NSView* view, - Bool isBackingLayerView, + Bool allowIncompleteView, NSOpenGLPixelFormat* fmt, Bool opaque, int* viewNotReady) @@ -512,13 +512,13 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, getRendererInfo(); - DBG_PRINT("createContext.0: share %p, view %p, isBackingLayer %d, pixfmt %p, opaque %d\n", - share, view, (int)isBackingLayerView, fmt, opaque); + DBG_PRINT("createContext.0: share %p, view %p, allowIncompleteView %d, pixfmt %p, opaque %d\n", + share, view, (int)allowIncompleteView, fmt, opaque); if (view != NULL) { Bool viewReady = true; - if(!isBackingLayerView) { + if(!allowIncompleteView) { if ([view lockFocusIfCanDraw] == NO) { DBG_PRINT("createContext.1 [view lockFocusIfCanDraw] failed\n"); viewReady = false; @@ -527,7 +527,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, if(viewReady) { NSRect frame = [view frame]; if ((frame.size.width == 0) || (frame.size.height == 0)) { - if(!isBackingLayerView) { + if(!allowIncompleteView) { [view unlockFocus]; } DBG_PRINT("createContext.2 view.frame size %dx%d\n", (int)frame.size.width, (int)frame.size.height); @@ -558,7 +558,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, [ctx setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity]; } [ctx setView:view]; - if(!isBackingLayerView) { + if(!allowIncompleteView) { [view unlockFocus]; } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java index 04f616daf..b7f6ba45d 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java @@ -30,51 +30,49 @@ package com.jogamp.nativewindow; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.SurfaceChangeable; +public class WrappedSurface extends ProxySurface { + protected long surfaceHandle; -public class WrappedSurface extends ProxySurface implements SurfaceChangeable { - protected long surfaceHandle; - - public WrappedSurface(AbstractGraphicsConfiguration cfg) { - this(cfg, 0); - } - - public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle) { - super(cfg); + public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { + super(cfg, initialWidth, initialHeight, upstream); surfaceHandle=handle; } @Override - protected final void invalidateImpl() { + protected void invalidateImpl() { surfaceHandle = 0; } @Override - final public long getSurfaceHandle() { + public final long getSurfaceHandle() { return surfaceHandle; } @Override - final public void setSurfaceHandle(long surfaceHandle) { + public final void setSurfaceHandle(long surfaceHandle) { this.surfaceHandle=surfaceHandle; } - + @Override - final protected int lockSurfaceImpl() { - return LOCK_SUCCESS; + protected final int lockSurfaceImpl() { + return LOCK_SUCCESS; } @Override - final protected void unlockSurfaceImpl() { + protected final void unlockSurfaceImpl() { } @Override public String toString() { + final UpstreamSurfaceHook ush = getUpstreamSurfaceHook(); + final String ush_s = null != ush ? ( ush.getClass().getName() + ": " + ush ) : "nil"; + return "WrappedSurface[config " + getPrivateGraphicsConfiguration()+ ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + ", size " + getWidth() + "x" + getHeight() + - ", surfaceLock "+surfaceLock+"]"; + ", surfaceLock "+surfaceLock+ + ", upstreamSurfaceHook "+ush_s+"]"; } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java index d161f2f34..389949e90 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java @@ -38,7 +38,7 @@ import javax.media.nativewindow.*; */ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneable { final long nativeDisplayID; - final EGLTerminateCallback eglTerminateCallback; + final EGLDisplayLifecycleCallback eglLifecycleCallback; /** * Hack to allow inject a EGL termination call. @@ -47,7 +47,14 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl * since then it can be utilized directly. *

    */ - public interface EGLTerminateCallback { + public interface EGLDisplayLifecycleCallback { + /** + * Implementation should issue an EGL.eglGetDisplay(nativeDisplayID) + * inclusive EGL.eglInitialize(eglDisplayHandle, ..) call. + * @param eglDisplayHandle + */ + public long eglGetAndInitDisplay(long nativeDisplayID); + /** * Implementation should issue an EGL.eglTerminate(eglDisplayHandle) call. * @param eglDisplayHandle @@ -61,28 +68,45 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl */ public EGLGraphicsDevice(String connection, int unitID) { super(NativeWindowFactory.TYPE_EGL, connection, unitID); - this.nativeDisplayID = 0; - this.eglTerminateCallback = null; + this.nativeDisplayID = 0 ; // EGL.EGL_DEFAULT_DISPLAY + this.eglLifecycleCallback = null; } - public EGLGraphicsDevice(long nativeDisplayID, long eglDisplay, String connection, int unitID, EGLTerminateCallback eglTerminateCallback) { + public EGLGraphicsDevice(long nativeDisplayID, long eglDisplay, String connection, int unitID, EGLDisplayLifecycleCallback eglLifecycleCallback) { super(NativeWindowFactory.TYPE_EGL, connection, unitID, eglDisplay); this.nativeDisplayID = nativeDisplayID; - this.eglTerminateCallback = eglTerminateCallback; + this.eglLifecycleCallback = eglLifecycleCallback; } public long getNativeDisplayID() { return nativeDisplayID; } + @Override public Object clone() { return super.clone(); } + + @Override + public boolean open() { + if(null != eglLifecycleCallback && 0 == handle) { + if(DEBUG) { + System.err.println(Thread.currentThread().getName() + " - EGLGraphicsDevice.open(): "+this); + } + handle = eglLifecycleCallback.eglGetAndInitDisplay(nativeDisplayID); + if(0 == handle) { + throw new NativeWindowException("EGLGraphicsDevice.open() failed: "+this); + } + return true; + } + return false; + } + @Override public boolean close() { - if(null != eglTerminateCallback) { + if(null != eglLifecycleCallback && 0 != handle) { if(DEBUG) { - System.err.println(Thread.currentThread().getName() + " - eglTerminate: "+this); + System.err.println(Thread.currentThread().getName() + " - EGLGraphicsDevice.close(): "+this); } - eglTerminateCallback.eglTerminate(handle); + eglLifecycleCallback.eglTerminate(handle); } return super.close(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 735d85fb1..0494bb408 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -43,7 +43,6 @@ import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsDevice; -import jogamp.common.awt.AWTEDTExecutor; import jogamp.nativewindow.macosx.OSXUtil; public class SWTAccessor { @@ -204,8 +203,6 @@ public class SWTAccessor { if( null != OS_gtk_class ) { long widgedHandle = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle); long displayHandle = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, widgedHandle); - // FIXME: May think about creating a private non-shared X11 Display handle, like we use to for AWT - // to avoid locking problems ! return new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, false); } if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) ) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index a02332413..7a98e3c25 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -33,7 +33,6 @@ package com.jogamp.nativewindow.x11; -import jogamp.nativewindow.Debug; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; @@ -46,7 +45,7 @@ import javax.media.nativewindow.ToolkitLock; */ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable { - final boolean closeDisplay; + final boolean handleOwner; /** Constructs a new X11GraphicsDevice corresponding to the given connection and default * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String)}.
    @@ -56,7 +55,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl */ public X11GraphicsDevice(String connection, int unitID) { super(NativeWindowFactory.TYPE_X11, connection, unitID); - closeDisplay = false; + handleOwner = false; } /** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default @@ -69,7 +68,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl if(0==display) { throw new NativeWindowException("null display"); } - closeDisplay = owner; + handleOwner = owner; } /** @@ -82,16 +81,39 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl if(0==display) { throw new NativeWindowException("null display"); } - closeDisplay = owner; + handleOwner = owner; } + public int getDefaultVisualID() { + // It still could be an AWT hold handle .. + final long display = getHandle(); + final int scrnIdx = X11Lib.DefaultScreen(display); + return (int) X11Lib.DefaultVisualID(display, scrnIdx); + } + + @Override public Object clone() { return super.clone(); } + @Override + public boolean open() { + if(handleOwner && 0 == handle) { + if(DEBUG) { + System.err.println(Thread.currentThread().getName() + " - X11GraphicsDevice.open(): "+this); + } + handle = X11Util.openDisplay(connection); + if(0 == handle) { + throw new NativeWindowException("X11GraphicsDevice.open() failed: "+this); + } + return true; + } + return false; + } + + @Override public boolean close() { - // FIXME: shall we respect the unitID ? - if(closeDisplay && 0 != handle) { + if(handleOwner && 0 != handle) { if(DEBUG) { System.err.println(Thread.currentThread().getName() + " - X11GraphicsDevice.close(): "+this); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index 94013ec38..014f4f688 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -56,13 +56,11 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl return new X11GraphicsScreen(new X11GraphicsDevice(display, AbstractGraphicsDevice.DEFAULT_UNIT, owner), screenIdx); } - public long getDefaultVisualID() { + public int getVisualID() { // It still could be an AWT hold handle .. - long display = getDevice().getHandle(); - int scrnIdx = X11Lib.DefaultScreen(display); - return X11Lib.DefaultVisualID(display, scrnIdx); + return (int) X11Lib.DefaultVisualID(getDevice().getHandle(), getIndex()); } - + private static int fetchScreen(X11GraphicsDevice device, int screen) { // It still could be an AWT hold handle .. if(X11Util.XineramaIsEnabled(device.getHandle())) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index 4979f1949..756e4451b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -113,16 +113,33 @@ public interface AbstractGraphicsDevice extends Cloneable { */ public void unlock(); + /** + * Optionally [re]opening the device if handle is null. + *

    + * The default implementation is a NOP. + *

    + *

    + * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} + * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} + * issue the native open operation in case handle is null. + *

    + * + * @return true if the handle was null and opening was successful, otherwise false. + */ + public boolean open(); + /** - * Optionally closing the device. + * Optionally closing the device if handle is not null. *

    * The default implementation is a NOP, just setting the handle to null. *

    - * The specific implementing, ie {@link com.jogamp.nativewindow.x11.X11GraphicsDevice}, - * shall have a enable/disable like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice#setCloseDisplay(boolean, boolean)},
    - * which shall be invoked at creation time to determine ownership/role of freeing the resource.
    + *

    + * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} + * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} + * issue the native close operation or skip it depending on the handles's ownership. + *

    * - * @return true if the handle was not null, otherwise false. + * @return true if the handle was not null and closing was successful, otherwise false. */ public boolean close(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index 187959a67..583fde07f 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -97,22 +97,27 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice } } + @Override public final String getType() { return type; } + @Override public final String getConnection() { return connection; } + @Override public final int getUnitID() { return unitID; } + @Override public final String getUniqueID() { return uniqueID; } + @Override public final long getHandle() { return handle; } @@ -124,6 +129,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long) * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock) */ + @Override public final void lock() { toolkitLock.lock(); } @@ -135,10 +141,17 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long) * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock) */ + @Override public final void unlock() { toolkitLock.unlock(); } + + @Override + public boolean open() { + return false; + } + @Override public boolean close() { if(0 != handle) { handle = 0; diff --git a/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java b/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java new file mode 100644 index 000000000..ff53c8109 --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/MutableSurface.java @@ -0,0 +1,44 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.nativewindow; + +/** + * Provides a {@link NativeSurface} with a mutable surfaceHandle + * via {@link #setSurfaceHandle(long)}. + * + * @see NativeSurface + */ +public interface MutableSurface extends NativeSurface { + + /** + * Sets the surface handle which is created outside of this implementation. + */ + public void setSurfaceHandle(long surfaceHandle); +} + diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index 1dabc3dcd..7fc9789c2 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -28,38 +28,108 @@ package javax.media.nativewindow; - import jogamp.nativewindow.Debug; import jogamp.nativewindow.SurfaceUpdatedHelper; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; -public abstract class ProxySurface implements NativeSurface { +public abstract class ProxySurface implements NativeSurface, MutableSurface { public static final boolean DEBUG = Debug.debug("ProxySurface"); + + /** + * Implementation specific bitvalue stating the upstream's {@link AbstractGraphicsDevice} is owned by this {@link ProxySurface}. + * @see #setImplBitfield(int) + * @see #getImplBitfield() + */ + public static final int OWN_DEVICE = 1 << 7; + + /** + * Implementation specific bitvalue stating the upstream's {@link NativeSurface} is an invisible window, i.e. maybe incomplete. + * @see #setImplBitfield(int) + * @see #getImplBitfield() + */ + public static final int INVISIBLE_WINDOW = 1 << 8; - private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); - private AbstractGraphicsConfiguration config; // control access due to delegation - protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); + /** Interface allowing upstream caller to pass lifecycle actions and size info to a {@link ProxySurface} instance. */ + public interface UpstreamSurfaceHook { + /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */ + public void create(ProxySurface s); + /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */ + public void destroy(ProxySurface s); + + /** Returns the width of the upstream surface */ + public int getWidth(ProxySurface s); + /** Returns the height of the upstream surface */ + public int getHeight(ProxySurface s); + } + + private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); + private final AbstractGraphicsConfiguration config; // control access due to delegation + private final UpstreamSurfaceHook upstream; + public final int initialWidth; + public final int initialHeight; private long surfaceHandle_old; + protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); protected long displayHandle; - protected int height; protected int scrnIndex; - protected int width; + protected int implBitfield; - public ProxySurface(AbstractGraphicsConfiguration cfg) { - invalidate(); - config = cfg; - displayHandle=cfg.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); - surfaceHandle_old = 0; + /** + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param initialWidth the initial width + * @param initialHeight the initial height + */ + protected ProxySurface(AbstractGraphicsConfiguration cfg, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { + if(null == cfg) { + throw new IllegalArgumentException("null config"); + } + this.config = cfg; + this.upstream = upstream; + this.initialWidth = initialWidth; + this.initialHeight = initialHeight; + this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); + this.surfaceHandle_old = 0; + this.implBitfield = 0; } - void invalidate() { - displayHandle = 0; - invalidateImpl(); + public final UpstreamSurfaceHook getUpstreamSurfaceHook() { return upstream; } + + /** + * If a valid {@link UpstreamSurfaceHook} instance is passed in the + * {@link ProxySurface#ProxySurface(AbstractGraphicsConfiguration, int, int, UpstreamSurfaceHook) constructor}, + * {@link UpstreamSurfaceHook#create(ProxySurface)} is being issued and the proxy surface/window handles shall be set. + */ + public void createNotify() { + if(null != upstream) { + upstream.create(this); + } + this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); + this.surfaceHandle_old = 0; } - protected abstract void invalidateImpl(); - + + /** + * If a valid {@link UpstreamSurfaceHook} instance is passed in the + * {@link ProxySurface#ProxySurface(AbstractGraphicsConfiguration, int, int, UpstreamSurfaceHook) constructor}, + * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all fields are cleared. + */ + public void destroyNotify() { + if(null != upstream) { + upstream.destroy(this); + invalidateImpl(); + } + this.displayHandle = 0; + this.surfaceHandle_old = 0; + } + + /** + * Must be overridden by implementations allowing having a {@link UpstreamSurfaceHook} being passed. + * @see #destroyNotify() + */ + protected void invalidateImpl() { + throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); + } + @Override public final long getDisplayHandle() { return displayHandle; @@ -82,19 +152,23 @@ public abstract class ProxySurface implements NativeSurface { @Override public abstract long getSurfaceHandle(); + @Override + public abstract void setSurfaceHandle(long surfaceHandle); + @Override public final int getWidth() { - return width; + if(null != upstream) { + return upstream.getWidth(this); + } + return initialWidth; } @Override public final int getHeight() { - return height; - } - - public void surfaceSizeChanged(int width, int height) { - this.width = width; - this.height = height; + if(null != upstream) { + return upstream.getHeight(this); + } + return initialHeight; } @Override @@ -187,7 +261,10 @@ public abstract class ProxySurface implements NativeSurface { public final Thread getSurfaceLockOwner() { return surfaceLock.getOwner(); } - + @Override public abstract String toString(); + + public int getImplBitfield() { return implBitfield; } + public void setImplBitfield(int v) { implBitfield=v; } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java b/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java deleted file mode 100644 index 956e68e61..000000000 --- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceChangeable.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package javax.media.nativewindow; - -public interface SurfaceChangeable { - - /** Sets the surface handle which is created outside of this implementation */ - public void setSurfaceHandle(long surfaceHandle); - - /** - * The surface's size has been determined or changed. - * Implementation shall update the stored surface size with the given ones. - */ - public void surfaceSizeChanged(int width, int height); - -} - diff --git a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java index 4877d5c4f..4f68c6945 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SurfaceUpdatedHelper.java @@ -34,8 +34,8 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.SurfaceUpdatedListener; public class SurfaceUpdatedHelper implements SurfaceUpdatedListener { - private Object surfaceUpdatedListenersLock = new Object(); - private ArrayList surfaceUpdatedListeners = new ArrayList(); + private final Object surfaceUpdatedListenersLock = new Object(); + private final ArrayList surfaceUpdatedListeners = new ArrayList(); // // Management Utils diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 42fd08df1..e81d61e0f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -48,7 +48,7 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.MutableGraphicsConfiguration; @@ -62,7 +62,7 @@ import jogamp.nativewindow.jawt.JAWT_DrawingSurfaceInfo; import jogamp.nativewindow.jawt.macosx.JAWT_MacOSXDrawingSurfaceInfo; import jogamp.nativewindow.macosx.OSXUtil; -public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { +public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { public MacOSXJAWTWindow(Object comp, AbstractGraphicsConfiguration config) { super(comp, config); if(DEBUG) { @@ -103,24 +103,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { if(DEBUG) { System.err.println("MacOSXJAWTWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); } - sscSet &= 0 != surfaceHandle; // reset ssc flag if NULL surfaceHandle, ie. back to JAWT this.surfaceHandle = surfaceHandle; } - public void surfaceSizeChanged(int width, int height) { - sscSet = true; - sscWidth = width; - sscHeight = height; - } - - public int getWidth() { - return sscSet ? sscWidth : super.getWidth(); - } - - public int getHeight() { - return sscSet ? sscHeight: super.getHeight(); - } - protected JAWT fetchJAWTImpl() throws NativeWindowException { // use offscreen if supported and [ applet or requested ] return JAWTUtil.getJAWT(getShallUseOffscreenLayer() || isApplet()); @@ -280,8 +265,6 @@ public class MacOSXJAWTWindow extends JAWTWindow implements SurfaceChangeable { private long rootSurfaceLayerHandle = 0; // attached to the JAWT_SurfaceLayer private long surfaceHandle = 0; - private int sscWidth, sscHeight; - private boolean sscSet = false; // Workaround for instance of 4796548 private boolean firstLock = true; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 4d472b01a..99fc9244e 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -63,19 +63,15 @@ public class OSXUtil { return (Point) GetLocationOnScreen0(windowOrView, src_x, src_y); } - public static long CreateNSView(int x, int y, int width, int height) { - return CreateNSView0(x, y, width, height); - } - public static void DestroyNSView(long nsView) { - DestroyNSView0(nsView); - } - public static long CreateNSWindow(int x, int y, int width, int height) { return CreateNSWindow0(x, y, width, height); } public static void DestroyNSWindow(long nsWindow) { DestroyNSWindow0(nsWindow); } + public static long GetNSView(long nsWindow) { + return GetNSView0(nsWindow); + } public static long CreateCALayer(int x, int y, int width, int height) { return CreateCALayer0(x, y, width, height); @@ -134,10 +130,9 @@ public class OSXUtil { private static native boolean initIDs0(); private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y); - private static native long CreateNSView0(int x, int y, int width, int height); - private static native void DestroyNSView0(long nsView); private static native long CreateNSWindow0(int x, int y, int width, int height); private static native void DestroyNSWindow0(long nsWindow); + private static native long GetNSView0(long nsWindow); private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index c24f64b32..e368aa6a1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -31,6 +31,7 @@ package jogamp.nativewindow.windows; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; /** @@ -43,22 +44,49 @@ public class GDISurface extends ProxySurface { protected long windowHandle; protected long surfaceHandle; - public GDISurface(AbstractGraphicsConfiguration cfg, long windowHandle) { - super(cfg); - if(0 == windowHandle) { - throw new NativeWindowException("Error hwnd 0, werr: "+GDI.GetLastError()); - } + public GDISurface(AbstractGraphicsConfiguration cfg, long windowHandle, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { + super(cfg, initialWidth, initialHeight, upstream); this.windowHandle=windowHandle; + this.surfaceHandle=0; } @Override - protected final void invalidateImpl() { - windowHandle=0; - surfaceHandle=0; + protected void invalidateImpl() { + if(0 != surfaceHandle) { + throw new NativeWindowException("didn't release surface Handle: "+this); + } + windowHandle = 0; + // surfaceHandle = 0; + } + + /** + * {@inheritDoc} + *

    + * Actually the window handle (HWND), since the surfaceHandle (HDC) is derived + * from it at {@link #lockSurface()}. + *

    + */ + @Override + public final void setSurfaceHandle(long surfaceHandle) { + this.windowHandle = surfaceHandle; + } + + /** + * Sets the window handle (HWND). + */ + public final void setWindowHandle(long windowHandle) { + this.windowHandle = windowHandle; + } + + public final long getWindowHandle() { + return windowHandle; } @Override final protected int lockSurfaceImpl() { + if (0 == windowHandle) { + throw new NativeWindowException("null window handle: "+this); + } if (0 != surfaceHandle) { throw new InternalError("surface not released"); } @@ -89,12 +117,15 @@ public class GDISurface extends ProxySurface { @Override final public String toString() { - return "GDISurface[config "+getPrivateGraphicsConfiguration()+ + final UpstreamSurfaceHook ush = getUpstreamSurfaceHook(); + final String ush_s = null != ush ? ( ush.getClass().getName() + ": " + ush ) : "nil"; + return getClass().getSimpleName()+"[config "+getPrivateGraphicsConfiguration()+ ", displayHandle 0x"+Long.toHexString(getDisplayHandle())+ ", windowHandle 0x"+Long.toHexString(windowHandle)+ ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ ", size "+getWidth()+"x"+getHeight()+ - ", surfaceLock "+surfaceLock+"]"; + ", surfaceLock "+surfaceLock+ + ", upstreamSurfaceHook "+ush_s+"]"; } } diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index e010fc440..ebfefe345 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -148,37 +148,6 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetLocationOnS return res; } -/* - * Class: Java_jogamp_nativewindow_macosx_OSXUtil - * Method: CreateNSView0 - * Signature: (IIIIZ)J - */ -JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSView0 - (JNIEnv *env, jclass unused, jint x, jint y, jint width, jint height) -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSRect rect = NSMakeRect(x, y, width, height); - NSView * view = [[NSView alloc] initWithFrame: rect] ; - [view setCanDrawConcurrently: YES]; - [pool release]; - - return (jlong) (intptr_t) view; -} - -/* - * Class: Java_jogamp_nativewindow_macosx_OSXUtil - * Method: DestroyNSView0 - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSView0 - (JNIEnv *env, jclass unused, jlong nsView) -{ - NSView* view = (NSView*) (intptr_t) nsView; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [view release]; - [pool release]; -} - /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateNSWindow0 @@ -222,6 +191,27 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyNSWindow0 [pool release]; } +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: GetNSView0 + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSView0 + (JNIEnv *env, jclass unused, jlong window) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSWindow* win = (NSWindow*) ((intptr_t) window); + + DBG_PRINT( "contentView0 - window: %p (START)\n", win); + + jlong res = (jlong) ((intptr_t) [win contentView]); + + DBG_PRINT( "contentView0 - window: %p (END)\n", win); + + [pool release]; + return res; +} + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateCALayer0 diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 71e86d520..e8537fec5 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -40,8 +40,20 @@ import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.WindowClosingProtocol; /** - * Specifying the public Window functionality for the - * using a Window and for shadowing one like {@link com.jogamp.newt.opengl.GLWindow}. + * Specifying NEWT's Window functionality: + *
      + *
    • On- and offscreen windows
    • + *
    • Keyboard and multi-pointer input
    • + *
    • Native reparenting
    • + *
    • Toggable fullscreen and decoration mode
    • + *
    • Transparency
    • + *
    • ... and more
    • + *
    + *

    + * One use case is {@link com.jogamp.newt.opengl.GLWindow}, which delegates + * window operation to an instance of this interface while providing OpenGL + * functionality. + *

    */ public interface Window extends NativeWindow, WindowClosingProtocol { public static final boolean DEBUG_MOUSE_EVENT = Debug.debug("Window.MouseEvent"); diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 44fcea49c..4db661eeb 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -43,7 +43,7 @@ public class KeyEvent extends InputEvent this.keyChar=keyChar; } - /** Only valid if delivered via {@link KeyListener#keyPressed(KeyEvent)} */ + /** Only valid on all platforms at {@link KeyListener#keyTyped(KeyEvent)} */ public char getKeyChar() { return keyChar; } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index f08fbc8fa..c50ab77c4 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -124,6 +124,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind this.window.setLifecycleHook(new GLLifecycleHook()); } + @Override + public final Object getUpstreamWidget() { + return window; + } + /** * Creates a new GLWindow attaching a new Window referencing a * new default Screen and default Display with the given GLCapabilities. @@ -762,7 +767,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind System.err.println(GlueGenVersion.getInstance()); System.err.println(JoglVersion.getInstance()); - System.err.println(JoglVersion.getDefaultOpenGLInfo(null, true).toString()); + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, true).toString()); final GLProfile glp = GLProfile.getDefault(); final GLCapabilitiesImmutable caps = new GLCapabilities( glp ); diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index 050e24b6c..be543aba9 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -34,15 +34,24 @@ package jogamp.newt; -import javax.media.nativewindow.*; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; -public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { +public class OffscreenWindow extends WindowImpl implements MutableSurface { long surfaceHandle = 0; - + ProxySurface.UpstreamSurfaceHook upstreamHook; + ProxySurface dummySurface; + public OffscreenWindow() { + upstreamHook = null; + dummySurface = null; } static long nextWindowHandle = 0x100; // start here - a marker @@ -52,6 +61,17 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { throw new NativeWindowException("Capabilities is onscreen"); } final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); + /** Cannot use OpenGL here .. + if(capsRequested instanceof GLCapabilitiesImmutable) { + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) capsRequested; + if(caps.isFBO() && GLContext.isFBOAvailable(aScreen.getDevice(), caps.getGLProfile()) ) { + final GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLCapabilitiesImmutable dummyCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(caps); + final ProxySurface dummySurface = factory.createDummySurfaceImpl(aScreen.getDevice(), false, dummyCaps, null, 64, 64); + upstreamHook = dummySurface.getUpstreamSurfaceHook(); + dummySurface.createNotify(); + } + } */ final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aScreen.getDevice()).chooseGraphicsConfiguration( capsRequested, capsRequested, capabilitiesChooser, aScreen); if (null == cfg) { @@ -68,13 +88,14 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { // nop } - public void surfaceSizeChanged(int width, int height) { - sizeChanged(false, width, height, false); - } - @Override public synchronized void destroy() { super.destroy(); + if(null != dummySurface) { + dummySurface.destroyNotify(); + dummySurface = null; + upstreamHook = null; + } surfaceHandle = 0; } @@ -84,8 +105,12 @@ public class OffscreenWindow extends WindowImpl implements SurfaceChangeable { @Override public long getSurfaceHandle() { + if(null != dummySurface) { + return dummySurface.getSurfaceHandle(); + // return upstreamHook.getWidth(); + } return surfaceHandle; - } + } protected void requestFocusImpl(boolean reparented) { } diff --git a/src/newt/classes/jogamp/newt/driver/android/MD.java b/src/newt/classes/jogamp/newt/driver/android/MD.java index 403eae383..f2f30937b 100644 --- a/src/newt/classes/jogamp/newt/driver/android/MD.java +++ b/src/newt/classes/jogamp/newt/driver/android/MD.java @@ -43,7 +43,7 @@ public class MD { .append(JoglVersion.getInstance()).append(Platform.NEWLINE) .append(Platform.NEWLINE); - JoglVersion.getDefaultOpenGLInfo(sb, true); + JoglVersion.getDefaultOpenGLInfo(null, sb, true); return sb.toString(); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java index 942994c13..fcca5c843 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java @@ -38,7 +38,7 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.SurfaceChangeable; +import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; @@ -50,7 +50,7 @@ import jogamp.newt.driver.DriverUpdatePosition; import com.jogamp.newt.event.KeyEvent; -public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverClearFocus, DriverUpdatePosition { +public class MacWindow extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { static { MacDisplay.initSingleton(); @@ -131,10 +131,6 @@ public class MacWindow extends WindowImpl implements SurfaceChangeable, DriverCl } } - public void surfaceSizeChanged(int width, int height) { - sizeChanged(false, width, height, false); - } - @Override protected void setTitleImpl(final String title) { setTitle0(getWindowHandle(), title); diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index f914467af..b58b99e38 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -972,7 +972,7 @@ static jint mods2JavaMods(NSUInteger mods) NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { - return; + return NO; } NewtView* view = (NewtView *) nsview; @@ -981,14 +981,14 @@ static jint mods2JavaMods(NSUInteger mods) DBG_PRINT( "*************** windowWillClose.0: %p\n", (void *)(intptr_t)javaWindowObject); if (javaWindowObject == NULL) { DBG_PRINT("windowWillClose: null javaWindowObject\n"); - return; + return NO; } int shallBeDetached = 0; JavaVM *jvmHandle = [view getJVMHandle]; JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached); if(NULL==env) { DBG_PRINT("windowWillClose: null JNIEnv\n"); - return; + return NO; } [view setDestroyNotifySent: true]; // earmark assumption of being closed diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java index a09cc76ac..b22be0a93 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java @@ -194,7 +194,7 @@ public class TestTextRendererNEWT00 extends UITestCase { pw.printf("%s-%03dx%03d-T%04d", objName, drawable.getWidth(), drawable.getHeight(), texSize[0]); final String filename = dir + sw +".png"; - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + if(screenshot.readPixels(drawable.getGL(), false)) { screenshot.write(new File(filename)); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java index a3182a30f..6378c1ee3 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java @@ -194,7 +194,7 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), texSize[0], objName); final String filename = dir + tech + sw +".png"; - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + if(screenshot.readPixels(drawable.getGL(), false)) { screenshot.write(new File(filename)); } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java index d0093ad0c..15daf70cd 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java @@ -180,7 +180,7 @@ public abstract class UIListenerBase01 implements GLEventListener { pw.printf("-%03dx%03d-Z%04d-T%04d-%s", drawable.getWidth(), drawable.getHeight(), (int)Math.abs(zoom), 0, objName); final String filename = dir + tech + sw +".png"; - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { + if(screenshot.readPixels(drawable.getGL(), false)) { screenshot.write(new File(filename)); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java new file mode 100644 index 000000000..1a33845b3 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java @@ -0,0 +1,272 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import jogamp.opengl.GLFBODrawableImpl; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.OffscreenAutoDrawable; +import com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; + +public class TestFBODrawableNEWT extends UITestCase { + + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + @Test + public void testGL2ES2_Demo1Normal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } + + @Test + public void testGL2ES2_Demo1MSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } + + @Test + public void testGL2ES2_Demo2Normal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, new MultisampleDemoES2(false)); + } + + @Test + public void testGL2ES2_Demo2MSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new MultisampleDemoES2(true)); + } + + @Test + public void testGL2ES2_FBODemoNormal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); + demo.setDoRotation(false); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, demo); + } + + @Test + public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); + demo.setDoRotation(false); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, demo); + } + + @Test + public void testEGLES2_Demo0Normal() throws InterruptedException { + if( GLProfile.isAvailable(GLProfile.GLES2) ) { + final GLProfile glp = GLProfile.get(GLProfile.GLES2); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } else { + System.err.println("EGL ES2 n/a"); + } + } + + @Test + public void testEGLES2_Demo0MSAA4() throws InterruptedException { + if( GLProfile.isAvailable(GLProfile.GLES2) ) { + final GLProfile glp = GLProfile.get(GLProfile.GLES2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } else { + System.err.println("EGL ES2 n/a"); + } + } + + boolean skipShot = false; + + void testGLFBODrawableImpl(GLCapabilities caps, GLEventListener demo) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + caps.setFBO(true); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable fboDrawable = factory.createOffscreenDrawable(null, caps, null, widthStep*szStep, heightStep*szStep); + Assert.assertNotNull(fboDrawable); + Assert.assertTrue("Not an FBO Drawable", fboDrawable instanceof GLFBODrawableImpl); + + fboDrawable.setRealized(true); + Assert.assertTrue(fboDrawable.isRealized()); + + final FBObject fbo = ((GLFBODrawableImpl)fboDrawable).getFBObject(); + + System.out.println("Realized: "+fboDrawable); + System.out.println("Realized: "+fboDrawable.getChosenGLCapabilities()); + System.out.println("Realized: "+fbo); + + final GLContext context = fboDrawable.createContext(null); + Assert.assertNotNull(context); + + int res = context.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + context.release(); + + System.out.println("Post Create-Ctx: "+fbo); + final FBObject.Colorbuffer colorA = fbo.getColorbuffer(0); + Assert.assertNotNull(colorA); + final FBObject.RenderAttachment depthA = fbo.getDepthAttachment(); + Assert.assertNotNull(depthA); + + final OffscreenAutoDrawable glad = new OffscreenAutoDrawable(fboDrawable, context, null); + + glad.addGLEventListener(demo); + glad.addGLEventListener(new GLEventListener() { + volatile int displayCount=0; + volatile int reshapeCount=0; + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + // System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": step "+szStep+" "+drawable.getWidth()+"x"+drawable.getHeight()); + // System.err.println(Thread.currentThread().getName()+": ** FBO-THIS: "+fbo); + // System.err.println(Thread.currentThread().getName()+": ** FBO-SINK: "+fbo.getSamplingSinkFBO()); + // System.err.println(Thread.currentThread().getName()+": ** drawable-read: "+gl.getDefaultReadFramebuffer()); + if(skipShot) { + skipShot=false; + } else { + snapshot(getSimpleTestName("."), displayCount, "msaa"+fbo.getNumSamples(), gl, screenshot, TextureIO.PNG, null); + } + Assert.assertEquals(drawable.getWidth(), widthStep*szStep); + Assert.assertEquals(drawable.getHeight(), heightStep*szStep); + displayCount++; + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + System.err.println(Thread.currentThread().getName()+": ** reshape: "+reshapeCount+": step "+szStep+" "+width+"x"+height+" - "+drawable.getWidth()+"x"+drawable.getHeight()); + Assert.assertEquals(drawable.getWidth(), widthStep*szStep); + Assert.assertEquals(drawable.getHeight(), heightStep*szStep); + reshapeCount++; + } + }); + + // 0 - szStep = 2 + glad.display(); + + // 1, 2 (resize + display) + szStep = 1; + skipShot=true; + glad.setSize(widthStep*szStep, heightStep*szStep); + glad.display(); + Assert.assertEquals(glad.getWidth(), widthStep*szStep); + Assert.assertEquals(glad.getHeight(), heightStep*szStep); + { + // Check whether the attachment reference are still valid! + FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0); + Assert.assertNotNull(_colorA); + Assert.assertTrue(colorA == _colorA); + Assert.assertTrue(colorA.equals(_colorA)); + FBObject.RenderAttachment _depthA = fbo.getDepthAttachment(); + Assert.assertNotNull(_depthA); + Assert.assertTrue(depthA == _depthA); + Assert.assertTrue(depthA.equals(_depthA)); + + _colorA = fbo.getColorbuffer(colorA); + Assert.assertNotNull(_colorA); + Assert.assertTrue(colorA == _colorA); + Assert.assertTrue(colorA.equals(_colorA)); + } + + // 3, 4 (resize + display) + szStep = 4; + skipShot=true; + glad.setSize(widthStep*szStep, heightStep*szStep); + glad.display(); + Assert.assertEquals(glad.getWidth(), widthStep*szStep); + Assert.assertEquals(glad.getHeight(), heightStep*szStep); + { + // Check whether the attachment reference are still valid! + FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0); + Assert.assertNotNull(_colorA); + Assert.assertTrue(colorA == _colorA); + final FBObject.RenderAttachment _depthA = fbo.getDepthAttachment(); + Assert.assertNotNull(_depthA); + Assert.assertTrue(depthA == _depthA); + + _colorA = fbo.getColorbuffer(colorA); + Assert.assertNotNull(_colorA); + Assert.assertTrue(colorA == _colorA); + } + + // 5 + glad.display(); + Assert.assertEquals(glad.getWidth(), widthStep*szStep); + Assert.assertEquals(glad.getHeight(), heightStep*szStep); + + // 6, 7 (resize + display) + szStep = 3; + skipShot=true; + glad.setSize(widthStep*szStep, heightStep*szStep); + glad.display(); + Assert.assertEquals(glad.getWidth(), widthStep*szStep); + Assert.assertEquals(glad.getHeight(), heightStep*szStep); + + glad.destroy(); + System.out.println("Fin: "+fboDrawable); + + // final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(fboDrawable, context); + } + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestFBODrawableNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java new file mode 100644 index 000000000..f7c83a03b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java @@ -0,0 +1,266 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.acore; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.TextureAttachment; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; +import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.FBObject.Attachment.Type; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.NEWTGLContext; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import java.io.IOException; + +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLPipelineFactory; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLUniformData; + +import org.junit.Assert; +import org.junit.Test; + +public class TestFBOMRTNEWT01 extends UITestCase { + static long durationPerTest = 10*40*2; // ms + + @Test + public void test01() throws InterruptedException { + final int step = 4; + final int width = 800; + final int height = 600; + // preset .. + if(!GLProfile.isAvailable(GLProfile.GL2GL3)) { + System.err.println("Test requires GL2/GL3 profile."); + return; + } + final NEWTGLContext.WindowContext winctx = NEWTGLContext.createOnscreenWindow( + new GLCapabilities(GLProfile.getGL2GL3()), width/step, height/step, true); + final GLDrawable drawable = winctx.context.getGLDrawable(); + GL2GL3 gl = winctx.context.getGL().getGL2GL3(); + gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", null, gl, null) ).getGL2GL3(); + System.err.println(winctx.context); + + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + // test code .. + final ShaderState st = new ShaderState(); + // st.setVerbose(true); + + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader", + "shader/bin", "fbo-mrt-1", false); + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader", + "shader/bin", "fbo-mrt-1", false); + final ShaderProgram sp0 = new ShaderProgram(); + sp0.add(gl, vp0, System.err); + sp0.add(gl, fp0, System.err); + Assert.assertTrue(0<=sp0.program()); + Assert.assertTrue(!sp0.inUse()); + Assert.assertTrue(!sp0.linked()); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + st.attachShaderProgram(gl, sp0, false); + + final ShaderCode vp1 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader", + "shader/bin", "fbo-mrt-2", false); + final ShaderCode fp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader", + "shader/bin", "fbo-mrt-2", false); + final ShaderProgram sp1 = new ShaderProgram(); + sp1.add(gl, vp1, System.err); + sp1.add(gl, fp1, System.err); + Assert.assertTrue(0<=sp1.program()); + Assert.assertTrue(!sp1.inUse()); + Assert.assertTrue(!sp1.linked()); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + st.attachShaderProgram(gl, sp1, true); + + final PMVMatrix pmvMatrix = new PMVMatrix(); + final GLUniformData pmvMatrixUniform = new GLUniformData("gcu_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final GLArrayDataServer vertices0 = GLArrayDataServer.createGLSL("gca_Vertices", 3, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + // st.bindAttribLocation(gl, 0, vertices0); + vertices0.putf(0); vertices0.putf(1); vertices0.putf(0); + vertices0.putf(1); vertices0.putf(1); vertices0.putf(0); + vertices0.putf(0); vertices0.putf(0); vertices0.putf(0); + vertices0.putf(1); vertices0.putf(0); vertices0.putf(0); + vertices0.seal(gl, true); + st.ownAttribute(vertices0, true); + vertices0.enableBuffer(gl, false); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final GLArrayDataServer colors0 = GLArrayDataServer.createGLSL("gca_Colors", 4, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + // st.bindAttribLocation(gl, 1, colors0); + colors0.putf(1); colors0.putf(0); colors0.putf(1); colors0.putf(1); + colors0.putf(0); colors0.putf(0); colors0.putf(1); colors0.putf(1); + colors0.putf(0); colors0.putf(0); colors0.putf(0); colors0.putf(1); + colors0.putf(0); colors0.putf(1); colors0.putf(1); colors0.putf(1); + colors0.seal(gl, true); + st.ownAttribute(colors0, true); + colors0.enableBuffer(gl, false); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final GLUniformData texUnit0 = new GLUniformData("gcs_TexUnit0", 0); + st.ownUniform(texUnit0); + st.uniform(gl, texUnit0); + final GLUniformData texUnit1 = new GLUniformData("gcs_TexUnit1", 1); + st.ownUniform(texUnit1); + st.uniform(gl, texUnit1); + + final GLArrayDataServer texCoords0 = GLArrayDataServer.createGLSL("gca_TexCoords", 2, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + // st.bindAttribLocation(gl, 2, texCoords0); + texCoords0.putf(0f); texCoords0.putf(1f); + texCoords0.putf(1f); texCoords0.putf(1f); + texCoords0.putf(0f); texCoords0.putf(0f); + texCoords0.putf(1f); texCoords0.putf(0f); + texCoords0.seal(gl, true); + st.ownAttribute(texCoords0, true); + texCoords0.enableBuffer(gl, false); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final int texA0Point = 0; // attachment point for texA0 + final int texA1Point = 1; // attachment point for texA1 + + // FBO w/ 2 texture2D color buffers + final FBObject fbo_mrt = new FBObject(); + fbo_mrt.reset(gl, drawable.getWidth(), drawable.getHeight()); + final TextureAttachment texA0 = fbo_mrt.attachTexture2D(gl, texA0Point, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + final TextureAttachment texA1 = fbo_mrt.attachTexture2D(gl, texA1Point, true, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + fbo_mrt.attachRenderbuffer(gl, Type.DEPTH, 24); + Assert.assertTrue( fbo_mrt.isStatusValid() ) ; + fbo_mrt.unbind(gl); + + // misc GL setup + gl.glClearColor(1, 1, 1, 1); + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + // reshape + pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glOrthof(0f, 1f, 0f, 1f, -10f, 10f); + pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + st.uniform(gl, pmvMatrixUniform); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + final int[] two_buffers = new int[] { GL.GL_COLOR_ATTACHMENT0+texA0Point, GL.GL_COLOR_ATTACHMENT0+texA1Point }; + final int[] bck_buffers = new int[] { GL2GL3.GL_BACK_LEFT }; + + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + int step_i = 0; + int[] last_snap_size = new int[] { 0, 0 }; + + for(int i=0; i buffer0, Green -> buffer1 + st.attachShaderProgram(gl, sp0, true); + vertices0.enableBuffer(gl, true); + colors0.enableBuffer(gl, true); + + fbo_mrt.bind(gl); + gl.glDrawBuffers(2, two_buffers, 0); + gl.glViewport(0, 0, fbo_mrt.getWidth(), fbo_mrt.getHeight()); + + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); + fbo_mrt.unbind(gl); + vertices0.enableBuffer(gl, false); + colors0.enableBuffer(gl, false); + + // pass 2 - mix buffer0, buffer1 and blue + // rg = buffer0.rg + buffer1.rg, b = Blue - length(rg); + st.attachShaderProgram(gl, sp1, true); + vertices0.enableBuffer(gl, true); + colors0.enableBuffer(gl, true); + texCoords0.enableBuffer(gl, true); + gl.glDrawBuffers(1, bck_buffers, 0); + + gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue()); + fbo_mrt.use(gl, texA0); + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit1.intValue()); + fbo_mrt.use(gl, texA1); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); + fbo_mrt.unuse(gl); + vertices0.enableBuffer(gl, false); + colors0.enableBuffer(gl, false); + texCoords0.enableBuffer(gl, false); + + { + final NativeSurface ns = gl.getContext().getGLReadDrawable().getNativeSurface(); + if(last_snap_size[0] != ns.getWidth() && last_snap_size[1] != ns.getHeight()) { + gl.glFinish(); // sync .. no swap buffers yet! + snapshot(getSimpleTestName("."), step_i, null, gl, screenshot, TextureIO.PNG, null); // overwrite ok + last_snap_size[0] = ns.getWidth(); + last_snap_size[1] = ns.getHeight(); + } + } + + drawable.swapBuffers(); + Thread.sleep(50); + int j = (int) ( (long)i / (durationPerTest/(long)step) ) + 1; + if(j>step_i) { + int w = width/step * j; + int h = height/step * j; + System.err.println("resize: "+step_i+" -> "+j+" - "+w+"x"+h); + fbo_mrt.reset(gl, w, h); + winctx.window.setSize(w, h); + step_i = j; + } + } + + NEWTGLContext.destroyWindow(winctx); + } + + public static void main(String args[]) throws IOException { + System.err.println("main - start"); + for(int i=0; i "+num); + demo.setMSAA(num); + } + } + } + }); + + animator.start(); + // glWindow.setSkipContextReleaseThread(animator.getThread()); + + glWindow.setVisible(true); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()= 0; i--) { - immModeSink.glVertex3f((float) (radius * Math.cos(i * increment)), - (float) (radius * Math.sin(i * increment)), - 0f); - immModeSink.glVertex3f((float) (-1.0 * radius * Math.cos(i * increment)), - (float) (-1.0 * radius * Math.sin(i * increment)), - 0f); - } - immModeSink.glEnd(gl, false); - } - - public void dispose(GLAutoDrawable drawable) { - immModeSink.destroy(drawable.getGL()); - immModeSink = null; - } - - public void display(GLAutoDrawable drawable) { - GL2ES1 gl = drawable.getGL().getGL2ES1(); - if (multisample) { - gl.glEnable(GL.GL_MULTISAMPLE); - } - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - immModeSink.draw(gl, true); - if (multisample) { - gl.glDisable(GL.GL_MULTISAMPLE); - } - } - - // Unused routines - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - - public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java index 4b0caf898..478bd4543 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java @@ -40,7 +40,6 @@ package com.jogamp.opengl.test.junit.jogl.caps; -import java.io.File; import java.lang.reflect.InvocationTargetException; import java.awt.BorderLayout; import java.awt.Frame; @@ -48,14 +47,15 @@ import java.awt.Frame; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; -import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; +import com.jogamp.opengl.test.junit.jogl.demos.es1.MultisampleDemoES1; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import org.junit.Test; @@ -75,13 +75,6 @@ public class TestMultisampleES1AWT extends UITestCase { org.junit.runner.JUnitCore.main(tstname); } - protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); - if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { - screenshot.write(new File(filename)); - } - } - @Test public void testOnscreenMultiSampleAA0() throws InterruptedException, InvocationTargetException { testMultiSampleAAImpl(0); @@ -98,6 +91,7 @@ public class TestMultisampleES1AWT extends UITestCase { } private void testMultiSampleAAImpl(int reqSamples) throws InterruptedException, InvocationTargetException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp = GLProfile.getMaxFixedFunc(true); GLCapabilities caps = new GLCapabilities(glp); GLCapabilitiesChooser chooser = new MultisampleChooser01(); @@ -110,14 +104,11 @@ public class TestMultisampleES1AWT extends UITestCase { canvas = new GLCanvas(caps, chooser, null, null); canvas.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false)); canvas.addGLEventListener(new GLEventListener() { + int displayCount = 0; public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); - final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; - final String aaext = caps.getSampleExtension(); - final int samples = caps.getSampleBuffers() ? caps.getNumSamples() : 0 ; - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-S"+samples+"-"+aaext+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java index 2e47b6841..ed8e2bd85 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java @@ -40,21 +40,20 @@ package com.jogamp.opengl.test.junit.jogl.caps; -import java.io.File; - import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; -import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import org.junit.Test; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es1.MultisampleDemoES1; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; public class TestMultisampleES1NEWT extends UITestCase { static long durationPerTest = 60; // ms @@ -71,13 +70,6 @@ public class TestMultisampleES1NEWT extends UITestCase { org.junit.runner.JUnitCore.main(tstname); } - protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); - if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { - screenshot.write(new File(filename)); - } - } - @Test public void testOnscreenMultiSampleAA0() throws InterruptedException { testMultiSampleAAImpl(true, 0); @@ -119,6 +111,7 @@ public class TestMultisampleES1NEWT extends UITestCase { } private void testMultiSampleAAImpl(boolean onscreen, int reqSamples) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp = GLProfile.getMaxFixedFunc(true); GLCapabilities caps = new GLCapabilities(glp); GLCapabilitiesChooser chooser = new MultisampleChooser01(); @@ -136,14 +129,11 @@ public class TestMultisampleES1NEWT extends UITestCase { window.setCapabilitiesChooser(chooser); window.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false)); window.addGLEventListener(new GLEventListener() { + int displayCount = 0; public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); - final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; - final String aaext = caps.getSampleExtension(); - final int samples = caps.getSampleBuffers() ? caps.getNumSamples() : 0 ; - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-S"+samples+"-"+aaext+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java new file mode 100644 index 000000000..b2dad1f39 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.jogamp.opengl.test.junit.jogl.caps; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; + +public class TestMultisampleES2NEWT extends UITestCase { + static long durationPerTest = 60; // ms + private GLWindow window; + + public static void main(String[] args) { + for(int i=0; i0) { + caps.setSampleBuffers(true); + caps.setNumSamples(reqSamples); + } + + window = GLWindow.create(caps); + window.setCapabilitiesChooser(chooser); + window.addGLEventListener(new MultisampleDemoES2(reqSamples>0?true:false)); + window.addGLEventListener(new GLEventListener() { + int displayCount = 0; + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + window.setSize(512, 512); + window.setVisible(true); + window.requestFocus(); + + Thread.sleep(durationPerTest); + + window.destroy(); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java index 5c82a43c6..e81d1b4af 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java @@ -129,12 +129,13 @@ public class GearsES1 implements GLEventListener { gl.glEnable(GL2ES1.GL_NORMALIZE); - if (drawable.getNativeSurface() instanceof Window) { - Window window = (Window) drawable.getNativeSurface(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addMouseListener(gearsMouse); window.addKeyListener(gearsKeys); - } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { - java.awt.Component comp = (java.awt.Component) drawable; + } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { + final java.awt.Component comp = (java.awt.Component) upstreamWidget; new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse).addTo(comp); new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys).addTo(comp); } @@ -165,8 +166,9 @@ public class GearsES1 implements GLEventListener { public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES1.dispose ... "); - if (drawable.getNativeSurface() instanceof Window) { - Window window = (Window) drawable.getNativeSurface(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); } @@ -188,8 +190,9 @@ public class GearsES1 implements GLEventListener { GL2ES1 gl = drawable.getGL().getGL2ES1(); final boolean hasFocus; - if(drawable.getNativeSurface() instanceof NativeWindow) { - hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if(upstreamWidget instanceof NativeWindow) { + hasFocus = ((NativeWindow)upstreamWidget).hasFocus(); } else { hasFocus = true; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/MultisampleDemoES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/MultisampleDemoES1.java new file mode 100644 index 000000000..aad56581b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/MultisampleDemoES1.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es1; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +import com.jogamp.opengl.util.ImmModeSink; + +public class MultisampleDemoES1 implements GLEventListener { + + boolean multisample; + ImmModeSink immModeSink; + + public MultisampleDemoES1(boolean multisample) { + this.multisample = multisample; + } + + public void init(GLAutoDrawable drawable) { + System.err.println(); + System.err.println("Requested: " + drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()); + System.err.println(); + System.err.println("Chosen : " + drawable.getChosenGLCapabilities()); + System.err.println(); + GL2ES1 gl = drawable.getGL().getGL2ES1(); + if (multisample) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + gl.glClearColor(0, 0, 0, 0); + // gl.glEnable(GL.GL_DEPTH_TEST); + // gl.glDepthFunc(GL.GL_LESS); + gl.glMatrixMode(GL2ES1.GL_MODELVIEW); + gl.glLoadIdentity(); + gl.glMatrixMode(GL2ES1.GL_PROJECTION); + gl.glLoadIdentity(); + gl.glOrtho(-1, 1, -1, 1, -1, 1); + if (multisample) { + gl.glDisable(GL.GL_MULTISAMPLE); + } + immModeSink = ImmModeSink.createFixed(gl, GL.GL_STATIC_DRAW, 40, + 3, GL.GL_FLOAT, // vertex + 0, GL.GL_FLOAT, // color + 0, GL.GL_FLOAT,// normal + 0, GL.GL_FLOAT); // texture + final int numSteps = 20; + final double increment = Math.PI / numSteps; + final double radius = 1; + immModeSink.glBegin(GL.GL_LINES); + for (int i = numSteps - 1; i >= 0; i--) { + immModeSink.glVertex3f((float) (radius * Math.cos(i * increment)), + (float) (radius * Math.sin(i * increment)), + 0f); + immModeSink.glVertex3f((float) (-1.0 * radius * Math.cos(i * increment)), + (float) (-1.0 * radius * Math.sin(i * increment)), + 0f); + } + immModeSink.glEnd(gl, false); + } + + public void dispose(GLAutoDrawable drawable) { + immModeSink.destroy(drawable.getGL()); + immModeSink = null; + } + + public void display(GLAutoDrawable drawable) { + GL2ES1 gl = drawable.getGL().getGL2ES1(); + if (multisample) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + immModeSink.draw(gl, true); + if (multisample) { + gl.glDisable(GL.GL_MULTISAMPLE); + } + } + + // Unused routines + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java new file mode 100644 index 000000000..3dfbb4893 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/FBOMix2DemosES2.java @@ -0,0 +1,309 @@ +/** + * Copyright (C) 2011 JogAmp Community. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2; + +import java.nio.FloatBuffer; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLUniformData; +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.TextureAttachment; +import com.jogamp.opengl.FBObject.Attachment.Type; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; + +public class FBOMix2DemosES2 implements GLEventListener { + private final GearsES2 demo0; + private final RedSquareES2 demo1; + private final int swapInterval; + private int numSamples; + private boolean demo0Only; + + + private final ShaderState st; + private final PMVMatrix pmvMatrix; + + private final FBObject fbo0; + private final FBObject fbo1; + + private TextureAttachment fbo0Tex; + private TextureAttachment fbo1Tex; + + private ShaderProgram sp0; + private GLUniformData pmvMatrixUniform; + private GLArrayDataServer interleavedVBO; + private GLUniformData texUnit0; + private GLUniformData texUnit1; + + public FBOMix2DemosES2(int swapInterval) { + demo0 = new GearsES2(-1); + demo0.setIsFBOSlave(true); + demo1 = new RedSquareES2(-1); + demo1.setIsFBOSlave(true); + this.swapInterval = swapInterval; + + st = new ShaderState(); + // st.setVerbose(true); + pmvMatrix = new PMVMatrix(); + + fbo0 = new FBObject(); + fbo1 = new FBObject(); + + numSamples = 0; + demo0Only = false; + } + + public void setDemo0Only(boolean v) { + this.demo0Only = v; + } + public boolean getDemo0Only() { return demo0Only; } + + public void setMSAA(int numSamples) { + this.numSamples=numSamples; + } + public int getMSAA() { return numSamples; } + + public void setDoRotation(boolean rotate) { demo1.setDoRotation(rotate); } + + static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; + static final String gl2_prelude = "#version 110\n"; + + @Override + public void init(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + + demo0.init(drawable); + demo1.init(drawable); + + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, FBOMix2DemosES2.class, "shader", + "shader/bin", "texture01_xxx", true); + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, FBOMix2DemosES2.class, "shader", + "shader/bin", "texture02_xxx", true); + + // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ] + int fp0Pos; + if(gl.isGLES2()) { + vp0.insertShaderSource(0, 0, es2_prelude[0]); + fp0Pos = fp0.insertShaderSource(0, 0, es2_prelude[0]); + } else { + vp0.insertShaderSource(0, 0, gl2_prelude); + fp0Pos = fp0.insertShaderSource(0, 0, gl2_prelude); + } + if(gl.isGLES2()) { + fp0Pos = fp0.insertShaderSource(0, fp0Pos, es2_prelude[1]); + } + + sp0 = new ShaderProgram(); + sp0.add(gl, vp0, System.err); + sp0.add(gl, fp0, System.err); + st.attachShaderProgram(gl, sp0, true); + + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + + interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW); + { + interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER); + //interleavedVBO.addGLSLSubArray("mgl_Normal", 3, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER); + + FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer(); + + for(int i=0; i<4; i++) { + ib.put(s_quadVertices, i*3, 3); + ib.put(s_quadColors, i*4, 4); + //ib.put(s_cubeNormals, i*3, 3); + ib.put(s_quadTexCoords, i*2, 2); + } + } + interleavedVBO.seal(gl, true); + interleavedVBO.enableBuffer(gl, false); + st.ownAttribute(interleavedVBO, true); + + texUnit0 = new GLUniformData("mgl_Texture0", 0); + st.ownUniform(texUnit0); + st.uniform(gl, texUnit0); + texUnit1 = new GLUniformData("mgl_Texture1", 1); + st.ownUniform(texUnit1); + st.uniform(gl, texUnit1); + + st.useProgram(gl, false); + + System.err.println("**** Init"); + resetFBOs(gl, drawable); + + fbo0.attachRenderbuffer(gl, Type.DEPTH, 24); + fbo0.unbind(gl); + fbo1.attachRenderbuffer(gl, Type.DEPTH, 24); + fbo1.unbind(gl); + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + + numSamples=fbo0.getNumSamples(); + } + + /** Since we switch MSAA and non-MSAA we need to take extra care, i.e. sync msaa for both FBOs ..*/ + private void resetFBOs(GL gl, GLAutoDrawable drawable) { + // remove all texture attachments, since MSAA uses just color-render-buffer + // and non-MSAA uses texture2d-buffer + fbo0.detachAllColorbuffer(gl); + fbo1.detachAllColorbuffer(gl); + + fbo0.reset(gl, drawable.getWidth(), drawable.getHeight(), numSamples); + fbo1.reset(gl, drawable.getWidth(), drawable.getHeight(), numSamples); + if(fbo0.getNumSamples() != fbo1.getNumSamples()) { + throw new InternalError("sample size mismatch: \n\t0: "+fbo0+"\n\t1: "+fbo1); + } + numSamples = fbo0.getNumSamples(); + + if(numSamples>0) { + fbo0.attachColorbuffer(gl, 0, true); + fbo1.attachColorbuffer(gl, 0, true); + fbo0Tex = fbo0.getSamplingSink(); + fbo1Tex = fbo1.getSamplingSink(); + } else { + fbo0Tex = fbo0.attachTexture2D(gl, 0, true); + fbo1Tex = fbo1.attachTexture2D(gl, 0, true); + } + } + + @Override + public void dispose(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + demo0.dispose(drawable); + demo1.dispose(drawable); + fbo0.destroy(gl); + fbo1.destroy(gl); + st.destroy(gl); + + fbo0Tex = null; + fbo1Tex = null; + sp0 = null; + pmvMatrixUniform = null; + interleavedVBO = null; + } + + @Override + public void display(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + + if( fbo0.getNumSamples() != numSamples ) { + System.err.println("**** NumSamples: "+fbo0.getNumSamples()+" -> "+numSamples); + resetFBOs(gl, drawable); + } + + if(0 < numSamples) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + + fbo0.bind(gl); + demo0.display(drawable); + fbo0.unbind(gl); + + if(!demo0Only) { + fbo1.bind(gl); + demo1.display(drawable); + fbo1.unbind(gl); + } + + st.useProgram(gl, true); + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue()); + fbo0.use(gl, fbo0Tex); + if(!demo0Only) { + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit1.intValue()); + fbo1.use(gl, fbo1Tex); + } + interleavedVBO.enableBuffer(gl, true); + + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); + + interleavedVBO.enableBuffer(gl, false); + fbo0.unuse(gl); + if(!demo0Only) { + fbo1.unuse(gl); + } + + st.useProgram(gl, false); + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } + + // if(drawable.getWidth() == fbo0.getWidth() && drawable.getHeight() == fbo0.getHeight() ) { + System.err.println("**** Reshape: "+width+"x"+height); + resetFBOs(gl, drawable); + //} + + fbo0.bind(gl); + demo0.reshape(drawable, x, y, width, height); + fbo0.unbind(gl); + fbo1.bind(gl); + demo1.reshape(drawable, x, y, width, height); + fbo1.unbind(gl); + + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); + + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + + st.useProgram(gl, true); + st.uniform(gl, pmvMatrixUniform); + st.useProgram(gl, false); + + } + + private static final float[] s_quadVertices = { + -1f, -1f, 0f, // LB + 1f, -1f, 0f, // RB + -1f, 1f, 0f, // LT + 1f, 1f, 0f // RT + }; + private static final float[] s_quadColors = { + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f }; + private static final float[] s_quadTexCoords = { + 0f, 0f, // LB + 1f, 0f, // RB + 0f, 1f, // LT + 1f, 1f // RT + }; +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 6aea5bb9c..38e8a15ce 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -65,6 +65,7 @@ public class GearsES2 implements GLEventListener { private int prevMouseX, prevMouseY; private boolean isInitialized = false; + boolean isFBOSlave = false; public GearsES2(int swapInterval) { this.swapInterval = swapInterval; @@ -74,6 +75,8 @@ public class GearsES2 implements GLEventListener { this.swapInterval = 1; } + public void setIsFBOSlave(boolean v) { isFBOSlave = v; } + public void setPMVUseBackingArray(boolean pmvUseBackingArray) { this.pmvUseBackingArray = pmvUseBackingArray; } @@ -115,7 +118,6 @@ public class GearsES2 implements GLEventListener { System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); - gl.glEnable(GL.GL_CULL_FACE); gl.glEnable(GL.GL_DEPTH_TEST); st = new ShaderState(); @@ -168,13 +170,14 @@ public class GearsES2 implements GLEventListener { gear3 = new GearsObjectES2(gear3, pmvMatrix, pmvMatrixUniform, colorU); System.err.println("gear3 reused: "+gear3); } - - if (drawable.getNativeSurface() instanceof Window) { - Window window = (Window) drawable.getNativeSurface(); + + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addMouseListener(gearsMouse); window.addKeyListener(gearsKeys); - } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { - java.awt.Component comp = (java.awt.Component) drawable; + } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { + final java.awt.Component comp = (java.awt.Component) upstreamWidget; new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse).addTo(comp); new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys).addTo(comp); } @@ -187,7 +190,9 @@ public class GearsES2 implements GLEventListener { System.err.println(Thread.currentThread()+" GearsES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval); GL2ES2 gl = drawable.getGL().getGL2ES2(); - gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } st.useProgram(gl, true); pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); @@ -218,8 +223,9 @@ public class GearsES2 implements GLEventListener { } isInitialized = false; System.err.println(Thread.currentThread()+" GearsES2.dispose ... "); - if (drawable.getNativeSurface() instanceof Window) { - Window window = (Window) drawable.getNativeSurface(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); } @@ -235,6 +241,7 @@ public class GearsES2 implements GLEventListener { colorU = null; st.destroy(gl); st = null; + System.err.println(Thread.currentThread()+" GearsES2.dispose FIN"); } @@ -246,12 +253,16 @@ public class GearsES2 implements GLEventListener { GL2ES2 gl = drawable.getGL().getGL2ES2(); final boolean hasFocus; - if(drawable.getNativeSurface() instanceof NativeWindow) { - hasFocus = ((NativeWindow)drawable.getNativeSurface()).hasFocus(); + final Object upstreamWidget = drawable.getUpstreamWidget(); + if(upstreamWidget instanceof NativeWindow) { + hasFocus = ((NativeWindow)upstreamWidget).hasFocus(); } else { hasFocus = true; } - if(hasFocus) { + + gl.glEnable(GL.GL_CULL_FACE); + + if( isFBOSlave || hasFocus ) { gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } else { gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f); @@ -278,7 +289,9 @@ public class GearsES2 implements GLEventListener { gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f, GearsObject.green); gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f, GearsObject.blue); pmvMatrix.glPopMatrix(); - st.useProgram(gl, false); + st.useProgram(gl, false); + + gl.glDisable(GL.GL_CULL_FACE); } boolean confinedFixedCenter = false; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java new file mode 100644 index 000000000..5facc1a49 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es2; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLUniformData; +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +import com.jogamp.opengl.util.ImmModeSink; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; + +public class MultisampleDemoES2 implements GLEventListener { + + private boolean multisample; + private final ShaderState st; + private final PMVMatrix pmvMatrix; + private ShaderProgram sp0; + private GLUniformData pmvMatrixUniform; + private ImmModeSink immModeSink; + + public MultisampleDemoES2(boolean multisample) { + this.multisample = multisample; + st = new ShaderState(); + st.setVerbose(true); + pmvMatrix = new PMVMatrix(); + } + + static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; + static final String gl2_prelude = "#version 110\n"; + + public void init(GLAutoDrawable glad) { + final GL2ES2 gl = glad.getGL().getGL2ES2(); + System.err.println(); + System.err.println("Requested: " + glad.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()); + System.err.println(); + System.err.println("Chosen : " + glad.getChosenGLCapabilities()); + System.err.println(); + + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MultisampleDemoES2.class, "shader", + "shader/bin", "mgl_default_xxx", true); + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MultisampleDemoES2.class, "shader", + "shader/bin", "mgl_default_xxx", true); + + // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ] + int fp0Pos; + if(gl.isGLES2()) { + vp0.insertShaderSource(0, 0, es2_prelude[0]); + fp0Pos = fp0.insertShaderSource(0, 0, es2_prelude[0]); + } else { + vp0.insertShaderSource(0, 0, gl2_prelude); + fp0Pos = fp0.insertShaderSource(0, 0, gl2_prelude); + } + if(gl.isGLES2()) { + fp0Pos = fp0.insertShaderSource(0, fp0Pos, es2_prelude[1]); + } + + sp0 = new ShaderProgram(); + sp0.add(gl, vp0, System.err); + sp0.add(gl, fp0, System.err); + st.attachShaderProgram(gl, sp0, true); + + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + + // Using predef array names, see + // GLPointerFuncUtil.getPredefinedArrayIndexName(glArrayIndex); + immModeSink = ImmModeSink.createGLSL(gl, GL.GL_STATIC_DRAW, 40, + 3, GL.GL_FLOAT, // vertex + 4, GL.GL_FLOAT, // color + 0, GL.GL_FLOAT,// normal + 0, GL.GL_FLOAT); // texture + final int numSteps = 20; + final double increment = Math.PI / numSteps; + final double radius = 1; + immModeSink.glBegin(GL.GL_LINES); + for (int i = numSteps - 1; i >= 0; i--) { + immModeSink.glVertex3f((float) (radius * Math.cos(i * increment)), + (float) (radius * Math.sin(i * increment)), + 0f); + immModeSink.glColor4f( 1f, 1f, 1f, 1f ); + immModeSink.glVertex3f((float) (-1.0 * radius * Math.cos(i * increment)), + (float) (-1.0 * radius * Math.sin(i * increment)), + 0f); + immModeSink.glColor4f( 1f, 1f, 1f, 1f ); + } + immModeSink.glEnd(gl, false); + + st.useProgram(gl, false); + } + + public void dispose(GLAutoDrawable glad) { + final GL2ES2 gl = glad.getGL().getGL2ES2(); + immModeSink.destroy(gl); + immModeSink = null; + st.destroy(gl); + } + + public void display(GLAutoDrawable glad) { + final GL2ES2 gl = glad.getGL().getGL2ES2(); + if (multisample) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + gl.glClearColor(0, 0, 0, 0); + // gl.glEnable(GL.GL_DEPTH_TEST); + // gl.glDepthFunc(GL.GL_LESS); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + st.useProgram(gl, true); + + immModeSink.draw(gl, true); + + st.useProgram(gl, false); + } + + // Unused routines + public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { + System.err.println("reshape .."); + final GL2ES2 gl = glad.getGL().getGL2ES2(); + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + // pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); + pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + + st.useProgram(gl, true); + st.uniform(gl, pmvMatrixUniform); + st.useProgram(gl, false); + } + + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 6982d61b7..436c44759 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -27,9 +27,9 @@ */ package com.jogamp.opengl.test.junit.jogl.demos.es2; +import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -37,10 +37,8 @@ import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; -import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLRunnable; import javax.media.opengl.GLUniformData; public class RedSquareES2 implements GLEventListener { @@ -52,10 +50,11 @@ public class RedSquareES2 implements GLEventListener { long t0; private int swapInterval = 0; MyMouseAdapter myMouse = new MyMouseAdapter(); - GLWindow glWindow = null; + Window window = null; float aspect = 1.0f; boolean doRotate = true; boolean isInitialized = false; + boolean isFBOSlave = false; public RedSquareES2(int swapInterval) { this.swapInterval = swapInterval; @@ -65,6 +64,7 @@ public class RedSquareES2 implements GLEventListener { this.swapInterval = 1; } + public void setIsFBOSlave(boolean v) { isFBOSlave = v; } public void setAspect(float aspect) { this.aspect = aspect; } public void setDoRotation(boolean rotate) { this.doRotate = rotate; } @@ -129,13 +129,13 @@ public class RedSquareES2 implements GLEventListener { colors.enableBuffer(gl, false); // OpenGL Render Settings - gl.glClearColor(0, 0, 0, 0); gl.glEnable(GL2ES2.GL_DEPTH_TEST); st.useProgram(gl, false); - if (glad instanceof GLWindow) { - glWindow = (GLWindow) glad; - glWindow.addMouseListener(myMouse); + final Object upstreamWidget = glad.getUpstreamWidget(); + if (!isFBOSlave && upstreamWidget instanceof Window) { + window = (Window) upstreamWidget; + window.addMouseListener(myMouse); } t0 = System.currentTimeMillis(); System.err.println(Thread.currentThread()+" RedSquareES2.init FIN"); @@ -145,6 +145,7 @@ public class RedSquareES2 implements GLEventListener { long t1 = System.currentTimeMillis(); GL2ES2 gl = glad.getGL().getGL2ES2(); + gl.glClearColor(0, 0, 0, 0); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); st.useProgram(gl, true); // One rotation every four seconds @@ -171,7 +172,9 @@ public class RedSquareES2 implements GLEventListener { System.err.println(Thread.currentThread()+" RedSquareES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval); GL2ES2 gl = glad.getGL().getGL2ES2(); - gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } st.useProgram(gl, true); // Set location in front of camera @@ -192,9 +195,9 @@ public class RedSquareES2 implements GLEventListener { } isInitialized = false; System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... "); - if (null != glWindow) { - glWindow.removeMouseListener(myMouse); - glWindow = null; + if (null != window) { + window.removeMouseListener(myMouse); + window = null; } GL2ES2 gl = glad.getGL().getGL2ES2(); st.destroy(gl); @@ -207,24 +210,9 @@ public class RedSquareES2 implements GLEventListener { class MyMouseAdapter extends MouseAdapter { public void mouseClicked(MouseEvent e) { System.err.println(e); - if(null != glWindow && e.getSource() == glWindow.getDelegatedWindow()) { - if(e.getX() < glWindow.getWidth()/2) { - glWindow.setFullscreen(!glWindow.isFullscreen()); - System.err.println("setFullscreen: "+glWindow.isFullscreen()); - } else { - glWindow.invoke(false, new GLRunnable() { - public boolean run(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - gl.setSwapInterval(gl.getSwapInterval()<=0?1:0); - System.err.println("setSwapInterval: "+gl.getSwapInterval()); - final GLAnimatorControl a = drawable.getAnimator(); - if( null != a ) { - a.resetFPSCounter(); - } - return true; - } - }); - } + if(null != window && e.getSource() == window) { + window.setFullscreen(!window.isFullscreen()); + System.err.println("setFullscreen: "+window.isFullscreen()); } } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index b04bd07c1..9217e2b53 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -265,11 +265,12 @@ public class TextureSequenceCubeES2 implements GLEventListener { st.useProgram(gl, false); - if (drawable instanceof Window) { - Window window = (Window) drawable; + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addMouseListener(mouseAction); - } else if (GLProfile.isAWTAvailable() && drawable instanceof java.awt.Component) { - java.awt.Component comp = (java.awt.Component) drawable; + } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { + final java.awt.Component comp = (java.awt.Component) upstreamWidget; new com.jogamp.newt.event.awt.AWTMouseAdapter(mouseAction).addTo(comp); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 0b83aacd8..7f2713354 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -163,8 +163,9 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { mPlayer.start(); boolean added; - if (drawable instanceof Window) { - Window window = (Window) drawable; + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addKeyListener(keyAction); added = true; } else { added = false; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index 8210065ab..e17c9e88b 100755 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -400,8 +400,9 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { startTime = System.currentTimeMillis(); - if (drawable instanceof Window) { - Window window = (Window) drawable; + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; window.addMouseListener(mouseAction); winWidth = window.getWidth(); winHeight = window.getHeight(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 04563d62e..797a16485 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -258,7 +258,6 @@ public class TestGearsES2NEWT extends UITestCase { public static void main(String args[]) throws IOException { int x=0, y=0, w=640, h=480; - boolean useSize = false; boolean usePos = false; for(int i=0; i= height. + * + * Draws the Gears demo in a window that's twice as wide than it is tall, + * and checks to see if a particular pixel in the right half of the frame + * is colored. + * + * @author Wade Walker (adapted from TestGearsGLJPanelAWT) + */ +public class TestGLJPanelAWTBug450 extends UITestCase { + static GLProfile glp; + static int width, height; + static int r_x, r_y; + /** Set this if test fails. Needed because we can't throw an exception + * all the way up the stack from where we test the pixel. */ + static boolean failed; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getGL2ES2(); + Assert.assertNotNull(glp); + height = 256; + width = 2*height; + r_x = 5*height/4; // 5/8 * width + r_y = height/2; + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilities caps) + throws AWTException, InterruptedException, InvocationTargetException + { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + JFrame frame = new JFrame("Swing GLJPanel"); + Assert.assertNotNull(frame); + + GLJPanel glJPanel = new GLJPanel(caps); + Assert.assertNotNull(glJPanel); + RedSquareES2 demo = new RedSquareES2(); + demo.setAspect((float)width/(float)height); + demo.setDoRotation(false); + glJPanel.addGLEventListener(demo); + glJPanel.addGLEventListener(new GLEventListener() { + int f = 0; + @Override + public void init(GLAutoDrawable drawable) { + // drawable.getGL().glClearColor(0, 0, 1, 1); + } + @Override + public void display(GLAutoDrawable drawable) { + // look at one pixel at the bottom of the frame, just right of + // the center line, and make sure it's not black + GL2 gl = GLUgl2.getCurrentGL2(); + ByteBuffer bytebuffer = ByteBuffer.allocateDirect( 3 ); + gl.glReadPixels( r_x, r_y, 1, 1, GL2.GL_BGR, GL2.GL_UNSIGNED_BYTE, bytebuffer ); + byte byte0 = bytebuffer.get( 0 ); + byte byte1 = bytebuffer.get( 1 ); + byte byte2 = bytebuffer.get( 2 ); + if( (byte0 == 0) && (byte1 == 0) && (byte2 == 0) ) { + failed = true; + } + if(0 == f) { + System.err.println("BGR ("+r_x+"/"+r_y+"): "+byte0+", "+byte1+", "+byte2+" - OK "+(!failed)); + snapshot(getSimpleTestName("."), f, null, gl, screenshot, TextureIO.PNG, null); + } + f++; + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + FPSAnimator animator = new FPSAnimator(glJPanel, 60); + + final JFrame _frame = frame; + final GLJPanel _glJPanel = glJPanel; + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + _frame.getContentPane().add(_glJPanel, BorderLayout.CENTER); + _frame.setSize(width, height); + _frame.setVisible(true); + } } ) ; + + animator.setUpdateFPSFrames(1, null); + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + + while(animator.isAnimating() && animator.getTotalFPSDuration()= height. - * - * Draws the Gears demo in a window that's twice as wide than it is tall, - * and checks to see if a particular pixel in the right half of the frame - * is colored. - * - * @author Wade Walker (adapted from TestGearsGLJPanelAWT) - */ -public class TestGearsGLJPanelAWTBug450 extends UITestCase { - static GLProfile glp; - static int width, height; - static int r_x, r_y; - /** Set this if test fails. Needed because we can't throw an exception - * all the way up the stack from where we test the pixel. */ - static boolean failed; - - @BeforeClass - public static void initClass() { - glp = GLProfile.getGL2ES2(); - Assert.assertNotNull(glp); - height = 256; - width = 2*height; - r_x = 5*height/4; // 5/8 * width - r_y = height/2; - } - - @AfterClass - public static void releaseClass() { - } - - protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); - if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { - screenshot.write(new File(filename)); - } - } - - protected void runTestGL(GLCapabilities caps) - throws AWTException, InterruptedException, InvocationTargetException - { - JFrame frame = new JFrame("Swing GLJPanel"); - Assert.assertNotNull(frame); - - GLJPanel glJPanel = new GLJPanel(caps); - Assert.assertNotNull(glJPanel); - RedSquareES2 demo = new RedSquareES2(); - demo.setAspect((float)width/(float)height); - demo.setDoRotation(false); - glJPanel.addGLEventListener(demo); - glJPanel.addGLEventListener(new GLEventListener() { - int f = 0; - @Override - public void init(GLAutoDrawable drawable) { - // drawable.getGL().glClearColor(0, 0, 1, 1); - } - @Override - public void display(GLAutoDrawable drawable) { - // look at one pixel at the bottom of the frame, just right of - // the center line, and make sure it's not black - GL2 gl = GLUgl2.getCurrentGL2(); - ByteBuffer bytebuffer = ByteBuffer.allocateDirect( 3 ); - gl.glReadPixels( r_x, r_y, 1, 1, GL2.GL_BGR, GL2.GL_UNSIGNED_BYTE, bytebuffer ); - byte byte0 = bytebuffer.get( 0 ); - byte byte1 = bytebuffer.get( 1 ); - byte byte2 = bytebuffer.get( 2 ); - if( (byte0 == 0) && (byte1 == 0) && (byte2 == 0) ) { - failed = true; - } - if(0 == f) { - System.err.println("BGR ("+r_x+"/"+r_y+"): "+byte0+", "+byte1+", "+byte2+" - OK "+(!failed)); - snapshot(drawable, true, false, getSimpleTestName(".")+".png"); - } - f++; - } - @Override - public void dispose(GLAutoDrawable drawable) {} - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } - }); - - FPSAnimator animator = new FPSAnimator(glJPanel, 60); - - final JFrame _frame = frame; - final GLJPanel _glJPanel = glJPanel; - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - _frame.getContentPane().add(_glJPanel, BorderLayout.CENTER); - _frame.setSize(width, height); - _frame.setVisible(true); - } } ) ; - - animator.setUpdateFPSFrames(1, null); - animator.start(); - Assert.assertEquals(true, animator.isAnimating()); - - while(animator.isAnimating() && animator.getTotalFPSDuration() buffer0, Green -> buffer1 - st.attachShaderProgram(gl, sp0, true); - vertices0.enableBuffer(gl, true); - colors0.enableBuffer(gl, true); - - fbo_mrt.bind(gl); - gl.glDrawBuffers(2, two_buffers, 0); - gl.glViewport(0, 0, fbo_mrt.getWidth(), fbo_mrt.getHeight()); - - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); - fbo_mrt.unbind(gl); - vertices0.enableBuffer(gl, false); - colors0.enableBuffer(gl, false); - - // pass 2 - mix buffer0, buffer1 and blue - // rg = buffer0.rg + buffer1.rg, b = Blue - length(rg); - st.attachShaderProgram(gl, sp1, true); - vertices0.enableBuffer(gl, true); - colors0.enableBuffer(gl, true); - texCoords0.enableBuffer(gl, true); - gl.glDrawBuffers(1, bck_buffers, 0); - - gl.glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); - fbo_mrt.use(gl, 0); - fbo_mrt.use(gl, 1); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); - fbo_mrt.unuse(gl); - vertices0.enableBuffer(gl, false); - colors0.enableBuffer(gl, false); - texCoords0.enableBuffer(gl, false); - - drawable.swapBuffers(); - Thread.sleep(50); - } - - NEWTGLContext.destroyWindow(winctx); - } - - public static void main(String args[]) throws IOException { - System.err.println("main - start"); - for(int i=0; i 0 ? "rgba" : "rgb_"; - snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null); + snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null); + f++; } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java index b5b12035d..5681df0ad 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite01NEWT.java @@ -28,8 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.util.texture; -import java.io.File; - import com.jogamp.newt.opengl.GLWindow; import javax.media.opengl.GLAutoDrawable; @@ -37,6 +35,7 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -62,32 +61,26 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase { height = 256; } - protected void snapshot(GLAutoDrawable drawable, boolean alpha, boolean flip, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(alpha, false); - if(screenshot.readPixels(drawable.getGL(), drawable, flip)) { - screenshot.write(new File(filename)); - } - } - @Test public void testOnscreenWritePNG_TGA_PAM() throws InterruptedException { + final GLReadBufferUtil screenshotRGB = new GLReadBufferUtil(false, false); + final GLReadBufferUtil screenshotRGBA = new GLReadBufferUtil(true, false); GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Shared Gears NEWT Test"); glWindow.setSize(width, height); glWindow.addGLEventListener(new GearsES2(1)); glWindow.addGLEventListener(new GLEventListener() { + int f = 0; public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - // snapshot(drawable, false, true, getSimpleTestName(".")+"-rgb_-"+drawable.getGLProfile().getName()+".ppm"); - snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".tga"); - snapshot(drawable, true, true, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".pam"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".tga"); - snapshot(drawable, false, true, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".pam"); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGBA, TextureIO.TGA, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGB, TextureIO.TGA, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGBA, TextureIO.PAM, null); + snapshot(getSimpleTestName("."), f++, null, drawable.getGL(), screenshotRGB, TextureIO.PAM, null); } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); @@ -98,18 +91,21 @@ public class TestGLReadBufferUtilTextureIOWrite01NEWT extends UITestCase { @Test public void testOffscreenWritePNG() throws InterruptedException { + final GLReadBufferUtil screenshotRGB = new GLReadBufferUtil(false, false); + final GLReadBufferUtil screenshotRGBA = new GLReadBufferUtil(true, false); final GLCapabilities caps2 = WindowUtilNEWT.fixCaps(caps, false, true, false); GLWindow glWindow = GLWindow.create(caps2); Assert.assertNotNull(glWindow); glWindow.setSize(width, height); glWindow.addGLEventListener(new GearsES2(1)); glWindow.addGLEventListener(new GLEventListener() { + int f = 0; public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - snapshot(drawable, true, false, getSimpleTestName(".")+"-F_rgba-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); - snapshot(drawable, false, false, getSimpleTestName(".")+"-F_rgb_-I_"+pfmt+"-"+drawable.getGLProfile().getName()+".png"); + snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGBA, TextureIO.PNG, null); + snapshot(getSimpleTestName("."), f, null, drawable.getGL(), screenshotRGB, TextureIO.PNG, null); + f++; } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java index 10dd4ea70..43641fe6d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02AWT.java @@ -30,9 +30,6 @@ package com.jogamp.opengl.test.junit.jogl.util.texture; import java.awt.Dimension; import java.awt.Frame; -import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -45,6 +42,7 @@ import jogamp.nativewindow.jawt.JAWTUtil; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -71,20 +69,6 @@ public class TestGLReadBufferUtilTextureIOWrite02AWT extends UITestCase { height = 64; } - protected void snapshot(GLAutoDrawable drawable, GLReadBufferUtil screenshot, int i) { - final StringWriter filename = new StringWriter(); - { - final PrintWriter pw = new PrintWriter(filename); - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - pw.printf("%s-F_rgba-I_%s-%s-n%03d-%04dx%04d.png", - getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), i, drawable.getWidth(), drawable.getHeight()); - } - drawable.getGL().glFinish(); // poor mans sync .. - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename.toString())); - } - } - protected void testWritePNGWithResizeImpl(boolean offscreenLayer) throws InterruptedException { if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { System.err.println("onscreen layer n/a"); @@ -127,7 +111,7 @@ public class TestGLReadBufferUtilTextureIOWrite02AWT extends UITestCase { if(snap) { System.err.println("XXX: ["+fw_old+", "+dw_old+"], "+fw+"x"+fh+", "+dw+"x"+dh+", sz_changed "+sz_changed+", snap "+snap); c=0; - snapshot(drawable, screenshot, i++); + snapshot(getSimpleTestName("."), i++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); dw_old = dw; fw_old = fw; Threading.invoke(true, new Runnable() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java index ed0791f7c..d1ffa84cf 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestGLReadBufferUtilTextureIOWrite02NEWT.java @@ -28,10 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.util.texture; -import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; - import com.jogamp.newt.opengl.GLWindow; import javax.media.opengl.GLAutoDrawable; @@ -41,6 +37,7 @@ import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -66,19 +63,6 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase { height = 64; } - protected void snapshot(GLAutoDrawable drawable, GLReadBufferUtil screenshot, int i) { - final StringWriter filename = new StringWriter(); - { - final PrintWriter pw = new PrintWriter(filename); - final String pfmt = drawable.getChosenGLCapabilities().getAlphaBits() > 0 ? "rgba" : "rgb_"; - pw.printf("%s-F_rgba-I_%s-%s-n%03d-%04dx%04d.png", - getSimpleTestName("."), pfmt, drawable.getGLProfile().getName(), i, drawable.getWidth(), drawable.getHeight()); - } - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename.toString())); - } - } - private void testWritePNGWithResizeImpl(boolean offscreen) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); final GLCapabilities caps2 = offscreen ? WindowUtilNEWT.fixCaps(caps, false, true, false) : caps; @@ -110,7 +94,7 @@ public class TestGLReadBufferUtilTextureIOWrite02NEWT extends UITestCase { if(snap) { System.err.println("XXX: ["+dw_old+"], "+dw+"x"+dh+", sz_changed "+sz_changed+", snap "+snap); c=0; - snapshot(drawable, screenshot, i++); + snapshot(getSimpleTestName("."), i++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); dw_old = dw; new Thread() { @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java index 068732696..0d4f2b01e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java @@ -52,7 +52,6 @@ import com.jogamp.opengl.util.GLReadBufferUtil; import java.awt.Dimension; import java.awt.Frame; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLConnection; @@ -96,16 +95,10 @@ public class TestPNGTextureFromFileAWT extends UITestCase { testTextureStream = null; } - protected void snapshot(GLAutoDrawable drawable, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename)); - } - } - public void testImpl(boolean useFFP, final InputStream istream, final boolean useAWTIIOP) throws InterruptedException, IOException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp; if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) { glp = GLProfile.getGL2GL3(); @@ -137,7 +130,7 @@ public class TestPNGTextureFromFileAWT extends UITestCase { // the bug submitter was doing it final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ; glc.addGLEventListener(gle); - glc.addGLEventListener(new GLEventListener() { + glc.addGLEventListener(new GLEventListener() { boolean shot = false; @Override public void init(GLAutoDrawable drawable) {} @@ -147,7 +140,7 @@ public class TestPNGTextureFromFileAWT extends UITestCase { // 1 snapshot if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { shot = true; - snapshot(drawable, getSimpleTestName(".")+".png"); + snapshot(getSimpleTestName("."), 0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java index d973dea2d..b4faafbe7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java @@ -48,7 +48,6 @@ import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URLConnection; @@ -80,14 +79,8 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { testTextureStream = null; } - protected void snapshot(GLAutoDrawable drawable, String filename) { - GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - if(screenshot.readPixels(drawable.getGL(), drawable, false)) { - screenshot.write(new File(filename)); - } - } - public void testImpl(boolean useFFP, final InputStream istream) throws InterruptedException, IOException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp; if(useFFP && GLProfile.isAvailable(GLProfile.GL2GL3)) { glp = GLProfile.getGL2GL3(); @@ -119,7 +112,7 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { // 1 snapshot if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { shot = true; - snapshot(drawable, getSimpleTestName(".")+".png"); + snapshot(getSimpleTestName("."), 0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java index 672675fab..c07d5b741 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java +++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java @@ -28,7 +28,17 @@ package com.jogamp.opengl.test.junit.util; +import java.io.File; +import java.io.PrintWriter; +import java.io.StringWriter; + +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawable; + import com.jogamp.common.util.locks.SingletonInstance; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; import org.junit.Assume; import org.junit.Before; @@ -108,6 +118,49 @@ public abstract class UITestCase { } static final String unsupportedTestMsg = "Test not supported on this platform."; - + + /** + * Takes a snapshot of the drawable's current framebuffer. Example filenames: + *
    +     * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0004-0800x0600.png
    +     * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0005-0800x0600.png
    +     * 
    + * + * @param simpleTestName will be used as the filename prefix + * @param sn sequential number + * @param postSNDetail optional detail to be added to the filename after sn + * @param gl the current GL context object. It's read drawable is being used as the pixel source and to gather some details which will end up in the filename. + * @param readBufferUtil the {@link GLReadBufferUtil} to be used to read the pixels for the screenshot. + * @param fileSuffix Optional file suffix without a dot defining the file type, i.e. "png". + * If null the "png" as defined in {@link TextureIO#PNG} is being used. + * @param destPath Optional platform dependent file path. It shall use {@link File#separatorChar} as is directory separator. + * It shall not end with a directory separator, {@link File#separatorChar}. + * If null the current working directory is being used. + */ + public static void snapshot(String simpleTestName, int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) { + if(null == fileSuffix) { + fileSuffix = TextureIO.PNG; + } + final StringWriter filenameSW = new StringWriter(); + { + final GLDrawable drawable = gl.getContext().getGLReadDrawable(); + final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); + final String F_pfmt = readBufferUtil.hasAlpha() ? "rgba" : "rgb_"; + final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; + final String aaext = caps.getSampleExtension(); + final int samples = caps.getNumSamples() ; + postSNDetail = null != postSNDetail ? "-"+postSNDetail : ""; + final PrintWriter pw = new PrintWriter(filenameSW); + pw.printf("%s-n%04d%s-F_%s-I_%s-S%d_%s-%s-%04dx%04d.%s", + simpleTestName, sn, postSNDetail, F_pfmt, pfmt, samples, aaext, drawable.getGLProfile().getName(), + drawable.getWidth(), drawable.getHeight(), fileSuffix); + } + final String filename = null != destPath ? destPath + File.separator + filenameSW.toString() : filenameSW.toString(); + System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename); + gl.glFinish(); // just make sure rendering finished .. + if(readBufferUtil.readPixels(gl, false)) { + readBufferUtil.write(new File(filename)); + } + } } -- cgit v1.2.3 From fb7d2d8a188fe5da159571cfabfd1d6a8879d1da Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Jul 2012 15:44:20 +0200 Subject: tests.sh minor edit --- make/scripts/tests.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 591f5f9d2..af99b8e72 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -53,7 +53,7 @@ function jrun() { swton=$1 shift - #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.DebugGL" + #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" @@ -61,16 +61,14 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" + #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" - #D_ARGS="-Djogl.debug.GLDrawable" - #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL" - #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.UseCurrentThreadLibLoader" #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" @@ -367,7 +365,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* # @@ -404,12 +402,15 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: -#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* # linux NV: cannot make ctx current .. +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $* # ?? # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* + $spath/count-edt-start.sh java-run.log -- cgit v1.2.3 From e58e7739379147af8c7b875f6e8a7cdb40e342bc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Jul 2012 22:05:32 +0200 Subject: Fix OSX OffscreenLayerSurface (OLS) regressions (pbuffer based) - Use pbuffer (still), don't set FBO (invisible) - OLS (only impl is JAWTWindow now) stores the attached layer handle created and attached by the GLContext implementation, so 'others' may detach it -> NewtCanvasAWT - NewtCanvasAWT.removeNotify() needs to ask the OLS to detach the layer since it's parent will be gone. - MacOSXCGLContext destroy allows a removed OLS (see above) --- make/scripts/tests.sh | 5 ++--- .../classes/jogamp/opengl/GLDrawableFactoryImpl.java | 5 +++-- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 13 +++++++------ .../com/jogamp/nativewindow/awt/JAWTWindow.java | 18 +++++++++++++++--- .../media/nativewindow/OffscreenLayerSurface.java | 9 +++++++-- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 10 ++++++++-- 6 files changed, 42 insertions(+), 18 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index af99b8e72..19297ae25 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -407,10 +407,9 @@ function testawtswt() { # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* $spath/count-edt-start.sh java-run.log diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 897d3fcaf..34bb8704a 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -143,9 +143,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // layered surface -> Offscreen/[FBO|PBuffer] final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); chosenCapsMod.setOnscreen(false); - if( isFBOAvailable ) { + /* if( isFBOAvailable ) { // FIXME JAU: FBO n/a yet chosenCapsMod.setFBO(true); - } else if(canCreateGLPbuffer(adevice)) { + } else */ + if( canCreateGLPbuffer(adevice) ) { chosenCapsMod.setPBuffer(true); } else { chosenCapsMod.setFBO(false); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index cb79e1560..82525cfde 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -444,9 +444,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl throw new RuntimeException("Anonymous drawable instance's handle not of type NSView: "+drawable.getClass().getName()+", "+drawable); } } - final NativeSurface surface = drawable.getNativeSurface(); + final NativeSurface surface = drawable.getNativeSurface(); final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); + boolean allowIncompleteView = null != backingLayerHost; if( !allowIncompleteView && surface instanceof ProxySurface ) { allowIncompleteView = 0 != ( ProxySurface.INVISIBLE_WINDOW & ((ProxySurface)surface).getImplBitfield() ) ; @@ -519,10 +520,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl texWidth = drawable.getWidth(); texHeight = drawable.getHeight(); } - nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight); if(0>=texWidth || 0>=texHeight || !drawable.isRealized()) { throw new GLException("Drawable not realized yet or invalid texture size, texSize "+texWidth+"x"+texHeight+", "+drawable); } + nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight); if (DEBUG) { System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", texSize "+texWidth+"x"+texHeight+", "+drawable); } @@ -545,11 +546,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer)); } final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true); - if(null == ols) { - throw new InternalError("XXX: "+ols); + if(null != ols && ols.isSurfaceLayerAttached()) { + // still having a valid OLS attached to surface (parent OLS could have been removed) + ols.detachSurfaceLayer(); } - CGL.releaseNSOpenGLLayer(nsOpenGLLayer); - ols.detachSurfaceLayer(nsOpenGLLayer); + CGL.releaseNSOpenGLLayer(nsOpenGLLayer); CGL.deletePixelFormat(nsOpenGLLayerPFmt); nsOpenGLLayerPFmt = 0; nsOpenGLLayer = 0; diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index cffe495f7..d4b927cf1 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -81,6 +81,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected long drawable; protected Rectangle bounds; protected Insets insets; + private long offscreenSurfaceLayer; private long drawable_old; @@ -106,6 +107,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, invalidate(); this.component = windowObject; this.isApplet = false; + this.offscreenSurfaceLayer = 0; } @Override @@ -196,6 +198,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle) + ", bounds "+bounds); } attachSurfaceLayerImpl(layerHandle); + offscreenSurfaceLayer = layerHandle; } finally { unlockSurface(); } @@ -206,25 +209,34 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, * {@inheritDoc} */ @Override - public final void detachSurfaceLayer(final long layerHandle) throws NativeWindowException { + public final void detachSurfaceLayer() throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { throw new java.lang.UnsupportedOperationException("Not an offscreen layer surface"); } + if( 0 == offscreenSurfaceLayer) { + throw new NativeWindowException("No offscreen layer attached: "+this); + } int lockRes = lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { throw new NativeWindowException("Could not lock (offscreen layer): "+this); } try { if(DEBUG) { - System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(layerHandle)); + System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(offscreenSurfaceLayer)); } - detachSurfaceLayerImpl(layerHandle); + detachSurfaceLayerImpl(offscreenSurfaceLayer); + offscreenSurfaceLayer = 0; } finally { unlockSurface(); } } protected abstract void detachSurfaceLayerImpl(final long layerHandle); + @Override + public final boolean isSurfaceLayerAttached() { + return 0 != offscreenSurfaceLayer; + } + // // SurfaceUpdateListener // diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index dd36509ba..f7dbc6c27 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -42,7 +42,12 @@ public interface OffscreenLayerSurface { * Detaches a previously attached offscreen layer from this offscreen layer surface. * @see #attachSurfaceLayer(long) * @see #isOffscreenLayerSurfaceEnabled() - * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + * or no surface layer is attached. */ - public void detachSurfaceLayer(final long layerHandle) throws NativeWindowException; + public void detachSurfaceLayer() throws NativeWindowException; + + /** Returns true if a surface layer is attached, otherwise false. */ + public boolean isSurfaceLayerAttached(); + } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 9af4a02ae..cd0e9aab6 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -42,7 +42,9 @@ import java.security.PrivilegedAction; import java.util.Set; import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerOption; +import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.WindowClosingProtocol; import javax.swing.MenuSelectionManager; @@ -368,6 +370,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont); } + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); + if(null != ols && ols.isSurfaceLayerAttached()) { + ols.detachSurfaceLayer(); + } reparentWindow(false, cont); super.removeNotify(); } @@ -413,7 +419,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // since this it is completely covered by the newtChild (z-order). setFocusable(true); } else { - configureNewtChild(false); + configureNewtChild(false); newtChild.setVisible(false); newtChild.reparentWindow(null); if(null != jawtWindow) { @@ -445,7 +451,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; } - newtChild.setVisible(false); + newtChild.setVisible(false); newtChild.reparentWindow(null); newtChild.destroy(); newtChild=null; -- cgit v1.2.3 From adc9522ccaff74eb779d4d33905d76d52acb36bb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Jul 2012 22:16:54 +0200 Subject: Fix TestSWTAccessor02GLn regression .. forgot to: canvas.addControlListener(swtUpstreamHook); --- make/scripts/tests.sh | 4 ++-- .../opengl/test/junit/jogl/swt/TestSWTAccessor02GLn.java | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 19297ae25..13e172770 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -402,14 +402,14 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $* # ?? +testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $* # ?? # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* $spath/count-edt-start.sh java-run.log diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02GLn.java index 6100ff377..c7053885e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02GLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02GLn.java @@ -140,23 +140,27 @@ public class TestSWTAccessor02GLn extends UITestCase { SWTAccessor.invoke(true, canvasCstr); final Canvas canvas = canvasCstr.canvas; - Assert.assertNotNull( canvas ); - + Assert.assertNotNull( canvas ); SWTAccessor.setRealized(canvas, true); + AbstractGraphicsDevice device = SWTAccessor.getDevice(canvas); long nativeWindowHandle = SWTAccessor.getWindowHandle(canvas); System.err.println("*** device: " + device); System.err.println("*** window handle: 0x" + Long.toHexString(nativeWindowHandle)); final SWTUpstreamHook swtUpstreamHook = new SWTUpstreamHook(canvas); + canvas.addControlListener(swtUpstreamHook); + final ProxySurface proxySurface = factory.createProxySurface(device, 0, nativeWindowHandle, caps, null, swtUpstreamHook); - Assert.assertNotNull( proxySurface ); + Assert.assertNotNull( proxySurface ); System.err.println("*** ProxySurface: " + proxySurface); + final GLDrawable drawable = factory.createGLDrawable(proxySurface); Assert.assertNotNull( drawable ); drawable.setRealized(true); System.err.println("*** Drawable: " + drawable); Assert.assertTrue( drawable.isRealized() ); + final GLContext glcontext = drawable.createContext(null); // trigger native creation .. if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { -- cgit v1.2.3 From 7bb5885fc3a904f49e22f0c8cbf747d9b189a7ba Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 25 Jul 2012 04:23:35 +0200 Subject: SWT Update: SWT GLCanvas creates lazy when resource is ready; Create new NewtCanvasSWT allowing to parent NEWT windows natively. SWT GLCanvas creates lazy when resource is ready - Ensures drawable and context are created when size > zero and native visualID is valid. The latter is platform dependent. - Note that you cannot utilize custom GLCapabilities w/ this one, since the configurations is already realized - use NewtCanvasSWT. Create new NewtCanvasSWT allowing to parent NEWT windows natively: - Similar to NewtCanvasAWT - Allows attaching / detaching NEWT windows NewtCanvasAWT: Public setNEWTChild(..) fixed Added test cases for the above - tested on Linux, OSX and Windows w/ SWT Note: As usual for OSX, add -XstartOnFirstThread Details: - NEWT Display has new method: 'EDTUtil setEDTUtil(EDTUtil)' allowing to set a custom event dispatch utility. We use this to set our SWTEDTUtil for using NEWT w/ SWT complying w/ SWT threading constraints. --- etc/profile.jogl | 5 + make/build-common.xml | 2 + make/build-newt.xml | 19 +- make/build-test.xml | 99 ++-- make/scripts/java-win64-dbg.bat | 4 +- make/scripts/tests-x64.bat | 25 +- make/scripts/tests.sh | 19 +- make/stub_includes/win32/wingdi.h | 2 + .../gluegen/opengl/BuildComposablePipeline.java | 2 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 199 +++++--- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 1 - .../com/jogamp/nativewindow/swt/SWTAccessor.java | 25 + .../media/nativewindow/NativeWindowFactory.java | 17 + .../jogamp/nativewindow/macosx/OSXUtil.java | 35 +- src/nativewindow/native/macosx/OSXmisc.m | 74 ++- src/newt/classes/com/jogamp/newt/Display.java | 17 + .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 74 ++- .../classes/com/jogamp/newt/opengl/GLWindow.java | 1 - .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 508 +++++++++++++++++++++ .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 99 ++++ src/newt/classes/jogamp/newt/DisplayImpl.java | 40 +- src/newt/classes/jogamp/newt/WindowImpl.java | 11 +- .../newt/awt/event/AWTParentWindowAdapter.java | 21 +- .../classes/jogamp/newt/driver/awt/AWTDisplay.java | 11 +- .../jogamp/newt/driver/macosx/MacWindow.java | 5 +- .../jogamp/newt/driver/windows/WindowsWindow.java | 11 +- src/newt/native/MacWindow.m | 56 ++- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 233 ++++++++++ .../test/junit/jogl/swt/TestSWTAccessor02GLn.java | 278 ----------- .../junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java | 55 ++- .../junit/newt/parenting/TestParenting01aSWT.java | 210 +++++++++ .../junit/newt/parenting/TestParenting04AWT.java | 239 ++++++++++ .../junit/newt/parenting/TestParenting04SWT.java | 264 +++++++++++ 33 files changed, 2158 insertions(+), 503 deletions(-) create mode 100644 src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java create mode 100644 src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor02GLn.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java (limited to 'make/scripts') diff --git a/etc/profile.jogl b/etc/profile.jogl index 4402adde6..7dd51919d 100755 --- a/etc/profile.jogl +++ b/etc/profile.jogl @@ -25,6 +25,9 @@ function concat_jogl_list() ARCH=`uname -m` KERNEL=`uname -s | awk ' { printf "%s",tolower($0) ; } '` +if [ "$KERNEL" = "sunos" ] ; then + KERNEL="solaris" +fi uname -a | grep -i LINUX && OSS=x11 uname -a | grep -i Darwin && OSS=osx @@ -99,6 +102,8 @@ export JOGL_CLASSPATH if [ "$KERNEL" = "linux" ] ; then SWT_SUB="gtk" +elif [ "$KERNEL" = "solaris" ] ; then + SWT_SUB="gtk" elif [ "$KERNEL" = "darwin" ] ; then SWT_SUB="cocoa" KERNEL="macosx" diff --git a/make/build-common.xml b/make/build-common.xml index 8d440a766..4de5de58b 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -362,6 +362,7 @@ + @@ -374,6 +375,7 @@ + diff --git a/make/build-newt.xml b/make/build-newt.xml index a6be5042e..776708857 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -107,6 +107,9 @@ + + @@ -135,11 +138,16 @@ + + + + - + @@ -707,6 +715,13 @@ + + + + + + - + diff --git a/make/build-test.xml b/make/build-test.xml index 51eadfebd..f295ae321 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -427,7 +427,7 @@ - - + - - @@ -491,40 +489,71 @@ - - - - - - - - - - - - - - - - + + + + - + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 109755d2e..c8a90454d 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -18,7 +18,7 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluege echo CP_ALL %CP_ALL% -set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" +REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" @@ -37,7 +37,7 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" -REM set D_ARGS="-Dnewt.debug.Window" +set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" REM set D_ARGS="-Djogl.debug.GLContext" "-Dnewt.debug=all" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 0b3711784..6d3e46af6 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -28,22 +28,29 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransf REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT -time 2000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* + +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT @@ -56,8 +63,6 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.Mo REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleAWT -time 10000 @@ -96,7 +101,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMe REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 13e172770..af6218968 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -61,7 +61,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" - #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" @@ -145,7 +145,8 @@ function jrun() { echo CLASSPATH $CLASSPATH X_ARGS="-Djava.awt.headless=false $X_ARGS" else - export CLASSPATH=$JOGAMP_ALL_NOAWT_CLASSPATH + export CLASSPATH=$JOGAMP_ALL_AWT_CLASSPATH + #export CLASSPATH=$JOGAMP_ALL_NOAWT_CLASSPATH #export CLASSPATH=$JOGAMP_MOBILE_CLASSPATH #export CLASSPATH=.:$GLUEGEN_JAR:$JOGL_BUILD_DIR/jar/atomic/jogl-core.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-gldesktop.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-os-x11.jar:$JOGL_BUILD_DIR/jar/atomic/jogl-util.jar:$JOGL_BUILD_DIR/jar/atomic/nativewindow-core.jar:$JOGL_BUILD_DIR/jar/atomic/nativewindow-os-x11.jar:$JOGL_BUILD_DIR/jar/atomic/newt-core.jar:$JOGL_BUILD_DIR/jar/atomic/newt-driver-x11.jar:$JOGL_BUILD_DIR/jar/atomic/newt-ogl.jar:$JOGL_BUILD_DIR/jar/jogl-test.jar:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS X_ARGS="-Djava.awt.headless=true $X_ARGS" @@ -298,13 +299,17 @@ function testawtswt() { # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # -# awtswt (testawtswt) +# awtswt (testawtswt) +# Per default (unit tests) all test are performed this way +# with OSX: -XstartOnFirstThread # +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # newt.awt (testawt) @@ -321,6 +326,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* +testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* @@ -402,7 +410,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: -testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor02GLn $* # ?? # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* diff --git a/make/stub_includes/win32/wingdi.h b/make/stub_includes/win32/wingdi.h index 2d3e33275..7a88582c2 100644 --- a/make/stub_includes/win32/wingdi.h +++ b/make/stub_includes/win32/wingdi.h @@ -44,6 +44,8 @@ WINUSERAPI BOOL WINAPI DestroyWindow(HWND hWnd); WINUSERAPI DWORD WINAPI GetObjectType(HGDIOBJ h); WINUSERAPI BOOL WINAPI IsWindowVisible(HWND hWnd); WINUSERAPI BOOL WINAPI IsWindow(HWND hWnd); +WINUSERAPI HWND WINAPI GetParent(HWND hWnd); +WINUSERAPI HWND WINAPI SetParent(HWND hWndChild,HWND hWndNewParent); WINUSERAPI HANDLE WINAPI GetCurrentProcess(void); WINUSERAPI BOOL WINAPI GetProcessAffinityMask(HANDLE hProcess,PDWORD_PTR lpProcessAffinityMask,PDWORD_PTR lpSystemAffinityMask); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 1d9cf3668..5334d45cf 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -410,7 +410,7 @@ public class BuildComposablePipeline { output.flush(); output.close(); - System.out.println("wrote to file: " + file); // JAU + System.out.println("wrote to file: " + file); } /** Get the name of the object through which API calls should be routed. */ diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 64ee1c1ad..8d237162c 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -45,6 +45,7 @@ import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import javax.media.opengl.Threading; +import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; @@ -70,8 +71,12 @@ import com.jogamp.opengl.JoglVersion; /** * Native SWT Canvas implementing GLAutoDrawable + * + *

    Note: To employ custom GLCapabilities, NewtCanvasSWT shall be used instead.

    + * */ public class GLCanvas extends Canvas implements GLAutoDrawable { + private static final boolean DEBUG = Debug.debug("GLCanvas"); /* * Flag for whether the SWT thread should be used for OpenGL calls when in single-threaded mode. This is controlled @@ -87,18 +92,20 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* GL Stuff */ private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); + + private final GLContext shareWith; + private final GLCapabilitiesImmutable capsRequested; + private final GLCapabilitiesChooser capsChooser; + private volatile GLDrawable drawable; // volatile: avoid locking for read-only access private GLContext context; /* Native window surface */ private AbstractGraphicsDevice device; - private final long nativeWindowHandle; - private final ProxySurface proxySurface; /* Construction parameters stored for GLAutoDrawable accessor methods */ private int additionalCtxCreationFlags = 0; - private final GLCapabilitiesImmutable glCapsRequested; /* Flag indicating whether an unprocessed reshape is pending. */ private volatile boolean sendReshape; // volatile: maybe written by WindowManager thread w/o locking @@ -218,6 +225,37 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { */ private volatile Rectangle clientArea; + /** + * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} + * on the SWT thread. + * + * @param parent + * Required (non-null) parent Composite. + * @param style + * Optional SWT style bit-field. The {@link SWT#NO_BACKGROUND} bit is set before passing this up to the + * Canvas constructor, so OpenGL handles the background. + * @param caps + * Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the + * graphics device determined by the parent Composite are used. Note that the GLCapabilities that are + * actually used may differ based on the capabilities of the graphics device. + * @param chooser + * Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the + * requested GLCapabilities, and the available capabilities of the graphics device. + * @param shareWith + * Optional GLContext to share state (textures, vbos, shaders, etc.) with. + * @return a new instance + */ + public static GLCanvas create(final Composite parent, final int style, final GLCapabilitiesImmutable caps, + final GLCapabilitiesChooser chooser, final GLContext shareWith) { + final GLCanvas[] res = new GLCanvas[] { null }; + parent.getDisplay().syncExec(new Runnable() { + public void run() { + res[0] = new GLCanvas( parent, style, caps, chooser, shareWith ); + } + }); + return res[0]; + } + /** * Creates a new SWT GLCanvas. * @@ -250,35 +288,26 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). * Note: SWT is owner of the native handle, hence no closing operation will be a NOP. */ device = SWTAccessor.getDevice(this); - /* Since we have no means of querying the screen index yet, assume 0. Good choice due to Xinerama alike settings anyways. */ - final int screenIdx = 0; - /* Native handle for the control, used to associate with GLContext */ - nativeWindowHandle = SWTAccessor.getWindowHandle(this); /* Select default GLCapabilities if none was provided, otherwise clone provided caps to ensure safety */ if(null == caps) { caps = new GLCapabilities(GLProfile.getDefault(device)); } - glCapsRequested = caps; - - final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile()); - - /* Create a NativeWindow proxy for the SWT canvas */ - proxySurface = glFactory.createProxySurface(device, screenIdx, nativeWindowHandle, caps, chooser, swtCanvasUpStreamHook); - - /* Associate a GL surface with the proxy */ - drawable = glFactory.createGLDrawable(proxySurface); - drawable.setRealized(true); - - context = drawable.createContext(shareWith); - + this.capsRequested = caps; + this.capsChooser = chooser; + this.shareWith = shareWith; + + // post create .. when ready + drawable = null; + context = null; + /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ addPaintListener(new PaintListener() { @Override public void paintControl(final PaintEvent arg0) { - if (!helper.isExternalAnimatorAnimating()) { - display(); + if ( !helper.isExternalAnimatorAnimating() ) { + display(); // checks: null != drawable } } }); @@ -291,39 +320,93 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }); } private final ProxySurface.UpstreamSurfaceHook swtCanvasUpStreamHook = new ProxySurface.UpstreamSurfaceHook() { - @Override - public final void create(ProxySurface s) { /* nop */ } - - @Override - public final void destroy(ProxySurface s) { /* nop */ } - - @Override - public final int getWidth(ProxySurface s) { - return clientArea.width; - } - - @Override - public final int getHeight(ProxySurface s) { - return clientArea.height; - } - - @Override - public String toString() { - return "SETUpstreamSurfaceHook[upstream: "+GLCanvas.this.toString()+"]"; - } - + @Override + public final void create(ProxySurface s) { /* nop */ } + + @Override + public final void destroy(ProxySurface s) { /* nop */ } + + @Override + public final int getWidth(ProxySurface s) { + return clientArea.width; + } + + @Override + public final int getHeight(ProxySurface s) { + return clientArea.height; + } + + @Override + public String toString() { + return "SWTCanvasUpstreamSurfaceHook[upstream: "+GLCanvas.this.toString()+", "+clientArea.width+"x"+clientArea.height+"]"; + } }; protected final void updateSizeCheck() { - clientArea = GLCanvas.this.getClientArea(); - if (clientArea != null && - proxySurface.getWidth() != clientArea.width && - proxySurface.getHeight() != clientArea.height) { + final Rectangle oClientArea = clientArea; + final Rectangle nClientArea = GLCanvas.this.getClientArea(); + if ( nClientArea != null && + ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) + ) { + clientArea = nClientArea; // write back new value sendReshape = true; // Mark for OpenGL reshape next time the control is painted } - sendReshape = false; + } + + @Override + public void display() { + if( null != drawable || validateDrawableAndContext() ) { + runInGLThread(makeCurrentAndDisplayOnEDTAction); + } } + + /** assumes drawable == null ! */ + protected final boolean validateDrawableAndContext() { + if( GLCanvas.this.isDisposed() ) { + return false; + } + final Rectangle nClientArea = clientArea; + if(0 == nClientArea.width * nClientArea.height) { + return false; + } + + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); + + /* Native handle for the control, used to associate with GLContext */ + final long nativeWindowHandle = SWTAccessor.getWindowHandle(this); + + /* Create a NativeWindow proxy for the SWT canvas */ + ProxySurface proxySurface = null; + try { + proxySurface = glFactory.createProxySurface(device, 0 /* screenIdx */, nativeWindowHandle, + capsRequested, capsChooser, swtCanvasUpStreamHook); + } catch (GLException gle) { + // not ready yet .. + if(DEBUG) { System.err.println(gle.getMessage()); } + } + + if(null != proxySurface) { + /* Associate a GL surface with the proxy */ + drawable = glFactory.createGLDrawable(proxySurface); + drawable.setRealized(true); + + context = drawable.createContext(shareWith); + } + } finally { + _lock.unlock(); + } + final boolean res = null != drawable; + if(DEBUG && res) { + System.err.println("SWT GLCanvas realized! "+this+", "+drawable); + Thread.dumpStack(); + } + return res; + } + @Override public final Object getUpstreamWidget() { return this; @@ -362,11 +445,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { dispose(); } - @Override - public void display() { - runInGLThread(makeCurrentAndDisplayOnEDTAction); - } - @Override public GLAnimatorControl getAnimator() { return helper.getAnimator(); @@ -379,7 +457,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLContext getContext() { - return context; + return null != drawable ? context : null; } @Override @@ -472,7 +550,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { - return (GLCapabilitiesImmutable)proxySurface.getGraphicsConfiguration().getChosenCapabilities(); + final GLDrawable _drawable = drawable; + return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getChosenGLCapabilities() : null; } /** @@ -481,7 +560,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * @return Non-null GLCapabilities. */ public GLCapabilitiesImmutable getRequestedGLCapabilities() { - return (GLCapabilitiesImmutable)proxySurface.getGraphicsConfiguration().getRequestedCapabilities(); + final GLDrawable _drawable = drawable; + return null != _drawable ? (GLCapabilitiesImmutable)_drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities() : null; } @Override @@ -492,7 +572,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLProfile getGLProfile() { - return glCapsRequested.getGLProfile(); + return capsRequested.getGLProfile(); } @Override @@ -523,10 +603,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { runInGLThread(makeCurrentAndSwapBuffersOnEDTAction); } - // FIXME: API of update() method ? @Override public void update() { - // FIXME: display(); ? + // don't paint background etc .. nop avoids flickering } @Override @@ -551,7 +630,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * @see Platform#AWT_AVAILABLE * @see Platform#getOSType() */ - private void runInGLThread(final Runnable action) { + private static void runInGLThread(final Runnable action) { if(Platform.OSType.MACOS == Platform.OS_TYPE) { SWTAccessor.invoke(true, action); } else { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index e730bc62e..bf6a0ee6e 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -338,7 +338,6 @@ public abstract class GLContextImpl extends GLContext { if (TRACE_SWITCH) { System.err.println(getThreadName() + ": GLContextImpl.destroy.X: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + ", isShared "+GLContextShareSet.isShared(this)+" - "+lock); - Thread.dumpStack(); // JAU } } } finally { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 0494bb408..ba07d97dc 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -34,16 +34,21 @@ import java.lang.reflect.Method; import org.eclipse.swt.graphics.GCData; import org.eclipse.swt.widgets.Control; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.VisualIDHolder; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.nativewindow.x11.X11Lib; public class SWTAccessor { static final Field swt_control_handle; @@ -213,6 +218,26 @@ public class SWTAccessor { } throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); } + public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) { + if( null != OS_gtk_class ) { + return new X11GraphicsScreen((X11GraphicsDevice)device, screen); + } + if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) || + NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { + return new DefaultGraphicsScreen(device, screen); + } + throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); + } + public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) { + if( null != OS_gtk_class ) { + return X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); + } + if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(false) || + NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { + return VisualIDHolder.VID_UNDEFINED; + } + throw new UnsupportedOperationException("n/a for this windowing system: "+NativeWindowFactory.getNativeWindowType(false)); + } public static long getWindowHandle(Control swtControl) { long handle = getHandle(swtControl); diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index b85ad47f2..6faa9890c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -561,4 +561,21 @@ public abstract class NativeWindowFactory { } return null; } + + /** + * Returns true if the given visualID is valid for further processing, i.e. OpenGL usage, + * otherwise return false. + *

    + * On certain platforms, i.e. X11, a valid visualID is required at window creation. + * Other platforms may determine it later on, e.g. OSX and Windows.

    + *

    + * If the visualID is {@link VisualIDHolder#VID_UNDEFINED} and the platform requires it + * at creation time (see above), it is not valid for further processing. + *

    + */ + public static boolean isNativeVisualIDValidForProcessing(int visualID) { + return NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(false) || + VisualIDHolder.VID_UNDEFINED != visualID ; + } + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 4767dff18..894084fce 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -28,6 +28,7 @@ package jogamp.nativewindow.macosx; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import jogamp.nativewindow.Debug; @@ -63,8 +64,37 @@ public class OSXUtil { return isNSView0(object); } - public static Point GetLocationOnScreen(long windowOrView, int src_x, int src_y) { - return (Point) GetLocationOnScreen0(windowOrView, src_x, src_y); + /** + * In case the windowOrView is top-level, + * you shall set topLevel to true where + * insets gets into account to compute the client position as follows: + *
    +      if(topLevel) {
    +          // top-level position -> client window position
    +          final Insets insets = GetInsets(windowOrView);
    +          los.setX(los.getX() + insets.getLeftWidth());
    +          los.setY(los.getY() + insets.getTopHeight());
    +      }
    +     * 
    + * @param windowOrView + * @param topLevel + * @param src_x + * @param src_y + * @return the client position + */ + public static Point GetLocationOnScreen(long windowOrView, boolean topLevel, int src_x, int src_y) { + final Point los = (Point) GetLocationOnScreen0(windowOrView, src_x, src_y); + if(topLevel) { + // top-level position -> client window position + final Insets insets = GetInsets(windowOrView); + los.setX(los.getX() + insets.getLeftWidth()); + los.setY(los.getY() + insets.getTopHeight()); + } + return los; + } + + public static Insets GetInsets(long windowOrView) { + return (Insets) GetInsets0(windowOrView); } public static long CreateNSWindow(int x, int y, int width, int height) { @@ -135,6 +165,7 @@ public class OSXUtil { private static native boolean initIDs0(); private static native boolean isNSView0(long object); private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y); + private static native Object GetInsets0(long windowOrView); private static native long CreateNSWindow0(int x, int y, int width, int height); private static native void DestroyNSWindow0(long nsWindow); private static native long GetNSView0(long nsWindow); diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 37fa4c88f..2c853a43d 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -52,12 +52,18 @@ static const char * const ClazzNameRunnable = "java/lang/Runnable"; static jmethodID runnableRunID = NULL; -static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; static const char * const ClazzAnyCstrName = ""; + +static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; static const char * const ClazzNamePointCstrSignature = "(II)V"; static jclass pointClz = NULL; static jmethodID pointCstr = NULL; +static const char * const ClazzNameInsets = "javax/media/nativewindow/util/Insets"; +static const char * const ClazzNameInsetsCstrSignature = "(IIII)V"; +static jclass insetsClz = NULL; +static jmethodID insetsCstr = NULL; + static int _initialized=0; JNIEXPORT jboolean JNICALL @@ -79,6 +85,21 @@ Java_jogamp_nativewindow_macosx_OSXUtil_initIDs0(JNIEnv *env, jclass _unused) { ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature); } + c = (*env)->FindClass(env, ClazzNameInsets); + if(NULL==c) { + NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNameInsets); + } + insetsClz = (jclass)(*env)->NewGlobalRef(env, c); + (*env)->DeleteLocalRef(env, c); + if(NULL==insetsClz) { + NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't use %s", ClazzNameInsets); + } + insetsCstr = (*env)->GetMethodID(env, insetsClz, ClazzAnyCstrName, ClazzNameInsetsCstrSignature); + if(NULL==insetsCstr) { + NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't fetch %s.%s %s", + ClazzNameInsets, ClazzAnyCstrName, ClazzNameInsetsCstrSignature); + } + c = (*env)->FindClass(env, ClazzNameRunnable); if(NULL==c) { NativewindowCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNameRunnable); @@ -154,6 +175,49 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetLocationOnS return res; } +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: getInsets0 + * Signature: (J)Ljavax/media/nativewindow/util/Insets; + */ +JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetInsets0 + (JNIEnv *env, jclass unused, jlong winOrView) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + NSObject *nsObj = (NSObject*) (intptr_t) winOrView; + NSWindow* win = NULL; + NSView* view = NULL; + jint il,ir,it,ib; + + if( [nsObj isKindOfClass:[NSWindow class]] ) { + win = (NSWindow*) nsObj; + view = [win contentView]; + } else if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) { + view = (NSView*) nsObj; + win = [view window]; + } else { + NativewindowCommon_throwNewRuntimeException(env, "neither win not view %p\n", nsObj); + } + + NSRect frameRect = [win frame]; + NSRect contentRect = [win contentRectForFrameRect: frameRect]; + + // note: this is a simplistic implementation which doesn't take + // into account DPI and scaling factor + CGFloat l = contentRect.origin.x - frameRect.origin.x; + il = (jint)l; // l + ir = (jint)(frameRect.size.width - (contentRect.size.width + l)); // r + it = (jint)(frameRect.size.height - contentRect.size.height); // t + ib = (jint)(contentRect.origin.y - frameRect.origin.y); // b + + jobject res = (*env)->NewObject(env, insetsClz, insetsCstr, il, ir, it, ib); + + [pool release]; + + return res; +} + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateNSWindow0 @@ -172,6 +236,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 defer: YES]; [myWindow setReleasedWhenClosed: YES]; // default [myWindow setPreservesContentDuringLiveResize: YES]; + // Remove animations +NS_DURING + // Available >= 10.7 - Removes default animations + [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; +NS_HANDLER +NS_ENDHANDLER // invisible .. [myWindow setOpaque: NO]; @@ -229,7 +299,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; CALayer* layer = [[CALayer alloc] init]; - DBG_PRINT("CALayer::CreateCALayer.0: %p %d/%d %dx%d (refcnt %d)\n", layer, x, y, width, height, (int)[layer retainCount]); + DBG_PRINT("CALayer::CreateCALayer.0: %p %d/%d %dx%d (refcnt %d)\n", layer, (int)x, (int)y, (int)width, (int)height, (int)[layer retainCount]); // avoid zero size if(0 == width) { width = 32; } if(0 == height) { height = 32; } diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 7b6849a30..1e9a0e9eb 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -141,6 +141,23 @@ public abstract class Display { */ public abstract String getType(); + /** + * Sets a new {@link EDTUtil} and returns the previous one. + *

    + * If newEDTUtil is null, + * the device's default EDTUtil is created and used. + *

    + *

    + * If a previous one exists and it differs from the new one, + * it's being stopped, wait-until-idle and reset to allow restart. + *

    + *

    + * If newEDTUtil is not null and equals the previous one, + * null is returned and no change is being made. + *

    + */ + public abstract EDTUtil setEDTUtil(EDTUtil newEDTUtil); + public abstract EDTUtil getEDTUtil(); public abstract boolean isEDTRunning(); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index cd0e9aab6..6f0028a77 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -263,17 +263,35 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final FocusPropertyChangeListener focusPropertyChangeListener = new FocusPropertyChangeListener(); private volatile KeyboardFocusManager keyboardFocusManager = null; - /** sets a new NEWT child, provoking reparenting. */ - private NewtCanvasAWT setNEWTChild(Window child) { - if(newtChild!=child) { - newtChild = child; - if(isDisplayable()) { - // reparent right away, addNotify has been called already - final java.awt.Container cont = AWTMisc.getContainer(this); - reparentWindow( (null!=child) ? true : false, cont ); - } + /** + * Sets a new NEWT child, provoking reparenting. + *

    + * A previously detached newChild will be released to top-level status + * and made invisible. + *

    + *

    + * Note: When switching NEWT child's, detaching the previous first via setNEWTChild(null) + * produced much cleaner visual results. + *

    + * @return the previous attached newt child. + */ + public Window setNEWTChild(Window newChild) { + final Window prevChild = newtChild; + if(DEBUG) { + System.err.println("NewtCanvasAWT.setNEWTChild.0: win "+newtWinHandleToHexString(prevChild)+" -> "+newtWinHandleToHexString(newChild)); + } + final java.awt.Container cont = AWTMisc.getContainer(this); + // remove old one + if(null != newtChild) { + reparentWindow( false, cont ); + newtChild = null; } - return this; + // add new one, reparent only if ready + newtChild = newChild; + if( isDisplayable() && null != newChild) { + reparentWindow( true, cont ); + } + return prevChild; } /** @return the current NEWT child */ @@ -306,13 +324,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto awtKeyAdapter.removeFrom(this); awtKeyAdapter = null; } - newtChild.setKeyboardFocusHandler(null); if(null != keyboardFocusManager) { keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); keyboardFocusManager = null; } if( null != newtChild ) { + newtChild.setKeyboardFocusHandler(null); if(attach) { if(null == jawtWindow.getGraphicsConfiguration()) { throw new InternalError("XXX"); @@ -360,7 +378,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // if ( isShowing() == true ) -> Container is already visible. System.err.println("NewtCanvasAWT.addNotify: "+newtChild+", "+this+", visible "+isVisible()+", showing "+isShowing()+ ", displayable "+isDisplayable()+" -> "+cont); - } + } reparentWindow(true, cont); } @@ -375,6 +393,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto ols.detachSurfaceLayer(); } reparentWindow(false, cont); + + if(null != jawtWindow) { + NewtFactoryAWT.destroyNativeWindow(jawtWindow); + jawtWindow=null; + } + super.removeNotify(); } @@ -382,14 +406,19 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(null==newtChild) { return; // nop } + if(DEBUG) { + System.err.println("NewtCanvasAWT.reparentWindow.0: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); + } newtChild.setFocusAction(null); // no AWT focus traversal .. if(add) { - jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); - jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); if(DEBUG) { System.err.println("NewtCanvasAWT.reparentWindow: newtChild: "+newtChild); } + if(null == jawtWindow) { + jawtWindow = NewtFactoryAWT.getNativeWindow(this, newtChild.getRequestedCapabilities()); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); + } final int w; final int h; if(isPreferredSizeSet()) { @@ -413,7 +442,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - newtChild.windowRepaint(0, 0, w, h); // force this AWT Canvas to be focus-able, // since this it is completely covered by the newtChild (z-order). @@ -422,10 +450,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto configureNewtChild(false); newtChild.setVisible(false); newtChild.reparentWindow(null); - if(null != jawtWindow) { - NewtFactoryAWT.destroyNativeWindow(jawtWindow); - jawtWindow=null; - } + } + if(DEBUG) { + System.err.println("NewtCanvasAWT.reparentWindow.X: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); } } @@ -451,7 +478,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto NewtFactoryAWT.destroyNativeWindow(jawtWindow); jawtWindow=null; } - newtChild.setVisible(false); + newtChild.setVisible(false); newtChild.reparentWindow(null); newtChild.destroy(); newtChild=null; @@ -569,5 +596,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } + + static String newtWinHandleToHexString(Window w) { + return null != w ? toHexString(w.getWindowHandle()) : "nil"; + } + static String toHexString(long l) { + return "0x"+Long.toHexString(l); + } } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 2205aec8e..d662a743a 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -480,7 +480,6 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } if(Window.DEBUG_IMPLEMENTATION) { System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", fin: dt "+ (System.nanoTime()-t0)/1e6 +"ms"); - Thread.dumpStack(); // JAU } } diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java new file mode 100644 index 000000000..f45b864fa --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -0,0 +1,508 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + + +package com.jogamp.newt.swt; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.SurfaceUpdatedListener; +import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.Point; + +import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.newt.Debug; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.newt.Display; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.util.EDTUtil; + +public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { + private static final boolean DEBUG = Debug.debug("Window"); + private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false); + + /** SWT EDTUtil associated w/ parent's SWT Display */ + private final EDTUtil swtEDTUtil; + + private final AbstractGraphicsScreen screen; + + private WindowClosingMode newtChildCloseOp = WindowClosingMode.DISPOSE_ON_CLOSE; + private volatile Rectangle clientArea; + + private volatile SWTNativeWindow nativeWindow; + private volatile Window newtChild = null; + + /** + * Creates an instance using {@link #NewtCanvasSWT(Composite, int, Window)} + * on the SWT thread. + * + *

    + * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation + * via {@link Display#setEDTUtil(EDTUtil)}. + *

    + * + * @param parent the SWT composite + * @param style additional styles to SWT#NO_BACKGROUND + * @param child optional preassigned {@link #Window}, maybe null + * @return a new instance + */ + public static NewtCanvasSWT create(final Composite parent, final int style, final Window child) { + final NewtCanvasSWT[] res = new NewtCanvasSWT[] { null }; + parent.getDisplay().syncExec( new Runnable() { + public void run() { + res[0] = new NewtCanvasSWT( parent, style, child); + } + }); + return res[0]; + } + + /** + * Instantiates a NewtCanvas with a NEWT child. + * + *

    + * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation + * via {@link Display#setEDTUtil(EDTUtil)}. + *

    + * + * @param parent the SWT composite + * @param style additional styles to SWT#NO_BACKGROUND + * @param child optional preassigned {@link #Window}, maybe null + */ + public NewtCanvasSWT(final Composite parent, final int style, Window child) { + super(parent, style | SWT.NO_BACKGROUND); + + swtEDTUtil = new SWTEDTUtil(parent.getDisplay()); + + SWTAccessor.setRealized(this, true); + + clientArea = getClientArea(); + + final AbstractGraphicsDevice device = SWTAccessor.getDevice(this); + screen = SWTAccessor.getScreen(device, 0); + nativeWindow = null; + + if(null != child) { + setNEWTChild(child); + } + + /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ + /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ + addPaintListener(new PaintListener() { + @Override + public void paintControl(final PaintEvent arg0) { + if( null != nativeWindow || validateNative() ) { + if( null !=newtChild ) { + newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); + } + } + } + }); + + addControlListener(new ControlAdapter() { + @Override + public void controlResized(final ControlEvent arg0) { + updateSizeCheck(); + } + }); + } + + /** assumes nativeWindow == null ! */ + protected final boolean validateNative() { + if( isDisposed() ) { + return false; + } + updateSizeCheck(); + final Rectangle nClientArea = clientArea; + if(0 == nClientArea.width * nClientArea.height) { + return false; + } + + /* Native handle for the control, used to associate with GLContext */ + final long nativeWindowHandle = SWTAccessor.getWindowHandle(this); + final int visualID = SWTAccessor.getNativeVisualID(screen.getDevice(), nativeWindowHandle); + final boolean visualIDValid = NativeWindowFactory.isNativeVisualIDValidForProcessing(visualID); + if(DEBUG) { + System.err.println("NewtCanvasSWT.validateNative() windowHandle 0x"+Long.toHexString(nativeWindowHandle)+", visualID 0x"+Integer.toHexString(visualID)+", valid "+visualIDValid); + } + if( visualIDValid ) { + /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). + * Note: SWT is owner of the native handle, hence no closing operation will be a NOP. */ + final CapabilitiesImmutable caps = new Capabilities(); + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(screen.getDevice(), caps); + final AbstractGraphicsConfiguration config = factory.chooseGraphicsConfiguration( caps, caps, null, screen, visualID ); + if(DEBUG) { + System.err.println("NewtCanvasSWT.validateNative() factory: "+factory+", windowHandle 0x"+Long.toHexString(nativeWindowHandle)+", visualID 0x"+Integer.toHexString(visualID)+", chosen config: "+config); + // Thread.dumpStack(); + } + if (null == config) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + + nativeWindow = new SWTNativeWindow(config, nativeWindowHandle); + reparentWindow( true ); + } + + return null != nativeWindow; + } + + protected final void updateSizeCheck() { + final Rectangle oClientArea = clientArea; + final Rectangle nClientArea = getClientArea(); + if ( nClientArea != null && + ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) + ) { + clientArea = nClientArea; // write back new value + if( null != newtChild ) { + newtChild.setSize(clientArea.width, clientArea.height); + } + } + } + + @Override + public void update() { + // don't paint background etc .. nop avoids flickering + } + + /** + * Destroys this resource: + *
      + *
    • Make the NEWT Child invisible
    • + *
    • Disconnects the NEWT Child from this Canvas NativeWindow, reparent to NULL
    • + *
    • Issues destroy() on the NEWT Child
    • + *
    • Remove reference to the NEWT Child
    • + *
    + * @see Window#destroy() + */ + @Override + public void dispose() { + if( null != newtChild ) { + if(DEBUG) { + System.err.println("NewtCanvasSWT.dispose.0: EDTUtil cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ + ",\n\t"+newtChild); + } + configureNewtChild(false); + newtChild.setVisible(false); + newtChild.reparentWindow(null); + newtChild.destroy(); + newtChild = null; + } + nativeWindow = null; + super.dispose(); + } + + /** @return this SWT Canvas NativeWindow representation, may be null in case it has not been realized. */ + public NativeWindow getNativeWindow() { return nativeWindow; } + + public WindowClosingMode getDefaultCloseOperation() { + return newtChildCloseOp; // FIXME + } + + public WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { + return newtChildCloseOp = op; // FIXME + } + + + boolean isParent() { + return null!=newtChild ; + } + + boolean isFullscreen() { + return null != newtChild && newtChild.isFullscreen(); + } + + /** + * Sets a new NEWT child, provoking reparenting. + *

    + * A previously detached newChild will be released to top-level status + * and made invisible. + *

    + *

    + * Note: When switching NEWT child's, detaching the previous first via setNEWTChild(null) + * produced much cleaner visual results. + *

    + *

    + * Note: The NEWT child {@link Display}'s {@link EDTUtil} is being set to an SWT conform implementation + * via {@link Display#setEDTUtil(EDTUtil)}. + *

    + * @return the previous attached newt child. + */ + public Window setNEWTChild(final Window newChild) { + final Window prevChild = newtChild; + if(DEBUG) { + System.err.println("NewtCanvasSWT.setNEWTChild.0: win "+newtWinHandleToHexString(prevChild)+" -> "+newtWinHandleToHexString(newChild)); + } + // remove old one + if(null != newtChild) { + reparentWindow( false ); + newtChild = null; + } + // add new one, reparent only if ready + newtChild = newChild; + if(null != nativeWindow && null != newChild) { + reparentWindow( true ); + } + return prevChild; + } + + /** @return the current NEWT child */ + public Window getNEWTChild() { + return newtChild; + } + + @Override + public boolean setParent(Composite parent) { + return super.setParent(parent); + } + + /* package */ void configureNewtChild(boolean attach) { + + if( null != newtChild ) { + newtChild.setKeyboardFocusHandler(null); + if(attach) { + newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); + } else { + newtChild.setFocusAction(null); + newtChild.setDefaultCloseOperation(newtChildCloseOp); + } + } + } + + void reparentWindow(boolean add) { + if( null == newtChild ) { + return; // nop + } + if(DEBUG) { + System.err.println("NewtCanvasSWT.reparentWindow.0: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); + } + + newtChild.setFocusAction(null); // no AWT focus traversal .. + if(add) { + updateSizeCheck(); + final int w = clientArea.width; + final int h = clientArea.height; + + newtChild.getScreen().getDisplay().setEDTUtil(swtEDTUtil); + + newtChild.setSize(w, h); + newtChild.reparentWindow(nativeWindow); + newtChild.setVisible(true); + configureNewtChild(true); + newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener + + // force this SWT Canvas to be focus-able, + // since this it is completely covered by the newtChild (z-order). + setEnabled(true); + } else { + configureNewtChild(false); + newtChild.setVisible(false); + newtChild.reparentWindow(null); + } + if(DEBUG) { + System.err.println("NewtCanvasSWT.reparentWindow.X: add="+add+", win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()); + } + } + + private final void requestFocusNEWTChild() { + if( null != newtChild ) { + newtChild.setFocusAction(null); + newtChild.requestFocus(); + } + } + + @Override + public boolean forceFocus() { + final boolean res = NewtCanvasSWT.super.forceFocus(); + requestFocusNEWTChild(); + return res; + } + + private class SWTNativeWindow implements NativeWindow { + private final AbstractGraphicsConfiguration config; + private final long nativeWindowHandle; + private final InsetsImmutable insets; // only required to allow proper client position calculation on OSX + + public SWTNativeWindow(AbstractGraphicsConfiguration config, long nativeWindowHandle) { + this.config = config; + this.nativeWindowHandle = nativeWindowHandle; + if(isOSX) { + this.insets = OSXUtil.GetInsets(nativeWindowHandle); + } else { + this.insets = new Insets(0, 0, 0, 0); + } + } + + @Override + public int lockSurface() throws NativeWindowException, RuntimeException { + return NativeSurface.LOCK_SUCCESS; + } + + @Override + public void unlockSurface() { } + + @Override + public boolean isSurfaceLockedByOtherThread() { + return false; + } + + @Override + public Thread getSurfaceLockOwner() { + return null; + } + + @Override + public boolean surfaceSwap() { + return false; + } + + @Override + public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { } + + @Override + public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { + } + + @Override + public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { } + + @Override + public long getSurfaceHandle() { + return 0; + } + + @Override + public int getWidth() { + return clientArea.width; + } + + @Override + public int getHeight() { + return clientArea.height; + } + + @Override + public AbstractGraphicsConfiguration getGraphicsConfiguration() { + return config; + } + + @Override + public long getDisplayHandle() { + return config.getScreen().getDevice().getHandle(); + } + + @Override + public int getScreenIndex() { + return config.getScreen().getIndex(); + } + + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { } + + @Override + public void destroy() { } + + @Override + public NativeWindow getParent() { + return null; + } + + @Override + public long getWindowHandle() { + return nativeWindowHandle; + } + + @Override + public InsetsImmutable getInsets() { + return insets; + } + + @Override + public int getX() { + return 0; + } + + @Override + public int getY() { + return 0; + } + + @Override + public Point getLocationOnScreen(Point point) { + if( isOSX ) { + final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); + // top-level position -> client window position + los.setX(los.getX() + insets.getLeftWidth()); + los.setY(los.getY() + insets.getTopHeight()); + if(null!=point) { + return point.translate(los); + } else { + return los; + } + } else { + // client position on 'normal' windowing systems is 0/0 + if(null == point) { + point = new Point(0, 0); + } + return point; + } + } + + @Override + public boolean hasFocus() { + return isFocusControl(); + } + }; + + static String newtWinHandleToHexString(Window w) { + return null != w ? toHexString(w.getWindowHandle()) : "nil"; + } + static String toHexString(long l) { + return "0x"+Long.toHexString(l); + } +} + diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java new file mode 100644 index 000000000..3538caad2 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -0,0 +1,99 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.swt; + +import org.eclipse.swt.widgets.Display; + +import com.jogamp.newt.util.EDTUtil; + +/** + * Simple {@link EDTUtil} implementation utilizing the SWT UI thread + * of the given {@link Display}. + */ +public class SWTEDTUtil implements EDTUtil { + private final Display swtDisplay; + + public SWTEDTUtil(Display swtDisplay) { + this.swtDisplay = swtDisplay; + } + + public final Display getDisplay() { + return swtDisplay; + } + + @Override + public long getPollPeriod() { + return 0; + } + + @Override + public void setPollPeriod(long ms) { + } + + @Override + public void reset() { + } + + @Override + public void start() { + } + + @Override + public boolean isCurrentThreadEDT() { + return swtDisplay.getThread() == Thread.currentThread(); + } + + @Override + public boolean isRunning() { + return true; + } + + @Override + public void invokeStop(Runnable finalTask) { + swtDisplay.syncExec(finalTask); + } + + @Override + public void invoke(boolean wait, Runnable task) { + if(wait) { + swtDisplay.syncExec(task); + } else { + swtDisplay.asyncExec(task); + } + } + + @Override + public void waitUntilIdle() { + // all sync .. + } + + @Override + public void waitUntilStopped() { + // all sync .. + } +} diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index b10561c5b..b178bb5d3 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -101,7 +101,9 @@ public abstract class DisplayImpl extends Display { display.hashCode = display.fqname.hashCode(); displayList.add(display); } - display.createEDTUtil(); + if(null == display.edtUtil) { + display.setEDTUtil(null); // device's default if EDT is used, or null + } if(DEBUG) { System.err.println("Display.create() NEW: "+display+" "+getThreadName()); } @@ -168,15 +170,45 @@ public abstract class DisplayImpl extends Display { return true; } - protected void createEDTUtil() { + protected EDTUtil createEDTUtil() { + final EDTUtil def; if(NewtFactory.useEDT()) { - edtUtil = new DefaultEDTUtil(Thread.currentThread().getThreadGroup(), "Display-"+getFQName(), dispatchMessagesRunnable); + def = new DefaultEDTUtil(Thread.currentThread().getThreadGroup(), "Display-"+getFQName(), dispatchMessagesRunnable); if(DEBUG) { - System.err.println("Display.createNative("+getFQName()+") Create EDTUtil: "+edtUtil.getClass().getName()); + System.err.println("Display.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); } + } else { + def = null; } + return def; } + @Override + public EDTUtil setEDTUtil(EDTUtil newEDTUtil) { + if(null == newEDTUtil) { + newEDTUtil = createEDTUtil(); + } + if( newEDTUtil == edtUtil ) { + if(DEBUG) { + System.err.println("Display.setEDTUtil: "+newEDTUtil+" - keep!"); + } + return null; // no change + } + final EDTUtil oldEDTUtil = edtUtil; + if(DEBUG) { + System.err.println("Display.setEDTUtil: "+oldEDTUtil+" -> "+newEDTUtil); + } + if(null != oldEDTUtil) { + stopEDT( new Runnable() { public void run() {} } ); + // ready for restart .. + oldEDTUtil.waitUntilStopped(); + oldEDTUtil.reset(); + } + edtUtil = newEDTUtil; + return oldEDTUtil; + } + + @Override public final EDTUtil getEDTUtil() { return edtUtil; } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index b12e42680..606101ade 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -445,9 +445,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected abstract void closeNativeImpl(); /** - * The native implementation must invoke {@link #focusChanged(boolean, boolean)} - * to change the focus state, if force == false. - * This may happen asynchronous within {@link #TIMEOUT_NATIVEWINDOW}. + * Async request which shall be performed within {@link #TIMEOUT_NATIVEWINDOW}. + *

    + * If if force == false the native implementation + * may only request focus if not yet owner.

    + *

    + * {@link #focusChanged(boolean, boolean)} should be called + * to notify about the focus traversal. + *

    * * @param force if true, bypass {@link #focusChanged(boolean, boolean)} and force focus request */ diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index ce8ed7c49..747e2368e 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -34,6 +34,7 @@ import javax.media.nativewindow.NativeWindow; import jogamp.newt.driver.DriverUpdatePosition; +import com.jogamp.newt.Window; import com.jogamp.newt.event.awt.AWTAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; @@ -92,19 +93,20 @@ public class AWTParentWindowAdapter if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentResized: "+comp); } - getNewtWindow().runOnEDTIfAvail(false, new Runnable() { + final Window newtWindow = getNewtWindow(); + newtWindow.runOnEDTIfAvail(false, new Runnable() { public void run() { int cw = comp.getWidth(); int ch = comp.getHeight(); if( 0 < cw * ch ) { - if( getNewtWindow().getWidth() != cw || getNewtWindow().getHeight() != ch ) { - getNewtWindow().setSize(cw, ch); - if(comp.isVisible() != getNewtWindow().isVisible()) { - getNewtWindow().setVisible(comp.isVisible()); + if( newtWindow.getWidth() != cw || newtWindow.getHeight() != ch ) { + newtWindow.setSize(cw, ch); + if(comp.isVisible() != newtWindow.isVisible()) { + newtWindow.setVisible(comp.isVisible()); } } - } else if(getNewtWindow().isVisible()) { - getNewtWindow().setVisible(false); + } else if(newtWindow.isVisible()) { + newtWindow.setVisible(false); } }}); } @@ -113,8 +115,9 @@ public class AWTParentWindowAdapter if(DEBUG_IMPLEMENTATION) { System.err.println("AWT: componentMoved: "+e); } - if(getNewtWindow().getDelegatedWindow() instanceof DriverUpdatePosition) { - ((DriverUpdatePosition)getNewtWindow().getDelegatedWindow()).updatePosition(); + final Window newtWindow = getNewtWindow(); + if(newtWindow.getDelegatedWindow() instanceof DriverUpdatePosition) { + ((DriverUpdatePosition)newtWindow.getDelegatedWindow()).updatePosition(); } } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java index 166da5c1c..65f8b4715 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java @@ -36,6 +36,7 @@ package jogamp.newt.driver.awt; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.util.EDTUtil; import jogamp.newt.DisplayImpl; @@ -54,13 +55,17 @@ public class AWTDisplay extends DisplayImpl { protected void closeNativeImpl() { } @Override - protected void createEDTUtil() { + protected EDTUtil createEDTUtil() { + final EDTUtil def; if(NewtFactory.useEDT()) { - edtUtil = AWTEDTUtil.getSingleton(); + def = AWTEDTUtil.getSingleton(); if(DEBUG) { - System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+edtUtil.getClass().getName()); + System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); } + } else { + def = null; } + return def; } protected void dispatchMessagesNative() { /* nop */ } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java index 720d4ee4c..27d7a1679 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java @@ -150,7 +150,7 @@ public class MacWindow extends WindowImpl implements MutableSurface, DriverClear System.err.println("MacWindow: clearFocus() - requestFocusParent, isOffscreenInstance "+isOffscreenInstance); } if(!isOffscreenInstance) { - requestFocusParent0(getWindowHandle()); + resignFocus0(getWindowHandle()); } else { focusChanged(false, false); } @@ -360,7 +360,6 @@ public class MacWindow extends WindowImpl implements MutableSurface, DriverClear if(recreate && 0==surfaceHandle) { throw new NativeWindowException("Internal Error - recreate, window but no view"); } - orderOut0(getWindowHandle()); close0(getWindowHandle()); setWindowHandle(0); } else { @@ -397,7 +396,7 @@ public class MacWindow extends WindowImpl implements MutableSurface, DriverClear private native boolean lockSurface0(long window); private native void unlockSurface0(long window); private native void requestFocus0(long window, boolean force); - private native void requestFocusParent0(long window); + private native void resignFocus0(long window); /** in case of a child window, it actually only issues orderBack(..) */ private native void orderOut0(long window); private native void orderFront0(long window); diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java index 34d76a148..6a8c81f3d 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java @@ -151,8 +151,8 @@ public class WindowsWindow extends WindowImpl { } protected void closeNativeImpl() { - if (hdc != 0) { - if(windowHandleClose != 0) { + if(windowHandleClose != 0) { + if (hdc != 0) { try { GDI.ReleaseDC(windowHandleClose, hdc); } catch (Throwable t) { @@ -162,11 +162,8 @@ public class WindowsWindow extends WindowImpl { } } } - hdc = 0; - hdc_old = 0; - } - if(windowHandleClose != 0) { try { + GDI.SetParent(windowHandleClose, 0); // detach first, experience hang w/ SWT parent GDI.DestroyWindow(windowHandleClose); } catch (Throwable t) { if(DEBUG_IMPLEMENTATION) { @@ -177,6 +174,8 @@ public class WindowsWindow extends WindowImpl { windowHandleClose = 0; } } + hdc = 0; + hdc_old = 0; } protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 01cbd80ec..bbadc9dd0 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -599,6 +599,15 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0 } DBG_PRINT( "createWindow0 - is visible.1: %d\n", [myWindow isVisible]); + // Remove animations for child windows + if(NULL != parentWindow) { +NS_DURING + // Available >= 10.7 - Removes default animations + [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; +NS_HANDLER +NS_ENDHANDLER + } + #ifdef VERBOSE_ON int dbgIdx = 1; #endif @@ -734,7 +743,7 @@ NS_ENDHANDLER if(NULL!=pWin) { [mWin detachFromParent: pWin]; } - [mWin orderOut: mWin]; + [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; DBG_PRINT( "windowClose.1 - %p,%d view %p,%d, parent %p\n", mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin); @@ -742,11 +751,6 @@ NS_ENDHANDLER // Only release window, if release is not yet in process. // E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked. if(!destroyNotifySent) { - // '[mWin close]' causes a crash at exit. - // This probably happens b/c it sends events to the main loop - // but our resources are gone ?! - // However, issuing a simple release seems to work quite well. - // [mWin release]; [mWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO]; } @@ -806,11 +810,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocus0 DBG_PRINT( "requestFocus - window: %p, force %d, hasFocus %d (START)\n", mWin, force, hasFocus); [mWin makeFirstResponder: nil]; - [mWin performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:YES]; - [mWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [mWin orderFrontRegardless]; - // [mWin makeKeyWindow]; + [mWin performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:NO]; + [mWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:NO]; DBG_PRINT( "requestFocus - window: %p, force %d (END)\n", mWin, force); @@ -819,26 +820,27 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocus0 /* * Class: jogamp_newt_driver_macosx_MacWindow - * Method: requestFocusParent0 + * Method: resignFocus0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocusParent0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_resignFocus0 (JNIEnv *env, jobject window, jlong w) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* mWin = (NSWindow*) ((intptr_t) w); NSWindow* pWin = [mWin parentWindow]; -#ifdef VERBOSE_ON BOOL hasFocus = [mWin isKeyWindow]; -#endif - DBG_PRINT( "requestFocusParent0 - window: %p, parent: %p, hasFocus %d (START)\n", mWin, pWin, hasFocus ); - if(NULL != pWin) { - [pWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [pWin makeKeyWindow]; + DBG_PRINT( "requestFocusParent0 - window: %p, parent %p, hasFocus %d (START)\n", mWin, pWin, hasFocus ); + if( hasFocus ) { + if(NULL != pWin) { + // [mWin performSelectorOnMainThread:@selector(makeFirstResponder:) withObject:pWin waitUntilDone:NO]; + [pWin performSelectorOnMainThread:@selector(makeKeyWindow) withObject:nil waitUntilDone:NO]; + } else { + [mWin performSelectorOnMainThread:@selector(resignKeyWindow) withObject:nil waitUntilDone:NO]; + } } - DBG_PRINT( "requestFocusParent0 - window: %p, parent: %p (END)\n", mWin, pWin); + DBG_PRINT( "requestFocusParent0 - window: %p (END)\n", mWin); [pool release]; } @@ -856,9 +858,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderFront0 DBG_PRINT( "orderFront0 - window: %p (START)\n", win); - [win performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [win orderFrontRegardless]; + [win performSelectorOnMainThread:@selector(orderFrontRegardless) withObject:nil waitUntilDone:NO]; DBG_PRINT( "orderFront0 - window: %p (END)\n", win); @@ -880,13 +880,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0 DBG_PRINT( "orderOut0 - window: (parent %p) %p (START)\n", pWin, mWin); if(NULL == pWin) { - [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [mWin orderOut: mWin]; + [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; } else { - [mWin performSelectorOnMainThread:@selector(orderBack:) withObject:mWin waitUntilDone:YES]; - // This will occasionally cause a free of non allocated object crash: - // [mWin orderBack: mWin]; + [mWin performSelectorOnMainThread:@selector(orderBack:) withObject:mWin waitUntilDone:NO]; } DBG_PRINT( "orderOut0 - window: (parent %p) %p (END)\n", pWin, mWin); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java new file mode 100644 index 000000000..6a27e6f27 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java @@ -0,0 +1,233 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.swt; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.After; +import org.junit.Test; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.swt.NewtCanvasSWT; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; + +/** + * Tests that a basic SWT app can open without crashing under different GL profiles + * _and_ custom GLCapabilities. + *

    + * Uses JOGL's NewtCanvasSWT, which allows to be a native container of a NEWT Window.
    + * This method allows utilizing custom GLCapability settings, + * independent from the already instantiated SWT visual. + *

    + *

    + * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ + * SWT running on Mac OSX, i.e. to enforce UI action on the main thread. + *

    + */ +public class TestNewtCanvasSWTGLn extends UITestCase { + + static int duration = 250; + + static final int iwidth = 640; + static final int iheight = 480; + + Display display = null; + Shell shell = null; + Composite composite = null; + + @BeforeClass + public static void startup() { + System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); + } + + @Before + public void init() { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite = new Composite( shell, SWT.NONE ); + composite.setLayout( new FillLayout() ); + Assert.assertNotNull( composite ); + }}); + } + + @After + public void release() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite ); + try { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + composite.dispose(); + shell.dispose(); + display.dispose(); + }}); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + display = null; + shell = null; + composite = null; + } + + protected void runTestAGL( GLCapabilitiesImmutable caps, GLEventListener demo, + boolean postAttach, boolean useAnimator ) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + + final GLWindow glWindow1 = GLWindow.create(caps); + Assert.assertNotNull(glWindow1); + Assert.assertEquals(false, glWindow1.isVisible()); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertNull(glWindow1.getParent()); + glWindow1.addGLEventListener(demo); + glWindow1.addGLEventListener(new GLEventListener() { + int displayCount = 0; + public void init(final GLAutoDrawable drawable) { } + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } + public void display(final GLAutoDrawable drawable) { + if(displayCount < 3) { + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); + } + } + public void dispose(final GLAutoDrawable drawable) { } + }); + + final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( composite, 0, postAttach ? null : glWindow1 ); + Assert.assertNotNull( canvas1 ); + + SWTAccessor.invoke(true, new Runnable() { + public void run() { + shell.setText( getSimpleTestName(".") ); + shell.setSize( 640, 480 ); + shell.open(); + } + }); + + if(postAttach) { + canvas1.setNEWTChild(glWindow1); + } + + // canvas1.update(); + + Animator anim; + if(useAnimator) { + anim = new Animator(glWindow1); + anim.start(); + } else { + anim = null; + } + + long lStartTime = System.currentTimeMillis(); + long lEndTime = lStartTime + duration; + try { + while( (System.currentTimeMillis() < lEndTime) && !canvas1.isDisposed() ) { + if( !display.readAndDispatch() ) { + // blocks on linux .. display.sleep(); + Thread.sleep(10); + } + } + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + if(null != anim) { + anim.stop(); + } + + canvas1.dispose(); + } + + @Test + public void preAttach_WithAnimator() throws InterruptedException { + runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2(), false /* postAttach */, true /* animator */); + } + + @Test + public void preAttach_NoAnimator() throws InterruptedException { + runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2(), false /* postAttach */, false /* animator */); + } + + @Test + public void postAttach_WithAnimator() throws InterruptedException { + runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2(), true /* postAttach */, true /* animator */); + } + + @Test + public void test_MultisampleAndAlpha() throws InterruptedException { + GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); + caps.setSampleBuffers(true); + caps.setNumSamples(2); + runTestAGL( caps, new MultisampleDemoES2(true), false /* postAttach */, false /* animator */); + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) { + for(int i=0; i - * Uses JOGL's SWTAccessor only. - *

    - * @author Wade Walker, et.al. - */ -public class TestSWTAccessor02GLn extends UITestCase { - - static int duration = 250; - - static final int iwidth = 640; - static final int iheight = 480; - - Display display = null; - Shell shell = null; - Composite composite = null; - - @BeforeClass - public static void startup() { - System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); - } - - @Before - public void init() { - SWTAccessor.invoke(true, new Runnable() { - public void run() { - display = new Display(); - Assert.assertNotNull( display ); - shell = new Shell( display ); - Assert.assertNotNull( shell ); - shell.setLayout( new FillLayout() ); - composite = new Composite( shell, SWT.NONE ); - composite.setLayout( new FillLayout() ); - Assert.assertNotNull( composite ); - }}); - } - - @After - public void release() { - Assert.assertNotNull( display ); - Assert.assertNotNull( shell ); - Assert.assertNotNull( composite ); - try { - SWTAccessor.invoke(true, new Runnable() { - public void run() { - composite.dispose(); - shell.dispose(); - display.dispose(); - }}); - } - catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - display = null; - shell = null; - composite = null; - } - - protected void runTestAGL( GLProfile glprofile ) throws InterruptedException { - GLCapabilities caps = new GLCapabilities(glprofile); - GLDrawableFactory factory = GLDrawableFactory.getFactory(glprofile); - - // need SWT.NO_BACKGROUND to prevent SWT from clearing the window - // at the wrong times (we use glClear for this instead) - final Canvas canvas = new Canvas( composite, SWT.NO_BACKGROUND); - Assert.assertNotNull( canvas ); - SWTAccessor.setRealized(canvas, true); - - AbstractGraphicsDevice device = SWTAccessor.getDevice(canvas); - long nativeWindowHandle = SWTAccessor.getWindowHandle(canvas); - System.err.println("*** device: " + device); - System.err.println("*** window handle: 0x" + Long.toHexString(nativeWindowHandle)); - - final SWTUpstreamHook swtUpstreamHook = new SWTUpstreamHook(canvas); - canvas.addControlListener(swtUpstreamHook); - - final ProxySurface proxySurface = factory.createProxySurface(device, 0, nativeWindowHandle, caps, null, swtUpstreamHook); - Assert.assertNotNull( proxySurface ); - System.err.println("*** ProxySurface: " + proxySurface); - - final GLDrawable drawable = factory.createGLDrawable(proxySurface); - Assert.assertNotNull( drawable ); - drawable.setRealized(true); - System.err.println("*** Drawable: " + drawable); - Assert.assertTrue( drawable.isRealized() ); - - final GLContext glcontext = drawable.createContext(null); - // trigger native creation .. - if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { - glcontext.release(); - } - - final boolean[] sizeMissing = new boolean[] { false }; - - // fix the viewport when the user resizes the window - canvas.addListener( SWT.Resize, new Listener() { - public void handleEvent( Event event ) { - Rectangle rectangle = canvas.getClientArea(); - boolean glok=false; - if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { - glok=true; - GL2ES1 gl = glcontext.getGL().getGL2ES1(); - OneTriangle.setup( gl, rectangle.width, rectangle.height ); - glcontext.release(); - } else { - sizeMissing[0] = true; - } - System.err.println("resize: glok " + glok); - } - }); - - // draw the triangle when the OS tells us that any part of the window needs drawing - canvas.addPaintListener( new PaintListener() { - public void paintControl( PaintEvent paintevent ) { - Rectangle rectangle = canvas.getClientArea(); - boolean glok=false; - if( GLContext.CONTEXT_NOT_CURRENT < glcontext.makeCurrent() ) { - glok=true; - GL2ES1 gl = glcontext.getGL().getGL2ES1(); - if(sizeMissing[0]) { - OneTriangle.setup( gl, rectangle.width, rectangle.height); - sizeMissing[0] = false; - } - OneTriangle.render( gl, rectangle.width, rectangle.height); - drawable.swapBuffers(); - glcontext.release(); - } - System.err.println("paint: glok " + glok); - } - }); - - shell.setText( getClass().getName() ); - shell.setSize( 640, 480 ); - shell.open(); - - long lStartTime = System.currentTimeMillis(); - long lEndTime = lStartTime + duration; - try { - while( (System.currentTimeMillis() < lEndTime) && !canvas.isDisposed() ) { - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } - } - } catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - glcontext.destroy(); - drawable.setRealized(false); - canvas.dispose(); - } - private static class SWTUpstreamHook implements ProxySurface.UpstreamSurfaceHook, ControlListener { - private Canvas c; - Rectangle clientArea; - public SWTUpstreamHook(Canvas c) { - this.c = c ; - this.clientArea = c.getClientArea(); - } - @Override - public final void create(ProxySurface s) { /* nop */ } - - @Override - public final void destroy(ProxySurface s) { /* nop */ } - - @Override - public final int getWidth(ProxySurface s) { - return clientArea.width; - } - @Override - public final int getHeight(ProxySurface s) { - return clientArea.width; - } - - @Override - public void controlResized(final ControlEvent arg0) { - clientArea = c.getClientArea(); - } - @Override - public void controlMoved(ControlEvent e) { - } - @Override - public String toString() { - final String us_s = null != c ? c.toString() : "nil"; - return "SETUpstreamSurfaceHook[upstream: "+us_s+"]"; - } - }; - - @Test - public void test() throws InterruptedException { - GLProfile glprofile = GLProfile.getGL2ES1(); - runTestAGL( glprofile ); - } - - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - - public static void main(String args[]) { - for(int i=0; i *

    + * Note: To employ custom GLCapabilities, NewtCanvasSWT shall be used. + *

    + *

    * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ * SWT running on Mac OSX, i.e. to enforce UI action on the main thread. *

    @@ -116,34 +121,32 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { composite = null; } - protected void runTestAGL( GLProfile glprofile ) throws InterruptedException { - // need SWT.NO_BACKGROUND to prevent SWT from clearing the window - // at the wrong times (we use glClear for this instead) - final GLCapabilitiesImmutable caps = new GLCapabilities( glprofile ); + protected void runTestAGL( GLCapabilitiesImmutable caps, GLEventListener demo ) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - final GLCanvas canvas = new GLCanvas( composite, 0, caps, null, null); + final GLCanvas canvas = GLCanvas.create( composite, 0, caps, null, null); Assert.assertNotNull( canvas ); + canvas.addGLEventListener( demo ); canvas.addGLEventListener(new GLEventListener() { - public void init(final GLAutoDrawable drawable) { - System.err.println(Thread.currentThread().getName()+" - SWT Canvas - GLEventListener - init()"); - } - public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { - System.err.println(Thread.currentThread().getName()+" - SWT Canvas - GLEventListener - reshape()"); - OneTriangle.setup( drawable.getGL().getGL2(), width, height ); - } + int displayCount = 0; + public void init(final GLAutoDrawable drawable) { } + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } public void display(final GLAutoDrawable drawable) { - OneTriangle.render( drawable.getGL().getGL2(), drawable.getWidth(), drawable.getHeight()); + if(displayCount < 3) { + snapshot(getSimpleTestName("."), displayCount++, null, drawable.getGL(), screenshot, TextureIO.PNG, null); + } } - public void dispose(final GLAutoDrawable drawable) { - System.err.println(Thread.currentThread().getName()+" - SWT Canvas - GLEventListener - dispose()"); - } - }); + public void dispose(final GLAutoDrawable drawable) { } + }); - shell.setText( getClass().getName() ); - shell.setSize( 640, 480 ); - shell.open(); - + SWTAccessor.invoke(true, new Runnable() { + public void run() { + shell.setText( getSimpleTestName(".") ); + shell.setSize( 640, 480 ); + shell.open(); + } } ); + long lStartTime = System.currentTimeMillis(); long lEndTime = lStartTime + duration; try { @@ -157,13 +160,15 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } - canvas.dispose(); + SWTAccessor.invoke(true, new Runnable() { + public void run() { + canvas.dispose(); + } } ); } @Test public void test() throws InterruptedException { - GLProfile glprofile = GLProfile.getGL2ES1(); - runTestAGL( glprofile ); + runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2() ); } static int atoi(String a) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java new file mode 100644 index 000000000..11aef7c24 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aSWT.java @@ -0,0 +1,210 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.parenting; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.junit.After; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.newt.Window; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.swt.NewtCanvasSWT; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Simple visibility test .. + */ +public class TestParenting01aSWT extends UITestCase { + static int width, height; + static long durationPerTest = 800; + static GLCapabilities glCaps; + + Display display = null; + Shell shell = null; + Composite composite1 = null; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @Before + public void init() { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite1 = new Composite( shell, SWT.NONE ); + composite1.setLayout( new FillLayout() ); + Assert.assertNotNull( composite1 ); + }}); + } + + @After + public void release() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite1 ); + try { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + composite1.dispose(); + shell.dispose(); + display.dispose(); + }}); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + display = null; + shell = null; + composite1 = null; + } + + @Test + public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { + + GLWindow glWindow1 = GLWindow.create(glCaps); + Assert.assertNotNull(glWindow1); + Assert.assertEquals(false, glWindow1.isVisible()); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertNull(glWindow1.getParent()); + glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); + GLEventListener demo1 = new RedSquareES2(); + setDemoFields(demo1, glWindow1, false); + glWindow1.addGLEventListener(demo1); + + final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( composite1, 0, glWindow1 ); + Assert.assertNotNull(canvas1); + Assert.assertEquals(false, glWindow1.isVisible()); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertNull(glWindow1.getParent()); + + SWTAccessor.invoke(true, new Runnable() { + public void run() { + shell.setText( getSimpleTestName(".") ); + shell.setSize( 640, 480 ); + shell.open(); + } + }); + + // visible test + Assert.assertEquals(canvas1.getNativeWindow(),glWindow1.getParent()); + + for(int i=0; i*10 2 + if(detachFirst) { + canvas1.setNEWTChild(null); + canvas2.setNEWTChild(null); + } else { + canvas2.setNEWTChild(null); // free g2 of w2 + } + canvas1.setNEWTChild(glWindow2); // put g2 -> w1. free g1 of w1 + canvas2.setNEWTChild(glWindow1); // put g1 -> w2 + frame1.validate(); + frame2.validate(); + } + }); + break; + case 1: + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + // 2 -> 1 + if(detachFirst) { + canvas1.setNEWTChild(null); + canvas2.setNEWTChild(null); + } else { + canvas2.setNEWTChild(null); + } + canvas1.setNEWTChild(glWindow1); + canvas2.setNEWTChild(glWindow2); + frame1.validate(); + frame2.validate(); + } + }); + break; + } + } + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.dispose(); + frame2.dispose(); + } } ); + glWindow1.destroy(); + glWindow2.destroy(); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertEquals(false, glWindow2.isNativeValid()); + } + + public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { + Assert.assertNotNull(demo); + Assert.assertNotNull(glWindow); + Window window = glWindow.getDelegatedWindow(); + if(debug) { + MiscUtils.setFieldIfExists(demo, "glDebug", true); + MiscUtils.setFieldIfExists(demo, "glTrace", true); + } + if(!MiscUtils.setFieldIfExists(demo, "window", window)) { + MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); + } + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i 2 + if(detachFirst) { + canvas1.setNEWTChild(null); + canvas2.setNEWTChild(null); + } else { + canvas2.setNEWTChild(null); // free g2 of w2 + } + canvas1.setNEWTChild(glWindow2); // put g2 -> w1. free g1 of w1 + canvas2.setNEWTChild(glWindow1); // put g1 -> w2 + } } ); + break; + case 1: + SWTAccessor.invoke(true, new Runnable() { + public void run() { + // 2 -> 1 + if(detachFirst) { + canvas1.setNEWTChild(null); + canvas2.setNEWTChild(null); + } else { + canvas2.setNEWTChild(null); + } + canvas1.setNEWTChild(glWindow1); + canvas2.setNEWTChild(glWindow2); + } } ); + break; + } + } + + canvas1.dispose(); + canvas2.dispose(); + Assert.assertEquals(false, glWindow1.isNativeValid()); + Assert.assertEquals(false, glWindow2.isNativeValid()); + } + + public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { + Assert.assertNotNull(demo); + Assert.assertNotNull(glWindow); + Window window = glWindow.getDelegatedWindow(); + if(debug) { + MiscUtils.setFieldIfExists(demo, "glDebug", true); + MiscUtils.setFieldIfExists(demo, "glTrace", true); + } + if(!MiscUtils.setFieldIfExists(demo, "window", window)) { + MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); + } + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Fri, 3 Aug 2012 01:38:37 +0300 Subject: Fix X11 Display Connection leak w/ new GLAutoDrawableBase code when used w/ offscreen drawables, reported by Mark Raynsford New common GLAutoDrawableBase missed to close the AbstractGraphicsDevice in case it has been created and dedicated for the passed GLDrawable. This detailed knowledge is only known to the creator, hence it is passed in the constructor and is being passed through all specializations. Further more the new X11/GLX impl. of GLDrawableFactory's 'createMutableSurfaceImpl' always creates it's own private X11 display connection to avoid locking / threading issues. Since the old implementation reused the shared display connection which is prone to threading issues, this bug was not visible before. Also fixed the unit test TestNEWTCloseX11DisplayBug565, now correctly validating that no display connection is left over after a new cycle of create/destroy of onscreen and offscreen drawables. --- make/scripts/tests.sh | 6 ++-- .../com/jogamp/opengl/OffscreenAutoDrawable.java | 13 ++++++-- .../javax/media/opengl/GLAutoDrawableDelegate.java | 14 +++++--- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 39 ++++++++++++++++------ .../jogamp/opengl/GLDrawableFactoryImpl.java | 2 +- src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 4 +-- .../classes/jogamp/nativewindow/x11/X11Util.java | 2 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 2 +- .../test/junit/jogl/acore/TestFBODrawableNEWT.java | 2 +- .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 2 +- .../acore/TestGLContextDrawableSwitchNEWT.java | 2 +- .../jogl/acore/TestNEWTCloseX11DisplayBug565.java | 8 ++--- 12 files changed, 64 insertions(+), 32 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index af6218968..43d04c6bd 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -61,7 +61,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" - D_ARGS="-Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" @@ -217,7 +217,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* @@ -328,7 +328,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java b/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java index 1ea8595c6..8450ffdb0 100644 --- a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java @@ -28,6 +28,7 @@ package com.jogamp.opengl; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GLAutoDrawableDelegate; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; @@ -45,8 +46,16 @@ import jogamp.opengl.GLFBODrawableImpl; */ public class OffscreenAutoDrawable extends GLAutoDrawableDelegate { - public OffscreenAutoDrawable(GLDrawable drawable, GLContext context, Object upstreamWidget) { - super(drawable, context, upstreamWidget); + /** + * @param drawable a valid {@link GLDrawable}, may not be realized yet. + * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. + */ + public OffscreenAutoDrawable(GLDrawable drawable, GLContext context, boolean ownDevice) { + super(drawable, context, null, ownDevice); } /** diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java index 76959f3f4..67e81270d 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java @@ -28,6 +28,8 @@ package javax.media.opengl; +import javax.media.nativewindow.AbstractGraphicsDevice; + import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; @@ -57,12 +59,16 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase { public static final boolean DEBUG = Debug.debug("GLAutoDrawableDelegate"); /** - * @param drawable - * @param context + * @param drawable a valid {@link GLDrawable}, may not be realized yet. + * @param context a valid {@link GLContext}, may not be made current (created) yet. * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. */ - public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget) { - super((GLDrawableImpl)drawable, (GLContextImpl)context); + public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice) { + super((GLDrawableImpl)drawable, (GLContextImpl)context, ownDevice); this.upstreamWidget = null; } diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index fe6d0fd76..cc4e1b434 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -30,6 +30,8 @@ package jogamp.opengl; import java.io.PrintStream; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; @@ -66,13 +68,23 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access protected GLContextImpl context; + protected final boolean ownDevice; protected int additionalCtxCreationFlags = 0; protected volatile boolean sendReshape = false; // volatile: maybe written by WindowManager thread w/o locking protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking - public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context) { + /** + * @param drawable a valid {@link GLDrawableImpl}, may not be realized yet. + * @param context a valid {@link GLContextImpl}, may not be made current (created) yet. + * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. + */ + public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context, boolean ownDevice) { this.drawable = drawable; this.context = context; + this.ownDevice = ownDevice; resetFPSCounter(); } @@ -174,7 +186,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } /** - * Calls {@link #destroyImplInLock()} while claiming the lock. + * Calls {@link #destroyImplInLock()} while claiming the lock. */ protected final void defaultDestroy() { final RecursiveLock lock = getLock(); @@ -200,17 +212,22 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { protected void destroyImplInLock() { final GLContext _context = context; final GLDrawable _drawable = drawable; - if( null != _drawable && _drawable.isRealized() ) { - if( null != _context && _context.isCreated() ) { - // Catch dispose GLExceptions by GLEventListener, just 'print' them - // so we can continue with the destruction. - try { - helper.disposeGL(this, _drawable, _context, null); - } catch (GLException gle) { - gle.printStackTrace(); + if( null != _drawable ) { + if( _drawable.isRealized() ) { + if( null != _context && _context.isCreated() ) { + // Catch dispose GLExceptions by GLEventListener, just 'print' them + // so we can continue with the destruction. + try { + helper.disposeGL(this, _drawable, _context, null); + } catch (GLException gle) { + gle.printStackTrace(); + } } + _drawable.setRealized(false); + } + if( ownDevice ) { + _drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice().close(); } - _drawable.setRealized(false); } context = null; drawable = null; diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index f092288fb..f7808294b 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -245,7 +245,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null==drawable) { throw new GLException("Could not create Pbuffer drawable for: "+device+", "+capsChosen+", "+width+"x"+height); } - return new GLPbufferImpl( drawable, shareWith); + return new GLPbufferImpl( drawable, shareWith, true); } //--------------------------------------------------------------------------- diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index 6b64120fe..32f4cb696 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -58,8 +58,8 @@ import com.jogamp.common.util.locks.RecursiveLock; public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { private int floatMode; - public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext sharedContext) { - super(pbufferDrawable, null); // drawable := pbufferDrawable + public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext sharedContext, boolean ownDevice) { + super(pbufferDrawable, null, ownDevice); // drawable := pbufferDrawable GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) drawable.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index fcc374751..7b46a1df0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -255,7 +255,7 @@ public class X11Util { */ public static int shutdown(boolean realXCloseOpenAndPendingDisplays, boolean verbose) { int num=0; - if(DEBUG||verbose||pendingDisplayList.size() > 0) { + if(DEBUG || verbose || openDisplayMap.size() > 0 || pendingDisplayList.size() > 0) { System.err.println("X11Util.Display: Shutdown (close open / pending Displays: "+realXCloseOpenAndPendingDisplays+ ", open (no close attempt): "+openDisplayMap.size()+"/"+openDisplayList.size()+ ", pending (not closed, marked uncloseable): "+pendingDisplayList.size()+")"); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index d662a743a..0fc1b4e89 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -97,7 +97,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind * Constructor. Do not call this directly -- use {@link #create()} instead. */ protected GLWindow(Window window) { - super(null, null); + super(null, null, false); this.window = (WindowImpl) window; this.window.setHandleDestroyNotify(false); window.addWindowListener(new WindowAdapter() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java index 1a33845b3..7977347a7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java @@ -167,7 +167,7 @@ public class TestFBODrawableNEWT extends UITestCase { final FBObject.RenderAttachment depthA = fbo.getDepthAttachment(); Assert.assertNotNull(depthA); - final OffscreenAutoDrawable glad = new OffscreenAutoDrawable(fboDrawable, context, null); + final OffscreenAutoDrawable glad = new OffscreenAutoDrawable(fboDrawable, context, true); glad.addGLEventListener(demo); glad.addGLEventListener(new GLEventListener() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java index 426b7734f..96d9b2e28 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java @@ -85,7 +85,7 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); context.release(); - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window) { + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false) { @Override protected void destroyImplInLock() { super.destroyImplInLock(); // destroys drawable/context diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java index 92b4c5238..cece4c6d5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java @@ -88,7 +88,7 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { drawable.setRealized(true); Assert.assertTrue(drawable.isRealized()); - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window) { + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false) { @Override protected void destroyImplInLock() { super.destroyImplInLock(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java index e14d5b800..33a9b7799 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java @@ -43,10 +43,10 @@ public class TestNEWTCloseX11DisplayBug565 { if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { final int openD = X11Util.getOpenDisplayConnectionNumber() - open0; - if(openD>1) { + if( openD > 0) { X11Util.dumpOpenDisplayConnections(); X11Util.dumpPendingDisplayConnections(); - Assert.assertTrue("More than 1 new open display connections", false); + Assert.assertEquals("New display connection didn't close", 0, openD); } } } @@ -86,10 +86,10 @@ public class TestNEWTCloseX11DisplayBug565 { if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { final int openD = X11Util.getOpenDisplayConnectionNumber() - open0; - if(openD>1) { + if(openD > 0) { X11Util.dumpOpenDisplayConnections(); X11Util.dumpPendingDisplayConnections(); - Assert.assertTrue("More than 1 new open display connections", false); + Assert.assertEquals("New display connection didn't close", 0, openD); } } } -- cgit v1.2.3 From 6e4051d8c9faeec003b15b68bd01e3caf22869fb Mon Sep 17 00:00:00 2001 From: Xerxes RÃ¥nby Date: Mon, 6 Aug 2012 21:00:19 +0000 Subject: Use armv6 optimization for armhf to stay compatible with the new Raspberry Pi Raspbian distribution. --- make/scripts/make.jogl.all.linux-armv7hf-cross.sh | 2 +- make/scripts/make.jogl.all.linux-armv7hf.sh | 27 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 make/scripts/make.jogl.all.linux-armv7hf.sh (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.linux-armv7hf-cross.sh b/make/scripts/make.jogl.all.linux-armv7hf-cross.sh index cd82d82af..b51fe94a9 100755 --- a/make/scripts/make.jogl.all.linux-armv7hf-cross.sh +++ b/make/scripts/make.jogl.all.linux-armv7hf-cross.sh @@ -33,7 +33,7 @@ export TARGET_PLATFORM_ROOT=/opt-linux-armv7-armhf export TARGET_PLATFORM_LIBS=$TARGET_PLATFORM_ROOT/usr/lib export TARGET_JAVA_LIBS=$TARGET_PLATFORM_ROOT/jre/lib/arm -export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv7hf.xml" +export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6hf.xml" #export JUNIT_DISABLED="true" export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" diff --git a/make/scripts/make.jogl.all.linux-armv7hf.sh b/make/scripts/make.jogl.all.linux-armv7hf.sh new file mode 100755 index 000000000..a94b05824 --- /dev/null +++ b/make/scripts/make.jogl.all.linux-armv7hf.sh @@ -0,0 +1,27 @@ +#! /bin/sh + +# arm-linux-gnueabihf == armhf triplet +PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabihf/bin:$PATH +export PATH + +# -Dc.compiler.debug=true +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxARMv7=true \ +# -DisX11=false \ + +export TARGET_PLATFORM_ROOT=/ +export TARGET_PLATFORM_LIBS=/usr/lib/arm-linux-gnueabihf +export TARGET_JAVA_LIBS=/usr/lib/jvm/java-6-openjdk-armhf/jre/lib/arm + +export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6hf.xml" + +ant \ + -Drootrel.build=build-linux-armv7hf \ + -Dsetup.addNativeKD=true \ + -Dsetup.addNativeOpenMAX=true \ + -Dsetup.addNativeBroadcomEGL=true \ + -Djunit.run.arg0="-Dnewt.test.Screen.disableScreenMode" \ + $* 2>&1 | tee make.jogl.all.linux-armv7hf.log + -- cgit v1.2.3 From 3732d0162051ffe56af34ba345b59c15bfc6f552 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 16 Aug 2012 14:47:16 +0200 Subject: Adapt to GlueGen ARM Build Changes 422d7a5eb53fca6642ebf4e8910d8b0311bb2597 Note: Patch set not clean since build*xml files contain 'NEWT Broadcom' driver changes of upcoming commit due to pervious uncommitted work. Will be fixed w/ next commit. --- make/build-common.xml | 4 +- make/build-jogl.xml | 14 ++-- make/build-nativewindow.xml | 14 ++-- make/build-newt.xml | 55 +++++++++----- make/build-test.xml | 2 +- make/scripts/adb-install-all-armv6.sh | 4 + make/scripts/adb-launch-main.sh | 6 +- make/scripts/adb-reinstall-all-armv6.sh | 5 ++ make/scripts/make.jogl.all.android-armv6-cross.sh | 92 +++++++++++++++++++++++ make/scripts/make.jogl.all.linux-armv6-cross.sh | 51 +++++++++++++ make/scripts/make.jogl.all.linux-armv6.sh | 27 +++++++ make/scripts/make.jogl.all.linux-armv6hf-cross.sh | 51 +++++++++++++ make/scripts/make.jogl.all.linux-armv6hf.sh | 27 +++++++ make/scripts/make.jogl.all.linux-armv7-cross.sh | 51 ------------- make/scripts/make.jogl.all.linux-armv7.sh | 27 ------- make/scripts/make.jogl.all.linux-armv7hf-cross.sh | 51 ------------- make/scripts/make.jogl.all.linux-armv7hf.sh | 27 ------- make/scripts/targetcommand-awt.sh | 9 ++- make/scripts/targetcommand-loop.sh | 75 ++++++++++++++++++ make/scripts/targetcommand-newt.sh | 14 ++-- make/scripts/tests-armv6_armel.sh | 7 ++ make/scripts/tests-armv6_armhf.sh | 7 ++ make/scripts/tests-armv7l_eabi.sh | 7 -- make/scripts/tests-linux-armv6.sh | 7 ++ make/scripts/tests-linux-armv6hf.sh | 7 ++ make/scripts/tests-linux-armv7.sh | 7 -- make/scripts/tests-linux-armv7hf.sh | 7 -- make/scripts/tests.sh | 6 +- 28 files changed, 432 insertions(+), 229 deletions(-) create mode 100755 make/scripts/adb-install-all-armv6.sh create mode 100755 make/scripts/adb-reinstall-all-armv6.sh create mode 100755 make/scripts/make.jogl.all.android-armv6-cross.sh create mode 100755 make/scripts/make.jogl.all.linux-armv6-cross.sh create mode 100755 make/scripts/make.jogl.all.linux-armv6.sh create mode 100755 make/scripts/make.jogl.all.linux-armv6hf-cross.sh create mode 100755 make/scripts/make.jogl.all.linux-armv6hf.sh delete mode 100755 make/scripts/make.jogl.all.linux-armv7-cross.sh delete mode 100755 make/scripts/make.jogl.all.linux-armv7.sh delete mode 100755 make/scripts/make.jogl.all.linux-armv7hf-cross.sh delete mode 100755 make/scripts/make.jogl.all.linux-armv7hf.sh create mode 100644 make/scripts/targetcommand-loop.sh create mode 100755 make/scripts/tests-armv6_armel.sh create mode 100755 make/scripts/tests-armv6_armhf.sh delete mode 100755 make/scripts/tests-armv7l_eabi.sh create mode 100755 make/scripts/tests-linux-armv6.sh create mode 100755 make/scripts/tests-linux-armv6hf.sh delete mode 100755 make/scripts/tests-linux-armv7.sh delete mode 100755 make/scripts/tests-linux-armv7hf.sh (limited to 'make/scripts') diff --git a/make/build-common.xml b/make/build-common.xml index 4de5de58b..df19cb7a5 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -140,7 +140,7 @@ - + @@ -370,7 +370,7 @@ - + diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 2605104d9..40859845c 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1119,7 +1119,7 @@ - + @@ -1147,7 +1147,7 @@ - + @@ -1236,10 +1236,10 @@
    - - - - + + + + @@ -1284,7 +1284,7 @@ - + diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index c77558d6b..6a9dbdc2e 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -342,7 +342,7 @@ - + @@ -396,7 +396,7 @@ - + @@ -487,10 +487,10 @@ - - - - + + + + @@ -535,7 +535,7 @@ - + diff --git a/make/build-newt.xml b/make/build-newt.xml index 17f54f988..f38d01c49 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -48,7 +48,7 @@ setup.noNativeDesktop setup.addNativeKD setup.addNativeIntelGDL - setup.addNativeBroadcomEGL + setup.addNativeBroadcom - Internal settings, may not be necessary to set them manually, since all JAR archives are orthogonal. @@ -79,7 +79,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -125,8 +125,8 @@ - + @@ -201,7 +201,8 @@ - + + @@ -254,7 +255,7 @@ - + @@ -274,7 +275,16 @@ - + + + + + + + + + + @@ -294,7 +304,7 @@ - + @@ -384,11 +394,11 @@ - - - - + + + + @@ -460,7 +470,7 @@ - + @@ -564,7 +574,8 @@ - + + @@ -609,7 +620,8 @@ - + + @@ -654,7 +666,10 @@ - + + + + @@ -746,9 +761,9 @@ - + + includes="${java.part.driver.bcm}"/> - + > $BUILD_DIR/jogl-targetcommand.sh diff --git a/make/scripts/adb-reinstall-all-armv6.sh b/make/scripts/adb-reinstall-all-armv6.sh new file mode 100755 index 000000000..0e62c5944 --- /dev/null +++ b/make/scripts/adb-reinstall-all-armv6.sh @@ -0,0 +1,5 @@ +sdir=`dirname $0` + +$sdir/adb-uninstall-all.sh $* +$sdir/adb-install-all-armv6.sh $* + diff --git a/make/scripts/make.jogl.all.android-armv6-cross.sh b/make/scripts/make.jogl.all.android-armv6-cross.sh new file mode 100755 index 000000000..262560090 --- /dev/null +++ b/make/scripts/make.jogl.all.android-armv6-cross.sh @@ -0,0 +1,92 @@ +#! /bin/sh + +export NODE_LABEL=. + +export HOST_UID=jogamp +# jogamp02 - 10.1.0.122 +export HOST_IP=10.1.0.122 +export HOST_RSYNC_ROOT=PROJECTS/JOGL + +export TARGET_UID=jogamp +export TARGET_IP=panda02 +#export TARGET_IP=jautab03 +#export TARGET_IP=jauphone04 +export TARGET_ADB_PORT=5555 +# needs executable bit (probably su) +export TARGET_ROOT=/data/projects +export TARGET_ANT_HOME=/usr/share/ant + +echo ANDROID_SDK_HOME $ANDROID_SDK_HOME +echo NDK_ROOT $NDK_ROOT + +if [ -z "$NDK_ROOT" ] ; then + # + # Generic android-ndk + # + if [ -e /usr/local/android-ndk ] ; then + NDK_ROOT=/usr/local/android-ndk + elif [ -e /opt-linux-x86/android-ndk ] ; then + NDK_ROOT=/opt-linux-x86/android-ndk + elif [ -e /opt/android-ndk ] ; then + NDK_ROOT=/opt/android-ndk + # + # Specific android-ndk-r7b + # + elif [ -e /usr/local/android-ndk-r7b ] ; then + NDK_ROOT=/usr/local/android-ndk-r7b + elif [ -e /opt-linux-x86/android-ndk-r7b ] ; then + NDK_ROOT=/opt-linux-x86/android-ndk-r7b + elif [ -e /opt/android-ndk-r7b ] ; then + NDK_ROOT=/opt/android-ndk-r7b + else + echo NDK_ROOT is not specified and does not exist in default locations + exit 1 + fi +elif [ ! -e $NDK_ROOT ] ; then + echo NDK_ROOT $NDK_ROOT does not exist + exit 1 +fi +export NDK_ROOT + +if [ -z "$ANDROID_SDK_HOME" ] ; then + if [ -e /usr/local/android-sdk-linux_x86 ] ; then + ANDROID_SDK_HOME=/usr/local/android-sdk-linux_x86 + elif [ -e /opt-linux-x86/android-sdk-linux_x86 ] ; then + ANDROID_SDK_HOME=/opt-linux-x86/android-sdk-linux_x86 + elif [ -e /opt/android-sdk-linux_x86 ] ; then + ANDROID_SDK_HOME=/opt/android-sdk-linux_x86 + else + echo ANDROID_SDK_HOME is not specified and does not exist in default locations + exit 1 + fi +elif [ ! -e $ANDROID_SDK_HOME ] ; then + echo ANDROID_SDK_HOME $ANDROID_SDK_HOME does not exist + exit 1 +fi +export ANDROID_SDK_HOME + +export ANDROID_VERSION=9 +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +export GCC_VERSION=4.4.3 +HOST_ARCH=linux-x86 +export TARGET_TRIPLE=arm-linux-androideabi + +export NDK_TOOLCHAIN_ROOT=$NDK_ROOT/toolchains/${TARGET_TRIPLE}-${GCC_VERSION}/prebuilt/${HOST_ARCH} +export TARGET_PLATFORM_ROOT=${NDK_ROOT}/platforms/android-${ANDROID_VERSION}/arch-arm + +# Need to add toolchain bins to the PATH. +export PATH="$NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin:$ANDROID_SDK_HOME/platform-tools:$PATH" + +export GLUEGEN_CPPTASKS_FILE=`pwd`/../../gluegen/make/lib/gluegen-cpptasks-android-armv6.xml + +#export JUNIT_DISABLED="true" +#export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" + +# BUILD_ARCHIVE=true \ +ant \ + -Drootrel.build=build-android-armv6 \ + $* 2>&1 | tee -a make.jogl.all.android-armv6-cross.log + diff --git a/make/scripts/make.jogl.all.linux-armv6-cross.sh b/make/scripts/make.jogl.all.linux-armv6-cross.sh new file mode 100755 index 000000000..9f31b798d --- /dev/null +++ b/make/scripts/make.jogl.all.linux-armv6-cross.sh @@ -0,0 +1,51 @@ +#! /bin/sh + +SDIR=`dirname $0` + +if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +fi + +# arm-linux-gnueabi == armel triplet +PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabi/bin:$PATH +export PATH + +# -Dc.compiler.debug=true +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxARMv6=true \ +# -DisX11=false \ + +export NODE_LABEL=. + +export HOST_UID=jogamp +export HOST_IP=jogamp02 +export HOST_RSYNC_ROOT=PROJECTS/JOGL + +export TARGET_UID=jogamp +export TARGET_IP=panda01 +#export TARGET_IP=jautab02 +export TARGET_ROOT=/home/jogamp/projects-cross +export TARGET_ANT_HOME=/usr/share/ant + +export TARGET_PLATFORM_ROOT=/opt-linux-armv6-armel +export TARGET_PLATFORM_LIBS=$TARGET_PLATFORM_ROOT/usr/lib +export TARGET_JAVA_LIBS=$TARGET_PLATFORM_ROOT/jre/lib/arm + +export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6.xml" + +#export JUNIT_DISABLED="true" +export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" + +ant \ + -Drootrel.build=build-linux-armv6 \ + \ + -Dsetup.addNativeKD=true \ + -Dsetup.addNativeOpenMAX=true \ + -Dsetup.addNativeBroadcom=true \ + $* 2>&1 | tee make.jogl.all.linux-armv6-cross.log + + + + diff --git a/make/scripts/make.jogl.all.linux-armv6.sh b/make/scripts/make.jogl.all.linux-armv6.sh new file mode 100755 index 000000000..3d526ea12 --- /dev/null +++ b/make/scripts/make.jogl.all.linux-armv6.sh @@ -0,0 +1,27 @@ +#! /bin/sh + +# arm-linux-gnueabi == armel triplet +PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabi/bin:$PATH +export PATH + +# -Dc.compiler.debug=true +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxARMv6=true \ +# -DisX11=false \ + +export TARGET_PLATFORM_ROOT=/ +export TARGET_PLATFORM_LIBS=/usr/lib/arm-linux-gnueabi +export TARGET_JAVA_LIBS=/usr/lib/jvm/default-java/jre/lib/arm + +export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6.xml" + +ant \ + -Drootrel.build=build-linux-armv6 \ + -Dsetup.addNativeKD=true \ + -Dsetup.addNativeOpenMAX=true \ + -Dsetup.addNativeBroadcom=true \ + -Djunit.run.arg0="-Dnewt.test.Screen.disableScreenMode" \ + $* 2>&1 | tee make.jogl.all.linux-armv6.log + diff --git a/make/scripts/make.jogl.all.linux-armv6hf-cross.sh b/make/scripts/make.jogl.all.linux-armv6hf-cross.sh new file mode 100755 index 000000000..6295a90f9 --- /dev/null +++ b/make/scripts/make.jogl.all.linux-armv6hf-cross.sh @@ -0,0 +1,51 @@ +#! /bin/sh + +SDIR=`dirname $0` + +if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +fi + +# arm-linux-gnueabihf == armel triplet +PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabihf/bin:$PATH +export PATH + +# -Dc.compiler.debug=true +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxARMv6=true \ +# -DisX11=false \ + +export NODE_LABEL=. + +export HOST_UID=jogamp +export HOST_IP=jogamp02 +export HOST_RSYNC_ROOT=PROJECTS/JOGL + +export TARGET_UID=jogamp +export TARGET_IP=panda02 +#export TARGET_IP=jautab02 +export TARGET_ROOT=/home/jogamp/projects-cross +export TARGET_ANT_HOME=/usr/share/ant + +export TARGET_PLATFORM_ROOT=/opt-linux-armv6-armhf +export TARGET_PLATFORM_LIBS=$TARGET_PLATFORM_ROOT/usr/lib +export TARGET_JAVA_LIBS=$TARGET_PLATFORM_ROOT/jre/lib/arm + +export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6hf.xml" + +#export JUNIT_DISABLED="true" +export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" + +ant \ + -Drootrel.build=build-linux-armv6hf \ + \ + -Dsetup.addNativeKD=true \ + -Dsetup.addNativeOpenMAX=true \ + -Dsetup.addNativeBroadcom=true \ + $* 2>&1 | tee make.jogl.all.linux-armv6hf-cross.log + + + + diff --git a/make/scripts/make.jogl.all.linux-armv6hf.sh b/make/scripts/make.jogl.all.linux-armv6hf.sh new file mode 100755 index 000000000..7d9480f26 --- /dev/null +++ b/make/scripts/make.jogl.all.linux-armv6hf.sh @@ -0,0 +1,27 @@ +#! /bin/sh + +# arm-linux-gnueabihf == armhf triplet +PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabihf/bin:$PATH +export PATH + +# -Dc.compiler.debug=true +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxARMv6=true \ +# -DisX11=false \ + +export TARGET_PLATFORM_ROOT=/ +export TARGET_PLATFORM_LIBS=/usr/lib/arm-linux-gnueabihf +export TARGET_JAVA_LIBS=/usr/lib/jvm/java-6-openjdk-armhf/jre/lib/arm + +export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6hf.xml" + +ant \ + -Drootrel.build=build-linux-armv6hf \ + -Dsetup.addNativeKD=true \ + -Dsetup.addNativeOpenMAX=true \ + -Dsetup.addNativeBroadcom=true \ + -Djunit.run.arg0="-Dnewt.test.Screen.disableScreenMode" \ + $* 2>&1 | tee make.jogl.all.linux-armv6hf.log + diff --git a/make/scripts/make.jogl.all.linux-armv7-cross.sh b/make/scripts/make.jogl.all.linux-armv7-cross.sh deleted file mode 100755 index 5bb572858..000000000 --- a/make/scripts/make.jogl.all.linux-armv7-cross.sh +++ /dev/null @@ -1,51 +0,0 @@ -#! /bin/sh - -SDIR=`dirname $0` - -if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then - . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh -fi - -# arm-linux-gnueabi == armel triplet -PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabi/bin:$PATH -export PATH - -# -Dc.compiler.debug=true -# -Dgluegen.cpptasks.detected.os=true \ -# -DisUnix=true \ -# -DisLinux=true \ -# -DisLinuxARMv7=true \ -# -DisX11=false \ - -export NODE_LABEL=. - -export HOST_UID=jogamp -export HOST_IP=jogamp02 -export HOST_RSYNC_ROOT=PROJECTS/JOGL - -export TARGET_UID=jogamp -export TARGET_IP=panda01 -#export TARGET_IP=jautab02 -export TARGET_ROOT=/home/jogamp/projects-cross -export TARGET_ANT_HOME=/usr/share/ant - -export TARGET_PLATFORM_ROOT=/opt-linux-armv7-armel -export TARGET_PLATFORM_LIBS=$TARGET_PLATFORM_ROOT/usr/lib -export TARGET_JAVA_LIBS=$TARGET_PLATFORM_ROOT/jre/lib/arm - -export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv4.xml" - -#export JUNIT_DISABLED="true" -export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" - -ant \ - -Drootrel.build=build-linux-armv7 \ - \ - -Dsetup.addNativeKD=true \ - -Dsetup.addNativeOpenMAX=true \ - -Dsetup.addNativeBroadcomEGL=true \ - $* 2>&1 | tee make.jogl.all.linux-armv7-cross.log - - - - diff --git a/make/scripts/make.jogl.all.linux-armv7.sh b/make/scripts/make.jogl.all.linux-armv7.sh deleted file mode 100755 index 0fd0b6edd..000000000 --- a/make/scripts/make.jogl.all.linux-armv7.sh +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/sh - -# arm-linux-gnueabi == armel triplet -PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabi/bin:$PATH -export PATH - -# -Dc.compiler.debug=true -# -Dgluegen.cpptasks.detected.os=true \ -# -DisUnix=true \ -# -DisLinux=true \ -# -DisLinuxARMv7=true \ -# -DisX11=false \ - -export TARGET_PLATFORM_ROOT=/ -export TARGET_PLATFORM_LIBS=/usr/lib/arm-linux-gnueabi -export TARGET_JAVA_LIBS=/usr/lib/jvm/default-java/jre/lib/arm - -export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv4.xml" - -ant \ - -Drootrel.build=build-linux-armv7 \ - -Dsetup.addNativeKD=true \ - -Dsetup.addNativeOpenMAX=true \ - -Dsetup.addNativeBroadcomEGL=true \ - -Djunit.run.arg0="-Dnewt.test.Screen.disableScreenMode" \ - $* 2>&1 | tee make.jogl.all.linux-armv7.log - diff --git a/make/scripts/make.jogl.all.linux-armv7hf-cross.sh b/make/scripts/make.jogl.all.linux-armv7hf-cross.sh deleted file mode 100755 index b51fe94a9..000000000 --- a/make/scripts/make.jogl.all.linux-armv7hf-cross.sh +++ /dev/null @@ -1,51 +0,0 @@ -#! /bin/sh - -SDIR=`dirname $0` - -if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then - . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh -fi - -# arm-linux-gnueabihf == armel triplet -PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabihf/bin:$PATH -export PATH - -# -Dc.compiler.debug=true -# -Dgluegen.cpptasks.detected.os=true \ -# -DisUnix=true \ -# -DisLinux=true \ -# -DisLinuxARMv7=true \ -# -DisX11=false \ - -export NODE_LABEL=. - -export HOST_UID=jogamp -export HOST_IP=jogamp02 -export HOST_RSYNC_ROOT=PROJECTS/JOGL - -export TARGET_UID=jogamp -export TARGET_IP=panda01 -#export TARGET_IP=jautab02 -export TARGET_ROOT=/home/jogamp/projects-cross -export TARGET_ANT_HOME=/usr/share/ant - -export TARGET_PLATFORM_ROOT=/opt-linux-armv7-armhf -export TARGET_PLATFORM_LIBS=$TARGET_PLATFORM_ROOT/usr/lib -export TARGET_JAVA_LIBS=$TARGET_PLATFORM_ROOT/jre/lib/arm - -export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6hf.xml" - -#export JUNIT_DISABLED="true" -export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" - -ant \ - -Drootrel.build=build-linux-armv7hf \ - \ - -Dsetup.addNativeKD=true \ - -Dsetup.addNativeOpenMAX=true \ - -Dsetup.addNativeBroadcomEGL=true \ - $* 2>&1 | tee make.jogl.all.linux-armv7hf-cross.log - - - - diff --git a/make/scripts/make.jogl.all.linux-armv7hf.sh b/make/scripts/make.jogl.all.linux-armv7hf.sh deleted file mode 100755 index a94b05824..000000000 --- a/make/scripts/make.jogl.all.linux-armv7hf.sh +++ /dev/null @@ -1,27 +0,0 @@ -#! /bin/sh - -# arm-linux-gnueabihf == armhf triplet -PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabihf/bin:$PATH -export PATH - -# -Dc.compiler.debug=true -# -Dgluegen.cpptasks.detected.os=true \ -# -DisUnix=true \ -# -DisLinux=true \ -# -DisLinuxARMv7=true \ -# -DisX11=false \ - -export TARGET_PLATFORM_ROOT=/ -export TARGET_PLATFORM_LIBS=/usr/lib/arm-linux-gnueabihf -export TARGET_JAVA_LIBS=/usr/lib/jvm/java-6-openjdk-armhf/jre/lib/arm - -export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6hf.xml" - -ant \ - -Drootrel.build=build-linux-armv7hf \ - -Dsetup.addNativeKD=true \ - -Dsetup.addNativeOpenMAX=true \ - -Dsetup.addNativeBroadcomEGL=true \ - -Djunit.run.arg0="-Dnewt.test.Screen.disableScreenMode" \ - $* 2>&1 | tee make.jogl.all.linux-armv7hf.log - diff --git a/make/scripts/targetcommand-awt.sh b/make/scripts/targetcommand-awt.sh index af3b5f775..7f95e33a2 100755 --- a/make/scripts/targetcommand-awt.sh +++ b/make/scripts/targetcommand-awt.sh @@ -2,6 +2,8 @@ THISDIR=`pwd` +ROOT_REL=build-linux-armv6hf + #XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode" XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #XTRA_FLAGS="-Dnewt.debug.Screen" @@ -22,15 +24,15 @@ TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT rsync -av --delete --delete-after --delete-excluded \ --exclude 'build-x86*/' --exclude 'build-linux-x*/' --exclude 'build-android*/' --exclude 'build-win*/' --exclude 'build-mac*/' \ --exclude 'classes/' --exclude 'src/' --exclude '.git/' --exclude '*-java-src.zip' \ + --exclude 'make/lib/external/' \ jogamp@jogamp02::PROJECTS/JOGL/gluegen jogamp@jogamp02::PROJECTS/JOGL/jogl $THISDIR/projects-cross cd $THISDIR/projects-cross/jogl/make function junit_run() { java \ - -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/build-linux-armv7/gluegen-rt.jar:../build-linux-armv7/jar/jogl.all.jar:../build-linux-armv7/jar/jogl.test.jar\ + -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/$ROOT_REL/gluegen-rt.jar:../$ROOT_REL/jar/jogl-all.jar:../$ROOT_REL/jar/jogl-test.jar\ $XTRA_FLAGS \ - com.jogamp.newt.util.MainThread\ org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner \ $TSTCLASS \ filtertrace=true \ @@ -46,9 +48,8 @@ function junit_run() { function main_run() { java \ - -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/build-linux-armv7/gluegen-rt.jar:../build-linux-armv7/jar/jogl.all.jar:../build-linux-armv7/jar/jogl.test.jar\ + -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/$ROOT_REL/gluegen-rt.jar:../$ROOT_REL/jar/jogl-all.jar:../$ROOT_REL/jar/jogl-test.jar\ $XTRA_FLAGS \ - com.jogamp.newt.util.MainThread\ $TSTCLASS \ $* } diff --git a/make/scripts/targetcommand-loop.sh b/make/scripts/targetcommand-loop.sh new file mode 100644 index 000000000..fc7baa77d --- /dev/null +++ b/make/scripts/targetcommand-loop.sh @@ -0,0 +1,75 @@ +#! /bin/sh + +THISDIR=`pwd` + +ROOT_REL=build-linux-armv6hf + +# export LD_LIBRARY_PATH=$THISDIR/PVRTrace/:$LD_LIBRARY_PATH + +XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode" +#XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.TraceGL" +#XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" +#XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" +#XTRA_FLAGS="-Dnewt.debug.Screen" +#XTRA_FLAGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" +#XTRA_FLAGS="-Dnewt.debug.Window -Djogl.debug.EGL -Djogl.debug.GLContext -Djogl.debug.GLDrawable" +#XTRA_FLAGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" +#XTRA_FLAGS="-Djogl.debug.EGL" +#XTRA_FLAGS="-Djogl.debug.GraphicsConfiguration" +#XTRA_FLAGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable" +#XTRA_FLAGS="-Djogl.debug.TraceGL" +#XTRA_FLAGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" + +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT +TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT + + mkdir -p $THISDIR/projects-cross + + rsync -av --delete --delete-after --delete-excluded \ + --exclude 'build-x86*/' --exclude 'build-linux-x*/' --exclude 'build-android*/' --exclude 'build-win*/' --exclude 'build-mac*/' \ + --exclude 'classes/' --exclude 'src/' --exclude '.git/' --exclude '*-java-src.zip' \ + --exclude 'make/lib/external/' \ + jogamp@jogamp02::PROJECTS/JOGL/gluegen jogamp@jogamp02::PROJECTS/JOGL/jogl $THISDIR/projects-cross + + cd $THISDIR/projects-cross/jogl/make + + cp -a $THISDIR/pvrtrace.cfg . + +function junit_run() { + java \ + -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/$ROOT_REL/gluegen-rt.jar:../$ROOT_REL/jar/jogl-all-noawt.jar:../$ROOT_REL/jar/jogl-test.jar\ + -Djava.awt.headless=true\ + $XTRA_FLAGS \ + org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner \ + $TSTCLASS \ + filtertrace=true \ + haltOnError=false \ + haltOnFailure=false \ + showoutput=true \ + outputtoformatters=true \ + logfailedtests=true \ + logtestlistenerevents=true \ + formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter \ + formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,$THISDIR/targetcommand.xml +} + +function main_run() { + java \ + -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/$ROOT_REL/gluegen-rt.jar:../$ROOT_REL/jar/jogl-all-noawt.jar:../$ROOT_REL/jar/jogl-test.jar\ + -Djava.awt.headless=true\ + $XTRA_FLAGS \ + $TSTCLASS \ + $* +} + + +let i=0 + +while true ; do + let i=$i+1 + echo TEST RUN $i + # junit_run $* + main_run -time 100 $* + cp -a trace-*.pvrt $THISDIR/ +done + diff --git a/make/scripts/targetcommand-newt.sh b/make/scripts/targetcommand-newt.sh index 47b7a0b80..8b3c0945a 100755 --- a/make/scripts/targetcommand-newt.sh +++ b/make/scripts/targetcommand-newt.sh @@ -2,9 +2,11 @@ THISDIR=`pwd` +ROOT_REL=build-linux-armv6hf + export LD_LIBRARY_PATH=$THISDIR/PVRTrace/:$LD_LIBRARY_PATH -XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch " +#XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch " #XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #XTRA_FLAGS="-Dnewt.debug.Screen" @@ -26,7 +28,7 @@ XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL -Djogl.deb #TSTCLASS=com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 # (Tegra regressions) #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT -TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT # Some Regressions (Panda, Omap4) @@ -49,6 +51,7 @@ TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT +TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.drawable.TestDrawable01NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 @@ -81,6 +84,7 @@ TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT rsync -av --delete --delete-after --delete-excluded \ --exclude 'build-x86*/' --exclude 'build-linux-x*/' --exclude 'build-android*/' --exclude 'build-win*/' --exclude 'build-mac*/' \ --exclude 'classes/' --exclude 'src/' --exclude '.git/' --exclude '*-java-src.zip' \ + --exclude 'make/lib/external/' \ jogamp@jogamp02::PROJECTS/JOGL/gluegen jogamp@jogamp02::PROJECTS/JOGL/jogl $THISDIR/projects-cross cd $THISDIR/projects-cross/jogl/make @@ -89,10 +93,9 @@ TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT function junit_run() { java \ - -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/build-linux-armv7/gluegen-rt.jar:../build-linux-armv7/jar/jogl.all-noawt.jar:../build-linux-armv7/jar/jogl.test.jar\ + -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/$ROOT_REL/gluegen-rt.jar:../$ROOT_REL/jar/jogl-all-noawt.jar:../$ROOT_REL/jar/jogl-test.jar\ -Djava.awt.headless=true\ $XTRA_FLAGS \ - com.jogamp.newt.util.MainThread\ org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner \ $TSTCLASS \ filtertrace=true \ @@ -108,10 +111,9 @@ function junit_run() { function main_run() { java \ - -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/build-linux-armv7/gluegen-rt.jar:../build-linux-armv7/jar/jogl.all-noawt.jar:../build-linux-armv7/jar/jogl.test.jar\ + -cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/$ROOT_REL/gluegen-rt.jar:../$ROOT_REL/jar/jogl-all-noawt.jar:../$ROOT_REL/jar/jogl-test.jar\ -Djava.awt.headless=true\ $XTRA_FLAGS \ - com.jogamp.newt.util.MainThread\ $TSTCLASS \ $* } diff --git a/make/scripts/tests-armv6_armel.sh b/make/scripts/tests-armv6_armel.sh new file mode 100755 index 000000000..8bc3eff65 --- /dev/null +++ b/make/scripts/tests-armv6_armel.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +spath=`dirname $0` + +. $spath/tests.sh `which java` -DummyArg ../build-linux-armv6 $* + + diff --git a/make/scripts/tests-armv6_armhf.sh b/make/scripts/tests-armv6_armhf.sh new file mode 100755 index 000000000..6b66a47de --- /dev/null +++ b/make/scripts/tests-armv6_armhf.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +spath=`dirname $0` + +. $spath/tests.sh `which java` -DummyArg ../build-linux-armv6hf $* + + diff --git a/make/scripts/tests-armv7l_eabi.sh b/make/scripts/tests-armv7l_eabi.sh deleted file mode 100755 index 2ed3070b4..000000000 --- a/make/scripts/tests-armv7l_eabi.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash - -spath=`dirname $0` - -. $spath/tests.sh `which java` -DummyArg ../build-armv7l_eabi $* - - diff --git a/make/scripts/tests-linux-armv6.sh b/make/scripts/tests-linux-armv6.sh new file mode 100755 index 000000000..8bc3eff65 --- /dev/null +++ b/make/scripts/tests-linux-armv6.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +spath=`dirname $0` + +. $spath/tests.sh `which java` -DummyArg ../build-linux-armv6 $* + + diff --git a/make/scripts/tests-linux-armv6hf.sh b/make/scripts/tests-linux-armv6hf.sh new file mode 100755 index 000000000..6b66a47de --- /dev/null +++ b/make/scripts/tests-linux-armv6hf.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +spath=`dirname $0` + +. $spath/tests.sh `which java` -DummyArg ../build-linux-armv6hf $* + + diff --git a/make/scripts/tests-linux-armv7.sh b/make/scripts/tests-linux-armv7.sh deleted file mode 100755 index 6ec93db68..000000000 --- a/make/scripts/tests-linux-armv7.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash - -spath=`dirname $0` - -. $spath/tests.sh `which java` -DummyArg ../build-linux-armv7 $* - - diff --git a/make/scripts/tests-linux-armv7hf.sh b/make/scripts/tests-linux-armv7hf.sh deleted file mode 100755 index 5526e81c3..000000000 --- a/make/scripts/tests-linux-armv7hf.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash - -spath=`dirname $0` - -. $spath/tests.sh `which java` -DummyArg ../build-linux-armv7hf $* - - diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 43d04c6bd..d0a5f64ff 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -53,6 +53,7 @@ function jrun() { swton=$1 shift + #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Dnewt.debug.Window.MouseEvent" #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" @@ -61,6 +62,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" + D_ARGS="-Djogl.debug=all" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" @@ -214,10 +216,10 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* -- cgit v1.2.3 From da697607fce1e6d2b0c65fcc37030c88981b76ec Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 17 Aug 2012 15:33:12 +0200 Subject: Fix EGLDrawableFactory.getEGLSurface(..): Catch WrappedSurface case w/ EGLDevice and EGLGraphicsConfiguration - Regression of 43a473b2005d7f59a7f4f5b8bc7ca9ae88b4e894 Do not create a WrappedSurface around a given WrappedSurface if the latter is intended for EGL, i.e. uses EGLDevice and EGLGraphicsConfiguration even though the surface handle is not valid [yet]. For this case we assume the WrappedSurface has a lifecycle hook as it is used for the dummy drawable. Otherwise we would have a recursive WrappedSurface, ie with EGLDrawableFactory.createOnscreenDrawableImpl( dummySurface ), where dummySurface is a WrappedSurface w/ EGL pbuffer drawable lifecycle hook. Commit 43a473b2005d7f59a7f4f5b8bc7ca9ae88b4e894 didn't take the above case into account. --- make/scripts/targetcommand-newt.sh | 4 +++- make/scripts/tests.sh | 7 +++---- src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java | 9 ++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/targetcommand-newt.sh b/make/scripts/targetcommand-newt.sh index 8b3c0945a..84b149b37 100755 --- a/make/scripts/targetcommand-newt.sh +++ b/make/scripts/targetcommand-newt.sh @@ -44,6 +44,7 @@ export LD_LIBRARY_PATH=$THISDIR/PVRTrace/:$LD_LIBRARY_PATH #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT +TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT @@ -51,10 +52,11 @@ export LD_LIBRARY_PATH=$THISDIR/PVRTrace/:$LD_LIBRARY_PATH #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT -TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.drawable.TestDrawable01NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d0a5f64ff..824daeaeb 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -61,8 +61,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" - #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" - D_ARGS="-Djogl.debug=all" + #D_ARGS="-Djogl.debug=all" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" @@ -216,7 +215,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* @@ -235,7 +234,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index f7377a648..e145a959c 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -471,10 +471,17 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration(); AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); if( aDevice instanceof EGLGraphicsDevice && aConfig instanceof EGLGraphicsConfiguration ) { + if(surface instanceof WrappedSurface) { + // already wrapped surface - no wrapped recursion + if(DEBUG) { + System.err.println(getThreadName() + ": getEGLSurface - already wrapped surface - use as-is: "+surface); + } + return surface; + } if(EGLDrawable.isValidEGLSurface((EGLGraphicsDevice)aDevice, surface)) { // already in native EGL format if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - already valid EGL surface - use as-is: "+aConfig); + System.err.println(getThreadName() + ": getEGLSurface - already valid EGL surface - use as-is: "+surface); } return surface; } -- cgit v1.2.3 From fe78d5095ef98215ce6c73d8912dfa19ae708bd0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 17 Aug 2012 17:11:03 +0200 Subject: Robostness FBObject / GLReadBufferUtil: Ignore pre-existing GL errors - remove GL error checking in FBObject bind/unbind. - User GL code caused errors shall not fail impl. - FBObject bind/unbind GL error checking is almost useless due to it's simple code, would only catch user GL code errors, which should be ignored here. - MultisampleDemoES2: Only enable GL_MULTISAMPLE if available, i.e. validate passed multisample flag --- make/scripts/targetcommand-newt.sh | 1 + src/jogl/classes/com/jogamp/opengl/FBObject.java | 4 +--- src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java | 4 ++++ .../opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java | 7 +++++-- 4 files changed, 11 insertions(+), 5 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/targetcommand-newt.sh b/make/scripts/targetcommand-newt.sh index 84b149b37..8cb3c2471 100755 --- a/make/scripts/targetcommand-newt.sh +++ b/make/scripts/targetcommand-newt.sh @@ -8,6 +8,7 @@ export LD_LIBRARY_PATH=$THISDIR/PVRTrace/:$LD_LIBRARY_PATH #XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch " #XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" +#XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.DebugGL" #XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #XTRA_FLAGS="-Dnewt.debug.Screen" #XTRA_FLAGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java index 663b4fb9d..8a6495e6b 100644 --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java @@ -725,7 +725,7 @@ public class FBObject { glerr = gl.glGetError(); if(DEBUG && GL.GL_NO_ERROR != glerr) { - System.err.println("FBObject.init-preexisting.1 GL Error 0x"+Integer.toHexString(glerr)); + System.err.println("Info: FBObject.init: pre-existing GL error 0x"+Integer.toHexString(glerr)); } this.width = width; @@ -1741,7 +1741,6 @@ public class FBObject { gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, getWriteFramebuffer()); } - checkNoError(null, gl.glGetError(), "FBObject post-bind"); // throws GLException if error bound = true; samplesSinkDirty = true; } @@ -1766,7 +1765,6 @@ public class FBObject { } else { gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer } - checkNoError(null, gl.glGetError(), "FBObject post-unbind"); // throws GLException if error bound = false; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index b0fae8a6d..34cc0eb07 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -116,6 +116,10 @@ public class GLReadBufferUtil { * @see #GLReadBufferUtil(boolean, boolean) */ public boolean readPixels(GL gl, boolean flip) { + final int glerr0 = gl.glGetError(); + if(GL.GL_NO_ERROR != glerr0) { + System.err.println("Info: GLReadBufferUtil.readPixels: pre-exisiting GL error 0x"+Integer.toHexString(glerr0)); + } final GLDrawable drawable = gl.getContext().getGLReadDrawable(); final int textureInternalFormat, textureDataFormat, textureDataType; final int[] glImplColorReadVals = new int[] { 0, 0 }; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java index 5facc1a49..c80455314 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/MultisampleDemoES2.java @@ -74,12 +74,15 @@ public class MultisampleDemoES2 implements GLEventListener { public void init(GLAutoDrawable glad) { final GL2ES2 gl = glad.getGL().getGL2ES2(); + System.err.println(); + System.err.println("req. msaa: "+multisample); System.err.println("Requested: " + glad.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()); - System.err.println(); + multisample = multisample & glad.getChosenGLCapabilities().getNumSamples() > 0 ; System.err.println("Chosen : " + glad.getChosenGLCapabilities()); + System.err.println("has msaa: "+multisample); System.err.println(); - + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MultisampleDemoES2.class, "shader", "shader/bin", "mgl_default_xxx", true); final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MultisampleDemoES2.class, "shader", -- cgit v1.2.3 From ec0f4a5ab604c73d40d3585c0147b451ad53dcf5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 17 Aug 2012 20:50:44 +0200 Subject: GLDrawableFactory.createGLDrawable() offscreen: Fix caps - set double-buffer := false to be consistent w/ GLDrawableFactory.createOffscreenDrawable() TestGLDrawable01NEWT: Enhance test case to run w/ EGLDrawableFactory (ES2) besides GL2 and GLX/WGL/..-Factory --- make/scripts/targetcommand-awt.sh | 3 +- make/scripts/targetcommand-newt.sh | 6 +- make/scripts/tests.sh | 4 +- .../jogamp/opengl/GLDrawableFactoryImpl.java | 9 +- .../junit/jogl/acore/TestGLDrawable01NEWT.java | 171 +++++++++++++++++++ .../junit/jogl/drawable/TestDrawable01NEWT.java | 183 --------------------- 6 files changed, 186 insertions(+), 190 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/drawable/TestDrawable01NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/targetcommand-awt.sh b/make/scripts/targetcommand-awt.sh index 7f95e33a2..d776abd16 100755 --- a/make/scripts/targetcommand-awt.sh +++ b/make/scripts/targetcommand-awt.sh @@ -16,8 +16,9 @@ XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Dnativewindow #XTRA_FLAGS="-Djogl.debug.TraceGL" #XTRA_FLAGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" -TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT +TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01AWT mkdir -p $THISDIR/projects-cross diff --git a/make/scripts/targetcommand-newt.sh b/make/scripts/targetcommand-newt.sh index 8cb3c2471..1cf7c306b 100755 --- a/make/scripts/targetcommand-newt.sh +++ b/make/scripts/targetcommand-newt.sh @@ -30,7 +30,10 @@ export LD_LIBRARY_PATH=$THISDIR/PVRTrace/:$LD_LIBRARY_PATH #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT +TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT # Some Regressions (Panda, Omap4) # @@ -45,8 +48,6 @@ export LD_LIBRARY_PATH=$THISDIR/PVRTrace/:$LD_LIBRARY_PATH #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT -TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT -#TSTCLASS=com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT @@ -55,7 +56,6 @@ TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -#TSTCLASS=com.jogamp.opengl.test.junit.jogl.drawable.TestDrawable01NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 #TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 824daeaeb..6aa69fa34 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -234,7 +234,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* @@ -411,6 +411,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01NEWT $* # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index f7808294b..2f2bf5961 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -143,6 +143,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // layered surface -> Offscreen/[FBO|PBuffer] final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); chosenCapsMod.setOnscreen(false); + chosenCapsMod.setDoubleBuffered(false); /* if( isFBOAvailable ) { // FIXME JAU: FBO n/a yet chosenCapsMod.setFBO(true); } else */ @@ -174,17 +175,21 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { result = createOnscreenDrawableImpl(target); } else { // offscreen + final GLCapabilitiesImmutable reqCaps = (GLCapabilitiesImmutable)config.getRequestedCapabilities(); if(DEBUG) { - System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable, FBO-chosen(-avail)/PBuffer: "+chosenCaps.isFBO()+"("+isFBOAvailable+")/"+chosenCaps.isPBuffer()+": "+target); + System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable, FBO req / chosen - avail, PBuffer: "+reqCaps.isFBO()+" / "+chosenCaps.isFBO()+" - "+isFBOAvailable+", "+chosenCaps.isPBuffer()+": "+target); } if( ! ( target instanceof MutableSurface ) ) { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target); } - if( ((GLCapabilitiesImmutable)config.getRequestedCapabilities()).isFBO() && isFBOAvailable ) { + if( reqCaps.isFBO() && isFBOAvailable ) { // FIXME JAU: Need to revise passed MutableSurface to work w/ FBO .. final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(target); result = new GLFBODrawableImpl(this, dummyDrawable, target, target.getWidth(), target.getHeight(), 0 /* textureUnit */); } else { + final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); + chosenCapsMod.setDoubleBuffered(false); + config.setChosenCapabilities(chosenCapsMod); result = createOffscreenDrawableImpl(target); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java new file mode 100644 index 000000000..a6e9cfb07 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java @@ -0,0 +1,171 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +public class TestGLDrawable01NEWT extends UITestCase { + static final int width = 200, height = 200; + + void doTest(String profile, boolean onscreen, boolean fbo, boolean pbuffer) throws InterruptedException { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return; + } + + final GLProfile glp = GLProfile.get(profile); + final GLCapabilities reqGLCaps = new GLCapabilities(glp); + + reqGLCaps.setOnscreen(onscreen); + reqGLCaps.setPBuffer(!onscreen && pbuffer); + reqGLCaps.setFBO(!onscreen && fbo); + reqGLCaps.setDoubleBuffered(onscreen); + // System.out.println("Requested: "+caps); + + // + // Create native windowing resources .. X11/Win/OSX + // + Window window = NewtFactory.createWindow(reqGLCaps); + Assert.assertNotNull(window); + window.setSize(width, height); + window.setVisible(true); + AWTRobotUtil.waitForVisible(window, true); + AWTRobotUtil.waitForRealized(window, true); + // System.out.println("Created: "+window); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = window.getGraphicsConfiguration().getChosenCapabilities(); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); + + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + // System.out.println("Pre: "+drawable); + // + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities(); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(reqGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(reqGLCaps.isOnscreen(), chosenGLCaps.getDoubleBuffered()); // offscreen shall be !dbl-buffer + // System.out.println("Post: "+drawable); + + GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + // System.out.println(context); + + int res = context.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + + // draw something .. + final GL gl = context.getGL(); + gl.glClearColor(1, 1, 1, 1); + gl.glEnable(GL.GL_DEPTH_TEST); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + gl.glViewport(0, 0, width, height); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); + + drawable.swapBuffers(); + context.release(); + + Thread.sleep(50); + + context.destroy(); + drawable.setRealized(false); + window.destroy(); + // System.out.println("Final: "+window); + } + + @Test + public void testGL2OnScreen() throws InterruptedException { + doTest(GLProfile.GL2, true, false, false); + } + + @Test + public void testES2OnScreen() throws InterruptedException { + doTest(GLProfile.GLES2, true, false, false); + } + + @Test + public void testGL2PBuffer() throws InterruptedException { + doTest(GLProfile.GL2, false, false, true); + } + + @Test + public void testES2PBuffer() throws InterruptedException { + doTest(GLProfile.GLES2, false, false, true); + } + + // @Test // TODO: FBO-Drawable via createGLDrawable and pre-exisiting NativeSurface + public void testGL2FBO() throws InterruptedException { + doTest(GLProfile.GL2, false, true, false); + } + + // @Test // TODO: FBO-Drawable via createGLDrawable and pre-exisiting NativeSurface + public void testES2FBO() throws InterruptedException { + doTest(GLProfile.GLES2, false, true, false); + } + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLDrawable01NEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/drawable/TestDrawable01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/drawable/TestDrawable01NEWT.java deleted file mode 100644 index 731f7c867..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/drawable/TestDrawable01NEWT.java +++ /dev/null @@ -1,183 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.drawable; - -import com.jogamp.opengl.test.junit.util.UITestCase; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -import javax.media.opengl.*; - -import com.jogamp.newt.*; -import java.io.IOException; - -public class TestDrawable01NEWT extends UITestCase { - static GLProfile glp; - static GLDrawableFactory factory; - static int width, height; - GLCapabilities caps; - Window window; - GLDrawable drawable; - GLContext context; - - @BeforeClass - public static void initClass() { - glp = GLProfile.getDefault(); - Assert.assertNotNull(glp); - factory = GLDrawableFactory.getFactory(glp); - Assert.assertNotNull(factory); - width = 640; - height = 480; - } - - @AfterClass - public static void releaseClass() { - Assert.assertNotNull(factory); - factory=null; - } - - @Before - public void initTest() { - caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - } - - void createWindow(boolean onscreen, boolean pbuffer, boolean undecorated) { - caps.setOnscreen(onscreen); - caps.setPBuffer(!onscreen && pbuffer); - caps.setDoubleBuffered(onscreen); - // System.out.println("Requested: "+caps); - - // - // Create native windowing resources .. X11/Win/OSX - // - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - - window = NewtFactory.createWindow(screen, caps); - Assert.assertNotNull(window); - window.setUndecorated(onscreen && undecorated); - window.setSize(width, height); - window.setVisible(true); - // System.out.println("Created: "+window); - - // - // Create native OpenGL resources .. XGL/WGL/CGL .. - // equivalent to GLAutoDrawable methods: setVisible(true) - // - GLCapabilities glCaps = (GLCapabilities) window.getGraphicsConfiguration().getChosenCapabilities(); - Assert.assertNotNull(glCaps); - Assert.assertTrue(glCaps.getGreenBits()>5); - Assert.assertTrue(glCaps.getBlueBits()>5); - Assert.assertTrue(glCaps.getRedBits()>5); - Assert.assertEquals(glCaps.isOnscreen(),onscreen); - Assert.assertTrue(onscreen || !pbuffer || glCaps.isPBuffer()); // pass if onscreen, or !pbuffer req. or have pbuffer - Assert.assertEquals(glCaps.getDoubleBuffered(),onscreen); - Assert.assertTrue(glCaps.getDepthBits()>4); - - drawable = factory.createGLDrawable(window); - Assert.assertNotNull(drawable); - // System.out.println("Pre: "+drawable); - // - drawable.setRealized(true); - // Assert.assertEquals(width,drawable.getWidth()); - // Assert.assertEquals(height,drawable.getHeight()); - // Assert.assertEquals(glCaps,drawable.getChosenGLCapabilities()); - Assert.assertEquals(window,drawable.getNativeSurface()); - // System.out.println("Post: "+drawable); - - context = drawable.createContext(null); - Assert.assertNotNull(context); - // System.out.println(context); - - int res = context.makeCurrent(); - Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); - - // draw something .. - - drawable.swapBuffers(); - context.release(); - - // System.out.println("Final: "+window); - } - - void destroyWindow() { - // GLWindow.dispose(..) sequence - Assert.assertNotNull(context); - context.destroy(); - - Assert.assertNotNull(drawable); - drawable.setRealized(false); - - // GLWindow.destroy(..) sequence cont.. - Assert.assertNotNull(window); - window.destroy(); - - drawable = null; - context = null; - window = null; - } - - @Test - public void testOnScreenDecorated() throws InterruptedException { - createWindow(true, false, false); - Thread.sleep(1000); // 1000 ms - destroyWindow(); - } - - @Test - public void testOnScreenUndecorated() throws InterruptedException { - createWindow(true, false, true); - Thread.sleep(1000); // 1000 ms - destroyWindow(); - } - - public static void main(String args[]) throws IOException { - String tstname = TestDrawable01NEWT.class.getName(); - org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { - tstname, - "filtertrace=true", - "haltOnError=false", - "haltOnFailure=false", - "showoutput=true", - "outputtoformatters=true", - "logfailedtests=true", - "logtestlistenerevents=true", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); - } - -} -- cgit v1.2.3 From 5a5c2bc7a113906453e0de6f0403f394acdb9a4f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 18 Aug 2012 00:45:13 +0200 Subject: Fix GLCanvas's JAWTWindow reference ; Add ES2 test in TestAWT01GLn ; Ubuntu 12.04/Pandaboard(Omap4, PowerVR SGX 540) 103/108 tests passed (before freeze) of 124 total Fix GLCanvas's JAWTWindow reference - drawable.getNativeSurface() may not be a JAWTWindow due to our EGL WrappedSurface. Hence store the created JAWTWindow reference locally. Add ES2 test in TestAWT01GLn - test EGL/ES2 w/ AWT GLCanvas Ubuntu 12.04/Pandaboard(Omap4, PowerVR SGX 540): 103/108 tests passed (before freeze) of 124 total - machine freezes around test 108 .. - new passed unit test high for ES2 incl. AWT tests --- make/scripts/targetcommand-awt.sh | 2 +- make/scripts/tests.sh | 4 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 11 ++-- .../opengl/test/junit/jogl/awt/TestAWT01GLn.java | 60 +++++++++++----------- 4 files changed, 37 insertions(+), 40 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/targetcommand-awt.sh b/make/scripts/targetcommand-awt.sh index d776abd16..6bd4dd22c 100755 --- a/make/scripts/targetcommand-awt.sh +++ b/make/scripts/targetcommand-awt.sh @@ -18,7 +18,7 @@ XTRA_FLAGS="-Dnewt.test.Screen.disableScreenMode -Djogl.debug.EGL -Dnativewindow #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01AWT +TSTCLASS=com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn mkdir -p $THISDIR/projects-cross diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6aa69fa34..5a8d596df 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -274,7 +274,7 @@ function testawtswt() { #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* @@ -411,8 +411,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01NEWT $* # osx: #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 03fd78ac7..033591fe3 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -146,6 +146,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final GLDrawableHelper helper = new GLDrawableHelper(); private AWTGraphicsConfiguration awtConfig; private volatile GLDrawable drawable; // volatile: avoid locking for read-only access + private volatile JAWTWindow jawtWindow; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle private GLContextImpl context; private volatile boolean sendReshape = false; // volatile: maybe written by EDT w/o locking @@ -268,9 +269,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public final boolean isOffscreenLayerSurfaceEnabled() { - final GLDrawable _drawable = drawable; - if(null != _drawable) { - return ((JAWTWindow)_drawable.getNativeSurface()).isOffscreenLayerSurfaceEnabled(); + final JAWTWindow _jawtWindow = jawtWindow; + if(null != _jawtWindow) { + return _jawtWindow.isOffscreenLayerSurfaceEnabled(); } return false; } @@ -539,7 +540,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private void createDrawableAndContext() { // no lock required, since this resource ain't available yet - final JAWTWindow jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); + jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); jawtWindow.lockSurface(); try { @@ -811,11 +812,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void run() { context=null; if(null!=drawable) { - final JAWTWindow jawtWindow = (JAWTWindow)drawable.getNativeSurface(); drawable.setRealized(false); drawable=null; if(null!=jawtWindow) { jawtWindow.destroy(); + jawtWindow=null; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT01GLn.java index 64a1a0138..e1048c2f8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT01GLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWT01GLn.java @@ -40,49 +40,23 @@ import java.awt.Frame; import org.junit.Assert; import org.junit.Assume; -import org.junit.Before; import org.junit.BeforeClass; -import org.junit.After; import org.junit.Test; public class TestAWT01GLn extends UITestCase { - Frame frame=null; - GLCanvas glCanvas=null; - @BeforeClass public static void startup() { System.out.println("GLProfile "+GLProfile.glAvailabilityToString()); } - @Before - public void init() { - frame = new Frame("Texture Test"); - Assert.assertNotNull(frame); - } - - @After - public void release() { - Assert.assertNotNull(frame); - Assert.assertNotNull(glCanvas); - try { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - frame.remove(glCanvas); - frame.dispose(); - }}); - } catch (Throwable t) { - t.printStackTrace(); - Assume.assumeNoException(t); - } - frame=null; - glCanvas=null; - } - protected void runTestGL(GLCapabilities caps) throws InterruptedException { - glCanvas = new GLCanvas(caps); + final Frame frame = new Frame("Texture Test"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); + glCanvas.addGLEventListener(new GearsES2()); frame.add(glCanvas); @@ -110,6 +84,18 @@ public class TestAWT01GLn extends UITestCase { Thread.sleep(500); // 500 ms animator.stop(); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.remove(glCanvas); + frame.dispose(); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } } @Test @@ -136,6 +122,18 @@ public class TestAWT01GLn extends UITestCase { } } + @Test + public void test02ES2() throws InterruptedException { + if(GLProfile.isAvailable(GLProfile.GLES2)) { + GLProfile glprofile = GLProfile.get(GLProfile.GLES2); + System.out.println( "GLProfile GLES2: " + glprofile ); + GLCapabilities caps = new GLCapabilities(glprofile); + runTestGL(caps); + } else { + System.out.println("GLES2 n/a"); + } + } + public static void main(String args[]) { org.junit.runner.JUnitCore.main(TestAWT01GLn.class.getName()); } -- cgit v1.2.3 From a694cadca4ab72481e777222f412f006f973f77e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 18 Aug 2012 14:12:54 +0200 Subject: NEWT Platform Driver: Uniform impl. class names [DisplayDriver, ScreenDriver, WindowDriver] to reduce complexity and programatic selection. --- make/build-newt.xml | 36 +- make/scripts/tests.sh | 4 +- .../media/nativewindow/NativeWindowFactory.java | 12 +- .../classes/com/jogamp/newt/util/MainThread.java | 2 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 22 +- src/newt/classes/jogamp/newt/ScreenImpl.java | 28 +- src/newt/classes/jogamp/newt/WindowImpl.java | 21 +- .../jogamp/newt/driver/android/AndroidDisplay.java | 66 --- .../jogamp/newt/driver/android/AndroidScreen.java | 138 ------- .../jogamp/newt/driver/android/AndroidWindow.java | 458 --------------------- .../jogamp/newt/driver/android/DisplayDriver.java | 66 +++ .../newt/driver/android/NewtBaseActivity.java | 10 +- .../newt/driver/android/NewtVersionActivity.java | 2 +- .../jogamp/newt/driver/android/ScreenDriver.java | 138 +++++++ .../jogamp/newt/driver/android/WindowDriver.java | 458 +++++++++++++++++++++ .../classes/jogamp/newt/driver/awt/AWTCanvas.java | 1 + .../classes/jogamp/newt/driver/awt/AWTDisplay.java | 73 ---- .../classes/jogamp/newt/driver/awt/AWTScreen.java | 81 ---- .../classes/jogamp/newt/driver/awt/AWTWindow.java | 233 ----------- .../jogamp/newt/driver/awt/DisplayDriver.java | 73 ++++ .../jogamp/newt/driver/awt/ScreenDriver.java | 81 ++++ .../jogamp/newt/driver/awt/WindowDriver.java | 233 +++++++++++ .../jogamp/newt/driver/bcm/egl/Display.java | 85 ---- .../jogamp/newt/driver/bcm/egl/DisplayDriver.java | 85 ++++ .../classes/jogamp/newt/driver/bcm/egl/Screen.java | 75 ---- .../jogamp/newt/driver/bcm/egl/ScreenDriver.java | 75 ++++ .../classes/jogamp/newt/driver/bcm/egl/Window.java | 170 -------- .../jogamp/newt/driver/bcm/egl/WindowDriver.java | 170 ++++++++ .../jogamp/newt/driver/bcm/vc/iv/Display.java | 78 ---- .../newt/driver/bcm/vc/iv/DisplayDriver.java | 78 ++++ .../jogamp/newt/driver/bcm/vc/iv/Screen.java | 73 ---- .../jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java | 73 ++++ .../jogamp/newt/driver/bcm/vc/iv/Window.java | 149 ------- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 149 +++++++ .../jogamp/newt/driver/intel/gdl/Display.java | 104 ----- .../newt/driver/intel/gdl/DisplayDriver.java | 105 +++++ .../jogamp/newt/driver/intel/gdl/Screen.java | 85 ---- .../jogamp/newt/driver/intel/gdl/ScreenDriver.java | 86 ++++ .../jogamp/newt/driver/intel/gdl/Window.java | 146 ------- .../jogamp/newt/driver/intel/gdl/WindowDriver.java | 147 +++++++ .../classes/jogamp/newt/driver/kd/Display.java | 77 ---- .../jogamp/newt/driver/kd/DisplayDriver.java | 77 ++++ src/newt/classes/jogamp/newt/driver/kd/Screen.java | 75 ---- .../jogamp/newt/driver/kd/ScreenDriver.java | 75 ++++ src/newt/classes/jogamp/newt/driver/kd/Window.java | 163 -------- .../jogamp/newt/driver/kd/WindowDriver.java | 163 ++++++++ .../jogamp/newt/driver/macosx/DisplayDriver.java | 88 ++++ .../jogamp/newt/driver/macosx/MacDisplay.java | 87 ---- .../jogamp/newt/driver/macosx/MacKeyUtil.java | 27 ++ .../jogamp/newt/driver/macosx/MacScreen.java | 143 ------- .../jogamp/newt/driver/macosx/MacWindow.java | 431 ------------------- .../jogamp/newt/driver/macosx/ScreenDriver.java | 143 +++++++ .../jogamp/newt/driver/macosx/WindowDriver.java | 431 +++++++++++++++++++ .../jogamp/newt/driver/windows/DisplayDriver.java | 95 +++++ .../jogamp/newt/driver/windows/ScreenDriver.java | 124 ++++++ .../jogamp/newt/driver/windows/WindowDriver.java | 311 ++++++++++++++ .../jogamp/newt/driver/windows/WindowsDisplay.java | 95 ----- .../jogamp/newt/driver/windows/WindowsScreen.java | 124 ------ .../jogamp/newt/driver/windows/WindowsWindow.java | 311 -------------- .../jogamp/newt/driver/x11/DisplayDriver.java | 171 ++++++++ .../jogamp/newt/driver/x11/ScreenDriver.java | 357 ++++++++++++++++ .../jogamp/newt/driver/x11/WindowDriver.java | 261 ++++++++++++ .../classes/jogamp/newt/driver/x11/X11Display.java | 171 -------- .../classes/jogamp/newt/driver/x11/X11Screen.java | 357 ---------------- .../classes/jogamp/newt/driver/x11/X11Window.java | 261 ------------ src/newt/native/AndroidWindow.c | 18 +- src/newt/native/IntelGDL.c | 24 +- src/newt/native/KDWindow.c | 20 +- src/newt/native/MacWindow.m | 116 +++--- src/newt/native/WindowsWindow.c | 78 ++-- src/newt/native/X11Common.h | 6 +- src/newt/native/X11Display.c | 22 +- src/newt/native/X11Screen.c | 62 +-- src/newt/native/X11Window.c | 42 +- src/newt/native/bcm_egl.c | 16 +- src/newt/native/bcm_vc_iv.c | 30 +- .../opengl/test/android/MovieSimpleActivity0.java | 6 +- .../opengl/test/android/MovieSimpleActivity1.java | 10 +- 78 files changed, 4608 insertions(+), 4629 deletions(-) delete mode 100644 src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java delete mode 100644 src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java create mode 100644 src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/android/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java delete mode 100644 src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java create mode 100644 src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/kd/Display.java create mode 100644 src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/kd/Screen.java create mode 100644 src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/kd/Window.java create mode 100644 src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java delete mode 100644 src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java create mode 100644 src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java delete mode 100644 src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/X11Display.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/X11Screen.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/X11Window.java (limited to 'make/scripts') diff --git a/make/build-newt.xml b/make/build-newt.xml index 0a12374dd..64dccc6ac 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -670,30 +670,30 @@ - + - - - + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5a8d596df..cccc825ee 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -247,7 +247,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* @@ -274,7 +274,7 @@ function testawtswt() { #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 94f5d753c..867d0733b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -57,22 +57,22 @@ public abstract class NativeWindowFactory { protected static final boolean DEBUG; /** OpenKODE/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}*/ - public static final String TYPE_EGL = "EGL"; + public static final String TYPE_EGL = "jogamp.newt.driver.kd"; /** Microsoft Windows type, as retrieved with {@link #getNativeWindowType(boolean)} */ - public static final String TYPE_WINDOWS = "Windows"; + public static final String TYPE_WINDOWS = "jogamp.newt.driver.windows"; /** X11 type, as retrieved with {@link #getNativeWindowType(boolean)} */ - public static final String TYPE_X11 = "X11"; + public static final String TYPE_X11 = "jogamp.newt.driver.x11"; /** Android/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}*/ - public static final String TYPE_ANDROID = "ANDROID"; + public static final String TYPE_ANDROID = "jogamp.newt.driver.android"; /** Mac OS X type, as retrieved with {@link #getNativeWindowType(boolean)} */ - public static final String TYPE_MACOSX = "MacOSX"; + public static final String TYPE_MACOSX = "jogamp.newt.driver.macosx"; /** Generic AWT type, as retrieved with {@link #getNativeWindowType(boolean)} */ - public static final String TYPE_AWT = "AWT"; + public static final String TYPE_AWT = "jogamp.newt.driver.awt"; /** Generic DEFAULT type, where platform implementation don't care, as retrieved with {@link #getNativeWindowType(boolean)} */ public static final String TYPE_DEFAULT = "default"; diff --git a/src/newt/classes/com/jogamp/newt/util/MainThread.java b/src/newt/classes/com/jogamp/newt/util/MainThread.java index a6e2ae02b..9c2f2a0b7 100644 --- a/src/newt/classes/com/jogamp/newt/util/MainThread.java +++ b/src/newt/classes/com/jogamp/newt/util/MainThread.java @@ -74,7 +74,7 @@ import jogamp.newt.NEWTJNILibLoader; * * To support your NEWT Window platform, * you have to pass your main thread actions to {@link #invoke invoke(..)}, - * have a look at the {@link com.jogamp.newt.macosx.MacWindow MacWindow} implementation.
    + * have a look at the {@link jogamp.newt.driver.macosx.WindowDriver NEWT Mac OSX Window} driver implementation.
    * TODO: Some hardcoded dependencies exist in this implementation, * where you have to patch this code or factor it out.

    * diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 867a1f176..bac4031f0 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -44,7 +44,6 @@ import com.jogamp.newt.util.EDTUtil; import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; public abstract class DisplayImpl extends Display { private static int serialno = 1; @@ -52,26 +51,9 @@ public abstract class DisplayImpl extends Display { private static Class getDisplayClass(String type) throws ClassNotFoundException { - Class displayClass = NewtFactory.getCustomClass(type, "Display"); + final Class displayClass = NewtFactory.getCustomClass(type, "DisplayDriver"); if(null==displayClass) { - if (NativeWindowFactory.TYPE_ANDROID == type) { - displayClass = Class.forName("jogamp.newt.driver.android.AndroidDisplay"); - } else if (NativeWindowFactory.TYPE_EGL == type) { - displayClass = Class.forName("jogamp.newt.driver.kd.Display"); - } else if (NativeWindowFactory.TYPE_WINDOWS == type) { - displayClass = Class.forName("jogamp.newt.driver.windows.WindowsDisplay"); - } else if (NativeWindowFactory.TYPE_MACOSX == type) { - displayClass = Class.forName("jogamp.newt.driver.macosx.MacDisplay"); - } else if (NativeWindowFactory.TYPE_X11 == type) { - displayClass = Class.forName("jogamp.newt.driver.x11.X11Display"); - } else if (NativeWindowFactory.TYPE_AWT == type) { - displayClass = Class.forName("jogamp.newt.driver.awt.AWTDisplay"); - } else { - throw new RuntimeException("Unknown display type \"" + type + "\""); - } - } - if(null==displayClass) { - throw new ClassNotFoundException("Failed to find NEWT Display Class <"+type+".Display>"); + throw new ClassNotFoundException("Failed to find NEWT Display Class <"+type+".DisplayDriver>"); } return displayClass; } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 9f75a0d25..e2c0f746f 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -90,31 +90,13 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { }); } - @SuppressWarnings("unchecked") - private static Class getScreenClass(String type) throws ClassNotFoundException + private static Class getScreenClass(String type) throws ClassNotFoundException { - Class screenClass = NewtFactory.getCustomClass(type, "Screen"); + final Class screenClass = NewtFactory.getCustomClass(type, "ScreenDriver"); if(null==screenClass) { - if (NativeWindowFactory.TYPE_ANDROID == type) { - screenClass = Class.forName("jogamp.newt.driver.android.AndroidScreen"); - } else if (NativeWindowFactory.TYPE_EGL == type) { - screenClass = Class.forName("jogamp.newt.driver.kd.Screen"); - } else if (NativeWindowFactory.TYPE_WINDOWS == type) { - screenClass = Class.forName("jogamp.newt.driver.windows.WindowsScreen"); - } else if (NativeWindowFactory.TYPE_MACOSX == type) { - screenClass = Class.forName("jogamp.newt.driver.macosx.MacScreen"); - } else if (NativeWindowFactory.TYPE_X11 == type) { - screenClass = Class.forName("jogamp.newt.driver.x11.X11Screen"); - } else if (NativeWindowFactory.TYPE_AWT == type) { - screenClass = Class.forName("jogamp.newt.driver.awt.AWTScreen"); - } else { - throw new RuntimeException("Unknown window type \"" + type + "\""); - } - } - if(null==screenClass) { - throw new ClassNotFoundException("Failed to find NEWT Screen Class <"+type+".Screen>"); + throw new ClassNotFoundException("Failed to find NEWT Screen Class <"+type+".ScreenDriver>"); } - return (Class)screenClass; + return screenClass; } public static Screen create(Display display, int idx) { @@ -133,7 +115,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { } } synchronized(screenList) { - Class screenClass = getScreenClass(display.getType()); + Class screenClass = getScreenClass(display.getType()); ScreenImpl screen = (ScreenImpl) screenClass.newInstance(); screen.display = (DisplayImpl) display; idx = screen.validateScreenIndex(idx); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 2971fa07e..ad7195944 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -152,26 +152,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private static Class getWindowClass(String type) throws ClassNotFoundException { - Class windowClass = NewtFactory.getCustomClass(type, "Window"); + final Class windowClass = NewtFactory.getCustomClass(type, "WindowDriver"); if(null==windowClass) { - if (NativeWindowFactory.TYPE_ANDROID == type) { - windowClass = Class.forName("jogamp.newt.driver.android.AndroidWindow"); - } else if (NativeWindowFactory.TYPE_EGL == type) { - windowClass = Class.forName("jogamp.newt.driver.kd.Window"); - } else if (NativeWindowFactory.TYPE_WINDOWS == type) { - windowClass = Class.forName("jogamp.newt.driver.windows.WindowsWindow"); - } else if (NativeWindowFactory.TYPE_MACOSX == type) { - windowClass = Class.forName("jogamp.newt.driver.macosx.MacWindow"); - } else if (NativeWindowFactory.TYPE_X11 == type) { - windowClass = Class.forName("jogamp.newt.driver.x11.X11Window"); - } else if (NativeWindowFactory.TYPE_AWT == type) { - windowClass = Class.forName("jogamp.newt.driver.awt.AWTWindow"); - } else { - throw new NativeWindowException("Unknown window type \"" + type + "\""); - } - } - if(null==windowClass) { - throw new ClassNotFoundException("Failed to find NEWT Window Class <"+type+".Window>"); + throw new ClassNotFoundException("Failed to find NEWT Window Class <"+type+".WindowDriver>"); } return windowClass; } diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java deleted file mode 100644 index 0a43c9b8f..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.android; - -import jogamp.newt.*; -import jogamp.opengl.egl.*; - -import javax.media.nativewindow.*; - -public class AndroidDisplay extends jogamp.newt.DisplayImpl { - static { - NEWTJNILibLoader.loadNEWT(); - - if (!AndroidWindow.initIDs0()) { - throw new NativeWindowException("Failed to initialize Android NEWT Windowing library"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public AndroidDisplay() { - } - - protected void createNativeImpl() { - // EGL Device - aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { - aDevice.close(); - } - - protected void dispatchMessagesNative() { - // n/a .. DispatchMessages(); - } -} - diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java b/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java deleted file mode 100644 index e108ed0bb..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidScreen.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.android; - -import javax.media.nativewindow.*; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -import android.content.Context; -import android.graphics.PixelFormat; -import android.util.DisplayMetrics; -import android.view.Surface; -import android.view.WindowManager; - -public class AndroidScreen extends jogamp.newt.ScreenImpl { - - static { - AndroidDisplay.initSingleton(); - } - - public AndroidScreen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { } - - protected ScreenMode getCurrentScreenModeImpl() { - final Context ctx = jogamp.common.os.android.StaticContext.getContext(); - final WindowManager wmgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); - final DisplayMetrics outMetrics = new DisplayMetrics(); - final android.view.Display aDisplay = wmgr.getDefaultDisplay(); - aDisplay.getMetrics(outMetrics); - - final int arot = aDisplay.getRotation(); - final int nrot = androidRotation2NewtRotation(arot); - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int offset = 1; // set later for verification of iterator - offset = getScreenSize(outMetrics, nrot, props, offset); - offset = getBpp(aDisplay, props, offset); - offset = getScreenSizeMM(outMetrics, props, offset); - props[offset++] = (int) aDisplay.getRefreshRate(); - props[offset++] = nrot; - props[offset - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = offset; // count - return ScreenModeUtil.streamIn(props, 0); - } - - protected int validateScreenIndex(int idx) { - return 0; // FIXME: only one screen available ? - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - final ScreenMode sm = getCurrentScreenMode(); - virtualSize.setWidth(sm.getRotatedWidth()); - virtualSize.setHeight(sm.getRotatedHeight()); - } - - //---------------------------------------------------------------------- - // Internals only - // - static int androidRotation2NewtRotation(int arot) { - switch(arot) { - case Surface.ROTATION_270: return ScreenMode.ROTATE_270; - case Surface.ROTATION_180: return ScreenMode.ROTATE_180; - case Surface.ROTATION_90: return ScreenMode.ROTATE_90; - case Surface.ROTATION_0: - } - return ScreenMode.ROTATE_0; - } - static int getScreenSize(DisplayMetrics outMetrics, int nrot, int[] props, int offset) { - // swap width and height, since Android reflects rotated dimension, we don't - if (ScreenMode.ROTATE_90 == nrot || ScreenMode.ROTATE_270 == nrot) { - props[offset++] = outMetrics.heightPixels; - props[offset++] = outMetrics.widthPixels; - } else { - props[offset++] = outMetrics.widthPixels; - props[offset++] = outMetrics.heightPixels; - } - return offset; - } - static int getBpp(android.view.Display aDisplay, int[] props, int offset) { - int bpp; - switch(aDisplay.getPixelFormat()) { - case PixelFormat.RGBA_8888: bpp=32; break; - case PixelFormat.RGBX_8888: bpp=32; break; - case PixelFormat.RGB_888: bpp=24; break; - case PixelFormat.RGB_565: bpp=16; break; - case PixelFormat.RGBA_5551: bpp=16; break; - case PixelFormat.RGBA_4444: bpp=16; break; - case PixelFormat.RGB_332: bpp= 8; break; - default: bpp=32; - } - props[offset++] = bpp; - return offset; - } - static int getScreenSizeMM(DisplayMetrics outMetrics, int[] props, int offset) { - final float iw = (float) outMetrics.widthPixels / outMetrics.xdpi; - final float ih = (float) outMetrics.heightPixels / outMetrics.xdpi; - final float mmpi = 25.4f; - props[offset++] = (int) ((iw * mmpi)+0.5); - props[offset++] = (int) ((ih * mmpi)+0.5); - return offset; - } -} - diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java deleted file mode 100644 index 73192a07f..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ /dev/null @@ -1,458 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.android; - -import jogamp.common.os.android.StaticContext; -import jogamp.newt.driver.android.event.AndroidNewtEventFactory; - -import javax.media.nativewindow.Capabilities; -import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; -import javax.media.opengl.GLCapabilitiesChooser; -import javax.media.opengl.GLCapabilitiesImmutable; - -import com.jogamp.nativewindow.egl.EGLGraphicsDevice; - -import jogamp.opengl.egl.EGL; -import jogamp.opengl.egl.EGLGraphicsConfiguration; -import jogamp.opengl.egl.EGLGraphicsConfigurationFactory; - -import android.content.Context; -import android.graphics.PixelFormat; -import android.os.Bundle; -import android.os.IBinder; -import android.os.ResultReceiver; -import android.util.Log; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceHolder.Callback2; -import android.view.inputmethod.InputMethodManager; -import android.view.SurfaceView; -import android.view.View; - -public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { - static { - AndroidDisplay.initSingleton(); - } - - public static CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { - PixelFormat pf = new PixelFormat(); - PixelFormat.getPixelFormatInfo(format, pf); - final CapabilitiesImmutable res; - int r, g, b, a; - - switch(format) { - case PixelFormat.RGBA_8888: r=8; g=8; b=8; a=8; break; - case PixelFormat.RGBX_8888: r=8; g=8; b=8; a=0; break; - case PixelFormat.RGB_888: r=8; g=8; b=8; a=0; break; - case PixelFormat.RGB_565: r=5; g=6; b=5; a=0; break; - case PixelFormat.RGBA_5551: r=5; g=5; b=5; a=1; break; - case PixelFormat.RGBA_4444: r=4; g=4; b=4; a=4; break; - case PixelFormat.RGB_332: r=3; g=3; b=2; a=0; break; - default: throw new InternalError("Unhandled pixelformat: "+format); - } - final boolean change = matchFormatPrecise || - rCaps.getRedBits() > r && - rCaps.getGreenBits() > g && - rCaps.getBlueBits() > b && - rCaps.getAlphaBits() > a ; - - if(change) { - Capabilities nCaps = (Capabilities) rCaps.cloneMutable(); - nCaps.setRedBits(r); - nCaps.setGreenBits(g); - nCaps.setBlueBits(b); - nCaps.setAlphaBits(a); - res = nCaps; - } else { - res = rCaps; - } - Log.d(MD.TAG, "fixCaps: format: "+format); - Log.d(MD.TAG, "fixCaps: requested: "+rCaps); - Log.d(MD.TAG, "fixCaps: chosen: "+res); - - return res; - } - - public static int getFormat(CapabilitiesImmutable rCaps) { - int fmt = PixelFormat.UNKNOWN; - - if(!rCaps.isBackgroundOpaque()) { - fmt = PixelFormat.TRANSLUCENT; - } else if(rCaps.getRedBits()<=5 && - rCaps.getGreenBits()<=6 && - rCaps.getBlueBits()<=5 && - rCaps.getAlphaBits()==0) { - fmt = PixelFormat.RGB_565; - } - /* else if(rCaps.getRedBits()<=5 && - rCaps.getGreenBits()<=5 && - rCaps.getBlueBits()<=5 && - rCaps.getAlphaBits()==1) { - fmt = PixelFormat.RGBA_5551; // FIXME: Supported ? - } */ - else { - fmt = PixelFormat.RGBA_8888; - } - Log.d(MD.TAG, "getFormat: requested: "+rCaps); - Log.d(MD.TAG, "getFormat: returned: "+fmt); - - return fmt; - } - - public static boolean isAndroidFormatTransparent(int aFormat) { - switch (aFormat) { - case PixelFormat.TRANSLUCENT: - case PixelFormat.TRANSPARENT: - return true; - } - return false; - } - - class AndroidEvents implements View.OnKeyListener, View.OnTouchListener, View.OnFocusChangeListener { - - @Override - public boolean onTouch(View v, android.view.MotionEvent event) { - final com.jogamp.newt.event.MouseEvent[] newtEvents = AndroidNewtEventFactory.createMouseEvents(event, AndroidWindow.this); - if(null != newtEvents) { - focusChanged(false, true); - for(int i=0; i[] getCustomConstructorArgumentTypes() { - return new Class[] { Context.class } ; - } - - public AndroidWindow() { - reset(); - } - - private void reset() { - ownAndroidWindow = false; - androidView = null; - nativeFormat = VisualIDHolder.VID_UNDEFINED; - androidFormat = VisualIDHolder.VID_UNDEFINED; - capsByFormat = null; - surface = null; - surfaceHandle = 0; - eglSurface = 0; - definePosition(0, 0); // default to 0/0 - setBrokenFocusChange(true); - } - - @Override - protected void instantiationFinished() { - final Context ctx = StaticContext.getContext(); - if(null == ctx) { - throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); - } - androidView = new MSurfaceView(ctx); - - final AndroidEvents ae = new AndroidEvents(); - androidView.setOnTouchListener(ae); - androidView.setClickable(false); - androidView.setOnKeyListener(ae); - androidView.setOnFocusChangeListener(ae); - androidView.setFocusable(true); - androidView.setFocusableInTouchMode(true); - - final SurfaceHolder sh = androidView.getHolder(); - sh.addCallback(AndroidWindow.this); - sh.setFormat(getFormat(getRequestedCapabilities())); - - // default size -> TBD ! - defineSize(0, 0); - } - - public SurfaceView getAndroidView() { return androidView; } - - @Override - protected boolean canCreateNativeImpl() { - final boolean b = 0 != surfaceHandle; - Log.d(MD.TAG, "canCreateNativeImpl: "+b); - return b; - } - - @Override - protected void createNativeImpl() { - Log.d(MD.TAG, "createNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ - ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - "+Thread.currentThread().getName()); - - if(0!=getParentWindowHandle()) { - throw new NativeWindowException("Window parenting not supported (yet)"); - } - if(0==surfaceHandle) { - throw new InternalError("XXX"); - } - - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); - final EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - capsByFormat, (GLCapabilitiesImmutable) getRequestedCapabilities(), - (GLCapabilitiesChooser)capabilitiesChooser, getScreen().getGraphicsScreen(), nativeFormat, - isAndroidFormatTransparent(androidFormat)); - if (eglConfig == null) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - final int nativeVisualID = eglConfig.getVisualID(VisualIDHolder.VIDType.NATIVE); - Log.d(MD.TAG, "nativeVisualID 0x"+Integer.toHexString(nativeVisualID)); - if(VisualIDHolder.VID_UNDEFINED != nativeVisualID) { - setSurfaceVisualID0(surfaceHandle, nativeVisualID); - } - - eglSurface = EGL.eglCreateWindowSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), surfaceHandle, null); - if (EGL.EGL_NO_SURFACE==eglSurface) { - throw new NativeWindowException("Creation of window surface failed: "+eglConfig+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", error "+toHexString(EGL.eglGetError())); - } - - // propagate data .. - setGraphicsConfiguration(eglConfig); - setWindowHandle(surfaceHandle); - focusChanged(false, true); - Log.d(MD.TAG, "createNativeImpl X"); - } - - @Override - protected void closeNativeImpl() { - release0(surfaceHandle); - surface = null; - surfaceHandle = 0; - eglSurface = 0; - } - - @Override - public final long getSurfaceHandle() { - return eglSurface; - } - - protected void requestFocusImpl(boolean reparented) { - if(null != androidView) { - Log.d(MD.TAG, "requestFocusImpl: reparented "+reparented); - androidView.post(new Runnable() { - public void run() { - androidView.requestFocus(); - androidView.bringToFront(); - } - }); - } - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { - Log.d(MD.TAG, "reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a"); - return false; - } - if(width>0 || height>0) { - if(0!=getWindowHandle()) { - Log.d(MD.TAG, "reconfigureWindowImpl.setSize n/a"); - return false; - } - } - if(x>=0 || y>=0) { - Log.d(MD.TAG, "reconfigureWindowImpl.setPos n/a"); - return false; - } - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - //---------------------------------------------------------------------- - // Virtual On-Screen Keyboard / SoftInput - // - - private class KeyboardVisibleReceiver extends ResultReceiver { - public KeyboardVisibleReceiver() { - super(null); - } - - @Override - public void onReceiveResult(int r, Bundle data) { - boolean v = false; - - switch(r) { - case InputMethodManager.RESULT_UNCHANGED_SHOWN: - case InputMethodManager.RESULT_SHOWN: - v = true; - break; - case InputMethodManager.RESULT_HIDDEN: - case InputMethodManager.RESULT_UNCHANGED_HIDDEN: - v = false; - break; - } - Log.d(MD.TAG, "keyboardVisible: "+v); - keyboardVisibilityChanged(v); - } - } - private KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); - - protected final boolean setKeyboardVisibleImpl(boolean visible) { - if(null != androidView) { - final InputMethodManager imm = (InputMethodManager) getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - final IBinder winid = getAndroidView().getWindowToken(); - if(visible) { - // Show soft-keyboard: - imm.showSoftInput(androidView, 0, keyboardVisibleReceiver); - } else { - // hide keyboard : - imm.hideSoftInputFromWindow(winid, 0, keyboardVisibleReceiver); - } - return visible; - } else { - return false; // nop - } - } - - //---------------------------------------------------------------------- - // Surface Callbacks - // - - public void surfaceCreated(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); - } - - public void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) { - Log.d(MD.TAG, "surfaceChanged: f "+nativeFormat+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)); - if(0!=surfaceHandle && androidFormat != aFormat ) { - // re-create - Log.d(MD.TAG, "surfaceChanged (destroy old)"); - if(!windowDestroyNotify(true)) { - destroy(); - } - surfaceHandle = 0; - surface=null; - } - if(getScreen().isNativeValid()) { - getScreen().getCurrentScreenMode(); // if ScreenMode changed .. trigger ScreenMode event - } - - if(0>getX() || 0>getY()) { - positionChanged(false, 0, 0); - } - - if(0 == surfaceHandle) { - androidFormat = aFormat; - surface = aHolder.getSurface(); - surfaceHandle = getSurfaceHandle0(surface); - acquire0(surfaceHandle); - nativeFormat = getSurfaceVisualID0(surfaceHandle); - final int nWidth = getWidth0(surfaceHandle); - final int nHeight = getHeight0(surfaceHandle); - capsByFormat = (GLCapabilitiesImmutable) fixCaps(true /* matchFormatPrecise */, nativeFormat, getRequestedCapabilities()); - sizeChanged(false, nWidth, nHeight, false); - - Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ - ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ - ", format [a "+androidFormat+"/n "+nativeFormat+"], "+ - getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible()); - - if(isVisible()) { - setVisible(true); - } - } - sizeChanged(false, aWidth, aHeight, false); - windowRepaint(0, 0, aWidth, aHeight); - Log.d(MD.TAG, "surfaceChanged: X"); - } - - public void surfaceDestroyed(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceDestroyed"); - windowDestroyNotify(true); // actually too late .. however .. - } - - public void surfaceRedrawNeeded(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceRedrawNeeded"); - windowRepaint(0, 0, getWidth(), getHeight()); - } - - private boolean ownAndroidWindow; - private MSurfaceView androidView; - private int nativeFormat; // chosen current native PixelFormat (suitable for EGL) - private int androidFormat; // chosen current android PixelFormat (-1, -2 ..) - private GLCapabilitiesImmutable capsByFormat; // fixed requestedCaps by PixelFormat - private Surface surface; - private volatile long surfaceHandle; - private long eglSurface; - - class MSurfaceView extends SurfaceView { - public MSurfaceView (Context ctx) { - super(ctx); - setBackgroundDrawable(null); - // setBackgroundColor(Color.TRANSPARENT); - } - } - //---------------------------------------------------------------------- - // Internals only - // - protected static native boolean initIDs0(); - protected static native long getSurfaceHandle0(Surface surface); - protected static native int getSurfaceVisualID0(long surfaceHandle); - protected static native void setSurfaceVisualID0(long surfaceHandle, int nativeVisualID); - protected static native int getWidth0(long surfaceHandle); - protected static native int getHeight0(long surfaceHandle); - protected static native void acquire0(long surfaceHandle); - protected static native void release0(long surfaceHandle); -} diff --git a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java new file mode 100644 index 000000000..a367462c4 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java @@ -0,0 +1,66 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.android; + +import jogamp.newt.*; +import jogamp.opengl.egl.*; + +import javax.media.nativewindow.*; + +public class DisplayDriver extends jogamp.newt.DisplayImpl { + static { + NEWTJNILibLoader.loadNEWT(); + + if (!WindowDriver.initIDs0()) { + throw new NativeWindowException("Failed to initialize Android NEWT Windowing library"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + // EGL Device + aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { + aDevice.close(); + } + + protected void dispatchMessagesNative() { + // n/a .. DispatchMessages(); + } +} + diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java index 4537fa963..91c589beb 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtBaseActivity.java @@ -36,7 +36,7 @@ import javax.media.opengl.FPSCounter; import com.jogamp.newt.Window; import com.jogamp.opengl.util.Animator; -import jogamp.newt.driver.android.AndroidWindow; +import jogamp.newt.driver.android.WindowDriver; import android.app.Activity; import android.content.Context; @@ -83,10 +83,10 @@ public class NewtBaseActivity extends Activity { */ public void setContentView(android.view.Window androidWindow, Window newtWindow) { newtWindow = newtWindow.getDelegatedWindow(); - if(newtWindow instanceof AndroidWindow) { + if(newtWindow instanceof WindowDriver) { adaptTheme4Transparency(newtWindow.getRequestedCapabilities()); layoutForNEWTWindow(androidWindow, newtWindow); - AndroidWindow newtAWindow = (AndroidWindow)newtWindow; + WindowDriver newtAWindow = (WindowDriver)newtWindow; androidWindow.setContentView(newtAWindow.getAndroidView()); registerNEWTWindow(newtAWindow); } else { @@ -107,8 +107,8 @@ public class NewtBaseActivity extends Activity { */ public void addContentView(android.view.Window androidWindow, Window newtWindow, android.view.ViewGroup.LayoutParams params) { newtWindow = newtWindow.getDelegatedWindow(); - if(newtWindow instanceof AndroidWindow) { - AndroidWindow newtAWindow = (AndroidWindow)newtWindow; + if(newtWindow instanceof WindowDriver) { + WindowDriver newtAWindow = (WindowDriver)newtWindow; androidWindow.addContentView(newtAWindow.getAndroidView(), params); registerNEWTWindow(newtAWindow); } else { diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index 36b83337a..a49f1648c 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -69,7 +69,7 @@ public class NewtVersionActivity extends NewtBaseActivity { glWindow.setUndecorated(true); glWindow.setSize(32, 32); glWindow.setPosition(0, 0); - final android.view.View androidGLView = ((AndroidWindow)glWindow.getDelegatedWindow()).getAndroidView(); + final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); registerNEWTWindow(glWindow); diff --git a/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java new file mode 100644 index 000000000..795aac5fb --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/ScreenDriver.java @@ -0,0 +1,138 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.android; + +import javax.media.nativewindow.*; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +import android.content.Context; +import android.graphics.PixelFormat; +import android.util.DisplayMetrics; +import android.view.Surface; +import android.view.WindowManager; + +public class ScreenDriver extends jogamp.newt.ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { } + + protected ScreenMode getCurrentScreenModeImpl() { + final Context ctx = jogamp.common.os.android.StaticContext.getContext(); + final WindowManager wmgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); + final DisplayMetrics outMetrics = new DisplayMetrics(); + final android.view.Display aDisplay = wmgr.getDefaultDisplay(); + aDisplay.getMetrics(outMetrics); + + final int arot = aDisplay.getRotation(); + final int nrot = androidRotation2NewtRotation(arot); + int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int offset = 1; // set later for verification of iterator + offset = getScreenSize(outMetrics, nrot, props, offset); + offset = getBpp(aDisplay, props, offset); + offset = getScreenSizeMM(outMetrics, props, offset); + props[offset++] = (int) aDisplay.getRefreshRate(); + props[offset++] = nrot; + props[offset - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = offset; // count + return ScreenModeUtil.streamIn(props, 0); + } + + protected int validateScreenIndex(int idx) { + return 0; // FIXME: only one screen available ? + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + final ScreenMode sm = getCurrentScreenMode(); + virtualSize.setWidth(sm.getRotatedWidth()); + virtualSize.setHeight(sm.getRotatedHeight()); + } + + //---------------------------------------------------------------------- + // Internals only + // + static int androidRotation2NewtRotation(int arot) { + switch(arot) { + case Surface.ROTATION_270: return ScreenMode.ROTATE_270; + case Surface.ROTATION_180: return ScreenMode.ROTATE_180; + case Surface.ROTATION_90: return ScreenMode.ROTATE_90; + case Surface.ROTATION_0: + } + return ScreenMode.ROTATE_0; + } + static int getScreenSize(DisplayMetrics outMetrics, int nrot, int[] props, int offset) { + // swap width and height, since Android reflects rotated dimension, we don't + if (ScreenMode.ROTATE_90 == nrot || ScreenMode.ROTATE_270 == nrot) { + props[offset++] = outMetrics.heightPixels; + props[offset++] = outMetrics.widthPixels; + } else { + props[offset++] = outMetrics.widthPixels; + props[offset++] = outMetrics.heightPixels; + } + return offset; + } + static int getBpp(android.view.Display aDisplay, int[] props, int offset) { + int bpp; + switch(aDisplay.getPixelFormat()) { + case PixelFormat.RGBA_8888: bpp=32; break; + case PixelFormat.RGBX_8888: bpp=32; break; + case PixelFormat.RGB_888: bpp=24; break; + case PixelFormat.RGB_565: bpp=16; break; + case PixelFormat.RGBA_5551: bpp=16; break; + case PixelFormat.RGBA_4444: bpp=16; break; + case PixelFormat.RGB_332: bpp= 8; break; + default: bpp=32; + } + props[offset++] = bpp; + return offset; + } + static int getScreenSizeMM(DisplayMetrics outMetrics, int[] props, int offset) { + final float iw = (float) outMetrics.widthPixels / outMetrics.xdpi; + final float ih = (float) outMetrics.heightPixels / outMetrics.xdpi; + final float mmpi = 25.4f; + props[offset++] = (int) ((iw * mmpi)+0.5); + props[offset++] = (int) ((ih * mmpi)+0.5); + return offset; + } +} + diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java new file mode 100644 index 000000000..8ad11b35f --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -0,0 +1,458 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.android; + +import jogamp.common.os.android.StaticContext; +import jogamp.newt.driver.android.event.AndroidNewtEventFactory; + +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; +import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLCapabilitiesImmutable; + +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + +import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLGraphicsConfiguration; +import jogamp.opengl.egl.EGLGraphicsConfigurationFactory; + +import android.content.Context; +import android.graphics.PixelFormat; +import android.os.Bundle; +import android.os.IBinder; +import android.os.ResultReceiver; +import android.util.Log; +import android.view.Surface; +import android.view.SurfaceHolder; +import android.view.SurfaceHolder.Callback2; +import android.view.inputmethod.InputMethodManager; +import android.view.SurfaceView; +import android.view.View; + +public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { + static { + DisplayDriver.initSingleton(); + } + + public static CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { + PixelFormat pf = new PixelFormat(); + PixelFormat.getPixelFormatInfo(format, pf); + final CapabilitiesImmutable res; + int r, g, b, a; + + switch(format) { + case PixelFormat.RGBA_8888: r=8; g=8; b=8; a=8; break; + case PixelFormat.RGBX_8888: r=8; g=8; b=8; a=0; break; + case PixelFormat.RGB_888: r=8; g=8; b=8; a=0; break; + case PixelFormat.RGB_565: r=5; g=6; b=5; a=0; break; + case PixelFormat.RGBA_5551: r=5; g=5; b=5; a=1; break; + case PixelFormat.RGBA_4444: r=4; g=4; b=4; a=4; break; + case PixelFormat.RGB_332: r=3; g=3; b=2; a=0; break; + default: throw new InternalError("Unhandled pixelformat: "+format); + } + final boolean change = matchFormatPrecise || + rCaps.getRedBits() > r && + rCaps.getGreenBits() > g && + rCaps.getBlueBits() > b && + rCaps.getAlphaBits() > a ; + + if(change) { + Capabilities nCaps = (Capabilities) rCaps.cloneMutable(); + nCaps.setRedBits(r); + nCaps.setGreenBits(g); + nCaps.setBlueBits(b); + nCaps.setAlphaBits(a); + res = nCaps; + } else { + res = rCaps; + } + Log.d(MD.TAG, "fixCaps: format: "+format); + Log.d(MD.TAG, "fixCaps: requested: "+rCaps); + Log.d(MD.TAG, "fixCaps: chosen: "+res); + + return res; + } + + public static int getFormat(CapabilitiesImmutable rCaps) { + int fmt = PixelFormat.UNKNOWN; + + if(!rCaps.isBackgroundOpaque()) { + fmt = PixelFormat.TRANSLUCENT; + } else if(rCaps.getRedBits()<=5 && + rCaps.getGreenBits()<=6 && + rCaps.getBlueBits()<=5 && + rCaps.getAlphaBits()==0) { + fmt = PixelFormat.RGB_565; + } + /* else if(rCaps.getRedBits()<=5 && + rCaps.getGreenBits()<=5 && + rCaps.getBlueBits()<=5 && + rCaps.getAlphaBits()==1) { + fmt = PixelFormat.RGBA_5551; // FIXME: Supported ? + } */ + else { + fmt = PixelFormat.RGBA_8888; + } + Log.d(MD.TAG, "getFormat: requested: "+rCaps); + Log.d(MD.TAG, "getFormat: returned: "+fmt); + + return fmt; + } + + public static boolean isAndroidFormatTransparent(int aFormat) { + switch (aFormat) { + case PixelFormat.TRANSLUCENT: + case PixelFormat.TRANSPARENT: + return true; + } + return false; + } + + class AndroidEvents implements View.OnKeyListener, View.OnTouchListener, View.OnFocusChangeListener { + + @Override + public boolean onTouch(View v, android.view.MotionEvent event) { + final com.jogamp.newt.event.MouseEvent[] newtEvents = AndroidNewtEventFactory.createMouseEvents(event, WindowDriver.this); + if(null != newtEvents) { + focusChanged(false, true); + for(int i=0; i[] getCustomConstructorArgumentTypes() { + return new Class[] { Context.class } ; + } + + public WindowDriver() { + reset(); + } + + private void reset() { + ownAndroidWindow = false; + androidView = null; + nativeFormat = VisualIDHolder.VID_UNDEFINED; + androidFormat = VisualIDHolder.VID_UNDEFINED; + capsByFormat = null; + surface = null; + surfaceHandle = 0; + eglSurface = 0; + definePosition(0, 0); // default to 0/0 + setBrokenFocusChange(true); + } + + @Override + protected void instantiationFinished() { + final Context ctx = StaticContext.getContext(); + if(null == ctx) { + throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); + } + androidView = new MSurfaceView(ctx); + + final AndroidEvents ae = new AndroidEvents(); + androidView.setOnTouchListener(ae); + androidView.setClickable(false); + androidView.setOnKeyListener(ae); + androidView.setOnFocusChangeListener(ae); + androidView.setFocusable(true); + androidView.setFocusableInTouchMode(true); + + final SurfaceHolder sh = androidView.getHolder(); + sh.addCallback(WindowDriver.this); + sh.setFormat(getFormat(getRequestedCapabilities())); + + // default size -> TBD ! + defineSize(0, 0); + } + + public SurfaceView getAndroidView() { return androidView; } + + @Override + protected boolean canCreateNativeImpl() { + final boolean b = 0 != surfaceHandle; + Log.d(MD.TAG, "canCreateNativeImpl: "+b); + return b; + } + + @Override + protected void createNativeImpl() { + Log.d(MD.TAG, "createNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ + ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - "+Thread.currentThread().getName()); + + if(0!=getParentWindowHandle()) { + throw new NativeWindowException("Window parenting not supported (yet)"); + } + if(0==surfaceHandle) { + throw new InternalError("XXX"); + } + + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); + final EGLGraphicsConfiguration eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( + capsByFormat, (GLCapabilitiesImmutable) getRequestedCapabilities(), + (GLCapabilitiesChooser)capabilitiesChooser, getScreen().getGraphicsScreen(), nativeFormat, + isAndroidFormatTransparent(androidFormat)); + if (eglConfig == null) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + final int nativeVisualID = eglConfig.getVisualID(VisualIDHolder.VIDType.NATIVE); + Log.d(MD.TAG, "nativeVisualID 0x"+Integer.toHexString(nativeVisualID)); + if(VisualIDHolder.VID_UNDEFINED != nativeVisualID) { + setSurfaceVisualID0(surfaceHandle, nativeVisualID); + } + + eglSurface = EGL.eglCreateWindowSurface(eglDevice.getHandle(), eglConfig.getNativeConfig(), surfaceHandle, null); + if (EGL.EGL_NO_SURFACE==eglSurface) { + throw new NativeWindowException("Creation of window surface failed: "+eglConfig+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", error "+toHexString(EGL.eglGetError())); + } + + // propagate data .. + setGraphicsConfiguration(eglConfig); + setWindowHandle(surfaceHandle); + focusChanged(false, true); + Log.d(MD.TAG, "createNativeImpl X"); + } + + @Override + protected void closeNativeImpl() { + release0(surfaceHandle); + surface = null; + surfaceHandle = 0; + eglSurface = 0; + } + + @Override + public final long getSurfaceHandle() { + return eglSurface; + } + + protected void requestFocusImpl(boolean reparented) { + if(null != androidView) { + Log.d(MD.TAG, "requestFocusImpl: reparented "+reparented); + androidView.post(new Runnable() { + public void run() { + androidView.requestFocus(); + androidView.bringToFront(); + } + }); + } + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { + Log.d(MD.TAG, "reconfigureWindowImpl.setFullscreen post creation (setContentView()) n/a"); + return false; + } + if(width>0 || height>0) { + if(0!=getWindowHandle()) { + Log.d(MD.TAG, "reconfigureWindowImpl.setSize n/a"); + return false; + } + } + if(x>=0 || y>=0) { + Log.d(MD.TAG, "reconfigureWindowImpl.setPos n/a"); + return false; + } + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + //---------------------------------------------------------------------- + // Virtual On-Screen Keyboard / SoftInput + // + + private class KeyboardVisibleReceiver extends ResultReceiver { + public KeyboardVisibleReceiver() { + super(null); + } + + @Override + public void onReceiveResult(int r, Bundle data) { + boolean v = false; + + switch(r) { + case InputMethodManager.RESULT_UNCHANGED_SHOWN: + case InputMethodManager.RESULT_SHOWN: + v = true; + break; + case InputMethodManager.RESULT_HIDDEN: + case InputMethodManager.RESULT_UNCHANGED_HIDDEN: + v = false; + break; + } + Log.d(MD.TAG, "keyboardVisible: "+v); + keyboardVisibilityChanged(v); + } + } + private KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); + + protected final boolean setKeyboardVisibleImpl(boolean visible) { + if(null != androidView) { + final InputMethodManager imm = (InputMethodManager) getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + final IBinder winid = getAndroidView().getWindowToken(); + if(visible) { + // Show soft-keyboard: + imm.showSoftInput(androidView, 0, keyboardVisibleReceiver); + } else { + // hide keyboard : + imm.hideSoftInputFromWindow(winid, 0, keyboardVisibleReceiver); + } + return visible; + } else { + return false; // nop + } + } + + //---------------------------------------------------------------------- + // Surface Callbacks + // + + public void surfaceCreated(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); + } + + public void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) { + Log.d(MD.TAG, "surfaceChanged: f "+nativeFormat+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)); + if(0!=surfaceHandle && androidFormat != aFormat ) { + // re-create + Log.d(MD.TAG, "surfaceChanged (destroy old)"); + if(!windowDestroyNotify(true)) { + destroy(); + } + surfaceHandle = 0; + surface=null; + } + if(getScreen().isNativeValid()) { + getScreen().getCurrentScreenMode(); // if ScreenMode changed .. trigger ScreenMode event + } + + if(0>getX() || 0>getY()) { + positionChanged(false, 0, 0); + } + + if(0 == surfaceHandle) { + androidFormat = aFormat; + surface = aHolder.getSurface(); + surfaceHandle = getSurfaceHandle0(surface); + acquire0(surfaceHandle); + nativeFormat = getSurfaceVisualID0(surfaceHandle); + final int nWidth = getWidth0(surfaceHandle); + final int nHeight = getHeight0(surfaceHandle); + capsByFormat = (GLCapabilitiesImmutable) fixCaps(true /* matchFormatPrecise */, nativeFormat, getRequestedCapabilities()); + sizeChanged(false, nWidth, nHeight, false); + + Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ + ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ + ", format [a "+androidFormat+"/n "+nativeFormat+"], "+ + getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible()); + + if(isVisible()) { + setVisible(true); + } + } + sizeChanged(false, aWidth, aHeight, false); + windowRepaint(0, 0, aWidth, aHeight); + Log.d(MD.TAG, "surfaceChanged: X"); + } + + public void surfaceDestroyed(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceDestroyed"); + windowDestroyNotify(true); // actually too late .. however .. + } + + public void surfaceRedrawNeeded(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceRedrawNeeded"); + windowRepaint(0, 0, getWidth(), getHeight()); + } + + private boolean ownAndroidWindow; + private MSurfaceView androidView; + private int nativeFormat; // chosen current native PixelFormat (suitable for EGL) + private int androidFormat; // chosen current android PixelFormat (-1, -2 ..) + private GLCapabilitiesImmutable capsByFormat; // fixed requestedCaps by PixelFormat + private Surface surface; + private volatile long surfaceHandle; + private long eglSurface; + + class MSurfaceView extends SurfaceView { + public MSurfaceView (Context ctx) { + super(ctx); + setBackgroundDrawable(null); + // setBackgroundColor(Color.TRANSPARENT); + } + } + //---------------------------------------------------------------------- + // Internals only + // + protected static native boolean initIDs0(); + protected static native long getSurfaceHandle0(Surface surface); + protected static native int getSurfaceVisualID0(long surfaceHandle); + protected static native void setSurfaceVisualID0(long surfaceHandle, int nativeVisualID); + protected static native int getWidth0(long surfaceHandle); + protected static native int getHeight0(long surfaceHandle); + protected static native void acquire0(long surfaceHandle); + protected static native void release0(long surfaceHandle); +} diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index a7950048a..b3fdcad41 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java b/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java deleted file mode 100644 index 65f8b4715..000000000 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTDisplay.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.awt; - -import com.jogamp.nativewindow.awt.AWTGraphicsDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.util.EDTUtil; - -import jogamp.newt.DisplayImpl; - -public class AWTDisplay extends DisplayImpl { - public AWTDisplay() { - } - - protected void createNativeImpl() { - aDevice = AWTGraphicsDevice.createDefault(); - } - - protected void setAWTGraphicsDevice(AWTGraphicsDevice d) { - aDevice = d; - } - - protected void closeNativeImpl() { } - - @Override - protected EDTUtil createEDTUtil() { - final EDTUtil def; - if(NewtFactory.useEDT()) { - def = AWTEDTUtil.getSingleton(); - if(DEBUG) { - System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); - } - } else { - def = null; - } - return def; - } - - protected void dispatchMessagesNative() { /* nop */ } -} - diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java b/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java deleted file mode 100644 index a3c0281b1..000000000 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTScreen.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.awt; - -import java.awt.DisplayMode; - -import jogamp.newt.ScreenImpl; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import com.jogamp.nativewindow.awt.AWTGraphicsDevice; -import com.jogamp.nativewindow.awt.AWTGraphicsScreen; - -public class AWTScreen extends ScreenImpl { - public AWTScreen() { - } - - protected void createNativeImpl() { - aScreen = new AWTGraphicsScreen((AWTGraphicsDevice)display.getGraphicsDevice()); - } - - protected void setAWTGraphicsScreen(AWTGraphicsScreen s) { - aScreen = s; - } - - /** - * Used by AWTWindow .. - */ - @Override - protected void updateVirtualScreenOriginAndSize() { - super.updateVirtualScreenOriginAndSize(); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return idx; // pass through ... - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); - if(null != mode) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(mode.getWidth()); - virtualSize.setHeight(mode.getHeight()); - } - } - -} diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java b/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java deleted file mode 100644 index 2b2fed545..000000000 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTWindow.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.awt; - -import java.awt.BorderLayout; -import java.awt.Container; -import java.awt.Frame; -import java.awt.Insets; - -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.WindowImpl; - -import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; -import com.jogamp.nativewindow.awt.AWTGraphicsDevice; -import com.jogamp.nativewindow.awt.AWTGraphicsScreen; -import com.jogamp.newt.event.awt.AWTKeyAdapter; -import com.jogamp.newt.event.awt.AWTMouseAdapter; -import com.jogamp.newt.event.awt.AWTWindowAdapter; - -/** An implementation of the Newt Window class built using the - AWT. This is provided for convenience of porting to platforms - supporting Java SE. */ - -public class AWTWindow extends WindowImpl { - - public AWTWindow() { - this(null); - } - - public static Class[] getCustomConstructorArgumentTypes() { - return new Class[] { Container.class } ; - } - - public AWTWindow(Container container) { - super(); - this.container = container; - if(container instanceof Frame) { - frame = (Frame) container; - } - } - - private boolean owningFrame; - private Container container = null; - private Frame frame = null; // same instance as container, just for impl. convenience - private AWTCanvas canvas; - - protected void requestFocusImpl(boolean reparented) { - container.requestFocus(); - } - - @Override - protected void setTitleImpl(final String title) { - if (frame != null) { - frame.setTitle(title); - } - } - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead"); - } - - if(null==container) { - frame = new Frame(); - container = frame; - owningFrame=true; - } else { - owningFrame=false; - defineSize(container.getWidth(), container.getHeight()); - definePosition(container.getX(), container.getY()); - } - if(null!=frame) { - frame.setTitle(getTitle()); - } - container.setLayout(new BorderLayout()); - canvas = new AWTCanvas(capsRequested, AWTWindow.this.capabilitiesChooser); - - addWindowListener(new LocalWindowListener()); - - new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here - new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here - - // canvas.addComponentListener(listener); - container.add(canvas, BorderLayout.CENTER); - container.setSize(getWidth(), getHeight()); - container.setLocation(getX(), getY()); - new AWTWindowAdapter(this).addTo(container); // fwd all AWT Window events to here - - reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); - // throws exception if failed .. - - setWindowHandle(1); // just a marker .. - } - - protected void closeNativeImpl() { - setWindowHandle(0); // just a marker .. - if(null!=container) { - container.setVisible(false); - container.remove(canvas); - container.setEnabled(false); - canvas.setEnabled(false); - } - if(owningFrame && null!=frame) { - frame.dispose(); - owningFrame=false; - frame = null; - } - } - - @Override - public boolean hasDeviceChanged() { - boolean res = canvas.hasDeviceChanged(); - if(res) { - final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); - if (null == cfg) { - throw new NativeWindowException("Error Device change null GraphicsConfiguration: "+this); - } - setGraphicsConfiguration(cfg); - - // propagate new info .. - ((AWTScreen)getScreen()).setAWTGraphicsScreen((AWTGraphicsScreen)cfg.getScreen()); - ((AWTDisplay)getScreen().getDisplay()).setAWTGraphicsDevice((AWTGraphicsDevice)cfg.getScreen().getDevice()); - - ((AWTScreen)getScreen()).updateVirtualScreenOriginAndSize(); - } - return res; - } - - protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { - Insets contInsets = container.getInsets(); - insets.setLeftWidth(contInsets.left); - insets.setRightWidth(contInsets.right); - insets.setTopHeight(contInsets.top); - insets.setBottomHeight(contInsets.bottom); - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=frame) { - if(!container.isDisplayable()) { - frame.setUndecorated(isUndecorated()); - } else { - if(DEBUG_IMPLEMENTATION) { - System.err.println("AWTWindow can't undecorate already created frame"); - } - } - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - container.setVisible(0 != ( FLAG_IS_VISIBLE & flags)); - } - - container.setLocation(x, y); - Insets insets = container.getInsets(); - container.setSize(width + insets.left + insets.right, - height + insets.top + insets.bottom); - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - if( 0 != ( FLAG_IS_VISIBLE & flags ) ) { - if( !hasDeviceChanged() ) { - // oops ?? - final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); - if(null == cfg) { - throw new NativeWindowException("Error: !hasDeviceChanged && null == GraphicsConfiguration: "+this); - } - setGraphicsConfiguration(cfg); - } - } - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - java.awt.Point ap = canvas.getLocationOnScreen(); - ap.translate(x, y); - return new Point((int)(ap.getX()+0.5),(int)(ap.getY()+0.5)); - } - - @Override - public Object getWrappedWindow() { - return canvas; - } - - class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter { - @Override - public void windowMoved(com.jogamp.newt.event.WindowEvent e) { - if(null!=container) { - definePosition(container.getX(), container.getY()); - } - } - @Override - public void windowResized(com.jogamp.newt.event.WindowEvent e) { - if(null!=canvas) { - defineSize(canvas.getWidth(), canvas.getHeight()); - } - } - } -} diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java new file mode 100644 index 000000000..39d96585b --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.awt; + +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.util.EDTUtil; + +import jogamp.newt.DisplayImpl; + +public class DisplayDriver extends DisplayImpl { + public DisplayDriver() { + } + + protected void createNativeImpl() { + aDevice = AWTGraphicsDevice.createDefault(); + } + + protected void setAWTGraphicsDevice(AWTGraphicsDevice d) { + aDevice = d; + } + + protected void closeNativeImpl() { } + + @Override + protected EDTUtil createEDTUtil() { + final EDTUtil def; + if(NewtFactory.useEDT()) { + def = AWTEDTUtil.getSingleton(); + if(DEBUG) { + System.err.println("AWTDisplay.createNative("+getFQName()+") Create EDTUtil: "+def.getClass().getName()); + } + } else { + def = null; + } + return def; + } + + protected void dispatchMessagesNative() { /* nop */ } +} + diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java new file mode 100644 index 000000000..6b1283a00 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.awt; + +import java.awt.DisplayMode; + +import jogamp.newt.ScreenImpl; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; + +public class ScreenDriver extends ScreenImpl { + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new AWTGraphicsScreen((AWTGraphicsDevice)display.getGraphicsDevice()); + } + + protected void setAWTGraphicsScreen(AWTGraphicsScreen s) { + aScreen = s; + } + + /** + * Used by AWTWindow .. + */ + @Override + protected void updateVirtualScreenOriginAndSize() { + super.updateVirtualScreenOriginAndSize(); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return idx; // pass through ... + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); + if(null != mode) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(mode.getWidth()); + virtualSize.setHeight(mode.getHeight()); + } + } + +} diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java new file mode 100644 index 000000000..1723ffee5 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.awt; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Frame; +import java.awt.Insets; + +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.WindowImpl; + +import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTMouseAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; + +/** An implementation of the Newt Window class built using the + AWT. This is provided for convenience of porting to platforms + supporting Java SE. */ + +public class WindowDriver extends WindowImpl { + + public WindowDriver() { + this(null); + } + + public static Class[] getCustomConstructorArgumentTypes() { + return new Class[] { Container.class } ; + } + + public WindowDriver(Container container) { + super(); + this.container = container; + if(container instanceof Frame) { + frame = (Frame) container; + } + } + + private boolean owningFrame; + private Container container = null; + private Frame frame = null; // same instance as container, just for impl. convenience + private AWTCanvas canvas; + + protected void requestFocusImpl(boolean reparented) { + container.requestFocus(); + } + + @Override + protected void setTitleImpl(final String title) { + if (frame != null) { + frame.setTitle(title); + } + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported in AWT, use AWTWindow(Frame) cstr for wrapping instead"); + } + + if(null==container) { + frame = new Frame(); + container = frame; + owningFrame=true; + } else { + owningFrame=false; + defineSize(container.getWidth(), container.getHeight()); + definePosition(container.getX(), container.getY()); + } + if(null!=frame) { + frame.setTitle(getTitle()); + } + container.setLayout(new BorderLayout()); + canvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser); + + addWindowListener(new LocalWindowListener()); + + new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here + new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here + + // canvas.addComponentListener(listener); + container.add(canvas, BorderLayout.CENTER); + container.setSize(getWidth(), getHeight()); + container.setLocation(getX(), getY()); + new AWTWindowAdapter(this).addTo(container); // fwd all AWT Window events to here + + reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); + // throws exception if failed .. + + setWindowHandle(1); // just a marker .. + } + + protected void closeNativeImpl() { + setWindowHandle(0); // just a marker .. + if(null!=container) { + container.setVisible(false); + container.remove(canvas); + container.setEnabled(false); + canvas.setEnabled(false); + } + if(owningFrame && null!=frame) { + frame.dispose(); + owningFrame=false; + frame = null; + } + } + + @Override + public boolean hasDeviceChanged() { + boolean res = canvas.hasDeviceChanged(); + if(res) { + final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); + if (null == cfg) { + throw new NativeWindowException("Error Device change null GraphicsConfiguration: "+this); + } + setGraphicsConfiguration(cfg); + + // propagate new info .. + ((ScreenDriver)getScreen()).setAWTGraphicsScreen((AWTGraphicsScreen)cfg.getScreen()); + ((DisplayDriver)getScreen().getDisplay()).setAWTGraphicsDevice((AWTGraphicsDevice)cfg.getScreen().getDevice()); + + ((ScreenDriver)getScreen()).updateVirtualScreenOriginAndSize(); + } + return res; + } + + protected void updateInsetsImpl(javax.media.nativewindow.util.Insets insets) { + Insets contInsets = container.getInsets(); + insets.setLeftWidth(contInsets.left); + insets.setRightWidth(contInsets.right); + insets.setTopHeight(contInsets.top); + insets.setBottomHeight(contInsets.bottom); + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(0 != ( FLAG_CHANGE_DECORATION & flags) && null!=frame) { + if(!container.isDisplayable()) { + frame.setUndecorated(isUndecorated()); + } else { + if(DEBUG_IMPLEMENTATION) { + System.err.println("AWTWindow can't undecorate already created frame"); + } + } + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + container.setVisible(0 != ( FLAG_IS_VISIBLE & flags)); + } + + container.setLocation(x, y); + Insets insets = container.getInsets(); + container.setSize(width + insets.left + insets.right, + height + insets.top + insets.bottom); + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + if( 0 != ( FLAG_IS_VISIBLE & flags ) ) { + if( !hasDeviceChanged() ) { + // oops ?? + final AWTGraphicsConfiguration cfg = canvas.getAWTGraphicsConfiguration(); + if(null == cfg) { + throw new NativeWindowException("Error: !hasDeviceChanged && null == GraphicsConfiguration: "+this); + } + setGraphicsConfiguration(cfg); + } + } + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + java.awt.Point ap = canvas.getLocationOnScreen(); + ap.translate(x, y); + return new Point((int)(ap.getX()+0.5),(int)(ap.getY()+0.5)); + } + + @Override + public Object getWrappedWindow() { + return canvas; + } + + class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter { + @Override + public void windowMoved(com.jogamp.newt.event.WindowEvent e) { + if(null!=container) { + definePosition(container.getX(), container.getY()); + } + } + @Override + public void windowResized(com.jogamp.newt.event.WindowEvent e) { + if(null!=canvas) { + defineSize(canvas.getWidth(), canvas.getHeight()); + } + } + } +} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java deleted file mode 100644 index f08890da6..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/Display.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.bcm.egl; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import jogamp.newt.NEWTJNILibLoader; -import jogamp.opengl.egl.EGL; - -import com.jogamp.nativewindow.egl.EGLGraphicsDevice; - -public class Display extends jogamp.newt.DisplayImpl { - - static { - NEWTJNILibLoader.loadNEWT(); - - if (!Window.initIDs()) { - throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public Display() { - } - - protected void createNativeImpl() { - final long handle = CreateDisplay(Screen.fixedWidth, Screen.fixedHeight); - if (handle == EGL.EGL_NO_DISPLAY) { - throw new NativeWindowException("BC EGL CreateDisplay failed"); - } - aDevice = new EGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, null); - } - - protected void closeNativeImpl() { - if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { - DestroyDisplay(aDevice.getHandle()); - } - } - - protected void dispatchMessagesNative() { - // n/a .. DispatchMessages(); - } - - private native long CreateDisplay(int width, int height); - private native void DestroyDisplay(long dpy); - private native void DispatchMessages(); -} - diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java new file mode 100644 index 000000000..65ca63eec --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.bcm.egl; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.NEWTJNILibLoader; +import jogamp.opengl.egl.EGL; + +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + +public class DisplayDriver extends jogamp.newt.DisplayImpl { + + static { + NEWTJNILibLoader.loadNEWT(); + + if (!WindowDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize BCEGL Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + final long handle = CreateDisplay(ScreenDriver.fixedWidth, ScreenDriver.fixedHeight); + if (handle == EGL.EGL_NO_DISPLAY) { + throw new NativeWindowException("BC EGL CreateDisplay failed"); + } + aDevice = new EGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, null); + } + + protected void closeNativeImpl() { + if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { + DestroyDisplay(aDevice.getHandle()); + } + } + + protected void dispatchMessagesNative() { + // n/a .. DispatchMessages(); + } + + private native long CreateDisplay(int width, int height); + private native void DestroyDisplay(long dpy); + private native void DispatchMessages(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java deleted file mode 100644 index 909444d24..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/Screen.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.bcm.egl; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -public class Screen extends jogamp.newt.ScreenImpl { - - static { - Display.initSingleton(); - } - - - public Screen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(fixedWidth); // FIXME - virtualSize.setHeight(fixedHeight); // FIXME - } - - //---------------------------------------------------------------------- - // Internals only - // - - static final int fixedWidth = 1920; // FIXME - static final int fixedHeight = 1080; // FIXME -} - diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java new file mode 100644 index 000000000..deb2a534b --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.bcm.egl; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +public class ScreenDriver extends jogamp.newt.ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(fixedWidth); // FIXME + virtualSize.setHeight(fixedHeight); // FIXME + } + + //---------------------------------------------------------------------- + // Internals only + // + + static final int fixedWidth = 1920; // FIXME + static final int fixedHeight = 1080; // FIXME +} + diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java deleted file mode 100644 index 87170e4ab..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/Window.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.bcm.egl; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; -import javax.media.opengl.GLCapabilitiesImmutable; - -import jogamp.opengl.egl.EGLGraphicsConfiguration; - -public class Window extends jogamp.newt.WindowImpl { - static { - Display.initSingleton(); - } - - public Window() { - } - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new RuntimeException("Window parenting not supported (yet)"); - } - // query a good configuration, however chose the final one by the native queried egl-cfg-id - // after creation at {@link #windowCreated(int, int, int)}. - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - setSizeImpl(getScreen().getWidth(), getScreen().getHeight()); - - setWindowHandle(realizeWindow(true, getWidth(), getHeight())); - if (0 == getWindowHandle()) { - throw new NativeWindowException("Error native Window Handle is null"); - } - } - - protected void closeNativeImpl() { - if(0!=windowHandleClose) { - CloseWindow(getDisplayHandle(), windowHandleClose); - } - } - - protected void requestFocusImpl(boolean reparented) { } - - protected void setSizeImpl(int width, int height) { - if(0!=getWindowHandle()) { - // n/a in BroadcomEGL - System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); - } else { - defineSize(width, height); - } - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(0!=getWindowHandle()) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { - // n/a in BroadcomEGL - System.err.println("setFullscreen n/a in BroadcomEGL"); - return false; - } - } - } - if(width>0 || height>0) { - if(0!=getWindowHandle()) { - // n/a in BroadcomEGL - System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); - } else { - defineSize((width>0)?width:getWidth(), (height>0)?height:getHeight()); - } - } - if(x>=0 || y>=0) { - System.err.println("BCEGL Window.setPositionImpl n/a in BroadcomEGL"); - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - @Override - public boolean surfaceSwap() { - SwapWindow(getDisplayHandle(), getWindowHandle()); - return true; - } - - //---------------------------------------------------------------------- - // Internals only - // - - protected static native boolean initIDs(); - private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height); - private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle); - private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle); - - - private long realizeWindow(boolean chromaKey, int width, int height) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+getGraphicsConfiguration()); - } - long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height); - if (0 == handle) { - throw new NativeWindowException("Error native Window Handle is null"); - } - windowHandleClose = handle; - return handle; - } - - private void windowCreated(int cfgID, int width, int height) { - defineSize(width, height); - GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities(); - final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID); - if (null == cfg) { - throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this); - } - setGraphicsConfiguration(cfg); - if(DEBUG_IMPLEMENTATION) { - System.err.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+cfg); - } - } - - private long windowHandleClose; -} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java new file mode 100644 index 000000000..49d3d98ba --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/WindowDriver.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.bcm.egl; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; +import javax.media.opengl.GLCapabilitiesImmutable; + +import jogamp.opengl.egl.EGLGraphicsConfiguration; + +public class WindowDriver extends jogamp.newt.WindowImpl { + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported (yet)"); + } + // query a good configuration, however chose the final one by the native queried egl-cfg-id + // after creation at {@link #windowCreated(int, int, int)}. + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + setSizeImpl(getScreen().getWidth(), getScreen().getHeight()); + + setWindowHandle(realizeWindow(true, getWidth(), getHeight())); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error native Window Handle is null"); + } + } + + protected void closeNativeImpl() { + if(0!=windowHandleClose) { + CloseWindow(getDisplayHandle(), windowHandleClose); + } + } + + protected void requestFocusImpl(boolean reparented) { } + + protected void setSizeImpl(int width, int height) { + if(0!=getWindowHandle()) { + // n/a in BroadcomEGL + System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); + } else { + defineSize(width, height); + } + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(0!=getWindowHandle()) { + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + if( 0 != ( FLAG_IS_FULLSCREEN & flags) ) { + // n/a in BroadcomEGL + System.err.println("setFullscreen n/a in BroadcomEGL"); + return false; + } + } + } + if(width>0 || height>0) { + if(0!=getWindowHandle()) { + // n/a in BroadcomEGL + System.err.println("BCEGL Window.setSizeImpl n/a in BroadcomEGL with realized window"); + } else { + defineSize((width>0)?width:getWidth(), (height>0)?height:getHeight()); + } + } + if(x>=0 || y>=0) { + System.err.println("BCEGL Window.setPositionImpl n/a in BroadcomEGL"); + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + @Override + public boolean surfaceSwap() { + SwapWindow(getDisplayHandle(), getWindowHandle()); + return true; + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native long CreateWindow(long eglDisplayHandle, boolean chromaKey, int width, int height); + private native void CloseWindow(long eglDisplayHandle, long eglWindowHandle); + private native void SwapWindow(long eglDisplayHandle, long eglWindowHandle); + + + private long realizeWindow(boolean chromaKey, int width, int height) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("BCEGL Window.realizeWindow() with: chroma "+chromaKey+", "+width+"x"+height+", "+getGraphicsConfiguration()); + } + long handle = CreateWindow(getDisplayHandle(), chromaKey, width, height); + if (0 == handle) { + throw new NativeWindowException("Error native Window Handle is null"); + } + windowHandleClose = handle; + return handle; + } + + private void windowCreated(int cfgID, int width, int height) { + defineSize(width, height); + GLCapabilitiesImmutable capsReq = (GLCapabilitiesImmutable) getGraphicsConfiguration().getRequestedCapabilities(); + final AbstractGraphicsConfiguration cfg = EGLGraphicsConfiguration.create(capsReq, getScreen().getGraphicsScreen(), cfgID); + if (null == cfg) { + throw new NativeWindowException("Error creating EGLGraphicsConfiguration from id: "+cfgID+", "+this); + } + setGraphicsConfiguration(cfg); + if(DEBUG_IMPLEMENTATION) { + System.err.println("BCEGL Window.windowCreated(): "+toHexString(cfgID)+", "+width+"x"+height+", "+cfg); + } + } + + private long windowHandleClose; +} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java deleted file mode 100644 index 62af02abb..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Display.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.bcm.vc.iv; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; -import jogamp.opengl.egl.EGL; -import jogamp.opengl.egl.EGLDisplayUtil; - -public class Display extends DisplayImpl { - static { - NEWTJNILibLoader.loadNEWT(); - - if (!Display.initIDs()) { - throw new NativeWindowException("Failed to initialize bcm.vc.iv Display jmethodIDs"); - } - if (!Screen.initIDs()) { - throw new NativeWindowException("Failed to initialize bcm.vc.iv Screen jmethodIDs"); - } - if (!Window.initIDs()) { - throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public Display() { - } - - protected void createNativeImpl() { - // FIXME: map name to EGL_*_DISPLAY - aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { - aDevice.close(); - } - - protected void dispatchMessagesNative() { - DispatchMessages(); - } - - protected static native boolean initIDs(); - private native void DispatchMessages(); -} - diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java new file mode 100644 index 000000000..08c5c573c --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -0,0 +1,78 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.bcm.vc.iv; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; +import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLDisplayUtil; + +public class DisplayDriver extends DisplayImpl { + static { + NEWTJNILibLoader.loadNEWT(); + + if (!DisplayDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize bcm.vc.iv Display jmethodIDs"); + } + if (!ScreenDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize bcm.vc.iv Screen jmethodIDs"); + } + if (!WindowDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + // FIXME: map name to EGL_*_DISPLAY + aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { + aDevice.close(); + } + + protected void dispatchMessagesNative() { + DispatchMessages(); + } + + protected static native boolean initIDs(); + private native void DispatchMessages(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java deleted file mode 100644 index 484d4bf81..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Screen.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.bcm.vc.iv; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.ScreenImpl; - -public class Screen extends ScreenImpl { - static { - Display.initSingleton(); - } - - public Screen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - initNative(); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); - } - - protected void setScreenSize(int width, int height) { - cachedWidth = width; - cachedHeight = height; - } - - private static int cachedWidth = 0; - private static int cachedHeight = 0; - - protected static native boolean initIDs(); - protected native void initNative(); -} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java new file mode 100644 index 000000000..787d1a1b4 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -0,0 +1,73 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.bcm.vc.iv; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.ScreenImpl; + +public class ScreenDriver extends ScreenImpl { + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + initNative(); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(cachedWidth); + virtualSize.setHeight(cachedHeight); + } + + protected void setScreenSize(int width, int height) { + cachedWidth = width; + cachedHeight = height; + } + + private static int cachedWidth = 0; + private static int cachedHeight = 0; + + protected static native boolean initIDs(); + protected native void initNative(); +} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java deleted file mode 100644 index 3d00949de..000000000 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/Window.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package jogamp.newt.driver.bcm.vc.iv; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.WindowImpl; -import jogamp.newt.driver.linux.LinuxMouseTracker; - -public class Window extends WindowImpl { - private static final String WINDOW_CLASS_NAME = "NewtWindow"; - - static { - Display.initSingleton(); - } - - public Window() { - } - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new RuntimeException("Window parenting not supported (yet)"); - } - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - - nativeWindowHandle = CreateWindow(getWidth(), getHeight()); - if (nativeWindowHandle == 0) { - throw new NativeWindowException("Error creating egl window: "+cfg); - } - setVisible0(nativeWindowHandle, false); - setWindowHandle(nativeWindowHandle); - if (0 == getWindowHandle()) { - throw new NativeWindowException("Error native Window Handle is null"); - } - windowHandleClose = nativeWindowHandle; - addWindowListener(LinuxMouseTracker.getSingleton()); - focusChanged(false, true); - } - - protected void closeNativeImpl() { - removeWindowListener(LinuxMouseTracker.getSingleton()); - - if(0!=windowHandleClose) { - CloseWindow(windowHandleClose, windowUserData); - windowUserData=0; - } - } - - protected void requestFocusImpl(boolean reparented) { - focusChanged(false, true); - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - if(0!=nativeWindowHandle) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; - setFullScreen0(nativeWindowHandle, fs); - if(fs) { - return true; - } - } - // int _x=(x>=0)?x:this.x; - // int _y=(x>=0)?y:this.y; - width=(width>0)?width:getWidth(); - height=(height>0)?height:getHeight(); - if(width>0 || height>0) { - setSize0(nativeWindowHandle, width, height); - } - if(x>=0 || y>=0) { - System.err.println("setPosition n/a in KD"); - } - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - //---------------------------------------------------------------------- - // Internals only - // - - protected static native boolean initIDs(); - private native long CreateWindow(int width, int height); - private native long RealizeWindow(long eglWindowHandle); - private native int CloseWindow(long eglWindowHandle, long userData); - private native void setVisible0(long eglWindowHandle, boolean visible); - private native void setSize0(long eglWindowHandle, int width, int height); - private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); - - private void windowCreated(long userData) { - windowUserData=userData; - } - - private long nativeWindowHandle; - private long windowHandleClose; - private long windowUserData; -} diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java new file mode 100644 index 000000000..6d4f36964 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -0,0 +1,149 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.driver.bcm.vc.iv; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.WindowImpl; +import jogamp.newt.driver.linux.LinuxMouseTracker; + +public class WindowDriver extends WindowImpl { + private static final String WINDOW_CLASS_NAME = "NewtWindow"; + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported (yet)"); + } + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + + nativeWindowHandle = CreateWindow(getWidth(), getHeight()); + if (nativeWindowHandle == 0) { + throw new NativeWindowException("Error creating egl window: "+cfg); + } + setVisible0(nativeWindowHandle, false); + setWindowHandle(nativeWindowHandle); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error native Window Handle is null"); + } + windowHandleClose = nativeWindowHandle; + addWindowListener(LinuxMouseTracker.getSingleton()); + focusChanged(false, true); + } + + protected void closeNativeImpl() { + removeWindowListener(LinuxMouseTracker.getSingleton()); + + if(0!=windowHandleClose) { + CloseWindow(windowHandleClose, windowUserData); + windowUserData=0; + } + } + + protected void requestFocusImpl(boolean reparented) { + focusChanged(false, true); + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + if(0!=nativeWindowHandle) { + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; + setFullScreen0(nativeWindowHandle, fs); + if(fs) { + return true; + } + } + // int _x=(x>=0)?x:this.x; + // int _y=(x>=0)?y:this.y; + width=(width>0)?width:getWidth(); + height=(height>0)?height:getHeight(); + if(width>0 || height>0) { + setSize0(nativeWindowHandle, width, height); + } + if(x>=0 || y>=0) { + System.err.println("setPosition n/a in KD"); + } + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native long CreateWindow(int width, int height); + private native long RealizeWindow(long eglWindowHandle); + private native int CloseWindow(long eglWindowHandle, long userData); + private native void setVisible0(long eglWindowHandle, boolean visible); + private native void setSize0(long eglWindowHandle, int width, int height); + private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); + + private void windowCreated(long userData) { + windowUserData=userData; + } + + private long nativeWindowHandle; + private long windowHandleClose; + private long windowUserData; +} diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Display.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Display.java deleted file mode 100644 index 20e151eb3..000000000 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Display.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.intel.gdl; - -import jogamp.newt.*; -import javax.media.nativewindow.*; - -public class Display extends jogamp.newt.DisplayImpl { - static int initCounter = 0; - - static { - NEWTJNILibLoader.loadNEWT(); - - if (!Screen.initIDs()) { - throw new NativeWindowException("Failed to initialize GDL Screen jmethodIDs"); - } - if (!Window.initIDs()) { - throw new NativeWindowException("Failed to initialize GDL Window jmethodIDs"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public Display() { - } - - protected void createNativeImpl() { - synchronized(Display.class) { - if(0==initCounter) { - displayHandle = CreateDisplay(); - if(0==displayHandle) { - throw new NativeWindowException("Couldn't initialize GDL Display"); - } - } - initCounter++; - } - aDevice = new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, displayHandle); - } - - protected void closeNativeImpl() { - if(0==displayHandle) { - throw new NativeWindowException("displayHandle null; initCnt "+initCounter); - } - synchronized(Display.class) { - if(initCounter>0) { - initCounter--; - if(0==initCounter) { - DestroyDisplay(displayHandle); - } - } - } - } - - protected void dispatchMessagesNative() { - if(0!=displayHandle) { - DispatchMessages(displayHandle, focusedWindow); - } - } - - protected void setFocus(Window focus) { - focusedWindow = focus; - } - - private long displayHandle = 0; - private Window focusedWindow = null; - private native long CreateDisplay(); - private native void DestroyDisplay(long displayHandle); - private native void DispatchMessages(long displayHandle, Window focusedWindow); -} - diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java new file mode 100644 index 000000000..97c384d33 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.intel.gdl; + +import jogamp.newt.*; +import javax.media.nativewindow.*; + +public class DisplayDriver extends jogamp.newt.DisplayImpl { + static int initCounter = 0; + + static { + NEWTJNILibLoader.loadNEWT(); + + if (!ScreenDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize GDL Screen jmethodIDs"); + } + if (!WindowDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize GDL Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + synchronized(DisplayDriver.class) { + if(0==initCounter) { + displayHandle = CreateDisplay(); + if(0==displayHandle) { + throw new NativeWindowException("Couldn't initialize GDL Display"); + } + } + initCounter++; + } + aDevice = new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, displayHandle); + } + + protected void closeNativeImpl() { + if(0==displayHandle) { + throw new NativeWindowException("displayHandle null; initCnt "+initCounter); + } + synchronized(DisplayDriver.class) { + if(initCounter>0) { + initCounter--; + if(0==initCounter) { + DestroyDisplay(displayHandle); + } + } + } + } + + protected void dispatchMessagesNative() { + if(0!=displayHandle) { + DispatchMessages(displayHandle, focusedWindow); + } + } + + protected void setFocus(WindowDriver focus) { + focusedWindow = focus; + } + + private long displayHandle = 0; + private WindowDriver focusedWindow = null; + private native long CreateDisplay(); + private native void DestroyDisplay(long displayHandle); + private native void DispatchMessages(long displayHandle, WindowDriver focusedWindow); +} + diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java deleted file mode 100644 index 66ad1c691..000000000 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Screen.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.intel.gdl; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -public class Screen extends jogamp.newt.ScreenImpl { - - static { - Display.initSingleton(); - } - - public Screen() { - } - - protected void createNativeImpl() { - AbstractGraphicsDevice adevice = getDisplay().getGraphicsDevice(); - GetScreenInfo(adevice.getHandle(), screen_idx); - aScreen = new DefaultGraphicsScreen(adevice, screen_idx); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); - } - - //---------------------------------------------------------------------- - // Internals only - // - - protected static native boolean initIDs(); - private native void GetScreenInfo(long displayHandle, int screen_idx); - - // called by GetScreenInfo() .. - private void screenCreated(int width, int height) { - cachedWidth = width; - cachedHeight = height; - } - - private static int cachedWidth = 0; - private static int cachedHeight = 0; -} - diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java new file mode 100644 index 000000000..8eed14dde --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.intel.gdl; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +public class ScreenDriver extends jogamp.newt.ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + AbstractGraphicsDevice adevice = getDisplay().getGraphicsDevice(); + GetScreenInfo(adevice.getHandle(), screen_idx); + aScreen = new DefaultGraphicsScreen(adevice, screen_idx); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(cachedWidth); + virtualSize.setHeight(cachedHeight); + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native void GetScreenInfo(long displayHandle, int screen_idx); + + // called by GetScreenInfo() .. + private void screenCreated(int width, int height) { + cachedWidth = width; + cachedHeight = height; + } + + private static int cachedWidth = 0; + private static int cachedHeight = 0; +} + diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java deleted file mode 100644 index d5c75abd4..000000000 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/Window.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.intel.gdl; - -import javax.media.nativewindow.*; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; - -public class Window extends jogamp.newt.WindowImpl { - static { - Display.initSingleton(); - } - - public Window() { - } - - static long nextWindowHandle = 1; - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new NativeWindowException("GDL Window does not support window parenting"); - } - final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); - final AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice(); - - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aDevice, capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, aScreen, VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - - synchronized(Window.class) { - setWindowHandle(nextWindowHandle++); // just a marker - - surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(), getX(), getY(), getWidth(), getHeight()); - if (surfaceHandle == 0) { - throw new NativeWindowException("Error creating window"); - } - } - } - - protected void closeNativeImpl() { - if(0!=surfaceHandle) { - synchronized(Window.class) { - CloseSurface(getDisplayHandle(), surfaceHandle); - } - surfaceHandle = 0; - ((Display)getScreen().getDisplay()).setFocus(null); - } - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - Screen screen = (Screen) getScreen(); - - if(width>screen.getWidth()) { - width=screen.getWidth(); - } - if(height>screen.getHeight()) { - height=screen.getHeight(); - } - if((x+width)>screen.getWidth()) { - x=screen.getWidth()-width; - } - if((y+height)>screen.getHeight()) { - y=screen.getHeight()-height; - } - - if(0!=surfaceHandle) { - SetBounds0(surfaceHandle, getScreen().getWidth(), getScreen().getHeight(), x, y, width, height); - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - if(0 != ( FLAG_IS_VISIBLE & flags)) { - ((Display)getScreen().getDisplay()).setFocus(this); - } - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - return true; - } - - protected void requestFocusImpl(boolean reparented) { - ((Display)getScreen().getDisplay()).setFocus(this); - } - - @Override - public final long getSurfaceHandle() { - return surfaceHandle; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - //---------------------------------------------------------------------- - // Internals only - // - - protected static native boolean initIDs(); - private native long CreateSurface(long displayHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); - private native void CloseSurface(long displayHandle, long surfaceHandle); - private native void SetBounds0(long surfaceHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); - - private void updateBounds(int x, int y, int width, int height) { - definePosition(x, y); - defineSize(width, height); - } - - private long surfaceHandle; -} diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java new file mode 100644 index 000000000..98335f192 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/WindowDriver.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.intel.gdl; + +import javax.media.nativewindow.*; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; + +public class WindowDriver extends jogamp.newt.WindowImpl { + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + static long nextWindowHandle = 1; + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new NativeWindowException("GDL Window does not support window parenting"); + } + final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); + final AbstractGraphicsDevice aDevice = getScreen().getDisplay().getGraphicsDevice(); + + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aDevice, capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, aScreen, VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + + synchronized(WindowDriver.class) { + setWindowHandle(nextWindowHandle++); // just a marker + + surfaceHandle = CreateSurface(aDevice.getHandle(), getScreen().getWidth(), getScreen().getHeight(), getX(), getY(), getWidth(), getHeight()); + if (surfaceHandle == 0) { + throw new NativeWindowException("Error creating window"); + } + } + } + + protected void closeNativeImpl() { + if(0!=surfaceHandle) { + synchronized(WindowDriver.class) { + CloseSurface(getDisplayHandle(), surfaceHandle); + } + surfaceHandle = 0; + ((DisplayDriver)getScreen().getDisplay()).setFocus(null); + } + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + ScreenDriver screen = (ScreenDriver) getScreen(); + + if(width>screen.getWidth()) { + width=screen.getWidth(); + } + if(height>screen.getHeight()) { + height=screen.getHeight(); + } + if((x+width)>screen.getWidth()) { + x=screen.getWidth()-width; + } + if((y+height)>screen.getHeight()) { + y=screen.getHeight()-height; + } + + if(0!=surfaceHandle) { + SetBounds0(surfaceHandle, getScreen().getWidth(), getScreen().getHeight(), x, y, width, height); + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + if(0 != ( FLAG_IS_VISIBLE & flags)) { + ((DisplayDriver)getScreen().getDisplay()).setFocus(this); + } + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + return true; + } + + protected void requestFocusImpl(boolean reparented) { + ((DisplayDriver)getScreen().getDisplay()).setFocus(this); + } + + @Override + public final long getSurfaceHandle() { + return surfaceHandle; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native long CreateSurface(long displayHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); + private native void CloseSurface(long displayHandle, long surfaceHandle); + private native void SetBounds0(long surfaceHandle, int scrn_width, int scrn_height, int x, int y, int width, int height); + + private void updateBounds(int x, int y, int width, int height) { + definePosition(x, y); + defineSize(width, height); + } + + private long surfaceHandle; +} diff --git a/src/newt/classes/jogamp/newt/driver/kd/Display.java b/src/newt/classes/jogamp/newt/driver/kd/Display.java deleted file mode 100644 index a58ad477a..000000000 --- a/src/newt/classes/jogamp/newt/driver/kd/Display.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.kd; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; -import jogamp.opengl.egl.EGL; -import jogamp.opengl.egl.EGLDisplayUtil; - -public class Display extends DisplayImpl { - static { - NEWTJNILibLoader.loadNEWT(); - - if (!Window.initIDs()) { - throw new NativeWindowException("Failed to initialize kd.Window jmethodIDs"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public Display() { - } - - protected void createNativeImpl() { - // FIXME: map name to EGL_*_DISPLAY - aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { - aDevice.close(); - } - - protected void dispatchMessagesNative() { - DispatchMessages(); - } - - private native void DispatchMessages(); -} - diff --git a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java new file mode 100644 index 000000000..745be5dae --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.kd; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; +import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLDisplayUtil; + +public class DisplayDriver extends DisplayImpl { + static { + NEWTJNILibLoader.loadNEWT(); + + if (!WindowDriver.initIDs()) { + throw new NativeWindowException("Failed to initialize kd.Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + protected void createNativeImpl() { + // FIXME: map name to EGL_*_DISPLAY + aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { + aDevice.close(); + } + + protected void dispatchMessagesNative() { + DispatchMessages(); + } + + private native void DispatchMessages(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/kd/Screen.java b/src/newt/classes/jogamp/newt/driver/kd/Screen.java deleted file mode 100644 index 53f5890b2..000000000 --- a/src/newt/classes/jogamp/newt/driver/kd/Screen.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.kd; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.ScreenImpl; - -public class Screen extends ScreenImpl { - static { - Display.initSingleton(); - } - - public Screen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { } - - protected int validateScreenIndex(int idx) { - return 0; // only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); - } - - protected void sizeChanged(int w, int h) { - cachedWidth = w; - cachedHeight = h; - } - - private static int cachedWidth = 0; - private static int cachedHeight = 0; -} diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java new file mode 100644 index 000000000..656bcf5c9 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.kd; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.ScreenImpl; + +public class ScreenDriver extends ScreenImpl { + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { } + + protected int validateScreenIndex(int idx) { + return 0; // only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(cachedWidth); + virtualSize.setHeight(cachedHeight); + } + + protected void sizeChanged(int w, int h) { + cachedWidth = w; + cachedHeight = h; + } + + private static int cachedWidth = 0; + private static int cachedHeight = 0; +} diff --git a/src/newt/classes/jogamp/newt/driver/kd/Window.java b/src/newt/classes/jogamp/newt/driver/kd/Window.java deleted file mode 100644 index ce65040c3..000000000 --- a/src/newt/classes/jogamp/newt/driver/kd/Window.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.kd; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.VisualIDHolder.VIDType; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.Point; -import javax.media.opengl.GLCapabilitiesImmutable; - -import jogamp.newt.WindowImpl; -import jogamp.opengl.egl.EGLGraphicsConfiguration; - -public class Window extends WindowImpl { - private static final String WINDOW_CLASS_NAME = "NewtWindow"; - - static { - Display.initSingleton(); - } - - public Window() { - } - - protected void createNativeImpl() { - if(0!=getParentWindowHandle()) { - throw new RuntimeException("Window parenting not supported (yet)"); - } - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - - GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) cfg.getChosenCapabilities(); - int eglConfigID = eglCaps.getVisualID(VIDType.EGL_CONFIG); - long eglConfig = EGLGraphicsConfiguration.EGLConfigId2EGLConfig(getDisplayHandle(), eglConfigID); - - eglWindowHandle = CreateWindow(getDisplayHandle(), eglConfig); - if (eglWindowHandle == 0) { - throw new NativeWindowException("Error creating egl window: "+cfg+", eglConfigID "+eglConfigID+", eglConfig 0x"+Long.toHexString(eglConfig)); - } - setVisible0(eglWindowHandle, false); - setWindowHandle(RealizeWindow(eglWindowHandle)); - if (0 == getWindowHandle()) { - throw new NativeWindowException("Error native Window Handle is null"); - } - windowHandleClose = eglWindowHandle; - } - - protected void closeNativeImpl() { - if(0!=windowHandleClose) { - CloseWindow(windowHandleClose, windowUserData); - windowUserData=0; - } - } - - protected void requestFocusImpl(boolean reparented) { } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - setVisible0(eglWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - if(0!=eglWindowHandle) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; - setFullScreen0(eglWindowHandle, fs); - if(fs) { - return true; - } - } - // int _x=(x>=0)?x:this.x; - // int _y=(x>=0)?y:this.y; - width=(width>0)?width:getWidth(); - height=(height>0)?height:getHeight(); - if(width>0 || height>0) { - setSize0(eglWindowHandle, width, height); - } - if(x>=0 || y>=0) { - System.err.println("setPosition n/a in KD"); - } - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return new Point(x,y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop .. - } - - //---------------------------------------------------------------------- - // Internals only - // - - protected static native boolean initIDs(); - private native long CreateWindow(long displayHandle, long eglConfig); - private native long RealizeWindow(long eglWindowHandle); - private native int CloseWindow(long eglWindowHandle, long userData); - private native void setVisible0(long eglWindowHandle, boolean visible); - private native void setSize0(long eglWindowHandle, int width, int height); - private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); - - private void windowCreated(long userData) { - windowUserData=userData; - } - - @Override - protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { - if(isFullscreen()) { - ((Screen)getScreen()).sizeChanged(getWidth(), getHeight()); - } - super.sizeChanged(defer, newWidth, newHeight, force); - } - - private long eglWindowHandle; - private long windowHandleClose; - private long windowUserData; -} diff --git a/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java new file mode 100644 index 000000000..c733a3e94 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/kd/WindowDriver.java @@ -0,0 +1,163 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.kd; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.VisualIDHolder.VIDType; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.Point; +import javax.media.opengl.GLCapabilitiesImmutable; + +import jogamp.newt.WindowImpl; +import jogamp.opengl.egl.EGLGraphicsConfiguration; + +public class WindowDriver extends WindowImpl { + private static final String WINDOW_CLASS_NAME = "NewtWindow"; + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + protected void createNativeImpl() { + if(0!=getParentWindowHandle()) { + throw new RuntimeException("Window parenting not supported (yet)"); + } + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + + GLCapabilitiesImmutable eglCaps = (GLCapabilitiesImmutable) cfg.getChosenCapabilities(); + int eglConfigID = eglCaps.getVisualID(VIDType.EGL_CONFIG); + long eglConfig = EGLGraphicsConfiguration.EGLConfigId2EGLConfig(getDisplayHandle(), eglConfigID); + + eglWindowHandle = CreateWindow(getDisplayHandle(), eglConfig); + if (eglWindowHandle == 0) { + throw new NativeWindowException("Error creating egl window: "+cfg+", eglConfigID "+eglConfigID+", eglConfig 0x"+Long.toHexString(eglConfig)); + } + setVisible0(eglWindowHandle, false); + setWindowHandle(RealizeWindow(eglWindowHandle)); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error native Window Handle is null"); + } + windowHandleClose = eglWindowHandle; + } + + protected void closeNativeImpl() { + if(0!=windowHandleClose) { + CloseWindow(windowHandleClose, windowUserData); + windowUserData=0; + } + } + + protected void requestFocusImpl(boolean reparented) { } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + setVisible0(eglWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + if(0!=eglWindowHandle) { + if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { + final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; + setFullScreen0(eglWindowHandle, fs); + if(fs) { + return true; + } + } + // int _x=(x>=0)?x:this.x; + // int _y=(x>=0)?y:this.y; + width=(width>0)?width:getWidth(); + height=(height>0)?height:getHeight(); + if(width>0 || height>0) { + setSize0(eglWindowHandle, width, height); + } + if(x>=0 || y>=0) { + System.err.println("setPosition n/a in KD"); + } + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return new Point(x,y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop .. + } + + //---------------------------------------------------------------------- + // Internals only + // + + protected static native boolean initIDs(); + private native long CreateWindow(long displayHandle, long eglConfig); + private native long RealizeWindow(long eglWindowHandle); + private native int CloseWindow(long eglWindowHandle, long userData); + private native void setVisible0(long eglWindowHandle, boolean visible); + private native void setSize0(long eglWindowHandle, int width, int height); + private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); + + private void windowCreated(long userData) { + windowUserData=userData; + } + + @Override + protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { + if(isFullscreen()) { + ((ScreenDriver)getScreen()).sizeChanged(getWidth(), getHeight()); + } + super.sizeChanged(defer, newWidth, newHeight, force); + } + + private long eglWindowHandle; + private long windowHandleClose; + private long windowUserData; +} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java new file mode 100644 index 000000000..1a3f14859 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.macosx; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; + +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; + +public class DisplayDriver extends DisplayImpl { + static { + NEWTJNILibLoader.loadNEWT(); + + if(!initNSApplication0()) { + throw new NativeWindowException("Failed to initialize native Application hook"); + } + if(!WindowDriver.initIDs0()) { + throw new NativeWindowException("Failed to initialize jmethodIDs"); + } + if(DEBUG) { + System.err.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName()); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + public DisplayDriver() { + } + + protected void dispatchMessagesNative() { + // nop + } + + protected void createNativeImpl() { + aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { } + + public static void runNSApplication() { + runNSApplication0(); + } + public static void stopNSApplication() { + stopNSApplication0(); + } + + private static native boolean initNSApplication0(); + private static native void runNSApplication0(); + private static native void stopNSApplication0(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java b/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java deleted file mode 100644 index 18f8d9538..000000000 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacDisplay.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.macosx; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; - -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; - -public class MacDisplay extends DisplayImpl { - static { - NEWTJNILibLoader.loadNEWT(); - - if(!initNSApplication0()) { - throw new NativeWindowException("Failed to initialize native Application hook"); - } - if(!MacWindow.initIDs0()) { - throw new NativeWindowException("Failed to initialize jmethodIDs"); - } - if(DEBUG) { - System.err.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName()); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - public MacDisplay() { - } - - protected void dispatchMessagesNative() { - // nop - } - - protected void createNativeImpl() { - aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { } - - public static void runNSApplication() { - runNSApplication0(); - } - public static void stopNSApplication() { - stopNSApplication0(); - } - - private static native boolean initNSApplication0(); - private static native void runNSApplication0(); - private static native void stopNSApplication0(); -} - diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java index 46625f7a9..d39e0027b 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java @@ -1,3 +1,30 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ package jogamp.newt.driver.macosx; import com.jogamp.newt.event.KeyEvent; diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java b/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java deleted file mode 100644 index b9c725fd4..000000000 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacScreen.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.macosx; - -import java.util.List; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.ScreenImpl; - -import com.jogamp.common.util.IntObjectHashMap; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -public class MacScreen extends ScreenImpl { - - // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) - private static IntObjectHashMap/**/ scrnIdx2Dimension; - - static { - MacDisplay.initSingleton(); - scrnIdx2Dimension = new IntObjectHashMap(); - scrnIdx2Dimension.setKeyNotFoundValue(null); - } - - public MacScreen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { } - - private static native int getWidthImpl0(int scrn_idx); - private static native int getHeightImpl0(int scrn_idx); - - private int[] getScreenModeIdx(int idx) { - // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) - DimensionImmutable dim = (DimensionImmutable) scrnIdx2Dimension.get(screen_idx); - if(null == dim) { - int[] res = getScreenSizeMM0(screen_idx); - if(null == res || 0 == res.length) { - return null; - } - dim = new Dimension(res[0], res[1]); - scrnIdx2Dimension.put(screen_idx, dim); - } - - int[] modeProps = getScreenMode0(screen_idx, idx, dim.getWidth(), dim.getHeight()); - if (null == modeProps || 0 == modeProps.length) { - return null; - } - if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { - throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); - } - return modeProps; - } - - private int nativeModeIdx; - - protected int[] getScreenModeFirstImpl() { - nativeModeIdx = 0; - return getScreenModeNextImpl(); - } - - protected int[] getScreenModeNextImpl() { - int[] modeProps = getScreenModeIdx(nativeModeIdx); - if (null != modeProps && 0 < modeProps.length) { - nativeModeIdx++; - return modeProps; - } - return null; - } - - protected ScreenMode getCurrentScreenModeImpl() { - int[] modeProps = getScreenModeIdx(-1); - if (null != modeProps && 0 < modeProps.length) { - return ScreenModeUtil.streamIn(modeProps, 0); - } - return null; - } - - protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { - final List screenModes = this.getScreenModesOrig(); - final int screenModeIdx = screenModes.indexOf(screenMode); - if(0>screenModeIdx) { - throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); - } - final int nativeModeIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - return setScreenMode0(screen_idx, nativeModeIdx); - } - - protected int validateScreenIndex(int idx) { - return idx; - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(getWidthImpl0(screen_idx)); - virtualSize.setHeight(getHeightImpl0(screen_idx)); - } - - private native int[] getScreenSizeMM0(int screen_idx); - private native int[] getScreenMode0(int screen_index, int mode_index, int widthMM, int heightMM); - private native boolean setScreenMode0(int screen_index, int mode_idx); -} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java b/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java deleted file mode 100644 index 27d7a1679..000000000 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacWindow.java +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.macosx; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindow; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.MutableSurface; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.InsetsImmutable; -import javax.media.nativewindow.util.Point; -import javax.media.nativewindow.util.PointImmutable; - -import jogamp.newt.WindowImpl; -import jogamp.newt.driver.DriverClearFocus; -import jogamp.newt.driver.DriverUpdatePosition; - -import com.jogamp.newt.event.KeyEvent; - -public class MacWindow extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { - - static { - MacDisplay.initSingleton(); - } - - public MacWindow() { - } - - @Override - protected void createNativeImpl() { - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true)); - if (0 == getWindowHandle()) { - throw new NativeWindowException("Error creating window"); - } - } - - @Override - protected void closeNativeImpl() { - try { - if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.CloseAction "+Thread.currentThread().getName()); } - final long handle = getWindowHandle(); - setWindowHandle(0); - surfaceHandle = 0; - sscSurfaceHandle = 0; - isOffscreenInstance = false; - if (0 != handle) { - close0(handle); - } - } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNative failed - "+Thread.currentThread().getName(), t); - e.printStackTrace(); - } - } - } - - @Override - protected int lockSurfaceImpl() { - if(!isOffscreenInstance) { - return lockSurface0(getWindowHandle()) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; - } - return LOCK_SUCCESS; - } - - @Override - protected void unlockSurfaceImpl() { - if(!isOffscreenInstance) { - final long h = getWindowHandle(); - if(0 != h) { - unlockSurface0(h); - } - } - } - - @Override - public final long getSurfaceHandle() { - return 0 != sscSurfaceHandle ? sscSurfaceHandle : surfaceHandle; - } - - public void setSurfaceHandle(long surfaceHandle) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); - } - sscSurfaceHandle = surfaceHandle; - if (isNativeValid()) { - if (0 != sscSurfaceHandle) { - orderOut0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); - } /** this is done by recreation! - else if (isVisible()){ - orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); - } */ - } - } - - @Override - protected void setTitleImpl(final String title) { - setTitle0(getWindowHandle(), title); - } - - protected void requestFocusImpl(boolean force) { - if(!isOffscreenInstance) { - requestFocus0(getWindowHandle(), force); - } else { - focusChanged(false, true); - } - } - - public final void clearFocus() { - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: clearFocus() - requestFocusParent, isOffscreenInstance "+isOffscreenInstance); - } - if(!isOffscreenInstance) { - resignFocus0(getWindowHandle()); - } else { - focusChanged(false, false); - } - } - - public void updatePosition() { - final Point pS = getTopLevelLocationOnScreen(getX(), getY()); - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow: updatePosition() - isOffscreenInstance "+isOffscreenInstance+", new abs pos: pS "+pS); - } - if( !isOffscreenInstance ) { - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); - } // else no offscreen position - // no native event (fullscreen, some reparenting) - super.positionChanged(true, getX(), getY()); - } - - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - final Point pS = getTopLevelLocationOnScreen(x, y); - isOffscreenInstance = 0 != sscSurfaceHandle || isOffscreenInstance(this, this.getParent()); - - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow reconfig: "+x+"/"+y+" -> "+pS+" - "+width+"x"+height+ - ", offscreenInstance "+isOffscreenInstance+ - ", "+getReconfigureFlagsAsString(null, flags)); - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { - if ( !isOffscreenInstance ) { - orderOut0(getWindowHandle()); - } - // no native event .. - visibleChanged(true, false); - } - if( 0 == getWindowHandle() && 0 != ( FLAG_IS_VISIBLE & flags) || - 0 != ( FLAG_CHANGE_DECORATION & flags) || - 0 != ( FLAG_CHANGE_PARENTING & flags) || - 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { - createWindow(isOffscreenInstance, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); - if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } - } - if(x>=0 && y>=0) { - if( !isOffscreenInstance ) { - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); - } // else no offscreen position - // no native event (fullscreen, some reparenting) - super.positionChanged(true, x, y); - } - if(width>0 && height>0) { - if( !isOffscreenInstance ) { - setContentSize0(getWindowHandle(), width, height); - } // else offscreen size is realized via recreation - // no native event (fullscreen, some reparenting) - sizeChanged(true, width, height, false); // incl. validation (incl. repositioning) - } - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { - if( !isOffscreenInstance ) { - orderFront0(getWindowHandle()); - } - // no native event .. - visibleChanged(true, true); - } - if( !isOffscreenInstance ) { - setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags)); - } - return true; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - Point p = new Point(x, y); - // min val is 0 - p.setX(Math.max(p.getX(), 0)); - p.setY(Math.max(p.getY(), 0)); - - final NativeWindow parent = getParent(); - if( null != parent && 0 != parent.getWindowHandle() ) { - p.translate(parent.getLocationOnScreen(null)); - } - return p; - } - - private Point getTopLevelLocationOnScreen(int x, int y) { - final InsetsImmutable _insets = getInsets(); // zero if undecorated - // client position -> top-level window position - x -= _insets.getLeftWidth() ; - y -= _insets.getTopHeight() ; - return getLocationOnScreenImpl(x, y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop - using event driven insetsChange(..) - } - - @Override - protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { - if(getWidth() != newWidth || getHeight() != newHeight) { - final Point p0S = getTopLevelLocationOnScreen(getX(), getY()); - setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), p0S.getX(), p0S.getY()); - } - super.sizeChanged(defer, newWidth, newHeight, force); - } - - @Override - protected void positionChanged(boolean defer, int newX, int newY) { - // passed coordinates are in screen position of the client area - if(getWindowHandle()!=0) { - // screen position -> window position - Point absPos = new Point(newX, newY); - final NativeWindow parent = getParent(); - if(null != parent) { - absPos.translate( parent.getLocationOnScreen(null).scale(-1, -1) ); - } - super.positionChanged(defer, absPos.getX(), absPos.getY()); - } - } - - @Override - protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - if( !isOffscreenInstance ) { - return setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible); - } // else may need offscreen solution ? FIXME - return false; - } - - @Override - protected boolean confinePointerImpl(final boolean confine) { - if( !isOffscreenInstance ) { - return confinePointer0(getWindowHandle(), confine); - } // else may need offscreen solution ? FIXME - return false; - } - - @Override - protected void warpPointerImpl(final int x, final int y) { - if( !isOffscreenInstance ) { - warpPointer0(getWindowHandle(), x, y); - } // else may need offscreen solution ? FIXME - } - - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we send the key char for the key code on this - // platform -- we do not get any useful key codes out of the system - final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); - final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); - if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); - if(valid) { - // only deliver keyChar on key Typed events, harmonizing platform behavior - keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; - super.sendKeyEvent(eventType, modifiers, keyCode2, keyChar); - } - } - - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we send the key char for the key code on this - // platform -- we do not get any useful key codes out of the system - final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); - final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); - if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); - if(valid) { - // only deliver keyChar on key Typed events, harmonizing platform behavior - keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode2, keyChar); - } - } - - private int keyDownModifiers = 0; - private int keyDownCode = 0; - - private boolean validateKeyEvent(int eventType, int modifiers, int keyCode) { - switch(eventType) { - case KeyEvent.EVENT_KEY_PRESSED: - keyDownModifiers = modifiers; - keyDownCode = keyCode; - return true; - case KeyEvent.EVENT_KEY_RELEASED: - return keyDownModifiers == modifiers && keyDownCode == keyCode; - case KeyEvent.EVENT_KEY_TYPED: - final boolean matchKeyDown = keyDownModifiers == modifiers && keyDownCode == keyCode; - keyDownModifiers = 0; - keyDownCode = 0; - return matchKeyDown; - default: - throw new NativeWindowException("Unexpected key event type " + eventType); - } - } - - - //---------------------------------------------------------------------- - // Internals only - // - - private void createWindow(final boolean offscreenInstance, final boolean recreate, - final PointImmutable pS, final int width, final int height, - final boolean fullscreen) { - - if(0!=getWindowHandle() && !recreate) { - return; - } - - try { - if(0!=getWindowHandle()) { - // save the view .. close the window - surfaceHandle = changeContentView0(getParentWindowHandle(), getWindowHandle(), 0); - if(recreate && 0==surfaceHandle) { - throw new NativeWindowException("Internal Error - recreate, window but no view"); - } - close0(getWindowHandle()); - setWindowHandle(0); - } else { - surfaceHandle = 0; - } - setWindowHandle(createWindow0(getParentWindowHandle(), - pS.getX(), pS.getY(), width, height, - (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), - fullscreen, - ((isUndecorated() || offscreenInstance) ? - NSBorderlessWindowMask : - NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask), - NSBackingStoreBuffered, - getScreen().getIndex(), surfaceHandle)); - if (getWindowHandle() == 0) { - throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this); - } - surfaceHandle = contentView0(getWindowHandle()); - if( offscreenInstance ) { - orderOut0(0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle()); - } else { - setTitle0(getWindowHandle(), getTitle()); - } - } catch (Exception ie) { - ie.printStackTrace(); - } - } - - protected static native boolean initIDs0(); - private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, int windowStyle, - int backingStoreType, - int screen_idx, long view); - private native boolean lockSurface0(long window); - private native void unlockSurface0(long window); - private native void requestFocus0(long window, boolean force); - private native void resignFocus0(long window); - /** in case of a child window, it actually only issues orderBack(..) */ - private native void orderOut0(long window); - private native void orderFront0(long window); - private native void close0(long window); - private native void setTitle0(long window, String title); - private native long contentView0(long window); - private native long changeContentView0(long parentWindowOrViewHandle, long window, long view); - private native void setContentSize0(long window, int w, int h); - private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y); - private native void setAlwaysOnTop0(long window, boolean atop); - private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); - private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); - private static native boolean confinePointer0(long windowHandle, boolean confine); - private static native void warpPointer0(long windowHandle, int x, int y); - - // Window styles - private static final int NSBorderlessWindowMask = 0; - private static final int NSTitledWindowMask = 1 << 0; - private static final int NSClosableWindowMask = 1 << 1; - private static final int NSMiniaturizableWindowMask = 1 << 2; - private static final int NSResizableWindowMask = 1 << 3; - - // Window backing store types - private static final int NSBackingStoreRetained = 0; - private static final int NSBackingStoreNonretained = 1; - private static final int NSBackingStoreBuffered = 2; - - private volatile long surfaceHandle = 0; - private long sscSurfaceHandle = 0; - private boolean isOffscreenInstance = false; - -} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java new file mode 100644 index 000000000..24e60ba0a --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.macosx; + +import java.util.List; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.ScreenImpl; + +import com.jogamp.common.util.IntObjectHashMap; +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class ScreenDriver extends ScreenImpl { + + // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) + private static IntObjectHashMap/**/ scrnIdx2Dimension; + + static { + DisplayDriver.initSingleton(); + scrnIdx2Dimension = new IntObjectHashMap(); + scrnIdx2Dimension.setKeyNotFoundValue(null); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { } + + private static native int getWidthImpl0(int scrn_idx); + private static native int getHeightImpl0(int scrn_idx); + + private int[] getScreenModeIdx(int idx) { + // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) + DimensionImmutable dim = (DimensionImmutable) scrnIdx2Dimension.get(screen_idx); + if(null == dim) { + int[] res = getScreenSizeMM0(screen_idx); + if(null == res || 0 == res.length) { + return null; + } + dim = new Dimension(res[0], res[1]); + scrnIdx2Dimension.put(screen_idx, dim); + } + + int[] modeProps = getScreenMode0(screen_idx, idx, dim.getWidth(), dim.getHeight()); + if (null == modeProps || 0 == modeProps.length) { + return null; + } + if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { + throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); + } + return modeProps; + } + + private int nativeModeIdx; + + protected int[] getScreenModeFirstImpl() { + nativeModeIdx = 0; + return getScreenModeNextImpl(); + } + + protected int[] getScreenModeNextImpl() { + int[] modeProps = getScreenModeIdx(nativeModeIdx); + if (null != modeProps && 0 < modeProps.length) { + nativeModeIdx++; + return modeProps; + } + return null; + } + + protected ScreenMode getCurrentScreenModeImpl() { + int[] modeProps = getScreenModeIdx(-1); + if (null != modeProps && 0 < modeProps.length) { + return ScreenModeUtil.streamIn(modeProps, 0); + } + return null; + } + + protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { + final List screenModes = this.getScreenModesOrig(); + final int screenModeIdx = screenModes.indexOf(screenMode); + if(0>screenModeIdx) { + throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); + } + final int nativeModeIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); + return setScreenMode0(screen_idx, nativeModeIdx); + } + + protected int validateScreenIndex(int idx) { + return idx; + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(getWidthImpl0(screen_idx)); + virtualSize.setHeight(getHeightImpl0(screen_idx)); + } + + private native int[] getScreenSizeMM0(int screen_idx); + private native int[] getScreenMode0(int screen_index, int mode_index, int widthMM, int heightMM); + private native boolean setScreenMode0(int screen_index, int mode_idx); +} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java new file mode 100644 index 000000000..ea48569bf --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -0,0 +1,431 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.macosx; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.MutableSurface; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; + +import jogamp.newt.WindowImpl; +import jogamp.newt.driver.DriverClearFocus; +import jogamp.newt.driver.DriverUpdatePosition; + +import com.jogamp.newt.event.KeyEvent; + +public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + @Override + protected void createNativeImpl() { + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY, true)); + if (0 == getWindowHandle()) { + throw new NativeWindowException("Error creating window"); + } + } + + @Override + protected void closeNativeImpl() { + try { + if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.CloseAction "+Thread.currentThread().getName()); } + final long handle = getWindowHandle(); + setWindowHandle(0); + surfaceHandle = 0; + sscSurfaceHandle = 0; + isOffscreenInstance = false; + if (0 != handle) { + close0(handle); + } + } catch (Throwable t) { + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Warning: closeNative failed - "+Thread.currentThread().getName(), t); + e.printStackTrace(); + } + } + } + + @Override + protected int lockSurfaceImpl() { + if(!isOffscreenInstance) { + return lockSurface0(getWindowHandle()) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; + } + return LOCK_SUCCESS; + } + + @Override + protected void unlockSurfaceImpl() { + if(!isOffscreenInstance) { + final long h = getWindowHandle(); + if(0 != h) { + unlockSurface0(h); + } + } + } + + @Override + public final long getSurfaceHandle() { + return 0 != sscSurfaceHandle ? sscSurfaceHandle : surfaceHandle; + } + + public void setSurfaceHandle(long surfaceHandle) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); + } + sscSurfaceHandle = surfaceHandle; + if (isNativeValid()) { + if (0 != sscSurfaceHandle) { + orderOut0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + } /** this is done by recreation! + else if (isVisible()){ + orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + } */ + } + } + + @Override + protected void setTitleImpl(final String title) { + setTitle0(getWindowHandle(), title); + } + + protected void requestFocusImpl(boolean force) { + if(!isOffscreenInstance) { + requestFocus0(getWindowHandle(), force); + } else { + focusChanged(false, true); + } + } + + public final void clearFocus() { + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow: clearFocus() - requestFocusParent, isOffscreenInstance "+isOffscreenInstance); + } + if(!isOffscreenInstance) { + resignFocus0(getWindowHandle()); + } else { + focusChanged(false, false); + } + } + + public void updatePosition() { + final Point pS = getTopLevelLocationOnScreen(getX(), getY()); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow: updatePosition() - isOffscreenInstance "+isOffscreenInstance+", new abs pos: pS "+pS); + } + if( !isOffscreenInstance ) { + setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); + } // else no offscreen position + // no native event (fullscreen, some reparenting) + super.positionChanged(true, getX(), getY()); + } + + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + final Point pS = getTopLevelLocationOnScreen(x, y); + isOffscreenInstance = 0 != sscSurfaceHandle || isOffscreenInstance(this, this.getParent()); + + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow reconfig: "+x+"/"+y+" -> "+pS+" - "+width+"x"+height+ + ", offscreenInstance "+isOffscreenInstance+ + ", "+getReconfigureFlagsAsString(null, flags)); + } + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { + if ( !isOffscreenInstance ) { + orderOut0(getWindowHandle()); + } + // no native event .. + visibleChanged(true, false); + } + if( 0 == getWindowHandle() && 0 != ( FLAG_IS_VISIBLE & flags) || + 0 != ( FLAG_CHANGE_DECORATION & flags) || + 0 != ( FLAG_CHANGE_PARENTING & flags) || + 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { + createWindow(isOffscreenInstance, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } + } + if(x>=0 && y>=0) { + if( !isOffscreenInstance ) { + setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), pS.getX(), pS.getY()); + } // else no offscreen position + // no native event (fullscreen, some reparenting) + super.positionChanged(true, x, y); + } + if(width>0 && height>0) { + if( !isOffscreenInstance ) { + setContentSize0(getWindowHandle(), width, height); + } // else offscreen size is realized via recreation + // no native event (fullscreen, some reparenting) + sizeChanged(true, width, height, false); // incl. validation (incl. repositioning) + } + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { + if( !isOffscreenInstance ) { + orderFront0(getWindowHandle()); + } + // no native event .. + visibleChanged(true, true); + } + if( !isOffscreenInstance ) { + setAlwaysOnTop0(getWindowHandle(), 0 != ( FLAG_IS_ALWAYSONTOP & flags)); + } + return true; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + Point p = new Point(x, y); + // min val is 0 + p.setX(Math.max(p.getX(), 0)); + p.setY(Math.max(p.getY(), 0)); + + final NativeWindow parent = getParent(); + if( null != parent && 0 != parent.getWindowHandle() ) { + p.translate(parent.getLocationOnScreen(null)); + } + return p; + } + + private Point getTopLevelLocationOnScreen(int x, int y) { + final InsetsImmutable _insets = getInsets(); // zero if undecorated + // client position -> top-level window position + x -= _insets.getLeftWidth() ; + y -= _insets.getTopHeight() ; + return getLocationOnScreenImpl(x, y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop - using event driven insetsChange(..) + } + + @Override + protected void sizeChanged(boolean defer, int newWidth, int newHeight, boolean force) { + if(getWidth() != newWidth || getHeight() != newHeight) { + final Point p0S = getTopLevelLocationOnScreen(getX(), getY()); + setFrameTopLeftPoint0(getParentWindowHandle(), getWindowHandle(), p0S.getX(), p0S.getY()); + } + super.sizeChanged(defer, newWidth, newHeight, force); + } + + @Override + protected void positionChanged(boolean defer, int newX, int newY) { + // passed coordinates are in screen position of the client area + if(getWindowHandle()!=0) { + // screen position -> window position + Point absPos = new Point(newX, newY); + final NativeWindow parent = getParent(); + if(null != parent) { + absPos.translate( parent.getLocationOnScreen(null).scale(-1, -1) ); + } + super.positionChanged(defer, absPos.getX(), absPos.getY()); + } + } + + @Override + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { + if( !isOffscreenInstance ) { + return setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible); + } // else may need offscreen solution ? FIXME + return false; + } + + @Override + protected boolean confinePointerImpl(final boolean confine) { + if( !isOffscreenInstance ) { + return confinePointer0(getWindowHandle(), confine); + } // else may need offscreen solution ? FIXME + return false; + } + + @Override + protected void warpPointerImpl(final int x, final int y) { + if( !isOffscreenInstance ) { + warpPointer0(getWindowHandle(), x, y); + } // else may need offscreen solution ? FIXME + } + + @Override + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + // Note that we send the key char for the key code on this + // platform -- we do not get any useful key codes out of the system + final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); + final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); + if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); + if(valid) { + // only deliver keyChar on key Typed events, harmonizing platform behavior + keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; + super.sendKeyEvent(eventType, modifiers, keyCode2, keyChar); + } + } + + @Override + public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + // Note that we send the key char for the key code on this + // platform -- we do not get any useful key codes out of the system + final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); + final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); + if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); + if(valid) { + // only deliver keyChar on key Typed events, harmonizing platform behavior + keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode2, keyChar); + } + } + + private int keyDownModifiers = 0; + private int keyDownCode = 0; + + private boolean validateKeyEvent(int eventType, int modifiers, int keyCode) { + switch(eventType) { + case KeyEvent.EVENT_KEY_PRESSED: + keyDownModifiers = modifiers; + keyDownCode = keyCode; + return true; + case KeyEvent.EVENT_KEY_RELEASED: + return keyDownModifiers == modifiers && keyDownCode == keyCode; + case KeyEvent.EVENT_KEY_TYPED: + final boolean matchKeyDown = keyDownModifiers == modifiers && keyDownCode == keyCode; + keyDownModifiers = 0; + keyDownCode = 0; + return matchKeyDown; + default: + throw new NativeWindowException("Unexpected key event type " + eventType); + } + } + + + //---------------------------------------------------------------------- + // Internals only + // + + private void createWindow(final boolean offscreenInstance, final boolean recreate, + final PointImmutable pS, final int width, final int height, + final boolean fullscreen) { + + if(0!=getWindowHandle() && !recreate) { + return; + } + + try { + if(0!=getWindowHandle()) { + // save the view .. close the window + surfaceHandle = changeContentView0(getParentWindowHandle(), getWindowHandle(), 0); + if(recreate && 0==surfaceHandle) { + throw new NativeWindowException("Internal Error - recreate, window but no view"); + } + close0(getWindowHandle()); + setWindowHandle(0); + } else { + surfaceHandle = 0; + } + setWindowHandle(createWindow0(getParentWindowHandle(), + pS.getX(), pS.getY(), width, height, + (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), + fullscreen, + ((isUndecorated() || offscreenInstance) ? + NSBorderlessWindowMask : + NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask), + NSBackingStoreBuffered, + getScreen().getIndex(), surfaceHandle)); + if (getWindowHandle() == 0) { + throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this); + } + surfaceHandle = contentView0(getWindowHandle()); + if( offscreenInstance ) { + orderOut0(0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle()); + } else { + setTitle0(getWindowHandle(), getTitle()); + } + } catch (Exception ie) { + ie.printStackTrace(); + } + } + + protected static native boolean initIDs0(); + private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h, + boolean opaque, boolean fullscreen, int windowStyle, + int backingStoreType, + int screen_idx, long view); + private native boolean lockSurface0(long window); + private native void unlockSurface0(long window); + private native void requestFocus0(long window, boolean force); + private native void resignFocus0(long window); + /** in case of a child window, it actually only issues orderBack(..) */ + private native void orderOut0(long window); + private native void orderFront0(long window); + private native void close0(long window); + private native void setTitle0(long window, String title); + private native long contentView0(long window); + private native long changeContentView0(long parentWindowOrViewHandle, long window, long view); + private native void setContentSize0(long window, int w, int h); + private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y); + private native void setAlwaysOnTop0(long window, boolean atop); + private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); + private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); + private static native boolean confinePointer0(long windowHandle, boolean confine); + private static native void warpPointer0(long windowHandle, int x, int y); + + // Window styles + private static final int NSBorderlessWindowMask = 0; + private static final int NSTitledWindowMask = 1 << 0; + private static final int NSClosableWindowMask = 1 << 1; + private static final int NSMiniaturizableWindowMask = 1 << 2; + private static final int NSResizableWindowMask = 1 << 3; + + // Window backing store types + private static final int NSBackingStoreRetained = 0; + private static final int NSBackingStoreNonretained = 1; + private static final int NSBackingStoreBuffered = 2; + + private volatile long surfaceHandle = 0; + private long sscSurfaceHandle = 0; + private boolean isOffscreenInstance = false; + +} diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java new file mode 100644 index 000000000..579ec5be8 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.windows; + +import jogamp.nativewindow.windows.RegisteredClass; +import jogamp.nativewindow.windows.RegisteredClassFactory; +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; + +public class DisplayDriver extends DisplayImpl { + + private static final String newtClassBaseName = "_newt_clazz" ; + private static RegisteredClassFactory sharedClassFactory; + + static { + NEWTJNILibLoader.loadNEWT(); + + if (!WindowDriver.initIDs0()) { + throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); + } + sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0()); + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + private RegisteredClass sharedClass; + + public DisplayDriver() { + } + + protected void createNativeImpl() { + sharedClass = sharedClassFactory.getSharedClass(); + aDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); + } + + protected void closeNativeImpl() { + sharedClassFactory.releaseSharedClass(); + } + + protected void dispatchMessagesNative() { + DispatchMessages0(); + } + + protected long getHInstance() { + return sharedClass.getHandle(); + } + + protected String getWindowClassName() { + return sharedClass.getName(); + } + + //---------------------------------------------------------------------- + // Internals only + // + private static native void DispatchMessages0(); +} + diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java new file mode 100644 index 000000000..948b29460 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ +package jogamp.newt.driver.windows; + +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class ScreenDriver extends ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { + } + + private int[] getScreenModeIdx(int idx) { + int[] modeProps = getScreenMode0(screen_idx, idx); + if (null == modeProps || 0 == modeProps.length) { + return null; + } + if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { + throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); + } + return modeProps; + } + + private int nativeModeIdx; + + protected int[] getScreenModeFirstImpl() { + nativeModeIdx = 0; + return getScreenModeNextImpl(); + } + + protected int[] getScreenModeNextImpl() { + int[] modeProps = getScreenModeIdx(nativeModeIdx); + if (null != modeProps && 0 < modeProps.length) { + nativeModeIdx++; + return modeProps; + } + return null; + } + + protected ScreenMode getCurrentScreenModeImpl() { + int[] modeProps = getScreenModeIdx(-1); + if (null != modeProps && 0 < modeProps.length) { + return ScreenModeUtil.streamIn(modeProps, 0); + } + return null; + } + + protected boolean setCurrentScreenModeImpl(ScreenMode sm) { + return setScreenMode0(screen_idx, + sm.getMonitorMode().getSurfaceSize().getResolution().getWidth(), + sm.getMonitorMode().getSurfaceSize().getResolution().getHeight(), + sm.getMonitorMode().getSurfaceSize().getBitsPerPixel(), + sm.getMonitorMode().getRefreshRate(), + sm.getRotation()); + } + + protected int validateScreenIndex(int idx) { + return 0; // big-desktop, only one screen available + } + + protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { + virtualOrigin.setX(getOriginX0(screen_idx)); + virtualOrigin.setY(getOriginY0(screen_idx)); + virtualSize.setWidth(getWidthImpl0(screen_idx)); + virtualSize.setHeight(getHeightImpl0(screen_idx)); + } + + // Native calls + private native int getOriginX0(int screen_idx); + private native int getOriginY0(int screen_idx); + private native int getWidthImpl0(int scrn_idx); + private native int getHeightImpl0(int scrn_idx); + + private native int[] getScreenMode0(int screen_index, int mode_index); + private native boolean setScreenMode0(int screen_index, int width, int height, int bits, int freq, int rot); +} diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java new file mode 100644 index 000000000..39ea54575 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.windows; + +import jogamp.nativewindow.windows.GDI; +import jogamp.nativewindow.windows.GDIUtil; +import jogamp.newt.WindowImpl; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.GraphicsConfigurationFactory; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.Point; + +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.MouseAdapter; +import com.jogamp.newt.event.MouseEvent; + +public class WindowDriver extends WindowImpl { + + private long hmon; + private long hdc; + private long hdc_old; + private long windowHandleClose; + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + @Override + protected int lockSurfaceImpl() { + if (0 != hdc) { + throw new InternalError("surface not released"); + } + hdc = GDI.GetDC(getWindowHandle()); + hmon = MonitorFromWindow0(getWindowHandle()); + + // return ( 0 == hdc ) ? LOCK_SURFACE_NOT_READY : ( hdc_old != hdc ) ? LOCK_SURFACE_CHANGED : LOCK_SUCCESS ; + if( 0 == hdc ) { + return LOCK_SURFACE_NOT_READY; + } + if( hdc_old == hdc ) { + return LOCK_SUCCESS; + } + if(DEBUG_IMPLEMENTATION) { + System.err.println("WindowsWindow: surface change "+toHexString(hdc_old)+" -> "+toHexString(hdc)); + // Thread.dumpStack(); + } + return LOCK_SURFACE_CHANGED; + } + + @Override + protected void unlockSurfaceImpl() { + if (0 != hdc) { + GDI.ReleaseDC(getWindowHandle(), hdc); + hdc_old = hdc; + hdc=0; + } + } + + @Override + public final long getSurfaceHandle() { + return hdc; + } + + @Override + public boolean hasDeviceChanged() { + if(0!=getWindowHandle()) { + long _hmon = MonitorFromWindow0(getWindowHandle()); + if (hmon != _hmon) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("Info: Window Device Changed "+Thread.currentThread().getName()+ + ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon)); + // Thread.dumpStack(); + } + hmon = _hmon; + return true; + } + } + return false; + } + + protected void createNativeImpl() { + final ScreenDriver screen = (ScreenDriver) getScreen(); + final DisplayDriver display = (DisplayDriver) screen.getDisplay(); + final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + setGraphicsConfiguration(cfg); + final int flags = getReconfigureFlags(0, true) & + ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; + setWindowHandle(CreateWindow0(display.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), + getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + if (getWindowHandle() == 0) { + throw new NativeWindowException("Error creating window"); + } + windowHandleClose = getWindowHandle(); + addMouseListener(new MouseTracker()); + + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ + " (Parent HWND "+toHexString(getParentWindowHandle())+ + ") : HWND "+toHexString(getWindowHandle())+", "+Thread.currentThread()); + e.printStackTrace(); + } + } + + class MouseTracker extends MouseAdapter { + public void mouseEntered(MouseEvent e) { + WindowDriver.trackPointerLeave0(WindowDriver.this.getWindowHandle()); + } + } + + protected void closeNativeImpl() { + if(windowHandleClose != 0) { + if (hdc != 0) { + try { + GDI.ReleaseDC(windowHandleClose, hdc); + } catch (Throwable t) { + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); + e.printStackTrace(); + } + } + } + try { + GDI.SetParent(windowHandleClose, 0); // detach first, experience hang w/ SWT parent + GDI.DestroyWindow(windowHandleClose); + } catch (Throwable t) { + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); + e.printStackTrace(); + } + } finally { + windowHandleClose = 0; + } + } + hdc = 0; + hdc_old = 0; + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("WindowsWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ + getReconfigureFlagsAsString(null, flags)); + } + + if(0 == ( FLAG_IS_UNDECORATED & flags)) { + final InsetsImmutable i = getInsets(); + + // client position -> top-level window position + x -= i.getLeftWidth() ; + y -= i.getTopHeight() ; + + if(0 top-level window size + width += i.getTotalWidth(); + height += i.getTotalHeight(); + } + } + reconfigureWindow0( getParentWindowHandle(), getWindowHandle(), x, y, width, height, flags); + + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } + return true; + } + + protected void requestFocusImpl(boolean force) { + requestFocus0(getWindowHandle(), force); + } + + @Override + protected void setTitleImpl(final String title) { + setTitle0(getWindowHandle(), title); + } + + @Override + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { + final Boolean[] res = new Boolean[] { Boolean.FALSE }; + + this.runOnEDTIfAvail(true, new Runnable() { + public void run() { + res[0] = Boolean.valueOf(setPointerVisible0(getWindowHandle(), pointerVisible)); + } + }); + return res[0].booleanValue(); + } + + @Override + protected boolean confinePointerImpl(final boolean confine) { + final Boolean[] res = new Boolean[] { Boolean.FALSE }; + + this.runOnEDTIfAvail(true, new Runnable() { + public void run() { + final Point p0 = getLocationOnScreenImpl(0, 0); + res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, + p0.getX(), p0.getY(), p0.getX()+getWidth(), p0.getY()+getHeight())); + } + }); + return res[0].booleanValue(); + } + + @Override + protected void warpPointerImpl(final int x, final int y) { + this.runOnEDTIfAvail(true, new Runnable() { + public void run() { + final Point sPos = getLocationOnScreenImpl(x, y); + warpPointer0(getWindowHandle(), sPos.getX(), sPos.getY()); + } + }); + return; + } + + protected Point getLocationOnScreenImpl(int x, int y) { + return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop - using event driven insetsChange(..) + } + + private final int validateKeyCode(int eventType, int keyCode) { + switch(eventType) { + case KeyEvent.EVENT_KEY_PRESSED: + lastPressedKeyCode = keyCode; + break; + case KeyEvent.EVENT_KEY_TYPED: + if(-1==keyCode) { + keyCode = lastPressedKeyCode; + } + lastPressedKeyCode = -1; + break; + } + return keyCode; + } + private int lastPressedKeyCode = 0; + + @Override + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform + keyCode = validateKeyCode(eventType, keyCode); + super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + } + + @Override + public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform + keyCode = validateKeyCode(eventType, keyCode); + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); + } + + //---------------------------------------------------------------------- + // Internals only + // + protected static native boolean initIDs0(); + protected static native long getNewtWndProc0(); + + private native long CreateWindow0(long hInstance, String wndClassName, String wndName, + long parentWindowHandle, + int x, int y, int width, int height, boolean autoPosition, int flags); + private native long MonitorFromWindow0(long windowHandle); + private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, + int x, int y, int width, int height, int flags); + private static native void setTitle0(long windowHandle, String title); + private native void requestFocus0(long windowHandle, boolean force); + + private static native boolean setPointerVisible0(long windowHandle, boolean visible); + private static native boolean confinePointer0(long windowHandle, boolean grab, int l, int t, int r, int b); + private static native void warpPointer0(long windowHandle, int x, int y); + private static native void trackPointerLeave0(long windowHandle); +} diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java deleted file mode 100644 index 225b115e4..000000000 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsDisplay.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.windows; - -import jogamp.nativewindow.windows.RegisteredClass; -import jogamp.nativewindow.windows.RegisteredClassFactory; -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; - -import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; - -public class WindowsDisplay extends DisplayImpl { - - private static final String newtClassBaseName = "_newt_clazz" ; - private static RegisteredClassFactory sharedClassFactory; - - static { - NEWTJNILibLoader.loadNEWT(); - - if (!WindowsWindow.initIDs0()) { - throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); - } - sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowsWindow.getNewtWndProc0()); - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - private RegisteredClass sharedClass; - - public WindowsDisplay() { - } - - protected void createNativeImpl() { - sharedClass = sharedClassFactory.getSharedClass(); - aDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); - } - - protected void closeNativeImpl() { - sharedClassFactory.releaseSharedClass(); - } - - protected void dispatchMessagesNative() { - DispatchMessages0(); - } - - protected long getHInstance() { - return sharedClass.getHandle(); - } - - protected String getWindowClassName() { - return sharedClass.getName(); - } - - //---------------------------------------------------------------------- - // Internals only - // - private static native void DispatchMessages0(); -} - diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java deleted file mode 100644 index f8bce9da3..000000000 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsScreen.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ -package jogamp.newt.driver.windows; - -import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import jogamp.newt.ScreenImpl; - -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -public class WindowsScreen extends ScreenImpl { - - static { - WindowsDisplay.initSingleton(); - } - - public WindowsScreen() { - } - - protected void createNativeImpl() { - aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { - } - - private int[] getScreenModeIdx(int idx) { - int[] modeProps = getScreenMode0(screen_idx, idx); - if (null == modeProps || 0 == modeProps.length) { - return null; - } - if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { - throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); - } - return modeProps; - } - - private int nativeModeIdx; - - protected int[] getScreenModeFirstImpl() { - nativeModeIdx = 0; - return getScreenModeNextImpl(); - } - - protected int[] getScreenModeNextImpl() { - int[] modeProps = getScreenModeIdx(nativeModeIdx); - if (null != modeProps && 0 < modeProps.length) { - nativeModeIdx++; - return modeProps; - } - return null; - } - - protected ScreenMode getCurrentScreenModeImpl() { - int[] modeProps = getScreenModeIdx(-1); - if (null != modeProps && 0 < modeProps.length) { - return ScreenModeUtil.streamIn(modeProps, 0); - } - return null; - } - - protected boolean setCurrentScreenModeImpl(ScreenMode sm) { - return setScreenMode0(screen_idx, - sm.getMonitorMode().getSurfaceSize().getResolution().getWidth(), - sm.getMonitorMode().getSurfaceSize().getResolution().getHeight(), - sm.getMonitorMode().getSurfaceSize().getBitsPerPixel(), - sm.getMonitorMode().getRefreshRate(), - sm.getRotation()); - } - - protected int validateScreenIndex(int idx) { - return 0; // big-desktop, only one screen available - } - - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(getOriginX0(screen_idx)); - virtualOrigin.setY(getOriginY0(screen_idx)); - virtualSize.setWidth(getWidthImpl0(screen_idx)); - virtualSize.setHeight(getHeightImpl0(screen_idx)); - } - - // Native calls - private native int getOriginX0(int screen_idx); - private native int getOriginY0(int screen_idx); - private native int getWidthImpl0(int scrn_idx); - private native int getHeightImpl0(int scrn_idx); - - private native int[] getScreenMode0(int screen_index, int mode_index); - private native boolean setScreenMode0(int screen_index, int width, int height, int bits, int freq, int rot); -} diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java b/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java deleted file mode 100644 index 6a8c81f3d..000000000 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowsWindow.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.windows; - -import jogamp.nativewindow.windows.GDI; -import jogamp.nativewindow.windows.GDIUtil; -import jogamp.newt.WindowImpl; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.GraphicsConfigurationFactory; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.VisualIDHolder; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.InsetsImmutable; -import javax.media.nativewindow.util.Point; - -import com.jogamp.newt.event.KeyEvent; -import com.jogamp.newt.event.MouseAdapter; -import com.jogamp.newt.event.MouseEvent; - -public class WindowsWindow extends WindowImpl { - - private long hmon; - private long hdc; - private long hdc_old; - private long windowHandleClose; - - static { - WindowsDisplay.initSingleton(); - } - - public WindowsWindow() { - } - - @Override - protected int lockSurfaceImpl() { - if (0 != hdc) { - throw new InternalError("surface not released"); - } - hdc = GDI.GetDC(getWindowHandle()); - hmon = MonitorFromWindow0(getWindowHandle()); - - // return ( 0 == hdc ) ? LOCK_SURFACE_NOT_READY : ( hdc_old != hdc ) ? LOCK_SURFACE_CHANGED : LOCK_SUCCESS ; - if( 0 == hdc ) { - return LOCK_SURFACE_NOT_READY; - } - if( hdc_old == hdc ) { - return LOCK_SUCCESS; - } - if(DEBUG_IMPLEMENTATION) { - System.err.println("WindowsWindow: surface change "+toHexString(hdc_old)+" -> "+toHexString(hdc)); - // Thread.dumpStack(); - } - return LOCK_SURFACE_CHANGED; - } - - @Override - protected void unlockSurfaceImpl() { - if (0 != hdc) { - GDI.ReleaseDC(getWindowHandle(), hdc); - hdc_old = hdc; - hdc=0; - } - } - - @Override - public final long getSurfaceHandle() { - return hdc; - } - - @Override - public boolean hasDeviceChanged() { - if(0!=getWindowHandle()) { - long _hmon = MonitorFromWindow0(getWindowHandle()); - if (hmon != _hmon) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("Info: Window Device Changed "+Thread.currentThread().getName()+ - ", HMON "+toHexString(hmon)+" -> "+toHexString(_hmon)); - // Thread.dumpStack(); - } - hmon = _hmon; - return true; - } - } - return false; - } - - protected void createNativeImpl() { - final WindowsScreen screen = (WindowsScreen) getScreen(); - final WindowsDisplay display = (WindowsDisplay) screen.getDisplay(); - final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - setGraphicsConfiguration(cfg); - final int flags = getReconfigureFlags(0, true) & - ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; - setWindowHandle(CreateWindow0(display.getHInstance(), display.getWindowClassName(), display.getWindowClassName(), - getParentWindowHandle(), getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); - if (getWindowHandle() == 0) { - throw new NativeWindowException("Error creating window"); - } - windowHandleClose = getWindowHandle(); - addMouseListener(new MouseTracker()); - - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Info: Window new window handle "+Thread.currentThread().getName()+ - " (Parent HWND "+toHexString(getParentWindowHandle())+ - ") : HWND "+toHexString(getWindowHandle())+", "+Thread.currentThread()); - e.printStackTrace(); - } - } - - class MouseTracker extends MouseAdapter { - public void mouseEntered(MouseEvent e) { - WindowsWindow.trackPointerLeave0(WindowsWindow.this.getWindowHandle()); - } - } - - protected void closeNativeImpl() { - if(windowHandleClose != 0) { - if (hdc != 0) { - try { - GDI.ReleaseDC(windowHandleClose, hdc); - } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); - e.printStackTrace(); - } - } - } - try { - GDI.SetParent(windowHandleClose, 0); // detach first, experience hang w/ SWT parent - GDI.DestroyWindow(windowHandleClose); - } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); - e.printStackTrace(); - } - } finally { - windowHandleClose = 0; - } - } - hdc = 0; - hdc_old = 0; - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("WindowsWindow reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ - getReconfigureFlagsAsString(null, flags)); - } - - if(0 == ( FLAG_IS_UNDECORATED & flags)) { - final InsetsImmutable i = getInsets(); - - // client position -> top-level window position - x -= i.getLeftWidth() ; - y -= i.getTopHeight() ; - - if(0 top-level window size - width += i.getTotalWidth(); - height += i.getTotalHeight(); - } - } - reconfigureWindow0( getParentWindowHandle(), getWindowHandle(), x, y, width, height, flags); - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - return true; - } - - protected void requestFocusImpl(boolean force) { - requestFocus0(getWindowHandle(), force); - } - - @Override - protected void setTitleImpl(final String title) { - setTitle0(getWindowHandle(), title); - } - - @Override - protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - final Boolean[] res = new Boolean[] { Boolean.FALSE }; - - this.runOnEDTIfAvail(true, new Runnable() { - public void run() { - res[0] = Boolean.valueOf(setPointerVisible0(getWindowHandle(), pointerVisible)); - } - }); - return res[0].booleanValue(); - } - - @Override - protected boolean confinePointerImpl(final boolean confine) { - final Boolean[] res = new Boolean[] { Boolean.FALSE }; - - this.runOnEDTIfAvail(true, new Runnable() { - public void run() { - final Point p0 = getLocationOnScreenImpl(0, 0); - res[0] = Boolean.valueOf(confinePointer0(getWindowHandle(), confine, - p0.getX(), p0.getY(), p0.getX()+getWidth(), p0.getY()+getHeight())); - } - }); - return res[0].booleanValue(); - } - - @Override - protected void warpPointerImpl(final int x, final int y) { - this.runOnEDTIfAvail(true, new Runnable() { - public void run() { - final Point sPos = getLocationOnScreenImpl(x, y); - warpPointer0(getWindowHandle(), sPos.getX(), sPos.getY()); - } - }); - return; - } - - protected Point getLocationOnScreenImpl(int x, int y) { - return GDIUtil.GetRelativeLocation( getWindowHandle(), 0 /*root win*/, x, y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop - using event driven insetsChange(..) - } - - private final int validateKeyCode(int eventType, int keyCode) { - switch(eventType) { - case KeyEvent.EVENT_KEY_PRESSED: - lastPressedKeyCode = keyCode; - break; - case KeyEvent.EVENT_KEY_TYPED: - if(-1==keyCode) { - keyCode = lastPressedKeyCode; - } - lastPressedKeyCode = -1; - break; - } - return keyCode; - } - private int lastPressedKeyCode = 0; - - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, keyCode); - super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); - } - - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, keyCode); - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); - } - - //---------------------------------------------------------------------- - // Internals only - // - protected static native boolean initIDs0(); - protected static native long getNewtWndProc0(); - - private native long CreateWindow0(long hInstance, String wndClassName, String wndName, - long parentWindowHandle, - int x, int y, int width, int height, boolean autoPosition, int flags); - private native long MonitorFromWindow0(long windowHandle); - private native void reconfigureWindow0(long parentWindowHandle, long windowHandle, - int x, int y, int width, int height, int flags); - private static native void setTitle0(long windowHandle, String title); - private native void requestFocus0(long windowHandle, boolean force); - - private static native boolean setPointerVisible0(long windowHandle, boolean visible); - private static native boolean confinePointer0(long windowHandle, boolean grab, int l, int t, int r, int b); - private static native void warpPointer0(long windowHandle, int x, int y); - private static native void trackPointerLeave0(long windowHandle); -} diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java new file mode 100644 index 000000000..714324d63 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.x11; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; + +import com.jogamp.nativewindow.x11.X11GraphicsDevice; + +import jogamp.nativewindow.x11.X11Util; +import jogamp.newt.DisplayImpl; +import jogamp.newt.NEWTJNILibLoader; + +public class DisplayDriver extends DisplayImpl { + + static { + NEWTJNILibLoader.loadNEWT(); + + if ( !initIDs0(X11Util.XERROR_STACKDUMP) ) { + throw new NativeWindowException("Failed to initialize X11Display jmethodIDs"); + } + + if (!WindowDriver.initIDs0()) { + throw new NativeWindowException("Failed to initialize X11Window jmethodIDs"); + } + } + + public static void initSingleton() { + // just exist to ensure static init has been run + } + + + public DisplayDriver() { + } + + public String validateDisplayName(String name, long handle) { + return X11Util.validateDisplayName(name, handle); + } + + /** + * {@inheritDoc} + * + * We use a private non-shared X11 Display instance for EDT window operations and one for exposed animation, eg. OpenGL. + *

    + * In case {@link X11Util#HAS_XLOCKDISPLAY_BUG} and {@link X11Util#XINITTHREADS_ALWAYS_ENABLED}, + * we use null locking. Even though this seems not to be rational, it gives most stable results on all platforms. + *

    + *

    + * Otherwise we use basic locking via the constructor {@link X11GraphicsDevice#X11GraphicsDevice(long, int, boolean)}, + * since it is possible to share this device via {@link com.jogamp.newt.NewtFactory#createDisplay(String, boolean)}. + *

    + */ + @SuppressWarnings("unused") + protected void createNativeImpl() { + long handle = X11Util.openDisplay(name); + if( 0 == handle ) { + throw new RuntimeException("Error creating display(Win): "+name); + } + if(USE_SEPARATE_DISPLAY_FOR_EDT) { + edtDisplayHandle = X11Util.openDisplay(name); + if( 0 == edtDisplayHandle ) { + X11Util.closeDisplay(handle); + throw new RuntimeException("Error creating display(EDT): "+name); + } + } else { + edtDisplayHandle = handle; + } + try { + CompleteDisplay0(edtDisplayHandle); + } catch(RuntimeException e) { + closeNativeImpl(); + throw e; + } + + // see API doc above! + if(X11Util.XINITTHREADS_ALWAYS_ENABLED && X11Util.HAS_XLOCKDISPLAY_BUG) { + aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), false); + } else { + aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, false); + } + } + + protected void closeNativeImpl() { + DisplayRelease0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); + javaObjectAtom = 0; + windowDeleteAtom = 0; + // closing using ATI driver bug 'same order' + final long handle = getHandle(); + X11Util.closeDisplay(handle); + if(handle != edtDisplayHandle) { + X11Util.closeDisplay(edtDisplayHandle); + } + edtDisplayHandle = 0; + } + + protected void dispatchMessagesNative() { + if(0 != edtDisplayHandle) { + DispatchMessages0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); + } + } + + protected long getEDTHandle() { return edtDisplayHandle; } + protected long getJavaObjectAtom() { return javaObjectAtom; } + protected long getWindowDeleteAtom() { return windowDeleteAtom; } + + //---------------------------------------------------------------------- + // Internals only + // + private static native boolean initIDs0(boolean debug); + + private native void CompleteDisplay0(long handle); + + private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) { + this.javaObjectAtom=javaObjectAtom; + this.windowDeleteAtom=windowDeleteAtom; + } + private native void DisplayRelease0(long handle, long javaObjectAtom, long windowDeleteAtom); + + private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom); + + /** + * 2011/06/14 libX11 1.4.2 and libxcb 1.7 bug 20708 - Multithreading Issues w/ OpenGL, .. + * https://bugs.freedesktop.org/show_bug.cgi?id=20708 + * https://jogamp.org/bugzilla/show_bug.cgi?id=502 + * Affects: Ubuntu 11.04, OpenSuSE 11, .. + * Workaround: Using a separate X11 Display connection for event dispatching (EDT) + */ + private final boolean USE_SEPARATE_DISPLAY_FOR_EDT = true; + + private long edtDisplayHandle; + + /** X11 Window delete atom marker used on EDT */ + private long windowDeleteAtom; + + /** X11 Window java object property used on EDT */ + private long javaObjectAtom; +} + diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java new file mode 100644 index 000000000..10f6b84da --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -0,0 +1,357 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ +package jogamp.newt.driver.x11; + +import java.util.List; + +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; + +import jogamp.nativewindow.x11.X11Util; +import jogamp.newt.DisplayImpl; +import jogamp.newt.DisplayImpl.DisplayRunnable; +import jogamp.newt.ScreenImpl; + +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class ScreenDriver extends ScreenImpl { + + static { + DisplayDriver.initSingleton(); + } + + public ScreenDriver() { + } + + protected void createNativeImpl() { + // validate screen index + Long handle = display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Long run(long dpy) { + return new Long(GetScreen0(dpy, screen_idx)); + } } ); + if (handle.longValue() == 0) { + throw new RuntimeException("Error creating screen: " + screen_idx); + } + aScreen = new X11GraphicsScreen((X11GraphicsDevice) getDisplay().getGraphicsDevice(), screen_idx); + } + + protected void closeNativeImpl() { + } + + private int[] nrotations; + private int nrotation_index; + private int nres_number; + private int nres_index; + private int[] nrates; + private int nrate_index; + private int nmode_number; + + protected int[] getScreenModeFirstImpl() { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public int[] run(long dpy) { + // initialize iterators and static data + nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); + if(null==nrotations || 0==nrotations.length) { + return null; + } + nrotation_index = 0; + + nres_number = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==nres_number) { + return null; + } + nres_index = 0; + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + + nmode_number = 0; + + return getScreenModeNextImpl(); + } } ); + } + + protected int[] getScreenModeNextImpl() { + // assemble: w x h x bpp x f x r + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public int[] run(long dpy) { + /** + System.err.println("******** mode: "+nmode_number); + System.err.println("rot "+nrotation_index); + System.err.println("rate "+nrate_index); + System.err.println("res "+nres_index); */ + + int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); + } + int rate = nrates[nrate_index]; + if(0>=rate) { + rate = default_sm_rate; + if(DEBUG) { + System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+default_sm_rate); + } + } + int rotation = nrotations[nrotation_index]; + + int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rotation; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element + + nmode_number++; + + // iteration: r -> f -> bpp -> [w x h] + nrotation_index++; + if(nrotation_index == nrotations.length) { + nrotation_index=0; + nrate_index++; + if(null == nrates || nrate_index == nrates.length){ + nres_index++; + if(nres_index == nres_number) { + // done + nrates=null; + nrotations=null; + return null; + } + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + } + } + + return props; + } } ); + } + + protected ScreenMode getCurrentScreenModeImpl() { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public ScreenMode run(long dpy) { + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return null; + } + int[] res; + int rate, rot; + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==resNumber) { + return null; + } + + int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); + if(0>resIdx) { + return null; + } + if(resIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); + } + res = getScreenModeResolution0(dpy, screen_idx, resIdx); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); + } + rate = getCurrentScreenRate0(screenConfigHandle); + if(0>rate) { + return null; + } + rot = getCurrentScreenRotation0(screenConfigHandle); + if(0>rot) { + return null; + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int i = 0; + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rot; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count + return ScreenModeUtil.streamIn(props, 0); + } } ); + } + + protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { + final List screenModes = this.getScreenModesOrig(); + final int screenModeIdx = screenModes.indexOf(screenMode); + if(0>screenModeIdx) { + throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); + } + final long t0 = System.currentTimeMillis(); + boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Boolean run(long dpy) { + boolean done = false; + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return Boolean.valueOf(done); + } + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); + if(0>resIdx || resIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); + } + + final int f = screenMode.getMonitorMode().getRefreshRate(); + final int r = screenMode.getRotation(); + + if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resIdx, f, r) ) { + while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) { + done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r); + if(!done) { + try { Thread.sleep(10); } catch (InterruptedException e) { } + } + } + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + return Boolean.valueOf(done); + } + }).booleanValue(); + + if(DEBUG || !done) { + System.err.println("X11Screen.setCurrentScreenModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ + (System.currentTimeMillis()-t0)+"ms; Current: "+getCurrentScreenMode()+"; Desired: "+screenMode); + } + return done; + } + + private class XineramaEnabledQuery implements DisplayImpl.DisplayRunnable { + public Boolean run(long dpy) { + return new Boolean(X11Util.XineramaIsEnabled(dpy)); + } + } + private XineramaEnabledQuery xineramaEnabledQuery = new XineramaEnabledQuery(); + + protected int validateScreenIndex(final int idx) { + if(getDisplay().isNativeValid()) { + return runWithLockedDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; + } else { + return runWithTempDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; + } + } + + protected void getVirtualScreenOriginAndSize(final Point virtualOrigin, final Dimension virtualSize) { + display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + virtualOrigin.setX(0); + virtualOrigin.setY(0); + virtualSize.setWidth(getWidth0(dpy, screen_idx)); + virtualSize.setHeight(getHeight0(dpy, screen_idx)); + return null; + } } ); + } + + //---------------------------------------------------------------------- + // Internals only + // + private final T runWithLockedDisplayHandle(DisplayRunnable action) { + return display.runWithLockedDisplayHandle(action); + // return runWithTempDisplayHandle(action); + // return runWithoutLock(action); + } + + private final T runWithTempDisplayHandle(DisplayRunnable action) { + final long displayHandle = X11Util.openDisplay(display.getName()); + if(0 == displayHandle) { + throw new RuntimeException("null device"); + } + T res; + try { + res = action.run(displayHandle); + } finally { + X11Util.closeDisplay(displayHandle); + } + return res; + } + private final T runWithoutLock(DisplayRunnable action) { + return action.run(display.getHandle()); + } + + private static native long GetScreen0(long dpy, int scrn_idx); + + private static native int getWidth0(long display, int scrn_idx); + + private static native int getHeight0(long display, int scrn_idx); + + /** @return int[] { rot1, .. } */ + private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); + + private static native int getNumScreenModeResolutions0(long display, int screen_index); + + /** @return int[] { width, height, widthmm, heightmm } */ + private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); + + private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); + + private static native long getScreenConfiguration0(long display, int screen_index); + private static native void freeScreenConfiguration0(long screenConfiguration); + + private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); + private static native int getCurrentScreenRate0(long screenConfiguration); + private static native int getCurrentScreenRotation0(long screenConfiguration); + + /** needs own Display connection for XRANDR event handling */ + private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); + private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java new file mode 100644 index 000000000..97d1ae3db --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + */ + +package jogamp.newt.driver.x11; + +import jogamp.nativewindow.x11.X11Lib; +import jogamp.newt.DisplayImpl; +import jogamp.newt.DisplayImpl.DisplayRunnable; +import jogamp.newt.WindowImpl; +import javax.media.nativewindow.*; +import javax.media.nativewindow.VisualIDHolder.VIDType; +import javax.media.nativewindow.util.Insets; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.Point; + +import com.jogamp.newt.event.MouseEvent; + +public class WindowDriver extends WindowImpl { + private static final String WINDOW_CLASS_NAME = "NewtWindow"; + private static final int X11_WHEEL_ONE_UP_BUTTON = 4; + private static final int X11_WHEEL_ONE_DOWN_BUTTON = 5; + private static final int X11_WHEEL_TWO_UP_BUTTON = 6; + private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; + + static { + DisplayDriver.initSingleton(); + } + + public WindowDriver() { + } + + protected void createNativeImpl() { + final ScreenDriver screen = (ScreenDriver) getScreen(); + final DisplayDriver display = (DisplayDriver) screen.getDisplay(); + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); + final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( + capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg); + } + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + final int visualID = cfg.getVisualID(VIDType.NATIVE); + if(VisualIDHolder.VID_UNDEFINED == visualID) { + throw new NativeWindowException("Chosen Configuration w/o native visual ID: "+cfg); + } + setGraphicsConfiguration(cfg); + final int flags = getReconfigureFlags(0, true) & + ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; + setWindowHandle(CreateWindow0(getParentWindowHandle(), + display.getEDTHandle(), screen.getIndex(), visualID, + display.getJavaObjectAtom(), display.getWindowDeleteAtom(), + getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + windowHandleClose = getWindowHandle(); + if (0 == windowHandleClose) { + throw new NativeWindowException("Error creating window"); + } + } + + protected void closeNativeImpl() { + if(0!=windowHandleClose && null!=getScreen() ) { + DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + try { + CloseWindow0(display.getEDTHandle(), windowHandleClose, + display.getJavaObjectAtom(), display.getWindowDeleteAtom()); + } catch (Throwable t) { + if(DEBUG_IMPLEMENTATION) { + Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); + e.printStackTrace(); + } + } finally { + windowHandleClose = 0; + } + } + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ + getReconfigureFlagsAsString(null, flags)); + } + if(0 == ( FLAG_IS_UNDECORATED & flags)) { + final InsetsImmutable i = getInsets(); + + // client position -> top-level window position + x -= i.getLeftWidth() ; + y -= i.getTopHeight() ; + } + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + reconfigureWindow0( getDisplayEDTHandle(), getScreenIndex(), + getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), + x, y, width, height, flags); + + return true; + } + + protected void reparentNotify(long newParentWindowHandle) { + if(DEBUG_IMPLEMENTATION) { + final long p0 = getParentWindowHandle(); + System.err.println("Window.reparentNotify ("+getThreadName()+"): "+toHexString(p0)+" -> "+toHexString(newParentWindowHandle)); + } + } + + protected void requestFocusImpl(boolean force) { + requestFocus0(getDisplayEDTHandle(), getWindowHandle(), force); + } + + @Override + protected void setTitleImpl(final String title) { + runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + setTitle0(dpy, getWindowHandle(), title); + return null; + } + }); + } + + @Override + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Boolean run(long dpy) { + return Boolean.valueOf(setPointerVisible0(getDisplayEDTHandle(), getWindowHandle(), pointerVisible)); + } + }).booleanValue(); + } + + @Override + protected boolean confinePointerImpl(final boolean confine) { + return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Boolean run(long dpy) { + return Boolean.valueOf(confinePointer0(getDisplayEDTHandle(), getWindowHandle(), confine)); + } + }).booleanValue(); + } + + @Override + protected void warpPointerImpl(final int x, final int y) { + runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + warpPointer0(getDisplayEDTHandle(), getWindowHandle(), x, y); + return null; + } + }); + } + + protected Point getLocationOnScreenImpl(final int x, final int y) { + // X11Util.GetRelativeLocation: locks display already ! + return X11Lib.GetRelativeLocation( getScreen().getDisplay().getHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); + } + + protected void updateInsetsImpl(Insets insets) { + // nop - using event driven insetsChange(..) + } + + protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, + int x, int y, int button, int rotation) { + switch(eventType) { + case MouseEvent.EVENT_MOUSE_PRESSED: + switch(button) { + case X11_WHEEL_ONE_UP_BUTTON: + case X11_WHEEL_ONE_DOWN_BUTTON: + case X11_WHEEL_TWO_UP_BUTTON: + case X11_WHEEL_TWO_DOWN_BUTTON: + // ignore wheel pressed ! + return; + } + break; + case MouseEvent.EVENT_MOUSE_RELEASED: + switch(button) { + case X11_WHEEL_ONE_UP_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 1; + rotation = 1; + break; + case X11_WHEEL_ONE_DOWN_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 1; + rotation = -1; + break; + case X11_WHEEL_TWO_UP_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 2; + rotation = 1; + break; + case X11_WHEEL_TWO_DOWN_BUTTON: + eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + button = 2; + rotation = -1; + break; + } + break; + } + super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation); + } + + + //---------------------------------------------------------------------- + // Internals only + // + + private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI + private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI + + private final long getDisplayEDTHandle() { + return ((DisplayDriver) getScreen().getDisplay()).getEDTHandle(); + } + private final T runWithLockedDisplayHandle(DisplayRunnable action) { + return ((DisplayImpl) getScreen().getDisplay()).runWithLockedDisplayHandle(action); + // return runWithTempDisplayHandle(action); + } + + protected static native boolean initIDs0(); + + private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, + int visualID, long javaObjectAtom, long windowDeleteAtom, + int x, int y, int width, int height, boolean autoPosition, int flags); + private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom); + private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, + long windowDeleteAtom, int x, int y, int width, int height, int flags); + private native void requestFocus0(long display, long windowHandle, boolean force); + + private static native void setTitle0(long display, long windowHandle, String title); + private static native long getParentWindow0(long display, long windowHandle); + private static native boolean setPointerVisible0(long display, long windowHandle, boolean visible); + private static native boolean confinePointer0(long display, long windowHandle, boolean grab); + private static native void warpPointer0(long display, long windowHandle, int x, int y); + + private long windowHandleClose; +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java b/src/newt/classes/jogamp/newt/driver/x11/X11Display.java deleted file mode 100644 index 8243fcf9d..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Display.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.x11; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; - -import com.jogamp.nativewindow.x11.X11GraphicsDevice; - -import jogamp.nativewindow.x11.X11Util; -import jogamp.newt.DisplayImpl; -import jogamp.newt.NEWTJNILibLoader; - -public class X11Display extends DisplayImpl { - - static { - NEWTJNILibLoader.loadNEWT(); - - if ( !initIDs0(X11Util.XERROR_STACKDUMP) ) { - throw new NativeWindowException("Failed to initialize X11Display jmethodIDs"); - } - - if (!X11Window.initIDs0()) { - throw new NativeWindowException("Failed to initialize X11Window jmethodIDs"); - } - } - - public static void initSingleton() { - // just exist to ensure static init has been run - } - - - public X11Display() { - } - - public String validateDisplayName(String name, long handle) { - return X11Util.validateDisplayName(name, handle); - } - - /** - * {@inheritDoc} - * - * We use a private non-shared X11 Display instance for EDT window operations and one for exposed animation, eg. OpenGL. - *

    - * In case {@link X11Util#HAS_XLOCKDISPLAY_BUG} and {@link X11Util#XINITTHREADS_ALWAYS_ENABLED}, - * we use null locking. Even though this seems not to be rational, it gives most stable results on all platforms. - *

    - *

    - * Otherwise we use basic locking via the constructor {@link X11GraphicsDevice#X11GraphicsDevice(long, int, boolean)}, - * since it is possible to share this device via {@link com.jogamp.newt.NewtFactory#createDisplay(String, boolean)}. - *

    - */ - @SuppressWarnings("unused") - protected void createNativeImpl() { - long handle = X11Util.openDisplay(name); - if( 0 == handle ) { - throw new RuntimeException("Error creating display(Win): "+name); - } - if(USE_SEPARATE_DISPLAY_FOR_EDT) { - edtDisplayHandle = X11Util.openDisplay(name); - if( 0 == edtDisplayHandle ) { - X11Util.closeDisplay(handle); - throw new RuntimeException("Error creating display(EDT): "+name); - } - } else { - edtDisplayHandle = handle; - } - try { - CompleteDisplay0(edtDisplayHandle); - } catch(RuntimeException e) { - closeNativeImpl(); - throw e; - } - - // see API doc above! - if(X11Util.XINITTHREADS_ALWAYS_ENABLED && X11Util.HAS_XLOCKDISPLAY_BUG) { - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), false); - } else { - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, false); - } - } - - protected void closeNativeImpl() { - DisplayRelease0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); - javaObjectAtom = 0; - windowDeleteAtom = 0; - // closing using ATI driver bug 'same order' - final long handle = getHandle(); - X11Util.closeDisplay(handle); - if(handle != edtDisplayHandle) { - X11Util.closeDisplay(edtDisplayHandle); - } - edtDisplayHandle = 0; - } - - protected void dispatchMessagesNative() { - if(0 != edtDisplayHandle) { - DispatchMessages0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); - } - } - - protected long getEDTHandle() { return edtDisplayHandle; } - protected long getJavaObjectAtom() { return javaObjectAtom; } - protected long getWindowDeleteAtom() { return windowDeleteAtom; } - - //---------------------------------------------------------------------- - // Internals only - // - private static native boolean initIDs0(boolean debug); - - private native void CompleteDisplay0(long handle); - - private void displayCompleted(long javaObjectAtom, long windowDeleteAtom) { - this.javaObjectAtom=javaObjectAtom; - this.windowDeleteAtom=windowDeleteAtom; - } - private native void DisplayRelease0(long handle, long javaObjectAtom, long windowDeleteAtom); - - private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom); - - /** - * 2011/06/14 libX11 1.4.2 and libxcb 1.7 bug 20708 - Multithreading Issues w/ OpenGL, .. - * https://bugs.freedesktop.org/show_bug.cgi?id=20708 - * https://jogamp.org/bugzilla/show_bug.cgi?id=502 - * Affects: Ubuntu 11.04, OpenSuSE 11, .. - * Workaround: Using a separate X11 Display connection for event dispatching (EDT) - */ - private final boolean USE_SEPARATE_DISPLAY_FOR_EDT = true; - - private long edtDisplayHandle; - - /** X11 Window delete atom marker used on EDT */ - private long windowDeleteAtom; - - /** X11 Window java object property used on EDT */ - private long javaObjectAtom; -} - diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java deleted file mode 100644 index 93db854ac..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ -package jogamp.newt.driver.x11; - -import java.util.List; - -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; - -import jogamp.nativewindow.x11.X11Util; -import jogamp.newt.DisplayImpl; -import jogamp.newt.DisplayImpl.DisplayRunnable; -import jogamp.newt.ScreenImpl; - -import com.jogamp.nativewindow.x11.X11GraphicsDevice; -import com.jogamp.nativewindow.x11.X11GraphicsScreen; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -public class X11Screen extends ScreenImpl { - - static { - X11Display.initSingleton(); - } - - public X11Screen() { - } - - protected void createNativeImpl() { - // validate screen index - Long handle = display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Long run(long dpy) { - return new Long(GetScreen0(dpy, screen_idx)); - } } ); - if (handle.longValue() == 0) { - throw new RuntimeException("Error creating screen: " + screen_idx); - } - aScreen = new X11GraphicsScreen((X11GraphicsDevice) getDisplay().getGraphicsDevice(), screen_idx); - } - - protected void closeNativeImpl() { - } - - private int[] nrotations; - private int nrotation_index; - private int nres_number; - private int nres_index; - private int[] nrates; - private int nrate_index; - private int nmode_number; - - protected int[] getScreenModeFirstImpl() { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public int[] run(long dpy) { - // initialize iterators and static data - nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); - if(null==nrotations || 0==nrotations.length) { - return null; - } - nrotation_index = 0; - - nres_number = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==nres_number) { - return null; - } - nres_index = 0; - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - - nmode_number = 0; - - return getScreenModeNextImpl(); - } } ); - } - - protected int[] getScreenModeNextImpl() { - // assemble: w x h x bpp x f x r - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public int[] run(long dpy) { - /** - System.err.println("******** mode: "+nmode_number); - System.err.println("rot "+nrotation_index); - System.err.println("rate "+nrate_index); - System.err.println("res "+nres_index); */ - - int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); - } - int rate = nrates[nrate_index]; - if(0>=rate) { - rate = default_sm_rate; - if(DEBUG) { - System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+default_sm_rate); - } - } - int rotation = nrotations[nrotation_index]; - - int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; - int i = 0; - props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element - - nmode_number++; - - // iteration: r -> f -> bpp -> [w x h] - nrotation_index++; - if(nrotation_index == nrotations.length) { - nrotation_index=0; - nrate_index++; - if(null == nrates || nrate_index == nrates.length){ - nres_index++; - if(nres_index == nres_number) { - // done - nrates=null; - nrotations=null; - return null; - } - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - } - } - - return props; - } } ); - } - - protected ScreenMode getCurrentScreenModeImpl() { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public ScreenMode run(long dpy) { - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return null; - } - int[] res; - int rate, rot; - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==resNumber) { - return null; - } - - int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); - if(0>resIdx) { - return null; - } - if(resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); - } - res = getScreenModeResolution0(dpy, screen_idx, resIdx); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); - } - rate = getCurrentScreenRate0(screenConfigHandle); - if(0>rate) { - return null; - } - rot = getCurrentScreenRotation0(screenConfigHandle); - if(0>rot) { - return null; - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int i = 0; - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rot; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - return ScreenModeUtil.streamIn(props, 0); - } } ); - } - - protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { - final List screenModes = this.getScreenModesOrig(); - final int screenModeIdx = screenModes.indexOf(screenMode); - if(0>screenModeIdx) { - throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); - } - final long t0 = System.currentTimeMillis(); - boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Boolean run(long dpy) { - boolean done = false; - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return Boolean.valueOf(done); - } - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - if(0>resIdx || resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); - } - - final int f = screenMode.getMonitorMode().getRefreshRate(); - final int r = screenMode.getRotation(); - - if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resIdx, f, r) ) { - while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) { - done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r); - if(!done) { - try { Thread.sleep(10); } catch (InterruptedException e) { } - } - } - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - return Boolean.valueOf(done); - } - }).booleanValue(); - - if(DEBUG || !done) { - System.err.println("X11Screen.setCurrentScreenModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ - (System.currentTimeMillis()-t0)+"ms; Current: "+getCurrentScreenMode()+"; Desired: "+screenMode); - } - return done; - } - - private class XineramaEnabledQuery implements DisplayImpl.DisplayRunnable { - public Boolean run(long dpy) { - return new Boolean(X11Util.XineramaIsEnabled(dpy)); - } - } - private XineramaEnabledQuery xineramaEnabledQuery = new XineramaEnabledQuery(); - - protected int validateScreenIndex(final int idx) { - if(getDisplay().isNativeValid()) { - return runWithLockedDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; - } else { - return runWithTempDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; - } - } - - protected void getVirtualScreenOriginAndSize(final Point virtualOrigin, final Dimension virtualSize) { - display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(getWidth0(dpy, screen_idx)); - virtualSize.setHeight(getHeight0(dpy, screen_idx)); - return null; - } } ); - } - - //---------------------------------------------------------------------- - // Internals only - // - private final T runWithLockedDisplayHandle(DisplayRunnable action) { - return display.runWithLockedDisplayHandle(action); - // return runWithTempDisplayHandle(action); - // return runWithoutLock(action); - } - - private final T runWithTempDisplayHandle(DisplayRunnable action) { - final long displayHandle = X11Util.openDisplay(display.getName()); - if(0 == displayHandle) { - throw new RuntimeException("null device"); - } - T res; - try { - res = action.run(displayHandle); - } finally { - X11Util.closeDisplay(displayHandle); - } - return res; - } - private final T runWithoutLock(DisplayRunnable action) { - return action.run(display.getHandle()); - } - - private static native long GetScreen0(long dpy, int scrn_idx); - - private static native int getWidth0(long display, int scrn_idx); - - private static native int getHeight0(long display, int scrn_idx); - - /** @return int[] { rot1, .. } */ - private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); - - private static native int getNumScreenModeResolutions0(long display, int screen_index); - - /** @return int[] { width, height, widthmm, heightmm } */ - private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); - - private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); - - private static native long getScreenConfiguration0(long display, int screen_index); - private static native void freeScreenConfiguration0(long screenConfiguration); - - private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); - private static native int getCurrentScreenRate0(long screenConfiguration); - private static native int getCurrentScreenRotation0(long screenConfiguration); - - /** needs own Display connection for XRANDR event handling */ - private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); - private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); -} diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java b/src/newt/classes/jogamp/newt/driver/x11/X11Window.java deleted file mode 100644 index 5501f5a3c..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/X11Window.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - */ - -package jogamp.newt.driver.x11; - -import jogamp.nativewindow.x11.X11Lib; -import jogamp.newt.DisplayImpl; -import jogamp.newt.DisplayImpl.DisplayRunnable; -import jogamp.newt.WindowImpl; -import javax.media.nativewindow.*; -import javax.media.nativewindow.VisualIDHolder.VIDType; -import javax.media.nativewindow.util.Insets; -import javax.media.nativewindow.util.InsetsImmutable; -import javax.media.nativewindow.util.Point; - -import com.jogamp.newt.event.MouseEvent; - -public class X11Window extends WindowImpl { - private static final String WINDOW_CLASS_NAME = "NewtWindow"; - private static final int X11_WHEEL_ONE_UP_BUTTON = 4; - private static final int X11_WHEEL_ONE_DOWN_BUTTON = 5; - private static final int X11_WHEEL_TWO_UP_BUTTON = 6; - private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; - - static { - X11Display.initSingleton(); - } - - public X11Window() { - } - - protected void createNativeImpl() { - final X11Screen screen = (X11Screen) getScreen(); - final X11Display display = (X11Display) screen.getDisplay(); - final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); - final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); - if(DEBUG_IMPLEMENTATION) { - System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg); - } - if (null == cfg) { - throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); - } - final int visualID = cfg.getVisualID(VIDType.NATIVE); - if(VisualIDHolder.VID_UNDEFINED == visualID) { - throw new NativeWindowException("Chosen Configuration w/o native visual ID: "+cfg); - } - setGraphicsConfiguration(cfg); - final int flags = getReconfigureFlags(0, true) & - ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; - setWindowHandle(CreateWindow0(getParentWindowHandle(), - display.getEDTHandle(), screen.getIndex(), visualID, - display.getJavaObjectAtom(), display.getWindowDeleteAtom(), - getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); - windowHandleClose = getWindowHandle(); - if (0 == windowHandleClose) { - throw new NativeWindowException("Error creating window"); - } - } - - protected void closeNativeImpl() { - if(0!=windowHandleClose && null!=getScreen() ) { - X11Display display = (X11Display) getScreen().getDisplay(); - try { - CloseWindow0(display.getEDTHandle(), windowHandleClose, - display.getJavaObjectAtom(), display.getWindowDeleteAtom()); - } catch (Throwable t) { - if(DEBUG_IMPLEMENTATION) { - Exception e = new Exception("Warning: closeNativeImpl failed - "+Thread.currentThread().getName(), t); - e.printStackTrace(); - } - } finally { - windowHandleClose = 0; - } - } - } - - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ - getReconfigureFlagsAsString(null, flags)); - } - if(0 == ( FLAG_IS_UNDECORATED & flags)) { - final InsetsImmutable i = getInsets(); - - // client position -> top-level window position - x -= i.getLeftWidth() ; - y -= i.getTopHeight() ; - } - final X11Display display = (X11Display) getScreen().getDisplay(); - reconfigureWindow0( getDisplayEDTHandle(), getScreenIndex(), - getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), - x, y, width, height, flags); - - return true; - } - - protected void reparentNotify(long newParentWindowHandle) { - if(DEBUG_IMPLEMENTATION) { - final long p0 = getParentWindowHandle(); - System.err.println("Window.reparentNotify ("+getThreadName()+"): "+toHexString(p0)+" -> "+toHexString(newParentWindowHandle)); - } - } - - protected void requestFocusImpl(boolean force) { - requestFocus0(getDisplayEDTHandle(), getWindowHandle(), force); - } - - @Override - protected void setTitleImpl(final String title) { - runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { - setTitle0(dpy, getWindowHandle(), title); - return null; - } - }); - } - - @Override - protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Boolean run(long dpy) { - return Boolean.valueOf(setPointerVisible0(getDisplayEDTHandle(), getWindowHandle(), pointerVisible)); - } - }).booleanValue(); - } - - @Override - protected boolean confinePointerImpl(final boolean confine) { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Boolean run(long dpy) { - return Boolean.valueOf(confinePointer0(getDisplayEDTHandle(), getWindowHandle(), confine)); - } - }).booleanValue(); - } - - @Override - protected void warpPointerImpl(final int x, final int y) { - runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { - warpPointer0(getDisplayEDTHandle(), getWindowHandle(), x, y); - return null; - } - }); - } - - protected Point getLocationOnScreenImpl(final int x, final int y) { - // X11Util.GetRelativeLocation: locks display already ! - return X11Lib.GetRelativeLocation( getScreen().getDisplay().getHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); - } - - protected void updateInsetsImpl(Insets insets) { - // nop - using event driven insetsChange(..) - } - - protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, - int x, int y, int button, int rotation) { - switch(eventType) { - case MouseEvent.EVENT_MOUSE_PRESSED: - switch(button) { - case X11_WHEEL_ONE_UP_BUTTON: - case X11_WHEEL_ONE_DOWN_BUTTON: - case X11_WHEEL_TWO_UP_BUTTON: - case X11_WHEEL_TWO_DOWN_BUTTON: - // ignore wheel pressed ! - return; - } - break; - case MouseEvent.EVENT_MOUSE_RELEASED: - switch(button) { - case X11_WHEEL_ONE_UP_BUTTON: - eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - button = 1; - rotation = 1; - break; - case X11_WHEEL_ONE_DOWN_BUTTON: - eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - button = 1; - rotation = -1; - break; - case X11_WHEEL_TWO_UP_BUTTON: - eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - button = 2; - rotation = 1; - break; - case X11_WHEEL_TWO_DOWN_BUTTON: - eventType = MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - button = 2; - rotation = -1; - break; - } - break; - } - super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation); - } - - - //---------------------------------------------------------------------- - // Internals only - // - - private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI - private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - - private final long getDisplayEDTHandle() { - return ((X11Display) getScreen().getDisplay()).getEDTHandle(); - } - private final T runWithLockedDisplayHandle(DisplayRunnable action) { - return ((DisplayImpl) getScreen().getDisplay()).runWithLockedDisplayHandle(action); - // return runWithTempDisplayHandle(action); - } - - protected static native boolean initIDs0(); - - private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, - int visualID, long javaObjectAtom, long windowDeleteAtom, - int x, int y, int width, int height, boolean autoPosition, int flags); - private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom); - private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, - long windowDeleteAtom, int x, int y, int width, int height, int flags); - private native void requestFocus0(long display, long windowHandle, boolean force); - - private static native void setTitle0(long display, long windowHandle, String title); - private static native long getParentWindow0(long display, long windowHandle); - private static native boolean setPointerVisible0(long display, long windowHandle, boolean visible); - private static native boolean confinePointer0(long display, long windowHandle, boolean grab); - private static native void warpPointer0(long display, long windowHandle, int x, int y); - - private long windowHandleClose; -} diff --git a/src/newt/native/AndroidWindow.c b/src/newt/native/AndroidWindow.c index fa5765672..94695e1d3 100644 --- a/src/newt/native/AndroidWindow.c +++ b/src/newt/native/AndroidWindow.c @@ -9,7 +9,7 @@ #include #include -#include "jogamp_newt_driver_android_AndroidWindow.h" +#include "jogamp_newt_driver_android_WindowDriver.h" #include #include @@ -23,56 +23,56 @@ #endif -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getSurfaceHandle0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_android_WindowDriver_getSurfaceHandle0 (JNIEnv *env, jclass clazz, jobject surface) { ANativeWindow * anw = ANativeWindow_fromSurface(env, surface); return (jlong) (intptr_t) anw; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getSurfaceVisualID0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_WindowDriver_getSurfaceVisualID0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; return (jint) ANativeWindow_getFormat(anw); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_setSurfaceVisualID0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_WindowDriver_setSurfaceVisualID0 (JNIEnv *env, jclass clazz, jlong surfaceHandle, jint nativeVisualID) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; ANativeWindow_setBuffersGeometry(anw, 0, 0, nativeVisualID); } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getWidth0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_WindowDriver_getWidth0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; return (jint) ANativeWindow_getWidth(anw); } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getHeight0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_WindowDriver_getHeight0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; return (jint) ANativeWindow_getHeight(anw); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_acquire0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_WindowDriver_acquire0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; ANativeWindow_acquire(anw); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_release0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_WindowDriver_release0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; ANativeWindow_release(anw); } -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_android_AndroidWindow_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_android_WindowDriver_initIDs0 (JNIEnv *env, jclass clazz) { DBG_PRINT( "initIDs ok\n" ); diff --git a/src/newt/native/IntelGDL.c b/src/newt/native/IntelGDL.c index 690e1123d..a3bf101c5 100644 --- a/src/newt/native/IntelGDL.c +++ b/src/newt/native/IntelGDL.c @@ -37,9 +37,9 @@ #include #include -#include "jogamp_newt_driver_intel_gdl_Display.h" -#include "jogamp_newt_driver_intel_gdl_Screen.h" -#include "jogamp_newt_driver_intel_gdl_Window.h" +#include "jogamp_newt_driver_intel_gdl_DisplayDriver.h" +#include "jogamp_newt_driver_intel_gdl_ScreenDriver.h" +#include "jogamp_newt_driver_intel_gdl_WindowDriver.h" #include "MouseEvent.h" #include "KeyEvent.h" @@ -122,7 +122,7 @@ static void JNI_ThrowNew(JNIEnv *env, const char *throwable, const char* message * Display */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Display_DispatchMessages +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_DisplayDriver_DispatchMessages (JNIEnv *env, jobject obj, jlong displayHandle, jobject focusedWindow) { // FIXME: n/a @@ -137,7 +137,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Display_DispatchMessage } */ } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_Display_CreateDisplay +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_DisplayDriver_CreateDisplay (JNIEnv *env, jobject obj) { gdl_ret_t retval; @@ -170,7 +170,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_Display_CreateDisplay return (jlong) (intptr_t) p_driver_info; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Display_DestroyDisplay +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_DisplayDriver_DestroyDisplay (JNIEnv *env, jobject obj, jlong displayHandle) { gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle; @@ -189,7 +189,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Display_DestroyDisplay * Screen */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_Screen_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_ScreenDriver_initIDs (JNIEnv *env, jclass clazz) { screenCreatedID = (*env)->GetMethodID(env, clazz, "screenCreated", "(II)V"); @@ -201,7 +201,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_Screen_initIDs return JNI_TRUE; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Screen_GetScreenInfo +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_ScreenDriver_GetScreenInfo (JNIEnv *env, jobject obj, jlong displayHandle, jint idx) { gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle; @@ -233,7 +233,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Screen_GetScreenInfo * Window */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_Window_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { updateBoundsID = (*env)->GetMethodID(env, clazz, "updateBounds", "(IIII)V"); @@ -245,7 +245,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_intel_gdl_Window_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_Window_CreateSurface +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_WindowDriver_CreateSurface (JNIEnv *env, jobject obj, jlong displayHandle, jint scr_width, jint scr_height, jint x, jint y, jint width, jint height) { gdl_driver_info_t * p_driver_info = (gdl_driver_info_t *) (intptr_t) displayHandle; @@ -338,7 +338,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_intel_gdl_Window_CreateSurface return (jlong) (intptr_t) plane; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Window_CloseSurface +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_WindowDriver_CloseSurface (JNIEnv *env, jobject obj, jlong display, jlong surface) { gdl_plane_id_t plane = (gdl_plane_id_t) (intptr_t) surface ; @@ -347,7 +347,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Window_CloseSurface DBG_PRINT("[CloseSurface] plane %d\n", plane); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_Window_SetBounds0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_intel_gdl_WindowDriver_SetBounds0 (JNIEnv *env, jobject obj, jlong surface, jint scr_width, jint scr_height, jint x, jint y, jint width, jint height) { gdl_plane_id_t plane = (gdl_plane_id_t) (intptr_t) surface ; diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index bceb86a85..f1d6aecdf 100644 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -44,7 +44,7 @@ #include #include -#include "jogamp_newt_driver_kd_Window.h" +#include "jogamp_newt_driver_kd_WindowDriver.h" #include "MouseEvent.h" #include "KeyEvent.h" @@ -82,7 +82,7 @@ static jmethodID sendKeyEventID = NULL; * Display */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Display_DispatchMessages +JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_DisplayDriver_DispatchMessages (JNIEnv *env, jobject obj) { const KDEvent * evt; @@ -180,7 +180,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Display_DispatchMessages * Window */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_Window_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { #ifdef VERBOSE_ON @@ -208,7 +208,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_Window_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_Window_CreateWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_WindowDriver_CreateWindow (JNIEnv *env, jobject obj, jlong display, jlong jeglConfig) { EGLDisplay dpy = (EGLDisplay)(intptr_t)display; @@ -236,7 +236,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_Window_CreateWindow return (jlong) (intptr_t) window; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_Window_RealizeWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_WindowDriver_RealizeWindow (JNIEnv *env, jobject obj, jlong window) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -251,7 +251,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_kd_Window_RealizeWindow return (jlong) (intptr_t) nativeWindow; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_kd_Window_CloseWindow +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_kd_WindowDriver_CloseWindow (JNIEnv *env, jobject obj, jlong window, jlong juserData) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -265,11 +265,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_kd_Window_CloseWindow } /* - * Class: jogamp_newt_driver_kd_Window + * Class: jogamp_newt_driver_kd_WindowDriver * Method: setVisible0 * Signature: (JJZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setVisible0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_WindowDriver_setVisible0 (JNIEnv *env, jobject obj, jlong window, jboolean visible) { KDWindow *w = (KDWindow*) (intptr_t) window; @@ -279,7 +279,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setVisible0 (*env)->CallVoidMethod(env, obj, visibleChangedID, JNI_FALSE, visible); // FIXME: or defer=true ? } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setFullScreen0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_WindowDriver_setFullScreen0 (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) { /** not supported, due to missing NV property .. @@ -296,7 +296,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setFullScreen0 (void)fullscreen; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_Window_setSize0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_WindowDriver_setSize0 (JNIEnv *env, jobject obj, jlong window, jint width, jint height) { KDWindow *w = (KDWindow*) (intptr_t) window; diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index bbadc9dd0..e0330a563 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -33,7 +33,7 @@ #import -#import "jogamp_newt_driver_macosx_MacWindow.h" +#import "jogamp_newt_driver_macosx_WindowDriver.h" #import "NewtMacWindow.h" #import "MouseEvent.h" @@ -155,11 +155,11 @@ NS_ENDHANDLER } /* - * Class: jogamp_newt_driver_macosx_MacDisplay + * Class: jogamp_newt_driver_macosx_DisplayDriver * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_initNSApplication0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_initNSApplication0 (JNIEnv *env, jclass clazz) { static int initialized = 0; @@ -189,11 +189,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_initNSAppli } /* - * Class: jogamp_newt_driver_macosx_MacDisplay + * Class: jogamp_newt_driver_macosx_DisplayDriver * Method: runNSApplication0 * Signature: ()V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_runNSApplication0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_runNSApplication0 (JNIEnv *env, jclass clazz) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -206,11 +206,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_runNSApplicatio } /* - * Class: jogamp_newt_driver_macosx_MacDisplay + * Class: jogamp_newt_driver_macosx_DisplayDriver * Method: stopNSApplication0 * Signature: ()V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacDisplay_stopNSApplication0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_stopNSApplication0 (JNIEnv *env, jclass clazz) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -250,11 +250,11 @@ static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx) { } /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: getWidthImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getWidthImpl0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getWidthImpl0 (JNIEnv *env, jclass clazz, jint screen_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -268,11 +268,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getWidthImpl0 } /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: getHeightImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getHeightImpl0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getHeightImpl0 (JNIEnv *env, jclass clazz, jint screen_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -318,11 +318,11 @@ static long GetDictionaryLong(CFDictionaryRef theDict, const void* key) #define ROTMODES_PER_REALMODE 4 /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: getScreenSizeMM0 * Signature: (I)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getScreenSizeMM0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScreenSizeMM0 (JNIEnv *env, jobject obj, jint scrn_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -367,11 +367,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getScreenSi } /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: getScreenMode0 * Signature: (IIII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getScreenMode0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScreenMode0 (JNIEnv *env, jobject obj, jint scrn_idx, jint mode_idx, jint widthMM, jint heightMM) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -459,11 +459,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_MacScreen_getScreenMo } /* - * Class: jogamp_newt_driver_macosx_MacScreen + * Class: jogamp_newt_driver_macosx_ScreenDriver * Method: setScreenMode0 * Signature: (II)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacScreen_setScreenMode0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_setScreenMode0 (JNIEnv *env, jobject object, jint scrn_idx, jint mode_idx) { jboolean res = JNI_TRUE; @@ -504,11 +504,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacScreen_setScreenMod } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 (JNIEnv *env, jclass clazz) { static int initialized = 0; @@ -519,16 +519,16 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_initIDs0 jclass c; c = (*env)->FindClass(env, ClazzNamePoint); if(NULL==c) { - NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't find %s", ClazzNamePoint); + NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0: can't find %s", ClazzNamePoint); } pointClz = (jclass)(*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); if(NULL==pointClz) { - NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't use %s", ClazzNamePoint); + NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0: can't use %s", ClazzNamePoint); } pointCstr = (*env)->GetMethodID(env, pointClz, ClazzAnyCstrName, ClazzNamePointCstrSignature); if(NULL==pointCstr) { - NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_MacWindow_initIDs0: can't fetch %s.%s %s", + NewtCommon_FatalError(env, "FatalError Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0: can't fetch %s.%s %s", ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature); } @@ -541,11 +541,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_initIDs0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createWindow0 * Signature: (JIIIIZIIIJ)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_createWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow0 (JNIEnv *env, jobject jthis, jlong parent, jint x, jint y, jint w, jint h, jboolean opaque, jboolean fullscreen, jint styleMask, jint bufferingType, jint screen_idx, jlong jview) { @@ -698,11 +698,11 @@ NS_ENDHANDLER /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: close0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_close0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -761,11 +761,11 @@ NS_ENDHANDLER } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: lockSurface0 * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_lockSurface0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_lockSurface0 (JNIEnv *env, jclass clazz, jlong window) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); @@ -779,11 +779,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_lockSurface0 } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: unlockSurface0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_unlockSurface0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_unlockSurface0 (JNIEnv *env, jclass clazz, jlong window) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); @@ -794,11 +794,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_unlockSurface0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: requestFocus0 * Signature: (JZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocus0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_requestFocus0 (JNIEnv *env, jobject window, jlong w, jboolean force) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -819,11 +819,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_requestFocus0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: resignFocus0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_resignFocus0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_resignFocus0 (JNIEnv *env, jobject window, jlong w) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -846,11 +846,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_resignFocus0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: orderFront0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderFront0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_orderFront0 (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -866,11 +866,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderFront0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: orderOut * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_orderOut0 (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -891,11 +891,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_orderOut0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setTitle0 * Signature: (JLjava/lang/String;)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setTitle0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setTitle0 (JNIEnv *env, jobject unused, jlong window, jstring title) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -913,11 +913,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setTitle0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: contentView * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_contentView0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 (JNIEnv *env, jobject unused, jlong window) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -934,11 +934,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_contentView0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: changeContentView * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_changeContentView0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeContentView0 (JNIEnv *env, jobject jthis, jlong parentWindowOrView, jlong window, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -977,11 +977,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_MacWindow_changeContentVi } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setContentSize * Signature: (JII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setContentSize0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setContentSize0 (JNIEnv *env, jobject unused, jlong window, jint w, jint h) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -998,11 +998,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setContentSize0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setFrameTopLeftPoint * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setFrameTopLeftPoint0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setFrameTopLeftPoint0 (JNIEnv *env, jobject unused, jlong parent, jlong window, jint x, jint y) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -1027,11 +1027,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setFrameTopLeftP } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: setAlwaysOnTop0 * Signature: (JZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setAlwaysOnTop0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setAlwaysOnTop0 (JNIEnv *env, jobject unused, jlong window, jboolean atop) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -1051,11 +1051,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setAlwaysOnTop0 } /* - * Class: jogamp_newt_driver_macosx_MacWindow + * Class: jogamp_newt_driver_macosx_WindowDriver * Method: getLocationOnScreen0 * Signature: (JII)Ljavax/media/nativewindow/util/Point; */ -JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_MacWindow_getLocationOnScreen0 +JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_getLocationOnScreen0 (JNIEnv *env, jclass unused, jlong win, jint src_x, jint src_y) { NSObject *nsObj = (NSObject*) ((intptr_t) win); @@ -1072,11 +1072,11 @@ JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_MacWindow_getLocationOn } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: setPointerVisible0 * Signature: (JZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setPointerVisible0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerVisible0 (JNIEnv *env, jclass clazz, jlong window, jboolean hasFocus, jboolean mouseVisible) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); @@ -1086,11 +1086,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_setPointerVi } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: confinePointer0 * Signature: (JZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_confinePointer0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePointer0 (JNIEnv *env, jclass clazz, jlong window, jboolean confine) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); @@ -1099,11 +1099,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_MacWindow_confinePoint } /* - * Class: Java_jogamp_newt_driver_macosx_MacWindow + * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: warpPointer0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_MacWindow_warpPointer0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong window, jint x, jint y) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 6d9c04dc3..40252f59b 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -81,9 +81,9 @@ #define DISPLAY_DEVICE_ACTIVE 0x00000001 #endif -#include "jogamp_newt_driver_windows_WindowsDisplay.h" -#include "jogamp_newt_driver_windows_WindowsScreen.h" -#include "jogamp_newt_driver_windows_WindowsWindow.h" +#include "jogamp_newt_driver_windows_DisplayDriver.h" +#include "jogamp_newt_driver_windows_ScreenDriver.h" +#include "jogamp_newt_driver_windows_WindowDriver.h" #include "Window.h" #include "MouseEvent.h" @@ -1011,11 +1011,11 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, } /* - * Class: jogamp_newt_driver_windows_WindowsDisplay + * Class: jogamp_newt_driver_windows_DisplayDriver * Method: DispatchMessages * Signature: ()V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsDisplay_DispatchMessages0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_DispatchMessages0 (JNIEnv *env, jclass clazz) { int i = 0; @@ -1040,11 +1040,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsDisplay_DispatchMe } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getOriginX0 * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginX0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginX0 (JNIEnv *env, jobject obj, jint scrn_idx) { if( GetSystemMetrics( SM_CMONITORS) > 1) { @@ -1055,11 +1055,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginX0 } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getOriginY0 * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginY0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginY0 (JNIEnv *env, jobject obj, jint scrn_idx) { if( GetSystemMetrics( SM_CMONITORS ) > 1) { @@ -1070,11 +1070,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getOriginY0 } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getWidthImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getWidthImpl0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getWidthImpl0 (JNIEnv *env, jobject obj, jint scrn_idx) { if( GetSystemMetrics( SM_CMONITORS) > 1) { @@ -1085,11 +1085,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getWidthImp } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getHeightImpl * Signature: (I)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getHeightImpl0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getHeightImpl0 (JNIEnv *env, jobject obj, jint scrn_idx) { if( GetSystemMetrics( SM_CMONITORS ) > 1) { @@ -1173,11 +1173,11 @@ static HDC NewtScreen_createDisplayDC(LPCTSTR displayDeviceName) { } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: getScreenMode0 * Signature: (II)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getScreenMode0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getScreenMode0 (JNIEnv *env, jobject obj, jint scrn_idx, jint mode_idx) { DISPLAY_DEVICE device; @@ -1246,11 +1246,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_getScr } /* - * Class: jogamp_newt_driver_windows_WindowsScreen + * Class: jogamp_newt_driver_windows_ScreenDriver * Method: setScreenMode0 * Signature: (IIIIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_setScreenMode0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScreenMode0 (JNIEnv *env, jobject object, jint scrn_idx, jint width, jint height, jint bits, jint rate, jint rot) { DISPLAY_DEVICE device; @@ -1283,11 +1283,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsScreen_setScre } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: initIDs0 * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 (JNIEnv *env, jclass clazz) { NewtCommon_init(env); @@ -1324,11 +1324,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_initIDs } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: getNewtWndProc0 * Signature: ()J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_getNewtWndProc0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_getNewtWndProc0 (JNIEnv *env, jclass clazz) { return (jlong) (intptr_t) wndProc; @@ -1366,10 +1366,10 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: CreateWindow */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_CreateWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong hInstance, jstring jWndClassName, jstring jWndName, jlong parent, @@ -1473,11 +1473,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_CreateWind } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: MonitorFromWindow * Signature: (J)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_MonitorFromWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_MonitorFromWindow0 (JNIEnv *env, jobject obj, jlong window) { #if (_WIN32_WINNT >= 0x0500 || _WIN32_WINDOWS >= 0x0410 || WINVER >= 0x0500) && !defined(_WIN32_WCE) @@ -1506,11 +1506,11 @@ static jboolean NewtWindows_setFullScreen(jboolean fullscreen) } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: reconfigureWindow0 * Signature: (JJIIIII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_reconfigureWindow0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_reconfigureWindow0 (JNIEnv *env, jobject obj, jlong parent, jlong window, jint x, jint y, jint width, jint height, jint flags) { @@ -1591,11 +1591,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_reconfigure } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: setTitle * Signature: (JLjava/lang/String;)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setTitle0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_setTitle0 (JNIEnv *env, jclass clazz, jlong window, jstring title) { HWND hwnd = (HWND) (intptr_t) window; @@ -1609,11 +1609,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setTitle0 } /* - * Class: jogamp_newt_driver_windows_WindowsWindow + * Class: jogamp_newt_driver_windows_WindowDriver * Method: requestFocus * Signature: (JZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_requestFocus0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_requestFocus0 (JNIEnv *env, jobject obj, jlong window, jboolean force) { DBG_PRINT("*** WindowsWindow: RequestFocus0\n"); @@ -1621,11 +1621,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_requestFocu } /* - * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Class: Java_jogamp_newt_driver_windows_WindowDriver * Method: setPointerVisible0 * Signature: (JJZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setPointerVisible0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_setPointerVisible0 (JNIEnv *env, jclass clazz, jlong window, jboolean mouseVisible) { HWND hwnd = (HWND) (intptr_t) window; @@ -1660,11 +1660,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_setPoin } /* - * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Class: Java_jogamp_newt_driver_windows_WindowDriver * Method: confinePointer0 * Signature: (JJZIIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_confinePointer0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_confinePointer0 (JNIEnv *env, jclass clazz, jlong window, jboolean confine, jint l, jint t, jint r, jint b) { HWND hwnd = (HWND) (intptr_t) window; @@ -1686,11 +1686,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_confine } /* - * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Class: Java_jogamp_newt_driver_windows_WindowDriver * Method: warpPointer0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_warpPointer0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong window, jint x, jint y) { DBG_PRINT( "*** WindowsWindow: warpPointer0: %d/%d\n", x, y); @@ -1698,11 +1698,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_warpPointer } /* - * Class: Java_jogamp_newt_driver_windows_WindowsWindow + * Class: Java_jogamp_newt_driver_windows_WindowDriver * Method: trackPointerLeave0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowsWindow_trackPointerLeave0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_trackPointerLeave0 (JNIEnv *env, jclass clazz, jlong window) { HWND hwnd = (HWND) (intptr_t) window; diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h index 982255b8a..128b6b6f1 100644 --- a/src/newt/native/X11Common.h +++ b/src/newt/native/X11Common.h @@ -45,9 +45,9 @@ #include -#include "jogamp_newt_driver_x11_X11Screen.h" -#include "jogamp_newt_driver_x11_X11Display.h" -#include "jogamp_newt_driver_x11_X11Window.h" +#include "jogamp_newt_driver_x11_ScreenDriver.h" +#include "jogamp_newt_driver_x11_DisplayDriver.h" +#include "jogamp_newt_driver_x11_WindowDriver.h" #include "Window.h" #include "MouseEvent.h" diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index ce7d9a0e1..3157538c3 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -34,7 +34,7 @@ jclass X11NewtWindowClazz = NULL; jmethodID insetsChangedID = NULL; jmethodID visibleChangedID = NULL; -static const char * const ClazzNameX11NewtWindow = "jogamp/newt/driver/x11/X11Window"; +static const char * const ClazzNameX11NewtWindow = "jogamp/newt/driver/x11/WindowDriver"; static jmethodID displayCompletedID = NULL; @@ -264,11 +264,11 @@ static jint X11InputState2NewtModifiers(unsigned int xstate) { */ /* - * Class: jogamp_newt_driver_x11_X11Display + * Class: jogamp_newt_driver_x11_DisplayDriver * Method: initIDs * Signature: (Z)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Display_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 (JNIEnv *env, jclass clazz, jboolean debug) { jclass c; @@ -281,12 +281,12 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Display_initIDs0 if(NULL==X11NewtWindowClazz) { c = (*env)->FindClass(env, ClazzNameX11NewtWindow); if(NULL==c) { - NewtCommon_FatalError(env, "NEWT X11Window: can't find %s", ClazzNameX11NewtWindow); + NewtCommon_FatalError(env, "NEWT X11Display: can't find %s", ClazzNameX11NewtWindow); } X11NewtWindowClazz = (jclass)(*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); if(NULL==X11NewtWindowClazz) { - NewtCommon_FatalError(env, "NEWT X11Window: can't use %s", ClazzNameX11NewtWindow); + NewtCommon_FatalError(env, "NEWT X11Display: can't use %s", ClazzNameX11NewtWindow); } } @@ -331,11 +331,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Display_initIDs0 } /* - * Class: jogamp_newt_driver_x11_X11Display + * Class: jogamp_newt_driver_x11_DisplayDriver * Method: CompleteDisplay * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_CompleteDisplay0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_CompleteDisplay0 (JNIEnv *env, jobject obj, jlong display) { Display * dpy = (Display *)(intptr_t)display; @@ -366,11 +366,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_CompleteDisplay0 } /* - * Class: jogamp_newt_driver_x11_X11Display + * Class: jogamp_newt_driver_x11_DisplayDriver * Method: DisplayRelease0 * Signature: (JJJ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DisplayRelease0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DisplayRelease0 (JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong windowDeleteAtom) { Display * dpy = (Display *)(intptr_t)display; @@ -390,11 +390,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DisplayRelease0 } /* - * Class: jogamp_newt_driver_x11_X11Display + * Class: jogamp_newt_driver_x11_DisplayDriver * Method: DispatchMessages * Signature: (JIJJ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0 (JNIEnv *env, jobject obj, jlong display, jlong javaObjectAtom, jlong windowDeleteAtom) { Display * dpy = (Display *) (intptr_t) display; diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c index 698eed89d..334c39727 100644 --- a/src/newt/native/X11Screen.c +++ b/src/newt/native/X11Screen.c @@ -36,11 +36,11 @@ #endif /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: GetScreen * Signature: (JI)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_GetScreen0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_GetScreen0 (JNIEnv *env, jclass clazz, jlong display, jint screen_index) { Display * dpy = (Display *)(intptr_t)display; @@ -60,14 +60,14 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_GetScreen0 return (jlong) (intptr_t) scrn; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getWidth0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getWidth0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display * dpy = (Display *) (intptr_t) display; return (jint) DisplayWidth( dpy, scrn_idx); } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getHeight0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getHeight0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display * dpy = (Display *) (intptr_t) display; @@ -112,11 +112,11 @@ static int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getAvailableScreenModeRotations0 * Signature: (JI)I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getAvailableScreenModeRotations0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailableScreenModeRotations0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -162,11 +162,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getAvailableSc } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getNumScreenModeResolution0 * Signature: (JI)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeResolutions0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -177,7 +177,7 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeRes #endif if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeResolutions0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0: RANDR not available\n"); return 0; } @@ -200,17 +200,17 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeRes } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getScreenModeResolutions0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeResolution0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getScreenModeResolution0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0: RANDR not available\n"); return (*env)->NewIntArray(env, 0); } @@ -242,17 +242,17 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeR } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getScreenModeRates0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeRates0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getScreenModeRates0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0: RANDR not available\n"); return (*env)->NewIntArray(env, 0); } @@ -285,11 +285,11 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeR } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getScreenConfiguration0 * Signature: (JI)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenConfiguration0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenConfiguration0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -301,7 +301,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenConfigura #endif if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getScreenConfiguration0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenConfiguration0: RANDR not available\n"); return 0; } #ifdef DBG_PERF @@ -320,22 +320,22 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenConfigura } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: freeScreenConfiguration0 * Signature: (J)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Screen_freeScreenConfiguration0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_freeScreenConfiguration0 (JNIEnv *env, jclass clazz, jlong screenConfiguration) { XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getCurrentScreenRate0 * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRate0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRate0 (JNIEnv *env, jclass clazz, jlong screenConfiguration) { XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; @@ -347,11 +347,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRat } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getCurrentScreenRotation0 * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRotation0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRotation0 (JNIEnv *env, jclass clazz, jlong screenConfiguration) { XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; @@ -364,11 +364,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRot /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: getCurrentScreenResolutionIndex0 * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenResolutionIndex0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenResolutionIndex0 (JNIEnv *env, jclass clazz, jlong screenConfiguration) { XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; @@ -383,11 +383,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRes } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: setCurrentScreenModeStart0 * Signature: (JIJIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModeStart0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModeStart0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) { Display *dpy = (Display *) (intptr_t) display; @@ -432,11 +432,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScree } /* - * Class: jogamp_newt_driver_x11_X11Screen + * Class: jogamp_newt_driver_x11_ScreenDriver * Method: setCurrentScreenModePollEnd0 * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModePollEnd0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) { Display *dpy = (Display *) (intptr_t) display; @@ -445,7 +445,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScree XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModePollEnd0: RANDR not available\n"); + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0: RANDR not available\n"); return JNI_FALSE; } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index daf9f2b53..59862f463 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -467,11 +467,11 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, */ /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: initIDs * Signature: ()Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_initIDs0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_WindowDriver_initIDs0 (JNIEnv *env, jclass clazz) { return JNI_TRUE; @@ -505,10 +505,10 @@ static void NewtWindows_setPosSize(Display *dpy, Window w, jint x, jint y, jint } /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: CreateWindow */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index, jint visualID, jlong javaObjectAtom, jlong windowDeleteAtom, @@ -666,11 +666,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_CreateWindow0 } /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: CloseWindow * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_CloseWindow0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 (JNIEnv *env, jobject obj, jlong display, jlong window, jlong javaObjectAtom, jlong windowDeleteAtom) { Display * dpy = (Display *) (intptr_t) display; @@ -703,7 +703,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_CloseWindow0 NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); // Drain all events related to this window .. - Java_jogamp_newt_driver_x11_X11Display_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom); + Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom); XDestroyWindow(dpy, w); XSync(dpy, False); @@ -729,11 +729,11 @@ static Bool WaitForReparentNotify( Display *dpy, XEvent *event, XPointer arg ) { */ /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: reconfigureWindow0 * Signature: (JIJJIIIII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindow0 (JNIEnv *env, jobject obj, jlong jdisplay, jint screen_index, jlong jparent, jlong jwindow, jlong windowDeleteAtom, jint x, jint y, jint width, jint height, jint flags) @@ -869,33 +869,33 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_reconfigureWindow0 } /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: requestFocus0 * Signature: (JJZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_requestFocus0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_requestFocus0 (JNIEnv *env, jobject obj, jlong display, jlong window, jboolean force) { NewtWindows_requestFocus ( env, obj, (Display *) (intptr_t) display, (Window)window, force ) ; } /* - * Class: jogamp_newt_driver_x11_X11Window + * Class: jogamp_newt_driver_x11_WindowDriver * Method: getParentWindow0 * Signature: (JJ)J */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Window_getParentWindow0 +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_getParentWindow0 (JNIEnv *env, jclass clazz, jlong display, jlong window) { return (jlong) NewtWindows_getParent ((Display *) (intptr_t) display, (Window)window); } /* - * Class: Java_jogamp_newt_driver_x11_X11Window + * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: setTitle0 * Signature: (JJLjava/lang/String;)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_setTitle0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_setTitle0 (JNIEnv *env, jclass clazz, jlong display, jlong window, jstring title) { Display * dpy = (Display *) (intptr_t) display; @@ -942,11 +942,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_setTitle0 } /* - * Class: Java_jogamp_newt_driver_x11_X11Window + * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: setPointerVisible0 * Signature: (JJZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_setPointerVisible0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_WindowDriver_setPointerVisible0 (JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean mouseVisible) { static char noData[] = { 0,0,0,0,0,0,0,0 }; @@ -976,11 +976,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_setPointerVisib } /* - * Class: Java_jogamp_newt_driver_x11_X11Window + * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: confinePointer0 * Signature: (JJZ)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_confinePointer0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_WindowDriver_confinePointer0 (JNIEnv *env, jclass clazz, jlong display, jlong window, jboolean confine) { Display * dpy = (Display *) (intptr_t) display; @@ -999,11 +999,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Window_confinePointer0 } /* - * Class: Java_jogamp_newt_driver_x11_X11Window + * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: warpPointer0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Window_warpPointer0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong display, jlong window, jint x, jint y) { Display * dpy = (Display *) (intptr_t) display; diff --git a/src/newt/native/bcm_egl.c b/src/newt/native/bcm_egl.c index 79ebd20e0..9b960d278 100644 --- a/src/newt/native/bcm_egl.c +++ b/src/newt/native/bcm_egl.c @@ -37,7 +37,7 @@ #include #include -#include "jogamp_newt_driver_bcm_egl_Window.h" +#include "jogamp_newt_driver_bcm_egl_WindowDriver.h" #include "MouseEvent.h" #include "KeyEvent.h" @@ -67,7 +67,7 @@ static jmethodID windowCreatedID = NULL; * Display */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DispatchMessages +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_DisplayDriver_DispatchMessages (JNIEnv *env, jobject obj) { // FIXME: n/a @@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DispatchMessages (void) obj; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Display_CreateDisplay +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_DisplayDriver_CreateDisplay (JNIEnv *env, jobject obj, jint width, jint height) { (void) env; @@ -89,7 +89,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Display_CreateDisplay return (jlong) (intptr_t) dpy; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DestroyDisplay +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_DisplayDriver_DestroyDisplay (JNIEnv *env, jobject obj, jlong display) { EGLDisplay dpy = (EGLDisplay)(intptr_t)display; @@ -106,7 +106,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Display_DestroyDisplay * Window */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_egl_Window_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_egl_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(III)V"); @@ -118,7 +118,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_egl_Window_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CreateWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_WindowDriver_CreateWindow (JNIEnv *env, jobject obj, jlong display, jboolean chromaKey, jint width, jint height) { EGLDisplay dpy = (EGLDisplay)(intptr_t)display; @@ -162,7 +162,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CreateWindow return (jlong) (intptr_t) window; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CloseWindow +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_WindowDriver_CloseWindow (JNIEnv *env, jobject obj, jlong display, jlong window) { EGLDisplay dpy = (EGLDisplay) (intptr_t) display; @@ -175,7 +175,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Window_CloseWindow DBG_PRINT( "[CloseWindow] X\n"); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_Window_SwapWindow +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_egl_WindowDriver_SwapWindow (JNIEnv *env, jobject obj, jlong display, jlong window) { EGLDisplay dpy = (EGLDisplay) (intptr_t) display; diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index 09ab8a634..e41745e14 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -32,9 +32,9 @@ #include "bcm_vc_iv.h" -#include "jogamp_newt_driver_bcm_vc_iv_Display.h" -#include "jogamp_newt_driver_bcm_vc_iv_Screen.h" -#include "jogamp_newt_driver_bcm_vc_iv_Window.h" +#include "jogamp_newt_driver_bcm_vc_iv_DisplayDriver.h" +#include "jogamp_newt_driver_bcm_vc_iv_ScreenDriver.h" +#include "jogamp_newt_driver_bcm_vc_iv_WindowDriver.h" #define VERBOSE_ON 1 @@ -57,7 +57,7 @@ static jmethodID sendKeyEventID = NULL; * Display */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_initIDs (JNIEnv *env, jclass clazz) { bcm_host_init(); @@ -66,7 +66,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_initIDs return JNI_TRUE; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_DispatchMessages +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DispatchMessages (JNIEnv *env, jobject obj) { } @@ -75,7 +75,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Display_DispatchMessage * Screen */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initIDs (JNIEnv *env, jclass clazz) { uint32_t screen_width; @@ -91,7 +91,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initIDs return JNI_TRUE; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initNative +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative (JNIEnv *env, jobject obj) { uint32_t screen_width; @@ -109,7 +109,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Screen_initNative * Window */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V"); @@ -131,7 +131,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_initIDs return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CreateWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow (JNIEnv *env, jobject obj, jint width, jint height) { int32_t success = 0; @@ -166,13 +166,13 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CreateWindow return (jlong) (intptr_t) nativeWindowPtr; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_RealizeWindow +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_RealizeWindow (JNIEnv *env, jobject obj, jlong window) { return (jlong) (intptr_t) 0; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CloseWindow +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindow (JNIEnv *env, jobject obj, jlong window, jlong juserData) { EGL_DISPMANX_WINDOW_T * nativeWindowPtr = (EGL_DISPMANX_WINDOW_T *) (intptr_t) window ; @@ -181,21 +181,21 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_CloseWindow } /* - * Class: jogamp_newt_driver_bcm_vc_iv_Window + * Class: jogamp_newt_driver_bcm_vc_iv_WindowDriver * Method: setVisible0 * Signature: (JJZ)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_setVisible0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setVisible0 (JNIEnv *env, jobject obj, jlong window, jboolean visible) { } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_setFullScreen0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setFullScreen0 (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) { } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_Window_setSize0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setSize0 (JNIEnv *env, jobject obj, jlong window, jint width, jint height) { // FIXME RESIZE (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index 11babf187..89395e309 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -34,11 +34,11 @@ import java.util.Arrays; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; -import jogamp.newt.driver.android.AndroidWindow; import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.opengl.GLWindow; @@ -55,8 +55,8 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { MouseAdapter toFrontMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { Object src = e.getSource(); - if(src instanceof AndroidWindow) { - ((AndroidWindow)src).requestFocus(false); + if(src instanceof Window) { + ((Window)src).requestFocus(false); } } }; diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index a5e5f4ccb..a7fefd838 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -36,11 +36,11 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; -import jogamp.newt.driver.android.AndroidWindow; import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.opengl.GLWindow; @@ -59,8 +59,8 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { MouseAdapter toFrontMouseListener = new MouseAdapter() { public void mouseClicked(MouseEvent e) { Object src = e.getSource(); - if(src instanceof AndroidWindow) { - ((AndroidWindow)src).requestFocus(false); + if(src instanceof Window) { + ((Window)src).requestFocus(false); } } }; @@ -121,7 +121,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); { final int padding = mPlayerHUD ? 32 : 0; - final android.view.View androidView = ((AndroidWindow)glWindowMain.getDelegatedWindow()).getAndroidView(); + final android.view.View androidView = ((jogamp.newt.driver.android.WindowDriver)glWindowMain.getDelegatedWindow()).getAndroidView(); glWindowMain.setSize(scrn.getWidth()-padding, scrn.getHeight()-padding); glWindowMain.setUndecorated(true); // setContentView(getWindow(), glWindowMain); @@ -168,7 +168,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { viewGroup.post(new Runnable() { public void run() { - final android.view.View androidView = ((AndroidWindow)glWindowHUD.getDelegatedWindow()).getAndroidView(); + final android.view.View androidView = ((jogamp.newt.driver.android.WindowDriver)glWindowHUD.getDelegatedWindow()).getAndroidView(); // addContentView(getWindow(), glWindowHUD, new android.view.ViewGroup.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight())); viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(glWindowHUD.getWidth(), glWindowHUD.getHeight(), Gravity.TOP|Gravity.LEFT)); registerNEWTWindow(glWindowHUD); -- cgit v1.2.3 From ee306d4900c9aad5248d30ce0594f07d2f79bb71 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 19 Aug 2012 11:48:04 +0200 Subject: NEWT Windows.closeNativeImpl(): Remove 'GDI.SetParent(windowHandleClose, 0)' for NewtCanvasSWT workaround - not required anymore --- make/scripts/java-win32-dbg.bat | 4 ++-- make/scripts/java-win32.bat | 4 ++-- make/scripts/tests-x32.bat | 7 ++++++- src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java | 1 - 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat index 6f8206721..5735797bf 100755 --- a/make/scripts/java-win32-dbg.bat +++ b/make/scripts/java-win32-dbg.bat @@ -9,9 +9,9 @@ set BLD_DIR=..\%BLD_SUB% set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj set LIB_DIR=%FFMPEG_LIB% diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat index 1d8430280..a4d631075 100755 --- a/make/scripts/java-win32.bat +++ b/make/scripts/java-win32.bat @@ -7,9 +7,9 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl set BLD_DIR=..\%BLD_SUB% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\angle\win32;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% set BLD_DIR=..\%BLD_SUB% REM set LIB_DIR=..\..\gluegen\%BLD_SUB%\obj;%BLD_DIR%\lib diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index 7947759a4..de0785661 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -1,6 +1,7 @@ REM scripts\java-win32-dbg.bat jogamp.newt.awt.opengl.VersionApplet REM scripts\java-win32-dbg.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win32-dbg.bat javax.media.opengl.awt.GLCanvas +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn @@ -71,6 +72,10 @@ REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingPr REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT01GLn $* +REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT -time 5000 @@ -94,7 +99,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMe REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* +REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 39ea54575..5dbdeb458 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -163,7 +163,6 @@ public class WindowDriver extends WindowImpl { } } try { - GDI.SetParent(windowHandleClose, 0); // detach first, experience hang w/ SWT parent GDI.DestroyWindow(windowHandleClose); } catch (Throwable t) { if(DEBUG_IMPLEMENTATION) { -- cgit v1.2.3 From 90d45928186f2be99999461cfe45f76a783cc961 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 7 Sep 2012 05:46:22 +0200 Subject: Fix Capabilities ambiguity and explosion of queried available-list; Add FBO availability detection for EGL, WGL and OSX. Introducing Capabilities 'bitmap' boolean, complementing the offscreen modes FBO and PBuffer. This allows: 1 - deterministic setting of the offscreen mode 2 - utilizing auto configuration of offscreen mode, if !onscreen !FBO !PBuffer and !Bitmap 3 - adding 'availability' semantic of 'onscreen' boolean, i.e. if onscree:=1 for a queried instance, the offscreen modes still indicate offscreen availability - see [4] 4 - avoiding explosion of the availability list due to [3], one Capability entry reflect on- and offscreen settings. Add FBO availability detection for EGL, WGL and OSX. Tested manually w/ 'TestGLCapabilities01NEWT' on X11 [NV, ATI], WGL[NV], OSX[NV]. --- make/scripts/tests-x64.bat | 3 +- make/scripts/tests.sh | 51 +++-- .../media/opengl/DefaultGLCapabilitiesChooser.java | 39 ++-- .../classes/javax/media/opengl/GLCapabilities.java | 96 +++++---- .../media/opengl/GLCapabilitiesImmutable.java | 79 +++++-- .../jogamp/opengl/GLDrawableFactoryImpl.java | 6 +- .../jogamp/opengl/GLGraphicsConfigurationUtil.java | 151 +++++++------ .../jogamp/opengl/egl/EGLDrawableFactory.java | 9 +- .../jogamp/opengl/egl/EGLGLCapabilities.java | 18 +- .../opengl/egl/EGLGraphicsConfiguration.java | 68 +++--- .../egl/EGLGraphicsConfigurationFactory.java | 36 ++-- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 9 +- .../macosx/cgl/MacOSXCGLGraphicsConfiguration.java | 6 +- .../windows/wgl/WindowsPbufferWGLDrawable.java | 15 +- .../wgl/WindowsWGLGraphicsConfiguration.java | 94 ++++----- .../WindowsWGLGraphicsConfigurationFactory.java | 80 +++---- .../x11/glx/X11GLXGraphicsConfiguration.java | 59 ++---- .../glx/X11GLXGraphicsConfigurationFactory.java | 81 +++---- .../javax/media/nativewindow/Capabilities.java | 160 +++++++------- .../media/nativewindow/CapabilitiesImmutable.java | 35 +++- .../nativewindow/DefaultCapabilitiesChooser.java | 9 +- .../junit/jogl/acore/TestGLCapabilities01NEWT.java | 233 +++++++++++++++++++++ .../opengl/test/junit/util/AWTRobotUtil.java | 13 ++ 23 files changed, 881 insertions(+), 469 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 6d3e46af6..669e0212e 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -1,6 +1,7 @@ REM scripts\java-win64-dbg.bat jogamp.newt.awt.opengl.VersionApplet REM scripts\java-win64-dbg.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win64-dbg.bat javax.media.opengl.awt.GLCanvas +scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn @@ -39,7 +40,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index cccc825ee..1314094cf 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -60,10 +60,9 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.fbo.force.none" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all" - #D_ARGS="-Dnewt.debug.Window" - #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDebugMessageHandler" @@ -76,7 +75,8 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLArrayData" - #D_ARGS="-Djogl.debug.EGL -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" + #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" + #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" @@ -107,7 +107,7 @@ function jrun() { #D_ARGS="-Djogl.debug.Animator -Dnewt.debug=all" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Display -Dnativewindow.debug.X11Util -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext" - #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" + #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLDrawable -Djogl.debug.GLProfile" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.EDT -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Dnewt.debug.EDT" @@ -247,7 +247,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* @@ -278,6 +278,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedAWT $* @@ -291,7 +292,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* @@ -315,8 +317,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # # newt.awt (testawt) # -#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper +#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* @@ -366,16 +368,32 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* # -# GLSL / FBO / .. +# GLSL # #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* + +# +# FBO / .. +# +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01bNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableMix2DemosES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # # Graph @@ -411,13 +429,20 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: +# EARMARK removal of shutdown mode! +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT $* # osx: +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* - #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* + $spath/count-edt-start.sh java-run.log diff --git a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java index 5fa8ce32d..b052769ca 100644 --- a/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java +++ b/src/jogl/classes/javax/media/opengl/DefaultGLCapabilitiesChooser.java @@ -87,20 +87,20 @@ import jogamp.opengl.Debug; public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { private static final boolean DEBUG = Debug.isPropertyDefined("jogl.debug.CapabilitiesChooser", true); - final static int NO_SCORE = -9999999; - final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000; - final static int OPAQUE_MISMATCH_PENALTY = 750; - final static int STENCIL_MISMATCH_PENALTY = 500; - final static int MULTISAMPLE_MISMATCH_PENALTY = 500; - final static int MULTISAMPLE_EXTENSION_MISMATCH_PENALTY = 250; // just a little drop, no scale + private final static int NO_SCORE = -9999999; + private final static int DOUBLE_BUFFER_MISMATCH_PENALTY = 1000; + private final static int OPAQUE_MISMATCH_PENALTY = 750; + private final static int STENCIL_MISMATCH_PENALTY = 500; + private final static int MULTISAMPLE_MISMATCH_PENALTY = 500; + private final static int MULTISAMPLE_EXTENSION_MISMATCH_PENALTY = 250; // just a little drop, no scale // Pseudo attempt to keep equal rank penalties scale-equivalent // (e.g., stencil mismatch is 3 * accum because there are 3 accum // components) - final static int COLOR_MISMATCH_PENALTY_SCALE = 36; - final static int DEPTH_MISMATCH_PENALTY_SCALE = 6; - final static int ACCUM_MISMATCH_PENALTY_SCALE = 1; - final static int STENCIL_MISMATCH_PENALTY_SCALE = 3; - final static int MULTISAMPLE_MISMATCH_PENALTY_SCALE = 3; + private final static int COLOR_MISMATCH_PENALTY_SCALE = 36; + private final static int DEPTH_MISMATCH_PENALTY_SCALE = 6; + private final static int ACCUM_MISMATCH_PENALTY_SCALE = 1; + private final static int STENCIL_MISMATCH_PENALTY_SCALE = 3; + private final static int MULTISAMPLE_MISMATCH_PENALTY_SCALE = 3; @Override public int chooseCapabilities(final CapabilitiesImmutable desired, @@ -150,11 +150,20 @@ public class DefaultGLCapabilitiesChooser implements GLCapabilitiesChooser { if (cur == null) { continue; } - if (gldes.isOnscreen() != cur.isOnscreen()) { - continue; + if (gldes.isOnscreen() && !cur.isOnscreen()) { + continue; // requested onscreen, but n/a } - if (!gldes.isOnscreen() && gldes.isPBuffer() && !cur.isPBuffer()) { - continue; // only skip if requested Offscreen && PBuffer, but no PBuffer available + if (!gldes.isOnscreen()) { + /** FBO is generic .. + if (gldes.isFBO() && !cur.isFBO()) { + continue; // requested FBO, but n/a + } */ + if (gldes.isPBuffer() && !cur.isPBuffer()) { + continue; // requested pBuffer, but n/a + } + if (gldes.isBitmap() && !cur.isBitmap()) { + continue; // requested pBuffer, but n/a + } } if (gldes.getStereo() != cur.getStereo()) { continue; diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilities.java b/src/jogl/classes/javax/media/opengl/GLCapabilities.java index 8845ec665..30a6215e7 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilities.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilities.java @@ -105,20 +105,21 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil @Override public int hashCode() { // 31 * x == (x << 5) - x - int hash = 31 + this.glProfile.hashCode() ; + int hash = super.hashCode(); + hash = ((hash << 5) - hash) + this.glProfile.hashCode() ; + hash = ((hash << 5) - hash) + ( this.hardwareAccelerated ? 1 : 0 ); + hash = ((hash << 5) - hash) + ( this.stereo ? 1 : 0 ); hash = ((hash << 5) - hash) + ( this.isFBO ? 1 : 0 ); hash = ((hash << 5) - hash) + ( this.isPBuffer ? 1 : 0 ); - hash = ((hash << 5) - hash) + ( this.stereo ? 1 : 0 ); - hash = ((hash << 5) - hash) + ( this.hardwareAccelerated ? 1 : 0 ); + hash = ((hash << 5) - hash) + ( this.sampleBuffers ? 1 : 0 ); + hash = ((hash << 5) - hash) + this.getNumSamples(); + hash = ((hash << 5) - hash) + this.sampleExtension.hashCode(); hash = ((hash << 5) - hash) + this.depthBits; hash = ((hash << 5) - hash) + this.stencilBits; hash = ((hash << 5) - hash) + this.accumRedBits; hash = ((hash << 5) - hash) + this.accumGreenBits; hash = ((hash << 5) - hash) + this.accumBlueBits; hash = ((hash << 5) - hash) + this.accumAlphaBits; - hash = ((hash << 5) - hash) + ( this.sampleBuffers ? 1 : 0 ); - hash = ((hash << 5) - hash) + this.numSamples; - hash = ((hash << 5) - hash) + this.sampleExtension.hashCode(); hash = ((hash << 5) - hash) + ( this.pbufferFloatingPointBuffers ? 1 : 0 ); hash = ((hash << 5) - hash) + ( this.pbufferRenderToTexture ? 1 : 0 ); hash = ((hash << 5) - hash) + ( this.pbufferRenderToTextureRectangle ? 1 : 0 ); @@ -148,9 +149,8 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil other.getPbufferFloatingPointBuffers()==pbufferFloatingPointBuffers && other.getPbufferRenderToTexture()==pbufferRenderToTexture && other.getPbufferRenderToTextureRectangle()==pbufferRenderToTextureRectangle; - if(sampleBuffers) { - res = res && - other.getNumSamples()==numSamples && + if(res && sampleBuffers) { + res = other.getNumSamples()==getNumSamples() && other.getSampleExtension().equals(sampleExtension) ; } return res; @@ -222,19 +222,24 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil public void setGLProfile(GLProfile profile) { glProfile=profile; } - + @Override public final boolean isPBuffer() { return isPBuffer; } /** - * Enables or disables pbuffer usage. + * Requesting offscreen pbuffer mode. *

    * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)}. *

    + *

    * Defaults to false. - */ + *

    + *

    + * Requesting offscreen pbuffer mode disables the offscreen auto selection. + *

    + */ public void setPBuffer(boolean enable) { if(enable) { setOnscreen(false); @@ -248,11 +253,16 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil } /** - * Enables or disables FBO usage. + * Requesting offscreen FBO mode. *

    * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)}. *

    + *

    * Defaults to false. + *

    + *

    + * Requesting offscreen FBO mode disables the offscreen auto selection. + *

    */ public void setFBO(boolean enable) { if(enable) { @@ -261,21 +271,6 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil isFBO = enable; } - /** - * Sets whether the drawable surface supports onscreen.
    - * If enabled this method also invokes {@link #setPBuffer(int) setPBuffer(false)} - * and {@link #setFBO(int) setFBO(false)}
    - * Defaults to true. - */ - @Override - public void setOnscreen(boolean onscreen) { - if(onscreen) { - setPBuffer(false); - setFBO(false); - } - super.setOnscreen(onscreen); - } - @Override public final boolean getDoubleBuffered() { return doubleBuffered; @@ -465,9 +460,9 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil sink = new StringBuilder(); } - int samples = sampleBuffers ? numSamples : 0 ; + final int samples = sampleBuffers ? numSamples : 0 ; - super.toString(sink); + super.toString(sink, false); sink.append(", accum-rgba ").append(accumRedBits).append("/").append(accumGreenBits).append("/").append(accumBlueBits).append("/").append(accumAlphaBits); sink.append(", dp/st/ms: ").append(depthBits).append("/").append(stencilBits).append("/").append(samples); @@ -490,20 +485,37 @@ public class GLCapabilities extends Capabilities implements Cloneable, GLCapabil sink.append(", sw, "); } sink.append(glProfile); - if(!isOnscreen()) { - if(isFBO) { - sink.append(", fbo"); - } - if(isPBuffer) { - sink.append(", pbuffer [r2t ").append(pbufferRenderToTexture?1:0) - .append(", r2tr ").append(pbufferRenderToTextureRectangle?1:0) - .append(", float ").append(pbufferFloatingPointBuffers?1:0) - .append("]"); - } - if(!isFBO && !isPBuffer) { - sink.append(", pixmap"); + if(isOnscreen()) { + sink.append(", on-scr["); + } else { + sink.append(", offscr["); + } + boolean ns=false; + if(isFBO()) { + sink.append("fbo"); + ns = true; + } + if(isPBuffer()) { + if(ns) { sink.append(", "); } + sink.append("pbuffer [r2t ").append(pbufferRenderToTexture?1:0) + .append(", r2tr ").append(pbufferRenderToTextureRectangle?1:0) + .append(", float ").append(pbufferFloatingPointBuffers?1:0) + .append("]"); + ns = true; + } + if(isBitmap()) { + if(ns) { sink.append(", "); } + sink.append("bitmap"); + ns = true; + } + if(!ns) { // !FBO !PBuffer !Bitmap + if(isOnscreen()) { + sink.append("."); // no additional off-screen modes besides on-screen + } else { + sink.append("auto-cfg"); // auto-config off-screen mode } } + sink.append("]"); return sink; } diff --git a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java index 7e0459b2d..ee261ca01 100644 --- a/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java +++ b/src/jogl/classes/javax/media/opengl/GLCapabilitiesImmutable.java @@ -50,7 +50,7 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { GLProfile getGLProfile(); /** - * Returns the number of bits requested for the accumulation + * Returns the number of bits for the accumulation * buffer's alpha component. On some systems only the accumulation * buffer depth, which is the sum of the red, green, and blue bits, * is considered. @@ -58,7 +58,7 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { int getAccumAlphaBits(); /** - * Returns the number of bits requested for the accumulation + * Returns the number of bits for the accumulation * buffer's blue component. On some systems only the accumulation * buffer depth, which is the sum of the red, green, and blue bits, * is considered. @@ -66,7 +66,7 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { int getAccumBlueBits(); /** - * Returns the number of bits requested for the accumulation + * Returns the number of bits for the accumulation * buffer's green component. On some systems only the accumulation * buffer depth, which is the sum of the red, green, and blue bits, * is considered. @@ -74,7 +74,7 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { int getAccumGreenBits(); /** - * Returns the number of bits requested for the accumulation + * Returns the number of bits for the accumulation * buffer's red component. On some systems only the accumulation * buffer depth, which is the sum of the red, green, and blue bits, * is considered. @@ -82,74 +82,115 @@ public interface GLCapabilitiesImmutable extends CapabilitiesImmutable { int getAccumRedBits(); /** - * Returns the number of bits requested for the depth buffer. + * Returns the number of depth buffer bits. */ int getDepthBits(); /** - * Indicates whether double-buffering is enabled. + * Returns whether double-buffering is requested, available or chosen. + *

    + * Default is true. + *

    */ boolean getDoubleBuffered(); /** - * Indicates whether hardware acceleration is enabled. + * Returns whether hardware acceleration is requested, available or chosen. + *

    + * Default is true. + *

    */ boolean getHardwareAccelerated(); /** - * Returns the used extension for full-scene antialiasing - * (FSAA), default is {@link #DEFAULT_SAMPLE_EXTENSION}. + * Returns the extension for full-scene antialiasing + * (FSAA). + *

    + * Default is {@link #DEFAULT_SAMPLE_EXTENSION}. + *

    */ String getSampleExtension(); /** * Returns whether sample buffers for full-scene antialiasing - * (FSAA) should be allocated for this drawable. Defaults to - * false. + * (FSAA) should be allocated for this drawable. + *

    + * Default is false. + *

    */ boolean getSampleBuffers(); /** * Returns the number of sample buffers to be allocated if sample - * buffers are enabled, otherwise returns 0. Defaults to 2. + * buffers are enabled, otherwise returns 0. + *

    + * Default is 0 due to disable sample buffers per default. + *

    */ int getNumSamples(); /** * For pbuffers only, returns whether floating-point buffers should - * be used if available. Defaults to false. + * be used if available. + *

    + * Default is false. + *

    */ boolean getPbufferFloatingPointBuffers(); /** * For pbuffers only, returns whether the render-to-texture - * extension should be used if available. Defaults to false. + * extension should be used if available. + *

    + * Default is false. + *

    */ boolean getPbufferRenderToTexture(); /** * For pbuffers only, returns whether the render-to-texture - * extension should be used. Defaults to false. + * extension should be used. + *

    + * Default is false. + *

    */ boolean getPbufferRenderToTextureRectangle(); /** - * Returns the number of bits requested for the stencil buffer. + * Returns the number of stencil buffer bits. + *

    + * Default is 0. + *

    */ int getStencilBits(); /** - * Indicates whether stereo is enabled. + * Returns whether stereo is requested, available or chosen. + *

    + * Default is false. + *

    */ boolean getStereo(); /** - * Indicates whether pbuffer offscreen is used/requested. + * Returns whether pbuffer offscreen mode is requested, available or chosen. + *

    + * Default is false. + *

    + *

    + * For chosen capabilities, only the selected offscreen surface is set to true. + *

    */ boolean isPBuffer(); /** - * Indicates whether FBO offscreen is used/requested. + * Returns whether FBO offscreen mode is requested, available or chosen. + *

    + * Default is false. + *

    + *

    + * For chosen capabilities, only the selected offscreen surface is set to true. + *

    */ boolean isFBO(); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 2f2bf5961..e1e253d35 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -271,7 +271,10 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { throw new GLException("No shared device for requested: "+deviceReq); } - if( capsRequested.isFBO() && GLContext.isFBOAvailable(device, capsRequested.getGLProfile()) ) { + final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, + GLContext.isFBOAvailable(device, capsRequested.getGLProfile()), + canCreateGLPbuffer(device)); + if( capsChosen.isFBO() ) { device.lock(); try { return createFBODrawableImpl(device, capsRequested, chooser, width, height); @@ -280,7 +283,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } } - final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, false, canCreateGLPbuffer(device)); device.lock(); try { return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, width, height, null) ); diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java index 3f38f33bc..d8e5ba31a 100644 --- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java +++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java @@ -28,7 +28,6 @@ package jogamp.opengl; -import java.util.List; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; @@ -74,56 +73,60 @@ public class GLGraphicsConfigurationUtil { } /** - * @param isFBO TODO - * @return bitmask representing the input boolean in exclusive or logic, ie only one bit will be set + public static final int getWinAttributeBits(boolean isOnscreen, boolean isFBO, boolean isPBuffer, boolean isBitmap) { + int winattrbits = 0; + if(isOnscreen) { + winattrbits |= WINDOW_BIT; + } + if(isFBO) { + winattrbits |= FBO_BIT; + } + if(isPBuffer ){ + winattrbits |= PBUFFER_BIT; + } + if(isBitmap) { + winattrbits |= BITMAP_BIT; + } + return winattrbits; + } + public static final int getWinAttributeBits(GLCapabilitiesImmutable caps) { + return getWinAttributeBits(caps.isOnscreen(), caps.isFBO(), caps.isPBuffer(), caps.isBitmap()); + } */ + + /** + * @return bitmask representing the input boolean in exclusive or logic, ie only one bit will be set. */ - public static final int getWinAttributeBits(boolean isOnscreen, boolean isPBuffer, boolean isFBO) { + public static final int getExclusiveWinAttributeBits(boolean isOnscreen, boolean isFBO, boolean isPBuffer, boolean isBitmap) { int winattrbits = 0; if(isOnscreen) { winattrbits |= WINDOW_BIT; - } else { - if(isFBO) { - winattrbits |= FBO_BIT; - } - if (!isPBuffer) { - winattrbits |= BITMAP_BIT; - } else { - winattrbits |= PBUFFER_BIT; - } + } else if(isFBO) { + winattrbits |= FBO_BIT; + } else if(isPBuffer ){ + winattrbits |= PBUFFER_BIT; + } else if(isBitmap) { + winattrbits |= BITMAP_BIT; + } + if(0 == winattrbits) { + throw new InternalError("Empty bitmask"); } return winattrbits; } /** - * @see #getWinAttributeBits(boolean, boolean, boolean) + * @see #getExclusiveWinAttributeBits(boolean, boolean, boolean, boolean) */ - public static final int getWinAttributeBits(GLCapabilitiesImmutable caps) { - return getWinAttributeBits(caps.isOnscreen(), caps.isPBuffer(), false); + public static final int getExclusiveWinAttributeBits(GLCapabilitiesImmutable caps) { + return getExclusiveWinAttributeBits(caps.isOnscreen(), caps.isFBO(), caps.isPBuffer(), caps.isBitmap()); } - public static final boolean addGLCapabilitiesPermutations(List capsBucket, GLCapabilitiesImmutable temp, int winattrbits) { - int preSize = capsBucket.size(); - if( 0 != ( WINDOW_BIT & winattrbits ) ) { - GLCapabilities cpy = (GLCapabilities) temp.cloneMutable(); - cpy.setOnscreen(true); - cpy.setPBuffer(false); - cpy.setFBO(false); - capsBucket.add(cpy); - } - if( 0 != ( PBUFFER_BIT & winattrbits ) || 0 != ( FBO_BIT & winattrbits ) ) { - GLCapabilities cpy = (GLCapabilities) temp.cloneMutable(); - cpy.setFBO(0 != ( FBO_BIT & winattrbits )); - cpy.setPBuffer(0 != ( PBUFFER_BIT & winattrbits )); - capsBucket.add(cpy); - } - if( 0 != ( BITMAP_BIT & winattrbits ) ) { - GLCapabilities cpy = (GLCapabilities) temp.cloneMutable(); - cpy.setOnscreen(false); - cpy.setPBuffer(false); - cpy.setFBO(false); - capsBucket.add(cpy); - } - return capsBucket.size() > preSize; + public static final GLCapabilities setWinAttributeBits(GLCapabilities caps, int winattrbits) { + caps.setBitmap ( 0 != ( BITMAP_BIT & winattrbits ) ); + caps.setPBuffer ( 0 != ( PBUFFER_BIT & winattrbits ) ); + caps.setFBO ( 0 != ( FBO_BIT & winattrbits ) ); + // we reflect availability semantics, hence setting onscreen at last (maybe overwritten above)! + caps.setOnscreen( 0 != ( WINDOW_BIT & winattrbits ) ); + return caps; } public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) @@ -131,33 +134,46 @@ public class GLGraphicsConfigurationUtil { if( !capsRequested.isOnscreen() ) { return fixOffscreenGLCapabilities(capsRequested, fboAvailable, pbufferAvailable); } - return fixOnscreenGLCapabilities(capsRequested); + return capsRequested; } public static GLCapabilitiesImmutable fixOnscreenGLCapabilities(GLCapabilitiesImmutable capsRequested) { if( !capsRequested.isOnscreen() ) { // fix caps .. - GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); + final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); + caps2.setBitmap (false); + caps2.setPBuffer (false); + caps2.setFBO (false); caps2.setOnscreen(true); return caps2; } return capsRequested; } - - public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) - { - if( capsRequested.getDoubleBuffered() || - capsRequested.isOnscreen() || - ( fboAvailable != capsRequested.isFBO() ) || - ( pbufferAvailable != capsRequested.isPBuffer() ) ) + + public static boolean isGLCapabilitiesOffscreenAutoSelection(GLCapabilitiesImmutable capsRequested) { + return !capsRequested.isOnscreen() && + !capsRequested.isFBO() && !capsRequested.isPBuffer() && !capsRequested.isBitmap() ; + } + + public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { + final boolean auto = !capsRequested.isFBO() && !capsRequested.isPBuffer() && !capsRequested.isBitmap() ; + + final boolean useFBO = fboAvailable && ( auto || capsRequested.isFBO() ) ; + final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || capsRequested.isPBuffer() ) ; + final boolean useBitmap = !usePbuffer && ( auto || capsRequested.isBitmap() ) ; + + if( capsRequested.isOnscreen() || + useFBO != capsRequested.isFBO() || + usePbuffer != capsRequested.isPBuffer() || + useBitmap != capsRequested.isBitmap() ) { // fix caps .. - GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); - caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN + final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setOnscreen(false); - caps2.setFBO( fboAvailable ); - caps2.setPBuffer( pbufferAvailable ); + caps2.setFBO( useFBO ); + caps2.setPBuffer( usePbuffer ); + caps2.setBitmap( useBitmap ); return caps2; } return capsRequested; @@ -165,31 +181,40 @@ public class GLGraphicsConfigurationUtil { public static GLCapabilitiesImmutable fixGLPBufferGLCapabilities(GLCapabilitiesImmutable capsRequested) { - if( capsRequested.getDoubleBuffered() || capsRequested.isOnscreen() || !capsRequested.isPBuffer() || capsRequested.isFBO() ) { + if( capsRequested.isOnscreen() || + !capsRequested.isPBuffer() || + capsRequested.isFBO() ) + { // fix caps .. - GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); - caps2.setDoubleBuffered(false); // FIXME DBLBUFOFFSCRN - we don't need to be single buffered .. + final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setOnscreen(false); - caps2.setPBuffer(true); caps2.setFBO(false); + caps2.setPBuffer(true); + caps2.setBitmap(false); return caps2; } return capsRequested; } /** Fix opaque setting while preserve alpha bits */ - public static GLCapabilitiesImmutable fixOpaqueGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean isOpaque) + public static GLCapabilities fixOpaqueGLCapabilities(GLCapabilities capsRequested, boolean isOpaque) { - GLCapabilities caps2 = null; - if( capsRequested.isBackgroundOpaque() != isOpaque) { final int alphaBits = capsRequested.getAlphaBits(); - caps2 = (GLCapabilities) capsRequested.cloneMutable(); - caps2.setBackgroundOpaque(isOpaque); - caps2.setAlphaBits(alphaBits); - return caps2; + capsRequested.setBackgroundOpaque(isOpaque); + capsRequested.setAlphaBits(alphaBits); } return capsRequested; } + /** Fix double buffered setting */ + public static GLCapabilitiesImmutable fixDoubleBufferedGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean doubleBuffered) + { + if( capsRequested.getDoubleBuffered() != doubleBuffered) { + final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); + caps2.setDoubleBuffered(doubleBuffered); + return caps2; + } + return capsRequested; + } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index a9e339bea..986b110be 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -290,9 +290,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(0 < numConfigs.get(0)) { final PointerBuffer configs = PointerBuffer.allocateDirect(numConfigs.get(0)); final IntBuffer attrs = Buffers.newDirectIntBuffer(EGLGraphicsConfiguration.GLCapabilities2AttribList(caps)); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(true, true, true); + final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(caps); if( EGL.eglChooseConfig(eglDisplay.getHandle(), attrs, configs, configs.capacity(), numConfigs) && numConfigs.get(0) > 0) { - return EGLGraphicsConfigurationFactory.eglConfigs2GLCaps(caps.getGLProfile(), eglDisplay.getHandle(), configs, numConfigs.get(0), winattrmask, false /* forceTransparentFlag */); + return EGLGraphicsConfigurationFactory.eglConfigs2GLCaps(eglDisplay, caps.getGLProfile(), configs, numConfigs.get(0), winattrmask, false /* forceTransparentFlag */); } } return new ArrayList(0); @@ -649,7 +649,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { - final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)); + final GLCapabilitiesImmutable chosenCaps = + GLGraphicsConfigurationUtil.fixDoubleBufferedGLCapabilities( + GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)), + false); return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); } private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java index 70a570174..e513a86cf 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java @@ -33,6 +33,8 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + public class EGLGLCapabilities extends GLCapabilities { private long eglcfg; @@ -45,13 +47,13 @@ public class EGLGLCapabilities extends GLCapabilities { * @param eglcfg * @param eglcfgid * @param visualID native visualID if valid, otherwise VisualIDHolder.VID_UNDEFINED - * @param glp desired GLProfile, or null if determined by renderableType + * @param glp desired GLProfile * @param renderableType actual EGL renderableType * * May throw GLException if given GLProfile is not compatible w/ renderableType */ public EGLGLCapabilities(long eglcfg, int eglcfgid, int visualID, GLProfile glp, int renderableType) { - super( ( null != glp ) ? glp : getCompatible(renderableType) ); + super( glp ); this.eglcfg = eglcfg; this.eglcfgid = eglcfgid; if(!isCompatible(glp, renderableType)) { @@ -111,15 +113,15 @@ public class EGLGLCapabilities extends GLCapabilities { return false; } - public static GLProfile getCompatible(int renderableType) { - if(0 != (renderableType & EGL.EGL_OPENGL_ES2_BIT) && GLProfile.isAvailable(GLProfile.GLES2)) { - return GLProfile.get(GLProfile.GLES2); + public static GLProfile getCompatible(EGLGraphicsDevice device, int renderableType) { + if(0 != (renderableType & EGL.EGL_OPENGL_ES2_BIT) && GLProfile.isAvailable(device, GLProfile.GLES2)) { + return GLProfile.get(device, GLProfile.GLES2); } - if(0 != (renderableType & EGL.EGL_OPENGL_ES_BIT) && GLProfile.isAvailable(GLProfile.GLES1)) { - return GLProfile.get(GLProfile.GLES1); + if(0 != (renderableType & EGL.EGL_OPENGL_ES_BIT) && GLProfile.isAvailable(device, GLProfile.GLES1)) { + return GLProfile.get(device, GLProfile.GLES1); } if(0 != (renderableType & EGL.EGL_OPENGL_BIT)) { - return GLProfile.getDefault(); + return GLProfile.getDefault(device); } return null; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 20102547d..135101ff2 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -37,8 +37,6 @@ package jogamp.opengl.egl; import java.nio.IntBuffer; -import java.util.ArrayList; -import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; @@ -48,6 +46,7 @@ import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -85,7 +84,8 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } final long cfg = EGLConfigId2EGLConfig(dpy, cfgID); if(0 < cfg) { - final EGLGLCapabilities caps = EGLConfig2Capabilities(capsRequested.getGLProfile(), dpy, cfg, false, capsRequested.isOnscreen(), capsRequested.isPBuffer(), false); + final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsRequested); + final EGLGLCapabilities caps = EGLConfig2Capabilities((EGLGraphicsDevice)absDevice, capsRequested.getGLProfile(), cfg, winattrmask, false); return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser()); } return null; @@ -129,9 +129,10 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple return configs.get(0); } - static int EGLConfigDrawableTypeBits(final long display, final long config) { + static int EGLConfigDrawableTypeBits(final EGLGraphicsDevice device, final GLProfile glp, final long config) { int val = 0; + final long display = device.getHandle(); int[] stype = new int[1]; if(! EGL.eglGetConfigAttrib(display, config, EGL.EGL_SURFACE_TYPE, stype, 0)) { throw new GLException("Could not determine EGL_SURFACE_TYPE"); @@ -146,32 +147,24 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple if ( 0 != ( stype[0] & EGL.EGL_PBUFFER_BIT ) ) { val |= GLGraphicsConfigurationUtil.PBUFFER_BIT; } + if ( GLContext.isFBOAvailable(device, glp) ) { + val |= GLGraphicsConfigurationUtil.FBO_BIT; + } return val; } - public static EGLGLCapabilities EGLConfig2Capabilities(GLProfile glp, long display, long config, - boolean relaxed, boolean onscreen, boolean usePBuffer, boolean forceTransparentFlag) { - List bucket = new ArrayList(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); - if( EGLConfig2Capabilities(bucket, glp, display, config, winattrmask, forceTransparentFlag) ) { - return (EGLGLCapabilities) bucket.get(0); - } else if ( relaxed && EGLConfig2Capabilities(bucket, glp, display, config, GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag) ) { - return (EGLGLCapabilities) bucket.get(0); - } - return null; - } - - public static boolean EGLConfig2Capabilities(List capsBucket, - GLProfile glp, long display, long config, - int winattrmask, boolean forceTransparentFlag) { - final int allDrawableTypeBits = EGLConfigDrawableTypeBits(display, config); - final int drawableTypeBits = winattrmask & allDrawableTypeBits; - - if( 0 == drawableTypeBits ) { - return false; - } - + /** + * @param device + * @param glp desired GLProfile, may be null + * @param config + * @param winattrmask + * @param forceTransparentFlag + * @return + */ + public static EGLGLCapabilities EGLConfig2Capabilities(EGLGraphicsDevice device, GLProfile glp, long config, + int winattrmask, boolean forceTransparentFlag) { + final long display = device.getHandle(); final IntBuffer val = Buffers.newDirectIntBuffer(1); final int cfgID; final int rType; @@ -183,7 +176,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple // FIXME: this happens on a ATI PC Emulation .. System.err.println("EGL couldn't retrieve ConfigID for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError())); } - return false; + return null; } cfgID = val.get(0); @@ -191,10 +184,10 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple if(DEBUG) { System.err.println("EGL couldn't retrieve EGL_RENDERABLE_TYPE for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError())); } - return false; + return null; } rType = val.get(0); - + if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_NATIVE_VISUAL_ID, val)) { visualID = val.get(0); } else { @@ -203,12 +196,15 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple EGLGLCapabilities caps = null; try { + if(null == glp) { + glp = EGLGLCapabilities.getCompatible(device, rType); + } caps = new EGLGLCapabilities(config, cfgID, visualID, glp, rType); } catch (GLException gle) { if(DEBUG) { System.err.println("config "+toHexString(config)+": "+gle); } - return false; + return null; } if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_CAVEAT, val)) { @@ -270,7 +266,17 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_DEPTH_SIZE, val)) { caps.setDepthBits(val.get(0)); } - return GLGraphicsConfigurationUtil.addGLCapabilitiesPermutations(capsBucket, caps, drawableTypeBits ); + + // Since the passed GLProfile may be null, + // we use EGL_RENDERABLE_TYPE derived profile as created in the EGLGLCapabilities constructor. + final int allDrawableTypeBits = EGLConfigDrawableTypeBits(device, caps.getGLProfile(), config); + final int drawableTypeBits = winattrmask & allDrawableTypeBits; + + if( 0 == drawableTypeBits ) { + return null; + } + + return (EGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(caps, drawableTypeBits); } public static int[] GLCapabilities2AttribList(GLCapabilitiesImmutable caps) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 72dea9ead..d08685dcb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -207,7 +207,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("Graphics configuration get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError())); } if (numConfigs.get(0) > 0) { - availableCaps = eglConfigs2GLCaps(null, eglDisplay, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, false); + availableCaps = eglConfigs2GLCaps(eglDevice, null, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, false); if( null != availableCaps && availableCaps.size() > 1) { Collections.sort(availableCaps, EglCfgIDComparator); } @@ -250,7 +250,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact final EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getEGLFactory(); capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(absDevice, glp), factory.canCreateGLPbuffer(absDevice) ); - EGLGraphicsConfiguration res = eglChooseConfig(eglDevice.getHandle(), capsChosen, capsReq, chooser, absScreen, nativeVisualID, forceTransparentFlag); + EGLGraphicsConfiguration res = eglChooseConfig(eglDevice, capsChosen, capsReq, chooser, absScreen, nativeVisualID, forceTransparentFlag); if(null==res) { if(DEBUG) { System.err.println("eglChooseConfig failed with given capabilities "+capsChosen); @@ -274,7 +274,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(DEBUG) { System.err.println("trying fixed caps (1): "+fixedCaps); } - res = eglChooseConfig(eglDevice.getHandle(), fixedCaps, capsReq, chooser, absScreen, nativeVisualID, false); + res = eglChooseConfig(eglDevice, fixedCaps, capsReq, chooser, absScreen, nativeVisualID, false); } if(null==res) { // @@ -292,7 +292,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(DEBUG) { System.err.println("trying fixed caps (2): "+fixedCaps); } - res = eglChooseConfig(eglDevice.getHandle(), fixedCaps, capsReq, chooser, absScreen, nativeVisualID, false); + res = eglChooseConfig(eglDevice, fixedCaps, capsReq, chooser, absScreen, nativeVisualID, false); } if(null==res) { // @@ -312,7 +312,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(DEBUG) { System.err.println("trying fixed caps (3): "+fixedCaps); } - res = eglChooseConfig(eglDevice.getHandle(), fixedCaps, capsReq, chooser, absScreen, nativeVisualID, false); + res = eglChooseConfig(eglDevice, fixedCaps, capsReq, chooser, absScreen, nativeVisualID, false); } if(null==res) { throw new GLException("Graphics configuration failed [direct caps, eglGetConfig/chooser and fixed-caps(1-3)]"); @@ -324,15 +324,14 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact return res; } - static EGLGraphicsConfiguration eglChooseConfig(long eglDisplay, + static EGLGraphicsConfiguration eglChooseConfig(EGLGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, AbstractGraphicsScreen absScreen, int nativeVisualID, boolean forceTransparentFlag) { + final long eglDisplay = device.getHandle(); final GLProfile glp = capsChosen.getGLProfile(); - final boolean onscreen = capsChosen.isOnscreen(); - final boolean usePBuffer = capsChosen.isPBuffer(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); + final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen); List availableCaps = null; int recommendedIndex = -1; long recommendedEGLConfig = -1; @@ -345,7 +344,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: Get maxConfigs (eglGetConfigs) no configs"); } if (DEBUG) { - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig eglDisplay "+toHexString(eglDisplay)+", nativeVisualID "+toHexString(nativeVisualID)+", onscreen "+onscreen+", usePBuffer "+usePBuffer+", "+capsChosen+", numConfigs "+numConfigs.get(0)); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig eglDisplay "+toHexString(eglDisplay)+", nativeVisualID "+toHexString(nativeVisualID)+", "+capsChosen+", numConfigs "+numConfigs.get(0)); } final IntBuffer attrs = Buffers.newDirectIntBuffer(EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen)); @@ -359,7 +358,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: false"); } } else if (numConfigs.get(0) > 0) { - availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); + availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); if(availableCaps.size() > 0) { recommendedEGLConfig = configs.get(0); recommendedIndex = 0; @@ -384,7 +383,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: #2 Get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError())); } if (numConfigs.get(0) > 0) { - availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); + availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); } } @@ -392,7 +391,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(DEBUG) { // FIXME: this happens on a ATI PC Emulation .. System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #2 Graphics configuration 1st choice and 2nd choice failed - no configs"); - availableCaps = eglConfigs2GLCaps(glp, eglDisplay, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag); + availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag); printCaps("AllCaps", availableCaps, System.err); } return null; @@ -439,12 +438,15 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact return new EGLGraphicsConfiguration(absScreen, chosenCaps, capsRequested, chooser); } - static List eglConfigs2GLCaps(GLProfile glp, long eglDisplay, PointerBuffer configs, int num, int winattrmask, boolean forceTransparentFlag) { - List caps = new ArrayList(num); + static List eglConfigs2GLCaps(EGLGraphicsDevice device, GLProfile glp, PointerBuffer configs, int num, int winattrmask, boolean forceTransparentFlag) { + List bucket = new ArrayList(num); for(int i=0; i caps, PrintStream out) { diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 82525cfde..55aea3a98 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -49,6 +49,7 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; @@ -495,8 +496,14 @@ public abstract class MacOSXCGLContext extends GLContextImpl CGL.setContextOpacity(ctx, 0); } - GLCapabilitiesImmutable fixedCaps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(chosenCaps.getGLProfile(), pixelFormat); + GLCapabilities fixedCaps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(chosenCaps.getGLProfile(), pixelFormat); fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); + if(!fixedCaps.isPBuffer()) { + // not handled, so copy them + fixedCaps.setFBO(chosenCaps.isFBO()); + fixedCaps.setBitmap(chosenCaps.isBitmap()); + fixedCaps.setOnscreen(chosenCaps.isOnscreen()); + } config.setChosenCapabilities(fixedCaps); if(DEBUG) { System.err.println("NS create fixedCaps: "+fixedCaps); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index 202644bb3..10e8193e2 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -176,7 +176,7 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration return CGL.createPixelFormat(cglInternalAttributeToken, off, len, ivalues, 0); } - static GLCapabilitiesImmutable NSPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) { + static GLCapabilities NSPixelFormat2GLCapabilities(GLProfile glp, long pixelFormat) { return PixelFormat2GLCapabilities(glp, pixelFormat, true); } @@ -233,11 +233,11 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration return fmt.get(0); } - static GLCapabilitiesImmutable CGLPixelFormat2GLCapabilities(long pixelFormat) { + static GLCapabilities CGLPixelFormat2GLCapabilities(long pixelFormat) { return PixelFormat2GLCapabilities(null, pixelFormat, false); } - private static GLCapabilitiesImmutable PixelFormat2GLCapabilities(GLProfile glp, long pixelFormat, boolean nsUsage) { + private static GLCapabilities PixelFormat2GLCapabilities(GLProfile glp, long pixelFormat, boolean nsUsage) { int len = cglInternalAttributeToken.length; int off = 0; if ( !MacOSXCGLContext.isLionOrLater ) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java index 175622343..75c1c4441 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java @@ -40,6 +40,7 @@ package jogamp.opengl.windows.wgl; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; @@ -52,6 +53,7 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.windows.GDI; import jogamp.opengl.GLDrawableImpl; +import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory.SharedResource; // import javax.media.opengl.GLPbuffer; @@ -127,13 +129,16 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { System.out.println("Pbuffer config: " + config); } + final int winattrPbuffer = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(false /* onscreen */, false /* fbo */, true /* pbuffer */, false /* bitmap */); + int[] iattributes = new int [2*WindowsWGLGraphicsConfiguration.MAX_ATTRIBS]; float[] fattributes = new float[1]; int[] floatModeTmp = new int[1]; int niattribs = 0; - GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); - GLProfile glProfile = chosenCaps.getGLProfile(); + final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); + final GLProfile glProfile = chosenCaps.getGLProfile(); + final AbstractGraphicsDevice device = config.getScreen().getDevice(); if (DEBUG) { System.out.println("Pbuffer parentHdc = " + toHexString(sharedHdc)); @@ -175,7 +180,8 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { if (DEBUG) { System.err.println("" + nformats + " suitable pixel formats found"); for (int i = 0; i < nformats; i++) { - WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, sharedHdc, pformats[i], glProfile, false, true); + WGLGLCapabilities dbgCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile, + sharedHdc, pformats[i], winattrPbuffer); System.err.println("pixel format " + pformats[i] + " (index " + i + "): " + dbgCaps); } } @@ -239,7 +245,8 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable { // Re-query chosen pixel format { - WGLGLCapabilities newCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, sharedHdc, pfdid, glProfile, false, true); + WGLGLCapabilities newCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile, + sharedHdc, pfdid, winattrPbuffer); if(null == newCaps) { throw new GLException("pbuffer creation error: unable to re-query chosen PFD ID: " + pfdid + ", hdc " + GLDrawableImpl.toHexString(tmpHdc)); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 209589b29..5b21353c3 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -42,6 +42,7 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLCapabilitiesChooser; +import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLPbuffer; @@ -104,9 +105,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio WGLGLCapabilities caps = null; if(hasARB) { - caps = wglARBPFID2GLCapabilities(sharedResource, hdc, pfdID, glp, onscreen, true /* pbuffer */); + caps = wglARBPFID2GLCapabilities(sharedResource, device, glp, hdc, pfdID, GLGraphicsConfigurationUtil.ALL_BITS); } else { - caps = PFD2GLCapabilities(glp, hdc, pfdID, onscreen); + caps = PFD2GLCapabilities(device, glp, hdc, pfdID, GLGraphicsConfigurationUtil.ALL_BITS); } if(null==caps) { throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+ @@ -304,8 +305,8 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } static WGLGLCapabilities wglARBPFID2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource, - long hdc, int pfdID, - GLProfile glp, boolean onscreen, boolean usePBuffer) { + AbstractGraphicsDevice device, GLProfile glp, + long hdc, int pfdID, int winattrbits) { if (!sharedResource.hasARBPixelFormat()) { return null; } @@ -319,17 +320,12 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID + " of device context " + toHexString(hdc) + ", werr " + GDI.GetLastError()); } - List bucket = new ArrayList(1); - final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); - if(AttribList2GLCapabilities(bucket, glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits)) { - return (WGLGLCapabilities) bucket.get(0); - } - return null; + return AttribList2GLCapabilities(device, glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits); } - static int[] wglChoosePixelFormatARB(long hdc, WindowsWGLDrawableFactory.SharedResource sharedResource, + static int[] wglChoosePixelFormatARB(WindowsWGLDrawableFactory.SharedResource sharedResource, AbstractGraphicsDevice device, GLCapabilitiesImmutable capabilities, - int[] iattributes, int accelerationMode, float[] fattributes) + long hdc, int[] iattributes, int accelerationMode, float[] fattributes) { if ( !WindowsWGLGraphicsConfiguration.GLCapabilities2AttribList(capabilities, @@ -366,27 +362,20 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio + Integer.toHexString(accelerationMode) + ": " + numFormats); for (int i = 0; i < numFormats; i++) { WGLGLCapabilities dbgCaps0 = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities( - sharedResource, hdc, pformats[i], - capabilities.getGLProfile(), capabilities.isOnscreen(), capabilities.isPBuffer()); + sharedResource, device, capabilities.getGLProfile(), hdc, pformats[i], GLGraphicsConfigurationUtil.ALL_BITS); System.err.println("pixel format " + pformats[i] + " (index " + i + "): " + dbgCaps0); } } return pformats; } - static List wglARBPFIDs2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource, - long hdc, int[] pfdIDs, GLProfile glp, boolean onscreen, boolean usePBuffer) { - final int winattrbits = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); - return wglARBPFIDs2GLCapabilitiesImpl(sharedResource, hdc, pfdIDs, glp, winattrbits); - } - static List wglARBPFIDs2AllGLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource, - long hdc, int[] pfdIDs, GLProfile glp) { - return wglARBPFIDs2GLCapabilitiesImpl(sharedResource, hdc, pfdIDs, glp, GLGraphicsConfigurationUtil.ALL_BITS); + AbstractGraphicsDevice device, GLProfile glp, long hdc, int[] pfdIDs) { + return wglARBPFIDs2GLCapabilities(sharedResource, device, glp, hdc, pfdIDs, GLGraphicsConfigurationUtil.ALL_BITS); } - private static List wglARBPFIDs2GLCapabilitiesImpl(WindowsWGLDrawableFactory.SharedResource sharedResource, - long hdc, int[] pfdIDs, GLProfile glp, int winattrbits) { + static List wglARBPFIDs2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource, + AbstractGraphicsDevice device, GLProfile glp, long hdc, int[] pfdIDs, int winattrbits) { if (!sharedResource.hasARBPixelFormat()) { return null; } @@ -401,7 +390,10 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio for(int i = 0; i= 1 && ((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, 0, iresults, 0) ) { - AttribList2GLCapabilities(bucket, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits); + final GLCapabilitiesImmutable caps = AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits); + if(null != caps) { + bucket.add(caps); + } } else if (DEBUG) { System.err.println("wglARBPFIDs2GLCapabilities: Cannot get pixel format attributes for pixel format " + i + "/" + numFormats + ": " + pfdIDs[i] + ", " + @@ -582,7 +574,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return true; } - static int AttribList2DrawableTypeBits(final int[] iattribs, final int niattribs, final int[] iresults) { + static int AttribList2DrawableTypeBits(AbstractGraphicsDevice device, GLProfile glp, final int[] iattribs, final int niattribs, final int[] iresults) { int val = 0; for (int i = 0; i < niattribs; i++) { @@ -599,18 +591,20 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio break; } } + if ( GLContext.isFBOAvailable(device, glp) ) { + val |= GLGraphicsConfigurationUtil.FBO_BIT; + } return val; } - static boolean AttribList2GLCapabilities( List capsBucket, - final GLProfile glp, final long hdc, final int pfdID, final int[] iattribs, - final int niattribs, - final int[] iresults, final int winattrmask) { - final int allDrawableTypeBits = AttribList2DrawableTypeBits(iattribs, niattribs, iresults); + static WGLGLCapabilities AttribList2GLCapabilities(final AbstractGraphicsDevice device, + final GLProfile glp, final long hdc, final int pfdID, + final int[] iattribs, final int niattribs, final int[] iresults, final int winattrmask) { + final int allDrawableTypeBits = AttribList2DrawableTypeBits(device, glp, iattribs, niattribs, iresults); int drawableTypeBits = winattrmask & allDrawableTypeBits; if( 0 == drawableTypeBits ) { - return false; + return null; } PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(); @@ -618,14 +612,13 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio // remove displayable bits, since pfdID is non displayable drawableTypeBits = drawableTypeBits & ~(GLGraphicsConfigurationUtil.WINDOW_BIT | GLGraphicsConfigurationUtil.BITMAP_BIT); if( 0 == drawableTypeBits ) { - return false; + return null; } // non displayable requested (pbuffer) } - WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); + final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByARB(iattribs, niattribs, iresults); - - return GLGraphicsConfigurationUtil.addGLCapabilitiesPermutations(capsBucket, res, drawableTypeBits ); + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits); } // @@ -645,7 +638,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return pfdIDs; } - static int PFD2DrawableTypeBits(PIXELFORMATDESCRIPTOR pfd) { + static int PFD2DrawableTypeBits(AbstractGraphicsDevice device, GLProfile glp, PIXELFORMATDESCRIPTOR pfd) { int val = 0; int dwFlags = pfd.getDwFlags(); @@ -656,37 +649,30 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio if( 0 != (GDI.PFD_DRAW_TO_BITMAP & dwFlags ) ) { val |= GLGraphicsConfigurationUtil.BITMAP_BIT; } + if ( GLContext.isFBOAvailable(device, glp) ) { + val |= GLGraphicsConfigurationUtil.FBO_BIT; + } return val; } - static WGLGLCapabilities PFD2GLCapabilities(GLProfile glp, long hdc, int pfdID, boolean onscreen) { - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false, false); - List capsBucket = new ArrayList(1); - if( PFD2GLCapabilities(capsBucket, glp, hdc, pfdID, winattrmask) ) { - return (WGLGLCapabilities) capsBucket.get(0); - } - return null; - } - - static boolean PFD2GLCapabilities(List capsBucket, final GLProfile glp, final long hdc, final int pfdID, final int winattrmask) { + static WGLGLCapabilities PFD2GLCapabilities(AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int pfdID, final int winattrmask) { PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(hdc, pfdID); if(null == pfd) { - return false; + return null; } if ((pfd.getDwFlags() & GDI.PFD_SUPPORT_OPENGL) == 0) { - return false; + return null; } - final int allDrawableTypeBits = PFD2DrawableTypeBits(pfd); + final int allDrawableTypeBits = PFD2DrawableTypeBits(device, glp, pfd); final int drawableTypeBits = winattrmask & allDrawableTypeBits; if( 0 == drawableTypeBits ) { - return false; + return null; } - WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); + final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByGDI(); - - return GLGraphicsConfigurationUtil.addGLCapabilitiesPermutations(capsBucket, res, drawableTypeBits ); + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits ); } static PIXELFORMATDESCRIPTOR GLCapabilities2PFD(GLCapabilitiesImmutable caps, PIXELFORMATDESCRIPTOR pfd) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 00ed91bb4..66a5821d3 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -131,10 +131,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat throw new GLException("Error: HDC is null"); } if (sharedResource.hasARBPixelFormat()) { - availableCaps = getAvailableGLCapabilitiesARB(hdc, sharedResource, capsChosen.getGLProfile()); + availableCaps = WindowsWGLGraphicsConfigurationFactory.getAvailableGLCapabilitiesARB(sharedResource, sharedResource.getDevice(), capsChosen.getGLProfile(), hdc); } if( null == availableCaps || availableCaps.isEmpty() ) { - availableCaps = getAvailableGLCapabilitiesGDI(hdc, capsChosen.getGLProfile()); + availableCaps = getAvailableGLCapabilitiesGDI(device, capsChosen.getGLProfile(), hdc); } } finally { if ( sharedResource.needsCurrentContext4ARBPFDQueries() ) { @@ -150,17 +150,20 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat return availableCaps; } - static List getAvailableGLCapabilitiesARB(long hdc, WindowsWGLDrawableFactory.SharedResource sharedResource, GLProfile glProfile) { + static List getAvailableGLCapabilitiesARB(WindowsWGLDrawableFactory.SharedResource sharedResource, AbstractGraphicsDevice device, GLProfile glProfile, long hdc) { int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFIDs((WindowsWGLContext)sharedResource.getContext(), hdc); - return WindowsWGLGraphicsConfiguration.wglARBPFIDs2AllGLCapabilities(sharedResource, hdc, pformats, glProfile); + return WindowsWGLGraphicsConfiguration.wglARBPFIDs2AllGLCapabilities(sharedResource, device, glProfile, hdc, pformats); } - static List getAvailableGLCapabilitiesGDI(long hdc, GLProfile glProfile) { + static List getAvailableGLCapabilitiesGDI(AbstractGraphicsDevice device, GLProfile glProfile, long hdc) { int[] pformats = WindowsWGLGraphicsConfiguration.wglAllGDIPFIDs(hdc); int numFormats = pformats.length; List bucket = new ArrayList(numFormats); for (int i = 0; i < numFormats; i++) { - WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(bucket, glProfile, hdc, pformats[i], GLGraphicsConfigurationUtil.ALL_BITS); + final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pformats[i], GLGraphicsConfigurationUtil.ALL_BITS); + if(null != caps) { + bucket.add(caps); + } } return bucket; } @@ -274,8 +277,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } } try { - if( !updateGraphicsConfigurationARB(hdc, extHDC, config, chooser, (WindowsWGLDrawableFactory)factory, pfdIDs) ) { - updateGraphicsConfigurationGDI(hdc, extHDC, config, chooser, pfdIDs); + if( !updateGraphicsConfigurationARB((WindowsWGLDrawableFactory)factory, config, chooser, hdc, extHDC, pfdIDs) ) { + updateGraphicsConfigurationGDI(config, chooser, hdc, extHDC, pfdIDs); } } finally { if (null != sharedContext) { @@ -284,10 +287,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } } - private static boolean updateGraphicsConfigurationARB(long hdc, boolean extHDC, WindowsWGLGraphicsConfiguration config, - CapabilitiesChooser chooser, WindowsWGLDrawableFactory factory, int[] pformats) { - AbstractGraphicsDevice device = config.getScreen().getDevice(); - WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device); + private static boolean updateGraphicsConfigurationARB(WindowsWGLDrawableFactory factory, WindowsWGLGraphicsConfiguration config, CapabilitiesChooser chooser, + long hdc, boolean extHDC, int[] pformats) { + final AbstractGraphicsDevice device = config.getScreen().getDevice(); + final WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device); if (null == sharedResource) { if (DEBUG) { @@ -302,11 +305,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat return false; } - GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - boolean isOpaque = capsChosen.isBackgroundOpaque() && GDI.DwmIsCompositionEnabled(); - boolean onscreen = capsChosen.isOnscreen(); - boolean usePBuffer = capsChosen.isPBuffer(); - GLProfile glProfile = capsChosen.getGLProfile(); + final GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final boolean isOpaque = capsChosen.isBackgroundOpaque() && GDI.DwmIsCompositionEnabled(); + final int winattrbits = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen); + final GLProfile glProfile = capsChosen.getGLProfile(); if(DEBUG) { System.err.println("translucency requested: "+(!capsChosen.isBackgroundOpaque())+", compositioning enabled: "+GDI.DwmIsCompositionEnabled()+" -> translucency "+(!isOpaque)); @@ -325,7 +327,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat + ", pixelformat " + presetPFDID); } pixelFormatSet = true; - pixelFormatCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, hdc, presetPFDID, glProfile, onscreen, usePBuffer); + pixelFormatCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, device, glProfile, hdc, presetPFDID, winattrbits); pixelFormatCaps = (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(pixelFormatCaps, isOpaque); } else { int recommendedIndex = -1; // recommended index @@ -337,17 +339,17 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat int[] iattributes = new int[2 * WindowsWGLGraphicsConfiguration.MAX_ATTRIBS]; float[] fattributes = new float[1]; int accelerationMode = WGLExt.WGL_FULL_ACCELERATION_ARB; - pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(hdc, sharedResource, capsChosen, - iattributes, accelerationMode, fattributes); + pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(sharedResource, device, capsChosen, + hdc, iattributes, accelerationMode, fattributes); if (null == pformats) { accelerationMode = WGLExt.WGL_GENERIC_ACCELERATION_ARB; - pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(hdc, sharedResource, capsChosen, - iattributes, accelerationMode, fattributes); + pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(sharedResource, device, capsChosen, + hdc, iattributes, accelerationMode, fattributes); } if (null == pformats) { accelerationMode = -1; // use what we are offered .. - pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(hdc, sharedResource, capsChosen, - iattributes, accelerationMode, fattributes); + pformats = WindowsWGLGraphicsConfiguration.wglChoosePixelFormatARB(sharedResource, device, capsChosen, + hdc, iattributes, accelerationMode, fattributes); } if (null != pformats) { recommendedIndex = 0; @@ -371,13 +373,13 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } } - List availableCaps = - WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, hdc, pformats, - glProfile, onscreen, usePBuffer); + List availableCaps = + WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, winattrbits); + if( null == availableCaps || 0 == availableCaps.size() ) { if (DEBUG) { System.err.println("updateGraphicsConfigurationARB: wglARBPFIDs2GLCapabilities failed with " + pformats.length + - " pfd ids, onscreen " + onscreen + ", pbuffer " + usePBuffer); + " pfd ids, " + GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString()); Thread.dumpStack(); } return false; @@ -385,7 +387,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if (DEBUG) { System.err.println("updateGraphicsConfigurationARB: " + pformats.length + - " pfd ids, onscreen " + onscreen + ", pbuffer " + usePBuffer + ", " + availableCaps.size() + " glcaps"); + " pfd ids, " + GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString() + ", " + availableCaps.size() + " glcaps"); if(0 <= recommendedIndex) { System.err.println("updateGraphicsConfigurationARB: Used wglChoosePixelFormatARB to recommend pixel format " + pformats[recommendedIndex] + ", idx " + recommendedIndex +", "+availableCaps.get(recommendedIndex)); @@ -420,8 +422,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat return true; } - private static boolean updateGraphicsConfigurationGDI(long hdc, boolean extHDC, WindowsWGLGraphicsConfiguration config, - CapabilitiesChooser chooser, int[] pformats) { + private static boolean updateGraphicsConfigurationGDI(WindowsWGLGraphicsConfiguration config, CapabilitiesChooser chooser, long hdc, + boolean extHDC, int[] pformats) { GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); if(capsChosen.isPBuffer()) { if (DEBUG) { @@ -429,9 +431,11 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } return false; } - boolean onscreen = capsChosen.isOnscreen(); - GLProfile glProfile = capsChosen.getGLProfile(); - + // final boolean onscreen = capsChosen.isOnscreen(); + // final boolean useFBO = capsChosen.isFBO(); + final GLProfile glProfile = capsChosen.getGLProfile(); + final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen); + List availableCaps = new ArrayList(); int pfdID; // chosen or preset PFD ID WGLGLCapabilities pixelFormatCaps = null; // chosen or preset PFD ID's caps @@ -447,15 +451,17 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat + ", pixelformat " + pfdID); } pixelFormatSet = true; - pixelFormatCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, hdc, pfdID, onscreen); + pixelFormatCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(config.getScreen().getDevice(), glProfile, hdc, pfdID, winattrmask); } else { if(null == pformats) { pformats = WindowsWGLGraphicsConfiguration.wglAllGDIPFIDs(hdc); } - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, false, false); for (int i = 0; i < pformats.length; i++) { - WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(availableCaps, glProfile, hdc, pformats[i], winattrmask); + final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(config.getScreen().getDevice(), glProfile, hdc, pformats[i], winattrmask); + if(null != caps) { + availableCaps.add(caps); + } } // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java index b458fffe1..d169945fe 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java @@ -33,10 +33,6 @@ package jogamp.opengl.x11.glx; -import java.util.ArrayList; -import java.util.List; - -import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.VisualIDHolder; @@ -58,6 +54,7 @@ import jogamp.opengl.GLGraphicsConfigurationUtil; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.nativewindow.x11.X11GraphicsConfiguration; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implements Cloneable { @@ -71,7 +68,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem } static X11GLXGraphicsConfiguration create(GLProfile glp, X11GraphicsScreen x11Screen, int fbcfgID) { - final AbstractGraphicsDevice device = x11Screen.getDevice(); + final X11GraphicsDevice device = (X11GraphicsDevice) x11Screen.getDevice(); final long display = device.getHandle(); if(0==display) { throw new GLException("Display null of "+x11Screen); @@ -85,7 +82,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem glp = GLProfile.getDefault(x11Screen.getDevice()); } final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - final X11GLCapabilities caps = GLXFBConfig2GLCapabilities(glp, device, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(device)); + final X11GLCapabilities caps = GLXFBConfig2GLCapabilities(device, glp, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, factory.isGLXMultisampleAvailable(device)); if(null==caps) { throw new GLException("GLCapabilities null of "+toHexString(fbcfg)); } @@ -247,7 +244,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return true; } - static int FBCfgDrawableTypeBits(final AbstractGraphicsDevice device, GLProfile glp, final long fbcfg) { + static int FBCfgDrawableTypeBits(final X11GraphicsDevice device, GLProfile glp, final long fbcfg) { int val = 0; int[] tmp = new int[1]; @@ -268,19 +265,6 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return val; } - static X11GLCapabilities GLXFBConfig2GLCapabilities(GLProfile glp, AbstractGraphicsDevice device, long fbcfg, - boolean relaxed, boolean onscreen, boolean usePBuffer, - boolean isMultisampleAvailable) { - ArrayList bucket = new ArrayList(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, false); - if( GLXFBConfig2GLCapabilities(bucket, glp, device, fbcfg, winattrmask, isMultisampleAvailable) ) { - return (X11GLCapabilities) bucket.get(0); - } else if ( relaxed && GLXFBConfig2GLCapabilities(bucket, glp, device, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { - return (X11GLCapabilities) bucket.get(0); - } - return null; - } - static XRenderDirectFormat XVisual2XRenderMask(long dpy, long visual) { XRenderPictFormat renderPictFmt = X11Lib.XRenderFindVisualFormat(dpy, visual); if(null == renderPictFmt) { @@ -289,9 +273,8 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return renderPictFmt.getDirect(); } - static boolean GLXFBConfig2GLCapabilities(List capsBucket, - GLProfile glp, AbstractGraphicsDevice device, long fbcfg, - int winattrmask, boolean isMultisampleAvailable) { + static X11GLCapabilities GLXFBConfig2GLCapabilities(X11GraphicsDevice device, GLProfile glp, long fbcfg, + int winattrmask, boolean isMultisampleAvailable) { final int allDrawableTypeBits = FBCfgDrawableTypeBits(device, glp, fbcfg); int drawableTypeBits = winattrmask & allDrawableTypeBits; @@ -307,18 +290,18 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem } if( 0 == drawableTypeBits ) { - return false; + return null; } int[] tmp = new int[1]; if(GLX.GLX_BAD_ATTRIBUTE == GLX.glXGetFBConfigAttrib(display, fbcfg, GLX.GLX_RENDER_TYPE, tmp, 0)) { - return false; + return null; } if( 0 == ( GLX.GLX_RGBA_BIT & tmp[0] ) ) { - return false; // no RGBA -> color index not supported + return null; // no RGBA -> color index not supported } - GLCapabilities res = new X11GLCapabilities(visualInfo, fbcfg, fbcfgid, glp); + X11GLCapabilities res = new X11GLCapabilities(visualInfo, fbcfg, fbcfgid, glp); if (isMultisampleAvailable) { res.setSampleBuffers(glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLE_BUFFERS, tmp, 0) != 0); res.setNumSamples (glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLES, tmp, 0)); @@ -353,7 +336,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setPbufferFloatingPointBuffers(glXGetFBConfig(display, fbcfg, GLXExt.GLX_FLOAT_COMPONENTS_NV, tmp, 0) != GL.GL_FALSE); } catch (Exception e) {} - return GLGraphicsConfigurationUtil.addGLCapabilitiesPermutations(capsBucket, res, drawableTypeBits ); + return (X11GLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits); } private static String glXGetFBConfigErrorCode(int err) { @@ -408,30 +391,34 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return res; } - static boolean XVisualInfo2GLCapabilities(List capsBucket, - GLProfile glp, long display, XVisualInfo info, - final int winattrmask, boolean isMultisampleEnabled) { - final int allDrawableTypeBits = GLGraphicsConfigurationUtil.WINDOW_BIT | GLGraphicsConfigurationUtil.BITMAP_BIT ; + static X11GLCapabilities XVisualInfo2GLCapabilities(final X11GraphicsDevice device, GLProfile glp, XVisualInfo info, + final int winattrmask, boolean isMultisampleEnabled) { + final int allDrawableTypeBits = GLGraphicsConfigurationUtil.WINDOW_BIT | + GLGraphicsConfigurationUtil.BITMAP_BIT | + ( GLContext.isFBOAvailable(device, glp) ? GLGraphicsConfigurationUtil.FBO_BIT : 0 ) + ; + final int drawableTypeBits = winattrmask & allDrawableTypeBits; if( 0 == drawableTypeBits ) { - return false; + return null; } + final long display = device.getHandle(); int[] tmp = new int[1]; int val = glXGetConfig(display, info, GLX.GLX_USE_GL, tmp, 0); if (val == 0) { if(DEBUG) { System.err.println("Visual ("+toHexString(info.getVisualid())+") does not support OpenGL"); } - return false; + return null; } val = glXGetConfig(display, info, GLX.GLX_RGBA, tmp, 0); if (val == 0) { if(DEBUG) { System.err.println("Visual ("+toHexString(info.getVisualid())+") does not support RGBA"); } - return false; + return null; } GLCapabilities res = new X11GLCapabilities(info, glp); @@ -470,7 +457,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setAccumBlueBits (glXGetConfig(display, info, GLX.GLX_ACCUM_BLUE_SIZE, tmp, 0)); res.setAccumAlphaBits(glXGetConfig(display, info, GLX.GLX_ACCUM_ALPHA_SIZE, tmp, 0)); - return GLGraphicsConfigurationUtil.addGLCapabilitiesPermutations(capsBucket, res, drawableTypeBits); + return (X11GLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits); } private static String glXGetConfigErrorCode(int err) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index 234b06bdb..3189f933f 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -152,12 +152,12 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF // Utilizing FBConfig // - AbstractGraphicsDevice absDevice = x11Screen.getDevice(); - long display = absDevice.getHandle(); + final X11GraphicsDevice absDevice = (X11GraphicsDevice) x11Screen.getDevice(); + final long display = absDevice.getHandle(); - int screen = x11Screen.getIndex(); - int[] count = { -1 }; - ArrayList availableCaps = new ArrayList(); + final int screen = x11Screen.getIndex(); + final int[] count = { -1 }; + final ArrayList availableCaps = new ArrayList(); fbcfgsL = GLX.glXChooseFBConfig(display, screen, null, 0, count, 0); if (fbcfgsL == null || fbcfgsL.limit()<=0) { @@ -167,18 +167,19 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF return null; } for (int i = 0; i < fbcfgsL.limit(); i++) { - if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { - if(DEBUG) { - System.err.println("X11GLXGraphicsConfiguration.getAvailableGLCapabilitiesFBConfig: FBConfig invalid (2): ("+x11Screen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); - } + final GLCapabilitiesImmutable caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(absDevice, glProfile, fbcfgsL.get(i), GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable); + if(null != caps) { + availableCaps.add(caps); + } else if(DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.getAvailableGLCapabilitiesFBConfig: FBConfig invalid (2): ("+x11Screen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); } } return availableCaps; } static List getAvailableGLCapabilitiesXVisual(X11GraphicsScreen x11Screen, GLProfile glProfile, boolean isMultisampleAvailable) { - AbstractGraphicsDevice absDevice = x11Screen.getDevice(); - long display = absDevice.getHandle(); + final X11GraphicsDevice absDevice = (X11GraphicsDevice) x11Screen.getDevice(); + final long display = absDevice.getHandle(); int screen = x11Screen.getIndex(); @@ -191,10 +192,11 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } ArrayList availableCaps = new ArrayList(); for (int i = 0; i < infos.length; i++) { - if( !X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(availableCaps, glProfile, display, infos[i], GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable) ) { - if(DEBUG) { - System.err.println("X11GLXGraphicsConfiguration.getAvailableGLCapabilitiesXVisual: XVisual invalid: ("+x11Screen+"): fbcfg: "+toHexString(infos[i].getVisualid())); - } + final GLCapabilitiesImmutable caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(absDevice, glProfile, infos[i], GLGraphicsConfigurationUtil.ALL_BITS, isMultisampleAvailable); + if(null != caps) { + availableCaps.add(caps); + } if(DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.getAvailableGLCapabilitiesXVisual: XVisual invalid: ("+x11Screen+"): fbcfg: "+toHexString(infos[i].getVisualid())); } } return availableCaps; @@ -238,8 +240,8 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } static X11GLXGraphicsConfiguration fetchGraphicsConfigurationFBConfig(X11GraphicsScreen x11Screen, int fbID, GLProfile glp) { - final AbstractGraphicsDevice absDevice = x11Screen.getDevice(); - final long display = absDevice.getHandle(); + final X11GraphicsDevice x11Device = (X11GraphicsDevice) x11Screen.getDevice(); + final long display = x11Device.getHandle(); final int screen = x11Screen.getIndex(); final long fbcfg = X11GLXGraphicsConfiguration.glXFBConfigID2FBConfig(display, screen, fbID); @@ -251,7 +253,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - final X11GLCapabilities caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(glp, absDevice, fbcfg, true, true, true, factory.isGLXMultisampleAvailable(absDevice)); + final X11GLCapabilities caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(x11Device, glp, fbcfg, GLGraphicsConfigurationUtil.ALL_BITS, factory.isGLXMultisampleAvailable(x11Device)); return new X11GLXGraphicsConfiguration(x11Screen, caps, caps, new DefaultGLCapabilitiesChooser()); } @@ -262,22 +264,19 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF int recommendedIndex = -1; PointerBuffer fbcfgsL = null; GLProfile glProfile = capsChosen.getGLProfile(); - boolean onscreen = capsChosen.isOnscreen(); - boolean usePBuffer = capsChosen.isPBuffer(); - boolean useFBO = capsChosen.isFBO(); // Utilizing FBConfig // - AbstractGraphicsDevice absDevice = x11Screen.getDevice(); - long display = absDevice.getHandle(); + X11GraphicsDevice x11Device = (X11GraphicsDevice) x11Screen.getDevice(); + long display = x11Device.getHandle(); int screen = x11Screen.getIndex(); final X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(absDevice); + final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(x11Device); int[] attribs = X11GLXGraphicsConfiguration.GLCapabilities2AttribList(capsChosen, true, isMultisampleAvailable, display, screen); int[] count = { -1 }; List availableCaps = new ArrayList(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(onscreen, usePBuffer, useFBO); + final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen); // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice, // skipped if xvisualID is given if( VisualIDHolder.VID_UNDEFINED == xvisualID ) { @@ -285,10 +284,11 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } if (fbcfgsL != null && fbcfgsL.limit()>0) { for (int i = 0; i < fbcfgsL.limit(); i++) { - if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { - if(DEBUG) { - System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid (1): ("+x11Screen+","+capsChosen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); - } + final GLCapabilitiesImmutable caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(x11Device, glProfile, fbcfgsL.get(i), winattrmask, isMultisampleAvailable); + if( null != caps ) { + availableCaps.add(caps); + } else if(DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid (1): ("+x11Screen+","+capsChosen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); } } if(availableCaps.size() > 0) { @@ -318,10 +318,11 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } for (int i = 0; i < fbcfgsL.limit(); i++) { - if( !X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(availableCaps, glProfile, absDevice, fbcfgsL.get(i), winattrmask, isMultisampleAvailable) ) { - if(DEBUG) { - System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid (2): ("+x11Screen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); - } + final GLCapabilitiesImmutable caps = X11GLXGraphicsConfiguration.GLXFBConfig2GLCapabilities(x11Device, glProfile, fbcfgsL.get(i), winattrmask, isMultisampleAvailable); + if( null != caps ) { + availableCaps.add(caps); + } else if(DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationFBConfig: FBConfig invalid (2): ("+x11Screen+"): fbcfg: "+toHexString(fbcfgsL.get(i))); } } } @@ -374,11 +375,11 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } GLProfile glProfile = capsChosen.getGLProfile(); - final int winattrmask = GLGraphicsConfigurationUtil.getWinAttributeBits(capsChosen.isOnscreen(), false /* pbuffer */, false); + final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsChosen.isOnscreen(), capsChosen.isFBO(), false /* pbuffer */, capsChosen.isBitmap()); List availableCaps = new ArrayList(); int recommendedIndex = -1; - AbstractGraphicsDevice absDevice = x11Screen.getDevice(); + X11GraphicsDevice absDevice = (X11GraphicsDevice) x11Screen.getDevice(); long display = absDevice.getHandle(); int screen = x11Screen.getIndex(); @@ -411,15 +412,15 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } for (int i = 0; i < infos.length; i++) { - if( !X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(availableCaps, glProfile, display, infos[i], winattrmask, isMultisampleAvailable) ) { - if(DEBUG) { - System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual: XVisual invalid: ("+x11Screen+"): fbcfg: "+toHexString(infos[i].getVisualid())); - } - } else { + final GLCapabilitiesImmutable caps = X11GLXGraphicsConfiguration.XVisualInfo2GLCapabilities(absDevice, glProfile, infos[i], winattrmask, isMultisampleAvailable); + if( null != caps ) { + availableCaps.add(caps); // Attempt to find the visual chosenIndex by glXChooseVisual, if not translucent if (capsChosen.isBackgroundOpaque() && recommendedVis != null && recommendedVis.getVisualid() == infos[i].getVisualid()) { recommendedIndex = availableCaps.size() - 1; } + } else if(DEBUG) { + System.err.println("X11GLXGraphicsConfiguration.chooseGraphicsConfigurationXVisual: XVisual invalid: ("+x11Screen+"): fbcfg: "+toHexString(infos[i].getVisualid())); } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java index cb33aec5e..50e6ed46c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java +++ b/src/nativewindow/classes/javax/media/nativewindow/Capabilities.java @@ -61,6 +61,9 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { // Switch for on- or offscreen private boolean onscreen = true; + + // offscreen bitmap mode + private boolean isBitmap = false; /** Creates a Capabilities object. All attributes are in a default state. @@ -85,6 +88,8 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { public int hashCode() { // 31 * x == (x << 5) - x int hash = 31 + this.redBits; + hash = ((hash << 5) - hash) + ( this.onscreen ? 1 : 0 ); + hash = ((hash << 5) - hash) + ( this.isBitmap ? 1 : 0 ); hash = ((hash << 5) - hash) + this.greenBits; hash = ((hash << 5) - hash) + this.blueBits; hash = ((hash << 5) - hash) + this.alphaBits; @@ -93,7 +98,6 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { hash = ((hash << 5) - hash) + this.transparentValueGreen; hash = ((hash << 5) - hash) + this.transparentValueBlue; hash = ((hash << 5) - hash) + this.transparentValueAlpha; - hash = ((hash << 5) - hash) + ( this.onscreen ? 1 : 0 ); return hash; } @@ -109,12 +113,13 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { other.getBlueBits()==blueBits && other.getAlphaBits()==alphaBits && other.isBackgroundOpaque()==backgroundOpaque && - other.isOnscreen()==onscreen; - if(!backgroundOpaque) { - res = res && other.getTransparentRedValue()==transparentValueRed && - other.getTransparentGreenValue()==transparentValueGreen && - other.getTransparentBlueValue()==transparentValueBlue && - other.getTransparentAlphaValue()==transparentValueAlpha; + other.isOnscreen()==onscreen && + other.isBitmap()==isBitmap; + if(res && !backgroundOpaque) { + res = other.getTransparentRedValue()==transparentValueRed && + other.getTransparentGreenValue()==transparentValueGreen && + other.getTransparentBlueValue()==transparentValueBlue && + other.getTransparentAlphaValue()==transparentValueAlpha; } return res; @@ -158,9 +163,6 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } } - /** Returns the number of bits requested for the color buffer's red - component. On some systems only the color depth, which is the - sum of the red, green, and blue bits, is considered. */ @Override public final int getRedBits() { return redBits; @@ -173,9 +175,6 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { this.redBits = redBits; } - /** Returns the number of bits requested for the color buffer's - green component. On some systems only the color depth, which is - the sum of the red, green, and blue bits, is considered. */ @Override public final int getGreenBits() { return greenBits; @@ -188,9 +187,6 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { this.greenBits = greenBits; } - /** Returns the number of bits requested for the color buffer's blue - component. On some systems only the color depth, which is the - sum of the red, green, and blue bits, is considered. */ @Override public final int getBlueBits() { return blueBits; @@ -203,9 +199,6 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { this.blueBits = blueBits; } - /** Returns the number of bits requested for the color buffer's - alpha component. On some systems only the color depth, which is - the sum of the red, green, and blue bits, is considered. */ @Override public final int getAlphaBits() { return alphaBits; @@ -228,10 +221,7 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } /** - * Defaults to true, ie. opaque surface. - *

    - * On supported platforms, setting opaque to false may result in a translucent surface.

    - * + * Sets whether the surface shall be opaque or translucent. *

    * Platform implementations may need an alpha component in the surface (eg. Windows), * or expect pre-multiplied alpha values (eg. X11/XRender).
    @@ -240,16 +230,9 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { * Please note that in case alpha is required on the platform the * clear color shall have an alpha lower than 1.0 to allow anything shining through. *

    - * *

    * Mind that translucency may cause a performance penalty - * due to the composite work required by the window manager.

    - * - *

    - * The platform implementation may utilize the transparency RGBA values.
    - * This is true for the original GLX transparency specification, which is no more used today.
    - * Actually these values are currently not used by any implementation, - * so we may mark them deprecated soon, if this doesn't change.
    + * due to the composite work required by the window manager. *

    */ public void setBackgroundOpaque(boolean opaque) { @@ -259,56 +242,65 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { } } - /** Indicates whether the background of this OpenGL context should - be considered opaque. Defaults to true. - - @see #setBackgroundOpaque - */ @Override public final boolean isBackgroundOpaque() { return backgroundOpaque; } - /** Sets whether the drawable surface supports onscreen. - Defaults to true. - */ + /** + * Sets whether the surface shall be on- or offscreen. + *

    + * Defaults to true. + *

    + *

    + * If requesting an offscreen surface without further selection of it's mode, + * e.g. FBO, Pbuffer or {@link #setBitmap(boolean) bitmap}, + * the implementation will choose the best available offscreen mode. + *

    + * @param onscreen + */ public void setOnscreen(boolean onscreen) { this.onscreen=onscreen; } - /** Indicates whether the drawable surface is onscreen. - Defaults to true. - */ @Override public final boolean isOnscreen() { return onscreen; } - /** Gets the transparent red value for the frame buffer configuration. - * This value is undefined if {@link #isBackgroundOpaque()} equals true. - * @see #setTransparentRedValue - */ + /** + * Requesting offscreen bitmap mode. + *

    + * If enabled this method also invokes {@link #setOnscreen(int) setOnscreen(false)}. + *

    + *

    + * Defaults to false. + *

    + *

    + * Requesting offscreen bitmap mode disables the offscreen auto selection. + *

    + */ + public void setBitmap(boolean enable) { + if(enable) { + setOnscreen(false); + } + isBitmap = enable; + } + + @Override + public boolean isBitmap() { + return isBitmap; + } + @Override public final int getTransparentRedValue() { return transparentValueRed; } - /** Gets the transparent green value for the frame buffer configuration. - * This value is undefined if {@link #isBackgroundOpaque()} equals true. - * @see #setTransparentGreenValue - */ @Override public final int getTransparentGreenValue() { return transparentValueGreen; } - /** Gets the transparent blue value for the frame buffer configuration. - * This value is undefined if {@link #isBackgroundOpaque()} equals true. - * @see #setTransparentBlueValue - */ @Override public final int getTransparentBlueValue() { return transparentValueBlue; } - /** Gets the transparent alpha value for the frame buffer configuration. - * This value is undefined if {@link #isBackgroundOpaque()} equals true. - * @see #setTransparentAlphaValue - */ @Override public final int getTransparentAlphaValue() { return transparentValueAlpha; } @@ -342,32 +334,58 @@ public class Capabilities implements CapabilitiesImmutable, Cloneable { @Override public StringBuilder toString(StringBuilder sink) { + return toString(sink, true); + } + + /** Returns a textual representation of this Capabilities + object. */ + @Override + public String toString() { + StringBuilder msg = new StringBuilder(); + msg.append("Caps["); + toString(msg); + msg.append("]"); + return msg.toString(); + } + + /** Return a textual representation of this object's on/off screen state. Use the given StringBuffer [optional]. */ + protected StringBuilder onoffScreenToString(StringBuilder sink) { if(null == sink) { sink = new StringBuilder(); } if(onscreen) { sink.append("on-scr"); } else { - sink.append("offscr"); + sink.append("offscr["); + } + if(isBitmap) { + sink.append("bitmap"); + } else if(onscreen) { + sink.append("."); // no additional off-screen modes besides on-screen + } else { + sink.append("auto-cfg"); // auto-config off-screen mode + } + sink.append("]"); + + return sink; + } + + protected StringBuilder toString(StringBuilder sink, boolean withOnOffScreen) { + if(null == sink) { + sink = new StringBuilder(); } - sink.append(", rgba 0x").append(toHexString(redBits)).append("/").append(toHexString(greenBits)).append("/").append(toHexString(blueBits)).append("/").append(toHexString(alphaBits)); + sink.append("rgba 0x").append(toHexString(redBits)).append("/").append(toHexString(greenBits)).append("/").append(toHexString(blueBits)).append("/").append(toHexString(alphaBits)); if(backgroundOpaque) { sink.append(", opaque"); } else { sink.append(", trans-rgba 0x").append(toHexString(transparentValueRed)).append("/").append(toHexString(transparentValueGreen)).append("/").append(toHexString(transparentValueBlue)).append("/").append(toHexString(transparentValueAlpha)); } + if(withOnOffScreen) { + sink.append(", "); + onoffScreenToString(sink); + } return sink; } + protected final String toHexString(int val) { return Integer.toHexString(val); } - - /** Returns a textual representation of this Capabilities - object. */ - @Override - public String toString() { - StringBuilder msg = new StringBuilder(); - msg.append("Caps["); - toString(msg); - msg.append("]"); - return msg.toString(); - } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java index b984a4626..b801ab457 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java @@ -39,44 +39,65 @@ import com.jogamp.common.type.WriteCloneable; public interface CapabilitiesImmutable extends VisualIDHolder, WriteCloneable, Comparable { /** - * Returns the number of bits requested for the color buffer's red + * Returns the number of bits for the color buffer's red * component. On some systems only the color depth, which is the sum of the * red, green, and blue bits, is considered. */ int getRedBits(); /** - * Returns the number of bits requested for the color buffer's green + * Returns the number of bits for the color buffer's green * component. On some systems only the color depth, which is the sum of the * red, green, and blue bits, is considered. */ int getGreenBits(); /** - * Returns the number of bits requested for the color buffer's blue + * Returns the number of bits for the color buffer's blue * component. On some systems only the color depth, which is the sum of the * red, green, and blue bits, is considered. */ int getBlueBits(); /** - * Returns the number of bits requested for the color buffer's alpha + * Returns the number of bits for the color buffer's alpha * component. On some systems only the color depth, which is the sum of the * red, green, and blue bits, is considered. */ int getAlphaBits(); /** - * Indicates whether the background of this OpenGL context should be - * considered opaque. Defaults to true. + * Returns whether an opaque or translucent surface is requested, supported or chosen. + *

    + * Default is true, i.e. opaque. + *

    */ boolean isBackgroundOpaque(); /** - * Indicates whether the drawable surface is onscreen. Defaults to true. + * Returns whether an on- or offscreen surface is requested, available or chosen. + *

    + * Default is true, i.e. onscreen. + *

    + *

    + * Mind that an capabilities intance w/ available semantics + * may show onscreen, but also the offscreen modes FBO, Pbuffer or {@link #setBitmap(boolean) bitmap}. + * This is valid, since one native configuration maybe used for either functionality. + *

    */ boolean isOnscreen(); + /** + * Returns whether bitmap offscreen mode is requested, available or chosen. + *

    + * Default is false. + *

    + *

    + * For chosen capabilities, only the selected offscreen surface is set to true. + *

    + */ + boolean isBitmap(); + /** * Gets the transparent red value for the frame buffer configuration. This * value is undefined if; equals true. diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java index 9d4b112b1..744c7e6d5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultCapabilitiesChooser.java @@ -68,6 +68,9 @@ import jogamp.nativewindow.Debug; public class DefaultCapabilitiesChooser implements CapabilitiesChooser { private static final boolean DEBUG = Debug.isPropertyDefined("nativewindow.debug.CapabilitiesChooser", true); + private final static int NO_SCORE = -9999999; + private final static int COLOR_MISMATCH_PENALTY_SCALE = 36; + public int chooseCapabilities(final CapabilitiesImmutable desired, final List available, final int windowSystemRecommendedChoice) { @@ -92,8 +95,6 @@ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { // Create score array int[] scores = new int[availnum]; - int NO_SCORE = -9999999; - int COLOR_MISMATCH_PENALTY_SCALE = 36; for (int i = 0; i < availnum; i++) { scores[i] = NO_SCORE; } @@ -103,6 +104,10 @@ public class DefaultCapabilitiesChooser implements CapabilitiesChooser { if (cur == null) { continue; } + if (desired.isOnscreen() && !cur.isOnscreen()) { + continue; // requested onscreen, but n/a + } + int score = 0; // Compute difference in color depth score += (COLOR_MISMATCH_PENALTY_SCALE * diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java new file mode 100644 index 000000000..0782e8915 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java @@ -0,0 +1,233 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +public class TestGLCapabilities01NEWT extends UITestCase { + static final int width = 100; + static final int height = 100; + + boolean checkProfile(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return false; + } + return true; + } + + void doTest(GLCapabilities reqGLCaps, GLEventListener demo) throws InterruptedException { + System.out.println("Requested GL Caps: "+reqGLCaps); + + // + // Create native windowing resources .. X11/Win/OSX + // + final Window window = NewtFactory.createWindow(reqGLCaps); + Assert.assertNotNull(window); + window.setSize(width, height); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + System.out.println("Window: "+window.getClass().getName()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = window.getGraphicsConfiguration().getChosenCapabilities(); + System.out.println("Window Caps Pre_GL: "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + System.out.println("Drawable Pre-GL(0): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); + + // + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + System.out.println("Window Caps PostGL : "+window.getGraphicsConfiguration().getChosenCapabilities()); + System.out.println("Drawable Post-GL(1): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(reqGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(reqGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(reqGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(reqGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(reqGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } + + GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + int res = context.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + context.release(); + + System.out.println("Chosen GL Caps(2): "+drawable.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(2): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); + + drawable.setRealized(false); + window.destroy(); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + //@Test + public void testGL2OffScreenAutoDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GL2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + // @Test + public void testGL2OffScreenFBODblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GL2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OnScreenDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GL2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GL2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GL2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OnScreenDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GLES2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GLES2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + /** Not implemented ! + @Test + public void testES2OffScreenBitmapDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GLES2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new GearsES2(1)); + } */ + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLCapabilities01NEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 35a2d9669..9e96db5e1 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -38,6 +38,7 @@ import java.awt.Robot; import java.awt.Toolkit; import javax.media.nativewindow.NativeWindow; +import javax.media.opengl.GLDrawable; import javax.media.opengl.awt.GLCanvas; import org.junit.Assert; @@ -494,6 +495,18 @@ public class AWTRobotUtil { return wait Date: Fri, 7 Sep 2012 05:46:52 +0200 Subject: Windows scripts: bump to 1.6.0_35 --- make/scripts/java-win32-dbg.bat | 4 ++-- make/scripts/java-win32.bat | 4 ++-- make/scripts/java-win64-dbg.bat | 8 ++++---- make/scripts/java-win64.bat | 4 ++-- make/scripts/make.jogl.all.win32.bat | 4 ++-- make/scripts/make.jogl.all.win64.bat | 6 +++--- make/scripts/tests-javaws-x64.bat | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat index 5735797bf..c592efccf 100755 --- a/make/scripts/java-win32-dbg.bat +++ b/make/scripts/java-win32-dbg.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win32 -set J2RE_HOME=c:\jre1.6.0_30_x32 -set JAVA_HOME=c:\jdk1.6.0_30_x32 +set J2RE_HOME=c:\jre1.6.0_35_x32 +set JAVA_HOME=c:\jdk1.6.0_35_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat index a4d631075..bf7437146 100755 --- a/make/scripts/java-win32.bat +++ b/make/scripts/java-win32.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win32 -set J2RE_HOME=c:\jre1.6.0_30_x32 -set JAVA_HOME=c:\jdk1.6.0_30_x32 +set J2RE_HOME=c:\jre1.6.0_35_x32 +set JAVA_HOME=c:\jdk1.6.0_35_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index c8a90454d..510ebf4dc 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win64 -set J2RE_HOME=c:\jre1.6.0_30_x64 -set JAVA_HOME=c:\jdk1.6.0_30_x64 +set J2RE_HOME=c:\jre1.6.0_35_x64 +set JAVA_HOME=c:\jdk1.6.0_35_x64 set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl @@ -32,12 +32,12 @@ REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache REM set D_ARGS="-Djogl.debug.GraphicsConfiguration" REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock" -REM set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" +set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" -set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" REM set D_ARGS="-Djogl.debug.GLContext" "-Dnewt.debug=all" diff --git a/make/scripts/java-win64.bat b/make/scripts/java-win64.bat index 2c09feedc..99f9bdcef 100755 --- a/make/scripts/java-win64.bat +++ b/make/scripts/java-win64.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win64 -set J2RE_HOME=c:\jre1.6.0_30_x64 -set JAVA_HOME=c:\jdk1.6.0_30_x64 +set J2RE_HOME=c:\jre1.6.0_35_x64 +set JAVA_HOME=c:\jdk1.6.0_35_x64 set ANT_PATH=C:\apache-ant-1.8.2 REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% diff --git a/make/scripts/make.jogl.all.win32.bat b/make/scripts/make.jogl.all.win32.bat index 52ea33a33..c4c80a75b 100755 --- a/make/scripts/make.jogl.all.win32.bat +++ b/make/scripts/make.jogl.all.win32.bat @@ -1,7 +1,7 @@ set THISDIR="C:\JOGL" -set J2RE_HOME=c:\jre1.6.0_30_x32 -set JAVA_HOME=c:\jdk1.6.0_30_x32 +set J2RE_HOME=c:\jre1.6.0_35_x32 +set JAVA_HOME=c:\jdk1.6.0_35_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% diff --git a/make/scripts/make.jogl.all.win64.bat b/make/scripts/make.jogl.all.win64.bat index e1d258cca..7355c6a1a 100755 --- a/make/scripts/make.jogl.all.win64.bat +++ b/make/scripts/make.jogl.all.win64.bat @@ -1,10 +1,10 @@ set THISDIR="C:\JOGL" -set J2RE_HOME=c:\jre1.6.0_30_x64 -set JAVA_HOME=c:\jdk1.6.0_30_x64 +set J2RE_HOME=c:\jre1.6.0_35_x64 +set JAVA_HOME=c:\jdk1.6.0_35_x64 set ANT_PATH=C:\apache-ant-1.8.2 -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;c:\mingw\bin;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%PATH% set LIB_GEN=%THISDIR%\lib set CLASSPATH=.;%THISDIR%\build-win64\classes diff --git a/make/scripts/tests-javaws-x64.bat b/make/scripts/tests-javaws-x64.bat index 40f118268..deef4ca37 100755 --- a/make/scripts/tests-javaws-x64.bat +++ b/make/scripts/tests-javaws-x64.bat @@ -1,4 +1,4 @@ -set JRE_PATH=C:\jre1.6.0_30_x64\bin +set JRE_PATH=C:\jre1.6.0_35_x64\bin set LOG_PATH=%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\log %JRE_PATH%\javaws -uninstall -- cgit v1.2.3 From f2cfb6119a3663715ed2d572643949b3bef58662 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 7 Sep 2012 08:13:06 +0200 Subject: Cleanup shutdown mechanism ; Fix X11/ATI SIGV at shutdown ; EGLDisplayUtil: Check for leaked display handles GLProfile / all shutdown methods: Remove ShutdownType to remove complexity (not required) Proper shutdown sequence: GLProfile - GLDrawableFactory+ - GLContext - NativeWindowFactory - [X11Util, OSXUtil, ..] GLDrawableFactory: Always keep shutdown-hook alive, required for X11Util shutdown (@ JVMShutdown only) X11Util: Shutdown - @ JVMShutdown only - If GL vendor ATI: close pending X11 display connections in proper order of creation. This finally removes the SIGV when shutting down the JVM on X11 w/ ATI driver. EGLDisplayUtil: Add shutdown, allowing to validate whether leaked EGL display handles remain. --- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 12 +- .../javax/media/opengl/GLDrawableFactory.java | 36 +++--- src/jogl/classes/javax/media/opengl/GLProfile.java | 29 +---- .../classes/jogamp/opengl/egl/EGLDisplayUtil.java | 38 +++++- .../jogamp/opengl/egl/EGLDrawableFactory.java | 22 ++-- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 10 +- .../windows/wgl/WindowsWGLDrawableFactory.java | 10 +- .../opengl/x11/glx/X11GLXDrawableFactory.java | 14 +-- .../media/nativewindow/NativeWindowFactory.java | 42 +++++-- .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 11 +- .../jogamp/nativewindow/macosx/OSXUtil.java | 10 ++ .../jogamp/nativewindow/windows/GDIUtil.java | 10 ++ .../classes/jogamp/nativewindow/x11/X11Util.java | 127 +++++++++++++-------- .../junit/jogl/acore/TestShutdownCompleteAWT.java | 4 +- .../junit/jogl/acore/TestShutdownCompleteNEWT.java | 14 ++- .../junit/jogl/acore/TestShutdownSharedAWT.java | 124 -------------------- .../junit/jogl/acore/TestShutdownSharedNEWT.java | 127 --------------------- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 13 +-- .../jogl/demos/es2/newt/TestRedSquareES2NEWT.java | 13 +-- .../test/junit/newt/TestScreenMode01NEWT.java | 2 +- 21 files changed, 243 insertions(+), 429 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownSharedNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 669e0212e..22cce49aa 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -1,7 +1,9 @@ REM scripts\java-win64-dbg.bat jogamp.newt.awt.opengl.VersionApplet REM scripts\java-win64-dbg.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win64-dbg.bat javax.media.opengl.awt.GLCanvas -scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* +scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 1314094cf..5668893f7 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -53,6 +53,7 @@ function jrun() { swton=$1 shift + #D_ARGS="-Djogl.disable.opengles" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Dnewt.debug.Window.MouseEvent" #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FBObject" @@ -217,12 +218,12 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* @@ -260,7 +261,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT @@ -281,7 +282,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 $* @@ -379,7 +379,6 @@ function testawtswt() { # # FBO / .. # -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable00NEWT $* @@ -429,11 +428,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #linux: -# EARMARK removal of shutdown mode! -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT $* # osx: #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index acda45bff..9fd895c1f 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -55,7 +55,6 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; -import javax.media.opengl.GLProfile.ShutdownType; import jogamp.opengl.Debug; @@ -106,6 +105,7 @@ public abstract class GLDrawableFactory { // Shutdown hook mechanism for the factory private static boolean factoryShutdownHookRegistered = false; private static Thread factoryShutdownHook = null; + private static volatile boolean isJVMShuttingDown = false; /** * Instantiate singleton factories if available, EGLES1, EGLES2 and the OS native ones. @@ -176,21 +176,24 @@ public abstract class GLDrawableFactory { } } - protected static void shutdown(ShutdownType shutdownType) { + protected static void shutdown() { if (isInit) { // volatile: ok synchronized (GLDrawableFactory.class) { if (isInit) { isInit=false; - unregisterFactoryShutdownHook(); - shutdownImpl(shutdownType); + shutdownImpl(); } } } } - private static void shutdownImpl(ShutdownType shutdownType) { + + private static void shutdownImpl() { + // Following code will _always_ remain in shutdown hook + // due to special semantics of native utils, i.e. X11Utils. + // The latter requires shutdown at JVM-Shutdown only. synchronized(glDrawableFactories) { for(int i=0; i() { @@ -218,20 +224,6 @@ public abstract class GLDrawableFactory { factoryShutdownHookRegistered = true; } - private static synchronized void unregisterFactoryShutdownHook() { - if (!factoryShutdownHookRegistered) { - return; - } - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Runtime.getRuntime().removeShutdownHook(factoryShutdownHook); - return null; - } - }); - factoryShutdownHookRegistered = false; - } - - protected GLDrawableFactory() { synchronized(glDrawableFactories) { glDrawableFactories.add(this); @@ -244,7 +236,7 @@ public abstract class GLDrawableFactory { protected void enterThreadCriticalZone() {}; protected void leaveThreadCriticalZone() {}; - protected abstract void destroy(ShutdownType shutdownType); + protected abstract void destroy(); /** * Retrieve the default device {@link AbstractGraphicsDevice#getConnection() connection}, diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 513ccd101..23d789afd 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -198,44 +198,25 @@ public class GLProfile { getProfileMap(device, true); } - /** - * Shutdown type for {@link GLProfile#shutdown(ShutdownType)}. - *

    - * {@link #SHARED_ONLY} For thread based resources only, suitable for eg. {@link java.applet.Applet Applet} restart.
    - * {@link #COMPLETE} Everything.
    - *

    - */ - public enum ShutdownType { - /* Shared thread based resources only, eg. for Applets */ - SHARED_ONLY, - /* Everything */ - COMPLETE; - } - /** * Manual shutdown method, may be called after your last JOGL use * within the running JVM.
    * It releases all temporary created resources, ie issues {@link javax.media.opengl.GLDrawableFactory#shutdown()}.
    * The shutdown implementation is called via the JVM shutdown hook, if not manually invoked.
    *

    - * This method shall not need to be called for other reasons than issuing a proper shutdown of resources. + * This method shall not need to be called for other reasons than issuing a proper shutdown of resources at a defined time. *

    - * @param type the shutdown type, see {@link ShutdownType}. */ - public static void shutdown(ShutdownType type) { + public static void shutdown() { initLock.lock(); try { if(initialized) { // volatile: ok initialized = false; if(DEBUG) { - System.err.println("GLProfile.shutdown(type: "+type+") - thread "+Thread.currentThread().getName()); + System.err.println("GLProfile.shutdown() - thread "+Thread.currentThread().getName()); Thread.dumpStack(); } - GLDrawableFactory.shutdown(type); - if(ShutdownType.COMPLETE == type) { - GLContext.shutdown(); - } - NativeWindowFactory.shutdown(); + GLDrawableFactory.shutdown(); } } finally { initLock.unlock(); @@ -1480,7 +1461,7 @@ public class GLProfile { if(DEBUG) { System.err.println("Info: GLProfile.init - EGL/ES2 ANGLE disabled"); } - eglFactory.destroy(ShutdownType.COMPLETE); + eglFactory.destroy(); eglFactory = null; hasEGLFactory = false; } else { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index 18d2f830d..ce2e824f5 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -29,6 +29,7 @@ package jogamp.opengl.egl; import java.nio.IntBuffer; +import java.util.Iterator; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; @@ -51,7 +52,7 @@ import com.jogamp.nativewindow.egl.EGLGraphicsDevice; *

    */ public class EGLDisplayUtil { - protected static final boolean DEBUG = Debug.debug("EGL"); + protected static final boolean DEBUG = Debug.debug("EGLDisplayUtil"); static LongIntHashMap eglDisplayCounter; @@ -60,6 +61,32 @@ public class EGLDisplayUtil { eglDisplayCounter.setKeyNotFoundValue(0); } + /** + * @return number of unclosed EGL Displays.
    + */ + public static int shutdown(boolean verbose) { + if(DEBUG || verbose || eglDisplayCounter.size() > 0 ) { + System.err.println("EGLDisplayUtil.EGLDisplays: Shutdown (open: "+eglDisplayCounter.size()+")"); + if(DEBUG) { + Thread.dumpStack(); + } + if( eglDisplayCounter.size() > 0) { + EGLDisplayUtil.dumpOpenDisplayConnections(); + } + } + + return eglDisplayCounter.size(); + } + + public static void dumpOpenDisplayConnections() { + System.err.println("EGLDisplayUtil: Open EGL Display Connections: "+eglDisplayCounter.size()); + int i=0; + for(Iterator iter = eglDisplayCounter.iterator(); iter.hasNext(); i++) { + final LongIntHashMap.Entry e = iter.next(); + System.err.println("EGLDisplayUtil: Open["+i+"]: 0x"+Long.toHexString(e.key)+": refCnt "+e.value); + } + } + public static long eglGetDisplay(long nativeDisplay_id) { final long eglDisplay = EGL.eglGetDisplay(nativeDisplay_id); if(DEBUG) { @@ -89,6 +116,7 @@ public class EGLDisplayUtil { eglDisplayCounter.put(eglDisplay, refCnt); if(DEBUG) { System.err.println("EGLDisplayUtil.eglInitialize1("+EGLContext.toHexString(eglDisplay)+" ...): #"+refCnt+" = "+res); + // Thread.dumpStack(); } return res; } @@ -117,6 +145,7 @@ public class EGLDisplayUtil { } if(DEBUG) { System.err.println("EGLDisplayUtil.eglInitialize2("+EGLContext.toHexString(eglDisplay)+" ...): #"+refCnt+" = "+res); + // Thread.dumpStack(); } return res; } @@ -185,12 +214,13 @@ public class EGLDisplayUtil { final int refCnt = eglDisplayCounter.get(eglDisplay) - 1; // 1 - 1 = 0 -> final terminate if(0==refCnt) { // no terminate if still in use or already terminated res = EGL.eglTerminate(eglDisplay); + eglDisplayCounter.remove(eglDisplay); } else { + if(0 < refCnt) { // no negative refCount + eglDisplayCounter.put(eglDisplay, refCnt); + } res = true; } - if(0<=refCnt) { // no negative refCount - eglDisplayCounter.put(eglDisplay, refCnt); - } if(DEBUG) { System.err.println("EGLDisplayUtil.eglTerminate("+EGLContext.toHexString(eglDisplay)+" ...): #"+refCnt+" = "+res); // Thread.dumpStack(); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 986b110be..292eb17c8 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -64,7 +64,6 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import javax.media.opengl.GLProfile.ShutdownType; import jogamp.opengl.Debug; import jogamp.opengl.GLDrawableFactoryImpl; @@ -201,13 +200,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override - protected final void destroy(ShutdownType shutdownType) { + protected final void destroy() { if(null != sharedMap) { Collection srl = sharedMap.values(); for(Iterator sri = srl.iterator(); sri.hasNext(); ) { SharedResource sr = sri.next(); if(DEBUG) { - System.err.println("EGLDrawableFactory.destroy("+shutdownType+"): "+sr.device.toString()); + System.err.println("EGLDrawableFactory.destroy(): "+sr.device.toString()); } sr.device.close(); } @@ -220,17 +219,16 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { /** * Pulling away the native library may cause havoc .. */ - if(ShutdownType.COMPLETE == shutdownType) { - if(null != eglES1DynamicLookupHelper) { - // eglES1DynamicLookupHelper.destroy(); - eglES1DynamicLookupHelper = null; - } - if(null != eglES2DynamicLookupHelper) { - // eglES2DynamicLookupHelper.destroy(); - eglES2DynamicLookupHelper = null; - } + if(null != eglES1DynamicLookupHelper) { + // eglES1DynamicLookupHelper.destroy(); + eglES1DynamicLookupHelper = null; + } + if(null != eglES2DynamicLookupHelper) { + // eglES2DynamicLookupHelper.destroy(); + eglES2DynamicLookupHelper = null; } EGLGraphicsConfigurationFactory.unregisterFactory(); + EGLDisplayUtil.shutdown(DEBUG); } private HashMap sharedMap = null; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index c1b15cac5..591fafc68 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -60,7 +60,6 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import javax.media.opengl.GLProfile.ShutdownType; import jogamp.nativewindow.macosx.OSXUtil; import jogamp.opengl.DesktopGLDynamicLookupHelper; @@ -124,7 +123,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected final void destroy(ShutdownType shutdownType) { + protected final void destroy() { if(null != sharedMap) { sharedMap.clear(); sharedMap = null; @@ -133,10 +132,9 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { /** * Pulling away the native library may cause havoc .. * - if(ShutdownType.COMPLETE == shutdownType && null != macOSXCGLDynamicLookupHelper) { - macOSXCGLDynamicLookupHelper.destroy(); - macOSXCGLDynamicLookupHelper = null; - } */ + macOSXCGLDynamicLookupHelper.destroy(); + */ + macOSXCGLDynamicLookupHelper = null; } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index c414083c4..7ea487523 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -61,7 +61,6 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import javax.media.opengl.GLProfile.ShutdownType; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.GDISurface; @@ -136,7 +135,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { @Override - protected final void destroy(ShutdownType shutdownType) { + protected final void destroy() { if(null != sharedResourceRunner) { sharedResourceRunner.stop(); sharedResourceRunner = null; @@ -149,10 +148,9 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { /** * Pulling away the native library may cause havoc .. * - if(ShutdownType.COMPLETE == shutdownType && null != windowsWGLDynamicLookupHelper) { - windowsWGLDynamicLookupHelper.destroy(); - windowsWGLDynamicLookupHelper = null; - } */ + windowsWGLDynamicLookupHelper.destroy(); + */ + windowsWGLDynamicLookupHelper = null; RegisteredClassFactory.shutdownSharedClasses(); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 293ac96f7..bc3e5b793 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -58,7 +58,6 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import javax.media.opengl.GLProfile.ShutdownType; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; @@ -129,7 +128,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } @Override - protected final void destroy(ShutdownType shutdownType) { + protected final void destroy() { if(null != sharedResourceRunner) { sharedResourceRunner.stop(); sharedResourceRunner = null; @@ -142,14 +141,9 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { /** * Pulling away the native library may cause havoc .. * - if(ShutdownType.COMPLETE == shutdownType && null != x11GLXDynamicLookupHelper) { - x11GLXDynamicLookupHelper.destroy(); - x11GLXDynamicLookupHelper = null; - } */ - - // Don't really close pending Display connections, - // since this may trigger a JVM exception - X11Util.shutdown( false, DEBUG ); + x11GLXDynamicLookupHelper.destroy(); + */ + x11GLXDynamicLookupHelper = null; } @Override diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index afcd0a008..89d476a3b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -102,6 +102,8 @@ public abstract class NativeWindowFactory { private static Constructor x11ToolkitLockConstructor; private static boolean requiresToolkitLock; + private static volatile boolean isJVMShuttingDown = false; + /** Creates a new NativeWindowFactory instance. End users do not need to call this method. */ protected NativeWindowFactory() { @@ -168,6 +170,22 @@ public abstract class NativeWindowFactory { } } + private static void shutdownNativeImpl(final ClassLoader cl) { + final String clazzName; + if( TYPE_X11 == nativeWindowingTypePure ) { + clazzName = X11UtilClassName; + } else if( TYPE_WINDOWS == nativeWindowingTypePure ) { + clazzName = GDIClassName; + } else if( TYPE_MACOSX == nativeWindowingTypePure ) { + clazzName = OSXUtilClassName; + } else { + clazzName = null; + } + if( null != clazzName ) { + ReflectionUtil.callStaticMethod(clazzName, "shutdown", null, null, cl ); + } + } + /** * Static one time initialization of this factory.
    * This initialization method must be called once by the program or utilizing modules! @@ -268,22 +286,28 @@ public abstract class NativeWindowFactory { } } - public static synchronized void shutdown() { + public static synchronized void shutdown(boolean _isJVMShuttingDown) { + isJVMShuttingDown = _isJVMShuttingDown; + if(DEBUG) { + System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() START: JVM Shutdown "+isJVMShuttingDown); + } if(initialized) { initialized = false; - if(DEBUG) { - System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() START"); + if(null != registeredFactories) { + registeredFactories.clear(); + registeredFactories = null; } - registeredFactories.clear(); - registeredFactories = null; GraphicsConfigurationFactory.shutdown(); - // X11Util.shutdown(..) already called via GLDrawableFactory.shutdown() .. - if(DEBUG) { - System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() END"); - } + } + shutdownNativeImpl(NativeWindowFactory.class.getClassLoader()); // always re-shutdown + if(DEBUG) { + System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() END JVM Shutdown "+isJVMShuttingDown); } } + /** Returns true if the JVM is shutting down, otherwise false. */ + public static final boolean isJVMShuttingDown() { return isJVMShuttingDown; } + /** @return true if the underlying toolkit requires locking, otherwise false. */ public static boolean requiresToolkitLock() { return requiresToolkitLock; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 36d7c3727..f1e8a786a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -48,6 +48,7 @@ import java.util.ArrayList; import java.util.Map; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ToolkitLock; import jogamp.nativewindow.Debug; @@ -271,10 +272,18 @@ public class JAWTUtil { } } + /** + * Called by {@link NativeWindowFactory#initSingleton()} + */ public static void initSingleton() { // just exist to ensure static init has been run } - + + /** + * Called by {@link NativeWindowFactory#shutdown()} + */ + public static void shutdown() { + } public static boolean hasJava2D() { return j2dExist; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index f5f735051..149ebdf4a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -28,6 +28,7 @@ package jogamp.nativewindow.macosx; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; @@ -38,6 +39,9 @@ public class OSXUtil { private static boolean isInit = false; private static final boolean DEBUG = Debug.debug("OSXUtil"); + /** + * Called by {@link NativeWindowFactory#initSingleton()} + */ public static synchronized void initSingleton() { if(!isInit) { if(DEBUG) { @@ -54,6 +58,12 @@ public class OSXUtil { } } + /** + * Called by {@link NativeWindowFactory#shutdown()} + */ + public static void shutdown() { + } + public static boolean requiresToolkitLock() { return false; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index fda1649b6..613c76032 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -29,6 +29,7 @@ package jogamp.nativewindow.windows; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; import jogamp.nativewindow.NWJNILibLoader; import jogamp.nativewindow.Debug; @@ -41,6 +42,9 @@ public class GDIUtil { private static RegisteredClassFactory dummyWindowClassFactory; private static boolean isInit = false; + /** + * Called by {@link NativeWindowFactory#initSingleton()} + */ public static synchronized void initSingleton() { if(!isInit) { synchronized(X11Util.class) { @@ -61,6 +65,12 @@ public class GDIUtil { } } + /** + * Called by {@link NativeWindowFactory#shutdown()} + */ + public static void shutdown() { + } + public static boolean requiresToolkitLock() { return false; } private static RegisteredClass dummyWindowClass = null; diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 860238649..93b7f3487 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -67,13 +67,13 @@ public class X11Util { *

    *

    * You may test this, ie just reverse the destroy order below. - * See also native test: jogl/test/native/displayMultiple02.c + * See also native test: jogl/test-native/displayMultiple02.c *

    *

    * Workaround is to not close them at all if driver vendor is ATI. *

    */ - public static final boolean ATI_HAS_XCLOSEDISPLAY_BUG = true; + public static final boolean ATI_HAS_XCLOSEDISPLAY_BUG = !Debug.isPropertyDefined("nativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG", true); /** Value is true, best 'stable' results if always using XInitThreads(). */ public static final boolean XINITTHREADS_ALWAYS_ENABLED = true; @@ -95,6 +95,9 @@ public class X11Util { private static Object setX11ErrorHandlerLock = new Object(); + /** + * Called by {@link NativeWindowFactory#initSingleton()} + */ public static void initSingleton() { if(!isInit) { synchronized(X11Util.class) { @@ -138,6 +141,52 @@ public class X11Util { } } + /** + * Cleanup resources. + *

    + * Called by {@link NativeWindowFactory#shutdown()} + *

    + */ + public static void shutdown() { + if(isInit) { + synchronized(X11Util.class) { + if(isInit) { + final boolean isJVMShuttingDown = NativeWindowFactory.isJVMShuttingDown() ; + if(DEBUG || openDisplayMap.size() > 0 || reusableDisplayList.size() > 0 || pendingDisplayList.size() > 0) { + System.err.println("X11Util.Display: Shutdown (JVM shutdown: "+isJVMShuttingDown+ + ", open (no close attempt): "+openDisplayMap.size()+"/"+openDisplayList.size()+ + ", reusable (open, marked uncloseable): "+reusableDisplayList.size()+ + ", pending (post closing): "+pendingDisplayList.size()+ + ")"); + if(DEBUG) { + Thread.dumpStack(); + } + if( openDisplayList.size() > 0) { + X11Util.dumpOpenDisplayConnections(); + } + if( reusableDisplayList.size() > 0 || pendingDisplayList.size() > 0 ) { + X11Util.dumpPendingDisplayConnections(); + } + } + + synchronized(globalLock) { + // Only at JVM shutdown time, since AWT impl. seems to + // dislike closing of X11 Display's (w/ ATI driver). + if( isJVMShuttingDown ) { + isInit = false; + closePendingDisplayConnections(); + openDisplayList.clear(); + reusableDisplayList.clear(); + pendingDisplayList.clear(); + openDisplayMap.clear(); + shutdown0(); + } + } + } + } + } + } + public static synchronized boolean isNativeLockAvailable() { return isX11LockAvailable; } @@ -183,6 +232,7 @@ public class X11Util { private static Object globalLock = new Object(); private static LongObjectHashMap openDisplayMap = new LongObjectHashMap(); // handle -> name private static List openDisplayList = new ArrayList(); + private static List reusableDisplayList = new ArrayList(); private static List pendingDisplayList = new ArrayList(); public static class NamedDisplay { @@ -218,8 +268,7 @@ public class X11Util { public final boolean equals(Object obj) { if(this == obj) { return true; } if(obj instanceof NamedDisplay) { - NamedDisplay n = (NamedDisplay) obj; - return handle == n.handle; + return handle == ((NamedDisplay) obj).handle; } return false; } @@ -246,43 +295,6 @@ public class X11Util { } } - /** - * Cleanup resources. - * If realXCloseOpenAndPendingDisplays is false, - * keep alive all references (open display connection) for restart on same ClassLoader. - * - * @return number of unclosed X11 Displays.
    - * @param realXCloseOpenAndPendingDisplays if true, {@link #closePendingDisplayConnections()} is called. - */ - public static int shutdown(boolean realXCloseOpenAndPendingDisplays, boolean verbose) { - int num=0; - if(DEBUG || verbose || openDisplayMap.size() > 0 || pendingDisplayList.size() > 0) { - System.err.println("X11Util.Display: Shutdown (close open / pending Displays: "+realXCloseOpenAndPendingDisplays+ - ", open (no close attempt): "+openDisplayMap.size()+"/"+openDisplayList.size()+ - ", pending (not closed, marked uncloseable): "+pendingDisplayList.size()+")"); - if(DEBUG) { - Thread.dumpStack(); - } - if( openDisplayList.size() > 0) { - X11Util.dumpOpenDisplayConnections(); - } - if( pendingDisplayList.size() > 0 ) { - X11Util.dumpPendingDisplayConnections(); - } - } - - synchronized(globalLock) { - if(realXCloseOpenAndPendingDisplays) { - closePendingDisplayConnections(); - openDisplayList.clear(); - pendingDisplayList.clear(); - openDisplayMap.clear(); - shutdown0(); - } - } - return num; - } - /** * Closing pending Display connections in reverse order. * @@ -292,9 +304,9 @@ public class X11Util { int num=0; synchronized(globalLock) { if(DEBUG) { - System.err.println("X11Util: Closing Pending X11 Display Connections: "+pendingDisplayList.size()); + System.err.println("X11Util: Closing Pending X11 Display Connections in order of their creation: "+pendingDisplayList.size()); } - for(int i=pendingDisplayList.size()-1; i>=0; i--) { + for(int i=0; i Date: Fri, 7 Sep 2012 08:34:32 +0200 Subject: NEWT AWT Driver: Remove flashing (clear background @ update/paint method) ; Proper canvas size and direct events. --- make/scripts/tests.sh | 4 +- .../jogamp/newt/event/awt/AWTWindowAdapter.java | 28 ++++++-- .../classes/jogamp/newt/driver/awt/AWTCanvas.java | 28 +++++++- .../jogamp/newt/driver/awt/WindowDriver.java | 78 +++++++++++++++++----- .../demos/gl2/newt/TestGearsNewtAWTWrapper.java | 20 +++++- 5 files changed, 131 insertions(+), 27 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5668893f7..ce04ae4dc 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -261,7 +261,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT @@ -331,7 +331,7 @@ testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index 69b0d0482..2d63ca455 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -28,6 +28,8 @@ package com.jogamp.newt.event.awt; +import java.awt.Dimension; + import jogamp.newt.awt.event.AWTNewtEventFactory; public class AWTWindowAdapter @@ -61,9 +63,9 @@ public class AWTWindowAdapter if(awtComponent instanceof java.awt.Window) { ((java.awt.Window)awtComponent).addWindowListener(this); } - return this; + return this; } - + public AWTAdapter removeFrom(java.awt.Component awtComponent) { awtComponent.removeFocusListener(this); awtComponent.removeComponentListener(this); @@ -89,6 +91,9 @@ public class AWTWindowAdapter public void focusGained(java.awt.event.FocusEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + if(DEBUG_IMPLEMENTATION) { + System.err.println("AWT: focusGained: "+e+" -> "+event); + } if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowGainedFocus(event); } else { @@ -98,6 +103,9 @@ public class AWTWindowAdapter public void focusLost(java.awt.event.FocusEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + if(DEBUG_IMPLEMENTATION) { + System.err.println("AWT: focusLost: "+e+" -> "+event); + } if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowLostFocus(event); } else { @@ -108,7 +116,19 @@ public class AWTWindowAdapter public void componentResized(java.awt.event.ComponentEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { - System.err.println("AWT: componentResized: "+event); + final java.awt.Component c = e.getComponent(); + final java.awt.Dimension sz = c.getSize(); + final java.awt.Insets insets; + final java.awt.Dimension sz2; + if(c instanceof java.awt.Container) { + insets = ((java.awt.Container)c).getInsets(); + sz2 = new Dimension(sz.width - insets.left - insets.right, + sz.height - insets.top - insets.bottom); + } else { + insets = null; + sz2 = sz; + } + System.err.println("AWT: componentResized: "+sz+" ( "+insets+", "+sz2+" ), "+e+" -> "+event); } if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowResized(event); @@ -120,7 +140,7 @@ public class AWTWindowAdapter public void componentMoved(java.awt.event.ComponentEvent e) { com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); if(DEBUG_IMPLEMENTATION) { - System.err.println("AWT: componentMoved: "+event); + System.err.println("AWT: componentMoved: "+e+" -> "+event); } if(null!=newtListener) { ((com.jogamp.newt.event.WindowListener)newtListener).windowMoved(event); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java index b3fdcad41..17eb6a2fb 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTCanvas.java @@ -35,6 +35,7 @@ package jogamp.newt.driver.awt; import java.awt.Canvas; +import java.awt.Graphics; import java.awt.GraphicsDevice; import java.awt.GraphicsConfiguration; import java.lang.reflect.Method; @@ -61,14 +62,16 @@ public class AWTCanvas extends Canvas { private GraphicsConfiguration chosen; private AWTGraphicsConfiguration awtConfig; + private WindowDriver newtWindowImpl; private CapabilitiesChooser chooser=null; private CapabilitiesImmutable capabilities; private boolean displayConfigChanged=false; - public AWTCanvas(CapabilitiesImmutable capabilities, CapabilitiesChooser chooser) { + public AWTCanvas(WindowDriver newtWindowImpl, CapabilitiesImmutable capabilities, CapabilitiesChooser chooser) { super(); + this.newtWindowImpl = newtWindowImpl; if(null==capabilities) { throw new NativeWindowException("Capabilities null"); } @@ -80,6 +83,25 @@ public class AWTCanvas extends Canvas { return awtConfig; } + /** + * Overridden from Canvas to prevent the AWT's clearing of the + * canvas from interfering with the OpenGL rendering. + */ + @Override + public void update(Graphics g) { + paint(g); + } + + /** Overridden to cause OpenGL rendering to be performed during + repaint cycles. Subclasses which override this method must call + super.paint() in their paint() method in order to function + properly. + */ + @Override + public void paint(Graphics g) { + newtWindowImpl.windowRepaint(0, 0, getWidth(), getHeight()); + } + public boolean hasDeviceChanged() { boolean res = displayConfigChanged; displayConfigChanged=false; @@ -275,10 +297,10 @@ public class AWTCanvas extends Canvas { private void disableBackgroundErase() { if (!disableBackgroundEraseInitialized) { try { - AccessController.doPrivileged(new PrivilegedAction() { + AccessController.doPrivileged(new PrivilegedAction() { public Object run() { try { - Class clazz = getToolkit().getClass(); + Class clazz = getToolkit().getClass(); while (clazz != null && disableBackgroundEraseMethod == null) { try { disableBackgroundEraseMethod = diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index 1723ffee5..bee43a95e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -36,6 +36,7 @@ package jogamp.newt.driver.awt; import java.awt.BorderLayout; import java.awt.Container; +import java.awt.Dimension; import java.awt.Frame; import java.awt.Insets; @@ -47,6 +48,8 @@ import jogamp.newt.WindowImpl; import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowUpdateEvent; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTMouseAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; @@ -107,18 +110,18 @@ public class WindowDriver extends WindowImpl { frame.setTitle(getTitle()); } container.setLayout(new BorderLayout()); - canvas = new AWTCanvas(capsRequested, WindowDriver.this.capabilitiesChooser); - - addWindowListener(new LocalWindowListener()); - - new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here - new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here + + canvas = new AWTCanvas(this, capsRequested, WindowDriver.this.capabilitiesChooser); // canvas.addComponentListener(listener); container.add(canvas, BorderLayout.CENTER); - container.setSize(getWidth(), getHeight()); - container.setLocation(getX(), getY()); - new AWTWindowAdapter(this).addTo(container); // fwd all AWT Window events to here + + // via EDT .. + new AWTMouseAdapter(this).addTo(canvas); // fwd all AWT Mouse events to here + new AWTKeyAdapter(this).addTo(canvas); // fwd all AWT Key events to here + + // direct w/o EDT + new AWTWindowAdapter(new LocalWindowListener(), this).addTo(canvas); // fwd all AWT Window events to here reconfigureWindowImpl(getX(), getY(), getWidth(), getHeight(), getReconfigureFlags(FLAG_CHANGE_VISIBILITY | FLAG_CHANGE_DECORATION, true)); // throws exception if failed .. @@ -174,20 +177,32 @@ public class WindowDriver extends WindowImpl { frame.setUndecorated(isUndecorated()); } else { if(DEBUG_IMPLEMENTATION) { - System.err.println("AWTWindow can't undecorate already created frame"); + System.err.println(getThreadName()+": AWTWindow can't undecorate already created frame"); } } } + final Dimension szClient = new Dimension(width, height); + canvas.setMinimumSize(szClient); + canvas.setPreferredSize(szClient); + canvas.setSize(szClient); + if(DEBUG_IMPLEMENTATION) { + final Insets insets = container.getInsets(); + final Dimension szContainer = new Dimension(width + insets.left + insets.right, + height + insets.top + insets.bottom); + System.err.println(getThreadName()+": AWTWindow new size: szClient "+szClient+", szCont "+szContainer+", insets "+insets); + } + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { + if(null != frame) { + frame.pack(); + } + container.validate(); container.setVisible(0 != ( FLAG_IS_VISIBLE & flags)); } container.setLocation(x, y); - Insets insets = container.getInsets(); - container.setSize(width + insets.left + insets.right, - height + insets.top + insets.bottom); - + if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { if( 0 != ( FLAG_IS_VISIBLE & flags ) ) { if( !hasDeviceChanged() ) { @@ -200,6 +215,12 @@ public class WindowDriver extends WindowImpl { } } visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); + } else { + container.invalidate(); + if(null != frame) { + frame.pack(); + } + container.validate(); } return true; @@ -216,18 +237,41 @@ public class WindowDriver extends WindowImpl { return canvas; } - class LocalWindowListener extends com.jogamp.newt.event.WindowAdapter { + class LocalWindowListener implements com.jogamp.newt.event.WindowListener { @Override public void windowMoved(com.jogamp.newt.event.WindowEvent e) { if(null!=container) { - definePosition(container.getX(), container.getY()); + WindowDriver.this.positionChanged(false, container.getX(), container.getY()); } } @Override public void windowResized(com.jogamp.newt.event.WindowEvent e) { if(null!=canvas) { - defineSize(canvas.getWidth(), canvas.getHeight()); + WindowDriver.this.sizeChanged(false, canvas.getWidth(), canvas.getHeight(), false); + } + } + @Override + public void windowDestroyNotify(WindowEvent e) { + WindowDriver.this.windowDestroyNotify(false); + } + @Override + public void windowDestroyed(WindowEvent e) { + if(isNativeValid()) { + WindowDriver.this.windowDestroyNotify(true); } + + } + @Override + public void windowGainedFocus(WindowEvent e) { + WindowDriver.this.focusChanged(false, true); + } + @Override + public void windowLostFocus(WindowEvent e) { + WindowDriver.this.focusChanged(false, false); + } + @Override + public void windowRepaint(WindowUpdateEvent e) { + WindowDriver.this.windowRepaint(false, 0, 0, getWidth(), getHeight()); } } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java index 62914bd4e..cc20cc27e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNewtAWTWrapper.java @@ -33,6 +33,7 @@ import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -78,8 +79,25 @@ public class TestGearsNewtAWTWrapper extends UITestCase { glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); - glWindow.setSize(width, height); + int div = 3; + glWindow.setSize(width/div, height/div); glWindow.setVisible(true); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + + div = 2; + glWindow.setSize(width/div, height/div); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + + div = 1; + glWindow.setSize(width/div, height/div); + glWindow.display(); + Assert.assertTrue("Size not reached: Expected "+(width/div)+"x"+(height/div)+", Is "+glWindow.getWidth()+"x"+glWindow.getHeight(), + AWTRobotUtil.waitForSize(glWindow, width/div, height/div)); + animator.setUpdateFPSFrames(1, null); animator.start(); -- cgit v1.2.3 From 4dd44b985fe0541be3a3bcd9045d201ed3ca2cc5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 15 Sep 2012 16:54:52 +0200 Subject: Seamless Integration of an FBObject based GLFBODrawable as GLOffscreenAutoDrawable.FBO and as an OffscreenLayerSurface's drawable (OSX) - Fix Bugs 569 and 599 Summary: ========= The new FBObject based GLFBODrawable implementation allows the seamless utilization of FBO offscreen rendering in single buffer, double buffer and MSAA mode. The GLFBODrawable uses a parent drawable based on a dummy surface to allow a GLOffscreenAutoDrawable.FBO creation or a mutable surface supporting an existing offscreen layer surface (OSX CALayer). Offscreen GLDrawable's and GLOffscreenAutoDrawable's can be selected via the GLCapabilities. If simply !onscreen is selected in the caps instance w/o enabling FBO, PBuffer or Bitmap, the factory will automatically choose regarding availability: FBO > PBuffer > Bitmap Double buffering is supported in MSAA more (intrinsic) and explicit in non MSAA. It is preferred when delivering resources (texture id's or framebuffer names) to a shared GLContext. This is demonstrated in (emulates our OSX CALayer implementation): TestFBOOffThreadSharedContextMix2DemosES2NEWT, TestFBOOnThreadSharedContext1DemoES2NEWT and with the OSX JAWT OffscreenLayerSurface itself. FBO is the preferred choice. +++ Offscreen drawables can be resized while maintaining a bound GLContext (e.g. w/ GLAutoDrawable). Previously both, drawable and context, needed to be destroyed and recreated at offscreen resize. Common implementation in GLDrawableHelper is used in the implementations (NEWT's GLWindow, AWT GLCanvas, SWT GLCanvas). +++ Tested: ======= Manually run all unit tests on: - Linux x86_64 NVidia/AMD/Mesa3d(ES) - OSX x86_64 NVidia - Windows x86_64 NVidia - Android arm Mali-400/Tegra-2 No regressions. Disclaimer: =========== This feature is committed almost in one patch. Both previous commits were introducing / fixing the capabilities behavior: 90d45928186f2be99999461cfe45f76a783cc961 9036376b7806a5fc61590bf49404eb71830de92f I have to appologize for the huge size and impact (files and platforms) of this commit however, I could not find a better way to inject this feature in one sane piece. NativeWindow Details: ===================== Complete decoupling of platform impl. detail of surfaces implementing ProxySurface. Used to generalize dummy surfaces and EGL surfaces on top of a native platform surface. - ProxySurface.UpstreamSurfaceHook -> UpstreamSurfaceHook - abstract class ProxySurface -> interface ProxySurface + ProxySurfaceImpl - Misc. implementations JOGL Details: ===================== FBOObject: API Change / Simplification & Usability - Removed reference counter to remove complexity, allow user to choose. - Add 'dispose' flag for detachColorbuffer(..), allowing to keep attachment alive - Fix equals operation of Attachment - Check pre-exising GL errors - Interface Colobuffer gets lifecycle methods - Add static factory methods to create Attachments w/o FBObject instance - Reset: - Clip min size to 1 - Keep alive samplingSink, i.e. don't issue resetMSAATexture2DSink(..). It gets called at syncFramebuffer()/use(..) later on before actual usage. This allows the consumer to utilize the GL_FRONT buffer until (e.g.) swap. - misc bugfixes GLOffscreenAutoDrawable: API Change - Reloc and interfacing - class com.jogamp.opengl.OffscreenAutoDrawable -> javax.media.opengl.* interfaces GLOffscreenAutoDrawable extends GLAutoDrawable GLOffscreenAutoDrawable.FBO extends GLOffscreenAutoDrawable, GLFBODrawable - Added general implementation and FBO specialization - Replacing GLPBuffer (deprecated) .. usable for any offscreen GLDrawable via factory GLAutoDrawable: - Add 'GLDrawable getDelegatedDrawable()' - Refine documentation of setContext(..), remove disclaimer and fixme tags GLDrawableFactory: - Refine API doc and it's selection mechanism for offscreen. - Add createOffscreenDrawable(..) - Add createOffscreenAutoDrawable(..) - Add canCreateFBO(..) - Mark createGLPbuffer(..) deprectated Mark GLPBuffer deprecated New: GLFBODrawable extends GLDrawable GLCanvas (AWT and SWT): Add offscreen resize support w/o GLContext recreation GLAutoDrawableBase .. GLWindow: - Add offscreen resize support w/o GLContext recreation - Remove double swapBuffer call - GLBase/GLContext: - Add: - boolean hasBasicFBOSupport() - boolean hasFullFBOSupport() - int getMaxRenderbufferSamples() - boolean isTextureFormatBGRA8888Available() GLContext: Fix version detection and hasGLSL() - Version detection in setGLFunctionAvailability(..) - Query GL_VERSION ASAP and parse it and compare w/ given major/minor - Use parsed version if valid and lower than given _or_ given is invalid. - Use validated version for caching (procaddr, ..), version number, etc. - Fix hasGLSL() Since 'isGL2ES2()' is true if 'isGL2()' and the latter simply alows GL 1.*, we confine the result to a GL >= 2.0 on desktops. FIXME: May consider GL 1.5 w/ extensions. - return isGL2ES2(); + return isGLES2() || + isGL3() || + isGL2() && ctxMajorVersion>1 ; GLDrawableImpl: - Add 'associateContext(GLContext, boolean)' allowing impl. to have a (weak) reference list of bound context. This is was pulled up from the OSX specific drawable impl. - swapBuffersImpl() -> swapBuffersImpl(boolean doubleBuffered) and call it regardless of single buffering. This is required to propagate this event to impl. properly, i.e. FBODrawable requires a swap notification. - Clarify 'contextMadeCurrent(..)' protocol GLDrawableHelper: - Add resize and recreate offscreen drawable util method - Simplify required init/reshape calls for GLEventListener - GLGraphicsConfigurationUtil: - fixWinAttribBitsAndHwAccel: Reflect sharede context hw-accel bits - OSX has no offscreen bitmap, use pbuffer - use proper offscreen auto selection if offscreen and no modes are set EGL Context/Drawable/DrawableFactory: Abstract native platform code out of base classes - Use EGLWrappedSurface w/ UpstreamSurfaceHook to handle upstream (X11, WGL, ..) lifecycle - in case the EGL resource is hooked up on it. Invisible dummy surfaces: All platforms - size is now reduced to 64x64 and decoupled of actual generic mutable size - fix device lifecycle, no more leaks +++ OSX ==== Enable support for GLFBODrawableImpl in offscreen CALayer mode - NSOpenGLImpl: hooks to calayer native code - calayer code: - allows pbuffer and texures (FBO) - decouple size and draw calls avoiding flickering - enable auto resize of calayer tree MacOSXCGLContext: - NSOpenGLImpl: - Fix false pbuffer 'usage', validate the pointer - If !pbuffer, copy other window mode bits of caps - MacOSXCGLGraphicsConfiguration: - Only assume pbuffer if !onscreen - Remove reference of native pixelformat pointer Native code: - use 'respondsToSelector:' query before calling 'new' methods avoiding an error message where unsuported (prev. OSX versions) - if monitor refresh-rate is queried 0, set to default 60hz - add missing NSAutoreleasePool decoration +++ Android / NEWT: =============== Issue setVisible(..) w/o wait, i.e. queue on EDT, @Android surfaceChanged() callback. Otherwise we could deadlock: setVisible(..) -> EDT -> setVisibleImpl(..) -> 'GL-display'. the latter may may cause havoc while Android-EDT is blocked [until it's return]. --- doc/TODO.txt | 12 - make/build-jogl.xml | 2 +- .../config/jogl/gl-impl-CustomJavaCode-common.java | 20 + make/scripts/java-win64-dbg.bat | 4 +- make/scripts/tests-x64.bat | 45 +- make/scripts/tests.sh | 50 +- make/stub_includes/opengl/macosx-window-system.h | 11 +- src/jogl/classes/com/jogamp/opengl/FBObject.java | 882 +++++++++++++-------- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 189 +++++ .../classes/com/jogamp/opengl/GLExtensions.java | 3 + .../com/jogamp/opengl/OffscreenAutoDrawable.java | 112 --- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 41 +- .../classes/javax/media/opengl/GLAutoDrawable.java | 38 +- .../javax/media/opengl/GLAutoDrawableDelegate.java | 144 ---- src/jogl/classes/javax/media/opengl/GLBase.java | 38 + src/jogl/classes/javax/media/opengl/GLContext.java | 97 ++- .../javax/media/opengl/GLDrawableFactory.java | 128 ++- .../classes/javax/media/opengl/GLFBODrawable.java | 173 ++++ .../media/opengl/GLOffscreenAutoDrawable.java | 63 ++ src/jogl/classes/javax/media/opengl/GLPbuffer.java | 6 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 119 +-- .../classes/javax/media/opengl/awt/GLJPanel.java | 13 +- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 76 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 175 ++-- .../jogamp/opengl/GLDrawableFactoryImpl.java | 127 +-- .../classes/jogamp/opengl/GLDrawableHelper.java | 185 ++++- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 80 +- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 496 ++++++++++-- .../jogamp/opengl/GLGraphicsConfigurationUtil.java | 28 +- .../jogamp/opengl/GLOffscreenAutoDrawableImpl.java | 123 +++ src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 31 +- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 6 - .../classes/jogamp/opengl/egl/EGLDrawable.java | 135 ++-- .../jogamp/opengl/egl/EGLDrawableFactory.java | 163 +--- .../opengl/egl/EGLDummyUpstreamSurfaceHook.java | 49 ++ .../jogamp/opengl/egl/EGLExternalContext.java | 11 - .../jogamp/opengl/egl/EGLGLCapabilities.java | 5 +- .../opengl/egl/EGLGraphicsConfiguration.java | 9 +- .../jogamp/opengl/egl/EGLOnscreenContext.java | 11 - .../jogamp/opengl/egl/EGLOnscreenDrawable.java | 4 +- .../jogamp/opengl/egl/EGLPbufferContext.java | 10 - .../jogamp/opengl/egl/EGLPbufferDrawable.java | 8 +- .../jogamp/opengl/egl/EGLUpstreamSurfaceHook.java | 145 +++- .../jogamp/opengl/egl/EGLWrappedSurface.java | 26 + .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 716 ++++++++++------- .../opengl/macosx/cgl/MacOSXCGLDrawable.java | 48 +- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 71 +- .../macosx/cgl/MacOSXCGLGraphicsConfiguration.java | 21 +- .../cgl/MacOSXCGLGraphicsConfigurationFactory.java | 2 +- .../macosx/cgl/MacOSXExternalCGLContext.java | 7 +- .../macosx/cgl/MacOSXOnscreenCGLDrawable.java | 4 +- .../opengl/macosx/cgl/MacOSXPbufferCGLContext.java | 1 + .../macosx/cgl/MacOSXPbufferCGLDrawable.java | 42 +- .../windows/wgl/WindowsExternalWGLContext.java | 4 +- .../windows/wgl/WindowsExternalWGLDrawable.java | 4 +- .../opengl/windows/wgl/WindowsWGLDrawable.java | 43 +- .../windows/wgl/WindowsWGLDrawableFactory.java | 58 +- .../wgl/WindowsWGLGraphicsConfiguration.java | 29 +- .../WindowsWGLGraphicsConfigurationFactory.java | 28 +- .../opengl/x11/glx/X11ExternalGLXContext.java | 4 +- .../opengl/x11/glx/X11ExternalGLXDrawable.java | 5 +- .../jogamp/opengl/x11/glx/X11GLXDrawable.java | 7 +- .../opengl/x11/glx/X11GLXDrawableFactory.java | 63 +- .../x11/glx/X11GLXGraphicsConfiguration.java | 6 +- .../glx/X11GLXGraphicsConfigurationFactory.java | 6 +- .../opengl/x11/glx/X11PbufferGLXDrawable.java | 17 +- .../macosx/MacOSXWindowSystemInterface-calayer.m | 665 ++++++++++++++++ .../macosx/MacOSXWindowSystemInterface-pbuffer.m | 494 ------------ .../native/macosx/MacOSXWindowSystemInterface.m | 40 +- .../DelegatedUpstreamSurfaceHookMutableSize.java | 39 + ...elegatedUpstreamSurfaceHookWithSurfaceSize.java | 54 ++ .../UpstreamSurfaceHookMutableSize.java | 45 ++ .../com/jogamp/nativewindow/WrappedSurface.java | 78 -- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 99 ++- .../jogamp/nativewindow/egl/EGLGraphicsDevice.java | 4 +- .../javax/media/nativewindow/NativeSurface.java | 5 +- .../media/nativewindow/OffscreenLayerSurface.java | 3 + .../javax/media/nativewindow/ProxySurface.java | 266 ++----- .../media/nativewindow/UpstreamSurfaceHook.java | 52 ++ .../jogamp/nativewindow/ProxySurfaceImpl.java | 326 ++++++++ .../jogamp/nativewindow/WrappedSurface.java | 95 +++ .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 84 +- .../macosx/OSXDummyUpstreamSurfaceHook.java | 56 ++ .../jogamp/nativewindow/macosx/OSXUtil.java | 15 + .../windows/GDIDummyUpstreamSurfaceHook.java | 50 ++ .../jogamp/nativewindow/windows/GDISurface.java | 34 +- .../x11/X11DummyUpstreamSurfaceHook.java | 60 ++ src/nativewindow/native/macosx/OSXmisc.m | 189 +++-- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 9 + .../classes/com/jogamp/newt/opengl/GLWindow.java | 25 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 3 + src/newt/classes/jogamp/newt/OffscreenWindow.java | 31 +- src/newt/classes/jogamp/newt/WindowImpl.java | 34 +- .../jogamp/newt/driver/android/WindowDriver.java | 2 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 24 +- src/newt/native/MacWindow.m | 49 +- .../test/android/MovieCubeActivityLauncher0.java | 2 + .../android/NEWTGraphUI1pActivityLauncher.java | 22 +- .../jogl/acore/TestFBOAutoDrawableDeadlockAWT.java | 128 +++ .../jogl/acore/TestFBOAutoDrawableFactoryNEWT.java | 375 +++++++++ .../test/junit/jogl/acore/TestFBODrawableNEWT.java | 272 ------- .../test/junit/jogl/acore/TestFBOMRTNEWT01.java | 2 +- .../junit/jogl/acore/TestFBOMix2DemosES2NEWT.java | 2 +- ...tFBOOffThreadSharedContextMix2DemosES2NEWT.java | 298 +++++++ .../TestFBOOnThreadSharedContext1DemoES2NEWT.java | 273 +++++++ .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 152 ---- ...estGLAutoDrawableDelegateOnOffscrnCapsNEWT.java | 384 +++++++++ .../TestGLAutoDrawableFactoryOffscrnCapsNEWT.java | 317 ++++++++ ...TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java | 328 ++++++++ ...estGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java | 351 ++++++++ ...LAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java | 300 +++++++ .../junit/jogl/acore/TestGLCapabilities01NEWT.java | 266 ------- .../acore/TestGLContextDrawableSwitchNEWT.java | 22 +- .../junit/jogl/acore/TestGLDrawable01NEWT.java | 171 ---- .../jogl/acore/TestGLExtensionQueryOffscreen.java | 19 +- .../jogl/acore/TestNEWTCloseX11DisplayBug565.java | 46 +- .../acore/TestOffscreenLayer01GLCanvasAWT.java | 236 ++++++ .../acore/TestOffscreenLayer02NewtCanvasAWT.java | 233 ++++++ .../junit/jogl/acore/TestPBufferDeadlockAWT.java | 2 + .../junit/jogl/acore/TestSharedContextListAWT.java | 20 +- .../jogl/acore/TestSharedContextListNEWT.java | 20 +- .../jogl/acore/TestSharedContextListNEWT2.java | 14 +- .../jogl/acore/TestSharedContextNewtAWTBug523.java | 17 +- .../jogl/acore/TestSharedContextVBOES1NEWT.java | 20 +- .../jogl/acore/TestSharedContextVBOES2NEWT.java | 20 +- .../jogl/acore/TestSharedContextVBOES2NEWT2.java | 14 +- .../awt/TestBug461FBOSupersamplingSwingAWT.java | 159 ++++ .../TestBug461OffscreenSupersamplingSwingAWT.java | 157 ---- .../TestBug461PBufferSupersamplingSwingAWT.java | 159 ++++ .../junit/jogl/caps/TestMultisampleES1AWT.java | 2 +- .../junit/jogl/caps/TestMultisampleES1NEWT.java | 2 +- .../junit/jogl/caps/TestMultisampleES2NEWT.java | 2 +- .../opengl/test/junit/jogl/demos/es1/GearsES1.java | 6 + .../test/junit/jogl/demos/es1/RedSquareES1.java | 19 +- .../test/junit/jogl/demos/es2/FBOMix2DemosES2.java | 5 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 17 +- .../test/junit/jogl/demos/es2/Mix2TexturesES2.java | 216 +++++ .../test/junit/jogl/demos/es2/RedSquareES2.java | 21 +- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 27 +- .../opengl/test/junit/jogl/demos/gl2/Gears.java | 13 +- .../jogl/demos/gl2/awt/TestGLJPanelAWTBug450.java | 2 +- .../test/junit/jogl/offscreen/ReadBufferBase.java | 2 +- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 2 +- .../junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java | 2 +- .../TestGLReadBufferUtilTextureIOWrite01AWT.java | 4 +- .../TestGLReadBufferUtilTextureIOWrite01NEWT.java | 16 +- .../TestGLReadBufferUtilTextureIOWrite02AWT.java | 2 +- .../TestGLReadBufferUtilTextureIOWrite02NEWT.java | 2 +- .../util/texture/TestPNGTextureFromFileAWT.java | 2 +- .../util/texture/TestPNGTextureFromFileNEWT.java | 2 +- .../test/junit/newt/TestFocus01SwingAWTRobot.java | 21 +- .../test/junit/newt/TestFocus02SwingAWTRobot.java | 16 +- .../opengl/test/junit/newt/TestWindows01NEWT.java | 1 - .../parenting/NewtAWTReparentingKeyAdapter.java | 2 +- .../TestParentingOffscreenLayer01GLCanvasAWT.java | 211 ----- ...TestParentingOffscreenLayer02NewtCanvasAWT.java | 221 ------ .../opengl/test/junit/util/AWTRobotUtil.java | 39 +- .../opengl/test/junit/util/NEWTGLContext.java | 4 +- .../jogamp/opengl/test/junit/util/UITestCase.java | 109 ++- 159 files changed, 9357 insertions(+), 4643 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java delete mode 100644 src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java delete mode 100644 src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java create mode 100644 src/jogl/classes/javax/media/opengl/GLFBODrawable.java create mode 100644 src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java create mode 100644 src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java create mode 100644 src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java create mode 100644 src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java create mode 100644 src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m delete mode 100644 src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m create mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java create mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java create mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java delete mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java create mode 100644 src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461OffscreenSupersamplingSwingAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer02NewtCanvasAWT.java (limited to 'make/scripts') diff --git a/doc/TODO.txt b/doc/TODO.txt index 20a7a9071..0ce1fd3ac 100644 --- a/doc/TODO.txt +++ b/doc/TODO.txt @@ -1,13 +1,6 @@ Version 2.0: -- Fix ES2 detection if it fails (no egl pbuffer on nokia es2) ? - SIGG slides / video -- FBO Drawable w/ given NativeSurface - and OSX w/ JAWT - - Bug 569 - - Bug 599 - -- cleanup jocl build/jar/demos -- clean up . in jar names in all docs and tutorials - ES3 / GL 4.3 @@ -15,11 +8,6 @@ Version 2.0: WIP: -- GLPbuffer -> GLOffscreenAutoDrawable - - GLPbuffer GLDrawableFactory.createPbuffer() -> - GLOffscreenAutoDrawable GLDrawableFactory.createOffsceenAutoDrawable() - - Mark both deprecated! - - Optimize/Fix NIO caching of glMapBuffer/glUnmapBuffer - optimize the NIO caching, i.e. memory range, incr. reference count - _remove_ the cached object w/ decr. ref count, remove object diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 40859845c..a72d6c77c 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1375,7 +1375,7 @@ - + diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index b05ba2643..283a4e623 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -50,6 +50,26 @@ return null; } + @Override + public final boolean hasBasicFBOSupport() { + return _context.hasBasicFBOSupport(); + } + + @Override + public final boolean hasFullFBOSupport() { + return _context.hasFullFBOSupport(); + } + + @Override + public final int getMaxRenderbufferSamples() { + return _context.getMaxRenderbufferSamples(); + } + + @Override + public final boolean isTextureFormatBGRA8888Available() { + return _context.isTextureFormatBGRA8888Available(); + } + @Override public final GLContext getContext() { return _context; diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 510ebf4dc..b63438534 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -30,13 +30,15 @@ REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dn REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" REM set D_ARGS="-Djogl.debug.GraphicsConfiguration" +REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.GLDrawable" "-Dnativewindow.debug.GraphicsConfiguration" REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock" -set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" +set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 22cce49aa..a4207b696 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -1,9 +1,9 @@ REM scripts\java-win64-dbg.bat jogamp.newt.awt.opengl.VersionApplet REM scripts\java-win64-dbg.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win64-dbg.bat javax.media.opengl.awt.GLCanvas -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* -scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn @@ -40,13 +40,13 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT @@ -73,9 +73,9 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestMultis REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn %* @@ -96,16 +96,25 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtD REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT +scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* + +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ce04ae4dc..d2e2db375 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -32,7 +32,7 @@ MOSX=0 MOSX_MT=0 uname -a | grep -i Darwin && MOSX=1 if [ $MOSX -eq 1 ] ; then - #export NSZombieEnabled=YES + export NSZombieEnabled=YES MOSX_MT=1 fi @@ -56,11 +56,13 @@ function jrun() { #D_ARGS="-Djogl.disable.opengles" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Dnewt.debug.Window.MouseEvent" #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" + #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.fbo.force.none" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all" @@ -208,7 +210,7 @@ function testawtswt() { } # -# newt (testnoawt and testawt) +# core/newt (testnoawt and testawt) # #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* @@ -237,6 +239,26 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* + +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT + +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* + #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* @@ -331,10 +353,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* @@ -376,24 +396,6 @@ testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* -# -# FBO / .. -# - -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable01bNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableMix2DemosES2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* - # # Graph # diff --git a/make/stub_includes/opengl/macosx-window-system.h b/make/stub_includes/opengl/macosx-window-system.h index 47b51a509..c627f67de 100644 --- a/make/stub_includes/opengl/macosx-window-system.h +++ b/make/stub_includes/opengl/macosx-window-system.h @@ -13,6 +13,7 @@ #include #include #include +#include typedef int Bool; @@ -51,12 +52,13 @@ NSOpenGLPixelBuffer* createPBuffer(int renderTarget, int internalFormat, int wid Bool destroyPBuffer(NSOpenGLPixelBuffer* pBuffer); void setContextPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer); void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, GLenum colorBuffer); +Bool isNSOpenGLPixelBuffer(uint64_t object); -// NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSView* view, Bool opaque); -NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* pbuffer, Bool opaque, int texWidth, int texHeight); +NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight); void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval); void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros); -void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* glLayer); +void flushNSOpenGLLayerPBuffer(NSOpenGLLayer* layer); +void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer, NSOpenGLPixelBuffer* p, uint32_t texID, int texWidth, int texHeight); void releaseNSOpenGLLayer(NSOpenGLLayer *glLayer); void* getProcAddress(const char *procName); @@ -67,6 +69,3 @@ void setSwapInterval(NSOpenGLContext* ctx, int interval); Bool setGammaRamp(int tableSize, float* redRamp, float* greenRamp, float* blueRamp); void resetGammaRamp(); -/* returns the screen refresh rate in Hz */ -int getScreenRefreshRate(int scrn_idx); - diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java index 8a6495e6b..cc0af29a9 100644 --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java @@ -35,6 +35,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2GL3; import javax.media.opengl.GL3; import javax.media.opengl.GLBase; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -61,55 +62,33 @@ public class FBObject { protected static final boolean DEBUG = Debug.debug("FBObject"); private static final boolean forceMinimumFBOSupport = Debug.isPropertyDefined("jogl.fbo.force.min", true); + private static enum DetachAction { NONE, DISPOSE, RECREATE }; + /** - * Returns true if basic FBO support is available, otherwise false. - *

    - * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions - * ARB_ES2_compatibility, ARB_framebuffer_object, EXT_framebuffer_object or OES_framebuffer_object. - *

    - *

    - * Basic FBO support may only include one color attachment and no multisampling, - * as well as limited internal formats for renderbuffer. - *

    - * @see GLContext#hasFBO() - */ - public static final boolean supportsBasicFBO(GL gl) { - return gl.getContext().hasFBO(); - } - - /** - * Returns true if full FBO support is available, otherwise false. - *

    - * Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions - * ARB_framebuffer_object, or all of - * EXT_framebuffer_object, EXT_framebuffer_multisample, - * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. - *

    - *

    - * Full FBO support includes multiple color attachments and multisampling. - *

    + * Marker interface, denotes a color buffer attachment. + *

    Always an instance of {@link Attachment}.

    + *

    Either an instance of {@link ColorAttachment} or {@link TextureAttachment}. */ - public static final boolean supportsFullFBO(GL gl) { - return !forceMinimumFBOSupport && - ( gl.isGL3() || // GL >= 3.0 - gl.isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object - - ( gl.isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object* - gl.isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) && - gl.isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) && - gl.isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil) - ) - ) ; - } - - public static final int getMaxSamples(GL gl) { - if( supportsFullFBO(gl) ) { - int[] val = new int[] { 0 } ; - gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); - return val[0]; - } else { - return 0; - } + public static interface Colorbuffer { + /** + * Initializes the color buffer and set it's parameter, if uninitialized, i.e. name is zero. + * @return true if newly initialized, otherwise false. + * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. + */ + public boolean initialize(GL gl) throws GLException; + + /** + * Releases the color buffer if initialized, i.e. name is not zero. + * @throws GLException if buffer release fails. + */ + public void free(GL gl) throws GLException; + + /** + * Writes the internal format to the given GLCapabilities object. + * @param caps the destination for format bits + * @param rgba8Avail whether rgba8 is available + */ + public void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail); } /** Common super class of all attachments */ @@ -155,21 +134,89 @@ public class FBObject { private int name; - /** true if resource is initialized by {@link #initialize(GL)}, hence {@link #free(GL)} is allowed to free the GL resources. */ - protected boolean resourceOwner; - - private int initCounter; - protected Attachment(Type type, int iFormat, int width, int height, int name) { this.type = type; this.format = iFormat; this.width = width; this.height = height; this.name = name; - this.resourceOwner = false; - this.initCounter = 0; } + /** + * Writes the internal format to the given GLCapabilities object. + * @param caps the destination for format bits + * @param rgba8Avail whether rgba8 is available + */ + public final void formatToGLCapabilities(GLCapabilities caps, boolean rgba8Avail) { + final int _format; + switch(format) { + case GL.GL_RGBA: + _format = rgba8Avail ? GL.GL_RGBA8 : GL.GL_RGBA4; + break; + case GL.GL_RGB: + _format = rgba8Avail ? GL.GL_RGB8 : GL.GL_RGB565; + break; + default: + _format = format; + } + switch(_format) { + case GL.GL_RGBA4: + caps.setRedBits(4); + caps.setGreenBits(4); + caps.setBlueBits(4); + caps.setAlphaBits(4); + break; + case GL.GL_RGB5_A1: + caps.setRedBits(5); + caps.setGreenBits(5); + caps.setBlueBits(5); + caps.setAlphaBits(1); + break; + case GL.GL_RGB565: + caps.setRedBits(5); + caps.setGreenBits(6); + caps.setBlueBits(5); + caps.setAlphaBits(0); + break; + case GL.GL_RGB8: + caps.setRedBits(8); + caps.setGreenBits(8); + caps.setBlueBits(8); + caps.setAlphaBits(0); + break; + case GL.GL_RGBA8: + caps.setRedBits(8); + caps.setGreenBits(8); + caps.setBlueBits(8); + caps.setAlphaBits(8); + break; + case GL.GL_DEPTH_COMPONENT16: + caps.setDepthBits(16); + break; + case GL.GL_DEPTH_COMPONENT24: + caps.setDepthBits(24); + break; + case GL.GL_DEPTH_COMPONENT32: + caps.setDepthBits(32); + break; + case GL.GL_STENCIL_INDEX1: + caps.setStencilBits(1); + break; + case GL.GL_STENCIL_INDEX4: + caps.setStencilBits(4); + break; + case GL.GL_STENCIL_INDEX8: + caps.setStencilBits(8); + break; + case GL.GL_DEPTH24_STENCIL8: + caps.setDepthBits(24); + caps.setStencilBits(8); + break; + default: + throw new IllegalArgumentException("format invalid: 0x"+Integer.toHexString(format)); + } + } + /** width of attachment */ public final int getWidth() { return width; } /** height of attachment */ @@ -180,45 +227,31 @@ public class FBObject { public final int getName() { return name; } /* pp */ final void setName(int n) { name = n; } - public final int getInitCounter() { return initCounter; } - /** - * Initializes the attachment buffer and set it's parameter, if uninitialized, i.e. name is zero. - *

    Implementation employs an initialization counter, hence it can be paired recursively with {@link #free(GL)}.

    - * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. - */ - public void initialize(GL gl) throws GLException { - initCounter++; - /* - super.initialize(gl); - if(1 == getInitCounter() && 0 == getName() ) { + * Initializes the attachment and set it's parameter, if uninitialized, i.e. name is zero. + *
    +            final boolean init = 0 == name;
    +            if( init ) {
                     do init ..
    -                freeResources = true; // if all OK
                 }
    -            */
    -        }
    +            return init;
    +         * 
    + * @return true if newly initialized, otherwise false. + * @throws GLException if buffer generation or setup fails. The just created buffer name will be deleted in this case. + */ + public abstract boolean initialize(GL gl) throws GLException; /** - * Releases the attachment buffer if initialized, i.e. name is zero. - *

    Implementation employs an initialization counter, hence it can be paired recursively with {@link #initialize(GL)}.

    - * @throws GLException if buffer release fails. - */ - public void free(GL gl) throws GLException { - /* - if(1 == getInitCounter() && freeResources && .. ) { + * Releases the attachment if initialized, i.e. name is not zero. + *
    +            if(0 != name) {
                     do free ..
    -            }
    -            super.free(gl);
    -            */
    -            initCounter--;
    -            if(0 == initCounter) {
    -                resourceOwner = false;
                     name = 0;
                 }
    -            if(DEBUG) {
    -                System.err.println("Attachment.free: "+this);
    -            }
    -        }
    +         * 
    + * @throws GLException if buffer release fails. + */ + public abstract void free(GL gl) throws GLException; /** *

    @@ -232,9 +265,9 @@ public class FBObject { if( ! ( o instanceof Attachment ) ) return false; final Attachment a = (Attachment)o; return type == a.type && - format == a.format || - width == a.width || - height== a.height || + format == a.format && + width == a.width && + height== a.height && name == a.name ; } @@ -259,8 +292,7 @@ public class FBObject { public String toString() { return getClass().getSimpleName()+"[type "+type+", format 0x"+Integer.toHexString(format)+", "+width+"x"+height+ - ", name 0x"+Integer.toHexString(name)+", obj 0x"+Integer.toHexString(objectHashCode())+ - ", resOwner "+resourceOwner+", initCount "+initCounter+"]"; + ", name 0x"+Integer.toHexString(name)+", obj 0x"+Integer.toHexString(objectHashCode())+"]"; } public static Type getType(int attachmentPoint, int maxColorAttachments) { @@ -277,7 +309,7 @@ public class FBObject { } } } - + /** Other renderbuffer attachment which maybe a colorbuffer, depth or stencil. */ public static class RenderAttachment extends Attachment { private int samples; @@ -339,14 +371,13 @@ public class FBObject { } @Override - public void initialize(GL gl) throws GLException { - super.initialize(gl); - if( 1 == getInitCounter() && 0 == getName() ) { + public boolean initialize(GL gl) throws GLException { + final boolean init = 0 == getName(); + if( init ) { + int glerr = checkPreGLError(gl); + final int[] name = new int[] { -1 }; gl.glGenRenderbuffers(1, name, 0); - if( 0 == name[0] ) { - throw new GLException("null renderbuffer, "+this); - } setName(name[0]); gl.glBindRenderbuffer(GL.GL_RENDERBUFFER, getName()); @@ -355,43 +386,37 @@ public class FBObject { } else { gl.glRenderbufferStorage(GL.GL_RENDERBUFFER, format, getWidth(), getHeight()); } - int glerr = gl.glGetError(); + glerr = gl.glGetError(); if(GL.GL_NO_ERROR != glerr) { gl.glDeleteRenderbuffers(1, name, 0); setName(0); throw new GLException("GL Error 0x"+Integer.toHexString(glerr)+" while creating "+this); } - resourceOwner = true; if(DEBUG) { System.err.println("Attachment.init: "+this); } } + return init; } @Override public void free(GL gl) { - if(1 == getInitCounter() && resourceOwner && 0 != getName() ) { - final int[] name = new int[] { getName() }; + final int[] name = new int[] { getName() }; + if( 0 != name[0] ) { gl.glDeleteRenderbuffers(1, name, 0); + setName(0); + if(DEBUG) { + System.err.println("Attachment.free: "+this); + } } - super.free(gl); } public String toString() { return getClass().getSimpleName()+"[type "+type+", format 0x"+Integer.toHexString(format)+", samples "+samples+", "+getWidth()+"x"+getHeight()+ - ", name 0x"+Integer.toHexString(getName())+", obj 0x"+Integer.toHexString(objectHashCode())+ - ", resOwner "+resourceOwner+", initCount "+getInitCounter()+"]"; + ", name 0x"+Integer.toHexString(getName())+", obj 0x"+Integer.toHexString(objectHashCode())+"]"; } } - /** - * Marker interface, denotes a color buffer attachment. - *

    Always an instance of {@link Attachment}.

    - *

    Either an instance of {@link ColorAttachment} or {@link TextureAttachment}. - */ - public static interface Colorbuffer { - } - /** Color render buffer attachment */ public static class ColorAttachment extends RenderAttachment implements Colorbuffer { public ColorAttachment(int iFormat, int samples, int width, int height, int name) { @@ -444,9 +469,11 @@ public class FBObject { * @throws GLException if texture generation and setup fails. The just created texture name will be deleted in this case. */ @Override - public void initialize(GL gl) throws GLException { - super.initialize(gl); - if( 1 == getInitCounter() && 0 == getName() ) { + public boolean initialize(GL gl) throws GLException { + final boolean init = 0 == getName(); + if( init ) { + int glerr = checkPreGLError(gl); + final int[] name = new int[] { -1 }; gl.glGenTextures(1, name, 0); if(0 == name[0]) { @@ -468,31 +495,111 @@ public class FBObject { if( 0 < wrapT ) { gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, wrapT); } - int glerr = gl.glGetError(); + glerr = gl.glGetError(); if(GL.GL_NO_ERROR != glerr) { gl.glDeleteTextures(1, name, 0); setName(0); throw new GLException("GL Error 0x"+Integer.toHexString(glerr)+" while creating "+this); } - resourceOwner = true; - } - if(DEBUG) { - System.err.println("Attachment.init: "+this); + if(DEBUG) { + System.err.println("Attachment.init: "+this); + } } + return init; } @Override public void free(GL gl) { - if(1 == getInitCounter() && resourceOwner && 0 != getName() ) { - final int[] name = new int[] { getName() }; + final int[] name = new int[] { getName() }; + if( 0 != name[0] ) { gl.glDeleteTextures(1, name, 0); + setName(0); + if(DEBUG) { + System.err.println("Attachment.free: "+this); + } } - super.free(gl); + } + } + + /** + * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}, + * selecting the texture data type and format automatically. + * + *

    Using default min/mag filter {@link GL#GL_NEAREST} and default wrapS/wrapT {@link GL#GL_CLAMP_TO_EDGE}.

    + * + * @param glp the chosen {@link GLProfile} + * @param alpha set to true if you request alpha channel, otherwise false; + * @param width texture width + * @param height texture height + * @return the created and uninitialized color {@link TextureAttachment} + */ + public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height) { + return createColorTextureAttachment(glp, alpha, width, height, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + } + + /** + * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}, + * selecting the texture data type and format automatically. + * + * @param glp the chosen {@link GLProfile} + * @param alpha set to true if you request alpha channel, otherwise false; + * @param width texture width + * @param height texture height + * @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER} + * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} + * @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S} + * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} + * @return the created and uninitialized color {@link TextureAttachment} + */ + public static final TextureAttachment createColorTextureAttachment(GLProfile glp, boolean alpha, int width, int height, + int magFilter, int minFilter, int wrapS, int wrapT) { + final int textureInternalFormat, textureDataFormat, textureDataType; + if(glp.isGLES()) { + textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; + textureDataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; + textureDataType = GL.GL_UNSIGNED_BYTE; + } else { + textureInternalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8; + textureDataFormat = alpha ? GL.GL_BGRA : GL.GL_RGB; + textureDataType = alpha ? GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV : GL.GL_UNSIGNED_BYTE; + } + return createColorTextureAttachment(textureInternalFormat, width, height, textureDataFormat, textureDataType, magFilter, minFilter, wrapS, wrapT); + } + + /** + * Creates a color {@link TextureAttachment}, i.e. type {@link Type#COLOR_TEXTURE}. + * + * @param internalFormat internalFormat parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} + * @param width texture width + * @param height texture height + * @param dataFormat format parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} + * @param dataType type parameter to {@link GL#glTexImage2D(int, int, int, int, int, int, int, int, long)} + * @param magFilter if > 0 value for {@link GL#GL_TEXTURE_MAG_FILTER} + * @param minFilter if > 0 value for {@link GL#GL_TEXTURE_MIN_FILTER} + * @param wrapS if > 0 value for {@link GL#GL_TEXTURE_WRAP_S} + * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} + * @return the created and uninitialized color {@link TextureAttachment} + */ + public static final TextureAttachment createColorTextureAttachment(int internalFormat, int width, int height, int dataFormat, int dataType, + int magFilter, int minFilter, int wrapS, int wrapT) { + return new TextureAttachment(Type.COLOR_TEXTURE, internalFormat, width, height, dataFormat, dataType, + magFilter, minFilter, wrapS, wrapT, 0 /* name */); + } + + private static boolean hasAlpha(int format) { + switch(format) { + case GL.GL_RGBA8: + case GL.GL_RGBA4: + case GL.GL_RGBA: + case GL.GL_BGRA: + case 4: + return true; + default: + return false; } } private boolean initialized; - private boolean basicFBOSupport; private boolean fullFBOSupport; private boolean rgba8Avail; private boolean depth24Avail; @@ -523,6 +630,9 @@ public class FBObject { // private final void validateColorAttachmentPointRange(int point) { + if(!initialized) { + throw new GLException("FBO not initialized"); + } if(maxColorAttachments != colorAttachmentPoints.length) { throw new InternalError("maxColorAttachments "+maxColorAttachments+", array.lenght "+colorAttachmentPoints); } @@ -621,7 +731,6 @@ public class FBObject { this.initialized = false; // TBD @ init - this.basicFBOSupport = false; this.fullFBOSupport = false; this.rgba8Avail = false; this.depth24Avail = false; @@ -657,14 +766,11 @@ public class FBObject { private void init(GL gl, int width, int height, int samples) throws GLException { if(initialized) { throw new GLException("FBO already initialized"); - } - fullFBOSupport = supportsFullFBO(gl); - - if( !fullFBOSupport && !supportsBasicFBO(gl) ) { + } + if( !gl.hasBasicFBOSupport() ) { throw new GLException("FBO not supported w/ context: "+gl.getContext()+", "+this); } - - basicFBOSupport = true; + fullFBOSupport = gl.hasFullFBOSupport(); rgba8Avail = gl.isGL2GL3() || gl.isExtensionAvailable(GLExtensions.OES_rgb8_rgba8); depth24Avail = fullFBOSupport || gl.isExtensionAvailable(GLExtensions.OES_depth24); @@ -680,10 +786,7 @@ public class FBObject { int val[] = new int[1]; - int glerr = gl.glGetError(); - if(DEBUG && GL.GL_NO_ERROR != glerr) { - System.err.println("FBObject.init-preexisting.0 GL Error 0x"+Integer.toHexString(glerr)); - } + int glerr = checkPreGLError(gl); int realMaxColorAttachments = 1; maxColorAttachments = 1; @@ -703,16 +806,7 @@ public class FBObject { colorAttachmentPoints = new Colorbuffer[maxColorAttachments]; colorAttachmentCount = 0; - maxSamples = 0; - if(fullFBOSupport) { - gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); - glerr = gl.glGetError(); - if(GL.GL_NO_ERROR == glerr) { - maxSamples = val[0]; - } else if(DEBUG) { - System.err.println("FBObject.init-GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr)); - } - } + maxSamples = gl.getMaxRenderbufferSamples(); if(!forceMinimumFBOSupport) { gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0); maxTextureSize = val[0]; @@ -733,10 +827,9 @@ public class FBObject { this.samples = samples <= maxSamples ? samples : maxSamples; if(DEBUG) { - System.err.println("FBObject "+width+"x"+height+", "+samples+" -> "+samples+" samples"); - System.err.println("basicFBOSupport: "+basicFBOSupport); + System.err.println("FBObject "+width+"x"+height+", "+samples+" -> "+this.samples+" samples"); System.err.println("fullFBOSupport: "+fullFBOSupport); - System.err.println("maxColorAttachments: "+maxColorAttachments+"/"+realMaxColorAttachments); + System.err.println("maxColorAttachments: "+maxColorAttachments+"/"+realMaxColorAttachments+" [capped/real]"); System.err.println("maxSamples: "+maxSamples); System.err.println("maxTextureSize: "+maxTextureSize); System.err.println("maxRenderbufferSize: "+maxRenderbufferSize); @@ -761,12 +854,8 @@ public class FBObject { throw new GLException("size "+width+"x"+height+" exceeds on of the maxima [texture "+maxTextureSize+", renderbuffer "+maxRenderbufferSize+"]"); } - if(null != samplesSink) { - // init sampling sink - samplesSink.reset(gl, width, height); - resetMSAATexture2DSink(gl); - } - + resetMSAATexture2DSink(gl); + // generate fbo .. gl.glGenFramebuffers(1, val, 0); fbName = val[0]; @@ -780,7 +869,8 @@ public class FBObject { if(!gl.glIsFramebuffer(fbName)) { checkNoError(gl, GL.GL_INVALID_VALUE, "FBObject Init.isFB"); // throws GLException } - bound = true; + bound = true; + samplesSinkDirty = true; initialized = true; updateStatus(gl); @@ -797,7 +887,7 @@ public class FBObject { * to match the new given parameters. *

    *

    - * Currently incompatibility and hence recreation is given if + * Incompatibility and hence recreation is forced if * the size or sample count doesn't match for subsequent calls. *

    * @@ -820,17 +910,17 @@ public class FBObject { * to match the new given parameters. *

    *

    - * Currently incompatibility and hence recreation is given if - * the size or sample count doesn't match for subsequent calls. + * Currently incompatibility and hence recreation of the attachments will be performed + * if the size or sample count doesn't match for subsequent calls. *

    * *

    Leaves the FBO bound state untouched

    * * @param gl the current GL context - * @param newWidth - * @param newHeight + * @param newWidth the new width, it's minimum is capped to 1 + * @param newHeight the new height, it's minimum is capped to 1 * @param newSamples if > 0, MSAA will be used, otherwise no multisampling. Will be capped to {@link #getMaxSamples()}. - * @throws GLException in case of an error + * @throws GLException in case of an error, i.e. size too big, etc .. */ public final void reset(GL gl, int newWidth, int newHeight, int newSamples) { if(!initialized) { @@ -841,13 +931,15 @@ public class FBObject { newSamples = newSamples <= maxSamples ? newSamples : maxSamples; // clamp if( newWidth != width || newHeight != height || newSamples != samples ) { + if(0>=newWidth) { newWidth = 1; } + if(0>=newHeight) { newHeight = 1; } if(newWidth > 2 + maxTextureSize || newHeight> 2 + maxTextureSize || newWidth > maxRenderbufferSize || newHeight> maxRenderbufferSize ) { throw new GLException("size "+width+"x"+height+" exceeds on of the maxima [texture "+maxTextureSize+", renderbuffer "+maxRenderbufferSize+"]"); } if(DEBUG) { - System.err.println("FBObject.reset - START - "+this); + System.err.println("FBObject.reset - START - "+width+"x"+height+", "+samples+" -> "+newWidth+"x"+newHeight+", "+newSamples+"; "+this); } final boolean wasBound = isBound(); @@ -856,11 +948,18 @@ public class FBObject { height = newHeight; samples = newSamples; detachAllImpl(gl, true , true); - resetMSAATexture2DSink(gl); - if(wasBound) { - bind(gl); - } else { + /** + * Postpone reset of samplesSink until syncFramebuffer, + * issued at use(..) method (swapBuffer usually initiates it). + * This allows another thread to still use the 'samplesSinkTexture' + * until swapBuffer happens and does not invalidate the GL_FRONT + * FBO (framebuffer & texture). + resetMSAATexture2DSink(gl); + */ + samplesSinkDirty = true; + + if(!wasBound) { unbind(gl); } @@ -870,6 +969,28 @@ public class FBObject { } } + /** + * Writes the internal format of the attachments to the given GLCapabilities object. + * @param caps the destination for format bits + */ + public final void formatToGLCapabilities(GLCapabilities caps) { + caps.setSampleBuffers(samples > 0); + caps.setNumSamples(samples); + caps.setDepthBits(0); + caps.setStencilBits(0); + + final Colorbuffer cb = samples > 0 ? getSamplingSink() : getColorbuffer(0); + if(null != cb) { + cb.formatToGLCapabilities(caps, rgba8Avail); + } + if(null != depth) { + depth.formatToGLCapabilities(caps, rgba8Avail); + } + if(null != stencil && stencil != depth) { + stencil.formatToGLCapabilities(caps, rgba8Avail); + } + } + /** * Note that the status may reflect an incomplete state during transition of attachments. * @return The FB status. {@link GL.GL_FRAMEBUFFER_COMPLETE} if ok, otherwise return GL FBO error state or -1 @@ -954,6 +1075,15 @@ public class FBObject { } } + private static int checkPreGLError(GL gl) { + int glerr = gl.glGetError(); + if(DEBUG && GL.GL_NO_ERROR != glerr) { + System.err.println("Pre-existing GL error: 0x"+Integer.toHexString(glerr)); + Thread.dumpStack(); + } + return glerr; + } + private final boolean checkNoError(GL gl, int err, String exceptionMessage) throws GLException { if(GL.GL_NO_ERROR != err) { if(null != gl) { @@ -974,7 +1104,7 @@ public class FBObject { } /** - * Attaches a Texture2D Color Buffer to this FBO's instance at the given attachment point, + * Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point, * selecting the texture data type and format automatically. * *

    Using default min/mag filter {@link GL#GL_NEAREST} and default wrapS/wrapT {@link GL#GL_CLAMP_TO_EDGE}.

    @@ -986,13 +1116,15 @@ public class FBObject { * @param alpha set to true if you request alpha channel, otherwise false; * @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen + * @see #createColorTextureAttachment(GLProfile, boolean, int, int) */ public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, boolean alpha) throws GLException { - return attachTexture2D(gl, attachmentPoint, alpha, GL.GL_NEAREST, GL.GL_NEAREST, GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE); + return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, + createColorTextureAttachment(gl.getGLProfile(), alpha, width, height)); } /** - * Attaches a Texture2D Color Buffer to this FBO's instance at the given attachment point, + * Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point, * selecting the texture data type and format automatically. * *

    Leaves the FBO bound.

    @@ -1006,23 +1138,15 @@ public class FBObject { * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen + * @see #createColorTextureAttachment(GLProfile, boolean, int, int, int, int, int, int) */ public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, boolean alpha, int magFilter, int minFilter, int wrapS, int wrapT) throws GLException { - final int textureInternalFormat, textureDataFormat, textureDataType; - if(gl.isGLES()) { - textureInternalFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; - textureDataFormat = alpha ? GL.GL_RGBA : GL.GL_RGB; - textureDataType = GL.GL_UNSIGNED_BYTE; - } else { - textureInternalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8; - textureDataFormat = alpha ? GL.GL_BGRA : GL.GL_RGB; - textureDataType = alpha ? GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV : GL.GL_UNSIGNED_BYTE; - } - return attachTexture2D(gl, attachmentPoint, textureInternalFormat, textureDataFormat, textureDataType, magFilter, minFilter, wrapS, wrapT); + return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, + createColorTextureAttachment(gl.getGLProfile(), alpha, width, height, magFilter, minFilter, wrapS, wrapT)); } /** - * Attaches a Texture2D Color Buffer to this FBO's instance at the given attachment point. + * Attaches a {@link Colorbuffer}, i.e. {@link TextureAttachment}, to this FBO's instance at the given attachment point. * *

    Leaves the FBO bound.

    * @@ -1037,66 +1161,33 @@ public class FBObject { * @param wrapT if > 0 value for {@link GL#GL_TEXTURE_WRAP_T} * @return TextureAttachment instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen + * @see #createColorTextureAttachment(int, int, int, int, int, int, int, int, int) */ public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, int internalFormat, int dataFormat, int dataType, int magFilter, int minFilter, int wrapS, int wrapT) throws GLException { - return attachTexture2D(gl, attachmentPoint, - new TextureAttachment(Type.COLOR_TEXTURE, internalFormat, width, height, dataFormat, dataType, - magFilter, minFilter, wrapS, wrapT, 0 /* name */)); + return (TextureAttachment)attachColorbuffer(gl, attachmentPoint, + createColorTextureAttachment(internalFormat, width, height, dataFormat, dataType, magFilter, minFilter, wrapS, wrapT)); } /** - * Attaches a Texture2D Color Buffer to this FBO's instance at the given attachment point. + * Creates a {@link ColorAttachment}, selecting the format automatically. * - *

    - * In case the passed TextureAttachment texA is uninitialized, i.e. it's texture name is zero, - * a new texture name is generated and setup w/ the texture parameter.
    - * Otherwise, i.e. texture name is not zero, the passed TextureAttachment texA is - * considered complete and assumed matching this FBO requirement. A GL error may occur is the latter is untrue. - *

    - * - *

    Leaves the FBO bound.

    - * - * @param gl the current GL context - * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] - * @param texA the to be attached {@link TextureAttachment}. Maybe complete or uninitialized, see above. - * @return the passed TextureAttachment texA instance describing the new attached texture colorbuffer if bound and configured successfully, otherwise GLException is thrown - * @throws GLException in case the texture colorbuffer couldn't be allocated or MSAA has been chosen + * @param alpha set to true if you request alpha channel, otherwise false; + * @return uninitialized ColorAttachment instance describing the new attached colorbuffer */ - public final TextureAttachment attachTexture2D(GL gl, int attachmentPoint, TextureAttachment texA) throws GLException { - validateAddColorAttachment(attachmentPoint, texA); - - if(samples>0) { - removeColorAttachment(attachmentPoint, texA); - throw new GLException("Texture2D not supported w/ MSAA. If you have enabled MSAA with exisiting texture attachments, you may want to detach them via detachAllTexturebuffer(gl)."); - } - - texA.initialize(gl); - addColorAttachment(attachmentPoint, texA); - - bind(gl); - - // Set up the color buffer for use as a renderable texture: - gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, - GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, - GL.GL_TEXTURE_2D, texA.getName(), 0); - - if(!ignoreStatus) { - updateStatus(gl); - if(!isStatusValid()) { - detachColorbuffer(gl, attachmentPoint); - throw new GLException("attachTexture2D "+texA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); - } - } - if(DEBUG) { - System.err.println("FBObject.attachTexture2D: "+this); + public final ColorAttachment createColorAttachment(boolean alpha) { + final int internalFormat; + if( rgba8Avail ) { + internalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8 ; + } else { + internalFormat = alpha ? GL.GL_RGBA4 : GL.GL_RGB565; } - return texA; + return new ColorAttachment(internalFormat, samples, width, height, 0); } - + /** - * Attaches a Color Buffer to this FBO's instance at the given attachment point, + * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point, * selecting the format automatically. * *

    Leaves the FBO bound.

    @@ -1106,19 +1197,14 @@ public class FBObject { * @param alpha set to true if you request alpha channel, otherwise false; * @return ColorAttachment instance describing the new attached colorbuffer if bound and configured successfully, otherwise GLException is thrown * @throws GLException in case the colorbuffer couldn't be allocated + * @see #createColorAttachment(boolean) */ public final ColorAttachment attachColorbuffer(GL gl, int attachmentPoint, boolean alpha) throws GLException { - final int internalFormat; - if( rgba8Avail ) { - internalFormat = alpha ? GL.GL_RGBA8 : GL.GL_RGB8 ; - } else { - internalFormat = alpha ? GL.GL_RGBA4 : GL.GL_RGB565; - } - return attachColorbuffer(gl, attachmentPoint, internalFormat); + return (ColorAttachment) attachColorbuffer(gl, attachmentPoint, createColorAttachment(alpha)); } /** - * Attaches a Color Buffer to this FBO's instance at the given attachment point. + * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment}, to this FBO's instance at the given attachment point. * *

    Leaves the FBO bound.

    * @@ -1135,46 +1221,80 @@ public class FBObject { throw new IllegalArgumentException("colorformat invalid: 0x"+Integer.toHexString(internalFormat)+", "+this); } - return attachColorbuffer(gl, attachmentPoint, new ColorAttachment(internalFormat, samples, width, height, 0)); + return (ColorAttachment) attachColorbuffer(gl, attachmentPoint, new ColorAttachment(internalFormat, samples, width, height, 0)); } /** - * Attaches a Color Buffer to this FBO's instance at the given attachment point. + * Attaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}, + * to this FBO's instance at the given attachment point. * + *

    + * If {@link Colorbuffer} is a {@link TextureAttachment} and is uninitialized, i.e. it's texture name is zero, + * a new texture name is generated and setup w/ the texture parameter.
    + * Otherwise, i.e. texture name is not zero, the passed TextureAttachment texA is + * considered complete and assumed matching this FBO requirement. A GL error may occur is the latter is untrue. + *

    + * *

    Leaves the FBO bound.

    * * @param gl * @param attachmentPoint the color attachment point ranging from [0..{@link #getMaxColorAttachments()}-1] - * @param colA the template for the new {@link ColorAttachment} - * @return ColorAttachment instance describing the new attached colorbuffer if bound and configured successfully, otherwise GLException is thrown - * @throws GLException in case the colorbuffer couldn't be allocated + * @param colbuf the to be attached {@link Colorbuffer} + * @return newly attached {@link Colorbuffer} instance if bound and configured successfully, otherwise GLException is thrown + * @throws GLException in case the colorbuffer couldn't be allocated or MSAA has been chosen in case of a {@link TextureAttachment} */ - public final ColorAttachment attachColorbuffer(GL gl, int attachmentPoint, ColorAttachment colA) throws GLException { - validateAddColorAttachment(attachmentPoint, colA); - - colA.initialize(gl); - addColorAttachment(attachmentPoint, colA); + public final Colorbuffer attachColorbuffer(GL gl, int attachmentPoint, Colorbuffer colbuf) throws GLException { + validateAddColorAttachment(attachmentPoint, colbuf); - bind(gl); + final boolean initializedColorbuf = colbuf.initialize(gl); + addColorAttachment(attachmentPoint, colbuf); - // Attach the color buffer - gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, - GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, - GL.GL_RENDERBUFFER, colA.getName()); + bind(gl); - if(!ignoreStatus) { - updateStatus(gl); - if(!isStatusValid()) { - detachColorbuffer(gl, attachmentPoint); - throw new GLException("attachColorbuffer "+colA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); + if(colbuf instanceof TextureAttachment) { + final TextureAttachment texA = (TextureAttachment) colbuf; + + if(samples>0) { + removeColorAttachment(attachmentPoint, texA); + if(initializedColorbuf) { + texA.free(gl); + } + throw new GLException("Texture2D not supported w/ MSAA. If you have enabled MSAA with exisiting texture attachments, you may want to detach them via detachAllTexturebuffer(gl)."); + } + + // Set up the color buffer for use as a renderable texture: + gl.glFramebufferTexture2D(GL.GL_FRAMEBUFFER, + GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, + GL.GL_TEXTURE_2D, texA.getName(), 0); + + if(!ignoreStatus) { + updateStatus(gl); + if(!isStatusValid()) { + detachColorbuffer(gl, attachmentPoint, true); + throw new GLException("attachTexture2D "+texA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); + } + } + } else if(colbuf instanceof ColorAttachment) { + final ColorAttachment colA = (ColorAttachment) colbuf; + + // Attach the color buffer + gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, + GL.GL_COLOR_ATTACHMENT0 + attachmentPoint, + GL.GL_RENDERBUFFER, colA.getName()); + + if(!ignoreStatus) { + updateStatus(gl); + if(!isStatusValid()) { + detachColorbuffer(gl, attachmentPoint, true); + throw new GLException("attachColorbuffer "+colA+" at "+attachmentPoint+" failed "+getStatusString()+", "+this); + } } } if(DEBUG) { - System.err.println("FBObject.attachColorbuffer: "+this); + System.err.println("FBObject.attachColorbuffer: [attachmentPoint "+attachmentPoint+", colbuf "+colbuf+"]: "+this); } - return colA; + return colbuf; } - /** * Attaches one depth, stencil or packed-depth-stencil buffer to this FBO's instance, @@ -1355,33 +1475,39 @@ public class FBObject { if(!ignoreStatus) { updateStatus(gl); if( !isStatusValid() ) { - detachRenderbuffer(gl, atype); + detachRenderbuffer(gl, atype, true); throw new GLException("renderbuffer attachment failed: "+this.getStatusString()); } } if(DEBUG) { - System.err.println("FBObject.attachRenderbuffer: "+this); - } + System.err.println("FBObject.attachRenderbuffer: [attachmentType "+atype+"]: "+this); + } } /** + * Detaches a {@link Colorbuffer}, i.e. {@link ColorAttachment} or {@link TextureAttachment}. *

    Leaves the FBO bound!

    + * * @param gl - * @param ca + * @param attachmentPoint + * @param dispose true if the Colorbuffer shall be disposed + * @return the detached Colorbuffer * @throws IllegalArgumentException */ - public final void detachColorbuffer(GL gl, int attachmentPoint) throws IllegalArgumentException { - if(null == detachColorbufferImpl(gl, attachmentPoint, false)) { + public final Colorbuffer detachColorbuffer(GL gl, int attachmentPoint, boolean dispose) throws IllegalArgumentException { + final Colorbuffer res = detachColorbufferImpl(gl, attachmentPoint, dispose ? DetachAction.DISPOSE : DetachAction.NONE); + if(null == res) { throw new IllegalArgumentException("ColorAttachment at "+attachmentPoint+", not attached, "+this); } if(DEBUG) { - System.err.println("FBObject.detachColorbuffer: [attachmentPoint "+attachmentPoint+"]: "+this); + System.err.println("FBObject.detachColorbuffer: [attachmentPoint "+attachmentPoint+", dispose "+dispose+"]: "+res+", "+this); } + return res; } - private final Colorbuffer detachColorbufferImpl(GL gl, int attachmentPoint, boolean recreate) { - final Colorbuffer colbuf = colorAttachmentPoints[attachmentPoint]; // shortcut, don't validate here + private final Colorbuffer detachColorbufferImpl(GL gl, int attachmentPoint, DetachAction detachAction) { + Colorbuffer colbuf = colorAttachmentPoints[attachmentPoint]; // shortcut, don't validate here if(null == colbuf) { return null; @@ -1389,6 +1515,8 @@ public class FBObject { bind(gl); + removeColorAttachment(attachmentPoint, colbuf); + if(colbuf instanceof TextureAttachment) { final TextureAttachment texA = (TextureAttachment) colbuf; if( 0 != texA.getName() ) { @@ -1397,11 +1525,22 @@ public class FBObject { GL.GL_TEXTURE_2D, 0, 0); gl.glBindTexture(GL.GL_TEXTURE_2D, 0); } - texA.free(gl); - removeColorAttachment(attachmentPoint, texA); - if(recreate) { - texA.setSize(width, height); - attachTexture2D(gl, attachmentPoint, texA); + switch(detachAction) { + case DISPOSE: + texA.free(gl); + break; + case RECREATE: + texA.free(gl); + if(samples == 0) { + // stay non MSAA + texA.setSize(width, height); + } else { + // switch to MSAA + colbuf = createColorAttachment(hasAlpha(texA.format)); + } + attachColorbuffer(gl, attachmentPoint, colbuf); + break; + default: } } else if(colbuf instanceof ColorAttachment) { final ColorAttachment colA = (ColorAttachment) colbuf; @@ -1410,12 +1549,30 @@ public class FBObject { GL.GL_COLOR_ATTACHMENT0+attachmentPoint, GL.GL_RENDERBUFFER, 0); } - colA.free(gl); - removeColorAttachment(attachmentPoint, colbuf); - if(recreate) { - colA.setSize(width, height); - colA.setSamples(samples); - attachColorbuffer(gl, attachmentPoint, colA); + switch(detachAction) { + case DISPOSE: + colA.free(gl); + break; + case RECREATE: + colA.free(gl); + if(samples > 0) { + // stay MSAA + colA.setSize(width, height); + colA.setSamples(samples); + } else { + // switch to non MSAA + if(null != samplesSinkTexture) { + colbuf = createColorTextureAttachment(samplesSinkTexture.format, width, height, + samplesSinkTexture.dataFormat, samplesSinkTexture.dataType, + samplesSinkTexture.magFilter, samplesSinkTexture.minFilter, + samplesSinkTexture.wrapS, samplesSinkTexture.wrapT); + } else { + colbuf = createColorTextureAttachment(gl.getGLProfile(), true, width, height); + } + } + attachColorbuffer(gl, attachmentPoint, colbuf); + break; + default: } } return colbuf; @@ -1424,10 +1581,14 @@ public class FBObject { /** * * @param gl + * @param dispose true if the Colorbuffer shall be disposed * @param reqAType {@link Type#DEPTH}, {@link Type#DEPTH} or {@link Type#DEPTH_STENCIL} */ - public final void detachRenderbuffer(GL gl, Attachment.Type atype) throws IllegalArgumentException { - detachRenderbufferImpl(gl, atype, false); + public final void detachRenderbuffer(GL gl, Attachment.Type atype, boolean dispose) throws IllegalArgumentException { + detachRenderbufferImpl(gl, atype, dispose ? DetachAction.DISPOSE : DetachAction.NONE); + if(DEBUG) { + System.err.println("FBObject.detachRenderbuffer: [attachmentType "+atype+", dispose "+dispose+"]: "+this); + } } public final boolean isDepthStencilPackedFormat() { @@ -1439,7 +1600,7 @@ public class FBObject { return res; } - private final void detachRenderbufferImpl(GL gl, Attachment.Type atype, boolean recreate) throws IllegalArgumentException { + private final void detachRenderbufferImpl(GL gl, Attachment.Type atype, DetachAction detachAction) throws IllegalArgumentException { switch ( atype ) { case DEPTH: case STENCIL: @@ -1485,8 +1646,14 @@ public class FBObject { if( 0 != depth.getName() ) { gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, 0); } - depth.free(gl); - if(!recreate) { + switch(detachAction) { + case DISPOSE: + case RECREATE: + depth.free(gl); + break; + default: + } + if(DetachAction.RECREATE != detachAction) { depth = null; } break; @@ -1495,8 +1662,14 @@ public class FBObject { if(0 != stencil.getName()) { gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0); } - stencil.free(gl); - if(!recreate) { + switch(detachAction) { + case DISPOSE: + case RECREATE: + stencil.free(gl); + break; + default: + } + if(DetachAction.RECREATE != detachAction) { stencil = null; } break; @@ -1506,9 +1679,15 @@ public class FBObject { gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, 0); gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0); } - depth.free(gl); - stencil.free(gl); - if(!recreate) { + switch(detachAction) { + case DISPOSE: + case RECREATE: + depth.free(gl); + stencil.free(gl); + break; + default: + } + if(DetachAction.RECREATE != detachAction) { depth = null; stencil = null; } @@ -1516,14 +1695,15 @@ public class FBObject { default: throw new InternalError("XXX"); } - if(recreate) { + if(DetachAction.RECREATE == detachAction) { attachRenderbufferImpl2(gl, action, format); } } } /** - * Detaches all {@link ColorAttachment}s, {@link TextureAttachment}s and {@link RenderAttachment}s. + * Detaches all {@link ColorAttachment}s, {@link TextureAttachment}s and {@link RenderAttachment}s + * and disposes them. *

    Leaves the FBO bound!

    *

    * An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. @@ -1538,7 +1718,8 @@ public class FBObject { } /** - * Detaches all {@link ColorAttachment}s and {@link TextureAttachment}s. + * Detaches all {@link ColorAttachment}s and {@link TextureAttachment}s + * and disposes them. *

    Leaves the FBO bound!

    *

    * An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. @@ -1553,7 +1734,7 @@ public class FBObject { } /** - * Detaches all {@link TextureAttachment}s + * Detaches all {@link TextureAttachment}s and disposes them. *

    Leaves the FBO bound!

    *

    * An attached sampling sink texture will be detached as well, see {@link #getSamplingSink()}. @@ -1566,30 +1747,33 @@ public class FBObject { } for(int i=0; i reset try { for(int i=0; i0 ) { throw new InternalError("Non zero ColorAttachments "+this); } if(detachNonColorbuffer) { - detachRenderbufferImpl(gl, Attachment.Type.DEPTH_STENCIL, recreate); + detachRenderbufferImpl(gl, Attachment.Type.DEPTH_STENCIL, recreate ? DetachAction.RECREATE : DetachAction.DISPOSE); } if(ignoreStatus) { // post validate updateStatus(gl); @@ -1651,14 +1835,22 @@ public class FBObject { } private final void resetMSAATexture2DSink(GL gl) throws GLException { + if(null == samplesSink ) { + return; // this is the sample sink! + } if(0 == samples) { // MSAA off - if(null != samplesSink) { + if(samplesSink.initialized) { + // cleanup samplesSink.detachAll(gl); } return; } + if(!samplesSink.initialized) { + samplesSink.init(gl, width, height, 0); + } + boolean sampleSinkSizeMismatch = sampleSinkSizeMismatch(); boolean sampleSinkTexMismatch = sampleSinkTexMismatch(); boolean sampleSinkDepthStencilMismatch = sampleSinkDepthStencilMismatch(); @@ -1692,7 +1884,7 @@ public class FBObject { samplesSinkTexture = samplesSink.attachTexture2D(gl, 0, true); } else if( 0 == samplesSinkTexture.getName() ) { samplesSinkTexture.setSize(width, height); - samplesSink.attachTexture2D(gl, 0, samplesSinkTexture); + samplesSink.attachColorbuffer(gl, 0, samplesSinkTexture); } if( sampleSinkDepthStencilMismatch ) { @@ -1768,6 +1960,17 @@ public class FBObject { bound = false; } } + + /** + * Method simply marks this FBO unbound w/o interfering w/ the bound framebuffer as perfomed by {@link #unbind(GL)}. + *

    + * Only use this method if a subsequent {@link #unbind(GL)}, {@link #use(GL, TextureAttachment)} or {@link #bind(GL)} + * follows on any FBO. + *

    + */ + public final void markUnbound() { + bound = false; + } /** * Returns true if framebuffer object is bound via {@link #bind(GL)}, otherwise false. @@ -1785,49 +1988,54 @@ public class FBObject { public final boolean isBound() { return bound; } /** - * Samples the multisampling colorbuffer (msaa-buffer) to it's sink {@link #getSamplingSink()}. - * - *

    The operation is skipped, if no multisampling is used or - * the msaa-buffer has not been flagged dirty by a previous call of {@link #bind(GL)}, - * see {@link #isSamplingBufferDirty()}

    - * - *

    If full FBO is supported, sets the read and write framebuffer individually to default after sampling, hence not disturbing - * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()}

    - * - *

    In case you intend to employ {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)} + * If multisampling is being used and flagged dirty by a previous call of {@link #bind(GL)} or after initialization, + * the msaa-buffers are sampled to it's sink {@link #getSamplingSink()}. + *

    + * Method also updates the sampling sink configuration (if used). Hence it is recommended to call this + * method after your have initialized the FBO and attached renderbuffer etc for the 1st time. + * Method is called automatically by {@link #use(GL, TextureAttachment)}. + *

    + *

    + * Methos always resets the framebuffer binding to default in the end. + * If full FBO is supported, sets the read and write framebuffer individually to default after sampling, hence not disturbing + * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()} + *

    + *

    + * In case you use this FBO w/o the {@link GLFBODrawable} and intend to employ {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)} * you may want to call {@link GL#glBindFramebuffer(int, int) glBindFramebuffer}({@link GL2GL3#GL_READ_FRAMEBUFFER}, {@link #getReadFramebuffer()}); *

    - * *

    Leaves the FBO unbound.

    * * @param gl the current GL context * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)} * @throws IllegalArgumentException */ - public final void syncSamplingBuffer(GL gl) { - unbind(gl); + public final void syncFramebuffer(GL gl) { + markUnbound(); if(samples>0 && samplesSinkDirty) { samplesSinkDirty = false; resetMSAATexture2DSink(gl); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbName); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, samplesSink.getWriteFramebuffer()); - ((GL2GL3)gl).glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, // since MSAA is supported, ugly cast is OK + ((GL2GL3)gl).glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, // since MSAA is supported, casting to GL2GL3 is OK GL.GL_COLOR_BUFFER_BIT, GL.GL_NEAREST); - if(fullFBOSupport) { - // default read/draw buffers, may utilize GLContext/GLDrawable override of - // GLContext.getDefaultDrawFramebuffer() and GLContext.getDefaultReadFramebuffer() - gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); - gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); - } else { - gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer - } + } + if(fullFBOSupport) { + // default read/draw buffers, may utilize GLContext/GLDrawable override of + // GLContext.getDefaultDrawFramebuffer() and GLContext.getDefaultReadFramebuffer() + gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, 0); + gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, 0); + } else { + gl.glBindFramebuffer(GL.GL_FRAMEBUFFER, 0); // default draw buffer } } /** * Bind the given texture colorbuffer. * - *

    If multisampling is being used, {@link #syncSamplingBuffer(GL)} is being called.

    + *

    If using multiple texture units, ensure you call {@link GL#glActiveTexture(int)} first!

    + * + *

    {@link #syncFramebuffer(GL)} is being called

    * *

    Leaves the FBO unbound!

    * @@ -1837,11 +2045,7 @@ public class FBObject { */ public final void use(GL gl, TextureAttachment ta) throws IllegalArgumentException { if(null == ta) { throw new IllegalArgumentException("null TextureAttachment, this: "+toString()); } - if(samples > 0 && samplesSinkTexture == ta) { - syncSamplingBuffer(gl); - } else { - unbind(gl); - } + syncFramebuffer(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, ta.getName()); // use it .. } @@ -1855,14 +2059,8 @@ public class FBObject { gl.glBindTexture(GL.GL_TEXTURE_2D, 0); // don't use it } - /** - * Returns true if basic or full FBO is supported, otherwise false. - * @param full true for full FBO supported query, otherwise false for basic FBO support query. - * @see #supportsFullFBO(GL) - * @see #supportsBasicFBO(GL) - * @throws GLException if {@link #init(GL)} hasn't been called. - */ - public final boolean supportsFBO(boolean full) throws GLException { checkInitialized(); return full ? fullFBOSupport : basicFBOSupport; } + /** @see GL#hasFullFBOSupport() */ + public final boolean hasFullFBOSupport() throws GLException { checkInitialized(); return this.fullFBOSupport; } /** * Returns true if renderbuffer accepts internal format {@link GL#GL_RGB8} and {@link GL#GL_RGBA8}, otherwise false. @@ -1878,7 +2076,7 @@ public class FBObject { public final boolean supportsDepth(int bits) throws GLException { checkInitialized(); switch(bits) { - case 16: return basicFBOSupport; + case 16: return true; case 24: return depth24Avail; case 32: return depth32Avail; default: return false; @@ -1913,11 +2111,11 @@ public class FBObject { */ public final int getMaxColorAttachments() throws GLException { checkInitialized(); return maxColorAttachments; } - /** - * Returns the maximum number of samples for multisampling. Maybe zero if multisampling is not supported. - * @throws GLException if {@link #init(GL)} hasn't been called. - */ - public final int getMaxSamples() throws GLException { checkInitialized(); return maxSamples; } + public final int getMaxTextureSize() throws GLException { checkInitialized(); return this.maxTextureSize; } + public final int getMaxRenderbufferSize() throws GLException { checkInitialized(); return this.maxRenderbufferSize; } + + /** @see GL#getMaxRenderbufferSamples() */ + public final int getMaxSamples() throws GLException { checkInitialized(); return this.maxSamples; } /** * Returns true if this instance has been initialized with {@link #reset(GL, int, int)} diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java new file mode 100644 index 000000000..38a8deef8 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -0,0 +1,189 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLException; + +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + +import jogamp.opengl.GLAutoDrawableBase; +import jogamp.opengl.GLContextImpl; +import jogamp.opengl.GLDrawableImpl; + + +/** + * Fully functional {@link GLAutoDrawable} implementation + * utilizing already created created {@link GLDrawable} and {@link GLContext} instances. + *

    + * Since no native windowing system events are being processed, it is recommended + * to handle at least: + *

      + *
    • {@link com.jogamp.newt.event.WindowListener#windowRepaint(com.jogamp.newt.event.WindowUpdateEvent) repaint} using {@link #windowRepaintOp()}
    • + *
    • {@link com.jogamp.newt.event.WindowListener#windowResized(com.jogamp.newt.event.WindowEvent) resize} using {@link #windowResizedOp()}
    • + *
    • {@link com.jogamp.newt.event.WindowListener#windowDestroyNotify(com.jogamp.newt.event.WindowEvent) destroy-notify} using {@link #windowDestroyNotifyOp()}
    • + *
    + *

    + *

    + * See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}. + *

    + */ +public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAutoDrawable { + /** + * @param drawable a valid and already realized {@link GLDrawable} + * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. + * @param lock optional custom {@link RecursiveLock}. + */ + public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice, RecursiveLock lock) { + super((GLDrawableImpl)drawable, (GLContextImpl)context, ownDevice); + if(null == drawable) { + throw new IllegalArgumentException("null drawable"); + } + if(null == context) { + throw new IllegalArgumentException("null context"); + } + if(!drawable.isRealized()) { + throw new IllegalArgumentException("drawable not realized"); + } + this.upstreamWidget = upstreamWidget; + this.lock = ( null != lock ) ? lock : LockFactory.createRecursiveLock() ; + } + + // + // expose default methods + // + + /** Default implementation to handle repaint events from the windowing system */ + public final void windowRepaintOp() { + super.defaultWindowRepaintOp(); + } + + /** Implementation to handle resize events from the windowing system. All required locks are being claimed. */ + public final void windowResizedOp(int newWidth, int newHeight) { + super.defaultWindowResizedOp(newWidth, newHeight); + } + + /** + * Implementation to handle destroy notifications from the windowing system. + * + *

    + * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol} + * or {@link WindowClosingMode#DISPOSE_ON_CLOSE} is enabled (default), + * a thread safe destruction is being induced. + *

    + */ + public final void windowDestroyNotifyOp() { + super.defaultWindowDestroyNotifyOp(); + } + + // + // Complete GLAutoDrawable + // + + private Object upstreamWidget; + private final RecursiveLock lock; + + @Override + protected final RecursiveLock getLock() { return lock; } + + @Override + public final Object getUpstreamWidget() { + return upstreamWidget; + } + + /** + * Set the upstream UI toolkit object. + * @see #getUpstreamWidget() + */ + public final void setUpstreamWidget(Object newUpstreamWidget) { + upstreamWidget = newUpstreamWidget; + } + + /** + * {@inheritDoc} + *

    + * This implementation calls {@link #defaultDestroy()}. + *

    + *

    + * User still needs to destroy the upstream window, which details are hidden from this aspect. + * This can be performed by overriding {@link #destroyImplInLock()}. + *

    + */ + @Override + public final void destroy() { + defaultDestroy(); + } + + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); + } + + @Override + public void display() { + defaultDisplay(); + } + + // + // GLDrawable delegation + // + + @Override + public final GLDrawableFactory getFactory() { + return drawable.getFactory(); + } + + @Override + public final void setRealized(boolean realized) { + } + + @Override + public final void swapBuffers() throws GLException { + defaultSwapBuffers(); + } + + @Override + public String toString() { + return getClass().getSimpleName()+"[ \n\tHelper: " + helper + ", \n\tDrawable: " + drawable + + ", \n\tContext: " + context + ", \n\tUpstreamWidget: "+upstreamWidget+ /** ", \n\tFactory: "+factory+ */ "]"; + } +} diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java index f7e25fa01..cf81b85ee 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java +++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java @@ -72,6 +72,9 @@ public class GLExtensions { public static final String OES_EGL_image_external = "GL_OES_EGL_image_external"; + public static final String ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64"; + public static final String ARB_shader_objects = "GL_ARB_shader_objects"; + // // Aliased GLX/WGL/.. extensions // diff --git a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java b/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java deleted file mode 100644 index 4caea03b2..000000000 --- a/src/jogl/classes/com/jogamp/opengl/OffscreenAutoDrawable.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl; - -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.opengl.GLAutoDrawableDelegate; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLException; - -import jogamp.opengl.GLFBODrawableImpl; - -/** - * Platform-independent class exposing FBO offscreen functionality to - * applications. - *

    - * This class distinguishes itself from {@link GLAutoDrawableDelegate} - * with it's {@link #setSize(int, int)} functionality. - *

    - */ -public class OffscreenAutoDrawable extends GLAutoDrawableDelegate { - - /** - * @param drawable a valid {@link GLDrawable}, may not be realized yet. - * @param context a valid {@link GLContext}, may not be made current (created) yet. - * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, - * otherwise pass false. Closing the device is required in case - * the drawable is created w/ it's own new instance, e.g. offscreen drawables, - * and no further lifecycle handling is applied. - */ - public OffscreenAutoDrawable(GLDrawable drawable, GLContext context, boolean ownDevice) { - super(drawable, context, null, ownDevice); - } - - /** - * Attempts to resize this offscreen auto drawable, if supported - * by the underlying {@link GLDrawable). - * @param newWidth - * @param newHeight - * @return true if resize was executed, otherwise false. - * @throws GLException in case of an error during the resize operation - */ - public boolean setSize(int newWidth, int newHeight) throws GLException { - boolean done = false; - if(drawable instanceof GLFBODrawableImpl) { - Throwable tFBO = null; - Throwable tGL = null; - context.makeCurrent(); - try { - ((GLFBODrawableImpl)drawable).setSize(context.getGL(), newWidth, newHeight); - done = true; - } catch (Throwable t) { - tFBO = t; - } finally { - try { - context.release(); - } catch (Throwable t) { - tGL = t; - } - } - if(null != tFBO) { - throw new GLException("OffscreenAutoDrawable.setSize(..) GLFBODrawableImpl.setSize(..) exception", tFBO); - } - if(null != tGL) { - throw new GLException("OffscreenAutoDrawable.setSize(..) GLContext.release() exception", tGL); - } - } - if(done) { - this.defaultWindowResizedOp(); - return true; - } - return false; - } - - /** - * If the underlying {@link GLDrawable} is an FBO implementation - * and contains an {#link FBObject}, the same is returned. - * Otherwise returns null. - */ - public FBObject getFBObject() { - if(drawable instanceof GLFBODrawableImpl) { - return ((GLFBODrawableImpl)drawable).getFBObject(); - } - return null; - } -} diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 8d237162c..02f62daec 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.swt; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GL; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; @@ -48,6 +49,7 @@ import javax.media.opengl.Threading; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; +import jogamp.opengl.GLDrawableImpl; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ControlAdapter; @@ -97,8 +99,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final GLCapabilitiesImmutable capsRequested; private final GLCapabilitiesChooser capsChooser; - private volatile GLDrawable drawable; // volatile: avoid locking for read-only access - private GLContext context; + private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access + private GLContextImpl context; /* Native window surface */ private AbstractGraphicsDevice device; @@ -319,7 +321,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } }); } - private final ProxySurface.UpstreamSurfaceHook swtCanvasUpStreamHook = new ProxySurface.UpstreamSurfaceHook() { + private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() { @Override public final void create(ProxySurface s) { /* nop */ } @@ -349,7 +351,27 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) ) { clientArea = nClientArea; // write back new value - sendReshape = true; // Mark for OpenGL reshape next time the control is painted + + GLDrawableImpl _drawable = drawable; + if( null != _drawable ) { + if(DEBUG) { + System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+nClientArea.width+"x"+nClientArea.height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, nClientArea.width, nClientArea.height); + if(_drawable != _drawableNew) { + // write back + drawable = _drawableNew; + } + } finally { + _lock.unlock(); + } + sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock + } + } } } @@ -391,10 +413,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { if(null != proxySurface) { /* Associate a GL surface with the proxy */ - drawable = glFactory.createGLDrawable(proxySurface); + drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); drawable.setRealized(true); - context = drawable.createContext(shareWith); + context = (GLContextImpl) drawable.createContext(shareWith); } } finally { _lock.unlock(); @@ -455,6 +477,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { return helper.getAutoSwapBufferMode(); } + @Override + public final GLDrawable getDelegatedDrawable() { + return drawable; + } + @Override public GLContext getContext() { return null != drawable ? context : null; @@ -502,7 +529,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { _lock.lock(); try { final GLContext oldCtx = context; - final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; if(newCtxCurrent) { context.makeCurrent(); diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 0b2c664fe..38f1746f9 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -114,6 +114,12 @@ public interface GLAutoDrawable extends GLDrawable { * where you drag the window to another monitor. */ public static final boolean SCREEN_CHANGE_ACTION_ENABLED = Debug.getBooleanProperty("jogl.screenchange.action", true); + /** + * If the implementation uses delegation, return the delegated {@link GLDrawable} instance, + * otherwise return this instance. + */ + public GLDrawable getDelegatedDrawable(); + /** * Returns the context associated with this drawable. The returned * context will be synchronized. @@ -124,23 +130,31 @@ public interface GLAutoDrawable extends GLDrawable { /** * Associate a new context to this drawable and also propagates the context/drawable switch by * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. - * drawable might be an inner GLDrawable instance if using such a delegation pattern, - * or this GLAutoDrawable itself. - *

    - * If the old context's drawable was an {@link GLAutoDrawable}, it's reference to the given drawable - * is being cleared by calling - * {@link GLAutoDrawable#setContext(GLContext) ((GLAutoDrawable)oldCtx.getGLDrawable()).setContext(null)}. - *

    + * drawable might be an inner GLDrawable instance if using a delegation pattern, + * or this GLAutoDrawable instance. *

    * If the old or new context was current on this thread, it is being released before switching the drawable. * The new context will be made current afterwards, if it was current before. - * However the user shall take extra care that not other thread - * attempts to make this context current. Otherwise a race condition may happen. + * However the user shall take extra care that no other thread + * attempts to make this context current. + *

    + *

    + * Be aware that the old context is still bound to the drawable, + * and that one context can only be bound to one drawable at one time! *

    *

    - * Disclaimer: Even though the API may allows this functionality in theory, your mileage may vary - * switching the drawable of an already established GLContext, i.e. which is already made current once. - * FIXME: Validate functionality! + * In case you do not intend to use the old context anymore, i.e. + * not assigning it to another drawable, it shall be + * destroyed before setting the new context, i.e.: + *

    +            GLContext oldCtx = glad.getContext();
    +            if(null != oldCtx) {
    +                oldCtx.destroy();
    +            }
    +            glad.setContext(newCtx);            
    +   * 
    + * This is required, since a context must have a valid drawable at all times + * and this API shall not restrict the user in any way. *

    * * @param newCtx the new context diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java deleted file mode 100644 index 67e81270d..000000000 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawableDelegate.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package javax.media.opengl; - -import javax.media.nativewindow.AbstractGraphicsDevice; - -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; - -import jogamp.opengl.Debug; -import jogamp.opengl.GLAutoDrawableBase; -import jogamp.opengl.GLContextImpl; -import jogamp.opengl.GLDrawableImpl; - - -/** - * Fully functional {@link GLAutoDrawable} implementation - * utilizing already created created {@link GLDrawable} and {@link GLContext} instances. - *

    - * Since no native windowing system events are being processed, it is recommended - * to handle at least: - *

      - *
    • {@link com.jogamp.newt.event.WindowListener#windowRepaint(com.jogamp.newt.event.WindowUpdateEvent) repaint} using {@link #defaultWindowRepaintOp()}
    • - *
    • {@link com.jogamp.newt.event.WindowListener#windowResized(com.jogamp.newt.event.WindowEvent) resize} using {@link #defaultWindowResizedOp()}
    • - *
    • {@link com.jogamp.newt.event.WindowListener#windowDestroyNotify(com.jogamp.newt.event.WindowEvent) destroy-notify} using {@link #defaultWindowDestroyNotifyOp()}
    • - *
    - *

    - *

    - * See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}. - *

    - */ -public class GLAutoDrawableDelegate extends GLAutoDrawableBase { - public static final boolean DEBUG = Debug.debug("GLAutoDrawableDelegate"); - - /** - * @param drawable a valid {@link GLDrawable}, may not be realized yet. - * @param context a valid {@link GLContext}, may not be made current (created) yet. - * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. - * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, - * otherwise pass false. Closing the device is required in case - * the drawable is created w/ it's own new instance, e.g. offscreen drawables, - * and no further lifecycle handling is applied. - */ - public GLAutoDrawableDelegate(GLDrawable drawable, GLContext context, Object upstreamWidget, boolean ownDevice) { - super((GLDrawableImpl)drawable, (GLContextImpl)context, ownDevice); - this.upstreamWidget = null; - } - - // - // expose default methods - // - - public final void windowRepaintOp() { - super.defaultWindowRepaintOp(); - } - - public final void windowResizedOp() { - super.defaultWindowResizedOp(); - } - - public final void windowDestroyNotifyOp() { - super.defaultWindowDestroyNotifyOp(); - } - - // - // Complete GLAutoDrawable - // - - private final RecursiveLock lock = LockFactory.createRecursiveLock(); // instance wide lock - private final Object upstreamWidget; - - @Override - protected final RecursiveLock getLock() { return lock; } - - @Override - public final Object getUpstreamWidget() { - return upstreamWidget; - } - - /** - * {@inheritDoc} - *

    - * This implementation calls {@link #defaultDestroy()}. - *

    - *

    - * User still needs to destroy the upstream window, which details are hidden from this aspect. - * This can be performed by overriding {@link #destroyImplInLock()}. - *

    - */ - @Override - public final void destroy() { - defaultDestroy(); - } - - @Override - public void display() { - defaultDisplay(); - } - - // - // GLDrawable delegation - // - - @Override - public final GLDrawableFactory getFactory() { - return drawable.getFactory(); - } - - @Override - public final void setRealized(boolean realized) { - } - - @Override - public final void swapBuffers() throws GLException { - defaultSwapBuffers(); - } - -} diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index f5831a72d..9bcee819a 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -273,6 +273,42 @@ public interface GLBase { */ public boolean isExtensionAvailable(String glExtensionName); + /** + * Returns true if basic FBO support is available, otherwise false. + *

    + * Basic FBO is supported if the context is either GL-ES >= 2.0, GL >= core 3.0 or implements the extensions + * GL_ARB_ES2_compatibility, GL_ARB_framebuffer_object, GL_EXT_framebuffer_object or GL_OES_framebuffer_object. + *

    + *

    + * Basic FBO support may only include one color attachment and no multisampling, + * as well as limited internal formats for renderbuffer. + *

    + * @see GLContext#hasBasicFBOSupport() + */ + public boolean hasBasicFBOSupport(); + + /** + * Returns true if full FBO support is available, otherwise false. + *

    + * Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions + * ARB_framebuffer_object, or all of + * EXT_framebuffer_object, EXT_framebuffer_multisample, + * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. + *

    + *

    + * Full FBO support includes multiple color attachments and multisampling. + *

    + * @see GLContext#hasFullFBOSupport() + */ + public boolean hasFullFBOSupport(); + + /** + * Returns the maximum number of FBO RENDERBUFFER samples + * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. + * @see GLContext#getMaxRenderbufferSamples() + */ + public int getMaxRenderbufferSamples(); + /** * Returns true if the GL context supports non power of two (NPOT) textures, * otherwise false. @@ -284,6 +320,8 @@ public interface GLBase { */ public boolean isNPOTTextureAvailable(); + public boolean isTextureFormatBGRA8888Available(); + /** Provides a platform-independent way to specify the minimum swap interval for buffer swaps. An argument of 0 disables sync-to-vertical-refresh completely, while an argument of 1 diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index c2f94b9af..a5e639c74 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -96,6 +96,9 @@ public abstract class GLContext { */ public static final boolean PROFILE_ALIASING = !Debug.isPropertyDefined("jogl.debug.GLContext.NoProfileAliasing", true); + protected static final boolean FORCE_NO_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.none", true); + protected static final boolean FORCE_MIN_FBO_SUPPORT = Debug.isPropertyDefined("jogl.fbo.force.min", true); + public static final boolean DEBUG = Debug.debug("GLContext"); public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); @@ -127,9 +130,9 @@ public abstract class GLContext { /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IMPL_ES2_COMPAT = 1 << 8; - /** Context supports basic FBO, details see {@link #hasFBO()}. + /** Context supports basic FBO, details see {@link #hasBasicFBOSupport()}. * Not a cache key. - * @see #hasFBO() + * @see #hasBasicFBOSupport() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) */ protected static final int CTX_IMPL_FBO = 1 << 9; @@ -178,11 +181,6 @@ public abstract class GLContext { * and made current afterwards. However the user shall take extra care that not other thread * attempts to make this context current. Otherwise a race condition may happen. *

    - *

    - * Disclaimer: Even though the API may allows this functionality in theory, your mileage may vary - * switching the drawable of an already established GLContext, i.e. which is already made current once. - * FIXME: Validate functionality! - *

    * @param readWrite the read/write drawable for framebuffer operations. * @param setWriteOnly if true and if the current read-drawable differs * from the write-drawable ({@link #setGLReadDrawable(GLDrawable)}), @@ -603,12 +601,23 @@ public abstract class GLContext { /** * @return true if impl. is a hardware rasterizer, otherwise false. + * @see #isHardwareRasterizer(AbstractGraphicsDevice, GLProfile) * @see GLProfile#isHardwareRasterizer() */ public final boolean isHardwareRasterizer() { return 0 == ( ctxOptions & CTX_IMPL_ACCEL_SOFT ) ; } + /** + * @return true if context supports GLSL, i.e. is either {@link #isGLES2()}, {@link #isGL3()} or {@link #isGL2()} and major-version > 1. + * @see GLProfile#hasGLSL() + */ + public final boolean hasGLSL() { + return isGLES2() || + isGL3() || + isGL2() && ctxMajorVersion>1 ; + } + /** * Returns true if basic FBO support is available, otherwise false. *

    @@ -620,21 +629,54 @@ public abstract class GLContext { * as well as limited internal formats for renderbuffer. *

    * @see #CTX_IMPL_FBO - * @see com.jogamp.opengl.FBObject#supportsBasicFBO(GL) - * @see com.jogamp.opengl.FBObject#supportsFullFBO(GL) */ - public final boolean hasFBO() { + public final boolean hasBasicFBOSupport() { return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; } + /** + * Returns true if full FBO support is available, otherwise false. + *

    + * Full FBO is supported if the context is either GL >= core 3.0 or implements the extensions + * ARB_framebuffer_object, or all of + * EXT_framebuffer_object, EXT_framebuffer_multisample, + * EXT_framebuffer_blit, GL_EXT_packed_depth_stencil. + *

    + *

    + * Full FBO support includes multiple color attachments and multisampling. + *

    + */ + public final boolean hasFullFBOSupport() { + return !FORCE_MIN_FBO_SUPPORT && hasBasicFBOSupport() && + ( isGL3() || // GL >= 3.0 + isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object + ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object* + isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) && + isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) && + isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil) + ) + ) ; + } + /** - * @return true if context supports GLSL - * @see GLProfile#hasGLSL() + * Returns the maximum number of FBO RENDERBUFFER samples + * if {@link #hasFullFBOSupport() full FBO is supported}, otherwise false. */ - public final boolean hasGLSL() { - return isGL2ES2() ; + public final int getMaxRenderbufferSamples() { + if( hasFullFBOSupport() ) { + final GL gl = getGL(); + final int[] val = new int[] { 0 } ; + gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); + final int glerr = gl.glGetError(); + if(GL.GL_NO_ERROR == glerr) { + return val[0]; + } else if(DEBUG) { + System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr)); + } + } + return 0; } - + /** Note: The GL impl. may return a const value, ie {@link GLES2#isNPOTTextureAvailable()} always returns true. */ public boolean isNPOTTextureAvailable() { return isGL3() || isGLES2Compatible() || isExtensionAvailable(GLExtensions.ARB_texture_non_power_of_two); @@ -1014,6 +1056,9 @@ public abstract class GLContext { validateProfileBits(profile, "profile"); validateProfileBits(resCtp, "resCtp"); + if(FORCE_NO_FBO_SUPPORT) { + resCtp &= ~CTX_IMPL_FBO ; + } if(DEBUG) { System.err.println("GLContext.mapAvailableGLVersion: "+device+": "+getGLVersion(reqMajor, 0, profile, null)+" -> "+getGLVersion(resMajor, resMinor, resCtp, null)); // Thread.dumpStack(); @@ -1197,17 +1242,35 @@ public abstract class GLContext { * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. *

    *

    - * FBO support is queried as described in {@link #hasFBO()}. + * FBO support is queried as described in {@link #hasBasicFBOSupport()}. *

    * * @param device the device to request whether FBO is available for * @param glp {@link GLProfile} to check for FBO capabilities - * @see GLContext#hasFBO() + * @see GLContext#hasBasicFBOSupport() */ public static final boolean isFBOAvailable(AbstractGraphicsDevice device, GLProfile glp) { return 0 != ( CTX_IMPL_FBO & getAvailableContextProperties(device, glp) ); } + /** + * @return 1 if using a hardware rasterizer, 0 if using a software rasterizer and -1 if not determined yet. + * @see GLContext#isHardwareRasterizer() + * @see GLProfile#isHardwareRasterizer() + */ + public static final int isHardwareRasterizer(AbstractGraphicsDevice device, GLProfile glp) { + final int r; + final int ctp = getAvailableContextProperties(device, glp); + if(0 == ctp) { + r = -1; + } else if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { + r = 1; + } else { + r = 0; + } + return r; + } + /** * @param device the device to request whether the profile is available for * @param reqMajor Key Value either 1, 2, 3 or 4 diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 9fd895c1f..b6e7b0576 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -48,13 +48,16 @@ import java.util.List; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.opengl.GLAutoDrawableDelegate; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; import jogamp.opengl.Debug; @@ -373,44 +376,63 @@ public abstract class GLDrawableFactory { // Methods to create high-level objects /** - * Returns a GLDrawable according to it's chosen Capabilities,
    + * Returns a GLDrawable according to it's chosen {@link GLCapabilitiesImmutable},
    * which determines pixel format, on- and offscreen incl. PBuffer type. *

    - * The native platform's chosen Capabilties are referenced within the target - * NativeSurface's AbstractGraphicsConfiguration.

    - * - * In case target's {@link javax.media.nativewindow.Capabilities#isOnscreen()} is true,
    - * an onscreen GLDrawable will be realized. + * The chosen {@link GLCapabilitiesImmutable} are referenced within the target + * {@link NativeSurface}'s {@link AbstractGraphicsConfiguration}.

    + *

    *

    - * In case target's {@link javax.media.nativewindow.Capabilities#isOnscreen()} is false,
    - * either a Pbuffer drawable is created if target's {@link javax.media.opengl.GLCapabilities#isPBuffer()} is true,
    - * or a simple pixmap/bitmap drawable is created. The latter is unlikely to be hardware accelerated.
    + * An onscreen GLDrawable is created if {@link CapabilitiesImmutable#isOnscreen() caps.isOnscreen()} is true. + *

    *

    - * + * A FBO drawable is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} + * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. + *

    + *

    + * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + *

    + *

    + * If not onscreen and neither FBO nor Pbuffer is available, + * a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated. + *

    + * * @throws IllegalArgumentException if the passed target is null * @throws GLException if any window system-specific errors caused * the creation of the GLDrawable to fail. * + * @see #canCreateGLPbuffer(AbstractGraphicsDevice) + * @see GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) + * @see javax.media.opengl.GLCapabilities#isOnscreen() + * @see javax.media.opengl.GLCapabilities#isFBO() + * @see javax.media.opengl.GLCapabilities#isPBuffer() * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen) */ public abstract GLDrawable createGLDrawable(NativeSurface target) throws IllegalArgumentException, GLException; - + /** - * Creates a Offscreen GLDrawable incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. + * Creates an {@link GLOffscreenAutoDrawable} incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. *

    - * It's {@link AbstractGraphicsConfiguration} is properly set according to the given {@link GLCapabilitiesImmutable}, see below. + * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is realized and it's {@link GLContext} assigned but not yet made current. *

    *

    - * A FBO drawable is created if both {@link javax.media.opengl.GLCapabilities#isFBO() caps.isFBO()} + * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. + * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true, + * it is auto-configured. The latter will set offscreen and also FBO or Pbuffer, whichever is available in that order. + *

    + *

    + * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. *

    *

    - * A Pbuffer drawable is created if both {@link javax.media.opengl.GLCapabilities#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(javax.media.nativewindow.AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + * A Pbuffer based auto drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. *

    *

    - * If neither FBO nor Pbuffer is available, a simple pixmap/bitmap drawable/surface is created, which is unlikely to be hardware accelerated. + * If neither FBO nor Pbuffer is available, + * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated. *

    * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. @@ -418,17 +440,55 @@ public abstract class GLDrawableFactory { * @param chooser the custom chooser, may be null for default * @param width the requested offscreen width * @param height the requested offscreen height + * @return the created and initialized offscreen {@link GLOffscreenAutoDrawable} instance * - * @return the created offscreen GLDrawable + * @throws GLException if any window system-specific errors caused + * the creation of the Offscreen to fail. + * + * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) + */ + public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, + GLCapabilitiesImmutable caps, + GLCapabilitiesChooser chooser, + int width, int height, + GLContext shareWith) throws GLException; + /** + * Creates a offscreen {@link GLDrawable} incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. + *

    + * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. + * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true, + * it is auto-configured. The latter will set offscreen and also FBO or Pbuffer, whichever is available in that order. + *

    + *

    + * A resizeable FBO drawable, {@link GLFBODrawable.Resizeable}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} + * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. + *

    + *

    + * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + *

    + *

    + * If neither FBO nor Pbuffer is available, + * a simple pixmap/bitmap drawable is created, which is unlikely to be hardware accelerated. + *

    + * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. + * @param caps the requested GLCapabilties + * @param chooser the custom chooser, may be null for default + * @param width the requested offscreen width + * @param height the requested offscreen height + * + * @return the created offscreen {@link GLDrawable} * * @throws GLException if any window system-specific errors caused * the creation of the Offscreen to fail. + * + * @see #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext) */ public abstract GLDrawable createOffscreenDrawable(AbstractGraphicsDevice device, - GLCapabilitiesImmutable capabilities, + GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, - int width, int height) - throws GLException; + int width, int height) throws GLException; /** * Creates a proxy {@link NativeSurface} w/ defined surface handle, i.e. a {@link WrappedSurface} or {@link GDISurface} instance. @@ -458,6 +518,21 @@ public abstract class GLDrawableFactory { long windowHandle, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream); + /** + * Returns true if it is possible to create an framebuffer object (FBO). + *

    + * FBO feature is implemented in OpenGL, hence it is {@link GLProfile} dependent. + *

    + *

    + * FBO support is queried as described in {@link GLContext#hasBasicFBOSupport()}. + *

    + * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + * @param glp {@link GLProfile} to check for FBO capabilities + * @see GLContext#hasBasicFBOSupport() + */ + public abstract boolean canCreateFBO(AbstractGraphicsDevice device, GLProfile glp); + /** * Returns true if it is possible to create a GLPbuffer. Some older * graphics cards do not have this capability. @@ -467,7 +542,10 @@ public abstract class GLDrawableFactory { public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device); /** - * Creates a GLPbuffer with the given capabilites and dimensions.

    + * Creates a GLPbuffer {@link GLAutoDrawable} with the given capabilites and dimensions. + *

    + * The GLPbuffer drawable is realized and initialized eagerly. + *

    * * See the note in the overview documentation on * context sharing. @@ -479,10 +557,12 @@ public abstract class GLDrawableFactory { * @param initialHeight initial height of pbuffer * @param shareWith a shared GLContext this GLPbuffer shall use * - * @return the new {@link GLPbuffer} specific {@link GLAutoDrawable} + * @return the created and initialized {@link GLPbuffer} instance * * @throws GLException if any window system-specific errors caused * the creation of the GLPbuffer to fail. + * + * @deprecated {@link GLPbuffer} is deprecated, use {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext)} */ public abstract GLPbuffer createGLPbuffer(AbstractGraphicsDevice device, GLCapabilitiesImmutable capabilities, diff --git a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java new file mode 100644 index 000000000..45fd3b686 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java @@ -0,0 +1,173 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.opengl; + +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.FBObject.TextureAttachment; + +/** + * Platform-independent {@link GLDrawable} specialization, + * exposing {@link FBObject} functionality. + * + *

    + * A {@link GLFBODrawable} is uninitialized until a {@link GLContext} is bound + * and made current the first time. + *

    + * + *

    + * MSAA is used if {@link GLCapabilitiesImmutable#getNumSamples() requested}. + *

    + *

    + * Double buffering is used if {@link GLCapabilitiesImmutable#getDoubleBuffered() requested}. + *

    + *

    + * In MSAA mode, it always uses the implicit 2nd {@link FBObject framebuffer} {@link FBObject#getSamplingSinkFBO() sink}. + * Hence double buffering is always the case w/ MSAA. + *

    + *

    + * In non MSAA a second explicit {@link FBObject framebuffer} is being used. + * This method allows compliance w/ the spec, i.e. read and draw framebuffer selection + * and double buffer usage for e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)}. + * This method also allows usage of both textures seperately. + *

    + *

    + * It would be possible to implement double buffering simply using + * {@link FBObject.TextureAttachment texture attachment}s with one {@link FBObject framebuffer}. + * This would require mode selection and hence complicate the API. Besides, it would + * not support differentiation of read and write framebuffer and hence not be spec compliant. + *

    + *

    + * Actual swapping of the {@link FBObject.TextureAttachment texture}s or {@link FBObject framebuffer} + * is performed either in the {@link #contextMadeCurrent(boolean) context current hook} + * or when {@link #swapBuffersImpl(boolean) swapping buffers}, whatever comes first.
    + *

    + */ +public interface GLFBODrawable extends GLDrawable { + // public enum DoubleBufferMode { NONE, TEXTURE, FBO }; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + + /** + * @return true if initialized, i.e. a {@link GLContext} is bound and made current once, otherwise false. + */ + public boolean isInitialized(); + + /** + * Notify this instance about upstream size change + * to reconfigure the {@link FBObject}. + * @param gl GL context object bound to this drawable, will be made current during operation. + * A prev. current context will be make current after operation. + * @throws GLException if resize operation failed + */ + void resetSize(GL gl) throws GLException; + + /** + * @return the used texture unit + */ + int getTextureUnit(); + + /** + * + * @param unit the texture unit to be used + */ + void setTextureUnit(int unit); + + /** + * Set a new sample size + * @param gl GL context object bound to this drawable, will be made current during operation. + * A prev. current context will be make current after operation. + * @param newSamples new sample size + * @throws GLException if resetting the FBO failed + */ + void setNumSamples(GL gl, int newSamples) throws GLException; + + /** + * @return the number of sample buffers if using MSAA, otherwise 0 + */ + int getNumSamples(); + + /** + * @return the used {@link DoubleBufferMode} + */ + // DoubleBufferMode getDoubleBufferMode(); // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + + /** + * Sets the {@link DoubleBufferMode}. Must be called before {@link #isInitialized() initialization}, + * otherwise an exception is thrown. + *

    + * This call has no effect is MSAA is selected, since MSAA always forces the mode to {@link DoubleBufferMode#FBO FBO}. + * Also setting the mode to {@link DoubleBufferMode#NONE NONE} where double buffering is {@link GLCapabilitiesImmutable#getDoubleBuffered() requested} + * or setting a double buffering mode w/o {@link GLCapabilitiesImmutable#getDoubleBuffered() request} will be ignored. + *

    + *

    + * Since {@link DoubleBufferMode#TEXTURE TEXTURE} mode is currently not implemented, this method has no effect. + *

    + * @throws GLException if already initialized, see {@link #isInitialized()}. + */ + // void setDoubleBufferMode(DoubleBufferMode mode) throws GLException; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + + /** + * If MSAA is being used and {@link GL#GL_FRONT} is requested, + * the internal {@link FBObject} {@link FBObject#getSamplingSinkFBO() sample sink} is being returned. + * + * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names + * @return the named {@link FBObject} + * @throws IllegalArgumentException if an illegal buffer name is being used + */ + FBObject getFBObject(int bufferName) throws IllegalArgumentException; + + /** + * Returns the named texture buffer. + *

    + * If MSAA is being used, only the {@link GL#GL_FRONT} buffer is accessible + * and an exception is being thrown if {@link GL#GL_BACK} is being requested. + *

    + * @param bufferName {@link GL#GL_FRONT} and {@link GL#GL_BACK} are valid buffer names + * @return the named {@link TextureAttachment} + * @throws IllegalArgumentException if using MSAA and {@link GL#GL_BACK} is requested or an illegal buffer name is being used + */ + FBObject.TextureAttachment getTextureBuffer(int bufferName) throws IllegalArgumentException; + + /** Resizeable {@link GLFBODrawable} specialization */ + public interface Resizeable extends GLFBODrawable { + /** + * Resize this drawable. + *

    + * This drawable is being locked during operation. + *

    + * @param context the {@link GLContext} bound to this drawable, will be made current during operation + * A prev. current context will be make current after operation. + * @param newWidth + * @param newHeight + * @throws NativeWindowException in case the surface could no be locked + * @throws GLException in case an error during the resize operation occurred + */ + void setSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException; + } +} diff --git a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java new file mode 100644 index 000000000..6fe76a3f4 --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java @@ -0,0 +1,63 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.opengl; + +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.opengl.FBObject; + +/** + * Platform-independent {@link GLAutoDrawable} specialization, + * exposing offscreen functionality. + *

    + * This class distinguishes itself from {@link GLAutoDrawable} + * with it's {@link #setSize(int, int)} functionality. + *

    + */ +public interface GLOffscreenAutoDrawable extends GLAutoDrawable { + + /** + * Resize this auto drawable. + * @param newWidth + * @param newHeight + * @throws NativeWindowException in case the surface could no be locked + * @throws GLException in case of an error during the resize operation + */ + void setSize(int newWidth, int newHeight) throws NativeWindowException, GLException; + + /** + * Set the upstream UI toolkit object. + * @see #getUpstreamWidget() + */ + void setUpstreamWidget(Object newUpstreamWidget); + + /** {@link FBObject} based {@link GLOffscreenAutoDrawable} specialization */ + public interface FBO extends GLOffscreenAutoDrawable, GLFBODrawable { + } +} diff --git a/src/jogl/classes/javax/media/opengl/GLPbuffer.java b/src/jogl/classes/javax/media/opengl/GLPbuffer.java index 273a992cf..de7731a3b 100644 --- a/src/jogl/classes/javax/media/opengl/GLPbuffer.java +++ b/src/jogl/classes/javax/media/opengl/GLPbuffer.java @@ -45,7 +45,11 @@ package javax.media.opengl; contains experimental methods for accessing the pbuffer's contents as a texture map and enabling rendering to floating-point frame buffers. These methods are not guaranteed to be supported on all - platforms and may be deprecated in a future release. */ + platforms and may be deprecated in a future release. + + @deprecated Use {@link GLOffscreenAutoDrawable} w/ {@link GLCapabilities#setFBO(boolean)} + via {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int, GLContext) GLDrawableFactory.createOffscreenAutoDrawable(..)}. + */ public interface GLPbuffer extends GLAutoDrawable { /** Indicates the GL_APPLE_float_pixels extension is being used for this pbuffer. */ diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 033591fe3..329cf9e3f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -98,6 +98,7 @@ import jogamp.common.awt.AWTEDTExecutor; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; +import jogamp.opengl.GLDrawableImpl; // FIXME: Subclasses need to call resetGLFunctionAvailability() on their // context whenever the displayChanged() function is called on our @@ -109,6 +110,16 @@ import jogamp.opengl.GLDrawableHelper; interfaces when adding a heavyweight doesn't work either because of Z-ordering or LayoutManager problems. * + *
    Offscreen Layer Remarks
    + * + * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} + * maybe called to use an offscreen drawable (FBO or PBuffer) allowing + * the underlying JAWT mechanism to composite the image, if supported. + *

    + * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} + * is being called if {@link GLCapabilitiesImmutable#isOnscreen()} is false. + *

    + * *
    Java2D OpenGL Remarks
    * * To avoid any conflicts with a potential Java2D OpenGL context,
    @@ -145,7 +156,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); private AWTGraphicsConfiguration awtConfig; - private volatile GLDrawable drawable; // volatile: avoid locking for read-only access + private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access private volatile JAWTWindow jawtWindow; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle private GLContextImpl context; private volatile boolean sendReshape = false; // volatile: maybe written by EDT w/o locking @@ -237,6 +248,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // don't allow the user to change data capsReqUser = (GLCapabilitiesImmutable) capsReqUser.cloneMutable(); } + if(!capsReqUser.isOnscreen()) { + setShallUseOffscreenLayer(true); // trigger offscreen layer - if supported + } if(null==device) { GraphicsConfiguration gc = super.getGraphicsConfiguration(); @@ -451,11 +465,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing /** Overridden to cause OpenGL rendering to be performed during repaint cycles. Subclasses which override this method must call super.paint() in their paint() method in order to function - properly.

    - - Overrides: -

    paint in class java.awt.Component
    */ - @Override + properly. + */ + @Override public void paint(Graphics g) { if (Beans.isDesignTime()) { // Make GLCanvas behave better in NetBeans GUI builder @@ -544,7 +556,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); jawtWindow.lockSurface(); try { - drawable = GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); + drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); context = (GLContextImpl) drawable.createContext(shareWith); context.setContextCreationFlags(additionalCtxCreationFlags); } finally { @@ -561,13 +573,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if (!Beans.isDesignTime() && 0 < _drawable.getWidth() * _drawable.getHeight() ) { // make sure drawable realization happens on AWT EDT, due to AWTTree lock - AWTEDTExecutor.singleton.invoke(true, setRealizedOnEDTAction); - sendReshape=true; // ensure a reshape is being send .. - if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); - Thread.dumpStack(); + AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); + if( _drawable.isRealized() ) { + sendReshape=true; // ensure a reshape is being send .. + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); + Thread.dumpStack(); + } + return true; } - return true; } } return false; @@ -575,7 +589,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private Runnable setRealizedOnEDTAction = new Runnable() { @Override public void run() { - drawable.setRealized(true); + final GLDrawable _drawable = drawable; + if ( null != _drawable && 0 < _drawable.getWidth() * _drawable.getHeight() ) { + _drawable.setRealized(true); + } } }; /**

    Overridden to track when this component is removed from a @@ -620,22 +637,37 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @SuppressWarnings("deprecation") @Override public void reshape(int x, int y, int width, int height) { - super.reshape(x, y, width, height); - final GLDrawable _drawable = drawable; - if(null != _drawable && _drawable.isRealized() && !_drawable.getChosenGLCapabilities().isOnscreen()) { - dispose(true); - } else { - sendReshape = true; + synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape + super.reshape(x, y, width, height); + + GLDrawableImpl _drawable = drawable; + if( null != _drawable ) { + if(DEBUG) { + System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, width, height); + if(_drawable != _drawableNew) { + // write back + drawable = _drawableNew; + } + } finally { + _lock.unlock(); + } + } + sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock + } } } - /** Overrides: -

    update in class java.awt.Component
    */ /** * Overridden from Canvas to prevent the AWT's clearing of the * canvas from interfering with the OpenGL rendering. */ - @Override + @Override public void update(Graphics g) { paint(g); } @@ -681,7 +713,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing _lock.lock(); try { final GLContext oldCtx = context; - final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; if(newCtxCurrent) { context.makeCurrent(); @@ -692,6 +724,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } + @Override + public final GLDrawable getDelegatedDrawable() { + return drawable; + } + @Override public GLContext getContext() { return context; @@ -866,7 +903,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if(!disposeRegenerate) { if(null != awtConfig) { - disposeAbstractGraphicsDevice(); + AWTEDTExecutor.singleton.invoke(getTreeLock(), true, disposeAbstractGraphicsDeviceActionOnEDT); } awtConfig=null; } @@ -881,7 +918,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } }; - private final Runnable disposeAbstractGraphicsDeviceAction = new Runnable() { + /** + * Disposes the AbstractGraphicsDevice within EDT, + * since resources created (X11: Display), must be destroyed in the same thread, where they have been created. + * + * @see #chooseGraphicsConfiguration(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, java.awt.GraphicsDevice) + */ + private final Runnable disposeAbstractGraphicsDeviceActionOnEDT = new Runnable() { @Override public void run() { if(null != awtConfig) { @@ -900,27 +943,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } }; - - /** - * Disposes the AbstractGraphicsDevice within EDT, - * since resources created (X11: Display), must be destroyed in the same thread, where they have been created. - * - * @see #chooseGraphicsConfiguration(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, java.awt.GraphicsDevice) - */ - private void disposeAbstractGraphicsDevice() { - if( EventQueue.isDispatchThread() || Thread.holdsLock(getTreeLock()) ) { - disposeAbstractGraphicsDeviceAction.run(); - } else { - try { - EventQueue.invokeAndWait(disposeAbstractGraphicsDeviceAction); - } catch (InvocationTargetException e) { - throw new GLException(e.getTargetException()); - } catch (InterruptedException e) { - throw new GLException(e); - } - } - } - + private final Runnable initAction = new Runnable() { @Override public void run() { @@ -1046,7 +1069,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing * @param device * @return the chosen AWTGraphicsConfiguration * - * @see #disposeAbstractGraphicsDevice() + * @see #disposeAbstractGraphicsDeviceActionOnEDT */ private AWTGraphicsConfiguration chooseGraphicsConfiguration(final GLCapabilitiesImmutable capsChosen, final GLCapabilitiesImmutable capsRequested, diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index acb8f2183..6d4a5861f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -121,7 +121,7 @@ import com.jogamp.opengl.util.GLBuffers; *

    */ -@SuppressWarnings("serial") +@SuppressWarnings({ "serial", "deprecation" }) public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("GLJPanel"); @@ -396,7 +396,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing their reshape() method in order to function properly.

    reshape in class java.awt.Component
    */ - @SuppressWarnings("deprecation") @Override public void reshape(int x, int y, int width, int height) { super.reshape(x, y, width, height); @@ -471,7 +470,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return null; } final GLContext oldCtx = backend.getContext(); - final boolean newCtxCurrent = helper.switchContext(backend.getDrawable(), oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = GLDrawableHelper.switchContext(backend.getDrawable(), oldCtx, newCtx, additionalCtxCreationFlags); backend.setContext(newCtx); if(newCtxCurrent) { newCtx.makeCurrent(); @@ -480,6 +479,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } + @Override + public final GLDrawable getDelegatedDrawable() { + if (backend == null) { + return null; + } + return backend.getDrawable(); + } + @Override public GLContext getContext() { if (backend == null) { diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index cc4e1b434..07029f143 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -30,16 +30,15 @@ package jogamp.opengl; import java.io.PrintStream; -import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; import javax.media.opengl.FPSCounter; import javax.media.opengl.GL; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLAutoDrawableDelegate; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; @@ -49,6 +48,7 @@ import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.opengl.GLAutoDrawableDelegate; import com.jogamp.opengl.util.Animator; @@ -61,38 +61,36 @@ import com.jogamp.opengl.util.Animator; * @see GLWindow */ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { - public static final boolean DEBUG = Debug.debug("GLAutoDrawable"); + public static final boolean DEBUG = GLDrawableImpl.DEBUG; protected final GLDrawableHelper helper = new GLDrawableHelper(); protected final FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access protected GLContextImpl context; - protected final boolean ownDevice; + protected final boolean ownsDevice; protected int additionalCtxCreationFlags = 0; protected volatile boolean sendReshape = false; // volatile: maybe written by WindowManager thread w/o locking protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking /** - * @param drawable a valid {@link GLDrawableImpl}, may not be realized yet. - * @param context a valid {@link GLContextImpl}, may not be made current (created) yet. - * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, - * otherwise pass false. Closing the device is required in case - * the drawable is created w/ it's own new instance, e.g. offscreen drawables, - * and no further lifecycle handling is applied. + * @param drawable upstream {@link GLDrawableImpl} instance, may be null for lazy initialization + * @param context upstream {@link GLContextImpl} instance, may be null for lazy initialization + * @param ownsDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, + * otherwise pass false. Closing the device is required in case + * the drawable is created w/ it's own new instance, e.g. offscreen drawables, + * and no further lifecycle handling is applied. */ - public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context, boolean ownDevice) { + public GLAutoDrawableBase(GLDrawableImpl drawable, GLContextImpl context, boolean ownsDevice) { this.drawable = drawable; this.context = context; - this.ownDevice = ownDevice; + this.ownsDevice = ownsDevice; resetFPSCounter(); } + /** Returns the recursive lock object of the upstream implementation, which synchronizes multithreaded access. */ protected abstract RecursiveLock getLock(); - /** Returns the delegated GLDrawable */ - public final GLDrawable getDelegatedDrawable() { return drawable; } - /** Default implementation to handle repaint events from the windowing system */ protected final void defaultWindowRepaintOp() { final GLDrawable _drawable = drawable; @@ -103,29 +101,43 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } } - /** Default implementation to handle resize events from the windowing system */ - protected final void defaultWindowResizedOp() { - final GLDrawable _drawable = drawable; + /** Default implementation to handle resize events from the windowing system. All required locks are being claimed. */ + protected final void defaultWindowResizedOp(int newWidth, int newHeight) throws NativeWindowException, GLException { + GLDrawableImpl _drawable = drawable; if( null!=_drawable ) { if(DEBUG) { - System.err.println("GLAutoDrawableBase.sizeChanged: ("+Thread.currentThread().getName()+"): "+getWidth()+"x"+getHeight()+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + System.err.println("GLAutoDrawableBase.sizeChanged: ("+Thread.currentThread().getName()+"): "+newWidth+"x"+newHeight+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { + final RecursiveLock _lock = getLock(); + _lock.lock(); + try { + final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, context, newWidth, newHeight); + if(_drawable != _drawableNew) { + // write back + _drawable = _drawableNew; + drawable = _drawableNew; + } + } finally { + _lock.unlock(); + } } sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock if( _drawable.isRealized() ) { if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimating() ) { display(); } - } + } } } - + /** * Default implementation to handle destroy notifications from the windowing system. * *

    * If the {@link NativeSurface} does not implement {@link WindowClosingProtocol} * or {@link WindowClosingMode#DISPOSE_ON_CLOSE} is enabled (default), - * {@link #defaultDestroy()} is being called. + * a thread safe destruction is being induced. *

    */ protected final void defaultWindowDestroyNotifyOp() { @@ -174,7 +186,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { ctrl.resume(); } } else if (null != ns && ns.isSurfaceLockedByOtherThread()) { - // surface is locked by another thread + // Surface is locked by another thread. // Flag that destroy should be performed on the next // attempt to display. sendDestroy = true; // async, but avoiding deadlock @@ -225,7 +237,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } _drawable.setRealized(false); } - if( ownDevice ) { + if( ownsDevice ) { _drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice().close(); } } @@ -238,7 +250,6 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { _lock.lock(); try { if(drawable!=null && context != null) { - drawable.swapBuffers(); helper.invokeGL(drawable, context, defaultSwapAction, defaultInitAction); } } finally { @@ -276,7 +287,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { destroy(); return; } - final RecursiveLock _lock = getLock(); + final RecursiveLock _lock = getLock(); _lock.lock(); try { if( null != context ) { @@ -294,6 +305,11 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { drawable.swapBuffers(); } } ; + @Override + public final GLDrawable getDelegatedDrawable() { + return drawable; + } + @Override public final GLContext getContext() { return context; @@ -305,7 +321,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { lock.lock(); try { final GLContext oldCtx = context; - final boolean newCtxCurrent = helper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; if(newCtxCurrent) { context.makeCurrent(); @@ -529,4 +545,10 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { final GLDrawable _drawable = drawable; return null != _drawable ? _drawable.getHandle() : 0; } + + @Override + public String toString() { + return getClass().getSimpleName()+"[ \n\tHelper: " + helper + ", \n\tDrawable: " + drawable + + ", \n\tContext: " + context + /** ", \n\tWindow: "+window+ ", \n\tFactory: "+factory+ */ "]"; + } } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index e82756022..050c619fd 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -47,6 +47,7 @@ import java.util.Map; import com.jogamp.common.os.DynamicLookupHelper; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLNameResolver; @@ -85,6 +86,7 @@ public abstract class GLContextImpl extends GLContext { private String glRenderer; private String glRendererLowerCase; + private String glVersion; // Tracks creation and initialization of buffer objects to avoid // repeated glGet calls upon glMapBuffer operations @@ -126,6 +128,9 @@ public abstract class GLContextImpl extends GLContext { GLContextShareSet.synchronizeBufferObjectSharing(shareWith, this); this.drawable = drawable; + if(null != drawable) { + drawable.associateContext(this, true); + } this.drawableRead = drawable; this.glDebugHandler = new GLDebugMessageHandler(this); @@ -205,8 +210,10 @@ public abstract class GLContextImpl extends GLContext { if(!setWriteOnly || drawableRead==drawable) { // if !setWriteOnly || !explicitReadDrawable drawableRead = (GLDrawableImpl) readWrite; } - final GLDrawable old = drawable; + final GLDrawableImpl old = drawable; + old.associateContext(this, false); drawable = (GLDrawableImpl) readWrite ; + drawable.associateContext(this, true); if(lockHeld) { makeCurrent(); } @@ -272,7 +279,7 @@ public abstract class GLContextImpl extends GLContext { if( actualRelease ) { if( !inDestruction ) { try { - drawable.contextMadeCurrent(this, false); + contextMadeCurrent(false); } catch (Throwable t) { drawableContextMadeCurrentException = t; } @@ -331,7 +338,8 @@ public abstract class GLContextImpl extends GLContext { makeCurrent(); } try { - drawable.contextRealized(this, false); + contextRealized(false); + drawable.associateContext(this, false); } catch (Throwable t) { drawableContextRealizedException = t; } @@ -514,19 +522,17 @@ public abstract class GLContextImpl extends GLContext { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); } - drawable.contextRealized(this, true); + contextRealized(true); if(DEBUG || TRACE_SWITCH) { System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT_NEW - "+lock); } - } else { - drawable.contextMadeCurrent(this, true); - - if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock); - } + } else if(TRACE_SWITCH) { + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock); } + contextMadeCurrent(true); + /* FIXME: refactor dependence on Java 2D / JOGL bridge // Try cleaning up any stale server-side OpenGL objects @@ -608,6 +614,20 @@ public abstract class GLContextImpl extends GLContext { } protected abstract void makeCurrentImpl() throws GLException; + /** + * @see GLDrawableImpl#contextRealized(GLContext, boolean) + */ + protected void contextRealized(boolean realized) { + drawable.contextRealized(this, realized); + } + + /** + * @see GLDrawableImpl#contextMadeCurrent(GLContext, boolean) + */ + protected void contextMadeCurrent(boolean current) { + drawable.contextMadeCurrent(this, current); + } + /** * Platform dependent entry point for context creation.
    * @@ -934,52 +954,43 @@ public abstract class GLContextImpl extends GLContext { /** * If major > 0 || minor > 0 : Use passed values, determined at creation time - * If major==0 && minor == 0 : Use GL_VERSION * Otherwise .. don't touch .. */ private final void setContextVersion(int major, int minor, int ctp, boolean setVersionString) { - if (0==ctp) { + if ( 0 == ctp ) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - if(major>0 || minor>0) { - if (!GLContext.isValidGLVersion(major, minor)) { - GLException e = new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); - throw e; - } - ctxMajorVersion = major; - ctxMinorVersion = minor; - ctxOptions = ctp; - if(setVersionString) { - ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, getGL().glGetString(GL.GL_VERSION)); - } - return; + + if (!GLContext.isValidGLVersion(major, minor)) { + throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - - if(major==0 && minor==0) { - String versionStr = getGL().glGetString(GL.GL_VERSION); - if(null==versionStr) { - throw new GLException("GL_VERSION is NULL: "+this); - } - ctxOptions = ctp; - - // Set version - GLVersionNumber version = new GLVersionNumber(versionStr); + ctxMajorVersion = major; + ctxMinorVersion = minor; + ctxOptions = ctp; + if(setVersionString) { + ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, getGL().glGetString(GL.GL_VERSION)); + } + } + + private static final VersionNumber getGLVersionNumber(int ctp, String glVersionStr) { + if( null != glVersionStr ) { + final GLVersionNumber version = new GLVersionNumber(glVersionStr); if (version.isValid()) { - ctxMajorVersion = version.getMajor(); - ctxMinorVersion = version.getMinor(); - // We cannot promote a non ARB context to >= 3.1, - // reduce it to 3.0 then. - if ( ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) - && 0 == (ctxOptions & CTX_IS_ARB_CREATED) ) { - ctxMajorVersion = 3; - ctxMinorVersion = 0; - } - if(setVersionString) { - ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, versionStr); - } - return; + int major = version.getMajor(); + int minor = version.getMinor(); + // We cannot promote a non ARB context to >= 3.1, + // reduce it to 3.0 then. + if ( 0 == (ctp & CTX_IS_ARB_CREATED) && + ( major > 3 || major == 3 && minor >= 1 ) ) { + major = 3; + minor = 0; + } + if ( GLContext.isValidGLVersion(major, minor) ) { + return new VersionNumber(major, minor, 0); + } } } + return null; } //---------------------------------------------------------------------- @@ -1019,14 +1030,18 @@ public abstract class GLContextImpl extends GLContext { /** * Pbuffer support; given that this is a GLContext associated with a * pbuffer, binds this pbuffer to its texture target. + * @throws GLException if not implemented (default) + * @deprecated use FBO/GLOffscreenAutoDrawable instead of pbuffer */ - public abstract void bindPbufferToTexture(); + public void bindPbufferToTexture() { throw new GLException("not implemented"); } /** * Pbuffer support; given that this is a GLContext associated with a * pbuffer, releases this pbuffer from its texture target. + * @throws GLException if not implemented (default) + * @deprecated use FBO/GLOffscreenAutoDrawable instead of pbuffer */ - public abstract void releasePbufferFromTexture(); + public void releasePbufferFromTexture() { throw new GLException("not implemented"); } public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); @@ -1064,7 +1079,7 @@ public abstract class GLContextImpl extends GLContext { table.reset(getDrawableImpl().getGLDynamicLookupHelper() ); } - private final boolean initGLRendererStrings() { + private final boolean initGLRendererAndGLVersionStrings() { final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper(); final long _glGetString = glDynLookupHelper.dynamicLookupFunction("glGetString"); if(0 == _glGetString) { @@ -1083,14 +1098,27 @@ public abstract class GLContextImpl extends GLContext { Thread.dumpStack(); } return false; - } else { - glRenderer = _glRenderer; - glRendererLowerCase = glRenderer.toLowerCase(); - return true; } + glRenderer = _glRenderer; + glRendererLowerCase = glRenderer.toLowerCase(); + + final String _glVersion = glGetStringInt(GL.GL_VERSION, _glGetString); + if(null == _glVersion) { + // FIXME + if(DEBUG) { + System.err.println("Warning: GL_VERSION is NULL."); + Thread.dumpStack(); + } + return false; + } + glVersion = _glVersion; + return true; } } + protected final String getGLVersionString() { + return glVersion; + } protected final String getGLRendererString(boolean lowerCase) { return lowerCase ? glRendererLowerCase : glRenderer; } @@ -1128,17 +1156,44 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - if( !initGLRendererStrings() && DEBUG) { - System.err.println("Warning: intialization of GL renderer strings failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + { + final boolean initGLRendererAndGLVersionStringsOK = initGLRendererAndGLVersionStrings(); + if(DEBUG) { + if( !initGLRendererAndGLVersionStringsOK ) { + System.err.println("Warning: setGLFunctionAvailability: intialization of GL renderer strings failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + } else { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Given "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)); + } + } } if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; } - + + // Pick the version from the GL-version string, + // if smaller _or_ given major == 0. + final VersionNumber glVersionNumber; + { + final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0); + final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); + if( null != strGLVersionNumber && ( strGLVersionNumber.compareTo(setGLVersionNumber) <= 0 || 0 == major ) ) { + glVersionNumber = strGLVersionNumber; + major = glVersionNumber.getMajor(); + minor = glVersionNumber.getMinor(); + } else { + glVersionNumber = setGLVersionNumber; + } + } + if ( !GLContext.isValidGLVersion(major, minor) ) { + throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctxProfileBits)+", "+glVersion+", "+glVersionNumber); + } + if( 2 > major ) { // there is no ES2-compat for a profile w/ major < 2 + ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT; + } contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 validated FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion) + ", "+glVersionNumber); } // @@ -1201,6 +1256,10 @@ public abstract class GLContextImpl extends GLContext { ctxProfileBits |= CTX_IMPL_FBO; } + if(FORCE_NO_FBO_SUPPORT) { + ctxProfileBits &= ~CTX_IMPL_FBO ; + } + // // Set GL Version (complete w/ version string) // diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index e1e253d35..4f965f620 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -48,18 +48,21 @@ import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.MutableSurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; -import javax.media.opengl.GLCapabilities; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; +import javax.media.opengl.GLFBODrawable; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; import com.jogamp.nativewindow.MutableGraphicsConfiguration; +import com.jogamp.nativewindow.DelegatedUpstreamSurfaceHookWithSurfaceSize; +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; /** Extends GLDrawableFactory with a few methods for handling @@ -67,6 +70,7 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; Independent Bitmaps on Windows, pixmaps on X11). Direct access to these GLDrawables is not supplied directly to end users, though they may be instantiated by the GLJPanel implementation. */ +@SuppressWarnings("deprecation") public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { protected static final boolean DEBUG = GLDrawableImpl.DEBUG; @@ -141,55 +145,53 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true); if(null != ols) { // layered surface -> Offscreen/[FBO|PBuffer] - final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); - chosenCapsMod.setOnscreen(false); - chosenCapsMod.setDoubleBuffered(false); - /* if( isFBOAvailable ) { // FIXME JAU: FBO n/a yet - chosenCapsMod.setFBO(true); - } else */ - if( canCreateGLPbuffer(adevice) ) { - chosenCapsMod.setPBuffer(true); - } else { - chosenCapsMod.setFBO(false); - chosenCapsMod.setPBuffer(false); + final boolean isPbufferAvailable = canCreateGLPbuffer(adevice) ; + if(!isPbufferAvailable && !isFBOAvailable) { + throw new GLException("Neither FBO nor Pbuffer is available for "+target); } + final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, isFBOAvailable, isPbufferAvailable); config.setChosenCapabilities(chosenCapsMod); + ols.setChosenCapabilities(chosenCapsMod); if(DEBUG) { - System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable -> Offscreen-Layer: "+target); + System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable -> Offscreen-Layer"); + System.err.println("chosenCaps: "+chosenCaps); + System.err.println("chosenCapsMod: "+chosenCapsMod); + System.err.println("OffscreenLayerSurface: **** "+ols); + System.err.println("Target: **** "+target); + Thread.dumpStack(); } if( ! ( target instanceof MutableSurface ) ) { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target); } - if( ((GLCapabilitiesImmutable)config.getRequestedCapabilities()).isFBO() && isFBOAvailable ) { - // FIXME JAU: Need to revise passed MutableSurface to work w/ FBO .. - final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(target); - result = new GLFBODrawableImpl(this, dummyDrawable, target, target.getWidth(), target.getHeight(), 0 /* textureUnit */); + if( chosenCapsMod.isFBO() && isFBOAvailable ) { + // target surface is already a native one + result = createFBODrawableImpl(target, chosenCapsMod, 0); } else { result = createOffscreenDrawableImpl(target); } } else if(chosenCaps.isOnscreen()) { // onscreen + final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(chosenCaps); + config.setChosenCapabilities(chosenCapsMod); if(DEBUG) { System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable: "+target); } result = createOnscreenDrawableImpl(target); } else { // offscreen - final GLCapabilitiesImmutable reqCaps = (GLCapabilitiesImmutable)config.getRequestedCapabilities(); if(DEBUG) { - System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable, FBO req / chosen - avail, PBuffer: "+reqCaps.isFBO()+" / "+chosenCaps.isFBO()+" - "+isFBOAvailable+", "+chosenCaps.isPBuffer()+": "+target); + System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OffScreenDrawable, FBO chosen / avail, PBuffer: "+ + chosenCaps.isFBO()+" / "+isFBOAvailable+", "+chosenCaps.isPBuffer()+": "+target); } if( ! ( target instanceof MutableSurface ) ) { - throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen: "+target); + throw new IllegalArgumentException("Passed NativeSurface must implement MutableSurface for offscreen: "+target); } - if( reqCaps.isFBO() && isFBOAvailable ) { - // FIXME JAU: Need to revise passed MutableSurface to work w/ FBO .. - final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(target); - result = new GLFBODrawableImpl(this, dummyDrawable, target, target.getWidth(), target.getHeight(), 0 /* textureUnit */); + if( chosenCaps.isFBO() && isFBOAvailable ) { + // need to hook-up a native dummy surface since source may not have + final ProxySurface dummySurface = createDummySurfaceImpl(adevice, true, chosenCaps, null, 64, 64); + dummySurface.setUpstreamSurfaceHook(new DelegatedUpstreamSurfaceHookWithSurfaceSize(dummySurface.getUpstreamSurfaceHook(), target)); + result = createFBODrawableImpl(dummySurface, chosenCaps, 0); } else { - final GLCapabilities chosenCapsMod = (GLCapabilities) chosenCaps.cloneMutable(); - chosenCapsMod.setDoubleBuffered(false); - config.setChosenCapabilities(chosenCapsMod); result = createOffscreenDrawableImpl(target); } } @@ -211,7 +213,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { //--------------------------------------------------------------------------- // - // PBuffer Offscreen GLDrawable construction + // PBuffer Offscreen GLAutoDrawable construction // @Override @@ -239,7 +241,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { GLDrawableImpl drawable = null; device.lock(); try { - drawable = (GLDrawableImpl) createGLDrawable( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, width, height, null) ); + drawable = createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + new UpstreamSurfaceHookMutableSize(width, height) ) ); if(null != drawable) { drawable.setRealized(true); } @@ -247,10 +250,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { device.unlock(); } - if(null==drawable) { - throw new GLException("Could not create Pbuffer drawable for: "+device+", "+capsChosen+", "+width+"x"+height); - } - return new GLPbufferImpl( drawable, shareWith, true); + return new GLPbufferImpl( drawable, (GLContextImpl) drawable.createContext(shareWith) ); } //--------------------------------------------------------------------------- @@ -258,6 +258,29 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // Offscreen GLDrawable construction // + public final boolean canCreateFBO(AbstractGraphicsDevice deviceReq, GLProfile glp) { + AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); + if(null == device) { + throw new GLException("No shared device for requested: "+deviceReq); + } + return GLContext.isFBOAvailable(device, glp); + } + + @Override + public GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice deviceReq, + GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, + int width, int height, + GLContext shareWith) { + final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height ); + drawable.setRealized(true); + final GLContext context = drawable.createContext(shareWith); + if(drawable instanceof GLFBODrawableImpl) { + return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, context, null, null ); + } + return new GLOffscreenAutoDrawableImpl( drawable, context, null, null); + } + @Override public GLDrawable createOffscreenDrawable(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, @@ -274,10 +297,13 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, GLContext.isFBOAvailable(device, capsRequested.getGLProfile()), canCreateGLPbuffer(device)); + if( capsChosen.isFBO() ) { device.lock(); try { - return createFBODrawableImpl(device, capsRequested, chooser, width, height); + final ProxySurface dummySurface = createDummySurfaceImpl(device, true, capsRequested, null, width, height); + final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); + return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); } finally { device.unlock(); } @@ -285,20 +311,17 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { device.lock(); try { - return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, width, height, null) ); + return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, + new UpstreamSurfaceHookMutableSize(width, height) ) ); } finally { device.unlock(); } } - /** Creates a platform independent offscreen FBO GLDrawable implementation */ - protected GLDrawable createFBODrawableImpl(AbstractGraphicsDevice device, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, - int initialWidth, int initialHeight) { - final GLCapabilitiesImmutable dummyCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); - final NativeSurface dummySurface = createDummySurfaceImpl(device, true, dummyCaps, null, 64, 64); + /** Creates a platform independent FBO offscreen GLDrawable */ + protected GLFBODrawable createFBODrawableImpl(NativeSurface dummySurface, GLCapabilitiesImmutable fboCaps, int textureUnit) { final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); - - return new GLFBODrawableImpl(this, dummyDrawable, dummySurface, initialWidth, initialHeight, 0 /* textureUnit */); + return new GLFBODrawableImpl(this, dummyDrawable, dummySurface, fboCaps, textureUnit); } /** Creates a platform dependent offscreen pbuffer/pixmap GLDrawable implementation */ @@ -318,15 +341,13 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param capsChosen * @param capsRequested * @param chooser the custom chooser, may be null for default - * @param width the initial width - * @param height the initial height - * @param lifecycleHook optional control of the surface's lifecycle + * @param upstreamHook surface size information and optional control of the surface's lifecycle * @return the created {@link MutableSurface} instance w/o defined surface handle */ protected abstract ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook); + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook); /** * A dummy surface is not visible on screen and will not be used to render directly to, @@ -341,9 +362,9 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param width the initial width * @param height the initial height * - * @return the created {@link MutableSurface} instance w/o defined surface handle + * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. */ - public NativeSurface createDummySurface(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, + public ProxySurface createDummySurface(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final AbstractGraphicsDevice device = getOrCreateSharedDevice(deviceReq); if(null == device) { @@ -369,9 +390,11 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * otherwise device instance is used as-is. * @param requestedCaps * @param chooser the custom chooser, may be null for default - * @param width the initial width - * @param height the initial height - * @return the created {@link MutableSurface} instance w/o defined surface handle + * @param width the initial width as returned by {@link NativeSurface#getWidth()}, not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()}, not the actual dummy surface height, + * The latter is platform specific and small + * @return the created {@link ProxySurface} instance w/o defined surface handle but platform specific {@link UpstreamSurfaceHook}. */ public abstract ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice device, boolean createNewDevice, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 090c5fe69..bdf0b6d74 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -43,12 +43,19 @@ package jogamp.opengl; import java.util.ArrayList; import java.util.HashSet; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; +import javax.media.opengl.GLFBODrawable; import javax.media.opengl.GLRunnable; import com.jogamp.opengl.util.Animator; @@ -108,24 +115,27 @@ public class GLDrawableHelper { /** * Associate a new context to the drawable and also propagates the context/drawable switch by * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. - *

    - * If the old context's drawable was an {@link GLAutoDrawable}, it's reference to the given drawable - * is being cleared by calling - * {@link GLAutoDrawable#setContext(GLContext) ((GLAutoDrawable)oldCtx.getGLDrawable()).setContext(null)}. - *

    *

    * If the old or new context was current on this thread, it is being released before switching the drawable. *

    + *

    + * Be aware that the old context is still bound to the drawable, + * and that one context can only bound to one drawable at one time! + *

    + *

    + * No locking is being performed on the drawable, caller is required to take care of it. + *

    * * @param drawable the drawable which context is changed - * @param newCtx the new context * @param oldCtx the old context - * @return true if the newt context was current, otherwise false + * @param newCtx the new context + * @param newCtxCreationFlags additional creation flags if newCtx is not null and not been created yet, see {@link GLContext#setContextCreationFlags(int)} + * @return true if the new context was current, otherwise false * * @see GLAutoDrawable#setContext(GLContext) */ - public final boolean switchContext(GLDrawable drawable, GLContext oldCtx, GLContext newCtx, int additionalCtxCreationFlags) { - if(null != oldCtx && oldCtx.isCurrent()) { + public static final boolean switchContext(GLDrawable drawable, GLContext oldCtx, GLContext newCtx, int newCtxCreationFlags) { + if( null != oldCtx && oldCtx.isCurrent() ) { oldCtx.release(); } final boolean newCtxCurrent; @@ -134,17 +144,135 @@ public class GLDrawableHelper { if(newCtxCurrent) { newCtx.release(); } - newCtx.setContextCreationFlags(additionalCtxCreationFlags); + newCtx.setContextCreationFlags(newCtxCreationFlags); newCtx.setGLDrawable(drawable, true); // propagate context/drawable switch } else { newCtxCurrent = false; } - if(null!=oldCtx && oldCtx.getGLDrawable() instanceof GLAutoDrawable) { - ((GLAutoDrawable)oldCtx.getGLDrawable()).setContext(null); - } return newCtxCurrent; } + /** + * If the drawable is not realized, OP is a NOP. + *
      + *
    • release context if current
    • + *
    • destroy old drawable
    • + *
    • create new drawable
    • + *
    • attach new drawable to context
    • + *
    • make context current, if it was current
    • + *
    + *

    + * No locking is being performed, caller is required to take care of it. + *

    + * + * @param drawable + * @param context maybe null + * @return the new drawable + */ + public static final GLDrawableImpl recreateGLDrawable(GLDrawableImpl drawable, GLContext context) { + if( ! drawable.isRealized() ) { + return drawable; + } + final boolean contextCurrent = null != context && context.isCurrent(); + final GLDrawableFactory factory = drawable.getFactory(); + final NativeSurface surface = drawable.getNativeSurface(); + final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface)surface : null; + + if(contextCurrent) { + context.release(); + } + + if(null != proxySurface) { + proxySurface.enableUpstreamSurfaceHookLifecycle(false); + } + try { + drawable.setRealized(false); + drawable = (GLDrawableImpl) factory.createGLDrawable(surface); // [2] + drawable.setRealized(true); + } finally { + if(null != proxySurface) { + proxySurface.enableUpstreamSurfaceHookLifecycle(true); + } + } + + if(null != context) { + context.setGLDrawable(drawable, true); // re-association + } + + if(contextCurrent) { + context.makeCurrent(); + } + return drawable; + } + + /** + * Performs resize operation on the given drawable, assuming it is offscreen. + *

    + * The {@link GLDrawableImpl}'s {@link NativeSurface} is being locked during operation. + * In case the holder is an auto drawable or similar, it's lock shall be claimed by the caller. + *

    + *

    + * May recreate the drawable via {@link #recreateGLDrawable(GLDrawableImpl, GLContext)} + * in case of a a pbuffer- or pixmap-drawable. + *

    + *

    + * FBO drawables are resized w/o drawable destruction. + *

    + *

    + * Offscreen resize operation is validated w/ drawable size in the end. + * An exception is thrown if not successful. + *

    + * + * @param drawable + * @param context + * @param newWidth the new width, it's minimum is capped to 1 + * @param newHeight the new height, it's minimum is capped to 1 + * @return the new drawable in case of an pbuffer/pixmap drawable, otherwise the passed drawable is being returned. + * @throws NativeWindowException is drawable is not offscreen or it's surface lock couldn't be claimed + * @throws GLException may be thrown a resize operation + */ + public static final GLDrawableImpl resizeOffscreenDrawable(GLDrawableImpl drawable, GLContext context, int newWidth, int newHeight) + throws NativeWindowException, GLException + { + if(drawable.getChosenGLCapabilities().isOnscreen()) { + throw new NativeWindowException("Drawable is not offscreen: "+drawable); + } + final NativeSurface ns = drawable.getNativeSurface(); + final int lockRes = ns.lockSurface(); + if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { + throw new NativeWindowException("Could not lock surface of drawable: "+drawable); + } + try { + if(0>=newWidth) { newWidth = 1; } + if(0>=newHeight) { newHeight = 1; } + // propagate new size + if(ns instanceof ProxySurface) { + final ProxySurface ps = (ProxySurface) ns; + final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); + if(ush instanceof UpstreamSurfaceHook.MutableSize) { + ((UpstreamSurfaceHook.MutableSize)ush).setSize(newWidth, newHeight); + } else if(DEBUG) { // we have to assume UpstreamSurfaceHook contains the new size already, hence size check @ bottom + System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen ProxySurface n.a. UpstreamSurfaceHook.MutableSize, but "+ush.getClass().getName()+": "+ush); + } + } else if(DEBUG) { // we have to assume surface contains the new size already, hence size check @ bottom + System.err.println("GLDrawableHelper.resizeOffscreenDrawable: Drawable's offscreen surface n.a. ProxySurface, but "+ns.getClass().getName()+": "+ns); + } + if(drawable instanceof GLFBODrawable) { + if( null != context && context.isCreated() ) { + ((GLFBODrawable) drawable).resetSize(context.getGL()); + } + } else { + drawable = GLDrawableHelper.recreateGLDrawable(drawable, context); + } + } finally { + ns.unlockSurface(); + } + if(drawable.getWidth() != newWidth || drawable.getHeight() != newHeight) { + throw new InternalError("Incomplete resize operation: expected "+newWidth+"x"+newHeight+", has: "+drawable); + } + return drawable; + } + public final void addGLEventListener(GLEventListener listener) { addGLEventListener(-1, listener); } @@ -196,15 +324,11 @@ public class GLDrawableHelper { } } - private final boolean init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape) { - if(listenersToBeInit.remove(l)) { - l.init(drawable); - if(sendReshape) { - reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), true /* setViewport */, false /* checkInit */); - } - return true; + private final void init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape) { + l.init(drawable); + if(sendReshape) { + reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), true /* setViewport */, false /* checkInit */); } - return false; } /** The default init action to be called once after ctx is being created @ 1st makeCurrent(). */ @@ -214,14 +338,11 @@ public class GLDrawableHelper { for (int i=0; i < _listeners.size(); i++) { final GLEventListener listener = _listeners.get(i) ; - // If make current ctx, invoked by invokGL(..), results in a new ctx, init gets called. + // If make ctx current, invoked by invokGL(..), results in a new ctx, init gets called. // This may happen not just for initial setup, but for ctx recreation due to resource change (drawable/window), - // hence the must always be initialized unconditional. - listenersToBeInit.add(listener); - - if ( ! init( listener, drawable, true /* sendReshape */) ) { - throw new GLException("GLEventListener "+listener+" already initialized: "+drawable); - } + // hence it must be called unconditional, always. + listenersToBeInit.remove(listener); // remove if exist, avoiding dbl init + init( listener, drawable, true /* sendReshape */); } } } @@ -239,7 +360,9 @@ public class GLDrawableHelper { final GLEventListener listener = _listeners.get(i) ; // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable - init( listener, drawable, true /* sendReshape */) ; + if( listenersToBeInit.remove(listener) ) { + init( listener, drawable, true /* sendReshape */) ; + } listener.display(drawable); } } @@ -251,7 +374,9 @@ public class GLDrawableHelper { // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable synchronized(listenersLock) { - init( listener, drawable, false /* sendReshape */) ; + if( listenersToBeInit.remove(listener) ) { + init( listener, drawable, false /* sendReshape */) ; + } } } if(setViewport) { diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index abf2bf557..311690f1d 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -43,6 +43,7 @@ package jogamp.opengl; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; +import javax.media.opengl.GL; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; @@ -76,31 +77,46 @@ public abstract class GLDrawableImpl implements GLDrawable { if( !realized ) { return; // destroyed already } - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); - if ( caps.getDoubleBuffered() ) { - if(!surface.surfaceSwap()) { - int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] - if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { - return; + int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] + if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { + return; + } + try { + if (NativeSurface.LOCK_SURFACE_CHANGED == lockRes) { + updateHandle(); + } + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); + if ( caps.getDoubleBuffered() ) { + if(!surface.surfaceSwap()) { + swapBuffersImpl(true); } - try { - if (NativeSurface.LOCK_SURFACE_CHANGED == lockRes) { - updateHandle(); - } - swapBuffersImpl(); - } finally { - unlockSurface(); + } else { + final GLContext ctx = GLContext.getCurrent(); + if(null!=ctx && ctx.getGLDrawable()==this) { + ctx.getGL().glFlush(); } + swapBuffersImpl(false); } - } else { - GLContext ctx = GLContext.getCurrent(); - if(null!=ctx && ctx.getGLDrawable()==this) { - ctx.getGL().glFinish(); - } - } + } finally { + unlockSurface(); + } surface.surfaceUpdated(this, surface, System.currentTimeMillis()); } - protected abstract void swapBuffersImpl(); + + /** + * Platform and implementation depending surface swap. + *

    The surface is locked.

    + *

    + * If doubleBuffered is true, + * an actual platform dependent surface swap shall be executed. + *

    + *

    + * If doubleBuffered is false, + * {@link GL#glFlush()} has been called already and + * the implementation may execute implementation specific code. + *

    + */ + protected abstract void swapBuffersImpl(boolean doubleBuffered); public final static String toHexString(long hex) { return "0x" + Long.toHexString(hex); @@ -181,6 +197,9 @@ public abstract class GLDrawableImpl implements GLDrawable { System.err.println(getThreadName() + ": setRealized: "+getClass().getName()+" "+this.realized+" == "+realizedArg); } } + /** + * Platform specific realization of drawable + */ protected abstract void setRealizedImpl(); /** @@ -189,7 +208,7 @@ public abstract class GLDrawableImpl implements GLDrawable { * If realized is true, the context has just been created and made current. *

    *

    - * If realized is false, the context is still current and will be release and destroyed after this method returns. + * If realized is false, the context is still current and will be released and destroyed after this method returns. *

    *

    * @see #contextMadeCurrent(GLContext, boolean) @@ -199,18 +218,27 @@ public abstract class GLDrawableImpl implements GLDrawable { /** * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: makeCurrent, release. *

    - * Will not be called if {@link #contextRealized(GLContext, boolean)} has been triggered. - *

    - *

    * If current is true, the context has just been made current. *

    *

    * If current is false, the context is still current and will be release after this method returns. *

    + *

    + * Note: Will also be called after {@link #contextRealized(GLContext, boolean) contextRealized(ctx, true)} + * but not at context destruction, i.e. {@link #contextRealized(GLContext, boolean) contextRealized(ctx, false)}. + *

    * @see #contextRealized(GLContext, boolean) */ protected void contextMadeCurrent(GLContext glc, boolean current) { } + /** + * Callback for special implementations, allowing to associate bound context to this drawable (bound == true) + * or to remove such association (bound == false). + * @param ctx the just bounded or unbounded context + * @param bound if true create an association, otherwise remove it + */ + protected void associateContext(GLContext ctx, boolean bound) { } + /** Callback for special implementations, allowing GLContext to fetch a custom default render framebuffer. Defaults to zero.*/ protected int getDefaultDrawFramebuffer() { return 0; } /** Callback for special implementations, allowing GLContext to fetch a custom default read framebuffer. Defaults to zero. */ @@ -245,8 +273,8 @@ public abstract class GLDrawableImpl implements GLDrawable { public String toString() { return getClass().getSimpleName()+"[Realized "+isRealized()+ ",\n\tFactory "+getFactory()+ - ",\n\thandle "+toHexString(getHandle())+ - ",\n\tWindow "+getNativeSurface()+"]"; + ",\n\tHandle "+toHexString(getHandle())+ + ",\n\tSurface "+getNativeSurface()+"]"; } protected static String getThreadName() { diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index 03bc26cbc..de45466f3 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -1,142 +1,476 @@ package jogamp.opengl; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GL; -import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; +import javax.media.opengl.GLFBODrawable; import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.Attachment; +import com.jogamp.opengl.FBObject.Colorbuffer; import com.jogamp.opengl.FBObject.TextureAttachment; /** - * Offscreen GLDrawable implementation using framebuffer object (FBO) - * as it's offscreen rendering mechanism. + * {@link FBObject} offscreen GLDrawable implementation, i.e. {@link GLFBODrawable}. + *

    + * It utilizes the context lifecycle hook {@link #contextRealized(GLContext, boolean)} + * to initialize the {@link FBObject} instance. + *

    + *

    + * It utilizes the context current hook {@link #contextMadeCurrent(GLContext, boolean) contextMadeCurrent(context, true)} + * to {@link FBObject#bind(GL) bind} the FBO. + *

    + * See {@link GLFBODrawable} for double buffering details. * * @see GLDrawableImpl#contextRealized(GLContext, boolean) * @see GLDrawableImpl#contextMadeCurrent(GLContext, boolean) * @see GLDrawableImpl#getDefaultDrawFramebuffer() * @see GLDrawableImpl#getDefaultReadFramebuffer() */ -public class GLFBODrawableImpl extends GLDrawableImpl { - final GLDrawableImpl parent; - final FBObject fbo; - int texUnit; - int samplesTexUnit = 0; - int width=0, height=0, samples=0; - - protected GLFBODrawableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, - NativeSurface surface, int initialWidth, int initialHeight, int textureUnit) { +public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { + protected static final boolean DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject"); + + private final GLDrawableImpl parent; + + private boolean initialized; + private int texUnit; + private int samples; + + private FBObject[] fbos; + private int fboIBack; // points to GL_BACK buffer + private int fboIFront; // points to GL_FRONT buffer + private FBObject pendingFBOReset = null; + private boolean fboBound; + private static final int bufferCount = 2; // number of FBOs for double buffering. TODO: Possible to configure! + + // private DoubleBufferMode doubleBufferMode; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + + private SwapBufferContext swapBufferContext; + + public static interface SwapBufferContext { + public void swapBuffers(boolean doubleBuffered); + } + + protected GLFBODrawableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, NativeSurface surface, + GLCapabilitiesImmutable fboCaps, int textureUnit) { super(factory, surface, false); + this.initialized = false; + + // Replace the chosen caps of dummy-surface w/ it's clone and copied values of orig FBO caps request. + // The dummy-surface has already been configured, hence value replace is OK + // and due to cloning, the native GLCapability portion is being preserved. + final MutableGraphicsConfiguration msConfig = (MutableGraphicsConfiguration) surface.getGraphicsConfiguration(); + final GLCapabilities fboCapsNative = (GLCapabilities) msConfig.getChosenCapabilities().cloneMutable(); + fboCapsNative.copyFrom(fboCaps); + msConfig.setChosenCapabilities(fboCapsNative); + this.parent = parent; this.texUnit = textureUnit; - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); - this.width = initialWidth; - this.height = initialHeight; - this.samples = caps.getNumSamples(); - this.fbo = new FBObject(); + this.samples = fboCaps.getNumSamples(); + + // default .. // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + // this.doubleBufferMode = ( samples > 0 || fboCaps.getDoubleBuffered() ) ? DoubleBufferMode.FBO : DoubleBufferMode.NONE ; + + this.swapBufferContext = null; } - @Override - protected void contextRealized(GLContext glc, boolean realized) { - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); - final GL gl = glc.getGL(); - if(realized) { - fbo.reset(gl, width, height, samples); - samples = fbo.getNumSamples(); // update, maybe capped + private final void initialize(boolean realize, GL gl) { + if(realize) { + final int maxSamples = gl.getMaxRenderbufferSamples(); + samples = samples <= maxSamples ? samples : maxSamples; + + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) surface.getGraphicsConfiguration().getChosenCapabilities(); + final int fbosN; if(samples > 0) { - fbo.attachColorbuffer(gl, 0, caps.getAlphaBits()>0); + fbosN = 1; + } else if( caps.getDoubleBuffered() ) { + fbosN = bufferCount; } else { - fbo.attachTexture2D(gl, 0, caps.getAlphaBits()>0); + fbosN = 1; } - if( caps.getStencilBits() > 0 ) { - fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24); - } else { - fbo.attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); + + fbos = new FBObject[fbosN]; + fboIBack = 0; // head + fboIFront = fbos.length - 1; // tail + + for(int i=0; i 0) { + fbos[i].attachColorbuffer(gl, 0, caps.getAlphaBits()>0); + } else { + fbos[i].attachTexture2D(gl, 0, caps.getAlphaBits()>0); + } + if( caps.getStencilBits() > 0 ) { + fbos[i].attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24); + } else { + fbos[i].attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); + } } - } else if(null != fbo) { - fbo.destroy(gl); - } - } - - @Override - protected void contextMadeCurrent(GLContext glc, boolean current) { - final GL gl = glc.getGL(); - if(current) { - fbo.bind(gl); + fbos[fboIFront].syncFramebuffer(gl); + fboBound = false; + final GLCapabilities fboCapsNative = (GLCapabilities) surface.getGraphicsConfiguration().getChosenCapabilities(); + fbos[0].formatToGLCapabilities(fboCapsNative); + fboCapsNative.setDoubleBuffered( fboCapsNative.getDoubleBuffered() || samples > 0 ); + + initialized = true; } else { - fbo.unbind(gl); - final TextureAttachment attachment = samples > 0 ? fbo.getSamplingSink() : (TextureAttachment) fbo.getColorbuffer(0) ; - if(null == attachment) { - throw new GLException("Null texture colorbuffer, samples "+samples+", "+fbo.toString()); - } - gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit); - fbo.use(gl, attachment ); - if( samples > 0) { - gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbo.getReadFramebuffer()); + initialized = false; + + for(int i=0; i "+newSamples); + } + initialize(false, gl); + samples = newSamples; + initialize(true, gl); + } else { + if(DEBUG) { + System.err.println("GLFBODrawableImpl.reset(): simple reconfig: "+samples+" -> "+newSamples); + } + final int nWidth = getWidth(); + final int nHeight = getHeight(); + samples = newSamples; + pendingFBOReset = ( 1 < fbos.length ) ? fbos[fboIFront] : null; // pending-front reset only w/ double buffering (or zero samples) + for(int i=0; i 0 ) { + res = fbos[0].getSamplingSinkFBO(); + } else { + res = fbos[fboIFront]; + } + break; + case GL.GL_BACK: + res = fbos[fboIBack]; + break; + default: + throw new IllegalArgumentException(illegalBufferName+toHexString(bufferName)); + } + return res; + } + + @Override + public final TextureAttachment getTextureBuffer(int bufferName) throws IllegalArgumentException { + if(!initialized) { + return null; + } + final TextureAttachment res; + switch(bufferName) { + case GL.GL_FRONT: + if( samples > 0 ) { + res = fbos[0].getSamplingSink(); + } else { + res = (TextureAttachment) fbos[fboIFront].getColorbuffer(0); + } + break; + case GL.GL_BACK: + if( samples > 0 ) { + throw new IllegalArgumentException("Cannot access GL_BACK buffer of MSAA FBO: "+this); + } else { + res = (TextureAttachment) fbos[fboIBack].getColorbuffer(0); + } + break; + default: + throw new IllegalArgumentException(illegalBufferName+toHexString(bufferName)); + } + return res; + } + private static final String illegalBufferName = "Only GL_FRONT and GL_BACK buffer are allowed, passed "; + + @Override + public String toString() { + return getClass().getSimpleName()+"[Initialized "+initialized+", realized "+isRealized()+", texUnit "+texUnit+", samples "+samples+ + ",\n\tFactory "+getFactory()+ + ",\n\tHandle "+toHexString(getHandle())+ + ",\n\tCaps "+surface.getGraphicsConfiguration().getChosenCapabilities()+ + ",\n\tfboI back "+fboIBack+", front "+fboIFront+", num "+(initialized ? fbos.length : 0)+ + ",\n\tFBO front read "+getDefaultReadFramebuffer()+", "+getFBObject(GL.GL_FRONT)+ + ",\n\tFBO back write "+getDefaultDrawFramebuffer()+", "+getFBObject(GL.GL_BACK)+ + ",\n\tSurface "+getNativeSurface()+ + "]"; + } + + public static class ResizeableImpl extends GLFBODrawableImpl implements GLFBODrawable.Resizeable { + protected ResizeableImpl(GLDrawableFactoryImpl factory, GLDrawableImpl parent, ProxySurface surface, + GLCapabilitiesImmutable fboCaps, int textureUnit) { + super(factory, parent, surface, fboCaps, textureUnit); + } + + @Override + public final void setSize(GLContext context, int newWidth, int newHeight) throws NativeWindowException, GLException { + if(DEBUG) { + System.err.println("GLFBODrawableImpl.ResizeableImpl setSize: ("+Thread.currentThread().getName()+"): "+newWidth+"x"+newHeight+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + } + int lockRes = lockSurface(); + if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { + throw new NativeWindowException("Could not lock surface: "+this); + } + try { + // propagate new size + final ProxySurface ps = (ProxySurface) getNativeSurface(); + final UpstreamSurfaceHook ush = ps.getUpstreamSurfaceHook(); + if(ush instanceof UpstreamSurfaceHook.MutableSize) { + ((UpstreamSurfaceHook.MutableSize)ush).setSize(newWidth, newHeight); + } else { + throw new InternalError("GLFBODrawableImpl.ResizableImpl's ProxySurface doesn't hold a UpstreamSurfaceHookMutableSize but "+ush.getClass().getName()+", "+ps+", ush"); + } + if( null != context && context.isCreated() ) { + resetSize(context.getGL()); + } + } finally { + unlockSurface(); + } + } + } } diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java index 768fc6892..79f96b64a 100644 --- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java +++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java @@ -28,8 +28,12 @@ package jogamp.opengl; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; + +import com.jogamp.common.os.Platform; public class GLGraphicsConfigurationUtil { public static final String NV_coverage_sample = "NV_coverage_sample"; @@ -119,26 +123,34 @@ public class GLGraphicsConfigurationUtil { return getExclusiveWinAttributeBits(caps.isOnscreen(), caps.isFBO(), caps.isPBuffer(), caps.isBitmap()); } - public static final GLCapabilities setWinAttributeBits(GLCapabilities caps, int winattrbits) { + public static final GLCapabilities fixWinAttribBitsAndHwAccel(AbstractGraphicsDevice device, int winattrbits, GLCapabilities caps) { caps.setBitmap ( 0 != ( BITMAP_BIT & winattrbits ) ); caps.setPBuffer ( 0 != ( PBUFFER_BIT & winattrbits ) ); caps.setFBO ( 0 != ( FBO_BIT & winattrbits ) ); // we reflect availability semantics, hence setting onscreen at last (maybe overwritten above)! - caps.setOnscreen( 0 != ( WINDOW_BIT & winattrbits ) ); - return caps; - } + caps.setOnscreen( 0 != ( WINDOW_BIT & winattrbits ) ); + final int accel = GLContext.isHardwareRasterizer( device, caps.getGLProfile() ); + if(0 == accel && caps.getHardwareAccelerated() ) { + caps.setHardwareAccelerated(false); + } + + return caps; + } + public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { if( !capsRequested.isOnscreen() ) { return fixOffscreenGLCapabilities(capsRequested, fboAvailable, pbufferAvailable); - } + } /* we maintain the offscreen mode flags in onscreen mode - else { + return fixOnscreenGLCapabilities(capsRequested); + } */ return capsRequested; } public static GLCapabilitiesImmutable fixOnscreenGLCapabilities(GLCapabilitiesImmutable capsRequested) { - if( !capsRequested.isOnscreen() ) { + if( !capsRequested.isOnscreen() || capsRequested.isFBO() || capsRequested.isPBuffer() || capsRequested.isBitmap() ) { // fix caps .. final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); caps2.setBitmap (false); @@ -157,9 +169,11 @@ public class GLGraphicsConfigurationUtil { public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { final boolean auto = !capsRequested.isFBO() && !capsRequested.isPBuffer() && !capsRequested.isBitmap() ; + + final boolean requestedPBuffer = capsRequested.isPBuffer() || Platform.getOSType() == Platform.OSType.MACOS ; // no native bitmap for OSX final boolean useFBO = fboAvailable && ( auto || capsRequested.isFBO() ) ; - final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || capsRequested.isPBuffer() ) ; + final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || requestedPBuffer ) ; final boolean useBitmap = !useFBO && !usePbuffer && ( auto || capsRequested.isBitmap() ) ; if( capsRequested.isOnscreen() || diff --git a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java new file mode 100644 index 000000000..7701f209f --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java @@ -0,0 +1,123 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl; + +import javax.media.nativewindow.NativeWindowException; +import javax.media.opengl.GL; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLException; +import javax.media.opengl.GLOffscreenAutoDrawable; + +import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.GLAutoDrawableDelegate; + +import jogamp.opengl.GLFBODrawableImpl; + +public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implements GLOffscreenAutoDrawable { + + /** + * @param drawable a valid and already realized {@link GLDrawable} + * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + * @param lock optional upstream lock, may be null + */ + public GLOffscreenAutoDrawableImpl(GLDrawable drawable, GLContext context, Object upstreamWidget, RecursiveLock lock) { + super(drawable, context, upstreamWidget, true, lock); + } + + @Override + public void setSize(int newWidth, int newHeight) throws NativeWindowException, GLException { + this.defaultWindowResizedOp(newWidth, newHeight); + } + + public static class FBOImpl extends GLOffscreenAutoDrawableImpl implements GLOffscreenAutoDrawable.FBO { + /** + * @param drawable a valid and already realized {@link GLDrawable} + * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. + * @param lock optional upstream lock, may be null + */ + public FBOImpl(GLFBODrawableImpl drawable, GLContext context, Object upstreamWidget, RecursiveLock lock) { + super(drawable, context, upstreamWidget, lock); + } + + @Override + public boolean isInitialized() { + return ((GLFBODrawableImpl)drawable).isInitialized(); + } + + @Override + public final int getTextureUnit() { + return ((GLFBODrawableImpl)drawable).getTextureUnit(); + } + + @Override + public final void setTextureUnit(int unit) { + ((GLFBODrawableImpl)drawable).setTextureUnit(unit); + } + + @Override + public final int getNumSamples() { + return ((GLFBODrawableImpl)drawable).getNumSamples(); + } + + @Override + public final void setNumSamples(GL gl, int newSamples) throws GLException { + ((GLFBODrawableImpl)drawable).setNumSamples(gl, newSamples); + windowRepaintOp(); + } + + /** // TODO: Add or remove TEXTURE (only) DoubleBufferMode support + @Override + public DoubleBufferMode getDoubleBufferMode() { + return ((GLFBODrawableImpl)drawable).getDoubleBufferMode(); + } + + @Override + public void setDoubleBufferMode(DoubleBufferMode mode) throws GLException { + ((GLFBODrawableImpl)drawable).setDoubleBufferMode(mode); + } */ + + @Override + public final FBObject getFBObject(int bufferName) { + return ((GLFBODrawableImpl)drawable).getFBObject(bufferName); + } + + public final FBObject.TextureAttachment getTextureBuffer(int bufferName) { + return ((GLFBODrawableImpl)drawable).getTextureBuffer(bufferName); + } + + @Override + public void resetSize(GL gl) throws GLException { + ((GLFBODrawableImpl)drawable).resetSize(gl); + } + } +} diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index 32f4cb696..b438131bc 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -40,9 +40,6 @@ package jogamp.opengl; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLPbuffer; @@ -50,36 +47,18 @@ import javax.media.opengl.GLPbuffer; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; -/** Platform-independent class exposing pbuffer functionality to - applications. This class is not exposed in the public API as it - would probably add no value; however it implements the GLDrawable - interface so can be interacted with via its display() method. */ - +@SuppressWarnings("deprecation") public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { private int floatMode; - public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContext sharedContext, boolean ownDevice) { - super(pbufferDrawable, null, ownDevice); // drawable := pbufferDrawable - - GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) - drawable.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities(); - if(caps.isOnscreen()) { - if(caps.isPBuffer()) { - throw new IllegalArgumentException("Error: Given drawable is Onscreen and Pbuffer: "+pbufferDrawable); - } - throw new IllegalArgumentException("Error: Given drawable is Onscreen: "+pbufferDrawable); - } else { - if(!caps.isPBuffer()) { - throw new IllegalArgumentException("Error: Given drawable is not Pbuffer: "+pbufferDrawable); - } - } - context = (GLContextImpl) drawable.createContext(sharedContext); + public GLPbufferImpl(GLDrawableImpl pbufferDrawable, GLContextImpl pbufferContext) { + super(pbufferDrawable, pbufferContext, true); // drawable := pbufferDrawable, context := pbufferContext } // // pbuffer specifics - // - + // + @Override public void bindTexture() { // Doesn't make much sense to try to do this on the event dispatch diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 03d0d650f..06953a8e1 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -282,12 +282,6 @@ public abstract class EGLContext extends GLContextImpl { return EGL.eglSwapInterval(drawable.getNativeSurface().getDisplayHandle(), interval); } - @Override - public abstract void bindPbufferToTexture(); - - @Override - public abstract void releasePbufferFromTexture(); - // // Accessible .. // diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index 0dba4bb09..167eebf3a 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -36,7 +36,8 @@ package jogamp.opengl.egl; -import javax.media.nativewindow.MutableSurface; +import java.nio.IntBuffer; + import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.ProxySurface; @@ -46,10 +47,10 @@ import javax.media.opengl.GLException; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; +import com.jogamp.common.nio.Buffers; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public abstract class EGLDrawable extends GLDrawableImpl { - private boolean ownEGLSurface = false; // for destruction protected EGLDrawable(EGLDrawableFactory factory, NativeSurface component) throws GLException { super(factory, component, false); @@ -58,21 +59,14 @@ public abstract class EGLDrawable extends GLDrawableImpl { @Override public abstract GLContext createContext(GLContext shareWith); - protected abstract long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle); + protected abstract long createSurface(EGLGraphicsConfiguration config, int width, int height, long nativeSurfaceHandle); - private final void recreateSurface() { - final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) surface.getGraphicsConfiguration(); - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglConfig.getScreen().getDevice(); - if(DEBUG) { - System.err.println(getThreadName() + ": createSurface using "+eglConfig); - } - if( EGL.EGL_NO_SURFACE != surface.getSurfaceHandle() ) { - EGL.eglDestroySurface(eglDevice.getHandle(), surface.getSurfaceHandle()); - } + private final long createEGLSurface() { + final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; + final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) eglws.getGraphicsConfiguration(); + final NativeSurface upstreamSurface = eglws.getUpstreamSurface(); - final EGLUpstreamSurfaceHook upstreamHook = (EGLUpstreamSurfaceHook) ((ProxySurface)surface).getUpstreamSurfaceHook(); - final NativeSurface upstreamSurface = upstreamHook.getUpstreamSurface(); - long eglSurface = createSurface(eglConfig, upstreamSurface.getSurfaceHandle()); + long eglSurface = createSurface(eglConfig, eglws.getWidth(), eglws.getHeight(), upstreamSurface.getSurfaceHandle()); int eglError0; if (EGL.EGL_NO_SURFACE == eglSurface) { @@ -86,7 +80,7 @@ public abstract class EGLDrawable extends GLDrawableImpl { if(DEBUG) { System.err.println(getThreadName() + ": Info: Creation of window surface w/ surface handle failed: "+eglConfig+", error "+toHexString(eglError0)+", retry w/ windowHandle"); } - eglSurface = createSurface(eglConfig, nw.getWindowHandle()); + eglSurface = createSurface(eglConfig, eglws.getWidth(), eglws.getHeight(), nw.getWindowHandle()); if (EGL.EGL_NO_SURFACE == eglSurface) { eglError0 = EGL.eglGetError(); } @@ -99,34 +93,53 @@ public abstract class EGLDrawable extends GLDrawableImpl { if (EGL.EGL_NO_SURFACE == eglSurface) { throw new GLException("Creation of window surface failed: "+eglConfig+", "+surface+", error "+toHexString(eglError0)); } - if(DEBUG) { - System.err.println(getThreadName() + ": setSurface using component: handle "+toHexString(surface.getSurfaceHandle())+" -> "+toHexString(eglSurface)); + System.err.println(getThreadName() + ": createEGLSurface handle "+toHexString(eglSurface)); } - - ((MutableSurface)surface).setSurfaceHandle(eglSurface); + return eglSurface; } @Override protected final void updateHandle() { - if(ownEGLSurface) { - recreateSurface(); + final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; + if(DEBUG) { + System.err.println(getThreadName() + ": updateHandle of "+eglws); + } + if( eglws.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + if( EGL.EGL_NO_SURFACE != eglws.getSurfaceHandle() ) { + throw new InternalError("Set surface but claimed to be invalid: "+eglws); + } + eglws.setSurfaceHandle( createEGLSurface() ); + } else if( EGL.EGL_NO_SURFACE == eglws.getSurfaceHandle() ) { + throw new InternalError("Nil surface but claimed to be valid: "+eglws); + } + } + + protected void destroyHandle() { + final EGLWrappedSurface eglws = (EGLWrappedSurface) surface; + if(DEBUG) { + System.err.println(getThreadName() + ": destroyHandle of "+eglws); + } + if( EGL.EGL_NO_SURFACE == eglws.getSurfaceHandle() ) { + throw new InternalError("Nil surface but claimed to be valid: "+eglws); + } + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglws.getGraphicsConfiguration().getScreen().getDevice(); + if( eglws.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + EGL.eglDestroySurface(eglDevice.getHandle(), eglws.getSurfaceHandle()); + eglws.setSurfaceHandle(EGL.EGL_NO_SURFACE); } } - protected static boolean isValidEGLSurface(EGLGraphicsDevice eglDevice, NativeSurface surface) { - final long eglDisplayHandle = eglDevice.getHandle(); - if (EGL.EGL_NO_DISPLAY == eglDisplayHandle) { - throw new GLException("Invalid EGL display in EGLGraphicsDevice "+eglDevice); + protected static boolean isValidEGLSurface(long eglDisplayHandle, long surfaceHandle) { + if( 0 == surfaceHandle ) { + return false; } - boolean eglSurfaceValid = 0 != surface.getSurfaceHandle(); - if(eglSurfaceValid) { - int[] tmp = new int[1]; - eglSurfaceValid = EGL.eglQuerySurface(eglDisplayHandle, surface.getSurfaceHandle(), EGL.EGL_CONFIG_ID, tmp, 0); - if(!eglSurfaceValid) { - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.isValidEGLSurface eglQuerySuface failed: "+toHexString(EGL.eglGetError())+", "+surface); - } + final IntBuffer val = Buffers.newDirectIntBuffer(1); + final boolean eglSurfaceValid = EGL.eglQuerySurface(eglDisplayHandle, surfaceHandle, EGL.EGL_CONFIG_ID, val); + if( !eglSurfaceValid ) { + final int eglErr = EGL.eglGetError(); + if(DEBUG) { + System.err.println(getThreadName() + ": EGLDrawable.isValidEGLSurface eglQuerySuface failed: error "+toHexString(eglErr)+", "+toHexString(surfaceHandle)); } } return eglSurfaceValid; @@ -134,55 +147,19 @@ public abstract class EGLDrawable extends GLDrawableImpl { @Override protected final void setRealizedImpl() { - final EGLGraphicsConfiguration eglConfig = (EGLGraphicsConfiguration) surface.getGraphicsConfiguration(); - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) eglConfig.getScreen().getDevice(); - if (realized) { - final boolean eglSurfaceValid = isValidEGLSurface(eglDevice, surface); - if(eglSurfaceValid) { - // surface holds valid EGLSurface - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl re-using component's EGLSurface: handle "+toHexString(surface.getSurfaceHandle())); - } - ownEGLSurface=false; - } else { - // EGLSurface is ours - subsequent updateHandle() will issue recreateSurface(); - // However .. let's validate the surface object first - if( ! (surface instanceof ProxySurface) ) { - throw new InternalError("surface not ProxySurface: "+surface.getClass().getName()+", "+surface); - } - final ProxySurface.UpstreamSurfaceHook upstreamHook = ((ProxySurface)surface).getUpstreamSurfaceHook(); - if( null == upstreamHook ) { - throw new InternalError("null upstreamHook of: "+surface); - } - if( ! (upstreamHook instanceof EGLUpstreamSurfaceHook) ) { - throw new InternalError("upstreamHook not EGLUpstreamSurfaceHook: Surface: "+surface.getClass().getName()+", "+surface+"; UpstreamHook: "+upstreamHook.getClass().getName()+", "+upstreamHook); - } - if( null == ((EGLUpstreamSurfaceHook)upstreamHook).getUpstreamSurface() ) { - throw new InternalError("null upstream surface"); - } - ownEGLSurface=true; - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealizedImpl owning EGLSurface"); - } - } - } else if (ownEGLSurface && surface.getSurfaceHandle() != EGL.EGL_NO_SURFACE) { - if(DEBUG) { - System.err.println(getThreadName() + ": EGLDrawable.setRealized(false): ownSurface "+ownEGLSurface+", "+eglDevice+", eglSurface: "+toHexString(surface.getSurfaceHandle())); - } - // Destroy the window surface - if (!EGL.eglDestroySurface(eglDevice.getHandle(), surface.getSurfaceHandle())) { - throw new GLException("Error destroying window surface (eglDestroySurface)"); - } - ((MutableSurface)surface).setSurfaceHandle(EGL.EGL_NO_SURFACE); + if(DEBUG) { + System.err.println(getThreadName() + ": EGLDrawable.setRealized("+realized+"): NOP - "+surface); } } @Override - protected final void swapBuffersImpl() { - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); - // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - if(!EGL.eglSwapBuffers(eglDevice.getHandle(), surface.getSurfaceHandle())) { - throw new GLException("Error swapping buffers, eglError "+toHexString(EGL.eglGetError())+", "+this); + protected final void swapBuffersImpl(boolean doubleBuffered) { + if(doubleBuffered) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); + // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() + if(!EGL.eglSwapBuffers(eglDevice.getHandle(), surface.getSurfaceHandle())) { + throw new GLException("Error swapping buffers, eglError "+toHexString(EGL.eglGetError())+", "+this); + } } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 292eb17c8..e98d69140 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -52,8 +52,7 @@ import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; -import javax.media.nativewindow.VisualIDHolder.VIDType; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; @@ -65,6 +64,7 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; import jogamp.opengl.Debug; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; @@ -76,10 +76,11 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; -import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; public class EGLDrawableFactory extends GLDrawableFactoryImpl { + protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; + /* package */ static final boolean QUERY_EGL_ES = !Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.DontQuery", true); /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); @@ -112,7 +113,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } catch (JogampRuntimeException jre) { /* n/a .. */ } } - defaultDevice = new EGLGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + defaultDevice = new EGLGraphicsDevice(); // FIXME: Probably need to move EGL from a static model // to a dynamic one, where there can be 2 instances @@ -310,6 +311,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { try { final GLCapabilities reqCapsAny = new GLCapabilities(glp); reqCapsAny.setRedBits(5); reqCapsAny.setGreenBits(5); reqCapsAny.setBlueBits(5); reqCapsAny.setAlphaBits(0); + reqCapsAny.setDoubleBuffered(false); final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny); final List availablePBufferCapsL = getAvailableEGLConfigs(sharedEGLDevice, reqCapsPBuffer); hasPBuffer[0] = availablePBufferCapsL.size() > 0; @@ -324,18 +326,20 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } else { final List capsAnyL = getAvailableEGLConfigs(eglDevice, reqCapsAny); if(capsAnyL.size() > 0) { - final GLCapabilitiesImmutable caps = capsAnyL.get(0); - EGLContext.mapStaticGLESVersion(eglDevice, caps); + final GLCapabilitiesImmutable chosenCaps = capsAnyL.get(0); + EGLContext.mapStaticGLESVersion(eglDevice, chosenCaps); if(eglDevice != adevice) { - EGLContext.mapStaticGLESVersion(adevice, caps); + EGLContext.mapStaticGLESVersion(adevice, chosenCaps); } + final EGLGraphicsDevice adeviceEGLDevice = new EGLGraphicsDevice(adevice.getHandle(), EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), null); + EGLContext.mapStaticGLESVersion(adeviceEGLDevice, chosenCaps); success = true; } if(DEBUG) { System.err.println("EGLDrawableFactory.isEGLContextAvailable() no pbuffer config available, detected !pbuffer config: "+success); EGLGraphicsConfigurationFactory.printCaps("!PBufferCaps", capsAnyL, System.err); } - } + } } else { surface = desktopFactory.createDummySurface(adevice, reqCapsAny, null, 64, 64); // X11, WGL, .. dummy window upstreamSurface = ( surface instanceof ProxySurface ) ? (ProxySurface)surface : null ; @@ -361,6 +365,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(eglDevice != adevice) { context.mapCurrentAvailableGLVersion(adevice); } + final EGLGraphicsDevice adeviceEGLDevice = new EGLGraphicsDevice(adevice.getHandle(), EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), null); + context.mapCurrentAvailableGLVersion(adeviceEGLDevice); success = true; } else { // Oops .. something is wrong @@ -538,70 +544,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if (target == null) { throw new IllegalArgumentException("Null target"); } - return new EGLOnscreenDrawable(this, getEGLSurface(target)); + return new EGLOnscreenDrawable(this, EGLWrappedSurface.get(target)); } - protected static NativeSurface getEGLSurface(NativeSurface surface) { - AbstractGraphicsConfiguration aConfig = surface.getGraphicsConfiguration(); - AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); - if( aDevice instanceof EGLGraphicsDevice && aConfig instanceof EGLGraphicsConfiguration ) { - if(surface instanceof WrappedSurface) { - // already wrapped surface - no wrapped recursion - if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - already wrapped surface - use as-is: "+surface); - } - return surface; - } - if(EGLDrawable.isValidEGLSurface((EGLGraphicsDevice)aDevice, surface)) { - // already in native EGL format - if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - already valid EGL surface - use as-is: "+surface); - } - return surface; - } - } - // create EGL instance out of platform native types - final EGLGraphicsDevice eglDevice; - if( aDevice instanceof EGLGraphicsDevice ) { - eglDevice = (EGLGraphicsDevice) aDevice; - if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - Reusing eglDevice: "+eglDevice); - } - if(0 == eglDevice.getHandle()) { - eglDevice.open(); - } - } else { - eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface); - } - final AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); - final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); - final EGLGraphicsConfiguration eglConfig; - if( aConfig instanceof EGLGraphicsConfiguration ) { - // Config is already in EGL type - reuse .. - final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities(); - if( 0 == capsChosen.getEGLConfig() ) { - // 'refresh' the native EGLConfig handle - capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDevice.getHandle(), capsChosen.getEGLConfigID())); - if( 0 == capsChosen.getEGLConfig() ) { - throw new GLException("Refreshing native EGLConfig handle failed with error "+EGLContext.toHexString(EGL.eglGetError())+": "+eglDevice+", "+capsChosen+" of "+aConfig); - } - } - eglConfig = new EGLGraphicsConfiguration(eglScreen, capsChosen, capsRequested, null); - if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - Reusing chosenCaps: "+eglConfig); - } - } else { - eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( - capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false); - - if (null == eglConfig) { - throw new GLException("Couldn't create EGLGraphicsConfiguration from "+eglScreen); - } else if(DEBUG) { - System.err.println(getThreadName() + ": getEGLSurface - Chosen eglConfig: "+eglConfig); - } - } - return new WrappedSurface(eglConfig, EGL.EGL_NO_SURFACE, surface.getWidth(), surface.getHeight(), new EGLUpstreamSurfaceHook(surface)); - } static String getThreadName() { return Thread.currentThread().getName(); } @Override @@ -615,7 +560,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { throw new GLException("Non pbuffer not yet implemented"); } // PBuffer GLDrawable Creation - return new EGLPbufferDrawable(this, getEGLSurface(target)); + return new EGLPbufferDrawable(this, EGLWrappedSurface.get(target)); } @Override @@ -628,20 +573,24 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { + final boolean ownDevice; final EGLGraphicsDevice device; - if(createNewDevice) { - final EGLGraphicsDevice eglDeviceReq = (EGLGraphicsDevice) deviceReq; - device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); + if(createNewDevice || ! ( deviceReq instanceof EGLGraphicsDevice ) ) { + final long nativeDisplayID = ( deviceReq instanceof EGLGraphicsDevice) ? + ( (EGLGraphicsDevice) deviceReq ).getNativeDisplayID() : deviceReq.getHandle() ; + device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(nativeDisplayID, deviceReq.getConnection(), deviceReq.getUnitID()); + ownDevice = true; } else { device = (EGLGraphicsDevice) deviceReq; + ownDevice = false; } final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, 0); final EGLGraphicsConfiguration config = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, width, height, lifecycleHook); + return new WrappedSurface(config, 0, upstreamHook, ownDevice); } @Override @@ -649,54 +598,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixDoubleBufferedGLCapabilities( - GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)), - false); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)), false); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new EGLDummyUpstreamSurfaceHook(width, height)); } - private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { - @Override - public final void create(ProxySurface s) { - if( EGL.EGL_NO_SURFACE == s.getSurfaceHandle() ) { - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); - if(0 == eglDevice.getHandle()) { - eglDevice.open(); - s.setImplBitfield(ProxySurface.OWN_DEVICE); - } - createPBufferSurfaceImpl(s, false); - if(DEBUG) { - System.err.println("EGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); - } - } - } - @Override - public final void destroy(ProxySurface s) { - if( EGL.EGL_NO_SURFACE != s.getSurfaceHandle() ) { - final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) s.getGraphicsConfiguration(); - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) config.getScreen().getDevice(); - EGL.eglDestroySurface(eglDevice.getHandle(), s.getSurfaceHandle()); - s.setSurfaceHandle(EGL.EGL_NO_SURFACE); - if( 0 != ( ProxySurface.OWN_DEVICE & s.getImplBitfield() ) ) { - eglDevice.close(); - } - if(DEBUG) { - System.err.println("EGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); - } - } - } - @Override - public final int getWidth(ProxySurface s) { - return s.initialWidth; - } - @Override - public final int getHeight(ProxySurface s) { - return s.initialHeight; - } - @Override - public String toString() { - return "EGLSurfaceLifecycleHook[]"; - } - - }; /** * @param ms {@link MutableSurface} which dimensions and config are being used to create the pbuffer surface. @@ -705,7 +609,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { * @return the passed {@link MutableSurface} which now has the EGL pbuffer surface set as it's handle */ protected static MutableSurface createPBufferSurfaceImpl(MutableSurface ms, boolean useTexture) { - final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) ms.getGraphicsConfiguration(); + return null; + } + protected static long createPBufferSurfaceImpl(EGLGraphicsConfiguration config, int width, int height, boolean useTexture) { final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) config.getScreen().getDevice(); final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); final int texFormat; @@ -720,15 +626,14 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { System.out.println("Pbuffer config: " + config); } - final int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(ms.getWidth(), ms.getHeight(), texFormat); + final int[] attrs = EGLGraphicsConfiguration.CreatePBufferSurfaceAttribList(width, height, texFormat); final long surf = EGL.eglCreatePbufferSurface(eglDevice.getHandle(), config.getNativeConfig(), attrs, 0); if (EGL.EGL_NO_SURFACE==surf) { - throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+ms.getWidth()+"x"+ms.getHeight()+", error 0x"+Integer.toHexString(EGL.eglGetError())); + throw new GLException("Creation of window surface (eglCreatePbufferSurface) failed, dim "+width+"x"+height+", "+eglDevice+", "+config+", error 0x"+Integer.toHexString(EGL.eglGetError())); } else if(DEBUG) { System.err.println("PBuffer setSurface result: eglSurface 0x"+Long.toHexString(surf)); } - ms.setSurfaceHandle(surf); - return ms; + return surf; } @Override @@ -737,7 +642,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final EGLGraphicsDevice device = EGLDisplayUtil.eglCreateEGLGraphicsDevice(eglDeviceReq.getNativeDisplayID(), deviceReq.getConnection(), deviceReq.getUnitID()); final DefaultGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); final EGLGraphicsConfiguration cfg = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED, false); - return new WrappedSurface(cfg, windowHandle, 0, 0, upstream); + return new WrappedSurface(cfg, windowHandle, upstream, true); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java new file mode 100644 index 000000000..b172d4f35 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDummyUpstreamSurfaceHook.java @@ -0,0 +1,49 @@ +package jogamp.opengl.egl; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; + +public class EGLDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { + /** + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * not the actual dummy surface height, + * The latter is platform specific and small + */ + public EGLDummyUpstreamSurfaceHook(int width, int height) { + super(width, height); + } + + @Override + public final void create(ProxySurface s) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); + if(0 == eglDevice.getHandle()) { + eglDevice.open(); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + if( EGL.EGL_NO_SURFACE == s.getSurfaceHandle() ) { + s.setSurfaceHandle( EGLDrawableFactory.createPBufferSurfaceImpl((EGLGraphicsConfiguration)s.getGraphicsConfiguration(), 64, 64, false) ); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); + } + + @Override + public final void destroy(ProxySurface s) { + if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); + if( EGL.EGL_NO_SURFACE == s.getSurfaceHandle() ) { + throw new InternalError("Owns upstream surface, but no EGL surface: "+s); + } + EGL.eglDestroySurface(eglDevice.getHandle(), s.getSurfaceHandle()); + s.setSurfaceHandle(EGL.EGL_NO_SURFACE); + s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + } +} diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java index 585638d21..84bd705db 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java @@ -79,15 +79,4 @@ public class EGLExternalContext extends EGLContext { @Override protected void destroyImpl() throws GLException { } - - @Override - public void bindPbufferToTexture() { - throw new GLException("Should not call this"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Should not call this"); - } - } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java index e513a86cf..f857c6b5c 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java @@ -57,8 +57,8 @@ public class EGLGLCapabilities extends GLCapabilities { this.eglcfg = eglcfg; this.eglcfgid = eglcfgid; if(!isCompatible(glp, renderableType)) { - throw new GLException("Incompatible "+glp+ - " with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]"); + throw new GLException("Requested GLProfile "+glp+ + " not compatible with EGL-RenderableType["+renderableTypeToString(null, renderableType)+"]"); } this.renderableType = renderableType; this.nativeVisualID = visualID; @@ -131,6 +131,7 @@ public class EGLGLCapabilities extends GLCapabilities { sink = new StringBuilder(); } boolean first=true; + sink.append("0x").append(Integer.toHexString(renderableType)).append(": "); if(0 != (renderableType & EGL.EGL_OPENGL_BIT)) { sink.append("GL"); first=false; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 8ee98072f..7bf201238 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -211,6 +211,13 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple if(null == glp) { glp = EGLGLCapabilities.getCompatible(device, rType); } + if(!EGLGLCapabilities.isCompatible(glp, rType)) { + if(DEBUG) { + System.err.println("config "+toHexString(config)+": Requested GLProfile "+glp+ + " not compatible with EGL-RenderableType["+EGLGLCapabilities.renderableTypeToString(null, rType)+"]"); + } + return null; + } caps = new EGLGLCapabilities(config, cfgID, visualID, glp, rType); } catch (GLException gle) { if(DEBUG) { @@ -288,7 +295,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple return null; } - return (EGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(caps, drawableTypeBits); + return (EGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, caps); } public static int[] GLCapabilities2AttribList(GLCapabilitiesImmutable caps) { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java index eae47fa92..325ad6142 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenContext.java @@ -41,16 +41,5 @@ public class EGLOnscreenContext extends EGLContext { public EGLOnscreenContext(EGLOnscreenDrawable drawable, GLContext shareWith) { super(drawable, shareWith); } - - @Override - public void bindPbufferToTexture() { - throw new GLException("Should not call this"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Should not call this"); - } - } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java index d54057775..6440cf1e5 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLOnscreenDrawable.java @@ -54,8 +54,8 @@ public class EGLOnscreenDrawable extends EGLDrawable { } @Override - protected long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle) { + protected long createSurface(EGLGraphicsConfiguration config, int width, int height, long nativeSurfaceHandle) { return EGL.eglCreateWindowSurface(config.getScreen().getDevice().getHandle(), config.getNativeConfig(), nativeSurfaceHandle, null); - } + } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java index 7175d516f..bb9eeb892 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferContext.java @@ -46,15 +46,5 @@ public class EGLPbufferContext extends EGLContext { public int getFloatingPointMode() { return 0; // FIXME ?? } - - @Override - public void bindPbufferToTexture() { - throw new GLException("Not yet implemented"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Not yet implemented"); - } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java index 4a36625bd..eb7e320c8 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLPbufferDrawable.java @@ -52,12 +52,8 @@ public class EGLPbufferDrawable extends EGLDrawable { } @Override - protected long createSurface(EGLGraphicsConfiguration config, long nativeSurfaceHandle) { - final MutableSurface ms = (MutableSurface)getNativeSurface(); - if(config != ms.getGraphicsConfiguration()) { - throw new InternalError("Not same: "+config.hashCode()+", "+ms.getGraphicsConfiguration()+": "+config+", "+ms.getGraphicsConfiguration()); - } - return EGLDrawableFactory.createPBufferSurfaceImpl(ms, useTexture).getSurfaceHandle(); + protected long createSurface(EGLGraphicsConfiguration config, int width, int height, long nativeSurfaceHandle) { + return EGLDrawableFactory.createPBufferSurfaceImpl(config, width, height, false); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java index 42c6e100e..342c4c417 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java @@ -1,38 +1,163 @@ package jogamp.opengl.egl; +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; +import javax.media.nativewindow.VisualIDHolder.VIDType; +import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLException; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; -public class EGLUpstreamSurfaceHook implements ProxySurface.UpstreamSurfaceHook { +public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { + protected static final boolean DEBUG = EGLDrawableFactory.DEBUG; private final NativeSurface upstreamSurface; + private final UpstreamSurfaceHook.MutableSize upstreamSurfaceHookMutableSize; public EGLUpstreamSurfaceHook(NativeSurface upstream) { upstreamSurface = upstream; + if(upstreamSurface instanceof ProxySurface) { + final UpstreamSurfaceHook ush = ((ProxySurface)upstreamSurface).getUpstreamSurfaceHook(); + if(ush instanceof UpstreamSurfaceHook.MutableSize) { + // offscreen NativeSurface w/ MutableSize (default) + upstreamSurfaceHookMutableSize = (UpstreamSurfaceHook.MutableSize) ush; + } else { + upstreamSurfaceHookMutableSize = null; + } + } else { + upstreamSurfaceHookMutableSize = null; + } } public final NativeSurface getUpstreamSurface() { return upstreamSurface; } + static String getThreadName() { return Thread.currentThread().getName(); } + + public final void setSize(int width, int height) { + if(null != upstreamSurfaceHookMutableSize) { + upstreamSurfaceHookMutableSize.setSize(width, height); + } + } + @Override public final void create(ProxySurface surface) { + final String dbgPrefix; + if(DEBUG) { + dbgPrefix = getThreadName() + ": EGLUpstreamSurfaceHook.create("+surface.getClass().getSimpleName()+"): "; + System.err.println(dbgPrefix+this); + } else { + dbgPrefix = null; + } + if(upstreamSurface instanceof ProxySurface) { + // propagate createNotify(..) so upstreamSurface will be created ((ProxySurface)upstreamSurface).createNotify(); - if(NativeSurface.LOCK_SURFACE_NOT_READY >= upstreamSurface.lockSurface()) { - throw new GLException("Could not lock: "+upstreamSurface); + } + + // lock upstreamSurface, so it can be used in case EGLDisplay is derived from it! + if(NativeSurface.LOCK_SURFACE_NOT_READY >= upstreamSurface.lockSurface()) { + throw new GLException("Could not lock: "+upstreamSurface); + } + try { + evalUpstreamSurface(dbgPrefix, surface); + } finally { + upstreamSurface.unlockSurface(); + } + } + + private final void evalUpstreamSurface(String dbgPrefix, ProxySurface surface) { + // + // evaluate nature of upstreamSurface, may create EGL instances if required + // + + boolean isEGLSurfaceValid = true; // assume yes + + final AbstractGraphicsConfiguration aConfig = upstreamSurface.getGraphicsConfiguration(); + final AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); + + final EGLGraphicsDevice eglDevice; + if( aDevice instanceof EGLGraphicsDevice ) { + eglDevice = (EGLGraphicsDevice) aDevice; + if(DEBUG) { + System.err.println(dbgPrefix+"Reusing eglDevice: "+eglDevice); + } + if(EGL.EGL_NO_DISPLAY == eglDevice.getHandle()) { + eglDevice.open(); + isEGLSurfaceValid = false; + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + } else { + eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(upstreamSurface); + isEGLSurfaceValid = false; + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + + final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); + final EGLGraphicsConfiguration eglConfig; + if( aConfig instanceof EGLGraphicsConfiguration ) { + // Config is already in EGL type - reuse .. + final EGLGLCapabilities capsChosen = (EGLGLCapabilities) aConfig.getChosenCapabilities(); + if( !isEGLSurfaceValid || !EGLGraphicsConfiguration.isEGLConfigValid(eglDevice.getHandle(), capsChosen.getEGLConfig()) ) { + // 'refresh' the native EGLConfig handle + capsChosen.setEGLConfig(EGLGraphicsConfiguration.EGLConfigId2EGLConfig(eglDevice.getHandle(), capsChosen.getEGLConfigID())); + if( 0 == capsChosen.getEGLConfig() ) { + throw new GLException("Refreshing native EGLConfig handle failed with error "+EGLContext.toHexString(EGL.eglGetError())+": "+eglDevice+", "+capsChosen+" of "+aConfig); + } + final AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); + eglConfig = new EGLGraphicsConfiguration(eglScreen, capsChosen, capsRequested, null); + if(DEBUG) { + System.err.println(dbgPrefix+"Refreshing eglConfig: "+eglConfig); + } + isEGLSurfaceValid = false; + } else { + eglConfig = (EGLGraphicsConfiguration) aConfig; + if(DEBUG) { + System.err.println(dbgPrefix+"Reusing eglConfig: "+eglConfig); + } + } + } else { + final AbstractGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aConfig.getScreen().getIndex()); + eglConfig = EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( + capsRequested, capsRequested, null, eglScreen, aConfig.getVisualID(VIDType.NATIVE), false); + + if (null == eglConfig) { + throw new GLException("Couldn't create EGLGraphicsConfiguration from "+eglScreen); + } else if(DEBUG) { + System.err.println(dbgPrefix+"Chosen eglConfig: "+eglConfig); } + isEGLSurfaceValid = false; } - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); - eglDevice.open(); + surface.setGraphicsConfiguration(eglConfig); + + if(isEGLSurfaceValid) { + isEGLSurfaceValid = EGLDrawable.isValidEGLSurface(eglDevice.getHandle(), upstreamSurface.getSurfaceHandle()); + } + if(isEGLSurfaceValid) { + surface.setSurfaceHandle(upstreamSurface.getSurfaceHandle()); + surface.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + if(DEBUG) { + System.err.println(dbgPrefix+"Fin: Already valid EGL surface - use as-is: "+upstreamSurface); + } + } else { + surface.setSurfaceHandle(EGL.EGL_NO_SURFACE); + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); // create/destroy in EGLDrawable + if(DEBUG) { + System.err.println(dbgPrefix+"Fin: EGL surface n/a - TBD: "+upstreamSurface); + } + } } @Override public final void destroy(ProxySurface surface) { - final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) surface.getGraphicsConfiguration().getScreen().getDevice(); - eglDevice.close(); + if(EGLDrawableFactory.DEBUG) { + System.err.println("EGLUpstreamSurfaceHook.destroy("+surface.getClass().getSimpleName()+"): "+this); + } + surface.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); if(upstreamSurface instanceof ProxySurface) { - upstreamSurface.unlockSurface(); ((ProxySurface)upstreamSurface).destroyNotify(); } } @@ -49,8 +174,8 @@ public class EGLUpstreamSurfaceHook implements ProxySurface.UpstreamSurfaceHook @Override public String toString() { - final String us_s = null != upstreamSurface ? ( upstreamSurface.getClass().getName() + ": " + upstreamSurface ) : "nil"; - return "EGLUpstreamSurfaceHook[upstream: "+us_s+"]"; + final String us_s = null != upstreamSurface ? ( upstreamSurface.getClass().getName() + ": 0x" + Long.toHexString(upstreamSurface.getSurfaceHandle()) ) : "nil"; + return "EGLUpstreamSurfaceHook[ "+ upstreamSurface.getWidth() + "x" + upstreamSurface.getHeight() + ", " + us_s+ "]"; } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java b/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java new file mode 100644 index 000000000..b36303392 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/egl/EGLWrappedSurface.java @@ -0,0 +1,26 @@ +package jogamp.opengl.egl; + +import javax.media.nativewindow.NativeSurface; + +import jogamp.nativewindow.WrappedSurface; + +public class EGLWrappedSurface extends WrappedSurface { + + public static EGLWrappedSurface get(NativeSurface surface) { + if(surface instanceof EGLWrappedSurface) { + return (EGLWrappedSurface)surface; + } + return new EGLWrappedSurface(surface); + } + + public EGLWrappedSurface(NativeSurface surface) { + super(surface.getGraphicsConfiguration(), EGL.EGL_NO_SURFACE, new EGLUpstreamSurfaceHook(surface), false /* tbd in UpstreamSurfaceHook */); + if(EGLDrawableFactory.DEBUG) { + System.err.println("EGLWrappedSurface.ctor(): "+this); + } + } + + public final NativeSurface getUpstreamSurface() { + return ((EGLUpstreamSurfaceHook)super.getUpstreamSurfaceHook()).getUpstreamSurface(); + } +} diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 55aea3a98..ec29558d1 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -49,6 +49,7 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; +import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -58,6 +59,7 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.macosx.OSXUtil; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; +import jogamp.opengl.GLFBODrawableImpl; import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType; @@ -76,9 +78,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl boolean isNSContext(); long create(long share, int ctp, int major, int minor); boolean destroy(long ctx); + boolean contextRealized(boolean realized); boolean copyImpl(long src, int mask); boolean makeCurrent(long ctx); boolean release(long ctx); + boolean detachPBuffer(); boolean setSwapInterval(int interval); boolean swapBuffers(); } @@ -279,7 +283,24 @@ public abstract class MacOSXCGLContext extends GLContextImpl throw new GLException("Error destroying OpenGL Context: "+this); } } + + @Override + protected void contextRealized(boolean realized) { + // context stuff depends on drawable stuff + if(realized) { + super.contextRealized(true); // 1) init drawable stuff + impl.contextRealized(true); // 2) init context stuff + } else { + impl.contextRealized(false); // 1) free context stuff + super.contextRealized(false); // 2) free drawable stuff + } + } + + /* pp */ void detachPBuffer() { + impl.detachPBuffer(); + } + @Override protected void copyImpl(GLContext source, int mask) throws GLException { if( isNSContext() != ((MacOSXCGLContext)source).isNSContext() ) { @@ -365,16 +386,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl throw new GLException("Should not call this"); } - @Override - public void bindPbufferToTexture() { - throw new GLException("Should not call this"); - } - - @Override - public void releasePbufferFromTexture() { - throw new GLException("Should not call this"); - } - // Support for "mode switching" as described in MacOSXCGLDrawable public void setOpenGLMode(GLBackendType mode) { if (mode == openGLMode) { @@ -421,323 +432,486 @@ public abstract class MacOSXCGLContext extends GLContextImpl // NSOpenGLContext-based implementation class NSOpenGLImpl implements GLBackendImpl { - long nsOpenGLLayer = 0; - long nsOpenGLLayerPFmt = 0; - float screenVSyncTimeout; // microSec - int vsyncTimeout; // microSec - for nsOpenGLLayer mode - - @Override - public boolean isNSContext() { return true; } - - @Override - public long create(long share, int ctp, int major, int minor) { - long ctx = 0; - final long nsViewHandle; - if(drawable instanceof MacOSXCGLDrawable) { - // we allow null here! (special pbuffer case) - nsViewHandle = ((MacOSXCGLDrawable)MacOSXCGLContext.this.drawable).getNSViewHandle(); - } else { - // we only allow a valid NSView here - final long aHandle = drawable.getHandle(); - if( OSXUtil.isNSView(aHandle) ) { - nsViewHandle = aHandle; - } else { - throw new RuntimeException("Anonymous drawable instance's handle not of type NSView: "+drawable.getClass().getName()+", "+drawable); - } - } - final NativeSurface surface = drawable.getNativeSurface(); - final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); - final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); - - boolean allowIncompleteView = null != backingLayerHost; - if( !allowIncompleteView && surface instanceof ProxySurface ) { - allowIncompleteView = 0 != ( ProxySurface.INVISIBLE_WINDOW & ((ProxySurface)surface).getImplBitfield() ) ; - } - final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor); - if (pixelFormat == 0) { - if(DEBUG) { - System.err.println("Unable to allocate pixel format with requested GLCapabilities: "+chosenCaps); - } - return 0; - } - config.setChosenPixelFormat(pixelFormat); - int sRefreshRate = CGL.getScreenRefreshRate(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getIndex()); - screenVSyncTimeout = 1000000f / sRefreshRate; - if(DEBUG) { - System.err.println("NS create OSX>=lion "+isLionOrLater); - System.err.println("NS create allowIncompleteView: "+allowIncompleteView); - System.err.println("NS create backingLayerHost: "+backingLayerHost); - System.err.println("NS create share: "+share); - System.err.println("NS create chosenCaps: "+chosenCaps); - System.err.println("NS create pixelFormat: "+toHexString(pixelFormat)); - System.err.println("NS create drawable native-handle: "+toHexString(drawable.getHandle())); - System.err.println("NS create drawable NSView-handle: "+toHexString(nsViewHandle)); - System.err.println("NS create screen refresh-rate: "+sRefreshRate+" hz, "+screenVSyncTimeout+" micros"); - // Thread.dumpStack(); - } - try { - int[] viewNotReady = new int[1]; - // Try to allocate a context with this - ctx = CGL.createContext(share, - nsViewHandle, allowIncompleteView, - pixelFormat, - chosenCaps.isBackgroundOpaque(), - viewNotReady, 0); - if (0 == ctx) { - if(DEBUG) { - System.err.println("NS create failed: viewNotReady: "+ (1 == viewNotReady[0])); - } - return 0; - } + private OffscreenLayerSurface backingLayerHost = null; + private long nsOpenGLLayer = 0; + private long nsOpenGLLayerPFmt = 0; + private float screenVSyncTimeout; // microSec + private int vsyncTimeout; // microSec - for nsOpenGLLayer mode + private int lastWidth=0, lastHeight=0; // allowing to detect size change + private long lastPBufferHandle = 0; // allowing to detect pbuffer recreation + + @Override + public boolean isNSContext() { return true; } + + @Override + public long create(long share, int ctp, int major, int minor) { + long ctx = 0; + final NativeSurface surface = drawable.getNativeSurface(); + final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); + final GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final long nsViewHandle; + final boolean isPBuffer; + final boolean isFBO; + if(drawable instanceof GLFBODrawableImpl) { + nsViewHandle = 0; + isPBuffer = false; + isFBO = true; + if(DEBUG) { + System.err.println("NS create GLFBODrawableImpl drawable: isFBO "+isFBO+", isPBuffer "+isPBuffer+", "+drawable.getClass().getName()+",\n\t"+drawable); + } + } else if(drawable instanceof MacOSXCGLDrawable) { + // we allow null here! (special pbuffer case) + nsViewHandle = ((MacOSXCGLDrawable)MacOSXCGLContext.this.drawable).getNSViewHandle(); + isPBuffer = CGL.isNSOpenGLPixelBuffer(drawable.getHandle()); + isFBO = false; + if(DEBUG) { + System.err.println("NS create MacOSXCGLDrawable drawable handle isFBO "+isFBO+", isPBuffer "+isPBuffer+", "+drawable.getClass().getName()+",\n\t"+drawable); + } + } else { + // we only allow a valid NSView here + final long drawableHandle = drawable.getHandle(); + final boolean isNSView = OSXUtil.isNSView(drawableHandle); + final boolean isNSWindow = OSXUtil.isNSWindow(drawableHandle); + isPBuffer = CGL.isNSOpenGLPixelBuffer(drawableHandle); + isFBO = false; - if (!chosenCaps.isPBuffer() && !chosenCaps.isBackgroundOpaque()) { - // Set the context opacity - CGL.setContextOpacity(ctx, 0); + if(DEBUG) { + System.err.println("NS create Anonymous drawable handle "+toHexString(drawableHandle)+": isNSView "+isNSView+", isNSWindow "+isNSWindow+", isFBO "+isFBO+", isPBuffer "+isPBuffer+", "+drawable.getClass().getName()+",\n\t"+drawable); + } + if( isNSView ) { + nsViewHandle = drawableHandle; + } else if( isNSWindow ) { + nsViewHandle = OSXUtil.GetNSView(drawableHandle); + } else if( isPBuffer ) { + nsViewHandle = 0; + } else { + throw new RuntimeException("Anonymous drawable instance's handle neither NSView, NSWindow nor PBuffer: "+toHexString(drawableHandle)+", "+drawable.getClass().getName()+",\n\t"+drawable); + } } + backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); + boolean allowIncompleteView = null != backingLayerHost; + if( !allowIncompleteView && surface instanceof ProxySurface ) { + allowIncompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); + } + long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor); + if (pixelFormat == 0) { + if(DEBUG) { + System.err.println("Unable to allocate pixel format with requested GLCapabilities: "+chosenCaps); + } + return 0; + } GLCapabilities fixedCaps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(chosenCaps.getGLProfile(), pixelFormat); - fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); - if(!fixedCaps.isPBuffer()) { + if(chosenCaps.isOnscreen() || !fixedCaps.isPBuffer()) { // not handled, so copy them fixedCaps.setFBO(chosenCaps.isFBO()); + fixedCaps.setPBuffer(chosenCaps.isPBuffer()); fixedCaps.setBitmap(chosenCaps.isBitmap()); fixedCaps.setOnscreen(chosenCaps.isOnscreen()); } - config.setChosenCapabilities(fixedCaps); + fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); + int sRefreshRate = OSXUtil.GetScreenRefreshRate(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getIndex()); + screenVSyncTimeout = 1000000f / sRefreshRate; if(DEBUG) { + System.err.println("NS create OSX>=lion "+isLionOrLater); + System.err.println("NS create allowIncompleteView: "+allowIncompleteView); + System.err.println("NS create backingLayerHost: "+backingLayerHost); + System.err.println("NS create share: "+share); + System.err.println("NS create drawable type: "+drawable.getClass().getName()); + System.err.println("NS create drawable handle: isPBuffer "+isPBuffer+", isFBO "+isFBO); + System.err.println("NS create pixelFormat: "+toHexString(pixelFormat)); + System.err.println("NS create chosenCaps: "+chosenCaps); System.err.println("NS create fixedCaps: "+fixedCaps); + System.err.println("NS create drawable native-handle: "+toHexString(drawable.getHandle())); + System.err.println("NS create drawable NSView-handle: "+toHexString(nsViewHandle)); + System.err.println("NS create screen refresh-rate: "+sRefreshRate+" hz, "+screenVSyncTimeout+" micros"); + // Thread.dumpStack(); } if(fixedCaps.isPBuffer()) { - // Must now associate the pbuffer with our newly-created context - CGL.setContextPBuffer(ctx, drawable.getHandle()); + if(!isPBuffer) { + throw new InternalError("fixedCaps is PBuffer, handle not: "+drawable); + } + } else { + if(isPBuffer) { + throw new InternalError("handle is PBuffer, fixedCaps not: "+drawable); + } } - // - // handled layered surface - // + config.setChosenCapabilities(fixedCaps); + /** if(null != backingLayerHost) { - nsOpenGLLayerPFmt = pixelFormat; - pixelFormat = 0; - final int texWidth, texHeight; - if(drawable instanceof MacOSXPbufferCGLDrawable) { - final MacOSXPbufferCGLDrawable osxPDrawable = (MacOSXPbufferCGLDrawable)drawable; - texWidth = osxPDrawable.getTextureWidth(); - texHeight = osxPDrawable.getTextureHeight(); - } else { - texWidth = drawable.getWidth(); - texHeight = drawable.getHeight(); + backingLayerHost.setChosenCapabilities(fixedCaps); + } */ + + try { + int[] viewNotReady = new int[1]; + // Try to allocate a context with this + ctx = CGL.createContext(share, + nsViewHandle, allowIncompleteView, + pixelFormat, + chosenCaps.isBackgroundOpaque(), + viewNotReady, 0); + if (0 == ctx) { + if(DEBUG) { + System.err.println("NS create failed: viewNotReady: "+ (1 == viewNotReady[0])); + } + return 0; } - if(0>=texWidth || 0>=texHeight || !drawable.isRealized()) { - throw new GLException("Drawable not realized yet or invalid texture size, texSize "+texWidth+"x"+texHeight+", "+drawable); + + if(null != backingLayerHost) { + nsOpenGLLayerPFmt = pixelFormat; + pixelFormat = 0; } - nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, drawable.getHandle(), fixedCaps.isBackgroundOpaque(), texWidth, texHeight); - if (DEBUG) { - System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", texSize "+texWidth+"x"+texHeight+", "+drawable); + + if (chosenCaps.isOnscreen() && !chosenCaps.isBackgroundOpaque()) { + // Set the context opacity + CGL.setContextOpacity(ctx, 0); + } + } finally { + if(0!=pixelFormat) { + CGL.deletePixelFormat(pixelFormat); + pixelFormat = 0; } - backingLayerHost.attachSurfaceLayer(nsOpenGLLayer); - setSwapInterval(1); // enabled per default in layered surface - } - } finally { - if(0!=pixelFormat) { - CGL.deletePixelFormat(pixelFormat); - } - } - return ctx; - } - - @Override - public boolean destroy(long ctx) { - if(0 != nsOpenGLLayer) { - final NativeSurface surface = drawable.getNativeSurface(); - if (DEBUG) { - System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer)); - } - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true); - if(null != ols && ols.isSurfaceLayerAttached()) { - // still having a valid OLS attached to surface (parent OLS could have been removed) - ols.detachSurfaceLayer(); } - CGL.releaseNSOpenGLLayer(nsOpenGLLayer); - CGL.deletePixelFormat(nsOpenGLLayerPFmt); - nsOpenGLLayerPFmt = 0; - nsOpenGLLayer = 0; + return ctx; } - return CGL.deleteContext(ctx, true); - } - - @Override - public boolean copyImpl(long src, int mask) { - CGL.copyContext(contextHandle, src, mask); - return true; - } - @Override - public boolean makeCurrent(long ctx) { - final long cglCtx = CGL.getCGLContext(ctx); - if(0 == cglCtx) { - throw new InternalError("Null CGLContext for: "+this); + @Override + public boolean destroy(long ctx) { + lastPBufferHandle = 0; + return CGL.deleteContext(ctx, true); } - int err = CGL.CGLLockContext(cglCtx); - if(CGL.kCGLNoError == err) { - return CGL.makeCurrentContext(ctx); - } else if(DEBUG) { - System.err.println("NSGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this); + + @Override + public boolean contextRealized(boolean realized) { + if( realized ) { + if( null != backingLayerHost ) { + // + // handled layered surface + // + final GLCapabilitiesImmutable chosenCaps = drawable.getChosenGLCapabilities(); + final long ctx = MacOSXCGLContext.this.getHandle(); + final int texID; + final long drawableHandle = drawable.getHandle(); + if(drawable instanceof GLFBODrawableImpl) { + final GLFBODrawableImpl fbod = (GLFBODrawableImpl)drawable; + texID = fbod.getTextureBuffer(GL.GL_FRONT).getName(); + fbod.setSwapBufferContext(new GLFBODrawableImpl.SwapBufferContext() { + public void swapBuffers(boolean doubleBuffered) { + MacOSXCGLContext.NSOpenGLImpl.this.swapBuffers(); + } } ) ; + lastPBufferHandle = 0; + } else if( chosenCaps.isPBuffer() && CGL.isNSOpenGLPixelBuffer(drawableHandle) ) { + texID = 0; + lastPBufferHandle = drawableHandle; + } else { + throw new GLException("BackingLayerHost w/ unknown handle (!FBO, !PBuffer): "+drawable); + } + lastWidth = drawable.getWidth(); + lastHeight = drawable.getHeight(); + if(0>=lastWidth || 0>=lastHeight || !drawable.isRealized()) { + throw new GLException("Drawable not realized yet or invalid texture size, texSize "+lastWidth+"x"+lastHeight+", "+drawable); + } + nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, nsOpenGLLayerPFmt, lastPBufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight); + if (DEBUG) { + System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+" w/ pbuffer "+toHexString(lastPBufferHandle)+", texID "+texID+", texSize "+lastWidth+"x"+lastHeight+", "+drawable); + } + backingLayerHost.attachSurfaceLayer(nsOpenGLLayer); + setSwapInterval(1); // enabled per default in layered surface + } else { + lastWidth = drawable.getWidth(); + lastHeight = drawable.getHeight(); + } + } else { + if( 0 != nsOpenGLLayer ) { + final NativeSurface surface = drawable.getNativeSurface(); + if (DEBUG) { + System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", "+drawable); + } + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true); + if(null != ols && ols.isSurfaceLayerAttached()) { + // still having a valid OLS attached to surface (parent OLS could have been removed) + ols.detachSurfaceLayer(); + } + CGL.releaseNSOpenGLLayer(nsOpenGLLayer); + nsOpenGLLayer = 0; + } + if(0 != nsOpenGLLayerPFmt) { + CGL.deletePixelFormat(nsOpenGLLayerPFmt); + nsOpenGLLayerPFmt = 0; + } + lastPBufferHandle = 0; + } + backingLayerHost = null; + return true; } - return false; - } - @Override - public boolean release(long ctx) { - try { - gl.glFlush(); // w/o glFlush()/glFinish() OSX < 10.7 (NVidia driver) may freeze - } catch (GLException gle) { - if(DEBUG) { - System.err.println("MacOSXCGLContext.NSOpenGLImpl.release: INFO: glFlush() catched exception:"); - gle.printStackTrace(); + private final void validatePBufferConfig(long ctx) { + final GLCapabilitiesImmutable chosenCaps = drawable.getChosenGLCapabilities(); + final long drawableHandle = drawable.getHandle(); + if(chosenCaps.isPBuffer() && CGL.isNSOpenGLPixelBuffer(drawableHandle) && lastPBufferHandle != drawableHandle) { + // Must associate the pbuffer with our newly-created context + lastPBufferHandle = drawableHandle; + if(0 != drawableHandle) { + CGL.setContextPBuffer(ctx, drawableHandle); + } + if(DEBUG) { + System.err.println("NS.validateDrawableConfig bind pbuffer "+toHexString(drawableHandle)+" -> ctx "+toHexString(ctx)); + } } } - final boolean res = CGL.clearCurrentContext(ctx); - final long cglCtx = CGL.getCGLContext(ctx); - if(0 == cglCtx) { - throw new InternalError("Null CGLContext for: "+this); + + /** Returns true if size has been updated, otherwise false (same size). */ + private final boolean validateDrawableSizeConfig(long ctx) { + final int width = drawable.getWidth(); + final int height = drawable.getHeight(); + if( lastWidth != width || lastHeight != height ) { + lastWidth = drawable.getWidth(); + lastHeight = drawable.getHeight(); + if(DEBUG) { + System.err.println("NS.validateDrawableConfig size changed"); + } + return true; + } + return false; } - final int err = CGL.CGLUnlockContext(cglCtx); - if(DEBUG && CGL.kCGLNoError != err) { - System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err)+": "+this); + + @Override + public boolean copyImpl(long src, int mask) { + CGL.copyContext(contextHandle, src, mask); + return true; } - return res && CGL.kCGLNoError == err; - } - @Override - public boolean setSwapInterval(int interval) { - if(0 != nsOpenGLLayer) { - CGL.setNSOpenGLLayerSwapInterval(nsOpenGLLayer, interval); - vsyncTimeout = interval * (int)screenVSyncTimeout; - if(DEBUG) { System.err.println("NS setSwapInterval: "+vsyncTimeout+" micros"); } + @Override + public boolean makeCurrent(long ctx) { + final long cglCtx = CGL.getCGLContext(ctx); + if(0 == cglCtx) { + throw new InternalError("Null CGLContext for: "+this); + } + int err = CGL.CGLLockContext(cglCtx); + if(CGL.kCGLNoError == err) { + validatePBufferConfig(ctx); // required to handle pbuffer change ASAP + return CGL.makeCurrentContext(ctx); + } else if(DEBUG) { + System.err.println("NSGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this); + } + return false; + } + + @Override + public boolean release(long ctx) { + try { + gl.glFlush(); // w/o glFlush()/glFinish() OSX < 10.7 (NVidia driver) may freeze + } catch (GLException gle) { + if(DEBUG) { + System.err.println("MacOSXCGLContext.NSOpenGLImpl.release: INFO: glFlush() catched exception:"); + gle.printStackTrace(); + } + } + final boolean res = CGL.clearCurrentContext(ctx); + final long cglCtx = CGL.getCGLContext(ctx); + if(0 == cglCtx) { + throw new InternalError("Null CGLContext for: "+this); + } + final int err = CGL.CGLUnlockContext(cglCtx); + if(DEBUG && CGL.kCGLNoError != err) { + System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err)+": "+this); + } + return res && CGL.kCGLNoError == err; } - CGL.setSwapInterval(contextHandle, interval); - return true; - } - @Override - public boolean swapBuffers() { - if( 0 != nsOpenGLLayer ) { - // If v-sync is disabled, frames will be drawn as quickly as possible - // w/o delay but in sync w/ CALayer. Otherwise wait until next swap interval (v-sync). - CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, vsyncTimeout); + @Override + public boolean detachPBuffer() { + if(0 != lastPBufferHandle) { + lastPBufferHandle = 0; + if(0 != nsOpenGLLayer) { + CGL.flushNSOpenGLLayerPBuffer(nsOpenGLLayer); // notify invalid pbuffer + } + // CGL.setContextPBuffer(contextHandle, 0); // doesn't work, i.e. not taking nil + } + return true; } - if(CGL.flushBuffer(contextHandle)) { + + @Override + public boolean setSwapInterval(int interval) { if(0 != nsOpenGLLayer) { - // trigger CALayer to update - CGL.setNSOpenGLLayerNeedsDisplay(nsOpenGLLayer); + CGL.setNSOpenGLLayerSwapInterval(nsOpenGLLayer, interval); + vsyncTimeout = interval * (int)screenVSyncTimeout + 1000; // +1ms + if(DEBUG) { System.err.println("NS setSwapInterval: "+vsyncTimeout+" micros"); } } + CGL.setSwapInterval(contextHandle, interval); return true; } - return false; - } + + private int skipSync=0; + + @Override + public boolean swapBuffers() { + final boolean res; + if( 0 != nsOpenGLLayer ) { + if( validateDrawableSizeConfig(contextHandle) ) { + // skip wait-for-vsync for a few frames if size has changed, + // allowing to update the texture IDs ASAP. + skipSync = 10; + } + + final int texID; + final boolean valid; + if(drawable instanceof GLFBODrawableImpl) { + texID = ((GLFBODrawableImpl)drawable).getTextureBuffer(GL.GL_FRONT).getName(); + valid = 0 != texID; + } else { + texID = 0; + valid = 0 != lastPBufferHandle; + } + if(valid) { + if(0 == skipSync) { + // If v-sync is disabled, frames will be drawn as quickly as possible + // w/o delay but in sync w/ CALayer. Otherwise wait until next swap interval (v-sync). + CGL.waitUntilNSOpenGLLayerIsReady(nsOpenGLLayer, vsyncTimeout); + } else { + skipSync--; + } + res = CGL.flushBuffer(contextHandle); + if(res) { + // trigger CALayer to update incl. possible surface change + CGL.setNSOpenGLLayerNeedsDisplay(nsOpenGLLayer, lastPBufferHandle, texID, lastWidth, lastHeight); + } + } else { + res = true; + } + } else { + res = CGL.flushBuffer(contextHandle); + } + return res; + } + } class CGLImpl implements GLBackendImpl { - @Override - public boolean isNSContext() { return false; } - - @Override - public long create(long share, int ctp, int major, int minor) { - long ctx = 0; - MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); - GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); - long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2CGLPixelFormat(chosenCaps, ctp, major, minor); - if (pixelFormat == 0) { - throw new GLException("Unable to allocate pixel format with requested GLCapabilities"); - } - config.setChosenPixelFormat(pixelFormat); - try { - // Create new context - PointerBuffer ctxPB = PointerBuffer.allocateDirect(1); - if (DEBUG) { - System.err.println("Share context for CGL-based pbuffer context is " + toHexString(share)); + @Override + public boolean isNSContext() { return false; } + + @Override + public long create(long share, int ctp, int major, int minor) { + long ctx = 0; + MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); + GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); + long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2CGLPixelFormat(chosenCaps, ctp, major, minor); + if (pixelFormat == 0) { + throw new GLException("Unable to allocate pixel format with requested GLCapabilities"); } - int res = CGL.CGLCreateContext(pixelFormat, share, ctxPB); - if (res != CGL.kCGLNoError) { - throw new GLException("Error code " + res + " while creating context"); - } - if(chosenCaps.isPBuffer()) { - // Attach newly-created context to the pbuffer - res = CGL.CGLSetPBuffer(ctxPB.get(0), drawable.getHandle(), 0, 0, 0); + try { + // Create new context + PointerBuffer ctxPB = PointerBuffer.allocateDirect(1); + if (DEBUG) { + System.err.println("Share context for CGL-based pbuffer context is " + toHexString(share)); + } + int res = CGL.CGLCreateContext(pixelFormat, share, ctxPB); if (res != CGL.kCGLNoError) { - throw new GLException("Error code " + res + " while attaching context to pbuffer"); + throw new GLException("Error code " + res + " while creating context"); } - } - ctx = ctxPB.get(0); - if(0!=ctx) { - if(DEBUG) { - GLCapabilitiesImmutable caps0 = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(pixelFormat); - System.err.println("NS created: "+caps0); + ctx = ctxPB.get(0); + + if (0 != ctx) { + GLCapabilities fixedCaps = MacOSXCGLGraphicsConfiguration.CGLPixelFormat2GLCapabilities(pixelFormat); + fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); + if(chosenCaps.isOnscreen() || !fixedCaps.isPBuffer()) { + // not handled, so copy them + fixedCaps.setFBO(chosenCaps.isFBO()); + fixedCaps.setPBuffer(chosenCaps.isPBuffer()); + fixedCaps.setBitmap(chosenCaps.isBitmap()); + fixedCaps.setOnscreen(chosenCaps.isOnscreen()); + } + config.setChosenCapabilities(fixedCaps); + if(DEBUG) { + System.err.println("CGL create fixedCaps: "+fixedCaps); + } + if(fixedCaps.isPBuffer()) { + // Must now associate the pbuffer with our newly-created context + res = CGL.CGLSetPBuffer(ctx, drawable.getHandle(), 0, 0, 0); + if (res != CGL.kCGLNoError) { + throw new GLException("Error code " + res + " while attaching context to pbuffer"); + } + } } + } finally { + CGL.CGLDestroyPixelFormat(pixelFormat); } - } finally { - CGL.CGLDestroyPixelFormat(pixelFormat); + return ctx; } - return ctx; - } - @Override - public boolean destroy(long ctx) { - return CGL.CGLDestroyContext(ctx) == CGL.kCGLNoError; - } + @Override + public boolean destroy(long ctx) { + return CGL.CGLDestroyContext(ctx) == CGL.kCGLNoError; + } - @Override - public boolean copyImpl(long src, int mask) { - CGL.CGLCopyContext(src, contextHandle, mask); - return true; - } + @Override + public boolean contextRealized(boolean realized) { + return true; + } + + @Override + public boolean copyImpl(long src, int mask) { + CGL.CGLCopyContext(src, contextHandle, mask); + return true; + } - @Override - public boolean makeCurrent(long ctx) { - int err = CGL.CGLLockContext(ctx); - if(CGL.kCGLNoError == err) { - err = CGL.CGLSetCurrentContext(ctx); + @Override + public boolean makeCurrent(long ctx) { + int err = CGL.CGLLockContext(ctx); if(CGL.kCGLNoError == err) { - return true; + err = CGL.CGLSetCurrentContext(ctx); + if(CGL.kCGLNoError == err) { + return true; + } else if(DEBUG) { + System.err.println("CGL: Could not make context current: err 0x"+Integer.toHexString(err)+": "+this); + } } else if(DEBUG) { - System.err.println("CGL: Could not make context current: err 0x"+Integer.toHexString(err)+": "+this); + System.err.println("CGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this); } - } else if(DEBUG) { - System.err.println("CGL: Could not lock context: err 0x"+Integer.toHexString(err)+": "+this); + return false; } - return false; - } - @Override - public boolean release(long ctx) { - try { - gl.glFlush(); // w/o glFlush()/glFinish() OSX < 10.7 (NVidia driver) may freeze - } catch (GLException gle) { - if(DEBUG) { - System.err.println("MacOSXCGLContext.CGLImpl.release: INFO: glFlush() catched exception:"); - gle.printStackTrace(); + @Override + public boolean release(long ctx) { + try { + gl.glFlush(); // w/o glFlush()/glFinish() OSX < 10.7 (NVidia driver) may freeze + } catch (GLException gle) { + if(DEBUG) { + System.err.println("MacOSXCGLContext.CGLImpl.release: INFO: glFlush() catched exception:"); + gle.printStackTrace(); + } } + int err = CGL.CGLSetCurrentContext(0); + if(DEBUG && CGL.kCGLNoError != err) { + System.err.println("CGL: Could not release current context: err 0x"+Integer.toHexString(err)+": "+this); + } + int err2 = CGL.CGLUnlockContext(ctx); + if(DEBUG && CGL.kCGLNoError != err2) { + System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err2)+": "+this); + } + return CGL.kCGLNoError == err && CGL.kCGLNoError == err2; + } + + @Override + public boolean detachPBuffer() { + /* Doesn't work, i.e. not taking NULL + final int res = CGL.CGLSetPBuffer(contextHandle, 0, 0, 0, 0); + if (res != CGL.kCGLNoError) { + throw new GLException("Error code " + res + " while detaching context from pbuffer"); + } */ + return true; } - int err = CGL.CGLSetCurrentContext(0); - if(DEBUG && CGL.kCGLNoError != err) { - System.err.println("CGL: Could not release current context: err 0x"+Integer.toHexString(err)+": "+this); + + @Override + public boolean setSwapInterval(int interval) { + int[] lval = new int[] { interval } ; + CGL.CGLSetParameter(contextHandle, CGL.kCGLCPSwapInterval, lval, 0); + return true; } - int err2 = CGL.CGLUnlockContext(ctx); - if(DEBUG && CGL.kCGLNoError != err2) { - System.err.println("CGL: Could not unlock context: err 0x"+Integer.toHexString(err2)+": "+this); + @Override + public boolean swapBuffers() { + return CGL.kCGLNoError == CGL.CGLFlushDrawable(contextHandle); } - return CGL.kCGLNoError == err && CGL.kCGLNoError == err2; - } - - @Override - public boolean setSwapInterval(int interval) { - int[] lval = new int[] { interval } ; - CGL.CGLSetParameter(contextHandle, CGL.kCGLCPSwapInterval, lval, 0); - return true; - } - @Override - public boolean swapBuffers() { - return CGL.kCGLNoError == CGL.CGLFlushDrawable(contextHandle); - } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index af767f0c3..cc727c8e1 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -42,10 +42,10 @@ package jogamp.opengl.macosx.cgl; import java.lang.ref.WeakReference; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; @@ -92,7 +92,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { this.id = id; } } - private List> createdContexts = new ArrayList>(); + /* pp */ List> createdContexts = new ArrayList>(); private boolean haveSetOpenGLMode = false; private GLBackendType openGLMode = GLBackendType.NSOPENGL; @@ -110,26 +110,42 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { return GLBackendType.NSOPENGL == openGLMode ? getHandle() : 0; } - protected void registerContext(MacOSXCGLContext ctx) { + @Override + protected void associateContext(GLContext ctx, boolean bound) { // NOTE: we need to keep track of the created contexts in order to // implement swapBuffers() because of how Mac OS X implements its // OpenGL window interface synchronized (createdContexts) { - createdContexts.add(new WeakReference(ctx)); - } + if(bound) { + createdContexts.add(new WeakReference((MacOSXCGLContext)ctx)); + } else { + for(int i=0; i ref = createdContexts.get(i); + final MacOSXCGLContext _ctx = ref.get(); + if( _ctx == null || _ctx == ctx) { + createdContexts.remove(i); + } else { + i++; + } + } + } + } } + @Override - protected final void swapBuffersImpl() { - // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - synchronized (createdContexts) { - for (Iterator> iter = createdContexts.iterator(); iter.hasNext(); ) { - WeakReference ref = iter.next(); - MacOSXCGLContext ctx = ref.get(); - if (ctx != null) { - ctx.swapBuffers(); - } else { - iter.remove(); - } + protected final void swapBuffersImpl(boolean doubleBuffered) { + if(doubleBuffered) { + synchronized (createdContexts) { + for(int i=0; i ref = createdContexts.get(i); + final MacOSXCGLContext ctx = ref.get(); + if (ctx != null) { + ctx.swapBuffers(); + i++; + } else { + createdContexts.remove(i); + } + } } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 591fafc68..e174d38f4 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -51,7 +51,7 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -61,7 +61,8 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.macosx.OSXDummyUpstreamSurfaceHook; import jogamp.opengl.DesktopGLDynamicLookupHelper; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; @@ -71,7 +72,7 @@ import jogamp.opengl.GLGraphicsConfigurationUtil; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; -import com.jogamp.nativewindow.WrappedSurface; +import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.opengl.GLExtensions; @@ -320,9 +321,14 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected GLDrawableImpl createOffscreenDrawableImpl(NativeSurface target) { - AbstractGraphicsConfiguration config = target.getGraphicsConfiguration(); - GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final MutableGraphicsConfiguration config = (MutableGraphicsConfiguration) target.getGraphicsConfiguration(); + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); if(!caps.isPBuffer()) { + // Actual implementation is using PBuffer ... + final GLCapabilities modCaps = (GLCapabilities) caps.cloneMutable(); + modCaps.setPBuffer(true); + modCaps.setBitmap(false); + config.setChosenCapabilities(modCaps); return new MacOSXOffscreenCGLDrawable(this, target); } return new MacOSXPbufferCGLDrawable(this, target); @@ -336,7 +342,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final MacOSXGraphicsDevice device; if(createNewDevice) { device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); @@ -348,68 +354,23 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, width, height, lifecycleHook); + return new WrappedSurface(config, 0, upstreamHook, createNewDevice); } @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, + new OSXDummyUpstreamSurfaceHook(width, height)); } - private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { - long nsWindow = 0; - @Override - public final void create(ProxySurface s) { - if(0 == nsWindow && 0 == s.getSurfaceHandle()) { - nsWindow = OSXUtil.CreateNSWindow(0, 0, s.getWidth(), s.getHeight()); - if(0 == nsWindow) { - throw new GLException("Error NS window 0"); - } - long nsView = OSXUtil.GetNSView(nsWindow); - if(0 == nsView) { - throw new GLException("Error NS view 0"); - } - s.setSurfaceHandle(nsView); - s.setImplBitfield(ProxySurface.INVISIBLE_WINDOW); - if(DEBUG) { - System.err.println("MacOSXCGLDrawableFactory.dummySurfaceLifecycleHook.create: "+s); - } - } - } - @Override - public final void destroy(ProxySurface s) { - if(0 != nsWindow && 0 != s.getSurfaceHandle()) { - OSXUtil.DestroyNSWindow(nsWindow); - nsWindow = 0; - s.setSurfaceHandle(0); - if(DEBUG) { - System.err.println("MacOSXCGLDrawableFactory.dummySurfaceLifecycleHook.destroy: "+s); - } - } - } - @Override - public final int getWidth(ProxySurface s) { - return s.initialWidth; - } - @Override - public final int getHeight(ProxySurface s) { - return s.initialHeight; - } - - @Override - public String toString() { - return "MacOSXLSurfaceLifecycleHook[]"; - } - - }; @Override protected ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final MacOSXGraphicsDevice device = new MacOSXGraphicsDevice(deviceReq.getUnitID()); final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); final MacOSXCGLGraphicsConfiguration config = MacOSXCGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen, true); - return new WrappedSurface(config, windowHandle, 0, 0, upstream); + return new WrappedSurface(config, windowHandle, upstream, true); } @Override diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java index 149927160..8866c7ce6 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfiguration.java @@ -51,23 +51,16 @@ import com.jogamp.common.nio.PointerBuffer; import com.jogamp.nativewindow.MutableGraphicsConfiguration; public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { - long pixelformat; MacOSXCGLGraphicsConfiguration(AbstractGraphicsScreen screen, - GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - long pixelformat) { + GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested) { super(screen, capsChosen, capsRequested); - this.pixelformat=pixelformat; } public Object clone() { return super.clone(); } - void setChosenPixelFormat(long pixelformat) { - this.pixelformat=pixelformat; - } - protected static List getAvailableCapabilities(MacOSXCGLDrawableFactory factory, AbstractGraphicsDevice device) { MacOSXCGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateOSXSharedResource(device); if(null == sharedResource) { @@ -114,11 +107,11 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration break; case CGL.kCGLPFAColorFloat: - ivalues[idx] = caps.getPbufferFloatingPointBuffers() ? 1 : 0; + ivalues[idx] = ( !caps.isOnscreen() && caps.isPBuffer() && caps.getPbufferFloatingPointBuffers() ) ? 1 : 0; break; case CGL.NSOpenGLPFAPixelBuffer: - ivalues[idx] = caps.isPBuffer() ? 1 : 0; + ivalues[idx] = ( !caps.isOnscreen() && caps.isPBuffer() ) ? 1 : 0; break; case CGL.NSOpenGLPFADoubleBuffer: @@ -188,11 +181,11 @@ public class MacOSXCGLGraphicsConfiguration extends MutableGraphicsConfiguration attrs[i++] = CGL.kCGLPFAOpenGLProfile; attrs[i++] = MacOSXCGLContext.GLProfile2CGLOGLProfileValue(ctp, major, minor); } - if(caps.isPBuffer()) { + if(!caps.isOnscreen() && caps.isPBuffer()) { attrs[i++] = CGL.kCGLPFAPBuffer; - } - if (caps.getPbufferFloatingPointBuffers()) { - attrs[i++] = CGL.kCGLPFAColorFloat; + if (caps.getPbufferFloatingPointBuffers()) { + attrs[i++] = CGL.kCGLPFAColorFloat; + } } if (caps.getDoubleBuffered()) { attrs[i++] = CGL.kCGLPFADoubleBuffer; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java index 13faf7090..43a9d0d1a 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java @@ -96,6 +96,6 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurati capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(device) ); - return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested, 0); + return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested); } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index 6be9e386d..65ed5fc15 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -49,8 +49,8 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; -import com.jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.WrappedSurface; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLContextShareSet; import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType; @@ -62,7 +62,6 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { private MacOSXExternalCGLContext(Drawable drawable, boolean isNSContext, long handle) { super(drawable, null); setOpenGLMode(isNSContext ? GLBackendType.NSOPENGL : GLBackendType.CGL ); - drawable.registerContext(this); this.contextHandle = handle; GLContextShareSet.contextCreated(this); setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT); @@ -108,13 +107,13 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { } AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_MACOSX); - MacOSXCGLGraphicsConfiguration cfg = new MacOSXCGLGraphicsConfiguration(aScreen, caps, caps, pixelFormat); + MacOSXCGLGraphicsConfiguration cfg = new MacOSXCGLGraphicsConfiguration(aScreen, caps, caps); if(0 == currentDrawable) { // set a fake marker stating a valid drawable currentDrawable = 1; } - WrappedSurface ns = new WrappedSurface(cfg, currentDrawable, 64, 64, null); + WrappedSurface ns = new WrappedSurface(cfg, currentDrawable, 64, 64, true); return new MacOSXExternalCGLContext(new Drawable(factory, ns), isNSContext, contextHandle); } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java index b1e283ebc..ec9628004 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java @@ -52,9 +52,7 @@ public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - final MacOSXOnscreenCGLContext ctx= new MacOSXOnscreenCGLContext(this, shareWith); - registerContext(ctx); - return ctx; + return new MacOSXOnscreenCGLContext(this, shareWith); } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java index 88886ddd2..7e2d8cf10 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java @@ -39,6 +39,7 @@ import javax.media.opengl.GLPbuffer; import jogamp.opengl.GLContextImpl; +@SuppressWarnings("deprecation") public class MacOSXPbufferCGLContext extends MacOSXCGLContext { // State for render-to-texture and render-to-texture-rectangle support diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index 8f2f386af..668e463a2 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -40,6 +40,8 @@ package jogamp.opengl.macosx.cgl; +import java.lang.ref.WeakReference; + import javax.media.nativewindow.DefaultGraphicsConfiguration; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.MutableSurface; @@ -70,9 +72,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { // private int textureTarget; // e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_NV // private int texture; // actual texture object - // Note that we can not store this in the NativeSurface because the - // semantic is that contains an NSView - protected long pBuffer; protected int pBufferTexTarget, pBufferTexWidth, pBufferTexHeight; public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, NativeSurface target) { @@ -90,9 +89,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { @Override public GLContext createContext(GLContext shareWith) { - final MacOSXPbufferCGLContext ctx = new MacOSXPbufferCGLContext(this, shareWith); - registerContext(ctx); - return ctx; + return new MacOSXPbufferCGLContext(this, shareWith); } @Override @@ -101,27 +98,34 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { return 0; } - @Override - public long getHandle() { - return pBuffer; - } - protected int getTextureTarget() { return pBufferTexTarget; } protected int getTextureWidth() { return pBufferTexWidth; } protected int getTextureHeight() { return pBufferTexHeight; } protected void destroyPbuffer() { - if (this.pBuffer != 0) { - NativeSurface ns = getNativeSurface(); + final MutableSurface ms = (MutableSurface) getNativeSurface(); + final long pBuffer = ms.getSurfaceHandle(); + if (0 != pBuffer) { + synchronized (createdContexts) { + for(int i=0; i ref = createdContexts.get(i); + final MacOSXCGLContext ctx = ref.get(); + if (ctx != null) { + ctx.detachPBuffer(); + i++; + } else { + createdContexts.remove(i); + } + } + } impl.destroy(pBuffer); - this.pBuffer = 0; - ((MutableSurface)ns).setSurfaceHandle(0); + ms.setSurfaceHandle(0); } } private void createPbuffer() { - final NativeSurface ns = getNativeSurface(); - final DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ns.getGraphicsConfiguration(); + final MutableSurface ms = (MutableSurface) getNativeSurface(); + final DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ms.getGraphicsConfiguration(); final GLCapabilitiesImmutable capabilities = (GLCapabilitiesImmutable)config.getChosenCapabilities(); final GLProfile glProfile = capabilities.getGLProfile(); MacOSXCGLDrawableFactory.SharedResource sr = ((MacOSXCGLDrawableFactory)factory).getOrCreateOSXSharedResource(config.getScreen().getDevice()); @@ -161,7 +165,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { } } - pBuffer = impl.create(pBufferTexTarget, internalFormat, getWidth(), getHeight()); + final long pBuffer = impl.create(pBufferTexTarget, internalFormat, getWidth(), getHeight()); if(DEBUG) { System.err.println("MacOSXPbufferCGLDrawable tex: target "+toHexString(pBufferTexTarget)+ ", pbufferSize "+getWidth()+"x"+getHeight()+ @@ -174,7 +178,7 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { throw new GLException("pbuffer creation error: CGL.createPBuffer() failed"); } - ((MutableSurface)ns).setSurfaceHandle(pBuffer); + ms.setSurfaceHandle(pBuffer); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index 96c1187d3..f6cc2956d 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -50,8 +50,8 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import com.jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; import jogamp.opengl.GLContextShareSet; @@ -102,7 +102,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { System.err.println("WindowsExternalWGLContext valid hdc/pfd, retrieved cfg: " + cfg); } } - return new WindowsExternalWGLContext(new Drawable(factory, new WrappedSurface(cfg, hdc, 64, 64, null)), ctx, cfg); + return new WindowsExternalWGLContext(new Drawable(factory, new WrappedSurface(cfg, hdc, 64, 64, true)), ctx, cfg); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java index 15bd005dc..f8c237c9e 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java @@ -49,10 +49,10 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.GDIUtil; -import com.jogamp.nativewindow.WrappedSurface; public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { @@ -72,7 +72,7 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { final AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); final WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromExternal(factory, hdc, pfdID, glp, aScreen, true); - return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc, 64, 64, null)); + return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc, 64, 64, true)); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java index ca7886e7f..3b3f0c123 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawable.java @@ -73,27 +73,28 @@ public abstract class WindowsWGLDrawable extends GLDrawableImpl { } @Override - protected final void swapBuffersImpl() { - // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - final long t0; - if (PROFILING) { - t0 = System.currentTimeMillis(); - } else { - t0 = 0; - } - - if (!WGLUtil.SwapBuffers(getHandle()) && (GDI.GetLastError() != GDI.ERROR_SUCCESS)) { - throw new GLException("Error swapping buffers"); - } - - if (PROFILING) { - profilingSwapBuffersTime += System.currentTimeMillis() - t0; - if (++profilingSwapBuffersTicks == PROFILING_TICKS) { - System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + PROFILING_TICKS + " calls (" + - ((float) profilingSwapBuffersTime / (float) PROFILING_TICKS) + " ms/call)"); - profilingSwapBuffersTime = 0; - profilingSwapBuffersTicks = 0; - } + protected final void swapBuffersImpl(boolean doubleBuffered) { + if(doubleBuffered) { + final long t0; + if (PROFILING) { + t0 = System.currentTimeMillis(); + } else { + t0 = 0; + } + + if (!WGLUtil.SwapBuffers(getHandle()) && (GDI.GetLastError() != GDI.ERROR_SUCCESS)) { + throw new GLException("Error swapping buffers"); + } + + if (PROFILING) { + profilingSwapBuffersTime += System.currentTimeMillis() - t0; + if (++profilingSwapBuffersTicks == PROFILING_TICKS) { + System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + PROFILING_TICKS + " calls (" + + ((float) profilingSwapBuffersTime / (float) PROFILING_TICKS) + " ms/call)"); + profilingSwapBuffersTime = 0; + profilingSwapBuffersTicks = 0; + } + } } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 7ea487523..91d5c225a 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -52,7 +52,7 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.opengl.GL; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -62,9 +62,10 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; +import jogamp.nativewindow.windows.GDIDummyUpstreamSurfaceHook; import jogamp.nativewindow.windows.GDISurface; -import jogamp.nativewindow.windows.GDIUtil; import jogamp.nativewindow.windows.RegisteredClassFactory; import jogamp.opengl.DesktopGLDynamicLookupHelper; import jogamp.opengl.GLContextImpl; @@ -79,7 +80,6 @@ import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; -import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.opengl.GLExtensions; @@ -541,7 +541,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final WindowsGraphicsDevice device; if(createNewDevice) { device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); @@ -553,7 +553,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface(config, 0, width, height, lifecycleHook); + return new WrappedSurface(config, 0, upstreamHook, createNewDevice); } @Override @@ -571,57 +571,15 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+requestedCaps+" on "+screen); } - return new GDISurface(config, 0, width, height, dummySurfaceLifecycleHook); - } - private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { - @Override - public final void create(ProxySurface s) { - final GDISurface ms = (GDISurface)s; - if(0 == ms.getWindowHandle()) { - final long windowHandle = GDIUtil.CreateDummyWindow(0, 0, s.getWidth(), s.getHeight()); - if(0 == windowHandle) { - throw new GLException("Error windowHandle 0, werr: "+GDI.GetLastError()); - } - ms.setWindowHandle(windowHandle); - if(DEBUG) { - System.err.println("WindowsWGLDrawableFactory.dummySurfaceLifecycleHook.create: "+ms); - } - } - } - @Override - public final void destroy(ProxySurface s) { - final GDISurface ms = (GDISurface)s; - if(0 != ms.getWindowHandle()) { - GDI.ShowWindow(ms.getWindowHandle(), GDI.SW_HIDE); - GDIUtil.DestroyDummyWindow(ms.getWindowHandle()); - ms.setWindowHandle(0); - if(DEBUG) { - System.err.println("WindowsWGLDrawableFactory.dummySurfaceLifecycleHook.destroy: "+ms); - } - } - } - @Override - public final int getWidth(ProxySurface s) { - return s.initialWidth; - } - @Override - public final int getHeight(ProxySurface s) { - return s.initialHeight; - } - - @Override - public String toString() { - return "GDISurfaceLifecycleHook[]"; - } - }; - + return new GDISurface(config, 0, new GDIDummyUpstreamSurfaceHook(width, height), createNewDevice); + } @Override protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { final WindowsGraphicsDevice device = new WindowsGraphicsDevice(deviceReq.getConnection(), deviceReq.getUnitID()); final AbstractGraphicsScreen screen = new DefaultGraphicsScreen(device, screenIdx); final WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsRequested, capsRequested, chooser, screen); - return new GDISurface(cfg, windowHandle, 0, 0, upstream); + return new GDISurface(cfg, windowHandle, upstream, true); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 4d1069e6b..058f4e336 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -107,7 +107,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio if(hasARB) { caps = wglARBPFID2GLCapabilities(sharedResource, device, glp, hdc, pfdID, GLGraphicsConfigurationUtil.ALL_BITS); } else { - caps = PFD2GLCapabilities(glp, hdc, pfdID, GLGraphicsConfigurationUtil.ALL_BITS); + caps = PFD2GLCapabilities(device, glp, hdc, pfdID, GLGraphicsConfigurationUtil.ALL_BITS); } if(null==caps) { throw new GLException("Couldn't choose Capabilities by: HDC 0x"+Long.toHexString(hdc)+ @@ -325,7 +325,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio throw new GLException("wglARBPFID2GLCapabilities: Error getting pixel format attributes for pixel format " + pfdID + " of device context " + toHexString(hdc) + ", werr " + GDI.GetLastError()); } - return AttribList2GLCapabilities(glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits); + return AttribList2GLCapabilities(device, glp, hdc, pfdID, iattributes, niattribs, iresults, winattrbits); } static int[] wglChoosePixelFormatARB(WindowsWGLDrawableFactory.SharedResource sharedResource, AbstractGraphicsDevice device, @@ -390,7 +390,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio for(int i = 0; i= 1 && ((WindowsWGLContext)sharedResource.getContext()).getWGLExt().wglGetPixelFormatAttribivARB(hdc, pfdIDs[i], 0, niattribs, iattributes, 0, iresults, 0) ) { - final GLCapabilitiesImmutable caps = AttribList2GLCapabilities(glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits); + final GLCapabilitiesImmutable caps = AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, winattrbits); if(null != caps) { bucket.add(caps); if(DEBUG) { @@ -398,7 +398,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio System.err.println("wglARBPFIDs2GLCapabilities: bucket["+i+" -> "+j+"]: "+caps); } } else if(DEBUG) { - GLCapabilitiesImmutable skipped = AttribList2GLCapabilities(glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, GLGraphicsConfigurationUtil.ALL_BITS); + GLCapabilitiesImmutable skipped = AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, GLGraphicsConfigurationUtil.ALL_BITS); System.err.println("wglARBPFIDs2GLCapabilities: bucket["+i+" -> skip]: pfdID "+pfdIDs[i]+", "+skipped+", winattr "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString()); } } else if (DEBUG) { @@ -616,9 +616,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return val; } - static WGLGLCapabilities AttribList2GLCapabilities(final GLProfile glp, - final long hdc, final int pfdID, final int[] iattribs, - final int niattribs, final int[] iresults, final int winattrmask) { + static WGLGLCapabilities AttribList2GLCapabilities(final AbstractGraphicsDevice device, + final GLProfile glp, final long hdc, final int pfdID, + final int[] iattribs, final int niattribs, final int[] iresults, final int winattrmask) { final int allDrawableTypeBits = AttribList2DrawableTypeBits(iattribs, niattribs, iresults); int drawableTypeBits = winattrmask & allDrawableTypeBits; @@ -637,7 +637,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio } final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByARB(iattribs, niattribs, iresults); - return (WGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits); + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } // @@ -672,7 +672,7 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio return val; } - static WGLGLCapabilities PFD2GLCapabilities(final GLProfile glp, final long hdc, final int pfdID, final int winattrmask) { + static WGLGLCapabilities PFD2GLCapabilities(AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int pfdID, final int winattrmask) { PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(hdc, pfdID); if(null == pfd) { return null; @@ -689,21 +689,22 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByGDI(); - return (WGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits ); + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } - static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(final GLProfile glp, final long hdc, final int pfdID) { + static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(AbstractGraphicsDevice device, final GLProfile glp, final long hdc, final int pfdID) { PIXELFORMATDESCRIPTOR pfd = createPixelFormatDescriptor(hdc, pfdID); - return PFD2GLCapabilitiesNoCheck(glp, pfd, pfdID); + return PFD2GLCapabilitiesNoCheck(device, glp, pfd, pfdID); } - static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(GLProfile glp, PIXELFORMATDESCRIPTOR pfd, int pfdID) { + static WGLGLCapabilities PFD2GLCapabilitiesNoCheck(AbstractGraphicsDevice device, GLProfile glp, PIXELFORMATDESCRIPTOR pfd, int pfdID) { if(null == pfd) { return null; } final WGLGLCapabilities res = new WGLGLCapabilities(pfd, pfdID, glp); res.setValuesByGDI(); - return (WGLGLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, PFD2DrawableTypeBits(pfd)); + + return (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, PFD2DrawableTypeBits(pfd), res); } static PIXELFORMATDESCRIPTOR GLCapabilities2PFD(GLCapabilitiesImmutable caps, PIXELFORMATDESCRIPTOR pfd) { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 41c9bba02..d2d1dafc8 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -113,13 +113,14 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } protected static List getAvailableCapabilities(WindowsWGLDrawableFactory factory, AbstractGraphicsDevice device) { - WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device); + final WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device); if(null == sharedResource) { throw new GLException("Shared resource for device n/a: "+device); } - GLDrawableImpl sharedDrawable = sharedResource.getDrawable(); - GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities(); - GLContext sharedContext = sharedResource.getContext(); + final GLDrawableImpl sharedDrawable = sharedResource.getDrawable(); + final GLContext sharedContext = sharedResource.getContext(); + final GLProfile glp = GLProfile.getDefault(device); + List availableCaps = null; if ( sharedResource.needsCurrentContext4ARBPFDQueries() ) { @@ -135,10 +136,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat throw new GLException("Error: HDC is null"); } if (sharedResource.hasARBPixelFormat()) { - availableCaps = WindowsWGLGraphicsConfigurationFactory.getAvailableGLCapabilitiesARB(sharedResource, sharedResource.getDevice(), capsChosen.getGLProfile(), hdc); + availableCaps = WindowsWGLGraphicsConfigurationFactory.getAvailableGLCapabilitiesARB(sharedResource, sharedResource.getDevice(), glp, hdc); } if( null == availableCaps || availableCaps.isEmpty() ) { - availableCaps = getAvailableGLCapabilitiesGDI(device, capsChosen.getGLProfile(), hdc); + availableCaps = getAvailableGLCapabilitiesGDI(device, glp, hdc); } } finally { if ( sharedResource.needsCurrentContext4ARBPFDQueries() ) { @@ -165,7 +166,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat int numFormats = pformats.length; List bucket = new ArrayList(numFormats); for (int i = 0; i < numFormats; i++) { - final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, hdc, pformats[i], GLGraphicsConfigurationUtil.ALL_BITS); + final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pformats[i], GLGraphicsConfigurationUtil.ALL_BITS); if(null != caps) { bucket.add(caps); } @@ -439,7 +440,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat private static boolean updateGraphicsConfigurationGDI(WindowsWGLGraphicsConfiguration config, CapabilitiesChooser chooser, long hdc, boolean extHDC, int[] pformats) { GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - if(capsChosen.isPBuffer()) { + if( !capsChosen.isOnscreen() && capsChosen.isPBuffer() ) { if (DEBUG) { System.err.println("updateGraphicsConfigurationGDI: no pbuffer supported on GDI: " + capsChosen); } @@ -454,6 +455,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat System.err.println("updateGraphicsConfigurationGDI: capsChosen "+capsChosen+", "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrmask).toString()); } + AbstractGraphicsDevice device = config.getScreen().getDevice(); int pfdID; // chosen or preset PFD ID WGLGLCapabilities pixelFormatCaps = null; // chosen or preset PFD ID's caps boolean pixelFormatSet = false; // indicates a preset PFD ID [caps] @@ -468,7 +470,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat + ", pixelformat " + pfdID); } pixelFormatSet = true; - pixelFormatCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, hdc, pfdID, winattrmask); + pixelFormatCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask); if(null == pixelFormatCaps) { throw new GLException("Could not map PFD2GLCaps w/ already chosen pfdID "+pfdID); } @@ -480,7 +482,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat List availableCaps = new ArrayList(); for (int i = 0; i < pformats.length; i++) { - final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, hdc, pformats[i], winattrmask); + final GLCapabilitiesImmutable caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pformats[i], winattrmask); if(null != caps) { availableCaps.add(caps); if(DEBUG) { @@ -488,7 +490,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> "+j+"]: "+caps); } } else if(DEBUG) { - GLCapabilitiesImmutable skipped = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(glProfile, hdc, pformats[i]); + GLCapabilitiesImmutable skipped = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, hdc, pformats[i]); System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> skip]: pfdID "+pformats[i]+", "+skipped); } } @@ -505,8 +507,8 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat recommendedIndex--) { /* nop */ } if(DEBUG && 0 > recommendedIndex) { - final GLCapabilitiesImmutable reqPFDCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(glProfile, pfd, pfdID); - final GLCapabilitiesImmutable chosenCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(glProfile, hdc, pfdID, winattrmask); + final GLCapabilitiesImmutable reqPFDCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, pfd, pfdID); + final GLCapabilitiesImmutable chosenCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask); System.err.println("Chosen PFDID "+pfdID+", but not found in available caps (use given pfdIDs "+givenPFormats+", reqPFDCaps "+reqPFDCaps+", chosenCaps: "+chosenCaps); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index 1f3edbd8a..03a0eefbf 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -48,10 +48,10 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLContextShareSet; -import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.x11.X11GraphicsScreen; public class X11ExternalGLXContext extends X11GLXContext { @@ -105,7 +105,7 @@ public class X11ExternalGLXContext extends X11GLXContext { cfg = X11GLXGraphicsConfiguration.create(glp, x11Screen, val[0]); } - final WrappedSurface ns = new WrappedSurface(cfg, drawable, w, h, null); + final WrappedSurface ns = new WrappedSurface(cfg, drawable, w, h, true); return new X11ExternalGLXContext(new Drawable(factory, ns), ctx); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java index 8652e2d4a..ac78c6f4a 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXDrawable.java @@ -45,7 +45,8 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import com.jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.WrappedSurface; + import com.jogamp.nativewindow.x11.X11GraphicsScreen; @@ -87,7 +88,7 @@ public class X11ExternalGLXDrawable extends X11GLXDrawable { System.err.println("X11ExternalGLXDrawable: WARNING: forcing GLX_RGBA_TYPE for newly created contexts (current 0x"+Integer.toHexString(val[0])+")"); } } - return new X11ExternalGLXDrawable(factory, new WrappedSurface(cfg, drawable, w, h, null)); + return new X11ExternalGLXDrawable(factory, new WrappedSurface(cfg, drawable, w, h, true)); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java index e9912ce9d..8c642777d 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawable.java @@ -69,9 +69,10 @@ public abstract class X11GLXDrawable extends GLDrawableImpl { } @Override - protected final void swapBuffersImpl() { - // single-buffer is already filtered out @ GLDrawableImpl#swapBuffers() - GLX.glXSwapBuffers(getNativeSurface().getDisplayHandle(), getHandle()); + protected final void swapBuffersImpl(boolean doubleBuffered) { + if(doubleBuffered) { + GLX.glXSwapBuffers(getNativeSurface().getDisplayHandle(), getHandle()); + } } //--------------------------------------------------------------------------- diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index bc3e5b793..fb11f8bba 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -49,7 +49,7 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; @@ -59,6 +59,8 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.WrappedSurface; +import jogamp.nativewindow.x11.X11DummyUpstreamSurfaceHook; import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; import jogamp.opengl.DesktopGLDynamicLookupHelper; @@ -70,7 +72,6 @@ import jogamp.opengl.GLGraphicsConfigurationUtil; import jogamp.opengl.SharedResourceRunner; import com.jogamp.common.util.VersionNumber; -import com.jogamp.nativewindow.WrappedSurface; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; @@ -505,7 +506,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { protected final ProxySurface createMutableSurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, - GLCapabilitiesChooser chooser, int width, int height, UpstreamSurfaceHook lifecycleHook) { + GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final X11GraphicsDevice device; if(createNewDevice) { // Null X11 locking, due to private non-shared Display handle @@ -518,65 +519,15 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); } - return new WrappedSurface( config, 0, width, height, lifecycleHook); + return new WrappedSurface(config, 0, upstreamHook, createNewDevice); } @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(requestedCaps); - return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, width, height, dummySurfaceLifecycleHook); + return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new X11DummyUpstreamSurfaceHook(width, height)); } - private static final ProxySurface.UpstreamSurfaceHook dummySurfaceLifecycleHook = new ProxySurface.UpstreamSurfaceHook() { - @Override - public final void create(ProxySurface s) { - if( 0 == s.getSurfaceHandle() ) { - final X11GLXGraphicsConfiguration cfg = (X11GLXGraphicsConfiguration) s.getGraphicsConfiguration(); - final X11GraphicsScreen screen = (X11GraphicsScreen) cfg.getScreen(); - final X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice(); - if(0 == device.getHandle()) { - device.open(); - s.setImplBitfield(ProxySurface.OWN_DEVICE); - } - final long windowHandle = X11Lib.CreateDummyWindow(device.getHandle(), screen.getIndex(), cfg.getXVisualID(), s.getWidth(), s.getHeight()); - if(0 == windowHandle) { - throw new GLException("Creating dummy window failed w/ "+cfg+", "+s.getWidth()+"x"+s.getHeight()); - } - s.setSurfaceHandle(windowHandle); - if(DEBUG) { - System.err.println("X11GLXDrawableFactory.dummySurfaceLifecycleHook.create: "+s); - } - } - } - @Override - public final void destroy(ProxySurface s) { - if(0 != s.getSurfaceHandle()) { - final X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) s.getGraphicsConfiguration(); - final X11GraphicsDevice device = (X11GraphicsDevice) config.getScreen().getDevice(); - X11Lib.DestroyDummyWindow(device.getHandle(), s.getSurfaceHandle()); - s.setSurfaceHandle(0); - if( 0 != ( ProxySurface.OWN_DEVICE & s.getImplBitfield() ) ) { - device.close(); - } - if(DEBUG) { - System.err.println("X11GLXDrawableFactory.dummySurfaceLifecycleHook.destroy: "+s); - } - } - } - @Override - public final int getWidth(ProxySurface s) { - return s.initialWidth; - } - @Override - public final int getHeight(ProxySurface s) { - return s.initialHeight; - } - @Override - public String toString() { - return "X11SurfaceLifecycleHook[]"; - } - }; - @Override protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { @@ -593,7 +544,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { if(DEBUG) { System.err.println("X11GLXDrawableFactory.createProxySurfaceImpl 0x"+Long.toHexString(windowHandle)+": "+cfg); } - return new WrappedSurface(cfg, windowHandle, 0, 0, upstream); + return new WrappedSurface(cfg, windowHandle, upstream, true); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java index 866fcbbe4..96c3c4123 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfiguration.java @@ -307,7 +307,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem return null; // no RGBA -> color index not supported } - X11GLCapabilities res = new X11GLCapabilities(visualInfo, fbcfg, fbcfgid, glp); + final X11GLCapabilities res = new X11GLCapabilities(visualInfo, fbcfg, fbcfgid, glp); if (isMultisampleAvailable) { res.setSampleBuffers(glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLE_BUFFERS, tmp, 0) != 0); res.setNumSamples (glXGetFBConfig(display, fbcfg, GLX.GLX_SAMPLES, tmp, 0)); @@ -342,7 +342,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setPbufferFloatingPointBuffers(glXGetFBConfig(display, fbcfg, GLXExt.GLX_FLOAT_COMPONENTS_NV, tmp, 0) != GL.GL_FALSE); } catch (Exception e) {} - return (X11GLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits); + return (X11GLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } private static String glXGetFBConfigErrorCode(int err) { @@ -462,7 +462,7 @@ public class X11GLXGraphicsConfiguration extends X11GraphicsConfiguration implem res.setAccumBlueBits (glXGetConfig(display, info, GLX.GLX_ACCUM_BLUE_SIZE, tmp, 0)); res.setAccumAlphaBits(glXGetConfig(display, info, GLX.GLX_ACCUM_ALPHA_SIZE, tmp, 0)); - return (X11GLCapabilities) GLGraphicsConfigurationUtil.setWinAttributeBits(res, drawableTypeBits); + return (X11GLCapabilities) GLGraphicsConfigurationUtil.fixWinAttribBitsAndHwAccel(device, drawableTypeBits, res); } private static String glXGetConfigErrorCode(int err) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index 8086cd26a..431706e24 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -129,9 +129,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } final X11GraphicsScreen sharedScreen = (X11GraphicsScreen) sharedResource.getScreen(); final boolean isMultisampleAvailable = factory.isGLXMultisampleAvailable(sharedScreen.getDevice()); - final X11GLXDrawable sharedDrawable = (X11GLXDrawable) sharedResource.getDrawable(); - final GLCapabilitiesImmutable capsChosen = sharedDrawable.getChosenGLCapabilities(); - final GLProfile glp = capsChosen.getGLProfile(); + final GLProfile glp = GLProfile.getDefault(device); List availableCaps = null; @@ -217,7 +215,7 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(x11Device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(x11Device) ); - boolean usePBuffer = capsChosen.isPBuffer(); + boolean usePBuffer = !capsChosen.isOnscreen() && capsChosen.isPBuffer(); X11GLXGraphicsConfiguration res = null; if( factory.isGLXVersionGreaterEqualOneThree(x11Device) ) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java index e1fe2f27e..bba2b3513 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java @@ -81,10 +81,11 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } private void createPbuffer() { - X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration(); - AbstractGraphicsScreen aScreen = config.getScreen(); - AbstractGraphicsDevice aDevice = aScreen.getDevice(); - long display = aDevice.getHandle(); + final MutableSurface ms = (MutableSurface) getNativeSurface(); + final X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) ms.getGraphicsConfiguration(); + final AbstractGraphicsScreen aScreen = config.getScreen(); + final AbstractGraphicsDevice aDevice = aScreen.getDevice(); + final long display = aDevice.getHandle(); if (DEBUG) { System.out.println("Pbuffer config: " + config); @@ -94,8 +95,6 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { throw new GLException("Null display"); } - NativeSurface ns = getNativeSurface(); - GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities(); if (chosenCaps.getPbufferRenderToTexture()) { @@ -111,9 +110,9 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { int[] iattributes = new int[7]; iattributes[niattribs++] = GLX.GLX_PBUFFER_WIDTH; - iattributes[niattribs++] = ns.getWidth(); + iattributes[niattribs++] = ms.getWidth(); iattributes[niattribs++] = GLX.GLX_PBUFFER_HEIGHT; - iattributes[niattribs++] = ns.getHeight(); + iattributes[niattribs++] = ms.getHeight(); iattributes[niattribs++] = GLX.GLX_LARGEST_PBUFFER; // exact iattributes[niattribs++] = 0; iattributes[niattribs++] = 0; @@ -125,7 +124,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable { } // Set up instance variables - ((MutableSurface)ns).setSurfaceHandle(pbuffer); + ms.setSurfaceHandle(pbuffer); if (DEBUG) { System.err.println("Created pbuffer " + this); diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m new file mode 100644 index 000000000..63323b76d --- /dev/null +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -0,0 +1,665 @@ +#import "MacOSXWindowSystemInterface.h" +#import +#import +#include "timespec.h" + +// +// CADisplayLink only available on iOS >= 3.1, sad, since it's convenient. +// Use CVDisplayLink otherwise. +// +// #define HAS_CADisplayLink 1 +// + +// lock/sync debug output +// +// #define DBG_SYNC 1 +// +#ifdef DBG_SYNC + // #define SYNC_PRINT(...) NSLog(@ ## __VA_ARGS__) + #define SYNC_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) +#else + #define SYNC_PRINT(...) +#endif + +// fps debug output +// +// #define DBG_PERF 1 + +@interface MyNSOpenGLLayer: NSOpenGLLayer +{ +@private + GLfloat gl_texCoords[8]; + +@protected + NSOpenGLContext* parentCtx; + NSOpenGLPixelFormat* parentPixelFmt; + volatile NSOpenGLPixelBuffer* pbuffer; + volatile GLuint textureID; + volatile int texWidth; + volatile int texHeight; +#ifdef HAS_CADisplayLink + CADisplayLink* displayLink; +#else + CVDisplayLinkRef displayLink; +#endif + int tc; + struct timespec tStart; +@public + struct timespec lastWaitTime; + GLint swapInterval; + GLint swapIntervalCounter; + pthread_mutex_t renderLock; + pthread_cond_t renderSignal; + volatile Bool shallDraw; + volatile int newTexWidth; + volatile int newTexHeight; +} + +- (id) setupWithContext: (NSOpenGLContext*) parentCtx + pixelFormat: (NSOpenGLPixelFormat*) pfmt + pbuffer: (NSOpenGLPixelBuffer*) p + texIDArg: (GLuint) texID + opaque: (Bool) opaque + texWidth: (int) texWidth + texHeight: (int) texHeight; + +- (Bool) validateTexSizeWithNewSize; +- (Bool) validateTexSize: (int) _texWidth texHeight: (int) _texHeight; +- (void) setTextureID: (int) _texID; + +- (void) validatePBuffer: (NSOpenGLPixelBuffer*) p; + +- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat; +- (void)disableAnimation; +- (void)pauseAnimation:(Bool)pause; +- (void)deallocPBuffer; +- (void)releaseLayer; +- (void)dealloc; +- (void)setSwapInterval:(int)interval; +- (void)tick; +- (void)waitUntilRenderSignal: (long) to_micros; +- (Bool)isGLSourceValid; + +@end + +#ifndef HAS_CADisplayLink + +static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, + const CVTimeStamp *inNow, + const CVTimeStamp *inOutputTime, + CVOptionFlags flagsIn, + CVOptionFlags *flagsOut, + void *displayLinkContext) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*)displayLinkContext; + pthread_mutex_lock(&l->renderLock); + if( 0 < l->swapInterval ) { + l->swapIntervalCounter++; + if( l->swapIntervalCounter >= l->swapInterval ) { + SYNC_PRINT("", (int)l->swapIntervalCounter, l->swapInterval); + l->swapIntervalCounter = 0; + pthread_cond_signal(&l->renderSignal); // wake up vsync + } + } + pthread_mutex_unlock(&l->renderLock); + [pool release]; + return kCVReturnSuccess; +} + +#endif + +static const GLfloat gl_verts[] = { + -1.0, -1.0, + -1.0, 1.0, + 1.0, 1.0, + 1.0, -1.0 +}; + +@implementation MyNSOpenGLLayer + +- (id) setupWithContext: (NSOpenGLContext*) _parentCtx + pixelFormat: (NSOpenGLPixelFormat*) _parentPixelFmt + pbuffer: (NSOpenGLPixelBuffer*) p + texIDArg: (GLuint) texID + opaque: (Bool) opaque + texWidth: (int) _texWidth + texHeight: (int) _texHeight; +{ + pthread_mutexattr_t renderLockAttr; + pthread_mutexattr_init(&renderLockAttr); + pthread_mutexattr_settype(&renderLockAttr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&renderLock, &renderLockAttr); // recursive + pthread_cond_init(&renderSignal, NULL); // no attribute + + { + int i; + for(i=0; i<8; i++) { + gl_texCoords[i] = 0.0f; + } + } + parentCtx = _parentCtx; + parentPixelFmt = _parentPixelFmt; + swapInterval = 1; // defaults to on (as w/ new GL profiles) + swapIntervalCounter = 0; + timespec_now(&lastWaitTime); + shallDraw = NO; + newTexWidth = _texWidth; + newTexHeight = _texHeight; + [self validateTexSizeWithNewSize]; + [self setTextureID: texID]; + + pbuffer = p; + if(NULL != pbuffer) { + [pbuffer retain]; + } + + { + // no animations for add/remove/swap sublayers etc + // doesn't work: [self removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] + [self removeAllAnimations]; + } + + // instantiate a deactivated displayLink +#ifdef HAS_CADisplayLink + displayLink = [[CVDisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)] retain]; +#else + CVReturn cvres; + { + int allDisplaysMask = 0; + int virtualScreen, accelerated, displayMask; + for (virtualScreen = 0; virtualScreen < [parentPixelFmt numberOfVirtualScreens]; virtualScreen++) { + [parentPixelFmt getValues:&displayMask forAttribute:NSOpenGLPFAScreenMask forVirtualScreen:virtualScreen]; + [parentPixelFmt getValues:&accelerated forAttribute:NSOpenGLPFAAccelerated forVirtualScreen:virtualScreen]; + if (accelerated) { + allDisplaysMask |= displayMask; + } + } + cvres = CVDisplayLinkCreateWithOpenGLDisplayMask(allDisplaysMask, &displayLink); + if(kCVReturnSuccess != cvres) { + DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkCreateWithOpenGLDisplayMask %X failed: %d\n", self, allDisplaysMask, cvres); + displayLink = NULL; + } + } + if(NULL != displayLink) { + cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [parentCtx CGLContextObj], [parentPixelFmt CGLPixelFormatObj]); + if(kCVReturnSuccess != cvres) { + DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); + displayLink = NULL; + } + } + if(NULL != displayLink) { + cvres = CVDisplayLinkSetOutputCallback(displayLink, renderMyNSOpenGLLayer, self); + if(kCVReturnSuccess != cvres) { + DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetOutputCallback failed: %d\n", self, cvres); + displayLink = NULL; + } + } +#endif + [self pauseAnimation: YES]; + + [self removeAllAnimations]; + [self setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [self setNeedsDisplayOnBoundsChange: YES]; + + [self setOpaque: opaque ? YES : NO]; + + if(NULL != pbuffer) { + DBG_PRINT("MyNSOpenGLLayer::init (pbuffer) %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, bounds: %lf/%lf %lfx%lf (refcnt %d)\n", + self, parentCtx, parentPixelFmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight, + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); + } else { + DBG_PRINT("MyNSOpenGLLayer::init (texture) %p, ctx %p, pfmt %p, opaque %d, tex[id %d, %dx%d], bounds: %lf/%lf %lfx%lf (refcnt %d)\n", + self, parentCtx, parentPixelFmt, opaque, (int)textureID, texWidth, texHeight, + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); + } + return self; +} + +- (Bool) validateTexSizeWithNewSize +{ + return [self validateTexSize: newTexWidth texHeight: newTexHeight]; +} + +- (Bool) validateTexSize: (int) _texWidth texHeight: (int) _texHeight +{ + if(_texHeight != texHeight || _texWidth != texWidth) { + texWidth = _texWidth; + texHeight = _texHeight; + CGRect lRect = [self bounds]; + lRect.origin.x = 0; + lRect.origin.y = 0; + lRect.size.width = texWidth; + lRect.size.height = texHeight; + [self setFrame: lRect]; + + GLfloat texCoordWidth, texCoordHeight; + if(NULL != pbuffer) { + GLenum textureTarget = [pbuffer textureTarget] ; + GLsizei pwidth = [pbuffer pixelsWide]; + GLsizei pheight = [pbuffer pixelsHigh]; + if( GL_TEXTURE_2D == textureTarget ) { + texCoordWidth = (GLfloat)pwidth /(GLfloat)texWidth ; + texCoordHeight = (GLfloat)pheight/(GLfloat)texHeight ; + } else { + texCoordWidth = pwidth; + texCoordHeight = pheight; + } + } else { + texCoordWidth = (GLfloat)1.0f; + texCoordHeight = (GLfloat)1.0f; + } + gl_texCoords[3] = texCoordHeight; + gl_texCoords[5] = texCoordHeight; + gl_texCoords[4] = texCoordWidth; + gl_texCoords[6] = texCoordWidth; + return YES; + } else { + return NO; + } +} + +- (void) setTextureID: (int) _texID +{ + textureID = _texID; +} + +- (void) validatePBuffer: (NSOpenGLPixelBuffer*) p +{ + if( pbuffer != p ) { + DBG_PRINT("MyNSOpenGLLayer::validatePBuffer.0 %p, pbuffer %p, (refcnt %d)\n", self, p, (int)[self retainCount]); + + SYNC_PRINT("{PB-nil}"); + + [self deallocPBuffer]; + + pbuffer = p; + if(NULL != pbuffer) { + [pbuffer retain]; + } + [self setTextureID: 0]; + + shallDraw = NO; + } +} + +/** +- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask +{ + DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask: %p (refcnt %d) - parent-pfmt %p -> new-pfmt %p\n", + self, (int)[self retainCount], parentPixelFmt, parentPixelFmt); + return parentPixelFmt; +} */ + +- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat +{ + NSOpenGLContext * nctx = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat: %p (refcnt %d) - pfmt %p, parent %p -> new-ctx %p\n", + self, (int)[self retainCount], pixelFormat, parentCtx, nctx); + return nctx; +} + +- (void)disableAnimation +{ + DBG_PRINT("MyNSOpenGLLayer::disableAnimation: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink); + pthread_mutex_lock(&renderLock); + [self setAsynchronous: NO]; + if(NULL != displayLink) { +#ifdef HAS_CADisplayLink + [displayLink setPaused: YES]; + [displayLink release]; +#else + CVDisplayLinkStop(displayLink); + CVDisplayLinkRelease(displayLink); +#endif + displayLink = NULL; + } + pthread_mutex_unlock(&renderLock); +} + +- (void)deallocPBuffer +{ + if(NULL != pbuffer) { + NSOpenGLContext* context = [self openGLContext]; + if(NULL!=context) { + [context makeCurrentContext]; + + DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (with ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)texureID); + + if( 0 != textureID ) { + glDeleteTextures(1, &textureID); + } + [pbuffer release]; + + [context clearDrawable]; + } else { + DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (w/o ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)texureID); + } + pbuffer = NULL; + [self setTextureID: 0]; + } +} + +- (void)releaseLayer +{ + DBG_PRINT("MyNSOpenGLLayer::releaseLayer.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + pthread_mutex_lock(&renderLock); + [self disableAnimation]; + [self deallocPBuffer]; + [self release]; + DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p (refcnt %d)\n", self, (int)[self retainCount]); + pthread_mutex_unlock(&renderLock); +} + +- (void)dealloc +{ + DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]); + + pthread_mutex_lock(&renderLock); + [self disableAnimation]; + [self deallocPBuffer]; + pthread_mutex_unlock(&renderLock); + pthread_cond_destroy(&renderSignal); + pthread_mutex_destroy(&renderLock); + [super dealloc]; + DBG_PRINT("MyNSOpenGLLayer::dealloc.X %p\n", self); +} + +- (Bool)isGLSourceValid +{ + return NULL != pbuffer || 0 != textureID ; +} + +- (void)resizeWithOldSuperlayerSize:(CGSize)size + { + CGRect lRectS = [[self superlayer] bounds]; + + DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d, bounds: %lfx%lf -> %lfx%lf (refcnt %d)\n", + self, texWidth, texHeight, size.width, size.height, lRectS.size.width, lRectS.size.height, (int)[self retainCount]); + + newTexWidth = lRectS.size.width; + newTexHeight = lRectS.size.height; + shallDraw = YES; + SYNC_PRINT("", newTexWidth, newTexHeight); + + [super resizeWithOldSuperlayerSize: size]; +} + +- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat + forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp +{ + SYNC_PRINT("", (int)shallDraw); + return shallDraw; +} + +- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat + forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp +{ + pthread_mutex_unlock(&renderLock); + SYNC_PRINT("<* "); + // NSLog(@"MyNSOpenGLLayer::DRAW: %@",[NSThread callStackSymbols]); + + if( shallDraw && ( NULL != pbuffer || 0 != textureID ) ) { + [context makeCurrentContext]; + + GLenum textureTarget; + + Bool texSizeChanged = [self validateTexSizeWithNewSize]; + + if( NULL != pbuffer ) { + if( texSizeChanged && 0 != textureID ) { + glDeleteTextures(1, &textureID); + [self setTextureID: 0]; + } + textureTarget = [pbuffer textureTarget]; + if( 0 == textureID ) { + glGenTextures(1, &textureID); + glBindTexture(textureTarget, textureID); + glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } else { + glBindTexture(textureTarget, textureID); + } + [context setTextureImageToPixelBuffer: pbuffer colorBuffer: GL_FRONT]; + } else { + textureTarget = GL_TEXTURE_2D; + glBindTexture(textureTarget, textureID); + } + SYNC_PRINT(" %d*>", (int)textureID); + + glEnable(textureTarget); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, gl_verts); + glTexCoordPointer(2, GL_FLOAT, 0, gl_texCoords); + + glDrawArrays(GL_QUADS, 0, 4); + + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + + glDisable(textureTarget); + glBindTexture(textureTarget, 0); + + [context clearDrawable]; + + [super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp]; + + } else { + // glClear(GL_COLOR_BUFFER_BIT); + // glBlitFramebuffer(0, 0, texWidth, texHeight, + // 0, 0, texWidth, texHeight, + // GL_COLOR_BUFFER_BIT, GL_NEAREST); + SYNC_PRINT(" 0*>"); + } + + #ifdef DBG_PERF + [self tick]; + #endif + shallDraw = NO; + + if( 0 >= swapInterval ) { + pthread_cond_signal(&renderSignal); // wake up !vsync + SYNC_PRINT(""); + } + SYNC_PRINT("<$>\n"); + pthread_mutex_unlock(&renderLock); +} + +- (void)pauseAnimation:(Bool)pause +{ + DBG_PRINT("MyNSOpenGLLayer::pauseAnimation: %d\n", (int)pause); + [self setAsynchronous: NO]; + if(pause) { + if(NULL != displayLink) { + #ifdef HAS_CADisplayLink + [displayLink setPaused: YES]; + #else + CVDisplayLinkStop(displayLink); + #endif + } + } else { + if(NULL != displayLink) { + #ifdef HAS_CADisplayLink + [displayLink setPaused: NO]; + [displayLink setFrameInterval: swapInterval]; + #else + CVDisplayLinkStart(displayLink); + #endif + } + } + tc = 0; + timespec_now(&tStart); +} + +- (void)setSwapInterval:(int)interval +{ + /** + * v-sync doesn't works w/ NSOpenGLLayer's context .. well :( + * Using CVDisplayLink .. see setSwapInterval() below. + * + GLint si; + [context getValues: &si forParameter: NSOpenGLCPSwapInterval]; + if(si != swapInterval) { + DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p setSwapInterval: %d -> %d\n", self, si, swapInterval); + [context setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval]; + } + */ + + pthread_mutex_lock(&renderLock); + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0: %d - displayLink %p\n", interval, displayLink); + swapInterval = interval; + swapIntervalCounter = 0; + pthread_mutex_unlock(&renderLock); + + if(0 < swapInterval) { + [self pauseAnimation: NO]; + } else { + [self pauseAnimation: YES]; + } + DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.X: %d\n", interval); +} + +-(void)tick +{ + tc++; + if(tc%60==0) { + struct timespec t1, td; + timespec_now(&t1); + timespec_subtract(&td, &t1, &tStart); + long td_ms = timespec_milliseconds(&td); + fprintf(stderr, "NSOpenGLLayer: %ld ms / %d frames, %ld ms / frame, %f fps\n", + td_ms, tc, td_ms/tc, (tc * 1000.0) / (float)td_ms ); + fflush(NULL); + } +} + +- (void)waitUntilRenderSignal: (long) to_micros +{ + BOOL ready = NO; + int wr = 0; + pthread_mutex_lock(&renderLock); + SYNC_PRINT("{W %ld us", to_micros); + do { + if(0 >= swapInterval) { + ready = YES; + } + if(NO == ready) { + #ifdef DBG_SYNC + struct timespec t0, t1, td, td2; + timespec_now(&t0); + #endif + if(0 < to_micros) { + struct timespec to_abs = lastWaitTime; + timespec_addmicros(&to_abs, to_micros); + #ifdef DBG_SYNC + timespec_subtract(&td, &to_abs, &t0); + fprintf(stderr, ", (%ld) / ", timespec_milliseconds(&td)); + #endif + wr = pthread_cond_timedwait(&renderSignal, &renderLock, &to_abs); + #ifdef DBG_SYNC + timespec_now(&t1); + timespec_subtract(&td, &t1, &t0); + timespec_subtract(&td2, &t1, &lastWaitTime); + fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); + #endif + } else { + pthread_cond_wait (&renderSignal, &renderLock); + #ifdef DBG_SYNC + timespec_now(&t1); + timespec_subtract(&td, &t1, &t0); + timespec_subtract(&td2, &t1, &lastWaitTime); + fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); + #endif + } + ready = YES; + } + } while (NO == ready && 0 == wr) ; + SYNC_PRINT("-%d-%d-%d}", shallDraw, wr, ready); + timespec_now(&lastWaitTime); + pthread_mutex_unlock(&renderLock); +} + +@end + +NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight) { + // This simply crashes after dealloc() has been called .. ie. ref-count -> 0 too early ? + // However using alloc/init, actual dealloc happens at JAWT destruction, hence too later IMHO. + // return [[MyNSOpenGLLayer layer] setupWithContext:ctx pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID + // opaque: opaque texWidth: texWidth texHeight: texHeight]; + + return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID + opaque: opaque texWidth: texWidth texHeight: texHeight]; +} + +void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [l setSwapInterval: interval]; + [pool release]; +} + +void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [l waitUntilRenderSignal: to_micros]; + [pool release]; +} + +void flushNSOpenGLLayerPBuffer(NSOpenGLLayer* layer) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + pthread_mutex_lock(&l->renderLock); + [l validatePBuffer:0]; + pthread_mutex_unlock(&l->renderLock); + + [pool release]; +} + +void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer, NSOpenGLPixelBuffer* p, uint32_t texID, int texWidth, int texHeight) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + Bool shallDraw; + + pthread_mutex_lock(&l->renderLock); + [l validatePBuffer:p]; + // l->newTexWidth = texWidth; + // l->newTexHeight = texHeight; + [l setTextureID: texID]; + shallDraw = [l isGLSourceValid]; + l->shallDraw = shallDraw; + pthread_mutex_unlock(&l->renderLock); + + SYNC_PRINT("", texWidth, texHeight, l->newTexWidth, l->newTexHeight, (int)shallDraw); + if(shallDraw) { + if ( [NSThread isMainThread] == YES ) { + [l setNeedsDisplay]; + } else { + // don't wait - using doublebuffering + [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO]; + } + } + // DBG_PRINT("MyNSOpenGLLayer::setNSOpenGLLayerNeedsDisplay %p\n", l); + [pool release]; +} + +void releaseNSOpenGLLayer(NSOpenGLLayer* layer) { + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.0: %p\n", l); + + if ( [NSThread isMainThread] == YES ) { + [l releaseLayer]; + } else { + [l performSelectorOnMainThread:@selector(releaseLayer) withObject:nil waitUntilDone:NO]; + } + + DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.X: %p\n", l); + [pool release]; +} + diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m deleted file mode 100644 index b81b43e54..000000000 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-pbuffer.m +++ /dev/null @@ -1,494 +0,0 @@ -#import "MacOSXWindowSystemInterface.h" -#import -#import -#include "timespec.h" - -// -// CADisplayLink only available on iOS >= 3.1, sad, since it's convenient. -// Use CVDisplayLink otherwise. -// -// #define HAS_CADisplayLink 1 -// - -// lock/sync debug output -// -// #define DBG_SYNC 1 -// -#ifdef DBG_SYNC - // #define SYNC_PRINT(...) NSLog(@ ## __VA_ARGS__) - #define SYNC_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) -#else - #define SYNC_PRINT(...) -#endif - -// fps debug output -// -// #define DBG_PERF 1 - -@interface MyNSOpenGLLayer: NSOpenGLLayer -{ -@protected - NSOpenGLPixelBuffer* pbuffer; - int texWidth; - int texHeight; - GLuint textureID; -#ifdef HAS_CADisplayLink - CADisplayLink* displayLink; -#else - CVDisplayLinkRef displayLink; -#endif - int tc; - struct timespec t0; -@public - struct timespec lastWaitTime; - GLint swapInterval; - GLint swapIntervalCounter; - pthread_mutex_t renderLock; - pthread_cond_t renderSignal; - BOOL shallDraw; -} - -- (id) setupWithContext: (NSOpenGLContext*) ctx - pixelFormat: (NSOpenGLPixelFormat*) pfmt - pbuffer: (NSOpenGLPixelBuffer*) p - opaque: (Bool) opaque - texWidth: (int) texWidth - texHeight: (int) texHeight; - -- (void)deallocTex; -- (void)disableAnimation; -- (void)releaseLayer; -- (void)dealloc; -- (int)getSwapInterval; -- (void)setSwapInterval:(int)interval; -- (void)tick; - -@end - -#ifndef HAS_CADisplayLink - -static CVReturn renderMyNSOpenGLLayer(CVDisplayLinkRef displayLink, - const CVTimeStamp *inNow, - const CVTimeStamp *inOutputTime, - CVOptionFlags flagsIn, - CVOptionFlags *flagsOut, - void *displayLinkContext) -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*)displayLinkContext; - pthread_mutex_lock(&l->renderLock); - #ifdef DBG_PERF - [l tick]; - #endif - if(0 < l->swapInterval) { - l->swapIntervalCounter++; - if(l->swapIntervalCounter>=l->swapInterval) { - l->swapIntervalCounter = 0; - pthread_cond_signal(&l->renderSignal); - SYNC_PRINT("S"); - } - } - pthread_mutex_unlock(&l->renderLock); - [pool release]; - return kCVReturnSuccess; -} - -#endif - -@implementation MyNSOpenGLLayer - -- (id) setupWithContext: (NSOpenGLContext*) _ctx - pixelFormat: (NSOpenGLPixelFormat*) _fmt - pbuffer: (NSOpenGLPixelBuffer*) p - opaque: (Bool) opaque - texWidth: (int) _texWidth - texHeight: (int) _texHeight; -{ - pthread_mutexattr_t renderLockAttr; - pthread_mutexattr_init(&renderLockAttr); - pthread_mutexattr_settype(&renderLockAttr, PTHREAD_MUTEX_RECURSIVE); - pthread_mutex_init(&renderLock, &renderLockAttr); // recursive - pthread_cond_init(&renderSignal, NULL); // no attribute - - textureID = 0; - swapInterval = 1; // defaults to on (as w/ new GL profiles) - swapIntervalCounter = 0; - timespec_now(&lastWaitTime); - shallDraw = NO; - texWidth = _texWidth; - texHeight = _texHeight; - pbuffer = p; - [pbuffer retain]; - - { - CGRect lRect = CGRectMake(0, 0, texWidth, texHeight); - [self setFrame:lRect]; - - // no animations for add/remove/swap sublayers etc - // doesn't work: [self removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] - [self removeAllAnimations]; - } - - // instantiate a deactivated displayLink -#ifdef HAS_CADisplayLink - displayLink = [[CVDisplayLink displayLinkWithTarget:self selector:@selector(setNeedsDisplay)] retain]; - [displayLink setPaused: YES]; -#else - CVReturn cvres; - { - int allDisplaysMask = 0; - int virtualScreen, accelerated, displayMask; - for (virtualScreen = 0; virtualScreen < [_fmt numberOfVirtualScreens]; virtualScreen++) { - [_fmt getValues:&displayMask forAttribute:NSOpenGLPFAScreenMask forVirtualScreen:virtualScreen]; - [_fmt getValues:&accelerated forAttribute:NSOpenGLPFAAccelerated forVirtualScreen:virtualScreen]; - if (accelerated) { - allDisplaysMask |= displayMask; - } - } - cvres = CVDisplayLinkCreateWithOpenGLDisplayMask(allDisplaysMask, &displayLink); - if(kCVReturnSuccess != cvres) { - DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkCreateWithOpenGLDisplayMask %X failed: %d\n", self, allDisplaysMask, cvres); - displayLink = NULL; - } - } - if(NULL != displayLink) { - cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [_ctx CGLContextObj], [_fmt CGLPixelFormatObj]); - if(kCVReturnSuccess != cvres) { - DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); - displayLink = NULL; - } - } - if(NULL != displayLink) { - cvres = CVDisplayLinkSetOutputCallback(displayLink, renderMyNSOpenGLLayer, self); - if(kCVReturnSuccess != cvres) { - DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetOutputCallback failed: %d\n", self, cvres); - displayLink = NULL; - } - } - if(NULL != displayLink) { - CVDisplayLinkStop(displayLink); - } -#endif - [self setAsynchronous: YES]; - - [self setNeedsDisplayOnBoundsChange: YES]; - - [self setOpaque: opaque ? YES : NO]; - - CGRect lRect = [self frame]; - DBG_PRINT("MyNSOpenGLLayer::init %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, frame: %lf/%lf %lfx%lf (refcnt %d)\n", - self, _ctx, _fmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight, - lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); - return self; -} - -- (void)disableAnimation -{ - DBG_PRINT("MyNSOpenGLLayer::disableAnimation: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink); - pthread_mutex_lock(&renderLock); - [self setAsynchronous: NO]; - if(NULL != displayLink) { -#ifdef HAS_CADisplayLink - [displayLink setPaused: YES]; - [displayLink release]; -#else - CVDisplayLinkStop(displayLink); - CVDisplayLinkRelease(displayLink); -#endif - displayLink = NULL; - } - pthread_mutex_unlock(&renderLock); -} - -- (void)deallocTex -{ - pthread_mutex_lock(&renderLock); - NSOpenGLContext* context = [self openGLContext]; - DBG_PRINT("MyNSOpenGLLayer::deallocTex %p (refcnt %d) - context %p, pbuffer %p\n", self, (int)[self retainCount], context, pbuffer); - if(NULL != pbuffer) { - if(NULL!=context) { - [context makeCurrentContext]; - if(0 != textureID) { - glDeleteTextures(1, &textureID); - textureID = 0; - } - [context clearDrawable]; - } - [pbuffer release]; - pbuffer = NULL; - } - pthread_mutex_unlock(&renderLock); -} - -- (void)releaseLayer -{ - DBG_PRINT("MyNSOpenGLLayer::releaseLayer.0: %p (refcnt %d)\n", self, (int)[self retainCount]); - pthread_mutex_lock(&renderLock); - [self disableAnimation]; - [self deallocTex]; - [self release]; - DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p (refcnt %d)\n", self, (int)[self retainCount]); - pthread_mutex_unlock(&renderLock); -} - -- (void)dealloc -{ - DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); - // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]); - - [self disableAnimation]; - [self deallocTex]; - pthread_cond_destroy(&renderSignal); - pthread_mutex_destroy(&renderLock); - [super dealloc]; - DBG_PRINT("MyNSOpenGLLayer::dealloc.X %p\n", self); -} - -- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat - forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp -{ - // assume both methods 'canDrawInOpenGLContext' and 'drawInOpenGLContext' - // are called from the same thread subsequently - pthread_mutex_lock(&renderLock); - Bool res = NULL != pbuffer && YES == shallDraw; - if(!res) { - SYNC_PRINT("0"); - pthread_mutex_unlock(&renderLock); - } else { - SYNC_PRINT("1"); - } - return res; -} - -- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat - forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp -{ - [context makeCurrentContext]; - - GLenum textureTarget = [pbuffer textureTarget]; - GLfloat texCoordWidth, texCoordHeight; - { - GLsizei pwidth = [pbuffer pixelsWide]; - GLsizei pheight = [pbuffer pixelsHigh]; - texCoordWidth = textureTarget == GL_TEXTURE_2D ? (GLfloat)pwidth /(GLfloat)texWidth : pwidth; - texCoordHeight = textureTarget == GL_TEXTURE_2D ? (GLfloat)pheight/(GLfloat)texHeight : pheight; - } - Bool texCreated = 0 == textureID; - - if(texCreated) { - glGenTextures(1, &textureID); - - CGRect lRect = [self frame]; - DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p, pbuffer %p %dx%d -> tex %dx%d [%fx%f] id 0x%X target 0x%X, frame: %lf/%lf %lfx%lf (refcnt %d)\n", - self, pbuffer, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight, texCoordWidth, texCoordHeight, textureID, textureTarget, - lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); - } - - glBindTexture(textureTarget, textureID); - - /** - if(texCreated) { - // proper tex size setup - glTexImage2D(textureTarget, 0, GL_RGB, texWidth, texHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); - } */ - - [context setTextureImageToPixelBuffer: pbuffer colorBuffer: GL_FRONT]; - - glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(textureTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(textureTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - - glEnable(textureTarget); - - static GLfloat verts[] = { - -1.0, -1.0, - -1.0, 1.0, - 1.0, 1.0, - 1.0, -1.0 - }; - - GLfloat tex[] = { - 0.0, 0.0, - 0.0, texCoordHeight, - texCoordWidth, texCoordHeight, - texCoordWidth, 0.0 - }; - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, verts); - glTexCoordPointer(2, GL_FLOAT, 0, tex); - - glDrawArrays(GL_QUADS, 0, 4); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - - glDisable(textureTarget); - glBindTexture(textureTarget, 0); - - [super drawInOpenGLContext: context pixelFormat: pixelFormat forLayerTime: timeInterval displayTime: timeStamp]; - shallDraw = NO; - if(0 >= swapInterval) { - pthread_cond_signal(&renderSignal); // just to wake up - SYNC_PRINT("s"); - } - SYNC_PRINT("$"); - pthread_mutex_unlock(&renderLock); -} - -- (int)getSwapInterval -{ - return swapInterval; -} - -- (void)setSwapInterval:(int)interval -{ - /** - * v-sync doesn't works w/ NSOpenGLLayer's context .. well :( - * Using CVDisplayLink .. see setSwapInterval() below. - * - GLint si; - [context getValues: &si forParameter: NSOpenGLCPSwapInterval]; - if(si != swapInterval) { - DBG_PRINT("MyNSOpenGLLayer::drawInOpenGLContext %p setSwapInterval: %d -> %d\n", self, si, swapInterval); - [context setValues: &swapInterval forParameter: NSOpenGLCPSwapInterval]; - } - } */ - - pthread_mutex_lock(&renderLock); - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0: %d - displayLink %p\n", interval, displayLink); - swapInterval = interval; - swapIntervalCounter = 0; - pthread_mutex_unlock(&renderLock); - - if(NULL!=displayLink) { - if(0 < swapInterval) { - tc = 0; - timespec_now(&t0); - - [self setAsynchronous: NO]; - #ifdef HAS_CADisplayLink - [displayLink setPaused: NO]; - [displayLink setFrameInterval: interval]; - #else - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.1.b.1\n"); - CVDisplayLinkStart(displayLink); - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.1.b.X\n"); - #endif - } else { - #ifdef HAS_CADisplayLink - [displayLink setPaused: YES]; - #else - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0.b.1\n"); - CVDisplayLinkStop(displayLink); - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.0.b.X\n"); - #endif - [self setAsynchronous: YES]; - } - } - DBG_PRINT("MyNSOpenGLLayer::setSwapInterval.X: %d\n", interval); -} - --(void)tick -{ - tc++; - if(tc%60==0) { - struct timespec t1, td; - timespec_now(&t1); - timespec_subtract(&td, &t1, &t0); - long td_ms = timespec_milliseconds(&td); - fprintf(stderr, "NSOpenGLLayer: %ld ms / %d frames, %ld ms / frame, %f fps\n", - td_ms, tc, td_ms/tc, (tc * 1000.0) / (float)td_ms ); - fflush(NULL); - } -} - -@end - -NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, Bool opaque, int texWidth, int texHeight) { - // This simply crashes after dealloc() has been called .. ie. ref-count -> 0 too early ? - // However using alloc/init, actual dealloc happens at JAWT destruction, hence too later IMHO. - // return [[MyNSOpenGLLayer layer] setupWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque texWidth: texWidth texHeight: texHeight]; - - return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx pixelFormat: fmt pbuffer: p opaque: opaque texWidth: texWidth texHeight: texHeight]; -} - -void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; - [l setSwapInterval: interval]; -} - -void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; - BOOL ready = NO; - int wr = 0; - pthread_mutex_lock(&l->renderLock); - SYNC_PRINT("{"); - do { - if([l getSwapInterval] <= 0) { - ready = !l->shallDraw; - } - if(NO == ready) { - if(0 < to_micros) { - #ifdef DBG_SYNC - struct timespec t0, t1, td, td2; - timespec_now(&t0); - #endif - struct timespec to_abs = l->lastWaitTime; - timespec_addmicros(&to_abs, to_micros); - #ifdef DBG_SYNC - timespec_subtract(&td, &to_abs, &t0); - fprintf(stderr, "(%ld) / ", timespec_milliseconds(&td)); - #endif - wr = pthread_cond_timedwait(&l->renderSignal, &l->renderLock, &to_abs); - #ifdef DBG_SYNC - timespec_now(&t1); - timespec_subtract(&td, &t1, &t0); - timespec_subtract(&td2, &t1, &l->lastWaitTime); - fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); - #endif - } else { - pthread_cond_wait (&l->renderSignal, &l->renderLock); - } - ready = !l->shallDraw; - } - } while (NO == ready && 0 == wr) ; - SYNC_PRINT("-%d}", ready); - timespec_now(&l->lastWaitTime); - pthread_mutex_unlock(&l->renderLock); -} - -void setNSOpenGLLayerNeedsDisplay(NSOpenGLLayer* layer) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - pthread_mutex_lock(&l->renderLock); - l->shallDraw = YES; - if ( [NSThread isMainThread] == YES ) { - [l setNeedsDisplay]; - } else { - // can't wait, otherwise we may deadlock AWT - [l performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:NO]; - } - SYNC_PRINT("."); - pthread_mutex_unlock(&l->renderLock); - // DBG_PRINT("MyNSOpenGLLayer::setNSOpenGLLayerNeedsDisplay %p\n", l); - [pool release]; -} - -void releaseNSOpenGLLayer(NSOpenGLLayer* layer) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.0: %p\n", l); - - if ( [NSThread isMainThread] == YES ) { - [l releaseLayer]; - } else { - [l performSelectorOnMainThread:@selector(releaseLayer) withObject:nil waitUntilDone:NO]; - } - - DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.X: %p\n", l); - [pool release]; -} - diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index f774f8f4a..becd41bb2 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -696,6 +696,11 @@ void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* [pool release]; } +Bool isNSOpenGLPixelBuffer(uint64_t object) { + NSObject *nsObj = (NSObject*) (intptr_t) object; + return [nsObj isMemberOfClass:[NSOpenGLPixelBuffer class]]; +} + #include Bool imagesInitialized = false; static char libGLStr[] = "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib"; @@ -746,38 +751,3 @@ void resetGammaRamp() { CGDisplayRestoreColorSyncSettings(); } -/*** - * The following static functions are copied out of NEWT's OSX impl. - * May need to push code to NativeWindow, to remove duplication. - */ -static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx) { - NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; - return (NSScreen *) [screens objectAtIndex: screen_idx]; -} -static CGDirectDisplayID NewtScreen_getCGDirectDisplayIDByNSScreen(NSScreen *screen) { - // Mind: typedef uint32_t CGDirectDisplayID; - however, we assume it's 64bit on 64bit ?! - NSDictionary * dict = [screen deviceDescription]; - NSNumber * val = (NSNumber *) [dict objectForKey: @"NSScreenNumber"]; - // [NSNumber integerValue] returns NSInteger which is 32 or 64 bit native size - return (CGDirectDisplayID) [val integerValue]; -} -static long GetDictionaryLong(CFDictionaryRef theDict, const void* key) -{ - long value = 0; - CFNumberRef numRef; - numRef = (CFNumberRef)CFDictionaryGetValue(theDict, key); - if (numRef != NULL) - CFNumberGetValue(numRef, kCFNumberLongType, &value); - return value; -} -#define CGDDGetModeRefreshRate(mode) GetDictionaryLong((mode), kCGDisplayRefreshRate) - -int getScreenRefreshRate(int scrn_idx) { - NSScreen *screen = NewtScreen_getNSScreenByIndex(scrn_idx); - CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); - CFDictionaryRef mode = CGDisplayCurrentMode(display); - return CGDDGetModeRefreshRate(mode); -} - diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java new file mode 100644 index 000000000..22c95f3dd --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookMutableSize.java @@ -0,0 +1,39 @@ +package com.jogamp.nativewindow; + +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +public class DelegatedUpstreamSurfaceHookMutableSize extends UpstreamSurfaceHookMutableSize { + final UpstreamSurfaceHook upstream; + + /** + * @param upstream optional upstream UpstreamSurfaceHook used for {@link #create(ProxySurface)} and {@link #destroy(ProxySurface)}. + * @param width initial width + * @param height initial height + */ + public DelegatedUpstreamSurfaceHookMutableSize(UpstreamSurfaceHook upstream, int width, int height) { + super(width, height); + this.upstream = upstream; + } + + @Override + public final void create(ProxySurface s) { + if(null != upstream) { + upstream.create(s); + } + } + + @Override + public final void destroy(ProxySurface s) { + if(null != upstream) { + upstream.destroy(s); + } + } + + @Override + public String toString() { + return getClass().getSimpleName()+"[ "+ width + "x" + height + ", " + upstream + "]"; + } + +} + diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java new file mode 100644 index 000000000..85e24582c --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/DelegatedUpstreamSurfaceHookWithSurfaceSize.java @@ -0,0 +1,54 @@ +package com.jogamp.nativewindow; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +public class DelegatedUpstreamSurfaceHookWithSurfaceSize implements UpstreamSurfaceHook { + final UpstreamSurfaceHook upstream; + final NativeSurface surface; + + /** + * @param upstream optional upstream UpstreamSurfaceHook used for {@link #create(ProxySurface)} and {@link #destroy(ProxySurface)}. + * @param surface mandatory {@link NativeSurface} used for {@link #getWidth(ProxySurface)} and {@link #getHeight(ProxySurface)} + */ + public DelegatedUpstreamSurfaceHookWithSurfaceSize(UpstreamSurfaceHook upstream, NativeSurface surface) { + this.upstream = upstream; + this.surface = surface; + if(null == surface) { + throw new IllegalArgumentException("given surface is null"); + } + } + + @Override + public final void create(ProxySurface s) { + if(null != upstream) { + upstream.create(s); + } + } + + @Override + public final void destroy(ProxySurface s) { + if(null != upstream) { + upstream.destroy(s); + } + } + + @Override + public final int getWidth(ProxySurface s) { + return surface.getWidth(); + } + + @Override + public final int getHeight(ProxySurface s) { + return surface.getHeight(); + } + + @Override + public String toString() { + final String us_s = null != surface ? ( surface.getClass().getName() + ": 0x" + Long.toHexString(surface.getSurfaceHandle()) + " " +surface.getWidth() + "x" + surface.getHeight() ) : "nil"; + return getClass().getSimpleName()+"["+upstream+", "+us_s+"]"; + } + +} + diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java new file mode 100644 index 000000000..29c540ac4 --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/UpstreamSurfaceHookMutableSize.java @@ -0,0 +1,45 @@ +package com.jogamp.nativewindow; + +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +public class UpstreamSurfaceHookMutableSize implements UpstreamSurfaceHook.MutableSize { + int width, height; + + /** + * @param width initial width + * @param height initial height + */ + public UpstreamSurfaceHookMutableSize(int width, int height) { + this.width = width; + this.height = height; + } + + @Override + public final void setSize(int width, int height) { + this.width = width; + this.height = height; + } + + @Override + public final int getWidth(ProxySurface s) { + return width; + } + + @Override + public final int getHeight(ProxySurface s) { + return height; + } + @Override + public void create(ProxySurface s) { /* nop */ } + + @Override + public void destroy(ProxySurface s) { /* nop */ } + + @Override + public String toString() { + return getClass().getSimpleName()+"[ "+ width + "x" + height + "]"; + } + +} + diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java deleted file mode 100644 index b7f6ba45d..000000000 --- a/src/nativewindow/classes/com/jogamp/nativewindow/WrappedSurface.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.nativewindow; - -import javax.media.nativewindow.AbstractGraphicsConfiguration; -import javax.media.nativewindow.ProxySurface; - -public class WrappedSurface extends ProxySurface { - protected long surfaceHandle; - - public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { - super(cfg, initialWidth, initialHeight, upstream); - surfaceHandle=handle; - } - - @Override - protected void invalidateImpl() { - surfaceHandle = 0; - } - - @Override - public final long getSurfaceHandle() { - return surfaceHandle; - } - - @Override - public final void setSurfaceHandle(long surfaceHandle) { - this.surfaceHandle=surfaceHandle; - } - - @Override - protected final int lockSurfaceImpl() { - return LOCK_SUCCESS; - } - - @Override - protected final void unlockSurfaceImpl() { - } - - @Override - public String toString() { - final UpstreamSurfaceHook ush = getUpstreamSurfaceHook(); - final String ush_s = null != ush ? ( ush.getClass().getName() + ": " + ush ) : "nil"; - - return "WrappedSurface[config " + getPrivateGraphicsConfiguration()+ - ", displayHandle 0x" + Long.toHexString(getDisplayHandle()) + - ", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle()) + - ", size " + getWidth() + "x" + getHeight() + - ", surfaceLock "+surfaceLock+ - ", upstreamSurfaceHook "+ush_s+"]"; - } -} diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index d4b927cf1..a62d08ccf 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -39,12 +39,14 @@ package com.jogamp.nativewindow.awt; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.nativewindow.MutableGraphicsConfiguration; import java.awt.Component; import java.awt.Container; import java.applet.Applet; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; @@ -110,21 +112,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, this.offscreenSurfaceLayer = 0; } - @Override - public void setShallUseOffscreenLayer(boolean v) { - shallUseOffscreenLayer = v; - } - - @Override - public final boolean getShallUseOffscreenLayer() { - return shallUseOffscreenLayer; - } - - @Override - public final boolean isOffscreenLayerSurfaceEnabled() { - return isOffscreenLayerSurface; - } - protected synchronized void invalidate() { invalidateNative(); jawt = null; @@ -136,26 +123,29 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void invalidateNative(); - protected final void updateBounds(JAWT_Rectangle jawtBounds) { - if(DEBUG) { - final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); - if(!bounds.equals(jb)) { + protected final boolean updateBounds(JAWT_Rectangle jawtBounds) { + final Rectangle jb = new Rectangle(jawtBounds.getX(), jawtBounds.getY(), jawtBounds.getWidth(), jawtBounds.getHeight()); + final boolean changed = !bounds.equals(jb); + + if(changed) { + if(DEBUG) { System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); Thread.dumpStack(); } + bounds.setX(jawtBounds.getX()); + bounds.setY(jawtBounds.getY()); + bounds.setWidth(jawtBounds.getWidth()); + bounds.setHeight(jawtBounds.getHeight()); + + if(component instanceof Container) { + java.awt.Insets contInsets = ((Container)component).getInsets(); + insets.setLeftWidth(contInsets.left); + insets.setRightWidth(contInsets.right); + insets.setTopHeight(contInsets.top); + insets.setBottomHeight(contInsets.bottom); + } } - bounds.setX(jawtBounds.getX()); - bounds.setY(jawtBounds.getY()); - bounds.setWidth(jawtBounds.getWidth()); - bounds.setHeight(jawtBounds.getHeight()); - - if(component instanceof Container) { - java.awt.Insets contInsets = ((Container)component).getInsets(); - insets.setLeftWidth(contInsets.left); - insets.setRightWidth(contInsets.right); - insets.setTopHeight(contInsets.top); - insets.setBottomHeight(contInsets.bottom); - } + return changed; } /** @return the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock */ @@ -181,9 +171,29 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return jawt; } - /** - * {@inheritDoc} - */ + // + // OffscreenLayerOption + // + + @Override + public void setShallUseOffscreenLayer(boolean v) { + shallUseOffscreenLayer = v; + } + + @Override + public final boolean getShallUseOffscreenLayer() { + return shallUseOffscreenLayer; + } + + @Override + public final boolean isOffscreenLayerSurfaceEnabled() { + return isOffscreenLayerSurface; + } + + // + // OffscreenLayerSurface + // + @Override public final void attachSurfaceLayer(final long layerHandle) throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { @@ -205,9 +215,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void attachSurfaceLayerImpl(final long layerHandle); - /** - * {@inheritDoc} - */ @Override public final void detachSurfaceLayer() throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { @@ -232,11 +239,21 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void detachSurfaceLayerImpl(final long layerHandle); + protected final long getAttachedSurfaceLayer() { + return offscreenSurfaceLayer; + } + @Override public final boolean isSurfaceLayerAttached() { return 0 != offscreenSurfaceLayer; } + @Override + public final void setChosenCapabilities(CapabilitiesImmutable caps) { + ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps); + getPrivateGraphicsConfiguration().setChosenCapabilities(caps); + } + // // SurfaceUpdateListener // @@ -381,7 +398,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); } - + @Override public final long getDisplayHandle() { return getGraphicsConfiguration().getScreen().getDevice().getHandle(); @@ -393,13 +410,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public int getWidth() { + public final int getWidth() { return component.getWidth(); } @Override - public int getHeight() { - return component.getHeight(); + public final int getHeight() { + return component.getHeight(); } // diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java index 40042ec81..b824350ff 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java @@ -67,8 +67,8 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl * Note that this is not an open connection, ie no native display handle exist. * This constructor exist to setup a default device connection/unit.
    */ - public EGLGraphicsDevice(String connection, int unitID) { - super(NativeWindowFactory.TYPE_EGL, connection, unitID); + public EGLGraphicsDevice() { + super(NativeWindowFactory.TYPE_EGL, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); this.nativeDisplayID[0] = 0 ; // EGL.EGL_DEFAULT_DISPLAY this.eglLifecycleCallback = null; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java index cec7d4ec3..27462ae70 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java @@ -124,8 +124,11 @@ public interface NativeSurface extends SurfaceUpdatedListener { /** * Provide a mechanism to utilize custom (pre-) swap surface * code. This method is called before the render toolkit (e.g. JOGL) - * swaps the buffer/surface. The implementation may itself apply the swapping, + * swaps the buffer/surface if double buffering is enabled. + *

    + * The implementation may itself apply the swapping, * in which case true shall be returned. + *

    * * @return true if this method completed swapping the surface, * otherwise false, in which case eg the GLDrawable diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index f7dbc6c27..f9800109c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -50,4 +50,7 @@ public interface OffscreenLayerSurface { /** Returns true if a surface layer is attached, otherwise false. */ public boolean isSurfaceLayerAttached(); + /** Sets the capabilities of this instance, allowing upstream API's to refine it, i.e. OpenGL related settings. */ + public void setChosenCapabilities(CapabilitiesImmutable caps); + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java index 7fc9789c2..395fdc818 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ProxySurface.java @@ -1,5 +1,5 @@ /** - * Copyright 2010 JogAmp Community. All rights reserved. + * Copyright 2012 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: @@ -29,242 +29,82 @@ package javax.media.nativewindow; import jogamp.nativewindow.Debug; -import jogamp.nativewindow.SurfaceUpdatedHelper; -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; - -public abstract class ProxySurface implements NativeSurface, MutableSurface { +/** + * Provides a mutable {@link NativeSurface}, i.e. {@link MutableSurface}, while allowing an + * {@link UpstreamSurfaceHook} to influence the lifecycle and information. + * + * @see UpstreamSurfaceHook + * @see MutableSurface + * @see NativeSurface + */ +public interface ProxySurface extends MutableSurface { public static final boolean DEBUG = Debug.debug("ProxySurface"); /** - * Implementation specific bitvalue stating the upstream's {@link AbstractGraphicsDevice} is owned by this {@link ProxySurface}. - * @see #setImplBitfield(int) - * @see #getImplBitfield() + * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's surface handle + * @see #addUpstreamOptionBits(int) + * @see #getUpstreamOptionBits() */ - public static final int OWN_DEVICE = 1 << 7; + public static final int OPT_PROXY_OWNS_UPSTREAM_SURFACE = 1 << 6; + + /** + * Implementation specific bit-value stating this {@link ProxySurface} owns the upstream's {@link AbstractGraphicsDevice}. + * @see #addUpstreamOptionBits(int) + * @see #getUpstreamOptionBits() + */ + public static final int OPT_PROXY_OWNS_UPSTREAM_DEVICE = 1 << 7; /** * Implementation specific bitvalue stating the upstream's {@link NativeSurface} is an invisible window, i.e. maybe incomplete. - * @see #setImplBitfield(int) - * @see #getImplBitfield() + * @see #addUpstreamOptionBits(int) + * @see #getUpstreamOptionBits() */ - public static final int INVISIBLE_WINDOW = 1 << 8; + public static final int OPT_UPSTREAM_WINDOW_INVISIBLE = 1 << 8; - /** Interface allowing upstream caller to pass lifecycle actions and size info to a {@link ProxySurface} instance. */ - public interface UpstreamSurfaceHook { - /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */ - public void create(ProxySurface s); - /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */ - public void destroy(ProxySurface s); + /** Allow redefining the AbstractGraphicsConfiguration */ + public void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg); - /** Returns the width of the upstream surface */ - public int getWidth(ProxySurface s); - /** Returns the height of the upstream surface */ - public int getHeight(ProxySurface s); - } + /** Returns the set {@link UpstreamSurfaceHook}, or null if not set. */ + public UpstreamSurfaceHook getUpstreamSurfaceHook(); - private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); - private final AbstractGraphicsConfiguration config; // control access due to delegation - private final UpstreamSurfaceHook upstream; - public final int initialWidth; - public final int initialHeight; - private long surfaceHandle_old; - protected RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); - protected long displayHandle; - protected int scrnIndex; - protected int implBitfield; - /** - * @param cfg the {@link AbstractGraphicsConfiguration} to be used - * @param initialWidth the initial width - * @param initialHeight the initial height + * Sets the {@link UpstreamSurfaceHook} and returns the previous value. */ - protected ProxySurface(AbstractGraphicsConfiguration cfg, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { - if(null == cfg) { - throw new IllegalArgumentException("null config"); - } - this.config = cfg; - this.upstream = upstream; - this.initialWidth = initialWidth; - this.initialHeight = initialHeight; - this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); - this.surfaceHandle_old = 0; - this.implBitfield = 0; - } - - public final UpstreamSurfaceHook getUpstreamSurfaceHook() { return upstream; } + public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook); + + /** + * Enables or disables the {@link UpstreamSurfaceHook} lifecycle functions + * {@link UpstreamSurfaceHook#create(ProxySurface)} and {@link UpstreamSurfaceHook#destroy(ProxySurface)}. + *

    + * Use this for small code blocks where the native resources shall not change, + * i.e. resizing a derived (OpenGL) drawable. + *

    + */ + public void enableUpstreamSurfaceHookLifecycle(boolean enable); /** - * If a valid {@link UpstreamSurfaceHook} instance is passed in the - * {@link ProxySurface#ProxySurface(AbstractGraphicsConfiguration, int, int, UpstreamSurfaceHook) constructor}, * {@link UpstreamSurfaceHook#create(ProxySurface)} is being issued and the proxy surface/window handles shall be set. */ - public void createNotify() { - if(null != upstream) { - upstream.create(this); - } - this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); - this.surfaceHandle_old = 0; - } + public void createNotify(); /** - * If a valid {@link UpstreamSurfaceHook} instance is passed in the - * {@link ProxySurface#ProxySurface(AbstractGraphicsConfiguration, int, int, UpstreamSurfaceHook) constructor}, - * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all fields are cleared. + * {@link UpstreamSurfaceHook#destroy(ProxySurface)} is being issued and all proxy surface/window handles shall be cleared. */ - public void destroyNotify() { - if(null != upstream) { - upstream.destroy(this); - invalidateImpl(); - } - this.displayHandle = 0; - this.surfaceHandle_old = 0; - } + public void destroyNotify(); - /** - * Must be overridden by implementations allowing having a {@link UpstreamSurfaceHook} being passed. - * @see #destroyNotify() - */ - protected void invalidateImpl() { - throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); - } + public StringBuilder getUpstreamOptionBits(StringBuilder sink); + public int getUpstreamOptionBits(); - @Override - public final long getDisplayHandle() { - return displayHandle; - } - - protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { - return config; - } - - @Override - public final AbstractGraphicsConfiguration getGraphicsConfiguration() { - return config.getNativeGraphicsConfiguration(); - } - - @Override - public final int getScreenIndex() { - return getGraphicsConfiguration().getScreen().getIndex(); - } - - @Override - public abstract long getSurfaceHandle(); - - @Override - public abstract void setSurfaceHandle(long surfaceHandle); + /** Returns true if the give bit-mask v is set in this instance upstream-option-bits, otherwise false.*/ + public boolean containsUpstreamOptionBits(int v); - @Override - public final int getWidth() { - if(null != upstream) { - return upstream.getWidth(this); - } - return initialWidth; - } - - @Override - public final int getHeight() { - if(null != upstream) { - return upstream.getHeight(this); - } - return initialHeight; - } - - @Override - public boolean surfaceSwap() { - return false; - } - - @Override - public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { - surfaceUpdatedHelper.addSurfaceUpdatedListener(l); - } - - @Override - public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { - surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); - } - - @Override - public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { - surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); - } - - @Override - public void surfaceUpdated(Object updater, NativeSurface ns, long when) { - surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); - } - - @Override - public int lockSurface() throws NativeWindowException, RuntimeException { - surfaceLock.lock(); - int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? - - if ( LOCK_SURFACE_NOT_READY == res ) { - try { - final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); - adevice.lock(); - try { - res = lockSurfaceImpl(); - if(LOCK_SUCCESS == res && surfaceHandle_old != getSurfaceHandle()) { - res = LOCK_SURFACE_CHANGED; - if(DEBUG) { - System.err.println("ProxySurface: surface change 0x"+Long.toHexString(surfaceHandle_old)+" -> 0x"+Long.toHexString(getSurfaceHandle())); - // Thread.dumpStack(); - } - } - } finally { - if (LOCK_SURFACE_NOT_READY >= res) { - adevice.unlock(); - } - } - } finally { - if (LOCK_SURFACE_NOT_READY >= res) { - surfaceLock.unlock(); - } - } - } - return res; - } - - @Override - public final void unlockSurface() { - surfaceLock.validateLocked(); - surfaceHandle_old = getSurfaceHandle(); - - if (surfaceLock.getHoldCount() == 1) { - final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); - try { - unlockSurfaceImpl(); - } finally { - adevice.unlock(); - } - } - surfaceLock.unlock(); - } - - protected abstract int lockSurfaceImpl(); - - protected abstract void unlockSurfaceImpl() ; - - public final void validateSurfaceLocked() { - surfaceLock.validateLocked(); - } - - @Override - public final boolean isSurfaceLockedByOtherThread() { - return surfaceLock.isLockedByOtherThread(); - } - - @Override - public final Thread getSurfaceLockOwner() { - return surfaceLock.getOwner(); - } + /** Add the given bit-mask to this instance upstream-option-bits using bit-or w/ v.*/ + public void addUpstreamOptionBits(int v); - @Override - public abstract String toString(); + /** Clear the given bit-mask from this instance upstream-option-bits using bit-and w/ ~v*/ + public void clearUpstreamOptionBits(int v); - public int getImplBitfield() { return implBitfield; } - public void setImplBitfield(int v) { implBitfield=v; } + public StringBuilder toString(StringBuilder sink); + public String toString(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java b/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java new file mode 100644 index 000000000..6fe2e5364 --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/UpstreamSurfaceHook.java @@ -0,0 +1,52 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.nativewindow; + +/** + * Interface allowing upstream caller to pass lifecycle actions and size info + * to a {@link ProxySurface} instance. + */ +public interface UpstreamSurfaceHook { + /** called within {@link ProxySurface#createNotify()} within lock, before using surface. */ + public void create(ProxySurface s); + /** called within {@link ProxySurface#destroyNotify()} within lock, before clearing fields. */ + public void destroy(ProxySurface s); + + /** Returns the width of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ + public int getWidth(ProxySurface s); + /** Returns the height of the upstream surface, used if {@link ProxySurface#UPSTREAM_PROVIDES_SIZE} is set. */ + public int getHeight(ProxySurface s); + + /** + * {@link UpstreamSurfaceHook} w/ mutable size, allowing it's {@link ProxySurface} user to resize. + */ + public interface MutableSize extends UpstreamSurfaceHook { + public void setSize(int width, int height); + } +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java new file mode 100644 index 000000000..63f56cbae --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/ProxySurfaceImpl.java @@ -0,0 +1,326 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.nativewindow; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.SurfaceUpdatedListener; +import javax.media.nativewindow.UpstreamSurfaceHook; + + +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + +public abstract class ProxySurfaceImpl implements ProxySurface { + private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); + protected long displayHandle; // convenient ref of config.screen.device.handle + private AbstractGraphicsConfiguration config; // control access due to delegation + private UpstreamSurfaceHook upstream; + private long surfaceHandle_old; + private RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); + private int implBitfield; + private boolean upstreamSurfaceHookLifecycleEnabled; + + /** + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param upstream the {@link UpstreamSurfaceHook} to be used + * @param ownsDevice true if this {@link ProxySurface} instance + * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, + * otherwise false. Owning the device implies closing it at {@link #destroyNotify()}. + */ + protected ProxySurfaceImpl(AbstractGraphicsConfiguration cfg, UpstreamSurfaceHook upstream, boolean ownsDevice) { + if(null == cfg) { + throw new IllegalArgumentException("null AbstractGraphicsConfiguration"); + } + if(null == upstream) { + throw new IllegalArgumentException("null UpstreamSurfaceHook"); + } + this.config = cfg; + this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); + this.upstream = upstream; + this.surfaceHandle_old = 0; + this.implBitfield = 0; + this.upstreamSurfaceHookLifecycleEnabled = true; + if(ownsDevice) { + addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + } + + @Override + public final UpstreamSurfaceHook getUpstreamSurfaceHook() { return upstream; } + + @Override + public void setUpstreamSurfaceHook(UpstreamSurfaceHook hook) { + if(null == hook) { + throw new IllegalArgumentException("null UpstreamSurfaceHook"); + } + upstream = hook; + } + + @Override + public final void enableUpstreamSurfaceHookLifecycle(boolean enable) { + upstreamSurfaceHookLifecycleEnabled = enable; + } + + @Override + public void createNotify() { + if(upstreamSurfaceHookLifecycleEnabled) { + upstream.create(this); + } + this.displayHandle=config.getNativeGraphicsConfiguration().getScreen().getDevice().getHandle(); + this.surfaceHandle_old = 0; + } + + @Override + public void destroyNotify() { + if(upstreamSurfaceHookLifecycleEnabled) { + upstream.destroy(this); + if( containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ) ) { + final AbstractGraphicsDevice aDevice = getGraphicsConfiguration().getScreen().getDevice(); + aDevice.close(); + clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + invalidateImpl(); + } + this.displayHandle = 0; + this.surfaceHandle_old = 0; + } + + /** + * Must be overridden by implementations allowing having a {@link UpstreamSurfaceHook} being passed. + * @see #destroyNotify() + */ + protected void invalidateImpl() { + throw new InternalError("UpstreamSurfaceHook given, but required method not implemented."); + } + + @Override + public final long getDisplayHandle() { + return displayHandle; + } + + protected final AbstractGraphicsConfiguration getPrivateGraphicsConfiguration() { + return config; + } + + @Override + public final AbstractGraphicsConfiguration getGraphicsConfiguration() { + return config.getNativeGraphicsConfiguration(); + } + + @Override + public final void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg) { + config = cfg; + } + + @Override + public final int getScreenIndex() { + return getGraphicsConfiguration().getScreen().getIndex(); + } + + @Override + public abstract long getSurfaceHandle(); + + @Override + public abstract void setSurfaceHandle(long surfaceHandle); + + @Override + public final int getWidth() { + return upstream.getWidth(this); + } + + @Override + public final int getHeight() { + return upstream.getHeight(this); + } + + @Override + public boolean surfaceSwap() { + return false; + } + + @Override + public void addSurfaceUpdatedListener(SurfaceUpdatedListener l) { + surfaceUpdatedHelper.addSurfaceUpdatedListener(l); + } + + @Override + public void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsException { + surfaceUpdatedHelper.addSurfaceUpdatedListener(index, l); + } + + @Override + public void removeSurfaceUpdatedListener(SurfaceUpdatedListener l) { + surfaceUpdatedHelper.removeSurfaceUpdatedListener(l); + } + + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + surfaceUpdatedHelper.surfaceUpdated(updater, ns, when); + } + + @Override + public int lockSurface() throws NativeWindowException, RuntimeException { + surfaceLock.lock(); + int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? + + if ( LOCK_SURFACE_NOT_READY == res ) { + try { + final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); + adevice.lock(); + try { + res = lockSurfaceImpl(); + if(LOCK_SUCCESS == res && surfaceHandle_old != getSurfaceHandle()) { + res = LOCK_SURFACE_CHANGED; + if(DEBUG) { + System.err.println("ProxySurfaceImpl: surface change 0x"+Long.toHexString(surfaceHandle_old)+" -> 0x"+Long.toHexString(getSurfaceHandle())); + // Thread.dumpStack(); + } + } + } finally { + if (LOCK_SURFACE_NOT_READY >= res) { + adevice.unlock(); + } + } + } finally { + if (LOCK_SURFACE_NOT_READY >= res) { + surfaceLock.unlock(); + } + } + } + return res; + } + + @Override + public final void unlockSurface() { + surfaceLock.validateLocked(); + surfaceHandle_old = getSurfaceHandle(); + + if (surfaceLock.getHoldCount() == 1) { + final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); + try { + unlockSurfaceImpl(); + } finally { + adevice.unlock(); + } + } + surfaceLock.unlock(); + } + + protected abstract int lockSurfaceImpl(); + + protected abstract void unlockSurfaceImpl() ; + + public final void validateSurfaceLocked() { + surfaceLock.validateLocked(); + } + + @Override + public final boolean isSurfaceLockedByOtherThread() { + return surfaceLock.isLockedByOtherThread(); + } + + @Override + public final Thread getSurfaceLockOwner() { + return surfaceLock.getOwner(); + } + + public final StringBuilder getUpstreamOptionBits(StringBuilder sink) { + if(null == sink) { + sink = new StringBuilder(); + } + sink.append("UOB[ "); + if(0 == implBitfield) { + sink.append("]"); + return sink; + } + boolean needsOr = false; + if( 0 != ( implBitfield & OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + sink.append("OWNS_SURFACE"); + needsOr = true; + } + if( 0 != ( implBitfield & OPT_PROXY_OWNS_UPSTREAM_DEVICE ) ) { + if(needsOr) { + sink.append(" | "); + } + sink.append("OWNS_DEVICE"); + needsOr = true; + } + if( 0 != ( implBitfield & OPT_UPSTREAM_WINDOW_INVISIBLE ) ) { + if(needsOr) { + sink.append(" | "); + } + sink.append("WINDOW_INVISIBLE"); + needsOr = true; + } + sink.append(" ]"); + return sink; + } + + @Override + public final int getUpstreamOptionBits() { return implBitfield; } + + @Override + public final boolean containsUpstreamOptionBits(int v) { + return v == ( implBitfield & v ) ; + } + + @Override + public final void addUpstreamOptionBits(int v) { implBitfield |= v; } + + @Override + public final void clearUpstreamOptionBits(int v) { implBitfield &= ~v; } + + @Override + public StringBuilder toString(StringBuilder sink) { + if(null == sink) { + sink = new StringBuilder(); + } + sink.append(getUpstreamSurfaceHook()). + append(", displayHandle 0x" + Long.toHexString(getDisplayHandle())). + append(", surfaceHandle 0x" + Long.toHexString(getSurfaceHandle())). + append(", size " + getWidth() + "x" + getHeight()).append(", "); + getUpstreamOptionBits(sink); + sink.append(", surfaceLock "+surfaceLock); + return sink; + } + + @Override + public String toString() { + StringBuilder msg = new StringBuilder(); + msg.append(getClass().getSimpleName()).append("[ "); + toString(msg); + msg.append(" ]"); + return msg.toString(); + } + +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java new file mode 100644 index 000000000..e544bc61a --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/WrappedSurface.java @@ -0,0 +1,95 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.nativewindow; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; + +public class WrappedSurface extends ProxySurfaceImpl { + protected long surfaceHandle; + + /** + * Utilizes a {@link UpstreamSurfaceHook.MutableSize} to hold the size information, + * which is being passed to the {@link ProxySurface} instance. + * + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param handle the wrapped pre-existing native surface handle, maybe 0 if not yet determined + * @param initialWidth + * @param initialHeight + * @param ownsDevice true if this {@link ProxySurface} instance + * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, + * otherwise false. Owning the device implies closing it at {@link #destroyNotify()}. + */ + public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle, int initialWidth, int initialHeight, boolean ownsDevice) { + super(cfg, new UpstreamSurfaceHookMutableSize(initialWidth, initialHeight), ownsDevice); + surfaceHandle=handle; + } + + /** + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param handle the wrapped pre-existing native surface handle, maybe 0 if not yet determined + * @param upstream the {@link UpstreamSurfaceHook} to be used + * @param ownsDevice true if this {@link ProxySurface} instance + * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, + * otherwise false. + */ + public WrappedSurface(AbstractGraphicsConfiguration cfg, long handle, UpstreamSurfaceHook upstream, boolean ownsDevice) { + super(cfg, upstream, ownsDevice); + surfaceHandle=handle; + } + + @Override + protected void invalidateImpl() { + surfaceHandle = 0; + } + + @Override + public final long getSurfaceHandle() { + return surfaceHandle; + } + + @Override + public final void setSurfaceHandle(long surfaceHandle) { + this.surfaceHandle=surfaceHandle; + } + + @Override + protected final int lockSurfaceImpl() { + return LOCK_SUCCESS; + } + + @Override + protected final void unlockSurfaceImpl() { + } + +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index e81d61e0f..5fd242247 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -51,7 +51,6 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.util.Point; -import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.nativewindow.awt.JAWTWindow; import jogamp.nativewindow.jawt.JAWT; @@ -71,17 +70,18 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } protected void invalidateNative() { - surfaceHandle=0; + offscreenSurfaceHandle=0; + offscreenSurfaceHandleSet=false; if(isOffscreenLayerSurfaceEnabled()) { if(0 != rootSurfaceLayerHandle) { OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); rootSurfaceLayerHandle = 0; } - if(0 != drawable) { - OSXUtil.DestroyNSWindow(drawable); - drawable = 0; + if(0 != windowHandle) { + OSXUtil.DestroyNSWindow(windowHandle); } } + windowHandle=0; } protected void attachSurfaceLayerImpl(final long layerHandle) { @@ -92,8 +92,14 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.RemoveCASublayer(rootSurfaceLayerHandle, layerHandle); } - public long getSurfaceHandle() { - return isOffscreenLayerSurfaceEnabled() ? surfaceHandle : super.getSurfaceHandle() ; + @Override + public final long getWindowHandle() { + return windowHandle; + } + + @Override + public final long getSurfaceHandle() { + return offscreenSurfaceHandleSet ? offscreenSurfaceHandle : drawable /* super.getSurfaceHandle() */ ; } public void setSurfaceHandle(long surfaceHandle) { @@ -103,7 +109,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if(DEBUG) { System.err.println("MacOSXJAWTWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); } - this.surfaceHandle = surfaceHandle; + this.offscreenSurfaceHandle = surfaceHandle; + this.offscreenSurfaceHandleSet = true; } protected JAWT fetchJAWTImpl() throws NativeWindowException { @@ -167,6 +174,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { unlockSurfaceImpl(); return NativeWindow.LOCK_SURFACE_NOT_READY; } else { + windowHandle = OSXUtil.GetNSWindow(drawable); ret = NativeWindow.LOCK_SUCCESS; } } else { @@ -177,36 +185,46 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { * The actual surface/ca-layer shall be created/attached * by the upper framework (JOGL) since they require more information. */ + String errMsg = null; if(0 == drawable) { - drawable = OSXUtil.CreateNSWindow(0, 0, getBounds().getWidth(), getBounds().getHeight()); - if(0 == drawable) { - unlockSurfaceImpl(); - throw new NativeWindowException("Unable to created dummy NSWindow (layered case)"); + windowHandle = OSXUtil.CreateNSWindow(0, 0, 64, 64); + if(0 == windowHandle) { + errMsg = "Unable to create dummy NSWindow (layered case)"; + } else { + drawable = OSXUtil.GetNSView(windowHandle); + if(0 == drawable) { + errMsg = "Null NSView of NSWindow 0x"+Long.toHexString(windowHandle); + } + } + if(null == errMsg) { + // fix caps reflecting offscreen! (no GL available here ..) + Capabilities caps = (Capabilities) getGraphicsConfiguration().getChosenCapabilities().cloneMutable(); + caps.setOnscreen(false); + setChosenCapabilities(caps); } - // fix caps reflecting offscreen! - Capabilities caps = (Capabilities) getPrivateGraphicsConfiguration().getChosenCapabilities().cloneMutable(); - caps.setOnscreen(false); - getPrivateGraphicsConfiguration().setChosenCapabilities(caps); - caps = (Capabilities) getGraphicsConfiguration().getChosenCapabilities().cloneMutable(); - caps.setOnscreen(false); - ((MutableGraphicsConfiguration)getGraphicsConfiguration()).setChosenCapabilities(caps); } - if(0 == rootSurfaceLayerHandle) { - rootSurfaceLayerHandle = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); - if(0 == rootSurfaceLayerHandle) { - OSXUtil.DestroyNSWindow(drawable); - drawable = 0; - unlockSurfaceImpl(); - throw new NativeWindowException("Could not create root CALayer: "+this); + if(null == errMsg) { + if(0 == rootSurfaceLayerHandle) { + rootSurfaceLayerHandle = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); + if(0 == rootSurfaceLayerHandle) { + errMsg = "Could not create root CALayer"; + } else if(!SetJAWTRootSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { + errMsg = "Could not set JAWT rootSurfaceLayerHandle 0x"+Long.toHexString(rootSurfaceLayerHandle); + } } - if(!SetJAWTRootSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { + } + if(null != errMsg) { + if(0 != rootSurfaceLayerHandle) { OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); rootSurfaceLayerHandle = 0; - OSXUtil.DestroyNSWindow(drawable); - drawable = 0; - unlockSurfaceImpl(); - throw new NativeWindowException("Could not set JAWT rootSurfaceLayerHandle: "+this); } + if(0 != windowHandle) { + OSXUtil.DestroyNSWindow(windowHandle); + windowHandle = 0; + } + drawable = 0; + unlockSurfaceImpl(); + throw new NativeWindowException(errMsg+": "+this); } ret = NativeWindow.LOCK_SUCCESS; } @@ -264,7 +282,9 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { private long rootSurfaceLayerHandle = 0; // attached to the JAWT_SurfaceLayer - private long surfaceHandle = 0; + private long windowHandle = 0; + private long offscreenSurfaceHandle = 0; + private boolean offscreenSurfaceHandleSet = false; // Workaround for instance of 4796548 private boolean firstLock = true; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java new file mode 100644 index 000000000..de3206c0c --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXDummyUpstreamSurfaceHook.java @@ -0,0 +1,56 @@ +package jogamp.nativewindow.macosx; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; + +public class OSXDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { + long nsWindow; + + /** + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * not the actual dummy surface height, + * The latter is platform specific and small + */ + public OSXDummyUpstreamSurfaceHook(int width, int height) { + super(width, height); + nsWindow = 0; + } + + @Override + public final void create(ProxySurface s) { + if(0 == nsWindow && 0 == s.getSurfaceHandle()) { + nsWindow = OSXUtil.CreateNSWindow(0, 0, 64, 64); + if(0 == nsWindow) { + throw new NativeWindowException("Error NS window 0"); + } + long nsView = OSXUtil.GetNSView(nsWindow); + if(0 == nsView) { + throw new NativeWindowException("Error NS view 0"); + } + s.setSurfaceHandle(nsView); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); + } + + @Override + public final void destroy(ProxySurface s) { + if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + if( 0 == nsWindow || 0 == s.getSurfaceHandle() ) { + throw new InternalError("Owns upstream surface, but no OSX view/window: "+s+", nsWindow 0x"+Long.toHexString(nsWindow)); + } + OSXUtil.DestroyNSWindow(nsWindow); + nsWindow = 0; + s.setSurfaceHandle(0); + s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + } + +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 149ebdf4a..b7a83e133 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -72,6 +72,10 @@ public class OSXUtil { return isNSView0(object); } + public static boolean isNSWindow(long object) { + return isNSWindow0(object); + } + /** * In case the windowOrView is top-level, * you shall set topLevel to true where @@ -114,6 +118,9 @@ public class OSXUtil { public static long GetNSView(long nsWindow) { return GetNSView0(nsWindow); } + public static long GetNSWindow(long nsView) { + return GetNSWindow0(nsView); + } public static long CreateCALayer(int x, int y, int width, int height) { return CreateCALayer0(x, y, width, height); @@ -149,6 +156,11 @@ public class OSXUtil { return IsMainThread0(); } + /** Returns the screen refresh rate in Hz. If unavailable, returns 60Hz. */ + public static int GetScreenRefreshRate(int scrn_idx) { + return GetScreenRefreshRate0(scrn_idx); + } + /*** private static boolean isAWTEDTMainThreadInit = false; private static boolean isAWTEDTMainThread; @@ -172,15 +184,18 @@ public class OSXUtil { private static native boolean initIDs0(); private static native boolean isNSView0(long object); + private static native boolean isNSWindow0(long object); private static native Object GetLocationOnScreen0(long windowOrView, int src_x, int src_y); private static native Object GetInsets0(long windowOrView); private static native long CreateNSWindow0(int x, int y, int width, int height); private static native void DestroyNSWindow0(long nsWindow); private static native long GetNSView0(long nsWindow); + private static native long GetNSWindow0(long nsView); private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); private static native void RunOnMainThread0(boolean waitUntilDone, Runnable runnable); private static native boolean IsMainThread0(); + private static native int GetScreenRefreshRate0(int scrn_idx); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java new file mode 100644 index 000000000..aa5f3dac5 --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIDummyUpstreamSurfaceHook.java @@ -0,0 +1,50 @@ +package jogamp.nativewindow.windows; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; + +public class GDIDummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { + /** + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * not the actual dummy surface height, + * The latter is platform specific and small + */ + public GDIDummyUpstreamSurfaceHook(int width, int height) { + super(width, height); + } + + @Override + public final void create(ProxySurface s) { + final GDISurface ms = (GDISurface)s; + if(0 == ms.getWindowHandle()) { + final long windowHandle = GDIUtil.CreateDummyWindow(0, 0, 64, 64); + if(0 == windowHandle) { + throw new NativeWindowException("Error windowHandle 0, werr: "+GDI.GetLastError()); + } + ms.setWindowHandle(windowHandle); + ms.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); + } + + @Override + public final void destroy(ProxySurface s) { + final GDISurface ms = (GDISurface)s; + if( ms.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + if( 0 == ms.getWindowHandle() ) { + throw new InternalError("Owns upstream surface, but no GDI window: "+ms); + } + GDI.ShowWindow(ms.getWindowHandle(), GDI.SW_HIDE); + GDIUtil.DestroyDummyWindow(ms.getWindowHandle()); + ms.setWindowHandle(0); + ms.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + } +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java index e368aa6a1..3db2b5fc9 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDISurface.java @@ -29,9 +29,13 @@ package jogamp.nativewindow.windows; import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import jogamp.nativewindow.ProxySurfaceImpl; +import jogamp.nativewindow.windows.GDI; /** @@ -40,12 +44,20 @@ import javax.media.nativewindow.ProxySurface.UpstreamSurfaceHook; * The latter will get and release the HDC. * The size via getWidth()/getHeight() is invalid. */ -public class GDISurface extends ProxySurface { +public class GDISurface extends ProxySurfaceImpl { protected long windowHandle; protected long surfaceHandle; - public GDISurface(AbstractGraphicsConfiguration cfg, long windowHandle, int initialWidth, int initialHeight, UpstreamSurfaceHook upstream) { - super(cfg, initialWidth, initialHeight, upstream); + /** + * @param cfg the {@link AbstractGraphicsConfiguration} to be used + * @param windowHandle the wrapped pre-existing native window handle, maybe 0 if not yet determined + * @param upstream the {@link UpstreamSurfaceHook} to be used + * @param ownsDevice true if this {@link ProxySurface} instance + * owns the {@link AbstractGraphicsConfiguration}'s {@link AbstractGraphicsDevice}, + * otherwise false. Owning the device implies closing it at {@link #destroyNotify()}. + */ + public GDISurface(AbstractGraphicsConfiguration cfg, long windowHandle, UpstreamSurfaceHook upstream, boolean ownsDevice) { + super(cfg, upstream, ownsDevice); this.windowHandle=windowHandle; this.surfaceHandle=0; } @@ -114,18 +126,4 @@ public class GDISurface extends ProxySurface { final public long getSurfaceHandle() { return surfaceHandle; } - - @Override - final public String toString() { - final UpstreamSurfaceHook ush = getUpstreamSurfaceHook(); - final String ush_s = null != ush ? ( ush.getClass().getName() + ": " + ush ) : "nil"; - return getClass().getSimpleName()+"[config "+getPrivateGraphicsConfiguration()+ - ", displayHandle 0x"+Long.toHexString(getDisplayHandle())+ - ", windowHandle 0x"+Long.toHexString(windowHandle)+ - ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ - ", size "+getWidth()+"x"+getHeight()+ - ", surfaceLock "+surfaceLock+ - ", upstreamSurfaceHook "+ush_s+"]"; - } - } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java new file mode 100644 index 000000000..55a29dd5e --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java @@ -0,0 +1,60 @@ +package jogamp.nativewindow.x11; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.ProxySurface; +import javax.media.nativewindow.UpstreamSurfaceHook; + +import jogamp.nativewindow.x11.X11Lib; + +import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; +import com.jogamp.nativewindow.x11.X11GraphicsConfiguration; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; + +public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize { + /** + * @param width the initial width as returned by {@link NativeSurface#getWidth()} via {@link UpstreamSurfaceHook#getWidth(ProxySurface)}, + * not the actual dummy surface width. + * The latter is platform specific and small + * @param height the initial height as returned by {@link NativeSurface#getHeight()} via {@link UpstreamSurfaceHook#getHeight(ProxySurface)}, + * not the actual dummy surface height, + * The latter is platform specific and small + */ + public X11DummyUpstreamSurfaceHook(int width, int height) { + super(width, height); + } + + @Override + public final void create(ProxySurface s) { + final X11GraphicsConfiguration cfg = (X11GraphicsConfiguration) s.getGraphicsConfiguration(); + final X11GraphicsScreen screen = (X11GraphicsScreen) cfg.getScreen(); + final X11GraphicsDevice device = (X11GraphicsDevice) screen.getDevice(); + if(0 == device.getHandle()) { + device.open(); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + if( 0 == s.getSurfaceHandle() ) { + final long windowHandle = X11Lib.CreateDummyWindow(device.getHandle(), screen.getIndex(), cfg.getXVisualID(), 64, 64); + if(0 == windowHandle) { + throw new NativeWindowException("Creating dummy window failed w/ "+cfg); + } + s.setSurfaceHandle(windowHandle); + s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + s.addUpstreamOptionBits(ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE); + } + + @Override + public final void destroy(ProxySurface s) { + if( s.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ) ) { + final X11GraphicsDevice device = (X11GraphicsDevice) s.getGraphicsConfiguration().getScreen().getDevice(); + if( 0 == s.getSurfaceHandle() ) { + throw new InternalError("Owns upstream surface, but no X11 window: "+s); + } + X11Lib.DestroyDummyWindow(device.getHandle(), s.getSurfaceHandle()); + s.setSurfaceHandle(0); + s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); + } + } +} diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 2c853a43d..d6ae7ed31 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -119,6 +119,12 @@ Java_jogamp_nativewindow_macosx_OSXUtil_isNSView0(JNIEnv *env, jclass _unused, j return [nsObj isMemberOfClass:[NSView class]]; } +JNIEXPORT jboolean JNICALL +Java_jogamp_nativewindow_macosx_OSXUtil_isNSWindow0(JNIEnv *env, jclass _unused, jlong object) { + NSObject *nsObj = (NSObject*) (intptr_t) object; + return [nsObj isMemberOfClass:[NSWindow class]]; +} + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: getLocationOnScreen0 @@ -238,8 +244,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateNSWindow0 [myWindow setPreservesContentDuringLiveResize: YES]; // Remove animations NS_DURING + if ( [myWindow respondsToSelector:@selector(setAnimationBehavior:)] ) { // Available >= 10.7 - Removes default animations [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; + } NS_HANDLER NS_ENDHANDLER @@ -278,11 +286,28 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSView0 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); - DBG_PRINT( "contentView0 - window: %p (START)\n", win); - jlong res = (jlong) ((intptr_t) [win contentView]); - DBG_PRINT( "contentView0 - window: %p (END)\n", win); + DBG_PRINT( "GetNSView(window: %p): %p\n", win, (void*) (intptr_t) res); + + [pool release]; + return res; +} + +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: GetNSWindow0 + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 + (JNIEnv *env, jclass unused, jlong view) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSView* v = (NSView*) ((intptr_t) view); + + jlong res = (jlong) ((intptr_t) [v window]); + + DBG_PRINT( "GetNSWindow(view: %p): %p\n", v, (void*) (intptr_t) res); [pool release]; return res; @@ -314,6 +339,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [layer removeAllAnimations]; + [layer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [layer setNeedsDisplayOnBoundsChange: YES]; DBG_PRINT("CALayer::CreateCALayer.1: %p %lf/%lf %lfx%lf\n", layer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); DBG_PRINT("CALayer::CreateCALayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); @@ -357,7 +384,11 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [rootLayer removeAllAnimations]; + [rootLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [rootLayer setNeedsDisplayOnBoundsChange: YES]; [subLayer removeAllAnimations]; + [subLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [subLayer setNeedsDisplayOnBoundsChange: YES]; }]; DBG_PRINT("CALayer::AddCASublayer0.X: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]); JNF_COCOA_EXIT(env); @@ -404,6 +435,63 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0 JNF_COCOA_EXIT(env); } +/* + * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow + * Method: SetJAWTRootSurfaceLayer0 + * Signature: (JJ)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_SetJAWTRootSurfaceLayer0 + (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) +{ + JNF_COCOA_ENTER(env); + JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); + if (NULL == dsi) { + NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); + return JNI_FALSE; + } + CALayer* layer = (CALayer*) (intptr_t) caLayer; + [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + id surfaceLayers = (id )dsi->platformInfo; + DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: %p -> %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); + surfaceLayers.layer = layer; // already incr. retain count + DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); + }]; + JNF_COCOA_EXIT(env); + return JNI_TRUE; +} + +/* + * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow + * Method: UnsetJAWTRootSurfaceLayer0 + * Signature: (JJ)Z +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_UnsetJAWTRootSurfaceLayer0 + (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) +{ + JNF_COCOA_ENTER(env); + JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); + if (NULL == dsi) { + NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); + return JNI_FALSE; + } + CALayer* layer = (CALayer*) (intptr_t) caLayer; + { + id surfaceLayers = (id )dsi->platformInfo; + if(layer != surfaceLayers.layer) { + NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); + return JNI_FALSE; + } + } + // [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ + id surfaceLayers = (id )dsi->platformInfo; + DBG_PRINT("CALayer::detachJAWTSurfaceLayer: (%p) %p -> NULL\n", layer, surfaceLayers.layer); + surfaceLayers.layer = NULL; + [layer release]; + // }]; + JNF_COCOA_EXIT(env); + return JNI_TRUE; +} + */ + @interface MainRunnable : NSObject { @@ -489,60 +577,65 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_IsMainThread0 return ( [NSThread isMainThread] == YES ) ? JNI_TRUE : JNI_FALSE ; } -/* - * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow - * Method: SetJAWTRootSurfaceLayer0 - * Signature: (JJ)Z +/*** + * The following static functions are copied out of NEWT's OSX impl. + * May need to push code to NativeWindow, to remove duplication. */ -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_SetJAWTRootSurfaceLayer0 - (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) +static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx) { + NSArray *screens = [NSScreen screens]; + if(screen_idx<0) screen_idx=0; + if(screen_idx>=[screens count]) screen_idx=0; + return (NSScreen *) [screens objectAtIndex: screen_idx]; +} +static CGDirectDisplayID NewtScreen_getCGDirectDisplayIDByNSScreen(NSScreen *screen) { + // Mind: typedef uint32_t CGDirectDisplayID; - however, we assume it's 64bit on 64bit ?! + NSDictionary * dict = [screen deviceDescription]; + NSNumber * val = (NSNumber *) [dict objectForKey: @"NSScreenNumber"]; + // [NSNumber integerValue] returns NSInteger which is 32 or 64 bit native size + return (CGDirectDisplayID) [val integerValue]; +} +static long GetDictionaryLong(CFDictionaryRef theDict, const void* key) { - JNF_COCOA_ENTER(env); - JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); - if (NULL == dsi) { - NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); - return JNI_FALSE; - } - CALayer* layer = (CALayer*) (intptr_t) caLayer; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - id surfaceLayers = (id )dsi->platformInfo; - DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: %p -> %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); - surfaceLayers.layer = layer; // already incr. retain count - DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); - }]; - JNF_COCOA_EXIT(env); - return JNI_TRUE; + long value = 0; + CFNumberRef numRef; + numRef = (CFNumberRef)CFDictionaryGetValue(theDict, key); + if (numRef != NULL) + CFNumberGetValue(numRef, kCFNumberLongType, &value); + return value; } +#define CGDDGetModeRefreshRate(mode) GetDictionaryLong((mode), kCGDisplayRefreshRate) /* - * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow - * Method: UnsetJAWTRootSurfaceLayer0 - * Signature: (JJ)Z -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_UnsetJAWTRootSurfaceLayer0 - (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: GetScreenRefreshRate + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenRefreshRate0 + (JNIEnv *env, jclass unused, jint scrn_idx) { + int res = 0; JNF_COCOA_ENTER(env); - JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); - if (NULL == dsi) { - NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); - return JNI_FALSE; - } - CALayer* layer = (CALayer*) (intptr_t) caLayer; - { - id surfaceLayers = (id )dsi->platformInfo; - if(layer != surfaceLayers.layer) { - NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); - return JNI_FALSE; + // NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSScreen *screen = NewtScreen_getNSScreenByIndex((int)scrn_idx); + DBG_PRINT("GetScreenRefreshRate.0: screen %p\n", (void *)screen); + if(NULL != screen) { + CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); + DBG_PRINT("GetScreenRefreshRate.1: display %p\n", (void *)display); + if(0 != display) { + CFDictionaryRef mode = CGDisplayCurrentMode(display); + DBG_PRINT("GetScreenRefreshRate.2: mode %p\n", (void *)mode); + if(NULL != mode) { + res = CGDDGetModeRefreshRate(mode); + DBG_PRINT("GetScreenRefreshRate.3: res %d\n", res); + } } } - // [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - id surfaceLayers = (id )dsi->platformInfo; - DBG_PRINT("CALayer::detachJAWTSurfaceLayer: (%p) %p -> NULL\n", layer, surfaceLayers.layer); - surfaceLayers.layer = NULL; - [layer release]; - // }]; + if(0 == res) { + res = 60; // default .. (experienced on OSX 10.6.8) + } + fprintf(stderr, "GetScreenRefreshRate.X: %d\n", res); + // [pool release]; JNF_COCOA_EXIT(env); - return JNI_TRUE; + return res; } - */ diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 6f0028a77..89a749c51 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -68,6 +68,15 @@ import com.jogamp.newt.event.awt.AWTAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTMouseAdapter; +/** + * AWT {@link java.awt.Canvas Canvas} containing a NEWT {@link Window} using native parenting. + * + *
    Offscreen Layer Remarks
    + * + * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} + * maybe called to use an offscreen drawable (FBO or PBuffer) allowing + * the underlying JAWT mechanism to composite the image, if supported. + */ @SuppressWarnings("serial") public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption { public static final boolean DEBUG = Debug.debug("Window"); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 0fc1b4e89..a89ccaedb 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -51,6 +51,7 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; @@ -97,7 +98,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind * Constructor. Do not call this directly -- use {@link #create()} instead. */ protected GLWindow(Window window) { - super(null, null, false); + super(null, null, false /* always handle device lifecycle ourselves */); this.window = (WindowImpl) window; this.window.setHandleDestroyNotify(false); window.addWindowListener(new WindowAdapter() { @@ -107,8 +108,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override - public void windowResized(WindowEvent e) { - defaultWindowResizedOp(); + public void windowResized(WindowEvent e) { + defaultWindowResizedOp(getWidth(), getHeight()); } @Override @@ -201,11 +202,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind @Override public final CapabilitiesImmutable getChosenCapabilities() { - if (drawable == null) { - return window.getChosenCapabilities(); - } - - return drawable.getChosenGLCapabilities(); + final GLDrawable _drawable = drawable; + return null != _drawable ? _drawable.getChosenGLCapabilities() : window.getChosenCapabilities(); } @Override @@ -536,19 +534,24 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return; } + final boolean done; final RecursiveLock lock = window.getLock(); lock.lock(); // sync: context/drawable could have been recreated/destroyed while animating try { if( null != context ) { // surface is locked/unlocked implicit by context's makeCurrent/release helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); - } else if( 0 display - setVisible(true); + done = true; + } else { + done = false; } } finally { lock.unlock(); } + if( !done && 0 display + setVisible(true); + } } //---------------------------------------------------------------------- diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index cada253bc..36bc3f28f 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -63,6 +63,9 @@ import com.jogamp.newt.Window; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.util.EDTUtil; +/** + * SWT {@link Canvas} containing a NEWT {@link Window} using native parenting. + */ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false); diff --git a/src/newt/classes/jogamp/newt/OffscreenWindow.java b/src/newt/classes/jogamp/newt/OffscreenWindow.java index ba98ca3af..c6c1814f6 100644 --- a/src/newt/classes/jogamp/newt/OffscreenWindow.java +++ b/src/newt/classes/jogamp/newt/OffscreenWindow.java @@ -39,20 +39,16 @@ import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; public class OffscreenWindow extends WindowImpl implements MutableSurface { - long surfaceHandle = 0; - ProxySurface.UpstreamSurfaceHook upstreamHook; - ProxySurface dummySurface; + long surfaceHandle; public OffscreenWindow() { - upstreamHook = null; - dummySurface = null; + surfaceHandle = 0; } static long nextWindowHandle = 0x100; // start here - a marker @@ -62,17 +58,6 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { throw new NativeWindowException("Capabilities is onscreen"); } final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); - /** Cannot use OpenGL here .. - if(capsRequested instanceof GLCapabilitiesImmutable) { - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) capsRequested; - if(caps.isFBO() && GLContext.isFBOAvailable(aScreen.getDevice(), caps.getGLProfile()) ) { - final GLDrawableFactoryImpl factory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLCapabilitiesImmutable dummyCaps = GLGraphicsConfigurationUtil.fixOnscreenGLCapabilities(caps); - final ProxySurface dummySurface = factory.createDummySurfaceImpl(aScreen.getDevice(), false, dummyCaps, null, 64, 64); - upstreamHook = dummySurface.getUpstreamSurfaceHook(); - dummySurface.createNotify(); - } - } */ final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(aScreen.getDevice(), capsRequested).chooseGraphicsConfiguration( capsRequested, capsRequested, capabilitiesChooser, aScreen, VisualIDHolder.VID_UNDEFINED); if (null == cfg) { @@ -83,6 +68,7 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { synchronized(OffscreenWindow.class) { setWindowHandle(nextWindowHandle++); } + visibleChanged(false, true); } protected void closeNativeImpl() { @@ -92,11 +78,6 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { @Override public synchronized void destroy() { super.destroy(); - if(null != dummySurface) { - dummySurface.destroyNotify(); - dummySurface = null; - upstreamHook = null; - } surfaceHandle = 0; } @@ -106,10 +87,6 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { @Override public long getSurfaceHandle() { - if(null != dummySurface) { - return dummySurface.getSurfaceHandle(); - // return upstreamHook.getWidth(); - } return surfaceHandle; } @@ -128,8 +105,8 @@ public class OffscreenWindow extends WindowImpl implements MutableSurface { } protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + sizeChanged(false, width, height, false); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - sizeChanged(false, width, height, false); visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); } else { /** diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index ad7195944..c1ac87d38 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -767,11 +767,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - public void setVisible(boolean visible) { + protected void setVisible(boolean wait, boolean visible) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setVisible: START ("+getThreadName()+") "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible: "+this.visible+" -> "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+(null!=parentWindow)); } - runOnEDTIfAvail(true, new VisibleAction(visible)); + runOnEDTIfAvail(wait, new VisibleAction(visible)); + } + + public void setVisible(boolean visible) { + setVisible(true, visible); } private class SetSizeAction implements Runnable { @@ -783,21 +787,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } public final void run() { - boolean recreate = false; final RecursiveLock _lock = windowLock; _lock.lock(); try { if ( !isFullscreen() && ( getWidth() != width || getHeight() != height ) ) { - recreate = isNativeValid() && !getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible+", recreate "+recreate); - } - if(recreate) { - // will trigger visibleAction:=2 -> create if wasVisible - final boolean wasVisible = WindowImpl.this.visible; - screen.addReference(); // retain screen - destroyAction.run(); - WindowImpl.this.visible = wasVisible; + System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible); } int visibleAction; // 0 nop, 1 invisible, 2 visible (create) if ( isNativeValid() && 0>=width*height && visible ) { @@ -823,9 +818,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } finally { - if(recreate) { - screen.removeReference(); // bring back ref-count - } _lock.unlock(); } } @@ -940,11 +932,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer */ protected static boolean isOffscreenInstance(NativeWindow cWin, NativeWindow pWin) { boolean ofs = false; - if( null != cWin.getGraphicsConfiguration() ) { - ofs = !cWin.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); + final AbstractGraphicsConfiguration cWinCfg = cWin.getGraphicsConfiguration(); + if( null != cWinCfg ) { + ofs = !cWinCfg.getChosenCapabilities().isOnscreen(); } - if( !ofs && null != pWin && null != pWin.getGraphicsConfiguration() ) { - ofs |= !pWin.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); + if( !ofs && null != pWin ) { + final AbstractGraphicsConfiguration pWinCfg = pWin.getGraphicsConfiguration(); + if( null != pWinCfg ) { + ofs = !pWinCfg.getChosenCapabilities().isOnscreen(); + } } return ofs; } diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 276b0d070..f18520630 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -428,7 +428,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { getX()+"/"+getY()+" "+nWidth+"x"+nHeight+", visible: "+isVisible()); if(isVisible()) { - setVisible(true); + setVisible(false, true); } } sizeChanged(false, aWidth, aHeight, false); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index ea48569bf..d0c0b8b20 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -117,6 +117,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl return 0 != sscSurfaceHandle ? sscSurfaceHandle : surfaceHandle; } + @Override public void setSurfaceHandle(long surfaceHandle) { if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); @@ -170,13 +171,22 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - final Point pS = getTopLevelLocationOnScreen(x, y); - isOffscreenInstance = 0 != sscSurfaceHandle || isOffscreenInstance(this, this.getParent()); + final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent()); + isOffscreenInstance = 0 != sscSurfaceHandle || _isOffscreenInstance; + final PointImmutable pS = isOffscreenInstance ? new Point(0, 0) : getTopLevelLocationOnScreen(x, y); if(DEBUG_IMPLEMENTATION) { + final AbstractGraphicsConfiguration cWinCfg = this.getGraphicsConfiguration(); + final NativeWindow pWin = getParent(); + final AbstractGraphicsConfiguration pWinCfg = null != pWin ? pWin.getGraphicsConfiguration() : null; System.err.println("MacWindow reconfig: "+x+"/"+y+" -> "+pS+" - "+width+"x"+height+ - ", offscreenInstance "+isOffscreenInstance+ - ", "+getReconfigureFlagsAsString(null, flags)); + ",\n\t parent type "+(null != pWin ? pWin.getClass().getName() : null)+ + ",\n\t this-chosenCaps "+(null != cWinCfg ? cWinCfg.getChosenCapabilities() : null)+ + ",\n\t parent-chosenCaps "+(null != pWinCfg ? pWinCfg.getChosenCapabilities() : null)+ + ", isOffscreenInstance(sscSurfaceHandle "+toHexString(sscSurfaceHandle)+ + ", ioi: "+_isOffscreenInstance+ + ") -> "+isOffscreenInstance+ + "\n\t, "+getReconfigureFlagsAsString(null, flags)); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { @@ -190,7 +200,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl 0 != ( FLAG_CHANGE_DECORATION & flags) || 0 != ( FLAG_CHANGE_PARENTING & flags) || 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { - createWindow(isOffscreenInstance, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + if(isOffscreenInstance) { + createWindow(true, 0 != getWindowHandle(), pS, 64, 64, false); + } else { + createWindow(false, 0 != getWindowHandle(), pS, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); + } if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } } if(x>=0 && y>=0) { diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index e0330a563..b9c339285 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -94,7 +94,13 @@ static void changeContentView(JNIEnv *env, jobject javaWindowObject, NSView *pvi if(NULL!=oldNSView) { NS_DURING // Available >= 10.5 - Makes the menubar disapear - if([oldNSView isInFullScreenMode]) { + BOOL iifs; + if ( [oldNSView respondsToSelector:@selector(isInFullScreenMode)] ) { + iifs = [oldNSView isInFullScreenMode]; + } else { + iifs = NO; + } + if(iifs && [oldNSView respondsToSelector:@selector(exitFullScreenModeWithOptions:)] ) { [oldNSView exitFullScreenModeWithOptions: NULL]; } NS_HANDLER @@ -430,6 +436,8 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree if( -1 < mode_idx ) { prop[propIndex++] = mode_idx; } + int refreshRate = CGDDGetModeRefreshRate(mode); + int fRefreshRate = ( 0 < refreshRate ) ? refreshRate : 60; // default .. (experienced on OSX 10.6.8) prop[propIndex++] = 0; // set later for verification of iterator propIndexRes = propIndex; prop[propIndex++] = mWidth; @@ -437,14 +445,14 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree prop[propIndex++] = CGDDGetModeBitsPerPixel(mode); prop[propIndex++] = widthMM; prop[propIndex++] = heightMM; - prop[propIndex++] = CGDDGetModeRefreshRate(mode); + prop[propIndex++] = fRefreshRate; prop[propIndex++] = ccwRot; prop[propIndex - NUM_SCREEN_MODE_PROPERTIES_ALL] = ( -1 < mode_idx ) ? propIndex-1 : propIndex ; // count == NUM_SCREEN_MODE_PROPERTIES_ALL - DBG_PRINT( "getScreenMode0: Mode %d/%d (%d): %dx%d, %d bpp, %dx%d mm, %d Hz, rot %d ccw\n", + DBG_PRINT( "getScreenMode0: Mode %d/%d (%d): %dx%d, %d bpp, %dx%d mm, %d / %d Hz, rot %d ccw\n", (int)mode_idx, (int)numberOfAvailableModesRots, (int)numberOfAvailableModes, (int)prop[propIndexRes+0], (int)prop[propIndexRes+1], (int)prop[propIndexRes+2], - (int)prop[propIndexRes+3], (int)prop[propIndexRes+4], (int)prop[propIndexRes+5], (int)prop[propIndexRes+6]); + (int)prop[propIndexRes+3], (int)prop[propIndexRes+4], (int)prop[propIndexRes+5], refreshRate, (int)prop[propIndexRes+6]); jintArray properties = (*env)->NewIntArray(env, prop_num); if (properties == NULL) { @@ -516,6 +524,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 if(initialized) return JNI_TRUE; initialized = 1; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + jclass c; c = (*env)->FindClass(env, ClazzNamePoint); if(NULL==c) { @@ -537,7 +547,10 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 // printf("Going to sleep for 10 seconds\n"); // sleep(10); - return (jboolean) [NewtMacWindow initNatives: env forClass: clazz]; + BOOL res = [NewtMacWindow initNatives: env forClass: clazz]; + [pool release]; + + return (jboolean) res; } /* @@ -602,8 +615,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow // Remove animations for child windows if(NULL != parentWindow) { NS_DURING - // Available >= 10.7 - Removes default animations - [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; + if ( [myWindow respondsToSelector:@selector(setAnimationBehavior:)] ) { + // Available >= 10.7 - Removes default animations + [myWindow setAnimationBehavior: NSWindowAnimationBehaviorNone]; + } NS_HANDLER NS_ENDHANDLER } @@ -658,8 +673,12 @@ NS_ENDHANDLER NS_DURING // concurrent view rendering // Available >= 10.6 - Makes the menubar disapear - [myWindow setAllowsConcurrentViewDrawing: YES]; - [myView setCanDrawConcurrently: YES]; + if ( [myWindow respondsToSelector:@selector(setAllowsConcurrentViewDrawing:)] ) { + [myWindow setAllowsConcurrentViewDrawing: YES]; + } + if ( [myView respondsToSelector:@selector(setCanDrawConcurrently:)] ) { + [myView setCanDrawConcurrently: YES]; + } NS_HANDLER NS_ENDHANDLER @@ -669,7 +688,9 @@ NS_ENDHANDLER NS_DURING // Available >= 10.5 - Makes the menubar disapear if(fullscreen) { - [myView enterFullScreenMode: myScreen withOptions:NULL]; + if ( [myView respondsToSelector:@selector(enterFullScreenMode:withOptions:)] ) { + [myView enterFullScreenMode: myScreen withOptions:NULL]; + } } NS_HANDLER NS_ENDHANDLER @@ -730,7 +751,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 NS_DURING if(NULL!=mView) { // Available >= 10.5 - Makes the menubar disapear - if([mView isInFullScreenMode]) { + BOOL iifs; + if ( [mView respondsToSelector:@selector(isInFullScreenMode)] ) { + iifs = [mView isInFullScreenMode]; + } else { + iifs = NO; + } + if(iifs && [mView respondsToSelector:@selector(exitFullScreenModeWithOptions:)] ) { [mView exitFullScreenModeWithOptions: NULL]; } // Note: mWin's release will also release it's mView! diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java index 4f24fc9b8..c4b74c56f 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher0.java @@ -50,6 +50,8 @@ public class MovieCubeActivityLauncher0 extends LauncherUtil.BaseActivityLaunche // props.setProperty("jogamp.debug.NativeLibrary", "true"); // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); // props.setProperty("jogamp.debug.IOUtil", "true"); + // props.setProperty("jogamp.debug.Lock", "true"); + // props.setProperty("jogamp.debug.Lock.TraceLock", "true"); // props.setProperty("nativewindow.debug", "all"); props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); // props.setProperty("jogl.debug", "all"); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java index c75c229a8..576305835 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivityLauncher.java @@ -14,23 +14,23 @@ public class NEWTGraphUI1pActivityLauncher extends LauncherUtil.BaseActivityLaun final OrderedProperties props = getProperties(); // props.setProperty("jogamp.debug.JNILibLoader", "true"); // props.setProperty("jogamp.debug.NativeLibrary", "true"); - // properties.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); - // properties.setProperty("jogamp.debug.IOUtil", "true"); - // properties.setProperty("nativewindow.debug", "all"); + // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + // props.setProperty("nativewindow.debug", "all"); props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); - // properties.setProperty("jogl.debug", "all"); - // properties.setProperty("jogl.debug.GLProfile", "true"); + // props.setProperty("jogl.debug", "all"); + // props.setProperty("jogl.debug.GLProfile", "true"); props.setProperty("jogl.debug.GLDrawable", "true"); props.setProperty("jogl.debug.GLContext", "true"); props.setProperty("jogl.debug.GLSLCode", "true"); props.setProperty("jogl.debug.CapabilitiesChooser", "true"); - // properties.setProperty("jogl.debug.GLSLState", "true"); - // properties.setProperty("jogl.debug.DebugGL", "true"); - // properties.setProperty("jogl.debug.TraceGL", "true"); - // properties.setProperty("newt.debug", "all"); + // props.setProperty("jogl.debug.GLSLState", "true"); + // props.setProperty("jogl.debug.DebugGL", "true"); + // props.setProperty("jogl.debug.TraceGL", "true"); + // props.setProperty("newt.debug", "all"); props.setProperty("newt.debug.Window", "true"); - // properties.setProperty("newt.debug.Window.MouseEvent", "true"); - // properties.setProperty("newt.debug.Window.KeyEvent", "true"); + // props.setProperty("newt.debug.Window.MouseEvent", "true"); + // props.setProperty("newt.debug.Window.KeyEvent", "true"); } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java new file mode 100644 index 000000000..eab1a37e3 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java @@ -0,0 +1,128 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.EventQueue; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.DefaultGLCapabilitiesChooser; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import jogamp.nativewindow.jawt.JAWTUtil; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.util.RunnableTask; +import com.jogamp.opengl.test.junit.util.UITestCase; + +public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { + static GLProfile glp; + static int width, height; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getGL2ES2(); + Assert.assertNotNull( glp ); + width = 512; + height = 512; + } + + protected void runTestGL( GLCapabilities caps ) throws InterruptedException, InvocationTargetException { + final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable( + null, + caps, new DefaultGLCapabilitiesChooser(), + 512, 512, + null + ); + + final boolean[] done = {false}; + final Runnable pbufferCreationAction = new Runnable() { + public void run() { + System.err.println("AA.1"); + fbod.display(); + done[ 0 ] = true; + System.err.println("AA.X"); + } + }; + + EventQueue.invokeAndWait(new Runnable() { + public void run() { + Assert.assertTrue(EventQueue.isDispatchThread()); + JAWTUtil.lockToolkit(); + try { + final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false); + System.err.println("BB.0: "+rTask.getSyncObject()); + synchronized (rTask.getSyncObject()) { + System.err.println("BB.1: "+rTask.getSyncObject()); + new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); + try { + System.err.println("BB.2"); + rTask.getSyncObject().wait(); + System.err.println("BB.3"); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + System.err.println("BB.X"); + } + } finally { + JAWTUtil.unlockToolkit(); + } + } + }); + Assert.assertTrue(done[0]); + fbod.destroy(); + } + + @Test(timeout = 2000) // 2s timeout + public void testDeadlock() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities( glp ); + runTestGL( caps ); + } + + static long duration = 500; // ms + + public static void main( String args[] ) { + for ( int i = 0; i < args.length; i++ ) { + if ( args[ i ].equals( "-time" ) ) { + i++; + try { + duration = Integer.parseInt( args[ i ] ); + } + catch ( Exception ex ) { + ex.printStackTrace(); + } + } + } + org.junit.runner.JUnitCore.main( TestFBOAutoDrawableDeadlockAWT.class.getName() ); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java new file mode 100644 index 000000000..2dc547f39 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java @@ -0,0 +1,375 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.opengl.GL; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + *

    + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + *

    + *

    + * Extensive FBO reconfiguration (size and sample buffer count) and validation are performed. + *

    + */ +public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { + + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + interface MyGLEventListener extends GLEventListener { + void setMakeSnapshot(); + } + + @Test + public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setDoubleBuffered(false); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } + + @Test + public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setDoubleBuffered(true); // default + testGLFBODrawableImpl(caps, new GearsES2(0)); + } + + @Test + public void testGL2ES2_Demo2MSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new MultisampleDemoES2(true)); + } + + @Test + public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { + final GLProfile glp = GLProfile.getGL2ES2(); + final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); + demo.setDoRotation(false); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, demo); + } + + @Test + public void testEGLES2_Demo0Normal() throws InterruptedException { + if( GLProfile.isAvailable(GLProfile.GLES2) ) { + final GLProfile glp = GLProfile.get(GLProfile.GLES2); + final GLCapabilities caps = new GLCapabilities(glp); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } else { + System.err.println("EGL ES2 n/a"); + } + } + + @Test + public void testEGLES2_Demo0MSAA4() throws InterruptedException { + if( GLProfile.isAvailable(GLProfile.GLES2) ) { + final GLProfile glp = GLProfile.get(GLProfile.GLES2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(4); + testGLFBODrawableImpl(caps, new GearsES2(0)); + } else { + System.err.println("EGL ES2 n/a"); + } + } + + void testGLFBODrawableImpl(GLCapabilities caps, GLEventListener demo) throws InterruptedException { + caps.setFBO(true); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLOffscreenAutoDrawable.FBO glad = (GLOffscreenAutoDrawable.FBO) + factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep, null); + Assert.assertNotNull(glad); + + System.out.println("Realized GLAD: "+glad); + System.out.println("Realized GLAD: "+glad.getChosenGLCapabilities()); + Assert.assertTrue("FBO drawable is initialized before ctx creation", !glad.isInitialized()); + + glad.display(); // initial display incl. init! + { + final GLContext context = glad.getContext(); + Assert.assertNotNull(context); + Assert.assertTrue(context.isCreated()); + } + Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized()); + + // + // FBO incl. MSAA is fully initialized now + // + + final GLCapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); + System.out.println("Init GLAD: "+glad); + System.out.println("Init GLAD: "+chosenCaps); + + final FBObject fboFront = glad.getFBObject(GL.GL_FRONT); + final FBObject fboBack = glad.getFBObject(GL.GL_BACK); + + System.out.println("Init front FBO: "+fboFront); + System.out.println("Init back FBO: "+fboBack); + + Assert.assertTrue("FBO drawable is not initialized before ctx creation", glad.isInitialized()); + Assert.assertTrue("FBO Front is not initialized before ctx creation", fboFront.isInitialized()); + Assert.assertTrue("FBO Back is not initialized before ctx creation", fboBack.isInitialized()); + + if( chosenCaps.getDoubleBuffered() ) { + Assert.assertTrue("FBO are equal: "+fboFront+" == "+fboBack, !fboFront.equals(fboBack)); + Assert.assertNotSame(fboFront, fboBack); + } else { + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+fboBack, fboFront.equals(fboBack)); + Assert.assertSame(fboFront, fboBack); + } + + final FBObject.TextureAttachment texAttachA, texAttachB; + + texAttachA = glad.getTextureBuffer(GL.GL_FRONT); + if(0==glad.getNumSamples()) { + texAttachB = glad.getTextureBuffer(GL.GL_BACK); + } else { + texAttachB = null; + } + + final FBObject.Colorbuffer colorA, colorB; + final FBObject.RenderAttachment depthA, depthB; + + colorA = fboFront.getColorbuffer(0); + Assert.assertNotNull(colorA); + colorB = fboBack.getColorbuffer(0); + Assert.assertNotNull(colorB); + + depthA = fboFront.getDepthAttachment(); + Assert.assertNotNull(depthA); + depthB = fboBack.getDepthAttachment(); + Assert.assertNotNull(depthB); + + glad.display(); // SWAP_ODD + + if( chosenCaps.getDoubleBuffered() ) { + // double buffer or MSAA + Assert.assertTrue("Color attachments are equal: "+colorB+" == "+colorA, !colorB.equals(colorA)); + Assert.assertNotSame(colorB, colorA); + Assert.assertTrue("Depth attachments are equal: "+depthB+" == "+depthA, !depthB.equals(depthA)); + Assert.assertNotSame(depthB, depthA); + } else { + // single buffer + Assert.assertEquals(colorA, colorB); + Assert.assertSame(colorA, colorB); + Assert.assertEquals(depthA, depthB); + Assert.assertSame(depthA, depthB); + } + + Assert.assertEquals(texAttachA, colorA); + Assert.assertSame(texAttachA, colorA); + if(0==glad.getNumSamples()) { + Assert.assertEquals(texAttachB, colorB); + Assert.assertSame(texAttachB, colorB); + } + + if( chosenCaps.getNumSamples() > 0 ) { + // MSAA + FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront)); + Assert.assertSame(fboFront, _fboFront); + Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack.equals(_fboBack)); + Assert.assertSame(fboBack, _fboBack); + } else if( chosenCaps.getDoubleBuffered() ) { + // real double buffer + FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack.equals(_fboFront)); + Assert.assertSame(fboBack, _fboFront); + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack)); + Assert.assertSame(fboFront, _fboBack); + } else { + // single buffer + FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront)); + Assert.assertSame(fboFront, _fboFront); + Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboFront, fboBack.equals(_fboFront)); + Assert.assertSame(fboBack, _fboFront); + Assert.assertTrue("FBO are not equal: "+fboBack+" != "+_fboBack, fboBack.equals(_fboBack)); + Assert.assertSame(fboBack, _fboBack); + Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack)); + Assert.assertSame(fboFront, _fboBack); + } + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // - SWAP_EVEN + + // 1 - szStep = 2 + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); // - SWAP_ODD + + // 2, 3 (resize + display) + szStep = 1; + glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_EVEN + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); // - SWAP_ODD + glad.display(); // - SWAP_EVEN + { + // Check whether the attachment reference are still valid! + final FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + final FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + System.out.println("Resize1.oldFront: "+fboFront); + System.out.println("Resize1.nowFront: "+_fboFront); + System.out.println("Resize1.oldBack : "+fboBack); + System.out.println("Resize1.nowBack : "+_fboBack); + Assert.assertEquals(fboFront, _fboFront); + Assert.assertSame(fboFront, _fboFront); + Assert.assertEquals(fboBack, _fboBack); + Assert.assertSame(fboBack, _fboBack); + + FBObject.Colorbuffer _color = _fboFront.getColorbuffer(0); + Assert.assertNotNull(_color); + Assert.assertEquals(colorA, _color); + Assert.assertSame(colorA, _color); + + FBObject.RenderAttachment _depth = _fboFront.getDepthAttachment(); + System.err.println("Resize1.oldDepth "+depthA); + System.err.println("Resize1.newDepth "+_depth); + Assert.assertNotNull(_depth); + + Assert.assertEquals(depthA, _depth); + Assert.assertSame(depthA, _depth); + _depth = _fboBack.getDepthAttachment(); + Assert.assertNotNull(_depth); + Assert.assertEquals(depthB, _depth); + Assert.assertSame(depthB, _depth); + + _color = _fboFront.getColorbuffer(colorA); + Assert.assertNotNull(_color); + Assert.assertEquals(colorA, _color); + Assert.assertSame(colorA, _color); + } + + // 4, 5 (resize + display) + szStep = 4; + glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_ODD + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); // - SWAP_EVEN + glad.display(); // - SWAP_ODD + { + // Check whether the attachment reference are still valid! + final FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); + final FBObject _fboBack = glad.getFBObject(GL.GL_BACK); + System.out.println("Resize2.oldFront: "+fboFront); + System.out.println("Resize2.nowFront: "+_fboFront); + System.out.println("Resize2.oldBack : "+fboBack); + System.out.println("Resize2.nowBack : "+_fboBack); + if(chosenCaps.getDoubleBuffered() && 0==chosenCaps.getNumSamples()) { + // real double buffer + Assert.assertEquals(fboBack, _fboFront); + Assert.assertEquals(fboFront, _fboBack); + } else { + // single or MSAA + Assert.assertEquals(fboFront, _fboFront); + Assert.assertEquals(fboBack, _fboBack); + } + + FBObject.Colorbuffer _color = fboBack.getColorbuffer(0); + Assert.assertNotNull(_color); + Assert.assertEquals(colorB, _color); + Assert.assertSame(colorB, _color); + + FBObject.RenderAttachment _depth = fboBack.getDepthAttachment(); + Assert.assertNotNull(_depth); // MSAA back w/ depth + Assert.assertEquals(depthB, _depth); + Assert.assertSame(depthB, _depth); + + _depth = fboFront.getDepthAttachment(); + Assert.assertNotNull(_depth); + Assert.assertEquals(depthA, _depth); + Assert.assertSame(depthA, _depth); + + _color = fboBack.getColorbuffer(colorB); + Assert.assertNotNull(_color); + Assert.assertEquals(colorB, _color); + Assert.assertSame(colorB, _color); + } + + // 6 + 7 (samples + display) + glad.setNumSamples(glad.getGL(), chosenCaps.getNumSamples() > 0 ? 0 : 4); // triggers repaint + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); // actual screenshot + + // 8, 9 (resize + samples + display) + szStep = 3; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + glad.destroy(); + System.out.println("Fin: "+glad); + } + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestFBOAutoDrawableFactoryNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java deleted file mode 100644 index 7977347a7..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBODrawableNEWT.java +++ /dev/null @@ -1,272 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.io.IOException; - -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import jogamp.opengl.GLFBODrawableImpl; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.opengl.FBObject; -import com.jogamp.opengl.OffscreenAutoDrawable; -import com.jogamp.opengl.test.junit.jogl.demos.es2.FBOMix2DemosES2; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.texture.TextureIO; - -public class TestFBODrawableNEWT extends UITestCase { - - static final int widthStep = 800/4; - static final int heightStep = 600/4; - volatile int szStep = 2; - - @Test - public void testGL2ES2_Demo1Normal() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - testGLFBODrawableImpl(caps, new GearsES2(0)); - } - - @Test - public void testGL2ES2_Demo1MSAA4() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - caps.setSampleBuffers(true); - caps.setNumSamples(4); - testGLFBODrawableImpl(caps, new GearsES2(0)); - } - - @Test - public void testGL2ES2_Demo2Normal() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - testGLFBODrawableImpl(caps, new MultisampleDemoES2(false)); - } - - @Test - public void testGL2ES2_Demo2MSAA4() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - caps.setSampleBuffers(true); - caps.setNumSamples(4); - testGLFBODrawableImpl(caps, new MultisampleDemoES2(true)); - } - - @Test - public void testGL2ES2_FBODemoNormal() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); - demo.setDoRotation(false); - final GLCapabilities caps = new GLCapabilities(glp); - testGLFBODrawableImpl(caps, demo); - } - - @Test - public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { - final GLProfile glp = GLProfile.getGL2ES2(); - final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); - demo.setDoRotation(false); - final GLCapabilities caps = new GLCapabilities(glp); - caps.setSampleBuffers(true); - caps.setNumSamples(4); - testGLFBODrawableImpl(caps, demo); - } - - @Test - public void testEGLES2_Demo0Normal() throws InterruptedException { - if( GLProfile.isAvailable(GLProfile.GLES2) ) { - final GLProfile glp = GLProfile.get(GLProfile.GLES2); - final GLCapabilities caps = new GLCapabilities(glp); - testGLFBODrawableImpl(caps, new GearsES2(0)); - } else { - System.err.println("EGL ES2 n/a"); - } - } - - @Test - public void testEGLES2_Demo0MSAA4() throws InterruptedException { - if( GLProfile.isAvailable(GLProfile.GLES2) ) { - final GLProfile glp = GLProfile.get(GLProfile.GLES2); - final GLCapabilities caps = new GLCapabilities(glp); - caps.setSampleBuffers(true); - caps.setNumSamples(4); - testGLFBODrawableImpl(caps, new GearsES2(0)); - } else { - System.err.println("EGL ES2 n/a"); - } - } - - boolean skipShot = false; - - void testGLFBODrawableImpl(GLCapabilities caps, GLEventListener demo) throws InterruptedException { - final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - caps.setFBO(true); - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLDrawable fboDrawable = factory.createOffscreenDrawable(null, caps, null, widthStep*szStep, heightStep*szStep); - Assert.assertNotNull(fboDrawable); - Assert.assertTrue("Not an FBO Drawable", fboDrawable instanceof GLFBODrawableImpl); - - fboDrawable.setRealized(true); - Assert.assertTrue(fboDrawable.isRealized()); - - final FBObject fbo = ((GLFBODrawableImpl)fboDrawable).getFBObject(); - - System.out.println("Realized: "+fboDrawable); - System.out.println("Realized: "+fboDrawable.getChosenGLCapabilities()); - System.out.println("Realized: "+fbo); - - final GLContext context = fboDrawable.createContext(null); - Assert.assertNotNull(context); - - int res = context.makeCurrent(); - Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); - context.release(); - - System.out.println("Post Create-Ctx: "+fbo); - final FBObject.Colorbuffer colorA = fbo.getColorbuffer(0); - Assert.assertNotNull(colorA); - final FBObject.RenderAttachment depthA = fbo.getDepthAttachment(); - Assert.assertNotNull(depthA); - - final OffscreenAutoDrawable glad = new OffscreenAutoDrawable(fboDrawable, context, true); - - glad.addGLEventListener(demo); - glad.addGLEventListener(new GLEventListener() { - volatile int displayCount=0; - volatile int reshapeCount=0; - public void init(GLAutoDrawable drawable) {} - public void dispose(GLAutoDrawable drawable) {} - public void display(GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - // System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": step "+szStep+" "+drawable.getWidth()+"x"+drawable.getHeight()); - // System.err.println(Thread.currentThread().getName()+": ** FBO-THIS: "+fbo); - // System.err.println(Thread.currentThread().getName()+": ** FBO-SINK: "+fbo.getSamplingSinkFBO()); - // System.err.println(Thread.currentThread().getName()+": ** drawable-read: "+gl.getDefaultReadFramebuffer()); - if(skipShot) { - skipShot=false; - } else { - snapshot(getSimpleTestName("."), displayCount, "msaa"+fbo.getNumSamples(), gl, screenshot, TextureIO.PNG, null); - } - Assert.assertEquals(drawable.getWidth(), widthStep*szStep); - Assert.assertEquals(drawable.getHeight(), heightStep*szStep); - displayCount++; - } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - System.err.println(Thread.currentThread().getName()+": ** reshape: "+reshapeCount+": step "+szStep+" "+width+"x"+height+" - "+drawable.getWidth()+"x"+drawable.getHeight()); - Assert.assertEquals(drawable.getWidth(), widthStep*szStep); - Assert.assertEquals(drawable.getHeight(), heightStep*szStep); - reshapeCount++; - } - }); - - // 0 - szStep = 2 - glad.display(); - - // 1, 2 (resize + display) - szStep = 1; - skipShot=true; - glad.setSize(widthStep*szStep, heightStep*szStep); - glad.display(); - Assert.assertEquals(glad.getWidth(), widthStep*szStep); - Assert.assertEquals(glad.getHeight(), heightStep*szStep); - { - // Check whether the attachment reference are still valid! - FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0); - Assert.assertNotNull(_colorA); - Assert.assertTrue(colorA == _colorA); - Assert.assertTrue(colorA.equals(_colorA)); - FBObject.RenderAttachment _depthA = fbo.getDepthAttachment(); - Assert.assertNotNull(_depthA); - Assert.assertTrue(depthA == _depthA); - Assert.assertTrue(depthA.equals(_depthA)); - - _colorA = fbo.getColorbuffer(colorA); - Assert.assertNotNull(_colorA); - Assert.assertTrue(colorA == _colorA); - Assert.assertTrue(colorA.equals(_colorA)); - } - - // 3, 4 (resize + display) - szStep = 4; - skipShot=true; - glad.setSize(widthStep*szStep, heightStep*szStep); - glad.display(); - Assert.assertEquals(glad.getWidth(), widthStep*szStep); - Assert.assertEquals(glad.getHeight(), heightStep*szStep); - { - // Check whether the attachment reference are still valid! - FBObject.Colorbuffer _colorA = fbo.getColorbuffer(0); - Assert.assertNotNull(_colorA); - Assert.assertTrue(colorA == _colorA); - final FBObject.RenderAttachment _depthA = fbo.getDepthAttachment(); - Assert.assertNotNull(_depthA); - Assert.assertTrue(depthA == _depthA); - - _colorA = fbo.getColorbuffer(colorA); - Assert.assertNotNull(_colorA); - Assert.assertTrue(colorA == _colorA); - } - - // 5 - glad.display(); - Assert.assertEquals(glad.getWidth(), widthStep*szStep); - Assert.assertEquals(glad.getHeight(), heightStep*szStep); - - // 6, 7 (resize + display) - szStep = 3; - skipShot=true; - glad.setSize(widthStep*szStep, heightStep*szStep); - glad.display(); - Assert.assertEquals(glad.getWidth(), widthStep*szStep); - Assert.assertEquals(glad.getHeight(), heightStep*szStep); - - glad.destroy(); - System.out.println("Fin: "+fboDrawable); - - // final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(fboDrawable, context); - } - - public static void main(String args[]) throws IOException { - org.junit.runner.JUnitCore.main(TestFBODrawableNEWT.class.getName()); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java index f7c83a03b..077baad43 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java @@ -229,7 +229,7 @@ public class TestFBOMRTNEWT01 extends UITestCase { final NativeSurface ns = gl.getContext().getGLReadDrawable().getNativeSurface(); if(last_snap_size[0] != ns.getWidth() && last_snap_size[1] != ns.getHeight()) { gl.glFinish(); // sync .. no swap buffers yet! - snapshot(getSimpleTestName("."), step_i, null, gl, screenshot, TextureIO.PNG, null); // overwrite ok + snapshot(step_i, null, gl, screenshot, TextureIO.PNG, null); // overwrite ok last_snap_size[0] = ns.getWidth(); last_snap_size[1] = ns.getHeight(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java index b384c9327..b3c542c63 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java @@ -106,7 +106,7 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { if(dw<800) { System.err.println("XXX: "+dw+"x"+dh+", c "+c); if(0 == c%3) { - snapshot(getSimpleTestName("."), i++, "msaa"+demo.getMSAA(), drawable.getGL(), screenshot, TextureIO.PNG, null); + snapshot(i++, "msaa"+demo.getMSAA(), drawable.getGL(), screenshot, TextureIO.PNG, null); } if( 3 == c ) { new Thread() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java new file mode 100644 index 000000000..3ecf89bfc --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java @@ -0,0 +1,298 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.QuitAdapter; + +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.FPSAnimator; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; + +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.SurfaceUpdatedListener; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.AfterClass; +import org.junit.Test; + +/** + * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + *

    + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + *

    + *

    + * This test simulates shared off-thread GL context / texture usage, + * where the producer use FBOs and delivers shared textures. + * The receiver blends the shared textures onscreen. + * In detail the test consist of: + *

      + *
    • 2 {@link GLOffscreenAutoDrawable.FBO} double buffered + *
        + *
      • each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)
      • + *
      • both run within one {@link FPSAnimator} @ 30fps
      • + *
      • produce a texture
      • + *
      • notify the onscreen renderer about new textureID (swapping double buffer)
      • + *
    • + *
    • 1 onscreen {@link GLWindow} + *
        + *
      • shares it's {@link GLContext} w/ above FBOs
      • + *
      • running within one {@link Animator} at v-sync
      • + *
      • uses the shared FBO textures and blends them onscreen
      • + *
    • + *
    + *

    + */ +public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { + static long duration = 500; // ms + static int swapInterval = 1; + static boolean showFPS = false; + static boolean forceES2 = false; + static boolean mainRun = false; + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + System.err.println("requested: vsync "+swapInterval+", "+caps); + + final GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); + if(mainRun) { + glWindow.setSize(512, 512); + } else { + glWindow.setSize(256, 256); + } + // eager initialization of context + glWindow.setVisible(true); + glWindow.display(); + + final int fbod1_texUnit = 0; + final int fbod2_texUnit = 1; + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable(); + // fbodCaps.setDoubleBuffered(false); + + final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, fbod2_texUnit); + + // FBOD1 + final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO) + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen! + fbod1.setTextureUnit(fbod1_texUnit); + { + GearsES2 demo0 = new GearsES2(-1); + fbod1.addGLEventListener(demo0); + demo0.setIgnoreFocus(true); + } + fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); + } }); + fbod1.display(); // init + System.err.println("FBOD1 "+fbod1); + Assert.assertTrue(fbod1.isInitialized()); + + // FBOD2 + final GLOffscreenAutoDrawable.FBO fbod2 = (GLOffscreenAutoDrawable.FBO) + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + fbod2.setTextureUnit(fbod2_texUnit); + fbod2.addGLEventListener(new RedSquareES2(-1)); + fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName()); + } }); + fbod2.display(); // init + System.err.println("FBOD2 "+fbod2); + Assert.assertTrue(fbod2.isInitialized()); + + // preinit texIDs + mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); + mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName()); + + glWindow.addGLEventListener(mixerDemo); + glWindow.addGLEventListener(new GLEventListener() { + int i=0, c=0; + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + if(mainRun) return; + + final int dw = drawable.getWidth(); + final int dh = drawable.getHeight(); + c++; + + if(dw<800) { + System.err.println("XXX: "+dw+"x"+dh+", c "+c); + if(8 == c) { + snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); + } + if(9 == c) { + c=0; + new Thread() { + @Override + public void run() { + glWindow.setSize(dw+256, dh+256); + } }.start(); + } + } + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + fbod1.setSize(width, height); + fbod2.setSize(width, height); + } + }); + + final FPSAnimator animator0 = new FPSAnimator(30); + animator0.add(fbod1); + animator0.add(fbod2); + + final Animator animator1 = new Animator(); + animator1.add(glWindow); + + QuitAdapter quitAdapter = new QuitAdapter(); + + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + glWindow.addWindowListener(new WindowAdapter() { + public void windowResized(WindowEvent e) { + System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + public void windowMoved(WindowEvent e) { + System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + }); + + animator0.start(); + animator1.start(); + // glWindow.setSkipContextReleaseThread(animator.getThread()); + + glWindow.setVisible(true); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + animator0.setUpdateFPSFrames(30, showFPS ? System.err : null); + animator1.setUpdateFPSFrames(60, showFPS ? System.err : null); + + while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration() + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + *

    + *

    + * This test simulates shared on-thread GL context / texture usage, + * where the producer uses an FBO and delivers a shared texture. + * The receiver draws the shared texture onscreen. + * In detail the test consist of: + *

      + *
    • 1 {@link GLOffscreenAutoDrawable.FBO} double buffered + *
        + * + *
      • running within common {@link Animator} @ 60fps
      • + *
      • produce a texture
      • + *
      • notify the onscreen renderer about new textureID (swapping double buffer)
      • + *
    • + *
    • 1 onscreen {@link GLWindow} + *
        + *
      • shares it's {@link GLContext} w/ above FBO
      • + *
      • running within common {@link Animator} @ 60fps
      • + *
      • uses the shared FBO texture and draws it onscreen
      • + *
    • + *
    + *

    + */ +public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { + static long duration = 500; // ms + static int swapInterval = 1; + static boolean showFPS = false; + static boolean forceES2 = false; + static boolean mainRun = false; + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); + System.err.println("requested: vsync "+swapInterval+", "+caps); + + final GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); + if(mainRun) { + glWindow.setSize(512, 512); + } else { + glWindow.setSize(256, 256); + } + // eager initialization of context + glWindow.setVisible(true); + glWindow.display(); + + final int fbod1_texUnit = 0; + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable(); + // fbodCaps.setDoubleBuffered(false); + + final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, 0); + + // FBOD1 + final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO) + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen! + fbod1.setTextureUnit(fbod1_texUnit); + { + GearsES2 demo0 = new GearsES2(-1); + fbod1.addGLEventListener(demo0); + demo0.setIgnoreFocus(true); + } + fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { + @Override + public void surfaceUpdated(Object updater, NativeSurface ns, long when) { + mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); + } }); + fbod1.display(); // init + System.err.println("FBOD1 "+fbod1); + Assert.assertTrue(fbod1.isInitialized()); + + // preinit texIDs + mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); + + glWindow.addWindowListener(new WindowAdapter() { + @Override + public void windowResized(WindowEvent e) { + fbod1.setSize(glWindow.getWidth(), glWindow.getHeight()); + } + }); + glWindow.addGLEventListener(mixerDemo); + glWindow.addGLEventListener(new GLEventListener() { + int i=0, c=0; + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + if(mainRun) return; + + final int dw = drawable.getWidth(); + final int dh = drawable.getHeight(); + c++; + + if(dw<800) { + System.err.println("XXX: "+dw+"x"+dh+", c "+c); + if(8 == c) { + snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); + } + if(9 == c) { + c=0; + new Thread() { + @Override + public void run() { + glWindow.setSize(dw+256, dh+256); + } }.start(); + } + } + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + final Animator animator1 = new Animator(); + animator1.add(fbod1); + animator1.add(glWindow); + + QuitAdapter quitAdapter = new QuitAdapter(); + + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + glWindow.addWindowListener(new WindowAdapter() { + public void windowResized(WindowEvent e) { + System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + public void windowMoved(WindowEvent e) { + System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + }); + + animator1.start(); + // glWindow.setSkipContextReleaseThread(animator.getThread()); + + glWindow.setVisible(true); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + animator1.setUpdateFPSFrames(60, showFPS ? System.err : null); + + while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration() + * Each test creates a {@link GLDrawable} using the + * {@link GLDrawableFactory#createGLDrawable(javax.media.nativewindow.NativeSurface) factory model}. + * The {@link GLContext} is derived {@link GLDrawable#createContext(GLContext) from the drawable}. + *

    + *

    + * Finally a {@link GLAutoDrawableDelegate} is created with the just created {@link GLDrawable} and {@link GLContext}. + * It is being used to run the {@link GLEventListener}. + *

    + */ +public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + // + // Create native windowing resources .. X11/Win/OSX + // + final Window window = NewtFactory.createWindow(reqGLCaps); + Assert.assertNotNull(window); + window.setSize(widthStep*szStep, heightStep*szStep); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + System.out.println("Window: "+window.getClass().getName()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = window.getGraphicsConfiguration().getChosenCapabilities(); + System.out.println("Window Caps Pre_GL: "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + System.out.println("Drawable Pre-GL(0): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); + + // + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + System.out.println("Window Caps PostGL : "+window.getGraphicsConfiguration().getChosenCapabilities()); + System.out.println("Drawable Post-GL(1): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + int res = context.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + context.release(); + + System.out.println("Chosen GL Caps(2): "+drawable.getChosenGLCapabilities()); + System.out.println("Chosen GL CTX (2): "+context.getGLVersion()); + System.out.println("Drawable Post-GL(2): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); // destroys drawable/context + window.destroy(); // destroys the actual window, incl. the device + } + }; + + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + + @Override + public void windowDestroyNotify(WindowEvent e) { + glad.windowDestroyNotifyOp(); + } + }); + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + window.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + window.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + glad.destroy(); + System.out.println("Fin Drawable: "+drawable); + System.out.println("Fin Window: "+window); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testGL2OffScreenBitmapSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testES2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + /** Not implemented ! + @Test + public void testES2OffScreenBitmapDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GLES2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new GearsES2(1)); + } */ + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java new file mode 100644 index 000000000..544d74aa5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java @@ -0,0 +1,317 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import jogamp.opengl.GLGraphicsConfigurationUtil; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + *

    + * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + *

    + */ +public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null); + + Assert.assertNotNull(glad); + System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + Assert.assertTrue(glad.isRealized()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); + System.out.println("Drawable Caps Pre_GL : "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + glad.display(); // force native context creation + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + System.out.println("Chosen GL CTX (1): "+glad.getContext().getGLVersion()); + + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + glad.destroy(); + System.out.println("Fin Drawable: "+glad); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOStencil() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setStencilBits(1); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOStencilMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setStencilBits(1); + reqGLCaps.setSampleBuffers(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testGL2OffScreenBitmapSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testES2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + /** Not implemented ! + @Test + public void testES2OffScreenBitmapDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GLES2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new GearsES2(1)); + } */ + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryOffscrnCapsNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java new file mode 100644 index 000000000..64a75716b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java @@ -0,0 +1,328 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.Dimension; +import java.awt.Frame; +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; + +import jogamp.nativewindow.jawt.JAWTUtil; +import jogamp.opengl.GLGraphicsConfigurationUtil; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Tests using a NEWT {@link GLWindow} {@link GLAutoDrawable auto drawable} for on- and offscreen cases. + *

    + * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}. + *

    + */ +public class TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + static void setGLCanvasSize(final Frame frame, final GLCanvas glc, final int width, final int height) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + final Dimension new_sz = new Dimension(width, height); + glc.setMinimumSize(new_sz); + glc.setPreferredSize(new_sz); + glc.setSize(new_sz); + frame.pack(); + frame.validate(); + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + static interface MyGLEventListener extends GLEventListener { + void setMakeSnapshot(); + } + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + if(reqGLCaps.isOnscreen() && JAWTUtil.isOffscreenLayerRequired()) { + System.err.println("onscreen layer n/a"); + return; + } + if(!reqGLCaps.isOnscreen() && !JAWTUtil.isOffscreenLayerSupported()) { + System.err.println("offscreen layer n/a"); + return; + } + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + // + // Create native windowing resources .. X11/Win/OSX + // + final GLCanvas glad = new GLCanvas(reqGLCaps); // will implicit trigger offscreen layer - if !onscreen && supported + Assert.assertNotNull(glad); + Dimension glc_sz = new Dimension(widthStep*szStep, heightStep*szStep); + glad.setMinimumSize(glc_sz); + glad.setPreferredSize(glc_sz); + glad.setSize(glc_sz); + final Frame frame = new Frame(getSimpleTestName(".")); + Assert.assertNotNull(frame); + frame.add(glad); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + + Assert.assertTrue(AWTRobotUtil.waitForVisible(glad, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glad, true)); + System.out.println("Window: "+glad.getClass().getName()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); + System.out.println("Window Caps Pre_GL: "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + glad.display(); // force native context creation + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + { + final GLDrawable actualDrawable = glad.getDelegatedDrawable(); + Assert.assertNotNull(actualDrawable); + System.out.println("Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+", "+actualDrawable.getNativeSurface().getClass().getName()); + } + + System.out.println("Window Caps PostGL : "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(1): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + { + GLContext context = glad.getContext(); + System.out.println("Chosen GL CTX (2): "+context.getGLVersion()); + Assert.assertNotNull(context); + Assert.assertTrue(context.isCreated()); + } + + System.out.println("Chosen GL Caps(2): "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(2): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + setGLCanvasSize(frame, glad, widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + glad.display(); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + setGLCanvasSize(frame, glad, widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + glad.display(); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.remove(glad); + frame.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + System.out.println("Fin: "+glad); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OnScreen() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenAuto() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbuffer() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OnScreen() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenAuto() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBOMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbuffer() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java new file mode 100644 index 000000000..37ec44566 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java @@ -0,0 +1,351 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import jogamp.opengl.GLGraphicsConfigurationUtil; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Tests using a NEWT {@link GLWindow} {@link GLAutoDrawable auto drawable} for on- and offscreen cases. + *

    + * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}. + *

    + */ +public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static interface MyGLEventListener extends GLEventListener { + void setMakeSnapshot(); + } + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + // + // Create native windowing resources .. X11/Win/OSX + // + final GLWindow glad = GLWindow.create(reqGLCaps); + Assert.assertNotNull(glad); + glad.setSize(widthStep*szStep, heightStep*szStep); + glad.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glad, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glad, true)); + System.out.println("Window: "+glad.getClass().getName()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = glad.getGraphicsConfiguration().getChosenCapabilities(); + System.out.println("Window Caps Pre_GL: "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + { + final GLDrawable actualDrawable = glad.getDelegatedDrawable(); + Assert.assertNotNull(actualDrawable); + System.out.println("Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+", "+actualDrawable.getNativeSurface().getClass().getName()); + } + + System.out.println("Window Caps PostGL : "+glad.getGraphicsConfiguration().getChosenCapabilities()); + System.out.println("Drawable Post-GL(1): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + glad.display(); + { + GLContext context = glad.getContext(); + System.out.println("Chosen GL CTX (2): "+context.getGLVersion()); + Assert.assertNotNull(context); + Assert.assertTrue(context.isCreated()); + } + + System.out.println("Chosen GL Caps(2): "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(2): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + glad.destroy(); + System.out.println("Fin: "+glad); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testGL2OffScreenBitmapSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new Gears(1)); + } + + @Test + public void testES2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenPbufferSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setPBuffer(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + /** Not implemented ! + @Test + public void testES2OffScreenBitmapDblBuf() throws InterruptedException { + if(!checkProfile(GLProfile.GLES2)) { + return; + } + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new GearsES2(1)); + } */ + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java new file mode 100644 index 000000000..47fc99844 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java @@ -0,0 +1,300 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Frame; +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import jogamp.nativewindow.jawt.JAWTUtil; +import jogamp.opengl.GLGraphicsConfigurationUtil; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Tests using a NEWT {@link GLWindow} {@link GLAutoDrawable auto drawable} for on- and offscreen cases. + *

    + * The NEWT {@link GLAutoDrawable} is being used to run the {@link GLEventListener}. + *

    + */ +public class TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + static void setComponentSize(final Frame frame, final Component comp, final int width, final int height) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + final Dimension new_sz = new Dimension(width, height); + comp.setMinimumSize(new_sz); + comp.setPreferredSize(new_sz); + comp.setSize(new_sz); + frame.pack(); + frame.validate(); + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + static interface MyGLEventListener extends GLEventListener { + void setMakeSnapshot(); + } + + void doTest(boolean offscreenLayer, GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { + System.err.println("onscreen layer n/a"); + return; + } + if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + System.err.println("offscreen layer n/a"); + return; + } + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final GLCapabilitiesImmutable expGLCaps = offscreenLayer ? + GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable) : + GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + System.out.println("Expected GL Caps: "+expGLCaps); + + final GLWindow glad = GLWindow.create(reqGLCaps); + Assert.assertNotNull(glad); + + + final NewtCanvasAWT nca = new NewtCanvasAWT(glad); + Assert.assertNotNull(nca); + Dimension size0 = new Dimension(widthStep*szStep, heightStep*szStep); + nca.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported + nca.setPreferredSize(size0); + nca.setMinimumSize(size0); + nca.setSize(size0); + + final Frame frame = new Frame(getSimpleTestName(".")); + Assert.assertNotNull(frame); + frame.add(nca); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + + Assert.assertTrue(AWTRobotUtil.waitForVisible(glad, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glad, true)); + System.out.println("Window: "+glad.getClass().getName()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); + System.out.println("Window Caps Pre_GL: "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>5); + Assert.assertTrue(chosenCaps.getBlueBits()>5); + Assert.assertTrue(chosenCaps.getRedBits()>5); + + glad.display(); // force native context creation + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + { + final GLDrawable actualDrawable = glad.getDelegatedDrawable(); + Assert.assertNotNull(actualDrawable); + System.out.println("Drawable Pre-GL(0): "+actualDrawable.getClass().getName()+", "+actualDrawable.getNativeSurface().getClass().getName()); + } + + System.out.println("Window Caps PostGL : "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(1): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>5); + Assert.assertTrue(chosenGLCaps.getBlueBits()>5); + Assert.assertTrue(chosenGLCaps.getRedBits()>5); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + { + GLContext context = glad.getContext(); + System.out.println("Chosen GL CTX (2): "+context.getGLVersion()); + Assert.assertNotNull(context); + Assert.assertTrue(context.isCreated()); + } + + System.out.println("Chosen GL Caps(2): "+glad.getChosenGLCapabilities()); + System.out.println("Drawable Post-GL(2): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + setComponentSize(frame, nca, widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + glad.display(); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + setComponentSize(frame, nca, widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + glad.display(); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.remove(nca); + frame.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + glad.destroy(); + System.out.println("Fin: "+nca); + System.out.println("Fin: "+glad); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + @Test + public void testGL2OnScreenDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(false, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenLayerAuto() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + doTest(true, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBOMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setFBO(true); + reqGLCaps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(true, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenPbuffer() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setPBuffer(true); + reqGLCaps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow + doTest(true, reqGLCaps, new GearsES2(1)); + } + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.class.getName()); + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java deleted file mode 100644 index cd1107e25..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLCapabilities01NEWT.java +++ /dev/null @@ -1,266 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.io.IOException; - -import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import jogamp.opengl.GLGraphicsConfigurationUtil; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Window; -import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; - -public class TestGLCapabilities01NEWT extends UITestCase { - static final int width = 100; - static final int height = 100; - - boolean checkProfile(String profile) { - if( !GLProfile.isAvailable(profile) ) { - System.err.println("Profile "+profile+" n/a"); - return false; - } - return true; - } - - void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { - System.out.println("Requested GL Caps: "+reqGLCaps); - - final GLCapabilitiesImmutable expGLCaps; - if( GLGraphicsConfigurationUtil.isGLCapabilitiesOffscreenAutoSelection(reqGLCaps) ) { - final GLDrawableFactory f = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - final boolean fboAvailable = true ; // f.canCreateFBO(null, reqGLCaps.getGLProfile()); - final boolean pbufferAvailable = f.canCreateGLPbuffer(null); - expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); - } else { - expGLCaps = reqGLCaps; - } - System.out.println("Expected GL Caps: "+expGLCaps); - // - // Create native windowing resources .. X11/Win/OSX - // - final Window window = NewtFactory.createWindow(reqGLCaps); - Assert.assertNotNull(window); - window.setSize(width, height); - window.setVisible(true); - Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); - System.out.println("Window: "+window.getClass().getName()); - - // Check caps of NativeWindow config w/o GL - final CapabilitiesImmutable chosenCaps = window.getGraphicsConfiguration().getChosenCapabilities(); - System.out.println("Window Caps Pre_GL: "+chosenCaps); - Assert.assertNotNull(chosenCaps); - Assert.assertTrue(chosenCaps.getGreenBits()>5); - Assert.assertTrue(chosenCaps.getBlueBits()>5); - Assert.assertTrue(chosenCaps.getRedBits()>5); - - // - // Create native OpenGL resources .. XGL/WGL/CGL .. - // equivalent to GLAutoDrawable methods: setVisible(true) - // - final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - - final GLDrawable drawable = factory.createGLDrawable(window); - Assert.assertNotNull(drawable); - System.out.println("Drawable Pre-GL(0): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); - - // - drawable.setRealized(true); - Assert.assertTrue(drawable.isRealized()); - - System.out.println("Window Caps PostGL : "+window.getGraphicsConfiguration().getChosenCapabilities()); - System.out.println("Drawable Post-GL(1): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); - - // Check caps of GLDrawable after realization - final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities(); - System.out.println("Chosen GL Caps(1): "+chosenGLCaps); - Assert.assertNotNull(chosenGLCaps); - Assert.assertTrue(chosenGLCaps.getGreenBits()>5); - Assert.assertTrue(chosenGLCaps.getBlueBits()>5); - Assert.assertTrue(chosenGLCaps.getRedBits()>5); - Assert.assertTrue(chosenGLCaps.getDepthBits()>4); - Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); - Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); - Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); - Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); - if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { - // dbl buffer may be disabled w/ offscreen pbuffer and bitmap - Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); - } - - GLContext context = drawable.createContext(null); - Assert.assertNotNull(context); - int res = context.makeCurrent(); - Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); - context.release(); - - System.out.println("Chosen GL Caps(2): "+drawable.getChosenGLCapabilities()); - System.out.println("Drawable Post-GL(2): "+drawable.getClass().getName()+", "+drawable.getNativeSurface().getClass().getName()); - - drawable.setRealized(false); - window.destroy(); - } - - @Test - public void testAvailableInfo() { - GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); - if(null != f) { - System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); - } - f = GLDrawableFactory.getEGLFactory(); - if(null != f) { - System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); - } - } - - @Test - public void testGL2OnScreenDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testGL2OffScreenAutoDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - reqGLCaps.setOnscreen(false); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testGL2OffScreenFBODblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setFBO(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setPBuffer(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GL2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setBitmap(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testES2OnScreenDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testES2OffScreenAutoDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - reqGLCaps.setOnscreen(false); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testES2OffScreenFBODblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setFBO(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - @Test - public void testES2OffScreenPbufferDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setPBuffer(true); - doTest(reqGLCaps, new GearsES2(1)); - } - - /** Not implemented ! - @Test - public void testES2OffScreenBitmapDblBuf() throws InterruptedException { - if(!checkProfile(GLProfile.GLES2)) { - return; - } - final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); - reqGLCaps.setOnscreen(false); - reqGLCaps.setBitmap(true); - doTest(reqGLCaps, new GearsES2(1)); - } */ - - public static void main(String args[]) throws IOException { - org.junit.runner.JUnitCore.main(TestGLCapabilities01NEWT.class.getName()); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java index cece4c6d5..4c1130498 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java @@ -39,13 +39,14 @@ import com.jogamp.newt.event.WindowUpdateEvent; import com.jogamp.newt.opengl.GLWindow; import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLAutoDrawableDelegate; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.GLAutoDrawableDelegate; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -81,14 +82,17 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); - GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - GLDrawable drawable = factory.createGLDrawable(window); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable drawable = factory.createGLDrawable(window); Assert.assertNotNull(drawable); drawable.setRealized(true); Assert.assertTrue(drawable.isRealized()); - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false) { + final GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) { @Override protected void destroyImplInLock() { super.destroyImplInLock(); @@ -104,7 +108,7 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { } @Override public void windowResized(WindowEvent e) { - glad.windowResizedOp(); + glad.windowResizedOp(window.getWidth(), window.getHeight()); } @Override public void windowDestroyNotify(WindowEvent e) { @@ -123,9 +127,13 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); // no GLContext! GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); // no GLContext! - // create single context using glad1 and assign it to glad1 + // create single context using glad1 and assign it to glad1, + // after destroying the prev. context! { - GLContext singleCtx = glad1.createContext(null); + final GLContext oldCtx = glad1.getContext(); + Assert.assertNotNull(oldCtx); + oldCtx.destroy(); + final GLContext singleCtx = glad1.createContext(null); Assert.assertNotNull(singleCtx); int res = singleCtx.makeCurrent(); Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java deleted file mode 100644 index a6e9cfb07..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLDrawable01NEWT.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.io.IOException; - -import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.opengl.GL; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Window; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; - -public class TestGLDrawable01NEWT extends UITestCase { - static final int width = 200, height = 200; - - void doTest(String profile, boolean onscreen, boolean fbo, boolean pbuffer) throws InterruptedException { - if( !GLProfile.isAvailable(profile) ) { - System.err.println("Profile "+profile+" n/a"); - return; - } - - final GLProfile glp = GLProfile.get(profile); - final GLCapabilities reqGLCaps = new GLCapabilities(glp); - - reqGLCaps.setOnscreen(onscreen); - reqGLCaps.setPBuffer(!onscreen && pbuffer); - reqGLCaps.setFBO(!onscreen && fbo); - reqGLCaps.setDoubleBuffered(onscreen); - // System.out.println("Requested: "+caps); - - // - // Create native windowing resources .. X11/Win/OSX - // - Window window = NewtFactory.createWindow(reqGLCaps); - Assert.assertNotNull(window); - window.setSize(width, height); - window.setVisible(true); - AWTRobotUtil.waitForVisible(window, true); - AWTRobotUtil.waitForRealized(window, true); - // System.out.println("Created: "+window); - - // Check caps of NativeWindow config w/o GL - final CapabilitiesImmutable chosenCaps = window.getGraphicsConfiguration().getChosenCapabilities(); - Assert.assertNotNull(chosenCaps); - Assert.assertTrue(chosenCaps.getGreenBits()>5); - Assert.assertTrue(chosenCaps.getBlueBits()>5); - Assert.assertTrue(chosenCaps.getRedBits()>5); - - // - // Create native OpenGL resources .. XGL/WGL/CGL .. - // equivalent to GLAutoDrawable methods: setVisible(true) - // - final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - - final GLDrawable drawable = factory.createGLDrawable(window); - Assert.assertNotNull(drawable); - // System.out.println("Pre: "+drawable); - // - drawable.setRealized(true); - Assert.assertTrue(drawable.isRealized()); - - // Check caps of GLDrawable after realization - final GLCapabilitiesImmutable chosenGLCaps = drawable.getChosenGLCapabilities(); - Assert.assertNotNull(chosenGLCaps); - Assert.assertTrue(chosenGLCaps.getGreenBits()>5); - Assert.assertTrue(chosenGLCaps.getBlueBits()>5); - Assert.assertTrue(chosenGLCaps.getRedBits()>5); - Assert.assertTrue(chosenGLCaps.getDepthBits()>4); - Assert.assertEquals(reqGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); - Assert.assertEquals(reqGLCaps.isOnscreen(), chosenGLCaps.getDoubleBuffered()); // offscreen shall be !dbl-buffer - // System.out.println("Post: "+drawable); - - GLContext context = drawable.createContext(null); - Assert.assertNotNull(context); - // System.out.println(context); - - int res = context.makeCurrent(); - Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); - - // draw something .. - final GL gl = context.getGL(); - gl.glClearColor(1, 1, 1, 1); - gl.glEnable(GL.GL_DEPTH_TEST); - Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - gl.glViewport(0, 0, width, height); - gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - - drawable.swapBuffers(); - context.release(); - - Thread.sleep(50); - - context.destroy(); - drawable.setRealized(false); - window.destroy(); - // System.out.println("Final: "+window); - } - - @Test - public void testGL2OnScreen() throws InterruptedException { - doTest(GLProfile.GL2, true, false, false); - } - - @Test - public void testES2OnScreen() throws InterruptedException { - doTest(GLProfile.GLES2, true, false, false); - } - - @Test - public void testGL2PBuffer() throws InterruptedException { - doTest(GLProfile.GL2, false, false, true); - } - - @Test - public void testES2PBuffer() throws InterruptedException { - doTest(GLProfile.GLES2, false, false, true); - } - - // @Test // TODO: FBO-Drawable via createGLDrawable and pre-exisiting NativeSurface - public void testGL2FBO() throws InterruptedException { - doTest(GLProfile.GL2, false, true, false); - } - - // @Test // TODO: FBO-Drawable via createGLDrawable and pre-exisiting NativeSurface - public void testES2FBO() throws InterruptedException { - doTest(GLProfile.GLES2, false, true, false); - } - - public static void main(String args[]) throws IOException { - org.junit.runner.JUnitCore.main(TestGLDrawable01NEWT.class.getName()); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java index e4245ef11..d4f3fece5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java @@ -32,14 +32,11 @@ import java.util.Collections; import java.util.SortedSet; import java.util.TreeSet; -import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import jogamp.opengl.GLDrawableFactoryImpl; @@ -77,13 +74,11 @@ public class TestGLExtensionQueryOffscreen { @Test public void testJogl2ExtensionCheck2() { - GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); - GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory(); - GLCapabilitiesChooser glCapsChooser = new DefaultGLCapabilitiesChooser(); - AbstractGraphicsDevice agd = factory.getDefaultDevice(); + final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); - GLAutoDrawable drawable = factory.createGLPbuffer(agd, caps, glCapsChooser, 256, 256, null); - GLContext context = drawable.getContext(); + final GLContext context = drawable.getContext(); context.makeCurrent(); String extensions; try { @@ -94,8 +89,8 @@ public class TestGLExtensionQueryOffscreen { String[] tabExtensions = extensions.split(" "); SortedSet setExtensions = new TreeSet(); Collections.addAll(setExtensions, tabExtensions); - System.out.println("DefaulContext: "+context); - System.out.println("DefaulContext: "+setExtensions); + System.out.println("DefaultContext: "+context); + System.out.println("DefaultContext: "+setExtensions); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java index 33a9b7799..c1b7464e7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java @@ -11,12 +11,14 @@ import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLPbuffer; import javax.media.opengl.GLProfile; /** * Tests the closing the device of GLWindow and GLPBuffer in JOGL */ +@SuppressWarnings("deprecation") public class TestNEWTCloseX11DisplayBug565 { @Test @@ -59,7 +61,7 @@ public class TestNEWTCloseX11DisplayBug565 { @Test - public void testX11WindowMemoryLeakOffscreenWindow() throws Exception { + public void testX11WindowMemoryLeakGLPbuffer() throws Exception { GLProfile.initSingleton(); // ensure shared resource runner is done try { for ( int j = 0; j < 10; j++ ) { @@ -100,6 +102,48 @@ public class TestNEWTCloseX11DisplayBug565 { } } + @Test + public void testX11WindowMemoryLeakFBOAutoDrawable() throws Exception { + GLProfile.initSingleton(); // ensure shared resource runner is done + try { + for ( int j = 0; j < 10; j++ ) { + final int open0; + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + open0 = X11Util.getOpenDisplayConnectionNumber(); + } else { + open0 = 0; + } + final GLProfile glp = GLProfile.getDefault( ); + GLCapabilitiesImmutable caps = new GLCapabilities( glp ); + + + GLOffscreenAutoDrawable buffer = GLDrawableFactory.getFactory( glp ).createOffscreenAutoDrawable( + null, + caps, + new DefaultGLCapabilitiesChooser(), + 256, + 256, + null + ); + buffer.display(); + buffer.destroy(); + + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + final int openD = X11Util.getOpenDisplayConnectionNumber() - open0; + if(openD > 0) { + X11Util.dumpOpenDisplayConnections(); + X11Util.dumpPendingDisplayConnections(); + Assert.assertEquals("New display connection didn't close", 0, openD); + } + } + } + } + catch ( Exception e ) { + e.printStackTrace(); + Assert.fail(e.getMessage()); + } + } + public static void main(String args[]) { org.junit.runner.JUnitCore.main(TestNEWTCloseX11DisplayBug565.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java new file mode 100644 index 000000000..d181800c5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java @@ -0,0 +1,236 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Frame; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; + +import jogamp.nativewindow.jawt.JAWTUtil; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.os.Platform; +import com.jogamp.newt.Window; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { + static boolean useMSAA = false; + static boolean addComp = true; + static int swapInterval = 1; + static boolean shallUseOffscreenPBufferLayer = false; + static boolean noAnimation = false; + static Dimension frameSize0; + static Dimension frameSize1; + static Dimension preferredGLSize; + static long durationPerTest = 1000; + + @BeforeClass + public static void initClass() { + frameSize0 = new Dimension(500,300); + frameSize1 = new Dimension(800,600); + preferredGLSize = new Dimension(400,200); + } + + private void setupFrameAndShow(final Frame f, java.awt.Component comp) throws InterruptedException, InvocationTargetException { + + Container c = new Container(); + c.setLayout(new BorderLayout()); + c.add(new Button("north"), BorderLayout.NORTH); + c.add(new Button("south"), BorderLayout.SOUTH); + c.add(new Button("east"), BorderLayout.EAST); + c.add(new Button("west"), BorderLayout.WEST); + c.add(comp, BorderLayout.CENTER); + + f.setLayout(new BorderLayout()); + f.add(new Button("NORTH"), BorderLayout.NORTH); + f.add(new Button("SOUTH"), BorderLayout.SOUTH); + f.add(new Button("EAST"), BorderLayout.EAST); + f.add(new Button("WEST"), BorderLayout.WEST); + f.add(c, BorderLayout.CENTER); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f.pack(); + f.validate(); + f.setVisible(true); + }}); + } + + private void end(GLAnimatorControl actrl, final Frame f, Window w) throws InterruptedException, InvocationTargetException { + actrl.stop(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f.dispose(); + } } ); + if(null != w) { + w.destroy(); + } + } + + @Test + public void testInfo00() throws InterruptedException, InvocationTargetException { + System.err.println("Java Version: "+Platform.getJavaVersionNumber()); + System.err.println("OS Version: "+Platform.getOSVersionNumber()); + System.err.println("JAWTUtil.isOffscreenLayerRequired(): "+JAWTUtil.isOffscreenLayerRequired()); + System.err.println("JAWTUtil.isOffscreenLayerSupported(): "+JAWTUtil.isOffscreenLayerSupported()); + } + + @Test + public void testOffscreenLayerGLCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException { + testOffscreenLayerGLCanvas_Impl(true); + } + + private void testOffscreenLayerGLCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException { + if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { + System.err.println("onscreen layer n/a"); + return; + } + if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + System.err.println("offscreen layer n/a"); + return; + } + final Frame frame1 = new Frame("AWT Parent Frame"); + + GLCapabilities caps = new GLCapabilities(null); + if(useMSAA) { + caps.setNumSamples(4); + caps.setSampleBuffers(true); + } + if(shallUseOffscreenPBufferLayer) { + caps.setPBuffer(true); + caps.setOnscreen(true); // simulate normal behavior .. + } + final GLCanvas glc = new GLCanvas(caps); + glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported + glc.setPreferredSize(preferredGLSize); + glc.setMinimumSize(preferredGLSize); + glc.setSize(preferredGLSize); + + GearsES2 demo1 = new GearsES2(swapInterval); + if(noAnimation) { + demo1.setDoRotation(false); + } + glc.addGLEventListener(demo1); + + frame1.setSize(frameSize0); + setupFrameAndShow(frame1, glc); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glc, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glc, true)); + Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, + glc.isOffscreenLayerSurfaceEnabled()); + + GLAnimatorControl animator1 = new Animator(glc); + if(!noAnimation) { + animator1.start(); + } + animator1.setUpdateFPSFrames(60, System.err); + + Thread.sleep(durationPerTest/2); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setSize(frameSize1); + frame1.pack(); + frame1.validate(); + }}); + + Thread.sleep(durationPerTest/2); + + end(animator1, frame1, null); + } + + public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { + Assert.assertNotNull(demo); + Assert.assertNotNull(glWindow); + Window window = glWindow.getDelegatedWindow(); + if(debug) { + MiscUtils.setFieldIfExists(demo, "glDebug", true); + MiscUtils.setFieldIfExists(demo, "glTrace", true); + } + if(!MiscUtils.setFieldIfExists(demo, "window", window)) { + MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); + } + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i + * {@link JFrame} . {@link Container}+ . {@link NewtCanvasAWT} . {@link GLWindow} + *

    + *

    + * + Container is the JFrame's implicit root content pane
    + *

    + */ public class TestFocus01SwingAWTRobot extends UITestCase { static int width, height; static long durationPerTest = 10; @@ -125,6 +135,10 @@ public class TestFocus01SwingAWTRobot extends UITestCase { AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button"); button.addKeyListener(buttonKA); eventCountAdapters.add(buttonKA); + AWTMouseAdapter buttonMA = new AWTMouseAdapter("Button"); + button.addMouseListener(buttonMA); + eventCountAdapters.add(buttonMA); + frame1.getContentPane().add(button, BorderLayout.NORTH); frame1.setSize(width, height); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -158,13 +172,18 @@ public class TestFocus01SwingAWTRobot extends UITestCase { Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); System.err.println("FOCUS AWT Button sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, button, buttonKA); + AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, + button, buttonMA); + AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, + button, buttonMA); // Request the AWT focus, which should automatically provide the NEWT window with focus. Thread.sleep(100); // allow event sync System.err.println("FOCUS NEWT Canvas/GLWindow request"); EventCountAdapterUtil.reset(eventCountAdapters); AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA); - Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); + Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA, + AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA)); System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java index a0efa53ad..d8a9640c1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java @@ -56,6 +56,15 @@ import java.io.IOException; import com.jogamp.opengl.test.junit.util.*; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +/** + * Testing focus traversal of an AWT component tree with {@link NewtCanvasAWT} attached. + *

    + * {@link JFrame} . {@link JPanel}+ . {@link Container} . {@link NewtCanvasAWT} . {@link GLWindow} + *

    + *

    + * + JPanel is set as JFrame's root content pane
    + *

    + */ public class TestFocus02SwingAWTRobot extends UITestCase { static int width, height; static long durationPerTest = 10; @@ -85,9 +94,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase { ArrayList eventCountAdapters = new ArrayList(); - /** - * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow - */ GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); GLEventListener demo1 = new GearsES2(); @@ -225,7 +231,9 @@ public class TestFocus02SwingAWTRobot extends UITestCase { System.err.println("FOCUS NEWT Canvas/GLWindow request"); EventCountAdapterUtil.reset(eventCountAdapters); AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthInnerFA); - Assert.assertTrue(AWTRobotUtil.waitForFocusCount(false, newtCanvasAWTFA)); + Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA, + AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA)); + Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); Assert.assertEquals(false, buttonNorthOuterFA.focusGained()); Assert.assertEquals(false, jFrame1FA.focusGained()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java index bf72348f9..e03b5e7d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindows01NEWT.java @@ -33,7 +33,6 @@ import org.junit.BeforeClass; import org.junit.Test; import javax.media.nativewindow.*; -import javax.media.nativewindow.util.Point; import com.jogamp.newt.*; import java.io.IOException; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 473f2f584..f7881615d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -36,7 +36,7 @@ import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; -class NewtAWTReparentingKeyAdapter extends KeyAdapter { +public class NewtAWTReparentingKeyAdapter extends KeyAdapter { Frame frame; NewtCanvasAWT newtCanvasAWT; GLWindow glWindow; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java deleted file mode 100644 index 4542fa47e..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingOffscreenLayer01GLCanvasAWT.java +++ /dev/null @@ -1,211 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt.parenting; - -import java.awt.BorderLayout; -import java.awt.Button; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.Frame; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; - -import javax.media.opengl.GLAnimatorControl; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.awt.GLCanvas; - -import jogamp.nativewindow.jawt.JAWTUtil; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.common.os.Platform; -import com.jogamp.newt.Window; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; - -public class TestParentingOffscreenLayer01GLCanvasAWT extends UITestCase { - static Dimension frameSize0; - static Dimension frameSize1; - static Dimension preferredGLSize; - static Dimension minGLSize; - static long durationPerTest = 1000; - - @BeforeClass - public static void initClass() { - frameSize0 = new Dimension(500,300); - frameSize1 = new Dimension(800,600); - preferredGLSize = new Dimension(400,200); - minGLSize = new Dimension(200,100); - } - - private void setupFrameAndShow(final Frame f, java.awt.Component comp) throws InterruptedException, InvocationTargetException { - - Container c = new Container(); - c.setLayout(new BorderLayout()); - c.add(new Button("north"), BorderLayout.NORTH); - c.add(new Button("south"), BorderLayout.SOUTH); - c.add(new Button("east"), BorderLayout.EAST); - c.add(new Button("west"), BorderLayout.WEST); - c.add(comp, BorderLayout.CENTER); - - f.setLayout(new BorderLayout()); - f.add(new Button("NORTH"), BorderLayout.NORTH); - f.add(new Button("SOUTH"), BorderLayout.SOUTH); - f.add(new Button("EAST"), BorderLayout.EAST); - f.add(new Button("WEST"), BorderLayout.WEST); - f.add(c, BorderLayout.CENTER); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - f.validate(); - f.setVisible(true); - }}); - } - private void end(GLAnimatorControl actrl, final Frame f, Window w) throws InterruptedException, InvocationTargetException { - actrl.stop(); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - f.dispose(); - } } ); - if(null != w) { - w.destroy(); - } - } - - @Test - public void testInfo00() throws InterruptedException, InvocationTargetException { - System.err.println("Java Version: "+Platform.getJavaVersionNumber()); - System.err.println("OS Version: "+Platform.getOSVersionNumber()); - System.err.println("JAWTUtil.isOffscreenLayerRequired(): "+JAWTUtil.isOffscreenLayerRequired()); - System.err.println("JAWTUtil.isOffscreenLayerSupported(): "+JAWTUtil.isOffscreenLayerSupported()); - } - - @Test - public void testOnscreenLayerGLCanvas_Onscreen() throws InterruptedException, InvocationTargetException { - testOffscreenLayerGLCanvas_Impl(false); - } - - @Test - public void testOffscreenLayerGLCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException { - testOffscreenLayerGLCanvas_Impl(true); - } - - private void testOffscreenLayerGLCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException { - if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { - System.err.println("onscreen layer n/a"); - return; - } - if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { - System.err.println("offscreen layer n/a"); - return; - } - final Frame frame1 = new Frame("AWT Parent Frame"); - - GLCapabilities glCaps = new GLCapabilities(null); - final GLCanvas glc = new GLCanvas(glCaps); - glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported - glc.setPreferredSize(preferredGLSize); - glc.setMinimumSize(minGLSize); - - GLEventListener demo1 = new GearsES2(1); - glc.addGLEventListener(demo1); - - frame1.setSize(frameSize0); - setupFrameAndShow(frame1, glc); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glc, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glc, true)); - Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, - glc.isOffscreenLayerSurfaceEnabled()); - - GLAnimatorControl animator1 = new Animator(glc); - animator1.start(); - - Thread.sleep(durationPerTest/2); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setSize(frameSize1); - frame1.validate(); - }}); - - Thread.sleep(durationPerTest/2); - - end(animator1, frame1, null); - } - - public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { - Assert.assertNotNull(demo); - Assert.assertNotNull(glWindow); - Window window = glWindow.getDelegatedWindow(); - if(debug) { - MiscUtils.setFieldIfExists(demo, "glDebug", true); - MiscUtils.setFieldIfExists(demo, "glTrace", true); - } - if(!MiscUtils.setFieldIfExists(demo, "window", window)) { - MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); - } - } - - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - - public static void main(String args[]) throws IOException { - for(int i=0; ivisible within TIME_OUT diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java index 3f989bfa4..a76b67d57 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTGLContext.java @@ -70,8 +70,8 @@ public class NEWTGLContext { Assert.assertNotNull(window); window.setSize(width, height); window.setVisible(true); - AWTRobotUtil.waitForVisible(window, true); - AWTRobotUtil.waitForRealized(window, true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); GLDrawable drawable = factory.createGLDrawable(window); diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java index c07d5b741..c42d9ff62 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java +++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java @@ -29,12 +29,14 @@ package com.jogamp.opengl.test.junit.util; import java.io.File; -import java.io.PrintWriter; -import java.io.StringWriter; +import java.util.Iterator; +import java.util.List; import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLEventListener; import com.jogamp.common.util.locks.SingletonInstance; import com.jogamp.opengl.util.GLReadBufferUtil; @@ -47,6 +49,8 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Rule; import org.junit.rules.TestName; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.TestClass; public abstract class UITestCase { @@ -58,9 +62,11 @@ public abstract class UITestCase { public static final long SINGLE_INSTANCE_LOCK_TO = 3*60*1000; // wait up to 3 min public static final long SINGLE_INSTANCE_LOCK_POLL = 1000; // poll every 1s - static volatile SingletonInstance singletonInstance; + private static volatile SingletonInstance singletonInstance; - static volatile boolean testSupported = true; + private static volatile boolean testSupported = true; + + private static volatile int maxMethodNameLen = 0; private static final synchronized void initSingletonInstance() { if( null == singletonInstance ) { @@ -77,6 +83,20 @@ public abstract class UITestCase { testSupported = v; } + public int getMaxTestNameLen() { + if(0 == maxMethodNameLen) { + int ml = 0; + final TestClass tc = new TestClass(getClass()); + final List testMethods = tc.getAnnotatedMethods(org.junit.Test.class); + for(Iterator iter=testMethods.iterator(); iter.hasNext(); ) { + final int l = iter.next().getName().length(); + if( ml < l ) { ml = l; } + } + maxMethodNameLen = ml; + } + return maxMethodNameLen; + } + public final String getTestMethodName() { return _unitTestName.getMethodName(); } @@ -120,13 +140,12 @@ public abstract class UITestCase { static final String unsupportedTestMsg = "Test not supported on this platform."; /** - * Takes a snapshot of the drawable's current framebuffer. Example filenames: + * Takes a snapshot of the drawable's current front framebuffer. Example filenames: *
    -     * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0004-0800x0600.png
    -     * TestFBODrawableNEWT.test01-F_rgba-I_rgba-S0_default-GL2-n0005-0800x0600.png
    +     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenFBOSglBuf____-n0001-msaa0-GLES2_-sw-fbobject-Bdbl-Frgb__Irgb_-S00_default-0400x0300.png
    +     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenPbufferDblBuf-n0003-msaa0-GLES2_-sw-pbuffer_-Bdbl-Frgb__Irgb_-S00_default-0200x0150.png
    +     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testGL2OffScreenPbufferSglBuf-n0003-msaa0-GL2___-hw-pbuffer_-Bone-Frgb__Irgb_-S00_default-0200x0150.png
          * 
    - * - * @param simpleTestName will be used as the filename prefix * @param sn sequential number * @param postSNDetail optional detail to be added to the filename after sn * @param gl the current GL context object. It's read drawable is being used as the pixel source and to gather some details which will end up in the filename. @@ -137,30 +156,80 @@ public abstract class UITestCase { * It shall not end with a directory separator, {@link File#separatorChar}. * If null the current working directory is being used. */ - public static void snapshot(String simpleTestName, int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) { + public void snapshot(int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) { if(null == fileSuffix) { fileSuffix = TextureIO.PNG; } - final StringWriter filenameSW = new StringWriter(); - { + final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; + final String simpleTestName = this.getSimpleTestName("."); + final String filenameBaseName; + { final GLDrawable drawable = gl.getContext().getGLReadDrawable(); final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); + final String accel = caps.getHardwareAccelerated() ? "hw" : "sw" ; + final String scrnm; + if(caps.isOnscreen()) { + scrnm = "onscreen"; + } else if(caps.isFBO()) { + scrnm = "fbobject"; + } else if(caps.isPBuffer()) { + scrnm = "pbuffer_"; + } else if(caps.isBitmap()) { + scrnm = "bitmap__"; + } else { + scrnm = "unknown_"; + } + final String dblb = caps.getDoubleBuffered() ? "dbl" : "one"; final String F_pfmt = readBufferUtil.hasAlpha() ? "rgba" : "rgb_"; final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; - final String aaext = caps.getSampleExtension(); final int samples = caps.getNumSamples() ; + final String aaext = caps.getSampleExtension(); postSNDetail = null != postSNDetail ? "-"+postSNDetail : ""; - final PrintWriter pw = new PrintWriter(filenameSW); - pw.printf("%s-n%04d%s-F_%s-I_%s-S%d_%s-%s-%04dx%04d.%s", - simpleTestName, sn, postSNDetail, F_pfmt, pfmt, samples, aaext, drawable.getGLProfile().getName(), - drawable.getWidth(), drawable.getHeight(), fileSuffix); + + filenameBaseName = String.format("%-"+maxSimpleTestNameLen+"s-n%04d%s-%-6s-%s-%s-B%s-F%s_I%s-S%02d_%s-%04dx%04d.%s", + simpleTestName, sn, postSNDetail, drawable.getGLProfile().getName(), accel, + scrnm, dblb, F_pfmt, pfmt, samples, aaext, + drawable.getWidth(), drawable.getHeight(), fileSuffix).replace(' ', '_'); } - final String filename = null != destPath ? destPath + File.separator + filenameSW.toString() : filenameSW.toString(); - System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename); + final String filename = null != destPath ? destPath + File.separator + filenameBaseName : filenameBaseName; + System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename+", maxTestNameLen "+maxSimpleTestNameLen+", <"+simpleTestName+">"); gl.glFinish(); // just make sure rendering finished .. if(readBufferUtil.readPixels(gl, false)) { readBufferUtil.write(new File(filename)); } - } + } + + public class SnapshotGLEventListener implements GLEventListener { + private final GLReadBufferUtil screenshot; + private volatile boolean makeShot = false; + private volatile int displayCount=0; + private volatile int reshapeCount=0; + public SnapshotGLEventListener(GLReadBufferUtil screenshot) { + this.screenshot = screenshot; + } + public SnapshotGLEventListener() { + this.screenshot = new GLReadBufferUtil(false, false); + } + + public void init(GLAutoDrawable drawable) {} + public void dispose(GLAutoDrawable drawable) {} + public void display(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": "+drawable.getWidth()+"x"+drawable.getHeight()+", makeShot "+makeShot); + if(makeShot) { + makeShot=false; + snapshot(displayCount, null, gl, screenshot, TextureIO.PNG, null); + } + displayCount++; + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + System.err.println(Thread.currentThread().getName()+": ** reshape: "+reshapeCount+": "+width+"x"+height+" - "+drawable.getWidth()+"x"+drawable.getHeight()); + reshapeCount++; + } + public void setMakeSnapshot() { + makeShot=true; + } + }; + } -- cgit v1.2.3 From e30c2c7d06847889d961d12b50e77e4dfd6e525f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Sep 2012 13:27:06 +0200 Subject: OSX: Capture 'invalid drawable' message cause by NSOpenGLContext::setView(NULL || incomplete-view) ; Add missing [ctx release] in MyNSOpenGLLayer ; Misc NSOpenGLContext::setView(NULL || incomplete-view) was called on 2 occasions: [1] - MacOSXCGLContext native createContext [2] - NSOpenGLLayer internals For [1], we simply don't call setView(..) ourselfs in case view is NULL or incomplete (invisible) For [2], we need to wrap the class 'MyNSOpenGLContext:NSOpenGLContext' and capture setView(NULL) ++ Add missing [ctx release] in MyNSOpenGLLayer, otherwise resource won't get dealloc'ed +++ Misc: - MacOSXCGLContext. contextRealized(true): set pbuffer -> ctx, otherwise 1st makeCurrent call will not catch it - MacOSXOnscreenCGLContext: don't add ContextUpdater to invisible ProxySurface's (dummy window) --- make/scripts/tests.sh | 11 +++- make/stub_includes/opengl/macosx-window-system.h | 2 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 15 +++-- .../macosx/cgl/MacOSXOnscreenCGLContext.java | 19 +++++-- .../macosx/MacOSXWindowSystemInterface-calayer.m | 65 ++++++++++++++++++++-- .../native/macosx/MacOSXWindowSystemInterface.m | 43 ++++++++++---- src/nativewindow/native/macosx/OSXmisc.m | 2 +- .../acore/TestOffscreenLayer01GLCanvasAWT.java | 12 ++++ .../acore/TestOffscreenLayer02NewtCanvasAWT.java | 12 ++++ 9 files changed, 152 insertions(+), 29 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d2e2db375..5051979d5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -32,7 +32,13 @@ MOSX=0 MOSX_MT=0 uname -a | grep -i Darwin && MOSX=1 if [ $MOSX -eq 1 ] ; then + echo setup OSX environment vars export NSZombieEnabled=YES + export NSTraceEvents=YES + export OBJC_PRINT_EXCEPTIONS=YES + echo NSZombieEnabled $NSZombieEnabled + echo NSTraceEvents $NSTraceEvents + echo OBJC_PRINT_EXCEPTIONS $OBJC_PRINT_EXCEPTIONS MOSX_MT=1 fi @@ -224,6 +230,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $* @@ -239,14 +246,14 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* diff --git a/make/stub_includes/opengl/macosx-window-system.h b/make/stub_includes/opengl/macosx-window-system.h index c627f67de..828e3c01e 100644 --- a/make/stub_includes/opengl/macosx-window-system.h +++ b/make/stub_includes/opengl/macosx-window-system.h @@ -32,7 +32,7 @@ NSView* getNSView(NSOpenGLContext* ctx); NSOpenGLContext* createContext(NSOpenGLContext* shareContext, NSView* nsView, - Bool allowIncompleteView, + Bool incompleteView, NSOpenGLPixelFormat* pixelFormat, Bool opaque, int* viewNotReady); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index ec29558d1..e04955d87 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -490,9 +490,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl } backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); - boolean allowIncompleteView = null != backingLayerHost; - if( !allowIncompleteView && surface instanceof ProxySurface ) { - allowIncompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); + boolean incompleteView = null != backingLayerHost; + if( !incompleteView && surface instanceof ProxySurface ) { + incompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); } long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor); if (pixelFormat == 0) { @@ -514,7 +514,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl screenVSyncTimeout = 1000000f / sRefreshRate; if(DEBUG) { System.err.println("NS create OSX>=lion "+isLionOrLater); - System.err.println("NS create allowIncompleteView: "+allowIncompleteView); + System.err.println("NS create incompleteView: "+incompleteView); System.err.println("NS create backingLayerHost: "+backingLayerHost); System.err.println("NS create share: "+share); System.err.println("NS create drawable type: "+drawable.getClass().getName()); @@ -546,7 +546,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl int[] viewNotReady = new int[1]; // Try to allocate a context with this ctx = CGL.createContext(share, - nsViewHandle, allowIncompleteView, + nsViewHandle, incompleteView, pixelFormat, chosenCaps.isBackgroundOpaque(), viewNotReady, 0); @@ -603,6 +603,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl } else if( chosenCaps.isPBuffer() && CGL.isNSOpenGLPixelBuffer(drawableHandle) ) { texID = 0; lastPBufferHandle = drawableHandle; + if(0 != drawableHandle) { // complete 'validatePBufferConfig(..)' procedure + CGL.setContextPBuffer(ctx, drawableHandle); + } } else { throw new GLException("BackingLayerHost w/ unknown handle (!FBO, !PBuffer): "+drawable); } @@ -648,7 +651,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl private final void validatePBufferConfig(long ctx) { final GLCapabilitiesImmutable chosenCaps = drawable.getChosenGLCapabilities(); final long drawableHandle = drawable.getHandle(); - if(chosenCaps.isPBuffer() && CGL.isNSOpenGLPixelBuffer(drawableHandle) && lastPBufferHandle != drawableHandle) { + if( chosenCaps.isPBuffer() && lastPBufferHandle != drawableHandle && CGL.isNSOpenGLPixelBuffer(drawableHandle) ) { // Must associate the pbuffer with our newly-created context lastPBufferHandle = drawableHandle; if(0 != drawableHandle) { diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java index e344fd461..447d18f68 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLContext.java @@ -39,6 +39,8 @@ package jogamp.opengl.macosx.cgl; +import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; @@ -60,7 +62,7 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext { @Override protected void drawableUpdatedNotify() throws GLException { final int w = drawable.getWidth(); - final int h = drawable.getHeight(); + final int h = drawable.getHeight(); final boolean updateContext = ( 0!=updateHandle && CGL.updateContextNeedsUpdate(updateHandle) ) || w != lastWidth || h != lastHeight; if(updateContext) { @@ -82,9 +84,18 @@ public class MacOSXOnscreenCGLContext extends MacOSXCGLContext { if(0 != updateHandle) { throw new InternalError("XXX1"); } - updateHandle = CGL.updateContextRegister(contextHandle, drawable.getHandle()); - if(0 == updateHandle) { - throw new InternalError("XXX2"); + final boolean incompleteView; + final NativeSurface surface = drawable.getNativeSurface(); + if( surface instanceof ProxySurface ) { + incompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); + } else { + incompleteView = false; + } + if(!incompleteView) { + updateHandle = CGL.updateContextRegister(contextHandle, drawable.getHandle()); + if(0 == updateHandle) { + throw new InternalError("XXX2"); + } } } return res; diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 63323b76d..f3495efff 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -25,6 +25,56 @@ // // #define DBG_PERF 1 +/** + * Capture setView(NULL), which produces a 'invalid drawable' message + * + * Also track lifecycle via DBG_PRINT messages, if VERBOSE is enabled! + */ +@interface MyNSOpenGLContext: NSOpenGLContext +{ +} +- (id)initWithFormat:(NSOpenGLPixelFormat *)format shareContext:(NSOpenGLContext *)share; +- (void)setView:(NSView *)view; +- (void)update; +- (void)dealloc; + +@end + +@implementation MyNSOpenGLContext + +- (id)initWithFormat:(NSOpenGLPixelFormat *)format shareContext:(NSOpenGLContext *)share +{ + DBG_PRINT("MyNSOpenGLContext.initWithFormat.0: format %p, share %p\n", format, share); + MyNSOpenGLContext * o = [super initWithFormat:format shareContext:share]; + DBG_PRINT("MyNSOpenGLContext.initWithFormat.X: new %p\n", o); + return o; +} + +- (void)setView:(NSView *)view +{ + DBG_PRINT("MyNSOpenGLContext.setView: this.0 %p, view %p\n", self, view); + if(NULL != view) { + [super setView:view]; + } + DBG_PRINT("MyNSOpenGLContext.setView.X\n"); +} + +- (void)update +{ + DBG_PRINT("MyNSOpenGLContext.update: this.0 %p, view %p\n", self, [self view]); + [super update]; + DBG_PRINT("MyNSOpenGLContext.update.X\n"); +} + +- (void)dealloc +{ + DBG_PRINT("MyNSOpenGLContext.dealloc: this.0 %p\n", self); + [super dealloc]; + DBG_PRINT("MyNSOpenGLContext.dealloc.X: %p\n", self); +} + +@end + @interface MyNSOpenGLLayer: NSOpenGLLayer { @private @@ -204,6 +254,8 @@ static const GLfloat gl_verts[] = { [self setOpaque: opaque ? YES : NO]; +#ifdef VERBOSE_ON + CGRect lRect = [self bounds]; if(NULL != pbuffer) { DBG_PRINT("MyNSOpenGLLayer::init (pbuffer) %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, bounds: %lf/%lf %lfx%lf (refcnt %d)\n", self, parentCtx, parentPixelFmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight, @@ -213,6 +265,7 @@ static const GLfloat gl_verts[] = { self, parentCtx, parentPixelFmt, opaque, (int)textureID, texWidth, texHeight, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); } +#endif return self; } @@ -293,9 +346,10 @@ static const GLfloat gl_verts[] = { - (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat { - NSOpenGLContext * nctx = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; - DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat: %p (refcnt %d) - pfmt %p, parent %p -> new-ctx %p\n", - self, (int)[self retainCount], pixelFormat, parentCtx, nctx); + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.0: %p (refcnt %d) - pfmt %p, parent %p\n", + self, (int)[self retainCount], pixelFormat, parentCtx); + NSOpenGLContext * nctx = [[MyNSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.X: new-ctx %p\n", nctx); return nctx; } @@ -324,7 +378,7 @@ static const GLfloat gl_verts[] = { if(NULL!=context) { [context makeCurrentContext]; - DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (with ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)texureID); + DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (with ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)textureID); if( 0 != textureID ) { glDeleteTextures(1, &textureID); @@ -333,7 +387,7 @@ static const GLfloat gl_verts[] = { [context clearDrawable]; } else { - DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (w/o ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)texureID); + DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (w/o ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)textureID); } pbuffer = NULL; [self setTextureID: 0]; @@ -346,6 +400,7 @@ static const GLfloat gl_verts[] = { pthread_mutex_lock(&renderLock); [self disableAnimation]; [self deallocPBuffer]; + [[self openGLContext] release]; [self release]; DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p (refcnt %d)\n", self, (int)[self retainCount]); pthread_mutex_unlock(&renderLock); diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index becd41bb2..48807ee29 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -446,7 +446,7 @@ NSOpenGLPixelFormat* createPixelFormat(int* iattrs, int niattrs, int* ivalues) { NSOpenGLPixelFormat* fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; // if(fmt == nil) { fallback to a [NSOpenGLView defaultPixelFormat] crashed (SIGSEGV) on 10.6.7/NV } - DBG_PRINT("createPixelFormat.X: pfmt %p\n", fmt); + DBG_PRINT("\ncreatePixelFormat.X: pfmt %p\n", fmt); [pool release]; return fmt; @@ -503,7 +503,7 @@ NSView* getNSView(NSOpenGLContext* ctx) { NSOpenGLContext* createContext(NSOpenGLContext* share, NSView* view, - Bool allowIncompleteView, + Bool incompleteView, NSOpenGLPixelFormat* fmt, Bool opaque, int* viewNotReady) @@ -512,13 +512,13 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, getRendererInfo(); - DBG_PRINT("createContext.0: share %p, view %p, allowIncompleteView %d, pixfmt %p, opaque %d\n", - share, view, (int)allowIncompleteView, fmt, opaque); + DBG_PRINT("createContext.0: share %p, view %p, incompleteView %d, pixfmt %p, opaque %d\n", + share, view, (int)incompleteView, fmt, opaque); if (view != nil) { Bool viewReady = true; - if(!allowIncompleteView) { + if(!incompleteView) { if ([view lockFocusIfCanDraw] == NO) { DBG_PRINT("createContext.1 [view lockFocusIfCanDraw] failed\n"); viewReady = false; @@ -527,7 +527,7 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, if(viewReady) { NSRect frame = [view frame]; if ((frame.size.width == 0) || (frame.size.height == 0)) { - if(!allowIncompleteView) { + if(!incompleteView) { [view unlockFocus]; } DBG_PRINT("createContext.2 view.frame size %dx%d\n", (int)frame.size.width, (int)frame.size.height); @@ -557,8 +557,10 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, GLint zeroOpacity = 0; [ctx setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity]; } - [ctx setView:view]; - if(!allowIncompleteView) { + if(!incompleteView) { + DBG_PRINT("createContext.3.0: setView\n"); + [ctx setView:view]; + DBG_PRINT("createContext.3.X: setView\n"); [view unlockFocus]; } } @@ -628,7 +630,12 @@ void setContextOpacity(NSOpenGLContext* ctx, int opacity) { void updateContext(NSOpenGLContext* ctx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [ctx update]; + NSView *nsView = [ctx view]; + if(NULL != nsView) { + DBG_PRINT("updateContext.0: ctx %p, ctx.view %p\n", ctx, nsView); + [ctx update]; + DBG_PRINT("updateContext.X\n"); + } [pool release]; } @@ -638,7 +645,10 @@ void copyContext(NSOpenGLContext* dest, NSOpenGLContext* src, int mask) { void* updateContextRegister(NSOpenGLContext* ctx, NSView* view) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + DBG_PRINT("updateContextRegister.0: ctx %p, view %p\n", ctx, view); ContextUpdater *contextUpdater = [[ContextUpdater alloc] initWithContext: ctx view: view]; + DBG_PRINT("updateContextRegister.X: ctxupd %p\n", contextUpdater); [pool release]; return contextUpdater; } @@ -658,47 +668,60 @@ void updateContextUnregister(void* updater) { ContextUpdater *contextUpdater = (ContextUpdater *)updater; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + DBG_PRINT("updateContextUnregister.0: ctxupd %p\n", contextUpdater); [contextUpdater release]; + DBG_PRINT("updateContextUnregister.X\n"); [pool release]; } NSOpenGLPixelBuffer* createPBuffer(int renderTarget, int internalFormat, int width, int height) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + DBG_PRINT("createPBuffer.0: renderTarget 0x%x, ifmt 0x%x, %dx%d: \n", renderTarget, internalFormat, width, height); NSOpenGLPixelBuffer* pBuffer = [[NSOpenGLPixelBuffer alloc] initWithTextureTarget:renderTarget textureInternalFormat:internalFormat textureMaxMipMapLevel:0 pixelsWide:width pixelsHigh:height]; + DBG_PRINT("createPBuffer.X: res %p\n", pBuffer); [pool release]; return pBuffer; } Bool destroyPBuffer(NSOpenGLPixelBuffer* pBuffer) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + DBG_PRINT("destroyPBuffer.0: pbuffer %p\n", pBuffer); [pBuffer release]; + DBG_PRINT("destroyPBuffer.X\n"); [pool release]; return true; } void setContextPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + DBG_PRINT("setContextPBuffer.0: ctx %p, pbuffer %p\n", ctx, pBuffer); [ctx setPixelBuffer: pBuffer cubeMapFace: 0 mipMapLevel: 0 currentVirtualScreen: [ctx currentVirtualScreen]]; + DBG_PRINT("setContextPBuffer.X\n"); [pool release]; } void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, GLenum colorBuffer) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + DBG_PRINT("setContextTextureImageToPBuffer.0: ctx %p, pbuffer %p, colorBuffer 0x%x\n", ctx, pBuffer, (int)colorBuffer); [ctx setTextureImageToPixelBuffer: pBuffer colorBuffer: colorBuffer]; + DBG_PRINT("setContextTextureImageToPBuffer.X\n"); [pool release]; } Bool isNSOpenGLPixelBuffer(uint64_t object) { NSObject *nsObj = (NSObject*) (intptr_t) object; - return [nsObj isMemberOfClass:[NSOpenGLPixelBuffer class]]; + DBG_PRINT("isNSOpenGLPixelBuffer.0: obj %p\n", object); + Bool res = [nsObj isMemberOfClass:[NSOpenGLPixelBuffer class]]; + DBG_PRINT("isNSOpenGLPixelBuffer.X: res %d\n", (int)res); + return res; } #include diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index d6ae7ed31..1cf41fc9d 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -633,7 +633,7 @@ JNIEXPORT jint JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenRefreshR if(0 == res) { res = 60; // default .. (experienced on OSX 10.6.8) } - fprintf(stderr, "GetScreenRefreshRate.X: %d\n", res); + DBG_PRINT(stderr, "GetScreenRefreshRate.X: %d\n", res); // [pool release]; JNF_COCOA_EXIT(env); return res; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java index d181800c5..3c9afbd2f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java @@ -33,7 +33,9 @@ import java.awt.Button; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLAnimatorControl; @@ -203,6 +205,7 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { } public static void main(String args[]) throws IOException { + boolean waitForKey = false; for(int i=0; i Date: Sun, 16 Sep 2012 15:39:10 +0200 Subject: Adding test case for Bug 611: On Windows XP is a performance issue, after JOGL initialization there seems to be a huge time lag when trying to open the Desktop folder. --- make/scripts/tests.sh | 11 +-- .../opengl/test/junit/jogl/awt/TestBug611AWT.java | 81 ++++++++++++++++++++++ 2 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug611AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5051979d5..724b7df97 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -35,10 +35,10 @@ if [ $MOSX -eq 1 ] ; then echo setup OSX environment vars export NSZombieEnabled=YES export NSTraceEvents=YES - export OBJC_PRINT_EXCEPTIONS=YES - echo NSZombieEnabled $NSZombieEnabled - echo NSTraceEvents $NSTraceEvents - echo OBJC_PRINT_EXCEPTIONS $OBJC_PRINT_EXCEPTIONS + #export OBJC_PRINT_EXCEPTIONS=YES + echo NSZombieEnabled $NSZombieEnabled 2>&1 | tee -a java-run.log + echo NSTraceEvents $NSTraceEvents 2>&1 | tee -a java-run.log + echo OBJC_PRINT_EXCEPTIONS $OBJC_PRINT_EXCEPTIONS 2>&1 | tee -a java-run.log MOSX_MT=1 fi @@ -253,7 +253,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -304,6 +304,7 @@ testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAW #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug611AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug611AWT.java new file mode 100644 index 000000000..b6a7639bd --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug611AWT.java @@ -0,0 +1,81 @@ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import java.awt.Desktop; +import java.io.File; + +import javax.media.opengl.GLProfile; + +import org.junit.Test; + +import com.jogamp.common.os.Platform; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * As reported in Bug 611, on Windows XP is a performance issue: + * After JOGL initialization there seems to be a huge time lag + * when trying to open the Desktop folder. + *

    + * Test disabled since showing the Desktop folder will + * disturb the 'desktop' .. if there is another way to show + * the performance bug, pls do so. + *

    + *

    + * Since Windows XP is out of life .. we may not care .. + *

    + */ +public class TestBug611AWT extends UITestCase { + + @Test + public void test00() { + // make junit happy + } + + // @Test + public void test01() { + try { + // System.setProperty("jogamp.gluegen.UseTempJarCache", "false"); + GLProfile.initSingleton(); + Desktop desktop; + if (Desktop.isDesktopSupported()) { + desktop = Desktop.getDesktop(); + } else { + desktop = null; + } + if(null != desktop) { + String home = System.getProperty("user.home"); + File homeFolder = null; + if(null != home) { + { + File tst = new File(home + "/Desktop"); + if( tst.canRead() ) { + homeFolder = tst; + } + } + if(null == homeFolder) { + File tst = new File(home); + if( tst.canRead() ) { + homeFolder = tst; + } + } + } + if(null == homeFolder) { + if(Platform.getOSType() == Platform.OSType.WINDOWS) { + homeFolder = new File("c:\\"); + } else { + homeFolder = new File("/"); + } + } + if(null != homeFolder) { + desktop.open(homeFolder); + } + } + } catch(Exception ex) { + ex.printStackTrace(); + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestBug611AWT.class.getName()); + } +} -- cgit v1.2.3 From 646714d3dab87396b9a3119bf90ca26e0b1c97ce Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Sep 2012 21:13:51 +0200 Subject: Fix Bug 601: Harmonize order of key events incl. auto-repeat and adding AUTOREPEAT_MASK modifier bit. Refine InputEvent toString(..) and list modifiers by name. As now described in NEWT's KeyEvent: +/** + * Key events are delivered in the following order: + *
      + *
    1. {@link #EVENT_KEY_PRESSED}
    2. + *
    3. {@link #EVENT_KEY_RELEASED}
    4. + *
    5. {@link #EVENT_KEY_TYPED}
    6. + *
    + * In case the native platform does not + * deliver keyboard events in the above order or skip events, + * the NEWT driver will reorder and inject synthetic events if required. + *

    + * Besides regular modifiers like {@link InputEvent##SHIFT_MASK} etc., + * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. + *

    + */ --- make/scripts/java-win64-dbg.bat | 6 +- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 6 +- src/newt/classes/com/jogamp/newt/Window.java | 2 + .../classes/com/jogamp/newt/event/InputEvent.java | 82 ++++++++++++++++++---- .../classes/com/jogamp/newt/event/KeyEvent.java | 26 ++++++- .../classes/com/jogamp/newt/event/MouseEvent.java | 12 +++- .../classes/com/jogamp/newt/event/NEWTEvent.java | 10 ++- .../classes/com/jogamp/newt/event/WindowEvent.java | 13 +++- .../com/jogamp/newt/event/WindowUpdateEvent.java | 11 ++- .../jogamp/newt/driver/macosx/WindowDriver.java | 20 ++++++ .../jogamp/newt/driver/windows/WindowDriver.java | 36 ++++++++-- src/newt/native/InputEvent.h | 22 +++--- src/newt/native/X11Display.c | 18 ++++- 14 files changed, 223 insertions(+), 45 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index b63438534..07722c78e 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -38,7 +38,8 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" -set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" @@ -53,4 +54,5 @@ REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=false" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" -%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win64-dbg.log 2>&1 +REM %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win64-dbg.log 2>&1 +%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index a4207b696..9ffbcd6d3 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -19,7 +19,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLPro REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* @@ -103,7 +103,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT -scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 724b7df97..7b39c3fbd 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -123,7 +123,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -263,7 +263,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* @@ -304,7 +304,7 @@ function testawtswt() { #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index e8537fec5..78e2abc6e 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -245,6 +245,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { String getTitle(); + /** @see #setPointerVisible(boolean) */ boolean isPointerVisible(); /** @@ -256,6 +257,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { */ void setPointerVisible(boolean pointerVisible); + /** @see #confinePointer(boolean) */ boolean isPointerConfined(); /** diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 819338ccb..148ac5962 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -34,22 +34,31 @@ package com.jogamp.newt.event; +import com.jogamp.newt.Window; + @SuppressWarnings("serial") public abstract class InputEvent extends NEWTEvent { - public static final int SHIFT_MASK = 1 << 0; - public static final int CTRL_MASK = 1 << 1; - public static final int META_MASK = 1 << 2; - public static final int ALT_MASK = 1 << 3; - public static final int ALT_GRAPH_MASK = 1 << 5; - public static final int BUTTON1_MASK = 1 << 6; - public static final int BUTTON2_MASK = 1 << 7; - public static final int BUTTON3_MASK = 1 << 8; - public static final int BUTTON4_MASK = 1 << 9; - public static final int BUTTON5_MASK = 1 << 10; - public static final int BUTTON6_MASK = 1 << 11; - public static final int CONFINED_MASK = 1 << 16; - public static final int INVISIBLE_MASK = 1 << 17; + public static final int SHIFT_MASK = 1 << 0; + public static final int CTRL_MASK = 1 << 1; + public static final int META_MASK = 1 << 2; + public static final int ALT_MASK = 1 << 3; + public static final int ALT_GRAPH_MASK = 1 << 5; + public static final int BUTTON1_MASK = 1 << 6; + public static final int BUTTON2_MASK = 1 << 7; + public static final int BUTTON3_MASK = 1 << 8; + public static final int BUTTON4_MASK = 1 << 9; + public static final int BUTTON5_MASK = 1 << 10; + public static final int BUTTON6_MASK = 1 << 11; + + /** Event is caused by auto-repeat. */ + public static final int AUTOREPEAT_MASK = 1 << 15; + + /** Pointer is confined, see {@link Window#confinePointer(boolean)}. */ + public static final int CONFINED_MASK = 1 << 16; + + /** Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ + public static final int INVISIBLE_MASK = 1 << 17; /** * Returns the corresponding button mask for the given button. @@ -76,30 +85,64 @@ public abstract class InputEvent extends NEWTEvent this.modifiers=modifiers; } + /** Return the modifier bits of this event, e.g. see {@link #SHIFT_MASK} .. etc. */ public int getModifiers() { return modifiers; } + /** {@link #getModifiers()} contains {@link #ALT_MASK}. */ public boolean isAltDown() { return (modifiers&ALT_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #ALT_GRAPH_MASK}. */ public boolean isAltGraphDown() { return (modifiers&ALT_GRAPH_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #CTRL_MASK}. */ public boolean isControlDown() { return (modifiers&CTRL_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #META_MASK}. */ public boolean isMetaDown() { return (modifiers&META_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #SHIFT_MASK}. */ public boolean isShiftDown() { return (modifiers&SHIFT_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #AUTOREPEAT_MASK}. */ + public boolean isAutoRepeat() { + return (modifiers&AUTOREPEAT_MASK)!=0; + } + /** {@link #getModifiers()} contains {@link #CONFINED_MASK}. Pointer is confined, see {@link Window#confinePointer(boolean)}. */ public boolean isConfined() { return (modifiers&CONFINED_MASK)!=0; } + /** {@link #getModifiers()} contains {@link #INVISIBLE_MASK}. Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ public boolean isInvisible() { return (modifiers&INVISIBLE_MASK)!=0; } + + public StringBuilder getModifiersString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("["); + boolean isFirst = true; + if(isShiftDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("shift"); } + if(isControlDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("ctrl"); } + if(isMetaDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("meta"); } + if(isAltDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("alt"); } + if(isAltGraphDown()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("altg"); } + if(isAutoRepeat()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("repeat"); } + for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { + if(isButtonDown(i)) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("button").append(i); } + } + if(isConfined()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("confined"); } + if(isInvisible()) { if(!isFirst) { sb.append(", "); } isFirst = false; sb.append("invisible"); } + sb.append("]"); + + return sb; + } /** * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}]. @@ -124,7 +167,18 @@ public abstract class InputEvent extends NEWTEvent } public String toString() { - return "InputEvent[modifiers: 0x"+Integer.toHexString(modifiers)+", "+super.toString()+"]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("InputEvent[modifiers: "); + getModifiersString(sb); + sb.append(", "); + super.toString(sb).append("]"); + return sb; } private final int modifiers; diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 4db661eeb..bd48981da 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -34,6 +34,21 @@ package com.jogamp.newt.event; +/** + * Key events are delivered in the following order: + *
      + *
    1. {@link #EVENT_KEY_PRESSED}
    2. + *
    3. {@link #EVENT_KEY_RELEASED}
    4. + *
    5. {@link #EVENT_KEY_TYPED}
    6. + *
    + * In case the native platform does not + * deliver keyboard events in the above order or skip events, + * the NEWT driver will reorder and inject synthetic events if required. + *

    + * Besides regular modifiers like {@link InputEvent##SHIFT_MASK} etc., + * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. + *

    + */ @SuppressWarnings("serial") public class KeyEvent extends InputEvent { @@ -54,8 +69,15 @@ public class KeyEvent extends InputEvent } public String toString() { - return "KeyEvent["+getEventTypeString(getEventType())+ - ", code "+keyCode+"("+toHexString(keyCode)+"), char '"+keyChar+"' ("+toHexString((int)keyChar)+"), isActionKey "+isActionKey()+", "+super.toString()+"]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(keyCode).append("(").append(toHexString(keyCode)).append("), char '").append(keyChar).append("' (").append(toHexString((int)keyChar)).append("), isActionKey ").append(isActionKey()).append(", "); + return super.toString(sb).append("]"); } public static String getEventTypeString(int type) { diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index ceaf7d47a..d293d2db7 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -165,7 +165,13 @@ public class MouseEvent extends InputEvent } public String toString() { - StringBuilder sb = new StringBuilder(); + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } sb.append("MouseEvent[").append(getEventTypeString(getEventType())) .append(", ").append(x).append("/").append(y) .append(", button ").append(button).append(", count ") @@ -182,8 +188,8 @@ public class MouseEvent extends InputEvent } sb.append("]"); } - sb.append(", ").append(super.toString()).append("]"); - return sb.toString(); + sb.append(", "); + return super.toString(sb).append("]"); } public static String getEventTypeString(int type) { diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 3f3817b91..fd5b69ccc 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -151,7 +151,14 @@ public class NEWTEvent extends java.util.EventObject { } public String toString() { - return "NEWTEvent[sys:"+isSystemEvent()+", source:"+getSource().getClass().getName()+", when:"+getWhen()+" d "+(System.currentTimeMillis()-getWhen())+"ms]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + return sb.append("NEWTEvent[sys:").append(isSystemEvent()).append(", source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); } public static String toHexString(int hex) { @@ -161,5 +168,4 @@ public class NEWTEvent extends java.util.EventObject { public static String toHexString(long hex) { return "0x" + Long.toHexString(hex); } - } diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java index f3d62d8c6..163b51439 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java @@ -39,6 +39,7 @@ package com.jogamp.newt.event; * NEWT will automatically handle component moves and resizes internally, regardless of whether a program is receiving these events or not.
    * The actual event semantic, here move and resize, is processed before the event is send.
    */ +@SuppressWarnings("serial") public class WindowEvent extends NEWTEvent { public static final int EVENT_WINDOW_RESIZED = 100; public static final int EVENT_WINDOW_MOVED = 101; @@ -64,8 +65,16 @@ public class WindowEvent extends NEWTEvent { default: return "unknown (" + type + ")"; } } + public String toString() { - return "WindowEvent["+getEventTypeString(getEventType()) + - ", " + super.toString() + "]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("WindowEvent[").append(getEventTypeString(getEventType())).append(", "); + return super.toString(sb).append("]"); } } diff --git a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java index 505939de2..e3f0373ec 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java @@ -30,6 +30,7 @@ package com.jogamp.newt.event; import javax.media.nativewindow.util.Rectangle; +@SuppressWarnings("serial") public class WindowUpdateEvent extends WindowEvent { final Rectangle bounds; @@ -44,6 +45,14 @@ public class WindowUpdateEvent extends WindowEvent { } public String toString() { - return "WindowUpdateEvent["+super.toString()+", "+bounds+"]"; + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("WindowUpdateEvent[").append(bounds).append(", "); + return super.toString(sb).append("]"); } } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index d0c0b8b20..4eeafb244 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -49,6 +49,7 @@ import jogamp.newt.WindowImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; +import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; public class WindowDriver extends WindowImpl implements MutableSurface, DriverClearFocus, DriverUpdatePosition { @@ -313,6 +314,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); if(valid) { + if(pressedKeyBalance > 1) { + // Auto-Repeat: OSX delivers only PRESSED + // inject auto-repeat RELEASE and TYPED keys _before_ + pressedKeyBalance--; + modifiers |= InputEvent.AUTOREPEAT_MASK; + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + super.sendKeyEvent(KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED + } // only deliver keyChar on key Typed events, harmonizing platform behavior keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; super.sendKeyEvent(eventType, modifiers, keyCode2, keyChar); @@ -327,6 +336,14 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); if(valid) { + if(pressedKeyBalance > 1) { + // Auto-Repeat: OSX delivers only PRESSED + // inject auto-repeat RELEASE and TYPED keys _before_ + pressedKeyBalance--; + modifiers |= InputEvent.AUTOREPEAT_MASK; + super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED + } // only deliver keyChar on key Typed events, harmonizing platform behavior keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; super.enqueueKeyEvent(wait, eventType, modifiers, keyCode2, keyChar); @@ -335,14 +352,17 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private int keyDownModifiers = 0; private int keyDownCode = 0; + private int pressedKeyBalance = 0; private boolean validateKeyEvent(int eventType, int modifiers, int keyCode) { switch(eventType) { case KeyEvent.EVENT_KEY_PRESSED: + pressedKeyBalance++; keyDownModifiers = modifiers; keyDownCode = keyCode; return true; case KeyEvent.EVENT_KEY_RELEASED: + pressedKeyBalance--; return keyDownModifiers == modifiers && keyDownCode == keyCode; case KeyEvent.EVENT_KEY_TYPED: final boolean matchKeyDown = keyDownModifiers == modifiers && keyDownCode == keyCode; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 5dbdeb458..18cc88472 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; @@ -258,9 +259,14 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } - private final int validateKeyCode(int eventType, int keyCode) { + private final int validateKeyCode(int eventType, int modifiers, int keyCode, char keyChar) { switch(eventType) { + case KeyEvent.EVENT_KEY_RELEASED: + pressedKeyBalance--; + lastPressedKeyCode = keyCode; + break; case KeyEvent.EVENT_KEY_PRESSED: + pressedKeyBalance++; lastPressedKeyCode = keyCode; break; case KeyEvent.EVENT_KEY_TYPED: @@ -273,18 +279,40 @@ public class WindowDriver extends WindowImpl { return keyCode; } private int lastPressedKeyCode = 0; + private int pressedKeyBalance = 0; + private int autoRepeat = 0; @Override public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, keyCode); - super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); + switch(eventType) { + case KeyEvent.EVENT_KEY_RELEASED: + // reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED + break; + case KeyEvent.EVENT_KEY_PRESSED: + if(pressedKeyBalance > 1) { + // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. + // Since reordering already injects RELEASE, we only need to set the AUTOREPEAT_MASK. + pressedKeyBalance--; + autoRepeat |= InputEvent.AUTOREPEAT_MASK; + } else { + autoRepeat &= ~InputEvent.AUTOREPEAT_MASK; + } + super.sendKeyEvent(eventType, modifiers | autoRepeat, keyCode, (char)-1); + break; + case KeyEvent.EVENT_KEY_TYPED: + modifiers |= autoRepeat; + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); + super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + break; + } } @Override public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, keyCode); + keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); } diff --git a/src/newt/native/InputEvent.h b/src/newt/native/InputEvent.h index b42c06d21..51c56c474 100644 --- a/src/newt/native/InputEvent.h +++ b/src/newt/native/InputEvent.h @@ -34,13 +34,19 @@ #ifndef _INPUT_EVENT_H_ #define _INPUT_EVENT_H_ -#define EVENT_SHIFT_MASK 1 -#define EVENT_CTRL_MASK 2 -#define EVENT_META_MASK 4 -#define EVENT_ALT_MASK 8 -#define EVENT_ALT_GRAPH_MASK 32 -#define EVENT_BUTTON1_MASK (1<<6) -#define EVENT_BUTTON2_MASK (1<<7) -#define EVENT_BUTTON3_MASK (1<<8) +#define EVENT_SHIFT_MASK (1 << 0) +#define EVENT_CTRL_MASK (1 << 1) +#define EVENT_META_MASK (1 << 2) +#define EVENT_ALT_MASK (1 << 3) +#define EVENT_ALT_GRAPH_MASK (1 << 5) +#define EVENT_BUTTON1_MASK (1 << 6) +#define EVENT_BUTTON2_MASK (1 << 7) +#define EVENT_BUTTON3_MASK (1 << 8) +#define EVENT_BUTTON4_MASK (1 << 9) +#define EVENT_BUTTON5_MASK (1 << 10) +#define EVENT_BUTTON6_MASK (1 << 11) +#define EVENT_AUTOREPEAT_MASK (1 << 15) +#define EVENT_CONFINED_MASK (1 << 16) +#define EVENT_INVISIBLE_MASK (1 << 17) #endif diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 3157538c3..84b3a7630 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -400,6 +400,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage Display * dpy = (Display *) (intptr_t) display; Atom wm_delete_atom = (Atom)windowDeleteAtom; int num_events = 100; + int autoRepeatModifiers = 0; if ( NULL == dpy ) { return; @@ -458,6 +459,19 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage switch(evt.type) { case KeyRelease: + if (XEventsQueued(dpy, QueuedAfterReading)) { + XEvent nevt; + XPeekEvent(dpy, &nevt); + + if (nevt.type == KeyPress && nevt.xkey.time == evt.xkey.time && + nevt.xkey.keycode == evt.xkey.keycode) + { + autoRepeatModifiers |= EVENT_AUTOREPEAT_MASK; + } else { + autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK; + } + } + // fall through intended case KeyPress: if(XLookupString(&evt.xkey,text,255,&keySym,0)==1) { KeySym lower_return = 0, upper_return = 0; @@ -469,13 +483,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage keyChar=0; keySym = X11KeySym2NewtVKey(keySym); } - modifiers = X11InputState2NewtModifiers(evt.xkey.state); + modifiers |= X11InputState2NewtModifiers(evt.xkey.state) | autoRepeatModifiers; break; case ButtonPress: case ButtonRelease: case MotionNotify: - modifiers = X11InputState2NewtModifiers(evt.xbutton.state); + modifiers |= X11InputState2NewtModifiers(evt.xbutton.state); break; default: -- cgit v1.2.3 From 94eae65015f188ff88324710d12895aba71d6f9d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Sep 2012 00:01:51 +0200 Subject: Analyze crash of shared context each running in multiple threads, disabled test for OSX > 10.7.0 Shared context w/ 3 context each running in there own thread is instable here on OSX 10.7.4/NVidia, SIGSEGV @ glDrawArrays / glBindBuffer .. any shared VBO. Seems to run fine on 10.6.8/NVidia. --- make/scripts/tests.sh | 8 +- .../jogl/acore/TestSharedContextVBOES2NEWT.java | 124 ++++++++++++++-- .../jogl/acore/TestSharedContextVBOES2NEWT2.java | 156 --------------------- 3 files changed, 113 insertions(+), 175 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7b39c3fbd..fc84d99e6 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -68,6 +68,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.fbo.force.none" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" @@ -123,7 +124,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -240,8 +241,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* @@ -263,7 +263,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java index da91350f1..4aa977ae8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java @@ -28,12 +28,14 @@ package com.jogamp.opengl.test.junit.jogl.acore; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.VersionNumber; import com.jogamp.newt.opengl.GLWindow; import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.Animator; @@ -49,7 +51,7 @@ public class TestSharedContextVBOES2NEWT extends UITestCase { static GLProfile glp; static GLCapabilities caps; static int width, height; - GLOffscreenAutoDrawable sharedDrawable; + GLAutoDrawable sharedDrawable; GearsES2 sharedGears; @BeforeClass @@ -66,8 +68,16 @@ public class TestSharedContextVBOES2NEWT extends UITestCase { } } - private void initShared() { - sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null); + private void initShared(boolean onscreen) { + if(onscreen) { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setSize(width, height); + glWindow.setVisible(true); + sharedDrawable = glWindow; + } else { + sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null); + } Assert.assertNotNull(sharedDrawable); sharedGears = new GearsES2(); Assert.assertNotNull(sharedGears); @@ -79,6 +89,7 @@ public class TestSharedContextVBOES2NEWT extends UITestCase { private void releaseShared() { Assert.assertNotNull(sharedDrawable); sharedDrawable.destroy(); + sharedDrawable = null; } protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException { @@ -86,7 +97,7 @@ public class TestSharedContextVBOES2NEWT extends UITestCase { Assert.assertNotNull(glWindow); glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared); if(useShared) { - glWindow.setSharedContext(sharedDrawable.getContext()); + glWindow.setSharedContext(sharedDrawable.getContext()); } glWindow.setSize(width, height); @@ -98,41 +109,120 @@ public class TestSharedContextVBOES2NEWT extends UITestCase { glWindow.addGLEventListener(gears); animator.add(glWindow); - + animator.start(); glWindow.setVisible(true); Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); - + glWindow.setPosition(x, y); return glWindow; } @Test - public void test01() throws InterruptedException { - initShared(); + public void testCommonAnimatorSharedOnscreen() throws InterruptedException { + initShared(true); + Animator animator = new Animator(); + GLWindow f1 = runTestGL(animator, 0, 0, true, false); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + + releaseShared(); + } + + @Test + public void testCommonAnimatorSharedOffscreen() throws InterruptedException { + initShared(false); Animator animator = new Animator(); GLWindow f1 = runTestGL(animator, 0, 0, true, false); InsetsImmutable insets = f1.getInsets(); GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), f1.getY()+0, true, false); GLWindow f3 = runTestGL(animator, f1.getX()+0, - f1.getY()+height+insets.getTotalHeight(), false, true); - animator.setUpdateFPSFrames(1, null); - animator.start(); - while(animator.isAnimating() && animator.getTotalFPSDuration() 0 ) { + // instable on OSX .. driver/OS bug when multi threading (3 animator) + System.err.println("Shared context w/ 3 context each running in there own thread is instable here on OSX 10.7.4/NVidia,"); + System.err.println("SIGSEGV @ glDrawArrays / glBindBuffer .. any shared VBO."); + System.err.println("Seems to run fine on 10.6.8/NVidia."); + return; + } + initShared(false); + Animator animator1 = new Animator(); + Animator animator2 = new Animator(); + Animator animator3 = new Animator(); + GLWindow f1 = runTestGL(animator1, 0, 0, true, false); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator3, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator1.stop(); + animator2.stop(); + animator3.stop(); - static long duration = 500; // ms + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + + releaseShared(); + } + + static long duration = 2000; // ms public static void main(String args[]) { for(int i=0; i Date: Mon, 17 Sep 2012 00:27:37 +0200 Subject: Anotate focus tests in regards to OSX stability .. sporadically won't gain focus and receive keyboard input via AWTRobot --- make/scripts/tests.sh | 6 +++--- .../com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java | 6 +++--- .../com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index fc84d99e6..05109e52f 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -91,7 +91,7 @@ function jrun() { #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" #D_ARGS="-Dnewt.debug.MainThread" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" @@ -241,7 +241,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* @@ -350,7 +350,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug -#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* +testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java index 592b00144..5d6218df4 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java @@ -163,11 +163,11 @@ public class TestFocus01SwingAWTRobot extends UITestCase { animator.start(); // Button Focus - Thread.sleep(100); // allow event sync + Thread.sleep(200); // allow event sync System.err.println("FOCUS AWT Button request"); EventCountAdapterUtil.reset(eventCountAdapters); - AWTRobotUtil.assertRequestFocusAndWait(robot, button, button, buttonFA, frame1FA); + AWTRobotUtil.assertRequestFocusAndWait(robot, button, button, buttonFA, frame1FA); // OSX sporadically button did not gain - major UI failure Assert.assertEquals(false, glWindow1FA.focusGained()); Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); System.err.println("FOCUS AWT Button sync"); @@ -181,7 +181,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase { Thread.sleep(100); // allow event sync System.err.println("FOCUS NEWT Canvas/GLWindow request"); EventCountAdapterUtil.reset(eventCountAdapters); - AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA); + AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA); // OSX sporadically button did not loose - minor UI failure Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA, AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA)); System.err.println("FOCUS NEWT Canvas/GLWindow sync"); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java index d8a9640c1..0e87144da 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java @@ -183,12 +183,12 @@ public class TestFocus02SwingAWTRobot extends UITestCase { Thread.sleep(100); // allow event sync System.err.println("FOCUS AWT Button Outer request"); EventCountAdapterUtil.reset(eventCountAdapters); - AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthOuter, buttonNorthOuter, buttonNorthOuterFA, jFrame1FA); + AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthOuter, buttonNorthOuter, buttonNorthOuterFA, jFrame1FA); // OSX sporadically buttonNorthOuter did not gain - major UI failure Assert.assertEquals(false, glWindow1FA.focusGained()); Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); Assert.assertEquals(false, buttonNorthInnerFA.focusGained()); System.err.println("FOCUS AWT Button Outer sync"); - AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, buttonNorthOuter, buttonNorthOuterKA); + AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, buttonNorthOuter, buttonNorthOuterKA); // OSX sporadically won't receive the keyboard input - major UI failure AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, buttonNorthOuter, buttonNorthOuterMA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, -- cgit v1.2.3 From c0cc74a7d525aaa7eb89f60c836589678053d5fb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Sep 2012 03:30:36 +0200 Subject: Fixes Bug 615 - X11: Use proper screen index/name for shared resources and device denominated 'mutable' surfaces (dummy, offscreen, ..) Fix follows findings of Rob Hatcherson, but instead of parsing the display connection ourself we use the X11 macro 'DefaultScreen(display)' See "The screen number specified in the display_name argument is returned by the DefaultScreen() macro (or the XDefaultScreen() function)." Since I currently have no two-head X11 setup here, only xinerama via virtualbox, pls test / validate. Note: One Display connection may span multiple screens, i.e.: display 'lala:0.1' may span from screen 1 - 3 (non xinerama mode) Discussion: [1] How to validate whether a screen number belongs to one display connection ? We can query ScreenCount(display), however it is not clear what the range would be. [2] With 1 display connection spanning multiple screens, what is/are the proper connection string[s] ? [3] After all, it seems this ancient configuration really cannot beat a modern setup w/ XRandR having Xinerama enabled. The latter is the default anyways. --- make/scripts/tests.sh | 6 ++--- make/stub_includes/x11/window-lib.c | 5 +++- .../opengl/x11/glx/X11GLXDrawableFactory.java | 4 +-- .../jogamp/nativewindow/x11/X11GraphicsDevice.java | 29 +++++++++++++++++++--- .../test/junit/newt/TestRemoteGLWindows01NEWT.java | 1 - 5 files changed, 35 insertions(+), 10 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 05109e52f..9733e3710 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -91,7 +91,7 @@ function jrun() { #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" #D_ARGS="-Dnewt.debug.MainThread" - D_ARGS="-Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" @@ -273,7 +273,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -350,7 +350,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug -testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* diff --git a/make/stub_includes/x11/window-lib.c b/make/stub_includes/x11/window-lib.c index bc5df4ae4..1204d033d 100644 --- a/make/stub_includes/x11/window-lib.c +++ b/make/stub_includes/x11/window-lib.c @@ -27,9 +27,12 @@ extern void XLockDisplay(Display *display); extern void XUnlockDisplay(Display *display); -extern Window RootWindow(Display *display, int screen_number); extern int DefaultScreen(Display *display); +extern int ScreenCount(Display *display); + +extern Window RootWindow(Display *display, int screen_number); + extern XVisualInfo *XGetVisualInfo( Display* /* display */, long /* vinfo_mask */, diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index fb11f8bba..ca5cd424b 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -237,7 +237,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { // NativeWindowFactory.getNullToolkitLock(), true); // own non-shared display connection, w/o locking sharedDevice.lock(); try { - final X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, 0); + final X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, sharedDevice.getDefaultScreen()); if(!GLXUtil.isGLXAvailableOnServer(sharedDevice)) { throw new GLException("GLX not available on device/server: "+sharedDevice); @@ -514,7 +514,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } else { device = (X11GraphicsDevice)deviceReq; } - final X11GraphicsScreen screen = new X11GraphicsScreen(device, 0); + final X11GraphicsScreen screen = new X11GraphicsScreen(device, device.getDefaultScreen()); final X11GLXGraphicsConfiguration config = X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(capsChosen, capsRequested, chooser, screen, VisualIDHolder.VID_UNDEFINED); if(null == config) { throw new GLException("Choosing GraphicsConfiguration failed w/ "+capsChosen+" on "+screen); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index 5e4d6f41a..152384980 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -84,11 +84,34 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl handleOwner = owner; } + private static int getDefaultScreenImpl(long dpy) { + return X11Lib.DefaultScreen(dpy); + } + + /** + * Returns the default screen number as referenced by the display connection, i.e. 'somewhere:0.1' -> 1 + *

    + * Implementation uses the XLib macro DefaultScreen(display). + *

    + */ + public int getDefaultScreen() { + final long display = getHandle(); + if(0==display) { + throw new NativeWindowException("null display"); + } + final int ds = getDefaultScreenImpl(display); + if(DEBUG) { + System.err.println(Thread.currentThread().getName() + " - X11GraphicsDevice.getDefaultDisplay() of "+this+": "+ds+", count "+X11Lib.ScreenCount(display)); + } + return ds; + } + public int getDefaultVisualID() { - // It still could be an AWT hold handle .. final long display = getHandle(); - final int scrnIdx = X11Lib.DefaultScreen(display); - return X11Lib.DefaultVisualID(display, scrnIdx); + if(0==display) { + throw new NativeWindowException("null display"); + } + return X11Lib.DefaultVisualID(display, getDefaultScreenImpl(display)); } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java index 35e24403f..ef830b660 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestRemoteGLWindows01NEWT.java @@ -30,7 +30,6 @@ package com.jogamp.opengl.test.junit.newt; import org.junit.Assert; import org.junit.Assume; -import org.junit.BeforeClass; import org.junit.Test; import javax.media.opengl.*; -- cgit v1.2.3 From 923d9dd7f1d40db72d35ca76a761ca14babf147f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 20 Sep 2012 23:12:48 +0200 Subject: Add GLRendererQuirks; Fix shared EGL/ES resources; Add GLRendererQuirks: - Contains centralized 'tagged' workarounds for GL renderer bugs (quirks) - Accessible via GLContext and GLDrawableFactory - Initialized in GLContext.setAvailability* - Simplify GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(..) & use Quirks - use quirks - instead of passing booleans for each config, pass factory & device Fix shared EGL/ES resources: - GLProfile needs to initialize EGLDrawableFactory's shared resources before desktop, so EGLDrawableFactory can use the fallback defaultDisplay & defaultSharedResource for host mapped sharedResources (hack). - If using defaultSharedResources for host mapped ones, do not go through initialization cycles - simply map (sharedResource + context). - EGLDrawableFactory: Use device's unique-key instead of connection only, since the latter causes a collision (EGL-connection == X11-connection). --- make/scripts/tests.sh | 16 +- .../com/jogamp/opengl/GLRendererQuirks.java | 130 +++++++++ src/jogl/classes/javax/media/opengl/GLContext.java | 51 +++- .../javax/media/opengl/GLDrawableFactory.java | 37 +++ src/jogl/classes/javax/media/opengl/GLProfile.java | 46 ++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 55 +++- .../jogamp/opengl/GLDrawableFactoryImpl.java | 42 ++- .../jogamp/opengl/GLGraphicsConfigurationUtil.java | 95 +++++-- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 51 ++-- .../jogamp/opengl/egl/EGLDrawableFactory.java | 302 +++++++++++++-------- .../egl/EGLGraphicsConfigurationFactory.java | 4 +- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 19 +- .../cgl/MacOSXCGLGraphicsConfigurationFactory.java | 6 +- .../WindowsWGLGraphicsConfigurationFactory.java | 5 +- .../glx/X11GLXGraphicsConfigurationFactory.java | 7 +- ...estGLAutoDrawableDelegateOnOffscrnCapsNEWT.java | 7 +- .../TestGLAutoDrawableFactoryOffscrnCapsNEWT.java | 11 +- ...TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java | 5 +- ...estGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java | 5 +- ...LAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java | 9 +- 20 files changed, 625 insertions(+), 278 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9733e3710..a5fb898a8 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -60,10 +60,11 @@ function jrun() { shift #D_ARGS="-Djogl.disable.opengles" - #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Dnewt.debug.Window.MouseEvent" + #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" + #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" + #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" - #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" @@ -85,6 +86,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLArrayData" + #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" @@ -193,6 +195,9 @@ function jrun() { echo $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* #LIBGL_DRIVERS_PATH=/usr/lib/mesa:/usr/lib32/mesa \ #gdb --args $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* + #LIBGL_DEBUG=verbose INTEL_STRICT_CONFORMANCE=1 INTEL_DEBUG="buf bat" \ + #LIBGL_DEBUG=verbose MESA_DEBUG=true INTEL_STRICT_CONFORMANCE=1 \ + #LIBGL_DEBUG=verbose MESA_DEBUG=true LIBGL_ALWAYS_SOFTWARE=true \ $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* echo echo "Test End: $*" @@ -244,7 +249,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* @@ -252,7 +256,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* @@ -273,7 +277,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -444,8 +448,6 @@ testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01GLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer02NewtCanvasAWT $* $spath/count-edt-start.sh java-run.log diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java new file mode 100644 index 000000000..13c94c6f2 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -0,0 +1,130 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl; + +/** + * GLRendererQuirks contains information of known bugs of various GL renderer. + * This information allows us to workaround them. + *

    + * Using centralized quirk identifier enables us to + * locate code dealing w/ it and hence eases it's maintenance. + *

    + */ +public class GLRendererQuirks { + /** Crashes XServer when using double buffered PBuffer with 'Mesa DRI Intel(R) Sandybridge Desktop' & 'Mesa DRI Intel(R) Ivybridge Mobile - 3.0 Mesa 8.0.4' */ + public static final int NoDoubleBufferedPBuffer = 0; + + /** On Windows no double buffered bitmaps are guaranteed to be available. */ + public static final int NoDoubleBufferedBitmap = 1; + + /** Crashes application when trying to set EGL swap interval on Android 4.0.3 / Pandaboard ES / PowerVR SGX 540 */ + public static final int NoSetSwapInterval = 2; + + /** No offscreen bitmap available, currently true for JOGL's OSX implementation. */ + public static final int NoOffscreenBitmap = 3; + + /** Number of quirks known. */ + public static final int COUNT = 4; + + private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", + "NoOffscreenBitmap" + }; + + private final int _bitmask; + + /** + * @param quirks an array of valid quirks + * @param offset offset in quirks array to start reading + * @param len number of quirks to read from offset within quirks array + * @throws IllegalArgumentException if one of the quirks is out of range + */ + public GLRendererQuirks(int[] quirks, int offset, int len) throws IllegalArgumentException { + int bitmask = 0; + if( !( 0 <= offset + len && offset + len < quirks.length ) ) { + throw new IllegalArgumentException("offset and len out of bounds: offset "+offset+", len "+len+", array-len "+quirks.length); + } + for(int i=offset; inull. + */ + public final GLRendererQuirks getRendererQuirks() { return glRendererQuirks; } + + /** + * Returns true if the quirk exist in {@link #getRendererQuirks()}, otherwise false. + *

    + * Convenience method for: + *

    +   *    final GLRendererQuirks glrq = ctx.getRendererQuirks();
    +   *    boolean hasQuirk = null != glrq ? glrq.exist(quirk) : false ;
    +   * 
    + *

    + * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}. + * @throws IllegalArgumentException if the quirk is out of range + */ + public final boolean hasRendererQuirk(int quirk) throws IllegalArgumentException { + return null != glRendererQuirks ? glRendererQuirks.exist(quirk) : false ; + } + /** * Sets the read/write drawable for framebuffer operations. *

    @@ -464,6 +489,12 @@ public abstract class GLContext { sb.append(toHexString(contextHandle)); sb.append(", "); sb.append(getGL()); + sb.append(",\n\t quirks: "); + if(null != glRendererQuirks) { + glRendererQuirks.toString(sb); + } else { + sb.append("n/a"); + } if(getGLDrawable()!=getGLReadDrawable()) { sb.append(",\n\tRead Drawable : "); sb.append(getGLReadDrawable()); @@ -473,8 +504,6 @@ public abstract class GLContext { sb.append(",\n\tDrawable: "); sb.append(getGLDrawable()); } - sb.append(", lock "); - sb.append(lock.toString()); return sb; } @@ -666,13 +695,15 @@ public abstract class GLContext { if( hasFullFBOSupport() ) { final GL gl = getGL(); final int[] val = new int[] { 0 } ; - gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); - final int glerr = gl.glGetError(); - if(GL.GL_NO_ERROR == glerr) { - return val[0]; - } else if(DEBUG) { - System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr)); - } + try { + gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); + final int glerr = gl.glGetError(); + if(GL.GL_NO_ERROR == glerr) { + return val[0]; + } else if(DEBUG) { + System.err.println("GLContext.getMaxRenderbufferSamples: GL_MAX_SAMPLES query GL Error 0x"+Integer.toHexString(glerr)); + } + } catch (GLException gle) { gle.printStackTrace(); } } return 0; } @@ -1369,6 +1400,6 @@ public abstract class GLContext { protected static String getThreadName() { return Thread.currentThread().getName(); } - + } diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index b6e7b0576..ae49eeeff 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -49,6 +49,7 @@ import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.opengl.GLAutoDrawableDelegate; +import com.jogamp.opengl.GLRendererQuirks; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; @@ -307,6 +308,42 @@ public abstract class GLDrawableFactory { */ protected abstract boolean createSharedResource(AbstractGraphicsDevice device); + /** + * Returns true if the quirk exist in the shared resource's context {@link GLRendererQuirks}. + *

    + * Convenience method for: + *

    +      final GLRendererQuirks glrq = factory.getRendererQuirks(device);
    +      return null != glrq ? glrq.exist(quirk) : false;
    +   * 
    + *

    + * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + * @param quirk the quirk to be tested, e.g. {@link GLRendererQuirks#NoDoubleBufferedPBuffer}. + * @throws IllegalArgumentException if the quirk is out of range + * @see #getRendererQuirks() + * @see GLRendererQuirks + */ + public final boolean hasRendererQuirk(AbstractGraphicsDevice device, int quirk) { + final GLRendererQuirks glrq = getRendererQuirks(device); + return null != glrq ? glrq.exist(quirk) : false; + } + + /** + * Returns the shared resource's context {@link GLRendererQuirks}. + *

    + * Implementation calls {@link GLContext#getRendererQuirks()} on the shared resource context. + *

    + *

    + * In case no shared device exist yet or the implementation doesn't support tracking quirks, + * the result is always null. + *

    + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + * @see GLContext#getRendererQuirks() + * @see GLRendererQuirks + */ + public abstract GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device); + /** * Returns the sole GLDrawableFactory instance for the desktop (X11, WGL, ..) if exist or null */ diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 23d789afd..aabda465e 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -1445,10 +1445,6 @@ public class GLProfile { } } else { defaultDesktopDevice = desktopFactory.getDefaultDevice(); - defaultDevice = defaultDesktopDevice; - if(DEBUG) { - System.err.println("Info: GLProfile.init - Default device is desktop derived: "+defaultDevice); - } } if ( !disableOpenGLES && ReflectionUtil.isClassAvailable("jogamp.opengl.egl.EGLDrawableFactory", classloader) ) { @@ -1490,7 +1486,7 @@ public class GLProfile { } } - final AbstractGraphicsDevice defaultEGLDevice; + final AbstractGraphicsDevice defaultEGLDevice; if(null == eglFactory) { hasGLES2Impl = false; hasGLES1Impl = false; @@ -1499,25 +1495,33 @@ public class GLProfile { System.err.println("Info: GLProfile.init - EGL GLDrawable factory not available"); } } else { - defaultEGLDevice = eglFactory.getDefaultDevice(); - if(null == defaultDevice) { - defaultDevice = defaultEGLDevice; - if(DEBUG) { - System.err.println("Info: GLProfile.init - Default device is EGL derived: "+defaultDevice); - } - } + defaultEGLDevice = eglFactory.getDefaultDevice(); } - /** Should not be required .. but keep it here if simple probe on defaultDevice ain't enough. - final boolean addedDesktopProfile = initProfilesForDevice(defaultDesktopDevice); - final boolean addedEGLProfile = initProfilesForDevice(defaultEGLDevice); - final boolean addedAnyProfile = addedDesktopProfile || addedEGLProfile ; - */ - final boolean addedAnyProfile = initProfilesForDevice(defaultDevice); - + if( null != defaultDesktopDevice ) { + defaultDevice = defaultDesktopDevice; + if(DEBUG) { + System.err.println("Info: GLProfile.init - Default device is desktop derived: "+defaultDevice); + } + } else if ( null != defaultEGLDevice ) { + defaultDevice = defaultEGLDevice; + if(DEBUG) { + System.err.println("Info: GLProfile.init - Default device is EGL derived: "+defaultDevice); + } + } else { + if(DEBUG) { + System.err.println("Info: GLProfile.init - Default device not available"); + } + defaultDevice = null; + } + + // we require to initialize the EGL device 1st, if available + final boolean addedEGLProfile = null != defaultEGLDevice ? initProfilesForDevice(defaultEGLDevice) : false; + final boolean addedDesktopProfile = null != defaultDesktopDevice ? initProfilesForDevice(defaultDesktopDevice) : false; + final boolean addedAnyProfile = addedEGLProfile || addedDesktopProfile ; + if(DEBUG) { - // System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")"); - System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile); + System.err.println("GLProfile.init addedAnyProfile "+addedAnyProfile+" (desktop: "+addedDesktopProfile+", egl "+addedEGLProfile+")"); System.err.println("GLProfile.init isAWTAvailable "+isAWTAvailable); System.err.println("GLProfile.init hasDesktopGLFactory "+hasDesktopGLFactory); System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl); diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 050c619fd..e164dfe44 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -46,6 +46,7 @@ import java.util.HashMap; import java.util.Map; import com.jogamp.common.os.DynamicLookupHelper; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.FunctionAddressResolver; @@ -53,6 +54,7 @@ import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLNameResolver; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; import com.jogamp.opengl.GLExtensions; +import com.jogamp.opengl.GLRendererQuirks; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -162,7 +164,7 @@ public abstract class GLContextImpl extends GLContext { additionalCtxCreationFlags = 0; glRenderer = ""; - glRendererLowerCase = glRenderer; + glRendererLowerCase = glRenderer; if (boundFBOTarget != null) { // boundFBOTarget[0] = 0; // draw @@ -1116,13 +1118,6 @@ public abstract class GLContextImpl extends GLContext { } } - protected final String getGLVersionString() { - return glVersion; - } - protected final String getGLRendererString(boolean lowerCase) { - return lowerCase ? glRendererLowerCase : glRenderer; - } - /** * Sets the OpenGL implementation class and * the cache of which GL functions are available for calling through this @@ -1264,6 +1259,8 @@ public abstract class GLContextImpl extends GLContext { // Set GL Version (complete w/ version string) // setContextVersion(major, minor, ctxProfileBits, true); + + setRendererQuirks(); setDefaultSwapInterval(); @@ -1272,7 +1269,45 @@ public abstract class GLContextImpl extends GLContext { } } - protected static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) { + private final void setRendererQuirks() { + int[] quirks = new int[GLRendererQuirks.COUNT]; + int i = 0; + + // OS related quirks + if( Platform.getOSType() == Platform.OSType.MACOS ) { + final int quirk = GLRendererQuirks.NoOffscreenBitmap; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()); + } + quirks[i++] = quirk; + } else if( Platform.getOSType() == Platform.OSType.WINDOWS ) { + final int quirk = GLRendererQuirks.NoDoubleBufferedBitmap; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()); + } + quirks[i++] = quirk; + } + + // Renderer related quirks, may also involve OS + if( Platform.OSType.ANDROID == Platform.getOSType() && glRendererLowerCase.contains("powervr") ) { + final int quirk = GLRendererQuirks.NoSetSwapInterval; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + " / Renderer " + glRenderer); + } + quirks[i++] = quirk; + } + if( glRendererLowerCase.contains("intel(r)") && glRendererLowerCase.contains("mesa") ) { + final int quirk = GLRendererQuirks.NoDoubleBufferedPBuffer; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer); + } + quirks[i++] = quirk; + } + glRendererQuirks = new GLRendererQuirks(quirks, 0, i); + } + + + private static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) { return ( 0 != (ctp & CTX_PROFILE_ES) && major >= 2 ) || // ES >= 2.0 major >= 3 || // any >= 3.0 GL ctx @@ -1288,7 +1323,7 @@ public abstract class GLContextImpl extends GLContext { extCache.isExtensionAvailable(GLExtensions.OES_framebuffer_object) ) ; // OES_framebuffer_object excluded } - protected final void removeCachedVersion(int major, int minor, int ctxProfileBits) { + private final void removeCachedVersion(int major, int minor, int ctxProfileBits) { if(!isCurrentContextHardwareRasterizer()) { ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 4f965f620..bd2db1b81 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -63,6 +63,7 @@ import javax.media.opengl.GLProfile; import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.nativewindow.DelegatedUpstreamSurfaceHookWithSurfaceSize; import com.jogamp.nativewindow.UpstreamSurfaceHookMutableSize; +import com.jogamp.opengl.GLRendererQuirks; /** Extends GLDrawableFactory with a few methods for handling @@ -78,6 +79,15 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { super(); } + @Override + public GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device) { + final GLContext ctx = getOrCreateSharedContextImpl(device); + if(null != ctx) { + return ctx.getRendererQuirks(); + } + return null; + } + /** * Returns the shared context mapped to the device {@link AbstractGraphicsDevice#getConnection()}, * either a pre-existing or newly created, or null if creation failed or not supported.
    @@ -102,24 +112,15 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. */ protected final AbstractGraphicsDevice getOrCreateSharedDevice(AbstractGraphicsDevice device) { - if(null==device) { - device = getDefaultDevice(); - if(null==device) { - throw new InternalError("no default device"); - } - if (GLProfile.DEBUG) { - System.err.println("Info: GLDrawableFactoryImpl.getOrCreateSharedContext: using default device : "+device); - } - } else if( !getIsDeviceCompatible(device) ) { - if (GLProfile.DEBUG) { - System.err.println("Info: GLDrawableFactoryImpl.getOrCreateSharedContext: device not compatible : "+device); - } - return null; + device = validateDevice(device); + if( null != device) { + return getOrCreateSharedDeviceImpl(device); } - return getOrCreateSharedDeviceImpl(device); + return null; } protected abstract AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device); + /** * Returns the GLDynamicLookupHelper * @param profile if EGL/ES, profile 1 refers to ES1 and 2 to ES2, @@ -144,12 +145,11 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { try { final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true); if(null != ols) { + final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, this, adevice); // layered surface -> Offscreen/[FBO|PBuffer] - final boolean isPbufferAvailable = canCreateGLPbuffer(adevice) ; - if(!isPbufferAvailable && !isFBOAvailable) { - throw new GLException("Neither FBO nor Pbuffer is available for "+target); + if( !chosenCapsMod.isFBO() && !chosenCapsMod.isPBuffer() ) { + throw new GLException("Neither FBO nor Pbuffer is available for "+chosenCapsMod+", "+target); } - final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, isFBOAvailable, isPbufferAvailable); config.setChosenCapabilities(chosenCapsMod); ols.setChosenCapabilities(chosenCapsMod); if(DEBUG) { @@ -163,7 +163,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if( ! ( target instanceof MutableSurface ) ) { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target); } - if( chosenCapsMod.isFBO() && isFBOAvailable ) { + if( chosenCapsMod.isFBO() ) { // target surface is already a native one result = createFBODrawableImpl(target, chosenCapsMod, 0); } else { @@ -294,9 +294,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { throw new GLException("No shared device for requested: "+deviceReq); } - final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, - GLContext.isFBOAvailable(device, capsRequested.getGLProfile()), - canCreateGLPbuffer(device)); + final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, this, device); if( capsChosen.isFBO() ) { device.lock(); diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java index 13c95b0dd..31e52b86c 100644 --- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java +++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java @@ -32,8 +32,9 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; -import com.jogamp.common.os.Platform; +import com.jogamp.opengl.GLRendererQuirks; public class GLGraphicsConfigurationUtil { public static final String NV_coverage_sample = "NV_coverage_sample"; @@ -138,16 +139,25 @@ public class GLGraphicsConfigurationUtil { return caps; } - public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) - { + /** + * Fixes the requested {@link GLCapabilitiesImmutable} according to on- and offscreen usage. + *

    + * No modification will be made for onscreen usage, for offscreen usage see + * {@link #fixOffscreenGLCapabilities(GLCapabilitiesImmutable, GLDrawableFactory, AbstractGraphicsDevice)}. + *

    + * @param capsRequested the requested {@link GLCapabilitiesImmutable} + * @param factory the {@link GLDrawableFactory} used to validate the requested capabilities and later used to create the drawable. + * @param device the device on which the drawable will be created, maybe null for the {@link GLDrawableFactory#getDefaultDevice() default device}. + * @return either the given requested {@link GLCapabilitiesImmutable} instance if no modifications were required, or a modified {@link GLCapabilitiesImmutable} instance. + */ + public static GLCapabilitiesImmutable fixGLCapabilities(GLCapabilitiesImmutable capsRequested, + GLDrawableFactory factory, AbstractGraphicsDevice device) { if( !capsRequested.isOnscreen() ) { - return fixOffscreenGLCapabilities(capsRequested, fboAvailable, pbufferAvailable); - } /* we maintain the offscreen mode flags in onscreen mode - else { - return fixOnscreenGLCapabilities(capsRequested); - } */ + return fixOffscreenGLCapabilities(capsRequested, factory, device); + } return capsRequested; } - + public static GLCapabilitiesImmutable fixOnscreenGLCapabilities(GLCapabilitiesImmutable capsRequested) { if( !capsRequested.isOnscreen() || capsRequested.isFBO() || capsRequested.isPBuffer() || capsRequested.isBitmap() ) { @@ -162,25 +172,68 @@ public class GLGraphicsConfigurationUtil { return capsRequested; } - public static boolean isGLCapabilitiesOffscreenAutoSelection(GLCapabilitiesImmutable capsRequested) { - return !capsRequested.isOnscreen() && - !capsRequested.isFBO() && !capsRequested.isPBuffer() && !capsRequested.isBitmap() ; + public static GLCapabilitiesImmutable fixOffscreenBitOnly(GLCapabilitiesImmutable capsRequested) + { + if( capsRequested.isOnscreen() ) { + // fix caps .. + final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); + caps2.setOnscreen(false); + return caps2; + } + return capsRequested; } - - public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested, boolean fboAvailable, boolean pbufferAvailable) { - final boolean auto = !capsRequested.isFBO() && !capsRequested.isPBuffer() && !capsRequested.isBitmap() ; - - final boolean requestedPBuffer = capsRequested.isPBuffer() || Platform.getOSType() == Platform.OSType.MACOS ; // no native bitmap for OSX + + /** + * Fixes the requested {@link GLCapabilitiesImmutable} according to: + *
      + *
    • offscreen usage
    • + *
    • availability of FBO, PBuffer, Bitmap
    • + *
    • {@link GLRendererQuirks}
    • + *
    + * @param capsRequested the requested {@link GLCapabilitiesImmutable} + * @param factory the {@link GLDrawableFactory} used to validate the requested capabilities and later used to create the drawable. + * @param device the device on which the drawable will be created, maybe null for the {@link GLDrawableFactory#getDefaultDevice() default device}. + * @return either the given requested {@link GLCapabilitiesImmutable} instance if no modifications were required, or a modified {@link GLCapabilitiesImmutable} instance. + */ + public static GLCapabilitiesImmutable fixOffscreenGLCapabilities(GLCapabilitiesImmutable capsRequested, + GLDrawableFactory factory, AbstractGraphicsDevice device) { + if(null == device) { + device = factory.getDefaultDevice(); + } + final boolean fboAvailable = GLContext.isFBOAvailable(device, capsRequested.getGLProfile()); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(device); + + final GLRendererQuirks glrq = factory.getRendererQuirks(device); + final boolean bitmapAvailable; + final boolean doubleBufferAvailable; + + if(null != glrq) { + bitmapAvailable = !glrq.exist(GLRendererQuirks.NoOffscreenBitmap); + if( capsRequested.getDoubleBuffered() && + ( capsRequested.isPBuffer() && glrq.exist(GLRendererQuirks.NoDoubleBufferedPBuffer) ) || + ( capsRequested.isBitmap() && glrq.exist(GLRendererQuirks.NoDoubleBufferedBitmap) ) ) { + doubleBufferAvailable = false; + } else { + doubleBufferAvailable = true; + } + } else { + bitmapAvailable = true; + doubleBufferAvailable = true; + } - final boolean useFBO = fboAvailable && ( auto || capsRequested.isFBO() ) ; - final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || requestedPBuffer ) ; - final boolean useBitmap = !useFBO && !usePbuffer && ( auto || capsRequested.isBitmap() ) ; + final boolean auto = !( fboAvailable && capsRequested.isFBO() ) && + !( pbufferAvailable && capsRequested.isPBuffer() ) && + !( bitmapAvailable && capsRequested.isBitmap() ) ; + + final boolean useFBO = fboAvailable && ( auto || capsRequested.isFBO() ) ; + final boolean usePbuffer = !useFBO && pbufferAvailable && ( auto || capsRequested.isPBuffer() ) ; + final boolean useBitmap = !useFBO && !usePbuffer && bitmapAvailable && ( auto || capsRequested.isBitmap() ) ; if( capsRequested.isOnscreen() || useFBO != capsRequested.isFBO() || usePbuffer != capsRequested.isPBuffer() || useBitmap != capsRequested.isBitmap() || - useBitmap && capsRequested.getDoubleBuffered() ) + !doubleBufferAvailable && capsRequested.getDoubleBuffered() ) { // fix caps .. final GLCapabilities caps2 = (GLCapabilities) capsRequested.cloneMutable(); @@ -188,7 +241,7 @@ public class GLGraphicsConfigurationUtil { caps2.setFBO( useFBO ); caps2.setPBuffer( usePbuffer ); caps2.setBitmap( useBitmap ); - if( useBitmap ) { + if( !doubleBufferAvailable ) { caps2.setDoubleBuffered(false); } return caps2; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 06953a8e1..84aeaa94a 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -51,9 +51,10 @@ import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; import com.jogamp.common.nio.Buffers; -import com.jogamp.common.os.Platform; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; +import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.opengl.GLRendererQuirks; public abstract class EGLContext extends GLContextImpl { private boolean eglQueryStringInitialized; @@ -269,14 +270,7 @@ public abstract class EGLContext extends GLContextImpl { @Override protected boolean setSwapIntervalImpl(int interval) { - // FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - // eglSwapInterval(..) issued: - // Android 4.0.3 / Pandaboard ES / PowerVR SGX 540: crashes - // FIXME !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - if( Platform.OSType.ANDROID == Platform.getOSType() && getGLRendererString(true).contains("powervr") ) { - if(DEBUG) { - System.err.println("Ignored: eglSwapInterval("+interval+") - cause: OS "+Platform.getOSType() + " / Renderer " + getGLRendererString(false)); - } + if( hasRendererQuirk(GLRendererQuirks.NoSetSwapInterval) ) { return false; } return EGL.eglSwapInterval(drawable.getNativeSurface().getDisplayHandle(), interval); @@ -286,20 +280,11 @@ public abstract class EGLContext extends GLContextImpl { // Accessible .. // - /** - * If context is an ES profile, map it to the given device - * via {@link GLContext#mapAvailableGLVersion(AbstractGraphicsDevice, int, int, int, int, int)}. - *

    - * We intentionally override a non native EGL device ES profile mapping, - * i.e. this will override/modify an already 'set' X11/WGL/.. mapping. - *

    - * - * @param device - */ - protected void mapCurrentAvailableGLVersion(AbstractGraphicsDevice device) { - mapCurrentAvailableGLVersionImpl(device, ctxMajorVersion, ctxMinorVersion, ctxOptions); - } - protected static void mapStaticGLESVersion(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps) { + /* pp */ void mapCurrentAvailableGLVersion(AbstractGraphicsDevice device) { + mapStaticGLVersion(device, ctxMajorVersion, ctxMinorVersion, ctxOptions); + } + /* pp */ int getContextOptions() { return ctxOptions; } + /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps) { final GLProfile glp = caps.getGLProfile(); final int[] reqMajorCTP = new int[2]; GLContext.getRequestMajorAndCompat(glp, reqMajorCTP); @@ -309,21 +294,27 @@ public abstract class EGLContext extends GLContextImpl { if(!caps.getHardwareAccelerated()) { reqMajorCTP[1] |= GLContext.CTX_IMPL_ACCEL_SOFT; } - mapCurrentAvailableGLVersionImpl(device, reqMajorCTP[0], 0, reqMajorCTP[1]); - } - protected static void mapStaticGLESVersion(AbstractGraphicsDevice device, int major) { + mapStaticGLVersion(device, reqMajorCTP[0], 0, reqMajorCTP[1]); + } + /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, int major) { int ctp = ( 2 == major ) ? ( GLContext.CTX_PROFILE_ES | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) : ( GLContext.CTX_PROFILE_ES ); - mapCurrentAvailableGLVersionImpl(device, major, 0, ctp); + mapStaticGLVersion(device, major, 0, ctp); } - private static void mapCurrentAvailableGLVersionImpl(AbstractGraphicsDevice device, int major, int minor, int ctp) { + /* pp */ static void mapStaticGLVersion(AbstractGraphicsDevice device, int major, int minor, int ctp) { if( 0 != ( ctp & GLContext.CTX_PROFILE_ES) ) { // ES1 or ES2 final int reqMajor = major; final int reqProfile = GLContext.CTX_PROFILE_ES; - GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, - major, minor, ctp); + GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp); + if(! ( device instanceof EGLGraphicsDevice ) ) { + final EGLGraphicsDevice eglDevice = new EGLGraphicsDevice(device.getHandle(), EGL.EGL_NO_DISPLAY, device.getConnection(), device.getUnitID(), null); + GLContext.mapAvailableGLVersion(eglDevice, reqMajor, reqProfile, major, minor, ctp); + } } } + protected static String getGLVersion(int major, int minor, int ctp, String gl_version) { + return GLContext.getGLVersion(major, minor, ctp, gl_version); + } protected static boolean getAvailableGLVersionsSet(AbstractGraphicsDevice device) { return GLContext.getAvailableGLVersionsSet(device); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index e98d69140..a907c4aff 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -43,6 +43,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Set; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -77,11 +78,11 @@ import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.opengl.GLRendererQuirks; public class EGLDrawableFactory extends GLDrawableFactoryImpl { protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; - /* package */ static final boolean QUERY_EGL_ES = !Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.DontQuery", true); /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null; @@ -113,36 +114,11 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } catch (JogampRuntimeException jre) { /* n/a .. */ } } - defaultDevice = new EGLGraphicsDevice(); - // FIXME: Probably need to move EGL from a static model // to a dynamic one, where there can be 2 instances // for each ES profile with their own ProcAddressTable. synchronized(EGLDrawableFactory.class) { - /** - * Currently AMD's EGL impl. crashes at eglGetDisplay(EGL_DEFAULT_DISPLAY) - * - // Check Desktop ES2 Availability first (AMD, ..) - if(null==eglES2DynamicLookupHelper) { - GLDynamicLookupHelper tmp=null; - try { - tmp = new GLDynamicLookupHelper(new DesktopES2DynamicLibraryBundleInfo()); - } catch (GLException gle) { - if(DEBUG) { - gle.printStackTrace(); - } - } - if(null!=tmp && tmp.isLibComplete()) { - eglES2DynamicLookupHelper = tmp; - EGL.resetProcAddressTable(eglES2DynamicLookupHelper); - if (GLProfile.DEBUG) { - System.err.println("Info: EGLDrawableFactory: Desktop ES2 - OK"); - } - } else if (GLProfile.DEBUG) { - System.err.println("Info: EGLDrawableFactory: Desktop ES2 - NOPE"); - } - } */ final boolean hasDesktopES2 = null != eglES2DynamicLookupHelper; if(!hasDesktopES2 && null==eglES1DynamicLookupHelper) { @@ -188,8 +164,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } } if(null != eglES2DynamicLookupHelper || null != eglES1DynamicLookupHelper) { - sharedMap = new HashMap(); + sharedMap = new HashMap(); sharedMapCreateAttempt = new HashSet(); + defaultDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } } } @@ -203,6 +180,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected final void destroy() { if(null != sharedMap) { + if(DEBUG) { + System.err.println("EGLDrawableFactory.destroy() .. "); + dumpMap(); + } Collection srl = sharedMap.values(); for(Iterator sri = srl.iterator(); sri.hasNext(); ) { SharedResource sr = sri.next(); @@ -216,7 +197,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { sharedMap = null; sharedMapCreateAttempt = null; } - defaultDevice = null; + if(null != defaultSharedResource) { + defaultSharedResource = null; + } + if(null != defaultDevice) { + defaultDevice.close(); + defaultDevice = null; + } /** * Pulling away the native library may cause havoc .. */ @@ -231,39 +218,63 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { EGLGraphicsConfigurationFactory.unregisterFactory(); EGLDisplayUtil.shutdown(DEBUG); } + + private void dumpMap() { + synchronized(sharedMap) { + System.err.println("EGLDrawableFactory.map "+sharedMap.size()); + int i=0; + Set keys = sharedMap.keySet(); + for(Iterator keyI = keys.iterator(); keyI.hasNext(); i++) { + String key = keyI.next(); + SharedResource sr = sharedMap.get(key); + System.err.println("EGLDrawableFactory.map["+i+"] "+key+" -> "+sr.getDevice()+", "+ + "es1 [avail "+sr.wasES1ContextAvailable()+", pbuffer "+sr.hasES1PBuffer()+", quirks "+sr.getGLRendererQuirksES1()+", ctp "+EGLContext.getGLVersion(1, 0, sr.getCtpES1(), null)+"], "+ + "es2 [avail "+sr.wasES2ContextAvailable()+", pbuffer "+sr.hasES2PBuffer()+", quirks "+sr.getGLRendererQuirksES1()+", ctp "+EGLContext.getGLVersion(2, 0, sr.getCtpES2(), null)+"]"); + } + ; + } + } - private HashMap sharedMap = null; + private HashMap sharedMap = null; private HashSet sharedMapCreateAttempt = null; - - private EGLGraphicsDevice defaultDevice; + private EGLGraphicsDevice defaultDevice = null; + private SharedResource defaultSharedResource = null; static class SharedResource { private final EGLGraphicsDevice device; - // private final EGLDrawable drawable; // private final EGLContext contextES1; // private final EGLContext contextES2; + private final GLRendererQuirks rendererQuirksES1; + private final GLRendererQuirks rendererQuirksES2; + private final int ctpES1; + private final int ctpES2; private final boolean wasES1ContextCreated; private final boolean wasES2ContextCreated; private final boolean hasPBufferES1; private final boolean hasPBufferES2; SharedResource(EGLGraphicsDevice dev, - boolean wasContextES1Created, boolean hasPBufferES1, - boolean wasContextES2Created, boolean hasPBufferES2 - /*EGLDrawable draw, EGLContext ctxES1, EGLContext ctxES2 */) { + boolean wasContextES1Created, boolean hasPBufferES1, GLRendererQuirks rendererQuirksES1, int ctpES1, + boolean wasContextES2Created, boolean hasPBufferES2, GLRendererQuirks rendererQuirksES2, int ctpES2) { this.device = dev; - // this.drawable = draw; // this.contextES1 = ctxES1; // this.contextES2 = ctxES2; + this.rendererQuirksES1 = rendererQuirksES1; + this.rendererQuirksES2 = rendererQuirksES2; + this.ctpES1 = ctpES1; + this.ctpES2 = ctpES2; this.wasES1ContextCreated = wasContextES1Created; this.wasES2ContextCreated = wasContextES2Created; this.hasPBufferES1= hasPBufferES1; this.hasPBufferES2= hasPBufferES2; } final EGLGraphicsDevice getDevice() { return device; } - // final EGLDrawable getDrawable() { return drawable; } // final EGLContext getContextES1() { return contextES1; } // final EGLContext getContextES2() { return contextES2; } + final GLRendererQuirks getGLRendererQuirksES1() { return rendererQuirksES1; } + final GLRendererQuirks getGLRendererQuirksES2() { return rendererQuirksES2; } + final int getCtpES1() { return ctpES1; } + final int getCtpES2() { return ctpES2; } final boolean wasES1ContextAvailable() { return wasES1ContextCreated; } final boolean wasES2ContextAvailable() { return wasES2ContextCreated; } final boolean hasES1PBuffer() { return hasPBufferES1; } @@ -297,12 +308,23 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return new ArrayList(0); } - private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, EGLGraphicsDevice sharedEGLDevice, String profileString, boolean[] hasPBuffer) { - if( !GLProfile.isAvailable(adevice, profileString) ) { + private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, int esProfile, + boolean[] hasPBuffer, GLRendererQuirks[] rendererQuirks, int[] ctp) { + final String profileString; + switch( esProfile ) { + case 1: + profileString = GLProfile.GLES1; break; + case 2: + default: + profileString = GLProfile.GLES2; break; + } + if ( !GLProfile.isAvailable(adevice, profileString) ) { return false; } final GLProfile glp = GLProfile.get(adevice, profileString) ; final GLDrawableFactoryImpl desktopFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory(); + final boolean mapsADeviceToDefaultDevice = !QUERY_EGL_ES_NATIVE_TK || null == desktopFactory || adevice instanceof EGLGraphicsDevice ; + EGLGraphicsDevice eglDevice = null; NativeSurface surface = null; ProxySurface upstreamSurface = null; // X11, GLX, .. @@ -312,27 +334,49 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final GLCapabilities reqCapsAny = new GLCapabilities(glp); reqCapsAny.setRedBits(5); reqCapsAny.setGreenBits(5); reqCapsAny.setBlueBits(5); reqCapsAny.setAlphaBits(0); reqCapsAny.setDoubleBuffered(false); - final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny); - final List availablePBufferCapsL = getAvailableEGLConfigs(sharedEGLDevice, reqCapsPBuffer); - hasPBuffer[0] = availablePBufferCapsL.size() > 0; - if(adevice instanceof EGLGraphicsDevice || null == desktopFactory || !QUERY_EGL_ES_NATIVE_TK) { - eglDevice = sharedEGLDevice; // reuse + if( mapsADeviceToDefaultDevice ) { + // In this branch, any non EGL device is mapped to EGL default shared resources (default behavior). + // Only one default shared resource instance is ever be created. + final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny); + final List availablePBufferCapsL = getAvailableEGLConfigs(defaultDevice, reqCapsPBuffer); + hasPBuffer[0] = availablePBufferCapsL.size() > 0; + + // 1st case: adevice is not the EGL default device, map default shared resources + if( adevice != defaultDevice ) { + if(null == defaultSharedResource) { + return false; + } + switch(esProfile) { + case 1: + rendererQuirks[0] = defaultSharedResource.rendererQuirksES1; + ctp[0] = defaultSharedResource.ctpES1; + break; + case 2: + rendererQuirks[0] = defaultSharedResource.rendererQuirksES2; + ctp[0] = defaultSharedResource.ctpES2; + break; + } + EGLContext.mapStaticGLVersion(adevice, esProfile, 0, ctp[0]); + return true; + } + + // attempt to created the default shared resources .. + + eglDevice = defaultDevice; // reuse + if( hasPBuffer[0] ) { + // 2nd case create defaultDevice shared resource using pbuffer surface surface = createDummySurfaceImpl(eglDevice, false, reqCapsPBuffer, null, 64, 64); // egl pbuffer offscreen upstreamSurface = (ProxySurface)surface; upstreamSurface.createNotify(); deviceFromUpstreamSurface = false; } else { + // 3rd case fake creation of defaultDevice shared resource, no pbuffer available final List capsAnyL = getAvailableEGLConfigs(eglDevice, reqCapsAny); if(capsAnyL.size() > 0) { final GLCapabilitiesImmutable chosenCaps = capsAnyL.get(0); EGLContext.mapStaticGLESVersion(eglDevice, chosenCaps); - if(eglDevice != adevice) { - EGLContext.mapStaticGLESVersion(adevice, chosenCaps); - } - final EGLGraphicsDevice adeviceEGLDevice = new EGLGraphicsDevice(adevice.getHandle(), EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), null); - EGLContext.mapStaticGLESVersion(adeviceEGLDevice, chosenCaps); success = true; } if(DEBUG) { @@ -341,6 +385,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } } } else { + // 4th case always creates a true mapping of given device to EGL surface = desktopFactory.createDummySurface(adevice, reqCapsAny, null, 64, 64); // X11, WGL, .. dummy window upstreamSurface = ( surface instanceof ProxySurface ) ? (ProxySurface)surface : null ; if(null != upstreamSurface) { @@ -365,8 +410,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(eglDevice != adevice) { context.mapCurrentAvailableGLVersion(adevice); } - final EGLGraphicsDevice adeviceEGLDevice = new EGLGraphicsDevice(adevice.getHandle(), EGL.EGL_NO_DISPLAY, adevice.getConnection(), adevice.getUnitID(), null); - context.mapCurrentAvailableGLVersion(adeviceEGLDevice); + rendererQuirks[0] = context.getRendererQuirks(); + ctp[0] = context.getContextOptions(); success = true; } else { // Oops .. something is wrong @@ -393,7 +438,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } success = false; } finally { - if(eglDevice == sharedEGLDevice) { + if(eglDevice == defaultDevice) { if(null != upstreamSurface) { upstreamSurface.destroyNotify(); } @@ -416,67 +461,101 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return success; } - /* package */ SharedResource getOrCreateEGLSharedResource(AbstractGraphicsDevice adevice) { - if(null == sharedMap) { // null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper - return null; - } - final String connection = adevice.getConnection(); - SharedResource sr; - boolean createAttempted; + private final boolean needsToCreateSharedResource(String key, SharedResource[] existing) { synchronized(sharedMap) { - sr = sharedMap.get(connection); + final SharedResource sr = sharedMap.get(key); if( null == sr ) { - createAttempted = sharedMapCreateAttempt.contains(connection); + final boolean createAttempted = sharedMapCreateAttempt.contains(key); if(!createAttempted) { - sharedMapCreateAttempt.add(connection); + sharedMapCreateAttempt.add(key); } + return !createAttempted; } else { - createAttempted = true; - } - } - if(null==sr && !createAttempted) { - final boolean madeCurrentES1; - final boolean madeCurrentES2; - final EGLGraphicsDevice sharedDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); - boolean[] hasPBufferES1 = new boolean[1]; - boolean[] hasPBufferES2 = new boolean[1]; - - if(QUERY_EGL_ES) { - madeCurrentES1 = mapAvailableEGLESConfig(adevice, sharedDevice, GLProfile.GLES1, hasPBufferES1); - madeCurrentES2 = mapAvailableEGLESConfig(adevice, sharedDevice, GLProfile.GLES2, hasPBufferES2); - } else { - madeCurrentES1 = true; - madeCurrentES2 = true; - hasPBufferES1[0] = true; - hasPBufferES2[0] = true; - EGLContext.mapStaticGLESVersion(sharedDevice, 1); - if(sharedDevice != adevice) { - EGLContext.mapStaticGLESVersion(adevice, 1); - } - EGLContext.mapStaticGLESVersion(sharedDevice, 2); - if(sharedDevice != adevice) { - EGLContext.mapStaticGLESVersion(adevice, 2); + if(null != existing) { + existing[0] = sr; } + return false; } - - if( !EGLContext.getAvailableGLVersionsSet(adevice) ) { - // Even though we override the non EGL native mapping intentionally, - // avoid exception due to double 'set' - carefull exception of the rule. - EGLContext.setAvailableGLVersionsSet(adevice); + } + } + + /* package */ SharedResource getOrCreateEGLSharedResource(AbstractGraphicsDevice adevice) { + if(null == sharedMap) { // null == eglES1DynamicLookupHelper && null == eglES2DynamicLookupHelper + return null; + } + + if( needsToCreateSharedResource(defaultDevice.getUniqueID(), null) ) { + if (DEBUG) { + System.err.println("EGLDrawableFactory.createShared: (defaultDevice): req. device: "+adevice+", defaultDevice "+defaultDevice); + Thread.dumpStack(); } - sr = new SharedResource(sharedDevice, madeCurrentES1, hasPBufferES1[0], madeCurrentES2, hasPBufferES2[0]); - - synchronized(sharedMap) { - sharedMap.put(connection, sr); - if(adevice != sharedDevice) { - sharedMap.put(sharedDevice.getConnection(), sr); - } + if(null != defaultSharedResource) { + dumpMap(); + throw new InternalError("defaultSharedResource already exist: "+defaultSharedResource); } - if (DEBUG) { - System.err.println("EGLDrawableFactory.createShared: devices: queried " + QUERY_EGL_ES + "[nativeTK "+QUERY_EGL_ES_NATIVE_TK+"], " + adevice + ", " + sharedDevice); - System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]); - System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES2[0]); + defaultSharedResource = createEGLSharedResourceImpl(defaultDevice); + } + + final String key = adevice.getUniqueID(); + if( defaultDevice.getUniqueID().equals(key) ) { + return defaultSharedResource; + } else { + if( null == defaultSharedResource) { // defaultDevice must be initialized before host-device + dumpMap(); + throw new InternalError("defaultSharedResource does not exist"); } + final SharedResource[] existing = new SharedResource[] { null }; + if ( !needsToCreateSharedResource(key, existing) ) { + return existing[0]; + } + return createEGLSharedResourceImpl(adevice); + } + } + + private SharedResource createEGLSharedResourceImpl(AbstractGraphicsDevice adevice) { + final boolean madeCurrentES1; + final boolean madeCurrentES2; + boolean[] hasPBufferES1 = new boolean[] { false }; + boolean[] hasPBufferES2 = new boolean[] { false }; + // EGLContext[] eglCtxES1 = new EGLContext[] { null }; + // EGLContext[] eglCtxES2 = new EGLContext[] { null }; + GLRendererQuirks[] rendererQuirksES1 = new GLRendererQuirks[] { null }; + GLRendererQuirks[] rendererQuirksES2 = new GLRendererQuirks[] { null }; + int[] ctpES1 = new int[] { -1 }; + int[] ctpES2 = new int[] { -1 }; + + + if (DEBUG) { + System.err.println("EGLDrawableFactory.createShared(): device "+adevice); + } + + if( null != eglES1DynamicLookupHelper ) { + madeCurrentES1 = mapAvailableEGLESConfig(adevice, 1, hasPBufferES1, rendererQuirksES1, ctpES1); + } else { + madeCurrentES1 = false; + } + if( null != eglES2DynamicLookupHelper ) { + madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES2, rendererQuirksES2, ctpES2); + } else { + madeCurrentES2 = false; + } + + if( !EGLContext.getAvailableGLVersionsSet(adevice) ) { + // Even though we override the non EGL native mapping intentionally, + // avoid exception due to double 'set' - carefull exception of the rule. + EGLContext.setAvailableGLVersionsSet(adevice); + } + final SharedResource sr = new SharedResource(defaultDevice, madeCurrentES1, hasPBufferES1[0], rendererQuirksES1[0], ctpES1[0], + madeCurrentES2, hasPBufferES2[0], rendererQuirksES2[0], ctpES2[0]); + + synchronized(sharedMap) { + sharedMap.put(adevice.getUniqueID(), sr); + } + if (DEBUG) { + System.err.println("EGLDrawableFactory.createShared: devices: queried nativeTK "+QUERY_EGL_ES_NATIVE_TK+", adevice " + adevice + ", defaultDevice " + defaultDevice); + System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]); + System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES2[0]); + dumpMap(); } return sr; } @@ -504,9 +583,18 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) { - return null; // n/a for EGL .. since we don't keep the resources + return null; // FIXME: n/a .. } - + + @Override + public GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device) { + SharedResource sr = getOrCreateEGLSharedResource(device); + if(null!=sr) { + return null != sr.getGLRendererQuirksES2() ? sr.getGLRendererQuirksES2() : sr.getGLRendererQuirksES1() ; + } + return null; + } + @Override protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) { SharedResource sr = getOrCreateEGLSharedResource(device); @@ -596,9 +684,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override public final ProxySurface createDummySurfaceImpl(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable requestedCaps, GLCapabilitiesChooser chooser, int width, int height) { - final GLCapabilitiesImmutable chosenCaps = - GLGraphicsConfigurationUtil.fixDoubleBufferedGLCapabilities( - GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(requestedCaps, false, canCreateGLPbuffer(deviceReq)), false); + final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixOffscreenBitOnly(requestedCaps); // complete validation in EGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic(..) above return createMutableSurfaceImpl(deviceReq, createNewDevice, chosenCaps, requestedCaps, chooser, new EGLDummyUpstreamSurfaceHook(width, height)); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index e72255108..a2ac22fa5 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -247,9 +247,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } final GLProfile glp = capsChosen.getGLProfile(); - final EGLDrawableFactory factory = (EGLDrawableFactory) GLDrawableFactory.getEGLFactory(); - capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(absDevice, glp), factory.canCreateGLPbuffer(absDevice) ); - + capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLDrawableFactory.getEGLFactory(), absDevice); EGLGraphicsConfiguration res = eglChooseConfig(eglDevice, capsChosen, capsReq, chooser, absScreen, nativeVisualID, forceTransparentFlag); if(null==res) { if(DEBUG) { diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index e174d38f4..06f8c0c25 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -45,7 +45,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; -import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; @@ -64,7 +63,6 @@ import javax.media.opengl.GLProfile; import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.macosx.OSXDummyUpstreamSurfaceHook; import jogamp.opengl.DesktopGLDynamicLookupHelper; -import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; @@ -148,7 +146,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { static class SharedResource { // private MacOSXCGLDrawable drawable; - // private MacOSXCGLContext context; + private MacOSXCGLContext context; MacOSXGraphicsDevice device; boolean wasContextCreated; boolean hasNPOTTextures; @@ -157,9 +155,9 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { SharedResource(MacOSXGraphicsDevice device, boolean wasContextCreated, boolean hasNPOTTextures, boolean hasRECTTextures, boolean hasAppletFloatPixels - /* MacOSXCGLDrawable draw, MacOSXCGLContext ctx */) { + /* MacOSXCGLDrawable draw */, MacOSXCGLContext ctx) { // drawable = draw; - // context = ctx; + this.context = ctx; this.device = device; this.wasContextCreated = wasContextCreated; this.hasNPOTTextures = hasNPOTTextures; @@ -167,6 +165,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { this.hasAppleFloatPixels = hasAppletFloatPixels; } final MacOSXGraphicsDevice getDevice() { return device; } + final MacOSXCGLContext getContext() { return context; } final boolean wasContextAvailable() { return wasContextCreated; } final boolean isNPOTTextureAvailable() { return hasNPOTTextures; } final boolean isRECTTextureAvailable() { return hasRECTTextures; } @@ -213,6 +212,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { if(null==sr && !getDeviceTried(connection)) { addDeviceTried(connection); final MacOSXGraphicsDevice sharedDevice = new MacOSXGraphicsDevice(adevice.getUnitID()); + final MacOSXCGLContext sharedContext; boolean madeCurrent = false; boolean hasNPOTTextures = false; boolean hasRECTTextures = false; @@ -225,7 +225,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); sharedDrawable.setRealized(true); - final GLContextImpl sharedContext = (GLContextImpl) sharedDrawable.createContext(null); + sharedContext = (MacOSXCGLContext) sharedDrawable.createContext(null); if (null == sharedContext) { throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); } @@ -256,7 +256,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } sharedDrawable.setRealized(false); } - sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppleFloatPixels); + sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppleFloatPixels, sharedContext); synchronized(sharedMap) { sharedMap.put(connection, sr); } @@ -293,7 +293,10 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) { - // FIXME: not implemented .. needs a dummy OSX surface + SharedResource sr = getOrCreateOSXSharedResource(device); + if(null!=sr) { + return sr.getContext(); + } return null; } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java index 43a9d0d1a..3bbba2c52 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLGraphicsConfigurationFactory.java @@ -35,7 +35,6 @@ package jogamp.opengl.macosx.cgl; import jogamp.opengl.GLGraphicsConfigurationFactory; import jogamp.opengl.GLGraphicsConfigurationUtil; -import jogamp.opengl.x11.glx.X11GLXDrawableFactory; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -45,7 +44,6 @@ import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; @@ -91,10 +89,8 @@ public class MacOSXCGLGraphicsConfigurationFactory extends GLGraphicsConfigurati if (absScreen == null) { throw new IllegalArgumentException("AbstractGraphicsScreen is null"); } - final MacOSXCGLDrawableFactory factory = (MacOSXCGLDrawableFactory) GLDrawableFactory.getDesktopFactory(); final AbstractGraphicsDevice device = absScreen.getDevice(); - - capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(device) ); + capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLDrawableFactory.getDesktopFactory(), device); return new MacOSXCGLGraphicsConfiguration(absScreen, (GLCapabilitiesImmutable)capsChosen, (GLCapabilitiesImmutable)capsRequested); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index d2d1dafc8..10d7fb22b 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -105,10 +105,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat absScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); } final AbstractGraphicsDevice absDevice = absScreen.getDevice(); - final GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory(); - capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( - capsChosen, GLContext.isFBOAvailable(absDevice, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(absDevice) ); - + capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLDrawableFactory.getDesktopFactory(), absDevice); return new WindowsWGLGraphicsConfiguration( absScreen, capsChosen, capsReq, (GLCapabilitiesChooser)chooser ); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index 431706e24..ef2d3283d 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -45,7 +45,6 @@ import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -213,9 +212,9 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF } X11GraphicsDevice x11Device = (X11GraphicsDevice) x11Screen.getDevice(); X11GLXDrawableFactory factory = (X11GLXDrawableFactory) GLDrawableFactory.getDesktopFactory(); - - capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLContext.isFBOAvailable(x11Device, capsChosen.getGLProfile()), factory.canCreateGLPbuffer(x11Device) ); - boolean usePBuffer = !capsChosen.isOnscreen() && capsChosen.isPBuffer(); + + capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, factory, x11Device); + final boolean usePBuffer = !capsChosen.isOnscreen() && capsChosen.isPBuffer(); X11GLXGraphicsConfiguration res = null; if( factory.isGLXVersionGreaterEqualOneThree(x11Device) ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java index 4628a5a58..829739caa 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java @@ -84,10 +84,7 @@ public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase { void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { System.out.println("Requested GL Caps: "+reqGLCaps); final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - - final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); - final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); - final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, factory, null); System.out.println("Expected GL Caps: "+expGLCaps); // // Create native windowing resources .. X11/Win/OSX @@ -238,7 +235,7 @@ public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase { reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } - + @Test public void testGL2OffScreenAutoDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java index d318446d2..1f5ac9b8a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java @@ -73,10 +73,7 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { System.out.println("Requested GL Caps: "+reqGLCaps); final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - - final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); - final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); - final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, factory, null); System.out.println("Expected GL Caps: "+expGLCaps); // @@ -212,8 +209,8 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); reqGLCaps.setSampleBuffers(true); doTest(reqGLCaps, new GearsES2(1)); - } - + } + @Test public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -221,7 +218,7 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { reqGLCaps.setOnscreen(false); reqGLCaps.setPBuffer(true); doTest(reqGLCaps, new GearsES2(1)); - } + } @Test public void testGL2OffScreenPbufferSglBuf() throws InterruptedException { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java index fac40de35..a2ffa9069 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java @@ -106,10 +106,7 @@ public class TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT extends UITestCase { } System.out.println("Requested GL Caps: "+reqGLCaps); final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - - final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); - final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); - final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, factory, null); System.out.println("Expected GL Caps: "+expGLCaps); // // Create native windowing resources .. X11/Win/OSX diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java index 145078629..da5456777 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java @@ -78,10 +78,7 @@ public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { System.out.println("Requested GL Caps: "+reqGLCaps); final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - - final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); - final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); - final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, factory, null); System.out.println("Expected GL Caps: "+expGLCaps); // // Create native windowing resources .. X11/Win/OSX diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java index 47fc99844..37483f7e7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java @@ -33,6 +33,7 @@ import java.awt.Dimension; import java.awt.Frame; import java.io.IOException; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -108,12 +109,10 @@ public class TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT extends UITestCase } System.out.println("Requested GL Caps: "+reqGLCaps); final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - - final boolean fboAvailable = factory.canCreateFBO(null, reqGLCaps.getGLProfile()); - final boolean pbufferAvailable = factory.canCreateGLPbuffer(null); + final AbstractGraphicsDevice device = factory.getDefaultDevice(); final GLCapabilitiesImmutable expGLCaps = offscreenLayer ? - GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable) : - GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, fboAvailable, pbufferAvailable); + GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(reqGLCaps, factory, device) : + GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, factory, device); System.out.println("Expected GL Caps: "+expGLCaps); final GLWindow glad = GLWindow.create(reqGLCaps); -- cgit v1.2.3 From 5b378cb2cd162cb9af44812c37935eb3a83aabd2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 21 Sep 2012 07:20:37 +0200 Subject: MacOSXCGLDrawableFactory: Cannot use shared context to retrieve quirks since it's transient, store it. --- make/scripts/tests.sh | 4 +-- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 31 +++++++++++++++------- 2 files changed, 23 insertions(+), 12 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a5fb898a8..9f09ffa6b 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -250,13 +250,13 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index 06f8c0c25..d59197e1d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -73,6 +73,7 @@ import com.jogamp.common.util.ReflectionUtil; import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.opengl.GLExtensions; +import com.jogamp.opengl.GLRendererQuirks; public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { private static DesktopGLDynamicLookupHelper macOSXCGLDynamicLookupHelper = null; @@ -146,7 +147,8 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { static class SharedResource { // private MacOSXCGLDrawable drawable; - private MacOSXCGLContext context; + // private MacOSXCGLContext context; + private GLRendererQuirks glRendererQuirks; MacOSXGraphicsDevice device; boolean wasContextCreated; boolean hasNPOTTextures; @@ -155,9 +157,10 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { SharedResource(MacOSXGraphicsDevice device, boolean wasContextCreated, boolean hasNPOTTextures, boolean hasRECTTextures, boolean hasAppletFloatPixels - /* MacOSXCGLDrawable draw */, MacOSXCGLContext ctx) { + /* MacOSXCGLDrawable draw, MacOSXCGLContext ctx */, GLRendererQuirks glRendererQuirks) { // drawable = draw; - this.context = ctx; + // this.context = ctx; + this.glRendererQuirks = glRendererQuirks; this.device = device; this.wasContextCreated = wasContextCreated; this.hasNPOTTextures = hasNPOTTextures; @@ -165,7 +168,8 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { this.hasAppleFloatPixels = hasAppletFloatPixels; } final MacOSXGraphicsDevice getDevice() { return device; } - final MacOSXCGLContext getContext() { return context; } + // final MacOSXCGLContext getContext() { return context; } + final GLRendererQuirks getGLRendererQuirks() { return glRendererQuirks; } final boolean wasContextAvailable() { return wasContextCreated; } final boolean isNPOTTextureAvailable() { return hasNPOTTextures; } final boolean isRECTTextureAvailable() { return hasRECTTextures; } @@ -212,7 +216,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { if(null==sr && !getDeviceTried(connection)) { addDeviceTried(connection); final MacOSXGraphicsDevice sharedDevice = new MacOSXGraphicsDevice(adevice.getUnitID()); - final MacOSXCGLContext sharedContext; + GLRendererQuirks glRendererQuirks = null; boolean madeCurrent = false; boolean hasNPOTTextures = false; boolean hasRECTTextures = false; @@ -225,7 +229,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { final GLDrawableImpl sharedDrawable = createOnscreenDrawableImpl(createDummySurfaceImpl(sharedDevice, false, new GLCapabilities(glp), null, 64, 64)); sharedDrawable.setRealized(true); - sharedContext = (MacOSXCGLContext) sharedDrawable.createContext(null); + final MacOSXCGLContext sharedContext = (MacOSXCGLContext) sharedDrawable.createContext(null); if (null == sharedContext) { throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); } @@ -238,6 +242,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { hasNPOTTextures = gl.isNPOTTextureAvailable(); hasRECTTextures = gl.isExtensionAvailable(GLExtensions.EXT_texture_rectangle); hasAppleFloatPixels = gl.isExtensionAvailable(GLExtensions.APPLE_float_pixels); + glRendererQuirks = sharedContext.getRendererQuirks(); } } catch (GLException gle) { if (DEBUG) { @@ -256,7 +261,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } sharedDrawable.setRealized(false); } - sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppleFloatPixels, sharedContext); + sr = new SharedResource(sharedDevice, madeCurrent, hasNPOTTextures, hasRECTTextures, hasAppleFloatPixels, glRendererQuirks); synchronized(sharedMap) { sharedMap.put(connection, sr); } @@ -264,7 +269,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { if (DEBUG) { System.err.println("MacOSXCGLDrawableFactory.createShared: device: " + sharedDevice); System.err.println("MacOSXCGLDrawableFactory.createShared: context: madeCurrent " + madeCurrent + ", NPOT "+hasNPOTTextures+ - ", RECT "+hasRECTTextures+", FloatPixels "+hasAppleFloatPixels); + ", RECT "+hasRECTTextures+", FloatPixels "+hasAppleFloatPixels+", "+glRendererQuirks); } } return sr; @@ -293,13 +298,19 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { @Override protected final GLContext getOrCreateSharedContextImpl(AbstractGraphicsDevice device) { + // FIXME: no more available + return null; + } + + @Override + public GLRendererQuirks getRendererQuirks(AbstractGraphicsDevice device) { SharedResource sr = getOrCreateOSXSharedResource(device); if(null!=sr) { - return sr.getContext(); + return sr.getGLRendererQuirks(); } return null; } - + @Override protected AbstractGraphicsDevice getOrCreateSharedDeviceImpl(AbstractGraphicsDevice device) { SharedResource sr = getOrCreateOSXSharedResource(device); -- cgit v1.2.3 From 459af1bba130495943e51ff289a094b602c642cd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 21 Sep 2012 08:28:42 +0200 Subject: MacOSXCGLContext: Fix missing initialization of 'needsSetContextPBuffer' if not offscreen-layer. --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 8 ++++---- .../jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9f09ffa6b..b8960d518 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -250,7 +250,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* @@ -426,7 +426,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOf # # Security # -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* # diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 929ac00c2..eae365925 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -488,6 +488,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl throw new RuntimeException("Anonymous drawable instance's handle neither NSView, NSWindow nor PBuffer: "+toHexString(drawableHandle)+", "+drawable.getClass().getName()+",\n\t"+drawable); } } + needsSetContextPBuffer = isPBuffer; backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); boolean incompleteView = null != backingLayerHost; @@ -600,11 +601,12 @@ public abstract class MacOSXCGLContext extends GLContextImpl public void swapBuffers(boolean doubleBuffered) { MacOSXCGLContext.NSOpenGLImpl.this.swapBuffers(); } } ) ; - } else if( chosenCaps.isPBuffer() && CGL.isNSOpenGLPixelBuffer(drawableHandle) ) { + } else if( CGL.isNSOpenGLPixelBuffer(drawableHandle) ) { texID = 0; pbufferHandle = drawableHandle; if(0 != drawableHandle) { // complete 'validatePBufferConfig(..)' procedure CGL.setContextPBuffer(ctx, pbufferHandle); + needsSetContextPBuffer = false; } } else { throw new GLException("BackingLayerHost w/ unknown handle (!FBO, !PBuffer): "+drawable); @@ -652,9 +654,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl if( needsSetContextPBuffer && 0 != drawableHandle && CGL.isNSOpenGLPixelBuffer(drawableHandle) ) { // Must associate the pbuffer with our newly-created context needsSetContextPBuffer = false; - if(0 != drawableHandle) { - CGL.setContextPBuffer(ctx, drawableHandle); - } + CGL.setContextPBuffer(ctx, drawableHandle); if(DEBUG) { System.err.println("NS.validateDrawableConfig bind pbuffer "+toHexString(drawableHandle)+" -> ctx "+toHexString(ctx)); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java index bebe3531e..60803433d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGPUMemSec01NEWT.java @@ -61,6 +61,8 @@ public class TestGPUMemSec01NEWT extends UITestCase { new GLCapabilities(glp), width, height, true); final GL gl = winctx.context.getGL(); + // System.err.println("Pre GL Error: 0x"+Integer.toHexString(gl.glGetError())); + // System.err.println(winctx.drawable); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); // misc GL setup @@ -249,7 +251,7 @@ public class TestGPUMemSec01NEWT extends UITestCase { NEWTGLContext.destroyWindow(winctx); } - + @Test public void testReadPixelsGL_99x100xRGBxUB() throws InterruptedException { GLProfile glp = GLProfile.getGL2ES2(); -- cgit v1.2.3 From ba846a478d616327817dd530dbdcd9a786be5b7a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 21 Sep 2012 22:18:20 +0200 Subject: Fix Bug 621, JVM Crashes During X11 Shutdown while closing all unclosed display connections. This is a regression of JOGL commit f2cfb6119a3663715ed2d572643949b3bef58662 to fix Bug 610. Commit f2cfb6119a3663715ed2d572643949b3bef58662 closed all open display connections at JVM shutdown in order of their creation. This is required IF the driver is the proprietary ATI on X11. X11Util.setMarkAllDisplaysUnclosable(true) is called in this case. However, this behavior causes a SIGSEGV for other GPU driver, i.e. Nvidia :) This fix only closes the pending display connections in their respective order IF X11Util.getMarkAllDisplaysUnclosable() == true. Hence the 'new' cleanup as introduced in the offending commit is only performed on the erroneous ATI driver. Manually tested w/ TestGearsES2AWT, see it's commandline options for details. --- make/scripts/tests.sh | 4 +- .../classes/jogamp/nativewindow/x11/X11Util.java | 45 ++++++++++++---------- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 23 ++++++++++- 3 files changed, 47 insertions(+), 25 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b8960d518..8a0a638ba 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -322,7 +322,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* @@ -426,7 +426,7 @@ function testawtswt() { # # Security # -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* # diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 93b7f3487..2ea75c7fb 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -70,7 +70,12 @@ public class X11Util { * See also native test: jogl/test-native/displayMultiple02.c *

    *

    - * Workaround is to not close them at all if driver vendor is ATI. + * Workaround is to not close them at all if driver vendor is ATI + * during operation. + *

    + *

    + * With ATI X11 drivers all connections must be closed at JVM shutdown, + * otherwise a SIGSEGV (after JVM safepoint) will be caused. *

    */ public static final boolean ATI_HAS_XCLOSEDISPLAY_BUG = !Debug.isPropertyDefined("nativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG", true); @@ -141,6 +146,14 @@ public class X11Util { } } + // not exactly thread safe, but good enough for our purpose, + // which is to tag a NamedDisplay uncloseable after creation. + private static Object globalLock = new Object(); + private static LongObjectHashMap openDisplayMap = new LongObjectHashMap(); // handle -> name + private static List openDisplayList = new ArrayList(); // open, no close attempt + private static List reusableDisplayList = new ArrayList(); // close attempt, marked uncloseable, for reuse + private static List pendingDisplayList = new ArrayList(); // all open (close attempt or reusable) in creation order + /** * Cleanup resources. *

    @@ -156,7 +169,7 @@ public class X11Util { System.err.println("X11Util.Display: Shutdown (JVM shutdown: "+isJVMShuttingDown+ ", open (no close attempt): "+openDisplayMap.size()+"/"+openDisplayList.size()+ ", reusable (open, marked uncloseable): "+reusableDisplayList.size()+ - ", pending (post closing): "+pendingDisplayList.size()+ + ", pending (open in creation order): "+pendingDisplayList.size()+ ")"); if(DEBUG) { Thread.dumpStack(); @@ -227,14 +240,6 @@ public class X11Util { private X11Util() {} - // not exactly thread safe, but good enough for our purpose, - // which is to tag a NamedDisplay uncloseable after creation. - private static Object globalLock = new Object(); - private static LongObjectHashMap openDisplayMap = new LongObjectHashMap(); // handle -> name - private static List openDisplayList = new ArrayList(); - private static List reusableDisplayList = new ArrayList(); - private static List pendingDisplayList = new ArrayList(); - public static class NamedDisplay { final String name; final long handle; @@ -296,23 +301,21 @@ public class X11Util { } /** - * Closing pending Display connections in reverse order. + * Closing pending Display connections in original creation order, if {@link #getMarkAllDisplaysUnclosable()} is true. * * @return number of closed Display connections */ - public static int closePendingDisplayConnections() { + private static int closePendingDisplayConnections() { int num=0; synchronized(globalLock) { - if(DEBUG) { - System.err.println("X11Util: Closing Pending X11 Display Connections in order of their creation: "+pendingDisplayList.size()); - } - for(int i=0; i Date: Thu, 27 Sep 2012 17:33:39 +0200 Subject: Fix Bug 616: X11: Remove XInitThreads() dependency while cleaning up device locking, resulting in a native-lock-free impl. The X11 implementation details of NativeWindow and NEWT used the X11 implicit locking facility XLockDisplay/XUnlockDisplay, enabled via XInitThreads(). The latter useage is complicated within an unsure environment where the initialization point of JOGL is unknown, but XInitThreads() requires to be called once and before any other X11 calls. The solution is simple and thorough, replace native X11 locking w/ 'application level' locking. Following this pattern actually cleans up a pretty messy part of X11 NativeWindow and NEWT, since the generalization of platform independent locking simplifies code. Simply using our RecursiveLock also speeds up locking, since it doesn't require JNI calls down to X11 anymore. It allows us to get rid of X11ToolkitLock and X11JAWTToolkitLock. Using the RecursiveLock also allows us to remove the shortcut of explicitly createing a NullToolkitLocked device for 'private' display connections. All devices use proper locking as claimed in their toolkit util 'requiresToolkitLock()' in X11Util, OSXUtil, .. Further more a bug has been fixed of X11ErrorHandler usage, i.e. we need to keep our handler alive at all times due to async X11 messaging behavior. This allows to remove the redundant code in X11/NEWT. The AbstractGraphicsDevice lifecycle has been fixed as well, i.e. called when closing NEWT's Display for all driver implementations. On the NEWT side the Display's AbstractGraphicsDevice semantics has been clarified, i.e. it's usage for EDT and lifecycle operations. Hence the X11 Display 2nd device for rendering operations has been moved to X11 Window where it belongs - and the X11 Display's default device used for EDT/lifecycle-ops as it should be. This allows running X11/NEWT properly with the default usage, where the Display instance and hence the EDT thread is shared with many Screen and Window. Rendering using NEWT Window is decoupled from it's shared Display lock via it's own native X11 display. Lock free AbstractGraphicsDevice impl. (Windows, OSX, ..) don't require any attention in this regard since they use NullToolkitLock. Tests: ====== This implementation has been tested manually with Mesa3d (soft, Intel), ATI and Nvidia on X11, Windows and OSX w/o any regressions found in any unit test. Issues on ATI: ============== Only on ATI w/o a composite renderer the unit tests expose a driver or WM bug where XCB claims a lack of locking. Setting env. var 'LIBXCB_ALLOW_SLOPPY_LOCK=true' is one workaround if users refuse to enable compositing. We may investigate this issue in more detail later on. --- make/scripts/tests.sh | 50 ++++- .../classes/jogamp/opengl/egl/EGLDisplayUtil.java | 3 +- .../jogamp/opengl/x11/glx/X11GLXContext.java | 37 +--- .../opengl/x11/glx/X11GLXDrawableFactory.java | 13 +- .../jogamp/nativewindow/x11/X11GraphicsDevice.java | 2 +- .../jogamp/nativewindow/x11/X11GraphicsScreen.java | 2 +- .../media/nativewindow/AbstractGraphicsDevice.java | 2 +- .../media/nativewindow/DefaultGraphicsDevice.java | 3 +- .../media/nativewindow/NativeWindowFactory.java | 99 ++------- .../javax/media/nativewindow/ToolkitLock.java | 18 +- .../jogamp/nativewindow/NullToolkitLock.java | 9 + .../jogamp/nativewindow/ResourceToolkitLock.java | 74 +++++++ .../nativewindow/SharedResourceToolkitLock.java | 141 +++++++++++++ .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 3 + .../nativewindow/jawt/x11/X11JAWTToolkitLock.java | 76 ------- .../nativewindow/jawt/x11/X11JAWTWindow.java | 3 +- .../jogamp/nativewindow/x11/X11ToolkitLock.java | 70 ------ .../classes/jogamp/nativewindow/x11/X11Util.java | 119 ++++------- .../awt/X11AWTGraphicsConfigurationFactory.java | 7 +- src/nativewindow/native/x11/Xmisc.c | 38 ++-- src/newt/classes/com/jogamp/newt/Display.java | 35 ++- src/newt/classes/com/jogamp/newt/NewtFactory.java | 2 +- src/newt/classes/com/jogamp/newt/Screen.java | 2 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 79 ++++--- src/newt/classes/jogamp/newt/ScreenImpl.java | 3 +- src/newt/classes/jogamp/newt/WindowImpl.java | 33 +-- .../jogamp/newt/driver/awt/DisplayDriver.java | 4 +- .../jogamp/newt/driver/bcm/egl/DisplayDriver.java | 2 + .../newt/driver/intel/gdl/DisplayDriver.java | 1 + .../jogamp/newt/driver/macosx/DisplayDriver.java | 4 +- .../jogamp/newt/driver/windows/DisplayDriver.java | 1 + .../jogamp/newt/driver/x11/DisplayDriver.java | 65 ++---- .../jogamp/newt/driver/x11/ScreenDriver.java | 31 ++- .../jogamp/newt/driver/x11/WindowDriver.java | 107 +++++++--- src/newt/native/X11Common.h | 1 - src/newt/native/X11Display.c | 91 -------- src/newt/native/X11Window.c | 10 - .../junit/jogl/acore/InitConcurrentBaseNEWT.java | 219 +++++++++++++++++++ .../junit/jogl/acore/TestInitConcurrent01NEWT.java | 78 +++++++ .../junit/jogl/acore/TestInitConcurrent02NEWT.java | 78 +++++++ .../junit/jogl/acore/TestInitConcurrentNEWT.java | 235 --------------------- 41 files changed, 964 insertions(+), 886 deletions(-) create mode 100644 src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java delete mode 100644 src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java delete mode 100644 src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrent02NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestInitConcurrentNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8a0a638ba..3dc983072 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -81,6 +81,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.UseCurrentThreadLibLoader" + #D_ARGS="-Djogamp.debug.NativeLibrary" #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" @@ -100,7 +101,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" - #D_ARGS="-Dnewt.debug.EDT -Dnativewindow.debug.ToolkitLock.TraceLock -Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" @@ -109,6 +109,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" + #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnativewindow.debug.X11Util" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock" @@ -135,7 +136,9 @@ function jrun() { #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas" - #D_ARGS="-Dnativewindow.debug.ToolkitLock.TraceLock" + #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" + #D_ARGS="-Dnativewindow.debug.X11Util.XSync" + #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" @@ -187,6 +190,8 @@ function jrun() { #export LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH=/usr/lib/mesa:/usr/lib32/mesa:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/mesa:/usr/lib/i386-linux-gnu/mesa:$LD_LIBRARY_PATH + #export LD_LIBRARY_PATH=`pwd`/lib/external/mesa/x86_64-linux-gnu:$LD_LIBRARY_PATH + #export LD_LIBRARY_PATH=`pwd`/lib/external/mesa/x86_64-linux-gnu/gallium:$LD_LIBRARY_PATH echo echo "Test Start: $*" echo @@ -194,10 +199,10 @@ function jrun() { echo echo $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* #LIBGL_DRIVERS_PATH=/usr/lib/mesa:/usr/lib32/mesa \ - #gdb --args $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* #LIBGL_DEBUG=verbose INTEL_STRICT_CONFORMANCE=1 INTEL_DEBUG="buf bat" \ #LIBGL_DEBUG=verbose MESA_DEBUG=true INTEL_STRICT_CONFORMANCE=1 \ - #LIBGL_DEBUG=verbose MESA_DEBUG=true LIBGL_ALWAYS_SOFTWARE=true \ + #export LIBGL_DEBUG=verbose MESA_DEBUG=true LIBGL_ALWAYS_SOFTWARE=true + #gdb --args $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* echo echo "Test End: $*" @@ -239,7 +244,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* @@ -250,6 +256,38 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +# x11 no XinitThreads() specific tests (regressions, concurrent behavior) ! +# Deadlock: +# com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 - test01 +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* +# com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT - testEachWithAnimatorSharedOffscreen +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* +# +# XCB: +# +# com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT - testShaderState01PerformanceDouble +#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* +# com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT - testWindowParenting02ReparentTop2WinReparentRecreate +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +# com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT - winHopFrame2FrameDirectHop +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* + +#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* + + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -322,7 +360,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index ce2e824f5..0a603ab8a 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -71,10 +71,9 @@ public class EGLDisplayUtil { Thread.dumpStack(); } if( eglDisplayCounter.size() > 0) { - EGLDisplayUtil.dumpOpenDisplayConnections(); + dumpOpenDisplayConnections(); } } - return eglDisplayCounter.size(); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index e1e25be67..bdccc1047 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -172,7 +172,6 @@ public abstract class X11GLXContext extends GLContextImpl { glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, ctx); } - private static final int ctx_arb_attribs_idx_major = 0; private static final int ctx_arb_attribs_idx_minor = 2; private static final int ctx_arb_attribs_idx_flags = 6; @@ -228,14 +227,14 @@ public abstract class X11GLXContext extends GLContextImpl { X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration)drawable.getNativeSurface().getGraphicsConfiguration(); AbstractGraphicsDevice device = config.getScreen().getDevice(); - long display = device.getHandle(); + final long display = device.getHandle(); try { // critical path, a remote display might not support this command, // hence we need to catch the X11 Error within this block. - X11Lib.XSync(display, false); + X11Util.setX11ErrorHandler(true, DEBUG ? false : true); // make sure X11 error handler is set ctx = _glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs); - X11Lib.XSync(display, false); + if(DEBUG) { X11Lib.XSync(display, false); } } catch (RuntimeException re) { if(DEBUG) { Throwable t = new Throwable(getThreadName()+": Info: X11GLXContext.createContextARBImpl glXCreateContextAttribsARB failed with "+getGLVersion(major, minor, ctp, "@creation"), re); @@ -263,16 +262,6 @@ public abstract class X11GLXContext extends GLContextImpl { @Override protected boolean createImpl(GLContextImpl shareWith) { - // covers the whole context creation loop incl createContextARBImpl and destroyContextARBImpl - X11Util.setX11ErrorHandler(true, DEBUG ? false : true); - try { - return createImplRaw(shareWith); - } finally { - X11Util.setX11ErrorHandler(false, false); - } - } - - private boolean createImplRaw(GLContextImpl shareWith) { boolean direct = true; // try direct always isDirect = false; // fall back @@ -401,14 +390,9 @@ public abstract class X11GLXContext extends GLContextImpl { protected void makeCurrentImpl() throws GLException { long dpy = drawable.getNativeSurface().getDisplayHandle(); - if (GLX.glXGetCurrentContext() != contextHandle) { - X11Util.setX11ErrorHandler(true, DEBUG ? false : true); - try { - if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { - throw new GLException(getThreadName()+": Error making context current: "+this); - } - } finally { - X11Util.setX11ErrorHandler(false, false); + if (GLX.glXGetCurrentContext() != contextHandle) { + if (!glXMakeContextCurrent(dpy, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { + throw new GLException(getThreadName()+": Error making context current: "+this); } } } @@ -416,13 +400,8 @@ public abstract class X11GLXContext extends GLContextImpl { @Override protected void releaseImpl() throws GLException { long display = drawable.getNativeSurface().getDisplayHandle(); - X11Util.setX11ErrorHandler(true, DEBUG ? false : true); - try { - if (!glXMakeContextCurrent(display, 0, 0, 0)) { - throw new GLException(getThreadName()+": Error freeing OpenGL context"); - } - } finally { - X11Util.setX11ErrorHandler(false, false); + if (!glXMakeContextCurrent(display, 0, 0, 0)) { + throw new GLException(getThreadName()+": Error freeing OpenGL context"); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index ca5cd424b..03c661565 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -47,7 +47,6 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.UpstreamSurfaceHook; import javax.media.nativewindow.VisualIDHolder; @@ -230,11 +229,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { @Override public SharedResourceRunner.Resource createSharedResource(String connection) { - final X11GraphicsDevice sharedDevice = - new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, - true); // own non-shared display connection, w/ locking - // new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, - // NativeWindowFactory.getNullToolkitLock(), true); // own non-shared display connection, w/o locking + final X11GraphicsDevice sharedDevice = new X11GraphicsDevice(X11Util.openDisplay(connection), AbstractGraphicsDevice.DEFAULT_UNIT, true); sharedDevice.lock(); try { final X11GraphicsScreen sharedScreen = new X11GraphicsScreen(sharedDevice, sharedDevice.getDefaultScreen()); @@ -509,8 +504,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstreamHook) { final X11GraphicsDevice device; if(createNewDevice) { - // Null X11 locking, due to private non-shared Display handle - device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), NativeWindowFactory.getNullToolkitLock(), true); + // Null X11 resource locking, due to private non-shared Display handle + device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true); } else { device = (X11GraphicsDevice)deviceReq; } @@ -531,7 +526,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { @Override protected final ProxySurface createProxySurfaceImpl(AbstractGraphicsDevice deviceReq, int screenIdx, long windowHandle, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, UpstreamSurfaceHook upstream) { - final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), NativeWindowFactory.getNullToolkitLock(), true); + final X11GraphicsDevice device = new X11GraphicsDevice(X11Util.openDisplay(deviceReq.getConnection()), deviceReq.getUnitID(), true); final X11GraphicsScreen screen = new X11GraphicsScreen(device, screenIdx); final int xvisualID = X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); if(VisualIDHolder.VID_UNDEFINED == xvisualID) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index 152384980..2e4099c1b 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -73,7 +73,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl /** * @param display the Display connection - * @param locker custom {@link javax.media.nativewindow.ToolkitLock}, eg to force null locking in NEWT + * @param locker custom {@link javax.media.nativewindow.ToolkitLock}, eg to force null locking w/ private connection * @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long, ToolkitLock) */ public X11GraphicsDevice(long display, int unitID, ToolkitLock locker, boolean owner) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index 5f3c220ca..7ab5bd6aa 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -63,7 +63,7 @@ public class X11GraphicsScreen extends DefaultGraphicsScreen implements Cloneabl private static int fetchScreen(X11GraphicsDevice device, int screen) { // It still could be an AWT hold handle .. - if(X11Util.XineramaIsEnabled(device.getHandle())) { + if(X11Util.XineramaIsEnabled(device)) { screen = 0; // Xinerama -> 1 screen } return screen; diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index 756e4451b..5eaaa6613 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -131,7 +131,7 @@ public interface AbstractGraphicsDevice extends Cloneable { /** * Optionally closing the device if handle is not null. *

    - * The default implementation is a NOP, just setting the handle to null. + * The default implementation {@link ToolkitLock#dispose() dispose} it's {@link ToolkitLock} and sets the handle to null. *

    *

    * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index 583fde07f..b16b0c75c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -153,6 +153,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice @Override public boolean close() { + toolkitLock.dispose(); if(0 != handle) { handle = 0; return true; @@ -162,7 +163,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice @Override public String toString() { - return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+"]"; + return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", "+toolkitLock+"]"; } /** diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 40aaa8a25..4f4bb629b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -33,7 +33,6 @@ package javax.media.nativewindow; -import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; @@ -43,6 +42,7 @@ import java.util.Map; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NativeWindowFactoryImpl; +import jogamp.nativewindow.ResourceToolkitLock; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; @@ -93,13 +93,6 @@ public abstract class NativeWindowFactory { private static ToolkitLock jawtUtilJAWTToolkitLock; - public static final String X11JAWTToolkitLockClassName = "jogamp.nativewindow.jawt.x11.X11JAWTToolkitLock" ; - public static final String X11ToolkitLockClassName = "jogamp.nativewindow.x11.X11ToolkitLock" ; - - private static Class x11JAWTToolkitLockClass; - private static Constructor x11JAWTToolkitLockConstructor; - private static Class x11ToolkitLockClass; - private static Constructor x11ToolkitLockConstructor; private static boolean requiresToolkitLock; private static volatile boolean isJVMShuttingDown = false; @@ -266,16 +259,6 @@ public abstract class NativeWindowFactory { // register either our default factory or (if exist) the X11/AWT one -> AWT Component registerFactory(ReflectionUtil.getClass(ReflectionUtil.AWTNames.ComponentClass, false, cl), factory); } - - if( TYPE_X11 == nativeWindowingTypePure ) { - // passing through RuntimeException if not exists intended - x11ToolkitLockClass = ReflectionUtil.getClass(X11ToolkitLockClassName, false, cl); - x11ToolkitLockConstructor = ReflectionUtil.getConstructor(x11ToolkitLockClass, new Class[] { long.class } ); - if( isAWTAvailable() ) { - x11JAWTToolkitLockClass = ReflectionUtil.getClass(X11JAWTToolkitLockClassName, false, cl); - x11JAWTToolkitLockConstructor = ReflectionUtil.getConstructor(x11JAWTToolkitLockClass, new Class[] { long.class } ); - } - } if(DEBUG) { System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock); @@ -300,6 +283,7 @@ public abstract class NativeWindowFactory { GraphicsConfigurationFactory.shutdown(); } shutdownNativeImpl(NativeWindowFactory.class.getClassLoader()); // always re-shutdown + // SharedResourceToolkitLock.shutdown(DEBUG); // not used yet if(DEBUG) { System.err.println(Thread.currentThread().getName()+" - NativeWindowFactory.shutdown() END JVM Shutdown "+isJVMShuttingDown); } @@ -358,16 +342,9 @@ public abstract class NativeWindowFactory { /** * Provides the default {@link ToolkitLock} for type, a singleton instance. - *
    *

      - *
    • If {@link #initSingleton(boolean) initSingleton( firstUIActionOnProcess := false )}
    • - *
        - *
      • If AWT-type and native-X11-type and AWT-available
      • - *
          - *
        • return {@link #getAWTToolkitLock()}
        • - *
        - *
      - *
    • Otherwise return {@link #getNullToolkitLock()}
    • + *
    • JAWT {@link ToolkitLock} if required and AWT available, otherwise
    • + *
    • {@link jogamp.nativewindow.NullToolkitLock}
    • *
    */ public static ToolkitLock getDefaultToolkitLock(String type) { @@ -390,84 +367,36 @@ public abstract class NativeWindowFactory { /** * Creates the default {@link ToolkitLock} for type and deviceHandle. - *
    *
      - *
    • If {@link #initSingleton(boolean) initSingleton( firstUIActionOnProcess := false )}
    • - *
        - *
      • If X11 type
      • - *
          - *
        • return {@link jogamp.nativewindow.x11.X11ToolkitLock}
        • - *
        - *
      - *
    • Otherwise return {@link jogamp.nativewindow.NullToolkitLock}
    • + *
    • {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
    • + *
    • {@link jogamp.nativewindow.NullToolkitLock}
    • *
    */ public static ToolkitLock createDefaultToolkitLock(String type, long deviceHandle) { if( requiresToolkitLock() ) { - if( TYPE_X11 == type ) { - if( 0== deviceHandle ) { - throw new RuntimeException("JAWTUtil.createDefaultToolkitLock() called with NULL device but on X11"); - } - return createX11ToolkitLock(deviceHandle); - } + return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); } /** * Creates the default {@link ToolkitLock} for type and deviceHandle. - *
    *
      - *
    • If {@link #initSingleton(boolean) initSingleton( firstUIActionOnProcess := false )}
    • - *
        - *
      • If X11 type
      • - *
          - *
        • If shared-AWT-type and AWT available
        • - *
            - *
          • return {@link jogamp.nativewindow.jawt.x11.X11JAWTToolkitLock}
          • - *
          - *
        • else return {@link jogamp.nativewindow.x11.X11ToolkitLock}
        • - *
        - *
      - *
    • Otherwise return {@link jogamp.nativewindow.NullToolkitLock}
    • + *
    • JAWT {@link ToolkitLock} if required and AWT available,
    • + *
    • {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
    • + *
    • {@link jogamp.nativewindow.NullToolkitLock}
    • *
    */ public static ToolkitLock createDefaultToolkitLock(String type, String sharedType, long deviceHandle) { if( requiresToolkitLock() ) { - if( TYPE_X11 == type ) { - if( 0== deviceHandle ) { - throw new RuntimeException("JAWTUtil.createDefaultToolkitLock() called with NULL device but on X11"); - } - if( TYPE_AWT == sharedType && isAWTAvailable() ) { - return createX11AWTToolkitLock(deviceHandle); - } - return createX11ToolkitLock(deviceHandle); + if( TYPE_AWT == sharedType && isAWTAvailable() ) { + return getAWTToolkitLock(); } + return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); } - - protected static ToolkitLock createX11AWTToolkitLock(long deviceHandle) { - try { - if(DEBUG) { - System.err.println("NativeWindowFactory.createX11AWTToolkitLock(0x"+Long.toHexString(deviceHandle)+")"); - // Thread.dumpStack(); - } - return (ToolkitLock) x11JAWTToolkitLockConstructor.newInstance(new Object[]{new Long(deviceHandle)}); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - - protected static ToolkitLock createX11ToolkitLock(long deviceHandle) { - try { - return (ToolkitLock) x11ToolkitLockConstructor.newInstance(new Object[]{new Long(deviceHandle)}); - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - - + /** Returns the appropriate NativeWindowFactory to handle window objects of the given type. The windowClass might be {@link NativeWindow NativeWindow}, in which case the client has diff --git a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java index 30f9660f0..18b7cf5d9 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java @@ -33,12 +33,26 @@ import jogamp.nativewindow.Debug; /** * Marker for a singleton global recursive blocking lock implementation, * optionally locking a native windowing toolkit as well. - *
    - * One use case is the AWT locking on X11, see {@link jogamp.nativewindow.jawt.JAWTToolkitLock}. + *

    + * Toolkit locks are created solely via {@link NativeWindowFactory}. + *

    + *

    + * One use case is the AWT locking on X11, see {@link NativeWindowFactory#createDefaultToolkitLock(String, long)}. + *

    */ public interface ToolkitLock { public static final boolean TRACE_LOCK = Debug.isPropertyDefined("nativewindow.debug.ToolkitLock.TraceLock", true); public void lock(); public void unlock(); + + /** + * Dispose this instance. + *

    + * Shall be called when instance is no more required. + *

    + * This allows implementations sharing a lock via resources + * to decrease the reference counter. + */ + public void dispose(); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java index 1af6bf279..e59910138 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java @@ -50,4 +50,13 @@ public class NullToolkitLock implements ToolkitLock { public final void unlock() { if(TRACE_LOCK) { System.err.println("NullToolkitLock.unlock()"); } } + + public final void dispose() { + // nop + } + + public String toString() { + return "NullToolkitLock[]"; + } + } diff --git a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java new file mode 100644 index 000000000..a3b0804fa --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java @@ -0,0 +1,74 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.nativewindow; + +import javax.media.nativewindow.ToolkitLock; + +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + +/** + * Implementing a resource based recursive {@link javax.media.nativewindow.ToolkitLock}. + *

    + * A resource handle maybe used within a unique object + * and can be synchronized across threads via an instance of ResourceToolkitLock. + *

    + */ +public class ResourceToolkitLock implements ToolkitLock { + public static final boolean DEBUG = Debug.debug("ToolkitLock"); + + public static final ResourceToolkitLock create() { + return new ResourceToolkitLock(); + } + + private final RecursiveLock lock; + + private ResourceToolkitLock() { + this.lock = LockFactory.createRecursiveLock(); + } + + + public final void lock() { + if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.lock()"); } + lock.lock(); + } + + public final void unlock() { + if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.unlock()"); } + lock.unlock(); + } + + public final void dispose() { + // nop + } + + public String toString() { + return "ResourceToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; + } +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java new file mode 100644 index 000000000..5d7ae8abb --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java @@ -0,0 +1,141 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.nativewindow; + +import java.util.Iterator; + +import javax.media.nativewindow.ToolkitLock; + +import com.jogamp.common.util.LongObjectHashMap; +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + +/** + * Implementing a shared resource based recursive {@link javax.media.nativewindow.ToolkitLock}. + *

    + * A resource handle maybe used within many objects + * and can be synchronized across threads via an unique instance of SharedResourceToolkitLock. + *

    + *

    + * Implementation holds a synchronized map from handle to reference counted {@link SharedResourceToolkitLock}. + * New elements are added via {@link #get(long)} if new + * and removed via {@link #dispose()} if no more referenced. + *

    + */ +public class SharedResourceToolkitLock implements ToolkitLock { + public static final boolean DEBUG = Debug.debug("ToolkitLock"); + private static final LongObjectHashMap handle2Lock; + static { + handle2Lock = new LongObjectHashMap(); + handle2Lock.setKeyNotFoundValue(null); + } + + /** + * @return number of unclosed EGL Displays.
    + */ + public static int shutdown(boolean verbose) { + if(DEBUG || verbose || handle2Lock.size() > 0 ) { + System.err.println("SharedResourceToolkitLock: Shutdown (open: "+handle2Lock.size()+")"); + if(DEBUG) { + Thread.dumpStack(); + } + if( handle2Lock.size() > 0) { + dumpOpenDisplayConnections(); + } + } + return handle2Lock.size(); + } + + public static void dumpOpenDisplayConnections() { + System.err.println("SharedResourceToolkitLock: Open ResourceToolkitLock's: "+handle2Lock.size()); + int i=0; + for(Iterator iter = handle2Lock.iterator(); iter.hasNext(); i++) { + final LongObjectHashMap.Entry e = iter.next(); + System.err.println("SharedResourceToolkitLock: Open["+i+"]: "+e.value); + } + } + + public static final SharedResourceToolkitLock get(long handle) { + SharedResourceToolkitLock res; + synchronized(handle2Lock) { + res = (SharedResourceToolkitLock) handle2Lock.get(handle); + if( null == res ) { + res = new SharedResourceToolkitLock(handle); + res.refCount++; + handle2Lock.put(handle, res); + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.get() * NEW *: "+res); } + } else { + res.refCount++; + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.get() * EXIST *: "+res); } + } + } + return res; + } + + private final RecursiveLock lock; + private final long handle; + private volatile int refCount; + + private SharedResourceToolkitLock(long handle) { + this.lock = LockFactory.createRecursiveLock(); + this.handle = handle; + this.refCount = 0; + } + + + public final void lock() { + if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.lock()"); } + lock.lock(); + } + + public final void unlock() { + if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.unlock()"); } + lock.unlock(); + } + + public final void dispose() { + if(0 < refCount) { // volatile OK + synchronized(handle2Lock) { + refCount--; + if(0 == refCount) { + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.dispose() * REMOV *: "+this); } + handle2Lock.remove(handle); + } else { + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.dispose() * DOWN *: "+this); } + } + } + } else { + if(DEBUG || TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.dispose() * NULL *: "+this); } + } + } + + public String toString() { + return "SharedResourceToolkitLock[refCount "+refCount+", handle 0x"+Long.toHexString(handle)+", obj 0x"+Integer.toHexString(hashCode())+", isOwner "+lock.isOwner(Thread.currentThread())+", "+lock.toString()+"]"; + } +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index f1e8a786a..7c934b154 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -237,6 +237,9 @@ public class JAWTUtil { public final void unlock() { JAWTUtil.unlockToolkit(); } + public final void dispose() { + // nop + } }; // trigger native AWT toolkit / properties initialization diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java deleted file mode 100644 index 743d371b7..000000000 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTToolkitLock.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package jogamp.nativewindow.jawt.x11; - -import jogamp.nativewindow.jawt.*; -import jogamp.nativewindow.x11.X11Lib; -import jogamp.nativewindow.x11.X11Util; -import javax.media.nativewindow.ToolkitLock; - -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; - -/** - * Implementing a recursive {@link javax.media.nativewindow.ToolkitLock} - * utilizing JAWT's AWT lock via {@link JAWTUtil#lockToolkit()} and {@link X11Util#XLockDisplay(long)}. - *
    - * This strategy should only be used if AWT is using the underlying native windowing toolkit - * in a not intrinsic thread safe manner, e.g. under X11 where no XInitThreads() call - * is issued before any other X11 usage. This is the current situation for e.g. Webstart or Applets. - */ -public class X11JAWTToolkitLock implements ToolkitLock { - long displayHandle; - RecursiveLock lock; - - public X11JAWTToolkitLock(long displayHandle) { - this.displayHandle = displayHandle; - if(!X11Util.isNativeLockAvailable()) { - lock = LockFactory.createRecursiveLock(); - } - } - - public final void lock() { - if(TRACE_LOCK) { System.err.println("X11JAWTToolkitLock.lock() - native: "+(null==lock)); } - JAWTUtil.lockToolkit(); - if(null == lock) { - X11Lib.XLockDisplay(displayHandle); - } else { - lock.lock(); - } - } - - public final void unlock() { - if(TRACE_LOCK) { System.err.println("X11JAWTToolkitLock.unlock() - native: "+(null==lock)); } - if(null == lock) { - X11Lib.XUnlockDisplay(displayHandle); - } else { - lock.unlock(); - } - JAWTUtil.unlockToolkit(); - } -} diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java index 736718de8..467809284 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/x11/X11JAWTWindow.java @@ -127,7 +127,8 @@ public class X11JAWTWindow extends JAWTWindow { } protected Point getLocationOnScreenNativeImpl(int x, int y) { - return X11Lib.GetRelativeLocation( getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); + // surface is locked and hence the device + return X11Lib.GetRelativeLocation(getDisplayHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); } // Variables for lockSurface/unlockSurface diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java deleted file mode 100644 index 5166ef577..000000000 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11ToolkitLock.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package jogamp.nativewindow.x11; - -import javax.media.nativewindow.ToolkitLock; - -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; - -/** - * Implementing a recursive {@link javax.media.nativewindow.ToolkitLock} - * utilizing {@link X11Util#XLockDisplay(long)}. - *
    - * This strategy should not be used in case XInitThreads() is being used, - * or a higher level toolkit lock is required, ie AWT lock. - */ -public class X11ToolkitLock implements ToolkitLock { - long displayHandle; - RecursiveLock lock; - - public X11ToolkitLock(long displayHandle) { - this.displayHandle = displayHandle; - if(!X11Util.isNativeLockAvailable()) { - lock = LockFactory.createRecursiveLock(); - } - } - - public final void lock() { - if(TRACE_LOCK) { System.err.println("X11ToolkitLock.lock() - native: "+(null==lock)); } - if(null == lock) { - X11Lib.XLockDisplay(displayHandle); - } else { - lock.lock(); - } - } - - public final void unlock() { - if(TRACE_LOCK) { System.err.println("X11ToolkitLock.unlock() - native: "+(null==lock)); } - if(null == lock) { - X11Lib.XUnlockDisplay(displayHandle); - } else { - lock.unlock(); - } - } -} diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 2ea75c7fb..60f54eb3c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -42,8 +42,8 @@ import javax.media.nativewindow.NativeWindowFactory; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NWJNILibLoader; - import com.jogamp.common.util.LongObjectHashMap; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; /** * Contains a thread safe X11 utility to retrieve display connections. @@ -80,25 +80,15 @@ public class X11Util { */ public static final boolean ATI_HAS_XCLOSEDISPLAY_BUG = !Debug.isPropertyDefined("nativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG", true); - /** Value is true, best 'stable' results if always using XInitThreads(). */ - public static final boolean XINITTHREADS_ALWAYS_ENABLED = true; - - /** Value is true, best 'stable' results if not using XLockDisplay/XUnlockDisplay at all. */ - public static final boolean HAS_XLOCKDISPLAY_BUG = true; - public static final boolean DEBUG = Debug.debug("X11Util"); public static final boolean XSYNC_ENABLED = Debug.isPropertyDefined("nativewindow.debug.X11Util.XSync", true); public static final boolean XERROR_STACKDUMP = DEBUG || Debug.isPropertyDefined("nativewindow.debug.X11Util.XErrorStackDump", true); private static final boolean TRACE_DISPLAY_LIFECYCLE = Debug.isPropertyDefined("nativewindow.debug.X11Util.TraceDisplayLifecycle", true); private static String nullDisplayName = null; - private static boolean isX11LockAvailable = false; - private static boolean requiresX11Lock = true; private static volatile boolean isInit = false; private static boolean markAllDisplaysUnclosable = false; // ATI/AMD X11 driver issues - private static int setX11ErrorHandlerRecCount = 0; private static Object setX11ErrorHandlerLock = new Object(); - /** * Called by {@link NativeWindowFactory#initSingleton()} @@ -115,9 +105,7 @@ public class X11Util { throw new NativeWindowException("NativeWindow X11 native library load error."); } - final boolean callXInitThreads = XINITTHREADS_ALWAYS_ENABLED ; - final boolean isXInitThreadsOK = initialize0( callXInitThreads, XERROR_STACKDUMP); - isX11LockAvailable = isXInitThreadsOK && !HAS_XLOCKDISPLAY_BUG ; + final boolean isInitOK = initialize0( XERROR_STACKDUMP ); final long dpy = X11Lib.XOpenDisplay(null); if(0 != dpy) { @@ -134,9 +122,7 @@ public class X11Util { } if(DEBUG) { - System.err.println("X11Util requiresX11Lock "+requiresX11Lock+ - ", XInitThreads [called "+callXInitThreads+", OK "+isXInitThreadsOK+"]"+ - ", isX11LockAvailable "+isX11LockAvailable+ + System.err.println("X11Util init OK "+isInitOK+"]"+ ", X11 Display(NULL) <"+nullDisplayName+">"+ ", XSynchronize Enabled: "+XSYNC_ENABLED); // Thread.dumpStack(); @@ -199,31 +185,14 @@ public class X11Util { } } } - - public static synchronized boolean isNativeLockAvailable() { - return isX11LockAvailable; - } - - public static synchronized boolean requiresToolkitLock() { - return requiresX11Lock; + + public static boolean requiresToolkitLock() { + return true; // JAWT locking: yes, instead of native X11 locking w use a recursive lock. } - + public static void setX11ErrorHandler(boolean onoff, boolean quiet) { synchronized(setX11ErrorHandlerLock) { - if(onoff) { - if(0==setX11ErrorHandlerRecCount) { - setX11ErrorHandler0(true, quiet); - } - setX11ErrorHandlerRecCount++; - } else { - if(0 >= setX11ErrorHandlerRecCount) { - throw new InternalError(); - } - setX11ErrorHandlerRecCount--; - if(0==setX11ErrorHandlerRecCount) { - setX11ErrorHandler0(false, false); - } - } + setX11ErrorHandler0(onoff, quiet); } } @@ -492,52 +461,50 @@ public class X11Util { *******************************/ public static long XOpenDisplay(String arg0) { - NativeWindowFactory.getDefaultToolkitLock().lock(); - try { - long handle = X11Lib.XOpenDisplay(arg0); - if(XSYNC_ENABLED && 0 != handle) { - X11Lib.XSynchronize(handle, true); - } - if(TRACE_DISPLAY_LIFECYCLE) { - System.err.println(Thread.currentThread()+" - X11Util.XOpenDisplay("+arg0+") 0x"+Long.toHexString(handle)); - // Thread.dumpStack(); - } - return handle; - } finally { - NativeWindowFactory.getDefaultToolkitLock().unlock(); + long handle = X11Lib.XOpenDisplay(arg0); + if(XSYNC_ENABLED && 0 != handle) { + X11Lib.XSynchronize(handle, true); + } + if(TRACE_DISPLAY_LIFECYCLE) { + System.err.println(Thread.currentThread()+" - X11Util.XOpenDisplay("+arg0+") 0x"+Long.toHexString(handle)); + // Thread.dumpStack(); } + return handle; } public static int XCloseDisplay(long display) { - NativeWindowFactory.getDefaultToolkitLock().lock(); + if(TRACE_DISPLAY_LIFECYCLE) { + System.err.println(Thread.currentThread()+" - X11Util.XCloseDisplay() 0x"+Long.toHexString(display)); + // Thread.dumpStack(); + } + int res = -1; try { - if(TRACE_DISPLAY_LIFECYCLE) { - System.err.println(Thread.currentThread()+" - X11Util.XCloseDisplay() 0x"+Long.toHexString(display)); - // Thread.dumpStack(); - } - int res = -1; - X11Util.setX11ErrorHandler(true, DEBUG ? false : true); - try { - res = X11Lib.XCloseDisplay(display); - } catch (Exception ex) { - System.err.println("X11Util: Catched Exception:"); - ex.printStackTrace(); - } finally { - X11Util.setX11ErrorHandler(false, false); - } - return res; - } finally { - NativeWindowFactory.getDefaultToolkitLock().unlock(); + res = X11Lib.XCloseDisplay(display); + } catch (Exception ex) { + System.err.println("X11Util: Catched Exception:"); + ex.printStackTrace(); } + return res; } static volatile boolean XineramaFetched = false; static long XineramaLibHandle = 0; static long XineramaQueryFunc = 0; - public static boolean XineramaIsEnabled(long display) { - if(0==display) { - throw new IllegalArgumentException("Display NULL"); + public static boolean XineramaIsEnabled(X11GraphicsDevice device) { + if(null == device) { + throw new IllegalArgumentException("X11 Display device is NULL"); + } + device.lock(); + try { + return XineramaIsEnabled(device.getHandle()); + } finally { + device.unlock(); + } + } + public static boolean XineramaIsEnabled(long displayHandle) { + if( 0 == displayHandle ) { + throw new IllegalArgumentException("X11 Display handle is NULL"); } if(!XineramaFetched) { // volatile: ok synchronized(X11Util.class) { @@ -551,9 +518,9 @@ public class X11Util { } } if(0!=XineramaQueryFunc) { - final boolean res = X11Lib.XineramaIsEnabled(XineramaQueryFunc, display); + final boolean res = X11Lib.XineramaIsEnabled(XineramaQueryFunc, displayHandle); if(DEBUG) { - System.err.println("XineramaIsEnabled: "+res); + System.err.println("XineramaIsEnabled: 0x"+Long.toHexString(displayHandle)+": "+res); } return res; } else if(DEBUG) { @@ -566,7 +533,7 @@ public class X11Util { private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - private static native boolean initialize0(boolean firstUIActionOnProcess, boolean debug); + private static native boolean initialize0(boolean debug); private static native void shutdown0(); private static native void setX11ErrorHandler0(boolean onoff, boolean quiet); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java index 1de03e8be..b152f0f97 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/awt/X11AWTGraphicsConfigurationFactory.java @@ -91,7 +91,7 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac final long displayHandleAWT = X11SunJDKReflection.graphicsDeviceGetDisplay(device); final long displayHandle; - boolean owner = false; + final boolean owner; if(0==displayHandleAWT) { displayHandle = X11Util.openDisplay(null); owner = true; @@ -112,9 +112,8 @@ public class X11AWTGraphicsConfigurationFactory extends GraphicsConfigurationFac System.err.println(getThreadName()+" - X11AWTGraphicsConfigurationFactory: AWT dpy "+displayName+" / "+toHexString(displayHandleAWT)+", create X11 display "+toHexString(displayHandle)); } } - final ToolkitLock lock = owner ? - NativeWindowFactory.getDefaultToolkitLock(NativeWindowFactory.TYPE_AWT) : // own non-shared X11 display connection, no X11 lock - NativeWindowFactory.createDefaultToolkitLock(NativeWindowFactory.TYPE_X11, NativeWindowFactory.TYPE_AWT, displayHandle); + // Global JAWT lock required - No X11 resource locking due to private display connection + final ToolkitLock lock = NativeWindowFactory.getDefaultToolkitLock(NativeWindowFactory.TYPE_AWT); final X11GraphicsDevice x11Device = new X11GraphicsDevice(displayHandle, AbstractGraphicsDevice.DEFAULT_UNIT, lock, owner); final X11GraphicsScreen x11Screen = new X11GraphicsScreen(x11Device, awtScreen.getIndex()); if(DEBUG) { diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index fcba8580c..afdd413eb 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -178,11 +178,14 @@ static int x11ErrorHandler(Display *dpy, XErrorEvent *e) char threadName[80]; char errCodeStr[80]; char reqCodeStr[80]; - int shallBeDetached = 0; - JNIEnv *jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); + JNIEnv *jniEnv = NULL; + if( errorHandlerDebug || errorHandlerThrowException ) { + jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); + } (void) NativewindowCommon_GetStaticStringMethod(jniEnv, X11UtilClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); + snprintf(errCodeStr, sizeof(errCodeStr), "%d", e->request_code); XGetErrorDatabaseText(dpy, "XRequest", errCodeStr, "Unknown", reqCodeStr, sizeof(reqCodeStr)); XGetErrorText(dpy, e->error_code, errCodeStr, sizeof(errCodeStr)); @@ -191,7 +194,7 @@ static int x11ErrorHandler(Display *dpy, XErrorEvent *e) threadName, e->error_code, errCodeStr, e->display, (int)e->resourceid, (int)e->serial, (int)e->request_code, (int)e->minor_code, reqCodeStr); - if( errorHandlerDebug ) { + if( errorHandlerDebug && NULL != jniEnv ) { (*jniEnv)->CallStaticVoidMethod(jniEnv, X11UtilClazz, dumpStackID); } @@ -246,16 +249,17 @@ static int x11IOErrorHandler(Display *dpy) { const char * dpyName = XDisplayName(NULL); const char * errnoStr = strerror(errno); - char threadName[80]; int shallBeDetached = 0; - JNIEnv *jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); - - (void) NativewindowCommon_GetStaticStringMethod(jniEnv, X11UtilClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); + JNIEnv *jniEnv = NULL; - fprintf(stderr, "Nativewindow X11 IOError (Thread %s): Display %p (%s): %s\n", threadName, dpy, dpyName, errnoStr); + fprintf(stderr, "Nativewindow X11 IOError: Display %p (%s): %s\n", dpy, dpyName, errnoStr); (*jniEnv)->CallStaticVoidMethod(jniEnv, X11UtilClazz, dumpStackID); + jniEnv = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); if (NULL != jniEnv) { + char threadName[80]; + (void) NativewindowCommon_GetStaticStringMethod(jniEnv, X11UtilClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); + NativewindowCommon_FatalError(jniEnv, "Nativewindow X11 IOError (Thread %s): Display %p (%s): %s", threadName, dpy, dpyName, errnoStr); if (shallBeDetached) { @@ -305,6 +309,7 @@ Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass clazz, jboo _initClazzAccess(env); x11IOErrorHandlerEnable(1, env); + NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 1, 0, 0 /* no dpy, no sync */); _initialized=1; if(JNI_TRUE == debug) { fprintf(stderr, "Info: NativeWindow native init passed\n"); @@ -315,6 +320,7 @@ Java_jogamp_nativewindow_x11_X11Util_initialize0(JNIEnv *env, jclass clazz, jboo JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Util_shutdown0(JNIEnv *env, jclass _unused) { + NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 0, 0, 0 /* no dpy, no sync */); x11IOErrorHandlerEnable(0, env); } @@ -347,7 +353,7 @@ Java_jogamp_nativewindow_x11_X11Lib_XGetVisualInfo1__JJLjava_nio_ByteBuffer_2Lja } NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) arg0, 1, 0, 0); _res = XGetVisualInfo((Display *) (intptr_t) arg0, (long) arg1, (XVisualInfo *) _ptr2, (int *) _ptr3); - NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) arg0, 0, 0, 0); + // NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) arg0, 0, 0, 0); count = _ptr3[0]; if (arg3 != NULL) { (*env)->ReleasePrimitiveArrayCritical(env, arg3, _ptr3, 0); @@ -382,7 +388,7 @@ Java_jogamp_nativewindow_x11_X11Lib_GetVisualIDFromWindow(JNIEnv *env, jclass _u } else { r = 0; } - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); return r; } @@ -396,7 +402,7 @@ Java_jogamp_nativewindow_x11_X11Lib_DefaultVisualID(JNIEnv *env, jclass _unused, } NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 1, 0, 0); r = (jint) XVisualIDFromVisual( DefaultVisual( (Display*) (intptr_t) display, screen ) ); - NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 0, 0, 0); + // NativewindowCommon_x11ErrorHandlerEnable(env, (Display *) (intptr_t) display, 0, 0, 0); return r; } @@ -439,7 +445,7 @@ Java_jogamp_nativewindow_x11_X11Lib_XCloseDisplay__J(JNIEnv *env, jclass _unused } NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 1, 0, 0); _res = XCloseDisplay((Display *) (intptr_t) display); - NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 0, 0, 0); + // NativewindowCommon_x11ErrorHandlerEnable(env, NULL, 0, 0, 0); return _res; } @@ -497,7 +503,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow if (visual==NULL) { - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); NativewindowCommon_throwNewRuntimeException(env, "could not query Visual by given VisualID, bail out!"); return 0; } @@ -541,7 +547,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow XSelectInput(dpy, window, 0); // no events - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); DBG_PRINT( "X11: [CreateWindow] created window %p on display %p\n", window, dpy); @@ -569,7 +575,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyDummyWindow XUnmapWindow(dpy, w); XSync(dpy, False); XDestroyWindow(dpy, w); - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); } /* @@ -597,7 +603,7 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_x11_X11Lib_GetRelativeLocatio res = XTranslateCoordinates(dpy, src_win, dest_win, src_x, src_y, &dest_x, &dest_y, &child); - NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 0); + // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 0); DBG_PRINT( "X11: GetRelativeLocation0: %p %d/%d -> %p %d/%d - ok: %d\n", (void*)src_win, src_x, src_y, (void*)dest_win, dest_x, dest_y, (int)res); diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 1e9a0e9eb..391bccf3d 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -113,16 +113,22 @@ public abstract class Display { */ public abstract int removeReference(); + /** + * Return the {@link AbstractGraphicsDevice} used for depending resources lifecycle, + * i.e. {@link Screen} and {@link Window}, as well as the event dispatching (EDT). */ public abstract AbstractGraphicsDevice getGraphicsDevice(); /** - * @return the fully qualified Display name, - * which is a key of {@link #getType()} + {@link #getName()} + {@link #getId()} + * Return the handle of the {@link AbstractGraphicsDevice} as returned by {@link #getGraphicsDevice()}. */ - public abstract String getFQName(); - public abstract long getHandle(); + /** + * @return The fully qualified Display name, + * which is a key of {@link #getType()} + {@link #getName()} + {@link #getId()}. + */ + public abstract String getFQName(); + /** * @return this display internal serial id */ @@ -141,6 +147,9 @@ public abstract class Display { */ public abstract String getType(); + /** Return true if this instance is exclusive, i.e. will not be shared. */ + public abstract boolean isExclusive(); + /** * Sets a new {@link EDTUtil} and returns the previous one. *

    @@ -183,11 +192,12 @@ public abstract class Display { * * @param type * @param name - * @param fromIndex start index, then increasing until found or end of list * + * @param fromIndex start index, then increasing until found or end of list + * @paran shared if true, only shared instances are found, otherwise also exclusive * @return */ - public static Display getFirstDisplayOf(String type, String name, int fromIndex) { - return getDisplayOfImpl(type, name, fromIndex, 1); + public static Display getFirstDisplayOf(String type, String name, int fromIndex, boolean shared) { + return getDisplayOfImpl(type, name, fromIndex, 1, shared); } /** @@ -195,19 +205,22 @@ public abstract class Display { * @param type * @param name * @param fromIndex start index, then decreasing until found or end of list. -1 is interpreted as size - 1. + * @paran shared if true, only shared instances are found, otherwise also exclusive * @return */ - public static Display getLastDisplayOf(String type, String name, int fromIndex) { - return getDisplayOfImpl(type, name, fromIndex, -1); + public static Display getLastDisplayOf(String type, String name, int fromIndex, boolean shared) { + return getDisplayOfImpl(type, name, fromIndex, -1, shared); } - private static Display getDisplayOfImpl(String type, String name, int fromIndex, int incr) { + private static Display getDisplayOfImpl(String type, String name, int fromIndex, int incr, boolean shared) { synchronized(displayList) { int i = fromIndex >= 0 ? fromIndex : displayList.size() - 1 ; while( ( incr > 0 ) ? i < displayList.size() : i >= 0 ) { Display display = (Display) displayList.get(i); if( display.getType().equals(type) && - display.getName().equals(name) ) { + display.getName().equals(name) && + ( !shared || shared && !display.isExclusive() ) + ) { return display; } i+=incr; diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index abae94ab6..1bf47f4aa 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -305,7 +305,7 @@ public class NewtFactory { * Instantiate a Display entity using the native handle. */ public static Display createDisplay(String type, long handle, boolean reuse) { - return DisplayImpl.create(type, null, handle, false); + return DisplayImpl.create(type, null, handle, reuse); } public static boolean isScreenCompatible(NativeWindow parent, Screen childScreen) { diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index 26f19ad6b..cfbcc988a 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -145,7 +145,7 @@ public abstract class Screen { public abstract Display getDisplay(); /** - * @return the screen fully qualified Screen name, + * @return The screen fully qualified Screen name, * which is a key of {@link com.jogamp.newt.Display#getFQName()} + {@link #getIndex()}. */ public abstract String getFQName(); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index bca7f6e5b..daeb3e886 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -42,6 +42,7 @@ import com.jogamp.newt.event.NEWTEventConsumer; import jogamp.newt.event.NEWTEventTask; import com.jogamp.newt.util.EDTUtil; import java.util.ArrayList; + import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; @@ -66,7 +67,7 @@ public abstract class DisplayImpl extends Display { name = display.validateDisplayName(name, handle); synchronized(displayList) { if(reuse) { - Display display0 = Display.getLastDisplayOf(type, name, -1); + Display display0 = Display.getLastDisplayOf(type, name, -1, true /* shared only */); if(null != display0) { if(DEBUG) { System.err.println("Display.create() REUSE: "+display0+" "+getThreadName()); @@ -74,9 +75,9 @@ public abstract class DisplayImpl extends Display { return display0; } } + display.exclusive = !reuse; display.name = name; display.type=type; - display.destroyWhenUnused=false; display.refCount=0; display.id = serialno++; display.fqname = getFQName(display.type, display.name, display.id); @@ -94,7 +95,7 @@ public abstract class DisplayImpl extends Display { throw new RuntimeException(e); } } - + @Override public boolean equals(Object obj) { if (obj == null) { @@ -116,10 +117,12 @@ public abstract class DisplayImpl extends Display { return true; } + @Override public int hashCode() { return hashCode; } + @Override public synchronized final void createNative() throws NativeWindowException { @@ -148,10 +151,6 @@ public abstract class DisplayImpl extends Display { } } - protected boolean shallRunOnEDT() { - return true; - } - protected EDTUtil createEDTUtil() { final EDTUtil def; if(NewtFactory.useEDT()) { @@ -179,12 +178,7 @@ public abstract class DisplayImpl extends Display { if(DEBUG) { System.err.println("Display.setEDTUtil: "+oldEDTUtil+" -> "+newEDTUtil); } - if(null != oldEDTUtil) { - stopEDT( new Runnable() { public void run() {} } ); - // ready for restart .. - oldEDTUtil.waitUntilStopped(); - oldEDTUtil.reset(); - } + removeEDT( new Runnable() { public void run() {} } ); edtUtil = newEDTUtil; return oldEDTUtil; } @@ -194,16 +188,19 @@ public abstract class DisplayImpl extends Display { return edtUtil; } - private void stopEDT(final Runnable task) { - if( shallRunOnEDT() && null!=edtUtil ) { + private void removeEDT(final Runnable task) { + if(null!=edtUtil) { edtUtil.invokeStop(task); + // ready for restart .. + edtUtil.waitUntilStopped(); + edtUtil.reset(); } else { task.run(); } } public void runOnEDTIfAvail(boolean wait, final Runnable task) { - if( shallRunOnEDT() && null!=edtUtil && !edtUtil.isCurrentThreadEDT()) { + if( null!=edtUtil && !edtUtil.isCurrentThreadEDT()) { edtUtil.invoke(wait, task); } else { task.run(); @@ -212,18 +209,17 @@ public abstract class DisplayImpl extends Display { public boolean validateEDT() { if(0==refCount && null==aDevice && null != edtUtil && edtUtil.isRunning()) { - stopEDT( new Runnable() { + removeEDT( new Runnable() { public void run() { // nop } } ); - edtUtil.waitUntilStopped(); - edtUtil.reset(); return true; } return false; } + @Override public synchronized final void destroy() { if(DEBUG) { dumpDisplayList("Display.destroy("+getFQName()+") BEGIN"); @@ -239,17 +235,13 @@ public abstract class DisplayImpl extends Display { } final AbstractGraphicsDevice f_aDevice = aDevice; final DisplayImpl f_dpy = this; - stopEDT( new Runnable() { + removeEDT( new Runnable() { public void run() { if ( null != f_aDevice ) { f_dpy.closeNativeImpl(); } } } ); - if(null!=edtUtil) { - edtUtil.waitUntilStopped(); - edtUtil.reset(); - } aDevice = null; refCount=0; if(DEBUG) { @@ -290,21 +282,30 @@ public abstract class DisplayImpl extends Display { protected abstract void createNativeImpl(); protected abstract void closeNativeImpl(); + @Override public final int getId() { return id; } + @Override public final String getType() { return type; } + @Override public final String getName() { return name; } + @Override public final String getFQName() { return fqname; } + + @Override + public final boolean isExclusive() { + return exclusive; + } public static final String nilString = "nil" ; @@ -324,9 +325,10 @@ public abstract class DisplayImpl extends Display { sb.append(name); sb.append("-"); sb.append(id); - return sb.toString().intern(); + return sb.toString(); } + @Override public final long getHandle() { if(null!=aDevice) { return aDevice.getHandle(); @@ -334,14 +336,17 @@ public abstract class DisplayImpl extends Display { return 0; } + @Override public final AbstractGraphicsDevice getGraphicsDevice() { return aDevice; } + @Override public synchronized final boolean isNativeValid() { return null != aDevice; } + @Override public boolean isEDTRunning() { if(null!=edtUtil) { return edtUtil.isRunning(); @@ -351,7 +356,7 @@ public abstract class DisplayImpl extends Display { @Override public String toString() { - return "NEWT-Display["+getFQName()+", refCount "+refCount+", hasEDT "+(null!=edtUtil)+", edtRunning "+isEDTRunning()+", "+aDevice+"]"; + return "NEWT-Display["+getFQName()+", excl "+exclusive+", refCount "+refCount+", hasEDT "+(null!=edtUtil)+", edtRunning "+isEDTRunning()+", "+aDevice+"]"; } protected abstract void dispatchMessagesNative(); @@ -403,6 +408,7 @@ public abstract class DisplayImpl extends Display { eventTask.notifyCaller(); } + @Override public void dispatchMessages() { // System.err.println("Display.dispatchMessages() 0 "+this+" "+getThreadName()); if(0==refCount || // no screens @@ -475,20 +481,23 @@ public abstract class DisplayImpl extends Display { public interface DisplayRunnable { T run(long dpy); } - public final T runWithLockedDisplayHandle(DisplayRunnable action) { - final AbstractGraphicsDevice aDevice = getGraphicsDevice(); - if(null == aDevice) { - throw new RuntimeException("null device - not initialized: "+this); - } + public static final T runWithLockedDevice(AbstractGraphicsDevice device, DisplayRunnable action) { T res; - aDevice.lock(); + device.lock(); try { - res = action.run(aDevice.getHandle()); + res = action.run(device.getHandle()); } finally { - aDevice.unlock(); + device.unlock(); } return res; } + public final T runWithLockedDisplayDevice(DisplayRunnable action) { + final AbstractGraphicsDevice device = getGraphicsDevice(); + if(null == device) { + throw new RuntimeException("null device - not initialized: "+this); + } + return runWithLockedDevice(device, action); + } protected EDTUtil edtUtil = null; protected int id; @@ -497,7 +506,7 @@ public abstract class DisplayImpl extends Display { protected String fqname; protected int hashCode; protected int refCount; // number of Display references by Screen - protected boolean destroyWhenUnused; + protected boolean exclusive; // do not share this display, uses NullLock! protected AbstractGraphicsDevice aDevice; } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index e2c0f746f..1cc53e80e 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -42,7 +42,6 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.Point; @@ -130,7 +129,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { } } screen.screen_idx = idx; - screen.fqname = (display.getFQName()+idx).intern(); + screen.fqname = display.getFQName()+"-s"+idx; screen.hashCode = screen.fqname.hashCode(); screenList.add(screen); if(DEBUG) { diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index c1ac87d38..79770189b 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -85,7 +85,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private volatile long windowHandle = 0; // lifecycle critical private volatile boolean visible = false; // lifecycle critical private RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock - private RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); // Surface only lock + private int surfaceLockCount = 0; // surface lock recursion count private ScreenImpl screen; // never null after create - may change reference though (reparent) private boolean screenReferenceAdded = false; @@ -553,10 +553,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final int lockSurface() throws NativeWindowException, RuntimeException { final RecursiveLock _wlock = windowLock; - final RecursiveLock _slock = surfaceLock; _wlock.lock(); - _slock.lock(); - int res = _slock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? + surfaceLockCount++; + int res = ( 1 == surfaceLockCount ) ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? if ( LOCK_SURFACE_NOT_READY == res ) { try { @@ -573,7 +572,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } finally { if (LOCK_SURFACE_NOT_READY >= res) { - _slock.unlock(); _wlock.unlock(); } } @@ -583,12 +581,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final void unlockSurface() { - final RecursiveLock _slock = surfaceLock; final RecursiveLock _wlock = windowLock; - _slock.validateLocked(); _wlock.validateLocked(); - if (_slock.getHoldCount() == 1) { + if ( 1 == surfaceLockCount ) { final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); try { unlockSurfaceImpl(); @@ -596,42 +592,48 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer adevice.unlock(); } } - _slock.unlock(); + surfaceLockCount--; _wlock.unlock(); } @Override public final boolean isSurfaceLockedByOtherThread() { - return surfaceLock.isLockedByOtherThread(); + return windowLock.isLockedByOtherThread(); } @Override public final Thread getSurfaceLockOwner() { - return surfaceLock.getOwner(); + return windowLock.getOwner(); } public final RecursiveLock getLock() { return windowLock; } + @Override public long getSurfaceHandle() { return windowHandle; // default: return window handle } + @Override public boolean surfaceSwap() { return false; } + @Override public final AbstractGraphicsConfiguration getGraphicsConfiguration() { return config.getNativeGraphicsConfiguration(); } - public final long getDisplayHandle() { - return getScreen().getDisplay().getHandle(); + @Override + public long getDisplayHandle() { + // Actually: return getGraphicsConfiguration().getScreen().getDevice().getHandle(); + return screen.getDisplay().getHandle(); // shortcut } + @Override public final int getScreenIndex() { - return getScreen().getIndex(); + return screen.getIndex(); } //---------------------------------------------------------------------- @@ -1554,8 +1556,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer for (int i = 0; i < keyListeners.size(); i++ ) { sb.append(keyListeners.get(i)+", "); } - sb.append("], surfaceLock "+surfaceLock); - sb.append(", windowLock "+windowLock+"]"); + sb.append("], windowLock "+windowLock+"]"); return sb.toString(); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index 70e9ba570..ead567d82 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -66,7 +66,9 @@ public class DisplayDriver extends DisplayImpl { return def; } - protected void closeNativeImpl() { } + protected void closeNativeImpl() { + aDevice.close(); + } protected void dispatchMessagesNative() { /* nop */ } } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java index 65ca63eec..cc55c336e 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -39,6 +39,7 @@ import javax.media.nativewindow.NativeWindowException; import jogamp.newt.NEWTJNILibLoader; import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLDisplayUtil; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; @@ -72,6 +73,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { DestroyDisplay(aDevice.getHandle()); } + aDevice.close(); } protected void dispatchMessagesNative() { diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java index 97c384d33..e370038d9 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -84,6 +84,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { } } } + aDevice.close(); } protected void dispatchMessagesNative() { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index 1a3f14859..b49c6b6e0 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -72,7 +72,9 @@ public class DisplayDriver extends DisplayImpl { aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { } + protected void closeNativeImpl() { + aDevice.close(); + } public static void runNSApplication() { runNSApplication0(); diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 579ec5be8..615f9e63b 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -73,6 +73,7 @@ public class DisplayDriver extends DisplayImpl { protected void closeNativeImpl() { sharedClassFactory.releaseSharedClass(); + aDevice.close(); } protected void dispatchMessagesNative() { diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 714324d63..bff050030 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -36,7 +36,6 @@ package jogamp.newt.driver.x11; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.NativeWindowFactory; import com.jogamp.nativewindow.x11.X11GraphicsDevice; @@ -74,71 +73,48 @@ public class DisplayDriver extends DisplayImpl { * {@inheritDoc} * * We use a private non-shared X11 Display instance for EDT window operations and one for exposed animation, eg. OpenGL. - *

    - * In case {@link X11Util#HAS_XLOCKDISPLAY_BUG} and {@link X11Util#XINITTHREADS_ALWAYS_ENABLED}, - * we use null locking. Even though this seems not to be rational, it gives most stable results on all platforms. - *

    - *

    - * Otherwise we use basic locking via the constructor {@link X11GraphicsDevice#X11GraphicsDevice(long, int, boolean)}, - * since it is possible to share this device via {@link com.jogamp.newt.NewtFactory#createDisplay(String, boolean)}. - *

    */ - @SuppressWarnings("unused") protected void createNativeImpl() { + X11Util.setX11ErrorHandler(true, DEBUG ? false : true); // make sure X11 error handler is set long handle = X11Util.openDisplay(name); if( 0 == handle ) { throw new RuntimeException("Error creating display(Win): "+name); } - if(USE_SEPARATE_DISPLAY_FOR_EDT) { - edtDisplayHandle = X11Util.openDisplay(name); - if( 0 == edtDisplayHandle ) { - X11Util.closeDisplay(handle); - throw new RuntimeException("Error creating display(EDT): "+name); - } - } else { - edtDisplayHandle = handle; - } + aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, true); try { - CompleteDisplay0(edtDisplayHandle); + CompleteDisplay0(aDevice.getHandle()); } catch(RuntimeException e) { closeNativeImpl(); throw e; - } - - // see API doc above! - if(X11Util.XINITTHREADS_ALWAYS_ENABLED && X11Util.HAS_XLOCKDISPLAY_BUG) { - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, NativeWindowFactory.getNullToolkitLock(), false); - } else { - aDevice = new X11GraphicsDevice(handle, AbstractGraphicsDevice.DEFAULT_UNIT, false); - } + } } protected void closeNativeImpl() { - DisplayRelease0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); + DisplayRelease0(aDevice.getHandle(), javaObjectAtom, windowDeleteAtom); javaObjectAtom = 0; windowDeleteAtom = 0; - // closing using ATI driver bug 'same order' - final long handle = getHandle(); - X11Util.closeDisplay(handle); - if(handle != edtDisplayHandle) { - X11Util.closeDisplay(edtDisplayHandle); - } - edtDisplayHandle = 0; + aDevice.close(); // closes X11 display } protected void dispatchMessagesNative() { - if(0 != edtDisplayHandle) { - DispatchMessages0(edtDisplayHandle, javaObjectAtom, windowDeleteAtom); + aDevice.lock(); + try { + final long handle = aDevice.getHandle(); + if(0 != handle) { + DispatchMessages0(handle, javaObjectAtom, windowDeleteAtom); + } + } finally { + aDevice.unlock(); } } - protected long getEDTHandle() { return edtDisplayHandle; } protected long getJavaObjectAtom() { return javaObjectAtom; } protected long getWindowDeleteAtom() { return windowDeleteAtom; } //---------------------------------------------------------------------- // Internals only // + private static native boolean initIDs0(boolean debug); private native void CompleteDisplay0(long handle); @@ -151,17 +127,6 @@ public class DisplayDriver extends DisplayImpl { private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom); - /** - * 2011/06/14 libX11 1.4.2 and libxcb 1.7 bug 20708 - Multithreading Issues w/ OpenGL, .. - * https://bugs.freedesktop.org/show_bug.cgi?id=20708 - * https://jogamp.org/bugzilla/show_bug.cgi?id=502 - * Affects: Ubuntu 11.04, OpenSuSE 11, .. - * Workaround: Using a separate X11 Display connection for event dispatching (EDT) - */ - private final boolean USE_SEPARATE_DISPLAY_FOR_EDT = true; - - private long edtDisplayHandle; - /** X11 Window delete atom marker used on EDT */ private long windowDeleteAtom; diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 10f6b84da..b09d98e06 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -59,7 +59,7 @@ public class ScreenDriver extends ScreenImpl { protected void createNativeImpl() { // validate screen index - Long handle = display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + Long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Long run(long dpy) { return new Long(GetScreen0(dpy, screen_idx)); } } ); @@ -81,7 +81,7 @@ public class ScreenDriver extends ScreenImpl { private int nmode_number; protected int[] getScreenModeFirstImpl() { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { // initialize iterators and static data nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); @@ -110,7 +110,7 @@ public class ScreenDriver extends ScreenImpl { protected int[] getScreenModeNextImpl() { // assemble: w x h x bpp x f x r - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { /** System.err.println("******** mode: "+nmode_number); @@ -176,7 +176,7 @@ public class ScreenDriver extends ScreenImpl { } protected ScreenMode getCurrentScreenModeImpl() { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public ScreenMode run(long dpy) { long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); if(0 == screenConfigHandle) { @@ -237,7 +237,7 @@ public class ScreenDriver extends ScreenImpl { throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); } final long t0 = System.currentTimeMillis(); - boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { boolean done = false; long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); @@ -276,23 +276,21 @@ public class ScreenDriver extends ScreenImpl { return done; } - private class XineramaEnabledQuery implements DisplayImpl.DisplayRunnable { + private DisplayImpl.DisplayRunnable xineramaEnabledQueryWithTemp = new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { return new Boolean(X11Util.XineramaIsEnabled(dpy)); - } - } - private XineramaEnabledQuery xineramaEnabledQuery = new XineramaEnabledQuery(); + } }; protected int validateScreenIndex(final int idx) { if(getDisplay().isNativeValid()) { - return runWithLockedDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; + return X11Util.XineramaIsEnabled((X11GraphicsDevice)getDisplay().getGraphicsDevice()) ? 0 : idx; } else { - return runWithTempDisplayHandle( xineramaEnabledQuery ).booleanValue() ? 0 : idx; + return runWithTempDisplayHandle( xineramaEnabledQueryWithTemp ).booleanValue() ? 0 : idx; } } protected void getVirtualScreenOriginAndSize(final Point virtualOrigin, final Dimension virtualSize) { - display.runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { virtualOrigin.setX(0); virtualOrigin.setY(0); @@ -305,10 +303,8 @@ public class ScreenDriver extends ScreenImpl { //---------------------------------------------------------------------- // Internals only // - private final T runWithLockedDisplayHandle(DisplayRunnable action) { - return display.runWithLockedDisplayHandle(action); - // return runWithTempDisplayHandle(action); - // return runWithoutLock(action); + private final T runWithLockedDisplayDevice(DisplayRunnable action) { + return display.runWithLockedDisplayDevice(action); } private final T runWithTempDisplayHandle(DisplayRunnable action) { @@ -324,9 +320,6 @@ public class ScreenDriver extends ScreenImpl { } return res; } - private final T runWithoutLock(DisplayRunnable action) { - return action.run(display.getHandle()); - } private static native long GetScreen0(long dpy, int scrn_idx); diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 97d1ae3db..aea86a420 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -35,6 +35,7 @@ package jogamp.newt.driver.x11; import jogamp.nativewindow.x11.X11Lib; +import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; import jogamp.newt.WindowImpl; @@ -44,6 +45,8 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; import com.jogamp.newt.event.MouseEvent; public class WindowDriver extends WindowImpl { @@ -63,9 +66,19 @@ public class WindowDriver extends WindowImpl { protected void createNativeImpl() { final ScreenDriver screen = (ScreenDriver) getScreen(); final DisplayDriver display = (DisplayDriver) screen.getDisplay(); + final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice(); + + // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering + final long renderDeviceHandle = X11Util.openDisplay(edtDevice.getConnection()); + if( 0 == renderDeviceHandle ) { + throw new RuntimeException("Error creating display(EDT): "+edtDevice.getConnection()); + } + renderDevice = new X11GraphicsDevice(renderDeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true); + AbstractGraphicsScreen renderScreen = new X11GraphicsScreen((X11GraphicsDevice) renderDevice, screen.getIndex()); + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(display.getGraphicsDevice(), capsRequested); final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( - capsRequested, capsRequested, capabilitiesChooser, screen.getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + capsRequested, capsRequested, capabilitiesChooser, renderScreen, VisualIDHolder.VID_UNDEFINED); if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window.createNativeImpl() factory: "+factory+", chosen config: "+cfg); } @@ -78,11 +91,16 @@ public class WindowDriver extends WindowImpl { } setGraphicsConfiguration(cfg); final int flags = getReconfigureFlags(0, true) & - ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; - setWindowHandle(CreateWindow0(getParentWindowHandle(), - display.getEDTHandle(), screen.getIndex(), visualID, - display.getJavaObjectAtom(), display.getWindowDeleteAtom(), - getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + ( FLAG_IS_ALWAYSONTOP | FLAG_IS_UNDECORATED ) ; + edtDevice.lock(); + try { + setWindowHandle(CreateWindow0(getParentWindowHandle(), + edtDevice.getHandle(), screen.getIndex(), visualID, + display.getJavaObjectAtom(), display.getWindowDeleteAtom(), + getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + } finally { + edtDevice.unlock(); + } windowHandleClose = getWindowHandle(); if (0 == windowHandleClose) { throw new NativeWindowException("Error creating window"); @@ -92,8 +110,10 @@ public class WindowDriver extends WindowImpl { protected void closeNativeImpl() { if(0!=windowHandleClose && null!=getScreen() ) { DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + final AbstractGraphicsDevice edtDevice = display.getGraphicsDevice(); + edtDevice.lock(); try { - CloseWindow0(display.getEDTHandle(), windowHandleClose, + CloseWindow0(edtDevice.getHandle(), windowHandleClose, display.getJavaObjectAtom(), display.getWindowDeleteAtom()); } catch (Throwable t) { if(DEBUG_IMPLEMENTATION) { @@ -101,28 +121,47 @@ public class WindowDriver extends WindowImpl { e.printStackTrace(); } } finally { + edtDevice.unlock(); windowHandleClose = 0; } } + if(null != renderDevice) { + renderDevice.close(); // closes X11 display + renderDevice = null; + } } - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + @Override + public long getDisplayHandle() { + // Actually: return getGraphicsConfiguration().getScreen().getDevice().getHandle(); + return renderDevice.getHandle(); // shortcut + } + + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); } + final int _x, _y; if(0 == ( FLAG_IS_UNDECORATED & flags)) { final InsetsImmutable i = getInsets(); // client position -> top-level window position - x -= i.getLeftWidth() ; - y -= i.getTopHeight() ; + _x = x - i.getLeftWidth() ; + _y = y - i.getTopHeight() ; + } else { + _x = x; + _y = y; } final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); - reconfigureWindow0( getDisplayEDTHandle(), getScreenIndex(), - getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), - x, y, width, height, flags); - + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + reconfigureWindow0( dpy, getScreenIndex(), + getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), + _x, _y, width, height, flags); + return null; + } + }); return true; } @@ -133,13 +172,18 @@ public class WindowDriver extends WindowImpl { } } - protected void requestFocusImpl(boolean force) { - requestFocus0(getDisplayEDTHandle(), getWindowHandle(), force); + protected void requestFocusImpl(final boolean force) { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + requestFocus0(dpy, getWindowHandle(), force); + return null; + } + }); } @Override protected void setTitleImpl(final String title) { - runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { setTitle0(dpy, getWindowHandle(), title); return null; @@ -149,35 +193,38 @@ public class WindowDriver extends WindowImpl { @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { - return Boolean.valueOf(setPointerVisible0(getDisplayEDTHandle(), getWindowHandle(), pointerVisible)); + return Boolean.valueOf(setPointerVisible0(dpy, getWindowHandle(), pointerVisible)); } }).booleanValue(); } @Override protected boolean confinePointerImpl(final boolean confine) { - return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { - return Boolean.valueOf(confinePointer0(getDisplayEDTHandle(), getWindowHandle(), confine)); + return Boolean.valueOf(confinePointer0(dpy, getWindowHandle(), confine)); } }).booleanValue(); } @Override protected void warpPointerImpl(final int x, final int y) { - runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable() { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { - warpPointer0(getDisplayEDTHandle(), getWindowHandle(), x, y); + warpPointer0(dpy, getWindowHandle(), x, y); return null; } }); } protected Point getLocationOnScreenImpl(final int x, final int y) { - // X11Util.GetRelativeLocation: locks display already ! - return X11Lib.GetRelativeLocation( getScreen().getDisplay().getHandle(), getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Point run(long dpy) { + return X11Lib.GetRelativeLocation(dpy, getScreenIndex(), getWindowHandle(), 0 /*root win*/, x, y); + } + } ); } protected void updateInsetsImpl(Insets insets) { @@ -229,16 +276,11 @@ public class WindowDriver extends WindowImpl { //---------------------------------------------------------------------- // Internals only // - private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI - private final long getDisplayEDTHandle() { - return ((DisplayDriver) getScreen().getDisplay()).getEDTHandle(); - } - private final T runWithLockedDisplayHandle(DisplayRunnable action) { - return ((DisplayImpl) getScreen().getDisplay()).runWithLockedDisplayHandle(action); - // return runWithTempDisplayHandle(action); + private final T runWithLockedDisplayDevice(DisplayRunnable action) { + return ((DisplayDriver) getScreen().getDisplay()).runWithLockedDisplayDevice(action); } protected static native boolean initIDs0(); @@ -258,4 +300,5 @@ public class WindowDriver extends WindowImpl { private static native void warpPointer0(long display, long windowHandle, int x, int y); private long windowHandleClose; + private AbstractGraphicsDevice renderDevice; } diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h index 128b6b6f1..4d1a7b59e 100644 --- a/src/newt/native/X11Common.h +++ b/src/newt/native/X11Common.h @@ -70,7 +70,6 @@ extern jclass X11NewtWindowClazz; extern jmethodID insetsChangedID; extern jmethodID visibleChangedID; -void NewtDisplay_x11ErrorHandlerEnable(JNIEnv * env, Display *dpy, int onoff, int quiet, int sync); jobject getJavaWindowProperty(JNIEnv *env, Display *dpy, Window window, jlong javaObjectAtom, Bool showWarning); Status NewtWindows_getRootAndParent (Display *dpy, Window w, Window * root_return, Window * parent_return); diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 84b3a7630..56c11fab4 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -52,90 +52,6 @@ static jmethodID enqueueKeyEventID = NULL; static jmethodID sendKeyEventID = NULL; static jmethodID requestFocusID = NULL; -static JavaVM *jvmHandle = NULL; -static int jvmVersion = 0; - -static void setupJVMVars(JNIEnv * env) { - if(0 != (*env)->GetJavaVM(env, &jvmHandle)) { - jvmHandle = NULL; - } - jvmVersion = (*env)->GetVersion(env); -} - -static XErrorHandler origErrorHandler = NULL ; -static int errorHandlerQuiet = 0 ; -static int errorHandlerDebug = 0 ; -static int errorHandlerThrowException = 0; - -static int x11ErrorHandler(Display *dpy, XErrorEvent *e) -{ - if(!errorHandlerQuiet) { - const char * errnoStr = strerror(errno); - char threadName[80]; - char errCodeStr[80]; - char reqCodeStr[80]; - - int shallBeDetached = 0; - JNIEnv *jniEnv = NewtCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); - - (void) NewtCommon_GetStaticStringMethod(jniEnv, X11NewtWindowClazz, getCurrentThreadNameID, threadName, sizeof(threadName), "n/a"); - snprintf(errCodeStr, sizeof(errCodeStr), "%d", e->request_code); - XGetErrorDatabaseText(dpy, "XRequest", errCodeStr, "Unknown", reqCodeStr, sizeof(reqCodeStr)); - XGetErrorText(dpy, e->error_code, errCodeStr, sizeof(errCodeStr)); - - fprintf(stderr, "Info: Newt X11 Error (Thread: %s): %d - %s, dpy %p, id %x, # %d: %d:%d %s\n", - threadName, e->error_code, errCodeStr, e->display, (int)e->resourceid, (int)e->serial, - (int)e->request_code, (int)e->minor_code, reqCodeStr); - - if( errorHandlerDebug ) { - (*jniEnv)->CallStaticVoidMethod(jniEnv, X11NewtWindowClazz, dumpStackID); - } - - if(errorHandlerThrowException) { - if(NULL != jniEnv) { - NewtCommon_throwNewRuntimeException(jniEnv, "Newt X11 Error (Thread: %s): %d - %s, dpy %p, id %x, # %d: %d:%d %s\n", - threadName, e->error_code, errCodeStr, e->display, (int)e->resourceid, (int)e->serial, - (int)e->request_code, (int)e->minor_code, reqCodeStr); - } else { - fprintf(stderr, "Nativewindow X11 Error: null JNIEnv"); - #if 0 - if(NULL!=origErrorHandler) { - origErrorHandler(dpy, e); - } - #endif - } - } - fflush(stderr); - - if (NULL != jniEnv && shallBeDetached) { - (*jvmHandle)->DetachCurrentThread(jvmHandle); - } - } - - return 0; -} - -void NewtDisplay_x11ErrorHandlerEnable(JNIEnv * env, Display *dpy, int onoff, int quiet, int sync) { - errorHandlerQuiet = quiet; - if(onoff) { - if(NULL==origErrorHandler) { - setupJVMVars(env); - origErrorHandler = XSetErrorHandler(x11ErrorHandler); - if(sync && NULL!=dpy) { - XSync(dpy, False); - } - } - } else { - if(NULL!=origErrorHandler) { - if(sync && NULL!=dpy) { - XSync(dpy, False); - } - XSetErrorHandler(origErrorHandler); - origErrorHandler = NULL; - } - } -} - /** * Keycode */ @@ -273,9 +189,6 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 { jclass c; - if(debug) { - errorHandlerDebug = 1 ; - } NewtCommon_init(env); if(NULL==X11NewtWindowClazz) { @@ -439,8 +352,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage // DBG_PRINT( "X11: DispatchMessages dpy %p, win %p, Event %d\n", (void*)dpy, (void*)evt.xany.window, (int)evt.type); - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); - jwindow = getJavaWindowProperty(env, dpy, evt.xany.window, javaObjectAtom, #ifdef VERBOSE_ON True @@ -449,8 +360,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage #endif ); - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); - if(NULL==jwindow) { fprintf(stderr, "Warning: NEWT X11 DisplayDispatch %p, Couldn't handle event %d for X11 window %p\n", (void*)dpy, evt.type, (void*)evt.xany.window); diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 59862f463..2e16e7cae 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -683,16 +683,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 DBG_PRINT( "X11: CloseWindow START dpy %p, win %p\n", (void*)dpy, (void*)w); - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); - jwindow = getJavaWindowProperty(env, dpy, w, javaObjectAtom, True); if(NULL==jwindow) { - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); NewtCommon_throwNewRuntimeException(env, "could not fetch Java Window object, bail out!"); return; } if ( JNI_FALSE == (*env)->IsSameObject(env, jwindow, obj) ) { - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); NewtCommon_throwNewRuntimeException(env, "Internal Error .. Window global ref not the same!"); return; } @@ -700,7 +696,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 XSync(dpy, False); XSelectInput(dpy, w, 0); XUnmapWindow(dpy, w); - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); // Drain all events related to this window .. Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom); @@ -761,8 +756,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo fsEWMHFlags |= _NET_WM_ABOVE; // toggle above } - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 1, 0, 0); - DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d, tempInvisible %d, fsEWMHFlags %d\n", (void*)dpy, screen_index, (void*) jparent, (void*)parent, (void*)w, x, y, width, height, @@ -779,7 +772,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_ALWAYSONTOP(flags) ) ) { Bool enable = TST_FLAG_CHANGE_FULLSCREEN(flags) ? TST_FLAG_IS_FULLSCREEN(flags) : TST_FLAG_IS_ALWAYSONTOP(flags) ; if( NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, enable) ) { - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); #ifdef FS_GRAB_KEYBOARD if(TST_FLAG_CHANGE_FULLSCREEN(flags)) { if(TST_FLAG_IS_FULLSCREEN(flags)) { @@ -863,8 +855,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo #endif } - NewtDisplay_x11ErrorHandlerEnable(env, dpy, 0, 0, 1); - DBG_PRINT( "X11: reconfigureWindow0 X\n"); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java new file mode 100644 index 000000000..11d1331ed --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java @@ -0,0 +1,219 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; + +import com.jogamp.newt.Display; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Concurrent and lock-free initialization and rendering using exclusive NEWT Display EDT instances, or + * concurrent locked initialization and lock-free rendering using a shared NEWT Display EDT instances. + *

    + * Rendering is always lock-free and independent of the EDT. + *

    + */ +public class InitConcurrentBaseNEWT extends UITestCase { + + static final int demoSize = 128; + + static long duration = 300; // ms + + static InsetsImmutable insets = null; + static int scrnHeight, scrnWidth; + static int num_x, num_y; + + @BeforeClass + public static void initClass() { + Window dummyWindow = NewtFactory.createWindow(new Capabilities()); + dummyWindow.setSize(demoSize, demoSize); + dummyWindow.setVisible(true); + Assert.assertEquals(true, dummyWindow.isVisible()); + Assert.assertEquals(true, dummyWindow.isNativeValid()); + insets = dummyWindow.getInsets(); + scrnHeight = dummyWindow.getScreen().getHeight(); + scrnWidth = dummyWindow.getScreen().getWidth(); + num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; + num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; + dummyWindow.destroy(); + } + + public class JOGLTask implements Runnable { + private final int id; + private final Object postSync; + private final boolean reuse; + private boolean done = false; + + public JOGLTask(Object postSync, int id, boolean reuse) { + this.postSync = postSync; + this.id = id; + this.reuse = reuse; + } + public void run() { + int x = ( id % num_x ) * ( demoSize + insets.getTotalHeight() ); + int y = ( (id / num_x) % num_y ) * ( demoSize + insets.getTotalHeight() ); + + System.err.println("JOGLTask "+id+": START: "+x+"/"+y+", reuse "+reuse+" - "+Thread.currentThread().getName()); + final Display display = NewtFactory.createDisplay(null, reuse); + final Screen screen = NewtFactory.createScreen(display, 0); + final GLWindow glWindow = GLWindow.create(screen, new GLCapabilities(GLProfile.getDefault())); + Assert.assertNotNull(glWindow); + glWindow.setTitle("Task "+id); + glWindow.setPosition(x + insets.getLeftWidth(), y + insets.getTopHeight() ); + + glWindow.addGLEventListener(new GearsES2(0)); + + Animator animator = new Animator(glWindow); + + glWindow.setSize(demoSize, demoSize); + glWindow.setVisible(true); + animator.setUpdateFPSFrames(60, null); + + System.err.println("JOGLTask "+id+": INITIALIZED: "+", "+display+" - "+Thread.currentThread().getName()); + + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + Assert.assertEquals(true, glWindow.isVisible()); + Assert.assertEquals(true, glWindow.isNativeValid()); + Assert.assertEquals(true, glWindow.isRealized()); + System.err.println("JOGLTask "+id+": RUNNING: "+Thread.currentThread().getName()); + + while(animator.isAnimating() && animator.getTotalFPSDuration()=0; i--) { + if(!tasks[i].done()) { + return false; + } + } + return true; + } + protected static String doneDump(JOGLTask[] tasks) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for(int i=0; i0) { + sb.append(", "); + } + sb.append(i).append(": ").append(tasks[i].done()); + } + sb.append("]"); + return sb.toString(); + } + + protected static boolean isDead(Thread[] threads) { + for(int i=threads.length-1; i>=0; i--) { + if(threads[i].isAlive()) { + return false; + } + } + return true; + } + protected static String isAliveDump(Thread[] threads) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for(int i=0; i0) { + sb.append(", "); + } + sb.append(i).append(": ").append(threads[i].isAlive()); + } + sb.append("]"); + return sb.toString(); + } + + protected void runJOGLTasks(int num, boolean reuse) throws InterruptedException { + final String currentThreadName = Thread.currentThread().getName(); + final Object syncDone = new Object(); + final JOGLTask[] tasks = new JOGLTask[num]; + final Thread[] threads = new Thread[num]; + int i; + for(i=0; i + * Rendering is always lock-free and independent of the EDT, however shared NEWT Display instances + * perform lifecycle actions (window creation etc) with locking. + *

    + */ +public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT { + + @Test + public void test02TwoThreads() throws InterruptedException { + runJOGLTasks(2, true); + } + + @Test + public void test02FourThreads() throws InterruptedException { + runJOGLTasks(4, true); + } + + @Test + public void test16SixteenThreads() throws InterruptedException { + if( Platform.getCPUFamily() != Platform.CPUFamily.ARM ) { + runJOGLTasks(16, true); + } else { + runJOGLTasks( 8, true); + } + } + + public static void main(String args[]) throws IOException { + for(int i=0; i + * Rendering is always lock-free and independent of the EDT, however exclusive NEWT Display instances + * perform lifecycle actions (window creation etc) w/o locking. + *

    + */ +public class TestInitConcurrent02NEWT extends InitConcurrentBaseNEWT { + + @Test + public void test02TwoThreads() throws InterruptedException { + runJOGLTasks(2, false); + } + + @Test + public void test02FourThreads() throws InterruptedException { + runJOGLTasks(4, false); + } + + @Test + public void test16SixteenThreads() throws InterruptedException { + if( Platform.getCPUFamily() != Platform.CPUFamily.ARM ) { + runJOGLTasks(16, false); + } else { + runJOGLTasks( 8, false); + } + } + + public static void main(String args[]) throws IOException { + for(int i=0; i=0; i--) { - if(!tasks[i].done()) { - return false; - } - } - return true; - } - protected static String doneDump(JOGLTask[] tasks) { - StringBuilder sb = new StringBuilder(); - sb.append("["); - for(int i=0; i0) { - sb.append(", "); - } - sb.append(i).append(": ").append(tasks[i].done()); - } - sb.append("]"); - return sb.toString(); - } - - protected static boolean isDead(Thread[] threads) { - for(int i=threads.length-1; i>=0; i--) { - if(threads[i].isAlive()) { - return false; - } - } - return true; - } - protected static String isAliveDump(Thread[] threads) { - StringBuilder sb = new StringBuilder(); - sb.append("["); - for(int i=0; i0) { - sb.append(", "); - } - sb.append(i).append(": ").append(threads[i].isAlive()); - } - sb.append("]"); - return sb.toString(); - } - - protected void runJOGLTasks(int num) throws InterruptedException { - final String currentThreadName = Thread.currentThread().getName(); - final Object sync = new Object(); - final JOGLTask[] tasks = new JOGLTask[num]; - final Thread[] threads = new Thread[num]; - int i; - for(i=0; i Date: Thu, 27 Sep 2012 17:38:01 +0200 Subject: FBObject: Clarify reset(..), resetSamplingSink(..) ; Rename syncFramebuffer(..) -> syncSamplingSink(..) - reset(..) adds a new argument, boolean resetSamplingSink, allowing to trigger a reset on the samplink sink as well. Use cases are documented. - made public: resetSamplingSink() - Rename syncFramebuffer(..) -> syncSamplingSink(..) to clarify semantics --- make/scripts/tests.sh | 6 +-- src/jogl/classes/com/jogamp/opengl/FBObject.java | 60 +++++++++++++--------- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 8 +-- .../test/junit/jogl/demos/es2/FBOMix2DemosES2.java | 46 +++++++++++------ 4 files changed, 74 insertions(+), 46 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3dc983072..4fc1211db 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -276,9 +276,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java index 59d1c9fa6..b32c8cdcc 100644 --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java @@ -47,7 +47,7 @@ import com.jogamp.opengl.FBObject.Attachment.Type; * Core utility class simplifying usage of framebuffer objects (FBO) * with all {@link GLProfile}s. *

    - * Supports on-the-fly reconfiguration of dimension and multisample buffers via {@link #reset(GL, int, int, int)} + * Supports on-the-fly reconfiguration of dimension and multisample buffers via {@link #reset(GL, int, int, int, boolean)} * while preserving the {@link Attachment} references. *

    *

    @@ -866,7 +866,7 @@ public class FBObject { throw new GLException("size "+width+"x"+height+" exceeds on of the maxima [texture "+maxTextureSize+", renderbuffer "+maxRenderbufferSize+"]"); } - resetMSAATexture2DSink(gl); + resetSamplingSink(gl); // generate fbo .. gl.glGenFramebuffers(1, val, 0); @@ -911,7 +911,7 @@ public class FBObject { * @throws GLException in case of an error */ public final void reset(GL gl, int newWidth, int newHeight) { - reset(gl, newWidth, newHeight, 0); + reset(gl, newWidth, newHeight, 0, false); } /** @@ -932,9 +932,14 @@ public class FBObject { * @param newWidth the new width, it's minimum is capped to 1 * @param newHeight the new height, it's minimum is capped to 1 * @param newSamples if > 0, MSAA will be used, otherwise no multisampling. Will be capped to {@link #getMaxSamples()}. + * @param resetSamplingSink true calls {@link #resetSamplingSink(GL)} immediatly. + * false postpones resetting the sampling sink until {@link #use(GL, TextureAttachment)} or {@link #syncSamplingSink(GL)}, + * allowing to use the samples sink's FBO and texture until then. The latter is useful to benefit + * from implicit double buffering while resetting the sink just before it's being used, eg. at swap-buffer. + * * @throws GLException in case of an error, i.e. size too big, etc .. */ - public final void reset(GL gl, int newWidth, int newHeight, int newSamples) { + public final void reset(GL gl, int newWidth, int newHeight, int newSamples, boolean resetSamplingSink) { if(!initialized) { init(gl, newWidth, newHeight, newSamples); return; @@ -959,16 +964,11 @@ public class FBObject { width = newWidth; height = newHeight; samples = newSamples; - detachAllImpl(gl, true , true); + detachAllImpl(gl, true , true); + if(resetSamplingSink) { + resetSamplingSink(gl); + } - /** - * Postpone reset of samplesSink until syncFramebuffer, - * issued at use(..) method (swapBuffer usually initiates it). - * This allows another thread to still use the 'samplesSinkTexture' - * until swapBuffer happens and does not invalidate the GL_FRONT - * FBO (framebuffer & texture). - resetMSAATexture2DSink(gl); - */ samplesSinkDirty = true; if(!wasBound) { @@ -1925,7 +1925,20 @@ public class FBObject { return depthMismatch || stencilMismatch; } - private final void resetMSAATexture2DSink(GL gl) throws GLException { + /** + * Manually reset the MSAA sampling sink, if used. + *

    + * Automatically called by {@link #reset(GL, int, int, int, boolean)} + * and {@link #syncSamplingSink(GL)}. + *

    + *

    + * It is recommended to call this method after initializing the FBO and attaching renderbuffer etc for the 1st time + * if access to sampling sink resources is required. + *

    + * @param gl the current GL context + * @throws GLException in case of an error, i.e. size too big, etc .. + */ + public final void resetSamplingSink(GL gl) throws GLException { if(null == samplesSink ) { return; // this is the sample sink! } @@ -2082,12 +2095,13 @@ public class FBObject { * If multisampling is being used and flagged dirty by a previous call of {@link #bind(GL)} or after initialization, * the msaa-buffers are sampled to it's sink {@link #getSamplingSink()}. *

    - * Method also updates the sampling sink configuration (if used). Hence it is recommended to call this - * method after your have initialized the FBO and attached renderbuffer etc for the 1st time. + * Method also resets the sampling sink configuration via {@link #resetSamplingSink(GL)} if used and required. + *

    + *

    * Method is called automatically by {@link #use(GL, TextureAttachment)}. *

    *

    - * Methos always resets the framebuffer binding to default in the end. + * Method always resets the framebuffer binding to default in the end. * If full FBO is supported, sets the read and write framebuffer individually to default after sampling, hence not disturbing * an optional operating MSAA FBO, see {@link GLBase#getDefaultReadFramebuffer()} and {@link GLBase#getDefaultDrawFramebuffer()} *

    @@ -2101,11 +2115,11 @@ public class FBObject { * @param ta {@link TextureAttachment} to use, prev. attached w/ {@link #attachTexture2D(GL, int, boolean, int, int, int, int) attachTexture2D(..)} * @throws IllegalArgumentException */ - public final void syncFramebuffer(GL gl) { + public final void syncSamplingSink(GL gl) { markUnbound(); if(samples>0 && samplesSinkDirty) { samplesSinkDirty = false; - resetMSAATexture2DSink(gl); + resetSamplingSink(gl); gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbName); gl.glBindFramebuffer(GL2GL3.GL_DRAW_FRAMEBUFFER, samplesSink.getWriteFramebuffer()); ((GL2GL3)gl).glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, // since MSAA is supported, casting to GL2GL3 is OK @@ -2126,7 +2140,7 @@ public class FBObject { * *

    If using multiple texture units, ensure you call {@link GL#glActiveTexture(int)} first!

    * - *

    {@link #syncFramebuffer(GL)} is being called

    + *

    {@link #syncSamplingSink(GL)} is being called

    * *

    Leaves the FBO unbound!

    * @@ -2135,8 +2149,8 @@ public class FBObject { * @throws IllegalArgumentException */ public final void use(GL gl, TextureAttachment ta) throws IllegalArgumentException { - if(null == ta) { throw new IllegalArgumentException("null TextureAttachment, this: "+toString()); } - syncFramebuffer(gl); + if(null == ta) { throw new IllegalArgumentException("Null TextureAttachment, this: "+toString()); } + syncSamplingSink(gl); gl.glBindTexture(GL.GL_TEXTURE_2D, ta.getName()); // use it .. } @@ -2210,7 +2224,7 @@ public class FBObject { /** * Returns true if this instance has been initialized with {@link #reset(GL, int, int)} - * or {@link #reset(GL, int, int, int)}, otherwise false + * or {@link #reset(GL, int, int, int, boolean)}, otherwise false */ public final boolean isInitialized() { return initialized; } /** Returns the width */ diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index d7de7ca50..503b70af7 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -102,7 +102,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { for(int i=0; i0) { fbo0.attachColorbuffer(gl, 0, true); + fbo0.resetSamplingSink(gl); fbo1.attachColorbuffer(gl, 0, true); + fbo1.resetSamplingSink(gl); fbo0Tex = fbo0.getSamplingSink(); fbo1Tex = fbo1.getSamplingSink(); } else { fbo0Tex = fbo0.attachTexture2D(gl, 0, true); fbo1Tex = fbo1.attachTexture2D(gl, 0, true); } + numSamples=fbo0.getNumSamples(); + fbo0.attachRenderbuffer(gl, Type.DEPTH, 24); + fbo0.unbind(gl); + fbo1.attachRenderbuffer(gl, Type.DEPTH, 24); + fbo1.unbind(gl); } + private void resetFBOs(GL gl, GLAutoDrawable drawable) { + fbo0.reset(gl, drawable.getWidth(), drawable.getHeight(), numSamples, true); + fbo1.reset(gl, drawable.getWidth(), drawable.getHeight(), numSamples, true); + if(fbo0.getNumSamples() != fbo1.getNumSamples()) { + throw new InternalError("sample size mismatch: \n\t0: "+fbo0+"\n\t1: "+fbo1); + } + numSamples = fbo0.getNumSamples(); + if(numSamples>0) { + fbo0Tex = fbo0.getSamplingSink(); + fbo1Tex = fbo1.getSamplingSink(); + } else { + fbo0Tex = (TextureAttachment) fbo0.getColorbuffer(0); + fbo1Tex = (TextureAttachment) fbo1.getColorbuffer(0); + } + } + @Override public void dispose(GLAutoDrawable drawable) { final GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -265,10 +281,8 @@ public class FBOMix2DemosES2 implements GLEventListener { gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) } - // if(drawable.getWidth() == fbo0.getWidth() && drawable.getHeight() == fbo0.getHeight() ) { - System.err.println("**** Reshape: "+width+"x"+height); - resetFBOs(gl, drawable); - //} + System.err.println("**** Reshape: "+width+"x"+height); + resetFBOs(gl, drawable); fbo0.bind(gl); demo0.reshape(drawable, x, y, width, height); -- cgit v1.2.3 From 54f79e402ddb87de9caa3297228cbd16c452cfb4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 28 Sep 2012 09:56:46 +0200 Subject: NEWT X11 ScreenMode: Ignore invalid rotation event --- make/scripts/tests.sh | 36 +--------------- src/newt/native/X11Screen.c | 25 +++++++---- .../test/junit/newt/TestScreenMode01NEWT.java | 48 ++++++++++++++++------ 3 files changed, 53 insertions(+), 56 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4fc1211db..7faca0b42 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -92,6 +92,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" + D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnewt.debug.Window" @@ -115,7 +116,6 @@ function jrun() { #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnativewindow.debug.X11Util" #D_ARGS="-Dnewt.debug.EDT -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator -Dnewt.debug.Display -Dnewt.debug.Screen" - #D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.Animator -Dnewt.debug=all" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Display -Dnativewindow.debug.X11Util -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas" @@ -256,38 +256,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -# x11 no XinitThreads() specific tests (regressions, concurrent behavior) ! -# Deadlock: -# com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 - test01 -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* -# com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT - testEachWithAnimatorSharedOffscreen -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -# -# XCB: -# -# com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT - testShaderState01PerformanceDouble -#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* -# com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT - testWindowParenting02ReparentTop2WinReparentRecreate -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* -# com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT - winHopFrame2FrameDirectHop -#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* - -#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* - - #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -334,7 +302,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c index 334c39727..e8a3ca656 100644 --- a/src/newt/native/X11Screen.c +++ b/src/newt/native/X11Screen.c @@ -469,15 +469,22 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentSc switch (evt.type - randr_event_base) { case RRScreenChangeNotify: - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; + if(0 < scn_event->rotation ) { + rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, rot, + scn_event->width, scn_event->height); + // done = scn_event->size_index == resMode_idx; // not reliable .. + done = rot == rotation && + scn_event->width == xrrs[resMode_idx].width && + scn_event->height == xrrs[resMode_idx].height; + } else { + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, + scn_event->width, scn_event->height); + } break; default: DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java index b9f3e67dc..f253f3b58 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java @@ -34,7 +34,6 @@ import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.Animator; -import org.junit.After; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -48,6 +47,7 @@ import com.jogamp.newt.ScreenMode; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.util.ScreenModeUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import java.util.List; @@ -109,10 +109,12 @@ public class TestScreenMode01NEWT extends UITestCase { * Remedy B) is shown in {@link TestScreenMode01bNEWT} * */ - @After - public void cleanupGL() throws InterruptedException { + private void cleanupGL() throws InterruptedException { + System.err.println("*** cleanupGL.shutdown"); GLProfile.shutdown(); + System.err.println("*** cleanupGL.initSingleton"); GLProfile.initSingleton(); + System.err.println("*** cleanupGL.DONE"); } static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { @@ -166,7 +168,15 @@ public class TestScreenMode01NEWT extends UITestCase { Thread.sleep(waitTimeShort); animator.stop(); - destroyWindow(window); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + Assert.assertEquals(false, window.isRealized()); + Assert.assertEquals(false, window.isNativeValid()); + + cleanupGL(); } @Test @@ -230,11 +240,15 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertEquals(true,window.isNativeValid()); Assert.assertEquals(true,window.isVisible()); - animator.stop(); + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + destroyWindow(window); - Thread.sleep(waitTimeShort); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isRealized()); Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); @@ -246,14 +260,15 @@ public class TestScreenMode01NEWT extends UITestCase { smCurrent = screen.getCurrentScreenMode(); System.err.println("[1] current/orig: "+smCurrent); + screen.destroy(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); Assert.assertNotNull(smCurrent); Assert.assertEquals(smCurrent, smOrig); - screen.destroy(); - - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); + + cleanupGL(); } @Test @@ -326,10 +341,14 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertEquals(true,window.isVisible()); animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + destroyWindow(window); - Thread.sleep(waitTimeShort); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isRealized()); Assert.assertEquals(false,window.isNativeValid()); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); @@ -341,11 +360,14 @@ public class TestScreenMode01NEWT extends UITestCase { smCurrent = screen.getCurrentScreenMode(); System.err.println("[1] current/orig: "+smCurrent); + screen.destroy(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); Assert.assertNotNull(smCurrent); Assert.assertEquals(smCurrent, smOrig); - - screen.destroy(); + + cleanupGL(); } public static void main(String args[]) throws IOException { -- cgit v1.2.3 From 27fe889023c7366e264647e5dc25053f22df0956 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 28 Sep 2012 18:59:11 +0200 Subject: Adding Mesa Quirk 'NoSetSwapIntervalPostRetarget': SIGSEGV on setSwapInterval() after changing the context's drawable w/ 'Mesa 8.0.4' dri2SetSwapInterval/DRI2 (soft & intel) Analyzing 'TestGLContextDrawableSwitchNEWT' crash at setSwapInterval -> dri2SetSwapInterval after retargeting the context (new drawable association). Turns out Mesa's dri2SetSwapInterval may have a bug. +++ GLContext TRACE_SWITCH: Add drawable handle to debug/trace output. --- make/scripts/tests.sh | 7 ++-- .../com/jogamp/opengl/GLRendererQuirks.java | 9 +++-- src/jogl/classes/javax/media/opengl/GLContext.java | 25 +++++++------- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 38 ++++++++++++++-------- .../jogamp/opengl/x11/glx/X11GLXContext.java | 1 - .../acore/TestGLContextDrawableSwitchNEWT.java | 22 +++++++++---- 6 files changed, 64 insertions(+), 38 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7faca0b42..f3a71d288 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -92,7 +92,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" - D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" + #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnewt.debug.Window" @@ -137,6 +137,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" + D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" @@ -254,7 +255,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* @@ -302,7 +303,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 13c94c6f2..1bbe22548 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -48,12 +48,15 @@ public class GLRendererQuirks { /** No offscreen bitmap available, currently true for JOGL's OSX implementation. */ public static final int NoOffscreenBitmap = 3; + /** SIGSEGV on setSwapInterval() after changing the context's drawable w/ 'Mesa 8.0.4' dri2SetSwapInterval/DRI2 (soft & intel) */ + public static final int NoSetSwapIntervalPostRetarget = 4; + /** Number of quirks known. */ - public static final int COUNT = 4; + public static final int COUNT = 5; private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", - "NoOffscreenBitmap" - }; + "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget" + }; private final int _bitmask; diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 93b9bfe82..1cee0209c 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -162,6 +162,9 @@ public abstract class GLContext { private int currentSwapInterval; protected GLRendererQuirks glRendererQuirks; + /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */ + protected boolean drawableRetargeted; + protected void resetStates() { if (DEBUG) { System.err.println(getThreadName() + ": GLContext.resetStates()"); @@ -175,6 +178,7 @@ public abstract class GLContext { contextHandle=0; currentSwapInterval = -1; glRendererQuirks = null; + drawableRetargeted = false; } /** @@ -781,8 +785,8 @@ public abstract class GLContext { } /** - * Set the swap interval if the current context. - * @param interval Should be ≥ 0. 0 Disables the vertical synchronisation, + * Set the swap interval of the current context and attached drawable. + * @param interval Should be ≥ 0. 0 disables the vertical synchronization, * where ≥ 1 is the number of vertical refreshes before a swap buffer occurs. * A value < 0 is ignored. * @return true if the operation was successful, otherwise false @@ -792,9 +796,11 @@ public abstract class GLContext { public final boolean setSwapInterval(int interval) throws GLException { validateCurrent(); if(0<=interval) { - if( setSwapIntervalImpl(interval) ) { - currentSwapInterval = interval; - return true; + if( !drawableRetargeted || !hasRendererQuirk(GLRendererQuirks.NoSetSwapIntervalPostRetarget) ) { + if( setSwapIntervalImpl(interval) ) { + currentSwapInterval = interval; + return true; + } } } return false; @@ -808,15 +814,12 @@ public abstract class GLContext { * the default value -1 is returned. *

    *

    - * The default value for a valid context is 1 for - * an EGL based profile (ES1 or ES2) and -1 (undefined) - * for desktop. + * For a valid context the default value is 1 + * in case of an EGL based profile (ES1 or ES2) and -1 + * (undefined) for desktop. *

    */ public final int getSwapInterval() { - if(-1 == currentSwapInterval && this.isGLES()) { - currentSwapInterval = 1; - } return currentSwapInterval; } protected final void setDefaultSwapInterval() { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index e164dfe44..d7f61681f 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -214,6 +214,7 @@ public abstract class GLContextImpl extends GLContext { } final GLDrawableImpl old = drawable; old.associateContext(this, false); + drawableRetargeted = null != drawable; drawable = (GLDrawableImpl) readWrite ; drawable.associateContext(this, true); if(lockHeld) { @@ -270,7 +271,7 @@ public abstract class GLContextImpl extends GLContext { } private void release(boolean inDestruction) throws GLException { if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - release() - force: "+inDestruction+", "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - release() - force: "+inDestruction+", "+lock); } if ( !lock.isOwner(Thread.currentThread()) ) { throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this); @@ -296,7 +297,7 @@ public abstract class GLContextImpl extends GLContext { drawable.unlockSurface(); lock.unlock(); if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - "+(actualRelease?"switch":"keep ")+" - CONTEXT_RELEASE - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+(actualRelease?"switch":"keep ")+" - CONTEXT_RELEASE - "+lock); } } if(null != drawableContextMadeCurrentException) { @@ -310,7 +311,7 @@ public abstract class GLContextImpl extends GLContext { public final void destroy() { if (DEBUG || TRACE_SWITCH) { System.err.println(getThreadName() + ": GLContextImpl.destroy.0: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + - ", isShared "+GLContextShareSet.isShared(this)+" - "+lock); + ", surf "+toHexString(drawable.getHandle())+", isShared "+GLContextShareSet.isShared(this)+" - "+lock); } if (contextHandle != 0) { int lockRes = drawable.lockSurface(); @@ -463,7 +464,7 @@ public abstract class GLContextImpl extends GLContext { // For Mac OS X, however, we need to update the context to track resizes drawableUpdatedNotify(); if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - keep - CONTEXT_CURRENT - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep - CONTEXT_CURRENT - "+lock); } return CONTEXT_CURRENT; } else { @@ -503,7 +504,7 @@ public abstract class GLContextImpl extends GLContext { if (res == CONTEXT_NOT_CURRENT) { if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_NOT_CURRENT - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - CONTEXT_NOT_CURRENT - "+lock); } } else { setCurrent(this); @@ -527,10 +528,10 @@ public abstract class GLContextImpl extends GLContext { contextRealized(true); if(DEBUG || TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT_NEW - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - CONTEXT_CURRENT_NEW - "+lock); } } else if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+" - switch - CONTEXT_CURRENT - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - CONTEXT_CURRENT - "+lock); } contextMadeCurrent(true); @@ -568,10 +569,10 @@ public abstract class GLContextImpl extends GLContext { } if (DEBUG || TRACE_SWITCH) { if(created) { - System.err.println(getThreadName() + ": Create GL context OK: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + " for " + getClass().getName()+" - "+getGLVersion()); + System.err.println(getThreadName() + ": Create GL context OK: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName()+" - "+getGLVersion()); // Thread.dumpStack(); } else { - System.err.println(getThreadName() + ": Create GL context FAILED obj " + toHexString(hashCode()) + ", for " + getClass().getName()); + System.err.println(getThreadName() + ": Create GL context FAILED obj " + toHexString(hashCode()) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName()); } } if(!created) { @@ -1296,12 +1297,21 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - if( glRendererLowerCase.contains("intel(r)") && glRendererLowerCase.contains("mesa") ) { - final int quirk = GLRendererQuirks.NoDoubleBufferedPBuffer; - if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer); + if( glRendererLowerCase.contains("mesa") ) { + { + final int quirk = GLRendererQuirks.NoSetSwapIntervalPostRetarget; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer); + } + quirks[i++] = quirk; + } + if( glRendererLowerCase.contains("intel(r)") ) { + final int quirk = GLRendererQuirks.NoDoubleBufferedPBuffer; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer); + } + quirks[i++] = quirk; } - quirks[i++] = quirk; } glRendererQuirks = new GLRendererQuirks(quirks, 0, i); } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index d1801d8f8..e1330eb52 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -245,7 +245,6 @@ public abstract class X11GLXContext extends GLContextImpl { // hence we need to catch the X11 Error within this block. X11Util.setX11ErrorHandler(true, DEBUG ? false : true); // make sure X11 error handler is set ctx = _glXExt.glXCreateContextAttribsARB(display, config.getFBConfig(), share, direct, attribs); - if(DEBUG) { X11Lib.XSync(display, false); } } catch (RuntimeException re) { if(DEBUG) { Throwable t = new Throwable(getThreadName()+": Info: X11GLXContext.createContextARBImpl glXCreateContextAttribsARB failed with "+getGLVersion(major, minor, ctp, "@creation"), re); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java index 4c1130498..496be3d93 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java @@ -124,8 +124,8 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { public void testSwitch2WindowSingleContext() throws InterruptedException { final QuitAdapter quitAdapter = new QuitAdapter(); - GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); // no GLContext! - GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); // no GLContext! + GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); + GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); // create single context using glad1 and assign it to glad1, // after destroying the prev. context! @@ -159,15 +159,22 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { System.err.println(s+" - switch - START "+ ( t1 - t0 )); animator.pause(); + // switch context _and_ the demo synchronously if(0 == s%2) { - glad1.addGLEventListener(0, glad2.removeGLEventListener(0)); + final GLEventListener demo = glad2.removeGLEventListener(0); GLContext ctx1 = glad1.setContext(glad2.getContext()); glad2.setContext(ctx1); + glad1.addGLEventListener(0, demo); } else { - glad2.addGLEventListener(0, glad1.removeGLEventListener(0)); + final GLEventListener demo = glad1.removeGLEventListener(0); GLContext ctx2 = glad2.setContext(glad1.getContext()); glad1.setContext(ctx2); + glad2.addGLEventListener(0, demo); } + System.err.println(s+" - switch - display-1"); + glad1.display(); + System.err.println(s+" - switch - display-2"); + glad2.display(); System.err.println(s+" - switch - END "+ ( t1 - t0 )); @@ -218,13 +225,16 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { System.err.println(s+" - switch - START "+ ( t1 - t0 )); animator.pause(); + // switch context _and_ the demo synchronously if(0 == s%2) { - glWindow1.addGLEventListener(0, glWindow2.removeGLEventListener(0)); + final GLEventListener demo = glWindow2.removeGLEventListener(0); GLContext ctx1 = glWindow1.setContext(glWindow2.getContext()); + glWindow1.addGLEventListener(0, demo); glWindow2.setContext(ctx1); } else { - glWindow2.addGLEventListener(0, glWindow1.removeGLEventListener(0)); + final GLEventListener demo = glWindow1.removeGLEventListener(0); GLContext ctx2 = glWindow2.setContext(glWindow1.getContext()); + glWindow2.addGLEventListener(0, demo); glWindow1.setContext(ctx2); } -- cgit v1.2.3 From 43891be36e8485353ac74f329fd2f7438303a846 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 29 Sep 2012 04:41:47 +0200 Subject: Cache XineramaIsEnabled(dpy) per display-name in X11Util minimize triggering ATI driver bug of sporadic XCB errors and to reduce server roundtrips. Enhances commit: e4176f4e76f519b3599ad557210def3d35266e7b X11Util.XineramaIsEnabled(dpy) hash maps the Xinerama enable result to the dpy-name. Minimize triggering ATI driver bug of sporadic XCB errors: Our multithreading code somehow triggers an _XReply in XQueryExtension beside other functions, which fails the XCB assertion: ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed. This only appears w/ ATI driver and is probably due to a race condition in the driver (?). This change also reduces server roundtrips / querying time for the cost of 1 hash-map. --- make/scripts/tests.sh | 1 - .../classes/jogamp/nativewindow/x11/X11Util.java | 31 +++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f3a71d288..345e23ae7 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -137,7 +137,6 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" - D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 67508bf87..30792113d 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -34,6 +34,7 @@ package jogamp.nativewindow.x11; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -139,6 +140,7 @@ public class X11Util { private static List openDisplayList = new ArrayList(); // open, no close attempt private static List reusableDisplayList = new ArrayList(); // close attempt, marked uncloseable, for reuse private static List pendingDisplayList = new ArrayList(); // all open (close attempt or reusable) in creation order + private static final HashMap displayXineramaEnabledMap = new HashMap(); /** * Cleanup resources. @@ -178,6 +180,7 @@ public class X11Util { reusableDisplayList.clear(); pendingDisplayList.clear(); openDisplayMap.clear(); + displayXineramaEnabledMap.clear(); shutdown0(); } } @@ -503,10 +506,19 @@ public class X11Util { device.unlock(); } } + public static boolean XineramaIsEnabled(long displayHandle) { if( 0 == displayHandle ) { throw new IllegalArgumentException("X11 Display handle is NULL"); } + final String displayName = X11Lib.XDisplayString(displayHandle); + synchronized(displayXineramaEnabledMap) { + final Boolean b = displayXineramaEnabledMap.get(displayName); + if(null != b) { + return b.booleanValue(); + } + } + final boolean res; if(!XineramaFetched) { // volatile: ok synchronized(X11Util.class) { if( !XineramaFetched ) { @@ -519,16 +531,21 @@ public class X11Util { } } if(0!=XineramaQueryFunc) { - final boolean res = X11Lib.XineramaIsEnabled(XineramaQueryFunc, displayHandle); + res = X11Lib.XineramaIsEnabled(XineramaQueryFunc, displayHandle); + } else { if(DEBUG) { - System.err.println("XineramaIsEnabled: 0x"+Long.toHexString(displayHandle)+": "+res); + System.err.println("XineramaIsEnabled: Couldn't bind to Xinerama - lib 0x"+Long.toHexString(XineramaLibHandle)+ + "query 0x"+Long.toHexString(XineramaQueryFunc)); } - return res; - } else if(DEBUG) { - System.err.println("XineramaIsEnabled: Couldn't bind to Xinerama - lib 0x"+Long.toHexString(XineramaLibHandle)+ - "query 0x"+Long.toHexString(XineramaQueryFunc)); + res = false; } - return false; + synchronized(displayXineramaEnabledMap) { + if(DEBUG) { + System.err.println("XineramaIsEnabled Cache: Display "+displayName+" (0x"+Long.toHexString(displayHandle)+") -> "+res); + } + displayXineramaEnabledMap.put(displayName, Boolean.valueOf(res)); + } + return res; } private static final String getCurrentThreadName() { return Thread.currentThread().getName(); } // Callback for JNI -- cgit v1.2.3 From 92398025abdabb2fdef0d78edd41e730991a6f94 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Sep 2012 19:47:46 +0200 Subject: Workaround for Bug 623: Sporadic XCB assertion failures w/ ATI proprietary driver and w/o native X11 locking The proprietary ATI X11 driver does not handle multi-threaded [GL] clients well, i.e. triggers an XCB assertion 'from time to time'. It almost seems like that the driver either: - aliases all display connections to it's connection name, i.e. server; or - utilizes a build-in display connection w/o locking, used for some reason +++ - X11Lib: Add QueryExtension(dpy, name) allowing early driver determination w/o GL - X11Util detects 'requiresGlobalToolkitLock' and 'markAllDisplaysUnclosable' via X11 extensions. In case certain ATI extensions are available, both are set to true. - X11GLXDrawableFactory: Dropped setting 'markAllDisplaysUnclosable', using X11Util's detection (see above). - New GlobalToolkitLock to satisfy certain driver restrictions (ATI's XCB multithreading bug) - NativeWindowFactory handles new property requiresGlobalToolkitLock, in which case the new GlobalToolkitLock is being used instead of ResourceToolkitLock. - JAWTUtil ToolkitLock locks GlobalToolkitLock 1st to match new 'requiresGlobalToolkitLock' property. - Document static method requirement of X11Util, GDIUtil and OSXUtil via marker interface ToolkitProperties - ToolkitLock: New method 'validateLocked()', allowing use to validate whether the device/toolkit is properly locked and hence to detect implementation bugs. See unit test class: ValidateLockListener --- make/config/nativewindow/x11-CustomJavaCode.java | 5 + make/scripts/tests.sh | 8 +- .../opengl/x11/glx/X11GLXDrawableFactory.java | 4 - .../jogamp/nativewindow/x11/X11GraphicsDevice.java | 2 +- .../media/nativewindow/AbstractGraphicsDevice.java | 11 ++- .../media/nativewindow/DefaultGraphicsDevice.java | 21 +++-- .../media/nativewindow/NativeWindowFactory.java | 101 +++++++++++++-------- .../javax/media/nativewindow/ToolkitLock.java | 22 ++++- .../jogamp/nativewindow/GlobalToolkitLock.java | 75 +++++++++++++++ .../nativewindow/NativeWindowFactoryImpl.java | 7 +- .../jogamp/nativewindow/NullToolkitLock.java | 19 +++- .../jogamp/nativewindow/ResourceToolkitLock.java | 15 ++- .../nativewindow/SharedResourceToolkitLock.java | 11 ++- .../jogamp/nativewindow/ToolkitProperties.java | 51 +++++++++++ .../classes/jogamp/nativewindow/jawt/JAWTUtil.java | 36 +++++++- .../jogamp/nativewindow/macosx/OSXUtil.java | 22 +++-- .../jogamp/nativewindow/windows/GDIUtil.java | 15 ++- .../classes/jogamp/nativewindow/x11/X11Util.java | 51 ++++++++--- src/nativewindow/native/x11/Xmisc.c | 35 +++++++ .../junit/jogl/acore/InitConcurrentBaseNEWT.java | 2 + .../test/junit/util/ValidateLockListener.java | 71 +++++++++++++++ 21 files changed, 496 insertions(+), 88 deletions(-) create mode 100644 src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java create mode 100644 src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java create mode 100644 src/test/com/jogamp/opengl/test/junit/util/ValidateLockListener.java (limited to 'make/scripts') diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java index 56aec4725..8e5da3b2d 100644 --- a/make/config/nativewindow/x11-CustomJavaCode.java +++ b/make/config/nativewindow/x11-CustomJavaCode.java @@ -36,6 +36,11 @@ } private static native Object GetRelativeLocation0(long display, int screen_index, long src_win, long dest_win, int src_x, int src_y); + public static boolean QueryExtension(long display, String extensionName) { + return QueryExtension0(display, extensionName); + } + private static native boolean QueryExtension0(long display, String extensionName); + public static native int XCloseDisplay(long display); public static native void XUnlockDisplay(long display); public static native void XLockDisplay(long display); diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 345e23ae7..0908ef1fd 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -137,7 +137,8 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" - #D_ARGS="-Dnativewindow.debug.X11Util.XSync" + #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" + D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.NullToolkitLock.InvalidLocked -Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" @@ -245,7 +246,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* @@ -254,7 +255,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug623ATIXCBAssertionFailureNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index b867125ad..018f6a6ea 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -241,10 +241,6 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { final String glXServerVendorName = GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_VENDOR); final VersionNumber glXServerVersion = GLXUtil.getGLXServerVersionNumber(sharedDevice); final boolean glXServerMultisampleAvailable = GLXUtil.isMultisampleAvailable(GLX.glXQueryServerString(sharedDevice.getHandle(), 0, GLX.GLX_EXTENSIONS)); - if(X11Util.ATI_HAS_XCLOSEDISPLAY_BUG && GLXUtil.isVendorATI(glXServerVendorName)) { - X11Util.setMarkAllDisplaysUnclosable(true); - X11Util.markDisplayUncloseable(sharedDevice.getHandle()); - } final GLProfile glp = GLProfile.get(sharedDevice, GLProfile.GL_PROFILE_LIST_MIN_DESKTOP, false); if (null == glp) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index 142bb99e3..0f28ca67c 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -61,7 +61,7 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } /** Constructs a new X11GraphicsDevice corresponding to the given native display handle and default - * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#createDefaultToolkitLock(String, long)}. + * {@link javax.media.nativewindow.ToolkitLock} via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. * @see DefaultGraphicsDevice#DefaultGraphicsDevice(String, String, int, long) */ public X11GraphicsDevice(long display, int unitID, boolean owner) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index 5eaaa6613..8ecd5242d 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -102,17 +102,24 @@ public interface AbstractGraphicsDevice extends Cloneable { public long getHandle(); /** - * Optionally locking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock}. + * Optionally locking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock#lock()}. * The lock implementation must be recursive. */ public void lock(); /** - * Optionally unlocking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock}. + * Optionally unlocking the device, utilizing eg {@link javax.media.nativewindow.ToolkitLock#unlock()}. * The lock implementation must be recursive. + * + * @throws RuntimeException in case the lock is not acquired by this thread. */ public void unlock(); + /** + * @throws RuntimeException if current thread does not hold the lock + */ + public void validateLocked() throws RuntimeException; + /** * Optionally [re]opening the device if handle is null. *

    diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index b16b0c75c..9288652d9 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -60,7 +60,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice /** * Create an instance with the system default {@link ToolkitLock}. - * gathered via {@link NativeWindowFactory#createDefaultToolkitLock(String, long)}. + * gathered via {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. * @param type * @param handle */ @@ -70,7 +70,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice this.unitID = unitID; this.uniqueID = getUniqueID(type, connection, unitID); this.handle = handle; - this.toolkitLock = NativeWindowFactory.createDefaultToolkitLock(type, handle); + this.toolkitLock = NativeWindowFactory.getDefaultToolkitLock(type, handle); } /** @@ -123,8 +123,10 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice } /** - * No lock is performed on the graphics device per default, - * instead the aggregated recursive {@link ToolkitLock#lock()} is invoked. + * {@inheritDoc} + *

    + * Locking is perfomed via delegation to {@link ToolkitLock#lock()}, {@link ToolkitLock#unlock()}. + *

    * * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long) * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock) @@ -134,9 +136,16 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice toolkitLock.lock(); } + @Override + public final void validateLocked() throws RuntimeException { + toolkitLock.validateLocked(); + } + /** - * No lock is performed on the graphics device per default, - * instead the aggregated recursive {@link ToolkitLock#unlock()} is invoked. + * {@inheritDoc} + *

    + * Locking is perfomed via delegation to {@link ToolkitLock#lock()}, {@link ToolkitLock#unlock()}. + *

    * * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long) * @see DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock) diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 4f4bb629b..af8008f0f 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -42,6 +42,7 @@ import java.util.Map; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NativeWindowFactoryImpl; +import jogamp.nativewindow.ToolkitProperties; import jogamp.nativewindow.ResourceToolkitLock; import com.jogamp.common.os.Platform; @@ -87,13 +88,17 @@ public abstract class NativeWindowFactory { private static boolean isAWTAvailable; private static final String JAWTUtilClassName = "jogamp.nativewindow.jawt.JAWTUtil" ; + /** {@link jogamp.nativewindow.x11.X11Util} implements {@link ToolkitProperties}. */ private static final String X11UtilClassName = "jogamp.nativewindow.x11.X11Util"; + /** {@link jogamp.nativewindow.macosx.OSXUtil} implements {@link ToolkitProperties}. */ private static final String OSXUtilClassName = "jogamp.nativewindow.macosx.OSXUtil"; + /** {@link jogamp.nativewindow.windows.GDIUtil} implements {@link ToolkitProperties}. */ private static final String GDIClassName = "jogamp.nativewindow.windows.GDIUtil"; private static ToolkitLock jawtUtilJAWTToolkitLock; private static boolean requiresToolkitLock; + private static boolean requiresGlobalToolkitLock; private static volatile boolean isJVMShuttingDown = false; @@ -156,11 +161,18 @@ public abstract class NativeWindowFactory { if( null != clazzName ) { ReflectionUtil.callStaticMethod(clazzName, "initSingleton", null, null, cl ); - final Boolean res = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl); - requiresToolkitLock = res.booleanValue(); + final Boolean res1 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresToolkitLock", null, null, cl); + requiresToolkitLock = res1.booleanValue(); + if(requiresToolkitLock) { + final Boolean res2 = (Boolean) ReflectionUtil.callStaticMethod(clazzName, "requiresGlobalToolkitLock", null, null, cl); + requiresGlobalToolkitLock = res2.booleanValue(); + } else { + requiresGlobalToolkitLock = false; + } } else { requiresToolkitLock = false; - } + requiresGlobalToolkitLock = false; + } } private static void shutdownNativeImpl(final ClassLoader cl) { @@ -261,7 +273,7 @@ public abstract class NativeWindowFactory { } if(DEBUG) { - System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock); + System.err.println("NativeWindowFactory requiresToolkitLock "+requiresToolkitLock+", requiresGlobalToolkitLock "+requiresGlobalToolkitLock); System.err.println("NativeWindowFactory isAWTAvailable "+isAWTAvailable+", defaultFactory "+factory); } @@ -295,7 +307,12 @@ public abstract class NativeWindowFactory { /** @return true if the underlying toolkit requires locking, otherwise false. */ public static boolean requiresToolkitLock() { return requiresToolkitLock; - } + } + + /** @return true if the underlying toolkit requires global locking, otherwise false. */ + public static boolean requiresGlobalToolkitLock() { + return requiresGlobalToolkitLock; + } /** @return true if not headless, AWT Component and NativeWindow's AWT part available */ public static boolean isAWTAvailable() { return isAWTAvailable; } @@ -331,9 +348,28 @@ public abstract class NativeWindowFactory { return defaultFactory; } + /** + * Returns the AWT {@link ToolkitLock} (JAWT based) if {@link #isAWTAvailable}, otherwise null. + *

    + * The JAWT based {@link ToolkitLock} also locks the global lock, + * which matters if the latter is required. + *

    + */ + public static ToolkitLock getAWTToolkitLock() { + return jawtUtilJAWTToolkitLock; + } + + public static ToolkitLock getNullToolkitLock() { + return NativeWindowFactoryImpl.getNullToolkitLock(); + } + + public static ToolkitLock getGlobalToolkitLock() { + return NativeWindowFactoryImpl.getGlobalToolkitLock(); + } + /** - * Provides the system default {@link ToolkitLock}, a singleton instance. - *
    + * Provides the system default {@link ToolkitLock} for the default system windowing type. + * @see #getNativeWindowType(boolean) * @see #getDefaultToolkitLock(java.lang.String) */ public static ToolkitLock getDefaultToolkitLock() { @@ -341,57 +377,44 @@ public abstract class NativeWindowFactory { } /** - * Provides the default {@link ToolkitLock} for type, a singleton instance. + * Provides the default {@link ToolkitLock} for type. *
      - *
    • JAWT {@link ToolkitLock} if required and AWT available, otherwise
    • + *
    • JAWT {@link ToolkitLock} if required and type is of {@link #TYPE_AWT} and AWT available,
    • + *
    • {@link jogamp.nativewindow.GlobalToolkitLock} if required, otherwise
    • + *
    • {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
    • *
    • {@link jogamp.nativewindow.NullToolkitLock}
    • *
    */ public static ToolkitLock getDefaultToolkitLock(String type) { - if( requiresToolkitLock() ) { - if( TYPE_AWT == type && TYPE_X11 == getNativeWindowType(false) && isAWTAvailable() ) { + if( requiresToolkitLock ) { + if( TYPE_AWT == type && isAWTAvailable() ) { return getAWTToolkitLock(); } - } - return NativeWindowFactoryImpl.getNullToolkitLock(); - } - - /** Returns the AWT Toolkit (JAWT based) if {@link #isAWTAvailable}, otherwise null. */ - public static ToolkitLock getAWTToolkitLock() { - return jawtUtilJAWTToolkitLock; - } - - public static ToolkitLock getNullToolkitLock() { - return NativeWindowFactoryImpl.getNullToolkitLock(); - } - - /** - * Creates the default {@link ToolkitLock} for type and deviceHandle. - *
      - *
    • {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
    • - *
    • {@link jogamp.nativewindow.NullToolkitLock}
    • - *
    - */ - public static ToolkitLock createDefaultToolkitLock(String type, long deviceHandle) { - if( requiresToolkitLock() ) { + if( requiresGlobalToolkitLock ) { + return NativeWindowFactoryImpl.getGlobalToolkitLock(); + } return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); } - + /** - * Creates the default {@link ToolkitLock} for type and deviceHandle. + * Provides the default {@link ToolkitLock} for type and deviceHandle. *
      - *
    • JAWT {@link ToolkitLock} if required and AWT available,
    • + *
    • JAWT {@link ToolkitLock} if required and type is of {@link #TYPE_AWT} and AWT available,
    • + *
    • {@link jogamp.nativewindow.GlobalToolkitLock} if required, otherwise
    • *
    • {@link jogamp.nativewindow.ResourceToolkitLock} if required, otherwise
    • *
    • {@link jogamp.nativewindow.NullToolkitLock}
    • *
    */ - public static ToolkitLock createDefaultToolkitLock(String type, String sharedType, long deviceHandle) { - if( requiresToolkitLock() ) { - if( TYPE_AWT == sharedType && isAWTAvailable() ) { + public static ToolkitLock getDefaultToolkitLock(String type, long deviceHandle) { + if( requiresToolkitLock ) { + if( TYPE_AWT == type && isAWTAvailable() ) { return getAWTToolkitLock(); } + if( requiresGlobalToolkitLock ) { + return NativeWindowFactoryImpl.getGlobalToolkitLock(); + } return ResourceToolkitLock.create(); } return NativeWindowFactoryImpl.getNullToolkitLock(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java index 18b7cf5d9..eccfcfa4f 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java +++ b/src/nativewindow/classes/javax/media/nativewindow/ToolkitLock.java @@ -37,15 +37,35 @@ import jogamp.nativewindow.Debug; * Toolkit locks are created solely via {@link NativeWindowFactory}. *

    *

    - * One use case is the AWT locking on X11, see {@link NativeWindowFactory#createDefaultToolkitLock(String, long)}. + * One use case is the AWT locking on X11, see {@link NativeWindowFactory#getDefaultToolkitLock(String, long)}. *

    */ public interface ToolkitLock { + public static final boolean DEBUG = Debug.debug("ToolkitLock"); public static final boolean TRACE_LOCK = Debug.isPropertyDefined("nativewindow.debug.ToolkitLock.TraceLock", true); + /** + * Blocking until the lock is acquired by this Thread or a timeout is reached. + *

    + * Timeout is implementation specific, if used at all. + *

    + * + * @throws RuntimeException in case of a timeout + */ public void lock(); + + /** + * Release the lock. + * + * @throws RuntimeException in case the lock is not acquired by this thread. + */ public void unlock(); + /** + * @throws RuntimeException if current thread does not hold the lock + */ + public void validateLocked() throws RuntimeException; + /** * Dispose this instance. *

    diff --git a/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java new file mode 100644 index 000000000..0c2a1e43f --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/GlobalToolkitLock.java @@ -0,0 +1,75 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.nativewindow; + +import javax.media.nativewindow.ToolkitLock; + +import com.jogamp.common.util.locks.LockFactory; +import com.jogamp.common.util.locks.RecursiveLock; + +/** + * Implementing a global recursive {@link javax.media.nativewindow.ToolkitLock}. + *

    + * This is the last resort for unstable driver, e.g. proprietary ATI/X11 12.8 and 12.9, + * where multiple X11 display connections to the same connection name are not treated + * thread safe within the GL/X11 driver. + *

    + */ +public class GlobalToolkitLock implements ToolkitLock { + private static final RecursiveLock globalLock = LockFactory.createRecursiveLock(); + + /** Singleton via {@link NativeWindowFactoryImpl#getGlobalToolkitLock()} */ + protected GlobalToolkitLock() { } + + @Override + public final void lock() { + globalLock.lock(); + if(TRACE_LOCK) { System.err.println("GlobalToolkitLock.lock()"); } + } + + @Override + public final void unlock() { + if(TRACE_LOCK) { System.err.println("GlobalToolkitLock.unlock()"); } + globalLock.unlock(); // implicit lock validation + } + + @Override + public final void validateLocked() throws RuntimeException { + globalLock.validateLocked(); + } + + @Override + public final void dispose() { + // nop + } + + public String toString() { + return "GlobalToolkitLock[obj 0x"+Integer.toHexString(hashCode())+", isOwner "+globalLock.isOwner(Thread.currentThread())+", "+globalLock.toString()+"]"; + } +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java index 29564da3b..c35cede77 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NativeWindowFactoryImpl.java @@ -44,9 +44,14 @@ import com.jogamp.common.util.ReflectionUtil.AWTNames; public class NativeWindowFactoryImpl extends NativeWindowFactory { private static final ToolkitLock nullToolkitLock = new NullToolkitLock(); + private static final ToolkitLock globalToolkitLock = new GlobalToolkitLock(); public static ToolkitLock getNullToolkitLock() { - return nullToolkitLock; + return nullToolkitLock; + } + + public static ToolkitLock getGlobalToolkitLock() { + return globalToolkitLock; } // This subclass of NativeWindowFactory handles the case of diff --git a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java index e59910138..211e15955 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java @@ -31,15 +31,16 @@ package jogamp.nativewindow; import javax.media.nativewindow.ToolkitLock; /** - * Implementing a singleton global recursive {@link javax.media.nativewindow.ToolkitLock} - * without any locking. Since there is no locking it all, - * it is intrinsically recursive. + * Implementing a singleton global NOP {@link javax.media.nativewindow.ToolkitLock} + * without any locking. Since there is no locking it all, it is intrinsically recursive. */ public class NullToolkitLock implements ToolkitLock { - + public static final boolean INVALID_LOCKED = Debug.isPropertyDefined("nativewindow.debug.NullToolkitLock.InvalidLocked", true); + /** Singleton via {@link NativeWindowFactoryImpl#getNullToolkitLock()} */ protected NullToolkitLock() { } + @Override public final void lock() { if(TRACE_LOCK) { System.err.println("NullToolkitLock.lock()"); @@ -47,10 +48,20 @@ public class NullToolkitLock implements ToolkitLock { } } + @Override public final void unlock() { if(TRACE_LOCK) { System.err.println("NullToolkitLock.unlock()"); } } + @Override + public final void validateLocked() throws RuntimeException { + /* nop */ + if(INVALID_LOCKED) { + throw new RuntimeException("NullToolkitLock does not lock"); + } + } + + @Override public final void dispose() { // nop } diff --git a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java index a3b0804fa..5b79de0b8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/ResourceToolkitLock.java @@ -41,8 +41,6 @@ import com.jogamp.common.util.locks.RecursiveLock; *

    */ public class ResourceToolkitLock implements ToolkitLock { - public static final boolean DEBUG = Debug.debug("ToolkitLock"); - public static final ResourceToolkitLock create() { return new ResourceToolkitLock(); } @@ -53,17 +51,24 @@ public class ResourceToolkitLock implements ToolkitLock { this.lock = LockFactory.createRecursiveLock(); } - + @Override public final void lock() { - if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.lock()"); } lock.lock(); + if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.lock()"); } } + @Override public final void unlock() { if(TRACE_LOCK) { System.err.println("ResourceToolkitLock.unlock()"); } - lock.unlock(); + lock.unlock(); // implicit lock validation + } + + @Override + public final void validateLocked() throws RuntimeException { + lock.validateLocked(); } + @Override public final void dispose() { // nop } diff --git a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java index 5d7ae8abb..94d12e6fc 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/SharedResourceToolkitLock.java @@ -49,7 +49,6 @@ import com.jogamp.common.util.locks.RecursiveLock; *

    */ public class SharedResourceToolkitLock implements ToolkitLock { - public static final boolean DEBUG = Debug.debug("ToolkitLock"); private static final LongObjectHashMap handle2Lock; static { handle2Lock = new LongObjectHashMap(); @@ -109,16 +108,24 @@ public class SharedResourceToolkitLock implements ToolkitLock { } + @Override public final void lock() { - if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.lock()"); } lock.lock(); + if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.lock()"); } } + @Override public final void unlock() { if(TRACE_LOCK) { System.err.println("SharedResourceToolkitLock.unlock()"); } lock.unlock(); } + @Override + public final void validateLocked() throws RuntimeException { + lock.validateLocked(); + } + + @Override public final void dispose() { if(0 < refCount) { // volatile OK synchronized(handle2Lock) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java new file mode 100644 index 000000000..2062d1f58 --- /dev/null +++ b/src/nativewindow/classes/jogamp/nativewindow/ToolkitProperties.java @@ -0,0 +1,51 @@ +package jogamp.nativewindow; + +import javax.media.nativewindow.NativeWindowFactory; + +/** + * Marker interface. + *

    + * Implementation requires to provide static methods: + *

    +    public static void initSingleton() {}
    +    
    +    public static void shutdown() {}
    +    
    +    public static boolean requiresToolkitLock() {}
    +    
    +    public static boolean requiresGlobalToolkitLock() {}
    + * 
    + * Above static methods are invoked by {@link NativeWindowFactory#initSingleton()}, + * or {@link NativeWindowFactory#shutdown()} via reflection. + *

    + *

    + * If requiresGlobalToolkitLock() == true, then + * requiresToolkitLock() == true shall be valid as well. + *

    + */ +public interface ToolkitProperties { + + /** + * Called by {@link NativeWindowFactory#initSingleton()} + */ + // void initSingleton(); + + /** + * Cleanup resources. + *

    + * Called by {@link NativeWindowFactory#shutdown()} + *

    + */ + // void shutdown(); + + /** + * Called by {@link NativeWindowFactory#initSingleton()} + */ + // boolean requiresToolkitLock(); + + /** + * Called by {@link NativeWindowFactory#initSingleton()} + */ + // boolean requiresGlobalToolkitLock(); + +} diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java index 7c934b154..2dadfb16b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/JAWTUtil.java @@ -79,6 +79,8 @@ public class JAWTUtil { private static final Method sunToolkitAWTLockMethod; private static final Method sunToolkitAWTUnlockMethod; private static final boolean hasSunToolkitAWTLock; + + private static volatile Thread exclusiveOwnerThread; private static final ToolkitLock jawtToolkitLock; @@ -229,13 +231,23 @@ public class JAWTUtil { } hasSunToolkitAWTLock = _hasSunToolkitAWTLock; // hasSunToolkitAWTLock = false; + exclusiveOwnerThread = null; jawtToolkitLock = new ToolkitLock() { public final void lock() { + NativeWindowFactory.getGlobalToolkitLock().lock(); JAWTUtil.lockToolkit(); + if(TRACE_LOCK) { System.err.println("JAWTToolkitLock.lock()"); } } public final void unlock() { + if(TRACE_LOCK) { System.err.println("JAWTToolkitLock.unlock()"); } JAWTUtil.unlockToolkit(); + NativeWindowFactory.getGlobalToolkitLock().unlock(); + } + @Override + public final void validateLocked() throws RuntimeException { + NativeWindowFactory.getGlobalToolkitLock().validateLocked(); + JAWTUtil.validateLocked(); } public final void dispose() { // nop @@ -312,7 +324,7 @@ public class JAWTUtil { * JAWT's native Lock() function calls SunToolkit.awtLock(), * which just uses AWT's global ReentrantLock.
    */ - private static void awtLock() { + private static final void awtLock() { if(hasSunToolkitAWTLock) { try { sunToolkitAWTLockMethod.invoke(null, (Object[])null); @@ -322,6 +334,7 @@ public class JAWTUtil { } else { jawtLockObject.Lock(); } + exclusiveOwnerThread = Thread.currentThread(); } /** @@ -330,7 +343,9 @@ public class JAWTUtil { * JAWT's native Unlock() function calls SunToolkit.awtUnlock(), * which just uses AWT's global ReentrantLock.
    */ - private static void awtUnlock() { + private static final void awtUnlock() { + awtValidateLocked(); + exclusiveOwnerThread = null; if(hasSunToolkitAWTLock) { try { sunToolkitAWTUnlockMethod.invoke(null, (Object[])null); @@ -342,6 +357,16 @@ public class JAWTUtil { } } + private static final void awtValidateLocked() throws RuntimeException { + final Thread ct = Thread.currentThread(); + if( ct != exclusiveOwnerThread ) { + if ( null == exclusiveOwnerThread ) { + throw new RuntimeException(ct.getName()+": JAWT-ToolkitLock not locked"); + } + throw new RuntimeException(ct.getName()+": Not JAWT-ToolkitLock owner. Owner is "+exclusiveOwnerThread.getName()); + } + } + public static void lockToolkit() throws NativeWindowException { if(ToolkitLock.TRACE_LOCK) { System.err.println("JAWTUtil-ToolkitLock.lock()"); } if(!headlessMode && !isJava2DQueueFlusherThread()) { @@ -355,6 +380,13 @@ public class JAWTUtil { awtUnlock(); } } + + public static final void validateLocked() throws RuntimeException { + if(!headlessMode && !isJava2DQueueFlusherThread()) { + awtValidateLocked(); + } + } + public static ToolkitLock getJAWTToolkitLock() { return jawtToolkitLock; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index b7a83e133..481cbbe39 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -34,13 +34,15 @@ import javax.media.nativewindow.util.Point; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NWJNILibLoader; +import jogamp.nativewindow.ToolkitProperties; -public class OSXUtil { +public class OSXUtil implements ToolkitProperties { private static boolean isInit = false; private static final boolean DEBUG = Debug.debug("OSXUtil"); /** * Called by {@link NativeWindowFactory#initSingleton()} + * @see ToolkitProperties */ public static synchronized void initSingleton() { if(!isInit) { @@ -60,13 +62,21 @@ public class OSXUtil { /** * Called by {@link NativeWindowFactory#shutdown()} + * @see ToolkitProperties */ - public static void shutdown() { - } + public static void shutdown() { } - public static boolean requiresToolkitLock() { - return false; - } + /** + * Called by {@link NativeWindowFactory#initSingleton()} + * @see ToolkitProperties + */ + public static boolean requiresToolkitLock() { return false; } + + /** + * Called by {@link NativeWindowFactory#initSingleton()} + * @see ToolkitProperties + */ + public static final boolean requiresGlobalToolkitLock() { return false; } public static boolean isNSView(long object) { return isNSView0(object); diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index 613c76032..4408a0903 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -33,9 +33,10 @@ import javax.media.nativewindow.NativeWindowFactory; import jogamp.nativewindow.NWJNILibLoader; import jogamp.nativewindow.Debug; +import jogamp.nativewindow.ToolkitProperties; import jogamp.nativewindow.x11.X11Util; -public class GDIUtil { +public class GDIUtil implements ToolkitProperties { private static final boolean DEBUG = Debug.debug("GDIUtil"); private static final String dummyWindowClassNameBase = "_dummyWindow_clazz" ; @@ -44,6 +45,7 @@ public class GDIUtil { /** * Called by {@link NativeWindowFactory#initSingleton()} + * @see ToolkitProperties */ public static synchronized void initSingleton() { if(!isInit) { @@ -67,12 +69,23 @@ public class GDIUtil { /** * Called by {@link NativeWindowFactory#shutdown()} + * @see ToolkitProperties */ public static void shutdown() { } + /** + * Called by {@link NativeWindowFactory#initSingleton()} + * @see ToolkitProperties + */ public static boolean requiresToolkitLock() { return false; } + /** + * Called by {@link NativeWindowFactory#initSingleton()} + * @see ToolkitProperties + */ + public static final boolean requiresGlobalToolkitLock() { return false; } + private static RegisteredClass dummyWindowClass = null; private static Object dummyWindowSync = new Object(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 30792113d..a331fa940 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -43,13 +43,15 @@ import javax.media.nativewindow.NativeWindowFactory; import jogamp.nativewindow.Debug; import jogamp.nativewindow.NWJNILibLoader; +import jogamp.nativewindow.ToolkitProperties; + import com.jogamp.common.util.LongObjectHashMap; import com.jogamp.nativewindow.x11.X11GraphicsDevice; /** * Contains a thread safe X11 utility to retrieve display connections. */ -public class X11Util { +public class X11Util implements ToolkitProperties { /** * See Bug 515 - https://jogamp.org/bugzilla/show_bug.cgi?id=515 *

    @@ -88,11 +90,15 @@ public class X11Util { private static String nullDisplayName = null; private static volatile boolean isInit = false; private static boolean markAllDisplaysUnclosable = false; // ATI/AMD X11 driver issues + private static boolean requiresGlobalToolkitLock = false; // ATI/AMD X11 driver issues private static Object setX11ErrorHandlerLock = new Object(); + private static final String X11_EXTENSION_ATIFGLRXDRI = "ATIFGLRXDRI"; + private static final String X11_EXTENSION_ATIFGLEXTENSION = "ATIFGLEXTENSION"; /** * Called by {@link NativeWindowFactory#initSingleton()} + * @see ToolkitProperties */ public static void initSingleton() { if(!isInit) { @@ -100,7 +106,7 @@ public class X11Util { if(!isInit) { isInit = true; if(DEBUG) { - System.out.println("X11UtilUtil.initSingleton()"); + System.out.println("X11Util.initSingleton()"); } if(!NWJNILibLoader.loadNativeWindow("x11")) { throw new NativeWindowException("NativeWindow X11 native library load error."); @@ -108,6 +114,7 @@ public class X11Util { final boolean isInitOK = initialize0( XERROR_STACKDUMP ); + final boolean hasX11_EXTENSION_ATIFGLRXDRI, hasX11_EXTENSION_ATIFGLEXTENSION; final long dpy = X11Lib.XOpenDisplay(null); if(0 != dpy) { if(XSYNC_ENABLED) { @@ -115,17 +122,29 @@ public class X11Util { } try { nullDisplayName = X11Lib.XDisplayString(dpy); + hasX11_EXTENSION_ATIFGLRXDRI = X11Lib.QueryExtension(dpy, X11_EXTENSION_ATIFGLRXDRI); + hasX11_EXTENSION_ATIFGLEXTENSION = X11Lib.QueryExtension(dpy, X11_EXTENSION_ATIFGLEXTENSION); } finally { X11Lib.XCloseDisplay(dpy); } } else { nullDisplayName = "nil"; + hasX11_EXTENSION_ATIFGLRXDRI = false; + hasX11_EXTENSION_ATIFGLEXTENSION = false; } + requiresGlobalToolkitLock = hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION; + markAllDisplaysUnclosable = ATI_HAS_XCLOSEDISPLAY_BUG && ( hasX11_EXTENSION_ATIFGLRXDRI || hasX11_EXTENSION_ATIFGLEXTENSION ); if(DEBUG) { - System.err.println("X11Util init OK "+isInitOK+"]"+ - ", X11 Display(NULL) <"+nullDisplayName+">"+ - ", XSynchronize Enabled: "+XSYNC_ENABLED); + System.err.println("X11Util.initSingleton(): OK "+isInitOK+"]"+ + ",\n\t X11 Display(NULL) <"+nullDisplayName+">"+ + ",\n\t XSynchronize Enabled: " + XSYNC_ENABLED+ + ",\n\t X11_EXTENSION_ATIFGLRXDRI " + hasX11_EXTENSION_ATIFGLRXDRI+ + ",\n\t X11_EXTENSION_ATIFGLEXTENSION " + hasX11_EXTENSION_ATIFGLEXTENSION+ + ",\n\t requiresToolkitLock "+requiresToolkitLock()+ + ",\n\t requiresGlobalToolkitLock "+requiresGlobalToolkitLock()+ + ",\n\t markAllDisplaysUnclosable "+getMarkAllDisplaysUnclosable() + ); // Thread.dumpStack(); } } @@ -147,6 +166,7 @@ public class X11Util { *

    * Called by {@link NativeWindowFactory#shutdown()} *

    + * @see ToolkitProperties */ public static void shutdown() { if(isInit) { @@ -189,8 +209,20 @@ public class X11Util { } } - public static boolean requiresToolkitLock() { - return true; // JAWT locking: yes, instead of native X11 locking w use a recursive lock. + /** + * Called by {@link NativeWindowFactory#initSingleton()} + * @see ToolkitProperties + */ + public static final boolean requiresToolkitLock() { + return true; // JAWT locking: yes, instead of native X11 locking w use a recursive lock per display connection. + } + + /** + * Called by {@link NativeWindowFactory#initSingleton()} + * @see ToolkitProperties + */ + public static final boolean requiresGlobalToolkitLock() { + return requiresGlobalToolkitLock; // JAWT locking: yes, instead of native X11 locking w use a global lock. } public static void setX11ErrorHandler(boolean onoff, boolean quiet) { @@ -206,9 +238,6 @@ public class X11Util { public static boolean getMarkAllDisplaysUnclosable() { return markAllDisplaysUnclosable; } - public static void setMarkAllDisplaysUnclosable(boolean v) { - markAllDisplaysUnclosable = v; - } private X11Util() {} @@ -373,7 +402,7 @@ public class X11Util { name = validateDisplayName(name); boolean reused = false; - synchronized(globalLock) { + synchronized(globalLock) { for(int i=0; iNewObject(env, pointClz, pointCstr, (jint)dest_x, (jint)dest_y); } +/* + * Class: jogamp_nativewindow_x11_X11Lib + * Method: QueryExtension0 + * Signature: (JLjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_x11_X11Lib_QueryExtension0 + (JNIEnv *env, jclass unused, jlong jdisplay, jstring jextensionName) +{ + int32_t major_opcode, first_event, first_error; + jboolean res = JNI_FALSE; + Display * display = (Display *) (intptr_t) jdisplay; + const char* extensionName = NULL; + + if(NULL==display) { + NativewindowCommon_throwNewRuntimeException(env, "NULL argument \"display\""); + return res; + } + if ( NULL == jextensionName ) { + NativewindowCommon_throwNewRuntimeException(env, "NULL argument \"extensionName\""); + return res; + } + extensionName = (*env)->GetStringUTFChars(env, jextensionName, (jboolean*)NULL); + if ( NULL == extensionName ) { + NativewindowCommon_throwNewRuntimeException(env, "Failed to get UTF-8 chars for argument \"extensionName\""); + return res; + } + + res = True == XQueryExtension(display, extensionName, &major_opcode, &first_event, &first_error) ? JNI_TRUE : JNI_FALSE; + + if ( NULL != jextensionName ) { + (*env)->ReleaseStringUTFChars(env, jextensionName, extensionName); + } + return res; +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java index 11d1331ed..6b2de8366 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java @@ -43,6 +43,7 @@ import com.jogamp.newt.Window; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.ValidateLockListener; import com.jogamp.opengl.util.Animator; /** @@ -100,6 +101,7 @@ public class InitConcurrentBaseNEWT extends UITestCase { glWindow.setTitle("Task "+id); glWindow.setPosition(x + insets.getLeftWidth(), y + insets.getTopHeight() ); + glWindow.addGLEventListener(new ValidateLockListener()); glWindow.addGLEventListener(new GearsES2(0)); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/junit/util/ValidateLockListener.java b/src/test/com/jogamp/opengl/test/junit/util/ValidateLockListener.java new file mode 100644 index 000000000..73c1ad74c --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/util/ValidateLockListener.java @@ -0,0 +1,71 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.util; + + +import javax.media.nativewindow.NativeSurface; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + + +public class ValidateLockListener implements GLEventListener { + + private void validateLock(GLAutoDrawable drawable) { + final NativeSurface ns = drawable.getNativeSurface(); + ns.getGraphicsConfiguration().getScreen().getDevice().validateLocked(); + + final Thread current = Thread.currentThread(); + final Thread owner = ns.getSurfaceLockOwner(); + if( ns.isSurfaceLockedByOtherThread() ) { + throw new RuntimeException(current.getName()+": Locked by another thread(1), owner "+owner+", "+ns); + } + if( current != owner ) { + if( null == owner ) { + throw new RuntimeException(current.getName()+": Not locked: "+ns); + } + throw new RuntimeException(current.getName()+": Locked by another thread(2), owner "+owner+", "+ns); + } + } + + public void init(GLAutoDrawable drawable) { + validateLock(drawable); + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + validateLock(drawable); + } + + public void display(GLAutoDrawable drawable) { + validateLock(drawable); + } + + public void dispose(GLAutoDrawable drawable) { + validateLock(drawable); + } +} -- cgit v1.2.3 From 7302b1014a33c373650ed20e6dd363bb6c2a984e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Sep 2012 20:29:06 +0200 Subject: NullToolkitLock.validateLocker(): Throw exception if locking is required (detecting impl. bugs) --- make/scripts/tests.sh | 2 +- src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0908ef1fd..9e384d59f 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -138,7 +138,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" - D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.NullToolkitLock.InvalidLocked -Dnativewindow.debug.NativeWindow" + D_ARGS="-Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" diff --git a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java index 211e15955..5fc5fe376 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java +++ b/src/nativewindow/classes/jogamp/nativewindow/NullToolkitLock.java @@ -28,6 +28,7 @@ package jogamp.nativewindow; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ToolkitLock; /** @@ -35,8 +36,6 @@ import javax.media.nativewindow.ToolkitLock; * without any locking. Since there is no locking it all, it is intrinsically recursive. */ public class NullToolkitLock implements ToolkitLock { - public static final boolean INVALID_LOCKED = Debug.isPropertyDefined("nativewindow.debug.NullToolkitLock.InvalidLocked", true); - /** Singleton via {@link NativeWindowFactoryImpl#getNullToolkitLock()} */ protected NullToolkitLock() { } @@ -55,9 +54,8 @@ public class NullToolkitLock implements ToolkitLock { @Override public final void validateLocked() throws RuntimeException { - /* nop */ - if(INVALID_LOCKED) { - throw new RuntimeException("NullToolkitLock does not lock"); + if( NativeWindowFactory.requiresToolkitLock() ) { + throw new RuntimeException("NullToolkitLock does not lock, but locking is required."); } } -- cgit v1.2.3 From c69d62a7869ba8e42ba4f4a6d4467bc1c49080e4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Sep 2012 20:29:54 +0200 Subject: test script: remove deleted unit test --- make/scripts/tests.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9e384d59f..0cf36ea66 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -256,7 +256,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug623ATIXCBAssertionFailureNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* -- cgit v1.2.3 From a7ab7a722db30f2016b15f0d55d1fa165f30282e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Oct 2012 17:22:35 +0200 Subject: Misc: tests.sh --- make/scripts/tests.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0cf36ea66..5f24ae3cc 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -59,6 +59,8 @@ function jrun() { swton=$1 shift + #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" + #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG" #D_ARGS="-Djogl.disable.opengles" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" @@ -80,7 +82,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL" - #D_ARGS="-Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.UseCurrentThreadLibLoader" #D_ARGS="-Djogamp.debug.NativeLibrary" #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" @@ -108,11 +109,12 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.XSync" + #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.X11Util.TraceDisplayLifecycle" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnativewindow.debug.X11Util" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" - #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" + #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnativewindow.debug.X11Util" #D_ARGS="-Dnewt.debug.EDT -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator -Dnewt.debug.Display -Dnewt.debug.Screen" @@ -138,7 +140,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" - D_ARGS="-Dnativewindow.debug.NativeWindow" + #D_ARGS="-Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" @@ -238,7 +240,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* @@ -448,8 +449,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* -#linux: - # osx: #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT -- cgit v1.2.3 From f7ca4df7b4e6b2acbdb941f67f6d7058db134d91 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Oct 2012 17:56:20 +0200 Subject: Fix regression of fbe331f013608eb31ff0d8675f4e4c9881c9c48b [Remove XInitThreads()] NativeWindowFactory.getDefaultToolkitLock() is no more a global singleton, but an instance which has to track/lock a single resource. Hence the decoration w/ it in GLDrawableFactory is useless and applying lock/unlock on a new instance also a bug/regression. --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java | 14 ++------------ .../com/jogamp/nativewindow/x11/X11GraphicsScreen.java | 6 ++++-- 3 files changed, 8 insertions(+), 16 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5f24ae3cc..afc145460 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -247,7 +247,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* @@ -351,7 +351,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* # Per default (unit tests) all test are performed this way # with OSX: -XstartOnFirstThread # -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 0ea565b89..deb187372 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -441,24 +441,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { @Override public GLContext createExternalGLContext() { - NativeWindowFactory.getDefaultToolkitLock().lock(); - try { - return createExternalGLContextImpl(); - } finally { - NativeWindowFactory.getDefaultToolkitLock().unlock(); - } + return createExternalGLContextImpl(); } protected abstract GLDrawable createExternalGLDrawableImpl(); @Override public GLDrawable createExternalGLDrawable() { - NativeWindowFactory.getDefaultToolkitLock().lock(); - try { - return createExternalGLDrawableImpl(); - } finally { - NativeWindowFactory.getDefaultToolkitLock().unlock(); - } + return createExternalGLDrawableImpl(); } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java index fa57124fb..2ec66290a 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsScreen.java @@ -33,10 +33,12 @@ package com.jogamp.nativewindow.x11; -import javax.media.nativewindow.*; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsScreen; +import javax.media.nativewindow.NativeWindowException; import jogamp.nativewindow.x11.X11Lib; -import jogamp.nativewindow.x11.X11Util; /** Encapsulates a screen index on X11 platforms. Objects of this type are passed to {@link -- cgit v1.2.3 From a644d779ab19cb1d200ae4ba567b9c042c34b337 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Oct 2012 00:34:56 +0200 Subject: Update PMVMatrix/GLMatrixFunc API doc and refine PMVMatrix update / get-Mvi/Mvit-Matrix operation. (Minor API change) Using bitmask for requested Mvi and Mvit matrices, same as dirty-bits to ease matching and update operation. Update of Mvi and Mvit will be performed only if it's dirty-bit and request-bit set within update(). The individual dirty bit is cleared only if it's matrix update is performed. Update is also issued at get-Mvi/Mvit-Matrix operations to ensure proper values w/o update call w/o clearing the modified-bits. update() returns true if the Mvi or Mvit matrix got updated _or_ one of the modified bits is set. update() clears the modified-bits. Adding explicit getModifiedBits() to get and clear it's state. Adding unit test. Lots of API docs .. --- make/scripts/tests.sh | 3 +- .../classes/com/jogamp/opengl/util/PMVMatrix.java | 780 +++++++++++++++------ .../javax/media/opengl/fixedfunc/GLMatrixFunc.java | 175 +++-- src/jogl/classes/jogamp/opengl/ProjectFloat.java | 29 +- .../test/junit/jogl/acore/TestPMVMatrix01NEWT.java | 378 ++++++++++ .../test/junit/jogl/demos/es2/GearsObjectES2.java | 8 +- .../jogamp/opengl/test/junit/util/MiscUtils.java | 48 ++ 7 files changed, 1152 insertions(+), 269 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index afc145460..f650ffc19 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -241,6 +241,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -351,7 +352,7 @@ function testawtswt() { # Per default (unit tests) all test are performed this way # with OSX: -XstartOnFirstThread # -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index fc6ef3ede..eb4231533 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -48,11 +48,196 @@ import jogamp.opengl.ProjectFloat; import com.jogamp.opengl.FloatUtil; import com.jogamp.common.nio.Buffers; - +import com.jogamp.common.os.Platform; + +/** + * PMVMatrix implements a subset of the fixed function pipeline + * regarding the projection (P), modelview (Mv) matrix operation + * which is specified in {@link GLMatrixFunc}. + *

    + * Further more, PMVMatrix provides the {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)} and + * {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}. + * To keep both synchronized after mutable Mv operations like {@link #glRotatef(float, float, float, float) glRotatef(..)} + * in {@link #glMatrixMode(int) glMatrixMode}({@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}), + * users have to call {@link #update()} before using Mvi and Mvit. + *

    + *

    + * All matrices are provided in column-major order, + * as specified in the OpenGL fixed function pipeline, i.e. compatibility profile. + *

    + *

    + * PMVMatrix can supplement {@link GL2ES2} applications w/ the + * lack of the described matrix functionality. + *

    + *

    Matrix storage details

    + *

    + * All matrices use a common FloatBuffer storage + * and are a {@link Buffers#slice2Float(Buffer, float[], int, int) sliced} representation of it. + * The common FloatBuffer and hence all matrices may use NIO direct storage or a {@link #usesBackingArray() backing float array}, + * depending how the instance if {@link #PMVMatrix(boolean) being constructed}. + *

    + *

    + * Note: + *

      + *
    • The matrix is a {@link Buffers#slice2Float(Buffer, float[], int, int) sliced part } of a host matrix and it's start position has been {@link FloatBuffer#mark() marked}.
    • + *
    • Use {@link FloatBuffer#reset() reset()} to rewind it to it's start position after relative operations, like {@link FloatBuffer#get() get()}.
    • + *
    • If using absolute operations like {@link FloatBuffer#get(int) get(int)}, use it's {@link FloatBuffer#reset() reset} {@link FloatBuffer#position() position} as it's offset.
    • + *
    + *

    + */ public class PMVMatrix implements GLMatrixFunc { - protected final float[] matrixBufferArray; + /** Bit value stating a modified {@link #glGetPMatrixf() projection matrix (P)}, since last {@link #update()} call. */ + public static final int MODIFIED_PROJECTION = 1 << 0; + /** Bit value stating a modified {@link #glGetMvMatrixf() modelview matrix (Mv)}, since last {@link #update()} call. */ + public static final int MODIFIED_MODELVIEW = 1 << 1; + /** Bit value stating a modified {@link #glGetTMatrixf() texture matrix (T)}, since last {@link #update()} call. */ + public static final int MODIFIED_TEXTURE = 1 << 2; + /** Bit value stating all is modified */ + public static final int MODIFIED_ALL = MODIFIED_PROJECTION | MODIFIED_MODELVIEW | MODIFIED_TEXTURE ; + + /** Bit value stating a dirty {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)}. */ + public static final int DIRTY_INVERSE_MODELVIEW = 1 << 0; + /** Bit value stating a dirty {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}. */ + public static final int DIRTY_INVERSE_TRANSPOSED_MODELVIEW = 1 << 1; + /** Bit value stating all is dirty */ + public static final int DIRTY_ALL = DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + + /** + * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} + * @return true if the given matrix-mode name is valid, otherwise false. + */ + public static final boolean isMatrixModeName(final int matrixModeName) { + switch(matrixModeName) { + case GL_MODELVIEW_MATRIX: + case GL_PROJECTION_MATRIX: + case GL_TEXTURE_MATRIX: + return true; + } + return false; + } + + /** + * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} + * @return The corresponding matrix-get name, one of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} + */ + public static final int matrixModeName2MatrixGetName(final int matrixModeName) { + switch(matrixModeName) { + case GL_MODELVIEW: + return GL_MODELVIEW_MATRIX; + case GL_PROJECTION: + return GL_PROJECTION_MATRIX; + case GL.GL_TEXTURE: + return GL_TEXTURE_MATRIX; + default: + throw new GLException("unsupported matrixName: "+matrixModeName); + } + } + /** + * @param matrixGetName One of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} + * @return true if the given matrix-get name is valid, otherwise false. + */ + public static final boolean isMatrixGetName(final int matrixGetName) { + switch(matrixGetName) { + case GL_MATRIX_MODE: + case GL_MODELVIEW_MATRIX: + case GL_PROJECTION_MATRIX: + case GL_TEXTURE_MATRIX: + return true; + } + return false; + } + + /** + * @param matrixGetName One of {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX} + * @return The corresponding matrix-mode name, one of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} + */ + public static final int matrixGetName2MatrixModeName(final int matrixGetName) { + switch(matrixGetName) { + case GL_MODELVIEW_MATRIX: + return GL_MODELVIEW; + case GL_PROJECTION_MATRIX: + return GL_PROJECTION; + case GL_TEXTURE_MATRIX: + return GL.GL_TEXTURE; + default: + throw new GLException("unsupported matrixGetName: "+matrixGetName); + } + } + + /** + * @param sb optional passed StringBuilder instance to be used + * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} + * @param row row number + * @param a 4x4 matrix in column major order (OpenGL) + * @return matrix row string representation + */ + public static StringBuilder matrixRowToString(StringBuilder sb, String f, int row, FloatBuffer a) { + if(null == sb) { + sb = new StringBuilder(); + } + final int a0 = a.position(); + sb.append( String.format("[ "+f+" "+f+" "+f+" "+f+" ]", + a.get(a0+row+0*4), a.get(a0+row+1*4), a.get(a0+row+2*4), a.get(a0+row+3*4) ) ); + return sb; + } + + /** + * @param sb optional passed StringBuilder instance to be used + * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} + * @param a 4x4 matrix in column major order (OpenGL) + * @return matrix string representation + */ + public static StringBuilder matrixToString(StringBuilder sb, String f, FloatBuffer a) { + if(null == sb) { + sb = new StringBuilder(); + } + matrixRowToString(sb, f, 0, a).append(Platform.getNewline()); + matrixRowToString(sb, f, 1, a).append(Platform.getNewline()); + matrixRowToString(sb, f, 2, a).append(Platform.getNewline()); + matrixRowToString(sb, f, 3, a).append(Platform.getNewline()); + return sb; + } + + /** + * @param sb optional passed StringBuilder instance to be used + * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} + * @param row row number + * @param a 4x4 matrix in column major order (OpenGL) + * @param b 4x4 matrix in column major order (OpenGL) + * @return matrix row string representation side by side + */ + public static StringBuilder matrixRowToString(StringBuilder sb, String f, int row, FloatBuffer a, FloatBuffer b) { + if(null == sb) { + sb = new StringBuilder(); + } + final int a0 = a.position(); + final int b0 = b.position(); + sb.append( String.format("[ "+f+" "+f+" "+f+" "+f+" =?= "+f+" "+f+" "+f+" "+f+" ]", + a.get(a0+row+0*4), a.get(a0+row+1*4), a.get(a0+row+2*4), a.get(a0+row+3*4), + b.get(b0+row+0*4), b.get(b0+row+1*4), b.get(b0+row+2*4), b.get(b0+row+3*4) ) ); + return sb; + } + + /** + * @param sb optional passed StringBuilder instance to be used + * @param f the format string of one floating point, i.e. "%10.5f", see {@link java.util.Formatter} + * @param a 4x4 matrix in column major order (OpenGL) + * @param b 4x4 matrix in column major order (OpenGL) + * @return side by side representation + */ + public static StringBuilder matrixToString(StringBuilder sb, String f, FloatBuffer a, FloatBuffer b) { + if(null == sb) { + sb = new StringBuilder(); + } + matrixRowToString(sb, f, 0, a, b).append(Platform.getNewline()); + matrixRowToString(sb, f, 1, a, b).append(Platform.getNewline()); + matrixRowToString(sb, f, 2, a, b).append(Platform.getNewline()); + matrixRowToString(sb, f, 3, a, b).append(Platform.getNewline()); + return sb; + } + /** * Creates an instance of PMVMatrix {@link #PMVMatrix(boolean) PMVMatrix(boolean useBackingArray)}, * with useBackingArray = true. @@ -132,13 +317,16 @@ public class PMVMatrix implements GLMatrixFunc { glLoadIdentity(); glMatrixMode(GL.GL_TEXTURE); glLoadIdentity(); - setDirty(); - update(); + modifiedBits = MODIFIED_ALL; + dirtyBits = DIRTY_ALL; + requestMask = 0; + matrixMode = GL_MODELVIEW; } + /** @see #PMVMatrix(boolean) */ public final boolean usesBackingArray() { return usesBackingArray; } - public void destroy() { + public final void destroy() { if(null!=projectFloat) { projectFloat.destroy(); projectFloat=null; } @@ -169,170 +357,156 @@ public class PMVMatrix implements GLMatrixFunc { } } - - public static final boolean isMatrixModeName(final int matrixModeName) { - switch(matrixModeName) { - case GL_MODELVIEW_MATRIX: - case GL_PROJECTION_MATRIX: - case GL_TEXTURE_MATRIX: - return true; - } - return false; - } - - public static final int matrixModeName2MatrixGetName(final int matrixModeName) { - switch(matrixModeName) { - case GL_MODELVIEW: - return GL_MODELVIEW_MATRIX; - case GL_PROJECTION: - return GL_PROJECTION_MATRIX; - case GL.GL_TEXTURE: - return GL_TEXTURE_MATRIX; - default: - throw new GLException("unsupported matrixName: "+matrixModeName); - } - } - - public static final boolean isMatrixGetName(final int matrixGetName) { - switch(matrixGetName) { - case GL_MATRIX_MODE: - case GL_MODELVIEW_MATRIX: - case GL_PROJECTION_MATRIX: - case GL_TEXTURE_MATRIX: - return true; - } - return false; - } - - public static final int matrixGetName2MatrixModeName(final int matrixGetName) { - switch(matrixGetName) { - case GL_MODELVIEW_MATRIX: - return GL_MODELVIEW; - case GL_PROJECTION_MATRIX: - return GL_PROJECTION; - case GL_TEXTURE_MATRIX: - return GL.GL_TEXTURE; - default: - throw new GLException("unsupported matrixGetName: "+matrixGetName); - } - } - - public void setDirty() { - modified = DIRTY_MODELVIEW | DIRTY_PROJECTION | DIRTY_TEXTURE ; - matrixMode = GL_MODELVIEW; - } - - public int getDirtyBits() { - return modified; - } - - public boolean isDirty(final int matrixName) { - boolean res; - switch(matrixName) { - case GL_MODELVIEW: - res = (modified&DIRTY_MODELVIEW)!=0 ; - break; - case GL_PROJECTION: - res = (modified&DIRTY_PROJECTION)!=0 ; - break; - case GL.GL_TEXTURE: - res = (modified&DIRTY_TEXTURE)!=0 ; - break; - default: - throw new GLException("unsupported matrixName: "+matrixName); - } - return res; - } - - public boolean isDirty() { - return modified!=0; - } - - /** - * Update the derived Mvi, Mvit and Pmv matrices - * in case Mv or P has changed. - * - * @return - */ - public boolean update() { - if(0==modified) return false; - - final int res = modified; - if( (res&DIRTY_MODELVIEW)!=0 ) { - setMviMvit(); - } - modified=0; - return res!=0; - } - + + /** Returns the current matrix-mode, one of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE}. */ public final int glGetMatrixMode() { return matrixMode; } + /** + * Returns the {@link GLMatrixFunc#GL_TEXTURE_MATRIX texture matrix} (T). + *

    + * See matrix storage details. + *

    + */ public final FloatBuffer glGetTMatrixf() { return matrixTex; } + /** + * Returns the {@link GLMatrixFunc#GL_PROJECTION_MATRIX projection matrix} (P). + *

    + * See matrix storage details. + *

    + */ public final FloatBuffer glGetPMatrixf() { return matrixP; } + /** + * Returns the {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mv). + *

    + * See matrix storage details. + *

    + */ public final FloatBuffer glGetMvMatrixf() { return matrixMv; } - public final FloatBuffer glGetPMvMviMatrixf() { - usesMviMvit |= 1; - return matrixPMvMvi; + /** + * Returns the inverse {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvi). + *

    + * Method enables the Mvi matrix update, and performs it's update w/o clearing the modified bits. + *

    + *

    + * See {@link #update()} and matrix storage details. + *

    + * @see #update() + * @see #disableMviMvitUpdate() + */ + public final FloatBuffer glGetMviMatrixf() { + requestMask |= DIRTY_INVERSE_MODELVIEW ; + updateImpl(false); + return matrixMvi; } + /** + * Returns the inverse transposed {@link GLMatrixFunc#GL_MODELVIEW_MATRIX modelview matrix} (Mvit). + *

    + * Method enables the Mvit matrix update, and performs it's update w/o clearing the modified bits. + *

    + *

    + * See {@link #update()} and matrix storage details. + *

    + * @see #update() + * @see #disableMviMvitUpdate() + */ + public final FloatBuffer glGetMvitMatrixf() { + requestMask |= DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + updateImpl(false); + return matrixMvit; + } + + /** + * Returns 2 matrices within one FloatBuffer: {@link #glGetPMatrixf() P} and {@link #glGetMvMatrixf() Mv}. + *

    + * See matrix storage details. + *

    + */ public final FloatBuffer glGetPMvMatrixf() { return matrixPMv; } - public final FloatBuffer glGetMviMatrixf() { - usesMviMvit |= 1; - return matrixMvi; + /** + * Returns 3 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv} and {@link #glGetMviMatrixf() Mvi}. + *

    + * Method enables the Mvi matrix update, and performs it's update w/o clearing the modified bits. + *

    + *

    + * See {@link #update()} and matrix storage details. + *

    + * @see #update() + * @see #disableMviMvitUpdate() + */ + public final FloatBuffer glGetPMvMviMatrixf() { + requestMask |= DIRTY_INVERSE_MODELVIEW ; + updateImpl(false); + return matrixPMvMvi; } - + + /** + * Returns 4 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv}, {@link #glGetMviMatrixf() Mvi} and {@link #glGetMvitMatrixf() Mvit}. + *

    + * Method enables the Mvi and Mvit matrix update, and performs it's update w/o clearing the modified bits. + *

    + *

    + * See {@link #update()} and matrix storage details. + *

    + * @see #update() + * @see #disableMviMvitUpdate() + */ public final FloatBuffer glGetPMvMvitMatrixf() { - usesMviMvit |= 1 | 2; + requestMask |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + updateImpl(false); return matrixPMvMvit; } - public final FloatBuffer glGetMvitMatrixf() { - usesMviMvit |= 1 | 2; - return matrixMvit; - } - - /* - * @return the current matrix - */ + /* + * @return the matrix of the current matrix-mode + */ public final FloatBuffer glGetMatrixf() { return glGetMatrixf(matrixMode); } - /** - * @param matrixName GL_MODELVIEW, GL_PROJECTION or GL.GL_TEXTURE - * @return the given matrix - */ + /** + * @param matrixName Either a matrix-get-name, i.e. + * {@link GLMatrixFunc#GL_MODELVIEW_MATRIX GL_MODELVIEW_MATRIX}, {@link GLMatrixFunc#GL_PROJECTION_MATRIX GL_PROJECTION_MATRIX} or {@link GLMatrixFunc#GL_TEXTURE_MATRIX GL_TEXTURE_MATRIX}, + * or a matrix-mode-name, i.e. + * {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} + * @return the named matrix + */ public final FloatBuffer glGetMatrixf(final int matrixName) { - if(matrixName==GL_MODELVIEW) { - return matrixMv; - } else if(matrixName==GL_PROJECTION) { - return matrixP; - } else if(matrixName==GL.GL_TEXTURE) { - return matrixTex; - } else { - throw new GLException("unsupported matrixName: "+matrixName); - } + switch(matrixName) { + case GL_MODELVIEW_MATRIX: + case GL_MODELVIEW: + return matrixMv; + case GL_PROJECTION_MATRIX: + case GL_PROJECTION: + return matrixP; + case GL_TEXTURE_MATRIX: + case GL.GL_TEXTURE: + return matrixTex; + default: + throw new GLException("unsupported matrixName: "+matrixName); + } } // - // MatrixIf + // GLMatrixFunc implementation // - public void glMatrixMode(final int matrixName) { + @Override + public final void glMatrixMode(final int matrixName) { switch(matrixName) { case GL_MODELVIEW: case GL_PROJECTION: @@ -344,27 +518,32 @@ public class PMVMatrix implements GLMatrixFunc { matrixMode = matrixName; } - public void glGetFloatv(int matrixGetName, FloatBuffer params) { + @Override + public final void glGetFloatv(int matrixGetName, FloatBuffer params) { int pos = params.position(); if(matrixGetName==GL_MATRIX_MODE) { params.put((float)matrixMode); } else { - FloatBuffer matrix = glGetMatrixf(matrixGetName2MatrixModeName(matrixGetName)); + FloatBuffer matrix = glGetMatrixf(matrixGetName); params.put(matrix); // matrix -> params matrix.reset(); } params.position(pos); } - public void glGetFloatv(int matrixGetName, float[] params, int params_offset) { + + @Override + public final void glGetFloatv(int matrixGetName, float[] params, int params_offset) { if(matrixGetName==GL_MATRIX_MODE) { params[params_offset]=(float)matrixMode; } else { - FloatBuffer matrix = glGetMatrixf(matrixGetName2MatrixModeName(matrixGetName)); + FloatBuffer matrix = glGetMatrixf(matrixGetName); matrix.get(params, params_offset, 16); // matrix -> params matrix.reset(); } } - public void glGetIntegerv(int pname, IntBuffer params) { + + @Override + public final void glGetIntegerv(int pname, IntBuffer params) { int pos = params.position(); if(pname==GL_MATRIX_MODE) { params.put(matrixMode); @@ -373,7 +552,9 @@ public class PMVMatrix implements GLMatrixFunc { } params.position(pos); } - public void glGetIntegerv(int pname, int[] params, int params_offset) { + + @Override + public final void glGetIntegerv(int pname, int[] params, int params_offset) { if(pname==GL_MATRIX_MODE) { params[params_offset]=matrixMode; } else { @@ -381,41 +562,46 @@ public class PMVMatrix implements GLMatrixFunc { } } + @Override public final void glLoadMatrixf(final float[] values, final int offset) { int len = values.length-offset; if(matrixMode==GL_MODELVIEW) { matrixMv.put(values, offset, len); matrixMv.reset(); - modified |= DIRTY_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { matrixP.put(values, offset, len); matrixP.reset(); - modified |= DIRTY_PROJECTION ; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(values, offset, len); matrixTex.reset(); - modified |= DIRTY_TEXTURE ; + modifiedBits |= MODIFIED_TEXTURE; } } + @Override public final void glLoadMatrixf(java.nio.FloatBuffer m) { int spos = m.position(); if(matrixMode==GL_MODELVIEW) { matrixMv.put(m); matrixMv.reset(); - modified |= DIRTY_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { matrixP.put(m); matrixP.reset(); - modified |= DIRTY_PROJECTION ; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(m); matrixTex.reset(); - modified |= DIRTY_TEXTURE ; + modifiedBits |= MODIFIED_TEXTURE; } m.position(spos); } + @Override public final void glPopMatrix() { float[] stackEntry=null; if(matrixMode==GL_MODELVIEW) { @@ -428,6 +614,7 @@ public class PMVMatrix implements GLMatrixFunc { glLoadMatrixf(stackEntry, 0); } + @Override public final void glPushMatrix() { float[] stackEntry = new float[1*16]; if(matrixMode==GL_MODELVIEW) { @@ -445,49 +632,56 @@ public class PMVMatrix implements GLMatrixFunc { } } + @Override public final void glLoadIdentity() { if(matrixMode==GL_MODELVIEW) { matrixMv.put(matrixIdent); matrixMv.reset(); - modified |= DIRTY_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { matrixP.put(matrixIdent); matrixP.reset(); - modified |= DIRTY_PROJECTION ; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(matrixIdent); matrixTex.reset(); - modified |= DIRTY_TEXTURE ; + modifiedBits |= MODIFIED_TEXTURE; } - matrixIdent.reset(); + matrixIdent.reset(); } + @Override public final void glMultMatrixf(final FloatBuffer m) { if(matrixMode==GL_MODELVIEW) { FloatUtil.multMatrixf(matrixMv, m, matrixMv); - modified |= DIRTY_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { FloatUtil.multMatrixf(matrixP, m, matrixP); - modified |= DIRTY_PROJECTION ; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { FloatUtil.multMatrixf(matrixTex, m, matrixTex); - modified |= DIRTY_TEXTURE ; + modifiedBits |= MODIFIED_TEXTURE; } } - public void glMultMatrixf(float[] m, int m_offset) { + @Override + public final void glMultMatrixf(float[] m, int m_offset) { if(matrixMode==GL_MODELVIEW) { FloatUtil.multMatrixf(matrixMv, m, m_offset, matrixMv); - modified |= DIRTY_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { FloatUtil.multMatrixf(matrixP, m, m_offset, matrixP); - modified |= DIRTY_PROJECTION ; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { FloatUtil.multMatrixf(matrixTex, m, m_offset, matrixTex); - modified |= DIRTY_TEXTURE ; + modifiedBits |= MODIFIED_TEXTURE; } } + @Override public final void glTranslatef(final float x, final float y, final float z) { // Translation matrix: // 1 0 0 x @@ -500,6 +694,7 @@ public class PMVMatrix implements GLMatrixFunc { glMultMatrixf(matrixTrans, 0); } + @Override public final void glRotatef(final float angdeg, float x, float y, float z) { final float angrad = angdeg * (float) Math.PI / 180.0f; final float c = (float)Math.cos(angrad); @@ -536,6 +731,7 @@ public class PMVMatrix implements GLMatrixFunc { glMultMatrixf(matrixRot, 0); } + @Override public final void glScalef(final float x, final float y, final float z) { // Scale matrix: // x 0 0 0 @@ -549,6 +745,7 @@ public class PMVMatrix implements GLMatrixFunc { glMultMatrixf(matrixScale, 0); } + @Override public final void glOrthof(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { // Ortho matrix: // 2/dx 0 0 tx @@ -572,14 +769,7 @@ public class PMVMatrix implements GLMatrixFunc { glMultMatrixf(matrixOrtho, 0); } - public final void gluPerspective(final float fovy, final float aspect, final float zNear, final float zFar) { - float top=(float)Math.tan(fovy*((float)Math.PI)/360.0f)*zNear; - float bottom=-1.0f*top; - float left=aspect*bottom; - float right=aspect*top; - glFrustumf(left, right, bottom, top, zNear, zFar); - } - + @Override public final void glFrustumf(final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { if(zNear<=0.0f||zFar<0.0f) { throw new GLException("GL_INVALID_VALUE: zNear and zFar must be positive, and zNear>0"); @@ -614,14 +804,33 @@ public class PMVMatrix implements GLMatrixFunc { glMultMatrixf(matrixFrustum, 0); } - public void gluLookAt(float eyex, float eyey, float eyez, + // + // Extra functionality + // + + /** + * {@link #glMultMatrixf(FloatBuffer) Multiply} the {@link #glGetMatrixMode() current matrix} with the perspective/frustum matrix. + */ + public final void gluPerspective(final float fovy, final float aspect, final float zNear, final float zFar) { + float top=(float)Math.tan(fovy*((float)Math.PI)/360.0f)*zNear; + float bottom=-1.0f*top; + float left=aspect*bottom; + float right=aspect*top; + glFrustumf(left, right, bottom, top, zNear, zFar); + } + + /** + * {@link #glMultMatrixf(FloatBuffer) Multiply} and {@link #glTranslatef(float, float, float) translate} the {@link #glGetMatrixMode() current matrix} + * with the eye, object and orientation. + */ + public final void gluLookAt(float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz) { projectFloat.gluLookAt(this, eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz); } /** - * Uses this instance {@link #glGetMvMatrixf()} and {@link #glGetPMatrixf()} + * Map object coordinates to window coordinates. * * @param objx * @param objy @@ -632,7 +841,7 @@ public class PMVMatrix implements GLMatrixFunc { * @param win_pos_offset * @return */ - public boolean gluProject(float objx, float objy, float objz, + public final boolean gluProject(float objx, float objy, float objz, int[] viewport, int viewport_offset, float[] win_pos, int win_pos_offset ) { if(usesBackingArray) { @@ -651,7 +860,7 @@ public class PMVMatrix implements GLMatrixFunc { } /** - * Uses this instance {@link #glGetMvMatrixf()} and {@link #glGetPMatrixf()} + * Map window coordinates to object coordinates. * * @param winx * @param winy @@ -680,11 +889,186 @@ public class PMVMatrix implements GLMatrixFunc { } } - public void gluPickMatrix(float x, float y, + public final void gluPickMatrix(float x, float y, float deltaX, float deltaY, int[] viewport, int viewport_offset) { projectFloat.gluPickMatrix(this, x, y, deltaX, deltaY, viewport, viewport_offset); } + + public StringBuilder toString(StringBuilder sb, String f) { + if(null == sb) { + sb = new StringBuilder(); + } + final boolean mviDirty = 0 != (DIRTY_INVERSE_MODELVIEW & dirtyBits); + final boolean mvitDirty = 0 != (DIRTY_INVERSE_TRANSPOSED_MODELVIEW & dirtyBits); + final boolean mviReq = 0 != (DIRTY_INVERSE_MODELVIEW & requestMask); + final boolean mvitReq = 0 != (DIRTY_INVERSE_TRANSPOSED_MODELVIEW & requestMask); + final boolean modP = 0 != ( MODIFIED_PROJECTION & modifiedBits ); + final boolean modMv = 0 != ( MODIFIED_MODELVIEW & modifiedBits ); + final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); + + sb.append("PMVMatrix[backingArray ").append(this.usesBackingArray()); + sb.append(", modified[P ").append(modP).append(", Mv ").append(modMv).append(", T ").append(modT); + sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq); + sb.append("], Projection").append(Platform.NEWLINE); + matrixToString(sb, f, matrixP); + sb.append(", Modelview").append(Platform.NEWLINE); + matrixToString(sb, f, matrixMv); + sb.append(", Texture").append(Platform.NEWLINE); + matrixToString(sb, f, matrixTex); + if( 0 != ( requestMask & DIRTY_INVERSE_MODELVIEW ) ) { + sb.append(", Inverse Modelview").append(Platform.NEWLINE); + matrixToString(sb, f, matrixMvi); + } + if( 0 != ( requestMask & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) { + sb.append(", Inverse Transposed Modelview").append(Platform.NEWLINE); + matrixToString(sb, f, matrixMvit); + } + sb.append("]"); + return sb; + } + + public String toString() { + return toString(null, "%10.5f").toString(); + } + + /** + * Returns the modified bits due to mutable operations and clears it. + *

    + * A modified bit is set, if the corresponding matrix had been modified by a mutable operation + * since last {@link #update()} or {@link #getModifiedBits()} call. + *

    + * + * @see #MODIFIED_PROJECTION + * @see #MODIFIED_MODELVIEW + * @see #MODIFIED_TEXTURE + */ + public final int getModifiedBits() { + final int r = modifiedBits; + modifiedBits = 0; + return r; + } + + /** + * Returns the dirty bits due to mutable operations. + *

    + * A dirty bit is set , if the corresponding matrix had been modified by a mutable operation + * since last {@link #update()} call. The latter clears the dirty state only if the dirty matrix (Mvi or Mvit) + * has been requested by one of the {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} methods. + *

    + * + * @deprecated Function is exposed for debugging purposes only. + * @see #DIRTY_INVERSE_MODELVIEW + * @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW + * @see #glGetMviMatrixf() + * @see #glGetMvitMatrixf() + * @see #glGetPMvMviMatrixf() + * @see #glGetPMvMvitMatrixf() + */ + public final int getDirtyBits() { + return dirtyBits; + } + + /** + * Returns the request bit mask, which uses bit values equal to the dirty mask. + *

    + * The request bit mask is set by one of the {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} methods. + *

    + * + * @deprecated Function is exposed for debugging purposes only. + * @see #disableMviMvitUpdate() + * @see #DIRTY_INVERSE_MODELVIEW + * @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW + * @see #glGetMviMatrixf() + * @see #glGetMvitMatrixf() + * @see #glGetPMvMviMatrixf() + * @see #glGetPMvMvitMatrixf() + */ + public final int getRequestMask() { + return requestMask; + } + + + /** + * Disable {@link #update()} of the Mvi and Mvit matrix + * after it has been enabled by one of the {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} methods. + *

    + * This cleans the request bit mask used internally. + *

    + *

    + * Function may be useful to disable subsequent Mvi and Mvit updates if no more required. + *

    + * + * @see #glGetMviMatrixf() + * @see #glGetMvitMatrixf() + * @see #glGetPMvMviMatrixf() + * @see #glGetPMvMvitMatrixf() + * @see #getRequestMask() + */ + public final void disableMviMvitUpdate() { + requestMask &= ~DIRTY_ALL; + } + + /** + * Update the derived {@link #glGetMviMatrixf() inverse modelview (Mvi)} + * and {@link #glGetMvitMatrixf() inverse transposed modelview (Mvit)} matrices + * if they are dirty and their usage/update has been requested + * by one of the {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} methods. + *

    + * The Mvi and Mvit matrices are considered dirty, if their corresponding + * {@link #glGetMvMatrixf() Mv matrix} has been modified since their last update. + *

    + *

    + * Method should be called manually in case mutable operations has been called + * and caller operates on already fetched references, i.e. not calling + * {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} etc anymore. + *

    + *

    + * This method clears the modified bits like {@link #getModifiedBits()}, + * which are set by any mutable operation. The modified bits have no impact + * on this method, but the return value. + *

    + * + * @return true if any matrix has been modified since last update call or + * if the derived matrices Mvi and Mvit were updated, otherwise false. + * In other words, method returns true if any matrix used by the caller must be updated, + * e.g. uniforms in a shader program. + * + * @see #getModifiedBits() + * @see #MODIFIED_PROJECTION + * @see #MODIFIED_MODELVIEW + * @see #MODIFIED_TEXTURE + * @see #DIRTY_INVERSE_MODELVIEW + * @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW + * @see #glGetMviMatrixf() + * @see #glGetMvitMatrixf() + * @see #glGetPMvMviMatrixf() + * @see #glGetPMvMvitMatrixf() + * @see #disableMviMvitUpdate() + */ + public final boolean update() { + return updateImpl(true); + } + private final boolean updateImpl(boolean clearModBits) { + final boolean mod = 0 != modifiedBits; + if(clearModBits) { + modifiedBits = 0; + } + + if( 0 == ( dirtyBits & requestMask ) ) { + return mod; // nothing requested which may have been dirty + } + + if(nioBackupArraySupported>=0) { + try { + nioBackupArraySupported = 1; + return setMviMvitNIOBackupArray() || mod; + } catch(UnsupportedOperationException uoe) { + nioBackupArraySupported = -1; + } + } + return setMviMvitNIODirectAccess() || mod; + } // // private @@ -692,27 +1076,18 @@ public class PMVMatrix implements GLMatrixFunc { private int nioBackupArraySupported = 0; // -1 not supported, 0 - TBD, 1 - supported private final String msgCantComputeInverse = "Invalid source Mv matrix, can't compute inverse"; - private final void setMviMvit() { - if( 0 != (usesMviMvit & 1) ) { - if(nioBackupArraySupported>=0) { - try { - setMviMvitNIOBackupArray(); - nioBackupArraySupported = 1; - return; - } catch(UnsupportedOperationException uoe) { - nioBackupArraySupported = -1; - } - } - setMviMvitNIODirectAccess(); - } - } - private final void setMviMvitNIOBackupArray() { + private final boolean setMviMvitNIOBackupArray() { final float[] _matrixMvi = matrixMvi.array(); final int _matrixMviOffset = matrixMvi.position(); - if(!projectFloat.gluInvertMatrixf(matrixMv.array(), matrixMv.position(), _matrixMvi, _matrixMviOffset)) { - throw new GLException(msgCantComputeInverse); + boolean res = false; + if( 0 != ( dirtyBits & DIRTY_INVERSE_MODELVIEW ) ) { // only if dirt; always requested at this point, see update() + if(!projectFloat.gluInvertMatrixf(matrixMv.array(), matrixMv.position(), _matrixMvi, _matrixMviOffset)) { + throw new GLException(msgCantComputeInverse); + } + dirtyBits &= ~DIRTY_INVERSE_MODELVIEW; + res = true; } - if( 0 != (usesMviMvit & 2) ) { + if( 0 != ( requestMask & ( dirtyBits & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty // transpose matrix final float[] _matrixMvit = matrixMvit.array(); final int _matrixMvitOffset = matrixMvit.position(); @@ -721,34 +1096,43 @@ public class PMVMatrix implements GLMatrixFunc { _matrixMvit[_matrixMvitOffset+j+i*4] = _matrixMvi[_matrixMviOffset+i+j*4]; } } - } + dirtyBits &= ~DIRTY_INVERSE_TRANSPOSED_MODELVIEW; + res = true; + } + return res; } - private final void setMviMvitNIODirectAccess() { - if(!projectFloat.gluInvertMatrixf(matrixMv, matrixMvi)) { - throw new GLException(msgCantComputeInverse); + private final boolean setMviMvitNIODirectAccess() { + boolean res = false; + if( 0 != ( dirtyBits & DIRTY_INVERSE_MODELVIEW ) ) { // only if dirt; always requested at this point, see update() + if(!projectFloat.gluInvertMatrixf(matrixMv, matrixMvi)) { + throw new GLException(msgCantComputeInverse); + } + dirtyBits &= ~DIRTY_INVERSE_MODELVIEW; + res = true; } - if( 0 != (usesMviMvit & 2) ) { + if( 0 != ( requestMask & ( dirtyBits & DIRTY_INVERSE_TRANSPOSED_MODELVIEW ) ) ) { // only if requested & dirty // transpose matrix for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { matrixMvit.put(j+i*4, matrixMvi.get(i+j*4)); } } - } + dirtyBits &= ~DIRTY_INVERSE_TRANSPOSED_MODELVIEW; + res = true; + } + return res; } + protected final float[] matrixBufferArray; protected final boolean usesBackingArray; protected Buffer matrixBuffer; protected FloatBuffer matrixIdent, matrixPMvMvit, matrixPMvMvi, matrixPMv, matrixP, matrixTex, matrixMv, matrixMvi, matrixMvit; protected float[] matrixMult, matrixTrans, matrixRot, matrixScale, matrixOrtho, matrixFrustum, vec3f; protected List matrixTStack, matrixPStack, matrixMvStack; protected int matrixMode = GL_MODELVIEW; - protected int modified = 0; - protected int usesMviMvit = 0; // 0 - none, 1 - Mvi, 2 - Mvit, 3 - MviMvit (ofc no Mvit w/o Mvi!) + protected int modifiedBits = MODIFIED_ALL; + protected int dirtyBits = DIRTY_ALL; // contains the dirty bits, i.e. hinting for update operation + protected int requestMask = 0; // may contain the requested dirty bits: DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW protected ProjectFloat projectFloat; - - public static final int DIRTY_MODELVIEW = 1 << 0; - public static final int DIRTY_PROJECTION = 1 << 1; - public static final int DIRTY_TEXTURE = 1 << 2; } diff --git a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java b/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java index a34d490c0..9fee0a2e2 100644 --- a/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java +++ b/src/jogl/classes/javax/media/opengl/fixedfunc/GLMatrixFunc.java @@ -31,69 +31,122 @@ package javax.media.opengl.fixedfunc; import java.nio.*; +import javax.media.opengl.GL; + +/** + * Subset of OpenGL fixed function pipeline's matrix operations. + */ public interface GLMatrixFunc { - public static final int GL_MATRIX_MODE = 0x0BA0; - public static final int GL_MODELVIEW = 0x1700; - public static final int GL_PROJECTION = 0x1701; - // public static final int GL_TEXTURE = 0x1702; // Use GL.GL_TEXTURE due to ambiguous GL usage - public static final int GL_MODELVIEW_MATRIX = 0x0BA6; - public static final int GL_PROJECTION_MATRIX = 0x0BA7; - public static final int GL_TEXTURE_MATRIX = 0x0BA8; - - /** - * glGetFloatv - * @param pname GL_MODELVIEW_MATRIX, GL_PROJECTION_MATRIX or GL_TEXTURE_MATRIX - * @param params the FloatBuffer's position remains unchanged, - * which is the same behavior than the native JOGL GL impl - */ - public void glGetFloatv(int pname, java.nio.FloatBuffer params); - public void glGetFloatv(int pname, float[] params, int params_offset); - /** - * glGetIntegerv - * @param pname GL_MATRIX_MODE - * @param params the FloatBuffer's position remains unchanged - * which is the same behavior than the native JOGL GL impl - */ - public void glGetIntegerv(int pname, IntBuffer params); - public void glGetIntegerv(int pname, int[] params, int params_offset); - - /** - * sets the current matrix - * @param pname GL_MODELVIEW, GL_PROJECTION or GL.GL_TEXTURE - */ - public void glMatrixMode(int mode) ; - - public void glPushMatrix(); - public void glPopMatrix(); - - public void glLoadIdentity() ; - - /** - * glLoadMatrixf - * @param params the FloatBuffer's position remains unchanged, - * which is the same behavior than the native JOGL GL impl - */ - public void glLoadMatrixf(java.nio.FloatBuffer m) ; - public void glLoadMatrixf(float[] m, int m_offset); - - /** - * glMultMatrixf - * @param m the FloatBuffer's position remains unchanged, - * which is the same behavior than the native JOGL GL impl - */ - public void glMultMatrixf(java.nio.FloatBuffer m) ; - public void glMultMatrixf(float[] m, int m_offset); - - public void glTranslatef(float x, float y, float z) ; - - public void glRotatef(float angle, float x, float y, float z); - - public void glScalef(float x, float y, float z) ; - - public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) ; - - public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar); + public static final int GL_MATRIX_MODE = 0x0BA0; + /** Matrix mode modelview */ + public static final int GL_MODELVIEW = 0x1700; + /** Matrix mode projection */ + public static final int GL_PROJECTION = 0x1701; + // public static final int GL_TEXTURE = 0x1702; // Use GL.GL_TEXTURE due to ambiguous GL usage + /** Matrix access name for modelview */ + public static final int GL_MODELVIEW_MATRIX = 0x0BA6; + /** Matrix access name for projection */ + public static final int GL_PROJECTION_MATRIX = 0x0BA7; + /** Matrix access name for texture */ + public static final int GL_TEXTURE_MATRIX = 0x0BA8; + + /** + * Copy the named matrix into the given storage. + * @param pname {@link #GL_MODELVIEW_MATRIX}, {@link #GL_PROJECTION_MATRIX} or {@link #GL_TEXTURE_MATRIX} + * @param params the FloatBuffer's position remains unchanged, + * which is the same behavior than the native JOGL GL impl + */ + public void glGetFloatv(int pname, java.nio.FloatBuffer params); + + /** + * Copy the named matrix to the given storage at offset. + * @param pname {@link #GL_MODELVIEW_MATRIX}, {@link #GL_PROJECTION_MATRIX} or {@link #GL_TEXTURE_MATRIX} + * @param params storage + * @param params_offset storage offset + */ + public void glGetFloatv(int pname, float[] params, int params_offset); + + /** + * glGetIntegerv + * @param pname {@link #GL_MATRIX_MODE} to receive the current matrix mode + * @param params the FloatBuffer's position remains unchanged + * which is the same behavior than the native JOGL GL impl + */ + public void glGetIntegerv(int pname, IntBuffer params); + public void glGetIntegerv(int pname, int[] params, int params_offset); + + /** + * Sets the current matrix mode. + * @param mode {@link #GL_MODELVIEW}, {@link #GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE}. + */ + public void glMatrixMode(int mode) ; + + /** + * Push the current matrix to it's stack, while preserving it's values. + *

    + * There exist one stack per matrix mode, i.e. {@link #GL_MODELVIEW}, {@link #GL_PROJECTION} and {@link GL#GL_TEXTURE GL_TEXTURE}. + *

    + */ + public void glPushMatrix(); + + /** + * Pop the current matrix from it's stack. + * @see #glPushMatrix() + */ + public void glPopMatrix(); + + /** + * Load the current matrix with the identity matrix + */ + public void glLoadIdentity() ; + + /** + * Load the current matrix w/ the provided one. + * @param params the FloatBuffer's position remains unchanged, + * which is the same behavior than the native JOGL GL impl + */ + public void glLoadMatrixf(java.nio.FloatBuffer m) ; + /** + * Load the current matrix w/ the provided one. + */ + public void glLoadMatrixf(float[] m, int m_offset); + + /** + * Multiply the current matrix + * @param m the FloatBuffer's position remains unchanged, + * which is the same behavior than the native JOGL GL impl + */ + public void glMultMatrixf(java.nio.FloatBuffer m) ; + /** + * Multiply the current matrix + */ + public void glMultMatrixf(float[] m, int m_offset); + + /** + * Translate the current matrix. + */ + public void glTranslatef(float x, float y, float z) ; + + /** + * Rotate the current matrix. + */ + public void glRotatef(float angle, float x, float y, float z); + + /** + * Scale the current matrix. + */ + public void glScalef(float x, float y, float z) ; + + /** + * {@link #glMultMatrixf(FloatBuffer) Multiply} the current matrix with the orthogonal matrix. + */ + public void glOrthof(float left, float right, float bottom, float top, float zNear, float zFar) ; + + /** + * {@link #glMultMatrixf(FloatBuffer) Multiply} the current matrix with the frustum matrix. + */ + public void glFrustumf(float left, float right, float bottom, float top, float zNear, float zFar); } diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java index ce8405f74..b1ba1f89c 100644 --- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java +++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java @@ -458,7 +458,7 @@ public class ProjectFloat { } /** - * Method gluProject + * Map object coordinates to window coordinates. * * @param objx * @param objy @@ -506,6 +506,9 @@ public class ProjectFloat { return true; } + /** + * Map object coordinates to window coordinates. + */ public boolean gluProject(float objx, float objy, float objz, FloatBuffer modelMatrix, FloatBuffer projMatrix, @@ -543,7 +546,7 @@ public class ProjectFloat { } /** - * Method gluProject + * Map object coordinates to window coordinates. * * @param objx * @param objy @@ -595,7 +598,7 @@ public class ProjectFloat { /** - * Method gluUnproject + * Map window coordinates to object coordinates. * * @param winx * @param winy @@ -651,6 +654,20 @@ public class ProjectFloat { } + /** + * Map window coordinates to object coordinates. + * + * @param winx + * @param winy + * @param winz + * @param modelMatrix + * @param projMatrix + * @param viewport + * @param viewport_offset + * @param obj_pos + * @param obj_pos_offset + * @return + */ public boolean gluUnProject(float winx, float winy, float winz, FloatBuffer modelMatrix, FloatBuffer projMatrix, @@ -695,7 +712,7 @@ public class ProjectFloat { } /** - * Method gluUnproject + * Map window coordinates to object coordinates. * * @param winx * @param winy @@ -754,7 +771,7 @@ public class ProjectFloat { /** - * Method gluUnproject4 + * Map window coordinates to object coordinates. * * @param winx * @param winy @@ -819,7 +836,7 @@ public class ProjectFloat { } /** - * Method gluUnproject4 + * Map window coordinates to object coordinates. * * @param winx * @param winy diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java new file mode 100644 index 000000000..6c16cfcc1 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java @@ -0,0 +1,378 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.nio.FloatBuffer; + +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.os.Platform; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.PMVMatrix; + +public class TestPMVMatrix01NEWT extends UITestCase { + + static final float epsilon = 0.00001f; + // Translated xyz 123 - Normal - In column major order ! + static FloatBuffer translated123N = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 2.0f, 3.0f, 1.0f } ); + + // Translated xyz 123 - Inverse - In column major order ! + static FloatBuffer translated123I = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + -1.0f, -2.0f, -3.0f, 1.0f } ); + + // Translated xyz 123 - Inverse and Transposed - In column major order ! + static FloatBuffer translated123IT = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, -1.0f, + 0.0f, 1.0f, 0.0f, -2.0f, + 0.0f, 0.0f, 1.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f } ); + + /** + * Test using traditional access workflow, i.e. 1) operation 2) get-matrix references + *

    + * The Mvi and Mvit dirty-bits and request-mask will be validated. + *

    + */ + @SuppressWarnings("deprecation") + @Test + public void test01MviUpdateTraditionalAccess() { + FloatBuffer p, mv, mvi, mvit; + boolean b; + final PMVMatrix pmv = new PMVMatrix(true); + // System.err.println("P0: "+pmv.toString()); + + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + + // + // Action #0 + // + final FloatBuffer ident; + { + pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmv.glLoadIdentity(); + ident = pmv.glGetPMatrixf(); + + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + } + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits()); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + + // + // Action #1 + // + pmv.glTranslatef(1f, 2f, 3f); // all dirty ! + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits()); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + // System.err.println("P1: "+pmv.toString()); + + b = pmv.update(); // will not clean dirty bits, since no request has been made -> false + Assert.assertEquals("Update has been perfomed, but non requested", false, b); + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + // System.err.println("P2: "+pmv.toString()); + + // + // Get + // + p = pmv.glGetPMatrixf(); + MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); + mv = pmv.glGetMvMatrixf(); + MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString(), translated123N, mv, epsilon); + mvi = pmv.glGetMviMatrixf(); + MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString(), translated123I, mvi, epsilon); + Assert.assertEquals("Remaining dirty bits not Mvit, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getDirtyBits()); + Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask()); + // System.err.println("P3: "+pmv.toString()); + + mvit = pmv.glGetMvitMatrixf(); + MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); + Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + // System.err.println("P4: "+pmv.toString()); + + // + // Action #2 + // + pmv.glLoadIdentity(); // all dirty + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits()); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); + MiscUtils.assertFloatBufferEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon); + MiscUtils.assertFloatBufferNotEqual("Mvi already identity w/o update, "+pmv.toString(), ident, mvi, epsilon); + MiscUtils.assertFloatBufferNotEqual("Mvit already identity w/o update, "+pmv.toString(), ident, mvit, epsilon); + MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); + MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); + + b = pmv.update(); // will clean dirty bits, since request has been made -> true + Assert.assertEquals("Update has not been perfomed, but requested", true, b); + Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + MiscUtils.assertFloatBufferEquals("Mvi not identity after update, "+pmv.toString(), ident, mvi, epsilon); + MiscUtils.assertFloatBufferEquals("Mvit not identity after update, "+pmv.toString(), ident, mvit, epsilon); + } + + /** + * Test using shader access workflow, i.e. 1) get-matrix references 2) operations + *

    + * The Mvi and Mvit dirty-bits and request-mask will be validated. + *

    + */ + @SuppressWarnings("deprecation") + @Test + public void test02MviUpdateShaderAccess() { + final FloatBuffer p, mv, mvi, mvit; + boolean b; + final PMVMatrix pmv = new PMVMatrix(true); + // System.err.println("P0: "+pmv.toString()); + + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + + // + // Action #0 + // + final FloatBuffer ident; + { + pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmv.glLoadIdentity(); + ident = pmv.glGetPMatrixf(); + + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + } + // System.err.println("P0: "+pmv.toString()); + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits()); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + // System.err.println("P1: "+pmv.toString()); + + // + // Get + // + p = pmv.glGetPMatrixf(); + MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); + mv = pmv.glGetMvMatrixf(); + MiscUtils.assertFloatBufferEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon); + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + + mvi = pmv.glGetMviMatrixf(); + MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvi, epsilon); + Assert.assertEquals("Remaining dirty bits not Mvit, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getDirtyBits()); + Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask()); + + mvit = pmv.glGetMvitMatrixf(); + MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvit, epsilon); + Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + + // + // Action #1 + // + pmv.glTranslatef(1f, 2f, 3f); // all dirty ! + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits()); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString()+pmv.toString(), ident, p, epsilon); + MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString()+pmv.toString(), translated123N, mv, epsilon); + MiscUtils.assertFloatBufferNotEqual("Mvi already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); + MiscUtils.assertFloatBufferNotEqual("Mvit already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); + MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString()+pmv.toString(), ident, mvi, epsilon); + MiscUtils.assertFloatBufferEquals("Mvit not identity, "+pmv.toString()+pmv.toString(), ident, mvit, epsilon); + + b = pmv.update(); // will clean dirty bits, since all requests has been made -> true + Assert.assertEquals("Update has not been perfomed, but requested", true, b); + Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); + MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); + // System.err.println("P2: "+pmv.toString()); + } + + @SuppressWarnings("unused") + @Test + public void test03MvTranslate() { + final FloatBuffer pmvMv, pmvMvi, pmvMvit; + { + final PMVMatrix pmv = new PMVMatrix(true); + pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmv.glLoadIdentity(); + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + pmv.glTranslatef(5f, 6f, 7f); + + pmvMv = pmv.glGetMvMatrixf(); + pmvMvi = pmv.glGetMviMatrixf(); + pmvMvit = pmv.glGetMvitMatrixf(); + } + + final FloatBuffer glMv = FloatBuffer.allocate(16); + { + GL2ES1 gl = dc.glc.getGL().getGL2ES1(); + gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + gl.glLoadIdentity(); + gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + gl.glLoadIdentity(); + gl.glTranslatef(5f, 6f, 7f); + + gl.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, glMv); + } + // System.err.println(PMVMatrix.matrixToString(null, "%10.5f", glMv, pmvMv).toString()); + + MiscUtils.assertFloatBufferEquals("Arrays not equal, expected"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", glMv).toString()+ + ", actual"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMv).toString(), + glMv, pmvMv, epsilon); + + // System.err.println("pmvMvi: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvi)); + // System.err.println("pmvMvit: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvit)); + } + + @SuppressWarnings("unused") + @Test + public void test04MvTranslateRotate() { + final FloatBuffer pmvMv, pmvMvi, pmvMvit; + { + final PMVMatrix pmv = new PMVMatrix(true); + pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmv.glLoadIdentity(); + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + pmv.glTranslatef(5f, 6f, 7f); + pmv.glRotatef(90f, 1f, 0f, 0f); + + pmvMv = pmv.glGetMvMatrixf(); + pmvMvi = pmv.glGetMviMatrixf(); + pmvMvit = pmv.glGetMvitMatrixf(); + } + + final FloatBuffer glMv = FloatBuffer.allocate(16); + { + GL2ES1 gl = dc.glc.getGL().getGL2ES1(); + gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + gl.glLoadIdentity(); + gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + gl.glLoadIdentity(); + gl.glTranslatef(5f, 6f, 7f); + gl.glRotatef(90f, 1f, 0f, 0f); + + gl.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, glMv); + } + // System.err.println(PMVMatrix.matrixToString(null, "%10.5f", glMv, pmvMv).toString()); + + MiscUtils.assertFloatBufferEquals("Arrays not equal, expected"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", glMv).toString()+ + ", actual"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMv).toString(), + glMv, pmvMv, epsilon); + + // System.err.println("pmvMvi: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvi)); + // System.err.println("pmvMvit: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvit)); + } + + static DrawableContext dc; + + @BeforeClass + public static void setup() throws Throwable { + try { + dc = createOffscreenDrawableAndCurrentFFPContext(); + } catch (Throwable t) { + setTestSupported(false); + throw t; + } + } + + @AfterClass + public static void cleanup() { + destroyDrawableContext(dc); + } + + static class DrawableContext { + DrawableContext(GLDrawable d, GLContext glc) { + this.d = d; + this.glc = glc; + } + GLDrawable d; + GLContext glc; + } + + private static DrawableContext createOffscreenDrawableAndCurrentFFPContext() throws Throwable { + GLProfile glp = GLProfile.getMaxFixedFunc(true); + GLCapabilities glCaps = new GLCapabilities(glp); + glCaps.setOnscreen(false); + glCaps.setPBuffer(true); + GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); + GLDrawable d = factory.createOffscreenDrawable(null, glCaps, null, 64, 64); + d.setRealized(true); + GLContext glc = null; + try { + glc = d.createContext(null); + Assert.assertTrue("Context could not be made current", GLContext.CONTEXT_NOT_CURRENT < glc.makeCurrent()); + return new DrawableContext(d, glc); + } catch (Throwable t) { + if(null != glc) { + glc.destroy(); + } + d.setRealized(false); + throw t; + } + } + + private static void destroyDrawableContext(DrawableContext dc) { + if(null != dc.glc) { + dc.glc.destroy(); + dc.glc = null; + } + if(null != dc.d) { + dc.d.setRealized(false); + dc.d = null; + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPMVMatrix01NEWT.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java index 82485ea1a..bb526e350 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java @@ -26,7 +26,6 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLUniformData; - import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; @@ -89,8 +88,11 @@ public class GearsObjectES2 extends GearsObject { pmvMatrix.glPushMatrix(); pmvMatrix.glTranslatef(x, y, 0f); pmvMatrix.glRotatef(angle, 0f, 0f, 1f); - pmvMatrix.update(); - st.uniform(gl, pmvMatrixUniform); + if( pmvMatrix.update() ) { + st.uniform(gl, pmvMatrixUniform); + } else { + throw new InternalError("PMVMatrix.update() returns false after mutable operations"); + } colorUniform.setData(color); st.uniform(gl, colorUniform); diff --git a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java index 9cbeabb85..c230f0aa1 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java +++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.util; import java.lang.reflect.*; +import java.nio.FloatBuffer; public class MiscUtils { public static int atoi(String str, int def) { @@ -50,6 +51,53 @@ public class MiscUtils { return def; } + public static void assertFloatBufferEquals(String errmsg, FloatBuffer expected, FloatBuffer actual, float delta) { + if(null == expected && null == actual) { + return; + } + String msg = null != errmsg ? errmsg + " " : ""; + if(null == expected) { + throw new AssertionError(msg+"; Expected is null, but actual not: "+actual); + } + if(null == actual) { + throw new AssertionError(msg+"; Actual is null, but expected not: "+expected); + } + if(expected.remaining() != actual.remaining()) { + throw new AssertionError(msg+"; Expected has "+expected.remaining()+" remaining, but actual has "+actual.remaining()); + } + final int a0 = expected.position(); + final int b0 = actual.position(); + for(int i=0; i delta ) { + throw new AssertionError(msg+"; Expected @ ["+a0+"+"+i+"] has "+ai+", but actual @ ["+b0+"+"+i+"] has "+bi+", it's delta "+daibi+" > "+delta); + } + } + } + + public static void assertFloatBufferNotEqual(String errmsg, FloatBuffer expected, FloatBuffer actual, float delta) { + if(null == expected || null == actual) { + return; + } + if(expected.remaining() != actual.remaining()) { + return; + } + String msg = null != errmsg ? errmsg + " " : ""; + final int a0 = expected.position(); + final int b0 = actual.position(); + for(int i=0; i delta ) { + return; + } + } + throw new AssertionError(msg+"; Expected and actual are equal."); + } + public static boolean setFieldIfExists(Object instance, String fieldName, Object value) { try { Field f = instance.getClass().getField(fieldName); -- cgit v1.2.3 From 7278244e321dd1d533223e9b6d668a6acd82bc76 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Oct 2012 03:57:25 +0200 Subject: Footprint Stats ; Fix Bug 624 - Compile and generate android JAR files (jogl-all-android.jar, jogl-test-android.jar) if android SDK JAR files are available. ; Split up atomic jogl-util.jar Compile and generate android JAR files (jogl-all-android.jar, jogl-test-android.jar) if android SDK JAR files are available. - See gluegen commit 55b4552aef7882c358d545d020d6f12c958ed8ed Also split up atomic jogl-util.jar - jogl-util.jar -> jogl-util.jar + jogl-util-graph.jar Footprint Stats: This demonstrates small footprint of a minimum configuration, all numbers in kilobytes (du -ksc). NOTE the min size of ~ 1MB! JOGL ALL 220 kB gluegen-rt.jar 5180 kB jogl-all.jar 4 kB libgluegen-rt.so.gz 4 kB libnativewindow_awt.so.gz 12 kB libnativewindow_x11.so.gz 100 kB libjogl_desktop.so.gz 20 kB libnewt.so.gz 5540 kB total JOGL Min X11 Min egl es1 es2 220 kB gluegen-rt.jar 296 kB atomic/jogl-core.jar 156 kB atomic/jogl-glmobile.jar 284 kB atomic/jogl-util.jar 76 kB atomic/nativewindow-core.jar 120 kB atomic/newt-core.jar 28 kB atomic/nativewindow-os-x11.jar 28 kB atomic/newt-driver-x11.jar 4 kB libgluegen-rt.so.gz 48 kB libjogl_mobile.so.gz 12 kB libnativewindow_x11.so.gz 20 kB libnewt.so.gz 1292 kB total JOGL Android - mobile egl es1 es2 224 kB gluegen-rt-android.jar 3020 kB jogl-all-android.jar 4 kB libgluegen-rt.so.gz 48 kB libjogl_mobile.so.gz 3296 kB total JOGL Min Android/Mobile Min egl es1 es2 224 kB gluegen-rt-android.jar 296 kB atomic/jogl-core.jar 156 kB atomic/jogl-glmobile.jar 8 kB atomic/jogl-os-android.jar 284 kB atomic/jogl-util.jar 76 kB atomic/nativewindow-core.jar 120 kB atomic/newt-core.jar 28 kB atomic/newt-driver-android.jar 4 kB libgluegen-rt.so.gz 48 kB libjogl_mobile.so.gz 1244 kB total --- make/build-common.xml | 7 ++++++- make/build-jogl.xml | 14 +++++++++----- make/build-newt.xml | 4 ++-- make/build-test.xml | 6 ++++-- make/build.xml | 2 +- make/scripts/lstjars.sh | 24 ++++++++++++++++++------ make/scripts/tests.sh | 4 ++-- 7 files changed, 42 insertions(+), 19 deletions(-) (limited to 'make/scripts') diff --git a/make/build-common.xml b/make/build-common.xml index 2cb776e74..a718ae09a 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -278,6 +278,7 @@ + @@ -301,6 +302,7 @@ + @@ -322,6 +324,7 @@ + @@ -339,6 +342,7 @@ + @@ -350,6 +354,7 @@ + @@ -357,7 +362,7 @@ + ${jogl-core.jar} ${jogl-glutess.jar} ${jogl-glumipmap.jar} ${jogl-glu-gldesktop.jar} ${jogl-os-x11.jar} ${jogl-os-win.jar} ${jogl-os-osx.jar} ${jogl-gldesktop.jar} ${jogl-gldesktop-dbg.jar} ${jogl-glmobile.jar} ${jogl-glmobile-dbg.jar} ${jogl-omx.jar} ${jogl-util.jar} ${jogl-util-graph.jar} ${jogl-util-gldesktop.jar} ${jogl-util-awt.jar} ${jogl-util-fixedfuncemu.jar} ${jogl-sdk.jar} --> diff --git a/make/build-jogl.xml b/make/build-jogl.xml index a72d6c77c..85abf10b7 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1054,7 +1054,7 @@ - + + includes="${jogl-util.jar} ${jogl-util-graph.jar} ${jogl-util-fixedfuncemu.jar}" /> @@ -1581,7 +1581,7 @@ - + @@ -1662,10 +1662,14 @@ + includes="${java.part.util} ${java.part.util.glsl}" + excludes="${java.part.util.awt} ${java.part.util.gldesktop} ${java.part.util.fixedfuncemu} ${java.part.util.graph}"/> + + + diff --git a/make/build-newt.xml b/make/build-newt.xml index 1b59433d7..7b9a51863 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -237,7 +237,7 @@ - + - + diff --git a/make/build-test.xml b/make/build-test.xml index d1175f3dd..3402b4d9d 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -96,7 +96,7 @@ - + + + - + diff --git a/make/build.xml b/make/build.xml index 23aa218b4..44adf805f 100644 --- a/make/build.xml +++ b/make/build.xml @@ -98,7 +98,7 @@ - + diff --git a/make/scripts/lstjars.sh b/make/scripts/lstjars.sh index 82e378e20..5763e419f 100755 --- a/make/scripts/lstjars.sh +++ b/make/scripts/lstjars.sh @@ -1,5 +1,7 @@ #! /bin/sh +#set -x + THISDIR=$(pwd) BUILDDIR=$1 @@ -21,7 +23,7 @@ fi function report() { #ls -1 -s --block-size=1024 $* #ls -1 -s --block-size=1024 $* | awk ' BEGIN { sum=0 ; } { sum=sum+$1; } END { printf("%d Total\n", sum); }' - du -ksc $* + du -ksc $* | awk ' { printf("%5d kB %s\n", $1, $2); } ' } OSS=x11 @@ -35,15 +37,23 @@ function listdeployment() { echo echo JOGL ALL - report gluegen-rt.$JAR_SUFFIX jogl.all.$JAR_SUFFIX libgluegen-rt.so.gz libnativewindow_awt.so.gz libnativewindow_x11.so.gz libjogl_desktop.so.gz libnewt.so.gz + report gluegen-rt.$JAR_SUFFIX jogl-all.$JAR_SUFFIX libgluegen-rt.so.gz libnativewindow_awt.so.gz libnativewindow_x11.so.gz libjogl_desktop.so.gz libnewt.so.gz echo echo JOGL ALL no AWT - report gluegen-rt.$JAR_SUFFIX jogl.all-noawt.$JAR_SUFFIX libgluegen-rt.so.gz libnativewindow_x11.so.gz libjogl_desktop.so.gz libnewt.so.gz + report gluegen-rt.$JAR_SUFFIX jogl-all-noawt.$JAR_SUFFIX libgluegen-rt.so.gz libnativewindow_x11.so.gz libjogl_desktop.so.gz libnewt.so.gz + echo + + echo JOGL Min X11 Min egl es1 es2 + report gluegen-rt.$JAR_SUFFIX atomic/jogl-core.$JAR_SUFFIX atomic/jogl-glmobile.$JAR_SUFFIX atomic/jogl-util.$JAR_SUFFIX atomic/nativewindow-core.$JAR_SUFFIX atomic/newt-core.$JAR_SUFFIX atomic/nativewindow-os-x11.$JAR_SUFFIX atomic/newt-driver-x11.$JAR_SUFFIX libgluegen-rt.so.gz libjogl_mobile.so.gz libnativewindow_x11.so.gz libnewt.so.gz echo echo JOGL Android - mobile egl es1 es2 - report gluegen-rt.$JAR_SUFFIX jogl.all-android.$JAR_SUFFIX libgluegen-rt.so.gz libjogl_mobile.so.gz + report gluegen-rt-android.$JAR_SUFFIX jogl-all-android.$JAR_SUFFIX libgluegen-rt.so.gz libjogl_mobile.so.gz + echo + + echo JOGL Min Android/Mobile Min egl es1 es2 + report gluegen-rt-android.$JAR_SUFFIX atomic/jogl-core.$JAR_SUFFIX atomic/jogl-glmobile.$JAR_SUFFIX atomic/jogl-os-android.$JAR_SUFFIX atomic/jogl-util.$JAR_SUFFIX atomic/nativewindow-core.$JAR_SUFFIX atomic/newt-core.$JAR_SUFFIX atomic/newt-driver-android.$JAR_SUFFIX libgluegen-rt.so.gz libjogl_mobile.so.gz echo } @@ -52,6 +62,7 @@ mkdir -p $STATDIR cp -a $BUILDDIR/lib/*.so $STATDIR cp -a $BUILDDIR/jar/* $STATDIR cp -a $BUILDDIR_GLUEGEN/gluegen-rt.jar $STATDIR +cp -a $BUILDDIR_GLUEGEN/gluegen-rt-android.jar $STATDIR cp -a $BUILDDIR_GLUEGEN/obj/libgluegen-rt.so $STATDIR cd $STATDIR @@ -84,13 +95,14 @@ sort atomic/jogl*.lst | uniq -d cat atomic/*.lst | sort -u > allparts.lst mv nope/*jar . -cat jogl.all.lst gluegen-rt.lst | sort -u > allall.lst +cat jogl-all.lst gluegen-rt.lst | sort -u > allall.lst echo all vs allparts delta echo diff -Nur allparts.lst allall.lst -mv nope/* . +mv nope/*.jar . +#mv nope/atomic/*.jar atomic/ listdeployment jar diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f650ffc19..5d12475a5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -238,10 +238,10 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* -- cgit v1.2.3 From 84632ca22d112da45b807299d2b1f5e4f4107695 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Oct 2012 03:27:44 +0200 Subject: Fix SWTEDTUtil bug, where it simply doesn't start by an implicit 'invoke()' - No NewtCanvasSWT resize, nor input event delivery. A new EDTUtil instance is not started automatically. Since SWTEDTUtil is attached to the DisplayImpl later in time, i.e. after it's native creation, there is no EDTUtil.invoke(..) call which started it. The not started SWTEDTUtil could not deliver any events. Fix: Start it explicitly - add API doc comment in Display.setEDTUtil(..) --- make/scripts/tests.sh | 6 +++--- src/newt/classes/com/jogamp/newt/Display.java | 8 ++++++++ src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 9 +++++++-- 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5d12475a5..affa130fb 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -104,7 +104,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow" - #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" + D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -238,7 +238,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -355,7 +355,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # newt.awt (testawt) diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 391bccf3d..de1d58068 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -164,6 +164,14 @@ public abstract class Display { * If newEDTUtil is not null and equals the previous one, * null is returned and no change is being made. *

    + *

    + * Note that newEDTUtil will not be started if not done so already, + * to do so you may issue {@link EDTUtil#invoke(boolean, Runnable) invoke} + * on the new EDTUtil: + *

    +     *          newEDTUtil.invoke(true, new Runnable() { public void run() { } } );
    +     * 
    + *

    */ public abstract EDTUtil setEDTUtil(EDTUtil newEDTUtil); diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 36bc3f28f..74611706a 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -325,8 +325,13 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { final int w = clientArea.width; final int h = clientArea.height; - final Display newtDisplay = newtChild.getScreen().getDisplay(); - newtDisplay.setEDTUtil(new SWTEDTUtil(newtDisplay, getDisplay())); + // set SWT EDT and start it + { + final Display newtDisplay = newtChild.getScreen().getDisplay(); + final EDTUtil edt = new SWTEDTUtil(newtDisplay, getDisplay()); + newtDisplay.setEDTUtil(edt); + edt.invoke(true, new Runnable() { public void run() { } } ); // start EDT + } newtChild.setSize(w, h); newtChild.reparentWindow(nativeWindow); -- cgit v1.2.3 From a3cb6bb14f410f67fccf5ccd4cd7ecc66f448389 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Oct 2012 06:31:08 +0200 Subject: Fix Bug 572 (2nd time): GLCanvas.validateGLDrawable() @ display() and reshape() ; GLCanvas.reshape() only if drawble valid ; GLCanvas.validateGLDrawable() also test isDisplayable() ; Fix size validation ; resizeOffscreenDrawable(..) don't validate 'safe' size 1x1 - GLCanvas.validateGLDrawable() @ display() and reshape() To help users using GLCanvas w/ having a realized GLCanvas/Drawable, validateGLDrawable() is also called at reshape(). This shall ensure a valid drawable after even a non AWT-EDT issued first setVisible(). - GLCanvas.reshape() only if drawble valid Otherwise offscreen reshape attempts would happen even on unrealized drawable, which is not necessary. - GLCanvas.validateGLDrawable() also test isDisplayable() To make sure the native peer is valid, also test isDisplayable() - Fix size validation Since we have experienced odd size like 0 x -41 test each component, i.e. 0 < width && 0 < height. This is done through all JOGL/NEWT components. - resizeOffscreenDrawable(..) don't validate 'safe' size 1x1 In case method is called w/ odd size, i.e. 0 x -41, the safe size 1x1 is used. However, we cannot validate this size. Dump WARNING if odd size is detected. --- make/scripts/tests.sh | 6 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 2 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 60 +++++----- .../classes/jogamp/opengl/GLDrawableHelper.java | 11 +- src/newt/classes/com/jogamp/newt/Window.java | 6 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 2 +- src/newt/classes/jogamp/newt/WindowImpl.java | 8 +- .../opengl/test/junit/jogl/awt/TestBug572AWT.java | 127 +++++++++++++++++++++ .../jogamp/opengl/test/junit/util/UITestCase.java | 11 +- 9 files changed, 188 insertions(+), 45 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index affa130fb..ed2e238fb 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -137,7 +137,7 @@ function jrun() { #D_ARGS="-Xprof" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Dnativewindow.debug=all" - #D_ARGS="-Djogl.debug.GLCanvas" + D_ARGS="-Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Dnativewindow.debug.NativeWindow" @@ -317,6 +317,7 @@ function testawtswt() { #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* @@ -355,7 +356,8 @@ function testawtswt() { #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # # newt.awt (testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 06114431a..24971ff97 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -389,7 +389,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { return false; } final Rectangle nClientArea = clientArea; - if(0 == nClientArea.width * nClientArea.height) { + if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 335322be9..4bdae7135 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -440,6 +440,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void display() { + if( !validateGLDrawable() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet"); + } + return; // not yet available .. + } Threading.invoke(true, displayOnEDTAction, getTreeLock()); awtWindowClosingProtocol.addClosingListenerOneShot(); } @@ -489,7 +495,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing (int) ((getHeight() + bounds.getHeight()) / 2)); return; } - if( ! this.helper.isAnimatorAnimating() ) { + if( ! this.helper.isExternalAnimatorAnimating() ) { display(); } } @@ -570,30 +576,29 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( _drawable.isRealized() ) { return true; } - if (!Beans.isDesignTime() && - 0 < _drawable.getWidth() * _drawable.getHeight() ) { - // make sure drawable realization happens on AWT EDT, due to AWTTree lock - AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); - if( _drawable.isRealized() ) { - sendReshape=true; // ensure a reshape is being send .. - if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); - Thread.dumpStack(); + final RecursiveLock _lock = lock; + _lock.lock(); + try { + if (!Beans.isDesignTime() && isDisplayable() && + 0 < _drawable.getWidth() && 0 < _drawable.getHeight() ) { + // make sure drawable realization happens on AWT EDT, due to AWTTree lock + AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction); + if( _drawable.isRealized() ) { + sendReshape=true; // ensure a reshape is being send .. + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString()); + Thread.dumpStack(); + } + return true; } - return true; } + } finally { + _lock.unlock(); } } return false; } - private Runnable setRealizedOnEDTAction = new Runnable() { - @Override - public void run() { - final GLDrawable _drawable = drawable; - if ( null != _drawable && 0 < _drawable.getWidth() * _drawable.getHeight() ) { - _drawable.setRealized(true); - } - } }; + private Runnable setRealizedOnEDTAction = new Runnable() { public void run() { drawable.setRealized(true); } }; /**

    Overridden to track when this component is removed from a container. Subclasses which override this method must call @@ -640,11 +645,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape super.reshape(x, y, width, height); - GLDrawableImpl _drawable = drawable; - if( null != _drawable ) { - if(DEBUG) { - System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); - } + if(DEBUG) { + System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+width+"x"+height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); + // Thread.dumpStack(); + } + if( validateGLDrawable() ) { + final GLDrawableImpl _drawable = drawable; if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { final RecursiveLock _lock = lock; _lock.lock(); @@ -984,11 +990,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final RecursiveLock _lock = lock; _lock.lock(); try { - if( validateGLDrawable() ) { - helper.invokeGL(drawable, context, displayAction, initAction); - } else if(DEBUG) { - System.err.println(getThreadName()+": Info: GLCanvas display - skipped GL render, drawable not valid yet"); - } + helper.invokeGL(drawable, context, displayAction, initAction); } finally { _lock.unlock(); } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 13c387231..d4ff9702c 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -241,9 +241,14 @@ public class GLDrawableHelper { if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { throw new NativeWindowException("Could not lock surface of drawable: "+drawable); } + boolean validateSize = true; try { - if(0>=newWidth) { newWidth = 1; } - if(0>=newHeight) { newHeight = 1; } + if(DEBUG && ( 0>=newWidth || 0>=newHeight) ) { + System.err.println("WARNING: Odd size detected: "+newWidth+"x"+newHeight+", using safe size 1x1. Drawable "+drawable); + Thread.dumpStack(); + } + if(0>=newWidth) { newWidth = 1; validateSize=false; } + if(0>=newHeight) { newHeight = 1; validateSize=false; } // propagate new size if(ns instanceof ProxySurface) { final ProxySurface ps = (ProxySurface) ns; @@ -266,7 +271,7 @@ public class GLDrawableHelper { } finally { ns.unlockSurface(); } - if(drawable.getWidth() != newWidth || drawable.getHeight() != newHeight) { + if( validateSize && ( drawable.getWidth() != newWidth || drawable.getHeight() != newHeight ) ) { throw new InternalError("Incomplete resize operation: expected "+newWidth+"x"+newHeight+", has: "+drawable); } return drawable; diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 78e2abc6e..cc42465f1 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -129,7 +129,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { *

          * if ( 0 == windowHandle && visible ) {
          *   this.visible = visible;
    -     *   if( 0 < width*height ) {
    +     *   if( 0 < width && 0 < height ) {
          *     createNative();
          *   }
          * } else if ( this.visible != visible ) {
    @@ -171,9 +171,9 @@ public interface Window extends NativeWindow, WindowClosingProtocol {
          * 

    * Zero size semantics are respected, see {@link #setVisible(boolean)}:
    *

    -     * if ( 0 != windowHandle && 0 ≥ width*height && visible ) {
    +     * if ( visible && 0 != windowHandle && ( 0 ≥ width || 0 ≥ height ) ) {
          *   setVisible(false);
    -     * } else if ( 0 == windowHandle && 0 < width*height && visible ) {
    +     * } else if ( visible && 0 == windowHandle && 0 < width && 0 < height ) {
          *   setVisible(true);
          * } else {
          *   // as expected ..
    diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
    index 74611706a..525225804 100644
    --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
    +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java
    @@ -157,7 +157,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol {
             }
             updateSizeCheck();
             final Rectangle nClientArea = clientArea;
    -        if(0 == nClientArea.width * nClientArea.height) {
    +        if(0 >= nClientArea.width || 0 >= nClientArea.height) {        
                 return false;
             }
             
    diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
    index 79770189b..c94ce286b 100644
    --- a/src/newt/classes/jogamp/newt/WindowImpl.java
    +++ b/src/newt/classes/jogamp/newt/WindowImpl.java
    @@ -797,10 +797,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
                             System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible);
                         }
                         int visibleAction; // 0 nop, 1 invisible, 2 visible (create)
    -                    if ( isNativeValid() && 0>=width*height && visible ) {
    +                    if ( visible && isNativeValid() && ( 0 >= width || 0 >= height ) ) {
                             visibleAction=1; // invisible
                             defineSize(0, 0);
    -                    } else if ( !isNativeValid() && 00);
    +        Assert.assertTrue("GLCanvas didn't display", snapshooter.getDisplayCount()>0);
    +        
    +        // After initial 'setVisible(true)' all AWT manipulation needs to be done
    +        // via the AWT EDT, according to the AWT spec.
    +
    +        Runnable cleanup = new Runnable() {
    +            public void run() {
    +                System.err.println("cleaning up...");
    +                window.setVisible(false);
    +                try {
    +                    window.removeAll();
    +                } catch (Throwable t) {
    +                    Assume.assumeNoException(t);
    +                    t.printStackTrace();
    +                }
    +                window.dispose();
    +            }
    +
    +        };
    +
    +        // AWT / Swing on EDT..
    +        SwingUtilities.invokeAndWait(cleanup);
    +    }
    +
    +    @Test
    +    public void test01() throws InterruptedException, InvocationTargetException {
    +        runTestGL();
    +    }
    +
    +    public static void main(String args[]) {
    +        org.junit.runner.JUnitCore.main(TestBug572AWT.class.getName());
    +    }
    +}
    diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
    index c31555969..741014502 100644
    --- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
    +++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java
    @@ -206,6 +206,7 @@ public abstract class UITestCase {
         public class SnapshotGLEventListener implements GLEventListener {
             private final GLReadBufferUtil screenshot;
             private volatile boolean makeShot = false;
    +        private volatile boolean makeShotAlways = false;
             private volatile int displayCount=0;
             private volatile int reshapeCount=0;
             public SnapshotGLEventListener(GLReadBufferUtil screenshot) {
    @@ -214,13 +215,16 @@ public abstract class UITestCase {
             public SnapshotGLEventListener() {
                 this.screenshot = new GLReadBufferUtil(false, false);
             }
    +        public int getDisplayCount() { return displayCount; }
    +        public int getReshapeCount() { return reshapeCount; }
     
             public void init(GLAutoDrawable drawable) {}
             public void dispose(GLAutoDrawable drawable) {}
             public void display(GLAutoDrawable drawable) {
                 final GL gl = drawable.getGL();
    -            System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": "+drawable.getWidth()+"x"+drawable.getHeight()+", makeShot "+makeShot);
    -            if(makeShot) {
    +            final boolean _makeShot = makeShot || makeShotAlways;
    +            System.err.println(Thread.currentThread().getName()+": ** display: "+displayCount+": "+drawable.getWidth()+"x"+drawable.getHeight()+", makeShot "+_makeShot);
    +            if(_makeShot) {
                     makeShot=false;
                     snapshot(displayCount, null, gl, screenshot, TextureIO.PNG, null);
                 }
    @@ -233,6 +237,9 @@ public abstract class UITestCase {
             public void setMakeSnapshot() {
                 makeShot=true;
             }
    +        public void setMakeSnapshotAlways(boolean v) {
    +            makeShotAlways=v;
    +        }
         };
         
     }
    -- 
    cgit v1.2.3
    
    
    From f541f349bdb99fbb4a00f1b81c9d4a60545cdb7e Mon Sep 17 00:00:00 2001
    From: Sven Gothel 
    Date: Fri, 5 Oct 2012 17:44:25 +0200
    Subject: Fix FBObject DEPTH_STENCIL renderbuffer usage
    
    If DEPTH_STENCIL was selected, recreate destroyed the common buffer when stencil was being 'reset'.
    
    To unify and simplify code, if DEPTH_STENCIL stencil == depth reference.
    ---
     make/scripts/tests.sh                            | 10 +--
     src/jogl/classes/com/jogamp/opengl/FBObject.java | 84 +++++++++++++-----------
     2 files changed, 51 insertions(+), 43 deletions(-)
    
    (limited to 'make/scripts')
    
    diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
    index ed2e238fb..8b554b923 100755
    --- a/make/scripts/tests.sh
    +++ b/make/scripts/tests.sh
    @@ -66,7 +66,7 @@ function jrun() {
         #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker"
         #D_ARGS="-Djogl.debug.FBObject"
         #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode"
    -    #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window"
    +    #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window"
         #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject"
         #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing"
         #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
    @@ -104,7 +104,7 @@ function jrun() {
         #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile"
         #D_ARGS="-Djogl.debug.GLProfile"
         #D_ARGS="-Dnativewindow.debug.NativeWindow"
    -    D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT"
    +    #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT"
         #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext"
         #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util"
         #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all"
    @@ -137,7 +137,7 @@ function jrun() {
         #D_ARGS="-Xprof"
         #D_ARGS="-Djogl.debug.Animator"
         #D_ARGS="-Dnativewindow.debug=all"
    -    D_ARGS="-Djogl.debug.GLCanvas"
    +    #D_ARGS="-Djogl.debug.GLCanvas"
         #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync"
         #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock"
         #D_ARGS="-Dnativewindow.debug.NativeWindow"
    @@ -263,7 +263,7 @@ function testawtswt() {
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $*
    -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $*
    +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $*
     
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $*
    @@ -317,7 +317,7 @@ function testawtswt() {
     #testawt javax.media.opengl.awt.GLCanvas $*
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $*
    -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $*
    +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $*
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $*
    diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java
    index 4745b5e01..922225207 100644
    --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java
    +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java
    @@ -317,7 +317,7 @@ public class FBObject {
             private int samples;
             
             /**
    -         * @param type allowed types are {@link Type#DEPTH}, {@link Type#STENCIL} or {@link Type#COLOR}
    +         * @param type allowed types are {@link Type#DEPTH_STENCIL} {@link Type#DEPTH}, {@link Type#STENCIL} or {@link Type#COLOR}
              * @param iFormat
              * @param samples
              * @param width
    @@ -335,6 +335,7 @@ public class FBObject {
             
             private static Type validateType(Type type) {
                 switch(type) {
    +                case DEPTH_STENCIL:
                     case DEPTH:
                     case STENCIL:
                     case COLOR:
    @@ -395,7 +396,7 @@ public class FBObject {
                         throw new GLException("GL Error "+toHexString(glerr)+" while creating "+this);
                     }
                     if(DEBUG) {
    -                    System.err.println("Attachment.init: "+this);
    +                    System.err.println("Attachment.init.X: "+this);
                     }
                 }
                 return init;
    @@ -405,10 +406,10 @@ public class FBObject {
             public void free(GL gl) {
                 final int[] name = new int[] { getName() };
                 if( 0 != name[0] ) {
    -                gl.glDeleteRenderbuffers(1, name, 0);
                     if(DEBUG) {
    -                    System.err.println("Attachment.free: "+this);
    +                    System.err.println("Attachment.free.0: "+this);
                     }
    +                gl.glDeleteRenderbuffers(1, name, 0);
                     setName(0);
                 }
             }
    @@ -509,7 +510,7 @@ public class FBObject {
                         throw new GLException("GL Error "+toHexString(glerr)+" while creating (pre TexImage2D "+preTexImage2D+") "+this);
                     }
                     if(DEBUG) {
    -                    System.err.println("Attachment.init: "+this);
    +                    System.err.println("Attachment.init.X: "+this);
                     }
                 }
                 return init;
    @@ -519,10 +520,10 @@ public class FBObject {
             public void free(GL gl) {
                 final int[] name = new int[] { getName() };
                 if( 0 != name[0] ) {
    -                gl.glDeleteTextures(1, name, 0);
                     if(DEBUG) {
    -                    System.err.println("Attachment.free: "+this);
    +                    System.err.println("Attachment.free.0: "+this);
                     }
    +                gl.glDeleteTextures(1, name, 0);
                     setName(0);
                 }
             }
    @@ -1082,7 +1083,7 @@ public class FBObject {
                     
                 case 0:                
                 default:
    -                System.out.println("Framebuffer " + fbName + " is incomplete: status = " + toHexString(vStatus) + 
    +                System.err.println("Framebuffer " + fbName + " is incomplete, status = " + toHexString(vStatus) + 
                             " : " + getStatusString(vStatus));
                     return false;
             }
    @@ -1307,7 +1308,7 @@ public class FBObject {
                 }
             }
             if(DEBUG) {
    -            System.err.println("FBObject.attachColorbuffer: [attachmentPoint "+attachmentPoint+", colbuf "+colbuf+"]: "+this);
    +            System.err.println("FBObject.attachColorbuffer.X: [attachmentPoint "+attachmentPoint+", colbuf "+colbuf+"]: "+this);
             }
             return colbuf;
         }
    @@ -1462,20 +1463,17 @@ public class FBObject {
                 stencil.initialize(gl);
             } else if( Attachment.Type.DEPTH_STENCIL == atype ) {
                 if(null == depth) {
    -                depth = new RenderAttachment(Type.DEPTH, internalFormat, samples, width, height, 0);
    +                if(null != stencil) {
    +                    throw new InternalError("XXX: DEPTH_STENCIL, depth was null, stencil not: "+this.toString());
    +                }
    +                depth = new RenderAttachment(Type.DEPTH_STENCIL, internalFormat, samples, width, height, 0);
                 } else {
                     depth.setSize(width, height);
                     depth.setSamples(samples);
                 }
                 depth.initialize(gl);
    -            if(null == stencil) {
    -                stencil = new RenderAttachment(Type.STENCIL, internalFormat, samples, width, height, depth.getName());
    -            } else {
    -                stencil.setName(depth.getName());
    -                stencil.setSize(width, height);
    -                stencil.setSamples(samples);
    -            }
    -            stencil.initialize(gl);
    +            // DEPTH_STENCIL shares buffer w/ depth and stencil
    +            stencil = depth;
             }
     
             // Attach the buffer
    @@ -1492,12 +1490,12 @@ public class FBObject {
                 updateStatus(gl);
                 if( !isStatusValid() ) {
                     detachRenderbuffer(gl, atype, true);
    -                throw new GLException("renderbuffer attachment failed: "+this.getStatusString());
    +                throw new GLException("renderbuffer [attachmentType "+atype+", iformat "+toHexString(internalFormat)+"] failed: "+this.getStatusString()+": "+this.toString());
                 }
             }
     
             if(DEBUG) {
    -            System.err.println("FBObject.attachRenderbuffer: [attachmentType "+atype+"]: "+this);
    +            System.err.println("FBObject.attachRenderbuffer.X: [attachmentType "+atype+", iformat "+toHexString(internalFormat)+"]: "+this);
             }        
         }
         
    @@ -1519,7 +1517,7 @@ public class FBObject {
                 throw new IllegalArgumentException("ColorAttachment at "+attachmentPoint+", not attached, "+this);            
             }
             if(DEBUG) {
    -            System.err.println("FBObject.detachColorbuffer: [attachmentPoint "+attachmentPoint+", dispose "+dispose+"]: "+res+", "+this);
    +            System.err.println("FBObject.detachColorbuffer.X: [attachmentPoint "+attachmentPoint+", dispose "+dispose+"]: "+res+", "+this);
             }
             return res;
         }
    @@ -1633,15 +1631,20 @@ public class FBObject {
             bind(gl);        
             detachRenderbufferImpl(gl, atype, dispose ? DetachAction.DISPOSE : DetachAction.NONE);
             if(DEBUG) {
    -            System.err.println("FBObject.detachRenderbuffer: [attachmentType "+atype+", dispose "+dispose+"]: "+this);
    +            System.err.println("FBObject.detachRenderbuffer.X: [attachmentType "+atype+", dispose "+dispose+"]: "+this);
             }        
         }
         
         public final boolean isDepthStencilPackedFormat() {
             final boolean res = null != depth && null != stencil &&
                                 depth.format == stencil.format ;
    -        if(res && depth.getName() != stencil.getName() ) {
    -            throw new InternalError("depth/stencil packed format not sharing: depth "+depth+", stencil "+stencil);
    +        if(res) {
    +            if(depth.getName() != stencil.getName() ) {
    +                throw new InternalError("depth/stencil packed format not sharing: depth "+depth+", stencil "+stencil);
    +            }
    +            if(depth != stencil) {
    +                throw new InternalError("depth/stencil packed format not a shared reference: depth "+depth+", stencil "+stencil);
    +            }
             }
             return res;
         }
    @@ -1660,7 +1663,7 @@ public class FBObject {
             } 
             final boolean packed = isDepthStencilPackedFormat();
             if( packed ) {
    -            // packed
    +            // Note: DEPTH_STENCIL shares buffer w/ depth and stencil
                 atype = Attachment.Type.DEPTH_STENCIL;
             }
             switch ( atype ) {
    @@ -1709,6 +1712,9 @@ public class FBObject {
                         final int format = depth.format;
                         if(0 != depth.getName()) {
                             gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, 0);
    +                        if(packed) {
    +                            gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0);
    +                        }
                             switch(detachAction) {
                                 case DISPOSE:
                                 case RECREATE:
    @@ -1718,12 +1724,15 @@ public class FBObject {
                             }
                         }
                         if(DetachAction.RECREATE == detachAction) {
    -                        attachRenderbufferImpl2(gl, Attachment.Type.DEPTH, format);
    -                    } else if(!packed) {
    +                        attachRenderbufferImpl2(gl, packed ? Attachment.Type.DEPTH_STENCIL : Attachment.Type.DEPTH, format);
    +                    } else {
                             depth = null;
    +                        if(packed) {
    +                            stencil = null;
    +                        }
                         }                    
                     }
    -                if( null != stencil ) {
    +                if( !packed && null != stencil ) {
                         final int format = stencil.format;
                         if(0 != stencil.getName()) {
                             gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0);
    @@ -1736,13 +1745,7 @@ public class FBObject {
                             }
                         }
                         if(DetachAction.RECREATE == detachAction) {
    -                        if(packed) {
    -                            // packed
    -                            attachRenderbufferImpl2(gl, Attachment.Type.DEPTH_STENCIL, format);
    -                        } else {
    -                            // single
    -                            attachRenderbufferImpl2(gl, Attachment.Type.STENCIL, format);
    -                        }
    +                        attachRenderbufferImpl2(gl, Attachment.Type.STENCIL, format);
                         } else {
                             stencil = null;
                         }
    @@ -1753,13 +1756,18 @@ public class FBObject {
         }
             
         private final void freeAllRenderbufferImpl(GL gl) throws IllegalArgumentException {
    +        // Note: DEPTH_STENCIL shares buffer w/ depth and stencil
    +        final boolean packed = isDepthStencilPackedFormat();
             if( null != depth ) { 
                 if(0 != depth.getName()) {
                     gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_DEPTH_ATTACHMENT, GL.GL_RENDERBUFFER, 0);
    +                if(packed) {
    +                    gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0);                    
    +                }
                     depth.free(gl);
                 }
             }
    -        if( null != stencil ) {
    +        if( !packed && null != stencil ) {
                 if(0 != stencil.getName()) {
                     gl.glFramebufferRenderbuffer(GL.GL_FRAMEBUFFER, GL.GL_STENCIL_ATTACHMENT, GL.GL_RENDERBUFFER, 0);
                     stencil.free(gl);                    
    @@ -1821,7 +1829,7 @@ public class FBObject {
                 }
             }
             if(DEBUG) {
    -            System.err.println("FBObject.detachAllTexturebuffer: "+this);
    +            System.err.println("FBObject.detachAllTexturebuffer.X: "+this);
             }
         }
         
    @@ -1870,7 +1878,7 @@ public class FBObject {
                 ignoreStatus = false;
             }
             if(DEBUG) {
    -            System.err.println("FBObject.detachAll: [resetNonColorbuffer "+detachNonColorbuffer+", recreate "+recreate+"]: "+this);
    +            System.err.println("FBObject.detachAll.X: [resetNonColorbuffer "+detachNonColorbuffer+", recreate "+recreate+"]: "+this);
             }
         }
             
    -- 
    cgit v1.2.3
    
    
    From bb8454d735c511c6d80798d3b6258e1ed355579e Mon Sep 17 00:00:00 2001
    From: Sven Gothel 
    Date: Fri, 5 Oct 2012 19:11:26 +0200
    Subject: Refine a3cb6bb14f410f67fccf5ccd4cd7ecc66f448389, fix deadlock
     (regression)
    
    The lock being claimed at validateGLDrawable() is 'offthread', i.e. may fight w/ AWT / Animator
    at reshape/display.
    
    Locking is moved 'down' to AWT runnable 'setRealizedOnEDTAction', which also double checks
    the drawable [again].
    ---
     make/scripts/tests.sh                              | 14 ++++++-
     .../classes/javax/media/opengl/awt/GLCanvas.java   | 46 +++++++++++++---------
     2 files changed, 39 insertions(+), 21 deletions(-)
    
    (limited to 'make/scripts')
    
    diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
    index 8b554b923..f76e2b1f8 100755
    --- a/make/scripts/tests.sh
    +++ b/make/scripts/tests.sh
    @@ -73,6 +73,7 @@ function jrun() {
         #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all"
         #D_ARGS="-Djogl.debug=all -Dnewt.debug=all"
         #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration"
    +    #D_ARGS="-Djogl.debug.GLDrawable"
         #D_ARGS="-Djogl.fbo.force.none"
         #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock"
         #D_ARGS="-Djogl.debug=all"
    @@ -259,11 +260,10 @@ function testawtswt() {
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $*
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $*
     
    -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $*
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $*
    -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $*
    +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $*
     
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $*
    @@ -458,6 +458,16 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffsc
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $*
     #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $*
     
    +#linux:
    +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $*
    +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT
    +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT
    +#testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $*
    +testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $*
    +#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $*
    +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $*
    +
    +
     
     $spath/count-edt-start.sh java-run.log
     
    diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
    index 4bdae7135..a5c15dbda 100644
    --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
    +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java
    @@ -576,29 +576,37 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing
             if( _drawable.isRealized() ) {
                 return true;
             }
    -        final RecursiveLock _lock = lock;
    -        _lock.lock();
    -        try {            
    -            if (!Beans.isDesignTime() && isDisplayable() &&
    -                 0 < _drawable.getWidth() && 0 < _drawable.getHeight() ) {
    -                // make sure drawable realization happens on AWT EDT, due to AWTTree lock
    -                AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction);
    -                if( _drawable.isRealized() ) {
    -                    sendReshape=true; // ensure a reshape is being send ..
    -                    if(DEBUG) {
    -                        System.err.println(getThreadName()+": Realized Drawable: "+_drawable.toString());
    -                        Thread.dumpStack();
    -                    }
    -                    return true;
    -                }
    -            }
    -        } finally {
    -            _lock.unlock();
    +        if( Beans.isDesignTime() || !isDisplayable() || 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) {
    +            return false; // early out!
    +        }
    +        // make sure drawable realization happens on AWT EDT, due to AWTTree lock
    +        AWTEDTExecutor.singleton.invoke(getTreeLock(), true, setRealizedOnEDTAction);
    +        final boolean res = _drawable.isRealized();
    +        if(DEBUG) {
    +            System.err.println(getThreadName()+": Realized Drawable: "+res+", "+_drawable.toString());
    +            Thread.dumpStack();
             }
    +        return res;
         }
         return false;
       }
    -  private Runnable setRealizedOnEDTAction = new Runnable() { public void run() { drawable.setRealized(true); } };
    +  private Runnable setRealizedOnEDTAction = new Runnable() { 
    +      public void run() { 
    +          final RecursiveLock _lock = lock;
    +          _lock.lock();
    +          try {            
    +              final GLDrawable _drawable = drawable;
    +              if( null == _drawable || 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) {
    +                  return; 
    +              }
    +              _drawable.setRealized(true);
    +              if( _drawable.isRealized() ) {
    +                  sendReshape=true; // ensure a reshape is being send ..
    +              }
    +          } finally {
    +              _lock.unlock();
    +          }
    +      } };
     
       /** 

    Overridden to track when this component is removed from a container. Subclasses which override this method must call -- cgit v1.2.3 From d3033e42faa909f6c1055f5ba3c7925766a3e583 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 6 Oct 2012 04:57:13 +0200 Subject: Adding unit test for Bug 605 - WORKSFORME, i.e. no unwanted y-flip, so I can just assume it's the SW renderer, flipping. --- make/scripts/tests.sh | 8 +- .../junit/jogl/caps/TestBug605FlippedImageAWT.java | 185 +++++++++++++++++++++ .../jogl/caps/TestBug605FlippedImageNEWT.java | 176 ++++++++++++++++++++ .../jogamp/opengl/test/junit/util/UITestCase.java | 59 ++++--- 4 files changed, 395 insertions(+), 33 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f76e2b1f8..df1f7141f 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -385,6 +385,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* @@ -459,13 +461,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #linux: -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java new file mode 100644 index 000000000..b949bc34d --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java @@ -0,0 +1,185 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.caps; + +import java.io.File; +import java.io.IOException; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.awt.Screenshot; +import com.jogamp.opengl.util.texture.TextureIO; + +import java.awt.image.BufferedImage; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.jogamp.opengl.test.junit.util.UITestCase; + +public class TestBug605FlippedImageAWT extends UITestCase { + class FlippedImageTest implements GLEventListener { + public void display(GLAutoDrawable drawable) { + GL2 gl = drawable.getGL().getGL2(); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT | GL2.GL_ACCUM_BUFFER_BIT ); + + gl.glMatrixMode(GL2.GL_PROJECTION); + gl.glLoadIdentity(); + gl.glMatrixMode(GL2.GL_MODELVIEW); + gl.glLoadIdentity(); + + // red below + gl.glColor3f(1, 0, 0); + gl.glRectf(-1, -1, 1, 0); + + // green above + gl.glColor3f(0, 1, 0); + gl.glRectf(-1, 0, 1, 1); + gl.glFinish(); + + final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); + if(caps.getAccumGreenBits() > 0) { + gl.glAccum(GL2.GL_ACCUM, 1.0f); + gl.glAccum(GL2.GL_RETURN, 1.0f); + } + gl.glFinish(); + + final int width = drawable.getWidth(); + final int height = drawable.getHeight(); + + final String fname = getSnapshotFilename(0, null, caps, width, height, false, TextureIO.PNG, null); + try { + Screenshot.writeToFile(new File(fname), width, height, false); + } catch (GLException e) { + throw e; + } catch (IOException e) { + throw new GLException(e); + } + testFlipped(width, height); + } + + public void init(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + System.err.println("GL_RENDERER: "+gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: "+gl.glGetString(GL.GL_VERSION)); + } + public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {} + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} + public void dispose(GLAutoDrawable drawable) {} + } + + static final int green = 0x0000ff00; // above + static final int red = 0x00ff0000; // below + + private void testFlipped(int width, int height) { + // Default origin 0/0 is lower left corner, so is the memory layout + // However AWT origin 0/0 is upper left corner + final BufferedImage image = Screenshot.readToBufferedImage(width, height); + + final int below = image.getRGB(0, height-1) & 0x00ffffff; + System.err.println("below: 0x"+Integer.toHexString(below)); + + final int above = image.getRGB(0, 0) & 0x00ffffff; + System.err.println("above: 0x"+Integer.toHexString(above)); + + if (above == green && below == red) { + System.out.println("Image right side up"); + } else if (above == red && below == green) { + Assert.assertTrue("Image is flipped", false); + } else { + Assert.assertTrue("Error in test", false); + } + } + + private void test(GLCapabilitiesImmutable caps) { + + final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); + final FlippedImageTest tglel = new FlippedImageTest(); + glad.addGLEventListener(tglel); + + // 1 frame incl. snapshot to memory & file + glad.display(); + System.err.println("XXX "+glad.getChosenGLCapabilities()); + System.err.println("XXX "+glad.getContext().getGLVersion()); + + glad.destroy(); + } + + @Test + public void test01DefaultFBO() { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setFBO(true); + test(caps); + } + + @Test + public void test01StencilFBO() { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setStencilBits(8); + caps.setFBO(true); + test(caps); + } + + @Test + public void test01DefaultPBuffer() { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setPBuffer(true); + test(caps); + } + + @Test + public void test01AccumStencilPBuffer() { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setAccumRedBits(16); + caps.setAccumGreenBits(16); + caps.setAccumBlueBits(16); + caps.setStencilBits(8); + caps.setPBuffer(true); + test(caps); + } + + public static void main(String[] args) { + org.junit.runner.JUnitCore.main(TestBug605FlippedImageAWT.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java new file mode 100644 index 000000000..837d94cb3 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java @@ -0,0 +1,176 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.caps; + +import java.nio.ByteBuffer; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.GLReadBufferUtil; + +public class TestBug605FlippedImageNEWT extends UITestCase { + static class FlippedImageTest implements GLEventListener { + public void display(GLAutoDrawable drawable) { + GL2 gl = drawable.getGL().getGL2(); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT | GL2.GL_ACCUM_BUFFER_BIT ); + + gl.glMatrixMode(GL2.GL_PROJECTION); + gl.glLoadIdentity(); + gl.glMatrixMode(GL2.GL_MODELVIEW); + gl.glLoadIdentity(); + + // red below + gl.glColor3f(1, 0, 0); + gl.glRectf(-1, -1, 1, 0); + + // green above + gl.glColor3f(0, 1, 0); + gl.glRectf(-1, 0, 1, 1); + gl.glFinish(); + + final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); + if(caps.getAccumGreenBits() > 0) { + gl.glAccum(GL2.GL_ACCUM, 1.0f); + gl.glAccum(GL2.GL_RETURN, 1.0f); + } + gl.glFinish(); + } + + public void init(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + System.err.println("GL_RENDERER: "+gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: "+gl.glGetString(GL.GL_VERSION)); + } + public void reshape(GLAutoDrawable glDrawable, int x, int y, int w, int h) {} + public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {} + public void dispose(GLAutoDrawable drawable) {} + } + + static final int green = 0x0000ff00; // above + static final int red = 0x00ff0000; // below + + private int getRGB(ByteBuffer bb, int o) { + return ( (int)bb.get(o+0) & 0x000000ff ) << 16 | + ( (int)bb.get(o+1) & 0x000000ff ) << 8 | + ( (int)bb.get(o+2) & 0x000000ff ); + } + + private void testFlipped(ByteBuffer bb, int width, int height, int comp) { + // Default origin 0/0 is lower left corner, so is the memory layout + + // x=0, y=0: RGB -> _RGB [high-byte .. low-byte] + final int below = getRGB(bb, 0); + System.err.println("below: 0x"+Integer.toHexString(below)); + + // x=0, y=height-1: RGB -> _RGB [high-byte .. low-byte] + final int above= getRGB(bb, ( height - 1 ) * ( width * comp )); + System.err.println("above: 0x"+Integer.toHexString(above)); + + if (above == green && below == red) { + System.out.println("Image right side up"); + } else if (above == red && below == green) { + Assert.assertTrue("Image is flipped", false); + } else { + Assert.assertTrue("Error in test", false); + } + } + + private void test(GLCapabilitiesImmutable caps) { + final GLReadBufferUtil rbu = new GLReadBufferUtil(false, false); + final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); + final FlippedImageTest tglel = new FlippedImageTest(); + glad.addGLEventListener(tglel); + final SnapshotGLEventListener snap = new SnapshotGLEventListener(rbu); + glad.addGLEventListener(snap); + snap.setMakeSnapshotAlways(true); + + // 1 frame incl. snapshot to memory & file + glad.display(); + System.err.println("XXX "+glad.getChosenGLCapabilities()); + System.err.println("XXX "+glad.getContext().getGLVersion()); + testFlipped(rbu.getPixelBuffer(), glad.getWidth(), glad.getHeight(), 3); + + glad.destroy(); + } + + @Test + public void test01DefaultFBO() { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setFBO(true); + test(caps); + } + + @Test + public void test01StencilFBO() { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setStencilBits(8); + caps.setFBO(true); + test(caps); + } + + @Test + public void test01DefaultPBuffer() { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setPBuffer(true); + test(caps); + } + + @Test + public void test01AccumStencilPBuffer() { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setAccumRedBits(16); + caps.setAccumGreenBits(16); + caps.setAccumBlueBits(16); + caps.setStencilBits(8); + caps.setPBuffer(true); + test(caps); + } + + public static void main(String[] args) { + org.junit.runner.JUnitCore.main(TestBug605FlippedImageNEWT.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java index b48f027bb..bd9cd0966 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java +++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java @@ -142,25 +142,8 @@ public abstract class UITestCase { } static final String unsupportedTestMsg = "Test not supported on this platform."; - - /** - * Takes a snapshot of the drawable's current front framebuffer. Example filenames: - *

    -     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenFBOSglBuf____-n0001-msaa0-GLES2_-sw-fbobject-Bdbl-Frgb__Irgb_-S00_default-0400x0300.png
    -     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenPbufferDblBuf-n0003-msaa0-GLES2_-sw-pbuffer_-Bdbl-Frgb__Irgb_-S00_default-0200x0150.png
    -     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testGL2OffScreenPbufferSglBuf-n0003-msaa0-GL2___-hw-pbuffer_-Bone-Frgb__Irgb_-S00_default-0200x0150.png
    -     * 
    - * @param sn sequential number - * @param postSNDetail optional detail to be added to the filename after sn - * @param gl the current GL context object. It's read drawable is being used as the pixel source and to gather some details which will end up in the filename. - * @param readBufferUtil the {@link GLReadBufferUtil} to be used to read the pixels for the screenshot. - * @param fileSuffix Optional file suffix without a dot defining the file type, i.e. "png". - * If null the "png" as defined in {@link TextureIO#PNG} is being used. - * @param destPath Optional platform dependent file path. It shall use {@link File#separatorChar} as is directory separator. - * It shall not end with a directory separator, {@link File#separatorChar}. - * If null the current working directory is being used. - */ - public void snapshot(int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) { + + public String getSnapshotFilename(int sn, String postSNDetail, GLCapabilitiesImmutable caps, int width, int height, boolean sinkHasAlpha, String fileSuffix, String destPath) { if(null == fileSuffix) { fileSuffix = TextureIO.PNG; } @@ -168,8 +151,6 @@ public abstract class UITestCase { final String simpleTestName = this.getSimpleTestName("."); final String filenameBaseName; { - final GLDrawable drawable = gl.getContext().getGLReadDrawable(); - final GLCapabilitiesImmutable caps = drawable.getChosenGLCapabilities(); final String accel = caps.getHardwareAccelerated() ? "hw" : "sw" ; final String scrnm; if(caps.isOnscreen()) { @@ -184,7 +165,7 @@ public abstract class UITestCase { scrnm = "unknown_"; } final String dblb = caps.getDoubleBuffered() ? "dbl" : "one"; - final String F_pfmt = readBufferUtil.hasAlpha() ? "rgba" : "rgb_"; + final String F_pfmt = sinkHasAlpha ? "rgba" : "rgb_"; final String pfmt = caps.getAlphaBits() > 0 ? "rgba" : "rgb_"; final int depthBits = caps.getDepthBits(); final int stencilBits = caps.getStencilBits(); @@ -193,12 +174,36 @@ public abstract class UITestCase { postSNDetail = null != postSNDetail ? "-"+postSNDetail : ""; filenameBaseName = String.format("%-"+maxSimpleTestNameLen+"s-n%04d%s-%-6s-%s-%s-B%s-F%s_I%s-D%02d-St%02d-Sa%02d_%s-%04dx%04d.%s", - simpleTestName, sn, postSNDetail, drawable.getGLProfile().getName(), accel, + simpleTestName, sn, postSNDetail, caps.getGLProfile().getName(), accel, scrnm, dblb, F_pfmt, pfmt, depthBits, stencilBits, samples, aaext, - drawable.getWidth(), drawable.getHeight(), fileSuffix).replace(' ', '_'); + width, height, fileSuffix).replace(' ', '_'); } - final String filename = null != destPath ? destPath + File.separator + filenameBaseName : filenameBaseName; - System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename+", maxTestNameLen "+maxSimpleTestNameLen+", <"+simpleTestName+">"); + return null != destPath ? destPath + File.separator + filenameBaseName : filenameBaseName; + } + + /** + * Takes a snapshot of the drawable's current front framebuffer. Example filenames: + *
    +     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenFBOSglBuf____-n0001-msaa0-GLES2_-sw-fbobject-Bdbl-Frgb__Irgb_-D24-St00-Sa00_default-0400x0300.png
    +     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenPbufferDblBuf-n0003-msaa0-GLES2_-sw-pbuffer_-Bdbl-Frgb__Irgb_-D24-St00-Sa00_default-0200x0150.png
    +     * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testGL2OffScreenPbufferSglBuf-n0003-msaa0-GL2___-hw-pbuffer_-Bone-Frgb__Irgb_-D24-St00-Sa00_default-0200x0150.png
    +     * 
    + * @param sn sequential number + * @param postSNDetail optional detail to be added to the filename after sn + * @param gl the current GL context object. It's read drawable is being used as the pixel source and to gather some details which will end up in the filename. + * @param readBufferUtil the {@link GLReadBufferUtil} to be used to read the pixels for the screenshot. + * @param fileSuffix Optional file suffix without a dot defining the file type, i.e. "png". + * If null the "png" as defined in {@link TextureIO#PNG} is being used. + * @param destPath Optional platform dependent file path. It shall use {@link File#separatorChar} as is directory separator. + * It shall not end with a directory separator, {@link File#separatorChar}. + * If null the current working directory is being used. + */ + public void snapshot(int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) { + final GLDrawable drawable = gl.getContext().getGLReadDrawable(); + final String filename = getSnapshotFilename(sn, postSNDetail, + drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), + readBufferUtil.hasAlpha(), fileSuffix, destPath); + System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename); gl.glFinish(); // just make sure rendering finished .. if(readBufferUtil.readPixels(gl, false)) { readBufferUtil.write(new File(filename)); @@ -219,7 +224,7 @@ public abstract class UITestCase { } public int getDisplayCount() { return displayCount; } public int getReshapeCount() { return reshapeCount; } - + public GLReadBufferUtil getGLReadBufferUtil() { return screenshot; } public void init(GLAutoDrawable drawable) {} public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { -- cgit v1.2.3 From 630d43be7a8cccf28632fc1f7542bb484382d775 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 6 Oct 2012 07:19:37 +0200 Subject: Fix Bug 617 (part2): Workaround buggy GPU driver where FBO reattachment of Colorbuffer w/ diff size leads to GL_FRAMEBUFFER_UNSUPPORTED. This occured at least on: - OS X 10.6.8 - GL_RENDERER NVIDIA GeForce 7300 GT OpenGL Engine - GL_VERSION 2.1 NVIDIA-1.6.36 Remedy is to catch the exception @ GLFBODrawableImpl.reset(..) and switch over to fallback 'reset' method: FBO reattachment -> FBO complete recreation Of course, the FBO recreation is noticable slower, but at least it seems to work on the offending system. Not tested on the offending system, but manually provoked GLException on FBOObject to trigger fallback, which is working here. --- make/scripts/tests.sh | 4 +- src/jogl/classes/com/jogamp/opengl/FBObject.java | 5 +- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 65 ++++++++++++++-------- 3 files changed, 49 insertions(+), 25 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index df1f7141f..b0a8c78a2 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -269,7 +269,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* @@ -386,7 +386,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java index 922225207..f40d44ff5 100644 --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java @@ -1869,7 +1869,10 @@ public class FBObject { detachRenderbufferImpl(gl, Attachment.Type.DEPTH_STENCIL, recreate ? DetachAction.RECREATE : DetachAction.DISPOSE); } if(ignoreStatus) { // post validate - updateStatus(gl); + /* if(true) { + throw new GLException("Simulating bug 617, reset FBO failure"); + } */ + updateStatus(gl); if(!isStatusValid()) { throw new GLException("detachAllImpl failed "+getStatusString()+", "+this); } diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index f14c7e5e7..a516060fb 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -11,11 +11,13 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLFBODrawable; +import com.jogamp.common.util.VersionUtil; import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.FBObject.Attachment; import com.jogamp.opengl.FBObject.Colorbuffer; import com.jogamp.opengl.FBObject.TextureAttachment; +import com.jogamp.opengl.JoglVersion; /** * {@link FBObject} offscreen GLDrawable implementation, i.e. {@link GLFBODrawable}. @@ -43,12 +45,15 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { private boolean initialized; private int texUnit; private int samples; + private boolean fboResetQuirk; private FBObject[] fbos; private int fboIBack; // points to GL_BACK buffer private int fboIFront; // points to GL_FRONT buffer private int pendingFBOReset = -1; private boolean fboBound; + + private static volatile boolean resetQuirkInfoDumped = false; private static final int bufferCount = 2; // number of FBOs for double buffering. TODO: Possible to configure! // private DoubleBufferMode doubleBufferMode; // TODO: Add or remove TEXTURE (only) DoubleBufferMode support @@ -75,6 +80,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { this.origParentChosenCaps = (GLCapabilitiesImmutable) getChosenGLCapabilities(); // just to avoid null, will be reset at initialize(..) this.texUnit = textureUnit; this.samples = fboCaps.getNumSamples(); + fboResetQuirk = false; // default .. // TODO: Add or remove TEXTURE (only) DoubleBufferMode support // this.doubleBufferMode = ( samples > 0 || fboCaps.getDoubleBuffered() ) ? DoubleBufferMode.FBO : DoubleBufferMode.NONE ; @@ -151,31 +157,46 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { swapBufferContext = sbc; } - static final boolean FBOResetQuirk = false; - private final void reset(GL gl, int idx, int width, int height, int samples, int alphaBits, int stencilBits) { - if( !FBOResetQuirk ) { - fbos[idx].reset(gl, width, height, samples, false); - if(fbos[idx].getNumSamples() != samples) { - throw new InternalError("Sample number mismatch: "+samples+", fbos["+idx+"] "+fbos[idx]); + if( !fboResetQuirk ) { + try { + fbos[idx].reset(gl, width, height, samples, false); + if(fbos[idx].getNumSamples() != samples) { + throw new InternalError("Sample number mismatch: "+samples+", fbos["+idx+"] "+fbos[idx]); + } + return; + } catch (GLException e) { + if(DEBUG) { + e.printStackTrace(); + } + if(!resetQuirkInfoDumped) { // dump info only once + resetQuirkInfoDumped = true; + System.err.println("GLFBODrawable: Reset failed: "+e.getMessage()); + System.err.println("GLFBODrawable: Enabling FBOResetQuirk, due to previous GLException. "+this.toString()); + System.err.println(VersionUtil.getPlatformInfo()); + System.err.println(JoglVersion.getInstance()); + System.err.println(JoglVersion.getGLInfo(gl, null)); + } + fboResetQuirk = true; + // 'fallthrough' intended } + } + // resetQuirk fallback + fbos[idx].destroy(gl); + fbos[idx] = new FBObject(); + fbos[idx].reset(gl, getWidth(), getHeight(), samples, false); + if(fbos[idx].getNumSamples() != samples) { + throw new InternalError("Sample number mismatch: "+samples+", fbos["+idx+"] "+fbos[idx]); + } + if(samples > 0) { + fbos[idx].attachColorbuffer(gl, 0, alphaBits>0); } else { - fbos[idx].destroy(gl); - fbos[idx] = new FBObject(); - fbos[idx].reset(gl, getWidth(), getHeight(), samples, false); - if(fbos[idx].getNumSamples() != samples) { - throw new InternalError("Sample number mismatch: "+samples+", fbos["+idx+"] "+fbos[idx]); - } - if(samples > 0) { - fbos[idx].attachColorbuffer(gl, 0, alphaBits>0); - } else { - fbos[idx].attachTexture2D(gl, 0, alphaBits>0); - } - if( stencilBits > 0 ) { - fbos[idx].attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24); - } else { - fbos[idx].attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); - } + fbos[idx].attachTexture2D(gl, 0, alphaBits>0); + } + if( stencilBits > 0 ) { + fbos[idx].attachRenderbuffer(gl, Attachment.Type.DEPTH_STENCIL, 24); + } else { + fbos[idx].attachRenderbuffer(gl, Attachment.Type.DEPTH, 24); } } -- cgit v1.2.3 From d10dae464ef9309a92eb9b49323fe1db93c3fc9f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 8 Oct 2012 01:22:30 +0200 Subject: Raise NEWT MouseButton Maximum from 6 -> 16 (API Change) - Button 9 has been reported to be sent by Olamedia - Rearrange the input bit mask in InputEvent (API Change) - Raise the max. button number to 16 --- make/scripts/tests.sh | 6 ++--- .../classes/com/jogamp/newt/event/InputEvent.java | 28 +++++++++++++--------- .../classes/com/jogamp/newt/event/MouseEvent.java | 11 +++++++-- .../jogamp/newt/driver/x11/WindowDriver.java | 4 ++-- src/newt/native/InputEvent.h | 25 +++++++++++-------- 5 files changed, 46 insertions(+), 28 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b0a8c78a2..8b4f7dda4 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -131,7 +131,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window.MouseEvent" + D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window" @@ -239,7 +239,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -269,7 +269,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 148ac5962..0122bda9a 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -43,22 +43,28 @@ public abstract class InputEvent extends NEWTEvent public static final int CTRL_MASK = 1 << 1; public static final int META_MASK = 1 << 2; public static final int ALT_MASK = 1 << 3; - public static final int ALT_GRAPH_MASK = 1 << 5; - public static final int BUTTON1_MASK = 1 << 6; - public static final int BUTTON2_MASK = 1 << 7; - public static final int BUTTON3_MASK = 1 << 8; - public static final int BUTTON4_MASK = 1 << 9; - public static final int BUTTON5_MASK = 1 << 10; - public static final int BUTTON6_MASK = 1 << 11; + public static final int ALT_GRAPH_MASK = 1 << 4; + + public static final int BUTTON1_MASK = 1 << 5; + public static final int BUTTON2_MASK = 1 << 6; + public static final int BUTTON3_MASK = 1 << 7; + public static final int BUTTON4_MASK = 1 << 8; + public static final int BUTTON5_MASK = 1 << 9; + public static final int BUTTON6_MASK = 1 << 10; + public static final int BUTTON7_MASK = 1 << 11; + public static final int BUTTON8_MASK = 1 << 12; + public static final int BUTTON9_MASK = 1 << 13; + + public static final int BUTTONLAST_MASK = 1 << 20; // 16 /** Event is caused by auto-repeat. */ - public static final int AUTOREPEAT_MASK = 1 << 15; + public static final int AUTOREPEAT_MASK = 1 << 29; /** Pointer is confined, see {@link Window#confinePointer(boolean)}. */ - public static final int CONFINED_MASK = 1 << 16; + public static final int CONFINED_MASK = 1 << 30; /** Pointer is invisible, see {@link Window#setPointerVisible(boolean)}. */ - public static final int INVISIBLE_MASK = 1 << 17; + public static final int INVISIBLE_MASK = 1 << 31; /** * Returns the corresponding button mask for the given button. @@ -70,7 +76,7 @@ public abstract class InputEvent extends NEWTEvent */ public static final int getButtonMask(int button) { if( 0 < button && button <= MouseEvent.BUTTON_NUMBER ) { - return 1 << ( 5 + button ) ; + return 1 << ( 4 + button ) ; } return 0; } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index d293d2db7..914aaa647 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -49,8 +49,15 @@ public class MouseEvent extends InputEvent public static final int BUTTON5 = 5; /** ID for button 6, value 6 */ public static final int BUTTON6 = 6; - /** Number of buttons, value 6 */ - public static final int BUTTON_NUMBER = 6; + /** ID for button 6, value 7 */ + public static final int BUTTON7 = 7; + /** ID for button 6, value 8 */ + public static final int BUTTON8 = 8; + /** ID for button 6, value 9 */ + public static final int BUTTON9 = 9; + + /** Maximum number of buttons, value 16 */ + public static final int BUTTON_NUMBER = 16; public static final int getClickTimeout() { return 300; diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 92f174e39..c21cb4b40 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -51,9 +51,9 @@ import com.jogamp.newt.event.MouseEvent; public class WindowDriver extends WindowImpl { private static final String WINDOW_CLASS_NAME = "NewtWindow"; - private static final int X11_WHEEL_ONE_UP_BUTTON = 4; + private static final int X11_WHEEL_ONE_UP_BUTTON = 4; private static final int X11_WHEEL_ONE_DOWN_BUTTON = 5; - private static final int X11_WHEEL_TWO_UP_BUTTON = 6; + private static final int X11_WHEEL_TWO_UP_BUTTON = 6; private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; static { diff --git a/src/newt/native/InputEvent.h b/src/newt/native/InputEvent.h index 51c56c474..3fa7dbefe 100644 --- a/src/newt/native/InputEvent.h +++ b/src/newt/native/InputEvent.h @@ -38,15 +38,20 @@ #define EVENT_CTRL_MASK (1 << 1) #define EVENT_META_MASK (1 << 2) #define EVENT_ALT_MASK (1 << 3) -#define EVENT_ALT_GRAPH_MASK (1 << 5) -#define EVENT_BUTTON1_MASK (1 << 6) -#define EVENT_BUTTON2_MASK (1 << 7) -#define EVENT_BUTTON3_MASK (1 << 8) -#define EVENT_BUTTON4_MASK (1 << 9) -#define EVENT_BUTTON5_MASK (1 << 10) -#define EVENT_BUTTON6_MASK (1 << 11) -#define EVENT_AUTOREPEAT_MASK (1 << 15) -#define EVENT_CONFINED_MASK (1 << 16) -#define EVENT_INVISIBLE_MASK (1 << 17) +#define EVENT_ALT_GRAPH_MASK (1 << 4) + +#define EVENT_BUTTON1_MASK (1 << 5) +#define EVENT_BUTTON2_MASK (1 << 6) +#define EVENT_BUTTON3_MASK (1 << 7) +#define EVENT_BUTTON4_MASK (1 << 8) +#define EVENT_BUTTON5_MASK (1 << 9) +#define EVENT_BUTTON6_MASK (1 << 10) +#define EVENT_BUTTON7_MASK (1 << 11) +#define EVENT_BUTTON8_MASK (1 << 12) +#define EVENT_BUTTON9_MASK (1 << 13) + +#define EVENT_AUTOREPEAT_MASK (1 << 29) +#define EVENT_CONFINED_MASK (1 << 30) +#define EVENT_INVISIBLE_MASK (1 << 31) #endif -- cgit v1.2.3 From 2958508131e5f0b3336f07c6f1c2865eb954921b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 12 Oct 2012 15:12:39 +0200 Subject: Adding unit tests for ImmModeSink and FixedFunctionPipeline (single & combinations, plus texture usage) --- make/scripts/tests.sh | 18 +- .../opengl/test/junit/jogl/demos/es1/GearsES1.java | 44 +++- .../test/junit/jogl/demos/es1/RedSquareES1.java | 46 +++-- .../jogl/demos/es1/newt/TestGearsES1NEWT.java | 27 ++- .../jogl/demos/es1/newt/TestRedSquareES1NEWT.java | 27 ++- .../junit/jogl/util/DemoGL2ES1ImmModeSink.java | 97 +++++++++ .../test/junit/jogl/util/DemoGL2ES1Plain.java | 161 +++++++++++++++ .../jogl/util/DemoGL2ES1TextureImmModeSink.java | 142 +++++++++++++ .../util/TestES1FixedFunctionPipelineNEWT.java | 151 ++++++++++++++ .../junit/jogl/util/TestImmModeSinkES1NEWT.java | 226 +-------------------- .../jogamp/opengl/test/junit/util/UITestCase.java | 6 +- 11 files changed, 684 insertions(+), 261 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1ImmModeSink.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1Plain.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/TestES1FixedFunctionPipelineNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8b4f7dda4..6ed6709d4 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -65,6 +65,10 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" + #D_ARGS="-Djogl.debug.GLSLCode" + #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" + #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" + #D_ARGS="-Djogl.debug.FixedFuncPipeline" #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" @@ -131,7 +135,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - D_ARGS="-Dnewt.debug.Window.MouseEvent" + #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window" @@ -239,7 +243,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -395,6 +399,14 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt $* +# +# Misc Utils +# +#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* + # # Texture / TextureUtils # @@ -433,7 +445,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 $* -#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo01 $* +testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo02 $* # diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java index 40b351a75..5186fd7fd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java @@ -27,6 +27,7 @@ import javax.media.opengl.GL2ES1; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLPipelineFactory; import javax.media.opengl.GLProfile; import com.jogamp.newt.Window; @@ -37,12 +38,21 @@ import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; +import com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil; +import com.jogamp.opengl.util.glsl.fixedfunc.ShaderSelectionMode; /** * GearsES1.java
    * @author Brian Paul (converted to Java by Ron Cemer and Sven Gothel)

    */ public class GearsES1 implements GLEventListener { + private boolean debugFFPEmu = false; + private boolean verboseFFPEmu = false; + private boolean traceFFPEmu = false; + private boolean forceFFPEmu = false; + private boolean debug = false ; + private boolean trace = false ; + private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; @@ -63,6 +73,13 @@ public class GearsES1 implements GLEventListener { this.swapInterval = 1; } + public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) { + this.forceFFPEmu = forceFFPEmu; + this.verboseFFPEmu = verboseFFPEmu; + this.debugFFPEmu = debugFFPEmu; + this.traceFFPEmu = traceFFPEmu; + } + public void setGears(GearsObject g1, GearsObject g2, GearsObject g3) { gear1 = g1; gear2 = g2; @@ -91,8 +108,31 @@ public class GearsES1 implements GLEventListener { // drawable.setGL(new DebugGL(drawable.getGL())); GL _gl = drawable.getGL(); - // GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl /*, true*/); - GL2ES1 gl = _gl.getGL2ES1(); + + if(debugFFPEmu) { + // Debug .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) ); + debug = false; + } + if(traceFFPEmu) { + // Trace .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) ); + trace = false; + } + GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu); + + if(debug) { + try { + // Debug .. + gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) ); + } catch (Exception e) {e.printStackTrace();} + } + if(trace) { + try { + // Trace .. + gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) ); + } catch (Exception e) {e.printStackTrace();} + } System.err.println("GearsES1 init on "+Thread.currentThread()); System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java index 84234d464..37ed83eb6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/RedSquareES1.java @@ -10,11 +10,14 @@ import com.jogamp.opengl.util.glsl.fixedfunc.*; public class RedSquareES1 implements GLEventListener { - public static boolean glDebugEmu = false; - public static boolean glDebug = false ; - public static boolean glTrace = false ; public static boolean oneThread = false; public static boolean useAnimator = false; + private boolean debugFFPEmu = false; + private boolean verboseFFPEmu = false; + private boolean traceFFPEmu = false; + private boolean forceFFPEmu = false; + private boolean debug = false ; + private boolean trace = false ; private int swapInterval = 0; long startTime = 0; @@ -28,6 +31,13 @@ public class RedSquareES1 implements GLEventListener { this.swapInterval = 1; } + public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) { + this.forceFFPEmu = forceFFPEmu; + this.verboseFFPEmu = verboseFFPEmu; + this.debugFFPEmu = debugFFPEmu; + this.traceFFPEmu = traceFFPEmu; + } + // FIXME: we must add storage of the pointers in the GL state to // the GLImpl classes. The need for this can be seen by making // these variables method local instead of instance members. The @@ -42,29 +52,25 @@ public class RedSquareES1 implements GLEventListener { System.err.println(Thread.currentThread()+" RedSquareES1.init ..."); GL _gl = drawable.getGL(); - if(glDebugEmu) { - try { - // Debug .. - _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) ); - - if(glTrace) { - // Trace .. - _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) ); - } - } catch (Exception e) {e.printStackTrace();} - glDebug = false; - glTrace = false; + if(debugFFPEmu) { + // Debug .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) ); + debug = false; } - - GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl); - if(glDebug) { + if(traceFFPEmu) { + // Trace .. + _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES2.class, _gl, new Object[] { System.err } ) ); + trace = false; + } + GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu); + + if(debug) { try { // Debug .. gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) ); } catch (Exception e) {e.printStackTrace();} } - - if(glTrace) { + if(trace) { try { // Trace .. gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) ); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java index ff168d9e9..9e0bbae71 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java @@ -48,6 +48,8 @@ import org.junit.Test; public class TestGearsES1NEWT extends UITestCase { static int width, height; + static boolean forceES2 = false; + static boolean forceFFPEmu = false; @BeforeClass public static void initClass() { @@ -59,12 +61,16 @@ public class TestGearsES1NEWT extends UITestCase { public static void releaseClass() { } - protected void runTestGL(GLCapabilities caps) throws InterruptedException { + protected void runTestGL(GLCapabilities caps, boolean forceFFPEmu) throws InterruptedException { GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test"); - glWindow.addGLEventListener(new GearsES1()); + final GearsES1 demo = new GearsES1(); + demo.setForceFFPEmu(forceFFPEmu, forceFFPEmu, false, false); + glWindow.addGLEventListener(demo); + final SnapshotGLEventListener snap = new SnapshotGLEventListener(); + glWindow.addGLEventListener(snap); Animator animator = new Animator(glWindow); QuitAdapter quitAdapter = new QuitAdapter(); @@ -95,6 +101,7 @@ public class TestGearsES1NEWT extends UITestCase { glWindow.setVisible(true); animator.setUpdateFPSFrames(1, null); animator.start(); + snap.setMakeSnapshot(); while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Fri, 12 Oct 2012 21:44:07 +0200 Subject: GLArrayDataClient.bindBuffer(gl, bind=true): checkSeal and init_vbo if required (similar sanity checks as enableBuffer()) --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6ed6709d4..10811d3e5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -441,11 +441,11 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 $* -#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 $* +testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 $* -testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo01 $* +#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUUISceneNewtDemo02 $* # diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java index af091d52b..88cb3303f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataClient.java @@ -182,6 +182,11 @@ public class GLArrayDataClient extends GLArrayDataWrapper implements GLArrayData @Override public boolean bindBuffer(GL gl, boolean bind) { + if(bind) { + checkSeal(true); + // init/generate VBO name if not done yet + init_vbo(gl); + } return glArrayHandler.bindBuffer(gl, bind); } -- cgit v1.2.3 From e03c5a17f1e6ebe7c8581469f35feb67a7100d15 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 12 Oct 2012 22:01:24 +0200 Subject: FixedFuncHook: Add ES2 alignment of certain GL functions, i.e. GL_QUAD_STRIP/GL_POLYGON/GL_QUADS mapping, glTexImage2D internalformat/format match. --- make/scripts/tests.sh | 4 +- .../com/jogamp/opengl/util/ImmModeSink.java | 4 +- .../opengl/util/glsl/fixedfunc/FixedFuncHook.java | 53 ++++++++++++++++++++-- 3 files changed, 54 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 10811d3e5..7519606e1 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -403,7 +403,7 @@ function testawtswt() { # Misc Utils # #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* @@ -441,7 +441,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 $* -testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 $* +#testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 238e402d1..1292a9298 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -422,12 +422,12 @@ public class ImmModeSink { if ( GL_QUADS == mode && !gl.isGL2() ) { if( GL.GL_UNSIGNED_BYTE == type ) { final ByteBuffer b = (ByteBuffer) indices; - for (int j = 0; j < b.remaining(); j++) { + for (int j = b.position(); j < b.remaining(); j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x000000ff & b.get(j)), 4); } } else { final ShortBuffer b = (ShortBuffer) indices; - for (int j = 0; j < b.remaining(); j++) { + for (int j = b.position(); j < b.remaining(); j++) { gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x0000ffff & b.get(j)), 4); } } diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java index abf71ba41..77b7a16b7 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java @@ -30,9 +30,12 @@ package jogamp.opengl.util.glsl.fixedfunc; import java.nio.Buffer; +import java.nio.ByteBuffer; import java.nio.IntBuffer; +import java.nio.ShortBuffer; import javax.media.opengl.GL; +import javax.media.opengl.GL2; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLArrayData; import javax.media.opengl.GLException; @@ -113,15 +116,49 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun // FixedFuncHookIf - hooks // public void glDrawArrays(int mode, int first, int count) { - fixedFunction.validate(gl); + fixedFunction.validate(gl); + switch(mode) { + case GL2.GL_QUAD_STRIP: + mode=GL.GL_TRIANGLE_STRIP; + break; + case GL2.GL_POLYGON: + mode=GL.GL_TRIANGLE_FAN; + break; + } + if ( GL2.GL_QUADS == mode && !gl.isGL2() ) { + for (int j = first; j < count - 3; j += 4) { + gl.glDrawArrays(GL.GL_TRIANGLE_FAN, j, 4); + } + } else { + gl.glDrawArrays(mode, first, count); + } + gl.glDrawArrays(mode, first, count); } public void glDrawElements(int mode, int count, int type, java.nio.Buffer indices) { fixedFunction.validate(gl); - gl.glDrawElements(mode, count, type, indices); + if ( GL2.GL_QUADS == mode && !gl.isGL2() ) { + if( GL.GL_UNSIGNED_BYTE == type ) { + final ByteBuffer b = (ByteBuffer) indices; + for (int j = b.position(); j < count; j++) { + gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x000000ff & b.get(j)), 4); + } + } else { + final ShortBuffer b = (ShortBuffer) indices; + for (int j = b.position(); j < count; j++) { + gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x0000ffff & b.get(j)), 4); + } + } + } else { + gl.glDrawElements(mode, count, type, indices); + // GL2: gl.glDrawRangeElements(mode, 0, count-1, indices.remaining(), type, indices); + } } public void glDrawElements(int mode, int count, int type, long indices_buffer_offset) { fixedFunction.validate(gl); + if ( GL2.GL_QUADS == mode && !gl.isGL2() ) { + throw new GLException("Cannot handle indexed QUADS on !GL2 w/ VBO due to lack of CPU index access"); + } gl.glDrawElements(mode, count, type, indices_buffer_offset); } @@ -183,11 +220,21 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun } public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, Buffer pixels) { + // align internalformat w/ format, an ES2 requirement + switch(internalformat) { + case 3: internalformat= ( GL.GL_RGBA == format ) ? GL.GL_RGBA : GL.GL_RGB; break; + case 4: internalformat= ( GL.GL_RGB == format ) ? GL.GL_RGB : GL.GL_RGBA; break; + } fixedFunction.glTexImage2D(target, /* level, */ internalformat, /*width, height, border, */ format /*, type, pixels*/); gl.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); } public void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, - int format, int type, long pixels_buffer_offset) { + int format, int type, long pixels_buffer_offset) { + // align internalformat w/ format, an ES2 requirement + switch(internalformat) { + case 3: internalformat= ( GL.GL_RGBA == format ) ? GL.GL_RGBA : GL.GL_RGB; break; + case 4: internalformat= ( GL.GL_RGB == format ) ? GL.GL_RGB : GL.GL_RGBA; break; + } fixedFunction.glTexImage2D(target, /* level, */ internalformat, /*width, height, border, */ format /*, type, pixels*/); gl.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels_buffer_offset); } -- cgit v1.2.3 From 61bb64aea9d8967f5360ba42fc9ec7a24b79683b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 13 Oct 2012 07:10:52 +0200 Subject: Fix Windows ANGLE Workaround Regression of commit 923d9dd7f1d40db72d35ca76a761ca14babf147f We are aware that Google's ANGLE (Windows EGL/ES2 impl. based on D3D) crashes using eglInitialize(..) w/ EGL_DEFAULT_DISPLAY. Commit 923d9dd7f1d40db72d35ca76a761ca14babf147f moved the EGL device initialization into the EGLDrawableFactory ctor and hence slipped out ANGLE workaround to disable it per default. - Moving property static flags from GLProfile -> GLDrawableFactory - Moving ANGLE workaround right into EGLDrawableFactory (where it belongs) - Moving optional EGL/ES disable code to GLDrawableFactory (where it belongs) Tested on Windows w/ Java-32bit and latest Chrome ANGLE DLLs --- make/scripts/java-win32-dbg.bat | 13 +++--- make/scripts/java-win32.bat | 9 ++-- make/scripts/tests-x32.bat | 4 +- .../javax/media/opengl/GLDrawableFactory.java | 51 ++++++++++++++++------ src/jogl/classes/javax/media/opengl/GLProfile.java | 40 +++-------------- .../jogamp/opengl/GLDrawableFactoryImpl.java | 2 +- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 4 +- .../jogamp/opengl/egl/EGLDrawableFactory.java | 31 ++++++++----- 8 files changed, 81 insertions(+), 73 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat index c592efccf..e0760d02b 100755 --- a/make/scripts/java-win32-dbg.bat +++ b/make/scripts/java-win32-dbg.bat @@ -7,20 +7,21 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl set BLD_DIR=..\%BLD_SUB% -set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 - -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20120127;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj -set LIB_DIR=%FFMPEG_LIB% +REM set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 +REM set LIB_DIR=%FFMPEG_LIB% +set LIB_DIR= set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar echo CP_ALL %CP_ALL% -set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" +set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.FBObject" "-Djogl.enable.ANGLE" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat index bf7437146..d35715707 100755 --- a/make/scripts/java-win32.bat +++ b/make/scripts/java-win32.bat @@ -7,12 +7,15 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl set BLD_DIR=..\%BLD_SUB% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\angle\win32;%PATH% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20120127;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% set BLD_DIR=..\%BLD_SUB% REM set LIB_DIR=..\..\gluegen\%BLD_SUB%\obj;%BLD_DIR%\lib +REM set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 +REM set LIB_DIR=%FFMPEG_LIB% set LIB_DIR= set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index de0785661..ec6c41f37 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -1,5 +1,5 @@ REM scripts\java-win32-dbg.bat jogamp.newt.awt.opengl.VersionApplet -REM scripts\java-win32-dbg.bat com.jogamp.newt.opengl.GLWindow +scripts\java-win32-dbg.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win32-dbg.bat javax.media.opengl.awt.GLCanvas REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* @@ -75,7 +75,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT0 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* -scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT -time 5000 diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index ae49eeeff..70480e728 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -97,9 +97,28 @@ import jogamp.opengl.Debug; */ public abstract class GLDrawableFactory { + protected static final boolean DEBUG = Debug.debug("GLDrawable"); + + /** + * We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome. + * When run in the mentioned browsers, the eglInitialize(..) implementation crashes. + *

    + * This can be overridden by explicitly enabling ANGLE on Windows by setting the property + * jogl.enable.ANGLE. + *

    + */ + protected static final boolean enableANGLE = Debug.isPropertyDefined("jogl.enable.ANGLE", true); + + /** + * In case no OpenGL ES implementation is required + * and if the running platform may have a buggy implementation, + * setting the property jogl.disable.opengles disables querying a possible existing OpenGL ES implementation. + */ + protected static final boolean disableOpenGLES = Debug.isPropertyDefined("jogl.disable.opengles", true); + static final String macosxFactoryClassNameCGL = "jogamp.opengl.macosx.cgl.MacOSXCGLDrawableFactory"; static final String macosxFactoryClassNameAWTCGL = "jogamp.opengl.macosx.cgl.awt.MacOSXAWTCGLDrawableFactory"; - + private static volatile boolean isInit = false; private static GLDrawableFactory eglFactory; private static GLDrawableFactory nativeOSFactory; @@ -144,19 +163,19 @@ public abstract class GLDrawableFactory { } } else { // may use egl*Factory .. - if (GLProfile.DEBUG) { + if (DEBUG || GLProfile.DEBUG) { System.err.println("GLDrawableFactory.static - No native Windowing Factory for: "+nwt+"; May use EGLDrawableFactory, if available." ); } } } if (null != factoryClassName) { - if (GLProfile.DEBUG) { + if (DEBUG || GLProfile.DEBUG) { System.err.println("GLDrawableFactory.static - Native OS Factory for: "+nwt+": "+factoryClassName); } try { tmp = (GLDrawableFactory) ReflectionUtil.createInstance(factoryClassName, cl); } catch (JogampRuntimeException jre) { - if (GLProfile.DEBUG) { + if (DEBUG || GLProfile.DEBUG) { System.err.println("Info: GLDrawableFactory.static - Native Platform: "+nwt+" - not available: "+factoryClassName); jre.printStackTrace(); } @@ -165,18 +184,22 @@ public abstract class GLDrawableFactory { if(null != tmp && tmp.isComplete()) { nativeOSFactory = tmp; } - tmp = null; - try { - tmp = (GLDrawableFactory) ReflectionUtil.createInstance("jogamp.opengl.egl.EGLDrawableFactory", cl); - } catch (JogampRuntimeException jre) { - if (GLProfile.DEBUG) { - System.err.println("Info: GLDrawableFactory.static - EGLDrawableFactory - not available"); - jre.printStackTrace(); + + if(!disableOpenGLES) { + try { + tmp = (GLDrawableFactory) ReflectionUtil.createInstance("jogamp.opengl.egl.EGLDrawableFactory", cl); + } catch (JogampRuntimeException jre) { + if (DEBUG || GLProfile.DEBUG) { + System.err.println("Info: GLDrawableFactory.static - EGLDrawableFactory - not available"); + jre.printStackTrace(); + } } - } - if(null != tmp && tmp.isComplete()) { - eglFactory = tmp; + if(null != tmp && tmp.isComplete()) { + eglFactory = tmp; + } + } else if( DEBUG || GLProfile.DEBUG ) { + System.err.println("Info: GLDrawableFactory.static - EGLDrawableFactory - disabled!"); } } diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index aabda465e..f916ab8b1 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -77,23 +77,6 @@ public class GLProfile { public static final boolean DEBUG = Debug.debug("GLProfile"); - /** - * We have to disable support for ANGLE, the D3D ES2 emulation on Windows provided w/ Firefox and Chrome. - * When run in the mentioned browsers, the eglInitialize(..) implementation crashes. - *

    - * This can be overridden by explicitly enabling ANGLE on Windows by setting the property - * jogl.enable.ANGLE. - *

    - */ - private static final boolean enableANGLE = Debug.isPropertyDefined("jogl.enable.ANGLE", true); - - /** - * In case no OpenGL ES implementation is required - * and if the running platform may have a buggy implementation, - * setting the property jogl.disable.opengles disables querying a possible existing OpenGL ES implementation. - */ - private static final boolean disableOpenGLES = Debug.isPropertyDefined("jogl.disable.opengles", true); - static { // Also initializes TempJarCache if shall be used. Platform.initSingleton(); @@ -1447,28 +1430,15 @@ public class GLProfile { defaultDesktopDevice = desktopFactory.getDefaultDevice(); } - if ( !disableOpenGLES && ReflectionUtil.isClassAvailable("jogamp.opengl.egl.EGLDrawableFactory", classloader) ) { + if ( ReflectionUtil.isClassAvailable("jogamp.opengl.egl.EGLDrawableFactory", classloader) ) { t=null; try { eglFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactoryImpl(GLES2); if(null != eglFactory) { - final boolean isANGLE = ((jogamp.opengl.egl.EGLDrawableFactory)eglFactory).isANGLE(); - if(isANGLE && !enableANGLE) { - if(DEBUG) { - System.err.println("Info: GLProfile.init - EGL/ES2 ANGLE disabled"); - } - eglFactory.destroy(); - eglFactory = null; - hasEGLFactory = false; - } else { - if(DEBUG && isANGLE) { - System.err.println("Info: GLProfile.init - EGL/ES2 ANGLE enabled"); - } - hasEGLFactory = true; - // update hasGLES1Impl, hasGLES2Impl based on EGL - hasGLES2Impl = null!=eglFactory.getGLDynamicLookupHelper(2) && hasGLES2Impl; - hasGLES1Impl = null!=eglFactory.getGLDynamicLookupHelper(1) && hasGLES1Impl; - } + hasEGLFactory = true; + // update hasGLES1Impl, hasGLES2Impl based on EGL + hasGLES2Impl = null!=eglFactory.getGLDynamicLookupHelper(2) && hasGLES2Impl; + hasGLES1Impl = null!=eglFactory.getGLDynamicLookupHelper(1) && hasGLES1Impl; } } catch (LinkageError le) { t=le; diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 9aa6ce3cc..2bb22f7b0 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -74,7 +74,7 @@ import com.jogamp.opengl.GLRendererQuirks; they may be instantiated by the GLJPanel implementation. */ @SuppressWarnings("deprecation") public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { - protected static final boolean DEBUG = GLDrawableImpl.DEBUG; + protected static final boolean DEBUG = GLDrawableFactory.DEBUG; // allow package access protected GLDrawableFactoryImpl() { super(); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index 13960ecdd..df7f742aa 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -52,8 +52,8 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; public abstract class GLDrawableImpl implements GLDrawable { - protected static final boolean DEBUG = Debug.debug("GLDrawable"); - + protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; + protected GLDrawableImpl(GLDrawableFactory factory, NativeSurface comp, boolean realized) { this(factory, comp, (GLCapabilitiesImmutable) comp.getGraphicsConfiguration().getRequestedCapabilities(), realized); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index da3907193..e985e63b2 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -81,13 +81,12 @@ import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.opengl.GLRendererQuirks; public class EGLDrawableFactory extends GLDrawableFactoryImpl { - protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; + protected static final boolean DEBUG = GLDrawableFactoryImpl.DEBUG; // allow package access /* package */ static final boolean QUERY_EGL_ES_NATIVE_TK = Debug.isPropertyDefined("jogl.debug.EGLDrawableFactory.QueryNativeTK", true); private static GLDynamicLookupHelper eglES1DynamicLookupHelper = null; private static GLDynamicLookupHelper eglES2DynamicLookupHelper = null; - private static boolean isANGLE = false; private static final boolean isANGLE(GLDynamicLookupHelper dl) { if(Platform.OSType.WINDOWS == Platform.OS_TYPE) { @@ -135,10 +134,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { EGL.resetProcAddressTable(eglES1DynamicLookupHelper); final boolean isANGLEES1 = isANGLE(eglES1DynamicLookupHelper); isANGLE |= isANGLEES1; - if (GLProfile.DEBUG) { + if (DEBUG || GLProfile.DEBUG) { System.err.println("Info: EGLDrawableFactory: EGL ES1 - OK, isANGLE: "+isANGLEES1); } - } else if (GLProfile.DEBUG) { + } else if (DEBUG || GLProfile.DEBUG) { System.err.println("Info: EGLDrawableFactory: EGL ES1 - NOPE"); } } @@ -156,17 +155,28 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { EGL.resetProcAddressTable(eglES2DynamicLookupHelper); final boolean isANGLEES2 = isANGLE(eglES2DynamicLookupHelper); isANGLE |= isANGLEES2; - if (GLProfile.DEBUG) { + if (DEBUG || GLProfile.DEBUG) { System.err.println("Info: EGLDrawableFactory: EGL ES2 - OK, isANGLE: "+isANGLEES2); } - } else if (GLProfile.DEBUG) { + } else if (DEBUG || GLProfile.DEBUG) { System.err.println("Info: EGLDrawableFactory: EGL ES2 - NOPE"); } } - if(null != eglES2DynamicLookupHelper || null != eglES1DynamicLookupHelper) { - sharedMap = new HashMap(); - sharedMapCreateAttempt = new HashSet(); - defaultDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + if( null != eglES2DynamicLookupHelper || null != eglES1DynamicLookupHelper ) { + if(isANGLE && !enableANGLE) { + if(DEBUG || GLProfile.DEBUG) { + System.err.println("Info: EGLDrawableFactory.init - EGL/ES2 ANGLE disabled"); + } + } else { + if( isANGLE && ( DEBUG || GLProfile.DEBUG ) ) { + System.err.println("Info: EGLDrawableFactory.init - EGL/ES2 ANGLE enabled"); + } + sharedMap = new HashMap(); + sharedMapCreateAttempt = new HashSet(); + + // FIXME: Following triggers eglInitialize(..) which crashed on Windows w/ Chrome/Angle, FF/Angle! + defaultDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + } } } } @@ -239,6 +249,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private HashSet sharedMapCreateAttempt = null; private EGLGraphicsDevice defaultDevice = null; private SharedResource defaultSharedResource = null; + private boolean isANGLE = false; static class SharedResource { private final EGLGraphicsDevice device; -- cgit v1.2.3 From 658d269db957cdb986f2da2fbe15d2441b6f03c4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 16 Oct 2012 06:27:40 +0200 Subject: ImmModeSink: Fix buffer grow (+1 element @ named buffer), enable DEBUG_* via properties, drawIndices QUAD w/ proper range and add uint; FixedFunctionHook: drawIndices QUAD w/ proper range and add uint --- make/scripts/tests.sh | 4 +- .../com/jogamp/opengl/util/ImmModeSink.java | 120 ++++++++++++--------- .../opengl/util/glsl/fixedfunc/FixedFuncHook.java | 19 ++-- 3 files changed, 83 insertions(+), 60 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7519606e1..a667dbe6e 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -402,8 +402,8 @@ function testawtswt() { # # Misc Utils # -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 1292a9298..52e4cbce0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -3,6 +3,7 @@ package com.jogamp.opengl.util; import java.nio.Buffer; import java.nio.ByteBuffer; +import java.nio.IntBuffer; import java.nio.ShortBuffer; import java.util.ArrayList; import java.util.Iterator; @@ -13,6 +14,8 @@ import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; import javax.media.opengl.fixedfunc.GLPointerFunc; +import jogamp.opengl.Debug; + import com.jogamp.opengl.util.glsl.ShaderState; /** @@ -43,10 +46,9 @@ import com.jogamp.opengl.util.glsl.ShaderState; *

    */ public class ImmModeSink { - - public static final boolean DEBUG_BEGIN_END = false; - public static final boolean DEBUG_DRAW = false; - public static final boolean DEBUG_BUFFER = false; + protected static final boolean DEBUG_BEGIN_END = Debug.isPropertyDefined("jogl.debug.ImmModeSink.BeginEnd", true); + protected static final boolean DEBUG_DRAW = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Draw", true); + protected static final boolean DEBUG_BUFFER = Debug.isPropertyDefined("jogl.debug.ImmModeSink.Buffer", true); public static final int GL_QUADS = 0x0007; // Needs data manipulation on ES1/ES2 public static final int GL_QUAD_STRIP = 0x0008; @@ -410,30 +412,39 @@ public class ImmModeSink { gl.glDrawArrays(mode, 0, vElems); } } else { - int type=-1; + final int type; if(indices instanceof ByteBuffer) { type = GL.GL_UNSIGNED_BYTE; } else if(indices instanceof ShortBuffer) { type = GL.GL_UNSIGNED_SHORT; + } else if(indices instanceof IntBuffer) { + type = GL.GL_UNSIGNED_INT; } else { - throw new GLException("Given Buffer Class not supported: "+indices.getClass()+", should be ubyte or ushort:\n\t"+this); + throw new GLException("Given Buffer Class not supported: "+indices.getClass()+", should be ubyte, ushort or uint:\n\t"+this); } + final int idxLen = indices.remaining(); + final int idx0 = indices.position(); if ( GL_QUADS == mode && !gl.isGL2() ) { if( GL.GL_UNSIGNED_BYTE == type ) { final ByteBuffer b = (ByteBuffer) indices; - for (int j = b.position(); j < b.remaining(); j++) { - gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x000000ff & b.get(j)), 4); + for (int j = 0; j < idxLen; j++) { + gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x000000ff & b.get(idx0+j)), 4); } - } else { + } else if( GL.GL_UNSIGNED_SHORT == type ){ final ShortBuffer b = (ShortBuffer) indices; - for (int j = b.position(); j < b.remaining(); j++) { - gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x0000ffff & b.get(j)), 4); + for (int j = 0; j < idxLen; j++) { + gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0x0000ffff & b.get(idx0+j)), 4); + } + } else { + final IntBuffer b = (IntBuffer) indices; + for (int j = 0; j < idxLen; j++) { + gl.glDrawArrays(GL.GL_TRIANGLE_FAN, (int)(0xffffffff & b.get(idx0+j)), 4); } } } else { - gl.glDrawElements(mode, indices.remaining(), type, indices); - // GL2: gl.glDrawRangeElements(mode, 0, indices.remaining()-1, indices.remaining(), type, indices); + gl.glDrawElements(mode, idxLen, type, indices); + // GL2: gl.glDrawRangeElements(mode, 0, idxLen-1, idxLen, type, indices); } } } @@ -466,7 +477,7 @@ public class ImmModeSink { public void glVertex2b(byte x, byte y) { checkSeal(false); - growBuffer(VERTEX, 2); + growBuffer(VERTEX); if(vComps>0) GLBuffers.putb(vertexArray, x); if(vComps>1) @@ -475,7 +486,7 @@ public class ImmModeSink { } public void glVertex3b(byte x, byte y, byte z) { checkSeal(false); - growBuffer(VERTEX, 3); + growBuffer(VERTEX); if(vComps>0) GLBuffers.putb(vertexArray, x); if(vComps>1) @@ -486,7 +497,7 @@ public class ImmModeSink { } public void glVertex2s(short x, short y) { checkSeal(false); - growBuffer(VERTEX, 2); + growBuffer(VERTEX); if(vComps>0) GLBuffers.puts(vertexArray, x); if(vComps>1) @@ -495,7 +506,7 @@ public class ImmModeSink { } public void glVertex3s(short x, short y, short z) { checkSeal(false); - growBuffer(VERTEX, 3); + growBuffer(VERTEX); if(vComps>0) GLBuffers.puts(vertexArray, x); if(vComps>1) @@ -506,7 +517,7 @@ public class ImmModeSink { } public void glVertex2f(float x, float y) { checkSeal(false); - growBuffer(VERTEX, 2); + growBuffer(VERTEX); if(vComps>0) GLBuffers.putf(vertexArray, x); if(vComps>1) @@ -515,7 +526,7 @@ public class ImmModeSink { } public void glVertex3f(float x, float y, float z) { checkSeal(false); - growBuffer(VERTEX, 3); + growBuffer(VERTEX); if(vComps>0) GLBuffers.putf(vertexArray, x); if(vComps>1) @@ -527,7 +538,7 @@ public class ImmModeSink { public void glNormal3b(byte x, byte y, byte z) { checkSeal(false); - growBuffer(NORMAL, 3); + growBuffer(NORMAL); if(nComps>0) GLBuffers.putb(normalArray, x); if(nComps>1) @@ -538,7 +549,7 @@ public class ImmModeSink { } public void glNormal3s(short x, short y, short z) { checkSeal(false); - growBuffer(NORMAL, 3); + growBuffer(NORMAL); if(nComps>0) GLBuffers.puts(normalArray, x); if(nComps>1) @@ -549,7 +560,7 @@ public class ImmModeSink { } public void glNormal3f(float x, float y, float z) { checkSeal(false); - growBuffer(NORMAL, 3); + growBuffer(NORMAL); if(nComps>0) GLBuffers.putf(normalArray, x); if(nComps>1) @@ -561,7 +572,7 @@ public class ImmModeSink { public void glColor3b(byte r, byte g, byte b) { checkSeal(false); - growBuffer(COLOR, 3); + growBuffer(COLOR); if(cComps>0) GLBuffers.putb(colorArray, r); if(cComps>1) @@ -572,7 +583,7 @@ public class ImmModeSink { } public void glColor4b(byte r, byte g, byte b, byte a) { checkSeal(false); - growBuffer(COLOR, 4); + growBuffer(COLOR); if(cComps>0) GLBuffers.putb(colorArray, r); if(cComps>1) @@ -585,7 +596,7 @@ public class ImmModeSink { } public void glColor3s(short r, short g, short b) { checkSeal(false); - growBuffer(COLOR, 3); + growBuffer(COLOR); if(cComps>0) GLBuffers.puts(colorArray, r); if(cComps>1) @@ -596,7 +607,7 @@ public class ImmModeSink { } public void glColor4s(short r, short g, short b, short a) { checkSeal(false); - growBuffer(COLOR, 4); + growBuffer(COLOR); if(cComps>0) GLBuffers.puts(colorArray, r); if(cComps>1) @@ -609,7 +620,7 @@ public class ImmModeSink { } public void glColor3f(float r, float g, float b) { checkSeal(false); - growBuffer(COLOR, 3); + growBuffer(COLOR); if(cComps>0) GLBuffers.putf(colorArray, r); if(cComps>1) @@ -620,7 +631,7 @@ public class ImmModeSink { } public void glColor4f(float r, float g, float b, float a) { checkSeal(false); - growBuffer(COLOR, 4); + growBuffer(COLOR); if(cComps>0) GLBuffers.putf(colorArray, r); if(cComps>1) @@ -634,7 +645,7 @@ public class ImmModeSink { public void glTexCoord2b(byte x, byte y) { checkSeal(false); - growBuffer(TEXTCOORD, 2); + growBuffer(TEXTCOORD); if(tComps>0) GLBuffers.putb(textCoordArray, x); if(tComps>1) @@ -643,7 +654,7 @@ public class ImmModeSink { } public void glTexCoord3b(byte x, byte y, byte z) { checkSeal(false); - growBuffer(TEXTCOORD, 3); + growBuffer(TEXTCOORD); if(tComps>0) GLBuffers.putb(textCoordArray, x); if(tComps>1) @@ -654,7 +665,7 @@ public class ImmModeSink { } public void glTexCoord2s(short x, short y) { checkSeal(false); - growBuffer(TEXTCOORD, 2); + growBuffer(TEXTCOORD); if(tComps>0) GLBuffers.puts(textCoordArray, x); if(tComps>1) @@ -663,7 +674,7 @@ public class ImmModeSink { } public void glTexCoord3s(short x, short y, short z) { checkSeal(false); - growBuffer(TEXTCOORD, 3); + growBuffer(TEXTCOORD); if(tComps>0) GLBuffers.puts(textCoordArray, x); if(tComps>1) @@ -674,7 +685,7 @@ public class ImmModeSink { } public void glTexCoord2f(float x, float y) { checkSeal(false); - growBuffer(TEXTCOORD, 2); + growBuffer(TEXTCOORD); if(tComps>0) GLBuffers.putf(textCoordArray, x); if(tComps>1) @@ -683,7 +694,7 @@ public class ImmModeSink { } public void glTexCoord3f(float x, float y, float z) { checkSeal(false); - growBuffer(TEXTCOORD, 3); + growBuffer(TEXTCOORD); if(tComps>0) GLBuffers.putf(textCoordArray, x); if(tComps>1) @@ -805,7 +816,7 @@ public class ImmModeSink { final boolean useT = tComps>0 && tElems>0 ; if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableFixed.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"]"); + System.err.println("ImmModeSink.enableFixed.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); } if(enable) { @@ -877,7 +888,7 @@ public class ImmModeSink { final boolean useT = tComps>0 && tElems>0 ; if(DEBUG_DRAW) { - System.err.println("ImmModeSink.enableGLSL.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"]"); + System.err.println("ImmModeSink.enableGLSL.0 "+enable+": use [ v "+useV+", c "+useC+", n "+useN+", t "+useT+"], "+getElemUseCountStr()+", "+buffer); } if(enable) { @@ -957,16 +968,20 @@ public class ImmModeSink { return "[v "+vElems+"/"+vCount+", c "+cElems+"/"+cCount+", n "+nElems+"/"+nCount+", t "+tElems+"/"+tCount+"]"; } - protected boolean fitElemsInBuffers(int addElems) { - final int vAdd = addElems - ( vCount - vElems ); - final int cAdd = addElems - ( cCount - cElems ); - final int nAdd = addElems - ( nCount - nElems ); - final int tAdd = addElems - ( tCount - tElems ); - final boolean res = 0>=vAdd && 0>=cAdd && 0>=nAdd && 0>=tAdd; - /* if(DEBUG_BUFFER) { - System.err.println("ImmModeSink.fitElemsInBuffer: "+getElemUseCountStr()+" + "+addElems+" -> "+res); - } */ - return res; + protected boolean fitElementInBuffer(int type) { + final int addElems = 1; + switch (type) { + case VERTEX: + return ( vCount - vElems ) >= addElems ; + case COLOR: + return ( cCount - cElems ) >= addElems ; + case NORMAL: + return ( nCount - nElems ) >= addElems ; + case TEXTCOORD: + return ( tCount - tElems ) >= addElems ; + default: + throw new InternalError("XXX"); + } } protected boolean reallocateBuffer(int addElems) { @@ -1065,9 +1080,10 @@ public class ImmModeSink { return true; } - protected final boolean growBuffer(int type, int additional) { - if( null !=buffer && !sealed && 0 Date: Thu, 18 Oct 2012 09:39:21 +0200 Subject: ImmModeSink: Add glColor3ub(), glColor4ub(); Add proper value conversion of imm. gl* functions; Default color padding is 1f; Make fields private. --- make/scripts/tests.sh | 7 +- .../classes/com/jogamp/opengl/util/GLBuffers.java | 25 +- .../com/jogamp/opengl/util/ImmModeSink.java | 252 ++++++++++++--------- 3 files changed, 179 insertions(+), 105 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a667dbe6e..7a768d68c 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -69,6 +69,8 @@ function jrun() { #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.FixedFuncPipeline" + #D_ARGS="-Djogl.debug.ImmModeSink.Buffer -Djogl.debug.ImmModeSink.Draw" + #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState -Djogl.debug.ImmModeSink.Buffer -Djogl.debug.ImmModeSink.Draw" #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" @@ -246,6 +248,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLBufferConversionNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* @@ -402,8 +405,8 @@ function testawtswt() { # # Misc Utils # -testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java index 116790ec1..10d59bf7d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLBuffers.java @@ -38,7 +38,8 @@ */ package com.jogamp.opengl.util; -import com.jogamp.common.nio.Buffers; +import java.nio.Buffer; +import java.nio.ByteBuffer; import javax.media.opengl.GL; import javax.media.opengl.GL2; @@ -47,7 +48,7 @@ import javax.media.opengl.GL2GL3; import javax.media.opengl.GLES2; import javax.media.opengl.GLException; -import java.nio.*; +import com.jogamp.common.nio.Buffers; /** * Utility routines for dealing with direct buffers. @@ -56,6 +57,26 @@ import java.nio.*; */ public class GLBuffers extends Buffers { + /** + * @param glType GL primitive type + * @return false if one of GL primitive unsigned types, otherwise true + * GL_UNSIGNED_BYTE,
    + * GL_UNSIGNED_SHORT,
    + * GL_UNSIGNED_INT,
    + * GL_HILO16_NV
    + */ + public static final boolean isSignedGLType(int glType) { + switch (glType) { // 29 + case GL.GL_UNSIGNED_BYTE: + case GL.GL_UNSIGNED_SHORT: + case GL.GL_UNSIGNED_INT: + case GL2.GL_HILO16_NV: + return false; + + } + return true; + } + /** * @param glType shall be one of (29)
    * GL_BYTE, GL_UNSIGNED_BYTE,
    diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 52e4cbce0..c4e8e4619 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -16,6 +16,7 @@ import javax.media.opengl.fixedfunc.GLPointerFunc; import jogamp.opengl.Debug; +import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.glsl.ShaderState; /** @@ -301,10 +302,18 @@ public class ImmModeSink { vboSet.glColor3b(x,y,z); } + public final void glColor3ub(byte x, byte y, byte z) { + vboSet.glColor3ub(x,y,z); + } + public final void glColor4b(byte x, byte y, byte z, byte a) { vboSet.glColor4b(x,y,z,a); } + public final void glColor4ub(byte x, byte y, byte z, byte a) { + vboSet.glColor4ub(x,y,z,a); + } + public final void glTexCoord2b(byte x, byte y) { vboSet.glTexCoord2b(x,y); } @@ -344,17 +353,21 @@ public class ImmModeSink { this.glBufferUsage=glBufferUsage; this.initialElementCount=initialElementCount; this.vDataType=vDataType; + this.vDataTypeSigned=GLBuffers.isSignedGLType(vDataType); this.vComps=vComps; this.cDataType=cDataType; + this.cDataTypeSigned=GLBuffers.isSignedGLType(cDataType); this.cComps=cComps; this.nDataType=nDataType; + this.nDataTypeSigned=GLBuffers.isSignedGLType(nDataType); this.nComps=nComps; this.tDataType=tDataType; + this.tDataTypeSigned=GLBuffers.isSignedGLType(tDataType); this.tComps=tComps; this.useGLSL=useGLSL; this.useVBO = 0 != glBufferUsage; this.vboName = 0; - + this.vCount=0; this.cCount=0; this.nCount=0; @@ -460,113 +473,113 @@ public class ImmModeSink { public void glVertexv(Buffer v) { checkSeal(false); - GLBuffers.put(vertexArray, v); + Buffers.put(vertexArray, v); } public void glNormalv(Buffer v) { checkSeal(false); - GLBuffers.put(normalArray, v); + Buffers.put(normalArray, v); } public void glColorv(Buffer v) { checkSeal(false); - GLBuffers.put(colorArray, v); + Buffers.put(colorArray, v); } public void glTexCoordv(Buffer v) { checkSeal(false); - GLBuffers.put(textCoordArray, v); + Buffers.put(textCoordArray, v); } public void glVertex2b(byte x, byte y) { checkSeal(false); growBuffer(VERTEX); if(vComps>0) - GLBuffers.putb(vertexArray, x); - if(vComps>1) - GLBuffers.putb(vertexArray, y); + Buffers.putNb(vertexArray, vDataTypeSigned, x, true); + if(vComps>1) + Buffers.putNb(vertexArray, vDataTypeSigned, y, true); padding(VERTEX, vComps-2); } public void glVertex3b(byte x, byte y, byte z) { checkSeal(false); growBuffer(VERTEX); - if(vComps>0) - GLBuffers.putb(vertexArray, x); - if(vComps>1) - GLBuffers.putb(vertexArray, y); - if(vComps>2) - GLBuffers.putb(vertexArray, z); + if(vComps>0) + Buffers.putNb(vertexArray, vDataTypeSigned, x, true); + if(vComps>1) + Buffers.putNb(vertexArray, vDataTypeSigned, y, true); + if(vComps>2) + Buffers.putNb(vertexArray, vDataTypeSigned, z, true); padding(VERTEX, vComps-3); } public void glVertex2s(short x, short y) { checkSeal(false); growBuffer(VERTEX); - if(vComps>0) - GLBuffers.puts(vertexArray, x); + if(vComps>0) + Buffers.putNs(vertexArray, vDataTypeSigned, x, true); if(vComps>1) - GLBuffers.puts(vertexArray, y); + Buffers.putNs(vertexArray, vDataTypeSigned, y, true); padding(VERTEX, vComps-2); } public void glVertex3s(short x, short y, short z) { checkSeal(false); growBuffer(VERTEX); - if(vComps>0) - GLBuffers.puts(vertexArray, x); + if(vComps>0) + Buffers.putNs(vertexArray, vDataTypeSigned, x, true); if(vComps>1) - GLBuffers.puts(vertexArray, y); + Buffers.putNs(vertexArray, vDataTypeSigned, y, true); if(vComps>2) - GLBuffers.puts(vertexArray, z); + Buffers.putNs(vertexArray, vDataTypeSigned, z, true); padding(VERTEX, vComps-3); } public void glVertex2f(float x, float y) { checkSeal(false); growBuffer(VERTEX); if(vComps>0) - GLBuffers.putf(vertexArray, x); - if(vComps>1) - GLBuffers.putf(vertexArray, y); + Buffers.putNf(vertexArray, vDataTypeSigned, x); + if(vComps>1) + Buffers.putNf(vertexArray, vDataTypeSigned, y); padding(VERTEX, vComps-2); } public void glVertex3f(float x, float y, float z) { checkSeal(false); growBuffer(VERTEX); if(vComps>0) - GLBuffers.putf(vertexArray, x); - if(vComps>1) - GLBuffers.putf(vertexArray, y); + Buffers.putNf(vertexArray, vDataTypeSigned, x); + if(vComps>1) + Buffers.putNf(vertexArray, vDataTypeSigned, y); if(vComps>2) - GLBuffers.putf(vertexArray, z); + Buffers.putNf(vertexArray, vDataTypeSigned, z); padding(VERTEX, vComps-3); } public void glNormal3b(byte x, byte y, byte z) { checkSeal(false); growBuffer(NORMAL); - if(nComps>0) - GLBuffers.putb(normalArray, x); + if(nComps>0) + Buffers.putNb(normalArray, nDataTypeSigned, x, true); if(nComps>1) - GLBuffers.putb(normalArray, y); + Buffers.putNb(normalArray, nDataTypeSigned, y, true); if(nComps>2) - GLBuffers.putb(normalArray, z); + Buffers.putNb(normalArray, nDataTypeSigned, z, true); padding(NORMAL, nComps-3); } public void glNormal3s(short x, short y, short z) { checkSeal(false); growBuffer(NORMAL); if(nComps>0) - GLBuffers.puts(normalArray, x); + Buffers.putNs(normalArray, nDataTypeSigned, x, true); if(nComps>1) - GLBuffers.puts(normalArray, y); + Buffers.putNs(normalArray, nDataTypeSigned, y, true); if(nComps>2) - GLBuffers.puts(normalArray, z); + Buffers.putNs(normalArray, nDataTypeSigned, z, true); padding(NORMAL, nComps-3); } public void glNormal3f(float x, float y, float z) { checkSeal(false); growBuffer(NORMAL); if(nComps>0) - GLBuffers.putf(normalArray, x); - if(nComps>1) - GLBuffers.putf(normalArray, y); + Buffers.putNf(normalArray, nDataTypeSigned, x); + if(nComps>1) + Buffers.putNf(normalArray, nDataTypeSigned, y); if(nComps>2) - GLBuffers.putf(normalArray, z); + Buffers.putNf(normalArray, nDataTypeSigned, z); padding(NORMAL, nComps-3); } @@ -574,72 +587,96 @@ public class ImmModeSink { checkSeal(false); growBuffer(COLOR); if(cComps>0) - GLBuffers.putb(colorArray, r); + Buffers.putNb(colorArray, cDataTypeSigned, r, true); + if(cComps>1) + Buffers.putNb(colorArray, cDataTypeSigned, g, true); + if(cComps>2) + Buffers.putNb(colorArray, cDataTypeSigned, b, true); + padding(COLOR, cComps-3); + } + public void glColor3ub(byte r, byte g, byte b) { + checkSeal(false); + growBuffer(COLOR); + if(cComps>0) + Buffers.putNb(colorArray, cDataTypeSigned, r, false); if(cComps>1) - GLBuffers.putb(colorArray, g); + Buffers.putNb(colorArray, cDataTypeSigned, g, false); if(cComps>2) - GLBuffers.putb(colorArray, b); + Buffers.putNb(colorArray, cDataTypeSigned, b, false); padding(COLOR, cComps-3); } public void glColor4b(byte r, byte g, byte b, byte a) { checkSeal(false); growBuffer(COLOR); if(cComps>0) - GLBuffers.putb(colorArray, r); + Buffers.putNb(colorArray, cDataTypeSigned, r, true); if(cComps>1) - GLBuffers.putb(colorArray, g); + Buffers.putNb(colorArray, cDataTypeSigned, g, true); if(cComps>2) - GLBuffers.putb(colorArray, b); + Buffers.putNb(colorArray, cDataTypeSigned, b, true); if(cComps>3) - GLBuffers.putb(colorArray, a); + Buffers.putNb(colorArray, cDataTypeSigned, a, true); + padding(COLOR, cComps-4); + } + public void glColor4ub(byte r, byte g, byte b, byte a) { + checkSeal(false); + growBuffer(COLOR); + if(cComps>0) + Buffers.putNb(colorArray, cDataTypeSigned, r, false); + if(cComps>1) + Buffers.putNb(colorArray, cDataTypeSigned, g, false); + if(cComps>2) + Buffers.putNb(colorArray, cDataTypeSigned, b, false); + if(cComps>3) + Buffers.putNb(colorArray, cDataTypeSigned, a, false); padding(COLOR, cComps-4); } public void glColor3s(short r, short g, short b) { checkSeal(false); growBuffer(COLOR); if(cComps>0) - GLBuffers.puts(colorArray, r); + Buffers.putNs(colorArray, cDataTypeSigned, r, true); if(cComps>1) - GLBuffers.puts(colorArray, g); + Buffers.putNs(colorArray, cDataTypeSigned, g, true); if(cComps>2) - GLBuffers.puts(colorArray, b); + Buffers.putNs(colorArray, cDataTypeSigned, b, true); padding(COLOR, cComps-3); } public void glColor4s(short r, short g, short b, short a) { checkSeal(false); growBuffer(COLOR); if(cComps>0) - GLBuffers.puts(colorArray, r); + Buffers.putNs(colorArray, cDataTypeSigned, r, true); if(cComps>1) - GLBuffers.puts(colorArray, g); + Buffers.putNs(colorArray, cDataTypeSigned, g, true); if(cComps>2) - GLBuffers.puts(colorArray, b); + Buffers.putNs(colorArray, cDataTypeSigned, b, true); if(cComps>3) - GLBuffers.puts(colorArray, a); + Buffers.putNs(colorArray, cDataTypeSigned, a, true); padding(COLOR, cComps-4); } public void glColor3f(float r, float g, float b) { checkSeal(false); growBuffer(COLOR); if(cComps>0) - GLBuffers.putf(colorArray, r); + Buffers.putNf(colorArray, cDataTypeSigned, r); if(cComps>1) - GLBuffers.putf(colorArray, g); + Buffers.putNf(colorArray, cDataTypeSigned, g); if(cComps>2) - GLBuffers.putf(colorArray, b); + Buffers.putNf(colorArray, cDataTypeSigned, b); padding(COLOR, cComps-3); } public void glColor4f(float r, float g, float b, float a) { checkSeal(false); growBuffer(COLOR); if(cComps>0) - GLBuffers.putf(colorArray, r); + Buffers.putNf(colorArray, cDataTypeSigned, r); if(cComps>1) - GLBuffers.putf(colorArray, g); + Buffers.putNf(colorArray, cDataTypeSigned, g); if(cComps>2) - GLBuffers.putf(colorArray, b); + Buffers.putNf(colorArray, cDataTypeSigned, b); if(cComps>3) - GLBuffers.putf(colorArray, a); + Buffers.putNf(colorArray, cDataTypeSigned, a); padding(COLOR, cComps-4); } @@ -647,60 +684,60 @@ public class ImmModeSink { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) - GLBuffers.putb(textCoordArray, x); + Buffers.putNb(textCoordArray, tDataTypeSigned, x, true); if(tComps>1) - GLBuffers.putb(textCoordArray, y); + Buffers.putNb(textCoordArray, tDataTypeSigned, y, true); padding(TEXTCOORD, tComps-2); } public void glTexCoord3b(byte x, byte y, byte z) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) - GLBuffers.putb(textCoordArray, x); + Buffers.putNb(textCoordArray, tDataTypeSigned, x, true); if(tComps>1) - GLBuffers.putb(textCoordArray, y); + Buffers.putNb(textCoordArray, tDataTypeSigned, y, true); if(tComps>2) - GLBuffers.putb(textCoordArray, z); + Buffers.putNb(textCoordArray, tDataTypeSigned, z, true); padding(TEXTCOORD, tComps-3); } public void glTexCoord2s(short x, short y) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) - GLBuffers.puts(textCoordArray, x); + Buffers.putNs(textCoordArray, tDataTypeSigned, x, true); if(tComps>1) - GLBuffers.puts(textCoordArray, y); + Buffers.putNs(textCoordArray, tDataTypeSigned, y, true); padding(TEXTCOORD, tComps-2); } public void glTexCoord3s(short x, short y, short z) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) - GLBuffers.puts(textCoordArray, x); + Buffers.putNs(textCoordArray, tDataTypeSigned, x, true); if(tComps>1) - GLBuffers.puts(textCoordArray, y); + Buffers.putNs(textCoordArray, tDataTypeSigned, y, true); if(tComps>2) - GLBuffers.puts(textCoordArray, z); + Buffers.putNs(textCoordArray, tDataTypeSigned, z, true); padding(TEXTCOORD, tComps-3); } public void glTexCoord2f(float x, float y) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) - GLBuffers.putf(textCoordArray, x); + Buffers.putNf(textCoordArray, tDataTypeSigned, x); if(tComps>1) - GLBuffers.putf(textCoordArray, y); + Buffers.putNf(textCoordArray, tDataTypeSigned, y); padding(TEXTCOORD, tComps-2); } public void glTexCoord3f(float x, float y, float z) { checkSeal(false); growBuffer(TEXTCOORD); if(tComps>0) - GLBuffers.putf(textCoordArray, x); + Buffers.putNf(textCoordArray, tDataTypeSigned, x); if(tComps>1) - GLBuffers.putf(textCoordArray, y); + Buffers.putNf(textCoordArray, tDataTypeSigned, y); if(tComps>2) - GLBuffers.putf(textCoordArray, z); + Buffers.putNf(textCoordArray, tDataTypeSigned, z); padding(TEXTCOORD, tComps-3); } @@ -1015,7 +1052,7 @@ public class ImmModeSink { final int bSizeN = nCount * nWidth; final int bSizeT = tCount * tWidth; - buffer = GLBuffers.newDirectByteBuffer( bSizeV + bSizeC + bSizeN + bSizeT ); + buffer = Buffers.newDirectByteBuffer( bSizeV + bSizeC + bSizeN + bSizeT ); vOffset = 0; if(bSizeV>0) { @@ -1090,19 +1127,19 @@ public class ImmModeSink { if ( reallocateBuffer(initialElementCount) ) { if(null!=_vertexArray) { _vertexArray.flip(); - GLBuffers.put(vertexArray, _vertexArray); + Buffers.put(vertexArray, _vertexArray); } if(null!=_colorArray) { _colorArray.flip(); - GLBuffers.put(colorArray, _colorArray); + Buffers.put(colorArray, _colorArray); } if(null!=_normalArray) { _normalArray.flip(); - GLBuffers.put(normalArray, _normalArray); + Buffers.put(normalArray, _normalArray); } if(null!=_textCoordArray) { _textCoordArray.flip(); - GLBuffers.put(textCoordArray, _textCoordArray); + Buffers.put(textCoordArray, _textCoordArray); } return true; } @@ -1114,56 +1151,69 @@ public class ImmModeSink { protected void padding(int type, int fill) { if ( sealed ) return; - Buffer dest = null; - + final Buffer dest; + final boolean dSigned; + final float v; + + switch (type) { case VERTEX: dest = vertexArray; + dSigned = vDataTypeSigned; + v = 0f; vElems++; break; case COLOR: dest = colorArray; + dSigned = cDataTypeSigned; + v = 1f; cElems++; break; case NORMAL: dest = normalArray; + dSigned = nDataTypeSigned; + v = 0f; nElems++; break; case TEXTCOORD: dest = textCoordArray; + dSigned = tDataTypeSigned; + v = 0f; tElems++; break; + default: throw new InternalError("Invalid type "+type); } if ( null==dest ) return; while((fill--)>0) { - GLBuffers.putb(dest, (byte)0); + Buffers.putNf(dest, dSigned, v); } } - final protected int glBufferUsage, initialElementCount; - final protected boolean useVBO; - protected int mode, modeOrig; + final private int glBufferUsage, initialElementCount; + final private boolean useVBO; + private int mode, modeOrig; - protected ByteBuffer buffer; - protected int vboName; + private ByteBuffer buffer; + private int vboName; - public static final int VERTEX = 0; - public static final int COLOR = 1; - public static final int NORMAL = 2; - public static final int TEXTCOORD = 3; + private static final int VERTEX = 0; + private static final int COLOR = 1; + private static final int NORMAL = 2; + private static final int TEXTCOORD = 3; - protected int vCount, cCount, nCount, tCount; // number of elements fit in each buffer - protected int vOffset, cOffset, nOffset, tOffset; - protected int vComps, cComps, nComps, tComps; // number of components for each elements [2, 3, 4] - protected int vElems, cElems, nElems, tElems; // number of used elements in each buffer - protected int vDataType, cDataType, nDataType, tDataType; - protected Buffer vertexArray, colorArray, normalArray, textCoordArray; - protected GLArrayDataWrapper vArrayData, cArrayData, nArrayData, tArrayData; + private int vCount, cCount, nCount, tCount; // number of elements fit in each buffer + private int vOffset, cOffset, nOffset, tOffset; // offset of specific array in common buffer + private int vElems, cElems, nElems, tElems; // number of used elements in each buffer + private final int vComps, cComps, nComps, tComps; // number of components for each elements [2, 3, 4] + private final int vDataType, cDataType, nDataType, tDataType; + private final boolean vDataTypeSigned, cDataTypeSigned, nDataTypeSigned, tDataTypeSigned; + private Buffer vertexArray, colorArray, normalArray, textCoordArray; + private GLArrayDataWrapper vArrayData, cArrayData, nArrayData, tArrayData; - protected boolean sealed, sealedGL, useGLSL; - protected boolean bufferEnabled, bufferWritten; + private boolean sealed, sealedGL, useGLSL; + private boolean bufferEnabled, bufferWritten; } } -- cgit v1.2.3 From f25682cabc5f421c3126e75833ae70b5a16e5b2e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 18 Oct 2012 15:15:58 +0200 Subject: FixedFuncPipeline: Cache current ShaderSelectionMode, update PMVMatrix according it's usage (update Mvi/Mvit only if lighting is being used) --- make/scripts/tests.sh | 1 - .../util/glsl/fixedfunc/FixedFuncPipeline.java | 37 +++++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7a768d68c..6398fa4cc 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -248,7 +248,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLBufferConversionNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java index 5a1678efa..f92c02403 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -91,8 +91,9 @@ public class FixedFuncPipeline { init(gl, mode, pmvMatrix); } - public ShaderSelectionMode getShaderSelectionMode() { return shaderSelectionMode; } - public void setShaderSelectionMode(ShaderSelectionMode mode) { shaderSelectionMode=mode; } + public ShaderSelectionMode getShaderSelectionMode() { return requestedShaderSelectionMode; } + public void setShaderSelectionMode(ShaderSelectionMode mode) { requestedShaderSelectionMode=mode; } + public ShaderSelectionMode getCurrentShaderSelectionMode() { return currentShaderSelectionMode; } public boolean verbose() { return verbose; } @@ -599,7 +600,7 @@ public class FixedFuncPipeline { } public void validate(GL2ES2 gl) { - if( ShaderSelectionMode.AUTO == shaderSelectionMode) { + if( ShaderSelectionMode.AUTO == requestedShaderSelectionMode) { final ShaderSelectionMode newMode; // pre-validate shader switch @@ -629,9 +630,19 @@ public class FixedFuncPipeline { } GLUniformData ud; - if( pmvMatrix.update() ) { + if( pmvMatrix.update() ) { ud = shaderState.getUniform(mgl_PMVMatrix); if(null!=ud) { + final FloatBuffer m; + if(ShaderSelectionMode.COLOR_TEXTURE8_LIGHT_PER_VERTEX == currentShaderSelectionMode || + ShaderSelectionMode.COLOR_LIGHT_PER_VERTEX== currentShaderSelectionMode ) { + m = pmvMatrix.glGetPMvMvitMatrixf(); + } else { + m = pmvMatrix.glGetPMvMatrixf(); + } + if(m != ud.getBuffer()) { + ud.setData(m); + } // same data object .. shaderState.uniform(gl, ud); } else { @@ -857,13 +868,13 @@ public class FixedFuncPipeline { } } - private ShaderProgram selectShaderProgram(GL2ES2 gl, ShaderSelectionMode mode) { - if(ShaderSelectionMode.AUTO == mode) { - mode = ShaderSelectionMode.COLOR; + private ShaderProgram selectShaderProgram(GL2ES2 gl, ShaderSelectionMode newMode) { + if(ShaderSelectionMode.AUTO == newMode) { + newMode = ShaderSelectionMode.COLOR; } - loadShader(gl, mode); + loadShader(gl, newMode); final ShaderProgram sp; - switch(mode) { + switch(newMode) { case COLOR_LIGHT_PER_VERTEX: sp = shaderProgramColorLight; break; @@ -883,6 +894,7 @@ public class FixedFuncPipeline { default: sp = shaderProgramColor; } + currentShaderSelectionMode = newMode; return sp; } @@ -891,11 +903,11 @@ public class FixedFuncPipeline { throw new GLException("PMVMatrix is null"); } this.pmvMatrix=pmvMatrix; - this.shaderSelectionMode = mode; + this.requestedShaderSelectionMode = mode; this.shaderState=new ShaderState(); this.shaderState.setVerbose(verbose); - shaderState.attachShaderProgram(gl, selectShaderProgram(gl, shaderSelectionMode), true); + shaderState.attachShaderProgram(gl, selectShaderProgram(gl, requestedShaderSelectionMode), true); // mandatory .. if(!shaderState.uniform(gl, new GLUniformData(mgl_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMvitMatrixf()))) { @@ -985,7 +997,8 @@ public class FixedFuncPipeline { private ShaderProgram shaderProgramColorLight; private ShaderProgram shaderProgramColorTexture8Light; - private ShaderSelectionMode shaderSelectionMode = ShaderSelectionMode.AUTO; + private ShaderSelectionMode requestedShaderSelectionMode = ShaderSelectionMode.AUTO; + private ShaderSelectionMode currentShaderSelectionMode = requestedShaderSelectionMode; // uniforms .. private static final String mgl_PMVMatrix = "mgl_PMVMatrix"; // m4fv[4] - P, Mv, Mvi and Mvit -- cgit v1.2.3 From 416c7fc1b90cd7b34c251268bb83ebeea61d17d6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 19 Oct 2012 07:46:31 +0200 Subject: NEWT / BCM-VC-IV: Fix transparency according to given capabilities Tested manual w/ TestGearsES2NEWT on Raspberry Pi --- make/scripts/tests.sh | 4 ++-- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 17 ++++++++--------- src/newt/native/bcm_vc_iv.c | 21 ++++++++++++++++++--- .../junit/jogl/demos/es2/newt/TestGearsES2NEWT.java | 8 ++++++++ 4 files changed, 36 insertions(+), 14 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6398fa4cc..85b439437 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -245,7 +245,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -405,7 +405,7 @@ function testawtswt() { # Misc Utils # #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index 7b8d2e958..21fbea9ac 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -53,20 +53,19 @@ public class WindowDriver extends WindowImpl { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } - // FIXME: Hack - Native BCM_VC_IV code CreateWindow() uses the default alpha value setting, - // which is alpha:8 ! Hence we require to chose alpha from the egl configurations. - // TODO: Properly select the alpha mode in CreateWindow()! This will allow this hack. - final Capabilities capsChosen = (Capabilities) capsRequested.cloneMutable(); - capsChosen.setAlphaBits(1); final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration( - capsChosen, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); + capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED); if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); } + final Capabilities chosenCaps = (Capabilities) cfg.getChosenCapabilities(); + // FIXME: Pass along opaque flag, since EGL doesn't determine it + if(capsRequested.isBackgroundOpaque() != chosenCaps.isBackgroundOpaque()) { + chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque()); + } setGraphicsConfiguration(cfg); - - nativeWindowHandle = CreateWindow(getWidth(), getHeight()); + nativeWindowHandle = CreateWindow(getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); if (nativeWindowHandle == 0) { throw new NativeWindowException("Error creating egl window: "+cfg); } @@ -139,7 +138,7 @@ public class WindowDriver extends WindowImpl { // protected static native boolean initIDs(); - private native long CreateWindow(int width, int height); + private native long CreateWindow(int width, int height, boolean opaque, int alphaBits); private native long RealizeWindow(long eglWindowHandle); private native int CloseWindow(long eglWindowHandle, long userData); private native void setVisible0(long eglWindowHandle, boolean visible); diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index e41745e14..0093da437 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -101,8 +101,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative if( graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height) >= 0 ) { DBG_PRINT( "BCM.Screen initNative ok %dx%d\n", screen_width, screen_height ); (*env)->CallVoidMethod(env, obj, setScreenSizeID, (jint) screen_width, (jint) screen_height); + } else { + DBG_PRINT( "BCM.Screen initNative failed\n" ); } - DBG_PRINT( "BCM.Screen initNative failed\n" ); } /** @@ -132,7 +133,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID } JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow - (JNIEnv *env, jobject obj, jint width, jint height) + (JNIEnv *env, jobject obj, jint width, jint height, jboolean opaque, jint alphaBits) { int32_t success = 0; VC_RECT_T dst_rect; @@ -148,12 +149,26 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin src_rect.width = width << 16; src_rect.height = height << 16; + VC_DISPMANX_ALPHA_T dispman_alpha; + memset(&dispman_alpha, 0x0, sizeof(VC_DISPMANX_ALPHA_T)); + + if( JNI_TRUE == opaque ) { + dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS ; + dispman_alpha.opacity = 0xFF; + dispman_alpha.mask = 0; + } else { + dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE ; + dispman_alpha.opacity = 0xFF; + dispman_alpha.mask = 0xFF; + } + DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */); DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display, 0/*layer*/, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, - 0 /*alpha TODO*/, 0/*clamp*/, 0/*transform*/); + &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); + EGL_DISPMANX_WINDOW_T * nativeWindowPtr = calloc(1, sizeof(EGL_DISPMANX_WINDOW_T)); nativeWindowPtr->element = dispman_element; nativeWindowPtr->width = width; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index a79c924d6..1620985c1 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -75,6 +75,7 @@ public class TestGearsES2NEWT extends UITestCase { static long duration = 500; // ms static boolean opaque = true; + static int forceAlpha = -1; static boolean undecorated = false; static boolean alwaysOnTop = false; static boolean fullscreen = false; @@ -257,6 +258,9 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("Loop "+i+"/"+loops); GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2()); caps.setBackgroundOpaque(opaque); + if(-1 < forceAlpha) { + caps.setAlphaBits(forceAlpha); + } runTestGL(caps, undecorated); if(loop_shutdown) { GLProfile.shutdown(); @@ -274,6 +278,9 @@ public class TestGearsES2NEWT extends UITestCase { duration = MiscUtils.atol(args[i], duration); } else if(args[i].equals("-translucent")) { opaque = false; + } else if(args[i].equals("-forceAlpha")) { + i++; + forceAlpha = MiscUtils.atoi(args[i], 0); } else if(args[i].equals("-undecorated")) { undecorated = true; } else if(args[i].equals("-atop")) { @@ -328,6 +335,7 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("size "+wsize); System.err.println("screen "+screenIdx); System.err.println("translucent "+(!opaque)); + System.err.println("forceAlpha "+forceAlpha); System.err.println("undecorated "+undecorated); System.err.println("atop "+alwaysOnTop); System.err.println("fullscreen "+fullscreen); -- cgit v1.2.3 From 5bdd283a9c3d0c656c859d499476173e2f609839 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 22 Oct 2012 18:54:19 +0200 Subject: FixedFuncPipeline GL_POINTS: Fix gl_PointSize (attribute data format), Add GL_POINT_SOFT and dist/fade attenuation (Adding basic POINT unit tests) gl_PointSize (and all other uniform array elems) was not propagated due to wrong usage of GLUniformData component param. Due to efficiency, we use vec4[2] now and #defines in shader to easy readability. GL_POINT_SOFT uses gl_PointCoord to determnine inside/outside circle position while adding a seam of 10% in/out. This almost matches 'other' implementations and gives a nice smooth circle. !GL_POINT_SOFT produces a proper square (billboard). Point-Vertex shader takes dist/fade attentuation into account. --- make/scripts/tests.sh | 3 +- .../util/glsl/fixedfunc/FixedFuncPipeline.java | 119 ++++-------- .../util/glsl/fixedfunc/shaders/FixedFuncPoints.fp | 29 ++- .../util/glsl/fixedfunc/shaders/FixedFuncPoints.vp | 25 ++- .../util/glsl/fixedfunc/shaders/mgl_uniform.glsl | 15 +- .../test/junit/jogl/acore/TestPointsNEWT.java | 138 ++++++++++++++ .../opengl/test/junit/jogl/demos/PointsDemo.java | 48 +++++ .../test/junit/jogl/demos/es1/PointsDemoES1.java | 155 +++++++++++++++ .../test/junit/jogl/demos/es2/PointsDemoES2.java | 207 +++++++++++++++++++++ .../junit/jogl/demos/es2/shader/PointsShader.fp | 40 ++++ .../junit/jogl/demos/es2/shader/PointsShader.vp | 42 +++++ 11 files changed, 723 insertions(+), 98 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/PointsDemo.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/PointsDemoES1.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/PointsShader.fp create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/PointsShader.vp (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 85b439437..0d16ec002 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -245,7 +245,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -265,6 +265,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java index a5ab684b6..8e0091e4c 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -357,19 +357,19 @@ public class FixedFuncPipeline { // Point Sprites // public void glPointSize(float size) { - pointParams1.put(0, size); + pointParams.put(0, size); pointParamsDirty = true; } public void glPointParameterf(int pname, float param) { switch(pname) { case GL2ES1.GL_POINT_SIZE_MIN: - pointParams1.put(2, param); + pointParams.put(2, param); break; case GL2ES1.GL_POINT_SIZE_MAX: - pointParams1.put(3, param); + pointParams.put(3, param); break; case GL2ES2.GL_POINT_FADE_THRESHOLD_SIZE: - pointParams2.put(3, param); + pointParams.put(4+3, param); break; } pointParamsDirty = true; @@ -377,9 +377,9 @@ public class FixedFuncPipeline { public void glPointParameterfv(int pname, float[] params, int params_offset) { switch(pname) { case GL2ES1.GL_POINT_DISTANCE_ATTENUATION: - pointParams2.put(0, params[params_offset + 0]); - pointParams2.put(1, params[params_offset + 1]); - pointParams2.put(2, params[params_offset + 2]); + pointParams.put(4+0, params[params_offset + 0]); + pointParams.put(4+1, params[params_offset + 1]); + pointParams.put(4+2, params[params_offset + 2]); break; } pointParamsDirty = true; @@ -388,9 +388,9 @@ public class FixedFuncPipeline { final int o = params.position(); switch(pname) { case GL2ES1.GL_POINT_DISTANCE_ATTENUATION: - pointParams2.put(0, params.get(o + 0)); - pointParams2.put(1, params.get(o + 1)); - pointParams2.put(2, params.get(o + 2)); + pointParams.put(4+0, params.get(o + 0)); + pointParams.put(4+1, params.get(o + 1)); + pointParams.put(4+2, params.get(o + 2)); break; } pointParamsDirty = true; @@ -399,68 +399,24 @@ public class FixedFuncPipeline { // private int[] pointTexObj = new int[] { 0 }; private void glDrawPoints(GL2ES2 gl, GLRunnable2 glDrawAction, Object args) { - /** - * FIXME: - * - * Event thought it works using a texture and gl_PointCoord in frag shader, - * I don't see the point here (lol) if gl_PointSize must be 1.0 in vert shader .. - * otherwise nothing is seen on ES2.0. - * On Desktop POINTS are always shown as 1 pixel sized points! - - final int prevActiveTextureUnit = activeTextureUnit; - final int prevBoundTextureObject = this.boundTextureObject[0]; - glActiveTexture(GL.GL_TEXTURE0); - gl.glActiveTexture(GL.GL_TEXTURE0); - if( 0 == pointTexObj[0] ) { - gl.glGenTextures(1, pointTexObj, 0); - glBindTexture(GL.GL_TEXTURE_2D, pointTexObj[0]); - gl.glBindTexture(GL.GL_TEXTURE_2D, pointTexObj[0]); - final int sz = 32; - ByteBuffer bb = Buffers.newDirectByteBuffer(sz*sz*4); - for(int i=sz*sz*4-1; 0<=i; i--) { - bb.put(i, (byte)0xff); - } - glTexImage2D(GL.GL_TEXTURE_2D, GL.GL_RGBA, GL.GL_RGBA); - gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA, sz, sz, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, bb); - gl.glTexParameteri ( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR ); - gl.glTexParameteri ( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR ); - gl.glTexParameteri ( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT ); - gl.glTexParameteri ( GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT ); - } else { - glBindTexture(GL.GL_TEXTURE_2D, pointTexObj[0]); - gl.glBindTexture(GL.GL_TEXTURE_2D, pointTexObj[0]); + if(gl.isGL2GL3()) { + gl.glEnable(GL2GL3.GL_VERTEX_PROGRAM_POINT_SIZE); + } + if(gl.isGL2ES1()) { + gl.glEnable(GL2ES1.GL_POINT_SPRITE); } - final boolean wasEnabled = glEnableTexture(true, 0); - */ - loadShaderPoints(gl); shaderState.attachShaderProgram(gl, shaderProgramPoints, true); validate(gl, false); // sync uniforms - if(gl.isGL2GL3()) { - // if(gl.isGL2()) { - // gl.glEnable(GL2.GL_POINT_SPRITE); - //} - gl.glEnable(GL2GL3.GL_VERTEX_PROGRAM_POINT_SIZE); - } glDrawAction.run(gl, args); + if(gl.isGL2ES1()) { + gl.glDisable(GL2ES1.GL_POINT_SPRITE); + } if(gl.isGL2GL3()) { gl.glDisable(GL2GL3.GL_VERTEX_PROGRAM_POINT_SIZE); - // if(gl.isGL2()) { - // gl.glDisable(GL2.GL_POINT_SPRITE); - //} } - /** - if( 0 != prevBoundTextureObject ) { - glBindTexture(GL.GL_TEXTURE_2D, prevBoundTextureObject); - gl.glBindTexture(GL.GL_TEXTURE_2D, prevBoundTextureObject); - } - glActiveTexture(GL.GL_TEXTURE0+prevActiveTextureUnit); - gl.glActiveTexture(GL.GL_TEXTURE0+prevActiveTextureUnit); - if(!wasEnabled) { - glEnableTexture(false, 0); - } */ shaderState.attachShaderProgram(gl, selectShaderProgram(gl, currentShaderSelectionMode), true); } private static final GLRunnable2 glDrawArraysAction = new GLRunnable2() { @@ -712,9 +668,13 @@ public class FixedFuncPipeline { return false; case GL2ES1.GL_POINT_SMOOTH: - pointParams1.put(1, enable ? 1.0f : 0.0f); + pointParams.put(1, enable ? 1.0f : 0.0f); pointParamsDirty = true; return false; + + case GL2ES1.GL_POINT_SPRITE: + // gl_PointCoord always enabled + return false; } int light = cap - GLLightingFunc.GL_LIGHT0; @@ -859,11 +819,13 @@ public class FixedFuncPipeline { if(colorVAEnabledDirty) { ud = shaderState.getUniform(mgl_ColorEnabled); if(null!=ud) { - int ca = (shaderState.isVertexAttribArrayEnabled(GLPointerFuncUtil.mgl_Color)==true)?1:0; + int ca = true == shaderState.isVertexAttribArrayEnabled(GLPointerFuncUtil.mgl_Color) ? 1 : 0 ; if(ca!=ud.intValue()) { ud.setData(ca); shaderState.uniform(gl, ud); } + } else { + throw new GLException("Failed to update: mgl_ColorEnabled"); } colorVAEnabledDirty = false; } @@ -891,17 +853,11 @@ public class FixedFuncPipeline { alphaTestDirty = false; } if(pointParamsDirty) { - /** FIXME - ud = shaderState.getUniform(mgl_PointParams1); + ud = shaderState.getUniform(mgl_PointParams); if(null!=ud) { // same data object shaderState.uniform(gl, ud); } - ud = shaderState.getUniform(mgl_PointParams2); - if(null!=ud) { - // same data object - shaderState.uniform(gl, ud); - } */ pointParamsDirty = false; } @@ -1012,9 +968,9 @@ public class FixedFuncPipeline { } final ShaderCode vp = ShaderCode.create( gl, GL2ES2.GL_VERTEX_SHADER, shaderRootClass, shaderSrcRoot, - shaderBinRoot, vertexPointsFileDef, true); + shaderBinRoot, shaderPointFileDef, true); final ShaderCode fp = ShaderCode.create( gl, GL2ES2.GL_FRAGMENT_SHADER, shaderRootClass, shaderSrcRoot, - shaderBinRoot, fragmentPointsFileDef, true); + shaderBinRoot, shaderPointFileDef, true); customizeShader(gl, vp, fp, constMaxTextures2); shaderProgramPoints = new ShaderProgram(); shaderProgramPoints.add(vp); @@ -1173,8 +1129,7 @@ public class FixedFuncPipeline { shaderState.uniform(gl, new GLUniformData(mgl_CullFace, cullFace)); */ shaderState.uniform(gl, new GLUniformData(mgl_AlphaTestFunc, alphaTestFunc)); shaderState.uniform(gl, new GLUniformData(mgl_AlphaTestRef, alphaTestRef)); - shaderState.uniform(gl, new GLUniformData(mgl_PointParams1, 4, pointParams1)); - shaderState.uniform(gl, new GLUniformData(mgl_PointParams2, 4, pointParams2)); + shaderState.uniform(gl, new GLUniformData(mgl_PointParams, 4, pointParams)); for(int i=0; i @@ -1304,8 +1256,7 @@ public class FixedFuncPipeline { private static final String vertexColorLightFileDef = "FixedFuncColorLight"; private static final String fragmentColorFileDef = "FixedFuncColor"; private static final String fragmentColorTextureFileDef = "FixedFuncColorTexture"; - private static final String vertexPointsFileDef = "FixedFuncPoints"; - private static final String fragmentPointsFileDef = vertexPointsFileDef; + private static final String shaderPointFileDef = "FixedFuncPoints"; private static final String shaderSrcRootDef = "shaders" ; private static final String shaderBinRootDef = "shaders/bin" ; diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncPoints.fp b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncPoints.fp index beca47bc1..6185e96ef 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncPoints.fp +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncPoints.fp @@ -6,11 +6,34 @@ #include mgl_uniform.glsl #include mgl_varying.glsl +// #define TEST 1 + void main (void) { - // FIXME: Since gl_Points must be 1.0 (otherwise no points) - // don't see reason for fetching texture color. - // gl_FragColor = frontColor * texture2D(mgl_Texture0, gl_PointCoord); gl_FragColor = frontColor; + + if( pointSmooth > 0.5 ) { + // smooth (AA) + const float border = 0.90; // take/give 10% for AA + + // origin to 0/0, [-1/-1 .. 1/1] + vec2 pointPos = 2.0 * gl_PointCoord - 1.0 ; + float r = length( pointPos ); // one-circle sqrt(x * x + y * y), range: in-circle [0..1], out >1 + float r1 = 1.0 - ( step(border, r) * 10.0 * ( r - border ) ) ; // [0..1] + #ifndef TEST + if( r1 < 0.0 ) { + discard; + } + #endif + + #ifndef TEST + gl_FragColor.a *= r1; + #else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + gl_FragColor.r = r1 < 0.0 ? 1.0 : 0.0; + gl_FragColor.g = r > 1.0 ? 1.0 : 0.0; + gl_FragColor.b = r > border ? 1.0 : 0.0; + #endif + } } diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncPoints.vp b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncPoints.vp index 6d6a3a982..64732dc9e 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncPoints.vp +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncPoints.vp @@ -9,17 +9,26 @@ void main(void) { - if(mgl_ColorEnabled>0) { - frontColor=mgl_Color; + if( mgl_ColorEnabled > 0 ) { + frontColor = mgl_Color; } else { - frontColor=mgl_ColorStatic; + frontColor = mgl_ColorStatic; } - // FIXME: ES2 .. doesn't work, but even on desktop - // no big points! - // gl_PointSize = mgl_PointParams1[0]; - gl_PointSize = 1.0; + vec4 eyeCoord = mgl_PMVMatrix[1] * mgl_Vertex; + gl_Position = mgl_PMVMatrix[0] * eyeCoord; - gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * vec4(mgl_Vertex.xyz, 1.0); + float dist = distance(eyeCoord, vec4(0.0, 0.0, 0.0, 1.0)); + float atten = sqrt( 1.0 / ( pointDistanceConstantAtten + + ( pointDistanceLinearAtten + + pointDistanceQuadraticAtten * dist + ) * dist + ) + ); + float size = clamp(pointSize * atten, pointSizeMin, pointSizeMax); + gl_PointSize = max(size, pointFadeThresholdSize); + + float fade = min(size, pointFadeThresholdSize) / pointFadeThresholdSize; + frontColor.a *= fade * fade; } diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_uniform.glsl b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_uniform.glsl index fd24a953d..5029e4bd8 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_uniform.glsl +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/mgl_uniform.glsl @@ -11,8 +11,19 @@ uniform LOWP int mgl_ColorEnabled; uniform vec4 mgl_ColorStatic; uniform LOWP int mgl_AlphaTestFunc; uniform float mgl_AlphaTestRef; -uniform MEDIUMP float mgl_PointParams1[4]; // sz, smooth, attnMinSz, attnMaxSz -uniform MEDIUMP float mgl_PointParams2[4]; // attnCoeff(3), attnAlphaTs + +// [0].rgba: size, smooth, attnMinSz, attnMaxSz +// [1].rgba: attnCoeff(3), attnFadeTs +uniform MEDIUMP vec4 mgl_PointParams[2]; + +#define pointSize (mgl_PointParams[0].r) +#define pointSmooth (mgl_PointParams[0].g) +#define pointSizeMin (mgl_PointParams[0].b) +#define pointSizeMax (mgl_PointParams[0].a) +#define pointDistanceConstantAtten (mgl_PointParams[1].r) +#define pointDistanceLinearAtten (mgl_PointParams[1].g) +#define pointDistanceQuadraticAtten (mgl_PointParams[1].b) +#define pointFadeThresholdSize (mgl_PointParams[1].a) // uniform LOWP int mgl_CullFace; // ES2 supports CullFace implicit .. #if MAX_TEXTURE_UNITS > 0 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java new file mode 100644 index 000000000..37994914e --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java @@ -0,0 +1,138 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import com.jogamp.opengl.test.junit.jogl.demos.PointsDemo; +import com.jogamp.opengl.test.junit.jogl.demos.es1.PointsDemoES1; +import com.jogamp.opengl.test.junit.jogl.demos.es2.PointsDemoES2; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +public class TestPointsNEWT extends UITestCase { + static int width, height; + + @BeforeClass + public static void initClass() { + width = 512; + height = 512; + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL0(GLCapabilities caps, PointsDemo demo) throws InterruptedException { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setTitle(getSimpleTestName(".")); + + glWindow.addGLEventListener(demo); + final SnapshotGLEventListener snap = new SnapshotGLEventListener(); + snap.setPostSNDetail(demo.getClass().getSimpleName()); + glWindow.addGLEventListener(snap); + + glWindow.setSize(width, height); + glWindow.setVisible(true); + + demo.setSmoothPoints(false); + snap.setMakeSnapshot(); + snap.setPostSNDetail("flat"); + glWindow.display(); + + demo.setSmoothPoints(true); + snap.setMakeSnapshot(); + snap.setPostSNDetail("smooth"); + glWindow.display(); + + demo.setPointParams(2f, 40f, 0.01f, 0.0f, 0.01f, 1f); + snap.setMakeSnapshot(); + snap.setPostSNDetail("attn0"); + glWindow.display(); + + glWindow.removeGLEventListener(demo); + + glWindow.destroy(); + } + + protected void runTestGL(GLCapabilities caps, PointsDemo demo, boolean forceFFPEmu) throws InterruptedException { + // final PointsDemoES2 demo01 = new PointsDemoES2(); + runTestGL0(caps, demo); + } + + @Test + public void test01FFP__GL2() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); + runTestGL(caps, new PointsDemoES1(), false); + } + + @Test + public void test02FFP__ES1() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GLES1)) { System.err.println("GLES1 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1)); + runTestGL(caps, new PointsDemoES1(), false); + } + + @Test + public void test11GLSL_GL2() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); + runTestGL(caps, new PointsDemoES2(), false); + } + + @Test + public void test12GLSL_ES2() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + runTestGL(caps, new PointsDemoES2(), false); // should be FFPEmu implicit + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i=0; i--) { + gl.glPointSize(pointSizes[i]); + gl.glDrawArrays(GL.GL_POINTS, i, 1); + } + + vertices.enableBuffer(gl, false); + } + + public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { + // Thread.dumpStack(); + GL2ES1 gl = glad.getGL().getGL2ES1(); + + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } + + // Set location in front of camera + gl.glMatrixMode(PMVMatrix.GL_PROJECTION); + gl.glLoadIdentity(); + glu.gluPerspective(45.0F, ( (float) width / (float) height ) / 1.0f, 1.0F, 100.0F); + //gl.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f); + } + + public void dispose(GLAutoDrawable glad) { + GL2ES1 gl = glad.getGL().getGL2ES1(); + vertices.destroy(gl); + vertices = null; + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java new file mode 100644 index 000000000..8c6d7e180 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java @@ -0,0 +1,207 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2; + +import java.nio.FloatBuffer; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.test.junit.jogl.demos.PointsDemo; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLUniformData; + +public class PointsDemoES2 extends PointsDemo { + ShaderState st; + PMVMatrix pmvMatrix; + GLUniformData pmvMatrixUniform; + GLArrayDataServer vertices ; + GLArrayDataServer pointSizes ; + private int swapInterval = 0; + final int edge = 8; // 8*8 + /** vec4[2]: { (sz, smooth, attnMinSz, attnMaxSz), (attnCoeff(3), attnFadeTs) } */ + private static final String mgl_PointParams = "mgl_PointParams"; + + /** ( pointSize, pointSmooth, attn. pointMinSize, attn. pointMaxSize ) , ( attenuation coefficients 1f 0f 0f, attenuation fade theshold 1f ) */ + private final FloatBuffer pointParams = Buffers.newDirectFloatBuffer(new float[] { 1.0f, 0.0f, 0.0f, 4096.0f, 1.0f, 0.0f, 0.0f, 1.0f }); + + public PointsDemoES2(int swapInterval) { + this.swapInterval = swapInterval; + } + + public PointsDemoES2() { + this.swapInterval = 1; + } + + public void setSmoothPoints(boolean v) { + pointParams.put(1, v ? 1.0f : 0.0f); + } + + public void setPointParams(float minSize, float maxSize, float distAttenConst, float distAttenLinear, float distAttenQuadratic, float fadeThreshold) { + pointParams.put(2, minSize); + pointParams.put(3, maxSize); + pointParams.put(4+0, distAttenConst); + pointParams.put(4+1, distAttenLinear); + pointParams.put(4+2, distAttenQuadratic); + pointParams.put(4+3, fadeThreshold); + } + + public void init(GLAutoDrawable glad) { + GL2ES2 gl = glad.getGL().getGL2ES2(); + + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none")); + System.err.println("GL Profile: "+gl.getGLProfile()); + + st = new ShaderState(); + st.setVerbose(true); + final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader", + "shader/bin", "PointsShader", false); + final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", + "shader/bin", "PointsShader", false); + final ShaderProgram sp0 = new ShaderProgram(); + sp0.add(gl, vp0, System.err); + sp0.add(gl, fp0, System.err); + st.attachShaderProgram(gl, sp0, true); + + // setup mgl_PMVMatrix + pmvMatrix = new PMVMatrix(); + pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + + st.uniform(gl, new GLUniformData(mgl_PointParams, 4, pointParams)); + + final GLUniformData colorStaticUniform = new GLUniformData("mgl_ColorStatic", 4, Buffers.newDirectFloatBuffer(new float[] { 1.0f, 1.0f, 1.0f, 1.0f }) ); + st.uniform(gl, colorStaticUniform); + st.ownUniform(colorStaticUniform); + + // Allocate Vertex Array + vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, edge*edge, GL.GL_STATIC_DRAW); + pointSizes = GLArrayDataServer.createGLSL("mgl_PointSize", 1, GL.GL_FLOAT, false, edge*edge, GL.GL_STATIC_DRAW); + for(int i=0; i 0.5 ) { + // smooth (AA) + const float border = 0.90; // take/give 10% for AA + + // origin to 0/0, [-1/-1 .. 1/1] + vec2 pointPos = 2.0 * gl_PointCoord - 1.0 ; + float r = length( pointPos ); // one-circle sqrt(x * x + y * y), range: in-circle [0..1], out >1 + float r1 = 1.0 - ( step(border, r) * 10.0 * ( r - border ) ) ; // [0..1] + #ifndef TEST + if( r1 < 0.0 ) { + discard; + } + #endif + + #ifndef TEST + gl_FragColor.a *= r1; + #else + gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); + gl_FragColor.r = r1 < 0.0 ? 1.0 : 0.0; + gl_FragColor.g = r > 1.0 ? 1.0 : 0.0; + gl_FragColor.b = r > border ? 1.0 : 0.0; + #endif + } +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/PointsShader.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/PointsShader.vp new file mode 100644 index 000000000..5043a652b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/PointsShader.vp @@ -0,0 +1,42 @@ + +uniform vec4 mgl_ColorStatic; +uniform mat4 mgl_PMVMatrix[4]; // P, Mv, Mvi and Mvit (transpose(inverse(ModelView)) == normalMatrix) + +// [0].rgba: 0, smooth, attnMinSz, attnMaxSz +// [1].rgba: attnCoeff(3), attnFadeTs +uniform vec4 mgl_PointParams[2]; + +#define pointSmooth (mgl_PointParams[0].g) +#define pointSizeMin (mgl_PointParams[0].b) +#define pointSizeMax (mgl_PointParams[0].a) +#define pointDistanceConstantAtten (mgl_PointParams[1].r) +#define pointDistanceLinearAtten (mgl_PointParams[1].g) +#define pointDistanceQuadraticAtten (mgl_PointParams[1].b) +#define pointFadeThresholdSize (mgl_PointParams[1].a) + +attribute vec4 mgl_Vertex; +attribute float mgl_PointSize; + +varying vec4 frontColor; + +void main(void) +{ + frontColor = mgl_ColorStatic; + + vec4 eyeCoord = mgl_PMVMatrix[1] * mgl_Vertex; + gl_Position = mgl_PMVMatrix[0] * eyeCoord; + + float dist = distance(eyeCoord, vec4(0.0, 0.0, 0.0, 1.0)); + float atten = sqrt( 1.0 / ( pointDistanceConstantAtten + + ( pointDistanceLinearAtten + + pointDistanceQuadraticAtten * dist + ) * dist + ) + ); + float size = clamp(mgl_PointSize * atten, pointSizeMin, pointSizeMax); + gl_PointSize = max(size, pointFadeThresholdSize); + + float fade = min(size, pointFadeThresholdSize) / pointFadeThresholdSize; + frontColor.a *= fade * fade; +} + -- cgit v1.2.3 From 133d7b82d47b2918af042944158e9b09e2663855 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 23 Oct 2012 17:31:08 +0200 Subject: Fix regression of commit 40d01bef2a1db44533472c37961aabbef68de644: Test for fourth element was invalid --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0d16ec002..8a9607a30 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -265,7 +265,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -389,7 +389,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageNEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index 888fa526a..f01896b96 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -1222,7 +1222,7 @@ public class ImmModeSink { final Buffer dest; final boolean dSigned; - final int e; + final int e; // either 0 or 1 switch (type) { case VERTEX: @@ -1258,7 +1258,7 @@ public class ImmModeSink { fill--; Buffers.putNf(dest, dSigned, 0f); } - if( e > 0 ) { + if( fill > 0 ) { // e == 1, add missing '1f end component' Buffers.putNf(dest, dSigned, 1f); } } -- cgit v1.2.3 From f8237ac370585bd454675a84ee6d81da3f74d765 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 23 Oct 2012 19:28:37 +0200 Subject: tests.sh: TestPointsNEWT --- make/scripts/tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8a9607a30..0d16ec002 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -265,7 +265,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -389,7 +389,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageNEWT $* -- cgit v1.2.3 From b008de41549e38aebdfcb7b094046235a8dde72f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 26 Oct 2012 16:43:13 +0200 Subject: Fix Bug 601 - Auto-Repeat Behavior: Adding unit tests for typed key order w/ and w/o auto repeat. Incl. fix for Windows. Auto-Repeat tests recognizes whether auto-repeat could be triggered by AWT Robot. The latter is not possible on Windows, hence manual testing was required on this platform. Impact: X11, Windows and OSX produce proper key sequence incl. auto-repeat modifier mask. --- make/scripts/java-win64-dbg.bat | 2 +- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 7 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 11 + .../classes/com/jogamp/newt/event/NEWTEvent.java | 6 +- .../jogamp/newt/driver/windows/WindowDriver.java | 82 +++--- src/newt/native/X11Display.c | 2 + .../junit/newt/TestKeyEventAutoRepeatNEWT.java | 309 +++++++++++++++++++++ .../test/junit/newt/TestKeyEventOrderNEWT.java | 219 +++++++++++++++ .../opengl/test/junit/util/AWTFocusAdapter.java | 11 +- .../opengl/test/junit/util/AWTKeyAdapter.java | 49 +++- .../opengl/test/junit/util/AWTMouseAdapter.java | 27 +- .../opengl/test/junit/util/AWTRobotUtil.java | 51 +++- .../test/junit/util/AWTWindowFocusAdapter.java | 11 +- .../opengl/test/junit/util/EventCountAdapter.java | 9 + .../test/junit/util/InputEventCountAdapter.java | 5 + .../test/junit/util/KeyEventCountAdapter.java | 38 +++ .../opengl/test/junit/util/NEWTFocusAdapter.java | 11 +- .../opengl/test/junit/util/NEWTKeyAdapter.java | 64 ++++- .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 103 +++++++ .../opengl/test/junit/util/NEWTMouseAdapter.java | 28 +- 21 files changed, 978 insertions(+), 71 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventAutoRepeatNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java create mode 100644 src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java (limited to 'make/scripts') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 07722c78e..5dc34f42d 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -39,7 +39,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Dnewt.debug.Window" -set D_ARGS="-Dnewt.debug.Window.KeyEvent" +REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 9ffbcd6d3..f67bda373 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -19,7 +19,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLPro REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* @@ -32,6 +32,8 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSi REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0d16ec002..047c0ed63 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -65,7 +65,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" - #D_ARGS="-Djogl.debug.GLSLCode" + #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.FixedFuncPipeline" @@ -265,7 +265,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -274,6 +274,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -374,6 +375,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* +testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 7daaeada6..b6f4264f5 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -48,6 +48,17 @@ package com.jogamp.newt.event; * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. *

    + *

    + * Auto-Repeat shall behave as follow: + *

    +    D = pressed, U = released, T = typed
    +    0 = normal, 1 = auto-repeat
    +
    +    D(0), [ U(1), T(1), D(1), U(1) T(1) ..], U(0) T(0)
    + * 
    + * The idea is if you mask out auto-repeat in your event listener + * you just get one long pressed key D/U/T triple. + *

    */ @SuppressWarnings("serial") public class KeyEvent extends InputEvent diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index fd5b69ccc..9d8d92ff6 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -161,11 +161,7 @@ public class NEWTEvent extends java.util.EventObject { return sb.append("NEWTEvent[sys:").append(isSystemEvent()).append(", source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); } - public static String toHexString(int hex) { + static String toHexString(int hex) { return "0x" + Integer.toHexString(hex); } - - public static String toHexString(long hex) { - return "0x" + Long.toHexString(hex); - } } diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 71437c461..c211bac61 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -279,61 +279,73 @@ public class WindowDriver extends WindowImpl { return keyCode; } private int lastPressedKeyCode = 0; + private char lastTypedKeyChar = 0; private int pressedKeyBalance = 0; private int autoRepeat = 0; - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + if( send ) { + super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + } else { + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); + } + } + + private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", mods "+toHexString(modifiers)); + // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); + + // Reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED + // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - // reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED + if( 0 != autoRepeat ) { + // AR out - send out missing PRESSED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | autoRepeat, keyCode, lastTypedKeyChar); + } + autoRepeat = 0; + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + if( 0 != lastTypedKeyChar ) { + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, lastTypedKeyChar); + lastTypedKeyChar = 0; + } break; case KeyEvent.EVENT_KEY_PRESSED: - if(pressedKeyBalance > 1) { - // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. - // Since reordering already injects RELEASE, we only need to set the AUTOREPEAT_MASK. + if( pressedKeyBalance > 1 ) { pressedKeyBalance--; - autoRepeat |= InputEvent.AUTOREPEAT_MASK; + if ( 0 == autoRepeat ) { + // AR in - skip already send PRESSED + autoRepeat = InputEvent.AUTOREPEAT_MASK; + } else { + emitKeyEvent(send, wait, eventType, modifiers | autoRepeat, keyCode, (char)-1); + } } else { - autoRepeat &= ~InputEvent.AUTOREPEAT_MASK; + autoRepeat = 0; + emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); } - super.sendKeyEvent(eventType, modifiers | autoRepeat, keyCode, (char)-1); break; case KeyEvent.EVENT_KEY_TYPED: - modifiers |= autoRepeat; - super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); - super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + if( 0 == autoRepeat ) { + lastTypedKeyChar = keyChar; + } else { + modifiers |= autoRepeat; + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + } break; } } + @Override + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); + } + @Override public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); - switch(eventType) { - case KeyEvent.EVENT_KEY_RELEASED: - // reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED - break; - case KeyEvent.EVENT_KEY_PRESSED: - if(pressedKeyBalance > 1) { - // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. - // Since reordering already injects RELEASE, we only need to set the AUTOREPEAT_MASK. - pressedKeyBalance--; - autoRepeat |= InputEvent.AUTOREPEAT_MASK; - } else { - autoRepeat &= ~InputEvent.AUTOREPEAT_MASK; - } - super.enqueueKeyEvent(wait, eventType, modifiers | autoRepeat, keyCode, (char)-1); - break; - case KeyEvent.EVENT_KEY_TYPED: - modifiers |= autoRepeat; - super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); - break; - } + handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar); } //---------------------------------------------------------------------- diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index d8202fcde..9f29acc0c 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -381,6 +381,8 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage } else { autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK; } + } else { + autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK; } // fall through intended case KeyPress: diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventAutoRepeatNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventAutoRepeatNEWT.java new file mode 100644 index 000000000..22c362dd8 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventAutoRepeatNEWT.java @@ -0,0 +1,309 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import org.junit.After; +import org.junit.Assert; +import org.junit.AfterClass; +import org.junit.Assume; +import org.junit.Before; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Robot; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.EventObject; +import java.util.List; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.swing.JFrame; + +import java.io.IOException; + +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; + +import com.jogamp.opengl.test.junit.util.*; + +/** + * Testing key event order incl. auto-repeat (Bug 601) + * + *

    + * Note Event order: + *

      + *
    1. {@link #EVENT_KEY_PRESSED}
    2. + *
    3. {@link #EVENT_KEY_RELEASED}
    4. + *
    5. {@link #EVENT_KEY_TYPED}
    6. + *
    + *

    + *

    + * Auto-Repeat shall behave as follow: + *

    +    D = pressed, U = released, T = typed
    +    0 = normal, 1 = auto-repeat
    +
    +    D(0), [ U(1), T(1), D(1), U(1) T(1) ..], U(0) T(0)
    + * 
    + * + * The idea is if you mask out auto-repeat in your event listener + * you just get one long pressed key D/U/T triple. + */ +public class TestKeyEventAutoRepeatNEWT extends UITestCase { + static int width, height; + static long durationPerTest = 100; + static long awtWaitTimeout = 1000; + + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + @Before + public void initTest() { + } + + @After + public void releaseTest() { + } + + @Test + public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + glWindow.setSize(width, height); + glWindow.setVisible(true); + + testImpl(glWindow); + + glWindow.destroy(); + } + + @Test + public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + + // Wrap the window in a canvas. + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + + // Add the canvas to a frame, and make it all visible. + final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); + frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); + frame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } } ); + + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); + + testImpl(glWindow); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(false); + frame1.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + glWindow.destroy(); + } + + static void testKeyEventAutoRepeat(Robot robot, NEWTKeyAdapter keyAdapter, int loops, int pressDurationMS) { + System.err.println("KEY Event Auto-Repeat Test: "+loops); + EventObject[][] first = new EventObject[loops][3]; + EventObject[][] last = new EventObject[loops][3]; + + keyAdapter.reset(); + final List keyEvents = keyAdapter.getQueued(); + int firstIdx = 0; + for(int i=0; i + * Note Event order: + *
      + *
    1. {@link #EVENT_KEY_PRESSED}
    2. + *
    3. {@link #EVENT_KEY_RELEASED}
    4. + *
    5. {@link #EVENT_KEY_TYPED}
    6. + *
    + *

    + */ +public class TestKeyEventOrderNEWT extends UITestCase { + static int width, height; + static long durationPerTest = 100; + static long awtWaitTimeout = 1000; + + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + @Before + public void initTest() { + } + + @After + public void releaseTest() { + } + + @Test + public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + glWindow.setSize(width, height); + glWindow.setVisible(true); + + testImpl(glWindow); + + glWindow.destroy(); + } + + @Test + public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + + // Wrap the window in a canvas. + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + + // Add the canvas to a frame, and make it all visible. + final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); + frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); + frame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } } ); + + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); + + testImpl(glWindow); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(false); + frame1.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + glWindow.destroy(); + } + + static void testKeyEventOrder(Robot robot, NEWTKeyAdapter keyAdapter, int loops) { + System.err.println("KEY Event Order Test: "+loops); + keyAdapter.reset(); + for(int i=0; i0) { focusCount=0; } focusCount--; wasTemporary = e.isTemporary(); - System.err.println("FOCUS AWT LOST "+(wasTemporary?"TEMP":"PERM")+" [fc "+focusCount+"]: "+prefix+", "+e); + if( verbose ) { + System.err.println("FOCUS AWT LOST "+(wasTemporary?"TEMP":"PERM")+" [fc "+focusCount+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[focusCount "+focusCount +", temp "+wasTemporary+"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java index 6c0156170..a9fa373b5 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java @@ -29,18 +29,25 @@ package com.jogamp.opengl.test.junit.util; import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; -public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements InputEventCountAdapter { +public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEventCountAdapter { String prefix; - int keyTyped; + int keyPressed, keyReleased, keyTyped; boolean pressed; + List queue = new ArrayList(); + boolean verbose = true; public AWTKeyAdapter(String prefix) { this.prefix = prefix; reset(); } + public void setVerbose(boolean v) { verbose = false; } + public boolean isPressed() { return pressed; } @@ -49,24 +56,54 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements InputEve return keyTyped; } + public int getKeyPressedCount(boolean autoRepeatOnly) { + return keyPressed; + } + + public int getKeyReleasedCount(boolean autoRepeatOnly) { + return keyReleased; + } + + public int getKeyTypedCount(boolean autoRepeatOnly) { + return keyTyped; + } + + public List getQueued() { + return queue; + } + public void reset() { keyTyped = 0; + keyPressed = 0; + keyReleased = 0; pressed = false; + queue.clear(); } public void keyPressed(KeyEvent e) { pressed = true; - System.err.println("KEY AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + keyPressed++; + queue.add(e); + if( verbose ) { + System.err.println("KEY AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } } public void keyReleased(KeyEvent e) { pressed = false; - System.err.println("KEY AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + keyReleased++; + queue.add(e); + if( verbose ) { + System.err.println("KEY AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } } public void keyTyped(java.awt.event.KeyEvent e) { - ++keyTyped; - System.err.println("KEY AWT TYPED ["+keyTyped+"]: "+prefix+", "+e); + keyTyped++; + queue.add(e); + if( verbose ) { + System.err.println("KEY AWT TYPED ["+keyTyped+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java index b94802348..3334f18ea 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java @@ -29,17 +29,24 @@ package com.jogamp.opengl.test.junit.util; import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements InputEventCountAdapter { String prefix; int mouseClicked; boolean pressed; + List queue = new ArrayList(); + boolean verbose = true; public AWTMouseAdapter(String prefix) { this.prefix = prefix; reset(); } + public void setVerbose(boolean v) { verbose = false; } + public boolean isPressed() { return pressed; } @@ -48,24 +55,38 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu return mouseClicked; } + public List getQueued() { + return queue; + } + public void reset() { mouseClicked = 0; pressed = false; + queue.clear(); } public void mousePressed(MouseEvent e) { pressed = true; - System.err.println("MOUSE AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } } public void mouseReleased(MouseEvent e) { pressed = false; - System.err.println("MOUSE AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } } public void mouseClicked(java.awt.event.MouseEvent e) { mouseClicked+=e.getClickCount(); - System.err.println("MOUSE AWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE AWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 160653cd5..06e172a5d 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -312,7 +312,7 @@ public class AWTRobotUtil { } if(!hasFocus) { System.err.print("*** AWTRobotUtil.assertRequestFocusAndWait() "); - if(gain.focusGained() && !lost.focusLost()) { + if( ( null == gain || gain.focusGained() ) && ( null == lost || !lost.focusLost() ) ) { // be error tolerant here, some impl. may lack focus-lost events (OS X) System.err.println("minor UI failure"); hasFocus = true; @@ -337,7 +337,7 @@ public class AWTRobotUtil { } public static int keyType(int i, Robot robot, int keyCode, - Object obj, InputEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException + Object obj, KeyEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException { int tc = 0; int j; @@ -365,13 +365,26 @@ public class AWTRobotUtil { Assert.assertEquals("Key ("+i+":"+j+") not typed one time", 1, tc); return (int) ( System.currentTimeMillis() - t0 ) ; } + + /** No validation is performed .. */ + public static int keyPress(int i, Robot robot, boolean press, int keyCode, int msDelay) { + final long t0 = System.currentTimeMillis(); + if(press) { + robot.keyPress(keyCode); + } else { + robot.keyRelease(keyCode); + } + robot.delay(msDelay); + + return (int) ( System.currentTimeMillis() - t0 ) ; + } /** * @param keyCode TODO * @param counter shall return the number of keys typed (press + release) */ public static void assertKeyType(Robot robot, int keyCode, int typeCount, - Object obj, InputEventCountAdapter counter) + Object obj, KeyEventCountAdapter counter) throws AWTException, InterruptedException, InvocationTargetException { if(null == robot) { @@ -398,6 +411,38 @@ public class AWTRobotUtil { Assert.assertEquals("Wrong key count", typeCount, counter.getCount()-c0); } + /** + * @param keyCode TODO + * @param counter shall return the number of keys typed (press + release) + */ + public static void assertKeyPress(Robot robot, int keyCode, int typeCount, + Object obj, KeyEventCountAdapter counter) + throws AWTException, InterruptedException, InvocationTargetException { + + if(null == robot) { + robot = new Robot(); + robot.setAutoWaitForIdle(true); + } + + centerMouse(robot, obj, false); + + Assert.assertEquals("Key already pressed", false, counter.isPressed()); + + if(DEBUG) { + System.err.println("**************************************"); + System.err.println("KC0: "+counter); + } + + final int c0 = counter.getCount(); + + for(int i=0; i0) { focusCount=0; } focusCount--; - System.err.println("FOCUS AWT LOST (Window) [fc "+focusCount+"]: "+prefix+", "+e); + if( verbose ) { + System.err.println("FOCUS AWT LOST (Window) [fc "+focusCount+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[focusCount "+focusCount +"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java index 76a1884c8..906e4a7c9 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/EventCountAdapter.java @@ -28,7 +28,16 @@ package com.jogamp.opengl.test.junit.util; +/** + * Base event count adapter. + *

    + * Instance starts in verbose mode. + *

    + */ public interface EventCountAdapter { void reset(); + + /** Instance starts in verbose mode, call w/ false to disable verbosity. */ + void setVerbose(boolean v); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java index 27f3d7e29..ed7485951 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java @@ -28,8 +28,13 @@ package com.jogamp.opengl.test.junit.util; +import java.util.EventObject; +import java.util.List; + public interface InputEventCountAdapter extends EventCountAdapter { int getCount(); boolean isPressed(); + + public List getQueued(); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java new file mode 100644 index 000000000..832f5ae82 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java @@ -0,0 +1,38 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.util; + +public interface KeyEventCountAdapter extends InputEventCountAdapter { + public int getKeyPressedCount(boolean autoRepeatOnly); + + public int getKeyReleasedCount(boolean autoRepeatOnly); + + public int getKeyTypedCount(boolean autoRepeatOnly); +} + diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java index 27d4abd9c..ccb1bde78 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTFocusAdapter.java @@ -36,12 +36,15 @@ public class NEWTFocusAdapter implements WindowListener, FocusEventCountAdapter String prefix; int focusCount; + boolean verbose = true; public NEWTFocusAdapter(String prefix) { this.prefix = prefix; reset(); } + public void setVerbose(boolean v) { verbose = false; } + public boolean focusLost() { return focusCount<0; } @@ -57,13 +60,17 @@ public class NEWTFocusAdapter implements WindowListener, FocusEventCountAdapter public void windowGainedFocus(WindowEvent e) { if(focusCount<0) { focusCount=0; } focusCount++; - System.err.println("FOCUS NEWT GAINED [fc "+focusCount+"]: "+prefix+", "+e); + if( verbose ) { + System.err.println("FOCUS NEWT GAINED [fc "+focusCount+"]: "+prefix+", "+e); + } } public void windowLostFocus(WindowEvent e) { if(focusCount>0) { focusCount=0; } focusCount--; - System.err.println("FOCUS NEWT LOST [fc "+focusCount+"]: "+prefix+", "+e); + if( verbose ) { + System.err.println("FOCUS NEWT LOST [fc "+focusCount+"]: "+prefix+", "+e); + } } public void windowResized(WindowEvent e) { } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java index 32b392ca8..42235254a 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java @@ -28,19 +28,29 @@ package com.jogamp.opengl.test.junit.util; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; + +import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; -public class NEWTKeyAdapter extends KeyAdapter implements InputEventCountAdapter { +public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { String prefix; - int keyTyped; + int keyPressed, keyReleased, keyTyped; + int keyPressedAR, keyReleasedAR, keyTypedAR; boolean pressed; + List queue = new ArrayList(); + boolean verbose = true; public NEWTKeyAdapter(String prefix) { this.prefix = prefix; reset(); } + + public void setVerbose(boolean v) { verbose = false; } public boolean isPressed() { return pressed; @@ -50,25 +60,67 @@ public class NEWTKeyAdapter extends KeyAdapter implements InputEventCountAdapter return keyTyped; } + public int getKeyPressedCount(boolean autoRepeatOnly) { + return autoRepeatOnly ? keyPressedAR: keyPressed; + } + + public int getKeyReleasedCount(boolean autoRepeatOnly) { + return autoRepeatOnly ? keyReleasedAR: keyReleased; + } + + public int getKeyTypedCount(boolean autoRepeatOnly) { + return autoRepeatOnly ? keyTypedAR: keyTyped; + } + + public List getQueued() { + return queue; + } + public void reset() { keyTyped = 0; + keyPressed = 0; + keyReleased = 0; + keyTypedAR = 0; + keyPressedAR = 0; + keyReleasedAR = 0; pressed = false; + queue.clear(); } public void keyPressed(KeyEvent e) { pressed = true; - System.err.println("NEWT AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + keyPressed++; + if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { + keyPressedAR++; + } + queue.add(e); + if( verbose ) { + System.err.println("NEWT AWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } } public void keyReleased(KeyEvent e) { pressed = false; - System.err.println("NEWT AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + keyReleased++; + if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { + keyReleasedAR++; + } + queue.add(e); + if( verbose ) { + System.err.println("NEWT AWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } } @Override public void keyTyped(KeyEvent e) { - ++keyTyped; - System.err.println("KEY NEWT TYPED ["+keyTyped+"]: "+prefix+", "+e); + keyTyped++; + if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { + keyTypedAR++; + } + queue.add(e); + if( verbose ) { + System.err.println("KEY NEWT TYPED ["+keyTyped+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java new file mode 100644 index 000000000..dfc96edcb --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java @@ -0,0 +1,103 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.util; + +import java.util.EventObject; +import java.util.List; + +import org.junit.Assert; + +import com.jogamp.newt.event.KeyEvent; + +public class NEWTKeyUtil { + public static void dumpKeyEvents(List keyEvents) { + for(int i=0; i keyEvents) { + int eet = KeyEvent.EVENT_KEY_PRESSED; + for(int i=0; i keyEvents = keyAdapter.getQueued(); + Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3); + Assert.assertEquals("Key event count not 3 * press_release_count", 3*expTotalCount, keyEvents.size()); + Assert.assertEquals("Key press count failure", expTotalCount, keyPressed); + Assert.assertEquals("Key press count failure (AR)", expARCount, keyPressedAR); + Assert.assertEquals("Key released count failure", expTotalCount, keyReleased); + Assert.assertEquals("Key released count failure (AR)", expARCount, keyReleasedAR); + Assert.assertEquals("Key typed count failure", expTotalCount, keyTyped); + Assert.assertEquals("Key typed count failure (AR)", expARCount, keyTypedAR); + + // should be true - always, reaching this point - duh! + Assert.assertEquals(expTotalCount-expARCount, keyPressedNR); + Assert.assertEquals(expTotalCount-expARCount, keyReleasedNR); + Assert.assertEquals(expTotalCount-expARCount, keyTypedNR); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java index d98b9ca74..c77462884 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java @@ -28,6 +28,10 @@ package com.jogamp.opengl.test.junit.util; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; + import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; @@ -36,12 +40,16 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda String prefix; int mouseClicked; boolean pressed; + List queue = new ArrayList(); + boolean verbose = true; public NEWTMouseAdapter(String prefix) { this.prefix = prefix; reset(); } + public void setVerbose(boolean v) { verbose = false; } + public boolean isPressed() { return pressed; } @@ -50,24 +58,38 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda return mouseClicked; } + public List getQueued() { + return queue; + } + public void reset() { mouseClicked = 0; pressed = false; + queue.clear(); } public void mousePressed(MouseEvent e) { pressed = true; - System.err.println("MOUSE NEWT PRESSED ["+pressed+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE NEWT PRESSED ["+pressed+"]: "+prefix+", "+e); + } } public void mouseReleased(MouseEvent e) { pressed = false; - System.err.println("MOUSE NEWT RELEASED ["+pressed+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE NEWT RELEASED ["+pressed+"]: "+prefix+", "+e); + } } public void mouseClicked(MouseEvent e) { mouseClicked+=e.getClickCount(); - System.err.println("MOUSE NEWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); + queue.add(e); + if( verbose ) { + System.err.println("MOUSE NEWT CLICKED ["+mouseClicked+"]: "+prefix+", "+e); + } } public String toString() { return prefix+"[pressed "+pressed+", clicked "+mouseClicked+"]"; } -- cgit v1.2.3 From 2f9c77a347b76bebdadd4bec1ac92aa7ab72365f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 27 Oct 2012 02:48:43 +0200 Subject: Fix Bug 631 and enhance 601: Handle multiple keys (pressed, released, types incl. auto-repeat) - Using keyCode (bit) maps to isPressed and isAutoRepeat, allowing use of multiple keys - Enhance unit test TestKeyEventOrderNEWT w/ injecting variations of 2 diff. keys - Manual tested on X11, Windows and OSX w/ and w/o auto-repeat --- make/scripts/tests-x64.bat | 1 + make/scripts/tests.sh | 5 +- src/newt/classes/jogamp/newt/WindowImpl.java | 25 +++ .../jogamp/newt/driver/macosx/WindowDriver.java | 100 ++++------ .../jogamp/newt/driver/windows/WindowDriver.java | 75 +++---- .../test/junit/newt/TestKeyEventOrderNEWT.java | 22 +- .../newt/TestKeyPressReleaseUnmaskRepeatNEWT.java | 222 +++++++++++++++++++++ .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 8 +- 8 files changed, 350 insertions(+), 108 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestKeyPressReleaseUnmaskRepeatNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index f67bda373..21e303dc2 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -34,6 +34,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 047c0ed63..734fa671f 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -375,8 +375,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* -testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* +testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 8901411a3..311ed0bbb 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -37,6 +37,7 @@ package jogamp.newt; import java.util.ArrayList; import java.lang.reflect.Method; +import com.jogamp.common.util.IntBitfield; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Display; @@ -2169,6 +2170,30 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // KeyListener/Event Support // + protected IntBitfield keyPressedState = new IntBitfield(KeyEvent.VK_CONTEXT_MENU+1); + protected IntBitfield keyRepeatState = new IntBitfield(KeyEvent.VK_CONTEXT_MENU+1); + + /** + * @param keyCode + * @return 1 if pressed, 0 if not pressed, -1 if not handled. + */ + protected final int isKeyPressed(int keyCode) { + if( 0 <= keyCode && keyCode < keyPressedState.capacity() ) { + return keyPressedState.get(keyCode) ? 1 : 0; + } + return -1; + } + /** + * @param keyCode + * @return 1 if pressed, 0 if not pressed, -1 if not handled. + */ + protected final int isKeyInAutoRepeat(int keyCode) { + if( 0 <= keyCode && keyCode < keyRepeatState.capacity() ) { + return keyRepeatState.get(keyCode) ? 1 : 0; + } + return -1; + } + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 4eeafb244..bcdd6b9df 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -306,74 +306,60 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } // else may need offscreen solution ? FIXME } - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - // Note that we send the key char for the key code on this - // platform -- we do not get any useful key codes out of the system - final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); - final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); - if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); - if(valid) { - if(pressedKeyBalance > 1) { - // Auto-Repeat: OSX delivers only PRESSED - // inject auto-repeat RELEASE and TYPED keys _before_ - pressedKeyBalance--; - modifiers |= InputEvent.AUTOREPEAT_MASK; - super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED - super.sendKeyEvent(KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED - } - // only deliver keyChar on key Typed events, harmonizing platform behavior - keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; - super.sendKeyEvent(eventType, modifiers, keyCode2, keyChar); + private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + if( send ) { + super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); + } else { + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); } } - - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + + private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { // Note that we send the key char for the key code on this // platform -- we do not get any useful key codes out of the system - final int keyCode2 = MacKeyUtil.validateKeyCode(keyCode, keyChar); - final boolean valid = validateKeyEvent(eventType, modifiers, keyCode); - if(DEBUG_IMPLEMENTATION) System.err.println("MacWindow.enqueueKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode2)+", valid "+valid); - if(valid) { - if(pressedKeyBalance > 1) { - // Auto-Repeat: OSX delivers only PRESSED - // inject auto-repeat RELEASE and TYPED keys _before_ - pressedKeyBalance--; - modifiers |= InputEvent.AUTOREPEAT_MASK; - super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED - super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED - } - // only deliver keyChar on key Typed events, harmonizing platform behavior - keyChar = KeyEvent.EVENT_KEY_TYPED == eventType ? keyChar : (char)-1; - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode2, keyChar); + keyCode = MacKeyUtil.validateKeyCode(keyCode, keyChar); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode)); } - } - - private int keyDownModifiers = 0; - private int keyDownCode = 0; - private int pressedKeyBalance = 0; - - private boolean validateKeyEvent(int eventType, int modifiers, int keyCode) { + // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED switch(eventType) { - case KeyEvent.EVENT_KEY_PRESSED: - pressedKeyBalance++; - keyDownModifiers = modifiers; - keyDownCode = keyCode; - return true; case KeyEvent.EVENT_KEY_RELEASED: - pressedKeyBalance--; - return keyDownModifiers == modifiers && keyDownCode == keyCode; + if( 1 == isKeyInAutoRepeat(keyCode) ) { + // AR out + keyRepeatState.put(keyCode, false); + } + keyPressedState.put(keyCode, false); + keyChar = (char)-1; + break; + case KeyEvent.EVENT_KEY_PRESSED: + if( 1 == isKeyPressed(keyCode) ) { + if( 0 == isKeyInAutoRepeat(keyCode) ) { + // AR in + keyRepeatState.put(keyCode, true); + } + modifiers |= InputEvent.AUTOREPEAT_MASK; + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED + } else { + keyPressedState.put(keyCode, true); + } + keyChar = (char)-1; + break; case KeyEvent.EVENT_KEY_TYPED: - final boolean matchKeyDown = keyDownModifiers == modifiers && keyDownCode == keyCode; - keyDownModifiers = 0; - keyDownCode = 0; - return matchKeyDown; - default: - throw new NativeWindowException("Unexpected key event type " + eventType); + break; } + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + } + + @Override + public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { + handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); } + @Override + public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar); + } //---------------------------------------------------------------------- // Internals only diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index c211bac61..be9f6603e 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -259,29 +260,10 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } - private final int validateKeyCode(int eventType, int modifiers, int keyCode, char keyChar) { - switch(eventType) { - case KeyEvent.EVENT_KEY_RELEASED: - pressedKeyBalance--; - lastPressedKeyCode = keyCode; - break; - case KeyEvent.EVENT_KEY_PRESSED: - pressedKeyBalance++; - lastPressedKeyCode = keyCode; - break; - case KeyEvent.EVENT_KEY_TYPED: - if(-1==keyCode) { - keyCode = lastPressedKeyCode; - } - lastPressedKeyCode = -1; - break; - } - return keyCode; - } + /** We have to regenerate the keyCode for EVENT_KEY_TYPED on this platform. */ private int lastPressedKeyCode = 0; - private char lastTypedKeyChar = 0; - private int pressedKeyBalance = 0; - private int autoRepeat = 0; + /** We have to reorder the native key events to match NEWT's order */ + private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { if( send ) { @@ -292,47 +274,50 @@ public class WindowDriver extends WindowImpl { } private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", mods "+toHexString(modifiers)); - - // Note that we have to regenerate the keyCode for EVENT_KEY_TYPED on this platform - keyCode = validateKeyCode(eventType, modifiers, keyCode, keyChar); - + // final int kc = 0 <= keyCode ? keyCode : lastPressedKeyCode; + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key "+toHexString(kc)+", mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(kc)+", repeat "+isKeyInAutoRepeat(kc)); + // Reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED - // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. + // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - if( 0 != autoRepeat ) { + if( 1 == isKeyInAutoRepeat(keyCode) ) { // AR out - send out missing PRESSED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | autoRepeat, keyCode, lastTypedKeyChar); + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + keyRepeatState.put(keyCode, false); } - autoRepeat = 0; - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - if( 0 != lastTypedKeyChar ) { + keyPressedState.put(keyCode, false); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + final char lastTypedKeyChar = (char) typedKeyCode2KeyChar.put(keyCode, 0); + if( 0 < lastTypedKeyChar ) { emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, lastTypedKeyChar); - lastTypedKeyChar = 0; } break; case KeyEvent.EVENT_KEY_PRESSED: - if( pressedKeyBalance > 1 ) { - pressedKeyBalance--; - if ( 0 == autoRepeat ) { + lastPressedKeyCode = keyCode; + if( 1 == isKeyPressed(keyCode) ) { + if( 0 == isKeyInAutoRepeat(keyCode) ) { // AR in - skip already send PRESSED - autoRepeat = InputEvent.AUTOREPEAT_MASK; + keyRepeatState.put(keyCode, true); } else { - emitKeyEvent(send, wait, eventType, modifiers | autoRepeat, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); } } else { - autoRepeat = 0; + keyPressedState.put(keyCode, true); emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); } break; case KeyEvent.EVENT_KEY_TYPED: - if( 0 == autoRepeat ) { - lastTypedKeyChar = keyChar; - } else { - modifiers |= autoRepeat; + if(-1==keyCode) { + keyCode = lastPressedKeyCode; + } + lastPressedKeyCode = -1; + if( 1 == isKeyInAutoRepeat(keyCode) ) { + modifiers |= InputEvent.AUTOREPEAT_MASK; emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + } else { + typedKeyCode2KeyChar.put(keyCode, keyChar); } break; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java index e0c3005a2..31d9912d1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyEventOrderNEWT.java @@ -141,17 +141,33 @@ public class TestKeyEventOrderNEWT extends UITestCase { System.err.println("KEY Event Order Test: "+loops); keyAdapter.reset(); for(int i=0; i keyEvents) { - int eet = KeyEvent.EVENT_KEY_PRESSED; + IntIntHashMap keyCode2NextEvent = new IntIntHashMap(); for(int i=0; i= eet ) { + eet = KeyEvent.EVENT_KEY_PRESSED; + } final int et = e.getEventType(); Assert.assertEquals("Key event not in proper order", eet, et); eet = getNextKeyEventType(et); + keyCode2NextEvent.put(e.getKeyCode(), eet); } } -- cgit v1.2.3 From 70d58b030bdbac98ba592a3a14a84cc0e4941c51 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 27 Oct 2012 04:01:56 +0200 Subject: NEWT KeyEvent (Windows, OSX): Check whether keyCode is tracked before using bitfield, use more IntBitfield.put(..) return value for efficiency. --- make/scripts/tests-x64.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 3 +++ .../jogamp/newt/driver/macosx/WindowDriver.java | 23 +++++++++---------- .../jogamp/newt/driver/windows/WindowDriver.java | 26 ++++++++++++---------- 5 files changed, 31 insertions(+), 29 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 21e303dc2..72ee5f666 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -32,9 +32,9 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSi REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 734fa671f..8594bfe2e 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -375,9 +375,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* -testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* +testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 311ed0bbb..4f8eb3d3a 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2193,6 +2193,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return -1; } + protected final boolean isKeyCodeTracked(int keyCode) { + return 0 <= keyCode && keyCode < keyRepeatState.capacity(); + } public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index bcdd6b9df..e0ea8ea76 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -324,24 +324,21 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - if( 1 == isKeyInAutoRepeat(keyCode) ) { - // AR out - keyRepeatState.put(keyCode, false); + if( isKeyCodeTracked(keyCode) ) { + keyRepeatState.put(keyCode, false); // prev == true -> AR out + keyPressedState.put(keyCode, false); } - keyPressedState.put(keyCode, false); keyChar = (char)-1; break; case KeyEvent.EVENT_KEY_PRESSED: - if( 1 == isKeyPressed(keyCode) ) { - if( 0 == isKeyInAutoRepeat(keyCode) ) { - // AR in - keyRepeatState.put(keyCode, true); + if( isKeyCodeTracked(keyCode) ) { + if( keyPressedState.put(keyCode, true) ) { + // key was already pressed + keyRepeatState.put(keyCode, true); // prev == false -> AR in + modifiers |= InputEvent.AUTOREPEAT_MASK; + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED } - modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED - } else { - keyPressedState.put(keyCode, true); } keyChar = (char)-1; break; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index be9f6603e..8b57a241d 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -281,12 +281,13 @@ public class WindowDriver extends WindowImpl { // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - if( 1 == isKeyInAutoRepeat(keyCode) ) { - // AR out - send out missing PRESSED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); - keyRepeatState.put(keyCode, false); + if( isKeyCodeTracked(keyCode) ) { + if( keyRepeatState.put(keyCode, false) ) { + // AR out - send out missing PRESSED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + } + keyPressedState.put(keyCode, false); } - keyPressedState.put(keyCode, false); emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); final char lastTypedKeyChar = (char) typedKeyCode2KeyChar.put(keyCode, 0); if( 0 < lastTypedKeyChar ) { @@ -294,16 +295,17 @@ public class WindowDriver extends WindowImpl { } break; case KeyEvent.EVENT_KEY_PRESSED: - lastPressedKeyCode = keyCode; - if( 1 == isKeyPressed(keyCode) ) { - if( 0 == isKeyInAutoRepeat(keyCode) ) { - // AR in - skip already send PRESSED - keyRepeatState.put(keyCode, true); + lastPressedKeyCode = keyCode; + if( isKeyCodeTracked(keyCode) ) { + if( keyPressedState.put(keyCode, true) ) { + // key was already pressed + if( keyRepeatState.put(keyCode, true) ) { + emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + } // else AR in - skip already send PRESSED } else { - emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); } } else { - keyPressedState.put(keyCode, true); emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); } break; -- cgit v1.2.3 From cf9a4e236891ce2f6d9469a017e880eed704dea0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 28 Oct 2012 05:44:24 +0100 Subject: Fix NEWT KeyCode: Basic KeyCode Validation on X11, Windows and OSX - X11: Add VK_QUOTE mapping - OSX: Add single shift, ctrl alt key press; Fix mapping: Command -> Windows, Option -> ALT, add BACK_QUOTE and QUOTE. --- make/scripts/tests-x64.bat | 3 +- make/scripts/tests.sh | 3 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 16 +- .../jogamp/newt/driver/macosx/MacKeyUtil.java | 145 ++++++------ .../jogamp/newt/driver/macosx/WindowDriver.java | 6 +- src/newt/native/NewtMacWindow.h | 4 + src/newt/native/NewtMacWindow.m | 74 +++++- src/newt/native/X11Display.c | 2 + .../opengl/test/junit/newt/TestKeyCodeNEWT.java | 256 +++++++++++++++++++++ .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 64 ++++++ 10 files changed, 472 insertions(+), 101 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestKeyCodeNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 72ee5f666..6c9dae729 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -34,7 +34,8 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyCodeNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8594bfe2e..0db48b289 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -377,7 +377,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* -testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* +testawt com.jogamp.opengl.test.junit.newt.TestKeyCodeNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index a8ac70b4d..8d3d9e88f 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -156,10 +156,10 @@ public class KeyEvent extends InputEvent /* Virtual key codes. */ - public static final int VK_ENTER = '\n'; - public static final int VK_BACK_SPACE = '\b'; - public static final int VK_TAB = '\t'; public static final int VK_CANCEL = 0x03; + public static final int VK_BACK_SPACE = 0x08; // '\b' + public static final int VK_TAB = 0x09; // '\t' + public static final int VK_ENTER = 0x0A; // '\n' public static final int VK_CLEAR = 0x0C; public static final int VK_SHIFT = 0x10; public static final int VK_CONTROL = 0x11; @@ -296,18 +296,10 @@ public class KeyEvent extends InputEvent public static final int VK_MULTIPLY = 0x6A; public static final int VK_ADD = 0x6B; - /** - * This constant is obsolete, and is included only for backwards - * compatibility. - * @see #VK_SEPARATOR - */ - public static final int VK_SEPARATER = 0x6C; - /** * Constant for the Numpad Separator key. - * @since 1.4 */ - public static final int VK_SEPARATOR = VK_SEPARATER; + public static final int VK_SEPARATOR = 0x6C; public static final int VK_SUBTRACT = 0x6D; public static final int VK_DECIMAL = 0x6E; diff --git a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java index d39e0027b..5966bd30f 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/MacKeyUtil.java @@ -162,13 +162,13 @@ public class MacKeyUtil { case kVK_Space: return KeyEvent.VK_SPACE; case kVK_Delete: return KeyEvent.VK_BACK_SPACE; case kVK_Escape: return KeyEvent.VK_ESCAPE; - case kVK_Command: return KeyEvent.VK_ALT; + case kVK_Command: return KeyEvent.VK_WINDOWS; case kVK_Shift: return KeyEvent.VK_SHIFT; case kVK_CapsLock: return KeyEvent.VK_CAPS_LOCK; - case kVK_Option: return KeyEvent.VK_WINDOWS; + case kVK_Option: return KeyEvent.VK_ALT; case kVK_Control: return KeyEvent.VK_CONTROL; case kVK_RightShift: return KeyEvent.VK_SHIFT; - case kVK_RightOption: return KeyEvent.VK_WINDOWS; + case kVK_RightOption: return KeyEvent.VK_ALT; case kVK_RightControl: return KeyEvent.VK_CONTROL; // case kVK_Function: return KeyEvent.VK_F; case kVK_F17: return KeyEvent.VK_F17; @@ -206,78 +206,73 @@ public class MacKeyUtil { case kVK_UpArrow: return KeyEvent.VK_UP; } - if (keyChar == '\r') { - // Turn these into \n - return KeyEvent.VK_ENTER; - } - - if (keyChar >= NSUpArrowFunctionKey && keyChar <= NSModeSwitchFunctionKey) { - switch (keyChar) { - case NSUpArrowFunctionKey: return KeyEvent.VK_UP; - case NSDownArrowFunctionKey: return KeyEvent.VK_DOWN; - case NSLeftArrowFunctionKey: return KeyEvent.VK_LEFT; - case NSRightArrowFunctionKey: return KeyEvent.VK_RIGHT; - case NSF1FunctionKey: return KeyEvent.VK_F1; - case NSF2FunctionKey: return KeyEvent.VK_F2; - case NSF3FunctionKey: return KeyEvent.VK_F3; - case NSF4FunctionKey: return KeyEvent.VK_F4; - case NSF5FunctionKey: return KeyEvent.VK_F5; - case NSF6FunctionKey: return KeyEvent.VK_F6; - case NSF7FunctionKey: return KeyEvent.VK_F7; - case NSF8FunctionKey: return KeyEvent.VK_F8; - case NSF9FunctionKey: return KeyEvent.VK_F9; - case NSF10FunctionKey: return KeyEvent.VK_F10; - case NSF11FunctionKey: return KeyEvent.VK_F11; - case NSF12FunctionKey: return KeyEvent.VK_F12; - case NSF13FunctionKey: return KeyEvent.VK_F13; - case NSF14FunctionKey: return KeyEvent.VK_F14; - case NSF15FunctionKey: return KeyEvent.VK_F15; - case NSF16FunctionKey: return KeyEvent.VK_F16; - case NSF17FunctionKey: return KeyEvent.VK_F17; - case NSF18FunctionKey: return KeyEvent.VK_F18; - case NSF19FunctionKey: return KeyEvent.VK_F19; - case NSF20FunctionKey: return KeyEvent.VK_F20; - case NSF21FunctionKey: return KeyEvent.VK_F21; - case NSF22FunctionKey: return KeyEvent.VK_F22; - case NSF23FunctionKey: return KeyEvent.VK_F23; - case NSF24FunctionKey: return KeyEvent.VK_F24; - case NSInsertFunctionKey: return KeyEvent.VK_INSERT; - case NSDeleteFunctionKey: return KeyEvent.VK_DELETE; - case NSHomeFunctionKey: return KeyEvent.VK_HOME; - case NSBeginFunctionKey: return KeyEvent.VK_BEGIN; - case NSEndFunctionKey: return KeyEvent.VK_END; - case NSPageUpFunctionKey: return KeyEvent.VK_PAGE_UP; - case NSPageDownFunctionKey: return KeyEvent.VK_PAGE_DOWN; - case NSPrintScreenFunctionKey: return KeyEvent.VK_PRINTSCREEN; - case NSScrollLockFunctionKey: return KeyEvent.VK_SCROLL_LOCK; - case NSPauseFunctionKey: return KeyEvent.VK_PAUSE; - // Not handled: - // NSSysReqFunctionKey - // NSBreakFunctionKey - // NSResetFunctionKey - case NSStopFunctionKey: return KeyEvent.VK_STOP; - // Not handled: - // NSMenuFunctionKey - // NSUserFunctionKey - // NSSystemFunctionKey - // NSPrintFunctionKey - // NSClearLineFunctionKey - // NSClearDisplayFunctionKey - // NSInsertLineFunctionKey - // NSDeleteLineFunctionKey - // NSInsertCharFunctionKey - // NSDeleteCharFunctionKey - // NSPrevFunctionKey - // NSNextFunctionKey - // NSSelectFunctionKey - // NSExecuteFunctionKey - // NSUndoFunctionKey - // NSRedoFunctionKey - // NSFindFunctionKey - // NSHelpFunctionKey - // NSModeSwitchFunctionKey - default: break; - } + switch (keyChar) { + case NSUpArrowFunctionKey: return KeyEvent.VK_UP; + case NSDownArrowFunctionKey: return KeyEvent.VK_DOWN; + case NSLeftArrowFunctionKey: return KeyEvent.VK_LEFT; + case NSRightArrowFunctionKey: return KeyEvent.VK_RIGHT; + case NSF1FunctionKey: return KeyEvent.VK_F1; + case NSF2FunctionKey: return KeyEvent.VK_F2; + case NSF3FunctionKey: return KeyEvent.VK_F3; + case NSF4FunctionKey: return KeyEvent.VK_F4; + case NSF5FunctionKey: return KeyEvent.VK_F5; + case NSF6FunctionKey: return KeyEvent.VK_F6; + case NSF7FunctionKey: return KeyEvent.VK_F7; + case NSF8FunctionKey: return KeyEvent.VK_F8; + case NSF9FunctionKey: return KeyEvent.VK_F9; + case NSF10FunctionKey: return KeyEvent.VK_F10; + case NSF11FunctionKey: return KeyEvent.VK_F11; + case NSF12FunctionKey: return KeyEvent.VK_F12; + case NSF13FunctionKey: return KeyEvent.VK_F13; + case NSF14FunctionKey: return KeyEvent.VK_F14; + case NSF15FunctionKey: return KeyEvent.VK_F15; + case NSF16FunctionKey: return KeyEvent.VK_F16; + case NSF17FunctionKey: return KeyEvent.VK_F17; + case NSF18FunctionKey: return KeyEvent.VK_F18; + case NSF19FunctionKey: return KeyEvent.VK_F19; + case NSF20FunctionKey: return KeyEvent.VK_F20; + case NSF21FunctionKey: return KeyEvent.VK_F21; + case NSF22FunctionKey: return KeyEvent.VK_F22; + case NSF23FunctionKey: return KeyEvent.VK_F23; + case NSF24FunctionKey: return KeyEvent.VK_F24; + case NSInsertFunctionKey: return KeyEvent.VK_INSERT; + case NSDeleteFunctionKey: return KeyEvent.VK_DELETE; + case NSHomeFunctionKey: return KeyEvent.VK_HOME; + case NSBeginFunctionKey: return KeyEvent.VK_BEGIN; + case NSEndFunctionKey: return KeyEvent.VK_END; + case NSPageUpFunctionKey: return KeyEvent.VK_PAGE_UP; + case NSPageDownFunctionKey: return KeyEvent.VK_PAGE_DOWN; + case NSPrintScreenFunctionKey: return KeyEvent.VK_PRINTSCREEN; + case NSScrollLockFunctionKey: return KeyEvent.VK_SCROLL_LOCK; + case NSPauseFunctionKey: return KeyEvent.VK_PAUSE; + // Not handled: + // NSSysReqFunctionKey + // NSBreakFunctionKey + // NSResetFunctionKey + case NSStopFunctionKey: return KeyEvent.VK_STOP; + // Not handled: + // NSMenuFunctionKey + // NSUserFunctionKey + // NSSystemFunctionKey + // NSPrintFunctionKey + // NSClearLineFunctionKey + // NSClearDisplayFunctionKey + // NSInsertLineFunctionKey + // NSDeleteLineFunctionKey + // NSInsertCharFunctionKey + // NSDeleteCharFunctionKey + // NSPrevFunctionKey + // NSNextFunctionKey + // NSSelectFunctionKey + // NSExecuteFunctionKey + // NSUndoFunctionKey + // NSRedoFunctionKey + // NSFindFunctionKey + // NSHelpFunctionKey + // NSModeSwitchFunctionKey + case 0x60: return KeyEvent.VK_BACK_QUOTE; // ` + case 0x27: return KeyEvent.VK_QUOTE; // ' + case '\r': return KeyEvent.VK_ENTER; } if ('a' <= keyChar && keyChar <= 'z') { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index e0ea8ea76..bc83f9540 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -314,12 +314,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } - private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { + private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int _keyCode, char keyChar) { // Note that we send the key char for the key code on this // platform -- we do not get any useful key codes out of the system - keyCode = MacKeyUtil.validateKeyCode(keyCode, keyChar); + final int keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(keyCode)+" -> 0x"+Integer.toHexString(keyCode)); + System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)); } // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED switch(eventType) { diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index c0912ad3c..29b646fbf 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -111,6 +111,7 @@ BOOL mouseInside; BOOL cursorIsHidden; BOOL realized; + BOOL modsDown[4]; // shift, ctrl, alt/option, win/command NSPoint lastInsideMousePosition; @public int cachedInsets[4]; // l, r, t, b @@ -145,6 +146,7 @@ - (void) setMousePosition:(NSPoint)p; - (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType; +- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType; - (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType; - (void) focusChanged: (BOOL) gained; @@ -157,6 +159,8 @@ - (void) windowDidResignKey: (NSNotification *) notification; - (void) keyDown: (NSEvent*) theEvent; - (void) keyUp: (NSEvent*) theEvent; +- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods; +- (void) flagsChanged: (NSEvent *) theEvent; - (void) mouseEntered: (NSEvent*) theEvent; - (void) mouseExited: (NSEvent*) theEvent; - (void) mouseMoved: (NSEvent*) theEvent; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index b58b99e38..de5f3773c 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -368,6 +368,10 @@ static jmethodID windowRepaintID = NULL; cachedInsets[1] = 0; // r cachedInsets[2] = 0; // t cachedInsets[3] = 0; // b + modsDown[0] = NO; // shift + modsDown[1] = NO; // ctrl + modsDown[2] = NO; // alt + modsDown[3] = NO; // win mouseConfined = NO; mouseVisible = YES; mouseInside = NO; @@ -596,6 +600,14 @@ static jint mods2JavaMods(NSUInteger mods) } - (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType +{ + jint keyCode = (jint) [event keyCode]; + NSString* chars = [event charactersIgnoringModifiers]; + NSUInteger mods = [event modifierFlags]; + [self sendKeyEvent: keyCode characters: chars modifiers: mods eventType: evType]; +} + +- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType { NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { @@ -616,16 +628,30 @@ static jint mods2JavaMods(NSUInteger mods) } int i; - jint keyCode = (jint) [event keyCode]; - NSString* chars = [event charactersIgnoringModifiers]; - int len = [chars length]; - jint javaMods = mods2JavaMods([event modifierFlags]); - - for (i = 0; i < len; i++) { - // Note: the key code in the NSEvent does not map to anything we can use - jchar keyChar = (jchar) [chars characterAtIndex: i]; + int len = NULL != chars ? [chars length] : 0; + jint javaMods = mods2JavaMods(mods); + + if(len > 0) { + // printable chars + for (i = 0; i < len; i++) { + // Note: the key code in the NSEvent does not map to anything we can use + jchar keyChar = (jchar) [chars characterAtIndex: i]; + + DBG_PRINT("sendKeyEvent: %d/%d char 0x%X, code 0x%X\n", i, len, (int)keyChar, (int)keyCode); + + #ifdef USE_SENDIO_DIRECT + (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID, + evType, javaMods, keyCode, keyChar); + #else + (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, + evType, javaMods, keyCode, keyChar); + #endif + } + } else { + // non-printable chars + jchar keyChar = (jchar) -1; - DBG_PRINT("sendKeyEvent: %d/%d char 0x%X, code 0x%X\n", i, len, (int)keyChar, (int)keyCode); + DBG_PRINT("sendKeyEvent: code 0x%X\n", (int)keyCode); #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID, @@ -805,6 +831,36 @@ static jint mods2JavaMods(NSUInteger mods) [self sendKeyEvent: theEvent eventType: EVENT_KEY_TYPED]; } +#define kVK_Shift 0x38 +#define kVK_Option 0x3A +#define kVK_Control 0x3B +#define kVK_Command 0x37 + +- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods +{ + if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { + modsDown[keyIdx] = YES; + mods &= ~keyMask; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_TYPED]; + } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { + modsDown[keyIdx] = NO; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_RELEASED]; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_TYPED]; + } +} + +- (void) flagsChanged:(NSEvent *) theEvent +{ + NSUInteger mods = [theEvent modifierFlags]; + + // BOOL modsDown[4]; // shift, ctrl, alt/option, win/command + + [self handleFlagsChanged: NSShiftKeyMask keyIndex: 0 keyCode: kVK_Shift modifiers: mods]; + [self handleFlagsChanged: NSControlKeyMask keyIndex: 1 keyCode: kVK_Control modifiers: mods]; + [self handleFlagsChanged: NSAlternateKeyMask keyIndex: 2 keyCode: kVK_Option modifiers: mods]; + [self handleFlagsChanged: NSCommandKeyMask keyIndex: 3 keyCode: kVK_Command modifiers: mods]; +} + - (void) mouseEntered: (NSEvent*) theEvent { DBG_PRINT( "mouseEntered: confined %d, visible %d\n", mouseConfined, mouseVisible); diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 9f29acc0c..341455f0f 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -148,6 +148,8 @@ static jint X11KeySym2NewtVKey(KeySym keySym) { return J_VK_HELP; case XK_grave: return J_VK_BACK_QUOTE; + case XK_apostrophe: + return J_VK_QUOTE; } return keySym; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestKeyCodeNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyCodeNEWT.java new file mode 100644 index 000000000..8af0f0246 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestKeyCodeNEWT.java @@ -0,0 +1,256 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import org.junit.After; +import org.junit.Assert; +import org.junit.AfterClass; +import org.junit.Assume; +import org.junit.Before; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Robot; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.List; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.swing.JFrame; + +import java.io.IOException; + +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; + +import com.jogamp.opengl.test.junit.util.*; +import com.jogamp.opengl.test.junit.util.NEWTKeyUtil.CodeSeg; + +/** + * Testing key event order incl. auto-repeat (Bug 601) + * + *

    + * Note Event order: + *

      + *
    1. {@link #EVENT_KEY_PRESSED}
    2. + *
    3. {@link #EVENT_KEY_RELEASED}
    4. + *
    5. {@link #EVENT_KEY_TYPED}
    6. + *
    + *

    + */ +public class TestKeyCodeNEWT extends UITestCase { + static int width, height; + static long durationPerTest = 100; + static long awtWaitTimeout = 1000; + + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + @Before + public void initTest() { + } + + @After + public void releaseTest() { + } + + @Test + public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + glWindow.setSize(width, height); + glWindow.setVisible(true); + + testImpl(glWindow); + + glWindow.destroy(); + } + + // @Test + public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + GLWindow glWindow = GLWindow.create(glCaps); + + // Wrap the window in a canvas. + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + + // Add the canvas to a frame, and make it all visible. + final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); + frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); + frame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } } ); + + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); + + testImpl(glWindow); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(false); + frame1.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + glWindow.destroy(); + } + + static CodeSeg[] codeSegments = new CodeSeg[] { + new CodeSeg(0x008, 0x00a, "bs, tab, cr"), + new CodeSeg(0x010, 0x011, "shift, ctrl"), // single alt n/a on windows + new CodeSeg(0x01B, 0x01B, "esc"), + new CodeSeg(0x020, 0x024, "space, up, down, end, home"), + new CodeSeg(0x025, 0x028, "cursor"), + new CodeSeg(0x02C, 0x02F, ", - . /"), + new CodeSeg(0x030, 0x039, "0 - 9"), + new CodeSeg(0x03B, 0x03B, ";"), + new CodeSeg(0x03D, 0x03D, "="), + new CodeSeg(0x041, 0x05A, "a - z"), + new CodeSeg(0x05B, 0x05D, "[ \\ ]"), + // new CodeSeg(0x060, 0x06B, "numpad1"), // can be mapped to normal keycodes + // new CodeSeg(0x06D, 0x06F, "numpad2"), // can be mapped to normal keycodes + new CodeSeg(0x07F, 0x07F, "del"), + // new CodeSeg(0x090, 0x091, "num lock, scroll lock"), + // new CodeSeg(0x070, 0x07B, "F1 - F12"), + // new CodeSeg(0x09A, 0x09D, "prt ins hlp meta"), + new CodeSeg(0x0C0, 0x0C0, "back quote"), + new CodeSeg(0x0DE, 0x0DE, "quote"), + // new CodeSeg(0x0E0, 0x0E3, "cursor kp"), + // new CodeSeg(0x080, 0x08F, "dead-1"), + // new CodeSeg(0x096, 0x0A2, "& ^ \" < > { }"), + // new CodeSeg(0x200, 0x20D, "extra-2"), // @ ; .. + }; + + static void testKeyCode(Robot robot, NEWTKeyAdapter keyAdapter) { + List> cse = new ArrayList>(); + + for(int i=0; i queue = keyAdapter.getQueued(); + for(int j=0; j < 10 && queue.size() < 3 * codeCount; j++) { // wait until events are collected + robot.delay(100); + } + final ArrayList events = new ArrayList(queue); + cse.add(events); + } + Assert.assertEquals("KeyCode impl. incomplete", true, NEWTKeyUtil.validateKeyCode(codeSegments, cse, true)); + } + + void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { + final Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + + GLEventListener demo1 = new RedSquareES2(); + TestListenerCom01AWT.setDemoFields(demo1, glWindow, false); + glWindow.addGLEventListener(demo1); + + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1KA.setVerbose(false); + glWindow.addKeyListener(glWindow1KA); + + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); + AWTRobotUtil.clearAWTFocus(robot); + + // Continuous animation .. + Animator animator = new Animator(glWindow); + animator.start(); + + Thread.sleep(durationPerTest); // manual testing + + glWindow1KA.reset(); + AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic + // AWTRobotUtil.assertRequestFocusAndWait(robot, glWindow, glWindow, null, null); // by mouse click + + // + // Test the key event order w/o auto-repeat + // + testKeyCode(robot, glWindow1KA); + + // Remove listeners to avoid logging during dispose/destroy. + glWindow.removeKeyListener(glWindow1KA); + + // Shutdown the test. + animator.stop(); + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i keyEvents) { for(int i=0; i> keyEventsList, boolean verbose) { + final List missCodes = new ArrayList(); + int totalCodeCount = 0; + boolean res = true; + for(int i=0; i keyEvents = keyEventsList.get(i); + res &= validateKeyCode(missCodes, codeSeg, keyEvents, verbose); + } + if(verbose) { + System.err.println("*** Total KeyCode Misses "+missCodes.size()+" / "+totalCodeCount+", valid "+res); + for(int i=0; i missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) { + final int codeCount = codeSeg.max - codeSeg.min + 1; + int misses = 0; + for(int i=0; i Date: Sun, 28 Oct 2012 22:56:21 +0100 Subject: GLRendererQuirks: Add RequiresBoundVAO (w/ impl.), GLSLBuggyDiscard (todo) ; GLContextImpl: Bind default VAO if having quirk RequiresBoundVAO. OSX w/ OpenGL >= 3 core context implementation requires a bound VAO for vertex attribute operations, i.e. VertexAttributePointer(..). This has been experienced on OSX 10.7.5, OpenGL 3.2 core w/ Nvidia GPU and in several forum posts. Such 'behavior' violates the GL 3.2 core specification, which does not state this requirement, hence it is a bug. (Please correct me if I am wrong!) GLContextImpl works around this quirk, by generating a default VAO and binds it at 1st makeCurrent (@creation) and deletes it at destroy. This is minimal invasive since no action is required for subsequent makeCurrent or release. We assume if a user uses and binds a VAO herself, she will mind this quirk. Note: We could enhance this workaround by quering for a currently bound VAO at makeCurrent() and bind our default if none. However, we refrain from this operation to minimize the workaround and complexity. --- make/scripts/tests.sh | 4 +-- .../com/jogamp/opengl/GLRendererQuirks.java | 11 ++++++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 29 +++++++++++++++++++--- 3 files changed, 36 insertions(+), 8 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0db48b289..92a492c74 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -245,7 +245,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -378,7 +378,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* -testawt com.jogamp.opengl.test.junit.newt.TestKeyCodeNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestKeyCodeNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 82799bf67..51944cb71 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -58,12 +58,19 @@ public class GLRendererQuirks { /** SIGSEGV on setSwapInterval() after changing the context's drawable w/ 'Mesa 8.0.4' dri2SetSwapInterval/DRI2 (soft & intel) */ public static final int NoSetSwapIntervalPostRetarget = 4; + + /** Requires a bound VAO for vertex attribute operations, i.e. GL impl. uses no default VAO. Violates GL 3.2. On OSX OpenGL 3.2 context. FIXME: Constrain version. */ + public static final int RequiresBoundVAO = 5; + + /** GLSL discard command leads to undefined behavior or won't get compiled if being used. Appears to happen on Nvidia Tegra2. FIXME: Constrain version. */ + public static final int GLSLBuggyDiscard = 6; /** Number of quirks known. */ - public static final int COUNT = 5; + public static final int COUNT = 7; private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", - "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget" + "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "RequiresBoundVAO", + "GLSLBuggyDiscard" }; private final int _bitmask; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index d2e0bb407..48184119b 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -98,7 +98,8 @@ public abstract class GLContextImpl extends GLContext { private final GLStateTracker glStateTracker = new GLStateTracker(); private GLDebugMessageHandler glDebugHandler = null; private final int[] boundFBOTarget = new int[] { 0, 0 }; // { draw, read } - + private int defaultVAO = 0; + protected GLDrawableImpl drawable; protected GLDrawableImpl drawableRead; @@ -347,6 +348,12 @@ public abstract class GLContextImpl extends GLContext { } catch (Throwable t) { drawableContextRealizedException = t; } + if(0 != defaultVAO) { + int[] tmp = new int[] { defaultVAO }; + gl.getGL2GL3().glBindVertexArray(0); + gl.getGL2GL3().glDeleteVertexArrays(1, tmp, 0); + defaultVAO = 0; + } glDebugHandler.enable(false); if(lock.getHoldCount() > 1) { // pending release() after makeCurrent() @@ -563,6 +570,13 @@ public abstract class GLContextImpl extends GLContext { final boolean created; try { created = createImpl(shareWith); // may throws exception if fails! + if( created && glRendererQuirks.exist(GLRendererQuirks.RequiresBoundVAO) ) { + // Workaround: Create a default VAO to be used per default on makeCurrent + final int[] tmp = new int[1]; + gl.getGL2GL3().glGenVertexArrays(1, tmp, 0); + defaultVAO = tmp[0]; + gl.getGL2GL3().glBindVertexArray(defaultVAO); + } } finally { if (null != shareWith) { shareWith.getDrawableImpl().unlockSurface(); @@ -1292,11 +1306,18 @@ public abstract class GLContextImpl extends GLContext { // OS related quirks if( Platform.getOSType() == Platform.OSType.MACOS ) { - final int quirk = GLRendererQuirks.NoOffscreenBitmap; + final int quirk1 = GLRendererQuirks.NoOffscreenBitmap; if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()); + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk1)+": cause: OS "+Platform.getOSType()); + } + quirks[i++] = quirk1; + if( 3 <= ctxMajorVersion ) { + final int quirk2 = GLRendererQuirks.RequiresBoundVAO; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk2)+": cause: OS "+Platform.getOSType()); + } + quirks[i++] = quirk2; } - quirks[i++] = quirk; } else if( Platform.getOSType() == Platform.OSType.WINDOWS ) { final int quirk = GLRendererQuirks.NoDoubleBufferedBitmap; if(DEBUG) { -- cgit v1.2.3 From cbbfb0170eee1fb57e6ddc47da082bd93fe7ad85 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 29 Oct 2012 11:51:16 +0100 Subject: Complete Rename NEWT KeyEvent Unit tests, commit 85851c9839d620bcbbd07b6ca833f1a5901831cc --- make/scripts/tests-x64.bat | 9 +++++---- make/scripts/tests.sh | 12 ++++++------ .../jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java | 4 ++-- .../test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java | 4 ++-- .../opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java | 4 ++-- .../junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java | 4 ++-- 6 files changed, 19 insertions(+), 18 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 6c9dae729..5a8ca34af 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -32,10 +32,11 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSi REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestKeyCodeNEWT %* + +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 92a492c74..ea3fa68e2 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -245,7 +245,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -375,10 +375,10 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventOrderNEWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestKeyEventAutoRepeatNEWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestKeyPressReleaseUnmaskRepeatNEWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestKeyCodeNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* @@ -411,7 +411,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # Misc Utils # #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java index 8af0f0246..baa735889 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java @@ -71,7 +71,7 @@ import com.jogamp.opengl.test.junit.util.NEWTKeyUtil.CodeSeg; * *

    */ -public class TestKeyCodeNEWT extends UITestCase { +public class TestNewtKeyCodeAWT extends UITestCase { static int width, height; static long durationPerTest = 100; static long awtWaitTimeout = 1000; @@ -248,7 +248,7 @@ public class TestKeyCodeNEWT extends UITestCase { System.err.println(stdin.readLine()); */ System.out.println("durationPerTest: "+durationPerTest); - String tstname = TestKeyCodeNEWT.class.getName(); + String tstname = TestNewtKeyCodeAWT.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java index 22c362dd8..51f3cb7c9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java @@ -83,7 +83,7 @@ import com.jogamp.opengl.test.junit.util.*; * The idea is if you mask out auto-repeat in your event listener * you just get one long pressed key D/U/T triple. */ -public class TestKeyEventAutoRepeatNEWT extends UITestCase { +public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { static int width, height; static long durationPerTest = 100; static long awtWaitTimeout = 1000; @@ -301,7 +301,7 @@ public class TestKeyEventAutoRepeatNEWT extends UITestCase { System.err.println(stdin.readLine()); */ System.out.println("durationPerTest: "+durationPerTest); - String tstname = TestKeyEventAutoRepeatNEWT.class.getName(); + String tstname = TestNewtKeyEventAutoRepeatAWT.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java index 31d9912d1..5f55fbf97 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java @@ -67,7 +67,7 @@ import com.jogamp.opengl.test.junit.util.*; * *

    */ -public class TestKeyEventOrderNEWT extends UITestCase { +public class TestNewtKeyEventOrderAWT extends UITestCase { static int width, height; static long durationPerTest = 100; static long awtWaitTimeout = 1000; @@ -227,7 +227,7 @@ public class TestKeyEventOrderNEWT extends UITestCase { System.err.println(stdin.readLine()); */ System.out.println("durationPerTest: "+durationPerTest); - String tstname = TestKeyEventOrderNEWT.class.getName(); + String tstname = TestNewtKeyEventOrderAWT.class.getName(); org.junit.runner.JUnitCore.main(tstname); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java index 6f3b97f0c..e6d75afba 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java @@ -61,7 +61,7 @@ import com.jogamp.opengl.test.junit.util.*; /** * Testing key press and release events w/o AUTO-REPEAT */ -public class TestKeyPressReleaseUnmaskRepeatNEWT extends UITestCase { +public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase { static int width, height; static long durationPerTest = 100; static long awtWaitTimeout = 1000; @@ -214,7 +214,7 @@ public class TestKeyPressReleaseUnmaskRepeatNEWT extends UITestCase { System.err.println(stdin.readLine()); */ System.out.println("durationPerTest: "+durationPerTest); - String tstname = TestKeyPressReleaseUnmaskRepeatNEWT.class.getName(); + String tstname = TestNewtKeyPressReleaseUnmaskRepeatAWT.class.getName(); org.junit.runner.JUnitCore.main(tstname); } -- cgit v1.2.3 From 3c8a814d7fb536f298507413f290309ed7c0f24e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 29 Oct 2012 14:44:11 +0100 Subject: TestNewtKeyEventAutoRepeatAWT: Wait for 'some' KeyEvents and check count; TestNewtKeyPressReleaseUnmaskRepeatAWT: Enable NewtCanvasAWT test --- make/scripts/tests-x64.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- .../opengl/test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java | 11 +++++++++-- .../junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 5a8ca34af..887af5484 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -34,9 +34,9 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ea3fa68e2..85a7139e0 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -376,7 +376,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* +testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT @@ -411,7 +411,7 @@ function testawtswt() { # Misc Utils # #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java index 51f3cb7c9..d373f1486 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventAutoRepeatAWT.java @@ -165,8 +165,15 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { System.err.println("+++ KEY Event Auto-Repeat START Input Loop: "+i); AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_A, pressDurationMS); robot.waitForIdle(); - AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 1000); // 1s .. no AR anymore - robot.waitForIdle(); + AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 500); // 1s .. no AR anymore + robot.waitForIdle(); + final int minCodeCount = firstIdx + 3; + final int desiredCodeCount = firstIdx + 6; + for(int j=0; j < 10 && keyEvents.size() < desiredCodeCount; j++) { // wait until events are collected + robot.delay(100); + } + Assert.assertTrue("AR Test didn't collect enough key events: required min "+minCodeCount+", received "+(keyEvents.size()-firstIdx)+", "+keyEvents, + keyEvents.size() >= minCodeCount ); first[i][0] = (KeyEvent) keyEvents.get(firstIdx+0); first[i][1] = (KeyEvent) keyEvents.get(firstIdx+1); first[i][2] = (KeyEvent) keyEvents.get(firstIdx+2); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java index e6d75afba..c4dc5a8ad 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java @@ -98,7 +98,7 @@ public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase { glWindow.destroy(); } - // @Test + @Test public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { GLWindow glWindow = GLWindow.create(glCaps); -- cgit v1.2.3 From b62e1d027c289877686d6008ea8dd40e4e1541ec Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 04:04:39 +0100 Subject: Fix NEWT KeyEvent: Deliver keyChar w/ pressed and released; Deliver proper modified flags and modifier-key events; Simplify Windows key handling Preface: Modifier-keys are SHIFT, CTRL, ALT and META and they have a matching modifier-bit. - Simplify Windows key handling - Employ MapVirtualKey(..) for virtual-key to character and scancode to virtual-key mappings, allowing to drop tracking of keyCode to keyChar in java code. This also removes the platform restriction of delivering keyChar at TYPED only. - Deliver keyChar w/ pressed and released - Due to the lift restriction on the Windows platform (see above), we can deliver keyChar w/ all key events on all platforms. - Deliver proper modified flags and modifier-key events All modifier-keys deliver pressed, released and typed events with their modifier-bit set. The above is covered by unit tests, which passed on X11, Windows and OSX (manual test run). --- make/scripts/tests-x64.bat | 5 +- make/scripts/tests.sh | 8 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 111 +++++---- .../jogamp/newt/driver/macosx/WindowDriver.java | 11 +- .../jogamp/newt/driver/windows/WindowDriver.java | 40 +-- src/newt/native/NewtMacWindow.m | 7 +- src/newt/native/WindowsWindow.c | 199 +++++++++------ src/newt/native/X11Display.c | 26 +- .../opengl/test/junit/newt/TestNewtKeyCodeAWT.java | 259 ------------------- .../junit/newt/TestNewtKeyCodeModifiersAWT.java | 275 +++++++++++++++++++++ .../test/junit/newt/TestNewtKeyCodesAWT.java | 246 ++++++++++++++++++ .../junit/newt/TestNewtKeyEventAutoRepeatAWT.java | 25 +- .../test/junit/newt/TestNewtKeyEventOrderAWT.java | 6 +- .../TestNewtKeyPressReleaseUnmaskRepeatAWT.java | 2 +- .../opengl/test/junit/util/AWTKeyAdapter.java | 26 +- .../opengl/test/junit/util/AWTMouseAdapter.java | 20 +- .../opengl/test/junit/util/AWTRobotUtil.java | 14 +- .../test/junit/util/InputEventCountAdapter.java | 3 +- .../opengl/test/junit/util/NEWTKeyAdapter.java | 26 +- .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 46 ++-- .../opengl/test/junit/util/NEWTMouseAdapter.java | 20 +- 21 files changed, 865 insertions(+), 510 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeModifiersAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodesAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 887af5484..7de5fe51c 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -34,9 +34,10 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 85a7139e0..6c0095c51 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -263,7 +263,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* @@ -376,9 +376,11 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT $* -testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeAWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT $* +testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 8d3d9e88f..927c9aa85 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -59,6 +59,10 @@ package com.jogamp.newt.event; * The idea is if you mask out auto-repeat in your event listener * you just get one long pressed key D/U/T triple. *

    + *

    + * {@link #isModifierKey() Modifiers keys} will produce regular events (pressed, released and typed), + * however they will not produce Auto-Repeat events itself. + *

    */ @SuppressWarnings("serial") public class KeyEvent extends InputEvent @@ -69,12 +73,12 @@ public class KeyEvent extends InputEvent this.keyChar=keyChar; } - /** Only valid on all platforms at {@link KeyListener#keyTyped(KeyEvent)} */ + /** Returns the character matching the {@link #getKeyCode() virtual key code}, if exist. */ public char getKeyChar() { return keyChar; } - /** Always valid. */ + /** Returns the virtual key code. */ public int getKeyCode() { return keyCode; } @@ -100,49 +104,68 @@ public class KeyEvent extends InputEvent } } - public boolean isActionKey() { + /** Returns true if keyCode represents a modifier key, i.e. one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. */ + public static boolean isModifierKey(int keyCode) { + switch (keyCode) { + case VK_SHIFT: + case VK_CONTROL: + case VK_ALT: + case VK_ALT_GRAPH: + case VK_META: + return true; + default: + return false; + } + } + + /** Returns true if {@link #getKeyCode()} represents a modifier key, i.e. one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. */ + public boolean isModifierKey() { + return isModifierKey(keyCode); + } + + public boolean isActionKey() { switch (keyCode) { - case VK_HOME: - case VK_END: - case VK_PAGE_UP: - case VK_PAGE_DOWN: - case VK_UP: - case VK_DOWN: - case VK_LEFT: - case VK_RIGHT: - - case VK_F1: - case VK_F2: - case VK_F3: - case VK_F4: - case VK_F5: - case VK_F6: - case VK_F7: - case VK_F8: - case VK_F9: - case VK_F10: - case VK_F11: - case VK_F12: - case VK_F13: - case VK_F14: - case VK_F15: - case VK_F16: - case VK_F17: - case VK_F18: - case VK_F19: - case VK_F20: - case VK_F21: - case VK_F22: - case VK_F23: - case VK_F24: - case VK_PRINTSCREEN: - case VK_CAPS_LOCK: - case VK_PAUSE: - case VK_INSERT: - - case VK_HELP: - case VK_WINDOWS: - return true; + case VK_HOME: + case VK_END: + case VK_PAGE_UP: + case VK_PAGE_DOWN: + case VK_UP: + case VK_DOWN: + case VK_LEFT: + case VK_RIGHT: + + case VK_F1: + case VK_F2: + case VK_F3: + case VK_F4: + case VK_F5: + case VK_F6: + case VK_F7: + case VK_F8: + case VK_F9: + case VK_F10: + case VK_F11: + case VK_F12: + case VK_F13: + case VK_F14: + case VK_F15: + case VK_F16: + case VK_F17: + case VK_F18: + case VK_F19: + case VK_F20: + case VK_F21: + case VK_F22: + case VK_F23: + case VK_F24: + case VK_PRINTSCREEN: + case VK_CAPS_LOCK: + case VK_PAUSE: + case VK_INSERT: + + case VK_HELP: + case VK_WINDOWS: + return true; } return false; } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 121c3fa99..5755bdf11 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -324,9 +324,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // Note that we send the key char for the key code on this // platform -- we do not get any useful key codes out of the system final int keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow.sendKeyEvent "+Thread.currentThread().getName()+" char: 0x"+Integer.toHexString(keyChar)+", code 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)); - } + // final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+", mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + + // 1:1 Order: OSX and NEWT delivery order is PRESSED, RELEASED and TYPED // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: @@ -334,7 +335,6 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl keyRepeatState.put(keyCode, false); // prev == true -> AR out keyPressedState.put(keyCode, false); } - keyChar = (char)-1; break; case KeyEvent.EVENT_KEY_PRESSED: if( isKeyCodeTracked(keyCode) ) { @@ -342,11 +342,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // key was already pressed keyRepeatState.put(keyCode, true); // prev == false -> AR in modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); // RELEASED + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); // RELEASED emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED } } - keyChar = (char)-1; break; case KeyEvent.EVENT_KEY_TYPED: break; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 8b57a241d..c513b9e84 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,7 +46,6 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; -import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -260,11 +259,6 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } - /** We have to regenerate the keyCode for EVENT_KEY_TYPED on this platform. */ - private int lastPressedKeyCode = 0; - /** We have to reorder the native key events to match NEWT's order */ - private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); - private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { if( send ) { super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); @@ -274,52 +268,42 @@ public class WindowDriver extends WindowImpl { } private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - // final int kc = 0 <= keyCode ? keyCode : lastPressedKeyCode; - // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key "+toHexString(kc)+", mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(kc)+", repeat "+isKeyInAutoRepeat(kc)); - + final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + // Reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: if( isKeyCodeTracked(keyCode) ) { - if( keyRepeatState.put(keyCode, false) ) { + if( keyRepeatState.put(keyCode, false) && !isModifierKeyCode ) { // AR out - send out missing PRESSED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); } keyPressedState.put(keyCode, false); } emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - final char lastTypedKeyChar = (char) typedKeyCode2KeyChar.put(keyCode, 0); - if( 0 < lastTypedKeyChar ) { - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, lastTypedKeyChar); - } + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); break; case KeyEvent.EVENT_KEY_PRESSED: - lastPressedKeyCode = keyCode; if( isKeyCodeTracked(keyCode) ) { if( keyPressedState.put(keyCode, true) ) { // key was already pressed - if( keyRepeatState.put(keyCode, true) ) { - emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, (char)-1); - } // else AR in - skip already send PRESSED + if( keyRepeatState.put(keyCode, true) && !isModifierKeyCode ) { + emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); + } // else AR in - skip already send PRESSED ; or ALT } else { - emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); } } else { - emitKeyEvent(send, wait, eventType, modifiers, keyCode, (char)-1); + emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); } break; case KeyEvent.EVENT_KEY_TYPED: - if(-1==keyCode) { - keyCode = lastPressedKeyCode; - } - lastPressedKeyCode = -1; if( 1 == isKeyInAutoRepeat(keyCode) ) { modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, (char)-1); + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - } else { - typedKeyCode2KeyChar.put(keyCode, keyChar); } break; } diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index de5f3773c..b89b5c21d 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -840,12 +840,11 @@ static jint mods2JavaMods(NSUInteger mods) { if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { modsDown[keyIdx] = YES; - mods &= ~keyMask; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_TYPED]; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_PRESSED]; } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { modsDown[keyIdx] = NO; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_RELEASED]; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods eventType: EVENT_KEY_TYPED]; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_RELEASED]; + [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_TYPED]; } } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index bb90a2dce..2152166e4 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -463,87 +463,108 @@ static void BuildDynamicKeyMapTable() } // for each VK_OEM_* } -static jint GetModifiers() { +static jint GetModifiers(BOOL altKeyFlagged, UINT jkey) { jint modifiers = 0; // have to do &0xFFFF to avoid runtime assert caused by compiling with // /RTCcsu - if (HIBYTE((GetKeyState(VK_CONTROL) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_CONTROL) & 0xFFFF)) != 0 || J_VK_CONTROL == jkey ) { modifiers |= EVENT_CTRL_MASK; } - if (HIBYTE((GetKeyState(VK_SHIFT) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_SHIFT) & 0xFFFF)) != 0 || J_VK_SHIFT == jkey ) { modifiers |= EVENT_SHIFT_MASK; } - if (HIBYTE((GetKeyState(VK_MENU) & 0xFFFF)) != 0) { + if ( altKeyFlagged || HIBYTE((GetKeyState(VK_MENU) & 0xFFFF)) != 0 || J_VK_ALT == jkey ) { modifiers |= EVENT_ALT_MASK; } - if (HIBYTE((GetKeyState(VK_LBUTTON) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_LBUTTON) & 0xFFFF)) != 0 ) { modifiers |= EVENT_BUTTON1_MASK; } - if (HIBYTE((GetKeyState(VK_MBUTTON) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_MBUTTON) & 0xFFFF)) != 0 ) { modifiers |= EVENT_BUTTON2_MASK; } - if (HIBYTE((GetKeyState(VK_RBUTTON) & 0xFFFF)) != 0) { + if ( HIBYTE((GetKeyState(VK_RBUTTON) & 0xFFFF)) != 0 ) { modifiers |= EVENT_BUTTON3_MASK; } return modifiers; } -static int WmChar(JNIEnv *env, jobject window, UINT character, UINT repCnt, - UINT flags, BOOL system) -{ +static BOOL IsAltKeyDown(BYTE flags, BOOL system) { // The Alt modifier is reported in the 29th bit of the lParam, - // i.e., it is the 13th bit of `flags' (which is HIWORD(lParam)). - BOOL alt_is_down = (flags & (1<<13)) != 0; - if (system && alt_is_down) { - if (character == VK_SPACE) { - return 1; - } - } - - if (character == VK_RETURN) { - character = J_VK_ENTER; - } - (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_TYPED, - GetModifiers(), - (jint) -1, - (jchar) character); - return 1; + // i.e., it is the 5th bit of `flags' (which is HIBYTE(HIWORD(lParam))). + return system && ( flags & (1<<5) ) != 0; } -UINT WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers) +UINT WindowsKeyToJavaKey(UINT windowsKey) { - int i, j; + int i, j, javaKey = J_VK_UNDEFINED; // for the general case, use a bi-directional table for (i = 0; keyMapTable[i].windowsKey != 0; i++) { if (keyMapTable[i].windowsKey == windowsKey) { - return keyMapTable[i].javaKey; + javaKey = keyMapTable[i].javaKey; } } - for (j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) { - if (dynamicKeyMapTable[j].windowsKey == windowsKey) { - if (dynamicKeyMapTable[j].javaKey != J_VK_UNDEFINED) { - return dynamicKeyMapTable[j].javaKey; - } else { - break; + if( J_VK_UNDEFINED == javaKey ) { + for (j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) { + if (dynamicKeyMapTable[j].windowsKey == windowsKey) { + if (dynamicKeyMapTable[j].javaKey != J_VK_UNDEFINED) { + javaKey = dynamicKeyMapTable[j].javaKey; + } else { + break; + } } } } - return J_VK_UNDEFINED; +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: WindowsKeyToJavaKey 0x%X -> 0x%X\n", windowsKey, javaKey); +#endif + return javaKey; } -static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt, - UINT flags, BOOL system) -{ +#ifndef MAPVK_VSC_TO_VK + #define MAPVK_VSC_TO_VK 1 +#endif +#ifndef MAPVK_VK_TO_CHAR + #define MAPVK_VK_TO_CHAR 2 +#endif + +static UINT WmVKey2ShiftedChar(UINT wkey, UINT modifiers) { + UINT c = MapVirtualKey(wkey, MAPVK_VK_TO_CHAR); + if( 0 != ( modifiers & EVENT_SHIFT_MASK ) ) { + return islower(c) ? toupper(c) : c; + } + return isupper(c) ? tolower(c) : c; +} + +static int WmChar(JNIEnv *env, jobject window, UINT character, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { + UINT modifiers = 0, jkey = 0, wkey = 0; + + wkey = MapVirtualKey(scanCode, MAPVK_VSC_TO_VK); + jkey = WindowsKeyToJavaKey(wkey); + modifiers = GetModifiers( IsAltKeyDown(flags, system), 0 ); + + if (character == VK_RETURN) { + character = J_VK_ENTER; + } + + (*env)->CallVoidMethod(env, window, sendKeyEventID, + (jint) EVENT_KEY_TYPED, + modifiers, + (jint) jkey, + (jchar) character); + return 1; +} + +static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { UINT modifiers = 0, jkey = 0, character = -1; if (wkey == VK_PROCESSKEY) { return 1; } - modifiers = GetModifiers(); - jkey = WindowsKeyToJavaKey(wkey, modifiers); + jkey = WindowsKeyToJavaKey(wkey); + modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey ); + character = WmVKey2ShiftedChar(wkey, modifiers); /* character = WindowsKeyToJavaChar(wkey, modifiers, SAVE); @@ -562,7 +583,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt, if (jkey == J_VK_DELETE) { (*env)->CallVoidMethod(env, window, sendKeyEventID, (jint) EVENT_KEY_TYPED, - GetModifiers(), + modifiers, (jint) -1, (jchar) '\177'); } @@ -570,16 +591,16 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, UINT repCnt, return 0; } -static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, UINT repCnt, - UINT flags, BOOL system) -{ +static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { UINT modifiers = 0, jkey = 0, character = -1; if (wkey == VK_PROCESSKEY) { return 1; } - modifiers = GetModifiers(); - jkey = WindowsKeyToJavaKey(wkey, modifiers); + jkey = WindowsKeyToJavaKey(wkey); + modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey ); + character = WmVKey2ShiftedChar(wkey, modifiers); + /* character = WindowsKeyToJavaChar(wkey, modifiers, SAVE); */ @@ -775,21 +796,15 @@ static void WmSize(JNIEnv *env, jobject window, HWND wnd, UINT type) (*env)->CallVoidMethod(env, window, sizeChangedID, JNI_FALSE, w, h, JNI_FALSE); } -static LRESULT CALLBACK wndProc(HWND wnd, UINT message, - WPARAM wParam, LPARAM lParam) -{ +static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT res = 0; int useDefWindowProc = 0; JNIEnv *env = NULL; jobject window = NULL; BOOL isKeyDown = FALSE; WindowUserData * wud; - -#ifdef DEBUG_KEYS - if ( WM_KEYDOWN == message ) { - STD_PRINT("*** WindowsWindow: wndProc window %p, 0x%X %d/%d\n", wnd, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); - } -#endif + WORD repCnt; + BYTE scanCode, flags; #if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1200 ) wud = (WindowUserData *) GetWindowLong(wnd, GWL_USERDATA); @@ -831,26 +846,57 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, break; case WM_SYSCHAR: - useDefWindowProc = WmChar(env, window, wParam, - LOWORD(lParam), HIWORD(lParam), FALSE); + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_SYSCHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, TRUE); + break; + + case WM_SYSKEYDOWN: + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, TRUE); + break; + + case WM_SYSKEYUP: + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, TRUE); break; case WM_CHAR: - useDefWindowProc = WmChar(env, window, wParam, - LOWORD(lParam), HIWORD(lParam), TRUE); + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_CHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, FALSE); break; case WM_KEYDOWN: + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc sending window %p -> %p, 0x%X %d/%d\n", wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); + STD_PRINT("*** WindowsWindow: windProc WM_KEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif - useDefWindowProc = WmKeyDown(env, window, wParam, - LOWORD(lParam), HIWORD(lParam), FALSE); + useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, FALSE); break; case WM_KEYUP: - useDefWindowProc = WmKeyUp(env, window, wParam, - LOWORD(lParam), HIWORD(lParam), FALSE); + repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); + repCnt = LOWORD(lParam); +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: windProc WM_KEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); +#endif + useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, FALSE); break; case WM_SIZE: @@ -873,7 +919,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 1, (jint) 0); useDefWindowProc = 1; @@ -882,7 +928,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_LBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 1, (jint) 0); useDefWindowProc = 1; @@ -893,7 +939,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 2, (jint) 0); useDefWindowProc = 1; @@ -902,7 +948,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_MBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 2, (jint) 0); useDefWindowProc = 1; @@ -913,7 +959,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 3, (jint) 0); useDefWindowProc = 1; @@ -922,7 +968,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_RBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 3, (jint) 0); useDefWindowProc = 1; @@ -931,7 +977,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, case WM_MOUSEMOVE: (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jint) 0, (jint) 0); useDefWindowProc = 1; @@ -956,7 +1002,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, ScreenToClient(wnd, &eventPt); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_WHEEL_MOVED, - GetModifiers(), + GetModifiers( FALSE, 0 ), (jint) eventPt.x, (jint) eventPt.y, (jint) 1, (jint) (GET_WHEEL_DELTA_WPARAM(wParam)/120.0f)); useDefWindowProc = 1; @@ -1035,11 +1081,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_DispatchMes // DBG_PRINT("*** WindowsWindow.DispatchMessages0: thread 0x%X - gotOne %d\n", (int)GetCurrentThreadId(), (int)gotOne); if (gotOne) { ++i; -#ifdef DEBUG_KEYS - if(WM_KEYDOWN == msg.message) { - STD_PRINT("*** WindowsWindow: DispatchMessages window %p, 0x%X %d/%d\n", msg.hwnd, msg.message, (int)LOWORD(msg.lParam), (int)HIWORD(msg.lParam)); - } -#endif TranslateMessage(&msg); DispatchMessage(&msg); } diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 89cf75043..3f34a16b6 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -154,24 +154,24 @@ static jint X11KeySym2NewtVKey(KeySym keySym) { return keySym; } -static jint X11InputState2NewtModifiers(unsigned int xstate) { +static jint X11InputState2NewtModifiers(unsigned int xstate, KeySym keySym) { jint modifiers = 0; - if ((ControlMask & xstate) != 0) { + if ( (ControlMask & xstate) != 0 || J_VK_CONTROL == keySym ) { modifiers |= EVENT_CTRL_MASK; } - if ((ShiftMask & xstate) != 0) { + if ( (ShiftMask & xstate) != 0 || J_VK_SHIFT == keySym ) { modifiers |= EVENT_SHIFT_MASK; } - if ((Mod1Mask & xstate) != 0) { + if ( (Mod1Mask & xstate) != 0 || J_VK_ALT == keySym ) { modifiers |= EVENT_ALT_MASK; } - if ((Button1Mask & xstate) != 0) { + if ( (Button1Mask & xstate) != 0 ) { modifiers |= EVENT_BUTTON1_MASK; } - if ((Button2Mask & xstate) != 0) { + if ( (Button2Mask & xstate) != 0 ) { modifiers |= EVENT_BUTTON2_MASK; } - if ((Button3Mask & xstate) != 0) { + if ( (Button3Mask & xstate) != 0 ) { modifiers |= EVENT_BUTTON3_MASK; } @@ -397,13 +397,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage keyChar=0; keySym = X11KeySym2NewtVKey(keySym); } - modifiers |= X11InputState2NewtModifiers(evt.xkey.state) | autoRepeatModifiers; + modifiers |= X11InputState2NewtModifiers(evt.xkey.state, keySym) | autoRepeatModifiers; break; case ButtonPress: case ButtonRelease: case MotionNotify: - modifiers |= X11InputState2NewtModifiers(evt.xbutton.state); + modifiers |= X11InputState2NewtModifiers(evt.xbutton.state, 0); break; default: @@ -472,23 +472,23 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage case KeyPress: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_PRESSED, - modifiers, keySym, (jchar) -1); + modifiers, keySym, (jchar) keyChar); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_PRESSED, - modifiers, keySym, (jchar) -1); + modifiers, keySym, (jchar) keyChar); #endif break; case KeyRelease: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, - modifiers, keySym, (jchar) -1); + modifiers, keySym, (jchar) keyChar); (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, modifiers, keySym, (jchar) keyChar); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, - modifiers, keySym, (jchar) -1); + modifiers, keySym, (jchar) keyChar); (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, modifiers, keySym, (jchar) keyChar); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java deleted file mode 100644 index 37debfcc2..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyCodeAWT.java +++ /dev/null @@ -1,259 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import org.junit.After; -import org.junit.Assert; -import org.junit.AfterClass; -import org.junit.Assume; -import org.junit.Before; - -import java.awt.AWTException; -import java.awt.BorderLayout; -import java.awt.Robot; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.EventObject; -import java.util.List; - -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.swing.JFrame; - -import java.io.IOException; - -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.newt.awt.NewtCanvasAWT; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; - -import com.jogamp.opengl.test.junit.util.*; -import com.jogamp.opengl.test.junit.util.NEWTKeyUtil.CodeSeg; - -/** - * Testing key event order incl. auto-repeat (Bug 601) - * - *

    - * Note Event order: - *

      - *
    1. {@link #EVENT_KEY_PRESSED}
    2. - *
    3. {@link #EVENT_KEY_RELEASED}
    4. - *
    5. {@link #EVENT_KEY_TYPED}
    6. - *
    - *

    - */ -public class TestNewtKeyCodeAWT extends UITestCase { - static int width, height; - static long durationPerTest = 100; - static long awtWaitTimeout = 1000; - - static GLCapabilities glCaps; - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glCaps = new GLCapabilities(null); - } - - @AfterClass - public static void release() { - } - - @Before - public void initTest() { - } - - @After - public void releaseTest() { - } - - @Test - public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { - GLWindow glWindow = GLWindow.create(glCaps); - glWindow.setSize(width, height); - glWindow.setVisible(true); - - testImpl(glWindow); - - glWindow.destroy(); - } - - // @Test - public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { - GLWindow glWindow = GLWindow.create(glCaps); - - // Wrap the window in a canvas. - final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); - - // Add the canvas to a frame, and make it all visible. - final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); - frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); - frame1.setSize(width, height); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setVisible(true); - } } ); - - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); - - testImpl(glWindow); - - try { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setVisible(false); - frame1.dispose(); - }}); - } catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - glWindow.destroy(); - } - - static CodeSeg[] codeSegments = new CodeSeg[] { - new CodeSeg(0x008, 0x008, "bs"), - // new CodeSeg(0x009, 0x009, "tab"), // TAB functions as focus traversal key - new CodeSeg(0x00a, 0x00a, "cr"), - new CodeSeg(0x010, 0x011, "shift, ctrl"), // single alt n/a on windows - new CodeSeg(0x01B, 0x01B, "esc"), - new CodeSeg(0x020, 0x024, "space, up, down, end, home"), - new CodeSeg(0x025, 0x028, "cursor"), - new CodeSeg(0x02C, 0x02F, ", - . /"), - new CodeSeg(0x030, 0x039, "0 - 9"), - new CodeSeg(0x03B, 0x03B, ";"), - new CodeSeg(0x03D, 0x03D, "="), - new CodeSeg(0x041, 0x05A, "a - z"), - new CodeSeg(0x05B, 0x05D, "[ \\ ]"), - // new CodeSeg(0x060, 0x06B, "numpad1"), // can be mapped to normal keycodes - // new CodeSeg(0x06D, 0x06F, "numpad2"), // can be mapped to normal keycodes - new CodeSeg(0x07F, 0x07F, "del"), - // new CodeSeg(0x090, 0x091, "num lock, scroll lock"), - // new CodeSeg(0x070, 0x07B, "F1 - F12"), - // new CodeSeg(0x09A, 0x09D, "prt ins hlp meta"), - new CodeSeg(0x0C0, 0x0C0, "back quote"), - new CodeSeg(0x0DE, 0x0DE, "quote"), - // new CodeSeg(0x0E0, 0x0E3, "cursor kp"), - // new CodeSeg(0x080, 0x08F, "dead-1"), - // new CodeSeg(0x096, 0x0A2, "& ^ \" < > { }"), - // new CodeSeg(0x200, 0x20D, "extra-2"), // @ ; .. - }; - - static void testKeyCode(Robot robot, NEWTKeyAdapter keyAdapter) { - final List> cse = new ArrayList>(); - final List queue = keyAdapter.getQueued(); - - for(int i=0; i events = new ArrayList(queue); - cse.add(events); - } - Assert.assertEquals("KeyCode impl. incomplete", true, NEWTKeyUtil.validateKeyCode(codeSegments, cse, true)); - } - - void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { - final Robot robot = new Robot(); - robot.setAutoWaitForIdle(true); - - GLEventListener demo1 = new RedSquareES2(); - TestListenerCom01AWT.setDemoFields(demo1, glWindow, false); - glWindow.addGLEventListener(demo1); - - // NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); - // glWindow.addWindowListener(glWindow1FA); - NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); - glWindow1KA.setVerbose(false); - glWindow.addKeyListener(glWindow1KA); - - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); - - // Continuous animation .. - Animator animator = new Animator(glWindow); - animator.start(); - - Thread.sleep(durationPerTest); // manual testing - - AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic - AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input - glWindow1KA.reset(); - - // - // Test the key event order w/o auto-repeat - // - testKeyCode(robot, glWindow1KA); - - // Remove listeners to avoid logging during dispose/destroy. - glWindow.removeKeyListener(glWindow1KA); - - // Shutdown the test. - animator.stop(); - } - - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - - public static void main(String args[]) throws IOException { - for(int i=0; i queue = keyAdapter.getQueued(); + int i=0; + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, KeyEvent.VK_P); + + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, modifierKey); + } + + static void testKeyCodeAllModifierV1(Robot robot, NEWTKeyAdapter keyAdapter) { + final int m1k = KeyEvent.VK_ALT; + final int m1m = InputEvent.ALT_MASK; + final int m2k = KeyEvent.VK_CONTROL; + final int m2m = InputEvent.CTRL_MASK; + final int m3k = KeyEvent.VK_SHIFT; + final int m3m = InputEvent.SHIFT_MASK; + + keyAdapter.reset(); + AWTRobotUtil.keyPress(0, robot, true, m1k, 10); // press MOD1 + AWTRobotUtil.keyPress(0, robot, true, m2k, 10); // press MOD2 + AWTRobotUtil.keyPress(0, robot, true, m3k, 10); // press MOD3 + AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P + + AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 100); // release+typed P + AWTRobotUtil.keyPress(0, robot, false, m3k, 10); // release+typed MOD + AWTRobotUtil.keyPress(0, robot, false, m2k, 10); // release+typed MOD + AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release+typed MOD + + robot.waitForIdle(); + for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3*4; j++) { // wait until events are collected + robot.delay(100); + } + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3*4, 0); + + final List queue = keyAdapter.getQueued(); + int i=0; + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k); + + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_P); + + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, m3k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m, m2k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m, m1k); + } + + void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { + final Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + + GLEventListener demo1 = new RedSquareES2(); + TestListenerCom01AWT.setDemoFields(demo1, glWindow, false); + glWindow.addGLEventListener(demo1); + + // NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + // glWindow.addWindowListener(glWindow1FA); + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1KA.setVerbose(false); + glWindow.addKeyListener(glWindow1KA); + + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); + + // Continuous animation .. + Animator animator = new Animator(glWindow); + animator.start(); + + Thread.sleep(durationPerTest); // manual testing + + AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + glWindow1KA.reset(); + + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK); + + testKeyCodeAllModifierV1(robot, glWindow1KA); + + // Remove listeners to avoid logging during dispose/destroy. + glWindow.removeKeyListener(glWindow1KA); + + // Shutdown the test. + animator.stop(); + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i { }"), + // new CodeSeg(0x200, 0x20D, "extra-2"), // @ ; .. + }; + + static void testKeyCodes(Robot robot, NEWTKeyAdapter keyAdapter) { + final List> cse = new ArrayList>(); + + for(int i=0; i events = new ArrayList(keyAdapter.getQueued()); + cse.add(events); + } + Assert.assertEquals("KeyCode impl. incomplete", true, NEWTKeyUtil.validateKeyCodes(codeSegments, cse, true)); + } + + void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { + final Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + + GLEventListener demo1 = new RedSquareES2(); + TestListenerCom01AWT.setDemoFields(demo1, glWindow, false); + glWindow.addGLEventListener(demo1); + + // NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + // glWindow.addWindowListener(glWindow1FA); + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1KA.setVerbose(false); + glWindow.addKeyListener(glWindow1KA); + + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); + + // Continuous animation .. + Animator animator = new Animator(glWindow); + animator.start(); + + Thread.sleep(durationPerTest); // manual testing + + AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + glWindow1KA.reset(); + + testKeyCodes(robot, glWindow1KA); + + // Remove listeners to avoid logging during dispose/destroy. + glWindow.removeKeyListener(glWindow1KA); + + // Shutdown the test. + animator.stop(); + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i keyEvents = keyAdapter.getQueued(); int firstIdx = 0; for(int i=0; i= minCodeCount ); + Assert.assertTrue("AR Test didn't collect enough key events: required min "+minCodeCount+", received "+(keyAdapter.getQueueSize()-firstIdx)+", "+keyAdapter.getQueued(), + keyAdapter.getQueueSize() >= minCodeCount ); + final List keyEvents = keyAdapter.getQueued(); first[i][0] = (KeyEvent) keyEvents.get(firstIdx+0); first[i][1] = (KeyEvent) keyEvents.get(firstIdx+1); first[i][2] = (KeyEvent) keyEvents.get(firstIdx+2); @@ -184,22 +184,27 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { System.err.println("+++ KEY Event Auto-Repeat END Input Loop: "+i); // add a pair of normal press/release in between auto-repeat! + firstIdx = keyEvents.size(); AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_B, 10); robot.waitForIdle(); AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 250); robot.waitForIdle(); + for(int j=0; j < 10 && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected + robot.delay(100); + } firstIdx = keyEvents.size(); } // dumpKeyEvents(keyEvents); - + final List keyEvents = keyAdapter.getQueued(); NEWTKeyUtil.validateKeyEventOrder(keyEvents); final boolean hasAR = 0 < keyAdapter.getKeyPressedCount(true) ; - Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3); - final int expTotal = keyEvents.size()/3; - final int expAR = hasAR ? expTotal - loops - loops : 0; - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, expTotal, expAR); + { + final int expTotal = keyEvents.size(); + final int expAR = hasAR ? expTotal - 3 * 2 * loops : 0; // per loop: 3 for non AR events and 3 for non AR 'B' + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, expTotal, expAR); + } if( !hasAR ) { System.err.println("No AUTO-REPEAT triggered by AWT Robot .. aborting test analysis"); @@ -266,7 +271,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { Thread.sleep(durationPerTest); // manual testing AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic - AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input glWindow1KA.reset(); // diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java index 11f552ecb..cf5016173 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyEventOrderAWT.java @@ -56,7 +56,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; import com.jogamp.opengl.test.junit.util.*; /** - * Testing key event order incl. auto-repeat (Bug 601) + * Testing key event order excl. auto-repeat (Bug 601) * *

    * Note Event order: @@ -167,7 +167,7 @@ public class TestNewtKeyEventOrderAWT extends UITestCase { NEWTKeyUtil.validateKeyEventOrder(keyAdapter.getQueued()); - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 6*loops, 0); + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 6*3*loops, 0); } void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { @@ -191,7 +191,7 @@ public class TestNewtKeyEventOrderAWT extends UITestCase { Thread.sleep(durationPerTest); // manual testing AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic - AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input glWindow1KA.reset(); // diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java index 6ebaf2707..c27513905 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestNewtKeyPressReleaseUnmaskRepeatAWT.java @@ -151,7 +151,7 @@ public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase { Thread.sleep(durationPerTest); // manual testing AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic - AWTRobotUtil.requestFocus(robot, glWindow); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input // Remove listeners to avoid logging during dispose/destroy. glWindow.removeKeyListener(simpleKeyPressRelease); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java index a9fa373b5..837ba5da1 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java @@ -46,33 +46,37 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent reset(); } - public void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = false; } - public boolean isPressed() { + public synchronized boolean isPressed() { return pressed; } - public int getCount() { + public synchronized int getCount() { return keyTyped; } - public int getKeyPressedCount(boolean autoRepeatOnly) { + public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { return keyPressed; } - public int getKeyReleasedCount(boolean autoRepeatOnly) { + public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) { return keyReleased; } - public int getKeyTypedCount(boolean autoRepeatOnly) { + public synchronized int getKeyTypedCount(boolean autoRepeatOnly) { return keyTyped; } - public List getQueued() { + public synchronized List getQueued() { return queue; } - public void reset() { + public synchronized int getQueueSize() { + return queue.size(); + } + + public synchronized void reset() { keyTyped = 0; keyPressed = 0; keyReleased = 0; @@ -80,7 +84,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent queue.clear(); } - public void keyPressed(KeyEvent e) { + public synchronized void keyPressed(KeyEvent e) { pressed = true; keyPressed++; queue.add(e); @@ -89,7 +93,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } } - public void keyReleased(KeyEvent e) { + public synchronized void keyReleased(KeyEvent e) { pressed = false; keyReleased++; queue.add(e); @@ -98,7 +102,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } } - public void keyTyped(java.awt.event.KeyEvent e) { + public synchronized void keyTyped(java.awt.event.KeyEvent e) { keyTyped++; queue.add(e); if( verbose ) { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java index 3334f18ea..31362bfa1 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java @@ -45,27 +45,31 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu reset(); } - public void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = false; } - public boolean isPressed() { + public synchronized boolean isPressed() { return pressed; } - public int getCount() { + public synchronized int getCount() { return mouseClicked; } - public List getQueued() { + public synchronized List getQueued() { return queue; } - public void reset() { + public synchronized int getQueueSize() { + return queue.size(); + } + + public synchronized void reset() { mouseClicked = 0; pressed = false; queue.clear(); } - public void mousePressed(MouseEvent e) { + public synchronized void mousePressed(MouseEvent e) { pressed = true; queue.add(e); if( verbose ) { @@ -73,7 +77,7 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu } } - public void mouseReleased(MouseEvent e) { + public synchronized void mouseReleased(MouseEvent e) { pressed = false; queue.add(e); if( verbose ) { @@ -81,7 +85,7 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu } } - public void mouseClicked(java.awt.event.MouseEvent e) { + public synchronized void mouseClicked(java.awt.event.MouseEvent e) { mouseClicked+=e.getClickCount(); queue.add(e); if( verbose ) { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index f48033ae0..e64b3208e 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -196,10 +196,20 @@ public class AWTRobotUtil { /** * requestFocus, if robot is valid, use mouse operation, - * otherwise programatic, ie call requestFocus + * otherwise programmatic, ie call requestFocus */ public static void requestFocus(Robot robot, Object obj) throws AWTException, InterruptedException, InvocationTargetException { + requestFocus(robot, obj, true); + } + + /** + * requestFocus, if robot is valid, use mouse operation, + * otherwise programmatic, ie call requestFocus + */ + public static void requestFocus(Robot robot, Object obj, boolean onTitleBarIfWindow) + throws AWTException, InterruptedException, InvocationTargetException { + final Component comp; final com.jogamp.newt.Window win; @@ -226,7 +236,7 @@ public class AWTRobotUtil { } } else { final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK; - centerMouse(robot, obj, true); + centerMouse(robot, obj, onTitleBarIfWindow); robot.waitForIdle(); robot.mousePress(mouseButton); diff --git a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java index ed7485951..c4078436f 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/InputEventCountAdapter.java @@ -35,6 +35,7 @@ public interface InputEventCountAdapter extends EventCountAdapter { int getCount(); boolean isPressed(); - public List getQueued(); + public List getQueued(); + public int getQueueSize(); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java index 42235254a..f19169b42 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java @@ -50,33 +50,37 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { reset(); } - public void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = false; } - public boolean isPressed() { + public synchronized boolean isPressed() { return pressed; } - public int getCount() { + public synchronized int getCount() { return keyTyped; } - public int getKeyPressedCount(boolean autoRepeatOnly) { + public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { return autoRepeatOnly ? keyPressedAR: keyPressed; } - public int getKeyReleasedCount(boolean autoRepeatOnly) { + public synchronized int getKeyReleasedCount(boolean autoRepeatOnly) { return autoRepeatOnly ? keyReleasedAR: keyReleased; } - public int getKeyTypedCount(boolean autoRepeatOnly) { + public synchronized int getKeyTypedCount(boolean autoRepeatOnly) { return autoRepeatOnly ? keyTypedAR: keyTyped; } - public List getQueued() { + public synchronized List getQueued() { return queue; } - public void reset() { + public synchronized int getQueueSize() { + return queue.size(); + } + + public synchronized void reset() { keyTyped = 0; keyPressed = 0; keyReleased = 0; @@ -87,7 +91,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { queue.clear(); } - public void keyPressed(KeyEvent e) { + public synchronized void keyPressed(KeyEvent e) { pressed = true; keyPressed++; if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { @@ -99,7 +103,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } } - public void keyReleased(KeyEvent e) { + public synchronized void keyReleased(KeyEvent e) { pressed = false; keyReleased++; if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { @@ -112,7 +116,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } @Override - public void keyTyped(KeyEvent e) { + public synchronized void keyTyped(KeyEvent e) { keyTyped++; if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { keyTypedAR++; diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java index 95818845e..e090ed4cf 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java @@ -62,14 +62,14 @@ public class NEWTKeyUtil { return "Code 0x"+Integer.toHexString(code)+" != "+event+" // "+description; } } - + public static void dumpKeyEvents(List keyEvents) { for(int i=0; i> keyEventsList, boolean verbose) { + + public static boolean validateKeyCodes(CodeSeg[] codeSegments, List> keyEventsList, boolean verbose) { final List missCodes = new ArrayList(); int totalCodeCount = 0; boolean res = true; @@ -77,7 +77,7 @@ public class NEWTKeyUtil { final CodeSeg codeSeg = codeSegments[i]; totalCodeCount += codeSeg.max - codeSeg.min + 1; final List keyEvents = keyEventsList.get(i); - res &= validateKeyCode(missCodes, codeSeg, keyEvents, verbose); + res &= validateKeyCodes(missCodes, codeSeg, keyEvents, verbose); } if(verbose) { System.err.println("*** Total KeyCode Misses "+missCodes.size()+" / "+totalCodeCount+", valid "+res); @@ -87,7 +87,7 @@ public class NEWTKeyUtil { } return res; } - public static boolean validateKeyCode(List missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) { + public static boolean validateKeyCodes(List missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) { final int codeCount = codeSeg.max - codeSeg.min + 1; int misses = 0; for(int i=0; i keyEvents = keyAdapter.getQueued(); Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3); - Assert.assertEquals("Key event count not 3 * press_release_count", 3*expTotalCount, keyEvents.size()); - Assert.assertEquals("Key press count failure", expTotalCount, keyPressed); - Assert.assertEquals("Key press count failure (AR)", expARCount, keyPressedAR); - Assert.assertEquals("Key released count failure", expTotalCount, keyReleased); - Assert.assertEquals("Key released count failure (AR)", expARCount, keyReleasedAR); - Assert.assertEquals("Key typed count failure", expTotalCount, keyTyped); - Assert.assertEquals("Key typed count failure (AR)", expARCount, keyTypedAR); + Assert.assertEquals("Key event count not 3 * press_release_count", expTotalCount, keyEvents.size()); + Assert.assertEquals("Key press count failure", expTotalCount/3, keyPressed); + Assert.assertEquals("Key press count failure (AR)", expARCount/3, keyPressedAR); + Assert.assertEquals("Key released count failure", expTotalCount/3, keyReleased); + Assert.assertEquals("Key released count failure (AR)", expARCount/3, keyReleasedAR); + Assert.assertEquals("Key typed count failure", expTotalCount/3, keyTyped); + Assert.assertEquals("Key typed count failure (AR)", expARCount/3, keyTypedAR); // should be true - always, reaching this point - duh! - Assert.assertEquals(expTotalCount-expARCount, keyPressedNR); - Assert.assertEquals(expTotalCount-expARCount, keyReleasedNR); - Assert.assertEquals(expTotalCount-expARCount, keyTypedNR); + Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyPressedNR); + Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyReleasedNR); + Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyTypedNR); } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java index c77462884..644523782 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java @@ -48,27 +48,31 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda reset(); } - public void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = false; } - public boolean isPressed() { + public synchronized boolean isPressed() { return pressed; } - public int getCount() { + public synchronized int getCount() { return mouseClicked; } - public List getQueued() { + public synchronized List getQueued() { return queue; } - public void reset() { + public synchronized int getQueueSize() { + return queue.size(); + } + + public synchronized void reset() { mouseClicked = 0; pressed = false; queue.clear(); } - public void mousePressed(MouseEvent e) { + public synchronized void mousePressed(MouseEvent e) { pressed = true; queue.add(e); if( verbose ) { @@ -76,7 +80,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda } } - public void mouseReleased(MouseEvent e) { + public synchronized void mouseReleased(MouseEvent e) { pressed = false; queue.add(e); if( verbose ) { @@ -84,7 +88,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda } } - public void mouseClicked(MouseEvent e) { + public synchronized void mouseClicked(MouseEvent e) { mouseClicked+=e.getClickCount(); queue.add(e); if( verbose ) { -- cgit v1.2.3 From c2b328ea96b6cb16ca39f13d4bb4d1236c4b8a1d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 14:40:44 +0100 Subject: Shader: Add '#define texture2D texture' for GLSL >= 130 ; TestGearsES2AWT add forceGL3; TextureDraw01ES2Listener uses defaultShaderCustomization() --- make/scripts/tests.sh | 5 +++-- .../glsl/fixedfunc/shaders/FixedFuncColorTexture.fp | 1 + .../junit/jogl/demos/es2/TextureDraw01ES2Listener.java | 17 ++--------------- .../test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 14 +++++++++++++- .../junit/jogl/demos/es2/newt/TestGearsES2NEWT.java | 1 + .../junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java | 1 + .../es2/shader/elektronenmultiplizierer_development.fp | 1 + .../demos/es2/shader/elektronenmultiplizierer_port.fp | 1 + .../test/junit/jogl/demos/es2/shader/texture01_xxx.fp | 1 + .../test/junit/jogl/demos/es2/shader/texture02_xxx.fp | 1 + 10 files changed, 25 insertions(+), 18 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6c0095c51..9595bf9f7 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -65,6 +65,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" + #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" @@ -285,7 +286,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* @@ -379,7 +380,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT $* -testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorTexture.fp b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorTexture.fp index 82dfa24e1..130711e19 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorTexture.fp +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/shaders/FixedFuncColorTexture.fp @@ -2,6 +2,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java index 6e701658c..4bcb073dc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java @@ -62,8 +62,6 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A this.textureData = td; } - static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; - static final String gl2_prelude = "#version 110\n"; static final String shaderBasename = "texture01_xxx"; private void initShader(GL2ES2 gl, boolean use_program) { @@ -72,19 +70,8 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A "shader", "shader/bin", shaderBasename, true); ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", "shader/bin", shaderBasename, true); - - // Prelude shader code w/ GLSL profile specifics [ 1. pre-proc, 2. other ] - int rsFpPos; - if(gl.isGLES2()) { - rsVp.insertShaderSource(0, 0, es2_prelude[0]); - rsFpPos = rsFp.insertShaderSource(0, 0, es2_prelude[0]); - } else { - rsVp.insertShaderSource(0, 0, gl2_prelude); - rsFpPos = rsFp.insertShaderSource(0, 0, gl2_prelude); - } - if(gl.isGLES2()) { - rsFpPos = rsFp.insertShaderSource(0, rsFpPos, es2_prelude[1]); - } + rsVp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); + rsFp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); // Create & Link the shader program ShaderProgram sp = new ShaderProgram(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index c97054d18..07899b7d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -61,6 +61,7 @@ import org.junit.Test; public class TestGearsES2AWT extends UITestCase { static int width, height; static boolean forceES2 = false; + static boolean forceGL3 = false; static boolean shallUseOffscreenLayer = false; static boolean shallUseOffscreenPBufferLayer = false; static boolean useMSAA = false; @@ -145,7 +146,15 @@ public class TestGearsES2AWT extends UITestCase { @Test public void test01() throws InterruptedException, InvocationTargetException { - GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2()); + final GLProfile glp; + if(forceGL3) { + glp = GLProfile.get(GLProfile.GL3); + } else if(forceES2) { + glp = GLProfile.get(GLProfile.GLES2); + } else { + glp = GLProfile.getGL2ES2(); + } + final GLCapabilities caps = new GLCapabilities(glp); if(useMSAA) { caps.setNumSamples(4); caps.setSampleBuffers(true); @@ -172,6 +181,8 @@ public class TestGearsES2AWT extends UITestCase { } catch (Exception ex) { ex.printStackTrace(); } } else if(args[i].equals("-es2")) { forceES2 = true; + } else if(args[i].equals("-gl3")) { + forceGL3 = true; } else if(args[i].equals("-vsync")) { i++; swapInterval = MiscUtils.atoi(args[i], swapInterval); @@ -197,6 +208,7 @@ public class TestGearsES2AWT extends UITestCase { } } System.err.println("forceES2 "+forceES2); + System.err.println("forceGL3 "+forceGL3); System.err.println("swapInterval "+swapInterval); System.err.println("shallUseOffscreenLayer "+shallUseOffscreenLayer); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 90f2ab988..86831a6fa 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -372,6 +372,7 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("loops "+loops); System.err.println("loop shutdown "+loop_shutdown); System.err.println("forceES2 "+forceES2); + System.err.println("forceGL3 "+forceGL3); if(waitForKey) { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java index 21c09f78c..dbba4fae5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java @@ -183,6 +183,7 @@ public class TestRedSquareES2NEWT extends UITestCase { System.err.println("loops "+loops); System.err.println("loop shutdown "+loop_shutdown); System.err.println("forceES2 "+forceES2); + System.err.println("forceGL3 "+forceGL3); org.junit.runner.JUnitCore.main(TestRedSquareES2NEWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp index 2414af5dc..60f054b46 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_development.fp @@ -12,6 +12,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_port.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_port.fp index ce0b8f5aa..77c34f74f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_port.fp +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/elektronenmultiplizierer_port.fp @@ -15,6 +15,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp index 4cf1d9d10..c213f3ab4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture01_xxx.fp @@ -3,6 +3,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture02_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture02_xxx.fp index e15d7a154..10073e85c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture02_xxx.fp +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/texture02_xxx.fp @@ -3,6 +3,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif -- cgit v1.2.3 From 7dff066bb823dddb5d6e0e7672f5599afa5a43b9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 15:16:56 +0100 Subject: Add OSX CALayer OpenGL 3 (core) support: Derive pixelformat from parent (GL3), use GL3.2 compatible shader; Use VBO in general. Covered by: Auto unit tests: TestOffscreenLayer01GLCanvasAWT, TestOffscreenLayer02NewtCanvasAWT Manual: TestGearsES2AWT '-gl3 -layered' --- make/build-jogl.xml | 9 +- make/scripts/tests.sh | 10 +- make/stub_includes/opengl/macosx-window-system.h | 6 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 76 ++++++++++- .../classes/jogamp/opengl/shader/texture01_xxx.fp | 19 +++ .../classes/jogamp/opengl/shader/texture01_xxx.vp | 19 +++ .../macosx/MacOSXWindowSystemInterface-calayer.m | 150 ++++++++++++++++----- .../acore/TestOffscreenLayer01GLCanvasAWT.java | 25 ++-- .../acore/TestOffscreenLayer02NewtCanvasAWT.java | 25 ++-- 9 files changed, 269 insertions(+), 70 deletions(-) create mode 100644 src/jogl/classes/jogamp/opengl/shader/texture01_xxx.fp create mode 100644 src/jogl/classes/jogamp/opengl/shader/texture01_xxx.vp (limited to 'make/scripts') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 85abf10b7..3c6f0fc6e 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -89,7 +89,7 @@ value="com/jogamp/gluegen/runtime/opengl/*"/> + value="${java.part.gluegen-gl-rt} javax/media/opengl/* javax/media/opengl/fixedfunc/* javax/media/opengl/glu/* javax/media/opengl/glu/gl2es1/* com/jogamp/opengl/* jogamp/opengl/* jogamp/opengl/glu/* jogamp/opengl/glu/error/* jogamp/opengl/shader/**"/> + + @@ -177,7 +180,7 @@ value="jogamp/opengl/util/glsl/fixedfunc/shaders/* jogamp/opengl/util/glsl/fixedfunc/shaders/bin/**"/> + value="${java.part.core.shadercode} ${java.part.util.fixedfuncemu.shadercode} ${java.part.util.graph.shadercode} ${java.part.util.graph.fonts}"/> @@ -1550,7 +1553,7 @@ + includes="${jogl-core.jar} ${jogl-util.jar} ${jogl-util-graph.jar} ${jogl-util-fixedfuncemu.jar}" /> diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9595bf9f7..cd3d2de8c 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -274,8 +274,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -284,9 +284,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT - -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* @@ -366,7 +364,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # # newt.awt (testawt) @@ -381,7 +378,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/make/stub_includes/opengl/macosx-window-system.h b/make/stub_includes/opengl/macosx-window-system.h index 64d3d736b..aaa0cc42e 100644 --- a/make/stub_includes/opengl/macosx-window-system.h +++ b/make/stub_includes/opengl/macosx-window-system.h @@ -54,11 +54,11 @@ void setContextPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer); void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* pBuffer, GLenum colorBuffer); Bool isNSOpenGLPixelBuffer(uint64_t object); -NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight); +NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, int gl3ShaderProgramName, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight); void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval); void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros); -void setNSOpenGLLayerNeedsDisplayFBO(NSOpenGLLayer* layer, uint32_t texID, int texWidth, int texHeight); -void setNSOpenGLLayerNeedsDisplayPBuffer(NSOpenGLLayer* layer, NSOpenGLPixelBuffer* p, int texWidth, int texHeight); +void setNSOpenGLLayerNeedsDisplayFBO(NSOpenGLLayer* layer, uint32_t texID); +void setNSOpenGLLayerNeedsDisplayPBuffer(NSOpenGLLayer* layer, NSOpenGLPixelBuffer* p); void releaseNSOpenGLLayer(NSOpenGLLayer *glLayer); void* getProcAddress(const char *procName); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index f6338b04c..518d97067 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -51,11 +51,14 @@ import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL3; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import javax.media.opengl.GLUniformData; import jogamp.nativewindow.macosx.OSXUtil; import jogamp.opengl.GLContextImpl; @@ -71,6 +74,9 @@ import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; import com.jogamp.opengl.GLExtensions; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; public abstract class MacOSXCGLContext extends GLContextImpl { @@ -132,6 +138,52 @@ public abstract class MacOSXCGLContext extends GLContextImpl } } + /** Static instances of GL3 core shader code, initialized lazy when required - never destroyed. */ + private static Object gl3ShaderLock = new Object(); + private static volatile boolean gl3VertexShaderInitialized = false; + private static ShaderCode gl3VertexShader = null; + private static ShaderCode gl3FragmentShader = null; + + private static ShaderProgram createCALayerShader(GL3 gl) { + // Create vertex & fragment shader code objects + if( !gl3VertexShaderInitialized ) { // volatile OK + synchronized( gl3ShaderLock ) { + if( !gl3VertexShaderInitialized ) { + final String shaderBasename = "texture01_xxx"; + gl3VertexShader = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MacOSXCGLContext.class, + "../../shader", "../../shader/bin", shaderBasename, true); + gl3FragmentShader = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MacOSXCGLContext.class, + "../../shader", "../../shader/bin", shaderBasename, true); + gl3VertexShader.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); + gl3FragmentShader.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); + gl3VertexShaderInitialized = true; + } + } + } + // Create & Link the shader program + final ShaderProgram sp = new ShaderProgram(); + sp.add(gl3VertexShader); + sp.add(gl3FragmentShader); + if(!sp.link(gl, System.err)) { + throw new GLException("Couldn't link program: "+sp); + } + sp.useProgram(gl, true); + + // setup mgl_PMVMatrix + final PMVMatrix pmvMatrix = new PMVMatrix(); + pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + final GLUniformData pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv + pmvMatrixUniform.setLocation( gl.glGetUniformLocation( sp.program(), pmvMatrixUniform.getName() ) ); + gl.glUniform(pmvMatrixUniform); + + sp.useProgram(gl, false); + return sp; + } + + private boolean haveSetOpenGLMode = false; private GLBackendType openGLMode = GLBackendType.NSOPENGL; @@ -441,7 +493,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl private int vsyncTimeout; // microSec - for nsOpenGLLayer mode private int lastWidth=0, lastHeight=0; // allowing to detect size change private boolean needsSetContextPBuffer = false; - + private ShaderProgram gl3ShaderProgram = null; + @Override public boolean isNSContext() { return true; } @@ -611,7 +664,16 @@ public abstract class MacOSXCGLContext extends GLContextImpl if(0>=lastWidth || 0>=lastHeight || !drawable.isRealized()) { throw new GLException("Drawable not realized yet or invalid texture size, texSize "+lastWidth+"x"+lastHeight+", "+drawable); } - nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, /* MacOSXCGLContext.this.isGL3(), */ nsOpenGLLayerPFmt, pbufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight); + final int gl3ShaderProgramName; + if( MacOSXCGLContext.this.isGL3core() ) { + if( null == gl3ShaderProgram) { + gl3ShaderProgram = createCALayerShader(MacOSXCGLContext.this.gl.getGL3()); + } + gl3ShaderProgramName = gl3ShaderProgram.program(); + } else { + gl3ShaderProgramName = 0; + } + nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, gl3ShaderProgramName, nsOpenGLLayerPFmt, pbufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight); if (DEBUG) { System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+" w/ pbuffer "+toHexString(pbufferHandle)+", texID "+texID+", texSize "+lastWidth+"x"+lastHeight+", "+drawable); } @@ -632,7 +694,11 @@ public abstract class MacOSXCGLContext extends GLContextImpl // still having a valid OLS attached to surface (parent OLS could have been removed) ols.detachSurfaceLayer(); } - CGL.releaseNSOpenGLLayer(nsOpenGLLayer); + CGL.releaseNSOpenGLLayer(nsOpenGLLayer); + if( null != gl3ShaderProgram ) { + gl3ShaderProgram.destroy(MacOSXCGLContext.this.gl.getGL3()); + gl3ShaderProgram = null; + } nsOpenGLLayer = 0; } if(0 != nsOpenGLLayerPFmt) { @@ -767,10 +833,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl if(res) { if(isFBO) { // trigger CALayer to update incl. possible surface change (texture) - CGL.setNSOpenGLLayerNeedsDisplayFBO(nsOpenGLLayer, texID, lastWidth, lastHeight); + CGL.setNSOpenGLLayerNeedsDisplayFBO(nsOpenGLLayer, texID); } else { // trigger CALayer to update incl. possible surface change (new pbuffer handle) - CGL.setNSOpenGLLayerNeedsDisplayPBuffer(nsOpenGLLayer, drawable.getHandle(), lastWidth, lastHeight); + CGL.setNSOpenGLLayerNeedsDisplayPBuffer(nsOpenGLLayer, drawable.getHandle()); } } } else { diff --git a/src/jogl/classes/jogamp/opengl/shader/texture01_xxx.fp b/src/jogl/classes/jogamp/opengl/shader/texture01_xxx.fp new file mode 100644 index 000000000..8b30b65f9 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/shader/texture01_xxx.fp @@ -0,0 +1,19 @@ +// Copyright 2012 JogAmp Community. All rights reserved. + +#if __VERSION__ >= 130 + #define varying in + out vec4 mgl_FragColor; + #define texture2D texture +#else + #define mgl_FragColor gl_FragColor +#endif + +varying vec2 mgl_texCoord; + +uniform sampler2D mgl_Texture0; + +void main (void) +{ + mgl_FragColor = texture2D(mgl_Texture0, mgl_texCoord); +} + diff --git a/src/jogl/classes/jogamp/opengl/shader/texture01_xxx.vp b/src/jogl/classes/jogamp/opengl/shader/texture01_xxx.vp new file mode 100644 index 000000000..d9ef6b493 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/shader/texture01_xxx.vp @@ -0,0 +1,19 @@ +// Copyright 2012 JogAmp Community. All rights reserved. + +#if __VERSION__ >= 130 + #define attribute in + #define varying out +#endif + +uniform mat4 mgl_PMVMatrix[2]; + +attribute vec4 mgl_Vertex; +attribute vec4 mgl_MultiTexCoord; + +varying vec2 mgl_texCoord; + +void main(void) +{ + mgl_texCoord = mgl_MultiTexCoord.st; + gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex; +} diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index e83d0adcb..6ebf400e2 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -3,6 +3,22 @@ #import #include "timespec.h" +#import + +/** + * Partial include of gl3.h - which we can only expect and use + * in case of a GL3 core context at runtime. + * Otherwise we would need to have 2 modules, one including GL2 + * and one inclusing GL3 headers. + */ +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +extern void glBindVertexArray (GLuint array); +extern void glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +extern void glGenVertexArrays (GLsizei n, GLuint *arrays); +extern GLboolean glIsVertexArray (GLuint array); +#endif + // // CADisplayLink only available on iOS >= 3.1, sad, since it's convenient. // Use CVDisplayLink otherwise. @@ -82,11 +98,18 @@ @protected NSOpenGLContext* parentCtx; + GLuint gl3ShaderProgramName; + GLuint vboBufVert; + GLuint vboBufTexCoord; + GLint vertAttrLoc; + GLint texCoordAttrLoc; NSOpenGLPixelFormat* parentPixelFmt; + int texWidth; + int texHeight; + int newTexWidth; + int newTexHeight; volatile NSOpenGLPixelBuffer* pbuffer; volatile GLuint textureID; - volatile int texWidth; - volatile int texHeight; volatile NSOpenGLPixelBuffer* newPBuffer; #ifdef HAS_CADisplayLink CADisplayLink* displayLink; @@ -102,11 +125,10 @@ pthread_mutex_t renderLock; pthread_cond_t renderSignal; volatile Bool shallDraw; - volatile int newTexWidth; - volatile int newTexHeight; } - (id) setupWithContext: (NSOpenGLContext*) parentCtx + gl3ShaderProgramName: (GLuint) gl3ShaderProgramName pixelFormat: (NSOpenGLPixelFormat*) pfmt pbuffer: (NSOpenGLPixelBuffer*) p texIDArg: (GLuint) texID @@ -122,6 +144,7 @@ - (void) setNewPBuffer: (NSOpenGLPixelBuffer*)p; - (void) applyNewPBuffer; +- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask; - (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat; - (void)disableAnimation; - (void)pauseAnimation:(Bool)pause; @@ -172,6 +195,7 @@ static const GLfloat gl_verts[] = { @implementation MyNSOpenGLLayer - (id) setupWithContext: (NSOpenGLContext*) _parentCtx + gl3ShaderProgramName: (GLuint) _gl3ShaderProgramName pixelFormat: (NSOpenGLPixelFormat*) _parentPixelFmt pbuffer: (NSOpenGLPixelBuffer*) p texIDArg: (GLuint) texID @@ -192,6 +216,11 @@ static const GLfloat gl_verts[] = { } } parentCtx = _parentCtx; + gl3ShaderProgramName = _gl3ShaderProgramName; + vboBufVert = 0; + vboBufTexCoord = 0; + vertAttrLoc = 0; + texCoordAttrLoc = 0; parentPixelFmt = _parentPixelFmt; swapInterval = 1; // defaults to on (as w/ new GL profiles) swapIntervalCounter = 0; @@ -339,7 +368,7 @@ static const GLfloat gl_verts[] = { SYNC_PRINT(" %p>", pbuffer, newPBuffer); if( 0 != textureID ) { - glDeleteTextures(1, &textureID); + glDeleteTextures(1, (GLuint *)&textureID); [self setTextureID: 0]; } [pbuffer release]; @@ -359,7 +388,7 @@ static const GLfloat gl_verts[] = { DBG_PRINT("MyNSOpenGLLayer::deallocPBuffer (with ctx) %p (refcnt %d) - context %p, pbuffer %p, texID %d\n", self, (int)[self retainCount], context, pbuffer, (int)textureID); if( 0 != textureID ) { - glDeleteTextures(1, &textureID); + glDeleteTextures(1, (GLuint *)&textureID); [self setTextureID: 0]; } if(NULL != pbuffer) { @@ -378,13 +407,12 @@ static const GLfloat gl_verts[] = { } } -/** - (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask { DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask: %p (refcnt %d) - parent-pfmt %p -> new-pfmt %p\n", self, (int)[self retainCount], parentPixelFmt, parentPixelFmt); return parentPixelFmt; -} */ +} - (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat { @@ -487,12 +515,16 @@ static const GLfloat gl_verts[] = { if( NULL != pbuffer ) { if( texSizeChanged && 0 != textureID ) { - glDeleteTextures(1, &textureID); + glDeleteTextures(1, (GLuint *)&textureID); [self setTextureID: 0]; } textureTarget = [pbuffer textureTarget]; + if( 0 != gl3ShaderProgramName ) { + glUseProgram(gl3ShaderProgramName); + glActiveTexture(GL_TEXTURE0); + } if( 0 == textureID ) { - glGenTextures(1, &textureID); + glGenTextures(1, (GLuint *)&textureID); glBindTexture(textureTarget, textureID); glTexParameteri(textureTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(textureTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -501,26 +533,80 @@ static const GLfloat gl_verts[] = { } else { glBindTexture(textureTarget, textureID); } - [context setTextureImageToPixelBuffer: pbuffer colorBuffer: GL_FRONT]; + [context setTextureImageToPixelBuffer: (NSOpenGLPixelBuffer*) pbuffer colorBuffer: GL_FRONT]; } else { + if( 0 != gl3ShaderProgramName ) { + glUseProgram(gl3ShaderProgramName); + glActiveTexture(GL_TEXTURE0); + } textureTarget = GL_TEXTURE_2D; glBindTexture(textureTarget, textureID); } - SYNC_PRINT(" %d*>", (int)textureID); - - glEnable(textureTarget); - - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glVertexPointer(2, GL_FLOAT, 0, gl_verts); - glTexCoordPointer(2, GL_FLOAT, 0, gl_texCoords); - - glDrawArrays(GL_QUADS, 0, 4); - - glDisableClientState(GL_VERTEX_ARRAY); - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - - glDisable(textureTarget); + SYNC_PRINT(" %d gl3Prog %d/%d*>", (int)textureID, (int)gl3ShaderProgramName, (int)glIsProgram (gl3ShaderProgramName)); + + if( 0 == vboBufVert ) { // Once: Init Data and Bind to Pointer + if( 0 != gl3ShaderProgramName ) { + // Install default VAO as required by GL 3.2 core! + GLuint vaoBuf = 0; + glGenVertexArrays(1, &vaoBuf); + glBindVertexArray(vaoBuf); + + // Set texture-unit 0 + GLint texUnitLoc = glGetUniformLocation (gl3ShaderProgramName, "mgl_Texture0"); + glUniform1i (texUnitLoc, 0); + } + glGenBuffers( 1, &vboBufVert ); + glBindBuffer( GL_ARRAY_BUFFER, vboBufVert ); + glBufferData( GL_ARRAY_BUFFER, 4 * 2 * sizeof(GLfloat), gl_verts, GL_STATIC_DRAW); + if( 0 != gl3ShaderProgramName ) { + vertAttrLoc = glGetAttribLocation( gl3ShaderProgramName, "mgl_Vertex" ); + glVertexAttribPointer( vertAttrLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL ); + } else { + glVertexPointer(2, GL_FLOAT, 0, NULL); + } + + glGenBuffers( 1, &vboBufTexCoord ); + glBindBuffer( GL_ARRAY_BUFFER, vboBufTexCoord ); + glBufferData( GL_ARRAY_BUFFER, 4 * 2 * sizeof(GLfloat), gl_texCoords, GL_STATIC_DRAW); + if( 0 != gl3ShaderProgramName ) { + texCoordAttrLoc = glGetAttribLocation( gl3ShaderProgramName, "mgl_MultiTexCoord" ); + glVertexAttribPointer( texCoordAttrLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL ); + } else { + glTexCoordPointer(2, GL_FLOAT, 0, NULL); + } + } + if( texSizeChanged ) { + glBindBuffer( GL_ARRAY_BUFFER, vboBufTexCoord ); + glBufferSubData( GL_ARRAY_BUFFER, 0, 4 * 2 * sizeof(GLfloat), gl_texCoords); + if( 0 != gl3ShaderProgramName ) { + glVertexAttribPointer( texCoordAttrLoc, 2, GL_FLOAT, GL_FALSE, 0, NULL ); + } else { + glTexCoordPointer(2, GL_FLOAT, 0, NULL); + } + } + if( 0 != gl3ShaderProgramName ) { + glEnableVertexAttribArray( vertAttrLoc ); + glEnableVertexAttribArray( texCoordAttrLoc ); + } else { + glEnable(textureTarget); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + } + + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + + if( 0 != gl3ShaderProgramName ) { + glDisableVertexAttribArray( vertAttrLoc ); + glDisableVertexAttribArray( texCoordAttrLoc ); + glUseProgram(0); + } else { + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + + glDisable(textureTarget); + } + glBindTexture(textureTarget, 0); [context clearDrawable]; @@ -664,13 +750,13 @@ static const GLfloat gl_verts[] = { @end -NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight) { +NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, int gl3ShaderProgramName, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight) { // This simply crashes after dealloc() has been called .. ie. ref-count -> 0 too early ? // However using alloc/init, actual dealloc happens at JAWT destruction, hence too later IMHO. // return [[MyNSOpenGLLayer layer] setupWithContext:ctx pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID // opaque: opaque texWidth: texWidth texHeight: texHeight]; - return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID + return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx gl3ShaderProgramName: (GLuint)gl3ShaderProgramName pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID opaque: opaque texWidth: texWidth texHeight: texHeight]; } @@ -688,7 +774,7 @@ void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros) { [pool release]; } -void setNSOpenGLLayerNeedsDisplayFBO(NSOpenGLLayer* layer, uint32_t texID, int texWidth, int texHeight) { +void setNSOpenGLLayerNeedsDisplayFBO(NSOpenGLLayer* layer, uint32_t texID) { MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; Bool shallDraw; @@ -698,7 +784,7 @@ void setNSOpenGLLayerNeedsDisplayFBO(NSOpenGLLayer* layer, uint32_t texID, int t shallDraw = [l isGLSourceValid]; l->shallDraw = shallDraw; - SYNC_PRINT("", texWidth, texHeight, l->newTexWidth, l->newTexHeight, (int)shallDraw); + SYNC_PRINT("", (int)shallDraw); if(shallDraw) { if ( [NSThread isMainThread] == YES ) { [l setNeedsDisplay]; @@ -711,7 +797,7 @@ void setNSOpenGLLayerNeedsDisplayFBO(NSOpenGLLayer* layer, uint32_t texID, int t [pool release]; } -void setNSOpenGLLayerNeedsDisplayPBuffer(NSOpenGLLayer* layer, NSOpenGLPixelBuffer* p, int texWidth, int texHeight) { +void setNSOpenGLLayerNeedsDisplayPBuffer(NSOpenGLLayer* layer, NSOpenGLPixelBuffer* p) { MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; Bool shallDraw; @@ -724,7 +810,7 @@ void setNSOpenGLLayerNeedsDisplayPBuffer(NSOpenGLLayer* layer, NSOpenGLPixelBuff shallDraw = [l isGLSourceValid]; l->shallDraw = shallDraw; - SYNC_PRINT("", texWidth, texHeight, l->newTexWidth, l->newTexHeight, (int)shallDraw); + SYNC_PRINT("", (int)shallDraw); if(shallDraw) { if ( [NSThread isMainThread] == YES ) { [l setNeedsDisplay]; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java index b9e3f0606..90407166f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java @@ -41,6 +41,7 @@ import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; import jogamp.nativewindow.jawt.JAWTUtil; @@ -122,22 +123,27 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { } @Test - public void testOffscreenLayerGLCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException { - testOffscreenLayerGLCanvas_Impl(true); + public void test01_GLDefault() throws InterruptedException, InvocationTargetException { + testOffscreenLayerGLCanvas_Impl(null); } - private void testOffscreenLayerGLCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException { - if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { - System.err.println("onscreen layer n/a"); + @Test + public void test01_GL3() throws InterruptedException, InvocationTargetException { + if( !GLProfile.isAvailable(GLProfile.GL3) ) { + System.err.println("GL3 n/a"); return; } - if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + testOffscreenLayerGLCanvas_Impl(GLProfile.get(GLProfile.GL3)); + } + + private void testOffscreenLayerGLCanvas_Impl(GLProfile glp) throws InterruptedException, InvocationTargetException { + if(!JAWTUtil.isOffscreenLayerSupported()) { System.err.println("offscreen layer n/a"); return; } final Frame frame1 = new Frame("AWT Parent Frame"); - GLCapabilities caps = new GLCapabilities(null); + GLCapabilities caps = new GLCapabilities(glp); if(singleBuffer) { caps.setDoubleBuffered(false); } @@ -150,7 +156,7 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { caps.setOnscreen(true); // simulate normal behavior .. } final GLCanvas glc = new GLCanvas(caps); - glc.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported + glc.setShallUseOffscreenLayer(true); // trigger offscreen layer - if supported glc.setPreferredSize(preferredGLSize); glc.setMinimumSize(preferredGLSize); glc.setSize(preferredGLSize); @@ -165,8 +171,7 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { setupFrameAndShow(frame1, glc); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glc, true)); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glc, true)); - Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, - glc.isOffscreenLayerSurfaceEnabled()); + Assert.assertEquals(true, glc.isOffscreenLayerSurfaceEnabled()); GLAnimatorControl animator1 = new Animator(glc); if(!noAnimation) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java index ce90c77c5..e4a3bce71 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java @@ -41,6 +41,7 @@ import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; import jogamp.nativewindow.jawt.JAWTUtil; @@ -114,22 +115,27 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { } @Test - public void testOffscreenLayerNewtCanvas_OffscreenLayerWithOnscreenClass() throws InterruptedException, InvocationTargetException { - testOffscreenLayerNewtCanvas_Impl(true); + public void test01_GLDefault() throws InterruptedException, InvocationTargetException { + testOffscreenLayerNewtCanvas_Impl(null); } - private void testOffscreenLayerNewtCanvas_Impl(boolean offscreenLayer) throws InterruptedException, InvocationTargetException { - if(!offscreenLayer && JAWTUtil.isOffscreenLayerRequired()) { - System.err.println("onscreen layer n/a"); + @Test + public void test02_GL3() throws InterruptedException, InvocationTargetException { + if( !GLProfile.isAvailable(GLProfile.GL3) ) { + System.err.println("GL3 n/a"); return; } - if(offscreenLayer && !JAWTUtil.isOffscreenLayerSupported()) { + testOffscreenLayerNewtCanvas_Impl(GLProfile.get(GLProfile.GL3)); + } + + private void testOffscreenLayerNewtCanvas_Impl(GLProfile glp) throws InterruptedException, InvocationTargetException { + if(!JAWTUtil.isOffscreenLayerSupported()) { System.err.println("offscreen layer n/a"); return; } final Frame frame1 = new Frame("AWT Parent Frame"); - GLCapabilities caps = new GLCapabilities(null); + GLCapabilities caps = new GLCapabilities(glp); if(singleBuffer) { caps.setDoubleBuffered(false); } @@ -144,7 +150,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { GLWindow glWindow1 = GLWindow.create(caps); final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); - newtCanvasAWT1.setShallUseOffscreenLayer(offscreenLayer); // trigger offscreen layer - if supported + newtCanvasAWT1.setShallUseOffscreenLayer(true); // trigger offscreen layer - if supported newtCanvasAWT1.setPreferredSize(preferredGLSize); newtCanvasAWT1.setMinimumSize(preferredGLSize); newtCanvasAWT1.setSize(preferredGLSize); @@ -162,8 +168,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true)); Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); - Assert.assertEquals(JAWTUtil.isOffscreenLayerSupported() && offscreenLayer, - newtCanvasAWT1.isOffscreenLayerSurfaceEnabled()); + Assert.assertEquals(true, newtCanvasAWT1.isOffscreenLayerSurfaceEnabled()); GLAnimatorControl animator1 = new Animator(glWindow1); if(!noAnimation) { -- cgit v1.2.3 From f56e36bd4a497643756ab737422eb356b963b27d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 16:41:28 +0100 Subject: Fix ProjectFloat (Bug 633): Adding missing offset of sliced buffer usage; reduce buffer usage (performance) in favor of float[]. Thomas De Bodt reported this error and provided the unit test. --- make/scripts/tests.sh | 3 +- src/jogl/classes/com/jogamp/opengl/FloatUtil.java | 48 ++- src/jogl/classes/jogamp/opengl/ProjectFloat.java | 327 ++++++++++----------- .../test/junit/jogl/acore/TestPMVMatrix02NEWT.java | 109 +++++++ 4 files changed, 305 insertions(+), 182 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index cd3d2de8c..9c74a08a0 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -250,6 +250,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -274,7 +275,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/FloatUtil.java b/src/jogl/classes/com/jogamp/opengl/FloatUtil.java index 297cec285..ffd2344a6 100644 --- a/src/jogl/classes/com/jogamp/opengl/FloatUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/FloatUtil.java @@ -73,7 +73,7 @@ public class FloatUtil { * Make matrix an identity matrix */ public static final void makeIdentityf(FloatBuffer m) { - int oldPos = m.position(); + final int oldPos = m.position(); m.put(IDENTITY_MATRIX); m.position(oldPos); } @@ -91,7 +91,7 @@ public class FloatUtil { * Make matrix an zero matrix */ public static final void makeZero(FloatBuffer m) { - int oldPos = m.position(); + final int oldPos = m.position(); m.put(ZERO_MATRIX); m.position(oldPos); } @@ -246,10 +246,10 @@ public class FloatUtil { * @param v_in 4-component column-vector * @param v_out m_in * v_in */ - public static final void multMatrixVecf(float[] m_in, int m_in_off, float[] v_in, int v_in_off, float[] v_out) { + public static final void multMatrixVecf(float[] m_in, int m_in_off, float[] v_in, int v_in_off, float[] v_out, int v_out_off) { for (int i = 0; i < 4; i++) { // (one matrix row in column-major order) X (column vector) - v_out[i] = + v_out[i + v_out_off] = v_in[0+v_in_off] * m_in[0*4+i+m_in_off] + v_in[1+v_in_off] * m_in[1*4+i+m_in_off] + v_in[2+v_in_off] * m_in[2*4+i+m_in_off] + @@ -274,15 +274,49 @@ public class FloatUtil { } } + /** + * @param m_in 4x4 matrix in column-major order + * @param v_in 4-component column-vector + * @param v_out m_in * v_in + */ + public static final void multMatrixVecf(FloatBuffer m_in, float[] v_in, int v_in_off, float[] v_out, int v_out_off) { + final int matrixPos = m_in.position(); + for (int i = 0; i < 4; i++) { + // (one matrix row in column-major order) X (column vector) + v_out[i+v_out_off] = + v_in[0+v_in_off] * m_in.get(0*4+i+matrixPos) + + v_in[1+v_in_off] * m_in.get(1*4+i+matrixPos) + + v_in[2+v_in_off] * m_in.get(2*4+i+matrixPos) + + v_in[3+v_in_off] * m_in.get(3*4+i+matrixPos); + } + } + + /** + * @param m_in 4x4 matrix in column-major order + * @param v_in 4-component column-vector + * @param v_out m_in * v_in + */ + public static final void multMatrixVecf(FloatBuffer m_in, float[] v_in, float[] v_out) { + final int matrixPos = m_in.position(); + for (int i = 0; i < 4; i++) { + // (one matrix row in column-major order) X (column vector) + v_out[i] = + v_in[0] * m_in.get(0*4+i+matrixPos) + + v_in[1] * m_in.get(1*4+i+matrixPos) + + v_in[2] * m_in.get(2*4+i+matrixPos) + + v_in[3] * m_in.get(3*4+i+matrixPos); + } + } + /** * @param m_in 4x4 matrix in column-major order * @param v_in 4-component column-vector * @param v_out m_in * v_in */ public static final void multMatrixVecf(FloatBuffer m_in, FloatBuffer v_in, FloatBuffer v_out) { - int inPos = v_in.position(); - int outPos = v_out.position(); - int matrixPos = m_in.position(); + final int inPos = v_in.position(); + final int outPos = v_out.position(); + final int matrixPos = m_in.position(); for (int i = 0; i < 4; i++) { // (one matrix row in column-major order) X (column vector) v_out.put(i + outPos, diff --git a/src/jogl/classes/jogamp/opengl/ProjectFloat.java b/src/jogl/classes/jogamp/opengl/ProjectFloat.java index b1ba1f89c..18fe3e77e 100644 --- a/src/jogl/classes/jogamp/opengl/ProjectFloat.java +++ b/src/jogl/classes/jogamp/opengl/ProjectFloat.java @@ -135,7 +135,7 @@ import com.jogamp.opengl.FloatUtil; * @author Sven Gothel */ public class ProjectFloat { - public static final int getRequiredFloatBufferSize() { return 2*16+2*4+3*3; } + public static final int getRequiredFloatBufferSize() { return 1*16; } // Note that we have cloned parts of the implementation in order to // support incoming Buffers. The reason for this is to avoid loading @@ -153,18 +153,14 @@ public class ProjectFloat { private final float[] out = new float[4]; // Buffer-based implementation - private FloatBuffer matrixBuf; - private FloatBuffer tempInvertMatrixBuf; + private FloatBuffer matrixBuf; // 4x4 - private FloatBuffer inBuf; - private FloatBuffer outBuf; - - private FloatBuffer forwardBuf; - private FloatBuffer sideBuf; - private FloatBuffer upBuf; + private final float[] forward = new float[3]; // 3 + private final float[] side = new float[3]; // 3 + private final float[] up = new float[3]; // 3 public ProjectFloat() { - this(false); + this(true); } public ProjectFloat(boolean useBackingArray) { @@ -182,33 +178,11 @@ public class ProjectFloat { * @param floatOffset Offset for either of the given sources (buffer or array) */ public ProjectFloat(Buffer floatBuffer, float[] floatArray, int floatOffset) { - int floatPos = floatOffset; - int floatSize = 16; - matrixBuf = Buffers.slice2Float(floatBuffer, floatArray, floatPos, floatSize); - floatPos += floatSize; - tempInvertMatrixBuf = Buffers.slice2Float(floatBuffer, floatArray, floatPos, floatSize); - floatPos += floatSize; - floatSize = 4; - inBuf = Buffers.slice2Float(floatBuffer, floatArray, floatPos, floatSize); - floatPos += floatSize; - outBuf = Buffers.slice2Float(floatBuffer, floatArray, floatPos, floatSize); - floatPos += floatSize; - floatSize = 3; - forwardBuf = Buffers.slice2Float(floatBuffer, floatArray, floatPos, floatSize); - floatPos += floatSize; - sideBuf = Buffers.slice2Float(floatBuffer, floatArray, floatPos, floatSize); - floatPos += floatSize; - upBuf = Buffers.slice2Float(floatBuffer, floatArray, floatPos, floatSize); + matrixBuf = Buffers.slice2Float(floatBuffer, floatArray, floatOffset, 16); } public void destroy() { matrixBuf = null; - tempInvertMatrixBuf = null; - inBuf = null; - outBuf = null; - forwardBuf = null; - sideBuf = null; - upBuf = null; } /** @@ -221,7 +195,7 @@ public class ProjectFloat { public boolean gluInvertMatrixf(float[] src, int srcOffset, float[] inverse, int inverseOffset) { int i, j, k, swap; float t; - float[][] temp = tempInvertMatrix; + final float[][] temp = tempInvertMatrix; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { @@ -292,14 +266,14 @@ public class ProjectFloat { int i, j, k, swap; float t; - int srcPos = src.position(); - int invPos = inverse.position(); - - FloatBuffer temp = tempInvertMatrixBuf; + final int srcPos = src.position(); + final int invPos = inverse.position(); + + final float[][] temp = tempInvertMatrix; for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { - temp.put(i*4+j, src.get(i*4+j + srcPos)); + temp[i][j] = src.get(i*4+j + srcPos); } } FloatUtil.makeIdentityf(inverse); @@ -310,7 +284,7 @@ public class ProjectFloat { // swap = i; for (j = i + 1; j < 4; j++) { - if (Math.abs(temp.get(j*4+i)) > Math.abs(temp.get(i*4+i))) { + if (Math.abs(temp[j][i]) > Math.abs(temp[i][i])) { swap = j; } } @@ -320,17 +294,17 @@ public class ProjectFloat { // Swap rows. // for (k = 0; k < 4; k++) { - t = temp.get(i*4+k); - temp.put(i*4+k, temp.get(swap*4+k)); - temp.put(swap*4+k, t); - + t = temp[i][k]; + temp[i][k] = temp[swap][k]; + temp[swap][k] = t; + t = inverse.get(i*4+k + invPos); inverse.put(i*4+k + invPos, inverse.get(swap*4+k + invPos)); inverse.put(swap*4+k + invPos, t); } } - if (temp.get(i*4+i) == 0) { + if (temp[i][i] == 0) { // // No non-zero pivot. The matrix is singular, which shouldn't // happen. This means the user gave us a bad matrix. @@ -338,17 +312,19 @@ public class ProjectFloat { return false; } - t = temp.get(i*4+i); + t = temp[i][i]; for (k = 0; k < 4; k++) { - temp.put(i*4+k, temp.get(i*4+k) / t); - inverse.put(i*4+k + invPos, inverse.get(i*4+k + invPos) / t); + temp[i][k] /= t; + final int z = i*4+k + invPos; + inverse.put(z, inverse.get(z) / t); } for (j = 0; j < 4; j++) { if (j != i) { - t = temp.get(j*4+i); + t = temp[j][i]; for (k = 0; k < 4; k++) { - temp.put(j*4+k, temp.get(j*4+k) - temp.get(i*4+k) * t); - inverse.put(j*4+k + invPos, inverse.get(j*4+k + invPos) - inverse.get(i*4+k + invPos) * t); + temp[j][k] -= temp[i][k] * t; + final int z = j*4+k + invPos; + inverse.put(z, inverse.get(z) - inverse.get(i*4+k + invPos) * t); } } } @@ -378,8 +354,8 @@ public class ProjectFloat { * @param zFar */ public void gluPerspective(GLMatrixFunc gl, float fovy, float aspect, float zNear, float zFar) { + final float radians = fovy / 2 * (float) Math.PI / 180; float sine, cotangent, deltaZ; - float radians = fovy / 2 * (float) Math.PI / 180; deltaZ = zFar - zNear; sine = (float) Math.sin(radians); @@ -391,13 +367,13 @@ public class ProjectFloat { cotangent = (float) Math.cos(radians) / sine; FloatUtil.makeIdentityf(matrixBuf); - - matrixBuf.put(0 * 4 + 0, cotangent / aspect); - matrixBuf.put(1 * 4 + 1, cotangent); - matrixBuf.put(2 * 4 + 2, - (zFar + zNear) / deltaZ); - matrixBuf.put(2 * 4 + 3, -1); - matrixBuf.put(3 * 4 + 2, -2 * zNear * zFar / deltaZ); - matrixBuf.put(3 * 4 + 3, 0); + final int mPos = matrixBuf.position(); + matrixBuf.put(0 * 4 + 0 + mPos, cotangent / aspect); + matrixBuf.put(1 * 4 + 1 + mPos, cotangent); + matrixBuf.put(2 * 4 + 2 + mPos, - (zFar + zNear) / deltaZ); + matrixBuf.put(2 * 4 + 3 + mPos, -1); + matrixBuf.put(3 * 4 + 2 + mPos, -2 * zNear * zFar / deltaZ); + matrixBuf.put(3 * 4 + 3 + mPos, 0); gl.glMultMatrixf(matrixBuf); } @@ -419,17 +395,17 @@ public class ProjectFloat { float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz) { - FloatBuffer forward = this.forwardBuf; - FloatBuffer side = this.sideBuf; - FloatBuffer up = this.upBuf; + final float[] forward = this.forward; + final float[] side = this.side; + final float[] up = this.up; - forward.put(0, centerx - eyex); - forward.put(1, centery - eyey); - forward.put(2, centerz - eyez); + forward[0] = centerx - eyex; + forward[1] = centery - eyey; + forward[2] = centerz - eyez; - up.put(0, upx); - up.put(1, upy); - up.put(2, upz); + up[0] = upx; + up[1] = upy; + up[2] = upz; FloatUtil.normalize(forward); @@ -441,17 +417,18 @@ public class ProjectFloat { FloatUtil.cross(side, forward, up); FloatUtil.makeIdentityf(matrixBuf); - matrixBuf.put(0 * 4 + 0, side.get(0)); - matrixBuf.put(1 * 4 + 0, side.get(1)); - matrixBuf.put(2 * 4 + 0, side.get(2)); + final int mPos = matrixBuf.position(); + matrixBuf.put(0 * 4 + 0 + mPos, side[0]); + matrixBuf.put(1 * 4 + 0 + mPos, side[1]); + matrixBuf.put(2 * 4 + 0 + mPos, side[2]); - matrixBuf.put(0 * 4 + 1, up.get(0)); - matrixBuf.put(1 * 4 + 1, up.get(1)); - matrixBuf.put(2 * 4 + 1, up.get(2)); + matrixBuf.put(0 * 4 + 1 + mPos, up[0]); + matrixBuf.put(1 * 4 + 1 + mPos, up[1]); + matrixBuf.put(2 * 4 + 1 + mPos, up[2]); - matrixBuf.put(0 * 4 + 2, -forward.get(0)); - matrixBuf.put(1 * 4 + 2, -forward.get(1)); - matrixBuf.put(2 * 4 + 2, -forward.get(2)); + matrixBuf.put(0 * 4 + 2 + mPos, -forward[0]); + matrixBuf.put(1 * 4 + 2 + mPos, -forward[1]); + matrixBuf.put(2 * 4 + 2 + mPos, -forward[2]); gl.glMultMatrixf(matrixBuf); gl.glTranslatef(-eyex, -eyey, -eyez); @@ -476,16 +453,16 @@ public class ProjectFloat { int[] viewport, int viewport_offset, float[] win_pos, int win_pos_offset ) { - float[] in = this.in; - float[] out = this.out; + final float[] in = this.in; + final float[] out = this.out; in[0] = objx; in[1] = objy; in[2] = objz; in[3] = 1.0f; - FloatUtil.multMatrixVecf(modelMatrix, modelMatrix_offset, in, 0, out); - FloatUtil.multMatrixVecf(projMatrix, projMatrix_offset, out, 0, in); + FloatUtil.multMatrixVecf(modelMatrix, modelMatrix_offset, in, 0, out, 0); + FloatUtil.multMatrixVecf(projMatrix, projMatrix_offset, out, 0, in, 0); if (in[3] == 0.0f) { return false; @@ -515,33 +492,33 @@ public class ProjectFloat { int[] viewport, int viewport_offset, float[] win_pos, int win_pos_offset ) { - FloatBuffer in = this.inBuf; - FloatBuffer out = this.outBuf; + final float[] in = this.in; + final float[] out = this.out; - in.put(0, objx); - in.put(1, objy); - in.put(2, objz); - in.put(3, 1.0f); + in[0] = objx; + in[1] = objy; + in[2] = objz; + in[3] = 1.0f; FloatUtil.multMatrixVecf(modelMatrix, in, out); FloatUtil.multMatrixVecf(projMatrix, out, in); - if (in.get(3) == 0.0f) { + if (in[3] == 0.0f) { return false; } - in.put(3, (1.0f / in.get(3)) * 0.5f); + in[3] = (1.0f / in[3]) * 0.5f; // Map x, y and z to range 0-1 - in.put(0, in.get(0) * in.get(3) + 0.5f); - in.put(1, in.get(1) * in.get(3) + 0.5f); - in.put(2, in.get(2) * in.get(3) + 0.5f); + in[0] = in[0] * in[3] + 0.5f; + in[1] = in[1] * in[3] + 0.5f; + in[2] = in[2] * in[3] + 0.5f; // Map x,y to viewport - win_pos[0+win_pos_offset] = in.get(0) * viewport[2+viewport_offset] + viewport[0+viewport_offset]; - win_pos[1+win_pos_offset] = in.get(1) * viewport[3+viewport_offset] + viewport[1+viewport_offset]; - win_pos[2+win_pos_offset] = in.get(2); - + win_pos[0+win_pos_offset] = in[0] * viewport[2+viewport_offset] + viewport[0+viewport_offset]; + win_pos[1+win_pos_offset] = in[1] * viewport[3+viewport_offset] + viewport[1+viewport_offset]; + win_pos[2+win_pos_offset] = in[2]; + return true; } @@ -564,34 +541,34 @@ public class ProjectFloat { IntBuffer viewport, FloatBuffer win_pos) { - FloatBuffer in = this.inBuf; - FloatBuffer out = this.outBuf; + final float[] in = this.in; + final float[] out = this.out; - in.put(0, objx); - in.put(1, objy); - in.put(2, objz); - in.put(3, 1.0f); + in[0] = objx; + in[1] = objy; + in[2] = objz; + in[3] = 1.0f; FloatUtil.multMatrixVecf(modelMatrix, in, out); FloatUtil.multMatrixVecf(projMatrix, out, in); - if (in.get(3) == 0.0f) { + if (in[3] == 0.0f) { return false; } - in.put(3, (1.0f / in.get(3)) * 0.5f); + in[3] = (1.0f / in[3]) * 0.5f; // Map x, y and z to range 0-1 - in.put(0, in.get(0) * in.get(3) + 0.5f); - in.put(1, in.get(1) * in.get(3) + 0.5f); - in.put(2, in.get(2) * in.get(3) + 0.5f); + in[0] = in[0] * in[3] + 0.5f; + in[1] = in[1] * in[3] + 0.5f; + in[2] = in[2] * in[3] + 0.5f; // Map x,y to viewport - int vPos = viewport.position(); - int wPos = win_pos.position(); - win_pos.put(0+wPos, in.get(0) * viewport.get(2+vPos) + viewport.get(0+vPos)); - win_pos.put(1+wPos, in.get(1) * viewport.get(3+vPos) + viewport.get(1+vPos)); - win_pos.put(2+wPos, in.get(2)); + final int vPos = viewport.position(); + final int wPos = win_pos.position(); + win_pos.put(0+wPos, in[0] * viewport.get(2+vPos) + viewport.get(0+vPos)); + win_pos.put(1+wPos, in[1] * viewport.get(3+vPos) + viewport.get(1+vPos)); + win_pos.put(2+wPos, in[2]); return true; } @@ -615,8 +592,8 @@ public class ProjectFloat { float[] projMatrix, int projMatrix_offset, int[] viewport, int viewport_offset, float[] obj_pos, int obj_pos_offset) { - float[] in = this.in; - float[] out = this.out; + final float[] in = this.in; + final float[] out = this.out; FloatUtil.multMatrixf(projMatrix, projMatrix_offset, modelMatrix, modelMatrix_offset, matrix, 0); @@ -673,8 +650,8 @@ public class ProjectFloat { FloatBuffer projMatrix, int[] viewport, int viewport_offset, float[] obj_pos, int obj_pos_offset) { - FloatBuffer in = this.inBuf; - FloatBuffer out = this.outBuf; + final float[] in = this.in; + final float[] out = this.out; FloatUtil.multMatrixf(projMatrix, modelMatrix, matrixBuf); @@ -682,31 +659,31 @@ public class ProjectFloat { return false; } - in.put(0, winx); - in.put(1, winy); - in.put(2, winz); - in.put(3, 1.0f); + in[0] = winx; + in[1] = winy; + in[2] = winz; + in[3] = 1.0f; // Map x and y from window coordinates - in.put(0, (in.get(0) - viewport[0+viewport_offset]) / viewport[2+viewport_offset]); - in.put(1, (in.get(1) - viewport[1+viewport_offset]) / viewport[3+viewport_offset]); - + in[0] = (in[0] - viewport[0+viewport_offset]) / viewport[2+viewport_offset]; + in[1] = (in[1] - viewport[1+viewport_offset]) / viewport[3+viewport_offset]; + // Map to range -1 to 1 - in.put(0, in.get(0) * 2 - 1); - in.put(1, in.get(1) * 2 - 1); - in.put(2, in.get(2) * 2 - 1); + in[0] = in[0] * 2 - 1; + in[1] = in[1] * 2 - 1; + in[2] = in[2] * 2 - 1; FloatUtil.multMatrixVecf(matrixBuf, in, out); - - if (out.get(3) == 0.0f) { + + if (out[3] == 0.0) { return false; } - out.put(3, 1.0f / out.get(3)); + out[3] = 1.0f / out[3]; - obj_pos[0+obj_pos_offset] = out.get(0) * out.get(3); - obj_pos[1+obj_pos_offset] = out.get(1) * out.get(3); - obj_pos[2+obj_pos_offset] = out.get(2) * out.get(3); + obj_pos[0+obj_pos_offset] = out[0] * out[3]; + obj_pos[1+obj_pos_offset] = out[1] * out[3]; + obj_pos[2+obj_pos_offset] = out[2] * out[3]; return true; } @@ -729,8 +706,8 @@ public class ProjectFloat { FloatBuffer projMatrix, IntBuffer viewport, FloatBuffer obj_pos) { - FloatBuffer in = this.inBuf; - FloatBuffer out = this.outBuf; + final float[] in = this.in; + final float[] out = this.out; FloatUtil.multMatrixf(projMatrix, modelMatrix, matrixBuf); @@ -738,33 +715,33 @@ public class ProjectFloat { return false; } - in.put(0, winx); - in.put(1, winy); - in.put(2, winz); - in.put(3, 1.0f); + in[0] = winx; + in[1] = winy; + in[2] = winz; + in[3] = 1.0f; // Map x and y from window coordinates - int vPos = viewport.position(); - int oPos = obj_pos.position(); - in.put(0, (in.get(0) - viewport.get(0+vPos)) / viewport.get(2+vPos)); - in.put(1, (in.get(1) - viewport.get(1+vPos)) / viewport.get(3+vPos)); + final int vPos = viewport.position(); + final int oPos = obj_pos.position(); + in[0] = (in[0] - viewport.get(0+vPos)) / viewport.get(2+vPos); + in[1] = (in[1] - viewport.get(1+vPos)) / viewport.get(3+vPos); // Map to range -1 to 1 - in.put(0, in.get(0) * 2 - 1); - in.put(1, in.get(1) * 2 - 1); - in.put(2, in.get(2) * 2 - 1); + in[0] = in[0] * 2 - 1; + in[1] = in[1] * 2 - 1; + in[2] = in[2] * 2 - 1; FloatUtil.multMatrixVecf(matrixBuf, in, out); - if (out.get(3) == 0.0f) { + if (out[3] == 0.0) { return false; } - out.put(3, 1.0f / out.get(3)); + out[3] = 1.0f / out[3]; - obj_pos.put(0+oPos, out.get(0) * out.get(3)); - obj_pos.put(1+oPos, out.get(1) * out.get(3)); - obj_pos.put(2+oPos, out.get(2) * out.get(3)); + obj_pos.put(0+oPos, out[0] * out[3]); + obj_pos.put(1+oPos, out[1] * out[3]); + obj_pos.put(2+oPos, out[2] * out[3]); return true; } @@ -800,8 +777,8 @@ public class ProjectFloat { float far, float[] obj_pos, int obj_pos_offset ) { - float[] in = this.in; - float[] out = this.out; + final float[] in = this.in; + final float[] out = this.out; FloatUtil.multMatrixf(projMatrix, projMatrix_offset, modelMatrix, modelMatrix_offset, matrix, 0); @@ -825,8 +802,9 @@ public class ProjectFloat { FloatUtil.multMatrixVecf(matrix, in, out); - if (out[3] == 0.0f) + if (out[3] == 0.0f) { return false; + } obj_pos[0+obj_pos_offset] = out[0]; obj_pos[1+obj_pos_offset] = out[1]; @@ -861,40 +839,41 @@ public class ProjectFloat { float near, float far, FloatBuffer obj_pos) { - FloatBuffer in = this.inBuf; - FloatBuffer out = this.outBuf; + final float[] in = this.in; + final float[] out = this.out; FloatUtil.multMatrixf(projMatrix, modelMatrix, matrixBuf); if (!gluInvertMatrixf(matrixBuf, matrixBuf)) return false; - in.put(0, winx); - in.put(1, winy); - in.put(2, winz); - in.put(3, clipw); + in[0] = winx; + in[1] = winy; + in[2] = winz; + in[3] = clipw; // Map x and y from window coordinates - int vPos = viewport.position(); - in.put(0, (in.get(0) - viewport.get(0+vPos)) / viewport.get(2+vPos)); - in.put(1, (in.get(1) - viewport.get(1+vPos)) / viewport.get(3+vPos)); - in.put(2, (in.get(2) - near) / (far - near)); - + final int vPos = viewport.position(); + in[0] = (in[0] - viewport.get(0+vPos)) / viewport.get(2+vPos); + in[1] = (in[1] - viewport.get(1+vPos)) / viewport.get(3+vPos); + in[2] = (in[2] - near) / (far - near); + // Map to range -1 to 1 - in.put(0, in.get(0) * 2 - 1); - in.put(1, in.get(1) * 2 - 1); - in.put(2, in.get(2) * 2 - 1); + in[0] = in[0] * 2 - 1; + in[1] = in[1] * 2 - 1; + in[2] = in[2] * 2 - 1; FloatUtil.multMatrixVecf(matrixBuf, in, out); - if (out.get(3) == 0.0f) + if (out[3] == 0.0f) { return false; + } - int oPos = obj_pos.position(); - obj_pos.put(0+oPos, out.get(0)); - obj_pos.put(1+oPos, out.get(1)); - obj_pos.put(2+oPos, out.get(2)); - obj_pos.put(3+oPos, out.get(3)); + final int oPos = obj_pos.position(); + obj_pos.put(0+oPos, out[0]); + obj_pos.put(1+oPos, out[1]); + obj_pos.put(2+oPos, out[2]); + obj_pos.put(3+oPos, out[3]); return true; } @@ -919,7 +898,7 @@ public class ProjectFloat { } /* Translate and scale the picked region to the entire window */ - int vPos = viewport.position(); + final int vPos = viewport.position(); gl.glTranslatef((viewport.get(2+vPos) - 2 * (x - viewport.get(0+vPos))) / deltaX, (viewport.get(3+vPos) - 2 * (y - viewport.get(1+vPos))) / deltaY, 0); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java new file mode 100644 index 000000000..4e959d460 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java @@ -0,0 +1,109 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import org.junit.Before; +import org.junit.Test; + +import com.jogamp.opengl.util.PMVMatrix; + +import javax.media.opengl.fixedfunc.GLMatrixFunc; +import java.nio.FloatBuffer; + +import static org.junit.Assert.assertArrayEquals; + +/** + * @author Thomas De Bodt + */ +public class TestPMVMatrix02NEWT { + + private PMVMatrix fMat; + + @Before + public void setUp() throws Exception { + fMat = new PMVMatrix(); + } + + @Test + public void testLookAtNegZIsNoOp() throws Exception { + fMat.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + // Look towards -z + fMat.gluLookAt( + 0, 0, 0, + 0, 0, -1, + 0, 1, 0 + ); + FloatBuffer mvMatrix = fMat.glGetMvMatrixf(); + float[] mvMatrixArr = new float[16]; + mvMatrix.asReadOnlyBuffer().get(mvMatrixArr); + assertArrayEquals( + /** + * The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward. + */ + new float[] { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + }, + mvMatrixArr, + 1e-6f + ); + } + @Test + public void testLookAtPosY() throws Exception { + fMat.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + // Look towards +y + fMat.gluLookAt( + 0, 0, 0, + 0, 1, 0, + 0, 0, 1 + ); + FloatBuffer mvMatrix = fMat.glGetMvMatrixf(); + float[] mvMatrixArr = new float[16]; + mvMatrix.asReadOnlyBuffer().get(mvMatrixArr); + assertArrayEquals( + /** + * The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward. + */ + new float[] { + 1, 0, 0, 0, + 0, 0, -1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 + }, + mvMatrixArr, + 1e-6f + ); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPMVMatrix02NEWT.class.getName()); + } +} -- cgit v1.2.3 From 451faa16651a85bab92e11d12de48e4b195904ba Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 16:53:07 +0100 Subject: Fix Unit Tests regarding commit 55f4405dbf9253e6ca686e44c50b2cfc1af7f3eb: Shader program name is valid if non-zero. --- make/scripts/tests.sh | 4 ++-- .../test/junit/jogl/acore/TestFBOMRTNEWT01.java | 6 +++--- .../junit/jogl/glsl/TestGLSLShaderState01NEWT.java | 4 ++-- .../junit/jogl/glsl/TestGLSLShaderState02NEWT.java | 19 ++++++++++--------- .../opengl/test/junit/jogl/glsl/TestRulerNEWT01.java | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9c74a08a0..100117fa1 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -250,7 +250,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -438,7 +438,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* # diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java index 8e2468536..e5075bbea 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMRTNEWT01.java @@ -87,8 +87,8 @@ public class TestFBOMRTNEWT01 extends UITestCase { "shader/bin", "fbo-mrt-1", false); final ShaderProgram sp0 = new ShaderProgram(); sp0.add(gl, vp0, System.err); - sp0.add(gl, fp0, System.err); - Assert.assertTrue(0<=sp0.program()); + sp0.add(gl, fp0, System.err); + Assert.assertTrue(0 != sp0.program()); Assert.assertTrue(!sp0.inUse()); Assert.assertTrue(!sp0.linked()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); @@ -101,7 +101,7 @@ public class TestFBOMRTNEWT01 extends UITestCase { final ShaderProgram sp1 = new ShaderProgram(); sp1.add(gl, vp1, System.err); sp1.add(gl, fp1, System.err); - Assert.assertTrue(0<=sp1.program()); + Assert.assertTrue(0 != sp1.program()); Assert.assertTrue(!sp1.inUse()); Assert.assertTrue(!sp1.linked()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java index e64c3de19..ab4b2d8b6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java @@ -81,12 +81,12 @@ public class TestGLSLShaderState01NEWT extends UITestCase { rsFp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); final ShaderProgram sp = new ShaderProgram(); - Assert.assertTrue(0>sp.program()); + Assert.assertTrue(0 == sp.program()); sp.add(gl, rsVp, System.err); sp.add(gl, rsFp, System.err); - Assert.assertTrue(0<=sp.program()); + Assert.assertTrue(0 != sp.program()); Assert.assertTrue(!sp.inUse()); Assert.assertTrue(!sp.linked()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java index 69736f33b..7022b7400 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java @@ -94,9 +94,9 @@ public class TestGLSLShaderState02NEWT extends UITestCase { sp1.add(rsVp0); sp1.add(rsFp1); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - Assert.assertTrue(0>sp1.program()); - sp1.init(gl); - Assert.assertTrue(0<=sp1.program()); + Assert.assertTrue(0 == sp1.program()); + Assert.assertTrue(sp1.init(gl)); + Assert.assertTrue(0 != sp1.program()); Assert.assertTrue(!sp1.inUse()); Assert.assertTrue(!sp1.linked()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); @@ -111,9 +111,9 @@ public class TestGLSLShaderState02NEWT extends UITestCase { sp0.add(rsFp0); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - Assert.assertTrue(0>sp0.program()); - sp0.init(gl); - Assert.assertTrue(0<=sp0.program()); + Assert.assertTrue(0 == sp0.program()); + Assert.assertTrue(sp0.init(gl)); + Assert.assertTrue(0 != sp0.program()); Assert.assertTrue(!sp0.inUse()); Assert.assertTrue(!sp0.linked()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); @@ -265,15 +265,16 @@ public class TestGLSLShaderState02NEWT extends UITestCase { sp1.add(rsVp0); sp1.add(rsFp1); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - Assert.assertTrue(0>sp1.program()); - sp1.init(gl); + Assert.assertTrue(0 == sp1.program()); + Assert.assertTrue(sp1.init(gl)); + Assert.assertTrue(0 != sp1.program()); Assert.assertTrue(sp1.link(gl, System.err)); final ShaderProgram sp0 = new ShaderProgram(); sp0.add(rsVp0); sp0.add(rsFp0); - sp0.init(gl); + Assert.assertTrue(sp0.init(gl)); Assert.assertTrue(sp0.link(gl, System.err)); st.attachShaderProgram(gl, sp0, true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java index a7fe9a064..98620e0c1 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java @@ -83,7 +83,7 @@ public class TestRulerNEWT01 extends UITestCase { final ShaderProgram sp0 = new ShaderProgram(); sp0.add(gl, vp0, System.err); sp0.add(gl, fp0, System.err); - Assert.assertTrue(0<=sp0.program()); + Assert.assertTrue(0 != sp0.program()); Assert.assertTrue(!sp0.inUse()); Assert.assertTrue(!sp0.linked()); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); -- cgit v1.2.3 From 875a36a142b086e4f1c311440db008f816258de5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 21:32:28 +0100 Subject: MacOSXCGLContext: Fix ShaderCode instantiation .. (duh!) ; Tested via reparenting TestParentingFocusTraversal01AWT --- make/scripts/tests.sh | 3 ++- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 31 +++++++--------------- .../parenting/NewtAWTReparentingKeyAdapter.java | 4 ++- .../TestParentingFocusTraversal01AWT.java | 5 +++- 4 files changed, 18 insertions(+), 25 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 100117fa1..05409e819 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -276,6 +276,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* @@ -438,7 +439,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* # diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 518d97067..360b7457b 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -138,32 +138,19 @@ public abstract class MacOSXCGLContext extends GLContextImpl } } - /** Static instances of GL3 core shader code, initialized lazy when required - never destroyed. */ - private static Object gl3ShaderLock = new Object(); - private static volatile boolean gl3VertexShaderInitialized = false; - private static ShaderCode gl3VertexShader = null; - private static ShaderCode gl3FragmentShader = null; + private static final String shaderBasename = "texture01_xxx"; private static ShaderProgram createCALayerShader(GL3 gl) { - // Create vertex & fragment shader code objects - if( !gl3VertexShaderInitialized ) { // volatile OK - synchronized( gl3ShaderLock ) { - if( !gl3VertexShaderInitialized ) { - final String shaderBasename = "texture01_xxx"; - gl3VertexShader = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MacOSXCGLContext.class, - "../../shader", "../../shader/bin", shaderBasename, true); - gl3FragmentShader = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MacOSXCGLContext.class, - "../../shader", "../../shader/bin", shaderBasename, true); - gl3VertexShader.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); - gl3FragmentShader.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); - gl3VertexShaderInitialized = true; - } - } - } // Create & Link the shader program final ShaderProgram sp = new ShaderProgram(); - sp.add(gl3VertexShader); - sp.add(gl3FragmentShader); + final ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MacOSXCGLContext.class, + "../../shader", "../../shader/bin", shaderBasename, true); + final ShaderCode fp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MacOSXCGLContext.class, + "../../shader", "../../shader/bin", shaderBasename, true); + vp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); + fp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); + sp.add(vp); + sp.add(fp); if(!sp.link(gl, System.err)) { throw new GLException("Couldn't link program: "+sp); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index f7881615d..15393e8ea 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -48,7 +48,9 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } public void keyTyped(KeyEvent e) { - if(e.getKeyChar()=='d') { + if(e.getKeyChar()=='i') { + System.err.println(glWindow); + } else if(e.getKeyChar()=='d') { glWindow.setUndecorated(!glWindow.isUndecorated()); } else if(e.getKeyChar()=='f') { glWindow.setFullscreen(!glWindow.isFullscreen()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java index f39b5df3b..d6f1f817a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java @@ -68,12 +68,13 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { static long durationPerTest = numFocus * 200; static GLCapabilities glCaps; static boolean manual = false; + static boolean forceGL3 = false; @BeforeClass public static void initClass() { glSize = new Dimension(200,200); fSize = new Dimension(300,300); - glCaps = new GLCapabilities(null); + glCaps = new GLCapabilities( forceGL3 ? GLProfile.get(GLProfile.GL3) : null ); } @Test @@ -314,6 +315,8 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { durationPerTest = atoi(args[++i]); } else if(args[i].equals("-manual")) { manual = true; + } else if(args[i].equals("-gl3")) { + forceGL3 = true; } } String tstname = TestParentingFocusTraversal01AWT.class.getName(); -- cgit v1.2.3 From c135d638fe820457977747e3d45960da64038d53 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 31 Oct 2012 21:52:21 +0100 Subject: NEWT Windows KeyEvent: We have to store the keyChar for typed events, since keyChar from pressed/released may be wrong (Uppercase: SHIFT-1, etc ..) Partially reverts commit: b62e1d027c289877686d6008ea8dd40e4e1541ec --- make/scripts/tests-x64.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java | 10 ++++++++++ src/newt/native/WindowsWindow.c | 6 +++--- 4 files changed, 17 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 7de5fe51c..c8bc03017 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -19,7 +19,7 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLPro REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* @@ -37,7 +37,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEven REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 05409e819..ef64aa7dd 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -246,7 +246,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -276,7 +276,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index c513b9e84..6aac8617c 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -266,6 +267,9 @@ public class WindowDriver extends WindowImpl { super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); } } + + /** FIXME: We have to store the keyChar for typed events, since keyChar from pressed/released may be wrong (Uppercase: SHIFT-1, etc ..). */ + private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); @@ -282,6 +286,10 @@ public class WindowDriver extends WindowImpl { } keyPressedState.put(keyCode, false); } + final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0); + if( 0 != keyCharTyped ) { + keyChar = (char)keyCharTyped; + } emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); break; @@ -304,6 +312,8 @@ public class WindowDriver extends WindowImpl { modifiers |= InputEvent.AUTOREPEAT_MASK; emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + } else if( 0 != keyCode ) { + typedKeyCode2KeyChar.put(keyCode, keyChar); } break; } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 2152166e4..e3d5cffa0 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -557,7 +557,7 @@ static int WmChar(JNIEnv *env, jobject window, UINT character, WORD repCnt, BYTE } static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = -1; + UINT modifiers = 0, jkey = 0, character = 0; if (wkey == VK_PROCESSKEY) { return 1; } @@ -584,7 +584,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE s (*env)->CallVoidMethod(env, window, sendKeyEventID, (jint) EVENT_KEY_TYPED, modifiers, - (jint) -1, + (jint) 0, (jchar) '\177'); } @@ -592,7 +592,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE s } static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = -1; + UINT modifiers = 0, jkey = 0, character = 0; if (wkey == VK_PROCESSKEY) { return 1; } -- cgit v1.2.3 From c002e04f848116922a1ed7bd96ead54961649bbd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 4 Nov 2012 07:09:39 +0100 Subject: GLAutoDrawable: Fix GLEventListener lifecycle and expose more user control (API Change) ; Added GLDrawableUtil A GLEventListener resides in two states, initialized and uninitialized. When added to a GLAutoDrawable, it is uninitialized. A first 'display()' will issue GLEventListener's 'init(..)' which renders it initialized. This is usually accompanied by 'reshape(..)' propagating the drawable's dimension. Destruction of the GLAutoDrawable will issue GLEventListener's 'dispose(..)' which renders it uninitialized. It turns our these means of GLEventListener controls are not sufficient in case the user requires to remove and add them during the lifecycle and rendering of their GLAutoDrawable host. GLAutoDrawable 'removeGLEventListener(..)' merely removes the GLEventListener from the list, but does not complete it's lifecycle, i.e. issues 'dispose(..)' if initialized to realease GL related resources. Hence the following essential API changes are made to complete the lifecycle: + public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove); disposing a single GLEventListener, allowing it's removal from the list being optional This is demonstrated via GLDrawableUtil.swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b), see below. ++++++++ Further more the following API changes were made to expose complete control of GLEventListener to the user: - public void removeGLEventListener(GLEventListener listener); + public GLEventListener removeGLEventListener(GLEventListener listener); The return value allows simple pipelining, and also delivers information whether the passed listener was actually removed. - public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException; + public int getGLEventListenerCount(); + public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException; Dropping the redundant removal by index, while adding count and get methods. + public boolean getGLEventListenerInitState(GLEventListener listener); + public void setGLEventListenerInitState(GLEventListener listener, boolean initialized); Allows retrieving and setting of listener states. All in all these API changes allows a user to experience all freedoms in dealing w/ GLEventListeners hosted by GLAutoDrawable impl. and shall be future proof. Note that we have avoided the Iterator pattern due to it's overhead of temporal objects creation. The simple indexed access allows us to implement each method as an atomic operation. +++++++++++ Further more a simple enqueue(..) method has been added, allowing to just enqueue a GLRunnable w/o provoking it's execution - as invoke(..) does. This method pleases a use case where GLRunnables are batched and shall be executed later on.. public boolean invoke(boolean wait, GLRunnable glRunnable); + public void enqueue(GLRunnable glRunnable); +++++++++++ Added GLDrawableUtil, exposes utility function to rearrange GLEventListener, modifiy GLAutoDrawable, etc. GLDrawableUtil.swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b) is tested and demonstrated w/ TestGLContextDrawableSwitchNEWT. Manually tested on X11, OSX and Windows. --- make/scripts/tests-x64.bat | 5 +- make/scripts/tests.sh | 7 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 73 ++++- .../com/jogamp/opengl/util/GLDrawableUtil.java | 241 ++++++++++++++++ .../classes/javax/media/opengl/GLAutoDrawable.java | 183 ++++++++++-- .../classes/javax/media/opengl/awt/GLCanvas.java | 62 ++++- .../classes/javax/media/opengl/awt/GLJPanel.java | 63 ++++- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 49 +++- .../classes/jogamp/opengl/GLDrawableHelper.java | 306 ++++++++++++++++----- .../acore/TestGLContextDrawableSwitchNEWT.java | 64 ++--- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 11 - .../test/junit/jogl/demos/es2/RedSquareES2.java | 11 - .../jogl/demos/es2/TextureSequenceCubeES2.java | 1 - 13 files changed, 876 insertions(+), 200 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index c8bc03017..586b65175 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -14,12 +14,13 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ef64aa7dd..1fa687a21 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -146,6 +146,7 @@ function jrun() { #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Dnativewindow.debug.NativeWindow" @@ -246,7 +247,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -266,7 +267,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* @@ -349,6 +350,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* # # swt (testswt) diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 33322628d..ea794cc78 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -216,6 +216,26 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } }; + private class DisposeGLEventListenerAction implements Runnable { + private GLEventListener listener; + private boolean remove; + private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { + this.listener = listener; + this.remove = remove; + } + + @Override + public void run() { + final RecursiveLock _lock = lock; + _lock.lock(); + try { + listener = helper.disposeGLEventListener(GLCanvas.this, drawable, context, listener, remove); + } finally { + _lock.unlock(); + } + } + }; + /** * Storage for the client area rectangle so that it may be accessed from outside of the SWT thread. */ @@ -302,7 +322,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { addPaintListener(new PaintListener() { @Override public void paintControl(final PaintEvent arg0) { - if ( !helper.isExternalAnimatorAnimating() ) { + if ( !helper.isAnimatorAnimatingOnOtherThread() ) { display(); // checks: null != drawable } } @@ -439,13 +459,45 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } @Override - public void addGLEventListener(final GLEventListener arg0) { - helper.addGLEventListener(arg0); + public void addGLEventListener(final GLEventListener listener) { + helper.addGLEventListener(listener); } @Override - public void addGLEventListener(final int arg0, final GLEventListener arg1) throws IndexOutOfBoundsException { - helper.addGLEventListener(arg0, arg1); + public void addGLEventListener(final int idx, final GLEventListener listener) throws IndexOutOfBoundsException { + helper.addGLEventListener(idx, listener); + } + + @Override + public int getGLEventListenerCount() { + return helper.getGLEventListenerCount(); + } + + @Override + public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException { + return helper.getGLEventListener(index); + } + + @Override + public boolean getGLEventListenerInitState(GLEventListener listener) { + return helper.getGLEventListenerInitState(listener); + } + + @Override + public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { + helper.setGLEventListenerInitState(listener, initialized); + } + + @Override + public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { + final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove); + runInGLThread(r); + return r.listener; + } + + @Override + public GLEventListener removeGLEventListener(final GLEventListener listener) { + return helper.removeGLEventListener(listener); } /** @@ -496,17 +548,12 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public boolean invoke(final boolean wait, final GLRunnable run) { return helper.invoke(this, wait, run); } - + @Override - public void removeGLEventListener(final GLEventListener arg0) { - helper.removeGLEventListener(arg0); + public void enqueue(GLRunnable glRunnable) { + helper.enqueue(glRunnable); } - @Override - public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException { - return helper.removeGLEventListener(index); - } - @Override public void setAnimator(final GLAnimatorControl arg0) throws GLException { helper.setAnimator(arg0); diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java new file mode 100644 index 000000000..8197be4f5 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -0,0 +1,241 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLRunnable; + +import jogamp.opengl.Debug; + +/** + * Providing utility functions dealing w/ {@link GLDrawable}s, {@link GLAutoDrawable} and their {@link GLEventListener}. + */ +public class GLDrawableUtil { + protected static final boolean DEBUG = Debug.debug("GLDrawable"); + + public static final boolean isAnimatorStartedOnOtherThread(GLAnimatorControl animatorCtrl) { + return ( null != animatorCtrl ) ? animatorCtrl.isStarted() && animatorCtrl.getThread() != Thread.currentThread() : false ; + } + + public static final boolean isAnimatorStarted(GLAnimatorControl animatorCtrl) { + return ( null != animatorCtrl ) ? animatorCtrl.isStarted() : false ; + } + + public static final boolean isAnimatorAnimatingOnOtherThread(GLAnimatorControl animatorCtrl) { + return ( null != animatorCtrl ) ? animatorCtrl.isAnimating() && animatorCtrl.getThread() != Thread.currentThread() : false ; + } + + public static final boolean isAnimatorAnimating(GLAnimatorControl animatorCtrl) { + return ( null != animatorCtrl ) ? animatorCtrl.isAnimating() : false ; + } + + /** + * Moves the designated {@link GLEventListener} from {@link GLAutoDrawable} src to dest. + * If preserveInitState is true, it's initialized state is preserved + * and {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)} issued w/ the next {@link GLAutoDrawable#display()} call. + *

    + * Note that it is only legal to pass preserveInitState := true, + * if the {@link GLContext} of both src and dest are shared, or has itself moved from src to dest. + *

    + *

    + * Also note that the caller is encouraged to pause an attached {@link GLAnimatorControl}. + *

    + * @param src + * @param dest + * @param listener + * @param preserveInitState + */ + public static final void moveGLEventListener(GLAutoDrawable src, GLAutoDrawable dest, GLEventListener listener, boolean preserveInitState) { + final boolean initialized = src.getGLEventListenerInitState(listener); + src.removeGLEventListener(listener); + dest.addGLEventListener(listener); + if(preserveInitState && initialized) { + dest.setGLEventListenerInitState(listener, true); + dest.enqueue(new ReshapeGLEventListener(listener)); + } // else .. !init state is default + } + + /** + * Moves all {@link GLEventListener} from {@link GLAutoDrawable} src to dest. + * If preserveInitState is true, it's initialized state is preserved + * and {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)} issued w/ the next {@link GLAutoDrawable#display()} call. + *

    + * Note that it is only legal to pass preserveInitState := true, + * if the {@link GLContext} of both src and dest are shared, or has itself moved from src to dest. + *

    + *

    + * Also note that the caller is encouraged to pause an attached {@link GLAnimatorControl}. + *

    + * @param src + * @param dest + * @param listener + * @param preserveInitState + */ + public static final void moveAllGLEventListener(GLAutoDrawable src, GLAutoDrawable dest, boolean preserveInitState) { + for(int count = src.getGLEventListenerCount(); 0a and b, + * while preserving it's initialized state, resets the GL-Viewport and issuing {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)}. + *

    + * If an {@link GLAnimatorControl} is being attached to {@link GLAutoDrawable} a or b + * and the current thread is different than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. + *

    + * @param a + * @param b + */ + public static final void swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b) { + final GLAnimatorControl aAnim = a.getAnimator(); + final GLAnimatorControl bAnim = b.getAnimator(); + final boolean aIsPaused = isAnimatorAnimatingOnOtherThread(aAnim) && aAnim.pause(); + final boolean bIsPaused = isAnimatorAnimatingOnOtherThread(bAnim) && bAnim.pause(); + + // enqueue reset GL-Viewport + a.enqueue(setViewport); + b.enqueue(setViewport); + + // + // cache all GLEventListener and their init-state + // enqueue reshape on their destination, if already initialized + // + final int aSz = a.getGLEventListenerCount(); + final GLEventListener[] aGLE = new GLEventListener[aSz]; + final boolean[] aInit = new boolean[aSz]; + for(int i=0; i + * The GL-Viewport is reset and {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(..)} issued implicit. + *

    + *

    + * If an {@link GLAnimatorControl} is being attached to GLAutoDrawable src or dest and the current thread is different + * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. + *

    + * @param src + * @param dest + */ + public static final void swapGLContext(GLAutoDrawable src, GLAutoDrawable dest) { + final GLAnimatorControl aAnim = src.getAnimator(); + final GLAnimatorControl bAnim = dest.getAnimator(); + final boolean aIsPaused = isAnimatorAnimatingOnOtherThread(aAnim) && aAnim.pause(); + final boolean bIsPaused = isAnimatorAnimatingOnOtherThread(bAnim) && bAnim.pause(); + + for(int i = src.getGLEventListenerCount() - 1; 0 <= i; i--) { + src.disposeGLEventListener(src.getGLEventListener(i), false); + } + for(int i = dest.getGLEventListenerCount() - 1; 0 <= i; i--) { + dest.disposeGLEventListener(dest.getGLEventListener(i), false); + } + dest.setContext( src.setContext( dest.getContext() ) ); + + src.enqueue(setViewport); + dest.enqueue(setViewport); + src.display(); + dest.display(); + + if(aIsPaused) { aAnim.resume(); } + if(bIsPaused) { bAnim.resume(); } + } + +} diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 38f1746f9..fc569b13d 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -166,13 +166,26 @@ public interface GLAutoDrawable extends GLDrawable { */ public GLContext setContext(GLContext newCtx); - /** Adds a {@link GLEventListener} to the end of this drawable queue. - The listeners are notified of events in the order of the queue. */ + /** + * Adds the given {@link GLEventListener listener} to the end of this drawable queue. + * The {@link GLEventListener listeners} are notified of events in the order of the queue. + *

    + * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)} + * method will be called once before any other of it's callback methods. + * See {@link #getGLEventListenerInitState(GLEventListener)} for details. + *

    + * @param listener The GLEventListener object to be inserted + */ public void addGLEventListener(GLEventListener listener); /** - * Adds a {@link GLEventListener} at the given index of this drawable queue. - * The listeners are notified of events in the order of the queue. + * Adds the given {@link GLEventListener listener} at the given index of this drawable queue. + * The {@link GLEventListener listeners} are notified of events in the order of the queue. + *

    + * The newly added listener's {@link GLEventListener#init(GLAutoDrawable) init(..)} + * method will be called once before any other of it's callback methods. + * See {@link #getGLEventListenerInitState(GLEventListener)} for details. + *

    * @param index Position where the listener will be inserted. * Should be within (0 <= index && index <= size()). * An index value of -1 is interpreted as the end of the list, size(). @@ -181,30 +194,120 @@ public interface GLAutoDrawable extends GLDrawable { */ public void addGLEventListener(int index, GLEventListener listener) throws IndexOutOfBoundsException; - /** - * Removes a {@link GLEventListener} from this drawable. - * Note that if this is done from within a particular drawable's - * {@link GLEventListener} handler (reshape, display, etc.) that it is not + /** + * Returns the number of {@link GLEventListener} of this drawable queue. + * @return The number of GLEventListener objects of this drawable queue. + */ + public int getGLEventListenerCount(); + + /** + * Returns the {@link GLEventListener} at the given index of this drawable queue. + * @param index Position of the listener to be returned. + * Should be within (0 <= index && index < size()). + * An index value of -1 is interpreted as last listener, size()-1. + * @return The GLEventListener object at the given index. + * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index < size()), or -1 + */ + public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException; + + /** + * Retrieves whether the given {@link GLEventListener listener} is initialized or not. + *

    + * After {@link #addGLEventListener(GLEventListener) adding} a {@link GLEventListener} it is + * marked uninitialized and added to a list of to be initialized {@link GLEventListener}. + * If such uninitialized {@link GLEventListener}'s handler methods (reshape, display) + * are about to be invoked, it's {@link GLEventListener#init(GLAutoDrawable) init(..)} method is invoked first. + * Afterwards the {@link GLEventListener} is marked initialized + * and removed from the list of to be initialized {@link GLEventListener}. + *

    + *

    + * This methods returns the {@link GLEventListener} initialized state, + * i.e. returns false if it is included in the list of to be initialized {@link GLEventListener}, + * otherwise true. + *

    + * @param listener the GLEventListener object to query it's initialized state. + */ + public boolean getGLEventListenerInitState(GLEventListener listener); + + /** + * Sets the given {@link GLEventListener listener's} initialized state. + *

    + * This methods allows manually setting the {@link GLEventListener} initialized state, + * i.e. adding it to, or removing it from the list of to be initialized {@link GLEventListener}. + * See {@link #getGLEventListenerInitState(GLEventListener)} for details. + *

    + *

    + * Warning: This method does not validate whether the given {@link GLEventListener listener's} + * is member of this drawable queue, i.e. {@link #addGLEventListener(GLEventListener) added}. + *

    + *

    + * This method is only exposed to allow users full control over the {@link GLEventListener}'s state + * and is usually not recommended to change. + *

    + *

    + * One use case is moving a {@link GLContext} and their initialized {@link GLEventListener} + * from one {@link GLAutoDrawable} to another, + * where a subsequent {@link GLEventListener#init(GLAutoDrawable) init(..)} call after adding it + * to the new owner is neither required nor desired. + * See {@link com.jogamp.opengl.util.GLDrawableUtil#swapGLContextAndAllGLEventListener(GLAutoDrawable, GLAutoDrawable) swapGLContextAndAllGLEventListener(..)}. + *

    + * @param listener the GLEventListener object to perform a state change. + * @param initialized if true, mark the listener initialized, otherwise uninitialized. + */ + public void setGLEventListenerInitState(GLEventListener listener, boolean initialized); + + /** + * Disposes the given {@link GLEventListener listener} via {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)} + * if it has been initialized and added to this queue. + *

    + * If remove is true, the {@link GLEventListener} is removed from this drawable queue before disposal, + * otherwise marked uninitialized. + *

    + *

    + * If an {@link GLAnimatorControl} is being attached and the current thread is different + * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. + *

    + *

    + * Note that this is an expensive operation, since {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)} + * is decorated by {@link GLContext#makeCurrent()} and {@link GLContext#release()}. + *

    + *

    + * Use {@link #removeGLEventListener(GLEventListener) removeGLEventListener(listener)} instead + * if you just want to remove the {@link GLEventListener listener} and don't care about the disposal of the it's (OpenGL) resources. + *

    + *

    + * Also note that this is done from within a particular drawable's + * {@link GLEventListener} handler (reshape, display, etc.), that it is not * guaranteed that all other listeners will be evaluated properly * during this update cycle. - * @param listener The GLEventListener object to be removed + *

    + * @param listener The GLEventListener object to be disposed and removed if remove is true + * @param remove pass true to have the listener removed from this drawable queue, otherwise pass false + * @return the disposed and/or removed GLEventListener, or null if no action was performed, i.e. listener was not added */ - public void removeGLEventListener(GLEventListener listener); - + public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove); + /** - * Removes a {@link GLEventListener} at the given index from this drawable. + * Removes the given {@link GLEventListener listener} from this drawable queue. + *

    + * This is an inexpensive operation, since the removed listener's + * {@link GLEventListener#dispose(GLAutoDrawable) dispose(..)} method will not be called. + *

    + *

    + * Use {@link #disposeGLEventListener(GLEventListener, boolean) disposeGLEventListener(listener, true)} + * instead to ensure disposal of the {@link GLEventListener listener}'s (OpenGL) resources. + *

    + *

    * Note that if this is done from within a particular drawable's - * {@link GLEventListener} handler (reshape, display, etc.) that it is not + * {@link GLEventListener} handler (reshape, display, etc.), that it is not * guaranteed that all other listeners will be evaluated properly * during this update cycle. - * @param index Position of the listener to be removed. - * Should be within (0 <= index && index < size()). - * An index value of -1 is interpreted as last listener, size()-1. - * @return The removed GLEventListener object - * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index < size()), or -1 + *

    + * @param listener The GLEventListener object to be removed + * @return the removed GLEventListener, or null if listener was not added */ - public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException; - + public GLEventListener removeGLEventListener(GLEventListener listener); + /** *

    * Registers the usage of an animator, an {@link javax.media.opengl.GLAnimatorControl} implementation. @@ -236,25 +339,25 @@ public interface GLAutoDrawable extends GLDrawable { public GLAnimatorControl getAnimator(); /** - *

    * Enqueues a one-shot {@link GLRunnable}, * which will be executed within the next {@link #display()} call * after all registered {@link GLEventListener}s * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)} * methods has been called. - *

    *

    * If no {@link GLAnimatorControl} is animating (default),
    * or if the current thread is the animator thread,
    - * a {@link #display()} call is issued after enqueue the GLRunnable.
    - * No extra synchronization is performed in case wait is true, since it is executed in the current thread.

    + * a {@link #display()} call is issued after enqueue the GLRunnable, + * hence the {@link GLRunnable} will be executed right away.
    + *

    *

    - * If an {@link GLAnimatorControl} is animating,
    - * no {@link #display()} call is issued, since the animator thread performs it.
    + * If an {@link GLAnimatorControl animator} is running,
    + * no explicit {@link #display()} call is issued, allowing the {@link GLAnimatorControl animator} to perform it when it's due.
    *

    *

    * If wait is true the call blocks until the glRunnable - * has been executed.

    + * has been executed by the {@link GLAnimatorControl animator}, otherwise the method returns immediately. + *

    *

    * If wait is true and * {@link #isRealized()} returns false or {@link #getContext()} returns null, @@ -266,16 +369,40 @@ public interface GLAutoDrawable extends GLDrawable { * where all blocked callers are being notified. *

    * - * @param wait if true block until execution of glRunnable is finished, otherwise return immediatly w/o waiting + * @param wait if true block until execution of glRunnable is finished, otherwise return immediately w/o waiting * @param glRunnable the {@link GLRunnable} to execute within {@link #display()} * @return true if the {@link GLRunnable} has been processed or queued, otherwise false. * * @see #setAnimator(GLAnimatorControl) * @see #display() * @see GLRunnable + * @see #enqueue(GLRunnable) */ public boolean invoke(boolean wait, GLRunnable glRunnable); + /** + * Enqueues a one-shot {@link GLRunnable}, + * which will be executed within the next {@link #display()} call + * after all registered {@link GLEventListener}s + * {@link GLEventListener#display(GLAutoDrawable) display(GLAutoDrawable)} + * methods has been called. + *

    + * Unlike the {@link #invoke(boolean, GLRunnable)}, this method only enqueues the {@link GLRunnable} + * w/o taking care of it's execution. Hence either a performing {@link GLAnimatorControl animator} + * or explicit user call shall trigger {@link #display()} to ensure it's execution. + *

    + *

    + * Method return immediately w/o waiting or blocking + *

    + * + * @param glRunnable the {@link GLRunnable} to execute within the next {@link #display()} call + * + * @see #invoke(boolean, GLRunnable) + * @see #display() + * @see GLRunnable + */ + public void enqueue(GLRunnable glRunnable); + /** Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext. If a window is attached to it's implementation, it shall be closed. diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 1e9fcc95e..5b5f800a4 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -495,7 +495,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing (int) ((getHeight() + bounds.getHeight()) / 2)); return; } - if( ! this.helper.isExternalAnimatorAnimating() ) { + if( ! this.helper.isAnimatorAnimatingOnOtherThread() ) { display(); } } @@ -699,15 +699,37 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override - public void removeGLEventListener(GLEventListener listener) { - helper.removeGLEventListener(listener); + public int getGLEventListenerCount() { + return helper.getGLEventListenerCount(); } @Override - public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException { - return helper.removeGLEventListener(index); + public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException { + return helper.getGLEventListener(index); + } + + @Override + public boolean getGLEventListenerInitState(GLEventListener listener) { + return helper.getGLEventListenerInitState(listener); + } + + @Override + public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { + helper.setGLEventListenerInitState(listener, initialized); } + @Override + public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { + final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove); + Threading.invoke(true, r, getTreeLock()); + return r.listener; + } + + @Override + public GLEventListener removeGLEventListener(GLEventListener listener) { + return helper.removeGLEventListener(listener); + } + @Override public void setAnimator(GLAnimatorControl animatorControl) { helper.setAnimator(animatorControl); @@ -723,6 +745,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing return helper.invoke(this, wait, glRunnable); } + @Override + public void enqueue(GLRunnable glRunnable) { + helper.enqueue(glRunnable); + } + @Override public GLContext setContext(GLContext newCtx) { final RecursiveLock _lock = lock; @@ -984,15 +1011,12 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } }; - // Workaround for ATI driver bugs related to multithreading issues - // like simultaneous rendering via Animators to canvases that are - // being resized on the AWT event dispatch thread private final Runnable displayOnEDTAction = new Runnable() { @Override public void run() { final RecursiveLock _lock = lock; _lock.lock(); - try { + try { helper.invokeGL(drawable, context, displayAction, initAction); } finally { _lock.unlock(); @@ -1015,6 +1039,26 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } }; + private class DisposeGLEventListenerAction implements Runnable { + GLEventListener listener; + private boolean remove; + private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { + this.listener = listener; + this.remove = remove; + } + + @Override + public void run() { + final RecursiveLock _lock = lock; + _lock.lock(); + try { + listener = helper.disposeGLEventListener(GLCanvas.this, drawable, context, listener, remove); + } finally { + _lock.unlock(); + } + } + }; + // Disables the AWT's erasing of this Canvas's background on Windows // in Java SE 6. This internal API is not available in previous // releases, but the system property diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index d0b9fb913..08d70211b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -426,15 +426,47 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void removeGLEventListener(GLEventListener listener) { - helper.removeGLEventListener(listener); + public int getGLEventListenerCount() { + return helper.getGLEventListenerCount(); } @Override - public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException { - return helper.removeGLEventListener(index); - } + public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException { + return helper.getGLEventListener(index); + } + + @Override + public boolean getGLEventListenerInitState(GLEventListener listener) { + return helper.getGLEventListenerInitState(listener); + } + + @Override + public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { + helper.setGLEventListenerInitState(listener, initialized); + } + + @Override + public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { + final DisposeGLEventListenerAction r = new DisposeGLEventListenerAction(listener, remove); + if (EventQueue.isDispatchThread()) { + r.run(); + } else { + // Multithreaded redrawing of Swing components is not allowed, + // so do everything on the event dispatch thread + try { + EventQueue.invokeAndWait(r); + } catch (Exception e) { + throw new GLException(e); + } + } + return r.listener; + } + @Override + public GLEventListener removeGLEventListener(GLEventListener listener) { + return helper.removeGLEventListener(listener); + } + @Override public void setAnimator(GLAnimatorControl animatorControl) { helper.setAnimator(animatorControl); @@ -450,6 +482,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return helper.invoke(this, wait, glRunnable); } + @Override + public void enqueue(GLRunnable glRunnable) { + helper.enqueue(glRunnable); + } + @Override public GLContext createContext(GLContext shareWith) { return (null != backend) ? backend.createContext(shareWith) : null; @@ -685,7 +722,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void dispose(GLAutoDrawable drawable) { - helper.dispose(GLJPanel.this); + helper.disposeAllGLEventListener(GLJPanel.this, false); } @Override @@ -758,6 +795,20 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } }; + private class DisposeGLEventListenerAction implements Runnable { + GLEventListener listener; + private boolean remove; + private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { + this.listener = listener; + this.remove = remove; + } + + @Override + public void run() { + listener = helper.disposeGLEventListener(GLJPanel.this, backend.getDrawable(), backend.getContext(), listener, remove); + } + }; + private int getNextPowerOf2(int number) { // Workaround for problems where 0 width or height are transiently // seen during layout diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index 85156e8a1..09a754279 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -95,7 +95,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { protected final void defaultWindowRepaintOp() { final GLDrawable _drawable = drawable; if( null != _drawable && _drawable.isRealized() ) { - if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isExternalAnimatorAnimating() ) { + if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimatingOnOtherThread() ) { display(); } } @@ -124,7 +124,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock if( _drawable.isRealized() ) { - if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isExternalAnimatorAnimating() ) { + if( !_drawable.getNativeSurface().isSurfaceLockedByOtherThread() && !helper.isAnimatorAnimatingOnOtherThread() ) { display(); } } @@ -178,7 +178,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { final GLAnimatorControl ctrl = helper.getAnimator(); // Is an animator thread perform rendering? - if ( helper.isAnimatorRunningOnOtherThread() ) { + if ( helper.isAnimatorStartedOnOtherThread() ) { // Pause animations before initiating safe destroy. final boolean isPaused = ctrl.pause(); destroy(); @@ -299,6 +299,16 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } } + protected final GLEventListener defaultDisposeGLEventListener(GLEventListener listener, boolean remove) { + final RecursiveLock _lock = getLock(); + _lock.lock(); + try { + return helper.disposeGLEventListener(GLAutoDrawableBase.this, drawable, context, listener, remove); + } finally { + _lock.unlock(); + } + } + @Override public final GLDrawable getDelegatedDrawable() { return drawable; @@ -356,13 +366,33 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } @Override - public final void removeGLEventListener(GLEventListener listener) { - helper.removeGLEventListener(listener); + public int getGLEventListenerCount() { + return helper.getGLEventListenerCount(); + } + + @Override + public GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException { + return helper.getGLEventListener(index); + } + + @Override + public boolean getGLEventListenerInitState(GLEventListener listener) { + return helper.getGLEventListenerInitState(listener); + } + + @Override + public void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { + helper.setGLEventListenerInitState(listener, initialized); + } + + @Override + public GLEventListener disposeGLEventListener(GLEventListener listener, boolean remove) { + return defaultDisposeGLEventListener(listener, remove); } @Override - public GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException { - return helper.removeGLEventListener(index); + public final GLEventListener removeGLEventListener(GLEventListener listener) { + return helper.removeGLEventListener(listener); } @Override @@ -381,6 +411,11 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { return helper.invoke(this, wait, glRunnable); } + @Override + public final void enqueue(GLRunnable glRunnable) { + helper.enqueue(glRunnable); + } + @Override public final void setAutoSwapBufferMode(boolean enable) { helper.setAutoSwapBufferMode(enable); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index d4ff9702c..d891ae810 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -61,7 +61,6 @@ import com.jogamp.opengl.util.Animator; /** Encapsulates the implementation of most of the GLAutoDrawable's methods to be able to share it between GLCanvas and GLJPanel. */ - public class GLDrawableHelper { /** true if property jogl.debug.GLDrawable.PerfStats is defined. */ private static final boolean PERF_STATS = Debug.isPropertyDefined("jogl.debug.GLDrawable.PerfStats", true); @@ -75,6 +74,7 @@ public class GLDrawableHelper { private boolean autoSwapBufferMode; private Thread skipContextReleaseThread; private GLAnimatorControl animatorCtrl; + private static Runnable nop = new Runnable() { public void run() {} }; public GLDrawableHelper() { reset(); @@ -289,45 +289,239 @@ public class GLDrawableHelper { // GLEventListener may be added after context is created, // hence we earmark initialization for the next display call. listenersToBeInit.add(listener); + listeners.add(index, listener); } } - - public final void removeGLEventListener(GLEventListener listener) { + + /** + * Note that no {@link GLEventListener#dispose(GLAutoDrawable)} call is being issued + * due to the lack of a current context. + * Consider calling {@link #disposeGLEventListener(GLAutoDrawable, GLDrawable, GLContext, GLEventListener)}. + * @return the removed listener, or null if listener was not added + */ + public final GLEventListener removeGLEventListener(GLEventListener listener) { synchronized(listenersLock) { - listeners.remove(listener); listenersToBeInit.remove(listener); + return listeners.remove(listener) ? listener : null; } } - public final GLEventListener removeGLEventListener(int index) - throws IndexOutOfBoundsException { + public final GLEventListener removeGLEventListener(int index) throws IndexOutOfBoundsException { synchronized(listenersLock) { if(0>index) { index = listeners.size()-1; } - return listeners.remove(index); + final GLEventListener listener = listeners.remove(index); + listenersToBeInit.remove(listener); + return listener; + } + } + + public final int getGLEventListenerCount() { + synchronized(listenersLock) { + return listeners.size(); + } + } + + public final GLEventListener getGLEventListener(int index) throws IndexOutOfBoundsException { + synchronized(listenersLock) { + if(0>index) { + index = listeners.size()-1; + } + return listeners.get(index); + } + } + + public final boolean getGLEventListenerInitState(GLEventListener listener) { + synchronized(listenersLock) { + return !listenersToBeInit.contains(listener); + } + } + + public final void setGLEventListenerInitState(GLEventListener listener, boolean initialized) { + synchronized(listenersLock) { + if(initialized) { + listenersToBeInit.remove(listener); + } else { + listenersToBeInit.add(listener); + } } } /** - * Issues {@link javax.media.opengl.GLEventListener#dispose(javax.media.opengl.GLAutoDrawable)} - * to all listeners. + * Disposes the given {@link GLEventListener} via {@link GLEventListener#dispose(GLAutoDrawable)} + * if it has been initialized and added to this queue. *

    - * Please consider using {@link #disposeGL(GLAutoDrawable, GLDrawable, GLContext, Runnable)} - * for correctness! + * If remove is true, the {@link GLEventListener} is removed from this drawable queue before disposal, + * otherwise marked uninitialized. *

    - * @param drawable + *

    + * Please consider using {@link #disposeGLEventListener(GLAutoDrawable, GLDrawable, GLContext, GLEventListener)} + * for correctness, i.e. encapsulating all calls w/ makeCurrent etc. + *

    + * @param autoDrawable + * @param remove if true, the listener gets removed + * @return the disposed and/or removed listener, otherwise null if neither action is performed */ - public final void dispose(GLAutoDrawable drawable) { + public final GLEventListener disposeGLEventListener(GLAutoDrawable autoDrawable, GLEventListener listener, boolean remove) { + synchronized(listenersLock) { + if( remove ) { + if( listeners.remove(listener) ) { + if( !listenersToBeInit.remove(listener) ) { + listener.dispose(autoDrawable); + } + return listener; + } + } else { + if( listeners.contains(listener) && !listenersToBeInit.contains(listener) ) { + listener.dispose(autoDrawable); + listenersToBeInit.add(listener); + return listener; + } + } + } + return null; + } + + /** + * Disposes all added initialized {@link GLEventListener}s via {@link GLEventListener#dispose(GLAutoDrawable)}. + *

    + * If remove is true, the {@link GLEventListener}s are removed from this drawable queue before disposal, + * otherwise maked uninitialized. + *

    + *

    + * Please consider using {@link #disposeAllGLEventListener(GLAutoDrawable, GLDrawable, GLContext)} + * or {@link #disposeGL(GLAutoDrawable, GLDrawable, GLContext, Runnable)} + * for correctness, i.e. encapsulating all calls w/ makeCurrent etc. + *

    + * @param autoDrawable + * @return the disposal count + */ + public final int disposeAllGLEventListener(GLAutoDrawable autoDrawable, boolean remove) { + int disposeCount = 0; synchronized(listenersLock) { - final ArrayList _listeners = listeners; - for (int i=0; i < _listeners.size(); i++) { - _listeners.get(i).dispose(drawable); + if( remove ) { + for (int count = listeners.size(); 0 < count; count--) { + final GLEventListener listener = listeners.remove(0); + if( !listenersToBeInit.remove(listener) ) { + listener.dispose(autoDrawable); + disposeCount++; + } + } + } else { + final int count = listeners.size(); + for (int i = 0; i < count; i++) { + final GLEventListener listener = listeners.get(i); + if( !listenersToBeInit.contains(listener) ) { + listener.dispose(autoDrawable); + listenersToBeInit.add(listener); + disposeCount++; + } + } } } + return disposeCount; } + /** + * Principal helper method which runs {@link #disposeGLEventListener(GLAutoDrawable, GLEventListener, boolean)} + * with the context made current. + *

    + * If an {@link GLAnimatorControl} is being attached and the current thread is different + * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. + *

    + * + * @param autoDrawable + * @param context + * @param listener + * @param initAction + */ + public final GLEventListener disposeGLEventListener(final GLAutoDrawable autoDrawable, + final GLDrawable drawable, + final GLContext context, + final GLEventListener listener, + final boolean remove) { + synchronized(listenersLock) { + // fast path for uninitialized listener + if( listenersToBeInit.contains(listener) ) { + if( remove ) { + listenersToBeInit.remove(listener); + return listeners.remove(listener) ? listener : null; + } + return null; + } + } + final boolean isPaused = isAnimatorAnimatingOnOtherThread() && animatorCtrl.pause(); + final GLEventListener[] res = new GLEventListener[] { null }; + final Runnable action = new Runnable() { + public void run() { + res[0] = disposeGLEventListener(autoDrawable, listener, remove); + } + }; + invokeGL(drawable, context, action, nop); + + if(isPaused) { + animatorCtrl.resume(); + } + return res[0]; + } + + /** + * Principal helper method which runs {@link #disposeAllGLEventListener(GLAutoDrawable, boolean)} + * with the context made current. + *

    + * If an {@link GLAnimatorControl} is being attached and the current thread is different + * than {@link GLAnimatorControl#getThread() the animator's thread}, it is paused during the operation. + *

    + * + * @param autoDrawable + * @param context + * @param listener + * @param initAction + */ + public final void disposeAllGLEventListener(final GLAutoDrawable autoDrawable, + final GLDrawable drawable, + final GLContext context, + final boolean remove) { + + final boolean isPaused = isAnimatorAnimatingOnOtherThread() && animatorCtrl.pause(); + + final Runnable action = new Runnable() { + public void run() { + disposeAllGLEventListener(autoDrawable, remove); + } + }; + invokeGL(drawable, context, action, nop); + + if(isPaused) { + animatorCtrl.resume(); + } + } + + /** + * Principal helper method which runs + * {@link #disposeAllGLEventListener(GLAutoDrawable, boolean) disposeAllGLEventListener(autoDrawable, false)} + * with the context made current and destroys the context afterwards while holding the lock. + * @param autoDrawable + * @param drawable + * @param context + * @param postAction + */ + public final void disposeGL(final GLAutoDrawable autoDrawable, + final GLDrawable drawable, + final GLContext context, + final Runnable postAction) { + if(PERF_STATS) { + invokeGLImplStats(drawable, context, null, null, autoDrawable); + } else { + invokeGLImpl(drawable, context, null, null, autoDrawable); + } + if(null != postAction) { + postAction.run(); + } + } + private final void init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape) { l.init(drawable); if(sendReshape) { @@ -374,7 +568,7 @@ public class GLDrawableHelper { } } } - + private final void reshape(GLEventListener listener, GLAutoDrawable drawable, int x, int y, int width, int height, boolean setViewport, boolean checkInit) { if(checkInit) { @@ -459,15 +653,15 @@ public class GLDrawableHelper { } } - public final boolean isAnimatorRunningOnOtherThread() { + public final boolean isAnimatorStartedOnOtherThread() { return ( null != animatorCtrl ) ? animatorCtrl.isStarted() && animatorCtrl.getThread() != Thread.currentThread() : false ; } - public final boolean isAnimatorRunning() { + public final boolean isAnimatorStarted() { return ( null != animatorCtrl ) ? animatorCtrl.isStarted() : false ; } - public final boolean isExternalAnimatorAnimating() { + public final boolean isAnimatorAnimatingOnOtherThread() { return ( null != animatorCtrl ) ? animatorCtrl.isAnimating() && animatorCtrl.getThread() != Thread.currentThread() : false ; } @@ -501,9 +695,9 @@ public class GLDrawableHelper { GLRunnableTask rTask = null; Object rTaskLock = new Object(); synchronized(rTaskLock) { - boolean deferred; + final boolean deferred; synchronized(glRunnablesLock) { - deferred = isExternalAnimatorAnimating(); + deferred = isAnimatorAnimatingOnOtherThread(); if(!deferred) { wait = false; // don't wait if exec immediatly } @@ -531,6 +725,15 @@ public class GLDrawableHelper { return true; } + public final void enqueue(GLRunnable glRunnable) { + if( null == glRunnable) { + return; + } + synchronized(glRunnablesLock) { + glRunnables.add( new GLRunnableTask(glRunnable, null, false) ); + } + } + public final void setAutoSwapBufferMode(boolean enable) { autoSwapBufferMode = enable; } @@ -576,10 +779,10 @@ public class GLDrawableHelper { * @param runnable * @param initAction */ - public final void invokeGL(GLDrawable drawable, - GLContext context, - Runnable runnable, - Runnable initAction) { + public final void invokeGL(final GLDrawable drawable, + final GLContext context, + final Runnable runnable, + final Runnable initAction) { if(null==context) { if (DEBUG) { Exception e = new GLException(Thread.currentThread().getName()+" Info: GLDrawableHelper " + this + ".invokeGL(): NULL GLContext"); @@ -595,34 +798,11 @@ public class GLDrawableHelper { } } - /** - * Principal helper method which runs {@link #dispose(GLAutoDrawable)} with the context - * made current and destroys the context afterwards while holding the lock. - * - * @param autoDrawable - * @param drawable - * @param context - * @param postAction - */ - public final void disposeGL(GLAutoDrawable autoDrawable, - GLDrawable drawable, - GLContext context, - Runnable postAction) { - if(PERF_STATS) { - invokeGLImplStats(drawable, context, null, null, autoDrawable); - } else { - invokeGLImpl(drawable, context, null, null, autoDrawable); - } - if(null != postAction) { - postAction.run(); - } - } - - private final void invokeGLImpl(GLDrawable drawable, - GLContext context, - Runnable runnable, - Runnable initAction, - GLAutoDrawable disposeAutoDrawable) { + private final void invokeGLImpl(final GLDrawable drawable, + final GLContext context, + final Runnable runnable, + final Runnable initAction, + final GLAutoDrawable disposeAutoDrawable) { final Thread currentThread = Thread.currentThread(); final boolean isDisposeAction = null==initAction ; @@ -660,8 +840,8 @@ public class GLDrawableHelper { if(GLContext.CONTEXT_CURRENT_NEW == res) { throw new GLException(currentThread.getName()+" GLDrawableHelper " + this + ".invokeGL(): Dispose case (no init action given): Native context was not created (new ctx): "+context); } - if(listeners.size()>0) { - dispose(disposeAutoDrawable); + if( listeners.size() > 0 && null != disposeAutoDrawable ) { + disposeAllGLEventListener(disposeAutoDrawable, false); } } } @@ -686,11 +866,11 @@ public class GLDrawableHelper { } } - private final void invokeGLImplStats(GLDrawable drawable, - GLContext context, - Runnable runnable, - Runnable initAction, - GLAutoDrawable disposeAutoDrawable) { + private final void invokeGLImplStats(final GLDrawable drawable, + final GLContext context, + final Runnable runnable, + final Runnable initAction, + final GLAutoDrawable disposeAutoDrawable) { final Thread currentThread = Thread.currentThread(); final boolean isDisposeAction = null==initAction ; @@ -748,8 +928,8 @@ public class GLDrawableHelper { if(res == GLContext.CONTEXT_CURRENT_NEW) { throw new GLException(currentThread.getName()+" GLDrawableHelper " + this + ".invokeGL(): Dispose case (no init action given): Native context was not created (new ctx): "+context); } - if(listeners.size()>0) { - dispose(disposeAutoDrawable); + if( listeners.size() > 0 && null != disposeAutoDrawable ) { + disposeAllGLEventListener(disposeAutoDrawable, false); } } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java index 496be3d93..8d4b8f700 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java @@ -43,11 +43,11 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import com.jogamp.opengl.GLAutoDrawableDelegate; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLDrawableUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -157,28 +157,11 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { if( ( t1 - t0 ) / period > s) { s++; System.err.println(s+" - switch - START "+ ( t1 - t0 )); - animator.pause(); // switch context _and_ the demo synchronously - if(0 == s%2) { - final GLEventListener demo = glad2.removeGLEventListener(0); - GLContext ctx1 = glad1.setContext(glad2.getContext()); - glad2.setContext(ctx1); - glad1.addGLEventListener(0, demo); - } else { - final GLEventListener demo = glad1.removeGLEventListener(0); - GLContext ctx2 = glad2.setContext(glad1.getContext()); - glad1.setContext(ctx2); - glad2.addGLEventListener(0, demo); - } - System.err.println(s+" - switch - display-1"); - glad1.display(); - System.err.println(s+" - switch - display-2"); - glad2.display(); + GLDrawableUtil.swapGLContextAndAllGLEventListener(glad1, glad2); - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - - animator.resume(); + System.err.println(s+" - switch - END "+ ( t1 - t0 )); } Thread.sleep(100); t1 = System.currentTimeMillis(); @@ -223,24 +206,15 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { if( ( t1 - t0 ) / period > s) { s++; System.err.println(s+" - switch - START "+ ( t1 - t0 )); - animator.pause(); + System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); // switch context _and_ the demo synchronously - if(0 == s%2) { - final GLEventListener demo = glWindow2.removeGLEventListener(0); - GLContext ctx1 = glWindow1.setContext(glWindow2.getContext()); - glWindow1.addGLEventListener(0, demo); - glWindow2.setContext(ctx1); - } else { - final GLEventListener demo = glWindow1.removeGLEventListener(0); - GLContext ctx2 = glWindow2.setContext(glWindow1.getContext()); - glWindow2.addGLEventListener(0, demo); - glWindow1.setContext(ctx2); - } + GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); + System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); System.err.println(s+" - switch - END "+ ( t1 - t0 )); - - animator.resume(); } Thread.sleep(100); t1 = System.currentTimeMillis(); @@ -288,27 +262,23 @@ public class TestGLContextDrawableSwitchNEWT extends UITestCase { if( ( t1 - t0 ) / period > s) { s++; System.err.println(s+" - switch - START "+ ( t1 - t0 )); - animator.pause(); - - GLEventListener demo1 = glWindow1.removeGLEventListener(0); - GLEventListener demo2 = glWindow2.removeGLEventListener(0); - - GLContext ctx1 = glWindow1.setContext(glWindow2.getContext()); - glWindow1.addGLEventListener(0, demo2); - - glWindow2.setContext(ctx1); - glWindow2.addGLEventListener(0, demo1); - + System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); + System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); System.err.println(s+" - switch - END "+ ( t1 - t0 )); - - animator.resume(); } Thread.sleep(100); t1 = System.currentTimeMillis(); } animator.stop(); + System.err.println("pre -del-w1: w1: "+glWindow1); + System.err.println("pre -del-w1: w2: "+glWindow2); glWindow1.destroy(); + System.err.println("post-del-w1: w1: "+glWindow1); + System.err.println("post-del-w1: w2: "+glWindow2); glWindow2.destroy(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index e703b6fd9..e9fe9b401 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -65,7 +65,6 @@ public class GearsES2 implements GLEventListener { private int prevMouseX, prevMouseY; private boolean doRotate = true; - private boolean isInitialized = false; boolean ignoreFocus = false; public GearsES2(int swapInterval) { @@ -106,11 +105,6 @@ public class GearsES2 implements GLEventListener { public void init(GLAutoDrawable drawable) { - if(isInitialized) { - System.err.println(Thread.currentThread()+" GearsES2.init skipped!"); - return; - } - isInitialized = true; System.err.println(Thread.currentThread()+" GearsES2.init ..."); GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -228,11 +222,6 @@ public class GearsES2 implements GLEventListener { // private boolean useAndroidDebug = false; public void dispose(GLAutoDrawable drawable) { - if(!isInitialized) { - System.err.println(Thread.currentThread()+" GearsES2.dispose skipped!"); - return; - } - isInitialized = false; System.err.println(Thread.currentThread()+" GearsES2.dispose ... "); final Object upstreamWidget = drawable.getUpstreamWidget(); if (upstreamWidget instanceof Window) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index bf1ca5c2d..e4a457954 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -50,7 +50,6 @@ public class RedSquareES2 implements GLEventListener { Window window = null; float aspect = 1.0f; boolean doRotate = true; - boolean isInitialized = false; public RedSquareES2(int swapInterval) { this.swapInterval = swapInterval; @@ -64,11 +63,6 @@ public class RedSquareES2 implements GLEventListener { public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void init(GLAutoDrawable glad) { - if(isInitialized) { - System.err.println(Thread.currentThread()+" RedSquareES2.init skipped!"); - return; - } - isInitialized = true; System.err.println(Thread.currentThread()+" RedSquareES2.init ..."); GL2ES2 gl = glad.getGL().getGL2ES2(); @@ -184,11 +178,6 @@ public class RedSquareES2 implements GLEventListener { } public void dispose(GLAutoDrawable glad) { - if(!isInitialized) { - System.err.println(Thread.currentThread()+" RedSquareES2.dispose skipped!"); - return; - } - isInitialized = false; System.err.println(Thread.currentThread()+" RedSquareES2.dispose ... "); GL2ES2 gl = glad.getGL().getGL2ES2(); st.destroy(gl); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index 9217e2b53..25f8740d4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -75,7 +75,6 @@ public class TextureSequenceCubeES2 implements GLEventListener { private float view_rotx = 0.0f, view_roty = 0.0f, view_rotz = 0.0f; int[] vboNames = new int[4]; boolean innerCube; - boolean initialized = false; private ByteBuffer cubeIndices; private final MouseListener mouseAction = new MouseAdapter() { -- cgit v1.2.3 From 77db6a5c22cb4a53cf911b4caf57127770c70968 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 4 Nov 2012 19:05:32 +0100 Subject: Adding Andres Colubri's Test Case (junit'fyed), which provokes a Deadlock on OSX - Adding a similar one w/o deadlock and less framework bits. Andres Colubri reported a test case in the forum: Which is now included as TestGLCanvasAWTActionDeadlock01AWT. A similar w/ less framework bits and w/o dealock is also included as TestGLCanvasAWTActionDeadlock00AWT. A followup commit will incl. a fix after further analysis. A commit at this point where TestGLCanvasAWTActionDeadlock01AWT still freezes on OSX is done to be able to reproduce the bug and see the fix as a patch. --- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 4 +- .../awt/TestGLCanvasAWTActionDeadlock00AWT.java | 240 ++++++++ .../awt/TestGLCanvasAWTActionDeadlock01AWT.java | 604 +++++++++++++++++++++ 4 files changed, 849 insertions(+), 3 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock00AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 586b65175..e3e2fc1f9 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -15,7 +15,9 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 1fa687a21..e3a388e20 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -267,7 +267,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* @@ -351,7 +351,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEW #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* # # swt (testswt) diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock00AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock00AWT.java new file mode 100644 index 000000000..c6b70e12e --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock00AWT.java @@ -0,0 +1,240 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.AnimatorBase; +import com.jogamp.opengl.util.FPSAnimator; + +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import com.jogamp.opengl.test.junit.util.MiscUtils; + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Insets; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; + + +public class TestGLCanvasAWTActionDeadlock00AWT extends UITestCase { + static long durationPerTest = 1000; // ms + static final int width = 512; + static final int height = 512; + + GLEventListener gle1 = null; + GLEventListener gle2 = null; + + @Test + public void test01Animator() throws InterruptedException { + testImpl(new Animator(), 0, false); + } + + @Test + public void test02FPSAnimator() throws InterruptedException { + testImpl(new FPSAnimator(30), 0, false); + } + + @Test + public void test02FPSAnimator_RestartOnAWTEDT() throws InterruptedException { + testImpl(new FPSAnimator(30), 100, false); + } + + @Test + public void test02FPSAnimator_RestartOnCurrentThread() throws InterruptedException { + testImpl(new FPSAnimator(30), 100, true); + } + + void testImpl(final AnimatorBase animator, int restartPeriod, boolean restartOnCurrentThread) throws InterruptedException { + final Frame frame1 = new Frame("Frame 1"); + gle1 = new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + } + + @Override + public void dispose(GLAutoDrawable drawable) { + } + + @Override + public void display(GLAutoDrawable drawable) { + frame1.setTitle("f "+frameCount+", fps "+animator.getLastFPS()); + frameCount++; + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + }; + gle2 = new GearsES2(); + + Assert.assertNotNull(frame1); + { + Insets insets = frame1.getInsets(); + int w = width + insets.left + insets.right; + int h = height + insets.top + insets.bottom; + frame1.setSize(w, h); + } + frame1.setLocation(0, 0); + frame1.setTitle("Generic Title"); + + GLCanvas glCanvas = createGLCanvas(frame1); + glCanvas.addGLEventListener(gle1); + glCanvas.addGLEventListener(gle2); + + animator.setUpdateFPSFrames(60, System.err); + animator.add(glCanvas); + animator.start(); + + attachGLCanvas(frame1, glCanvas, false); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } + + final long sleep = 0 < restartPeriod ? restartPeriod : 100; + long togo = durationPerTest; + while( 0 < togo ) { + if(0 < restartPeriod) { + glCanvas = restart(frame1, glCanvas, restartOnCurrentThread); + } + + Thread.sleep(sleep); + + togo -= sleep; + } + + dispose(frame1, glCanvas); + animator.stop(); + + gle1 = null; + gle2 = null; + } + + void dispose(final Frame frame, final GLCanvas glCanvas) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + glCanvas.destroy(); + frame.dispose(); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } + } + + GLCanvas restart(final Frame frame, GLCanvas glCanvas, boolean restartOnCurrentThread) throws InterruptedException { + glCanvas.disposeGLEventListener(gle1, true); + glCanvas.disposeGLEventListener(gle2, true); + detachGLCanvas(frame, glCanvas, restartOnCurrentThread); + + glCanvas = createGLCanvas(frame); + + attachGLCanvas(frame, glCanvas, restartOnCurrentThread); + glCanvas.addGLEventListener(gle1); + glCanvas.addGLEventListener(gle2); + + return glCanvas; + } + + void attachGLCanvas(final Frame frame, final GLCanvas glCanvas, boolean restartOnCurrentThread) { + System.err.println("*** attachGLCanvas.0 on-current-thread "+restartOnCurrentThread+", currentThread "+Thread.currentThread().getName()); + if( restartOnCurrentThread ) { + frame.setLayout(new BorderLayout()); + frame.add(glCanvas, BorderLayout.CENTER); + frame.validate(); + } else { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setLayout(new BorderLayout()); + frame.add(glCanvas, BorderLayout.CENTER); + frame.validate(); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } + } + System.err.println("*** attachGLCanvas.X"); + } + + void detachGLCanvas(final Frame frame, final GLCanvas glCanvas, boolean restartOnCurrentThread) { + System.err.println("*** detachGLCanvas.0 on-current-thread "+restartOnCurrentThread+", currentThread "+Thread.currentThread().getName()); + if( restartOnCurrentThread ) { + frame.remove(glCanvas); + frame.validate(); + } else { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas); + frame.validate(); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } + } + System.err.println("*** detachGLCanvas.X"); + } + + int frameCount = 0; + + GLCanvas createGLCanvas(final Frame frame) { + System.err.println("*** createGLCanvas.0"); + final GLCanvas glCanvas = new GLCanvas(); + glCanvas.setBounds(0, 0, width, height); + Assert.assertNotNull(glCanvas); + System.err.println("*** createGLCanvas.X"); + return glCanvas; + } + + public static void main(String args[]) { + for(int i=0; i 1000 * fint) { + frate = (float)(fcount) / fint; + fcount = 0; + lastm = m; + System.err.println("fps: " + frate); + } + } + + void clock() { + long afterTime = System.nanoTime(); + long timeDiff = afterTime - beforeTime; + long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime; + + if (sleepTime > 0) { // some time left in this cycle + try { + Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L)); + } catch (InterruptedException ex) { } + + overSleepTime = (System.nanoTime() - afterTime) - sleepTime; + + } else { // sleepTime <= 0; the frame took longer than the period + overSleepTime = 0L; + } + + beforeTime = System.nanoTime(); + } + + class SimpleListener implements GLEventListener { + @Override + public void display(GLAutoDrawable drawable) { + draw(drawable.getGL().getGL2()); + } + + @Override + public void dispose(GLAutoDrawable drawable) { } + + @Override + public void init(GLAutoDrawable drawable) { } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { } + } + + public void mouseDragged(MouseEvent ev) { + if (printEventInfo) { + System.err.println("Mouse dragged event: " + ev); + } + } + + public void mouseMoved(MouseEvent ev) { + if (printEventInfo) { + System.err.println("Mouse moved event: " + ev); + } + } + + public void keyPressed(KeyEvent ev) { + if (printEventInfo) { + System.err.println("Key pressed event: " + ev); + } + } + + public void keyReleased(KeyEvent ev) { + if (printEventInfo) { + System.err.println("Key released event: " + ev); + } + } + + public void keyTyped(KeyEvent ev) { + if (printEventInfo) { + System.err.println("Key typed event: " + ev); + } + } + + /** An Animator subclass which renders one frame at the time + * upon calls to the requestRender() method. + **/ + public class CustomAnimator extends AnimatorBase { + private Timer timer = null; + private TimerTask task = null; + private volatile boolean shouldRun; + + protected String getBaseName(String prefix) { + return "Custom" + prefix + "Animator" ; + } + + /** Creates an CustomAnimator with an initial drawable to + * animate. */ + public CustomAnimator(GLAutoDrawable drawable) { + if (drawable != null) { + add(drawable); + } + } + + public synchronized void requestRender() { + shouldRun = true; + } + + public final boolean isStarted() { + stateSync.lock(); + try { + return (timer != null); + } finally { + stateSync.unlock(); + } + } + + public final boolean isAnimating() { + stateSync.lock(); + try { + return (timer != null) && (task != null); + } finally { + stateSync.unlock(); + } + } + + private void startTask() { + if(null != task) { + return; + } + + task = new TimerTask() { + private boolean firstRun = true; + public void run() { + if (firstRun) { + Thread.currentThread().setName("OPENGL"); + firstRun = false; + } + if(CustomAnimator.this.shouldRun) { + CustomAnimator.this.animThread = Thread.currentThread(); + // display impl. uses synchronized block on the animator instance + display(); + synchronized (this) { + // done with current frame. + shouldRun = false; + } + } + } + }; + + fpsCounter.resetFPSCounter(); + shouldRun = false; + + timer.schedule(task, 0, 1); + } + + public synchronized boolean start() { + if (timer != null) { + return false; + } + stateSync.lock(); + try { + timer = new Timer(); + startTask(); + } finally { + stateSync.unlock(); + } + return true; + } + + /** Stops this CustomAnimator. */ + public synchronized boolean stop() { + if (timer == null) { + return false; + } + stateSync.lock(); + try { + shouldRun = false; + if(null != task) { + task.cancel(); + task = null; + } + if(null != timer) { + timer.cancel(); + timer = null; + } + animThread = null; + try { + Thread.sleep(20); // ~ 1/60 hz wait, since we can't ctrl stopped threads + } catch (InterruptedException e) { } + } finally { + stateSync.unlock(); + } + return true; + } + + public final boolean isPaused() { return false; } + public synchronized boolean resume() { return false; } + public synchronized boolean pause() { return false; } + } + } + + @Test + public void test00() { + TestGLCanvasAWTActionDeadlock01AWT.MiniPApplet mini; + try { + Class c = Thread.currentThread().getContextClassLoader().loadClass(TestGLCanvasAWTActionDeadlock01AWT.MiniPApplet.class.getName()); + mini = (TestGLCanvasAWTActionDeadlock01AWT.MiniPApplet) c.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + if (mini != null) { + mini.run(); + } + } + + public static void main(String args[]) { + for(int i=0; i Date: Sun, 4 Nov 2012 19:51:31 +0100 Subject: TestGLCanvasAWTActionDeadlock01AWT: Reproducing OSX deadlock variation, using Applet as component which provokes offscreen FBO layer. --- make/scripts/tests-x64.bat | 2 +- make/scripts/tests.sh | 3 +- .../awt/TestGLCanvasAWTActionDeadlock01AWT.java | 259 +++++++++++++++++++++ 3 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index e3e2fc1f9..e4aa11869 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -17,7 +17,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLPro REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index e3a388e20..50e070130 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -106,7 +106,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" - #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" + D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" @@ -352,6 +352,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* # # swt (testswt) diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java new file mode 100644 index 000000000..fa4d4a5e2 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java @@ -0,0 +1,259 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.AnimatorBase; +import com.jogamp.opengl.util.FPSAnimator; + +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import com.jogamp.opengl.test.junit.util.MiscUtils; + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Frame; +import java.awt.Insets; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Test; + + +public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { + static long durationPerTest = 1000; // ms + static final int width = 512; + static final int height = 512; + + GLEventListener gle1 = null; + GLEventListener gle2 = null; + + @Test + public void test01Animator() throws InterruptedException { + testImpl(new Animator(), 0, false); + } + + // @Test + public void test02FPSAnimator() throws InterruptedException { + testImpl(new FPSAnimator(30), 0, false); + } + + // @Test + public void test02FPSAnimator_RestartOnAWTEDT() throws InterruptedException { + testImpl(new FPSAnimator(30), 100, false); + } + + // @Test + public void test02FPSAnimator_RestartOnCurrentThread() throws InterruptedException { + testImpl(new FPSAnimator(30), 100, true); + } + + void testImpl(final AnimatorBase animator, int restartPeriod, boolean restartOnCurrentThread) throws InterruptedException { + final Frame frame1 = new Frame("Frame 1"); + final Applet applet1 = new Applet() { + private static final long serialVersionUID = 1L; + }; + + Assert.assertNotNull(frame1); + frame1.setLayout(null); + frame1.pack(); + { + Insets insets = frame1.getInsets(); + int w = width + insets.left + insets.right; + int h = height + insets.top + insets.bottom; + frame1.setSize(w, h); + + int usableH = h - insets.top - insets.bottom; + applet1.setBounds((w - width)/2, insets.top + (usableH - height)/2, width, height); + } + frame1.setLocation(0, 0); + frame1.setTitle("Generic Title"); + frame1.add(applet1); + + frame1.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(frame1, applet1); + } + }); + + gle1 = new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + } + + @Override + public void dispose(GLAutoDrawable drawable) { + } + + @Override + public void display(GLAutoDrawable drawable) { + frame1.setTitle("f "+frameCount+", fps "+animator.getLastFPS()); + frameCount++; + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + }; + gle2 = new GearsES2(); + + GLCanvas glCanvas = createGLCanvas(); + glCanvas.addGLEventListener(gle1); + glCanvas.addGLEventListener(gle2); + + animator.setUpdateFPSFrames(60, System.err); + animator.add(glCanvas); + animator.start(); + + attachGLCanvas(applet1, glCanvas, false); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } + + final long sleep = 0 < restartPeriod ? restartPeriod : 100; + long togo = durationPerTest; + while( 0 < togo ) { + if(0 < restartPeriod) { + glCanvas = restart(applet1, glCanvas, restartOnCurrentThread); + } + + Thread.sleep(sleep); + + togo -= sleep; + } + + dispose(frame1, applet1); + animator.stop(); + + gle1 = null; + gle2 = null; + } + + void dispose(final Frame frame, final Applet applet) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(applet); + frame.dispose(); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } + } + + GLCanvas restart(final Applet frame, GLCanvas glCanvas, boolean restartOnCurrentThread) throws InterruptedException { + glCanvas.disposeGLEventListener(gle1, true); + glCanvas.disposeGLEventListener(gle2, true); + detachGLCanvas(frame, glCanvas, restartOnCurrentThread); + + glCanvas = createGLCanvas(); + + attachGLCanvas(frame, glCanvas, restartOnCurrentThread); + glCanvas.addGLEventListener(gle1); + glCanvas.addGLEventListener(gle2); + + return glCanvas; + } + + void attachGLCanvas(final Applet applet, final GLCanvas glCanvas, boolean restartOnCurrentThread) { + System.err.println("*** attachGLCanvas.0 on-current-thread "+restartOnCurrentThread+", currentThread "+Thread.currentThread().getName()); + if( restartOnCurrentThread ) { + applet.setLayout(new BorderLayout()); + applet.add(glCanvas, BorderLayout.CENTER); + applet.validate(); + } else { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + applet.setLayout(new BorderLayout()); + applet.add(glCanvas, BorderLayout.CENTER); + applet.validate(); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } + } + System.err.println("*** attachGLCanvas.X"); + } + + void detachGLCanvas(final Applet applet, final GLCanvas glCanvas, boolean restartOnCurrentThread) { + System.err.println("*** detachGLCanvas.0 on-current-thread "+restartOnCurrentThread+", currentThread "+Thread.currentThread().getName()); + if( restartOnCurrentThread ) { + applet.remove(glCanvas); + applet.validate(); + } else { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + applet.remove(glCanvas); + applet.validate(); + }}); + } catch (Throwable t) { + t.printStackTrace(); + Assume.assumeNoException(t); + } + } + System.err.println("*** detachGLCanvas.X"); + } + + int frameCount = 0; + + GLCanvas createGLCanvas() { + System.err.println("*** createGLCanvas.0"); + final GLCanvas glCanvas = new GLCanvas(); + glCanvas.setBounds(0, 0, width, height); + Assert.assertNotNull(glCanvas); + System.err.println("*** createGLCanvas.X"); + return glCanvas; + } + + public static void main(String args[]) { + for(int i=0; i Date: Mon, 5 Nov 2012 03:49:20 +0100 Subject: Analyzed OSX Deadlock w/ AWT Applet & CALayer: Andres Colubri's Test Case, Commit 77db6a5c22cb4a53cf911b4caf57127770c70968 [1] - The AWT/Applet test case on OSX utilized offscreen CALayer, which is correct. [2] - the GLEventListener.display(..) method calls Frame.setTitle(".."); which is correct, but freezes when called right after GLEventListener.init(..) BUG on OSX/CALayer: If frame.setTitle() is issued right after initialization the call hangs in at apple.awt.CWindow._setTitle(Native Method) at apple.awt.CWindow.setTitle(CWindow.java:765) [1.6.0_37, build 1.6.0_37-b06-434-11M3909] Happens w/ Oracle's JRE7u9 as well! Workaround: - Set 'justInitialized' flag in GLEventListener.init(..) - Clear 'justInitialized' flag in GLEventListener.display(..) at the end - Skip Frame.setTitle(..) in GLEventListener.display(..) if 'true == justInitialized' Somebody may send a bugreport to Oracle / OpenJDK. --- make/scripts/tests.sh | 6 +- .../awt/TestGLCanvasAWTActionDeadlock01AWT.java | 93 ++++++++++++++++------ .../awt/TestGLCanvasAWTActionDeadlock02AWT.java | 89 ++++++++++++++------- 3 files changed, 130 insertions(+), 58 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 50e070130..cc9a330a5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -106,7 +106,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" - D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" @@ -351,8 +351,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* # # swt (testswt) diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java index fa4d4a5e2..09609dd39 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java @@ -29,7 +29,9 @@ package com.jogamp.opengl.test.junit.jogl.awt; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.AnimatorBase; @@ -60,24 +62,29 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { GLEventListener gle1 = null; GLEventListener gle2 = null; + @Test + public void test00NoAnimator() throws InterruptedException { + testImpl(null, 0, false); + } + @Test public void test01Animator() throws InterruptedException { testImpl(new Animator(), 0, false); } - // @Test + @Test public void test02FPSAnimator() throws InterruptedException { testImpl(new FPSAnimator(30), 0, false); } - // @Test + @Test public void test02FPSAnimator_RestartOnAWTEDT() throws InterruptedException { - testImpl(new FPSAnimator(30), 100, false); + testImpl(new FPSAnimator(30), 200, false); } - // @Test + @Test public void test02FPSAnimator_RestartOnCurrentThread() throws InterruptedException { - testImpl(new FPSAnimator(30), 100, true); + testImpl(new FPSAnimator(30), 200, true); } void testImpl(final AnimatorBase animator, int restartPeriod, boolean restartOnCurrentThread) throws InterruptedException { @@ -109,8 +116,11 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { }); gle1 = new GLEventListener() { + boolean justInitialized = true; + @Override public void init(GLAutoDrawable drawable) { + justInitialized = true; } @Override @@ -119,8 +129,22 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { @Override public void display(GLAutoDrawable drawable) { - frame1.setTitle("f "+frameCount+", fps "+animator.getLastFPS()); + if(!justInitialized) { + // BUG on OSX/CALayer: If frame.setTitle() is issued right after initialization + // the call hangs in + // at apple.awt.CWindow._setTitle(Native Method) + // at apple.awt.CWindow.setTitle(CWindow.java:765) [1.6.0_37, build 1.6.0_37-b06-434-11M3909] + // + final String msg = "f "+frameCount+", fps "+( null != animator ? animator.getLastFPS() : 0); + System.err.println("About to setTitle: CT "+Thread.currentThread().getName()+", "+msg+ + frame1+", displayable "+frame1.isDisplayable()+ + ", valid "+frame1.isValid()+", visible "+frame1.isVisible()); + // Thread.dumpStack(); + frame1.setTitle(msg); + + } frameCount++; + justInitialized=false; } @Override @@ -133,27 +157,37 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { glCanvas.addGLEventListener(gle1); glCanvas.addGLEventListener(gle2); - animator.setUpdateFPSFrames(60, System.err); - animator.add(glCanvas); - animator.start(); + if(null != animator) { + System.err.println("About to start Animator: CT "+Thread.currentThread().getName()); + animator.setUpdateFPSFrames(60, System.err); + animator.add(glCanvas); + animator.start(); + } attachGLCanvas(applet1, glCanvas, false); + System.err.println("About to setVisible.0 CT "+Thread.currentThread().getName()); try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { + System.err.println("About to setVisible.1.0 CT "+Thread.currentThread().getName()); frame1.setVisible(true); + System.err.println("About to setVisible.1.X CT "+Thread.currentThread().getName()); }}); } catch (Throwable t) { t.printStackTrace(); Assume.assumeNoException(t); } + System.err.println("About to setVisible.X CT "+Thread.currentThread().getName()); final long sleep = 0 < restartPeriod ? restartPeriod : 100; long togo = durationPerTest; while( 0 < togo ) { + if(null == animator) { + glCanvas.display(); + } if(0 < restartPeriod) { - glCanvas = restart(applet1, glCanvas, restartOnCurrentThread); + glCanvas = restart(frame1, applet1, glCanvas, restartOnCurrentThread); } Thread.sleep(sleep); @@ -162,12 +196,30 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { } dispose(frame1, applet1); - animator.stop(); + if(null != animator) { + animator.stop(); + } gle1 = null; gle2 = null; } + int frameCount = 0; + + GLCanvas createGLCanvas() { + System.err.println("*** createGLCanvas.0"); + final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + // Iff using offscreen layer, use pbuffer, hence restore onscreen:=true. + // caps.setPBuffer(true); + // caps.setOnscreen(true); + final GLCanvas glCanvas = new GLCanvas(caps); + glCanvas.setBounds(0, 0, width, height); + Assert.assertNotNull(glCanvas); + System.err.println("*** createGLCanvas.X"); + frameCount = 0; + return glCanvas; + } + void dispose(final Frame frame, final Applet applet) { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -181,14 +233,14 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { } } - GLCanvas restart(final Applet frame, GLCanvas glCanvas, boolean restartOnCurrentThread) throws InterruptedException { + GLCanvas restart(final Frame frame, final Applet applet, GLCanvas glCanvas, boolean restartOnCurrentThread) throws InterruptedException { glCanvas.disposeGLEventListener(gle1, true); glCanvas.disposeGLEventListener(gle2, true); - detachGLCanvas(frame, glCanvas, restartOnCurrentThread); + detachGLCanvas(applet, glCanvas, restartOnCurrentThread); glCanvas = createGLCanvas(); - attachGLCanvas(frame, glCanvas, restartOnCurrentThread); + attachGLCanvas(applet, glCanvas, restartOnCurrentThread); glCanvas.addGLEventListener(gle1); glCanvas.addGLEventListener(gle2); @@ -226,7 +278,7 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - applet.remove(glCanvas); + applet.remove(glCanvas); applet.validate(); }}); } catch (Throwable t) { @@ -237,17 +289,6 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { System.err.println("*** detachGLCanvas.X"); } - int frameCount = 0; - - GLCanvas createGLCanvas() { - System.err.println("*** createGLCanvas.0"); - final GLCanvas glCanvas = new GLCanvas(); - glCanvas.setBounds(0, 0, width, height); - Assert.assertNotNull(glCanvas); - System.err.println("*** createGLCanvas.X"); - return glCanvas; - } - public static void main(String args[]) { for(int i=0; i Date: Mon, 5 Nov 2012 05:02:38 +0100 Subject: GLAutoDrawable: Refine API change of commit c002e04f848116922a1ed7bd96ead54961649bbd As suggested by Julien Gouesse, align 'enqueue(..)' method w/ 'invoke(..)': - public void enqueue(GLRunnable glRunnable); + public boolean invoke(boolean wait, List glRunnables); --- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 12 +++--- .../com/jogamp/opengl/util/GLDrawableUtil.java | 35 ++++++++-------- .../classes/javax/media/opengl/GLAutoDrawable.java | 32 +++++---------- .../classes/javax/media/opengl/awt/GLCanvas.java | 5 ++- .../classes/javax/media/opengl/awt/GLJPanel.java | 5 ++- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 5 ++- .../classes/jogamp/opengl/GLDrawableHelper.java | 47 +++++++++++++++++++++- .../acore/TestGLContextDrawableSwitchNEWT.java | 8 ++-- 9 files changed, 96 insertions(+), 57 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index cc9a330a5..3221deaab 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -267,7 +267,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* @@ -352,7 +352,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* # # swt (testswt) diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index ea794cc78..755a7c392 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -27,6 +27,8 @@ */ package com.jogamp.opengl.swt; +import java.util.List; + import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.ProxySurface; @@ -545,15 +547,15 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } @Override - public boolean invoke(final boolean wait, final GLRunnable run) { - return helper.invoke(this, wait, run); + public boolean invoke(final boolean wait, final GLRunnable runnable) { + return helper.invoke(this, wait, runnable); } @Override - public void enqueue(GLRunnable glRunnable) { - helper.enqueue(glRunnable); + public boolean invoke(final boolean wait, final List runnables) { + return helper.invoke(this, wait, runnables); } - + @Override public void setAnimator(final GLAnimatorControl arg0) throws GLException { helper.setAnimator(arg0); diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java index 08eaf0494..cc81e4820 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -27,6 +27,9 @@ */ package com.jogamp.opengl.util; +import java.util.ArrayList; +import java.util.List; + import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLContext; @@ -80,7 +83,7 @@ public class GLDrawableUtil { dest.addGLEventListener(listener); if(preserveInitState && initialized) { dest.setGLEventListenerInitState(listener, true); - dest.enqueue(new ReshapeGLEventListener(listener)); + dest.invoke(false, new ReshapeGLEventListener(listener)); } // else .. !init state is default } @@ -118,6 +121,8 @@ public class GLDrawableUtil { * @param b */ public static final void swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b) { + final List aGLCmds = new ArrayList(); + final List bGLCmds = new ArrayList(); final GLAnimatorControl aAnim = a.getAnimator(); final GLAnimatorControl bAnim = b.getAnimator(); final boolean aIsPaused = isAnimatorAnimatingOnOtherThread(aAnim) && aAnim.pause(); @@ -146,32 +151,30 @@ public class GLDrawableUtil { // // trigger glFinish to sync GL ctx // - a.enqueue(glFinish); - b.enqueue(glFinish); - a.display(); - b.display(); + a.invoke(true, glFinish); + b.invoke(true, glFinish); // // switch context and // trigger GL-Viewport reset and reshape of all initialized GLEventListeners // b.setContext( a.setContext( b.getContext() ) ); - a.enqueue(setViewport); - b.enqueue(setViewport); + aGLCmds.add(setViewport); + bGLCmds.add(setViewport); for(int i=0; i - * Unlike the {@link #invoke(boolean, GLRunnable)}, this method only enqueues the {@link GLRunnable} - * w/o taking care of it's execution. Hence either a performing {@link GLAnimatorControl animator} - * or explicit user call shall trigger {@link #display()} to ensure it's execution. - *

    - *

    - * Method return immediately w/o waiting or blocking - *

    - * - * @param glRunnable the {@link GLRunnable} to execute within the next {@link #display()} call - * - * @see #invoke(boolean, GLRunnable) - * @see #display() - * @see GLRunnable + * Extends {@link #invoke(boolean, GLRunnable)} functionality + * allowing to inject a list of {@link GLRunnable}s. + * @param wait if true block until execution of the last glRunnable is finished, otherwise return immediately w/o waiting + * @param glRunnables the {@link GLRunnable}s to execute within {@link #display()} + * @return true if the {@link GLRunnable}s has been processed or queued, otherwise false. */ - public void enqueue(GLRunnable glRunnable); - + public boolean invoke(boolean wait, List glRunnables); + /** Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext. If a window is attached to it's implementation, it shall be closed. diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 5b5f800a4..1d8666e6a 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -57,6 +57,7 @@ import java.awt.geom.Rectangle2D; import java.awt.EventQueue; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.List; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.OffscreenLayerOption; @@ -746,8 +747,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override - public void enqueue(GLRunnable glRunnable) { - helper.enqueue(glRunnable); + public boolean invoke(final boolean wait, final List glRunnables) { + return helper.invoke(this, wait, glRunnables); } @Override diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 08d70211b..58b1baa65 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -54,6 +54,7 @@ import java.awt.image.DataBufferInt; import java.beans.Beans; import java.nio.ByteBuffer; import java.nio.IntBuffer; +import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; @@ -483,8 +484,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void enqueue(GLRunnable glRunnable) { - helper.enqueue(glRunnable); + public boolean invoke(final boolean wait, final List glRunnables) { + return helper.invoke(this, wait, glRunnables); } @Override diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index 09a754279..7bcd37ecd 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -29,6 +29,7 @@ package jogamp.opengl; import java.io.PrintStream; +import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; @@ -412,8 +413,8 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } @Override - public final void enqueue(GLRunnable glRunnable) { - helper.enqueue(glRunnable); + public boolean invoke(final boolean wait, final List glRunnables) { + return helper.invoke(this, wait, glRunnables); } @Override diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index d891ae810..be63c9278 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -41,6 +41,7 @@ package jogamp.opengl; import java.util.ArrayList; +import java.util.List; import java.util.HashSet; import javax.media.nativewindow.NativeSurface; @@ -691,9 +692,9 @@ public class GLDrawableHelper { return false; } - Throwable throwable = null; GLRunnableTask rTask = null; Object rTaskLock = new Object(); + Throwable throwable = null; synchronized(rTaskLock) { final boolean deferred; synchronized(glRunnablesLock) { @@ -724,6 +725,50 @@ public class GLDrawableHelper { } return true; } + + public final boolean invoke(GLAutoDrawable drawable, boolean wait, List newGLRunnables) { + if( null == newGLRunnables || newGLRunnables.size() == 0 || null == drawable || + wait && ( !drawable.isRealized() || null==drawable.getContext() ) ) { + return false; + } + + final int count = newGLRunnables.size(); + GLRunnableTask rTask = null; + Object rTaskLock = new Object(); + Throwable throwable = null; + synchronized(rTaskLock) { + final boolean deferred; + synchronized(glRunnablesLock) { + deferred = isAnimatorAnimatingOnOtherThread(); + if(!deferred) { + wait = false; // don't wait if exec immediatly + } + for(int i=0; i Date: Tue, 6 Nov 2012 16:10:51 +0100 Subject: Fix GLDrawableHelper.recreateGLDrawable(..): Sync GL command stream before destruction of drawable Lack of finishing the GL command stream lead to a SIGSEGV on Windows w/ Nvidia driver where probably pending GL commands were still being processed concurrently. --- make/scripts/java-win64-dbg.bat | 4 ++-- make/scripts/java-win64.bat | 1 + make/scripts/tests-x64.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/jogl/classes/jogamp/opengl/GLDrawableHelper.java | 13 +++++++++---- 5 files changed, 16 insertions(+), 10 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 5dc34f42d..c7e8ea599 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -54,5 +54,5 @@ REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=false" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" -REM %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win64-dbg.log 2>&1 -%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* +%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win64-dbg.log 2>&1 +tail java-win64-dbg.log diff --git a/make/scripts/java-win64.bat b/make/scripts/java-win64.bat index 99f9bdcef..9dc1113a7 100755 --- a/make/scripts/java-win64.bat +++ b/make/scripts/java-win64.bat @@ -17,3 +17,4 @@ echo CP_ALL %CP_ALL% set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %X_ARGS% %* > java-win64.log 2>&1 +tail java-win64.log diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index e4aa11869..7dd00eabe 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -16,7 +16,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* @@ -112,7 +112,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3221deaab..e746f5e4c 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -266,8 +266,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index be63c9278..36dc933ab 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -173,12 +173,17 @@ public class GLDrawableHelper { if( ! drawable.isRealized() ) { return drawable; } - final boolean contextCurrent = null != context && context.isCurrent(); + final GLContext currentContext = GLContext.getCurrent(); final GLDrawableFactory factory = drawable.getFactory(); final NativeSurface surface = drawable.getNativeSurface(); final ProxySurface proxySurface = (surface instanceof ProxySurface) ? (ProxySurface)surface : null; - if(contextCurrent) { + if( null != context ) { + // Ensure to sync GL command stream + if( currentContext != context ) { + context.makeCurrent(); + } + context.getGL().glFinish(); context.release(); } @@ -199,8 +204,8 @@ public class GLDrawableHelper { context.setGLDrawable(drawable, true); // re-association } - if(contextCurrent) { - context.makeCurrent(); + if( null != currentContext ) { + currentContext.makeCurrent(); } return drawable; } -- cgit v1.2.3 From d0f91a8ed17fbb1a7b56511c4e53a29e576f01af Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 8 Nov 2012 18:07:19 +0100 Subject: Fix GLAutoDrawable.dispose(): Dispose drawable even w/o context; JAWTWindow.lockSurface(): Check AWT component's native peer - Fix GLAutoDrawable.dispose(): Dispose drawable even w/o context - It is possible to have the GLContext not being created (not made current), so drawable shall be disposed independent. - Merge Runnable 'postDisposeOnEDTAction' to dispose Runnable for clarity - GLDrawableHelper: Split disposeGL from invokeGLImpl for clarity - JAWTWindow.lockSurface(): Check AWT component's native peer - W/o a native peer (!isDisplayable()), JAWT locking cannot succeed. - On OSX OpenJDK 1.7, attempting to JAWT lock a peer-less component crashes the VM - MacOSXJAWTWindow.lockSurfaceImpl(): Remove redundant null checks --- make/scripts/tests-osx-x64-custom.sh | 9 + make/scripts/tests.sh | 23 +-- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 58 ++++--- .../classes/javax/media/opengl/awt/GLCanvas.java | 90 +++++----- .../classes/javax/media/opengl/awt/GLJPanel.java | 29 ++-- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 33 ++-- .../classes/jogamp/opengl/GLDrawableHelper.java | 181 ++++++++++----------- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 47 +++--- .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 40 ++--- .../awt/TestGLCanvasAWTActionDeadlock01AWT.java | 74 ++++++--- .../awt/TestGLCanvasAWTActionDeadlock02AWT.java | 51 ++++-- 11 files changed, 355 insertions(+), 280 deletions(-) create mode 100755 make/scripts/tests-osx-x64-custom.sh (limited to 'make/scripts') diff --git a/make/scripts/tests-osx-x64-custom.sh b/make/scripts/tests-osx-x64-custom.sh new file mode 100755 index 000000000..88587f086 --- /dev/null +++ b/make/scripts/tests-osx-x64-custom.sh @@ -0,0 +1,9 @@ +#! /bin/bash + +export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH + +spath=`dirname $0` + +. $spath/tests.sh "`which java`" -d64 ../build-macosx $* + + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index e746f5e4c..3add0371f 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -5,15 +5,15 @@ if [ -z "$1" -o -z "$2" -o -z "$3" ] ; then exit 0 fi -javaexe=$1 +javaexe="$1" shift javaxargs=$1 shift bdir=$1 shift -if [ ! -x $javaexe ] ; then - echo java-exe $javaexe is not an executable +if [ ! -x "$javaexe" ] ; then + echo java-exe "$javaexe" is not an executable exit 1 fi if [ ! -d $bdir ] ; then @@ -42,15 +42,15 @@ if [ $MOSX -eq 1 ] ; then MOSX_MT=1 fi -which $javaexe 2>&1 | tee -a java-run.log -$javaexe -version 2>&1 | tee -a java-run.log +which "$javaexe" 2>&1 | tee -a java-run.log +"$javaexe" -version 2>&1 | tee -a java-run.log echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a java-run.log echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a java-run.log echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a java-run.log echo LIBGL_ALWAYS_INDIRECT: $LIBGL_ALWAYS_INDIRECT 2>&1 | tee -a java-run.log echo LIBGL_ALWAYS_SOFTWARE: $LIBGL_ALWAYS_SOFTWARE 2>&1 | tee -a java-run.log echo SWT_CLASSPATH: $SWT_CLASSPATH 2>&1 | tee -a java-run.log -echo $javaexe $javaxargs $X_ARGS $D_ARGS $* 2>&1 | tee -a java-run.log +echo "$javaexe" $javaxargs $X_ARGS $D_ARGS $* 2>&1 | tee -a java-run.log echo MacOsX $MOSX function jrun() { @@ -209,13 +209,13 @@ function jrun() { echo echo LD_LIBRARY_PATH $LD_LIBRARY_PATH echo - echo $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* + echo "$javaexe" $javaxargs $X_ARGS $D_ARGS $C_ARG $* #LIBGL_DRIVERS_PATH=/usr/lib/mesa:/usr/lib32/mesa \ #LIBGL_DEBUG=verbose INTEL_STRICT_CONFORMANCE=1 INTEL_DEBUG="buf bat" \ #LIBGL_DEBUG=verbose MESA_DEBUG=true INTEL_STRICT_CONFORMANCE=1 \ #export LIBGL_DEBUG=verbose MESA_DEBUG=true LIBGL_ALWAYS_SOFTWARE=true - #gdb --args $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* - $javaexe $javaxargs $X_ARGS $D_ARGS $C_ARG $* + #gdb --args "$javaexe" $javaxargs $X_ARGS $D_ARGS $C_ARG $* + "$javaexe" $javaxargs $X_ARGS $D_ARGS $C_ARG $* echo echo "Test End: $*" echo @@ -266,7 +266,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* @@ -285,6 +285,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOf #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* + #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* @@ -351,7 +352,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOf #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* # diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 755a7c392..e80079c20 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -173,45 +173,49 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* * Disposes of OpenGL resources */ - private final Runnable postDisposeGLAction = new Runnable() { - @Override - public void run() { - context = null; - if (null != drawable) { - drawable.setRealized(false); - drawable = null; - } - } - }; - private final Runnable disposeOnEDTGLAction = new Runnable() { @Override public void run() { final RecursiveLock _lock = lock; _lock.lock(); try { - if (null != drawable && null != context) { - boolean animatorPaused = false; - final GLAnimatorControl animator = getAnimator(); - if (null != animator) { - animatorPaused = animator.pause(); - } - - if(context.isCreated()) { - helper.disposeGL(GLCanvas.this, drawable, context, postDisposeGLAction); - } - - if (animatorPaused) { - animator.resume(); - } + final GLAnimatorControl animator = getAnimator(); + final boolean animatorPaused; + if(null!=animator) { + // can't remove us from animator for recreational addNotify() + animatorPaused = animator.pause(); + } else { + animatorPaused = false; + } + + if ( null != context ) { + if( context.isCreated() ) { + // Catch dispose GLExceptions by GLEventListener, just 'print' them + // so we can continue with the destruction. + try { + helper.disposeGL(GLCanvas.this, context); + } catch (GLException gle) { + gle.printStackTrace(); + } + } + context = null; + } + if ( null != drawable ) { + drawable.setRealized(false); + drawable = null; } // SWT is owner of the device handle, not us. // Hence close() operation is a NOP. if (null != device) { - device.close(); - device = null; + device.close(); + device = null; } SWTAccessor.setRealized(GLCanvas.this, false); // unrealize .. + + if (animatorPaused) { + animator.resume(); + } + } finally { _lock.unlock(); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 1d8666e6a..a40cdcf88 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -888,33 +888,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // private boolean disposeRegenerate; - private final Runnable postDisposeOnEDTAction = new Runnable() { - @Override - public void run() { - context=null; - if(null!=drawable) { - drawable.setRealized(false); - drawable=null; - if(null!=jawtWindow) { - jawtWindow.destroy(); - jawtWindow=null; - } - } - - if(disposeRegenerate) { - // Similar process as in addNotify()! - - // Recreate GLDrawable/GLContext to reflect it's new graphics configuration - createDrawableAndContext(); - - if(DEBUG) { - System.err.println(getThreadName()+": GLCanvas.dispose(true): new drawable: "+drawable); - } - validateGLDrawable(); // immediate attempt to recreate the drawable - } - } - }; - private final Runnable disposeOnEDTAction = new Runnable() { @Override public void run() { @@ -929,31 +902,64 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing Thread.dumpStack(); } - if(null!=drawable && null!=context) { - boolean animatorPaused = false; - if(null!=animator) { - // can't remove us from animator for recreational addNotify() - animatorPaused = animator.pause(); - } - - if(context.isCreated()) { - helper.disposeGL(GLCanvas.this, drawable, context, postDisposeOnEDTAction); + final boolean animatorPaused; + if(null!=animator) { + // can't remove us from animator for recreational addNotify() + animatorPaused = animator.pause(); + } else { + animatorPaused = false; + } + + if( null != context ) { + if( context.isCreated() ) { + // Catch dispose GLExceptions by GLEventListener, just 'print' them + // so we can continue with the destruction. + try { + helper.disposeGL(GLCanvas.this, context); + } catch (GLException gle) { + gle.printStackTrace(); + } + } + context=null; + } + if( null != drawable ) { + drawable.setRealized(false); + if(DEBUG) { + System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - 1: "+drawable); } - - if(animatorPaused) { - animator.resume(); + drawable=null; + } + if( null != jawtWindow ) { + jawtWindow.destroy(); + if(DEBUG) { + System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - 2: "+jawtWindow); } + jawtWindow=null; } - - if(!disposeRegenerate) { + + if(disposeRegenerate) { + // Similar process as in addNotify()! + + // Recreate GLDrawable/GLContext to reflect it's new graphics configuration + createDrawableAndContext(); + + if(DEBUG) { + System.err.println(getThreadName()+": GLCanvas.dispose(true): new drawable: "+drawable); + } + validateGLDrawable(); // immediate attempt to recreate the drawable + } else { if(null != awtConfig) { AWTEDTExecutor.singleton.invoke(getTreeLock(), true, disposeAbstractGraphicsDeviceActionOnEDT); } awtConfig=null; } + if(animatorPaused) { + animator.resume(); + } + if(DEBUG) { - System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - END, "+animator); + System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - END, animator "+animator); } } finally { diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 58b1baa65..dcfc1f0dd 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -757,21 +757,26 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return "AWT-GLJPanel[ "+((null!=backend)?backend.getDrawable().getClass().getName():"null-drawable")+"]"; } - private final Runnable postDisposeAction = new Runnable() { - @Override - public void run() { - if (backend != null && !backend.isUsingOwnThreadManagment()) { - backend.destroy(); - backend = null; - isInitialized = false; - } - } - }; - private final Runnable disposeAction = new Runnable() { @Override public void run() { - helper.disposeGL(GLJPanel.this, backend.getDrawable(), backend.getContext(), postDisposeAction); + if ( null != backend ) { + final GLContext _context = backend.getContext(); + if( null != _context && _context.isCreated() ) { + // Catch dispose GLExceptions by GLEventListener, just 'print' them + // so we can continue with the destruction. + try { + helper.disposeGL(GLJPanel.this, _context); + } catch (GLException gle) { + gle.printStackTrace(); + } + } + if ( !backend.isUsingOwnThreadManagment() ) { + backend.destroy(); + backend = null; + isInitialized = false; + } + } } }; diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index 7bcd37ecd..68fbe3dd5 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -223,27 +223,26 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { * In such case call super.destroyImplInLock first.

    */ protected void destroyImplInLock() { - final GLContext _context = context; - final GLDrawable _drawable = drawable; - if( null != _drawable ) { - if( _drawable.isRealized() ) { - if( null != _context && _context.isCreated() ) { - // Catch dispose GLExceptions by GLEventListener, just 'print' them - // so we can continue with the destruction. - try { - helper.disposeGL(this, _drawable, _context, null); - } catch (GLException gle) { - gle.printStackTrace(); - } + if( null != context ) { + if( context.isCreated() ) { + // Catch dispose GLExceptions by GLEventListener, just 'print' them + // so we can continue with the destruction. + try { + helper.disposeGL(this, context); + } catch (GLException gle) { + gle.printStackTrace(); } - _drawable.setRealized(false); } + context = null; + } + if( null != drawable ) { + final AbstractGraphicsDevice device = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); + drawable.setRealized(false); + drawable = null; if( ownsDevice ) { - _drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice().close(); + device.close(); } - } - context = null; - drawable = null; + } } public final void defaultSwapBuffers() throws GLException { diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 36dc933ab..f7f846b05 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -397,8 +397,8 @@ public class GLDrawableHelper { * otherwise maked uninitialized. *

    *

    - * Please consider using {@link #disposeAllGLEventListener(GLAutoDrawable, GLDrawable, GLContext)} - * or {@link #disposeGL(GLAutoDrawable, GLDrawable, GLContext, Runnable)} + * Please consider using {@link #disposeAllGLEventListener(GLAutoDrawable, GLContext, boolean)} + * or {@link #disposeGL(GLAutoDrawable, GLContext)} * for correctness, i.e. encapsulating all calls w/ makeCurrent etc. *

    * @param autoDrawable @@ -483,8 +483,7 @@ public class GLDrawableHelper { * * @param autoDrawable * @param context - * @param listener - * @param initAction + * @param remove */ public final void disposeAllGLEventListener(final GLAutoDrawable autoDrawable, final GLDrawable drawable, @@ -505,29 +504,6 @@ public class GLDrawableHelper { } } - /** - * Principal helper method which runs - * {@link #disposeAllGLEventListener(GLAutoDrawable, boolean) disposeAllGLEventListener(autoDrawable, false)} - * with the context made current and destroys the context afterwards while holding the lock. - * @param autoDrawable - * @param drawable - * @param context - * @param postAction - */ - public final void disposeGL(final GLAutoDrawable autoDrawable, - final GLDrawable drawable, - final GLContext context, - final Runnable postAction) { - if(PERF_STATS) { - invokeGLImplStats(drawable, context, null, null, autoDrawable); - } else { - invokeGLImpl(drawable, context, null, null, autoDrawable); - } - if(null != postAction) { - postAction.run(); - } - } - private final void init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape) { l.init(drawable); if(sendReshape) { @@ -842,21 +818,66 @@ public class GLDrawableHelper { } if(PERF_STATS) { - invokeGLImplStats(drawable, context, runnable, initAction, null); + invokeGLImplStats(drawable, context, runnable, initAction); } else { - invokeGLImpl(drawable, context, runnable, initAction, null); + invokeGLImpl(drawable, context, runnable, initAction); } } + /** + * Principal helper method which runs + * {@link #disposeAllGLEventListener(GLAutoDrawable, boolean) disposeAllGLEventListener(autoDrawable, false)} + * with the context made current and destroys the context afterwards while holding the lock. + * @param autoDrawable + * @param context + */ + public final void disposeGL(final GLAutoDrawable autoDrawable, + final GLContext context) { + // Support for recursive makeCurrent() calls as well as calling + // other drawables' display() methods from within another one's + GLContext lastContext = GLContext.getCurrent(); + Runnable lastInitAction = null; + if (lastContext != null) { + if (lastContext == context) { + lastContext = null; // utilize recursive locking + } else { + lastInitAction = perThreadInitAction.get(); + lastContext.release(); + } + } + int res = GLContext.CONTEXT_NOT_CURRENT; + + try { + res = context.makeCurrent(); + if (GLContext.CONTEXT_NOT_CURRENT != res) { + if(GLContext.CONTEXT_CURRENT_NEW == res) { + throw new GLException(Thread.currentThread().getName()+" GLDrawableHelper " + this + ".invokeGL(): Dispose case (no init action given): Native context was not created (new ctx): "+context); + } + if( listeners.size() > 0 && null != autoDrawable ) { + disposeAllGLEventListener(autoDrawable, false); + } + } + } finally { + try { + context.destroy(); + flushGLRunnables(); + } catch (Exception e) { + System.err.println("Catched: "+e.getMessage()); + e.printStackTrace(); + } + if (lastContext != null) { + final int res2 = lastContext.makeCurrent(); + if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { + lastInitAction.run(); + } + } + } + } + private final void invokeGLImpl(final GLDrawable drawable, final GLContext context, final Runnable runnable, - final Runnable initAction, - final GLAutoDrawable disposeAutoDrawable) { - final Thread currentThread = Thread.currentThread(); - - final boolean isDisposeAction = null==initAction ; - + final Runnable initAction) { // Support for recursive makeCurrent() calls as well as calling // other drawables' display() methods from within another one's GLContext lastContext = GLContext.getCurrent(); @@ -874,35 +895,21 @@ public class GLDrawableHelper { try { res = context.makeCurrent(); if (GLContext.CONTEXT_NOT_CURRENT != res) { - if(!isDisposeAction) { - perThreadInitAction.set(initAction); - if (GLContext.CONTEXT_CURRENT_NEW == res) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); - } - initAction.run(); - } - runnable.run(); - if (autoSwapBufferMode) { - drawable.swapBuffers(); - } - } else { - if(GLContext.CONTEXT_CURRENT_NEW == res) { - throw new GLException(currentThread.getName()+" GLDrawableHelper " + this + ".invokeGL(): Dispose case (no init action given): Native context was not created (new ctx): "+context); - } - if( listeners.size() > 0 && null != disposeAutoDrawable ) { - disposeAllGLEventListener(disposeAutoDrawable, false); - } + perThreadInitAction.set(initAction); + if (GLContext.CONTEXT_CURRENT_NEW == res) { + if (DEBUG) { + System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); + } + initAction.run(); + } + runnable.run(); + if ( autoSwapBufferMode ) { + drawable.swapBuffers(); } } } finally { try { - if(isDisposeAction) { - context.destroy(); - flushGLRunnables(); - } else if( GLContext.CONTEXT_NOT_CURRENT != res ) { - context.release(); - } + context.release(); } catch (Exception e) { System.err.println("Catched: "+e.getMessage()); e.printStackTrace(); @@ -919,12 +926,9 @@ public class GLDrawableHelper { private final void invokeGLImplStats(final GLDrawable drawable, final GLContext context, final Runnable runnable, - final Runnable initAction, - final GLAutoDrawable disposeAutoDrawable) { + final Runnable initAction) { final Thread currentThread = Thread.currentThread(); - final boolean isDisposeAction = null==initAction ; - // Support for recursive makeCurrent() calls as well as calling // other drawables' display() methods from within another one's int res = GLContext.CONTEXT_NOT_CURRENT; @@ -956,41 +960,28 @@ public class GLDrawableHelper { ctxClaimed = true; } if (res != GLContext.CONTEXT_NOT_CURRENT) { - if(!isDisposeAction) { - perThreadInitAction.set(initAction); - if (res == GLContext.CONTEXT_CURRENT_NEW) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); - } - initAction.run(); - } - tdR = System.currentTimeMillis(); - tdA = tdR - t0; // makeCurrent - runnable.run(); - tdS = System.currentTimeMillis(); - tdR = tdS - tdR; // render time - if (autoSwapBufferMode) { - drawable.swapBuffers(); - tdX = System.currentTimeMillis(); - tdS = tdX - tdS; // swapBuffers - } - } else { - if(res == GLContext.CONTEXT_CURRENT_NEW) { - throw new GLException(currentThread.getName()+" GLDrawableHelper " + this + ".invokeGL(): Dispose case (no init action given): Native context was not created (new ctx): "+context); - } - if( listeners.size() > 0 && null != disposeAutoDrawable ) { - disposeAllGLEventListener(disposeAutoDrawable, false); - } + perThreadInitAction.set(initAction); + if (res == GLContext.CONTEXT_CURRENT_NEW) { + if (DEBUG) { + System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); + } + initAction.run(); + } + tdR = System.currentTimeMillis(); + tdA = tdR - t0; // makeCurrent + runnable.run(); + tdS = System.currentTimeMillis(); + tdR = tdS - tdR; // render time + if (autoSwapBufferMode) { + drawable.swapBuffers(); + tdX = System.currentTimeMillis(); + tdS = tdX - tdS; // swapBuffers } } } finally { try { - if(isDisposeAction) { - context.destroy(); - flushGLRunnables(); - ctxDestroyed = true; - } else if( res != GLContext.CONTEXT_NOT_CURRENT && - (null == skipContextReleaseThread || currentThread != skipContextReleaseThread) ) { + if( res != GLContext.CONTEXT_NOT_CURRENT && + (null == skipContextReleaseThread || currentThread != skipContextReleaseThread) ) { context.release(); ctxReleased = true; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 35c919f28..8527a0200 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -320,32 +320,41 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, int res = surfaceLock.getHoldCount() == 1 ? LOCK_SURFACE_NOT_READY : LOCK_SUCCESS; // new lock ? if ( LOCK_SURFACE_NOT_READY == res ) { - determineIfApplet(); - try { - final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); - adevice.lock(); + if( !component.isDisplayable() ) { + // W/o native peer, we cannot utilize JAWT for locking. + surfaceLock.unlock(); + if(DEBUG) { + System.err.println("JAWTWindow: Can't lock surface, component peer n/a. Component displayable "+component.isDisplayable()+", "+component); + Thread.dumpStack(); + } + } else { + determineIfApplet(); try { - if(null == jawt) { // no need to re-fetch for each frame - jawt = fetchJAWTImpl(); - isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt); - } - res = lockSurfaceImpl(); - if(LOCK_SUCCESS == res && drawable_old != drawable) { - res = LOCK_SURFACE_CHANGED; - if(DEBUG) { - System.err.println("JAWTWindow: surface change 0x"+Long.toHexString(drawable_old)+" -> 0x"+Long.toHexString(drawable)); - // Thread.dumpStack(); + final AbstractGraphicsDevice adevice = getGraphicsConfiguration().getScreen().getDevice(); + adevice.lock(); + try { + if(null == jawt) { // no need to re-fetch for each frame + jawt = fetchJAWTImpl(); + isOffscreenLayerSurface = JAWTUtil.isJAWTUsingOffscreenLayer(jawt); + } + res = lockSurfaceImpl(); + if(LOCK_SUCCESS == res && drawable_old != drawable) { + res = LOCK_SURFACE_CHANGED; + if(DEBUG) { + System.err.println("JAWTWindow: surface change 0x"+Long.toHexString(drawable_old)+" -> 0x"+Long.toHexString(drawable)); + // Thread.dumpStack(); + } + } + } finally { + if (LOCK_SURFACE_NOT_READY >= res) { + adevice.unlock(); } } } finally { if (LOCK_SURFACE_NOT_READY >= res) { - adevice.unlock(); + surfaceLock.unlock(); } } - } finally { - if (LOCK_SURFACE_NOT_READY >= res) { - surfaceLock.unlock(); - } } } return res; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 5fd242247..449121be1 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -119,13 +119,11 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SURFACE_NOT_READY; - if(null == ds) { - ds = getJAWT().GetDrawingSurface(component); - if (ds == null) { - // Widget not yet realized - unlockSurfaceImpl(); - return NativeWindow.LOCK_SURFACE_NOT_READY; - } + ds = getJAWT().GetDrawingSurface(component); + if (ds == null) { + // Widget not yet realized + unlockSurfaceImpl(); + return NativeWindow.LOCK_SURFACE_NOT_READY; } int res = ds.Lock(); dsLocked = ( 0 == ( res & JAWTFactory.JAWT_LOCK_ERROR ) ) ; @@ -141,21 +139,19 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if ((res & JAWTFactory.JAWT_LOCK_SURFACE_CHANGED) != 0) { ret = NativeWindow.LOCK_SURFACE_CHANGED; } - if(null == dsi) { - if (firstLock) { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - dsi = ds.GetDrawingSurfaceInfo(); - return null; - } - }); - } else { - dsi = ds.GetDrawingSurfaceInfo(); - } - if (dsi == null) { - unlockSurfaceImpl(); - return NativeWindow.LOCK_SURFACE_NOT_READY; - } + if (firstLock) { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + dsi = ds.GetDrawingSurfaceInfo(); + return null; + } + }); + } else { + dsi = ds.GetDrawingSurfaceInfo(); + } + if (dsi == null) { + unlockSurfaceImpl(); + return NativeWindow.LOCK_SURFACE_NOT_READY; } updateBounds(dsi.getBounds()); if (DEBUG && firstLock ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java index c2b6f1551..c51972c39 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock01AWT.java @@ -33,6 +33,9 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; + +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.VersionNumber; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.AnimatorBase; import com.jogamp.opengl.util.FPSAnimator; @@ -53,7 +56,21 @@ import org.junit.Assert; import org.junit.Assume; import org.junit.Test; - +/** + * BUG on OSX/CALayer w/ Java6: + * If frame.setTitle() is issued right after initialization the call hangs in + *
     
    + * at apple.awt.CWindow._setTitle(Native Method)
    + *  at apple.awt.CWindow.setTitle(CWindow.java:765) [1.6.0_37, build 1.6.0_37-b06-434-11M3909]
    + * 
    + *

    + * OSX/CALayer is forced by using an Applet component in this unit test. + *

    + *

    + * Similar deadlock has been experienced w/ other mutable operation on an AWT Container owning a GLCanvas child, + * e.g. setResizable*(). + *

    + */ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { static long durationPerTest = 1000; // ms static final int width = 512; @@ -87,6 +104,14 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { public void test02FPSAnimator_RestartOnCurrentThread() throws InterruptedException { testImpl(new FPSAnimator(30), 200, true); } */ + + private static void setFrameTitle(Frame frame, String msg) { + System.err.println("About to setTitle: <"+msg+"> CT "+Thread.currentThread().getName()+", "+ + frame+", displayable "+frame.isDisplayable()+ + ", valid "+frame.isValid()+", visible "+frame.isVisible()); + // Thread.dumpStack(); + frame.setTitle(msg); + } void testImpl(final AnimatorBase animator, int restartPeriod, boolean restartOnCurrentThread) throws InterruptedException { final Frame frame1 = new Frame("Frame 1"); @@ -94,6 +119,13 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { private static final long serialVersionUID = 1L; }; + final VersionNumber version170 = new VersionNumber(1, 7, 0); + final boolean osxCALayerAWTModBug = Platform.OSType.MACOS == Platform.getOSType() && + 0 > Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + Assert.assertNotNull(frame1); frame1.setLayout(null); frame1.pack(); @@ -109,7 +141,7 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { frame1.setLocation(0, 0); frame1.setTitle("Generic Title"); frame1.add(applet1); - + frame1.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(frame1, applet1); @@ -122,34 +154,36 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { @Override public void init(GLAutoDrawable drawable) { justInitialized = true; + if( !osxCALayerAWTModBug ) { + System.err.println("*Init*: CT "+Thread.currentThread().getName()); + setFrameTitle(frame1, "INIT"); + frame1.setResizable(false); + } } @Override public void dispose(GLAutoDrawable drawable) { + System.err.println("*Dispose*: CT "+Thread.currentThread().getName()); + setFrameTitle(frame1, "DISPOSE"); } @Override public void display(GLAutoDrawable drawable) { - if(!justInitialized) { - // BUG on OSX/CALayer: If frame.setTitle() is issued right after initialization - // the call hangs in - // at apple.awt.CWindow._setTitle(Native Method) - // at apple.awt.CWindow.setTitle(CWindow.java:765) [1.6.0_37, build 1.6.0_37-b06-434-11M3909] - // - final String msg = "f "+frameCount+", fps "+( null != animator ? animator.getLastFPS() : 0); - System.err.println("About to setTitle: CT "+Thread.currentThread().getName()+", "+msg+ - frame1+", displayable "+frame1.isDisplayable()+ - ", valid "+frame1.isValid()+", visible "+frame1.isVisible()); - // Thread.dumpStack(); - frame1.setTitle(msg); - + if( !osxCALayerAWTModBug || !justInitialized ) { + System.err.println("*Display*: CT "+Thread.currentThread().getName()); + setFrameTitle(frame1, "f "+frameCount+", fps "+( null != animator ? animator.getLastFPS() : 0)); + frame1.setResizable(false); } frameCount++; - justInitialized=false; + justInitialized = false; } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + if( !osxCALayerAWTModBug || !justInitialized ) { + System.err.println("*Reshape*: CT "+Thread.currentThread().getName()); + setFrameTitle(frame1, "RESHAPE"); + } } }; gle2 = new GearsES2(); @@ -188,7 +222,7 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { glCanvas.display(); } if(0 < restartPeriod) { - glCanvas = restart(frame1, applet1, glCanvas, restartOnCurrentThread); + glCanvas = restart(applet1, glCanvas, restartOnCurrentThread); } Thread.sleep(sleep); @@ -234,7 +268,7 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { } } - GLCanvas restart(final Frame frame, final Applet applet, GLCanvas glCanvas, boolean restartOnCurrentThread) throws InterruptedException { + GLCanvas restart(final Applet applet, GLCanvas glCanvas, boolean restartOnCurrentThread) throws InterruptedException { glCanvas.disposeGLEventListener(gle1, true); glCanvas.disposeGLEventListener(gle2, true); detachGLCanvas(applet, glCanvas, restartOnCurrentThread); @@ -253,7 +287,7 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { if( restartOnCurrentThread ) { applet.setLayout(new BorderLayout()); applet.add(glCanvas, BorderLayout.CENTER); - applet.validate(); + applet.validate(); } else { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -274,7 +308,7 @@ public class TestGLCanvasAWTActionDeadlock01AWT extends UITestCase { System.err.println("*** detachGLCanvas.0 on-current-thread "+restartOnCurrentThread+", currentThread "+Thread.currentThread().getName()); if( restartOnCurrentThread ) { applet.remove(glCanvas); - applet.validate(); + applet.validate(); } else { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java index a74286232..d8f25868b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java @@ -53,12 +53,31 @@ import javax.media.opengl.awt.GLCanvas; import org.junit.Assume; import org.junit.Test; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.VersionNumber; import com.jogamp.opengl.util.AnimatorBase; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; -// Sample program that relies on JOGL's mechanism to handle the OpenGL context -// and rendering loop when using an AWT canvas attached to an Applet. +/** + * Sample program that relies on JOGL's mechanism to handle the OpenGL context + * and rendering loop when using an AWT canvas attached to an Applet. + *

    + * BUG on OSX/CALayer w/ Java6: + * If frame.setTitle() is issued right after initialization the call hangs in + *

     
    + * at apple.awt.CWindow._setTitle(Native Method)
    + *  at apple.awt.CWindow.setTitle(CWindow.java:765) [1.6.0_37, build 1.6.0_37-b06-434-11M3909]
    + * 
    + *

    + *

    + * OSX/CALayer is forced by using an Applet component in this unit test. + *

    + *

    + * Similar deadlock has been experienced w/ other mutable operation on an AWT Container owning a GLCanvas child, + * e.g. setResizable*(). + *

    + */ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { static int framesPerTest = 240; // frames @@ -109,7 +128,9 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { private long frameRatePeriod = 1000000000L / frameRate; private boolean initialized = false; - + private boolean osxCALayerAWTModBug = false; + boolean justInitialized = true; + private double theta = 0; private double s = 0; private double c = 0; @@ -161,6 +182,13 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { millisOffset = System.currentTimeMillis(); + final VersionNumber version170 = new VersionNumber(1, 7, 0); + osxCALayerAWTModBug = Platform.OSType.MACOS == Platform.getOSType() && + 0 > Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + // Frame setup ---------------------------------------------------------- width = 300; @@ -328,16 +356,9 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { }}); } } - - boolean justInitialized = true; - + void draw(GL2 gl) { - if(!justInitialized) { - // BUG on OSX/CALayer: If frame.setTitle() is issued right after initialization - // the call hangs in - // at apple.awt.CWindow._setTitle(Native Method) - // at apple.awt.CWindow.setTitle(CWindow.java:765) [1.6.0_37, build 1.6.0_37-b06-434-11M3909] - // + if( !osxCALayerAWTModBug || !justInitialized ) { frame.setTitle("frame " + frameCount); } @@ -441,15 +462,15 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { class SimpleListener implements GLEventListener { @Override public void display(GLAutoDrawable drawable) { - draw(drawable.getGL().getGL2()); - justInitialized = false; + draw(drawable.getGL().getGL2()); + justInitialized = false; } @Override public void dispose(GLAutoDrawable drawable) { } @Override - public void init(GLAutoDrawable drawable) { + public void init(GLAutoDrawable drawable) { justInitialized = true; } -- cgit v1.2.3 From a2bc4bcf26ce392d892c8cba5071d3f3877ed0c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 11 Nov 2012 08:26:10 +0100 Subject: PMVMatrix: Add 'Frustum glGetFrustum()' adding same dirty/request methodology as for Mvi and Mvit Allows user to derive Frustum from updated P + MV Clarify method name for clearing all update request: - disableMviMvitUpdate() -> clearAllUpdateRequests() --- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/opengl/util/PMVMatrix.java | 139 ++++++++++++--------- .../test/junit/jogl/acore/TestPMVMatrix01NEWT.java | 42 +++++-- 3 files changed, 116 insertions(+), 69 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3add0371f..621b61c6f 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -250,7 +250,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* @@ -352,7 +352,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* # diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index 1628e0a8e..18129ba09 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -49,6 +49,7 @@ import jogamp.opengl.ProjectFloat; import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.Platform; import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.math.geom.Frustum; /** * PMVMatrix implements a subset of the fixed function pipeline @@ -57,7 +58,8 @@ import com.jogamp.opengl.math.FloatUtil; *

    * Further more, PMVMatrix provides the {@link #glGetMviMatrixf() inverse modelview matrix (Mvi)} and * {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}. - * To keep both synchronized after mutable Mv operations like {@link #glRotatef(float, float, float, float) glRotatef(..)} + * {@link Frustum} is also provided by {@link #glGetFrustum()}. + * To keep these derived values synchronized after mutable Mv operations like {@link #glRotatef(float, float, float, float) glRotatef(..)} * in {@link #glMatrixMode(int) glMatrixMode}({@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}), * users have to call {@link #update()} before using Mvi and Mvit. *

    @@ -100,8 +102,10 @@ public class PMVMatrix implements GLMatrixFunc { public static final int DIRTY_INVERSE_MODELVIEW = 1 << 0; /** Bit value stating a dirty {@link #glGetMvitMatrixf() inverse transposed modelview matrix (Mvit)}. */ public static final int DIRTY_INVERSE_TRANSPOSED_MODELVIEW = 1 << 1; + /** Bit value stating a dirty {@link #glGetFrustum() frustum}. */ + public static final int DIRTY_FRUSTUM = 1 << 2; /** Bit value stating all is dirty */ - public static final int DIRTY_ALL = DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + public static final int DIRTY_ALL = DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM; /** * @param matrixModeName One of {@link GLMatrixFunc#GL_MODELVIEW GL_MODELVIEW}, {@link GLMatrixFunc#GL_PROJECTION GL_PROJECTION} or {@link GL#GL_TEXTURE GL_TEXTURE} @@ -270,6 +274,9 @@ public class PMVMatrix implements GLMatrixFunc { dirtyBits = DIRTY_ALL; requestMask = 0; matrixMode = GL_MODELVIEW; + + mulPMV = null; + frustum = null; } /** @see #PMVMatrix(boolean) */ @@ -351,7 +358,7 @@ public class PMVMatrix implements GLMatrixFunc { * See {@link #update()} and matrix storage details. *

    * @see #update() - * @see #disableMviMvitUpdate() + * @see #clearAllUpdateRequests() */ public final FloatBuffer glGetMviMatrixf() { requestMask |= DIRTY_INVERSE_MODELVIEW ; @@ -368,7 +375,7 @@ public class PMVMatrix implements GLMatrixFunc { * See {@link #update()} and matrix storage details. *

    * @see #update() - * @see #disableMviMvitUpdate() + * @see #clearAllUpdateRequests() */ public final FloatBuffer glGetMvitMatrixf() { requestMask |= DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; @@ -386,26 +393,6 @@ public class PMVMatrix implements GLMatrixFunc { return matrixPMv; } - /** - * @param d a 4*4 float array to hold the pre-multiplied P*MV - * @param d_off offset of d - * @return the pre-multiplied P*MV, param d - */ - public float[] getPreMultipliedPMV(float[] d, int d_off) { - FloatUtil.multMatrixf(matrixP, matrixMv, d, d_off); - return d; - } - - /** - * @param d a 4*4 FloatBuffer to hold the premultiplied P*MV - * @param d_off offset of d - * @return the pre-multiplied P*MV, param d - */ - public FloatBuffer getPreMultipliedPMV(FloatBuffer d) { - FloatUtil.multMatrixf(matrixP, matrixMv, d); - return d; - } - /** * Returns 3 matrices within one FloatBuffer: {@link #glGetPMatrixf() P}, {@link #glGetMvMatrixf() Mv} and {@link #glGetMviMatrixf() Mvi}. *

    @@ -415,7 +402,7 @@ public class PMVMatrix implements GLMatrixFunc { * See {@link #update()} and matrix storage details. *

    * @see #update() - * @see #disableMviMvitUpdate() + * @see #clearAllUpdateRequests() */ public final FloatBuffer glGetPMvMviMatrixf() { requestMask |= DIRTY_INVERSE_MODELVIEW ; @@ -432,7 +419,7 @@ public class PMVMatrix implements GLMatrixFunc { * See {@link #update()} and matrix storage details. *

    * @see #update() - * @see #disableMviMvitUpdate() + * @see #clearAllUpdateRequests() */ public final FloatBuffer glGetPMvMvitMatrixf() { requestMask |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; @@ -440,6 +427,13 @@ public class PMVMatrix implements GLMatrixFunc { return matrixPMvMvit; } + /** Returns the frustum, derived from projection * modelview */ + public Frustum glGetFrustum() { + requestMask |= DIRTY_FRUSTUM; + updateImpl(false); + return frustum; + } + /* * @return the matrix of the current matrix-mode */ @@ -537,11 +531,12 @@ public class PMVMatrix implements GLMatrixFunc { if(matrixMode==GL_MODELVIEW) { matrixMv.put(values, offset, len); matrixMv.reset(); - dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { matrixP.put(values, offset, len); matrixP.reset(); + dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(values, offset, len); @@ -556,11 +551,12 @@ public class PMVMatrix implements GLMatrixFunc { if(matrixMode==GL_MODELVIEW) { matrixMv.put(m); matrixMv.reset(); - dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { matrixP.put(m); matrixP.reset(); + dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(m); @@ -606,12 +602,13 @@ public class PMVMatrix implements GLMatrixFunc { if(matrixMode==GL_MODELVIEW) { matrixMv.put(matrixIdent); matrixMv.reset(); - dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { matrixP.put(matrixIdent); matrixP.reset(); - modifiedBits |= MODIFIED_PROJECTION; + dirtyBits |= DIRTY_FRUSTUM ; + modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { matrixTex.put(matrixIdent); matrixTex.reset(); @@ -624,10 +621,11 @@ public class PMVMatrix implements GLMatrixFunc { public final void glMultMatrixf(final FloatBuffer m) { if(matrixMode==GL_MODELVIEW) { FloatUtil.multMatrixf(matrixMv, m, matrixMv); - dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { FloatUtil.multMatrixf(matrixP, m, matrixP); + dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { FloatUtil.multMatrixf(matrixTex, m, matrixTex); @@ -639,10 +637,11 @@ public class PMVMatrix implements GLMatrixFunc { public final void glMultMatrixf(float[] m, int m_offset) { if(matrixMode==GL_MODELVIEW) { FloatUtil.multMatrixf(matrixMv, m, m_offset, matrixMv); - dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW ; + dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { FloatUtil.multMatrixf(matrixP, m, m_offset, matrixP); + dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { FloatUtil.multMatrixf(matrixTex, m, m_offset, matrixTex); @@ -840,9 +839,9 @@ public class PMVMatrix implements GLMatrixFunc { * @param obj_pos_offset * @return */ - public boolean gluUnProject(float winx, float winy, float winz, - int[] viewport, int viewport_offset, - float[] obj_pos, int obj_pos_offset) { + public final boolean gluUnProject(float winx, float winy, float winz, + int[] viewport, int viewport_offset, + float[] obj_pos, int obj_pos_offset) { if(usesBackingArray) { return projectFloat.gluUnProject(winx, winy, winz, matrixMv.array(), 0, @@ -870,15 +869,17 @@ public class PMVMatrix implements GLMatrixFunc { } final boolean mviDirty = 0 != (DIRTY_INVERSE_MODELVIEW & dirtyBits); final boolean mvitDirty = 0 != (DIRTY_INVERSE_TRANSPOSED_MODELVIEW & dirtyBits); + final boolean frustumDirty = 0 != (DIRTY_FRUSTUM & dirtyBits); final boolean mviReq = 0 != (DIRTY_INVERSE_MODELVIEW & requestMask); final boolean mvitReq = 0 != (DIRTY_INVERSE_TRANSPOSED_MODELVIEW & requestMask); + final boolean frustumReq = 0 != (DIRTY_FRUSTUM & requestMask); final boolean modP = 0 != ( MODIFIED_PROJECTION & modifiedBits ); final boolean modMv = 0 != ( MODIFIED_MODELVIEW & modifiedBits ); - final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); + final boolean modT = 0 != ( MODIFIED_TEXTURE & modifiedBits ); sb.append("PMVMatrix[backingArray ").append(this.usesBackingArray()); sb.append(", modified[P ").append(modP).append(", Mv ").append(modMv).append(", T ").append(modT); - sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq); + sb.append("], dirty/req[Mvi ").append(mviDirty).append("/").append(mviReq).append(", Mvit ").append(mvitDirty).append("/").append(mvitReq).append(", Frustum ").append(frustumDirty).append("/").append(frustumReq); sb.append("], Projection").append(Platform.NEWLINE); matrixToString(sb, f, matrixP); sb.append(", Modelview").append(Platform.NEWLINE); @@ -925,17 +926,20 @@ public class PMVMatrix implements GLMatrixFunc { * Returns the dirty bits due to mutable operations. *

    * A dirty bit is set , if the corresponding matrix had been modified by a mutable operation - * since last {@link #update()} call. The latter clears the dirty state only if the dirty matrix (Mvi or Mvit) - * has been requested by one of the {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} methods. + * since last {@link #update()} call. The latter clears the dirty state only if the dirty matrix (Mvi or Mvit) or {@link Frustum} + * has been requested by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * or {@link #glGetFrustum() Frustum get} methods. *

    * * @deprecated Function is exposed for debugging purposes only. * @see #DIRTY_INVERSE_MODELVIEW * @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW + * @see #DIRTY_FRUSTUM * @see #glGetMviMatrixf() * @see #glGetMvitMatrixf() * @see #glGetPMvMviMatrixf() * @see #glGetPMvMvitMatrixf() + * @see #glGetFrustum() */ public final int getDirtyBits() { return dirtyBits; @@ -944,17 +948,20 @@ public class PMVMatrix implements GLMatrixFunc { /** * Returns the request bit mask, which uses bit values equal to the dirty mask. *

    - * The request bit mask is set by one of the {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} methods. + * The request bit mask is set by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * or {@link #glGetFrustum() Frustum get} methods. *

    * * @deprecated Function is exposed for debugging purposes only. - * @see #disableMviMvitUpdate() + * @see #clearAllUpdateRequests() * @see #DIRTY_INVERSE_MODELVIEW * @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW + * @see #DIRTY_FRUSTUM * @see #glGetMviMatrixf() * @see #glGetMvitMatrixf() * @see #glGetPMvMviMatrixf() * @see #glGetPMvMvitMatrixf() + * @see #glGetFrustum() */ public final int getRequestMask() { return requestMask; @@ -962,38 +969,39 @@ public class PMVMatrix implements GLMatrixFunc { /** - * Disable {@link #update()} of the Mvi and Mvit matrix - * after it has been enabled by one of the {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} methods. + * Clears all {@link #update()} requests of the Mvi and Mvit matrix and Frustum + * after it has been enabled by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * or {@link #glGetFrustum() Frustum get} methods. *

    - * This cleans the request bit mask used internally. - *

    - *

    - * Function may be useful to disable subsequent Mvi and Mvit updates if no more required. + * Allows user to disable subsequent Mvi, Mvit and {@link Frustum} updates if no more required. *

    * * @see #glGetMviMatrixf() * @see #glGetMvitMatrixf() * @see #glGetPMvMviMatrixf() * @see #glGetPMvMvitMatrixf() + * @see #glGetFrustum() * @see #getRequestMask() */ - public final void disableMviMvitUpdate() { + public final void clearAllUpdateRequests() { requestMask &= ~DIRTY_ALL; } /** - * Update the derived {@link #glGetMviMatrixf() inverse modelview (Mvi)} - * and {@link #glGetMvitMatrixf() inverse transposed modelview (Mvit)} matrices - * if they are dirty and their usage/update has been requested - * by one of the {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} methods. + * Update the derived {@link #glGetMviMatrixf() inverse modelview (Mvi)}, + * {@link #glGetMvitMatrixf() inverse transposed modelview (Mvit)} matrices and {@link Frustum} + * if they are dirty and they were requested + * by one of the {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * or {@link #glGetFrustum() Frustum get} methods. *

    - * The Mvi and Mvit matrices are considered dirty, if their corresponding + * The Mvi and Mvit matrices and {@link Frustum} are considered dirty, if their corresponding * {@link #glGetMvMatrixf() Mv matrix} has been modified since their last update. *

    *

    * Method should be called manually in case mutable operations has been called * and caller operates on already fetched references, i.e. not calling - * {@link #glGetMviMatrixf() Mvi get} or {@link #glGetMvitMatrixf() Mvit get} etc anymore. + * {@link #glGetMviMatrixf() Mvi get}, {@link #glGetMvitMatrixf() Mvit get} + * or {@link #glGetFrustum() Frustum get} etc anymore. *

    *

    * This method clears the modified bits like {@link #getModifiedBits(boolean) getModifiedBits(true)}, @@ -1002,7 +1010,7 @@ public class PMVMatrix implements GLMatrixFunc { *

    * * @return true if any matrix has been modified since last update call or - * if the derived matrices Mvi and Mvit were updated, otherwise false. + * if the derived matrices Mvi and Mvit or {@link Frustum} were updated, otherwise false. * In other words, method returns true if any matrix used by the caller must be updated, * e.g. uniforms in a shader program. * @@ -1012,23 +1020,36 @@ public class PMVMatrix implements GLMatrixFunc { * @see #MODIFIED_TEXTURE * @see #DIRTY_INVERSE_MODELVIEW * @see #DIRTY_INVERSE_TRANSPOSED_MODELVIEW + * @see #DIRTY_FRUSTUM * @see #glGetMviMatrixf() * @see #glGetMvitMatrixf() * @see #glGetPMvMviMatrixf() * @see #glGetPMvMvitMatrixf() - * @see #disableMviMvitUpdate() + * @see #glGetFrustum() + * @see #clearAllUpdateRequests() */ public final boolean update() { return updateImpl(true); } private final boolean updateImpl(boolean clearModBits) { - final boolean mod = 0 != modifiedBits; + boolean mod = 0 != modifiedBits; if(clearModBits) { modifiedBits = 0; } + if( 0 != ( dirtyBits & ( DIRTY_FRUSTUM & requestMask ) ) ) { + if( null == frustum ) { + frustum = new Frustum(); + mulPMV = new float[16]; + } + FloatUtil.multMatrixf(matrixP, matrixMv, mulPMV, 0); + frustum.update(mulPMV, 0); + dirtyBits &= ~DIRTY_FRUSTUM; + mod = true; + } + if( 0 == ( dirtyBits & requestMask ) ) { - return mod; // nothing requested which may have been dirty + return mod; // nothing more requested which may have been dirty } if(nioBackupArraySupported>=0) { @@ -1107,4 +1128,6 @@ public class PMVMatrix implements GLMatrixFunc { protected int dirtyBits = DIRTY_ALL; // contains the dirty bits, i.e. hinting for update operation protected int requestMask = 0; // may contain the requested dirty bits: DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW protected ProjectFloat projectFloat; + protected float[] mulPMV; // premultiplied PMV + protected Frustum frustum; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java index d7e89facc..c99bac9a4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java @@ -45,6 +45,7 @@ import org.junit.Test; import com.jogamp.common.os.Platform; import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.math.geom.Frustum; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.PMVMatrix; @@ -136,18 +137,20 @@ public class TestPMVMatrix01NEWT extends UITestCase { /** * Test using traditional access workflow, i.e. 1) operation 2) get-matrix references *

    - * The Mvi and Mvit dirty-bits and request-mask will be validated. + * The Mvi, Mvit and Frustum dirty-bits and request-mask will be validated. *

    */ @SuppressWarnings("deprecation") @Test public void test01MviUpdateTraditionalAccess() { FloatBuffer p, mv, mvi, mvit; + Frustum frustum; boolean b; final PMVMatrix pmv = new PMVMatrix(true); // System.err.println("P0: "+pmv.toString()); Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); // @@ -164,6 +167,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { } Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); // @@ -172,12 +176,14 @@ public class TestPMVMatrix01NEWT extends UITestCase { pmv.glTranslatef(1f, 2f, 3f); // all dirty ! Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); // System.err.println("P1: "+pmv.toString()); b = pmv.update(); // will not clean dirty bits, since no request has been made -> false Assert.assertEquals("Update has been perfomed, but non requested", false, b); Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); // System.err.println("P2: "+pmv.toString()); @@ -190,14 +196,19 @@ public class TestPMVMatrix01NEWT extends UITestCase { MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString(), translated123C, mv, epsilon); mvi = pmv.glGetMviMatrixf(); MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString(), translated123I, mvi, epsilon); - Assert.assertEquals("Remaining dirty bits not Mvit, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getDirtyBits()); Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask()); + Assert.assertEquals("Remaining dirty bits not Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + + frustum = pmv.glGetFrustum(); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! + Assert.assertEquals("Remaining dirty bits not Mvit, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); // System.err.println("P3: "+pmv.toString()); mvit = pmv.glGetMvitMatrixf(); MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); // System.err.println("P4: "+pmv.toString()); // @@ -206,37 +217,42 @@ public class TestPMVMatrix01NEWT extends UITestCase { pmv.glLoadIdentity(); // all dirty Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); MiscUtils.assertFloatBufferEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon); MiscUtils.assertFloatBufferNotEqual("Mvi already identity w/o update, "+pmv.toString(), ident, mvi, epsilon); MiscUtils.assertFloatBufferNotEqual("Mvit already identity w/o update, "+pmv.toString(), ident, mvit, epsilon); MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! b = pmv.update(); // will clean dirty bits, since request has been made -> true Assert.assertEquals("Update has not been perfomed, but requested", true, b); Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); MiscUtils.assertFloatBufferEquals("Mvi not identity after update, "+pmv.toString(), ident, mvi, epsilon); MiscUtils.assertFloatBufferEquals("Mvit not identity after update, "+pmv.toString(), ident, mvit, epsilon); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! } /** * Test using shader access workflow, i.e. 1) get-matrix references 2) operations *

    - * The Mvi and Mvit dirty-bits and request-mask will be validated. + * The Mvi, Mvit and Frustum dirty-bits and request-mask will be validated. *

    */ @SuppressWarnings("deprecation") @Test public void test02MviUpdateShaderAccess() { final FloatBuffer p, mv, mvi, mvit; + Frustum frustum; boolean b; final PMVMatrix pmv = new PMVMatrix(true); // System.err.println("P0: "+pmv.toString()); Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); // @@ -254,6 +270,7 @@ public class TestPMVMatrix01NEWT extends UITestCase { // System.err.println("P0: "+pmv.toString()); Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); // System.err.println("P1: "+pmv.toString()); @@ -269,31 +286,38 @@ public class TestPMVMatrix01NEWT extends UITestCase { mvi = pmv.glGetMviMatrixf(); MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvi, epsilon); - Assert.assertEquals("Remaining dirty bits not Mvit, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask()); mvit = pmv.glGetMvitMatrixf(); MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvit, epsilon); - Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Frustum, "+pmv.toString(), PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + frustum = pmv.glGetFrustum(); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! + Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); + // // Action #1 // pmv.glTranslatef(1f, 2f, 3f); // all dirty ! Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString()+pmv.toString(), ident, p, epsilon); MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString()+pmv.toString(), translated123C, mv, epsilon); MiscUtils.assertFloatBufferNotEqual("Mvi already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); MiscUtils.assertFloatBufferNotEqual("Mvit already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString()+pmv.toString(), ident, mvi, epsilon); MiscUtils.assertFloatBufferEquals("Mvit not identity, "+pmv.toString()+pmv.toString(), ident, mvit, epsilon); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! b = pmv.update(); // will clean dirty bits, since all requests has been made -> true Assert.assertEquals("Update has not been perfomed, but requested", true, b); Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); // System.err.println("P2: "+pmv.toString()); -- cgit v1.2.3 From 7e5371ca8eafce28c242fa7fbd8aec045fc81b71 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 21 Nov 2012 18:38:46 +0100 Subject: OSX CALayer Stencil/.. Fix: In case of FBO CALayer usage, use default caps/pixelformat w/ chosen GLProfile only Using a pixelformat w/ chosen stencil for CALayer does corrupt rendering for an unknown reason, probably due to incompatible pixelformat w/ CALayer composition. This patch simply discards any special chosen caps, while only recognizing the desired GLProfile for the FBO CALayer pixelformat. --- make/scripts/tests.sh | 11 +- .../jogamp/opengl/GLDrawableFactoryImpl.java | 4 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 40 +++--- .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 4 +- ...estGLAutoDrawableDelegateOnOffscrnCapsNEWT.java | 28 ++--- .../TestGLAutoDrawableFactoryOffscrnCapsNEWT.java | 53 +++++++- ...TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java | 51 +++++--- ...estGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java | 136 +++++++++++++++++++-- ...LAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java | 53 +++++++- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 6 + 10 files changed, 315 insertions(+), 71 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 621b61c6f..fc9b47c69 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -76,6 +76,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" + #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" @@ -250,7 +251,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* @@ -266,19 +267,19 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 2bb22f7b0..5c5db6d31 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -147,6 +147,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(target, true); if(null != ols) { final GLCapabilitiesImmutable chosenCapsMod = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(chosenCaps, this, adevice); + // layered surface -> Offscreen/[FBO|PBuffer] if( !chosenCapsMod.isFBO() && !chosenCapsMod.isPBuffer() ) { throw new GLException("Neither FBO nor Pbuffer is available for "+chosenCapsMod+", "+target); @@ -155,7 +156,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { ols.setChosenCapabilities(chosenCapsMod); if(DEBUG) { System.err.println("GLDrawableFactoryImpl.createGLDrawable -> OnscreenDrawable -> Offscreen-Layer"); - System.err.println("chosenCaps: "+chosenCaps); + System.err.println("chosenCaps: "+chosenCaps); System.err.println("chosenCapsMod: "+chosenCapsMod); System.err.println("OffscreenLayerSurface: **** "+ols); System.err.println("Target: **** "+target); @@ -165,7 +166,6 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { throw new IllegalArgumentException("Passed NativeSurface must implement SurfaceChangeable for offscreen layered surface: "+target); } if( chosenCapsMod.isFBO() ) { - // target surface is already a native one result = createFBODrawableImpl(target, chosenCapsMod, 0); } else { result = createOffscreenDrawableImpl(target); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 1c59b8d97..cde9841b8 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -568,24 +568,38 @@ public abstract class MacOSXCGLContext extends GLContextImpl if( !incompleteView && surface instanceof ProxySurface ) { incompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); } - long pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(chosenCaps, ctp, major, minor); + long pixelFormat; + { + final GLCapabilitiesImmutable targetCaps; + if( isFBO ) { + // Use minimum GLCapabilities for the target surface w/ same profile + targetCaps = new GLCapabilities( chosenCaps.getGLProfile() ); + } else { + targetCaps = chosenCaps; + } + pixelFormat = MacOSXCGLGraphicsConfiguration.GLCapabilities2NSPixelFormat(targetCaps, ctp, major, minor); + } if (pixelFormat == 0) { if(DEBUG) { System.err.println("Unable to allocate pixel format with requested GLCapabilities: "+chosenCaps); } return 0; } - GLCapabilities fixedCaps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(chosenCaps.getGLProfile(), pixelFormat); - if( !fixedCaps.isPBuffer() && isPBuffer ) { - throw new InternalError("handle is PBuffer, fixedCaps not: "+drawable); - } - { // determine on-/offscreen caps, since pformat is ambiguous - fixedCaps.setFBO( isFBO ); // exclusive - fixedCaps.setPBuffer( isPBuffer ); // exclusive - fixedCaps.setBitmap( false ); // n/a in our OSX impl. - fixedCaps.setOnscreen( !isFBO && !isPBuffer ); + final GLCapabilitiesImmutable fixedCaps; + if( isFBO ) { + // pixelformat of target doesn't affect caps w/ FBO + fixedCaps = chosenCaps; + } else { + final GLCapabilities _fixedCaps = MacOSXCGLGraphicsConfiguration.NSPixelFormat2GLCapabilities(chosenCaps.getGLProfile(), pixelFormat); + if( !_fixedCaps.isPBuffer() && isPBuffer ) { + throw new InternalError("handle is PBuffer, fixedCaps not: "+drawable); + } + // determine on-/offscreen caps, since pformat is ambiguous + _fixedCaps.setPBuffer( isPBuffer ); // exclusive + _fixedCaps.setBitmap( false ); // n/a in our OSX impl. + _fixedCaps.setOnscreen( !isFBO && !isPBuffer ); + fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(_fixedCaps, chosenCaps.isBackgroundOpaque()); } - fixedCaps = GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(fixedCaps, chosenCaps.isBackgroundOpaque()); int sRefreshRate = OSXUtil.GetScreenRefreshRate(drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getIndex()); screenVSyncTimeout = 1000000f / sRefreshRate; if(DEBUG) { @@ -604,10 +618,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl // Thread.dumpStack(); } config.setChosenCapabilities(fixedCaps); - /** - if(null != backingLayerHost) { - backingLayerHost.setChosenCapabilities(fixedCaps); - } */ try { final IntBuffer viewNotReady = Buffers.newDirectIntBuffer(1); diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 449121be1..9e270d403 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -193,8 +193,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } } if(null == errMsg) { - // fix caps reflecting offscreen! (no GL available here ..) - Capabilities caps = (Capabilities) getGraphicsConfiguration().getChosenCapabilities().cloneMutable(); + // Fix caps reflecting offscreen! (no GL available here ..) + final Capabilities caps = (Capabilities) getGraphicsConfiguration().getChosenCapabilities().cloneMutable(); caps.setOnscreen(false); setChosenCapabilities(caps); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java index d9e9b2bf3..c5b4227c2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateOnOffscrnCapsNEWT.java @@ -235,20 +235,20 @@ public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase { } @Test - public void testGL2OnScreenDblBuf() throws InterruptedException { + public void testGL2OnScreenSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } - + @Test - public void testGL2OnScreenSglBuf() throws InterruptedException { + public void testGL2OnScreenDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; - reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } - + @Test public void testGL2OffScreenAutoDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -258,21 +258,21 @@ public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase { } @Test - public void testGL2OffScreenFBODblBuf() throws InterruptedException { + public void testGL2OffScreenFBOSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } @Test - public void testGL2OffScreenFBOSglBuf() throws InterruptedException { + public void testGL2OffScreenFBODblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setFBO(true); - reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } @@ -306,17 +306,17 @@ public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase { } @Test - public void testES2OnScreenDblBuf() throws InterruptedException { + public void testES2OnScreenSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } @Test - public void testES2OnScreenSglBuf() throws InterruptedException { + public void testES2OnScreenDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; - reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } @@ -329,21 +329,21 @@ public class TestGLAutoDrawableDelegateOnOffscrnCapsNEWT extends UITestCase { } @Test - public void testES2OffScreenFBODblBuf() throws InterruptedException { + public void testES2OffScreenFBOSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } @Test - public void testES2OffScreenFBOSglBuf() throws InterruptedException { + public void testES2OffScreenFBODblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setFBO(true); - reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java index 51f9cc411..f8092d064 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryOffscrnCapsNEWT.java @@ -192,7 +192,7 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { } @Test - public void testGL2OffScreenFBOStencil() throws InterruptedException { + public void testGL2OffScreenFBODblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); @@ -202,13 +202,25 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { } @Test - public void testGL2OffScreenFBOStencilMSAA() throws InterruptedException { + public void testGL2OffScreenFBODblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBufStencilMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setFBO(true); reqGLCaps.setStencilBits(1); reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } @@ -249,6 +261,16 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { doTest(reqGLCaps, new GearsES2(1)); } + @Test + public void testES2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + @Test public void testES2OffScreenFBODblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -259,12 +281,35 @@ public class TestGLAutoDrawableFactoryOffscrnCapsNEWT extends UITestCase { } @Test - public void testES2OffScreenFBOSglBuf() throws InterruptedException { + public void testES2OffScreenFBODblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setFBO(true); - reqGLCaps.setDoubleBuffered(false); + reqGLCaps.setStencilBits(1); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBufStencilMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setStencilBits(1); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java index a2ffa9069..0673e2f45 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.java @@ -247,76 +247,89 @@ public class TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT extends UITestCase { } @Test - public void testGL2OnScreen() throws InterruptedException { + public void testGL2OnScreenDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; doTest(reqGLCaps, new GearsES2(1)); } @Test - public void testGL2OffScreenAuto() throws InterruptedException { + public void testGL2OnScreenDblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; - reqGLCaps.setOnscreen(false); + reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new GearsES2(1)); } - + @Test - public void testGL2OffScreenFBOMSAA() throws InterruptedException { + public void testGL2OnScreenDblBufMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; - reqGLCaps.setOnscreen(false); - reqGLCaps.setFBO(true); reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } @Test - public void testGL2OffScreenPbuffer() throws InterruptedException { + public void testGL2OnScreenDblBufStencilMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; - reqGLCaps.setOnscreen(false); - reqGLCaps.setPBuffer(true); + reqGLCaps.setStencilBits(1); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } @Test - public void testES2OnScreen() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + public void testGL2OffScreenAutoDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBufStencil() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new GearsES2(1)); } @Test - public void testES2OffScreenAuto() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + public void testGL2OffScreenFBODblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } @Test - public void testES2OffScreenFBOMSAA() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + public void testGL2OffScreenFBODblBufStencilMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setFBO(true); + reqGLCaps.setStencilBits(1); reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } @Test - public void testES2OffScreenPbuffer() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + public void testGL2OffScreenPbuffer() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setPBuffer(true); doTest(reqGLCaps, new GearsES2(1)); } - public static void main(String args[]) throws IOException { org.junit.runner.JUnitCore.main(TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java index da5456777..0a6056606 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT.java @@ -188,6 +188,14 @@ public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { } } + @Test + public void testGL2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + @Test public void testGL2OnScreenDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -196,10 +204,29 @@ public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { } @Test - public void testGL2OnScreenSglBuf() throws InterruptedException { + public void testGL2OnScreenDblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; - reqGLCaps.setDoubleBuffered(false); + reqGLCaps.setStencilBits(1); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OnScreenDblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OnScreenDblBufStencilMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setStencilBits(1); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } @@ -211,6 +238,16 @@ public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { doTest(reqGLCaps, new GearsES2(1)); } + @Test + public void testGL2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + @Test public void testGL2OffScreenFBODblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -221,12 +258,35 @@ public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { } @Test - public void testGL2OffScreenFBOSglBuf() throws InterruptedException { + public void testGL2OffScreenFBODblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setFBO(true); - reqGLCaps.setDoubleBuffered(false); + reqGLCaps.setStencilBits(1); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBufStencilMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setStencilBits(1); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } @@ -259,6 +319,14 @@ public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { doTest(reqGLCaps, new Gears(1)); } + @Test + public void testES2OnScreenSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + @Test public void testES2OnScreenDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -267,10 +335,29 @@ public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { } @Test - public void testES2OnScreenSglBuf() throws InterruptedException { + public void testES2OnScreenDblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; - reqGLCaps.setDoubleBuffered(false); + reqGLCaps.setStencilBits(1); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OnScreenDblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OnScreenDblBufStencilMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setStencilBits(1); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } @@ -282,6 +369,16 @@ public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { doTest(reqGLCaps, new GearsES2(1)); } + @Test + public void testES2OffScreenFBOSglBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setDoubleBuffered(false); + doTest(reqGLCaps, new GearsES2(1)); + } + @Test public void testES2OffScreenFBODblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -292,12 +389,35 @@ public class TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT extends UITestCase { } @Test - public void testES2OffScreenFBOSglBuf() throws InterruptedException { + public void testES2OffScreenFBODblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; reqGLCaps.setOnscreen(false); reqGLCaps.setFBO(true); - reqGLCaps.setDoubleBuffered(false); + reqGLCaps.setStencilBits(1); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new GearsES2(1)); + } + + @Test + public void testES2OffScreenFBODblBufStencilMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + reqGLCaps.setOnscreen(false); + reqGLCaps.setFBO(true); + reqGLCaps.setStencilBits(1); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java index 37483f7e7..f4999c0fa 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT.java @@ -266,18 +266,67 @@ public class TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT extends UITestCase } @Test - public void testGL2OffScreenLayerAuto() throws InterruptedException { + public void testGL2OnScreenDblBufStencil() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setStencilBits(1); + doTest(false, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OnScreenDblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(false, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OnScreenDblBufStencilMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setStencilBits(1); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(false, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenLayerAutoDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; doTest(true, reqGLCaps, new GearsES2(1)); } @Test - public void testGL2OffScreenFBOMSAA() throws InterruptedException { + public void testGL2OffScreenFBODblBufStencil() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setFBO(true); + reqGLCaps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow + reqGLCaps.setStencilBits(1); + doTest(true, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); + if(null == reqGLCaps) return; + reqGLCaps.setFBO(true); + reqGLCaps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(true, reqGLCaps, new GearsES2(1)); + } + + @Test + public void testGL2OffScreenFBODblBufStencilMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); if(null == reqGLCaps) return; reqGLCaps.setFBO(true); reqGLCaps.setOnscreen(true); // get native NEWT Window, not OffscreenWindow + reqGLCaps.setStencilBits(1); reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(true, reqGLCaps, new GearsES2(1)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index 07899b7d6..0a8063297 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -65,6 +65,7 @@ public class TestGearsES2AWT extends UITestCase { static boolean shallUseOffscreenLayer = false; static boolean shallUseOffscreenPBufferLayer = false; static boolean useMSAA = false; + static boolean useStencil = false; static boolean addComp = true; static boolean shutdownRemoveGLCanvas = true; static boolean shutdownDisposeFrame = true; @@ -159,6 +160,9 @@ public class TestGearsES2AWT extends UITestCase { caps.setNumSamples(4); caps.setSampleBuffers(true); } + if(useStencil) { + caps.setStencilBits(1); + } if(shallUseOffscreenLayer) { caps.setOnscreen(false); } @@ -192,6 +196,8 @@ public class TestGearsES2AWT extends UITestCase { shallUseOffscreenPBufferLayer = true; } else if(args[i].equals("-msaa")) { useMSAA = true; + } else if(args[i].equals("-stencil")) { + useStencil = true; } else if(args[i].equals("-wait")) { waitForKey = true; } else if(args[i].equals("-justGears")) { -- cgit v1.2.3 From f24844c5e6c57a43df79224f2d3a89e9720726f7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 23 Nov 2012 09:09:17 +0100 Subject: Fix SWTEDTUtil Bug628: Perform NEWT event dispatching on SWT-EDT, due to possible triggered locking action, i.e. display(). Do the same for AWTEDTUtil. This fix actually clarifies the annotated FIXME :) --- make/scripts/tests.sh | 3 ++- src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java | 15 +++++++++------ src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 11 +++++------ 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index fc9b47c69..a732d78fa 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -279,7 +279,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -372,6 +372,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock $* # # newt.awt (testawt) diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java index d4b83d891..d40aa18cf 100644 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -231,12 +231,15 @@ public class SWTEDTUtil implements EDTUtil { do { // event dispatch if(!shouldStop) { - // FIXME: Determine whether we require to run the - // delivery of events (dispatch) on AWT-EDT. - // Since the WindowDriver itself delivers all Window related events, - // this shall not be required. - // AWTEDTExecutor.singleton.invoke(true, dispatchMessages); - dispatchMessages.run(); + // EDT invoke thread is SWT-EDT, + // hence dispatching is required to run on SWT-EDT as well. + // Otherwise a deadlock may happen due to dispatched event's + // triggering a locking action. + if ( !swtDisplay.isDisposed() ) { + swtDisplay.syncExec(dispatchMessages); + } else { + dispatchMessages.run(); + } } // wait synchronized(sync) { diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 8771f5c74..6fa053dd3 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -215,12 +215,11 @@ public class AWTEDTUtil implements EDTUtil { do { // event dispatch if(!shouldStop) { - // FIXME: Determine whether we require to run the - // delivery of events (dispatch) on AWT-EDT. - // Since the WindowDriver itself delivers all Window related events, - // this shall not be required. - // AWTEDTExecutor.singleton.invoke(true, dispatchMessages); - dispatchMessages.run(); + // EDT invoke thread is AWT-EDT, + // hence dispatching is required to run on AWT-EDT as well. + // Otherwise a deadlock may happen due to dispatched event's + // triggering a locking action. + AWTEDTExecutor.singleton.invoke(true, dispatchMessages); } // wait synchronized(sync) { -- cgit v1.2.3 From ae30626c7d857c21eabaa0d0d819ad13d19d9987 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 25 Nov 2012 14:59:09 +0100 Subject: Add test-x64 script for running SWT junit test cases (only) - also documents how to run partial junit tests --- make/scripts/tests-x64-junit-swt.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 make/scripts/tests-x64-junit-swt.sh (limited to 'make/scripts') diff --git a/make/scripts/tests-x64-junit-swt.sh b/make/scripts/tests-x64-junit-swt.sh new file mode 100644 index 000000000..421791a19 --- /dev/null +++ b/make/scripts/tests-x64-junit-swt.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +SDIR=`dirname $0` + +. $SDIR/make.jogl.all.linux-x86_64.sh -f build-test.xml junit.run.settings junit.run.swt.awt + + -- cgit v1.2.3 From 17dd761d7c2b224f0505a399bf4ecb18634e9250 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 27 Nov 2012 01:55:10 +0100 Subject: SWTEDTUtil/AWTEDTUtil: Fix deadlock situations ; Cleanup TestNewtCanvasSWTBug628ResizeDeadlock - Fix deadlock situation in waitUntilStopped/Idle(), skip if on AWT/SWT EDT - Use RunnableTask for sync task invocation, don't block AWT/SWT EDT. - Cleanup TestNewtCanvasSWTBug628ResizeDeadlock (works on OSX as well) --- make/scripts/make.jogl.all.win64.bat | 4 +- make/scripts/tests-linux-x64-junit-swt.sh | 7 + make/scripts/tests-macosx64-junit-swt.sh | 7 + make/scripts/tests-win64-junit-swt.bat | 7 + make/scripts/tests-x64-junit-swt.sh | 7 - make/scripts/tests-x64.bat | 3 +- .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 89 +++++++---- src/newt/classes/jogamp/newt/DisplayImpl.java | 6 +- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 77 ++++++--- .../swt/TestNewtCanvasSWTBug628ResizeDeadlock.java | 176 ++++++++++++++------- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 10 +- 11 files changed, 265 insertions(+), 128 deletions(-) create mode 100644 make/scripts/tests-linux-x64-junit-swt.sh create mode 100644 make/scripts/tests-macosx64-junit-swt.sh create mode 100755 make/scripts/tests-win64-junit-swt.bat delete mode 100644 make/scripts/tests-x64-junit-swt.sh (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.win64.bat b/make/scripts/make.jogl.all.win64.bat index 7355c6a1a..e2b3a6b80 100755 --- a/make/scripts/make.jogl.all.win64.bat +++ b/make/scripts/make.jogl.all.win64.bat @@ -6,8 +6,8 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%PATH% -set LIB_GEN=%THISDIR%\lib -set CLASSPATH=.;%THISDIR%\build-win64\classes +REM set LIB_GEN=%THISDIR%\lib +REM set CLASSPATH=.;%THISDIR%\build-win64\classes REM -Dc.compiler.debug=true REM -Dsetup.addNativeOpenMAX=true REM -Dsetup.addNativeKD=true diff --git a/make/scripts/tests-linux-x64-junit-swt.sh b/make/scripts/tests-linux-x64-junit-swt.sh new file mode 100644 index 000000000..421791a19 --- /dev/null +++ b/make/scripts/tests-linux-x64-junit-swt.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +SDIR=`dirname $0` + +. $SDIR/make.jogl.all.linux-x86_64.sh -f build-test.xml junit.run.settings junit.run.swt.awt + + diff --git a/make/scripts/tests-macosx64-junit-swt.sh b/make/scripts/tests-macosx64-junit-swt.sh new file mode 100644 index 000000000..2a6ccd63a --- /dev/null +++ b/make/scripts/tests-macosx64-junit-swt.sh @@ -0,0 +1,7 @@ +#! /bin/bash + +SDIR=`dirname $0` + +. $SDIR/make.jogl.all.macosx.sh -f build-test.xml junit.run.settings junit.run.swt.awt + + diff --git a/make/scripts/tests-win64-junit-swt.bat b/make/scripts/tests-win64-junit-swt.bat new file mode 100755 index 000000000..fbcc5d692 --- /dev/null +++ b/make/scripts/tests-win64-junit-swt.bat @@ -0,0 +1,7 @@ +set THISDIR=%cd% + +set SDIR=%~dp0% + +%SDIR%/make.jogl.all.win64.bat -f build-test.xml junit.run.settings junit.run.swt.awt + + diff --git a/make/scripts/tests-x64-junit-swt.sh b/make/scripts/tests-x64-junit-swt.sh deleted file mode 100644 index 421791a19..000000000 --- a/make/scripts/tests-x64-junit-swt.sh +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash - -SDIR=`dirname $0` - -. $SDIR/make.jogl.all.linux-x86_64.sh -f build-test.xml junit.run.settings junit.run.swt.awt - - diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 7dd00eabe..0266f2bb7 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -56,6 +56,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT @@ -112,7 +113,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java index d08fefa29..42e1c9be5 100644 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java @@ -29,8 +29,11 @@ package com.jogamp.newt.swt; import java.awt.EventQueue; +import javax.media.nativewindow.NativeWindowException; + import jogamp.newt.Debug; +import com.jogamp.common.util.RunnableTask; import com.jogamp.newt.util.EDTUtil; /** @@ -136,38 +139,58 @@ public class SWTEDTUtil implements EDTUtil { if(task == null) { throw new RuntimeException("Null Runnable"); } - synchronized(edtLock) { // lock the EDT status - if( nedt.shouldStop ) { - // drop task .. - if(DEBUG) { - System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); - Thread.dumpStack(); + Throwable throwable = null; + RunnableTask rTask = null; + Object rTaskLock = new Object(); + synchronized(rTaskLock) { // lock the optional task execution + synchronized(edtLock) { // lock the EDT status + if( nedt.shouldStop ) { + // drop task .. + if(DEBUG) { + System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); + Thread.dumpStack(); + } + return; } - return; - } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - nedt.shouldStop = true; - if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); + // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); + // Thread.dumpStack(); + if(stop) { + nedt.shouldStop = true; + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + // Thread.dumpStack(); + } + } + if( isCurrentThreadEDT() ) { + task.run(); + wait = false; // running in same thread (EDT) -> no wait + } else if( swtDisplay.isDisposed() ) { + wait = false; // drop task, SWT disposed + } else { + // start if should not stop && not started yet + if( !stop && !nedt.isRunning() ) { + startImpl(); + } + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */); + swtDisplay.asyncExec(rTask); } } - if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else if( swtDisplay.isDisposed() ) { - wait = false; // drop task, SWT disposed - } else { - // start if should not stop && not started yet - if( !stop && !nedt.isRunning() ) { - startImpl(); + if( wait ) { + try { + rTaskLock.wait(); // free lock, allow execution of rTask + } catch (InterruptedException ie) { + throwable = ie; } - if(wait) { - swtDisplay.syncExec(task); - } else { - swtDisplay.asyncExec(task); + if(null==throwable) { + throwable = rTask.getThrowable(); + } + if(null!=throwable) { + if(throwable instanceof NativeWindowException) { + throw (NativeWindowException)throwable; + } + throw new RuntimeException(throwable); } } } @@ -175,11 +198,12 @@ public class SWTEDTUtil implements EDTUtil { @Override final public void waitUntilIdle() { - final NewtEventDispatchThread _edt; + final NewtEventDispatchThread _nedt; synchronized(edtLock) { - _edt = nedt; + _nedt = nedt; } - if(!_edt.isRunning() || EventQueue.isDispatchThread() || _edt == Thread.currentThread()) { + final Thread ct = Thread.currentThread(); + if(!_nedt.isRunning() || _nedt == ct || swtDisplay.getThread() == ct) { return; } try { @@ -192,7 +216,8 @@ public class SWTEDTUtil implements EDTUtil { @Override final public void waitUntilStopped() { synchronized(edtLock) { - if(nedt.isRunning() && nedt != Thread.currentThread() ) { + final Thread ct = Thread.currentThread(); + if(nedt.isRunning() && nedt != ct && swtDisplay.getThread() != ct) { while(nedt.isRunning()) { try { edtLock.wait(); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index fbccc5767..317535805 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -366,12 +366,10 @@ public abstract class DisplayImpl extends Display { private ArrayList events = new ArrayList(); private volatile boolean haveEvents = false; - class DispatchMessagesRunnable implements Runnable { + final protected Runnable dispatchMessagesRunnable = new Runnable() { public void run() { DisplayImpl.this.dispatchMessages(); - } - } - protected DispatchMessagesRunnable dispatchMessagesRunnable = new DispatchMessagesRunnable(); + } }; final void dispatchMessage(final NEWTEventTask eventTask) { final NEWTEvent event = eventTask.get(); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 01b5ad8a4..2175f2190 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -30,6 +30,9 @@ package jogamp.newt.driver.awt; import java.awt.EventQueue; +import javax.media.nativewindow.NativeWindowException; + +import com.jogamp.common.util.RunnableTask; import com.jogamp.newt.util.EDTUtil; import jogamp.common.awt.AWTEDTExecutor; @@ -124,33 +127,57 @@ public class AWTEDTUtil implements EDTUtil { if(task == null) { throw new RuntimeException("Null Runnable"); } - synchronized(edtLock) { // lock the EDT status - if( nedt.shouldStop ) { - // drop task .. - if(DEBUG) { - System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); - Thread.dumpStack(); + Throwable throwable = null; + RunnableTask rTask = null; + Object rTaskLock = new Object(); + synchronized(rTaskLock) { // lock the optional task execution + synchronized(edtLock) { // lock the EDT status + if( nedt.shouldStop ) { + // drop task .. + if(DEBUG) { + System.err.println("Warning: EDT about (1) to stop, won't enqueue new task: "+nedt); + Thread.dumpStack(); + } + return; } - return; - } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - nedt.shouldStop = true; - if(DEBUG) { - System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); + // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); + // Thread.dumpStack(); + if(stop) { + nedt.shouldStop = true; + if(DEBUG) { + System.err.println(Thread.currentThread()+": EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + // Thread.dumpStack(); + } + } + if( isCurrentThreadEDT() ) { + task.run(); + wait = false; // running in same thread (EDT) -> no wait + } else { + // start if should not stop && not started yet + if( !stop && !nedt.isRunning() ) { + startImpl(); + } + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */); + AWTEDTExecutor.singleton.invoke(false, rTask); } } - if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else { - // start if should not stop && not started yet - if( !stop && !nedt.isRunning() ) { - startImpl(); + if( wait ) { + try { + rTaskLock.wait(); // free lock, allow execution of rTask + } catch (InterruptedException ie) { + throwable = ie; + } + if(null==throwable) { + throwable = rTask.getThrowable(); + } + if(null!=throwable) { + if(throwable instanceof NativeWindowException) { + throw (NativeWindowException)throwable; + } + throw new RuntimeException(throwable); } - AWTEDTExecutor.singleton.invoke(wait, task); } } } @@ -161,7 +188,7 @@ public class AWTEDTUtil implements EDTUtil { synchronized(edtLock) { _edt = nedt; } - if(!_edt.isRunning() || EventQueue.isDispatchThread() || _edt == Thread.currentThread()) { + if(!_edt.isRunning() || _edt == Thread.currentThread() || EventQueue.isDispatchThread()) { return; } try { @@ -174,7 +201,7 @@ public class AWTEDTUtil implements EDTUtil { @Override final public void waitUntilStopped() { synchronized(edtLock) { - if(nedt.isRunning() && nedt != Thread.currentThread() ) { + if(nedt.isRunning() && nedt != Thread.currentThread() && !EventQueue.isDispatchThread()) { while(nedt.isRunning()) { try { edtLock.wait(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java index 3b5c4267e..9c0762c12 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java @@ -35,12 +35,11 @@ import java.lang.reflect.InvocationTargetException; import org.eclipse.swt.SWT ; import org.eclipse.swt.layout.FillLayout ; -import org.eclipse.swt.layout.GridData ; -import org.eclipse.swt.layout.GridLayout ; import org.eclipse.swt.widgets.Composite ; import org.eclipse.swt.widgets.Display ; import org.eclipse.swt.widgets.Shell ; +import org.junit.Assume; import org.junit.Test; import javax.media.opengl.GL ; @@ -52,6 +51,7 @@ import javax.media.opengl.GLProfile; import junit.framework.Assert; +import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow ; @@ -142,7 +142,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { //////////////////////////////////////////////////////////////////////////////// static class ResizeThread extends Thread { - boolean shallStop = false; + volatile boolean shallStop = false; private Shell _shell ; private int _n ; @@ -152,6 +152,26 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { _shell = shell ; } + final Runnable resizeAction = new Runnable() { + public void run() + { + System.err.println("[R-i shallStop "+shallStop+", disposed "+_shell.isDisposed()+"]"); + if( shallStop || _shell.isDisposed() ) { + return; + } + try { + if( _n % 2 == 0 ) { + _shell.setSize( 200, 200 ) ; + } else { + _shell.setSize( 400, 450 ) ; + } + } catch (Exception e0) { + e0.printStackTrace(); + Assert.assertTrue("Deadlock @ setSize: "+e0, false); + } + ++_n ; + } }; + public void run() { // The problem was originally observed by grabbing the lower right @@ -162,33 +182,24 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { // This loop simulates rapid resizing by the user by toggling // the shell back-and-forth between two sizes. - while( !shallStop ) + System.err.println("[R-0 shallStop "+shallStop+", disposed "+_shell.isDisposed()+"]"); + + final Display display = _shell.getDisplay(); + + while( !shallStop && !_shell.isDisposed() ) { try { - _shell.getDisplay().asyncExec( new Runnable() - { - public void run() - { - try { - if( _n % 2 == 0 ) { - _shell.setSize( 200, 200 ) ; - } else { - _shell.setSize( 400, 450 ) ; - } - } catch (Exception e0) { - e0.printStackTrace(); - Assert.assertTrue("Deadlock @ setSize: "+e0, false); - } - ++_n ; - } - } ) ; + System.err.println("[R-n shallStop "+shallStop+", disposed "+_shell.isDisposed()+"]"); + display.asyncExec( resizeAction ); + display.wake(); - Thread.sleep( 50L ) ; + Thread.sleep( 50L ) ; } catch( InterruptedException e ) { break ; } } + System.err.println("*R-Exit* shallStop "+shallStop+", disposed "+_shell.isDisposed()); } } @@ -196,50 +207,101 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { static class KeyfireThread extends Thread { - boolean shallStop = false; + volatile boolean shallStop = false; + Display _display; Robot _robot; int _n = 0; - public KeyfireThread(Robot robot) + public KeyfireThread(Robot robot, Display display) { _robot = robot; + _display = display; } public void run() { + System.err.println("[K-0]"); + while( !shallStop ) { try { + System.err.println("[K-"+_n+"]"); AWTRobotUtil.keyPress(_n, _robot, true, KeyEvent.VK_0, 10); AWTRobotUtil.keyPress(_n, _robot, false, KeyEvent.VK_0, 0); Thread.sleep( 40L ) ; + _n++; + if(!_display.isDisposed()) { + _display.wake(); + } } catch( InterruptedException e ) { break ; } } + System.err.println("*K-Exit*"); } } //////////////////////////////////////////////////////////////////////////////// + private volatile boolean shallStop = false; + + static class SWT_DSC { + Display display; + Shell shell; + Composite composite; + + public void init() { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + }}); + + display.syncExec(new Runnable() { + public void run() { + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite = new Composite( shell, SWT.NONE ); + composite.setLayout( new FillLayout() ); + Assert.assertNotNull( composite ); + }}); + } + + public void dispose() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite ); + try { + display.syncExec(new Runnable() { + public void run() { + composite.dispose(); + shell.dispose(); + }}); + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display.dispose(); + }}); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + display = null; + shell = null; + composite = null; + } + } + @Test public void test() throws InterruptedException, AWTException, InvocationTargetException { - final int columnCount = 1; - final Display display = new Display() ; - - final Shell shell = new Shell( display ) ; - shell.setLayout( new FillLayout() ) ; - final Robot robot = new Robot(); - Composite composite = new Composite( shell, SWT.NONE ) ; - { - GridLayout layout = new GridLayout() ; - layout.numColumns = columnCount ; - composite.setLayout( layout ) ; - } - + final SWT_DSC dsc = new SWT_DSC(); + dsc.init(); + final GLWindow glWindow; + final NewtCanvasSWT canvas; { final GLProfile gl2Profile = GLProfile.get( GLProfile.GL2 ) ; GLCapabilities caps = new GLCapabilities( gl2Profile ) ; @@ -252,26 +314,30 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { glWindow.display(); } }); - NewtCanvasSWT canvas = NewtCanvasSWT.create( composite, SWT.NO_BACKGROUND, glWindow ) ; - canvas.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, columnCount, 1 ) ) ; + canvas = NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ; } - shell.setText( "NewtCanvasSWT Resize Bug Demo" ) ; - shell.setSize( 400, 450 ) ; - shell.open() ; - + dsc.display.syncExec( new Runnable() { + public void run() { + dsc.shell.setText( "NewtCanvasSWT Resize Bug Demo" ) ; + dsc.shell.setSize( 400, 450 ) ; + dsc.shell.open() ; + } } ); + AWTRobotUtil.requestFocus(robot, glWindow, false); AWTRobotUtil.setMouseToClientLocation(robot, glWindow, 50, 50); + shallStop = false; + final ResizeThread resizer; { - resizer = new ResizeThread( shell ) ; + resizer = new ResizeThread( dsc.shell ) ; resizer.start() ; } final KeyfireThread keyfire; { - keyfire = new KeyfireThread( robot ) ; + keyfire = new KeyfireThread( robot, dsc.display ) ; keyfire.start() ; } @@ -292,18 +358,15 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { { keyfire.join(); } catch( InterruptedException e ) { } - display.syncExec( new Runnable() { - @Override - public void run() { - shell.dispose(); - } } ); + shallStop = true; + dsc.display.wake(); } } ).start(); } - + try { - while( !shell.isDisposed() ) { - if( !display.readAndDispatch() ) { - display.sleep(); + while( !shallStop && !dsc.display.isDisposed() ) { + if( !dsc.display.readAndDispatch() ) { + dsc.display.sleep(); } } } catch (Exception e0) { @@ -311,7 +374,10 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { Assert.assertTrue("Deadlock @ dispatch: "+e0, false); } - display.dispose() ; + System.err.println("NewtCanvasAWT Dispose"); + canvas.dispose(); + + dsc.dispose(); } public static void main( String[] args ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java index 61caa5ef9..396d219b4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTGLn.java @@ -93,6 +93,9 @@ public class TestNewtCanvasSWTGLn extends UITestCase { public void run() { display = new Display(); Assert.assertNotNull( display ); + }}); + display.syncExec(new Runnable() { + public void run() { shell = new Shell( display ); Assert.assertNotNull( shell ); shell.setLayout( new FillLayout() ); @@ -108,10 +111,13 @@ public class TestNewtCanvasSWTGLn extends UITestCase { Assert.assertNotNull( shell ); Assert.assertNotNull( composite ); try { - SWTAccessor.invoke(true, new Runnable() { + display.syncExec(new Runnable() { public void run() { composite.dispose(); shell.dispose(); + }}); + SWTAccessor.invoke(true, new Runnable() { + public void run() { display.dispose(); }}); } @@ -149,7 +155,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( composite, 0, postAttach ? null : glWindow1 ); Assert.assertNotNull( canvas1 ); - SWTAccessor.invoke(true, new Runnable() { + display.syncExec( new Runnable() { public void run() { shell.setText( getSimpleTestName(".") ); shell.setSize( 640, 480 ); -- cgit v1.2.3 From f25b5c973150252af5c5fbf4ca87b03e2e9aee32 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 27 Nov 2012 19:04:20 +0100 Subject: Fix script lstjars.sh's pack200 list --- make/scripts/lstjars.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/lstjars.sh b/make/scripts/lstjars.sh index 5763e419f..2cb4e1b56 100755 --- a/make/scripts/lstjars.sh +++ b/make/scripts/lstjars.sh @@ -107,11 +107,12 @@ mv nope/*.jar . listdeployment jar if [ $pack200 -eq 1 ] ; then - for i in *.jar ; do + for i in *.jar atomic/*jar ; do fname=$i + dname=$(dirname $fname) bname=$(basename $fname .jar) - echo pack200 $bname.pack.gz $fname - pack200 $bname.pack.gz $fname + echo pack200 $dname/$bname.pack.gz $fname + pack200 $dname/$bname.pack.gz $fname done listdeployment pack.gz fi -- cgit v1.2.3 From 601d6c46df61853fb61df087327a055550316b1d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 29 Nov 2012 00:08:06 +0100 Subject: SWT GLCanvas: Fix dispose bug, check for isDisposed() and add DisposeListener; Run GL tasks on current thread w/o restrictions Fix dispose bug, check for isDisposed() and add DisposeListener - Don't issue SWTAccessor.setRealized(..), since it's called implicit via super.dispose() - Check isDisposed() .. - add DisposeListener to act on parent's disposal (Shell, Composition, ..) Run GL tasks on current thread w/o restrictions + * The current thread seems to be valid for all platforms, + * since no SWT lifecycle tasks are being performed w/ this call. + * Only GL task, which are independent from the SWT threading model. --- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 69 ++++++++++++++++------ 3 files changed, 56 insertions(+), 21 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 0266f2bb7..f340af552 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -54,9 +54,9 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a732d78fa..2d8f3e1a8 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -370,9 +370,9 @@ function testawtswt() { # #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock $* # # newt.awt (testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 3c1a64a9e..38dd71f5e 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -54,8 +54,10 @@ import jogamp.opengl.GLDrawableHelper; import jogamp.opengl.GLDrawableImpl; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlAdapter; import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Rectangle; @@ -146,8 +148,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { public void run() { final RecursiveLock _lock = lock; _lock.lock(); - try { - helper.invokeGL(drawable, context, displayAction, initAction); + try { + if( !GLCanvas.this.isDisposed() ) { + helper.invokeGL(drawable, context, displayAction, initAction); + } } finally { _lock.unlock(); } @@ -161,7 +165,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final RecursiveLock _lock = lock; _lock.lock(); try { - if(null != drawable) { + if(null != drawable && !GLCanvas.this.isDisposed() ) { drawable.swapBuffers(); } } finally { @@ -193,7 +197,11 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { // Catch dispose GLExceptions by GLEventListener, just 'print' them // so we can continue with the destruction. try { - helper.disposeGL(GLCanvas.this, context); + if( !GLCanvas.this.isDisposed() ) { + helper.disposeGL(GLCanvas.this, context); + } else { + context.destroy(); + } } catch (GLException gle) { gle.printStackTrace(); } @@ -204,13 +212,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { drawable.setRealized(false); drawable = null; } - // SWT is owner of the device handle, not us. - // Hence close() operation is a NOP. if (null != device) { device.close(); device = null; } - SWTAccessor.setRealized(GLCanvas.this, false); // unrealize .. if (animatorPaused) { animator.resume(); @@ -235,7 +240,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final RecursiveLock _lock = lock; _lock.lock(); try { - listener = helper.disposeGLEventListener(GLCanvas.this, drawable, context, listener, remove); + if( !GLCanvas.this.isDisposed() ) { + listener = helper.disposeGLEventListener(GLCanvas.this, drawable, context, listener, remove); + } } finally { _lock.unlock(); } @@ -326,7 +333,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ addPaintListener(new PaintListener() { - @Override + @Override public void paintControl(final PaintEvent arg0) { if ( !helper.isAnimatorAnimatingOnOtherThread() ) { display(); // checks: null != drawable @@ -334,12 +341,23 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } }); - addControlListener(new ControlAdapter() { + addControlListener(new ControlListener() { + @Override + public void controlMoved(ControlEvent e) { + } + @Override public void controlResized(final ControlEvent arg0) { updateSizeCheck(); } }); + + addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + GLCanvas.this.dispose(); + } + }); } private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() { @Override @@ -684,8 +702,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void dispose() { - runInGLThread(disposeOnEDTGLAction); - super.dispose(); + runInGLThread(disposeOnEDTGLAction); + super.dispose(); } /** @@ -694,22 +712,39 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { *
  • Mac OSX *
      * - *
    • Main Thread: Run on OSX UI main thread.
    • + * + *
    • Current thread
    • *
  • *
  • Linux, Windows, .. *
      - *
    • Use {@link Threading#invokeOnOpenGLThread(boolean, Runnable)}
    • + * + *
    • Current thread
    • *
  • * + * The current thread seems to be valid for all platforms, + * since no SWT lifecycle tasks are being performed w/ this call. + * Only GL task, which are independent from the SWT threading model. + * * @see Platform#AWT_AVAILABLE * @see Platform#getOSType() */ - private static void runInGLThread(final Runnable action) { + private void runInGLThread(final Runnable action) { + /** if(Platform.OSType.MACOS == Platform.OS_TYPE) { SWTAccessor.invoke(true, action); } else { Threading.invokeOnOpenGLThread(true, action); - } + } */ + /** + if( !isDisposed() ) { + final Display d = getDisplay(); + if( d.getThread() == Thread.currentThread() ) { + action.run(); + } else { + d.syncExec(action); + } + } */ + action.run(); } public static void main(final String[] args) { -- cgit v1.2.3 From 0bb202f2883e1eb82256140f13310046f7b13c62 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 29 Nov 2012 18:21:02 +0100 Subject: Bug628: Adding unit-test 'TestNewtCanvasSWTBug628ResizeDeadlock' exposing NewtCanvasSWT asyncExec(..) bug w/ native parenting The unit test shows, that while using JOGL's SWT GLCanvas Display's asyncExec(..) works properly, but w/ NewtCanvasSWT on Windows does not. NewtCanvasSWT differs w/: - Using native parenting [Newt GLWindow to SWT Canvas] - Processing native events in own NEWT EDT, w/ own Windows dispatch hook [For the child GLWindow only] --- make/scripts/tests-x64.bat | 3 +- make/scripts/tests.sh | 3 +- .../swt/TestNewtCanvasSWTBug628ResizeDeadlock.java | 12 +- .../junit/jogl/swt/TestSWTBug643AsyncExec.java | 283 +++++++++++++++++++++ 4 files changed, 292 insertions(+), 9 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index f340af552..7a2946d31 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -54,9 +54,10 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2d8f3e1a8..0669efb37 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -370,9 +370,10 @@ function testawtswt() { # #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec $* # # newt.awt (testawt) diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java index 9c0762c12..834261d22 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java @@ -65,7 +65,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase; public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { - static int duration = 1000; + static int duration = 500; static class BigFlashingX implements GLEventListener { @@ -262,7 +262,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { shell = new Shell( display ); Assert.assertNotNull( shell ); shell.setLayout( new FillLayout() ); - composite = new Composite( shell, SWT.NONE ); + composite = new Composite( shell, SWT.NO_BACKGROUND ); composite.setLayout( new FillLayout() ); Assert.assertNotNull( composite ); }}); @@ -301,10 +301,9 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { dsc.init(); final GLWindow glWindow; - final NewtCanvasSWT canvas; { final GLProfile gl2Profile = GLProfile.get( GLProfile.GL2 ) ; - GLCapabilities caps = new GLCapabilities( gl2Profile ) ; + final GLCapabilities caps = new GLCapabilities( gl2Profile ) ; glWindow = GLWindow.create( caps ) ; glWindow.addGLEventListener( new BigFlashingX() ) ; glWindow.addKeyListener(new KeyAdapter() { @@ -314,7 +313,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { glWindow.display(); } }); - canvas = NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ; + NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ; } dsc.display.syncExec( new Runnable() { @@ -374,8 +373,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { Assert.assertTrue("Deadlock @ dispatch: "+e0, false); } - System.err.println("NewtCanvasAWT Dispose"); - canvas.dispose(); + // canvas is disposed implicit, due to it's disposed listener ! dsc.dispose(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java new file mode 100644 index 000000000..ccea76c02 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java @@ -0,0 +1,283 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.swt; + +import java.awt.AWTException; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.swt.SWT ; + +import org.eclipse.swt.layout.FillLayout ; + +import org.eclipse.swt.widgets.Composite ; +import org.eclipse.swt.widgets.Display ; +import org.eclipse.swt.widgets.Shell ; +import org.junit.Assume; +import org.junit.Test; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities ; +import javax.media.opengl.GLProfile; + +import junit.framework.Assert; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.newt.opengl.GLWindow ; +import com.jogamp.newt.swt.NewtCanvasSWT ; +import com.jogamp.opengl.swt.GLCanvas; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; + +//////////////////////////////////////////////////////////////////////////////// + + +public class TestSWTBug643AsyncExec extends UITestCase { + + static int duration = 500; + + //////////////////////////////////////////////////////////////////////////////// + + static void resetAsyncExecCount() { + synchronized(asyncExecCountSync) { + asyncExecCount=0; + } + } + static int incrAsyncExecCount() { + synchronized(asyncExecCountSync) { + asyncExecCount++; + return asyncExecCount; + } + } + static int getAsyncExecCount() { + synchronized(asyncExecCountSync) { + return asyncExecCount; + } + } + static Object asyncExecCountSync = new Object(); + static int asyncExecCount = 0; + + //////////////////////////////////////////////////////////////////////////////// + + static class AsyncExecFeederThread extends Thread { + volatile boolean shallStop = false; + private Display display ; + private int n ; + + public AsyncExecFeederThread( Display display ) + { + super(); + this.display = display ; + } + + final Runnable asyncAction = new Runnable() { + public void run() + { + ++n ; + System.err.println("[A-i shallStop "+shallStop+", disposed "+display.isDisposed()+"]: Counter[loc "+n+", glob: "+incrAsyncExecCount()+"]"); + } }; + + public void run() + { + System.err.println("[A-0 shallStop "+shallStop+", disposed "+display.isDisposed()+"]"); + + // final Display d = Display.getDefault(); + final Display d = this.display; + + while( !shallStop && !d.isDisposed() ) + { + try + { + System.err.println("[A-n shallStop "+shallStop+", disposed "+d.isDisposed()+"]"); + d.asyncExec( asyncAction ); + d.wake(); + + Thread.sleep( 50L ) ; + } catch( InterruptedException e ) { + break ; + } + } + System.err.println("*R-Exit* shallStop "+shallStop+", disposed "+d.isDisposed()); + } + } + + //////////////////////////////////////////////////////////////////////////////// + + private volatile boolean shallStop = false; + + static class SWT_DSC { + Display display; + Shell shell; + Composite composite; + + public void init() { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + }}); + + display.syncExec(new Runnable() { + public void run() { + shell = new Shell( display ); + Assert.assertNotNull( shell ); + shell.setLayout( new FillLayout() ); + composite = new Composite( shell, SWT.NO_BACKGROUND ); + composite.setLayout( new FillLayout() ); + Assert.assertNotNull( composite ); + }}); + } + + public void dispose() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell ); + Assert.assertNotNull( composite ); + try { + display.syncExec(new Runnable() { + public void run() { + composite.dispose(); + shell.dispose(); + }}); + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display.dispose(); + }}); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + display = null; + shell = null; + composite = null; + } + } + + private void testImpl(boolean useJOGLGLCanvas, boolean useNewtCanvasSWT) throws InterruptedException, AWTException, InvocationTargetException { + resetAsyncExecCount(); + + final SWT_DSC dsc = new SWT_DSC(); + dsc.init(); + + { + final GLProfile gl2Profile = GLProfile.get( GLProfile.GL2 ) ; + final GLCapabilities caps = new GLCapabilities( gl2Profile ) ; + + final GLAutoDrawable glad; + if( useJOGLGLCanvas ) { + glad = GLCanvas.create(dsc.composite, 0, caps, null, null); + } else if( useNewtCanvasSWT ) { + final GLWindow glWindow = GLWindow.create( caps ) ; + glad = glWindow; + NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ; + } else { + throw new InternalError("XXX"); + } + glad.addGLEventListener( new GearsES2() ) ; + } + + dsc.display.syncExec( new Runnable() { + public void run() { + dsc.shell.setText( "NewtCanvasSWT Resize Bug Demo" ) ; + dsc.shell.setSize( 400, 450 ) ; + dsc.shell.open() ; + } } ); + + shallStop = false; + + final int[] ayncExecCountBeforeExit = new int[] { 0 }; + + final AsyncExecFeederThread asyncExecFeeder; + { + asyncExecFeeder = new AsyncExecFeederThread( dsc.display) ; + asyncExecFeeder.start() ; + } + + { + new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(duration); + } catch (InterruptedException e) {} + + ayncExecCountBeforeExit[0] = getAsyncExecCount(); + asyncExecFeeder.shallStop = true; + try + { + asyncExecFeeder.join(); + } catch( InterruptedException e ) { } + shallStop = true; + dsc.display.wake(); + } } ).start(); + } + + try { + final Display d = dsc.display; + while( !shallStop && !d.isDisposed() ) { + final boolean r = d.readAndDispatch(); + System.err.print(","); + if( !r ) { + dsc.display.sleep(); + } + } + } catch (Exception e0) { + e0.printStackTrace(); + Assert.assertTrue("Deadlock @ dispatch: "+e0, false); + } + + // canvas is disposed implicit, due to it's disposed listener ! + + dsc.dispose(); + + System.err.println("AsyncExecCount before exit: " + ayncExecCountBeforeExit[0]); + Assert.assertTrue("AsyncExecCount not greater zero before dispose!", 0 < ayncExecCountBeforeExit[0]); + } + + @Test + public void test01JOGLGLCanvas() throws InterruptedException, AWTException, InvocationTargetException { + testImpl(true /* useJOGLGLCanvas */, false /* useNewtCanvasSWT */); + } + + @Test + public void test02NewtCanvasSWT() throws InterruptedException, AWTException, InvocationTargetException { + testImpl(false /* useJOGLGLCanvas */, true /* useNewtCanvasSWT */); + } + + public static void main( String[] args ) { + for(int i=0; i Date: Sun, 2 Dec 2012 04:14:30 +0100 Subject: SWT GLCanvas/NewtCanvasSWT: Check isVisible() @ validation; NewtCanvasSWT remove just introduced setVisible(false) and adapt to setEDTUtil() changes. ; Enhance Bug 643 unit test: Also test NEWT EDT and pre-visible GLWindow. - SWT GLCanvas/NewtCanvasSWT: Check isVisible() @ validation - NewtCanvasSWT remove just introduced setVisible(false) and adapt to setEDTUtil() changes - Enhance Bug 643 unit test: Also test NEWT EDT and pre-visible GLWindow. --- make/scripts/java-win64-dbg.bat | 1 + .../classes/com/jogamp/opengl/swt/GLCanvas.java | 2 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 15 +-- .../swt/TestNewtCanvasSWTBug628ResizeDeadlock.java | 6 +- .../junit/jogl/swt/TestSWTBug643AsyncExec.java | 150 ++++++++++++++------- 5 files changed, 114 insertions(+), 60 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index c7e8ea599..7ececa5e4 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -46,6 +46,7 @@ REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djo REM set D_ARGS="-Djogl.debug.GLContext" "-Dnewt.debug=all" REM set D_ARGS="-Dnewt.debug.Window" "-Dnativewindow.debug.TraceLock" REM set D_ARGS="-Dnativewindow.debug.TraceLock" +REM set D_ARGS="-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Djogl.debug.GLContext" REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.EDT" "-Dnativewindow.debug=all" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 38dd71f5e..a080a7045 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -423,7 +423,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /** assumes drawable == null ! */ protected final boolean validateDrawableAndContext() { - if( GLCanvas.this.isDisposed() ) { + if( isDisposed() || !isVisible() ) { return false; } final Rectangle nClientArea = clientArea; diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 18036b68b..5af7afeb3 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -171,7 +171,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { /** assumes nativeWindow == null ! */ protected final boolean validateNative() { - if( isDisposed() ) { + if( isDisposed() || !isVisible() ) { return false; } updateSizeCheck(); @@ -347,22 +347,19 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { updateSizeCheck(); final int w = clientArea.width; final int h = clientArea.height; - + // set SWT EDT and start it { final Display newtDisplay = newtChild.getScreen().getDisplay(); - final EDTUtil edt = new SWTEDTUtil(newtDisplay, getDisplay()); - newtDisplay.setEDTUtil(edt); - edt.invoke(true, null); // start EDT + newtDisplay.setEDTUtil( new SWTEDTUtil(newtDisplay, getDisplay()) ); } - newtChild.setVisible(false); // set invisible to force defineSize(w,h) in WindowImpl since event dispatching might be postponed - newtChild.setSize(w, h); + newtChild.setSize(w, h); newtChild.reparentWindow(nativeWindow); newtChild.setVisible(true); - configureNewtChild(true); + configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener - + // force this SWT Canvas to be focus-able, // since it is completely covered by the newtChild (z-order). setEnabled(true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java index 834261d22..a0874e609 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java @@ -341,7 +341,7 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { } { - new Thread(new Runnable() { + final Thread t = new Thread(new Runnable() { @Override public void run() { try { @@ -359,7 +359,9 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { } catch( InterruptedException e ) { } shallStop = true; dsc.display.wake(); - } } ).start(); + } } ); + t.setDaemon(true); + t.start(); } try { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java index ccea76c02..0a47b96eb 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java @@ -50,10 +50,13 @@ import junit.framework.Assert; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.opengl.GLWindow ; import com.jogamp.newt.swt.NewtCanvasSWT ; +import com.jogamp.newt.swt.SWTEDTUtil; import com.jogamp.opengl.swt.GLCanvas; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; //////////////////////////////////////////////////////////////////////////////// @@ -61,69 +64,93 @@ import com.jogamp.opengl.test.junit.util.UITestCase; public class TestSWTBug643AsyncExec extends UITestCase { static int duration = 500; + static boolean useAnimator = false; //////////////////////////////////////////////////////////////////////////////// - static void resetAsyncExecCount() { - synchronized(asyncExecCountSync) { - asyncExecCount=0; + static void resetSWTAndNEWTEDTCounter() { + synchronized(swtCountSync) { + swtCount=0; + } + synchronized(edtCountSync) { + edtCount=0; + } + } + static int incrSWTCount() { + synchronized(swtCountSync) { + swtCount++; + return swtCount; + } + } + static int getSWTCount() { + synchronized(swtCountSync) { + return swtCount; } } - static int incrAsyncExecCount() { - synchronized(asyncExecCountSync) { - asyncExecCount++; - return asyncExecCount; + static int incrNEWTCount() { + synchronized(edtCountSync) { + edtCount++; + return edtCount; } } - static int getAsyncExecCount() { - synchronized(asyncExecCountSync) { - return asyncExecCount; + static int getNEWTCount() { + synchronized(edtCountSync) { + return edtCount; } } - static Object asyncExecCountSync = new Object(); - static int asyncExecCount = 0; + static Object swtCountSync = new Object(); + static int swtCount = 0; + static Object edtCountSync = new Object(); + static int edtCount = 0; //////////////////////////////////////////////////////////////////////////////// - static class AsyncExecFeederThread extends Thread { + static class AsyncExecEDTFeederThread extends Thread { volatile boolean shallStop = false; - private Display display ; - private int n ; + private Display swtDisplay ; + private jogamp.newt.DisplayImpl newtDisplay; + private int swtN, newtN ; - public AsyncExecFeederThread( Display display ) + public AsyncExecEDTFeederThread( Display swtDisplay, com.jogamp.newt.Display newtDisplay ) { super(); - this.display = display ; + this.swtDisplay = swtDisplay ; + this.newtDisplay = (jogamp.newt.DisplayImpl)newtDisplay; } - final Runnable asyncAction = new Runnable() { + final Runnable swtAsyncAction = new Runnable() { public void run() { - ++n ; - System.err.println("[A-i shallStop "+shallStop+", disposed "+display.isDisposed()+"]: Counter[loc "+n+", glob: "+incrAsyncExecCount()+"]"); + ++swtN ; + System.err.println("[SWT A-i shallStop "+shallStop+"]: Counter[loc "+swtN+", glob: "+incrSWTCount()+"]"); + } }; + + final Runnable newtAsyncAction = new Runnable() { + public void run() + { + ++newtN ; + System.err.println("[NEWT A-i shallStop "+shallStop+"]: Counter[loc "+newtN+", glob: "+incrNEWTCount()+"]"); } }; public void run() { - System.err.println("[A-0 shallStop "+shallStop+", disposed "+display.isDisposed()+"]"); - - // final Display d = Display.getDefault(); - final Display d = this.display; + System.err.println("[A-0 shallStop "+shallStop+"]"); - while( !shallStop && !d.isDisposed() ) + while( !shallStop && !swtDisplay.isDisposed() ) { try { - System.err.println("[A-n shallStop "+shallStop+", disposed "+d.isDisposed()+"]"); - d.asyncExec( asyncAction ); - d.wake(); - + swtDisplay.asyncExec( swtAsyncAction ); + if(null != newtDisplay && newtDisplay.isNativeValid() && newtDisplay.getEDTUtil().isRunning()) { + // only perform async exec on valid and already running NEWT EDT! + newtDisplay.runOnEDTIfAvail(false, newtAsyncAction); + } Thread.sleep( 50L ) ; } catch( InterruptedException e ) { break ; } } - System.err.println("*R-Exit* shallStop "+shallStop+", disposed "+d.isDisposed()); + System.err.println("*R-Exit* shallStop "+shallStop); } } @@ -179,12 +206,13 @@ public class TestSWTBug643AsyncExec extends UITestCase { } } - private void testImpl(boolean useJOGLGLCanvas, boolean useNewtCanvasSWT) throws InterruptedException, AWTException, InvocationTargetException { - resetAsyncExecCount(); + private void testImpl(boolean useJOGLGLCanvas, boolean useNewtCanvasSWT, boolean glWindowPreVisible) throws InterruptedException, AWTException, InvocationTargetException { + resetSWTAndNEWTEDTCounter(); final SWT_DSC dsc = new SWT_DSC(); dsc.init(); + final com.jogamp.newt.Display newtDisplay; { final GLProfile gl2Profile = GLProfile.get( GLProfile.GL2 ) ; final GLCapabilities caps = new GLCapabilities( gl2Profile ) ; @@ -192,42 +220,58 @@ public class TestSWTBug643AsyncExec extends UITestCase { final GLAutoDrawable glad; if( useJOGLGLCanvas ) { glad = GLCanvas.create(dsc.composite, 0, caps, null, null); + glad.addGLEventListener( new GearsES2() ) ; + newtDisplay = null; } else if( useNewtCanvasSWT ) { final GLWindow glWindow = GLWindow.create( caps ) ; + glWindow.addGLEventListener( new GearsES2() ) ; + newtDisplay = glWindow.getScreen().getDisplay(); + if( glWindowPreVisible ) { + newtDisplay.setEDTUtil(new SWTEDTUtil(newtDisplay, dsc.display)); // Especially Windows requires creation access via same thread! + glWindow.setVisible(true); + AWTRobotUtil.waitForRealized(glWindow, true); + Thread.sleep(120); // let it render a bit, before consumed by SWT + } glad = glWindow; NewtCanvasSWT.create( dsc.composite, 0, glWindow ) ; } else { throw new InternalError("XXX"); } - glad.addGLEventListener( new GearsES2() ) ; + if(useAnimator) { + Animator animator = new Animator(glad); + animator.start(); + } } + System.err.println("**** Pre Shell Open"); dsc.display.syncExec( new Runnable() { public void run() { dsc.shell.setText( "NewtCanvasSWT Resize Bug Demo" ) ; dsc.shell.setSize( 400, 450 ) ; dsc.shell.open() ; } } ); + System.err.println("**** Post Shell Open"); shallStop = false; + + final int[] counterBeforeExit = new int[] { 0 /* SWT */, 0 /* NEWT */ }; - final int[] ayncExecCountBeforeExit = new int[] { 0 }; - - final AsyncExecFeederThread asyncExecFeeder; + final AsyncExecEDTFeederThread asyncExecFeeder; { - asyncExecFeeder = new AsyncExecFeederThread( dsc.display) ; + asyncExecFeeder = new AsyncExecEDTFeederThread(dsc.display, newtDisplay) ; asyncExecFeeder.start() ; } { - new Thread(new Runnable() { + final Thread t = new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(duration); } catch (InterruptedException e) {} - ayncExecCountBeforeExit[0] = getAsyncExecCount(); + counterBeforeExit[0] = getSWTCount(); + counterBeforeExit[1] = getNEWTCount(); asyncExecFeeder.shallStop = true; try { @@ -235,15 +279,15 @@ public class TestSWTBug643AsyncExec extends UITestCase { } catch( InterruptedException e ) { } shallStop = true; dsc.display.wake(); - } } ).start(); + } } ); + t.setDaemon(true); + t.start(); } try { final Display d = dsc.display; while( !shallStop && !d.isDisposed() ) { - final boolean r = d.readAndDispatch(); - System.err.print(","); - if( !r ) { + if( !d.readAndDispatch() ) { dsc.display.sleep(); } } @@ -256,24 +300,34 @@ public class TestSWTBug643AsyncExec extends UITestCase { dsc.dispose(); - System.err.println("AsyncExecCount before exit: " + ayncExecCountBeforeExit[0]); - Assert.assertTrue("AsyncExecCount not greater zero before dispose!", 0 < ayncExecCountBeforeExit[0]); + System.err.println("EDT Counter before exit: SWT " + counterBeforeExit[0] + ", NEWT "+counterBeforeExit[1]); + Assert.assertTrue("SWT EDT Counter not greater zero before dispose!", 0 < counterBeforeExit[0]); + if( null != newtDisplay ) { + Assert.assertTrue("NEWT EDT Counter not greater zero before dispose!", 0 < counterBeforeExit[1]); + } } @Test public void test01JOGLGLCanvas() throws InterruptedException, AWTException, InvocationTargetException { - testImpl(true /* useJOGLGLCanvas */, false /* useNewtCanvasSWT */); + testImpl(true /* useJOGLGLCanvas */, false /* useNewtCanvasSWT */, false /* glWindowPreVisible */); + } + + @Test + public void test02NewtCanvasSWTSimple() throws InterruptedException, AWTException, InvocationTargetException { + testImpl(false /* useJOGLGLCanvas */, true /* useNewtCanvasSWT */, false /* glWindowPreVisible */); } @Test - public void test02NewtCanvasSWT() throws InterruptedException, AWTException, InvocationTargetException { - testImpl(false /* useJOGLGLCanvas */, true /* useNewtCanvasSWT */); + public void test02NewtCanvasSWTPreVisible() throws InterruptedException, AWTException, InvocationTargetException { + testImpl(false /* useJOGLGLCanvas */, true /* useNewtCanvasSWT */, true /* glWindowPreVisible */); } public static void main( String[] args ) { for(int i=0; i Date: Tue, 4 Dec 2012 07:10:59 +0100 Subject: SWT GLCanvas: Fix sporadic drop of redraw on X11 _and_ allow using custom GLCapabilities on X11 (feature complete) To allow custom GLCapabilities, we had to use native parenting on X11 w/ a new child window. The desired visualID chosen by the users GLCapabilities is passed to the new child window. The redraw drops must be caused by the original GDK or the new child GDK window. Now we use a plain X11 child window similar to NEWT's X11 window and NewtCanvasSWT, which doesn't expose this bug. (Note: SWTAccessor/GLCanvas still contains the uncommented GDK code path for further inspection, if desired) Also added SWTNewtEventFactory to test event handling on the SWT GLCanvas w/ GearsES2. TestSWTJOGLGLCanvas01GLn tests custom GLCapabilities now. SWTEDTUtil has been moved to private: com.jogamp.newt.swt -> jogamp.newt.swt. --- make/build-common.xml | 1 + make/build-newt.xml | 2 +- make/config/nativewindow/x11-CustomJavaCode.java | 5 +- make/scripts/tests-x32.sh | 2 + make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 6 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 350 ++++++++++++++------- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 345 +++++++++++++------- .../x11/X11DummyUpstreamSurfaceHook.java | 4 +- src/nativewindow/native/x11/Xmisc.c | 123 +++++++- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 82 +++-- .../classes/com/jogamp/newt/swt/SWTEDTUtil.java | 313 ------------------ src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 313 ++++++++++++++++++ .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 249 +++++++++++++++ .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 8 +- .../swt/TestNewtCanvasSWTBug628ResizeDeadlock.java | 5 +- .../junit/jogl/swt/TestSWTBug643AsyncExec.java | 26 +- .../junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java | 16 +- 18 files changed, 1236 insertions(+), 618 deletions(-) delete mode 100644 src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java create mode 100644 src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java create mode 100644 src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java (limited to 'make/scripts') diff --git a/make/build-common.xml b/make/build-common.xml index a718ae09a..414b0eba2 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -428,6 +428,7 @@ + diff --git a/make/build-newt.xml b/make/build-newt.xml index 7b9a51863..c3b51141f 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -112,7 +112,7 @@ value="com/jogamp/newt/awt/** com/jogamp/newt/event/awt/** jogamp/newt/awt/** ${java.part.driver.awt}"/> + value="com/jogamp/newt/swt/** jogamp/newt/swt/**"/> diff --git a/make/config/nativewindow/x11-CustomJavaCode.java b/make/config/nativewindow/x11-CustomJavaCode.java index 8e5da3b2d..4240c5e2f 100644 --- a/make/config/nativewindow/x11-CustomJavaCode.java +++ b/make/config/nativewindow/x11-CustomJavaCode.java @@ -28,8 +28,9 @@ public static native int DefaultVisualID(long display, int screen); - public static native long CreateDummyWindow(long display, int screen_index, int visualID, int width, int height); - public static native void DestroyDummyWindow(long display, long window); + public static native long CreateWindow(long parent, long display, int screen_index, int visualID, int width, int height, boolean input, boolean visible); + public static native void DestroyWindow(long display, long window); + public static native void SetWindowPosSize(long display, long window, int x, int y, int width, int height); public static Point GetRelativeLocation(long display, int screen_index, long src_win, long dest_win, int src_x, int src_y) { return (Point) GetRelativeLocation0(display, screen_index, src_win, dest_win, src_x, src_y); diff --git a/make/scripts/tests-x32.sh b/make/scripts/tests-x32.sh index a3aed84c3..858ed5fd8 100755 --- a/make/scripts/tests-x32.sh +++ b/make/scripts/tests-x32.sh @@ -6,6 +6,8 @@ if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh ] ; then . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh fi +export SWT_CLASSPATH=`pwd`/lib/swt/gtk-linux-x86/swt-debug.jar + . $SDIR/tests.sh `which java` -d32 ../build-x86 $* diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 7a2946d31..db7e27264 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -54,10 +54,10 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0669efb37..628ab706b 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -113,7 +113,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow" - #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT" + D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -370,10 +370,10 @@ function testawtswt() { # #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock $* -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec $* # # newt.awt (testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index a080a7045..0320c63ae 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -29,10 +29,16 @@ package com.jogamp.opengl.swt; import java.util.List; +import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.UpstreamSurfaceHook; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.opengl.GL; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; @@ -48,23 +54,20 @@ import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import javax.media.opengl.Threading; +import jogamp.nativewindow.x11.X11Util; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableHelper; import jogamp.opengl.GLDrawableImpl; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ControlEvent; -import org.eclipse.swt.events.ControlListener; -import org.eclipse.swt.events.DisposeEvent; -import org.eclipse.swt.events.DisposeListener; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import com.jogamp.common.GlueGenVersion; @@ -73,13 +76,14 @@ import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.opengl.JoglVersion; /** * Native SWT Canvas implementing GLAutoDrawable - * - *

    Note: To employ custom GLCapabilities, NewtCanvasSWT shall be used instead.

    - * + *

    + * Implementation allows use of custom {@link GLCapabilities}. + *

    */ public class GLCanvas extends Canvas implements GLAutoDrawable { private static final boolean DEBUG = Debug.debug("GLCanvas"); @@ -103,11 +107,15 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final GLCapabilitiesImmutable capsRequested; private final GLCapabilitiesChooser capsChooser; + private volatile Rectangle clientArea; private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access - private GLContextImpl context; + private volatile GLContextImpl context; /* Native window surface */ - private AbstractGraphicsDevice device; + private final boolean useX11GTK; + private volatile long gdkWindow; // either GDK child window .. + private volatile long x11Window; // .. or X11 child window (for GL rendering) + private final AbstractGraphicsScreen screen; /* Construction parameters stored for GLAutoDrawable accessor methods */ private int additionalCtxCreationFlags = 0; @@ -135,7 +143,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void run() { if (sendReshape) { - helper.reshape(GLCanvas.this, 0, 0, getWidth(), getHeight()); + helper.reshape(GLCanvas.this, 0, 0, clientArea.width, clientArea.height); sendReshape = false; } helper.display(GLCanvas.this); @@ -143,7 +151,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }; /* Action to make specified context current prior to running displayAction */ - private final Runnable makeCurrentAndDisplayOnEDTAction = new Runnable() { + private final Runnable makeCurrentAndDisplayOnGLAction = new Runnable() { @Override public void run() { final RecursiveLock _lock = lock; @@ -159,13 +167,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { }; /* Swaps buffers, assuming the GLContext is current */ - private final Runnable swapBuffersOnEDTAction = new Runnable() { + private final Runnable swapBuffersOnGLAction = new Runnable() { @Override public void run() { final RecursiveLock _lock = lock; _lock.lock(); try { - if(null != drawable && !GLCanvas.this.isDisposed() ) { + final boolean drawableOK = null != drawable && drawable.isRealized(); + if( drawableOK && !GLCanvas.this.isDisposed() ) { drawable.swapBuffers(); } } finally { @@ -212,10 +221,14 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { drawable.setRealized(false); drawable = null; } - if (null != device) { - device.close(); - device = null; + if( 0 != x11Window) { + SWTAccessor.destroyX11Window(screen.getDevice(), x11Window); + x11Window = 0; + } else if( 0 != gdkWindow) { + SWTAccessor.destroyGDKWindow(gdkWindow); + gdkWindow = 0; } + screen.getDevice().close(); if (animatorPaused) { animator.resume(); @@ -249,11 +262,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } }; - /** - * Storage for the client area rectangle so that it may be accessed from outside of the SWT thread. - */ - private volatile Rectangle clientArea; - /** * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} * on the SWT thread. @@ -293,72 +301,80 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * @param style * Optional SWT style bit-field. The {@link SWT#NO_BACKGROUND} bit is set before passing this up to the * Canvas constructor, so OpenGL handles the background. - * @param caps + * @param capsReqUser * Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the * graphics device determined by the parent Composite are used. Note that the GLCapabilities that are * actually used may differ based on the capabilities of the graphics device. - * @param chooser + * @param capsChooser * Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the * requested GLCapabilities, and the available capabilities of the graphics device. * @param shareWith * Optional GLContext to share state (textures, vbos, shaders, etc.) with. */ - public GLCanvas(final Composite parent, final int style, GLCapabilitiesImmutable caps, - final GLCapabilitiesChooser chooser, final GLContext shareWith) { + public GLCanvas(final Composite parent, final int style, GLCapabilitiesImmutable capsReqUser, + final GLCapabilitiesChooser capsChooser, final GLContext shareWith) { /* NO_BACKGROUND required to avoid clearing bg in native SWT widget (we do this in the GL display) */ super(parent, style | SWT.NO_BACKGROUND); GLProfile.initSingleton(); // ensure JOGL is completly initialized SWTAccessor.setRealized(this, true); - + clientArea = GLCanvas.this.getClientArea(); /* Get the nativewindow-Graphics Device associated with this control (which is determined by the parent Composite). * Note: SWT is owner of the native handle, hence closing operation will be a NOP. */ - device = SWTAccessor.getDevice(this); + final AbstractGraphicsDevice swtDevice = SWTAccessor.getDevice(this); + + useX11GTK = SWTAccessor.useX11GTK(); + if(useX11GTK) { + // Decoupled X11 Device/Screen allowing X11 display lock-free off-thread rendering + final long x11DeviceHandle = X11Util.openDisplay(swtDevice.getConnection()); + if( 0 == x11DeviceHandle ) { + throw new RuntimeException("Error creating display(EDT): "+swtDevice.getConnection()); + } + final AbstractGraphicsDevice x11Device = new X11GraphicsDevice(x11DeviceHandle, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); + screen = SWTAccessor.getScreen(x11Device, -1 /* default */); + } else { + screen = SWTAccessor.getScreen(swtDevice, -1 /* default */); + } /* Select default GLCapabilities if none was provided, otherwise clone provided caps to ensure safety */ - if(null == caps) { - caps = new GLCapabilities(GLProfile.getDefault(device)); + if(null == capsReqUser) { + capsReqUser = new GLCapabilities(GLProfile.getDefault(screen.getDevice())); } - this.capsRequested = caps; - this.capsChooser = chooser; + + this.capsRequested = capsReqUser; + this.capsChooser = capsChooser; this.shareWith = shareWith; // post create .. when ready + gdkWindow = 0; + x11Window = 0; drawable = null; context = null; - /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ - /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ - addPaintListener(new PaintListener() { - @Override - public void paintControl(final PaintEvent arg0) { - if ( !helper.isAnimatorAnimatingOnOtherThread() ) { - display(); // checks: null != drawable - } - } - }); - - addControlListener(new ControlListener() { - @Override - public void controlMoved(ControlEvent e) { - } - - @Override - public void controlResized(final ControlEvent arg0) { - updateSizeCheck(); - } - }); - - addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - GLCanvas.this.dispose(); - } - }); + final Listener listener = new Listener () { + @Override + public void handleEvent (Event event) { + switch (event.type) { + case SWT.Paint: + displayIfNoAnimatorNoCheck(); + break; + case SWT.Resize: + updateSizeCheck(); + break; + case SWT.Dispose: + GLCanvas.this.dispose(); + break; + } + } + }; + addListener (SWT.Resize, listener); + addListener (SWT.Paint, listener); + addListener (SWT.Dispose, listener); } + private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() { @Override public final void create(ProxySurface s) { /* nop */ } @@ -390,11 +406,13 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { ) { clientArea = nClientArea; // write back new value - GLDrawableImpl _drawable = drawable; - if( null != _drawable ) { - if(DEBUG) { - System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+nClientArea.width+"x"+nClientArea.height+" - surfaceHandle 0x"+Long.toHexString(getNativeSurface().getSurfaceHandle())); - } + final GLDrawableImpl _drawable = drawable; + final boolean drawableOK = null != _drawable && _drawable.isRealized(); + if(DEBUG) { + final long dh = drawableOK ? _drawable.getHandle() : 0; + System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+nClientArea.x+"/"+nClientArea.y+" "+nClientArea.width+"x"+nClientArea.height+" - drawableHandle 0x"+Long.toHexString(dh)); + } + if( drawableOK ) { if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { final RecursiveLock _lock = lock; _lock.lock(); @@ -407,66 +425,154 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } finally { _lock.unlock(); } - } - sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock - } + } + } + if(0 != x11Window) { + SWTAccessor.resizeX11Window(screen.getDevice(), clientArea, x11Window); + } else if(0 != gdkWindow) { + SWTAccessor.resizeGDKWindow(clientArea, gdkWindow); + } + sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock } } - @Override - public void display() { - if( null != drawable || validateDrawableAndContext() ) { - runInGLThread(makeCurrentAndDisplayOnEDTAction); - } + private boolean isValidAndVisibleOnEDTActionResult; + private final Runnable isValidAndVisibleOnEDTAction = new Runnable() { + @Override + public void run() { + isValidAndVisibleOnEDTActionResult = !GLCanvas.this.isDisposed() && GLCanvas.this.isVisible(); + } }; + + private final boolean isValidAndVisibleOnEDT() { + synchronized(isValidAndVisibleOnEDTAction) { + runOnEDTIfAvail(true, isValidAndVisibleOnEDTAction); + return isValidAndVisibleOnEDTActionResult; + } } - - /** assumes drawable == null ! */ - protected final boolean validateDrawableAndContext() { - if( isDisposed() || !isVisible() ) { + /** assumes drawable == null || !drawable.isRealized() ! Checks of !isDispose() and isVisible() */ + protected final boolean validateDrawableAndContextWithCheck() { + if( !isValidAndVisibleOnEDT() ) { return false; } + return validateDrawableAndContextPostCheck(); + } + + /** assumes drawable == null || !drawable.isRealized() ! No check of !isDispose() and isVisible() */ + protected final boolean validateDrawableAndContextPostCheck() { final Rectangle nClientArea = clientArea; if(0 >= nClientArea.width || 0 >= nClientArea.height) { return false; } + final boolean res; final RecursiveLock _lock = lock; _lock.lock(); try { - final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); - - /* Native handle for the control, used to associate with GLContext */ - final long nativeWindowHandle = SWTAccessor.getWindowHandle(this); - - /* Create a NativeWindow proxy for the SWT canvas */ - ProxySurface proxySurface = null; - try { - proxySurface = glFactory.createProxySurface(device, 0 /* screenIdx */, nativeWindowHandle, - capsRequested, capsChooser, swtCanvasUpStreamHook); - } catch (GLException gle) { - // not ready yet .. - if(DEBUG) { System.err.println(gle.getMessage()); } + if(null == drawable) { + createDrawableAndContext(); } - - if(null != proxySurface) { - /* Associate a GL surface with the proxy */ - drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); + if(null != drawable) { drawable.setRealized(true); - - context = (GLContextImpl) drawable.createContext(shareWith); + res = drawable.isRealized(); + } else { + res = false; } } finally { _lock.unlock(); + } + + if(res) { + sendReshape = true; + if(DEBUG) { + System.err.println("SWT GLCanvas realized! "+this+", "+drawable); + // Thread.dumpStack(); + } } - final boolean res = null != drawable; - if(DEBUG && res) { - System.err.println("SWT GLCanvas realized! "+this+", "+drawable); - Thread.dumpStack(); - } - return res; + return res; + } + + private final void createDrawableAndContext() { + final AbstractGraphicsDevice device = screen.getDevice(); + device.open(); + + final long nativeWindowHandle; + if( useX11GTK ) { + final GraphicsConfigurationFactory factory = GraphicsConfigurationFactory.getFactory(device, capsRequested); + final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( + capsRequested, capsRequested, capsChooser, screen, VisualIDHolder.VID_UNDEFINED); + if(DEBUG) { + System.err.println("SWT.GLCanvas.X11 factory: "+factory+", chosen config: "+cfg); + } + if (null == cfg) { + throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); + } + final int visualID = cfg.getVisualID(VIDType.NATIVE); + if( VisualIDHolder.VID_UNDEFINED != visualID ) { + // gdkWindow = SWTAccessor.createCompatibleGDKChildWindow(this, visualID, clientArea.width, clientArea.height); + // nativeWindowHandle = SWTAccessor.gdk_window_get_xwindow(gdkWindow); + x11Window = SWTAccessor.createCompatibleX11ChildWindow(screen, this, visualID, clientArea.width, clientArea.height); + nativeWindowHandle = x11Window; + } else { + throw new GLException("Could not choose valid visualID: 0x"+Integer.toHexString(visualID)+", "+this); + } + } else { + nativeWindowHandle = SWTAccessor.getWindowHandle(this); + } + final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(capsRequested.getGLProfile()); + + // Create a NativeWindow proxy for the SWT canvas + ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle, + capsRequested, capsChooser, swtCanvasUpStreamHook); + // Associate a GL surface with the proxy + drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); + context = (GLContextImpl) drawable.createContext(shareWith); + context.setContextCreationFlags(additionalCtxCreationFlags); + } + + @Override + public void update() { + // don't paint background etc .. nop avoids flickering + // super.update(); + } + + /** + @Override + public boolean forceFocus() { + final boolean r = super.forceFocus(); + if(r && 0 != gdkWindow) { + SWTGTKUtil.focusGDKWindow(gdkWindow); + } + return r; + } */ + + @Override + public void dispose() { + runInGLThread(disposeOnEDTGLAction); + super.dispose(); + } + + private final void displayIfNoAnimatorNoCheck() { + if ( !helper.isAnimatorAnimatingOnOtherThread() ) { + final boolean drawableOK = null != drawable && drawable.isRealized(); + if( drawableOK || validateDrawableAndContextPostCheck() ) { + runInGLThread(makeCurrentAndDisplayOnGLAction); + } + } } + // + // GL[Auto]Drawable + // + + @Override + public void display() { + final boolean drawableOK = null != drawable && drawable.isRealized(); + if( drawableOK || validateDrawableAndContextWithCheck() ) { + runInGLThread(makeCurrentAndDisplayOnGLAction); + } + } + @Override public final Object getUpstreamWidget() { return this; @@ -692,18 +798,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void swapBuffers() throws GLException { - runInGLThread(swapBuffersOnEDTAction); - } - - @Override - public void update() { - // don't paint background etc .. nop avoids flickering - } - - @Override - public void dispose() { - runInGLThread(disposeOnEDTGLAction); - super.dispose(); + runInGLThread(swapBuffersOnGLAction); } /** @@ -746,7 +841,32 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } */ action.run(); } + + private void runOnEDTIfAvail(boolean wait, final Runnable action) { + final Display d = isDisposed() ? null : getDisplay(); + if( null == d || d.isDisposed() || d.getThread() == Thread.currentThread() ) { + action.run(); + } else if(wait) { + d.syncExec(action); + } else { + d.asyncExec(action); + } + } + + @Override + public String toString() { + final GLDrawable _drawable = drawable; + final int dw = (null!=_drawable) ? _drawable.getWidth() : -1; + final int dh = (null!=_drawable) ? _drawable.getHeight() : -1; + return "SWT-GLCanvas[Realized "+isRealized()+ + ",\n\t"+((null!=_drawable)?_drawable.getClass().getName():"null-drawable")+ + ",\n\tFactory "+getFactory()+ + ",\n\thandle 0x"+Long.toHexString(getHandle())+ + ",\n\tDrawable size "+dw+"x"+dh+ + ",\n\tSWT size "+getWidth()+"x"+getHeight()+"]"; + } + public static void main(final String[] args) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index e208cfb28..eba26c7d3 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -34,6 +34,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; import org.eclipse.swt.graphics.GCData; +import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Control; import javax.media.nativewindow.AbstractGraphicsScreen; @@ -59,12 +60,22 @@ public class SWTAccessor { private static final Field swt_control_handle; private static final boolean swt_uses_long_handles; + private static Object swt_osx_init = new Object(); + private static Field swt_osx_control_view = null; + private static Field swt_osx_view_id = null; + + private static final String nwt; + private static final boolean isOSX; + private static final boolean isWindows; + private static final boolean isX11; + private static final boolean isX11GTK; + // X11/GTK, Windows/GDI, .. private static final String str_handle = "handle"; // OSX/Cocoa - private static final String str_view = "view"; // OSX - private static final String str_id = "id"; // OSX + private static final String str_osx_view = "view"; // OSX + private static final String str_osx_id = "id"; // OSX // static final String str_NSView = "org.eclipse.swt.internal.cocoa.NSView"; private static final Method swt_control_internal_new_GC; @@ -73,9 +84,10 @@ public class SWTAccessor { private static final String str_internal_dispose_GC = "internal_dispose_GC"; private static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS"; - private static final Class OS_gtk_class; + public static final Class OS_gtk_class; private static final String str_OS_gtk_version = "GTK_VERSION"; - private static final VersionNumber OS_gtk_version; + public static final VersionNumber OS_gtk_version; + private static final Method OS_gtk_widget_realize; private static final Method OS_gtk_widget_unrealize; // optional (removed in SWT 4.3) private static final Method OS_GTK_WIDGET_WINDOW; @@ -85,6 +97,8 @@ public class SWTAccessor { private static final Method OS_gdk_window_get_display; private static final Method OS_gdk_x11_drawable_get_xid; private static final Method OS_gdk_x11_window_get_xid; + private static final Method OS_gdk_window_set_back_pixmap; + private static final String str_gtk_widget_realize = "gtk_widget_realize"; private static final String str_gtk_widget_unrealize = "gtk_widget_unrealize"; private static final String str_GTK_WIDGET_WINDOW = "GTK_WIDGET_WINDOW"; @@ -94,6 +108,7 @@ public class SWTAccessor { private static final String str_gdk_window_get_display = "gdk_window_get_display"; private static final String str_gdk_x11_drawable_get_xid = "gdk_x11_drawable_get_xid"; private static final String str_gdk_x11_window_get_xid = "gdk_x11_window_get_xid"; + private static final String str_gdk_window_set_back_pixmap = "gdk_window_set_back_pixmap"; private static final VersionNumber GTK_VERSION_2_14_0 = new VersionNumber(2, 14, 0); private static final VersionNumber GTK_VERSION_2_24_0 = new VersionNumber(2, 24, 0); @@ -108,23 +123,25 @@ public class SWTAccessor { } static { - Field f = null; - AccessController.doPrivileged(new PrivilegedAction() { public Object run() { NativeWindowFactory.initSingleton(); // last resort .. return null; } } ); - final String nwt = NativeWindowFactory.getNativeWindowType(false); - - if(NativeWindowFactory.TYPE_MACOSX != nwt ) { + nwt = NativeWindowFactory.getNativeWindowType(false); + isOSX = NativeWindowFactory.TYPE_MACOSX == nwt; + isWindows = NativeWindowFactory.TYPE_WINDOWS == nwt; + isX11 = NativeWindowFactory.TYPE_X11 == nwt; + + Field f = null; + if( !isOSX ) { try { f = Control.class.getField(str_handle); } catch (Exception ex) { throw new NativeWindowException(ex); } - } + } swt_control_handle = f; // maybe null ! boolean ulh; @@ -158,31 +175,32 @@ public class SWTAccessor { Class c=null; VersionNumber _gtk_version = new VersionNumber(0, 0, 0); - Method m1=null, m2=null, m3=null, m4=null, m5=null, m6=null, m7=null, m8=null, m9=null; - Class handleType = swt_uses_long_handles ? long.class : int.class ; - if( NativeWindowFactory.TYPE_X11 == nwt ) { + Method m1=null, m2=null, m3=null, m4=null, m5=null, m6=null, m7=null, m8=null, m9=null, ma=null; + final Class handleType = swt_uses_long_handles ? long.class : int.class ; + if( isX11 ) { // mandatory try { c = ReflectionUtil.getClass(str_OS_gtk_class, false, SWTAccessor.class.getClassLoader()); Field field_OS_gtk_version = c.getField(str_OS_gtk_version); _gtk_version = GTK_VERSION(field_OS_gtk_version.getInt(null)); m1 = c.getDeclaredMethod(str_gtk_widget_realize, handleType); - if( _gtk_version.compareTo(GTK_VERSION_2_14_0) < 0 ) { - m3 = c.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType); - } else { + if (_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) { m4 = c.getDeclaredMethod(str_gtk_widget_get_window, handleType); - } - if( _gtk_version.compareTo(GTK_VERSION_2_24_0) < 0 ) { - m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); } else { + m3 = c.getDeclaredMethod(str_GTK_WIDGET_WINDOW, handleType); + } + if (_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0) { m6 = c.getDeclaredMethod(str_gdk_x11_display_get_xdisplay, handleType); - m7 = c.getDeclaredMethod(str_gdk_window_get_display, handleType); - } - if( _gtk_version.compareTo(GTK_VERSION_3_0_0) < 0 ) { - m8 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xid, handleType); + m7 = c.getDeclaredMethod(str_gdk_window_get_display, handleType); } else { + m5 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xdisplay, handleType); + } + if (_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0) { m9 = c.getDeclaredMethod(str_gdk_x11_window_get_xid, handleType); + } else { + m8 = c.getDeclaredMethod(str_gdk_x11_drawable_get_xid, handleType); } + ma = c.getDeclaredMethod(str_gdk_window_set_back_pixmap, handleType, handleType, boolean.class); } catch (Exception ex) { throw new NativeWindowException(ex); } // optional try { @@ -200,25 +218,31 @@ public class SWTAccessor { OS_gdk_window_get_display = m7; OS_gdk_x11_drawable_get_xid = m8; OS_gdk_x11_window_get_xid = m9; + OS_gdk_window_set_back_pixmap = ma; + + isX11GTK = isX11 && null != OS_gtk_class; if(DEBUG) { System.err.println("SWTAccessor.: GTK Version: "+OS_gtk_version); } } - - - static Object getIntOrLong(long arg) { + + private static Number getIntOrLong(long arg) { if(swt_uses_long_handles) { return new Long(arg); } return new Integer((int) arg); } - static void callStaticMethodL2V(Method m, long arg) { + private static void callStaticMethodL2V(Method m, long arg) { ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) }); } - static long callStaticMethodL2L(Method m, long arg) { + private static void callStaticMethodLLZ2V(Method m, long arg0, long arg1, boolean arg3) { + ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg0), getIntOrLong(arg1), Boolean.valueOf(arg3) }); + } + + private static long callStaticMethodL2L(Method m, long arg) { Object o = ReflectionUtil.callMethod(null, m, new Object[] { getIntOrLong(arg) }); if(o instanceof Number) { return ((Number)o).longValue(); @@ -226,13 +250,73 @@ public class SWTAccessor { throw new InternalError("SWT method "+m.getName()+" didn't return int or long but "+o.getClass()); } } - + + // + // Public properties + // + public static boolean isUsingLongHandles() { return swt_uses_long_handles; } + public static boolean useX11GTK() { return isX11GTK; } public static VersionNumber GTK_VERSION() { return OS_gtk_version; } + // + // Common GTK + // + + public static long gdk_widget_get_window(long handle) { + final long window; + if (OS_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0) { + window = callStaticMethodL2L(OS_gtk_widget_get_window, handle); + } else { + window = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle); + } + if(0 == window) { + throw new NativeWindowException("Null gtk-window-handle of SWT handle 0x"+Long.toHexString(handle)); + } + return window; + } + + public static long gdk_window_get_xdisplay(long window) { + final long xdisplay; + if (OS_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0) { + final long display = callStaticMethodL2L(OS_gdk_window_get_display, window); + if(0 == display) { + throw new NativeWindowException("Null display-handle of gtk-window-handle 0x"+Long.toHexString(window)); + } + xdisplay = callStaticMethodL2L(OS_gdk_x11_display_get_xdisplay, display); + } else { + xdisplay = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, window); + } + if(0 == xdisplay) { + throw new NativeWindowException("Null x11-display-handle of gtk-window-handle 0x"+Long.toHexString(window)); + } + return xdisplay; + } + + public static long gdk_window_get_xwindow(long window) { + final long xWindow; + if (OS_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0) { + xWindow = callStaticMethodL2L(OS_gdk_x11_window_get_xid, window); + } else { + xWindow = callStaticMethodL2L(OS_gdk_x11_drawable_get_xid, window); + } + if(0 == xWindow) { + throw new NativeWindowException("Null x11-window-handle of gtk-window-handle 0x"+Long.toHexString(window)); + } + return xWindow; + } + + public static void gdk_window_set_back_pixmap(long window, long pixmap, boolean parent_relative) { + callStaticMethodLLZ2V(OS_gdk_window_set_back_pixmap, window, pixmap, parent_relative); + } + + // + // Common any toolkit + // + /** * @param swtControl the SWT Control to retrieve the native widget-handle from * @return the native widget-handle @@ -240,15 +324,21 @@ public class SWTAccessor { */ public static long getHandle(Control swtControl) throws NativeWindowException { long h = 0; - if(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false) ) { - try { - Field fView = Control.class.getField(str_view); - Object view = fView.get(swtControl); - Field fId = view.getClass().getField(str_id); - h = fId.getLong(view); - } catch (Exception ex) { - throw new NativeWindowException(ex); - } + if( isOSX ) { + synchronized(swt_osx_init) { + try { + if(null == swt_osx_view_id) { + swt_osx_control_view = Control.class.getField(str_osx_view); + Object view = swt_osx_control_view.get(swtControl); + swt_osx_view_id = view.getClass().getField(str_osx_id); + h = swt_osx_view_id.getLong(view); + } else { + h = swt_osx_view_id.getLong( swt_osx_control_view.get(swtControl) ); + } + } catch (Exception ex) { + throw new NativeWindowException(ex); + } + } } else { try { h = swt_control_handle.getLong(swtControl); @@ -283,49 +373,6 @@ public class SWTAccessor { } } - private static long gdk_x11_display_get_xdisplay(long window) { - final long xdisplay; - if ( OS_gtk_version.compareTo(GTK_VERSION_2_24_0) >= 0 ) { - final long display = callStaticMethodL2L(OS_gdk_window_get_display, window); - if(0 == display) { - throw new NativeWindowException("Null display-handle of gtk-window-handle 0x"+Long.toHexString(window)); - } - xdisplay = callStaticMethodL2L(OS_gdk_x11_display_get_xdisplay, display); - } else { - xdisplay = callStaticMethodL2L(OS_gdk_x11_drawable_get_xdisplay, window); - } - if(0 == xdisplay) { - throw new NativeWindowException("Null x11-display-handle of gtk-window-handle 0x"+Long.toHexString(window)); - } - return xdisplay; - } - - private static long gdk_widget_get_window(long handle) { - final long window; - if ( OS_gtk_version.compareTo(GTK_VERSION_2_14_0) >= 0 ) { - window = callStaticMethodL2L(OS_gtk_widget_get_window, handle); - } else { - window = callStaticMethodL2L(OS_GTK_WIDGET_WINDOW, handle); - } - if(0 == window) { - throw new NativeWindowException("Null gtk-window-handle of SWT handle 0x"+Long.toHexString(handle)); - } - return window; - } - - private static long gdk_window_get_xwindow(long window) { - final long xwindow; - if ( OS_gtk_version.compareTo(GTK_VERSION_3_0_0) >= 0 ) { - xwindow = callStaticMethodL2L(OS_gdk_x11_window_get_xid, window); - } else { - xwindow = callStaticMethodL2L(OS_gdk_x11_drawable_get_xid, window); - } - if(0 == xwindow) { - throw new NativeWindowException("Null x11-window-handle of gtk-window-handle 0x"+Long.toHexString(window)); - } - return xwindow; - } - /** * @param swtControl the SWT Control to retrieve the native device handle from * @return the AbstractGraphicsDevice w/ the native device handle @@ -333,43 +380,49 @@ public class SWTAccessor { * @throws UnsupportedOperationException if the windowing system is not supported */ public static AbstractGraphicsDevice getDevice(Control swtControl) throws NativeWindowException, UnsupportedOperationException { - long handle = getHandle(swtControl); - if( null != OS_gtk_class ) { - final long xdisplay0 = gdk_x11_display_get_xdisplay( gdk_widget_get_window( handle ) ); - // final String displayName = X11Lib.XDisplayString(xdisplay0); - // final long xdisplay1 = X11Util.openDisplay(displayName); - // return new X11GraphicsDevice(xdisplay1, AbstractGraphicsDevice.DEFAULT_UNIT, true /* owner */); + final long handle = getHandle(swtControl); + if( isX11GTK ) { + final long xdisplay0 = gdk_window_get_xdisplay( gdk_widget_get_window( handle ) ); return new X11GraphicsDevice(xdisplay0, AbstractGraphicsDevice.DEFAULT_UNIT, false /* owner */); } - final String nwt = NativeWindowFactory.getNativeWindowType(false); - if( NativeWindowFactory.TYPE_WINDOWS == nwt ) { + if( isWindows ) { return new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } - if( NativeWindowFactory.TYPE_MACOSX == nwt ) { + if( isOSX ) { return new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } + /** + * + * @param device + * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen + * @return + * @throws UnsupportedOperationException + */ public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) throws UnsupportedOperationException { - if( null != OS_gtk_class ) { - return new X11GraphicsScreen((X11GraphicsDevice)device, screen); + if( isX11 ) { + X11GraphicsDevice x11Device = (X11GraphicsDevice)device; + if(0 > screen) { + screen = x11Device.getDefaultScreen(); + } + return new X11GraphicsScreen(x11Device, screen); + } + if(0 > screen) { + screen = 0; // FIXME: Needs native API utilization } - final String nwt = NativeWindowFactory.getNativeWindowType(false); - if( NativeWindowFactory.TYPE_WINDOWS == nwt || - NativeWindowFactory.TYPE_MACOSX == nwt ) { + if( isWindows || isOSX ) { return new DefaultGraphicsScreen(device, screen); } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); } public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) { - if( null != OS_gtk_class ) { + if( isX11 ) { return X11Lib.GetVisualIDFromWindow(device.getHandle(), windowHandle); } - final String nwt = NativeWindowFactory.getNativeWindowType(false); - if( NativeWindowFactory.TYPE_WINDOWS == nwt || - NativeWindowFactory.TYPE_MACOSX == nwt ) { + if( isWindows || isOSX ) { return VisualIDHolder.VID_UNDEFINED; } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); @@ -383,12 +436,13 @@ public class SWTAccessor { */ public static long getWindowHandle(Control swtControl) throws NativeWindowException, UnsupportedOperationException { final long handle = getHandle(swtControl); - if( null != OS_gtk_class ) { + if(0 == handle) { + throw new NativeWindowException("Null SWT handle of SWT control "+swtControl); + } + if( isX11GTK ) { return gdk_window_get_xwindow( gdk_widget_get_window( handle ) ); } - final String nwt = NativeWindowFactory.getNativeWindowType(false); - if( NativeWindowFactory.TYPE_WINDOWS == nwt || - NativeWindowFactory.TYPE_MACOSX == nwt ) { + if( isWindows || isOSX ) { return handle; } throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); @@ -407,7 +461,7 @@ public class SWTAccessor { throw new InternalError("SWT internal_new_GC did not return int or long but "+o[0].getClass()); } } - + public static void disposeGC(final Control swtControl, final long gc, final GCData gcData) { invoke(true, new Runnable() { public void run() { @@ -437,7 +491,7 @@ public class SWTAccessor { * @see Platform#getOSType() */ public static void invoke(boolean wait, Runnable runnable) { - if( Platform.OS_TYPE == Platform.OSType.MACOS ) { + if( isOSX ) { // Use SWT main thread! Only reliable config w/ -XStartOnMainThread !? OSXUtil.RunOnMainThread(wait, runnable); } else { @@ -445,4 +499,85 @@ public class SWTAccessor { } } + // + // Specific X11 GTK ChildWindow - Using plain X11 native parenting (works well) + // + + public static long createCompatibleX11ChildWindow(AbstractGraphicsScreen screen, Control swtControl, int visualID, int width, int height) { + final long handle = getHandle(swtControl); + final long parentWindow = gdk_widget_get_window( handle ); + gdk_window_set_back_pixmap (parentWindow, 0, false); + + final long x11ParentHandle = gdk_window_get_xwindow(parentWindow); + final long x11WindowHandle = X11Lib.CreateWindow(x11ParentHandle, screen.getDevice().getHandle(), screen.getIndex(), visualID, width, height, true, true); + + return x11WindowHandle; + } + + public static void resizeX11Window(AbstractGraphicsDevice device, Rectangle clientArea, long x11Window) { + X11Lib.SetWindowPosSize(device.getHandle(), x11Window, clientArea.x, clientArea.y, clientArea.width, clientArea.height); + } + public static void destroyX11Window(AbstractGraphicsDevice device, long x11Window) { + X11Lib.DestroyWindow(device.getHandle(), x11Window); + } + + // + // Specific X11 SWT/GTK ChildWindow - Using SWT/GTK native parenting (buggy - sporadic resize flickering, sporadic drop of rendering) + // + // FIXME: Need to use reflection for 32bit access as well ! + // + + // public static final int GDK_WA_TYPE_HINT = 1 << 9; + // public static final int GDK_WA_VISUAL = 1 << 6; + + public static long createCompatibleGDKChildWindow(Control swtControl, int visualID, int width, int height) { + return 0; + /** + final long handle = SWTAccessor.getHandle(swtControl); + final long parentWindow = gdk_widget_get_window( handle ); + + final long screen = OS.gdk_screen_get_default (); + final long gdkvisual = OS.gdk_x11_screen_lookup_visual (screen, visualID); + + final GdkWindowAttr attrs = new GdkWindowAttr(); + attrs.width = width > 0 ? width : 1; + attrs.height = height > 0 ? height : 1; + attrs.event_mask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | + OS.GDK_FOCUS_CHANGE_MASK | OS.GDK_POINTER_MOTION_MASK | + OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | + OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK | + OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK | + OS.GDK_POINTER_MOTION_HINT_MASK; + attrs.window_type = OS.GDK_WINDOW_CHILD; + attrs.visual = gdkvisual; + + final long childWindow = OS.gdk_window_new (parentWindow, attrs, OS.GDK_WA_VISUAL|GDK_WA_TYPE_HINT); + OS.gdk_window_set_user_data (childWindow, handle); + OS.gdk_window_set_back_pixmap (parentWindow, 0, false); + + OS.gdk_window_show (childWindow); + OS.gdk_flush(); + return childWindow; */ + } + + public static void showGDKWindow(long gdkWindow) { + /* OS.gdk_window_show (gdkWindow); + OS.gdk_flush(); */ + } + public static void focusGDKWindow(long gdkWindow) { + /* + OS.gdk_window_show (gdkWindow); + OS.gdk_window_focus(gdkWindow, 0); + OS.gdk_flush(); */ + } + public static void resizeGDKWindow(Rectangle clientArea, long gdkWindow) { + /** + OS.gdk_window_move (gdkWindow, clientArea.x, clientArea.y); + OS.gdk_window_resize (gdkWindow, clientArea.width, clientArea.height); + OS.gdk_flush(); */ + } + + public static void destroyGDKWindow(long gdkWindow) { + // OS.gdk_window_destroy (gdkWindow); + } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java index 67a33e55c..827862002 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11DummyUpstreamSurfaceHook.java @@ -37,7 +37,7 @@ public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize s.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); } if( 0 == s.getSurfaceHandle() ) { - final long windowHandle = X11Lib.CreateDummyWindow(device.getHandle(), screen.getIndex(), cfg.getXVisualID(), 64, 64); + final long windowHandle = X11Lib.CreateWindow(0, device.getHandle(), screen.getIndex(), cfg.getXVisualID(), 64, 64, false, false); if(0 == windowHandle) { throw new NativeWindowException("Creating dummy window failed w/ "+cfg); } @@ -59,7 +59,7 @@ public class X11DummyUpstreamSurfaceHook extends UpstreamSurfaceHookMutableSize } device.lock(); try { - X11Lib.DestroyDummyWindow(device.getHandle(), s.getSurfaceHandle()); + X11Lib.DestroyWindow(device.getHandle(), s.getSurfaceHandle()); s.setSurfaceHandle(0); s.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_SURFACE ); } finally { diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index c73952693..a8d45f288 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -31,6 +31,8 @@ #include "jogamp_nativewindow_x11_X11Lib.h" #include "jogamp_nativewindow_x11_X11Util.h" +#include + // #define VERBOSE_ON 1 #ifdef VERBOSE_ON @@ -85,6 +87,8 @@ Bool XF86VidModeSetGammaRamp( #define RTLD_DEFAULT NULL #endif +#define X11_MOUSE_EVENT_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask | EnterWindowMask | LeaveWindowMask) + static const char * const ClazzNameBuffers = "com/jogamp/common/nio/Buffers"; static const char * const ClazzNameBuffersStaticCstrName = "copyByteBuffer"; static const char * const ClazzNameBuffersStaticCstrSignature = "(Ljava/nio/ByteBuffer;)Ljava/nio/ByteBuffer;"; @@ -436,17 +440,62 @@ Java_jogamp_nativewindow_x11_X11Lib_XCloseDisplay__J(JNIEnv *env, jclass _unused return _res; } +static void NativewindowX11_setNormalWindowEWMH (Display *dpy, Window w) { + Atom _NET_WM_WINDOW_TYPE = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE", False ); + Atom types[1]={0}; + types[0] = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE_NORMAL", False ); + XChangeProperty( dpy, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&types, 1); + XSync(dpy, False); +} + +#define DECOR_USE_MWM 1 // works for known WMs +// #define DECOR_USE_EWMH 1 // haven't seen this to work (NORMAL->POPUP, never gets undecorated) + +/* see */ +#define MWM_HINTS_DECORATIONS (1L << 1) +#define PROP_MWM_HINTS_ELEMENTS 5 + +static void NativewindowX11_setDecorations (Display *dpy, Window w, Bool decorated) { + +#ifdef DECOR_USE_MWM + unsigned long mwmhints[PROP_MWM_HINTS_ELEMENTS] = { MWM_HINTS_DECORATIONS, 0, decorated, 0, 0 }; // flags, functions, decorations, input_mode, status + Atom _MOTIF_WM_HINTS = XInternAtom( dpy, "_MOTIF_WM_HINTS", False ); +#endif + +#ifdef DECOR_USE_EWMH + Atom _NET_WM_WINDOW_TYPE = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE", False ); + Atom types[3]={0}; + int ntypes=0; + if(True==decorated) { + types[ntypes++] = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE_NORMAL", False ); + } else { + types[ntypes++] = XInternAtom( dpy, "_NET_WM_WINDOW_TYPE_POPUP_MENU", False ); + } +#endif + +#ifdef DECOR_USE_MWM + XChangeProperty( dpy, w, _MOTIF_WM_HINTS, _MOTIF_WM_HINTS, 32, PropModeReplace, (unsigned char *)&mwmhints, PROP_MWM_HINTS_ELEMENTS); +#endif + +#ifdef DECOR_USE_EWMH + XChangeProperty( dpy, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&types, ntypes); +#endif + + XSync(dpy, False); +} + /* * Class: jogamp_nativewindow_x11_X11Lib - * Method: CreateDummyWindow - * Signature: (JIIII)J + * Method: CreateWindow + * Signature: (JJIIIIZZ)J */ -JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow - (JNIEnv *env, jclass unused, jlong display, jint screen_index, jint visualID, jint width, jint height) +JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateWindow + (JNIEnv *env, jclass unused, jlong parent, jlong display, jint screen_index, jint visualID, jint width, jint height, jboolean input, jboolean visible) { Display * dpy = (Display *)(intptr_t)display; int scrn_idx = (int)screen_index; - Window windowParent = 0; + Window root = RootWindow(dpy, scrn_idx); + Window windowParent = (Window) parent; Window window = 0; XVisualInfo visualTemplate; @@ -473,6 +522,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 1, 0, 0); scrn = ScreenOfDisplay(dpy, scrn_idx); + if(0==windowParent) { + windowParent = root; + } // try given VisualID on screen memset(&visualTemplate, 0, sizeof(XVisualInfo)); @@ -500,9 +552,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow pVisualQuery=NULL; } - if(0==windowParent) { - windowParent = XRootWindowOfScreen(scrn); - } attrMask = ( CWBackingStore | CWBackingPlanes | CWBackingPixel | CWBackPixmap | CWBorderPixel | CWColormap | CWOverrideRedirect ) ; @@ -514,15 +563,22 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow xswa.backing_store=NotUseful; /* NotUseful, WhenMapped, Always */ xswa.backing_planes=0; /* planes to be preserved if possible */ xswa.backing_pixel=0; /* value to use in restoring planes */ + if( input ) { + xswa.event_mask = X11_MOUSE_EVENT_MASK; + xswa.event_mask |= KeyPressMask | KeyReleaseMask ; + } + if( visible ) { + xswa.event_mask |= FocusChangeMask | SubstructureNotifyMask | StructureNotifyMask | ExposureMask ; + } xswa.colormap = XCreateColormap(dpy, - XRootWindow(dpy, scrn_idx), + windowParent, visual, AllocNone); window = XCreateWindow(dpy, windowParent, - 0, 0, + 0, 0, // only a hint, WM most likely will override width, height, 0, // border width depth, @@ -530,9 +586,25 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow visual, attrMask, &xswa); + if(0==window) { + NativewindowCommon_throwNewRuntimeException(env, "could not create Window, bail out!"); + return 0; + } + + NativewindowX11_setNormalWindowEWMH(dpy, window); + NativewindowX11_setDecorations(dpy, window, False); + + if( visible ) { + XEvent event; + + XMapWindow(dpy, window); + } + XSync(dpy, False); - XSelectInput(dpy, window, 0); // no events + if( !input ) { + XSelectInput(dpy, window, 0); // no events + } // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 0, 1); @@ -544,10 +616,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_x11_X11Lib_CreateDummyWindow /* * Class: jogamp_nativewindow_x11_X11Lib - * Method: DestroyDummyWindow + * Method: DestroyWindow * Signature: (JJ)V */ -JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyDummyWindow +JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyWindow (JNIEnv *env, jclass unused, jlong display, jlong window) { Display * dpy = (Display *)(intptr_t)display; @@ -559,12 +631,37 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_DestroyDummyWindow } NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 1, 0, 0); + XSelectInput(dpy, w, 0); XUnmapWindow(dpy, w); XSync(dpy, False); XDestroyWindow(dpy, w); // NativewindowCommon_x11ErrorHandlerEnable(env, dpy, 0, 0, 0, 1); } +JNIEXPORT void JNICALL Java_jogamp_nativewindow_x11_X11Lib_SetWindowPosSize + (JNIEnv *env, jclass unused, jlong display, jlong window, jint x, jint y, jint width, jint height) { + Display * dpy = (Display *)(intptr_t)display; + Window w = (Window) window; + XWindowChanges xwc; + int flags = 0; + + memset(&xwc, 0, sizeof(XWindowChanges)); + + if(0<=x && 0<=y) { + flags |= CWX | CWY; + xwc.x=x; + xwc.y=y; + } + + if(0 + * Implementation allows use of custom {@link GLCapabilities}. + *

    */ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); @@ -126,54 +126,44 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { clientArea = getClientArea(); final AbstractGraphicsDevice device = SWTAccessor.getDevice(this); - screen = SWTAccessor.getScreen(device, 0); + screen = SWTAccessor.getScreen(device, -1 /* default */); nativeWindow = null; if(null != child) { setNEWTChild(child); } - - /* Register SWT listeners (e.g. PaintListener) to render/resize GL surface. */ - /* TODO: verify that these do not need to be manually de-registered when destroying the SWT component */ - addPaintListener(new PaintListener() { + + final Listener listener = new Listener () { @Override - public void paintControl(final PaintEvent arg0) { - if( null != nativeWindow || validateNative() ) { - if( newtChildReady ) { - if( postSetSize ) { - newtChild.setSize(clientArea.width, clientArea.height); - postSetSize = false; + public void handleEvent (Event event) { + switch (event.type) { + case SWT.Paint: + if( null != nativeWindow || validateNative() ) { + if( newtChildReady ) { + if( postSetSize ) { + newtChild.setSize(clientArea.width, clientArea.height); + postSetSize = false; + } + newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } - newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } + break; + case SWT.Resize: + updateSizeCheck(); + break; + case SWT.Dispose: + NewtCanvasSWT.this.dispose(); + break; } } - }); - - addControlListener(new ControlListener() { - @Override - public void controlMoved(ControlEvent e) { - } - @Override - public void controlResized(final ControlEvent arg0) { - updateSizeCheck(); - } - }); - - addDisposeListener(new DisposeListener() { - @Override - public void widgetDisposed(DisposeEvent e) { - NewtCanvasSWT.this.dispose(); - } - }); - + }; + addListener (SWT.Resize, listener); + addListener (SWT.Paint, listener); + addListener (SWT.Dispose, listener); } /** assumes nativeWindow == null ! */ protected final boolean validateNative() { - if( isDisposed() || !isVisible() ) { - return false; - } updateSizeCheck(); final Rectangle nClientArea = clientArea; if(0 >= nClientArea.width || 0 >= nClientArea.height) { @@ -216,6 +206,10 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { ( nClientArea.width != oClientArea.width || nClientArea.height != oClientArea.height ) ) { clientArea = nClientArea; // write back new value + if(DEBUG) { + final long nsh = newtChildReady ? newtChild.getSurfaceHandle() : 0; + System.err.println("NewtCanvasSWT.sizeChanged: ("+Thread.currentThread().getName()+"): newtChildReady "+newtChildReady+", "+nClientArea.x+"/"+nClientArea.y+" "+nClientArea.width+"x"+nClientArea.height+" - surfaceHandle 0x"+Long.toHexString(nsh)); + } if( newtChildReady ) { newtChild.setSize(clientArea.width, clientArea.height); } else { @@ -223,7 +217,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { } } } - + @Override public void update() { // don't paint background etc .. nop avoids flickering @@ -261,11 +255,11 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public NativeWindow getNativeWindow() { return nativeWindow; } public WindowClosingMode getDefaultCloseOperation() { - return newtChildCloseOp; // FIXME + return newtChildCloseOp; // TODO: implement ?! } public WindowClosingMode setDefaultCloseOperation(WindowClosingMode op) { - return newtChildCloseOp = op; // FIXME + return newtChildCloseOp = op; // TODO: implement ?! } diff --git a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java deleted file mode 100644 index 1c20fe524..000000000 --- a/src/newt/classes/com/jogamp/newt/swt/SWTEDTUtil.java +++ /dev/null @@ -1,313 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.newt.swt; - -import javax.media.nativewindow.NativeWindowException; - -import jogamp.newt.Debug; - -import com.jogamp.common.util.RunnableTask; -import com.jogamp.newt.util.EDTUtil; - -/** - * Simple {@link EDTUtil} implementation utilizing the SWT UI thread - * of the given {@link Display}. - */ -public class SWTEDTUtil implements EDTUtil { - public static final boolean DEBUG = Debug.debug("EDT"); - - private final Object edtLock = new Object(); // locking the EDT start/stop state - private final ThreadGroup threadGroup; - private final String name; - private final Runnable dispatchMessages; - private final org.eclipse.swt.widgets.Display swtDisplay; - private NewtEventDispatchThread nedt = null; - private int start_iter=0; - private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; - - public SWTEDTUtil(final com.jogamp.newt.Display newtDisplay, org.eclipse.swt.widgets.Display swtDisplay) { - this.threadGroup = Thread.currentThread().getThreadGroup(); - this.name=Thread.currentThread().getName()+"-SWTDisplay-"+newtDisplay.getFQName()+"-EDT-"; - this.dispatchMessages = new Runnable() { - public void run() { - ((jogamp.newt.DisplayImpl) newtDisplay).dispatchMessages(); - } }; - this.swtDisplay = swtDisplay; - this.nedt = new NewtEventDispatchThread(threadGroup, name); - this.nedt.setDaemon(true); // don't stop JVM from shutdown .. - } - - public final org.eclipse.swt.widgets.Display getDisplay() { - return swtDisplay; - } - - @Override - public long getPollPeriod() { - return pollPeriod; - } - - @Override - public void setPollPeriod(long ms) { - pollPeriod = ms; - } - - @Override - public void reset() { - synchronized(edtLock) { - waitUntilStopped(); - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt); - } - this.nedt = new NewtEventDispatchThread(threadGroup, name); - this.nedt.setDaemon(true); // don't stop JVM from shutdown .. - } - } - - private final void startImpl() { - if(nedt.isAlive()) { - throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); - } - start_iter++; - nedt.setName(name+start_iter); - nedt.shouldStop = false; - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT START - edt: "+nedt); - // Thread.dumpStack(); - } - nedt.start(); - } - - @Override - public boolean isCurrentThreadEDT() { - return swtDisplay.getThread() == Thread.currentThread(); - } - - @Override - public final boolean isCurrentThreadNEDT() { - return nedt == Thread.currentThread(); - } - - @Override - public final boolean isCurrentThreadEDTorNEDT() { - final Thread ct = Thread.currentThread(); - return ct == swtDisplay.getThread() || ct == nedt ; - } - - @Override - public boolean isRunning() { - return nedt.isRunning() ; // SWT is always running - } - - @Override - public final void invokeStop(Runnable task) { - invokeImpl(true, task, true); - } - - @Override - public final void invoke(boolean wait, Runnable task) { - invokeImpl(wait, task, false); - } - - private void invokeImpl(boolean wait, Runnable task, boolean stop) { - Throwable throwable = null; - RunnableTask rTask = null; - Object rTaskLock = new Object(); - synchronized(rTaskLock) { // lock the optional task execution - synchronized(edtLock) { // lock the EDT status - if( nedt.shouldStop ) { - // drop task .. - if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt); - Thread.dumpStack(); - } - return; - } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - synchronized(nedt.sync) { - nedt.shouldStop = true; - nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) - } - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); - } - } else if( !nedt.isRunning() ) { - // start if should not stop && not started yet - startImpl(); - } - if( null == task ) { - wait = false; - } else if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else if( swtDisplay.isDisposed() ) { - wait = false; // drop task, SWT disposed - } else { - rTask = new RunnableTask(task, - wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */); - swtDisplay.asyncExec(rTask); - } - } - if( wait ) { - try { - rTaskLock.wait(); // free lock, allow execution of rTask - } catch (InterruptedException ie) { - throwable = ie; - } - if(null==throwable) { - throwable = rTask.getThrowable(); - } - if(null!=throwable) { - if(throwable instanceof NativeWindowException) { - throw (NativeWindowException)throwable; - } - throw new RuntimeException(throwable); - } - } - } - } - - @Override - final public void waitUntilIdle() { - final NewtEventDispatchThread _nedt; - synchronized(edtLock) { - _nedt = nedt; - } - final Thread ct = Thread.currentThread(); - if(!_nedt.isRunning() || _nedt == ct || swtDisplay.getThread() == ct) { - return; - } - try { - swtDisplay.syncExec(new Runnable() { - public void run() { } - }); - } catch (Exception e) { } - } - - @Override - final public void waitUntilStopped() { - synchronized(edtLock) { - final Thread ct = Thread.currentThread(); - if(nedt.isRunning() && nedt != ct && swtDisplay.getThread() != ct) { - while(nedt.isRunning()) { - try { - edtLock.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } - } - - class NewtEventDispatchThread extends Thread { - volatile boolean shouldStop = false; - volatile boolean isRunning = false; - Object sync = new Object(); - - public NewtEventDispatchThread(ThreadGroup tg, String name) { - super(tg, name); - } - - final public boolean isRunning() { - return isRunning; - } - - @Override - final public void start() throws IllegalThreadStateException { - isRunning = true; - super.start(); - } - - /** - * Utilizing locking only on tasks and its execution, - * not for event dispatching. - */ - @Override - final public void run() { - if(DEBUG) { - System.err.println(getName()+": SWT-EDT run() START "+ getName()); - } - RuntimeException error = null; - try { - do { - // event dispatch - if(!shouldStop) { - // EDT invoke thread is SWT-EDT, - // hence dispatching is required to run on SWT-EDT as well. - // Otherwise a deadlock may happen due to dispatched event's - // triggering a locking action. - if ( !swtDisplay.isDisposed() ) { - swtDisplay.syncExec(dispatchMessages); - } else { - dispatchMessages.run(); - } - } - // wait - synchronized(sync) { - if(!shouldStop) { - try { - sync.wait(pollPeriod); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } - } while(!shouldStop) ; - } catch (Throwable t) { - // handle errors .. - shouldStop = true; - if(t instanceof RuntimeException) { - error = (RuntimeException) t; - } else { - error = new RuntimeException("Within SWT-EDT", t); - } - } finally { - if(DEBUG) { - System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error); - } - synchronized(edtLock) { - isRunning = !shouldStop; - if(!isRunning) { - edtLock.notifyAll(); - } - } - if(DEBUG) { - System.err.println(getName()+": SWT-EDT run() EXIT "+ getName()+", exception: "+error); - } - if(null!=error) { - throw error; - } - } // finally - } // run() - } // EventDispatchThread - -} diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java new file mode 100644 index 000000000..7297e5858 --- /dev/null +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -0,0 +1,313 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.swt; + +import javax.media.nativewindow.NativeWindowException; + +import jogamp.newt.Debug; + +import com.jogamp.common.util.RunnableTask; +import com.jogamp.newt.util.EDTUtil; + +/** + * Simple {@link EDTUtil} implementation utilizing the SWT UI thread + * of the given {@link Display}. + */ +public class SWTEDTUtil implements EDTUtil { + public static final boolean DEBUG = Debug.debug("EDT"); + + private final Object edtLock = new Object(); // locking the EDT start/stop state + private final ThreadGroup threadGroup; + private final String name; + private final Runnable dispatchMessages; + private final org.eclipse.swt.widgets.Display swtDisplay; + private NewtEventDispatchThread nedt = null; + private int start_iter=0; + private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; + + public SWTEDTUtil(final com.jogamp.newt.Display newtDisplay, org.eclipse.swt.widgets.Display swtDisplay) { + this.threadGroup = Thread.currentThread().getThreadGroup(); + this.name=Thread.currentThread().getName()+"-SWTDisplay-"+newtDisplay.getFQName()+"-EDT-"; + this.dispatchMessages = new Runnable() { + public void run() { + ((jogamp.newt.DisplayImpl) newtDisplay).dispatchMessages(); + } }; + this.swtDisplay = swtDisplay; + this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + + public final org.eclipse.swt.widgets.Display getDisplay() { + return swtDisplay; + } + + @Override + public long getPollPeriod() { + return pollPeriod; + } + + @Override + public void setPollPeriod(long ms) { + pollPeriod = ms; + } + + @Override + public void reset() { + synchronized(edtLock) { + waitUntilStopped(); + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt); + } + this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + } + + private final void startImpl() { + if(nedt.isAlive()) { + throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + } + start_iter++; + nedt.setName(name+start_iter); + nedt.shouldStop = false; + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT START - edt: "+nedt); + // Thread.dumpStack(); + } + nedt.start(); + } + + @Override + public boolean isCurrentThreadEDT() { + return swtDisplay.getThread() == Thread.currentThread(); + } + + @Override + public final boolean isCurrentThreadNEDT() { + return nedt == Thread.currentThread(); + } + + @Override + public final boolean isCurrentThreadEDTorNEDT() { + final Thread ct = Thread.currentThread(); + return ct == swtDisplay.getThread() || ct == nedt ; + } + + @Override + public boolean isRunning() { + return nedt.isRunning() ; // SWT is always running + } + + @Override + public final void invokeStop(Runnable task) { + invokeImpl(true, task, true); + } + + @Override + public final void invoke(boolean wait, Runnable task) { + invokeImpl(wait, task, false); + } + + private void invokeImpl(boolean wait, Runnable task, boolean stop) { + Throwable throwable = null; + RunnableTask rTask = null; + Object rTaskLock = new Object(); + synchronized(rTaskLock) { // lock the optional task execution + synchronized(edtLock) { // lock the EDT status + if( nedt.shouldStop ) { + // drop task .. + if(DEBUG) { + System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt); + Thread.dumpStack(); + } + return; + } + // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); + // Thread.dumpStack(); + if(stop) { + synchronized(nedt.sync) { + nedt.shouldStop = true; + nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) + } + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); + // Thread.dumpStack(); + } + } else if( !nedt.isRunning() ) { + // start if should not stop && not started yet + startImpl(); + } + if( null == task ) { + wait = false; + } else if( isCurrentThreadEDT() ) { + task.run(); + wait = false; // running in same thread (EDT) -> no wait + } else if( swtDisplay.isDisposed() ) { + wait = false; // drop task, SWT disposed + } else { + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */); + swtDisplay.asyncExec(rTask); + } + } + if( wait ) { + try { + rTaskLock.wait(); // free lock, allow execution of rTask + } catch (InterruptedException ie) { + throwable = ie; + } + if(null==throwable) { + throwable = rTask.getThrowable(); + } + if(null!=throwable) { + if(throwable instanceof NativeWindowException) { + throw (NativeWindowException)throwable; + } + throw new RuntimeException(throwable); + } + } + } + } + + @Override + final public void waitUntilIdle() { + final NewtEventDispatchThread _nedt; + synchronized(edtLock) { + _nedt = nedt; + } + final Thread ct = Thread.currentThread(); + if(!_nedt.isRunning() || _nedt == ct || swtDisplay.getThread() == ct) { + return; + } + try { + swtDisplay.syncExec(new Runnable() { + public void run() { } + }); + } catch (Exception e) { } + } + + @Override + final public void waitUntilStopped() { + synchronized(edtLock) { + final Thread ct = Thread.currentThread(); + if(nedt.isRunning() && nedt != ct && swtDisplay.getThread() != ct) { + while(nedt.isRunning()) { + try { + edtLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + } + + class NewtEventDispatchThread extends Thread { + volatile boolean shouldStop = false; + volatile boolean isRunning = false; + Object sync = new Object(); + + public NewtEventDispatchThread(ThreadGroup tg, String name) { + super(tg, name); + } + + final public boolean isRunning() { + return isRunning; + } + + @Override + final public void start() throws IllegalThreadStateException { + isRunning = true; + super.start(); + } + + /** + * Utilizing locking only on tasks and its execution, + * not for event dispatching. + */ + @Override + final public void run() { + if(DEBUG) { + System.err.println(getName()+": SWT-EDT run() START "+ getName()); + } + RuntimeException error = null; + try { + do { + // event dispatch + if(!shouldStop) { + // EDT invoke thread is SWT-EDT, + // hence dispatching is required to run on SWT-EDT as well. + // Otherwise a deadlock may happen due to dispatched event's + // triggering a locking action. + if ( !swtDisplay.isDisposed() ) { + swtDisplay.syncExec(dispatchMessages); + } else { + dispatchMessages.run(); + } + } + // wait + synchronized(sync) { + if(!shouldStop) { + try { + sync.wait(pollPeriod); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } while(!shouldStop) ; + } catch (Throwable t) { + // handle errors .. + shouldStop = true; + if(t instanceof RuntimeException) { + error = (RuntimeException) t; + } else { + error = new RuntimeException("Within SWT-EDT", t); + } + } finally { + if(DEBUG) { + System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error); + } + synchronized(edtLock) { + isRunning = !shouldStop; + if(!isRunning) { + edtLock.notifyAll(); + } + } + if(DEBUG) { + System.err.println(getName()+": SWT-EDT run() EXIT "+ getName()+", exception: "+error); + } + if(null!=error) { + throw error; + } + } // finally + } // run() + } // EventDispatchThread + +} diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java new file mode 100644 index 000000000..e238f5d9e --- /dev/null +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -0,0 +1,249 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt.swt.event; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +import com.jogamp.common.util.IntIntHashMap; +import com.jogamp.newt.event.InputEvent; + +/** + * SWT event translator to NEWT, inclusive dispatch listener. + *

    + * Disclaimer: This code is merely tested and subject to change. + *

    + */ +public class SWTNewtEventFactory { + + protected static final IntIntHashMap eventTypeSWT2NEWT; + + static { + IntIntHashMap map = new IntIntHashMap(); + map.setKeyNotFoundValue(0xFFFFFFFF); + + // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED); + map.put(SWT.MouseDown, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); + map.put(SWT.MouseUp, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); + map.put(SWT.MouseMove, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED); + map.put(SWT.MouseEnter, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED); + map.put(SWT.MouseExit, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED); + // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED); + map.put(SWT.MouseVerticalWheel, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED); + + map.put(SWT.KeyDown, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED); + map.put(SWT.KeyUp, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED); + // map.put(SWT.KeyXXX, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED); + + eventTypeSWT2NEWT = map; + } + + public static final int swtModifiers2Newt(int awtMods, boolean mouseHint) { + int newtMods = 0; + if ((awtMods & SWT.SHIFT) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + if ((awtMods & SWT.CTRL) != 0) newtMods |= com.jogamp.newt.event.InputEvent.CTRL_MASK; + if ((awtMods & SWT.ALT) != 0) newtMods |= com.jogamp.newt.event.InputEvent.ALT_MASK; + return newtMods; + } + + public static final com.jogamp.newt.event.InputEvent createInputEvent(org.eclipse.swt.widgets.Event event, Object source) { + com.jogamp.newt.event.InputEvent res = createMouseEvent(event, source); + if(null == res) { + res = createKeyEvent(event, source); + } + return res; + } + + public static final com.jogamp.newt.event.MouseEvent createMouseEvent(org.eclipse.swt.widgets.Event event, Object source) { + switch(event.type) { + case SWT.MouseDown: + case SWT.MouseUp: + case SWT.MouseMove: + case SWT.MouseEnter: + case SWT.MouseExit: + case SWT.MouseVerticalWheel: + break; + default: + return null; + } + int type = eventTypeSWT2NEWT.get(event.type); + if(0xFFFFFFFF != type) { + int rotation = 0; + if (SWT.MouseVerticalWheel == event.type) { + // SWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. + // rotation = -1 * (int) event.rotation; + rotation = (int) event.rotation; + } + + int mods = swtModifiers2Newt(event.stateMask, true); + + if( source instanceof com.jogamp.newt.Window) { + final com.jogamp.newt.Window newtSource = (com.jogamp.newt.Window)source; + if(newtSource.isPointerConfined()) { + mods |= InputEvent.CONFINED_MASK; + } + if(!newtSource.isPointerVisible()) { + mods |= InputEvent.INVISIBLE_MASK; + } + } + + return new com.jogamp.newt.event.MouseEvent( + type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), + mods, event.x, event.y, event.count, event.button, rotation); + } + return null; // no mapping .. + } + + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(org.eclipse.swt.widgets.Event event, Object source) { + switch(event.type) { + case SWT.KeyDown: + case SWT.KeyUp: + break; + default: + return null; + } + int type = eventTypeSWT2NEWT.get(event.type); + if(0xFFFFFFFF != type) { + return new com.jogamp.newt.event.KeyEvent( + type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), + swtModifiers2Newt(event.stateMask, false), + event.keyCode, event.character); + } + return null; // no mapping .. + } + + // + // + // + + int dragButtonDown = 0; + + public SWTNewtEventFactory() { + resetButtonsDown(); + } + + final void resetButtonsDown() { + dragButtonDown = 0; + } + + public final boolean dispatchMouseEvent(org.eclipse.swt.widgets.Event event, Object source, com.jogamp.newt.event.MouseListener l) { + com.jogamp.newt.event.MouseEvent res = createMouseEvent(event, source); + if(null != res) { + if(null != l) { + switch(event.type) { + case SWT.MouseDown: + dragButtonDown = event.button; + l.mousePressed(res); break; + case SWT.MouseUp: + dragButtonDown = 0; + l.mouseReleased(res); + { + final com.jogamp.newt.event.MouseEvent res2 = new com.jogamp.newt.event.MouseEvent( + com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, + res.getSource(), + res.getWhen(), res.getModifiers(), + res.getX(), res.getY(), res.getClickCount(), + res.getButton(), res.getWheelRotation() ); + l.mouseClicked(res2); + } + break; + case SWT.MouseMove: + if( 0 < dragButtonDown ) { + final com.jogamp.newt.event.MouseEvent res2 = new com.jogamp.newt.event.MouseEvent( + com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED, + res.getSource(), + res.getWhen(), res.getModifiers(), + res.getX(), res.getY(), res.getClickCount(), + dragButtonDown, res.getWheelRotation() ); + l.mouseDragged( res2 ); + } else { + l.mouseMoved(res); + } + break; + case SWT.MouseEnter: + l.mouseEntered(res); + break; + case SWT.MouseExit: + resetButtonsDown(); + l.mouseExited(res); + break; + case SWT.MouseVerticalWheel: + l.mouseWheelMoved(res); + break; + } + } + return true; + } + return false; + } + + public final boolean dispatchKeyEvent(org.eclipse.swt.widgets.Event event, Object source, com.jogamp.newt.event.KeyListener l) { + com.jogamp.newt.event.KeyEvent res = createKeyEvent(event, source); + if(null != res) { + if(null != l) { + switch(event.type) { + case SWT.KeyDown: + l.keyPressed(res); + break; + case SWT.KeyUp: + l.keyReleased(res); + l.keyTyped(res); + break; + } + } + return true; + } + return false; + } + + public final void attachDispatchListener(final org.eclipse.swt.widgets.Control ctrl, final Object source, + final com.jogamp.newt.event.MouseListener ml, + final com.jogamp.newt.event.KeyListener kl) { + final Listener listener = new Listener () { + @Override + public void handleEvent (Event event) { + if( dispatchMouseEvent( event, source, ml ) ) { + return; + } + if( dispatchKeyEvent( event, source, kl ) ) { + return; + } + } }; + ctrl.addListener(SWT.MouseDown, listener); + ctrl.addListener(SWT.MouseUp, listener); + ctrl.addListener(SWT.MouseMove, listener); + ctrl.addListener(SWT.MouseEnter, listener); + ctrl.addListener(SWT.MouseExit, listener); + ctrl.addListener(SWT.MouseVerticalWheel, listener); + ctrl.addListener(SWT.KeyDown, listener); + ctrl.addListener(SWT.KeyUp, listener); + } +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index e9fe9b401..a3023538f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -60,8 +60,8 @@ public class GearsES2 implements GLEventListener { private int swapInterval = 0; private boolean pmvUseBackingArray = true; // the default for PMVMatrix now, since it's faster // private MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); - private MouseListener gearsMouse = new GearsMouseAdapter(); - private KeyListener gearsKeys = new GearsKeyAdapter(); + public MouseListener gearsMouse = new GearsMouseAdapter(); + public KeyListener gearsKeys = new GearsKeyAdapter(); private int prevMouseX, prevMouseY; private boolean doRotate = true; @@ -352,6 +352,10 @@ public class GearsES2 implements GLEventListener { window = (Window) source; width=window.getWidth(); height=window.getHeight(); + } else if (source instanceof GLAutoDrawable) { + GLAutoDrawable glad = (GLAutoDrawable) source; + width = glad.getWidth(); + height = glad.getHeight(); } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) { java.awt.Component comp = (java.awt.Component) source; width=comp.getWidth(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java index a0874e609..1f3bf3156 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java @@ -366,8 +366,9 @@ public class TestNewtCanvasSWTBug628ResizeDeadlock extends UITestCase { try { while( !shallStop && !dsc.display.isDisposed() ) { - if( !dsc.display.readAndDispatch() ) { - dsc.display.sleep(); + if( !dsc.display.readAndDispatch() && !shallStop ) { + // blocks on linux .. dsc.display.sleep(); + Thread.sleep(10); } } } catch (Exception e0) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java index 0a47b96eb..97b3ab243 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTBug643AsyncExec.java @@ -45,12 +45,13 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities ; import javax.media.opengl.GLProfile; +import jogamp.newt.swt.SWTEDTUtil; +import jogamp.newt.swt.event.SWTNewtEventFactory; import junit.framework.Assert; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.opengl.GLWindow ; import com.jogamp.newt.swt.NewtCanvasSWT ; -import com.jogamp.newt.swt.SWTEDTUtil; import com.jogamp.opengl.swt.GLCanvas; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; @@ -121,15 +122,15 @@ public class TestSWTBug643AsyncExec extends UITestCase { final Runnable swtAsyncAction = new Runnable() { public void run() { - ++swtN ; - System.err.println("[SWT A-i shallStop "+shallStop+"]: Counter[loc "+swtN+", glob: "+incrSWTCount()+"]"); + ++swtN ; incrSWTCount(); + System.err.println("[SWT A-i shallStop "+shallStop+"]: Counter[loc "+swtN+", glob: "+getSWTCount()+"]"); } }; final Runnable newtAsyncAction = new Runnable() { public void run() { - ++newtN ; - System.err.println("[NEWT A-i shallStop "+shallStop+"]: Counter[loc "+newtN+", glob: "+incrNEWTCount()+"]"); + ++newtN ; incrNEWTCount(); + System.err.println("[NEWT A-i shallStop "+shallStop+"]: Counter[loc "+newtN+", glob: "+getNEWTCount()+"]"); } }; public void run() @@ -219,9 +220,13 @@ public class TestSWTBug643AsyncExec extends UITestCase { final GLAutoDrawable glad; if( useJOGLGLCanvas ) { - glad = GLCanvas.create(dsc.composite, 0, caps, null, null); - glad.addGLEventListener( new GearsES2() ) ; - newtDisplay = null; + final GearsES2 demo = new GearsES2(); + final GLCanvas glc = GLCanvas.create(dsc.composite, 0, caps, null, null); + final SWTNewtEventFactory swtNewtEventFactory = new SWTNewtEventFactory(); + swtNewtEventFactory.attachDispatchListener(glc, glc, demo.gearsMouse, demo.gearsKeys); + glc.addGLEventListener( demo ) ; + glad = glc; + newtDisplay = null; } else if( useNewtCanvasSWT ) { final GLWindow glWindow = GLWindow.create( caps ) ; glWindow.addGLEventListener( new GearsES2() ) ; @@ -287,8 +292,9 @@ public class TestSWTBug643AsyncExec extends UITestCase { try { final Display d = dsc.display; while( !shallStop && !d.isDisposed() ) { - if( !d.readAndDispatch() ) { - dsc.display.sleep(); + if( !d.readAndDispatch() && !shallStop ) { + // blocks on linux .. dsc.display.sleep(); + Thread.sleep(10); } } } catch (Exception e0) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java index a5d2c8012..1822d2eaf 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java @@ -50,6 +50,7 @@ import org.junit.Test; import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.opengl.swt.GLCanvas; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.MultisampleDemoES2; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; @@ -58,10 +59,9 @@ import com.jogamp.opengl.util.texture.TextureIO; /** * Tests that a basic SWT app can open without crashing under different GL profiles. *

    - * Uses JOGL's new SWT GLCanvas. - *

    - *

    - * Note: To employ custom GLCapabilities, NewtCanvasSWT shall be used. + * Uses JOGL's new SWT GLCanvas, + * which allows utilizing custom GLCapability settings, + * independent from the already instantiated SWT visual. *

    *

    * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ @@ -188,6 +188,14 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2() ); } + @Test + public void test_MultisampleAndAlpha() throws InterruptedException { + GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); + caps.setSampleBuffers(true); + caps.setNumSamples(2); + runTestAGL( caps, new MultisampleDemoES2(true) ); + } + static int atoi(String a) { int i=0; try { -- cgit v1.2.3 From e7064ece049705e013d80985eae698ce0ee3c4e3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 15 Dec 2012 23:25:12 +0100 Subject: Cleanup GLContext special entries: getOffscreenContextPixelDataType(), getOffscreenContextReadBuffer(), .. ; Add GLFBODrawable API entries for multi buffering (no impl. yet); GLJPanel 1st simplification using offscreen drawable - Cleanup GLContext special entries: getOffscreenContextPixelDataType(), getOffscreenContextReadBuffer(), .. ; - add: getDefaultReadBuffer() (-> exposed via GLBase as well) - add: isGLOrientationFlippedVertical() - add: getDefaultPixelDataType() - removed impl: getOffscreenContextPixelDataType() - removed impl: getOffscreenContextReadBuffer() - removed impl: offscreenImageNeedsVerticalFlip() - Add GLFBODrawable API entries for multi buffering (no impl. yet); - TODO: Add implementation code in GLFBODrawableImpl - GLJPanel 1st simplification using FBO - Use above new GL/GLContext entries - Fix: getNativeSurface() and getHandle() - TODO: - Remove distinction of 'pbuffer' and 'software', - Use GLDrawableFactory.createOffscreenDrawable(..) - Use GL for FBO swapping --- .../config/jogl/gl-impl-CustomJavaCode-common.java | 5 +++ make/scripts/tests-x64.bat | 15 ++++--- make/scripts/tests.sh | 22 +++++++--- src/jogl/classes/com/jogamp/opengl/FBObject.java | 3 +- src/jogl/classes/javax/media/opengl/GLBase.java | 15 ++++++- src/jogl/classes/javax/media/opengl/GLContext.java | 26 +++++++++++ .../classes/javax/media/opengl/GLFBODrawable.java | 22 +++++++++- .../classes/javax/media/opengl/awt/GLJPanel.java | 20 ++++++--- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 51 ++++++++++++++++++---- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 11 ++++- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 14 ++++++ .../jogamp/opengl/GLOffscreenAutoDrawableImpl.java | 10 +++++ src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 10 ----- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 14 ------ .../macosx/cgl/MacOSXOffscreenCGLContext.java | 14 +----- .../windows/wgl/WindowsBitmapWGLContext.java | 10 +---- .../opengl/windows/wgl/WindowsWGLContext.java | 14 ------ .../jogamp/opengl/x11/glx/X11GLXContext.java | 14 ------ .../jogamp/opengl/x11/glx/X11PixmapGLXContext.java | 17 +------- 19 files changed, 187 insertions(+), 120 deletions(-) (limited to 'make/scripts') diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index 283a4e623..8e8165fff 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -113,3 +113,8 @@ return _context.getDefaultReadFramebuffer(); } + @Override + public final int getDefaultReadBuffer() { + return _context.getDefaultReadBuffer(); + } + diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index db7e27264..719435d74 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -6,9 +6,6 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownC REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT -time 5000 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT -time 5000 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* @@ -16,8 +13,16 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* + +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 @@ -25,10 +30,8 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt. REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT -time 5000 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT -time 2000 @@ -54,7 +57,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 628ab706b..42358067a 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -113,7 +113,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow" - D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" + #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -164,10 +164,12 @@ function jrun() { #D_ARGS="-Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Dnewt.debug=all" + D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" #X_ARGS="-verbose:jni" #X_ARGS="-Xrs" + X_ARGS="-Dsun.awt.disableMixing=true" if [ $awton -eq 1 ] ; then export CLASSPATH=$JOGAMP_ALL_AWT_CLASSPATH @@ -328,10 +330,6 @@ function testawtswt() { #testawt jogamp.newt.awt.opengl.VersionApplet $* #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* @@ -339,14 +337,20 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $* +##testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT @@ -370,7 +374,7 @@ function testawtswt() { # #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec $* @@ -416,10 +420,14 @@ testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawt $* +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* + # # Misc Utils # #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java index 40b45ead2..26c8ff77f 100644 --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java @@ -2283,7 +2283,8 @@ public class FBObject { /** Returns the framebuffer name to render to. */ public final int getWriteFramebuffer() { return fbName; } /** Returns the framebuffer name to read from. Depending on multisampling, this may be a different framebuffer. */ - public final int getReadFramebuffer() { return ( samples > 0 ) ? samplingSink.getReadFramebuffer() : fbName; } + public final int getReadFramebuffer() { return ( samples > 0 ) ? samplingSink.getReadFramebuffer() : fbName; } + public final int getDefaultReadBuffer() { return GL.GL_COLOR_ATTACHMENT0; } /** Return the number of color/texture attachments */ public final int getColorAttachmentCount() { return colorAttachmentCount; } /** Return the stencil {@link RenderAttachment} attachment, if exist. Maybe share the same {@link Attachment#getName()} as {@link #getDepthAttachment()}, if packed depth-stencil is being used. */ diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index 9bcee819a..82bb06b9c 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -432,6 +432,19 @@ public interface GLBase { *

    */ public int getDefaultReadFramebuffer(); - + + /** + * Returns the default color buffer within the current bound + * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​, + * which will be used as the source for pixel reading commands, + * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)} etc. + *

    + * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0}, + * otherwise this is {@link GL#GL_FRONT} for single buffer configurations + * and {@link GL#GL_BACK} for double buffer configurations. + *

    + */ + public int getDefaultReadBuffer(); + } diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index de10a2815..235003c38 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -970,6 +970,32 @@ public abstract class GLContext { */ public abstract int getDefaultReadFramebuffer(); + /** + * Returns the default color buffer within the current bound + * {@link #getDefaultReadFramebuffer()}, i.e. GL_READ_FRAMEBUFFER​, + * which will be used as the source for pixel reading commands, + * like {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)} etc. + *

    + * For offscreen framebuffer objects this is {@link GL#GL_COLOR_ATTACHMENT0}, + * otherwise this is {@link GL#GL_FRONT} for single buffer configurations + * and {@link GL#GL_BACK} for double buffer configurations. + *

    + */ + public abstract int getDefaultReadBuffer(); + + /** On some platforms the mismatch between OpenGL's coordinate + system (origin at bottom left) and the window system's + coordinate system (origin at top left) necessitates a vertical + flip of pixels read from offscreen contexts. +

    + Default impl. is true. +

    + */ + public abstract boolean isGLOrientationFlippedVertical(); + + /** Get the default pixel data type, as required by e.g. {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer)}. */ + public abstract int getDefaultPixelDataType(); + /** * @return The extension implementing the GLDebugOutput feature, * either GL_ARB_debug_output or GL_AMD_debug_output. diff --git a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java index 079d9af5c..4d6c7c20e 100644 --- a/src/jogl/classes/javax/media/opengl/GLFBODrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLFBODrawable.java @@ -101,7 +101,8 @@ public interface GLFBODrawable extends GLDrawable { void setTextureUnit(int unit); /** - * Set a new sample size + * Set the number of sample buffers if using MSAA + * * @param gl GL context object bound to this drawable, will be made current during operation. * A prev. current context will be make current after operation. * @param newSamples new sample size @@ -113,6 +114,25 @@ public interface GLFBODrawable extends GLDrawable { * @return the number of sample buffers if using MSAA, otherwise 0 */ int getNumSamples(); + + /** + * Sets the number of buffers (FBO) being used if using {@link GLCapabilities#getDoubleBuffered() double buffering}. + *

    + * If {@link GLCapabilities#getDoubleBuffered() double buffering} is not chosen, this is a NOP. + *

    + *

    + * Must be called before {@link #isInitialized() initialization}, otherwise an exception is thrown. + *

    + * @return the new number of buffers (FBO) used, maybe different than the requested bufferCount (see above) + * @throws GLException if already initialized, see {@link #isInitialized()}. + */ + int setNumBuffers(int bufferCount) throws GLException; + + /** + * @return the number of buffers (FBO) being used. 1 if not using {@link GLCapabilities#getDoubleBuffered() double buffering}, + * otherwise ≥ 2, depending on {@link #setNumBuffers(int)}. + */ + int getNumBuffers(); /** * @return the used {@link DoubleBufferMode} diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index dcfc1f0dd..a9d4989dc 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -618,12 +618,18 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public NativeSurface getNativeSurface() { - throw new GLException("FIXME"); + if(null != backend) { + return backend.getDrawable().getNativeSurface(); + } + return null; } @Override public long getHandle() { - throw new GLException("FIXME"); + if(null != backend) { + return backend.getDrawable().getNativeSurface().getSurfaceHandle(); + } + return 0; } @Override @@ -657,6 +663,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (oglPipelineEnabled) { backend = new J2DOGLBackend(); } else { + backend = new SoftwareBackend(); + /** if (!hardwareAccelerationDisabled && factory.canCreateGLPbuffer(null)) { backend = new PbufferBackend(); @@ -665,7 +673,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing throw new GLException("Fallback to software rendering disabled by user"); } backend = new SoftwareBackend(); - } + } */ } } @@ -996,7 +1004,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing gl.glPixelStorei(GL2.GL_PACK_ALIGNMENT, 1); // Actually read the pixels. - gl.glReadBuffer(GL2.GL_FRONT); + gl.glReadBuffer(gl.getDefaultReadBuffer()); if (readBackBytes != null) { gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, glFormat, glType, readBackBytes); } else if (readBackInts != null) { @@ -1173,12 +1181,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override protected int getGLPixelType() { - return offscreenContext.getOffscreenContextPixelDataType(); + return offscreenContext.getDefaultPixelDataType(); } @Override protected boolean flipVertically() { - return offscreenContext.offscreenImageNeedsVerticalFlip(); + return offscreenContext.isGLOrientationFlippedVertical(); } } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 65b523394..24fc466b1 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1513,15 +1513,46 @@ public abstract class GLContextImpl extends GLContext { throw new GLException("Not supported on non-pbuffer contexts"); } - /** On some platforms the mismatch between OpenGL's coordinate - system (origin at bottom left) and the window system's - coordinate system (origin at top left) necessitates a vertical - flip of pixels read from offscreen contexts. */ - public abstract boolean offscreenImageNeedsVerticalFlip(); + @Override + public boolean isGLOrientationFlippedVertical() { + return true; + } - /** Only called for offscreen contexts; needed by glReadPixels */ - public abstract int getOffscreenContextPixelDataType(); + @Override + public int getDefaultPixelDataType() { + if(!pixelDataTypeEvaluated) { + synchronized(this) { + if(!pixelDataTypeEvaluated) { + evalPixelDataType(); + pixelDataTypeEvaluated = true; + } + } + } + return pixelDataType; + } + private volatile boolean pixelDataTypeEvaluated = false; + int /* pixelDataInternalFormat, */ pixelDataFormat, pixelDataType; + + private final void evalPixelDataType() { + /* if(isGL2GL3() && 3 == components) { + pixelDataInternalFormat=GL.GL_RGB; + pixelDataFormat=GL.GL_RGB; + pixelDataType = GL.GL_UNSIGNED_BYTE; + } else */ if(isGLES2Compatible() || isExtensionAvailable(GLExtensions.OES_read_format)) { + final int[] glImplColorReadVals = new int[] { 0, 0 }; + gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_FORMAT, glImplColorReadVals, 0); + gl.glGetIntegerv(GL.GL_IMPLEMENTATION_COLOR_READ_TYPE, glImplColorReadVals, 1); + // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; + pixelDataFormat = glImplColorReadVals[0]; + pixelDataType = glImplColorReadVals[1]; + } else { + // RGBA read is safe for all GL profiles + // pixelDataInternalFormat = (4 == components) ? GL.GL_RGBA : GL.GL_RGB; + pixelDataFormat=GL.GL_RGBA; + pixelDataType = GL.GL_UNSIGNED_BYTE; + } + } //---------------------------------------------------------------------- // Helpers for buffer object optimizations @@ -1599,8 +1630,10 @@ public abstract class GLContextImpl extends GLContext { @Override public final int getDefaultDrawFramebuffer() { return drawable.getDefaultDrawFramebuffer(); } @Override - public final int getDefaultReadFramebuffer() { return drawable.getDefaultReadFramebuffer(); } - + public final int getDefaultReadFramebuffer() { return drawable.getDefaultReadFramebuffer(); } + @Override + public final int getDefaultReadBuffer() { return drawable.getDefaultReadBuffer(gl); } + //--------------------------------------------------------------------------- // GL_ARB_debug_output, GL_AMD_debug_output helpers // diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index df7f742aa..ccf0a8f0d 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -244,7 +244,16 @@ public abstract class GLDrawableImpl implements GLDrawable { /** Callback for special implementations, allowing GLContext to fetch a custom default render framebuffer. Defaults to zero.*/ protected int getDefaultDrawFramebuffer() { return 0; } /** Callback for special implementations, allowing GLContext to fetch a custom default read framebuffer. Defaults to zero. */ - protected int getDefaultReadFramebuffer() { return 0; } + protected int getDefaultReadFramebuffer() { return 0; } + /** Callback for special implementations, allowing GLContext to fetch a custom default read buffer of current framebuffer. */ + protected int getDefaultReadBuffer(GL gl) { + if(gl.isGLES() || getChosenGLCapabilities().getDoubleBuffered()) { + // Note-1: Neither ES1 nor ES2 supports selecting the read buffer via glReadBuffer + // Note-2: ES3 only supports GL_BACK, GL_NONE or GL_COLOR_ATTACHMENT0+i + return GL.GL_BACK; + } + return GL.GL_FRONT ; + } @Override public final synchronized boolean isRealized() { diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index 7a468a41e..b72f79868 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -301,6 +301,9 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { @Override protected final int getDefaultReadFramebuffer() { return initialized ? fbos[fboIFront].getReadFramebuffer() : 0; } + @Override + protected final int getDefaultReadBuffer(GL gl) { return initialized ? fbos[fboIFront].getDefaultReadBuffer() : GL.GL_COLOR_ATTACHMENT0 ; } + @Override protected final void setRealizedImpl() { final MutableGraphicsConfiguration msConfig = (MutableGraphicsConfiguration) surface.getGraphicsConfiguration(); @@ -435,6 +438,17 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { } } + @Override + public final int setNumBuffers(int bufferCount) throws GLException { + // FIXME: Implement + return bufferCount; + } + + @Override + public final int getNumBuffers() { + return bufferCount; + } + /** // TODO: Add or remove TEXTURE (only) DoubleBufferMode support @Override public final DoubleBufferMode getDoubleBufferMode() { diff --git a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java index 7701f209f..59a00170d 100644 --- a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java @@ -95,6 +95,16 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen windowRepaintOp(); } + @Override + public final int setNumBuffers(int bufferCount) throws GLException { + return ((GLFBODrawableImpl)drawable).setNumBuffers(bufferCount); + } + + @Override + public final int getNumBuffers() { + return ((GLFBODrawableImpl)drawable).getNumBuffers(); + } + /** // TODO: Add or remove TEXTURE (only) DoubleBufferMode support @Override public DoubleBufferMode getDoubleBufferMode() { diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 84aeaa94a..deb3813b1 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -344,14 +344,4 @@ public abstract class EGLContext extends GLContextImpl { public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { throw new GLException("Should not call this"); } - - @Override - public boolean offscreenImageNeedsVerticalFlip() { - throw new GLException("Should not call this"); - } - - @Override - public int getOffscreenContextPixelDataType() { - throw new GLException("Should not call this"); - } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index cde9841b8..63ed2ab7d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -420,20 +420,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl return super.isExtensionAvailable(glExtensionName); } - @Override - public int getOffscreenContextPixelDataType() { - throw new GLException("Should not call this"); - } - - public int getOffscreenContextReadBuffer() { - throw new GLException("Should not call this"); - } - - @Override - public boolean offscreenImageNeedsVerticalFlip() { - throw new GLException("Should not call this"); - } - // Support for "mode switching" as described in MacOSXCGLDrawable public void setOpenGLMode(GLBackendType mode) { if (mode == openGLMode) { diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLContext.java index 7b13ce22e..f2e636796 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLContext.java @@ -49,18 +49,8 @@ public class MacOSXOffscreenCGLContext extends MacOSXPbufferCGLContext } @Override - public int getOffscreenContextPixelDataType() { - GL gl = getGL(); + public int getDefaultPixelDataType() { + final GL gl = getGL(); return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1; } - - @Override - public int getOffscreenContextReadBuffer() { - return GL.GL_FRONT; - } - - @Override - public boolean offscreenImageNeedsVerticalFlip() { - return true; - } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLContext.java index 51341a098..c8aac7f7b 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLContext.java @@ -49,18 +49,12 @@ public class WindowsBitmapWGLContext extends WindowsWGLContext { } @Override - public int getOffscreenContextPixelDataType() { + public int getDefaultPixelDataType() { return GL.GL_UNSIGNED_BYTE; } @Override - public int getOffscreenContextReadBuffer() { - // On Windows these contexts are always single-buffered - return GL.GL_FRONT; - } - - @Override - public boolean offscreenImageNeedsVerticalFlip() { + public boolean isGLOrientationFlippedVertical() { // We can take care of this in the DIB creation (see below) return false; } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 57f16522c..92d75e3fd 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -537,20 +537,6 @@ public class WindowsWGLContext extends GLContextImpl { return getWGLExt().wglAllocateMemoryNV(arg0, arg1, arg2, arg3); } - @Override - public int getOffscreenContextPixelDataType() { - throw new GLException("Should not call this"); - } - - public int getOffscreenContextReadBuffer() { - throw new GLException("Should not call this"); - } - - @Override - public boolean offscreenImageNeedsVerticalFlip() { - throw new GLException("Should not call this"); - } - @Override public void bindPbufferToTexture() { throw new GLException("Should not call this"); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 76e0bc15c..bf1045132 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -618,20 +618,6 @@ public abstract class X11GLXContext extends GLContextImpl { return getGLXExt().glXAllocateMemoryNV(arg0, arg1, arg2, arg3); } - @Override - public int getOffscreenContextPixelDataType() { - throw new GLException("Should not call this"); - } - - public int getOffscreenContextReadBuffer() { - throw new GLException("Should not call this"); - } - - @Override - public boolean offscreenImageNeedsVerticalFlip() { - throw new GLException("Should not call this"); - } - @Override public void bindPbufferToTexture() { throw new GLException("Should not call this"); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java index 96d0f18dc..1cfb7e427 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXContext.java @@ -50,24 +50,9 @@ public class X11PixmapGLXContext extends X11GLXContext { } @Override - public int getOffscreenContextPixelDataType() { + public int getDefaultPixelDataType() { GL gl = getGL(); return gl.isGL2GL3()?GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV:GL.GL_UNSIGNED_SHORT_5_5_5_1; } - @Override - public int getOffscreenContextReadBuffer() { - GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)drawable.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities(); - if (caps.getDoubleBuffered()) { - return GL.GL_BACK; - } - return GL.GL_FRONT; - } - - @Override - public boolean offscreenImageNeedsVerticalFlip() { - // There doesn't seem to be a way to do this in the construction - // of the Pixmap or GLXPixmap - return true; - } } -- cgit v1.2.3 From 52ccfbaedbfc0964b9b9c65984778b68557aa7aa Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Dec 2012 07:50:38 +0100 Subject: test script --- make/scripts/tests.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 42358067a..f2843e7c9 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -164,12 +164,12 @@ function jrun() { #D_ARGS="-Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Dnewt.debug=all" - D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" #X_ARGS="-verbose:jni" #X_ARGS="-Xrs" - X_ARGS="-Dsun.awt.disableMixing=true" + #X_ARGS="-Dsun.awt.disableMixing=true" if [ $awton -eq 1 ] ; then export CLASSPATH=$JOGAMP_ALL_AWT_CLASSPATH @@ -345,12 +345,12 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $* -##testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* -testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT -- cgit v1.2.3 From cdd6b8fe25581b127e36f713e31c84af2d72945e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 20 Dec 2012 10:35:53 +0100 Subject: Bug 651: Mesa3D: GL_INVALID_ENUM in glGetIntegerv(pname=GL_MAX_TEXTURE_IMAGE_UNITS) ; Add unit test / bisect Mesa3D This bug lies within Mesa3D (any renderer) and is fixed in commit 8dc79ae7d73cf6711c2182ff9a5d37ef6c989d23. Mesa3D Version 9.0 still exposes this bug, where 9.0.1 has it fixed w/ above commit. --- make/scripts/tests.sh | 42 +++-- .../test/junit/jogl/acore/TestGLPointsNEWT.java | 156 +++++++++++++++ .../test/junit/jogl/acore/TestGLUnitsNEWT.java | 210 +++++++++++++++++++++ .../test/junit/jogl/acore/TestPointsNEWT.java | 156 --------------- 4 files changed, 391 insertions(+), 173 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLPointsNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPointsNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f2843e7c9..11a2dc9ba 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -42,8 +42,30 @@ if [ $MOSX -eq 1 ] ; then MOSX_MT=1 fi +#export LD_LIBRARY_PATH=$spath/../lib/external/PVRVFrame/OGLES-2.0/Linux_x86_64:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=$spath/../lib/external/PVRVFrame/OGLES-2.0/Linux_x86_32:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/usr/local/projects/Xorg.modular/build-x86_64/lib:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/opt-linux-x86_64/x11lib-1.3:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/usr/lib/mesa:/usr/lib32/mesa:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/mesa:/usr/lib/i386-linux-gnu/mesa:$LD_LIBRARY_PATH +#export LIBGL_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri:/usr/lib/i386-linux-gnu/dri +#export LD_LIBRARY_PATH=`pwd`/lib/external/mesa_git/x86_64-linux-gnu:$LD_LIBRARY_PATH +#export LIBGL_DRIVERS_PATH=`pwd`/lib/external/mesa_git/x86_64-linux-gnu/dri +#export LD_LIBRARY_PATH=`pwd`/lib/external/mesa_901/x86_64-linux-gnu:$LD_LIBRARY_PATH +#export LIBGL_DRIVERS_PATH=`pwd`/lib/external/mesa_901/x86_64-linux-gnu/dri +#export LD_LIBRARY_PATH=`pwd`/lib/external/mesa_900/x86_64-linux-gnu:$LD_LIBRARY_PATH +#export LIBGL_DRIVERS_PATH=`pwd`/lib/external/mesa_900/x86_64-linux-gnu/dri + +#export LIBGL_DEBUG=verbose +#export MESA_DEBUG=true +#export LIBGL_ALWAYS_SOFTWARE=true +#export INTEL_DEBUG="buf bat" +#export INTEL_STRICT_CONFORMANCE=1 + which "$javaexe" 2>&1 | tee -a java-run.log "$javaexe" -version 2>&1 | tee -a java-run.log +echo LD_LIBRARY_PATH $LD_LIBRARY_PATH 2>&1 | tee -a java-run.log echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a java-run.log echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a java-run.log echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a java-run.log @@ -198,25 +220,10 @@ function jrun() { C_ARG="com.jogamp.newt.util.MainThread" fi fi - #export LD_LIBRARY_PATH=$spath/../lib/external/PVRVFrame/OGLES-2.0/Linux_x86_64:$LD_LIBRARY_PATH - #export LD_LIBRARY_PATH=$spath/../lib/external/PVRVFrame/OGLES-2.0/Linux_x86_32:$LD_LIBRARY_PATH - #export LD_LIBRARY_PATH=/usr/local/projects/Xorg.modular/build-x86_64/lib:$LD_LIBRARY_PATH - #export LD_LIBRARY_PATH=/opt-linux-x86_64/x11lib-1.3:$LD_LIBRARY_PATH - #export LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64:$LD_LIBRARY_PATH - #export LD_LIBRARY_PATH=/usr/lib/mesa:/usr/lib32/mesa:$LD_LIBRARY_PATH - #export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/mesa:/usr/lib/i386-linux-gnu/mesa:$LD_LIBRARY_PATH - #export LD_LIBRARY_PATH=`pwd`/lib/external/mesa/x86_64-linux-gnu:$LD_LIBRARY_PATH - #export LD_LIBRARY_PATH=`pwd`/lib/external/mesa/x86_64-linux-gnu/gallium:$LD_LIBRARY_PATH echo echo "Test Start: $*" echo - echo LD_LIBRARY_PATH $LD_LIBRARY_PATH - echo echo "$javaexe" $javaxargs $X_ARGS $D_ARGS $C_ARG $* - #LIBGL_DRIVERS_PATH=/usr/lib/mesa:/usr/lib32/mesa \ - #LIBGL_DEBUG=verbose INTEL_STRICT_CONFORMANCE=1 INTEL_DEBUG="buf bat" \ - #LIBGL_DEBUG=verbose MESA_DEBUG=true INTEL_STRICT_CONFORMANCE=1 \ - #export LIBGL_DEBUG=verbose MESA_DEBUG=true LIBGL_ALWAYS_SOFTWARE=true #gdb --args "$javaexe" $javaxargs $X_ARGS $D_ARGS $C_ARG $* "$javaexe" $javaxargs $X_ARGS $D_ARGS $C_ARG $* echo @@ -270,7 +277,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPointsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLUnitsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -345,7 +353,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLPointsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLPointsNEWT.java new file mode 100644 index 000000000..692a3181b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLPointsNEWT.java @@ -0,0 +1,156 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import com.jogamp.opengl.test.junit.jogl.demos.PointsDemo; +import com.jogamp.opengl.test.junit.jogl.demos.es1.PointsDemoES1; +import com.jogamp.opengl.test.junit.jogl.demos.es2.PointsDemoES2; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +public class TestGLPointsNEWT extends UITestCase { + static int width, height; + + @BeforeClass + public static void initClass() { + width = 512; + height = 512; + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL0(GLCapabilities caps, PointsDemo demo) throws InterruptedException { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setTitle(getSimpleTestName(".")); + + glWindow.addGLEventListener(demo); + final SnapshotGLEventListener snap = new SnapshotGLEventListener(); + snap.setPostSNDetail(demo.getClass().getSimpleName()); + glWindow.addGLEventListener(snap); + + glWindow.setSize(width, height); + glWindow.setVisible(true); + + demo.setSmoothPoints(false); + snap.setMakeSnapshot(); + snap.setPostSNDetail("flat"); + glWindow.display(); + + demo.setSmoothPoints(true); + snap.setMakeSnapshot(); + snap.setPostSNDetail("smooth"); + glWindow.display(); + + demo.setPointParams(2f, 40f, 0.01f, 0.0f, 0.01f, 1f); + snap.setMakeSnapshot(); + snap.setPostSNDetail("attn0"); + glWindow.display(); + + glWindow.removeGLEventListener(demo); + + glWindow.destroy(); + } + + protected void runTestGL(GLCapabilities caps, PointsDemo demo, boolean forceFFPEmu) throws InterruptedException { + // final PointsDemoES2 demo01 = new PointsDemoES2(); + runTestGL0(caps, demo); + } + + @Test + public void test01FFP__GL2() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); + runTestGL(caps, new PointsDemoES1(), false); + } + + @Test + public void test02FFP__ES1() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GLES1)) { System.err.println("GLES1 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES1)); + runTestGL(caps, new PointsDemoES1(), false); + } + + @Test + public void test03FFP__ES2() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + PointsDemoES1 demo = new PointsDemoES1(); + demo.setForceFFPEmu(true, false, false, false); + runTestGL(caps, demo, false); + } + + @Test + public void test04FFP__GL2ES2() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GL2ES2)) { System.err.println("GL2ES2 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES2)); + PointsDemoES1 demo = new PointsDemoES1(); + demo.setForceFFPEmu(true, false, false, false); + runTestGL(caps, demo, false); + } + + @Test + public void test11GLSL_GL2() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GL2)) { System.err.println("GL2 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2)); + runTestGL(caps, new PointsDemoES2(), false); + } + + @Test + public void test12GLSL_ES2() throws InterruptedException { + if(!GLProfile.isAvailable(GLProfile.GLES2)) { System.err.println("GLES2 n/a"); return; } + GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GLES2)); + runTestGL(caps, new PointsDemoES2(), false); // should be FFPEmu implicit + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i Date: Fri, 21 Dec 2012 19:24:51 +0100 Subject: GLContextImpl: Make createContextARBImpl/setGLFunctionAvailability more robost while detecting erroneous queried GL version --- make/scripts/java-win64-dbg.bat | 2 +- make/scripts/tests-x64.bat | 4 +-- make/scripts/tests.sh | 6 ++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 37 ++++++++++++++-------- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 2 +- .../jogamp/opengl/egl/EGLExternalContext.java | 2 +- .../macosx/cgl/MacOSXExternalCGLContext.java | 2 +- .../macosx/cgl/awt/MacOSXJava2DCGLContext.java | 2 +- .../windows/wgl/WindowsExternalWGLContext.java | 2 +- .../opengl/windows/wgl/WindowsWGLContext.java | 2 +- .../opengl/x11/glx/X11ExternalGLXContext.java | 2 +- .../jogamp/opengl/x11/glx/X11GLXContext.java | 4 +-- 12 files changed, 38 insertions(+), 29 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 7ececa5e4..c9f329421 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -21,7 +21,7 @@ echo CP_ALL %CP_ALL% REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" +set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 719435d74..d5d2d8f4e 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -10,7 +10,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT -time 5000 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* @@ -22,7 +22,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug551A REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 11a2dc9ba..3d8b3bcfe 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -100,7 +100,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLDrawable" @@ -264,7 +264,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* @@ -278,7 +278,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLUnitsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLUnitsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 24fc466b1..0a665f07e 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -693,8 +693,7 @@ public abstract class GLContextImpl extends GLContext { * @see #createContextARBImpl * @see #destroyContextARBImpl */ - protected abstract long createContextARBImpl(long share, boolean direct, int ctxOptionFlags, - int major, int minor); + protected abstract long createContextARBImpl(long share, boolean direct, int ctxOptionFlags, int major, int minor); /** * Destroy the context created by {@link #createContextARBImpl}. @@ -757,7 +756,7 @@ public abstract class GLContextImpl extends GLContext { _ctp[0] |= additionalCtxCreationFlags; _ctx = createContextARBImpl(share, direct, _ctp[0], _major[0], _minor[0]); if(0!=_ctx) { - setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0]); + setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0], false); } } return _ctx; @@ -940,8 +939,7 @@ public abstract class GLContextImpl extends GLContext { _context = createContextARBImpl(share, direct, ctxOptionFlags, major[0], minor[0]); if(0 != _context) { - ok = true; - setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags); + ok = setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true); } else { ok = false; } @@ -1166,15 +1164,17 @@ public abstract class GLContextImpl extends GLContext { * @param major OpenGL major version * @param minor OpenGL minor version * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY} - * + * @param strictVersionMatch if true and the ctx version (by string) is lower than the given major.minor version, + * method aborts and returns false, otherwise true. + * @return returns true if successful, otherwise false. See strictVersionMatch. * @see #setContextVersion * @see javax.media.opengl.GLContext#CTX_OPTION_ANY * @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT * @see javax.media.opengl.GLContext#CTX_IMPL_ES2_COMPAT */ - protected final void setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits) { + protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits, boolean strictVersionMatch) { if(null!=this.gl && null!=glProcAddressTable && !force) { - return; // already done and not forced + return true; // already done and not forced } if(null==this.gl || !verifyInstance(gl.getGLProfile(), "Impl", this.gl)) { @@ -1206,7 +1206,13 @@ public abstract class GLContextImpl extends GLContext { { final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0); final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); - if( null != strGLVersionNumber && ( strGLVersionNumber.compareTo(setGLVersionNumber) <= 0 || 0 == major ) ) { + if( null != strGLVersionNumber && ( strGLVersionNumber.compareTo(setGLVersionNumber) < 0 || 0 == major ) ) { + if( 0 < major && strictVersionMatch ) { + if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch: "+major+"."+minor+", ctp "+toHexString(ctxProfileBits)+", "+glVersion+", "+strGLVersionNumber); + } + return false; + } glVersionNumber = strGLVersionNumber; major = glVersionNumber.getMajor(); minor = glVersionNumber.getMinor(); @@ -1299,8 +1305,9 @@ public abstract class GLContextImpl extends GLContext { setDefaultSwapInterval(); if(DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: "+contextFQN+" - "+GLContext.getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, null)); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: OK "+contextFQN+" - "+GLContext.getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, null)); } + return true; } private final void setRendererQuirks(boolean hwAccel) { @@ -1380,16 +1387,18 @@ public abstract class GLContextImpl extends GLContext { } synchronized(mappedContextTypeObjectLock) { - ProcAddressTable table = mappedGLProcAddress.remove( contextFQN ); + final ProcAddressTable table = mappedGLProcAddress.remove( contextFQN ); if(DEBUG) { - System.err.println(getThreadName() + ": RM GLContext GL ProcAddressTable mapping key("+contextFQN+") -> "+table.hashCode()); + final int hc = null != table ? table.hashCode() : 0; + System.err.println(getThreadName() + ": RM GLContext GL ProcAddressTable mapping key("+contextFQN+") -> "+toHexString(hc)); } } synchronized(mappedContextTypeObjectLock) { - ExtensionAvailabilityCache eCache = mappedExtensionAvailabilityCache.remove( contextFQN ); + final ExtensionAvailabilityCache eCache = mappedExtensionAvailabilityCache.remove( contextFQN ); if(DEBUG) { - System.err.println(getThreadName() + ": RM GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+eCache.hashCode()); + final int hc = null != eCache ? eCache.hashCode() : 0; + System.err.println(getThreadName() + ": RM GLContext GL ExtensionAvailabilityCache mapping key("+contextFQN+") -> "+toHexString(hc)); } } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index deb3813b1..bd8e7dee9 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -214,7 +214,7 @@ public abstract class EGLContext extends GLContextImpl { throw new GLException("Error making context " + toHexString(contextHandle) + " current: error code " + toHexString(EGL.eglGetError())); } - setGLFunctionAvailability(true, glProfile.usesNativeGLES2() ? 2 : 1, 0, CTX_PROFILE_ES); + setGLFunctionAvailability(true, glProfile.usesNativeGLES2() ? 2 : 1, 0, CTX_PROFILE_ES, false); return true; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java index 84bd705db..da8fb519d 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java @@ -45,7 +45,7 @@ public class EGLExternalContext extends EGLContext { public EGLExternalContext(AbstractGraphicsScreen screen) { super(null, null); GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES, false); getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index 65ed5fc15..f121a2547 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -64,7 +64,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { setOpenGLMode(isNSContext ? GLBackendType.NSOPENGL : GLBackendType.CGL ); this.contextHandle = handle; GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java index f41400d83..bd183b900 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/awt/MacOSXJava2DCGLContext.java @@ -97,7 +97,7 @@ public class MacOSXJava2DCGLContext extends MacOSXCGLContext implements Java2DGL } return false; } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION contextHandle = ctx; return true; } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index f6cc2956d..84b29a09f 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -65,7 +65,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { System.err.println(getThreadName() + ": Created external OpenGL context " + toHexString(ctx) + " for " + this); } GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT); // use GL_VERSION + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 92d75e3fd..a654cdd04 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -308,7 +308,7 @@ public class WindowsWGLContext extends GLContextImpl { if (!WGL.wglMakeCurrent(drawable.getHandle(), temp_ctx)) { throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: "+GDI.GetLastError()); } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION WGL.wglMakeCurrent(0, 0); // release temp context if( !createContextARBTried) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index bebb4e68a..12fa5786a 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -64,7 +64,7 @@ public class X11ExternalGLXContext extends X11GLXContext { super(drawable, null); this.contextHandle = ctx; GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index bf1045132..5b0d32353 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -308,7 +308,7 @@ public abstract class X11GLXContext extends GLContextImpl { if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { throw new GLException(getThreadName()+": Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION isDirect = GLX.glXIsDirect(display, contextHandle); if (DEBUG) { System.err.println(getThreadName() + ": createContextImpl: OK (old-1) share "+share+", direct "+isDirect+"/"+direct); @@ -338,7 +338,7 @@ public abstract class X11GLXContext extends GLContextImpl { if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx)) { throw new GLException(getThreadName()+": Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable); } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION glXMakeContextCurrent(display, 0, 0, 0); // release temp context if( !createContextARBTried ) { // is*Available calls are valid since setGLFunctionAvailability(..) was called -- cgit v1.2.3 From 1ae0737f34143a5ed655bd9c4d5fe9b0437c7774 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 22 Dec 2012 05:40:36 +0100 Subject: Fix Bug 642 TestJSplitPaneMixHwLw01AWT (AWT-GLCanvas); Robustness GLContext/GLDrawable - Fix Bug 642 TestJSplitPaneMixHwLw01AWT On Windows platform when mixing hw/lw JSplitPanel, the GLCanvas is removed and added when splitter is moved. The lack of robustness (see below) lead to an exception. Note: Only w/ GLJPanel (no hw/lw mixing) the splitter can be moved in both direction. Only here it is guaranteed that the GL component will survive the action. - Fix AWT-GLCanvas EDT Runnable: swapBuffer().. / display(..) - Check drawable.isRealized() within the lock on the performing thread. This is not possible before issuing the EDT Runnable action since we cannot hold the lock beforehand. - Robustness GLDrawableImpl - boolean realized -> volatile boolean realized - remove 'synchronized' on isRealized() and setRealized(..) - Use dbl-checked locking on 'realized' test for swapBuffers() and setRealized(..) - Robustness GLContextImpl - Catch createImpl(..) exception and properly return CONTEXT_NOT_CURRENT --- make/scripts/java-win64-dbg.bat | 3 +- make/scripts/tests-x64.bat | 5 +- make/scripts/tests.sh | 8 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 6 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 9 +- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 49 +++++----- .../jogl/awt/TestBug642JSplitPaneMixHwLw01AWT.java | 3 +- .../jogl/awt/TestIsRealizedConcurrency01AWT.java | 101 +++++++++++++++++++++ .../jogl/awt/TestJScrollPaneMixHwLw01AWT.java | 3 +- 9 files changed, 154 insertions(+), 33 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestIsRealizedConcurrency01AWT.java (limited to 'make/scripts') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index c9f329421..83902ff45 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -21,7 +21,8 @@ echo CP_ALL %CP_ALL% REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" -set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" +set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index d5d2d8f4e..d33f5dfdc 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -10,7 +10,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT -time 5000 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* @@ -22,7 +22,8 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug551A REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3d8b3bcfe..767ebdae7 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -100,8 +100,9 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" + D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.fbo.force.none" @@ -264,7 +265,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* @@ -353,7 +354,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index e5f39e5de..3877a7997 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -1024,7 +1024,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final RecursiveLock _lock = lock; _lock.lock(); try { - helper.invokeGL(drawable, context, displayAction, initAction); + if( drawable.isRealized() ) { + helper.invokeGL(drawable, context, displayAction, initAction); + } } finally { _lock.unlock(); } @@ -1037,7 +1039,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final RecursiveLock _lock = lock; _lock.lock(); try { - if(null != drawable) { + if(null != drawable && drawable.isRealized() ) { drawable.swapBuffers(); } } finally { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 0a665f07e..6498a191b 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -567,7 +567,8 @@ public abstract class GLContextImpl extends GLContext { if (null != shareWith) { shareWith.getDrawableImpl().lockSurface(); } - final boolean created; + Throwable exception = null; + boolean created; try { created = createImpl(shareWith); // may throws exception if fails! if( created && isGL3core() && ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=2 ) ) { @@ -580,6 +581,9 @@ public abstract class GLContextImpl extends GLContext { defaultVAO = tmp[0]; gl.getGL2GL3().glBindVertexArray(defaultVAO); } + } catch (Throwable t) { + exception = t; + created = false; } finally { if (null != shareWith) { shareWith.getDrawableImpl().unlockSurface(); @@ -591,6 +595,9 @@ public abstract class GLContextImpl extends GLContext { // Thread.dumpStack(); } else { System.err.println(getThreadName() + ": Create GL context FAILED obj " + toHexString(hashCode()) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName()); + if(null != exception) { + exception.printStackTrace(); + } } } if(!created) { diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index ccf0a8f0d..2d062eaf1 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -76,7 +76,7 @@ public abstract class GLDrawableImpl implements GLDrawable { @Override public final void swapBuffers() throws GLException { - if( !realized ) { + if( !realized ) { // volatile OK (locked below) return; // destroyed already } int lockRes = lockSurface(); // it's recursive, so it's ok within [makeCurrent .. release] @@ -87,17 +87,19 @@ public abstract class GLDrawableImpl implements GLDrawable { if (NativeSurface.LOCK_SURFACE_CHANGED == lockRes) { updateHandle(); } - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); - if ( caps.getDoubleBuffered() ) { - if(!surface.surfaceSwap()) { - swapBuffersImpl(true); - } - } else { - final GLContext ctx = GLContext.getCurrent(); - if(null!=ctx && ctx.getGLDrawable()==this) { - ctx.getGL().glFlush(); + if( realized ) { // volatile OK + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable)surface.getGraphicsConfiguration().getChosenCapabilities(); + if ( caps.getDoubleBuffered() ) { + if(!surface.surfaceSwap()) { + swapBuffersImpl(true); + } + } else { + final GLContext ctx = GLContext.getCurrent(); + if(null!=ctx && ctx.getGLDrawable()==this) { + ctx.getGL().glFlush(); + } + swapBuffersImpl(false); } - swapBuffersImpl(false); } } finally { unlockSurface(); @@ -160,12 +162,11 @@ public abstract class GLDrawableImpl implements GLDrawable { } @Override - public final synchronized void setRealized(boolean realizedArg) { - if ( realized != realizedArg ) { + public final void setRealized(boolean realizedArg) { + if ( realized != realizedArg ) { // volatile: OK (locked below) if(DEBUG) { System.err.println(getThreadName() + ": setRealized: "+getClass().getSimpleName()+" "+realized+" -> "+realizedArg); } - realized = realizedArg; AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice(); if(realizedArg) { if(surface instanceof ProxySurface) { @@ -178,12 +179,15 @@ public abstract class GLDrawableImpl implements GLDrawable { aDevice.lock(); } try { - if(realizedArg) { - setRealizedImpl(); - updateHandle(); - } else { - destroyHandle(); - setRealizedImpl(); + if ( realized != realizedArg ) { // volatile: OK + realized = realizedArg; + if(realizedArg) { + setRealizedImpl(); + updateHandle(); + } else { + destroyHandle(); + setRealizedImpl(); + } } } finally { if(realizedArg) { @@ -199,6 +203,7 @@ public abstract class GLDrawableImpl implements GLDrawable { System.err.println(getThreadName() + ": setRealized: "+getClass().getName()+" "+this.realized+" == "+realizedArg); } } + /** * Platform specific realization of drawable */ @@ -256,7 +261,7 @@ public abstract class GLDrawableImpl implements GLDrawable { } @Override - public final synchronized boolean isRealized() { + public final boolean isRealized() { return realized; } @@ -306,6 +311,6 @@ public abstract class GLDrawableImpl implements GLDrawable { // result of calling show() on the main thread. To work around this // we prevent any JAWT or OpenGL operations from being done until // addNotify() is called on the surface. - protected boolean realized; + protected volatile boolean realized; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug642JSplitPaneMixHwLw01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug642JSplitPaneMixHwLw01AWT.java index d0c07570a..76b6ba0d7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug642JSplitPaneMixHwLw01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug642JSplitPaneMixHwLw01AWT.java @@ -77,7 +77,8 @@ public class TestBug642JSplitPaneMixHwLw01AWT extends UITestCase { } protected void runTestGL(GLCapabilities caps, boolean useGLJPanel) throws InterruptedException { - final JFrame frame = new JFrame("JSplitPane Mix Hw/Lw Swing"); + final String typeS = useGLJPanel ? "LW" : "HW"; + final JFrame frame = new JFrame("Mix Hw/Lw Swing - Canvas "+typeS); Assert.assertNotNull(frame); final Dimension f_sz = new Dimension(824,568); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestIsRealizedConcurrency01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestIsRealizedConcurrency01AWT.java new file mode 100644 index 000000000..778f07fff --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestIsRealizedConcurrency01AWT.java @@ -0,0 +1,101 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import javax.media.opengl.awt.GLCanvas; +import com.jogamp.opengl.util.Animator; + +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import com.jogamp.opengl.test.junit.util.MiscUtils; + +import java.awt.Dimension; +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; + +import org.junit.Assert; +import org.junit.Test; + + +public class TestIsRealizedConcurrency01AWT extends UITestCase { + static long durationPerTest = 1000; // ms + + @Test + public void testAddRemove() throws InterruptedException, InvocationTargetException { + final Dimension f_sz = new Dimension(512, 512); + + final GLCanvas glCanvas = new GLCanvas(); + Assert.assertNotNull(glCanvas); + glCanvas.addGLEventListener(new GearsES2()); + + final Animator animator = new Animator(glCanvas); + animator.start(); + + final Frame frame = new Frame("Frame"); + Assert.assertNotNull(frame); + frame.add(glCanvas); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setLocation(0, 0); + frame.setPreferredSize(f_sz); + frame.setSize(f_sz); + frame.pack(); + frame.setVisible(true); + }}); + Thread.sleep(durationPerTest/2); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas); + frame.validate(); + frame.add(glCanvas); + frame.validate(); + }}); + Thread.sleep(durationPerTest/2); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + glCanvas.destroy(); + frame.dispose(); + }}); + + animator.stop(); + } + + public static void main(String args[]) { + for(int i=0; i Date: Sat, 22 Dec 2012 07:09:47 +0100 Subject: Fix regression of commit b8a8fc24a3afb0cb06a31504bdea1a98b8f00ef4: Cache ShaderState for share ctor. --- make/scripts/java-win32-dbg.bat | 2 +- make/scripts/java-win64-dbg.bat | 2 +- make/scripts/tests.sh | 6 +++--- .../jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java | 9 +++++---- 4 files changed, 10 insertions(+), 9 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat index e0760d02b..a4a9e9a5b 100755 --- a/make/scripts/java-win32-dbg.bat +++ b/make/scripts/java-win32-dbg.bat @@ -21,7 +21,7 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluege echo CP_ALL %CP_ALL% -set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.FBObject" "-Djogl.enable.ANGLE" +REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.FBObject" "-Djogl.enable.ANGLE" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 83902ff45..f0a0e9ad7 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -22,7 +22,7 @@ REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" -set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" +REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 767ebdae7..9187ba162 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -102,7 +102,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" - D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" + #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.fbo.force.none" @@ -276,7 +276,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLUnitsNEWT $* @@ -354,7 +354,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java index 826f68cc3..eb9647949 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java @@ -36,10 +36,10 @@ import com.jogamp.opengl.util.glsl.ShaderState; * @author Brian Paul (converted to Java by Ron Cemer and Sven Gothel)

    */ public class GearsObjectES2 extends GearsObject { - PMVMatrix pmvMatrix; - GLUniformData pmvMatrixUniform; - GLUniformData colorUniform; - ShaderState st; + final PMVMatrix pmvMatrix; + final GLUniformData pmvMatrixUniform; + final GLUniformData colorUniform; + final ShaderState st; public GearsObjectES2(ShaderState st, float inner_radius, float outer_radius, float width, int teeth, @@ -64,6 +64,7 @@ public class GearsObjectES2 extends GearsObject { this.pmvMatrix = pmvMatrix; this.pmvMatrixUniform = pmvMatrixUniform; this.colorUniform = colorUniform; + this.st = st; associate(st); } -- cgit v1.2.3 From 97b817685af3fcb67f02ddd50f87627b97dd3e5b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 22 Dec 2012 07:18:30 +0100 Subject: Bug 642 / Refine 1ae0737f34143a5ed655bd9c4d5fe9b0437c7774: GLCanvas.displayOnEDT: Also check null!=drawable As for 1ae0737f34143a5ed655bd9c4d5fe9b0437c7774, an animator may inject a display Runnable on the EDT before AWT destruction. In case this Runnable is executed after destruction on the EDT - it would fail. --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9187ba162..6f6438267 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -276,7 +276,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLUnitsNEWT $* @@ -392,7 +392,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* # # newt.awt (testawt) # -#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* +testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 3877a7997..efdc69ed8 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -1024,7 +1024,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final RecursiveLock _lock = lock; _lock.lock(); try { - if( drawable.isRealized() ) { + if( null != drawable && drawable.isRealized() ) { helper.invokeGL(drawable, context, displayAction, initAction); } } finally { @@ -1039,7 +1039,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final RecursiveLock _lock = lock; _lock.lock(); try { - if(null != drawable && drawable.isRealized() ) { + if( null != drawable && drawable.isRealized() ) { drawable.swapBuffers(); } } finally { -- cgit v1.2.3 From f3e2467decf2a5ee47cfb458f7071772f39ea9c6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Dec 2012 01:55:55 +0100 Subject: AWT-NEWT Modifier mapping and test: part-3 (NEWT BUTTON MASK always, ..) - AWTNewtEventFactory's awtModifiers2Newt: - always include NEWT BUTTON_MASK (press, release, ..) where AWT doesn't include them at release (it's only a DOWN_MASK). - Test BaseNewtEventModifiers, .. - No need to call super class Before, BeforeClass, .. manually - Use RedSquareES2 as GL demo - Adapt to AWTNewtEventFactory's modifier change above (NEWT BUTTON MASK even at release) - More descriptive error/log text - Added _mandatory_ TestNewtEventModifiersNEWTWindowAWT to test native NEWT behavior. This shall be the golden behavior all translated events shall compare w/. --- make/scripts/tests-x64.bat | 15 ++- make/scripts/tests.sh | 16 ++- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 14 +- .../junit/newt/event/BaseNewtEventModifiers.java | 150 +++++++-------------- .../event/TestNewtEventModifiersAWTCanvas.java | 7 +- .../event/TestNewtEventModifiersNEWTWindowAWT.java | 75 +++++++++++ .../event/TestNewtEventModifiersNewtCanvasAWT.java | 7 +- .../event/TestNewtEventModifiersNewtCanvasSWT.java | 7 +- 8 files changed, 154 insertions(+), 137 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index d33f5dfdc..7cced0ecc 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -22,7 +22,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug551A REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* @@ -40,11 +40,14 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSi REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6f6438267..d96acf2e5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -392,16 +392,20 @@ function testawtswt() { # # newt.awt (testawt) # -testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* +#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventOrderAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyEventAutoRepeatAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodesAWT $* -#testawt com.jogamp.opengl.test.junit.newt.TestNewtKeyCodeModifiersAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index 665b7b5ee..1a61d0528 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -194,11 +194,8 @@ public class AWTNewtEventFactory { * @param awtModsEx * The AWT extended event modifiers. * AWT passes mouse button specific bits here and are the preferred way check the mouse button state. - * - * @param mouseHint - * Not used currently. */ - public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx, final boolean mouseHint) { + public static final int awtModifiers2Newt(final int awtMods, final int awtModsEx) { int newtMods = 0; /** Redundant old modifiers .. @@ -271,7 +268,9 @@ public class AWTNewtEventFactory { rotation = -1 * ((java.awt.event.MouseWheelEvent)event).getWheelRotation(); } - int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx(), true); + final int newtButton = awtButton2Newt(event.getButton()); + int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()); + mods |= com.jogamp.newt.event.InputEvent.getButtonMask(newtButton); // always include NEWT BUTTON_MASK if(null!=newtSource) { if(newtSource.isPointerConfined()) { mods |= com.jogamp.newt.event.InputEvent.CONFINED_MASK; @@ -280,11 +279,10 @@ public class AWTNewtEventFactory { mods |= com.jogamp.newt.event.InputEvent.INVISIBLE_MASK; } } - return new com.jogamp.newt.event.MouseEvent( type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), mods, event.getX(), event.getY(), event.getClickCount(), - awtButton2Newt(event.getButton()), rotation); + newtButton, rotation); } return null; // no mapping .. } @@ -294,7 +292,7 @@ public class AWTNewtEventFactory { if(0xFFFFFFFF != type) { return new com.jogamp.newt.event.KeyEvent( type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), - awtModifiers2Newt(event.getModifiers(), event.getModifiersEx(), false), + awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), event.getKeyCode(), event.getKeyChar()); } return null; // no mapping .. diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 1dfdc4021..53af603ba 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -31,10 +31,6 @@ package com.jogamp.opengl.test.junit.newt.event ; import java.io.PrintStream ; import java.util.ArrayList ; -import javax.media.opengl.GL ; -import javax.media.opengl.GL2 ; -import javax.media.opengl.GLAutoDrawable ; -import javax.media.opengl.GLEventListener ; import javax.media.opengl.GLProfile ; import org.junit.After ; @@ -44,7 +40,6 @@ import org.junit.Before ; import org.junit.BeforeClass ; import org.junit.Test ; -import com.jogamp.common.os.Platform; import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.test.junit.util.UITestCase ; @@ -61,63 +56,6 @@ public abstract class BaseNewtEventModifiers extends UITestCase { GLProfile.initSingleton() ; } - // A class to draw something on a canvas. This is only - // here so we can make sure the GL drawing area has - // filled the window. - - public static class BigGreenXGLEventListener implements GLEventListener - { - public void init( GLAutoDrawable drawable ) - { - GL2 gl = drawable.getGL().getGL2() ; - - gl.glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ) ; - - gl.glEnable( GL.GL_LINE_SMOOTH ) ; - gl.glEnable( GL.GL_BLEND ) ; - gl.glBlendFunc( GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA ) ; - } - - public void reshape( GLAutoDrawable drawable, int x, int y, int width, int height ) - { - GL2 gl = drawable.getGL().getGL2() ; - - gl.glViewport( 0, 0, width, height ) ; - - gl.glMatrixMode( GL2.GL_PROJECTION ) ; - gl.glLoadIdentity() ; - gl.glOrtho( -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 ) ; - - gl.glMatrixMode( GL2.GL_MODELVIEW ) ; - gl.glLoadIdentity() ; - } - - public void display( GLAutoDrawable drawable ) - { - GL2 gl = drawable.getGL().getGL2() ; - - gl.glClear( GL2.GL_COLOR_BUFFER_BIT ) ; - - gl.glColor4f( 0.0f, 1.0f, 0.0f, 1.0f ) ; - - gl.glBegin( GL.GL_LINES ) ; - { - gl.glVertex2f( -1.0f, 1.0f ) ; - gl.glVertex2f( 1.0f, -1.0f ) ; - - gl.glVertex2f( -1.0f, -1.0f ) ; - gl.glVertex2f( 1.0f, 1.0f ) ; - } - gl.glEnd() ; - } - - public void dispose( GLAutoDrawable drawable ) - { - } - } - - //////////////////////////////////////////////////////////////////////////// - private static class TestMouseListener implements com.jogamp.newt.event.MouseListener { private static final String NO_EVENT_DELIVERY = "no event delivery" ; @@ -152,34 +90,36 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _failures.add( NO_EVENT_DELIVERY ) ; } - private void _checkModifiers( com.jogamp.newt.event.MouseEvent event ) { + private void _checkModifiers( com.jogamp.newt.event.MouseEvent hasEvent ) { if( _debug ) { _debugPrintStream.print( " received NEWT " ) ; - _debugPrintStream.print( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ) ; + _debugPrintStream.print( com.jogamp.newt.event.MouseEvent.getEventTypeString( hasEvent.getEventType() ) ) ; } if( _modifierCheckEnabled ) { + final MouseEvent expEvent = new MouseEvent(hasEvent.getEventType(), hasEvent.getSource(), hasEvent.getWhen(), _expectedModifiers, + hasEvent.getX(), hasEvent.getY(), hasEvent.getClickCount(), hasEvent.getButton(), hasEvent.getWheelRotation()); + if( _debug ) { _debugPrintStream.println( ", checking modifiers..." ) ; _debugPrintStream.println( " expected NEWT Modifiers:" ) ; { - final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); - _debugPrintStream.println(" "+exp.getModifiersString(null).toString()); + _debugPrintStream.println(" "+expEvent.getModifiersString(null).toString()); } _debugPrintStream.println( " current NEWT Modifiers:" ) ; - _debugPrintStream.println(" "+event.getModifiersString(null).toString()); + _debugPrintStream.println(" "+hasEvent.getModifiersString(null).toString()); } - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.SHIFT_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.CTRL_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.META_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_MASK ) ; - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.SHIFT_MASK, "shift" ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.CTRL_MASK, "ctrl" ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.META_MASK, "meta" ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.ALT_MASK, "alt" ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.ALT_GRAPH_MASK, "graph" ) ; for( int n = 0 ; n < _numButtonsToTest ; ++n ) { - _checkModifierMask( event, com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ) ) ; + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ), "button"+(n+1) ) ; } } else { if( _debug ) { @@ -188,7 +128,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } } - private void _checkModifierMask( com.jogamp.newt.event.MouseEvent event, int mask ) { + private void _checkModifierMask( com.jogamp.newt.event.MouseEvent expEvent, com.jogamp.newt.event.MouseEvent hasEvent, int mask, String maskS ) { // If the "no event delivery" failure is still in the list then // get rid of it since that obviously isn't true anymore. We @@ -199,15 +139,21 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _failures.clear() ; } - if( ( event.getModifiers() & mask ) != ( _expectedModifiers & mask ) ) { + if( ( hasEvent.getModifiers() & mask ) != ( expEvent.getModifiers() & mask ) ) { StringBuilder sb = new StringBuilder(); - sb.append( com.jogamp.newt.event.MouseEvent.getEventTypeString( event.getEventType() ) ).append(": "); - final MouseEvent exp = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, null, 0, _expectedModifiers, 0, 0, 1, 1, 0); - sb.append("Expected:").append(Platform.NEWLINE); - exp.getModifiersString(sb).append(Platform.NEWLINE); - sb.append(", Have: ").append(Platform.NEWLINE); - event.getModifiersString(sb).append(Platform.NEWLINE); + sb.append( com.jogamp.newt.event.MouseEvent.getEventTypeString( hasEvent.getEventType() ) ).append(": mask ").append(maskS).append(" 0x").append(Integer.toHexString(mask)); + sb.append(", expected:"); + expEvent.getModifiersString(sb); + sb.append(", have: "); + hasEvent.getModifiersString(sb); _failures.add( sb.toString() ) ; + /** + System.err.println("*** MASK: 0x"+Integer.toHexString(mask)); + System.err.println("*** EXP: "+expEvent); + System.err.println("*** EXP: 0x"+Integer.toHexString(expEvent.getModifiers())); + System.err.println("*** HAS: "+hasEvent); + System.err.println("*** HAS: 0x"+Integer.toHexString(hasEvent.getModifiers())); + throw new RuntimeException(sb.toString()); */ } } @@ -290,7 +236,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } @BeforeClass - public static void beforeClass() throws Exception { + public static void baseBeforeClass() throws Exception { // Who know how many buttons the AWT will say exist on given platform. // We'll test the smaller of what NEWT supports and what the @@ -342,7 +288,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// @Before - public void before() throws Exception { + public void baseBeforeTest() throws Exception { _testMouseListener.setModifierCheckEnabled( false ) ; _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; @@ -360,8 +306,8 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; - _robot.mousePress( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; - _robot.mouseRelease( java.awt.event.InputEvent.BUTTON1_DOWN_MASK ) ; + _robot.mousePress( java.awt.event.InputEvent.BUTTON1_MASK ); // java7: java.awt.event.InputEvent.BUTTON1_DOWN_MASK + _robot.mouseRelease( java.awt.event.InputEvent.BUTTON1_MASK ) ; // java7: java.awt.event.InputEvent.BUTTON1_DOWN_MASK _testMouseListener.setModifierCheckEnabled( true ) ; _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; @@ -410,14 +356,14 @@ public abstract class BaseNewtEventModifiers extends UITestCase { // so it's probably best to leave them commented out. //@Test - //public void testSingleButtonPressAndReleaseWithMeta() throws Exception { - // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; - //} + public void testSingleButtonPressAndReleaseWithMeta() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; + } //@Test - //public void testSingleButtonPressAndReleaseWithAlt() throws Exception { - // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; - //} + public void testSingleButtonPressAndReleaseWithAlt() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; + } // FIXME - not sure yet what's up with ALT_GRAPH. It appears that this // modifier didn't make it through, so I had to disable this test else @@ -427,9 +373,9 @@ public abstract class BaseNewtEventModifiers extends UITestCase { // enough to not let this modifier slip through (?). //@Test - //public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { - // _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; - //} + public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; + } //////////////////////////////////////////////////////////////////////////// @@ -466,7 +412,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _checkFailures() ; if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mouseRelease( awtButtonMask ) ; _checkFailures() ; } @@ -501,14 +447,14 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _checkFailures() ; if( _debug ) { _debugPrintStream.println( "\n releasing additional button " + ( m + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask | _awtButtonMasks[m] ) ) ; _robot.mouseRelease( _awtButtonMasks[m] ) ; _checkFailures() ; } } if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mouseRelease( awtButtonMask ) ; _checkFailures() ; } @@ -539,12 +485,12 @@ public abstract class BaseNewtEventModifiers extends UITestCase { for (int n = _numButtonsToTest - 1 ; n >= 0 ; --n) { - cumulativeAwtModifiers &= ~_awtButtonMasks[n] ; - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; _robot.mouseRelease( _awtButtonMasks[n] ) ; _checkFailures() ; + + cumulativeAwtModifiers &= ~_awtButtonMasks[n] ; } } @@ -576,7 +522,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _checkFailures() ; if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } - _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask ) ) ; + _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mouseRelease( awtButtonMask ) ; _checkFailures() ; @@ -635,7 +581,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// @After - public void after() throws Exception { + public void baseAfterTest() throws Exception { _testMouseListener.setModifierCheckEnabled( false ) ; @@ -645,7 +591,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// @AfterClass - public static void afterClass() throws Exception { + public static void baseAfterClass() throws Exception { // Make sure all modifiers are released, otherwise the user's // desktop can get locked up (ask me how I know this). diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java index fd68ace73..725dbe97f 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java @@ -38,6 +38,7 @@ import org.junit.AfterClass ; import org.junit.BeforeClass ; import com.jogamp.newt.event.awt.AWTMouseAdapter ; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; /** * Test whether or not event modifiers are preserved by NEWT when @@ -53,10 +54,8 @@ public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { @BeforeClass public static void beforeClass() throws Exception { - BaseNewtEventModifiers.beforeClass() ; - final GLCanvas canvas = new GLCanvas() ; - canvas.addGLEventListener( new BigGreenXGLEventListener() ) ; + canvas.addGLEventListener( new RedSquareES2() ) ; new AWTMouseAdapter( _testMouseListener ).addTo( (java.awt.Component)canvas ) ; _testFrame = new JFrame( "Event Modifier Test AWTCanvas" ) ; @@ -76,8 +75,6 @@ public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { @AfterClass public static void afterClass() throws Exception { - BaseNewtEventModifiers.afterClass() ; - SwingUtilities.invokeAndWait(new Runnable() { public void run() { _testFrame.dispose() ; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java new file mode 100644 index 000000000..d6088e6a2 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java @@ -0,0 +1,75 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.event; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass ; +import org.junit.BeforeClass ; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; + +/** + * Test whether or not event modifiers are properly delivered by NEWT. + */ +public class TestNewtEventModifiersNEWTWindowAWT extends BaseNewtEventModifiers { + + private static GLWindow glWindow; + + //////////////////////////////////////////////////////////////////////////// + + @BeforeClass + public static void beforeClass() throws Exception { + glWindow = GLWindow.create( new GLCapabilities( GLProfile.getGL2ES2() ) ); + glWindow.setTitle("Event Modifier Test GLWindow"); + glWindow.addGLEventListener( new RedSquareES2() ) ; + glWindow.addMouseListener(_testMouseListener); + glWindow.setSize(TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT); + glWindow.setPosition(TEST_FRAME_X, TEST_FRAME_Y); + glWindow.setVisible(true); + } + + //////////////////////////////////////////////////////////////////////////// + + @AfterClass + public static void afterClass() throws Exception { + glWindow.destroy(); + } + + //////////////////////////////////////////////////////////////////////////// + + public static void main(String args[]) throws Exception { + String testName = TestNewtEventModifiersNEWTWindowAWT.class.getName() ; + org.junit.runner.JUnitCore.main( testName ) ; + } + + //////////////////////////////////////////////////////////////////////////// +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java index 44f116ea1..5590300c7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java @@ -42,6 +42,7 @@ import org.junit.BeforeClass ; import com.jogamp.newt.awt.NewtCanvasAWT ; import com.jogamp.newt.opengl.GLWindow ; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; /** * Test whether or not event modifiers are preserved by NEWT when @@ -58,8 +59,6 @@ public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - BaseNewtEventModifiers.beforeClass() ; - SwingUtilities.invokeAndWait( new Runnable() { public void run() { @@ -73,7 +72,7 @@ public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers NewtCanvasAWT canvas = new NewtCanvasAWT( _glWindow ) ; _testFrame.getContentPane().add( canvas, BorderLayout.CENTER ) ; - _glWindow.addGLEventListener( new BigGreenXGLEventListener() ) ; + _glWindow.addGLEventListener( new RedSquareES2() ) ; } _testFrame.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; @@ -89,8 +88,6 @@ public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - BaseNewtEventModifiers.afterClass() ; - SwingUtilities.invokeAndWait( new Runnable() { public void run() { _testFrame.dispose() ; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java index 501e0d1bd..c0d1690de 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java @@ -41,6 +41,7 @@ import org.junit.BeforeClass ; import com.jogamp.newt.opengl.GLWindow ; import com.jogamp.newt.swt.NewtCanvasSWT ; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; /** * Test whether or not event modifiers preserved by NEWT when @@ -87,8 +88,6 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers @BeforeClass public static void beforeClass() throws Exception { - BaseNewtEventModifiers.beforeClass() ; - _displayThread = new DisplayThread() ; _displayThread.start() ; @@ -111,7 +110,7 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers NewtCanvasSWT.create( _testShell, SWT.NO_BACKGROUND, _glWindow ) ; - _glWindow.addGLEventListener( new BigGreenXGLEventListener() ) ; + _glWindow.addGLEventListener( new RedSquareES2() ) ; } _testShell.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; @@ -127,8 +126,6 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - BaseNewtEventModifiers.afterClass() ; - _glWindow.destroy() ; _displayThread.getDisplay().syncExec( new Runnable() { -- cgit v1.2.3 From d45f777e7969769eaa9b7d7f3eb5b34c10268368 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Dec 2012 07:01:40 +0100 Subject: AWT-NEWT Modifier mapping and test: part-3 (Fix unit tests) - Finetune delay - Wait for eventCount - Fix Listener concurrency - Manually tested (enabled in our unit tests now) - Tool Combinations - NEWT GLWindow - AWT GLCanvas - NewtCanvasAWT - NewtCanvasSWT - On - Linux/X11 - Windows - OSX(+) (+): Failure NEWT: When multiple buttons are pressed, only the last one is visible via modifier MASK. "expected:[button1, button2], have: [button2]" --- make/scripts/tests-x64.bat | 1 + .../junit/newt/event/BaseNewtEventModifiers.java | 321 +++++++++++---------- .../event/TestNewtEventModifiersAWTCanvas.java | 8 +- .../event/TestNewtEventModifiersNEWTWindowAWT.java | 26 +- .../event/TestNewtEventModifiersNewtCanvasAWT.java | 12 +- .../event/TestNewtEventModifiersNewtCanvasSWT.java | 8 +- 6 files changed, 209 insertions(+), 167 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 7cced0ecc..09a45f816 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -45,6 +45,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtK REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 53af603ba..b4ece6c46 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -51,6 +51,29 @@ import com.jogamp.opengl.test.junit.util.UITestCase ; public abstract class BaseNewtEventModifiers extends UITestCase { + //////////////////////////////////////////////////////////////////////////// + + protected static final int TEST_FRAME_X = 100 ; + protected static final int TEST_FRAME_Y = 100 ; + + protected static final int TEST_FRAME_WIDTH = 400 ; + protected static final int TEST_FRAME_HEIGHT = 400 ; + + private static final int INITIAL_MOUSE_X = TEST_FRAME_X + ( TEST_FRAME_WIDTH / 2 ) ; + private static final int INITIAL_MOUSE_Y = TEST_FRAME_Y + ( TEST_FRAME_HEIGHT / 2 ) ; + + private static final int MS_ROBOT_KEY_PRESS_DELAY = 50 ; + private static final int MS_ROBOT_KEY_RELEASE_DELAY = 50 ; + private static final int MS_ROBOT_MOUSE_MOVE_DELAY = 100 ; + + private static final int MS_ROBOT_AUTO_DELAY = 50 ; + private static final int MS_ROBOT_POST_TEST_DELAY = 100; + + private static final boolean _debug = true ; + private static PrintStream _debugPrintStream = System.err ; + + //////////////////////////////////////////////////////////////////////////// + static { GLProfile.initSingleton() ; @@ -61,14 +84,15 @@ public abstract class BaseNewtEventModifiers extends UITestCase { private static final String NO_EVENT_DELIVERY = "no event delivery" ; private boolean _modifierCheckEnabled ; - private int _expectedModifiers ; + private int _expectedModifiers; + private volatile int _eventCount ; private ArrayList _failures = new ArrayList() ; - public void setModifierCheckEnabled( boolean value ) { + public synchronized void setModifierCheckEnabled( boolean value ) { _modifierCheckEnabled = value ; } - public boolean modifierCheckEnabled() { + public synchronized boolean modifierCheckEnabled() { return _modifierCheckEnabled ; } @@ -79,39 +103,41 @@ public abstract class BaseNewtEventModifiers extends UITestCase { * in this test code it's probably ok. */ - public void setExpectedModifiers( int value ) { + public synchronized void setExpectedModifiers( int value ) { _expectedModifiers = value ; + clear(); + } + + public synchronized ArrayList clear() { + ArrayList old = _failures; + + _eventCount = 0; // Assume we will have a failure due to no event delivery. // If an event is delivered and it's good this assumed - // failure will get cleared out. - - _failures.clear() ; - _failures.add( NO_EVENT_DELIVERY ) ; + // failure will get cleared out. + _failures = new ArrayList(); + _failures.add( NO_EVENT_DELIVERY ); + return old; } - private void _checkModifiers( com.jogamp.newt.event.MouseEvent hasEvent ) { - - if( _debug ) { - _debugPrintStream.print( " received NEWT " ) ; - _debugPrintStream.print( com.jogamp.newt.event.MouseEvent.getEventTypeString( hasEvent.getEventType() ) ) ; + public ArrayList getFailures(int waitEventCount) { + int j; + for(j=0; j < 20 && _eventCount < waitEventCount; j++) { // wait until events are collected + _robot.delay(MS_ROBOT_AUTO_DELAY); } - + if(0 == _eventCount) { + _debugPrintStream.println("**** No Event. Waited "+j+" * "+MS_ROBOT_AUTO_DELAY+"ms, eventCount "+_eventCount); + } + return clear(); + } + + private synchronized void _checkModifiers( com.jogamp.newt.event.MouseEvent hasEvent ) { if( _modifierCheckEnabled ) { final MouseEvent expEvent = new MouseEvent(hasEvent.getEventType(), hasEvent.getSource(), hasEvent.getWhen(), _expectedModifiers, hasEvent.getX(), hasEvent.getY(), hasEvent.getClickCount(), hasEvent.getButton(), hasEvent.getWheelRotation()); - if( _debug ) { - _debugPrintStream.println( ", checking modifiers..." ) ; - _debugPrintStream.println( " expected NEWT Modifiers:" ) ; - { - _debugPrintStream.println(" "+expEvent.getModifiersString(null).toString()); - } - _debugPrintStream.println( " current NEWT Modifiers:" ) ; - _debugPrintStream.println(" "+hasEvent.getModifiersString(null).toString()); - } - _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.SHIFT_MASK, "shift" ) ; _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.CTRL_MASK, "ctrl" ) ; _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.META_MASK, "meta" ) ; @@ -121,14 +147,10 @@ public abstract class BaseNewtEventModifiers extends UITestCase { for( int n = 0 ; n < _numButtonsToTest ; ++n ) { _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.getButtonMask( n + 1 ), "button"+(n+1) ) ; } - } else { - if( _debug ) { - _debugPrintStream.println( ", modifier check disabled" ) ; - } } } - private void _checkModifierMask( com.jogamp.newt.event.MouseEvent expEvent, com.jogamp.newt.event.MouseEvent hasEvent, int mask, String maskS ) { + private synchronized void _checkModifierMask( com.jogamp.newt.event.MouseEvent expEvent, com.jogamp.newt.event.MouseEvent hasEvent, int mask, String maskS ) { // If the "no event delivery" failure is still in the list then // get rid of it since that obviously isn't true anymore. We @@ -142,81 +164,88 @@ public abstract class BaseNewtEventModifiers extends UITestCase { if( ( hasEvent.getModifiers() & mask ) != ( expEvent.getModifiers() & mask ) ) { StringBuilder sb = new StringBuilder(); sb.append( com.jogamp.newt.event.MouseEvent.getEventTypeString( hasEvent.getEventType() ) ).append(": mask ").append(maskS).append(" 0x").append(Integer.toHexString(mask)); - sb.append(", expected:"); + sb.append(", eventCount ").append(_eventCount).append(", expected:"); expEvent.getModifiersString(sb); sb.append(", have: "); hasEvent.getModifiersString(sb); + sb.append(" - full event: "); + hasEvent.toString(sb); _failures.add( sb.toString() ) ; - /** - System.err.println("*** MASK: 0x"+Integer.toHexString(mask)); - System.err.println("*** EXP: "+expEvent); - System.err.println("*** EXP: 0x"+Integer.toHexString(expEvent.getModifiers())); - System.err.println("*** HAS: "+hasEvent); - System.err.println("*** HAS: 0x"+Integer.toHexString(hasEvent.getModifiers())); - throw new RuntimeException(sb.toString()); */ } } - public ArrayList getFailures() { - return _failures ; - } - - public void mouseClicked( com.jogamp.newt.event.MouseEvent event ) { + public synchronized void mouseClicked( com.jogamp.newt.event.MouseEvent event ) { + _eventCount++; + if( _debug ) { + _debugPrintStream.println( "MouseClicked "+_eventCount+": "+event); + } _checkModifiers( event ) ; } - public void mousePressed( com.jogamp.newt.event.MouseEvent event ) { + public synchronized void mousePressed( com.jogamp.newt.event.MouseEvent event ) { + _eventCount++; + if( _debug ) { + _debugPrintStream.println( "MousePressed "+_eventCount+": "+event); + } _checkModifiers( event ) ; } - public void mouseReleased( com.jogamp.newt.event.MouseEvent event ) { + public synchronized void mouseReleased( com.jogamp.newt.event.MouseEvent event ) { + _eventCount++; + if( _debug ) { + _debugPrintStream.println( "MouseReleased "+_eventCount+": "+event); + } _checkModifiers( event ) ; } - public void mouseEntered( com.jogamp.newt.event.MouseEvent event ) { + public synchronized void mouseEntered( com.jogamp.newt.event.MouseEvent event ) { + _eventCount++; + if( _debug ) { + _debugPrintStream.println( "MouseEntered "+_eventCount+": "+event); + } _checkModifiers( event ) ; } - public void mouseExited( com.jogamp.newt.event.MouseEvent event ) { + public synchronized void mouseExited( com.jogamp.newt.event.MouseEvent event ) { + _eventCount++; + if( _debug ) { + _debugPrintStream.println( "MouseExited "+_eventCount+": "+event); + } _checkModifiers( event ) ; } - public void mouseDragged( com.jogamp.newt.event.MouseEvent event ) { + public synchronized void mouseDragged( com.jogamp.newt.event.MouseEvent event ) { + _eventCount++; + if( _debug ) { + _debugPrintStream.println( "MouseDragged "+_eventCount+": "+event); + } _checkModifiers( event ) ; } - public void mouseMoved( com.jogamp.newt.event.MouseEvent event ) { - _checkModifiers( event ) ; + public synchronized void mouseMoved( com.jogamp.newt.event.MouseEvent event ) { + // Ignored, since mouse MOVE doesn't hold mouse button, we look for DRAGGED! + // _eventCount++; + if( _debug ) { + _debugPrintStream.println( "MouseMoved ignored: "+event); + } + // _checkModifiers( event ) ; } - public void mouseWheelMoved( com.jogamp.newt.event.MouseEvent event ) { + public synchronized void mouseWheelMoved( com.jogamp.newt.event.MouseEvent event ) { + _eventCount++; + if( _debug ) { + _debugPrintStream.println( "MouseWheeleMoved "+_eventCount+": "+event); + } _checkModifiers( event ) ; } } //////////////////////////////////////////////////////////////////////////// - protected static final int TEST_FRAME_X = 100 ; - protected static final int TEST_FRAME_Y = 100 ; - - protected static final int TEST_FRAME_WIDTH = 400 ; - protected static final int TEST_FRAME_HEIGHT = 400 ; - - private static final int INITIAL_MOUSE_X = TEST_FRAME_X + ( TEST_FRAME_WIDTH / 2 ) ; - private static final int INITIAL_MOUSE_Y = TEST_FRAME_Y + ( TEST_FRAME_HEIGHT / 2 ) ; - - private static final int MS_ROBOT_SHORT_AUTO_DELAY = 50 ; - private static final int MS_ROBOT_LONG_AUTO_DELAY = 500 ; - - private static boolean _debug = true ; - private static PrintStream _debugPrintStream = System.err ; - - //////////////////////////////////////////////////////////////////////////// - private static int _numButtonsToTest ; private static int _awtButtonMasks[] ; - private static java.awt.Robot _robot ; + protected static java.awt.Robot _robot ; protected static TestMouseListener _testMouseListener ; @@ -280,7 +309,6 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _robot = new java.awt.Robot() ; _robot.setAutoWaitForIdle( true ) ; - _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; _testMouseListener = new TestMouseListener() ; } @@ -291,30 +319,14 @@ public abstract class BaseNewtEventModifiers extends UITestCase { public void baseBeforeTest() throws Exception { _testMouseListener.setModifierCheckEnabled( false ) ; - _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; + _robot.setAutoDelay( MS_ROBOT_AUTO_DELAY ) ; // Make sure all the buttons and modifier keys are released. _releaseModifiers() ; _escape() ; - // Move the pointer into the window and click once to - // ensure that the test window has focus. - - if( _debug ) { - _debugPrintStream.println( ">>>> Clicking in the window to get focus." ) ; - } - - _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; - _robot.mousePress( java.awt.event.InputEvent.BUTTON1_MASK ); // java7: java.awt.event.InputEvent.BUTTON1_DOWN_MASK - _robot.mouseRelease( java.awt.event.InputEvent.BUTTON1_MASK ) ; // java7: java.awt.event.InputEvent.BUTTON1_DOWN_MASK - _testMouseListener.setModifierCheckEnabled( true ) ; - _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; - - if( _debug ) { - _debugPrintStream.println( ">>>> About to start testing." ) ; - } } //////////////////////////////////////////////////////////////////////////// @@ -352,30 +364,31 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_CONTROL, java.awt.event.InputEvent.CTRL_DOWN_MASK ) ; } - // The META and ALT tests get too tied up with functions of the window system on X11, - // so it's probably best to leave them commented out. - - //@Test - public void testSingleButtonPressAndReleaseWithMeta() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; - } - - //@Test - public void testSingleButtonPressAndReleaseWithAlt() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; - } - - // FIXME - not sure yet what's up with ALT_GRAPH. It appears that this - // modifier didn't make it through, so I had to disable this test else - // it would always fail. - // - // My US keyboard doesn't have an AltGr key, so maybe X is smart - // enough to not let this modifier slip through (?). + /** + * The META and ALT tests get too tied up with functions of the window system on X11, + * so it's probably best to leave them commented out. + @Test + public void testSingleButtonPressAndReleaseWithMeta() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; + } + + @Test + public void testSingleButtonPressAndReleaseWithAlt() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; + } + */ - //@Test - public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; - } + /** + * FIXME - not sure yet what's up with ALT_GRAPH. It appears that this + * modifier didn't make it through, so I had to disable this test else it would always fail. + * + * My US keyboard doesn't have an AltGr key, so maybe X is smart + * enough to not let this modifier slip through (?). + @Test + public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; + } + */ //////////////////////////////////////////////////////////////////////////// @@ -406,15 +419,15 @@ public abstract class BaseNewtEventModifiers extends UITestCase { int awtButtonMask = _awtButtonMasks[n] ; - if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** pressing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mousePress( awtButtonMask ) ; - _checkFailures() ; + _checkFailures("mouse-press("+(n+1)+")", 1) ; - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** releasing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mouseRelease( awtButtonMask ) ; - _checkFailures() ; + _checkFailures("mouse-release("+(n+1)+")", 1) ; } _doKeyRelease( keyCode ) ; @@ -432,31 +445,31 @@ public abstract class BaseNewtEventModifiers extends UITestCase { int awtButtonMask = _awtButtonMasks[n] ; - if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** pressing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mousePress( awtButtonMask ) ; - _checkFailures() ; - + _checkFailures("mouse-press("+(n+1)+")", 1) ; + for (int m = 0 ; m < _numButtonsToTest ; ++m) { if( n != m ) { - if( _debug ) { _debugPrintStream.println( "\n pressing additional button " + ( m + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** pressing additional button " + ( m + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask | _awtButtonMasks[m] ) ) ; _robot.mousePress( _awtButtonMasks[m] ) ; - _checkFailures() ; + _checkFailures("mouse-press("+(n+1)+", "+(m+1)+")", 1) ; - if( _debug ) { _debugPrintStream.println( "\n releasing additional button " + ( m + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** releasing additional button " + ( m + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask | _awtButtonMasks[m] ) ) ; _robot.mouseRelease( _awtButtonMasks[m] ) ; - _checkFailures() ; + _checkFailures("mouse-release("+(n+1)+", "+(m+1)+")", 1) ; } } - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** releasing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mouseRelease( awtButtonMask ) ; - _checkFailures() ; + _checkFailures("mouse-release("+(n+1)+")", 1); } _doKeyRelease( keyCode ) ; @@ -477,18 +490,18 @@ public abstract class BaseNewtEventModifiers extends UITestCase { cumulativeAwtModifiers |= _awtButtonMasks[n] ; - if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** pressing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; _robot.mousePress( _awtButtonMasks[n] ) ; - _checkFailures() ; + _checkFailures("mouse-press("+(n+1)+")", 1) ; } for (int n = _numButtonsToTest - 1 ; n >= 0 ; --n) { - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** releasing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; _robot.mouseRelease( _awtButtonMasks[n] ) ; - _checkFailures() ; + _checkFailures("mouse-release("+(n+1)+")", 1) ; cumulativeAwtModifiers &= ~_awtButtonMasks[n] ; } @@ -511,23 +524,26 @@ public abstract class BaseNewtEventModifiers extends UITestCase { int awtButtonMask = _awtButtonMasks[n] ; - if( _debug ) { _debugPrintStream.println( "\n pressing button " + ( n + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** pressing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mousePress( awtButtonMask ) ; - _checkFailures() ; + _checkFailures("mouse-press("+(n+1)+")", 1) ; // To get a drag we only need to move one pixel. - if( _debug ) { _debugPrintStream.println( "\n moving mouse" ) ; } - _robot.mouseMove( INITIAL_MOUSE_X + 1, INITIAL_MOUSE_Y + 1 ) ; - _checkFailures() ; + if( _debug ) { _debugPrintStream.println( "*** moving mouse" ) ; } + final int newX = INITIAL_MOUSE_X + 8, newY = INITIAL_MOUSE_Y + 8; + _robot.mouseMove( newX, newY ) ; + _robot.delay(MS_ROBOT_MOUSE_MOVE_DELAY); + _checkFailures("mouse-move("+newX+", "+newY+")", 1) ; - if( _debug ) { _debugPrintStream.println( "\n releasing button " + ( n + 1 ) ) ; } + if( _debug ) { _debugPrintStream.println( "*** releasing button " + ( n + 1 ) ) ; } _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mouseRelease( awtButtonMask ) ; - _checkFailures() ; + _checkFailures("mouse-release("+(n+1)+")", 1) ; _testMouseListener.setModifierCheckEnabled( false ) ; _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; + _robot.delay(MS_ROBOT_MOUSE_MOVE_DELAY); _testMouseListener.setModifierCheckEnabled( true ) ; } @@ -541,6 +557,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; _testMouseListener.setModifierCheckEnabled( false ) ; _robot.keyPress( keyCode ) ; + _robot.delay(MS_ROBOT_KEY_PRESS_DELAY); _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; } } @@ -552,26 +569,25 @@ public abstract class BaseNewtEventModifiers extends UITestCase { boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; _testMouseListener.setModifierCheckEnabled( false ) ; _robot.keyRelease( keyCode ) ; + _robot.delay(MS_ROBOT_KEY_RELEASE_DELAY); _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; } } //////////////////////////////////////////////////////////////////////////// - private void _checkFailures() { + private void _checkFailures(String descr, int waitEventCount) { + ArrayList failures = _testMouseListener.getFailures(waitEventCount) ; - ArrayList failures = _testMouseListener.getFailures() ; - - if( _debug ) { - int numFailures = failures.size() ; - if( numFailures == 0 ) { - _debugPrintStream.println( " PASSED" ) ; - } else { - _debugPrintStream.println( " FAILED" ) ; - for( int n = 0 ; n < numFailures ; ++n ) { - _debugPrintStream.print( " " ) ; - _debugPrintStream.println( failures.get(n) ) ; - } + _debugPrintStream.print(getSimpleTestName(".")+" - "+descr+": "); + int numFailures = failures.size() ; + if( numFailures == 0 ) { + _debugPrintStream.println( " PASSED" ) ; + } else { + _debugPrintStream.println( " FAILED" ) ; + for( int n = 0 ; n < numFailures ; ++n ) { + _debugPrintStream.print( " " ) ; + _debugPrintStream.println( failures.get(n) ) ; } } @@ -586,11 +602,12 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _testMouseListener.setModifierCheckEnabled( false ) ; Thread.sleep( 500 ) ; + + _robot.setAutoDelay( MS_ROBOT_POST_TEST_DELAY ) ; } //////////////////////////////////////////////////////////////////////////// - @AfterClass public static void baseAfterClass() throws Exception { // Make sure all modifiers are released, otherwise the user's @@ -606,7 +623,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { if (_robot != null) { - _robot.setAutoDelay( MS_ROBOT_SHORT_AUTO_DELAY ) ; + _robot.setAutoDelay( MS_ROBOT_AUTO_DELAY ) ; boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; _testMouseListener.setModifierCheckEnabled( false ) ; @@ -614,9 +631,9 @@ public abstract class BaseNewtEventModifiers extends UITestCase { { _robot.keyRelease( java.awt.event.KeyEvent.VK_SHIFT ) ; _robot.keyRelease( java.awt.event.KeyEvent.VK_CONTROL ) ; - _robot.keyRelease( java.awt.event.KeyEvent.VK_META ) ; - _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT ) ; - _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH ) ; + // _robot.keyRelease( java.awt.event.KeyEvent.VK_META ) ; + // _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT ) ; + // _robot.keyRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH ) ; for (int n = 0 ; n < _awtButtonMasks.length ; ++n) { _robot.mouseRelease( _awtButtonMasks[n] ) ; @@ -624,8 +641,6 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } _testMouseListener.setModifierCheckEnabled( modifierCheckEnabled ) ; - - _robot.setAutoDelay( MS_ROBOT_LONG_AUTO_DELAY ) ; } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java index 725dbe97f..17f81c583 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersAWTCanvas.java @@ -35,10 +35,12 @@ import javax.swing.SwingUtilities ; import javax.swing.WindowConstants ; import org.junit.AfterClass ; +import org.junit.Assert; import org.junit.BeforeClass ; import com.jogamp.newt.event.awt.AWTMouseAdapter ; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; /** * Test whether or not event modifiers are preserved by NEWT when @@ -68,13 +70,17 @@ public class TestNewtEventModifiersAWTCanvas extends BaseNewtEventModifiers { _testFrame.setVisible( true ) ; } }) ; + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(_testFrame, true)); + AWTRobotUtil.assertRequestFocusAndWait(null, canvas, canvas, null, null); // programmatic + Assert.assertNotNull(_robot); + AWTRobotUtil.requestFocus(_robot, canvas, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input } //////////////////////////////////////////////////////////////////////////// @AfterClass public static void afterClass() throws Exception { - + baseAfterClass(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { _testFrame.dispose() ; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java index d6088e6a2..5428958a0 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNEWTWindowAWT.java @@ -32,36 +32,44 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; import org.junit.AfterClass ; +import org.junit.Assert; import org.junit.BeforeClass ; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; /** * Test whether or not event modifiers are properly delivered by NEWT. */ public class TestNewtEventModifiersNEWTWindowAWT extends BaseNewtEventModifiers { - private static GLWindow glWindow; + private static GLWindow _glWindow; //////////////////////////////////////////////////////////////////////////// @BeforeClass public static void beforeClass() throws Exception { - glWindow = GLWindow.create( new GLCapabilities( GLProfile.getGL2ES2() ) ); - glWindow.setTitle("Event Modifier Test GLWindow"); - glWindow.addGLEventListener( new RedSquareES2() ) ; - glWindow.addMouseListener(_testMouseListener); - glWindow.setSize(TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT); - glWindow.setPosition(TEST_FRAME_X, TEST_FRAME_Y); - glWindow.setVisible(true); + _glWindow = GLWindow.create( new GLCapabilities( GLProfile.getGL2ES2() ) ); + _glWindow.setTitle("Event Modifier Test GLWindow"); + _glWindow.addGLEventListener( new RedSquareES2() ) ; + _glWindow.addMouseListener(_testMouseListener); + _glWindow.setSize(TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT); + _glWindow.setPosition(TEST_FRAME_X, TEST_FRAME_Y); + _glWindow.setVisible(true); + + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(_glWindow, true)); + AWTRobotUtil.assertRequestFocusAndWait(null, _glWindow, _glWindow, null, null); // programmatic + Assert.assertNotNull(_robot); + AWTRobotUtil.requestFocus(_robot, _glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input } //////////////////////////////////////////////////////////////////////////// @AfterClass public static void afterClass() throws Exception { - glWindow.destroy(); + baseAfterClass(); + _glWindow.destroy(); } //////////////////////////////////////////////////////////////////////////// diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java index 5590300c7..6a3f4a54b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasAWT.java @@ -38,11 +38,13 @@ import javax.swing.SwingUtilities ; import javax.swing.WindowConstants ; import org.junit.AfterClass ; +import org.junit.Assert; import org.junit.BeforeClass ; import com.jogamp.newt.awt.NewtCanvasAWT ; import com.jogamp.newt.opengl.GLWindow ; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; /** * Test whether or not event modifiers are preserved by NEWT when @@ -76,10 +78,14 @@ public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers } _testFrame.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; - _testFrame.setVisible( true ) ; + _testFrame.setVisible( true ) ; } } ) ; - + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(_testFrame, true)); + AWTRobotUtil.assertRequestFocusAndWait(null, _glWindow, _glWindow, null, null); // programmatic + Assert.assertNotNull(_robot); + AWTRobotUtil.requestFocus(_robot, _glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input + _glWindow.addMouseListener( _testMouseListener ) ; } @@ -87,7 +93,7 @@ public class TestNewtEventModifiersNewtCanvasAWT extends BaseNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - + baseAfterClass(); SwingUtilities.invokeAndWait( new Runnable() { public void run() { _testFrame.dispose() ; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java index c0d1690de..ec01ed9d3 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java @@ -37,11 +37,13 @@ import javax.media.opengl.GLCapabilities ; import javax.media.opengl.GLProfile ; import org.junit.AfterClass ; +import org.junit.Assert; import org.junit.BeforeClass ; import com.jogamp.newt.opengl.GLWindow ; import com.jogamp.newt.swt.NewtCanvasSWT ; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; /** * Test whether or not event modifiers preserved by NEWT when @@ -117,6 +119,9 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers _testShell.open() ; } } ) ; + AWTRobotUtil.assertRequestFocusAndWait(null, _glWindow, _glWindow, null, null); // programmatic + Assert.assertNotNull(_robot); + AWTRobotUtil.requestFocus(_robot, _glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input _glWindow.addMouseListener( _testMouseListener ) ; } @@ -125,7 +130,8 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers @AfterClass public static void afterClass() throws Exception { - + baseAfterClass(); + _glWindow.destroy() ; _displayThread.getDisplay().syncExec( new Runnable() { -- cgit v1.2.3 From b478cf3ead567fcc79fd8b75cade17efe0af3127 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Dec 2012 20:17:52 +0100 Subject: WT-NEWT Modifier mapping and test: part-4 (Fix unit tests): BaseNewtEventModifiers ignore more events (clicked, wheel, entered, exited); Fix TestNewtEventModifiersNewtCanvasSWT SWT-Display thread. --- make/build-test.xml | 1 + make/scripts/tests.sh | 4 +- .../junit/newt/event/BaseNewtEventModifiers.java | 58 +++++---- .../event/TestNewtEventModifiersNewtCanvasSWT.java | 134 +++++++++++++-------- 4 files changed, 120 insertions(+), 77 deletions(-) (limited to 'make/scripts') diff --git a/make/build-test.xml b/make/build-test.xml index 3402b4d9d..c4862cc0a 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -587,6 +587,7 @@ + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d96acf2e5..b91e155a0 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -403,9 +403,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index b4ece6c46..85a5f24cb 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -174,14 +174,6 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } } - public synchronized void mouseClicked( com.jogamp.newt.event.MouseEvent event ) { - _eventCount++; - if( _debug ) { - _debugPrintStream.println( "MouseClicked "+_eventCount+": "+event); - } - _checkModifiers( event ) ; - } - public synchronized void mousePressed( com.jogamp.newt.event.MouseEvent event ) { _eventCount++; if( _debug ) { @@ -198,46 +190,60 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _checkModifiers( event ) ; } - public synchronized void mouseEntered( com.jogamp.newt.event.MouseEvent event ) { + public synchronized void mouseDragged( com.jogamp.newt.event.MouseEvent event ) { _eventCount++; if( _debug ) { - _debugPrintStream.println( "MouseEntered "+_eventCount+": "+event); + _debugPrintStream.println( "MouseDragged "+_eventCount+": "+event); } _checkModifiers( event ) ; } + + // + // IGNORED + // - public synchronized void mouseExited( com.jogamp.newt.event.MouseEvent event ) { - _eventCount++; + public synchronized void mouseMoved( com.jogamp.newt.event.MouseEvent event ) { + // Ignored, since mouse MOVE doesn't hold mouse button, we look for DRAGGED! + // _eventCount++; if( _debug ) { - _debugPrintStream.println( "MouseExited "+_eventCount+": "+event); + _debugPrintStream.println( "MouseMoved ignored: "+event); } - _checkModifiers( event ) ; + // _checkModifiers( event ) ; } - - public synchronized void mouseDragged( com.jogamp.newt.event.MouseEvent event ) { - _eventCount++; + + public synchronized void mouseClicked( com.jogamp.newt.event.MouseEvent event ) { + // Ignored, since we look for PRESS/RELEASE only! + // _eventCount++; if( _debug ) { - _debugPrintStream.println( "MouseDragged "+_eventCount+": "+event); + _debugPrintStream.println( "MouseClicked ignored: "+event); } - _checkModifiers( event ) ; + // _checkModifiers( event ) ; } - public synchronized void mouseMoved( com.jogamp.newt.event.MouseEvent event ) { - // Ignored, since mouse MOVE doesn't hold mouse button, we look for DRAGGED! + public synchronized void mouseWheelMoved( com.jogamp.newt.event.MouseEvent event ) { // _eventCount++; if( _debug ) { - _debugPrintStream.println( "MouseMoved ignored: "+event); + _debugPrintStream.println( "MouseWheeleMoved ignored: "+event); } // _checkModifiers( event ) ; } - public synchronized void mouseWheelMoved( com.jogamp.newt.event.MouseEvent event ) { - _eventCount++; + public synchronized void mouseEntered( com.jogamp.newt.event.MouseEvent event ) { + // _eventCount++; if( _debug ) { - _debugPrintStream.println( "MouseWheeleMoved "+_eventCount+": "+event); + _debugPrintStream.println( "MouseEntered ignored: "+event); } - _checkModifiers( event ) ; + // _checkModifiers( event ) ; } + + public synchronized void mouseExited( com.jogamp.newt.event.MouseEvent event ) { + // _eventCount++; + if( _debug ) { + _debugPrintStream.println( "MouseExited ignored: "+event); + } + // _checkModifiers( event ) ; + } + } //////////////////////////////////////////////////////////////////////////// diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java index ec01ed9d3..83b7ded7a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.newt.event; import org.eclipse.swt.SWT ; import org.eclipse.swt.layout.FillLayout ; +import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display ; import org.eclipse.swt.widgets.Shell ; @@ -38,8 +39,10 @@ import javax.media.opengl.GLProfile ; import org.junit.AfterClass ; import org.junit.Assert; +import org.junit.Assume; import org.junit.BeforeClass ; +import com.jogamp.nativewindow.swt.SWTAccessor; import com.jogamp.newt.opengl.GLWindow ; import com.jogamp.newt.swt.NewtCanvasSWT ; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -52,7 +55,9 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers { - private static Shell _testShell ; + private static Display _display = null; + private static Shell _shell = null; + private static Composite _composite = null; private static GLWindow _glWindow ; private static DisplayThread _displayThread ; @@ -60,28 +65,48 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers private static class DisplayThread extends Thread { - private Display _display ; - + public volatile boolean shallStop = false; + public volatile boolean isInit = false; + public DisplayThread() { super( "SWT Display Thread" ) ; } - public Display getDisplay() { - return _display ; - } - public void run() { - - _display = new Display() ; - - while( isInterrupted() == false ) { + + synchronized(this) { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + _display = new Display(); + Assert.assertNotNull( _display ); + }}); + + isInit = true; + this.notifyAll(); + } + + while( !_display.isDisposed() && !shallStop && isInterrupted() == false ) { if( !_display.readAndDispatch() ) { - _display.sleep() ; + try { + Thread.sleep(10); + } catch (InterruptedException e) { } + } + } + + synchronized(this) { + try { + if(!_display.isDisposed()) { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + _display.dispose(); + }}); + } + } finally { + isInit = false; + this.notifyAll(); } } - - _display.dispose() ; } } @@ -91,34 +116,39 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers public static void beforeClass() throws Exception { _displayThread = new DisplayThread() ; - _displayThread.start() ; - - // Wait for the display thread's runnable to get set. - - while( _displayThread.getDisplay() == null ) { - try { Thread.sleep( 10 ) ; } catch( InterruptedException e ) {} + synchronized(_displayThread) { + _displayThread.start() ; + while(!_displayThread.isInit) { + _displayThread.wait(); + } } + + _display.syncExec(new Runnable() { + public void run() { + _shell = new Shell( _display ); + Assert.assertNotNull( _shell ); + _shell.setText( "Event Modifier Test NewtCanvasSWT" ) ; + _shell.setLayout( new FillLayout() ); + _composite = new Composite( _shell, SWT.NONE ); + _composite.setLayout( new FillLayout() ); + Assert.assertNotNull( _composite ); + }}); - _displayThread.getDisplay().syncExec( new Runnable() { - public void run() { - - _testShell = new Shell( _displayThread.getDisplay() ) ; - _testShell.setText( "Event Modifier Test NewtCanvasSWT" ) ; - _testShell.setLayout( new FillLayout() ) ; - - { - GLCapabilities caps = new GLCapabilities( GLProfile.get( GLProfile.GL2ES2 ) ) ; - _glWindow = GLWindow.create( caps ) ; - - NewtCanvasSWT.create( _testShell, SWT.NO_BACKGROUND, _glWindow ) ; - - _glWindow.addGLEventListener( new RedSquareES2() ) ; - } + { + GLCapabilities caps = new GLCapabilities( GLProfile.get( GLProfile.GL2ES2 ) ) ; + _glWindow = GLWindow.create( caps ) ; + _glWindow.addGLEventListener( new RedSquareES2() ) ; - _testShell.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; - _testShell.open() ; - } - } ) ; + NewtCanvasSWT.create( _composite, SWT.NO_BACKGROUND, _glWindow ) ; + } + + _display.syncExec( new Runnable() { + public void run() { + _shell.setBounds( TEST_FRAME_X, TEST_FRAME_Y, TEST_FRAME_WIDTH, TEST_FRAME_HEIGHT ) ; + _shell.open(); + } + }); + AWTRobotUtil.assertRequestFocusAndWait(null, _glWindow, _glWindow, null, null); // programmatic Assert.assertNotNull(_robot); AWTRobotUtil.requestFocus(_robot, _glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input @@ -134,17 +164,23 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers _glWindow.destroy() ; - _displayThread.getDisplay().syncExec( new Runnable() { - public void run() { - _testShell.dispose() ; - } - } ) ; - - _displayThread.interrupt() ; - try { - _displayThread.join() ; - } catch( InterruptedException e ) { + _display.syncExec(new Runnable() { + public void run() { + _composite.dispose(); + _shell.dispose(); + }}); + + synchronized(_displayThread) { + _displayThread.shallStop = true; + while( _displayThread.isInit && _displayThread.isAlive() ) { + _displayThread.wait(); + } + } + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); } } -- cgit v1.2.3 From b0be3d764fc6ff90457fcb96ea81d53ba04cd420 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Dec 2012 03:50:40 +0100 Subject: Misc OSX/SWT: OSXUtil.RunOnMainThread(..) refinement; Fix Test*NewtEventModifiers for SWT (TestNewtEventModifiersNewtCanvasSWT) - Misc OSX/SWT: OSXUtil.RunOnMainThread(..) refinement - 'waitUntilDone' is implemented on Java site via lock/wait on RunnableTask to not freeze OSX main thread. - Fix Test*NewtEventModifiers for SWT (TestNewtEventModifiersNewtCanvasSWT) - Deal with SWT's requirement to run the SWT event dispatch on the TK thread, which must be the main thread on OSX. We spawn off the actual test-action into another thread, while dispatching the events until the test-action is completed. - AWTRobot: Add 'void requestFocus(Robot robot, Object obj, int x, int y)' - Use waitForIdle() only if programmed in Robot (Deadlock w/ OSX SWT) - Required for SWT usage (see above) --- make/scripts/tests.sh | 2 +- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 2 +- .../jogamp/nativewindow/macosx/OSXUtil.java | 39 ++++++- src/nativewindow/native/macosx/OSXmisc.m | 21 +++- .../junit/newt/event/BaseNewtEventModifiers.java | 112 +++++++++++++++++---- .../event/TestNewtEventModifiersNewtCanvasSWT.java | 103 ++++++++----------- .../opengl/test/junit/util/AWTRobotUtil.java | 19 +++- 7 files changed, 206 insertions(+), 92 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b91e155a0..db061b4bc 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -405,7 +405,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* +testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index eba26c7d3..d3e339586 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -480,7 +480,7 @@ public class SWTAccessor { *

  • Mac OSX *
      * - *
    • Main Thread: Run on OSX UI main thread.
    • + *
    • Main Thread: Run on OSX UI main thread. 'wait' is implemented on Java site via lock/wait on {@link RunnableTask} to not freeze OSX main thread.
    • *
  • *
  • Linux, Windows, .. *
      diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index a195f137e..f06f97064 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -32,6 +32,8 @@ import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.RunnableTask; + import jogamp.nativewindow.Debug; import jogamp.nativewindow.NWJNILibLoader; import jogamp.nativewindow.ToolkitProperties; @@ -154,11 +156,42 @@ public class OSXUtil implements ToolkitProperties { DestroyCALayer0(caLayer); } + /** + * Run on OSX UI main thread. + *

      + * 'waitUntilDone' is implemented on Java site via lock/wait on {@link RunnableTask} to not freeze OSX main thread. + *

      + * + * @param waitUntilDone + * @param runnable + */ public static void RunOnMainThread(boolean waitUntilDone, Runnable runnable) { - if(IsMainThread0()) { + if( IsMainThread0() ) { runnable.run(); // don't leave the JVM } else { - RunOnMainThread0(waitUntilDone, runnable); + if( waitUntilDone ) { + // Utilize Java side lock/wait and simply pass the Runnable async to OSX main thread, + // otherwise we may freeze the OSX main thread. + Throwable throwable = null; + final Object sync = new Object(); + final RunnableTask rt = new RunnableTask( runnable, sync, true ); + synchronized(sync) { + RunOnMainThread0(rt); + try { + sync.wait(); + } catch (InterruptedException ie) { + throwable = ie; + } + if(null==throwable) { + throwable = rt.getThrowable(); + } + if(null!=throwable) { + throw new RuntimeException(throwable); + } + } + } else { + RunOnMainThread0(runnable); + } } } @@ -205,7 +238,7 @@ public class OSXUtil implements ToolkitProperties { private static native void AddCASublayer0(long rootCALayer, long subCALayer); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); - private static native void RunOnMainThread0(boolean waitUntilDone, Runnable runnable); + private static native void RunOnMainThread0(Runnable runnable); private static native boolean IsMainThread0(); private static native int GetScreenRefreshRate0(int scrn_idx); } diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 1cf41fc9d..72bb2338c 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -519,13 +519,18 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow { int shallBeDetached = 0; JNIEnv* env = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); + DBG_PRINT("MainRunnable.0 env: %d\n", (int)(NULL!=env)); if(NULL!=env) { + DBG_PRINT("MainRunnable.1.0\n"); (*env)->CallVoidMethod(env, runnableObj, runnableRunID); + DBG_PRINT("MainRunnable.1.1\n"); if (shallBeDetached) { + DBG_PRINT("MainRunnable.1.2\n"); (*jvmHandle)->DetachCurrentThread(jvmHandle); } } + DBG_PRINT("MainRunnable.X\n"); } @end @@ -537,14 +542,16 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow * Signature: (ZLjava/lang/Runnable;)V */ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RunOnMainThread0 - (JNIEnv *env, jclass unused, jboolean jwait, jobject runnable) + (JNIEnv *env, jclass unused, jobject runnable) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + DBG_PRINT( "RunOnMainThread0: isMainThread %d, NSApp %d, NSApp-isRunning %d\n", + (int)([NSThread isMainThread]), (int)(NULL!=NSApp), (int)([NSApp isRunning])); + if ( NO == [NSThread isMainThread] ) { jobject runnableGlob = (*env)->NewGlobalRef(env, runnable); - BOOL wait = (JNI_TRUE == jwait) ? YES : NO; JavaVM *jvmHandle = NULL; int jvmVersion = 0; @@ -554,14 +561,18 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RunOnMainThread0 jvmVersion = (*env)->GetVersion(env); } + DBG_PRINT( "RunOnMainThread0.1.0\n"); MainRunnable * mr = [[MainRunnable alloc] initWithRunnable: runnableGlob jvmHandle: jvmHandle jvmVersion: jvmVersion]; - [mr performSelectorOnMainThread:@selector(jRun) withObject:nil waitUntilDone:wait]; + [mr performSelectorOnMainThread:@selector(jRun) withObject:nil waitUntilDone:NO]; [mr release]; + DBG_PRINT( "RunOnMainThread0.1.1\n"); (*env)->DeleteGlobalRef(env, runnableGlob); } else { + DBG_PRINT( "RunOnMainThread0.2\n"); (*env)->CallVoidMethod(env, runnable, runnableRunID); } + DBG_PRINT( "RunOnMainThread0.X\n"); [pool release]; } @@ -620,7 +631,7 @@ JNIEXPORT jint JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenRefreshR DBG_PRINT("GetScreenRefreshRate.0: screen %p\n", (void *)screen); if(NULL != screen) { CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); - DBG_PRINT("GetScreenRefreshRate.1: display %p\n", (void *)display); + DBG_PRINT("GetScreenRefreshRate.1: display %p\n", (void *)(intptr_t)display); if(0 != display) { CFDictionaryRef mode = CGDisplayCurrentMode(display); DBG_PRINT("GetScreenRefreshRate.2: mode %p\n", (void *)mode); @@ -633,7 +644,7 @@ JNIEXPORT jint JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenRefreshR if(0 == res) { res = 60; // default .. (experienced on OSX 10.6.8) } - DBG_PRINT(stderr, "GetScreenRefreshRate.X: %d\n", res); + DBG_PRINT(stderr, "GetScreenRefreshRate.X: %d\n", (int)res); // [pool release]; JNF_COCOA_EXIT(env); return res; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 85a5f24cb..6cbbc675f 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -34,12 +34,12 @@ import java.util.ArrayList ; import javax.media.opengl.GLProfile ; import org.junit.After ; -import org.junit.AfterClass ; import org.junit.Assert ; import org.junit.Before ; import org.junit.BeforeClass ; import org.junit.Test ; +import com.jogamp.common.util.RunnableTask; import com.jogamp.newt.event.MouseEvent; import com.jogamp.opengl.test.junit.util.UITestCase ; @@ -59,18 +59,18 @@ public abstract class BaseNewtEventModifiers extends UITestCase { protected static final int TEST_FRAME_WIDTH = 400 ; protected static final int TEST_FRAME_HEIGHT = 400 ; - private static final int INITIAL_MOUSE_X = TEST_FRAME_X + ( TEST_FRAME_WIDTH / 2 ) ; - private static final int INITIAL_MOUSE_Y = TEST_FRAME_Y + ( TEST_FRAME_HEIGHT / 2 ) ; + protected static final int INITIAL_MOUSE_X = TEST_FRAME_X + ( TEST_FRAME_WIDTH / 2 ) ; + protected static final int INITIAL_MOUSE_Y = TEST_FRAME_Y + ( TEST_FRAME_HEIGHT / 2 ) ; - private static final int MS_ROBOT_KEY_PRESS_DELAY = 50 ; - private static final int MS_ROBOT_KEY_RELEASE_DELAY = 50 ; - private static final int MS_ROBOT_MOUSE_MOVE_DELAY = 100 ; + protected static final int MS_ROBOT_KEY_PRESS_DELAY = 50 ; + protected static final int MS_ROBOT_KEY_RELEASE_DELAY = 50 ; + protected static final int MS_ROBOT_MOUSE_MOVE_DELAY = 100 ; - private static final int MS_ROBOT_AUTO_DELAY = 50 ; - private static final int MS_ROBOT_POST_TEST_DELAY = 100; + protected static final int MS_ROBOT_AUTO_DELAY = 50 ; + protected static final int MS_ROBOT_POST_TEST_DELAY = 100; - private static final boolean _debug = true ; - private static PrintStream _debugPrintStream = System.err ; + protected static final boolean _debug = true ; + protected static PrintStream _debugPrintStream = System.err ; //////////////////////////////////////////////////////////////////////////// @@ -335,6 +335,35 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _testMouseListener.setModifierCheckEnabled( true ) ; } + //////////////////////////////////////////////////////////////////////////// + // Following both methods are mandatory to deal with SWT's requirement + // to run the SWT event dispatch on the TK thread - which must be the main thread on OSX. + // We spawn off the actual test-action into another thread, + // while dispatching the events until the test-action is completed. + // YES: This is sort of ideal - NOT :) + + protected void eventDispatch() { + try { + Thread.sleep(100); + } catch (InterruptedException e) { } + } + + private void execOffThreadWithOnThreadEventDispatch(Runnable testAction) { + Throwable throwable = null; + final Object sync = new Object(); + final RunnableTask rt = new RunnableTask( testAction, sync, true ); + new Thread(rt, "Test-Thread").start(); + while( !rt.isExecuted() && null == throwable ) { + eventDispatch(); + } + if(null==throwable) { + throwable = rt.getThrowable(); + } + if(null!=throwable) { + throw new RuntimeException(throwable); + } + } + //////////////////////////////////////////////////////////////////////////// // The approach on all these tests is to tell the test mouse listener what @@ -357,17 +386,32 @@ public abstract class BaseNewtEventModifiers extends UITestCase { @Test public void testSingleButtonPressAndRelease() throws Exception { - _doSingleButtonPressAndRelease( 0, 0 ) ; + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doSingleButtonPressAndRelease( 0, 0 ); + } catch (Exception e) { throw new RuntimeException(e); } + } } ); } @Test public void testSingleButtonPressAndReleaseWithShift() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_SHIFT, java.awt.event.InputEvent.SHIFT_DOWN_MASK ) ; + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_SHIFT, java.awt.event.InputEvent.SHIFT_DOWN_MASK ) ; + } catch (Exception e) { throw new RuntimeException(e); } + } } ); } @Test public void testSingleButtonPressAndReleaseWithCtrl() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_CONTROL, java.awt.event.InputEvent.CTRL_DOWN_MASK ) ; + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_CONTROL, java.awt.event.InputEvent.CTRL_DOWN_MASK ) ; + } catch (Exception e) { throw new RuntimeException(e); } + } } ); } /** @@ -375,12 +419,22 @@ public abstract class BaseNewtEventModifiers extends UITestCase { * so it's probably best to leave them commented out. @Test public void testSingleButtonPressAndReleaseWithMeta() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; + } catch (Exception e) { throw new RuntimeException(e); } + } } ); } @Test public void testSingleButtonPressAndReleaseWithAlt() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; + } catch (Exception e) { throw new RuntimeException(e); } + } } ); } */ @@ -392,7 +446,12 @@ public abstract class BaseNewtEventModifiers extends UITestCase { * enough to not let this modifier slip through (?). @Test public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { - _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; + } catch (Exception e) { throw new RuntimeException(e); } + } } ); } */ @@ -400,17 +459,32 @@ public abstract class BaseNewtEventModifiers extends UITestCase { @Test public void testHoldOneButtonAndPressAnother() throws Exception { - _doHoldOneButtonAndPressAnother( 0, 0 ) ; + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doHoldOneButtonAndPressAnother( 0, 0 ) ; + } catch (Exception e) { throw new RuntimeException(e); } + } } ); } @Test public void testPressAllButtonsInSequence() throws Exception { - _doPressAllButtonsInSequence( 0, 0 ) ; + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doPressAllButtonsInSequence( 0, 0 ) ; + } catch (Exception e) { throw new RuntimeException(e); } + } } ); } @Test public void testSingleButtonClickAndDrag() throws Exception { - _doSingleButtonClickAndDrag( 0, 0 ) ; + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doSingleButtonClickAndDrag( 0, 0 ) ; + } catch (Exception e) { throw new RuntimeException(e); } + } } ); } //////////////////////////////////////////////////////////////////////////// diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java index 83b7ded7a..cafc3dd46 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java @@ -59,69 +59,42 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers private static Shell _shell = null; private static Composite _composite = null; private static GLWindow _glWindow ; - private static DisplayThread _displayThread ; //////////////////////////////////////////////////////////////////////////// - - private static class DisplayThread extends Thread - { - public volatile boolean shallStop = false; - public volatile boolean isInit = false; - - public DisplayThread() - { - super( "SWT Display Thread" ) ; - } - - public void run() { - - synchronized(this) { - SWTAccessor.invoke(true, new Runnable() { - public void run() { - _display = new Display(); - Assert.assertNotNull( _display ); - }}); - - isInit = true; - this.notifyAll(); - } - - while( !_display.isDisposed() && !shallStop && isInterrupted() == false ) { - if( !_display.readAndDispatch() ) { - try { - Thread.sleep(10); - } catch (InterruptedException e) { } - } - } - - synchronized(this) { + + protected static void eventDispatch2xImpl() { + eventDispatchImpl(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { } + eventDispatchImpl(); + } + + protected static void eventDispatchImpl() { + if( !_display.isDisposed() ) { + if( !_display.readAndDispatch() ) { try { - if(!_display.isDisposed()) { - SWTAccessor.invoke(true, new Runnable() { - public void run() { - _display.dispose(); - }}); - } - } finally { - isInit = false; - this.notifyAll(); - } + Thread.sleep(10); + } catch (InterruptedException e) { } } - } + } } - + + @Override + protected void eventDispatch() { + eventDispatchImpl(); + } + //////////////////////////////////////////////////////////////////////////// @BeforeClass public static void beforeClass() throws Exception { - _displayThread = new DisplayThread() ; - synchronized(_displayThread) { - _displayThread.start() ; - while(!_displayThread.isInit) { - _displayThread.wait(); - } - } + SWTAccessor.invoke(true, new Runnable() { + public void run() { + _display = new Display(); + }}); + Assert.assertNotNull( _display ); _display.syncExec(new Runnable() { public void run() { @@ -149,10 +122,16 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers } }); - AWTRobotUtil.assertRequestFocusAndWait(null, _glWindow, _glWindow, null, null); // programmatic + // no AWT idling, may deadlock on OSX! Assert.assertNotNull(_robot); - AWTRobotUtil.requestFocus(_robot, _glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input - + _robot.setAutoWaitForIdle( false ) ; + + // no waiting for results .. + AWTRobotUtil.requestFocus(null, _glWindow, false); // programmatic + eventDispatch2xImpl(); + AWTRobotUtil.requestFocus(_robot, _glWindow, INITIAL_MOUSE_X, INITIAL_MOUSE_Y); + eventDispatch2xImpl(); + _glWindow.addMouseListener( _testMouseListener ) ; } @@ -171,12 +150,12 @@ public class TestNewtEventModifiersNewtCanvasSWT extends BaseNewtEventModifiers _shell.dispose(); }}); - synchronized(_displayThread) { - _displayThread.shallStop = true; - while( _displayThread.isInit && _displayThread.isAlive() ) { - _displayThread.wait(); - } - } + if(!_display.isDisposed()) { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + _display.dispose(); + }}); + } } catch( Throwable throwable ) { throwable.printStackTrace(); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index b5c96d10f..45648bedf 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -287,7 +287,24 @@ public class AWTRobotUtil { System.err.println("requestFocus: click, d: "+d+" ms"); } } - + + public static void requestFocus(Robot robot, Object obj, int x, int y) + throws AWTException, InterruptedException, InvocationTargetException { + + final boolean idling = robot.isAutoWaitForIdle(); + final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK; + robot.mouseMove( x, y ); + if( idling ) { + robot.waitForIdle(); + } else { + try { Thread.sleep(50); } catch (InterruptedException e) { } + } + robot.mousePress(mouseButton); + robot.mouseRelease(mouseButton); + final int d = getClickTimeout(obj) + 1; + robot.delay( d ); + } + public static boolean hasFocus(Object obj) { if(obj instanceof Component) { final Component comp = (Component) obj; -- cgit v1.2.3 From 3cb2d5c1714b7b371ebd979304bb1e09a193f228 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Dec 2012 05:18:14 +0100 Subject: Test*NewtEventModifiers*: Clear 'clearing' events on thread - @Before/@After -> execOffThreadWithOnThreadEventDispatch Remaining 'clearing' events from _releaseModifiers() and escape() broke test case. --- make/scripts/tests-x64.bat | 4 +- .../junit/newt/event/BaseNewtEventModifiers.java | 74 ++++++++++------------ 2 files changed, 34 insertions(+), 44 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 09a45f816..2429ede0b 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -46,9 +46,9 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtK REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 6cbbc675f..31fa11e9d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -33,9 +33,7 @@ import java.util.ArrayList ; import javax.media.opengl.GLProfile ; -import org.junit.After ; import org.junit.Assert ; -import org.junit.Before ; import org.junit.BeforeClass ; import org.junit.Test ; @@ -64,7 +62,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { protected static final int MS_ROBOT_KEY_PRESS_DELAY = 50 ; protected static final int MS_ROBOT_KEY_RELEASE_DELAY = 50 ; - protected static final int MS_ROBOT_MOUSE_MOVE_DELAY = 100 ; + protected static final int MS_ROBOT_MOUSE_MOVE_DELAY = 200 ; protected static final int MS_ROBOT_AUTO_DELAY = 50 ; protected static final int MS_ROBOT_POST_TEST_DELAY = 100; @@ -319,22 +317,6 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _testMouseListener = new TestMouseListener() ; } - //////////////////////////////////////////////////////////////////////////// - - @Before - public void baseBeforeTest() throws Exception { - - _testMouseListener.setModifierCheckEnabled( false ) ; - _robot.setAutoDelay( MS_ROBOT_AUTO_DELAY ) ; - - // Make sure all the buttons and modifier keys are released. - - _releaseModifiers() ; - _escape() ; - - _testMouseListener.setModifierCheckEnabled( true ) ; - } - //////////////////////////////////////////////////////////////////////////// // Following both methods are mandatory to deal with SWT's requirement // to run the SWT event dispatch on the TK thread - which must be the main thread on OSX. @@ -348,19 +330,38 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } catch (InterruptedException e) { } } - private void execOffThreadWithOnThreadEventDispatch(Runnable testAction) { + private void execOffThreadWithOnThreadEventDispatch(Runnable testAction) throws Exception { + _testMouseListener.setModifierCheckEnabled( false ) ; + _robot.setAutoDelay( MS_ROBOT_AUTO_DELAY ) ; + { + // Make sure all the buttons and modifier keys are released. + _releaseModifiers() ; + _escape() ; + eventDispatch(); eventDispatch(); eventDispatch(); + Thread.sleep( MS_ROBOT_POST_TEST_DELAY ) ; + eventDispatch(); eventDispatch(); eventDispatch(); + } + _testMouseListener.setModifierCheckEnabled( true ) ; + Throwable throwable = null; final Object sync = new Object(); - final RunnableTask rt = new RunnableTask( testAction, sync, true ); - new Thread(rt, "Test-Thread").start(); - while( !rt.isExecuted() && null == throwable ) { - eventDispatch(); - } - if(null==throwable) { - throwable = rt.getThrowable(); - } - if(null!=throwable) { - throw new RuntimeException(throwable); + final RunnableTask rt = new RunnableTask( testAction, sync, true ); + try { + new Thread(rt, "Test-Thread").start(); + while( !rt.isExecuted() && null == throwable ) { + eventDispatch(); + } + if(null==throwable) { + throwable = rt.getThrowable(); + } + if(null!=throwable) { + throw new RuntimeException(throwable); + } + } finally { + _testMouseListener.setModifierCheckEnabled( false ) ; + eventDispatch(); eventDispatch(); eventDispatch(); + Thread.sleep( MS_ROBOT_POST_TEST_DELAY ) ; + eventDispatch(); eventDispatch(); eventDispatch(); } } @@ -676,18 +677,6 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// - @After - public void baseAfterTest() throws Exception { - - _testMouseListener.setModifierCheckEnabled( false ) ; - - Thread.sleep( 500 ) ; - - _robot.setAutoDelay( MS_ROBOT_POST_TEST_DELAY ) ; - } - - //////////////////////////////////////////////////////////////////////////// - public static void baseAfterClass() throws Exception { // Make sure all modifiers are released, otherwise the user's @@ -695,6 +684,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _releaseModifiers() ; _escape() ; + Thread.sleep( MS_ROBOT_POST_TEST_DELAY ) ; } //////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 57c4e440ffa53ba7f868a145212df78e2eb2f8f2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 27 Dec 2012 06:01:56 +0100 Subject: Android build scripts: Fix env. name ANDROID_SDK_HOME -> ANDROID_HOME Intuitively I assumed ANDROID_SDK_HOME to be pointing to the SDK root dir, however this is not true: Semantics by Android tools are: ANDROID_SDK_HOME - Users ~/.android folder ANDROID_HOME - SDK root folder --- make/scripts/make.jogl.all.android-armv6-cross.sh | 20 ++++++++++---------- make/scripts/make.jogl.all.android-armv7-cross.sh | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.android-armv6-cross.sh b/make/scripts/make.jogl.all.android-armv6-cross.sh index 262560090..e75a73d45 100755 --- a/make/scripts/make.jogl.all.android-armv6-cross.sh +++ b/make/scripts/make.jogl.all.android-armv6-cross.sh @@ -16,7 +16,7 @@ export TARGET_ADB_PORT=5555 export TARGET_ROOT=/data/projects export TARGET_ANT_HOME=/usr/share/ant -echo ANDROID_SDK_HOME $ANDROID_SDK_HOME +echo ANDROID_HOME $ANDROID_HOME echo NDK_ROOT $NDK_ROOT if [ -z "$NDK_ROOT" ] ; then @@ -48,22 +48,22 @@ elif [ ! -e $NDK_ROOT ] ; then fi export NDK_ROOT -if [ -z "$ANDROID_SDK_HOME" ] ; then +if [ -z "$ANDROID_HOME" ] ; then if [ -e /usr/local/android-sdk-linux_x86 ] ; then - ANDROID_SDK_HOME=/usr/local/android-sdk-linux_x86 + ANDROID_HOME=/usr/local/android-sdk-linux_x86 elif [ -e /opt-linux-x86/android-sdk-linux_x86 ] ; then - ANDROID_SDK_HOME=/opt-linux-x86/android-sdk-linux_x86 + ANDROID_HOME=/opt-linux-x86/android-sdk-linux_x86 elif [ -e /opt/android-sdk-linux_x86 ] ; then - ANDROID_SDK_HOME=/opt/android-sdk-linux_x86 + ANDROID_HOME=/opt/android-sdk-linux_x86 else - echo ANDROID_SDK_HOME is not specified and does not exist in default locations + echo ANDROID_HOME is not specified and does not exist in default locations exit 1 fi -elif [ ! -e $ANDROID_SDK_HOME ] ; then - echo ANDROID_SDK_HOME $ANDROID_SDK_HOME does not exist +elif [ ! -e $ANDROID_HOME ] ; then + echo ANDROID_HOME $ANDROID_HOME does not exist exit 1 fi -export ANDROID_SDK_HOME +export ANDROID_HOME export ANDROID_VERSION=9 export SOURCE_LEVEL=1.6 @@ -78,7 +78,7 @@ export NDK_TOOLCHAIN_ROOT=$NDK_ROOT/toolchains/${TARGET_TRIPLE}-${GCC_VERSION}/p export TARGET_PLATFORM_ROOT=${NDK_ROOT}/platforms/android-${ANDROID_VERSION}/arch-arm # Need to add toolchain bins to the PATH. -export PATH="$NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin:$ANDROID_SDK_HOME/platform-tools:$PATH" +export PATH="$NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin:$ANDROID_HOME/platform-tools:$PATH" export GLUEGEN_CPPTASKS_FILE=`pwd`/../../gluegen/make/lib/gluegen-cpptasks-android-armv6.xml diff --git a/make/scripts/make.jogl.all.android-armv7-cross.sh b/make/scripts/make.jogl.all.android-armv7-cross.sh index 4c4ea4c6b..f38e05dea 100755 --- a/make/scripts/make.jogl.all.android-armv7-cross.sh +++ b/make/scripts/make.jogl.all.android-armv7-cross.sh @@ -16,7 +16,7 @@ export TARGET_ADB_PORT=5555 export TARGET_ROOT=/data/projects export TARGET_ANT_HOME=/usr/share/ant -echo ANDROID_SDK_HOME $ANDROID_SDK_HOME +echo ANDROID_HOME $ANDROID_HOME echo NDK_ROOT $NDK_ROOT if [ -z "$NDK_ROOT" ] ; then @@ -48,22 +48,22 @@ elif [ ! -e $NDK_ROOT ] ; then fi export NDK_ROOT -if [ -z "$ANDROID_SDK_HOME" ] ; then +if [ -z "$ANDROID_HOME" ] ; then if [ -e /usr/local/android-sdk-linux_x86 ] ; then - ANDROID_SDK_HOME=/usr/local/android-sdk-linux_x86 + ANDROID_HOME=/usr/local/android-sdk-linux_x86 elif [ -e /opt-linux-x86/android-sdk-linux_x86 ] ; then - ANDROID_SDK_HOME=/opt-linux-x86/android-sdk-linux_x86 + ANDROID_HOME=/opt-linux-x86/android-sdk-linux_x86 elif [ -e /opt/android-sdk-linux_x86 ] ; then - ANDROID_SDK_HOME=/opt/android-sdk-linux_x86 + ANDROID_HOME=/opt/android-sdk-linux_x86 else - echo ANDROID_SDK_HOME is not specified and does not exist in default locations + echo ANDROID_HOME is not specified and does not exist in default locations exit 1 fi -elif [ ! -e $ANDROID_SDK_HOME ] ; then - echo ANDROID_SDK_HOME $ANDROID_SDK_HOME does not exist +elif [ ! -e $ANDROID_HOME ] ; then + echo ANDROID_HOME $ANDROID_HOME does not exist exit 1 fi -export ANDROID_SDK_HOME +export ANDROID_HOME export ANDROID_VERSION=9 export SOURCE_LEVEL=1.6 @@ -78,7 +78,7 @@ export NDK_TOOLCHAIN_ROOT=$NDK_ROOT/toolchains/${TARGET_TRIPLE}-${GCC_VERSION}/p export TARGET_PLATFORM_ROOT=${NDK_ROOT}/platforms/android-${ANDROID_VERSION}/arch-arm # Need to add toolchain bins to the PATH. -export PATH="$NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin:$ANDROID_SDK_HOME/platform-tools:$PATH" +export PATH="$NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin:$ANDROID_HOME/platform-tools:$PATH" export GLUEGEN_CPPTASKS_FILE=`pwd`/../../gluegen/make/lib/gluegen-cpptasks-android-armv7.xml -- cgit v1.2.3 From f514582845efaf2bf41cbcbeb1e2378d224b11a3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 27 Dec 2012 07:24:06 +0100 Subject: adb-launch-main.sh: ANDROID_SDK_HOME -> ANDROID_HOME --- make/scripts/adb-launch-main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/adb-launch-main.sh b/make/scripts/adb-launch-main.sh index 6d6719209..e40cfeb11 100644 --- a/make/scripts/adb-launch-main.sh +++ b/make/scripts/adb-launch-main.sh @@ -15,8 +15,8 @@ export TARGET_ROOT=/data/projects export BUILD_DIR=../build-android-armv6 if [ -e /opt-linux-x86/android-sdk-linux_x86 ] ; then - export ANDROID_SDK_HOME=/opt-linux-x86/android-sdk-linux_x86 - export PATH=$ANDROID_SDK_HOME/platform-tools:$PATH + export ANDROID_HOME=/opt-linux-x86/android-sdk-linux_x86 + export PATH=$ANDROID_HOME/platform-tools:$PATH fi #TSTCLASS=jogamp.android.launcher.LauncherUtil -- cgit v1.2.3 From 74d8e51e1cbb436eab6b90f78de90dacd10e60a5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 29 Dec 2012 11:58:20 +0100 Subject: Adapt change of commit d93c5d23e304ea20e868595748f92a5bef4f5703 to unit test (GLCanvas realization point) --- make/scripts/tests.sh | 4 +- .../opengl/test/junit/jogl/awt/TestBug572AWT.java | 102 +++++++++++++++------ 2 files changed, 78 insertions(+), 28 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index db061b4bc..d4ce3c3e1 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -347,7 +347,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn @@ -405,7 +405,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* -testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java index b3abc4137..80f0e93b6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java @@ -50,8 +50,28 @@ import com.jogamp.opengl.test.junit.util.UITestCase; * Tests context creation + display on various kinds of Window implementations. */ public class TestBug572AWT extends UITestCase { + static class Cleanup implements Runnable { + Window window; + + public Cleanup(Window w) { + window = w; + } + + public void run() { + System.err.println("cleaning up..."); + window.setVisible(false); + try { + window.removeAll(); + } catch (Throwable t) { + Assume.assumeNoException(t); + t.printStackTrace(); + } + window.dispose(); + } + } - protected void runTestGL() throws InterruptedException, InvocationTargetException { + @Test + public void test01RealizeGLCanvasOnAWTEDT() throws InterruptedException, InvocationTargetException { final Window window = new JFrame(this.getSimpleTestName(" - ")); final GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); final GLCanvas glCanvas = new GLCanvas(caps); @@ -67,17 +87,19 @@ public class TestBug572AWT extends UITestCase { window.setSize(512, 512); window.validate(); - window.setVisible(true); + // trigger realization on AWT-EDT, otherwise it won't immediatly .. + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + window.setVisible(true); + } + } ); System.err.println("XXXX-0 "+glCanvas.getDelegatedDrawable().isRealized()+", "+glCanvas); - // Immediately displayable after issuing initial setVisible(true) .. even not within AWT-EDT ? + // Immediately displayable after issuing initial setVisible(true) on AWT-EDT! Assert.assertTrue("GLCanvas didn't become displayable", glCanvas.isDisplayable()); Assert.assertTrue("GLCanvas didn't become realized", glCanvas.isRealized()); - // Would be required if not immediately displayable ... - // Assert.assertTrue("GLCanvas didn't become displayable and realized", AWTRobotUtil.waitForRealized(glCanvas, true)); - // System.err.println("XXXX-1 "+glCanvas.getDelegatedDrawable().isRealized()+", "+glCanvas); - // The AWT-EDT reshape/repaint events happen offthread later .. System.err.println("XXXX-1 reshapeCount "+snapshooter.getReshapeCount()); System.err.println("XXXX-1 displayCount "+snapshooter.getDisplayCount()); @@ -97,30 +119,58 @@ public class TestBug572AWT extends UITestCase { // After initial 'setVisible(true)' all AWT manipulation needs to be done // via the AWT EDT, according to the AWT spec. - Runnable cleanup = new Runnable() { - public void run() { - System.err.println("cleaning up..."); - window.setVisible(false); - try { - window.removeAll(); - } catch (Throwable t) { - Assume.assumeNoException(t); - t.printStackTrace(); - } - window.dispose(); - } - - }; - // AWT / Swing on EDT.. - SwingUtilities.invokeAndWait(cleanup); + SwingUtilities.invokeAndWait(new Cleanup(window)); } @Test - public void test01() throws InterruptedException, InvocationTargetException { - runTestGL(); - } + public void test02RealizeGLCanvasOnCurrentThread() throws InterruptedException, InvocationTargetException { + final Window window = new JFrame(this.getSimpleTestName(" - ")); + final GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); + final GLCanvas glCanvas = new GLCanvas(caps); + final SnapshotGLEventListener snapshooter = new SnapshotGLEventListener(); + snapshooter.setMakeSnapshotAlways(true); + glCanvas.addGLEventListener(new GearsES2()); + glCanvas.addGLEventListener(snapshooter); + window.add(glCanvas); + + // Revalidate size/layout. + // Always validate if component added/removed. + // Ensure 1st paint of GLCanvas will have a valid size, hence drawable gets created. + window.setSize(512, 512); + window.validate(); + // trigger realization on non AWT-EDT, realization will happen at a later time .. + window.setVisible(true); + System.err.println("XXXX-0 "+glCanvas.getDelegatedDrawable().isRealized()+", "+glCanvas); + + // Wait until it's displayable after issuing initial setVisible(true) on current thread (non AWT-EDT)! + Assert.assertTrue("GLCanvas didn't become visible", AWTRobotUtil.waitForVisible(glCanvas, true)); + Assert.assertTrue("GLCanvas didn't become realized", AWTRobotUtil.waitForRealized(glCanvas, true)); // implies displayable + + // The AWT-EDT reshape/repaint events happen offthread later .. + System.err.println("XXXX-1 reshapeCount "+snapshooter.getReshapeCount()); + System.err.println("XXXX-1 displayCount "+snapshooter.getDisplayCount()); + + // Wait unitl AWT-EDT has issued reshape/repaint + for (int wait=0; wait0); + Assert.assertTrue("GLCanvas didn't display", snapshooter.getDisplayCount()>0); + + // After initial 'setVisible(true)' all AWT manipulation needs to be done + // via the AWT EDT, according to the AWT spec. + + // AWT / Swing on EDT.. + SwingUtilities.invokeAndWait(new Cleanup(window)); + } + public static void main(String args[]) { org.junit.runner.JUnitCore.main(TestBug572AWT.class.getName()); } -- cgit v1.2.3 From 3ce0aa6e36d9474ac3105cab491a60327860757d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 29 Dec 2012 23:37:36 +0100 Subject: Fix Bug 658 (Mesa 9.0 3.1 Intel compat quirk, 3.1 core only) ; No PROFILE_ALIASING compat -> core ; Fix setGLFunctionAvailability(..) failure path @ profile query - Add GLRendererQuirks.GLNonCompliant, marking a GL context/profile non compliant. Currently: 'Mesa DRI Intel(R) Sandybridge Desktop' && 3.1 compat profile - Fix Bug 658 (Mesa 9.0 3.1 Intel compat quirk, 3.1 core only) Detect case using new GLRendererQuirks.GLNonCompliant in setGLFunctionAvailability() and return 'false'. - No PROFILE_ALIASING compat -> core Use true core GL profiles / context if available to ensure proper API behavior across platforms due to different functionality. E.g. don't use GL3bc if GL3 is requested. - Fix setGLFunctionAvailability(..) failure path @ profile query Destroy temp context & zero result to cont. iterating through GL versions. This missing cleanup lead to returning the faulty GL context handle and it's mapping/usage. --- make/scripts/tests.sh | 6 +- .../com/jogamp/opengl/GLRendererQuirks.java | 18 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 115 +++++++---- .../junit/jogl/acore/TestGLMesaBug651NEWT.java | 222 +++++++++++++++++++++ .../junit/jogl/acore/TestGLMesaBug658NEWT.java | 200 +++++++++++++++++++ .../test/junit/jogl/acore/TestGLUnitsNEWT.java | 210 ------------------- 6 files changed, 518 insertions(+), 253 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug658NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d4ce3c3e1..9f168cbe5 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -97,6 +97,7 @@ function jrun() { #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" + #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" @@ -279,7 +280,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLUnitsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -347,7 +349,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 2f453a497..9a13ff904 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -37,7 +37,7 @@ package com.jogamp.opengl; */ public class GLRendererQuirks { /** - * Crashes XServer when using double buffered PBuffer with: + * Crashes XServer when using double buffered PBuffer with GL_RENDERER: *
        *
      • Mesa DRI Intel(R) Sandybridge Desktop
      • *
      • Mesa DRI Intel(R) Ivybridge Mobile - 3.0 Mesa 8.0.4
      • @@ -62,11 +62,23 @@ public class GLRendererQuirks { /** GLSL discard command leads to undefined behavior or won't get compiled if being used. Appears to happen on Nvidia Tegra2. FIXME: Constrain version. */ public static final int GLSLBuggyDiscard = 5; + /** + * Non compliant GL context, e.g. due to a buggy implementation rendering it not suitable for use. + *

        + * Mesa >= 9.0 (?), Intel driver, OpenGL 3.1 compatibility context is not compliant: + *

        +     * GL_RENDERER: Mesa DRI Intel(R) Sandybridge Desktop 
        +     * 
        + *

        + */ + public static final int GLNonCompliant = 6; + /** Number of quirks known. */ - public static final int COUNT = 6; + public static final int COUNT = 7; private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", - "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard" + "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", + "GLNonCompliant" }; private final int _bitmask; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index f61b55497..c3c2eff4b 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -571,9 +571,10 @@ public abstract class GLContextImpl extends GLContext { final boolean created; try { created = createImpl(shareWith); // may throws exception if fails! - if( created && isGL3core() && ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=2 ) ) { - // Due to GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331) - // There is no more default VAO buffer 0 bound, hence generating and binding one + if( created && isGL3core() && ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) ) { + // Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296), + // GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331) + // there is no more default VAO buffer 0 bound, hence generating and binding one // to avoid INVALID_OPERATION at VertexAttribPointer. // More clear is GL 4.3 core spec: 10.4 (p 307). final int[] tmp = new int[1]; @@ -773,6 +774,29 @@ public abstract class GLContextImpl extends GLContext { boolean hasGL2 = false; boolean hasGL4 = false; boolean hasGL3 = false; + + // Even w/ PROFILE_ALIASING, try to use true core GL profiles + // ensuring proper user behavior across platforms due to different feature sets! + // + if(!hasGL4) { + hasGL4 = createContextARBMapVersionsAvailable(4, CTX_PROFILE_CORE); // GL4 + success |= hasGL4; + if(hasGL4) { + // Map all lower compatible profiles: GL3 + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + if(PROFILE_ALIASING) { + hasGL3 = true; + } + resetStates(); // clean this context states, since creation was temporary + } + } + if(!hasGL3) { + hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 + success |= hasGL3; + if(hasGL3) { + resetStates(); // clean this context states, since creation was temporary + } + } if(!hasGL4bc) { hasGL4bc = createContextARBMapVersionsAvailable(4, CTX_PROFILE_COMPAT); // GL4bc success |= hasGL4bc; @@ -780,8 +804,12 @@ public abstract class GLContextImpl extends GLContext { // Map all lower compatible profiles: GL3bc, GL2, GL4, GL3 GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxMajorVersion, ctxMinorVersion, ctxOptions); GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxMajorVersion, ctxMinorVersion, ctxOptions); - GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + if(!hasGL4) { + GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + } + if(!hasGL3) { + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + } if(PROFILE_ALIASING) { hasGL3bc = true; hasGL2 = true; @@ -797,7 +825,9 @@ public abstract class GLContextImpl extends GLContext { if(hasGL3bc) { // Map all lower compatible profiles: GL2 and GL3 GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxMajorVersion, ctxMinorVersion, ctxOptions); - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + if(!hasGL3) { + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + } if(PROFILE_ALIASING) { hasGL2 = true; hasGL3 = true; @@ -812,25 +842,6 @@ public abstract class GLContextImpl extends GLContext { resetStates(); // clean this context states, since creation was temporary } } - if(!hasGL4) { - hasGL4 = createContextARBMapVersionsAvailable(4, CTX_PROFILE_CORE); // GL4 - success |= hasGL4; - if(hasGL4) { - // Map all lower compatible profiles: GL3 - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); - if(PROFILE_ALIASING) { - hasGL3 = true; - } - resetStates(); // clean this context states, since creation was temporary - } - } - if(!hasGL3) { - hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 - success |= hasGL3; - if(hasGL3) { - resetStates(); // clean this context states, since creation was temporary - } - } if(success) { // only claim GL versions set [and hence detected] if ARB context creation was successful GLContext.setAvailableGLVersionsSet(device); @@ -883,7 +894,7 @@ public abstract class GLContextImpl extends GLContext { /* min */ majorMin, minorMin, /* res */ major, minor); - if(0==_context && CTX_PROFILE_CORE == reqProfile) { + if( 0 == _context && CTX_PROFILE_CORE == reqProfile && !PROFILE_ALIASING ) { // try w/ FORWARD instead of CORE ctp &= ~CTX_PROFILE_CORE ; ctp |= CTX_OPTION_FORWARD ; @@ -891,7 +902,7 @@ public abstract class GLContextImpl extends GLContext { /* max */ majorMax, minorMax, /* min */ majorMin, minorMin, /* res */ major, minor); - if(0==_context) { + if( 0 == _context ) { // Try a compatible one .. even though not requested .. last resort ctp &= ~CTX_PROFILE_CORE ; ctp &= ~CTX_OPTION_FORWARD ; @@ -903,7 +914,7 @@ public abstract class GLContextImpl extends GLContext { } } final boolean res; - if(0!=_context) { + if( 0 != _context ) { AbstractGraphicsDevice device = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); // ctxMajorVersion, ctxMinorVersion, ctxOptions is being set by // createContextARBVersions(..) -> setGLFunctionAvailbility(..) -> setContextVersion(..) @@ -941,6 +952,10 @@ public abstract class GLContextImpl extends GLContext { if(0 != _context) { ok = setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true); + if(!ok) { + destroyContextARBImpl(_context); + _context = 0; + } } else { ok = false; } @@ -1157,7 +1172,7 @@ public abstract class GLContextImpl extends GLContext { * context. See {@link #isFunctionAvailable(String)} for more information on * the definition of "available". *
        - * All ProcaddressTables are being determined, the GL version is being set + * All ProcaddressTables are being determined and cached, the GL version is being set * and the extension cache is determined as well. * * @param force force the setting, even if is already being set. @@ -1165,15 +1180,19 @@ public abstract class GLContextImpl extends GLContext { * @param major OpenGL major version * @param minor OpenGL minor version * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY} - * @param strictVersionMatch if true and the ctx version (by string) is lower than the given major.minor version, - * method aborts and returns false, otherwise true. - * @return returns true if successful, otherwise false. See strictVersionMatch. + * @param strictMatch if true the ctx must + *
          + *
        • be greater or equal than the requested major.minor version version, and
        • + *
        • match the ctxProfileBits
        • + *
        , otherwise method aborts and returns false. + * @return returns true if successful, otherwise false. See strictMatch. + * If false is returned, no data has been cached or mapped, i.e. ProcAddressTable, Extensions, Version, etc. * @see #setContextVersion * @see javax.media.opengl.GLContext#CTX_OPTION_ANY * @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT * @see javax.media.opengl.GLContext#CTX_IMPL_ES2_COMPAT */ - protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits, boolean strictVersionMatch) { + protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits, boolean strictMatch) { if(null!=this.gl && null!=glProcAddressTable && !force) { return true; // already done and not forced } @@ -1208,7 +1227,7 @@ public abstract class GLContextImpl extends GLContext { final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0); final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); if( null != strGLVersionNumber && ( strGLVersionNumber.compareTo(setGLVersionNumber) < 0 || 0 == major ) ) { - if( 0 < major && strictVersionMatch ) { + if( strictMatch && 0 < major ) { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch: "+major+"."+minor+", ctp "+toHexString(ctxProfileBits)+", "+glVersion+", "+strGLVersionNumber); } @@ -1227,6 +1246,16 @@ public abstract class GLContextImpl extends GLContext { if( 2 > major ) { // there is no ES2-compat for a profile w/ major < 2 ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT; } + + setRendererQuirks(major, minor, ctxProfileBits); + + if( strictMatch && glRendererQuirks.exist(GLRendererQuirks.GLNonCompliant) ) { + if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL is not compliant: "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)+", "+glRenderer); + } + return false; + } + contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 validated FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion) + ", "+glVersionNumber); @@ -1301,8 +1330,6 @@ public abstract class GLContextImpl extends GLContext { // setContextVersion(major, minor, ctxProfileBits, true); - setRendererQuirks( 0 == ( ctxProfileBits & GLContext.CTX_IMPL_ACCEL_SOFT ) ); - setDefaultSwapInterval(); if(DEBUG) { @@ -1311,10 +1338,13 @@ public abstract class GLContextImpl extends GLContext { return true; } - private final void setRendererQuirks(boolean hwAccel) { + private final void setRendererQuirks(int major, int minor, int ctp) { int[] quirks = new int[GLRendererQuirks.COUNT]; int i = 0; + final boolean hwAccel = 0 == ( ctp & GLContext.CTX_IMPL_ACCEL_SOFT ); + final boolean compatCtx = 0 != ( ctp & GLContext.CTX_PROFILE_COMPAT ); + // OS related quirks if( Platform.getOSType() == Platform.OSType.MACOS ) { final int quirk1 = GLRendererQuirks.NoOffscreenBitmap; @@ -1344,7 +1374,7 @@ public abstract class GLContextImpl extends GLContext { if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer); } - quirks[i++] = quirk; + quirks[i++] = quirk; } if( hwAccel /* glRendererLowerCase.contains("intel(r)") || glRendererLowerCase.contains("amd") */ ) { @@ -1354,7 +1384,16 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } + if( glRendererLowerCase.contains("intel(r)") && compatCtx && ( major>3 || major==3 && minor>=1 ) ) + { + final int quirk = GLRendererQuirks.GLNonCompliant; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Renderer " + glRenderer); + } + quirks[i++] = quirk; + } } + glRendererQuirks = new GLRendererQuirks(quirks, 0, i); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java new file mode 100644 index 000000000..90f0c5414 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLMesaBug651NEWT.java @@ -0,0 +1,222 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.GLExtensions; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +/** + * Some GL state values are broken w/ Mesa 9.0 w/ multiple different context. + *

        + * This bug lies within Mesa3D (any renderer) and is fixed in + * commit 8dc79ae7d73cf6711c2182ff9a5d37ef6c989d23. + *

        + *

        + * Mesa3D Version 9.0 still exposes this bug, + * where 9.0.1 has it fixed w/ above commit. + *

        + * + */ +public class TestGLMesaBug651NEWT extends UITestCase { + static int width, height; + + @BeforeClass + public static void initClass() { + width = 512; + height = 512; + } + + @AfterClass + public static void releaseClass() { + } + + class UnitTester implements GLEventListener { + @Override + public void init(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + System.err.println("GL UnitTester"); + System.err.println(" GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println(" GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println(" GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println(" GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none")+", "+gl.getContext().getGLSLVersionNumber()); + System.err.println(" GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport()); + System.err.println(" GL Profile: "+gl.getGLProfile()); + System.err.println(" GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + System.err.println(" GL:" + gl + ", " + gl.getContext().getGLVersion()); + + final int _glerr = gl.glGetError(); // clear pre-error + System.err.println(" - pre GL-Error 0x"+Integer.toHexString(_glerr)); + + final int[] val = new int[1]; + final int[] glerr = new int[] { GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR }; + int i=0; + + val[0]=0; + gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0); + System.out.println(" - GL_MAX_TEXTURE_SIZE: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + i++; + + val[0]=0; + gl.glGetIntegerv(GL2ES2.GL_ACTIVE_TEXTURE, val, 0); + System.out.println(" - GL_ACTIVE_TEXTURE: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + i++; + + if(gl.isGL2ES2()) { + val[0]=0; + gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, val, 0); + System.out.println(" - GL_MAX_TEXTURE_IMAGE_UNITS: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + } + i++; + + if( gl.hasFullFBOSupport() || gl.isExtensionAvailable(GLExtensions.NV_fbo_color_attachments) ) { + val[0]=0; + gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, val, 0); + System.out.println(" - GL_MAX_COLOR_ATTACHMENTS: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + } + i++; + + if( gl.hasFullFBOSupport() ) { + val[0]=0; + gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); + System.out.println(" - GL_MAX_SAMPLES: " + val[0]); + glerr[i] = gl.glGetError(); // clear pre-error + System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); + } + i++; + + boolean ok = true; + String res=""; + for(int j=0; j= 9.0 seems to be broken. + *

        + * This bug lies within Mesa3D (any renderer) and is fixed in + * commit ??? (not yet). + *

        + *

        + * Mesa3D Version 9.0 still exposes this bug, + * where 9.?.? has it fixed w/ above commit. + *

        + * + */ +public class TestGLMesaBug658NEWT extends UITestCase { + + @Test + public void test00ShowAvailProfiles() { + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false).toString()); + } + + @Test + public void test10GL2PolygonModeFailure() { + testGLNPolygonModeFailureImpl(GLProfile.GL2); + } + + @Test + public void test11GL3bcPolygonModeFailure() { + testGLNPolygonModeFailureImpl(GLProfile.GL3bc); + } + + @Test + public void test12GL3PolygonModeFailure() { + testGLNPolygonModeFailureImpl(GLProfile.GL3); + } + + private void testGLNPolygonModeFailureImpl(String profile) { + if(!GLProfile.isAvailable(profile)) { System.err.println(profile+" n/a"); return; } + + final GLProfile pro = GLProfile.get(profile); + final GLCapabilities caps = new GLCapabilities(pro); + final GLWindow window = GLWindow.create(caps); + + window.setSize(640, 480); + window.addGLEventListener(new GLEventListener() { + public void reshape( + final GLAutoDrawable drawable, + final int x, + final int y, + final int width, + final int height) + { + // Nothing. + } + + public void init( + final GLAutoDrawable drawable) + { + final GLContext context = drawable.getContext(); + System.err.println("CTX: "+context.getGLVersion()); + + final GL2GL3 gl = drawable.getGL().getGL2GL3(); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + + if( gl.isGL2() || gl.isGLES2() ) { // compatibility profile || ES2 + gl.glPolygonMode(GL.GL_FRONT, GL2GL3.GL_FILL); + } else { + gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL2GL3.GL_FILL); + } + + final int e = gl.glGetError(); + Assert.assertTrue(e == GL.GL_NO_ERROR); // // FIXME On Mesa 9.0.1 w/ GL 3.1 -> GL.GL_INVALID_OPERATION ? + } + + public void dispose( + final GLAutoDrawable drawable) + { + // Nothing. + } + + public void display( + final GLAutoDrawable drawable) + { + // Nothing. + } + }); + + try { + window.setVisible(true); + } finally { + window.destroy(); + } + } + + @Test + public void test20GL2BindArrayAttributeFails() { + testGLNBindArrayAttributeFailsImpl(GLProfile.GL2); + } + + @Test + public void test21GL3bcBindArrayAttributeFails() { + testGLNBindArrayAttributeFailsImpl(GLProfile.GL3bc); + } + + @Test + public void test22GL3BindArrayAttributeFails() { + testGLNBindArrayAttributeFailsImpl(GLProfile.GL3); + } + + private void testGLNBindArrayAttributeFailsImpl(String profile) { + if(!GLProfile.isAvailable(profile)) { System.err.println(profile+ " n/a"); return; } + + final GLProfile pro = GLProfile.get(profile); + final GLCapabilities caps = new GLCapabilities(pro); + final GLWindow window = GLWindow.create(caps); + + window.setSize(640, 480); + window.addGLEventListener(new GLEventListener() { + public void reshape( + final GLAutoDrawable drawable, + final int x, + final int y, + final int width, + final int height) + { + // Nothing. + } + + public void init( + final GLAutoDrawable drawable) + { + final GLContext context = drawable.getContext(); + System.err.println("CTX: "+context.getGLVersion()); + + final GL2GL3 gl = drawable.getGL().getGL2GL3(); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + + final int[] name = new int[] { 0 }; + gl.glGenBuffers(1, name, 0); + Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); + + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, name[0]); + Assert.assertTrue(gl.glGetError() == 0); + gl.glBufferData(GL.GL_ARRAY_BUFFER, 4 * 32, null, GL.GL_STATIC_DRAW); + Assert.assertTrue(gl.glGetError() == 0); + + Assert.assertTrue(gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER) == name[0]); + gl.glEnableVertexAttribArray(1); + Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); + gl.glVertexAttribPointer(1, 4, GL.GL_FLOAT, false, 0, 0L); + Assert.assertTrue(gl.glGetError() == GL.GL_NO_ERROR); // FIXME On Mesa 9.0.1 w/ GL 3.1 -> GL.GL_INVALID_OPERATION ? + } + + public void dispose( + final GLAutoDrawable drawable) + { + // Nothing. + } + + public void display( + final GLAutoDrawable drawable) + { + // Nothing. + } + }); + + try { + window.setVisible(true); + } finally { + window.destroy(); + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestGLMesaBug658NEWT.class.getName()); + } + +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java deleted file mode 100644 index c699e6304..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLUnitsNEWT.java +++ /dev/null @@ -1,210 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.GLExtensions; -import com.jogamp.opengl.test.junit.util.UITestCase; - -import javax.media.opengl.GL; -import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL2GL3; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -public class TestGLUnitsNEWT extends UITestCase { - static int width, height; - - @BeforeClass - public static void initClass() { - width = 512; - height = 512; - } - - @AfterClass - public static void releaseClass() { - } - - class UnitTester implements GLEventListener { - @Override - public void init(GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - System.err.println("GL UnitTester"); - System.err.println(" GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); - System.err.println(" GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); - System.err.println(" GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); - System.err.println(" GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none")+", "+gl.getContext().getGLSLVersionNumber()); - System.err.println(" GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport()); - System.err.println(" GL Profile: "+gl.getGLProfile()); - System.err.println(" GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); - System.err.println(" GL:" + gl + ", " + gl.getContext().getGLVersion()); - - final int _glerr = gl.glGetError(); // clear pre-error - System.err.println(" - pre GL-Error 0x"+Integer.toHexString(_glerr)); - - final int[] val = new int[1]; - final int[] glerr = new int[] { GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR, GL.GL_NO_ERROR }; - int i=0; - - val[0]=0; - gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0); - System.out.println(" - GL_MAX_TEXTURE_SIZE: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - i++; - - val[0]=0; - gl.glGetIntegerv(GL2ES2.GL_ACTIVE_TEXTURE, val, 0); - System.out.println(" - GL_ACTIVE_TEXTURE: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - i++; - - if(gl.isGL2ES2()) { - val[0]=0; - gl.glGetIntegerv(GL2ES2.GL_MAX_TEXTURE_IMAGE_UNITS, val, 0); - System.out.println(" - GL_MAX_TEXTURE_IMAGE_UNITS: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - } - i++; - - if( gl.hasFullFBOSupport() || gl.isExtensionAvailable(GLExtensions.NV_fbo_color_attachments) ) { - val[0]=0; - gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, val, 0); - System.out.println(" - GL_MAX_COLOR_ATTACHMENTS: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - } - i++; - - if( gl.hasFullFBOSupport() ) { - val[0]=0; - gl.glGetIntegerv(GL2GL3.GL_MAX_SAMPLES, val, 0); - System.out.println(" - GL_MAX_SAMPLES: " + val[0]); - glerr[i] = gl.glGetError(); // clear pre-error - System.err.println(" - GL-Error 0x"+Integer.toHexString(glerr[i])); - } - i++; - - boolean ok = true; - String res=""; - for(int j=0; j Date: Sun, 30 Dec 2012 10:53:50 +0100 Subject: Cleanup / Simplify: setGLFunctionAvailability(..) / createContextARBVersions(..) GL Version Validation String or integer based GL version validation now happens in setGLFunctionAvailability(..) depending on the requested profile. Due to the 'strictMatch' argument the method fails early when unsatisfied also allowing to simplify createContextARBVersions(..) implementation. --- make/scripts/tests.sh | 2 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 145 ++++++++++++++-------- src/jogl/native/JoglCommon.c | 22 ++++ 3 files changed, 118 insertions(+), 51 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9f168cbe5..353cc873a 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -97,7 +97,7 @@ function jrun() { #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" - #D_ARGS="-Djogl.debug.GLContext" + D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index c3c2eff4b..e8654ccba 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -940,10 +940,8 @@ public abstract class GLContextImpl extends GLContext { major[0]=majorMax; minor[0]=minorMax; long _context=0; - boolean ok = false; - while ( !ok && - GLContext.isValidGLVersion(major[0], minor[0]) && + while ( GLContext.isValidGLVersion(major[0], minor[0]) && ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) { if (DEBUG) { System.err.println(getThreadName() + ": createContextARBVersions: share "+share+", direct "+direct+", version "+major[0]+"."+minor[0]); @@ -951,32 +949,16 @@ public abstract class GLContextImpl extends GLContext { _context = createContextARBImpl(share, direct, ctxOptionFlags, major[0], minor[0]); if(0 != _context) { - ok = setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true); - if(!ok) { - destroyContextARBImpl(_context); - _context = 0; - } - } else { - ok = false; - } - - if(ok && major[0]>=3) { - int[] hasMajor = new int[1]; int[] hasMinor = new int[1]; - gl.glGetIntegerv(GL2GL3.GL_MAJOR_VERSION, hasMajor, 0); - gl.glGetIntegerv(GL2GL3.GL_MINOR_VERSION, hasMinor, 0); - ok = hasMajor[0]>major[0] || ( hasMajor[0]==major[0] && hasMinor[0]>=minor[0] ) ; - if(!ok) { - removeCachedVersion(major[0], minor[0], ctxOptionFlags); + if( setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true) ) { + break; + } else { destroyContextARBImpl(_context); _context = 0; } - if (DEBUG) { - System.err.println(getThreadName() + ": createContextARBVersions: version verification - expected "+major[0]+"."+minor[0]+", has "+hasMajor[0]+"."+hasMinor[0]+" == "+ok); - } } - if(!ok) { - if(!GLContext.decrementGLVersion(major, minor)) break; + if(!GLContext.decrementGLVersion(major, minor)) { + break; } } return _context; @@ -1133,8 +1115,7 @@ public abstract class GLContextImpl extends GLContext { final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper(); final long _glGetString = glDynLookupHelper.dynamicLookupFunction("glGetString"); if(0 == _glGetString) { - // FIXME - System.err.println("Warning: Entry point to 'glGetString' is NULL."); + System.err.println("Error: Entry point to 'glGetString' is NULL."); if(DEBUG) { Thread.dumpStack(); } @@ -1142,7 +1123,6 @@ public abstract class GLContextImpl extends GLContext { } else { final String _glRenderer = glGetStringInt(GL.GL_RENDERER, _glGetString); if(null == _glRenderer) { - // FIXME if(DEBUG) { System.err.println("Warning: GL_RENDERER is NULL."); Thread.dumpStack(); @@ -1166,6 +1146,22 @@ public abstract class GLContextImpl extends GLContext { } } + private final boolean getGLIntVersion(int[] glIntMinor, int[] glIntMajor) { + final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper(); + final long _glGetIntegerv = glDynLookupHelper.dynamicLookupFunction("glGetIntegerv"); + if( 0 == _glGetIntegerv ) { + System.err.println("Error: Entry point to 'glGetIntegerv' is NULL."); + if(DEBUG) { + Thread.dumpStack(); + } + return false; + } else { + glGetIntegervInt(GL2GL3.GL_MAJOR_VERSION, glIntMajor, 0, _glGetIntegerv); + glGetIntegervInt(GL2GL3.GL_MINOR_VERSION, glIntMinor, 0, _glGetIntegerv); + return true; + } + } + /** * Sets the OpenGL implementation class and * the cache of which GL functions are available for calling through this @@ -1182,7 +1178,7 @@ public abstract class GLContextImpl extends GLContext { * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY} * @param strictMatch if true the ctx must *
          - *
        • be greater or equal than the requested major.minor version version, and
        • + *
        • be greater or equal than the requested major.minor version, and
        • *
        • match the ctxProfileBits
        • *
        , otherwise method aborts and returns false. * @return returns true if successful, otherwise false. See strictMatch. @@ -1207,42 +1203,84 @@ public abstract class GLContextImpl extends GLContext { { final boolean initGLRendererAndGLVersionStringsOK = initGLRendererAndGLVersionStrings(); - if(DEBUG) { - if( !initGLRendererAndGLVersionStringsOK ) { - System.err.println("Warning: setGLFunctionAvailability: intialization of GL renderer strings failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); + if( !initGLRendererAndGLVersionStringsOK ) { + final String errMsg = "Intialization of GL renderer strings failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null); + if( strictMatch ) { + // query mode .. simply fail + if(DEBUG) { + System.err.println("Warning: setGLFunctionAvailability: "+errMsg); + } + return false; } else { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Given "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)); + // unusable GL context - non query mode - hard fail! + throw new GLException(errMsg); } + } else if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Given "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)); } } - - if(!isCurrentContextHardwareRasterizer()) { - ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; - } - // Pick the version from the GL-version string, - // if smaller _or_ given major == 0. - final VersionNumber glVersionNumber; - { + // + // Validate GL version either by GL-Integer or GL-String + // + + if(major >= 3) { + // Validate the requested version w/ the GL-version from an integer query. + final int[] glIntMinor = new int[] { 0 }, glIntMajor = new int[] { 0 }; + final boolean getGLIntVersionOK = getGLIntVersion(glIntMinor, glIntMajor); + if( !getGLIntVersionOK ) { + final String errMsg = "Fetching GL Integer Version failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null); + if( strictMatch ) { + // query mode .. simply fail + if(DEBUG) { + System.err.println("Warning: setGLFunctionAvailability: "+errMsg); + } + return false; + } else { + // unusable GL context - non query mode - hard fail! + throw new GLException(errMsg); + } + } + if (DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (Int) - expected "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", has "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); + } + + if( glIntMajor[0] "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); + } + return false; + } + major = glIntMajor[0]; + minor = glIntMinor[0]; + } + if ( !GLContext.isValidGLVersion(major, minor) ) { + throw new GLException("Invalid GL Version (Int) "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); + } + } else { + // Validate the requested version w/ the GL-version from the version string. final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0); final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); + if (DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (String) - expected "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", has "+glVersion+", "+strGLVersionNumber); + } + if( null != strGLVersionNumber && ( strGLVersionNumber.compareTo(setGLVersionNumber) < 0 || 0 == major ) ) { if( strictMatch && 0 < major ) { if(DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch: "+major+"."+minor+", ctp "+toHexString(ctxProfileBits)+", "+glVersion+", "+strGLVersionNumber); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (String): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+strGLVersionNumber); } return false; } - glVersionNumber = strGLVersionNumber; - major = glVersionNumber.getMajor(); - minor = glVersionNumber.getMinor(); - } else { - glVersionNumber = setGLVersionNumber; + major = strGLVersionNumber.getMajor(); + minor = strGLVersionNumber.getMinor(); + } + if ( !GLContext.isValidGLVersion(major, minor) ) { + throw new GLException("Invalid GL Version (String) "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+strGLVersionNumber); } } - if ( !GLContext.isValidGLVersion(major, minor) ) { - throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctxProfileBits)+", "+glVersion+", "+glVersionNumber); - } + if( 2 > major ) { // there is no ES2-compat for a profile w/ major < 2 ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT; } @@ -1256,9 +1294,13 @@ public abstract class GLContextImpl extends GLContext { return false; } + if(!isCurrentContextHardwareRasterizer()) { + ctxProfileBits |= GLContext.CTX_IMPL_ACCEL_SOFT; + } + contextFQN = getContextFQN(adevice, major, minor, ctxProfileBits); if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 validated FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion) + ", "+glVersionNumber); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.0 validated FQN: "+contextFQN+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)); } // @@ -1771,4 +1813,7 @@ public abstract class GLContextImpl extends GLContext { /** Internal bootstraping glGetString(GL_RENDERER) */ protected static native String glGetStringInt(int name, long procAddress); + + /** Internal bootstraping glGetIntegerv(..) for version */ + protected static native void glGetIntegervInt(int pname, int[] params, int params_offset, long procAddress); } diff --git a/src/jogl/native/JoglCommon.c b/src/jogl/native/JoglCommon.c index d9f5edd49..62dd8ef21 100644 --- a/src/jogl/native/JoglCommon.c +++ b/src/jogl/native/JoglCommon.c @@ -149,3 +149,25 @@ Java_jogamp_opengl_GLContextImpl_glGetStringInt(JNIEnv *env, jclass _unused, jin return (*env)->NewStringUTF(env, _res); } +/* + * Class: jogamp_opengl_GLContextImpl + * Method: glGetIntegervInt + * Signature: (ILjava/lang/Object;I)V + */ +JNIEXPORT void JNICALL +Java_jogamp_opengl_GLContextImpl_glGetIntegervInt(JNIEnv *env, jclass _unused, jint pname, jobject params, jint params_byte_offset, jlong procAddress) { + typedef void (KHRONOS_APIENTRY*_local_PFNGLGETINTEGERVPROC)(unsigned int pname, int * params); + + _local_PFNGLGETINTEGERVPROC ptr_glGetIntegerv; + int * _params_ptr = NULL; + if ( NULL != params ) { + _params_ptr = (int *) (((char*) (*env)->GetPrimitiveArrayCritical(env, params, NULL) ) + params_byte_offset); + } + ptr_glGetIntegerv = (_local_PFNGLGETINTEGERVPROC) (intptr_t) procAddress; + assert(ptr_glGetIntegerv != NULL); + (* ptr_glGetIntegerv) ((unsigned int) pname, (int *) _params_ptr); + if ( NULL != params ) { + (*env)->ReleasePrimitiveArrayCritical(env, params, _params_ptr, 0); + } +} + -- cgit v1.2.3 From 35236f571a09e1ef21a57693bd2e4d715413f700 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Dec 2012 19:40:17 +0100 Subject: Bug632: Test NEWT Child Window Translucency (X11/Windows) .. - Windows: Child window is not translucent at all - X11: Child window is translucent to parent's background, however - parents content is _not_ 'composed in'. - TODO: Find whether there is a solution or not. - Note: The child window does not change it's rel. position if parent moves! This is a feature, since we don't have impl. a layout. --- make/scripts/java-win64-dbg.bat | 2 +- make/scripts/tests-x64.bat | 13 +- make/scripts/tests.sh | 47 ++++---- make/stub_includes/win32/WindowsDWM.h | 5 +- .../wgl/WindowsWGLGraphicsConfiguration.java | 13 +- .../jogamp/nativewindow/windows/GDIUtil.java | 10 ++ src/nativewindow/native/win32/GDImisc.c | 26 ++++ src/nativewindow/native/win32/WindowsDWM.h | 2 + .../TestTranslucentChildWindowBug632NEWT.java | 132 +++++++++++++++++++++ .../parenting/TestTranslucentParentingAWT.java | 12 +- 10 files changed, 219 insertions(+), 43 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentChildWindowBug632NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index f0a0e9ad7..239856c84 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -30,7 +30,7 @@ REM set D_ARGS="-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" -REM set D_ARGS="-Djogl.debug.GraphicsConfiguration" +set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.GLDrawable" "-Dnativewindow.debug.GraphicsConfiguration" REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 2429ede0b..63a8d57f7 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -48,7 +48,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtK REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* @@ -60,6 +60,8 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestP REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* @@ -87,8 +89,13 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCu REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleAWT -time 10000 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleNEWT -time 10000 +REM scripts\java-win64-dbg.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT %* +REM scripts\java-win64-dbg.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT %* +REM scripts\java-win64-dbg.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT %* +REM scripts\java-win64-dbg.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* + REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 353cc873a..7cd1fdc5b 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -97,14 +97,15 @@ function jrun() { #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" - D_ARGS="-Djogl.debug.GLContext" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" + D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" + #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.fbo.force.none" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" @@ -281,7 +282,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -291,7 +292,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* @@ -304,11 +304,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* - - #testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* @@ -324,8 +319,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT @@ -409,23 +402,13 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* -#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT @@ -436,9 +419,27 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* #testawt $* -#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* +# +# NEWT Parenting (w/ NEWT, AWT or SWT) +# +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* + # # Misc Utils # diff --git a/make/stub_includes/win32/WindowsDWM.h b/make/stub_includes/win32/WindowsDWM.h index 357602dae..2115a5908 100644 --- a/make/stub_includes/win32/WindowsDWM.h +++ b/make/stub_includes/win32/WindowsDWM.h @@ -1,8 +1,11 @@ #ifndef WGL_DWM_VERSION_1_X -#define DWM_BB_ENABLE 1 +#define DWM_BB_ENABLE 0x00000001 +#define DWM_BB_BLURREGION 0x00000002 +#define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 #define DWM_EC_DISABLECOMPOSITION 0 #define DWM_EC_ENABLECOMPOSITION 1 + typedef struct tagDWM_BLURBEHIND { DWORD dwFlags; diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java index 70da1137d..651d981ab 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java @@ -55,6 +55,7 @@ import com.jogamp.opengl.GLExtensions; import jogamp.nativewindow.windows.DWM_BLURBEHIND; import jogamp.nativewindow.windows.GDI; +import jogamp.nativewindow.windows.GDIUtil; import jogamp.nativewindow.windows.MARGINS; import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR; import jogamp.opengl.GLContextImpl; @@ -170,13 +171,13 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio " for device context " + toHexString(hdc) + ": error code " + GDI.GetLastError()); } - if(!caps.isBackgroundOpaque()) { + if( !caps.isBackgroundOpaque() ) { final long hwnd = GDI.WindowFromDC(hdc); DWM_BLURBEHIND bb = DWM_BLURBEHIND.create(); - bb.setDwFlags(GDI.DWM_BB_ENABLE); - bb.setFEnable(1); + bb.setDwFlags(GDI.DWM_BB_ENABLE| GDI.DWM_BB_TRANSITIONONMAXIMIZED); + bb.setFEnable( 1 ); boolean ok = GDI.DwmEnableBlurBehindWindow(hwnd, bb); - if(ok) { + if( ok ) { MARGINS m = MARGINS.create(); m.setCxLeftWidth(-1); m.setCxRightWidth(-1); @@ -185,7 +186,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio ok = GDI.DwmExtendFrameIntoClientArea(hwnd, m); } if(DEBUG) { - System.err.println("translucency enabled on wnd: 0x"+Long.toHexString(hwnd)+" - ok: "+ok); + final boolean isUndecorated = GDIUtil.IsUndecorated(hwnd); + final boolean isChild = GDIUtil.IsChild(hwnd); + System.err.println("translucency enabled on wnd: 0x"+Long.toHexString(hwnd)+" - isUndecorated "+isUndecorated+", isChild "+isChild+", ok: "+ok); } } if (DEBUG) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index 2f4e18359..acb4c84da 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -112,12 +112,22 @@ public class GDIUtil implements ToolkitProperties { return (Point) GetRelativeLocation0(src_win, dest_win, src_x, src_y); } + public static boolean IsUndecorated(long win) { + return IsUndecorated0(win); + } + + public static boolean IsChild(long win) { + return IsChild0(win); + } + public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc); public static native boolean DestroyWindowClass(long hInstance, String className); private static native boolean initIDs0(); private static native long getDummyWndProc0(); private static native Object GetRelativeLocation0(long src_win, long dest_win, int src_x, int src_y); + private static native boolean IsChild0(long win); + private static native boolean IsUndecorated0(long win); static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height); } diff --git a/src/nativewindow/native/win32/GDImisc.c b/src/nativewindow/native/win32/GDImisc.c index 3ab7f9859..23be47380 100644 --- a/src/nativewindow/native/win32/GDImisc.c +++ b/src/nativewindow/native/win32/GDImisc.c @@ -224,3 +224,29 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_windows_GDIUtil_GetRelativeLo return (*env)->NewObject(env, pointClz, pointCstr, (jint)dest.x, (jint)dest.y); } +/* + * Class: jogamp_nativewindow_windows_GDIUtil + * Method: IsChild0 + */ +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsChild0 + (JNIEnv *env, jclass unused, jlong jwin) +{ + HWND hwnd = (HWND) (intptr_t) jwin; + LONG style = GetWindowLong(hwnd, GWL_STYLE); + BOOL bIsChild = 0 != (style & WS_CHILD) ; + return bIsChild ? JNI_TRUE : JNI_FALSE; +} + +/* + * Class: jogamp_nativewindow_windows_GDIUtil + * Method: IsUndecorated0 + */ +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsUndecorated0 + (JNIEnv *env, jclass unused, jlong jwin) +{ + HWND hwnd = (HWND) (intptr_t) jwin; + LONG style = GetWindowLong(hwnd, GWL_STYLE); + BOOL bIsUndecorated = 0 != (style & (WS_CHILD|WS_POPUP)) ; + return bIsUndecorated ? JNI_TRUE : JNI_FALSE; +} + diff --git a/src/nativewindow/native/win32/WindowsDWM.h b/src/nativewindow/native/win32/WindowsDWM.h index 36f82fc94..6e5160fa4 100644 --- a/src/nativewindow/native/win32/WindowsDWM.h +++ b/src/nativewindow/native/win32/WindowsDWM.h @@ -4,6 +4,8 @@ #include #define DWM_BB_ENABLE 0x00000001 // fEnable has been specified + #define DWM_BB_BLURREGION 0x00000002 + #define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 #define DWM_EC_DISABLECOMPOSITION 0 #define DWM_EC_ENABLECOMPOSITION 1 diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentChildWindowBug632NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentChildWindowBug632NEWT.java new file mode 100644 index 000000000..1d186a490 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestTranslucentChildWindowBug632NEWT.java @@ -0,0 +1,132 @@ +package com.jogamp.opengl.test.junit.newt.parenting; + +import java.io.IOException; + +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindow; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestTranslucentChildWindowBug632NEWT extends UITestCase { + static long durationPerTest = 2*300; + static GLProfile glp; + static boolean opaque; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getDefault(); + opaque = false; + } + + static GLWindow createParentWindow(GLCapabilitiesImmutable caps, int width, int height) + throws InterruptedException + { + Assert.assertNotNull(caps); + // + // Create native windowing resources .. X11/Win/OSX + // + GLWindow glWindow; + glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + + glWindow.setTitle("NEWT Parenting Window Test"); + + glWindow.addGLEventListener(new GearsES2(1)); + + glWindow.setSize(width, height); + glWindow.setVisible(true); + Assert.assertEquals(true,glWindow.isVisible()); + Assert.assertEquals(true,glWindow.isNativeValid()); + + return glWindow; + } + + static GLWindow createNestedWindow(NativeWindow nativeParentWindow, GLCapabilitiesImmutable caps, int x, int y, int width, int height) + throws InterruptedException { + + Assert.assertNotNull(nativeParentWindow); + Assert.assertNotNull(caps); + // + // Create native windowing resources .. X11/Win/OSX + // + GLWindow glWindow; + glWindow = GLWindow.create(nativeParentWindow, caps); + Assert.assertNotNull(glWindow); + + glWindow.setTitle("NEWT Parenting Window Test"); + + glWindow.addGLEventListener(new GearsES2(1)); + + glWindow.setPosition(x, y); + glWindow.setSize(width, height); + glWindow.setVisible(true); + Assert.assertEquals(true,glWindow.isVisible()); + Assert.assertEquals(true,glWindow.isNativeValid()); + + return glWindow; + } + + static void destroyWindow(GLWindow glWindow) { + if(null!=glWindow) { + glWindow.destroy(); + Assert.assertEquals(false,glWindow.isNativeValid()); + } + } + + @Test + public void testWindow00() throws InterruptedException { + final Animator animator = new Animator(); + + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + caps.setBackgroundOpaque(opaque); + GLWindow window1 = createParentWindow(caps, 400, 400); + Assert.assertEquals(true,window1.isNativeValid()); + Assert.assertEquals(true,window1.isVisible()); + animator.add(window1); + + GLWindow window2 = createNestedWindow(window1, caps, 400-300, 400-300, 300, 300); + Assert.assertEquals(true,window2.isNativeValid()); + Assert.assertEquals(true,window2.isVisible()); + animator.add(window2); + + animator.start(); + + AbstractGraphicsDevice device1 = window1.getScreen().getDisplay().getGraphicsDevice(); + + System.err.println("GLProfiles window1: "+device1.getConnection()+": "+GLProfile.glAvailabilityToString(device1)); + + Thread.sleep(durationPerTest/2); + + window1.setSize(512, 512); + window2.setPosition(512-300, 512-300); + + Thread.sleep(durationPerTest/2); + + animator.stop(); + + destroyWindow(window2); + destroyWindow(window1); + } + + public static void main(String[] args) throws IOException { + for(int i=0; i Date: Mon, 31 Dec 2012 15:08:43 +0100 Subject: Enhance PMVMatrix: Use FloatStack to implement PushMatrix and PopMatrix (Bug 657) One FloatStack for each, MV, P and T, with initialialSize zero to save memore and growSizes: MV = 16 arrays, P = 2 arrays, T = 2 arrays, with array = 16 floats. This shall save performance due to the preallocated stack when used and growing only in the above mentioned grow intervals. We may finetune the growSize, if required. --- make/scripts/tests.sh | 6 +-- .../classes/com/jogamp/opengl/util/PMVMatrix.java | 57 +++++++++++----------- 2 files changed, 31 insertions(+), 32 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7cd1fdc5b..a235643f6 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -98,7 +98,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" - D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" + #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogamp.debug=all" @@ -260,7 +260,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -408,7 +408,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT $* #testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index 0d76151be..bfc03d019 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -37,8 +37,6 @@ package com.jogamp.opengl.util; import java.nio.Buffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; -import java.util.ArrayList; -import java.util.List; import javax.media.opengl.GL; import javax.media.opengl.GLException; @@ -48,6 +46,7 @@ import jogamp.opengl.ProjectFloat; import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.FloatStack; import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.geom.Frustum; @@ -260,9 +259,11 @@ public class PMVMatrix implements GLMatrixFunc { FloatUtil.makeIdentityf(matrixOrtho, 0); FloatUtil.makeZero(matrixFrustum, 0); - matrixPStack = new ArrayList(); - matrixMvStack= new ArrayList(); - + // Start w/ zero size to save memory + matrixTStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2) + matrixPStack = new FloatStack( 0, 2*16); // growSize: GL-min size (2) + matrixMvStack= new FloatStack( 0, 16*16); // growSize: half GL-min size (32) + // default values and mode glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -300,16 +301,16 @@ public class PMVMatrix implements GLMatrixFunc { matrixFrustum = null; if(null!=matrixPStack) { - matrixPStack.clear(); matrixPStack=null; + matrixPStack=null; } if(null!=matrixMvStack) { - matrixMvStack.clear(); matrixMvStack=null; + matrixMvStack=null; } if(null!=matrixPStack) { - matrixPStack.clear(); matrixPStack=null; + matrixPStack=null; } if(null!=matrixTStack) { - matrixTStack.clear(); matrixTStack=null; + matrixTStack=null; } } @@ -527,19 +528,18 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glLoadMatrixf(final float[] values, final int offset) { - int len = values.length-offset; if(matrixMode==GL_MODELVIEW) { - matrixMv.put(values, offset, len); + matrixMv.put(values, offset, 16); matrixMv.reset(); dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { - matrixP.put(values, offset, len); + matrixP.put(values, offset, 16); matrixP.reset(); dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { - matrixTex.put(values, offset, len); + matrixTex.put(values, offset, 16); matrixTex.reset(); modifiedBits |= MODIFIED_TEXTURE; } @@ -568,32 +568,31 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glPopMatrix() { - float[] stackEntry=null; + final FloatStack stack; if(matrixMode==GL_MODELVIEW) { - stackEntry = matrixMvStack.remove(0); + stack = matrixMvStack; } else if(matrixMode==GL_PROJECTION) { - stackEntry = matrixPStack.remove(0); + stack = matrixPStack; } else if(matrixMode==GL.GL_TEXTURE) { - stackEntry = matrixTStack.remove(0); - } - glLoadMatrixf(stackEntry, 0); + stack = matrixTStack; + } else { + throw new InternalError("XXX: mode "+matrixMode); + } + stack.position(stack.position() - 16); + glLoadMatrixf(stack.buffer(), stack.position()); } @Override public final void glPushMatrix() { - float[] stackEntry = new float[1*16]; - if(matrixMode==GL_MODELVIEW) { - matrixMv.get(stackEntry); - matrixMv.reset(); - matrixMvStack.add(0, stackEntry); + if(matrixMode==GL_MODELVIEW) { + matrixMvStack.putOnTop(matrixMv, 16); + matrixMv.reset(); } else if(matrixMode==GL_PROJECTION) { - matrixP.get(stackEntry); + matrixPStack.putOnTop(matrixP, 16); matrixP.reset(); - matrixPStack.add(0, stackEntry); } else if(matrixMode==GL.GL_TEXTURE) { - matrixTex.get(stackEntry); + matrixTStack.putOnTop(matrixTex, 16); matrixTex.reset(); - matrixTStack.add(0, stackEntry); } } @@ -1122,7 +1121,7 @@ public class PMVMatrix implements GLMatrixFunc { protected Buffer matrixBuffer; protected FloatBuffer matrixIdent, matrixPMvMvit, matrixPMvMvi, matrixPMv, matrixP, matrixTex, matrixMv, matrixMvi, matrixMvit; protected float[] matrixMult, matrixTrans, matrixRot, matrixScale, matrixOrtho, matrixFrustum, vec3f; - protected List matrixTStack, matrixPStack, matrixMvStack; + protected FloatStack matrixTStack, matrixPStack, matrixMvStack; protected int matrixMode = GL_MODELVIEW; protected int modifiedBits = MODIFIED_ALL; protected int dirtyBits = DIRTY_ALL; // contains the dirty bits, i.e. hinting for update operation -- cgit v1.2.3 From 921b33825340d27deec2883ded21cb7434decc94 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 31 Dec 2012 16:39:15 +0100 Subject: Update PNGJ 0.85 -> 1.12 (w/ interlace read support) ; Added PNG Interlace read tests (TestPNGTextureFromFileNEWT) --- LICENSE.txt | 2 +- make/scripts/tests.sh | 4 +- .../jogamp/opengl/util/pngj/FilterType.java | 49 +- .../opengl/util/pngj/FilterWriteStrategy.java | 4 +- .../classes/jogamp/opengl/util/pngj/ImageInfo.java | 38 +- .../classes/jogamp/opengl/util/pngj/ImageLine.java | 355 +++++--- .../jogamp/opengl/util/pngj/ImageLineHelper.java | 318 +++++++ .../jogamp/opengl/util/pngj/ImageLines.java | 101 +++ .../jogamp/opengl/util/pngj/PngDeinterlacer.java | 277 ++++++ .../classes/jogamp/opengl/util/pngj/PngHelper.java | 213 ----- .../jogamp/opengl/util/pngj/PngHelperInternal.java | 264 ++++++ .../opengl/util/pngj/PngIDatChunkInputStream.java | 63 +- .../opengl/util/pngj/PngIDatChunkOutputStream.java | 10 +- .../classes/jogamp/opengl/util/pngj/PngReader.java | 959 ++++++++++++++++----- .../classes/jogamp/opengl/util/pngj/PngWriter.java | 677 ++++++++++----- .../opengl/util/pngj/PngjExceptionInternal.java | 23 + .../opengl/util/pngj/ProgressiveOutputStream.java | 8 +- .../util/pngj/chunks/ChunkCopyBehaviour.java | 3 +- .../opengl/util/pngj/chunks/ChunkHelper.java | 151 +++- .../jogamp/opengl/util/pngj/chunks/ChunkList.java | 282 ------ .../util/pngj/chunks/ChunkLoadBehaviour.java | 27 +- .../opengl/util/pngj/chunks/ChunkPredicate.java | 14 + .../jogamp/opengl/util/pngj/chunks/ChunkRaw.java | 97 ++- .../jogamp/opengl/util/pngj/chunks/ChunksList.java | 174 ++++ .../util/pngj/chunks/ChunksListForWrite.java | 171 ++++ .../jogamp/opengl/util/pngj/chunks/PngChunk.java | 239 +++-- .../opengl/util/pngj/chunks/PngChunkBKGD.java | 44 +- .../opengl/util/pngj/chunks/PngChunkCHRM.java | 58 +- .../opengl/util/pngj/chunks/PngChunkGAMA.java | 30 +- .../opengl/util/pngj/chunks/PngChunkHIST.java | 32 +- .../opengl/util/pngj/chunks/PngChunkICCP.java | 35 +- .../opengl/util/pngj/chunks/PngChunkIDAT.java | 28 +- .../opengl/util/pngj/chunks/PngChunkIEND.java | 20 +- .../opengl/util/pngj/chunks/PngChunkIHDR.java | 41 +- .../opengl/util/pngj/chunks/PngChunkITXT.java | 36 +- .../opengl/util/pngj/chunks/PngChunkMultiple.java | 27 + .../opengl/util/pngj/chunks/PngChunkOFFS.java | 89 ++ .../opengl/util/pngj/chunks/PngChunkPHYS.java | 30 +- .../opengl/util/pngj/chunks/PngChunkPLTE.java | 23 +- .../opengl/util/pngj/chunks/PngChunkSBIT.java | 40 +- .../opengl/util/pngj/chunks/PngChunkSPLT.java | 55 +- .../opengl/util/pngj/chunks/PngChunkSRGB.java | 28 +- .../opengl/util/pngj/chunks/PngChunkSTER.java | 60 ++ .../opengl/util/pngj/chunks/PngChunkSingle.java | 43 + .../opengl/util/pngj/chunks/PngChunkSkipped.java | 41 + .../opengl/util/pngj/chunks/PngChunkTEXT.java | 32 +- .../opengl/util/pngj/chunks/PngChunkTIME.java | 38 +- .../opengl/util/pngj/chunks/PngChunkTRNS.java | 60 +- .../opengl/util/pngj/chunks/PngChunkTextVar.java | 10 +- .../opengl/util/pngj/chunks/PngChunkUNKNOWN.java | 21 +- .../opengl/util/pngj/chunks/PngChunkZTXT.java | 28 +- .../opengl/util/pngj/chunks/PngMetadata.java | 198 +++-- .../classes/jogamp/opengl/util/pngj/package.html | 5 +- .../util/texture/TestPNGTextureFromFileAWT.java | 10 +- .../util/texture/TestPNGTextureFromFileNEWT.java | 56 +- .../jogl/util/texture/test-ntscI01-160x90.png | Bin 0 -> 3729 bytes .../jogl/util/texture/test-ntscIG01-160x90.png | Bin 0 -> 3745 bytes .../jogl/util/texture/test-ntscN01-160x90.png | Bin 0 -> 2785 bytes 58 files changed, 4115 insertions(+), 1626 deletions(-) create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/PngDeinterlacer.java delete mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/PngHelper.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java delete mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkList.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkPredicate.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkOFFS.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSTER.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java create mode 100644 src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSkipped.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscI01-160x90.png create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscIG01-160x90.png create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscN01-160x90.png (limited to 'make/scripts') diff --git a/LICENSE.txt b/LICENSE.txt index 3550ab282..04e046de4 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -344,7 +344,7 @@ A.6) The JOGL source tree contains code from Hernan J. Gonzalez and Shawn Hartso PNGJ: Java library for reading and writing PNG images. - Version 0.85 (1 April 2012) + Version 1.12 (3 Dec 2012) diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a235643f6..f253ed1e2 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -260,7 +260,7 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -455,7 +455,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java b/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java index a34f73ab2..e88a95a33 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/FilterType.java @@ -30,17 +30,22 @@ public enum FilterType { */ FILTER_DEFAULT(-1), /** - * Aggresive strategy: select one of the above filters trying each of the filters (this is done every 8 rows) + * Aggressive strategy: select one of the above filters trying each of the filters (every 8 rows) */ FILTER_AGGRESSIVE(-2), + /** + * Very aggressive strategy: select one of the above filters trying each of the filters (for every row!) + */ + FILTER_VERYAGGRESSIVE(-3), /** * Uses all fiters, one for lines, cyciclally. Only for tests. */ - FILTER_ALTERNATE(-3), + FILTER_CYCLIC(-50), + /** - * Aggresive strategy: select one of the above filters trying each of the filters (this is done for every row!) + * Not specified, placeholder for unknown or NA filters. */ - FILTER_VERYAGGRESSIVE(-4), ; + FILTER_UNKNOWN(-100), ; public final int val; private FilterType(int val) { @@ -55,40 +60,4 @@ public enum FilterType { return null; } - public static int unfilterRowNone(int r) { - return (int) (r & 0xFF); - } - - public static int unfilterRowSub(int r, int left) { - return ((int) (r + left) & 0xFF); - } - - public static int unfilterRowUp(int r, int up) { - return ((int) (r + up) & 0xFF); - } - - public static int unfilterRowAverage(int r, int left, int up) { - return (r + (left + up) / 2) & 0xFF; - } - - public static int unfilterRowPaeth(int r, int a, int b, int c) { // a = left, b = above, c = upper left - return (r + filterPaethPredictor(a, b, c)) & 0xFF; - } - - public static int filterPaethPredictor(int a, int b, int c) { - // from http://www.libpng.org/pub/png/spec/1.2/PNG-Filters.html - // a = left, b = above, c = upper left - final int p = a + b - c;// ; initial estimate - final int pa = p >= a ? p - a : a - p; - final int pb = p >= b ? p - b : b - p; - final int pc = p >= c ? p - c : c - p; - // ; return nearest of a,b,c, - // ; breaking ties in order a,b,c. - if (pa <= pb && pa <= pc) - return a; - else if (pb <= pc) - return b; - else - return c; - } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/FilterWriteStrategy.java b/src/jogl/classes/jogamp/opengl/util/pngj/FilterWriteStrategy.java index 27586b292..79eed8f85 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/FilterWriteStrategy.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/FilterWriteStrategy.java @@ -1,7 +1,7 @@ package jogamp.opengl.util.pngj; /** - * Manages the writer strategy for selecting the internal png "filter" + * Manages the writer strategy for selecting the internal png predictor filter */ class FilterWriteStrategy { private static final int COMPUTE_STATS_EVERY_N_LINES = 8; @@ -89,7 +89,7 @@ class FilterWriteStrategy { } } } - if (configuredType == FilterType.FILTER_ALTERNATE) { + if (configuredType == FilterType.FILTER_CYCLIC) { currentType = FilterType.getByVal((currentType.val + 1) % 5); } return currentType; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java index 2f6b89e9c..26562ef3e 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageInfo.java @@ -13,12 +13,12 @@ public class ImageInfo { private static final int MAX_COLS_ROWS_VAL = 1000000; /** - * Image width, in pixels. + * Cols= Image width, in pixels. */ public final int cols; /** - * Image height, in pixels + * Rows= Image height, in pixels */ public final int rows; @@ -29,8 +29,8 @@ public class ImageInfo { public final int bitDepth; /** - * Number of channels, as used internally. This is 3 for RGB, 4 for RGBA, 2 for GA (gray with alpha), 1 for - * grayscales or indexed. + * Number of channels, as used internally: 3 for RGB, 4 for RGBA, 2 for GA (gray with alpha), 1 for grayscale or + * indexed. */ public final int channels; @@ -75,10 +75,14 @@ public class ImageInfo { public final int samplesPerRow; /** - * For internal use only. Samples available for our packed scanline. Equals samplesPerRow if not packed. Elsewhere, - * it's lower + * Amount of "packed samples" : when several samples are stored in a single byte (bitdepth 1,2 4) they are counted + * as one "packed sample". This is less that samplesPerRow only when bitdepth is 1-2-4 (flag packed = true) + *

        + * This equals the number of elements in the scanline array if working with packedMode=true + *

        + * For internal use, client code should rarely access this. */ - final int samplesPerRowP; + public final int samplesPerRowPacked; /** * Short constructor: assumes truecolor (RGB/RGBA) @@ -119,7 +123,7 @@ public class ImageInfo { this.bytesPixel = (bitspPixel + 7) / 8; this.bytesPerRow = (bitspPixel * cols + 7) / 8; this.samplesPerRow = channels * this.cols; - this.samplesPerRowP = packed ? bytesPerRow : samplesPerRow; + this.samplesPerRowPacked = packed ? bytesPerRow : samplesPerRow; // several checks switch (this.bitDepth) { case 1: @@ -147,7 +151,7 @@ public class ImageInfo { public String toString() { return "ImageInfo [cols=" + cols + ", rows=" + rows + ", bitDepth=" + bitDepth + ", channels=" + channels + ", bitspPixel=" + bitspPixel + ", bytesPixel=" + bytesPixel + ", bytesPerRow=" + bytesPerRow - + ", samplesPerRow=" + samplesPerRow + ", samplesPerRowP=" + samplesPerRowP + ", alpha=" + alpha + + ", samplesPerRow=" + samplesPerRow + ", samplesPerRowP=" + samplesPerRowPacked + ", alpha=" + alpha + ", greyscale=" + greyscale + ", indexed=" + indexed + ", packed=" + packed + "]"; } @@ -157,16 +161,11 @@ public class ImageInfo { int result = 1; result = prime * result + (alpha ? 1231 : 1237); result = prime * result + bitDepth; - result = prime * result + bitspPixel; - result = prime * result + bytesPerRow; - result = prime * result + bytesPixel; result = prime * result + channels; result = prime * result + cols; result = prime * result + (greyscale ? 1231 : 1237); result = prime * result + (indexed ? 1231 : 1237); - result = prime * result + (packed ? 1231 : 1237); result = prime * result + rows; - result = prime * result + samplesPerRow; return result; } @@ -183,12 +182,6 @@ public class ImageInfo { return false; if (bitDepth != other.bitDepth) return false; - if (bitspPixel != other.bitspPixel) - return false; - if (bytesPerRow != other.bytesPerRow) - return false; - if (bytesPixel != other.bytesPixel) - return false; if (channels != other.channels) return false; if (cols != other.cols) @@ -197,12 +190,9 @@ public class ImageInfo { return false; if (indexed != other.indexed) return false; - if (packed != other.packed) - return false; if (rows != other.rows) return false; - if (samplesPerRow != other.samplesPerRow) - return false; return true; } + } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java index bfbb35b7c..9f8a13230 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLine.java @@ -1,6 +1,6 @@ package jogamp.opengl.util.pngj; -import java.util.Arrays; +import jogamp.opengl.util.pngj.ImageLineHelper.ImageLineStats; /** * Lightweight wrapper for an image scanline, used for read and write. @@ -20,26 +20,87 @@ public class ImageLine { /** * The 'scanline' is an array of integers, corresponds to an image line (row). *

        - * Except for 'packed' formats (gray/indexed with 1-2-4 bitdepth) each int is a "sample" (one for channel), (0-255 - * or 0-65535) in the respective PNG sequence sequence : (R G B R G B...) or (R G B A R G B A...) or (g g g ...) or - * ( i i i) (palette index) + * Except for 'packed' formats (gray/indexed with 1-2-4 bitdepth) each int is a "sample" (one for + * channel), (0-255 or 0-65535) in the corresponding PNG sequence: R G B R G B... or + * R G B A R G B A... + * or g g g ... or i i i (palette index) *

        - * For bitdepth 1/2/4 , each element is a PACKED byte! To get an unpacked copy, see tf_pack() and its - * inverse tf_unpack() + * For bitdepth=1/2/4 , and if samplesUnpacked=false, each value is a PACKED byte! *

        - * To convert a indexed line to RGB balues, see ImageLineHelper.tf_palIdx2RGB() (can't do the reverse) + * To convert a indexed line to RGB balues, see ImageLineHelper.palIdx2RGB() (you can't do the reverse) */ - public final int[] scanline; // see explanation above!! + public final int[] scanline; + /** + * Same as {@link #scanline}, but with one byte per sample. Only one of scanline and scanlineb is valid - this + * depends on {@link #sampleType} + */ + public final byte[] scanlineb; protected FilterType filterUsed; // informational ; only filled by the reader - public final int channels; // copied from imgInfo, more handy - public final int bitDepth; // copied from imgInfo, more handy + final int channels; // copied from imgInfo, more handy + final int bitDepth; // copied from imgInfo, more handy + final int elementsPerRow; // = imgInfo.samplePerRowPacked, if packed:imgInfo.samplePerRow elswhere + + public enum SampleType { + INT, // 4 bytes per sample + // SHORT, // 2 bytes per sample + BYTE // 1 byte per sample + } + + /** + * tells if we are using BYTE or INT to store the samples. + */ + public final SampleType sampleType; + + /** + * true: each element of the scanline array represents a sample always, even for internally packed PNG formats + * + * false: if the original image was of packed type (bit depth less than 8) we keep samples packed in a single array + * element + */ + public final boolean samplesUnpacked; + /** + * default mode: INT packed + */ public ImageLine(ImageInfo imgInfo) { + this(imgInfo, SampleType.INT, false); + } + + /** + * + * @param imgInfo + * Inmutable ImageInfo, basic parameter of the image we are reading or writing + * @param stype + * INT or BYTE : this determines which scanline is the really used one + * @param unpackedMode + * If true, we use unpacked format, even for packed original images + * + */ + public ImageLine(ImageInfo imgInfo, SampleType stype, boolean unpackedMode) { + this(imgInfo, stype, unpackedMode, null, null); + } + + /** + * If a preallocated array is passed, the copy is shallow + */ + ImageLine(ImageInfo imgInfo, SampleType stype, boolean unpackedMode, int[] sci, byte[] scb) { this.imgInfo = imgInfo; channels = imgInfo.channels; - scanline = new int[imgInfo.samplesPerRowP]; - this.bitDepth = imgInfo.bitDepth; + bitDepth = imgInfo.bitDepth; + filterUsed = FilterType.FILTER_UNKNOWN; + this.sampleType = stype; + this.samplesUnpacked = unpackedMode || !imgInfo.packed; + elementsPerRow = this.samplesUnpacked ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked; + if (stype == SampleType.INT) { + scanline = sci != null ? sci : new int[elementsPerRow]; + scanlineb = null; + } else if (stype == SampleType.BYTE) { + scanlineb = scb != null ? scb : new byte[elementsPerRow]; + scanline = null; + } else + throw new PngjExceptionInternal("bad ImageLine initialization"); + this.rown = -1; } /** This row number inside the image (0 is top) */ @@ -47,129 +108,213 @@ public class ImageLine { return rown; } - /** Increments row number */ - public void incRown() { - this.rown++; - } - - /** Sets row number */ + /** Sets row number (0 : Rows-1) */ public void setRown(int n) { this.rown = n; } - /** Sets scanline, making copy from passed array */ - public void setScanLine(int[] b) { - System.arraycopy(b, 0, scanline, 0, scanline.length); + /* + * Unpacks scanline (for bitdepth 1-2-4) + * + * Arrays must be prealocated. src : samplesPerRowPacked dst : samplesPerRow + * + * This usually works in place (with src==dst and length=samplesPerRow)! + * + * If not, you should only call this only when necesary (bitdepth <8) + * + * If scale==true, it scales the value (just a bit shift) towards 0-255. + */ + static void unpackInplaceInt(final ImageInfo iminfo, final int[] src, final int[] dst, final boolean scale) { + final int bitDepth = iminfo.bitDepth; + if (bitDepth >= 8) + return; // nothing to do + final int mask0 = ImageLineHelper.getMaskForPackedFormatsLs(bitDepth); + final int scalefactor = 8 - bitDepth; + final int offset0 = 8 * iminfo.samplesPerRowPacked - bitDepth * iminfo.samplesPerRow; + int mask, offset, v; + if (offset0 != 8) { + mask = mask0 << offset0; + offset = offset0; // how many bits to shift the mask to the right to recover mask0 + } else { + mask = mask0; + offset = 0; + } + for (int j = iminfo.samplesPerRow - 1, i = iminfo.samplesPerRowPacked - 1; j >= 0; j--) { + v = (src[i] & mask) >> offset; + if (scale) + v <<= scalefactor; + dst[j] = v; + mask <<= bitDepth; + offset += bitDepth; + if (offset == 8) { + mask = mask0; + offset = 0; + i--; + } + } } - /** - * Returns a copy from scanline, in byte array. + /* + * Unpacks scanline (for bitdepth 1-2-4) * - * You can (OPTIONALLY) pass an preallocated array to use. - **/ - public int[] getScanLineCopy(int[] b) { - if (b == null || b.length < scanline.length) - b = new int[scanline.length]; - System.arraycopy(scanline, 0, b, 0, scanline.length); - return b; + * Arrays must be prealocated. src : samplesPerRow dst : samplesPerRowPacked + * + * This usually works in place (with src==dst and length=samplesPerRow)! If not, you should only call this only when + * necesary (bitdepth <8) + * + * The trailing elements are trash + * + * + * If scale==true, it scales the value (just a bit shift) towards 0-255. + */ + static void packInplaceInt(final ImageInfo iminfo, final int[] src, final int[] dst, final boolean scaled) { + final int bitDepth = iminfo.bitDepth; + if (bitDepth >= 8) + return; // nothing to do + final int mask0 = ImageLineHelper.getMaskForPackedFormatsLs(bitDepth); + final int scalefactor = 8 - bitDepth; + final int offset0 = 8 - bitDepth; + int v, v0; + int offset = 8 - bitDepth; + v0 = src[0]; // first value is special for in place + dst[0] = 0; + if (scaled) + v0 >>= scalefactor; + v0 = ((v0 & mask0) << offset); + for (int i = 0, j = 0; j < iminfo.samplesPerRow; j++) { + v = src[j]; + if (scaled) + v >>= scalefactor; + dst[i] |= ((v & mask0) << offset); + offset -= bitDepth; + if (offset < 0) { + offset = offset0; + i++; + dst[i] = 0; + } + } + dst[0] |= v0; } - /** - * Unpacks scanline (for bitdepth 1-2-4) into buffer. - *

        - * You can (OPTIONALLY) pass an preallocated array to use. - *

        - * If scale==TRUE scales the value (just a bit shift). - */ - public int[] tf_unpack(int[] buf, boolean scale) { - int len = scanline.length; - if (bitDepth == 1) - len *= 8; - else if (bitDepth == 2) - len *= 4; - else if (bitDepth == 4) - len *= 2; - if (buf == null) - buf = new int[len]; + static void unpackInplaceByte(final ImageInfo iminfo, final byte[] src, final byte[] dst, final boolean scale) { + final int bitDepth = iminfo.bitDepth; if (bitDepth >= 8) - System.arraycopy(scanline, 0, buf, 0, scanline.length); - else { - int mask, offset, v; - int mask0 = getMaskForPackedFormats(); - int offset0 = 8 - bitDepth; + return; // nothing to do + final int mask0 = ImageLineHelper.getMaskForPackedFormatsLs(bitDepth); + final int scalefactor = 8 - bitDepth; + final int offset0 = 8 * iminfo.samplesPerRowPacked - bitDepth * iminfo.samplesPerRow; + int mask, offset, v; + if (offset0 != 8) { + mask = mask0 << offset0; + offset = offset0; // how many bits to shift the mask to the right to recover mask0 + } else { mask = mask0; - offset = offset0; - for (int i = 0, j = 0; i < len; i++) { - v = (scanline[j] & mask) >> offset; - if (scale) - v <<= offset0; - buf[i] = v; - mask = mask >> bitDepth; - offset -= bitDepth; - if (mask == 0) { // new byte in source - mask = mask0; - offset = offset0; - j++; - } + offset = 0; + } + for (int j = iminfo.samplesPerRow - 1, i = iminfo.samplesPerRowPacked - 1; j >= 0; j--) { + v = (src[i] & mask) >> offset; + if (scale) + v <<= scalefactor; + dst[j] = (byte) v; + mask <<= bitDepth; + offset += bitDepth; + if (offset == 8) { + mask = mask0; + offset = 0; + i--; } } - return buf; } - /** - * Packs scanline (for bitdepth 1-2-4) from buffer. - *

        - * If scale==TRUE scales the value (just a bit shift). - */ - public void tf_pack(int[] buf, boolean scale) { // writes scanline - int len = scanline.length; - if (bitDepth == 1) - len *= 8; - else if (bitDepth == 2) - len *= 4; - else if (bitDepth == 4) - len *= 2; + /** size original: samplesPerRow sizeFinal: samplesPerRowPacked (trailing elements are trash!) **/ + static void packInplaceByte(final ImageInfo iminfo, final byte[] src, final byte[] dst, final boolean scaled) { + final int bitDepth = iminfo.bitDepth; if (bitDepth >= 8) - System.arraycopy(buf, 0, scanline, 0, scanline.length); - else { - int offset0 = 8 - bitDepth; - int mask0 = getMaskForPackedFormats() >> offset0; - int offset, v; - offset = offset0; - Arrays.fill(scanline, 0); - for (int i = 0, j = 0; i < len; i++) { - v = buf[i]; - if (scale) - v >>= offset0; - v = (v & mask0) << offset; - scanline[j] |= v; - offset -= bitDepth; - if (offset < 0) { // new byte in scanline - offset = offset0; - j++; - } + return; // nothing to do + final int mask0 = ImageLineHelper.getMaskForPackedFormatsLs(bitDepth); + final int scalefactor = 8 - bitDepth; + final int offset0 = 8 - bitDepth; + int v, v0; + int offset = 8 - bitDepth; + v0 = src[0]; // first value is special + dst[0] = 0; + if (scaled) + v0 >>= scalefactor; + v0 = ((v0 & mask0) << offset); + for (int i = 0, j = 0; j < iminfo.samplesPerRow; j++) { + v = src[j]; + if (scaled) + v >>= scalefactor; + dst[i] |= ((v & mask0) << offset); + offset -= bitDepth; + if (offset < 0) { + offset = offset0; + i++; + dst[i] = 0; } } + dst[0] |= v0; } - private int getMaskForPackedFormats() { // Utility function for pacj/unpack - if (bitDepth == 1) - return 0x80; - if (bitDepth == 2) - return 0xc0; - if (bitDepth == 4) - return 0xf0; - throw new RuntimeException("?"); + /** + * Creates a new ImageLine similar to this, but unpacked + * + * The caller must be sure that the original was really packed + */ + public ImageLine unpackToNewImageLine() { + ImageLine newline = new ImageLine(imgInfo, sampleType, true); + if (sampleType == SampleType.INT) + unpackInplaceInt(imgInfo, scanline, newline.scanline, false); + else + unpackInplaceByte(imgInfo, scanlineb, newline.scanlineb, false); + return newline; + } + + /** + * Creates a new ImageLine similar to this, but packed + * + * The caller must be sure that the original was really unpacked + */ + public ImageLine packToNewImageLine() { + ImageLine newline = new ImageLine(imgInfo, sampleType, false); + if (sampleType == SampleType.INT) + packInplaceInt(imgInfo, scanline, newline.scanline, false); + else + packInplaceByte(imgInfo, scanlineb, newline.scanlineb, false); + return newline; } public FilterType getFilterUsed() { return filterUsed; } + public void setFilterUsed(FilterType ft) { + filterUsed = ft; + } + + public int[] getScanlineInt() { + return scanline; + } + + public byte[] getScanlineByte() { + return scanlineb; + } + /** * Basic info */ public String toString() { return "row=" + rown + " cols=" + imgInfo.cols + " bpc=" + imgInfo.bitDepth + " size=" + scanline.length; } + + /** + * Prints some statistics - just for debugging + */ + public static void showLineInfo(ImageLine line) { + System.out.println(line); + ImageLineStats stats = new ImageLineHelper.ImageLineStats(line); + System.out.println(stats); + System.out.println(ImageLineHelper.infoFirstLastPixels(line)); + } + } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java new file mode 100644 index 000000000..98f235662 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLineHelper.java @@ -0,0 +1,318 @@ +package jogamp.opengl.util.pngj; + +import jogamp.opengl.util.pngj.ImageLine.SampleType; +import jogamp.opengl.util.pngj.chunks.PngChunkPLTE; +import jogamp.opengl.util.pngj.chunks.PngChunkTRNS; + +/** + * Bunch of utility static methods to process/analyze an image line at the pixel level. + *

        + * Not essential at all, some methods are probably to be removed if future releases. + *

        + * WARNING: most methods for getting/setting values work currently only for integer base imageLines + */ +public class ImageLineHelper { + + private final static double BIG_VALUE = Double.MAX_VALUE * 0.5; + + private final static double BIG_VALUE_NEG = Double.MAX_VALUE * (-0.5); + + /** + * Given an indexed line with a palette, unpacks as a RGB array, or RGBA if a non nul PngChunkTRNS chunk is passed + * + * @param line + * ImageLine as returned from PngReader + * @param pal + * Palette chunk + * @param buf + * Preallocated array, optional + * @return R G B (A), one sample 0-255 per array element. Ready for pngw.writeRowInt() + */ + public static int[] palette2rgb(ImageLine line, PngChunkPLTE pal, PngChunkTRNS trns, int[] buf) { + boolean isalpha = trns != null; + int channels = isalpha ? 4 : 3; + int nsamples = line.imgInfo.cols * channels; + if (buf == null || buf.length < nsamples) + buf = new int[nsamples]; + if (!line.samplesUnpacked) + line = line.unpackToNewImageLine(); + boolean isbyte = line.sampleType == SampleType.BYTE; + int nindexesWithAlpha = trns != null ? trns.getPalletteAlpha().length : 0; + for (int c = 0; c < line.imgInfo.cols; c++) { + int index = isbyte ? (line.scanlineb[c] & 0xFF) : line.scanline[c]; + pal.getEntryRgb(index, buf, c * channels); + if (isalpha) { + int alpha = index < nindexesWithAlpha ? trns.getPalletteAlpha()[index] : 255; + buf[c * channels + 3] = alpha; + } + } + return buf; + } + + public static int[] palette2rgb(ImageLine line, PngChunkPLTE pal, int[] buf) { + return palette2rgb(line, pal, null, buf); + } + + /** what follows is pretty uninteresting/untested/obsolete, subject to change */ + /** + * Just for basic info or debugging. Shows values for first and last pixel. Does not include alpha + */ + public static String infoFirstLastPixels(ImageLine line) { + return line.imgInfo.channels == 1 ? String.format("first=(%d) last=(%d)", line.scanline[0], + line.scanline[line.scanline.length - 1]) : String.format("first=(%d %d %d) last=(%d %d %d)", + line.scanline[0], line.scanline[1], line.scanline[2], line.scanline[line.scanline.length + - line.imgInfo.channels], line.scanline[line.scanline.length - line.imgInfo.channels + 1], + line.scanline[line.scanline.length - line.imgInfo.channels + 2]); + } + + public static String infoFull(ImageLine line) { + ImageLineStats stats = new ImageLineStats(line); + return "row=" + line.getRown() + " " + stats.toString() + "\n " + infoFirstLastPixels(line); + } + + /** + * Computes some statistics for the line. Not very efficient or elegant, mainly for tests. Only for RGB/RGBA Outputs + * values as doubles (0.0 - 1.0) + */ + static class ImageLineStats { + public double[] prom = { 0.0, 0.0, 0.0, 0.0 }; // channel averages + public double[] maxv = { BIG_VALUE_NEG, BIG_VALUE_NEG, BIG_VALUE_NEG, BIG_VALUE_NEG }; // maximo + public double[] minv = { BIG_VALUE, BIG_VALUE, BIG_VALUE, BIG_VALUE }; + public double promlum = 0.0; // maximum global (luminance) + public double maxlum = BIG_VALUE_NEG; // max luminance + public double minlum = BIG_VALUE; + public double[] maxdif = { BIG_VALUE_NEG, BIG_VALUE_NEG, BIG_VALUE_NEG, BIG_VALUE }; // maxima + public final int channels; // diferencia + + public String toString() { + return channels == 3 ? String.format( + "prom=%.1f (%.1f %.1f %.1f) max=%.1f (%.1f %.1f %.1f) min=%.1f (%.1f %.1f %.1f)", promlum, prom[0], + prom[1], prom[2], maxlum, maxv[0], maxv[1], maxv[2], minlum, minv[0], minv[1], minv[2]) + + String.format(" maxdif=(%.1f %.1f %.1f)", maxdif[0], maxdif[1], maxdif[2]) : String.format( + "prom=%.1f (%.1f %.1f %.1f %.1f) max=%.1f (%.1f %.1f %.1f %.1f) min=%.1f (%.1f %.1f %.1f %.1f)", + promlum, prom[0], prom[1], prom[2], prom[3], maxlum, maxv[0], maxv[1], maxv[2], maxv[3], minlum, + minv[0], minv[1], minv[2], minv[3]) + + String.format(" maxdif=(%.1f %.1f %.1f %.1f)", maxdif[0], maxdif[1], maxdif[2], maxdif[3]); + } + + public ImageLineStats(ImageLine line) { + this.channels = line.channels; + if (line.channels < 3) + throw new PngjException("ImageLineStats only works for RGB - RGBA"); + int ch = 0; + double lum, x, d; + for (int i = 0; i < line.imgInfo.cols; i++) { + lum = 0; + for (ch = channels - 1; ch >= 0; ch--) { + x = int2double(line, line.scanline[i * channels]); + if (ch < 3) + lum += x; + prom[ch] += x; + if (x > maxv[ch]) + maxv[ch] = x; + if (x < minv[ch]) + minv[ch] = x; + if (i >= channels) { + d = Math.abs(x - int2double(line, line.scanline[i - channels])); + if (d > maxdif[ch]) + maxdif[ch] = d; + } + } + promlum += lum; + if (lum > maxlum) + maxlum = lum; + if (lum < minlum) + minlum = lum; + } + for (ch = 0; ch < channels; ch++) { + prom[ch] /= line.imgInfo.cols; + } + promlum /= (line.imgInfo.cols * 3.0); + maxlum /= 3.0; + minlum /= 3.0; + } + } + + /** + * integer packed R G B only for bitdepth=8! (does not check!) + * + **/ + public static int getPixelRGB8(ImageLine line, int column) { + int offset = column * line.channels; + return (line.scanline[offset] << 16) + (line.scanline[offset + 1] << 8) + (line.scanline[offset + 2]); + } + + public static int getPixelARGB8(ImageLine line, int column) { + int offset = column * line.channels; + return (line.scanline[offset + 3] << 24) + (line.scanline[offset] << 16) + (line.scanline[offset + 1] << 8) + + (line.scanline[offset + 2]); + } + + public static void setPixelsRGB8(ImageLine line, int[] rgb) { + for (int i = 0, j = 0; i < line.imgInfo.cols; i++) { + line.scanline[j++] = ((rgb[i] >> 16) & 0xFF); + line.scanline[j++] = ((rgb[i] >> 8) & 0xFF); + line.scanline[j++] = ((rgb[i] & 0xFF)); + } + } + + public static void setPixelRGB8(ImageLine line, int col, int r, int g, int b) { + col *= line.channels; + line.scanline[col++] = r; + line.scanline[col++] = g; + line.scanline[col] = b; + } + + public static void setPixelRGB8(ImageLine line, int col, int rgb) { + setPixelRGB8(line, col, (rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF); + } + + public static void setPixelsRGBA8(ImageLine line, int[] rgb) { + for (int i = 0, j = 0; i < line.imgInfo.cols; i++) { + line.scanline[j++] = ((rgb[i] >> 16) & 0xFF); + line.scanline[j++] = ((rgb[i] >> 8) & 0xFF); + line.scanline[j++] = ((rgb[i] & 0xFF)); + line.scanline[j++] = ((rgb[i] >> 24) & 0xFF); + } + } + + public static void setPixelRGBA8(ImageLine line, int col, int r, int g, int b, int a) { + col *= line.channels; + line.scanline[col++] = r; + line.scanline[col++] = g; + line.scanline[col++] = b; + line.scanline[col] = a; + } + + public static void setPixelRGBA8(ImageLine line, int col, int rgb) { + setPixelRGBA8(line, col, (rgb >> 16) & 0xFF, (rgb >> 8) & 0xFF, rgb & 0xFF, (rgb >> 24) & 0xFF); + } + + public static void setValD(ImageLine line, int i, double d) { + line.scanline[i] = double2int(line, d); + } + + public static int interpol(int a, int b, int c, int d, double dx, double dy) { + // a b -> x (0-1) + // c d + // + double e = a * (1.0 - dx) + b * dx; + double f = c * (1.0 - dx) + d * dx; + return (int) (e * (1 - dy) + f * dy + 0.5); + } + + public static double int2double(ImageLine line, int p) { + return line.bitDepth == 16 ? p / 65535.0 : p / 255.0; + // TODO: replace my multiplication? check for other bitdepths + } + + public static double int2doubleClamped(ImageLine line, int p) { + // TODO: replace my multiplication? + double d = line.bitDepth == 16 ? p / 65535.0 : p / 255.0; + return d <= 0.0 ? 0 : (d >= 1.0 ? 1.0 : d); + } + + public static int double2int(ImageLine line, double d) { + d = d <= 0.0 ? 0 : (d >= 1.0 ? 1.0 : d); + return line.bitDepth == 16 ? (int) (d * 65535.0 + 0.5) : (int) (d * 255.0 + 0.5); // + } + + public static int double2intClamped(ImageLine line, double d) { + d = d <= 0.0 ? 0 : (d >= 1.0 ? 1.0 : d); + return line.bitDepth == 16 ? (int) (d * 65535.0 + 0.5) : (int) (d * 255.0 + 0.5); // + } + + public static int clampTo_0_255(int i) { + return i > 255 ? 255 : (i < 0 ? 0 : i); + } + + public static int clampTo_0_65535(int i) { + return i > 65535 ? 65535 : (i < 0 ? 0 : i); + } + + public static int clampTo_128_127(int x) { + return x > 127 ? 127 : (x < -128 ? -128 : x); + } + + /** + * Unpacks scanline (for bitdepth 1-2-4) into a array int[] + *

        + * You can (OPTIONALLY) pass an preallocated array, that will be filled and returned. If null, it will be allocated + *

        + * If scale==true, it scales the value (just a bit shift) towards 0-255. + *

        + * You probably should use {@link ImageLine#unpackToNewImageLine()} + * + */ + public static int[] unpack(ImageInfo imgInfo, int[] src, int[] dst, boolean scale) { + int len1 = imgInfo.samplesPerRow; + int len0 = imgInfo.samplesPerRowPacked; + if (dst == null || dst.length < len1) + dst = new int[len1]; + if (imgInfo.packed) + ImageLine.unpackInplaceInt(imgInfo, src, dst, scale); + else + System.arraycopy(src, 0, dst, 0, len0); + return dst; + } + + public static byte[] unpack(ImageInfo imgInfo, byte[] src, byte[] dst, boolean scale) { + int len1 = imgInfo.samplesPerRow; + int len0 = imgInfo.samplesPerRowPacked; + if (dst == null || dst.length < len1) + dst = new byte[len1]; + if (imgInfo.packed) + ImageLine.unpackInplaceByte(imgInfo, src, dst, scale); + else + System.arraycopy(src, 0, dst, 0, len0); + return dst; + } + + /** + * Packs scanline (for bitdepth 1-2-4) from array into the scanline + *

        + * If scale==true, it scales the value (just a bit shift). + * + * You probably should use {@link ImageLine#packToNewImageLine()} + */ + public static int[] pack(ImageInfo imgInfo, int[] src, int[] dst, boolean scale) { + int len0 = imgInfo.samplesPerRowPacked; + if (dst == null || dst.length < len0) + dst = new int[len0]; + if (imgInfo.packed) + ImageLine.packInplaceInt(imgInfo, src, dst, scale); + else + System.arraycopy(src, 0, dst, 0, len0); + return dst; + } + + public static byte[] pack(ImageInfo imgInfo, byte[] src, byte[] dst, boolean scale) { + int len0 = imgInfo.samplesPerRowPacked; + if (dst == null || dst.length < len0) + dst = new byte[len0]; + if (imgInfo.packed) + ImageLine.packInplaceByte(imgInfo, src, dst, scale); + else + System.arraycopy(src, 0, dst, 0, len0); + return dst; + } + + static int getMaskForPackedFormats(int bitDepth) { // Utility function for pack/unpack + if (bitDepth == 4) + return 0xf0; + else if (bitDepth == 2) + return 0xc0; + else + return 0x80; // bitDepth == 1 + } + + static int getMaskForPackedFormatsLs(int bitDepth) { // Utility function for pack/unpack + if (bitDepth == 4) + return 0x0f; + else if (bitDepth == 2) + return 0x03; + else + return 0x01; // bitDepth == 1 + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java new file mode 100644 index 000000000..1e0ab746a --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ImageLines.java @@ -0,0 +1,101 @@ +package jogamp.opengl.util.pngj; + +import jogamp.opengl.util.pngj.ImageLine.SampleType; + +/** + * Wraps in a matrix a set of image rows, not necessarily contiguous - but equispaced. + * + * The fields mirrors those of {@link ImageLine}, and you can access each row as a ImageLine backed by the matrix row, + * see {@link #getImageLineAtMatrixRow(int)} + */ +public class ImageLines { + + public final ImageInfo imgInfo; + public final int channels; + public final int bitDepth; + public final SampleType sampleType; + public final boolean samplesUnpacked; + public final int elementsPerRow; + public final int rowOffset; + public final int nRows; + public final int rowStep; + public final int[][] scanlines; + public final byte[][] scanlinesb; + + /** + * Allocates a matrix to store {@code nRows} image rows. See {@link ImageLine} and {@link PngReader#readRowsInt()} + * {@link PngReader#readRowsByte()} + * + * @param imgInfo + * @param stype + * @param unpackedMode + * @param rowOffset + * @param nRows + * @param rowStep + */ + public ImageLines(ImageInfo imgInfo, SampleType stype, boolean unpackedMode, int rowOffset, int nRows, int rowStep) { + this.imgInfo = imgInfo; + channels = imgInfo.channels; + bitDepth = imgInfo.bitDepth; + this.sampleType = stype; + this.samplesUnpacked = unpackedMode || !imgInfo.packed; + elementsPerRow = unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked; + this.rowOffset = rowOffset; + this.nRows = nRows; + this.rowStep = rowStep; + if (stype == SampleType.INT) { + scanlines = new int[nRows][elementsPerRow]; + scanlinesb = null; + } else if (stype == SampleType.BYTE) { + scanlinesb = new byte[nRows][elementsPerRow]; + scanlines = null; + } else + throw new PngjExceptionInternal("bad ImageLine initialization"); + } + + /** + * Warning: this always returns a valid matrix row (clamping on 0 : nrows-1, and rounding down) Eg: + * rowOffset=4,rowStep=2 imageRowToMatrixRow(17) returns 6 , imageRowToMatrixRow(1) returns 0 + */ + public int imageRowToMatrixRow(int imrow) { + int r = (imrow - rowOffset) / rowStep; + return r < 0 ? 0 : (r < nRows ? r : nRows - 1); + } + + /** + * Same as imageRowToMatrixRow, but returns negative if invalid + */ + public int imageRowToMatrixRowStrict(int imrow) { + imrow -= rowOffset; + int mrow = imrow >= 0 && imrow % rowStep == 0 ? imrow / rowStep : -1; + return mrow < nRows ? mrow : -1; + } + + /** + * Converts from matrix row number (0 : nRows-1) to image row number + * + * @param mrow + * Matrix row number + * @return Image row number. Invalid only if mrow is invalid + */ + public int matrixRowToImageRow(int mrow) { + return mrow * rowStep + rowOffset; + } + + /** + * Returns a ImageLine is backed by the matrix, no allocation done + * + * @param mrow + * Matrix row, from 0 to nRows This is not necessarily the image row, see + * {@link #imageRowToMatrixRow(int)} and {@link #matrixRowToImageRow(int)} + * @return A new ImageLine, backed by the matrix, with the correct ('real') rownumber + */ + public ImageLine getImageLineAtMatrixRow(int mrow) { + if (mrow < 0 || mrow > nRows) + throw new PngjException("Bad row " + mrow + ". Should be positive and less than " + nRows); + ImageLine imline = sampleType == SampleType.INT ? new ImageLine(imgInfo, sampleType, samplesUnpacked, + scanlines[mrow], null) : new ImageLine(imgInfo, sampleType, samplesUnpacked, null, scanlinesb[mrow]); + imline.setRown(matrixRowToImageRow(mrow)); + return imline; + } +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngDeinterlacer.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngDeinterlacer.java new file mode 100644 index 000000000..e099c4f6a --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngDeinterlacer.java @@ -0,0 +1,277 @@ +package jogamp.opengl.util.pngj; + +import java.util.Random; + +// you really dont' want to peek inside this +class PngDeinterlacer { + private final ImageInfo imi; + private int pass; // 1-7 + private int rows, cols, dY, dX, oY, oX, oXsamples, dXsamples; // at current pass + // current row in the virtual subsampled image; this incrementes from 0 to cols/dy 7 times + private int currRowSubimg = -1; + // in the real image, this will cycle from 0 to im.rows in different steps, 7 times + private int currRowReal = -1; + + private final int packedValsPerPixel; + private final int packedMask; + private final int packedShift; + + private int[][] imageInt; // FULL image -only used for PngWriter as temporary storage + private short[][] imageShort; + private byte[][] imageByte; + + PngDeinterlacer(ImageInfo iminfo) { + this.imi = iminfo; + pass = 0; + if (imi.packed) { + packedValsPerPixel = 8 / imi.bitDepth; + packedShift = imi.bitDepth; + if (imi.bitDepth == 1) + packedMask = 0x80; + else if (imi.bitDepth == 2) + packedMask = 0xc0; + else + packedMask = 0xf0; + } else { + packedMask = packedShift = packedValsPerPixel = 1;// dont care + } + setPass(1); + setRow(0); + } + + /** this refers to the row currRowSubimg */ + void setRow(int n) { + currRowSubimg = n; + currRowReal = n * dY + oY; + if (currRowReal < 0 || currRowReal >= imi.rows) + throw new PngjExceptionInternal("bad row - this should not happen"); + } + + void setPass(int p) { + if (this.pass == p) + return; + pass = p; + switch (pass) { + case 1: + dY = dX = 8; + oX = oY = 0; + break; + case 2: + dY = dX = 8; + oX = 4; + oY = 0; + break; + case 3: + dX = 4; + dY = 8; + oX = 0; + oY = 4; + break; + case 4: + dX = dY = 4; + oX = 2; + oY = 0; + break; + case 5: + dX = 2; + dY = 4; + oX = 0; + oY = 2; + break; + case 6: + dX = dY = 2; + oX = 1; + oY = 0; + break; + case 7: + dX = 1; + dY = 2; + oX = 0; + oY = 1; + break; + default: + throw new PngjExceptionInternal("bad interlace pass" + pass); + } + rows = (imi.rows - oY) / dY + 1; + if ((rows - 1) * dY + oY >= imi.rows) + rows--; // can be 0 + cols = (imi.cols - oX) / dX + 1; + if ((cols - 1) * dX + oX >= imi.cols) + cols--; // can be 0 + if (cols == 0) + rows = 0; // really... + dXsamples = dX * imi.channels; + oXsamples = oX * imi.channels; + } + + // notice that this is a "partial" deinterlace, it will be called several times for the same row! + void deinterlaceInt(int[] src, int[] dst, boolean readInPackedFormat) { + if (!(imi.packed && readInPackedFormat)) + for (int i = 0, j = oXsamples; i < cols * imi.channels; i += imi.channels, j += dXsamples) + for (int k = 0; k < imi.channels; k++) + dst[j + k] = src[i + k]; + else + deinterlaceIntPacked(src, dst); + } + + // interlaced+packed = monster; this is very clumsy! + private void deinterlaceIntPacked(int[] src, int[] dst) { + int spos, smod, smask; // source byte position, bits to shift to left (01,2,3,4 + int tpos, tmod, p, d; + spos = 0; + smask = packedMask; + smod = -1; + // can this really work? + for (int i = 0, j = oX; i < cols; i++, j += dX) { + spos = i / packedValsPerPixel; + smod += 1; + if (smod >= packedValsPerPixel) + smod = 0; + smask >>= packedShift; // the source mask cycles + if (smod == 0) + smask = packedMask; + tpos = j / packedValsPerPixel; + tmod = j % packedValsPerPixel; + p = src[spos] & smask; + d = tmod - smod; + if (d > 0) + p >>= (d * packedShift); + else if (d < 0) + p <<= ((-d) * packedShift); + dst[tpos] |= p; + } + } + + // yes, duplication of code is evil, normally + void deinterlaceByte(byte[] src, byte[] dst, boolean readInPackedFormat) { + if (!(imi.packed && readInPackedFormat)) + for (int i = 0, j = oXsamples; i < cols * imi.channels; i += imi.channels, j += dXsamples) + for (int k = 0; k < imi.channels; k++) + dst[j + k] = src[i + k]; + else + deinterlacePackedByte(src, dst); + } + + private void deinterlacePackedByte(byte[] src, byte[] dst) { + int spos, smod, smask; // source byte position, bits to shift to left (01,2,3,4 + int tpos, tmod, p, d; + // what the heck are you reading here? I told you would not enjoy this. Try Dostoyevsky or Simone Weil instead + spos = 0; + smask = packedMask; + smod = -1; + // Arrays.fill(dst, 0); + for (int i = 0, j = oX; i < cols; i++, j += dX) { + spos = i / packedValsPerPixel; + smod += 1; + if (smod >= packedValsPerPixel) + smod = 0; + smask >>= packedShift; // the source mask cycles + if (smod == 0) + smask = packedMask; + tpos = j / packedValsPerPixel; + tmod = j % packedValsPerPixel; + p = src[spos] & smask; + d = tmod - smod; + if (d > 0) + p >>= (d * packedShift); + else if (d < 0) + p <<= ((-d) * packedShift); + dst[tpos] |= p; + } + } + + /** + * Is current row the last row for the lass pass?? + */ + boolean isAtLastRow() { + return pass == 7 && currRowSubimg == rows - 1; + } + + /** + * current row number inside the "sub image" + */ + int getCurrRowSubimg() { + return currRowSubimg; + } + + /** + * current row number inside the "real image" + */ + int getCurrRowReal() { + return currRowReal; + } + + /** + * current pass number (1-7) + */ + int getPass() { + return pass; + } + + /** + * How many rows has the current pass? + **/ + int getRows() { + return rows; + } + + /** + * How many columns (pixels) are there in the current row + */ + int getCols() { + return cols; + } + + public int getPixelsToRead() { + return getCols(); + } + + int[][] getImageInt() { + return imageInt; + } + + void setImageInt(int[][] imageInt) { + this.imageInt = imageInt; + } + + short[][] getImageShort() { + return imageShort; + } + + void setImageShort(short[][] imageShort) { + this.imageShort = imageShort; + } + + byte[][] getImageByte() { + return imageByte; + } + + void setImageByte(byte[][] imageByte) { + this.imageByte = imageByte; + } + + static void test() { + Random rand = new Random(); + PngDeinterlacer ih = new PngDeinterlacer(new ImageInfo(rand.nextInt(35) + 1, rand.nextInt(52) + 1, 8, true)); + int np = ih.imi.cols * ih.imi.rows; + System.out.println(ih.imi); + for (int p = 1; p <= 7; p++) { + ih.setPass(p); + for (int row = 0; row < ih.getRows(); row++) { + ih.setRow(row); + int b = ih.getCols(); + np -= b; + System.out.printf("Read %d pixels. Pass:%d Realline:%d cols=%d dX=%d oX=%d last:%b\n", b, ih.pass, + ih.currRowReal, ih.cols, ih.dX, ih.oX, ih.isAtLastRow()); + + } + } + if (np != 0) + throw new PngjExceptionInternal("wtf??" + ih.imi); + } + + public static void main(String[] args) { + test(); + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelper.java deleted file mode 100644 index 1016b1b64..000000000 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelper.java +++ /dev/null @@ -1,213 +0,0 @@ -package jogamp.opengl.util.pngj; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.charset.Charset; -import java.util.HashSet; -import java.util.Set; -import java.util.zip.CRC32; - -/** - * Some utility static methods. - *

        - * See also FileHelper (if not sandboxed). - *

        - * Client code should rarely need these methods. - */ -public class PngHelper { - /** - * Default charset, used internally by PNG for several things - */ - public static Charset charsetLatin1 = Charset.forName("ISO-8859-1"); - public static Charset charsetUTF8 = Charset.forName("UTF-8"); // only for some chunks - - static boolean DEBUG = false; - - public static int readByte(InputStream is) { - try { - return is.read(); - } catch (IOException e) { - throw new PngjOutputException(e); - } - } - - /** - * -1 if eof - * - * PNG uses "network byte order" - */ - public static int readInt2(InputStream is) { - try { - int b1 = is.read(); - int b2 = is.read(); - if (b1 == -1 || b2 == -1) - return -1; - return (b1 << 8) + b2; - } catch (IOException e) { - throw new PngjInputException("error reading readInt2", e); - } - } - - /** - * -1 if eof - */ - public static int readInt4(InputStream is) { - try { - int b1 = is.read(); - int b2 = is.read(); - int b3 = is.read(); - int b4 = is.read(); - if (b1 == -1 || b2 == -1 || b3 == -1 || b4 == -1) - return -1; - return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4; - } catch (IOException e) { - throw new PngjInputException("error reading readInt4", e); - } - } - - public static int readInt1fromByte(byte[] b, int offset) { - return (b[offset] & 0xff); - } - - public static int readInt2fromBytes(byte[] b, int offset) { - return ((b[offset] & 0xff) << 16) | ((b[offset + 1] & 0xff)); - } - - public static int readInt4fromBytes(byte[] b, int offset) { - return ((b[offset] & 0xff) << 24) | ((b[offset + 1] & 0xff) << 16) | ((b[offset + 2] & 0xff) << 8) - | (b[offset + 3] & 0xff); - } - - public static void writeByte(OutputStream os, byte b) { - try { - os.write(b); - } catch (IOException e) { - throw new PngjOutputException(e); - } - } - - public static void writeInt2(OutputStream os, int n) { - byte[] temp = { (byte) ((n >> 8) & 0xff), (byte) (n & 0xff) }; - writeBytes(os, temp); - } - - public static void writeInt4(OutputStream os, int n) { - byte[] temp = new byte[4]; - writeInt4tobytes(n, temp, 0); - writeBytes(os, temp); - } - - public static void writeInt2tobytes(int n, byte[] b, int offset) { - b[offset] = (byte) ((n >> 8) & 0xff); - b[offset + 1] = (byte) (n & 0xff); - } - - public static void writeInt4tobytes(int n, byte[] b, int offset) { - b[offset] = (byte) ((n >> 24) & 0xff); - b[offset + 1] = (byte) ((n >> 16) & 0xff); - b[offset + 2] = (byte) ((n >> 8) & 0xff); - b[offset + 3] = (byte) (n & 0xff); - } - - /** - * guaranteed to read exactly len bytes. throws error if it cant - */ - public static void readBytes(InputStream is, byte[] b, int offset, int len) { - if (len == 0) - return; - try { - int read = 0; - while (read < len) { - int n = is.read(b, offset + read, len - read); - if (n < 1) - throw new RuntimeException("error reading bytes, " + n + " !=" + len); - read += n; - } - } catch (IOException e) { - throw new PngjInputException("error reading", e); - } - } - - public static void writeBytes(OutputStream os, byte[] b) { - try { - os.write(b); - } catch (IOException e) { - throw new PngjOutputException(e); - } - } - - public static void writeBytes(OutputStream os, byte[] b, int offset, int n) { - try { - os.write(b, offset, n); - } catch (IOException e) { - throw new PngjOutputException(e); - } - } - - public static void logdebug(String msg) { - if (DEBUG) - System.out.println(msg); - } - - public static Set asSet(String... values) { - return new HashSet(java.util.Arrays.asList(values)); - } - - public static Set unionSets(Set set1, Set set2) { - Set s = new HashSet(); - s.addAll(set1); - s.addAll(set2); - return s; - } - - public static Set unionSets(Set set1, Set set2, Set set3) { - Set s = new HashSet(); - s.addAll(set1); - s.addAll(set2); - s.addAll(set3); - return s; - } - - private static final ThreadLocal crcProvider = new ThreadLocal() { - protected CRC32 initialValue() { - return new CRC32(); - } - }; - - /** thread-singleton crc engine */ - public static CRC32 getCRC() { - return crcProvider.get(); - } - - static final byte[] pngIdBytes = { -119, 80, 78, 71, 13, 10, 26, 10 }; // png magic - - public static double resMetersToDpi(long res) { - return (double) res * 0.0254; - } - - public static long resDpiToMeters(double dpi) { - return (long) (dpi / 0.0254 + 0.5); - } - - public static int doubleToInt100000(double d) { - return (int) (d * 100000.0 + 0.5); - } - - public static double intToDouble100000(int i) { - return i / 100000.0; - } - - public static int clampTo_0_255(int i) { - return i > 255 ? 255 : (i < 0 ? 0 : i); - } - - public static int clampTo_0_65535(int i) { - return i > 65535 ? 65535 : (i < 0 ? 0 : i); - } - - public static int clampTo_128_127(int x) { - return x > 127 ? 127 : (x < -128 ? -128 : x); - } - -} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java new file mode 100644 index 000000000..63edf8d17 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngHelperInternal.java @@ -0,0 +1,264 @@ +package jogamp.opengl.util.pngj; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.charset.Charset; +import java.util.zip.CRC32; + +/** + * Some utility static methods for internal use. + *

        + * Client code should not normally use this class + *

        + */ +public class PngHelperInternal { + /** + * Default charset, used internally by PNG for several things + */ + public static Charset charsetLatin1 = Charset.forName("ISO-8859-1"); + /** + * UTF-8 is only used for some chunks + */ + public static Charset charsetUTF8 = Charset.forName("UTF-8"); + + static boolean DEBUG = false; + + /** + * PNG magic bytes + */ + public static byte[] getPngIdSignature() { + return new byte[] { -119, 80, 78, 71, 13, 10, 26, 10 }; + } + + public static int doubleToInt100000(double d) { + return (int) (d * 100000.0 + 0.5); + } + + public static double intToDouble100000(int i) { + return i / 100000.0; + } + + public static int readByte(InputStream is) { + try { + return is.read(); + } catch (IOException e) { + throw new PngjInputException("error reading byte", e); + } + } + + /** + * -1 if eof + * + * PNG uses "network byte order" + */ + public static int readInt2(InputStream is) { + try { + int b1 = is.read(); + int b2 = is.read(); + if (b1 == -1 || b2 == -1) + return -1; + return (b1 << 8) + b2; + } catch (IOException e) { + throw new PngjInputException("error reading readInt2", e); + } + } + + /** + * -1 if eof + */ + public static int readInt4(InputStream is) { + try { + int b1 = is.read(); + int b2 = is.read(); + int b3 = is.read(); + int b4 = is.read(); + if (b1 == -1 || b2 == -1 || b3 == -1 || b4 == -1) + return -1; + return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4; + } catch (IOException e) { + throw new PngjInputException("error reading readInt4", e); + } + } + + public static int readInt1fromByte(byte[] b, int offset) { + return (b[offset] & 0xff); + } + + public static int readInt2fromBytes(byte[] b, int offset) { + return ((b[offset] & 0xff) << 16) | ((b[offset + 1] & 0xff)); + } + + public static int readInt4fromBytes(byte[] b, int offset) { + return ((b[offset] & 0xff) << 24) | ((b[offset + 1] & 0xff) << 16) | ((b[offset + 2] & 0xff) << 8) + | (b[offset + 3] & 0xff); + } + + public static void writeByte(OutputStream os, byte b) { + try { + os.write(b); + } catch (IOException e) { + throw new PngjOutputException(e); + } + } + + public static void writeInt2(OutputStream os, int n) { + byte[] temp = { (byte) ((n >> 8) & 0xff), (byte) (n & 0xff) }; + writeBytes(os, temp); + } + + public static void writeInt4(OutputStream os, int n) { + byte[] temp = new byte[4]; + writeInt4tobytes(n, temp, 0); + writeBytes(os, temp); + } + + public static void writeInt2tobytes(int n, byte[] b, int offset) { + b[offset] = (byte) ((n >> 8) & 0xff); + b[offset + 1] = (byte) (n & 0xff); + } + + public static void writeInt4tobytes(int n, byte[] b, int offset) { + b[offset] = (byte) ((n >> 24) & 0xff); + b[offset + 1] = (byte) ((n >> 16) & 0xff); + b[offset + 2] = (byte) ((n >> 8) & 0xff); + b[offset + 3] = (byte) (n & 0xff); + } + + /** + * guaranteed to read exactly len bytes. throws error if it can't + */ + public static void readBytes(InputStream is, byte[] b, int offset, int len) { + if (len == 0) + return; + try { + int read = 0; + while (read < len) { + int n = is.read(b, offset + read, len - read); + if (n < 1) + throw new PngjInputException("error reading bytes, " + n + " !=" + len); + read += n; + } + } catch (IOException e) { + throw new PngjInputException("error reading", e); + } + } + + public static void skipBytes(InputStream is, int len) { + byte[] buf = new byte[8192 * 4]; + int read, remain = len; + try { + while (remain > 0) { + read = is.read(buf, 0, remain > buf.length ? buf.length : remain); + if (read < 0) + throw new PngjInputException("error reading (skipping) : EOF"); + remain -= read; + } + } catch (IOException e) { + throw new PngjInputException("error reading (skipping)", e); + } + } + + public static void writeBytes(OutputStream os, byte[] b) { + try { + os.write(b); + } catch (IOException e) { + throw new PngjOutputException(e); + } + } + + public static void writeBytes(OutputStream os, byte[] b, int offset, int n) { + try { + os.write(b, offset, n); + } catch (IOException e) { + throw new PngjOutputException(e); + } + } + + public static void logdebug(String msg) { + if (DEBUG) + System.out.println(msg); + } + + private static final ThreadLocal crcProvider = new ThreadLocal() { + protected CRC32 initialValue() { + return new CRC32(); + } + }; + + /** thread-singleton crc engine */ + public static CRC32 getCRC() { + return crcProvider.get(); + } + + // / filters + public static int filterRowNone(int r) { + return (int) (r & 0xFF); + } + + public static int filterRowSub(int r, int left) { + return ((int) (r - left) & 0xFF); + } + + public static int filterRowUp(int r, int up) { + return ((int) (r - up) & 0xFF); + } + + public static int filterRowAverage(int r, int left, int up) { + return (r - (left + up) / 2) & 0xFF; + } + + public static int filterRowPaeth(int r, int left, int up, int upleft) { // a = left, b = above, c = upper left + return (r - filterPaethPredictor(left, up, upleft)) & 0xFF; + } + + public static int unfilterRowNone(int r) { + return (int) (r & 0xFF); + } + + public static int unfilterRowSub(int r, int left) { + return ((int) (r + left) & 0xFF); + } + + public static int unfilterRowUp(int r, int up) { + return ((int) (r + up) & 0xFF); + } + + public static int unfilterRowAverage(int r, int left, int up) { + return (r + (left + up) / 2) & 0xFF; + } + + public static int unfilterRowPaeth(int r, int left, int up, int upleft) { // a = left, b = above, c = upper left + return (r + filterPaethPredictor(left, up, upleft)) & 0xFF; + } + + final static int filterPaethPredictor(final int a, final int b, final int c) { // a = left, b = above, c = upper + // left + // from http://www.libpng.org/pub/png/spec/1.2/PNG-Filters.html + + final int p = a + b - c;// ; initial estimate + final int pa = p >= a ? p - a : a - p; + final int pb = p >= b ? p - b : b - p; + final int pc = p >= c ? p - c : c - p; + // ; return nearest of a,b,c, + // ; breaking ties in order a,b,c. + if (pa <= pb && pa <= pc) + return a; + else if (pb <= pc) + return b; + else + return c; + } + + /* + * we put this methods here so as to not pollute the public interface of PngReader + */ + public final static void initCrcForTests(PngReader pngr) { + pngr.initCrctest(); + } + + public final static long getCrctestVal(PngReader pngr) { + return pngr.getCrctestVal(); + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java index 66c4b49f0..6cc39b0e6 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkInputStream.java @@ -11,23 +11,24 @@ import jogamp.opengl.util.pngj.chunks.ChunkHelper; /** - * Reads IDAT chunks + * Reads a sequence of contiguous IDAT chunks */ class PngIDatChunkInputStream extends InputStream { private final InputStream inputStream; private final CRC32 crcEngine; + private boolean checkCrc = true; private int lenLastChunk; private byte[] idLastChunk = new byte[4]; private int toReadThisChunk = 0; private boolean ended = false; - private long offset; // offset inside inputstream + private long offset; // offset inside whole inputstream (counting bytes before IDAT) // just informational static class IdatChunkInfo { public final int len; - public final int offset; + public final long offset; - private IdatChunkInfo(int len, int offset) { + private IdatChunkInfo(int len, long offset) { this.len = len; this.offset = offset; } @@ -38,16 +39,17 @@ class PngIDatChunkInputStream extends InputStream { /** * Constructor must be called just after reading length and id of first IDAT chunk **/ - PngIDatChunkInputStream(InputStream iStream, int lenFirstChunk, int offset) { - this.offset = (long) offset; + PngIDatChunkInputStream(InputStream iStream, int lenFirstChunk, long offset) { + this.offset = offset; inputStream = iStream; - crcEngine = new CRC32(); this.lenLastChunk = lenFirstChunk; toReadThisChunk = lenFirstChunk; // we know it's a IDAT System.arraycopy(ChunkHelper.b_IDAT, 0, idLastChunk, 0, 4); + crcEngine = new CRC32(); crcEngine.update(idLastChunk, 0, 4); foundChunksInfo.add(new IdatChunkInfo(lenLastChunk, offset - 8)); + // PngHelper.logdebug("IDAT Initial fragment: len=" + lenLastChunk); if (this.lenLastChunk == 0) endChunkGoForNext(); // rare, but... @@ -58,31 +60,33 @@ class PngIDatChunkInputStream extends InputStream { */ @Override public void close() throws IOException { - super.close(); // nothing + super.close(); // thsi does nothing } private void endChunkGoForNext() { - // Called after readging the last byte of chunk + // Called after readging the last byte of one IDAT chunk // Checks CRC, and read ID from next CHUNK // Those values are left in idLastChunk / lenLastChunk // Skips empty IDATS do { - int crc = PngHelper.readInt4(inputStream); // + int crc = PngHelperInternal.readInt4(inputStream); // offset += 4; - int crccalc = (int) crcEngine.getValue(); - if (lenLastChunk > 0 && crc != crccalc) - throw new PngjBadCrcException("error reading idat; offset: " + offset); - crcEngine.reset(); - lenLastChunk = PngHelper.readInt4(inputStream); - if (lenLastChunk < 0) - throw new PngjInputException("invalid len for chunk: " + lenLastChunk); + if (checkCrc) { + int crccalc = (int) crcEngine.getValue(); + if (lenLastChunk > 0 && crc != crccalc) + throw new PngjBadCrcException("error reading idat; offset: " + offset); + crcEngine.reset(); + } + lenLastChunk = PngHelperInternal.readInt4(inputStream); toReadThisChunk = lenLastChunk; - PngHelper.readBytes(inputStream, idLastChunk, 0, 4); + PngHelperInternal.readBytes(inputStream, idLastChunk, 0, 4); offset += 8; + // found a NON IDAT chunk? this stream is ended ended = !Arrays.equals(idLastChunk, ChunkHelper.b_IDAT); if (!ended) { - foundChunksInfo.add(new IdatChunkInfo(lenLastChunk, (int) (offset - 8))); - crcEngine.update(idLastChunk, 0, 4); + foundChunksInfo.add(new IdatChunkInfo(lenLastChunk, offset - 8)); + if (checkCrc) + crcEngine.update(idLastChunk, 0, 4); } // PngHelper.logdebug("IDAT ended. next len= " + lenLastChunk + " idat?" + // (!ended)); @@ -96,8 +100,9 @@ class PngIDatChunkInputStream extends InputStream { void forceChunkEnd() { if (!ended) { byte[] dummy = new byte[toReadThisChunk]; - PngHelper.readBytes(inputStream, dummy, 0, toReadThisChunk); - crcEngine.update(dummy, 0, toReadThisChunk); + PngHelperInternal.readBytes(inputStream, dummy, 0, toReadThisChunk); + if (checkCrc) + crcEngine.update(dummy, 0, toReadThisChunk); endChunkGoForNext(); } } @@ -107,11 +112,14 @@ class PngIDatChunkInputStream extends InputStream { */ @Override public int read(byte[] b, int off, int len) throws IOException { + if (ended) + return -1; // can happen only when raw reading, see Pngreader.readAndSkipsAllRows() if (toReadThisChunk == 0) - throw new RuntimeException("this should not happen"); + throw new PngjExceptionInternal("this should not happen"); int n = inputStream.read(b, off, len >= toReadThisChunk ? toReadThisChunk : len); if (n > 0) { - crcEngine.update(b, off, n); + if (checkCrc) + crcEngine.update(b, off, n); this.offset += n; toReadThisChunk -= n; } @@ -150,4 +158,11 @@ class PngIDatChunkInputStream extends InputStream { boolean isEnded() { return ended; } + + /** + * Disables CRC checking. This can make reading faster + */ + void disableCrcCheck() { + checkCrc = false; + } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkOutputStream.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkOutputStream.java index 8b9fa5dae..411d18819 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkOutputStream.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngIDatChunkOutputStream.java @@ -7,23 +7,23 @@ import jogamp.opengl.util.pngj.chunks.ChunkRaw; /** - * outputs the stream for IDAT chunk , fragmented at fixed size (16384 default). + * outputs the stream for IDAT chunk , fragmented at fixed size (32k default). */ class PngIDatChunkOutputStream extends ProgressiveOutputStream { - private static final int SIZE_DEFAULT = 16384; + private static final int SIZE_DEFAULT = 32768; // 32k private final OutputStream outputStream; PngIDatChunkOutputStream(OutputStream outputStream) { - this(outputStream, SIZE_DEFAULT); + this(outputStream, 0); } PngIDatChunkOutputStream(OutputStream outputStream, int size) { - super(size); + super(size > 0 ? size : SIZE_DEFAULT); this.outputStream = outputStream; } @Override - public final void flushBuffer(byte[] b, int len) { + protected final void flushBuffer(byte[] b, int len) { ChunkRaw c = new ChunkRaw(len, ChunkHelper.b_IDAT, false); c.data = b; c.writeChunk(outputStream); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java index 7343893b6..8cb4295a5 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java @@ -1,42 +1,66 @@ package jogamp.opengl.util.pngj; +import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; import java.util.Arrays; -import java.util.List; +import java.util.HashSet; +import java.util.zip.CRC32; import java.util.zip.InflaterInputStream; -import jogamp.opengl.util.pngj.PngIDatChunkInputStream.IdatChunkInfo; +import jogamp.opengl.util.pngj.ImageInfo; +import jogamp.opengl.util.pngj.ImageLine.SampleType; import jogamp.opengl.util.pngj.chunks.ChunkHelper; -import jogamp.opengl.util.pngj.chunks.ChunkList; import jogamp.opengl.util.pngj.chunks.ChunkLoadBehaviour; import jogamp.opengl.util.pngj.chunks.ChunkRaw; +import jogamp.opengl.util.pngj.chunks.ChunksList; import jogamp.opengl.util.pngj.chunks.PngChunk; +import jogamp.opengl.util.pngj.chunks.PngChunkIDAT; import jogamp.opengl.util.pngj.chunks.PngChunkIHDR; +import jogamp.opengl.util.pngj.chunks.PngChunkSkipped; import jogamp.opengl.util.pngj.chunks.PngMetadata; - /** - * Reads a PNG image, line by line + * Reads a PNG image, line by line. + *

        + * The reading sequence is as follows:
        + * 1. At construction time, the header and IHDR chunk are read (basic image info)
        + * 2. Afterwards you can set some additional global options. Eg. {@link #setUnpackedMode(boolean)}, + * {@link #setCrcCheckDisabled()}.
        + * 3. Optional: If you call getMetadata() or getChunksLisk() before start reading the rows, all the chunks before IDAT + * are automatically loaded and available
        + * 4a. The rows are read onen by one of the readRowXXX methods: {@link #readRowInt(int)}, + * {@link PngReader#readRowByte(int)}, etc, in order, from 0 to nrows-1 (you can skip or repeat rows, but not go + * backwards)
        + * 4b. Alternatively, you can read all rows, or a subset, in a single call: {@link #readRowsInt()}, + * {@link #readRowsByte()} ,etc. In general this consumes more memory, but for interlaced images this is equally + * efficient, and more so if reading a small subset of rows.
        + * 5. Read of the last row auyomatically loads the trailing chunks, and ends the reader.
        + * 6. end() forcibly finishes/aborts the reading and closes the stream */ public class PngReader { /** * Basic image info - final and inmutable. */ public final ImageInfo imgInfo; - protected final String filename; // not necesarily a file, can be a description - merely informative - private static int MAX_BYTES_CHUNKS_TO_LOAD = 640000; - private ChunkLoadBehaviour chunkLoadBehaviour = ChunkLoadBehaviour.LOAD_CHUNK_ALWAYS; + /** + * not necesarily a filename, can be a description - merely informative + */ + protected final String filename; + + private ChunkLoadBehaviour chunkLoadBehaviour = ChunkLoadBehaviour.LOAD_CHUNK_ALWAYS; // see setter/getter - private final InputStream is; - private InflaterInputStream idatIstream; - private PngIDatChunkInputStream iIdatCstream; + private boolean shouldCloseStream = true; // true: closes stream after ending - see setter/getter - protected int currentChunkGroup = -1; - protected int rowNum = -1; // current row number - private int offset = 0; - private int bytesChunksLoaded; // bytes loaded from anciallary chunks + // some performance/defensive limits + private long maxTotalBytesRead = 200 * 1024 * 1024; // 200MB + private int maxBytesMetadata = 5 * 1024 * 1024; // for ancillary chunks - see setter/getter + private int skipChunkMaxSize = 2 * 1024 * 1024; // chunks exceeding this size will be skipped (nor even CRC checked) + private String[] skipChunkIds = { "fdAT" }; // chunks with these ids will be skipped (nor even CRC checked) + private HashSet skipChunkIdsSet; // lazily created from skipChunksById + + protected final PngMetadata metadata; // this a wrapper over chunks + protected final ChunksList chunksList; protected ImageLine imgLine; @@ -45,12 +69,30 @@ public class PngReader { protected byte[] rowbprev = null; // rowb previous protected byte[] rowbfilter = null; // current line 'filtered': exactly as in uncompressed stream + // only set for interlaced PNG + private final boolean interlaced; + private final PngDeinterlacer deinterlacer; + + private boolean crcEnabled = true; + + // this only influences the 1-2-4 bitdepth format + private boolean unpackedMode = false; /** - * All chunks loaded. Criticals are included, except that all IDAT chunks appearance are replaced by a single - * dummy-marker IDAT chunk. These might be copied to the PngWriter + * Current chunk group, (0-6) already read or reading + *

        + * see {@link ChunksList} */ - private final ChunkList chunksList; - private final PngMetadata metadata; // this a wrapper over chunks + protected int currentChunkGroup = -1; + + protected int rowNum = -1; // last read row number, starting from 0 + private long offset = 0; // offset in InputStream = bytes read + private int bytesChunksLoaded; // bytes loaded from anciallary chunks + + protected final InputStream inputStream; + protected InflaterInputStream idatIstream; + protected PngIDatChunkInputStream iIdatCstream; + + protected CRC32 crctest; // If set to non null, it gets a CRC of the unfiltered bytes, to check for images equality /** * Constructs a PngReader from an InputStream. @@ -65,175 +107,234 @@ public class PngReader { */ public PngReader(InputStream inputStream, String filenameOrDescription) { this.filename = filenameOrDescription == null ? "" : filenameOrDescription; - this.is = inputStream; - this.chunksList = new ChunkList(null); - this.metadata = new PngMetadata(chunksList, true); - // reads header (magic bytes) - byte[] pngid = new byte[PngHelper.pngIdBytes.length]; - PngHelper.readBytes(is, pngid, 0, pngid.length); + this.inputStream = inputStream; + this.chunksList = new ChunksList(null); + this.metadata = new PngMetadata(chunksList); + // starts reading: signature + byte[] pngid = new byte[8]; + PngHelperInternal.readBytes(inputStream, pngid, 0, pngid.length); offset += pngid.length; - if (!Arrays.equals(pngid, PngHelper.pngIdBytes)) + if (!Arrays.equals(pngid, PngHelperInternal.getPngIdSignature())) throw new PngjInputException("Bad PNG signature"); // reads first chunk - currentChunkGroup = ChunkList.CHUNK_GROUP_0_IDHR; - int clen = PngHelper.readInt4(is); + currentChunkGroup = ChunksList.CHUNK_GROUP_0_IDHR; + int clen = PngHelperInternal.readInt4(inputStream); offset += 4; if (clen != 13) - throw new RuntimeException("IDHR chunk len != 13 ?? " + clen); + throw new PngjInputException("IDHR chunk len != 13 ?? " + clen); byte[] chunkid = new byte[4]; - PngHelper.readBytes(is, chunkid, 0, 4); + PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); if (!Arrays.equals(chunkid, ChunkHelper.b_IHDR)) throw new PngjInputException("IHDR not found as first chunk??? [" + ChunkHelper.toString(chunkid) + "]"); offset += 4; - ChunkRaw chunk = new ChunkRaw(clen, chunkid, true); - String chunkids = ChunkHelper.toString(chunkid); - offset += chunk.readChunkData(is); - PngChunkIHDR ihdr = (PngChunkIHDR) addChunkToList(chunk); + PngChunkIHDR ihdr = (PngChunkIHDR) readChunk(chunkid, clen, false); boolean alpha = (ihdr.getColormodel() & 0x04) != 0; boolean palette = (ihdr.getColormodel() & 0x01) != 0; boolean grayscale = (ihdr.getColormodel() == 0 || ihdr.getColormodel() == 4); + // creates ImgInfo and imgLine, and allocates buffers imgInfo = new ImageInfo(ihdr.getCols(), ihdr.getRows(), ihdr.getBitspc(), alpha, grayscale, palette); - imgLine = new ImageLine(imgInfo); - if (ihdr.getInterlaced() != 0) - throw new PngjUnsupportedException("PNG interlaced not supported by this library"); - if (ihdr.getFilmeth() != 0 || ihdr.getCompmeth() != 0) - throw new PngjInputException("compmethod o filtermethod unrecognized"); + // allocation: one extra byte for filter type one pixel + rowbfilter = new byte[imgInfo.bytesPerRow + 1]; + rowb = new byte[imgInfo.bytesPerRow + 1]; + rowbprev = new byte[rowb.length]; + interlaced = ihdr.getInterlaced() == 1; + deinterlacer = interlaced ? new PngDeinterlacer(imgInfo) : null; + // some checks + if (ihdr.getFilmeth() != 0 || ihdr.getCompmeth() != 0 || (ihdr.getInterlaced() & 0xFFFE) != 0) + throw new PngjInputException("compression method o filter method or interlaced unrecognized "); if (ihdr.getColormodel() < 0 || ihdr.getColormodel() > 6 || ihdr.getColormodel() == 1 || ihdr.getColormodel() == 5) throw new PngjInputException("Invalid colormodel " + ihdr.getColormodel()); if (ihdr.getBitspc() != 1 && ihdr.getBitspc() != 2 && ihdr.getBitspc() != 4 && ihdr.getBitspc() != 8 && ihdr.getBitspc() != 16) throw new PngjInputException("Invalid bit depth " + ihdr.getBitspc()); - // allocation: one extra byte for filter type one pixel - rowbfilter = new byte[imgInfo.bytesPerRow + 1]; - rowb = new byte[imgInfo.bytesPerRow + 1]; - rowbprev = new byte[rowb.length]; } - private static class FoundChunkInfo { - public final String id; - public final int len; - public final int offset; - public final boolean loaded; + private boolean firstChunksNotYetRead() { + return currentChunkGroup < ChunksList.CHUNK_GROUP_1_AFTERIDHR; + } + + /** + * Reads last Internally called after having read the last line. It reads extra chunks after IDAT, if present. + */ + private void readLastAndClose() { + // offset = iIdatCstream.getOffset(); + if (currentChunkGroup < ChunksList.CHUNK_GROUP_5_AFTERIDAT) { + try { + idatIstream.close(); + } catch (Exception e) { + } + readLastChunks(); + } + close(); + } + + private void close() { + if (currentChunkGroup < ChunksList.CHUNK_GROUP_6_END) { // this could only happen if forced close + try { + idatIstream.close(); + } catch (Exception e) { + } + currentChunkGroup = ChunksList.CHUNK_GROUP_6_END; + } + if (shouldCloseStream) { + try { + inputStream.close(); + } catch (Exception e) { + throw new PngjInputException("error closing input stream!", e); + } + } + } + + // nbytes: NOT including the filter byte. leaves result in rowb + private void unfilterRow(int nbytes) { + int ftn = rowbfilter[0]; + FilterType ft = FilterType.getByVal(ftn); + if (ft == null) + throw new PngjInputException("Filter type " + ftn + " invalid"); + switch (ft) { + case FILTER_NONE: + unfilterRowNone(nbytes); + break; + case FILTER_SUB: + unfilterRowSub(nbytes); + break; + case FILTER_UP: + unfilterRowUp(nbytes); + break; + case FILTER_AVERAGE: + unfilterRowAverage(nbytes); + break; + case FILTER_PAETH: + unfilterRowPaeth(nbytes); + break; + default: + throw new PngjInputException("Filter type " + ftn + " not implemented"); + } + if (crctest != null) + crctest.update(rowb, 1, rowb.length - 1); + } + + private void unfilterRowAverage(final int nbytes) { + int i, j, x; + for (j = 1 - imgInfo.bytesPixel, i = 1; i <= nbytes; i++, j++) { + x = j > 0 ? (rowb[j] & 0xff) : 0; + rowb[i] = (byte) (rowbfilter[i] + (x + (rowbprev[i] & 0xFF)) / 2); + } + } - private FoundChunkInfo(String id, int len, int offset, boolean loaded) { - this.id = id; - this.len = len; - this.offset = offset; - this.loaded = loaded; + private void unfilterRowNone(final int nbytes) { + for (int i = 1; i <= nbytes; i++) { + rowb[i] = (byte) (rowbfilter[i]); } + } - public String toString() { - return "chunk " + id + " len=" + len + " offset=" + offset + (this.loaded ? " " : " X "); + private void unfilterRowPaeth(final int nbytes) { + int i, j, x, y; + for (j = 1 - imgInfo.bytesPixel, i = 1; i <= nbytes; i++, j++) { + x = j > 0 ? (rowb[j] & 0xFF) : 0; + y = j > 0 ? (rowbprev[j] & 0xFF) : 0; + rowb[i] = (byte) (rowbfilter[i] + PngHelperInternal.filterPaethPredictor(x, rowbprev[i] & 0xFF, y)); } } - private PngChunk addChunkToList(ChunkRaw chunk) { - // this requires that the currentChunkGroup is ok - PngChunk chunkType = PngChunk.factory(chunk, imgInfo); - if (!chunkType.crit) { - bytesChunksLoaded += chunk.len; + private void unfilterRowSub(final int nbytes) { + int i, j; + for (i = 1; i <= imgInfo.bytesPixel; i++) { + rowb[i] = (byte) (rowbfilter[i]); + } + for (j = 1, i = imgInfo.bytesPixel + 1; i <= nbytes; i++, j++) { + rowb[i] = (byte) (rowbfilter[i] + rowb[j]); } - if (bytesChunksLoaded > MAX_BYTES_CHUNKS_TO_LOAD) { - throw new PngjInputException("Chunk exceeded available space (" + MAX_BYTES_CHUNKS_TO_LOAD + ") chunk: " - + chunk + " See PngReader.MAX_BYTES_CHUNKS_TO_LOAD\n"); + } + + private void unfilterRowUp(final int nbytes) { + for (int i = 1; i <= nbytes; i++) { + rowb[i] = (byte) (rowbfilter[i] + rowbprev[i]); } - chunksList.appendReadChunk(chunkType, currentChunkGroup); - return chunkType; } /** - * Reads chunks before first IDAT. Position before: after IDHR (crc included) Position after: just after the first - * IDAT chunk id - * + * Reads chunks before first IDAT. Normally this is called automatically + *

        + * Position before: after IDHR (crc included) Position after: just after the first IDAT chunk id + *

        * This can be called several times (tentatively), it does nothing if already run - * + *

        * (Note: when should this be called? in the constructor? hardly, because we loose the opportunity to call * setChunkLoadBehaviour() and perhaps other settings before reading the first row? but sometimes we want to access * some metadata (plte, phys) before. Because of this, this method can be called explicitly but is also called - * implicititly in some methods (getMetatada(), getChunks()) - * - **/ - public void readFirstChunks() { + * implicititly in some methods (getMetatada(), getChunksList()) + */ + private final void readFirstChunks() { if (!firstChunksNotYetRead()) return; int clen = 0; boolean found = false; byte[] chunkid = new byte[4]; // it's important to reallocate in each iteration - currentChunkGroup = ChunkList.CHUNK_GROUP_1_AFTERIDHR; + currentChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR; while (!found) { - clen = PngHelper.readInt4(is); + clen = PngHelperInternal.readInt4(inputStream); offset += 4; if (clen < 0) break; - PngHelper.readBytes(is, chunkid, 0, 4); + PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); offset += 4; if (Arrays.equals(chunkid, ChunkHelper.b_IDAT)) { found = true; - currentChunkGroup = ChunkList.CHUNK_GROUP_4_IDAT; + currentChunkGroup = ChunksList.CHUNK_GROUP_4_IDAT; // add dummy idat chunk to list - ChunkRaw chunk = new ChunkRaw(0, chunkid, false); - addChunkToList(chunk); + chunksList.appendReadChunk(new PngChunkIDAT(imgInfo, clen, offset - 8), currentChunkGroup); break; } else if (Arrays.equals(chunkid, ChunkHelper.b_IEND)) { throw new PngjInputException("END chunk found before image data (IDAT) at offset=" + offset); } - ChunkRaw chunk = new ChunkRaw(clen, chunkid, true); - String chunkids = ChunkHelper.toString(chunkid); - boolean loadchunk = ChunkHelper.shouldLoad(chunkids, chunkLoadBehaviour); - offset += chunk.readChunkData(is); - if (chunkids.equals(ChunkHelper.PLTE)) - currentChunkGroup = ChunkList.CHUNK_GROUP_2_PLTE; - if (loadchunk) - addChunkToList(chunk); - if (chunkids.equals(ChunkHelper.PLTE)) - currentChunkGroup = ChunkList.CHUNK_GROUP_3_AFTERPLTE; + if (Arrays.equals(chunkid, ChunkHelper.b_PLTE)) + currentChunkGroup = ChunksList.CHUNK_GROUP_2_PLTE; + readChunk(chunkid, clen, false); + if (Arrays.equals(chunkid, ChunkHelper.b_PLTE)) + currentChunkGroup = ChunksList.CHUNK_GROUP_3_AFTERPLTE; } int idatLen = found ? clen : -1; if (idatLen < 0) throw new PngjInputException("first idat chunk not found!"); - iIdatCstream = new PngIDatChunkInputStream(is, idatLen, offset); + iIdatCstream = new PngIDatChunkInputStream(inputStream, idatLen, offset); idatIstream = new InflaterInputStream(iIdatCstream); + if (!crcEnabled) + iIdatCstream.disableCrcCheck(); } /** * Reads (and processes) chunks after last IDAT. **/ - private void readLastChunks() { + void readLastChunks() { // PngHelper.logdebug("idat ended? " + iIdatCstream.isEnded()); - currentChunkGroup = ChunkList.CHUNK_GROUP_5_AFTERIDAT; + currentChunkGroup = ChunksList.CHUNK_GROUP_5_AFTERIDAT; if (!iIdatCstream.isEnded()) iIdatCstream.forceChunkEnd(); int clen = iIdatCstream.getLenLastChunk(); byte[] chunkid = iIdatCstream.getIdLastChunk(); boolean endfound = false; boolean first = true; - boolean ignore = false; + boolean skip = false; while (!endfound) { - ignore = false; + skip = false; if (!first) { - clen = PngHelper.readInt4(is); + clen = PngHelperInternal.readInt4(inputStream); offset += 4; if (clen < 0) - throw new PngjInputException("bad len " + clen); - PngHelper.readBytes(is, chunkid, 0, 4); + throw new PngjInputException("bad chuck len " + clen); + PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); offset += 4; } first = false; if (Arrays.equals(chunkid, ChunkHelper.b_IDAT)) { - // PngHelper.logdebug("extra IDAT chunk len - ignoring : "); - ignore = true; + skip = true; // extra dummy (empty?) idat chunk, it can happen, ignore it } else if (Arrays.equals(chunkid, ChunkHelper.b_IEND)) { - currentChunkGroup = ChunkList.CHUNK_GROUP_6_END; + currentChunkGroup = ChunksList.CHUNK_GROUP_6_END; endfound = true; } - ChunkRaw chunk = new ChunkRaw(clen, chunkid, true); - String chunkids = ChunkHelper.toString(chunkid); - boolean loadchunk = ChunkHelper.shouldLoad(chunkids, chunkLoadBehaviour); - offset += chunk.readChunkData(is); - if (loadchunk && !ignore) { - addChunkToList(chunk); - } + readChunk(chunkid, clen, skip); } if (!endfound) throw new PngjInputException("end chunk not found - offset=" + offset); @@ -241,173 +342,597 @@ public class PngReader { } /** - * Calls readRow(int[] buffer, int nrow) using internal ImageLine as buffer. This doesn't allocate or - * copy anything. + * Reads chunkd from input stream, adds to ChunksList, and returns it. If it's skipped, a PngChunkSkipped object is + * created + */ + private PngChunk readChunk(byte[] chunkid, int clen, boolean skipforced) { + if (clen < 0) + throw new PngjInputException("invalid chunk lenght: " + clen); + // skipChunksByIdSet is created lazyly, if fist IHDR has already been read + if (skipChunkIdsSet == null && currentChunkGroup > ChunksList.CHUNK_GROUP_0_IDHR) + skipChunkIdsSet = new HashSet(Arrays.asList(skipChunkIds)); + String chunkidstr = ChunkHelper.toString(chunkid); + boolean critical = ChunkHelper.isCritical(chunkidstr); + PngChunk pngChunk = null; + boolean skip = skipforced; + if (maxTotalBytesRead > 0 && clen + offset > maxTotalBytesRead) + throw new PngjInputException("Maximum total bytes to read exceeeded: " + maxTotalBytesRead + " offset:" + + offset + " clen=" + clen); + // an ancillary chunks can be skipped because of several reasons: + if (currentChunkGroup > ChunksList.CHUNK_GROUP_0_IDHR && !critical) + skip = skip || (skipChunkMaxSize > 0 && clen >= skipChunkMaxSize) || skipChunkIdsSet.contains(chunkidstr) + || (maxBytesMetadata > 0 && clen > maxBytesMetadata - bytesChunksLoaded) + || !ChunkHelper.shouldLoad(chunkidstr, chunkLoadBehaviour); + if (skip) { + PngHelperInternal.skipBytes(inputStream, clen); + PngHelperInternal.readInt4(inputStream); // skip - we dont call PngHelperInternal.skipBytes(inputStream, + // clen + 4) for risk of overflow + pngChunk = new PngChunkSkipped(chunkidstr, imgInfo, clen); + } else { + ChunkRaw chunk = new ChunkRaw(clen, chunkid, true); + chunk.readChunkData(inputStream, crcEnabled || critical); + pngChunk = PngChunk.factory(chunk, imgInfo); + if (!pngChunk.crit) + bytesChunksLoaded += chunk.len; + } + pngChunk.setOffset(offset - 8L); + chunksList.appendReadChunk(pngChunk, currentChunkGroup); + offset += clen + 4L; + return pngChunk; + } + + /** + * Logs/prints a warning. + *

        + * The default behaviour is print to stderr, but it can be overriden. + *

        + * This happens rarely - most errors are fatal. + */ + protected void logWarn(String warn) { + System.err.println(warn); + } + + /** + * @see #setChunkLoadBehaviour(ChunkLoadBehaviour) + */ + public ChunkLoadBehaviour getChunkLoadBehaviour() { + return chunkLoadBehaviour; + } + + /** + * Determines which ancillary chunks (metada) are to be loaded + * + * @param chunkLoadBehaviour + * {@link ChunkLoadBehaviour} + */ + public void setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour) { + this.chunkLoadBehaviour = chunkLoadBehaviour; + } + + /** + * All loaded chunks (metada). If we have not yet end reading the image, this will include only the chunks before + * the pixels data (IDAT) + *

        + * Critical chunks are included, except that all IDAT chunks appearance are replaced by a single dummy-marker IDAT + * chunk. These might be copied to the PngWriter + *

        + * + * @see #getMetadata() + */ + public ChunksList getChunksList() { + if (firstChunksNotYetRead()) + readFirstChunks(); + return chunksList; + } + + int getCurrentChunkGroup() { + return currentChunkGroup; + } + + /** + * High level wrapper over chunksList * - * @return The ImageLine that also is available inside this object. + * @see #getChunksList() + */ + public PngMetadata getMetadata() { + if (firstChunksNotYetRead()) + readFirstChunks(); + return metadata; + } + + /** + * If called for first time, calls readRowInt. Elsewhere, it calls the appropiate readRowInt/readRowByte + *

        + * In general, specifying the concrete readRowInt/readRowByte is preferrable + * + * @see #readRowInt(int) {@link #readRowByte(int)} */ public ImageLine readRow(int nrow) { - readRow(imgLine.scanline, nrow); - imgLine.filterUsed = FilterType.getByVal(rowbfilter[0]); + if (imgLine == null) + imgLine = new ImageLine(imgInfo, SampleType.INT, unpackedMode); + return imgLine.sampleType != SampleType.BYTE ? readRowInt(nrow) : readRowByte(nrow); + } + + /** + * Reads the row as INT, storing it in the {@link #imgLine} property and returning it. + * + * The row must be greater or equal than the last read row. + * + * @param nrow + * Row number, from 0 to rows-1. Increasing order. + * @return ImageLine object, also available as field. Data is in {@link ImageLine#scanline} (int) field. + */ + public ImageLine readRowInt(int nrow) { + if (imgLine == null) + imgLine = new ImageLine(imgInfo, SampleType.INT, unpackedMode); + if (imgLine.getRown() == nrow) // already read + return imgLine; + readRowInt(imgLine.scanline, nrow); + imgLine.setFilterUsed(FilterType.getByVal(rowbfilter[0])); + imgLine.setRown(nrow); + return imgLine; + } + + /** + * Reads the row as BYTES, storing it in the {@link #imgLine} property and returning it. + * + * The row must be greater or equal than the last read row. This method allows to pass the same row that was last + * read. + * + * @param nrow + * Row number, from 0 to rows-1. Increasing order. + * @return ImageLine object, also available as field. Data is in {@link ImageLine#scanlineb} (byte) field. + */ + public ImageLine readRowByte(int nrow) { + if (imgLine == null) + imgLine = new ImageLine(imgInfo, SampleType.BYTE, unpackedMode); + if (imgLine.getRown() == nrow) // already read + return imgLine; + readRowByte(imgLine.scanlineb, nrow); + imgLine.setFilterUsed(FilterType.getByVal(rowbfilter[0])); imgLine.setRown(nrow); return imgLine; } + /** + * @see #readRowInt(int[], int) + */ + public final int[] readRow(int[] buffer, final int nrow) { + return readRowInt(buffer, nrow); + } + /** * Reads a line and returns it as a int[] array. + *

        + * You can pass (optionally) a prealocatted buffer. + *

        + * If the bitdepth is less than 8, the bytes are packed - unless {@link #unpackedMode} is true. + * + * @param buffer + * Prealocated buffer, or null. + * @param nrow + * Row number (0 is top). Most be strictly greater than the last read row. * + * @return The scanline in the same passwd buffer if it was allocated, a newly allocated one otherwise + */ + public final int[] readRowInt(int[] buffer, final int nrow) { + if (buffer == null) + buffer = new int[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + if (!interlaced) { + if (nrow <= rowNum) + throw new PngjInputException("rows must be read in increasing order: " + nrow); + int bytesread = 0; + while (rowNum < nrow) + bytesread = readRowRaw(rowNum + 1); // read rows, perhaps skipping if necessary + decodeLastReadRowToInt(buffer, bytesread); + } else { // interlaced + if (deinterlacer.getImageInt() == null) + deinterlacer.setImageInt(readRowsInt().scanlines); // read all image and store it in deinterlacer + System.arraycopy(deinterlacer.getImageInt()[nrow], 0, buffer, 0, unpackedMode ? imgInfo.samplesPerRow + : imgInfo.samplesPerRowPacked); + } + return buffer; + } + + /** + * Reads a line and returns it as a byte[] array. + *

        * You can pass (optionally) a prealocatted buffer. + *

        + * If the bitdepth is less than 8, the bytes are packed - unless {@link #unpackedMode} is true.
        + * If the bitdepth is 16, the least significant byte is lost. + *

        * * @param buffer * Prealocated buffer, or null. * @param nrow - * Row number (0 is top). This is mostly for checking, because this library reads rows in sequence. + * Row number (0 is top). Most be strictly greater than the last read row. * * @return The scanline in the same passwd buffer if it was allocated, a newly allocated one otherwise */ - public int[] readRow(int[] buffer, int nrow) { - if (nrow < 0 || nrow >= imgInfo.rows) - throw new PngjInputException("invalid line"); - if (nrow != rowNum + 1) - throw new PngjInputException("invalid line (expected: " + (rowNum + 1)); + public final byte[] readRowByte(byte[] buffer, final int nrow) { + if (buffer == null) + buffer = new byte[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + if (!interlaced) { + if (nrow <= rowNum) + throw new PngjInputException("rows must be read in increasing order: " + nrow); + int bytesread = 0; + while (rowNum < nrow) + bytesread = readRowRaw(rowNum + 1); // read rows, perhaps skipping if necessary + decodeLastReadRowToByte(buffer, bytesread); + } else { // interlaced + if (deinterlacer.getImageByte() == null) + deinterlacer.setImageByte(readRowsByte().scanlinesb); // read all image and store it in deinterlacer + System.arraycopy(deinterlacer.getImageByte()[nrow], 0, buffer, 0, unpackedMode ? imgInfo.samplesPerRow + : imgInfo.samplesPerRowPacked); + } + return buffer; + } + + /** + * @param nrow + * @deprecated Now {@link #readRow(int)} implements the same funcion. This method will be removed in future releases + */ + public ImageLine getRow(int nrow) { + return readRow(nrow); + } + + private void decodeLastReadRowToInt(int[] buffer, int bytesRead) { + if (imgInfo.bitDepth <= 8) + for (int i = 0, j = 1; i < bytesRead; i++) + buffer[i] = (rowb[j++] & 0xFF); // http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html + else + for (int i = 0, j = 1; j <= bytesRead; i++) + buffer[i] = ((rowb[j++] & 0xFF) << 8) + (rowb[j++] & 0xFF); // 16 bitspc + if (imgInfo.packed && unpackedMode) + ImageLine.unpackInplaceInt(imgInfo, buffer, buffer, false); + } + + private void decodeLastReadRowToByte(byte[] buffer, int bytesRead) { + if (imgInfo.bitDepth <= 8) + System.arraycopy(rowb, 1, buffer, 0, bytesRead); + else + for (int i = 0, j = 1; j < bytesRead; i++, j += 2) + buffer[i] = rowb[j];// 16 bits in 1 byte: this discards the LSB!!! + if (imgInfo.packed && unpackedMode) + ImageLine.unpackInplaceByte(imgInfo, buffer, buffer, false); + } + + /** + * Reads a set of lines and returns it as a ImageLines object, which wraps matrix. Internally it reads all lines, + * but decodes and stores only the wanted ones. This starts and ends the reading, and cannot be combined with other + * reading methods. + *

        + * This it's more efficient (speed an memory) that doing calling readRowInt() for each desired line only if the + * image is interlaced. + *

        + * Notice that the columns in the matrix is not the pixel width of the image, but rather pixels x channels + * + * @see #readRowInt(int) to read about the format of each row + * + * @param rowOffset + * Number of rows to be skipped + * @param nRows + * Total number of rows to be read. -1: read all available + * @param rowStep + * Row increment. If 1, we read consecutive lines; if 2, we read even/odd lines, etc + * @return Set of lines as a ImageLines, which wraps a matrix + */ + public ImageLines readRowsInt(int rowOffset, int nRows, int rowStep) { + if (nRows < 0) + nRows = (imgInfo.rows - rowOffset) / rowStep; + if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > imgInfo.rows) + throw new PngjInputException("bad args"); + ImageLines imlines = new ImageLines(imgInfo, SampleType.INT, unpackedMode, rowOffset, nRows, rowStep); + if (!interlaced) { + for (int j = 0; j < imgInfo.rows; j++) { + int bytesread = readRowRaw(j); // read and perhaps discards + int mrow = imlines.imageRowToMatrixRowStrict(j); + if (mrow >= 0) + decodeLastReadRowToInt(imlines.scanlines[mrow], bytesread); + } + } else { // and now, for something completely different (interlaced) + int[] buf = new int[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + for (int p = 1; p <= 7; p++) { + deinterlacer.setPass(p); + for (int i = 0; i < deinterlacer.getRows(); i++) { + int bytesread = readRowRaw(i); + int j = deinterlacer.getCurrRowReal(); + int mrow = imlines.imageRowToMatrixRowStrict(j); + if (mrow >= 0) { + decodeLastReadRowToInt(buf, bytesread); + deinterlacer.deinterlaceInt(buf, imlines.scanlines[mrow], !unpackedMode); + } + } + } + } + end(); + return imlines; + } + + /** + * Same as readRowsInt(0, imgInfo.rows, 1) + * + * @see #readRowsInt(int, int, int) + */ + public ImageLines readRowsInt() { + return readRowsInt(0, imgInfo.rows, 1); + } + + /** + * Reads a set of lines and returns it as a ImageLines object, which wrapas a byte[][] matrix. Internally it reads + * all lines, but decodes and stores only the wanted ones. This starts and ends the reading, and cannot be combined + * with other reading methods. + *

        + * This it's more efficient (speed an memory) that doing calling readRowByte() for each desired line only if the + * image is interlaced. + *

        + * Notice that the columns in the matrix is not the pixel width of the image, but rather pixels x channels + * + * @see #readRowByte(int) to read about the format of each row. Notice that if the bitdepth is 16 this will lose + * information + * + * @param rowOffset + * Number of rows to be skipped + * @param nRows + * Total number of rows to be read. -1: read all available + * @param rowStep + * Row increment. If 1, we read consecutive lines; if 2, we read even/odd lines, etc + * @return Set of lines as a matrix + */ + public ImageLines readRowsByte(int rowOffset, int nRows, int rowStep) { + if (nRows < 0) + nRows = (imgInfo.rows - rowOffset) / rowStep; + if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > imgInfo.rows) + throw new PngjInputException("bad args"); + ImageLines imlines = new ImageLines(imgInfo, SampleType.BYTE, unpackedMode, rowOffset, nRows, rowStep); + if (!interlaced) { + for (int j = 0; j < imgInfo.rows; j++) { + int bytesread = readRowRaw(j); // read and perhaps discards + int mrow = imlines.imageRowToMatrixRowStrict(j); + if (mrow >= 0) + decodeLastReadRowToByte(imlines.scanlinesb[mrow], bytesread); + } + } else { // and now, for something completely different (interlaced) + byte[] buf = new byte[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + for (int p = 1; p <= 7; p++) { + deinterlacer.setPass(p); + for (int i = 0; i < deinterlacer.getRows(); i++) { + int bytesread = readRowRaw(i); + int j = deinterlacer.getCurrRowReal(); + int mrow = imlines.imageRowToMatrixRowStrict(j); + if (mrow >= 0) { + decodeLastReadRowToByte(buf, bytesread); + deinterlacer.deinterlaceByte(buf, imlines.scanlinesb[mrow], !unpackedMode); + } + } + } + } + end(); + return imlines; + } + + /** + * Same as readRowsByte(0, imgInfo.rows, 1) + * + * @see #readRowsByte(int, int, int) + */ + public ImageLines readRowsByte() { + return readRowsByte(0, imgInfo.rows, 1); + } + + /* + * For the interlaced case, nrow indicates the subsampled image - the pass must be set already. + * + * This must be called in strict order, both for interlaced or no interlaced. + * + * Updates rowNum. + * + * Leaves raw result in rowb + * + * Returns bytes actually read (not including the filter byte) + */ + private int readRowRaw(final int nrow) { + // if (nrow == 0 && firstChunksNotYetRead()) readFirstChunks(); - rowNum++; - if (buffer == null || buffer.length < imgInfo.samplesPerRowP) - buffer = new int[imgInfo.samplesPerRowP]; - // swap + if (nrow == 0 && interlaced) + Arrays.fill(rowb, (byte) 0); // new subimage: reset filters: this is enough, see the swap that happens lines + // below + int bytesRead = imgInfo.bytesPerRow; // NOT including the filter byte + if (interlaced) { + if (nrow < 0 || nrow > deinterlacer.getRows() || (nrow != 0 && nrow != deinterlacer.getCurrRowSubimg() + 1)) + throw new PngjInputException("invalid row in interlaced mode: " + nrow); + deinterlacer.setRow(nrow); + bytesRead = (imgInfo.bitspPixel * deinterlacer.getPixelsToRead() + 7) / 8; + if (bytesRead < 1) + throw new PngjExceptionInternal("wtf??"); + } else { // check for non interlaced + if (nrow < 0 || nrow >= imgInfo.rows || nrow != rowNum + 1) + throw new PngjInputException("invalid row: " + nrow); + } + rowNum = nrow; + // swap buffers byte[] tmp = rowb; rowb = rowbprev; rowbprev = tmp; // loads in rowbfilter "raw" bytes, with filter - PngHelper.readBytes(idatIstream, rowbfilter, 0, rowbfilter.length); + PngHelperInternal.readBytes(idatIstream, rowbfilter, 0, bytesRead + 1); + offset = iIdatCstream.getOffset(); + if (offset < 0) + throw new PngjExceptionInternal("bad offset ??" + offset); + if (maxTotalBytesRead > 0 && offset >= maxTotalBytesRead) + throw new PngjInputException("Reading IDAT: Maximum total bytes to read exceeeded: " + maxTotalBytesRead + + " offset:" + offset); rowb[0] = 0; - unfilterRow(); + unfilterRow(bytesRead); rowb[0] = rowbfilter[0]; - convertRowFromBytes(buffer); - return buffer; + if ((rowNum == imgInfo.rows - 1 && !interlaced) || (interlaced && deinterlacer.isAtLastRow())) + readLastAndClose(); + return bytesRead; } /** - * This should be called after having read the last line. It reads extra chunks after IDAT, if present. + * Reads all the (remaining) file, skipping the pixels data. This is much more efficient that calling readRow(), + * specially for big files (about 10 times faster!), because it doesn't even decompress the IDAT stream and disables + * CRC check Use this if you are not interested in reading pixels,only metadata. */ - public void end() { - offset = (int) iIdatCstream.getOffset(); - try { - idatIstream.close(); - } catch (Exception e) { - } - readLastChunks(); + public void readSkippingAllRows() { + if (firstChunksNotYetRead()) + readFirstChunks(); + // we read directly from the compressed stream, we dont decompress nor chec CRC + iIdatCstream.disableCrcCheck(); try { - is.close(); - } catch (Exception e) { - throw new PngjInputException("error closing input stream!", e); + int r; + do { + r = iIdatCstream.read(rowbfilter, 0, rowbfilter.length); + } while (r >= 0); + } catch (IOException e) { + throw new PngjInputException("error in raw read of IDAT", e); } + offset = iIdatCstream.getOffset(); + if (offset < 0) + throw new PngjExceptionInternal("bad offset ??" + offset); + if (maxTotalBytesRead > 0 && offset >= maxTotalBytesRead) + throw new PngjInputException("Reading IDAT: Maximum total bytes to read exceeeded: " + maxTotalBytesRead + + " offset:" + offset); + readLastAndClose(); } - private void convertRowFromBytes(int[] buffer) { - // http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html - int i, j; - if (imgInfo.bitDepth <= 8) { - for (i = 0, j = 1; i < imgInfo.samplesPerRowP; i++) { - buffer[i] = (rowb[j++] & 0xFF); - } - } else { // 16 bitspc - for (i = 0, j = 1; i < imgInfo.samplesPerRowP; i++) { - buffer[i] = ((rowb[j++] & 0xFF) << 8) + (rowb[j++] & 0xFF); - } - } + /** + * Set total maximum bytes to read (0: unlimited; default: 200MB).
        + * These are the bytes read (not loaded) in the input stream. If exceeded, an exception will be thrown. + */ + public void setMaxTotalBytesRead(long maxTotalBytesToRead) { + this.maxTotalBytesRead = maxTotalBytesToRead; } - private void unfilterRow() { - int ftn = rowbfilter[0]; - FilterType ft = FilterType.getByVal(ftn); - if (ft == null) - throw new PngjInputException("Filter type " + ftn + " invalid"); - switch (ft) { - case FILTER_NONE: - unfilterRowNone(); - break; - case FILTER_SUB: - unfilterRowSub(); - break; - case FILTER_UP: - unfilterRowUp(); - break; - case FILTER_AVERAGE: - unfilterRowAverage(); - break; - case FILTER_PAETH: - unfilterRowPaeth(); - break; - default: - throw new PngjInputException("Filter type " + ftn + " not implemented"); - } + /** + * @return Total maximum bytes to read. + */ + public long getMaxTotalBytesRead() { + return maxTotalBytesRead; } - private void unfilterRowNone() { - for (int i = 1; i <= imgInfo.bytesPerRow; i++) { - rowb[i] = (byte) (rowbfilter[i]); - } + /** + * Set total maximum bytes to load from ancillary chunks (0: unlimited; default: 5Mb).
        + * If exceeded, some chunks will be skipped + */ + public void setMaxBytesMetadata(int maxBytesChunksToLoad) { + this.maxBytesMetadata = maxBytesChunksToLoad; } - private void unfilterRowSub() { - int i, j; - for (i = 1; i <= imgInfo.bytesPixel; i++) { - rowb[i] = (byte) (rowbfilter[i]); - } - for (j = 1, i = imgInfo.bytesPixel + 1; i <= imgInfo.bytesPerRow; i++, j++) { - rowb[i] = (byte) (rowbfilter[i] + rowb[j]); - } + /** + * @return Total maximum bytes to load from ancillary ckunks. + */ + public int getMaxBytesMetadata() { + return maxBytesMetadata; } - private void unfilterRowUp() { - for (int i = 1; i <= imgInfo.bytesPerRow; i++) { - rowb[i] = (byte) (rowbfilter[i] + rowbprev[i]); - } + /** + * Set maximum size in bytes for individual ancillary chunks (0: unlimited; default: 2MB).
        + * Chunks exceeding this length will be skipped (the CRC will not be checked) and the chunk will be saved as a + * PngChunkSkipped object. See also setSkipChunkIds + */ + public void setSkipChunkMaxSize(int skipChunksBySize) { + this.skipChunkMaxSize = skipChunksBySize; } - private void unfilterRowAverage() { - int i, j, x; - for (j = 1 - imgInfo.bytesPixel, i = 1; i <= imgInfo.bytesPerRow; i++, j++) { - x = j > 0 ? (rowb[j] & 0xff) : 0; - rowb[i] = (byte) (rowbfilter[i] + (x + (rowbprev[i] & 0xFF)) / 2); - } + /** + * @return maximum size in bytes for individual ancillary chunks. + */ + public int getSkipChunkMaxSize() { + return skipChunkMaxSize; } - private void unfilterRowPaeth() { - int i, j, x, y; - for (j = 1 - imgInfo.bytesPixel, i = 1; i <= imgInfo.bytesPerRow; i++, j++) { - x = j > 0 ? (rowb[j] & 0xFF) : 0; - y = j > 0 ? (rowbprev[j] & 0xFF) : 0; - rowb[i] = (byte) (rowbfilter[i] + FilterType.filterPaethPredictor(x, rowbprev[i] & 0xFF, y)); - } + /** + * Chunks ids to be skipped.
        + * These chunks will be skipped (the CRC will not be checked) and the chunk will be saved as a PngChunkSkipped + * object. See also setSkipChunkMaxSize + */ + public void setSkipChunkIds(String[] skipChunksById) { + this.skipChunkIds = skipChunksById == null ? new String[] {} : skipChunksById; } - public ChunkLoadBehaviour getChunkLoadBehaviour() { - return chunkLoadBehaviour; + /** + * @return Chunk-IDs to be skipped. + */ + public String[] getSkipChunkIds() { + return skipChunkIds; } - public void setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour) { - this.chunkLoadBehaviour = chunkLoadBehaviour; + /** + * if true, input stream will be closed after ending read + *

        + * default=true + */ + public void setShouldCloseStream(boolean shouldCloseStream) { + this.shouldCloseStream = shouldCloseStream; } - private boolean firstChunksNotYetRead() { - return currentChunkGroup < ChunkList.CHUNK_GROUP_1_AFTERIDHR; + /** + * Normally this does nothing, but it can be used to force a premature closing. Its recommended practice to call it + * after reading the image pixels. + */ + public void end() { + if (currentChunkGroup < ChunksList.CHUNK_GROUP_6_END) + close(); } - public ChunkList getChunksList() { - if (firstChunksNotYetRead()) - readFirstChunks(); - return chunksList; + /** + * Interlaced PNG is accepted -though not welcomed- now... + */ + public boolean isInterlaced() { + return interlaced; } - public PngMetadata getMetadata() { - if (firstChunksNotYetRead()) - readFirstChunks(); - return metadata; + /** + * set/unset "unpackedMode"
        + * If false (default) packed types (bitdepth=1,2 or 4) will keep several samples packed in one element (byte or int)
        + * If true, samples will be unpacked on reading, and each element in the scanline will be sample. This implies more + * processing and memory, but it's the most efficient option if you intend to read individual pixels.
        + * This option should only be set before start reading. + * + * @param unPackedMode + */ + public void setUnpackedMode(boolean unPackedMode) { + this.unpackedMode = unPackedMode; + } + + /** + * @see PngReader#setUnpackedMode(boolean) + */ + public boolean isUnpackedMode() { + return unpackedMode; + } + + /** + * Disables the CRC integrity check in IDAT chunks and ancillary chunks, this gives a slight increase in reading + * speed for big files + */ + public void setCrcCheckDisabled() { + crcEnabled = false; + } + + /** + * Just for testing. TO be called after ending reading, only if initCrctest() was called before start + * + * @return CRC of the raw pixels values + */ + long getCrctestVal() { + return crctest.getValue(); + } + + /** + * Inits CRC object and enables CRC calculation + */ + void initCrctest() { + this.crctest = new CRC32(); } + /** + * Basic info, for debugging. + */ public String toString() { // basic info return "filename=" + filename + " " + imgInfo.toString(); } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java index ee8472bf0..601cd96c0 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngWriter.java @@ -7,51 +7,84 @@ import java.util.List; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; +import jogamp.opengl.util.pngj.ImageLine.SampleType; import jogamp.opengl.util.pngj.chunks.ChunkCopyBehaviour; import jogamp.opengl.util.pngj.chunks.ChunkHelper; -import jogamp.opengl.util.pngj.chunks.ChunkList; +import jogamp.opengl.util.pngj.chunks.ChunksList; +import jogamp.opengl.util.pngj.chunks.ChunksListForWrite; import jogamp.opengl.util.pngj.chunks.PngChunk; import jogamp.opengl.util.pngj.chunks.PngChunkIEND; import jogamp.opengl.util.pngj.chunks.PngChunkIHDR; +import jogamp.opengl.util.pngj.chunks.PngChunkSkipped; import jogamp.opengl.util.pngj.chunks.PngChunkTextVar; import jogamp.opengl.util.pngj.chunks.PngMetadata; - /** - * Writes a PNG image, line by line. + * Writes a PNG image */ public class PngWriter { public final ImageInfo imgInfo; - protected int compLevel = 6; // zip compression level 0 - 9 - private int deflaterStrategy = Deflater.FILTERED; - protected FilterWriteStrategy filterStrat; + private final String filename; // optional, can be a description + + /** + * last read row number, starting from 0 + */ + protected int rowNum = -1; + + private final ChunksListForWrite chunksList; + private final PngMetadata metadata; // high level wrapper over chunkList + + /** + * Current chunk grounp, (0-6) already read or reading + *

        + * see {@link ChunksList} + */ protected int currentChunkGroup = -1; - protected int rowNum = -1; // current line number - // current line, one (packed) sample per element (layout differnt from rowb!) - protected int[] scanline = null; - protected byte[] rowb = null; // element 0 is filter type! - protected byte[] rowbprev = null; // rowb prev - protected byte[] rowbfilter = null; // current line with filter + /** + * PNG filter strategy + */ + protected FilterWriteStrategy filterStrat; - protected final OutputStream os; - protected final String filename; // optional, can be a description + /** + * zip compression level 0 - 9 + */ + private int compLevel = 6; + private boolean shouldCloseStream = true; // true: closes stream after ending write private PngIDatChunkOutputStream datStream; + private DeflaterOutputStream datStreamDeflated; - private final ChunkList chunkList; - private final PngMetadata metadata; // high level wrapper over chunkList + /** + * Deflate algortithm compression strategy + */ + private int deflaterStrategy = Deflater.FILTERED; + + private int[] histox = new int[256]; // auxiliar buffer, only used by reportResultsForFilter + + private int idatMaxSize = 0; // 0=use default (PngIDatChunkOutputStream 32768) + + private final OutputStream os; + + protected byte[] rowb = null; // element 0 is filter type! + protected byte[] rowbfilter = null; // current line with filter + + protected byte[] rowbprev = null; // rowb prev + + // this only influences the 1-2-4 bitdepth format - and if we pass a ImageLine to writeRow, this is ignored + private boolean unpackedMode = false; public PngWriter(OutputStream outputStream, ImageInfo imgInfo) { this(outputStream, imgInfo, "[NO FILENAME AVAILABLE]"); } /** - * Constructs a new PngWriter from a output stream. + * Constructs a new PngWriter from a output stream. After construction nothing is writen yet. You still can set some + * parameters (compression, filters) and queue chunks before start writing the pixels. *

        * See also FileHelper.createPngWriter() if available. * @@ -67,171 +100,156 @@ public class PngWriter { this.os = outputStream; this.imgInfo = imgInfo; // prealloc - scanline = new int[imgInfo.samplesPerRowP]; rowb = new byte[imgInfo.bytesPerRow + 1]; rowbprev = new byte[rowb.length]; rowbfilter = new byte[rowb.length]; - datStream = new PngIDatChunkOutputStream(this.os); - chunkList = new ChunkList(imgInfo); - metadata = new PngMetadata(chunkList, false); - filterStrat = new FilterWriteStrategy(imgInfo, FilterType.FILTER_DEFAULT); + chunksList = new ChunksListForWrite(imgInfo); + metadata = new PngMetadata(chunksList); + filterStrat = new FilterWriteStrategy(imgInfo, FilterType.FILTER_DEFAULT); // can be changed } - /** - * Write id signature and also "IHDR" chunk - */ - private void writeSignatureAndIHDR() { - currentChunkGroup = ChunkList.CHUNK_GROUP_0_IDHR; - if (datStreamDeflated == null) { - Deflater def = new Deflater(compLevel); - def.setStrategy(deflaterStrategy); - datStreamDeflated = new DeflaterOutputStream(datStream, def, 8192); + private void init() { + datStream = new PngIDatChunkOutputStream(this.os, idatMaxSize); + Deflater def = new Deflater(compLevel); + def.setStrategy(deflaterStrategy); + datStreamDeflated = new DeflaterOutputStream(datStream, def); + writeSignatureAndIHDR(); + writeFirstChunks(); + } + + private void reportResultsForFilter(int rown, FilterType type, boolean tentative) { + Arrays.fill(histox, 0); + int s = 0, v; + for (int i = 1; i <= imgInfo.bytesPerRow; i++) { + v = rowbfilter[i]; + if (v < 0) + s -= (int) v; + else + s += (int) v; + histox[v & 0xFF]++; } - PngHelper.writeBytes(os, PngHelper.pngIdBytes); // signature - PngChunkIHDR ihdr = new PngChunkIHDR(imgInfo); - // http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html - ihdr.setCols(imgInfo.cols); - ihdr.setRows(imgInfo.rows); - ihdr.setBitspc(imgInfo.bitDepth); - int colormodel = 0; - if (imgInfo.alpha) - colormodel += 0x04; - if (imgInfo.indexed) - colormodel += 0x01; - if (!imgInfo.greyscale) - colormodel += 0x02; - ihdr.setColormodel(colormodel); - ihdr.setCompmeth(0); // compression method 0=deflate - ihdr.setFilmeth(0); // filter method (0) - ihdr.setInterlaced(0); // we never interlace - ihdr.createChunk().writeChunk(os); + filterStrat.fillResultsForFilter(rown, type, s, histox, tentative); + } + private void writeEndChunk() { + PngChunkIEND c = new PngChunkIEND(imgInfo); + c.createRawChunk().writeChunk(os); } private void writeFirstChunks() { int nw = 0; - currentChunkGroup = ChunkList.CHUNK_GROUP_1_AFTERIDHR; - nw = chunkList.writeChunks(os, currentChunkGroup); - currentChunkGroup = ChunkList.CHUNK_GROUP_2_PLTE; - nw = chunkList.writeChunks(os, currentChunkGroup); + currentChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR; + nw = chunksList.writeChunks(os, currentChunkGroup); + currentChunkGroup = ChunksList.CHUNK_GROUP_2_PLTE; + nw = chunksList.writeChunks(os, currentChunkGroup); if (nw > 0 && imgInfo.greyscale) throw new PngjOutputException("cannot write palette for this format"); if (nw == 0 && imgInfo.indexed) throw new PngjOutputException("missing palette"); - currentChunkGroup = ChunkList.CHUNK_GROUP_3_AFTERPLTE; - nw = chunkList.writeChunks(os, currentChunkGroup); - currentChunkGroup = ChunkList.CHUNK_GROUP_4_IDAT; + currentChunkGroup = ChunksList.CHUNK_GROUP_3_AFTERPLTE; + nw = chunksList.writeChunks(os, currentChunkGroup); + currentChunkGroup = ChunksList.CHUNK_GROUP_4_IDAT; } private void writeLastChunks() { // not including end - currentChunkGroup = ChunkList.CHUNK_GROUP_5_AFTERIDAT; - chunkList.writeChunks(os, currentChunkGroup); + currentChunkGroup = ChunksList.CHUNK_GROUP_5_AFTERIDAT; + chunksList.writeChunks(os, currentChunkGroup); // should not be unwriten chunks - List pending = chunkList.getQueuedChunks(); + List pending = chunksList.getQueuedChunks(); if (!pending.isEmpty()) throw new PngjOutputException(pending.size() + " chunks were not written! Eg: " + pending.get(0).toString()); - currentChunkGroup = ChunkList.CHUNK_GROUP_6_END; - } - - private void writeEndChunk() { - PngChunkIEND c = new PngChunkIEND(imgInfo); - c.createChunk().writeChunk(os); + currentChunkGroup = ChunksList.CHUNK_GROUP_6_END; } /** - * Writes a full image row. This must be called sequentially from n=0 to n=rows-1 One integer per sample , in the - * natural order: R G B R G B ... (or R G B A R G B A... if has alpha) The values should be between 0 and 255 for 8 - * bitspc images, and between 0- 65535 form 16 bitspc images (this applies also to the alpha channel if present) The - * array can be reused. - * - * @param newrow - * Array of pixel values - * @param rown - * Row number, from 0 (top) to rows-1 (bottom). This is just used as a check. Pass -1 if you want to - * autocompute it + * Write id signature and also "IHDR" chunk */ - public void writeRow(int[] newrow, int rown) { - if (rown == 0) { - writeSignatureAndIHDR(); - writeFirstChunks(); - } - if (rown < -1 || rown > imgInfo.rows) - throw new RuntimeException("invalid value for row " + rown); - rowNum++; - if (rown >= 0 && rowNum != rown) - throw new RuntimeException("rows must be written in strict consecutive order: tried to write row " + rown - + ", expected=" + rowNum); - scanline = newrow; - // swap - byte[] tmp = rowb; - rowb = rowbprev; - rowbprev = tmp; - convertRowToBytes(); - filterRow(rown); - try { - datStreamDeflated.write(rowbfilter, 0, imgInfo.bytesPerRow + 1); - } catch (IOException e) { - throw new PngjOutputException(e); - } - } + private void writeSignatureAndIHDR() { + currentChunkGroup = ChunksList.CHUNK_GROUP_0_IDHR; - /** - * Same as writeRow(int[] newrow, int rown), but does not check row number - * - * @param newrow - */ - public void writeRow(int[] newrow) { - writeRow(newrow, -1); - } + PngHelperInternal.writeBytes(os, PngHelperInternal.getPngIdSignature()); // signature + PngChunkIHDR ihdr = new PngChunkIHDR(imgInfo); + // http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html + ihdr.setCols(imgInfo.cols); + ihdr.setRows(imgInfo.rows); + ihdr.setBitspc(imgInfo.bitDepth); + int colormodel = 0; + if (imgInfo.alpha) + colormodel += 0x04; + if (imgInfo.indexed) + colormodel += 0x01; + if (!imgInfo.greyscale) + colormodel += 0x02; + ihdr.setColormodel(colormodel); + ihdr.setCompmeth(0); // compression method 0=deflate + ihdr.setFilmeth(0); // filter method (0) + ihdr.setInterlaced(0); // we never interlace + ihdr.createRawChunk().writeChunk(os); - /** - * Writes line. See writeRow(int[] newrow, int rown) - */ - public void writeRow(ImageLine imgline, int rownumber) { - writeRow(imgline.scanline, rownumber); } - /** - * Writes line, checks that the row number is consistent with that of the ImageLine See writeRow(int[] newrow, int - * rown) - * - * @deprecated Better use writeRow(ImageLine imgline, int rownumber) - */ - public void writeRow(ImageLine imgline) { - writeRow(imgline.scanline, imgline.getRown()); - } + protected void encodeRowFromByte(byte[] row) { + if (row.length == imgInfo.samplesPerRowPacked) { + // some duplication of code - because this case is typical and it works faster this way + int j = 1; + if (imgInfo.bitDepth <= 8) { + for (byte x : row) { // optimized + rowb[j++] = x; + } + } else { // 16 bitspc + for (byte x : row) { // optimized + rowb[j] = x; + j += 2; + } + } + } else { + // perhaps we need to pack? + if (row.length >= imgInfo.samplesPerRow && unpackedMode) + ImageLine.packInplaceByte(imgInfo, row, row, false); // row is packed in place! + if (imgInfo.bitDepth <= 8) { + for (int i = 0, j = 1; i < imgInfo.samplesPerRowPacked; i++) { + rowb[j++] = row[i]; + } + } else { // 16 bitspc + for (int i = 0, j = 1; i < imgInfo.samplesPerRowPacked; i++) { + rowb[j++] = row[i]; + rowb[j++] = 0; + } + } - /** - * Finalizes the image creation and closes the stream. This MUST be called after writing the lines. - */ - public void end() { - if (rowNum != imgInfo.rows - 1) - throw new PngjOutputException("all rows have not been written"); - try { - datStreamDeflated.finish(); - datStream.flush(); - writeLastChunks(); - writeEndChunk(); - os.close(); - } catch (IOException e) { - throw new PngjOutputException(e); } } - private int[] histox = new int[256]; // auxiliar buffer, only used by reportResultsForFilter - - private void reportResultsForFilter(int rown, FilterType type, boolean tentative) { - Arrays.fill(histox, 0); - int s = 0, v; - for (int i = 1; i <= imgInfo.bytesPerRow; i++) { - v = rowbfilter[i]; - if (v < 0) - s -= (int) v; - else - s += (int) v; - histox[v & 0xFF]++; + protected void encodeRowFromInt(int[] row) { + // http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html + if (row.length == imgInfo.samplesPerRowPacked) { + // some duplication of code - because this case is typical and it works faster this way + int j = 1; + if (imgInfo.bitDepth <= 8) { + for (int x : row) { // optimized + rowb[j++] = (byte) x; + } + } else { // 16 bitspc + for (int x : row) { // optimized + rowb[j++] = (byte) (x >> 8); + rowb[j++] = (byte) (x); + } + } + } else { + // perhaps we need to pack? + if (row.length >= imgInfo.samplesPerRow && unpackedMode) + ImageLine.packInplaceInt(imgInfo, row, row, false); // row is packed in place! + if (imgInfo.bitDepth <= 8) { + for (int i = 0, j = 1; i < imgInfo.samplesPerRowPacked; i++) { + rowb[j++] = (byte) (row[i]); + } + } else { // 16 bitspc + for (int i = 0, j = 1; i < imgInfo.samplesPerRowPacked; i++) { + rowb[j++] = (byte) (row[i] >> 8); + rowb[j++] = (byte) (row[i]); + } + } } - filterStrat.fillResultsForFilter(rown, type, s, histox, tentative); } private void filterRow(int rown) { @@ -268,123 +286,98 @@ public class PngWriter { filterRowPaeth(); break; default: - throw new PngjOutputException("Filter type " + filterType + " not implemented"); + throw new PngjUnsupportedException("Filter type " + filterType + " not implemented"); } reportResultsForFilter(rown, filterType, false); } - protected int sumRowbfilter() { // sums absolute value - int s = 0; - for (int i = 1; i <= imgInfo.bytesPerRow; i++) - if (rowbfilter[i] < 0) - s -= (int) rowbfilter[i]; - else - s += (int) rowbfilter[i]; - return s; + private void prepareEncodeRow(int rown) { + if (datStream == null) + init(); + rowNum++; + if (rown >= 0 && rowNum != rown) + throw new PngjOutputException("rows must be written in order: expected:" + rowNum + " passed:" + rown); + // swap + byte[] tmp = rowb; + rowb = rowbprev; + rowbprev = tmp; } - protected void filterRowNone() { - for (int i = 1; i <= imgInfo.bytesPerRow; i++) { - rowbfilter[i] = (byte) rowb[i]; + private void filterAndSend(int rown) { + filterRow(rown); + try { + datStreamDeflated.write(rowbfilter, 0, imgInfo.bytesPerRow + 1); + } catch (IOException e) { + throw new PngjOutputException(e); } } - protected void filterRowSub() { - int i, j; - for (i = 1; i <= imgInfo.bytesPixel; i++) - rowbfilter[i] = (byte) rowb[i]; - for (j = 1, i = imgInfo.bytesPixel + 1; i <= imgInfo.bytesPerRow; i++, j++) { - rowbfilter[i] = (byte) (rowb[i] - rowb[j]); + protected void filterRowAverage() { + int i, j, imax; + imax = imgInfo.bytesPerRow; + for (j = 1 - imgInfo.bytesPixel, i = 1; i <= imax; i++, j++) { + rowbfilter[i] = (byte) (rowb[i] - ((rowbprev[i] & 0xFF) + (j > 0 ? (rowb[j] & 0xFF) : 0)) / 2); } } - protected void filterRowUp() { + protected void filterRowNone() { for (int i = 1; i <= imgInfo.bytesPerRow; i++) { - rowbfilter[i] = (byte) (rowb[i] - rowbprev[i]); - } - } - - protected void filterRowAverage() { - int i, j; - for (j = 1 - imgInfo.bytesPixel, i = 1; i <= imgInfo.bytesPerRow; i++, j++) { - rowbfilter[i] = (byte) (rowb[i] - ((rowbprev[i] & 0xFF) + (j > 0 ? (rowb[j] & 0xFF) : 0)) / 2); + rowbfilter[i] = (byte) rowb[i]; } } protected void filterRowPaeth() { - int i, j; - for (j = 1 - imgInfo.bytesPixel, i = 1; i <= imgInfo.bytesPerRow; i++, j++) { - rowbfilter[i] = (byte) (rowb[i] - FilterType.filterPaethPredictor(j > 0 ? (rowb[j] & 0xFF) : 0, - rowbprev[i] & 0xFF, j > 0 ? (rowbprev[j] & 0xFF) : 0)); + int i, j, imax; + imax = imgInfo.bytesPerRow; + for (j = 1 - imgInfo.bytesPixel, i = 1; i <= imax; i++, j++) { + // rowbfilter[i] = (byte) (rowb[i] - PngHelperInternal.filterPaethPredictor(j > 0 ? (rowb[j] & 0xFF) : 0, + // rowbprev[i] & 0xFF, j > 0 ? (rowbprev[j] & 0xFF) : 0)); + rowbfilter[i] = (byte) PngHelperInternal.filterRowPaeth(rowb[i], j > 0 ? (rowb[j] & 0xFF) : 0, + rowbprev[i] & 0xFF, j > 0 ? (rowbprev[j] & 0xFF) : 0); } } - protected void convertRowToBytes() { - // http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html + protected void filterRowSub() { int i, j; - if (imgInfo.bitDepth <= 8) { - for (i = 0, j = 1; i < imgInfo.samplesPerRowP; i++) { - rowb[j++] = (byte) (scanline[i]); - } - } else { // 16 bitspc - for (i = 0, j = 1; i < imgInfo.samplesPerRowP; i++) { - // x = (int) (scanline[i]) & 0xFFFF; - rowb[j++] = (byte) (scanline[i] >> 8); - rowb[j++] = (byte) (scanline[i]); - } + for (i = 1; i <= imgInfo.bytesPixel; i++) + rowbfilter[i] = (byte) rowb[i]; + for (j = 1, i = imgInfo.bytesPixel + 1; i <= imgInfo.bytesPerRow; i++, j++) { + // !!! rowbfilter[i] = (byte) (rowb[i] - rowb[j]); + rowbfilter[i] = (byte) PngHelperInternal.filterRowSub(rowb[i], rowb[j]); } } - // /// several getters / setters - all this setters are optional - - /** - * Filename or description, from the optional constructor argument. - */ - public String getFilename() { - return filename; + protected void filterRowUp() { + for (int i = 1; i <= imgInfo.bytesPerRow; i++) { + // rowbfilter[i] = (byte) (rowb[i] - rowbprev[i]); !!! + rowbfilter[i] = (byte) PngHelperInternal.filterRowUp(rowb[i], rowbprev[i]); + } } - /** - * Sets internal prediction filter type, or strategy to choose it. - *

        - * This must be called just after constructor, before starting writing. - *

        - * See also setCompLevel() - * - * @param filterType - * One of the five prediction types or strategy to choose it (see PngFilterType) Recommended - * values: DEFAULT (default) or AGGRESIVE - */ - public void setFilterType(FilterType filterType) { - filterStrat = new FilterWriteStrategy(imgInfo, filterType); + protected int sumRowbfilter() { // sums absolute value + int s = 0; + for (int i = 1; i <= imgInfo.bytesPerRow; i++) + if (rowbfilter[i] < 0) + s -= (int) rowbfilter[i]; + else + s += (int) rowbfilter[i]; + return s; } /** - * Sets compression level of ZIP algorithm. + * copy chunks from reader - copy_mask : see ChunksToWrite.COPY_XXX *

        - * This must be called just after constructor, before starting writing. + * If we are after idat, only considers those chunks after IDAT in PngReader *

        - * See also setFilterType() - * - * @param compLevel - * between 0 and 9 (default:6 , recommended: 6 or more) - */ - public void setCompLevel(int compLevel) { - if (compLevel < 0 || compLevel > 9) - throw new PngjException("Compression level invalid (" + compLevel + ") Must be 0..9"); - this.compLevel = compLevel; - } - - /** - * copy chunks from reader - copy_mask : see ChunksToWrite.COPY_XXX - * - * If we are after idat, only considers those chunks after IDAT in PngReader TODO: this should be more customizable + * TODO: this should be more customizable */ private void copyChunks(PngReader reader, int copy_mask, boolean onlyAfterIdat) { - boolean idatDone = currentChunkGroup >= ChunkList.CHUNK_GROUP_4_IDAT; + boolean idatDone = currentChunkGroup >= ChunksList.CHUNK_GROUP_4_IDAT; + if (onlyAfterIdat && reader.getCurrentChunkGroup() < ChunksList.CHUNK_GROUP_6_END) + throw new PngjExceptionInternal("tried to copy last chunks but reader has not ended"); for (PngChunk chunk : reader.getChunksList().getChunks()) { int group = chunk.getChunkGroup(); - if (group < ChunkList.CHUNK_GROUP_4_IDAT && idatDone) + if (group < ChunksList.CHUNK_GROUP_4_IDAT && idatDone) continue; boolean copy = false; if (chunk.crit) { @@ -413,9 +406,11 @@ public class PngWriter { && !(ChunkHelper.isUnknown(chunk) || text || chunk.id.equals(ChunkHelper.hIST) || chunk.id .equals(ChunkHelper.tIME))) copy = true; + if (chunk instanceof PngChunkSkipped) + copy = false; } if (copy) { - chunkList.queueChunk(PngChunk.cloneChunk(chunk, imgInfo), !chunk.allowsMultiple(), false); + chunksList.queue(PngChunk.cloneChunk(chunk, imgInfo)); } } } @@ -451,12 +446,228 @@ public class PngWriter { copyChunks(reader, copy_mask, true); } - public ChunkList getChunkList() { - return chunkList; + /** + * Computes compressed size/raw size, approximate. + *

        + * Actually: compressed size = total size of IDAT data , raw size = uncompressed pixel bytes = rows * (bytesPerRow + + * 1). + * + * This must be called after pngw.end() + */ + public double computeCompressionRatio() { + if (currentChunkGroup < ChunksList.CHUNK_GROUP_6_END) + throw new PngjOutputException("must be called after end()"); + double compressed = (double) datStream.getCountFlushed(); + double raw = (imgInfo.bytesPerRow + 1) * imgInfo.rows; + return compressed / raw; } + /** + * Finalizes the image creation and closes the stream. This MUST be called after writing the lines. + */ + public void end() { + if (rowNum != imgInfo.rows - 1) + throw new PngjOutputException("all rows have not been written"); + try { + datStreamDeflated.finish(); + datStream.flush(); + writeLastChunks(); + writeEndChunk(); + if (shouldCloseStream) + os.close(); + } catch (IOException e) { + throw new PngjOutputException(e); + } + } + + /** + * returns the chunks list (queued and writen chunks) + */ + public ChunksListForWrite getChunksList() { + return chunksList; + } + + /** + * Filename or description, from the optional constructor argument. + */ + public String getFilename() { + return filename; + } + + /** + * High level wrapper over chunksList for metadata handling + */ public PngMetadata getMetadata() { return metadata; } + /** + * Sets compression level of ZIP algorithm. + *

        + * This must be called just after constructor, before starting writing. + *

        + * See also setFilterType() + * + * @param compLevel + * between 0 and 9 (default:6 , recommended: 6 or more) + */ + public void setCompLevel(int compLevel) { + if (compLevel < 0 || compLevel > 9) + throw new PngjOutputException("Compression level invalid (" + compLevel + ") Must be 0..9"); + this.compLevel = compLevel; + } + + /** + * Sets internal prediction filter type, or strategy to choose it. + *

        + * This must be called just after constructor, before starting writing. + *

        + * See also setCompLevel() + * + * @param filterType + * One of the five prediction types or strategy to choose it (see PngFilterType) Recommended + * values: DEFAULT (default) or AGGRESIVE + */ + public void setFilterType(FilterType filterType) { + filterStrat = new FilterWriteStrategy(imgInfo, filterType); + } + + /** + * Sets maximum size of IDAT fragments. This has little effect on performance you should rarely call this + *

        + * + * @param idatMaxSize + * default=0 : use defaultSize (32K) + */ + public void setIdatMaxSize(int idatMaxSize) { + this.idatMaxSize = idatMaxSize; + } + + /** + * if true, input stream will be closed after ending write + *

        + * default=true + */ + public void setShouldCloseStream(boolean shouldCloseStream) { + this.shouldCloseStream = shouldCloseStream; + } + + /** + * Deflater strategy: one of Deflater.FILTERED Deflater.HUFFMAN_ONLY Deflater.DEFAULT_STRATEGY + *

        + * Default: Deflater.FILTERED . This should be changed very rarely. + */ + public void setDeflaterStrategy(int deflaterStrategy) { + this.deflaterStrategy = deflaterStrategy; + } + + /** + * Writes line, checks that the row number is consistent with that of the ImageLine See writeRow(int[] newrow, int + * rown) + * + * @deprecated Better use writeRow(ImageLine imgline, int rownumber) + */ + public void writeRow(ImageLine imgline) { + writeRow(imgline.scanline, imgline.getRown()); + } + + /** + * Writes line. See writeRow(int[] newrow, int rown) + * + * The packed flag of the imageline is honoured! + * + * @see #writeRowInt(int[], int) + */ + public void writeRow(ImageLine imgline, int rownumber) { + unpackedMode = imgline.samplesUnpacked; + if (imgline.sampleType == SampleType.INT) + writeRowInt(imgline.scanline, rownumber); + else + writeRowByte(imgline.scanlineb, rownumber); + } + + /** + * Same as writeRow(int[] newrow, int rown), but does not check row number + * + * @param newrow + */ + public void writeRow(int[] newrow) { + writeRow(newrow, -1); + } + + /** + * Alias to writeRowInt + * + * @see #writeRowInt(int[], int) + */ + public void writeRow(int[] newrow, int rown) { + writeRowInt(newrow, rown); + } + + /** + * Writes a full image row. + *

        + * This must be called sequentially from n=0 to n=rows-1 One integer per sample , in the natural order: R G B R G B + * ... (or R G B A R G B A... if has alpha) The values should be between 0 and 255 for 8 bitspc images, and between + * 0- 65535 form 16 bitspc images (this applies also to the alpha channel if present) The array can be reused. + *

        + * Warning: the array might be modified in some cases (unpacked row with low bitdepth) + *

        + * + * @param newrow + * Array of pixel values. Warning: the array size should be exact (samplesPerRowP) + * @param rown + * Row number, from 0 (top) to rows-1 (bottom). This is just used as a check. Pass -1 if you want to + * autocompute it + */ + public void writeRowInt(int[] newrow, int rown) { + prepareEncodeRow(rown); + encodeRowFromInt(newrow); + filterAndSend(rown); + } + + /** + * Same semantics as writeRowInt but using bytes. Each byte is still a sample. If 16bitdepth, we are passing only + * the most significant byte (and hence losing some info) + * + * @see PngWriter#writeRowInt(int[], int) + */ + public void writeRowByte(byte[] newrow, int rown) { + prepareEncodeRow(rown); + encodeRowFromByte(newrow); + filterAndSend(rown); + } + + /** + * Writes all the pixels, calling writeRowInt() for each image row + */ + public void writeRowsInt(int[][] image) { + for (int i = 0; i < imgInfo.rows; i++) + writeRowInt(image[i], i); + } + + /** + * Writes all the pixels, calling writeRowByte() for each image row + */ + public void writeRowsByte(byte[][] image) { + for (int i = 0; i < imgInfo.rows; i++) + writeRowByte(image[i], i); + } + + public boolean isUnpackedMode() { + return unpackedMode; + } + + /** + * If false (default), and image has bitdepth 1-2-4, the scanlines passed are assumed to be already packed. + *

        + * If true, each element is a sample, the writer will perform the packing if necessary. + *

        + * Warning: when using {@link #writeRow(ImageLine, int)} (recommended) the packed flag of the ImageLine + * object overrides (and overwrites!) this field. + */ + public void setUseUnPackedMode(boolean useUnpackedMode) { + this.unpackedMode = useUnpackedMode; + } + } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java new file mode 100644 index 000000000..963abc50e --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngjExceptionInternal.java @@ -0,0 +1,23 @@ +package jogamp.opengl.util.pngj; + +/** + * Exception for anomalous internal problems (sort of asserts) that point to some issue with the library + * + * @author Hernan J Gonzalez + * + */ +public class PngjExceptionInternal extends RuntimeException { + private static final long serialVersionUID = 1L; + + public PngjExceptionInternal(String message, Throwable cause) { + super(message, cause); + } + + public PngjExceptionInternal(String message) { + super(message); + } + + public PngjExceptionInternal(Throwable cause) { + super(cause); + } +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java b/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java index bbec247fb..a5bad666c 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/ProgressiveOutputStream.java @@ -8,6 +8,7 @@ import java.io.IOException; */ abstract class ProgressiveOutputStream extends ByteArrayOutputStream { private final int size; + private long countFlushed = 0; public ProgressiveOutputStream(int size) { this.size = size; @@ -60,6 +61,7 @@ abstract class ProgressiveOutputStream extends ByteArrayOutputStream { if (nb == 0) return; flushBuffer(buf, nb); + countFlushed += nb; int bytesleft = count - nb; count = bytesleft; if (bytesleft > 0) @@ -67,5 +69,9 @@ abstract class ProgressiveOutputStream extends ByteArrayOutputStream { } } - public abstract void flushBuffer(byte[] b, int n); + protected abstract void flushBuffer(byte[] b, int n); + + public long getCountFlushed() { + return countFlushed; + } } \ No newline at end of file diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkCopyBehaviour.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkCopyBehaviour.java index 43c0cb135..a2d976fac 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkCopyBehaviour.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkCopyBehaviour.java @@ -1,8 +1,9 @@ package jogamp.opengl.util.pngj.chunks; /** - * Chunk copy policy to apply when copyng from a pngReader to a pngWriter http://www.w3.org/TR/PNG/#14 + * Chunk copy policy to apply when copyng from a pngReader to a pngWriter. *

        + * http://www.w3.org/TR/PNG/#14
        * These are masks, can be OR-ed **/ public class ChunkCopyBehaviour { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java index 26dafd4eb..ed091d35a 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java @@ -8,11 +8,13 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.Set; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; @@ -41,38 +43,83 @@ public class ChunkHelper { public static final String tEXt = "tEXt"; public static final String zTXt = "zTXt"; - public static Set KNOWN_CHUNKS_CRITICAL = PngHelper.asSet(IHDR, PLTE, IDAT, IEND); - + /** + * Converts to bytes using Latin1 (ISO-8859-1) + */ public static byte[] toBytes(String x) { - return x.getBytes(PngHelper.charsetLatin1); + return x.getBytes(PngHelperInternal.charsetLatin1); } + /** + * Converts to String using Latin1 (ISO-8859-1) + */ public static String toString(byte[] x) { - return new String(x, PngHelper.charsetLatin1); + return new String(x, PngHelperInternal.charsetLatin1); } - public static boolean isCritical(String id) { // critical chunk ? - // first letter is uppercase + /** + * Converts to String using Latin1 (ISO-8859-1) + */ + public static String toString(byte[] x, int offset, int len) { + return new String(x, offset, len, PngHelperInternal.charsetLatin1); + } + + /** + * Converts to bytes using UTF-8 + */ + public static byte[] toBytesUTF8(String x) { + return x.getBytes(PngHelperInternal.charsetUTF8); + } + + /** + * Converts to string using UTF-8 + */ + public static String toStringUTF8(byte[] x) { + return new String(x, PngHelperInternal.charsetUTF8); + } + + /** + * Converts to string using UTF-8 + */ + public static String toStringUTF8(byte[] x, int offset, int len) { + return new String(x, offset, len, PngHelperInternal.charsetUTF8); + } + + /** + * critical chunk : first letter is uppercase + */ + public static boolean isCritical(String id) { return (Character.isUpperCase(id.charAt(0))); } - public static boolean isPublic(String id) { // public chunk? - // second letter is uppercase + /** + * public chunk: second letter is uppercase + */ + public static boolean isPublic(String id) { // return (Character.isUpperCase(id.charAt(1))); } /** - * "Unknown" just means that our chunk factory (even when it has been augmented by client code) did not recognize its id + * Safe to copy chunk: fourth letter is lower case */ - public static boolean isUnknown(PngChunk c) { - return c instanceof PngChunkUNKNOWN; + public static boolean isSafeToCopy(String id) { + return (!Character.isUpperCase(id.charAt(3))); } - public static boolean isSafeToCopy(String id) { // safe to copy? - // fourth letter is lower case - return (!Character.isUpperCase(id.charAt(3))); + /** + * "Unknown" just means that our chunk factory (even when it has been augmented by client code) did not recognize + * its id + */ + public static boolean isUnknown(PngChunk c) { + return c instanceof PngChunkUNKNOWN; } + /** + * Finds position of null byte in array + * + * @param b + * @return -1 if not found + */ public static int posNullByte(byte[] b) { for (int i = 0; i < b.length; i++) if (b[i] == 0) @@ -80,6 +127,13 @@ public class ChunkHelper { return -1; } + /** + * Decides if a chunk should be loaded, according to a ChunkLoadBehaviour + * + * @param id + * @param behav + * @return true/false + */ public static boolean shouldLoad(String id, ChunkLoadBehaviour behav) { if (isCritical(id)) return true; @@ -131,4 +185,69 @@ public class ChunkHelper { return (v & mask) != 0; } + /** + * Returns only the chunks that "match" the predicate + * + * See also trimList() + */ + public static List filterList(List target, ChunkPredicate predicateKeep) { + List result = new ArrayList(); + for (PngChunk element : target) { + if (predicateKeep.match(element)) { + result.add(element); + } + } + return result; + } + + /** + * Remove (in place) the chunks that "match" the predicate + * + * See also filterList + */ + public static int trimList(List target, ChunkPredicate predicateRemove) { + Iterator it = target.iterator(); + int cont = 0; + while (it.hasNext()) { + PngChunk c = it.next(); + if (predicateRemove.match(c)) { + it.remove(); + cont++; + } + } + return cont; + } + + /** + * MY adhoc criteria: two chunks are "equivalent" ("practically equal") if they have same id and (perhaps, if + * multiple are allowed) if the match also in some "internal key" (eg: key for string values, palette for sPLT, etc) + * + * Notice that the use of this is optional, and that the PNG standard allows Text chunks that have same key + * + * @return true if "equivalent" + */ + public static final boolean equivalent(PngChunk c1, PngChunk c2) { + if (c1 == c2) + return true; + if (c1 == null || c2 == null || !c1.id.equals(c2.id)) + return false; + // same id + if (c1.getClass() != c2.getClass()) + return false; // should not happen + if (!c2.allowsMultiple()) + return true; + if (c1 instanceof PngChunkTextVar) { + return ((PngChunkTextVar) c1).getKey().equals(((PngChunkTextVar) c2).getKey()); + } + if (c1 instanceof PngChunkSPLT) { + return ((PngChunkSPLT) c1).getPalName().equals(((PngChunkSPLT) c2).getPalName()); + } + // unknown chunks that allow multiple? consider they don't match + return false; + } + + public static boolean isText(PngChunk c) { + return c instanceof PngChunkTextVar; + } + } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkList.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkList.java deleted file mode 100644 index badbbd0e8..000000000 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkList.java +++ /dev/null @@ -1,282 +0,0 @@ -package jogamp.opengl.util.pngj.chunks; - -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngjException; - - -/** - * All chunks that form an image, read or to be written - * - * chunks include all chunks, but IDAT is a single pseudo chunk without data - **/ -public class ChunkList { - // ref: http://www.w3.org/TR/PNG/#table53 - public static final int CHUNK_GROUP_0_IDHR = 0; // required - single - public static final int CHUNK_GROUP_1_AFTERIDHR = 1; // optional - multiple - public static final int CHUNK_GROUP_2_PLTE = 2; // optional - single - public static final int CHUNK_GROUP_3_AFTERPLTE = 3; // optional - multple - public static final int CHUNK_GROUP_4_IDAT = 4; // required (single pseudo chunk) - public static final int CHUNK_GROUP_5_AFTERIDAT = 5; // optional - multple - public static final int CHUNK_GROUP_6_END = 6; // only 1 chunk - requried - - /** - * All chunks, read, written (does not include IHDR, IDAT, END for written) - */ - private List chunks = new ArrayList(); - - /** - * chunks not yet writen - does not include IHDR, IDAT, END, perhaps yes PLTE - */ - private Set queuedChunks = new LinkedHashSet(); - - final ImageInfo imageInfo; // only required for writing - - public ChunkList(ImageInfo imfinfo) { - this.imageInfo = imfinfo; - } - - /** - * Adds chunk in next position. This is used when reading - */ - public void appendReadChunk(PngChunk chunk, int chunkGroup) { - chunk.setChunkGroup(chunkGroup); - chunks.add(chunk); - } - - public List getById(String id, boolean includeQueued, boolean includeProcessed) { - List list = new ArrayList(); - if (includeQueued) - for (PngChunk c : queuedChunks) - if (c.id.equals(id)) - list.add(c); - if (includeProcessed) - for (PngChunk c : chunks) - if (c.id.equals(id)) - list.add(c); - return list; - } - - /** - * Remove Chunk: only from queued - */ - public boolean removeChunk(PngChunk c) { - return queuedChunks.remove(c); - } - - /** - * add chunk to write queue - */ - public void queueChunk(PngChunk chunk, boolean replace, boolean priority) { - chunk.setPriority(priority); - if (replace) { - List current = getById(chunk.id, true, false); - for (PngChunk chunk2 : current) - removeChunk(chunk2); - } - queuedChunks.add(chunk); - } - - /** - * this should be called only for ancillary chunks and PLTE (groups 1 - 3 - 5) - **/ - private static boolean shouldWrite(PngChunk c, int currentGroup) { - if (currentGroup == CHUNK_GROUP_2_PLTE) - return c.id.equals(ChunkHelper.PLTE); - if (currentGroup % 2 == 0) - throw new RuntimeException("?"); - int minChunkGroup, maxChunkGroup; - if (c.mustGoBeforePLTE()) - minChunkGroup = maxChunkGroup = ChunkList.CHUNK_GROUP_1_AFTERIDHR; - else if (c.mustGoBeforeIDAT()) { - maxChunkGroup = ChunkList.CHUNK_GROUP_3_AFTERPLTE; - minChunkGroup = c.mustGoAfterPLTE() ? ChunkList.CHUNK_GROUP_3_AFTERPLTE : ChunkList.CHUNK_GROUP_1_AFTERIDHR; - } else { - maxChunkGroup = ChunkList.CHUNK_GROUP_5_AFTERIDAT; - minChunkGroup = ChunkList.CHUNK_GROUP_1_AFTERIDHR; - } - - int preferred = maxChunkGroup; - if (c.isWritePriority()) - preferred = minChunkGroup; - if (ChunkHelper.isUnknown(c) && c.getChunkGroup() > 0) - preferred = c.getChunkGroup(); - if (currentGroup == preferred) - return true; - if (currentGroup > preferred && currentGroup <= maxChunkGroup) - return true; - return false; - } - - public int writeChunks(OutputStream os, int currentGroup) { - int cont = 0; - Iterator it = queuedChunks.iterator(); - while (it.hasNext()) { - PngChunk c = it.next(); - if (!shouldWrite(c, currentGroup)) - continue; - c.write(os); - chunks.add(c); - c.setChunkGroup(currentGroup); - it.remove(); - cont++; - } - return cont; - } - - /** - * returns a copy of processed (read or writen) chunks - */ - public List getChunks() { - return new ArrayList(chunks); - } - - public List getChunksUnkown() { - List l = new ArrayList(); - for (PngChunk chunk : chunks) - if (ChunkHelper.isUnknown(chunk)) - l.add(chunk.id); - return l; - } - - /** - * returns a copy of queued (for write) chunks - */ - public List getQueuedChunks() { - return new ArrayList(queuedChunks); - } - - /** - * behaviour: - * - * a chunk already processed matches : exception a chunk queued matches and overwrite=true: replace it , return true - * a chunk queued matches and overwrite=false: do nothing, return false no matching: set it, return true - * - * @param c - * @param overwriteIfPresent - * @return true if added chunk - */ - public boolean setChunk(PngChunk c, boolean overwriteIfPresent) { - List list = getMatching(c, false, true); // processed - if (!list.isEmpty()) - throw new PngjException("chunk " + c.id + " already set "); - list = getMatching(c, true, false); // queued - if (!list.isEmpty()) { - if (overwriteIfPresent) { - for (PngChunk cx : list) - removeChunk(cx); - queueChunk(c, false, false); - return true; - } - return false; - } - queueChunk(c, false, false); - return true; - } - - /** - * returns only one chunk or null if nothing found - does not include queued - * - * If innerid!=null , the chunk is assumed to be PngChunkTextVar or PngChunkSPLT, and filtered by that id - * - * If more than one chunk (after filtering by inner id) is found, then an exception is thrown (failifMultiple=true) - * or the last one is returned (failifMultiple=false) - **/ - public PngChunk getChunk1(String id, String innerid, boolean failIfMultiple) { - List list = getChunks(id); - if (list.isEmpty()) - return null; - if (innerid != null) { - List list2 = new ArrayList(); - for (PngChunk c : list) { - if (c instanceof PngChunkTextVar) - if (((PngChunkTextVar) c).getKey().equals(innerid)) - list2.add(c); - if (c instanceof PngChunkSPLT) - if (((PngChunkSPLT) c).getPalName().equals(innerid)) - list2.add(c); - } - list = list2; - } - if (list.isEmpty()) - return null; - if (list.size() > 1 && failIfMultiple) - throw new PngjException("unexpected multiple chunks id=" + id); - return list.get(list.size() - 1); - } - - public PngChunk getChunk1(String id) { - return getChunk1(id, null, true); - } - - public List getChunks(String id) { // not including queued - return getById(id, false, true); - } - - private List getMatching(PngChunk cnew, boolean includeQueued, boolean includeProcessed) { - List list = new ArrayList(); - if (includeQueued) - for (PngChunk c : getQueuedChunks()) - if (matches(cnew, c)) - list.add(c); - if (includeProcessed) - for (PngChunk c : getChunks()) - if (matches(cnew, c)) - list.add(c); - return list; - } - - /** - * MY adhoc criteria: two chunks "match" if they have same id and (perhaps, if multiple are allowed) if the match - * also in some "internal key" (eg: key for string values, palette for sPLT, etc) - * - * @return true if "matches" - */ - public static boolean matches(PngChunk c2, PngChunk c1) { - if (c1 == null || c2 == null || !c1.id.equals(c2.id)) - return false; - // same id - if (c1.getClass() != c2.getClass()) - return false; // should not happen - if (!c2.allowsMultiple()) - return true; - if (c1 instanceof PngChunkTextVar) { - return ((PngChunkTextVar) c1).getKey().equals(((PngChunkTextVar) c2).getKey()); - } - if (c1 instanceof PngChunkSPLT) { - return ((PngChunkSPLT) c1).getPalName().equals(((PngChunkSPLT) c2).getPalName()); - } - // unknown chunks that allow multiple? consider they don't match - return false; - } - - public String toString() { - return "ChunkList: processed: " + chunks.size() + " queue: " + queuedChunks.size(); - } - - /** - * for debugging - */ - public String toStringFull() { - StringBuilder sb = new StringBuilder(toString()); - sb.append("\n Processed:\n"); - for (PngChunk chunk : chunks) { - sb.append(chunk).append(" G=" + chunk.getChunkGroup() + "\n"); - } - if (!queuedChunks.isEmpty()) { - sb.append(" Queued:\n"); - for (PngChunk chunk : chunks) { - sb.append(chunk).append("\n"); - } - - } - return sb.toString(); - } - -} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java index a3f85355c..03d50c2c4 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkLoadBehaviour.java @@ -1,10 +1,25 @@ package jogamp.opengl.util.pngj.chunks; +/** + * Defines gral strategy about what to do with ancillary (non-critical) chunks when reading + */ public enum ChunkLoadBehaviour { - // what to do with non critical chunks when reading? - LOAD_CHUNK_NEVER, /* ignore non-critical chunks */ - LOAD_CHUNK_KNOWN, /* load chunk if 'known' */ - LOAD_CHUNK_IF_SAFE, /* load chunk if 'known' or safe to copy */ - LOAD_CHUNK_ALWAYS /* load chunk always */ - ; + /** + * All non-critical chunks are skipped + */ + LOAD_CHUNK_NEVER, + /** + * Ancillary chunks are loaded only if 'known' (registered with the factory). + */ + LOAD_CHUNK_KNOWN, + /** + * + * Load chunk if "known" or "safe to copy". + */ + LOAD_CHUNK_IF_SAFE, + /** + * Load all chunks.
        + * Notice that other restrictions might apply, see PngReader.skipChunkMaxSize PngReader.skipChunkIds + */ + LOAD_CHUNK_ALWAYS; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkPredicate.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkPredicate.java new file mode 100644 index 000000000..a750ae34f --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkPredicate.java @@ -0,0 +1,14 @@ +package jogamp.opengl.util.pngj.chunks; + +/** + * Decides if another chunk "matches", according to some criterion + */ +public interface ChunkPredicate { + /** + * The other chunk matches with this one + * + * @param chunk + * @return true if match + */ + boolean match(PngChunk chunk); +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java index 6770d5e95..8dd0ef476 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkRaw.java @@ -5,24 +5,47 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.zip.CRC32; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjBadCrcException; import jogamp.opengl.util.pngj.PngjOutputException; /** - * Wraps the raw chunk data Short lived object, to be created while serialing/deserializing Do not reuse it for - * different chunks - * - * see http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html + * Raw (physical) chunk. + *

        + * Short lived object, to be created while serialing/deserializing Do not reuse it for different chunks.
        + * See http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html */ public class ChunkRaw { + /** + * The length counts only the data field, not itself, the chunk type code, or the CRC. Zero is a valid length. + * Although encoders and decoders should treat the length as unsigned, its value must not exceed 231-1 bytes. + */ public final int len; - public final byte[] idbytes = new byte[4]; // 4 bytes - public byte[] data = null; // crc not included + + /** + * A 4-byte chunk type code. uppercase and lowercase ASCII letters + */ + public final byte[] idbytes = new byte[4]; + + /** + * The data bytes appropriate to the chunk type, if any. This field can be of zero length. Does not include crc + */ + public byte[] data = null; + /** + * A 4-byte CRC (Cyclic Redundancy Check) calculated on the preceding bytes in the chunk, including the chunk type + * code and chunk data fields, but not including the length field. + */ private int crcval = 0; - // public int offset=-1; // only for read chunks - informational + /** + * @param len + * : data len + * @param idbytes + * : chunk type (deep copied) + * @param alloc + * : it true, the data array will be allocced + */ public ChunkRaw(int len, byte[] idbytes, boolean alloc) { this.len = len; System.arraycopy(idbytes, 0, this.idbytes, 0, 4); @@ -30,54 +53,58 @@ public class ChunkRaw { allocData(); } - public void writeChunk(OutputStream os) { - if (idbytes.length != 4) - throw new PngjOutputException("bad chunkid [" + ChunkHelper.toString(idbytes) + "]"); - computeCrc(); - PngHelper.writeInt4(os, len); - PngHelper.writeBytes(os, idbytes); - if (len > 0) - PngHelper.writeBytes(os, data, 0, len); - // System.err.println("writing chunk " + this.toString() + "crc=" + crcval); - - PngHelper.writeInt4(os, crcval); + private void allocData() { + if (data == null || data.length < len) + data = new byte[len]; } /** - * called after setting data, before writing to os + * this is called after setting data, before writing to os */ - private void computeCrc() { - CRC32 crcengine = PngHelper.getCRC(); + private int computeCrc() { + CRC32 crcengine = PngHelperInternal.getCRC(); crcengine.reset(); crcengine.update(idbytes, 0, 4); if (len > 0) crcengine.update(data, 0, len); // - crcval = (int) crcengine.getValue(); + return (int) crcengine.getValue(); } - public String toString() { - return "chunkid=" + ChunkHelper.toString(idbytes) + " len=" + len; + /** + * Computes the CRC and writes to the stream. If error, a PngjOutputException is thrown + */ + public void writeChunk(OutputStream os) { + if (idbytes.length != 4) + throw new PngjOutputException("bad chunkid [" + ChunkHelper.toString(idbytes) + "]"); + crcval = computeCrc(); + PngHelperInternal.writeInt4(os, len); + PngHelperInternal.writeBytes(os, idbytes); + if (len > 0) + PngHelperInternal.writeBytes(os, data, 0, len); + PngHelperInternal.writeInt4(os, crcval); } /** * position before: just after chunk id. positon after: after crc Data should be already allocated. Checks CRC * Return number of byte read. */ - public int readChunkData(InputStream is) { - PngHelper.readBytes(is, data, 0, len); - int crcori = PngHelper.readInt4(is); - computeCrc(); - if (crcori != crcval) - throw new PngjBadCrcException("crc invalid for chunk " + toString() + " calc=" + crcval + " read=" + crcori); + public int readChunkData(InputStream is, boolean checkCrc) { + PngHelperInternal.readBytes(is, data, 0, len); + crcval = PngHelperInternal.readInt4(is); + if (checkCrc) { + int crc = computeCrc(); + if (crc != crcval) + throw new PngjBadCrcException("chunk: " + this + " crc calc=" + crc + " read=" + crcval); + } return len + 4; } - public ByteArrayInputStream getAsByteStream() { // only the data + ByteArrayInputStream getAsByteStream() { // only the data return new ByteArrayInputStream(data); } - private void allocData() { - if (data == null || data.length < len) - data = new byte[len]; + public String toString() { + return "chunkid=" + ChunkHelper.toString(idbytes) + " len=" + len; } + } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java new file mode 100644 index 000000000..ad788f154 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksList.java @@ -0,0 +1,174 @@ +package jogamp.opengl.util.pngj.chunks; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import jogamp.opengl.util.pngj.ImageInfo; +import jogamp.opengl.util.pngj.PngjException; + +/** + * All chunks that form an image, read or to be written. + *

        + * chunks include all chunks, but IDAT is a single pseudo chunk without data + **/ +public class ChunksList { + // ref: http://www.w3.org/TR/PNG/#table53 + public static final int CHUNK_GROUP_0_IDHR = 0; // required - single + public static final int CHUNK_GROUP_1_AFTERIDHR = 1; // optional - multiple + public static final int CHUNK_GROUP_2_PLTE = 2; // optional - single + public static final int CHUNK_GROUP_3_AFTERPLTE = 3; // optional - multple + public static final int CHUNK_GROUP_4_IDAT = 4; // required (single pseudo chunk) + public static final int CHUNK_GROUP_5_AFTERIDAT = 5; // optional - multple + public static final int CHUNK_GROUP_6_END = 6; // only 1 chunk - requried + + /** + * All chunks, read (or written) + * + * But IDAT is a single pseudo chunk without data + */ + protected List chunks = new ArrayList(); + + final ImageInfo imageInfo; // only required for writing + + public ChunksList(ImageInfo imfinfo) { + this.imageInfo = imfinfo; + } + + /** + * Keys of processed (read or writen) chunks + * + * @return key:chunk id, val: number of occurrences + */ + public HashMap getChunksKeys() { + HashMap ck = new HashMap(); + for (PngChunk c : chunks) { + ck.put(c.id, ck.containsKey(c.id) ? ck.get(c.id) + 1 : 1); + } + return ck; + } + + /** + * Returns a copy of the list (but the chunks are not copied) This should not be used for general metadata + * handling + */ + public ArrayList getChunks() { + return new ArrayList(chunks); + } + + protected static List getXById(final List list, final String id, final String innerid) { + if (innerid == null) + return ChunkHelper.filterList(list, new ChunkPredicate() { + public boolean match(PngChunk c) { + return c.id.equals(id); + } + }); + else + return ChunkHelper.filterList(list, new ChunkPredicate() { + public boolean match(PngChunk c) { + if (!c.id.equals(id)) + return false; + if (c instanceof PngChunkTextVar && !((PngChunkTextVar) c).getKey().equals(innerid)) + return false; + if (c instanceof PngChunkSPLT && !((PngChunkSPLT) c).getPalName().equals(innerid)) + return false; + return true; + } + }); + } + + /** + * Adds chunk in next position. This is used onyl by the pngReader + */ + public void appendReadChunk(PngChunk chunk, int chunkGroup) { + chunk.setChunkGroup(chunkGroup); + chunks.add(chunk); + } + + /** + * All chunks with this ID + * + * @param id + * @return List, empty if none + */ + public List getById(final String id) { + return getById(id, null); + } + + /** + * If innerid!=null and the chunk is PngChunkTextVar or PngChunkSPLT, it's filtered by that id + * + * @param id + * @return innerid Only used for text and SPLT chunks + * @return List, empty if none + */ + public List getById(final String id, final String innerid) { + return getXById(chunks, id, innerid); + } + + /** + * Returns only one chunk + * + * @param id + * @return First chunk found, null if not found + */ + public PngChunk getById1(final String id) { + return getById1(id, false); + } + + /** + * Returns only one chunk or null if nothing found - does not include queued + *

        + * If more than one chunk is found, then an exception is thrown (failifMultiple=true or chunk is single) or the last + * one is returned (failifMultiple=false) + **/ + public PngChunk getById1(final String id, final boolean failIfMultiple) { + return getById1(id, null, failIfMultiple); + } + + /** + * Returns only one chunk or null if nothing found - does not include queued + *

        + * If more than one chunk (after filtering by inner id) is found, then an exception is thrown (failifMultiple=true + * or chunk is single) or the last one is returned (failifMultiple=false) + **/ + public PngChunk getById1(final String id, final String innerid, final boolean failIfMultiple) { + List list = getById(id, innerid); + if (list.isEmpty()) + return null; + if (list.size() > 1 && (failIfMultiple || !list.get(0).allowsMultiple())) + throw new PngjException("unexpected multiple chunks id=" + id); + return list.get(list.size() - 1); + } + + /** + * Finds all chunks "equivalent" to this one + * + * @param c2 + * @return Empty if nothing found + */ + public List getEquivalent(final PngChunk c2) { + return ChunkHelper.filterList(chunks, new ChunkPredicate() { + public boolean match(PngChunk c) { + return ChunkHelper.equivalent(c, c2); + } + }); + } + + public String toString() { + return "ChunkList: read: " + chunks.size(); + } + + /** + * for debugging + */ + public String toStringFull() { + StringBuilder sb = new StringBuilder(toString()); + sb.append("\n Read:\n"); + for (PngChunk chunk : chunks) { + sb.append(chunk).append(" G=" + chunk.getChunkGroup() + "\n"); + } + return sb.toString(); + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java new file mode 100644 index 000000000..204c4c2a5 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunksListForWrite.java @@ -0,0 +1,171 @@ +package jogamp.opengl.util.pngj.chunks; + +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import jogamp.opengl.util.pngj.ImageInfo; +import jogamp.opengl.util.pngj.PngjException; +import jogamp.opengl.util.pngj.PngjOutputException; + +public class ChunksListForWrite extends ChunksList { + + /** + * chunks not yet writen - does not include IHDR, IDAT, END, perhaps yes PLTE + */ + private final List queuedChunks = new ArrayList(); + + // redundant, just for eficciency + private HashMap alreadyWrittenKeys = new HashMap(); + + public ChunksListForWrite(ImageInfo imfinfo) { + super(imfinfo); + } + + /** + * Same as getById(), but looking in the queued chunks + */ + public List getQueuedById(final String id) { + return getQueuedById(id, null); + } + + /** + * Same as getById(), but looking in the queued chunks + */ + public List getQueuedById(final String id, final String innerid) { + return getXById(queuedChunks, id, innerid); + } + + /** + * Same as getById1(), but looking in the queued chunks + **/ + public PngChunk getQueuedById1(final String id, final String innerid, final boolean failIfMultiple) { + List list = getQueuedById(id, innerid); + if (list.isEmpty()) + return null; + if (list.size() > 1 && (failIfMultiple || !list.get(0).allowsMultiple())) + throw new PngjException("unexpected multiple chunks id=" + id); + return list.get(list.size() - 1); + } + + /** + * Same as getById1(), but looking in the queued chunks + **/ + public PngChunk getQueuedById1(final String id, final boolean failIfMultiple) { + return getQueuedById1(id, null, failIfMultiple); + } + + /** + * Same as getById1(), but looking in the queued chunks + **/ + public PngChunk getQueuedById1(final String id) { + return getQueuedById1(id, false); + } + + /** + * Remove Chunk: only from queued + * + * WARNING: this depends on c.equals() implementation, which is straightforward for SingleChunks. For + * MultipleChunks, it will normally check for reference equality! + */ + public boolean removeChunk(PngChunk c) { + return queuedChunks.remove(c); + } + + /** + * Adds chunk to queue + * + * Does not check for duplicated or anything + * + * @param c + */ + public boolean queue(PngChunk c) { + queuedChunks.add(c); + return true; + } + + /** + * this should be called only for ancillary chunks and PLTE (groups 1 - 3 - 5) + **/ + private static boolean shouldWrite(PngChunk c, int currentGroup) { + if (currentGroup == CHUNK_GROUP_2_PLTE) + return c.id.equals(ChunkHelper.PLTE); + if (currentGroup % 2 == 0) + throw new PngjOutputException("bad chunk group?"); + int minChunkGroup, maxChunkGroup; + if (c.getOrderingConstraint().mustGoBeforePLTE()) + minChunkGroup = maxChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR; + else if (c.getOrderingConstraint().mustGoBeforeIDAT()) { + maxChunkGroup = ChunksList.CHUNK_GROUP_3_AFTERPLTE; + minChunkGroup = c.getOrderingConstraint().mustGoAfterPLTE() ? ChunksList.CHUNK_GROUP_3_AFTERPLTE + : ChunksList.CHUNK_GROUP_1_AFTERIDHR; + } else { + maxChunkGroup = ChunksList.CHUNK_GROUP_5_AFTERIDAT; + minChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR; + } + + int preferred = maxChunkGroup; + if (c.hasPriority()) + preferred = minChunkGroup; + if (ChunkHelper.isUnknown(c) && c.getChunkGroup() > 0) + preferred = c.getChunkGroup(); + if (currentGroup == preferred) + return true; + if (currentGroup > preferred && currentGroup <= maxChunkGroup) + return true; + return false; + } + + public int writeChunks(OutputStream os, int currentGroup) { + int cont = 0; + Iterator it = queuedChunks.iterator(); + while (it.hasNext()) { + PngChunk c = it.next(); + if (!shouldWrite(c, currentGroup)) + continue; + if (ChunkHelper.isCritical(c.id) && !c.id.equals(ChunkHelper.PLTE)) + throw new PngjOutputException("bad chunk queued: " + c); + if (alreadyWrittenKeys.containsKey(c.id) && !c.allowsMultiple()) + throw new PngjOutputException("duplicated chunk does not allow multiple: " + c); + c.write(os); + chunks.add(c); + alreadyWrittenKeys.put(c.id, alreadyWrittenKeys.containsKey(c.id) ? alreadyWrittenKeys.get(c.id) + 1 : 1); + c.setChunkGroup(currentGroup); + it.remove(); + cont++; + } + return cont; + } + + /** + * warning: this is NOT a copy, do not modify + */ + public List getQueuedChunks() { + return queuedChunks; + } + + public String toString() { + return "ChunkList: written: " + chunks.size() + " queue: " + queuedChunks.size(); + } + + /** + * for debugging + */ + public String toStringFull() { + StringBuilder sb = new StringBuilder(toString()); + sb.append("\n Written:\n"); + for (PngChunk chunk : chunks) { + sb.append(chunk).append(" G=" + chunk.getChunkGroup() + "\n"); + } + if (!queuedChunks.isEmpty()) { + sb.append(" Queued:\n"); + for (PngChunk chunk : queuedChunks) { + sb.append(chunk).append("\n"); + } + + } + return sb.toString(); + } +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java index 2df9fd1f3..1d630591e 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunk.java @@ -6,26 +6,87 @@ import java.util.HashMap; import java.util.Map; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngjException; +import jogamp.opengl.util.pngj.PngjExceptionInternal; - -// see http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html +/** + * Represents a instance of a PNG chunk. + *

        + * See http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks + * .html + *

        + * Concrete classes should extend {@link PngChunkSingle} or {@link PngChunkMultiple} + *

        + * Note that some methods/fields are type-specific (getOrderingConstraint(), allowsMultiple()),
        + * some are 'almost' type-specific (id,crit,pub,safe; the exception is PngUKNOWN),
        + * and the rest are instance-specific + */ public abstract class PngChunk { - public final String id; // 4 letters + /** + * Chunk-id: 4 letters + */ + public final String id; + /** + * Autocomputed at creation time + */ public final boolean crit, pub, safe; - private int lenori = -1; // merely informational, for read chunks - private boolean writePriority = false; // for queued chunks protected final ImageInfo imgInfo; - private int chunkGroup = -1; // chunk group where it was read or writen + /** + * Possible ordering constraint for a PngChunk type -only relevant for ancillary chunks. Theoretically, there could + * be more general constraints, but these cover the constraints for standard chunks. + */ + public enum ChunkOrderingConstraint { + /** + * no ordering constraint + */ + NONE, + /** + * Must go before PLTE (and hence, also before IDAT) + */ + BEFORE_PLTE_AND_IDAT, + /** + * Must go after PLTE but before IDAT + */ + AFTER_PLTE_BEFORE_IDAT, + /** + * Must before IDAT (before or after PLTE) + */ + BEFORE_IDAT, + /** + * Does not apply + */ + NA; + + public boolean mustGoBeforePLTE() { + return this == BEFORE_PLTE_AND_IDAT; + } + + public boolean mustGoBeforeIDAT() { + return this == BEFORE_IDAT || this == BEFORE_PLTE_AND_IDAT || this == AFTER_PLTE_BEFORE_IDAT; + } + + public boolean mustGoAfterPLTE() { + return this == AFTER_PLTE_BEFORE_IDAT; + } + } + + private boolean priority = false; // For writing. Queued chunks with high priority will be written as soon as + // possible + + protected int chunkGroup = -1; // chunk group where it was read or writen + protected int length = -1; // merely informational, for read chunks + protected long offset = 0; // merely informational, for read chunks /** - * This static map defines which PngChunk class correspond to which ChunkID The client can add other chunks to this - * map statically, before reading + * This static map defines which PngChunk class correspond to which ChunkID + *

        + * The client can add other chunks to this map statically, before reading an image, calling + * PngChunk.factoryRegister(id,class) */ - public final static Map> factoryMap = new HashMap>(); + private final static Map> factoryMap = new HashMap>(); static { factoryMap.put(ChunkHelper.IDAT, PngChunkIDAT.class); factoryMap.put(ChunkHelper.IHDR, PngChunkIHDR.class); @@ -45,6 +106,32 @@ public abstract class PngChunk { factoryMap.put(ChunkHelper.sRGB, PngChunkSRGB.class); factoryMap.put(ChunkHelper.hIST, PngChunkHIST.class); factoryMap.put(ChunkHelper.sPLT, PngChunkSPLT.class); + // extended + factoryMap.put(PngChunkOFFS.ID, PngChunkOFFS.class); + factoryMap.put(PngChunkSTER.ID, PngChunkSTER.class); + } + + /** + * Registers a chunk-id (4 letters) to be associated with a PngChunk class + *

        + * This method should be called by user code that wants to add some chunks (not implmemented in this library) to the + * factory, so that the PngReader knows about it. + */ + public static void factoryRegister(String chunkId, Class chunkClass) { + factoryMap.put(chunkId, chunkClass); + } + + /** + * True if the chunk-id type is known. + *

        + * A chunk is known if we recognize its class, according with factoryMap + *

        + * This is not necessarily the same as being "STANDARD", or being implemented in this library + *

        + * Unknown chunks will be parsed as instances of {@link PngChunkUNKNOWN} + */ + public static boolean isKnown(String id) { + return factoryMap.containsKey(id); } protected PngChunk(String id, ImageInfo imgInfo) { @@ -55,29 +142,19 @@ public abstract class PngChunk { this.safe = ChunkHelper.isSafeToCopy(id); } - public abstract ChunkRaw createChunk(); - - public abstract void parseFromChunk(ChunkRaw c); - - // override to make deep copy from read data to write - public abstract void cloneDataFromRead(PngChunk other); - - @SuppressWarnings("unchecked") - public static T cloneChunk(T chunk, ImageInfo info) { - PngChunk cn = factoryFromId(chunk.id, info); - if (cn.getClass() != chunk.getClass()) - throw new PngjException("bad class cloning chunk: " + cn.getClass() + " " + chunk.getClass()); - cn.cloneDataFromRead(chunk); - return (T) cn; - } - + /** + * This factory creates the corresponding chunk and parses the raw chunk. This is used when reading. + */ public static PngChunk factory(ChunkRaw chunk, ImageInfo info) { PngChunk c = factoryFromId(ChunkHelper.toString(chunk.idbytes), info); - c.lenori = chunk.len; - c.parseFromChunk(chunk); + c.length = chunk.len; + c.parseFromRaw(chunk); return c; } + /** + * Creates one new blank chunk of the corresponding type, according to factoryMap (PngChunkUNKNOWN if not known) + */ public static PngChunk factoryFromId(String cid, ImageInfo info) { PngChunk chunk = null; try { @@ -87,66 +164,110 @@ public abstract class PngChunk { chunk = constr.newInstance(info); } } catch (Exception e) { - // this can happend for unkown chunks + // this can happen for unkown chunks } if (chunk == null) chunk = new PngChunkUNKNOWN(cid, info); return chunk; } - protected ChunkRaw createEmptyChunk(int len, boolean alloc) { + protected final ChunkRaw createEmptyChunk(int len, boolean alloc) { ChunkRaw c = new ChunkRaw(len, ChunkHelper.toBytes(id), alloc); return c; } - @Override - public String toString() { - return "chunk id= " + id + " (" + lenori + ") c=" + getClass().getSimpleName(); + /** + * Makes a clone (deep copy) calling {@link #cloneDataFromRead(PngChunk)} + */ + @SuppressWarnings("unchecked") + public static T cloneChunk(T chunk, ImageInfo info) { + PngChunk cn = factoryFromId(chunk.id, info); + if (cn.getClass() != chunk.getClass()) + throw new PngjExceptionInternal("bad class cloning chunk: " + cn.getClass() + " " + chunk.getClass()); + cn.cloneDataFromRead(chunk); + return (T) cn; } - void setPriority(boolean highPrioriy) { - writePriority = highPrioriy; + /** + * In which "chunkGroup" (see {@link ChunksList}for definition) this chunks instance was read or written. + *

        + * -1 if not read or written (eg, queued) + */ + final public int getChunkGroup() { + return chunkGroup; } - void write(OutputStream os) { - ChunkRaw c = createChunk(); - if (c == null) - throw new PngjException("null chunk ! creation failed for " + this); - c.writeChunk(os); + /** + * @see #getChunkGroup() + */ + final public void setChunkGroup(int chunkGroup) { + this.chunkGroup = chunkGroup; } - public boolean isWritePriority() { - return writePriority; + public boolean hasPriority() { + return priority; } - /** must be overriden - only relevant for ancillary chunks */ - public boolean allowsMultiple() { - return false; // override if allows multiple ocurrences + public void setPriority(boolean priority) { + this.priority = priority; } - /** mustGoBeforeXX/After must be overriden - only relevant for ancillary chunks */ - public boolean mustGoBeforeIDAT() { - return false; + final void write(OutputStream os) { + ChunkRaw c = createRawChunk(); + if (c == null) + throw new PngjExceptionInternal("null chunk ! creation failed for " + this); + c.writeChunk(os); } - public boolean mustGoBeforePLTE() { - return false; + public int getLength() { + return length; } - public boolean mustGoAfterPLTE() { - return false; - } + /* + * public void setLength(int length) { this.length = length; } + */ - static boolean isKnown(String id) { - return factoryMap.containsKey(id); + public long getOffset() { + return offset; } - public int getChunkGroup() { - return chunkGroup; + public void setOffset(long offset) { + this.offset = offset; } - public void setChunkGroup(int chunkGroup) { - this.chunkGroup = chunkGroup; + /** + * Creates the physical chunk. This is used when writing (serialization). Each particular chunk class implements its + * own logic. + * + * @return A newly allocated and filled raw chunk + */ + public abstract ChunkRaw createRawChunk(); + + /** + * Parses raw chunk and fill inside data. This is used when reading (deserialization). Each particular chunk class + * implements its own logic. + */ + public abstract void parseFromRaw(ChunkRaw c); + + /** + * Makes a copy of the chunk. + *

        + * This is used when copying chunks from a reader to a writer + *

        + * It should normally be a deep copy, and after the cloning this.equals(other) should return true + */ + public abstract void cloneDataFromRead(PngChunk other); + + public abstract boolean allowsMultiple(); // this is implemented in PngChunkMultiple/PngChunSingle + + /** + * see {@link ChunkOrderingConstraint} + */ + public abstract ChunkOrderingConstraint getOrderingConstraint(); + + @Override + public String toString() { + return "chunk id= " + id + " (len=" + length + " offset=" + offset + ") c=" + getClass().getSimpleName(); } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java index 51bbcb832..4a8502a3d 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkBKGD.java @@ -1,14 +1,18 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; -/* +/** + * bKGD Chunk. + *

        + * see http://www.w3.org/TR/PNG/#11bKGD + *

        + * this chunk structure depends on the image type */ -public class PngChunkBKGD extends PngChunk { - // http://www.w3.org/TR/PNG/#11bKGD - // this chunk structure depends on the image type +public class PngChunkBKGD extends PngChunkSingle { + public final static String ID = ChunkHelper.bKGD; // only one of these is meaningful private int gray; private int red, green, blue; @@ -19,43 +23,38 @@ public class PngChunkBKGD extends PngChunk { } @Override - public boolean mustGoBeforeIDAT() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT; } @Override - public boolean mustGoAfterPLTE() { - return true; - } - - @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = null; if (imgInfo.greyscale) { c = createEmptyChunk(2, true); - PngHelper.writeInt2tobytes(gray, c.data, 0); + PngHelperInternal.writeInt2tobytes(gray, c.data, 0); } else if (imgInfo.indexed) { c = createEmptyChunk(1, true); c.data[0] = (byte) paletteIndex; } else { c = createEmptyChunk(6, true); - PngHelper.writeInt2tobytes(red, c.data, 0); - PngHelper.writeInt2tobytes(green, c.data, 0); - PngHelper.writeInt2tobytes(blue, c.data, 0); + PngHelperInternal.writeInt2tobytes(red, c.data, 0); + PngHelperInternal.writeInt2tobytes(green, c.data, 0); + PngHelperInternal.writeInt2tobytes(blue, c.data, 0); } return c; } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { if (imgInfo.greyscale) { - gray = PngHelper.readInt2fromBytes(c.data, 0); + gray = PngHelperInternal.readInt2fromBytes(c.data, 0); } else if (imgInfo.indexed) { paletteIndex = (int) (c.data[0] & 0xff); } else { - red = PngHelper.readInt2fromBytes(c.data, 0); - green = PngHelper.readInt2fromBytes(c.data, 2); - blue = PngHelper.readInt2fromBytes(c.data, 4); + red = PngHelperInternal.readInt2fromBytes(c.data, 0); + green = PngHelperInternal.readInt2fromBytes(c.data, 2); + blue = PngHelperInternal.readInt2fromBytes(c.data, 4); } } @@ -119,4 +118,5 @@ public class PngChunkBKGD extends PngChunk { throw new PngjException("only rgb or rgba images support this"); return new int[] { red, green, blue }; } + } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkCHRM.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkCHRM.java index 4380761c7..25a4bf2d6 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkCHRM.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkCHRM.java @@ -1,12 +1,17 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; -/* +/** + * cHRM chunk. + *

        + * see http://www.w3.org/TR/PNG/#11cHRM */ -public class PngChunkCHRM extends PngChunk { +public class PngChunkCHRM extends PngChunkSingle { + public final static String ID = ChunkHelper.cHRM; + // http://www.w3.org/TR/PNG/#11cHRM private double whitex, whitey; private double redx, redy; @@ -14,46 +19,41 @@ public class PngChunkCHRM extends PngChunk { private double bluex, bluey; public PngChunkCHRM(ImageInfo info) { - super(ChunkHelper.cHRM, info); - } - - @Override - public boolean mustGoBeforeIDAT() { - return true; + super(ID, info); } @Override - public boolean mustGoBeforePLTE() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT; } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = null; c = createEmptyChunk(32, true); - PngHelper.writeInt4tobytes(PngHelper.doubleToInt100000(whitex), c.data, 0); - PngHelper.writeInt4tobytes(PngHelper.doubleToInt100000(whitey), c.data, 4); - PngHelper.writeInt4tobytes(PngHelper.doubleToInt100000(redx), c.data, 8); - PngHelper.writeInt4tobytes(PngHelper.doubleToInt100000(redy), c.data, 12); - PngHelper.writeInt4tobytes(PngHelper.doubleToInt100000(greenx), c.data, 16); - PngHelper.writeInt4tobytes(PngHelper.doubleToInt100000(greeny), c.data, 20); - PngHelper.writeInt4tobytes(PngHelper.doubleToInt100000(bluex), c.data, 24); - PngHelper.writeInt4tobytes(PngHelper.doubleToInt100000(bluey), c.data, 28); + PngHelperInternal.writeInt4tobytes(PngHelperInternal.doubleToInt100000(whitex), c.data, 0); + PngHelperInternal.writeInt4tobytes(PngHelperInternal.doubleToInt100000(whitey), c.data, 4); + PngHelperInternal.writeInt4tobytes(PngHelperInternal.doubleToInt100000(redx), c.data, 8); + PngHelperInternal.writeInt4tobytes(PngHelperInternal.doubleToInt100000(redy), c.data, 12); + PngHelperInternal.writeInt4tobytes(PngHelperInternal.doubleToInt100000(greenx), c.data, 16); + PngHelperInternal.writeInt4tobytes(PngHelperInternal.doubleToInt100000(greeny), c.data, 20); + PngHelperInternal.writeInt4tobytes(PngHelperInternal.doubleToInt100000(bluex), c.data, 24); + PngHelperInternal.writeInt4tobytes(PngHelperInternal.doubleToInt100000(bluey), c.data, 28); return c; } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { if (c.len != 32) throw new PngjException("bad chunk " + c); - whitex = PngHelper.intToDouble100000(PngHelper.readInt4fromBytes(c.data, 0)); - whitey = PngHelper.intToDouble100000(PngHelper.readInt4fromBytes(c.data, 4)); - redx = PngHelper.intToDouble100000(PngHelper.readInt4fromBytes(c.data, 8)); - redy = PngHelper.intToDouble100000(PngHelper.readInt4fromBytes(c.data, 12)); - greenx = PngHelper.intToDouble100000(PngHelper.readInt4fromBytes(c.data, 16)); - greeny = PngHelper.intToDouble100000(PngHelper.readInt4fromBytes(c.data, 20)); - bluex = PngHelper.intToDouble100000(PngHelper.readInt4fromBytes(c.data, 24)); - bluey = PngHelper.intToDouble100000(PngHelper.readInt4fromBytes(c.data, 28)); + whitex = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 0)); + whitey = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 4)); + redx = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 8)); + redy = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 12)); + greenx = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 16)); + greeny = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 20)); + bluex = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 24)); + bluey = PngHelperInternal.intToDouble100000(PngHelperInternal.readInt4fromBytes(c.data, 28)); } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkGAMA.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkGAMA.java index 184ee9ffa..74640746e 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkGAMA.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkGAMA.java @@ -1,42 +1,42 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; -/* +/** + * gAMA chunk. + *

        + * see http://www.w3.org/TR/PNG/#11gAMA */ -public class PngChunkGAMA extends PngChunk { +public class PngChunkGAMA extends PngChunkSingle { + public final static String ID = ChunkHelper.gAMA; + // http://www.w3.org/TR/PNG/#11gAMA private double gamma; public PngChunkGAMA(ImageInfo info) { - super(ChunkHelper.gAMA, info); - } - - @Override - public boolean mustGoBeforeIDAT() { - return true; + super(ID, info); } @Override - public boolean mustGoBeforePLTE() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT; } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = createEmptyChunk(4, true); int g = (int) (gamma * 100000 + 0.5); - PngHelper.writeInt4tobytes(g, c.data, 0); + PngHelperInternal.writeInt4tobytes(g, c.data, 0); return c; } @Override - public void parseFromChunk(ChunkRaw chunk) { + public void parseFromRaw(ChunkRaw chunk) { if (chunk.len != 4) throw new PngjException("bad chunk " + chunk); - int g = PngHelper.readInt4fromBytes(chunk.data, 0); + int g = PngHelperInternal.readInt4fromBytes(chunk.data, 0); gamma = ((double) g) / 100000.0; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java index b0f02ea37..6dc3fd9ec 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkHIST.java @@ -1,50 +1,48 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; -/* +/** + * hIST chunk. + *

        + * see http://www.w3.org/TR/PNG/#11hIST
        + * only for palette images */ -public class PngChunkHIST extends PngChunk { - // http://www.w3.org/TR/PNG/#11hIST - // only for palette images +public class PngChunkHIST extends PngChunkSingle { + public final static String ID = ChunkHelper.hIST; private int[] hist = new int[0]; // should have same lenght as palette public PngChunkHIST(ImageInfo info) { - super(ChunkHelper.hIST, info); + super(ID, info); } @Override - public boolean mustGoBeforeIDAT() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT; } @Override - public boolean mustGoAfterPLTE() { - return true; - } - - @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { if (!imgInfo.indexed) throw new PngjException("only indexed images accept a HIST chunk"); int nentries = c.data.length / 2; hist = new int[nentries]; for (int i = 0; i < hist.length; i++) { - hist[i] = PngHelper.readInt2fromBytes(c.data, i * 2); + hist[i] = PngHelperInternal.readInt2fromBytes(c.data, i * 2); } } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { if (!imgInfo.indexed) throw new PngjException("only indexed images accept a HIST chunk"); ChunkRaw c = null; c = createEmptyChunk(hist.length * 2, true); for (int i = 0; i < hist.length; i++) { - PngHelper.writeInt2tobytes(hist[i], c.data, i * 2); + PngHelperInternal.writeInt2tobytes(hist[i], c.data, i * 2); } return c; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkICCP.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkICCP.java index db1c1ba64..399577d72 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkICCP.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkICCP.java @@ -1,31 +1,32 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; +import jogamp.opengl.util.pngj.PngjException; -/* +/** + * iCCP chunk. + *

        + * see http://www.w3.org/TR/PNG/#11iCCP */ -public class PngChunkICCP extends PngChunk { +public class PngChunkICCP extends PngChunkSingle { + public final static String ID = ChunkHelper.iCCP; + // http://www.w3.org/TR/PNG/#11iCCP private String profileName; private byte[] compressedProfile; // copmression/decopmresion is done in getter/setter public PngChunkICCP(ImageInfo info) { - super(ChunkHelper.iCCP, info); - } - - @Override - public boolean mustGoBeforeIDAT() { - return true; + super(ID, info); } @Override - public boolean mustGoBeforePLTE() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT; } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = createEmptyChunk(profileName.length() + compressedProfile.length + 2, true); System.arraycopy(ChunkHelper.toBytes(profileName), 0, c.data, 0, profileName.length()); c.data[profileName.length()] = 0; @@ -35,12 +36,12 @@ public class PngChunkICCP extends PngChunk { } @Override - public void parseFromChunk(ChunkRaw chunk) { + public void parseFromRaw(ChunkRaw chunk) { int pos0 = ChunkHelper.posNullByte(chunk.data); - profileName = new String(chunk.data, 0, pos0, PngHelper.charsetLatin1); + profileName = new String(chunk.data, 0, pos0, PngHelperInternal.charsetLatin1); int comp = (chunk.data[pos0 + 1] & 0xff); if (comp != 0) - throw new RuntimeException("bad compression for ChunkTypeICCP"); + throw new PngjException("bad compression for ChunkTypeICCP"); int compdatasize = chunk.data.length - (pos0 + 2); compressedProfile = new byte[compdatasize]; System.arraycopy(chunk.data, pos0 + 2, compressedProfile, 0, compdatasize); @@ -64,7 +65,7 @@ public class PngChunkICCP extends PngChunk { } public void setProfileNameAndContent(String name, String profile) { - setProfileNameAndContent(name, profile.getBytes(PngHelper.charsetLatin1)); + setProfileNameAndContent(name, profile.getBytes(PngHelperInternal.charsetLatin1)); } public String getProfileName() { @@ -79,7 +80,7 @@ public class PngChunkICCP extends PngChunk { } public String getProfileAsString() { - return new String(getProfile(), PngHelper.charsetLatin1); + return new String(getProfile(), PngHelperInternal.charsetLatin1); } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java index a7cb95dbf..b816db205 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIDAT.java @@ -2,21 +2,35 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -public class PngChunkIDAT extends PngChunk { +/** + * IDAT chunk. + *

        + * see http://www.w3.org/TR/PNG/#11IDAT + *

        + * This is dummy placeholder - we write/read this chunk (actually several) by special code. + */ +public class PngChunkIDAT extends PngChunkMultiple { + public final static String ID = ChunkHelper.IDAT; + // http://www.w3.org/TR/PNG/#11IDAT - // This is dummy placeholder - we write/read this chunk (actually several) - // by special code. - public PngChunkIDAT(ImageInfo i) { - super(ChunkHelper.IDAT, i); + public PngChunkIDAT(ImageInfo i, int len, long offset) { + super(ID, i); + this.length = len; + this.offset = offset; + } + + @Override + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.NA; } @Override - public ChunkRaw createChunk() {// does nothing + public ChunkRaw createRawChunk() {// does nothing return null; } @Override - public void parseFromChunk(ChunkRaw c) { // does nothing + public void parseFromRaw(ChunkRaw c) { // does nothing } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIEND.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIEND.java index 0d5b266da..fbec564d8 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIEND.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIEND.java @@ -2,21 +2,33 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -public class PngChunkIEND extends PngChunk { +/** + * IEND chunk. + *

        + * see http://www.w3.org/TR/PNG/#11IEND + */ +public class PngChunkIEND extends PngChunkSingle { + public final static String ID = ChunkHelper.IEND; + // http://www.w3.org/TR/PNG/#11IEND // this is a dummy placeholder public PngChunkIEND(ImageInfo info) { - super(ChunkHelper.IEND, info); + super(ID, info); + } + + @Override + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.NA; } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = new ChunkRaw(0, ChunkHelper.b_IEND, false); return c; } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { // this is not used } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIHDR.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIHDR.java index fcb4150ff..94bfedd38 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIHDR.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkIHDR.java @@ -3,14 +3,20 @@ package jogamp.opengl.util.pngj.chunks; import java.io.ByteArrayInputStream; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; /** - * this is a special chunk! + * IHDR chunk. + *

        + * see http://www.w3.org/TR/PNG/#11IHDR + *

        + * This is a special critical Chunk. */ -public class PngChunkIHDR extends PngChunk { +public class PngChunkIHDR extends PngChunkSingle { + public final static String ID = ChunkHelper.IHDR; + private int cols; private int rows; private int bitspc; @@ -22,16 +28,21 @@ public class PngChunkIHDR extends PngChunk { // http://www.w3.org/TR/PNG/#11IHDR // public PngChunkIHDR(ImageInfo info) { - super(ChunkHelper.IHDR, info); + super(ID, info); + } + + @Override + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.NA; } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = new ChunkRaw(13, ChunkHelper.b_IHDR, true); int offset = 0; - PngHelper.writeInt4tobytes(cols, c.data, offset); + PngHelperInternal.writeInt4tobytes(cols, c.data, offset); offset += 4; - PngHelper.writeInt4tobytes(rows, c.data, offset); + PngHelperInternal.writeInt4tobytes(rows, c.data, offset); offset += 4; c.data[offset++] = (byte) bitspc; c.data[offset++] = (byte) colormodel; @@ -42,18 +53,18 @@ public class PngChunkIHDR extends PngChunk { } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { if (c.len != 13) throw new PngjException("Bad IDHR len " + c.len); ByteArrayInputStream st = c.getAsByteStream(); - cols = PngHelper.readInt4(st); - rows = PngHelper.readInt4(st); + cols = PngHelperInternal.readInt4(st); + rows = PngHelperInternal.readInt4(st); // bit depth: number of bits per channel - bitspc = PngHelper.readByte(st); - colormodel = PngHelper.readByte(st); - compmeth = PngHelper.readByte(st); - filmeth = PngHelper.readByte(st); - interlaced = PngHelper.readByte(st); + bitspc = PngHelperInternal.readByte(st); + colormodel = PngHelperInternal.readByte(st); + compmeth = PngHelperInternal.readByte(st); + filmeth = PngHelperInternal.readByte(st); + interlaced = PngHelperInternal.readByte(st); } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkITXT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkITXT.java index 4e5c7c74a..ab52d7c90 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkITXT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkITXT.java @@ -4,14 +4,17 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; /** - * UNTESTED! + * iTXt chunk. + *

        + * see http://www.w3.org/TR/PNG/#11iTXt */ public class PngChunkITXT extends PngChunkTextVar { + public final static String ID = ChunkHelper.iTXt; private boolean compressed = false; private String langTag = ""; @@ -19,24 +22,24 @@ public class PngChunkITXT extends PngChunkTextVar { // http://www.w3.org/TR/PNG/#11iTXt public PngChunkITXT(ImageInfo info) { - super(ChunkHelper.iTXt, info); + super(ID, info); } @Override - public ChunkRaw createChunk() { - if (val.isEmpty() || key.isEmpty()) - return null; + public ChunkRaw createRawChunk() { + if (key.isEmpty()) + throw new PngjException("Text chunk key must be non empty"); try { ByteArrayOutputStream ba = new ByteArrayOutputStream(); - ba.write(key.getBytes(PngHelper.charsetLatin1)); + ba.write(ChunkHelper.toBytes(key)); ba.write(0); // separator ba.write(compressed ? 1 : 0); ba.write(0); // compression method (always 0) - ba.write(langTag.getBytes(PngHelper.charsetUTF8)); + ba.write(ChunkHelper.toBytes(langTag)); ba.write(0); // separator - ba.write(translatedTag.getBytes(PngHelper.charsetUTF8)); + ba.write(ChunkHelper.toBytesUTF8(translatedTag)); ba.write(0); // separator - byte[] textbytes = val.getBytes(PngHelper.charsetUTF8); + byte[] textbytes = ChunkHelper.toBytesUTF8(val); if (compressed) { textbytes = ChunkHelper.compressBytes(textbytes, true); } @@ -51,7 +54,7 @@ public class PngChunkITXT extends PngChunkTextVar { } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { int nullsFound = 0; int[] nullsIdx = new int[3]; for (int i = 0; i < c.data.length; i++) { @@ -66,20 +69,21 @@ public class PngChunkITXT extends PngChunkTextVar { } if (nullsFound != 3) throw new PngjException("Bad formed PngChunkITXT chunk"); - key = new String(c.data, 0, nullsIdx[0], PngHelper.charsetLatin1); + key = ChunkHelper.toString(c.data, 0, nullsIdx[0]); int i = nullsIdx[0] + 1; compressed = c.data[i] == 0 ? false : true; i++; if (compressed && c.data[i] != 0) throw new PngjException("Bad formed PngChunkITXT chunk - bad compression method "); - langTag = new String(c.data, i, nullsIdx[1] - i, PngHelper.charsetLatin1); - translatedTag = new String(c.data, nullsIdx[1] + 1, nullsIdx[2] - nullsIdx[1] - 1, PngHelper.charsetUTF8); + langTag = new String(c.data, i, nullsIdx[1] - i, PngHelperInternal.charsetLatin1); + translatedTag = new String(c.data, nullsIdx[1] + 1, nullsIdx[2] - nullsIdx[1] - 1, + PngHelperInternal.charsetUTF8); i = nullsIdx[2] + 1; if (compressed) { byte[] bytes = ChunkHelper.compressBytes(c.data, i, c.data.length - i, false); - val = new String(bytes, PngHelper.charsetUTF8); + val = ChunkHelper.toStringUTF8(bytes); } else { - val = new String(c.data, i, c.data.length - i, PngHelper.charsetUTF8); + val = ChunkHelper.toStringUTF8(c.data, i, c.data.length - i); } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java new file mode 100644 index 000000000..696edd431 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkMultiple.java @@ -0,0 +1,27 @@ +package jogamp.opengl.util.pngj.chunks; + +import jogamp.opengl.util.pngj.ImageInfo; + +/** + * PNG chunk type (abstract) that allows multiple instances in same image. + */ +public abstract class PngChunkMultiple extends PngChunk { + + protected PngChunkMultiple(String id, ImageInfo imgInfo) { + super(id, imgInfo); + } + + @Override + public final boolean allowsMultiple() { + return true; + } + + /** + * NOTE: this chunk uses the default Object's equals() hashCode() implementation. + * + * This is the right thing to do, normally. + * + * This is important, eg see ChunkList.removeFromList() + */ + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkOFFS.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkOFFS.java new file mode 100644 index 000000000..a3bab4995 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkOFFS.java @@ -0,0 +1,89 @@ +package jogamp.opengl.util.pngj.chunks; + +import jogamp.opengl.util.pngj.ImageInfo; +import jogamp.opengl.util.pngj.PngHelperInternal; +import jogamp.opengl.util.pngj.PngjException; + +/** + * oFFs chunk. + *

        + * see http://www.libpng.org/pub/png/spec/register/pngext-1.3.0-pdg.html#C.oFFs + */ +public class PngChunkOFFS extends PngChunkSingle { + public final static String ID = "oFFs"; + + // http://www.libpng.org/pub/png/spec/register/pngext-1.3.0-pdg.html#C.oFFs + private long posX; + private long posY; + private int units; // 0: pixel 1:micrometer + + public PngChunkOFFS(ImageInfo info) { + super(ID, info); + } + + @Override + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.BEFORE_IDAT; + } + + @Override + public ChunkRaw createRawChunk() { + ChunkRaw c = createEmptyChunk(9, true); + PngHelperInternal.writeInt4tobytes((int) posX, c.data, 0); + PngHelperInternal.writeInt4tobytes((int) posY, c.data, 4); + c.data[8] = (byte) units; + return c; + } + + @Override + public void parseFromRaw(ChunkRaw chunk) { + if (chunk.len != 9) + throw new PngjException("bad chunk length " + chunk); + posX = PngHelperInternal.readInt4fromBytes(chunk.data, 0); + if (posX < 0) + posX += 0x100000000L; + posY = PngHelperInternal.readInt4fromBytes(chunk.data, 4); + if (posY < 0) + posY += 0x100000000L; + units = PngHelperInternal.readInt1fromByte(chunk.data, 8); + } + + @Override + public void cloneDataFromRead(PngChunk other) { + PngChunkOFFS otherx = (PngChunkOFFS) other; + this.posX = otherx.posX; + this.posY = otherx.posY; + this.units = otherx.units; + } + + /** + * 0: pixel, 1:micrometer + */ + public int getUnits() { + return units; + } + + /** + * 0: pixel, 1:micrometer + */ + public void setUnits(int units) { + this.units = units; + } + + public long getPosX() { + return posX; + } + + public void setPosX(long posX) { + this.posX = posX; + } + + public long getPosY() { + return posY; + } + + public void setPosY(long posY) { + this.posY = posY; + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPHYS.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPHYS.java index 47e2c492c..b0a1bb898 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPHYS.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPHYS.java @@ -1,44 +1,50 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; +/** + * pHYs chunk. + *

        + * see http://www.w3.org/TR/PNG/#11pHYs + */ +public class PngChunkPHYS extends PngChunkSingle { + public final static String ID = ChunkHelper.pHYs; -public class PngChunkPHYS extends PngChunk { // http://www.w3.org/TR/PNG/#11pHYs private long pixelsxUnitX; private long pixelsxUnitY; private int units; // 0: unknown 1:metre public PngChunkPHYS(ImageInfo info) { - super(ChunkHelper.pHYs, info); + super(ID, info); } @Override - public boolean mustGoBeforeIDAT() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.BEFORE_IDAT; } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = createEmptyChunk(9, true); - PngHelper.writeInt4tobytes((int) pixelsxUnitX, c.data, 0); - PngHelper.writeInt4tobytes((int) pixelsxUnitY, c.data, 4); + PngHelperInternal.writeInt4tobytes((int) pixelsxUnitX, c.data, 0); + PngHelperInternal.writeInt4tobytes((int) pixelsxUnitY, c.data, 4); c.data[8] = (byte) units; return c; } @Override - public void parseFromChunk(ChunkRaw chunk) { + public void parseFromRaw(ChunkRaw chunk) { if (chunk.len != 9) throw new PngjException("bad chunk length " + chunk); - pixelsxUnitX = PngHelper.readInt4fromBytes(chunk.data, 0); + pixelsxUnitX = PngHelperInternal.readInt4fromBytes(chunk.data, 0); if (pixelsxUnitX < 0) pixelsxUnitX += 0x100000000L; - pixelsxUnitY = PngHelper.readInt4fromBytes(chunk.data, 4); + pixelsxUnitY = PngHelperInternal.readInt4fromBytes(chunk.data, 4); if (pixelsxUnitY < 0) pixelsxUnitY += 0x100000000L; - units = PngHelper.readInt1fromByte(chunk.data, 8); + units = PngHelperInternal.readInt1fromByte(chunk.data, 8); } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPLTE.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPLTE.java index 123080bb3..dbf5e53c0 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPLTE.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkPLTE.java @@ -3,10 +3,16 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; import jogamp.opengl.util.pngj.PngjException; -/* - * Palette chunk *this is critical* +/** + * PLTE chunk. + *

        + * see http://www.w3.org/TR/PNG/#11PLTE + *

        + * Critical chunk */ -public class PngChunkPLTE extends PngChunk { +public class PngChunkPLTE extends PngChunkSingle { + public final static String ID = ChunkHelper.PLTE; + // http://www.w3.org/TR/PNG/#11PLTE private int nentries = 0; /** @@ -15,11 +21,16 @@ public class PngChunkPLTE extends PngChunk { private int[] entries; public PngChunkPLTE(ImageInfo info) { - super(ChunkHelper.PLTE, info); + super(ID, info); + } + + @Override + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.NA; } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { int len = 3 * nentries; int[] rgb = new int[3]; ChunkRaw c = createEmptyChunk(len, true); @@ -33,7 +44,7 @@ public class PngChunkPLTE extends PngChunk { } @Override - public void parseFromChunk(ChunkRaw chunk) { + public void parseFromRaw(ChunkRaw chunk) { setNentries(chunk.len / 3); for (int n = 0, i = 0; n < nentries; n++) { setEntry(n, (int) (chunk.data[i++] & 0xff), (int) (chunk.data[i++] & 0xff), (int) (chunk.data[i++] & 0xff)); diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java index 6850d260d..bc70c6e5e 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSBIT.java @@ -1,31 +1,31 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; -/* +/** + * sBIT chunk. + *

        + * see http://www.w3.org/TR/PNG/#11sBIT + *

        + * this chunk structure depends on the image type */ -public class PngChunkSBIT extends PngChunk { +public class PngChunkSBIT extends PngChunkSingle { + public final static String ID = ChunkHelper.sBIT; // http://www.w3.org/TR/PNG/#11sBIT - // this chunk structure depends on the image type // significant bits private int graysb, alphasb; private int redsb, greensb, bluesb; public PngChunkSBIT(ImageInfo info) { - super(ChunkHelper.sBIT, info); + super(ID, info); } @Override - public boolean mustGoBeforeIDAT() { - return true; - } - - @Override - public boolean mustGoBeforePLTE() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT; } private int getLen() { @@ -36,24 +36,24 @@ public class PngChunkSBIT extends PngChunk { } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { if (c.len != getLen()) throw new PngjException("bad chunk length " + c); if (imgInfo.greyscale) { - graysb = PngHelper.readInt1fromByte(c.data, 0); + graysb = PngHelperInternal.readInt1fromByte(c.data, 0); if (imgInfo.alpha) - alphasb = PngHelper.readInt1fromByte(c.data, 1); + alphasb = PngHelperInternal.readInt1fromByte(c.data, 1); } else { - redsb = PngHelper.readInt1fromByte(c.data, 0); - greensb = PngHelper.readInt1fromByte(c.data, 1); - bluesb = PngHelper.readInt1fromByte(c.data, 2); + redsb = PngHelperInternal.readInt1fromByte(c.data, 0); + greensb = PngHelperInternal.readInt1fromByte(c.data, 1); + bluesb = PngHelperInternal.readInt1fromByte(c.data, 2); if (imgInfo.alpha) - alphasb = PngHelper.readInt1fromByte(c.data, 3); + alphasb = PngHelperInternal.readInt1fromByte(c.data, 3); } } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = null; c = createEmptyChunk(getLen(), true); if (imgInfo.greyscale) { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSPLT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSPLT.java index 953adb7d9..2ff65834d 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSPLT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSPLT.java @@ -4,11 +4,17 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; +/** + * sPLT chunk. + *

        + * see http://www.w3.org/TR/PNG/#11sPLT + */ +public class PngChunkSPLT extends PngChunkMultiple { + public final static String ID = ChunkHelper.sPLT; -public class PngChunkSPLT extends PngChunk { // http://www.w3.org/TR/PNG/#11sPLT private String palName; @@ -16,35 +22,30 @@ public class PngChunkSPLT extends PngChunk { private int[] palette; // 5 elements per entry public PngChunkSPLT(ImageInfo info) { - super(ChunkHelper.sPLT, info); + super(ID, info); } @Override - public boolean allowsMultiple() { - return true; // allows multiple, but pallete name should be different + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.BEFORE_IDAT; } @Override - public boolean mustGoBeforeIDAT() { - return true; - } - - @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { try { ByteArrayOutputStream ba = new ByteArrayOutputStream(); - ba.write(palName.getBytes(PngHelper.charsetLatin1)); + ba.write(palName.getBytes(PngHelperInternal.charsetLatin1)); ba.write(0); // separator ba.write((byte) sampledepth); int nentries = getNentries(); for (int n = 0; n < nentries; n++) { for (int i = 0; i < 4; i++) { if (sampledepth == 8) - PngHelper.writeByte(ba, (byte) palette[n * 5 + i]); + PngHelperInternal.writeByte(ba, (byte) palette[n * 5 + i]); else - PngHelper.writeInt2(ba, palette[n * 5 + i]); + PngHelperInternal.writeInt2(ba, palette[n * 5 + i]); } - PngHelper.writeInt2(ba, palette[n * 5 + 4]); + PngHelperInternal.writeInt2(ba, palette[n * 5 + 4]); } byte[] b = ba.toByteArray(); ChunkRaw chunk = createEmptyChunk(b.length, false); @@ -56,7 +57,7 @@ public class PngChunkSPLT extends PngChunk { } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { int t = -1; for (int i = 0; i < c.data.length; i++) { // look for first zero if (c.data[i] == 0) { @@ -66,8 +67,8 @@ public class PngChunkSPLT extends PngChunk { } if (t <= 0 || t > c.data.length - 2) throw new PngjException("bad sPLT chunk: no separator found"); - palName = new String(c.data, 0, t, PngHelper.charsetLatin1); - sampledepth = PngHelper.readInt1fromByte(c.data, t + 1); + palName = new String(c.data, 0, t, PngHelperInternal.charsetLatin1); + sampledepth = PngHelperInternal.readInt1fromByte(c.data, t + 1); t += 2; int nentries = (c.data.length - t) / (sampledepth == 8 ? 6 : 10); palette = new int[nentries * 5]; @@ -75,21 +76,21 @@ public class PngChunkSPLT extends PngChunk { ne = 0; for (int i = 0; i < nentries; i++) { if (sampledepth == 8) { - r = PngHelper.readInt1fromByte(c.data, t++); - g = PngHelper.readInt1fromByte(c.data, t++); - b = PngHelper.readInt1fromByte(c.data, t++); - a = PngHelper.readInt1fromByte(c.data, t++); + r = PngHelperInternal.readInt1fromByte(c.data, t++); + g = PngHelperInternal.readInt1fromByte(c.data, t++); + b = PngHelperInternal.readInt1fromByte(c.data, t++); + a = PngHelperInternal.readInt1fromByte(c.data, t++); } else { - r = PngHelper.readInt2fromBytes(c.data, t); + r = PngHelperInternal.readInt2fromBytes(c.data, t); t += 2; - g = PngHelper.readInt2fromBytes(c.data, t); + g = PngHelperInternal.readInt2fromBytes(c.data, t); t += 2; - b = PngHelper.readInt2fromBytes(c.data, t); + b = PngHelperInternal.readInt2fromBytes(c.data, t); t += 2; - a = PngHelper.readInt2fromBytes(c.data, t); + a = PngHelperInternal.readInt2fromBytes(c.data, t); t += 2; } - f = PngHelper.readInt2fromBytes(c.data, t); + f = PngHelperInternal.readInt2fromBytes(c.data, t); t += 2; palette[ne++] = r; palette[ne++] = g; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSRGB.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSRGB.java index 774558785..e4d77d40a 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSRGB.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSRGB.java @@ -1,12 +1,17 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; -/* +/** + * sRGB chunk. + *

        + * see http://www.w3.org/TR/PNG/#11sRGB */ -public class PngChunkSRGB extends PngChunk { +public class PngChunkSRGB extends PngChunkSingle { + public final static String ID = ChunkHelper.sRGB; + // http://www.w3.org/TR/PNG/#11sRGB public static final int RENDER_INTENT_Perceptual = 0; @@ -17,28 +22,23 @@ public class PngChunkSRGB extends PngChunk { private int intent; public PngChunkSRGB(ImageInfo info) { - super(ChunkHelper.sRGB, info); - } - - @Override - public boolean mustGoBeforeIDAT() { - return true; + super(ID, info); } @Override - public boolean mustGoBeforePLTE() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.BEFORE_PLTE_AND_IDAT; } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { if (c.len != 1) throw new PngjException("bad chunk length " + c); - intent = PngHelper.readInt1fromByte(c.data, 0); + intent = PngHelperInternal.readInt1fromByte(c.data, 0); } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = null; c = createEmptyChunk(1, true); c.data[0] = (byte) intent; diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSTER.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSTER.java new file mode 100644 index 000000000..4dc5edec5 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSTER.java @@ -0,0 +1,60 @@ +package jogamp.opengl.util.pngj.chunks; + +import jogamp.opengl.util.pngj.ImageInfo; +import jogamp.opengl.util.pngj.PngjException; + +/** + * sTER chunk. + *

        + * see http://www.libpng.org/pub/png/spec/register/pngext-1.3.0-pdg.html#C.sTER + */ +public class PngChunkSTER extends PngChunkSingle { + public final static String ID = "sTER"; + + // http://www.libpng.org/pub/png/spec/register/pngext-1.3.0-pdg.html#C.sTER + private byte mode; // 0: cross-fuse layout 1: diverging-fuse layout + + public PngChunkSTER(ImageInfo info) { + super(ID, info); + } + + @Override + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.BEFORE_IDAT; + } + + @Override + public ChunkRaw createRawChunk() { + ChunkRaw c = createEmptyChunk(1, true); + c.data[0] = (byte) mode; + return c; + } + + @Override + public void parseFromRaw(ChunkRaw chunk) { + if (chunk.len != 1) + throw new PngjException("bad chunk length " + chunk); + mode = chunk.data[0]; + } + + @Override + public void cloneDataFromRead(PngChunk other) { + PngChunkSTER otherx = (PngChunkSTER) other; + this.mode = otherx.mode; + } + + /** + * 0: cross-fuse layout 1: diverging-fuse layout + */ + public byte getMode() { + return mode; + } + + /** + * 0: cross-fuse layout 1: diverging-fuse layout + */ + public void setMode(byte mode) { + this.mode = mode; + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java new file mode 100644 index 000000000..286f39db0 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSingle.java @@ -0,0 +1,43 @@ +package jogamp.opengl.util.pngj.chunks; + +import jogamp.opengl.util.pngj.ImageInfo; + +/** + * PNG chunk type (abstract) that does not allow multiple instances in same image. + */ +public abstract class PngChunkSingle extends PngChunk { + + protected PngChunkSingle(String id, ImageInfo imgInfo) { + super(id, imgInfo); + } + + public final boolean allowsMultiple() { + return false; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PngChunkSingle other = (PngChunkSingle) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSkipped.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSkipped.java new file mode 100644 index 000000000..f4c77b4e1 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkSkipped.java @@ -0,0 +1,41 @@ +package jogamp.opengl.util.pngj.chunks; + +import jogamp.opengl.util.pngj.ImageInfo; +import jogamp.opengl.util.pngj.PngjException; + +/** + * Pseudo chunk type, for chunks that were skipped on reading + */ +public class PngChunkSkipped extends PngChunk { + + public PngChunkSkipped(String id, ImageInfo info, int clen) { + super(id, info); + this.length = clen; + } + + @Override + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.NONE; + } + + @Override + public ChunkRaw createRawChunk() { + throw new PngjException("Non supported for a skipped chunk"); + } + + @Override + public void parseFromRaw(ChunkRaw c) { + throw new PngjException("Non supported for a skipped chunk"); + } + + @Override + public void cloneDataFromRead(PngChunk other) { + throw new PngjException("Non supported for a skipped chunk"); + } + + @Override + public boolean allowsMultiple() { + return true; + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTEXT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTEXT.java index c535fe34a..d97cd63c5 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTEXT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTEXT.java @@ -1,28 +1,40 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; +import jogamp.opengl.util.pngj.PngjException; +/** + * tEXt chunk. + *

        + * see http://www.w3.org/TR/PNG/#11tEXt + */ public class PngChunkTEXT extends PngChunkTextVar { + public final static String ID = ChunkHelper.tEXt; + public PngChunkTEXT(ImageInfo info) { - super(ChunkHelper.tEXt, info); + super(ID, info); } @Override - public ChunkRaw createChunk() { - if (val.isEmpty() || key.isEmpty()) - return null; - byte[] b = (key + "\0" + val).getBytes(PngHelper.charsetLatin1); + public ChunkRaw createRawChunk() { + if (key.isEmpty()) + throw new PngjException("Text chunk key must be non empty"); + byte[] b = (key + "\0" + val).getBytes(PngHelperInternal.charsetLatin1); ChunkRaw chunk = createEmptyChunk(b.length, false); chunk.data = b; return chunk; } @Override - public void parseFromChunk(ChunkRaw c) { - String[] k = (new String(c.data, PngHelper.charsetLatin1)).split("\0"); - key = k[0]; - val = k[1]; + public void parseFromRaw(ChunkRaw c) { + int i; + for (i = 0; i < c.data.length; i++) + if (c.data[i] == 0) + break; + key = new String(c.data, 0, i, PngHelperInternal.charsetLatin1); + i++; + val = i < c.data.length ? new String(c.data, i, c.data.length - i, PngHelperInternal.charsetLatin1) : ""; } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTIME.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTIME.java index fa61f6237..8f34c78fe 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTIME.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTIME.java @@ -3,22 +3,33 @@ package jogamp.opengl.util.pngj.chunks; import java.util.Calendar; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; +/** + * tIME chunk. + *

        + * see http://www.w3.org/TR/PNG/#11tIME + */ +public class PngChunkTIME extends PngChunkSingle { + public final static String ID = ChunkHelper.tIME; -public class PngChunkTIME extends PngChunk { // http://www.w3.org/TR/PNG/#11tIME private int year, mon, day, hour, min, sec; public PngChunkTIME(ImageInfo info) { - super(ChunkHelper.tIME, info); + super(ID, info); } @Override - public ChunkRaw createChunk() { + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.NONE; + } + + @Override + public ChunkRaw createRawChunk() { ChunkRaw c = createEmptyChunk(7, true); - PngHelper.writeInt2tobytes(year, c.data, 0); + PngHelperInternal.writeInt2tobytes(year, c.data, 0); c.data[2] = (byte) mon; c.data[3] = (byte) day; c.data[4] = (byte) hour; @@ -28,15 +39,15 @@ public class PngChunkTIME extends PngChunk { } @Override - public void parseFromChunk(ChunkRaw chunk) { + public void parseFromRaw(ChunkRaw chunk) { if (chunk.len != 7) throw new PngjException("bad chunk " + chunk); - year = PngHelper.readInt2fromBytes(chunk.data, 0); - mon = PngHelper.readInt1fromByte(chunk.data, 2); - day = PngHelper.readInt1fromByte(chunk.data, 3); - hour = PngHelper.readInt1fromByte(chunk.data, 4); - min = PngHelper.readInt1fromByte(chunk.data, 5); - sec = PngHelper.readInt1fromByte(chunk.data, 6); + year = PngHelperInternal.readInt2fromBytes(chunk.data, 0); + mon = PngHelperInternal.readInt1fromByte(chunk.data, 2); + day = PngHelperInternal.readInt1fromByte(chunk.data, 3); + hour = PngHelperInternal.readInt1fromByte(chunk.data, 4); + min = PngHelperInternal.readInt1fromByte(chunk.data, 5); + sec = PngHelperInternal.readInt1fromByte(chunk.data, 6); } @Override @@ -69,6 +80,7 @@ public class PngChunkTIME extends PngChunk { min = minx; sec = secx; } + public int[] getYMDHMS() { return new int[] { year, mon, day, hour, min, sec }; } @@ -78,6 +90,4 @@ public class PngChunkTIME extends PngChunk { return String.format("%04d/%02d/%02d %02d:%02d:%02d", year, mon, day, hour, min, sec); } - - } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java index 9365e5e8e..1de5c0833 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java @@ -1,39 +1,41 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; -/* +/** + * tRNS chunk. + *

        + * see http://www.w3.org/TR/PNG/#11tRNS + *

        + * this chunk structure depends on the image type */ -public class PngChunkTRNS extends PngChunk { +public class PngChunkTRNS extends PngChunkSingle { + public final static String ID = ChunkHelper.tRNS; + // http://www.w3.org/TR/PNG/#11tRNS - // this chunk structure depends on the image type - // only one of these is meaningful + + // only one of these is meaningful, depending on the image type private int gray; private int red, green, blue; private int[] paletteAlpha = new int[] {}; public PngChunkTRNS(ImageInfo info) { - super(ChunkHelper.tRNS, info); - } - - @Override - public boolean mustGoBeforeIDAT() { - return true; + super(ID, info); } @Override - public boolean mustGoAfterPLTE() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT; } @Override - public ChunkRaw createChunk() { + public ChunkRaw createRawChunk() { ChunkRaw c = null; if (imgInfo.greyscale) { c = createEmptyChunk(2, true); - PngHelper.writeInt2tobytes(gray, c.data, 0); + PngHelperInternal.writeInt2tobytes(gray, c.data, 0); } else if (imgInfo.indexed) { c = createEmptyChunk(paletteAlpha.length, true); for (int n = 0; n < c.len; n++) { @@ -41,17 +43,17 @@ public class PngChunkTRNS extends PngChunk { } } else { c = createEmptyChunk(6, true); - PngHelper.writeInt2tobytes(red, c.data, 0); - PngHelper.writeInt2tobytes(green, c.data, 0); - PngHelper.writeInt2tobytes(blue, c.data, 0); + PngHelperInternal.writeInt2tobytes(red, c.data, 0); + PngHelperInternal.writeInt2tobytes(green, c.data, 0); + PngHelperInternal.writeInt2tobytes(blue, c.data, 0); } return c; } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { if (imgInfo.greyscale) { - gray = PngHelper.readInt2fromBytes(c.data, 0); + gray = PngHelperInternal.readInt2fromBytes(c.data, 0); } else if (imgInfo.indexed) { int nentries = c.data.length; paletteAlpha = new int[nentries]; @@ -59,9 +61,9 @@ public class PngChunkTRNS extends PngChunk { paletteAlpha[n] = (int) (c.data[n] & 0xff); } } else { - red = PngHelper.readInt2fromBytes(c.data, 0); - green = PngHelper.readInt2fromBytes(c.data, 2); - blue = PngHelper.readInt2fromBytes(c.data, 4); + red = PngHelperInternal.readInt2fromBytes(c.data, 0); + green = PngHelperInternal.readInt2fromBytes(c.data, 2); + blue = PngHelperInternal.readInt2fromBytes(c.data, 4); } } @@ -117,6 +119,18 @@ public class PngChunkTRNS extends PngChunk { paletteAlpha = palAlpha; } + /** + * to use when only one pallete index is set as totally transparent + */ + public void setIndexEntryAsTransparent(int palAlphaIndex) { + if (!imgInfo.indexed) + throw new PngjException("only indexed images support this"); + paletteAlpha = new int[] { palAlphaIndex + 1 }; + for (int i = 0; i < palAlphaIndex; i++) + paletteAlpha[i] = 255; + paletteAlpha[palAlphaIndex] = 0; + } + /** * WARNING: non deep copy */ diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTextVar.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTextVar.java index 3d92a806f..ba3ffc30c 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTextVar.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTextVar.java @@ -3,11 +3,9 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; /** - * superclass for three textual chunks (TEXT, ITXT, ZTXT) - * - * @author Hernan J Gonzalez + * Superclass (abstract) for three textual chunks (TEXT, ITXT, ZTXT) */ -public abstract class PngChunkTextVar extends PngChunk { +public abstract class PngChunkTextVar extends PngChunkMultiple { protected String key; // key/val: only for tEXt. lazy computed protected String val; @@ -28,8 +26,8 @@ public abstract class PngChunkTextVar extends PngChunk { } @Override - public boolean allowsMultiple() { - return true; + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.NONE; } public static class PngTxtInfo { diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkUNKNOWN.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkUNKNOWN.java index 15a35935a..3803428e6 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkUNKNOWN.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkUNKNOWN.java @@ -2,7 +2,12 @@ package jogamp.opengl.util.pngj.chunks; import jogamp.opengl.util.pngj.ImageInfo; -public class PngChunkUNKNOWN extends PngChunk { // unkown, custom or not +/** + * Placeholder for UNKNOWN (custom or not) chunks. + *

        + * For PngReader, a chunk is unknown if it's not registered in the chunk factory + */ +public class PngChunkUNKNOWN extends PngChunkMultiple { // unkown, custom or not private byte[] data; @@ -10,25 +15,25 @@ public class PngChunkUNKNOWN extends PngChunk { // unkown, custom or not super(id, info); } - @Override - public boolean allowsMultiple() { - return true; - } - private PngChunkUNKNOWN(PngChunkUNKNOWN c, ImageInfo info) { super(c.id, info); System.arraycopy(c.data, 0, data, 0, c.data.length); } @Override - public ChunkRaw createChunk() { + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.NONE; + } + + @Override + public ChunkRaw createRawChunk() { ChunkRaw p = createEmptyChunk(data.length, false); p.data = this.data; return p; } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { data = c.data; } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkZTXT.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkZTXT.java index fd6c08273..64593eae4 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkZTXT.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkZTXT.java @@ -4,26 +4,32 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelper; +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; - +/** + * zTXt chunk. + *

        + * see http://www.w3.org/TR/PNG/#11zTXt + */ public class PngChunkZTXT extends PngChunkTextVar { + public final static String ID = ChunkHelper.zTXt; + // http://www.w3.org/TR/PNG/#11zTXt public PngChunkZTXT(ImageInfo info) { - super(ChunkHelper.zTXt, info); + super(ID, info); } @Override - public ChunkRaw createChunk() { - if (val.isEmpty() || key.isEmpty()) - return null; + public ChunkRaw createRawChunk() { + if (key.isEmpty()) + throw new PngjException("Text chunk key must be non empty"); try { ByteArrayOutputStream ba = new ByteArrayOutputStream(); - ba.write(key.getBytes(PngHelper.charsetLatin1)); + ba.write(key.getBytes(PngHelperInternal.charsetLatin1)); ba.write(0); // separator ba.write(0); // compression method: 0 - byte[] textbytes = ChunkHelper.compressBytes(val.getBytes(PngHelper.charsetLatin1), true); + byte[] textbytes = ChunkHelper.compressBytes(val.getBytes(PngHelperInternal.charsetLatin1), true); ba.write(textbytes); byte[] b = ba.toByteArray(); ChunkRaw chunk = createEmptyChunk(b.length, false); @@ -35,7 +41,7 @@ public class PngChunkZTXT extends PngChunkTextVar { } @Override - public void parseFromChunk(ChunkRaw c) { + public void parseFromRaw(ChunkRaw c) { int nullsep = -1; for (int i = 0; i < c.data.length; i++) { // look for first zero if (c.data[i] != 0) @@ -45,12 +51,12 @@ public class PngChunkZTXT extends PngChunkTextVar { } if (nullsep < 0 || nullsep > c.data.length - 2) throw new PngjException("bad zTXt chunk: no separator found"); - key = new String(c.data, 0, nullsep, PngHelper.charsetLatin1); + key = new String(c.data, 0, nullsep, PngHelperInternal.charsetLatin1); int compmet = (int) c.data[nullsep + 1]; if (compmet != 0) throw new PngjException("bad zTXt chunk: unknown compression method"); byte[] uncomp = ChunkHelper.compressBytes(c.data, nullsep + 2, c.data.length - nullsep - 2, false); // uncompress - val = new String(uncomp, PngHelper.charsetLatin1); + val = new String(uncomp, PngHelperInternal.charsetLatin1); } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java index a82754588..52d1b22c1 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngMetadata.java @@ -1,68 +1,70 @@ package jogamp.opengl.util.pngj.chunks; -import jogamp.opengl.util.pngj.PngHelper; +import java.util.ArrayList; +import java.util.List; + +import jogamp.opengl.util.pngj.PngHelperInternal; import jogamp.opengl.util.pngj.PngjException; /** * We consider "image metadata" every info inside the image except for the most basic image info (IHDR chunk - ImageInfo * class) and the pixels values. - * + *

        * This includes the palette (if present) and all the ancillary chunks - * + *

        * This class provides a wrapper over the collection of chunks of a image (read or to write) and provides some high * level methods to access them - * */ public class PngMetadata { - private final ChunkList chunkList; + private final ChunksList chunkList; private final boolean readonly; - public PngMetadata(ChunkList chunks, boolean readonly) { + public PngMetadata(ChunksList chunks) { this.chunkList = chunks; - this.readonly = readonly; + if (chunks instanceof ChunksListForWrite) { + this.readonly = false; + } else { + this.readonly = true; + } } /** * Queues the chunk at the writer + *

        + * lazyOverwrite: if true, checks if there is a queued "equivalent" chunk and if so, overwrites it. However if that + * not check for already written chunks. */ - public boolean setChunk(PngChunk c, boolean overwriteIfPresent) { + public void queueChunk(final PngChunk c, boolean lazyOverwrite) { + ChunksListForWrite cl = getChunkListW(); if (readonly) throw new PngjException("cannot set chunk : readonly metadata"); - return chunkList.setChunk(c, overwriteIfPresent); + if (lazyOverwrite) { + ChunkHelper.trimList(cl.getQueuedChunks(), new ChunkPredicate() { + public boolean match(PngChunk c2) { + return ChunkHelper.equivalent(c, c2); + } + }); + } + cl.queue(c); } - - /** - * Returns only one chunk or null if nothing found - does not include queued chunks - * - * If more than one chunk (after filtering by inner id) is found, then an exception is thrown (failifMultiple=true) - * or the last one is returned (failifMultiple=false) - * - * @param id Chunk id - * @param innerid if not null, the chunk is assumed to be PngChunkTextVar or PngChunkSPLT, and filtered by that 'internal id' - * @param failIfMultiple throw exception if more that one - * @return chunk (not cloned) - */ - public PngChunk getChunk1(String id, String innerid, boolean failIfMultiple) { - return chunkList.getChunk1(id, innerid, failIfMultiple); + public void queueChunk(final PngChunk c) { + queueChunk(c, true); } - /** - * Same as getChunk1(id, innerid=null, failIfMultiple=true); - */ - public PngChunk getChunk1(String id) { - return chunkList.getChunk1(id); + private ChunksListForWrite getChunkListW() { + return (ChunksListForWrite) chunkList; } // ///// high level utility methods follow //////////// // //////////// DPI - /** - * returns -1 if not found or dimension unknown - **/ + /** + * returns -1 if not found or dimension unknown + */ public double[] getDpi() { - PngChunk c = getChunk1(ChunkHelper.pHYs, null, true); + PngChunk c = chunkList.getById1(ChunkHelper.pHYs, true); if (c == null) return new double[] { -1, -1 }; else @@ -76,31 +78,68 @@ public class PngMetadata { public void setDpi(double x, double y) { PngChunkPHYS c = new PngChunkPHYS(chunkList.imageInfo); c.setAsDpi2(x, y); - setChunk(c, true); + queueChunk(c); } // //////////// TIME - public void setTimeNow(int secsAgo) { + /** + * Creates a time chunk with current time, less secsAgo seconds + *

        + * + * @return Returns the created-queued chunk, just in case you want to examine or modify it + */ + public PngChunkTIME setTimeNow(int secsAgo) { PngChunkTIME c = new PngChunkTIME(chunkList.imageInfo); c.setNow(secsAgo); - setChunk(c, true); + queueChunk(c); + return c; + } + + public PngChunkTIME setTimeNow() { + return setTimeNow(0); } - public void setTimeYMDHMS(int yearx, int monx, int dayx, int hourx, int minx, int secx) { + /** + * Creates a time chunk with diven date-time + *

        + * + * @return Returns the created-queued chunk, just in case you want to examine or modify it + */ + public PngChunkTIME setTimeYMDHMS(int yearx, int monx, int dayx, int hourx, int minx, int secx) { PngChunkTIME c = new PngChunkTIME(chunkList.imageInfo); c.setYMDHMS(yearx, monx, dayx, hourx, minx, secx); - setChunk(c, true); + queueChunk(c, true); + return c; + } + + /** + * null if not found + */ + public PngChunkTIME getTime() { + return (PngChunkTIME) chunkList.getById1(ChunkHelper.tIME); } public String getTimeAsString() { - PngChunk c = getChunk1(ChunkHelper.tIME, null, true); - return c != null ? ((PngChunkTIME) c).getAsString() : ""; + PngChunkTIME c = getTime(); + return c == null ? "" : c.getAsString(); } // //////////// TEXT - public void setText(String k, String val, boolean useLatin1, boolean compress) { + /** + * Creates a text chunk and queue it. + *

        + * + * @param k + * : key (latin1) + * @param val + * (arbitrary, should be latin1 if useLatin1) + * @param useLatin1 + * @param compress + * @return Returns the created-queued chunks, just in case you want to examine, touch it + */ + public PngChunkTextVar setText(String k, String val, boolean useLatin1, boolean compress) { if (compress && !useLatin1) throw new PngjException("cannot compress non latin text"); PngChunkTextVar c; @@ -115,21 +154,80 @@ public class PngMetadata { ((PngChunkITXT) c).setLangtag(k); // we use the same orig tag (this is not quite right) } c.setKeyVal(k, val); - setChunk(c, true); + queueChunk(c, true); + return c; } - public void setText(String k, String val) { - setText(k, val, false, val.length() > 400); + public PngChunkTextVar setText(String k, String val) { + return setText(k, val, false, false); } - /** tries all text chunks - returns null if not found */ + /** + * gets all text chunks with a given key + *

        + * returns null if not found + *

        + * Warning: this does not check the "lang" key of iTxt + */ + @SuppressWarnings("unchecked") + public List getTxtsForKey(String k) { + @SuppressWarnings("rawtypes") + List c = new ArrayList(); + c.addAll(chunkList.getById(ChunkHelper.tEXt, k)); + c.addAll(chunkList.getById(ChunkHelper.zTXt, k)); + c.addAll(chunkList.getById(ChunkHelper.iTXt, k)); + return c; + } + + /** + * Returns empty if not found, concatenated (with newlines) if multiple! - and trimmed + *

        + * Use getTxtsForKey() if you don't want this behaviour + */ public String getTxtForKey(String k) { - PngChunk c = getChunk1(ChunkHelper.tEXt, k, true); - if (c == null) - c = getChunk1(ChunkHelper.zTXt, k, true); - if (c == null) - c = getChunk1(ChunkHelper.iTXt, k, true); - return c != null ? ((PngChunkTextVar) c).getVal() : null; + List li = getTxtsForKey(k); + if (li.isEmpty()) + return ""; + StringBuilder t = new StringBuilder(); + for (PngChunkTextVar c : li) + t.append(c.getVal()).append("\n"); + return t.toString().trim(); + } + + /** + * Returns the palette chunk, if present + * + * @return null if not present + */ + public PngChunkPLTE getPLTE() { + return (PngChunkPLTE) chunkList.getById1(PngChunkPLTE.ID); + } + + /** + * Creates a new empty palette chunk, queues it for write and return it to the caller, who should fill its entries + */ + public PngChunkPLTE createPLTEChunk() { + PngChunkPLTE plte = new PngChunkPLTE(chunkList.imageInfo); + queueChunk(plte); + return plte; + } + + /** + * Returns the TRNS chunk, if present + * + * @return null if not present + */ + public PngChunkTRNS getTRNS() { + return (PngChunkTRNS) chunkList.getById1(PngChunkTRNS.ID); + } + + /** + * Creates a new empty TRNS chunk, queues it for write and return it to the caller, who should fill its entries + */ + public PngChunkTRNS createTRNSChunk() { + PngChunkTRNS trns = new PngChunkTRNS(chunkList.imageInfo); + queueChunk(trns); + return trns; } } diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/package.html b/src/jogl/classes/jogamp/opengl/util/pngj/package.html index 209b39c59..0b0e2c8c1 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/package.html +++ b/src/jogl/classes/jogamp/opengl/util/pngj/package.html @@ -1,11 +1,10 @@

        -Contains the main classes for the PNGJ library.

        -Client code should rarely need more than the public members of this package. +PNGJ main package

        -See also the nosandbox package if available. +Client code should rarely need more than the public members of this package.

        diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java index 7dbccd5e0..07f35b5a5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java @@ -83,10 +83,12 @@ public class TestPNGTextureFromFileAWT extends UITestCase { public void initTest() throws IOException { grayTextureStream = TestPNGTextureFromFileAWT.class.getResourceAsStream( "grayscale_texture.png" ); Assert.assertNotNull(grayTextureStream); - URLConnection testTextureUrlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader()); - Assert.assertNotNull(testTextureUrlConn); - testTextureStream = testTextureUrlConn.getInputStream(); - Assert.assertNotNull(testTextureStream); + { + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscN01-160x90.png"); + Assert.assertNotNull(testTextureUrlConn); + testTextureStream = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStream); + } } @After diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java index e9ef9b9b6..fe21f86a9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java @@ -61,22 +61,40 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { static boolean showFPS = false; static long duration = 100; // ms InputStream grayTextureStream; - InputStream testTextureStream; + InputStream testTextureStreamN; + InputStream testTextureStreamI; + InputStream testTextureStreamIG; @Before public void initTest() throws IOException { grayTextureStream = TestPNGTextureFromFileNEWT.class.getResourceAsStream( "grayscale_texture.png" ); Assert.assertNotNull(grayTextureStream); - URLConnection testTextureUrlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader()); - Assert.assertNotNull(testTextureUrlConn); - testTextureStream = testTextureUrlConn.getInputStream(); - Assert.assertNotNull(testTextureStream); + { + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscN01-160x90.png"); + Assert.assertNotNull(testTextureUrlConn); + testTextureStreamN = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamN); + } + { + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscI01-160x90.png"); + Assert.assertNotNull(testTextureUrlConn); + testTextureStreamI = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamI); + } + { + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscIG01-160x90.png"); + Assert.assertNotNull(testTextureUrlConn); + testTextureStreamIG = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamIG); + } } @After public void cleanupTest() { grayTextureStream = null; - testTextureStream = null; + testTextureStreamN = null; + testTextureStreamI = null; + testTextureStreamIG = null; } public void testImpl(boolean useFFP, final InputStream istream) throws InterruptedException, IOException { @@ -146,12 +164,30 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { } @Test - public void testTestPNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStream); + public void testTestN_PNGJLoaderGL2() throws InterruptedException, IOException { + testImpl(true, testTextureStreamN); + } + @Test + public void testTestN_PNGJLoaderES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamN); + } + + @Test + public void testTestI_PNGJLoaderGL2() throws InterruptedException, IOException { + testImpl(true, testTextureStreamI); + } + @Test + public void testTestI_PNGJLoaderES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamI); + } + + @Test + public void testTestIG_PNGJLoaderGL2() throws InterruptedException, IOException { + testImpl(true, testTextureStreamIG); } @Test - public void testTestPNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStream); + public void testTestIG_PNGJLoaderES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamIG); } public static void main(String args[]) throws IOException { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscI01-160x90.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscI01-160x90.png new file mode 100644 index 000000000..e579c58c6 Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscI01-160x90.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscIG01-160x90.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscIG01-160x90.png new file mode 100644 index 000000000..b90a90988 Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscIG01-160x90.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscN01-160x90.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscN01-160x90.png new file mode 100644 index 000000000..3df47432e Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscN01-160x90.png differ -- cgit v1.2.3 From 224fab1b2c71464826594740022fdcbe278867dc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 11 Jan 2013 08:13:24 +0100 Subject: GLAutoDrawable/AnimatorBase: Add ExclusiveContextThread (ECT) feature; AnimatorBase: Add setModeBits/MODE_EXPECT_AWT_RENDERING_THREAD; FPSAnimator: Make transactions deterministic. ExclusiveContextThread (ECT) allows user to dedicate a GLContext to a given thread. Only the ECT will be allowed to claim the GLContext, hence releasing must be done on the ECT itself. The core feature is accessible via GLAutoDrawable, while it can be conveniently enabled and disabled via an AnimatorBase implementation. The latter ensures it's being released on the ECT and waits for the result. Note that ECT cannot be guaranteed to work correctly w/ native (heavyweight) AWT components due to resource locking and AWT-EDT access. This is disabled in all new tests per default and noted on the API doc. Note: 'Animator transaction' == start(), stop(), pause(), resume(). - Add ExclusiveContextThread (ECT) feature - GLAutoDrawable NEW: - Thread setExclusiveContextThread(Thread t) - Thread getExclusiveContextThread() - AnimatorBase NEW: - Thread setExclusiveContext(Thread t) - boolean setExclusiveContext(boolean enable) - boolean isExclusiveContextEnabled() - Thread getExclusiveContextThread() - AnimatorBase: Add setModeBits/MODE_EXPECT_AWT_RENDERING_THREAD Allows user to pre-determine whether AWT rendering is expected before starting the animator. If AWT is excluded, a more simple and transaction correct impl. will be used. - FPSAnimator: Make transactions deterministic. FPSAnimator previously did not ensure whether a transaction was completed. A deterministic transaction is required to utilize ECT. FPSAnimator now uses same mechanism like Animator to ensure completeness, i.e. Condition and 'finishLifecycleAction(..)'. Both are moved to AnimatorBase. Tested manually on Linux/NV, Linux/AMD, Windows/NV and OSX/NV. - All new tests validated correctness. - All new tests shows an performance increase of ~3x w/ single GLWindow, where multiple GLWindows don't show a perf. increase. --- make/scripts/tests-x64.bat | 40 +- make/scripts/tests.sh | 15 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 10 + .../classes/com/jogamp/opengl/util/Animator.java | 187 ++++----- .../com/jogamp/opengl/util/AnimatorBase.java | 458 ++++++++++++++++++--- .../com/jogamp/opengl/util/FPSAnimator.java | 307 ++++++++++---- .../javax/media/opengl/GLAnimatorControl.java | 21 +- .../classes/javax/media/opengl/GLAutoDrawable.java | 45 +- src/jogl/classes/javax/media/opengl/GLContext.java | 8 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 10 + .../classes/javax/media/opengl/awt/GLJPanel.java | 10 + .../classes/jogamp/opengl/GLAutoDrawableBase.java | 30 +- .../classes/jogamp/opengl/GLDrawableHelper.java | 421 ++++++++++++------- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 5 +- .../junit/jogl/acore/ExclusiveContextBase00.java | 420 +++++++++++++++++++ .../jogl/acore/ExclusiveContextBase00AWT.java | 161 ++++++++ .../jogl/acore/ExclusiveContextBase00NEWT.java | 94 +++++ .../junit/jogl/acore/ExclusiveContextBase10.java | 213 ++++++++++ .../jogl/acore/ExclusiveContextBase10AWT.java | 161 ++++++++ .../jogl/acore/ExclusiveContextBase10NEWT.java | 94 +++++ .../junit/jogl/acore/InitConcurrentBaseNEWT.java | 2 +- .../acore/TestExclusiveContext01VSyncAnimAWT.java | 70 ++++ .../acore/TestExclusiveContext01VSyncAnimNEWT.java | 67 +++ .../acore/TestExclusiveContext02FPSAnimAWT.java | 70 ++++ .../acore/TestExclusiveContext02FPSAnimNEWT.java | 67 +++ .../acore/TestExclusiveContext11VSyncAnimNEWT.java | 66 +++ .../acore/TestExclusiveContext12FPSAnimNEWT.java | 67 +++ .../jogl/demos/es1/newt/TestGearsES1NEWT.java | 9 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 87 ++-- .../test/junit/jogl/demos/es2/RedSquareES2.java | 24 +- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 28 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 40 +- 32 files changed, 2815 insertions(+), 492 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext02FPSAnimAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext02FPSAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext11VSyncAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext12FPSAnimNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 63a8d57f7..8367228b5 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -13,6 +13,27 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimAWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimAWT %* +scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext11VSyncAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext12FPSAnimNEWT %* + +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* @@ -94,7 +115,7 @@ REM scripts\java-win64-dbg.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps. REM scripts\java-win64-dbg.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT %* REM scripts\java-win64-dbg.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT @@ -122,23 +143,6 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtD REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* - -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* - -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f253ed1e2..395546ab9 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -104,6 +104,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLDrawable" @@ -169,7 +170,6 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" - #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" @@ -283,6 +283,14 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimAWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext11VSyncAnimNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext12FPSAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -292,7 +300,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -302,12 +309,12 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -455,7 +462,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 4ba4def9a..80e1aa80d 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -648,6 +648,16 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, context); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public boolean getAutoSwapBufferMode() { return helper.getAutoSwapBufferMode(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index ddbc66fa3..10f43a0c1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -41,7 +41,7 @@ package com.jogamp.opengl.util; import javax.media.opengl.GLAutoDrawable; - +import javax.media.opengl.GLException; /**

        An Animator can be attached to one or more {@link GLAutoDrawable}s to drive their display() methods in a loop.

        @@ -57,10 +57,7 @@ import javax.media.opengl.GLAutoDrawable; * Call {@link #stop() } to terminate the animation and it's execution thread. *

        */ -public class Animator extends AnimatorBase { - /** timeout in milliseconds, 15 frames @ 60Hz = 240ms, limiting {@link #finishLifecycleAction(Condition)} */ - private static final long TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 15*16; - +public class Animator extends AnimatorBase { protected ThreadGroup threadGroup; private Runnable runnable; private boolean runAsFastAsPossible; @@ -68,6 +65,9 @@ public class Animator extends AnimatorBase { protected boolean pauseIssued; protected volatile boolean stopIssued; + /** + * Creates a new, empty Animator. + */ public Animator() { super(); if(DEBUG) { @@ -75,25 +75,38 @@ public class Animator extends AnimatorBase { } } + /** + * Creates a new Animator w/ an associated ThreadGroup. + */ public Animator(ThreadGroup tg) { super(); - threadGroup = tg; - + setThreadGroup(tg); if(DEBUG) { System.err.println("Animator created, ThreadGroup: "+threadGroup); } } - /** Creates a new Animator for a particular drawable. */ + /** + * Creates a new Animator for a particular drawable. + */ public Animator(GLAutoDrawable drawable) { super(); add(drawable); + if(DEBUG) { + System.err.println("Animator created, w/ "+drawable); + } } - /** Creates a new Animator for a particular drawable. */ + /** + * Creates a new Animator w/ an associated ThreadGroup for a particular drawable. + */ public Animator(ThreadGroup tg, GLAutoDrawable drawable) { - this(tg); + super(); + setThreadGroup(tg); add(drawable); + if(DEBUG) { + System.err.println("Animator created, ThreadGroup: "+threadGroup+" and "+drawable); + } } protected String getBaseName(String prefix) { @@ -114,7 +127,7 @@ public class Animator extends AnimatorBase { stateSync.unlock(); } } - + private final void setIsAnimatingSynced(boolean v) { stateSync.lock(); try { @@ -126,36 +139,39 @@ public class Animator extends AnimatorBase { class MainLoop implements Runnable { public String toString() { - return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+"]"; + return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; } public void run() { try { - synchronized (Animator.this) { - if(DEBUG) { - System.err.println("Animator start:" + Thread.currentThread() + ": " + toString()); - } - fpsCounter.resetFPSCounter(); - animThread = Thread.currentThread(); - setIsAnimatingSynced(false); // barrier - Animator.this.notifyAll(); + if(DEBUG) { + System.err.println("Animator start:" + Thread.currentThread() + ": " + toString()); } + fpsCounter.resetFPSCounter(); + animThread = Thread.currentThread(); + setIsAnimatingSynced(false); // barrier + // 'waitForStartedCondition' wake-up is handled below! while (!stopIssued) { synchronized (Animator.this) { - // Don't consume CPU unless there is work to be done and not paused + // Pause; Also don't consume CPU unless there is work to be done and not paused + boolean ectCleared = false; while (!stopIssued && (pauseIssued || drawablesEmpty)) { boolean wasPaused = pauseIssued; if (DEBUG) { System.err.println("Animator pause:" + Thread.currentThread() + ": " + toString()); } + if ( exclusiveContext && !drawablesEmpty && !ectCleared ) { + ectCleared = true; + setDrawablesExclCtxState(false); + display(); // propagate exclusive change! + } setIsAnimatingSynced(false); // barrier Animator.this.notifyAll(); try { Animator.this.wait(); } catch (InterruptedException e) { } - if (wasPaused) { // resume from pause -> reset counter fpsCounter.resetFPSCounter(); @@ -165,9 +181,12 @@ public class Animator extends AnimatorBase { } } if (!stopIssued && !isAnimating) { - // resume from pause or drawablesEmpty, + // Wakes up 'waitForStartedCondition' sync + // - and - + // Resume from pause or drawablesEmpty, // implies !pauseIssued and !drawablesEmpty - setIsAnimatingSynced(true); + setIsAnimatingSynced(true); // barrier + setDrawablesExclCtxState(exclusiveContext); Animator.this.notifyAll(); } } // sync Animator.this @@ -180,6 +199,10 @@ public class Animator extends AnimatorBase { } } } finally { + if( exclusiveContext && !drawablesEmpty ) { + setDrawablesExclCtxState(false); + display(); // propagate exclusive change! + } synchronized (Animator.this) { if(DEBUG) { System.err.println("Animator stop " + Thread.currentThread() + ": " + toString()); @@ -194,18 +217,6 @@ public class Animator extends AnimatorBase { } } - private final boolean isStartedImpl() { - return animThread != null ; - } - public final boolean isStarted() { - stateSync.lock(); - try { - return animThread != null ; - } finally { - stateSync.unlock(); - } - } - private final boolean isAnimatingImpl() { return animThread != null && isAnimating ; } @@ -230,39 +241,19 @@ public class Animator extends AnimatorBase { } } - interface Condition { - /** - * @return true if branching (cont waiting, action), otherwise false - */ - boolean result(); - } - - private synchronized void finishLifecycleAction(Condition condition) { - // It's hard to tell whether the thread which changes the lifecycle has - // dependencies on the Animator's internal thread. Currently we - // use a couple of heuristics to determine whether we should do - // the blocking wait(). - final boolean blocking = impl.blockUntilDone(animThread); - long remaining = blocking ? TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION : 0; - while (remaining>0 && condition.result()) { - long td = System.currentTimeMillis(); - try { - wait(remaining); - } catch (InterruptedException ie) { } - remaining -= (System.currentTimeMillis() - td) ; - } - if(DEBUG) { - if(remaining<0) { - System.err.println("finishLifecycleAction(" + condition.getClass().getName() + "): ++++++ timeout reached ++++++ " + Thread.currentThread().getName()); - } - System.err.println("finishLifecycleAction(" + condition.getClass().getName() + "): finished "+ - "- blocking "+blocking+ - ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + - ", started: " + isStartedImpl() +", animating: " + isAnimatingImpl() + - ", paused: " + isPausedImpl() + ", drawables " + drawables.size() + " - " + Thread.currentThread().getName()); + /** + * Set a {@link ThreadGroup} for the {@link #getThread() animation thread}. + * + * @param tg the {@link ThreadGroup} + * @throws GLException if the animator has already been started + */ + public synchronized void setThreadGroup(ThreadGroup tg) throws GLException { + if ( isStartedImpl() ) { + throw new GLException("Animator already started."); } + threadGroup = tg; } - + public synchronized boolean start() { if ( isStartedImpl() ) { return false; @@ -284,74 +275,48 @@ public class Animator extends AnimatorBase { System.err.println("Animator "+ct.getName()+"[daemon "+ct.isDaemon()+"]: starting "+thread.getName()+"[daemon "+thread.isDaemon()+"]"); } thread.start(); - finishLifecycleAction(waitForStartedCondition); - return true; + return finishLifecycleAction(waitForStartedCondition, 0); } - - private class WaitForStartedCondition implements Condition { - public boolean result() { + private final Condition waitForStartedCondition = new Condition() { + public boolean eval() { return !isStartedImpl() || (!drawablesEmpty && !isAnimating) ; - } - } - Condition waitForStartedCondition = new WaitForStartedCondition(); + } }; public synchronized boolean stop() { if ( !isStartedImpl() ) { return false; } stopIssued = true; - notifyAll(); - finishLifecycleAction(waitForStoppedCondition); - return true; + return finishLifecycleAction(waitForStoppedCondition, 0); } - private class WaitForStoppedCondition implements Condition { - public boolean result() { + private final Condition waitForStoppedCondition = new Condition() { + public boolean eval() { return isStartedImpl(); - } - } - Condition waitForStoppedCondition = new WaitForStoppedCondition(); + } }; public synchronized boolean pause() { if ( !isStartedImpl() || pauseIssued ) { return false; } - stateSync.lock(); - try { - pauseIssued = true; - } finally { - stateSync.unlock(); - } - notifyAll(); - finishLifecycleAction(waitForPausedCondition); - return true; + pauseIssued = true; + return finishLifecycleAction(waitForPausedCondition, 0); } - private class WaitForPausedCondition implements Condition { - public boolean result() { + private final Condition waitForPausedCondition = new Condition() { + public boolean eval() { // end waiting if stopped as well return isAnimating && isStartedImpl(); - } - } - Condition waitForPausedCondition = new WaitForPausedCondition(); + } }; public synchronized boolean resume() { if ( !isStartedImpl() || !pauseIssued ) { return false; } - stateSync.lock(); - try { - pauseIssued = false; - } finally { - stateSync.unlock(); - } - notifyAll(); - finishLifecycleAction(waitForResumeCondition); - return true; + pauseIssued = false; + return finishLifecycleAction(waitForResumeCondition, 0); } - private class WaitForResumeCondition implements Condition { - public boolean result() { + private final Condition waitForResumeCondition = new Condition() { + public boolean eval() { // end waiting if stopped as well return !drawablesEmpty && !isAnimating && isStartedImpl(); - } - } - Condition waitForResumeCondition = new WaitForResumeCondition(); + } }; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index 46fc1d991..bda716e97 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -38,6 +38,7 @@ import java.util.ArrayList; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; /** @@ -51,69 +52,174 @@ import javax.media.opengl.GLProfile; */ public abstract class AnimatorBase implements GLAnimatorControl { protected static final boolean DEBUG = Debug.debug("Animator"); - - private static int animatorCount = 0; - + + /** A 1s timeout while waiting for a native action response, limiting {@link #finishLifecycleAction(Condition, long)} */ + protected static final long TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 1000; + + protected static final long POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION = 32; // 2 frames @ 60Hz + + /** + * If present in modeBits field and + * {@link GLProfile#isAWTAvailable() AWT is available}, + * implementation is aware of the AWT EDT, otherwise not. + *

        + * This is the default. + *

        + * @see #setModeBits(boolean, int) + */ + public static final int MODE_EXPECT_AWT_RENDERING_THREAD = 1 << 0; + public interface AnimatorImpl { void display(ArrayList drawables, boolean ignoreExceptions, boolean printExceptions); boolean blockUntilDone(Thread thread); } - protected ArrayList drawables = new ArrayList(); - protected boolean drawablesEmpty; + protected int modeBits; protected AnimatorImpl impl; protected String baseName; + + protected ArrayList drawables = new ArrayList(); + protected boolean drawablesEmpty; protected Thread animThread; protected boolean ignoreExceptions; protected boolean printExceptions; + protected boolean exclusiveContext; + protected Thread userExclusiveContextThread; protected FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected RecursiveLock stateSync = LockFactory.createRecursiveLock(); - - /** Creates a new, empty Animator. */ - public AnimatorBase() { - if(GLProfile.isAWTAvailable()) { + + private final static Class awtAnimatorImplClazz; + static { + GLProfile.initSingleton(); + if( GLProfile.isAWTAvailable() ) { + Class clazz; try { - impl = (AnimatorImpl) Class.forName("com.jogamp.opengl.util.AWTAnimatorImpl").newInstance(); - baseName = "AWTAnimator"; - } catch (Exception e) { e.printStackTrace(); } - } - if(null==impl) { - impl = new DefaultAnimatorImpl(); - baseName = "Animator"; - } - synchronized (Animator.class) { - animatorCount++; - baseName = baseName.concat("-"+animatorCount); - drawablesEmpty = true; + clazz = Class.forName("com.jogamp.opengl.util.AWTAnimatorImpl"); + } catch (Exception e) { + clazz = null; + } + awtAnimatorImplClazz = clazz; + } else { + awtAnimatorImplClazz = null; } } + /** + * Creates a new, empty Animator instance + * while expecting an AWT rendering thread if AWT is available. + * + * @see GLProfile#isAWTAvailable() + */ + public AnimatorBase() { + modeBits = MODE_EXPECT_AWT_RENDERING_THREAD; // default! + drawablesEmpty = true; + } + + /** + * Initializes implementation details post setup, + * invoked at {@link #add(GLAutoDrawable)}, {@link #start()}, .. + *

        + * Operation is a NOP if force is false + * and this instance is already initialized. + *

        + * + * @throws GLException if Animator is {@link #isStarted()} + */ + protected void initImpl(boolean force) { + if( force || null == impl ) { + if( 0 != ( MODE_EXPECT_AWT_RENDERING_THREAD & modeBits ) && null != awtAnimatorImplClazz ) { + try { + impl = (AnimatorImpl) awtAnimatorImplClazz.newInstance(); + baseName = getBaseName("AWT"); + } catch (Exception e) { e.printStackTrace(); } + } + if( null == impl ) { + impl = new DefaultAnimatorImpl(); + baseName = getBaseName(""); + } + if(DEBUG) { + System.err.println("Animator.initImpl: baseName "+baseName+", implClazz "+impl.getClass().getName()+" - "+toString()+" - "+Thread.currentThread().getName()); + } + } + } protected abstract String getBaseName(String prefix); - public synchronized void add(GLAutoDrawable drawable) { + /** + * Enables or disables the given bitValues + * in this Animators modeBits. + * @param enable + * @param bitValues + * + * @throws GLException if Animator is {@link #isStarted()} + * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD + */ + public synchronized void setModeBits(boolean enable, int bitValues) throws GLException { + if( isStarted() ) { + throw new GLException("Animator already started"); + } + final int _oldModeBits = modeBits; + if(enable) { + modeBits |= bitValues; + } else { + modeBits &= ~bitValues; + } + if( _oldModeBits != modeBits ) { + initImpl(true); + } + } + public synchronized int getModeBits() { return modeBits; } + + + @Override + public synchronized void add(final GLAutoDrawable drawable) { if(DEBUG) { - System.err.println("Animator add: "+drawable.hashCode()+" - "+Thread.currentThread().getName()); + System.err.println("Animator add: 0x"+Integer.toHexString(drawable.hashCode())+" - "+toString()+" - "+Thread.currentThread().getName()); } + if( drawables.contains(drawable) ) { + throw new IllegalArgumentException("Drawable already added to animator: "+this+", "+drawable); + } + initImpl(false); boolean paused = pause(); + if( isStarted() ) { + drawable.setExclusiveContextThread( exclusiveContext ? getExclusiveContextThread() : null ); // if already running .. + } drawables.add(drawable); drawablesEmpty = drawables.size() == 0; drawable.setAnimator(this); if(paused) { resume(); } - if(impl.blockUntilDone(animThread)) { - while(isStarted() && !isPaused() && !isAnimating()) { - try { - wait(); - } catch (InterruptedException ie) { } - } + final Condition waitForAnimatingAndECTCondition = new Condition() { + public boolean eval() { + final Thread dect = drawable.getExclusiveContextThread(); + return isStarted() && !isPaused() && !isAnimating() && ( exclusiveContext && null == dect || !exclusiveContext && null != dect ); + } }; + final boolean res = finishLifecycleAction(waitForAnimatingAndECTCondition, 0); + if(DEBUG) { + System.err.println("Animator add: Wait for Animating/ECT OK: "+res+", "+toString()+", dect "+drawable.getExclusiveContextThread()); } notifyAll(); } - public synchronized void remove(GLAutoDrawable drawable) { + @Override + public synchronized void remove(final GLAutoDrawable drawable) { if(DEBUG) { - System.err.println("Animator remove: "+drawable.hashCode()+" - "+Thread.currentThread().getName() + ": "+toString()); + System.err.println("Animator remove: 0x"+Integer.toHexString(drawable.hashCode())+" - "+toString()+" - "+Thread.currentThread().getName()); + } + if( !drawables.contains(drawable) ) { + throw new IllegalArgumentException("Drawable not added to animator: "+this+", "+drawable); + } + + if( exclusiveContext && isAnimating() ) { + drawable.setExclusiveContextThread( null ); + final Condition waitForNullECTCondition = new Condition() { + public boolean eval() { + return null != drawable.getExclusiveContextThread(); + } }; + final boolean res = finishLifecycleAction(waitForNullECTCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + if(DEBUG) { + System.err.println("Animator remove: Wait for Null-ECT OK: "+res+", "+toString()+", dect "+drawable.getExclusiveContextThread()); + } } boolean paused = pause(); @@ -123,14 +229,202 @@ public abstract class AnimatorBase implements GLAnimatorControl { if(paused) { resume(); } - if(impl.blockUntilDone(animThread)) { - while(isStarted() && drawablesEmpty && isAnimating()) { + final boolean res = finishLifecycleAction(waitForNotAnimatingIfEmptyCondition, 0); + if(DEBUG) { + System.err.println("Animator remove: Wait for !Animating-if-empty OK: "+res+", "+toString()); + } + notifyAll(); + } + private final Condition waitForNotAnimatingIfEmptyCondition = new Condition() { + public boolean eval() { + return isStarted() && drawablesEmpty && isAnimating(); + } }; + + + /** + * Dedicate all {@link GLAutoDrawable}'s context to the given exclusive context thread. + *

        + * The given thread will be exclusive to all {@link GLAutoDrawable}'s context while {@link #isAnimating()}. + *

        + *

        + * If already started and disabling, method waits + * until change is propagated to all {@link GLAutoDrawable} if not + * called from the animator thread or {@link #getExclusiveContextThread() exclusive context thread}. + *

        + *

        + * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. + * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. + *

        + * + * @param enable + * @return previous value + * @see #setExclusiveContext(boolean) + * @see #getExclusiveContextThread() + * @see #isExclusiveContextEnabled() + */ + // @Override + public final Thread setExclusiveContext(Thread t) { + final Thread old; + final boolean enable = null != t; + stateSync.lock(); + try { + old = userExclusiveContextThread; + if( enable && t != animThread ) { // disable: will be cleared at end after propagation && filter out own animThread usae + userExclusiveContextThread=t; + } + } finally { + stateSync.unlock(); + } + setExclusiveContext(enable); + return old; + } + + /** + * Dedicate all {@link GLAutoDrawable}'s context to this animator thread. + *

        + * The given thread will be exclusive to all {@link GLAutoDrawable}'s context while {@link #isAnimating()}. + *

        + *

        + * If already started and disabling, method waits + * until change is propagated to all {@link GLAutoDrawable} if not + * called from the animator thread or {@link #getExclusiveContextThread() exclusive context thread}. + *

        + *

        + * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. + * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. + *

        + * + * @param enable + * @return previous value + * @see #setExclusiveContext(Thread) + * @see #getExclusiveContextThread() + * @see #isExclusiveContextEnabled() + */ + // @Override + public final boolean setExclusiveContext(boolean enable) { + final boolean propagateState; + final boolean oldExclusiveContext; + final Thread _exclusiveContextThread; + synchronized (AnimatorBase.this) { + propagateState = isStarted() && !drawablesEmpty; + _exclusiveContextThread = userExclusiveContextThread; + oldExclusiveContext = exclusiveContext; + exclusiveContext = enable; + if(DEBUG) { + System.err.println("AnimatorBase.setExclusiveContextThread: "+oldExclusiveContext+" -> "+exclusiveContext+", propagateState "+propagateState+", "+this); + } + } + final Thread dECT = enable ? ( null != userExclusiveContextThread ? userExclusiveContextThread : animThread ) : null ; + if( propagateState ) { + setDrawablesExclCtxState(enable); + if( !enable ) { + if( Thread.currentThread() == getThread() || Thread.currentThread() == _exclusiveContextThread ) { + display(); + } else { + final boolean resumed = isAnimating() ? false : resume(); + int counter = 10; + while( 0true
        , if the exclusive context thread is enabled, otherwise false. + * + * @see #setExclusiveContext(boolean) + * @see #setExclusiveContext(Thread) + */ + // @Override + public final boolean isExclusiveContextEnabled() { + stateSync.lock(); + try { + return exclusiveContext; + } finally { + stateSync.unlock(); + } + } + + /** + * Returns the exclusive context thread if {@link #isExclusiveContextEnabled()} and {@link #isStarted()}, otherwise null. + *

        + * If exclusive context is enabled via {@link #setExclusiveContext(boolean)} + * the {@link #getThread() animator thread} is returned if above conditions are met. + *

        + *

        + * If exclusive context is enabled via {@link #setExclusiveContext(Thread)} + * the user passed thread is returned if above conditions are met. + *

        + * @see #setExclusiveContext(boolean) + * @see #setExclusiveContext(Thread) + */ + // @Override + public final Thread getExclusiveContextThread() { + stateSync.lock(); + try { + return ( isStartedImpl() && exclusiveContext ) ? ( null != userExclusiveContextThread ? userExclusiveContextThread : animThread ) : null ; + } finally { + stateSync.unlock(); + } + } + + /** + * Should be called at {@link #start()} and {@link #stop()} + * from within the animator thread. + *

        + * At {@link #stop()} an additional {@link #display()} call shall be issued + * to allow propagation of releasing the exclusive thread. + *

        + */ + protected final synchronized void setDrawablesExclCtxState(boolean enable) { + if(DEBUG) { + System.err.println("AnimatorBase.setExclusiveContextImpl exlusive "+exclusiveContext+": Enable "+enable+" for "+this+" - "+Thread.currentThread()); + // Thread.dumpStack(); + } + final Thread ect = getExclusiveContextThread(); + for (int i=0; ifalse
        . + * @param pollPeriod if 0, method will wait until TO is reached or being notified. + * if > 0, method will wait for the given pollPeriod in milliseconds. + * @return true if {@link Condition#eval() waitCondition.eval()} returned false, otherwise false. + */ + protected synchronized boolean finishLifecycleAction(Condition waitCondition, long pollPeriod) { + // It's hard to tell whether the thread which changes the lifecycle has + // dependencies on the Animator's internal thread. Currently we + // use a couple of heuristics to determine whether we should do + // the blocking wait(). + initImpl(false); + final boolean blocking = impl.blockUntilDone(animThread); + long remaining = blocking ? TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION : 0; + if( 0 >= pollPeriod ) { + pollPeriod = remaining; + } + boolean nok = waitCondition.eval(); + while ( nok && remaining>0 ) { + final long t1 = System.currentTimeMillis(); + if( pollPeriod > remaining ) { pollPeriod = remaining; } + notifyAll(); + try { + wait(pollPeriod); + } catch (InterruptedException ie) { } + remaining -= System.currentTimeMillis() - t1 ; + nok = waitCondition.eval(); + } + if(DEBUG || nok) { + if( remaining<=0 && nok ) { + System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): ++++++ timeout reached ++++++ " + Thread.currentThread().getName()); + } + stateSync.lock(); // avoid too many lock/unlock ops + try { + System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): OK "+(!nok)+ + "- pollPeriod "+pollPeriod+", blocking "+blocking+ + ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + + " - " + Thread.currentThread().getName()); + System.err.println(" - "+toString()); + } finally { + stateSync.unlock(); + } + if(nok) { + Thread.dumpStack(); + } + } + return !nok; + } + + protected final boolean isStartedImpl() { + return animThread != null ; + } + @Override + public boolean isStarted() { + stateSync.lock(); + try { + return animThread != null ; + } finally { + stateSync.unlock(); + } + } + public String toString() { - return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", drawable "+drawables.size()+", totals[dt "+getTotalFPSDuration()+", frames "+getTotalFPSFrames()+", fps "+getTotalFPS()+"]]"; + return getClass().getName()+"[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", drawable "+drawables.size()+ + ", totals[dt "+getTotalFPSDuration()+", frames "+getTotalFPSFrames()+", fps "+getTotalFPS()+ + "], modeBits "+modeBits+", init'ed "+(null!=impl)+", animThread "+getThread()+", exclCtxThread "+exclusiveContext+"("+getExclusiveContextThread()+")]"; } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index 251792110..bfcab23fd 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -39,8 +39,11 @@ */ package com.jogamp.opengl.util; -import java.util.*; -import javax.media.opengl.*; +import java.util.Timer; +import java.util.TimerTask; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLException; /** * An Animator subclass which attempts to achieve a target @@ -54,10 +57,12 @@ import javax.media.opengl.*; */ public class FPSAnimator extends AnimatorBase { private Timer timer = null; - private TimerTask task = null; + private MainTask task = null; private int fps; private boolean scheduleAtFixedRate; - private volatile boolean shouldRun; + private boolean isAnimating; // MainTask feedback + private volatile boolean shouldRun; // MainTask trigger + private volatile boolean shouldStop; // MainTask trigger protected String getBaseName(String prefix) { return "FPS" + prefix + "Animator" ; @@ -88,6 +93,7 @@ public class FPSAnimator extends AnimatorBase { value, an initial drawable to animate, and a flag indicating whether to use fixed-rate scheduling. */ public FPSAnimator(GLAutoDrawable drawable, int fps, boolean scheduleAtFixedRate) { + super(); this.fps = fps; if (drawable != null) { add(drawable); @@ -95,133 +101,260 @@ public class FPSAnimator extends AnimatorBase { this.scheduleAtFixedRate = scheduleAtFixedRate; } - public final boolean isStarted() { - stateSync.lock(); - try { - return (timer != null); - } finally { - stateSync.unlock(); + /** + * @param fps + * @throws GLException if the animator has already been started + */ + public final synchronized void setFPS(int fps) throws GLException { + if ( isStartedImpl() ) { + throw new GLException("Animator already started."); } + this.fps = fps; } + public final int getFPS() { return fps; } + + class MainTask extends TimerTask { + private boolean justStarted; + private boolean alreadyStopped; + private boolean alreadyPaused; + + public MainTask() { + } + + public void start(Timer timer) { + fpsCounter.resetFPSCounter(); + shouldRun = true; + shouldStop = false; + + justStarted = true; + alreadyStopped = false; + alreadyPaused = false; + final long period = 0 < fps ? (long) (1000.0f / (float) fps) : 1; // 0 -> 1: IllegalArgumentException: Non-positive period + if (scheduleAtFixedRate) { + timer.scheduleAtFixedRate(this, 0, period); + } else { + timer.schedule(this, 0, period); + } + } + + public boolean isActive() { return !alreadyStopped && !alreadyPaused; } + + public String toString() { + return "Task[thread "+animThread+", stopped "+alreadyStopped+", paused "+alreadyPaused+" shouldRun "+shouldRun+", shouldStop "+shouldStop+" -- started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; + } + + public void run() { + if( justStarted ) { + justStarted = false; + synchronized (FPSAnimator.this) { + animThread = Thread.currentThread(); + if(DEBUG) { + System.err.println("FPSAnimator start/resume:" + Thread.currentThread() + ": " + toString()); + } + isAnimating = true; + if( drawablesEmpty ) { + shouldRun = false; // isAnimating:=false @ pause below + } else { + shouldRun = true; + setDrawablesExclCtxState(exclusiveContext); + FPSAnimator.this.notifyAll(); + } + System.err.println("FPSAnimator P1:" + Thread.currentThread() + ": " + toString()); + } + } + if( shouldRun ) { + display(); + } else if( shouldStop ) { // STOP + System.err.println("FPSAnimator P4: "+alreadyStopped+", "+ Thread.currentThread() + ": " + toString()); + this.cancel(); + + if( !alreadyStopped ) { + alreadyStopped = true; + if( exclusiveContext && !drawablesEmpty ) { + setDrawablesExclCtxState(false); + display(); // propagate exclusive change! + } + synchronized (FPSAnimator.this) { + if(DEBUG) { + System.err.println("FPSAnimator stop " + Thread.currentThread() + ": " + toString()); + } + animThread = null; + isAnimating = false; + FPSAnimator.this.notifyAll(); + } + } + } else { + System.err.println("FPSAnimator P5: "+alreadyPaused+", "+ Thread.currentThread() + ": " + toString()); + this.cancel(); + + if( !alreadyPaused ) { // PAUSE + alreadyPaused = true; + if( exclusiveContext && !drawablesEmpty ) { + setDrawablesExclCtxState(false); + display(); // propagate exclusive change! + } + synchronized (FPSAnimator.this) { + if(DEBUG) { + System.err.println("FPSAnimator pause " + Thread.currentThread() + ": " + toString()); + } + isAnimating = false; + FPSAnimator.this.notifyAll(); + } + } + } + } + } + private final boolean isAnimatingImpl() { + return animThread != null && isAnimating ; + } public final boolean isAnimating() { stateSync.lock(); try { - return (timer != null) && (task != null); + return animThread != null && isAnimating ; } finally { stateSync.unlock(); } } + private final boolean isPausedImpl() { + return animThread != null && ( !shouldRun && !shouldStop ) ; + } public final boolean isPaused() { stateSync.lock(); try { - return (timer != null) && (task == null); + return animThread != null && ( !shouldRun && !shouldStop ) ; } finally { stateSync.unlock(); } } - private void startTask() { - if(null != task) { - return; - } - final long period = (long) (1000.0f / (float) fps); - task = new TimerTask() { - public void run() { - if(FPSAnimator.this.shouldRun) { - FPSAnimator.this.animThread = Thread.currentThread(); - // display impl. uses synchronized block on the animator instance - display(); - } - } - }; - - fpsCounter.resetFPSCounter(); - shouldRun = true; - - if (scheduleAtFixedRate) { - timer.scheduleAtFixedRate(task, 0, period); - } else { - timer.schedule(task, 0, period); - } - } - - public synchronized boolean start() { - if (timer != null) { + static int timerNo = 0; + + public synchronized boolean start() { + if ( null != timer || null != task || isStartedImpl() ) { return false; } - stateSync.lock(); - try { - timer = new Timer(); - startTask(); - } finally { - stateSync.unlock(); + timer = new Timer( Thread.currentThread().getName()+"-"+baseName+"-Timer"+(timerNo++) ); + task = new MainTask(); + if(DEBUG) { + System.err.println("FPSAnimator.start() START: "+task+", "+ Thread.currentThread() + ": " + toString()); } - return true; + task.start(timer); + + final boolean res = finishLifecycleAction( drawablesEmpty ? waitForStartedEmptyCondition : waitForStartedAddedCondition, + POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + if(DEBUG) { + System.err.println("FPSAnimator.start() END: "+task+", "+ Thread.currentThread() + ": " + toString()); + } + if( drawablesEmpty ) { + task.cancel(); + task = null; + } + return res; } + private final Condition waitForStartedAddedCondition = new Condition() { + public boolean eval() { + return !isStartedImpl() || !isAnimating ; + } }; + private final Condition waitForStartedEmptyCondition = new Condition() { + public boolean eval() { + return !isStartedImpl() || isAnimating ; + } }; /** Stops this FPSAnimator. Due to the implementation of the FPSAnimator it is not guaranteed that the FPSAnimator will be completely stopped by the time this method returns. */ public synchronized boolean stop() { - if (timer == null) { + if ( null == timer || !isStartedImpl() ) { return false; + } + if(DEBUG) { + System.err.println("FPSAnimator.stop() START: "+task+", "+ Thread.currentThread() + ": " + toString()); } - stateSync.lock(); - try { + final boolean res; + if( null == task ) { + // start/resume case w/ drawablesEmpty + res = true; + } else { shouldRun = false; - if(null != task) { - task.cancel(); - task = null; - } - if(null != timer) { - timer.cancel(); - timer = null; - } - animThread = null; - try { - final long periodx2 = 2L * (long) (1000.0f / (float) fps); - Thread.sleep(periodx2 > 20L ? periodx2 : 20L); // max(2 x timer period, ~ 1/60), since we can't ctrl stopped threads - } catch (InterruptedException e) { } - } finally { - stateSync.unlock(); + shouldStop = true; + res = finishLifecycleAction(waitForStoppedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + } + + if(DEBUG) { + System.err.println("FPSAnimator.stop() END: "+task+", "+ Thread.currentThread() + ": " + toString()); + } + if(null != task) { + task.cancel(); + task = null; } - return true; + if(null != timer) { + timer.cancel(); + timer = null; + } + animThread = null; + return res; } + private final Condition waitForStoppedCondition = new Condition() { + public boolean eval() { + return isStartedImpl(); + } }; public synchronized boolean pause() { - if (timer == null) { + if ( !isStartedImpl() || ( null != task && isPausedImpl() ) ) { return false; } - stateSync.lock(); - try { + if(DEBUG) { + System.err.println("FPSAnimator.pause() START: "+task+", "+ Thread.currentThread() + ": " + toString()); + } + final boolean res; + if( null == task ) { + // start/resume case w/ drawablesEmpty + res = true; + } else { shouldRun = false; - if(null != task) { - task.cancel(); - task = null; - } - animThread = null; - try { - final long periodx2 = 2L * (long) (1000.0f / (float) fps); - Thread.sleep(periodx2 > 20L ? periodx2 : 20L); // max(2 x timer period, ~ 1/60), since we can't ctrl stopped threads - } catch (InterruptedException e) { } - } finally { - stateSync.unlock(); + res = finishLifecycleAction(waitForPausedCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + } + + if(DEBUG) { + System.err.println("FPSAnimator.pause() END: "+task+", "+ Thread.currentThread() + ": " + toString()); + } + if(null != task) { + task.cancel(); + task = null; } - return true; + return res; } + private final Condition waitForPausedCondition = new Condition() { + public boolean eval() { + // end waiting if stopped as well + return isAnimating && isStartedImpl(); + } }; public synchronized boolean resume() { - if (timer == null) { + if ( null != task || !isStartedImpl() || !isPausedImpl() ) { return false; } - stateSync.lock(); - try { - startTask(); - } finally { - stateSync.unlock(); + if(DEBUG) { + System.err.println("FPSAnimator.resume() START: "+ Thread.currentThread() + ": " + toString()); + } + final boolean res; + if( drawablesEmpty ) { + res = true; + } else { + task = new MainTask(); + task.start(timer); + res = finishLifecycleAction(waitForResumeCondition, POLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTION); + } + if(DEBUG) { + System.err.println("FPSAnimator.resume() END: "+task+", "+ Thread.currentThread() + ": " + toString()); } - return true; + return res; } + private final Condition waitForResumeCondition = new Condition() { + public boolean eval() { + // end waiting if stopped as well + return !drawablesEmpty && !isAnimating && isStartedImpl(); + } }; } diff --git a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java index 83e9e22c4..3052b924e 100644 --- a/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java +++ b/src/jogl/classes/javax/media/opengl/GLAnimatorControl.java @@ -117,7 +117,7 @@ public interface GLAnimatorControl extends FPSCounter { * or in some cases from an implementation-internal thread like the * AWT event queue thread. * - * @return false if if not started or already paused, otherwise true + * @return false if not started, already paused or failed to pause, otherwise true * * @see #resume() * @see #isAnimating() @@ -134,21 +134,32 @@ public interface GLAnimatorControl extends FPSCounter { *

        * If resumed, all counters (time, frames, ..) are reset to zero. * - * @return false if if not started or not paused, otherwise true + * @return false if not started, not paused or unable to resume, otherwise true * * @see #pause() * @see #isAnimating() */ boolean resume(); + /** + * Adds a drawable to this animator's list of rendering drawables.
        + * This allows the animator thread to become active, i.e. {@link #isAnimating()}==true, + * in case the first drawable is added and {@link #isStarted()} and not {@link #isPaused()}.
        + * + * @param drawable the drawable to be added + * @throws IllegalArgumentException if drawable was already added to this animator + */ + void add(GLAutoDrawable drawable); + /** * Removes a drawable from the animator's list of rendering drawables.
        * This method should get called in case a drawable becomes invalid, * and will not be recovered.
        - * This allows the animator thread to become idle in case the last drawable - * has reached it's end of life.
        + * This allows the animator thread to become idle, i.e. {@link #isAnimating()}==false, + * in case the last drawable has reached it's end of life.
        * - * @param drawable the to be removed drawable + * @param drawable the drawable to be removed + * @throws IllegalArgumentException if drawable was not added to this animator */ void remove(GLAutoDrawable drawable); } diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 0f487f463..a7db3f3fd 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -311,13 +311,13 @@ public interface GLAutoDrawable extends GLDrawable { public GLEventListener removeGLEventListener(GLEventListener listener); /** - *

        * Registers the usage of an animator, an {@link javax.media.opengl.GLAnimatorControl} implementation. - * The animator will be queried whether it's animating, ie periodically issuing {@link #display()} calls or not.


        + * The animator will be queried whether it's animating, ie periodically issuing {@link #display()} calls or not. *

        * This method shall be called by an animator implementation only,
        * e.g. {@link com.jogamp.opengl.util.Animator#add(javax.media.opengl.GLAutoDrawable)}, passing it's control implementation,
        - * and {@link com.jogamp.opengl.util.Animator#remove(javax.media.opengl.GLAutoDrawable)}, passing null.


        + * and {@link com.jogamp.opengl.util.Animator#remove(javax.media.opengl.GLAutoDrawable)}, passing null. + *

        *

        * Impacts {@link #display()} and {@link #invoke(boolean, GLRunnable)} semantics.


        * @@ -340,6 +340,45 @@ public interface GLAutoDrawable extends GLDrawable { */ public GLAnimatorControl getAnimator(); + /** + * Dedicates this instance's {@link GLContext} to the given thread.
        + * The thread will exclusively claim the {@link GLContext} via {@link #display()} and not release it + * until {@link #destroy()} or setExclusiveContextThread(null) has been called. + *

        + * Default non-exclusive behavior is requested via setExclusiveContextThread(null), + * which will cause the next call of {@link #display()} on the exclusive thread to + * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()} + * will return null. + *

        + *

        + * To release a previous made exclusive thread, a user issues setExclusiveContextThread(null) + * and may poll {@link #getExclusiveContextThread()} until it returns null, + * while the exclusive thread is still running. + *

        + *

        + * Note: Setting a new exclusive thread without properly releasing a previous one + * will throw an GLException. + *

        + *

        + * Note: Utilizing this feature w/ AWT could lead to an AWT-EDT deadlock, depending on the AWT implementation. + * Hence it is advised not to use it with native AWT GLAutoDrawable like GLCanvas. + *

        + *

        + * One scenario could be to dedicate the context to the {@link GLAnimatorControl#getThread() animator thread} + * and spare redundant context switches, see {@link com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean)}. + *

        + * @param t the exclusive thread to claim the context, or null for default operation. + * @return previous exclusive context thread + * @throws GLException If an exclusive thread is still active but a new one is attempted to be set + * @see com.jogamp.opengl.util.AnimatorBase#setExclusiveContext(boolean) + */ + public Thread setExclusiveContextThread(Thread t) throws GLException; + + /** + * @see #setExclusiveContextThread(Thread) + */ + public Thread getExclusiveContextThread(); + /** * Enqueues a one-shot {@link GLRunnable}, * which will be executed within the next {@link #display()} call diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 235003c38..461d481a8 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -276,6 +276,9 @@ public abstract class GLContext { /** * Makes this GLContext current on the calling thread. *

        + * Recursive call to {@link #makeCurrent()} and hence {@link #release()} are supported. + *

        + *

        * There are two return values that indicate success and one that * indicates failure. *

        @@ -288,7 +291,7 @@ public abstract class GLContext { *

        *

        * A return value of {@link #CONTEXT_CURRENT} indicates that the context has - * been made currrent, with its previous state restored. + * been made current, with its previous state restored. *

        *

        * If the context could not be made current (for example, because @@ -320,6 +323,9 @@ public abstract class GLContext { /** * Releases control of this GLContext from the current thread. *

        + * Recursive call to {@link #release()} and hence {@link #makeCurrent()} are supported. + *

        + *

        * The drawable's surface is being unlocked at exit, * assumed to be locked by {@link #makeCurrent()}. *

        diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 2f7fef9be..2de86b545 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -741,6 +741,16 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, context); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public boolean invoke(boolean wait, GLRunnable glRunnable) { return helper.invoke(this, wait, glRunnable); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 23dedaa66..664edb996 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -473,6 +473,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, getContext()); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public boolean invoke(boolean wait, GLRunnable glRunnable) { return helper.invoke(this, wait, glRunnable); diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index cbb7cd699..eadd59559 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -50,7 +50,6 @@ import javax.media.opengl.GLRunnable; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.opengl.GLAutoDrawableDelegate; -import com.jogamp.opengl.util.Animator; /** @@ -406,6 +405,16 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { return helper.getAnimator(); } + @Override + public final Thread setExclusiveContextThread(Thread t) throws GLException { + return helper.setExclusiveContextThread(t, context); + } + + @Override + public final Thread getExclusiveContextThread() { + return helper.getExclusiveContextThread(); + } + @Override public final boolean invoke(boolean wait, GLRunnable glRunnable) { return helper.invoke(this, wait, glRunnable); @@ -532,25 +541,6 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { return null != _drawable ? _drawable.getHeight() : 0; } - /** - * @param t the thread for which context release shall be skipped, usually the animation thread, - * ie. {@link Animator#getThread()}. - * @deprecated This is an experimental feature, - * intended for measuring performance in regards to GL context switch. - */ - @Deprecated - public void setSkipContextReleaseThread(Thread t) { - helper.setSkipContextReleaseThread(t); - } - - /** - * @deprecated see {@link #setSkipContextReleaseThread(Thread)} - */ - @Deprecated - public Thread getSkipContextReleaseThread() { - return helper.getSkipContextReleaseThread(); - } - @Override public final GLCapabilitiesImmutable getChosenGLCapabilities() { final GLDrawable _drawable = drawable; diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index dc5d50cf2..f8c58ee34 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -58,8 +58,6 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLFBODrawable; import javax.media.opengl.GLRunnable; -import com.jogamp.opengl.util.Animator; - /** Encapsulates the implementation of most of the GLAutoDrawable's methods to be able to share it between GLCanvas and GLJPanel. */ public class GLDrawableHelper { @@ -73,7 +71,9 @@ public class GLDrawableHelper { private final Object glRunnablesLock = new Object(); private volatile ArrayList glRunnables = new ArrayList(); private boolean autoSwapBufferMode; - private Thread skipContextReleaseThread; + private volatile Thread exclusiveContextThread; + /** -1 release, 0 nop, 1 claim */ + private volatile int exclusiveContextSwitch; private GLAnimatorControl animatorCtrl; private static Runnable nop = new Runnable() { public void run() {} }; @@ -87,7 +87,8 @@ public class GLDrawableHelper { listenersToBeInit.clear(); } autoSwapBufferMode = true; - skipContextReleaseThread = null; + exclusiveContextThread = null; + exclusiveContextSwitch = 0; synchronized(glRunnablesLock) { glRunnables.clear(); } @@ -112,6 +113,23 @@ public class GLDrawableHelper { return sb.toString(); } + /** + * Since GLContext's {@link GLContext#makeCurrent()} and {@link GLContext#release()} + * is recursive, a call to {@link GLContext#release()} may not natively release the context. + *

        + * This methods continues calling {@link GLContext#release()} until the context has been natively released. + *

        + * @param ctx + */ + public static final void forceNativeRelease(GLContext ctx) { + do { + ctx.release(); + if (DEBUG) { + System.err.println("GLDrawableHelper.forceNativeRelease() -- currentThread "+Thread.currentThread()+" -> "+GLContext.getCurrent()); + } + } while( ctx == GLContext.getCurrent() ); + } + /** * Associate a new context to the drawable and also propagates the context/drawable switch by * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. @@ -767,23 +785,72 @@ public class GLDrawableHelper { return autoSwapBufferMode; } + private final String getExclusiveContextSwitchString() { + return 0 == exclusiveContextSwitch ? "nop" : ( 0 > exclusiveContextSwitch ? "released" : "claimed" ) ; + } + /** - * @param t the thread for which context release shall be skipped, usually the animation thread, - * ie. {@link Animator#getThread()}. - * @deprecated this is an experimental feature, - * intended for measuring performance in regards to GL context switch - * and only being used if {@link #PERF_STATS} is enabled - * by defining property jogl.debug.GLDrawable.PerfStats. + * Dedicates this instance's {@link GLContext} to the given thread.
        + * The thread will exclusively claim the {@link GLContext} via {@link #display()} and not release it + * until {@link #destroy()} or setExclusiveContextThread(null) has been called. + *

        + * Default non-exclusive behavior is requested via setExclusiveContextThread(null), + * which will cause the next call of {@link #display()} on the exclusive thread to + * release the {@link GLContext}. Only after it's async release, {@link #getExclusiveContextThread()} + * will return null. + *

        + *

        + * To release a previous made exclusive thread, a user issues setExclusiveContextThread(null) + * and may poll {@link #getExclusiveContextThread()} until it returns null, + * while the exclusive thread is still running. + *

        + *

        + * Note: Setting a new exclusive thread without properly releasing a previous one + * will throw an GLException. + *

        + *

        + * One scenario could be to dedicate the context to the {@link com.jogamp.opengl.util.AnimatorBase#getThread() animator thread} + * and spare redundant context switches. + *

        + * @param t the exclusive thread to claim the context, or null for default operation. + * @return previous exclusive context thread + * @throws GLException If an exclusive thread is still active but a new one is attempted to be set */ - public final void setSkipContextReleaseThread(Thread t) { - skipContextReleaseThread = t; + public final Thread setExclusiveContextThread(Thread t, GLContext context) throws GLException { + if (DEBUG) { + System.err.println("GLDrawableHelper.setExclusiveContextThread(): START switch "+getExclusiveContextSwitchString()+", thread "+exclusiveContextThread+" -> "+t+" -- currentThread "+Thread.currentThread()); + } + final Thread oldExclusiveContextThread = exclusiveContextThread; + if( exclusiveContextThread == t ) { + exclusiveContextSwitch = 0; // keep + } else if( null == t ) { + exclusiveContextSwitch = -1; // release + } else { + exclusiveContextSwitch = 1; // claim + if( null != exclusiveContextThread ) { + throw new GLException("Release current exclusive Context Thread "+exclusiveContextThread+" first"); + } + if( null != context && GLContext.getCurrent() == context ) { + try { + forceNativeRelease(context); + } catch (Throwable ex) { + ex.printStackTrace(); + throw new GLException(ex); + } + } + exclusiveContextThread = t; + } + if (DEBUG) { + System.err.println("GLDrawableHelper.setExclusiveContextThread(): END switch "+getExclusiveContextSwitchString()+", thread "+exclusiveContextThread+" -- currentThread "+Thread.currentThread()); + } + return oldExclusiveContextThread; } - + /** - * @deprecated see {@link #setSkipContextReleaseThread(Thread)} + * @see #setExclusiveContextThread(Thread, GLContext) */ - public final Thread getSkipContextReleaseThread() { - return skipContextReleaseThread; + public final Thread getExclusiveContextThread() { + return exclusiveContextThread; } private static final ThreadLocal perThreadInitAction = new ThreadLocal(); @@ -828,7 +895,10 @@ public class GLDrawableHelper { * {@link #disposeAllGLEventListener(GLAutoDrawable, boolean) disposeAllGLEventListener(autoDrawable, false)} * with the context made current. *

        - * If destroyContext is true the context is destroyed in the end while holding the lock.
        + * If destroyContext is true the context is destroyed in the end while holding the lock. + *

        + *

        + * If destroyContext is false the context is natively released, i.e. released as often as locked before. *

        * @param autoDrawable * @param context @@ -842,14 +912,15 @@ public class GLDrawableHelper { Runnable lastInitAction = null; if (lastContext != null) { if (lastContext == context) { - lastContext = null; // utilize recursive locking + lastContext = null; } else { + // utilize recursive locking lastInitAction = perThreadInitAction.get(); lastContext.release(); } } - int res = GLContext.CONTEXT_NOT_CURRENT; - + + int res; try { res = context.makeCurrent(); if (GLContext.CONTEXT_NOT_CURRENT != res) { @@ -865,7 +936,7 @@ public class GLDrawableHelper { if(destroyContext) { context.destroy(); } else { - context.release(); + forceNativeRelease(context); } flushGLRunnables(); } catch (Exception e) { @@ -880,136 +951,204 @@ public class GLDrawableHelper { } } } - + private final void invokeGLImpl(final GLDrawable drawable, - final GLContext context, - final Runnable runnable, - final Runnable initAction) { - // Support for recursive makeCurrent() calls as well as calling - // other drawables' display() methods from within another one's - GLContext lastContext = GLContext.getCurrent(); - Runnable lastInitAction = null; - if (lastContext != null) { - if (lastContext == context) { - lastContext = null; // utilize recursive locking - } else { - lastInitAction = perThreadInitAction.get(); - lastContext.release(); - } - } - int res = GLContext.CONTEXT_NOT_CURRENT; - - try { - res = context.makeCurrent(); - if (GLContext.CONTEXT_NOT_CURRENT != res) { - try { - perThreadInitAction.set(initAction); - if (GLContext.CONTEXT_CURRENT_NEW == res) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); - } - initAction.run(); - } - runnable.run(); - if ( autoSwapBufferMode ) { - drawable.swapBuffers(); - } - } finally { - try { - context.release(); - } catch (Exception e) { - System.err.println("Catched: "+e.getMessage()); - e.printStackTrace(); - } - } - } - } finally { - if (lastContext != null) { - final int res2 = lastContext.makeCurrent(); - if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { - lastInitAction.run(); - } - } - } - } - - private final void invokeGLImplStats(final GLDrawable drawable, - final GLContext context, - final Runnable runnable, - final Runnable initAction) { - final Thread currentThread = Thread.currentThread(); - - // Support for recursive makeCurrent() calls as well as calling - // other drawables' display() methods from within another one's - int res = GLContext.CONTEXT_NOT_CURRENT; - GLContext lastContext = GLContext.getCurrent(); - Runnable lastInitAction = null; - if (lastContext != null) { - if (lastContext == context) { - if( currentThread == skipContextReleaseThread ) { - res = GLContext.CONTEXT_CURRENT; - } // else: utilize recursive locking - lastContext = null; - } else { - lastInitAction = perThreadInitAction.get(); - lastContext.release(); - } - } - - long t0 = System.currentTimeMillis(); - long tdA = 0; // makeCurrent - long tdR = 0; // render time - long tdS = 0; // swapBuffers - long tdX = 0; // release - boolean ctxClaimed = false; - boolean ctxReleased = false; - boolean ctxDestroyed = false; - try { - if (res == GLContext.CONTEXT_NOT_CURRENT) { - res = context.makeCurrent(); - ctxClaimed = true; + final GLContext context, + final Runnable runnable, + final Runnable initAction) { + final Thread currentThread = Thread.currentThread(); + + // Exclusive Cases: + // 1: lock - unlock : default + // 2: lock - - : exclusive, not locked yet + // 3: - - - : exclusive, already locked + // 4: - - unlock : ex-exclusive, already locked + final boolean _isExclusiveThread, _releaseExclusiveThread; + if( null != exclusiveContextThread) { + if( currentThread == exclusiveContextThread ) { + _releaseExclusiveThread = 0 > exclusiveContextSwitch; + _isExclusiveThread = !_releaseExclusiveThread; + exclusiveContextSwitch = 0; + } else { + // Exclusive thread usage, but on other thread + return; + } + } else { + _releaseExclusiveThread = false; + _isExclusiveThread = false; } - if (res != GLContext.CONTEXT_NOT_CURRENT) { - perThreadInitAction.set(initAction); - if (res == GLContext.CONTEXT_CURRENT_NEW) { - if (DEBUG) { - System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); + + // Support for recursive makeCurrent() calls as well as calling + // other drawables' display() methods from within another one's + int res = GLContext.CONTEXT_NOT_CURRENT; + GLContext lastContext = GLContext.getCurrent(); + Runnable lastInitAction = null; + if (lastContext != null) { + if (lastContext == context) { + res = GLContext.CONTEXT_CURRENT; + lastContext = null; + } else { + // utilize recursive locking + lastInitAction = perThreadInitAction.get(); + lastContext.release(); } - initAction.run(); - } - tdR = System.currentTimeMillis(); - tdA = tdR - t0; // makeCurrent - runnable.run(); - tdS = System.currentTimeMillis(); - tdR = tdS - tdR; // render time - if (autoSwapBufferMode) { - drawable.swapBuffers(); - tdX = System.currentTimeMillis(); - tdS = tdX - tdS; // swapBuffers - } } - } finally { + try { - if( res != GLContext.CONTEXT_NOT_CURRENT && - (null == skipContextReleaseThread || currentThread != skipContextReleaseThread) ) { - context.release(); - ctxReleased = true; + final boolean releaseContext; + if( GLContext.CONTEXT_NOT_CURRENT == res ) { + res = context.makeCurrent(); + releaseContext = !_isExclusiveThread; + } else { + releaseContext = _releaseExclusiveThread; } - } catch (Exception e) { - System.err.println("Catched: "+e.getMessage()); - e.printStackTrace(); + if (GLContext.CONTEXT_NOT_CURRENT != res) { + try { + perThreadInitAction.set(initAction); + if (GLContext.CONTEXT_CURRENT_NEW == res) { + if (DEBUG) { + System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); + } + initAction.run(); + } + runnable.run(); + if ( autoSwapBufferMode ) { + drawable.swapBuffers(); + } + } finally { + if( _releaseExclusiveThread ) { + exclusiveContextThread = null; + if (DEBUG) { + System.err.println("GLDrawableHelper.invokeGL() - Release ExclusiveContextThread -- currentThread "+Thread.currentThread()); + } + } + if( releaseContext ) { + try { + context.release(); + } catch (Exception e) { + System.err.println("Catched: "+e.getMessage()); + e.printStackTrace(); + } + } + } + } + } finally { + if (lastContext != null) { + final int res2 = lastContext.makeCurrent(); + if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { + lastInitAction.run(); + } + } + } + } + + private final void invokeGLImplStats(final GLDrawable drawable, + final GLContext context, + final Runnable runnable, + final Runnable initAction) { + final Thread currentThread = Thread.currentThread(); + + // Exclusive Cases: + // 1: lock - unlock : default + // 2: lock - - : exclusive, not locked yet + // 3: - - - : exclusive, already locked + // 4: - - unlock : ex-exclusive, already locked + final boolean _isExclusiveThread, _releaseExclusiveThread; + if( null != exclusiveContextThread) { + if( currentThread == exclusiveContextThread ) { + _releaseExclusiveThread = 0 > exclusiveContextSwitch; + _isExclusiveThread = !_releaseExclusiveThread; + } else { + // Exclusive thread usage, but on other thread + return; + } + } else { + _releaseExclusiveThread = false; + _isExclusiveThread = false; } - tdX = System.currentTimeMillis() - tdX; // release / destroy + // Support for recursive makeCurrent() calls as well as calling + // other drawables' display() methods from within another one's + int res = GLContext.CONTEXT_NOT_CURRENT; + GLContext lastContext = GLContext.getCurrent(); + Runnable lastInitAction = null; if (lastContext != null) { - final int res2 = lastContext.makeCurrent(); - if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { - lastInitAction.run(); - } + if (lastContext == context) { + res = GLContext.CONTEXT_CURRENT; + lastContext = null; + } else { + // utilize recursive locking + lastInitAction = perThreadInitAction.get(); + lastContext.release(); + } } - } - long td = System.currentTimeMillis() - t0; - System.err.println("td0 "+td+"ms, fps "+(1.0/(td/1000.0))+", td-makeCurrent: "+tdA+"ms, td-render "+tdR+"ms, td-swap "+tdS+"ms, td-release "+tdX+"ms, ctx claimed: "+ctxClaimed+", ctx release: "+ctxReleased+", ctx destroyed "+ctxDestroyed); + + long t0 = System.currentTimeMillis(); + long tdA = 0; // makeCurrent + long tdR = 0; // render time + long tdS = 0; // swapBuffers + long tdX = 0; // release + boolean ctxClaimed = false; + boolean ctxReleased = false; + boolean ctxDestroyed = false; + try { + final boolean releaseContext; + if( GLContext.CONTEXT_NOT_CURRENT == res ) { + res = context.makeCurrent(); + releaseContext = !_isExclusiveThread; + ctxClaimed = true; + } else { + releaseContext = _releaseExclusiveThread; + } + if (GLContext.CONTEXT_NOT_CURRENT != res) { + try { + perThreadInitAction.set(initAction); + if (GLContext.CONTEXT_CURRENT_NEW == res) { + if (DEBUG) { + System.err.println("GLDrawableHelper " + this + ".invokeGL(): Running initAction"); + } + initAction.run(); + } + tdR = System.currentTimeMillis(); + tdA = tdR - t0; // makeCurrent + runnable.run(); + tdS = System.currentTimeMillis(); + tdR = tdS - tdR; // render time + if ( autoSwapBufferMode ) { + drawable.swapBuffers(); + tdX = System.currentTimeMillis(); + tdS = tdX - tdS; // swapBuffers + } + } finally { + if( _releaseExclusiveThread ) { + exclusiveContextSwitch = 0; + exclusiveContextThread = null; + if (DEBUG) { + System.err.println("GLDrawableHelper.invokeGL() - Release ExclusiveContextThread -- currentThread "+Thread.currentThread()); + } + } + if( releaseContext ) { + try { + context.release(); + ctxReleased = true; + } catch (Exception e) { + System.err.println("Catched: "+e.getMessage()); + e.printStackTrace(); + } + } + } + } + } finally { + tdX = System.currentTimeMillis() - tdX; // release / destroy + if (lastContext != null) { + final int res2 = lastContext.makeCurrent(); + if (null != lastInitAction && res2 == GLContext.CONTEXT_CURRENT_NEW) { + lastInitAction.run(); + } + } + } + long td = System.currentTimeMillis() - t0; + System.err.println("td0 "+td+"ms, fps "+(1.0/(td/1000.0))+", td-makeCurrent: "+tdA+"ms, td-render "+tdR+"ms, td-swap "+tdS+"ms, td-release "+tdX+"ms, ctx claimed: "+ctxClaimed+", ctx release: "+ctxReleased+", ctx destroyed "+ctxDestroyed); } } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 082c01c23..07004503e 100755 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -208,7 +208,10 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, System.err); // glAnimator = new FPSAnimator(canvas, 60); - glAnimator = new Animator(tg, glWindow); + glAnimator = new Animator(); + glAnimator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); // No AWT thread involved! + glAnimator.setThreadGroup(tg); + glAnimator.add(glWindow); glAnimator.setUpdateFPSFrames(FPSCounter.DEFAULT_FRAMES_PER_INTERVAL, null); } catch (Throwable t) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java new file mode 100644 index 000000000..c6eb3a103 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java @@ -0,0 +1,420 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.AnimatorBase; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import javax.media.nativewindow.Capabilities; +import javax.media.nativewindow.util.InsetsImmutable; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +/** + * ExclusiveContextThread base implementation to test correctness of the ExclusiveContext feature _and_ AnimatorBase. + */ +public abstract class ExclusiveContextBase00 extends UITestCase { + static boolean testExclusiveWithAWT = false; + static final int durationParts = 9; + static long duration = 320 * durationParts; // ms ~ 20 frames + + static boolean showFPS = false; + static int showFPSRate = 100; + + static final int demoSize = 128; + + static InsetsImmutable insets = null; + static int scrnHeight, scrnWidth; + static int num_x, num_y; + + static int swapInterval = 0; + + @BeforeClass + public static void initClass00() { + Window dummyWindow = NewtFactory.createWindow(new Capabilities()); + dummyWindow.setSize(demoSize, demoSize); + dummyWindow.setVisible(true); + Assert.assertEquals(true, dummyWindow.isVisible()); + Assert.assertEquals(true, dummyWindow.isNativeValid()); + insets = dummyWindow.getInsets(); + scrnHeight = dummyWindow.getScreen().getHeight(); + scrnWidth = dummyWindow.getScreen().getWidth(); + num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; + num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; + dummyWindow.destroy(); + } + + @AfterClass + public static void releaseClass00() { + } + + protected abstract boolean isAWTTestCase(); + protected abstract Thread getAWTRenderThread(); + protected abstract AnimatorBase createAnimator(); + protected abstract GLAutoDrawable createGLAutoDrawable(String title, int x, int y, int width, int height, GLCapabilitiesImmutable caps); + protected abstract void setGLAutoDrawableVisible(GLAutoDrawable[] glads); + protected abstract void destroyGLAutoDrawableVisible(GLAutoDrawable glad); + + protected void runTestGL(GLCapabilitiesImmutable caps, int drawableCount, boolean exclusive, boolean preAdd, boolean shortenTest) throws InterruptedException { + final boolean useAWTRenderThread = isAWTTestCase(); + if( useAWTRenderThread && exclusive ) { + if( testExclusiveWithAWT ) { + System.err.println("Warning: Testing AWT + Exclusive -> Not advised!"); + } else { + System.err.println("Info: Skip test: AWT + Exclusive!"); + return; + } + } + if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { + System.err.println("Skip test: AWT + Exclusive -> Not advised!"); + return; + } + final Thread awtRenderThread = getAWTRenderThread(); + final AnimatorBase animator = createAnimator(); + if( !useAWTRenderThread ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + } + final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; + for(int i=0; i0) { + System.err.println("Clearing drawable ECT was done 'later' @ "+(c*20)+"ms, ok "+ok); + } + Assert.assertEquals(true, ok); + } + final Thread t = drawables[i].setExclusiveContextThread(ect); + Assert.assertEquals(null, t); + } + + Thread.sleep(duration/durationParts); // 3 + } + + // Disable/Enable exclusive mode via Animator for all GLAutoDrawable + if(exclusive) { + final Thread ect = animator.getExclusiveContextThread(); + if( useAWTRenderThread ) { + Assert.assertEquals(awtRenderThread, ect); + } else { + Assert.assertEquals(animator.getThread(), ect); + } + + Assert.assertEquals(true, animator.setExclusiveContext(false)); + Assert.assertFalse(animator.isExclusiveContextEnabled()); + for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + awtEDT = Thread.currentThread(); + } } ); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + } + + @AfterClass + public static void releaseClass00AWT() { + } + + @Override + protected boolean isAWTTestCase() { return true; } + + @Override + protected Thread getAWTRenderThread() { + return awtEDT; + } + + @Override + protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { + final GLCanvas glCanvas = new GLCanvas(); + + // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow + // final Dimension sz = new Dimension(width, height); + // glCanvas.setMinimumSize(sz); + // glCanvas.setPreferredSize(sz); + // glCanvas.setSize(sz); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final Frame frame = new Frame(); + frame.setLayout(new BorderLayout()); + frame.setMinimumSize(new Dimension(width, height)); + frame.setBounds(x, y, width, height); + frame.add(glCanvas, BorderLayout.CENTER); + // frame.pack(); + frame.validate(); + if( !osxCALayerAWTModBug ) { + frame.setTitle(title); + } + } }); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + return glCanvas; + } + + protected Frame getFrame(GLAutoDrawable glad) { + Container p = ((Component)glad).getParent(); + while( null != p && !( p instanceof Frame ) ) { + p = p.getParent(); + } + return (Frame)p; + } + + @Override + protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final int count = glads.length; + for(int i=0; i Not advised!"); + } else { + System.err.println("Info: Skip test: AWT + Exclusive!"); + return; + } + } + if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { + System.err.println("Skip test: AWT + Exclusive -> Not advised!"); + return; + } + final Thread awtRenderThread = getAWTRenderThread(); + final AnimatorBase animator = createAnimator(); + if( !useAWTRenderThread ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + } + final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; + for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + awtEDT = Thread.currentThread(); + } } ); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + } + + @AfterClass + public static void releaseClass00AWT() { + } + + @Override + protected boolean isAWTTestCase() { return true; } + + @Override + protected Thread getAWTRenderThread() { + return awtEDT; + } + + @Override + protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { + final GLCanvas glCanvas = new GLCanvas(); + + // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow + // final Dimension sz = new Dimension(width, height); + // glCanvas.setMinimumSize(sz); + // glCanvas.setPreferredSize(sz); + // glCanvas.setSize(sz); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final Frame frame = new Frame(); + frame.setLayout(new BorderLayout()); + frame.setMinimumSize(new Dimension(width, height)); + frame.setBounds(x, y, width, height); + frame.add(glCanvas, BorderLayout.CENTER); + // frame.pack(); + frame.validate(); + if( !osxCALayerAWTModBug ) { + frame.setTitle(title); + } + } }); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + return glCanvas; + } + + protected Frame getFrame(GLAutoDrawable glad) { + Container p = ((Component)glad).getParent(); + while( null != p && !( p instanceof Frame ) ) { + p = p.getParent(); + } + return (Frame)p; + } + + @Override + protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final int count = glads.length; + for(int i=0; i */ -public class InitConcurrentBaseNEWT extends UITestCase { +public abstract class InitConcurrentBaseNEWT extends UITestCase { static final int demoSize = 128; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java new file mode 100644 index 000000000..245d42031 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java @@ -0,0 +1,70 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import com.jogamp.opengl.test.junit.util.MiscUtils; + +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.AnimatorBase; + +/** + * ExclusiveContextThread VSync Animator to test correctness of the ExclusiveContext feature _and_ Animator with AWT. + */ +public class TestExclusiveContext01VSyncAnimAWT extends ExclusiveContextBase00AWT { + + @Override + protected AnimatorBase createAnimator() { + return new Animator(); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Sat, 12 Jan 2013 09:04:31 +0100 Subject: Adding GEOMETRY_SHADER support in ShaderCode, adding core GL3/GEOMETRY_SHADER unit tests. ; Simplified GLContext version number - Adding GEOMETRY_SHADER support in ShaderCode, adding core GL3/GEOMETRY_SHADER unit tests Chuck Ritola reported in December 2012 that we lack support of GEOMETRY_SHADER and he provided a test case. The latter is cleaned up to use GL3 core profile features only tesing a pass-through and the flip-XYZ geometry shader. ShaderUtil is fixed. - Simplified GLContext version number The OpenGL major/minor version is now hold in a VersionNumber instance to simplify usage. Also expose it via getGLVersionNumber() while marking getGLVersionMajor() and getGLVersionMinor() deprecated. --- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/opengl/GLExtensions.java | 5 +- .../com/jogamp/opengl/util/glsl/ShaderCode.java | 33 ++- .../com/jogamp/opengl/util/glsl/ShaderUtil.java | 8 + src/jogl/classes/javax/media/opengl/GLContext.java | 57 ++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 35 ++- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 2 +- .../jogl/demos/gl3/GeomShader01TextureGL3.java | 293 +++++++++++++++++++++ .../gl3/newt/TestGeomShader01TextureGL3NEWT.java | 126 +++++++++ .../junit/jogl/demos/gl3/shader/flipXYZ01_xxx.gp | 32 +++ .../jogl/demos/gl3/shader/passthrough01_xxx.gp | 31 +++ .../junit/jogl/demos/gl3/shader/texture01_xxx.fp | 20 ++ .../junit/jogl/demos/gl3/shader/texture01_xxx.vp | 20 ++ 13 files changed, 613 insertions(+), 53 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/newt/TestGeomShader01TextureGL3NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/flipXYZ01_xxx.gp create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/passthrough01_xxx.gp create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/texture01_xxx.fp create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/texture01_xxx.vp (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 395546ab9..b9c5302a9 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -260,8 +260,10 @@ function testawtswt() { #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* @@ -287,7 +289,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext11VSyncAnimNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext11VSyncAnimNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext12FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java index cf81b85ee..c0666d153 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java +++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java @@ -73,8 +73,9 @@ public class GLExtensions { public static final String OES_EGL_image_external = "GL_OES_EGL_image_external"; public static final String ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64"; - public static final String ARB_shader_objects = "GL_ARB_shader_objects"; - + public static final String ARB_shader_objects = "GL_ARB_shader_objects"; + public static final String ARB_geometry_shader4 = "GL_ARB_geometry_shader4"; + // // Aliased GLX/WGL/.. extensions // diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index e6dde3237..1e552c17f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -45,6 +45,7 @@ import java.util.Set; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL3; import javax.media.opengl.GLES2; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; @@ -72,6 +73,12 @@ public class ShaderCode { /** Unique resource suffix for {@link GL2ES2#GL_VERTEX_SHADER} in binary: bvp */ public static final String SUFFIX_VERTEX_BINARY = "bvp" ; + /** Unique resource suffix for {@link GL3#GL_GEOMETRY_SHADER} in source code: gp */ + public static final String SUFFIX_GEOMETRY_SOURCE = "gp" ; + + /** Unique resource suffix for {@link GL3#GL_GEOMETRY_SHADER} in binary: bgp */ + public static final String SUFFIX_GEOMETRY_BINARY = "bgp" ; + /** Unique resource suffix for {@link GL2ES2#GL_FRAGMENT_SHADER} in source code: fp */ public static final String SUFFIX_FRAGMENT_SOURCE = "fp" ; @@ -82,7 +89,7 @@ public class ShaderCode { public static final String SUB_PATH_NVIDIA = "nvidia" ; /** - * @param type either {@link GL2ES2#GL_VERTEX_SHADER} or {@link GL2ES2#GL_FRAGMENT_SHADER} + * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * @param count number of shaders * @param source CharSequence array containing the shader sources, organized as source[count][strings-per-shader]. * May be either an immutable String - or mutable StringBuilder array. @@ -96,6 +103,7 @@ public class ShaderCode { switch (type) { case GL2ES2.GL_VERTEX_SHADER: case GL2ES2.GL_FRAGMENT_SHADER: + case GL3.GL_GEOMETRY_SHADER: break; default: throw new GLException("Unknown shader type: "+type); @@ -114,7 +122,7 @@ public class ShaderCode { } /** - * @param type either {@link GL2ES2#GL_VERTEX_SHADER} or {@link GL2ES2#GL_FRAGMENT_SHADER} + * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * @param count number of shaders * @param binary binary buffer containing the shader binaries, */ @@ -122,6 +130,7 @@ public class ShaderCode { switch (type) { case GL2ES2.GL_VERTEX_SHADER: case GL2ES2.GL_FRAGMENT_SHADER: + case GL3.GL_GEOMETRY_SHADER: break; default: throw new GLException("Unknown shader type: "+type); @@ -139,7 +148,7 @@ public class ShaderCode { * which location is resolved using the context class, see {@link #readShaderSource(Class, String)}. * * @param gl current GL object to determine whether a shader compiler is available. If null, no validation is performed. - * @param type either {@link GL2ES2#GL_VERTEX_SHADER} or {@link GL2ES2#GL_FRAGMENT_SHADER} + * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * @param count number of shaders * @param context class used to help resolving the source location * @param sourceFiles array of source locations, organized as sourceFiles[count] @@ -183,7 +192,7 @@ public class ShaderCode { * Creates a complete {@link ShaderCode} object while reading the shader binary of binaryFile, * which location is resolved using the context class, see {@link #readShaderBinary(Class, String)}. * - * @param type either {@link GL2ES2#GL_VERTEX_SHADER} or {@link GL2ES2#GL_FRAGMENT_SHADER} + * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * @param count number of shaders * @param context class used to help resolving the source location * @param binFormat a valid native binary format as they can be queried by {@link ShaderUtil#getShaderBinaryFormats(GL)}. @@ -215,13 +224,15 @@ public class ShaderCode { *
          *
        • Source
            *
          • {@link GL2ES2#GL_VERTEX_SHADER vertex}: {@link #SUFFIX_VERTEX_SOURCE}
          • - *
          • {@link GL2ES2#GL_FRAGMENT_SHADER fragment}: {@link #SUFFIX_FRAGMENT_SOURCE}
        • + *
        • {@link GL2ES2#GL_FRAGMENT_SHADER fragment}: {@link #SUFFIX_FRAGMENT_SOURCE}
        • + *
        • {@link GL3#GL_GEOMETRY_SHADER geometry}: {@link #SUFFIX_GEOMETRY_SOURCE}
        *
      • Binary
          *
        • {@link GL2ES2#GL_VERTEX_SHADER vertex}: {@link #SUFFIX_VERTEX_BINARY}
        • - *
        • {@link GL2ES2#GL_FRAGMENT_SHADER fragment}: {@link #SUFFIX_FRAGMENT_BINARY}
      • + *
      • {@link GL2ES2#GL_FRAGMENT_SHADER fragment}: {@link #SUFFIX_FRAGMENT_BINARY}
      • + *
      • {@link GL3#GL_GEOMETRY_SHADER geometry}: {@link #SUFFIX_GEOMETRY_BINARY}
      *
    * @param binary true for a binary resource, false for a source resource - * @param type either {@link GL2ES2#GL_VERTEX_SHADER} or {@link GL2ES2#GL_FRAGMENT_SHADER} + * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * * @throws GLException if type is not supported * @@ -233,6 +244,8 @@ public class ShaderCode { return binary?SUFFIX_VERTEX_BINARY:SUFFIX_VERTEX_SOURCE; case GL2ES2.GL_FRAGMENT_SHADER: return binary?SUFFIX_FRAGMENT_BINARY:SUFFIX_FRAGMENT_SOURCE; + case GL3.GL_GEOMETRY_SHADER: + return binary?SUFFIX_GEOMETRY_BINARY:SUFFIX_GEOMETRY_SOURCE; default: throw new GLException("illegal shader type: "+type); } @@ -311,7 +324,7 @@ public class ShaderCode { * * @param gl current GL object to determine whether a shader compiler is available (if source is used), * or to determine the shader binary format (if binary is used). - * @param type either {@link GL2ES2#GL_VERTEX_SHADER} or {@link GL2ES2#GL_FRAGMENT_SHADER} + * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * @param count number of shaders * @param context class used to help resolving the source and binary location * @param srcRoot relative root path for srcBasenames @@ -411,7 +424,7 @@ public class ShaderCode { * * @param gl current GL object to determine whether a shader compiler is available (if source is used), * or to determine the shader binary format (if binary is used). - * @param type either {@link GL2ES2#GL_VERTEX_SHADER} or {@link GL2ES2#GL_FRAGMENT_SHADER} + * @param type either {@link GL2ES2#GL_VERTEX_SHADER}, {@link GL2ES2#GL_FRAGMENT_SHADER} or {@link GL3#GL_GEOMETRY_SHADER} * @param context class used to help resolving the source and binary location * @param srcRoot relative root path for basename * @param binRoot relative root path for basename @@ -447,6 +460,8 @@ public class ShaderCode { return "VERTEX_SHADER"; case GL2ES2.GL_FRAGMENT_SHADER: return "FRAGMENT_SHADER"; + case GL3.GL_GEOMETRY_SHADER: + return "GEOMETRY_SHADER"; } return "UNKNOWN_SHADER"; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java index 5afc5e38c..eceeea6db 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderUtil.java @@ -40,6 +40,7 @@ import java.util.*; import javax.media.opengl.*; import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.GLExtensions; public class ShaderUtil { public static String getShaderInfoLog(GL _gl, int shaderObj) { @@ -210,6 +211,13 @@ public class ShaderUtil { } return info.shaderCompilerAvailable.booleanValue(); } + + /** Returns true if GeometryShader is supported, i.e. whether GLContext is ≥ 3.2 or ARB_geometry_shader4 extension is available. */ + public static boolean isGeometryShaderSupported(GL _gl) { + final GLContext ctx = _gl.getContext(); + return ctx.getGLVersionNumber().compareTo(GLContext.Version32) >= 0 || + ctx.isExtensionAvailable(GLExtensions.ARB_geometry_shader4); + } public static void shaderSource(GL _gl, int shader, CharSequence[] source) { diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 461d481a8..8cc29f1f2 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -116,6 +116,15 @@ public abstract class GLContext { /** Indicates that a newly-created context was made current during the last call to {@link #makeCurrent makeCurrent}. */ public static final int CONTEXT_CURRENT_NEW = 2; + /** Version 3.2. As an OpenGL version, it qualifies for geometry shader */ + public static final VersionNumber Version32 = new VersionNumber(3, 2, 0); + + /** Version 3.1. As an OpenGL version, it qualifies for {@link #isGL3core()}, {@link #isGL3bc()} and {@link #isGL3()} */ + public static final VersionNumber Version31 = new VersionNumber(3, 1, 0); + + /** Version 3.0. As an OpenGL version, it qualifies for {@link #isGL2()} only */ + public static final VersionNumber Version30 = new VersionNumber(3, 0, 0); + /** ARB_create_context related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IS_ARB_CREATED = 1 << 0; /** ARB_create_context related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ @@ -156,8 +165,7 @@ public abstract class GLContext { resetStates(); } - protected int ctxMajorVersion; - protected int ctxMinorVersion; + protected VersionNumber ctxVersion; protected int ctxOptions; protected String ctxVersionString; protected VersionNumber ctxGLSLVersion; @@ -172,8 +180,7 @@ public abstract class GLContext { System.err.println(getThreadName() + ": GLContext.resetStates()"); // Thread.dumpStack(); } - ctxMajorVersion=-1; - ctxMinorVersion=-1; + ctxVersion = new VersionNumber(-1, -1, -1); ctxOptions=0; ctxVersionString=null; ctxGLSLVersion=null; @@ -629,8 +636,15 @@ public abstract class GLContext { return ctxVersionString; } - public final int getGLVersionMajor() { return ctxMajorVersion; } - public final int getGLVersionMinor() { return ctxMinorVersion; } + /** @deprecated Use {@link #getGLVersionNumber()} */ + public final int getGLVersionMajor() { return ctxVersion.getMajor(); } + /** @deprecated Use {@link #getGLVersionNumber()} */ + public final int getGLVersionMinor() { return ctxVersion.getMinor(); } + /** + * Returns this context OpenGL version. + * @see #getGLSLVersionNumber() + **/ + public final VersionNumber getGLVersionNumber() { return ctxVersion; } public final boolean isGLCompatibilityProfile() { return ( 0 != ( CTX_PROFILE_COMPAT & ctxOptions ) ); } public final boolean isGLCoreProfile() { return ( 0 != ( CTX_PROFILE_CORE & ctxOptions ) ); } public final boolean isGLForwardCompatible() { return ( 0 != ( CTX_OPTION_FORWARD & ctxOptions ) ); } @@ -659,8 +673,7 @@ public abstract class GLContext { * * @param GLSL version number if context has been made current at least once, otherwise null. * - * @see #getGLVersionMajor() - * @see #getGLVersionMinor() + * @see #getGLVersionNumber() */ public final VersionNumber getGLSLVersionNumber() { return ctxGLSLVersion; @@ -733,7 +746,7 @@ public abstract class GLContext { public final boolean hasGLSL() { return isGLES2() || isGL3() || - isGL2() && ctxMajorVersion>1 ; + isGL2() && ctxVersion.getMajor()>1 ; } /** @@ -810,46 +823,46 @@ public abstract class GLContext { /** @see GLProfile#isGL4bc() */ public final boolean isGL4bc() { - return ctxMajorVersion>=4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & CTX_PROFILE_COMPAT); + return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) + && 0 != (ctxOptions & CTX_PROFILE_COMPAT); } /** @see GLProfile#isGL4() */ public final boolean isGL4() { - return ctxMajorVersion>=4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); + return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) + && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); } /** Indicates whether this profile is capable of GL4 (core only).

    Includes [ GL4 ].

    */ public final boolean isGL4core() { - return ctxMajorVersion>=4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & CTX_PROFILE_CORE); + return ctxVersion.getMajor() >= 4 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) + && 0 != (ctxOptions & CTX_PROFILE_CORE); } /** @see GLProfile#isGL3bc() */ public final boolean isGL3bc() { - return ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) + return ctxVersion.compareTo(Version31) >= 0 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_COMPAT); } /** @see GLProfile#isGL3() */ public final boolean isGL3() { - return ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) + return ctxVersion.compareTo(Version31) >= 0 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); } - /** Indicates whether this profile is capable of GL3 (core only).

    Includes [ GL4, GL3 ].

    */ + /** Indicates whether this profile is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1

    Includes [ GL4, GL3 ].

    */ public final boolean isGL3core() { - return ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) + return ctxVersion.compareTo(Version31) >= 0 && 0 != (ctxOptions & CTX_IS_ARB_CREATED) && 0 != (ctxOptions & CTX_PROFILE_CORE); } /** @see GLProfile#isGL2() */ public final boolean isGL2() { - return ctxMajorVersion>=1 && 0!=(ctxOptions & CTX_PROFILE_COMPAT); + return ctxVersion.getMajor()>=1 && 0!=(ctxOptions & CTX_PROFILE_COMPAT); } /** @see GLProfile#isGL2GL3() */ @@ -859,12 +872,12 @@ public abstract class GLContext { /** @see GLProfile#isGLES1() */ public final boolean isGLES1() { - return ctxMajorVersion==1 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; + return ctxVersion.getMajor() == 1 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; } /** @see GLProfile#isGLES2() */ public final boolean isGLES2() { - return ctxMajorVersion==2 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; + return ctxVersion.getMajor() == 2 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; } /** @see GLProfile#isGLES() */ diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 36aaeb597..d960883d5 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -568,7 +568,7 @@ public abstract class GLContextImpl extends GLContext { final boolean created; try { created = createImpl(shareWith); // may throws exception if fails! - if( created && isGL3core() && ( ctxMajorVersion>3 || ctxMajorVersion==3 && ctxMinorVersion>=1 ) ) { + if( created && isGL3core() ) { // Due to GL 3.1 core spec: E.1. DEPRECATED AND REMOVED FEATURES (p 296), // GL 3.2 core spec: E.2. DEPRECATED AND REMOVED FEATURES (p 331) // there is no more default VAO buffer 0 bound, hence generating and binding one @@ -606,10 +606,10 @@ public abstract class GLContextImpl extends GLContext { if( 0 == ( ctxOptions & GLContext.CTX_PROFILE_ES) ) { // not ES profile final int reqMajor; final int reqProfile; - if(ctxMajorVersion<3 || ctxMajorVersion==3 && ctxMinorVersion==0) { + if( ctxVersion.compareTo(Version30) <= 0 ) { reqMajor = 2; } else { - reqMajor = ctxMajorVersion; + reqMajor = ctxVersion.getMajor(); } if( 0 != ( ctxOptions & GLContext.CTX_PROFILE_CORE) ) { reqProfile = GLContext.CTX_PROFILE_CORE; @@ -617,7 +617,7 @@ public abstract class GLContextImpl extends GLContext { reqProfile = GLContext.CTX_PROFILE_COMPAT; } GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, - ctxMajorVersion, ctxMinorVersion, ctxOptions); + ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); GLContext.setAvailableGLVersionsSet(device); if (DEBUG) { @@ -780,7 +780,7 @@ public abstract class GLContextImpl extends GLContext { success |= hasGL4; if(hasGL4) { // Map all lower compatible profiles: GL3 - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); if(PROFILE_ALIASING) { hasGL3 = true; } @@ -799,13 +799,13 @@ public abstract class GLContextImpl extends GLContext { success |= hasGL4bc; if(hasGL4bc) { // Map all lower compatible profiles: GL3bc, GL2, GL4, GL3 - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxMajorVersion, ctxMinorVersion, ctxOptions); - GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxMajorVersion, ctxMinorVersion, ctxOptions); + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); if(!hasGL4) { - GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); } if(!hasGL3) { - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); } if(PROFILE_ALIASING) { hasGL3bc = true; @@ -821,9 +821,9 @@ public abstract class GLContextImpl extends GLContext { success |= hasGL3bc; if(hasGL3bc) { // Map all lower compatible profiles: GL2 and GL3 - GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxMajorVersion, ctxMinorVersion, ctxOptions); + GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); if(!hasGL3) { - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxMajorVersion, ctxMinorVersion, ctxOptions); + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); } if(PROFILE_ALIASING) { hasGL2 = true; @@ -915,7 +915,7 @@ public abstract class GLContextImpl extends GLContext { AbstractGraphicsDevice device = drawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); // ctxMajorVersion, ctxMinorVersion, ctxOptions is being set by // createContextARBVersions(..) -> setGLFunctionAvailbility(..) -> setContextVersion(..) - GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, ctxMajorVersion, ctxMinorVersion, ctxOptions); + GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); destroyContextARBImpl(_context); if (DEBUG) { System.err.println(getThreadName() + ": createContextARB-MapVersionsAvailable HAVE: " +reqMajor+"."+reqProfile+ " -> "+getGLVersion()); @@ -978,13 +978,12 @@ public abstract class GLContextImpl extends GLContext { if (!GLContext.isValidGLVersion(major, minor)) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - ctxMajorVersion = major; - ctxMinorVersion = minor; + ctxVersion = new VersionNumber(major, minor, 0); ctxOptions = ctp; if(setVersionString) { - ctxVersionString = getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, gl.glGetString(GL.GL_VERSION)); + ctxVersionString = getGLVersion(major, minor, ctxOptions, gl.glGetString(GL.GL_VERSION)); ctxGLSLVersion = null; - if(ctxMajorVersion >= 2) { // >= ES2 || GL2.0 + if(major >= 2) { // >= ES2 || GL2.0 final String glslVersion = gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION); if( null != glslVersion ) { ctxGLSLVersion = new VersionNumber(glslVersion, "."); @@ -995,7 +994,7 @@ public abstract class GLContextImpl extends GLContext { } if( null == ctxGLSLVersion ){ final int[] sver = new int[2]; - getStaticGLSLVersionNumber(ctxMajorVersion, ctxMinorVersion, ctxOptions, sver); + getStaticGLSLVersionNumber(major, minor, ctxOptions, sver); ctxGLSLVersion = new VersionNumber(sver[0], sver[1], 0); } } @@ -1424,7 +1423,7 @@ public abstract class GLContextImpl extends GLContext { final int glErrX = gl.glGetError(); // clear GL error, maybe caused by above operations if(DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: OK "+contextFQN+" - "+GLContext.getGLVersion(ctxMajorVersion, ctxMinorVersion, ctxOptions, null)+" - glErr "+toHexString(glErrX)); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: OK "+contextFQN+" - "+GLContext.getGLVersion(ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions, null)+" - glErr "+toHexString(glErrX)); } return true; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index bd8e7dee9..572888bae 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -281,7 +281,7 @@ public abstract class EGLContext extends GLContextImpl { // /* pp */ void mapCurrentAvailableGLVersion(AbstractGraphicsDevice device) { - mapStaticGLVersion(device, ctxMajorVersion, ctxMinorVersion, ctxOptions); + mapStaticGLVersion(device, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); } /* pp */ int getContextOptions() { return ctxOptions; } /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java new file mode 100644 index 000000000..929491187 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/GeomShader01TextureGL3.java @@ -0,0 +1,293 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.demos.gl3; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URLConnection; +import java.nio.FloatBuffer; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL3; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLUniformData; +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; +import com.jogamp.opengl.util.glsl.ShaderUtil; +import com.jogamp.opengl.util.texture.Texture; +import com.jogamp.opengl.util.texture.TextureCoords; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; + +/** + * JOGL Geometry ShaderCode test case using OpenGL 3.2 core profile features only. + *

    + * Demonstrates pass through and XYZ flipping + * geometry shader. + *

    + *

    + * If the XYZ flipping geometry shader functions properly, + * the texture will be flipped horizontally and vertically. + *

    + * + * @author Chuck Ritola December 2012 + * @author Sven Gothel (GL3 core, pass-though, core geometry shader) + */ +public class GeomShader01TextureGL3 implements GLEventListener { + private final int geomShader; + private Texture texture; + private ShaderState st; + private PMVMatrix pmvMatrix; + private GLUniformData pmvMatrixUniform; + private GLArrayDataServer interleavedVBO; + + static final String shaderBasename = "texture01_xxx"; + static final String[] geomShaderBaseNames = new String[] { "passthrough01_xxx", "flipXYZ01_xxx" }; + + public GeomShader01TextureGL3(int geomShader) { + this.geomShader = geomShader; + } + + @Override + public void init(GLAutoDrawable drawable) { + { + final GL gl = drawable.getGL(); + System.err.println("Init - START - useGeomShader "+geomShader+" -> "+geomShaderBaseNames[geomShader]); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL GLSL: "+gl.hasGLSL()+", has-compiler: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none")); + System.err.println("GL Profile: "+gl.getGLProfile()); + System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion()); + if( !gl.isGL3() ) { + throw new RuntimeException("GL object not a GL3 core compatible profile: "+gl); + } + if( !ShaderUtil.isGeometryShaderSupported(gl) ) { + throw new RuntimeException("GL object not >= 3.2, i.e. no geometry shader support.: "+gl); + } + } + final GL3 gl = drawable.getGL().getGL3(); + + final ShaderProgram sp; + { + final ShaderCode vs, gs, fs; + vs = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), + "shader", "shader/bin", shaderBasename, true); + gs = ShaderCode.create(gl, GL3.GL_GEOMETRY_SHADER, this.getClass(), + "shader", "shader/bin", geomShaderBaseNames[geomShader], true); + fs = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), + "shader", "shader/bin", shaderBasename, true); + vs.defaultShaderCustomization(gl, true, null); + gs.defaultShaderCustomization(gl, true, null); + fs.defaultShaderCustomization(gl, true, null); + + sp = new ShaderProgram(); + sp.add(gl, vs, System.err); + sp.add(gl, gs, System.err); + sp.add(gl, fs, System.err); + if(!sp.link(gl, System.err)) { + throw new GLException("Couldn't link program: "+sp); + } + } + + st=new ShaderState(); + st.attachShaderProgram(gl, sp, true); + + // setup mgl_PMVMatrix + pmvMatrix = new PMVMatrix(); + pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv + st.ownUniform(pmvMatrixUniform); + st.uniform(gl, pmvMatrixUniform); + + st.ownUniform(pmvMatrixUniform); + if(!st.uniform(gl, pmvMatrixUniform)) { + throw new GLException("Error setting PMVMatrix in shader: "+st); + } + if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", 0))) { + throw new GLException("Error setting mgl_ActiveTexture in shader: "+st); + } + + try { + texture = createTestTexture(gl); + } catch (IOException e) { + throw new RuntimeException(e); + } + if(null == texture) { + throw new RuntimeException("Could not load test texture"); + } + + // Tri order: + // TL, BL, BR + // TL, TR, BR + { + int i=0; + TextureCoords tc = texture.getImageTexCoords(); + s_triTexCoords[i++] = tc.left(); s_triTexCoords[i++] = tc.top(); + s_triTexCoords[i++] = tc.left(); s_triTexCoords[i++] = tc.bottom(); + s_triTexCoords[i++] = tc.right(); s_triTexCoords[i++] = tc.bottom(); + s_triTexCoords[i++] = tc.left(); s_triTexCoords[i++] = tc.top(); + s_triTexCoords[i++] = tc.right(); s_triTexCoords[i++] = tc.top(); + s_triTexCoords[i++] = tc.right(); s_triTexCoords[i++] = tc.bottom(); + } + + interleavedVBO = GLArrayDataServer.createGLSLInterleaved(2+4+2, GL.GL_FLOAT, false, 3*6, GL.GL_STATIC_DRAW); + { + interleavedVBO.addGLSLSubArray("mgl_Vertex", 2, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER); + + FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer(); + + for(int i=0; i<6; i++) { + ib.put(s_triVertices, i*2, 2); + ib.put(s_triColors, i*4, 4); + ib.put(s_triTexCoords, i*2, 2); + } + } + interleavedVBO.seal(gl, true); + interleavedVBO.enableBuffer(gl, false); + st.ownAttribute(interleavedVBO, true); + + gl.glClearColor(0f, 0f, 0f, 0f); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + st.useProgram(gl, false); + } + + private Texture createTestTexture(GL3 gl) throws IOException { + final URLConnection urlConn = IOUtil.getResource(this.getClass(), "../../util/texture/test-ntscI01-160x90.png"); + if(null == urlConn) { return null; } + final InputStream istream = urlConn.getInputStream(); + if(null == istream) { return null; } + final TextureData texData = TextureIO.newTextureData(gl.getGLProfile(), istream, false /* mipmap */, TextureIO.PNG); + final Texture res = TextureIO.newTexture(gl, texData); + texData.destroy(); + return res; + } + + @Override + public void dispose(GLAutoDrawable drawable) { + final GL3 gl = drawable.getGL().getGL3(); + if(null!=texture) { + texture.disable(gl); + texture.destroy(gl); + } + + if(null != st) { + pmvMatrixUniform = null; + pmvMatrix.destroy(); + pmvMatrix=null; + st.destroy(gl); + st=null; + } + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + GL3 gl = drawable.getGL().getGL3(); + + gl.setSwapInterval(1); + + // Clear background to white + gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f); + + if(null != st) { + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); + + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + + st.useProgram(gl, true); + st.uniform(gl, pmvMatrixUniform); + st.useProgram(gl, false); + } + } + + @Override + public void display(GLAutoDrawable drawable) { + final GL3 gl = drawable.getGL().getGL3(); + + gl.glClear(GL.GL_DEPTH_BUFFER_BIT | GL.GL_COLOR_BUFFER_BIT); + + if(null != st) { + //Draw the image as a pseudo-quad using two triangles + st.useProgram(gl, true); + interleavedVBO.enableBuffer(gl, true); + gl.glActiveTexture(GL.GL_TEXTURE0); + texture.enable(gl); + texture.bind(gl); + + gl.glDrawArrays(GL.GL_TRIANGLES, 0, 6); + + texture.disable(gl); + interleavedVBO.enableBuffer(gl, false); + st.useProgram(gl, false); + } + }//end display() + + private static final float[] s_triVertices = { + -1f, 1f, // TL + -1f, -1f, // BL + 1f, -1f, // BR + -1f, 1f, // TL + 1f, 1f, // TR + 1f, -1f // BR + }; + private static final float[] s_triColors = { + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f + }; + private static final float[] s_triTexCoords = { + 0f, 1f, // TL + 0f, 0f, // BL + 1f, 0f, // BR + 0f, 1f, // TL + 1f, 1f, // TR + 1f, 0f // BR + }; + +}//end Test diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/newt/TestGeomShader01TextureGL3NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/newt/TestGeomShader01TextureGL3NEWT.java new file mode 100644 index 000000000..71c0ae7ac --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/newt/TestGeomShader01TextureGL3NEWT.java @@ -0,0 +1,126 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.demos.gl3.newt; + +import java.io.IOException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.gl3.GeomShader01TextureGL3; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Test Geometry shader demo GeomShader01TextureGL3 + */ +public class TestGeomShader01TextureGL3NEWT extends UITestCase { + static long duration = 500; // ms + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + @Test + public void test01_GL3Core_Passthrough() throws InterruptedException { + GLCapabilities caps = getCaps(GLProfile.GL3); + if( null == caps ) { return; } + testImpl(caps, 0); + } + + @Test + public void test02_GL3Core_FlipXYZ() throws InterruptedException { + GLCapabilities caps = getCaps(GLProfile.GL3); + if( null == caps ) { return; } + testImpl(caps, 1); + } + + @Test + public void test11_GL3Compat_Passthrough() throws InterruptedException { + GLCapabilities caps = getCaps(GLProfile.GL3bc); + if( null == caps ) { return; } + testImpl(caps, 0); + } + + @Test + public void test12_GL3Compat_FlipXYZ() throws InterruptedException { + GLCapabilities caps = getCaps(GLProfile.GL3bc); + if( null == caps ) { return; } + testImpl(caps, 1); + } + + private void testImpl(GLCapabilities caps, int geomShader) throws InterruptedException { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setSize(800, 600); + glWindow.setVisible(true); + glWindow.setTitle("JOGL Geometry Shader Banana Test"); + Assert.assertTrue(glWindow.isNativeValid()); + + QuitAdapter quitAdapter = new QuitAdapter(); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + glWindow.addGLEventListener( new GeomShader01TextureGL3(geomShader) ); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glWindow.addGLEventListener(snapshotGLEventListener); + + final Animator animator = new Animator(glWindow); + animator.start(); + + animator.setUpdateFPSFrames(60, System.err); + snapshotGLEventListener.setMakeSnapshot(); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()= 150 + +layout (triangles) in; +layout (triangle_strip, max_vertices=3) out; + +in VertexData { + vec4 frontColor; + vec2 texCoord; +} vp_data[3]; + +out VertexData { + vec4 frontColor; + vec2 texCoord; +} gp_data; + +void main() +{ + for(int i = 0; i < gl_in.length(); i++) + { + // copy attributes + gl_Position = vec4(gl_in[i].gl_Position.xyz*-1,1); // This line flips the coordinates. + gp_data.frontColor = vp_data[i].frontColor; + gp_data.texCoord = vp_data[i].texCoord; + + // done with the vertex + EmitVertex(); + } +} + + + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/passthrough01_xxx.gp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/passthrough01_xxx.gp new file mode 100644 index 000000000..588b72426 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/passthrough01_xxx.gp @@ -0,0 +1,31 @@ +// Copyright 2012 JogAmp Community. All rights reserved. +// Requires version >= 150 + +layout (triangles) in; +layout (triangle_strip, max_vertices=3) out; + +in VertexData { + vec4 frontColor; + vec2 texCoord; +} vp_data[3]; + +out VertexData { + vec4 frontColor; + vec2 texCoord; +} gp_data; + +void main() +{ + for(int i = 0; i < gl_in.length(); i++) + { + // copy attributes + gl_Position = gl_in[i].gl_Position; + gp_data.frontColor = vp_data[i].frontColor; + gp_data.texCoord = vp_data[i].texCoord; + + // done with the vertex + EmitVertex(); + } +} + + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/texture01_xxx.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/texture01_xxx.fp new file mode 100644 index 000000000..61f4529ac --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/texture01_xxx.fp @@ -0,0 +1,20 @@ +// Copyright 2012 JogAmp Community. All rights reserved. +// Requires version >= 130 + +in VertexData { + vec4 frontColor; + vec2 texCoord; +} gp_data; + +out vec4 mgl_FragColor; + +uniform sampler2D mgl_ActiveTexture; + +void main (void) +{ + vec4 texColor = texture(mgl_ActiveTexture, gp_data.texCoord); + + // mix frontColor with texture .. + mgl_FragColor = vec4(gp_data.frontColor*texColor); +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/texture01_xxx.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/texture01_xxx.vp new file mode 100644 index 000000000..b220c83f1 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl3/shader/texture01_xxx.vp @@ -0,0 +1,20 @@ +// Copyright 2012 JogAmp Community. All rights reserved. +// Requires version >= 130 + +uniform mat4 mgl_PMVMatrix[2]; + +in vec4 mgl_Vertex; +in vec4 mgl_Color; +in vec4 mgl_MultiTexCoord; + +out VertexData { + vec4 frontColor; + vec2 texCoord; +} vp_data; + +void main(void) +{ + vp_data.frontColor = mgl_Color; + vp_data.texCoord = mgl_MultiTexCoord.st; + gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex; +} -- cgit v1.2.3 From 64041218f3d5965b9525e8699aa97e9ec751cd95 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 12 Jan 2013 09:08:55 +0100 Subject: Move all Exclusive Context Thread (ECT) tests to it's own package to de-clutter core test package --- make/scripts/tests-x64.bat | 12 +- make/scripts/tests.sh | 14 +- .../junit/jogl/acore/ExclusiveContextBase00.java | 420 --------------------- .../jogl/acore/ExclusiveContextBase00AWT.java | 161 -------- .../jogl/acore/ExclusiveContextBase00NEWT.java | 94 ----- .../junit/jogl/acore/ExclusiveContextBase10.java | 213 ----------- .../jogl/acore/ExclusiveContextBase10AWT.java | 161 -------- .../jogl/acore/ExclusiveContextBase10NEWT.java | 94 ----- .../acore/TestExclusiveContext01VSyncAnimAWT.java | 70 ---- .../acore/TestExclusiveContext01VSyncAnimNEWT.java | 67 ---- .../acore/TestExclusiveContext02FPSAnimAWT.java | 70 ---- .../acore/TestExclusiveContext02FPSAnimNEWT.java | 67 ---- .../acore/TestExclusiveContext11VSyncAnimNEWT.java | 66 ---- .../acore/TestExclusiveContext12FPSAnimNEWT.java | 67 ---- .../jogl/acore/ect/ExclusiveContextBase00.java | 420 +++++++++++++++++++++ .../jogl/acore/ect/ExclusiveContextBase00AWT.java | 161 ++++++++ .../jogl/acore/ect/ExclusiveContextBase00NEWT.java | 94 +++++ .../jogl/acore/ect/ExclusiveContextBase10.java | 213 +++++++++++ .../jogl/acore/ect/ExclusiveContextBase10AWT.java | 161 ++++++++ .../jogl/acore/ect/ExclusiveContextBase10NEWT.java | 94 +++++ .../ect/TestExclusiveContext01VSyncAnimAWT.java | 70 ++++ .../ect/TestExclusiveContext01VSyncAnimNEWT.java | 67 ++++ .../ect/TestExclusiveContext02FPSAnimAWT.java | 70 ++++ .../ect/TestExclusiveContext02FPSAnimNEWT.java | 67 ++++ .../ect/TestExclusiveContext11VSyncAnimNEWT.java | 66 ++++ .../ect/TestExclusiveContext12FPSAnimNEWT.java | 67 ++++ 26 files changed, 1563 insertions(+), 1563 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00AWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10AWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase10NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext01VSyncAnimNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext02FPSAnimAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext02FPSAnimNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext11VSyncAnimNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestExclusiveContext12FPSAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase00NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/ExclusiveContextBase10NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext01VSyncAnimAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext01VSyncAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext02FPSAnimAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext02FPSAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext11VSyncAnimNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/ect/TestExclusiveContext12FPSAnimNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 8367228b5..20cb54147 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -18,12 +18,12 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDeb REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimAWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimAWT %* -scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext11VSyncAnimNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext12FPSAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT %* +scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b9c5302a9..130cf1570 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -263,7 +263,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* @@ -285,12 +285,12 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01Textu #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimNEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext01VSyncAnimAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimNEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext02FPSAnimAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext11VSyncAnimNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestExclusiveContext12FPSAnimNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java deleted file mode 100644 index c6eb3a103..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/ExclusiveContextBase00.java +++ /dev/null @@ -1,420 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Window; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; - -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.AnimatorBase; - -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; - -import javax.media.nativewindow.Capabilities; -import javax.media.nativewindow.util.InsetsImmutable; - -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; - -/** - * ExclusiveContextThread base implementation to test correctness of the ExclusiveContext feature _and_ AnimatorBase. - */ -public abstract class ExclusiveContextBase00 extends UITestCase { - static boolean testExclusiveWithAWT = false; - static final int durationParts = 9; - static long duration = 320 * durationParts; // ms ~ 20 frames - - static boolean showFPS = false; - static int showFPSRate = 100; - - static final int demoSize = 128; - - static InsetsImmutable insets = null; - static int scrnHeight, scrnWidth; - static int num_x, num_y; - - static int swapInterval = 0; - - @BeforeClass - public static void initClass00() { - Window dummyWindow = NewtFactory.createWindow(new Capabilities()); - dummyWindow.setSize(demoSize, demoSize); - dummyWindow.setVisible(true); - Assert.assertEquals(true, dummyWindow.isVisible()); - Assert.assertEquals(true, dummyWindow.isNativeValid()); - insets = dummyWindow.getInsets(); - scrnHeight = dummyWindow.getScreen().getHeight(); - scrnWidth = dummyWindow.getScreen().getWidth(); - num_x = scrnWidth / ( demoSize + insets.getTotalWidth() ) - 2; - num_y = scrnHeight / ( demoSize + insets.getTotalHeight() ) - 2; - dummyWindow.destroy(); - } - - @AfterClass - public static void releaseClass00() { - } - - protected abstract boolean isAWTTestCase(); - protected abstract Thread getAWTRenderThread(); - protected abstract AnimatorBase createAnimator(); - protected abstract GLAutoDrawable createGLAutoDrawable(String title, int x, int y, int width, int height, GLCapabilitiesImmutable caps); - protected abstract void setGLAutoDrawableVisible(GLAutoDrawable[] glads); - protected abstract void destroyGLAutoDrawableVisible(GLAutoDrawable glad); - - protected void runTestGL(GLCapabilitiesImmutable caps, int drawableCount, boolean exclusive, boolean preAdd, boolean shortenTest) throws InterruptedException { - final boolean useAWTRenderThread = isAWTTestCase(); - if( useAWTRenderThread && exclusive ) { - if( testExclusiveWithAWT ) { - System.err.println("Warning: Testing AWT + Exclusive -> Not advised!"); - } else { - System.err.println("Info: Skip test: AWT + Exclusive!"); - return; - } - } - if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { - System.err.println("Skip test: AWT + Exclusive -> Not advised!"); - return; - } - final Thread awtRenderThread = getAWTRenderThread(); - final AnimatorBase animator = createAnimator(); - if( !useAWTRenderThread ) { - animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); - } - final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; - for(int i=0; i0) { - System.err.println("Clearing drawable ECT was done 'later' @ "+(c*20)+"ms, ok "+ok); - } - Assert.assertEquals(true, ok); - } - final Thread t = drawables[i].setExclusiveContextThread(ect); - Assert.assertEquals(null, t); - } - - Thread.sleep(duration/durationParts); // 3 - } - - // Disable/Enable exclusive mode via Animator for all GLAutoDrawable - if(exclusive) { - final Thread ect = animator.getExclusiveContextThread(); - if( useAWTRenderThread ) { - Assert.assertEquals(awtRenderThread, ect); - } else { - Assert.assertEquals(animator.getThread(), ect); - } - - Assert.assertEquals(true, animator.setExclusiveContext(false)); - Assert.assertFalse(animator.isExclusiveContextEnabled()); - for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); - System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); - System.err.println("OSType "+Platform.getOSType()); - System.err.println("Java Version "+Platform.getJavaVersionNumber()); - - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - awtEDT = Thread.currentThread(); - } } ); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertNull(e); - } - - } - - @AfterClass - public static void releaseClass00AWT() { - } - - @Override - protected boolean isAWTTestCase() { return true; } - - @Override - protected Thread getAWTRenderThread() { - return awtEDT; - } - - @Override - protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { - final GLCanvas glCanvas = new GLCanvas(); - - // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow - // final Dimension sz = new Dimension(width, height); - // glCanvas.setMinimumSize(sz); - // glCanvas.setPreferredSize(sz); - // glCanvas.setSize(sz); - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - final Frame frame = new Frame(); - frame.setLayout(new BorderLayout()); - frame.setMinimumSize(new Dimension(width, height)); - frame.setBounds(x, y, width, height); - frame.add(glCanvas, BorderLayout.CENTER); - // frame.pack(); - frame.validate(); - if( !osxCALayerAWTModBug ) { - frame.setTitle(title); - } - } }); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertNull(e); - } - - return glCanvas; - } - - protected Frame getFrame(GLAutoDrawable glad) { - Container p = ((Component)glad).getParent(); - while( null != p && !( p instanceof Frame ) ) { - p = p.getParent(); - } - return (Frame)p; - } - - @Override - protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - final int count = glads.length; - for(int i=0; i Not advised!"); - } else { - System.err.println("Info: Skip test: AWT + Exclusive!"); - return; - } - } - if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { - System.err.println("Skip test: AWT + Exclusive -> Not advised!"); - return; - } - final Thread awtRenderThread = getAWTRenderThread(); - final AnimatorBase animator = createAnimator(); - if( !useAWTRenderThread ) { - animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); - } - final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; - for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); - System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); - System.err.println("OSType "+Platform.getOSType()); - System.err.println("Java Version "+Platform.getJavaVersionNumber()); - - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - awtEDT = Thread.currentThread(); - } } ); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertNull(e); - } - - } - - @AfterClass - public static void releaseClass00AWT() { - } - - @Override - protected boolean isAWTTestCase() { return true; } - - @Override - protected Thread getAWTRenderThread() { - return awtEDT; - } - - @Override - protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { - final GLCanvas glCanvas = new GLCanvas(); - - // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow - // final Dimension sz = new Dimension(width, height); - // glCanvas.setMinimumSize(sz); - // glCanvas.setPreferredSize(sz); - // glCanvas.setSize(sz); - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - final Frame frame = new Frame(); - frame.setLayout(new BorderLayout()); - frame.setMinimumSize(new Dimension(width, height)); - frame.setBounds(x, y, width, height); - frame.add(glCanvas, BorderLayout.CENTER); - // frame.pack(); - frame.validate(); - if( !osxCALayerAWTModBug ) { - frame.setTitle(title); - } - } }); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertNull(e); - } - - return glCanvas; - } - - protected Frame getFrame(GLAutoDrawable glad) { - Container p = ((Component)glad).getParent(); - while( null != p && !( p instanceof Frame ) ) { - p = p.getParent(); - } - return (Frame)p; - } - - @Override - protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - final int count = glads.length; - for(int i=0; i Not advised!"); + } else { + System.err.println("Info: Skip test: AWT + Exclusive!"); + return; + } + } + if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { + System.err.println("Skip test: AWT + Exclusive -> Not advised!"); + return; + } + final Thread awtRenderThread = getAWTRenderThread(); + final AnimatorBase animator = createAnimator(); + if( !useAWTRenderThread ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + } + final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; + for(int i=0; i0) { + System.err.println("Clearing drawable ECT was done 'later' @ "+(c*20)+"ms, ok "+ok); + } + Assert.assertEquals(true, ok); + } + final Thread t = drawables[i].setExclusiveContextThread(ect); + Assert.assertEquals(null, t); + } + + Thread.sleep(duration/durationParts); // 3 + } + + // Disable/Enable exclusive mode via Animator for all GLAutoDrawable + if(exclusive) { + final Thread ect = animator.getExclusiveContextThread(); + if( useAWTRenderThread ) { + Assert.assertEquals(awtRenderThread, ect); + } else { + Assert.assertEquals(animator.getThread(), ect); + } + + Assert.assertEquals(true, animator.setExclusiveContext(false)); + Assert.assertFalse(animator.isExclusiveContextEnabled()); + for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + awtEDT = Thread.currentThread(); + } } ); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + } + + @AfterClass + public static void releaseClass00AWT() { + } + + @Override + protected boolean isAWTTestCase() { return true; } + + @Override + protected Thread getAWTRenderThread() { + return awtEDT; + } + + @Override + protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { + final GLCanvas glCanvas = new GLCanvas(); + + // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow + // final Dimension sz = new Dimension(width, height); + // glCanvas.setMinimumSize(sz); + // glCanvas.setPreferredSize(sz); + // glCanvas.setSize(sz); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final Frame frame = new Frame(); + frame.setLayout(new BorderLayout()); + frame.setMinimumSize(new Dimension(width, height)); + frame.setBounds(x, y, width, height); + frame.add(glCanvas, BorderLayout.CENTER); + // frame.pack(); + frame.validate(); + if( !osxCALayerAWTModBug ) { + frame.setTitle(title); + } + } }); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + return glCanvas; + } + + protected Frame getFrame(GLAutoDrawable glad) { + Container p = ((Component)glad).getParent(); + while( null != p && !( p instanceof Frame ) ) { + p = p.getParent(); + } + return (Frame)p; + } + + @Override + protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final int count = glads.length; + for(int i=0; i Not advised!"); + } else { + System.err.println("Info: Skip test: AWT + Exclusive!"); + return; + } + } + if( useAWTRenderThread && exclusive && !testExclusiveWithAWT) { + System.err.println("Skip test: AWT + Exclusive -> Not advised!"); + return; + } + final Thread awtRenderThread = getAWTRenderThread(); + final AnimatorBase animator = createAnimator(); + if( !useAWTRenderThread ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + } + final GLAutoDrawable[] drawables = new GLAutoDrawable[drawableCount]; + for(int i=0; i Platform.getJavaVersionNumber().compareTo(version170); + System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); + System.err.println("OSType "+Platform.getOSType()); + System.err.println("Java Version "+Platform.getJavaVersionNumber()); + + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + awtEDT = Thread.currentThread(); + } } ); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + } + + @AfterClass + public static void releaseClass00AWT() { + } + + @Override + protected boolean isAWTTestCase() { return true; } + + @Override + protected Thread getAWTRenderThread() { + return awtEDT; + } + + @Override + protected GLAutoDrawable createGLAutoDrawable(final String title, final int x, final int y, final int width, final int height, GLCapabilitiesImmutable caps) { + final GLCanvas glCanvas = new GLCanvas(); + + // FIXME: Below AWT layouts freezes OSX/Java7 @ setVisible: Window.setVisible .. CWrapper@NSWindow.isKeyWindow + // final Dimension sz = new Dimension(width, height); + // glCanvas.setMinimumSize(sz); + // glCanvas.setPreferredSize(sz); + // glCanvas.setSize(sz); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final Frame frame = new Frame(); + frame.setLayout(new BorderLayout()); + frame.setMinimumSize(new Dimension(width, height)); + frame.setBounds(x, y, width, height); + frame.add(glCanvas, BorderLayout.CENTER); + // frame.pack(); + frame.validate(); + if( !osxCALayerAWTModBug ) { + frame.setTitle(title); + } + } }); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + + return glCanvas; + } + + protected Frame getFrame(GLAutoDrawable glad) { + Container p = ((Component)glad).getParent(); + while( null != p && !( p instanceof Frame ) ) { + p = p.getParent(); + } + return (Frame)p; + } + + @Override + protected void setGLAutoDrawableVisible(final GLAutoDrawable[] glads) { + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + final int count = glads.length; + for(int i=0; i Date: Mon, 14 Jan 2013 05:58:21 +0100 Subject: NEWT-MouseEvent getWheelRotation() API Update - Fixes Bug 659: NEWT Horizontal Scrolling Behavior (OSX, X11, Win32); Bug 639: High-Res Mouse-Wheel - API update 'float getWheelRotation()': Usually a wheel rotation of > 0.0f is up, and < 0.0f is down. Usually a wheel rotations is considered a vertical scroll. If isShiftDown(), a wheel rotations is considered a horizontal scroll, where shift-up = left = > 0.0f, and shift-down = right = < 0.0f. However, on some OS this might be flipped due to the OS default behavior. The latter is true for OS X 10.7 (Lion) for example. The events will be send usually in steps of one, ie. -1.0f and 1.0f. Higher values may result due to fast scrolling. Fractional values may result due to slow scrolling with high resolution devices. The button number refers to the wheel number. - Fix Bug 659: NEWT Horizontal Scrolling Behavior (OSX, X11, Win32) - See new API doc above - X11/Horiz: Keep using button1 and set SHIFT modifier - OSX/Horiz: - PAD: Use highes absolute scrolling value (Axis1/Axis2) and set SHIFT modifier for horizontal scrolling (Axis2) - XXX: Use deltaX for horizontal scrolling, detected by SHIFT modifier. (traditional) - Windows/Horiz: - Add WM_MOUSEHWHEEL support (-> set SHIFT modifier), but it's rarely impl. for trackpads! - Add exp. WM_HSCROLL, but it will only be delivered if windows has WS_HSCROLL, hence dead code! - Android: - Add ACTION_SCROLL (API Level 12), only used if layout is a scroll layout - Using GestureDetector to detect scroll even w/ pointerCount > 2, while: - skipping 1st scroll event (value too high) - skipping other events while in-scroll mode - waiting until all pointers were released before cont. normally - using View config's 1/touchSlope as scale factor - Fix Bug 639: High-Res Mouse-Wheel - getWheelRotation() return value changed: int -> float allowing fractions, see API doc changes above. - Fractions are currently supported natively (API) on - Windows - OSX - Android - AndroidNewtEventFactory ir refactored (requires an instance now) and AndroidNewtEventTranslator (event listener) is pulled our of Android WindowDriver. --- make/resources/android/AndroidManifest-test.xml | 24 +- make/scripts/java-win32-dbg.bat | 1 + make/scripts/java-win64-dbg.bat | 3 +- make/scripts/tests-x32.bat | 6 +- make/scripts/tests-x64.bat | 8 +- make/scripts/tests.sh | 6 +- .../jogamp/nativewindow/windows/GDIUtil.java | 5 +- .../nativewindow/windows/RegisteredClass.java | 5 +- .../windows/RegisteredClassFactory.java | 26 +- src/newt/classes/com/jogamp/newt/NewtFactory.java | 8 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 24 +- src/newt/classes/jogamp/newt/WindowImpl.java | 16 +- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 4 +- .../jogamp/newt/driver/android/WindowDriver.java | 100 +++--- .../android/event/AndroidNewtEventFactory.java | 355 ++++++++++++++++----- .../android/event/AndroidNewtEventTranslator.java | 55 ++++ .../jogamp/newt/driver/windows/DisplayDriver.java | 13 +- .../jogamp/newt/driver/windows/WindowDriver.java | 13 +- .../jogamp/newt/driver/x11/WindowDriver.java | 14 +- .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 4 +- src/newt/native/KDWindow.c | 6 +- src/newt/native/NewtMacWindow.m | 58 ++-- src/newt/native/WindowsWindow.c | 181 +++++++++-- src/newt/native/X11Display.c | 24 +- src/newt/native/X11Event.c | 20 +- src/newt/native/XCBEvent.c | 12 +- src/newt/native/bcm_vc_iv.c | 2 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 29 +- 28 files changed, 750 insertions(+), 272 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java (limited to 'make/scripts') diff --git a/make/resources/android/AndroidManifest-test.xml b/make/resources/android/AndroidManifest-test.xml index 3c2046df1..0817b3450 100644 --- a/make/resources/android/AndroidManifest-test.xml +++ b/make/resources/android/AndroidManifest-test.xml @@ -18,9 +18,9 @@ android:persistent="false" > - @@ -28,9 +28,9 @@ - @@ -39,9 +39,9 @@ - @@ -49,9 +49,9 @@ - diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat index a4a9e9a5b..1852d9b0c 100755 --- a/make/scripts/java-win32-dbg.bat +++ b/make/scripts/java-win32-dbg.bat @@ -36,6 +36,7 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" "-Djogl.debug=all" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Xcheck:jni" "-Xint" "-verbose:jni" set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 239856c84..63c46eee5 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -30,7 +30,7 @@ REM set D_ARGS="-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" -set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" +REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.GLDrawable" "-Dnativewindow.debug.GraphicsConfiguration" REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock" @@ -41,6 +41,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index ec6c41f37..adc4ece39 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -1,5 +1,5 @@ REM scripts\java-win32-dbg.bat jogamp.newt.awt.opengl.VersionApplet -scripts\java-win32-dbg.bat com.jogamp.newt.opengl.GLWindow +REM scripts\java-win32-dbg.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win32-dbg.bat javax.media.opengl.awt.GLCanvas REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* @@ -16,12 +16,14 @@ REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt. REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT -time 5000 +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* +REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 20cb54147..b66f8b8ab 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -22,7 +22,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclu REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT %* -scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* @@ -49,11 +49,13 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT -time 5000 +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT -time 2000 @@ -146,5 +148,3 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNew REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* - diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 130cf1570..bc379de63 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -165,7 +165,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window.MouseEvent" + D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window" @@ -261,7 +261,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* @@ -285,7 +285,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT $* diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index acb4c84da..00741a328 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -34,7 +34,6 @@ import javax.media.nativewindow.NativeWindowFactory; import jogamp.nativewindow.NWJNILibLoader; import jogamp.nativewindow.Debug; import jogamp.nativewindow.ToolkitProperties; -import jogamp.nativewindow.x11.X11Util; public class GDIUtil implements ToolkitProperties { private static final boolean DEBUG = Debug.debug("GDIUtil"); @@ -49,7 +48,7 @@ public class GDIUtil implements ToolkitProperties { */ public static synchronized void initSingleton() { if(!isInit) { - synchronized(X11Util.class) { + synchronized(GDIUtil.class) { if(!isInit) { if(DEBUG) { System.out.println("GDI.initSingleton()"); @@ -92,7 +91,7 @@ public class GDIUtil implements ToolkitProperties { public static long CreateDummyWindow(int x, int y, int width, int height) { synchronized(dummyWindowSync) { dummyWindowClass = dummyWindowClassFactory.getSharedClass(); - return CreateDummyWindow0(dummyWindowClass.getHandle(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); + return CreateDummyWindow0(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java index afb3daf7c..949f5d06d 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java @@ -37,7 +37,10 @@ public class RegisteredClass { className = name; } - public final long getHandle() { return hInstance; } + /** Application handle, same as {@link RegisteredClassFactory#getHInstance()}. */ + public final long getHInstance() { return hInstance; } + + /** Unique Window Class Name */ public final String getName() { return className; } @Override diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java index 00bedfc8e..0280b0df7 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java @@ -33,8 +33,17 @@ import java.util.ArrayList; import javax.media.nativewindow.NativeWindowException; public class RegisteredClassFactory { - static final boolean DEBUG = Debug.debug("RegisteredClass"); - private static ArrayList registeredFactories = new ArrayList(); + private static final boolean DEBUG = Debug.debug("RegisteredClass"); + private static final ArrayList registeredFactories; + private static final long hInstance; + + static { + hInstance = GDI.GetApplicationHandle(); + if( 0 == hInstance ) { + throw new NativeWindowException("Error: Null ModuleHandle for Application"); + } + registeredFactories = new ArrayList(); + } private String classBaseName; private long wndProc; @@ -43,7 +52,7 @@ public class RegisteredClassFactory { private int classIter = 0; private int sharedRefCount = 0; private final Object sync = new Object(); - + /** * Release the {@link RegisteredClass} of all {@link RegisteredClassFactory}. */ @@ -53,7 +62,7 @@ public class RegisteredClassFactory { final RegisteredClassFactory rcf = registeredFactories.get(j); synchronized(rcf.sync) { if(null != rcf.sharedClass) { - GDIUtil.DestroyWindowClass(rcf.sharedClass.getHandle(), rcf.sharedClass.getName()); + GDIUtil.DestroyWindowClass(rcf.sharedClass.getHInstance(), rcf.sharedClass.getName()); rcf.sharedClass = null; rcf.sharedRefCount = 0; rcf.classIter = 0; @@ -65,6 +74,9 @@ public class RegisteredClassFactory { } } } + + /** Application handle. */ + public static long getHInstance() { return hInstance; } public RegisteredClassFactory(String classBaseName, long wndProc) { this.classBaseName = classBaseName; @@ -80,10 +92,6 @@ public class RegisteredClassFactory { if( null != sharedClass ) { throw new InternalError("Error ("+sharedRefCount+"): SharedClass not null: "+sharedClass); } - long hInstance = GDI.GetApplicationHandle(); - if( 0 == hInstance ) { - throw new NativeWindowException("Error: Null ModuleHandle for Application"); - } String clazzName = null; boolean registered = false; final int classIterMark = classIter - 1; @@ -121,7 +129,7 @@ public class RegisteredClassFactory { throw new InternalError("Error ("+sharedRefCount+"): SharedClass is null"); } if( 0 == sharedRefCount ) { - GDIUtil.DestroyWindowClass(sharedClass.getHandle(), sharedClass.getName()); + GDIUtil.DestroyWindowClass(sharedClass.getHInstance(), sharedClass.getName()); if(DEBUG) { System.err.println("RegisteredClassFactory releaseSharedClass ("+sharedRefCount+") released: "+sharedClass); } diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index b3e904310..e66b2f624 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -44,8 +44,6 @@ import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowFactory; -import com.jogamp.common.os.Platform; - import jogamp.newt.Debug; import jogamp.newt.DisplayImpl; import jogamp.newt.ScreenImpl; @@ -56,13 +54,15 @@ public class NewtFactory { public static final String DRIVER_DEFAULT_ROOT_PACKAGE = "jogamp.newt.driver"; - // Work-around for initialization order problems on Mac OS X - // between native Newt and (apparently) Fmod static { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { NativeWindowFactory.initSingleton(); // last resort .. + + // Work-around for initialization order problems on Mac OS X + // between native Newt and (apparently) Fmod WindowImpl.init(NativeWindowFactory.getNativeWindowType(true)); + return null; } } ); } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 914aaa647..e6b3d8a24 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -65,7 +65,7 @@ public class MouseEvent extends InputEvent public MouseEvent(int eventType, Object source, long when, int modifiers, int x, int y, int clickCount, int button, - int rotation) + float rotation) { super(eventType, source, when, modifiers); this.x = new int[]{x}; @@ -79,7 +79,7 @@ public class MouseEvent extends InputEvent public MouseEvent(int eventType, Object source, long when, int modifiers, int[] x, int[] y, float[] pressure, int[] pointerids, int clickCount, int button, - int rotation) + float rotation) { super(eventType, source, when, modifiers); this.x = x; @@ -154,20 +154,29 @@ public class MouseEvent extends InputEvent } /** - * Usually a wheel rotation of > 0 is up, - * and < 0 is down.
    + * Usually a wheel rotation of > 0.0f is up, + * and < 0.0f is down. + *

    + * Usually a wheel rotations is considered a vertical scroll.
    + * If {@link #isShiftDown()}, a wheel rotations is + * considered a horizontal scroll, where shift-up = left = > 0.0f, + * and shift-down = right = < 0.0f. + *

    + *

    * However, on some OS this might be flipped due to the OS default behavior. * The latter is true for OS X 10.7 (Lion) for example. + *

    *

    - * The events will be send usually in steps of one, ie. -1 and 1. + * The events will be send usually in steps of one, ie. -1.0f and 1.0f. * Higher values may result due to fast scrolling. + * Fractional values may result due to slow scrolling with high resolution devices. *

    *

    * The button number refers to the wheel number. *

    * @return */ - public int getWheelRotation() { + public float getWheelRotation() { return wheelRotation; } @@ -212,7 +221,8 @@ public class MouseEvent extends InputEvent default: return "unknown (" + type + ")"; } } - private final int x[], y[], clickCount, button, wheelRotation; + private final int x[], y[], clickCount, button; + private final float wheelRotation; private final float pressure[]; private final int pointerids[]; diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 6e1059952..3c93de5b3 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -133,10 +133,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList windowListeners = new ArrayList(); private boolean repaintQueued = false; - // Workaround for initialization order problems on Mac OS X - // between native Newt and (apparently) Fmod -- if Fmod is - // initialized first then the connection to the window server - // breaks, leading to errors from deep within the AppKit + /** + * Workaround for initialization order problems on Mac OS X + * between native Newt and (apparently) Fmod -- if Fmod is + * initialized first then the connection to the window server + * breaks, leading to errors from deep within the AppKit + */ public static void init(String type) { if (NativeWindowFactory.TYPE_MACOSX.equals(type)) { try { @@ -1974,16 +1976,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // MouseListener/Event Support // public void sendMouseEvent(int eventType, int modifiers, - int x, int y, int button, int rotation) { + int x, int y, int button, float rotation) { doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation); } public void enqueueMouseEvent(boolean wait, int eventType, int modifiers, - int x, int y, int button, int rotation) { + int x, int y, int button, float rotation) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation); } protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, - int x, int y, int button, int rotation) { + int x, int y, int button, float rotation) { if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) { if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) { x = lastMousePosition.getX(); diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index 1a61d0528..e0f7af69c 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -262,10 +262,10 @@ public class AWTNewtEventFactory { public static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) { int type = eventTypeAWT2NEWT.get(event.getID()); if(0xFFFFFFFF != type) { - int rotation = 0; + float rotation = 0; if (event instanceof java.awt.event.MouseWheelEvent) { // AWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. - rotation = -1 * ((java.awt.event.MouseWheelEvent)event).getWheelRotation(); + rotation = -1f * ((java.awt.event.MouseWheelEvent)event).getWheelRotation(); } final int newtButton = awtButton2Newt(event.getButton()); diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index f18520630..281bd9e0f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -29,7 +29,7 @@ package jogamp.newt.driver.android; import jogamp.common.os.android.StaticContext; -import jogamp.newt.driver.android.event.AndroidNewtEventFactory; +import jogamp.newt.driver.android.event.AndroidNewtEventTranslator; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.CapabilitiesImmutable; @@ -41,6 +41,7 @@ import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLException; +import com.jogamp.common.os.AndroidVersion; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import jogamp.opengl.egl.EGL; @@ -58,7 +59,6 @@ import android.view.SurfaceHolder; import android.view.SurfaceHolder.Callback2; import android.view.inputmethod.InputMethodManager; import android.view.SurfaceView; -import android.view.View; public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { static { @@ -139,42 +139,6 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return false; } - class AndroidEvents implements View.OnKeyListener, View.OnTouchListener, View.OnFocusChangeListener { - - @Override - public boolean onTouch(View v, android.view.MotionEvent event) { - final com.jogamp.newt.event.MouseEvent[] newtEvents = AndroidNewtEventFactory.createMouseEvents(event, WindowDriver.this); - if(null != newtEvents) { - focusChanged(false, true); - for(int i=0; i[] getCustomConstructorArgumentTypes() { return new Class[] { Context.class } ; } @@ -196,22 +160,33 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { setBrokenFocusChange(true); } + private void setupInputListener(boolean enable) { + Log.d(MD.TAG, "setupInputListener(enable "+enable+") - "+Thread.currentThread().getName()); + + final AndroidNewtEventTranslator eventTranslator = + enable ? new AndroidNewtEventTranslator(this, androidView.getContext(), androidView.getHandler()) : null; + androidView.setOnTouchListener(eventTranslator); + androidView.setOnKeyListener(eventTranslator); + androidView.setOnFocusChangeListener(eventTranslator); + if(AndroidVersion.SDK_INT >= 12) { // API Level 12 + Log.d(MD.TAG, "instantiationFinished() - enable GenericMotionListener - "+Thread.currentThread().getName()); + androidView.setOnGenericMotionListener(eventTranslator); + } + androidView.setClickable(false); + androidView.setFocusable(enable); + androidView.setFocusableInTouchMode(enable); + } + @Override protected void instantiationFinished() { + Log.d(MD.TAG, "instantiationFinished() - "+Thread.currentThread().getName()); + final Context ctx = StaticContext.getContext(); if(null == ctx) { throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); } androidView = new MSurfaceView(ctx); - - final AndroidEvents ae = new AndroidEvents(); - androidView.setOnTouchListener(ae); - androidView.setClickable(false); - androidView.setOnKeyListener(ae); - androidView.setOnFocusChangeListener(ae); - androidView.setFocusable(true); - androidView.setFocusableInTouchMode(true); - + final SurfaceHolder sh = androidView.getHolder(); sh.addCallback(WindowDriver.this); sh.setFormat(getFormat(getRequestedCapabilities())); @@ -220,7 +195,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { defineSize(0, 0); } - public SurfaceView getAndroidView() { return androidView; } + public final SurfaceView getAndroidView() { return androidView; } @Override protected boolean canCreateNativeImpl() { @@ -259,11 +234,14 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { if (EGL.EGL_NO_SURFACE==eglSurface) { throw new NativeWindowException("Creation of window surface failed: "+eglConfig+", surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", error "+toHexString(EGL.eglGetError())); } - + // propagate data .. setGraphicsConfiguration(eglConfig); setWindowHandle(surfaceHandle); focusChanged(false, true); + + setupInputListener(true); + Log.d(MD.TAG, "createNativeImpl X: eglSurfaceHandle 0x"+Long.toHexString(eglSurface)); } @@ -272,6 +250,9 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "closeNativeImpl 0 - surfaceHandle 0x"+Long.toHexString(surfaceHandle)+ ", eglSurfaceHandle 0x"+Long.toHexString(eglSurface)+ ", format [a "+androidFormat+", n "+nativeFormat+"], "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()+" - "+Thread.currentThread().getName()); + + setupInputListener(false); + if(0 != eglSurface) { final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getScreen().getDisplay().getGraphicsDevice(); if (!EGL.eglDestroySurface(eglDevice.getHandle(), eglSurface)) { @@ -289,6 +270,19 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return eglSurface; } + /** + *

    + * Accessible protected method! + *

    + * + * {@inheritDoc} + */ + @Override + public void focusChanged(boolean defer, boolean focusGained) { + super.focusChanged(defer, focusGained); + } + + @Override protected void requestFocusImpl(boolean reparented) { if(null != androidView) { Log.d(MD.TAG, "requestFocusImpl: reparented "+reparented); @@ -301,6 +295,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } } + @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { boolean res = true; @@ -330,10 +325,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return res; } + @Override protected Point getLocationOnScreenImpl(int x, int y) { return new Point(x,y); } + @Override protected void updateInsetsImpl(Insets insets) { // nop .. } @@ -367,6 +364,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } private KeyboardVisibleReceiver keyboardVisibleReceiver = new KeyboardVisibleReceiver(); + @Override protected final boolean setKeyboardVisibleImpl(boolean visible) { if(null != androidView) { final InputMethodManager imm = (InputMethodManager) getAndroidView().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); @@ -388,10 +386,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { // Surface Callbacks // + @Override public void surfaceCreated(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceCreated: "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } + @Override public void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) { Log.d(MD.TAG, "surfaceChanged: f "+nativeFormat+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)); if(0!=surfaceHandle && androidFormat != aFormat ) { @@ -436,11 +436,13 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { Log.d(MD.TAG, "surfaceChanged: X"); } + @Override public void surfaceDestroyed(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceDestroyed"); windowDestroyNotify(true); // actually too late .. however .. } + @Override public void surfaceRedrawNeeded(SurfaceHolder holder) { Log.d(MD.TAG, "surfaceRedrawNeeded"); windowRepaint(0, 0, getWidth(), getHeight()); diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index d23b5f576..dc1e8aeef 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -28,38 +28,81 @@ package jogamp.newt.driver.android.event; -import java.awt.event.MouseEvent; - -import com.jogamp.common.util.IntIntHashMap; +import com.jogamp.common.os.AndroidVersion; import com.jogamp.newt.Window; import com.jogamp.newt.event.InputEvent; public class AndroidNewtEventFactory { - protected static final IntIntHashMap eventTypeANDROID2NEWT; - - private static final String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" , - "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" }; + private static final String names[] = { "DOWN" , "UP" , "MOVE", "CANCEL" , "OUTSIDE", // 0 - 4 + "POINTER_DOWN" , "POINTER_UP" , "HOVER_MOVE" , "SCROLL", // 5 - 8 + "HOVER_ENTER", "HOVER_EXIT" // 0 - 10 + }; - static { - IntIntHashMap map = new IntIntHashMap(); - map.setKeyNotFoundValue(0xFFFFFFFF); - - map.put(android.view.MotionEvent.ACTION_DOWN, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); - map.put(android.view.MotionEvent.ACTION_UP, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - map.put(android.view.MotionEvent.ACTION_CANCEL, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - map.put(android.view.MotionEvent.ACTION_MOVE, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED); - map.put(android.view.MotionEvent.ACTION_OUTSIDE, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED); - - map.put(android.view.MotionEvent.ACTION_POINTER_DOWN, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); - map.put(android.view.MotionEvent.ACTION_POINTER_UP, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - - map.put(android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); - - eventTypeANDROID2NEWT = map; + /** API Level 12: {@link android.view.MotionEvent#ACTION_SCROLL} = {@value} */ + private static final int ACTION_SCROLL = 8; + + private static final int aMotionEventType2Newt(int aType) { + final int nType; + switch( aType ) { + case android.view.MotionEvent.ACTION_DOWN: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; + break; + case android.view.MotionEvent.ACTION_UP: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + break; + case android.view.MotionEvent.ACTION_MOVE: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; + break; + case android.view.MotionEvent.ACTION_CANCEL: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + break; + case android.view.MotionEvent.ACTION_OUTSIDE: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; + break; + // + case android.view.MotionEvent.ACTION_POINTER_DOWN: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; + break; + case android.view.MotionEvent.ACTION_POINTER_UP: + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + break; + // case ACTION_HOVER_MOVE + case ACTION_SCROLL: // API Level 12 ! + nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + break; + // case ACTION_HOVER_ENTER + // case ACTION_HOVER_EXIT + default: + nType = 0xFFFFFFFF; + } + return nType; + } + + private static final int aAccessibilityEventType2Newt(int aType) { + final int nType; + switch( aType ) { + case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED: + nType = com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; break; + default: + nType = 0xFFFFFFFF; + } + return nType; } - static final int androidKeyCode2Newt(int androidKeyCode) { + private static final int aKeyEventType2NewtEventType(int androidKeyAction) { + switch(androidKeyAction) { + case android.view.KeyEvent.ACTION_DOWN: + case android.view.KeyEvent.ACTION_MULTIPLE: + return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; + case android.view.KeyEvent.ACTION_UP: + return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; + default: + return 0; + } + } + + private static final int aKeyCode2NewtKeyCode(int androidKeyCode) { if(android.view.KeyEvent.KEYCODE_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_9) { return com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) ; } @@ -104,15 +147,7 @@ public class AndroidNewtEventFactory { return 0; } - public static final com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeANDROID2NEWT.get(event.getEventType()); - if(0xFFFFFFFF != type) { - return new com.jogamp.newt.event.WindowEvent(type, ((null==newtSource)?null:(Object)newtSource), event.getEventTime()); - } - return null; // no mapping .. - } - - static final int androidKeyModifiers2Newt(int androidMods) { + private static final int aKeyModifiers2Newt(int androidMods) { int newtMods = 0; if ((androidMods & android.view.KeyEvent.META_SYM_ON) != 0) newtMods |= com.jogamp.newt.event.InputEvent.META_MASK; if ((androidMods & android.view.KeyEvent.META_SHIFT_ON) != 0) newtMods |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; @@ -121,29 +156,40 @@ public class AndroidNewtEventFactory { return newtMods; } - private static final int androidKeyAction2NewtEventType(int androidKeyAction) { - switch(androidKeyAction) { - case android.view.KeyEvent.ACTION_DOWN: - case android.view.KeyEvent.ACTION_MULTIPLE: - return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; - case android.view.KeyEvent.ACTION_UP: - return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; - default: - return 0; + private final NewtGestureListener gestureListener; + private final android.view.GestureDetector gestureDetector; + private final float touchSlop; + + public AndroidNewtEventFactory(android.content.Context context, android.os.Handler handler) { + gestureListener = new NewtGestureListener(); + gestureDetector = new android.view.GestureDetector(context, gestureListener, handler, false /* ignoreMultitouch */); + gestureDetector.setIsLongpressEnabled(false); // favor scroll event! + final android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get(context); + touchSlop = configuration.getScaledTouchSlop(); + } + + public com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) { + final int aType = event.getEventType(); + final int nType = aAccessibilityEventType2Newt(aType); + + if(0xFFFFFFFF != nType) { + return new com.jogamp.newt.event.WindowEvent(nType, ((null==newtSource)?null:(Object)newtSource), event.getEventTime()); } + return null; // no mapping .. } + - public static final com.jogamp.newt.event.KeyEvent[] createKeyEvents(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) { - final int type = androidKeyAction2NewtEventType(event.getAction()); + public com.jogamp.newt.event.KeyEvent[] createKeyEvents(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) { + final int type = aKeyEventType2NewtEventType(event.getAction()); if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createKeyEvent: type 0x"+Integer.toHexString(type)+", keyCode 0x"+Integer.toHexString(keyCode)+", "+event); } if(0xFFFFFFFF != type) { - final int newtKeyCode = androidKeyCode2Newt(keyCode); + final int newtKeyCode = aKeyCode2NewtKeyCode(keyCode); if(0 != newtKeyCode) { final Object src = (null==newtSource)?null:(Object)newtSource; final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); - final int newtMods = androidKeyModifiers2Newt(event.getMetaState()); + final int newtMods = aKeyModifiers2Newt(event.getMetaState()); final com.jogamp.newt.event.KeyEvent ke1 = new com.jogamp.newt.event.KeyEvent( type, src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel()); @@ -161,29 +207,145 @@ public class AndroidNewtEventFactory { return null; } - public static final com.jogamp.newt.event.MouseEvent[] createMouseEvents(android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { + private int gestureScrollPointerDown = 0; + + public com.jogamp.newt.event.MouseEvent[] createMouseEvents(boolean isOnTouchEvent, + android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { if(Window.DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: "+toString(event)); + System.err.println("createMouseEvent: "+toString(event)); } - int type = eventTypeANDROID2NEWT.get(event.getAction()); - if(0xFFFFFFFF != type) { - int rotation = 0; - int clickCount = 1; + + // + // Prefilter Android Event (Gesture, ..) and determine final type + // + final int aType, nType; + float[] rotationXY = null; + int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL + { + final int pointerCount = event.getPointerCount(); + final boolean gestureEvent = isOnTouchEvent && pointerCount>1 && gestureDetector.onTouchEvent(event); + int _aType = 0xFFFFFFFF; + if( gestureEvent ) { + rotationXY = gestureListener.getScrollDistanceXY(); + if( null != rotationXY) { + final boolean skip = 0 == gestureScrollPointerDown; // skip 1st .. too bug distance + gestureScrollPointerDown = pointerCount; + if( skip ) { + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: GestureEvent Scroll Start - SKIP "+rotationXY[0]+"/"+rotationXY[1]+", gestureScrollPointerDown "+gestureScrollPointerDown); + } + return null; + } + _aType = ACTION_SCROLL; // 8 + rotationSource = 1; + } else { + throw new InternalError("Gesture Internal Error: consumed onTouchEvent, but no result (Scroll)"); + } + } + if( 0xFFFFFFFF == _aType ) { + _aType = event.getActionMasked(); + } + aType = _aType; + nType = aMotionEventType2Newt(aType); + + // + // Check whether events shall be skipped + // + if( !gestureEvent ) { + // Scroll Gesture: Wait for all pointers up - ACTION_UP, ACTION_POINTER_UP + if( 0 < gestureScrollPointerDown ) { + if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { + gestureScrollPointerDown--; + } + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: !GestureEvent SKIP gestureScrollPointerDown "+gestureScrollPointerDown); + } + return null; + } + } + } + + if(0xFFFFFFFF != nType) { + final int clickCount = 1; int modifiers = 0; - int[] x = new int[event.getPointerCount()]; - int[] y = new int[event.getPointerCount()]; - float[] pressure = new float[event.getPointerCount()]; - int[] pointers = new int[event.getPointerCount()]; - int index = 0; - while(index < event.getPointerCount()) { - x[index] = (int)event.getX(index); - y[index] = (int)event.getY(index); - pressure[index] = event.getPressure(index); - pointers[index] = event.getPointerId(index); - index++; + if( null == rotationXY && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12 + rotationXY = new float[] { event.getAxisValue(android.view.MotionEvent.AXIS_X), + event.getAxisValue(android.view.MotionEvent.AXIS_Y) }; + rotationSource = 2; } - + + final float rotation; + if( null != rotationXY ) { + final float _rotation; + if( rotationXY[0]*rotationXY[0] > rotationXY[1]*rotationXY[1] ) { + // Horizontal + modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + _rotation = rotationXY[0]; + } else { + // Vertical + _rotation = rotationXY[1]; + } + rotation = _rotation / touchSlop; + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: Scroll "+rotationXY[0]+"/"+rotationXY[1]+" -> "+_rotation+" / "+touchSlop+" -> "+rotation+" scaled -- mods "+modifiers+", source "+rotationSource); + } + } else { + rotation = 0.0f; + } + + // + // Determine newt-button and whether dedicated pointer is pressed + // + final int pCount; + final int pIndex; + final int button; + switch( aType ) { + case android.view.MotionEvent.ACTION_POINTER_DOWN: + case android.view.MotionEvent.ACTION_POINTER_UP: { + pIndex = event.getActionIndex(); + pCount = 1; + final int b = event.getPointerId(pIndex) + 1; // FIXME: Assumption that Pointer-ID starts w/ 0 ! + if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + button = b; + } else { + button = com.jogamp.newt.event.MouseEvent.BUTTON1; + } + } + break; + default: { + pIndex = 0; + pCount = event.getPointerCount(); // all + button = com.jogamp.newt.event.MouseEvent.BUTTON1; + } + } + + // + // Collect common data + // + final int[] x = new int[pCount]; + final int[] y = new int[pCount]; + final float[] pressure = new float[pCount]; + final int[] pointerIds = new int[pCount]; + { + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: collect ptr-data ["+pIndex+".."+(pIndex+pCount-1)+", "+pCount+"], aType "+aType+", button "+button+", gestureScrollPointerDown "+gestureScrollPointerDown); + } + int i = pIndex; + int j = 0; + while(j < pCount) { + x[j] = (int)event.getX(i); + y[j] = (int)event.getY(i); + pressure[j] = event.getPressure(i); + pointerIds[j] = event.getPointerId(i); + if(Window.DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: ptr-data["+i+" -> "+j+"] "+x[j]+"/"+y[j]+", pressure "+pressure[j]+", id "+pointerIds[j]); + } + i++; + j++; + } + } + if(null!=newtSource) { if(newtSource.isPointerConfined()) { modifiers |= InputEvent.CONFINED_MASK; @@ -195,21 +357,20 @@ public class AndroidNewtEventFactory { final Object src = (null==newtSource)?null:(Object)newtSource; final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); - final int button = pointers.length==1 ? MouseEvent.BUTTON1 : 0; final com.jogamp.newt.event.MouseEvent me1 = new com.jogamp.newt.event.MouseEvent( - type, src, unixTime, - modifiers, x, y, pressure, pointers, clickCount, + nType, src, unixTime, + modifiers, x, y, pressure, pointerIds, clickCount, button, rotation); - if(type == com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED) { + if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { return new com.jogamp.newt.event.MouseEvent[] { me1, new com.jogamp.newt.event.MouseEvent( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, - src, unixTime, modifiers, x, y, pressure, pointers, clickCount, + src, unixTime, modifiers, x, y, pressure, pointerIds, clickCount, button, rotation) }; } else { - return new com.jogamp.newt.event.MouseEvent[] { me1 }; + return new com.jogamp.newt.event.MouseEvent[] { me1 }; } } return null; // no mapping .. @@ -238,6 +399,58 @@ public class AndroidNewtEventFactory { } sb.append("]" ); return sb.toString(); - } + } + + class NewtGestureListener implements android.view.GestureDetector.OnGestureListener { + private float[] scrollDistance; + + NewtGestureListener() { + scrollDistance = null; + } + + /** Returns non null w/ 2 float values, XY, if storing onScroll's XY distance - otherwise null */ + public float[] getScrollDistanceXY() { + float[] sd = scrollDistance; + scrollDistance = null; + return sd; + } + + // + // Simple feedback + // + + @Override + public void onShowPress(android.view.MotionEvent e) { + } + + @Override + public void onLongPress(android.view.MotionEvent e) { + } + + @Override + public boolean onSingleTapUp(android.view.MotionEvent e) { + return false; + } + + // + // Consumed or not consumed ! + // + + @Override + public boolean onDown(android.view.MotionEvent e) { + return false; + } + + @Override + public boolean onScroll(android.view.MotionEvent e1, android.view.MotionEvent e2, float distanceX, float distanceY) { + scrollDistance = new float[] { distanceX, distanceY }; + return true; + } + + @Override + public boolean onFling(android.view.MotionEvent e1, android.view.MotionEvent e2, float velocityX, float velocityY) { + return false; + } + }; } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java new file mode 100644 index 000000000..ee0c8f8b1 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -0,0 +1,55 @@ +package jogamp.newt.driver.android.event; + +import jogamp.newt.driver.android.WindowDriver; +import android.view.View; + +public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTouchListener, View.OnFocusChangeListener, View.OnGenericMotionListener { + private final WindowDriver newtWindow; + private final AndroidNewtEventFactory factory; + + public AndroidNewtEventTranslator(WindowDriver newtWindow, android.content.Context context, android.os.Handler handler) { + this.newtWindow = newtWindow; + this.factory = new AndroidNewtEventFactory(context, handler); + } + + private final boolean processTouchMotionEvents(View v, android.view.MotionEvent event, boolean isOnTouchEvent) { + final com.jogamp.newt.event.MouseEvent[] newtEvents = factory.createMouseEvents(isOnTouchEvent, event, newtWindow); + if(null != newtEvents) { + newtWindow.focusChanged(false, true); + for(int i=0; iCallVoidMethod(env, javaWindow, sendMouseEventID, (ptr->select==0) ? (jint) EVENT_MOUSE_RELEASED : (jint) EVENT_MOUSE_PRESSED, (jint) 0, - (jint) ptr->x, (jint) ptr->y, 1, 0); + (jint) ptr->x, (jint) ptr->y, 1, 0.0f); } else { DBG_PRINT( "event mouse: src: %d, s:%p, i:0x%X (%d,%d)\n", userData, ptr->select, ptr->index, ptr->x, ptr->y); (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, 0, - (jint) ptr->x, (jint) ptr->y, 0, 0); + (jint) ptr->x, (jint) ptr->y, 0, 0.0f); } } break; @@ -193,7 +193,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_WindowDriver_initIDs sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); if (windowCreatedID == NULL || sizeChangedID == NULL || diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index b89b5c21d..5b826566b 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -36,36 +36,49 @@ #import "KeyEvent.h" #import "MouseEvent.h" -jint GetDeltaY(NSEvent *event, jint javaMods) { - CGFloat deltaY = 0.0; +#include + +static jfloat GetDelta(NSEvent *event, jint javaMods[]) { CGEventRef cgEvent = [event CGEvent]; + CGFloat deltaY = 0.0; + CGFloat deltaX = 0.0; + CGFloat delta = 0.0; if (CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventIsContinuous)) { // mouse pad case - deltaY = - CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1); - // fprintf(stderr, "WHEEL/PAD: %lf\n", (double)deltaY); + deltaX = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis2); + deltaY = CGEventGetIntegerValueField(cgEvent, kCGScrollWheelEventPointDeltaAxis1); + // fprintf(stderr, "WHEEL/PAD: %lf/%lf - 0x%X\n", (double)deltaX, (double)deltaY, javaMods[0]); + if( fabsf(deltaX) > fabsf(deltaY) ) { + javaMods[0] |= EVENT_SHIFT_MASK; + delta = deltaX; + } else { + delta = deltaY; + } } else { // traditional mouse wheel case + deltaX = [event deltaX]; deltaY = [event deltaY]; - // fprintf(stderr, "WHEEL/TRAD: %lf\n", (double)deltaY); - if (deltaY == 0.0 && (javaMods & EVENT_SHIFT_MASK) != 0) { + // fprintf(stderr, "WHEEL/TRACK: %lf/%lf - 0x%X\n", (double)deltaX, (double)deltaY, javaMods[0]); + if (deltaY == 0.0 && (javaMods[0] & EVENT_SHIFT_MASK) != 0) { // shift+vertical wheel scroll produces horizontal scroll // we convert it to vertical - deltaY = [event deltaX]; + delta = deltaX; + } else { + delta = deltaY; } - if (-1.0 < deltaY && deltaY < 1.0) { - deltaY *= 10.0; + if (-1.0 < delta && delta < 1.0) { + delta *= 10.0; } else { - if (deltaY < 0.0) { - deltaY = deltaY - 0.5f; + if (delta < 0.0) { + delta = delta - 0.5f; } else { - deltaY = deltaY + 0.5f; + delta = delta + 0.5f; } } } - // fprintf(stderr, "WHEEL/res: %d\n", (int)deltaY); - return (jint) deltaY; + // fprintf(stderr, "WHEEL/RES: %lf - 0x%X\n", (double)delta, javaMods[0]); + return (jfloat) delta; } static jmethodID enqueueMouseEventID = NULL; @@ -328,8 +341,8 @@ static jmethodID windowRepaintID = NULL; + (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz { - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); @@ -686,15 +699,16 @@ static jint mods2JavaMods(NSUInteger mods) DBG_PRINT("sendMouseEvent: null JNIEnv\n"); return; } - jint javaMods = mods2JavaMods([event modifierFlags]); + jint javaMods[] = { 0 } ; + javaMods[0] = mods2JavaMods([event modifierFlags]); // convert to 1-based button number (or use zero if no button is involved) // TODO: detect mouse button when mouse wheel scrolled jint javaButtonNum = 0; - jint scrollDeltaY = 0; + jfloat scrollDeltaY = 0.0f; switch ([event type]) { case NSScrollWheel: { - scrollDeltaY = GetDeltaY(event, javaMods); + scrollDeltaY = GetDelta(event, javaMods); javaButtonNum = 1; break; } @@ -727,12 +741,12 @@ static jint mods2JavaMods(NSUInteger mods) #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, javaWindowObject, sendMouseEventID, - evType, javaMods, + evType, javaMods[0], (jint) location.x, (jint) location.y, javaButtonNum, scrollDeltaY); #else (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID, JNI_FALSE, - evType, javaMods, + evType, javaMods[0], (jint) location.x, (jint) location.y, javaButtonNum, scrollDeltaY); #endif diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index b20717acc..17b93cfce 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -53,9 +53,13 @@ #define WM_MOUSEWHEEL 0x020A #endif //WM_MOUSEWHEEL -#ifndef WHEEL_DELTA -#define WHEEL_DELTA 120 -#endif //WHEEL_DELTA +#ifndef WM_MOUSEHWHEEL +#define WM_MOUSEHWHEEL 0x020E +#endif //WM_MOUSEHWHEEL + +#ifndef WHEEL_DELTAf +#define WHEEL_DELTAf (120.0f) +#endif //WHEEL_DELTAf #ifndef WHEEL_PAGESCROLL #define WHEEL_PAGESCROLL (UINT_MAX) @@ -64,6 +68,23 @@ #ifndef GET_WHEEL_DELTA_WPARAM // defined for (_WIN32_WINNT >= 0x0500) #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam)) #endif +#ifndef GET_KEYSTATE_WPARAM +#define GET_KEYSTATE_WPARAM(wParam) ((short)LOWORD(wParam)) +#endif + +#ifndef WM_HSCROLL +#define WM_HSCROLL 0x0114 +#endif +#ifndef WM_VSCROLL +#define WM_VSCROLL 0x0115 +#endif + +#ifndef WH_MOUSE +#define WH_MOUSE 7 +#endif +#ifndef WH_MOUSE_LL +#define WH_MOUSE_LL 14 +#endif #ifndef MONITOR_DEFAULTTONULL #define MONITOR_DEFAULTTONULL 0 @@ -796,6 +817,72 @@ static void WmSize(JNIEnv *env, jobject window, HWND wnd, UINT type) (*env)->CallVoidMethod(env, window, sizeChangedID, JNI_FALSE, w, h, JNI_FALSE); } +#ifdef TEST_MOUSE_HOOKS + +static HHOOK hookLLMP; +static HHOOK hookMP; + +static LRESULT CALLBACK HookLowLevelMouseProc (int code, WPARAM wParam, LPARAM lParam) +{ + // if (code == HC_ACTION) + { + const char *msg; + char msg_buff[128]; + switch (wParam) + { + case WM_LBUTTONDOWN: msg = "WM_LBUTTONDOWN"; break; + case WM_LBUTTONUP: msg = "WM_LBUTTONUP"; break; + case WM_MOUSEMOVE: msg = "WM_MOUSEMOVE"; break; + case WM_MOUSEWHEEL: msg = "WM_MOUSEWHEEL"; break; + case WM_MOUSEHWHEEL: msg = "WM_MOUSEHWHEEL"; break; + case WM_RBUTTONDOWN: msg = "WM_RBUTTONDOWN"; break; + case WM_RBUTTONUP: msg = "WM_RBUTTONUP"; break; + default: + sprintf(msg_buff, "Unknown msg: %u", wParam); + msg = msg_buff; + break; + }//switch + + const MSLLHOOKSTRUCT *p = (MSLLHOOKSTRUCT*)lParam; + DBG_PRINT("**** LLMP: Code: 0x%X: %s - %d/%d\n", code, msg, (int)p->pt.x, (int)p->pt.y); + //} else { + // DBG_PRINT("**** LLMP: CODE: 0x%X\n", code); + } + return CallNextHookEx(hookLLMP, code, wParam, lParam); +} + +static LRESULT CALLBACK HookMouseProc (int code, WPARAM wParam, LPARAM lParam) +{ + // if (code == HC_ACTION) + { + const char *msg; + char msg_buff[128]; + switch (wParam) + { + case WM_LBUTTONDOWN: msg = "WM_LBUTTONDOWN"; break; + case WM_LBUTTONUP: msg = "WM_LBUTTONUP"; break; + case WM_MOUSEMOVE: msg = "WM_MOUSEMOVE"; break; + case WM_MOUSEWHEEL: msg = "WM_MOUSEWHEEL"; break; + case WM_MOUSEHWHEEL: msg = "WM_MOUSEHWHEEL"; break; + case WM_RBUTTONDOWN: msg = "WM_RBUTTONDOWN"; break; + case WM_RBUTTONUP: msg = "WM_RBUTTONUP"; break; + default: + sprintf(msg_buff, "Unknown msg: %u", wParam); + msg = msg_buff; + break; + }//switch + + const MOUSEHOOKSTRUCT *p = (MOUSEHOOKSTRUCT*)lParam; + DBG_PRINT("**** MP: Code: 0x%X: %s - hwnd %p, %d/%d\n", code, msg, p->hwnd, (int)p->pt.x, (int)p->pt.y); + //} else { + // DBG_PRINT("**** MP: CODE: 0x%X\n", code); + } + return CallNextHookEx(hookMP, code, wParam, lParam); +} + +#endif + + static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lParam) { LRESULT res = 0; int useDefWindowProc = 0; @@ -817,7 +904,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP env = wud->jenv; window = wud->jinstance; - // DBG_PRINT("*** WindowsWindow: thread 0x%X - window %p -> %p, 0x%X %d/%d\n", (int)GetCurrentThreadId(), wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); + // DBG_PRINT("*** WindowsWindow: thread 0x%X - window %p -> %p, msg 0x%X, %d/%d\n", (int)GetCurrentThreadId(), wnd, window, message, (int)LOWORD(lParam), (int)HIWORD(lParam)); if (NULL==window || NULL==env) { return DefWindowProc(wnd, message, wParam, lParam); @@ -921,7 +1008,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 1, (jint) 0); + (jint) 1, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -930,7 +1017,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 1, (jint) 0); + (jint) 1, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -941,7 +1028,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 2, (jint) 0); + (jint) 2, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -950,7 +1037,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 2, (jint) 0); + (jint) 2, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -961,7 +1048,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 3, (jint) 0); + (jint) 3, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -970,7 +1057,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 3, (jint) 0); + (jint) 3, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -979,7 +1066,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_MOVED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 0, (jint) 0); + (jint) 0, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_MOUSELEAVE: @@ -987,24 +1074,64 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (jint) EVENT_MOUSE_EXITED, 0, (jint) -1, (jint) -1, // fake - (jint) 0, (jint) 0); + (jint) 0, (jfloat) 0.0f); useDefWindowProc = 1; break; // Java synthesizes EVENT_MOUSE_ENTERED - case WM_MOUSEWHEEL: { + case WM_HSCROLL: { // Only delivered if windows has WS_HSCROLL, hence dead code! + int sb = LOWORD(wParam); + int modifiers = GetModifiers( FALSE, 0 ) | EVENT_SHIFT_MASK; + float rotation; + switch(sb) { + case SB_LINELEFT: + rotation = 1.0f; + break; + case SB_PAGELEFT: + rotation = 2.0f; + break; + case SB_LINERIGHT: + rotation = -1.0f; + break; + case SB_PAGERIGHT: + rotation = -1.0f; + break; + } + DBG_PRINT("*** WindowsWindow: WM_HSCROLL 0x%X, rotation %f, mods 0x%X\n", sb, rotation, modifiers); + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jint) EVENT_MOUSE_WHEEL_MOVED, + modifiers, + (jint) 0, (jint) 0, + (jint) 1, (jfloat) rotation); + useDefWindowProc = 1; + break; + } + case WM_MOUSEHWHEEL: /* tilt */ + case WM_MOUSEWHEEL: /* rotation */ { // need to convert the coordinates to component-relative int x = GET_X_LPARAM(lParam); int y = GET_Y_LPARAM(lParam); + int modifiers = GetModifiers( FALSE, 0 ); + float rotationOrTilt = (float)(GET_WHEEL_DELTA_WPARAM(wParam))/WHEEL_DELTAf; + int vKeys = GET_KEYSTATE_WPARAM(wParam); POINT eventPt; eventPt.x = x; eventPt.y = y; ScreenToClient(wnd, &eventPt); + + if( WM_MOUSEHWHEEL == message ) { + modifiers |= EVENT_SHIFT_MASK; + DBG_PRINT("*** WindowsWindow: WM_MOUSEHWHEEL %d/%d, tilt %f, vKeys 0x%X, mods 0x%X\n", + (int)eventPt.x, (int)eventPt.y, rotationOrTilt, vKeys, modifiers); + } else { + DBG_PRINT("*** WindowsWindow: WM_MOUSEWHEEL %d/%d, rotation %f, vKeys 0x%X, mods 0x%X\n", + (int)eventPt.x, (int)eventPt.y, rotationOrTilt, vKeys, modifiers); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jint) EVENT_MOUSE_WHEEL_MOVED, - GetModifiers( FALSE, 0 ), + modifiers, (jint) eventPt.x, (jint) eventPt.y, - (jint) 1, (jint) (GET_WHEEL_DELTA_WPARAM(wParam)/120.0f)); + (jint) 1, (jfloat) rotationOrTilt); useDefWindowProc = 1; break; } @@ -1057,8 +1184,9 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP useDefWindowProc = 1; } - if (useDefWindowProc) + if (useDefWindowProc) { return DefWindowProc(wnd, message, wParam, lParam); + } return res; } @@ -1195,7 +1323,7 @@ static void NewtScreen_scanDisplayDevices() { int i = 0; LPCTSTR name; while(NULL != (name = NewtScreen_getDisplayDeviceName(&device, i))) { - fprintf(stderr, "*** [%d]: <%s> active %d\n", i, name, ( 0 != ( device.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); + DBG_PRINT("*** [%d]: <%s> active %d\n", i, name, ( 0 != ( device.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); i++; } }*/ @@ -1335,7 +1463,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScree * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 - (JNIEnv *env, jclass clazz) + (JNIEnv *env, jclass clazz, jlong hInstance) { NewtCommon_init(env); @@ -1346,8 +1474,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIII)V"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V"); @@ -1367,6 +1495,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 return JNI_FALSE; } BuildDynamicKeyMapTable(); + return JNI_TRUE; } @@ -1412,6 +1541,8 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, UpdateWindow(hwnd); } +#define WS_DEFAULT_STYLES (WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_TABSTOP) + /* * Class: jogamp_newt_driver_windows_WindowDriver * Method: CreateWindow @@ -1425,7 +1556,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo HWND parentWindow = (HWND) (intptr_t) parent; const TCHAR* wndClassName = NULL; const TCHAR* wndName = NULL; - DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_VISIBLE | WS_TABSTOP; + DWORD windowStyle = WS_DEFAULT_STYLES | WS_VISIBLE; int x=(int)jx, y=(int)jy; int width=(int)defaultWidth, height=(int)defaultHeight; HWND window = NULL; @@ -1516,6 +1647,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo (*env)->ReleaseStringUTFChars(env, jWndName, wndName); #endif +#ifdef TEST_MOUSE_HOOKS + hookLLMP = SetWindowsHookEx(WH_MOUSE_LL, &HookLowLevelMouseProc, (HINSTANCE) (intptr_t) hInstance, 0); + hookMP = SetWindowsHookEx(WH_MOUSE_LL, &HookMouseProc, (HINSTANCE) (intptr_t) hInstance, 0); + DBG_PRINT("**** LLMP Hook %p, MP Hook %p\n", hookLLMP, hookMP); +#endif + return (jlong) (intptr_t) window; } @@ -1563,7 +1700,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_reconfigureW { HWND hwndP = (HWND) (intptr_t) parent; HWND hwnd = (HWND) (intptr_t) window; - DWORD windowStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN ; + DWORD windowStyle = WS_DEFAULT_STYLES; BOOL styleChange = TST_FLAG_CHANGE_DECORATION(flags) || TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_PARENTING(flags) ; DBG_PRINT( "*** WindowsWindow: reconfigureWindow0 parent %p, window %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d -> styleChange %d\n", diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 3f34a16b6..85b3a14c7 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -218,8 +218,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 reparentNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "reparentNotify", "(J)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowRepaint", "(ZIIII)V"); - enqueueMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueMouseEvent", "(ZIIIIII)V"); - sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(IIIIII)V"); + enqueueMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueMouseEvent", "(ZIIIIIF)V"); + sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(IIIIIF)V"); enqueueKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueKeyEvent", "(ZIIIC)V"); sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(IIIC)V"); requestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "requestFocus", "(Z)V"); @@ -416,33 +416,33 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #endif break; case ButtonRelease: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #endif break; case MotionNotify: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); #endif break; case EnterNotify: @@ -450,11 +450,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #endif break; case LeaveNotify: @@ -462,11 +462,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #endif break; case KeyPress: diff --git a/src/newt/native/X11Event.c b/src/newt/native/X11Event.c index 079203400..770f60e8f 100644 --- a/src/newt/native/X11Event.c +++ b/src/newt/native/X11Event.c @@ -103,33 +103,33 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #endif break; case ButtonRelease: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0 /*rotation*/); + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); #endif break; case MotionNotify: #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); #endif break; case EnterNotify: @@ -137,11 +137,11 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #endif break; case LeaveNotify: @@ -149,11 +149,11 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0 /*rotation*/); + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); #endif break; case KeyPress: diff --git a/src/newt/native/XCBEvent.c b/src/newt/native/XCBEvent.c index 77a3380db..f067f4b7a 100644 --- a/src/newt/native/XCBEvent.c +++ b/src/newt/native/XCBEvent.c @@ -129,11 +129,11 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0.0f /*rotation*/); #endif } break; case XCB_BUTTON_RELEASE: { @@ -141,11 +141,11 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint) _evt->state, 0.0f /*rotation*/); #endif } break; case XCB_MOTION_NOTIFY: { @@ -153,11 +153,11 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint)0, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint)0, 0.0f /*rotation*/); #else (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED, modifiers, - (jint) _evt->event_x, (jint) _evt->event_y, (jint)0, 0 /*rotation*/); + (jint) _evt->event_x, (jint) _evt->event_y, (jint)0, 0.0f /*rotation*/); #endif } break; case XCB_KEY_PRESS: { diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index 0093da437..bbddf764b 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -117,7 +117,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIII)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); if (windowCreatedID == NULL || sizeChangedID == NULL || diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index cc5aae99e..43a393495 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -55,6 +55,7 @@ public class GearsES2 implements GLEventListener { private GLUniformData pmvMatrixUniform = null; private GLUniformData colorU = null; private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; + private float panX = 0.0f, panY = 0.0f; private GearsObjectES2 gear1=null, gear2=null, gear3=null; private float angle = 0.0f; private int swapInterval = 0; @@ -302,6 +303,7 @@ public class GearsES2 implements GLEventListener { st.useProgram(gl, true); pmvMatrix.glPushMatrix(); + pmvMatrix.glTranslatef(panX, panY, 0.0f); pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); @@ -336,7 +338,32 @@ public class GearsES2 implements GLEventListener { } } - class GearsMouseAdapter extends MouseAdapter { + class GearsMouseAdapter implements MouseListener{ + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + } + + @Override + public void mouseExited(MouseEvent e) { + } + + @Override + public void mouseWheelMoved(MouseEvent e) { + float r = e.getWheelRotation() * 1.0f; + if( e.isShiftDown() ) { + // horizontal + panX -= r; // positive -> left + } else { + // vertical + panY += r; // positive -> up + } + } + public void mousePressed(MouseEvent e) { prevMouseX = e.getX(); prevMouseY = e.getY(); -- cgit v1.2.3 From 5060b728b26a89a14367f8fca9f4eb7968f719ca Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 15 Jan 2013 19:24:50 +0100 Subject: ShaderState: Reduce hash-map utilization at shader switch (reset uniforms/attributes); Refine API doc. --- make/scripts/tests.sh | 6 +- .../com/jogamp/opengl/util/glsl/ShaderState.java | 103 ++++++++++++--------- 2 files changed, 62 insertions(+), 47 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bc379de63..9e76b314c 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -165,7 +165,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - D_ARGS="-Dnewt.debug.Window.MouseEvent" + #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window" @@ -261,7 +261,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* @@ -481,7 +481,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* # diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java index 9d71ee276..a221cd51e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderState.java @@ -366,14 +366,13 @@ public class ShaderState { if(null==shaderProgram) throw new GLException("No program is attached"); if(shaderProgram.linked()) throw new GLException("Program is already linked"); final String name = data.getName(); - final Integer loc = new Integer(location); - activeAttribLocationMap.put(name, loc); + activeAttribLocationMap.put(name, new Integer(location)); data.setLocation(gl, shaderProgram.program(), location); activeAttribDataMap.put(data.getName(), data); } /** - * Gets the location of a shader attribute.
    + * Gets the location of a shader attribute with given name.
    * Uses either the cached value {@link #getCachedAttribLocation(String)} if valid, * or the GLSL queried via {@link GL2ES2#glGetAttribLocation(int, String)}.
    * The location will be cached. @@ -395,8 +394,7 @@ public class ShaderState { if(!shaderProgram.linked()) throw new GLException("Program is not linked"); location = gl.glGetAttribLocation(shaderProgram.program(), name); if(0<=location) { - Integer idx = new Integer(location); - activeAttribLocationMap.put(name, idx); + activeAttribLocationMap.put(name, new Integer(location)); if(DEBUG) { System.err.println("ShaderState: glGetAttribLocation: "+name+", loc: "+location); } @@ -409,7 +407,7 @@ public class ShaderState { } return location; } - + /** * Validates and returns the location of a shader attribute.
    * Uses either the cached value {@link #getCachedAttribLocation(String)} if valid, @@ -622,11 +620,12 @@ public class ShaderState { } /** - * Set the {@link GLArrayData} vertex attribute data. - * - * This method uses the {@link GLArrayData}'s location if set. - * If data location is unset it will be retrieved via {@link #getAttribLocation(GL2ES2, GLArrayData)}, set - * and cached in this state. + * Set the {@link GLArrayData} vertex attribute data, if it's location is valid, i.e. ≥ 0. + *

    + * This method uses the {@link GLArrayData}'s location if valid, i.e. ≥ 0.
    + * If data's location is invalid, it will be retrieved via {@link #getAttribLocation(GL2ES2, GLArrayData)}, + * set and cached in this state. + *

    * * @return false, if the location could not be determined, otherwise true * @@ -713,12 +712,14 @@ public class ShaderState { } private final void relocateAttribute(GL2ES2 gl, GLArrayData attribute) { - // get new location .. + // get new location .. note: 'activeAttribLocationMap' is cleared before final String name = attribute.getName(); - final int loc = getAttribLocation(gl, name); - attribute.setLocation(loc); - + final int loc = attribute.setLocation(gl, shaderProgram.program()); if(0<=loc) { + activeAttribLocationMap.put(name, new Integer(loc)); + if(DEBUG) { + System.err.println("ShaderState: relocateAttribute: "+name+", loc: "+loc); + } if(isVertexAttribArrayEnabled(name)) { // enable attrib, VBO and pass location/data gl.glEnableVertexAttribArray(loc); @@ -737,13 +738,20 @@ public class ShaderState { /** * Reset all previously enabled mapped vertex attribute data. * - *

    Attribute data is bound to the GL state

    - *

    Attribute location is bound to the program

    + *

    + * Attribute data is bound to the GL state, i.e. VBO data itself will not be updated. + *

    + * + *

    + * Attribute location and it's data assignment is bound to the program, + * hence both are updated. + *

    + * + *

    + * Note: Such update could only be prevented, + * if tracking am attribute/program dirty flag. + *

    * - *

    However, since binding an attribute to a location via {@link #bindAttribLocation(GL2ES2, int, GLArrayData)} - * must happen before linking and we try to promote the attributes to the new program, - * we have to gather the probably new location etc.

    - * * @throws GLException is the program is not linked * * @see #attachShaderProgram(GL2ES2, ShaderProgram) @@ -835,7 +843,7 @@ public class ShaderState { } /** - * Gets the location of a shader uniform.
    + * Gets the location of a shader uniform with given name.
    * Uses either the cached value {@link #getCachedUniformLocation(String)} if valid, * or the GLSL queried via {@link GL2ES2#glGetUniformLocation(int, String)}.
    * The location will be cached. @@ -902,8 +910,7 @@ public class ShaderState { if(!shaderProgram.linked()) throw new GLException("Program is not linked"); location = data.setLocation(gl, shaderProgram.program()); if(0<=location) { - Integer idx = new Integer(location); - activeUniformLocationMap.put(name, idx); + activeUniformLocationMap.put(name, new Integer(location)); } else if(verbose) { System.err.println("ShaderState: glUniform failed, no location for: "+name+", index: "+location); if(DEBUG) { @@ -916,19 +923,14 @@ public class ShaderState { } /** - * Set the uniform data. - * - * Even if the uniform is not found in the current shader, - * it is stored in this state. - * - * @param data the GLUniforms's name must match the uniform one, - * it's index will be set with the uniforms's location, - * if found. - * - * - * @return false, if the name is not found, otherwise true + * Set the uniform data, if it's location is valid, i.e. ≥ 0. + *

    + * This method uses the {@link GLUniformData}'s location if valid, i.e. ≥ 0.
    + * If data's location is invalid, it will be retrieved via {@link #getUniformLocation(GL2ES2, GLUniformData)}, + * set and cached in this state. + *

    * - * @throws GLException if the program is not in use + * @return false, if the location could not be determined, otherwise true * * @see #glGetUniformLocation * @see javax.media.opengl.GL2ES2#glGetUniformLocation @@ -948,10 +950,11 @@ public class ShaderState { System.err.println("ShaderState: glUniform: "+data); } gl.glUniform(data); + return true; } - return true; + return false; } - + /** * Get the uniform data, previously set. * @@ -973,10 +976,15 @@ public class ShaderState { /** * Reset all previously mapped uniform data - * + *

    * Uniform data and location is bound to the program, - * hence both are updated here - * + * hence both are updated. + *

    + *

    + * Note: Such update could only be prevented, + * if tracking a uniform/program dirty flag. + *

    + * * @throws GLException is the program is not in use * * @see #attachShaderProgram(GL2ES2, ShaderProgram) @@ -988,9 +996,16 @@ public class ShaderState { iter.next().setLocation(-1); } for(Iterator iter = activeUniformDataMap.values().iterator(); iter.hasNext(); ) { - final GLUniformData uniform = iter.next(); - uniform.setLocation(-1); - uniform(gl, uniform); + final GLUniformData data = iter.next(); + final int loc = data.setLocation(gl, shaderProgram.program()); + if( 0 <= loc ) { + // only pass the data, if the uniform exists in the current shader + activeUniformLocationMap.put(data.getName(), new Integer(loc)); + if(DEBUG) { + System.err.println("ShaderState: resetAllUniforms: "+data); + } + gl.glUniform(data); + } } } -- cgit v1.2.3 From 34687193484b2404d83eebf5d008b71d54e52286 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 18 Jan 2013 03:38:35 +0100 Subject: Fix Bug 669: Recursive GLContext makeCurrent()/release() Culprit: GLContext's makeCurrent() didn't clear the boolean flag 'unlockContextAndSurface' in case the context is already current (-> recursion). Above case was detected within a code block tailed by a finally block, which acted on mentioned flag, i.e. called lock.unlock() and hence decremented the lock count even though the method return w/ successful state. Fixed. Added debug code: GLContext.release() debug code (DEBUG | TRACE_SWITCH), recording stack trace of last release() call, which is dumped in case no current was current. Added 2 unit tests: - Simple recursive GLContext makeCurrent()/release() from within GLEventListener's display(). Test also validates lock count and lock ownership. - GLAutoDrawable display() of another GLAutoDrawable from within GLEventListener's display(..). --- make/scripts/tests.sh | 5 +- src/jogl/classes/javax/media/opengl/GLContext.java | 11 ++ src/jogl/classes/jogamp/opengl/GLContextImpl.java | 122 +++++++++++++------ .../jogamp/opengl/x11/glx/X11GLXContext.java | 2 +- .../acore/TestBug669RecursiveGLContext01NEWT.java | 135 +++++++++++++++++++++ .../acore/TestBug669RecursiveGLContext02NEWT.java | 132 ++++++++++++++++++++ 6 files changed, 368 insertions(+), 39 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext02NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9e76b314c..46e6c63a9 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -89,6 +89,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" + #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.FixedFuncPipeline" @@ -277,6 +278,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* @@ -481,7 +484,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 $* # diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 8cc29f1f2..455f2d70d 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -103,6 +103,7 @@ public abstract class GLContext { public static final boolean DEBUG = Debug.debug("GLContext"); public static final boolean TRACE_SWITCH = Debug.isPropertyDefined("jogl.debug.GLContext.TraceSwitch", true); + public static final boolean DEBUG_TRACE_SWITCH = DEBUG || TRACE_SWITCH; /** Reflects property jogl.debug.DebugGL. If true, the debug pipeline is enabled at context creation. */ public static final boolean DEBUG_GL = Debug.isPropertyDefined("jogl.debug.DebugGL", true); @@ -414,6 +415,16 @@ public abstract class GLContext { } } + /** Returns a String representation of the {@link #makeCurrent()} result. */ + public static final String makeCurrentResultToString(int res) { + switch(res) { + case CONTEXT_NOT_CURRENT: return "CONTEXT_NOT_CURRENT"; + case CONTEXT_CURRENT: return "CONTEXT_CURRENT"; + case CONTEXT_CURRENT_NEW: return "CONTEXT_NOT_CURRENT"; + default: return "INVALID_VALUE"; + } + } + /** * Sets the thread-local variable returned by {@link #getCurrent} * and has no other side-effects. For use by third parties adding diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index d960883d5..f2c2cfada 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -49,6 +49,7 @@ import com.jogamp.common.os.DynamicLookupHelper; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; +import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLNameResolver; @@ -270,14 +271,25 @@ public abstract class GLContextImpl extends GLContext { @Override public void release() throws GLException { release(false); - } + } private void release(boolean inDestruction) throws GLException { if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - release() - force: "+inDestruction+", "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch[release.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+", inDestruction: "+inDestruction+", "+lock); } if ( !lock.isOwner(Thread.currentThread()) ) { - throw new GLException("Context not current on current thread "+Thread.currentThread().getName()+": "+this); + final String msg = getThreadName() +": Context not current on current thread, obj " + toHexString(hashCode())+", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+", inDestruction: "+inDestruction+", "+lock; + if( DEBUG_TRACE_SWITCH ) { + System.err.println(msg); + if( null != lastCtxReleaseStack) { + System.err.print("Last release call: "); + lastCtxReleaseStack.printStackTrace(); + } else { + System.err.println("Last release call: NONE"); + } + } + throw new GLException(msg); } + Throwable drawableContextMadeCurrentException = null; final boolean actualRelease = ( inDestruction || lock.getHoldCount() == 1 ) && 0 != contextHandle; try { @@ -298,8 +310,13 @@ public abstract class GLContextImpl extends GLContext { } drawable.unlockSurface(); lock.unlock(); - if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+(actualRelease?"switch":"keep ")+" - CONTEXT_RELEASE - "+lock); + if( DEBUG_TRACE_SWITCH ) { + final String msg = getThreadName() +": GLContext.ContextSwitch[release.X]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+(actualRelease?"switch":"keep ")+" - "+lock; + lastCtxReleaseStack = new Throwable(msg); + if(TRACE_SWITCH) { + System.err.println(msg); + // Thread.dumpStack(); + } } } if(null != drawableContextMadeCurrentException) { @@ -307,11 +324,12 @@ public abstract class GLContextImpl extends GLContext { } } + private Throwable lastCtxReleaseStack = null; protected abstract void releaseImpl() throws GLException; @Override public final void destroy() { - if (DEBUG || TRACE_SWITCH) { + if (DEBUG_TRACE_SWITCH) { System.err.println(getThreadName() + ": GLContextImpl.destroy.0: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + ", surf "+toHexString(drawable.getHandle())+", isShared "+GLContextShareSet.isShared(this)+" - "+lock); } @@ -328,7 +346,7 @@ public abstract class GLContextImpl extends GLContext { lock.lock(); // holdCount++ -> 1 - n (1: not locked, 2-n: destroy while rendering) if ( lock.getHoldCount() > 2 ) { final String msg = getThreadName() + ": GLContextImpl.destroy: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle); - if (DEBUG || TRACE_SWITCH) { + if (DEBUG_TRACE_SWITCH) { System.err.println(msg+" - Lock was hold more than once - makeCurrent/release imbalance: "+lock); Thread.dumpStack(); } @@ -445,14 +463,21 @@ public abstract class GLContextImpl extends GLContext { */ @Override public int makeCurrent() throws GLException { - boolean unlockContextAndDrawable = true; - int res = CONTEXT_NOT_CURRENT; + if(TRACE_SWITCH) { + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+lock); + } // Note: the surface is locked within [makeCurrent .. swap .. release] - int lockRes = drawable.lockSurface(); + final int lockRes = drawable.lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY >= lockRes) { + if(DEBUG_TRACE_SWITCH) { + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X1]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - Surface Not Ready - CONTEXT_NOT_CURRENT - "+lock); + } return CONTEXT_NOT_CURRENT; } + + boolean unlockContextAndSurface = true; // Must be cleared if successful, otherwise finally block will release context and surface! + int res = CONTEXT_NOT_CURRENT; try { if (0 == drawable.getHandle()) { throw new GLException("drawable has invalid handle: "+drawable); @@ -472,8 +497,9 @@ public abstract class GLContextImpl extends GLContext { // Assume we don't need to make this context current again // For Mac OS X, however, we need to update the context to track resizes drawableUpdatedNotify(); + unlockContextAndSurface = false; // success if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep - CONTEXT_CURRENT - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X2]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - keep - CONTEXT_CURRENT - "+lock); } return CONTEXT_CURRENT; } else { @@ -481,7 +507,7 @@ public abstract class GLContextImpl extends GLContext { } } res = makeCurrentWithinLock(lockRes); - unlockContextAndDrawable = CONTEXT_NOT_CURRENT == res; + unlockContextAndSurface = CONTEXT_NOT_CURRENT == res; // success ? /** * FIXME: refactor dependence on Java 2D / JOGL bridge @@ -491,28 +517,27 @@ public abstract class GLContextImpl extends GLContext { } */ } catch (RuntimeException e) { - unlockContextAndDrawable = true; + unlockContextAndSurface = true; throw e; } finally { - if (unlockContextAndDrawable) { + if (unlockContextAndSurface) { + if(DEBUG_TRACE_SWITCH) { + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.1]: Context lock.unlock() due to error, res "+makeCurrentResultToString(res)+", "+lock); + } lock.unlock(); } } } /* if ( drawable.isRealized() ) */ } catch (RuntimeException e) { - unlockContextAndDrawable = true; + unlockContextAndSurface = true; throw e; } finally { - if (unlockContextAndDrawable) { + if (unlockContextAndSurface) { drawable.unlockSurface(); } } - if (res == CONTEXT_NOT_CURRENT) { - if(DEBUG || TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+", drawable.isRealized() "+drawable.isRealized()+" - switch - CONTEXT_NOT_CURRENT - "+lock); - } - } else { + if (res != CONTEXT_NOT_CURRENT) { setCurrent(this); if(res == CONTEXT_CURRENT_NEW) { // check if the drawable's and the GL's GLProfile are equal @@ -531,15 +556,9 @@ public abstract class GLContextImpl extends GLContext { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); } - contextRealized(true); - - if(DEBUG || TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - CONTEXT_CURRENT_NEW - "+lock); - } - } else if(TRACE_SWITCH) { - System.err.println(getThreadName() +": GLContext.ContextSwitch: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - CONTEXT_CURRENT - "+lock); + contextRealized(true); } - + contextMadeCurrent(true); /* FIXME: refactor dependence on Java 2D / JOGL bridge @@ -551,9 +570,12 @@ public abstract class GLContextImpl extends GLContext { } */ } + if(TRACE_SWITCH) { + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X3]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - "+makeCurrentResultToString(res)+" - "+lock); + } return res; } - + private final int makeCurrentWithinLock(int surfaceLockRes) throws GLException { if (!isCreated()) { if(DEBUG_GL) { @@ -584,7 +606,7 @@ public abstract class GLContextImpl extends GLContext { shareWith.getDrawableImpl().unlockSurface(); } } - if (DEBUG || TRACE_SWITCH) { + if (DEBUG_TRACE_SWITCH) { if(created) { System.err.println(getThreadName() + ": Create GL context OK: obj " + toHexString(hashCode()) + ", ctx " + toHexString(contextHandle) + ", surf "+toHexString(drawable.getHandle())+" for " + getClass().getName()+" - "+getGLVersion()); // Thread.dumpStack(); @@ -1641,7 +1663,7 @@ public abstract class GLContextImpl extends GLContext { return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); } - protected String getContextFQN() { + protected final String getContextFQN() { return contextFQN; } @@ -1696,19 +1718,19 @@ public abstract class GLContextImpl extends GLContext { //---------------------------------------------------------------------- // Helpers for buffer object optimizations - public void setBufferSizeTracker(GLBufferSizeTracker bufferSizeTracker) { + public final void setBufferSizeTracker(GLBufferSizeTracker bufferSizeTracker) { this.bufferSizeTracker = bufferSizeTracker; } - public GLBufferSizeTracker getBufferSizeTracker() { + public final GLBufferSizeTracker getBufferSizeTracker() { return bufferSizeTracker; } - public GLBufferStateTracker getBufferStateTracker() { + public final GLBufferStateTracker getBufferStateTracker() { return bufferStateTracker; } - public GLStateTracker getGLStateTracker() { + public final GLStateTracker getGLStateTracker() { return glStateTracker; } @@ -1717,10 +1739,36 @@ public abstract class GLContextImpl extends GLContext { // current on the OpenGL worker thread // - public boolean hasWaiters() { + /** + * Returns true if the given thread is owner, otherwise false. + *

    + * Method exists merely for code validation of {@link #isCurrent()}. + *

    + */ + public final boolean isOwner(Thread thread) { + return lock.isOwner(thread); + } + + /** + * Returns true if there are other threads waiting for this GLContext to {@link #makeCurrent()}, otherwise false. + *

    + * Since method does not perform any synchronization, accurate result are returned if lock is hold - only. + *

    + */ + public final boolean hasWaiters() { return lock.getQueueLength()>0; } + /** + * Returns the number of hold locks. See {@link RecursiveLock#getHoldCount()} for semantics. + *

    + * Since method does not perform any synchronization, accurate result are returned if lock is hold - only. + *

    + */ + public final int getLockCount() { + return lock.getHoldCount(); + } + //--------------------------------------------------------------------------- // Special FBO hook // diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 5b0d32353..c2b66801e 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -166,7 +166,7 @@ public abstract class X11GLXContext extends GLContextImpl { throw new InternalError("Given readDrawable but no driver support"); } } catch (RuntimeException re) { - if(DEBUG || TRACE_SWITCH) { + if(DEBUG_TRACE_SWITCH) { System.err.println(getThreadName()+": Warning: X11GLXContext.glXMakeContextCurrent failed: "+re+", with "+ "dpy "+toHexString(dpy)+ ", write "+toHexString(writeDrawable)+ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext01NEWT.java new file mode 100644 index 000000000..7b8529191 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext01NEWT.java @@ -0,0 +1,135 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.acore; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import jogamp.opengl.GLContextImpl; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Tests simple recursive GLContext behavior. + * + *

    + * Issues {@link GLContext#makeCurrent()} and {@link GLContext#release()} + * from within {@link GLEventListener#display(GLAutoDrawable)}. + *

    + * + * + */ +public class TestBug669RecursiveGLContext01NEWT extends UITestCase { + + @Test(timeout=5000) + public void test01_Plain() { + test01Impl(false); + } + + @Test(timeout=5000) + public void test01_Anim() { + test01Impl(true); + } + + private void test01Impl(boolean anim) { + final String profile = GLProfile.GL2ES2; + if(!GLProfile.isAvailable(profile)) { System.err.println(profile+" n/a"); return; } + + final GLProfile pro = GLProfile.get(profile); + final GLCapabilities caps = new GLCapabilities(pro); + final GLWindow window = GLWindow.create(caps); + + final Animator animator = new Animator(); + if(anim) { + animator.add(window); + } + animator.start(); + + window.setSize(640, 480); + window.addGLEventListener(new GLEventListener() { + private void makeCurrentRecursive(GLContextImpl context, int lockCount) { + Assert.assertEquals(true, context.isOwner(Thread.currentThread())); + Assert.assertEquals(lockCount, context.getLockCount()); + Assert.assertEquals(true, context.isCurrent()); + + Assert.assertEquals(GLContext.CONTEXT_CURRENT, context.makeCurrent()); // recursive: lock +1 + + Assert.assertEquals(true, context.isOwner(Thread.currentThread())); + Assert.assertEquals(lockCount+1, context.getLockCount()); + Assert.assertEquals(true, context.isCurrent()); + } + private void releaseRecursive(GLContextImpl context, int lockCount) { + Assert.assertEquals(true, context.isOwner(Thread.currentThread())); + Assert.assertEquals(lockCount, context.getLockCount()); + Assert.assertEquals(true, context.isCurrent()); // still current + + context.release(); // recursive: lock -1 + + Assert.assertEquals(true, context.isOwner(Thread.currentThread())); + Assert.assertEquals(lockCount-1, context.getLockCount()); + Assert.assertEquals(true, context.isCurrent()); // still current + } + + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } + + public void init(final GLAutoDrawable drawable) { } + + public void dispose(final GLAutoDrawable drawable) { } + + public void display(final GLAutoDrawable drawable) { + final GLContextImpl context = (GLContextImpl)drawable.getContext(); + makeCurrentRecursive(context, 1); + releaseRecursive(context, 2); + } + }); + window.addGLEventListener(new GearsES2()); + + try { + window.setVisible(true); + window.display(); + } finally { + animator.stop(); + window.destroy(); + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestBug669RecursiveGLContext01NEWT.class.getName()); + } + +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext02NEWT.java new file mode 100644 index 000000000..104355a18 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug669RecursiveGLContext02NEWT.java @@ -0,0 +1,132 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.acore; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Tests recursive GLContext behavior. + * + *

    + * Issues {@link GLAutoDrawable#display()} of another {@link GLAutoDrawable} + * from within {@link GLEventListener#display(GLAutoDrawable)}. + *

    + * + * + */ +public class TestBug669RecursiveGLContext02NEWT extends UITestCase { + + @Test(timeout=5000) + public void test01_Plain() { + test01Impl(false); + } + + @Test(timeout=5000) + public void test01_Anim() { + test01Impl(true); + } + + private void test01Impl(boolean anim) { + final String profile = GLProfile.GL2ES2; + if(!GLProfile.isAvailable(profile)) { System.err.println(profile+" n/a"); return; } + + final GLProfile pro = GLProfile.get(profile); + final GLCapabilities caps = new GLCapabilities(pro); + + final GLWindow window2 = GLWindow.create(caps); // display() triggered by window's GLEventListener! + window2.setPosition(0, 0); + window2.setSize(200, 200); + window2.addGLEventListener(new RedSquareES2()); + + final GLWindow window1 = GLWindow.create(caps); + + final Animator animator1 = new Animator(); + final Animator animator2 = new Animator(); + if(anim) { + animator1.add(window1); + animator2.add(window2); + } + animator1.start(); + animator2.start(); + + window1.setPosition(250, 0); + window1.setSize(200, 200); + window1.addGLEventListener(new GLEventListener() { + public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } + + public void init(final GLAutoDrawable drawable) { } + + public void dispose(final GLAutoDrawable drawable) { } + + public void display(final GLAutoDrawable drawable) { + window2.display(); + } + }); + window1.addGLEventListener(new GearsES2()); + + try { + window2.setVisible(true); + window1.setVisible(true); + window1.display(); + window2.display(); + if(anim) { + try { + Thread.sleep(500); + } catch(InterruptedException ie) {} + } + } finally { + animator1.stop(); + + final int win1Frames = window1.getTotalFPSFrames(); + final int win2Frames = window2.getTotalFPSFrames(); + System.err.println("Window1: frames "+win1Frames); + System.err.println("Window2: frames "+win2Frames); + Assert.assertTrue("Win2 frames not double the amount of Win1 frames", 2*win2Frames >= win1Frames); + window1.destroy(); + window2.destroy(); + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestBug669RecursiveGLContext02NEWT.class.getName()); + } + +} + -- cgit v1.2.3 From 50f997557b91a2f014ef0c2ea848c5c326d0cfb2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 19 Jan 2013 07:04:56 +0100 Subject: NEWT/Android: Full Lifecycle for WindowDriver; Using static ViewGroup; AWTRobotUtil: More tolerant for non AWT env.; Fix adb-launch-* - NEWT/Android WindowDriver - Full Lifecycle, remove refs on closeNative() - Respect isFullscreen() - Using static ViewGroup if available and surface not ready, allows running from main() - AWTRobotUtil: More tolerant for non AWT env. - Check for NEWT first - Only use AWT iff available, which allows running on Android - Fix adb-launch-* - Launch main/junit tests --- make/scripts/adb-launch-junit.sh | 82 +++++++ make/scripts/adb-launch-main.sh | 66 +++--- make/scripts/tests.sh | 4 +- src/newt/classes/jogamp/newt/WindowImpl.java | 7 +- .../jogamp/newt/driver/android/WindowDriver.java | 177 +++++++++++---- .../test/android/NEWTGearsES2ActivityLauncher.java | 6 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 1 - .../opengl/test/junit/util/AWTRobotUtil.java | 239 ++++++++++----------- 8 files changed, 367 insertions(+), 215 deletions(-) create mode 100644 make/scripts/adb-launch-junit.sh (limited to 'make/scripts') diff --git a/make/scripts/adb-launch-junit.sh b/make/scripts/adb-launch-junit.sh new file mode 100644 index 000000000..e53e76456 --- /dev/null +++ b/make/scripts/adb-launch-junit.sh @@ -0,0 +1,82 @@ +#! /bin/bash + +export HOST_UID=jogamp +# jogamp02 - 10.1.0.122 +export HOST_IP=10.1.0.122 +#export HOST_IP=10.1.0.52 +export HOST_RSYNC_ROOT=PROJECTS/JOGL + +export TARGET_UID=jogamp +#export TARGET_IP=panda02 +export TARGET_IP=jautab03 +export TARGET_ADB_PORT=5555 +export TARGET_ROOT=jogamp-test + +export BUILD_DIR=../build-android-armv6 + +if [ -e /opt-linux-x86/android-sdk-linux_x86 ] ; then + export ANDROID_HOME=/opt-linux-x86/android-sdk-linux_x86 + export PATH=$ANDROID_HOME/platform-tools:$PATH +fi + +#TSTCLASS=jogamp.android.launcher.LauncherUtil +#TSTCLASS=com.jogamp.opengl.test.android.LauncherUtil +#TSTCLASS=com.jogamp.android.launcher.NEWTLauncherMain +#TSTCLASS=com.jogamp.nativewindow.NativeWindowVersion +#TSTCLASS=com.jogamp.opengl.JoglVersion +#TSTCLASS=com.jogamp.newt.NewtVersion +#TSTCLASS=com.jogamp.newt.opengl.GLWindow +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState01NEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 +#TSTCLASS=com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 +#TSTCLASS=com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02 +#TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears.newt.TestGearsGL2ES1NEWT +TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT + +#D_FLAGS="\&newt.debug=all\&jogl.debug=all\&nativewindow.debug=all" +#D_FLAGS="\&newt.debug=all\&jogl.debug=all" +#D_FLAGS="\&newt.debug=all" + + +M_FLAGS="\&arg=$TSTCLASS\ +\&arg=filtertrace=true\ +\&arg=haltOnError=false\ +\&arg=haltOnFailure=false\ +\&arg=showoutput=true\ +\&arg=outputtoformatters=true\ +\&arg=logfailedtests=true\ +\&arg=logtestlistenerevents=true\ +\&arg=formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter\ +\&arg=formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,/sdcard/$TARGET_ROOT/$TSTCLASS.xml\ +" + +LOGFILE=`basename $0 .sh`.log + +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall jogamp.android.launcher +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.common +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jogamp-android-launcher.apk +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/gluegen-rt-android-armeabi.apk + +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall javax.media.opengl +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jar/jogl-all-android-armeabi.apk + +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.opengl.test +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jar/jogl-test-android.apk + +SHELL_CMD="\ +cd /sdcard ; \ +if [ -e $TARGET_ROOT ] ; then rm -r $TARGET_ROOT ; fi ; \ +mkdir $TARGET_ROOT ; cd $TARGET_ROOT ; \ +setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \ +am kill-all ; \ +am start -W -S -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android.launcher.MainLauncher -d launch://jogamp.org/org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner/?pkg=com.jogamp.opengl.test$D_FLAGS$M_FLAGS \ +" + +adb connect $TARGET_IP:$TARGET_ADB_PORT +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -c +adb -s $TARGET_IP:$TARGET_ADB_PORT shell $SHELL_CMD 2>&1 | tee $LOGFILE +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -d 2>&1 | tee -a $LOGFILE + diff --git a/make/scripts/adb-launch-main.sh b/make/scripts/adb-launch-main.sh index e40cfeb11..12dcab1e4 100644 --- a/make/scripts/adb-launch-main.sh +++ b/make/scripts/adb-launch-main.sh @@ -2,15 +2,15 @@ export HOST_UID=jogamp # jogamp02 - 10.1.0.122 -#export HOST_IP=10.1.0.122 -export HOST_IP=10.1.0.52 +export HOST_IP=10.1.0.122 +#export HOST_IP=10.1.0.52 export HOST_RSYNC_ROOT=PROJECTS/JOGL export TARGET_UID=jogamp #export TARGET_IP=panda02 -export TARGET_IP=jautab01 +export TARGET_IP=jautab03 export TARGET_ADB_PORT=5555 -export TARGET_ROOT=/data/projects +export TARGET_ROOT=jogamp-test export BUILD_DIR=../build-android-armv6 @@ -36,42 +36,38 @@ fi #TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.gl2es1.gears.newt.TestGearsGL2ES1NEWT TSTCLASS=com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT +#D_FLAGS="\&newt.debug=all\&jogl.debug=all\&nativewindow.debug=all" +#D_FLAGS="\&newt.debug=all\&jogl.debug=all" +D_FLAGS="\&newt.debug=all" + +#Screen: 1280 x 752 +#M_FLAGS="\&arg=-time\&arg=100000\&arg=-width\&arg=1280\&arg=-height\&arg=752" +M_FLAGS="\&arg=-time\&arg=100000\&arg=-fullscreen" + LOGFILE=`basename $0 .sh`.log -RSYNC_EXCLUDES="--delete-excluded \ - --exclude 'build-x86*/' --exclude 'build-linux*/' --exclude 'build-win*/' --exclude 'build-mac*/' \ - --exclude 'classes/' --exclude 'src/' --exclude '.git/' --exclude '*-java-src.zip' \ - --exclude 'gensrc/' --exclude 'doc/' --exclude 'jnlp-files' --exclude 'archive/' \ - --exclude 'android-sdk/' --exclude 'resources/' --exclude 'scripts/' \ - --exclude 'stub_includes/' --exclude 'nbproject/' --exclude '*.log' --exclude '*.zip' --exclude '*.7z' \ - --exclude 'make/lib/external/'" +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall jogamp.android.launcher +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.common +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jogamp-android-launcher.apk +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/gluegen-rt-android-armeabi.apk -echo "#! /system/bin/sh" > $BUILD_DIR/jogl-targetcommand.sh +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall javax.media.opengl +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jar/jogl-all-android-armeabi.apk -echo "\ -rsync -av --delete --delete-after $RSYNC_EXCLUDES \ - $HOST_UID@$HOST_IP::$HOST_RSYNC_ROOT/gluegen \ - $HOST_UID@$HOST_IP::$HOST_RSYNC_ROOT/jogl \ - $TARGET_ROOT ; \ -cd $TARGET_ROOT/jogl/make ; -export LD_LIBRARY_PATH=/system/lib:$TARGET_ROOT/gluegen/make/$BUILD_DIR/obj:$TARGET_ROOT/jogl/make/$BUILD_DIR/lib ; \ -# export BOOTCLASSPATH=/system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar ; -setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \ -am start -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android.launcher.MainLauncher -d launch://jogamp.org/$TSTCLASS/?pkg=com.jogamp.opengl.test\&newt.debug=all\&jogl.debug=all\&nativewindow.debug=all \ -# \ -#dalvikvm \ -# -Xjnigreflimit:2000 \ -# -cp ../../gluegen/make/$BUILD_DIR/jogamp.android-launcher.apk:../../gluegen/make/lib/ant-junit-all.apk:../../gluegen/make/$BUILD_DIR/gluegen-rt-android-armeabi.apk:$BUILD_DIR/jar/jogl.all-android-armeabi.apk:$BUILD_DIR/jar/jogl.test.apk \ -# -Dgluegen.root=../../gluegen \ -# -Drootrel.build=build-android-armv6 \ -# com.android.internal.util.WithFramework \ -# $TSTCLASS \ -" >> $BUILD_DIR/jogl-targetcommand.sh +#adb -s $TARGET_IP:$TARGET_ADB_PORT uninstall com.jogamp.opengl.test +#adb -s $TARGET_IP:$TARGET_ADB_PORT install $BUILD_DIR/jar/jogl-test-android.apk +SHELL_CMD="\ +cd /sdcard ; \ +if [ -e $TARGET_ROOT ] ; then rm -r $TARGET_ROOT ; fi ; \ +mkdir $TARGET_ROOT ; cd $TARGET_ROOT ; \ +setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \ +am kill-all ; \ +am start -W -S -a android.intent.action.MAIN -n jogamp.android.launcher/jogamp.android.launcher.MainLauncher -d launch://jogamp.org/$TSTCLASS/?pkg=com.jogamp.opengl.test$D_FLAGS$M_FLAGS \ +" -chmod ugo+x $BUILD_DIR/jogl-targetcommand.sh adb connect $TARGET_IP:$TARGET_ADB_PORT -adb -s $TARGET_IP:$TARGET_ADB_PORT push $BUILD_DIR/jogl-targetcommand.sh $TARGET_ROOT/jogl-targetcommand.sh -adb -s $TARGET_IP:$TARGET_ADB_PORT shell su -c $TARGET_ROOT/jogl-targetcommand.sh 2>&1 | tee $LOGFILE - +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -c +adb -s $TARGET_IP:$TARGET_ADB_PORT shell $SHELL_CMD 2>&1 | tee $LOGFILE +adb -s $TARGET_IP:$TARGET_ADB_PORT logcat -d 2>&1 | tee -a $LOGFILE diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 46e6c63a9..a2cca3211 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -279,7 +279,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* @@ -295,7 +295,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02 #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 3c93de5b3..89c3bada6 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -278,12 +278,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer boolean postParentlockFocus = false; try { if(validateParentWindowHandle()) { - if(screenReferenceAdded) { - throw new InternalError("XXX"); - } - if(canCreateNativeImpl()) { + if( !screenReferenceAdded ) { screen.addReference(); screenReferenceAdded = true; + } + if(canCreateNativeImpl()) { createNativeImpl(); screen.addScreenModeListener(screenModeListenerImpl); setTitleImpl(title); diff --git a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java index 281bd9e0f..ba5d09759 100644 --- a/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/WindowDriver.java @@ -29,6 +29,7 @@ package jogamp.newt.driver.android; import jogamp.common.os.android.StaticContext; +import jogamp.newt.WindowImpl; import jogamp.newt.driver.android.event.AndroidNewtEventTranslator; import javax.media.nativewindow.Capabilities; @@ -43,6 +44,8 @@ import javax.media.opengl.GLException; import com.jogamp.common.os.AndroidVersion; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.newt.Screen; +import com.jogamp.newt.ScreenMode; import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLGraphicsConfiguration; @@ -52,11 +55,14 @@ import android.content.Context; import android.graphics.PixelFormat; import android.os.Bundle; import android.os.IBinder; +import android.os.Looper; import android.os.ResultReceiver; import android.util.Log; +import android.view.Gravity; import android.view.Surface; import android.view.SurfaceHolder; import android.view.SurfaceHolder.Callback2; +import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.view.SurfaceView; @@ -65,7 +71,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { DisplayDriver.initSingleton(); } - public static CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { + public static final CapabilitiesImmutable fixCaps(boolean matchFormatPrecise, int format, CapabilitiesImmutable rCaps) { PixelFormat pf = new PixelFormat(); PixelFormat.getPixelFormatInfo(format, pf); final CapabilitiesImmutable res; @@ -104,7 +110,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return res; } - public static int getFormat(CapabilitiesImmutable rCaps) { + public static final int getFormat(CapabilitiesImmutable rCaps) { int fmt = PixelFormat.UNKNOWN; if(!rCaps.isBackgroundOpaque()) { @@ -130,7 +136,7 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { return fmt; } - public static boolean isAndroidFormatTransparent(int aFormat) { + public static final boolean isAndroidFormatTransparent(int aFormat) { switch (aFormat) { case PixelFormat.TRANSLUCENT: case PixelFormat.TRANSPARENT: @@ -147,8 +153,8 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { reset(); } - private void reset() { - ownAndroidWindow = false; + private final void reset() { + added2StaticViewGroup = false; androidView = null; nativeFormat = VisualIDHolder.VID_UNDEFINED; androidFormat = VisualIDHolder.VID_UNDEFINED; @@ -157,10 +163,12 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { surfaceHandle = 0; eglSurface = 0; definePosition(0, 0); // default to 0/0 + defineSize(0, 0); // default size -> TBD ! + setBrokenFocusChange(true); } - private void setupInputListener(boolean enable) { + private final void setupInputListener(final boolean enable) { Log.d(MD.TAG, "setupInputListener(enable "+enable+") - "+Thread.currentThread().getName()); final AndroidNewtEventTranslator eventTranslator = @@ -169,51 +177,104 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { androidView.setOnKeyListener(eventTranslator); androidView.setOnFocusChangeListener(eventTranslator); if(AndroidVersion.SDK_INT >= 12) { // API Level 12 - Log.d(MD.TAG, "instantiationFinished() - enable GenericMotionListener - "+Thread.currentThread().getName()); + Log.d(MD.TAG, "setupInputListener - enable GenericMotionListener - "+Thread.currentThread().getName()); androidView.setOnGenericMotionListener(eventTranslator); } - androidView.setClickable(false); - androidView.setFocusable(enable); - androidView.setFocusableInTouchMode(enable); + if( enable ) { + androidView.post(new Runnable() { + public void run() { + androidView.setClickable(false); + androidView.setFocusable(true); + androidView.setFocusableInTouchMode(true); + } } ); + } } + private final void setupAndroidView(Context ctx) { + androidView = new MSurfaceView(ctx); + + final SurfaceHolder sh = androidView.getHolder(); + sh.addCallback(WindowDriver.this); + sh.setFormat(getFormat(getRequestedCapabilities())); + } + private final void removeAndroidView() { + final SurfaceHolder sh = androidView.getHolder(); + sh.removeCallback(WindowDriver.this); + androidView = null; + } + + public final SurfaceView getAndroidView() { return androidView; } + @Override - protected void instantiationFinished() { + protected final void instantiationFinished() { Log.d(MD.TAG, "instantiationFinished() - "+Thread.currentThread().getName()); - + final Context ctx = StaticContext.getContext(); if(null == ctx) { throw new NativeWindowException("No static [Application] Context has been set. Call StaticContext.setContext(Context) first."); } - androidView = new MSurfaceView(ctx); - - final SurfaceHolder sh = androidView.getHolder(); - sh.addCallback(WindowDriver.this); - sh.setFormat(getFormat(getRequestedCapabilities())); - // default size -> TBD ! - defineSize(0, 0); + if( null != Looper.myLooper() ) { + setupAndroidView(ctx); + } } - public final SurfaceView getAndroidView() { return androidView; } - @Override - protected boolean canCreateNativeImpl() { - final boolean b = 0 != surfaceHandle; - Log.d(MD.TAG, "canCreateNativeImpl: "+b); + protected final boolean canCreateNativeImpl() { + Log.d(MD.TAG, "canCreateNativeImpl.0: surfaceHandle ready "+(0!=surfaceHandle)+" - on thread "+Thread.currentThread().getName()); + if(WindowImpl.DEBUG_IMPLEMENTATION) { + Thread.dumpStack(); + } + + if( isFullscreen() ) { + final Screen screen = getScreen(); + final ScreenMode sm = screen.getCurrentScreenMode(); + definePosition(screen.getX(), screen.getY()); + defineSize(sm.getRotatedWidth(), sm.getRotatedHeight()); + } + + final boolean b; + + if( 0 == surfaceHandle ) { + // Static ViewGroup, i.e. self contained main code + final ViewGroup viewGroup = StaticContext.getContentViewGroup(); + Log.d(MD.TAG, "canCreateNativeImpl: viewGroup "+viewGroup); + if( null != viewGroup && !added2StaticViewGroup ) { + added2StaticViewGroup = true; + viewGroup.post(new Runnable() { + public void run() { + if(null == androidView) { + setupAndroidView( StaticContext.getContext() ); + } + viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(getWidth(), getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); + Log.d(MD.TAG, "canCreateNativeImpl: added to static ViewGroup - on thread "+Thread.currentThread().getName()); + } }); + for(long sleep = TIMEOUT_NATIVEWINDOW; 0 "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)); + public final void surfaceChanged(SurfaceHolder aHolder, int aFormat, int aWidth, int aHeight) { + Log.d(MD.TAG, "surfaceChanged: f "+nativeFormat+" -> "+aFormat+", "+aWidth+"x"+aHeight+", current surfaceHandle: 0x"+Long.toHexString(surfaceHandle)+" - on thread "+Thread.currentThread().getName()); + if(WindowImpl.DEBUG_IMPLEMENTATION) { + Thread.dumpStack(); + } if(0!=surfaceHandle && androidFormat != aFormat ) { // re-create Log.d(MD.TAG, "surfaceChanged (destroy old)"); @@ -437,18 +525,21 @@ public class WindowDriver extends jogamp.newt.WindowImpl implements Callback2 { } @Override - public void surfaceDestroyed(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceDestroyed"); + public final void surfaceDestroyed(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceDestroyed - on thread "+Thread.currentThread().getName()); + if(WindowImpl.DEBUG_IMPLEMENTATION) { + Thread.dumpStack(); + } windowDestroyNotify(true); // actually too late .. however .. } @Override - public void surfaceRedrawNeeded(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceRedrawNeeded"); + public final void surfaceRedrawNeeded(SurfaceHolder holder) { + Log.d(MD.TAG, "surfaceRedrawNeeded - on thread "+Thread.currentThread().getName()); windowRepaint(0, 0, getWidth(), getHeight()); } - private boolean ownAndroidWindow; + private boolean added2StaticViewGroup; private MSurfaceView androidView; private int nativeFormat; // chosen current native PixelFormat (suitable for EGL) private int androidFormat; // chosen current android PixelFormat (-1, -2 ..) diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java index 415efc7f2..7138ba805 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java @@ -49,7 +49,7 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); // props.setProperty("jogl.debug", "all"); // properties.setProperty("jogl.debug.GLProfile", "true"); - props.setProperty("jogl.debug.GLDrawable", "true"); + // props.setProperty("jogl.debug.GLDrawable", "true"); props.setProperty("jogl.debug.GLContext", "true"); props.setProperty("jogl.debug.GLSLCode", "true"); // props.setProperty("jogl.debug.CapabilitiesChooser", "true"); @@ -57,8 +57,8 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc // props.setProperty("jogl.debug.DebugGL", "true"); // props.setProperty("jogl.debug.TraceGL", "true"); // props.setProperty("newt.debug", "all"); - // props.setProperty("newt.debug.Window", "true"); - // props.setProperty("newt.debug.Window.MouseEvent", "true"); + props.setProperty("newt.debug.Window", "true"); + props.setProperty("newt.debug.Window.MouseEvent", "true"); props.setProperty("newt.debug.Window.KeyEvent", "true"); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 43a393495..74377a5f8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -25,7 +25,6 @@ import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; -import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 45648bedf..ffc42e318 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -32,13 +32,10 @@ import jogamp.newt.WindowImplAccess; import java.lang.reflect.InvocationTargetException; import java.awt.AWTException; -import java.awt.Component; -import java.awt.EventQueue; -import java.awt.KeyboardFocusManager; import java.awt.Robot; -import java.awt.Toolkit; import javax.media.nativewindow.NativeWindow; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLDrawable; import javax.media.opengl.awt.GLCanvas; @@ -63,77 +60,69 @@ public class AWTRobotUtil { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { System.err.println("******** clearAWTFocus.0"); - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); }}); robot.delay(ROBOT_DELAY); System.err.println("******** clearAWTFocus.X"); } - public static java.awt.Point getCenterLocation(Object obj, boolean onTitleBarIfWindow) + public static int[] getCenterLocation(Object obj, boolean onTitleBarIfWindow) throws InterruptedException, InvocationTargetException { - Component comp = null; - com.jogamp.newt.Window win = null; - if(obj instanceof com.jogamp.newt.Window) { - win = (com.jogamp.newt.Window) obj; - } else if(obj instanceof Component) { - comp = (Component) obj; + return getCenterLocationNEWT((com.jogamp.newt.Window)obj, onTitleBarIfWindow); + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { + return getCenterLocationAWT((java.awt.Component)obj, onTitleBarIfWindow); } else { throw new RuntimeException("Neither AWT nor NEWT: "+obj); - } + } + } + private static int[] getCenterLocationNEWT(com.jogamp.newt.Window win, boolean onTitleBarIfWindow) + throws InterruptedException, InvocationTargetException { + javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); + if( onTitleBarIfWindow ) { + javax.media.nativewindow.util.InsetsImmutable insets = win.getInsets(); + p0.translate(win.getWidth()/2, insets.getTopHeight()/2); + } else { + p0.translate(win.getWidth()/2, win.getHeight()/2); + } + return new int[] { p0.getX(), p0.getY() }; + } + private static int[] getCenterLocationAWT(java.awt.Component comp, boolean onTitleBarIfWindow) + throws InterruptedException, InvocationTargetException { int x0, y0; - if(null!=comp) { - java.awt.Point p0 = comp.getLocationOnScreen(); - java.awt.Rectangle r0 = comp.getBounds(); - if( onTitleBarIfWindow && comp instanceof java.awt.Window) { - java.awt.Window window = (java.awt.Window) comp; - java.awt.Insets insets = window.getInsets(); - y0 = (int) ( p0.getY() + insets.top / 2.0 + .5 ) ; - } else { - y0 = (int) ( p0.getY() + r0.getHeight() / 2.0 + .5 ) ; - } - x0 = (int) ( p0.getX() + r0.getWidth() / 2.0 + .5 ) ; + java.awt.Point p0 = comp.getLocationOnScreen(); + java.awt.Rectangle r0 = comp.getBounds(); + if( onTitleBarIfWindow && comp instanceof java.awt.Window) { + java.awt.Window window = (java.awt.Window) comp; + java.awt.Insets insets = window.getInsets(); + y0 = (int) ( p0.getY() + insets.top / 2.0 + .5 ) ; } else { - javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); - if( onTitleBarIfWindow ) { - javax.media.nativewindow.util.InsetsImmutable insets = win.getInsets(); - p0.translate(win.getWidth()/2, insets.getTopHeight()/2); - } else { - p0.translate(win.getWidth()/2, win.getHeight()/2); - } - x0 = p0.getX(); - y0 = p0.getY(); + y0 = (int) ( p0.getY() + r0.getHeight() / 2.0 + .5 ) ; } - - return new java.awt.Point(x0, y0); + x0 = (int) ( p0.getX() + r0.getWidth() / 2.0 + .5 ) ; + return new int[] { x0, y0 }; } - public static java.awt.Point getClientLocation(Object obj, int x, int y) + public static int[] getClientLocation(Object obj, int x, int y) throws InterruptedException, InvocationTargetException { - Component comp = null; - com.jogamp.newt.Window win = null; - if(obj instanceof com.jogamp.newt.Window) { - win = (com.jogamp.newt.Window) obj; - } else if(obj instanceof Component) { - comp = (Component) obj; + return getClientLocationNEWT((com.jogamp.newt.Window)obj, x, y); + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { + return getClientLocationAWT((java.awt.Component)obj, x, y); } else { throw new RuntimeException("Neither AWT nor NEWT: "+obj); - } - - int x0, y0; - if(null!=comp) { - java.awt.Point p0 = comp.getLocationOnScreen(); - x0 = (int) p0.getX() + x; - y0 = (int) p0.getY() + y; - } else { - javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); - x0 = p0.getX() + x; - y0 = p0.getY() + y; - } - - return new java.awt.Point(x0, y0); + } + } + private static int[] getClientLocationNEWT(com.jogamp.newt.Window win, int x, int y) + throws InterruptedException, InvocationTargetException { + javax.media.nativewindow.util.Point p0 = win.getLocationOnScreen(null); + return new int[] { p0.getX(), p0.getY() }; + } + private static int[] getClientLocationAWT(java.awt.Component comp, int x, int y) + throws InterruptedException, InvocationTargetException { + java.awt.Point p0 = comp.getLocationOnScreen(); + return new int[] { (int)p0.getX(), (int)p0.getY() }; } /** @@ -154,9 +143,9 @@ public class AWTRobotUtil { robot = new Robot(); robot.setAutoWaitForIdle(true); } - java.awt.Point p0 = getCenterLocation(window, false); - System.err.println("toFront: robot pos: "+p0); - robot.mouseMove( (int) p0.getX(), (int) p0.getY() ); + int[] p0 = getCenterLocation(window, false); + System.err.println("toFront: robot pos: "+p0[0]+"x"+p0[1]); + robot.mouseMove( p0[0], p0[1] ); robot.delay(ROBOT_DELAY); int wait=0; @@ -197,10 +186,10 @@ public class AWTRobotUtil { robot.setAutoWaitForIdle(true); } - java.awt.Point p0 = getCenterLocation(obj, onTitleBarIfWindow); - System.err.println("centerMouse: robot pos: "+p0+", onTitleBarIfWindow: "+onTitleBarIfWindow); + int[] p0 = getCenterLocation(obj, onTitleBarIfWindow); + System.err.println("centerMouse: robot pos: "+p0[0]+"x"+p0[1]+", onTitleBarIfWindow: "+onTitleBarIfWindow); - robot.mouseMove( (int) p0.getX(), (int) p0.getY() ); + robot.mouseMove( p0[0], p0[1] ); robot.delay(ROBOT_DELAY); } @@ -212,19 +201,19 @@ public class AWTRobotUtil { robot.setAutoWaitForIdle(true); } - java.awt.Point p0 = getClientLocation(obj, x, y); + int[] p0 = getClientLocation(obj, x, y); - robot.mouseMove( (int) p0.getX(), (int) p0.getY() ); + robot.mouseMove( p0[0], p0[1] ); robot.delay(ROBOT_DELAY); } public static int getClickTimeout(Object obj) { if(obj instanceof com.jogamp.newt.Window) { return com.jogamp.newt.event.MouseEvent.getClickTimeout(); - } else if(obj instanceof Component) { + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { if(null == AWT_CLICK_TO) { AWT_CLICK_TO = - (Integer) Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval"); + (Integer) java.awt.Toolkit.getDefaultToolkit().getDesktopProperty("awt.multiClickInterval"); if(null == AWT_CLICK_TO) { AWT_CLICK_TO = new Integer(500); } @@ -250,32 +239,7 @@ public class AWTRobotUtil { */ public static void requestFocus(Robot robot, Object obj, boolean onTitleBarIfWindow) throws AWTException, InterruptedException, InvocationTargetException { - - final Component comp; - final com.jogamp.newt.Window win; - - if(obj instanceof com.jogamp.newt.Window) { - win = (com.jogamp.newt.Window) obj; - comp = null; - } else if(obj instanceof Component) { - win = null; - comp = (Component) obj; - } else { - throw new RuntimeException("Neither AWT nor NEWT: "+obj); - } - - if(null == robot) { - if(null!=comp) { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - comp.requestFocus(); - System.err.println("requestFocus: AWT Component"); - }}); - } else { - win.requestFocus(); - System.err.println("requestFocus: NEWT Component"); - } - } else { + if(null != robot) { final int mouseButton = java.awt.event.InputEvent.BUTTON1_MASK; centerMouse(robot, obj, onTitleBarIfWindow); @@ -284,9 +248,30 @@ public class AWTRobotUtil { robot.mouseRelease(mouseButton); final int d = getClickTimeout(obj) + 1; robot.delay( d ); - System.err.println("requestFocus: click, d: "+d+" ms"); + System.err.println("requestFocus: click, d: "+d+" ms"); + } else { + if(obj instanceof com.jogamp.newt.Window) { + requestFocusNEWT((com.jogamp.newt.Window) obj, onTitleBarIfWindow); + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { + requestFocusAWT((java.awt.Component) obj, onTitleBarIfWindow); + } else { + throw new RuntimeException("Neither AWT nor NEWT: "+obj); + } } } + private static void requestFocusNEWT(com.jogamp.newt.Window win, boolean onTitleBarIfWindow) + throws AWTException, InterruptedException, InvocationTargetException { + win.requestFocus(); + System.err.println("requestFocus: NEWT Component"); + } + private static void requestFocusAWT(final java.awt.Component comp, boolean onTitleBarIfWindow) + throws AWTException, InterruptedException, InvocationTargetException { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + comp.requestFocus(); + System.err.println("requestFocus: AWT Component"); + }}); + } public static void requestFocus(Robot robot, Object obj, int x, int y) throws AWTException, InterruptedException, InvocationTargetException { @@ -306,12 +291,12 @@ public class AWTRobotUtil { } public static boolean hasFocus(Object obj) { - if(obj instanceof Component) { - final Component comp = (Component) obj; - final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - return comp == kfm.getPermanentFocusOwner(); - } else if(obj instanceof com.jogamp.newt.Window) { + if(obj instanceof com.jogamp.newt.Window) { return ((com.jogamp.newt.Window) obj).hasFocus(); + } else if(NativeWindowFactory.isAWTAvailable() && obj instanceof java.awt.Component) { + final java.awt.Component comp = (java.awt.Component) obj; + final java.awt.KeyboardFocusManager kfm = java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager(); + return comp == kfm.getPermanentFocusOwner(); } else { throw new RuntimeException("Neither AWT nor NEWT: "+obj); } @@ -323,17 +308,17 @@ public class AWTRobotUtil { */ public static boolean waitForFocus(Object obj) throws InterruptedException { int wait; - if(obj instanceof Component) { - final Component comp = (Component) obj; - final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - for (wait=0; wait Date: Sat, 19 Jan 2013 09:20:10 +0100 Subject: Adapt to change 5060b728b26a89a14367f8fca9f4eb7968f719ca: ShaderState.uniform(..) returns false if no location available. --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a2cca3211..8f8d67c13 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -295,7 +295,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -492,7 +492,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $* -#testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* +testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 $* diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java index 3c23733a5..fcccf592e 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java @@ -139,8 +139,10 @@ public abstract class Renderer { throw new GLException("Error setting PMVMatrix in shader: "+rs.getShaderState()); } - if(!rs.getShaderState().uniform(gl, rs.getWeight())) { - throw new GLException("Error setting weight in shader: "+rs.getShaderState()); + if( Region.isNonUniformWeight( getRenderModes() ) ) { + if(!rs.getShaderState().uniform(gl, rs.getWeight())) { + throw new GLException("Error setting weight in shader: "+rs.getShaderState()); + } } if(!rs.getShaderState().uniform(gl, rs.getAlpha())) { @@ -181,7 +183,7 @@ public abstract class Renderer { throw new IllegalArgumentException("Weight out of range"); } rs.getWeight().setData(v); - if(null != gl && rs.getShaderState().inUse()) { + if(null != gl && rs.getShaderState().inUse() && Region.isNonUniformWeight( getRenderModes() ) ) { rs.getShaderState().uniform(gl, rs.getWeight()); } } -- cgit v1.2.3 From c27f0b37024b8a991512ad8d0856821804bb3692 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 19 Jan 2013 20:05:48 +0100 Subject: TestSwingAWTRobotUsageBeforeJOGLInitBug411: Fix 'chicken egg' init problem w/ AWTRobot, i.e. NativeWindow not yet initialized. Regression since: 50f997557b91a2f014ef0c2ea848c5c326d0cfb2 --- make/scripts/tests.sh | 4 ++-- .../newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8f8d67c13..80e418056 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -399,7 +399,7 @@ function testawtswt() { # # newt.awt (testawt) # -#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* +testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* @@ -492,7 +492,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $* -testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* +#testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java b/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java index b165a9693..0e9b6cd88 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/newt/TestSwingAWTRobotUsageBeforeJOGLInitBug411.java @@ -33,6 +33,8 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.*; import java.lang.reflect.InvocationTargetException; + +import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLCapabilities; @@ -157,7 +159,16 @@ public class TestSwingAWTRobotUsageBeforeJOGLInitBug411 extends UITestCase { robot = new Robot(); robot.setAutoWaitForIdle(true); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + // NativeWindow/JOGL is not initialized yet .. + for (int wait=0; wait Date: Thu, 24 Jan 2013 17:24:22 +0100 Subject: Bug 665 (part 1) - Allow dis-association of GLContext's GLDrawable .. Changes allowing re-association (incl. null) of GLContext/GLDrawable: - GLAutoDrawable: Refine API doc 'setContext(..)' - GLContext: Refine API doc: 'setGLDrawable(..)' 'getGLDrawable()' - GLContextImpl.setGLDrawable(): Handle null drawable - GLAutoDrawableDelegate/GLAutoDrawableBase: Allow null GLContext - GLDrawableHelper.switchContext(..)/recreateGLDrawable(): Balance GLContext.setGLDrawable(..) calls - New GLEventListenerState, holding state vector [GLEventListener, GLContext, .. ] impl. relocation of all components from/to GLAutoDrawable. - GLDrawableUtil - Using GLEventListenerState for swapGLContextAndAllGLEventListener(..) +++ NEWT Window*: - getDisplayHandle() is 'final', no more 'shortcut' code allowed due to re-association incl. display handle. - close*: - close config's device (was missing) - null config +++ Changes allowing reconfig of Display handle as required to re-associate pre-existing GLContext to a 'window': - AbstractGraphicsDevice: Add isHandleOwner() / clearHandleOwner() - Impl. in X11GraphicsDevice and EGLGraphicsDevice, NOP in DefaultGraphicsDevice - DefaultGraphicsConfiguration add 'setScreen(..)' - MutableGraphicsConfiguration - Make DefaultGraphicsConfiguration.setScreen(..) public - NativeWindowFactory add 'createScreen(String type, AbstractGraphicsDevice device, int screen)' - Refactored from SWTAccessor - NativeWindow x11ErrorHandler: Dump Stack Trace in DEBUG mode, always. --- make/scripts/tests-x64.bat | 3 +- make/scripts/tests.sh | 10 +- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 8 +- .../com/jogamp/opengl/util/GLDrawableUtil.java | 116 +------ .../classes/javax/media/opengl/GLAutoDrawable.java | 32 +- src/jogl/classes/javax/media/opengl/GLContext.java | 23 +- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 13 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 24 +- .../classes/jogamp/opengl/GLDrawableHelper.java | 31 +- .../jogamp/opengl/GLEventListenerState.java | 267 ++++++++++++++++ .../nativewindow/MutableGraphicsConfiguration.java | 7 + .../jogamp/nativewindow/egl/EGLGraphicsDevice.java | 11 +- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 19 +- .../jogamp/nativewindow/x11/X11GraphicsDevice.java | 12 +- .../AbstractGraphicsConfiguration.java | 3 +- .../media/nativewindow/AbstractGraphicsDevice.java | 12 +- .../media/nativewindow/AbstractGraphicsScreen.java | 2 + .../nativewindow/DefaultGraphicsConfiguration.java | 17 +- .../media/nativewindow/DefaultGraphicsDevice.java | 19 +- .../media/nativewindow/DefaultGraphicsScreen.java | 6 +- .../media/nativewindow/NativeWindowFactory.java | 27 ++ src/nativewindow/native/x11/Xmisc.c | 2 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 18 +- src/newt/classes/jogamp/newt/WindowImpl.java | 9 +- .../jogamp/newt/driver/x11/WindowDriver.java | 10 +- .../acore/TestGLContextDrawableSwitch01NEWT.java | 330 +++++++++++++++++++ .../acore/TestGLContextDrawableSwitch11NEWT.java | 352 +++++++++++++++++++++ .../acore/TestGLContextDrawableSwitchNEWT.java | 310 ------------------ .../test/junit/util/GLEventListenerCounter.java | 65 ++++ 29 files changed, 1222 insertions(+), 536 deletions(-) create mode 100644 src/jogl/classes/jogamp/opengl/GLEventListenerState.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch11NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitchNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/util/GLEventListenerCounter.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index b66f8b8ab..8bee4c6dd 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -12,7 +12,8 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 80e418056..9625519b9 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -89,6 +89,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" @@ -105,6 +106,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" @@ -284,7 +286,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitchNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* @@ -303,6 +306,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* + #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* @@ -399,7 +405,7 @@ function testawtswt() { # # newt.awt (testawt) # -testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* +#testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java index 38a8deef8..38315dc72 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -65,7 +65,10 @@ import jogamp.opengl.GLDrawableImpl; public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAutoDrawable { /** * @param drawable a valid and already realized {@link GLDrawable} - * @param context a valid {@link GLContext}, may not be made current (created) yet. + * @param context a valid {@link GLContext}, + * may not have been made current (created) yet, + * may not be associated w/ drawable yet, + * may be null for lazy initialization * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, * otherwise pass false. Closing the device is required in case @@ -78,9 +81,6 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto if(null == drawable) { throw new IllegalArgumentException("null drawable"); } - if(null == context) { - throw new IllegalArgumentException("null context"); - } if(!drawable.isRealized()) { throw new IllegalArgumentException("drawable not realized"); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java index cc81e4820..c03e4bfa4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -27,17 +27,14 @@ */ package com.jogamp.opengl.util; -import java.util.ArrayList; -import java.util.List; - import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLRunnable; import jogamp.opengl.Debug; +import jogamp.opengl.GLEventListenerState; /** * Providing utility functions dealing w/ {@link GLDrawable}s, {@link GLAutoDrawable} and their {@link GLEventListener}. @@ -83,7 +80,7 @@ public class GLDrawableUtil { dest.addGLEventListener(listener); if(preserveInitState && initialized) { dest.setGLEventListenerInitState(listener, true); - dest.invoke(false, new ReshapeGLEventListener(listener)); + dest.invoke(false, new GLEventListenerState.ReshapeGLEventListener(listener)); } // else .. !init state is default } @@ -121,108 +118,13 @@ public class GLDrawableUtil { * @param b */ public static final void swapGLContextAndAllGLEventListener(GLAutoDrawable a, GLAutoDrawable b) { - final List aGLCmds = new ArrayList(); - final List bGLCmds = new ArrayList(); - final GLAnimatorControl aAnim = a.getAnimator(); - final GLAnimatorControl bAnim = b.getAnimator(); - final boolean aIsPaused = isAnimatorAnimatingOnOtherThread(aAnim) && aAnim.pause(); - final boolean bIsPaused = isAnimatorAnimatingOnOtherThread(bAnim) && bAnim.pause(); - - // - // remove and cache all GLEventListener and their init-state - // - final int aSz = a.getGLEventListenerCount(); - final GLEventListener[] aGLE = new GLEventListener[aSz]; - final boolean[] aInit = new boolean[aSz]; - for(int i=0; idrawable might be an inner GLDrawable instance if using a delegation pattern, - * or this GLAutoDrawable instance. + * Associate the new context, newtCtx, to this auto-drawable. *

    - * If the old or new context was current on this thread, it is being released before switching the drawable. + * The current context will be dis-associated from this auto-drawable + * via {@link GLContext#setGLDrawable(GLDrawable, boolean) setGLDrawable(null, true);} first. + *

    + *

    + * The new context will be associated with this auto-drawable + * via {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. + *

    + *

    + * If the old or new context was current on this thread, it is being released before switching the association. * The new context will be made current afterwards, if it was current before. * However the user shall take extra care that no other thread * attempts to make this context current. *

    *

    - * Be aware that the old context is still bound to the drawable, - * and that one context can only be bound to one drawable at one time! - *

    - *

    * In case you do not intend to use the old context anymore, i.e. - * not assigning it to another drawable, it shall be - * destroyed before setting the new context, i.e.: + * not assigning it to another drawable, it shall be + * destroyed, i.e.: *

    -            GLContext oldCtx = glad.getContext();
    +            GLContext oldCtx = glad.setContext(newCtx);
                 if(null != oldCtx) {
                     oldCtx.destroy();
                 }
    -            glad.setContext(newCtx);            
        * 
    - * This is required, since a context must have a valid drawable at all times - * and this API shall not restrict the user in any way. *

    * - * @param newCtx the new context - * @return the replaced GLContext, maybe null + * @param newCtx the new context, maybe null for dis-association. + * @return the previous GLContext, maybe null * * @see GLContext#setGLDrawable(GLDrawable, boolean) * @see GLContext#setGLReadDrawable(GLDrawable) diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 455f2d70d..4817add4d 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -217,15 +217,20 @@ public abstract class GLContext { /** * Sets the read/write drawable for framebuffer operations. *

    + * If the arguments reflect the current state of this context + * this method is a no-operation and returns the old and current {@link GLDrawable}. + *

    + *

    * If the context was current on this thread, it is being released before switching the drawable * and made current afterwards. However the user shall take extra care that not other thread * attempts to make this context current. Otherwise a race condition may happen. *

    - * @param readWrite the read/write drawable for framebuffer operations. - * @param setWriteOnly if true and if the current read-drawable differs - * from the write-drawable ({@link #setGLReadDrawable(GLDrawable)}), - * only change the write-drawable. Otherwise set both drawables. - * @return the replaced read/write drawable + * @param readWrite The read/write drawable for framebuffer operations, maybe null to remove association. + * @param setWriteOnly Only change the write-drawable, if setWriteOnly is true and + * if the {@link #getGLReadDrawable() read-drawable} differs + * from the {@link #getGLDrawable() write-drawable}. + * Otherwise set both drawables, read and write. + * @return The previous read/write drawable * * @throws GLException in case null is being passed or * this context is made current on another thread. @@ -239,6 +244,12 @@ public abstract class GLContext { /** * Returns the write-drawable this context uses for framebuffer operations. + *

    + * If the read-drawable has not been changed manually via {@link #setGLReadDrawable(GLDrawable)}, + * it equals to the write-drawable (default). + *

    + * @see #setGLDrawable(GLDrawable, boolean) + * @see #setGLReadDrawable(GLDrawable) */ public abstract GLDrawable getGLDrawable(); @@ -259,7 +270,7 @@ public abstract class GLContext { * * @param read the read-drawable for read framebuffer operations. * If null is passed, the default write drawable will be set. - * @return the replaced read-drawable + * @return the previous read-drawable * * @throws GLException in case a read drawable is not supported or * this context is made current on another thread. diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index eadd59559..c20197e72 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -74,8 +74,12 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking /** - * @param drawable upstream {@link GLDrawableImpl} instance, may be null for lazy initialization - * @param context upstream {@link GLContextImpl} instance, may be null for lazy initialization + * @param drawable upstream {@link GLDrawableImpl} instance, + * may be null for lazy initialization + * @param context upstream {@link GLContextImpl} instance, + * may not have been made current (created) yet, + * may not be associated w/ drawable yet, + * may be null for lazy initialization * @param ownsDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, * otherwise pass false. Closing the device is required in case * the drawable is created w/ it's own new instance, e.g. offscreen drawables, @@ -85,6 +89,9 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { this.drawable = drawable; this.context = context; this.ownsDevice = ownsDevice; + if(null != context && null != drawable) { + context.setGLDrawable(drawable, false); + } resetFPSCounter(); } @@ -326,7 +333,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { final GLContext oldCtx = context; final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; - if(newCtxCurrent) { + if(newCtxCurrent) { // implies null != newCtx context.makeCurrent(); } return oldCtx; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index f2c2cfada..2a2b6a8fd 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -203,8 +203,8 @@ public abstract class GLContextImpl extends GLContext { @Override public final GLDrawable setGLDrawable(GLDrawable readWrite, boolean setWriteOnly) { - if(null==readWrite) { - throw new GLException("Null read/write drawable not allowed"); + if( drawable == readWrite && ( setWriteOnly || drawableRead == readWrite ) ) { + return drawable; // no change. } final boolean lockHeld = lock.isOwner(Thread.currentThread()); if(lockHeld) { @@ -212,16 +212,20 @@ public abstract class GLContextImpl extends GLContext { } else if(lock.isLockedByOtherThread()) { // still could glitch .. throw new GLException("GLContext current by other thread ("+lock.getOwner()+"), operation not allowed."); } - if(!setWriteOnly || drawableRead==drawable) { // if !setWriteOnly || !explicitReadDrawable + if( !setWriteOnly || drawableRead == drawable ) { // if !setWriteOnly || !explicitReadDrawable drawableRead = (GLDrawableImpl) readWrite; } final GLDrawableImpl old = drawable; - old.associateContext(this, false); - drawableRetargeted = null != drawable; + if( null != old ) { + old.associateContext(this, false); + } + drawableRetargeted |= null != drawable && readWrite != drawable; drawable = (GLDrawableImpl) readWrite ; - drawable.associateContext(this, true); - if(lockHeld) { - makeCurrent(); + if( null != drawable ) { + drawable.associateContext(this, true); + if( lockHeld ) { + makeCurrent(); + } } return old; } @@ -334,7 +338,7 @@ public abstract class GLContextImpl extends GLContext { ", surf "+toHexString(drawable.getHandle())+", isShared "+GLContextShareSet.isShared(this)+" - "+lock); } if (contextHandle != 0) { - int lockRes = drawable.lockSurface(); + final int lockRes = drawable.lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { // this would be odd .. throw new GLException("Surface not ready to lock: "+drawable); @@ -408,7 +412,7 @@ public abstract class GLContextImpl extends GLContext { throw new GLException("Destination OpenGL context has not been created"); } - int lockRes = drawable.lockSurface(); + final int lockRes = drawable.lockSurface(); if (NativeSurface.LOCK_SURFACE_NOT_READY == lockRes) { // this would be odd .. throw new GLException("Surface not ready to lock"); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index f8c58ee34..5d113ff83 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -131,30 +131,36 @@ public class GLDrawableHelper { } /** - * Associate a new context to the drawable and also propagates the context/drawable switch by - * calling {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. - *

    - * If the old or new context was current on this thread, it is being released before switching the drawable. + * Switch {@link GLContext} / {@link GLDrawable} association. + *

    + * Dis-associate oldCtx from drawable + * via {@link GLContext#setGLDrawable(GLDrawable, boolean) oldCtx.setGLDrawable(null, true);}. *

    *

    - * Be aware that the old context is still bound to the drawable, - * and that one context can only bound to one drawable at one time! + * Re-associate newCtx with drawable + * via {@link GLContext#setGLDrawable(GLDrawable, boolean) newCtx.setGLDrawable(drawable, true);}. + *

    + *

    + * If the old or new context was current on this thread, it is being released before switching the drawable. *

    *

    * No locking is being performed on the drawable, caller is required to take care of it. *

    * * @param drawable the drawable which context is changed - * @param oldCtx the old context - * @param newCtx the new context + * @param oldCtx the old context, maybe null. + * @param newCtx the new context, maybe null for dis-association. * @param newCtxCreationFlags additional creation flags if newCtx is not null and not been created yet, see {@link GLContext#setContextCreationFlags(int)} * @return true if the new context was current, otherwise false * * @see GLAutoDrawable#setContext(GLContext) */ public static final boolean switchContext(GLDrawable drawable, GLContext oldCtx, GLContext newCtx, int newCtxCreationFlags) { - if( null != oldCtx && oldCtx.isCurrent() ) { - oldCtx.release(); + if( null != oldCtx ) { + if( oldCtx.isCurrent() ) { + oldCtx.release(); + } + oldCtx.setGLDrawable(null, true); // dis-associate old pair } final boolean newCtxCurrent; if(null!=newCtx) { @@ -163,8 +169,8 @@ public class GLDrawableHelper { newCtx.release(); } newCtx.setContextCreationFlags(newCtxCreationFlags); - newCtx.setGLDrawable(drawable, true); // propagate context/drawable switch - } else { + newCtx.setGLDrawable(drawable, true); // re-associate new pair + } else { newCtxCurrent = false; } return newCtxCurrent; @@ -203,6 +209,7 @@ public class GLDrawableHelper { } context.getGL().glFinish(); context.release(); + context.setGLDrawable(null, true); // dis-associate } if(null != proxySurface) { diff --git a/src/jogl/classes/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/jogamp/opengl/GLEventListenerState.java new file mode 100644 index 000000000..dea2bc85b --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/GLEventListenerState.java @@ -0,0 +1,267 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.opengl; + +import java.util.ArrayList; +import java.util.List; + +import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.VisualIDHolder; +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLRunnable; + +import com.jogamp.nativewindow.MutableGraphicsConfiguration; + +/** + * GLEventListenerState is holding {@link GLAutoDrawable} components crucial + * to relocating all its {@link GLEventListener} w/ their operating {@link GLContext}, etc. + * The components are: + *
      + *
    • {@link AbstractGraphicsScreen}
    • + *
    • {@link GLCapabilitiesImmutable}
    • + *
    • {@link GLContext} operating all {@link GLEventListener}
    • + *
    • All {@link GLEventListener}
    • + *
    • All {@link GLEventListener}'s init state
    • + *
    • {@link GLAnimatorControl}
    • + *
    + *

    + * A GLEventListenerState instance can be created while components are {@link #moveFrom(GLAutoDrawable) moved from} a {@link GLAutoDrawable} + * to the new instance, which gains {@link #isOwner() ownership} of the moved components. + *

    + *

    + * A GLEventListenerState instance's components can be {@link #moveTo(GLAutoDrawable) moved to} a {@link GLAutoDrawable}, + * while loosing {@link #isOwner() ownership} of the moved components. + *

    + *

    + */ +public class GLEventListenerState { + private GLEventListenerState(AbstractGraphicsScreen screen, GLCapabilitiesImmutable caps, GLContext context, int count, GLAnimatorControl anim) { + this.screen = screen; + this.caps = caps; + this.context = context; + this.listeners = new GLEventListener[count]; + this.listenersInit = new boolean[count]; + this.anim = anim; + this.owner = true; + } + /** + * Returns true, if this instance is the current owner of the components, + * otherwise false. + *

    + * Ownership is lost if {@link #moveTo(GLAutoDrawable)} is being called successfully + * and all components are transferred to the new {@link GLAutoDrawable}. + *

    + */ + public final boolean isOwner() { return owner; } + + public final int listenerCount() { return listeners.length; } + + public final AbstractGraphicsScreen screen; + public final GLCapabilitiesImmutable caps; + public final GLContext context; + public final GLEventListener[] listeners; + public final boolean[] listenersInit; + public final GLAnimatorControl anim; + + private boolean owner; + + /** + * Last resort to destroy and loose ownership + */ + public void destroy() { + if( owner ) { + final int aSz = listenerCount(); + for(int i=0; i + * Note that all components are removed from the {@link GLAutoDrawable}, + * i.e. the {@link GLContext}, all {@link GLEventListener}. + *

    + *

    + * If the {@link GLAutoDrawable} was added to a {@link GLAnimatorControl}, it is removed + * and the {@link GLAnimatorControl} added to the GLEventListenerState. + *

    + *

    + * The returned GLEventListenerState instance is the {@link #isOwner() owner of the components}. + *

    + * + * @param a {@link GLAutoDrawable} source to move components from + * @return new GLEventListenerState instance {@link #isOwner() owning} moved components. + * + * @see #moveTo(GLAutoDrawable) + */ + public static GLEventListenerState moveFrom(GLAutoDrawable a) { + final int aSz = a.getGLEventListenerCount(); + + // Create new AbstractGraphicsScreen w/ cloned AbstractGraphicsDevice for future GLAutoDrawable + // allowing this AbstractGraphicsDevice to loose ownership -> not closing display/device! + final AbstractGraphicsConfiguration aCfg1 = a.getNativeSurface().getGraphicsConfiguration(); + final GLCapabilitiesImmutable caps1 = (GLCapabilitiesImmutable) aCfg1.getChosenCapabilities(); + final AbstractGraphicsScreen aScreen1 = aCfg1.getScreen(); + final AbstractGraphicsDevice aDevice1 = aScreen1.getDevice(); + final AbstractGraphicsDevice aDevice2 = (AbstractGraphicsDevice) aDevice1.clone(); + final AbstractGraphicsScreen aScreen2 = NativeWindowFactory.createScreen( NativeWindowFactory.getNativeWindowType(false), aDevice2, aScreen1.getIndex() ); + + final GLAnimatorControl aAnim = a.getAnimator(); + if( null != aAnim ) { + aAnim.remove(a); // also handles ECT + } + + final GLEventListenerState glls = new GLEventListenerState(aScreen2, caps1, a.getContext(), aSz, aAnim); + + // + // remove and cache all GLEventListener and their init-state + // + for(int i=0; i + * If the previous {@link GLAutoDrawable} was removed from a {@link GLAnimatorControl} by previous {@link #moveFrom(GLAutoDrawable)}, + * the given {@link GLAutoDrawable} is added to the cached {@link GLAnimatorControl}. + * This operation is skipped, if the given {@link GLAutoDrawable} is already added to a {@link GLAnimatorControl} instance. + *

    + *

    + * Note: After this operation, the GLEventListenerState reference should be released. + *

    + * + * @param a {@link GLAutoDrawable} destination to move GLEventListenerState components to + * + * @throws GLException if the {@link GLAutoDrawable}'s configuration is incompatible, i.e. different {@link GLCapabilitiesImmutable}. + * + * @see #moveFrom(GLAutoDrawable) + * @see #isOwner() + */ + public final void moveTo(GLAutoDrawable a) { + final List aGLCmds = new ArrayList(); + final int aSz = listenerCount(); + + final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) a.getNativeSurface().getGraphicsConfiguration(); + final GLCapabilitiesImmutable aCaps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); + if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) ) { + throw new GLException("XXX: Incompatible - Prev Holder: "+caps+", New Holder "+caps); + } + final GLContext prevContext = a.getContext(); + if( null != prevContext) { + prevContext.destroy(); + } + final AbstractGraphicsScreen preScreen = aCfg.getScreen(); + aCfg.setScreen( screen ); + preScreen.getDevice().close(); + a.setContext( context ); + owner = false; + + // + // Trigger GL-Viewport reset and reshape of all initialized GLEventListeners + // + aGLCmds.add(setViewport); + for(int i=0; i= 0 is specific screen * @return - * @throws UnsupportedOperationException */ - public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) throws UnsupportedOperationException { - if( isX11 ) { - X11GraphicsDevice x11Device = (X11GraphicsDevice)device; - if(0 > screen) { - screen = x11Device.getDefaultScreen(); - } - return new X11GraphicsScreen(x11Device, screen); - } - if(0 > screen) { - screen = 0; // FIXME: Needs native API utilization - } - if( isWindows || isOSX ) { - return new DefaultGraphicsScreen(device, screen); - } - throw new UnsupportedOperationException("n/a for this windowing system: "+nwt); + public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen) { + return NativeWindowFactory.createScreen(nwt, device, screen); } public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index 0f28ca67c..da3b31de4 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -45,7 +45,7 @@ import javax.media.nativewindow.ToolkitLock; */ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneable { - final boolean handleOwner; + /* final */ boolean handleOwner; final boolean isXineramaEnabled; /** Constructs a new X11GraphicsDevice corresponding to the given connection and default @@ -153,5 +153,13 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl } return super.close(); } + + @Override + public boolean isHandleOwner() { + return handleOwner; + } + @Override + public void clearHandleOwner() { + handleOwner = false; + } } - diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java index ebdaf2fbb..4e45113d4 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsConfiguration.java @@ -42,8 +42,9 @@ package javax.media.nativewindow; /** A marker interface describing a graphics configuration, visual, or pixel format in a toolkit-independent manner. */ - public interface AbstractGraphicsConfiguration extends VisualIDHolder, Cloneable { + public Object clone(); + /** * Return the screen this graphics configuration is valid for */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java index 8ecd5242d..585cd1f09 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsDevice.java @@ -45,7 +45,6 @@ import jogamp.nativewindow.Debug; /** A interface describing a graphics device in a toolkit-independent manner. */ - public interface AbstractGraphicsDevice extends Cloneable { public static final boolean DEBUG = Debug.debug("GraphicsDevice"); @@ -58,6 +57,8 @@ public interface AbstractGraphicsDevice extends Cloneable { /** Default unit id for the 1st device: 0 */ public static int DEFAULT_UNIT = 0; + public Object clone(); + /** * Returns the type of the underlying subsystem, ie * NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, .. @@ -143,10 +144,17 @@ public interface AbstractGraphicsDevice extends Cloneable { *

    * Example implementations like {@link com.jogamp.nativewindow.x11.X11GraphicsDevice} * or {@link com.jogamp.nativewindow.egl.EGLGraphicsDevice} - * issue the native close operation or skip it depending on the handles's ownership. + * issue the native close operation or skip it depending on the {@link #isHandleOwner() handles's ownership}. *

    * * @return true if the handle was not null and closing was successful, otherwise false. */ public boolean close(); + + /** + * @return true if instance owns the handle to issue {@link #close()}, otherwise false. + */ + public boolean isHandleOwner(); + + public void clearHandleOwner(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java index eb2cc9120..acb98073b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/AbstractGraphicsScreen.java @@ -44,6 +44,8 @@ package javax.media.nativewindow; */ public interface AbstractGraphicsScreen extends Cloneable { + public Object clone(); + /** * Return the device this graphics configuration is valid for */ diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java index a33c3792a..6b23172e1 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsConfiguration.java @@ -93,25 +93,26 @@ public class DefaultGraphicsConfiguration implements Cloneable, AbstractGraphics /** * Set the capabilities to a new value. * + *

    * The use case for setting the Capabilities at a later time is - * a change of the graphics device in a multi-screen environment.
    - * + * a change or re-validation of capabilities. + *

    * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen) */ protected void setChosenCapabilities(CapabilitiesImmutable capsChosen) { - capabilitiesChosen = capsChosen; + this.capabilitiesChosen = capsChosen; } /** * Set a new screen. * + *

    * the use case for setting a new screen at a later time is - * a change of the graphics device in a multi-screen environment.
    - * - * A copy of the passed object is being used. + * a change of the graphics device in a multi-screen environment. + *

    */ - final protected void setScreen(DefaultGraphicsScreen screen) { - this.screen = (AbstractGraphicsScreen) screen.clone(); + protected void setScreen(AbstractGraphicsScreen screen) { + this.screen = screen; } @Override diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index 9288652d9..b3ae4628c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -37,10 +37,10 @@ import jogamp.nativewindow.NativeWindowFactoryImpl; public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice { private static final String separator = "_"; - private String type; - protected String connection; - protected int unitID; - protected String uniqueID; + private final String type; + protected final String connection; + protected final int unitID; + protected final String uniqueID; protected long handle; protected ToolkitLock toolkitLock; @@ -170,9 +170,18 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice return false; } + @Override + public boolean isHandleOwner() { + return false; + } + + @Override + public void clearHandleOwner() { + } + @Override public String toString() { - return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", "+toolkitLock+"]"; + return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", owner "+isHandleOwner()+", "+toolkitLock+"]"; } /** diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java index f50bd0e14..9fa58c7a3 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsScreen.java @@ -33,8 +33,8 @@ package javax.media.nativewindow; public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen { - AbstractGraphicsDevice device; - private int idx; + private final AbstractGraphicsDevice device; + private final int idx; public DefaultGraphicsScreen(AbstractGraphicsDevice device, int idx) { this.device = device; @@ -57,7 +57,7 @@ public class DefaultGraphicsScreen implements Cloneable, AbstractGraphicsScreen public AbstractGraphicsDevice getDevice() { return device; } - + public int getIndex() { return idx; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index d7f28a986..07702c762 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -48,6 +48,10 @@ import jogamp.nativewindow.ResourceToolkitLock; import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.nativewindow.awt.AWTGraphicsDevice; +import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.nativewindow.x11.X11GraphicsDevice; +import com.jogamp.nativewindow.x11.X11GraphicsScreen; /** Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the {@link NativeWindow} interface, @@ -428,6 +432,29 @@ public abstract class NativeWindowFactory { return NativeWindowFactoryImpl.getNullToolkitLock(); } + /** + * @param device + * @param screen -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen + * @return newly created AbstractGraphicsScreen of given native type + */ + public static AbstractGraphicsScreen createScreen(String type, AbstractGraphicsDevice device, int screen) { + if( TYPE_X11 == type ) { + final X11GraphicsDevice x11Device = (X11GraphicsDevice)device; + if(0 > screen) { + screen = x11Device.getDefaultScreen(); + } + return new X11GraphicsScreen(x11Device, screen); + } + if(0 > screen) { + screen = 0; // FIXME: Needs native API utilization + } + if( TYPE_AWT == type ) { + final AWTGraphicsDevice awtDevice = (AWTGraphicsDevice) device; + return new AWTGraphicsScreen(awtDevice); + } + return new DefaultGraphicsScreen(device, screen); + } + /** Returns the appropriate NativeWindowFactory to handle window objects of the given type. The windowClass might be {@link NativeWindow NativeWindow}, in which case the client has diff --git a/src/nativewindow/native/x11/Xmisc.c b/src/nativewindow/native/x11/Xmisc.c index a8d45f288..017c52df2 100644 --- a/src/nativewindow/native/x11/Xmisc.c +++ b/src/nativewindow/native/x11/Xmisc.c @@ -180,7 +180,7 @@ static int errorHandlerThrowException = 0; static int x11ErrorHandler(Display *dpy, XErrorEvent *e) { - if(!errorHandlerQuiet) { + if( !errorHandlerQuiet || errorHandlerDebug ) { const char * errnoStr = strerror(errno); char errCodeStr[80]; char reqCodeStr[80]; diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 96d0f6e3b..7fccb6622 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -458,24 +458,22 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } else { t0 = 0; } - - /* if (nativeWindowCreated && null != context) { - throw new GLException("InternalError: Native Windows has been just created, but context wasn't destroyed (is not null)"); - } */ - if (null == context && visible && 0 != window.getWindowHandle() && 0 ctx1/draw2, ctx2/draw1. + */ +public class TestGLContextDrawableSwitch01NEWT extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getGL2ES2(); + caps = new GLCapabilities(glp); + width = 256; + height = 256; + } + + private GLAutoDrawable createGLAutoDrawable(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException { + final Window window = NewtFactory.createWindow(caps); + Assert.assertNotNull(window); + window.setPosition(x, y); + window.setSize(width, height); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + final GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); + window.destroy(); // destroys the actual window + } + }; + + // add basic window interaction + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + @Override + public void windowDestroyNotify(WindowEvent e) { + glad.windowDestroyNotifyOp(); + } + }); + window.addWindowListener(wl); + + return glad; + } + + @Test(timeout=30000) + public void testSwitch2WindowSingleContext() throws InterruptedException { + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); + GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); + + // create single context using glad1 and assign it to glad1, + // destroy the prev. context afterwards. + { + final GLContext newCtx = glad1.createContext(null); + Assert.assertNotNull(newCtx); + final GLContext oldCtx = glad1.setContext(newCtx); + Assert.assertNotNull(oldCtx); + oldCtx.destroy(); + final int res = newCtx.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + newCtx.release(); + } + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + GearsES2 gears = new GearsES2(1); + glad1.addGLEventListener(gears); + glad1.addGLEventListener(snapshotGLEventListener); + snapshotGLEventListener.setMakeSnapshot(); + + Animator animator = new Animator(); + animator.add(glad1); + animator.add(glad2); + animator.start(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + + // switch context _and_ the demo synchronously + GLDrawableUtil.swapGLContextAndAllGLEventListener(glad1, glad2); + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glad1.destroy(); + glad2.destroy(); + } + + @Test(timeout=30000) + public void testSwitch2GLWindowOneDemo() throws InterruptedException { + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final GearsES2 gears = new GearsES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addGLEventListener(snapshotGLEventListener); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + snapshotGLEventListener.setMakeSnapshot(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + + // switch context _and_ the demo synchronously + GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); + + System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + snapshotGLEventListener.setMakeSnapshot(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glWindow1.destroy(); + glWindow2.destroy(); + + } + + @Test(timeout=30000) + public void testSwitch2GLWindowEachWithOwnDemo() throws InterruptedException { + final GearsES2 gears = new GearsES2(1); + final RedSquareES2 rsquare = new RedSquareES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + final SnapshotGLEventListener snapshotGLEventListener1 = new SnapshotGLEventListener(); + final SnapshotGLEventListener snapshotGLEventListener2 = new SnapshotGLEventListener(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addGLEventListener(snapshotGLEventListener1); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addGLEventListener(0, rsquare); + glWindow2.addGLEventListener(snapshotGLEventListener2); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + snapshotGLEventListener1.setMakeSnapshot(); + snapshotGLEventListener2.setMakeSnapshot(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); + System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + snapshotGLEventListener1.setMakeSnapshot(); + snapshotGLEventListener2.setMakeSnapshot(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + // System.err.println("pre -del-w1: w1: "+glWindow1); + // System.err.println("pre -del-w1: w2: "+glWindow2); + glWindow1.destroy(); + // System.err.println("post-del-w1: w1: "+glWindow1); + // System.err.println("post-del-w1: w2: "+glWindow2); + glWindow2.destroy(); + + } + + // default timing for 2 switches + static long duration = 2200; // ms + static long period = 1000; // ms + + public static void main(String args[]) throws IOException { + for(int i=0; i + * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665. + *

    + */ +public class TestGLContextDrawableSwitch11NEWT extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + glp = GLProfile.getGL2ES2(); + caps = new GLCapabilities(glp); + width = 256; + height = 256; + } + + private GLAutoDrawable createGLAutoDrawable(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException { + final Window window = NewtFactory.createWindow(caps); + Assert.assertNotNull(window); + window.setPosition(x, y); + window.setSize(width, height); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); + window.destroy(); // destroys the actual window + } + }; + + // add basic window interaction + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + @Override + public void windowDestroyNotify(WindowEvent e) { + glad.windowDestroyNotifyOp(); + } + }); + window.addWindowListener(wl); + + return glad; + } + + @Test(timeout=30000) + public void test01() throws InterruptedException { + final QuitAdapter quitAdapter = new QuitAdapter(); + + final GLEventListenerCounter glelCounter = new GLEventListenerCounter(); + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final Animator animator = new Animator(); + animator.start(); + + final long t0 = System.currentTimeMillis(); + final GLEventListenerState glls1; + + // - create glad1 w/o context + // - create context using glad1 and assign it to glad1 + { + final GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); + final GLContext context1 = glad1.createContext(null); + glad1.setContext(context1); + animator.add(glad1); + + glad1.addGLEventListener(glelCounter); + glad1.addGLEventListener(new GearsES2(1)); + glad1.addGLEventListener(snapshotGLEventListener); + snapshotGLEventListener.setMakeSnapshot(); + + long t1 = System.currentTimeMillis(); + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/2 ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + // - dis-associate context from glad1 + // - destroy glad1 + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + Assert.assertEquals(context1, glad1.getContext()); + Assert.assertEquals(3, glad1.getGLEventListenerCount()); + Assert.assertEquals(context1.getGLReadDrawable(), glad1.getDelegatedDrawable()); + Assert.assertEquals(context1.getGLDrawable(), glad1.getDelegatedDrawable()); + + glls1 = GLEventListenerState.moveFrom(glad1); + + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + Assert.assertEquals(context1, glls1.context); + Assert.assertNull(context1.getGLReadDrawable()); + Assert.assertNull(context1.getGLDrawable()); + Assert.assertEquals(3, glls1.listenerCount()); + Assert.assertEquals(true, glls1.isOwner()); + Assert.assertEquals(null, glad1.getContext()); + Assert.assertEquals(0, glad1.getGLEventListenerCount()); + + glad1.destroy(); + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + } + + // - create glad2 w/ survived context + { + final GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); + snapshotGLEventListener.setMakeSnapshot(); + + Assert.assertEquals(null, glad2.getContext()); + Assert.assertEquals(0, glad2.getGLEventListenerCount()); + + glls1.moveTo(glad2); + + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + Assert.assertEquals(glls1.context, glad2.getContext()); + Assert.assertEquals(3, glad2.getGLEventListenerCount()); + Assert.assertEquals(glls1.context.getGLReadDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(glls1.context.getGLDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(false, glls1.isOwner()); + + long t1 = System.currentTimeMillis(); + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/1 ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + glad2.destroy(); + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(1, glelCounter.disposeCount); + } + animator.stop(); + } + + @Test(timeout=30000) + public void test02() throws InterruptedException { + final QuitAdapter quitAdapter = new QuitAdapter(); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final GLEventListenerCounter glelTracker = new GLEventListenerCounter(); + final Animator animator = new Animator(); + animator.start(); + + final long t0 = System.currentTimeMillis(); + final GLEventListenerState glls1; + + // - create glad1 w/o context + // - create context using glad1 and assign it to glad1 + { + final GLWindow glad1 = GLWindow.create(caps); + glad1.setSize(width, height); + glad1.setPosition(64, 64); + glad1.addWindowListener(quitAdapter); + glad1.setVisible(true); + animator.add(glad1); + + glad1.addGLEventListener(glelTracker); + glad1.addGLEventListener(new GearsES2(1)); + glad1.addGLEventListener(snapshotGLEventListener); + snapshotGLEventListener.setMakeSnapshot(); + + long t1 = System.currentTimeMillis(); + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/2 ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + // - dis-associate context from glad1 + // - destroy glad1 + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + Assert.assertEquals(3, glad1.getGLEventListenerCount()); + Assert.assertEquals(glad1.getContext().getGLReadDrawable(), glad1.getDelegatedDrawable()); + Assert.assertEquals(glad1.getContext().getGLDrawable(), glad1.getDelegatedDrawable()); + + final GLContext context1 = glad1.getContext(); + glls1 = GLEventListenerState.moveFrom(glad1); + + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + Assert.assertEquals(context1, glls1.context); + Assert.assertNull(context1.getGLReadDrawable()); + Assert.assertNull(context1.getGLDrawable()); + Assert.assertEquals(3, glls1.listenerCount()); + Assert.assertEquals(true, glls1.isOwner()); + Assert.assertEquals(null, glad1.getContext()); + Assert.assertEquals(0, glad1.getGLEventListenerCount()); + + glad1.destroy(); + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + } + + // - create glad2 w/ survived context + { + final GLWindow glad2 = GLWindow.create(caps); + glad2.setSize(width+100, height+100); + glad2.setPosition(2*64+width, 64); + glad2.addWindowListener(quitAdapter); + glad2.setVisible(true); + snapshotGLEventListener.setMakeSnapshot(); + + Assert.assertNotNull(glad2.getContext()); + Assert.assertEquals(0, glad2.getGLEventListenerCount()); + + glls1.moveTo(glad2); + + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + Assert.assertEquals(glls1.context, glad2.getContext()); + Assert.assertEquals(3, glad2.getGLEventListenerCount()); + Assert.assertEquals(glls1.context.getGLReadDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(glls1.context.getGLDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(false, glls1.isOwner()); + + long t1 = System.currentTimeMillis(); + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/1 ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + glad2.destroy(); + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(1, glelTracker.disposeCount); + } + animator.stop(); + } + + // default timing for 2 switches + static long duration = 2200; // ms + + public static void main(String args[]) throws IOException { + for(int i=0; i s) { - s++; - System.err.println(s+" - switch - START "+ ( t1 - t0 )); - - // switch context _and_ the demo synchronously - GLDrawableUtil.swapGLContextAndAllGLEventListener(glad1, glad2); - - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - } - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - animator.stop(); - glad1.destroy(); - glad2.destroy(); - } - - @Test(timeout=30000) - public void testSwitch2GLWindowOneDemo() throws InterruptedException { - GearsES2 gears = new GearsES2(1); - final QuitAdapter quitAdapter = new QuitAdapter(); - - GLWindow glWindow1 = GLWindow.create(caps); - glWindow1.setTitle("win1"); - glWindow1.setSize(width, height); - glWindow1.setPosition(64, 64); - glWindow1.addGLEventListener(0, gears); - glWindow1.addWindowListener(quitAdapter); - - GLWindow glWindow2 = GLWindow.create(caps); - glWindow2.setTitle("win2"); - glWindow2.setSize(width+100, height+100); - glWindow2.setPosition(2*64+width, 64); - glWindow2.addWindowListener(quitAdapter); - - Animator animator = new Animator(); - animator.add(glWindow1); - animator.add(glWindow2); - animator.start(); - - glWindow1.setVisible(true); - glWindow2.setVisible(true); - - int s = 0; - long t0 = System.currentTimeMillis(); - long t1 = t0; - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { - if( ( t1 - t0 ) / period > s) { - s++; - System.err.println(s+" - switch - START "+ ( t1 - t0 )); - System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - - // switch context _and_ the demo synchronously - GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); - - System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - } - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - animator.stop(); - glWindow1.destroy(); - glWindow2.destroy(); - - } - - @Test(timeout=30000) - public void testSwitch2GLWindowEachWithOwnDemo() throws InterruptedException { - GearsES2 gears = new GearsES2(1); - RedSquareES2 rsquare = new RedSquareES2(1); - final QuitAdapter quitAdapter = new QuitAdapter(); - - GLWindow glWindow1 = GLWindow.create(caps); - glWindow1.setTitle("win1"); - glWindow1.setSize(width, height); - glWindow1.setPosition(64, 64); - glWindow1.addGLEventListener(0, gears); - glWindow1.addWindowListener(quitAdapter); - - GLWindow glWindow2 = GLWindow.create(caps); - glWindow2.setTitle("win2"); - glWindow2.setSize(width+100, height+100); - glWindow2.setPosition(2*64+width, 64); - glWindow2.addGLEventListener(0, rsquare); - glWindow2.addWindowListener(quitAdapter); - - Animator animator = new Animator(); - animator.add(glWindow1); - animator.add(glWindow2); - animator.start(); - - glWindow1.setVisible(true); - glWindow2.setVisible(true); - - int s = 0; - long t0 = System.currentTimeMillis(); - long t1 = t0; - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { - if( ( t1 - t0 ) / period > s) { - s++; - System.err.println(s+" - switch - START "+ ( t1 - t0 )); - System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); - System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - } - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - animator.stop(); - // System.err.println("pre -del-w1: w1: "+glWindow1); - // System.err.println("pre -del-w1: w2: "+glWindow2); - glWindow1.destroy(); - // System.err.println("post-del-w1: w1: "+glWindow1); - // System.err.println("post-del-w1: w2: "+glWindow2); - glWindow2.destroy(); - - } - - // default timing for 2 switches - static long duration = 2200; // ms - static long period = 1000; // ms - - public static void main(String args[]) throws IOException { - for(int i=0; i Date: Tue, 29 Jan 2013 21:27:57 +0100 Subject: Fix Bug 678: Deliver key-char value for printable chars on all KeyEventListener (-> On Windows as well) The following is observed, where t0 and t1 refer to subsequent different timestamps: NEWT delivery order: PRESSED (t0), RELEASED (t1) and TYPED (t1) WINDOWS delivery order: PRESSED (t0), TYPED (t0) and RELEASED (t1) Windows Auto-Repeat: PRESSED (t0), TYPED (t0) Hence we changed the event reorder-code in NEWT to trigger NEWT-PRESSED on Windows-TYPED for printable chars, assuring key-char values on all listener callbacks. - KeyEvent.getKeyChar(): Removed disclaimer dedicated for Windows - Keyevent.isActionKey(): Completed for all NEWT non-printable action keys; Added static variant - Keyevent.isPrintableKey(): NEW: returns !isModifierKey(keyCode) && !isActionKey(keyCode) ; With static variant - Windows WindowDriver: - EVENT_KEY_PRESSED handles non-printable chars only - EVENT_KEY_TYPE handles printable chars only - Native: VK_DELETE passes keyCode - Unit tests: Wait for completion 1s -> 2s --- make/scripts/java-win64-dbg.bat | 1 + make/scripts/tests-x64.bat | 6 +- make/scripts/tests.sh | 7 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 142 +++++++++++++++------ .../jogamp/newt/driver/windows/WindowDriver.java | 62 +++++---- src/newt/native/WindowsWindow.c | 2 +- .../newt/event/TestNewtKeyCodeModifiersAWT.java | 4 +- .../test/junit/newt/event/TestNewtKeyCodesAWT.java | 2 +- .../newt/event/TestNewtKeyEventAutoRepeatAWT.java | 2 +- 9 files changed, 151 insertions(+), 77 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 63c46eee5..ee7fe80e7 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -59,3 +59,4 @@ REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2 %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win64-dbg.log 2>&1 tail java-win64-dbg.log +REM %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 8bee4c6dd..b4b05d58b 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -12,7 +12,7 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedCon REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* @@ -50,7 +50,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -67,7 +67,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9625519b9..0aeb54b56 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -106,6 +106,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" @@ -167,7 +168,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -307,7 +308,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* @@ -413,7 +414,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11N #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 289aa31f6..ff67b7f57 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -74,12 +74,7 @@ public class KeyEvent extends InputEvent } /** - * Returns the character matching the {@link #getKeyCode() virtual key code}, if exist. - *

    - * Disclaimer: Only valid on all platforms at {@link KeyListener#keyTyped(KeyEvent)}. - * Precisely, on the Windows platform we currently cannot deliver the proper character - * in case of shifted keys where no uppercase exists, e.g. 'shift + 1' doesn't produce '!'. - *

    + * Returns the character matching the {@link #getKeyCode() virtual key code}. */ public char getKeyChar() { return keyChar; @@ -111,7 +106,12 @@ public class KeyEvent extends InputEvent } } - /** Returns true if keyCode represents a modifier key, i.e. one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. */ + /** + * Returns true if the given keyCode represents a non-printable modifier key. + *

    + * A modifier key is one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. + *

    + */ public static boolean isModifierKey(int keyCode) { switch (keyCode) { case VK_SHIFT: @@ -125,58 +125,116 @@ public class KeyEvent extends InputEvent } } - /** Returns true if {@link #getKeyCode()} represents a modifier key, i.e. one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. */ + /** + * Returns true if {@link #getKeyCode()} represents a non-printable modifier key. + *

    + * See {@link #isModifierKey(int)} for details. + *

    + */ public boolean isModifierKey() { return isModifierKey(keyCode); } - - public boolean isActionKey() { + + /** + * Returns true if the given keyCode represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}. + *

    + * An action key is one of {@link #VK_HOME}, {@link #VK_END}, {@link #VK_PAGE_UP}, {@link #VK_PAGE_DOWN}, {@link #VK_UP}, {@link #VK_PAGE_DOWN}, + * {@link #VK_LEFT}, {@link #VK_RIGHT}, {@link #VK_F1}-{@link #VK_F24}, {@link #VK_PRINTSCREEN}, {@link #VK_CAPS_LOCK}, {@link #VK_PAUSE}, + * {@link #VK_INSERT}, {@link #VK_HELP}, {@link #VK_WINDOWS}, etc ... + *

    + */ + public static boolean isActionKey(int keyCode) { + if( ( VK_F1 <= keyCode && keyCode <= VK_F24 ) || + ( VK_ALL_CANDIDATES <= keyCode && keyCode <= VK_INPUT_METHOD_ON_OFF ) || + ( VK_CUT <= keyCode && keyCode <= VK_STOP ) ) { + return true; + } + switch (keyCode) { - case VK_HOME: - case VK_END: + case VK_CANCEL: + case VK_CLEAR: + case VK_PAUSE: + case VK_CAPS_LOCK: + case VK_ESCAPE: case VK_PAGE_UP: case VK_PAGE_DOWN: - case VK_UP: - case VK_DOWN: + case VK_END: + case VK_HOME: case VK_LEFT: + case VK_UP: case VK_RIGHT: - - case VK_F1: - case VK_F2: - case VK_F3: - case VK_F4: - case VK_F5: - case VK_F6: - case VK_F7: - case VK_F8: - case VK_F9: - case VK_F10: - case VK_F11: - case VK_F12: - case VK_F13: - case VK_F14: - case VK_F15: - case VK_F16: - case VK_F17: - case VK_F18: - case VK_F19: - case VK_F20: - case VK_F21: - case VK_F22: - case VK_F23: - case VK_F24: + case VK_DOWN: + case VK_DELETE: + case VK_NUM_LOCK: + case VK_SCROLL_LOCK: + case VK_PRINTSCREEN: - case VK_CAPS_LOCK: - case VK_PAUSE: case VK_INSERT: - case VK_HELP: + case VK_META: + case VK_KP_UP: + case VK_KP_DOWN: + case VK_KP_LEFT: + case VK_KP_RIGHT: + + case VK_DEAD_VOICED_SOUND: + case VK_DEAD_SEMIVOICED_SOUND: + case VK_WINDOWS: + case VK_CONTEXT_MENU: + case VK_FINAL: + + case VK_CONVERT: + case VK_NONCONVERT: + case VK_ACCEPT: + case VK_MODECHANGE: + + case VK_KANA: + case VK_KANJI: + + case VK_ALPHANUMERIC: + case VK_KATAKANA: + case VK_HIRAGANA: + case VK_FULL_WIDTH: + case VK_HALF_WIDTH: + case VK_ROMAN_CHARACTERS: + + case VK_COMPOSE: + case VK_BEGIN: + return true; } return false; } + + /** + * Returns true if {@link #getKeyCode() keyCode} represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}. + *

    + * See {@link #isActionKey(int)} for details. + *

    + */ + public boolean isActionKey() { + return isActionKey(keyCode); + } + + /** + * Returns true if given keyKode represents a printable character, which is neither a {@link #isModifierKey(int) modifier key} + * nor an {@link #isActionKey(int) action key}. + * Otherwise returns false. + */ + public static boolean isPrintableKey(int keyCode) { + return !isModifierKey(keyCode) && !isActionKey(keyCode); + } + /** + * Returns true if {@link #getKeyCode() keyCode} represents a printable character, which is neither a {@link #isModifierKey(int) modifier key} + * nor an {@link #isActionKey(int) action key}. + * Otherwise returns false. + */ + public boolean isPrintableKey() { + return isPrintableKey(keyCode); + } + private final int keyCode; private final char keyChar; diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index b2e518f45..650958f25 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -273,53 +273,67 @@ public class WindowDriver extends WindowImpl { private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); - // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + final boolean isPrintableKey = KeyEvent.isPrintableKey(keyCode); + final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); + // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+isPrintableKey+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); - // Reorder: WINDOWS delivery order is PRESSED, TYPED and RELEASED -> NEWT order: PRESSED, RELEASED and TYPED - // Auto-Repeat: WINDOWS delivers only PRESSED and TYPED. + // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0), RELEASED (t1) and TYPED (t1) + // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0). switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: + final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0); + if( 0 != keyCharTyped ) { + keyChar = (char)keyCharTyped; + } if( isKeyCodeTracked(keyCode) ) { - if( keyRepeatState.put(keyCode, false) && !isModifierKeyCode ) { + if( keyRepeatState.put(keyCode, false) && !isModifierKey ) { // AR out - send out missing PRESSED emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); } keyPressedState.put(keyCode, false); } - final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0); - if( 0 != keyCharTyped ) { - keyChar = (char)keyCharTyped; - } emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); break; case KeyEvent.EVENT_KEY_PRESSED: - if( isKeyCodeTracked(keyCode) ) { - if( keyPressedState.put(keyCode, true) ) { - // key was already pressed - if( keyRepeatState.put(keyCode, true) && !isModifierKeyCode ) { - emitKeyEvent(send, wait, eventType, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); - } // else AR in - skip already send PRESSED ; or ALT - } else { - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); + // TYPED is delivered right after PRESSED for printable keys and contains the key-char information, + // hence we only deliver non printable keys (action and modifier keys) here. + // Modifier keys shall not AR. + if( !isPrintableKey ) { + if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) { + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); } - } else { - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); } break; case KeyEvent.EVENT_KEY_TYPED: - if( 1 == isKeyInAutoRepeat(keyCode) ) { - modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - } else if( 0 != keyCode ) { + if( isPrintableKey ) { typedKeyCode2KeyChar.put(keyCode, keyChar); + if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) { + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); + } } break; } } + private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, boolean send, boolean wait, int modifiers, int keyCode, char keyChar) { + if( isKeyCodeTracked(keyCode) && keyPressedState.put(keyCode, true) ) { + final boolean preKeyRepeatState = keyRepeatState.put(keyCode, true); + if( !isModifierKey ) { + // AR: Key was already pressed: Either [enter | within] AR mode + modifiers |= InputEvent.AUTOREPEAT_MASK; + if( preKeyRepeatState ) { + // AR: Within AR mode + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); + } // else { AR: Enter AR mode - skip already send PRESSED ; or ALT } + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); + emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); + } + return true; + } + return false; + } + @Override public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 17b93cfce..24d513c68 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -605,7 +605,7 @@ static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE s (*env)->CallVoidMethod(env, window, sendKeyEventID, (jint) EVENT_KEY_TYPED, modifiers, - (jint) 0, + (jint) jkey, (jchar) '\177'); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java index 478f6eb8b..ec06379e0 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java @@ -146,7 +146,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 10); // release+typed P AWTRobotUtil.keyPress(0, robot, false, modifierKey, 100); // release+typed MOD robot.waitForIdle(); - for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3+6; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3+6; j++) { // wait until events are collected robot.delay(100); } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3+6, 0); @@ -185,7 +185,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release+typed MOD robot.waitForIdle(); - for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3*4; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3*4; j++) { // wait until events are collected robot.delay(100); } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3*4, 0); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java index e43072961..ef4b17375 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java @@ -174,7 +174,7 @@ public class TestNewtKeyCodesAWT extends UITestCase { robot.waitForIdle(); } final int codeCount = codeSeg.max - codeSeg.min + 1; - for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3 * codeCount; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3 * codeCount; j++) { // wait until events are collected robot.delay(100); } final ArrayList events = new ArrayList(keyAdapter.getQueued()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index ca612bac6..00fbc0500 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -189,7 +189,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { robot.waitForIdle(); AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 250); robot.waitForIdle(); - for(int j=0; j < 10 && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected robot.delay(100); } firstIdx = keyEvents.size(); -- cgit v1.2.3 From 4d6983ca087feb0544c27326c8bf470444df2eec Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Jan 2013 16:24:14 +0100 Subject: Add OSX Java7 build/test scripts --- make/scripts/make.jogl.all.macosx-java7.sh | 25 +++++++++++++++++++++++++ make/scripts/tests-osx-x64-java7.sh | 13 +++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 make/scripts/make.jogl.all.macosx-java7.sh create mode 100755 make/scripts/tests-osx-x64-java7.sh (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.macosx-java7.sh b/make/scripts/make.jogl.all.macosx-java7.sh new file mode 100755 index 000000000..afb72bf8c --- /dev/null +++ b/make/scripts/make.jogl.all.macosx-java7.sh @@ -0,0 +1,25 @@ +#! /bin/sh + +if [ -e /opt-share/etc/profile.ant ] ; then + . /opt-share/etc/profile.ant +fi + + +# -Dc.compiler.debug=true \ +# -Djavacdebug="true" \ +# -Djavacdebuglevel="source,lines,vars" \ +# +# -Dtarget.sourcelevel=1.6 \ +# -Dtarget.targetlevel=1.6 \ +# -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ + +JAVA_HOME=`/usr/libexec/java_home -version 1.7` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + +ant \ + -Dtarget.sourcelevel=1.6 \ + -Dtarget.targetlevel=1.6 \ + -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ + -Drootrel.build=build-macosx-java7 \ + $* 2>&1 | tee make.jogl.all.macosx.log diff --git a/make/scripts/tests-osx-x64-java7.sh b/make/scripts/tests-osx-x64-java7.sh new file mode 100755 index 000000000..378938167 --- /dev/null +++ b/make/scripts/tests-osx-x64-java7.sh @@ -0,0 +1,13 @@ +#! /bin/bash + +export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH + +JAVA_HOME=`/usr/libexec/java_home -version 1.7` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + +spath=`dirname $0` + +. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* + + -- cgit v1.2.3 From cedbdb09c00bb2a32cc065cb75590f3571bb7aa1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Jan 2013 20:41:11 +0100 Subject: Fix AWTKeyAdapter: Reorder AWT events to NEWT order - also ensuring TYPED is always sent. This foremost fixes an issue w/ OSX/Java7 and NewtCanvasAWT offscreen CALayer usage, which utilizes AWTKeyAdapter and AWTNewtEventFactory (AWT -> NEWT) key events. --- make/scripts/tests-osx-x64-java7.sh | 2 +- make/scripts/tests-x64-custom.sh | 12 + make/scripts/tests.sh | 8 +- .../com/jogamp/newt/event/awt/AWTKeyAdapter.java | 26 +- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 35 +-- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 300 +++++++++++++++++++++ 6 files changed, 353 insertions(+), 30 deletions(-) create mode 100755 make/scripts/tests-x64-custom.sh create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-osx-x64-java7.sh b/make/scripts/tests-osx-x64-java7.sh index 378938167..36eee3255 100755 --- a/make/scripts/tests-osx-x64-java7.sh +++ b/make/scripts/tests-osx-x64-java7.sh @@ -8,6 +8,6 @@ export JAVA_HOME PATH spath=`dirname $0` -. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* +. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx-java7 $* diff --git a/make/scripts/tests-x64-custom.sh b/make/scripts/tests-x64-custom.sh new file mode 100755 index 000000000..482afbbf2 --- /dev/null +++ b/make/scripts/tests-x64-custom.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +SDIR=`dirname $0` + +#export LD_LIBRARY_PATH=/home/sven/libav/lib:$LD_LIBRARY_PATH + +#if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then +# . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +#fi + +. $SDIR/tests.sh `which java` -d64 ../build-x86_64 $* + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0aeb54b56..cd8d37b47 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -168,7 +168,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -266,6 +266,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* @@ -298,8 +299,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -414,6 +413,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index 7b0f6ba97..64071eed6 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -30,6 +30,11 @@ package com.jogamp.newt.event.awt; import jogamp.newt.awt.event.AWTNewtEventFactory; +/** + * AWT: + * printable: PRESSED (t0), TYPED (t0), RELEASED (t1) + * non-printable: PRESSED (t0), RELEASED (t1) + */ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListener { public AWTKeyAdapter(com.jogamp.newt.event.KeyListener newtListener) { @@ -54,8 +59,9 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe return this; } + @Override public void keyPressed(java.awt.event.KeyEvent e) { - com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow); + final com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED, e, newtWindow); if(null!=newtListener) { ((com.jogamp.newt.event.KeyListener)newtListener).keyPressed(event); } else { @@ -63,22 +69,22 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe } } + @Override public void keyReleased(java.awt.event.KeyEvent e) { - com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow); + com.jogamp.newt.event.KeyEvent keyReleaseEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow); + com.jogamp.newt.event.KeyEvent keyTypedEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED, e, newtWindow); if(null!=newtListener) { - ((com.jogamp.newt.event.KeyListener)newtListener).keyReleased(event); + final com.jogamp.newt.event.KeyListener newtKeyListener = (com.jogamp.newt.event.KeyListener)newtListener; + newtKeyListener.keyReleased(keyReleaseEvt); + newtKeyListener.keyTyped(keyTypedEvt); } else { - enqueueEvent(false, event); + enqueueEvent(false, keyReleaseEvt); + enqueueEvent(false, keyTypedEvt); } } + @Override public void keyTyped(java.awt.event.KeyEvent e) { - com.jogamp.newt.event.KeyEvent event = AWTNewtEventFactory.createKeyEvent(e, newtWindow); - if(null!=newtListener) { - ((com.jogamp.newt.event.KeyListener)newtListener).keyTyped(event); - } else { - enqueueEvent(false, event); - } } } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index e0f7af69c..e11d79ddc 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -236,32 +236,32 @@ public class AWTNewtEventFactory { } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { - return new com.jogamp.newt.event.WindowEvent(type, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis()); + final int newtType = eventTypeAWT2NEWT.get(event.getID()); + if(0xFFFFFFFF != newtType) { + return new com.jogamp.newt.event.WindowEvent(newtType, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.ComponentEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { - return new com.jogamp.newt.event.WindowEvent(type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); + final int newtType = eventTypeAWT2NEWT.get(event.getID()); + if(0xFFFFFFFF != newtType) { + return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.FocusEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { - return new com.jogamp.newt.event.WindowEvent(type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); + final int newtType = eventTypeAWT2NEWT.get(event.getID()); + if(0xFFFFFFFF != newtType) { + return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { + final int newtType = eventTypeAWT2NEWT.get(event.getID()); + if(0xFFFFFFFF != newtType) { float rotation = 0; if (event instanceof java.awt.event.MouseWheelEvent) { // AWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. @@ -280,7 +280,7 @@ public class AWTNewtEventFactory { } } return new com.jogamp.newt.event.MouseEvent( - type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), + newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), mods, event.getX(), event.getY(), event.getClickCount(), newtButton, rotation); } @@ -288,15 +288,18 @@ public class AWTNewtEventFactory { } public static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { - int type = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != type) { + return createKeyEvent(eventTypeAWT2NEWT.get(event.getID()), event, newtSource); + } + + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(int newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { + if(0xFFFFFFFF != newtType) { return new com.jogamp.newt.event.KeyEvent( - type, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), + newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), event.getKeyCode(), event.getKeyChar()); } return null; // no mapping .. } - + } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java new file mode 100644 index 000000000..5fca50593 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -0,0 +1,300 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; + +import java.awt.BorderLayout; +import java.awt.Frame; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import com.jogamp.newt.Display; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.QuitAdapter; + +import com.jogamp.opengl.util.Animator; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; +import javax.media.nativewindow.util.DimensionImmutable; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; +import javax.swing.SwingUtilities; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; + +public class TestGearsES2NewtCanvasAWT extends UITestCase { + static int screenIdx = 0; + static PointImmutable wpos; + static DimensionImmutable wsize; + + static long duration = 500; // ms + static boolean opaque = true; + static int forceAlpha = -1; + static boolean fullscreen = false; + static boolean pmvUseBackingArray = true; + static int swapInterval = 1; + static boolean showFPS = false; + static int loops = 1; + static boolean loop_shutdown = false; + static boolean forceES2 = false; + static boolean forceGL3 = false; + static boolean mainRun = false; + static boolean exclusiveContext = false; + + @BeforeClass + public static void initClass() { + if(null == wsize) { + wsize = new Dimension(640, 480); + } + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException { + System.err.println("requested: vsync "+swapInterval+", "+caps); + Display dpy = NewtFactory.createDisplay(null); + Screen screen = NewtFactory.createScreen(dpy, screenIdx); + final GLWindow glWindow = GLWindow.create(screen, caps); + Assert.assertNotNull(glWindow); + + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + + final Frame frame1 = new Frame("AWT Parent Frame"); + frame1.setLayout(new BorderLayout()); + frame1.add(newtCanvasAWT, BorderLayout.CENTER); + frame1.setSize(wsize.getWidth(), wsize.getHeight()); + frame1.setLocation(0, 0); + frame1.setTitle("Gears NewtCanvasAWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval+", size "+wsize+", pos "+wpos); + + final GearsES2 demo = new GearsES2(swapInterval); + demo.setPMVUseBackingArray(pmvUseBackingArray); + glWindow.addGLEventListener(demo); + + Animator animator = new Animator(); + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + animator.setExclusiveContext(exclusiveContext); + + QuitAdapter quitAdapter = new QuitAdapter(); + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + glWindow.addWindowListener(new WindowAdapter() { + public void windowResized(WindowEvent e) { + System.err.println("window resized: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + public void windowMoved(WindowEvent e) { + System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); + } + }); + + glWindow.addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + if(e.getKeyChar()=='f') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } + } + }); + + animator.add(glWindow); + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } + }); + + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Thu, 31 Jan 2013 21:19:47 +0100 Subject: Bump Android NDK to android-ndk-r8d --- make/scripts/make.jogl.all.android-armv6-cross.sh | 17 +++++++++-------- make/scripts/make.jogl.all.android-armv7-cross.sh | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.android-armv6-cross.sh b/make/scripts/make.jogl.all.android-armv6-cross.sh index e75a73d45..da1b95c78 100755 --- a/make/scripts/make.jogl.all.android-armv6-cross.sh +++ b/make/scripts/make.jogl.all.android-armv6-cross.sh @@ -30,14 +30,14 @@ if [ -z "$NDK_ROOT" ] ; then elif [ -e /opt/android-ndk ] ; then NDK_ROOT=/opt/android-ndk # - # Specific android-ndk-r7b + # Specific android-ndk-r8d # - elif [ -e /usr/local/android-ndk-r7b ] ; then - NDK_ROOT=/usr/local/android-ndk-r7b - elif [ -e /opt-linux-x86/android-ndk-r7b ] ; then - NDK_ROOT=/opt-linux-x86/android-ndk-r7b - elif [ -e /opt/android-ndk-r7b ] ; then - NDK_ROOT=/opt/android-ndk-r7b + elif [ -e /usr/local/android-ndk-r8d ] ; then + NDK_ROOT=/usr/local/android-ndk-r8d + elif [ -e /opt-linux-x86/android-ndk-r8d ] ; then + NDK_ROOT=/opt-linux-x86/android-ndk-r8d + elif [ -e /opt/android-ndk-r8d ] ; then + NDK_ROOT=/opt/android-ndk-r8d else echo NDK_ROOT is not specified and does not exist in default locations exit 1 @@ -70,7 +70,8 @@ export SOURCE_LEVEL=1.6 export TARGET_LEVEL=1.6 export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar -export GCC_VERSION=4.4.3 +#export GCC_VERSION=4.4.3 +export GCC_VERSION=4.7 HOST_ARCH=linux-x86 export TARGET_TRIPLE=arm-linux-androideabi diff --git a/make/scripts/make.jogl.all.android-armv7-cross.sh b/make/scripts/make.jogl.all.android-armv7-cross.sh index f38e05dea..f37abcdfd 100755 --- a/make/scripts/make.jogl.all.android-armv7-cross.sh +++ b/make/scripts/make.jogl.all.android-armv7-cross.sh @@ -30,14 +30,14 @@ if [ -z "$NDK_ROOT" ] ; then elif [ -e /opt/android-ndk ] ; then NDK_ROOT=/opt/android-ndk # - # Specific android-ndk-r7b + # Specific android-ndk-r8d # - elif [ -e /usr/local/android-ndk-r7b ] ; then - NDK_ROOT=/usr/local/android-ndk-r7b - elif [ -e /opt-linux-x86/android-ndk-r7b ] ; then - NDK_ROOT=/opt-linux-x86/android-ndk-r7b - elif [ -e /opt/android-ndk-r7b ] ; then - NDK_ROOT=/opt/android-ndk-r7b + elif [ -e /usr/local/android-ndk-r8d ] ; then + NDK_ROOT=/usr/local/android-ndk-r8d + elif [ -e /opt-linux-x86/android-ndk-r8d ] ; then + NDK_ROOT=/opt-linux-x86/android-ndk-r8d + elif [ -e /opt/android-ndk-r8d ] ; then + NDK_ROOT=/opt/android-ndk-r8d else echo NDK_ROOT is not specified and does not exist in default locations exit 1 @@ -70,7 +70,8 @@ export SOURCE_LEVEL=1.6 export TARGET_LEVEL=1.6 export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar -export GCC_VERSION=4.4.3 +#export GCC_VERSION=4.4.3 +export GCC_VERSION=4.7 HOST_ARCH=linux-x86 export TARGET_TRIPLE=arm-linux-androideabi -- cgit v1.2.3 From feebfdea24f8ac98282751824aa4d3569bb71d93 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 1 Feb 2013 12:41:53 +0100 Subject: Fix Animator resume() wait-condition (drawablesEmpty didn't wait for pausedIssued); Update TestGLWindows02NEWTAnimated (isPaused()) --- make/scripts/tests.sh | 15 +++++-- .../classes/com/jogamp/opengl/util/Animator.java | 4 +- .../junit/newt/TestGLWindows02NEWTAnimated.java | 46 +++++++++++++--------- 3 files changed, 41 insertions(+), 24 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index cd8d37b47..d00e3c133 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -414,9 +414,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* @@ -536,9 +534,18 @@ testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #linux: -#testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* +# ATI/Linux: XCB Unknown request in queue while dequeuing +# Most likely this is a multi-threaded client and XInitThreads has not been called +# ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed +testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* +# this one works - though ! +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $* +# ATI/Linux XCB Unknown request in queue while dequeuing +# Most likely this is a multi-threaded client and XInitThreads has not been called +# ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed. +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* $spath/count-edt-start.sh java-run.log diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index 22832f6bd..673ec895e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -307,7 +307,7 @@ public class Animator extends AnimatorBase { private final Condition waitForPausedCondition = new Condition() { public boolean eval() { // end waiting if stopped as well - return isAnimating && isStartedImpl(); + return isStartedImpl() && isAnimating; } }; public synchronized boolean resume() { @@ -320,6 +320,6 @@ public class Animator extends AnimatorBase { private final Condition waitForResumeCondition = new Condition() { public boolean eval() { // end waiting if stopped as well - return !drawablesEmpty && !isAnimating && isStartedImpl(); + return isStartedImpl() && ( !drawablesEmpty && !isAnimating || drawablesEmpty && !pauseIssued ) ; } }; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java index 6f4ced53c..64c5e9c8d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java @@ -132,7 +132,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { animator.remove(window); Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isPaused()); + Assert.assertEquals(true, animator.isPaused()); // zero drawables Assert.assertEquals(true, animator.isStarted()); Assert.assertTrue(animator.stop()); } @@ -142,21 +142,24 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); GLWindow window = createWindow(null, caps, width, height, true /* onscreen */, false /* undecorated */, true /* vsync */); - Animator animator = new Animator(window); + Animator animator = new Animator(); animator.setUpdateFPSFrames(1, null); Assert.assertTrue(animator.start()); + Assert.assertEquals(false, animator.isAnimating()); // zero drawables + Assert.assertEquals(true, animator.isPaused()); // zero drawables + animator.add(window); while(animator.isAnimating() && animator.getTotalFPSDuration() Date: Thu, 14 Feb 2013 15:12:18 +0100 Subject: Fix OSX CALayer Bug 690 and Bug 691: Occasional Freeze on CVDisplayLinkStop; Layers and native GL-Context are _not_ Released ; Java Side wait for Main-Thread - Fix Bug 690: Occasional Freeze on CVDisplayLinkStop - NSOpenGLLayer.disableAnimation() shall not claim the renderLock mutex, since the CVDisplayLink callback could be waiting for the lock. This waiting callback could freeze the call to CVDisplayLinkStop. - Fix Bug 691: Layers and native GL-Context are _not_ Released - Following proper release cycle: Context unrealized: - JAWTWindow.detachSurfaceLayer() -> OSXUtil.RemoveCASublayer(..) - CGL.releaseNSOpenGLLayer(..) JAWTWindow.destroy() - MacOSXJAWTWindow.UnsetJAWTRootSurfaceLayer(..) - OSXUtil.DestroyCALayer(..) - 'Magic' CALayer release calls (w/o manual retain beforehand) at: - OSXUtil.RemoveCASublayer(..): [subLayer release] - MacOSXJAWTWindow.UnsetJAWTRootSurfaceLayer(..): [rootLayer release] - OSXUtil.DestroyCALayer(..): [rootLayer release] - 'Magic' NSOpenGLLayer's NSOpenGLContext dealloc: - [NSOpenGLContext clearDrawable] - CGLDestroyContext( [NSOpenGLContext CGLContextObj] ) - Java Side wait for Main-Thread - Waiting for the delegated Main-Thread on the Java side eases debugging and won't block the Main-Thread in native code. - Utilizing this for all CALayer calls Test case: TestGLCanvasAddRemove01SwingAWT --- make/scripts/tests-osx-x64-java7.sh | 2 +- make/scripts/tests-osx-x64.sh | 4 + make/scripts/tests.sh | 14 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 5 +- .../macosx/MacOSXWindowSystemInterface-calayer.m | 116 +++++++--- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 14 +- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 2 - .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 57 ++++- .../jogamp/nativewindow/macosx/OSXUtil.java | 83 +++++-- src/nativewindow/native/macosx/OSXmisc.m | 170 ++++++++------ .../jogl/awt/TestGLCanvasAddRemove01SwingAWT.java | 257 +++++++++++++++++++++ .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 11 +- 12 files changed, 596 insertions(+), 139 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAddRemove01SwingAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-osx-x64-java7.sh b/make/scripts/tests-osx-x64-java7.sh index 36eee3255..378938167 100755 --- a/make/scripts/tests-osx-x64-java7.sh +++ b/make/scripts/tests-osx-x64-java7.sh @@ -8,6 +8,6 @@ export JAVA_HOME PATH spath=`dirname $0` -. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx-java7 $* +. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh index 748cf39a9..01f3e1bb2 100755 --- a/make/scripts/tests-osx-x64.sh +++ b/make/scripts/tests-osx-x64.sh @@ -2,6 +2,10 @@ export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH +JAVA_HOME=`/usr/libexec/java_home -version 1.6` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + spath=`dirname $0` . $spath/tests.sh /usr/bin/java -d64 ../build-macosx $* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d00e3c133..198a8f2e6 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -33,7 +33,7 @@ MOSX_MT=0 uname -a | grep -i Darwin && MOSX=1 if [ $MOSX -eq 1 ] ; then echo setup OSX environment vars - export NSZombieEnabled=YES + #export NSZombieEnabled=YES export NSTraceEvents=YES #export OBJC_PRINT_EXCEPTIONS=YES echo NSZombieEnabled $NSZombieEnabled 2>&1 | tee -a java-run.log @@ -89,7 +89,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch -Dnativewindow.debug.JAWT" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" @@ -175,7 +175,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" - #D_ARGS="-Djogl.debug.GLCanvas" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" @@ -415,6 +415,12 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* + +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove01SwingAWT $* + #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* @@ -538,7 +544,7 @@ function testawtswt() { # ATI/Linux: XCB Unknown request in queue while dequeuing # Most likely this is a multi-threaded client and XInitThreads has not been called # ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed -testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* # this one works - though ! #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $* diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 838a0387d..0deaa2987 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -709,7 +709,10 @@ public abstract class MacOSXCGLContext extends GLContextImpl // still having a valid OLS attached to surface (parent OLS could have been removed) ols.detachSurfaceLayer(); } - CGL.releaseNSOpenGLLayer(nsOpenGLLayer); + OSXUtil.RunOnMainThread(true, new Runnable() { + public void run() { + CGL.releaseNSOpenGLLayer(nsOpenGLLayer); + } } ); if( null != gl3ShaderProgram ) { gl3ShaderProgram.destroy(MacOSXCGLContext.this.gl.getGL3()); gl3ShaderProgram = null; diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index b37930587..4334fc676 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -41,6 +41,8 @@ extern GLboolean glIsVertexArray (GLuint array); // // #define DBG_PERF 1 +// #define DBG_LIFECYCLE 1 + /** * Capture setView(NULL), which produces a 'invalid drawable' message * @@ -52,6 +54,10 @@ extern GLboolean glIsVertexArray (GLuint array); - (id)initWithFormat:(NSOpenGLPixelFormat *)format shareContext:(NSOpenGLContext *)share; - (void)setView:(NSView *)view; - (void)update; +#ifdef DBG_LIFECYCLE +- (id)retain; +- (oneway void)release; +#endif - (void)dealloc; @end @@ -82,11 +88,36 @@ extern GLboolean glIsVertexArray (GLuint array); DBG_PRINT("MyNSOpenGLContext.update.X\n"); } +#ifdef DBG_LIFECYCLE + +- (id)retain +{ + DBG_PRINT("MyNSOpenGLContext::retain.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyNSOpenGLContext::retain: %@",[NSThread callStackSymbols]); + id o = [super retain]; + DBG_PRINT("MyNSOpenGLContext::retain.X: %p (refcnt %d)\n", o, (int)[o retainCount]); + return o; +} + +- (oneway void)release +{ + DBG_PRINT("MyNSOpenGLContext::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + [super release]; + // DBG_PRINT("MyNSOpenGLContext::release.X: %p (refcnt %d)\n", self, (int)[self retainCount]); +} + +#endif + - (void)dealloc { - DBG_PRINT("MyNSOpenGLContext.dealloc: this.0 %p\n", self); + CGLContextObj cglCtx = [self CGLContextObj]; + DBG_PRINT("MyNSOpenGLContext::dealloc.0 %p (refcnt %d) - CGL-Ctx %p\n", self, (int)[self retainCount], cglCtx); + [self clearDrawable]; + if( NULL != cglCtx ) { + CGLDestroyContext( cglCtx ); + } [super dealloc]; - DBG_PRINT("MyNSOpenGLContext.dealloc.X: %p\n", self); + // DBG_PRINT("MyNSOpenGLContext.dealloc.X: %p\n", self); } @end @@ -95,6 +126,7 @@ extern GLboolean glIsVertexArray (GLuint array); { @private GLfloat gl_texCoords[8]; + NSOpenGLContext* myCtx; @protected NSOpenGLContext* parentCtx; @@ -150,6 +182,10 @@ extern GLboolean glIsVertexArray (GLuint array); - (void)pauseAnimation:(Bool)pause; - (void)deallocPBuffer; - (void)releaseLayer; +#ifdef DBG_LIFECYCLE +- (id)retain; +- (oneway void)release; +#endif - (void)dealloc; - (void)setSwapInterval:(int)interval; - (void)tick; @@ -209,6 +245,7 @@ static const GLfloat gl_verts[] = { pthread_mutex_init(&renderLock, &renderLockAttr); // recursive pthread_cond_init(&renderSignal, NULL); // no attribute + myCtx = NULL; { int i; for(i=0; i<8; i++) { @@ -418,15 +455,15 @@ static const GLfloat gl_verts[] = { { DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.0: %p (refcnt %d) - pfmt %p, parent %p\n", self, (int)[self retainCount], pixelFormat, parentCtx); - NSOpenGLContext * nctx = [[MyNSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; - DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.X: new-ctx %p\n", nctx); - return nctx; + // NSLog(@"MyNSOpenGLLayer::openGLContextForPixelFormat: %@",[NSThread callStackSymbols]); + myCtx = [[MyNSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.X: new-ctx %p\n", myCtx); + return myCtx; } - (void)disableAnimation { - DBG_PRINT("MyNSOpenGLLayer::disableAnimation: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink); - pthread_mutex_lock(&renderLock); + DBG_PRINT("MyNSOpenGLLayer::disableAnimation.0: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink); [self setAsynchronous: NO]; if(NULL != displayLink) { #ifdef HAS_CADisplayLink @@ -438,35 +475,63 @@ static const GLfloat gl_verts[] = { #endif displayLink = NULL; } - pthread_mutex_unlock(&renderLock); + DBG_PRINT("MyNSOpenGLLayer::disableAnimation.X: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink); } - (void)releaseLayer { DBG_PRINT("MyNSOpenGLLayer::releaseLayer.0: %p (refcnt %d)\n", self, (int)[self retainCount]); - pthread_mutex_lock(&renderLock); [self disableAnimation]; + pthread_mutex_lock(&renderLock); [self deallocPBuffer]; - [[self openGLContext] release]; + // [[self openGLContext] release]; + if( NULL != myCtx ) { + [myCtx release]; + // [myCtx dealloc]; + myCtx = NULL; + } + parentCtx = NULL; [parentPixelFmt release]; - [self release]; - DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p (refcnt %d)\n", self, (int)[self retainCount]); pthread_mutex_unlock(&renderLock); + [self release]; + DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p\n", self); } +#ifdef DBG_LIFECYCLE + +- (id)retain +{ + DBG_PRINT("MyNSOpenGLLayer::retain.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyNSOpenGLLayer::retain: %@",[NSThread callStackSymbols]); + id o = [super retain]; + DBG_PRINT("MyNSOpenGLLayer::retain.X: %p (refcnt %d)\n", o, (int)[o retainCount]); + return o; +} + +- (oneway void)release +{ + DBG_PRINT("MyNSOpenGLLayer::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyNSOpenGLLayer::release: %@",[NSThread callStackSymbols]); + [super release]; + // DBG_PRINT("MyNSOpenGLLayer::release.X: %p (refcnt %d)\n", self, (int)[self retainCount]); +} + +#endif + - (void)dealloc { DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]); - pthread_mutex_lock(&renderLock); [self disableAnimation]; + pthread_mutex_lock(&renderLock); [self deallocPBuffer]; + // [[self openGLContext] dealloc]; pthread_mutex_unlock(&renderLock); pthread_cond_destroy(&renderSignal); pthread_mutex_destroy(&renderLock); [super dealloc]; - DBG_PRINT("MyNSOpenGLLayer::dealloc.X %p\n", self); + // DBG_PRINT("MyNSOpenGLLayer::dealloc.X %p\n", self); } - (Bool)isGLSourceValid @@ -752,32 +817,27 @@ static const GLfloat gl_verts[] = { @end NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, int gl3ShaderProgramName, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight) { - // This simply crashes after dealloc() has been called .. ie. ref-count -> 0 too early ? - // However using alloc/init, actual dealloc happens at JAWT destruction, hence too later IMHO. - // return [[MyNSOpenGLLayer layer] setupWithContext:ctx pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID - // opaque: opaque texWidth: texWidth texHeight: texHeight]; - return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx gl3ShaderProgramName: (GLuint)gl3ShaderProgramName pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID opaque: opaque texWidth: texWidth texHeight: texHeight]; } void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; [l setSwapInterval: interval]; [pool release]; } void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; [l waitUntilRenderSignal: to_micros]; [pool release]; } void setNSOpenGLLayerNeedsDisplayFBO(NSOpenGLLayer* layer, uint32_t texID) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; Bool shallDraw; // volatile OK @@ -799,8 +859,8 @@ void setNSOpenGLLayerNeedsDisplayFBO(NSOpenGLLayer* layer, uint32_t texID) { } void setNSOpenGLLayerNeedsDisplayPBuffer(NSOpenGLLayer* layer, NSOpenGLPixelBuffer* p) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; Bool shallDraw; if( NO == [l isSamePBuffer: p] ) { @@ -825,16 +885,10 @@ void setNSOpenGLLayerNeedsDisplayPBuffer(NSOpenGLLayer* layer, NSOpenGLPixelBuff } void releaseNSOpenGLLayer(NSOpenGLLayer* layer) { - MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.0: %p\n", l); - - if ( [NSThread isMainThread] == YES ) { - [l releaseLayer]; - } else { - [l performSelectorOnMainThread:@selector(releaseLayer) withObject:nil waitUntilDone:NO]; - } - + [l releaseLayer]; DBG_PRINT("MyNSOpenGLLayer::releaseNSOpenGLLayer.X: %p\n", l); [pool release]; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 8527a0200..007a917a6 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -205,7 +205,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } try { if(DEBUG) { - System.err.println("JAWTWindow.attachSurfaceHandle(): 0x"+Long.toHexString(layerHandle) + ", bounds "+bounds); + System.err.println("JAWTWindow.attachSurfaceHandle(): "+toHexString(layerHandle) + ", bounds "+bounds); } attachSurfaceLayerImpl(layerHandle); offscreenSurfaceLayer = layerHandle; @@ -229,7 +229,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } try { if(DEBUG) { - System.err.println("JAWTWindow.detachSurfaceHandle(): 0x"+Long.toHexString(offscreenSurfaceLayer)); + System.err.println("JAWTWindow.detachSurfaceHandle(): osh "+toHexString(offscreenSurfaceLayer)); } detachSurfaceLayerImpl(offscreenSurfaceLayer); offscreenSurfaceLayer = 0; @@ -341,7 +341,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(LOCK_SUCCESS == res && drawable_old != drawable) { res = LOCK_SURFACE_CHANGED; if(DEBUG) { - System.err.println("JAWTWindow: surface change 0x"+Long.toHexString(drawable_old)+" -> 0x"+Long.toHexString(drawable)); + System.err.println("JAWTWindow: surface change "+toHexString(drawable_old)+" -> "+toHexString(drawable)); // Thread.dumpStack(); } } @@ -549,8 +549,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, StringBuilder sb = new StringBuilder(); sb.append("JAWT-Window["+ - "windowHandle 0x"+Long.toHexString(getWindowHandle())+ - ", surfaceHandle 0x"+Long.toHexString(getSurfaceHandle())+ + "windowHandle "+toHexString(getWindowHandle())+ + ", surfaceHandle "+toHexString(getSurfaceHandle())+ ", bounds "+bounds+", insets "+insets+ ", shallUseOffscreenLayer "+shallUseOffscreenLayer+", isOffscreenLayerSurface "+isOffscreenLayerSurface); if(null!=component) { @@ -566,4 +566,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, return sb.toString(); } + + protected final String toHexString(long l) { + return "0x"+Long.toHexString(l); + } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 2b49f6745..5479f2495 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -38,7 +38,6 @@ import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Control; import javax.media.nativewindow.AbstractGraphicsScreen; -import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowFactory; @@ -49,7 +48,6 @@ import com.jogamp.common.util.VersionNumber; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.nativewindow.windows.WindowsGraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsDevice; -import com.jogamp.nativewindow.x11.X11GraphicsScreen; import jogamp.nativewindow.macosx.OSXUtil; import jogamp.nativewindow.x11.X11Lib; diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 9e270d403..9b06cce1a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -51,6 +51,7 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.Function; import com.jogamp.nativewindow.awt.JAWTWindow; import jogamp.nativewindow.jawt.JAWT; @@ -70,11 +71,40 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } protected void invalidateNative() { + if(DEBUG) { + System.err.println("MacOSXJAWTWindow.invalidateNative(): osh-enabled "+isOffscreenLayerSurfaceEnabled()+ + ", osh-set "+offscreenSurfaceHandleSet+ + ", osh "+toHexString(offscreenSurfaceHandle)+ + ", rsh "+toHexString(rootSurfaceLayerHandle)+ + ", wh "+toHexString(windowHandle)); + } offscreenSurfaceHandle=0; offscreenSurfaceHandleSet=false; - if(isOffscreenLayerSurfaceEnabled()) { + if( isOffscreenLayerSurfaceEnabled() ) { if(0 != rootSurfaceLayerHandle) { + final JAWT jawt = getJAWT(); + if( null != jawt ) { + final JAWT_DrawingSurface ds = jawt.GetDrawingSurface(component); + if (ds != null) { + if ( 0 == ( ds.Lock() & JAWTFactory.JAWT_LOCK_ERROR ) ) { + JAWT_DrawingSurfaceInfo dsi = null; + try { + dsi = ds.GetDrawingSurfaceInfo(); + if(! UnsetJAWTRootSurfaceLayer(dsi.getBuffer(), rootSurfaceLayerHandle)) { + System.err.println("Error clearing JAWT rootSurfaceLayerHandle "+toHexString(rootSurfaceLayerHandle)); + } + } finally { + if ( null != dsi ) { + ds.FreeDrawingSurfaceInfo(dsi); + } + ds.Unlock(); + } + } + jawt.FreeDrawingSurface(ds); + } + } OSXUtil.DestroyCALayer(rootSurfaceLayerHandle); + rootSurfaceLayerHandle = 0; } if(0 != windowHandle) { @@ -107,7 +137,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { throw new java.lang.UnsupportedOperationException("Not using CALAYER"); } if(DEBUG) { - System.err.println("MacOSXJAWTWindow.setSurfaceHandle(): 0x"+Long.toHexString(surfaceHandle)); + System.err.println("MacOSXJAWTWindow.setSurfaceHandle(): "+toHexString(surfaceHandle)); } this.offscreenSurfaceHandle = surfaceHandle; this.offscreenSurfaceHandleSet = true; @@ -117,6 +147,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { // use offscreen if supported and [ applet or requested ] return JAWTUtil.getJAWT(getShallUseOffscreenLayer() || isApplet()); } + protected int lockSurfaceImpl() throws NativeWindowException { int ret = NativeWindow.LOCK_SURFACE_NOT_READY; ds = getJAWT().GetDrawingSurface(component); @@ -189,7 +220,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { } else { drawable = OSXUtil.GetNSView(windowHandle); if(0 == drawable) { - errMsg = "Null NSView of NSWindow 0x"+Long.toHexString(windowHandle); + errMsg = "Null NSView of NSWindow "+toHexString(windowHandle); } } if(null == errMsg) { @@ -204,8 +235,8 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { rootSurfaceLayerHandle = OSXUtil.CreateCALayer(bounds.getX(), bounds.getY(), bounds.getWidth(), bounds.getHeight()); if(0 == rootSurfaceLayerHandle) { errMsg = "Could not create root CALayer"; - } else if(!SetJAWTRootSurfaceLayer0(dsi.getBuffer(), rootSurfaceLayerHandle)) { - errMsg = "Could not set JAWT rootSurfaceLayerHandle 0x"+Long.toHexString(rootSurfaceLayerHandle); + } else if(!SetJAWTRootSurfaceLayer(dsi.getBuffer(), rootSurfaceLayerHandle)) { + errMsg = "Could not set JAWT rootSurfaceLayerHandle "+toHexString(rootSurfaceLayerHandle); } } } @@ -265,9 +296,23 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { return getLocationOnScreenNonBlocking(storage, component); } protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; } + + private static boolean SetJAWTRootSurfaceLayer(final Buffer jawtDrawingSurfaceInfoBuffer, final long caLayer) { + return OSXUtil.RunOnMainThread(true, new Function() { + public Boolean eval(Object... args) { + return Boolean.valueOf( SetJAWTRootSurfaceLayer0(jawtDrawingSurfaceInfoBuffer, caLayer) ); + } } ).booleanValue(); + } + + private static boolean UnsetJAWTRootSurfaceLayer(final Buffer jawtDrawingSurfaceInfoBuffer, final long caLayer) { + return OSXUtil.RunOnMainThread(true, new Function() { + public Boolean eval(Object... args) { + return Boolean.valueOf( UnsetJAWTRootSurfaceLayer0(jawtDrawingSurfaceInfoBuffer, caLayer) ); + } } ).booleanValue(); + } private static native boolean SetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); - // private static native boolean UnsetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); + private static native boolean UnsetJAWTRootSurfaceLayer0(Buffer jawtDrawingSurfaceInfoBuffer, long caLayer); // Variables for lockSurface/unlockSurface private JAWT_DrawingSurface ds; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index f06f97064..2e133c22f 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -32,6 +32,8 @@ import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.Function; +import com.jogamp.common.util.FunctionTask; import com.jogamp.common.util.RunnableTask; import jogamp.nativewindow.Debug; @@ -137,23 +139,33 @@ public class OSXUtil implements ToolkitProperties { public static long CreateCALayer(int x, int y, int width, int height) { return CreateCALayer0(x, y, width, height); } - public static void AddCASublayer(long rootCALayer, long subCALayer) { + public static void AddCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } - AddCASublayer0(rootCALayer, subCALayer); + RunOnMainThread(true, new Runnable() { + public void run() { + AddCASublayer0(rootCALayer, subCALayer); + } + }); } - public static void RemoveCASublayer(long rootCALayer, long subCALayer) { + public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } - RemoveCASublayer0(rootCALayer, subCALayer); + RunOnMainThread(true, new Runnable() { + public void run() { + RemoveCASublayer0(rootCALayer, subCALayer); + } } ); } - public static void DestroyCALayer(long caLayer) { + public static void DestroyCALayer(final long caLayer) { if(0==caLayer) { throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer)); } - DestroyCALayer0(caLayer); + RunOnMainThread(true, new Runnable() { + public void run() { + DestroyCALayer0(caLayer); + } } ); } /** @@ -169,14 +181,14 @@ public class OSXUtil implements ToolkitProperties { if( IsMainThread0() ) { runnable.run(); // don't leave the JVM } else { - if( waitUntilDone ) { - // Utilize Java side lock/wait and simply pass the Runnable async to OSX main thread, - // otherwise we may freeze the OSX main thread. - Throwable throwable = null; - final Object sync = new Object(); - final RunnableTask rt = new RunnableTask( runnable, sync, true ); - synchronized(sync) { - RunOnMainThread0(rt); + // Utilize Java side lock/wait and simply pass the Runnable async to OSX main thread, + // otherwise we may freeze the OSX main thread. + Throwable throwable = null; + final Object sync = new Object(); + final RunnableTask rt = new RunnableTask( runnable, waitUntilDone ? sync : null, true ); + synchronized(sync) { + RunOnMainThread0(rt); + if( waitUntilDone ) { try { sync.wait(); } catch (InterruptedException ie) { @@ -188,10 +200,47 @@ public class OSXUtil implements ToolkitProperties { if(null!=throwable) { throw new RuntimeException(throwable); } - } - } else { - RunOnMainThread0(runnable); + } + } + } + } + + /** + * Run on OSX UI main thread. + *

    + * 'waitUntilDone' is implemented on Java site via lock/wait on {@link FunctionTask} to not freeze OSX main thread. + *

    + * + * @param waitUntilDone + * @param func + */ + public static R RunOnMainThread(boolean waitUntilDone, Function func, A... args) { + if( IsMainThread0() ) { + return func.eval(args); // don't leave the JVM + } else { + // Utilize Java side lock/wait and simply pass the Runnable async to OSX main thread, + // otherwise we may freeze the OSX main thread. + Throwable throwable = null; + final Object sync = new Object(); + final FunctionTask rt = new FunctionTask( func, waitUntilDone ? sync : null, true ); + synchronized(sync) { + rt.setArgs(args); + RunOnMainThread0(rt); + if( waitUntilDone ) { + try { + sync.wait(); + } catch (InterruptedException ie) { + throwable = ie; + } + if(null==throwable) { + throwable = rt.getThrowable(); + } + if(null!=throwable) { + throw new RuntimeException(throwable); + } + } } + return rt.getResult(); } } diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 72bb2338c..3fa320042 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -49,6 +49,16 @@ #define DBG_PRINT(...) #endif +// #define VERBOSE2 1 +// +#ifdef VERBOSE2 + #define DBG_PRINT2(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) +#else + #define DBG_PRINT2(...) +#endif + +// #define DBG_LIFECYCLE 1 + static const char * const ClazzNameRunnable = "java/lang/Runnable"; static jmethodID runnableRunID = NULL; @@ -324,7 +334,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; CALayer* layer = [[CALayer alloc] init]; - DBG_PRINT("CALayer::CreateCALayer.0: %p %d/%d %dx%d (refcnt %d)\n", layer, (int)x, (int)y, (int)width, (int)height, (int)[layer retainCount]); + DBG_PRINT("CALayer::CreateCALayer.0: root %p %d/%d %dx%d (refcnt %d)\n", layer, (int)x, (int)y, (int)width, (int)height, (int)[layer retainCount]); // avoid zero size if(0 == width) { width = 32; } if(0 == height) { height = 32; } @@ -341,8 +351,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 [layer removeAllAnimations]; [layer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [layer setNeedsDisplayOnBoundsChange: YES]; - DBG_PRINT("CALayer::CreateCALayer.1: %p %lf/%lf %lfx%lf\n", layer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); - DBG_PRINT("CALayer::CreateCALayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); + DBG_PRINT("CALayer::CreateCALayer.1: root %p %lf/%lf %lfx%lf\n", layer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + DBG_PRINT("CALayer::CreateCALayer.X: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); [pool release]; @@ -367,30 +377,28 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 if(lRectRoot.origin.x!=0 || lRectRoot.origin.y!=0) { lRectRoot.origin.x = 0; lRectRoot.origin.y = 0; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - [rootLayer setFrame: lRectRoot]; - }]; + [rootLayer setFrame: lRectRoot]; DBG_PRINT("CALayer::AddCASublayer0.1: Origin %p frame*: %lf/%lf %lfx%lf\n", rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height); } - DBG_PRINT("CALayer::AddCASublayer0.2: %p . %p %lf/%lf %lfx%lf (refcnt %d)\n", - rootLayer, subLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (int)[subLayer retainCount]); - - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - // simple 1:1 layout ! - [subLayer setFrame:lRectRoot]; - [rootLayer addSublayer:subLayer]; - - // no animations for add/remove/swap sublayers etc - // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] - [rootLayer removeAllAnimations]; - [rootLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; - [rootLayer setNeedsDisplayOnBoundsChange: YES]; - [subLayer removeAllAnimations]; - [subLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; - [subLayer setNeedsDisplayOnBoundsChange: YES]; - }]; - DBG_PRINT("CALayer::AddCASublayer0.X: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]); + DBG_PRINT("CALayer::AddCASublayer0.2: root %p (refcnt %d) .sub %p %lf/%lf %lfx%lf (refcnt %d)\n", + rootLayer, (int)[rootLayer retainCount], + subLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (int)[subLayer retainCount]); + + // simple 1:1 layout ! + [subLayer setFrame:lRectRoot]; + [rootLayer addSublayer:subLayer]; + + // no animations for add/remove/swap sublayers etc + // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] + [rootLayer removeAllAnimations]; + [rootLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [rootLayer setNeedsDisplayOnBoundsChange: YES]; + [subLayer removeAllAnimations]; + [subLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; + [subLayer setNeedsDisplayOnBoundsChange: YES]; + DBG_PRINT("CALayer::AddCASublayer0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n", + rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); JNF_COCOA_EXIT(env); } @@ -408,11 +416,12 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0 (void)rootLayer; // no warnings - DBG_PRINT("CALayer::RemoveCASublayer0.0: %p . %p (refcnt %d)\n", rootLayer, subLayer, (int)[subLayer retainCount]); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - [subLayer removeFromSuperlayer]; - }]; - DBG_PRINT("CALayer::RemoveCASublayer0.X: %p . %p\n", rootLayer, subLayer); + DBG_PRINT("CALayer::RemoveCASublayer0.0: root %p (refcnt %d) .sub %p (refcnt %d)\n", + rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); + [subLayer removeFromSuperlayer]; + [subLayer release]; + DBG_PRINT("CALayer::RemoveCASublayer0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n", + rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); JNF_COCOA_EXIT(env); } @@ -427,11 +436,10 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0 JNF_COCOA_ENTER(env); CALayer* layer = (CALayer*) ((intptr_t) caLayer); - DBG_PRINT("CALayer::DestroyCALayer0.0: %p (refcnt %d)\n", layer, (int)[layer retainCount]); - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - [layer release]; // performs release! - }]; - DBG_PRINT("CALayer::DestroyCALayer0.X: %p\n", layer); + DBG_PRINT("CALayer::DestroyCALayer0.0: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); + [layer release]; // Var.A + // [layer dealloc]; // Var.B -> SIGSEGV + DBG_PRINT("CALayer::DestroyCALayer0.X: root %p\n", layer); JNF_COCOA_EXIT(env); } @@ -450,12 +458,10 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow return JNI_FALSE; } CALayer* layer = (CALayer*) (intptr_t) caLayer; - [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - id surfaceLayers = (id )dsi->platformInfo; - DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: %p -> %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); - surfaceLayers.layer = layer; // already incr. retain count - DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.X: %p (refcnt %d)\n", layer, (int)[layer retainCount]); - }]; + id surfaceLayers = (id )dsi->platformInfo; + DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: pre %p -> root %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); + surfaceLayers.layer = layer; // already incr. retain count + DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.X: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); JNF_COCOA_EXIT(env); return JNI_TRUE; } @@ -464,6 +470,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow * Class: Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow * Method: UnsetJAWTRootSurfaceLayer0 * Signature: (JJ)Z + */ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_UnsetJAWTRootSurfaceLayer0 (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) { @@ -474,23 +481,18 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow return JNI_FALSE; } CALayer* layer = (CALayer*) (intptr_t) caLayer; - { - id surfaceLayers = (id )dsi->platformInfo; - if(layer != surfaceLayers.layer) { - NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); - return JNI_FALSE; - } + id surfaceLayers = (id )dsi->platformInfo; + if(layer != surfaceLayers.layer) { + NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); + return JNI_FALSE; } - // [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){ - id surfaceLayers = (id )dsi->platformInfo; - DBG_PRINT("CALayer::detachJAWTSurfaceLayer: (%p) %p -> NULL\n", layer, surfaceLayers.layer); - surfaceLayers.layer = NULL; - [layer release]; - // }]; + DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.0: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]); + surfaceLayers.layer = NULL; + [layer release]; // Var.A + DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.X: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]); JNF_COCOA_EXIT(env); return JNI_TRUE; } - */ @interface MainRunnable : NSObject @@ -503,6 +505,13 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow - (id) initWithRunnable: (jobject)runnable jvmHandle: (JavaVM*)jvm jvmVersion: (int)jvmVers; - (void) jRun; +#ifdef DBG_LIFECYCLE +- (id)retain; +- (oneway void)release; +- (void)dealloc; +#endif + + @end @implementation MainRunnable @@ -519,20 +528,47 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow { int shallBeDetached = 0; JNIEnv* env = NativewindowCommon_GetJNIEnv(jvmHandle, jvmVersion, &shallBeDetached); - DBG_PRINT("MainRunnable.0 env: %d\n", (int)(NULL!=env)); + DBG_PRINT2("MainRunnable.1 env: %d\n", (int)(NULL!=env)); if(NULL!=env) { - DBG_PRINT("MainRunnable.1.0\n"); + DBG_PRINT2("MainRunnable.1.0\n"); (*env)->CallVoidMethod(env, runnableObj, runnableRunID); - DBG_PRINT("MainRunnable.1.1\n"); + DBG_PRINT2("MainRunnable.1.1\n"); + (*env)->DeleteGlobalRef(env, runnableObj); if (shallBeDetached) { - DBG_PRINT("MainRunnable.1.2\n"); + DBG_PRINT2("MainRunnable.1.3\n"); (*jvmHandle)->DetachCurrentThread(jvmHandle); } } - DBG_PRINT("MainRunnable.X\n"); + DBG_PRINT2("MainRunnable.X\n"); +} + +#ifdef DBG_LIFECYCLE + +- (id)retain +{ + DBG_PRINT2("MainRunnable::retain.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + id o = [super retain]; + DBG_PRINT2("MainRunnable::retain.X: %p (refcnt %d)\n", o, (int)[o retainCount]); + return o; +} + +- (oneway void)release +{ + DBG_PRINT2("MainRunnable::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + [super release]; + // DBG_PRINT2("MainRunnable::release.X: %p (refcnt %d)\n", self, (int)[self retainCount]); } +- (void)dealloc +{ + DBG_PRINT2("MainRunnable::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); + [super dealloc]; + // DBG_PRINT2("MainRunnable.dealloc.X: %p\n", self); +} + +#endif + @end @@ -546,11 +582,11 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RunOnMainThread0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - DBG_PRINT( "RunOnMainThread0: isMainThread %d, NSApp %d, NSApp-isRunning %d\n", + DBG_PRINT2( "RunOnMainThread0: isMainThread %d, NSApp %d, NSApp-isRunning %d\n", (int)([NSThread isMainThread]), (int)(NULL!=NSApp), (int)([NSApp isRunning])); if ( NO == [NSThread isMainThread] ) { - jobject runnableGlob = (*env)->NewGlobalRef(env, runnable); + jobject runnableObj = (*env)->NewGlobalRef(env, runnable); JavaVM *jvmHandle = NULL; int jvmVersion = 0; @@ -561,18 +597,18 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RunOnMainThread0 jvmVersion = (*env)->GetVersion(env); } - DBG_PRINT( "RunOnMainThread0.1.0\n"); - MainRunnable * mr = [[MainRunnable alloc] initWithRunnable: runnableGlob jvmHandle: jvmHandle jvmVersion: jvmVersion]; + DBG_PRINT2( "RunOnMainThread0.1.0\n"); + MainRunnable * mr = [[MainRunnable alloc] initWithRunnable: runnableObj jvmHandle: jvmHandle jvmVersion: jvmVersion]; [mr performSelectorOnMainThread:@selector(jRun) withObject:nil waitUntilDone:NO]; + DBG_PRINT2( "RunOnMainThread0.1.1\n"); [mr release]; - DBG_PRINT( "RunOnMainThread0.1.1\n"); + DBG_PRINT2( "RunOnMainThread0.1.2\n"); - (*env)->DeleteGlobalRef(env, runnableGlob); } else { - DBG_PRINT( "RunOnMainThread0.2\n"); + DBG_PRINT2( "RunOnMainThread0.2\n"); (*env)->CallVoidMethod(env, runnable, runnableRunID); } - DBG_PRINT( "RunOnMainThread0.X\n"); + DBG_PRINT2( "RunOnMainThread0.X\n"); [pool release]; } @@ -644,7 +680,7 @@ JNIEXPORT jint JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenRefreshR if(0 == res) { res = 60; // default .. (experienced on OSX 10.6.8) } - DBG_PRINT(stderr, "GetScreenRefreshRate.X: %d\n", (int)res); + DBG_PRINT("GetScreenRefreshRate.X: %d\n", (int)res); // [pool release]; JNF_COCOA_EXIT(env); return res; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAddRemove01SwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAddRemove01SwingAWT.java new file mode 100644 index 000000000..76bb6362f --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAddRemove01SwingAWT.java @@ -0,0 +1,257 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.UITestCase; + +public class TestGLCanvasAddRemove01SwingAWT extends UITestCase { + static long durationPerTest = 50; + static int addRemoveCount = 15; + static boolean shallUseOffscreenFBOLayer = false; + static boolean shallUseOffscreenPBufferLayer = false; + static GLProfile glp; + static int width, height; + static boolean waitForKey = false; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2)) { + glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + width = 640; + height = 480; + } else { + setTestSupported(false); + } + } + + @AfterClass + public static void releaseClass() { + } + + protected JPanel createParkingSlot(final JFrame[] top, final int width, final int height) + throws InterruptedException, InvocationTargetException + { + final JPanel[] jPanel = new JPanel[] { null }; + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jPanel[0] = new JPanel(); + jPanel[0].setLayout(new BorderLayout()); + + final JFrame jFrame1 = new JFrame("Parking Slot"); + // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! + jFrame1.getContentPane().add(jPanel[0]); + jFrame1.setSize(width, height); + + top[0] = jFrame1; + } } ); + return jPanel[0]; + } + + protected JPanel create(final JFrame[] top, final int width, final int height, final int num) + throws InterruptedException, InvocationTargetException + { + final JPanel[] jPanel = new JPanel[] { null }; + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jPanel[0] = new JPanel(); + jPanel[0].setLayout(new BorderLayout()); + // jPanel[0].add(glcContainer[0], BorderLayout.CENTER); + + // final Container container2 = new Container(); + // container2.setLayout(new BorderLayout()); + // container2.add(jPanel1, BorderLayout.CENTER); + + final JPanel jPanel2 = new JPanel(); + jPanel2.setLayout(new BorderLayout()); + // jPanel2.add(container2, BorderLayout.CENTER); + jPanel2.add(jPanel[0], BorderLayout.CENTER); + + final JFrame jFrame1 = new JFrame("JFrame #"+num); + // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! + jFrame1.getContentPane().add(jPanel2); + jFrame1.setSize(width, height); + + top[0] = jFrame1; + } } ); + return jPanel[0]; + } + + protected void add(final Container cont, final Component comp) + throws InterruptedException, InvocationTargetException + { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + cont.add(comp, BorderLayout.CENTER); + } } ); + } + + protected void remove(final Container cont, final Component comp) + throws InterruptedException, InvocationTargetException + { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + cont.remove(comp); + } } ); + } + protected void dispose(final GLCanvas glc) + throws InterruptedException, InvocationTargetException + { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + glc.destroy(); + } } ); + } + + protected void setVisible(final JFrame jFrame, final boolean visible) throws InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + if( visible ) { + jFrame.validate(); + jFrame.pack(); + } + jFrame.setVisible(visible); + } } ) ; + } + + protected void dispose(final JFrame jFrame) throws InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jFrame.dispose(); + } } ) ; + } + + protected void runTestGL(GLCapabilities caps, int addRemoveOpCount) + throws AWTException, InterruptedException, InvocationTargetException + { + + // final JFrame[] parkingFrame = new JFrame[] { null }; + // final JPanel parkingPanel = createParkingSlot(parkingFrame, 2, 2); + + for(int i=0; i Date: Fri, 15 Feb 2013 17:15:49 +0100 Subject: Fix Bug 691 (part-2): Extra '[subLayer release]' is wrong, since 'CGL.releaseNSOpenGLLayer' triggers release - but very late w/ AWT usage. OSXUtil_RemoveCASublayer0's added '[subLayer release]' in commit f6e6fab2a7ddfb5c9b614cb072c27ff697629161 is wrong, since 'CGL.releaseNSOpenGLLayer' actually does trigger it's release. This was not seen w/ AWT tests, since it happens very later. A NewtCanvasAWT test disclosed this error -> removed that extra release call. The culprit for the late release w/ AWT usage was CGL.createNSOpenGLLayer's call in the current thread. Moving it to the Main-Thread fixed the problem. All CALayer lifecycle calls are issued on the Main-Thread now. NSOpenGLLayer's CVDisplayLink OpenGL fitting via 'CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext' is now performed at it's context creation in 'NSOpenGLLayer::openGLContextForPixelFormat'. The 'extra' release of the NSOpenGLLayer's NSOpenGLContext as introduced in commit f6e6fab2a7ddfb5c9b614cb072c27ff697629161 is still valid. --- make/config/jogl/cgl-macosx-CustomJavaCode.java | 22 ++ make/config/jogl/cgl-macosx.cfg | 9 + make/scripts/tests.sh | 11 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 5 +- .../macosx/MacOSXWindowSystemInterface-calayer.m | 25 ++- .../jogamp/nativewindow/macosx/OSXUtil.java | 16 +- src/nativewindow/native/macosx/OSXmisc.m | 119 +++++++++-- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 5 +- .../acore/TestOffscreenLayer01GLCanvasAWT.java | 15 +- .../acore/TestOffscreenLayer02NewtCanvasAWT.java | 16 +- .../jogl/awt/TestGLCanvasAddRemove01SwingAWT.java | 53 ++--- .../awt/TestGLCanvasAddRemove02NewtCanvasAWT.java | 238 +++++++++++++++++++++ .../jogamp/opengl/test/junit/util/UITestCase.java | 11 + 13 files changed, 438 insertions(+), 107 deletions(-) create mode 100644 make/config/jogl/cgl-macosx-CustomJavaCode.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAddRemove02NewtCanvasAWT.java (limited to 'make/scripts') diff --git a/make/config/jogl/cgl-macosx-CustomJavaCode.java b/make/config/jogl/cgl-macosx-CustomJavaCode.java new file mode 100644 index 000000000..b9a37d0c6 --- /dev/null +++ b/make/config/jogl/cgl-macosx-CustomJavaCode.java @@ -0,0 +1,22 @@ + +/** + * Creates the NSOpenGLLayer for FBO/PBuffer w/ optional GL3 shader program on Main-Thread + */ +public static long createNSOpenGLLayer(final long ctx, final int gl3ShaderProgramName, final long fmt, final long p, + final int texID, final boolean opaque, final int texWidth, final int texHeight) { + return OSXUtil.RunOnMainThread(true, new Function() { + public Long eval(Object... args) { + return Long.valueOf( createNSOpenGLLayerImpl(ctx, gl3ShaderProgramName, fmt, p, texID, opaque, texWidth, texHeight) ); + } } ).longValue(); +} + +/** + * Releases the NSOpenGLLayer on Main-Thread + */ +public static void releaseNSOpenGLLayer(final long nsOpenGLLayer) { + OSXUtil.RunOnMainThread(true, new Runnable() { + public void run() { + releaseNSOpenGLLayerImpl(nsOpenGLLayer); + } } ); +} + diff --git a/make/config/jogl/cgl-macosx.cfg b/make/config/jogl/cgl-macosx.cfg index 203802d29..98123f605 100644 --- a/make/config/jogl/cgl-macosx.cfg +++ b/make/config/jogl/cgl-macosx.cfg @@ -34,6 +34,13 @@ Opaque long NSOpenGLLayer * CustomCCode #include CustomCCode #include "macosx-window-system.h" +AccessControl createNSOpenGLLayerImpl PRIVATE +AccessControl releaseNSOpenGLLayerImpl PRIVATE +RenameJavaMethod createNSOpenGLLayer createNSOpenGLLayerImpl +RenameJavaMethod releaseNSOpenGLLayer releaseNSOpenGLLayerImpl + +IncludeAs CustomJavaCode CGL cgl-macosx-CustomJavaCode.java + # Implement the first argument to getProcAddress as String instead # of byte[] ArgumentIsString getProcAddress 0 @@ -53,3 +60,5 @@ DropUniqVendorExtensions SGIX DropUniqVendorExtensions SUN DropUniqVendorExtensions WIN +Import com.jogamp.common.util.Function +Import jogamp.nativewindow.macosx.OSXUtil diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 198a8f2e6..5f5248156 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -34,7 +34,7 @@ uname -a | grep -i Darwin && MOSX=1 if [ $MOSX -eq 1 ] ; then echo setup OSX environment vars #export NSZombieEnabled=YES - export NSTraceEvents=YES + #export NSTraceEvents=YES #export OBJC_PRINT_EXCEPTIONS=YES echo NSZombieEnabled $NSZombieEnabled 2>&1 | tee -a java-run.log echo NSTraceEvents $NSTraceEvents 2>&1 | tee -a java-run.log @@ -89,7 +89,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch -Dnativewindow.debug.JAWT" + #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" @@ -311,6 +311,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove01SwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove02NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -416,11 +418,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove01SwingAWT $* - #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 0deaa2987..838a0387d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -709,10 +709,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl // still having a valid OLS attached to surface (parent OLS could have been removed) ols.detachSurfaceLayer(); } - OSXUtil.RunOnMainThread(true, new Runnable() { - public void run() { - CGL.releaseNSOpenGLLayer(nsOpenGLLayer); - } } ); + CGL.releaseNSOpenGLLayer(nsOpenGLLayer); if( null != gl3ShaderProgram ) { gl3ShaderProgram.destroy(MacOSXCGLContext.this.gl.getGL3()); gl3ShaderProgram = null; diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 4334fc676..8d1286169 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -75,8 +75,11 @@ extern GLboolean glIsVertexArray (GLuint array); - (void)setView:(NSView *)view { DBG_PRINT("MyNSOpenGLContext.setView: this.0 %p, view %p\n", self, view); + // NSLog(@"MyNSOpenGLContext::setView: %@",[NSThread callStackSymbols]); if(NULL != view) { [super setView:view]; + } else { + [self clearDrawable]; } DBG_PRINT("MyNSOpenGLContext.setView.X\n"); } @@ -301,13 +304,6 @@ static const GLfloat gl_verts[] = { displayLink = NULL; } } - if(NULL != displayLink) { - cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [parentCtx CGLContextObj], [parentPixelFmt CGLPixelFormatObj]); - if(kCVReturnSuccess != cvres) { - DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); - displayLink = NULL; - } - } if(NULL != displayLink) { cvres = CVDisplayLinkSetOutputCallback(displayLink, renderMyNSOpenGLLayer, self); if(kCVReturnSuccess != cvres) { @@ -453,10 +449,20 @@ static const GLfloat gl_verts[] = { - (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat { - DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.0: %p (refcnt %d) - pfmt %p, parent %p\n", - self, (int)[self retainCount], pixelFormat, parentCtx); + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.0: %p (refcnt %d) - pfmt %p, parent %p, DisplayLink %p\n", + self, (int)[self retainCount], pixelFormat, parentCtx, displayLink); // NSLog(@"MyNSOpenGLLayer::openGLContextForPixelFormat: %@",[NSThread callStackSymbols]); myCtx = [[MyNSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; +#ifndef HAS_CADisplayLink + if(NULL != displayLink) { + CVReturn cvres; + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.1: setup DisplayLink %p\n", displayLink); + cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [myCtx CGLContextObj], [pixelFormat CGLPixelFormatObj]); + if(kCVReturnSuccess != cvres) { + DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); + } + } +#endif DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.X: new-ctx %p\n", myCtx); return myCtx; } @@ -487,7 +493,6 @@ static const GLfloat gl_verts[] = { // [[self openGLContext] release]; if( NULL != myCtx ) { [myCtx release]; - // [myCtx dealloc]; myCtx = NULL; } parentCtx = NULL; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 2e133c22f..b765a68c3 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -136,8 +136,11 @@ public class OSXUtil implements ToolkitProperties { return GetNSWindow0(nsView); } - public static long CreateCALayer(int x, int y, int width, int height) { - return CreateCALayer0(x, y, width, height); + public static long CreateCALayer(final int x, final int y, final int width, final int height) { + return OSXUtil.RunOnMainThread(true, new Function() { + public Long eval(Object... args) { + return Long.valueOf( CreateCALayer0(x, y, width, height) ); + } } ).longValue(); } public static void AddCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { @@ -145,7 +148,7 @@ public class OSXUtil implements ToolkitProperties { } RunOnMainThread(true, new Runnable() { public void run() { - AddCASublayer0(rootCALayer, subCALayer); + AddCASublayer0(rootCALayer, subCALayer); } }); } @@ -205,6 +208,13 @@ public class OSXUtil implements ToolkitProperties { } } + private static Runnable _nop = new Runnable() { public void run() {}; }; + + /** Issues a {@link #RunOnMainThread(boolean, Runnable)} w/ an NOP runnable, while waiting until done. */ + public static void WaitUntilFinish() { + RunOnMainThread(true, _nop); + } + /** * Run on OSX UI main thread. *

    diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 3fa320042..83f3c821f 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -32,6 +32,7 @@ #include #include #include +#import #include "NativewindowCommon.h" #include "jogamp_nativewindow_macosx_OSXUtil.h" @@ -323,6 +324,64 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 return res; } +/** + * Track lifecycle via DBG_PRINT messages, if VERBOSE is enabled! + */ +@interface MyCALayer: CALayer +{ +} +- (id)init; +#ifdef DBG_LIFECYCLE +- (id)retain; +- (oneway void)release; +- (void)dealloc; +#endif + +@end + +@implementation MyCALayer + +- (id)init +{ + DBG_PRINT("MyCALayer.0\n"); + MyCALayer * o = [super init]; + DBG_PRINT("MyNSOpenGLContext.init.X: new %p\n", o); + DBG_PRINT("MyCALayer.0\n"); + return o; +} + +#ifdef DBG_LIFECYCLE + +- (id)retain +{ + DBG_PRINT("MyCALayer::retain.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyCALayer::retain: %@",[NSThread callStackSymbols]); + id o = [super retain]; + DBG_PRINT("MyCALayer::retain.X: %p (refcnt %d)\n", o, (int)[o retainCount]); + return o; +} + +- (oneway void)release +{ + DBG_PRINT("MyCALayer::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyCALayer::release: %@",[NSThread callStackSymbols]); + [super release]; + // DBG_PRINT("MyCALayer::release.X: %p (refcnt %d)\n", self, (int)[self retainCount]); +} + +- (void)dealloc +{ + DBG_PRINT("MyCALayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); + // NSLog(@"MyCALayer::dealloc: %@",[NSThread callStackSymbols]); + [super dealloc]; + // DBG_PRINT("MyCALayer.dealloc.X: %p\n", self); +} + +#endif + + +@end + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateCALayer0 @@ -333,7 +392,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - CALayer* layer = [[CALayer alloc] init]; + MyCALayer* layer = [[MyCALayer alloc] init]; DBG_PRINT("CALayer::CreateCALayer.0: root %p %d/%d %dx%d (refcnt %d)\n", layer, (int)x, (int)y, (int)width, (int)height, (int)[layer retainCount]); // avoid zero size if(0 == width) { width = 32; } @@ -349,12 +408,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [layer removeAllAnimations]; + // [layer addAnimation:nil forKey:kCATransition]; [layer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [layer setNeedsDisplayOnBoundsChange: YES]; DBG_PRINT("CALayer::CreateCALayer.1: root %p %lf/%lf %lfx%lf\n", layer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); - DBG_PRINT("CALayer::CreateCALayer.X: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); - [pool release]; + DBG_PRINT("CALayer::CreateCALayer.X: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); return (jlong) ((intptr_t) layer); } @@ -367,8 +426,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer) { - JNF_COCOA_ENTER(env); - CALayer* rootLayer = (CALayer*) ((intptr_t) rootCALayer); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); CGRect lRectRoot = [rootLayer frame]; @@ -385,6 +444,9 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 rootLayer, (int)[rootLayer retainCount], subLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (int)[subLayer retainCount]); + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + // simple 1:1 layout ! [subLayer setFrame:lRectRoot]; [rootLayer addSublayer:subLayer]; @@ -392,14 +454,19 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [rootLayer removeAllAnimations]; + // [rootLayer addAnimation:nil forKey:kCATransition]; [rootLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [rootLayer setNeedsDisplayOnBoundsChange: YES]; [subLayer removeAllAnimations]; + // [sublayer addAnimation:nil forKey:kCATransition]; [subLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [subLayer setNeedsDisplayOnBoundsChange: YES]; + + [CATransaction commit]; + + [pool release]; DBG_PRINT("CALayer::AddCASublayer0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n", rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); - JNF_COCOA_EXIT(env); } /* @@ -410,19 +477,26 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0 (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer) { - JNF_COCOA_ENTER(env); - CALayer* rootLayer = (CALayer*) ((intptr_t) rootCALayer); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); (void)rootLayer; // no warnings DBG_PRINT("CALayer::RemoveCASublayer0.0: root %p (refcnt %d) .sub %p (refcnt %d)\n", rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + [subLayer removeFromSuperlayer]; - [subLayer release]; + // [subLayer release] is called explicitly, e.g. via CGL.releaseNSOpenGLLayer(..) (MyNSOpenGLLayer::releaseLayer) + + [CATransaction commit]; + + [pool release]; DBG_PRINT("CALayer::RemoveCASublayer0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n", rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); - JNF_COCOA_EXIT(env); } /* @@ -433,14 +507,13 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0 JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0 (JNIEnv *env, jclass unused, jlong caLayer) { - JNF_COCOA_ENTER(env); - CALayer* layer = (CALayer*) ((intptr_t) caLayer); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyCALayer* layer = (MyCALayer*) ((intptr_t) caLayer); DBG_PRINT("CALayer::DestroyCALayer0.0: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); - [layer release]; // Var.A - // [layer dealloc]; // Var.B -> SIGSEGV + [layer release]; // Trigger release of root CALayer + [pool release]; DBG_PRINT("CALayer::DestroyCALayer0.X: root %p\n", layer); - JNF_COCOA_EXIT(env); } /* @@ -451,18 +524,18 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_DestroyCALayer0 JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_SetJAWTRootSurfaceLayer0 (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) { - JNF_COCOA_ENTER(env); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); if (NULL == dsi) { NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); return JNI_FALSE; } - CALayer* layer = (CALayer*) (intptr_t) caLayer; + MyCALayer* layer = (MyCALayer*) (intptr_t) caLayer; id surfaceLayers = (id )dsi->platformInfo; DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.0: pre %p -> root %p (refcnt %d)\n", surfaceLayers.layer, layer, (int)[layer retainCount]); - surfaceLayers.layer = layer; // already incr. retain count + surfaceLayers.layer = [layer retain]; // Pairs w/ Unset + [pool release]; DBG_PRINT("CALayer::SetJAWTRootSurfaceLayer.X: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); - JNF_COCOA_EXIT(env); return JNI_TRUE; } @@ -474,23 +547,23 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow_UnsetJAWTRootSurfaceLayer0 (JNIEnv *env, jclass unused, jobject jawtDrawingSurfaceInfoBuffer, jlong caLayer) { - JNF_COCOA_ENTER(env); + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; JAWT_DrawingSurfaceInfo* dsi = (JAWT_DrawingSurfaceInfo*) (*env)->GetDirectBufferAddress(env, jawtDrawingSurfaceInfoBuffer); if (NULL == dsi) { NativewindowCommon_throwNewRuntimeException(env, "Argument \"jawtDrawingSurfaceInfoBuffer\" was not a direct buffer"); return JNI_FALSE; } - CALayer* layer = (CALayer*) (intptr_t) caLayer; + MyCALayer* layer = (MyCALayer*) (intptr_t) caLayer; id surfaceLayers = (id )dsi->platformInfo; if(layer != surfaceLayers.layer) { NativewindowCommon_throwNewRuntimeException(env, "Attached layer %p doesn't match given layer %p\n", surfaceLayers.layer, layer); return JNI_FALSE; } DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.0: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]); + [layer release]; // Pairs w/ Set surfaceLayers.layer = NULL; - [layer release]; // Var.A + [pool release]; DBG_PRINT("CALayer::UnsetJAWTRootSurfaceLayer.X: root %p (refcnt %d) -> nil\n", layer, (int)[layer retainCount]); - JNF_COCOA_EXIT(env); return JNI_TRUE; } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 89a749c51..6fc5a46ce 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -397,11 +397,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont); } + // Detach OLS early.. final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); if(null != ols && ols.isSurfaceLayerAttached()) { ols.detachSurfaceLayer(); - } - reparentWindow(false, cont); + } + reparentWindow(false, cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) if(null != jawtWindow) { NewtFactoryAWT.destroyNativeWindow(jawtWindow); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java index 90407166f..8cc094276 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer01GLCanvasAWT.java @@ -33,9 +33,7 @@ import java.awt.Button; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLAnimatorControl; @@ -70,6 +68,7 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { static Dimension frameSize1; static Dimension preferredGLSize; static long durationPerTest = 1000; + static boolean waitForKey = false; @BeforeClass public static void initClass() { @@ -189,7 +188,10 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { Thread.sleep(durationPerTest/2); - end(animator1, frame1, null); + end(animator1, frame1, null); + if( waitForKey ) { + UITestCase.waitForKey("Continue"); + } } public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { @@ -214,7 +216,6 @@ public class TestOffscreenLayer01GLCanvasAWT extends UITestCase { } public static void main(String args[]) throws IOException { - boolean waitForKey = false; for(int i=0; i Press enter to continue"); + try { + System.err.println(stdin.readLine()); + } catch (IOException e) { } + } + static final String unsupportedTestMsg = "Test not supported on this platform."; public String getSnapshotFilename(int sn, String postSNDetail, GLCapabilitiesImmutable caps, int width, int height, boolean sinkHasAlpha, String fileSuffix, String destPath) { -- cgit v1.2.3 From 3567e7e8519f82720f98b0b2ac30456cbfeddc0d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 15 Feb 2013 17:44:37 +0100 Subject: Fix Bug 675: NPE w/ Beans.setDesignTime(true) ; Fix GLCanvas.destroy(): Don't issue removeNotify(), delete drawable and context only! - Fix Bug 675: NPE w/ Beans.setDesignTime(true) - Carefully consider Beans.isDesginTime() fixes NPE - added unit test - Fix GLCanvas.destroy(): Don't issue removeNotify(), delete drawable and context only! - AWT removeNotify() shall only be issued via AWT itself, not manually - Add 'destroyImpl(boolean destroyJAWTWindowAndAWTDevice)' to be called by - GLCanvas.destroy(): destroyImpl( false ); - GLCanvas.removeNotify(): destroyImpl( true ); - Ensures JAWTWindow and AWTDevice are created and destroyed via the AWT callbacks addNotify() and removeNotify() only. --- make/scripts/tests.sh | 10 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 251 +++++++++++---------- .../jogl/awt/TestBug675BeansInDesignTimeAWT.java | 111 +++++++++ 3 files changed, 250 insertions(+), 122 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug675BeansInDesignTimeAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5f5248156..ca337e431 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -299,6 +299,10 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove01SwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove02NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -309,11 +313,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove01SwingAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove02NewtCanvasAWT $* - #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* @@ -361,6 +360,7 @@ testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove02NewtCanvasA #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 2de86b545..cc338ab16 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -174,7 +174,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { - GLCanvas.this.destroy(); + GLCanvas.this.destroyImpl( true ); } }); @@ -312,6 +312,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing * all platforms since the peer hasn't been created. */ final GraphicsConfiguration gc = super.getGraphicsConfiguration(); + + if( Beans.isDesignTime() ) { + return gc; + } + /* * chosen is only non-null on platforms where the GLDrawableFactory * returns a non-null GraphicsConfiguration (in the GLCanvas @@ -370,10 +375,15 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing */ chosen = compatible; - awtConfig = config; - if( !equalCaps && GLAutoDrawable.SCREEN_CHANGE_ACTION_ENABLED ) { - dispose(true); + // complete destruction! + destroyImpl( true ); + // recreation! + awtConfig = config; + createDrawableAndContext( true ); + validateGLDrawable(); + } else { + awtConfig = config; } } } @@ -451,22 +461,28 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing awtWindowClosingProtocol.addClosingListenerOneShot(); } - private void dispose(boolean regenerate) { - disposeRegenerate=regenerate; - Threading.invoke(true, disposeOnEDTAction, getTreeLock()); - } - /** * {@inheritDoc} * *

    - * This impl. calls this class's {@link #removeNotify()} AWT override, - * where the actual implementation resides. + * This impl. only destroys all GL related resources. + *

    + *

    + * This impl. does not remove the GLCanvas from it's parent AWT container + * so this class's {@link #removeNotify()} AWT override won't get called. + * To do so, remove this component from it's parent AWT container. *

    */ @Override public void destroy() { - removeNotify(); + destroyImpl( false ); + } + + protected void destroyImpl(boolean destroyJAWTWindowAndAWTDevice) { + Threading.invoke(true, destroyOnEDTAction, getTreeLock()); + if( destroyJAWTWindowAndAWTDevice ) { + AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, disposeJAWTWindowAndAWTDeviceOnEDT); + } } /** Overridden to cause OpenGL rendering to be performed during @@ -476,7 +492,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing */ @Override public void paint(Graphics g) { - if (Beans.isDesignTime()) { + if( Beans.isDesignTime() ) { // Make GLCanvas behave better in NetBeans GUI builder g.setColor(Color.BLACK); g.fillRect(0, 0, getWidth(), getHeight()); @@ -494,9 +510,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing g.drawString(name, (int) ((getWidth() - bounds.getWidth()) / 2), (int) ((getHeight() + bounds.getHeight()) / 2)); - return; - } - if( ! this.helper.isAnimatorAnimatingOnOtherThread() ) { + } else if( !this.helper.isAnimatorAnimatingOnOtherThread() ) { display(); } } @@ -513,42 +527,46 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void addNotify() { final RecursiveLock _lock = lock; _lock.lock(); - try { + try { + final boolean isBeansDesignTime = Beans.isDesignTime(); + if(DEBUG) { - System.err.println(getThreadName()+": Info: addNotify - start, bounds: "+this.getBounds()); + System.err.println(getThreadName()+": Info: addNotify - start, bounds: "+this.getBounds()+", isBeansDesignTime "+isBeansDesignTime); Thread.dumpStack(); } - /** - * 'super.addNotify()' determines the GraphicsConfiguration, - * while calling this class's overriden 'getGraphicsConfiguration()' method - * after which it creates the native peer. - * Hence we have to set the 'awtConfig' before since it's GraphicsConfiguration - * is being used in getGraphicsConfiguration(). - * This code order also allows recreation, ie re-adding the GLCanvas. - */ - awtConfig = chooseGraphicsConfiguration(capsReqUser, capsReqUser, chooser, device); - if(null==awtConfig) { - throw new GLException("Error: NULL AWTGraphicsConfiguration"); - } - - // before native peer is valid: X11 - disableBackgroundErase(); - - // issues getGraphicsConfiguration() and creates the native peer - super.addNotify(); - - // after native peer is valid: Windows - disableBackgroundErase(); - - if (!Beans.isDesignTime()) { - createDrawableAndContext(); + if( isBeansDesignTime ) { + super.addNotify(); + } else { + /** + * 'super.addNotify()' determines the GraphicsConfiguration, + * while calling this class's overriden 'getGraphicsConfiguration()' method + * after which it creates the native peer. + * Hence we have to set the 'awtConfig' before since it's GraphicsConfiguration + * is being used in getGraphicsConfiguration(). + * This code order also allows recreation, ie re-adding the GLCanvas. + */ + awtConfig = chooseGraphicsConfiguration(capsReqUser, capsReqUser, chooser, device); + if(null==awtConfig) { + throw new GLException("Error: NULL AWTGraphicsConfiguration"); + } + + // before native peer is valid: X11 + disableBackgroundErase(); + + // issues getGraphicsConfiguration() and creates the native peer + super.addNotify(); + + // after native peer is valid: Windows + disableBackgroundErase(); + + createDrawableAndContext( true ); + + // init drawable by paint/display makes the init sequence more equal + // for all launch flavors (applet/javaws/..) + // validateGLDrawable(); } - // init drawable by paint/display makes the init sequence more equal - // for all launch flavors (applet/javaws/..) - // validateGLDrawable(); - if(DEBUG) { System.err.println(getThreadName()+": Info: addNotify - end: peer: "+getPeer()); } @@ -557,27 +575,33 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } - private void createDrawableAndContext() { - // no lock required, since this resource ain't available yet - jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); - jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - jawtWindow.lockSurface(); - try { - drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); - context = (GLContextImpl) drawable.createContext(shareWith); - context.setContextCreationFlags(additionalCtxCreationFlags); - } finally { - jawtWindow.unlockSurface(); + private void createDrawableAndContext(boolean createJAWTWindow) { + if ( !Beans.isDesignTime() ) { + if( createJAWTWindow ) { + jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); + } + jawtWindow.lockSurface(); + try { + drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); + context = (GLContextImpl) drawable.createContext(shareWith); + context.setContextCreationFlags(additionalCtxCreationFlags); + } finally { + jawtWindow.unlockSurface(); + } } - } + } private boolean validateGLDrawable() { + if( Beans.isDesignTime() || !isDisplayable() ) { + return false; // early out! + } final GLDrawable _drawable = drawable; if ( null != _drawable ) { if( _drawable.isRealized() ) { return true; } - if( Beans.isDesignTime() || !isDisplayable() || 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { + if( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { return false; // early out! } // Make sure drawable realization happens on AWT-EDT and only there. Consider the AWTTree lock! @@ -627,11 +651,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing awtWindowClosingProtocol.removeClosingListener(); - if (Beans.isDesignTime()) { + if( Beans.isDesignTime() ) { super.removeNotify(); } else { try { - dispose(false); + destroyImpl( true ); } finally { super.removeNotify(); } @@ -790,7 +814,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public GL getGL() { - if (Beans.isDesignTime()) { + if( Beans.isDesignTime() ) { return null; } final GLContext _context = context; @@ -844,18 +868,18 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { - if (awtConfig == null) { + if( Beans.isDesignTime() ) { + return capsReqUser; + } else if( null == awtConfig ) { throw new GLException("No AWTGraphicsConfiguration: "+this); } - return (GLCapabilitiesImmutable)awtConfig.getChosenCapabilities(); } public GLCapabilitiesImmutable getRequestedGLCapabilities() { - if (awtConfig == null) { + if( null == awtConfig ) { return capsReqUser; } - return (GLCapabilitiesImmutable)awtConfig.getRequestedCapabilities(); } @@ -897,8 +921,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // Internals only below this point // - private boolean disposeRegenerate; - private final Runnable disposeOnEDTAction = new Runnable() { + private final Runnable destroyOnEDTAction = new Runnable() { @Override public void run() { final RecursiveLock _lock = lock; @@ -907,11 +930,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final GLAnimatorControl animator = getAnimator(); if(DEBUG) { - System.err.println(getThreadName()+": Info: dispose("+disposeRegenerate+") - START, hasContext " + + System.err.println(getThreadName()+": Info: destroyOnEDTAction() - START, hasContext " + (null!=context) + ", hasDrawable " + (null!=drawable)+", "+animator); Thread.dumpStack(); } - + final boolean animatorPaused; if(null!=animator) { // can't remove us from animator for recreational addNotify() @@ -926,50 +949,29 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // so we can continue with the destruction. try { helper.disposeGL(GLCanvas.this, context, true); + if(DEBUG) { + System.err.println(getThreadName()+": destroyOnEDTAction() - post ctx: "+context); + } } catch (GLException gle) { gle.printStackTrace(); } - } - context=null; + } + context = null; } if( null != drawable ) { drawable.setRealized(false); if(DEBUG) { - System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - 1: "+drawable); - } - drawable=null; - } - if( null != jawtWindow ) { - jawtWindow.destroy(); - if(DEBUG) { - System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - 2: "+jawtWindow); + System.err.println(getThreadName()+": destroyOnEDTAction() - post drawable: "+drawable); } - jawtWindow=null; + drawable = null; } - if(disposeRegenerate) { - // Similar process as in addNotify()! - - // Recreate GLDrawable/GLContext to reflect it's new graphics configuration - createDrawableAndContext(); - - if(DEBUG) { - System.err.println(getThreadName()+": GLCanvas.dispose(true): new drawable: "+drawable); - } - validateGLDrawable(); // immediate attempt to recreate the drawable - } else { - if(null != awtConfig) { - AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, disposeAbstractGraphicsDeviceActionOnEDT); - } - awtConfig=null; - } - if(animatorPaused) { animator.resume(); } if(DEBUG) { - System.err.println(getThreadName()+": dispose("+disposeRegenerate+") - END, animator "+animator); + System.err.println(getThreadName()+": dispose() - END, animator "+animator); } } finally { @@ -979,28 +981,43 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing }; /** - * Disposes the AbstractGraphicsDevice within EDT, + * Disposes the JAWTWindow and AbstractGraphicsDevice within EDT, * since resources created (X11: Display), must be destroyed in the same thread, where they have been created. + *

    + * The drawable and context handle are null'ed as well, assuming {@link #destroy()} has been called already. + *

    * * @see #chooseGraphicsConfiguration(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, java.awt.GraphicsDevice) */ - private final Runnable disposeAbstractGraphicsDeviceActionOnEDT = new Runnable() { + private final Runnable disposeJAWTWindowAndAWTDeviceOnEDT = new Runnable() { @Override public void run() { - if(null != awtConfig) { - final AbstractGraphicsConfiguration aconfig = awtConfig.getNativeGraphicsConfiguration(); - final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - final String adeviceMsg; - if(DEBUG) { - adeviceMsg = adevice.toString(); - } else { - adeviceMsg = null; - } - boolean closed = adevice.close(); - if(DEBUG) { - System.err.println(getThreadName()+": GLCanvas.dispose(false): closed GraphicsDevice: "+adeviceMsg+", result: "+closed); - } - } + context=null; + drawable=null; + + if( null != jawtWindow ) { + jawtWindow.destroy(); + if(DEBUG) { + System.err.println(getThreadName()+": GLCanvas.disposeJAWTWindowAndAWTDeviceOnEDT(): post JAWTWindow: "+jawtWindow); + } + jawtWindow=null; + } + + if(null != awtConfig) { + final AbstractGraphicsConfiguration aconfig = awtConfig.getNativeGraphicsConfiguration(); + final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); + final String adeviceMsg; + if(DEBUG) { + adeviceMsg = adevice.toString(); + } else { + adeviceMsg = null; + } + boolean closed = adevice.close(); + if(DEBUG) { + System.err.println(getThreadName()+": GLCanvas.disposeJAWTWindowAndAWTDeviceOnEDT(): post GraphicsDevice: "+adeviceMsg+", result: "+closed); + } + } + awtConfig=null; } }; @@ -1139,14 +1156,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing * @param device * @return the chosen AWTGraphicsConfiguration * - * @see #disposeAbstractGraphicsDeviceActionOnEDT + * @see #disposeJAWTWindowAndAWTDeviceOnEDT */ private AWTGraphicsConfiguration chooseGraphicsConfiguration(final GLCapabilitiesImmutable capsChosen, final GLCapabilitiesImmutable capsRequested, final GLCapabilitiesChooser chooser, final GraphicsDevice device) { // Make GLCanvas behave better in NetBeans GUI builder - if (Beans.isDesignTime()) { + if( Beans.isDesignTime() ) { return null; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug675BeansInDesignTimeAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug675BeansInDesignTimeAWT.java new file mode 100644 index 000000000..0c0975308 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug675BeansInDesignTimeAWT.java @@ -0,0 +1,111 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Window; +import java.beans.Beans; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +import junit.framework.Assert; + +import org.junit.Test; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; + +public class TestBug675BeansInDesignTimeAWT extends UITestCase { + static boolean waitForKey = false; + static long durationPerTest = 200; + + @Test + public void test01() throws InterruptedException, InvocationTargetException { + Beans.setDesignTime(true); + + final GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); + final GLCanvas glCanvas = new GLCanvas(caps); + final Dimension preferredGLSize = new Dimension(400,200); + glCanvas.setPreferredSize(preferredGLSize); + glCanvas.setMinimumSize(preferredGLSize); + glCanvas.setSize(preferredGLSize); + + glCanvas.addGLEventListener(new GearsES2()); + + final Window window = new JFrame(this.getSimpleTestName(" - ")); + window.setLayout(new BorderLayout()); + window.add(glCanvas, BorderLayout.CENTER); + + // trigger realization on AWT-EDT, otherwise it won't immediatly .. + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + window.pack(); + window.validate(); + window.setVisible(true); + } + } ); + + // Immediately displayable after issuing initial setVisible(true) on AWT-EDT! + Assert.assertTrue("GLCanvas didn't become displayable", glCanvas.isDisplayable()); + if( !Beans.isDesignTime() ) { + Assert.assertTrue("GLCanvas didn't become realized", glCanvas.isRealized()); + } + + Thread.sleep(durationPerTest); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + window.dispose(); + } + } ); + } + + public static void main(String args[]) { + for(int i=0; i Date: Fri, 15 Feb 2013 18:01:20 +0100 Subject: Refine unit test for Bug 691: Add onscreen/offscreen tests [if available] ; Move tests to 'acore'. --- make/scripts/tests.sh | 6 +- .../acore/TestAddRemove01GLCanvasSwingAWT.java | 254 ++++++++++++++++++++ .../TestAddRemove02GLWindowNewtCanvasAWT.java | 259 +++++++++++++++++++++ .../jogl/awt/TestGLCanvasAddRemove01SwingAWT.java | 232 ------------------ .../awt/TestGLCanvasAddRemove02NewtCanvasAWT.java | 238 ------------------- 5 files changed, 516 insertions(+), 473 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAddRemove01SwingAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAddRemove02NewtCanvasAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ca337e431..559c2aa6a 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -301,8 +301,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove01SwingAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAddRemove02NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -360,7 +360,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java new file mode 100644 index 000000000..2038124b5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java @@ -0,0 +1,254 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import jogamp.nativewindow.jawt.JAWTUtil; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.UITestCase; + +public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { + static long durationPerTest = 50; + static int addRemoveCount = 15; + static boolean shallUseOffscreenFBOLayer = false; + static boolean shallUseOffscreenPBufferLayer = false; + static GLProfile glp; + static int width, height; + static boolean waitForKey = false; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2)) { + glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + width = 640; + height = 480; + } else { + setTestSupported(false); + } + } + + @AfterClass + public static void releaseClass() { + } + + protected JPanel createParkingSlot(final JFrame[] top, final int width, final int height) + throws InterruptedException, InvocationTargetException + { + final JPanel[] jPanel = new JPanel[] { null }; + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jPanel[0] = new JPanel(); + jPanel[0].setLayout(new BorderLayout()); + + final JFrame jFrame1 = new JFrame("Parking Slot"); + // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! + jFrame1.getContentPane().add(jPanel[0]); + jFrame1.setSize(width, height); + + top[0] = jFrame1; + } } ); + return jPanel[0]; + } + + protected JPanel create(final JFrame[] top, final int width, final int height, final int num) + throws InterruptedException, InvocationTargetException + { + final JPanel[] jPanel = new JPanel[] { null }; + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jPanel[0] = new JPanel(); + jPanel[0].setLayout(new BorderLayout()); + + final JFrame jFrame1 = new JFrame("JFrame #"+num); + // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! + jFrame1.getContentPane().add(jPanel[0]); + jFrame1.setSize(width, height); + + top[0] = jFrame1; + } } ); + return jPanel[0]; + } + + protected void add(final Container cont, final Component comp) + throws InterruptedException, InvocationTargetException + { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + cont.add(comp, BorderLayout.CENTER); + } } ); + } + + protected void dispose(final GLCanvas glc) + throws InterruptedException, InvocationTargetException + { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + glc.destroy(); + } } ); + } + + protected void setVisible(final JFrame jFrame, final boolean visible) throws InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + if( visible ) { + jFrame.validate(); + jFrame.pack(); + } + jFrame.setVisible(visible); + } } ) ; + } + + protected void dispose(final JFrame jFrame) throws InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jFrame.dispose(); + } } ) ; + } + + protected void runTestGL(boolean onscreen, GLCapabilities caps, int addRemoveOpCount) + throws AWTException, InterruptedException, InvocationTargetException + { + + for(int i=0; i Date: Sat, 16 Feb 2013 03:55:22 +0100 Subject: Fix Bug 691 (part-3): NSOpenGLLayer::openGLContextForPixelFormat(..) on main-thread deadlock'ed due to locked shared context NSOpenGLLayer::openGLContextForPixelFormat(..) is performed on main-thread at 1st NSOpenGLLayer display method. This happened irregulary, i.e. sometimes (T0) right after NSOpenGLLayer creation and attachSurfaceLayer()/AddCASublayer(..), sometimes later (T1). NSOpenGLLayer::openGLContextForPixelFormat(..) uses the passed shared user context. The shared user context is locked at NSOpenGLLayer's creation (T0) and if performed at this early time the call deadlocks due to pthread_mutex wait for the shared user context. This fix performs NSOpenGLLayer creation and layer attachment while the shared user context is kept unlocked and enforces NSOpenGLLayer display and hence NSOpenGLLayer::openGLContextForPixelFormat(..). Added CGL.setNSOpenGLLayerEnabled(..) to enable/disable NSOpenGLLayer - currently not used. - Passed AddRemove tests for GLCanvas/Swing and GLWindow/NewtCanvasAWT w/ 100 loops on Java6 and Java7 on OSX. - Passed Instruments Leaks test w/ 10 loops on Java6 and Java7 --- make/config/jogl/cgl-macosx-CustomJavaCode.java | 22 +++++++++++++++ make/config/jogl/cgl-macosx.cfg | 2 ++ make/scripts/tests.sh | 4 +-- make/stub_includes/opengl/macosx-window-system.h | 1 + .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 31 +++++++++++++++++----- .../macosx/MacOSXWindowSystemInterface-calayer.m | 28 ++++++++++++++----- .../media/nativewindow/OffscreenLayerSurface.java | 8 ++++++ .../jogamp/nativewindow/macosx/OSXUtil.java | 28 +++++++++++++++++++ src/nativewindow/native/macosx/OSXmisc.m | 16 +++++++---- .../acore/TestAddRemove01GLCanvasSwingAWT.java | 2 +- .../TestAddRemove02GLWindowNewtCanvasAWT.java | 2 +- 11 files changed, 123 insertions(+), 21 deletions(-) (limited to 'make/scripts') diff --git a/make/config/jogl/cgl-macosx-CustomJavaCode.java b/make/config/jogl/cgl-macosx-CustomJavaCode.java index b9a37d0c6..d32e0ae8f 100644 --- a/make/config/jogl/cgl-macosx-CustomJavaCode.java +++ b/make/config/jogl/cgl-macosx-CustomJavaCode.java @@ -1,6 +1,14 @@ /** * Creates the NSOpenGLLayer for FBO/PBuffer w/ optional GL3 shader program on Main-Thread + *

    + * It is mandatory that the shared context handle ctx + * is not locked while calling this method. + *

    + *

    + * The NSOpenGLLayer starts in enabled mode, + * you may enable/disable it via {@link #setNSOpenGLLayerEnabled(long, boolean)}. + *

    */ public static long createNSOpenGLLayer(final long ctx, final int gl3ShaderProgramName, final long fmt, final long p, final int texID, final boolean opaque, final int texWidth, final int texHeight) { @@ -10,6 +18,20 @@ public static long createNSOpenGLLayer(final long ctx, final int gl3ShaderProgra } } ).longValue(); } +/** + * Enable or disable NSOpenGLLayer. + * + *

    + * If disabled, the NSOpenGLLayer will not be displayed, i.e. rendered. + *

    + */ +public static void setNSOpenGLLayerEnabled(final long nsOpenGLLayer, final boolean enable) { + OSXUtil.RunOnMainThread(true, new Runnable() { + public void run() { + setNSOpenGLLayerEnabledImpl(nsOpenGLLayer, enable); + } } ); +} + /** * Releases the NSOpenGLLayer on Main-Thread */ diff --git a/make/config/jogl/cgl-macosx.cfg b/make/config/jogl/cgl-macosx.cfg index 98123f605..edb5bfbbf 100644 --- a/make/config/jogl/cgl-macosx.cfg +++ b/make/config/jogl/cgl-macosx.cfg @@ -35,8 +35,10 @@ CustomCCode #include CustomCCode #include "macosx-window-system.h" AccessControl createNSOpenGLLayerImpl PRIVATE +AccessControl setNSOpenGLLayerEnabledImpl PRIVATE AccessControl releaseNSOpenGLLayerImpl PRIVATE RenameJavaMethod createNSOpenGLLayer createNSOpenGLLayerImpl +RenameJavaMethod setNSOpenGLLayerEnabled setNSOpenGLLayerEnabledImpl RenameJavaMethod releaseNSOpenGLLayer releaseNSOpenGLLayerImpl IncludeAs CustomJavaCode CGL cgl-macosx-CustomJavaCode.java diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 559c2aa6a..a20ec507c 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -301,8 +301,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* diff --git a/make/stub_includes/opengl/macosx-window-system.h b/make/stub_includes/opengl/macosx-window-system.h index a2da66878..402a16efc 100644 --- a/make/stub_includes/opengl/macosx-window-system.h +++ b/make/stub_includes/opengl/macosx-window-system.h @@ -56,6 +56,7 @@ void setContextTextureImageToPBuffer(NSOpenGLContext* ctx, NSOpenGLPixelBuffer* Bool isNSOpenGLPixelBuffer(uint64_t object); NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, int gl3ShaderProgramName, NSOpenGLPixelFormat* fmt, NSOpenGLPixelBuffer* p, uint32_t texID, Bool opaque, int texWidth, int texHeight); +void setNSOpenGLLayerEnabled(NSOpenGLLayer* layer, Bool enable); void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval); void waitUntilNSOpenGLLayerIsReady(NSOpenGLLayer* layer, long to_micros); void setNSOpenGLLayerNeedsDisplayFBO(NSOpenGLLayer* layer, uint32_t texID); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 838a0387d..37aca0cd7 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -687,13 +687,32 @@ public abstract class MacOSXCGLContext extends GLContextImpl } else { gl3ShaderProgramName = 0; } - nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, gl3ShaderProgramName, nsOpenGLLayerPFmt, pbufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight); - nsOpenGLLayerPFmt = 0; // NSOpenGLLayer will release pfmt - if (DEBUG) { - System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+" w/ pbuffer "+toHexString(pbufferHandle)+", texID "+texID+", texSize "+lastWidth+"x"+lastHeight+", "+drawable); + + /** + * Perform NSOpenGLLayer creation and attaching on main-thread, + * hence release the lock on our context - which will be used to + * create a shared context within NSOpenGLLayer. + */ + final long cglCtx = CGL.getCGLContext(ctx); + if(0 == cglCtx) { + throw new InternalError("Null CGLContext for: "+this); + } + final boolean ctxUnlocked = CGL.kCGLNoError == CGL.CGLUnlockContext(cglCtx); + try { + nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, gl3ShaderProgramName, nsOpenGLLayerPFmt, pbufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight); + nsOpenGLLayerPFmt = 0; // NSOpenGLLayer will release pfmt + if (DEBUG) { + System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+" w/ pbuffer "+toHexString(pbufferHandle)+", texID "+texID+", texSize "+lastWidth+"x"+lastHeight+", "+drawable); + } + backingLayerHost.attachSurfaceLayer(nsOpenGLLayer); + setSwapInterval(1); // enabled per default in layered surface + } finally { + if( ctxUnlocked ) { + if( CGL.kCGLNoError != CGL.CGLLockContext(cglCtx) ) { + throw new InternalError("Could not re-lock CGLContext for: "+this); + } + } } - backingLayerHost.attachSurfaceLayer(nsOpenGLLayer); - setSwapInterval(1); // enabled per default in layered surface } else { lastWidth = drawable.getWidth(); lastHeight = drawable.getHeight(); diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 8d1286169..55c4ad053 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -130,6 +130,7 @@ extern GLboolean glIsVertexArray (GLuint array); @private GLfloat gl_texCoords[8]; NSOpenGLContext* myCtx; + Bool isGLEnabled; @protected NSOpenGLContext* parentCtx; @@ -171,6 +172,7 @@ extern GLboolean glIsVertexArray (GLuint array); texWidth: (int) texWidth texHeight: (int) texHeight; +- (void) setGLEnabled: (Bool) enable; - (Bool) validateTexSizeWithNewSize; - (Bool) validateTexSize: (int) _texWidth texHeight: (int) _texHeight; - (void) setTextureID: (int) _texID; @@ -266,6 +268,7 @@ static const GLfloat gl_verts[] = { swapIntervalCounter = 0; timespec_now(&lastWaitTime); shallDraw = NO; + isGLEnabled = YES; newTexWidth = _texWidth; newTexHeight = _texHeight; [self validateTexSizeWithNewSize]; @@ -335,6 +338,12 @@ static const GLfloat gl_verts[] = { return self; } +- (void) setGLEnabled: (Bool) enable +{ + DBG_PRINT("MyNSOpenGLLayer::setGLEnabled: %p, %d -> %d\n", self, (int)isGLEnabled, (int)enable); + isGLEnabled = enable; +} + - (Bool) validateTexSizeWithNewSize { return [self validateTexSize: newTexWidth texHeight: newTexHeight]; @@ -444,6 +453,7 @@ static const GLfloat gl_verts[] = { { DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask: %p (refcnt %d) - parent-pfmt %p -> new-pfmt %p\n", self, (int)[self retainCount], parentPixelFmt, parentPixelFmt); + // We simply take over ownership of parent PixelFormat .. return parentPixelFmt; } @@ -531,7 +541,6 @@ static const GLfloat gl_verts[] = { [self disableAnimation]; pthread_mutex_lock(&renderLock); [self deallocPBuffer]; - // [[self openGLContext] dealloc]; pthread_mutex_unlock(&renderLock); pthread_cond_destroy(&renderSignal); pthread_mutex_destroy(&renderLock); @@ -548,8 +557,8 @@ static const GLfloat gl_verts[] = { { CGRect lRectS = [[self superlayer] bounds]; - DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d, bounds: %lfx%lf -> %lfx%lf (refcnt %d)\n", - self, texWidth, texHeight, size.width, size.height, lRectS.size.width, lRectS.size.height, (int)[self retainCount]); + DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d, bounds: %lfx%lf -> %lf/%lf %lfx%lf (refcnt %d)\n", + self, texWidth, texHeight, size.width, size.height, lRectS.origin.x, lRectS.origin.y, lRectS.size.width, lRectS.size.height, (int)[self retainCount]); newTexWidth = lRectS.size.width; newTexHeight = lRectS.size.height; @@ -562,8 +571,8 @@ static const GLfloat gl_verts[] = { - (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp { - SYNC_PRINT("", (int)shallDraw); - return shallDraw; + SYNC_PRINT("", (int)shallDraw, (int)isGLEnabled); + return shallDraw && isGLEnabled; } - (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat @@ -573,7 +582,7 @@ static const GLfloat gl_verts[] = { SYNC_PRINT("<* "); // NSLog(@"MyNSOpenGLLayer::DRAW: %@",[NSThread callStackSymbols]); - if( shallDraw && ( NULL != pbuffer || NULL != newPBuffer || 0 != textureID ) ) { + if( isGLEnabled && shallDraw && ( NULL != pbuffer || NULL != newPBuffer || 0 != textureID ) ) { [context makeCurrentContext]; if( NULL != newPBuffer ) { // volatile OK @@ -825,6 +834,13 @@ NSOpenGLLayer* createNSOpenGLLayer(NSOpenGLContext* ctx, int gl3ShaderProgramNam return [[[MyNSOpenGLLayer alloc] init] setupWithContext:ctx gl3ShaderProgramName: (GLuint)gl3ShaderProgramName pixelFormat: fmt pbuffer: p texIDArg: (GLuint)texID opaque: opaque texWidth: texWidth texHeight: texHeight]; } + +void setNSOpenGLLayerEnabled(NSOpenGLLayer* layer, Bool enable) { + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyNSOpenGLLayer* l = (MyNSOpenGLLayer*) layer; + [l setGLEnabled: enable]; + [pool release]; +} void setNSOpenGLLayerSwapInterval(NSOpenGLLayer* layer, int interval) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index f6bc5822b..ba60a7f38 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -33,6 +33,14 @@ package javax.media.nativewindow; public interface OffscreenLayerSurface { /** * Attach the offscreen layer to this offscreen layer surface. + *

    + * Implementation may realize all required resources at this point. + *

    + *

    + * It is mandatory that any related resources, e.g. a shared context, + * are not locked while calling this method. + *

    + * * @see #isOffscreenLayerSurfaceEnabled() * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false */ diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index b765a68c3..d85d1a84b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -136,12 +136,31 @@ public class OSXUtil implements ToolkitProperties { return GetNSWindow0(nsView); } + /** + * Create a CALayer suitable to act as a root CALayer on the main-thread. + * @see #DestroyCALayer(long) + * @see #AddCASublayer(long, long) + */ public static long CreateCALayer(final int x, final int y, final int width, final int height) { return OSXUtil.RunOnMainThread(true, new Function() { public Long eval(Object... args) { return Long.valueOf( CreateCALayer0(x, y, width, height) ); } } ).longValue(); } + + /** + * Attach a sub CALayer to the root CALayer on the main-thread. + *

    + * Method will trigger a display + * call to the CALayer hierarchy to enforce resource creation if required, e.g. an NSOpenGLContext. + *

    + *

    + * It is mandatory that any related resources, e.g. a shared NSOpenGLContext, + * are not locked while calling this method. + *

    + * @see #CreateCALayer(int, int, int, int) + * @see #RemoveCASublayer(long, long) + */ public static void AddCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); @@ -152,6 +171,10 @@ public class OSXUtil implements ToolkitProperties { } }); } + + /** + * Detach a sub CALayer from the root CALayer on the main-thread. + */ public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); @@ -161,6 +184,11 @@ public class OSXUtil implements ToolkitProperties { RemoveCASublayer0(rootCALayer, subCALayer); } } ); } + + /** + * Destroy a CALayer on the main-thread. + * @see #CreateCALayer(int, int, int, int) + */ public static void DestroyCALayer(final long caLayer) { if(0==caLayer) { throw new IllegalArgumentException("caLayer 0x"+Long.toHexString(caLayer)); diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 83f3c821f..8d876c175 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -430,6 +430,9 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + CGRect lRectRoot = [rootLayer frame]; DBG_PRINT("CALayer::AddCASublayer0.0: Origin %p frame0: %lf/%lf %lfx%lf\n", rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height); @@ -444,9 +447,6 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 rootLayer, (int)[rootLayer retainCount], subLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (int)[subLayer retainCount]); - [CATransaction begin]; - [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - // simple 1:1 layout ! [subLayer setFrame:lRectRoot]; [rootLayer addSublayer:subLayer]; @@ -454,14 +454,20 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [rootLayer removeAllAnimations]; - // [rootLayer addAnimation:nil forKey:kCATransition]; + // [rootLayer addAnimation:nil forKey:kCATransition]; // JAU [rootLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [rootLayer setNeedsDisplayOnBoundsChange: YES]; [subLayer removeAllAnimations]; - // [sublayer addAnimation:nil forKey:kCATransition]; + // [subLayer addAnimation:nil forKey:kCATransition]; // JAU [subLayer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [subLayer setNeedsDisplayOnBoundsChange: YES]; + // Trigger display and hence ctx creation. + // The latter is essential since since the parent-context lock is cleared + // only for this window of time (method call). + [rootLayer setNeedsDisplay]; + [rootLayer displayIfNeeded]; + [CATransaction commit]; [pool release]; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java index 2038124b5..61652371b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java @@ -140,8 +140,8 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { SwingUtilities.invokeAndWait(new Runnable() { public void run() { if( visible ) { - jFrame.validate(); jFrame.pack(); + jFrame.validate(); } jFrame.setVisible(visible); } } ) ; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java index 0f12f967a..b4272a9c0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove02GLWindowNewtCanvasAWT.java @@ -142,8 +142,8 @@ public class TestAddRemove02GLWindowNewtCanvasAWT extends UITestCase { SwingUtilities.invokeAndWait(new Runnable() { public void run() { if( visible ) { - jFrame.validate(); jFrame.pack(); + jFrame.validate(); } jFrame.setVisible(visible); } } ) ; -- cgit v1.2.3 From 1cee0f1ac437de952c5cc15d5a23c8c5ddfdda8a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 16 Feb 2013 20:04:24 +0100 Subject: Fix Bug 644: AWT GLCanvas and GLJPanel ignored their visibility state If !visible, GLCanvas and GLJPanel's paint* and display method shall not render as the other GLAutoDrawable impl. do (GLWindow, SWT GLCanvas). --- make/scripts/tests.sh | 4 +- .../com/jogamp/opengl/util/AnimatorBase.java | 2 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 4 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 32 +-- src/jogl/classes/jogamp/opengl/FPSCounterImpl.java | 1 + .../awt/TestBug664GLCanvasSetVisibleSwingAWT.java | 280 +++++++++++++++++++++ 6 files changed, 305 insertions(+), 18 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a20ec507c..ecfdc6fa9 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -301,7 +301,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* @@ -370,6 +370,7 @@ testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* @@ -417,7 +418,6 @@ testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* - #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index 53a99b640..aa0e70132 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -537,7 +537,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { remaining -= System.currentTimeMillis() - t1 ; nok = waitCondition.eval(); } - if(DEBUG || nok) { + if(DEBUG || blocking && nok) { // Info only if DEBUG or ( blocking && not-ok ) ; !blocking possible if AWT if( remaining<=0 && nok ) { System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): ++++++ timeout reached ++++++ " + Thread.currentThread().getName()); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index cc338ab16..c9069f9ce 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -457,7 +457,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } return; // not yet available .. } - Threading.invoke(true, displayOnEDTAction, getTreeLock()); + if( isVisible() ) { + Threading.invoke(true, displayOnEDTAction, getTreeLock()); + } awtWindowClosingProtocol.addClosingListenerOneShot(); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 864a5c91c..2b99bb570 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -250,17 +250,19 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void display() { - if (EventQueue.isDispatchThread()) { - // Want display() to be synchronous, so call paintImmediately() - paintImmediately(0, 0, getWidth(), getHeight()); - } else { - // Multithreaded redrawing of Swing components is not allowed, - // so do everything on the event dispatch thread - try { - EventQueue.invokeAndWait(paintImmediatelyAction); - } catch (Exception e) { - throw new GLException(e); - } + if( isVisible() ) { + if (EventQueue.isDispatchThread()) { + // Want display() to be synchronous, so call paintImmediately() + paintImmediately(0, 0, getWidth(), getHeight()); + } else { + // Multithreaded redrawing of Swing components is not allowed, + // so do everything on the event dispatch thread + try { + EventQueue.invokeAndWait(paintImmediatelyAction); + } catch (Exception e) { + throw new GLException(e); + } + } } } @@ -350,9 +352,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing sendReshape = handleReshape(); } - updater.setGraphics(g); - - backend.doPaintComponent(g); + if( isVisible() ) { + updater.setGraphics(g); + + backend.doPaintComponent(g); + } } diff --git a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java index 27569d210..b74ac9f41 100644 --- a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java +++ b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java @@ -103,6 +103,7 @@ public class FPSCounterImpl implements FPSCounter { fpsLastPeriod = 0; fpsTotalFrames = 0; fpsLast = 0f; fpsTotal = 0f; + fpsLastPeriod = 0; fpsTotalDuration=0; } public final synchronized int getUpdateFPSFrames() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java new file mode 100644 index 000000000..f2fae293b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug664GLCanvasSetVisibleSwingAWT.java @@ -0,0 +1,280 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import jogamp.nativewindow.jawt.JAWTUtil; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +public class TestBug664GLCanvasSetVisibleSwingAWT extends UITestCase { + static long durationPerTest = 500; + static boolean shallUseOffscreenFBOLayer = false; + static boolean shallUseOffscreenPBufferLayer = false; + static GLProfile glp; + static int width, height; + static boolean waitForKey = false; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + width = 640; + height = 480; + } else { + setTestSupported(false); + } + } + + @AfterClass + public static void releaseClass() { + } + + protected JPanel create(final JFrame[] top, final int width, final int height, final int num) + throws InterruptedException, InvocationTargetException + { + final JPanel[] jPanel = new JPanel[] { null }; + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jPanel[0] = new JPanel(); + jPanel[0].setLayout(new BorderLayout()); + + final JFrame jFrame1 = new JFrame("JFrame #"+num); + // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! + jFrame1.getContentPane().add(jPanel[0]); + jFrame1.setSize(width, height); + + top[0] = jFrame1; + } } ); + return jPanel[0]; + } + + protected void add(final Container cont, final Component comp, final JFrame jFrame) + throws InterruptedException, InvocationTargetException + { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + cont.add(comp, BorderLayout.CENTER); + jFrame.pack(); + jFrame.validate(); + } } ); + } + + protected void dispose(final GLCanvas glc) + throws InterruptedException, InvocationTargetException + { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + glc.destroy(); + } } ); + } + + protected void setFrameVisible(final JFrame jFrame, final boolean visible) throws InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jFrame.setVisible(visible); + } } ) ; + } + + protected void setComponentVisible(final Component comp, final boolean visible) throws InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + comp.setVisible(visible); + } } ) ; + } + + protected void dispose(final JFrame jFrame) throws InterruptedException, InvocationTargetException { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jFrame.dispose(); + } } ) ; + } + + private volatile int frameCount = 0; + + protected void runTestGL(boolean onscreen, GLCapabilities caps) + throws AWTException, InterruptedException, InvocationTargetException + { + + for(int i=0; i<1; i++) { + Animator anim = new Animator(); + final GLCanvas glc = new GLCanvas(caps); + Assert.assertNotNull(glc); + anim.add(glc); + if( !onscreen ) { + glc.setShallUseOffscreenLayer(true); + } + Dimension glc_sz = new Dimension(width, height); + glc.setMinimumSize(glc_sz); + glc.setPreferredSize(glc_sz); + glc.setSize(glc_sz); + glc.addGLEventListener(new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) {} + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) { + frameCount++; + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }); + glc.addGLEventListener(new GearsES2()); + + final JFrame[] top = new JFrame[] { null }; + final Container glcCont = create(top, width, height, i); + add(glcCont, glc, top[0]); + + frameCount = 0; + setFrameVisible(top[0], true); + Assert.assertTrue("Component didn't become visible", AWTRobotUtil.waitForVisible(glc, true)); + + anim.setUpdateFPSFrames(60, null); + anim.start(); + anim.resetFPSCounter(); + System.err.println("Visible Part 1/3"); + + while( anim.getTotalFPSDuration() < durationPerTest ) { + Thread.sleep(60); + } + + setComponentVisible(glc, false); + Assert.assertTrue("Component didn't become invisible", AWTRobotUtil.waitForVisible(glc, false)); + final int frameCountT0 = frameCount; + anim.resetFPSCounter(); + System.err.println("Invisible Part 2/3"); + + while( anim.getTotalFPSDuration() < durationPerTest ) { + Thread.sleep(60); + } + + final int frameCountT1 = frameCount; + System.err.println("GLCanvas invisible frame count: Before "+frameCountT0+", after "+frameCountT1); + Assert.assertTrue("GLCanvas rendered more that 4 times while being invisible, before "+frameCountT0+", after "+frameCountT1, + 4 >= frameCountT1 - frameCountT0); + + setComponentVisible(glc, true); + Assert.assertTrue("Component didn't become visible", AWTRobotUtil.waitForVisible(glc, true)); + anim.resetFPSCounter(); + System.err.println("Visible Part 3/3"); + + while( anim.getTotalFPSDuration() < durationPerTest ) { + Thread.sleep(60); + } + + System.err.println("GLCanvas isOffscreenLayerSurfaceEnabled: "+glc.isOffscreenLayerSurfaceEnabled()+": "+glc.getChosenGLCapabilities()); + + dispose(top[0]); + } + } + + @Test + public void test01Onscreen() + throws AWTException, InterruptedException, InvocationTargetException + { + if( shallUseOffscreenFBOLayer || shallUseOffscreenPBufferLayer || JAWTUtil.isOffscreenLayerRequired() ) { + System.err.println("Offscreen test requested or platform requires it."); + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + if(shallUseOffscreenPBufferLayer) { + caps.setPBuffer(true); + caps.setOnscreen(true); // simulate normal behavior .. + } + runTestGL(true, caps); + } + + @Test + public void test02Offscreen() + throws AWTException, InterruptedException, InvocationTargetException + { + if( !JAWTUtil.isOffscreenLayerSupported() ) { + System.err.println("Platform doesn't support offscreen test."); + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + if(shallUseOffscreenPBufferLayer) { + caps.setPBuffer(true); + caps.setOnscreen(true); // simulate normal behavior .. + } + runTestGL(false, caps); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Sat, 16 Feb 2013 20:10:23 +0100 Subject: TestWindowClosingProtocol01AWT: More relaxed timing reducing false positives --- make/scripts/tests.sh | 5 ++--- .../opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java | 10 +++++++++- .../test/junit/newt/TestWindowClosingProtocol02NEWT.java | 2 ++ .../test/junit/newt/TestWindowClosingProtocol03NewtAWT.java | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ecfdc6fa9..400f3f023 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -344,7 +344,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT # @@ -370,7 +369,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* @@ -435,7 +434,7 @@ testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingA #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT -#testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* +testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java index 3a923d435..6aedb8433 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol01AWT.java @@ -87,10 +87,16 @@ public class TestWindowClosingProtocol01AWT extends UITestCase { glCanvas.setDefaultCloseOperation(WindowClosingMode.DISPOSE_ON_CLOSE); op = glCanvas.getDefaultCloseOperation(); Assert.assertEquals(WindowClosingMode.DISPOSE_ON_CLOSE, op); + + Thread.sleep(300); - Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false)); // no frame close + Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false)); // no frame close, but GLCanvas's GL resources will be destroyed + Thread.sleep(100); Assert.assertEquals(true, frame.isDisplayable()); Assert.assertEquals(true, frame.isVisible()); + for (int wait=0; wait Date: Sun, 17 Feb 2013 03:25:34 +0100 Subject: NEWT/OSX: Fix Memory Leak ; Fix Occasional Crash Duer to Lifecycle Ops not on Main-Thread. - Fix Memory Leak - NewtWindow::dealloc -> [NewtView release]: Fixes NewtView leak - NewtView::dealloc -> removeTrackingRect: Removes occasional crash (double free of TrackingRect) - Fix Occasional Crash Duer to Lifecycle Ops not on Main-Thread. Perform OSX WindowDriver ops on Main-Thread: - close0 - changeContentView0 - createWindow0 - Cleaned up AddRemove unit tests, added TestAddRemove03GLWindowNEWT --- make/scripts/tests-osx-x64-java7.sh | 1 - make/scripts/tests-osx-x64.sh | 1 - make/scripts/tests.sh | 9 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 43 +++++-- src/newt/native/MacWindow.m | 31 +++-- src/newt/native/NewtMacWindow.m | 32 +++-- .../acore/TestAddRemove01GLCanvasSwingAWT.java | 35 +++--- .../TestAddRemove02GLWindowNewtCanvasAWT.java | 37 +++--- .../jogl/acore/TestAddRemove03GLWindowNEWT.java | 130 +++++++++++++++++++++ .../awt/TestBug664GLCanvasSetVisibleSwingAWT.java | 4 +- 10 files changed, 248 insertions(+), 75 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove03GLWindowNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-osx-x64-java7.sh b/make/scripts/tests-osx-x64-java7.sh index 378938167..e1b07202b 100755 --- a/make/scripts/tests-osx-x64-java7.sh +++ b/make/scripts/tests-osx-x64-java7.sh @@ -10,4 +10,3 @@ spath=`dirname $0` . $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* - diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh index 01f3e1bb2..fe2d2c4ec 100755 --- a/make/scripts/tests-osx-x64.sh +++ b/make/scripts/tests-osx-x64.sh @@ -10,4 +10,3 @@ spath=`dirname $0` . $spath/tests.sh /usr/bin/java -d64 ../build-macosx $* - diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 400f3f023..5a7c0f0ec 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -34,8 +34,8 @@ uname -a | grep -i Darwin && MOSX=1 if [ $MOSX -eq 1 ] ; then echo setup OSX environment vars #export NSZombieEnabled=YES - #export NSTraceEvents=YES - #export OBJC_PRINT_EXCEPTIONS=YES + export NSTraceEvents=YES + export OBJC_PRINT_EXCEPTIONS=YES echo NSZombieEnabled $NSZombieEnabled 2>&1 | tee -a java-run.log echo NSTraceEvents $NSTraceEvents 2>&1 | tee -a java-run.log echo OBJC_PRINT_EXCEPTIONS $OBJC_PRINT_EXCEPTIONS 2>&1 | tee -a java-run.log @@ -302,7 +302,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove03GLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* @@ -434,7 +435,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT -testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* +#testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT $* diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 5755bdf11..89d53fbeb 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -50,6 +50,7 @@ import jogamp.newt.WindowImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; +import com.jogamp.common.util.Function; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; @@ -86,7 +87,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sscSurfaceHandle = 0; isOffscreenInstance = false; if (0 != handle) { - close0(handle); + OSXUtil.RunOnMainThread(true, new Runnable() { + public void run() { + close0( handle ); + } } ); } } catch (Throwable t) { if(DEBUG_IMPLEMENTATION) { @@ -378,24 +382,36 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl try { if(0!=getWindowHandle()) { // save the view .. close the window - surfaceHandle = changeContentView0(getParentWindowHandle(), getWindowHandle(), 0); + surfaceHandle = OSXUtil.RunOnMainThread(true, new Function() { + public Long eval(Object... args) { + return Long.valueOf( + changeContentView0(getParentWindowHandle(), getWindowHandle(), 0) ); + } } ).longValue(); if(recreate && 0==surfaceHandle) { throw new NativeWindowException("Internal Error - recreate, window but no view"); } - close0(getWindowHandle()); + OSXUtil.RunOnMainThread(true, new Runnable() { + public void run() { + close0( getWindowHandle() ); + } } ); setWindowHandle(0); } else { surfaceHandle = 0; } - setWindowHandle(createWindow0(getParentWindowHandle(), - pS.getX(), pS.getY(), width, height, - (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), - fullscreen, - ((isUndecorated() || offscreenInstance) ? - NSBorderlessWindowMask : - NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask), - NSBackingStoreBuffered, - getScreen().getIndex(), surfaceHandle)); + + setWindowHandle( OSXUtil.RunOnMainThread(true, new Function() { + public Long eval(Object... args) { + return Long.valueOf( + createWindow0( getParentWindowHandle(), + pS.getX(), pS.getY(), width, height, + (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), + fullscreen, + ( (isUndecorated() || offscreenInstance) ? NSBorderlessWindowMask : + NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask ), + NSBackingStoreBuffered, + getScreen().getIndex(), surfaceHandle) ); + } } ).longValue() ); + if (getWindowHandle() == 0) { throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this); } @@ -411,6 +427,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } protected static native boolean initIDs0(); + /** Must be called on Main-Thread */ private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h, boolean opaque, boolean fullscreen, int windowStyle, int backingStoreType, @@ -422,9 +439,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl /** in case of a child window, it actually only issues orderBack(..) */ private native void orderOut0(long window); private native void orderFront0(long window); + /** Must be called on Main-Thread */ private native void close0(long window); private native void setTitle0(long window, String title); private native long contentView0(long window); + /** Must be called on Main-Thread */ private native long changeContentView0(long parentWindowOrViewHandle, long window, long view); private native void setContentSize0(long window, int w, int h); private native void setFrameTopLeftPoint0(long parentWindowHandle, long window, int x, int y); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index b9c339285..94363624f 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -553,7 +553,9 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 return (jboolean) res; } -/* +/** + * Method is called on Main-Thread, hence no special invocation required inside method. + * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createWindow0 * Signature: (JIIIIZIIIJ)J @@ -706,19 +708,10 @@ NS_ENDHANDLER return (jlong) ((intptr_t) myWindow); } -// Footnote: Our view handling produces random 'Assertion failure' even w/o parenting: -// -// [NSThemeFrame lockFocus], /SourceCache/AppKit/AppKit-1138.23/AppKit.subproj/NSView.m:6053 -// [NSThemeFrame(0x7fe94bc72c80) lockFocus] failed with window=0x7fe94bc445a0, windowNumber=9425, [self isHiddenOrHasHiddenAncestor]=0 -// .. -// AppKit 0x00007fff89621001 -[NSView lockFocus] + 250 -// AppKit 0x00007fff8961eafa -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 3780 -// AppKit 0x00007fff8961793e -[NSView displayIfNeeded] + 1676 -// AppKit 0x00007fff8961707d _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints + 648 -// - -/* +/** + * Method is called on Main-Thread, hence no special invocation required inside method. + * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: close0 * Signature: (J)V @@ -761,8 +754,6 @@ NS_DURING [mView exitFullScreenModeWithOptions: NULL]; } // Note: mWin's release will also release it's mView! - // [mWin setContentView: nil]; - // [mView release]; } NS_HANDLER NS_ENDHANDLER @@ -770,7 +761,8 @@ NS_ENDHANDLER if(NULL!=pWin) { [mWin detachFromParent: pWin]; } - [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; + // [mWin performSelectorOnMainThread:@selector(orderOut:) withObject:mWin waitUntilDone:NO]; + [mWin orderOut: mWin]; DBG_PRINT( "windowClose.1 - %p,%d view %p,%d, parent %p\n", mWin, getRetainCount(mWin), mView, getRetainCount(mView), pWin); @@ -778,7 +770,8 @@ NS_ENDHANDLER // Only release window, if release is not yet in process. // E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked. if(!destroyNotifySent) { - [mWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO]; + // [mWin performSelectorOnMainThread:@selector(release) withObject:nil waitUntilDone:NO]; + [mWin release]; } DBG_PRINT( "windowClose.X - %p,%d, released %d, view %p,%d, parent %p\n", @@ -960,7 +953,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 return res; } -/* +/** + * Method is called on Main-Thread, hence no special invocation required inside method. + * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: changeContentView * Signature: (J)J diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 5b826566b..e69f74dfb 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -107,6 +107,7 @@ static jmethodID windowRepaintID = NULL; - (id)initWithFrame:(NSRect)frameRect { + id res = [super initWithFrame:frameRect]; javaWindowObject = NULL; jvmHandle = NULL; @@ -129,28 +130,35 @@ static jmethodID windowRepaintID = NULL; */ myCursor = NULL; - return [super initWithFrame:frameRect]; + DBG_PRINT("NewtView::create: %p (refcnt %d)\n", res, (int)[res retainCount]); + return res; } - (void) release { + DBG_PRINT("NewtView::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); #ifdef VERBOSE_ON - NSLog(@"NewtView::release\n"); - NSLog(@"%@",[NSThread callStackSymbols]); + // NSLog(@"%@",[NSThread callStackSymbols]); #endif [super release]; } - (void) dealloc { + DBG_PRINT("NewtView::dealloc.0: %p (refcnt %d), ptrTrackingTag %d\n", self, (int)[self retainCount], (int)ptrTrackingTag); if(softLocked) { NSLog(@"NewtView::dealloc: softLock still hold @ dealloc!\n"); } + if(0 != ptrTrackingTag) { + // [self removeCursorRect: ptrRect cursor: myCursor]; + [self removeTrackingRect: ptrTrackingTag]; + ptrTrackingTag = 0; + } pthread_mutex_destroy(&softLockSync); #ifdef VERBOSE_ON - NSLog(@"NewtView::dealloc\n"); - NSLog(@"%@",[NSThread callStackSymbols]); + //NSLog(@"%@",[NSThread callStackSymbols]); #endif + DBG_PRINT("NewtView::dealloc.X: %p\n", self); [super dealloc]; } @@ -390,25 +398,31 @@ static jmethodID windowRepaintID = NULL; mouseInside = NO; cursorIsHidden = NO; realized = YES; + DBG_PRINT("NewtWindow::create: %p (refcnt %d)\n", res, (int)[res retainCount]); return res; } - (void) release { + DBG_PRINT("NewtWindow::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); #ifdef VERBOSE_ON - NSLog(@"NewtWindow::release\n"); - NSLog(@"%@",[NSThread callStackSymbols]); + // NSLog(@"%@",[NSThread callStackSymbols]); #endif [super release]; } - (void) dealloc { + DBG_PRINT("NewtWindow::dealloc.0: %p (refcnt %d)\n", self, (int)[self retainCount]); #ifdef VERBOSE_ON - NSLog(@"NewtWindow::dealloc\n"); - NSLog(@"%@",[NSThread callStackSymbols]); + // NSLog(@"%@",[NSThread callStackSymbols]); #endif + NewtView* mView = (NewtView *)[self contentView]; + if( NULL != mView ) { + [mView release]; + } [super dealloc]; + DBG_PRINT("NewtWindow::dealloc.X: %p\n", self); } - (void) setUnrealized diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java index a14364e05..ce8f9adc8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java @@ -50,13 +50,14 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; -import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { static long durationPerTest = 50; static int addRemoveCount = 15; - static boolean shallUseOffscreenFBOLayer = false; + static boolean noOnscreenTest = false; + static boolean noOffscreenTest = false; static boolean shallUseOffscreenPBufferLayer = false; static GLProfile glp; static int width, height; @@ -64,8 +65,8 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { @BeforeClass public static void initClass() { - if(GLProfile.isAvailable(GLProfile.GL2)) { - glp = GLProfile.get(GLProfile.GL2); + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); Assert.assertNotNull(glp); width = 640; height = 480; @@ -139,6 +140,7 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { { for(int i=0; i Date: Sun, 17 Feb 2013 18:55:18 +0100 Subject: OSX/Java7 Cleanup: Remove JavaNativeFoundation dependency; NativeWindow-JAWT: Remove c.fixup.jawt.version.macosx (redundant, libjawt.dylib is rpath'ed always) --- make/build-nativewindow.xml | 19 ---------------- make/scripts/make.jogl.all.macosx-java7.sh | 2 +- make/scripts/make.jogl.all.macosx-java7u12ea.sh | 25 ++++++++++++++++++++++ make/scripts/tests-osx-x64-java7.sh | 2 +- make/scripts/tests-osx-x64-java7OnJava6build.sh | 12 +++++++++++ make/scripts/tests-osx-x64-java7u12ea.sh | 12 +++++++++++ .../tests-osx-x64-java7u12eaOnJava6Build.sh | 12 +++++++++++ src/nativewindow/native/macosx/OSXmisc.m | 7 ++---- 8 files changed, 65 insertions(+), 26 deletions(-) create mode 100755 make/scripts/make.jogl.all.macosx-java7u12ea.sh create mode 100755 make/scripts/tests-osx-x64-java7OnJava6build.sh create mode 100755 make/scripts/tests-osx-x64-java7u12ea.sh create mode 100755 make/scripts/tests-osx-x64-java7u12eaOnJava6Build.sh (limited to 'make/scripts') diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index 3c97d9d9b..a8408eaa7 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -361,7 +361,6 @@ - @@ -446,9 +445,6 @@ - - - @@ -735,20 +731,6 @@ - - - - - - - - - - - - diff --git a/make/scripts/make.jogl.all.macosx-java7.sh b/make/scripts/make.jogl.all.macosx-java7.sh index afb72bf8c..fc7ace9d0 100755 --- a/make/scripts/make.jogl.all.macosx-java7.sh +++ b/make/scripts/make.jogl.all.macosx-java7.sh @@ -22,4 +22,4 @@ ant \ -Dtarget.targetlevel=1.6 \ -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ -Drootrel.build=build-macosx-java7 \ - $* 2>&1 | tee make.jogl.all.macosx.log + $* 2>&1 | tee make.jogl.all.macosx-java7.log diff --git a/make/scripts/make.jogl.all.macosx-java7u12ea.sh b/make/scripts/make.jogl.all.macosx-java7u12ea.sh new file mode 100755 index 000000000..88f23b8ee --- /dev/null +++ b/make/scripts/make.jogl.all.macosx-java7u12ea.sh @@ -0,0 +1,25 @@ +#! /bin/sh + +if [ -e /opt-share/etc/profile.ant ] ; then + . /opt-share/etc/profile.ant +fi + + +# -Dc.compiler.debug=true \ +# -Djavacdebug="true" \ +# -Djavacdebuglevel="source,lines,vars" \ +# +# -Dtarget.sourcelevel=1.6 \ +# -Dtarget.targetlevel=1.6 \ +# -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ + +JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_12` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + +ant \ + -Dtarget.sourcelevel=1.6 \ + -Dtarget.targetlevel=1.6 \ + -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ + -Drootrel.build=build-macosx-java7 \ + $* 2>&1 | tee make.jogl.all.macosx-java7u12ea.log diff --git a/make/scripts/tests-osx-x64-java7.sh b/make/scripts/tests-osx-x64-java7.sh index e1b07202b..e870d0752 100755 --- a/make/scripts/tests-osx-x64-java7.sh +++ b/make/scripts/tests-osx-x64-java7.sh @@ -8,5 +8,5 @@ export JAVA_HOME PATH spath=`dirname $0` -. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* +. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx-java7 $* diff --git a/make/scripts/tests-osx-x64-java7OnJava6build.sh b/make/scripts/tests-osx-x64-java7OnJava6build.sh new file mode 100755 index 000000000..e1b07202b --- /dev/null +++ b/make/scripts/tests-osx-x64-java7OnJava6build.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH + +JAVA_HOME=`/usr/libexec/java_home -version 1.7` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + +spath=`dirname $0` + +. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* + diff --git a/make/scripts/tests-osx-x64-java7u12ea.sh b/make/scripts/tests-osx-x64-java7u12ea.sh new file mode 100755 index 000000000..a8c9bed77 --- /dev/null +++ b/make/scripts/tests-osx-x64-java7u12ea.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH + +JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_12` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + +spath=`dirname $0` + +. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx-java7 $* + diff --git a/make/scripts/tests-osx-x64-java7u12eaOnJava6Build.sh b/make/scripts/tests-osx-x64-java7u12eaOnJava6Build.sh new file mode 100755 index 000000000..dad9c430e --- /dev/null +++ b/make/scripts/tests-osx-x64-java7u12eaOnJava6Build.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH + +JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_12` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + +spath=`dirname $0` + +. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* + diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 8d876c175..4c07b4df7 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -39,7 +39,6 @@ #include "jogamp_nativewindow_jawt_macosx_MacOSXJAWTWindow.h" #include -#import // #define VERBOSE 1 // @@ -740,8 +739,7 @@ JNIEXPORT jint JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenRefreshR (JNIEnv *env, jclass unused, jint scrn_idx) { int res = 0; - JNF_COCOA_ENTER(env); - // NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSScreen *screen = NewtScreen_getNSScreenByIndex((int)scrn_idx); DBG_PRINT("GetScreenRefreshRate.0: screen %p\n", (void *)screen); if(NULL != screen) { @@ -760,8 +758,7 @@ JNIEXPORT jint JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenRefreshR res = 60; // default .. (experienced on OSX 10.6.8) } DBG_PRINT("GetScreenRefreshRate.X: %d\n", (int)res); - // [pool release]; - JNF_COCOA_EXIT(env); + [pool release]; return res; } -- cgit v1.2.3 From fc9539d50c12f9def7a3babde7384e3d38f61721 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Feb 2013 20:54:27 +0100 Subject: Unit Tests: Use Property 'jvmJava.exe' ; Add target 'junit.run.local.java7' (if="jvmJava7.exe") See GlueGen commit 6b86764f2e195b4046000fd5a7fcf3331ca72d21 --- make/build-test.xml | 45 ++++++++++++++++++++++-------- make/scripts/tests-macosx64-junit-java7.sh | 8 ++++++ 2 files changed, 42 insertions(+), 11 deletions(-) create mode 100644 make/scripts/tests-macosx64-junit-java7.sh (limited to 'make/scripts') diff --git a/make/build-test.xml b/make/build-test.xml index edef389cf..4163e98bb 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -196,7 +196,7 @@ - - + @@ -287,7 +287,7 @@ - - + @@ -369,7 +369,7 @@ - + @@ -406,11 +406,11 @@ - + + - - + @@ -496,7 +496,7 @@ - - + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/make/scripts/tests-macosx64-junit-java7.sh b/make/scripts/tests-macosx64-junit-java7.sh new file mode 100644 index 000000000..12be91bdf --- /dev/null +++ b/make/scripts/tests-macosx64-junit-java7.sh @@ -0,0 +1,8 @@ +#! /bin/bash + +export JAVA7_EXE=`/usr/libexec/java_home -version 1.7.0_12`/bin/java + +SDIR=`dirname $0` + +. $SDIR/make.jogl.all.macosx.sh -f build-test.xml junit.run.settings junit.run.local.java7 + -- cgit v1.2.3 From a40ee817a3bd537b0de7018772b0835f995a1bed Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Feb 2013 21:24:46 +0100 Subject: Unit Tests: Add 'results-java7' to check-junit.sh (Completes commit fc9539d50c12f9def7a3babde7384e3d38f61721) --- make/scripts/check-junit.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'make/scripts') diff --git a/make/scripts/check-junit.sh b/make/scripts/check-junit.sh index 474d074a6..232b3c6a2 100755 --- a/make/scripts/check-junit.sh +++ b/make/scripts/check-junit.sh @@ -35,4 +35,5 @@ function checkresult() { } checkresult results +checkresult results-java7 checkresult results-x32 -- cgit v1.2.3 From 85338858f5c58694fa88e77df1386d0556887944 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 19 Feb 2013 08:00:38 +0100 Subject: Bug 678 (fix), Bug 641 (API + Windows Impl.), Bug 688 (prep): Update NEWT's KeyEvent handling while distinguish keyCode (kbd layout independent) and keySym (kbd layout dependent) API Changes: - Virtual key codes and symbols are of type short. - KeyEvent.keySymbol() shall return a layout dependent value (Bug 641) - Method returns former keyCode() value, which was layout dependent. - Returns 'short' value - KeyEvent.keyCode() returns a short value, instead of int - KeyEvent.keyCode() shall return a layout independent value (Bug 641) - To ease implementation, we only 'require' the scan code to be mapped to a 'US Keyboard layout', which allows reusing layout dependent code while preserving the goal to have a fixed physical key association - Implementation status: - Windows OK - X11 TODO - OSX: 50/50 TODO - Using layout independent 'action keys' - Using layout dependent 'printable keys' - returning above semantics for both, keyCode and keySym - Android 50/50 TODO - Returning the layout independent keyCode - Mapping probably incomplete - KeyEvent.EVENT_KEY_TYPED and KeyListener.keyTyped(KeyEvent) (Bug 688) - Marked DEPRECATED - No more called for auto-repeat events - Synthesized in WindowImpl.consumeKeyEvent(..): No more injection by native- or java driver code - NEWTEvent.eventType: int -> short - field, as well as all method involving eventType changed to short. - NEWTEvent.isSystemEvent: REMOVED - Never used as well as never being implemented properly Internal Changes: - Simplified keyEvent driver code - Especially the Windows native driver's mapping code could be simplified using scanCode and MapVirtualKeyEx - NEWT Event Factories: hashMap -> switch/case Unit Tests: - - Added NewtCanvasAWT Offscreen Layer Tests important to test the AWT -> NEWT translation on OSX/CALayer: - TestNewtKeyCodeModifiersAWT - TestNewtKeyCodesAWT - TestNewtKeyEventAutoRepeatAWT - TestNewtKeyEventOrderAWT - TestNewtKeyPressReleaseUnmaskRepeatAWT --- make/build-test.xml | 38 ++ make/scripts/java-win32-dbg.bat | 1 + make/scripts/make.jogl.all.linux-x86_64.sh | 6 +- make/scripts/tests-x64.bat | 8 +- make/scripts/tests.sh | 7 +- .../classes/com/jogamp/newt/event/InputEvent.java | 10 +- .../classes/com/jogamp/newt/event/KeyEvent.java | 552 ++++++++------- .../classes/com/jogamp/newt/event/KeyListener.java | 18 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 61 +- .../classes/com/jogamp/newt/event/NEWTEvent.java | 72 +- .../classes/com/jogamp/newt/event/WindowEvent.java | 18 +- .../com/jogamp/newt/event/WindowUpdateEvent.java | 2 +- .../com/jogamp/newt/event/awt/AWTKeyAdapter.java | 3 - src/newt/classes/jogamp/newt/WindowImpl.java | 116 ++-- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 110 ++- .../android/event/AndroidNewtEventFactory.java | 100 ++- .../android/event/AndroidNewtEventTranslator.java | 8 +- .../newt/driver/linux/LinuxEventDeviceTracker.java | 33 +- .../newt/driver/linux/LinuxMouseTracker.java | 14 +- .../jogamp/newt/driver/macosx/MacKeyUtil.java | 262 ++++++-- .../jogamp/newt/driver/macosx/WindowDriver.java | 40 +- .../jogamp/newt/driver/windows/WindowDriver.java | 89 +-- .../jogamp/newt/driver/x11/WindowDriver.java | 33 +- .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 52 +- src/newt/native/KDWindow.c | 12 +- src/newt/native/NewtMacWindow.h | 6 +- src/newt/native/NewtMacWindow.m | 36 +- src/newt/native/WindowsWindow.c | 743 ++++++++------------- src/newt/native/X11Display.c | 142 ++-- src/newt/native/bcm_vc_iv.c | 8 +- .../newt/event/TestNewtKeyCodeModifiersAWT.java | 113 ++-- .../test/junit/newt/event/TestNewtKeyCodesAWT.java | 52 +- .../newt/event/TestNewtKeyEventAutoRepeatAWT.java | 21 +- .../junit/newt/event/TestNewtKeyEventOrderAWT.java | 32 +- .../TestNewtKeyPressReleaseUnmaskRepeatAWT.java | 26 +- .../jogamp/opengl/test/junit/util/MiscUtils.java | 16 + .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 136 ++-- 37 files changed, 1578 insertions(+), 1418 deletions(-) (limited to 'make/scripts') diff --git a/make/build-test.xml b/make/build-test.xml index 4163e98bb..b3b121049 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -442,6 +442,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat index 1852d9b0c..cb2108b58 100755 --- a/make/scripts/java-win32-dbg.bat +++ b/make/scripts/java-win32-dbg.bat @@ -37,6 +37,7 @@ REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" "-Djogl.debug=all" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Xcheck:jni" "-Xint" "-verbose:jni" set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh index 4642326d5..0bdde6831 100755 --- a/make/scripts/make.jogl.all.linux-x86_64.sh +++ b/make/scripts/make.jogl.all.linux-x86_64.sh @@ -28,6 +28,9 @@ fi # -Dtarget.sourcelevel=1.6 \ # -Dtarget.targetlevel=1.6 \ # -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ +# +# -Dsetup.addNativeOpenMAX=true \ +# -Dsetup.addNativeKD=true \ #LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64 @@ -52,9 +55,6 @@ ant \ -Dtarget.sourcelevel=1.6 \ -Dtarget.targetlevel=1.6 \ -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ - -Djavacdebuglevel="source,lines,vars" \ -Drootrel.build=build-x86_64 \ - -Dsetup.addNativeOpenMAX=true \ - -Dsetup.addNativeKD=true \ $* 2>&1 | tee -a $LOGF diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index b4b05d58b..df855bf56 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -65,14 +65,16 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* + +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5a7c0f0ec..7a65c736a 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -168,7 +168,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -302,7 +302,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove03GLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* @@ -417,8 +417,9 @@ testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanva #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index ad77ec79f..9ef4de2b6 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -86,7 +86,7 @@ public abstract class InputEvent extends NEWTEvent */ public static final Object consumedTag = new Object(); - protected InputEvent(int eventType, Object source, long when, int modifiers) { + protected InputEvent(short eventType, Object source, long when, int modifiers) { super(eventType, source, when); this.modifiers=modifiers; } @@ -154,16 +154,16 @@ public abstract class InputEvent extends NEWTEvent * @return Array of pressed mouse buttons [{@link MouseEvent#BUTTON1} .. {@link MouseEvent#BUTTON6}]. * If none is down, the resulting array is of length 0. */ - public final int[] getButtonsDown() { + public final short[] getButtonsDown() { int len = 0; for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { - if(isButtonDown(i)) { len++; } + if( isButtonDown(i) ) { len++; } } - int[] res = new int[len]; + short[] res = new short[len]; int j = 0; for(int i=1; i<=MouseEvent.BUTTON_NUMBER; i++) { - if(isButtonDown(i)) { res[j++] = ( MouseEvent.BUTTON1 - 1 ) + i; } + if( isButtonDown(i) ) { res[j++] = (short) ( ( MouseEvent.BUTTON1 - 1 ) + i ); } } return res; } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index ff67b7f57..f626fec38 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -36,68 +36,123 @@ package com.jogamp.newt.event; /** * Key events are delivered in the following order: - *
      - *
    1. {@link #EVENT_KEY_PRESSED}
    2. - *
    3. {@link #EVENT_KEY_RELEASED}
    4. - *
    5. {@link #EVENT_KEY_TYPED}
    6. - *
    + *

    + * + * + * + * + * + *
    #Event Type Constraints Notes
    1{@link #EVENT_KEY_PRESSED} excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys
    2{@link #EVENT_KEY_RELEASED} excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys
    3{@link #EVENT_KEY_TYPED} only for {@link #isPrintableKey() printable} and non {@link #isAutoRepeat() auto-repeat} keysDeprecated: Use {@link #EVENT_KEY_RELEASED} and apply constraints.
    + *

    * In case the native platform does not * deliver keyboard events in the above order or skip events, * the NEWT driver will reorder and inject synthetic events if required. *

    * Besides regular modifiers like {@link InputEvent#SHIFT_MASK} etc., - * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected. + * the {@link InputEvent#AUTOREPEAT_MASK} bit is added if repetition is detected, following above constraints. *

    *

    * Auto-Repeat shall behave as follow: *

    -    D = pressed, U = released, T = typed
    +    P = pressed, R = released, T = typed
         0 = normal, 1 = auto-repeat
     
    -    D(0), [ U(1), T(1), D(1), U(1) T(1) ..], U(0) T(0)
    +    P(0), [ R(1), P(1), R(1), ..], R(0) T(0)    
      * 
    * The idea is if you mask out auto-repeat in your event listener - * you just get one long pressed key D/U/T triple. + * or catch {@link #EVENT_KEY_TYPED typed} events only, + * you just get one long pressed P/R/T triple for {@link #isPrintableKey() printable} keys. + * {@link #isActionKey() Action} keys would produce one long pressed P/R tuple in case you mask out auto-repeat . + *

    + *

    + * {@link #isActionKey() Action} keys will produce {@link #EVENT_KEY_PRESSED pressed} + * and {@link #EVENT_KEY_RELEASED released} events including {@link #isAutoRepeat() auto-repeat}. + *

    + *

    + * {@link #isPrintableKey() Printable} keys will produce {@link #EVENT_KEY_PRESSED pressed}, + * {@link #EVENT_KEY_RELEASED released} and {@link #EVENT_KEY_TYPED typed} events, the latter is excluded for {@link #isAutoRepeat() auto-repeat} events. *

    *

    - * {@link #isModifierKey() Modifiers keys} will produce regular events (pressed, released and typed), - * however they will not produce Auto-Repeat events itself. + * {@link #isModifierKey() Modifier} keys will produce {@link #EVENT_KEY_PRESSED pressed} + * and {@link #EVENT_KEY_RELEASED released} events excluding {@link #isAutoRepeat() auto-repeat}. + * They will also influence subsequent event's {@link #getModifiers() modifier} bits while pressed. *

    */ @SuppressWarnings("serial") public class KeyEvent extends InputEvent { - public KeyEvent(int eventType, Object source, long when, int modifiers, int keyCode, char keyChar) { + public KeyEvent(short eventType, Object source, long when, int modifiers, short keyCode, short keySym, char keyChar) { super(eventType, source, when, modifiers); this.keyCode=keyCode; + this.keySym=keySym; this.keyChar=keyChar; + { // cache modifier and action flags + byte _flags = 0; + if( isModifierKey(keySym) ) { + _flags |= F_MODIFIER_MASK; + } + if( isActionKey(keySym) ) { + _flags |= F_ACTION_MASK; + } + flags = _flags; + } } /** - * Returns the character matching the {@link #getKeyCode() virtual key code}. + * Returns the UTF-16 character reflecting the {@link #getKeySymbol() key symbol}. + * @see #getKeySymbol() + * @see #getKeyCode() */ - public char getKeyChar() { + public final char getKeyChar() { return keyChar; } - /** Returns the virtual key code. */ - public int getKeyCode() { + /** + * Returns the virtual key symbol reflecting the current keyboard layout. + * @see #getKeyChar() + * @see #getKeyCode() + */ + public final short getKeySymbol() { + return keySym; + } + + /** + * Returns the virtual key code using a fixed mapping to the US keyboard layout. + *

    + * In contrast to {@link #getKeySymbol() key symbol}, key code + * uses a fixed US keyboard layout and therefore is keyboard layout independent. + *

    + *

    + * E.g. virtual key code {@link #VK_Y} denotes the same physical key + * regardless whether keyboard layout QWERTY or + * QWERTZ is active. The {@link #getKeySymbol() key symbol} of the former is + * {@link #VK_Y}, where the latter produces {@link #VK_Y}. + *

    + *

    + * Disclaimer: In case key code is not implemented on your platform (OSX, ..) + * the {@link #getKeySymbol() key symbol} is returned. + *

    + * @see #getKeyChar() + * @see #getKeySymbol() + */ + public final short getKeyCode() { return keyCode; } - public String toString() { + public final String toString() { return toString(null).toString(); } - public StringBuilder toString(StringBuilder sb) { + public final StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); } - sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(keyCode).append("(").append(toHexString(keyCode)).append("), char '").append(keyChar).append("' (").append(toHexString((int)keyChar)).append("), isActionKey ").append(isActionKey()).append(", "); + sb.append("KeyEvent[").append(getEventTypeString(getEventType())).append(", code ").append(toHexString(keyCode)).append(", sym ").append(toHexString(keySym)).append(", char '").append(keyChar).append("' (").append(toHexString((short)keyChar)) + .append("), isModifierKey ").append(isModifierKey()).append(", isActionKey ").append(isActionKey()).append(", "); return super.toString(sb).append("]"); } - public static String getEventTypeString(int type) { + public static String getEventTypeString(short type) { switch(type) { case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED"; case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED"; @@ -107,13 +162,13 @@ public class KeyEvent extends InputEvent } /** - * Returns true if the given keyCode represents a non-printable modifier key. + * Returns true if the given virtualKey represents a modifier key, otherwise false. *

    * A modifier key is one of {@link #VK_SHIFT}, {@link #VK_CONTROL}, {@link #VK_ALT}, {@link #VK_ALT_GRAPH}, {@link #VK_META}. *

    */ - public static boolean isModifierKey(int keyCode) { - switch (keyCode) { + public static boolean isModifierKey(short vKey) { + switch (vKey) { case VK_SHIFT: case VK_CONTROL: case VK_ALT: @@ -126,31 +181,36 @@ public class KeyEvent extends InputEvent } /** - * Returns true if {@link #getKeyCode()} represents a non-printable modifier key. + * Returns true if {@link #getKeySymbol() key symbol} represents a modifier key, + * otherwise false. + *

    + * See {@link #isModifierKey(short)} for details. + *

    *

    - * See {@link #isModifierKey(int)} for details. + * Note: Implementation uses a cached value. *

    */ - public boolean isModifierKey() { - return isModifierKey(keyCode); + public final boolean isModifierKey() { + return 0 != ( F_MODIFIER_MASK & flags ) ; } /** - * Returns true if the given keyCode represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}. + * Returns true if the given virtualKey represents a non-printable and + * non-{@link #isModifierKey(short) modifier} action key, otherwise false. *

    * An action key is one of {@link #VK_HOME}, {@link #VK_END}, {@link #VK_PAGE_UP}, {@link #VK_PAGE_DOWN}, {@link #VK_UP}, {@link #VK_PAGE_DOWN}, * {@link #VK_LEFT}, {@link #VK_RIGHT}, {@link #VK_F1}-{@link #VK_F24}, {@link #VK_PRINTSCREEN}, {@link #VK_CAPS_LOCK}, {@link #VK_PAUSE}, * {@link #VK_INSERT}, {@link #VK_HELP}, {@link #VK_WINDOWS}, etc ... *

    */ - public static boolean isActionKey(int keyCode) { - if( ( VK_F1 <= keyCode && keyCode <= VK_F24 ) || - ( VK_ALL_CANDIDATES <= keyCode && keyCode <= VK_INPUT_METHOD_ON_OFF ) || - ( VK_CUT <= keyCode && keyCode <= VK_STOP ) ) { + public static boolean isActionKey(short vKey) { + if( ( VK_F1 <= vKey && vKey <= VK_F24 ) || + ( VK_ALL_CANDIDATES <= vKey && vKey <= VK_INPUT_METHOD_ON_OFF ) || + ( VK_CUT <= vKey && vKey <= VK_STOP ) ) { return true; } - switch (keyCode) { + switch (vKey) { case VK_CANCEL: case VK_CLEAR: case VK_PAUSE: @@ -208,600 +268,614 @@ public class KeyEvent extends InputEvent } /** - * Returns true if {@link #getKeyCode() keyCode} represents a non-printable action key, which is not a {@link #isModifierKey(int) modifier key}. + * Returns true if {@link #getKeySymbol() key symbol} represents a non-printable and + * non-{@link #isModifierKey(short) modifier} action key, otherwise false. *

    - * See {@link #isActionKey(int)} for details. + * See {@link #isActionKey(short)} for details. *

    */ - public boolean isActionKey() { - return isActionKey(keyCode); + public final boolean isActionKey() { + return 0 != ( F_ACTION_MASK & flags ) ; } /** - * Returns true if given keyKode represents a printable character, which is neither a {@link #isModifierKey(int) modifier key} - * nor an {@link #isActionKey(int) action key}. + * Returns true if given virtualKey represents a printable character, + * i.e. neither a {@link #isModifierKey(short) modifier key} + * nor an {@link #isActionKey(short) action key}. * Otherwise returns false. */ - public static boolean isPrintableKey(int keyCode) { - return !isModifierKey(keyCode) && !isActionKey(keyCode); + public static boolean isPrintableKey(short vKey) { + return !isModifierKey(vKey) && !isActionKey(vKey); } /** - * Returns true if {@link #getKeyCode() keyCode} represents a printable character, which is neither a {@link #isModifierKey(int) modifier key} - * nor an {@link #isActionKey(int) action key}. + * Returns true if {@link #getKeySymbol() key symbol} represents a printable character, + * i.e. neither a {@link #isModifierKey(short) modifier key} + * nor an {@link #isActionKey(short) action key}. * Otherwise returns false. */ - public boolean isPrintableKey() { - return isPrintableKey(keyCode); + public final boolean isPrintableKey() { + return 0 == ( F_NON_PRINT_MASK & flags ) ; } - private final int keyCode; + private final short keyCode; + private final short keySym; private final char keyChar; - - public static final int EVENT_KEY_PRESSED = 300; - public static final int EVENT_KEY_RELEASED= 301; - public static final int EVENT_KEY_TYPED = 302; + private final byte flags; + private static final byte F_MODIFIER_MASK = 1 << 0; + private static final byte F_ACTION_MASK = 1 << 1; + private static final byte F_NON_PRINT_MASK = F_MODIFIER_MASK | F_ACTION_MASK ; + + /** A key has been pressed, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */ + public static final short EVENT_KEY_PRESSED = 300; + /** A key has been released, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */ + public static final short EVENT_KEY_RELEASED= 301; + /** + * A {@link #isPrintableKey() printable} key has been typed (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. + * @deprecated Redundant, will be removed soon. Use {@link #EVENT_KEY_RELEASED} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}. + */ + public static final short EVENT_KEY_TYPED = 302; /* Virtual key codes. */ - public static final int VK_CANCEL = 0x03; - public static final int VK_BACK_SPACE = 0x08; // '\b' - public static final int VK_TAB = 0x09; // '\t' - public static final int VK_ENTER = 0x0A; // '\n' - public static final int VK_CLEAR = 0x0C; - public static final int VK_SHIFT = 0x10; - public static final int VK_CONTROL = 0x11; - public static final int VK_ALT = 0x12; - public static final int VK_PAUSE = 0x13; - public static final int VK_CAPS_LOCK = 0x14; - public static final int VK_ESCAPE = 0x1B; - public static final int VK_SPACE = 0x20; - public static final int VK_PAGE_UP = 0x21; - public static final int VK_PAGE_DOWN = 0x22; - public static final int VK_END = 0x23; - public static final int VK_HOME = 0x24; + public static final short VK_CANCEL = (short) 0x03; + public static final short VK_BACK_SPACE = (short) 0x08; // '\b' + public static final short VK_TAB = (short) 0x09; // '\t' + public static final short VK_ENTER = (short) 0x0A; // '\n' + public static final short VK_CLEAR = (short) 0x0C; + public static final short VK_SHIFT = (short) 0x10; + public static final short VK_CONTROL = (short) 0x11; + public static final short VK_ALT = (short) 0x12; + public static final short VK_PAUSE = (short) 0x13; + public static final short VK_CAPS_LOCK = (short) 0x14; + public static final short VK_ESCAPE = (short) 0x1B; + public static final short VK_SPACE = (short) 0x20; + public static final short VK_PAGE_UP = (short) 0x21; + public static final short VK_PAGE_DOWN = (short) 0x22; + public static final short VK_END = (short) 0x23; + public static final short VK_HOME = (short) 0x24; /** * Constant for the non-numpad left arrow key. * @see #VK_KP_LEFT */ - public static final int VK_LEFT = 0x25; + public static final short VK_LEFT = (short) 0x25; /** * Constant for the non-numpad up arrow key. * @see #VK_KP_UP */ - public static final int VK_UP = 0x26; + public static final short VK_UP = (short) 0x26; /** * Constant for the non-numpad right arrow key. * @see #VK_KP_RIGHT */ - public static final int VK_RIGHT = 0x27; + public static final short VK_RIGHT = (short) 0x27; /** * Constant for the non-numpad down arrow key. * @see #VK_KP_DOWN */ - public static final int VK_DOWN = 0x28; + public static final short VK_DOWN = (short) 0x28; /** * Constant for the comma key, "," */ - public static final int VK_COMMA = 0x2C; + public static final short VK_COMMA = (short) 0x2C; /** * Constant for the minus key, "-" * @since 1.2 */ - public static final int VK_MINUS = 0x2D; + public static final short VK_MINUS = (short) 0x2D; /** * Constant for the period key, "." */ - public static final int VK_PERIOD = 0x2E; + public static final short VK_PERIOD = (short) 0x2E; /** * Constant for the forward slash key, "/" */ - public static final int VK_SLASH = 0x2F; + public static final short VK_SLASH = (short) 0x2F; /** VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */ - public static final int VK_0 = 0x30; - public static final int VK_1 = 0x31; - public static final int VK_2 = 0x32; - public static final int VK_3 = 0x33; - public static final int VK_4 = 0x34; - public static final int VK_5 = 0x35; - public static final int VK_6 = 0x36; - public static final int VK_7 = 0x37; - public static final int VK_8 = 0x38; - public static final int VK_9 = 0x39; + public static final short VK_0 = (short) 0x30; + public static final short VK_1 = (short) 0x31; + public static final short VK_2 = (short) 0x32; + public static final short VK_3 = (short) 0x33; + public static final short VK_4 = (short) 0x34; + public static final short VK_5 = (short) 0x35; + public static final short VK_6 = (short) 0x36; + public static final short VK_7 = (short) 0x37; + public static final short VK_8 = (short) 0x38; + public static final short VK_9 = (short) 0x39; /** * Constant for the semicolon key, ";" */ - public static final int VK_SEMICOLON = 0x3B; + public static final short VK_SEMICOLON = (short) 0x3B; /** * Constant for the equals key, "=" */ - public static final int VK_EQUALS = 0x3D; + public static final short VK_EQUALS = (short) 0x3D; /** VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */ - public static final int VK_A = 0x41; - public static final int VK_B = 0x42; - public static final int VK_C = 0x43; - public static final int VK_D = 0x44; - public static final int VK_E = 0x45; - public static final int VK_F = 0x46; - public static final int VK_G = 0x47; - public static final int VK_H = 0x48; - public static final int VK_I = 0x49; - public static final int VK_J = 0x4A; - public static final int VK_K = 0x4B; - public static final int VK_L = 0x4C; - public static final int VK_M = 0x4D; - public static final int VK_N = 0x4E; - public static final int VK_O = 0x4F; - public static final int VK_P = 0x50; - public static final int VK_Q = 0x51; - public static final int VK_R = 0x52; - public static final int VK_S = 0x53; - public static final int VK_T = 0x54; - public static final int VK_U = 0x55; - public static final int VK_V = 0x56; - public static final int VK_W = 0x57; - public static final int VK_X = 0x58; - public static final int VK_Y = 0x59; - public static final int VK_Z = 0x5A; + public static final short VK_A = (short) 0x41; + public static final short VK_B = (short) 0x42; + public static final short VK_C = (short) 0x43; + public static final short VK_D = (short) 0x44; + public static final short VK_E = (short) 0x45; + public static final short VK_F = (short) 0x46; + public static final short VK_G = (short) 0x47; + public static final short VK_H = (short) 0x48; + public static final short VK_I = (short) 0x49; + public static final short VK_J = (short) 0x4A; + public static final short VK_K = (short) 0x4B; + public static final short VK_L = (short) 0x4C; + public static final short VK_M = (short) 0x4D; + public static final short VK_N = (short) 0x4E; + public static final short VK_O = (short) 0x4F; + public static final short VK_P = (short) 0x50; + public static final short VK_Q = (short) 0x51; + public static final short VK_R = (short) 0x52; + public static final short VK_S = (short) 0x53; + public static final short VK_T = (short) 0x54; + public static final short VK_U = (short) 0x55; + public static final short VK_V = (short) 0x56; + public static final short VK_W = (short) 0x57; + public static final short VK_X = (short) 0x58; + public static final short VK_Y = (short) 0x59; + public static final short VK_Z = (short) 0x5A; /** * Constant for the open bracket key, "[" */ - public static final int VK_OPEN_BRACKET = 0x5B; + public static final short VK_OPEN_BRACKET = (short) 0x5B; /** * Constant for the back slash key, "\" */ - public static final int VK_BACK_SLASH = 0x5C; + public static final short VK_BACK_SLASH = (short) 0x5C; /** * Constant for the close bracket key, "]" */ - public static final int VK_CLOSE_BRACKET = 0x5D; - - public static final int VK_NUMPAD0 = 0x60; - public static final int VK_NUMPAD1 = 0x61; - public static final int VK_NUMPAD2 = 0x62; - public static final int VK_NUMPAD3 = 0x63; - public static final int VK_NUMPAD4 = 0x64; - public static final int VK_NUMPAD5 = 0x65; - public static final int VK_NUMPAD6 = 0x66; - public static final int VK_NUMPAD7 = 0x67; - public static final int VK_NUMPAD8 = 0x68; - public static final int VK_NUMPAD9 = 0x69; - public static final int VK_MULTIPLY = 0x6A; - public static final int VK_ADD = 0x6B; + public static final short VK_CLOSE_BRACKET = (short) 0x5D; + + public static final short VK_NUMPAD0 = (short) 0x60; + public static final short VK_NUMPAD1 = (short) 0x61; + public static final short VK_NUMPAD2 = (short) 0x62; + public static final short VK_NUMPAD3 = (short) 0x63; + public static final short VK_NUMPAD4 = (short) 0x64; + public static final short VK_NUMPAD5 = (short) 0x65; + public static final short VK_NUMPAD6 = (short) 0x66; + public static final short VK_NUMPAD7 = (short) 0x67; + public static final short VK_NUMPAD8 = (short) 0x68; + public static final short VK_NUMPAD9 = (short) 0x69; + public static final short VK_MULTIPLY = (short) 0x6A; + public static final short VK_ADD = (short) 0x6B; /** * Constant for the Numpad Separator key. */ - public static final int VK_SEPARATOR = 0x6C; + public static final short VK_SEPARATOR = (short) 0x6C; - public static final int VK_SUBTRACT = 0x6D; - public static final int VK_DECIMAL = 0x6E; - public static final int VK_DIVIDE = 0x6F; - public static final int VK_DELETE = 0x7F; /* ASCII DEL */ - public static final int VK_NUM_LOCK = 0x90; - public static final int VK_SCROLL_LOCK = 0x91; + public static final short VK_SUBTRACT = (short) 0x6D; + public static final short VK_DECIMAL = (short) 0x6E; + public static final short VK_DIVIDE = (short) 0x6F; + public static final short VK_DELETE = (short) 0x7F; /* ASCII DEL */ + public static final short VK_NUM_LOCK = (short) 0x90; + public static final short VK_SCROLL_LOCK = (short) 0x91; /** Constant for the F1 function key. */ - public static final int VK_F1 = 0x70; + public static final short VK_F1 = (short) 0x70; /** Constant for the F2 function key. */ - public static final int VK_F2 = 0x71; + public static final short VK_F2 = (short) 0x71; /** Constant for the F3 function key. */ - public static final int VK_F3 = 0x72; + public static final short VK_F3 = (short) 0x72; /** Constant for the F4 function key. */ - public static final int VK_F4 = 0x73; + public static final short VK_F4 = (short) 0x73; /** Constant for the F5 function key. */ - public static final int VK_F5 = 0x74; + public static final short VK_F5 = (short) 0x74; /** Constant for the F6 function key. */ - public static final int VK_F6 = 0x75; + public static final short VK_F6 = (short) 0x75; /** Constant for the F7 function key. */ - public static final int VK_F7 = 0x76; + public static final short VK_F7 = (short) 0x76; /** Constant for the F8 function key. */ - public static final int VK_F8 = 0x77; + public static final short VK_F8 = (short) 0x77; /** Constant for the F9 function key. */ - public static final int VK_F9 = 0x78; + public static final short VK_F9 = (short) 0x78; /** Constant for the F10 function key. */ - public static final int VK_F10 = 0x79; + public static final short VK_F10 = (short) 0x79; /** Constant for the F11 function key. */ - public static final int VK_F11 = 0x7A; + public static final short VK_F11 = (short) 0x7A; /** Constant for the F12 function key. */ - public static final int VK_F12 = 0x7B; + public static final short VK_F12 = (short) 0x7B; /** * Constant for the F13 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F13 = 0xF000; + public static final short VK_F13 = (short) 0xF000; /** * Constant for the F14 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F14 = 0xF001; + public static final short VK_F14 = (short) 0xF001; /** * Constant for the F15 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F15 = 0xF002; + public static final short VK_F15 = (short) 0xF002; /** * Constant for the F16 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F16 = 0xF003; + public static final short VK_F16 = (short) 0xF003; /** * Constant for the F17 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F17 = 0xF004; + public static final short VK_F17 = (short) 0xF004; /** * Constant for the F18 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F18 = 0xF005; + public static final short VK_F18 = (short) 0xF005; /** * Constant for the F19 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F19 = 0xF006; + public static final short VK_F19 = (short) 0xF006; /** * Constant for the F20 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F20 = 0xF007; + public static final short VK_F20 = (short) 0xF007; /** * Constant for the F21 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F21 = 0xF008; + public static final short VK_F21 = (short) 0xF008; /** * Constant for the F22 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F22 = 0xF009; + public static final short VK_F22 = (short) 0xF009; /** * Constant for the F23 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F23 = 0xF00A; + public static final short VK_F23 = (short) 0xF00A; /** * Constant for the F24 function key. *

    F13 - F24 are used on IBM 3270 keyboard; use random range for constants.

    */ - public static final int VK_F24 = 0xF00B; + public static final short VK_F24 = (short) 0xF00B; - public static final int VK_PRINTSCREEN = 0x9A; - public static final int VK_INSERT = 0x9B; - public static final int VK_HELP = 0x9C; - public static final int VK_META = 0x9D; + public static final short VK_PRINTSCREEN = (short) 0x9A; + public static final short VK_INSERT = (short) 0x9B; + public static final short VK_HELP = (short) 0x9C; + public static final short VK_META = (short) 0x9D; - public static final int VK_BACK_QUOTE = 0xC0; - public static final int VK_QUOTE = 0xDE; + public static final short VK_BACK_QUOTE = (short) 0xC0; + public static final short VK_QUOTE = (short) 0xDE; /** * Constant for the numeric keypad up arrow key. * @see #VK_UP */ - public static final int VK_KP_UP = 0xE0; + public static final short VK_KP_UP = (short) 0xE0; /** * Constant for the numeric keypad down arrow key. * @see #VK_DOWN */ - public static final int VK_KP_DOWN = 0xE1; + public static final short VK_KP_DOWN = (short) 0xE1; /** * Constant for the numeric keypad left arrow key. * @see #VK_LEFT */ - public static final int VK_KP_LEFT = 0xE2; + public static final short VK_KP_LEFT = (short) 0xE2; /** * Constant for the numeric keypad right arrow key. * @see #VK_RIGHT */ - public static final int VK_KP_RIGHT = 0xE3; + public static final short VK_KP_RIGHT = (short) 0xE3; /** For European keyboards */ - public static final int VK_DEAD_GRAVE = 0x80; + public static final short VK_DEAD_GRAVE = (short) 0x80; /** For European keyboards */ - public static final int VK_DEAD_ACUTE = 0x81; + public static final short VK_DEAD_ACUTE = (short) 0x81; /** For European keyboards */ - public static final int VK_DEAD_CIRCUMFLEX = 0x82; + public static final short VK_DEAD_CIRCUMFLEX = (short) 0x82; /** For European keyboards */ - public static final int VK_DEAD_TILDE = 0x83; + public static final short VK_DEAD_TILDE = (short) 0x83; /** For European keyboards */ - public static final int VK_DEAD_MACRON = 0x84; + public static final short VK_DEAD_MACRON = (short) 0x84; /** For European keyboards */ - public static final int VK_DEAD_BREVE = 0x85; + public static final short VK_DEAD_BREVE = (short) 0x85; /** For European keyboards */ - public static final int VK_DEAD_ABOVEDOT = 0x86; + public static final short VK_DEAD_ABOVEDOT = (short) 0x86; /** For European keyboards */ - public static final int VK_DEAD_DIAERESIS = 0x87; + public static final short VK_DEAD_DIAERESIS = (short) 0x87; /** For European keyboards */ - public static final int VK_DEAD_ABOVERING = 0x88; + public static final short VK_DEAD_ABOVERING = (short) 0x88; /** For European keyboards */ - public static final int VK_DEAD_DOUBLEACUTE = 0x89; + public static final short VK_DEAD_DOUBLEACUTE = (short) 0x89; /** For European keyboards */ - public static final int VK_DEAD_CARON = 0x8a; + public static final short VK_DEAD_CARON = (short) 0x8a; /** For European keyboards */ - public static final int VK_DEAD_CEDILLA = 0x8b; + public static final short VK_DEAD_CEDILLA = (short) 0x8b; /** For European keyboards */ - public static final int VK_DEAD_OGONEK = 0x8c; + public static final short VK_DEAD_OGONEK = (short) 0x8c; /** For European keyboards */ - public static final int VK_DEAD_IOTA = 0x8d; + public static final short VK_DEAD_IOTA = (short) 0x8d; /** For European keyboards */ - public static final int VK_DEAD_VOICED_SOUND = 0x8e; + public static final short VK_DEAD_VOICED_SOUND = (short) 0x8e; /** For European keyboards */ - public static final int VK_DEAD_SEMIVOICED_SOUND = 0x8f; + public static final short VK_DEAD_SEMIVOICED_SOUND = (short) 0x8f; /** For European keyboards */ - public static final int VK_AMPERSAND = 0x96; + public static final short VK_AMPERSAND = (short) 0x96; /** For European keyboards */ - public static final int VK_ASTERISK = 0x97; + public static final short VK_ASTERISK = (short) 0x97; /** For European keyboards */ - public static final int VK_QUOTEDBL = 0x98; + public static final short VK_QUOTEDBL = (short) 0x98; /** For European keyboards */ - public static final int VK_LESS = 0x99; + public static final short VK_LESS = (short) 0x99; /** For European keyboards */ - public static final int VK_GREATER = 0xa0; + public static final short VK_GREATER = (short) 0xa0; /** For European keyboards */ - public static final int VK_BRACELEFT = 0xa1; + public static final short VK_BRACELEFT = (short) 0xa1; /** For European keyboards */ - public static final int VK_BRACERIGHT = 0xa2; + public static final short VK_BRACERIGHT = (short) 0xa2; /** * Constant for the "@" key. */ - public static final int VK_AT = 0x0200; + public static final short VK_AT = (short) 0x0200; /** * Constant for the ":" key. */ - public static final int VK_COLON = 0x0201; + public static final short VK_COLON = (short) 0x0201; /** * Constant for the "^" key. */ - public static final int VK_CIRCUMFLEX = 0x0202; + public static final short VK_CIRCUMFLEX = (short) 0x0202; /** * Constant for the "$" key. */ - public static final int VK_DOLLAR = 0x0203; + public static final short VK_DOLLAR = (short) 0x0203; /** * Constant for the Euro currency sign key. */ - public static final int VK_EURO_SIGN = 0x0204; + public static final short VK_EURO_SIGN = (short) 0x0204; /** * Constant for the "!" key. */ - public static final int VK_EXCLAMATION_MARK = 0x0205; + public static final short VK_EXCLAMATION_MARK = (short) 0x0205; /** * Constant for the inverted exclamation mark key. */ - public static final int VK_INVERTED_EXCLAMATION_MARK = 0x0206; + public static final short VK_INVERTED_EXCLAMATION_MARK = (short) 0x0206; /** * Constant for the "(" key. */ - public static final int VK_LEFT_PARENTHESIS = 0x0207; + public static final short VK_LEFT_PARENTHESIS = (short) 0x0207; /** * Constant for the "#" key. */ - public static final int VK_NUMBER_SIGN = 0x0208; + public static final short VK_NUMBER_SIGN = (short) 0x0208; /** * Constant for the "+" key. */ - public static final int VK_PLUS = 0x0209; + public static final short VK_PLUS = (short) 0x0209; /** * Constant for the ")" key. */ - public static final int VK_RIGHT_PARENTHESIS = 0x020A; + public static final short VK_RIGHT_PARENTHESIS = (short) 0x020A; /** * Constant for the "_" key. */ - public static final int VK_UNDERSCORE = 0x020B; + public static final short VK_UNDERSCORE = (short) 0x020B; /** * Constant for the Microsoft Windows "Windows" key. * It is used for both the left and right version of the key. */ - public static final int VK_WINDOWS = 0x020C; + public static final short VK_WINDOWS = (short) 0x020C; /** * Constant for the Microsoft Windows Context Menu key. */ - public static final int VK_CONTEXT_MENU = 0x020D; + public static final short VK_CONTEXT_MENU = (short) 0x020D; /* for input method support on Asian Keyboards */ /* not clear what this means - listed in Microsoft Windows API */ - public static final int VK_FINAL = 0x0018; + public static final short VK_FINAL = (short) 0x0018; /** Constant for the Convert function key. */ /* Japanese PC 106 keyboard, Japanese Solaris keyboard: henkan */ - public static final int VK_CONVERT = 0x001C; + public static final short VK_CONVERT = (short) 0x001C; /** Constant for the Don't Convert function key. */ /* Japanese PC 106 keyboard: muhenkan */ - public static final int VK_NONCONVERT = 0x001D; + public static final short VK_NONCONVERT = (short) 0x001D; /** Constant for the Accept or Commit function key. */ /* Japanese Solaris keyboard: kakutei */ - public static final int VK_ACCEPT = 0x001E; + public static final short VK_ACCEPT = (short) 0x001E; /* not clear what this means - listed in Microsoft Windows API */ - public static final int VK_MODECHANGE = 0x001F; + public static final short VK_MODECHANGE = (short) 0x001F; /* replaced by VK_KANA_LOCK for Microsoft Windows and Solaris; might still be used on other platforms */ - public static final int VK_KANA = 0x0015; + public static final short VK_KANA = (short) 0x0015; /* replaced by VK_INPUT_METHOD_ON_OFF for Microsoft Windows and Solaris; might still be used for other platforms */ - public static final int VK_KANJI = 0x0019; + public static final short VK_KANJI = (short) 0x0019; /** * Constant for the Alphanumeric function key. */ /* Japanese PC 106 keyboard: eisuu */ - public static final int VK_ALPHANUMERIC = 0x00F0; + public static final short VK_ALPHANUMERIC = (short) 0x00F0; /** * Constant for the Katakana function key. */ /* Japanese PC 106 keyboard: katakana */ - public static final int VK_KATAKANA = 0x00F1; + public static final short VK_KATAKANA = (short) 0x00F1; /** * Constant for the Hiragana function key. */ /* Japanese PC 106 keyboard: hiragana */ - public static final int VK_HIRAGANA = 0x00F2; + public static final short VK_HIRAGANA = (short) 0x00F2; /** * Constant for the Full-Width Characters function key. */ /* Japanese PC 106 keyboard: zenkaku */ - public static final int VK_FULL_WIDTH = 0x00F3; + public static final short VK_FULL_WIDTH = (short) 0x00F3; /** * Constant for the Half-Width Characters function key. */ /* Japanese PC 106 keyboard: hankaku */ - public static final int VK_HALF_WIDTH = 0x00F4; + public static final short VK_HALF_WIDTH = (short) 0x00F4; /** * Constant for the Roman Characters function key. */ /* Japanese PC 106 keyboard: roumaji */ - public static final int VK_ROMAN_CHARACTERS = 0x00F5; + public static final short VK_ROMAN_CHARACTERS = (short) 0x00F5; /** * Constant for the All Candidates function key. */ /* Japanese PC 106 keyboard - VK_CONVERT + ALT: zenkouho */ - public static final int VK_ALL_CANDIDATES = 0x0100; + public static final short VK_ALL_CANDIDATES = (short) 0x0100; /** * Constant for the Previous Candidate function key. */ /* Japanese PC 106 keyboard - VK_CONVERT + SHIFT: maekouho */ - public static final int VK_PREVIOUS_CANDIDATE = 0x0101; + public static final short VK_PREVIOUS_CANDIDATE = (short) 0x0101; /** * Constant for the Code Input function key. */ /* Japanese PC 106 keyboard - VK_ALPHANUMERIC + ALT: kanji bangou */ - public static final int VK_CODE_INPUT = 0x0102; + public static final short VK_CODE_INPUT = (short) 0x0102; /** * Constant for the Japanese-Katakana function key. * This key switches to a Japanese input method and selects its Katakana input mode. */ /* Japanese Macintosh keyboard - VK_JAPANESE_HIRAGANA + SHIFT */ - public static final int VK_JAPANESE_KATAKANA = 0x0103; + public static final short VK_JAPANESE_KATAKANA = (short) 0x0103; /** * Constant for the Japanese-Hiragana function key. * This key switches to a Japanese input method and selects its Hiragana input mode. */ /* Japanese Macintosh keyboard */ - public static final int VK_JAPANESE_HIRAGANA = 0x0104; + public static final short VK_JAPANESE_HIRAGANA = (short) 0x0104; /** * Constant for the Japanese-Roman function key. * This key switches to a Japanese input method and selects its Roman-Direct input mode. */ /* Japanese Macintosh keyboard */ - public static final int VK_JAPANESE_ROMAN = 0x0105; + public static final short VK_JAPANESE_ROMAN = (short) 0x0105; /** * Constant for the locking Kana function key. * This key locks the keyboard into a Kana layout. */ /* Japanese PC 106 keyboard with special Windows driver - eisuu + Control; Japanese Solaris keyboard: kana */ - public static final int VK_KANA_LOCK = 0x0106; + public static final short VK_KANA_LOCK = (short) 0x0106; /** * Constant for the input method on/off key. */ /* Japanese PC 106 keyboard: kanji. Japanese Solaris keyboard: nihongo */ - public static final int VK_INPUT_METHOD_ON_OFF = 0x0107; + public static final short VK_INPUT_METHOD_ON_OFF = (short) 0x0107; /* for Sun keyboards */ - public static final int VK_CUT = 0xFFD1; - public static final int VK_COPY = 0xFFCD; - public static final int VK_PASTE = 0xFFCF; - public static final int VK_UNDO = 0xFFCB; - public static final int VK_AGAIN = 0xFFC9; - public static final int VK_FIND = 0xFFD0; - public static final int VK_PROPS = 0xFFCA; - public static final int VK_STOP = 0xFFC8; + public static final short VK_CUT = (short) 0xFFD1; + public static final short VK_COPY = (short) 0xFFCD; + public static final short VK_PASTE = (short) 0xFFCF; + public static final short VK_UNDO = (short) 0xFFCB; + public static final short VK_AGAIN = (short) 0xFFC9; + public static final short VK_FIND = (short) 0xFFD0; + public static final short VK_PROPS = (short) 0xFFCA; + public static final short VK_STOP = (short) 0xFFC8; /** * Constant for the Compose function key. */ - public static final int VK_COMPOSE = 0xFF20; + public static final short VK_COMPOSE = (short) 0xFF20; /** * Constant for the AltGraph function key. */ - public static final int VK_ALT_GRAPH = 0xFF7E; + public static final short VK_ALT_GRAPH = (short) 0xFF7E; /** * Constant for the Begin key. */ - public static final int VK_BEGIN = 0xFF58; + public static final short VK_BEGIN = (short) 0xFF58; /** * This value is used to indicate that the keyCode is unknown. * KEY_TYPED events do not have a keyCode value; this value * is used instead. */ - public static final int VK_UNDEFINED = 0x0; + public static final short VK_UNDEFINED = (short) 0x0; } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyListener.java b/src/newt/classes/com/jogamp/newt/event/KeyListener.java index dae343d80..5bca733d3 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyListener.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyListener.java @@ -34,10 +34,22 @@ package com.jogamp.newt.event; +/** + * Listener for {@link KeyEvent}s. + * + * @see KeyEvent + */ public interface KeyListener extends NEWTEventListener { - public void keyPressed(KeyEvent e); - public void keyReleased(KeyEvent e); - public void keyTyped(KeyEvent e) ; + /** A key has been {@link KeyEvent#EVENT_KEY_PRESSED pressed}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ + public void keyPressed(KeyEvent e); + /** A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ + public void keyReleased(KeyEvent e); + + /** + * A {@link #isPrintableKey() printable} key has been {@link KeyEvent#EVENT_KEY_TYPED typed} (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. See {@link KeyEvent}. + * @deprecated Redundant, will be removed soon. Use {@link #keyReleased(KeyEvent)} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}. + */ + public void keyTyped(KeyEvent e) ; } diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index e6b3d8a24..23549533e 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -38,47 +38,47 @@ package com.jogamp.newt.event; public class MouseEvent extends InputEvent { /** ID for button 1, value 1 */ - public static final int BUTTON1 = 1; + public static final short BUTTON1 = 1; /** ID for button 2, value 2 */ - public static final int BUTTON2 = 2; + public static final short BUTTON2 = 2; /** ID for button 3, value 3 */ - public static final int BUTTON3 = 3; + public static final short BUTTON3 = 3; /** ID for button 4, value 4 */ - public static final int BUTTON4 = 4; + public static final short BUTTON4 = 4; /** ID for button 5, value 5 */ - public static final int BUTTON5 = 5; + public static final short BUTTON5 = 5; /** ID for button 6, value 6 */ - public static final int BUTTON6 = 6; + public static final short BUTTON6 = 6; /** ID for button 6, value 7 */ - public static final int BUTTON7 = 7; + public static final short BUTTON7 = 7; /** ID for button 6, value 8 */ - public static final int BUTTON8 = 8; + public static final short BUTTON8 = 8; /** ID for button 6, value 9 */ - public static final int BUTTON9 = 9; + public static final short BUTTON9 = 9; /** Maximum number of buttons, value 16 */ - public static final int BUTTON_NUMBER = 16; + public static final short BUTTON_NUMBER = 16; - public static final int getClickTimeout() { + public static final short getClickTimeout() { return 300; } - public MouseEvent(int eventType, Object source, long when, - int modifiers, int x, int y, int clickCount, int button, + public MouseEvent(short eventType, Object source, long when, + int modifiers, int x, int y, short clickCount, short button, float rotation) { super(eventType, source, when, modifiers); this.x = new int[]{x}; this.y = new int[]{y}; this.pressure = new float[]{0}; - this.pointerids = new int[]{-1}; + this.pointerids = new short[]{-1}; this.clickCount=clickCount; this.button=button; this.wheelRotation = rotation; } - public MouseEvent(int eventType, Object source, long when, - int modifiers, int[] x, int[] y, float[] pressure, int[] pointerids, int clickCount, int button, + public MouseEvent(short eventType, Object source, long when, + int modifiers, int[] x, int[] y, float[] pressure, short[] pointerids, short clickCount, short button, float rotation) { super(eventType, source, when, modifiers); @@ -107,17 +107,17 @@ public class MouseEvent extends InputEvent * @return the pointer id for the data at index. * return -1 if index not available. */ - public int getPointerId(int index) { + public short getPointerId(int index) { if(index >= pointerids.length) return -1; return pointerids[index]; } - public int getButton() { + public short getButton() { return button; } - public int getClickCount() { + public short getClickCount() { return clickCount; } public int getX() { @@ -208,7 +208,7 @@ public class MouseEvent extends InputEvent return super.toString(sb).append("]"); } - public static String getEventTypeString(int type) { + public static String getEventTypeString(short type) { switch(type) { case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED"; case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED"; @@ -221,17 +221,18 @@ public class MouseEvent extends InputEvent default: return "unknown (" + type + ")"; } } - private final int x[], y[], clickCount, button; + private final int x[], y[];; + private final short clickCount, button; private final float wheelRotation; private final float pressure[]; - private final int pointerids[]; + private final short pointerids[]; - public static final int EVENT_MOUSE_CLICKED = 200; - public static final int EVENT_MOUSE_ENTERED = 201; - public static final int EVENT_MOUSE_EXITED = 202; - public static final int EVENT_MOUSE_PRESSED = 203; - public static final int EVENT_MOUSE_RELEASED = 204; - public static final int EVENT_MOUSE_MOVED = 205; - public static final int EVENT_MOUSE_DRAGGED = 206; - public static final int EVENT_MOUSE_WHEEL_MOVED = 207; + public static final short EVENT_MOUSE_CLICKED = 200; + public static final short EVENT_MOUSE_ENTERED = 201; + public static final short EVENT_MOUSE_EXITED = 202; + public static final short EVENT_MOUSE_PRESSED = 203; + public static final short EVENT_MOUSE_RELEASED = 204; + public static final short EVENT_MOUSE_MOVED = 205; + public static final short EVENT_MOUSE_DRAGGED = 206; + public static final short EVENT_MOUSE_WHEEL_MOVED = 207; } diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index 9d8d92ff6..b8de6eb18 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -48,81 +48,21 @@ package com.jogamp.newt.event; */ @SuppressWarnings("serial") public class NEWTEvent extends java.util.EventObject { - private final boolean isSystemEvent; - private final int eventType; + private final short eventType; private final long when; private Object attachment; static final boolean DEBUG = false; - // 0: NEWTEvent.java - // 1: InputEvent.java - // 2: KeyEvent.java - // 3: com.jogamp.newt.Window - // 3: com.jogamp.newt.event.awt.AWTNewtEventFactory - // 2: MouseEvent.java - // 3: com.jogamp.newt.Window - // 3: com.jogamp.newt.event.awt.AWTNewtEventFactory - // 1: WindowEvent.java - // 2: com.jogamp.newt.Window - // 2: com.jogamp.newt.event.awt.AWTNewtEventFactory - // - // FIXME: verify the isSystemEvent evaluation - // - static final String WindowClazzName = "com.jogamp.newt.Window" ; - static final String AWTNewtEventFactoryClazzName = "com.jogamp.newt.event.awt.AWTNewtEventFactory" ; - - /** - static final boolean evaluateIsSystemEvent(NEWTEvent event, Throwable t) { - StackTraceElement[] stack = t.getStackTrace(); - if(stack.length==0 || null==stack[0]) { - return false; - } - if(DEBUG) { - for (int i = 0; i < stack.length && i<5; i++) { - System.err.println(i+": " + stack[i].getClassName()+ "." + stack[i].getMethodName()); - } - } - - String clazzName = null; - - if( event instanceof com.jogamp.newt.event.WindowEvent ) { - if ( stack.length > 2 ) { - clazzName = stack[2].getClassName(); - } - } else if( (event instanceof com.jogamp.newt.event.MouseEvent) || - (event instanceof com.jogamp.newt.event.KeyEvent) ) { - if ( stack.length > 3 ) { - clazzName = stack[3].getClassName(); - } - } - - boolean res = null!=clazzName && ( - clazzName.equals(WindowClazzName) || - clazzName.equals(AWTNewtEventFactoryClazzName) ) ; - if(DEBUG) { - System.err.println("system: "+res); - } - return res; - } */ - - protected NEWTEvent(int eventType, Object source, long when) { + protected NEWTEvent(short eventType, Object source, long when) { super(source); - // this.isSystemEvent = evaluateIsSystemEvent(this, new Throwable()); - this.isSystemEvent = false; // FIXME: Need a more efficient way to determine system events this.eventType = eventType; this.when = when; this.attachment=null; } - /** Indicates whether this event was produced by the system or - generated by user code. */ - public final boolean isSystemEvent() { - return isSystemEvent; - } - /** Returns the event type of this event. */ - public final int getEventType() { + public final short getEventType() { return eventType; } @@ -158,10 +98,10 @@ public class NEWTEvent extends java.util.EventObject { if(null == sb) { sb = new StringBuilder(); } - return sb.append("NEWTEvent[sys:").append(isSystemEvent()).append(", source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); + return sb.append("NEWTEvent[source:").append(getSource().getClass().getName()).append(", when:").append(getWhen()).append(" d ").append((System.currentTimeMillis()-getWhen())).append("ms]"); } - static String toHexString(int hex) { - return "0x" + Integer.toHexString(hex); + static String toHexString(short hex) { + return "0x" + Integer.toHexString( (int)hex & 0x0000FFFF ); } } diff --git a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java index 163b51439..24b3b380a 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowEvent.java @@ -41,19 +41,19 @@ package com.jogamp.newt.event; */ @SuppressWarnings("serial") public class WindowEvent extends NEWTEvent { - public static final int EVENT_WINDOW_RESIZED = 100; - public static final int EVENT_WINDOW_MOVED = 101; - public static final int EVENT_WINDOW_DESTROY_NOTIFY = 102; - public static final int EVENT_WINDOW_GAINED_FOCUS = 103; - public static final int EVENT_WINDOW_LOST_FOCUS = 104; - public static final int EVENT_WINDOW_REPAINT = 105; - public static final int EVENT_WINDOW_DESTROYED = 106; + public static final short EVENT_WINDOW_RESIZED = 100; + public static final short EVENT_WINDOW_MOVED = 101; + public static final short EVENT_WINDOW_DESTROY_NOTIFY = 102; + public static final short EVENT_WINDOW_GAINED_FOCUS = 103; + public static final short EVENT_WINDOW_LOST_FOCUS = 104; + public static final short EVENT_WINDOW_REPAINT = 105; + public static final short EVENT_WINDOW_DESTROYED = 106; - public WindowEvent(int eventType, Object source, long when) { + public WindowEvent(short eventType, Object source, long when) { super(eventType, source, when); } - public static String getEventTypeString(int type) { + public static String getEventTypeString(short type) { switch(type) { case EVENT_WINDOW_RESIZED: return "WINDOW_RESIZED"; case EVENT_WINDOW_MOVED: return "WINDOW_MOVED"; diff --git a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java index e3f0373ec..a0f6e2cb4 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowUpdateEvent.java @@ -34,7 +34,7 @@ import javax.media.nativewindow.util.Rectangle; public class WindowUpdateEvent extends WindowEvent { final Rectangle bounds; - public WindowUpdateEvent(int eventType, Object source, long when, Rectangle bounds) + public WindowUpdateEvent(short eventType, Object source, long when, Rectangle bounds) { super(eventType, source, when); this.bounds = bounds; diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java index 64071eed6..1edef347b 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTKeyAdapter.java @@ -72,14 +72,11 @@ public class AWTKeyAdapter extends AWTAdapter implements java.awt.event.KeyListe @Override public void keyReleased(java.awt.event.KeyEvent e) { com.jogamp.newt.event.KeyEvent keyReleaseEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED, e, newtWindow); - com.jogamp.newt.event.KeyEvent keyTypedEvt = AWTNewtEventFactory.createKeyEvent(com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED, e, newtWindow); if(null!=newtListener) { final com.jogamp.newt.event.KeyListener newtKeyListener = (com.jogamp.newt.event.KeyListener)newtListener; newtKeyListener.keyReleased(keyReleaseEvt); - newtKeyListener.keyTyped(keyTypedEvt); } else { enqueueEvent(false, keyReleaseEvt); - enqueueEvent(false, keyTypedEvt); } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index cb43fae32..73c0d2754 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -121,10 +121,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList childWindows = new ArrayList(); private ArrayList mouseListeners = new ArrayList(); - private int mouseButtonPressed = 0; // current pressed mouse button number - private int mouseButtonModMask = 0; // current pressed mouse button modifier mask + private short mouseButtonPressed = (short)0; // current pressed mouse button number + private int mouseButtonModMask = 0; // current pressed mouse button modifier mask private long lastMousePressed = 0; // last time when a mouse button was pressed - private int lastMouseClickCount = 0; // last mouse button click count + private short lastMouseClickCount = (short)0; // last mouse button click count private boolean mouseInWindow = false;// mouse entered window - is inside the window (may be synthetic) private Point lastMousePosition = new Point(); @@ -1976,17 +1976,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // MouseListener/Event Support // - public void sendMouseEvent(int eventType, int modifiers, - int x, int y, int button, float rotation) { + public void sendMouseEvent(short eventType, int modifiers, + int x, int y, short button, float rotation) { doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation); } - public void enqueueMouseEvent(boolean wait, int eventType, int modifiers, - int x, int y, int button, float rotation) { + public void enqueueMouseEvent(boolean wait, short eventType, int modifiers, + int x, int y, short button, float rotation) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation); } - protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, - int x, int y, int button, float rotation) { + protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, + int x, int y, short button, float rotation) { if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) { if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) { x = lastMousePosition.getX(); @@ -1996,9 +1996,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer x = Math.min(Math.max(x, 0), getWidth()-1); y = Math.min(Math.max(y, 0), getHeight()-1); mouseInWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - lastMousePressed = 0; // clear state - mouseButtonPressed = 0; // clear state - mouseButtonModMask = 0; // clear state + // clear states + lastMousePressed = 0; + lastMouseClickCount = (short)0; + mouseButtonPressed = 0; + mouseButtonModMask = 0; } if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { return; // .. invalid .. @@ -2013,10 +2015,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!mouseInWindow) { mouseInWindow = true; eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when, - modifiers, x, y, lastMouseClickCount, button, 0); - lastMousePressed = 0; // clear state - mouseButtonPressed = 0; // clear state - mouseButtonModMask = 0; // clear state + modifiers, x, y, (short)0, (short)0, (short)0); + // clear states + lastMousePressed = 0; + lastMouseClickCount = (short)0; + mouseButtonPressed = 0; + mouseButtonModMask = 0; } else if( lastMousePosition.getX() == x && lastMousePosition.getY()==y ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+lastMousePosition); @@ -2046,7 +2050,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( when - lastMousePressed < MouseEvent.getClickTimeout() ) { lastMouseClickCount++; } else { - lastMouseClickCount=1; + lastMouseClickCount=(short)1; } lastMousePressed = when; mouseButtonPressed = button; @@ -2060,7 +2064,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer eClicked = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, this, when, modifiers, x, y, lastMouseClickCount, button, 0); } else { - lastMouseClickCount = 0; + lastMouseClickCount = (short)0; lastMousePressed = 0; } mouseButtonPressed = 0; @@ -2068,15 +2072,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if( MouseEvent.EVENT_MOUSE_MOVED == eventType ) { if ( mouseButtonPressed > 0 ) { e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, - modifiers, x, y, 1, mouseButtonPressed, 0); + modifiers, x, y, (short)1, mouseButtonPressed, 0); } else { e = new MouseEvent(eventType, this, when, - modifiers, x, y, 0, button, 0); + modifiers, x, y, (short)0, button, (short)0); } } else if( MouseEvent.EVENT_MOUSE_WHEEL_MOVED == eventType ) { - e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, rotation); + e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotation); } else { - e = new MouseEvent(eventType, this, when, modifiers, x, y, 0, button, 0); + e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, 0); } if( null != eEntered ) { if(DEBUG_MOUSE_EVENT) { @@ -2203,23 +2207,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return 0 <= keyCode && keyCode < keyRepeatState.capacity(); } - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - doKeyEvent(false, false, eventType, modifiers, keyCode, keyChar); + public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + // Always add currently pressed mouse buttons to modifier mask + consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); } - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - doKeyEvent(true, wait, eventType, modifiers, keyCode, keyChar); + public void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + // Always add currently pressed mouse buttons to modifier mask + enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); } - protected void doKeyEvent(boolean enqueue, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - modifiers |= mouseButtonModMask; // Always add currently pressed mouse buttons to modifier mask - if( enqueue ) { - enqueueEvent(wait, new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); - } else { - consumeKeyEvent(new KeyEvent(eventType, this, System.currentTimeMillis(), modifiers, keyCode, keyChar) ); - } - } - public void addKeyListener(KeyListener l) { addKeyListener(-1, l); } @@ -2290,6 +2287,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return keyListeners.toArray(new KeyListener[keyListeners.size()]); } + @SuppressWarnings("deprecation") private final boolean propagateKeyEvent(KeyEvent e, KeyListener l) { switch(e.getEventType()) { case KeyEvent.EVENT_KEY_PRESSED: @@ -2307,21 +2305,49 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return InputEvent.consumedTag == e.getAttachment(); } + @SuppressWarnings("deprecation") protected void consumeKeyEvent(KeyEvent e) { - boolean consumed; + boolean consumedE = false, consumedTyped = false; + if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { + throw new InternalError("Deprecated KeyEvent.EVENT_KEY_TYPED is synthesized - don't send/enqueue it!"); + } + + // Synthesize deprecated event KeyEvent.EVENT_KEY_TYPED + final KeyEvent eTyped; + if( KeyEvent.EVENT_KEY_RELEASED == e.getEventType() && e.isPrintableKey() && !e.isAutoRepeat() ) { + eTyped = new KeyEvent(KeyEvent.EVENT_KEY_TYPED, e.getSource(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeySymbol(), e.getKeyChar()); + } else { + eTyped = null; + } if(null != keyboardFocusHandler) { - consumed = propagateKeyEvent(e, keyboardFocusHandler); + consumedE = propagateKeyEvent(e, keyboardFocusHandler); if(DEBUG_KEY_EVENT) { - System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumed); + System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumedE); } - } else { - consumed = false; - if(DEBUG_KEY_EVENT) { + if( null != eTyped ) { + consumedTyped = propagateKeyEvent(eTyped, keyboardFocusHandler); + if(DEBUG_KEY_EVENT) { + System.err.println("consumeKeyEvent: "+eTyped+", keyboardFocusHandler consumed: "+consumedTyped); + } + } + } + if(DEBUG_KEY_EVENT) { + if( !consumedE ) { System.err.println("consumeKeyEvent: "+e); } } - for(int i = 0; !consumed && i < keyListeners.size(); i++ ) { - consumed = propagateKeyEvent(e, keyListeners.get(i)); + for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) { + consumedE = propagateKeyEvent(e, keyListeners.get(i)); + } + if( null != eTyped ) { + if(DEBUG_KEY_EVENT) { + if( !consumedTyped ) { + System.err.println("consumeKeyEvent: "+eTyped); + } + } + for(int i = 0; !consumedTyped && i < keyListeners.size(); i++ ) { + consumedTyped = propagateKeyEvent(eTyped, keyListeners.get(i)); + } } } @@ -2329,11 +2355,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // WindowListener/Event Support // public void sendWindowEvent(int eventType) { - consumeWindowEvent( new WindowEvent(eventType, this, System.currentTimeMillis()) ); + consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME } public void enqueueWindowEvent(boolean wait, int eventType) { - enqueueEvent( wait, new WindowEvent(eventType, this, System.currentTimeMillis()) ); + enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME } public void addWindowListener(WindowListener l) { diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index e11d79ddc..b90c2106e 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -28,8 +28,6 @@ package jogamp.newt.awt.event; -import com.jogamp.common.util.IntIntHashMap; - /** * *
    AWT Event Modifier Mapping
    @@ -76,47 +74,10 @@ import com.jogamp.common.util.IntIntHashMap; */ public class AWTNewtEventFactory { - protected static final IntIntHashMap eventTypeAWT2NEWT; - /** zero-based AWT button mask array filled by {@link #getAWTButtonDownMask(int)}, allowing fast lookup. */ private static int awtButtonDownMasks[] ; static { - IntIntHashMap map = new IntIntHashMap(); - map.setKeyNotFoundValue(0xFFFFFFFF); - // n/a map.put(java.awt.event.WindowEvent.WINDOW_OPENED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED); - map.put(java.awt.event.WindowEvent.WINDOW_CLOSING, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); - map.put(java.awt.event.WindowEvent.WINDOW_CLOSED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROYED); - // n/a map.put(java.awt.event.WindowEvent.WINDOW_ICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_ICONIFIED); - // n/a map.put(java.awt.event.WindowEvent.WINDOW_DEICONIFIED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DEICONIFIED); - map.put(java.awt.event.WindowEvent.WINDOW_ACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); - map.put(java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); - map.put(java.awt.event.FocusEvent.FOCUS_GAINED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS); - map.put(java.awt.event.WindowEvent.WINDOW_DEACTIVATED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS); - map.put(java.awt.event.WindowEvent.WINDOW_LOST_FOCUS, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS); - map.put(java.awt.event.FocusEvent.FOCUS_LOST, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS); - // n/a map.put(java.awt.event.WindowEvent.WINDOW_STATE_CHANGED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_STATE_CHANGED); - - map.put(java.awt.event.ComponentEvent.COMPONENT_MOVED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_MOVED); - map.put(java.awt.event.ComponentEvent.COMPONENT_RESIZED, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_RESIZED); - // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_SHOWN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_SHOWN); - // n/a map.put(java.awt.event.ComponentEvent.COMPONENT_HIDDEN, com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_HIDDEN); - - map.put(java.awt.event.MouseEvent.MOUSE_CLICKED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED); - map.put(java.awt.event.MouseEvent.MOUSE_PRESSED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); - map.put(java.awt.event.MouseEvent.MOUSE_RELEASED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - map.put(java.awt.event.MouseEvent.MOUSE_MOVED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED); - map.put(java.awt.event.MouseEvent.MOUSE_ENTERED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED); - map.put(java.awt.event.MouseEvent.MOUSE_EXITED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED); - map.put(java.awt.event.MouseEvent.MOUSE_DRAGGED, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED); - map.put(java.awt.event.MouseEvent.MOUSE_WHEEL, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED); - - map.put(java.awt.event.KeyEvent.KEY_PRESSED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED); - map.put(java.awt.event.KeyEvent.KEY_RELEASED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED); - map.put(java.awt.event.KeyEvent.KEY_TYPED, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED); - - eventTypeAWT2NEWT = map; - // There is an assumption in awtModifiers2Newt(int,int,boolean) // that the awtButtonMasks and newtButtonMasks are peers, i.e. // a given index refers to the same button in each array. @@ -135,6 +96,41 @@ public class AWTNewtEventFactory { } } + public static final short eventTypeAWT2NEWT(int awtType) { + switch( awtType ) { + // n/a case java.awt.event.WindowEvent.WINDOW_OPENED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_OPENED; + case java.awt.event.WindowEvent.WINDOW_CLOSING: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY; + case java.awt.event.WindowEvent.WINDOW_CLOSED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DESTROYED; + // n/a case java.awt.event.WindowEvent.WINDOW_ICONIFIED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_ICONIFIED; + // n/a case java.awt.event.WindowEvent.WINDOW_DEICONIFIED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_DEICONIFIED; + case java.awt.event.WindowEvent.WINDOW_ACTIVATED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; + case java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; + case java.awt.event.FocusEvent.FOCUS_GAINED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; + case java.awt.event.WindowEvent.WINDOW_DEACTIVATED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS; + case java.awt.event.WindowEvent.WINDOW_LOST_FOCUS: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS; + case java.awt.event.FocusEvent.FOCUS_LOST: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_LOST_FOCUS; + // n/a case java.awt.event.WindowEvent.WINDOW_STATE_CHANGED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_STATE_CHANGED; + + case java.awt.event.ComponentEvent.COMPONENT_MOVED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_MOVED; + case java.awt.event.ComponentEvent.COMPONENT_RESIZED: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_RESIZED; + // n/a case java.awt.event.ComponentEvent.COMPONENT_SHOWN: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_SHOWN; + // n/a case java.awt.event.ComponentEvent.COMPONENT_HIDDEN: return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_HIDDEN; + + case java.awt.event.MouseEvent.MOUSE_CLICKED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED; + case java.awt.event.MouseEvent.MOUSE_PRESSED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; + case java.awt.event.MouseEvent.MOUSE_RELEASED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + case java.awt.event.MouseEvent.MOUSE_MOVED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; + case java.awt.event.MouseEvent.MOUSE_ENTERED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED; + case java.awt.event.MouseEvent.MOUSE_EXITED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED; + case java.awt.event.MouseEvent.MOUSE_DRAGGED: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; + case java.awt.event.MouseEvent.MOUSE_WHEEL: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; + + case java.awt.event.KeyEvent.KEY_PRESSED: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; + case java.awt.event.KeyEvent.KEY_RELEASED: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; + } + return (short)0; + } + private static int getAWTButtonDownMaskImpl(int button) { /** * java.awt.event.InputEvent.getMaskForButton(button); @@ -227,48 +223,48 @@ public class AWTNewtEventFactory { return newtMods; } - public static final int awtButton2Newt(int awtButton) { + public static final short awtButton2Newt(int awtButton) { if( 0 < awtButton && awtButton <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { - return awtButton; + return (short)awtButton; } else { - return 0; + return (short)0; } } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.WindowEvent event, com.jogamp.newt.Window newtSource) { - final int newtType = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != newtType) { + final short newtType = eventTypeAWT2NEWT(event.getID()); + if( (short)0 != newtType ) { return new com.jogamp.newt.event.WindowEvent(newtType, ((null==newtSource)?(Object)event.getComponent():(Object)newtSource), System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.ComponentEvent event, com.jogamp.newt.Window newtSource) { - final int newtType = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != newtType) { + final short newtType = eventTypeAWT2NEWT(event.getID()); + if( (short)0 != newtType ) { return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.WindowEvent createWindowEvent(java.awt.event.FocusEvent event, com.jogamp.newt.Window newtSource) { - final int newtType = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != newtType) { + final short newtType = eventTypeAWT2NEWT(event.getID()); + if( (short)0 != newtType ) { return new com.jogamp.newt.event.WindowEvent(newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, System.currentTimeMillis()); } return null; // no mapping .. } public static final com.jogamp.newt.event.MouseEvent createMouseEvent(java.awt.event.MouseEvent event, com.jogamp.newt.Window newtSource) { - final int newtType = eventTypeAWT2NEWT.get(event.getID()); - if(0xFFFFFFFF != newtType) { + final short newtType = eventTypeAWT2NEWT(event.getID()); + if( (short)0 != newtType ) { float rotation = 0; if (event instanceof java.awt.event.MouseWheelEvent) { // AWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. rotation = -1f * ((java.awt.event.MouseWheelEvent)event).getWheelRotation(); } - final int newtButton = awtButton2Newt(event.getButton()); + final short newtButton = awtButton2Newt(event.getButton()); int mods = awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()); mods |= com.jogamp.newt.event.InputEvent.getButtonMask(newtButton); // always include NEWT BUTTON_MASK if(null!=newtSource) { @@ -281,25 +277,25 @@ public class AWTNewtEventFactory { } return new com.jogamp.newt.event.MouseEvent( newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), - mods, event.getX(), event.getY(), event.getClickCount(), + mods, event.getX(), event.getY(), (short)event.getClickCount(), newtButton, rotation); } return null; // no mapping .. } public static final com.jogamp.newt.event.KeyEvent createKeyEvent(java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { - return createKeyEvent(eventTypeAWT2NEWT.get(event.getID()), event, newtSource); + return createKeyEvent(eventTypeAWT2NEWT(event.getID()), event, newtSource); } - public static final com.jogamp.newt.event.KeyEvent createKeyEvent(int newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { - if(0xFFFFFFFF != newtType) { + public static final com.jogamp.newt.event.KeyEvent createKeyEvent(short newtType, java.awt.event.KeyEvent event, com.jogamp.newt.Window newtSource) { + if( (short)0 != newtType ) { + final short keyCode = (short)event.getKeyCode(); return new com.jogamp.newt.event.KeyEvent( newtType, (null==newtSource)?(Object)event.getComponent():(Object)newtSource, event.getWhen(), awtModifiers2Newt(event.getModifiers(), event.getModifiersEx()), - event.getKeyCode(), event.getKeyChar()); + keyCode, keyCode, event.getKeyChar()); } return null; // no mapping .. } } - diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index dc1e8aeef..22e2cbc51 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -42,78 +42,62 @@ public class AndroidNewtEventFactory { /** API Level 12: {@link android.view.MotionEvent#ACTION_SCROLL} = {@value} */ private static final int ACTION_SCROLL = 8; - private static final int aMotionEventType2Newt(int aType) { - final int nType; + private static final short aMotionEventType2Newt(int aType) { switch( aType ) { case android.view.MotionEvent.ACTION_DOWN: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; case android.view.MotionEvent.ACTION_UP: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; case android.view.MotionEvent.ACTION_MOVE: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; case android.view.MotionEvent.ACTION_CANCEL: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; case android.view.MotionEvent.ACTION_OUTSIDE: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; - break; - // + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; case android.view.MotionEvent.ACTION_POINTER_DOWN: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; case android.view.MotionEvent.ACTION_POINTER_UP: - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; // case ACTION_HOVER_MOVE case ACTION_SCROLL: // API Level 12 ! - nType = com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - break; + return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; // case ACTION_HOVER_ENTER // case ACTION_HOVER_EXIT - default: - nType = 0xFFFFFFFF; } - return nType; + return (short)0; } - private static final int aAccessibilityEventType2Newt(int aType) { - final int nType; + private static final short aAccessibilityEventType2Newt(int aType) { switch( aType ) { case android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED: - nType = com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; break; - default: - nType = 0xFFFFFFFF; + return com.jogamp.newt.event.WindowEvent.EVENT_WINDOW_GAINED_FOCUS; } - return nType; + return (short)0; } - private static final int aKeyEventType2NewtEventType(int androidKeyAction) { + private static final short aKeyEventType2NewtEventType(int androidKeyAction) { switch(androidKeyAction) { case android.view.KeyEvent.ACTION_DOWN: case android.view.KeyEvent.ACTION_MULTIPLE: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; case android.view.KeyEvent.ACTION_UP: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; - default: - return 0; } + return (short)0; } - private static final int aKeyCode2NewtKeyCode(int androidKeyCode) { + private static final short aKeyCode2NewtKeyCode(int androidKeyCode) { if(android.view.KeyEvent.KEYCODE_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_9) { - return com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) ; + return (short) ( com.jogamp.newt.event.KeyEvent.VK_0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_0 ) ); } if(android.view.KeyEvent.KEYCODE_A <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_Z) { - return com.jogamp.newt.event.KeyEvent.VK_A + ( androidKeyCode - android.view.KeyEvent.KEYCODE_A ) ; + return (short) ( com.jogamp.newt.event.KeyEvent.VK_A + ( androidKeyCode - android.view.KeyEvent.KEYCODE_A ) ); } if(android.view.KeyEvent.KEYCODE_F1 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_F12) { - return com.jogamp.newt.event.KeyEvent.VK_F1 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_F1 ) ; + return (short) ( com.jogamp.newt.event.KeyEvent.VK_F1 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_F1 ) ); } if(android.view.KeyEvent.KEYCODE_NUMPAD_0 <= androidKeyCode && androidKeyCode <= android.view.KeyEvent.KEYCODE_NUMPAD_9) { - return com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_NUMPAD_0 ) ; + return (short) ( com.jogamp.newt.event.KeyEvent.VK_NUMPAD0 + ( androidKeyCode - android.view.KeyEvent.KEYCODE_NUMPAD_0 ) ); } switch(androidKeyCode) { case android.view.KeyEvent.KEYCODE_COMMA: return com.jogamp.newt.event.KeyEvent.VK_COMMA; @@ -144,7 +128,7 @@ public class AndroidNewtEventFactory { case android.view.KeyEvent.KEYCODE_CTRL_LEFT: return com.jogamp.newt.event.KeyEvent.VK_CONTROL; case android.view.KeyEvent.KEYCODE_CTRL_RIGHT: return com.jogamp.newt.event.KeyEvent.VK_CONTROL; // ?? } - return 0; + return (short)0; } private static final int aKeyModifiers2Newt(int androidMods) { @@ -170,38 +154,29 @@ public class AndroidNewtEventFactory { public com.jogamp.newt.event.WindowEvent createWindowEvent(android.view.accessibility.AccessibilityEvent event, com.jogamp.newt.Window newtSource) { final int aType = event.getEventType(); - final int nType = aAccessibilityEventType2Newt(aType); + final short nType = aAccessibilityEventType2Newt(aType); - if(0xFFFFFFFF != nType) { + if( (short)0 != nType) { return new com.jogamp.newt.event.WindowEvent(nType, ((null==newtSource)?null:(Object)newtSource), event.getEventTime()); } return null; // no mapping .. } - public com.jogamp.newt.event.KeyEvent[] createKeyEvents(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) { - final int type = aKeyEventType2NewtEventType(event.getAction()); + public com.jogamp.newt.event.KeyEvent createKeyEvent(int keyCode, android.view.KeyEvent event, com.jogamp.newt.Window newtSource) { + final short type = aKeyEventType2NewtEventType(event.getAction()); if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createKeyEvent: type 0x"+Integer.toHexString(type)+", keyCode 0x"+Integer.toHexString(keyCode)+", "+event); } - if(0xFFFFFFFF != type) { - final int newtKeyCode = aKeyCode2NewtKeyCode(keyCode); - if(0 != newtKeyCode) { + if( (short)0 != type) { + final short newtKeyCode = aKeyCode2NewtKeyCode(keyCode); + if( (short)0 != newtKeyCode ) { final Object src = (null==newtSource)?null:(Object)newtSource; final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); final int newtMods = aKeyModifiers2Newt(event.getMetaState()); - final com.jogamp.newt.event.KeyEvent ke1 = new com.jogamp.newt.event.KeyEvent( - type, src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel()); - - if( com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED == type ) { - return new com.jogamp.newt.event.KeyEvent[] { ke1, - new com.jogamp.newt.event.KeyEvent( - com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED, - src, unixTime, newtMods, newtKeyCode, event.getDisplayLabel()) }; - } else { - return new com.jogamp.newt.event.KeyEvent[] { ke1 }; - } + return new com.jogamp.newt.event.KeyEvent( + type, src, unixTime, newtMods, newtKeyCode, newtKeyCode, event.getDisplayLabel()); } } return null; @@ -218,7 +193,8 @@ public class AndroidNewtEventFactory { // // Prefilter Android Event (Gesture, ..) and determine final type // - final int aType, nType; + final int aType; + final short nType; float[] rotationXY = null; int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL { @@ -265,8 +241,8 @@ public class AndroidNewtEventFactory { } } - if(0xFFFFFFFF != nType) { - final int clickCount = 1; + if( (short)0 != nType ) { + final short clickCount = 1; int modifiers = 0; if( null == rotationXY && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12 @@ -299,7 +275,7 @@ public class AndroidNewtEventFactory { // final int pCount; final int pIndex; - final int button; + final short button; switch( aType ) { case android.view.MotionEvent.ACTION_POINTER_DOWN: case android.view.MotionEvent.ACTION_POINTER_UP: { @@ -307,7 +283,7 @@ public class AndroidNewtEventFactory { pCount = 1; final int b = event.getPointerId(pIndex) + 1; // FIXME: Assumption that Pointer-ID starts w/ 0 ! if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { - button = b; + button = (short)b; } else { button = com.jogamp.newt.event.MouseEvent.BUTTON1; } @@ -326,7 +302,7 @@ public class AndroidNewtEventFactory { final int[] x = new int[pCount]; final int[] y = new int[pCount]; final float[] pressure = new float[pCount]; - final int[] pointerIds = new int[pCount]; + final short[] pointerIds = new short[pCount]; { if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: collect ptr-data ["+pIndex+".."+(pIndex+pCount-1)+", "+pCount+"], aType "+aType+", button "+button+", gestureScrollPointerDown "+gestureScrollPointerDown); @@ -337,7 +313,7 @@ public class AndroidNewtEventFactory { x[j] = (int)event.getX(i); y[j] = (int)event.getY(i); pressure[j] = event.getPressure(i); - pointerIds[j] = event.getPointerId(i); + pointerIds[j] = (short)event.getPointerId(i); if(Window.DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: ptr-data["+i+" -> "+j+"] "+x[j]+"/"+y[j]+", pressure "+pressure[j]+", id "+pointerIds[j]); } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java index ee0c8f8b1..2d972f752 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -38,11 +38,9 @@ public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTo @Override public boolean onKey(View v, int keyCode, android.view.KeyEvent event) { - final com.jogamp.newt.event.KeyEvent[] newtEvents = factory.createKeyEvents(keyCode, event, newtWindow); - if(null != newtEvents) { - for(int i=0; i 0x"+Integer.toHexString(keyCode)+", mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + final short keyCode = MacKeyUtil.validateKeyCode(_keyCode, keyChar); + /* { + final boolean isModifierKeyCode = KeyEvent.isModifierKey(keyCode); + System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", key 0x"+Integer.toHexString(_keyCode)+" -> 0x"+Integer.toHexString(keyCode)+", mods "+toHexString(modifiers)+ + ", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", isModifierKeyCode "+isModifierKeyCode); + } */ // 1:1 Order: OSX and NEWT delivery order is PRESSED, RELEASED and TYPED // Auto-Repeat: OSX delivers only PRESSED, inject auto-repeat RELEASE and TYPED keys _before_ PRESSED @@ -346,25 +347,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // key was already pressed keyRepeatState.put(keyCode, true); // prev == false -> AR in modifiers |= InputEvent.AUTOREPEAT_MASK; - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); // RELEASED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); // TYPED + super.enqueueKeyEvent(wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyCode, keyChar); // RELEASED } } break; - case KeyEvent.EVENT_KEY_TYPED: - break; } - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - } - - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); - } - - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar); + super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyCode, keyChar); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 650958f25..475687eb4 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -46,7 +46,6 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; -import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseAdapter; @@ -261,87 +260,55 @@ public class WindowDriver extends WindowImpl { // nop - using event driven insetsChange(..) } - private final void emitKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - if( send ) { - super.sendKeyEvent(eventType, modifiers, keyCode, keyChar); - } else { - super.enqueueKeyEvent(wait, eventType, modifiers, keyCode, keyChar); - } + private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, int modifiers, short keyCode, short keySym, char keyChar) { + if( isKeyCodeTracked(keyCode) && keyPressedState.put(keyCode, true) ) { + final boolean preKeyRepeatState = keyRepeatState.put(keyCode, true); + if( !isModifierKey ) { + // AR: Key was already pressed: Either [enter | within] AR mode + modifiers |= InputEvent.AUTOREPEAT_MASK; + if( preKeyRepeatState ) { + // AR: Within AR mode + super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); + } // else { AR: Enter AR mode - skip already send PRESSED ; or ALT } + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); + } + return true; + } + return false; } - /** FIXME: We have to store the keyChar for typed events, since keyChar from pressed/released may be wrong (Uppercase: SHIFT-1, etc ..). */ - private IntIntHashMap typedKeyCode2KeyChar = new IntIntHashMap(KeyEvent.VK_CONTEXT_MENU+1); - - private final void handleKeyEvent(boolean send, boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - final boolean isPrintableKey = KeyEvent.isPrintableKey(keyCode); - final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); - // System.err.println("*** handleKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+isPrintableKey+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); + @Override + public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + final boolean isModifierKey = KeyEvent.isModifierKey(keySym); + // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+ + // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isKeyInAutoRepeat(keyCode)+", printableKey "+KeyEvent.isPrintableKey(keyCode)+" [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); // Reorder: WINDOWS delivery order is PRESSED (t0), TYPED (t0) and RELEASED (t1) -> NEWT order: PRESSED (t0), RELEASED (t1) and TYPED (t1) // Auto-Repeat: WINDOWS delivers only PRESSED (t0) and TYPED (t0). switch(eventType) { case KeyEvent.EVENT_KEY_RELEASED: - final int keyCharTyped = typedKeyCode2KeyChar.put(keyCode, 0); - if( 0 != keyCharTyped ) { - keyChar = (char)keyCharTyped; - } if( isKeyCodeTracked(keyCode) ) { if( keyRepeatState.put(keyCode, false) && !isModifierKey ) { // AR out - send out missing PRESSED - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keyChar); + super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers | InputEvent.AUTOREPEAT_MASK, keyCode, keySym, keyChar); } keyPressedState.put(keyCode, false); } - emitKeyEvent(send, wait, eventType, modifiers, keyCode, keyChar); - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); break; case KeyEvent.EVENT_KEY_PRESSED: - // TYPED is delivered right after PRESSED for printable keys and contains the key-char information, - // hence we only deliver non printable keys (action and modifier keys) here. - // Modifier keys shall not AR. - if( !isPrintableKey ) { - if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) { - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); - } - } - break; - case KeyEvent.EVENT_KEY_TYPED: - if( isPrintableKey ) { - typedKeyCode2KeyChar.put(keyCode, keyChar); - if( !handlePressTypedAutoRepeat(isModifierKey, send, wait, modifiers, keyCode, keyChar) ) { - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); - } + if( !handlePressTypedAutoRepeat(isModifierKey, modifiers, keyCode, keySym, keyChar) ) { + super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); } break; + // case KeyEvent.EVENT_KEY_TYPED: + // break; } } - private final boolean handlePressTypedAutoRepeat(boolean isModifierKey, boolean send, boolean wait, int modifiers, int keyCode, char keyChar) { - if( isKeyCodeTracked(keyCode) && keyPressedState.put(keyCode, true) ) { - final boolean preKeyRepeatState = keyRepeatState.put(keyCode, true); - if( !isModifierKey ) { - // AR: Key was already pressed: Either [enter | within] AR mode - modifiers |= InputEvent.AUTOREPEAT_MASK; - if( preKeyRepeatState ) { - // AR: Within AR mode - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keyChar); - } // else { AR: Enter AR mode - skip already send PRESSED ; or ALT } - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keyChar); - emitKeyEvent(send, wait, KeyEvent.EVENT_KEY_TYPED, modifiers, keyCode, keyChar); - } - return true; - } - return false; - } - - @Override - public void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar) { - handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); - } - @Override - public void enqueueKeyEvent(boolean wait, int eventType, int modifiers, int keyCode, char keyChar) { - handleKeyEvent(false, wait, eventType, modifiers, keyCode, keyChar); + public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index c55fddd07..8d33d4d73 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -48,6 +48,7 @@ import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; import com.jogamp.newt.event.InputEvent; +import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseEvent; public class WindowDriver extends WindowImpl { @@ -227,8 +228,8 @@ public class WindowDriver extends WindowImpl { } @Override - protected void doMouseEvent(boolean enqueue, boolean wait, int eventType, int modifiers, - int x, int y, int button, float rotation) { + protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, + int x, int y, short button, float rotation) { switch(eventType) { case MouseEvent.EVENT_MOUSE_PRESSED: switch(button) { @@ -270,6 +271,34 @@ public class WindowDriver extends WindowImpl { super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotation); } + @Override + public final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); + final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); + final boolean isAutoRepeat = 0 != ( KeyEvent.AUTOREPEAT_MASK & modifiers ); + // System.err.println("*** sendKeyEvent: event "+KeyEvent.getEventTypeString(eventType)+", keyCode "+toHexString(keyCode)+", keyChar <"+keyChar+">, mods "+toHexString(modifiers)+ + // ", isKeyCodeTracked "+isKeyCodeTracked(keyCode)+", was: pressed "+isKeyPressed(keyCode)+", repeat "+isAutoRepeat+", [modifierKey "+isModifierKey+"] - "+System.currentTimeMillis()); + + if( !isAutoRepeat || !isModifierKey ) { // ! ( isModifierKey && isAutoRepeat ) + switch(eventType) { + case KeyEvent.EVENT_KEY_PRESSED: + super.sendKeyEvent(KeyEvent.EVENT_KEY_PRESSED, modifiers, keyCode, keySym, keyChar); + break; + + case KeyEvent.EVENT_KEY_RELEASED: + super.sendKeyEvent(KeyEvent.EVENT_KEY_RELEASED, modifiers, keyCode, keySym, keyChar); + break; + + // case KeyEvent.EVENT_KEY_TYPED: + // break; + } + } + } + + @Override + public final void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { + throw new InternalError("XXX: Adapt Java Code to Native Code Changes"); + } //---------------------------------------------------------------------- // Internals only diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 0fc487e91..1ebb714fa 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -32,7 +32,6 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; -import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.InputEvent; /** @@ -43,26 +42,22 @@ import com.jogamp.newt.event.InputEvent; */ public class SWTNewtEventFactory { - protected static final IntIntHashMap eventTypeSWT2NEWT; + public static final short eventTypeSWT2NEWT(int swtType) { + switch( swtType ) { + // case SWT.MouseXXX: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED; + case SWT.MouseDown: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; + case SWT.MouseUp: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; + case SWT.MouseMove: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; + case SWT.MouseEnter: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED; + case SWT.MouseExit: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED; + // case SWT.MouseXXX: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; + case SWT.MouseVerticalWheel: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; - static { - IntIntHashMap map = new IntIntHashMap(); - map.setKeyNotFoundValue(0xFFFFFFFF); - - // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED); - map.put(SWT.MouseDown, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED); - map.put(SWT.MouseUp, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED); - map.put(SWT.MouseMove, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED); - map.put(SWT.MouseEnter, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_ENTERED); - map.put(SWT.MouseExit, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_EXITED); - // map.put(SWT.MouseXXX, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED); - map.put(SWT.MouseVerticalWheel, com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED); - - map.put(SWT.KeyDown, com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED); - map.put(SWT.KeyUp, com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED); - // map.put(SWT.KeyXXX, com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED); - - eventTypeSWT2NEWT = map; + case SWT.KeyDown: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_PRESSED; + case SWT.KeyUp: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_RELEASED; + // case SWT.KeyXXX: return com.jogamp.newt.event.KeyEvent.EVENT_KEY_TYPED; + } + return (short)0; } public static final int swtModifiers2Newt(int awtMods, boolean mouseHint) { @@ -93,8 +88,8 @@ public class SWTNewtEventFactory { default: return null; } - int type = eventTypeSWT2NEWT.get(event.type); - if(0xFFFFFFFF != type) { + final short type = eventTypeSWT2NEWT(event.type); + if( (short)0 != type ) { float rotation = 0; if (SWT.MouseVerticalWheel == event.type) { // SWT/NEWT rotation is reversed - AWT +1 is down, NEWT +1 is up. @@ -116,7 +111,7 @@ public class SWTNewtEventFactory { return new com.jogamp.newt.event.MouseEvent( type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), - mods, event.x, event.y, event.count, event.button, rotation); + mods, event.x, event.y, (short)event.count, (short)event.button, rotation); } return null; // no mapping .. } @@ -129,12 +124,12 @@ public class SWTNewtEventFactory { default: return null; } - int type = eventTypeSWT2NEWT.get(event.type); - if(0xFFFFFFFF != type) { + final short type = eventTypeSWT2NEWT(event.type); + if( (short)0 != type ) { return new com.jogamp.newt.event.KeyEvent( type, (null==source)?(Object)event.data:source, (0xFFFFFFFFL & (long)event.time), swtModifiers2Newt(event.stateMask, false), - event.keyCode, event.character); + (short)event.keyCode, (short)event.keyCode, event.character); } return null; // no mapping .. } @@ -143,7 +138,7 @@ public class SWTNewtEventFactory { // // - int dragButtonDown = 0; + short dragButtonDown = 0; public SWTNewtEventFactory() { resetButtonsDown(); @@ -159,7 +154,7 @@ public class SWTNewtEventFactory { if(null != l) { switch(event.type) { case SWT.MouseDown: - dragButtonDown = event.button; + dragButtonDown = (short) event.button; l.mousePressed(res); break; case SWT.MouseUp: dragButtonDown = 0; @@ -214,7 +209,6 @@ public class SWTNewtEventFactory { break; case SWT.KeyUp: l.keyReleased(res); - l.keyTyped(res); break; } } diff --git a/src/newt/native/KDWindow.c b/src/newt/native/KDWindow.c index 3d059c336..cfec60dc1 100644 --- a/src/newt/native/KDWindow.c +++ b/src/newt/native/KDWindow.c @@ -161,14 +161,14 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_kd_DisplayDriver_DispatchMessages if(KD_INPUT_POINTER_SELECT==ptr->index) { DBG_PRINT( "event mouse click: src: %p, s:%d, (%d,%d)\n", userData, ptr->select, ptr->x, ptr->y); (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, - (ptr->select==0) ? (jint) EVENT_MOUSE_RELEASED : (jint) EVENT_MOUSE_PRESSED, + (ptr->select==0) ? (jshort) EVENT_MOUSE_RELEASED : (jshort) EVENT_MOUSE_PRESSED, (jint) 0, - (jint) ptr->x, (jint) ptr->y, 1, 0.0f); + (jint) ptr->x, (jint) ptr->y, (short)1, 0.0f); } else { DBG_PRINT( "event mouse: src: %d, s:%p, i:0x%X (%d,%d)\n", userData, ptr->select, ptr->index, ptr->x, ptr->y); - (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, + (*env)->CallVoidMethod(env, javaWindow, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, 0, - (jint) ptr->x, (jint) ptr->y, 0, 0.0f); + (jint) ptr->x, (jint) ptr->y, (jshort)0, 0.0f); } } break; @@ -193,8 +193,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_kd_WindowDriver_initIDs sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); - sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V"); + sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V"); if (windowCreatedID == NULL || sizeChangedID == NULL || visibleChangedID == NULL || diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index 29b646fbf..1e4f0c3ba 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -145,9 +145,9 @@ - (void) setMouseConfined:(BOOL)v; - (void) setMousePosition:(NSPoint)p; -- (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType; -- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType; -- (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType; +- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType; +- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType; +- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType; - (void) focusChanged: (BOOL) gained; - (BOOL) becomeFirstResponder; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index e69f74dfb..66d68d9d2 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -349,10 +349,10 @@ static jmethodID windowRepaintID = NULL; + (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz { - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); - sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZSIIISF)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V"); + enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISSC)V"); + sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V"); sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); @@ -626,15 +626,15 @@ static jint mods2JavaMods(NSUInteger mods) return javaMods; } -- (void) sendKeyEvent: (NSEvent*) event eventType: (jint) evType +- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType { - jint keyCode = (jint) [event keyCode]; + jshort keyCode = (jshort) [event keyCode]; NSString* chars = [event charactersIgnoringModifiers]; NSUInteger mods = [event modifierFlags]; [self sendKeyEvent: keyCode characters: chars modifiers: mods eventType: evType]; } -- (void) sendKeyEvent: (jint) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jint) evType +- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType { NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { @@ -668,10 +668,10 @@ static jint mods2JavaMods(NSUInteger mods) #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID, - evType, javaMods, keyCode, keyChar); + evType, javaMods, keyCode, keyCode, keyChar); #else (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, keyChar); + evType, javaMods, keyCode, keyCode, keyChar); #endif } } else { @@ -682,10 +682,10 @@ static jint mods2JavaMods(NSUInteger mods) #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, javaWindowObject, sendKeyEventID, - evType, javaMods, keyCode, keyChar); + evType, javaMods, keyCode, keyCode, keyChar); #else (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, keyChar); + evType, javaMods, keyCode, keyCode, keyChar); #endif } @@ -694,7 +694,7 @@ static jint mods2JavaMods(NSUInteger mods) } } -- (void) sendMouseEvent: (NSEvent*) event eventType: (jint) evType +- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType { NSView* nsview = [self contentView]; if( ! [nsview isMemberOfClass:[NewtView class]] ) { @@ -718,7 +718,7 @@ static jint mods2JavaMods(NSUInteger mods) // convert to 1-based button number (or use zero if no button is involved) // TODO: detect mouse button when mouse wheel scrolled - jint javaButtonNum = 0; + jshort javaButtonNum = 0; jfloat scrollDeltaY = 0.0f; switch ([event type]) { case NSScrollWheel: { @@ -850,13 +850,12 @@ static jint mods2JavaMods(NSUInteger mods) - (void) keyDown: (NSEvent*) theEvent { - [self sendKeyEvent: theEvent eventType: EVENT_KEY_PRESSED]; + [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_PRESSED]; } - (void) keyUp: (NSEvent*) theEvent { - [self sendKeyEvent: theEvent eventType: EVENT_KEY_RELEASED]; - [self sendKeyEvent: theEvent eventType: EVENT_KEY_TYPED]; + [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_RELEASED]; } #define kVK_Shift 0x38 @@ -868,11 +867,10 @@ static jint mods2JavaMods(NSUInteger mods) { if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { modsDown[keyIdx] = YES; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_PRESSED]; + [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_PRESSED]; } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { modsDown[keyIdx] = NO; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_RELEASED]; - [self sendKeyEvent: keyCode characters: NULL modifiers: mods|keyMask eventType: EVENT_KEY_TYPED]; + [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_RELEASED]; } } diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 24d513c68..05953cb86 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -132,9 +132,7 @@ static jmethodID focusChangedID = NULL; static jmethodID visibleChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; static jmethodID windowRepaintID = NULL; -static jmethodID enqueueMouseEventID = NULL; static jmethodID sendMouseEventID = NULL; -static jmethodID enqueueKeyEventID = NULL; static jmethodID sendKeyEventID = NULL; static jmethodID requestFocusID = NULL; @@ -146,345 +144,294 @@ typedef struct { } WindowUserData; typedef struct { - UINT javaKey; - UINT windowsKey; + USHORT javaKey; + USHORT windowsKey; + USHORT windowsScanCodeUS; } KeyMapEntry; // Static table, arranged more or less spatially. static KeyMapEntry keyMapTable[] = { // Modifier keys - {J_VK_CAPS_LOCK, VK_CAPITAL}, - {J_VK_SHIFT, VK_SHIFT}, - {J_VK_CONTROL, VK_CONTROL}, - {J_VK_ALT, VK_MENU}, - {J_VK_NUM_LOCK, VK_NUMLOCK}, + {J_VK_CAPS_LOCK, VK_CAPITAL, 0}, + {J_VK_SHIFT, VK_SHIFT, 0}, + {J_VK_SHIFT, VK_LSHIFT, 0}, + {J_VK_SHIFT, VK_RSHIFT, 0}, + {J_VK_CONTROL, VK_CONTROL, 0}, + {J_VK_CONTROL, VK_LCONTROL, 0}, + {J_VK_CONTROL, VK_RCONTROL, 0}, + {J_VK_ALT, VK_MENU, 0}, + {J_VK_ALT, VK_LMENU, 0}, + {J_VK_ALT, VK_RMENU, 0}, + {J_VK_NUM_LOCK, VK_NUMLOCK, 0}, // Miscellaneous Windows keys - {J_VK_WINDOWS, VK_LWIN}, - {J_VK_WINDOWS, VK_RWIN}, - {J_VK_CONTEXT_MENU, VK_APPS}, + {J_VK_WINDOWS, VK_LWIN, 0}, + {J_VK_WINDOWS, VK_RWIN, 0}, + {J_VK_CONTEXT_MENU, VK_APPS, 0}, // Alphabet - {J_VK_A, 'A'}, - {J_VK_B, 'B'}, - {J_VK_C, 'C'}, - {J_VK_D, 'D'}, - {J_VK_E, 'E'}, - {J_VK_F, 'F'}, - {J_VK_G, 'G'}, - {J_VK_H, 'H'}, - {J_VK_I, 'I'}, - {J_VK_J, 'J'}, - {J_VK_K, 'K'}, - {J_VK_L, 'L'}, - {J_VK_M, 'M'}, - {J_VK_N, 'N'}, - {J_VK_O, 'O'}, - {J_VK_P, 'P'}, - {J_VK_Q, 'Q'}, - {J_VK_R, 'R'}, - {J_VK_S, 'S'}, - {J_VK_T, 'T'}, - {J_VK_U, 'U'}, - {J_VK_V, 'V'}, - {J_VK_W, 'W'}, - {J_VK_X, 'X'}, - {J_VK_Y, 'Y'}, - {J_VK_Z, 'Z'}, - {J_VK_0, '0'}, - {J_VK_1, '1'}, - {J_VK_2, '2'}, - {J_VK_3, '3'}, - {J_VK_4, '4'}, - {J_VK_5, '5'}, - {J_VK_6, '6'}, - {J_VK_7, '7'}, - {J_VK_8, '8'}, - {J_VK_9, '9'}, - {J_VK_ENTER, VK_RETURN}, - {J_VK_SPACE, VK_SPACE}, - {J_VK_BACK_SPACE, VK_BACK}, - {J_VK_TAB, VK_TAB}, - {J_VK_ESCAPE, VK_ESCAPE}, - {J_VK_INSERT, VK_INSERT}, - {J_VK_DELETE, VK_DELETE}, - {J_VK_HOME, VK_HOME}, - {J_VK_END, VK_END}, - {J_VK_PAGE_UP, VK_PRIOR}, - {J_VK_PAGE_DOWN, VK_NEXT}, - {J_VK_CLEAR, VK_CLEAR}, // NumPad 5 + {J_VK_A, 'A', 0}, + {J_VK_B, 'B', 0}, + {J_VK_C, 'C', 0}, + {J_VK_D, 'D', 0}, + {J_VK_E, 'E', 0}, + {J_VK_F, 'F', 0}, + {J_VK_G, 'G', 0}, + {J_VK_H, 'H', 0}, + {J_VK_I, 'I', 0}, + {J_VK_J, 'J', 0}, + {J_VK_K, 'K', 0}, + {J_VK_L, 'L', 0}, + {J_VK_M, 'M', 0}, + {J_VK_N, 'N', 0}, + {J_VK_O, 'O', 0}, + {J_VK_P, 'P', 0}, + {J_VK_Q, 'Q', 0}, + {J_VK_R, 'R', 0}, + {J_VK_S, 'S', 0}, + {J_VK_T, 'T', 0}, + {J_VK_U, 'U', 0}, + {J_VK_V, 'V', 0}, + {J_VK_W, 'W', 0}, + {J_VK_X, 'X', 0}, + {J_VK_Y, 'Y', 0}, + {J_VK_Z, 'Z', 0}, + {J_VK_0, '0', 0}, + {J_VK_1, '1', 0}, + {J_VK_2, '2', 0}, + {J_VK_3, '3', 0}, + {J_VK_4, '4', 0}, + {J_VK_5, '5', 0}, + {J_VK_6, '6', 0}, + {J_VK_7, '7', 0}, + {J_VK_8, '8', 0}, + {J_VK_9, '9', 0}, + {J_VK_ENTER, VK_RETURN, 0}, + {J_VK_SPACE, VK_SPACE, 0}, + {J_VK_BACK_SPACE, VK_BACK, 0}, + {J_VK_TAB, VK_TAB, 0}, + {J_VK_ESCAPE, VK_ESCAPE, 0}, + {J_VK_INSERT, VK_INSERT, 0}, + {J_VK_DELETE, VK_DELETE, 0}, + {J_VK_HOME, VK_HOME, 0}, + {J_VK_END, VK_END, 0}, + {J_VK_PAGE_UP, VK_PRIOR, 0}, + {J_VK_PAGE_DOWN, VK_NEXT, 0}, + {J_VK_CLEAR, VK_CLEAR, 0}, // NumPad 5 // NumPad with NumLock off & extended arrows block (triangular) - {J_VK_LEFT, VK_LEFT}, - {J_VK_RIGHT, VK_RIGHT}, - {J_VK_UP, VK_UP}, - {J_VK_DOWN, VK_DOWN}, + {J_VK_LEFT, VK_LEFT, 0}, + {J_VK_RIGHT, VK_RIGHT, 0}, + {J_VK_UP, VK_UP, 0}, + {J_VK_DOWN, VK_DOWN, 0}, // NumPad with NumLock on: numbers - {J_VK_NUMPAD0, VK_NUMPAD0}, - {J_VK_NUMPAD1, VK_NUMPAD1}, - {J_VK_NUMPAD2, VK_NUMPAD2}, - {J_VK_NUMPAD3, VK_NUMPAD3}, - {J_VK_NUMPAD4, VK_NUMPAD4}, - {J_VK_NUMPAD5, VK_NUMPAD5}, - {J_VK_NUMPAD6, VK_NUMPAD6}, - {J_VK_NUMPAD7, VK_NUMPAD7}, - {J_VK_NUMPAD8, VK_NUMPAD8}, - {J_VK_NUMPAD9, VK_NUMPAD9}, + {J_VK_NUMPAD0, VK_NUMPAD0, 0}, + {J_VK_NUMPAD1, VK_NUMPAD1, 0}, + {J_VK_NUMPAD2, VK_NUMPAD2, 0}, + {J_VK_NUMPAD3, VK_NUMPAD3, 0}, + {J_VK_NUMPAD4, VK_NUMPAD4, 0}, + {J_VK_NUMPAD5, VK_NUMPAD5, 0}, + {J_VK_NUMPAD6, VK_NUMPAD6, 0}, + {J_VK_NUMPAD7, VK_NUMPAD7, 0}, + {J_VK_NUMPAD8, VK_NUMPAD8, 0}, + {J_VK_NUMPAD9, VK_NUMPAD9, 0}, // NumPad with NumLock on - {J_VK_MULTIPLY, VK_MULTIPLY}, - {J_VK_ADD, VK_ADD}, - {J_VK_SEPARATOR, VK_SEPARATOR}, - {J_VK_SUBTRACT, VK_SUBTRACT}, - {J_VK_DECIMAL, VK_DECIMAL}, - {J_VK_DIVIDE, VK_DIVIDE}, + {J_VK_MULTIPLY, VK_MULTIPLY, 0}, + {J_VK_ADD, VK_ADD, 0}, + {J_VK_SEPARATOR, VK_SEPARATOR, 0}, + {J_VK_SUBTRACT, VK_SUBTRACT, 0}, + {J_VK_DECIMAL, VK_DECIMAL, 0}, + {J_VK_DIVIDE, VK_DIVIDE, 0}, // Functional keys - {J_VK_F1, VK_F1}, - {J_VK_F2, VK_F2}, - {J_VK_F3, VK_F3}, - {J_VK_F4, VK_F4}, - {J_VK_F5, VK_F5}, - {J_VK_F6, VK_F6}, - {J_VK_F7, VK_F7}, - {J_VK_F8, VK_F8}, - {J_VK_F9, VK_F9}, - {J_VK_F10, VK_F10}, - {J_VK_F11, VK_F11}, - {J_VK_F12, VK_F12}, - {J_VK_F13, VK_F13}, - {J_VK_F14, VK_F14}, - {J_VK_F15, VK_F15}, - {J_VK_F16, VK_F16}, - {J_VK_F17, VK_F17}, - {J_VK_F18, VK_F18}, - {J_VK_F19, VK_F19}, - {J_VK_F20, VK_F20}, - {J_VK_F21, VK_F21}, - {J_VK_F22, VK_F22}, - {J_VK_F23, VK_F23}, - {J_VK_F24, VK_F24}, - - {J_VK_PRINTSCREEN, VK_SNAPSHOT}, - {J_VK_SCROLL_LOCK, VK_SCROLL}, - {J_VK_PAUSE, VK_PAUSE}, - {J_VK_CANCEL, VK_CANCEL}, - {J_VK_HELP, VK_HELP}, + {J_VK_F1, VK_F1, 0}, + {J_VK_F2, VK_F2, 0}, + {J_VK_F3, VK_F3, 0}, + {J_VK_F4, VK_F4, 0}, + {J_VK_F5, VK_F5, 0}, + {J_VK_F6, VK_F6, 0}, + {J_VK_F7, VK_F7, 0}, + {J_VK_F8, VK_F8, 0}, + {J_VK_F9, VK_F9, 0}, + {J_VK_F10, VK_F10, 0}, + {J_VK_F11, VK_F11, 0}, + {J_VK_F12, VK_F12, 0}, + {J_VK_F13, VK_F13, 0}, + {J_VK_F14, VK_F14, 0}, + {J_VK_F15, VK_F15, 0}, + {J_VK_F16, VK_F16, 0}, + {J_VK_F17, VK_F17, 0}, + {J_VK_F18, VK_F18, 0}, + {J_VK_F19, VK_F19, 0}, + {J_VK_F20, VK_F20, 0}, + {J_VK_F21, VK_F21, 0}, + {J_VK_F22, VK_F22, 0}, + {J_VK_F23, VK_F23, 0}, + {J_VK_F24, VK_F24, 0}, + + {J_VK_PRINTSCREEN, VK_SNAPSHOT, 0}, + {J_VK_SCROLL_LOCK, VK_SCROLL, 0}, + {J_VK_PAUSE, VK_PAUSE, 0}, + {J_VK_CANCEL, VK_CANCEL, 0}, + {J_VK_HELP, VK_HELP, 0}, + + // Since we unify mappings via US kbd layout .. this is valid: + {J_VK_SEMICOLON, VK_OEM_1, 0}, // US only ';:' + {J_VK_EQUALS, VK_OEM_PLUS, 0}, // '=+' + {J_VK_COMMA, VK_OEM_COMMA, 0}, // ',<' + {J_VK_MINUS, VK_OEM_MINUS, 0}, // '-_' + {J_VK_PERIOD, VK_OEM_PERIOD, 0}, // '.>' + {J_VK_SLASH, VK_OEM_2, 0}, // US only '/?' + {J_VK_BACK_QUOTE, VK_OEM_3, 0}, // US only '`~' + {J_VK_OPEN_BRACKET, VK_OEM_4, 0}, // US only '[}' + {J_VK_BACK_SLASH, VK_OEM_5, 0}, // US only '\|' + {J_VK_CLOSE_BRACKET, VK_OEM_6, 0}, // US only ']}' + {J_VK_QUOTE, VK_OEM_7, 0}, // US only ''"' + // {J_VK_????, VK_OEM_8, 0}, // varies .. + // {J_VK_????, VK_OEM_102, 0}, // angle-bracket or backslash key on RT 102-key kbd // Japanese /* - {J_VK_CONVERT, VK_CONVERT}, - {J_VK_NONCONVERT, VK_NONCONVERT}, - {J_VK_INPUT_METHOD_ON_OFF, VK_KANJI}, - {J_VK_ALPHANUMERIC, VK_DBE_ALPHANUMERIC}, - {J_VK_KATAKANA, VK_DBE_KATAKANA}, - {J_VK_HIRAGANA, VK_DBE_HIRAGANA}, - {J_VK_FULL_WIDTH, VK_DBE_DBCSCHAR}, - {J_VK_HALF_WIDTH, VK_DBE_SBCSCHAR}, - {J_VK_ROMAN_CHARACTERS, VK_DBE_ROMAN}, + {J_VK_CONVERT, VK_CONVERT, 0}, + {J_VK_NONCONVERT, VK_NONCONVERT, 0}, + {J_VK_INPUT_METHOD_ON_OFF, VK_KANJI, 0}, + {J_VK_ALPHANUMERIC, VK_DBE_ALPHANUMERIC, 0}, + {J_VK_KATAKANA, VK_DBE_KATAKANA, 0}, + {J_VK_HIRAGANA, VK_DBE_HIRAGANA, 0}, + {J_VK_FULL_WIDTH, VK_DBE_DBCSCHAR, 0}, + {J_VK_HALF_WIDTH, VK_DBE_SBCSCHAR, 0}, + {J_VK_ROMAN_CHARACTERS, VK_DBE_ROMAN, 0}, */ - {J_VK_UNDEFINED, 0} + {J_VK_UNDEFINED, 0, 0} }; -/* -Dynamic mapping table for OEM VK codes. This table is refilled -by BuildDynamicKeyMapTable when keyboard layout is switched. -(see NT4 DDK src/input/inc/vkoem.h for OEM VK_ values). -*/ -typedef struct { - // OEM VK codes known in advance - UINT windowsKey; - // depends on input langauge (kbd layout) - UINT javaKey; -} DynamicKeyMapEntry; - -static DynamicKeyMapEntry dynamicKeyMapTable[] = { - {0x00BA, J_VK_UNDEFINED}, // VK_OEM_1 - {0x00BB, J_VK_UNDEFINED}, // VK_OEM_PLUS - {0x00BC, J_VK_UNDEFINED}, // VK_OEM_COMMA - {0x00BD, J_VK_UNDEFINED}, // VK_OEM_MINUS - {0x00BE, J_VK_UNDEFINED}, // VK_OEM_PERIOD - {0x00BF, J_VK_UNDEFINED}, // VK_OEM_2 - {0x00C0, J_VK_UNDEFINED}, // VK_OEM_3 - {0x00DB, J_VK_UNDEFINED}, // VK_OEM_4 - {0x00DC, J_VK_UNDEFINED}, // VK_OEM_5 - {0x00DD, J_VK_UNDEFINED}, // VK_OEM_6 - {0x00DE, J_VK_UNDEFINED}, // VK_OEM_7 - {0x00DF, J_VK_UNDEFINED}, // VK_OEM_8 - {0x00E2, J_VK_UNDEFINED}, // VK_OEM_102 - {0, 0} -}; +#ifndef KLF_ACTIVATE + #define KLF_ACTIVATE 0x00000001 +#endif +#ifndef MAPVK_VK_TO_VSC + #define MAPVK_VK_TO_VSC 0 +#endif +#ifndef MAPVK_VSC_TO_VK + #define MAPVK_VSC_TO_VK 1 +#endif +#ifndef MAPVK_VK_TO_CHAR + #define MAPVK_VK_TO_CHAR 2 +#endif +#ifndef MAPVK_VSC_TO_VK_EX + #define MAPVK_VSC_TO_VK_EX 3 +#endif +#ifndef MAPVK_VK_TO_VSC_EX + #define MAPVK_VK_TO_VSC_EX 4 +#endif -// Auxiliary tables used to fill the above dynamic table. We first -// find the character for the OEM VK code using ::MapVirtualKey and -// then go through these auxiliary tables to map it to Java VK code. +static HKL kbdLayoutUS = 0; +static const LPCSTR US_LAYOUT_NAME = "00000409"; -typedef struct { - WCHAR c; - UINT javaKey; -} CharToVKEntry; - -static const CharToVKEntry charToVKTable[] = { - {L'!', J_VK_EXCLAMATION_MARK}, - {L'"', J_VK_QUOTEDBL}, - {L'#', J_VK_NUMBER_SIGN}, - {L'$', J_VK_DOLLAR}, - {L'&', J_VK_AMPERSAND}, - {L'\'', J_VK_QUOTE}, - {L'(', J_VK_LEFT_PARENTHESIS}, - {L')', J_VK_RIGHT_PARENTHESIS}, - {L'*', J_VK_ASTERISK}, - {L'+', J_VK_PLUS}, - {L',', J_VK_COMMA}, - {L'-', J_VK_MINUS}, - {L'.', J_VK_PERIOD}, - {L'/', J_VK_SLASH}, - {L':', J_VK_COLON}, - {L';', J_VK_SEMICOLON}, - {L'<', J_VK_LESS}, - {L'=', J_VK_EQUALS}, - {L'>', J_VK_GREATER}, - {L'@', J_VK_AT}, - {L'[', J_VK_OPEN_BRACKET}, - {L'\\', J_VK_BACK_SLASH}, - {L']', J_VK_CLOSE_BRACKET}, - {L'^', J_VK_CIRCUMFLEX}, - {L'_', J_VK_UNDERSCORE}, - {L'`', J_VK_BACK_QUOTE}, - {L'{', J_VK_BRACELEFT}, - {L'}', J_VK_BRACERIGHT}, - {0x00A1, J_VK_INVERTED_EXCLAMATION_MARK}, - {0x20A0, J_VK_EURO_SIGN}, // ???? - {0,0} -}; +static BYTE kbdState[256]; +static USHORT spaceScanCode; -// For dead accents some layouts return ASCII punctuation, while some -// return spacing accent chars, so both should be listed. NB: MS docs -// say that conversion routings return spacing accent character, not -// combining. -static const CharToVKEntry charToDeadVKTable[] = { - {L'`', J_VK_DEAD_GRAVE}, - {L'\'', J_VK_DEAD_ACUTE}, - {0x00B4, J_VK_DEAD_ACUTE}, - {L'^', J_VK_DEAD_CIRCUMFLEX}, - {L'~', J_VK_DEAD_TILDE}, - {0x02DC, J_VK_DEAD_TILDE}, - {0x00AF, J_VK_DEAD_MACRON}, - {0x02D8, J_VK_DEAD_BREVE}, - {0x02D9, J_VK_DEAD_ABOVEDOT}, - {L'"', J_VK_DEAD_DIAERESIS}, - {0x00A8, J_VK_DEAD_DIAERESIS}, - {0x02DA, J_VK_DEAD_ABOVERING}, - {0x02DD, J_VK_DEAD_DOUBLEACUTE}, - {0x02C7, J_VK_DEAD_CARON}, // aka hacek - {L',', J_VK_DEAD_CEDILLA}, - {0x00B8, J_VK_DEAD_CEDILLA}, - {0x02DB, J_VK_DEAD_OGONEK}, - {0x037A, J_VK_DEAD_IOTA}, // ASCII ??? - {0x309B, J_VK_DEAD_VOICED_SOUND}, - {0x309C, J_VK_DEAD_SEMIVOICED_SOUND}, - {0,0} -}; +static void InitKeyMapTableScanCode(JNIEnv *env) { + HKL hkl = GetKeyboardLayout(0); + int i; -// ANSI CP identifiers are no longer than this -#define MAX_ACP_STR_LEN 7 + kbdLayoutUS = LoadKeyboardLayout( US_LAYOUT_NAME, 0 /* ? KLF_ACTIVATE ? */ ); + if( 0 == kbdLayoutUS ) { + int lastError = (int) GetLastError(); + kbdLayoutUS = hkl; // use prev. layout .. well + STD_PRINT("Warning: NEWT Windows: LoadKeyboardLayout(US, ..) failed: winErr 0x%X %d\n", lastError, lastError); + } + ActivateKeyboardLayout(hkl, 0); + + spaceScanCode = MapVirtualKeyEx(VK_SPACE, MAPVK_VK_TO_VSC, hkl); + + // Setup keyMapTable's windowsScanCodeUS + for (i = 0; keyMapTable[i].windowsKey != 0; i++) { + USHORT scancode = (USHORT) MapVirtualKeyEx(keyMapTable[i].windowsKey, MAPVK_VK_TO_VSC_EX, kbdLayoutUS); + #ifdef DEBUG_KEYS + if( 0 == scancode ) { + int lastError = (int) GetLastError(); + STD_PRINT("*** WindowsWindow: InitKeyMapTableScanCode: No ScanCode for windows vkey 0x%X (item %d), winErr 0x%X %d\n", + keyMapTable[i].windowsKey, i, lastError, lastError); + } + STD_PRINT("*** WindowsWindow: InitKeyMapTableScanCode: %3.3d windows vkey 0x%X -> scancode 0x%X\n", + i, keyMapTable[i].windowsKey, scancode); + #endif + keyMapTable[i].windowsScanCodeUS = scancode; + } +} + +static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags, USHORT *outJavaVKeyUS, USHORT *outJavaVKeyXX, USHORT *outUTF16Char) { + wchar_t uniChars[2] = { L'\0', L'\0' }; // uint16_t + USHORT winVKeyUS = 0; + int nUniChars, i, j; + USHORT javaVKeyUS = J_VK_UNDEFINED; + USHORT javaVKeyXX = J_VK_UNDEFINED; -static void BuildDynamicKeyMapTable() -{ HKL hkl = GetKeyboardLayout(0); - // Will need this to reset layout after dead keys. - UINT spaceScanCode = MapVirtualKeyEx(VK_SPACE, 0, hkl); - DynamicKeyMapEntry *dynamic; - - LANGID idLang = LOWORD(GetKeyboardLayout(0)); - UINT codePage; - TCHAR strCodePage[MAX_ACP_STR_LEN]; - // use the LANGID to create a LCID - LCID idLocale = MAKELCID(idLang, SORT_DEFAULT); - // get the ANSI code page associated with this locale - if (GetLocaleInfo(idLocale, LOCALE_IDEFAULTANSICODEPAGE, - strCodePage, sizeof(strCodePage)/sizeof(TCHAR)) > 0 ) - { - codePage = _ttoi(strCodePage); - } else { - codePage = GetACP(); + + // + // winVKey, winScanCode -> UTF16 w/ current KeyboardLayout + // + GetKeyboardState(kbdState); + kbdState[winVKey] |= 0x80; + nUniChars = ToUnicodeEx(winVKey, winScanCode, kbdState, uniChars, 2, 0, hkl); + kbdState[winVKey] &= ~0x80; + + *outUTF16Char = (USHORT)(uniChars[0]); // Note: Even dead key are written in uniChar's .. + + if ( 0 > nUniChars ) { // Dead key + char junkbuf[2] = { '\0', '\0'}; + + // We need to reset layout so that next translation + // is unaffected by the dead status. We do this by + // translating key. + kbdState[VK_SPACE] |= 0x80; + ToAsciiEx(VK_SPACE, spaceScanCode, kbdState, (WORD*)junkbuf, 0, hkl); + kbdState[VK_SPACE] &= ~0x80; } - // Entries in dynamic table that maps between Java VK and Windows - // VK are built in three steps: - // 1. Map windows VK to ANSI character (cannot map to unicode - // directly, since ::ToUnicode is not implemented on win9x) - // 2. Convert ANSI char to Unicode char - // 3. Map Unicode char to Java VK via two auxilary tables. + // Assume extended scan code 0xE0 if extended flags is set (no 0xE1 from WM_KEYUP/WM_KEYDOWN) + USHORT winScanCodeExt = winScanCode; + if( 0 != ( 0x01 & flags ) ) { + winScanCodeExt |= 0xE000; + } - for (dynamic = dynamicKeyMapTable; dynamic->windowsKey != 0; ++dynamic) - { - char cbuf[2] = { '\0', '\0'}; - WCHAR ucbuf[2] = { L'\0', L'\0' }; - int nchars; - UINT scancode; - const CharToVKEntry *charMap; - int nconverted; - WCHAR uc; - BYTE kbdState[256]; - - // Defaults to J_VK_UNDEFINED - dynamic->javaKey = J_VK_UNDEFINED; - - GetKeyboardState(kbdState); - - kbdState[dynamic->windowsKey] |= 0x80; // Press the key. - - // Unpress modifiers, since they are most likely pressed as - // part of the keyboard switching shortcut. - kbdState[VK_CONTROL] &= ~0x80; - kbdState[VK_SHIFT] &= ~0x80; - kbdState[VK_MENU] &= ~0x80; - - scancode = MapVirtualKeyEx(dynamic->windowsKey, 0, hkl); - nchars = ToAsciiEx(dynamic->windowsKey, scancode, kbdState, - (WORD*)cbuf, 0, hkl); - - // Auxiliary table used to map Unicode character to Java VK. - // Will assign a different table for dead keys (below). - charMap = charToVKTable; - - if (nchars < 0) { // Dead key - char junkbuf[2] = { '\0', '\0'}; - // Use a different table for dead chars since different layouts - // return different characters for the same dead key. - charMap = charToDeadVKTable; - - // We also need to reset layout so that next translation - // is unaffected by the dead status. We do this by - // translating key. - kbdState[dynamic->windowsKey] &= ~0x80; - kbdState[VK_SPACE] |= 0x80; - - ToAsciiEx(VK_SPACE, spaceScanCode, kbdState, - (WORD*)junkbuf, 0, hkl); + // + // winVKey, winScanCodeExt -> javaVKeyUS w/ US KeyboardLayout + // + for (i = 0; keyMapTable[i].windowsKey != 0; i++) { + if ( keyMapTable[i].windowsScanCodeUS == winScanCodeExt ) { + javaVKeyUS = keyMapTable[i].javaKey; + winVKeyUS = keyMapTable[i].windowsKey; + break; } + } - nconverted = MultiByteToWideChar(codePage, 0, - cbuf, 1, ucbuf, 2); - - uc = ucbuf[0]; - { - const CharToVKEntry *map; - for (map = charMap; map->c != 0; ++map) { - if (uc == map->c) { - dynamic->javaKey = map->javaKey; - break; - } - } + // + // winVKey -> javaVKeyXX + // + for (i = 0; keyMapTable[i].windowsKey != 0; i++) { + if ( keyMapTable[i].windowsKey == winVKey ) { + javaVKeyXX = keyMapTable[i].javaKey; + break; } + } + + *outJavaVKeyUS = javaVKeyUS; + *outJavaVKeyXX = javaVKeyXX; - } // for each VK_OEM_* +#ifdef DEBUG_KEYS + STD_PRINT("*** WindowsWindow: ParseWmVKeyAndScanCode winVKey 0x%X, winScanCode 0x%X, winScanCodeExt 0x%X, flags 0x%X -> UTF(0x%X, %c, res %d, sizeof %d), vKeys( US(win 0x%X, java 0x%X), XX(win 0x%X, java 0x%X))\n", + (int)winVKey, (int)winScanCode, winScanCodeExt, (int)flags, + *outUTF16Char, *outUTF16Char, nUniChars, sizeof(uniChars[0]), + winVKeyUS, javaVKeyUS, winVKey, javaVKeyXX); +#endif } -static jint GetModifiers(BOOL altKeyFlagged, UINT jkey) { +static jint GetModifiers(BOOL altKeyFlagged, USHORT jkey) { jint modifiers = 0; // have to do &0xFFFF to avoid runtime assert caused by compiling with // /RTCcsu @@ -516,121 +463,38 @@ static BOOL IsAltKeyDown(BYTE flags, BOOL system) { return system && ( flags & (1<<5) ) != 0; } -UINT WindowsKeyToJavaKey(UINT windowsKey) -{ - int i, j, javaKey = J_VK_UNDEFINED; - // for the general case, use a bi-directional table - for (i = 0; keyMapTable[i].windowsKey != 0; i++) { - if (keyMapTable[i].windowsKey == windowsKey) { - javaKey = keyMapTable[i].javaKey; - } - } - if( J_VK_UNDEFINED == javaKey ) { - for (j = 0; dynamicKeyMapTable[j].windowsKey != 0; j++) { - if (dynamicKeyMapTable[j].windowsKey == windowsKey) { - if (dynamicKeyMapTable[j].javaKey != J_VK_UNDEFINED) { - javaKey = dynamicKeyMapTable[j].javaKey; - } else { - break; - } - } - } - } - -#ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: WindowsKeyToJavaKey 0x%X -> 0x%X\n", windowsKey, javaKey); -#endif - return javaKey; -} - -#ifndef MAPVK_VSC_TO_VK - #define MAPVK_VSC_TO_VK 1 -#endif -#ifndef MAPVK_VK_TO_CHAR - #define MAPVK_VK_TO_CHAR 2 -#endif - -static UINT WmVKey2ShiftedChar(UINT wkey, UINT modifiers) { - UINT c = MapVirtualKey(wkey, MAPVK_VK_TO_CHAR); - if( 0 != ( modifiers & EVENT_SHIFT_MASK ) ) { - return islower(c) ? toupper(c) : c; - } - return isupper(c) ? tolower(c) : c; -} - -static int WmChar(JNIEnv *env, jobject window, UINT character, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, wkey = 0; - - wkey = MapVirtualKey(scanCode, MAPVK_VSC_TO_VK); - jkey = WindowsKeyToJavaKey(wkey); - modifiers = GetModifiers( IsAltKeyDown(flags, system), 0 ); - - if (character == VK_RETURN) { - character = J_VK_ENTER; - } - - (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_TYPED, - modifiers, - (jint) jkey, - (jchar) character); - return 1; -} - -static int WmKeyDown(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = 0; +static int WmKeyDown(JNIEnv *env, jobject window, USHORT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { + UINT modifiers = 0; + USHORT javaVKeyUS=0, javaVKeyXX=0, utf16Char=0; if (wkey == VK_PROCESSKEY) { return 1; } - jkey = WindowsKeyToJavaKey(wkey); - modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey ); - character = WmVKey2ShiftedChar(wkey, modifiers); + ParseWmVKeyAndScanCode(wkey, scanCode, flags, &javaVKeyUS, &javaVKeyXX, &utf16Char); -/* - character = WindowsKeyToJavaChar(wkey, modifiers, SAVE); -*/ + modifiers = GetModifiers( IsAltKeyDown(flags, system), javaVKeyXX ); (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_PRESSED, - modifiers, - (jint) jkey, - (jchar) character); - - /* windows does not create a WM_CHAR for the Del key - for some reason, so we need to create the KEY_TYPED event on the - WM_KEYDOWN. - */ - if (jkey == J_VK_DELETE) { - (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_TYPED, - modifiers, - (jint) jkey, - (jchar) '\177'); - } + (jshort) EVENT_KEY_PRESSED, + (jint) modifiers, (jshort) javaVKeyUS, (jshort) javaVKeyXX, (jchar) utf16Char); return 0; } -static int WmKeyUp(JNIEnv *env, jobject window, UINT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { - UINT modifiers = 0, jkey = 0, character = 0; +static int WmKeyUp(JNIEnv *env, jobject window, USHORT wkey, WORD repCnt, BYTE scanCode, BYTE flags, BOOL system) { + UINT modifiers = 0; + USHORT javaVKeyUS=0, javaVKeyXX=0, utf16Char=0; if (wkey == VK_PROCESSKEY) { return 1; } - jkey = WindowsKeyToJavaKey(wkey); - modifiers = GetModifiers( IsAltKeyDown(flags, system), jkey ); - character = WmVKey2ShiftedChar(wkey, modifiers); + ParseWmVKeyAndScanCode(wkey, scanCode, flags, &javaVKeyUS, &javaVKeyXX, &utf16Char); -/* - character = WindowsKeyToJavaChar(wkey, modifiers, SAVE); -*/ + modifiers = GetModifiers( IsAltKeyDown(flags, system), javaVKeyXX ); (*env)->CallVoidMethod(env, window, sendKeyEventID, - (jint) EVENT_KEY_RELEASED, - modifiers, - (jint) jkey, - (jchar) character); + (jshort) EVENT_KEY_RELEASED, + (jint) modifiers, (jshort) javaVKeyUS, (jshort) javaVKeyXX, (jchar) utf16Char); return 0; } @@ -933,46 +797,35 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_SYSCHAR: - repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); - repCnt = LOWORD(lParam); -#ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_SYSCHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); -#endif - useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, TRUE); + useDefWindowProc = 1; break; case WM_SYSKEYDOWN: repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); + DBG_PRINT("*** WindowsWindow: windProc WM_SYSKEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif - useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, TRUE); + useDefWindowProc = WmKeyDown(env, window, (USHORT)wParam, repCnt, scanCode, flags, TRUE); break; case WM_SYSKEYUP: repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_SYSKEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); + DBG_PRINT("*** WindowsWindow: windProc WM_SYSKEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif - useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, TRUE); + useDefWindowProc = WmKeyUp(env, window, (USHORT)wParam, repCnt, scanCode, flags, TRUE); break; case WM_CHAR: - repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); - repCnt = LOWORD(lParam); -#ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_CHAR sending window %p -> %p, char 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); -#endif - useDefWindowProc = WmChar(env, window, wParam, repCnt, scanCode, flags, FALSE); + useDefWindowProc = 1; break; case WM_KEYDOWN: repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); - repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_KEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); + DBG_PRINT("*** WindowsWindow: windProc WM_KEYDOWN sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif useDefWindowProc = WmKeyDown(env, window, wParam, repCnt, scanCode, flags, FALSE); break; @@ -981,7 +834,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP repCnt = HIWORD(lParam); scanCode = LOBYTE(repCnt); flags = HIBYTE(repCnt); repCnt = LOWORD(lParam); #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: windProc WM_KEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); + DBG_PRINT("*** WindowsWindow: windProc WM_KEYUP sending window %p -> %p, code 0x%X, repCnt %d, scanCode 0x%X, flags 0x%X\n", wnd, window, (int)wParam, (int)repCnt, (int)scanCode, (int)flags); #endif useDefWindowProc = WmKeyUp(env, window, wParam, repCnt, scanCode, flags, FALSE); break; @@ -1005,19 +858,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP DBG_PRINT("*** WindowsWindow: LBUTTONDOWN\n"); (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_PRESSED, + (jshort) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 1, (jfloat) 0.0f); + (jshort) 1, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_LBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_RELEASED, + (jshort) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 1, (jfloat) 0.0f); + (jshort) 1, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -1025,19 +878,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP DBG_PRINT("*** WindowsWindow: MBUTTONDOWN\n"); (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_PRESSED, + (jshort) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 2, (jfloat) 0.0f); + (jshort) 2, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_MBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_RELEASED, + (jshort) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 2, (jfloat) 0.0f); + (jshort) 2, (jfloat) 0.0f); useDefWindowProc = 1; break; @@ -1045,36 +898,36 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP DBG_PRINT("*** WindowsWindow: RBUTTONDOWN\n"); (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_PRESSED, + (jshort) EVENT_MOUSE_PRESSED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 3, (jfloat) 0.0f); + (jshort) 3, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_RBUTTONUP: (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_RELEASED, + (jshort) EVENT_MOUSE_RELEASED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 3, (jfloat) 0.0f); + (jshort) 3, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_MOUSEMOVE: (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_MOVED, + (jshort) EVENT_MOUSE_MOVED, GetModifiers( FALSE, 0 ), (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - (jint) 0, (jfloat) 0.0f); + (jshort) 0, (jfloat) 0.0f); useDefWindowProc = 1; break; case WM_MOUSELEAVE: - (*env)->CallVoidMethod(env, window, enqueueMouseEventID, JNI_FALSE, - (jint) EVENT_MOUSE_EXITED, + (*env)->CallVoidMethod(env, window, sendMouseEventID, JNI_FALSE, + (jshort) EVENT_MOUSE_EXITED, 0, (jint) -1, (jint) -1, // fake - (jint) 0, (jfloat) 0.0f); + (jshort) 0, (jfloat) 0.0f); useDefWindowProc = 1; break; // Java synthesizes EVENT_MOUSE_ENTERED @@ -1099,10 +952,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP } DBG_PRINT("*** WindowsWindow: WM_HSCROLL 0x%X, rotation %f, mods 0x%X\n", sb, rotation, modifiers); (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_WHEEL_MOVED, + (jshort) EVENT_MOUSE_WHEEL_MOVED, modifiers, (jint) 0, (jint) 0, - (jint) 1, (jfloat) rotation); + (jshort) 1, (jfloat) rotation); useDefWindowProc = 1; break; } @@ -1128,10 +981,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP (int)eventPt.x, (int)eventPt.y, rotationOrTilt, vKeys, modifiers); } (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jint) EVENT_MOUSE_WHEEL_MOVED, + (jshort) EVENT_MOUSE_WHEEL_MOVED, modifiers, (jint) eventPt.x, (jint) eventPt.y, - (jint) 1, (jfloat) rotationOrTilt); + (jshort) 1, (jfloat) rotationOrTilt); useDefWindowProc = 1; break; } @@ -1208,7 +1061,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_DispatchMes // DBG_PRINT("*** WindowsWindow.DispatchMessages0: thread 0x%X - gotOne %d\n", (int)GetCurrentThreadId(), (int)gotOne); if (gotOne) { ++i; - TranslateMessage(&msg); + // TranslateMessage(&msg); // No more needed: We translate V_KEY -> UTF Char manually in key up/down DispatchMessage(&msg); } } while (gotOne && i < 100); @@ -1474,10 +1327,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZIIIIIF)V"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZIIIC)V"); - sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); + sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(SIIISF)V"); + sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(SISSC)V"); requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V"); if (insetsChangedID == NULL || @@ -1487,14 +1338,12 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_initIDs0 visibleChangedID == NULL || windowDestroyNotifyID == NULL || windowRepaintID == NULL || - enqueueMouseEventID == NULL || sendMouseEventID == NULL || - enqueueKeyEventID == NULL || sendKeyEventID == NULL || requestFocusID == NULL) { return JNI_FALSE; } - BuildDynamicKeyMapTable(); + InitKeyMapTableScanCode(env); return JNI_TRUE; } diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 85b3a14c7..9b11ff0dd 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -28,8 +28,6 @@ #include "X11Common.h" -#define USE_SENDIO_DIRECT 1 - jclass X11NewtWindowClazz = NULL; jmethodID insetsChangedID = NULL; jmethodID visibleChangedID = NULL; @@ -46,9 +44,7 @@ static jmethodID focusChangedID = NULL; static jmethodID reparentNotifyID = NULL; static jmethodID windowDestroyNotifyID = NULL; static jmethodID windowRepaintID = NULL; -static jmethodID enqueueMouseEventID = NULL; static jmethodID sendMouseEventID = NULL; -static jmethodID enqueueKeyEventID = NULL; static jmethodID sendKeyEventID = NULL; static jmethodID requestFocusID = NULL; @@ -59,10 +55,18 @@ static jmethodID requestFocusID = NULL; #define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b)) static jint X11KeySym2NewtVKey(KeySym keySym) { - if(IS_WITHIN(keySym,XK_F1,XK_F12)) - return (keySym-XK_F1)+J_VK_F1; - if(IS_WITHIN(keySym,XK_KP_0,XK_KP_9)) - return (keySym-XK_KP_0)+J_VK_NUMPAD0; + if( IS_WITHIN( keySym, XK_a, XK_z ) ) { + return ( keySym - XK_a ) + J_VK_A ; + } + if( IS_WITHIN( keySym, XK_0, XK_9 ) ) { + return ( keySym - XK_0 ) + J_VK_0 ; + } + if( IS_WITHIN( keySym, XK_KP_0, XK_KP_9 ) ) { + return ( keySym - XK_KP_0 ) + J_VK_NUMPAD0 ; + } + if( IS_WITHIN( keySym, XK_F1, XK_F12 ) ) { + return ( keySym - XK_F1 ) + J_VK_F1 ; + } switch(keySym) { case XK_Return: @@ -154,15 +158,15 @@ static jint X11KeySym2NewtVKey(KeySym keySym) { return keySym; } -static jint X11InputState2NewtModifiers(unsigned int xstate, KeySym keySym) { +static jint X11InputState2NewtModifiers(unsigned int xstate, int javaVKey) { jint modifiers = 0; - if ( (ControlMask & xstate) != 0 || J_VK_CONTROL == keySym ) { + if ( (ControlMask & xstate) != 0 || J_VK_CONTROL == javaVKey ) { modifiers |= EVENT_CTRL_MASK; } - if ( (ShiftMask & xstate) != 0 || J_VK_SHIFT == keySym ) { + if ( (ShiftMask & xstate) != 0 || J_VK_SHIFT == javaVKey ) { modifiers |= EVENT_SHIFT_MASK; } - if ( (Mod1Mask & xstate) != 0 || J_VK_ALT == keySym ) { + if ( (Mod1Mask & xstate) != 0 || J_VK_ALT == javaVKey ) { modifiers |= EVENT_ALT_MASK; } if ( (Button1Mask & xstate) != 0 ) { @@ -218,10 +222,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 reparentNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "reparentNotify", "(J)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowDestroyNotify", "(Z)Z"); windowRepaintID = (*env)->GetMethodID(env, X11NewtWindowClazz, "windowRepaint", "(ZIIII)V"); - enqueueMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueMouseEvent", "(ZIIIIIF)V"); - sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(IIIIIF)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "enqueueKeyEvent", "(ZIIIC)V"); - sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(IIIC)V"); + sendMouseEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendMouseEvent", "(SIIISF)V"); + sendKeyEventID = (*env)->GetMethodID(env, X11NewtWindowClazz, "sendKeyEvent", "(SISSC)V"); requestFocusID = (*env)->GetMethodID(env, X11NewtWindowClazz, "requestFocus", "(Z)V"); if (displayCompletedID == NULL || @@ -235,9 +237,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_initIDs0 reparentNotifyID == NULL || windowDestroyNotifyID == NULL || windowRepaintID == NULL || - enqueueMouseEventID == NULL || sendMouseEventID == NULL || - enqueueKeyEventID == NULL || sendKeyEventID == NULL || requestFocusID == NULL) { return JNI_FALSE; @@ -328,6 +328,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage jobject jwindow = NULL; XEvent evt; KeySym keySym = 0; + KeyCode keyCode = 0; + jshort javaVKeyUS = 0; + jshort javaVKeyNN = 0; jint modifiers = 0; char keyChar = 0; char text[255]; @@ -386,18 +389,23 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage autoRepeatModifiers &= ~EVENT_AUTOREPEAT_MASK; } // fall through intended - case KeyPress: - if(XLookupString(&evt.xkey,text,255,&keySym,0)==1) { - KeySym lower_return = 0, upper_return = 0; - keyChar=text[0]; - XConvertCase(keySym, &lower_return, &upper_return); - // always return upper case, set modifier masks (SHIFT, ..) - keySym = X11KeySym2NewtVKey(upper_return); - } else { - keyChar=0; - keySym = X11KeySym2NewtVKey(keySym); + case KeyPress: { + KeySym shiftedKeySym; // layout depending keySym w/ SHIFT + + keyCode = evt.xkey.keycode; + keySym = XkbKeycodeToKeysym(dpy, keyCode, 0 /* group */, 0 /* shift level */); // layout depending keySym w/o SHIFT + + if( XLookupString(&evt.xkey, text, 255, &shiftedKeySym, 0) == 1 ) { + keyChar=text[0]; + } + + javaVKeyNN = X11KeySym2NewtVKey(keySym); + javaVKeyUS = javaVKeyNN; // FIXME! + modifiers |= X11InputState2NewtModifiers(evt.xkey.state, javaVKeyNN) | autoRepeatModifiers; + + fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X (shifted: 0x%X), keyChar '%c', javaVKey[US 0x%X, NN 0x%X]\n", + (int)keyCode, (int)keySym, (int)shiftedKeySym, (int)keyChar, (int)javaVKeyUS, (int)javaVKeyNN); } - modifiers |= X11InputState2NewtModifiers(evt.xkey.state, keySym) | autoRepeatModifiers; break; case ButtonPress: @@ -413,87 +421,39 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage switch(evt.type) { case ButtonPress: (*env)->CallVoidMethod(env, jwindow, requestFocusID, JNI_FALSE); - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_PRESSED, - modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_PRESSED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); - #endif + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jshort) evt.xbutton.button, 0.0f /*rotation*/); break; case ButtonRelease: - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_RELEASED, - modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_RELEASED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, modifiers, - (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jint) evt.xbutton.button, 0.0f /*rotation*/); - #endif + (jint) evt.xbutton.x, (jint) evt.xbutton.y, (jshort) evt.xbutton.button, 0.0f /*rotation*/); break; case MotionNotify: - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_MOVED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_MOVED, - modifiers, - (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jint) 0, 0.0f /*rotation*/); - #endif + (jint) evt.xmotion.x, (jint) evt.xmotion.y, (jshort) 0, 0.0f /*rotation*/); break; case EnterNotify: DBG_PRINT( "X11: event . EnterNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y); - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_ENTERED, - modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_ENTERED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_ENTERED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); - #endif + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jshort) 0, 0.0f /*rotation*/); break; case LeaveNotify: DBG_PRINT( "X11: event . LeaveNotify call %p %d/%d\n", (void*)evt.xcrossing.window, evt.xcrossing.x, evt.xcrossing.y); - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jint) EVENT_MOUSE_EXITED, + (*env)->CallVoidMethod(env, jwindow, sendMouseEventID, (jshort) EVENT_MOUSE_EXITED, modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueMouseEventID, JNI_FALSE, (jint) EVENT_MOUSE_EXITED, - modifiers, - (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jint) 0, 0.0f /*rotation*/); - #endif + (jint) evt.xcrossing.x, (jint) evt.xcrossing.y, (jshort) 0, 0.0f /*rotation*/); break; case KeyPress: - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_PRESSED, - modifiers, keySym, (jchar) keyChar); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_PRESSED, - modifiers, keySym, (jchar) keyChar); - #endif - + (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jshort) EVENT_KEY_PRESSED, + modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar); break; case KeyRelease: - #ifdef USE_SENDIO_DIRECT - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, - modifiers, keySym, (jchar) keyChar); - - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, - modifiers, keySym, (jchar) keyChar); - #else - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, - modifiers, keySym, (jchar) keyChar); - - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, - modifiers, keySym, (jchar) keyChar); - #endif - + (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jshort) EVENT_KEY_RELEASED, + modifiers, javaVKeyUS, javaVKeyNN, (jchar) keyChar); break; case DestroyNotify: DBG_PRINT( "X11: event . DestroyNotify call %p, parent %p, child-event: %d\n", diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index bbddf764b..f3474ee34 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -50,8 +50,6 @@ static jmethodID windowCreatedID = NULL; static jmethodID sizeChangedID = NULL; static jmethodID visibleChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; -static jmethodID sendMouseEventID = NULL; -static jmethodID sendKeyEventID = NULL; /** * Display @@ -117,14 +115,10 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - sendMouseEventID = (*env)->GetMethodID(env, clazz, "sendMouseEvent", "(IIIIIF)V"); - sendKeyEventID = (*env)->GetMethodID(env, clazz, "sendKeyEvent", "(IIIC)V"); if (windowCreatedID == NULL || sizeChangedID == NULL || visibleChangedID == NULL || - windowDestroyNotifyID == NULL || - sendMouseEventID == NULL || - sendKeyEventID == NULL) { + windowDestroyNotifyID == NULL) { DBG_PRINT( "initIDs failed\n" ); return JNI_FALSE; } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java index ec06379e0..08a181e10 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java @@ -47,6 +47,8 @@ import javax.swing.JFrame; import java.io.IOException; +import jogamp.nativewindow.jawt.JAWTUtil; + import org.junit.BeforeClass; import org.junit.Test; @@ -61,6 +63,11 @@ import com.jogamp.opengl.test.junit.util.*; /** * Testing combinations of key code modifiers of key event. + * + *

    + * Due to limitation of AWT Robot, the test machine needs to have US keyboard enabled, + * even though we do unify VK codes to US keyboard across all layouts. + *

    */ public class TestNewtKeyCodeModifiersAWT extends UITestCase { static int width, height; @@ -99,12 +106,14 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { glWindow.destroy(); } - @Test - public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + private void testNewtCanvasAWT_Impl(boolean onscreen) throws AWTException, InterruptedException, InvocationTargetException { GLWindow glWindow = GLWindow.create(glCaps); // Wrap the window in a canvas. final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + if( !onscreen ) { + newtCanvasAWT.setShallUseOffscreenLayer(true); + } // Add the canvas to a frame, and make it all visible. final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); @@ -129,42 +138,63 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } - glWindow.destroy(); + glWindow.destroy(); + } + + @Test + public void test02NewtCanvasAWT_Onscreen() throws AWTException, InterruptedException, InvocationTargetException { + if( JAWTUtil.isOffscreenLayerRequired() ) { + System.err.println("Platform doesn't support onscreen rendering."); + return; + } + testNewtCanvasAWT_Impl(true); } - static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, int modifierKey, int modifierMask) { + @Test + public void test03NewtCanvasAWT_Offsccreen() throws AWTException, InterruptedException, InvocationTargetException { + if( !JAWTUtil.isOffscreenLayerSupported() ) { + System.err.println("Platform doesn't support offscreen rendering."); + return; + } + testNewtCanvasAWT_Impl(false); + } + + @SuppressWarnings("deprecation") + static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, int modifierKey, int modifierMask, int keyCode, char keyCharOnly, char keyCharMod) { keyAdapter.reset(); - AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P - AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 100); // release+typed P + AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode + AWTRobotUtil.keyPress(0, robot, false, keyCode, 100); // release+typed keyCode robot.waitForIdle(); - for(int j=0; j < 10 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected + for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected robot.delay(100); } AWTRobotUtil.keyPress(0, robot, true, modifierKey, 10); // press MOD - AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P - AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 10); // release+typed P - AWTRobotUtil.keyPress(0, robot, false, modifierKey, 100); // release+typed MOD + AWTRobotUtil.keyPress(0, robot, true, keyCode, 10); // press keyCode + AWTRobotUtil.keyPress(0, robot, false, keyCode, 10); // release+typed keyCode + AWTRobotUtil.keyPress(0, robot, false, modifierKey, 100); // release MOD robot.waitForIdle(); - for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3+6; j++) { // wait until events are collected + for(int j=0; j < 40 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected robot.delay(100); } - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3+6, 0); + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, + 3 /* press-SI */, 3 /* release-SI */, 2 /* typed-SI */, + 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); final List queue = keyAdapter.getQueued(); int i=0; - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, keyCode, keyCharOnly); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, keyCode, keyCharOnly); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, keyCode, keyCharOnly); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, modifierKey); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, keyCode, keyCharMod); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, keyCode, keyCharMod); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, (char)0); } + @SuppressWarnings("deprecation") static void testKeyCodeAllModifierV1(Robot robot, NEWTKeyAdapter keyAdapter) { final int m1k = KeyEvent.VK_ALT; final int m1m = InputEvent.ALT_MASK; @@ -180,32 +210,31 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.keyPress(0, robot, true, KeyEvent.VK_P, 10); // press P AWTRobotUtil.keyPress(0, robot, false, KeyEvent.VK_P, 100); // release+typed P - AWTRobotUtil.keyPress(0, robot, false, m3k, 10); // release+typed MOD - AWTRobotUtil.keyPress(0, robot, false, m2k, 10); // release+typed MOD - AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release+typed MOD + AWTRobotUtil.keyPress(0, robot, false, m3k, 10); // release MOD + AWTRobotUtil.keyPress(0, robot, false, m2k, 10); // release MOD + AWTRobotUtil.keyPress(0, robot, false, m1k, 10); // release MOD robot.waitForIdle(); - for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3*4; j++) { // wait until events are collected + for(int j=0; j < 40 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected robot.delay(100); } - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, 3*4, 0); + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, + 4 /* press-SI */, 4 /* release-SI */, 1 /* typed-SI */, + 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); final List queue = keyAdapter.getQueued(); int i=0; - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, m3k, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_P); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_P); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_P, (char)0); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, m3k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m|m2m, m2k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, m1m, m1k); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, (char)0); + NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, (char)0); } void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { @@ -233,9 +262,11 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input glWindow1KA.reset(); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK); - testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_1, '1', '!'); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_Y, 'y', 'Y'); // US: Y, DE: Z + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_SHIFT, InputEvent.SHIFT_MASK, KeyEvent.VK_P, 'p', 'P'); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_CONTROL, InputEvent.CTRL_MASK, KeyEvent.VK_P, 'p', (char)0); + testKeyCodeModifier(robot, glWindow1KA, KeyEvent.VK_ALT, InputEvent.ALT_MASK, KeyEvent.VK_P, 'p', (char)0); testKeyCodeAllModifierV1(robot, glWindow1KA); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java index ef4b17375..b3ba71795 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java @@ -48,10 +48,13 @@ import javax.swing.JFrame; import java.io.IOException; +import jogamp.nativewindow.jawt.JAWTUtil; + import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -99,12 +102,14 @@ public class TestNewtKeyCodesAWT extends UITestCase { glWindow.destroy(); } - @Test - public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { + private void testNewtCanvasAWT_Impl(boolean onscreen) throws AWTException, InterruptedException, InvocationTargetException { GLWindow glWindow = GLWindow.create(glCaps); // Wrap the window in a canvas. final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); + if( !onscreen ) { + newtCanvasAWT.setShallUseOffscreenLayer(true); + } // Add the canvas to a frame, and make it all visible. final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); @@ -131,7 +136,25 @@ public class TestNewtKeyCodesAWT extends UITestCase { } glWindow.destroy(); } + + @Test + public void test02NewtCanvasAWT_Onscreen() throws AWTException, InterruptedException, InvocationTargetException { + if( JAWTUtil.isOffscreenLayerRequired() ) { + System.err.println("Platform doesn't support onscreen rendering."); + return; + } + testNewtCanvasAWT_Impl(true); + } + @Test + public void test03NewtCanvasAWT_Offsccreen() throws AWTException, InterruptedException, InvocationTargetException { + if( !JAWTUtil.isOffscreenLayerSupported() ) { + System.err.println("Platform doesn't support offscreen rendering."); + return; + } + testNewtCanvasAWT_Impl(false); + } + static CodeSeg[] codeSegments = new CodeSeg[] { new CodeSeg(0x008, 0x008, "bs"), // new CodeSeg(0x009, 0x009, "tab"), // TAB functions as focus traversal key @@ -167,14 +190,29 @@ public class TestNewtKeyCodesAWT extends UITestCase { keyAdapter.reset(); final CodeSeg codeSeg = codeSegments[i]; // System.err.println("*** Segment "+codeSeg.description); - for(int c=codeSeg.min; c<=codeSeg.max; c++) { + int eventCount = 0; + for(short c=codeSeg.min; c<=codeSeg.max; c++) { // System.err.println("*** KeyCode 0x"+Integer.toHexString(c)); - AWTRobotUtil.keyPress(0, robot, true, c, 10); - AWTRobotUtil.keyPress(0, robot, false, c, 100); + try { + AWTRobotUtil.keyPress(0, robot, true, c, 10); + } catch (Exception e) { + System.err.println("Exception @ AWT Robot.PRESS "+MiscUtils.toHexString(c)+" - "+e.getMessage()); + break; + } + eventCount++; + try { + AWTRobotUtil.keyPress(0, robot, false, c, 100); + } catch (Exception e) { + System.err.println("Exception @ AWT Robot.RELEASE "+MiscUtils.toHexString(c)+" - "+e.getMessage()); + break; + } + eventCount++; + if( KeyEvent.isPrintableKey(c) ) { + eventCount++; + } robot.waitForIdle(); } - final int codeCount = codeSeg.max - codeSeg.min + 1; - for(int j=0; j < 20 && keyAdapter.getQueueSize() < 3 * codeCount; j++) { // wait until events are collected + for(int j=0; j < 20 && keyAdapter.getQueueSize() < eventCount; j++) { // wait until events are collected robot.delay(100); } final ArrayList events = new ArrayList(keyAdapter.getQueued()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index 00fbc0500..d7de4e735 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -153,6 +153,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { glWindow.destroy(); } + @SuppressWarnings("deprecation") static void testKeyEventAutoRepeat(Robot robot, NEWTKeyAdapter keyAdapter, int loops, int pressDurationMS) { System.err.println("KEY Event Auto-Repeat Test: "+loops); EventObject[][] first = new EventObject[loops][3]; @@ -201,9 +202,19 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { final boolean hasAR = 0 < keyAdapter.getKeyPressedCount(true) ; { - final int expTotal = keyEvents.size(); - final int expAR = hasAR ? expTotal - 3 * 2 * loops : 0; // per loop: 3 for non AR events and 3 for non AR 'B' - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, expTotal, expAR); + final int perLoopSI = 2; // per loop: 1 non AR event and 1 for non AR 'B' + final int expSI, expAR; + if( hasAR ) { + expSI = perLoopSI * loops; + expAR = ( keyEvents.size() - expSI*3 ) / 2; // AR: no typed -> 2, SI: typed -> 3 + } else { + expSI = keyEvents.size() / 3; // all typed events + expAR = 0; + } + + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, + expSI /* press-SI */, expSI /* release-SI */, expSI /* typed-SI */, + expAR /* press-AR */, expAR /* release-AR */, 0 /* typed-AR */ ); } if( !hasAR ) { @@ -216,7 +227,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { NEWTKeyUtil.dumpKeyEvents(Arrays.asList(first[i])); System.err.println("Auto-Repeat Loop "+i+" - Tail:"); NEWTKeyUtil.dumpKeyEvents(Arrays.asList(last[i])); - } + } for(int i=0; i missCodes, CodeSeg codeSeg, List keyEvents, boolean verbose) { final int codeCount = codeSeg.max - codeSeg.min + 1; int misses = 0; + int evtIdx = 0; for(int i=0; i KEY_PRESSED ! + final short c = (short) ( codeSeg.min + i ); + final KeyEvent e = (KeyEvent) ( evtIdx < keyEvents.size() ? keyEvents.get(evtIdx) : null ); + if( null == e ) { missCodes.add(new CodeEvent(c, codeSeg.description, e)); misses++; + evtIdx++; + } else { + if( c != e.getKeyCode() ) { + missCodes.add(new CodeEvent(c, codeSeg.description, e)); + misses++; + } + if( KeyEvent.isPrintableKey(c) ) { + evtIdx += 3; // w/ TYPED + } else { + evtIdx += 2; + } } } - final boolean res = 3*codeCount == keyEvents.size() && 0 == missCodes.size(); + final boolean res = evtIdx == keyEvents.size() && 0 == missCodes.size(); if(verbose) { System.err.println("+++ Code Segment "+codeSeg.description+", Misses: "+misses+" / "+codeCount+", events "+keyEvents.size()+", valid "+res); } return res; } - public static void validateKeyEvent(KeyEvent e, int eventType, int modifier, int keyCode) { - if(0 <= keyCode) { - Assert.assertTrue("KeyEvent code mismatch, expected 0x"+Integer.toHexString(keyCode)+", has "+e, keyCode == e.getKeyCode()); - } + public static void validateKeyEvent(KeyEvent e, int eventType, int modifier, int keyCode, char keyChar) { if(0 <= eventType) { Assert.assertTrue("KeyEvent type mismatch, expected 0x"+Integer.toHexString(eventType)+", has "+e, eventType == e.getEventType()); } if(0 <= modifier) { Assert.assertTrue("KeyEvent modifier mismatch, expected 0x"+Integer.toHexString(modifier)+", has "+e, modifier == e.getModifiers()); } + if(0 < keyCode) { + Assert.assertTrue("KeyEvent code mismatch, expected 0x"+Integer.toHexString(keyCode)+", has "+e, keyCode == e.getKeyCode()); + } + if(0 < keyChar) { + Assert.assertTrue("KeyEvent char mismatch, expected 0x"+Integer.toHexString(keyChar)+", has "+e, keyChar == e.getKeyChar()); + } } - public static int getNextKeyEventType(int et) { + @SuppressWarnings("deprecation") + public static short getNextKeyEventType(KeyEvent e) { + final int et = e.getEventType(); switch( et ) { case KeyEvent.EVENT_KEY_PRESSED: return KeyEvent.EVENT_KEY_RELEASED; case KeyEvent.EVENT_KEY_RELEASED: - return KeyEvent.EVENT_KEY_TYPED; + return e.isPrintableKey() && !e.isAutoRepeat() ? KeyEvent.EVENT_KEY_TYPED : KeyEvent.EVENT_KEY_PRESSED; case KeyEvent.EVENT_KEY_TYPED: return KeyEvent.EVENT_KEY_PRESSED; default: - Assert.assertTrue("Invalid event type "+et, false); + Assert.assertTrue("Invalid event "+e, false); return 0; - } + } } public static void validateKeyEventOrder(List keyEvents) { @@ -141,45 +158,68 @@ public class NEWTKeyUtil { eet = KeyEvent.EVENT_KEY_PRESSED; } final int et = e.getEventType(); - Assert.assertEquals("Key event not in proper order", eet, et); - eet = getNextKeyEventType(et); + Assert.assertEquals("Key event not in proper order "+i+"/"+keyEvents.size()+" - event "+e, eet, et); + eet = getNextKeyEventType(e); keyCode2NextEvent.put(e.getKeyCode(), eet); } } /** - * * @param keyAdapter - * @param expTotalCount number of key press/release/types events - * @param expARCount number of key press/release/types Auto-Release events + * @param expPressedCountSI number of single key press events + * @param expReleasedCountSI number of single key release events + * @param expTypedCountSI number of single key types events + * @param expPressedCountAR number of auto-repeat key press events + * @param expReleasedCountAR number of auto-repeat key release events + * @param expTypedCountAR number of auto-repeat key types events */ - public static void validateKeyAdapterStats(NEWTKeyAdapter keyAdapter, int expTotalCount, int expARCount) { - final int keyPressed = keyAdapter.getKeyPressedCount(false); + public static void validateKeyAdapterStats(NEWTKeyAdapter keyAdapter, + int expPressedCountSI, int expReleasedCountSI, int expTypedCountSI, + int expPressedCountAR, int expReleasedCountAR, int expTypedCountAR) { + final int expTotalCountSI = expPressedCountSI + expReleasedCountSI + expTypedCountSI; + final int expTotalCountAR = expPressedCountAR + expReleasedCountAR + expTypedCountAR; + final int expTotalCountALL = expTotalCountSI + expTotalCountAR; + + final int keyPressedALL = keyAdapter.getKeyPressedCount(false); final int keyPressedAR = keyAdapter.getKeyPressedCount(true); - final int keyReleased = keyAdapter.getKeyReleasedCount(false); + final int keyReleasedALL = keyAdapter.getKeyReleasedCount(false); final int keyReleasedAR = keyAdapter.getKeyReleasedCount(true); - final int keyTyped = keyAdapter.getKeyTypedCount(false); + final int keyTypedALL = keyAdapter.getKeyTypedCount(false); final int keyTypedAR = keyAdapter.getKeyTypedCount(true); - final int keyPressedNR = keyPressed-keyPressedAR; - final int keyReleasedNR = keyReleased-keyReleasedAR; - final int keyTypedNR = keyTyped-keyTypedAR; - System.err.println("Total Press "+keyPressed +", Release "+keyReleased +", Typed "+keyTyped); - System.err.println("AutoR Press "+keyPressedAR+", Release "+keyReleasedAR+", Typed "+keyTypedAR); - System.err.println("No AR Press "+keyPressedNR+", Release "+keyReleasedNR+", Typed "+keyTypedNR); + + final int keyPressedSI = keyPressedALL-keyPressedAR; + final int keyReleasedSI = keyReleasedALL-keyReleasedAR; + final int keyTypedSI = keyTypedALL-keyTypedAR; + + final int totalCountALL = keyPressedALL + keyReleasedALL + keyTypedALL; + final int totalCountSI = keyPressedSI + keyReleasedSI + keyTypedSI; + final int totalCountAR = keyPressedAR + keyReleasedAR + keyTypedAR; + + System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI +", Events "+expTotalCountSI); + System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR +", Events "+expTotalCountAR); + + System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+totalCountSI); + System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+totalCountAR); + System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+totalCountALL); + + Assert.assertEquals("Internal Error: totalSI != totalALL - totalAR", totalCountSI, totalCountALL - totalCountAR); + + Assert.assertEquals("Invalid: Has AR Typed events", 0, keyTypedAR); + Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR); + + Assert.assertEquals("Key press count failure (SI)", expPressedCountSI, keyPressedSI); + Assert.assertEquals("Key released count failure (SI)", expReleasedCountSI, keyReleasedSI); + Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI); + + Assert.assertEquals("Key press count failure (AR)", expPressedCountAR, keyPressedAR); + Assert.assertEquals("Key released count failure (AR)", expReleasedCountAR, keyReleasedAR); + + Assert.assertEquals("Key total count failure (SI)", expTotalCountSI, totalCountSI); + Assert.assertEquals("Key total count failure (AR)", expTotalCountAR, totalCountAR); final List keyEvents = keyAdapter.getQueued(); - Assert.assertEquals("Key event count not multiple of 3", 0, keyEvents.size()%3); - Assert.assertEquals("Key event count not 3 * press_release_count", expTotalCount, keyEvents.size()); - Assert.assertEquals("Key press count failure", expTotalCount/3, keyPressed); - Assert.assertEquals("Key press count failure (AR)", expARCount/3, keyPressedAR); - Assert.assertEquals("Key released count failure", expTotalCount/3, keyReleased); - Assert.assertEquals("Key released count failure (AR)", expARCount/3, keyReleasedAR); - Assert.assertEquals("Key typed count failure", expTotalCount/3, keyTyped); - Assert.assertEquals("Key typed count failure (AR)", expARCount/3, keyTypedAR); - // should be true - always, reaching this point - duh! - Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyPressedNR); - Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyReleasedNR); - Assert.assertEquals( ( expTotalCount - expARCount ) / 3, keyTypedNR); - } + Assert.assertEquals("Key total count failure (ALL) w/ list sum ", expTotalCountALL, totalCountALL); + Assert.assertEquals("Key total count failure (ALL) w/ list size ", expTotalCountALL, keyEvents.size()); + } } -- cgit v1.2.3 From 14b278536e6f8de2ee6254796b89bd27d5419b72 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 20 Feb 2013 21:51:40 +0100 Subject: OSX/Java7/CALayer + JAWT: Partially Fix AWT/NEWT CALayer 'out of sight' bug, where our CALayer is moved out of the visible area - same erroneous behavior for GLCanvas and NewtCanvasAWT - sized-frame: Set framesize and validate() it - sized-component: Set component preferred size and call frame.pack() - added workaround 'OffscreenLayerSurface.layoutSurfaceLayer()' to fix CALayer size, which snaps for: - OK initial size before setVisible: sized-frame and sized-component - OK resize w/ sized-frame - OK manual frame resize - Invisible: w/ sized-component after setVisible() ++ - CALayer-Sublayer (GL) has additional retain/release when added/removed to be on safe side. --- make/scripts/tests.sh | 73 ++++++++++++---------- .../classes/javax/media/opengl/awt/GLCanvas.java | 3 + .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 1 + .../macosx/MacOSXWindowSystemInterface-calayer.m | 24 ++++--- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 15 ++++- .../media/nativewindow/OffscreenLayerSurface.java | 15 +++++ .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 12 +++- .../jogamp/nativewindow/macosx/OSXUtil.java | 30 ++++++++- src/nativewindow/native/macosx/OSXmisc.m | 57 ++++++++++++++++- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 14 ++++- .../jogamp/newt/driver/macosx/WindowDriver.java | 2 +- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 3 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 3 +- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 3 +- .../demos/es2/newt/TestGearsES2NewtCanvasSWT.java | 9 +-- .../junit/jogl/demos/es2/swt/TestGearsES2SWT.java | 3 +- 16 files changed, 205 insertions(+), 62 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7a65c736a..b3aa39dfc 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -35,7 +35,7 @@ if [ $MOSX -eq 1 ] ; then echo setup OSX environment vars #export NSZombieEnabled=YES export NSTraceEvents=YES - export OBJC_PRINT_EXCEPTIONS=YES + #export OBJC_PRINT_EXCEPTIONS=YES echo NSZombieEnabled $NSZombieEnabled 2>&1 | tee -a java-run.log echo NSTraceEvents $NSTraceEvents 2>&1 | tee -a java-run.log echo OBJC_PRINT_EXCEPTIONS $OBJC_PRINT_EXCEPTIONS 2>&1 | tee -a java-run.log @@ -135,7 +135,6 @@ function jrun() { #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" #D_ARGS="-Dnewt.debug.MainThread" - #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" @@ -167,8 +166,8 @@ function jrun() { #D_ARGS="-Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" - #D_ARGS="-Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -222,9 +221,13 @@ function jrun() { #X_ARGS="-Dnativewindow.ws.name=jogamp.newt.driver.broadcom.egl $X_ARGS" echo CLASSPATH $CLASSPATH if [ $MOSX_MT -eq 1 ] ; then - X_ARGS="-XstartOnFirstThread $X_ARGS" - if [ $swton -eq 0 ] ; then + if [ $awton -eq 0 -a $swton -eq 0 ] ; then + # No AWT, No SWT -> Preserve Main-Thread + X_ARGS="-XstartOnFirstThread $X_ARGS" C_ARG="com.jogamp.newt.util.MainThread" + elif [ $swton -eq 1 ] ; then + # SWT: Only Launch on Main-Thread + X_ARGS="-XstartOnFirstThread $X_ARGS" fi fi echo @@ -255,6 +258,31 @@ function testawtswt() { jrun 1 1 $* 2>&1 | tee -a java-run.log } +# +# demos (any TK, more user driven tests) +# +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* +#testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* +#testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2SWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* +#testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* + # # core/newt (testnoawt and testawt) # @@ -262,13 +290,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* #testnoawt com.jogamp.newt.opengl.GLWindow $* -#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* @@ -305,6 +326,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove03GLWindowNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -326,13 +350,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* + #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* @@ -373,11 +391,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* @@ -409,21 +422,19 @@ function testawtswt() { # newt.awt (testawt) # #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* + #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* @@ -469,8 +480,6 @@ testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestImmModeSinkES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestES1FixedFunctionPipelineNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* # # Texture / TextureUtils @@ -486,8 +495,6 @@ testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* # # GLSL diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index c9069f9ce..dc4fe955c 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -702,6 +702,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } sendReshape = true; // async if display() doesn't get called below, but avoiding deadlock + if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + jawtWindow.layoutSurfaceLayer(); + } } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 37aca0cd7..9e0174595 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -713,6 +713,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl } } } + backingLayerHost.layoutSurfaceLayer(); } else { lastWidth = drawable.getWidth(); lastHeight = drawable.getHeight(); diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 55c4ad053..b965accab 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -114,6 +114,7 @@ extern GLboolean glIsVertexArray (GLuint array); - (void)dealloc { CGLContextObj cglCtx = [self CGLContextObj]; + DBG_PRINT("MyNSOpenGLContext::dealloc.0 %p (refcnt %d) - CGL-Ctx %p\n", self, (int)[self retainCount], cglCtx); [self clearDrawable]; if( NULL != cglCtx ) { @@ -537,7 +538,6 @@ static const GLfloat gl_verts[] = { { DBG_PRINT("MyNSOpenGLLayer::dealloc.0 %p (refcnt %d)\n", self, (int)[self retainCount]); // NSLog(@"MyNSOpenGLLayer::dealloc: %@",[NSThread callStackSymbols]); - [self disableAnimation]; pthread_mutex_lock(&renderLock); [self deallocPBuffer]; @@ -555,13 +555,23 @@ static const GLfloat gl_verts[] = { - (void)resizeWithOldSuperlayerSize:(CGSize)size { - CGRect lRectS = [[self superlayer] bounds]; - - DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d, bounds: %lfx%lf -> %lf/%lf %lfx%lf (refcnt %d)\n", - self, texWidth, texHeight, size.width, size.height, lRectS.origin.x, lRectS.origin.y, lRectS.size.width, lRectS.size.height, (int)[self retainCount]); + CALayer * superL = [self superlayer]; + CGRect lRectSFrame = [superL frame]; + + DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d -> size: %lfx%lf ; Super Frame[%lf/%lf %lfx%lf] (refcnt %d)\n", + self, texWidth, texHeight, size.width, size.height, + lRectSFrame.origin.x, lRectSFrame.origin.y, lRectSFrame.size.width, lRectSFrame.size.height, + (int)[self retainCount]); + + // With Java7 our root CALayer's frame gets off-limit -> force 0/0 origin! + if( lRectSFrame.origin.x!=0 || lRectSFrame.origin.y!=0 ) { + lRectSFrame.origin.x = 0; + lRectSFrame.origin.y = 0; + [superL setPosition: lRectSFrame.origin]; + } - newTexWidth = lRectS.size.width; - newTexHeight = lRectS.size.height; + newTexWidth = lRectSFrame.size.width; + newTexHeight = lRectSFrame.size.height; shallDraw = [self isGLSourceValid]; SYNC_PRINT("", newTexWidth, newTexHeight); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 007a917a6..d65f8c231 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -130,7 +130,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(changed) { if(DEBUG) { System.err.println("JAWTWindow.updateBounds: "+bounds+" -> "+jb); - Thread.dumpStack(); + // Thread.dumpStack(); } bounds.setX(jawtBounds.getX()); bounds.setY(jawtBounds.getY()); @@ -205,7 +205,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } try { if(DEBUG) { - System.err.println("JAWTWindow.attachSurfaceHandle(): "+toHexString(layerHandle) + ", bounds "+bounds); + System.err.println("JAWTWindow.attachSurfaceHandle: "+toHexString(layerHandle) + ", bounds "+bounds); } attachSurfaceLayerImpl(layerHandle); offscreenSurfaceLayer = layerHandle; @@ -215,6 +215,17 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract void attachSurfaceLayerImpl(final long layerHandle); + @Override + public void layoutSurfaceLayer() throws NativeWindowException { + if( !isOffscreenLayerSurfaceEnabled() ) { + throw new NativeWindowException("Not an offscreen layer surface"); + } + if( 0 != offscreenSurfaceLayer) { + layoutSurfaceLayerImpl(); + } + } + protected void layoutSurfaceLayerImpl() {} + @Override public final void detachSurfaceLayer() throws NativeWindowException { if( !isOffscreenLayerSurfaceEnabled() ) { diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index ba60a7f38..4885d5a4c 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -46,6 +46,21 @@ public interface OffscreenLayerSurface { */ public void attachSurfaceLayer(final long layerHandle) throws NativeWindowException; + /** + * Layout the offscreen layer according to the implementing class's constraints. + *

    + * This method allows triggering a re-layout of the offscreen surface + * in case the implementation requires it. + *

    + *

    + * Call this method if any parent or ancestor's layout has been changed, + * which could affects the layout of this surface. + *

    + * @see #isOffscreenLayerSurfaceEnabled() + * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false + */ + public void layoutSurfaceLayer() throws NativeWindowException; + /** * Detaches a previously attached offscreen layer from this offscreen layer surface. * @see #attachSurfaceLayer(long) diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 9b06cce1a..b25836d3c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -118,10 +118,20 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { OSXUtil.AddCASublayer(rootSurfaceLayerHandle, layerHandle); } + protected void layoutSurfaceLayerImpl() { + final long osl = getAttachedSurfaceLayer(); + final int w = getWidth(); + final int h = getHeight(); + if(DEBUG) { + System.err.println("JAWTWindow.fixSurfaceLayerLayout: "+toHexString(osl) + ", bounds "+bounds+", "+w+"x"+h); + } + OSXUtil.FixCALayerPosition(rootSurfaceLayerHandle, osl, w, h); + } + protected void detachSurfaceLayerImpl(final long layerHandle) { OSXUtil.RemoveCASublayer(rootSurfaceLayerHandle, layerHandle); } - + @Override public final long getWindowHandle() { return windowHandle; diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index d85d1a84b..5ff451cc0 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -149,7 +149,7 @@ public class OSXUtil implements ToolkitProperties { } /** - * Attach a sub CALayer to the root CALayer on the main-thread. + * Attach a sub CALayer to the root CALayer on the main-thread w/ blocking. *

    * Method will trigger a display * call to the CALayer hierarchy to enforce resource creation if required, e.g. an NSOpenGLContext. @@ -173,7 +173,30 @@ public class OSXUtil implements ToolkitProperties { } /** - * Detach a sub CALayer from the root CALayer on the main-thread. + * Fix root and sub CALayer position to 0/0 on the main-thread w/o blocking. + *

    + * For an unknown reason, on OSX/Java7 our root CALayer's frame position gets corrupted + * and is moved out of 'sight' .. or oddly half way to the upper right corner. + *

    + * + * @param rootCALayer the root surface layer, maybe null. + * @param subCALayer the client surface layer, maybe null. + * @param width the expected width + * @param height the expected height + */ + public static void FixCALayerPosition(final long rootCALayer, final long subCALayer, final int width, final int height) { + if( 0==rootCALayer && 0==subCALayer ) { + return; + } + RunOnMainThread(false, new Runnable() { + public void run() { + FixCALayerPosition0(rootCALayer, subCALayer, width, height); + } + }); + } + + /** + * Detach a sub CALayer from the root CALayer on the main-thread w/ blocking. */ public static void RemoveCASublayer(final long rootCALayer, final long subCALayer) { if(0==rootCALayer || 0==subCALayer) { @@ -186,7 +209,7 @@ public class OSXUtil implements ToolkitProperties { } /** - * Destroy a CALayer on the main-thread. + * Destroy a CALayer on the main-thread w/ blocking. * @see #CreateCALayer(int, int, int, int) */ public static void DestroyCALayer(final long caLayer) { @@ -323,6 +346,7 @@ public class OSXUtil implements ToolkitProperties { private static native long GetNSWindow0(long nsView); private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); + private static native void FixCALayerPosition0(long rootCALayer, long subCALayer, int width, int height); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); private static native void RunOnMainThread0(Runnable runnable); diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 4c07b4df7..28e63e875 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -429,11 +429,13 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); + [subLayer retain]; // Pairs w/ RemoveCASublayer + [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; CGRect lRectRoot = [rootLayer frame]; - DBG_PRINT("CALayer::AddCASublayer0.0: Origin %p frame0: %lf/%lf %lfx%lf\n", + DBG_PRINT("CALayer::AddCASublayer0.0: Origin %p frame0: %lf/%lf %lfx%lf\n", rootLayer, lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height); if(lRectRoot.origin.x!=0 || lRectRoot.origin.y!=0) { lRectRoot.origin.x = 0; @@ -474,6 +476,57 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); } +/* + * Class: Java_jogamp_nativewindow_macosx_OSXUtil + * Method: FixCALayerPosition0 + * Signature: (JJII)V + */ +JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerPosition0 + (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); + CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + + if( NULL != rootLayer ) { + CGRect lRect = [rootLayer frame]; + DBG_PRINT("CALayer::FixCALayerPosition0.0: Root Origin %p exp 0/0 %dx%d frame0: %lf/%lf %lfx%lf\n", + rootLayer, width, height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) { + lRect.origin.x = 0; + lRect.origin.y = 0; + lRect.size.width = width; + lRect.size.height = height; + [rootLayer setFrame: lRect]; + DBG_PRINT("CALayer::FixCALayerPosition0.1: Root Origin %p frame*: %lf/%lf %lfx%lf\n", + rootLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + } + } + if( NULL != subLayer ) { + CGRect lRect = [subLayer frame]; + DBG_PRINT("CALayer::FixCALayerPosition0.0: SubL %p exp 0/0 %dx%d frame0: %lf/%lf %lfx%lf\n", + subLayer, width, height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) { + lRect.origin.x = 0; + lRect.origin.y = 0; + lRect.size.width = width; + lRect.size.height = height; + [subLayer setFrame: lRect]; + DBG_PRINT("CALayer::FixCALayerPosition0.1: SubL Origin %p frame*: %lf/%lf %lfx%lf\n", + subLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + } + } + + [CATransaction commit]; + + [pool release]; + DBG_PRINT("CALayer::FixCALayerPosition0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n", + rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); +} + /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: RemoveCASublayer0 @@ -495,7 +548,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_RemoveCASublayer0 [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; [subLayer removeFromSuperlayer]; - // [subLayer release] is called explicitly, e.g. via CGL.releaseNSOpenGLLayer(..) (MyNSOpenGLLayer::releaseLayer) + [subLayer release]; // Pairs w/ AddCASublayer [CATransaction commit]; diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 195f8af8c..524917780 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -391,6 +391,18 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto reparentWindow(true, cont); } + @SuppressWarnings("deprecation") + @Override + public void reshape(int x, int y, int width, int height) { + super.reshape(x, y, width, height); + if(DEBUG) { + System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); + } + if(null != jawtWindow && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + jawtWindow.layoutSurfaceLayer(); + } + } + @Override public void removeNotify() { java.awt.Container cont = AWTMisc.getContainer(this); @@ -459,7 +471,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // force this AWT Canvas to be focus-able, // since this it is completely covered by the newtChild (z-order). - setFocusable(true); + setFocusable(true); } else { configureNewtChild(false); newtChild.setVisible(false); diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 08c7a14c2..f47ca327d 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -227,7 +227,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } // else offscreen size is realized via recreation // no native event (fullscreen, some reparenting) positionChanged(true, x, y); - sizeChanged(true, width, height, false); // incl. validation (incl. repositioning) + sizeChanged(true, width, height, false); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 != ( FLAG_IS_VISIBLE & flags) ) { if( !isOffscreenInstance ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index 8d1ad57b4..447c6b94c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -77,13 +77,12 @@ public class TestGearsES2AWT extends UITestCase { static int swapInterval = 1; static boolean exclusiveContext = false; static Thread awtEDT; - static Dimension rwsize; + static Dimension rwsize = null; @BeforeClass public static void initClass() { width = 640; height = 480; - rwsize = null; try { EventQueue.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 52ce425a8..47891a8df 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -71,7 +71,7 @@ import org.junit.Test; public class TestGearsES2NEWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; - static DimensionImmutable wsize, rwsize; + static DimensionImmutable wsize, rwsize=null; static long duration = 500; // ms static boolean opaque = true; @@ -96,7 +96,6 @@ public class TestGearsES2NEWT extends UITestCase { public static void initClass() { if(null == wsize) { wsize = new Dimension(640, 480); - rwsize = null; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index 035ed624a..f98cb240b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -78,7 +78,7 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; - static DimensionImmutable wsize, rwsize; + static DimensionImmutable wsize, rwsize = null; static long duration = 500; // ms static boolean opaque = true; @@ -99,7 +99,6 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { public static void initClass() { if(null == wsize) { wsize = new Dimension(640, 480); - rwsize = null; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java index 112a1282d..cb2cf064f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java @@ -73,7 +73,7 @@ import org.junit.Test; public class TestGearsES2NewtCanvasSWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; - static DimensionImmutable wsize, rwsize; + static DimensionImmutable wsize, rwsize = null; static long duration = 500; // ms static boolean opaque = true; @@ -93,7 +93,6 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { public static void initClass() { if(null == wsize) { wsize = new Dimension(640, 480); - rwsize = new Dimension(-1, -1); } } @@ -219,7 +218,7 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - if( 0 < rwsize.getWidth() && 0 < rwsize.getHeight() ) { + if( null != rwsize ) { for(int i=0; i<50; i++) { // 500 ms dispatched delay if( !display.readAndDispatch() ) { // blocks on linux .. display.sleep(); @@ -349,7 +348,9 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { } } wsize = new Dimension(w, h); - rwsize = new Dimension(rw, rh); + if( 0 < rw && 0 < rh ) { + rwsize = new Dimension(rw, rh); + } if(usePos) { wpos = new Point(x, y); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java index 45bd3bb39..08e4ac26a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/swt/TestGearsES2SWT.java @@ -65,7 +65,7 @@ import org.junit.Test; public class TestGearsES2SWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; - static DimensionImmutable wsize, rwsize; + static DimensionImmutable wsize, rwsize=null; static long duration = 500; // ms static boolean opaque = true; @@ -85,7 +85,6 @@ public class TestGearsES2SWT extends UITestCase { public static void initClass() { if(null == wsize) { wsize = new Dimension(640, 480); - rwsize = null; } } -- cgit v1.2.3 From cbd8e33f1e19cf0c061c371af6930aba7c36b84f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 22 Feb 2013 04:01:44 +0100 Subject: Fix CALayer pos/size and animation. - Fix CALayer animation: - All CALayer animations are set to nil via overriding 'actionForKey' - Fix CALayer pos/size bug: - Fix root and sub CALayer position to 0/0 and size on the main-thread w/o blocking. - If the sub CALayer implements the Objective-C NativeWindow protocol NWDedicatedSize (e.g. JOGL's MyNSOpenGLLayer), the dedicated size is passed to the layer, which propagates it appropriately. - On OSX/Java7 our root CALayer's frame position and size gets corrupted by its NSView, hence we have created the NWDedicatedSize protocol. --- make/build-jogl.xml | 14 +- make/build-nativewindow.xml | 3 +- make/scripts/tests.sh | 21 +-- .../macosx/MacOSXWindowSystemInterface-calayer.m | 197 ++++++++++++++------- .../native/macosx/MacOSXWindowSystemInterface.m | 1 - .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 2 +- .../jogamp/nativewindow/macosx/OSXUtil.java | 16 +- .../native/macosx/NativeWindowProtocols.h | 34 ++++ src/nativewindow/native/macosx/OSXmisc.m | 33 ++-- 9 files changed, 219 insertions(+), 102 deletions(-) create mode 100644 src/nativewindow/native/macosx/NativeWindowProtocols.h (limited to 'make/scripts') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 379758392..c481eb0f5 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -224,8 +224,9 @@ - - + + + @@ -1439,12 +1440,13 @@ + - - - + + + - + diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index a8408eaa7..d7ef73a46 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -691,8 +691,9 @@ - + + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b3aa39dfc..7a71932ca 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -171,7 +171,8 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" - #D_ARGS="-Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -261,27 +262,27 @@ function testawtswt() { # # demos (any TK, more user driven tests) # +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* -#testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2SWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* +#testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index b965accab..2cf74380c 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -1,6 +1,7 @@ #import "MacOSXWindowSystemInterface.h" #import #import +#import "NativeWindowProtocols.h" #include "timespec.h" #import @@ -126,7 +127,7 @@ extern GLboolean glIsVertexArray (GLuint array); @end -@interface MyNSOpenGLLayer: NSOpenGLLayer +@interface MyNSOpenGLLayer: NSOpenGLLayer { @private GLfloat gl_texCoords[8]; @@ -143,8 +144,8 @@ extern GLboolean glIsVertexArray (GLuint array); NSOpenGLPixelFormat* parentPixelFmt; int texWidth; int texHeight; - int newTexWidth; - int newTexHeight; + int dedicatedWidth; + int dedicatedHeight; volatile NSOpenGLPixelBuffer* pbuffer; volatile GLuint textureID; volatile NSOpenGLPixelBuffer* newPBuffer; @@ -173,8 +174,17 @@ extern GLboolean glIsVertexArray (GLuint array); texWidth: (int) texWidth texHeight: (int) texHeight; +- (void)releaseLayer; +- (void)deallocPBuffer; +- (void)disableAnimation; +- (void)pauseAnimation:(Bool)pause; +- (void)setSwapInterval:(int)interval; +- (void)tick; +- (void)waitUntilRenderSignal: (long) to_micros; +- (Bool)isGLSourceValid; + - (void) setGLEnabled: (Bool) enable; -- (Bool) validateTexSizeWithNewSize; +- (Bool) validateTexSizeWithDedicatedSize; - (Bool) validateTexSize: (int) _texWidth texHeight: (int) _texHeight; - (void) setTextureID: (int) _texID; @@ -182,21 +192,22 @@ extern GLboolean glIsVertexArray (GLuint array); - (void) setNewPBuffer: (NSOpenGLPixelBuffer*)p; - (void) applyNewPBuffer; +- (void)setDedicatedSize:(CGSize)size; // @NWDedicatedSize +- (CGRect)fixMyFrame; +- (CGRect)fixSuperPosition; +- (id)actionForKey:(NSString *)key ; - (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask; - (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat; -- (void)disableAnimation; -- (void)pauseAnimation:(Bool)pause; -- (void)deallocPBuffer; -- (void)releaseLayer; +- (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat + forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp; +- (void)drawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat + forLayerTime:(CFTimeInterval)timeInterval displayTime:(const CVTimeStamp *)timeStamp; + #ifdef DBG_LIFECYCLE - (id)retain; - (oneway void)release; #endif - (void)dealloc; -- (void)setSwapInterval:(int)interval; -- (void)tick; -- (void)waitUntilRenderSignal: (long) to_micros; -- (Bool)isGLSourceValid; @end @@ -270,9 +281,9 @@ static const GLfloat gl_verts[] = { timespec_now(&lastWaitTime); shallDraw = NO; isGLEnabled = YES; - newTexWidth = _texWidth; - newTexHeight = _texHeight; - [self validateTexSizeWithNewSize]; + dedicatedWidth = _texWidth; + dedicatedHeight = _texHeight; + [self validateTexSizeWithDedicatedSize]; [self setTextureID: texID]; newPBuffer = NULL; @@ -345,9 +356,9 @@ static const GLfloat gl_verts[] = { isGLEnabled = enable; } -- (Bool) validateTexSizeWithNewSize +- (Bool) validateTexSizeWithDedicatedSize { - return [self validateTexSize: newTexWidth texHeight: newTexHeight]; + return [self validateTexSize: dedicatedWidth texHeight: dedicatedHeight]; } - (Bool) validateTexSize: (int) _texWidth texHeight: (int) _texHeight @@ -355,12 +366,14 @@ static const GLfloat gl_verts[] = { if(_texHeight != texHeight || _texWidth != texWidth) { texWidth = _texWidth; texHeight = _texHeight; + /** CGRect lRect = [self bounds]; lRect.origin.x = 0; lRect.origin.y = 0; lRect.size.width = texWidth; lRect.size.height = texHeight; - [self setFrame: lRect]; + [self setFrame: lRect]; */ + CGRect lRect = [self fixMyFrame]; GLfloat texCoordWidth, texCoordHeight; if(NULL != pbuffer) { @@ -382,8 +395,14 @@ static const GLfloat gl_verts[] = { gl_texCoords[5] = texCoordHeight; gl_texCoords[4] = texCoordWidth; gl_texCoords[6] = texCoordWidth; +#ifdef VERBOSE_ON + DBG_PRINT("MyNSOpenGLLayer::validateTexSize %p -> tex %dx%d, bounds: %lf/%lf %lfx%lf\n", + self, texWidth, texHeight, + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); +#endif return YES; } else { + [self fixMyFrame]; return NO; } } @@ -450,34 +469,6 @@ static const GLfloat gl_verts[] = { } } -- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask -{ - DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask: %p (refcnt %d) - parent-pfmt %p -> new-pfmt %p\n", - self, (int)[self retainCount], parentPixelFmt, parentPixelFmt); - // We simply take over ownership of parent PixelFormat .. - return parentPixelFmt; -} - -- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat -{ - DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.0: %p (refcnt %d) - pfmt %p, parent %p, DisplayLink %p\n", - self, (int)[self retainCount], pixelFormat, parentCtx, displayLink); - // NSLog(@"MyNSOpenGLLayer::openGLContextForPixelFormat: %@",[NSThread callStackSymbols]); - myCtx = [[MyNSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; -#ifndef HAS_CADisplayLink - if(NULL != displayLink) { - CVReturn cvres; - DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.1: setup DisplayLink %p\n", displayLink); - cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [myCtx CGLContextObj], [pixelFormat CGLPixelFormatObj]); - if(kCVReturnSuccess != cvres) { - DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); - } - } -#endif - DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.X: new-ctx %p\n", myCtx); - return myCtx; -} - - (void)disableAnimation { DBG_PRINT("MyNSOpenGLLayer::disableAnimation.0: %p (refcnt %d) - displayLink %p\n", self, (int)[self retainCount], displayLink); @@ -553,29 +544,107 @@ static const GLfloat gl_verts[] = { return NULL != pbuffer || NULL != newPBuffer || 0 != textureID ; } -- (void)resizeWithOldSuperlayerSize:(CGSize)size - { - CALayer * superL = [self superlayer]; - CGRect lRectSFrame = [superL frame]; +// @NWDedicatedSize +- (void)setDedicatedSize:(CGSize)size { + DBG_PRINT("MyNSOpenGLLayer::setDedicatedSize: %p, texSize %dx%d <- %lfx%lf\n", + self, texWidth, texHeight, size.width, size.height); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + + dedicatedWidth = size.width; + dedicatedHeight = size.height; + + CGRect rect = CGRectMake(0, 0, dedicatedWidth, dedicatedHeight); + [self setFrame: rect]; - DBG_PRINT("MyNSOpenGLLayer::resizeWithOldSuperlayerSize: %p, texSize %dx%d -> size: %lfx%lf ; Super Frame[%lf/%lf %lfx%lf] (refcnt %d)\n", - self, texWidth, texHeight, size.width, size.height, - lRectSFrame.origin.x, lRectSFrame.origin.y, lRectSFrame.size.width, lRectSFrame.size.height, - (int)[self retainCount]); + [CATransaction commit]; +} + +- (void) setFrame:(CGRect) frame { + CGRect rect = CGRectMake(0, 0, dedicatedWidth, dedicatedHeight); + [super setFrame: rect]; +} + +- (CGRect)fixMyFrame +{ + CGRect lRect = [self frame]; + + // With Java7 our root CALayer's frame gets off-limit -> force 0/0 origin! + if( lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=texWidth || lRect.size.height!=texHeight) { + DBG_PRINT("MyNSOpenGLLayer::fixMyFrame: %p, 0/0 texSize %dx%d -> Frame[%lf/%lf %lfx%lf]\n", + self, texWidth, texHeight, + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + + lRect.origin.x = 0; + lRect.origin.y = 0; + lRect.size.width=texWidth; + lRect.size.height=texHeight; + [self setFrame: lRect]; + + [CATransaction commit]; + } + return lRect; +} + +- (CGRect)fixSuperPosition +{ + CALayer * superL = [self superlayer]; + CGRect lRect = [superL frame]; // With Java7 our root CALayer's frame gets off-limit -> force 0/0 origin! - if( lRectSFrame.origin.x!=0 || lRectSFrame.origin.y!=0 ) { - lRectSFrame.origin.x = 0; - lRectSFrame.origin.y = 0; - [superL setPosition: lRectSFrame.origin]; + if( lRect.origin.x!=0 || lRect.origin.y!=0 ) { + DBG_PRINT("MyNSOpenGLLayer::fixSuperPosition: %p, 0/0 -> Super Frame[%lf/%lf %lfx%lf]\n", + self, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + + lRect.origin.x = 0; + lRect.origin.y = 0; + [superL setPosition: lRect.origin]; + + [CATransaction commit]; } + return lRect; +} + +- (id)actionForKey:(NSString *)key +{ + DBG_PRINT("MyNSOpenGLLayer::actionForKey.0 %p key %s -> NIL\n", self, [key UTF8String]); + return nil; + // return [super actionForKey: key]; +} - newTexWidth = lRectSFrame.size.width; - newTexHeight = lRectSFrame.size.height; - shallDraw = [self isGLSourceValid]; - SYNC_PRINT("", newTexWidth, newTexHeight); +- (NSOpenGLPixelFormat *)openGLPixelFormatForDisplayMask:(uint32_t)mask +{ + DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask: %p (refcnt %d) - parent-pfmt %p -> new-pfmt %p\n", + self, (int)[self retainCount], parentPixelFmt, parentPixelFmt); + // We simply take over ownership of parent PixelFormat .. + return parentPixelFmt; +} - [super resizeWithOldSuperlayerSize: size]; +- (NSOpenGLContext *)openGLContextForPixelFormat:(NSOpenGLPixelFormat *)pixelFormat +{ + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.0: %p (refcnt %d) - pfmt %p, parent %p, DisplayLink %p\n", + self, (int)[self retainCount], pixelFormat, parentCtx, displayLink); + // NSLog(@"MyNSOpenGLLayer::openGLContextForPixelFormat: %@",[NSThread callStackSymbols]); + myCtx = [[MyNSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:parentCtx]; +#ifndef HAS_CADisplayLink + if(NULL != displayLink) { + CVReturn cvres; + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.1: setup DisplayLink %p\n", displayLink); + cvres = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(displayLink, [myCtx CGLContextObj], [pixelFormat CGLPixelFormatObj]); + if(kCVReturnSuccess != cvres) { + DBG_PRINT("MyNSOpenGLLayer::init %p, CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext failed: %d\n", self, cvres); + } + } +#endif + DBG_PRINT("MyNSOpenGLLayer::openGLContextForPixelFormat.X: new-ctx %p\n", myCtx); + return myCtx; } - (BOOL)canDrawInOpenGLContext:(NSOpenGLContext *)context pixelFormat:(NSOpenGLPixelFormat *)pixelFormat @@ -601,7 +670,7 @@ static const GLfloat gl_verts[] = { GLenum textureTarget; - Bool texSizeChanged = [self validateTexSizeWithNewSize]; + Bool texSizeChanged = [self validateTexSizeWithDedicatedSize]; if( NULL != pbuffer ) { if( texSizeChanged && 0 != textureID ) { diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index e8925f8e8..f8faeb8d0 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -575,7 +575,6 @@ void setContextView(NSOpenGLContext* ctx, NSView* view) { [ctx setView:view]; } [pool release]; - return ctx; } Bool makeCurrentContext(NSOpenGLContext* ctx) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index b25836d3c..3ec54ca78 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -125,7 +125,7 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { if(DEBUG) { System.err.println("JAWTWindow.fixSurfaceLayerLayout: "+toHexString(osl) + ", bounds "+bounds+", "+w+"x"+h); } - OSXUtil.FixCALayerPosition(rootSurfaceLayerHandle, osl, w, h); + OSXUtil.FixCALayerLayout(rootSurfaceLayerHandle, osl, w, h); } protected void detachSurfaceLayerImpl(final long layerHandle) { diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index 5ff451cc0..aa44e2d64 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -173,10 +173,14 @@ public class OSXUtil implements ToolkitProperties { } /** - * Fix root and sub CALayer position to 0/0 on the main-thread w/o blocking. + * Fix root and sub CALayer position to 0/0 and size on the main-thread w/o blocking. *

    - * For an unknown reason, on OSX/Java7 our root CALayer's frame position gets corrupted - * and is moved out of 'sight' .. or oddly half way to the upper right corner. + * If the sub CALayer implements the Objective-C NativeWindow protocol NWDedicatedSize (e.g. JOGL's MyNSOpenGLLayer), + * the dedicated size is passed to the layer, which propagates it appropriately. + *

    + *

    + * On OSX/Java7 our root CALayer's frame position and size gets corrupted by its NSView, + * hence we have created the NWDedicatedSize protocol. *

    * * @param rootCALayer the root surface layer, maybe null. @@ -184,13 +188,13 @@ public class OSXUtil implements ToolkitProperties { * @param width the expected width * @param height the expected height */ - public static void FixCALayerPosition(final long rootCALayer, final long subCALayer, final int width, final int height) { + public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final int width, final int height) { if( 0==rootCALayer && 0==subCALayer ) { return; } RunOnMainThread(false, new Runnable() { public void run() { - FixCALayerPosition0(rootCALayer, subCALayer, width, height); + FixCALayerLayout0(rootCALayer, subCALayer, width, height); } }); } @@ -346,7 +350,7 @@ public class OSXUtil implements ToolkitProperties { private static native long GetNSWindow0(long nsView); private static native long CreateCALayer0(int x, int y, int width, int height); private static native void AddCASublayer0(long rootCALayer, long subCALayer); - private static native void FixCALayerPosition0(long rootCALayer, long subCALayer, int width, int height); + private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int width, int height); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); private static native void RunOnMainThread0(Runnable runnable); diff --git a/src/nativewindow/native/macosx/NativeWindowProtocols.h b/src/nativewindow/native/macosx/NativeWindowProtocols.h new file mode 100644 index 000000000..b91a50dfd --- /dev/null +++ b/src/nativewindow/native/macosx/NativeWindowProtocols.h @@ -0,0 +1,34 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#import + +@protocol NWDedicatedSize +- (void)setDedicatedSize:(CGSize)size; +@end + diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 28e63e875..c74d6cc58 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -33,6 +33,7 @@ #include #include #import +#import "NativeWindowProtocols.h" #include "NativewindowCommon.h" #include "jogamp_nativewindow_macosx_OSXUtil.h" @@ -335,6 +336,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 - (oneway void)release; - (void)dealloc; #endif +- (id)actionForKey:(NSString *)key ; @end @@ -378,6 +380,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 #endif +- (id)actionForKey:(NSString *)key +{ + DBG_PRINT("MyCALayer::actionForKey.0 %p key %s -> NIL\n", self, [key UTF8String]); + return nil; + // return [super actionForKey: key]; +} @end @@ -478,10 +486,10 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil - * Method: FixCALayerPosition0 + * Method: FixCALayerLayout0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerPosition0 +JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerLayout0 (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -493,38 +501,37 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerPositio if( NULL != rootLayer ) { CGRect lRect = [rootLayer frame]; - DBG_PRINT("CALayer::FixCALayerPosition0.0: Root Origin %p exp 0/0 %dx%d frame0: %lf/%lf %lfx%lf\n", - rootLayer, width, height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) { + DBG_PRINT("CALayer::FixCALayerLayout0.0: Root %p exp 0/0 %dx%d -> frame0: %lf/%lf %lfx%lf\n", + rootLayer, (int)width, (int)height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); lRect.origin.x = 0; lRect.origin.y = 0; lRect.size.width = width; lRect.size.height = height; [rootLayer setFrame: lRect]; - DBG_PRINT("CALayer::FixCALayerPosition0.1: Root Origin %p frame*: %lf/%lf %lfx%lf\n", - rootLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); } } if( NULL != subLayer ) { CGRect lRect = [subLayer frame]; - DBG_PRINT("CALayer::FixCALayerPosition0.0: SubL %p exp 0/0 %dx%d frame0: %lf/%lf %lfx%lf\n", - subLayer, width, height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); if(lRect.origin.x!=0 || lRect.origin.y!=0 || lRect.size.width!=width || lRect.size.height!=height) { + DBG_PRINT("CALayer::FixCALayerLayout0.0: SubL %p exp 0/0 %dx%d -> frame0: %lf/%lf %lfx%lf\n", + subLayer, (int)width, (int)height, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); lRect.origin.x = 0; lRect.origin.y = 0; lRect.size.width = width; lRect.size.height = height; - [subLayer setFrame: lRect]; - DBG_PRINT("CALayer::FixCALayerPosition0.1: SubL Origin %p frame*: %lf/%lf %lfx%lf\n", - subLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + if( [subLayer conformsToProtocol:@protocol(NWDedicatedSize)] ) { + CALayer * subLayerDS = (CALayer *) subLayer; + [subLayerDS setDedicatedSize: lRect.size]; + } else { + [subLayer setFrame: lRect]; + } } } [CATransaction commit]; [pool release]; - DBG_PRINT("CALayer::FixCALayerPosition0.X: root %p (refcnt %d) .sub %p (refcnt %d)\n", - rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount]); } /* -- cgit v1.2.3 From 808a9a27a8c1c9e0a6701a8dd81d51f8daa8129d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Feb 2013 00:39:28 +0100 Subject: Fix NEWT/AWT WindowClosing Unit Tests ; Review/Cleanup NEWT WindowClosing mechanism Due to a NEWT WindowClosing event regression cause by NewtCanvasAWT changes a review of our WindowClosing event mechanism was required. Important cleanups are marked w/ '(*)' below. I would have preferred to change the 'WindowListener.windowDestroyNotify(WindowEvent)' method to pass a WindowCloseEvent object exposing more information like toolkit or programmatic destruction and passing whether a 'closing' or 'nop' action will be performed based on the WindowClosingMode. For now I postponed this idea .. since it would change the API again, but may reconsider it after merging the Android 'closing' patch. - InputEvent.consumedTag -> NEWTEvent.consumedTag - Window - (*) Promote setWindowDestroyNotifyAction(Runnable) to public, former WindowImpl.setHandleDestroyNotify(boolean). Using a Runnable action for WindowImpl.windowDestroyNotify(boolean) allows a setting defined alternative for destroy() and gets rid of [ab]using WindowListener.windowDestroyNotify(WindowEvent) for lifecycle actions. Used in: - GLWindow - GLAutoDrawableDelegate impl. - WindowImpl - Respect NEWTEvent.consumedTag for WindowEvents as well - (*) Impl. setHandleDestroyNotify(boolean) (see above) - (*) destroy() simply sends out pre- and post- destruction Window events, where windowDestroyNotify(boolean) sends out the pre-destruction event if NOP. - (*) windowDestroyNotify(boolean) is public now, allowing other impl. details to follow proper destruction using handleDestroyNotify Runnable (-> NewtCanvasAWT). - AWTWindowClosingProtocol: - addClosingListenerOneShot() -> addClosingListener() - calling addClosingListener() at addNotify() - calling removeClosingListener() at removeNotify() - AWTWindowClosingProtocol ctor taking NOP runnable, allowing to send WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY at WindowClosingMode.DO_NOTHING_ON_CLOSE - add/remove listener on AWT-EDT - AWTWindowAdapter - Add 'removeWindowClosingFrom(..)', allowing to remove window closing event fwd. - Also fwd windowClosed in window closing fwd'ing. - NewtCanvasAWT - (*) Utilize AWTWindowClosingProtocol NOP runnable (see above) to fwd closing-NOP event to NEWT - (*) Unify remove/destroy code in destroyImpl(..) - !removeNotify -> destroy NEWT child programatic or as toolkit event - removeNotify || windowClosing -> destroy jawtWindow - (*) Remove AWTWindowAdapter/AWTParentWindowAdapter's windowClosingListener, since we utilize AWTWindowClosingProtocol - DisplayImpl - Adding 'final void dispatchMessage(final NEWTEvent event)' allowing to remove the NEWTEventTask wrapping for no reason in enqueueEvent(..) if on EDT and waiting. --- make/scripts/tests.sh | 5 +- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 6 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 6 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 5 +- .../nativewindow/awt/AWTWindowClosingProtocol.java | 85 ++++++----- .../javax/media/nativewindow/NativeWindow.java | 3 +- .../media/nativewindow/WindowClosingProtocol.java | 4 + src/newt/classes/com/jogamp/newt/Window.java | 36 ++++- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 83 ++++++----- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 4 +- .../classes/com/jogamp/newt/event/InputEvent.java | 5 - .../classes/com/jogamp/newt/event/NEWTEvent.java | 6 + .../com/jogamp/newt/event/WindowListener.java | 5 +- .../com/jogamp/newt/event/awt/AWTAdapter.java | 7 +- .../jogamp/newt/event/awt/AWTWindowAdapter.java | 20 ++- .../classes/com/jogamp/newt/opengl/GLWindow.java | 14 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 26 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 72 ++++++---- .../newt/awt/event/AWTParentWindowAdapter.java | 4 +- .../jogamp/newt/driver/awt/WindowDriver.java | 5 +- .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 160 +++++++++++++++++++++ ...estGLAutoDrawableDelegateOnOffscrnCapsNEWT.java | 11 +- .../acore/TestGLContextDrawableSwitch01NEWT.java | 9 +- .../acore/TestGLContextDrawableSwitch11NEWT.java | 9 +- .../jogl/acore/TestSharedContextNewtAWTBug523.java | 5 +- .../opengl/test/junit/newt/TestCloseNewtAWT.java | 7 +- .../junit/newt/TestWindowClosingProtocol01AWT.java | 24 ++-- .../newt/TestWindowClosingProtocol02NEWT.java | 12 +- .../newt/TestWindowClosingProtocol03NewtAWT.java | 41 ++++-- .../opengl/test/junit/util/AWTRobotUtil.java | 83 +++++++---- 30 files changed, 539 insertions(+), 223 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7a71932ca..7a43fd3da 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -266,7 +266,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* @@ -330,6 +330,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -437,7 +438,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT -#testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* @@ -448,6 +448,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT +#testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java index 206331ac0..0f0f03ac4 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -51,12 +51,12 @@ import jogamp.opengl.GLDrawableImpl; * utilizing already created {@link GLDrawable} and {@link GLContext} instances. *

    * Since no native windowing system events are being processed, it is recommended - * to handle at least: + * to handle at least the {@link com.jogamp.newt.event.WindowEvent window events}: *

      *
    • {@link com.jogamp.newt.event.WindowListener#windowRepaint(com.jogamp.newt.event.WindowUpdateEvent) repaint} using {@link #windowRepaintOp()}
    • *
    • {@link com.jogamp.newt.event.WindowListener#windowResized(com.jogamp.newt.event.WindowEvent) resize} using {@link #windowResizedOp()}
    • - *
    • {@link com.jogamp.newt.event.WindowListener#windowDestroyNotify(com.jogamp.newt.event.WindowEvent) destroy-notify} using {@link #windowDestroyNotifyOp()}
    • - *
    + * + * and setup a {@link com.jogamp.newt.Window#setWindowDestroyNotifyAction(Runnable) custom toolkit destruction} issuing {@link #windowDestroyNotifyOp()}. *

    *

    * See example {@link com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT TestGLAutoDrawableDelegateNEWT}. diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index dc4fe955c..94e123b3e 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -176,7 +176,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void run() { GLCanvas.this.destroyImpl( true ); } - }); + }, null); /** Creates a new GLCanvas component with a default set of OpenGL capabilities, using the default OpenGL capabilities selection @@ -460,7 +460,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( isVisible() ) { Threading.invoke(true, displayOnEDTAction, getTreeLock()); } - awtWindowClosingProtocol.addClosingListenerOneShot(); } /** @@ -568,7 +567,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // for all launch flavors (applet/javaws/..) // validateGLDrawable(); } - + awtWindowClosingProtocol.addClosingListener(); + if(DEBUG) { System.err.println(getThreadName()+": Info: addNotify - end: peer: "+getPeer()); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 2b99bb570..6c28c75ab 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -174,7 +174,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void run() { GLJPanel.this.destroy(); } - }); + }, null); static { // Force eager initialization of part of the Java2D class since @@ -369,6 +369,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void addNotify() { super.addNotify(); + awtWindowClosingProtocol.addClosingListener(); if (DEBUG) { System.err.println(getThreadName()+": GLJPanel.addNotify()"); } @@ -677,8 +678,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (!isInitialized) { backend.initialize(); } - - awtWindowClosingProtocol.addClosingListenerOneShot(); } @Override diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java index d78b4ac15..e3f85b948 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTWindowClosingProtocol.java @@ -33,22 +33,31 @@ import java.awt.Window; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; + import javax.media.nativewindow.WindowClosingProtocol; +import jogamp.common.awt.AWTEDTExecutor; import jogamp.nativewindow.awt.AWTMisc; public class AWTWindowClosingProtocol implements WindowClosingProtocol { private Component comp; - private Runnable closingOperation; - private volatile boolean closingListenerSet = false; + private Runnable closingOperationClose; + private Runnable closingOperationNOP; + private boolean closingListenerSet = false; private Object closingListenerLock = new Object(); private WindowClosingMode defaultCloseOperation = WindowClosingMode.DISPOSE_ON_CLOSE; private boolean defaultCloseOperationSetByUser = false; - public AWTWindowClosingProtocol(Component comp, Runnable closingOperation) { + /** + * @param comp mandatory AWT component which AWT Window is being queried by parent traversal + * @param closingOperationClose mandatory closing operation, triggered if windowClosing and {@link WindowClosingMode#DISPOSE_ON_CLOSE} + * @param closingOperationNOP optional closing operation, triggered if windowClosing and {@link WindowClosingMode#DO_NOTHING_ON_CLOSE} + */ + public AWTWindowClosingProtocol(Component comp, Runnable closingOperationClose, Runnable closingOperationNOP) { this.comp = comp; - this.closingOperation = closingOperation; + this.closingOperationClose = closingOperationClose; + this.closingOperationNOP = closingOperationNOP; } class WindowClosingAdapter extends WindowAdapter { @@ -59,54 +68,56 @@ public class AWTWindowClosingProtocol implements WindowClosingProtocol { if( WindowClosingMode.DISPOSE_ON_CLOSE == op ) { // we have to issue this call right away, // otherwise the window gets destroyed - closingOperation.run(); + closingOperationClose.run(); + } else if( null != closingOperationNOP ){ + closingOperationNOP.run(); } } } WindowListener windowClosingAdapter = new WindowClosingAdapter(); - final boolean addClosingListenerImpl() { - Window w = AWTMisc.getWindow(comp); - if(null!=w) { - w.addWindowListener(windowClosingAdapter); - return true; - } - return false; - } - /** - * Adds this closing listener to the components Window if exist and only one time.
    - * Hence you may call this method every time to ensure it has been set, - * ie in case the Window parent is not available yet. + * Adds this closing listener to the components Window if exist and only one time. + *

    + * If the closing listener is already added, and {@link IllegalStateException} is thrown. + *

    * - * @return + * @return true if added, otherwise false. + * @throws IllegalStateException */ - public final boolean addClosingListenerOneShot() { - if(!closingListenerSet) { // volatile: ok + public final boolean addClosingListener() throws IllegalStateException { synchronized(closingListenerLock) { - if(!closingListenerSet) { - closingListenerSet=addClosingListenerImpl(); - return closingListenerSet; - } + if(closingListenerSet) { + throw new IllegalStateException("WindowClosingListener already set"); + } + final Window w = AWTMisc.getWindow(comp); + if(null!=w) { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + w.addWindowListener(windowClosingAdapter); + } } ); + closingListenerSet = true; + return true; + } } - } - return false; + return false; } public final boolean removeClosingListener() { - if(closingListenerSet) { // volatile: ok synchronized(closingListenerLock) { - if(closingListenerSet) { - Window w = AWTMisc.getWindow(comp); - if(null!=w) { - w.removeWindowListener(windowClosingAdapter); - closingListenerSet = false; - return true; - } - } + if(closingListenerSet) { + final Window w = AWTMisc.getWindow(comp); + if(null!=w) { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + w.removeWindowListener(windowClosingAdapter); + } } ); + closingListenerSet = false; + return true; + } + } } - } - return false; + return false; } /** diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java index 12e202975..a740ebbe0 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java @@ -54,8 +54,7 @@ import javax.media.nativewindow.util.Point; public interface NativeWindow extends NativeSurface { /** - * destroys the window and releases - * windowing related resources. + * Destroys this window incl. releasing all related resources. */ public void destroy(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java b/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java index 884c916e4..02f68f442 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java +++ b/src/nativewindow/classes/javax/media/nativewindow/WindowClosingProtocol.java @@ -37,6 +37,10 @@ package javax.media.nativewindow; * this protocol default behavior {@link WindowClosingMode#DISPOSE_ON_CLOSE DISPOSE_ON_CLOSE} shall be used.

    */ public interface WindowClosingProtocol { + + /** + * Window closing mode if triggered by toolkit close operation. + */ public enum WindowClosingMode { /** * Do nothing on native window close operation.
    diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index cc42465f1..ab1eef308 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -28,12 +28,15 @@ package com.jogamp.newt; +import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.MouseListener; import jogamp.newt.Debug; +import jogamp.newt.WindowImpl; + import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; @@ -104,20 +107,42 @@ public interface Window extends NativeWindow, WindowClosingProtocol { CapabilitiesImmutable getChosenCapabilities(); /** - * Destroy the Window and it's children, incl. native destruction.
    - * The Window can be recreate via {@link #setVisible(boolean) setVisible(true)}. - *

    Visibility is set to false.

    + * {@inheritDoc} + *

    + * Also iterates through this window's children and destroys them. + *

    + *

    + * Visibility is set to false. + *

    + *

    + * Method sends out {@link WindowEvent#EVENT_WINDOW_DESTROY_NOTIFY pre-} and + * {@link WindowEvent#EVENT_WINDOW_DESTROYED post-} destruction events + * to all of it's {@link WindowListener}. + *

    *

    * This method invokes {@link Screen#removeReference()} after it's own destruction,
    * which will issue {@link Screen#destroy()} if the reference count becomes 0.
    * This destruction sequence shall end up in {@link Display#destroy()}, if all reference counts become 0. *

    + *

    + * The Window can be recreate via {@link #setVisible(boolean) setVisible(true)}. + *

    * @see #destroy() * @see #setVisible(boolean) */ @Override void destroy(); + /** + * Set a custom action handling destruction issued by a {@link WindowImpl#windowDestroyNotify(boolean) toolkit triggered window destroy} + * replacing the default {@link #destroy()} action. + *

    + * The custom action shall call {@link #destroy()} + * but may perform further tasks before and after. + *

    + */ + void setWindowDestroyNotifyAction(Runnable r); + /** * setVisible makes the window and children visible if visible is true, * otherwise the window and children becomes invisible. @@ -383,10 +408,13 @@ public interface Window extends NativeWindow, WindowClosingProtocol { // WindowListener // + /** + * Send a {@link WindowEvent} to all {@link WindowListener}. + * @param eventType a {@link WindowEvent} type, e.g. {@link WindowEvent#EVENT_WINDOW_REPAINT}. + */ public void sendWindowEvent(int eventType); /** - * * Appends the given {@link com.jogamp.newt.event.WindowListener} to the end of * the list. */ diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 3503dabd5..3c10859bf 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -51,6 +51,7 @@ import javax.swing.MenuSelectionManager; import jogamp.nativewindow.awt.AWTMisc; import jogamp.newt.Debug; +import jogamp.newt.WindowImpl; import jogamp.newt.awt.NewtFactoryAWT; import jogamp.newt.awt.event.AWTParentWindowAdapter; import jogamp.newt.driver.DriverClearFocus; @@ -59,9 +60,9 @@ import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.Display; import com.jogamp.newt.Window; -import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; +import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; @@ -88,16 +89,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private boolean newtChildAttached = false; private boolean isOnscreen = true; private WindowClosingMode newtChildCloseOp; - private AWTAdapter awtAdapter = null; + private AWTParentWindowAdapter awtAdapter = null; private AWTAdapter awtMouseAdapter = null; private AWTAdapter awtKeyAdapter = null; private AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { public void run() { - NewtCanvasAWT.this.destroy(); + NewtCanvasAWT.this.destroyImpl(false /* removeNotify */, true /* windowClosing */); } - }); + }, new Runnable() { + public void run() { + if( newtChild != null ) { + newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); + } + } + } ); /** * Instantiates a NewtCanvas without a NEWT child.
    @@ -209,7 +216,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } public void keyTyped(KeyEvent e) { if(suppress) { - e.setAttachment(InputEvent.consumedTag); + e.setAttachment(NEWTEvent.consumedTag); suppress = false; // reset } } @@ -239,7 +246,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } if(suppress) { - evt.setAttachment(InputEvent.consumedTag); + evt.setAttachment(NEWTEvent.consumedTag); } if(DEBUG) { System.err.println("NewtCanvasAWT.focusKey: XXX: "+ks); @@ -361,27 +368,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto ", displayable "+isDisplayable()+", cont "+AWTMisc.getContainer(this)); } } + awtWindowClosingProtocol.addClosingListener(); } @Override public void removeNotify() { + awtWindowClosingProtocol.removeClosingListener(); + if( Beans.isDesignTime() ) { super.removeNotify(); } else { - java.awt.Container cont = AWTMisc.getContainer(this); - if(DEBUG) { - System.err.println("NewtCanvasAWT.removeNotify: "+newtChild+", from "+cont); - } - // Detach OLS early.. - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); - if(null != ols && ols.isSurfaceLayerAttached()) { - ols.detachSurfaceLayer(); - } - detachNewtChild(cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) - - NewtFactoryAWT.destroyNativeWindow(jawtWindow); - jawtWindow=null; - + destroyImpl(true /* removeNotify */, false /* windowClosing */); super.removeNotify(); } } @@ -397,20 +394,32 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * @see Window#destroy() */ public final void destroy() { + destroyImpl(false /* removeNotify */, false /* windowClosing */); + } + + private final void destroyImpl(boolean removeNotify, boolean windowClosing) { if( null !=newtChild ) { java.awt.Container cont = AWTMisc.getContainer(this); if(DEBUG) { - System.err.println("NewtCanvasAWT.destroy(): "+newtChild+", from "+cont); + System.err.println("NewtCanvasAWT.destroy(removeNotify "+removeNotify+", windowClosing "+windowClosing+"): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); } - // Detach OLS early.. - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); - if(null != ols && ols.isSurfaceLayerAttached()) { - ols.detachSurfaceLayer(); - } - detachNewtChild(cont); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) - newtChild.destroy(); - newtChild=null; + detachNewtChild(cont); + + if( !removeNotify ) { + final Window cWin = newtChild; + final Window dWin = cWin.getDelegatedWindow(); + newtChild=null; + if( windowClosing && dWin instanceof WindowImpl ) { + ((WindowImpl)dWin).windowDestroyNotify(true); + } else { + cWin.destroy(); + } + } } + if( ( removeNotify || windowClosing ) && null!=jawtWindow) { + NewtFactoryAWT.destroyNativeWindow(jawtWindow); + jawtWindow=null; + } } @Override @@ -501,8 +510,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return false; } - awtWindowClosingProtocol.addClosingListenerOneShot(); - if( attachNewtChild && !newtChildAttached && null != newtChild ) { attachNewtChild(cont); } @@ -535,11 +542,11 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto throw new InternalError("XXX"); } isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); - awtAdapter = new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! newtChild.addWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(focusAction); // enable AWT focus traversal newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); - awtWindowClosingProtocol.addClosingListenerOneShot(); keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); keyboardFocusManager.addPropertyChangeListener("focusOwner", focusPropertyChangeListener); if(isOnscreen) { @@ -554,7 +561,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.removeWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(null); newtChild.setDefaultCloseOperation(newtChildCloseOp); - awtWindowClosingProtocol.removeClosingListener(); } } } @@ -611,7 +617,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.setFocusAction(null); // no AWT focus traversal .. configureNewtChild(false); newtChild.setVisible(false); - newtChild.reparentWindow(null); + + // Detach OLS early.. + final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(newtChild, true); + if(null != ols && ols.isSurfaceLayerAttached()) { + ols.detachSurfaceLayer(); + } + newtChild.reparentWindow(null); // will destroy context (offscreen -> onscreen) and implicit detachSurfaceLayer (if still attached) + if(DEBUG) { System.err.println("NewtCanvasAWT.detachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 07004503e..c3ad51c96 100755 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -300,9 +300,7 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.reparentWindow(awtParent); } else { glWindow.reparentWindow(null); - if(glClosable) { - glWindow.setDefaultCloseOperation(WindowClosingMode.DISPOSE_ON_CLOSE); - } + glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE ); } } } diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index 9ef4de2b6..4920b59ea 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -81,11 +81,6 @@ public abstract class InputEvent extends NEWTEvent return 0; } - /** Object when attached via {@link #setAttachment(Object)} marks the event consumed, - * ie. stops propagating the event any further to the event listener. - */ - public static final Object consumedTag = new Object(); - protected InputEvent(short eventType, Object source, long when, int modifiers) { super(eventType, source, when); this.modifiers=modifiers; diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index b8de6eb18..6f4561ce6 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -48,6 +48,12 @@ package com.jogamp.newt.event; */ @SuppressWarnings("serial") public class NEWTEvent extends java.util.EventObject { + /** + * Object when attached via {@link #setAttachment(Object)} marks the event consumed, + * ie. stops propagating the event any further to the other event listener. + */ + public static final Object consumedTag = new Object(); + private final short eventType; private final long when; private Object attachment; diff --git a/src/newt/classes/com/jogamp/newt/event/WindowListener.java b/src/newt/classes/com/jogamp/newt/event/WindowListener.java index 011e1f654..dde182510 100644 --- a/src/newt/classes/com/jogamp/newt/event/WindowListener.java +++ b/src/newt/classes/com/jogamp/newt/event/WindowListener.java @@ -36,6 +36,7 @@ package com.jogamp.newt.event; import javax.media.nativewindow.WindowClosingProtocol; +/** NEWT {@link WindowEvent} listener. */ public interface WindowListener extends NEWTEventListener { /** Window is resized, your application shall respect the new window dimension. A repaint is recommended. */ public void windowResized(WindowEvent e); @@ -53,7 +54,9 @@ public interface WindowListener extends NEWTEventListener { **/ public void windowDestroyNotify(WindowEvent e); - /** Window has been destroyed.*/ + /** + * Window has been destroyed. + */ public void windowDestroyed(WindowEvent e); /** Window gained focus. */ diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java index 8991203d5..6de2eee45 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTAdapter.java @@ -181,8 +181,13 @@ public abstract class AWTAdapter implements java.util.EventListener /** @see #addTo(java.awt.Component) */ public abstract AWTAdapter removeFrom(java.awt.Component awtComponent); + /** + * Enqueues the event to the {@link #getNewtWindow()} is not null. + */ void enqueueEvent(boolean wait, com.jogamp.newt.event.NEWTEvent event) { - newtWindow.enqueueEvent(wait, event); + if( null != newtWindow ) { + newtWindow.enqueueEvent(wait, event); + } } } diff --git a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java index 2d63ca455..e91bb2f82 100644 --- a/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/awt/AWTWindowAdapter.java @@ -66,13 +66,18 @@ public class AWTWindowAdapter return this; } - public AWTAdapter removeFrom(java.awt.Component awtComponent) { - awtComponent.removeFocusListener(this); - awtComponent.removeComponentListener(this); + public AWTAdapter removeWindowClosingFrom(java.awt.Component awtComponent) { java.awt.Window win = getWindow(awtComponent); if( null != win && null != windowClosingListener ) { win.removeWindowListener(windowClosingListener); } + return this; + } + + public AWTAdapter removeFrom(java.awt.Component awtComponent) { + awtComponent.removeFocusListener(this); + awtComponent.removeComponentListener(this); + removeWindowClosingFrom(awtComponent); if(awtComponent instanceof java.awt.Window) { ((java.awt.Window)awtComponent).removeWindowListener(this); } @@ -220,9 +225,16 @@ public class AWTWindowAdapter enqueueEvent(true, event); } } + public void windowClosed(java.awt.event.WindowEvent e) { + com.jogamp.newt.event.WindowEvent event = AWTNewtEventFactory.createWindowEvent(e, newtWindow); + if(null!=newtListener) { + ((com.jogamp.newt.event.WindowListener)newtListener).windowDestroyed(event); + } else { + enqueueEvent(true, event); + } + } public void windowActivated(java.awt.event.WindowEvent e) { } - public void windowClosed(java.awt.event.WindowEvent e) { } public void windowDeactivated(java.awt.event.WindowEvent e) { } public void windowDeiconified(java.awt.event.WindowEvent e) { } public void windowIconified(java.awt.event.WindowEvent e) { } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 7fccb6622..ce50d95dd 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -100,7 +100,10 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind protected GLWindow(Window window) { super(null, null, false /* always handle device lifecycle ourselves */); this.window = (WindowImpl) window; - this.window.setHandleDestroyNotify(false); + this.window.setWindowDestroyNotifyAction( new Runnable() { + public void run() { + defaultWindowDestroyNotifyOp(); + } } ); window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { @@ -112,10 +115,6 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind defaultWindowResizedOp(getWidth(), getHeight()); } - @Override - public void windowDestroyNotify(WindowEvent e) { - defaultWindowDestroyNotifyOp(); - } }); this.window.setLifecycleHook(new GLLifecycleHook()); } @@ -389,6 +388,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind window.destroy(); } + @Override + public void setWindowDestroyNotifyAction(Runnable r) { + window.setWindowDestroyNotifyAction(r); + } + @Override public final void setVisible(boolean visible) { window.setVisible(visible); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 20b915cae..d4842ba2f 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -370,15 +370,8 @@ public abstract class DisplayImpl extends Display { DisplayImpl.this.dispatchMessages(); } }; - final void dispatchMessage(final NEWTEventTask eventTask) { - final NEWTEvent event = eventTask.get(); + final void dispatchMessage(final NEWTEvent event) { try { - if(null == event) { - // Ooops ? - System.err.println("Warning: event of eventTask is NULL"); - Thread.dumpStack(); - return; - } final Object source = event.getSource(); if(source instanceof NEWTEventConsumer) { final NEWTEventConsumer consumer = (NEWTEventConsumer) source ; @@ -396,6 +389,21 @@ public abstract class DisplayImpl extends Display { } else { re = new RuntimeException(t); } + throw re; + } + } + + final void dispatchMessage(final NEWTEventTask eventTask) { + final NEWTEvent event = eventTask.get(); + try { + if(null == event) { + // Ooops ? + System.err.println("Warning: event of eventTask is NULL"); + Thread.dumpStack(); + return; + } + dispatchMessage(event); + } catch (RuntimeException re) { if( eventTask.isCallerWaiting() ) { // propagate exception to caller eventTask.setException(re); @@ -451,7 +459,7 @@ public abstract class DisplayImpl extends Display { // can't wait if we are on EDT or NEDT -> consume right away if(wait && edtUtil.isCurrentThreadEDTorNEDT() ) { - dispatchMessage(new NEWTEventTask(e, null)); + dispatchMessage(e); return; } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 222a1173c..66ca3e07d 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -110,7 +110,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private boolean pointerConfined = false; private LifecycleHook lifecycleHook = null; - private boolean handleDestroyNotify = true; + private Runnable windowDestroyNotifyAction = null; private FocusRunnable focusAction = null; private KeyListener keyboardFocusHandler = null; @@ -864,8 +864,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer _lock.lock(); try { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window DestroyAction() "+getThreadName()); + System.err.println("Window DestroyAction() hasScreen "+(null != screen)+", isNativeValid "+isNativeValid()+" - "+getThreadName()); } + + // send synced destroy-notify notification + sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); + // Childs first .. synchronized(childWindowsLock) { if(childWindows.size()>0) { @@ -875,8 +879,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer while( clonedChildWindows.size() > 0 ) { NativeWindow nw = clonedChildWindows.remove(0); if(nw instanceof WindowImpl) { - ((WindowImpl)nw).sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); - ((WindowImpl)nw).destroy(); + ((WindowImpl)nw).windowDestroyNotify(true); } else { nw.destroy(); } @@ -1549,14 +1552,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public Object getWrappedWindow() { return null; } - - /** - * If set to true, the default value, this NEWT Window implementation will - * handle the destruction (ie {@link #destroy()} call) within {@link #windowDestroyNotify(boolean)} implementation.
    - * If set to false, it's up to the caller/owner to handle destruction within {@link #windowDestroyNotify(boolean)}. - */ - public void setHandleDestroyNotify(boolean b) { - handleDestroyNotify = b; + + @Override + public void setWindowDestroyNotifyAction(Runnable r) { + windowDestroyNotifyAction = r; } /** @@ -2211,7 +2210,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer default: throw new NativeWindowException("Unexpected mouse event type " + e.getEventType()); } - consumed = InputEvent.consumedTag == e.getAttachment(); + consumed = NEWTEvent.consumedTag == e.getAttachment(); } } @@ -2340,7 +2339,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer default: throw new NativeWindowException("Unexpected key event type " + e.getEventType()); } - return InputEvent.consumedTag == e.getAttachment(); + return NEWTEvent.consumedTag == e.getAttachment(); } @SuppressWarnings("deprecation") @@ -2446,7 +2445,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("consumeWindowEvent: "+e+", visible "+isVisible()+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } - for(int i = 0; i < windowListeners.size(); i++ ) { + boolean consumed = false; + for(int i = 0; !consumed && i < windowListeners.size(); i++ ) { WindowListener l = windowListeners.get(i); switch(e.getEventType()) { case WindowEvent.EVENT_WINDOW_RESIZED: @@ -2475,6 +2475,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer new NativeWindowException("Unexpected window event type " + e.getEventType()); } + consumed = NEWTEvent.consumedTag == e.getAttachment(); } } @@ -2615,32 +2616,45 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** - * Triggered by implementation's WM events or programmatically + * Triggered by implementation's WM events or programmatic while respecting {@link #getDefaultCloseOperation()}. * * @param force if true, overrides {@link #setDefaultCloseOperation(WindowClosingMode)} with {@link WindowClosingProtocol#DISPOSE_ON_CLOSE} * and hence force destruction. Otherwise is follows the user settings. * @return true if this window is no more valid and hence has been destroyed, otherwise false. */ - protected boolean windowDestroyNotify(boolean force) { + public boolean windowDestroyNotify(boolean force) { + final WindowClosingMode defMode = getDefaultCloseOperation(); + final WindowClosingMode mode = force ? WindowClosingMode.DISPOSE_ON_CLOSE : defMode; if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowDestroyNotify(force: "+force+") START "+getThreadName()+": "+this); - } - if(force) { - setDefaultCloseOperation(WindowClosingMode.DISPOSE_ON_CLOSE); + System.err.println("Window.windowDestroyNotify(force: "+force+", mode "+defMode+" -> "+mode+") "+getThreadName()+": "+this); } - - // send synced destroy notifications - enqueueWindowEvent(true, WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); - - if(handleDestroyNotify && WindowClosingMode.DISPOSE_ON_CLOSE == getDefaultCloseOperation()) { - destroy(); + + if( WindowClosingMode.DISPOSE_ON_CLOSE == mode ) { + if(force) { + setDefaultCloseOperation(mode); + } + try { + if( null == windowDestroyNotifyAction ) { + destroy(); + } else { + windowDestroyNotifyAction.run(); + } + } finally { + if(force) { + setDefaultCloseOperation(defMode); + } + } + } else { + // send synced destroy notifications + sendWindowEvent(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY); } final boolean destroyed = !isNativeValid(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.windowDestroyNotify(force: "+force+") END "+getThreadName()+": destroyed "+destroyed+", "+this); - } + System.err.println("Window.windowDestroyNotify(force: "+force+", mode "+mode+") END "+getThreadName()+": destroyed "+destroyed+", "+this); + } + return destroyed; } diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java index 701d9d60a..b348220d6 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTParentWindowAdapter.java @@ -42,9 +42,7 @@ import com.jogamp.newt.event.awt.AWTWindowAdapter; * Specialized parent/client adapter, * where the NEWT child window really gets resized, * and the parent move window event gets discarded. */ -public class AWTParentWindowAdapter - extends AWTWindowAdapter - implements java.awt.event.HierarchyListener +public class AWTParentWindowAdapter extends AWTWindowAdapter implements java.awt.event.HierarchyListener { NativeWindow downstreamParent; diff --git a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java index bee43a95e..0172309fb 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/WindowDriver.java @@ -256,10 +256,7 @@ public class WindowDriver extends WindowImpl { } @Override public void windowDestroyed(WindowEvent e) { - if(isNativeValid()) { - WindowDriver.this.windowDestroyNotify(true); - } - + // Not fwd by AWTWindowAdapter, synthesized by NEWT } @Override public void windowGainedFocus(WindowEvent e) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java new file mode 100644 index 000000000..2729d6a5d --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableDelegateNEWT.java @@ -0,0 +1,160 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowUpdateEvent; +import com.jogamp.opengl.GLAutoDrawableDelegate; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Test using a NEWT {@link Window} for onscreen case. + *

    + * Creates a {@link GLDrawable} using the + * {@link GLDrawableFactory#createGLDrawable(javax.media.nativewindow.NativeSurface) factory model}. + * The {@link GLContext} is derived {@link GLDrawable#createContext(GLContext) from the drawable}. + *

    + *

    + * Finally a {@link GLAutoDrawableDelegate} is created with the just created {@link GLDrawable} and {@link GLContext}. + * It is being used to run the {@link GLEventListener}. + *

    + */ +public class TestGLAutoDrawableDelegateNEWT extends UITestCase { + static long duration = 500; // ms + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + + // + // Create native windowing resources .. X11/Win/OSX + // + final Window window = NewtFactory.createWindow(reqGLCaps); + Assert.assertNotNull(window); + window.setSize(640, 400); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + System.out.println("Window: "+window.getClass().getName()); + + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + drawable.setRealized(true); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, drawable.createContext(null), window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); // destroys drawable/context + window.destroy(); // destroys the actual window, incl. the device + } + }; + + window.setWindowDestroyNotifyAction( new Runnable() { + public void run() { + glad.windowDestroyNotifyOp(); + } } ); + + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + }); + + glad.addGLEventListener(demo); + + QuitAdapter quitAdapter = new QuitAdapter(); + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + window.addKeyListener(quitAdapter); + window.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.setUpdateFPSFrames(60, System.err); + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + animator.add(glad); + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() dispose @@ -90,10 +93,12 @@ public class TestWindowClosingProtocol01AWT extends UITestCase { Thread.sleep(300); - Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false)); // no frame close, but GLCanvas's GL resources will be destroyed + Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false, closingListener)); // no frame close, but GLCanvas's GL resources will be destroyed Thread.sleep(100); Assert.assertEquals(true, frame.isDisplayable()); Assert.assertEquals(true, frame.isVisible()); + Assert.assertEquals(true, closingListener.isWindowClosing()); + Assert.assertEquals(false, closingListener.isWindowClosed()); for (int wait=0; wait dispose @@ -84,9 +84,9 @@ public class TestWindowClosingProtocol02NEWT extends UITestCase { op = glWindow.getDefaultCloseOperation(); Assert.assertEquals(WindowClosingMode.DISPOSE_ON_CLOSE, op); - Assert.assertEquals(true, AWTRobotUtil.closeWindow(glWindow, true)); + Assert.assertEquals(true, AWTRobotUtil.closeWindow(glWindow, true, closingListener)); Assert.assertEquals(false, glWindow.isNativeValid()); - Assert.assertEquals(true, windowClosingListener.isWindowClosing()); + Assert.assertEquals(true, closingListener.isWindowClosing()); } public static void main(String[] args) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java index be3c48fb6..b0a222a5a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestWindowClosingProtocol03NewtAWT.java @@ -46,17 +46,19 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil.WindowClosingListener; public class TestWindowClosingProtocol03NewtAWT extends UITestCase { @Test public void testCloseJFrameNewtCanvasAWT() throws InterruptedException, InvocationTargetException { final JFrame frame = new JFrame("testCloseJFrameNewtCanvasAWT"); - + final WindowClosingListener awtClosingListener = AWTRobotUtil.addClosingListener(frame); + GLProfile glp = GLProfile.getGL2ES2(); GLCapabilities caps = new GLCapabilities(glp); final GLWindow glWindow = GLWindow.create(caps); - final AWTRobotUtil.WindowClosingListener windowClosingListener = AWTRobotUtil.addClosingListener(glWindow); + final AWTRobotUtil.WindowClosingListener newtClosingListener = AWTRobotUtil.addClosingListener(glWindow); glWindow.addGLEventListener(new GearsES2()); @@ -81,20 +83,26 @@ public class TestWindowClosingProtocol03NewtAWT extends UITestCase { // // close with op: DO_NOTHING_ON_CLOSE -> NOP / HIDE (default) // - Assert.assertEquals(JFrame.HIDE_ON_CLOSE, frame.getDefaultCloseOperation()); - WindowClosingMode op = newtCanvas.getDefaultCloseOperation(); - Assert.assertEquals(WindowClosingMode.DO_NOTHING_ON_CLOSE, op); + { + Assert.assertEquals(JFrame.HIDE_ON_CLOSE, frame.getDefaultCloseOperation()); + WindowClosingMode op = newtCanvas.getDefaultCloseOperation(); + Assert.assertEquals(WindowClosingMode.DO_NOTHING_ON_CLOSE, op); + } Thread.sleep(300); - Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false)); + Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, false, awtClosingListener)); Assert.assertEquals(true, frame.isDisplayable()); Assert.assertEquals(false, frame.isVisible()); Assert.assertEquals(true, newtCanvas.isValid()); Assert.assertEquals(true, newtCanvas.isDisplayable()); Assert.assertEquals(true, glWindow.isNativeValid()); - Assert.assertEquals(true, windowClosingListener.isWindowClosing()); - windowClosingListener.reset(); + Assert.assertEquals(true, awtClosingListener.isWindowClosing()); + Assert.assertEquals(false, awtClosingListener.isWindowClosed()); + Assert.assertEquals(true, newtClosingListener.isWindowClosing()); + Assert.assertEquals(false, newtClosingListener.isWindowClosed()); + awtClosingListener.reset(); + newtClosingListener.reset(); SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -107,20 +115,25 @@ public class TestWindowClosingProtocol03NewtAWT extends UITestCase { // // close with op (JFrame): DISPOSE_ON_CLOSE -- newtCanvas -- glWindow --> dispose // - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - Assert.assertEquals(JFrame.DISPOSE_ON_CLOSE, frame.getDefaultCloseOperation()); - op = newtCanvas.getDefaultCloseOperation(); - Assert.assertEquals(WindowClosingMode.DISPOSE_ON_CLOSE, op); + { + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + Assert.assertEquals(JFrame.DISPOSE_ON_CLOSE, frame.getDefaultCloseOperation()); + WindowClosingMode op = newtCanvas.getDefaultCloseOperation(); + Assert.assertEquals(WindowClosingMode.DISPOSE_ON_CLOSE, op); + } Thread.sleep(300); - Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.closeWindow(frame, true, awtClosingListener)); Assert.assertEquals(false, frame.isDisplayable()); Assert.assertEquals(false, frame.isVisible()); Assert.assertEquals(false, newtCanvas.isValid()); Assert.assertEquals(false, newtCanvas.isDisplayable()); Assert.assertEquals(false, glWindow.isNativeValid()); - Assert.assertEquals(true, windowClosingListener.isWindowClosing()); + Assert.assertEquals(true, awtClosingListener.isWindowClosing()); + Assert.assertEquals(true, awtClosingListener.isWindowClosed()); + Assert.assertEquals(true, newtClosingListener.isWindowClosing()); + Assert.assertEquals(true, newtClosingListener.isWindowClosed()); } public static void main(String[] args) { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index ffc42e318..8b46760e1 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.util; +import jogamp.common.awt.AWTEDTExecutor; import jogamp.newt.WindowImplAccess; import java.lang.reflect.InvocationTargetException; @@ -41,6 +42,8 @@ import javax.media.opengl.awt.GLCanvas; import org.junit.Assert; +import com.jogamp.newt.event.WindowEvent; + public class AWTRobotUtil { static final boolean DEBUG = false; @@ -646,16 +649,19 @@ public class AWTRobotUtil { * * @param obj either an AWT Window (Frame, JFrame) or NEWT Window * @param willClose indicating that the window will close, hence this method waits for the window to be closed + * @param wcl the WindowClosingListener to determine whether the AWT or NEWT widget has been closed. It should be attached + * to the widget ASAP before any other listener, e.g. via {@link #addClosingListener(Object)}. + * The WindowClosingListener will be reset before attempting to close the widget. * @return True if the Window is closing and closed (if willClose is true), each within TIME_OUT * @throws InterruptedException */ - public static boolean closeWindow(Object obj, boolean willClose) throws InterruptedException, InvocationTargetException { - WindowClosingListener closingListener = addClosingListener(obj); + public static boolean closeWindow(Object obj, boolean willClose, WindowClosingListener closingListener) throws InterruptedException { + closingListener.reset(); if(obj instanceof java.awt.Window) { final java.awt.Window win = (java.awt.Window) obj; java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit(); final java.awt.EventQueue evtQ = tk.getSystemEventQueue(); - java.awt.EventQueue.invokeAndWait(new Runnable() { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { evtQ.postEvent(new java.awt.event.WindowEvent(win, java.awt.event.WindowEvent.WINDOW_CLOSING)); } }); @@ -675,12 +681,15 @@ public class AWTRobotUtil { return wait Date: Thu, 28 Feb 2013 20:18:43 +0100 Subject: TestBug572AWT: Add test case w/ setting GLCanvas's size and frame.pack() on AWT-EDT and current thread. --- make/scripts/tests.sh | 4 +- .../opengl/test/junit/jogl/awt/TestBug572AWT.java | 111 ++++++++++----------- 2 files changed, 53 insertions(+), 62 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7a43fd3da..d5b045c6b 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -330,7 +330,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* @@ -382,7 +382,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java index 80f0e93b6..ea8fe070d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug572AWT.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.jogl.awt; +import java.awt.Dimension; import java.awt.Window; import java.lang.reflect.InvocationTargetException; @@ -47,9 +48,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; /** - * Tests context creation + display on various kinds of Window implementations. + * Test realize GLCanvas and setVisible(true) AWT-Frames on AWT-EDT and on current thread (non AWT-EDT) */ public class TestBug572AWT extends UITestCase { + static long durationPerTest = 150; // ms + static class Cleanup implements Runnable { Window window; @@ -69,9 +72,8 @@ public class TestBug572AWT extends UITestCase { window.dispose(); } } - - @Test - public void test01RealizeGLCanvasOnAWTEDT() throws InterruptedException, InvocationTargetException { + + private void testRealizeGLCanvas(final boolean onAWTEDT, final boolean setFrameSize) throws InterruptedException, InvocationTargetException { final Window window = new JFrame(this.getSimpleTestName(" - ")); final GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); final GLCanvas glCanvas = new GLCanvas(caps); @@ -81,22 +83,37 @@ public class TestBug572AWT extends UITestCase { glCanvas.addGLEventListener(snapshooter); window.add(glCanvas); - // Revalidate size/layout. - // Always validate if component added/removed. - // Ensure 1st paint of GLCanvas will have a valid size, hence drawable gets created. - window.setSize(512, 512); - window.validate(); - - // trigger realization on AWT-EDT, otherwise it won't immediatly .. - SwingUtilities.invokeAndWait(new Runnable() { + final Runnable realizeAction = new Runnable() { @Override public void run() { + // Revalidate size/layout. + // Always validate if component added/removed. + // Ensure 1st paint of GLCanvas will have a valid size, hence drawable gets created. + if( setFrameSize ) { + window.setSize(512, 512); + window.validate(); + } else { + Dimension size = new Dimension(512, 512); + glCanvas.setPreferredSize(size); + glCanvas.setMinimumSize(size); + window.pack(); + } window.setVisible(true); - } - } ); + } }; + if( onAWTEDT ) { + // trigger realization on AWT-EDT, otherwise it won't immediatly .. + SwingUtilities.invokeAndWait( realizeAction ); + } else { + // trigger realization on non AWT-EDT, realization will happen at a later time .. + realizeAction.run(); + + // Wait until it's displayable after issuing initial setVisible(true) on current thread (non AWT-EDT)! + Assert.assertTrue("GLCanvas didn't become visible", AWTRobotUtil.waitForVisible(glCanvas, true)); + Assert.assertTrue("GLCanvas didn't become realized", AWTRobotUtil.waitForRealized(glCanvas, true)); // implies displayable + } + System.err.println("XXXX-0 "+glCanvas.getDelegatedDrawable().isRealized()+", "+glCanvas); - // Immediately displayable after issuing initial setVisible(true) on AWT-EDT! Assert.assertTrue("GLCanvas didn't become displayable", glCanvas.isDisplayable()); Assert.assertTrue("GLCanvas didn't become realized", glCanvas.isRealized()); @@ -116,59 +133,33 @@ public class TestBug572AWT extends UITestCase { Assert.assertTrue("GLCanvas didn't reshape", snapshooter.getReshapeCount()>0); Assert.assertTrue("GLCanvas didn't display", snapshooter.getDisplayCount()>0); + Thread.sleep(durationPerTest); + // After initial 'setVisible(true)' all AWT manipulation needs to be done // via the AWT EDT, according to the AWT spec. // AWT / Swing on EDT.. SwingUtilities.invokeAndWait(new Cleanup(window)); } + + @Test(timeout = 10000) // 10s timeout + public void test01RealizeGLCanvasOnAWTEDTUseFrameSize() throws InterruptedException, InvocationTargetException { + testRealizeGLCanvas(true, true); + } - @Test - public void test02RealizeGLCanvasOnCurrentThread() throws InterruptedException, InvocationTargetException { - final Window window = new JFrame(this.getSimpleTestName(" - ")); - final GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); - final GLCanvas glCanvas = new GLCanvas(caps); - final SnapshotGLEventListener snapshooter = new SnapshotGLEventListener(); - snapshooter.setMakeSnapshotAlways(true); - glCanvas.addGLEventListener(new GearsES2()); - glCanvas.addGLEventListener(snapshooter); - window.add(glCanvas); - - // Revalidate size/layout. - // Always validate if component added/removed. - // Ensure 1st paint of GLCanvas will have a valid size, hence drawable gets created. - window.setSize(512, 512); - window.validate(); - - // trigger realization on non AWT-EDT, realization will happen at a later time .. - window.setVisible(true); - System.err.println("XXXX-0 "+glCanvas.getDelegatedDrawable().isRealized()+", "+glCanvas); - - // Wait until it's displayable after issuing initial setVisible(true) on current thread (non AWT-EDT)! - Assert.assertTrue("GLCanvas didn't become visible", AWTRobotUtil.waitForVisible(glCanvas, true)); - Assert.assertTrue("GLCanvas didn't become realized", AWTRobotUtil.waitForRealized(glCanvas, true)); // implies displayable - - // The AWT-EDT reshape/repaint events happen offthread later .. - System.err.println("XXXX-1 reshapeCount "+snapshooter.getReshapeCount()); - System.err.println("XXXX-1 displayCount "+snapshooter.getDisplayCount()); - - // Wait unitl AWT-EDT has issued reshape/repaint - for (int wait=0; wait0); - Assert.assertTrue("GLCanvas didn't display", snapshooter.getDisplayCount()>0); - - // After initial 'setVisible(true)' all AWT manipulation needs to be done - // via the AWT EDT, according to the AWT spec. + @Test(timeout = 10000) // 10s timeout + public void test02RealizeGLCanvasOnAWTEDTUseGLCanvasSize() throws InterruptedException, InvocationTargetException { + testRealizeGLCanvas(true, false); + } + + @Test(timeout = 10000) // 10s timeout + public void test11RealizeGLCanvasOnMainTUseFrameSize() throws InterruptedException, InvocationTargetException { + testRealizeGLCanvas(false, true); + } - // AWT / Swing on EDT.. - SwingUtilities.invokeAndWait(new Cleanup(window)); + @Test(timeout = 10000) // 10s timeout + public void test12RealizeGLCanvasOnMainTUseGLCanvasSize() throws InterruptedException, InvocationTargetException { + testRealizeGLCanvas(false, false); } public static void main(String args[]) { -- cgit v1.2.3 From d3672684177a98a58c434bcd27541f44917050f3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 9 Mar 2013 04:23:55 +0100 Subject: Fix Mix2TexturesES2 unit tests: Use synchronized texID access and add glFinish() after demo -> FBO rendering on or off thread. Fixes shared GLContext OSX rendering. --- make/scripts/tests.sh | 26 ++++++++++++-- ...tFBOOffThreadSharedContextMix2DemosES2NEWT.java | 3 ++ .../TestFBOOnThreadSharedContext1DemoES2NEWT.java | 2 ++ .../test/junit/jogl/demos/GLFinishOnDisplay.java | 40 ++++++++++++++++++++++ .../test/junit/jogl/demos/es2/Mix2TexturesES2.java | 37 ++++++++++++-------- 5 files changed, 90 insertions(+), 18 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d5b045c6b..5d259d6be 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -172,7 +172,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" - D_ARGS="-Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -192,6 +192,8 @@ function jrun() { #D_ARGS="-Dnewt.debug=all -Djogamp.debug.Lock.TraceLock -Djogamp.common.utils.locks.Lock.timeout=600000" #D_ARGS="-Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" + #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" + #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" @@ -342,7 +344,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* @@ -382,7 +384,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug611AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn @@ -396,6 +398,7 @@ testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug694ScaleImageUnpackBufferSizeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* @@ -546,6 +549,23 @@ testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +# +# OSX Java6 NEWT +# + +# Cut-off top +#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* + +# Child too low +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* + +# NPE: +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* + +# test rotation change +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT + #linux: # ATI/Linux: XCB Unknown request in queue while dequeuing diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java index 3ecf89bfc..19e57c9bc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java @@ -44,6 +44,7 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.FPSAnimator; import com.jogamp.opengl.util.GLReadBufferUtil; import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.test.junit.jogl.demos.GLFinishOnDisplay; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -136,6 +137,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { { GearsES2 demo0 = new GearsES2(-1); fbod1.addGLEventListener(demo0); + fbod1.addGLEventListener(new GLFinishOnDisplay()); demo0.setIgnoreFocus(true); } fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { @@ -152,6 +154,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); fbod2.setTextureUnit(fbod2_texUnit); fbod2.addGLEventListener(new RedSquareES2(-1)); + fbod2.addGLEventListener(new GLFinishOnDisplay()); fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { @Override public void surfaceUpdated(Object updater, NativeSurface ns, long when) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java index 7d9a9c662..acd46f57f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOnThreadSharedContext1DemoES2NEWT.java @@ -43,6 +43,7 @@ import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.test.junit.jogl.demos.GLFinishOnDisplay; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.jogl.demos.es2.Mix2TexturesES2; @@ -133,6 +134,7 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { { GearsES2 demo0 = new GearsES2(-1); fbod1.addGLEventListener(demo0); + fbod1.addGLEventListener(new GLFinishOnDisplay()); demo0.setIgnoreFocus(true); } fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java new file mode 100644 index 000000000..cb76f1057 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GLFinishOnDisplay.java @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2013 JogAmp Community. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.jogamp.opengl.test.junit.jogl.demos; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +public class GLFinishOnDisplay implements GLEventListener { + @Override + public void init(GLAutoDrawable drawable) { } + + @Override + public void dispose(GLAutoDrawable drawable) { } + + @Override + public void display(GLAutoDrawable drawable) { + drawable.getGL().glFinish(); + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java index 26e7e234a..cd40b5c6e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/Mix2TexturesES2.java @@ -42,7 +42,8 @@ public class Mix2TexturesES2 implements GLEventListener { private final PMVMatrix pmvMatrix; private final GLUniformData texUnit0, texUnit1; - private volatile int texID0, texID1; + private Object syncTexIDs = new Object(); + private int texID0, texID1; private ShaderProgram sp0; private GLUniformData pmvMatrixUniform; private GLArrayDataServer interleavedVBO; @@ -66,10 +67,14 @@ public class Mix2TexturesES2 implements GLEventListener { } public void setTexID0(int texID) { - this.texID0 = texID; + synchronized( syncTexIDs ) { + this.texID0 = texID; + } } public void setTexID1(int texID) { - this.texID1 = texID; + synchronized( syncTexIDs ) { + this.texID1 = texID; + } } static final String[] es2_prelude = { "#version 100\n", "precision mediump float;\n" }; @@ -156,20 +161,22 @@ public class Mix2TexturesES2 implements GLEventListener { interleavedVBO.enableBuffer(gl, true); - if(0 Date: Wed, 13 Mar 2013 06:35:30 +0100 Subject: Bug 665: Allow re-association of GLContext/GLEventListener to a GLDrawable (Part 4) Note: - GLEventListenerState preservs the GLAutoDrawable state, i.e. GLContext, all GLEventListener and the GLAnimatorControl association. - GLEventListenerState may be utilized to move the state from a dying GLAutoDrawable, to be moved to a new created GLAutoDrawable at a later time. - GLEventListenerState will be made public soon. +++ Exessive unit tests cover the new feature, tested manually on GNU/Linux/X11 and OSX(Java6/Java7). +++ - GLAutoDrawable - Change 'setContext(..)' to allow the destruction of the unbound old context: 'setContext(GLContext newCtx)' -> 'setContext(GLContext newCtx, boolean destroyPrevCtx)' - Implementations: Properly implement 'setRealized(..)' incl. obeying threading constraints if exists. Method is being utilized at least for GLEventListenerState.moveTo(..) to unrealize and realize the drawable resources. +++ Fix propagation of GLContext/GLDrawable association change (Bottom -> Top): GLDrawableImpl.associateContext GLContextImpl.associateDrawable GLContextImpl.makeCurrent GLContextImpl.destroy GLContext.setGLDrawable ... GLDrawableHelper.switchContext GLAutoDrawble.setContext associateDrawable(..)/associateContext(..) unifies and hence: - GLContextImpl.contextRealized() (removed) - GLDrawableImpl.contextRealized() (removed) - GLDrawableImpl.associateContext(..) (merged) - MacOSXCGLContext.drawableChangedNotify(..) (removed) +++ - EGLUpstreamSurfaceHook.evalUpstreamSurface() validates the surface's device for reusage, which is valid in case of GLEventListenerState.moveTo(..) - MacOSXCGLContext.NSOpenGLImpl: pixelFormat replaces NSOpenGLLayerPfmt and has simplified lifecycle [create..destroy], while native NSOpenGLLayer code only holds the reference until released. --- make/scripts/tests.sh | 45 ++- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 5 - .../classes/com/jogamp/opengl/swt/GLCanvas.java | 7 +- .../com/jogamp/opengl/util/GLDrawableUtil.java | 2 +- .../classes/javax/media/opengl/GLAutoDrawable.java | 21 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 90 ++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 7 +- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 25 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 59 ++-- .../classes/jogamp/opengl/GLDrawableHelper.java | 45 +-- src/jogl/classes/jogamp/opengl/GLDrawableImpl.java | 40 +-- .../jogamp/opengl/GLEventListenerState.java | 55 +-- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 14 +- src/jogl/classes/jogamp/opengl/GLPbufferImpl.java | 10 +- .../jogamp/opengl/egl/EGLUpstreamSurfaceHook.java | 53 ++- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 132 +++---- .../opengl/macosx/cgl/MacOSXCGLDrawable.java | 1 - .../macosx/MacOSXWindowSystemInterface-calayer.m | 17 +- .../acore/TestGLContextDrawableSwitch01NEWT.java | 374 -------------------- .../acore/TestGLContextDrawableSwitch11NEWT.java | 386 --------------------- .../acore/glels/GLContextDrawableSwitchBase.java | 276 +++++++++++++++ .../glels/TestGLContextDrawableSwitch01NEWT.java | 374 ++++++++++++++++++++ .../glels/TestGLContextDrawableSwitch10NEWT.java | 274 +++++++++++++++ .../TestGLContextDrawableSwitch11NewtAWT.java | 118 +++++++ .../glels/TestGLContextDrawableSwitch12AWT.java | 144 ++++++++ .../TestGLContextDrawableSwitch21Newt2AWT.java | 165 +++++++++ .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 31 +- .../jogamp/opengl/test/junit/util/QuitAdapter.java | 19 +- 28 files changed, 1730 insertions(+), 1059 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch11NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch10NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch11NewtAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch12AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch21Newt2AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5d259d6be..8cc3fd84a 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -106,10 +106,11 @@ function jrun() { #D_ARGS="-Djogamp.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" + #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.fbo.force.none" @@ -194,7 +195,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" - #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" @@ -312,17 +312,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* @@ -339,15 +331,27 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* - #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* + +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* + #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT @@ -560,9 +564,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1D # Child too low #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* -# NPE: -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT $* - # test rotation change #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT @@ -580,5 +581,15 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1D # ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed. #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +# NEW +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NEWT $* + +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* + + $spath/count-edt-start.sh java-run.log diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java index 0f0f03ac4..bec05a0bd 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -169,11 +169,6 @@ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAuto return drawable.getFactory(); } - @Override - public final void setRealized(boolean realized) { - drawable.setRealized(realized); - } - @Override public final void swapBuffers() throws GLException { defaultSwapBuffers(); diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 80e1aa80d..169266152 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -705,16 +705,13 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } @Override - public GLContext setContext(GLContext newCtx) { + public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) { final RecursiveLock _lock = lock; _lock.lock(); try { final GLContext oldCtx = context; - final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + GLDrawableHelper.switchContext(drawable, oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; - if(newCtxCurrent) { - context.makeCurrent(); - } return oldCtx; } finally { _lock.unlock(); diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java index c03e4bfa4..83414ddb0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLDrawableUtil.java @@ -151,7 +151,7 @@ public class GLDrawableUtil { for(int i = dest.getGLEventListenerCount() - 1; 0 <= i; i--) { dest.disposeGLEventListener(dest.getGLEventListener(i), false); } - dest.setContext( src.setContext( dest.getContext() ) ); + dest.setContext( src.setContext( dest.getContext(), false ), false ); src.invoke(true, GLEventListenerState.setViewport); dest.invoke(true, GLEventListenerState.setViewport); diff --git a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java index 6abe4308b..bdbbd96a5 100644 --- a/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLAutoDrawable.java @@ -132,7 +132,8 @@ public interface GLAutoDrawable extends GLDrawable { /** * Associate the new context, newtCtx, to this auto-drawable. *

    - * The current context will be dis-associated from this auto-drawable + * The current context will be destroyed if destroyPrevCtx is true, + * otherwise it will be dis-associated from this auto-drawable * via {@link GLContext#setGLDrawable(GLDrawable, boolean) setGLDrawable(null, true);} first. *

    *

    @@ -145,26 +146,16 @@ public interface GLAutoDrawable extends GLDrawable { * However the user shall take extra care that no other thread * attempts to make this context current. *

    - *

    - * In case you do not intend to use the old context anymore, i.e. - * not assigning it to another drawable, it shall be - * destroyed, i.e.: - *

    -            GLContext oldCtx = glad.setContext(newCtx);
    -            if(null != oldCtx) {
    -                oldCtx.destroy();
    -            }
    -   * 
    - *

    * * @param newCtx the new context, maybe null for dis-association. + * @param destroyPrevCtx if true, destroy the previous context if exists * @return the previous GLContext, maybe null * * @see GLContext#setGLDrawable(GLDrawable, boolean) * @see GLContext#setGLReadDrawable(GLDrawable) - * @see jogamp.opengl.GLDrawableHelper#switchContext(GLDrawable, GLContext, GLContext, int) + * @see jogamp.opengl.GLDrawableHelper#switchContext(GLDrawable, GLContext, boolean, GLContext, int) */ - public GLContext setContext(GLContext newCtx); + public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx); /** * Adds the given {@link GLEventListener listener} to the end of this drawable queue. @@ -500,7 +491,7 @@ public interface GLAutoDrawable extends GLDrawable { *

    * This GLAutoDrawable implementation holds it's own GLContext reference, * thus created a GLContext using this methods won't replace it implicitly. - * To replace or set this GLAutoDrawable's GLContext you need to call {@link #setContext(GLContext)}. + * To replace or set this GLAutoDrawable's GLContext you need to call {@link #setContext(GLContext, boolean)}. *

    *

    * The GLAutoDrawable implementation shall also set the diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index ebc25e2ad..63c18db5d 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -429,8 +429,29 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } + private final void setRealizedImpl(boolean realized) { + final RecursiveLock _lock = lock; + _lock.lock(); + try { + final GLDrawable _drawable = drawable; + if( null == _drawable || realized && ( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) ) { + return; + } + _drawable.setRealized(realized); + if( realized && _drawable.isRealized() ) { + sendReshape=true; // ensure a reshape is being send .. + } + } finally { + _lock.unlock(); + } + } + private final Runnable realizeOnEDTAction = new Runnable() { public void run() { setRealizedImpl(true); } }; + private final Runnable unrealizeOnEDTAction = new Runnable() { public void run() { setRealizedImpl(false); } }; + @Override - public void setRealized(boolean realized) { + public final void setRealized(boolean realized) { + // Make sure drawable realization happens on AWT-EDT and only there. Consider the AWTTree lock! + AWTEDTExecutor.singleton.invoke(getTreeLock(), false /* allowOnNonEDT */, true /* wait */, realized ? realizeOnEDTAction : unrealizeOnEDTAction); } @Override @@ -595,46 +616,28 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } private boolean validateGLDrawable() { - if( Beans.isDesignTime() || !isDisplayable() ) { - return false; // early out! - } - final GLDrawable _drawable = drawable; - if ( null != _drawable ) { - if( _drawable.isRealized() ) { - return true; - } - if( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { - return false; // early out! - } - // Make sure drawable realization happens on AWT-EDT and only there. Consider the AWTTree lock! - final boolean res0 = AWTEDTExecutor.singleton.invoke(getTreeLock(), false /* allowOnNonEDT */, true /* wait */, setRealizedOnEDTAction); - final boolean res1 = res0 && _drawable.isRealized(); - if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: invoked "+res0+", probedIsRealized "+res1+", "+_drawable.toString()); - Thread.dumpStack(); - } - return res1; - } - return false; - } - private Runnable setRealizedOnEDTAction = new Runnable() { - public void run() { - final RecursiveLock _lock = lock; - _lock.lock(); - try { - final GLDrawable _drawable = drawable; - if( null == _drawable || 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { - return; - } - _drawable.setRealized(true); - if( _drawable.isRealized() ) { - sendReshape=true; // ensure a reshape is being send .. - } - } finally { - _lock.unlock(); + if( Beans.isDesignTime() || !isDisplayable() ) { + return false; // early out! + } + final GLDrawable _drawable = drawable; + if ( null != _drawable ) { + if( _drawable.isRealized() ) { + return true; } - } }; - + if( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { + return false; // early out! + } + setRealized(true); + final boolean res = _drawable.isRealized(); + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: isRealized "+res+", "+_drawable.toString()); + Thread.dumpStack(); + } + return res; + } + return false; + } + /**

    Overridden to track when this component is removed from a container. Subclasses which override this method must call super.removeNotify() in their removeNotify() method in order to @@ -791,16 +794,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } @Override - public GLContext setContext(GLContext newCtx) { + public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) { final RecursiveLock _lock = lock; _lock.lock(); try { final GLContext oldCtx = context; - final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + GLDrawableHelper.switchContext(drawable, oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; - if(newCtxCurrent) { - context.makeCurrent(); - } return oldCtx; } finally { _lock.unlock(); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 8d9493cbf..d62967d7f 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -519,16 +519,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public GLContext setContext(GLContext newCtx) { + public GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) { if (backend == null) { return null; } final GLContext oldCtx = backend.getContext(); - final boolean newCtxCurrent = GLDrawableHelper.switchContext(backend.getDrawable(), oldCtx, newCtx, additionalCtxCreationFlags); + GLDrawableHelper.switchContext(backend.getDrawable(), oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags); backend.setContext(newCtx); - if(newCtxCurrent) { - newCtx.makeCurrent(); - } return oldCtx; } diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index c20197e72..ad67f8281 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -326,16 +326,13 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } @Override - public final GLContext setContext(GLContext newCtx) { + public final GLContext setContext(GLContext newCtx, boolean destroyPrevCtx) { final RecursiveLock lock = getLock(); lock.lock(); try { final GLContext oldCtx = context; - final boolean newCtxCurrent = GLDrawableHelper.switchContext(drawable, oldCtx, newCtx, additionalCtxCreationFlags); + GLDrawableHelper.switchContext(drawable, oldCtx, destroyPrevCtx, newCtx, additionalCtxCreationFlags); context=(GLContextImpl)newCtx; - if(newCtxCurrent) { // implies null != newCtx - context.makeCurrent(); - } return oldCtx; } finally { lock.unlock(); @@ -530,6 +527,24 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, FPSCounter { } } + @Override + public final void setRealized(boolean realized) { + final RecursiveLock _lock = getLock(); + _lock.lock(); + try { + final GLDrawable _drawable = drawable; + if( null == _drawable || realized && ( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) ) { + return; + } + _drawable.setRealized(realized); + if( realized && _drawable.isRealized() ) { + sendReshape=true; // ensure a reshape is being send .. + } + } finally { + _lock.unlock(); + } + } + @Override public final boolean isRealized() { final GLDrawable _drawable = drawable; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 42364dbfd..4121e8f77 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -133,9 +133,6 @@ public abstract class GLContextImpl extends GLContext { GLContextShareSet.synchronizeBufferObjectSharing(shareWith, this); this.drawable = drawable; - if(null != drawable) { - drawable.associateContext(this, true); - } this.drawableRead = drawable; this.glDebugHandler = new GLDebugMessageHandler(this); @@ -207,25 +204,36 @@ public abstract class GLContextImpl extends GLContext { return drawable; // no change. } final Thread currentThread = Thread.currentThread(); + if( lock.isLockedByOtherThread() ) { + throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName()); + } final boolean lockHeld = lock.isOwner(currentThread); + if( lockHeld && lock.getHoldCount() > 1 ) { + // would need to makeCurrent * holdCount + throw new GLException("GLContext is recursively locked - unsupported for setGLDrawable(..)"); + } + final GLDrawableImpl old = drawable; + if( isCreated() && null != old && old.isRealized() ) { + if(!lockHeld) { + makeCurrent(); + } + associateDrawable(false); + if(!lockHeld) { + release(); + } + } if(lockHeld) { release(); - } else if(lock.isLockedByOtherThread()) { // still could glitch .. - throw new GLException("GLContext current by other thread "+lock.getOwner().getName()+", operation not allowed on this thread "+currentThread.getName()); - } + } if( !setWriteOnly || drawableRead == drawable ) { // if !setWriteOnly || !explicitReadDrawable drawableRead = (GLDrawableImpl) readWrite; } - final GLDrawableImpl old = drawable; - if( null != old ) { - old.associateContext(this, false); - } drawableRetargeted |= null != drawable && readWrite != drawable; drawable = (GLDrawableImpl) readWrite ; - if( null != drawable ) { - drawable.associateContext(this, true); - if( lockHeld ) { - makeCurrent(); + if( isCreated() && null != drawable && drawable.isRealized() ) { + makeCurrent(true); // implicit: associateDrawable(true) + if( !lockHeld ) { + release(); } } return old; @@ -363,8 +371,7 @@ public abstract class GLContextImpl extends GLContext { makeCurrent(); } try { - contextRealized(false); - drawable.associateContext(this, false); + associateDrawable(false); } catch (Throwable t) { drawableContextRealizedException = t; } @@ -467,7 +474,11 @@ public abstract class GLContextImpl extends GLContext { * @see #destroyContextARBImpl */ @Override - public int makeCurrent() throws GLException { + public final int makeCurrent() throws GLException { + return makeCurrent(false); + } + + protected final int makeCurrent(boolean forceDrawableAssociation) throws GLException { if( TRACE_SWITCH ) { System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.0]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - "+lock); } @@ -561,7 +572,11 @@ public abstract class GLContextImpl extends GLContext { gl = gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", null, gl, new Object[] { System.err } ) ); } - contextRealized(true); + forceDrawableAssociation = true; + } + + if( forceDrawableAssociation ) { + associateDrawable(true); } contextMadeCurrent(true); @@ -662,14 +677,14 @@ public abstract class GLContextImpl extends GLContext { protected abstract void makeCurrentImpl() throws GLException; /** - * @see GLDrawableImpl#contextRealized(GLContext, boolean) + * Calls {@link GLDrawableImpl#associateContext(GLContext, boolean)} */ - protected void contextRealized(boolean realized) { - drawable.contextRealized(this, realized); + protected void associateDrawable(boolean bound) { + drawable.associateContext(this, bound); } /** - * @see GLDrawableImpl#contextMadeCurrent(GLContext, boolean) + * Calls {@link GLDrawableImpl#contextMadeCurrent(GLContext, boolean)} */ protected void contextMadeCurrent(boolean current) { drawable.contextMadeCurrent(this, current); diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 3eedf918e..1caa942ba 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -59,7 +59,7 @@ import javax.media.opengl.GLFBODrawable; import javax.media.opengl.GLRunnable; /** Encapsulates the implementation of most of the GLAutoDrawable's - methods to be able to share it between GLCanvas and GLJPanel. */ + methods to be able to share it between GLAutoDrawable implementations like GLAutoDrawableBase, GLCanvas and GLJPanel. */ public class GLDrawableHelper { /** true if property jogl.debug.GLDrawable.PerfStats is defined. */ private static final boolean PERF_STATS = Debug.isPropertyDefined("jogl.debug.GLDrawable.PerfStats", true); @@ -113,6 +113,9 @@ public class GLDrawableHelper { return sb.toString(); } + /** Limit release calls of {@link #forceNativeRelease(GLContext)} to {@value}. */ + private static final int MAX_RELEASE_ITER = 512; + /** * Since GLContext's {@link GLContext#makeCurrent()} and {@link GLContext#release()} * is recursive, a call to {@link GLContext#release()} may not natively release the context. @@ -122,18 +125,25 @@ public class GLDrawableHelper { * @param ctx */ public static final void forceNativeRelease(GLContext ctx) { + int releaseCount = 0; do { ctx.release(); + releaseCount++; if (DEBUG) { - System.err.println("GLDrawableHelper.forceNativeRelease() -- currentThread "+Thread.currentThread()+" -> "+GLContext.getCurrent()); + System.err.println("GLDrawableHelper.forceNativeRelease() #"+releaseCount+" -- currentThread "+Thread.currentThread()+" -> "+GLContext.getCurrent()); } - } while( ctx == GLContext.getCurrent() ); + } while( MAX_RELEASE_ITER > releaseCount && ctx.isCurrent() ); + + if( ctx.isCurrent() ) { + throw new GLException("Context still current after "+MAX_RELEASE_ITER+" releases: "+ctx); + } } /** * Switch {@link GLContext} / {@link GLDrawable} association. *

    - * Dis-associate oldCtx from drawable + * The oldCtx will be destroyed if destroyPrevCtx is true, + * otherwise dis-associate oldCtx from drawable * via {@link GLContext#setGLDrawable(GLDrawable, boolean) oldCtx.setGLDrawable(null, true);}. *

    *

    @@ -149,31 +159,25 @@ public class GLDrawableHelper { * * @param drawable the drawable which context is changed * @param oldCtx the old context, maybe null. + * @param destroyOldCtx if true, destroy the oldCtx * @param newCtx the new context, maybe null for dis-association. * @param newCtxCreationFlags additional creation flags if newCtx is not null and not been created yet, see {@link GLContext#setContextCreationFlags(int)} - * @return true if the new context was current, otherwise false * - * @see GLAutoDrawable#setContext(GLContext) + * @see GLAutoDrawable#setContext(GLContext, boolean) */ - public static final boolean switchContext(GLDrawable drawable, GLContext oldCtx, GLContext newCtx, int newCtxCreationFlags) { + public static final void switchContext(GLDrawable drawable, GLContext oldCtx, boolean destroyOldCtx, GLContext newCtx, int newCtxCreationFlags) { if( null != oldCtx ) { - if( oldCtx.isCurrent() ) { - oldCtx.release(); + if( destroyOldCtx ) { + oldCtx.destroy(); + } else { + oldCtx.setGLDrawable(null, true); // dis-associate old pair } - oldCtx.setGLDrawable(null, true); // dis-associate old pair } - final boolean newCtxCurrent; + if(null!=newCtx) { - newCtxCurrent = newCtx.isCurrent(); - if(newCtxCurrent) { - newCtx.release(); - } newCtx.setContextCreationFlags(newCtxCreationFlags); - newCtx.setGLDrawable(drawable, true); // re-associate new pair - } else { - newCtxCurrent = false; + newCtx.setGLDrawable(drawable, true); // re-associate new pair } - return newCtxCurrent; } /** @@ -208,7 +212,6 @@ public class GLDrawableHelper { context.makeCurrent(); } context.getGL().glFinish(); - context.release(); context.setGLDrawable(null, true); // dis-associate } @@ -837,7 +840,7 @@ public class GLDrawableHelper { if( null != exclusiveContextThread ) { throw new GLException("Release current exclusive Context Thread "+exclusiveContextThread+" first"); } - if( null != context && GLContext.getCurrent() == context ) { + if( null != context && context.isCurrent() ) { try { forceNativeRelease(context); } catch (Throwable ex) { diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java index c0c28a5f2..d0c1461a9 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableImpl.java @@ -164,13 +164,14 @@ public abstract class GLDrawableImpl implements GLDrawable { @Override public final void setRealized(boolean realizedArg) { if ( realized != realizedArg ) { // volatile: OK (locked below) + final boolean isProxySurface = surface instanceof ProxySurface; if(DEBUG) { - System.err.println(getThreadName() + ": setRealized: "+getClass().getSimpleName()+" "+realized+" -> "+realizedArg); + System.err.println(getThreadName() + ": setRealized: drawable "+getClass().getSimpleName()+", surface "+surface.getClass().getSimpleName()+", isProxySurface "+isProxySurface+": "+realized+" -> "+realizedArg); Thread.dumpStack(); } AbstractGraphicsDevice aDevice = surface.getGraphicsConfiguration().getScreen().getDevice(); if(realizedArg) { - if(surface instanceof ProxySurface) { + if(isProxySurface) { ((ProxySurface)surface).createNotify(); } if(NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) { @@ -195,7 +196,7 @@ public abstract class GLDrawableImpl implements GLDrawable { unlockSurface(); } else { aDevice.unlock(); - if(surface instanceof ProxySurface) { + if(isProxySurface) { ((ProxySurface)surface).destroyNotify(); } } @@ -210,18 +211,26 @@ public abstract class GLDrawableImpl implements GLDrawable { */ protected abstract void setRealizedImpl(); - /** - * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: construct, destroy. + /** + * Callback for special implementations, allowing + *

      + *
    • to associate bound context to this drawable (bound == true) + * or to remove such association (bound == false).
    • + *
    • to trigger GLContext/GLDrawable related lifecycle: construct, destroy.
    • + *
    *

    - * If realized is true, the context has just been created and made current. + * If bound is true, the context is current and being newly associated w/ this drawable. *

    *

    - * If realized is false, the context is still current and will be released and destroyed after this method returns. + * If bound is false, the context is still current and will be unbound (released and destroyed, or simply disassociated). *

    *

    - * @see #contextMadeCurrent(GLContext, boolean) + * Being called by {@link GLContextImpl#associateDrawable(boolean)}. + *

    + * @param ctx the just bounded or unbounded context + * @param bound if true create an association, otherwise remove it */ - protected void contextRealized(GLContext glc, boolean realized) {} + protected void associateContext(GLContext ctx, boolean bound) { } /** * Callback for special implementations, allowing GLContext to trigger GL related lifecycle: makeCurrent, release. @@ -232,21 +241,12 @@ public abstract class GLDrawableImpl implements GLDrawable { * If current is false, the context is still current and will be release after this method returns. *

    *

    - * Note: Will also be called after {@link #contextRealized(GLContext, boolean) contextRealized(ctx, true)} - * but not at context destruction, i.e. {@link #contextRealized(GLContext, boolean) contextRealized(ctx, false)}. + * Being called by {@link GLContextImpl#contextMadeCurrent(boolean)}. *

    - * @see #contextRealized(GLContext, boolean) + * @see #associateContext(GLContext, boolean) */ protected void contextMadeCurrent(GLContext glc, boolean current) { } - /** - * Callback for special implementations, allowing to associate bound context to this drawable (bound == true) - * or to remove such association (bound == false). - * @param ctx the just bounded or unbounded context - * @param bound if true create an association, otherwise remove it - */ - protected void associateContext(GLContext ctx, boolean bound) { } - /** Callback for special implementations, allowing GLContext to fetch a custom default render framebuffer. Defaults to zero.*/ protected int getDefaultDrawFramebuffer() { return 0; } /** Callback for special implementations, allowing GLContext to fetch a custom default read framebuffer. Defaults to zero. */ diff --git a/src/jogl/classes/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/jogamp/opengl/GLEventListenerState.java index 7a2569850..2385460fe 100644 --- a/src/jogl/classes/jogamp/opengl/GLEventListenerState.java +++ b/src/jogl/classes/jogamp/opengl/GLEventListenerState.java @@ -45,7 +45,6 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLRunnable; -import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.MutableGraphicsConfiguration; /** @@ -71,11 +70,12 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; *

    */ public class GLEventListenerState { - private static final boolean DEBUG = true; + private static final boolean DEBUG = GLDrawableImpl.DEBUG; - private GLEventListenerState(AbstractGraphicsScreen upstreamScreen, AbstractGraphicsScreen screen, GLCapabilitiesImmutable caps, + private GLEventListenerState(AbstractGraphicsScreen upstreamScreen, boolean proxyOwnsUpstreamDevice, AbstractGraphicsScreen screen, GLCapabilitiesImmutable caps, GLContext context, int count, GLAnimatorControl anim) { this.upstreamScreen = upstreamScreen; + this.proxyOwnsUpstreamDevice = proxyOwnsUpstreamDevice; this.screen = screen; this.caps = caps; this.context = context; @@ -97,6 +97,7 @@ public class GLEventListenerState { public final int listenerCount() { return listeners.length; } public final AbstractGraphicsScreen upstreamScreen; + public final boolean proxyOwnsUpstreamDevice; public final AbstractGraphicsScreen screen; public final GLCapabilitiesImmutable caps; public final GLContext context; @@ -161,25 +162,30 @@ public class GLEventListenerState { } aScreen1.getDevice().clearHandleOwner(); // don't close device handle - final AbstractGraphicsScreen aUpScreen2; + final AbstractGraphicsScreen aUpScreen2; + final boolean proxyOwnsUpstreamDevice; { AbstractGraphicsScreen _aUpScreen2=null; if(aSurface instanceof ProxySurface) { final ProxySurface aProxy = (ProxySurface)aSurface; + proxyOwnsUpstreamDevice = aProxy.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); - if(null != aUpSurface) { + if(DEBUG && null != aUpSurface) { System.err.println("X00 UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface); } - aProxy.clearUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); // don't close device handle if(null != aUpSurface) { final AbstractGraphicsScreen aUpScreen1 = aUpSurface.getGraphicsConfiguration().getScreen(); _aUpScreen2 = cloneScreen(aUpScreen1); if(null != aUpScreen1) { aUpScreen1.getDevice().clearHandleOwner(); // don't close device handle } - System.err.println("X0X NativeSurface: "+aSurface.getClass().getName()+", "+aSurface); - System.err.println("X0X UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface); + if(DEBUG) { + System.err.println("X0X NativeSurface: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("X0X UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface); + } } + } else { + proxyOwnsUpstreamDevice = false; } aUpScreen2=_aUpScreen2; } @@ -189,7 +195,7 @@ public class GLEventListenerState { aAnim.remove(a); // also handles ECT } - final GLEventListenerState glls = new GLEventListenerState(aUpScreen2, aScreen2, caps, a.getContext(), aSz, aAnim); + final GLEventListenerState glls = new GLEventListenerState(aUpScreen2, proxyOwnsUpstreamDevice, aScreen2, caps, a.getContext(), aSz, aAnim); // // remove and cache all GLEventListener and their init-state @@ -205,7 +211,7 @@ public class GLEventListenerState { // a.invoke(true, glFinish); - a.setContext( null ); + a.setContext( null, false ); return glls; } @@ -241,13 +247,7 @@ public class GLEventListenerState { throw new GLException("Incompatible Capabilities - Prev-Holder: "+caps+", New-Holder "+caps); } // Destroy and remove currently associated GLContext, if any (will be replaced) - { - final GLContext ctx = a.getContext(); - if( null != ctx) { - ctx.destroy(); - } - a.setContext( null ); - } + a.setContext( null, true ); final boolean aRealized = a.isRealized(); if( aRealized ) { a.setRealized(false); @@ -260,8 +260,11 @@ public class GLEventListenerState { final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); aCfg.setScreen( screen ); aScreen1.getDevice().close(); - System.err.println("XXX NativeSurface: "+aSurface.getClass().getName()+", "+aSurface); + if( DEBUG ) { + System.err.println("XXX NativeSurface: "+aSurface.getClass().getName()+", "+aSurface); + } } + // If using a ProxySurface w/ an upstream surface, set new Screen and close previous one on it { boolean upstreamSet = false; @@ -270,13 +273,19 @@ public class GLEventListenerState { final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); if(null != aUpSurface) { final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration(); - final AbstractGraphicsScreen aUpScreen1 = aUpCfg.getScreen(); if( null != upstreamScreen ) { - System.err.println("XX0 UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface); + if( DEBUG ) { + System.err.println("XX0 UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); + } + aUpCfg.getScreen().getDevice().close(); aUpCfg.setScreen( upstreamScreen ); - aUpScreen1.getDevice().close(); + if( proxyOwnsUpstreamDevice ) { + aProxy.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } upstreamSet = true; - System.err.println("XXX UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface); + if( DEBUG ) { + System.err.println("XXX UpstreamSurface: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); + } } else { throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true"); } @@ -292,7 +301,7 @@ public class GLEventListenerState { } final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface(); try { - a.setContext( context ); + a.setContext( context, false ); } finally { if( surfaceLocked ) { aSurface.unlockSurface(); diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index 86cfa4f4c..51ec7dda6 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -38,6 +38,7 @@ import com.jogamp.opengl.JoglVersion; */ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { protected static final boolean DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject"); + protected static final boolean DEBUG_SWAP = Debug.isPropertyDefined("jogl.debug.FBObject.Swap", true); private final GLDrawableImpl parent; private GLCapabilitiesImmutable origParentChosenCaps; @@ -92,6 +93,9 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { } private final void initialize(boolean realize, GL gl) { + if( initialized == realize ) { + throw new InternalError("Already set to initialize := "+realize+": "+this); + } if(realize) { final GLCapabilities chosenFBOCaps = (GLCapabilities) getChosenGLCapabilities(); // cloned at setRealized(true) @@ -323,8 +327,8 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { } @Override - protected final void contextRealized(GLContext glc, boolean realized) { - initialize(realized, glc.getGL()); + protected void associateContext(GLContext glc, boolean bound) { + initialize(bound, glc.getGL()); } @Override @@ -338,7 +342,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { swapFBOImpl(glc); swapFBOImplPost(glc); fboBound=false; - if(DEBUG) { + if(DEBUG_SWAP) { System.err.println("Post FBO swap(@release): done"); } } @@ -354,7 +358,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { swapFBOImpl(ctx); doPostSwap = true; fboBound=false; - if(DEBUG) { + if(DEBUG_SWAP) { System.err.println("Post FBO swap(@swap): done"); } } @@ -406,7 +410,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { gl.glBindFramebuffer(GL2GL3.GL_READ_FRAMEBUFFER, fbos[fboIFront].getReadFramebuffer()); } */ - if(DEBUG) { + if(DEBUG_SWAP) { System.err.println("Post FBO swap(X): fboI back "+fboIBack+", front "+fboIFront+", num "+fbos.length); } } diff --git a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java index b438131bc..ddc6d5917 100644 --- a/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLPbufferImpl.java @@ -86,9 +86,10 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { // @Override - public final void setRealized(boolean realized) { + public final void swapBuffers() throws GLException { + defaultSwapBuffers(); } - + // // GLAutoDrawable completion // @@ -125,11 +126,6 @@ public class GLPbufferImpl extends GLAutoDrawableBase implements GLPbuffer { } } - @Override - public final void swapBuffers() throws GLException { - defaultSwapBuffers(); - } - //---------------------------------------------------------------------- // Internals only below this point // diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java index 342c4c417..77e9dc173 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLUpstreamSurfaceHook.java @@ -47,7 +47,7 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { public final void create(ProxySurface surface) { final String dbgPrefix; if(DEBUG) { - dbgPrefix = getThreadName() + ": EGLUpstreamSurfaceHook.create("+surface.getClass().getSimpleName()+"): "; + dbgPrefix = getThreadName() + ": EGLUpstreamSurfaceHook.create( up "+upstreamSurface.getClass().getSimpleName()+" -> this "+surface.getClass().getSimpleName()+" ): "; System.err.println(dbgPrefix+this); } else { dbgPrefix = null; @@ -76,24 +76,51 @@ public class EGLUpstreamSurfaceHook implements UpstreamSurfaceHook.MutableSize { boolean isEGLSurfaceValid = true; // assume yes - final AbstractGraphicsConfiguration aConfig = upstreamSurface.getGraphicsConfiguration(); - final AbstractGraphicsDevice aDevice = aConfig.getScreen().getDevice(); - final EGLGraphicsDevice eglDevice; - if( aDevice instanceof EGLGraphicsDevice ) { - eglDevice = (EGLGraphicsDevice) aDevice; + final AbstractGraphicsConfiguration aConfig; + { + final AbstractGraphicsConfiguration surfaceConfig = surface.getGraphicsConfiguration(); + final AbstractGraphicsDevice surfaceDevice = null != surfaceConfig ? surfaceConfig.getScreen().getDevice() : null; + if(DEBUG) { + System.err.println(dbgPrefix+"SurfaceDevice: "+surfaceDevice.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(surfaceDevice.hashCode())+", "+surfaceDevice); + System.err.println(dbgPrefix+"SurfaceConfig: "+surfaceConfig.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(surfaceConfig.hashCode())+", "+surfaceConfig); + } + + final AbstractGraphicsConfiguration upstreamConfig = upstreamSurface.getGraphicsConfiguration(); + final AbstractGraphicsDevice upstreamDevice = upstreamConfig.getScreen().getDevice(); if(DEBUG) { - System.err.println(dbgPrefix+"Reusing eglDevice: "+eglDevice); + System.err.println(dbgPrefix+"UpstreamDevice: "+upstreamDevice.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(upstreamDevice.hashCode())+", "+upstreamDevice); + System.err.println(dbgPrefix+"UpstreamConfig: "+upstreamConfig.getClass().getSimpleName()+", hash 0x"+Integer.toHexString(upstreamConfig.hashCode())+", "+upstreamConfig); } - if(EGL.EGL_NO_DISPLAY == eglDevice.getHandle()) { - eglDevice.open(); + + if( surfaceDevice instanceof EGLGraphicsDevice ) { + eglDevice = (EGLGraphicsDevice) surfaceDevice; + aConfig = surfaceConfig; + if(DEBUG) { + System.err.println(dbgPrefix+"Reusing this eglDevice: "+eglDevice+", using this config "+aConfig.getClass().getSimpleName()+" "+aConfig); + } + if(EGL.EGL_NO_DISPLAY == eglDevice.getHandle()) { + eglDevice.open(); + isEGLSurfaceValid = false; + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + } else if( upstreamDevice instanceof EGLGraphicsDevice ) { + eglDevice = (EGLGraphicsDevice) upstreamDevice; + aConfig = upstreamConfig; + if(DEBUG) { + System.err.println(dbgPrefix+"Reusing upstream eglDevice: "+eglDevice+", using upstream config "+aConfig.getClass().getSimpleName()+" "+aConfig); + } + if(EGL.EGL_NO_DISPLAY == eglDevice.getHandle()) { + eglDevice.open(); + isEGLSurfaceValid = false; + surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + } else { + eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(upstreamSurface); + aConfig = upstreamConfig; isEGLSurfaceValid = false; surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); } - } else { - eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(upstreamSurface); - isEGLSurfaceValid = false; - surface.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); } final GLCapabilitiesImmutable capsRequested = (GLCapabilitiesImmutable) aConfig.getRequestedCapabilities(); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 3825f855c..a03850043 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -85,10 +85,9 @@ public abstract class MacOSXCGLContext extends GLContextImpl // NSOpenGL-based or CGL-based) protected interface GLBackendImpl { boolean isNSContext(); - void drawableChangedNotify(); long create(long share, int ctp, int major, int minor); boolean destroy(long ctx); - boolean contextRealized(boolean realized); + void associateDrawable(boolean bound); boolean copyImpl(long src, int mask); boolean makeCurrent(long ctx); boolean release(long ctx); @@ -328,20 +327,15 @@ public abstract class MacOSXCGLContext extends GLContextImpl } @Override - protected void contextRealized(boolean realized) { + protected void associateDrawable(boolean bound) { // context stuff depends on drawable stuff - if(realized) { - super.contextRealized(true); // 1) init drawable stuff - impl.contextRealized(true); // 2) init context stuff + System.err.println("MaxOSXCGLContext.associateDrawable: "+bound); + if(bound) { + super.associateDrawable(true); // 1) init drawable stuff + impl.associateDrawable(true); // 2) init context stuff } else { - impl.contextRealized(false); // 1) free context stuff - super.contextRealized(false); // 2) free drawable stuff - } - } - - /* pp */ void drawableChangedNotify() { - if( 0 != contextHandle) { - impl.drawableChangedNotify(); + impl.associateDrawable(false); // 1) free context stuff + super.associateDrawable(false); // 2) free drawable stuff } } @@ -467,9 +461,8 @@ public abstract class MacOSXCGLContext extends GLContextImpl // NSOpenGLContext-based implementation class NSOpenGLImpl implements GLBackendImpl { - private OffscreenLayerSurface backingLayerHost = null; - private long nsOpenGLLayer = 0; - private long nsOpenGLLayerPFmt = 0; // lifecycle: [create - contextRealized] + private long pixelFormat = 0; // lifecycle: [create - destroy] + private long nsOpenGLLayer = 0; // lifecycle: [associateDrawable_true - associateDrawable_false] private float screenVSyncTimeout; // microSec private int vsyncTimeout; // microSec - for nsOpenGLLayer mode private int lastWidth=0, lastHeight=0; // allowing to detect size change @@ -479,18 +472,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override public boolean isNSContext() { return true; } - @Override - public void drawableChangedNotify() { - backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(drawable.getNativeSurface(), true); - if( null == backingLayerHost ) { - boolean[] isPBuffer = { false }; - boolean[] isFBO = { false }; - CGL.setContextView(contextHandle, getNSViewHandle(isPBuffer, isFBO)); - } else { - nsOpenGLLayer = backingLayerHost.getAttachedSurfaceLayer(); - } - } - private long getNSViewHandle(boolean[] isPBuffer, boolean[] isFBO) { final long nsViewHandle; if(drawable instanceof GLFBODrawableImpl) { @@ -549,13 +530,12 @@ public abstract class MacOSXCGLContext extends GLContextImpl isPBuffer = _isPBuffer[0]; isFBO = _isFBO[0]; } - backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); + final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); boolean incompleteView = null != backingLayerHost; if( !incompleteView && surface instanceof ProxySurface ) { incompleteView = ((ProxySurface)surface).containsUpstreamOptionBits( ProxySurface.OPT_UPSTREAM_WINDOW_INVISIBLE ); } - long pixelFormat; { final GLCapabilitiesImmutable targetCaps; if( isFBO ) { @@ -606,48 +586,54 @@ public abstract class MacOSXCGLContext extends GLContextImpl } config.setChosenCapabilities(fixedCaps); - try { - final IntBuffer viewNotReady = Buffers.newDirectIntBuffer(1); - // Try to allocate a context with this - ctx = CGL.createContext(share, - nsViewHandle, incompleteView, - pixelFormat, - chosenCaps.isBackgroundOpaque(), - viewNotReady); - if (0 == ctx) { - if(DEBUG) { - System.err.println("NS create failed: viewNotReady: "+ (1 == viewNotReady.get(0))); - } - return 0; + final IntBuffer viewNotReady = Buffers.newDirectIntBuffer(1); + // Try to allocate a context with this + ctx = CGL.createContext(share, nsViewHandle, incompleteView, + pixelFormat, chosenCaps.isBackgroundOpaque(), viewNotReady); + if (0 == ctx) { + if(DEBUG) { + System.err.println("NS create failed: viewNotReady: "+ (1 == viewNotReady.get(0))); } + return 0; + } - if(null != backingLayerHost) { - nsOpenGLLayerPFmt = pixelFormat; - pixelFormat = 0; - } - - if (chosenCaps.isOnscreen() && !chosenCaps.isBackgroundOpaque()) { - // Set the context opacity - CGL.setContextOpacity(ctx, 0); - } - } finally { - if(0!=pixelFormat) { - CGL.deletePixelFormat(pixelFormat); - pixelFormat = 0; - } + if (chosenCaps.isOnscreen() && !chosenCaps.isBackgroundOpaque()) { + // Set the context opacity + CGL.setContextOpacity(ctx, 0); } return ctx; } @Override public boolean destroy(long ctx) { + if(0!=pixelFormat) { + CGL.deletePixelFormat(pixelFormat); + pixelFormat = 0; + } return CGL.deleteContext(ctx, true); + } @Override - public boolean contextRealized(boolean realized) { - if( realized ) { + public void associateDrawable(boolean bound) { + final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(drawable.getNativeSurface(), true); + + if(DEBUG) { + System.err.println("MaxOSXCGLContext.NSOpenGLImpl.associateDrawable: "+bound+", ctx "+toHexString(contextHandle)+", hasBackingLayerHost "+(null!=backingLayerHost)); + } + + if( bound ) { + if( null != backingLayerHost ) { + + if( 0 != nsOpenGLLayer ) { // FIXME: redundant + throw new InternalError("Lifecycle: bound=true, hasBackingLayerHost=true, but 'nsOpenGLLayer' is already/still set local: "+nsOpenGLLayer+", "+this); + } + nsOpenGLLayer = backingLayerHost.getAttachedSurfaceLayer(); + if( 0 != nsOpenGLLayer ) { // FIXME: redundant + throw new InternalError("Lifecycle: bound=true, hasBackingLayerHost=true, but 'nsOpenGLLayer' is already/still set on backingLayerHost: "+nsOpenGLLayer+", "+this); + } + // // handled layered surface // @@ -700,8 +686,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl } final boolean ctxUnlocked = CGL.kCGLNoError == CGL.CGLUnlockContext(cglCtx); try { - nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, gl3ShaderProgramName, nsOpenGLLayerPFmt, pbufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight); - nsOpenGLLayerPFmt = 0; // NSOpenGLLayer will release pfmt + nsOpenGLLayer = CGL.createNSOpenGLLayer(ctx, gl3ShaderProgramName, pixelFormat, pbufferHandle, texID, chosenCaps.isBackgroundOpaque(), lastWidth, lastHeight); if (DEBUG) { System.err.println("NS create nsOpenGLLayer "+toHexString(nsOpenGLLayer)+" w/ pbuffer "+toHexString(pbufferHandle)+", texID "+texID+", texSize "+lastWidth+"x"+lastHeight+", "+drawable); } @@ -718,17 +703,22 @@ public abstract class MacOSXCGLContext extends GLContextImpl } else { lastWidth = drawable.getWidth(); lastHeight = drawable.getHeight(); + boolean[] isPBuffer = { false }; + boolean[] isFBO = { false }; + CGL.setContextView(contextHandle, getNSViewHandle(isPBuffer, isFBO)); } } else { if( 0 != nsOpenGLLayer ) { - final NativeSurface surface = drawable.getNativeSurface(); + if( null == backingLayerHost ) { // FIXME: redundant + throw new InternalError("Lifecycle: bound=false, hasNSOpneGLLayer=true, but 'backingLayerHost' is null local: "+nsOpenGLLayer+", "+this); + } + if (DEBUG) { System.err.println("NS destroy nsOpenGLLayer "+toHexString(nsOpenGLLayer)+", "+drawable); } - final OffscreenLayerSurface ols = NativeWindowFactory.getOffscreenLayerSurface(surface, true); - if(null != ols && ols.isSurfaceLayerAttached()) { + if( backingLayerHost.isSurfaceLayerAttached() ) { // still having a valid OLS attached to surface (parent OLS could have been removed) - ols.detachSurfaceLayer(); + backingLayerHost.detachSurfaceLayer(); } CGL.releaseNSOpenGLLayer(nsOpenGLLayer); if( null != gl3ShaderProgram ) { @@ -738,8 +728,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl nsOpenGLLayer = 0; } } - backingLayerHost = null; - return true; } private final void validatePBufferConfig(long ctx) { @@ -888,11 +876,6 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override public boolean isNSContext() { return false; } - @Override - public void drawableChangedNotify() { - // FIXME - } - @Override public long create(long share, int ctp, int major, int minor) { long ctx = 0; @@ -947,8 +930,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl } @Override - public boolean contextRealized(boolean realized) { - return true; + public void associateDrawable(boolean bound) { } @Override diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index ff1772860..0f282d33f 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -119,7 +119,6 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { if(bound) { final MacOSXCGLContext osxCtx = (MacOSXCGLContext)ctx; createdContexts.add(new WeakReference(osxCtx)); - osxCtx.drawableChangedNotify(); } else { for(int i=0; i ref = createdContexts.get(i); diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 2cf74380c..abc9d7958 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -275,7 +275,7 @@ static const GLfloat gl_verts[] = { vboBufTexCoord = 0; vertAttrLoc = 0; texCoordAttrLoc = 0; - parentPixelFmt = _parentPixelFmt; + parentPixelFmt = [_parentPixelFmt retain]; // until destruction swapInterval = 1; // defaults to on (as w/ new GL profiles) swapIntervalCounter = 0; timespec_now(&lastWaitTime); @@ -338,13 +338,13 @@ static const GLfloat gl_verts[] = { #ifdef VERBOSE_ON CGRect lRect = [self bounds]; if(NULL != pbuffer) { - DBG_PRINT("MyNSOpenGLLayer::init (pbuffer) %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, bounds: %lf/%lf %lfx%lf (refcnt %d)\n", + DBG_PRINT("MyNSOpenGLLayer::init (pbuffer) %p, ctx %p, pfmt %p, pbuffer %p, opaque %d, pbuffer %dx%d -> tex %dx%d, bounds: %lf/%lf %lfx%lf, displayLink %p (refcnt %d)\n", self, parentCtx, parentPixelFmt, pbuffer, opaque, [pbuffer pixelsWide], [pbuffer pixelsHigh], texWidth, texHeight, - lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, displayLink, (int)[self retainCount]); } else { - DBG_PRINT("MyNSOpenGLLayer::init (texture) %p, ctx %p, pfmt %p, opaque %d, tex[id %d, %dx%d], bounds: %lf/%lf %lfx%lf (refcnt %d)\n", + DBG_PRINT("MyNSOpenGLLayer::init (texture) %p, ctx %p, pfmt %p, opaque %d, tex[id %d, %dx%d], bounds: %lf/%lf %lfx%lf, displayLink %p (refcnt %d)\n", self, parentCtx, parentPixelFmt, opaque, (int)textureID, texWidth, texHeight, - lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, (int)[self retainCount]); + lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, displayLink, (int)[self retainCount]); } #endif return self; @@ -498,7 +498,10 @@ static const GLfloat gl_verts[] = { myCtx = NULL; } parentCtx = NULL; - [parentPixelFmt release]; + if( NULL != parentPixelFmt ) { + [parentPixelFmt release]; + parentPixelFmt = NULL; + } pthread_mutex_unlock(&renderLock); [self release]; DBG_PRINT("MyNSOpenGLLayer::releaseLayer.X: %p\n", self); @@ -623,7 +626,7 @@ static const GLfloat gl_verts[] = { { DBG_PRINT("MyNSOpenGLLayer::openGLPixelFormatForDisplayMask: %p (refcnt %d) - parent-pfmt %p -> new-pfmt %p\n", self, (int)[self retainCount], parentPixelFmt, parentPixelFmt); - // We simply take over ownership of parent PixelFormat .. + // We simply take over ownership of parent PixelFormat until releaseLayer.. return parentPixelFmt; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java deleted file mode 100644 index cce4149ba..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLContextDrawableSwitch01NEWT.java +++ /dev/null @@ -1,374 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.io.IOException; - -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Window; -import com.jogamp.newt.event.WindowAdapter; -import com.jogamp.newt.event.WindowEvent; -import com.jogamp.newt.event.WindowListener; -import com.jogamp.newt.event.WindowUpdateEvent; -import com.jogamp.newt.opengl.GLWindow; - -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLProfile; - -import com.jogamp.opengl.GLAutoDrawableDelegate; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLDrawableUtil; - -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.QuitAdapter; -import com.jogamp.opengl.test.junit.util.UITestCase; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -/** - * Test re-association (switching) of GLContext/GLDrawables, - * i.e. ctx1/draw1, ctx2/draw2 -> ctx1/draw2, ctx2/draw1. - */ -public class TestGLContextDrawableSwitch01NEWT extends UITestCase { - static int width, height; - - static GLCapabilities getCaps(String profile) { - if( !GLProfile.isAvailable(profile) ) { - System.err.println("Profile "+profile+" n/a"); - return null; - } - return new GLCapabilities(GLProfile.get(profile)); - } - - @BeforeClass - public static void initClass() { - width = 256; - height = 256; - } - - private GLAutoDrawable createGLAutoDrawable(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException { - final Window window = NewtFactory.createWindow(caps); - Assert.assertNotNull(window); - window.setPosition(x, y); - window.setSize(width, height); - window.setVisible(true); - Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); - - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLDrawable drawable = factory.createGLDrawable(window); - Assert.assertNotNull(drawable); - - drawable.setRealized(true); - Assert.assertTrue(drawable.isRealized()); - - final GLContext context = drawable.createContext(null); - Assert.assertNotNull(context); - - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) { - @Override - protected void destroyImplInLock() { - super.destroyImplInLock(); - window.destroy(); // destroys the actual window - } - }; - - window.setWindowDestroyNotifyAction( new Runnable() { - public void run() { - glad.windowDestroyNotifyOp(); - } } ); - - // add basic window interaction - window.addWindowListener(new WindowAdapter() { - @Override - public void windowRepaint(WindowUpdateEvent e) { - glad.windowRepaintOp(); - } - @Override - public void windowResized(WindowEvent e) { - glad.windowResizedOp(window.getWidth(), window.getHeight()); - } - }); - window.addWindowListener(wl); - - return glad; - } - - @Test(timeout=30000) - public void testSwitch2WindowSingleContextGL2ES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); - if(null == reqGLCaps) return; - testSwitch2WindowSingleContextImpl(reqGLCaps); - } - - @Test(timeout=30000) - public void testSwitch2WindowSingleContextGLES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); - if(null == reqGLCaps) return; - testSwitch2WindowSingleContextImpl(reqGLCaps); - } - - private void testSwitch2WindowSingleContextImpl(GLCapabilities caps) throws InterruptedException { - final QuitAdapter quitAdapter = new QuitAdapter(); - - GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); - GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); - - // create single context using glad1 and assign it to glad1, - // destroy the prev. context afterwards. - { - final GLContext newCtx = glad1.createContext(null); - Assert.assertNotNull(newCtx); - final GLContext oldCtx = glad1.setContext(newCtx); - Assert.assertNotNull(oldCtx); - oldCtx.destroy(); - final int res = newCtx.makeCurrent(); - Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); - newCtx.release(); - } - - final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); - GearsES2 gears = new GearsES2(1); - glad1.addGLEventListener(gears); - glad1.addGLEventListener(snapshotGLEventListener); - snapshotGLEventListener.setMakeSnapshot(); - - Animator animator = new Animator(); - animator.add(glad1); - animator.add(glad2); - animator.start(); - - int s = 0; - long t0 = System.currentTimeMillis(); - long t1 = t0; - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { - if( ( t1 - t0 ) / period > s) { - s++; - System.err.println(s+" - switch - START "+ ( t1 - t0 )); - - // switch context _and_ the demo synchronously - GLDrawableUtil.swapGLContextAndAllGLEventListener(glad1, glad2); - - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - } - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - animator.stop(); - glad1.destroy(); - glad2.destroy(); - } - - @Test(timeout=30000) - public void testSwitch2GLWindowOneDemoGL2ES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); - if(null == reqGLCaps) return; - testSwitch2GLWindowOneDemoImpl(reqGLCaps); - } - - @Test(timeout=30000) - public void testSwitch2GLWindowOneDemoGLES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); - if(null == reqGLCaps) return; - testSwitch2GLWindowOneDemoImpl(reqGLCaps); - } - - private void testSwitch2GLWindowOneDemoImpl(GLCapabilities caps) throws InterruptedException { - final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); - final GearsES2 gears = new GearsES2(1); - final QuitAdapter quitAdapter = new QuitAdapter(); - - GLWindow glWindow1 = GLWindow.create(caps); - glWindow1.setTitle("win1"); - glWindow1.setSize(width, height); - glWindow1.setPosition(64, 64); - glWindow1.addGLEventListener(0, gears); - glWindow1.addGLEventListener(snapshotGLEventListener); - glWindow1.addWindowListener(quitAdapter); - - GLWindow glWindow2 = GLWindow.create(caps); - glWindow2.setTitle("win2"); - glWindow2.setSize(width+100, height+100); - glWindow2.setPosition(2*64+width, 64); - glWindow2.addWindowListener(quitAdapter); - - Animator animator = new Animator(); - animator.add(glWindow1); - animator.add(glWindow2); - animator.start(); - - glWindow1.setVisible(true); - glWindow2.setVisible(true); - - snapshotGLEventListener.setMakeSnapshot(); - - int s = 0; - long t0 = System.currentTimeMillis(); - long t1 = t0; - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { - if( ( t1 - t0 ) / period > s) { - s++; - System.err.println(s+" - switch - START "+ ( t1 - t0 )); - System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - - // switch context _and_ the demo synchronously - GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); - - System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - - snapshotGLEventListener.setMakeSnapshot(); - } - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - animator.stop(); - glWindow1.destroy(); - glWindow2.destroy(); - - } - - @Test(timeout=30000) - public void testSwitch2GLWindowEachWithOwnDemoGL2ES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); - if(null == reqGLCaps) return; - testSwitch2GLWindowEachWithOwnDemoImpl(reqGLCaps); - } - - @Test(timeout=30000) - public void testSwitch2GLWindowEachWithOwnDemoGLES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); - if(null == reqGLCaps) return; - testSwitch2GLWindowEachWithOwnDemoImpl(reqGLCaps); - } - - public void testSwitch2GLWindowEachWithOwnDemoImpl(GLCapabilities caps) throws InterruptedException { - final GearsES2 gears = new GearsES2(1); - final RedSquareES2 rsquare = new RedSquareES2(1); - final QuitAdapter quitAdapter = new QuitAdapter(); - final SnapshotGLEventListener snapshotGLEventListener1 = new SnapshotGLEventListener(); - final SnapshotGLEventListener snapshotGLEventListener2 = new SnapshotGLEventListener(); - - GLWindow glWindow1 = GLWindow.create(caps); - glWindow1.setTitle("win1"); - glWindow1.setSize(width, height); - glWindow1.setPosition(64, 64); - glWindow1.addGLEventListener(0, gears); - glWindow1.addGLEventListener(snapshotGLEventListener1); - glWindow1.addWindowListener(quitAdapter); - - GLWindow glWindow2 = GLWindow.create(caps); - glWindow2.setTitle("win2"); - glWindow2.setSize(width+100, height+100); - glWindow2.setPosition(2*64+width, 64); - glWindow2.addGLEventListener(0, rsquare); - glWindow2.addGLEventListener(snapshotGLEventListener2); - glWindow2.addWindowListener(quitAdapter); - - Animator animator = new Animator(); - animator.add(glWindow1); - animator.add(glWindow2); - animator.start(); - - glWindow1.setVisible(true); - glWindow2.setVisible(true); - - snapshotGLEventListener1.setMakeSnapshot(); - snapshotGLEventListener2.setMakeSnapshot(); - - int s = 0; - long t0 = System.currentTimeMillis(); - long t1 = t0; - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { - if( ( t1 - t0 ) / period > s) { - s++; - System.err.println(s+" - switch - START "+ ( t1 - t0 )); - System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); - System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); - System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); - System.err.println(s+" - switch - END "+ ( t1 - t0 )); - snapshotGLEventListener1.setMakeSnapshot(); - snapshotGLEventListener2.setMakeSnapshot(); - } - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - animator.stop(); - // System.err.println("pre -del-w1: w1: "+glWindow1); - // System.err.println("pre -del-w1: w2: "+glWindow2); - glWindow1.destroy(); - // System.err.println("post-del-w1: w1: "+glWindow1); - // System.err.println("post-del-w1: w2: "+glWindow2); - glWindow2.destroy(); - - } - - // default timing for 2 switches - static long duration = 2200; // ms - static long period = 1000; // ms - - public static void main(String args[]) throws IOException { - for(int i=0; i - * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665. - *

    - */ -public class TestGLContextDrawableSwitch11NEWT extends UITestCase { - static int width, height; - - static GLCapabilities getCaps(String profile) { - if( !GLProfile.isAvailable(profile) ) { - System.err.println("Profile "+profile+" n/a"); - return null; - } - return new GLCapabilities(GLProfile.get(profile)); - } - - @BeforeClass - public static void initClass() { - width = 256; - height = 256; - } - - private GLAutoDrawable createGLAutoDrawableWithoutContext(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException { - final Window window = NewtFactory.createWindow(caps); - Assert.assertNotNull(window); - window.setPosition(x, y); - window.setSize(width, height); - window.setVisible(true); - Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); - - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLDrawable drawable = factory.createGLDrawable(window); - Assert.assertNotNull(drawable); - - drawable.setRealized(true); - Assert.assertTrue(drawable.isRealized()); - - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false, null) { - @Override - protected void destroyImplInLock() { - super.destroyImplInLock(); - window.destroy(); // destroys the actual window - } - }; - - window.setWindowDestroyNotifyAction( new Runnable() { - public void run() { - glad.windowDestroyNotifyOp(); - } } ); - - // add basic window interaction - window.addWindowListener(new WindowAdapter() { - @Override - public void windowRepaint(WindowUpdateEvent e) { - glad.windowRepaintOp(); - } - @Override - public void windowResized(WindowEvent e) { - glad.windowResizedOp(window.getWidth(), window.getHeight()); - } - }); - window.addWindowListener(wl); - - return glad; - } - - @Test(timeout=30000) - public void test01GLADDelegateGL2ES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); - if(null == reqGLCaps) return; - test01GLADDelegateImpl(reqGLCaps); - } - - @Test(timeout=30000) - public void test01GLADDelegateGLES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); - if(null == reqGLCaps) return; - test01GLADDelegateImpl(reqGLCaps); - } - - private void test01GLADDelegateImpl(GLCapabilities caps) throws InterruptedException { - final QuitAdapter quitAdapter = new QuitAdapter(); - - final GLEventListenerCounter glelCounter = new GLEventListenerCounter(); - final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); - final Animator animator = new Animator(); - animator.start(); - - final long t0 = System.currentTimeMillis(); - final GLEventListenerState glls1; - - // - create glad1 w/o context - // - create context using glad1 and assign it to glad1 - { - final GLAutoDrawable glad1 = createGLAutoDrawableWithoutContext(caps, 64, 64, width, height, quitAdapter); - final GLContext context1 = glad1.createContext(null); - glad1.setContext(context1); - animator.add(glad1); - - glad1.addGLEventListener(glelCounter); - glad1.addGLEventListener(new GearsES2(1)); - glad1.addGLEventListener(snapshotGLEventListener); - snapshotGLEventListener.setMakeSnapshot(); - - long t1 = System.currentTimeMillis(); - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/2 ) { - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - Assert.assertEquals(1, glelCounter.initCount); - Assert.assertTrue(1 <= glelCounter.reshapeCount); - Assert.assertTrue(1 <= glelCounter.displayCount); - Assert.assertEquals(0, glelCounter.disposeCount); - Assert.assertEquals(context1, glad1.getContext()); - Assert.assertEquals(3, glad1.getGLEventListenerCount()); - Assert.assertEquals(context1.getGLReadDrawable(), glad1.getDelegatedDrawable()); - Assert.assertEquals(context1.getGLDrawable(), glad1.getDelegatedDrawable()); - - // - dis-associate context from glad1 - // - destroy glad1 - glls1 = GLEventListenerState.moveFrom(glad1); - - Assert.assertEquals(1, glelCounter.initCount); - Assert.assertTrue(1 <= glelCounter.reshapeCount); - Assert.assertTrue(1 <= glelCounter.displayCount); - Assert.assertEquals(0, glelCounter.disposeCount); - Assert.assertEquals(context1, glls1.context); - Assert.assertNull(context1.getGLReadDrawable()); - Assert.assertNull(context1.getGLDrawable()); - Assert.assertEquals(3, glls1.listenerCount()); - Assert.assertEquals(true, glls1.isOwner()); - Assert.assertEquals(null, glad1.getContext()); - Assert.assertEquals(0, glad1.getGLEventListenerCount()); - - glad1.destroy(); - Assert.assertEquals(1, glelCounter.initCount); - Assert.assertTrue(1 <= glelCounter.reshapeCount); - Assert.assertTrue(1 <= glelCounter.displayCount); - Assert.assertEquals(0, glelCounter.disposeCount); - } - - // - create glad2 w/ survived context - { - final GLAutoDrawable glad2 = createGLAutoDrawableWithoutContext(caps, 2*64+width, 64, width+100, height+100, quitAdapter); - snapshotGLEventListener.setMakeSnapshot(); - - Assert.assertEquals(null, glad2.getContext()); - Assert.assertEquals(0, glad2.getGLEventListenerCount()); - - glls1.moveTo(glad2); - - Assert.assertTrue(glad2.isRealized()); - - Assert.assertEquals(1, glelCounter.initCount); - Assert.assertTrue(1 <= glelCounter.reshapeCount); - Assert.assertTrue(1 <= glelCounter.displayCount); - Assert.assertEquals(0, glelCounter.disposeCount); - Assert.assertEquals(glls1.context, glad2.getContext()); - Assert.assertEquals(3, glad2.getGLEventListenerCount()); - Assert.assertEquals(glls1.context.getGLReadDrawable(), glad2.getDelegatedDrawable()); - Assert.assertEquals(glls1.context.getGLDrawable(), glad2.getDelegatedDrawable()); - Assert.assertEquals(false, glls1.isOwner()); - - long t1 = System.currentTimeMillis(); - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/1 ) { - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - glad2.destroy(); - Assert.assertEquals(1, glelCounter.initCount); - Assert.assertTrue(1 <= glelCounter.reshapeCount); - Assert.assertTrue(1 <= glelCounter.displayCount); - Assert.assertEquals(1, glelCounter.disposeCount); - } - animator.stop(); - } - - @Test(timeout=30000) - public void test02GLWindowGL2ES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); - if(null == reqGLCaps) return; - test02GLWindowImpl(reqGLCaps); - } - - @Test(timeout=30000) - public void test02GLWindowGLES2() throws InterruptedException { - final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); - if(null == reqGLCaps) return; - test02GLWindowImpl(reqGLCaps); - } - - private void test02GLWindowImpl(GLCapabilities caps) throws InterruptedException { - final QuitAdapter quitAdapter = new QuitAdapter(); - - final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); - final GLEventListenerCounter glelTracker = new GLEventListenerCounter(); - final Animator animator = new Animator(); - animator.start(); - - final long t0 = System.currentTimeMillis(); - final GLEventListenerState glls1; - - // - create glad1 w/o context - // - create context using glad1 and assign it to glad1 - { - final GLWindow glad1 = GLWindow.create(caps); - glad1.setSize(width, height); - glad1.setPosition(64, 64); - glad1.addWindowListener(quitAdapter); - animator.add(glad1); - - glad1.addGLEventListener(glelTracker); - glad1.addGLEventListener(new GearsES2(1)); - glad1.addGLEventListener(snapshotGLEventListener); - snapshotGLEventListener.setMakeSnapshot(); - - glad1.setVisible(true); - - long t1 = System.currentTimeMillis(); - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/2 ) { - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - // - dis-associate context from glad1 - // - destroy glad1 - Assert.assertEquals(1, glelTracker.initCount); - Assert.assertTrue(1 <= glelTracker.reshapeCount); - Assert.assertTrue(1 <= glelTracker.displayCount); - Assert.assertEquals(0, glelTracker.disposeCount); - Assert.assertEquals(3, glad1.getGLEventListenerCount()); - Assert.assertEquals(glad1.getContext().getGLReadDrawable(), glad1.getDelegatedDrawable()); - Assert.assertEquals(glad1.getContext().getGLDrawable(), glad1.getDelegatedDrawable()); - - final GLContext context1 = glad1.getContext(); - glls1 = GLEventListenerState.moveFrom(glad1); - - Assert.assertEquals(1, glelTracker.initCount); - Assert.assertTrue(1 <= glelTracker.reshapeCount); - Assert.assertTrue(1 <= glelTracker.displayCount); - Assert.assertEquals(0, glelTracker.disposeCount); - Assert.assertEquals(context1, glls1.context); - Assert.assertNull(context1.getGLReadDrawable()); - Assert.assertNull(context1.getGLDrawable()); - Assert.assertEquals(3, glls1.listenerCount()); - Assert.assertEquals(true, glls1.isOwner()); - Assert.assertEquals(null, glad1.getContext()); - Assert.assertEquals(0, glad1.getGLEventListenerCount()); - - glad1.destroy(); - Assert.assertEquals(1, glelTracker.initCount); - Assert.assertTrue(1 <= glelTracker.reshapeCount); - Assert.assertTrue(1 <= glelTracker.displayCount); - Assert.assertEquals(0, glelTracker.disposeCount); - } - - // - create glad2 w/ survived context - { - final GLWindow glad2 = GLWindow.create(caps); - glad2.setSize(width+100, height+100); - glad2.setPosition(2*64+width, 64); - glad2.addWindowListener(quitAdapter); - snapshotGLEventListener.setMakeSnapshot(); - glad2.setVisible(true); - - Assert.assertNotNull(glad2.getContext()); - Assert.assertEquals(0, glad2.getGLEventListenerCount()); - - glls1.moveTo(glad2); - - Assert.assertEquals(1, glelTracker.initCount); - Assert.assertTrue(1 <= glelTracker.reshapeCount); - Assert.assertTrue(1 <= glelTracker.displayCount); - Assert.assertEquals(0, glelTracker.disposeCount); - Assert.assertEquals(glls1.context, glad2.getContext()); - Assert.assertEquals(3, glad2.getGLEventListenerCount()); - Assert.assertEquals(glls1.context.getGLReadDrawable(), glad2.getDelegatedDrawable()); - Assert.assertEquals(glls1.context.getGLDrawable(), glad2.getDelegatedDrawable()); - Assert.assertEquals(false, glls1.isOwner()); - - long t1 = System.currentTimeMillis(); - - while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration/1 ) { - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - glad2.destroy(); - Assert.assertEquals(1, glelTracker.initCount); - Assert.assertTrue(1 <= glelTracker.reshapeCount); - Assert.assertTrue(1 <= glelTracker.displayCount); - Assert.assertEquals(1, glelTracker.disposeCount); - } - animator.stop(); - } - - // default timing for 2 switches - static long duration = 2200; // ms - - public static void main(String args[]) throws IOException { - for(int i=0; i + * Test utilizes {@link GLEventListenerState} for preserving the + * GLAutoDrawable state, i.e. GLContext, all GLEventListener + * and the GLAnimatorControl association. + *

    + *

    + * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665. + *

    + */ +public abstract class GLContextDrawableSwitchBase extends UITestCase { + static protected enum GLADType { GLCanvasOnscreen, GLCanvasOffscreen, GLWindow, GLOffscreen }; + + // default period for 1 GLAD cycle + static long duration = 1000; // ms + + static int width, height; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + @BeforeClass + public static void initClass() { + width = 256; + height = 256; + } + + static void setGLCanvasSize(final GLCanvas glc, final Dimension new_sz) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + glc.setMinimumSize(new_sz); + glc.setPreferredSize(new_sz); + glc.setSize(new_sz); + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + static void setFrameVisible(final Frame frame) throws InterruptedException { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + static void destroyFrame(final Frame frame) throws InterruptedException { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.dispose(); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + private GLOffscreenAutoDrawable createGLOffscreenAutoDrawable(GLCapabilities caps, int width, int height) throws InterruptedException { + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + return factory.createOffscreenAutoDrawable(null, caps, null, width, height, null); + } + + protected static boolean validateOnOffscreenLayer(GLADType gladType1, GLADType gladType2) { + final boolean useOffscreenLayer = GLADType.GLCanvasOffscreen == gladType1 || GLADType.GLCanvasOffscreen == gladType2 ; + final boolean useOnscreenLayer = GLADType.GLCanvasOnscreen == gladType1 || GLADType.GLCanvasOnscreen == gladType2 ; + if( useOffscreenLayer ) { + if( !JAWTUtil.isOffscreenLayerSupported() ) { + System.err.println("Platform doesn't support offscreen rendering."); + return false; + } + } else if( useOnscreenLayer ) { + if( JAWTUtil.isOffscreenLayerRequired() ) { + System.err.println("Platform requires offscreen rendering."); + return false; + } + } + return true; + } + + protected void testGLADOneLifecycle(GLCapabilities caps, GLADType gladType, int width, int height, + GLEventListenerCounter glelTracker, SnapshotGLEventListener snapshotGLEventListener, + GLEventListenerState glelsIn, GLEventListenerState glelsOut[], GLAnimatorControl animator) + throws InterruptedException { + + final Frame frame; + final GLAutoDrawable glad; + if( GLADType.GLCanvasOnscreen == gladType ) { + if( jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerRequired() ) { + throw new InternalError("Platform requires offscreen rendering, but onscreen requested: "+gladType); + } + frame = new Frame("AWT GLCanvas"); + + glad = new GLCanvas(caps); + setGLCanvasSize((GLCanvas)glad, new Dimension(width, height)); + frame.add((GLCanvas)glad); + } else if( GLADType.GLCanvasOffscreen == gladType ) { + if( !jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerSupported() ) { + throw new InternalError("Platform doesn't support offscreen rendering: "+gladType); + } + frame = new Frame("AWT GLCanvas"); + + glad = new GLCanvas(caps); + ((GLCanvas)glad).setShallUseOffscreenLayer(true); + setGLCanvasSize((GLCanvas)glad, new Dimension(width, height)); + frame.add((GLCanvas)glad); + } else if( GLADType.GLWindow == gladType ) { + frame = null; + + glad = GLWindow.create(caps); + ((GLWindow)glad).setTitle("Newt GLWindow"); + ((GLWindow)glad).setSize(width, height); + } else if( GLADType.GLOffscreen == gladType ) { + frame = null; + + glad = this.createGLOffscreenAutoDrawable(caps, width, height); + } else { + throw new InternalError("Unsupported: "+gladType); + } + + if( null == glelsIn ) { + if( null != animator ) { + animator.add(glad); + } + glad.addGLEventListener(glelTracker); + glad.addGLEventListener(new GearsES2(1)); + glad.addGLEventListener(snapshotGLEventListener); + } + snapshotGLEventListener.setMakeSnapshot(); + + if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) { + setFrameVisible(frame); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + } else if( GLADType.GLWindow == gladType ) { + ((GLWindow)glad).setVisible(true); + } + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, true)); + Assert.assertNotNull(glad.getContext()); + Assert.assertTrue(glad.isRealized()); + + if( null != glelsIn ) { + Assert.assertEquals(0, glad.getGLEventListenerCount()); + glelsIn.moveTo(glad); + + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + Assert.assertEquals(3, glad.getGLEventListenerCount()); + + Assert.assertEquals(glelsIn.context, glad.getContext()); + Assert.assertEquals(glelsIn.listenerCount(), glad.getGLEventListenerCount()); + Assert.assertEquals(glelsIn.context.getGLReadDrawable(), glad.getDelegatedDrawable()); + Assert.assertEquals(glelsIn.context.getGLDrawable(), glad.getDelegatedDrawable()); + Assert.assertEquals(false, glelsIn.isOwner()); + } + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( ( t1 - t0 ) < duration ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + Assert.assertEquals(0, glelTracker.disposeCount); + + if( null != glelsOut ) { + final GLContext context1 = glad.getContext(); + final GLEventListenerState _gllsOut = GLEventListenerState.moveFrom(glad); + + Assert.assertEquals(context1, _gllsOut.context); + Assert.assertNull(context1.getGLReadDrawable()); + Assert.assertNull(context1.getGLDrawable()); + Assert.assertEquals(3, _gllsOut.listenerCount()); + Assert.assertEquals(true, _gllsOut.isOwner()); + Assert.assertEquals(null, glad.getContext()); + Assert.assertEquals(0, glad.getGLEventListenerCount()); + + glelsOut[0] = _gllsOut; + } + if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) { + destroyFrame(frame); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, false)); + } else if( GLADType.GLWindow == gladType ) { + glad.destroy(); + } else if( GLADType.GLOffscreen == gladType ) { + glad.destroy(); + } + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, false)); + + Assert.assertEquals(1, glelTracker.initCount); + Assert.assertTrue(1 <= glelTracker.reshapeCount); + Assert.assertTrue(1 <= glelTracker.displayCount); + if( null != glelsOut ) { + Assert.assertEquals(0, glelTracker.disposeCount); + } else { + Assert.assertEquals(1, glelTracker.disposeCount); + } + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch01NEWT.java new file mode 100644 index 000000000..5f2b9fb53 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch01NEWT.java @@ -0,0 +1,374 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore.glels; + +import java.io.IOException; + +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Window; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowListener; +import com.jogamp.newt.event.WindowUpdateEvent; +import com.jogamp.newt.opengl.GLWindow; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.GLAutoDrawableDelegate; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLDrawableUtil; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Test re-association (switching) of GLContext/GLDrawables, + * i.e. ctx1/draw1, ctx2/draw2 -> ctx1/draw2, ctx2/draw1. + */ +public class TestGLContextDrawableSwitch01NEWT extends UITestCase { + static int width, height; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + @BeforeClass + public static void initClass() { + width = 256; + height = 256; + } + + private GLAutoDrawable createGLAutoDrawable(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException { + final Window window = NewtFactory.createWindow(caps); + Assert.assertNotNull(window); + window.setPosition(x, y); + window.setSize(width, height); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + final GLContext context = drawable.createContext(null); + Assert.assertNotNull(context); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, context, window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); + window.destroy(); // destroys the actual window + } + }; + + window.setWindowDestroyNotifyAction( new Runnable() { + public void run() { + glad.windowDestroyNotifyOp(); + } } ); + + // add basic window interaction + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + }); + window.addWindowListener(wl); + + return glad; + } + + @Test(timeout=30000) + public void testSwitch2WindowSingleContextGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testSwitch2WindowSingleContextImpl(reqGLCaps); + } + + @Test(timeout=30000) + public void testSwitch2WindowSingleContextGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testSwitch2WindowSingleContextImpl(reqGLCaps); + } + + private void testSwitch2WindowSingleContextImpl(GLCapabilities caps) throws InterruptedException { + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLAutoDrawable glad1 = createGLAutoDrawable(caps, 64, 64, width, height, quitAdapter); + GLAutoDrawable glad2 = createGLAutoDrawable(caps, 2*64+width, 64, width+100, height+100, quitAdapter); + + // create single context using glad1 and assign it to glad1, + // destroy the prev. context afterwards. + { + final GLContext newCtx = glad1.createContext(null); + Assert.assertNotNull(newCtx); + final GLContext oldCtx = glad1.setContext(newCtx, true); + Assert.assertNotNull(oldCtx); + Assert.assertFalse(oldCtx.isCreated()); + final int res = newCtx.makeCurrent(); + Assert.assertTrue(GLContext.CONTEXT_CURRENT_NEW==res || GLContext.CONTEXT_CURRENT==res); + newCtx.release(); + } + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + GearsES2 gears = new GearsES2(1); + glad1.addGLEventListener(gears); + glad1.addGLEventListener(snapshotGLEventListener); + snapshotGLEventListener.setMakeSnapshot(); + + Animator animator = new Animator(); + animator.add(glad1); + animator.add(glad2); + animator.start(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + + // switch context _and_ the demo synchronously + GLDrawableUtil.swapGLContextAndAllGLEventListener(glad1, glad2); + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glad1.destroy(); + glad2.destroy(); + } + + @Test(timeout=30000) + public void testSwitch2GLWindowOneDemoGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testSwitch2GLWindowOneDemoImpl(reqGLCaps); + } + + @Test(timeout=30000) + public void testSwitch2GLWindowOneDemoGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testSwitch2GLWindowOneDemoImpl(reqGLCaps); + } + + private void testSwitch2GLWindowOneDemoImpl(GLCapabilities caps) throws InterruptedException { + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final GearsES2 gears = new GearsES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addGLEventListener(snapshotGLEventListener); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + snapshotGLEventListener.setMakeSnapshot(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + + // switch context _and_ the demo synchronously + GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); + + System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + snapshotGLEventListener.setMakeSnapshot(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + glWindow1.destroy(); + glWindow2.destroy(); + + } + + @Test(timeout=30000) + public void testSwitch2GLWindowEachWithOwnDemoGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testSwitch2GLWindowEachWithOwnDemoImpl(reqGLCaps); + } + + @Test(timeout=30000) + public void testSwitch2GLWindowEachWithOwnDemoGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testSwitch2GLWindowEachWithOwnDemoImpl(reqGLCaps); + } + + public void testSwitch2GLWindowEachWithOwnDemoImpl(GLCapabilities caps) throws InterruptedException { + final GearsES2 gears = new GearsES2(1); + final RedSquareES2 rsquare = new RedSquareES2(1); + final QuitAdapter quitAdapter = new QuitAdapter(); + final SnapshotGLEventListener snapshotGLEventListener1 = new SnapshotGLEventListener(); + final SnapshotGLEventListener snapshotGLEventListener2 = new SnapshotGLEventListener(); + + GLWindow glWindow1 = GLWindow.create(caps); + glWindow1.setTitle("win1"); + glWindow1.setSize(width, height); + glWindow1.setPosition(64, 64); + glWindow1.addGLEventListener(0, gears); + glWindow1.addGLEventListener(snapshotGLEventListener1); + glWindow1.addWindowListener(quitAdapter); + + GLWindow glWindow2 = GLWindow.create(caps); + glWindow2.setTitle("win2"); + glWindow2.setSize(width+100, height+100); + glWindow2.setPosition(2*64+width, 64); + glWindow2.addGLEventListener(0, rsquare); + glWindow2.addGLEventListener(snapshotGLEventListener2); + glWindow2.addWindowListener(quitAdapter); + + Animator animator = new Animator(); + animator.add(glWindow1); + animator.add(glWindow2); + animator.start(); + + glWindow1.setVisible(true); + glWindow2.setVisible(true); + + snapshotGLEventListener1.setMakeSnapshot(); + snapshotGLEventListener2.setMakeSnapshot(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + System.err.println(s+" - A w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - A w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + GLDrawableUtil.swapGLContextAndAllGLEventListener(glWindow1, glWindow2); + System.err.println(s+" - B w1-h 0x"+Long.toHexString(glWindow1.getHandle())+",-ctx 0x"+Long.toHexString(glWindow1.getContext().getHandle())); + System.err.println(s+" - B w2-h 0x"+Long.toHexString(glWindow2.getHandle())+",-ctx 0x"+Long.toHexString(glWindow2.getContext().getHandle())); + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + snapshotGLEventListener1.setMakeSnapshot(); + snapshotGLEventListener2.setMakeSnapshot(); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + // System.err.println("pre -del-w1: w1: "+glWindow1); + // System.err.println("pre -del-w1: w2: "+glWindow2); + glWindow1.destroy(); + // System.err.println("post-del-w1: w1: "+glWindow1); + // System.err.println("post-del-w1: w2: "+glWindow2); + glWindow2.destroy(); + + } + + // default timing for 2 switches + static long duration = 2200; // ms + static long period = 1000; // ms + + public static void main(String args[]) throws IOException { + for(int i=0; i + * Test utilizes {@link GLEventListenerState} for preserving the + * GLAutoDrawable state, i.e. GLContext, all GLEventListener + * and the GLAnimatorControl association. + *

    + *

    + * This test is using NEWT's plain Window w/ GLAutoDrawableDelegate. + *

    + *

    + * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665. + *

    + */ +public class TestGLContextDrawableSwitch10NEWT extends UITestCase { + // default period for 1 GLAD cycle + static long duration = 1000; // ms + + static int width, height; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + @BeforeClass + public static void initClass() { + width = 256; + height = 256; + } + + private GLAutoDrawable createGLAutoDrawableWithoutContext(GLCapabilities caps, int x, int y, int width, int height, WindowListener wl) throws InterruptedException { + final Window window = NewtFactory.createWindow(caps); + Assert.assertNotNull(window); + window.setPosition(x, y); + window.setSize(width, height); + window.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLDrawable drawable = factory.createGLDrawable(window); + Assert.assertNotNull(drawable); + + drawable.setRealized(true); + Assert.assertTrue(drawable.isRealized()); + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false, null) { + @Override + protected void destroyImplInLock() { + super.destroyImplInLock(); + window.destroy(); // destroys the actual window + } + }; + + window.setWindowDestroyNotifyAction( new Runnable() { + public void run() { + glad.windowDestroyNotifyOp(); + } } ); + + // add basic window interaction + window.addWindowListener(new WindowAdapter() { + @Override + public void windowRepaint(WindowUpdateEvent e) { + glad.windowRepaintOp(); + } + @Override + public void windowResized(WindowEvent e) { + glad.windowResizedOp(window.getWidth(), window.getHeight()); + } + }); + window.addWindowListener(wl); + + return glad; + } + + @Test(timeout=30000) + public void test01GLADDelegateGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testGLADDelegateImpl(reqGLCaps); + } + + @Test(timeout=30000) + public void test02GLADDelegateGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testGLADDelegateImpl(reqGLCaps); + } + + private void testGLADDelegateImpl(GLCapabilities caps) throws InterruptedException { + final GLEventListenerCounter glelCounter = new GLEventListenerCounter(); + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final Animator animator = new Animator(); + animator.start(); + + final GLEventListenerState glls1; + + // - create glad1 w/o context + // - create context using glad1 and assign it to glad1 + { + final QuitAdapter quitAdapter = new QuitAdapter(); + final GLAutoDrawable glad1 = createGLAutoDrawableWithoutContext(caps, 64, 64, width, height, quitAdapter); + final GLContext context1 = glad1.createContext(null); + glad1.setContext(context1, true); + animator.add(glad1); + + glad1.addGLEventListener(glelCounter); + glad1.addGLEventListener(new GearsES2(1)); + glad1.addGLEventListener(snapshotGLEventListener); + snapshotGLEventListener.setMakeSnapshot(); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + Assert.assertEquals(context1, glad1.getContext()); + Assert.assertEquals(3, glad1.getGLEventListenerCount()); + Assert.assertEquals(context1.getGLReadDrawable(), glad1.getDelegatedDrawable()); + Assert.assertEquals(context1.getGLDrawable(), glad1.getDelegatedDrawable()); + + // - dis-associate context from glad1 + // - destroy glad1 + glls1 = GLEventListenerState.moveFrom(glad1); + + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + Assert.assertEquals(context1, glls1.context); + Assert.assertNull(context1.getGLReadDrawable()); + Assert.assertNull(context1.getGLDrawable()); + Assert.assertEquals(3, glls1.listenerCount()); + Assert.assertEquals(true, glls1.isOwner()); + Assert.assertEquals(null, glad1.getContext()); + Assert.assertEquals(0, glad1.getGLEventListenerCount()); + + glad1.destroy(); + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + } + + // - create glad2 w/ survived context + { + final QuitAdapter quitAdapter = new QuitAdapter(); + final GLAutoDrawable glad2 = createGLAutoDrawableWithoutContext(caps, 2*64+width, 64, width+100, height+100, quitAdapter); + snapshotGLEventListener.setMakeSnapshot(); + + Assert.assertEquals(null, glad2.getContext()); + Assert.assertEquals(0, glad2.getGLEventListenerCount()); + + glls1.moveTo(glad2); + + Assert.assertTrue(glad2.isRealized()); + + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(0, glelCounter.disposeCount); + Assert.assertEquals(glls1.context, glad2.getContext()); + Assert.assertEquals(3, glad2.getGLEventListenerCount()); + Assert.assertEquals(glls1.context.getGLReadDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(glls1.context.getGLDrawable(), glad2.getDelegatedDrawable()); + Assert.assertEquals(false, glls1.isOwner()); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + glad2.destroy(); + Assert.assertEquals(1, glelCounter.initCount); + Assert.assertTrue(1 <= glelCounter.reshapeCount); + Assert.assertTrue(1 <= glelCounter.displayCount); + Assert.assertEquals(1, glelCounter.disposeCount); + } + animator.stop(); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i + * Test utilizes {@link GLEventListenerState} for preserving the + * GLAutoDrawable state, i.e. GLContext, all GLEventListener + * and the GLAnimatorControl association. + *

    + *

    + * This test is using JOGL's NEWT GLWindow. + *

    + *

    + * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665. + *

    + */ +public class TestGLContextDrawableSwitch11NewtAWT extends GLContextDrawableSwitchBase { + + @Test(timeout=30000) + public void test21GLWindowGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testGLWindowImpl(reqGLCaps); + } + + @Test(timeout=30000) + public void test22GLWindowGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testGLWindowImpl(reqGLCaps); + } + + private void testGLWindowImpl(GLCapabilities caps) throws InterruptedException { + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final GLEventListenerCounter glelTracker = new GLEventListenerCounter(); + final Animator animator = new Animator(); + animator.start(); + + final GLEventListenerState glels[] = new GLEventListenerState[1]; + + // - create glad1 w/o context + // - create context using glad1 and assign it to glad1 + { + testGLADOneLifecycle(caps, GLADType.GLWindow, width, height, + glelTracker, snapshotGLEventListener, + null, + glels, animator); + } + + // - create glad2 w/ survived context + { + testGLADOneLifecycle(caps, GLADType.GLWindow, width+100, height+100, + glelTracker, snapshotGLEventListener, + glels[0], + null, null); + } + animator.stop(); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i + * Test utilizes {@link GLEventListenerState} for preserving the + * GLAutoDrawable state, i.e. GLContext, all GLEventListener + * and the GLAnimatorControl association. + *

    + *

    + * This test is using JOGL's AWT GLCanvas + *

    + *

    + * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665. + *

    + */ +public class TestGLContextDrawableSwitch12AWT extends GLContextDrawableSwitchBase { + + @Test(timeout=30000) + public void test01GLCanvasOnscreenGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testGLCanvasImpl(reqGLCaps, false); + } + + @Test(timeout=30000) + public void test02GLCanvasOnscreenGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testGLCanvasImpl(reqGLCaps, false); + } + + @Test(timeout=30000) + public void test11GLCanvasOffscreenGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testGLCanvasImpl(reqGLCaps, true); + } + + @Test(timeout=30000) + public void test12GLCanvasOffscreenGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testGLCanvasImpl(reqGLCaps, true); + } + + private void testGLCanvasImpl(GLCapabilities caps, boolean offscreenLayer) throws InterruptedException { + if( offscreenLayer ) { + if( !JAWTUtil.isOffscreenLayerSupported() ) { + System.err.println("Platform doesn't support offscreen rendering."); + return; + } + } else { + if( JAWTUtil.isOffscreenLayerRequired() ) { + System.err.println("Platform requires offscreen rendering."); + return; + } + } + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final GLEventListenerCounter glelTracker = new GLEventListenerCounter(); + final Animator animator = new Animator(); + animator.start(); + + final GLEventListenerState glels[] = new GLEventListenerState[1]; + + // - create glad1 w/o context + // - create context using glad1 and assign it to glad1 + { + testGLADOneLifecycle(caps, offscreenLayer ? GLADType.GLCanvasOffscreen : GLADType.GLCanvasOnscreen, width, height, + glelTracker, snapshotGLEventListener, + null, + glels, animator); + } + + // - create glad2 w/ survived context + { + testGLADOneLifecycle(caps, offscreenLayer ? GLADType.GLCanvasOffscreen : GLADType.GLCanvasOnscreen, width+100, height+100, + glelTracker, snapshotGLEventListener, + glels[0], + null, null); + } + animator.stop(); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i + * Test utilizes {@link GLEventListenerState} for preserving the + * GLAutoDrawable state, i.e. GLContext, all GLEventListener + * and the GLAnimatorControl association. + *

    + *

    + * This test moves the {@link GLEventListenerState} from a + * NEWT GLWindow before it's destruction to an AWT GLCanvas after it's creation + * and vice versa + *

    + *

    + * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665. + *

    + */ +public class TestGLContextDrawableSwitch21Newt2AWT extends GLContextDrawableSwitchBase { + + @Test(timeout=30000) + public void test01GLCanvasOnScrn2GLWindowGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLCanvasOnscreen, GLADType.GLWindow); + } + + @Test(timeout=30000) + public void test02GLCanvasOnScrn2GLWindowGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLCanvasOnscreen, GLADType.GLWindow); + } + + @Test(timeout=30000) + public void test11GLWindow2GLCanvasOnScrnGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOnscreen); + } + + @Test(timeout=30000) + public void test12GLWindow2GLCanvasOnScrnGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOnscreen); + } + + @Test(timeout=30000) + public void test21GLCanvasOffScrn2GLWindowGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLCanvasOffscreen, GLADType.GLWindow); + } + + @Test(timeout=30000) + public void test22GLCanvasOffScrn2GLWindowGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLCanvasOffscreen, GLADType.GLWindow); + } + + @Test(timeout=30000) + public void test31GLWindow2GLCanvasOffScrnGL2ES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOffscreen); + } + + @Test(timeout=30000) + public void test32GLWindow2GLCanvasOffScrnGLES2() throws InterruptedException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); + if(null == reqGLCaps) return; + testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOffscreen); + } + + private void testGLCanvas2GLWindowImpl(GLCapabilities caps, GLADType gladType1, GLADType gladType2) throws InterruptedException { + if( !validateOnOffscreenLayer(gladType1, gladType2) ) { + return; + } + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final GLEventListenerCounter glelTracker = new GLEventListenerCounter(); + final Animator animator = new Animator(); + animator.start(); + + final GLEventListenerState glels[] = new GLEventListenerState[1]; + + // - create glad1 w/o context + // - create context using glad1 and assign it to glad1 + { + testGLADOneLifecycle(caps, gladType1, width, height, + glelTracker, snapshotGLEventListener, + null, + glels, animator); + } + + // - create glad2 w/ survived context + { + testGLADOneLifecycle(caps, gladType2, width+100, height+100, + glelTracker, snapshotGLEventListener, + glels[0], + null, null); + } + animator.stop(); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); } - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Tue, 19 Mar 2013 00:33:00 +0100 Subject: OSX/NEWT: Following CALayer streaming design, i.e. issue NSWindow/NSView Ops on main-thread w/o blocking; NEWT/WindowImpl: Volatile multithreaded mutable values Similar to commits: 28c6472335b924080d638b33a28f8f4eedb459b1 f354fb204d8973453c538dda78a2c82c87be61dc main-thread operations cannot block main-thread. Luckily we are able to create the NSWindow and NSView instance uninitialized (deferred) on the current thread, while issuing their initialization on the main-thread w/o blocking. Further more a size glitch is fixed, which didn't take the title bar into account. +++ NEWT/WindowImpl: Volatile multithreaded mutable values Since position, size and other attributes might get changes off-thread, these fields needs to be volatile. --- make/scripts/tests.sh | 6 +- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 1 + src/newt/classes/jogamp/newt/WindowImpl.java | 17 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 165 +++++++------ src/newt/native/MacWindow.m | 257 ++++++++++++++------- src/newt/native/NewtMacWindow.h | 18 +- src/newt/native/NewtMacWindow.m | 145 +++++++----- 7 files changed, 376 insertions(+), 233 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8cc3fd84a..71e8ef98d 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -90,6 +90,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" + #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLState" @@ -268,7 +269,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* @@ -348,8 +349,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* - +#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index 3c015d3ec..651522799 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -332,6 +332,7 @@ public class DefaultEDTUtil implements EDTUtil { validateNoRecursiveLocksHold(); if(!task.hasWaiter() && null != task.getThrowable()) { // at least dump stack-trace in case nobody waits for result + System.err.println("DefaultEDT.run(): Catched exception occured on thread "+Thread.currentThread().getName()+": "+task.toString()); task.getThrowable().printStackTrace(); } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 448b192a2..c01f880fc 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -82,9 +82,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms - + + // + // Volatile: Multithread Mutable Access + // private volatile long windowHandle = 0; // lifecycle critical private volatile boolean visible = false; // lifecycle critical + private volatile boolean hasFocus = false; + private volatile int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user + private volatile int x = 64, y = 64; // client-area pos w/o insets + private volatile Insets insets = new Insets(); // insets of decoration (if top-level && decorated) + private RecursiveLock windowLock = LockFactory.createRecursiveLock(); // Window instance wide lock private int surfaceLockCount = 0; // surface lock recursion count @@ -95,12 +103,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private AbstractGraphicsConfiguration config = null; // control access due to delegation protected CapabilitiesImmutable capsRequested = null; protected CapabilitiesChooser capabilitiesChooser = null; // default null -> default - private boolean fullscreen = false, hasFocus = false, brokenFocusChange = false; - private int width = 128, height = 128; // client-area size w/o insets, default: may be overwritten by user - private int x = 64, y = 64; // client-area pos w/o insets + private boolean fullscreen = false, brokenFocusChange = false; private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) - private Insets insets = new Insets(); // insets of decoration (if top-level && decorated) - + private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets private NativeWindow nfs_parent = null; // non fullscreen parent, in case explicit reparenting is performed (offscreen) private String title = "Newt Window"; diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 6e9335f08..d3a92e023 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -49,7 +49,6 @@ import jogamp.newt.WindowImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; -import com.jogamp.common.util.Function; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; @@ -86,7 +85,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sscSurfaceHandle = 0; isOffscreenInstance = false; if (0 != handle) { - OSXUtil.RunOnMainThread(true, new Runnable() { + OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { close0( handle ); } } ); @@ -101,18 +100,31 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected int lockSurfaceImpl() { - if(!isOffscreenInstance) { - return lockSurface0(getWindowHandle()) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; + /** + * if( isOffscreenInstance ) { + * return LOCK_SUCCESS; + * } + */ + final long w = getWindowHandle(); + final long v = surfaceHandle; + if( 0 != v && 0 != w ) { + return lockSurface0(w, v) ? LOCK_SUCCESS : LOCK_SURFACE_NOT_READY; } - return LOCK_SUCCESS; + return LOCK_SURFACE_NOT_READY; } @Override protected void unlockSurfaceImpl() { - if(!isOffscreenInstance) { - final long h = getWindowHandle(); - if(0 != h) { - unlockSurface0(h); + /** + * if( isOffscreenInstance ) { + * return; + * } + */ + final long w = getWindowHandle(); + final long v = surfaceHandle; + if(0 != w && 0 != v) { + if( !unlockSurface0(w, v) ) { + throw new NativeWindowException("Failed to unlock surface, probably not locked!"); } } } @@ -130,7 +142,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl sscSurfaceHandle = surfaceHandle; if (isNativeValid()) { if (0 != sscSurfaceHandle) { - orderOut0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); + orderOut0( 0 != getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); } /** this is done by recreation! else if (isVisible()){ orderFront0( 0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle() ); @@ -172,7 +184,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow: updatePosition() -> abs child-client-pos: "+pS); } - setWindowClientTopLeftPoint0(handle, pS.getX(), pS.getY()); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + setWindowClientTopLeftPoint0(handle, pS.getX(), pS.getY()); + } } ); // no native event (fullscreen, some reparenting) positionChanged(true, pS.getX(), pS.getY()); } @@ -189,14 +204,17 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow: sizeChanged() "+newWidth+"x"+newHeight+" -> abs child-client-pos "+p0S); } - setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY()); + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + setWindowClientTopLeftPoint0(getWindowHandle(), p0S.getX(), p0S.getY()); + } } ); } } super.sizeChanged(defer, newWidth, newHeight, force); } @Override - protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, int flags) { final boolean _isOffscreenInstance = isOffscreenInstance(this, this.getParent()); isOffscreenInstance = 0 != sscSurfaceHandle || _isOffscreenInstance; final PointImmutable pClientLevelOnSreen; @@ -224,7 +242,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl ", ioi: "+_isOffscreenInstance+ ") -> "+isOffscreenInstance+ "\n\t, "+getReconfigureFlagsAsString(null, flags)); - Thread.dumpStack(); + // Thread.dumpStack(); } if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) && 0 == ( FLAG_IS_VISIBLE & flags) ) { @@ -244,11 +262,12 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags)); } if(isVisible()) { flags |= FLAG_CHANGE_VISIBILITY; } - } - if( width>0 && height>0 && x>=0 && y>=0 ) { - if( !isOffscreenInstance ) { - // setContentSize0(getWindowHandle(), width, height); - setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height); + } else if( width>0 && height>0 ) { + if( !isOffscreenInstance ) { + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + setWindowClientTopLeftPointAndSize0(getWindowHandle(), pClientLevelOnSreen.getX(), pClientLevelOnSreen.getY(), width, height); + } } ); } // else offscreen size is realized via recreation // no native event (fullscreen, some reparenting) positionChanged(true, x, y); @@ -297,19 +316,25 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl /** Callback for native screen position change event of the client area. */ protected void screenPositionChanged(boolean defer, int newX, int newY) { // passed coordinates are in screen position of the client area - if(DEBUG_IMPLEMENTATION) { - System.err.println("MacWindow.positionChanged (Screen Pos): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); - } if(getWindowHandle()!=0) { final NativeWindow parent = getParent(); - if(null == parent) { + if( null == parent || isOffscreenInstance ) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.positionChanged.0 (Screen Pos - TOP): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); + } positionChanged(defer, newX, newY); } else { // screen position -> rel child window position Point absPos = new Point(newX, newY); - absPos.translate( parent.getLocationOnScreen(null).scale(-1, -1) ); + Point parentOnScreen = parent.getLocationOnScreen(null); + absPos.translate( parentOnScreen.scale(-1, -1) ); + if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.positionChanged.1 (Screen Pos - CHILD): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> absPos "+newX+"/"+newY+", parentOnScreen "+parentOnScreen+" -> "+absPos); + } positionChanged(defer, absPos.getX(), absPos.getY()); } + } else if(DEBUG_IMPLEMENTATION) { + System.err.println("MacWindow.positionChanged.2 (Screen Pos - IGN): ("+getThreadName()+"): (defer: "+defer+") "+getX()+"/"+getY()+" -> "+newX+"/"+newY); } } @@ -383,65 +408,69 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final PointImmutable pS, final int width, final int height, final boolean fullscreen) { - if(0!=getWindowHandle() && !recreate) { + if( 0 != getWindowHandle() && !recreate ) { return; } try { - if(0!=getWindowHandle()) { - // save the view .. close the window - surfaceHandle = OSXUtil.RunOnMainThread(true, new Function() { - public Long eval(Object... args) { - return Long.valueOf( - changeContentView0(getParentWindowHandle(), getWindowHandle(), 0) ); - } } ).longValue(); - if(recreate && 0==surfaceHandle) { - throw new NativeWindowException("Internal Error - recreate, window but no view"); - } - OSXUtil.RunOnMainThread(true, new Runnable() { - public void run() { - close0( getWindowHandle() ); - } } ); + final long parentWin = getParentWindowHandle(); + if( 0 != getWindowHandle() ) { + final long thisWin = getWindowHandle(); setWindowHandle(0); + + if( 0 == surfaceHandle ) { + throw new NativeWindowException("Internal Error - create w/ window, but no Newt NSView"); + } + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + changeContentView0(parentWin, thisWin, 0); + close0( thisWin ); + } } ); } else { - surfaceHandle = 0; + if( 0 != surfaceHandle ) { + throw new NativeWindowException("Internal Error - create w/o window, but has Newt NSView"); + } + surfaceHandle = createView0(pS.getX(), pS.getY(), width, height, fullscreen, getScreen().getIndex()); + if( 0 == surfaceHandle ) { + throw new NativeWindowException("Could not create native view "+Thread.currentThread().getName()+" "+this); + } } - setWindowHandle( OSXUtil.RunOnMainThread(true, new Function() { - public Long eval(Object... args) { - return Long.valueOf( - createWindow0( getParentWindowHandle(), - pS.getX(), pS.getY(), width, height, - (getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance), - fullscreen, - ( (isUndecorated() || offscreenInstance) ? NSBorderlessWindowMask : - NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask ), - NSBackingStoreBuffered, - getScreen().getIndex(), surfaceHandle) ); - } } ).longValue() ); - - if (getWindowHandle() == 0) { - throw new NativeWindowException("Could create native window "+Thread.currentThread().getName()+" "+this); - } - surfaceHandle = contentView0(getWindowHandle()); - if( offscreenInstance ) { - orderOut0(0!=getParentWindowHandle() ? getParentWindowHandle() : getWindowHandle()); - } else { - setTitle0(getWindowHandle(), getTitle()); + final long newWin = createWindow0( pS.getX(), pS.getY(), width, height, fullscreen, + ( isUndecorated() || offscreenInstance ) ? NSBorderlessWindowMask : + NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask, + NSBackingStoreBuffered, getScreen().getIndex(), surfaceHandle); + if ( newWin == 0 ) { + throw new NativeWindowException("Could not create native window "+Thread.currentThread().getName()+" "+this); } + setWindowHandle( newWin ); + + final boolean isOpaque = getGraphicsConfiguration().getChosenCapabilities().isBackgroundOpaque() && !offscreenInstance; + // Non blocking initialization on main-thread! + OSXUtil.RunOnMainThread(false, new Runnable() { + public void run() { + initWindow0( parentWin, newWin, + pS.getX(), pS.getY(), width, height, + isOpaque, fullscreen, offscreenInstance, getScreen().getIndex(), surfaceHandle); + if( offscreenInstance ) { + orderOut0(0!=parentWin ? parentWin : newWin); + } else { + setTitle0(newWin, getTitle()); + } + } } ); } catch (Exception ie) { ie.printStackTrace(); } } protected static native boolean initIDs0(); + private native long createView0(int x, int y, int w, int h, boolean fullscreen, int screen_idx); + private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, int screen_idx, long view); /** Must be called on Main-Thread */ - private native long createWindow0(long parentWindowHandle, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, int windowStyle, - int backingStoreType, - int screen_idx, long view); - private native boolean lockSurface0(long window); - private native void unlockSurface0(long window); + private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, + boolean opaque, boolean fullscreen, boolean offscreen, int screen_idx, long view); + private native boolean lockSurface0(long window, long view); + private native boolean unlockSurface0(long window, long view); private native void requestFocus0(long window, boolean force); private native void resignFocus0(long window); /** in case of a child window, it actually only issues orderBack(..) */ @@ -452,7 +481,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private native void setTitle0(long window, String title); private native long contentView0(long window); /** Must be called on Main-Thread */ - private native long changeContentView0(long parentWindowOrViewHandle, long window, long view); + private native void changeContentView0(long parentWindowOrView, long window, long view); private native void setWindowClientTopLeftPointAndSize0(long window, int x, int y, int w, int h); private native void setWindowClientTopLeftPoint0(long window, int x, int y); private native void setAlwaysOnTop0(long window, boolean atop); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 1895b98a5..db4420b49 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -70,11 +70,18 @@ static void setWindowClientTopLeftPoint(NewtMacWindow* mWin, jint x, jint y) { [mWin invalidateCursorRectsForView: mView]; } -static void setWindowClientTopLeftPointAndSize(NewtMacWindow* mWin, jint x, jint y, jint width, jint height) { - NSSize sz = NSMakeSize(width, height); - NSPoint pS = [mWin newtAbsClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y) size: sz]; - NSRect rect = { pS, sz }; - [mWin setFrame: rect display:YES]; +static void setWindowClientTopLeftPointAndSize(NewtMacWindow* mWin, jint x, jint y, jint width, jint height, BOOL doDisplay) { + DBG_PRINT( "setWindowClientTopLeftPointAndSize.0 - window: %p %d/%d %dx%d\n", + mWin, (int)x, (int)y, (int)width, (int)height); + NSSize clientSZ = NSMakeSize(width, height); + NSPoint pS = [mWin newtAbsClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y) size: clientSZ]; + NSSize topSZ = [mWin newtClientSize2TLSize: clientSZ]; + NSRect rect = { pS, topSZ }; + + DBG_PRINT( "setWindowClientTopLeftPointAndSize.X: %d/%d %dx%d\n", + (int)rect.origin.x, (int)rect.origin.y, (int)rect.size.width, (int)rect.size.height); + + [mWin setFrame: rect display:doDisplay]; // -> display:YES // NSView* mView = [mWin contentView]; @@ -88,21 +95,20 @@ static int getRetainCount(NSObject * obj) { #endif static void changeContentView(JNIEnv *env, jobject javaWindowObject, NSView *pview, NewtMacWindow *win, NewtView *newView) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSView* oldNSView = [win contentView]; - NewtView* oldView = NULL; + NewtView* oldNewtView = NULL; #ifdef VERBOSE_ON int dbgIdx = 1; #endif - if( [oldNSView isMemberOfClass:[NewtView class]] ) { - oldView = (NewtView *) oldNSView; + if( [oldNSView isKindOfClass:[NewtView class]] ) { + oldNewtView = (NewtView *) oldNSView; } DBG_PRINT( "changeContentView.%d win %p, view (%p,%d (%d) -> %p,%d), parent view %p\n", - dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView), pview); + dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldNewtView, newView, getRetainCount(newView), pview); - if(NULL!=oldNSView) { + if( NULL!=oldNSView ) { NS_DURING // Available >= 10.5 - Makes the menubar disapear BOOL iifs; @@ -117,20 +123,20 @@ NS_DURING NS_HANDLER NS_ENDHANDLER DBG_PRINT( "changeContentView.%d win %p, view (%p,%d (%d) -> %p,%d)\n", - dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView)); + dbgIdx++, win, oldNSView, getRetainCount(oldNSView), NULL!=oldNewtView, newView, getRetainCount(newView)); - if( NULL != oldView ) { - jobject globJavaWindowObject = [oldView getJavaWindowObject]; + if( NULL != oldNewtView ) { + jobject globJavaWindowObject = [oldNewtView getJavaWindowObject]; (*env)->DeleteGlobalRef(env, globJavaWindowObject); - [oldView setJavaWindowObject: NULL]; - [oldView setDestroyNotifySent: false]; + [oldNewtView setJavaWindowObject: NULL]; + [oldNewtView setDestroyNotifySent: false]; } [oldNSView removeFromSuperviewWithoutNeedingDisplay]; } DBG_PRINT( "changeContentView.%d win %p, view (%p,%d -> %p,%d), isHidden %d, isHiddenOrHasHiddenAncestor: %d\n", dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView), [newView isHidden], [newView isHiddenOrHasHiddenAncestor]); - if(NULL!=newView) { + if( NULL!=newView ) { jobject globJavaWindowObject = (*env)->NewGlobalRef(env, javaWindowObject); [newView setJavaWindowObject: globJavaWindowObject]; [newView setDestroyNotifySent: false]; @@ -163,12 +169,10 @@ NS_ENDHANDLER dbgIdx++, win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView), [newView isHidden], [newView isHiddenOrHasHiddenAncestor]); // make sure the insets are updated in the java object - [win updateInsets: env]; + [win updateInsets: env jwin:javaWindowObject]; DBG_PRINT( "changeContentView.X win %p, view (%p,%d -> %p,%d)\n", win, oldNSView, getRetainCount(oldNSView), newView, getRetainCount(newView)); - - [pool release]; } /* @@ -565,29 +569,69 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 } /** - * Method is called on Main-Thread, hence no special invocation required inside method. + * Class: jogamp_newt_driver_macosx_WindowDriver + * Method: createView0 + * Signature: (IIIIZI)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 + (JNIEnv *env, jobject jthis, jint x, jint y, jint w, jint h, + jboolean fullscreen, jint screen_idx) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + + DBG_PRINT( "createView0 - %p (this), %d/%d %dx%d, fs %d, screenidx %d (START)\n", + (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, (int)screen_idx); + + NSArray *screens = [NSScreen screens]; + if(screen_idx<0) screen_idx=0; + if(screen_idx>=[screens count]) screen_idx=0; + NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; + NSRect rectWin; + + if (fullscreen) { + rectWin = [myScreen frame]; + x = 0; + y = 0; + w = (jint) (rectWin.size.width); + h = (jint) (rectWin.size.height); + } else { + rectWin = NSMakeRect(x, y, w, h); + } + + NSRect rectView = NSMakeRect(0, 0, w, h); + NewtView *myView = [[NewtView alloc] initWithFrame: rectView] ; + DBG_PRINT( "createView0.X.%d - new view: %p\n", myView); + + [pool release]; + + return (jlong) ((intptr_t) myView); +} + +/** + * Method creates a deferred un-initialized Window, hence no special invocation required inside method. * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createWindow0 - * Signature: (JIIIIZIIIJ)J + * Signature: (IIIIZIIIJ)J */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow0 - (JNIEnv *env, jobject jthis, jlong parent, jint x, jint y, jint w, jint h, jboolean opaque, jboolean fullscreen, jint styleMask, - jint bufferingType, jint screen_idx, jlong jview) + (JNIEnv *env, jobject jthis, jint x, jint y, jint w, jint h, + jboolean fullscreen, jint styleMask, jint bufferingType, jint screen_idx, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* myView = (NewtView*) (intptr_t) jview ; - DBG_PRINT( "createWindow0 - %p (this), %p (parent), %d/%d %dx%d, opaque %d, fs %d, style %X, buffType %X, screenidx %d, view %p (START)\n", - (void*)(intptr_t)jthis, (void*)(intptr_t)parent, (int)x, (int)y, (int)w, (int)h, (int) opaque, (int)fullscreen, + DBG_PRINT( "createWindow0 - %p (this), %d/%d %dx%d, fs %d, style %X, buffType %X, screenidx %d, view %p (START)\n", + (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, (int)styleMask, (int)bufferingType, (int)screen_idx, myView); + (void)myView; NSArray *screens = [NSScreen screens]; if(screen_idx<0) screen_idx=0; if(screen_idx>=[screens count]) screen_idx=0; NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; - NSRect rectWin; + NSRect rectWin; if (fullscreen) { styleMask = NSBorderlessWindowMask; rectWin = [myScreen frame]; @@ -603,9 +647,54 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow NewtMacWindow* myWindow = [[NewtMacWindow alloc] initWithContentRect: rectWin styleMask: (NSUInteger) styleMask backing: (NSBackingStoreType) bufferingType - defer: NO + defer: YES screen: myScreen isFullscreenWindow: fullscreen]; + + // DBG_PRINT( "createWindow0.1 - %p, isVisible %d\n", myWindow, [myWindow isVisible]); + + DBG_PRINT( "createWindow0.X - %p, isVisible %d\n", myWindow, [myWindow isVisible]); + + [pool release]; + + return (jlong) ((intptr_t) myWindow); +} + +/** + * Method is called on Main-Thread, hence no special invocation required inside method. + * + * Class: jogamp_newt_driver_macosx_WindowDriver + * Method: initWindow0 + * Signature: (JJIIIIZZZIIJ)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 + (JNIEnv *env, jobject jthis, jlong parent, jlong window, jint x, jint y, jint w, jint h, + jboolean opaque, jboolean fullscreen, jboolean offscreen, jint screen_idx, jlong jview) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NewtMacWindow* myWindow = (NewtMacWindow*) ((intptr_t) window); + NewtView* myView = (NewtView*) (intptr_t) jview ; + + DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, offscreen %d, screenidx %d, view %p (START)\n", + (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, (int)x, (int)y, (int)w, (int)h, (int) opaque, (int)fullscreen, + (int)offscreen, (int)screen_idx, myView); + + NSArray *screens = [NSScreen screens]; + if(screen_idx<0) screen_idx=0; + if(screen_idx>=[screens count]) screen_idx=0; + NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; + NSRect rectWin; + + if (fullscreen) { + rectWin = [myScreen frame]; + x = 0; + y = 0; + w = (jint) (rectWin.size.width); + h = (jint) (rectWin.size.height); + } else { + rectWin = NSMakeRect(x, y, w, h); + } + [myWindow setReleasedWhenClosed: YES]; // default [myWindow setPreservesContentDuringLiveResize: NO]; @@ -615,15 +704,15 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSWindow class]] ) { parentWindow = (NSWindow*) nsParentObj; parentView = [parentWindow contentView]; - DBG_PRINT( "createWindow0 - Parent is NSWindow : %p (win) -> %p (view) \n", parentWindow, parentView); + DBG_PRINT( "initWindow0 - Parent is NSWindow : %p (win) -> %p (view) \n", parentWindow, parentView); } else if( nsParentObj != NULL && [nsParentObj isKindOfClass:[NSView class]] ) { parentView = (NSView*) nsParentObj; parentWindow = [parentView window]; - DBG_PRINT( "createWindow0 - Parent is NSView : %p -(view) > %p (win) \n", parentView, parentWindow); + DBG_PRINT( "initWindow0 - Parent is NSView : %p -(view) > %p (win) \n", parentView, parentWindow); } else { - DBG_PRINT( "createWindow0 - Parent is neither NSWindow nor NSView : %p\n", nsParentObj); + DBG_PRINT( "initWindow0 - Parent is neither NSWindow nor NSView : %p\n", nsParentObj); } - DBG_PRINT( "createWindow0 - is visible.1: %d\n", [myWindow isVisible]); + DBG_PRINT( "initWindow0 - is visible.1: %d\n", [myWindow isVisible]); // Remove animations for child windows if(NULL != parentWindow) { @@ -641,11 +730,11 @@ NS_ENDHANDLER #endif if(opaque) { [myWindow setOpaque: YES]; - DBG_PRINT( "createWindow0.%d\n", dbgIdx++); + DBG_PRINT( "initWindow0.%d\n", dbgIdx++); if (!fullscreen) { [myWindow setShowsResizeIndicator: YES]; } - DBG_PRINT( "createWindow0.%d\n", dbgIdx++); + DBG_PRINT( "initWindow0.%d\n", dbgIdx++); } else { [myWindow setOpaque: NO]; [myWindow setBackgroundColor: [NSColor clearColor]]; @@ -653,36 +742,25 @@ NS_ENDHANDLER // specify we want mouse-moved events [myWindow setAcceptsMouseMovedEvents:YES]; - DBG_PRINT( "createWindow0.%d\n", dbgIdx++); - // Use given NewtView or allocate an NewtView if NULL - if(NULL == myView) { - NSRect rectView = NSMakeRect(0, 0, w, h); - myView = [[NewtView alloc] initWithFrame: rectView] ; - DBG_PRINT( "createWindow0.%d - use new view: %p,%d\n", dbgIdx++, myView, getRetainCount(myView)); - } else { - DBG_PRINT( "createWindow0.%d - use given view: %p,%d\n", dbgIdx++, myView, getRetainCount(myView)); - } - - DBG_PRINT( "createWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); // Set the content view changeContentView(env, jthis, parentView, myWindow, myView); - DBG_PRINT( "createWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); if(NULL!=parentWindow) { [myWindow attachToParent: parentWindow]; } - // Immediately re-position the window based on an upper-left coordinate system - setWindowClientTopLeftPoint(myWindow, x, y); + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); - // force surface creation - [myView lockFocus]; - [myView unlockFocus]; + // Immediately re-position the window based on an upper-left coordinate system + setWindowClientTopLeftPointAndSize(myWindow, x, y, w, h, NO); NS_DURING // concurrent view rendering @@ -696,12 +774,24 @@ NS_DURING NS_HANDLER NS_ENDHANDLER + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + // visible on front - [myWindow orderFront: myWindow]; + if( JNI_FALSE == offscreen ) { + [myWindow orderFront: myWindow]; + } + + DBG_PRINT( "initWindow0.%d - %p,%d view %p,%d, isVisible %d\n", + dbgIdx++, myWindow, getRetainCount(myWindow), myView, getRetainCount(myView), [myWindow isVisible]); + + // force surface creation + // [myView lockFocus]; + // [myView unlockFocus]; NS_DURING // Available >= 10.5 - Makes the menubar disapear - if(fullscreen) { + if( fullscreen ) { if ( [myView respondsToSelector:@selector(enterFullScreenMode:withOptions:)] ) { [myView enterFullScreenMode: myScreen withOptions:NULL]; } @@ -713,12 +803,10 @@ NS_ENDHANDLER // right mouse button down events [myView setNextResponder: myWindow]; - DBG_PRINT( "createWindow0 - %p (this), %p (parent): new window: %p, view %p,%d (END)\n", + DBG_PRINT( "initWindow0.X - %p (this), %p (parent): new window: %p, view %p,%d\n", (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, myView, getRetainCount(myView)); [pool release]; - - return (jlong) ((intptr_t) myWindow); } /** @@ -740,7 +828,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 DBG_PRINT( "windowClose.0 - %p,%d, destroyNotifySent %d, view %p,%d, parent %p\n", mWin, getRetainCount(mWin), destroyNotifySent, mView, getRetainCount(mView), pWin); - [mWin setUnrealized]; + [mWin setRealized: NO]; if(NULL!=mView) { // cleanup view @@ -786,8 +874,7 @@ NS_ENDHANDLER [mWin release]; } - DBG_PRINT( "windowClose.X - %p,%d, released %d, view %p,%d, parent %p\n", - mWin, getRetainCount(mWin), !destroyNotifySent, mView, getRetainCount(mView), pWin); + DBG_PRINT( "windowClose.Xp\n"); [pool release]; } @@ -795,16 +882,16 @@ NS_ENDHANDLER /* * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: lockSurface0 - * Signature: (J)Z + * Signature: (JJ)Z */ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_lockSurface0 - (JNIEnv *env, jclass clazz, jlong window) + (JNIEnv *env, jclass clazz, jlong window, jlong view) { NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); if(NO == [mWin isRealized]) { return JNI_FALSE; } - NewtView * mView = (NewtView *) [mWin contentView]; + NewtView * mView = (NewtView *) ((intptr_t) view); return [mView softLock] == YES ? JNI_TRUE : JNI_FALSE; /** deadlocks, since we render independent of focus return [mView lockFocusIfCanDraw] == YES ? JNI_TRUE : JNI_FALSE; */ @@ -813,14 +900,15 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_lockSurfa /* * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: unlockSurface0 - * Signature: (J)V + * Signature: (JJ)Z */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_unlockSurface0 - (JNIEnv *env, jclass clazz, jlong window) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_unlockSurface0 + (JNIEnv *env, jclass clazz, jlong window, jlong view) { - NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); - NewtView * mView = (NewtView *) [mWin contentView]; - [mView softUnlock]; + // NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); + (void) window; + NewtView * mView = (NewtView *) ((intptr_t) view); + return [mView softUnlock] == YES ? JNI_TRUE : JNI_FALSE; /** deadlocks, since we render independent of focus [mView unlockFocus]; */ } @@ -946,7 +1034,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setTitle0 /* * Class: jogamp_newt_driver_macosx_WindowDriver - * Method: contentView + * Method: contentView0 * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 @@ -954,12 +1042,16 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSWindow* win = (NSWindow*) ((intptr_t) window); + NSView* nsView = [win contentView]; + NewtView* newtView = NULL; - DBG_PRINT( "contentView0 - window: %p (START)\n", win); + if( [nsView isKindOfClass:[NewtView class]] ) { + newtView = (NewtView *) nsView; + } - jlong res = (jlong) ((intptr_t) [win contentView]); + DBG_PRINT( "contentView0 - window: %p, view: %p, newtView %p\n", win, nsView, newtView); - DBG_PRINT( "contentView0 - window: %p (END)\n", win); + jlong res = (jlong) ((intptr_t) nsView); [pool release]; return res; @@ -970,24 +1062,18 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_contentView0 * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: changeContentView - * Signature: (J)J + * Signature: (J)V */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeContentView0 +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeContentView0 (JNIEnv *env, jobject jthis, jlong parentWindowOrView, jlong window, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* newView = (NewtView *) ((intptr_t) jview); NewtMacWindow* win = (NewtMacWindow*) ((intptr_t) window); - NSView* oldNSView = [win contentView]; - NewtView* oldView = NULL; - if( [oldNSView isMemberOfClass:[NewtView class]] ) { - oldView = (NewtView *) oldNSView; - } - - DBG_PRINT( "changeContentView0.0 - win %p, view (%p,%d (%d) -> %p,%d)\n", - win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView)); + DBG_PRINT( "changeContentView0.0 - win %p, view (%p,%d)\n", + win, newView, getRetainCount(newView)); NSObject *nsParentObj = (NSObject*) ((intptr_t) parentWindowOrView); NSView* pView = NULL; @@ -1002,12 +1088,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_changeConten changeContentView(env, jthis, pView, win, newView); - DBG_PRINT( "changeContentView0.X - win %p, view (%p,%d (%d) -> %p,%d)\n", - win, oldNSView, getRetainCount(oldNSView), NULL!=oldView, newView, getRetainCount(newView)); + DBG_PRINT( "changeContentView0.X\n"); [pool release]; - - return (jlong) ((intptr_t) oldView); } /* @@ -1023,7 +1106,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setWindowClie DBG_PRINT( "setWindowClientTopLeftPointAndSize - window: %p (START)\n", mWin); - setWindowClientTopLeftPointAndSize(mWin, x, y, w, h); + setWindowClientTopLeftPointAndSize(mWin, x, y, w, h, YES); DBG_PRINT( "setWindowClientTopLeftPointAndSize - window: %p (END)\n", mWin); diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index 6d1bcca00..09f4a1fd3 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -47,6 +47,8 @@ #define DBG_PRINT(...) #endif +// #define DBG_LIFECYCLE 1 + @interface NewtView : NSView { jobject javaWindowObject; @@ -56,16 +58,19 @@ int jvmVersion; volatile BOOL destroyNotifySent; - volatile BOOL softLocked; + volatile int softLockCount; pthread_mutex_t softLockSync; - NSTrackingRectTag ptrTrackingTag; + volatile NSTrackingRectTag ptrTrackingTag; NSRect ptrRect; NSCursor * myCursor; } - (id)initWithFrame:(NSRect)frameRect; + +#ifdef DBG_LIFECYCLE - (void) release; +#endif - (void) dealloc; /* Set during event dispatching cycle */ @@ -87,7 +92,7 @@ - (BOOL) getDestroyNotifySent; - (BOOL) softLock; -- (void) softUnlock; +- (BOOL) softUnlock; - (BOOL) needsDisplay; - (void) displayIfNeeded; @@ -125,18 +130,21 @@ defer: (BOOL) deferCreation screen:(NSScreen *)screen isFullscreenWindow:(BOOL)isfs; +#ifdef DBG_LIFECYCLE - (void) release; +#endif - (void) dealloc; -- (void) setUnrealized; +- (void) setRealized: (BOOL)v; - (BOOL) isRealized; -- (void) updateInsets: (JNIEnv*) env; +- (void) updateInsets: (JNIEnv*) env jwin: (jobject) javaWin; - (void) attachToParent: (NSWindow*) parent; - (void) detachFromParent: (NSWindow*) parent; - (NSPoint) newtAbsClientTLWinPos2AbsBLScreenPos: (NSPoint) p; - (NSPoint) newtAbsClientTLWinPos2AbsBLScreenPos: (NSPoint) p size: (NSSize) nsz; - (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p; +- (NSSize) newtClientSize2TLSize: (NSSize) nsz; - (NSPoint) getLocationOnScreen: (NSPoint) p; - (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 282c13fd3..d7b357349 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -113,7 +113,7 @@ static jmethodID windowRepaintID = NULL; jvmHandle = NULL; jvmVersion = 0; destroyNotifySent = NO; - softLocked = NO; + softLockCount = 0; pthread_mutexattr_t softLockSyncAttr; pthread_mutexattr_init(&softLockSyncAttr); @@ -134,19 +134,21 @@ static jmethodID windowRepaintID = NULL; return res; } +#ifdef DBG_LIFECYCLE - (void) release { DBG_PRINT("NewtView::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); -#ifdef VERBOSE_ON - // NSLog(@"%@",[NSThread callStackSymbols]); -#endif [super release]; } +#endif - (void) dealloc { DBG_PRINT("NewtView::dealloc.0: %p (refcnt %d), ptrTrackingTag %d\n", self, (int)[self retainCount], (int)ptrTrackingTag); - if(softLocked) { +#ifdef DBG_LIFECYCLE + NSLog(@"%@",[NSThread callStackSymbols]); +#endif + if( 0 < softLockCount ) { NSLog(@"NewtView::dealloc: softLock still hold @ dealloc!\n"); } if(0 != ptrTrackingTag) { @@ -155,9 +157,6 @@ static jmethodID windowRepaintID = NULL; ptrTrackingTag = 0; } pthread_mutex_destroy(&softLockSync); -#ifdef VERBOSE_ON - //NSLog(@"%@",[NSThread callStackSymbols]); -#endif DBG_PRINT("NewtView::dealloc.X: %p\n", self); [super dealloc]; } @@ -206,6 +205,7 @@ static jmethodID windowRepaintID = NULL; if(0 != ptrTrackingTag) { // [self removeCursorRect: ptrRect cursor: myCursor]; [self removeTrackingRect: ptrTrackingTag]; + ptrTrackingTag = 0; } ptrRect = [self bounds]; // [self addCursorRect: ptrRect cursor: myCursor]; @@ -230,18 +230,27 @@ static jmethodID windowRepaintID = NULL; - (BOOL) softLock { // DBG_PRINT("*************** softLock.0: %p\n", (void*)pthread_self()); - // NSLog(@"NewtView::softLock: %@",[NSThread callStackSymbols]); - pthread_mutex_lock(&softLockSync); - softLocked = YES; + int err; + if( 0 != ( err = pthread_mutex_lock(&softLockSync) ) ) { + NSLog(@"NewtView::softLock failed: errCode %d - %@", err, [NSThread callStackSymbols]); + return NO; + } + softLockCount++; // DBG_PRINT("*************** softLock.X: %p\n", (void*)pthread_self()); - return softLocked; + return 0 < softLockCount; } -- (void) softUnlock +- (BOOL) softUnlock { // DBG_PRINT("*************** softUnlock: %p\n", (void*)pthread_self()); - softLocked = NO; - pthread_mutex_unlock(&softLockSync); + softLockCount--; + int err; + if( 0 != ( err = pthread_mutex_unlock(&softLockSync) ) ) { + softLockCount++; + NSLog(@"NewtView::softUnlock failed: Not locked by current thread - errCode %d - %@", err, [NSThread callStackSymbols]); + return NO; + } + return YES; } - (BOOL) needsDisplay @@ -398,25 +407,26 @@ static jmethodID windowRepaintID = NULL; mouseInside = NO; cursorIsHidden = NO; realized = YES; - DBG_PRINT("NewtWindow::create: %p (refcnt %d)\n", res, (int)[res retainCount]); + DBG_PRINT("NewtWindow::create: %p, realized %d (refcnt %d)\n", res, realized, (int)[res retainCount]); return res; } +#ifdef DBG_LIFECYCLE - (void) release { DBG_PRINT("NewtWindow::release.0: %p (refcnt %d)\n", self, (int)[self retainCount]); -#ifdef VERBOSE_ON // NSLog(@"%@",[NSThread callStackSymbols]); -#endif [super release]; } +#endif - (void) dealloc { DBG_PRINT("NewtWindow::dealloc.0: %p (refcnt %d)\n", self, (int)[self retainCount]); -#ifdef VERBOSE_ON - // NSLog(@"%@",[NSThread callStackSymbols]); +#ifdef DBG_LIFECYCLE + NSLog(@"%@",[NSThread callStackSymbols]); #endif + NewtView* mView = (NewtView *)[self contentView]; if( NULL != mView ) { [mView release]; @@ -425,9 +435,9 @@ static jmethodID windowRepaintID = NULL; DBG_PRINT("NewtWindow::dealloc.X: %p\n", self); } -- (void) setUnrealized +- (void) setRealized: (BOOL)v { - realized = NO; + realized = v; } - (BOOL) isRealized @@ -435,18 +445,8 @@ static jmethodID windowRepaintID = NULL; return realized; } -- (void) updateInsets: (JNIEnv*) env +- (void) updateInsets: (JNIEnv*) env jwin: (jobject) javaWin { - NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { - return; - } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; - if (env==NULL || javaWindowObject == NULL) { - return; - } - NSRect frameRect = [self frame]; NSRect contentRect = [self contentRectForFrameRect: frameRect]; @@ -460,7 +460,9 @@ static jmethodID windowRepaintID = NULL; DBG_PRINT( "updateInsets: [ l %d, r %d, t %d, b %d ]\n", cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); - (*env)->CallVoidMethod(env, javaWindowObject, insetsChangedID, JNI_FALSE, cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); + if( NULL != env && NULL != javaWin ) { + (*env)->CallVoidMethod(env, javaWin, insetsChangedID, JNI_FALSE, cachedInsets[0], cachedInsets[1], cachedInsets[2], cachedInsets[3]); + } } - (void) attachToParent: (NSWindow*) parent @@ -502,11 +504,21 @@ static jmethodID windowRepaintID = NULL; { int totalHeight = nsz.height + cachedInsets[3]; // height + insets.bottom + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: given %d/%d %dx%d, insets bottom %d -> totalHeight %d\n", + (int)p.x, (int)p.y, (int)nsz.width, (int)nsz.height, cachedInsets[3], totalHeight); + NSScreen* screen = [self screen]; NSRect screenFrame = [screen frame]; - return NSMakePoint(screenFrame.origin.x + p.x, - screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight); + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: screen %d/%d %dx%d\n", + (int)screenFrame.origin.x, (int)screenFrame.origin.y, (int)screenFrame.size.width, (int)screenFrame.size.height); + + NSPoint r = NSMakePoint(screenFrame.origin.x + p.x, + screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight); + + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: result %d/%d\n", (int)r.x, (int)r.y); + + return r; } /** @@ -524,6 +536,12 @@ static jmethodID windowRepaintID = NULL; winFrame.origin.y + ( mViewFrame.size.height - p.y ) ); // y-flip in view } +- (NSSize) newtClientSize2TLSize: (NSSize) nsz +{ + NSSize topSZ = { nsz.width, nsz.height + cachedInsets[2] + cachedInsets[3] }; // height + insets.top + insets.bottom + return topSZ; +} + /** * y-flips input / output * p rel client window position w/ top-left origin @@ -646,7 +664,7 @@ static jint mods2JavaMods(NSUInteger mods) - (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType { NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return; } NewtView* view = (NewtView *) nsview; @@ -706,7 +724,7 @@ static jint mods2JavaMods(NSUInteger mods) - (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType { NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return; } NewtView* view = (NewtView *) nsview; @@ -783,7 +801,7 @@ static jint mods2JavaMods(NSUInteger mods) { DBG_PRINT( "focusChanged: gained %d\n", gained); NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return; } NewtView* view = (NewtView *) nsview; @@ -981,43 +999,42 @@ static jint mods2JavaMods(NSUInteger mods) - (void)windowDidResize: (NSNotification*) notification { - NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { - return; - } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; - if (javaWindowObject == NULL) { - DBG_PRINT("windowDidResize: null javaWindowObject\n"); - return; - } + JNIEnv* env = NULL; + jobject javaWindowObject = NULL; int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; - JNIEnv* env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached); - if(NULL==env) { - DBG_PRINT("windowDidResize: null JNIEnv\n"); - return; + JavaVM *jvmHandle = NULL; + + NSView* nsview = [self contentView]; + if( [nsview isKindOfClass:[NewtView class]] ) { + NewtView* view = (NewtView *) nsview; + javaWindowObject = [view getJavaWindowObject]; + if (javaWindowObject != NULL) { + jvmHandle = [view getJVMHandle]; + env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], &shallBeDetached); + } } // update insets on every window resize for lack of better hook place - [self updateInsets: env]; + [self updateInsets: env jwin:javaWindowObject]; - NSRect frameRect = [self frame]; - NSRect contentRect = [self contentRectForFrameRect: frameRect]; + if( NULL != env && NULL != javaWindowObject ) { + NSRect frameRect = [self frame]; + NSRect contentRect = [self contentRectForFrameRect: frameRect]; - (*env)->CallVoidMethod(env, javaWindowObject, sizeChangedID, JNI_FALSE, - (jint) contentRect.size.width, - (jint) contentRect.size.height, JNI_FALSE); + (*env)->CallVoidMethod(env, javaWindowObject, sizeChangedID, JNI_FALSE, + (jint) contentRect.size.width, + (jint) contentRect.size.height, JNI_FALSE); - if (shallBeDetached) { - (*jvmHandle)->DetachCurrentThread(jvmHandle); + if (shallBeDetached) { + (*jvmHandle)->DetachCurrentThread(jvmHandle); + } } } - (void)windowDidMove: (NSNotification*) notification { NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return; } NewtView* view = (NewtView *) nsview; @@ -1061,7 +1078,7 @@ static jint mods2JavaMods(NSUInteger mods) [self cursorHide: NO]; NSView* nsview = [self contentView]; - if( ! [nsview isMemberOfClass:[NewtView class]] ) { + if( ! [nsview isKindOfClass:[NewtView class]] ) { return NO; } NewtView* view = (NewtView *) nsview; -- cgit v1.2.3 From bfe40bf3670731ef44ff4066c2a7119f1ab43bf8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 20 Mar 2013 04:32:12 +0100 Subject: TestPNGTextureFromFileNEWT: Use new PNG test file locations, add RGBA tests and use alpha in drawable --- make/scripts/tests.sh | 8 +- .../util/texture/TestPNGTextureFromFileNEWT.java | 164 +++++++++++---------- 2 files changed, 89 insertions(+), 83 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 71e8ef98d..d897d7331 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -158,7 +158,8 @@ function jrun() { #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnativewindow.debug.X11Util" #D_ARGS="-Dnewt.debug.EDT -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator -Dnewt.debug.Display -Dnewt.debug.Screen" - #D_ARGS="-Dnewt.debug.Window -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator" + #D_ARGS="-Dnewt.debug.Window -Djogamp.common.utils.locks.Lock.timeout=600000" + #D_ARGS="-Dnewt.debug=all -Djogamp.common.utils.locks.Lock.timeout=600000" #D_ARGS="-Djogl.debug.Animator -Dnewt.debug=all" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Display -Dnativewindow.debug.X11Util -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLContext" @@ -197,6 +198,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" + D_ARGS="-Djogl.debug.PNGImage" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" #X_ARGS="-verbose:jni" @@ -269,7 +271,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* @@ -496,7 +498,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java index 15a0eec50..773b839a2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java @@ -61,72 +61,90 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { static boolean showFPS = false; static long duration = 100; // ms InputStream grayTextureStream; - InputStream testTextureStreamN; - InputStream testTextureStreamI; - InputStream testTextureStreamIG; - InputStream testTextureStreamPRGB; - InputStream testTextureStreamPRGBA;/* - InputStream testTextureStreamNRGBA; - InputStream testTextureStreamIRGBA;*/ + + InputStream testTextureStreamN_3; + InputStream testTextureStreamN_4; + InputStream testTextureStreamNG4; + + InputStream testTextureStreamI_3; + InputStream testTextureStreamIG3; + InputStream testTextureStreamI_4; + InputStream testTextureStreamIG4; + + InputStream testTextureStreamP_3; + InputStream testTextureStreamP_4; @Before public void initTest() throws IOException { grayTextureStream = TestPNGTextureFromFileNEWT.class.getResourceAsStream( "grayscale_texture.png" ); Assert.assertNotNull(grayTextureStream); { - URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscN01-160x90.png"); + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscN_3-01-160x90.png"); + Assert.assertNotNull(testTextureUrlConn); + testTextureStreamN_3 = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamN_3); + } + { + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscN_4-01-160x90.png"); + Assert.assertNotNull(testTextureUrlConn); + testTextureStreamN_4 = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamN_4); + } + { + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscNG4-01-160x90.png"); Assert.assertNotNull(testTextureUrlConn); - testTextureStreamN = testTextureUrlConn.getInputStream(); - Assert.assertNotNull(testTextureStreamN); + testTextureStreamNG4 = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamNG4); } + { - URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscI01-160x90.png"); + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscI_3-01-160x90.png"); Assert.assertNotNull(testTextureUrlConn); - testTextureStreamI = testTextureUrlConn.getInputStream(); - Assert.assertNotNull(testTextureStreamI); + testTextureStreamI_3 = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamI_3); } { - URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscIG01-160x90.png"); + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscIG3-01-160x90.png"); Assert.assertNotNull(testTextureUrlConn); - testTextureStreamIG = testTextureUrlConn.getInputStream(); - Assert.assertNotNull(testTextureStreamIG); + testTextureStreamIG3 = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamIG3); } { - URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscP301-160x90.png"); + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscI_4-01-160x90.png"); Assert.assertNotNull(testTextureUrlConn); - testTextureStreamPRGB = testTextureUrlConn.getInputStream(); - Assert.assertNotNull(testTextureStreamPRGB); + testTextureStreamI_4 = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamI_4); } { - URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscP401-160x90.png"); + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscIG4-01-160x90.png"); Assert.assertNotNull(testTextureUrlConn); - testTextureStreamPRGBA = testTextureUrlConn.getInputStream(); - Assert.assertNotNull(testTextureStreamPRGBA); + testTextureStreamIG4 = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamIG4); } - /*{ - URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscN401-160x90.png"); + + + { + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscP_3-01-160x90.png"); Assert.assertNotNull(testTextureUrlConn); - testTextureStreamNRGBA = testTextureUrlConn.getInputStream(); - Assert.assertNotNull(testTextureStreamNRGBA); + testTextureStreamP_3 = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamP_3); } { - URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscI401-160x90.png"); + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "test-ntscP_4-01-160x90.png"); Assert.assertNotNull(testTextureUrlConn); - testTextureStreamIRGBA = testTextureUrlConn.getInputStream(); - Assert.assertNotNull(testTextureStreamIRGBA); - }*/ + testTextureStreamP_4 = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStreamP_4); + } } @After public void cleanupTest() { grayTextureStream = null; - testTextureStreamN = null; - testTextureStreamI = null; - testTextureStreamIG = null; - testTextureStreamPRGB = null; - testTextureStreamPRGBA = null;/* - testTextureStreamNRGBA = null; - testTextureStreamIRGBA = null;*/ + testTextureStreamN_3 = null; + testTextureStreamI_3 = null; + testTextureStreamIG3 = null; + testTextureStreamP_3 = null; + testTextureStreamP_4 = null; } public void testImpl(boolean useFFP, final InputStream istream) throws InterruptedException, IOException { @@ -141,8 +159,10 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { return; } final GLCapabilities caps = new GLCapabilities(glp); + caps.setAlphaBits(1); + final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG); - System.err.println("TextureData: "+texData); + System.err.println("TextureData: "+texData); final GLWindow glad = GLWindow.create(caps); glad.setTitle("TestPNGTextureGL2FromFileNEWT"); @@ -187,76 +207,60 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { } @Test - public void testGrayPNGJLoaderGL2() throws InterruptedException, IOException { + public void testGray__GL2() throws InterruptedException, IOException { testImpl(true, grayTextureStream); } @Test - public void testGrayPNGJLoaderES2() throws InterruptedException, IOException { + public void testGray__ES2() throws InterruptedException, IOException { testImpl(false, grayTextureStream); } @Test - public void testTestN_PNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStreamN); + public void testRGB3__GL2() throws InterruptedException, IOException { + testImpl(true, testTextureStreamN_3); } @Test - public void testTestN_PNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStreamN); - } - - @Test - public void testTestI_PNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStreamI); + public void testRGB3__ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamN_3); } @Test - public void testTestI_PNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStreamI); - } - - @Test - public void testTestIG_PNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStreamIG); + public void testRGB4__GL2() throws InterruptedException, IOException { + testImpl(true, testTextureStreamN_4); } @Test - public void testTestIG_PNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStreamIG); - } - - @Test - public void testTestPRGB_PNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStreamPRGB); + public void testRGB4__ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamN_4); } @Test - public void testTestPRGB_PNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStreamPRGB); + public void testRGB4G_ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamNG4); } @Test - public void testTestPRGBA_PNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStreamPRGBA); + public void testInterl3__ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamI_3); } @Test - public void testTestPRGBA_PNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStreamPRGBA); + public void testInterl4__ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamI_4); } - - /*@Test - public void testTestNRGBA_PNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStreamNRGBA); + @Test + public void testInterl3G_ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamIG3); } @Test - public void testTestNRGBA_PNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStreamNRGBA); + public void testInterl4G_ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamIG4); } @Test - public void testTestIRGBA_PNGJLoaderGL2() throws InterruptedException, IOException { - testImpl(true, testTextureStreamIRGBA); + public void testPalette3__ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamP_3); } @Test - public void testTestIRGBA_PNGJLoaderES2() throws InterruptedException, IOException { - testImpl(false, testTextureStreamIRGBA); - }*/ + public void testPalette4__ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStreamP_4); + } public static void main(String args[]) throws IOException { for(int i=0; i Date: Wed, 20 Mar 2013 10:58:07 +0100 Subject: TestGearsES2NEWT/TestGearsES2NewtCanvasAWT: Add -noanim option to manually validate Bug 649 --- make/scripts/tests.sh | 9 +++-- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 43 +++++++++++++++------- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 43 +++++++++++++++------- 3 files changed, 64 insertions(+), 31 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d897d7331..7dfca6e6f 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -198,7 +198,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" - D_ARGS="-Djogl.debug.PNGImage" + #D_ARGS="-Djogl.debug.PNGImage" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" #X_ARGS="-verbose:jni" @@ -271,7 +271,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* @@ -498,7 +498,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* @@ -559,6 +559,9 @@ testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileN # OSX Java6 NEWT # +# Freeze +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* + # Cut-off top #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 14b1f04b0..5dee22e1d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -89,6 +89,7 @@ public class TestGearsES2NEWT extends UITestCase { static boolean forceGL3 = false; static boolean mainRun = false; static boolean exclusiveContext = false; + static boolean useAnimator = true; @BeforeClass public static void initClass() { @@ -138,9 +139,11 @@ public class TestGearsES2NEWT extends UITestCase { }); } - Animator animator = new Animator(); - animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); - animator.setExclusiveContext(exclusiveContext); + final Animator animator = useAnimator ? new Animator() : null; + if( useAnimator ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + animator.setExclusiveContext(exclusiveContext); + } QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); @@ -246,14 +249,18 @@ public class TestGearsES2NEWT extends UITestCase { } }); - animator.add(glWindow); - animator.start(); - Assert.assertTrue(animator.isStarted()); - Assert.assertTrue(animator.isAnimating()); - Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); + if( useAnimator ) { + animator.add(glWindow); + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); + } glWindow.setVisible(true); - animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + if( useAnimator ) { + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + } System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); @@ -265,14 +272,19 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("window resize pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); } - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); } - while(!quitAdapter.shouldQuit() && animator.getTotalFPSDuration() Date: Wed, 20 Mar 2013 17:23:17 +0100 Subject: OSX/NEWT: Fix visible -> false when closing and reparenting window. This lead to non functional recreational reparenting. OSX recreational reparenting moves the saved GLEventListenerState at destroy to the new dawable/surface, which must be valid. The flaky visible state caused seemingly random reparenting failures. - WindowImpl.ReparentActionRecreate.run() set 'visible:=true', which circumvented OSX to wait for actual realization. - OSX WindowDriver.closeNative(): Issue visibleChanged(true, false); ASAP --- make/scripts/tests.sh | 2 -- src/newt/classes/jogamp/newt/WindowImpl.java | 1 - src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java | 7 ++++--- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7dfca6e6f..60990e3b4 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -352,7 +352,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT @@ -560,7 +559,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA # # Freeze -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* # Cut-off top #testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index c01f880fc..45100421a 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1275,7 +1275,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RecursiveLock _lock = windowLock; _lock.lock(); try { - visible = true; if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparentWindow: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow)); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 653e90e3b..965138ddf 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -80,10 +80,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl try { if(DEBUG_IMPLEMENTATION) { System.err.println("MacWindow.CloseAction "+Thread.currentThread().getName()); } final long handle = getWindowHandle(); + visibleChanged(true, false); setWindowHandle(0); surfaceHandle = 0; sscSurfaceHandle = 0; - isOffscreenInstance = false; + isOffscreenInstance = false; if (0 != handle) { OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { @@ -284,7 +285,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl 0 != ( FLAG_CHANGE_PARENTING & flags) || 0 != ( FLAG_CHANGE_FULLSCREEN & flags) ) { if(isOffscreenInstance) { - createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false, false, false); + createWindow(true, 0 != getWindowHandle(), pClientLevelOnSreen, 64, 64, false, setVisible, false); } else { createWindow(false, 0 != getWindowHandle(), pClientLevelOnSreen, width, height, 0 != ( FLAG_IS_FULLSCREEN & flags), setVisible, 0 != ( FLAG_IS_ALWAYSONTOP & flags)); @@ -488,7 +489,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl public void run() { initWindow0( parentWin, newWin, pS.getX(), pS.getY(), width, height, - isOpaque, fullscreen, visible, getScreen().getIndex(), surfaceHandle); + isOpaque, fullscreen, visible && !offscreenInstance, getScreen().getIndex(), surfaceHandle); if( offscreenInstance ) { orderOut0(0!=parentWin ? parentWin : newWin); } else { -- cgit v1.2.3 From a0c50530714ceb3072e258b8704cd05376d30074 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 27 Mar 2013 03:19:38 +0100 Subject: Unit Tests: Unify 'AWT Robot Key Press/Release', waitForIdle, action, delay, waitForIdle ; TestFocus0*: Wait until closed after win.destroy(). --- make/scripts/java-win64-dbg.bat | 2 +- make/scripts/tests-x64.bat | 7 ++-- make/scripts/tests.sh | 6 ++-- .../test/junit/newt/TestFocus01SwingAWTRobot.java | 1 + .../test/junit/newt/TestFocus02SwingAWTRobot.java | 1 + .../opengl/test/junit/util/AWTRobotUtil.java | 37 ++++++++++++++-------- 6 files changed, 32 insertions(+), 22 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index ee7fe80e7..1f712bae7 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -40,7 +40,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Dnewt.debug.Window" -REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index df855bf56..22f413ef7 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -69,12 +69,10 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtK REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* @@ -98,11 +96,10 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug6 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 60990e3b4..c5d00fb97 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -170,7 +170,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -271,7 +271,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* @@ -433,7 +433,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA # #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug -#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* +testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java index a87cbe0ac..672a44154 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java @@ -208,6 +208,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase { Assume.assumeNoException( throwable ); } glWindow1.destroy(); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, false)); } static int atoi(String a) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java index 978bc1c0a..5d0a0fbb5 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java @@ -262,6 +262,7 @@ public class TestFocus02SwingAWTRobot extends UITestCase { } }); glWindow1.destroy(); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, false)); } @Test diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 960145e78..4195711d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -393,6 +393,19 @@ public class AWTRobotUtil { Assert.assertTrue("Did not gain focus", hasFocus); } + private static void awtRobotKeyPress(final Robot robot, final int keyCode, final int msDelay) { + robot.waitForIdle(); + robot.keyPress(keyCode); + robot.delay(msDelay); + robot.waitForIdle(); + } + private static void awtRobotKeyRelease(final Robot robot, final int keyCode, final int msDelay) { + robot.waitForIdle(); + robot.keyRelease(keyCode); + robot.delay(msDelay); + robot.waitForIdle(); + } + public static int keyType(int i, Robot robot, int keyCode, Object obj, KeyEventCountAdapter counter) throws InterruptedException, AWTException, InvocationTargetException { @@ -404,24 +417,23 @@ public class AWTRobotUtil { for(j=0; 1 > tc && j tc; wait++) { + if(DEBUG) { System.err.println(i+":"+j+" KC1.4."+wait+": "+counter+", sleep for "+TIME_OUT+"ms"); } robot.delay(TIME_SLICE); tc = counter.getCount() - c0; } - if(DEBUG) { System.err.println(i+":"+j+" KC1.X: tc "+tc+", "+counter); } + if(DEBUG) { System.err.println(i+":"+j+" KC1.X: tc "+tc+", "+counter+" on thread "+Thread.currentThread().getName()); } } - Assert.assertEquals("Key ("+i+":"+j+") not typed one time", 1, tc); + Assert.assertEquals("Key ("+i+":"+j+") not typed one time on thread "+Thread.currentThread().getName(), 1, tc); return (int) ( System.currentTimeMillis() - t0 ) ; } @@ -429,11 +441,10 @@ public class AWTRobotUtil { public static int keyPress(int i, Robot robot, boolean press, int keyCode, int msDelay) { final long t0 = System.currentTimeMillis(); if(press) { - robot.keyPress(keyCode); + awtRobotKeyPress(robot, keyCode, msDelay); } else { - robot.keyRelease(keyCode); + awtRobotKeyRelease(robot, keyCode, msDelay); } - robot.delay(msDelay); return (int) ( System.currentTimeMillis() - t0 ) ; } -- cgit v1.2.3 From 0b242442fba01df86be636f54e3d478aa722d6a7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 28 Mar 2013 23:24:39 +0100 Subject: Adapt to new version scheme, see GlueGen a3f2ef50ad33c58a240a17fcf03e415d772207c3, etc; Fix NewtVersion, NativeWindowVersion and NewtVersionActivityLauncher NewtVersion, NativeWindowVersion: Also search for extension javax.media.opengl (all packaging) NewtVersionActivityLauncher: Use new launcher URI --- make/build-common.xml | 11 +---- make/build-jogl.xml | 9 +++-- make/build-nativewindow.xml | 9 +++-- make/build-newt.xml | 9 +++-- make/build-test.xml | 14 ++++--- make/build.xml | 13 +++--- make/joglversion | 1 + make/joglversion-test | 3 +- make/joglversion-test-android | 3 +- make/scripts/tests.sh | 12 +++--- make/versions.xml | 47 ---------------------- .../jogamp/nativewindow/NativeWindowVersion.java | 8 ++-- src/newt/classes/com/jogamp/newt/NewtVersion.java | 7 ++-- .../android/NewtVersionActivityLauncher.java | 2 +- 14 files changed, 51 insertions(+), 97 deletions(-) delete mode 100644 make/versions.xml (limited to 'make/scripts') diff --git a/make/build-common.xml b/make/build-common.xml index f68cc43be..dd33b1683 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -27,8 +27,6 @@ - - - - - - + diff --git a/make/build-jogl.xml b/make/build-jogl.xml index c481eb0f5..ce532c2b4 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -150,7 +150,7 @@ value="com/jogamp/opengl/**/swt/**"/> + value="com/jogamp/opengl/util/texture/** com/jogamp/opengl/util/av/* com/jogamp/opengl/util/packrect/** jogamp/opengl/util/av/** jogamp/opengl/util/jpeg/** jogamp/opengl/util/pngj/**"/> @@ -298,7 +298,7 @@ - + @@ -1551,10 +1551,11 @@ tofile="${build.jogl}/manifest.mf" overwrite="true"> - + + - +
    diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index d7ef73a46..6a42d72d4 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -149,7 +149,7 @@ - + @@ -794,10 +794,11 @@ tofile="${build.nativewindow}/manifest.mf" overwrite="true"> - + + - +
    @@ -934,7 +935,7 @@ - + diff --git a/make/build-newt.xml b/make/build-newt.xml index c3b51141f..864e0f93e 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -188,7 +188,7 @@ - + @@ -733,10 +733,11 @@ tofile="${build.newt}/manifest.mf" overwrite="true"> - + + - +
    @@ -907,7 +908,7 @@ - + diff --git a/make/build-test.xml b/make/build-test.xml index da6e3ec29..dd072bddb 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -78,10 +78,11 @@ tofile="${build.test}/manifest-test.mf" overwrite="true"> - + + - + @@ -114,10 +115,11 @@ tofile="${build.test}/manifest-test-android.mf" overwrite="true"> - + + - + @@ -142,8 +144,8 @@ androidmanifest.path="resources/android/AndroidManifest-test.xml" androidresources.path="resources/android/res-test" jarmanifest.path="${build.test}/manifest-test-android.mf" - version.code="${jogl_int_version}" - version.name="${jogl.version.plus}" /> + version.code="${jogamp.version.int}" + version.name="${jogamp.version}" /> diff --git a/make/build.xml b/make/build.xml index 44adf805f..0c6c97d34 100644 --- a/make/build.xml +++ b/make/build.xml @@ -165,8 +165,8 @@ androidmanifest.path="resources/android/AndroidManifest-jogl.xml" androidresources.path="resources/android/res-jogl" jarmanifest.path="${build.jogl}/manifest.mf" - version.code="${jogl_int_version}" - version.name="${jogl.version.plus}" /> + version.code="${jogamp.version.int}" + version.name="${jogamp.version}" /> @@ -241,10 +241,11 @@ tofile="${archive}/README.txt" overwrite="true"> - + + - + @@ -343,10 +344,10 @@ - + - + diff --git a/make/joglversion b/make/joglversion index bf0220fa0..3dc57cf32 100644 --- a/make/joglversion +++ b/make/joglversion @@ -4,6 +4,7 @@ Specification-Version: @BASEVERSION@ Specification-Vendor: JogAmp Community Implementation-Title: Java Bindings for OpenGL Runtime Environment Implementation-Version: @VERSION@ +Implementation-Build: @BUILD_VERSION@ Implementation-Branch: @SCM_BRANCH@ Implementation-Commit: @SCM_COMMIT@ Implementation-Vendor: JogAmp Community diff --git a/make/joglversion-test b/make/joglversion-test index cee93dbb4..b130bb279 100644 --- a/make/joglversion-test +++ b/make/joglversion-test @@ -2,8 +2,9 @@ Manifest-Version: 1.0 Specification-Title: Test Java Bindings for OpenGL API Specification Specification-Version: @BASEVERSION@ Specification-Vendor: JogAmp Community -Implementation-Title: Test Java Bindings for OpenGL Runtime Environment +Implementation-Title: Test JOGL Runtime Environment Implementation-Version: @VERSION@ +Implementation-Build: @BUILD_VERSION@ Implementation-Branch: @SCM_BRANCH@ Implementation-Commit: @SCM_COMMIT@ Implementation-Vendor: JogAmp Community diff --git a/make/joglversion-test-android b/make/joglversion-test-android index 88c35bed1..153b3c3b9 100644 --- a/make/joglversion-test-android +++ b/make/joglversion-test-android @@ -2,8 +2,9 @@ Manifest-Version: 1.0 Specification-Title: Test Java Bindings for OpenGL API Specification Specification-Version: @BASEVERSION@ Specification-Vendor: JogAmp Community -Implementation-Title: Test Java Bindings for OpenGL Runtime Environment on Android +Implementation-Title: Test JOGL Android Runtime Environment Implementation-Version: @VERSION@ +Implementation-Build: @BUILD_VERSION@ Implementation-Branch: @SCM_BRANCH@ Implementation-Commit: @SCM_COMMIT@ Implementation-Vendor: JogAmp Community diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c5d00fb97..41a06ea90 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -170,7 +170,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -294,7 +294,7 @@ function testawtswt() { # #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* -#testnoawt com.jogamp.newt.NewtVersion $* +testnoawt com.jogamp.newt.NewtVersion $* #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -433,7 +433,7 @@ function testawtswt() { # #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug -testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* @@ -494,8 +494,9 @@ testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* # # Texture / TextureUtils # -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* @@ -544,9 +545,6 @@ testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* # # regressions # -#Windows -#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* # osx: #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* diff --git a/make/versions.xml b/make/versions.xml deleted file mode 100644 index 6256831d3..000000000 --- a/make/versions.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java index 38bd70a90..29f4964c0 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/NativeWindowVersion.java @@ -31,6 +31,7 @@ package com.jogamp.nativewindow; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.JogampVersion; import com.jogamp.common.util.VersionUtil; + import java.util.jar.Manifest; public class NativeWindowVersion extends JogampVersion { @@ -45,9 +46,10 @@ public class NativeWindowVersion extends JogampVersion { if(null == jogampCommonVersionInfo) { // volatile: ok synchronized(NativeWindowVersion.class) { if( null == jogampCommonVersionInfo ) { - final String packageName = "javax.media.nativewindow"; - final Manifest mf = VersionUtil.getManifest(NativeWindowVersion.class.getClassLoader(), packageName); - jogampCommonVersionInfo = new NativeWindowVersion(packageName, mf); + final String packageName1 = "javax.media.nativewindow"; // atomic packaging - and identity + final String packageName2 = "javax.media.opengl"; // all packaging + final Manifest mf = VersionUtil.getManifest(NativeWindowVersion.class.getClassLoader(), new String[]{ packageName1, packageName2 } ); + jogampCommonVersionInfo = new NativeWindowVersion(packageName1, mf); } } } diff --git a/src/newt/classes/com/jogamp/newt/NewtVersion.java b/src/newt/classes/com/jogamp/newt/NewtVersion.java index 961ffdf6a..9adb7aac5 100644 --- a/src/newt/classes/com/jogamp/newt/NewtVersion.java +++ b/src/newt/classes/com/jogamp/newt/NewtVersion.java @@ -46,9 +46,10 @@ public class NewtVersion extends JogampVersion { if(null == jogampCommonVersionInfo) { // volatile: ok synchronized(NewtVersion.class) { if( null == jogampCommonVersionInfo ) { - final String packageName = "com.jogamp.newt"; - final Manifest mf = VersionUtil.getManifest(NewtVersion.class.getClassLoader(), packageName); - jogampCommonVersionInfo = new NewtVersion(packageName, mf); + final String packageName1 = "com.jogamp.newt"; // atomic packaging - and identity + final String packageName2 = "javax.media.opengl"; // all packaging + final Manifest mf = VersionUtil.getManifest(NativeWindowVersion.class.getClassLoader(), new String[]{ packageName1, packageName2 } ); + jogampCommonVersionInfo = new NewtVersion(packageName1, mf); } } } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java index cb8799b19..9b3c6e24b 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java @@ -11,7 +11,7 @@ public class NewtVersionActivityLauncher extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity"); + final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test"); final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri); Log.d(getClass().getSimpleName(), "Launching Activity: "+intent); startActivity (intent); -- cgit v1.2.3 From a54bd3e963a7be320dee0c9692d237607fcd0f96 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 1 Apr 2013 05:16:35 +0200 Subject: Fix Bug 671: Add JPEG Decoder w/o AWT Dependencies Original JavaScript code from , author 'notmasteryet' . Ported to Java. Enhancements: * InputStream instead of memory buffer * User provided memory handler * Fixed JPEG Component ID/Index mapping * Color space conversion (YCCK, CMYK -> RGB) * More error tolerant +++ Features: JOGL AWT RGB ok ok YCCK ok Exception CMYK ok Exception YUV Store ok n/a Need Y-Flip no yes +++ Benchmark: TestJPEGJoglAWTBenchmarkNewtAWT JOGL.RGB Loops 100, dt 1199 ms, 11.99 ms/l JOGL.YUV Loops 100, dt 351 ms, 3.51 ms/l AWT..... Loops 100, dt 2144 ms, 21.44 ms/l File: jogl/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/j1-baseline.jpg Machine: GNU/Linux PC (AMD 8 core), JavaSE 6 (1.6.0_38) .++++ UITestCase.setUp: com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT - benchmark libEGL warning: DRI2: failed to authenticate 0: JPEGImage[261x202, bytesPerPixel 3, reversedChannels false, JPEGPixels[261x202, sourceComp 3, sourceCS YCbCr, storageCS RGB, storageComp 3], java.nio.DirectByteBuffer[pos=0 lim=158166 cap=158166]] 0: TextureData[261x202, y-flip false, internFormat 0x1907, pixelFormat 0x1907, pixelType 0x1401, border 0, estSize 158166, alignment 1, rowlen 0, buffer java.nio.DirectByteBuffer[pos=0 lim=158166 cap=158166] JOGL.RGB Loops 100, dt 1199 ms, 11.99 ms/l 0: JPEGImage[261x202, bytesPerPixel 3, reversedChannels false, JPEGPixels[261x202, sourceComp 3, sourceCS YCbCr, storageCS YCbCr, storageComp 3], java.nio.DirectByteBuffer[pos=0 lim=158166 cap=158166]] 0: TextureData[261x202, y-flip false, internFormat 0x1907, pixelFormat 0x1907, pixelType 0x1401, border 0, estSize 158166, alignment 1, rowlen 0, buffer java.nio.DirectByteBuffer[pos=0 lim=158166 cap=158166] JOGL.YUV Loops 100, dt 351 ms, 3.51 ms/l 0: TextureData[261x202, y-flip true, internFormat 0x1907, pixelFormat 0x80e0, pixelType 0x1401, border 0, estSize 158166, alignment 1, rowlen 261, buffer java.nio.HeapByteBuffer[pos=0 lim=158166 cap=158166] AWT..... Loops 100, dt 2144 ms, 21.44 ms/l ++++ UITestCase.tearDown: com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT - benchmark --- make/scripts/tests.sh | 7 +- .../jogamp/opengl/util/texture/TextureData.java | 15 + .../com/jogamp/opengl/util/texture/TextureIO.java | 57 +- .../opengl/util/texture/awt/AWTTextureData.java | 50 +- .../jogamp/opengl/util/texture/spi/JPEGImage.java | 175 +++ .../jogamp/opengl/util/jpeg/JPEGDecoder.java | 1505 ++++++++++++++++++++ .../jogl/util/texture/TestJPEGImage01NEWT.java | 124 ++ .../texture/TestJPEGJoglAWTBenchmarkNewtAWT.java | 152 ++ .../texture/TestJPEGJoglAWTCompareNewtAWT.java | 267 ++++ .../util/texture/TestJPEGTextureFromFileNEWT.java | 264 ++++ .../test/junit/jogl/util/texture/j1-baseline.jpg | Bin 0 -> 21257 bytes .../junit/jogl/util/texture/j2-progressive.jpg | Bin 0 -> 22306 bytes .../junit/jogl/util/texture/j3-baseline_gray.jpg | Bin 0 -> 17776 bytes .../test/junit/jogl/util/texture/test-cmyk-01.jpg | Bin 0 -> 10445 bytes .../test-ntscN_3-01-160x90-60pct-yuv422h-base.jpg | Bin 0 -> 2628 bytes .../test-ntscN_3-01-160x90-60pct-yuv422h-prog.jpg | Bin 0 -> 2376 bytes .../test-ntscN_3-01-160x90-90pct-yuv444-base.jpg | Bin 0 -> 4122 bytes .../test-ntscN_3-01-160x90-90pct-yuv444-prog.jpg | Bin 0 -> 4411 bytes .../test/junit/jogl/util/texture/test-ycck-01.jpg | Bin 0 -> 62492 bytes 19 files changed, 2595 insertions(+), 21 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java create mode 100644 src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTBenchmarkNewtAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTCompareNewtAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/j1-baseline.jpg create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/j2-progressive.jpg create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/j3-baseline_gray.jpg create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-cmyk-01.jpg create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscN_3-01-160x90-60pct-yuv422h-base.jpg create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscN_3-01-160x90-60pct-yuv422h-prog.jpg create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscN_3-01-160x90-90pct-yuv444-base.jpg create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ntscN_3-01-160x90-90pct-yuv444-prog.jpg create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/test-ycck-01.jpg (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 41a06ea90..48fa02a6c 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -199,6 +199,7 @@ function jrun() { #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.PNGImage" + #D_ARGS="-Djogl.debug.JPEGImage" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" #X_ARGS="-verbose:jni" @@ -294,7 +295,7 @@ function testawtswt() { # #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* -testnoawt com.jogamp.newt.NewtVersion $* +#testnoawt com.jogamp.newt.NewtVersion $* #testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* @@ -495,7 +496,11 @@ testnoawt com.jogamp.newt.NewtVersion $* # Texture / TextureUtils # #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java index 96ee233fd..5b72bea82 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java @@ -54,6 +54,8 @@ import com.jogamp.opengl.util.GLBuffers; */ public class TextureData { + public static enum ColorSpace { RGB, YCbCr, YCCK, CMYK }; + protected int width; protected int height; private int border; @@ -77,6 +79,7 @@ public class TextureData { protected boolean haveEXTABGR; protected boolean haveGL12; protected GLProfile glProfile; + protected ColorSpace pixelCS = ColorSpace.RGB; /** * Constructs a new TextureData object with the specified parameters @@ -217,6 +220,18 @@ public class TextureData { } } + /** + * Returns the color space of the pixel data. + * @see #setColorSpace(ColorSpace) + */ + public ColorSpace getColorSpace() { return pixelCS; } + + /** + * Set the color space of the pixel data, which defaults to {@link ColorSpace#RGB}. + * @see #getColorSpace() + */ + public void setColorSpace(ColorSpace cs) { pixelCS = cs; } + /** Used only by subclasses */ protected TextureData(GLProfile glp) { this.glProfile = glp; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java index b878c6002..0b0af5625 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java @@ -63,6 +63,7 @@ import jogamp.opengl.Debug; import com.jogamp.common.util.IOUtil; import com.jogamp.opengl.util.texture.spi.DDSImage; +import com.jogamp.opengl.util.texture.spi.JPEGImage; import com.jogamp.opengl.util.texture.spi.NetPbmTextureWriter; import com.jogamp.opengl.util.texture.spi.PNGImage; import com.jogamp.opengl.util.texture.spi.SGIImage; @@ -714,8 +715,12 @@ public class TextureIO { // SPI support // - /** Adds a TextureProvider to support reading of a new file - format. */ + /** + * Adds a TextureProvider to support reading of a new file format. + *

    + * The last provider added, will be the first provider to be tested. + *

    + */ public static void addTextureProvider(TextureProvider provider) { // Must always add at the front so the ImageIO provider is last, // so we don't accidentally use it instead of a user's possibly @@ -723,8 +728,12 @@ public class TextureIO { textureProviders.add(0, provider); } - /** Adds a TextureWriter to support writing of a new file - format. */ + /** + * Adds a TextureWriter to support writing of a new file format. + *

    + * The last provider added, will be the first provider to be tested. + *

    + */ public static void addTextureWriter(TextureWriter writer) { // Must always add at the front so the ImageIO writer is last, // so we don't accidentally use it instead of a user's possibly @@ -768,7 +777,7 @@ public class TextureIO { private static List textureProviders = new ArrayList(); private static List textureWriters = new ArrayList(); - static { + static { // ImageIO provider, the fall-back, must be the first one added if(GLProfile.isAWTAvailable()) { try { @@ -787,6 +796,7 @@ public class TextureIO { addTextureProvider(new DDSTextureProvider()); addTextureProvider(new SGITextureProvider()); addTextureProvider(new TGATextureProvider()); + addTextureProvider(new JPGTextureProvider()); addTextureProvider(new PNGTextureProvider()); // ImageIO writer, the fall-back, must be the first one added @@ -1173,6 +1183,43 @@ public class TextureIO { } } + //---------------------------------------------------------------------- + // JPEG image provider + static class JPGTextureProvider extends StreamBasedTextureProvider { + public TextureData newTextureData(GLProfile glp, InputStream stream, + int internalFormat, + int pixelFormat, + boolean mipmap, + String fileSuffix) throws IOException { + if (JPG.equals(fileSuffix)) { + JPEGImage image = JPEGImage.read(/*glp, */ stream); + if (pixelFormat == 0) { + pixelFormat = image.getGLFormat(); + } + if (internalFormat == 0) { + if(glp.isGL2GL3()) { + internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA8:GL.GL_RGB8; + } else { + internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB; + } + } + return new TextureData(glp, internalFormat, + image.getWidth(), + image.getHeight(), + 0, + pixelFormat, + image.getGLType(), + mipmap, + false, + false, + image.getData(), + null); + } + + return null; + } + } + //---------------------------------------------------------------------- // DDS texture writer // diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java index ad96a9939..3b90fad65 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java @@ -37,15 +37,35 @@ package com.jogamp.opengl.util.texture.awt; import java.awt.AlphaComposite; -import java.awt.Color; import java.awt.Graphics2D; import java.awt.Transparency; -import java.awt.color.*; -import java.awt.image.*; -import java.nio.*; +import java.awt.image.BufferedImage; +import java.awt.image.ComponentColorModel; +import java.awt.image.ComponentSampleModel; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.DataBufferDouble; +import java.awt.image.DataBufferFloat; +import java.awt.image.DataBufferInt; +import java.awt.image.DataBufferShort; +import java.awt.image.DataBufferUShort; +import java.awt.image.MultiPixelPackedSampleModel; +import java.awt.image.SampleModel; +import java.awt.image.SinglePixelPackedSampleModel; +import java.awt.image.WritableRaster; +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.ShortBuffer; -import javax.media.opengl.*; -import com.jogamp.opengl.util.texture.*; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.texture.TextureData; public class AWTTextureData extends TextureData { // Mechanism for lazily converting input BufferedImages with custom @@ -56,13 +76,13 @@ public class AWTTextureData extends TextureData { private boolean expectingEXTABGR; private boolean expectingGL12; - private static final ColorModel rgbaColorModel = - new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + private static final java.awt.image.ColorModel rgbaColorModel = + new ComponentColorModel(java.awt.color.ColorSpace.getInstance(java.awt.color.ColorSpace.CS_sRGB), new int[] {8, 8, 8, 8}, true, true, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); - private static final ColorModel rgbColorModel = - new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + private static final java.awt.image.ColorModel rgbColorModel = + new ComponentColorModel(java.awt.color.ColorSpace.getInstance(java.awt.color.ColorSpace.CS_sRGB), new int[] {8, 8, 8, 0}, false, false, Transparency.OPAQUE, DataBuffer.TYPE_BYTE); @@ -282,7 +302,7 @@ public class AWTTextureData extends TextureData { case BufferedImage.TYPE_BYTE_INDEXED: case BufferedImage.TYPE_CUSTOM: default: - ColorModel cm = image.getColorModel(); + java.awt.image.ColorModel cm = image.getColorModel(); if (cm.equals(rgbColorModel)) { pixelFormat = GL.GL_RGB; pixelType = GL.GL_UNSIGNED_BYTE; @@ -350,7 +370,7 @@ public class AWTTextureData extends TextureData { case BufferedImage.TYPE_BYTE_INDEXED: case BufferedImage.TYPE_CUSTOM: default: - ColorModel cm = image.getColorModel(); + java.awt.image.ColorModel cm = image.getColorModel(); if (cm.equals(rgbColorModel)) { pixelFormat = GL.GL_RGB; pixelType = GL.GL_UNSIGNED_BYTE; @@ -409,7 +429,7 @@ public class AWTTextureData extends TextureData { // create a temporary image that is compatible with OpenGL boolean hasAlpha = image.getColorModel().hasAlpha(); - ColorModel cm = null; + java.awt.image.ColorModel cm = null; int dataBufferType = image.getRaster().getDataBuffer().getDataType(); // Don't use integer components for packed int images if (isPackedInt(image)) { @@ -419,12 +439,12 @@ public class AWTTextureData extends TextureData { cm = hasAlpha ? rgbaColorModel : rgbColorModel; } else { if (hasAlpha) { - cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + cm = new ComponentColorModel(java.awt.color.ColorSpace.getInstance(java.awt.color.ColorSpace.CS_sRGB), null, true, true, Transparency.TRANSLUCENT, dataBufferType); } else { - cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB), + cm = new ComponentColorModel(java.awt.color.ColorSpace.getInstance(java.awt.color.ColorSpace.CS_sRGB), null, false, false, Transparency.OPAQUE, dataBufferType); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java new file mode 100644 index 000000000..71dd53939 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/JPEGImage.java @@ -0,0 +1,175 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.texture.spi; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; + +import javax.media.opengl.GL; + +import jogamp.opengl.Debug; +import jogamp.opengl.util.jpeg.JPEGDecoder; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.util.texture.TextureData.ColorSpace; + +public class JPEGImage { + private static final boolean DEBUG = Debug.debug("JPEGImage"); + + + /** + * Reads a JPEG image from the specified InputStream, using the given color space for storage. + * + * @param in + * @param cs Storage color space, either {@link ColorSpace#RGB} or {@link ColorSpace#YCbCr}. {@link ColorSpace#YCCK} and {@link ColorSpace#CMYK} will throw an exception! + * @return + * @throws IOException + */ + public static JPEGImage read(InputStream in, ColorSpace cs) throws IOException { + return new JPEGImage(in, cs); + } + + /** Reads a JPEG image from the specified InputStream, using the {@link ColorSpace#RGB}. */ + public static JPEGImage read(InputStream in) throws IOException { + return new JPEGImage(in, ColorSpace.RGB); + } + + private static class JPEGPixelStorage implements JPEGDecoder.PixelStorage { + int width=0, height=0; + int sourceComponents=0; + ColorSpace sourceCS = ColorSpace.YCbCr; + int storageComponents; + final ColorSpace storageCS; + ByteBuffer data = null; + + JPEGPixelStorage(ColorSpace storageCM) { + this.storageCS = storageCM; + switch(storageCS) { + case RGB: + case YCbCr: + storageComponents = 3; + break; + default: + throw new IllegalArgumentException("Unsupported storage color-space: "+storageCS); + } + } + + @Override + public final ColorSpace allocate(int width, int height, ColorSpace sourceCM, int sourceComponents) throws RuntimeException { + this.width = width; + this.height = height; + this.sourceComponents = sourceComponents; + this.sourceCS = sourceCM; + this.data = Buffers.newDirectByteBuffer(width * height * storageComponents); + return storageCS; + } + + @Override + public final void storeRGB(int x, int y, byte r, byte g, byte b) { + int i = ( ( height - y - 1 ) * width + x ) * storageComponents; + data.put(i++, r); + data.put(i++, g); + data.put(i++, b); + // data.put(i++, (byte)0xff); + } + + @Override + public final void store2(int x, int y, byte c1, byte c2) { + throw new RuntimeException("not supported yet"); + } + + @Override + public final void storeYCbCr(int x, int y, byte Y, byte Cb, byte Cr) { + int i = ( ( height - y - 1 ) * width + x ) * storageComponents; + data.put(i++, Y); + data.put(i++, Cb); + data.put(i++, Cr); + } + + public String toString() { + return "JPEGPixels["+width+"x"+height+", sourceComp "+sourceComponents+", sourceCS "+sourceCS+", storageCS "+storageCS+", storageComp "+storageComponents+"]"; + } + }; + + private JPEGImage(InputStream in, ColorSpace cs) throws IOException { + pixelStorage = new JPEGPixelStorage(cs); + final JPEGDecoder decoder = new JPEGDecoder(); + decoder.parse(in); + pixelWidth = decoder.getWidth(); + pixelHeight = decoder.getHeight(); + decoder.getPixel(pixelStorage, pixelWidth, pixelHeight); + data = pixelStorage.data; + final boolean hasAlpha = false; + + bytesPerPixel = 3; + glFormat = GL.GL_RGB; + reversedChannels = false; // RGB[A] + if(DEBUG) { + System.err.println("JPEGImage: alpha "+hasAlpha+", bytesPerPixel "+bytesPerPixel+ + ", pixels "+pixelWidth+"x"+pixelHeight+", glFormat 0x"+Integer.toHexString(glFormat)); + System.err.println("JPEGImage: "+decoder); + System.err.println("JPEGImage: "+pixelStorage); + } + decoder.clear(null); + } + private JPEGPixelStorage pixelStorage; + private final int pixelWidth, pixelHeight, glFormat, bytesPerPixel; + private boolean reversedChannels; + private final ByteBuffer data; + + /** Returns the color space of the pixel data */ + public ColorSpace getColorSpace() { return pixelStorage.storageCS; } + + /** Returns the number of components of the pixel data */ + public int getComponentCount() { return pixelStorage.storageComponents; } + + /** Returns the width of the image. */ + public int getWidth() { return pixelWidth; } + + /** Returns the height of the image. */ + public int getHeight() { return pixelHeight; } + + /** Returns true if data has the channels reversed to BGR or BGRA, otherwise RGB or RGBA is expected. */ + public boolean getHasReversedChannels() { return reversedChannels; } + + /** Returns the OpenGL format for this texture; e.g. GL.GL_LUMINANCE, GL.GL_RGB or GL.GL_RGBA. */ + public int getGLFormat() { return glFormat; } + + /** Returns the OpenGL data type: GL.GL_UNSIGNED_BYTE. */ + public int getGLType() { return GL.GL_UNSIGNED_BYTE; } + + /** Returns the bytes per pixel */ + public int getBytesPerPixel() { return bytesPerPixel; } + + /** Returns the raw data for this texture in the correct + (bottom-to-top) order for calls to glTexImage2D. */ + public ByteBuffer getData() { return data; } + + public String toString() { return "JPEGImage["+pixelWidth+"x"+pixelHeight+", bytesPerPixel "+bytesPerPixel+", reversedChannels "+reversedChannels+", "+pixelStorage+", "+data+"]"; } +} diff --git a/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java b/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java new file mode 100644 index 000000000..748e70d5b --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java @@ -0,0 +1,1505 @@ +/** + * Original JavaScript code from , + * ported to Java for JogAmp Community. + * + * Enhancements: + * * InputStream instead of memory buffer + * * User provided memory handler + * * Fixed JPEG Component ID/Index mapping + * * Color space conversion (YCCK, CMYK -> RGB) + * * More error tolerant + * + * ***************** + * + * Copyright 2011 notmasteryet + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ***************** + * + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl.util.jpeg; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; + +import jogamp.opengl.Debug; + +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.common.util.VersionNumber; +import com.jogamp.opengl.util.texture.TextureData.ColorSpace; + +/** + * + *
      + *
    • The JPEG specification can be found in the ITU CCITT Recommendation T.81 + * (www.w3.org/Graphics/JPEG/itu-t81.pdf)
    • + *
    • The JFIF specification can be found in the JPEG File Interchange Format + * (www.w3.org/Graphics/JPEG/jfif3.pdf)
    • + *
    • The Adobe Application-Specific JPEG markers in the Supporting the DCT Filters + * in PostScript Level 2, Technical Note #5116 + * (partners.adobe.com/public/developer/en/ps/sdk/5116.DCT_Filter.pdf)
    • + *
    • http://halicery.com/jpeg/huffman.html
    • + *
    • https://en.wikipedia.org/wiki/Jpg#Syntax_and_structure
    • + *
    • http://www.cs.sfu.ca/CourseCentral/365/mark/material/notes/Chap4/Chap4.2/Chap4.2.html
    • + *
    • https://github.com/notmasteryet/jpgjs/blob/master/jpg.js
    • + *
    + */ +public class JPEGDecoder { + private static final boolean DEBUG = Debug.debug("JPEGImage"); + private static final boolean DEBUG_IN = false; + + public static interface PixelStorage { + /** + * @param width + * @param height + * @param sourceCS the color-space of the decoded JPEG + * @param sourceComponents number of components used for the given source color-space + * @return Either {@link ColorSpace#RGB} or {@link ColorSpace#YCbCr}. {@link ColorSpace#YCCK} and {@link ColorSpace#CMYK} will throw an exception! + * @throws RuntimeException + */ + public ColorSpace allocate(int width, int height, ColorSpace sourceCS, int sourceComponents) throws RuntimeException; + public void store2(int x, int y, byte c1, byte c2); + public void storeRGB(int x, int y, byte r, byte g, byte b); + public void storeYCbCr(int x, int y, byte Y, byte Cb, byte Cr); + } + + public static class JFIF { + final VersionNumber version; + final int densityUnits; + final int xDensity; + final int yDensity; + final int thumbWidth; + final int thumbHeight; + final byte[] thumbData; + + private JFIF(final byte data[]) { + version = new VersionNumber(data[5], data[6], 0); + densityUnits = data[7]; + xDensity = (data[8] << 8) | data[9]; + yDensity = (data[10] << 8) | data[11]; + thumbWidth = data[12]; + thumbHeight = data[13]; + if( 0 < thumbWidth && 0 < thumbHeight ) { + final int len = 14 + 3 * thumbWidth * thumbHeight; + thumbData = new byte[len]; + System.arraycopy(data, 14, thumbData, 0, len); + } else { + thumbData = null; + } + } + + public static final JFIF get(final byte[] data) throws RuntimeException { + if ( data[0] == (byte)0x4A && data[1] == (byte)0x46 && data[2] == (byte)0x49 && + data[3] == (byte)0x46 && data[4] == (byte)0x0) { // 'JFIF\x00' + final JFIF r = new JFIF(data); + return r; + } else { + return null; + } + } + + public final String toString() { + return "JFIF[ver "+version+", density[units "+densityUnits+", "+xDensity+"x"+yDensity+"], thumb "+thumbWidth+"x"+thumbHeight+"]"; + } + } + + public static class Adobe { + final short version; + final short flags0; + final short flags1; + final short colorCode; + final ColorSpace colorSpace; + + private Adobe(final byte[] data) { + version = data[6]; + flags0 = (short) ( (data[7] << 8) | data[8] ) ; + flags1 = (short) ( (data[9] << 8) | data[10] ) ; + colorCode = data[11]; + switch( colorCode ) { + case 2: colorSpace = ColorSpace.YCCK; break; + case 1: colorSpace = ColorSpace.YCbCr; break; + default: colorSpace = ColorSpace.CMYK; break; + } + } + public static final Adobe get(final byte[] data) throws RuntimeException { + if (data[0] == (byte)0x41 && data[1] == (byte)0x64 && data[2] == (byte)0x6F && + data[3] == (byte)0x62 && data[4] == (byte)0x65 && data[5] == (byte)0) { // 'Adobe\x00' + final Adobe r = new Adobe(data); + return r; + } else { + return null; + } + } + public final String toString() { + return "Adobe[ver "+version+", flags["+toHexString(flags0)+", "+toHexString(flags1)+"], colorSpace/Code "+colorSpace+"/"+toHexString(colorCode)+"]"; + } + } + /** TODO */ + public static class EXIF { + private EXIF(final byte data[]) { + } + + public static final EXIF get(final byte[] data) throws RuntimeException { + if ( data[0] == (byte)0x45 && data[1] == (byte)0x78 && data[2] == (byte)0x69 && + data[3] == (byte)0x66 && data[4] == (byte)0x0) { // 'Exif\x00' + final EXIF r = new EXIF(data); + return r; + } else { + return null; + } + } + public final String toString() { + return "EXIF[]"; + } + } + + @SuppressWarnings("serial") + public static class CodecException extends RuntimeException { + CodecException(String message) { + super(message); + } + } + @SuppressWarnings("serial") + public static class MarkerException extends CodecException { + final int marker; + MarkerException(int marker, String message) { + super(message+" - Marker "+toHexString(marker)); + this.marker = marker; + } + public int getMarker() { return marker; } + } + + /** Start of Image */ + private static final int M_SOI = 0xFFD8; + /** End of Image */ + private static final int M_EOI = 0xFFD9; + /** Start of Frame - Baseline DCT */ + private static final int M_SOF0 = 0xFFC0; + /** Start of Frame - Extended sequential DCT */ + // private static final int M_SOF1 = 0xFFC1; + /** Start of Frame - Progressive DCT */ + private static final int M_SOF2 = 0xFFC2; + /** DHT (Define Huffman Tables) */ + private static final int M_DHT = 0xFFC4; + // private static final int M_DAC = 0xFFCC; + /** SOS (Start of Scan) */ + private static final int M_SOS = 0xFFDA; + /** DQT (Define Quantization Tables) */ + private static final int M_QTT = 0xFFDB; + /** DRI (Define Restart Interval) */ + private static final int M_DRI = 0xFFDD; + /** APP0 (Application Specific) - JFIF Header */ + private static final int M_APP00 = 0xFFE0; + /** APP1 (Application Specific) - Exif Header */ + private static final int M_APP01 = 0xFFE1; + /** APP2 (Application Specific) */ + private static final int M_APP02 = 0xFFE2; + /** APP3 (Application Specific) */ + private static final int M_APP03 = 0xFFE3; + /** APP4 (Application Specific) */ + private static final int M_APP04 = 0xFFE4; + /** APP5 (Application Specific) */ + private static final int M_APP05 = 0xFFE5; + /** APP6 (Application Specific) */ + private static final int M_APP06 = 0xFFE6; + /** APP7 (Application Specific) */ + private static final int M_APP07 = 0xFFE7; + /** APP8 (Application Specific) */ + private static final int M_APP08 = 0xFFE8; + /** APP9 (Application Specific) */ + private static final int M_APP09 = 0xFFE9; + /** APP10 (Application Specific) */ + private static final int M_APP10 = 0xFFEA; + /** APP11 (Application Specific) */ + private static final int M_APP11 = 0xFFEB; + /** APP12 (Application Specific) */ + private static final int M_APP12 = 0xFFEC; + /** APP13 (Application Specific) */ + private static final int M_APP13 = 0xFFED; + /** APP14 (Application Specific) - ADOBE Header */ + private static final int M_APP14 = 0xFFEE; + /** APP15 (Application Specific) */ + private static final int M_APP15 = 0xFFEF; + + /** Annotation / Comment */ + private static final int M_ANO = 0xFFFE; + + static final int[] dctZigZag = new int[] { + 0, + 1, 8, + 16, 9, 2, + 3, 10, 17, 24, + 32, 25, 18, 11, 4, + 5, 12, 19, 26, 33, 40, + 48, 41, 34, 27, 20, 13, 6, + 7, 14, 21, 28, 35, 42, 49, 56, + 57, 50, 43, 36, 29, 22, 15, + 23, 30, 37, 44, 51, 58, + 59, 52, 45, 38, 31, + 39, 46, 53, 60, + 61, 54, 47, + 55, 62, + 63 + }; + + static final int dctCos1 = 4017; // cos(pi/16) + static final int dctSin1 = 799; // sin(pi/16) + static final int dctCos3 = 3406; // cos(3*pi/16) + static final int dctSin3 = 2276; // sin(3*pi/16) + static final int dctCos6 = 1567; // cos(6*pi/16) + static final int dctSin6 = 3784; // sin(6*pi/16) + static final int dctSqrt2 = 5793; // sqrt(2) + static final int dctSqrt1d2 = 2896; // sqrt(2) / 2 + + static class Frame { + final boolean progressive; + final int precision; + final int scanLines; + final int samplesPerLine; + private final ArrayHashSet compIDs; + private final ComponentIn[] comps; + private final int compCount; + int maxCompID; + int maxH; + int maxV; + int mcusPerLine; + int mcusPerColumn; + + Frame(boolean progressive, int precision, int scanLines, int samplesPerLine, int componentsCount) { + this.progressive = progressive; + this.precision = precision; + this.scanLines = scanLines; + this.samplesPerLine = samplesPerLine; + compIDs = new ArrayHashSet(componentsCount); + comps = new ComponentIn[componentsCount]; + this.compCount = componentsCount; + } + + private final void checkBounds(int idx) { + if( 0 > idx || idx >= compCount ) { + throw new CodecException("Idx out of bounds "+idx+", "+this); + } + } + + public final int getCompCount() { return compCount; } + public final int getMaxCompID() { return maxCompID; } + + public final void putOrdered(int compID, ComponentIn component) { + if( maxCompID < compID ) { + maxCompID = compID; + } + final int idx = compIDs.size(); + checkBounds(idx); + compIDs.add(compID); + comps[idx] = component; + } + public final ComponentIn getCompByIndex(int i) { + checkBounds(i); + return comps[i]; + } + public final ComponentIn getCompByID(int componentID) { + return getCompByIndex( compIDs.indexOf(componentID) ); + } + public final int getCompID(int idx) { + return compIDs.get(idx); + } + public final boolean hasCompID(int componentID) { + return compIDs.contains(componentID); + } + public final String toString() { + return "Frame[progressive "+progressive+", precision "+precision+", scanLines "+scanLines+", samplesPerLine "+samplesPerLine+ + ", components[count "+compCount+", maxID "+maxCompID+", componentIDs "+compIDs+", comps "+Arrays.asList(comps)+"]]"; + } + } + + /** The JPEG encoded components */ + class ComponentIn { + final int h, v; + final int[] quantizationTable; + int blocksPerColumn; + int blocksPerColumnForMcu; + int blocksPerLine; + int blocksPerLineForMcu; + /** [blocksPerColumnForMcu][blocksPerLineForMcu][64]; */ + int[][][] blocks; + int pred; + BinObj huffmanTableAC; + BinObj huffmanTableDC; + + ComponentIn(int h, int v, int[] quantizationTable) { + this.h = h; + this.v = v; + this.quantizationTable = quantizationTable; + } + + public final void allocateBlocks(int blocksPerColumn, int blocksPerColumnForMcu, int blocksPerLine, int blocksPerLineForMcu) { + this.blocksPerColumn = blocksPerColumn; + this.blocksPerColumnForMcu = blocksPerColumnForMcu; + this.blocksPerLine = blocksPerLine; + this.blocksPerLineForMcu = blocksPerLineForMcu; + this.blocks = new int[blocksPerColumnForMcu][blocksPerLineForMcu][64]; + } + public final int[] getBlock(int row, int col) { + if( row >= blocksPerColumnForMcu || col >= blocksPerLineForMcu ) { + throw new CodecException("Out of bounds given ["+row+"]["+col+"] - "+this); + } + return blocks[row][col]; + } + + public final String toString() { + return "CompIn[h "+h+", v "+v+", blocks["+blocksPerColumn+", mcu "+blocksPerColumnForMcu+"]["+blocksPerLine+", mcu "+blocksPerLineForMcu+"][64]]"; + } + } + + /** The decoded components */ + class ComponentOut { + private final ArrayList lines; + final float scaleX; + final float scaleY; + + ComponentOut(ArrayList lines, float scaleX, float scaleY) { + this.lines = lines; + this.scaleX = scaleX; + this.scaleY = scaleY; + } + + /** Safely returning a line, if index exceeds number of lines, last line is returned. */ + public final byte[] getLine(int i) { + final int sz = lines.size(); + return lines.get( i < sz ? i : sz - 1); + } + + public final String toString() { + return "CompOut[lines "+lines.size()+", scale "+scaleX+"x"+scaleY+"]"; + } + } + + public String toString() { + final String jfifS = null != jfif ? jfif.toString() : "JFIF nil"; + final String exifS = null != exif ? exif.toString() : "Exif nil"; + final String adobeS = null != adobe ? adobe.toString() : "Adobe nil"; + final String compOuts = null != components ? Arrays.asList(components).toString() : "nil"; + return "JPEG[size "+width+"x"+height+", compOut "+compOuts+", "+jfifS+", "+exifS+", "+adobeS+"]"; + } + + private BufferedInputStream istream; + private int _ipos = 0; + private int _iposSave = 0; + + private int width = 0; + private int height = 0; + private JFIF jfif = null; + private EXIF exif = null; + private Adobe adobe = null; + private ComponentOut[] components = null; + + public final JFIF getJFIFHeader() { return jfif; } + public final EXIF getEXIFHeader() { return exif; } + public final Adobe getAdobeHeader() { return adobe; } + public final int getWidth() { return width; } + public final int getHeight() { return height; } + + private final void resetInput(InputStream is) { + if( is instanceof BufferedInputStream ) { + istream = (BufferedInputStream) is; + } else { + istream = new BufferedInputStream(is); + } + _ipos = 0; + } + + private final void markStream(int readLimit) { + istream.mark(readLimit); + _iposSave = _ipos; + } + private final void rewindStream() throws IOException { + if(DEBUG_IN) { System.err.println("JPG.rewindStream: "+_ipos+" -> "+_iposSave); } + istream.reset(); + _ipos = _iposSave; + _iposSave = 0; + } + private final int readUint8() throws IOException { + final int r = istream.read(); + if( -1 < r ) { + if(DEBUG_IN) { System.err.println("u8["+_ipos+"]: "+toHexString(r)); } + _ipos++; + } else if(DEBUG_IN) { + System.err.println("u8["+_ipos+"]: EOS"); + } + return r; + } + + private final int readUint16() throws IOException { + final int hi = istream.read(); + if( -1 < hi ) { + _ipos++; + final int lo = istream.read(); + if( -1 < lo ) { + _ipos++; + final int r = hi << 8 | lo ; + if(DEBUG_IN) { System.err.println("u16["+(_ipos-2)+"]: "+toHexString(r)); } + return r; + } + } + if(DEBUG_IN) { System.err.println("u16["+_ipos+"]: EOS"); } + return -1; + } + + private final int readNumber() throws IOException { + final int len=readUint16(); + if(len!=4){ + throw new CodecException("ERROR: Define number format error [Len!=4, but "+len+"]"); + } + return readUint16(); + } + + private final byte[] readDataBlock() throws IOException { + int count=0, i=0; + final int len=readUint16(); count+=2; + byte[] data = new byte[len-2]; + while(count frames = new ArrayList(); + final BinObj[] huffmanTablesAC = new BinObj[0x0F]; // Huffman table spec - 4 bits + final BinObj[] huffmanTablesDC = new BinObj[0x0F]; // Huffman table spec - 4 bits + int fileMarker = readUint16(); + if ( fileMarker != M_SOI ) { + throw new CodecException("SOI not found, but has marker "+toHexString(fileMarker)); + } + + fileMarker = readUint16(); + while (fileMarker != M_EOI) { + if(DEBUG) { System.err.println("JPG.parse got marker "+toHexString(fileMarker)); } + switch(fileMarker) { + case M_APP00: + case M_APP01: + case M_APP02: + case M_APP03: + case M_APP04: + case M_APP05: + case M_APP06: + case M_APP07: + case M_APP08: + case M_APP09: + case M_APP10: + case M_APP11: + case M_APP12: + case M_APP13: + case M_APP14: + case M_APP15: + case M_ANO: { + final byte[] appData = readDataBlock(); + + if ( fileMarker == M_APP00 ) { + jfif = JFIF.get( appData ); + } + if ( fileMarker == M_APP01 ) { + exif = EXIF.get(appData); + } + if (fileMarker == M_APP14) { + adobe = Adobe.get(appData); + } + fileMarker = 0; // consumed and get-next + } + break; + + case M_QTT: { + int count = 0; + final int quantizationTablesLength = readUint16(); count+=2; + while( count < quantizationTablesLength ) { + final int quantizationTableSpec = readUint8(); count++; + final int precisionID = quantizationTableSpec >> 4; + final int[] tableData = new int[64]; + if ( precisionID == 0 ) { // 8 bit values + for (int j = 0; j < 64; j++) { + final int z = dctZigZag[j]; + tableData[z] = readUint8(); count++; + } + } else if ( precisionID == 1) { //16 bit + for (int j = 0; j < 64; j++) { + final int z = dctZigZag[j]; + tableData[z] = readUint16(); count+=2; + } + } else { + throw new CodecException("DQT: invalid table precision "+precisionID+", quantizationTableSpec "+quantizationTableSpec); + } + quantizationTables[quantizationTableSpec & 0x0F] = tableData; + } + if(count!=quantizationTablesLength){ + throw new CodecException("ERROR: QTT format error [count!=Length]"); + } + fileMarker = 0; // consumed and get-next + } + break; + + case M_SOF0: + case M_SOF2: { + int count = 0; + final int sofLen = readUint16(); count+=2; // header length; + final int componentsCount; + { + final boolean progressive = (fileMarker == M_SOF2); + final int precision = readUint8(); count++; + final int scanLines = readUint16(); count+=2; + final int samplesPerLine = readUint16(); count+=2; + componentsCount = readUint8(); count++; + frame = new Frame(progressive, precision, scanLines, samplesPerLine, componentsCount); + width = frame.samplesPerLine; + height = frame.scanLines; + } + for (int i = 0; i < componentsCount; i++) { + final int componentId = readUint8(); count++; + final int temp = readUint8(); count++; + final int h = temp >> 4; + final int v = temp & 0x0F; + final int qId = readUint8(); count++; + frame.putOrdered(componentId, new ComponentIn(h, v, quantizationTables[qId])); + } + if(count!=sofLen){ + throw new CodecException("ERROR: SOF format error [count!=Length]"); + } + prepareComponents(frame); + frames.add(frame); + if(DEBUG) { System.err.println("JPG.parse.SOF[02]: Got frame "+frame); } + fileMarker = 0; // consumed and get-next + } + break; + + case M_DHT: { + int count = 0; + final int huffmanLength = readUint16(); count+=2; + int i=count, codeLengthTotal = 0; + while( i < huffmanLength ) { + final int huffmanTableSpec = readUint8(); count++; + final int[] codeLengths = new int[16]; + int codeLengthSum = 0; + for (int j = 0; j < 16; j++) { + codeLengthSum += (codeLengths[j] = readUint8()); count++; + } + final byte[] huffmanValues = new byte[codeLengthSum]; + for (int j = 0; j < codeLengthSum; j++) { + huffmanValues[j] = (byte)readUint8(); count++; + } + codeLengthTotal += codeLengthSum; + i += 17 + codeLengthSum; + final BinObj[] table = ( huffmanTableSpec >> 4 ) == 0 ? huffmanTablesDC : huffmanTablesAC; + table[huffmanTableSpec & 0x0F] = buildHuffmanTable(codeLengths, huffmanValues); + } + if(count!=huffmanLength || i!=count){ + throw new CodecException("ERROR: Huffman table format error [count!=Length]"); + } + if(DEBUG) { System.err.println("JPG.parse.DHT: Got Huffman CodeLengthTotal "+codeLengthTotal); } + fileMarker = 0; // consumed and get-next + } + break; + + case M_DRI: + resetInterval = readNumber(); + if(DEBUG) { System.err.println("JPG.parse.DRI: Got Reset Interval "+resetInterval); } + fileMarker = 0; // consumed and get-next + break; + + case M_SOS: { + int count = 0; + final int sosLen = readUint16(); count+=2; + final int selectorsCount = readUint8(); count++; + ArrayList components = new ArrayList(); + if(DEBUG) { System.err.println("JPG.parse.SOS: selectorCount [0.."+(selectorsCount-1)+"]: "+frame); } + for (int i = 0; i < selectorsCount; i++) { + final int compID = readUint8(); count++; + final ComponentIn component = frame.getCompByID(compID); + final int tableSpec = readUint8(); count++; + component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4]; + component.huffmanTableAC = huffmanTablesAC[tableSpec & 15]; + components.add(component); + } + final int spectralStart = readUint8(); count++; + final int spectralEnd = readUint8(); count++; + final int successiveApproximation = readUint8(); count++; + if(count!=sosLen){ + throw new CodecException("ERROR: scan header format error [count!=Length]"); + } + fileMarker = decoder.decodeScan(frame, components, resetInterval, + spectralStart, spectralEnd, + successiveApproximation >> 4, successiveApproximation & 15); + if(DEBUG) { System.err.println("JPG.parse.SOS.decode result "+toHexString(fileMarker)); } + } + break; + default: + /** + if (data[offset - 3] == 0xFF && + data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) { + // could be incorrect encoding -- last 0xFF byte of the previous + // block was eaten by the encoder + offset -= 3; + break; + } */ + throw new CodecException("unknown JPEG marker " + toHexString(fileMarker)); + } + if( 0 == fileMarker ) { + fileMarker = readUint16(); + } + } + if(DEBUG) { System.err.println("JPG.parse.2: End of parsing input "+this); } + if ( frames.size() != 1 ) { + throw new CodecException("only single frame JPEGs supported"); + } + + final int compCount = frame.getCompCount(); + this.components = new ComponentOut[compCount]; + for (int i = 0; i < compCount; i++) { + final ComponentIn component = frame.getCompByIndex(i); + this.components[i] = new ComponentOut( output.buildComponentData(frame, component), + (float)component.h / (float)frame.maxH, + (float)component.v / (float)frame.maxV ); + } + if(DEBUG) { System.err.println("JPG.parse.X: End of processing input "+this); } + return this; + } + + private void prepareComponents(Frame frame) { + int maxH = 0, maxV = 0; + // for (componentId in frame.components) { + final int compCount = frame.getCompCount(); + for (int i=0; i code = new ArrayList(); + while (length > 0 && 0==codeLengths[length - 1]) { + length--; + } + code.add(new BinObjIdxed()); + BinObjIdxed p = code.get(0), q; + for (int i = 0; i < length; i++) { + for (int j = 0; j < codeLengths[i]; j++) { + p = code.remove(code.size()-1); + p.children.set(p.index, values[k]); + while (p.index > 0) { + p = code.remove(code.size()-1); + } + p.index++; + code.add(p); + while (code.size() <= i) { + q = new BinObjIdxed(); + code.add(q); + p.children.set(p.index, q.children); + p = q; + } + k++; + } + if (i + 1 < length) { + // p here points to last code + q = new BinObjIdxed(); + code.add(q); + p.children.set(p.index, q.children); + p = q; + } + } + return code.get(0).children; + } + + private final Output output = new Output(); + private static class Output { + private int blocksPerLine; + private int blocksPerColumn; + private int samplesPerLine; + + private ArrayList buildComponentData(Frame frame, ComponentIn component) { + ArrayList lines = new ArrayList(); + blocksPerLine = component.blocksPerLine; + blocksPerColumn = component.blocksPerColumn; + samplesPerLine = blocksPerLine << 3; + final int[] R = new int[64]; + final byte[] r = new byte[64]; + + for (int blockRow = 0; blockRow < blocksPerColumn; blockRow++) { + int scanLine = blockRow << 3; + for (int i = 0; i < 8; i++) { + lines.add(new byte[samplesPerLine]); + } + for (int blockCol = 0; blockCol < blocksPerLine; blockCol++) { + quantizeAndInverse(component.getBlock(blockRow, blockCol), r, R, component.quantizationTable); + + final int sample = blockCol << 3; + int offset = 0; + for (int j = 0; j < 8; j++) { + final byte[] line = lines.get(scanLine + j); + for (int i = 0; i < 8; i++) + line[sample + i] = r[offset++]; + } + } + } + return lines; + } + + // A port of poppler's IDCT method which in turn is taken from: + // Christoph Loeffler, Adriaan Ligtenberg, George S. Moschytz, + // "Practical Fast 1-D DCT Algorithms with 11 Multiplications", + // IEEE Intl. Conf. on Acoustics, Speech & Signal Processing, 1989, + // 988-991. + private void quantizeAndInverse(int[] zz, byte[] dataOut, int[] dataIn, int[] qt) { + int v0, v1, v2, v3, v4, v5, v6, v7, t; + int[] p = dataIn; + int i; + + // dequant + for (i = 0; i < 64; i++) { + p[i] = zz[i] * qt[i]; + } + + // inverse DCT on rows + for (i = 0; i < 8; ++i) { + int row = 8 * i; + + // check for all-zero AC coefficients + if (p[1 + row] == 0 && p[2 + row] == 0 && p[3 + row] == 0 && + p[4 + row] == 0 && p[5 + row] == 0 && p[6 + row] == 0 && + p[7 + row] == 0) { + t = (dctSqrt2 * p[0 + row] + 512) >> 10; + p[0 + row] = t; + p[1 + row] = t; + p[2 + row] = t; + p[3 + row] = t; + p[4 + row] = t; + p[5 + row] = t; + p[6 + row] = t; + p[7 + row] = t; + continue; + } + + // stage 4 + v0 = (dctSqrt2 * p[0 + row] + 128) >> 8; + v1 = (dctSqrt2 * p[4 + row] + 128) >> 8; + v2 = p[2 + row]; + v3 = p[6 + row]; + v4 = (dctSqrt1d2 * (p[1 + row] - p[7 + row]) + 128) >> 8; + v7 = (dctSqrt1d2 * (p[1 + row] + p[7 + row]) + 128) >> 8; + v5 = p[3 + row] << 4; + v6 = p[5 + row] << 4; + + // stage 3 + t = (v0 - v1+ 1) >> 1; + v0 = (v0 + v1 + 1) >> 1; + v1 = t; + t = (v2 * dctSin6 + v3 * dctCos6 + 128) >> 8; + v2 = (v2 * dctCos6 - v3 * dctSin6 + 128) >> 8; + v3 = t; + t = (v4 - v6 + 1) >> 1; + v4 = (v4 + v6 + 1) >> 1; + v6 = t; + t = (v7 + v5 + 1) >> 1; + v5 = (v7 - v5 + 1) >> 1; + v7 = t; + + // stage 2 + t = (v0 - v3 + 1) >> 1; + v0 = (v0 + v3 + 1) >> 1; + v3 = t; + t = (v1 - v2 + 1) >> 1; + v1 = (v1 + v2 + 1) >> 1; + v2 = t; + t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12; + v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12; + v7 = t; + t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12; + v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12; + v6 = t; + + // stage 1 + p[0 + row] = v0 + v7; + p[7 + row] = v0 - v7; + p[1 + row] = v1 + v6; + p[6 + row] = v1 - v6; + p[2 + row] = v2 + v5; + p[5 + row] = v2 - v5; + p[3 + row] = v3 + v4; + p[4 + row] = v3 - v4; + } + + // inverse DCT on columns + for (i = 0; i < 8; ++i) { + int col = i; + + // check for all-zero AC coefficients + if (p[1*8 + col] == 0 && p[2*8 + col] == 0 && p[3*8 + col] == 0 && + p[4*8 + col] == 0 && p[5*8 + col] == 0 && p[6*8 + col] == 0 && + p[7*8 + col] == 0) { + t = (dctSqrt2 * dataIn[i+0] + 8192) >> 14; + p[0*8 + col] = t; + p[1*8 + col] = t; + p[2*8 + col] = t; + p[3*8 + col] = t; + p[4*8 + col] = t; + p[5*8 + col] = t; + p[6*8 + col] = t; + p[7*8 + col] = t; + continue; + } + + // stage 4 + v0 = (dctSqrt2 * p[0*8 + col] + 2048) >> 12; + v1 = (dctSqrt2 * p[4*8 + col] + 2048) >> 12; + v2 = p[2*8 + col]; + v3 = p[6*8 + col]; + v4 = (dctSqrt1d2 * (p[1*8 + col] - p[7*8 + col]) + 2048) >> 12; + v7 = (dctSqrt1d2 * (p[1*8 + col] + p[7*8 + col]) + 2048) >> 12; + v5 = p[3*8 + col]; + v6 = p[5*8 + col]; + + // stage 3 + t = (v0 - v1 + 1) >> 1; + v0 = (v0 + v1 + 1) >> 1; + v1 = t; + t = (v2 * dctSin6 + v3 * dctCos6 + 2048) >> 12; + v2 = (v2 * dctCos6 - v3 * dctSin6 + 2048) >> 12; + v3 = t; + t = (v4 - v6 + 1) >> 1; + v4 = (v4 + v6 + 1) >> 1; + v6 = t; + t = (v7 + v5 + 1) >> 1; + v5 = (v7 - v5 + 1) >> 1; + v7 = t; + + // stage 2 + t = (v0 - v3 + 1) >> 1; + v0 = (v0 + v3 + 1) >> 1; + v3 = t; + t = (v1 - v2 + 1) >> 1; + v1 = (v1 + v2 + 1) >> 1; + v2 = t; + t = (v4 * dctSin3 + v7 * dctCos3 + 2048) >> 12; + v4 = (v4 * dctCos3 - v7 * dctSin3 + 2048) >> 12; + v7 = t; + t = (v5 * dctSin1 + v6 * dctCos1 + 2048) >> 12; + v5 = (v5 * dctCos1 - v6 * dctSin1 + 2048) >> 12; + v6 = t; + + // stage 1 + p[0*8 + col] = v0 + v7; + p[7*8 + col] = v0 - v7; + p[1*8 + col] = v1 + v6; + p[6*8 + col] = v1 - v6; + p[2*8 + col] = v2 + v5; + p[5*8 + col] = v2 - v5; + p[3*8 + col] = v3 + v4; + p[4*8 + col] = v3 - v4; + } + + // convert to 8-bit integers + for (i = 0; i < 64; ++i) { + int sample = 128 + ((p[i] + 8) >> 4); + dataOut[i] = (byte) ( sample < 0 ? 0 : sample > 0xFF ? 0xFF : sample ); + } + } + } + + private static interface DecoderFunction { + void decode(ComponentIn component, int[] zz) throws IOException; + } + + private class Decoder { + // private int precision; + // private int samplesPerLine; + // private int scanLines; + private int mcusPerLine; + private boolean progressive; + // private int maxH, maxV; + private int bitsData, bitsCount; + private int spectralStart, spectralEnd; + private int successive; + private int eobrun; + private int successiveACState, successiveACNextValue; + + private int decodeScan(Frame frame, ArrayList components, int resetInterval, + int spectralStart, int spectralEnd, int successivePrev, int successive) throws IOException { + // this.precision = frame.precision; + // this.samplesPerLine = frame.samplesPerLine; + // this.scanLines = frame.scanLines; + this.mcusPerLine = frame.mcusPerLine; + this.progressive = frame.progressive; + // this.maxH = frame.maxH; + // this.maxV = frame.maxV; + this.bitsData = 0; + this.bitsCount = 0; + this.spectralStart = spectralStart; + this.spectralEnd = spectralEnd; + this.successive = successive; + + final int componentsLength = components.size(); + + final DecoderFunction decodeFn; + if (progressive) { + if (spectralStart == 0) { + decodeFn = successivePrev == 0 ? decodeDCFirst : decodeDCSuccessive; + } else { + decodeFn = successivePrev == 0 ? decodeACFirst : decodeACSuccessive; + } + } else { + decodeFn = decodeBaseline; + } + + int mcu = 0; + int mcuExpected; + if (componentsLength == 1) { + final ComponentIn c = components.get(0); + mcuExpected = c.blocksPerLine * c.blocksPerColumn; + } else { + mcuExpected = mcusPerLine * frame.mcusPerColumn; + } + if (0 == resetInterval) { + resetInterval = mcuExpected; + } + if(DEBUG) { + System.err.println("JPEG.decodeScan.1 resetInterval "+resetInterval+", mcuExpected "+mcuExpected+", sA "+spectralStart+", sP "+successivePrev+", sE "+spectralEnd+", suc "+successive+", decodeFn "+decodeFn.getClass().getSimpleName()); + } + int marker = 0; + while ( /* untilMarker || */ mcu < mcuExpected) { + // reset interval stuff + for (int i = 0; i < componentsLength; i++) { + components.get(i).pred = 0; + } + eobrun = 0; + + try { + if (componentsLength == 1) { + final ComponentIn component = components.get(0); + for (int n = 0; n < resetInterval; n++) { + decodeBlock(component, decodeFn, mcu); + mcu++; + } + } else { + for (int n = 0; n < resetInterval; n++) { + for (int i = 0; i < componentsLength; i++) { + final ComponentIn component = components.get(i); + final int h = component.h; + final int v = component.v; + for (int j = 0; j < v; j++) { + for (int k = 0; k < h; k++) { + decodeMcu(component, decodeFn, mcu, j, k); + } + } + } + mcu++; + } + } + } catch (MarkerException markerException) { + if(DEBUG) { System.err.println("JPEG.decodeScan: Marker exception: "+markerException.getMessage()); markerException.printStackTrace(); } + return markerException.getMarker(); + } catch (CodecException codecException) { + if(DEBUG) { System.err.println("JPEG.decodeScan: Codec exception: "+codecException.getMessage()); codecException.printStackTrace(); } + bitsCount = 0; + return M_EOI; // force end ! + } + + // find marker + bitsCount = 0; + markStream(2); + marker = readUint16(); + if( marker < 0xFF00 ) { + rewindStream(); + throw new CodecException("marker not found @ mcu "+mcu+"/"+mcuExpected+", u16: "+toHexString(marker)); + } + final boolean isRSTx = 0xFFD0 <= marker && marker <= 0xFFD7; // !RSTx + if(DEBUG) { + System.err.println("JPEG.decodeScan: MCUs "+mcu+"/"+mcuExpected+", u16 "+toHexString(marker)+", RSTx "+isRSTx+", "+frame); + } + if ( !isRSTx ) { + break; // handle !RSTx marker in caller + } + } + return marker; + } + + private int readBit() throws MarkerException, IOException { + if (bitsCount > 0) { + bitsCount--; + return (bitsData >> bitsCount) & 1; + } + bitsData = readUint8(); + if( -1 == bitsData ) { + return -1; + } + if (bitsData == 0xFF) { // marker prefix + final int nextByte = readUint8(); // marker signature + if( -1 == nextByte ) { + throw new CodecException("marked prefix 0xFF, then EOF"); + } + if (0 != nextByte) { + final int marker = (bitsData << 8) | nextByte; + throw new MarkerException(marker, "Marker at readBit file pos " + _ipos); + } + // unstuff 0 + } + bitsCount = 7; + return bitsData >>> 7; + } + + private int decodeHuffman(BinObj tree) throws IOException { + BinObj node = tree; + int bit; + while ( ( bit = readBit() ) != -1 ) { + node = node.get(bit); + if ( node.isValue ) { + return 0x000000FF & node.getValue(); + } + } + throw new CodecException("EOF reached at "+_ipos); + } + private int receive(int length) throws IOException { + int n = 0; + while (length > 0) { + final int bit = readBit(); + if (bit == -1) { + return -1; + } + n = (n << 1) | bit; + length--; + } + return n; + } + private int receiveAndExtend(int length) throws IOException { + final int n = receive(length); + if (n >= 1 << (length - 1)) { + return n; + } + return n + (-1 << length) + 1; + } + + final DecoderFunction decodeBaseline = new BaselineDecoder(); + final DecoderFunction decodeDCFirst = new DCFirstDecoder(); + final DecoderFunction decodeDCSuccessive = new DCSuccessiveDecoder(); + final DecoderFunction decodeACFirst = new ACFirstDecoder(); + final DecoderFunction decodeACSuccessive = new ACSuccessiveDecoder(); + + class BaselineDecoder implements DecoderFunction { + public void decode(ComponentIn component, int[] zz) throws IOException { + final int t = decodeHuffman(component.huffmanTableDC); + final int diff = ( t == 0 ) ? 0 : receiveAndExtend(t); + zz[0] = ( component.pred += diff ); + int k = 1; + while (k < 64) { + final int rs = decodeHuffman(component.huffmanTableAC); + final int s = rs & 15, r = rs >> 4; + if (s == 0) { + if (r < 15) { + break; + } + k += 16; + continue; + } + k += r; + final int z = dctZigZag[k]; + zz[z] = receiveAndExtend(s); + k++; + } + } + } + class DCFirstDecoder implements DecoderFunction { + public void decode(ComponentIn component, int[] zz) throws IOException { + final int t = decodeHuffman(component.huffmanTableDC); + final int diff = ( t == 0 ) ? 0 : (receiveAndExtend(t) << successive); + zz[0] = ( component.pred += diff ); + } + } + class DCSuccessiveDecoder implements DecoderFunction { + public void decode(ComponentIn component, int[] zz) throws IOException { + zz[0] |= readBit() << successive; + } + } + + class ACFirstDecoder implements DecoderFunction { + public void decode(ComponentIn component, int[] zz) throws IOException { + if (eobrun > 0) { + eobrun--; + return; + } + int k = spectralStart, e = spectralEnd; + while (k <= e) { + final int rs = decodeHuffman(component.huffmanTableAC); + final int s = rs & 15, r = rs >> 4; + if (s == 0) { + if (r < 15) { + eobrun = receive(r) + (1 << r) - 1; + break; + } + k += 16; + continue; + } + k += r; + final int z = dctZigZag[k]; + zz[z] = receiveAndExtend(s) * (1 << successive); + k++; + } + } + } + class ACSuccessiveDecoder implements DecoderFunction { + public void decode(ComponentIn component, int[] zz) throws IOException { + int k = spectralStart, e = spectralEnd, r = 0; + while (k <= e) { + final int z = dctZigZag[k]; + switch (successiveACState) { + case 0: // initial state + final int rs = decodeHuffman(component.huffmanTableAC); + final int s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + eobrun = receive(r) + (1 << r); + successiveACState = 4; + } else { + r = 16; + successiveACState = 1; + } + } else { + // if (s !== 1) { + if (s != 1) { + throw new CodecException("invalid ACn encoding"); + } + successiveACNextValue = receiveAndExtend(s); + successiveACState = r != 0 ? 2 : 3; + } + continue; + case 1: // skipping r zero items + case 2: + if ( zz[z] != 0 ) { + zz[z] += (readBit() << successive); + } else { + r--; + if (r == 0) { + successiveACState = successiveACState == 2 ? 3 : 0; + } + } + break; + case 3: // set value for a zero item + if ( zz[z] != 0 ) { + zz[z] += (readBit() << successive); + } else { + zz[z] = successiveACNextValue << successive; + successiveACState = 0; + } + break; + case 4: // eob + if ( zz[z] != 0 ) { + zz[z] += (readBit() << successive); + } + break; + } + k++; + } + if (successiveACState == 4) { + eobrun--; + if (eobrun == 0) { + successiveACState = 0; + } + } + } + } + void decodeMcu(ComponentIn component, DecoderFunction decoder, int mcu, int row, int col) throws IOException { + final int mcuRow = (mcu / mcusPerLine) | 0; + final int mcuCol = mcu % mcusPerLine; + final int blockRow = mcuRow * component.v + row; + final int blockCol = mcuCol * component.h + col; + decoder.decode(component, component.getBlock(blockRow, blockCol)); + } + void decodeBlock(ComponentIn component, DecoderFunction decoder, int mcu) throws IOException { + final int blockRow = (mcu / component.blocksPerLine) | 0; + final int blockCol = mcu % component.blocksPerLine; + decoder.decode(component, component.getBlock(blockRow, blockCol)); + } + } + private final Decoder decoder = new Decoder(); + + /** wrong color space .. + private final void storeYCbCr2BGR(final PixelStorage pixelStorage, int x, int y, int Y, final int Cb, final int Cr) + { + if(Y<0) Y=0; + int B = Y + ( ( 116130 * Cb ) >> 16 ) ; + if(B<0) B=0; + else if(B>255) B=255; + + int G = Y - ( ( 22554 * Cb + 46802 * Cr ) >> 16 ) ; + if(G<0) G=0; + else if(G>255) G=255; + + int R = Y + ( ( 91881 * Cr ) >> 16 ); + if(R<0) R=0; + else if(R>255) R=255; + + pixelStorage.storeRGB(x, y, (byte)R, (byte)G, (byte)B); + } */ + + public synchronized void getPixel(PixelStorage pixelStorage, int width, int height) { + final int scaleX = this.width / width, scaleY = this.height / height; + + final int componentCount = this.components.length; + final ColorSpace sourceCS = ( null != adobe ) ? adobe.colorSpace : ColorSpace.YCbCr; + final ColorSpace storageCS = pixelStorage.allocate(width, height, sourceCS, componentCount); + if( ColorSpace.RGB != storageCS && ColorSpace.YCbCr != storageCS ) { + throw new IllegalArgumentException("Unsupported storage color space: "+storageCS); + } + + switch (componentCount) { + case 1: { + // Grayscale + final ComponentOut component1 = this.components[0]; + for (int y = 0; y < height; y++) { + final byte[] component1Line = component1.getLine((int)(y * component1.scaleY * scaleY)); + for (int x = 0; x < width; x++) { + final byte Y = component1Line[(int)(x * component1.scaleX * scaleX)]; + if( ColorSpace.YCbCr == storageCS ) { + pixelStorage.storeYCbCr(x, y, Y, (byte)0, (byte)0); + } else { + pixelStorage.storeRGB(x, y, Y, Y, Y); + } + } + } + } + break; + case 2: { + // PDF might compress two component data in custom colorspace + final ComponentOut component1 = this.components[0]; + final ComponentOut component2 = this.components[1]; + for (int y = 0; y < height; y++) { + final int ys = y * scaleY; + final byte[] component1Line = component1.getLine((int)(ys * component1.scaleY)); + final byte[] component2Line = component1.getLine((int)(ys * component2.scaleY)); + for (int x = 0; x < width; x++) { + final int xs = x * scaleX; + final byte Y1 = component1Line[(int)(xs * component1.scaleX)]; + final byte Y2 = component2Line[(int)(xs * component2.scaleX)]; + pixelStorage.store2(x, y, Y1, Y2); + } + } + } + break; + case 3: { + if (ColorSpace.YCbCr != sourceCS) { + throw new CodecException("Unsupported source color space w 3 components: "+sourceCS); + } + final ComponentOut component1 = this.components[0]; + final ComponentOut component2 = this.components[1]; + final ComponentOut component3 = this.components[2]; + for (int y = 0; y < height; y++) { + final int ys = y * scaleY; + final byte[] component1Line = component1.getLine((int)(ys * component1.scaleY)); + final byte[] component2Line = component2.getLine((int)(ys * component2.scaleY)); + final byte[] component3Line = component3.getLine((int)(ys * component3.scaleY)); + if( ColorSpace.YCbCr == storageCS ) { + for (int x = 0; x < width; x++) { + final int xs = x * scaleX; + final byte Y = component1Line[(int)(xs * component1.scaleX)]; + final byte Cb = component2Line[(int)(xs * component2.scaleX)]; + final byte Cr = component3Line[(int)(xs * component3.scaleX)]; + pixelStorage.storeYCbCr(x, y, Y, Cb, Cr); + } + } else { + for (int x = 0; x < width; x++) { + final int xs = x * scaleX; + final int Y = 0x000000FF & component1Line[(int)(xs * component1.scaleX)]; + final int Cb = 0x000000FF & component2Line[(int)(xs * component2.scaleX)]; + final int Cr = 0x000000FF & component3Line[(int)(xs * component3.scaleX)]; + // storeYCbCr2BGR(pixelStorage, x, y, Y, Cb, Cr); + final byte R = clampTo8bit(Y + 1.402f * (Cr - 128f)); + final byte G = clampTo8bit(Y - 0.3441363f * (Cb - 128f) - 0.71413636f * (Cr - 128f)); + final byte B = clampTo8bit(Y + 1.772f * (Cb - 128f)); + pixelStorage.storeRGB(x, y, R, G, B); + } + } + } + } + break; + case 4: { + if (ColorSpace.YCCK != sourceCS && ColorSpace.CMYK != sourceCS) { + throw new CodecException("Unsupported source color space w 4 components: "+sourceCS); + } + final ComponentOut component1 = this.components[0]; + final ComponentOut component2 = this.components[1]; + final ComponentOut component3 = this.components[2]; + final ComponentOut component4 = this.components[3]; + for (int y = 0; y < height; y++) { + final int ys = y * scaleY; + final byte[] component1Line = component1.getLine((int)(ys * component1.scaleY)); + final byte[] component2Line = component2.getLine((int)(ys * component2.scaleY)); + final byte[] component3Line = component3.getLine((int)(ys * component3.scaleY)); + final byte[] component4Line = component4.getLine((int)(ys * component4.scaleY)); + if( ColorSpace.YCbCr == storageCS ) { + if (ColorSpace.YCCK != sourceCS) { + throw new CodecException("Unsupported storage color space "+storageCS+" with source color space "+sourceCS); + } + for (int x = 0; x < width; x++) { + final int xs = x * scaleX; + final byte Y1 = component1Line[(int)(xs * component1.scaleX)]; + final byte C1 = component2Line[(int)(xs * component2.scaleX)]; + final byte C2 = component3Line[(int)(xs * component3.scaleX)]; + // final byte K = component4Line[(int)(xs * component4.scaleX)]; + // FIXME: YCCK is not really YCbCr, since K (black) is missing! + pixelStorage.storeYCbCr(x, y, Y1, C1, C2); + } + } else { + if (ColorSpace.CMYK == sourceCS) { + for (int x = 0; x < width; x++) { + final int xs = x * scaleX; + final int cC = 0x000000FF & component1Line[(int)(xs * component1.scaleX)]; + final int cM = 0x000000FF & component2Line[(int)(xs * component2.scaleX)]; + final int cY = 0x000000FF & component3Line[(int)(xs * component3.scaleX)]; + final int cK = 0x000000FF & component4Line[(int)(xs * component4.scaleX)]; + // CMYK -> RGB + final byte R = clampTo8bit( ( cC * cK ) / 255f ); + final byte G = clampTo8bit( ( cM * cK ) / 255f ); + final byte B = clampTo8bit( ( cY * cK ) / 255f ); + pixelStorage.storeRGB(x, y, R, G, B); + } + } else { // ColorModel.YCCK == sourceCM + for (int x = 0; x < width; x++) { + final int xs = x * scaleX; + final int Y = 0x000000FF & component1Line[(int)(xs * component1.scaleX)]; + final int Cb = 0x000000FF & component2Line[(int)(xs * component2.scaleX)]; + final int Cr = 0x000000FF & component3Line[(int)(xs * component3.scaleX)]; + final int cK = 0x000000FF & component4Line[(int)(xs * component4.scaleX)]; + // YCCK -> 255f - [ R'G'B' ] -> CMYK + final float cC = 255f - ( Y + 1.402f * (Cr - 128f) ); + final float cM = 255f - ( Y - 0.3441363f * (Cb - 128f) - 0.71413636f * (Cr - 128f) ); + final float cY = 255f - ( Y + 1.772f * (Cb - 128f) ); + // CMYK -> RGB + final byte R = clampTo8bit( ( cC * cK ) / 255f ); + final byte G = clampTo8bit( ( cM * cK ) / 255f ); + final byte B = clampTo8bit( ( cY * cK ) / 255f ); + pixelStorage.storeRGB(x, y, R, G, B); + } + } + } + } + } + break; + default: + throw new CodecException("Unsupported color model: Space "+sourceCS+", components "+componentCount); + } + } + + private static byte clampTo8bit(float a) { + return (byte) ( a < 0f ? 0 : a > 255f ? 255 : a ); + } + + private static String toHexString(int v) { + return "0x"+Integer.toHexString(v); + } +} \ No newline at end of file diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java new file mode 100644 index 000000000..37054afe6 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java @@ -0,0 +1,124 @@ +package com.jogamp.opengl.test.junit.jogl.util.texture; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URLConnection; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor; +import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.util.texture.spi.JPEGImage; +import javax.media.opengl.GL; + +public class TestJPEGImage01NEWT extends UITestCase { + + static boolean showFPS = false; + static long duration = 100; // ms + + public void testImpl(final boolean withAlpha, final InputStream istream) throws InterruptedException, IOException { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + final GLProfile glp = GLProfile.getGL2ES2(); + final GLCapabilities caps = new GLCapabilities(glp); + if( withAlpha ) { + caps.setAlphaBits(1); + } + + final JPEGImage image = JPEGImage.read(istream); + Assert.assertNotNull(image); + System.err.println("JPEGImage: "+image); + + final int internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB; + final TextureData texData = new TextureData(glp, internalFormat, + image.getWidth(), + image.getHeight(), + 0, + image.getGLFormat(), + image.getGLType(), + false /* mipmap */, + false /* compressed */, + false /* must flip-vert */, + image.getData(), + null); + // final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.JPG); + System.err.println("TextureData: "+texData); + + final GLWindow glad = GLWindow.create(caps); + glad.setTitle("TestJPEGImage01NEWT"); + // Size OpenGL to Video Surface + glad.setSize(texData.getWidth(), texData.getHeight()); + + // load texture from file inside current GL context to match the way + // the bug submitter was doing it + final GLEventListener gle = new TextureDraw01ES2Listener( texData ) ; + glad.addGLEventListener(gle); + glad.addGLEventListener(new GLEventListener() { + boolean shot = false; + + @Override public void init(GLAutoDrawable drawable) {} + + public void display(GLAutoDrawable drawable) { + // 1 snapshot + if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { + shot = true; + snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); + } + } + + @Override public void dispose(GLAutoDrawable drawable) { } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + Animator animator = new Animator(glad); + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + QuitAdapter quitAdapter = new QuitAdapter(); + glad.addKeyListener(quitAdapter); + glad.addWindowListener(quitAdapter); + glad.setVisible(true); + animator.start(); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(Unknown Source) + } + + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + final GLCapabilities caps = new GLCapabilities(glp); + caps.setAlphaBits(1); + + final GLWindow glad1 = GLWindow.create(caps); + glad1.setTitle("JPEG AWT"); + // Size OpenGL to Video Surface + glad1.setSize(w, h); + glad1.setPosition(xpos, 0); + + // load texture from file inside current GL context to match the way + // the bug submitter was doing it + final GLEventListener gle; + if( texData != null ) { + gle = new TextureDraw01ES2Listener( texData ) ; + glad1.addGLEventListener(gle); + } else { + gle = null; + } + glad1.addGLEventListener(new GLEventListener() { + boolean shot = false; + + @Override public void init(GLAutoDrawable drawable) {} + + public void display(GLAutoDrawable drawable) { + // 1 snapshot + if( null!=gle && null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { + shot = true; + snapshot(0, "AWTJPEG", drawable.getGL(), screenshot, TextureIO.PNG, null); + } + } + + @Override public void dispose(GLAutoDrawable drawable) { } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + return glad1; + } + + @Test + public void test01YUV444Base__ES2() throws InterruptedException, IOException { + testImpl(files[0]); + } + @Test + public void test01YUV444Prog__ES2() throws InterruptedException, IOException { + testImpl(files[1]); + } + + @Test + public void test01YUV422hBase__ES2() throws InterruptedException, IOException { + testImpl(files[2]); + } + @Test + public void test01YUV422hProg_ES2() throws InterruptedException, IOException { + testImpl(files[3]); + } + + @Test + public void test02YUV420Base__ES2() throws InterruptedException, IOException { + testImpl(files[4]); + } + @Test + public void test02YUV420Prog_ES2() throws InterruptedException, IOException { + testImpl(files[5]); + } + @Test + public void test02YUV420BaseGray_ES2() throws InterruptedException, IOException { + testImpl(files[6]); + } + + @Test + public void test03CMYK_01_ES2() throws InterruptedException, IOException { + testImpl(files[7]); + } + @Test + public void test03YCCK_01_ES2() throws InterruptedException, IOException { + testImpl(files[8]); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Thu, 4 Apr 2013 06:06:50 +0200 Subject: OSX CALayer/NewtCanvasAWT: Force relayout of component (size +1, size -1) when attaching NEWT Child to avoid false CALayer position. --- make/scripts/tests.sh | 30 ++-------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 23 +++++++- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 5 ++ .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 65 +++++++++++++++++----- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 7 +-- 5 files changed, 87 insertions(+), 43 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 48fa02a6c..0bd814322 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -272,7 +272,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* @@ -498,7 +498,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* @@ -543,36 +543,18 @@ testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareN #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* # -# osx bugs +# OSX bugs # #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* -# -# regressions -# - -# osx: -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDrawable02NEWT $* +# test rotation change #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* # -# OSX Java6 NEWT +# regressions # -# Freeze - -# Cut-off top -#testnoawt com.jogamp.opengl.test.junit.jogl.util.TestPNGImage01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* - -# Child too low -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* - -# test rotation change -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT - #linux: # ATI/Linux: XCB Unknown request in queue while dequeuing diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 3d907a86f..d0a4b7e98 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -54,6 +54,8 @@ import jogamp.newt.awt.NewtFactoryAWT; import jogamp.newt.awt.event.AWTParentWindowAdapter; import jogamp.newt.driver.DriverClearFocus; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.newt.Display; @@ -561,7 +563,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { // if ( isShowing() == false ) -> Container was not visible yet. // if ( isShowing() == true ) -> Container is already visible. - System.err.println("NewtCanvasAWT.attachNewtChild.0: win "+newtWinHandleToHexString(newtChild)+ + System.err.println("NewtCanvasAWT.attachNewtChild.0 @ "+Thread.currentThread().getName()+": win "+newtWinHandleToHexString(newtChild)+ ", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+ ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+", displayable "+isDisplayable()+ ", cont "+AWTMisc.getContainer(this)); @@ -575,9 +577,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final int w = getWidth(); final int h = getHeight(); System.err.println("NewtCanvasAWT.attachNewtChild.2: size "+w+"x"+h); + newtChild.setVisible(false); newtChild.setSize(w, h); newtChild.reparentWindow(jawtWindow); newtChild.addSurfaceUpdatedListener(jawtWindow); + if( Platform.OSType.MACOS == Platform.getOSType() && jawtWindow.isOffscreenLayerSurfaceEnabled() ) { + AWTEDTExecutor.singleton.invoke(false, forceRelayout); + } newtChild.setVisible(true); configureNewtChild(true); newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener @@ -589,6 +595,21 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto System.err.println("NewtCanvasAWT.attachNewtChild.X: win "+newtWinHandleToHexString(newtChild)+", EDTUtil: cur "+newtChild.getScreen().getDisplay().getEDTUtil()+", comp "+this); } } + private final Runnable forceRelayout = new Runnable() { + public void run() { + if(DEBUG) { + System.err.println("NewtCanvasAWT.forceRelayout.0"); + } + // Hack to force proper native AWT layout incl. CALayer components on OSX + final java.awt.Component component = NewtCanvasAWT.this; + final int cW = component.getWidth(); + final int cH = component.getHeight(); + component.setSize(cW+1, cH+1); + component.setSize(cW, cH); + if(DEBUG) { + System.err.println("NewtCanvasAWT.forceRelayout.X"); + } + } }; private final void detachNewtChild(java.awt.Container cont) { if( null == newtChild || null == jawtWindow || !newtChildAttached ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 49f1940dc..5e523c780 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -37,6 +37,7 @@ import java.nio.FloatBuffer; import javax.media.nativewindow.NativeWindow; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; @@ -267,6 +268,10 @@ public class GearsES2 implements GLEventListener { } public void display(GLAutoDrawable drawable) { + GLAnimatorControl anim = drawable.getAnimator(); + if( verbose && ( null == anim || !anim.isAnimating() ) ) { + System.err.println(Thread.currentThread()+" GearsES2.display"+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); + } // Turn the gears' teeth if(doRotate) { angle += 2.0f; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index 64151362b..78ee2f6b5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -47,6 +47,7 @@ import com.jogamp.opengl.test.junit.util.QuitAdapter; import java.awt.BorderLayout; import java.awt.Button; +import java.awt.Component; import java.awt.Container; import java.awt.Dimension; import java.awt.EventQueue; @@ -65,7 +66,13 @@ import org.junit.Test; public class TestGearsES2AWT extends UITestCase { public enum FrameLayout { None, TextOnBottom, BorderCenterSurrounded, DoubleBorderCenterSurrounded }; + public enum ResizeBy { Component, Frame }; + + static long duration = 500; // ms static int width, height; + static FrameLayout frameLayout = FrameLayout.None; + static ResizeBy resizeBy = ResizeBy.Component; + static boolean forceES2 = false; static boolean forceGL3 = false; static boolean shallUseOffscreenFBOLayer = false; @@ -79,7 +86,7 @@ public class TestGearsES2AWT extends UITestCase { static boolean exclusiveContext = false; static boolean useAnimator = true; static Thread awtEDT; - static Dimension rwsize = null; + static java.awt.Dimension rwsize = null; @BeforeClass public static void initClass() { @@ -100,13 +107,13 @@ public class TestGearsES2AWT extends UITestCase { public static void releaseClass() { } - static void setGLCanvasSize(final Frame frame, final GLCanvas glc, final Dimension new_sz) { + static void setComponentSize(final Frame frame, final Component comp, final java.awt.Dimension new_sz) { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - glc.setMinimumSize(new_sz); - glc.setPreferredSize(new_sz); - glc.setSize(new_sz); + comp.setMinimumSize(new_sz); + comp.setPreferredSize(new_sz); + comp.setSize(new_sz); if( null != frame ) { frame.pack(); } @@ -116,14 +123,39 @@ public class TestGearsES2AWT extends UITestCase { Assume.assumeNoException( throwable ); } } + static void setFrameSize(final Frame frame, final boolean frameLayout, final java.awt.Dimension new_sz) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(new_sz); + if( frameLayout ) { + frame.validate(); + } + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + static void setSize(final ResizeBy resizeBy, final Frame frame, final boolean frameLayout, final Component comp, final java.awt.Dimension new_sz) { + switch( resizeBy ) { + case Component: + setComponentSize(frameLayout ? frame : null, comp, new_sz); + break; + case Frame: + setFrameSize(frame, frameLayout, new_sz); + break; + } + } - protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout) throws InterruptedException, InvocationTargetException { + protected void runTestGL(GLCapabilities caps, final ResizeBy resizeBy, FrameLayout frameLayout) throws InterruptedException, InvocationTargetException { final Frame frame = new Frame("GearsES2 AWT Test"); Assert.assertNotNull(frame); final GLCanvas glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); - setGLCanvasSize(null, glCanvas, new Dimension(width, height)); + setSize(resizeBy, frame, false, glCanvas, new Dimension(width, height)); switch( frameLayout) { case None: @@ -179,8 +211,12 @@ public class TestGearsES2AWT extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - frame.pack(); - frame.setVisible(true); + if( ResizeBy.Frame == resizeBy ) { + frame.validate(); + } else { + frame.pack(); + } + frame.setVisible(true); }}); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true)); @@ -197,7 +233,7 @@ public class TestGearsES2AWT extends UITestCase { if( null != rwsize ) { Thread.sleep(500); // 500ms delay - setGLCanvasSize(frame, glCanvas, rwsize); + setSize(resizeBy, frame, true, glCanvas, rwsize); System.err.println("window resize pos/siz: "+glCanvas.getX()+"/"+glCanvas.getY()+" "+glCanvas.getWidth()+"x"+glCanvas.getHeight()); } @@ -263,12 +299,9 @@ public class TestGearsES2AWT extends UITestCase { if(shallUseOffscreenPBufferLayer) { caps.setPBuffer(true); } - runTestGL(caps, frameLayout); + runTestGL(caps, resizeBy, frameLayout); } - static long duration = 500; // ms - static FrameLayout frameLayout = FrameLayout.None; - public static void main(String args[]) { boolean waitForKey = false; int rw=-1, rh=-1; @@ -288,6 +321,9 @@ public class TestGearsES2AWT extends UITestCase { } else if(args[i].equals("-layout")) { i++; frameLayout = FrameLayout.valueOf(args[i]); + } else if(args[i].equals("-resizeBy")) { + i++; + resizeBy = ResizeBy.valueOf(args[i]); } else if(args[i].equals("-es2")) { forceES2 = true; } else if(args[i].equals("-gl3")) { @@ -326,6 +362,7 @@ public class TestGearsES2AWT extends UITestCase { System.err.println("resize "+rwsize); System.err.println("frameLayout "+frameLayout); + System.err.println("resizeBy "+resizeBy); System.err.println("forceES2 "+forceES2); System.err.println("forceGL3 "+forceGL3); System.err.println("swapInterval "+swapInterval); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index 38eb80be8..3cf8290c7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -80,7 +80,9 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; static DimensionImmutable wsize, rwsize = null; - + static FrameLayout frameLayout = FrameLayout.None; + static ResizeBy resizeBy = ResizeBy.Component; + static long duration = 500; // ms static boolean opaque = true; static int forceAlpha = -1; @@ -401,9 +403,6 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { runTestGL(caps, resizeBy, frameLayout); } - static FrameLayout frameLayout = FrameLayout.None; - static ResizeBy resizeBy = ResizeBy.Component; - public static void main(String args[]) throws IOException { mainRun = true; -- cgit v1.2.3 From e68566febb69f6aca4bdf39d1d841c17df894631 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Apr 2013 16:27:11 +0200 Subject: SWT unit tests: Sort w/ AWT and Headless - Fix threading w/ AWT. This especially impacts (fixes) Mac OSX. --- make/build-test.xml | 8 +- make/scripts/tests.sh | 14 +- .../swt/TestNewtCanvasSWTBug628ResizeDeadlock.java | 394 -------------------- .../TestNewtCanvasSWTBug628ResizeDeadlockAWT.java | 401 +++++++++++++++++++++ .../junit/jogl/swt/TestSWTBug643AsyncExec.java | 9 +- .../event/TestNewtEventModifiersNewtCanvasSWT.java | 169 --------- .../TestNewtEventModifiersNewtCanvasSWTAWT.java | 170 +++++++++ 7 files changed, 587 insertions(+), 578 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlock.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java (limited to 'make/scripts') diff --git a/make/build-test.xml b/make/build-test.xml index dd072bddb..3d9c31d83 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -521,7 +521,8 @@ - + + @@ -550,6 +551,7 @@ + @@ -583,9 +585,8 @@ - + - @@ -611,7 +612,6 @@ - - - - - - + + + + + - - - - - - + + + + + + + @@ -700,6 +701,7 @@ +
    diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 23dbf3fd0..d9d5cd622 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -289,7 +289,7 @@ function testawtswt() { #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* -testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* @@ -378,7 +378,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 56d6f67ff..1282e5dc5 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -61,11 +61,11 @@ import com.jogamp.newt.util.ScreenModeUtil; public abstract class ScreenImpl extends Screen implements ScreenModeListener { protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); - protected static final int default_sm_bpp = 32; - protected static final int default_sm_widthmm = 519; - protected static final int default_sm_heightmm = 324; - protected static final int default_sm_rate = 60; - protected static final int default_sm_rotation = 0; + public static final int default_sm_bpp = 32; + public static final int default_sm_widthmm = 519; + public static final int default_sm_heightmm = 324; + public static final int default_sm_rate = 60; + public static final int default_sm_rotation = 0; protected DisplayImpl display; protected int screen_idx; diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 7a3c718c0..d94f27371 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -43,10 +43,10 @@ import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; import jogamp.newt.ScreenImpl; +import com.jogamp.common.util.VersionNumber; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; public class ScreenDriver extends ScreenImpl { @@ -65,172 +65,63 @@ public class ScreenDriver extends ScreenImpl { } } ); if (handle.longValue() == 0) { throw new RuntimeException("Error creating screen: " + screen_idx); - } - aScreen = new X11GraphicsScreen((X11GraphicsDevice) getDisplay().getGraphicsDevice(), screen_idx); + } + final X11GraphicsDevice x11dev = (X11GraphicsDevice) getDisplay().getGraphicsDevice(); + final long dpy = x11dev.getHandle(); + aScreen = new X11GraphicsScreen(x11dev, screen_idx); + { + int v[] = getRandRVersion0(dpy); + randrVersion = new VersionNumber(v[0], v[1], 0); + } + System.err.println("RandR "+randrVersion); + if( !randrVersion.isZero() ) { + screenRandR = new ScreenRandR11(); + } else { + screenRandR = null; + } } protected void closeNativeImpl() { } - private int[] nrotations; - private int nrotation_index; - private int nres_number; - private int nres_index; - private int[] nrates; - private int nrate_index; - private int nmode_number; - + private VersionNumber randrVersion; + private ScreenRandR screenRandR; + + @Override protected int[] getScreenModeFirstImpl() { + if( null == screenRandR ) { return null; } + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { - // initialize iterators and static data - nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); - if(null==nrotations || 0==nrotations.length) { - return null; - } - nrotation_index = 0; - - nres_number = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==nres_number) { - return null; - } - nres_index = 0; - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - - nmode_number = 0; - - return getScreenModeNextImpl(); + return screenRandR.getScreenModeFirstImpl(dpy, screen_idx); } } ); } + @Override protected int[] getScreenModeNextImpl() { + if( null == screenRandR ) { return null; } + // assemble: w x h x bpp x f x r return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { - /** - System.err.println("******** mode: "+nmode_number); - System.err.println("rot "+nrotation_index); - System.err.println("rate "+nrate_index); - System.err.println("res "+nres_index); */ - - int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); - } - int rate = nrates[nrate_index]; - if(0>=rate) { - rate = default_sm_rate; - if(DEBUG) { - System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+default_sm_rate); - } - } - int rotation = nrotations[nrotation_index]; - - int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; - int i = 0; - props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element - - nmode_number++; - - // iteration: r -> f -> bpp -> [w x h] - nrotation_index++; - if(nrotation_index == nrotations.length) { - nrotation_index=0; - nrate_index++; - if(null == nrates || nrate_index == nrates.length){ - nres_index++; - if(nres_index == nres_number) { - // done - nrates=null; - nrotations=null; - return null; - } - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - } - } - - return props; + return screenRandR.getScreenModeNextImpl(dpy, screen_idx); } } ); } + @Override protected ScreenMode getCurrentScreenModeImpl() { + if( null == screenRandR ) { return null; } + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public ScreenMode run(long dpy) { - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return null; - } - int[] res; - int rate, rot; - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==resNumber) { - return null; - } - - int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); - if(0>resIdx) { - return null; - } - if(resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); - } - res = getScreenModeResolution0(dpy, screen_idx, resIdx); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); - } - rate = getCurrentScreenRate0(screenConfigHandle); - if(0>rate) { - return null; - } - rot = getCurrentScreenRotation0(screenConfigHandle); - if(0>rot) { - return null; - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int i = 0; - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rot; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - return ScreenModeUtil.streamIn(props, 0); + return screenRandR.getCurrentScreenModeImpl(dpy, screen_idx); } } ); } + @Override protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { + if( null == screenRandR ) { return false; } + final List screenModes = this.getScreenModesOrig(); final int screenModeIdx = screenModes.indexOf(screenMode); if(0>screenModeIdx) { @@ -239,33 +130,8 @@ public class ScreenDriver extends ScreenImpl { final long t0 = System.currentTimeMillis(); boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { - boolean done = false; - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return Boolean.valueOf(done); - } - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - if(0>resIdx || resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); - } - - final int f = screenMode.getMonitorMode().getRefreshRate(); - final int r = screenMode.getRotation(); - - if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resIdx, f, r) ) { - while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) { - done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r); - if(!done) { - try { Thread.sleep(10); } catch (InterruptedException e) { } - } - } - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - return Boolean.valueOf(done); + final int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); + return Boolean.valueOf( screenRandR.setCurrentScreenModeImpl(dpy, screen_idx, screenMode, screenModeIdx, resIdx) ); } }).booleanValue(); @@ -328,25 +194,6 @@ public class ScreenDriver extends ScreenImpl { private static native int getWidth0(long display, int scrn_idx); private static native int getHeight0(long display, int scrn_idx); - - /** @return int[] { rot1, .. } */ - private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); - - private static native int getNumScreenModeResolutions0(long display, int screen_index); - - /** @return int[] { width, height, widthmm, heightmm } */ - private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); - - private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); - - private static native long getScreenConfiguration0(long display, int screen_index); - private static native void freeScreenConfiguration0(long screenConfiguration); - private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); - private static native int getCurrentScreenRate0(long screenConfiguration); - private static native int getCurrentScreenRotation0(long screenConfiguration); - - /** needs own Display connection for XRANDR event handling */ - private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); - private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); + private static native int[] getRandRVersion0(long display); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java new file mode 100644 index 000000000..abf20ba59 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java @@ -0,0 +1,12 @@ +package jogamp.newt.driver.x11; + +import com.jogamp.newt.ScreenMode; + +public interface ScreenRandR { + + int[] getScreenModeFirstImpl(final long dpy, final int screen_idx); + int[] getScreenModeNextImpl(final long dpy, final int screen_idx); + ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx); + boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx); + +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java new file mode 100644 index 000000000..e8a616b99 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java @@ -0,0 +1,214 @@ +package jogamp.newt.driver.x11; + +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class ScreenRandR11 implements ScreenRandR { + private static final boolean DEBUG = ScreenDriver.DEBUG; + + private int[] nrotations; + private int nrotation_index; + private int nres_number; + private int nres_index; + private int[] nrates; + private int nrate_index; + private int nmode_number; + + @Override + public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + // initialize iterators and static data + nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); + if(null==nrotations || 0==nrotations.length) { + return null; + } + nrotation_index = 0; + + nres_number = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==nres_number) { + return null; + } + nres_index = 0; + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + + nmode_number = 0; + + return getScreenModeNextImpl(dpy, screen_idx); + } + + @Override + public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { + /** + System.err.println("******** mode: "+nmode_number); + System.err.println("rot "+nrotation_index); + System.err.println("rate "+nrate_index); + System.err.println("res "+nres_index); */ + + int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); + } + int rate = nrates[nrate_index]; + if(0>=rate) { + rate = ScreenImpl.default_sm_rate; + if(DEBUG) { + System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+ScreenImpl.default_sm_rate); + } + } + int rotation = nrotations[nrotation_index]; + + int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rotation; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element + + nmode_number++; + + // iteration: r -> f -> bpp -> [w x h] + nrotation_index++; + if(nrotation_index == nrotations.length) { + nrotation_index=0; + nrate_index++; + if(null == nrates || nrate_index == nrates.length){ + nres_index++; + if(nres_index == nres_number) { + // done + nrates=null; + nrotations=null; + return null; + } + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + } + } + + return props; + } + + @Override + public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return null; + } + int[] res; + int rate, rot; + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==resNumber) { + return null; + } + + int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); + if(0>resIdx) { + return null; + } + if(resIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); + } + res = getScreenModeResolution0(dpy, screen_idx, resIdx); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); + } + rate = getCurrentScreenRate0(screenConfigHandle); + if(0>rate) { + return null; + } + rot = getCurrentScreenRotation0(screenConfigHandle); + if(0>rot) { + return null; + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int i = 0; + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rot; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count + return ScreenModeUtil.streamIn(props, 0); + } + + @Override + public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { + final long t0 = System.currentTimeMillis(); + boolean done = false; + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return Boolean.valueOf(done); + } + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0>resolutionIdx || resolutionIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! 0 < "+resolutionIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); + } + + final int f = screenMode.getMonitorMode().getRefreshRate(); + final int r = screenMode.getRotation(); + + if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resolutionIdx, f, r) ) { + while(!done && System.currentTimeMillis()-t0 < ScreenImpl.SCREEN_MODE_CHANGE_TIMEOUT) { + done = setCurrentScreenModePollEnd0(dpy, screen_idx, resolutionIdx, f, r); + if(!done) { + try { Thread.sleep(10); } catch (InterruptedException e) { } + } + } + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + return done; + } + + /** @return int[] { rot1, .. } */ + private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); + + private static native int getNumScreenModeResolutions0(long display, int screen_index); + + /** @return int[] { width, height, widthmm, heightmm } */ + private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); + + private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); + + private static native long getScreenConfiguration0(long display, int screen_index); + private static native void freeScreenConfiguration0(long screenConfiguration); + + private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); + private static native int getCurrentScreenRate0(long screenConfiguration); + private static native int getCurrentScreenRotation0(long screenConfiguration); + + /** needs own Display connection for XRANDR event handling */ + private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); + private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); + +} diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h index 4d1a7b59e..7f35216e3 100644 --- a/src/newt/native/X11Common.h +++ b/src/newt/native/X11Common.h @@ -45,8 +45,9 @@ #include -#include "jogamp_newt_driver_x11_ScreenDriver.h" #include "jogamp_newt_driver_x11_DisplayDriver.h" +#include "jogamp_newt_driver_x11_ScreenDriver.h" +#include "jogamp_newt_driver_x11_ScreenRandR11.h" #include "jogamp_newt_driver_x11_WindowDriver.h" #include "Window.h" diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c index e8a3ca656..69a06aad0 100644 --- a/src/newt/native/X11Screen.c +++ b/src/newt/native/X11Screen.c @@ -29,7 +29,7 @@ // #define VERBOSE_ON 1 // #define DBG_PERF 1 -#include "X11Common.h" +#include "X11Screen.h" #ifdef DBG_PERF #include "timespec.h" @@ -76,7 +76,7 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getHeight0 static int showedRandRVersion = 0; -static Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor) { +Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor) { if( 0 == XRRQueryVersion(dpy, major, minor) ) { return False; } @@ -87,12 +87,12 @@ static Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor) { return True; } -static Bool NewtScreen_hasRANDR(Display *dpy) { +Bool NewtScreen_hasRANDR(Display *dpy) { int major, minor; return NewtScreen_getRANDRVersion(dpy, &major, &minor); } -static int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { +int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { int rot; if(xrotation == RR_Rotate_0) { rot = 0; @@ -113,386 +113,27 @@ static int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { /* * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getAvailableScreenModeRotations0 - * Signature: (JI)I + * Method: GetRandRVersion0 + * Signature: (J)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailableScreenModeRotations0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int num_rotations = 0; - Rotation cur_rotation, rotations_supported; - int rotations[4]; - int major, minor; - - if(False == NewtScreen_getRANDRVersion(dpy, &major, &minor)) { - fprintf(stderr, "RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); - - if(0 != (rotations_supported & RR_Rotate_0)) { - rotations[num_rotations++] = 0; - } - if(0 != (rotations_supported & RR_Rotate_90)) { - rotations[num_rotations++] = 90; - } - if(0 != (rotations_supported & RR_Rotate_180)) { - rotations[num_rotations++] = 180; - } - if(0 != (rotations_supported & RR_Rotate_270)) { - rotations[num_rotations++] = 270; - } - - jintArray properties = NULL; - - if(num_rotations>0) { - properties = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); - } - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getNumScreenModeResolution0 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getRandRVersion0 + (JNIEnv *env, jclass clazz, jlong display) { - Display *dpy = (Display *) (intptr_t) display; -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0: RANDR not available\n"); - return 0; - } - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); -#endif - - DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); - - return num_sizes; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeResolutions0 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0: RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - // Fill the properties in temp jint array - int propIndex = 0; - jint prop[4]; - - prop[propIndex++] = xrrs[(int)resMode_idx].width; - prop[propIndex++] = xrrs[(int)resMode_idx].height; - prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; - prop[propIndex++] = xrrs[(int)resMode_idx].mheight; - - jintArray properties = (*env)->NewIntArray(env, 4); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeRates0 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0: RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - int num_rates; - short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); - - jint prop[num_rates]; - int i; - for(i=0; iNewIntArray(env, num_rates); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); + jintArray jversion = (*env)->NewIntArray(env, 2); + if (jversion == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size 2"); } // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenConfiguration0 - * Signature: (JI)J - */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenConfiguration0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)screen_idx); -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_getScreenConfiguration0: RANDR not available\n"); - return 0; - } -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - // get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL); -#endif - - return (jlong) (intptr_t) conf; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: freeScreenConfiguration0 - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_freeScreenConfiguration0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRate0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRate0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + (*env)->SetIntArrayRegion(env, jversion, 0, 2, version); - short original_rate = XRRConfigCurrentRate(conf); - DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); - - return (jint) original_rate; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRotation0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRotation0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - Rotation rotation; - - XRRConfigCurrentConfiguration(conf, &rotation); - - return NewtScreen_XRotation2Degree(env, rotation); -} - - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenResolutionIndex0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenResolutionIndex0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - - short original_rate = XRRConfigCurrentRate(conf); - - Rotation original_rotation; - SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModeStart0 - * Signature: (JIJIII)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModeStart0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - Window root = RootWindow(dpy, (int)screen_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - int rot; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - switch(rotation) { - case 0: - rot = RR_Rotate_0; - break; - case 90: - rot = RR_Rotate_90; - break; - case 180: - rot = RR_Rotate_180; - break; - case 270: - rot = RR_Rotate_270; - break; - default: - NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); - } - - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", - resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); - - XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); - - XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); - XSync(dpy, False); - - return JNI_TRUE; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModePollEnd0 - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - int randr_event_base, randr_error_base; - XEvent evt; - XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0: RANDR not available\n"); - return JNI_FALSE; - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); - - int done = 0; - int rot; - do { - if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { - return; - } - XNextEvent(dpy, &evt); - - switch (evt.type - randr_event_base) { - case RRScreenChangeNotify: - if(0 < scn_event->rotation ) { - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; - } else { - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, - scn_event->width, scn_event->height); - } - break; - default: - DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); - } - XRRUpdateConfiguration(&evt); - } while(!done); - - XSync(dpy, False); - + return jversion; } diff --git a/src/newt/native/X11Screen.h b/src/newt/native/X11Screen.h new file mode 100644 index 000000000..a5b8e3e70 --- /dev/null +++ b/src/newt/native/X11Screen.h @@ -0,0 +1,39 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#ifndef _X11SCREEN_H +#define _X11SCREEN_H + + +#include "X11Common.h" + +Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor); +Bool NewtScreen_hasRANDR(Display *dpy); +int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation); + +#endif /* _X11SCREEN_H */ diff --git a/src/newt/native/X11ScreenRandR11.c b/src/newt/native/X11ScreenRandR11.c index bc7d91d20..a457fd47b 100644 --- a/src/newt/native/X11ScreenRandR11.c +++ b/src/newt/native/X11ScreenRandR11.c @@ -26,9 +26,14 @@ * or implied, of JogAmp Community. */ -#include "X11Common.h" +#include "X11Screen.h" -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailableScreenModeRotations0_RandR11 +/* + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getAvailableScreenModeRotations0 + * Signature: (JI)I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getAvailableScreenModeRotations0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -73,30 +78,59 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailabl return properties; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0_RandR11 +/* + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getNumScreenModeResolution0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getNumScreenModeResolutions0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getNumScreenModeResolutions0: RANDR not available\n"); + return 0; + } + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes); +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); +#endif + + DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); return num_sizes; } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeResolutions0_RandR11 + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getScreenModeResolutions0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0_RandR11 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeResolution0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeResolution0: RANDR not available\n"); + return (*env)->NewIntArray(env, 0); + } + int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions @@ -125,15 +159,20 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenMo } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeRates0_RandR11 + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getScreenModeRates0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0_RandR11 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeRates0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeRates0: RANDR not available\n"); + return (*env)->NewIntArray(env, 0); + } + int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions @@ -163,100 +202,139 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenMo } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRate0_RandR11 - * Signature: (JI)I + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getScreenConfiguration0 + * Signature: (JI)J */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRate0_RandR11 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenConfiguration0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) { Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - + Window root = RootWindow(dpy, (int)screen_idx); +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenConfiguration0: RANDR not available\n"); + return 0; + } +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + // get current resolutions and frequencies XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL); +#endif - //free - XRRFreeScreenConfigInfo(conf); + return (jlong) (intptr_t) conf; +} + +/* + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: freeScreenConfiguration0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_freeScreenConfiguration0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); +} + +/* + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getCurrentScreenRate0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenRate0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + short original_rate = XRRConfigCurrentRate(conf); DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); return (jint) original_rate; } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRotation0_RandR11 - * Signature: (JI)I + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getCurrentScreenRotation0 + * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRotation0_RandR11 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenRotation0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - //get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; Rotation rotation; + XRRConfigCurrentConfiguration(conf, &rotation); - //free - XRRFreeScreenConfigInfo(conf); - return NewtScreen_XRotation2Degree(env, rotation); } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenResolutionIndex0_RandR11 - * Signature: (JI)I + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: getCurrentScreenResolutionIndex0 + * Signature: (J)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenResolutionIndex0_RandR11 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenResolutionIndex0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - // get current resolutions and frequency configuration - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); short original_rate = XRRConfigCurrentRate(conf); Rotation original_rotation; SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - //free - XRRFreeScreenConfigInfo(conf); - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; + return (jint)original_size_id; } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModeStart0_RandR11 - * Signature: (JIIII)Z + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: setCurrentScreenModeStart0 + * Signature: (JIJIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModeStart0_RandR11 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModeStart0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) { Display *dpy = (Display *) (intptr_t) display; + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; Window root = RootWindow(dpy, (int)screen_idx); int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; int rot; if( 0 > resMode_idx || resMode_idx >= num_sizes ) { NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); } - conf = XRRGetScreenInfo(dpy, root); - - rot = int NewtScreen_Degree2XRotation(env, rotation); + switch(rotation) { + case 0: + rot = RR_Rotate_0; + break; + case 90: + rot = RR_Rotate_90; + break; + case 180: + rot = RR_Rotate_180; + break; + case 270: + rot = RR_Rotate_270; + break; + default: + NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); + } DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); @@ -267,19 +345,15 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentSc XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); XSync(dpy, False); - //free - XRRFreeScreenConfigInfo(conf); - XSync(dpy, False); - return JNI_TRUE; } /* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModePollEnd0_RandR11 + * Class: jogamp_newt_driver_x11_ScreenRandR11 + * Method: setCurrentScreenModePollEnd0 * Signature: (J)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0_RandR11 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModePollEnd0 (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) { Display *dpy = (Display *) (intptr_t) display; @@ -287,6 +361,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentSc XEvent evt; XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; + if(False == NewtScreen_hasRANDR(dpy)) { + DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModePollEnd0: RANDR not available\n"); + return JNI_FALSE; + } + int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions XRRScreenConfiguration *conf; @@ -307,15 +386,22 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentSc switch (evt.type - randr_event_base) { case RRScreenChangeNotify: - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; + if(0 < scn_event->rotation ) { + rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, rot, + scn_event->width, scn_event->height); + // done = scn_event->size_index == resMode_idx; // not reliable .. + done = rot == rotation && + scn_event->width == xrrs[resMode_idx].width && + scn_event->height == xrrs[resMode_idx].height; + } else { + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, + scn_event->width, scn_event->height); + } break; default: DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); -- cgit v1.2.3 From 0a7cd9c58537d80131dbebf102f1f639ca0eb334 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 18 Apr 2013 19:14:35 +0200 Subject: Bug 718: WindowsBitmapWGLDrawable: Requires GLProfile.GL2, fix BITMAP GLCaps ASAP at Ctor instead of setRealized(true); WindowsWGLContext: Exclude ARB creation for BITMAP Unit Test TestGLAutoDrawableFactoryGLnBitmapCapsNEWT added using BITMAP on GLProfile.getDefault() Also: X11GLXContext, WindowsWGLContext: Cleanup formatting in createImpl(..) --- make/scripts/tests-x64.bat | 21 +-- make/scripts/tests.sh | 3 +- .../jogamp/opengl/GLDrawableFactoryImpl.java | 14 +- .../jogamp/opengl/GLGraphicsConfigurationUtil.java | 11 ++ .../windows/wgl/WindowsBitmapWGLDrawable.java | 39 +++-- .../opengl/windows/wgl/WindowsWGLContext.java | 61 ++++--- .../windows/wgl/WindowsWGLDrawableFactory.java | 2 +- .../jogamp/opengl/x11/glx/X11GLXContext.java | 52 +++--- ...TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java | 182 +++++++++++++++++++++ 9 files changed, 302 insertions(+), 83 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 05b1414d6..d196b1d29 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -29,16 +29,17 @@ REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclu REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d9d5cd622..62478cdb3 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -340,6 +340,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* @@ -378,7 +379,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 7ef99b241..26b1975ba 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -297,20 +297,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { final GLCapabilitiesImmutable capsChosen = GLGraphicsConfigurationUtil.fixOffscreenGLCapabilities(capsRequested, this, device); - if( capsChosen.isFBO() ) { - device.lock(); - try { + device.lock(); + try { + if( capsChosen.isFBO() ) { // Use minimum GLCapabilities for the dummy surface w/ same profile final ProxySurface dummySurface = createDummySurfaceImpl(device, true, new GLCapabilities(capsChosen.getGLProfile()), capsRequested, null, width, height); final GLDrawableImpl dummyDrawable = createOnscreenDrawableImpl(dummySurface); return new GLFBODrawableImpl.ResizeableImpl(this, dummyDrawable, dummySurface, capsChosen, 0); - } finally { - device.unlock(); - } - } - - device.lock(); - try { + } return createOffscreenDrawableImpl( createMutableSurfaceImpl(device, true, capsChosen, capsRequested, chooser, new UpstreamSurfaceHookMutableSize(width, height) ) ); } finally { diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java index 654d286d3..48b509263 100644 --- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java +++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java @@ -33,6 +33,7 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; import com.jogamp.opengl.GLRendererQuirks; @@ -317,4 +318,14 @@ public class GLGraphicsConfigurationUtil { } return compOut; } + + public static GLCapabilitiesImmutable fixGLProfile(GLCapabilitiesImmutable caps, GLProfile glp) + { + if( caps.getGLProfile() != glp ) { + final GLCapabilities caps2 = (GLCapabilities) caps.cloneMutable(); + caps2.setGLProfile(glp); + return caps2; + } + return caps; + } } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java index 3c326e93e..909a017b0 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java @@ -40,12 +40,14 @@ package jogamp.opengl.windows.wgl; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.MutableSurface; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; import jogamp.nativewindow.windows.BITMAPINFO; import jogamp.nativewindow.windows.BITMAPINFOHEADER; @@ -58,8 +60,28 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { private long origbitmap; private long hbitmap; - protected WindowsBitmapWGLDrawable(GLDrawableFactory factory, NativeSurface target) { - super(factory, target, false); + private WindowsBitmapWGLDrawable(GLDrawableFactory factory, NativeSurface comp) { + super(factory, comp, false); + } + + protected static WindowsBitmapWGLDrawable create(GLDrawableFactory factory, NativeSurface comp) { + final WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)comp.getGraphicsConfiguration(); + final AbstractGraphicsDevice aDevice = config.getScreen().getDevice(); + if( !GLProfile.isAvailable(aDevice, GLProfile.GL2) ) { + throw new GLException("GLProfile GL2 n/a on "+aDevice+" but required for Windows BITMAP"); + } + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilitiesImmutable capsChosen0 = (GLCapabilitiesImmutable)config.getChosenCapabilities(); + // RGB555 and also alpha channel is experienced to fail on some Windows machines + final GLCapabilitiesImmutable capsChosen1 = GLGraphicsConfigurationUtil.clipRGBAGLCapabilities(capsChosen0, false /* allowRGB555 */, false /* allowAlpha */); + final GLCapabilitiesImmutable capsChosen2 = GLGraphicsConfigurationUtil.fixGLProfile(capsChosen1, glp); + if( capsChosen0 != capsChosen2 ) { + config.setChosenCapabilities(capsChosen2); + if(DEBUG) { + System.err.println("WindowsBitmapWGLDrawable: "+capsChosen0+" -> "+capsChosen2); + } + } + return new WindowsBitmapWGLDrawable(factory, comp); } @Override @@ -88,18 +110,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable { System.err.println(getThreadName()+": WindowsBitmapWGLDrawable (1): "+ns); } final WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration(); - final GLCapabilitiesImmutable capsChosen; - { - final GLCapabilitiesImmutable capsChosen0 = (GLCapabilitiesImmutable)config.getChosenCapabilities(); - // RGB555 and also alpha channel is experienced to fail on some Windows machines - capsChosen = GLGraphicsConfigurationUtil.clipRGBAGLCapabilities(capsChosen0, false /* allowRGB555 */, false /* allowAlpha */); - if( capsChosen0 != capsChosen ) { - config.setChosenCapabilities(capsChosen); - if(DEBUG) { - System.err.println("WindowsBitmapWGLDrawable: "+capsChosen0+" -> "+capsChosen); - } - } - } + final GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable)config.getChosenCapabilities(); final int width = getWidth(); final int height = getHeight(); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 1f41563ba..77d06f548 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -277,50 +277,63 @@ public class WindowsWGLContext extends GLContextImpl { isGLReadDrawableAvailable(); // trigger setup wglGLReadDrawableAvailable + if (DEBUG) { + System.err.println(getThreadName() + ": createImpl: START "+glCaps+", share "+shareWith); + } + // Windows can set up sharing of display lists after creation time - long share = 0; - if (null != shareWith) { - share = shareWith.getHandle(); - if (share == 0) { - throw new GLException("GLContextShareSet returned an invalid OpenGL context"); - } + long share; + if ( null != shareWith ) { + share = shareWith.getHandle(); + if (share == 0) { + throw new GLException("GLContextShareSet returned an invalid OpenGL context"); + } + } else { + share = 0; } boolean createContextARBTried = false; - // utilize the shared context's GLXExt in case it was using the ARB method and it already exists - if( null!=sharedContext && sharedContext.isCreatedWithARBMethod() ) { + // utilize the shared context's GLXExt in case it was using the ARB method and it already exists ; exclude BITMAP + if( null != sharedContext && sharedContext.isCreatedWithARBMethod() && !glCaps.isBitmap() ) { contextHandle = createContextARB(share, true); createContextARBTried = true; - if (DEBUG && 0!=contextHandle) { + if ( DEBUG && 0 != contextHandle ) { System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+share); } } - long temp_ctx = 0; - if(0==contextHandle) { + final long temp_ctx; + if( 0 == contextHandle ) { // To use WGL_ARB_create_context, we have to make a temp context current, // so we are able to use GetProcAddress temp_ctx = WGL.wglCreateContext(drawable.getHandle()); - if (temp_ctx == 0) { + if ( 0 == temp_ctx ) { throw new GLException("Unable to create temp OpenGL context for device context " + toHexString(drawable.getHandle())); } - if (!WGL.wglMakeCurrent(drawable.getHandle(), temp_ctx)) { + if ( !WGL.wglMakeCurrent(drawable.getHandle(), temp_ctx) ) { throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: "+GDI.GetLastError()); } setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION WGL.wglMakeCurrent(0, 0); // release temp context - if( !createContextARBTried) { + if( !createContextARBTried ) { // is*Available calls are valid since setGLFunctionAvailability(..) was called - final boolean isProcCreateContextAttribsARBAvailable = isFunctionAvailable("wglCreateContextAttribsARB"); - final boolean isExtARBCreateContextAvailable = isExtensionAvailable("WGL_ARB_create_context"); + final boolean isProcCreateContextAttribsARBAvailable; + final boolean isExtARBCreateContextAvailable; + if( !glCaps.isBitmap() ) { // exclude ARB if BITMAP + isProcCreateContextAttribsARBAvailable = isFunctionAvailable("wglCreateContextAttribsARB"); + isExtARBCreateContextAvailable = isExtensionAvailable("WGL_ARB_create_context"); + } else { + isProcCreateContextAttribsARBAvailable = false; + isExtARBCreateContextAvailable = false; + } if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) { // initial ARB context creation contextHandle = createContextARB(share, true); createContextARBTried=true; if (DEBUG) { - if(0!=contextHandle) { + if( 0 != contextHandle ) { System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+share); } else { System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+share); @@ -331,11 +344,13 @@ public class WindowsWGLContext extends GLContextImpl { ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable); } } + } else { + temp_ctx = 0; } - if(0!=contextHandle) { + if( 0 != contextHandle ) { share = 0; // mark as shared thx to the ARB create method - if(0!=temp_ctx) { + if( 0 != temp_ctx ) { WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_ctx); if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { @@ -343,7 +358,7 @@ public class WindowsWGLContext extends GLContextImpl { } } } else { - if(glCaps.getGLProfile().isGL3()) { + if( glCaps.getGLProfile().isGL3() ) { WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_ctx); throw new GLException(getThreadName()+": WindowsWGLContex.createContextImpl ctx !ARB, profile > GL2 requested (OpenGL >= 3.0.1). Requested: "+glCaps.getGLProfile()+", current: "+getGLVersion()); @@ -354,15 +369,15 @@ public class WindowsWGLContext extends GLContextImpl { // continue with temp context for GL < 3.0 contextHandle = temp_ctx; - if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { + if ( !wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) { WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(contextHandle); throw new GLException("Error making old context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError()); } - if(0!=share) { + if( 0 != share ) { // Only utilize the classic GDI 'wglShareLists' shared context method // for traditional non ARB context. - if (!WGL.wglShareLists(share, contextHandle)) { + if ( !WGL.wglShareLists(share, contextHandle) ) { throw new GLException("wglShareLists(" + toHexString(share) + ", " + toHexString(contextHandle) + ") failed: werr " + GDI.GetLastError()); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 26d73638f..e9742c4fe 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -490,7 +490,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { AbstractGraphicsConfiguration config = target.getGraphicsConfiguration(); GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); if(!chosenCaps.isPBuffer()) { - return new WindowsBitmapWGLDrawable(this, target); + return WindowsBitmapWGLDrawable.create(this, target); } // PBuffer GLDrawable Creation diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index c60619452..c3c35ed49 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -284,28 +284,30 @@ public class X11GLXContext extends GLContextImpl { final X11GLXContext sharedContext = (X11GLXContext) factory.getOrCreateSharedContextImpl(device); long display = device.getHandle(); - long share = 0; - if (shareWith != null) { - share = shareWith.getHandle(); - if (share == 0) { - throw new GLException("GLContextShareSet returned an invalid OpenGL context"); - } - direct = GLX.glXIsDirect(display, share); + final long share; + if ( null != shareWith ) { + share = shareWith.getHandle(); + if (share == 0) { + throw new GLException("GLContextShareSet returned an invalid OpenGL context"); + } + direct = GLX.glXIsDirect(display, share); + } else { + share = 0; } - GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - GLProfile glp = glCaps.getGLProfile(); + final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final GLProfile glp = glCaps.getGLProfile(); - if(config.getFBConfigID()<0) { + if( config.getFBConfigID() < 0 ) { // not able to use FBConfig if(glp.isGL3()) { throw new GLException(getThreadName()+": Unable to create OpenGL >= 3.1 context"); } contextHandle = GLX.glXCreateContext(display, config.getXVisualInfo(), share, direct); - if (contextHandle == 0) { + if ( 0 == contextHandle ) { throw new GLException(getThreadName()+": Unable to create context(0)"); } - if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { + if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) { throw new GLException(getThreadName()+": Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); } setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION @@ -319,23 +321,23 @@ public class X11GLXContext extends GLContextImpl { boolean createContextARBTried = false; // utilize the shared context's GLXExt in case it was using the ARB method and it already exists - if(null!=sharedContext && sharedContext.isCreatedWithARBMethod()) { + if( null != sharedContext && sharedContext.isCreatedWithARBMethod() ) { contextHandle = createContextARB(share, direct); createContextARBTried = true; - if (DEBUG && 0!=contextHandle) { + if ( DEBUG && 0 != contextHandle ) { System.err.println(getThreadName() + ": createContextImpl: OK (ARB, using sharedContext) share "+share); } } - long temp_ctx = 0; - if(0==contextHandle) { + final long temp_ctx; + if( 0 == contextHandle ) { // To use GLX_ARB_create_context, we have to make a temp context current, // so we are able to use GetProcAddress temp_ctx = GLX.glXCreateNewContext(display, config.getFBConfig(), GLX.GLX_RGBA_TYPE, share, direct); - if (temp_ctx == 0) { + if ( 0 == temp_ctx ) { throw new GLException(getThreadName()+": Unable to create temp OpenGL context(1)"); } - if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx)) { + if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx) ) { throw new GLException(getThreadName()+": Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable); } setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION @@ -349,7 +351,7 @@ public class X11GLXContext extends GLContextImpl { contextHandle = createContextARB(share, direct); createContextARBTried=true; if (DEBUG) { - if(0!=contextHandle) { + if( 0 != contextHandle ) { System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+share); } else { System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+share); @@ -360,18 +362,20 @@ public class X11GLXContext extends GLContextImpl { ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable); } } + } else { + temp_ctx = 0; } - if(0!=contextHandle) { - if(0!=temp_ctx) { + if( 0 != contextHandle ) { + if( 0 != temp_ctx ) { glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, temp_ctx); - if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { + if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) { throw new GLException(getThreadName()+": Cannot make previous verified context current"); } } } else { - if(glp.isGL3()) { + if( glp.isGL3() ) { glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, temp_ctx); throw new GLException(getThreadName()+": X11GLXContext.createContextImpl ctx !ARB, profile > GL2 requested (OpenGL >= 3.0.1). Requested: "+glp+", current: "+getGLVersion()); @@ -382,7 +386,7 @@ public class X11GLXContext extends GLContextImpl { // continue with temp context for GL <= 3.0 contextHandle = temp_ctx; - if (!glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { + if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) { glXMakeContextCurrent(display, 0, 0, 0); GLX.glXDestroyContext(display, temp_ctx); throw new GLException(getThreadName()+": Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java new file mode 100644 index 000000000..746b8e15a --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java @@ -0,0 +1,182 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.io.IOException; + +import javax.media.nativewindow.CapabilitiesImmutable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import jogamp.opengl.GLGraphicsConfigurationUtil; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + *

    + * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + *

    + */ +public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { + static final int widthStep = 800/4; + static final int heightStep = 600/4; + volatile int szStep = 2; + + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { + System.out.println("Requested GL Caps: "+reqGLCaps); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); + final GLCapabilitiesImmutable expGLCaps = GLGraphicsConfigurationUtil.fixGLCapabilities(reqGLCaps, factory, null); + System.out.println("Expected GL Caps: "+expGLCaps); + + // + // Create native OpenGL resources .. XGL/WGL/CGL .. + // equivalent to GLAutoDrawable methods: setVisible(true) + // + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null); + + Assert.assertNotNull(glad); + System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + Assert.assertTrue(glad.isRealized()); + + // Check caps of NativeWindow config w/o GL + final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); + System.out.println("Drawable Caps Pre_GL : "+chosenCaps); + Assert.assertNotNull(chosenCaps); + Assert.assertTrue(chosenCaps.getGreenBits()>4); + Assert.assertTrue(chosenCaps.getBlueBits()>4); + Assert.assertTrue(chosenCaps.getRedBits()>4); + + glad.display(); // force native context creation + + // Check caps of GLDrawable after realization + final GLCapabilitiesImmutable chosenGLCaps = glad.getChosenGLCapabilities(); + System.out.println("Chosen GL CTX (1): "+glad.getContext().getGLVersion()); + System.out.println("Chosen GL Caps(1): "+chosenGLCaps); + System.out.println("Chosen GL Caps(2): "+glad.getNativeSurface().getGraphicsConfiguration().getChosenCapabilities()); + + Assert.assertNotNull(chosenGLCaps); + Assert.assertTrue(chosenGLCaps.getGreenBits()>4); + Assert.assertTrue(chosenGLCaps.getBlueBits()>4); + Assert.assertTrue(chosenGLCaps.getRedBits()>4); + Assert.assertTrue(chosenGLCaps.getDepthBits()>4); + Assert.assertEquals(expGLCaps.isOnscreen(), chosenGLCaps.isOnscreen()); + Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); + Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); + Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); + /** Single/Double buffer cannot be checked since result may vary .. + if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { + // dbl buffer may be disabled w/ offscreen pbuffer and bitmap + Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); + } */ + + glad.addGLEventListener(demo); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + glad.addGLEventListener(snapshotGLEventListener); + + glad.display(); // initial resize/display + + // 1 - szStep = 2 + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 2, 3 (resize + display) + szStep = 1; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + // 4, 5 (resize + display) + szStep = 4; + glad.setSize(widthStep*szStep, heightStep*szStep); + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); + snapshotGLEventListener.setMakeSnapshot(); + glad.display(); + + Thread.sleep(50); + + glad.destroy(); + System.out.println("Fin Drawable: "+glad); + } + + @Test + public void testAvailableInfo() { + GLDrawableFactory f = GLDrawableFactory.getDesktopFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + f = GLDrawableFactory.getEGLFactory(); + if(null != f) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); + } + } + + // Might be reduced to !double-buff + @Test + public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.getDefault()); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + doTest(reqGLCaps, new Gears(1)); + } + + // Might be reduced to !MSAA + @Test + public void testGL2OffScreenBitmapDblBufMSAA() throws InterruptedException { + final GLCapabilities reqGLCaps = new GLCapabilities(GLProfile.getDefault()); + reqGLCaps.setOnscreen(false); + reqGLCaps.setBitmap(true); + reqGLCaps.setSampleBuffers(true); + reqGLCaps.setNumSamples(4); + doTest(reqGLCaps, new Gears(1)); + } + + public static void main(String args[]) throws IOException { + org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.class.getName()); + } + +} -- cgit v1.2.3 From 03a3f209aff955410e0f3133e73078529c23d3e1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 19 Apr 2013 02:46:48 +0200 Subject: Bug 721: NEWT/X11 RandR 1.3 Support - Part 2 - Rename impl class/files, start RandR13 coding. --- make/build-newt.xml | 5 +- make/scripts/tests.sh | 6 +- src/newt/classes/jogamp/newt/driver/x11/RandR.java | 39 ++ .../classes/jogamp/newt/driver/x11/RandR11.java | 241 ++++++++++++ .../classes/jogamp/newt/driver/x11/RandR13.java | 51 +++ .../jogamp/newt/driver/x11/ScreenDriver.java | 26 +- .../jogamp/newt/driver/x11/ScreenRandR.java | 12 - .../jogamp/newt/driver/x11/ScreenRandR11.java | 214 ----------- src/newt/native/X11Common.h | 3 +- src/newt/native/X11RandR11.c | 386 +++++++++++++++++++ src/newt/native/X11RandR13.c | 408 ++++++++++++++++++++ src/newt/native/X11Screen.c | 21 +- src/newt/native/X11Screen.h | 2 - src/newt/native/X11ScreenRandR11.c | 415 --------------------- src/newt/native/X11ScreenRandR13.c | 372 ------------------ 15 files changed, 1148 insertions(+), 1053 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/driver/x11/RandR.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/RandR11.java create mode 100644 src/newt/classes/jogamp/newt/driver/x11/RandR13.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java delete mode 100644 src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java create mode 100644 src/newt/native/X11RandR11.c create mode 100644 src/newt/native/X11RandR13.c delete mode 100644 src/newt/native/X11ScreenRandR11.c delete mode 100644 src/newt/native/X11ScreenRandR13.c (limited to 'make/scripts') diff --git a/make/build-newt.xml b/make/build-newt.xml index d728b42c7..862b78422 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -592,7 +592,7 @@ - + @@ -701,7 +701,8 @@ - + + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 62478cdb3..75e5f7fd6 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -340,7 +340,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* @@ -363,7 +363,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBi #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* +##testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT @@ -379,7 +379,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBi #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java new file mode 100644 index 000000000..485d976ec --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java @@ -0,0 +1,39 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.x11; + +import com.jogamp.newt.ScreenMode; + +public interface RandR { + + int[] getScreenModeFirstImpl(final long dpy, final int screen_idx); + int[] getScreenModeNextImpl(final long dpy, final int screen_idx); + ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx); + boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx); + +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java new file mode 100644 index 000000000..ee67bd304 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -0,0 +1,241 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.x11; + +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.util.ScreenModeUtil; + +public class RandR11 implements RandR { + private static final boolean DEBUG = ScreenDriver.DEBUG; + + private int[] nrotations; + private int nrotation_index; + private int nres_number; + private int nres_index; + private int[] nrates; + private int nrate_index; + private int nmode_number; + + @Override + public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + // initialize iterators and static data + nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); + if(null==nrotations || 0==nrotations.length) { + return null; + } + nrotation_index = 0; + + nres_number = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==nres_number) { + return null; + } + nres_index = 0; + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + + nmode_number = 0; + + return getScreenModeNextImpl(dpy, screen_idx); + } + + @Override + public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { + /** + System.err.println("******** mode: "+nmode_number); + System.err.println("rot "+nrotation_index); + System.err.println("rate "+nrate_index); + System.err.println("res "+nres_index); */ + + int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); + } + int rate = nrates[nrate_index]; + if(0>=rate) { + rate = ScreenImpl.default_sm_rate; + if(DEBUG) { + System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+ScreenImpl.default_sm_rate); + } + } + int rotation = nrotations[nrotation_index]; + + int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rotation; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element + + nmode_number++; + + // iteration: r -> f -> bpp -> [w x h] + nrotation_index++; + if(nrotation_index == nrotations.length) { + nrotation_index=0; + nrate_index++; + if(null == nrates || nrate_index == nrates.length){ + nres_index++; + if(nres_index == nres_number) { + // done + nrates=null; + nrotations=null; + return null; + } + + nrates = getScreenModeRates0(dpy, screen_idx, nres_index); + if(null==nrates || 0==nrates.length) { + return null; + } + nrate_index = 0; + } + } + + return props; + } + + @Override + public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return null; + } + int[] res; + int rate, rot; + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0==resNumber) { + return null; + } + + int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); + if(0>resIdx) { + return null; + } + if(resIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); + } + res = getScreenModeResolution0(dpy, screen_idx, resIdx); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); + } + rate = getCurrentScreenRate0(screenConfigHandle); + if(0>rate) { + return null; + } + rot = getCurrentScreenRotation0(screenConfigHandle); + if(0>rot) { + return null; + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int i = 0; + props[i++] = 0; // set later for verification of iterator + props[i++] = res[0]; // width + props[i++] = res[1]; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = res[2]; // widthmm + props[i++] = res[3]; // heightmm + props[i++] = rate; // rate + props[i++] = rot; + props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count + return ScreenModeUtil.streamIn(props, 0); + } + + @Override + public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { + final long t0 = System.currentTimeMillis(); + boolean done = false; + long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); + if(0 == screenConfigHandle) { + return Boolean.valueOf(done); + } + try { + int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + if(0>resolutionIdx || resolutionIdx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! 0 < "+resolutionIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); + } + + final int f = screenMode.getMonitorMode().getRefreshRate(); + final int r = screenMode.getRotation(); + + if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resolutionIdx, f, r) ) { + while(!done && System.currentTimeMillis()-t0 < ScreenImpl.SCREEN_MODE_CHANGE_TIMEOUT) { + done = setCurrentScreenModePollEnd0(dpy, screen_idx, resolutionIdx, f, r); + if(!done) { + try { Thread.sleep(10); } catch (InterruptedException e) { } + } + } + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + return done; + } + + /** @return int[] { rot1, .. } */ + private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); + + private static native int getNumScreenModeResolutions0(long display, int screen_index); + + /** @return int[] { width, height, widthmm, heightmm } */ + private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); + + private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); + + private static native long getScreenConfiguration0(long display, int screen_index); + private static native void freeScreenConfiguration0(long screenConfiguration); + + private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); + private static native int getCurrentScreenRate0(long screenConfiguration); + private static native int getCurrentScreenRotation0(long screenConfiguration); + + /** needs own Display connection for XRANDR event handling */ + private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); + private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); + +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java new file mode 100644 index 000000000..24c9806af --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -0,0 +1,51 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.x11; + +import com.jogamp.newt.ScreenMode; + +public class RandR13 implements RandR { + + public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + return null; + } + public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { + return null; + } + public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { + return null; + } + + public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { + return false; + } + + private static native long getScreenResources0(long display, int screen_index); + private static native void freeScreenResources0(long screenConfiguration); + +} diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index d94f27371..cd8da9b60 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -73,11 +73,13 @@ public class ScreenDriver extends ScreenImpl { int v[] = getRandRVersion0(dpy); randrVersion = new VersionNumber(v[0], v[1], 0); } - System.err.println("RandR "+randrVersion); + if( DEBUG ) { + System.err.println("RandR "+randrVersion); + } if( !randrVersion.isZero() ) { - screenRandR = new ScreenRandR11(); + rAndR = new RandR11(); } else { - screenRandR = null; + rAndR = null; } } @@ -85,42 +87,42 @@ public class ScreenDriver extends ScreenImpl { } private VersionNumber randrVersion; - private ScreenRandR screenRandR; + private RandR rAndR; @Override protected int[] getScreenModeFirstImpl() { - if( null == screenRandR ) { return null; } + if( null == rAndR ) { return null; } return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { - return screenRandR.getScreenModeFirstImpl(dpy, screen_idx); + return rAndR.getScreenModeFirstImpl(dpy, screen_idx); } } ); } @Override protected int[] getScreenModeNextImpl() { - if( null == screenRandR ) { return null; } + if( null == rAndR ) { return null; } // assemble: w x h x bpp x f x r return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public int[] run(long dpy) { - return screenRandR.getScreenModeNextImpl(dpy, screen_idx); + return rAndR.getScreenModeNextImpl(dpy, screen_idx); } } ); } @Override protected ScreenMode getCurrentScreenModeImpl() { - if( null == screenRandR ) { return null; } + if( null == rAndR ) { return null; } return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public ScreenMode run(long dpy) { - return screenRandR.getCurrentScreenModeImpl(dpy, screen_idx); + return rAndR.getCurrentScreenModeImpl(dpy, screen_idx); } } ); } @Override protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { - if( null == screenRandR ) { return false; } + if( null == rAndR ) { return false; } final List screenModes = this.getScreenModesOrig(); final int screenModeIdx = screenModes.indexOf(screenMode); @@ -131,7 +133,7 @@ public class ScreenDriver extends ScreenImpl { boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { final int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - return Boolean.valueOf( screenRandR.setCurrentScreenModeImpl(dpy, screen_idx, screenMode, screenModeIdx, resIdx) ); + return Boolean.valueOf( rAndR.setCurrentScreenModeImpl(dpy, screen_idx, screenMode, screenModeIdx, resIdx) ); } }).booleanValue(); diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java deleted file mode 100644 index abf20ba59..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR.java +++ /dev/null @@ -1,12 +0,0 @@ -package jogamp.newt.driver.x11; - -import com.jogamp.newt.ScreenMode; - -public interface ScreenRandR { - - int[] getScreenModeFirstImpl(final long dpy, final int screen_idx); - int[] getScreenModeNextImpl(final long dpy, final int screen_idx); - ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx); - boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx); - -} diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java deleted file mode 100644 index e8a616b99..000000000 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenRandR11.java +++ /dev/null @@ -1,214 +0,0 @@ -package jogamp.newt.driver.x11; - -import jogamp.newt.ScreenImpl; - -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; - -public class ScreenRandR11 implements ScreenRandR { - private static final boolean DEBUG = ScreenDriver.DEBUG; - - private int[] nrotations; - private int nrotation_index; - private int nres_number; - private int nres_index; - private int[] nrates; - private int nrate_index; - private int nmode_number; - - @Override - public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { - // initialize iterators and static data - nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); - if(null==nrotations || 0==nrotations.length) { - return null; - } - nrotation_index = 0; - - nres_number = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==nres_number) { - return null; - } - nres_index = 0; - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - - nmode_number = 0; - - return getScreenModeNextImpl(dpy, screen_idx); - } - - @Override - public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { - /** - System.err.println("******** mode: "+nmode_number); - System.err.println("rot "+nrotation_index); - System.err.println("rate "+nrate_index); - System.err.println("res "+nres_index); */ - - int[] res = getScreenModeResolution0(dpy, screen_idx, nres_index); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); - } - int rate = nrates[nrate_index]; - if(0>=rate) { - rate = ScreenImpl.default_sm_rate; - if(DEBUG) { - System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+ScreenImpl.default_sm_rate); - } - } - int rotation = nrotations[nrotation_index]; - - int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; - int i = 0; - props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = ScreenImpl.default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element - - nmode_number++; - - // iteration: r -> f -> bpp -> [w x h] - nrotation_index++; - if(nrotation_index == nrotations.length) { - nrotation_index=0; - nrate_index++; - if(null == nrates || nrate_index == nrates.length){ - nres_index++; - if(nres_index == nres_number) { - // done - nrates=null; - nrotations=null; - return null; - } - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - } - } - - return props; - } - - @Override - public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return null; - } - int[] res; - int rate, rot; - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==resNumber) { - return null; - } - - int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); - if(0>resIdx) { - return null; - } - if(resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); - } - res = getScreenModeResolution0(dpy, screen_idx, resIdx); - if(null==res || 0==res.length) { - return null; - } - if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); - } - rate = getCurrentScreenRate0(screenConfigHandle); - if(0>rate) { - return null; - } - rot = getCurrentScreenRotation0(screenConfigHandle); - if(0>rot) { - return null; - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int i = 0; - props[i++] = 0; // set later for verification of iterator - props[i++] = res[0]; // width - props[i++] = res[1]; // height - props[i++] = ScreenImpl.default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rot; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - return ScreenModeUtil.streamIn(props, 0); - } - - @Override - public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { - final long t0 = System.currentTimeMillis(); - boolean done = false; - long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); - if(0 == screenConfigHandle) { - return Boolean.valueOf(done); - } - try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0>resolutionIdx || resolutionIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! 0 < "+resolutionIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); - } - - final int f = screenMode.getMonitorMode().getRefreshRate(); - final int r = screenMode.getRotation(); - - if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resolutionIdx, f, r) ) { - while(!done && System.currentTimeMillis()-t0 < ScreenImpl.SCREEN_MODE_CHANGE_TIMEOUT) { - done = setCurrentScreenModePollEnd0(dpy, screen_idx, resolutionIdx, f, r); - if(!done) { - try { Thread.sleep(10); } catch (InterruptedException e) { } - } - } - } - } finally { - freeScreenConfiguration0(screenConfigHandle); - } - return done; - } - - /** @return int[] { rot1, .. } */ - private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); - - private static native int getNumScreenModeResolutions0(long display, int screen_index); - - /** @return int[] { width, height, widthmm, heightmm } */ - private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); - - private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); - - private static native long getScreenConfiguration0(long display, int screen_index); - private static native void freeScreenConfiguration0(long screenConfiguration); - - private static native int getCurrentScreenResolutionIndex0(long screenConfiguration); - private static native int getCurrentScreenRate0(long screenConfiguration); - private static native int getCurrentScreenRotation0(long screenConfiguration); - - /** needs own Display connection for XRANDR event handling */ - private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot); - private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot); - -} diff --git a/src/newt/native/X11Common.h b/src/newt/native/X11Common.h index 7f35216e3..e58cdb755 100644 --- a/src/newt/native/X11Common.h +++ b/src/newt/native/X11Common.h @@ -47,7 +47,8 @@ #include "jogamp_newt_driver_x11_DisplayDriver.h" #include "jogamp_newt_driver_x11_ScreenDriver.h" -#include "jogamp_newt_driver_x11_ScreenRandR11.h" +#include "jogamp_newt_driver_x11_RandR11.h" +#include "jogamp_newt_driver_x11_RandR13.h" #include "jogamp_newt_driver_x11_WindowDriver.h" #include "Window.h" diff --git a/src/newt/native/X11RandR11.c b/src/newt/native/X11RandR11.c new file mode 100644 index 000000000..cbf911a38 --- /dev/null +++ b/src/newt/native/X11RandR11.c @@ -0,0 +1,386 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#include "X11Screen.h" + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getAvailableScreenModeRotations0 + * Signature: (JI)I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getAvailableScreenModeRotations0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + int num_rotations = 0; + Rotation cur_rotation, rotations_supported; + int rotations[4]; + int major, minor; + + rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); + + if(0 != (rotations_supported & RR_Rotate_0)) { + rotations[num_rotations++] = 0; + } + if(0 != (rotations_supported & RR_Rotate_90)) { + rotations[num_rotations++] = 90; + } + if(0 != (rotations_supported & RR_Rotate_180)) { + rotations[num_rotations++] = 180; + } + if(0 != (rotations_supported & RR_Rotate_270)) { + rotations[num_rotations++] = 270; + } + + jintArray properties = NULL; + + if(num_rotations>0) { + properties = (*env)->NewIntArray(env, num_rotations); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); + } + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getNumScreenModeResolution0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenModeResolutions0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); +#endif + + DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); + + return num_sizes; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getScreenModeResolutions0 + * Signature: (JII)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeResolution0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + // Fill the properties in temp jint array + int propIndex = 0; + jint prop[4]; + + prop[propIndex++] = xrrs[(int)resMode_idx].width; + prop[propIndex++] = xrrs[(int)resMode_idx].height; + prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; + prop[propIndex++] = xrrs[(int)resMode_idx].mheight; + + jintArray properties = (*env)->NewIntArray(env, 4); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getScreenModeRates0 + * Signature: (JII)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeRates0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + int num_rates; + short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); + + jint prop[num_rates]; + int i; + for(i=0; iNewIntArray(env, num_rates); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getScreenConfiguration0 + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenConfiguration0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)screen_idx); +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + + // get current resolutions and frequencies + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL); +#endif + + return (jlong) (intptr_t) conf; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: freeScreenConfiguration0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR11_freeScreenConfiguration0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getCurrentScreenRate0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getCurrentScreenRate0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + + short original_rate = XRRConfigCurrentRate(conf); + DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); + + return (jint) original_rate; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getCurrentScreenRotation0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getCurrentScreenRotation0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + Rotation rotation; + + XRRConfigCurrentConfiguration(conf, &rotation); + + return NewtScreen_XRotation2Degree(env, rotation); +} + + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: getCurrentScreenResolutionIndex0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getCurrentScreenResolutionIndex0 + (JNIEnv *env, jclass clazz, jlong screenConfiguration) +{ + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + + short original_rate = XRRConfigCurrentRate(conf); + + Rotation original_rotation; + SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); + + DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); + return (jint)original_size_id; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: setCurrentScreenModeStart0 + * Signature: (JIJIII)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenModeStart0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) +{ + Display *dpy = (Display *) (intptr_t) display; + XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; + Window root = RootWindow(dpy, (int)screen_idx); + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions + int rot; + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + switch(rotation) { + case 0: + rot = RR_Rotate_0; + break; + case 90: + rot = RR_Rotate_90; + break; + case 180: + rot = RR_Rotate_180; + break; + case 270: + rot = RR_Rotate_270; + break; + default: + NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); + } + + DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", + resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); + + XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); + + XSync(dpy, False); + XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); + XSync(dpy, False); + + return JNI_TRUE; +} + +/* + * Class: jogamp_newt_driver_x11_RandR11 + * Method: setCurrentScreenModePollEnd0 + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenModePollEnd0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +{ + Display *dpy = (Display *) (intptr_t) display; + int randr_event_base, randr_error_base; + XEvent evt; + XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions + XRRScreenConfiguration *conf; + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); + + int done = 0; + int rot; + do { + if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { + return; + } + XNextEvent(dpy, &evt); + + switch (evt.type - randr_event_base) { + case RRScreenChangeNotify: + if(0 < scn_event->rotation ) { + rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, rot, + scn_event->width, scn_event->height); + // done = scn_event->size_index == resMode_idx; // not reliable .. + done = rot == rotation && + scn_event->width == xrrs[resMode_idx].width && + scn_event->height == xrrs[resMode_idx].height; + } else { + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, + scn_event->width, scn_event->height); + } + break; + default: + DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); + } + XRRUpdateConfiguration(&evt); + } while(!done); + + XSync(dpy, False); + +} + diff --git a/src/newt/native/X11RandR13.c b/src/newt/native/X11RandR13.c new file mode 100644 index 000000000..ea72cd35d --- /dev/null +++ b/src/newt/native/X11RandR13.c @@ -0,0 +1,408 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#include "X11Common.h" + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getScreenResources0 + * Signature: (JI)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenResources0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)screen_idx); +#ifdef DBG_PERF + struct timespec t0, t1, td; + long td_ms; + timespec_now(&t0); +#endif + +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenResources0.1: %ld ms\n", td_ms); fflush(NULL); +#endif + + XRRScreenResources *res = XRRGetScreenResourcesCurrent( dpy, root); +#ifdef DBG_PERF + timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); + fprintf(stderr, "X11Screen_getScreenResources0.2 (XRRScreenResources): %ld ms\n", td_ms); fflush(NULL); +#endif + + return (jlong) (intptr_t) res; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: freeScreenResources0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_freeScreenResources0 + (JNIEnv *env, jclass clazz, jlong screenResources) +{ + XRRFreeScreenResources( (XRRScreenResources *) (intptr_t) screenResources ); +} + +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getOrigin0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display * dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + int pos[] = { 0, 0 } ; + + int i; + XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); + fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); + for(i=0; incrtc; i++) { + RRCrtc crtc = xrrScreenResources->crtcs[i]; + XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); + fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); + XRRFreeCrtcInfo(xrrCrtcInfo); + } + + jintArray jpos = (*env)->NewIntArray(env, num_rotations); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 2); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, jpos, 0, 2, pos); + return jpos; +} + +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableScreenModeRotations0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + int num_rotations = 0; + Rotation cur_rotation, rotations_supported; + int rotations[4]; + int major, minor; + + rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); + + if(0 != (rotations_supported & RR_Rotate_0)) { + rotations[num_rotations++] = 0; + } + if(0 != (rotations_supported & RR_Rotate_90)) { + rotations[num_rotations++] = 90; + } + if(0 != (rotations_supported & RR_Rotate_180)) { + rotations[num_rotations++] = 180; + } + if(0 != (rotations_supported & RR_Rotate_270)) { + rotations[num_rotations++] = 270; + } + + jintArray properties = NULL; + + if(num_rotations>0) { + properties = (*env)->NewIntArray(env, num_rotations); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); + } + + return properties; +} + +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getNumScreenModeResolutions0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes); + + int i; + XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); + fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); + for(i=0; incrtc; i++) { + RRCrtc crtc = xrrScreenResources->crtcs[i]; + XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); + fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); + XRRFreeCrtcInfo(xrrCrtcInfo); + } + fprintf(stderr, "XRRScreenResources %p: XRRModeInfo modes %d\n", xrrScreenResources, xrrScreenResources->nmode); + for(i=0; inmode; i++) { + XRRModeInfo xrrModeInfo = xrrScreenResources->modes[i]; + fprintf(stderr, "XRRModeInfo %d: %dx%d, %s, %X\n", i, xrrModeInfo.width, xrrModeInfo.height, xrrModeInfo.name, xrrModeInfo.id); + } + XRRFreeScreenResources(xrrScreenResources); + + return num_sizes; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getScreenModeResolutions0 + * Signature: (JII)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenModeResolution0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + // Fill the properties in temp jint array + int propIndex = 0; + jint prop[4]; + + prop[propIndex++] = xrrs[(int)resMode_idx].width; + prop[propIndex++] = xrrs[(int)resMode_idx].height; + prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; + prop[propIndex++] = xrrs[(int)resMode_idx].mheight; + + jintArray properties = (*env)->NewIntArray(env, 4); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getScreenModeRates0 + * Signature: (JII)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenModeRates0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + int num_rates; + short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); + + jint prop[num_rates]; + int i; + for(i=0; iNewIntArray(env, num_rates); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); + } + + // move from the temp structure to the java structure + (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getCurrentScreenRate0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenRate0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + + // get current resolutions and frequencies + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); + short original_rate = XRRConfigCurrentRate(conf); + + //free + XRRFreeScreenConfigInfo(conf); + + DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); + + return (jint) original_rate; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getCurrentScreenRotation0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenRotation0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + + //get current resolutions and frequencies + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); + + Rotation rotation; + XRRConfigCurrentConfiguration(conf, &rotation); + + //free + XRRFreeScreenConfigInfo(conf); + + return NewtScreen_XRotation2Degree(env, rotation); +} + + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getCurrentScreenResolutionIndex0 + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenResolutionIndex0 + (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)scrn_idx); + + // get current resolutions and frequency configuration + XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); + short original_rate = XRRConfigCurrentRate(conf); + + Rotation original_rotation; + SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); + + //free + XRRFreeScreenConfigInfo(conf); + + DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); + return (jint)original_size_id; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: setCurrentScreenModeStart0 + * Signature: (JIIII)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setCurrentScreenModeStart0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +{ + Display *dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)screen_idx); + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions + XRRScreenConfiguration *conf; + int rot; + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + conf = XRRGetScreenInfo(dpy, root); + + rot = int NewtScreen_Degree2XRotation(env, rotation); + + DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", + resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); + + XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); + + XSync(dpy, False); + XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); + XSync(dpy, False); + + //free + XRRFreeScreenConfigInfo(conf); + XSync(dpy, False); + + return JNI_TRUE; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: setCurrentScreenModePollEnd0 + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setCurrentScreenModePollEnd0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +{ + Display *dpy = (Display *) (intptr_t) display; + int randr_event_base, randr_error_base; + XEvent evt; + XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; + + int num_sizes; + XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions + XRRScreenConfiguration *conf; + + if( 0 > resMode_idx || resMode_idx >= num_sizes ) { + NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + } + + XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); + + int done = 0; + int rot; + do { + if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { + return; + } + XNextEvent(dpy, &evt); + + switch (evt.type - randr_event_base) { + case RRScreenChangeNotify: + rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); + DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call %p (root %p) resIdx %d rot %d %dx%d\n", + (void*)scn_event->window, (void*)scn_event->root, + (int)scn_event->size_index, rot, + scn_event->width, scn_event->height); + // done = scn_event->size_index == resMode_idx; // not reliable .. + done = rot == rotation && + scn_event->width == xrrs[resMode_idx].width && + scn_event->height == xrrs[resMode_idx].height; + break; + default: + DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); + } + XRRUpdateConfiguration(&evt); + } while(!done); + + XSync(dpy, False); + +} + diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c index 69a06aad0..3d4b2a26c 100644 --- a/src/newt/native/X11Screen.c +++ b/src/newt/native/X11Screen.c @@ -74,24 +74,6 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getHeight0 return (jint) DisplayHeight( dpy, scrn_idx); } -static int showedRandRVersion = 0; - -Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor) { - if( 0 == XRRQueryVersion(dpy, major, minor) ) { - return False; - } - if(0 == showedRandRVersion) { - DBG_PRINT("X11 RandR Version %d.%d\n", *major, *minor); - showedRandRVersion = 1; - } - return True; -} - -Bool NewtScreen_hasRANDR(Display *dpy) { - int major, minor; - return NewtScreen_getRANDRVersion(dpy, &major, &minor); -} - int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { int rot; if(xrotation == RR_Rotate_0) { @@ -121,8 +103,7 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getRandRVer { Display * dpy = (Display *)(intptr_t)display; jint version[2]; - Bool res = NewtScreen_getRANDRVersion(dpy, &version[0], &version[1]); - if( False == res ) { + if( 0 == XRRQueryVersion(dpy, &version[0], &version[1] ) ) { version[0] = 0; version[1] = 0; } diff --git a/src/newt/native/X11Screen.h b/src/newt/native/X11Screen.h index a5b8e3e70..1a1440054 100644 --- a/src/newt/native/X11Screen.h +++ b/src/newt/native/X11Screen.h @@ -32,8 +32,6 @@ #include "X11Common.h" -Bool NewtScreen_getRANDRVersion(Display *dpy, int *major, int *minor); -Bool NewtScreen_hasRANDR(Display *dpy); int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation); #endif /* _X11SCREEN_H */ diff --git a/src/newt/native/X11ScreenRandR11.c b/src/newt/native/X11ScreenRandR11.c deleted file mode 100644 index a457fd47b..000000000 --- a/src/newt/native/X11ScreenRandR11.c +++ /dev/null @@ -1,415 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -#include "X11Screen.h" - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getAvailableScreenModeRotations0 - * Signature: (JI)I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getAvailableScreenModeRotations0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int num_rotations = 0; - Rotation cur_rotation, rotations_supported; - int rotations[4]; - int major, minor; - - if(False == NewtScreen_getRANDRVersion(dpy, &major, &minor)) { - fprintf(stderr, "RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); - - if(0 != (rotations_supported & RR_Rotate_0)) { - rotations[num_rotations++] = 0; - } - if(0 != (rotations_supported & RR_Rotate_90)) { - rotations[num_rotations++] = 90; - } - if(0 != (rotations_supported & RR_Rotate_180)) { - rotations[num_rotations++] = 180; - } - if(0 != (rotations_supported & RR_Rotate_270)) { - rotations[num_rotations++] = 270; - } - - jintArray properties = NULL; - - if(num_rotations>0) { - properties = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); - } - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getNumScreenModeResolution0 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getNumScreenModeResolutions0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getNumScreenModeResolutions0: RANDR not available\n"); - return 0; - } - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); -#endif - - DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); - - return num_sizes; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getScreenModeResolutions0 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeResolution0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeResolution0: RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - // Fill the properties in temp jint array - int propIndex = 0; - jint prop[4]; - - prop[propIndex++] = xrrs[(int)resMode_idx].width; - prop[propIndex++] = xrrs[(int)resMode_idx].height; - prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; - prop[propIndex++] = xrrs[(int)resMode_idx].mheight; - - jintArray properties = (*env)->NewIntArray(env, 4); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getScreenModeRates0 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeRates0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenModeRates0: RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - int num_rates; - short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); - - jint prop[num_rates]; - int i; - for(i=0; iNewIntArray(env, num_rates); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getScreenConfiguration0 - * Signature: (JI)J - */ -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenConfiguration0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)screen_idx); -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_getScreenConfiguration0: RANDR not available\n"); - return 0; - } -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - // get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL); -#endif - - return (jlong) (intptr_t) conf; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: freeScreenConfiguration0 - * Signature: (J)V - */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_freeScreenConfiguration0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration ); -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getCurrentScreenRate0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenRate0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - - short original_rate = XRRConfigCurrentRate(conf); - DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); - - return (jint) original_rate; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getCurrentScreenRotation0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenRotation0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - Rotation rotation; - - XRRConfigCurrentConfiguration(conf, &rotation); - - return NewtScreen_XRotation2Degree(env, rotation); -} - - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: getCurrentScreenResolutionIndex0 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_getCurrentScreenResolutionIndex0 - (JNIEnv *env, jclass clazz, jlong screenConfiguration) -{ - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - - short original_rate = XRRConfigCurrentRate(conf); - - Rotation original_rotation; - SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: setCurrentScreenModeStart0 - * Signature: (JIJIII)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModeStart0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration; - Window root = RootWindow(dpy, (int)screen_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - int rot; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - switch(rotation) { - case 0: - rot = RR_Rotate_0; - break; - case 90: - rot = RR_Rotate_90; - break; - case 180: - rot = RR_Rotate_180; - break; - case 270: - rot = RR_Rotate_270; - break; - default: - NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); - } - - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", - resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); - - XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); - - XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); - XSync(dpy, False); - - return JNI_TRUE; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenRandR11 - * Method: setCurrentScreenModePollEnd0 - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModePollEnd0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - int randr_event_base, randr_error_base; - XEvent evt; - XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; - - if(False == NewtScreen_hasRANDR(dpy)) { - DBG_PRINT("Java_jogamp_newt_driver_x11_ScreenRandR11_setCurrentScreenModePollEnd0: RANDR not available\n"); - return JNI_FALSE; - } - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); - - int done = 0; - int rot; - do { - if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { - return; - } - XNextEvent(dpy, &evt); - - switch (evt.type - randr_event_base) { - case RRScreenChangeNotify: - if(0 < scn_event->rotation ) { - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(1) %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; - } else { - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call(0) %p (root %p) resIdx %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, - scn_event->width, scn_event->height); - } - break; - default: - DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); - } - XRRUpdateConfiguration(&evt); - } while(!done); - - XSync(dpy, False); - -} - diff --git a/src/newt/native/X11ScreenRandR13.c b/src/newt/native/X11ScreenRandR13.c deleted file mode 100644 index da90d15c9..000000000 --- a/src/newt/native/X11ScreenRandR13.c +++ /dev/null @@ -1,372 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -#include "X11Common.h" - -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getOrigin0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display * dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int pos[] = { 0, 0 } ; - - int i; - XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); - fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); - for(i=0; incrtc; i++) { - RRCrtc crtc = xrrScreenResources->crtcs[i]; - XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); - fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); - XRRFreeCrtcInfo(xrrCrtcInfo); - } - - jintArray jpos = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 2); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, jpos, 0, 2, pos); - return jpos; -} - -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getAvailableScreenModeRotations0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int num_rotations = 0; - Rotation cur_rotation, rotations_supported; - int rotations[4]; - int major, minor; - - if(False == NewtScreen_getRANDRVersion(dpy, &major, &minor)) { - fprintf(stderr, "RANDR not available\n"); - return (*env)->NewIntArray(env, 0); - } - - rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); - - if(0 != (rotations_supported & RR_Rotate_0)) { - rotations[num_rotations++] = 0; - } - if(0 != (rotations_supported & RR_Rotate_90)) { - rotations[num_rotations++] = 90; - } - if(0 != (rotations_supported & RR_Rotate_180)) { - rotations[num_rotations++] = 180; - } - if(0 != (rotations_supported & RR_Rotate_270)) { - rotations[num_rotations++] = 270; - } - - jintArray properties = NULL; - - if(num_rotations>0) { - properties = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rotations); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rotations, rotations); - } - - return properties; -} - -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getNumScreenModeResolutions0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes); - - int i; - XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); - fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); - for(i=0; incrtc; i++) { - RRCrtc crtc = xrrScreenResources->crtcs[i]; - XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); - fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); - XRRFreeCrtcInfo(xrrCrtcInfo); - } - fprintf(stderr, "XRRScreenResources %p: XRRModeInfo modes %d\n", xrrScreenResources, xrrScreenResources->nmode); - for(i=0; inmode; i++) { - XRRModeInfo xrrModeInfo = xrrScreenResources->modes[i]; - fprintf(stderr, "XRRModeInfo %d: %dx%d, %s, %X\n", i, xrrModeInfo.width, xrrModeInfo.height, xrrModeInfo.name, xrrModeInfo.id); - } - XRRFreeScreenResources(xrrScreenResources); - - return num_sizes; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeResolutions0_RandR13 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeResolution0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - // Fill the properties in temp jint array - int propIndex = 0; - jint prop[4]; - - prop[propIndex++] = xrrs[(int)resMode_idx].width; - prop[propIndex++] = xrrs[(int)resMode_idx].height; - prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; - prop[propIndex++] = xrrs[(int)resMode_idx].mheight; - - jintArray properties = (*env)->NewIntArray(env, 4); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getScreenModeRates0_RandR13 - * Signature: (JII)[I - */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getScreenModeRates0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - int num_rates; - short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); - - jint prop[num_rates]; - int i; - for(i=0; iNewIntArray(env, num_rates); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); - } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); - - return properties; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRate0_RandR13 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRate0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - // get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); - - //free - XRRFreeScreenConfigInfo(conf); - - DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); - - return (jint) original_rate; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenRotation0_RandR13 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenRotation0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - //get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - - Rotation rotation; - XRRConfigCurrentConfiguration(conf, &rotation); - - //free - XRRFreeScreenConfigInfo(conf); - - return NewtScreen_XRotation2Degree(env, rotation); -} - - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: getCurrentScreenResolutionIndex0_RandR13 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getCurrentScreenResolutionIndex0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - // get current resolutions and frequency configuration - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); - - Rotation original_rotation; - SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - - //free - XRRFreeScreenConfigInfo(conf); - - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModeStart0_RandR13 - * Signature: (JIIII)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModeStart0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)screen_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - int rot; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - conf = XRRGetScreenInfo(dpy, root); - - rot = int NewtScreen_Degree2XRotation(env, rotation); - - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", - resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); - - XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); - - XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); - XSync(dpy, False); - - //free - XRRFreeScreenConfigInfo(conf); - XSync(dpy, False); - - return JNI_TRUE; -} - -/* - * Class: jogamp_newt_driver_x11_ScreenDriver - * Method: setCurrentScreenModePollEnd0_RandR13 - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_setCurrentScreenModePollEnd0_RandR13 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) -{ - Display *dpy = (Display *) (intptr_t) display; - int randr_event_base, randr_error_base; - XEvent evt; - XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); - } - - XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); - - int done = 0; - int rot; - do { - if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { - return; - } - XNextEvent(dpy, &evt); - - switch (evt.type - randr_event_base) { - case RRScreenChangeNotify: - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; - break; - default: - DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); - } - XRRUpdateConfiguration(&evt); - } while(!done); - - XSync(dpy, False); - -} - -- cgit v1.2.3 From 0f7412855c118cb501d8a001df7a7487354b5029 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 23 Apr 2013 07:53:31 +0200 Subject: Fix Bug 722: Make GLEventListenerState 'transaction' safe Animator.pause[ surface.lock[ modify ] ] GLEventListenerState: New model for GLEventListenerState's transaction safety: - Z Decorate-1: Animator.pause [ X ] Animator.resume - X Decorate-2: Surface.lock [ Y ] Surface.unlock - Instead of setting AbstractGraphicsDevice, just swap the handle and ownership. - Issuing setRealized(..) only if required, i.e. having an upstream-surface (EGL..) depending on used device - Utilizing setRealized(..) on the GLAD's delegated 'real' drawable, avoiding optional GLAD locking. - Cleanup and above changes shall render impl. easier to read. GLEventListenerState Unit Tests: - If swapping/moving from AWT -> NEWT, use a NEWT dedicated Display avoiding ATI driver XCB crash - read comment. --- make/build-test.xml | 1 + make/scripts/tests.sh | 8 +- .../com/jogamp/opengl/GLEventListenerState.java | 332 ++++++++++++--------- .../jogamp/nativewindow/egl/EGLGraphicsDevice.java | 11 +- .../jogamp/nativewindow/x11/X11GraphicsDevice.java | 10 + .../media/nativewindow/DefaultGraphicsDevice.java | 40 ++- .../acore/glels/GLContextDrawableSwitchBase.java | 37 ++- .../TestBug722GLContextDrawableSwitchNewt2AWT.java | 143 +++++++++ .../TestGLContextDrawableSwitch11NewtAWT.java | 16 +- .../glels/TestGLContextDrawableSwitch12AWT.java | 16 +- .../TestGLContextDrawableSwitch21Newt2AWT.java | 61 ++-- 11 files changed, 485 insertions(+), 190 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java (limited to 'make/scripts') diff --git a/make/build-test.xml b/make/build-test.xml index 3d9c31d83..e00348c38 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -437,6 +437,7 @@ + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 75e5f7fd6..65e070a99 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -115,6 +115,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLDrawable" + #D_ARGS="-Djogl.debug.GLEventListenerState" #D_ARGS="-Djogl.fbo.force.none" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Djogl.debug=all" @@ -362,8 +363,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* -##testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestBug722GLContextDrawableSwitchNewt2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT @@ -379,7 +381,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT diff --git a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java index 2914a1bf9..21dafecb1 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java +++ b/src/jogl/classes/com/jogamp/opengl/GLEventListenerState.java @@ -32,11 +32,9 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; -import javax.media.nativewindow.AbstractGraphicsScreen; +import javax.media.nativewindow.DefaultGraphicsDevice; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.ProxySurface; -import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilitiesImmutable; @@ -57,8 +55,8 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; *
  • {@link GLContext}
  • *
  • All {@link GLEventListener}, incl. their init state
  • *
  • {@link GLAnimatorControl}
  • - *
  • {@link GLCapabilitiesImmutable} for compatibility check
  • - *
  • {@link AbstractGraphicsScreen} for compatibility check and preserving the {@link AbstractGraphicsDevice}
  • + * + *
  • {@link AbstractGraphicsDevice} for compatibility check and preserving the native device handle incl. ownership
  • * *

    * A GLEventListenerState instance can be created while components are {@link #moveFrom(GLAutoDrawable) moved from} a {@link GLAutoDrawable} @@ -68,16 +66,16 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; * A GLEventListenerState instance's components can be {@link #moveTo(GLAutoDrawable) moved to} a {@link GLAutoDrawable}, * while loosing {@link #isOwner() ownership} of the moved components. *

    - *

    */ public class GLEventListenerState { - private static final boolean DEBUG = Debug.debug("GLDrawable"); + private static final boolean DEBUG = Debug.debug("GLDrawable") || Debug.debug("GLEventListenerState"); - private GLEventListenerState(AbstractGraphicsScreen upstreamScreen, boolean proxyOwnsUpstreamDevice, AbstractGraphicsScreen screen, GLCapabilitiesImmutable caps, + private GLEventListenerState(AbstractGraphicsDevice upstreamDevice, boolean proxyOwnsUpstreamDevice, AbstractGraphicsDevice device, + GLCapabilitiesImmutable caps, GLContext context, int count, GLAnimatorControl anim, boolean animStarted) { - this.upstreamScreen = upstreamScreen; + this.upstreamDevice = upstreamDevice; this.proxyOwnsUpstreamDevice = proxyOwnsUpstreamDevice; - this.screen = screen; + this.device = device; this.caps = caps; this.context = context; this.listeners = new GLEventListener[count]; @@ -99,9 +97,9 @@ public class GLEventListenerState { public final int listenerCount() { return listeners.length; } - public final AbstractGraphicsScreen upstreamScreen; + public final AbstractGraphicsDevice upstreamDevice; public final boolean proxyOwnsUpstreamDevice; - public final AbstractGraphicsScreen screen; + public final AbstractGraphicsDevice device; public final GLCapabilitiesImmutable caps; public final GLContext context; public final GLEventListener[] listeners; @@ -121,14 +119,13 @@ public class GLEventListenerState { listeners[i] = null; } // context.destroy(); - NPE (null drawable) - screen.getDevice().close(); + device.close(); owner = false; } } - private static AbstractGraphicsScreen cloneScreen(AbstractGraphicsScreen aScreen) { - final AbstractGraphicsDevice aDevice2 = (AbstractGraphicsDevice) aScreen.getDevice().clone(); - return NativeWindowFactory.createScreen( aDevice2, aScreen.getIndex() ); + private static AbstractGraphicsDevice cloneDevice(AbstractGraphicsDevice aDevice) { + return (AbstractGraphicsDevice) aDevice.clone(); } /** @@ -152,51 +149,6 @@ public class GLEventListenerState { * @see #moveTo(GLAutoDrawable) */ public static GLEventListenerState moveFrom(GLAutoDrawable a) { - final int aSz = a.getGLEventListenerCount(); - - // Create new AbstractGraphicsScreen w/ cloned AbstractGraphicsDevice for future GLAutoDrawable - // allowing this AbstractGraphicsDevice to loose ownership -> not closing display/device! - final NativeSurface aSurface = a.getNativeSurface(); - final AbstractGraphicsConfiguration aCfg = aSurface.getGraphicsConfiguration(); - final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); - final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); - final AbstractGraphicsScreen aScreen2 = cloneScreen(aScreen1); - aScreen1.getDevice().clearHandleOwner(); // don't close device handle - if( DEBUG ) { - System.err.println("GLEventListenerState.moveFrom.0a: orig 0x"+Integer.toHexString(aScreen1.getDevice().hashCode())+", "+aScreen1.getDevice()); - System.err.println("GLEventListenerState.moveFrom.0b: pres 0x"+Integer.toHexString(aScreen2.getDevice().hashCode())+", "+aScreen2.getDevice()); - System.err.println("GLEventListenerState.moveFrom.1: "+aSurface.getClass().getName()+", "+aSurface); - } - final AbstractGraphicsScreen aUpScreen2; - final boolean proxyOwnsUpstreamDevice; - { - AbstractGraphicsScreen _aUpScreen2=null; - if(aSurface instanceof ProxySurface) { - final ProxySurface aProxy = (ProxySurface)aSurface; - proxyOwnsUpstreamDevice = aProxy.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); - final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); - if(DEBUG && null != aUpSurface) { - System.err.println("GLEventListenerState.moveFrom.2: "+aUpSurface.getClass().getName()+", "+aUpSurface); - } - if(null != aUpSurface) { - final AbstractGraphicsScreen aUpScreen1 = aUpSurface.getGraphicsConfiguration().getScreen(); - _aUpScreen2 = cloneScreen(aUpScreen1); - if(null != aUpScreen1) { - aUpScreen1.getDevice().clearHandleOwner(); // don't close device handle - } - if(DEBUG) { - System.err.println("GLEventListenerState.moveFrom.3a: up-orig 0x"+Integer.toHexString(aUpScreen1.getDevice().hashCode())+", "+aUpScreen1.getDevice()); - System.err.println("GLEventListenerState.moveFrom.3b: up-pres 0x"+Integer.toHexString(_aUpScreen2.getDevice().hashCode())+", "+_aUpScreen2.getDevice()); - System.err.println("GLEventListenerState.moveFrom.3c: "+aSurface.getClass().getName()+", "+aSurface); - System.err.println("GLEventListenerState.moveFrom.3d: "+aUpSurface.getClass().getName()+", "+aUpSurface); - } - } - } else { - proxyOwnsUpstreamDevice = false; - } - aUpScreen2=_aUpScreen2; - } - final GLAnimatorControl aAnim = a.getAnimator(); final boolean aAnimStarted; if( null != aAnim ) { @@ -206,23 +158,75 @@ public class GLEventListenerState { aAnimStarted = false; } - final GLEventListenerState glls = new GLEventListenerState(aUpScreen2, proxyOwnsUpstreamDevice, aScreen2, caps, a.getContext(), aSz, aAnim, aAnimStarted); - - // - // remove and cache all GLEventListener and their init-state - // - for(int i=0; i not closing display/device! + final AbstractGraphicsConfiguration aCfg = aSurface.getGraphicsConfiguration(); + final GLCapabilitiesImmutable caps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); + final AbstractGraphicsDevice aDevice1 = aCfg.getScreen().getDevice(); + final AbstractGraphicsDevice aDevice2 = cloneDevice(aDevice1); + aDevice1.clearHandleOwner(); // don't close device handle + if( DEBUG ) { + System.err.println("GLEventListenerState.moveFrom.0a: orig 0x"+Integer.toHexString(aDevice1.hashCode())+", "+aDevice1); + System.err.println("GLEventListenerState.moveFrom.0b: pres 0x"+Integer.toHexString(aDevice2.hashCode())+", "+aDevice2); + System.err.println("GLEventListenerState.moveFrom.1: "+aSurface.getClass().getName()/*+", "+aSurface*/); + } + final AbstractGraphicsDevice aUpDevice2; + final boolean proxyOwnsUpstreamDevice; + { + AbstractGraphicsDevice _aUpDevice2 = null; + if(aSurface instanceof ProxySurface) { + final ProxySurface aProxy = (ProxySurface)aSurface; + proxyOwnsUpstreamDevice = aProxy.containsUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); + if(DEBUG && null != aUpSurface) { + System.err.println("GLEventListenerState.moveFrom.2: "+aUpSurface.getClass().getName()+", "+aUpSurface); + } + if(null != aUpSurface) { + final AbstractGraphicsDevice aUpDevice1 = aUpSurface.getGraphicsConfiguration().getScreen().getDevice(); + _aUpDevice2 = cloneDevice(aUpDevice1); + aUpDevice1.clearHandleOwner(); // don't close device handle + if(DEBUG) { + System.err.println("GLEventListenerState.moveFrom.3a: up-orig 0x"+Integer.toHexString(aUpDevice1.hashCode())+", "+aUpDevice1); + System.err.println("GLEventListenerState.moveFrom.3b: up-pres 0x"+Integer.toHexString(_aUpDevice2.hashCode())+", "+_aUpDevice2); + System.err.println("GLEventListenerState.moveFrom.3c: "+aSurface.getClass().getName()+", "+aSurface); + System.err.println("GLEventListenerState.moveFrom.3d: "+aUpSurface.getClass().getName()/*+", "+aUpSurface+", "*/+aProxy.getUpstreamOptionBits(null).toString()); + } + } + } else { + proxyOwnsUpstreamDevice = false; + } + aUpDevice2 = _aUpDevice2; + } + + glls = new GLEventListenerState(aUpDevice2, proxyOwnsUpstreamDevice, aDevice2, caps, a.getContext(), aSz, aAnim, aAnimStarted); + + // + // remove and cache all GLEventListener and their init-state + // + for(int i=0; i + * @throws GLException if this preserved {@link AbstractGraphicsDevice} is incompatible w/ the given destination one. * * @see #moveFrom(GLAutoDrawable) * @see #isOwner() */ public final void moveTo(GLAutoDrawable a) { + final GLAnimatorControl aAnim = a.getAnimator(); + final boolean hasAnimator = null != aAnim; + final boolean aPaused; + if( hasAnimator ) { + aPaused = aAnim.pause(); + aAnim.remove(a); // also handles ECT + if( aPaused ) { + aAnim.resume(); + } + } else { + aPaused = false; + } + final List aGLCmds = new ArrayList(); final int aSz = listenerCount(); final NativeSurface aSurface = a.getNativeSurface(); - final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) aSurface.getGraphicsConfiguration(); - final GLCapabilitiesImmutable aCaps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); - if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) || - caps.getVisualID(VisualIDHolder.VIDType.NATIVE) != aCaps.getVisualID(VisualIDHolder.VIDType.NATIVE) ) { - throw new GLException("Incompatible Capabilities - Prev-Holder: "+caps+", New-Holder "+caps); - } - // Destroy and remove currently associated GLContext, if any (will be replaced) - a.setContext( null, true ); - final boolean aRealized = a.isRealized(); - if( aRealized ) { - a.setRealized(false); - } - // Set new Screen and close previous one - { - final AbstractGraphicsScreen aScreen1 = aCfg.getScreen(); - if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.0a: orig 0x"+Integer.toHexString(aScreen1.getDevice().hashCode())+", "+aScreen1.getDevice()); - System.err.println("GLEventListenerState.moveTo.0b: pres 0x"+Integer.toHexString(screen.getDevice().hashCode())+", "+screen.getDevice()); + final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface(); + final boolean aRealized; + try { + + final MutableGraphicsConfiguration aCfg = (MutableGraphicsConfiguration) aSurface.getGraphicsConfiguration(); + /** + final GLCapabilitiesImmutable aCaps = (GLCapabilitiesImmutable) aCfg.getChosenCapabilities(); + if( caps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) != aCaps.getVisualID(VisualIDHolder.VIDType.INTRINSIC) || + caps.getVisualID(VisualIDHolder.VIDType.NATIVE) != aCaps.getVisualID(VisualIDHolder.VIDType.NATIVE) ) { + throw new GLException("Incompatible Capabilities - Prev-Holder: "+caps+", New-Holder "+caps); + } */ + final DefaultGraphicsDevice aDevice1 = (DefaultGraphicsDevice) aCfg.getScreen().getDevice(); + final DefaultGraphicsDevice aDevice2 = (DefaultGraphicsDevice) device; + if( !aDevice1.getUniqueID().equals( aDevice2.getUniqueID() ) ) { + throw new GLException("Incompatible devices: Preserved <"+aDevice2.getUniqueID()+">, target <"+aDevice1.getUniqueID()+">"); + } + + // collect optional upstream surface info + final ProxySurface aProxy; + final NativeSurface aUpSurface; + if(aSurface instanceof ProxySurface) { + aProxy = (ProxySurface)aSurface; + aUpSurface = aProxy.getUpstreamSurface(); + } else { + aProxy = null; + aUpSurface = null; } - aCfg.setScreen( screen ); - aScreen1.getDevice().close(); if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.1a: orig 0x"+Integer.toHexString(aScreen1.getDevice().hashCode())+", "+aScreen1.getDevice()); - System.err.println("GLEventListenerState.moveTo.1b: pres 0x"+Integer.toHexString(screen.getDevice().hashCode())+", "+screen.getDevice()); + System.err.println("GLEventListenerState.moveTo.0 : has aProxy "+(null!=aProxy)); + System.err.println("GLEventListenerState.moveTo.0 : has aUpSurface "+(null!=aUpSurface)); } - } - - // If using a ProxySurface w/ an upstream surface, set new Screen and close previous one on it - { - boolean upstreamSet = false; - if(aSurface instanceof ProxySurface) { - final ProxySurface aProxy = (ProxySurface)aSurface; - final NativeSurface aUpSurface = aProxy.getUpstreamSurface(); - if(null != aUpSurface) { - final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration(); - if( null != upstreamScreen ) { - final AbstractGraphicsScreen aUpScreen1 = aUpCfg.getScreen(); - if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.2a: up-orig 0x"+Integer.toHexString(aUpScreen1.getDevice().hashCode())+", "+aUpScreen1.getDevice()); - System.err.println("GLEventListenerState.moveTo.2b: up-pres 0x"+Integer.toHexString(upstreamScreen.getDevice().hashCode())+", "+upstreamScreen.getDevice()); - System.err.println("GLEventListenerState.moveTo.2c: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); - } - aUpScreen1.getDevice().close(); - aUpCfg.setScreen( upstreamScreen ); - if( proxyOwnsUpstreamDevice ) { - aProxy.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); - } - upstreamSet = true; - if( DEBUG ) { - System.err.println("GLEventListenerState.moveTo.3a: up-orig 0x"+Integer.toHexString(aUpScreen1.getDevice().hashCode())+", "+aUpScreen1.getDevice()); - System.err.println("GLEventListenerState.moveTo.3b: up-pres 0x"+Integer.toHexString(upstreamScreen.getDevice().hashCode())+", "+upstreamScreen.getDevice()); - System.err.println("GLEventListenerState.moveTo.3c: "+aUpSurface.getClass().getName()+", "+aUpSurface+", "+aProxy.getUpstreamOptionBits(null).toString()); - } - } else { - throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true"); + if( null==aUpSurface && null != upstreamDevice ) { + throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = true, New-Holder = false"); + } + + // Destroy and remove currently associated GLContext, if any (will be replaced) + a.setContext( null, true ); + aRealized = a.isRealized(); + if( aRealized && null != aUpSurface ) { + // Unrealize due to device dependencies of an upstream surface, e.g. EGLUpstreamSurfaceHook + a.getDelegatedDrawable().setRealized(false); + } + + // Set new Screen and close previous one + { + if( DEBUG ) { + System.err.println("GLEventListenerState.moveTo.0a: orig 0x"+Integer.toHexString(aDevice1.hashCode())+", "+aDevice1); + System.err.println("GLEventListenerState.moveTo.0b: pres 0x"+Integer.toHexString(aDevice2.hashCode())+", "+aDevice2); + } + DefaultGraphicsDevice.swapDeviceHandleAndOwnership(aDevice1, aDevice2); + aDevice2.close(); + if( DEBUG ) { + System.err.println("GLEventListenerState.moveTo.1a: orig 0x"+Integer.toHexString(aDevice1.hashCode())+", "+aDevice1); + System.err.println("GLEventListenerState.moveTo.1b: pres 0x"+Integer.toHexString(aDevice2.hashCode())+", "+aDevice2); + } + } + + // If using a ProxySurface w/ an upstream surface, set new Screen and close previous one on it + if( null != aUpSurface ) { + final MutableGraphicsConfiguration aUpCfg = (MutableGraphicsConfiguration) aUpSurface.getGraphicsConfiguration(); + if( null != upstreamDevice ) { + final DefaultGraphicsDevice aUpDevice1 = (DefaultGraphicsDevice) aUpCfg.getScreen().getDevice(); + final DefaultGraphicsDevice aUpDevice2 = (DefaultGraphicsDevice)upstreamDevice; + if( !aUpDevice1.getUniqueID().equals( aUpDevice2.getUniqueID() ) ) { + throw new GLException("Incompatible updtream devices: Preserved <"+aUpDevice2.getUniqueID()+">, target <"+aUpDevice1.getUniqueID()+">"); + } + if( DEBUG ) { + System.err.println("GLEventListenerState.moveTo.2a: up-orig 0x"+Integer.toHexString(aUpDevice1.hashCode())+", "+aUpDevice1); + System.err.println("GLEventListenerState.moveTo.2b: up-pres 0x"+Integer.toHexString(aUpDevice2.hashCode())+", "+aUpDevice2); + System.err.println("GLEventListenerState.moveTo.2c: "+aUpSurface.getClass().getName()/*+", "+aUpSurface+", "*/+aProxy.getUpstreamOptionBits(null).toString()); + } + DefaultGraphicsDevice.swapDeviceHandleAndOwnership(aUpDevice1, aUpDevice2); + aUpDevice2.close(); + if( proxyOwnsUpstreamDevice ) { + aProxy.addUpstreamOptionBits( ProxySurface.OPT_PROXY_OWNS_UPSTREAM_DEVICE ); + } + if( DEBUG ) { + System.err.println("GLEventListenerState.moveTo.3a: up-orig 0x"+Integer.toHexString(aUpDevice1.hashCode())+", "+aUpDevice1); + System.err.println("GLEventListenerState.moveTo.3b: up-pres 0x"+Integer.toHexString(aUpDevice2.hashCode())+", "+aUpDevice2); + System.err.println("GLEventListenerState.moveTo.3c: "+aUpSurface.getClass().getName()/*+", "+aUpSurface+", "*/+aProxy.getUpstreamOptionBits(null).toString()); } + } else { + throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = false, New-Holder = true"); } } - if( !upstreamSet && null != upstreamScreen ) { - throw new GLException("Incompatible Surface config - Has Upstream-Surface: Prev-Holder = true, New-Holder = false"); + + if( aRealized && null != aUpSurface ) { + a.getDelegatedDrawable().setRealized(true); + } + if( DEBUG ) { + System.err.println("GLEventListenerState.moveTo.X : has aProxy "+(null!=aProxy)); + System.err.println("GLEventListenerState.moveTo.X : has aUpSurface "+(null!=aUpSurface)); } - } - - if( aRealized ) { - a.setRealized(true); - } - final boolean surfaceLocked = false; // NativeSurface.LOCK_SURFACE_NOT_READY < aSurface.lockSurface(); - try { a.setContext( context, false ); } finally { if( surfaceLocked ) { @@ -347,7 +390,14 @@ public class GLEventListenerState { listeners[i] = null; } - if( null != anim && null == a.getAnimator() ) { + if( hasAnimator ) { + // prefer already bound animator + aAnim.add(a); + if( aPaused ) { + aAnim.resume(); + } + } else if ( null != anim ) { + // use previously bound animator anim.add(a); // also handles ECT if(animStarted) { anim.start(); diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java index 63200b393..fb6d39b2f 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/egl/EGLGraphicsDevice.java @@ -120,6 +120,15 @@ public class EGLGraphicsDevice extends DefaultGraphicsDevice implements Cloneabl public void clearHandleOwner() { eglLifecycleCallback = null; } - + @Override + protected Object getHandleOwnership() { + return eglLifecycleCallback; + } + @Override + protected Object setHandleOwnership(Object newOwnership) { + final EGLDisplayLifecycleCallback oldOwnership = eglLifecycleCallback; + eglLifecycleCallback = (EGLDisplayLifecycleCallback) newOwnership; + return oldOwnership; + } } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java index da3b31de4..e630e012e 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/x11/X11GraphicsDevice.java @@ -162,4 +162,14 @@ public class X11GraphicsDevice extends DefaultGraphicsDevice implements Cloneabl public void clearHandleOwner() { handleOwner = false; } + @Override + protected Object getHandleOwnership() { + return Boolean.valueOf(handleOwner); + } + @Override + protected Object setHandleOwnership(Object newOwnership) { + final Boolean oldOwnership = Boolean.valueOf(handleOwner); + handleOwner = ((Boolean) newOwnership).booleanValue(); + return oldOwnership; + } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index b3ae4628c..66b81d7fa 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -184,6 +184,42 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice return getClass().getSimpleName()+"[type "+getType()+", connection "+getConnection()+", unitID "+getUnitID()+", handle 0x"+Long.toHexString(getHandle())+", owner "+isHandleOwner()+", "+toolkitLock+"]"; } + /** + * Set the native handle of the underlying native device + * and return the previous one. + */ + protected final long setHandle(long newHandle) { + final long oldHandle = handle; + handle = newHandle; + return oldHandle; + } + + protected Object getHandleOwnership() { + return null; + } + protected Object setHandleOwnership(Object newOwnership) { + return null; + } + + public static final void swapDeviceHandleAndOwnership(final DefaultGraphicsDevice aDevice1, final DefaultGraphicsDevice aDevice2) { + aDevice1.lock(); + try { + aDevice2.lock(); + try { + final long aDevice1Handle = aDevice1.getHandle(); + final long aDevice2Handle = aDevice2.setHandle(aDevice1Handle); + aDevice1.setHandle(aDevice2Handle); + final Object aOwnership1 = aDevice1.getHandleOwnership(); + final Object aOwnership2 = aDevice2.setHandleOwnership(aOwnership1); + aDevice1.setHandleOwnership(aOwnership2); + } finally { + aDevice2.unlock(); + } + } finally { + aDevice1.unlock(); + } + } + /** * Set the internal ToolkitLock, which is used within the * {@link #lock()} and {@link #unlock()} implementation. @@ -194,8 +230,9 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice *

    * * @param locker the ToolkitLock, if null, {@link jogamp.nativewindow.NullToolkitLock} is being used + * @return the previous ToolkitLock instance */ - protected void setToolkitLock(ToolkitLock locker) { + protected ToolkitLock setToolkitLock(ToolkitLock locker) { final ToolkitLock _toolkitLock = toolkitLock; _toolkitLock.lock(); try { @@ -203,6 +240,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice } finally { _toolkitLock.unlock(); } + return _toolkitLock; } /** diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java index 300b4ec85..905cbcf25 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/GLContextDrawableSwitchBase.java @@ -42,6 +42,7 @@ import javax.media.opengl.awt.GLCanvas; import jogamp.nativewindow.jawt.JAWTUtil; +import com.jogamp.newt.Screen; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.GLEventListenerState; @@ -150,11 +151,12 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { return true; } - protected void testGLADOneLifecycle(GLCapabilities caps, GLADType gladType, int width, int height, - GLEventListenerCounter glelTracker, SnapshotGLEventListener snapshotGLEventListener, - GLEventListenerState glelsIn, GLEventListenerState glelsOut[], GLAnimatorControl animator) + protected void testGLADOneLifecycle(Screen screen, GLCapabilities caps, GLADType gladType, int width, + int height, GLEventListenerCounter glelTracker, + SnapshotGLEventListener snapshotGLEventListener, final GLEventListenerState glelsIn, final GLEventListenerState glelsOut[], GLAnimatorControl animator) throws InterruptedException { + System.err.println("GLAD Lifecycle.0 "+gladType+", restoring "+((null!=glelsIn)?true:false)+", preserving "+((null!=glelsOut)?true:false)); final Frame frame; final GLAutoDrawable glad; if( GLADType.GLCanvasOnscreen == gladType ) { @@ -179,7 +181,11 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } else if( GLADType.GLWindow == gladType ) { frame = null; - glad = GLWindow.create(caps); + if( null != screen ) { + glad = GLWindow.create(screen, caps); + } else { + glad = GLWindow.create(caps); + } ((GLWindow)glad).setTitle("Newt GLWindow"); ((GLWindow)glad).setSize(width, height); } else if( GLADType.GLOffscreen == gladType ) { @@ -212,7 +218,9 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { if( null != glelsIn ) { Assert.assertEquals(0, glad.getGLEventListenerCount()); - glelsIn.moveTo(glad); + System.err.println(".. restoring.0"); + glelsIn.moveTo(glad); + System.err.println(".. restoring.X"); Assert.assertEquals(1, glelTracker.initCount); Assert.assertTrue(1 <= glelTracker.reshapeCount); @@ -227,6 +235,12 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { Assert.assertEquals(false, glelsIn.isOwner()); } + for (int wait=0; wait glelTracker.initCount || 1 > glelTracker.reshapeCount || 1 > glelTracker.displayCount ); + wait++) { + Thread.sleep(AWTRobotUtil.TIME_SLICE); + } + final long t0 = System.currentTimeMillis(); long t1 = t0; @@ -242,17 +256,17 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { if( null != glelsOut ) { final GLContext context1 = glad.getContext(); - final GLEventListenerState _gllsOut = GLEventListenerState.moveFrom(glad); + System.err.println(".. preserving.0"); + glelsOut[0] = GLEventListenerState.moveFrom(glad); + System.err.println(".. preserving.X"); - Assert.assertEquals(context1, _gllsOut.context); + Assert.assertEquals(context1, glelsOut[0].context); Assert.assertNull(context1.getGLReadDrawable()); Assert.assertNull(context1.getGLDrawable()); - Assert.assertEquals(3, _gllsOut.listenerCount()); - Assert.assertEquals(true, _gllsOut.isOwner()); + Assert.assertEquals(3, glelsOut[0].listenerCount()); + Assert.assertEquals(true, glelsOut[0].isOwner()); Assert.assertEquals(null, glad.getContext()); Assert.assertEquals(0, glad.getGLEventListenerCount()); - - glelsOut[0] = _gllsOut; } if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) { destroyFrame(frame); @@ -272,5 +286,6 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } else { Assert.assertEquals(1, glelTracker.disposeCount); } + System.err.println("GLAD Lifecycle.X "+gladType); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java new file mode 100644 index 000000000..a11978784 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestBug722GLContextDrawableSwitchNewt2AWT.java @@ -0,0 +1,143 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore.glels; + +import java.io.IOException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + + +import com.jogamp.newt.Display; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.opengl.GLEventListenerState; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.GLRendererQuirks; +import com.jogamp.opengl.test.junit.util.GLEventListenerCounter; +import com.jogamp.opengl.test.junit.util.MiscUtils; + +import org.junit.Test; + +/** + * Tests Bug 722 + *

    + * See Bug 722 - https://jogamp.org/bugzilla/show_bug.cgi?id=722. + *

    + */ +public class TestBug722GLContextDrawableSwitchNewt2AWT extends GLContextDrawableSwitchBase { + + static int loops = 10; + static long duration2 = 100; // ms + + /** + * Interesting artifact w/ ATI proprietary driver is that the + * bug causing the quirk {@link GLRendererQuirks#DontCloseX11Display} + * also causes an XCB crash when reusing the X11 display connection + * from AWT -> NEWT. Pre-allocating the X11 Display and keeping it referenced + * to avoid such re-usage worksaround this problem. + */ + public static boolean fixedNewtDisplay = true; + + @Test(timeout=3000000) + public void test11GLWindow2GLCanvasOnScrnGL2ES2() throws InterruptedException { + final GLCapabilities caps = getCaps(GLProfile.GL2ES2); + if(null == caps) return; + + GLADType gladType1 = GLADType.GLWindow; + GLADType gladType2 = GLADType.GLCanvasOnscreen; + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + final Animator animator = new Animator(); + animator.start(); + + final Display dpy; + final Screen screen; + if( fixedNewtDisplay ) { + dpy = NewtFactory.createDisplay(null); + screen = NewtFactory.createScreen(dpy, 0); + screen.addReference(); + } else { + dpy = null; + screen = null; + } + + duration = duration2; + + for(int i=0; i * See Bug 665 - https://jogamp.org/bugzilla/show_bug.cgi?id=665. *

    + *

    + * Interesting artifact w/ ATI proprietary driver is that the + * bug causing the quirk {@link GLRendererQuirks#DontCloseX11Display} + * also causes an XCB crash when reusing the X11 display connection + * from AWT -> NEWT. Pre-allocating the X11 Display and keeping it referenced + * to avoid such re-usage worksaround this problem. + *

    */ public class TestGLContextDrawableSwitch21Newt2AWT extends GLContextDrawableSwitchBase { @@ -65,59 +76,75 @@ public class TestGLContextDrawableSwitch21Newt2AWT extends GLContextDrawableSwit public void test01GLCanvasOnScrn2GLWindowGL2ES2() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); if(null == reqGLCaps) return; - testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLCanvasOnscreen, GLADType.GLWindow); + testGLCanvas2GLWindowImpl(null, reqGLCaps, GLADType.GLCanvasOnscreen, GLADType.GLWindow); } @Test(timeout=30000) public void test02GLCanvasOnScrn2GLWindowGLES2() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; - testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLCanvasOnscreen, GLADType.GLWindow); + testGLCanvas2GLWindowImpl(null, reqGLCaps, GLADType.GLCanvasOnscreen, GLADType.GLWindow); } @Test(timeout=30000) public void test11GLWindow2GLCanvasOnScrnGL2ES2() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); if(null == reqGLCaps) return; - testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOnscreen); + final Display dpy = NewtFactory.createDisplay(null); + final Screen screen = NewtFactory.createScreen(dpy, 0); + screen.addReference(); + testGLCanvas2GLWindowImpl(screen, reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOnscreen); + screen.removeReference(); } @Test(timeout=30000) public void test12GLWindow2GLCanvasOnScrnGLES2() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; - testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOnscreen); + final Display dpy = NewtFactory.createDisplay(null); + final Screen screen = NewtFactory.createScreen(dpy, 0); + screen.addReference(); + testGLCanvas2GLWindowImpl(screen, reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOnscreen); + screen.removeReference(); } @Test(timeout=30000) public void test21GLCanvasOffScrn2GLWindowGL2ES2() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); if(null == reqGLCaps) return; - testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLCanvasOffscreen, GLADType.GLWindow); + testGLCanvas2GLWindowImpl(null, reqGLCaps, GLADType.GLCanvasOffscreen, GLADType.GLWindow); } @Test(timeout=30000) public void test22GLCanvasOffScrn2GLWindowGLES2() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; - testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLCanvasOffscreen, GLADType.GLWindow); + testGLCanvas2GLWindowImpl(null, reqGLCaps, GLADType.GLCanvasOffscreen, GLADType.GLWindow); } @Test(timeout=30000) public void test31GLWindow2GLCanvasOffScrnGL2ES2() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); if(null == reqGLCaps) return; - testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOffscreen); + final Display dpy = NewtFactory.createDisplay(null); + final Screen screen = NewtFactory.createScreen(dpy, 0); + screen.addReference(); + testGLCanvas2GLWindowImpl(screen, reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOffscreen); + screen.removeReference(); } @Test(timeout=30000) public void test32GLWindow2GLCanvasOffScrnGLES2() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); if(null == reqGLCaps) return; - testGLCanvas2GLWindowImpl(reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOffscreen); + final Display dpy = NewtFactory.createDisplay(null); + final Screen screen = NewtFactory.createScreen(dpy, 0); + screen.addReference(); + testGLCanvas2GLWindowImpl(screen, reqGLCaps, GLADType.GLWindow, GLADType.GLCanvasOffscreen); + screen.removeReference(); } - private void testGLCanvas2GLWindowImpl(GLCapabilities caps, GLADType gladType1, GLADType gladType2) throws InterruptedException { + private void testGLCanvas2GLWindowImpl(Screen screen, GLCapabilities caps, GLADType gladType1, GLADType gladType2) throws InterruptedException { if( !validateOnOffscreenLayer(gladType1, gladType2) ) { return; } @@ -131,18 +158,18 @@ public class TestGLContextDrawableSwitch21Newt2AWT extends GLContextDrawableSwit // - create glad1 w/o context // - create context using glad1 and assign it to glad1 { - testGLADOneLifecycle(caps, gladType1, width, height, - glelTracker, snapshotGLEventListener, - null, - glels, animator); + testGLADOneLifecycle(screen, caps, gladType1, width, + height, glelTracker, + snapshotGLEventListener, + null, glels, animator); } // - create glad2 w/ survived context { - testGLADOneLifecycle(caps, gladType2, width+100, height+100, - glelTracker, snapshotGLEventListener, - glels[0], - null, null); + testGLADOneLifecycle(screen, caps, gladType2, width+100, + height+100, glelTracker, + snapshotGLEventListener, + glels[0], null, null); } animator.stop(); } -- cgit v1.2.3 From 8d7819aa08b031fddd5813ec29b2fa3d66666407 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 24 Apr 2013 05:10:50 +0200 Subject: Use new toolchain (gluegen 3b7ea9f67487be8f133c19b493b632fc579c5049) --- make/scripts/make.jogl.all.linux-armv6-cross.sh | 2 +- make/scripts/make.jogl.all.linux-armv6.sh | 2 +- make/scripts/make.jogl.all.linux-armv6hf-cross.sh | 2 +- make/scripts/make.jogl.all.linux-armv6hf.sh | 2 +- make/scripts/tests.sh | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.linux-armv6-cross.sh b/make/scripts/make.jogl.all.linux-armv6-cross.sh index 9f31b798d..d3fb2783a 100755 --- a/make/scripts/make.jogl.all.linux-armv6-cross.sh +++ b/make/scripts/make.jogl.all.linux-armv6-cross.sh @@ -7,7 +7,7 @@ if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then fi # arm-linux-gnueabi == armel triplet -PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabi/bin:$PATH +PATH=`pwd`/../../gluegen/make/lib/toolchain/armsf-linux-gnueabi/bin:$PATH export PATH # -Dc.compiler.debug=true diff --git a/make/scripts/make.jogl.all.linux-armv6.sh b/make/scripts/make.jogl.all.linux-armv6.sh index 3d526ea12..6f1852a32 100755 --- a/make/scripts/make.jogl.all.linux-armv6.sh +++ b/make/scripts/make.jogl.all.linux-armv6.sh @@ -1,7 +1,7 @@ #! /bin/sh # arm-linux-gnueabi == armel triplet -PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabi/bin:$PATH +PATH=`pwd`/../../gluegen/make/lib/toolchain/armsf-linux-gnueabi/bin:$PATH export PATH # -Dc.compiler.debug=true diff --git a/make/scripts/make.jogl.all.linux-armv6hf-cross.sh b/make/scripts/make.jogl.all.linux-armv6hf-cross.sh index 6295a90f9..fd5611ea7 100755 --- a/make/scripts/make.jogl.all.linux-armv6hf-cross.sh +++ b/make/scripts/make.jogl.all.linux-armv6hf-cross.sh @@ -7,7 +7,7 @@ if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then fi # arm-linux-gnueabihf == armel triplet -PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabihf/bin:$PATH +PATH=`pwd`/../../gluegen/make/lib/toolchain/armhf-linux-gnueabi/bin:$PATH export PATH # -Dc.compiler.debug=true diff --git a/make/scripts/make.jogl.all.linux-armv6hf.sh b/make/scripts/make.jogl.all.linux-armv6hf.sh index 7d9480f26..ae554c59b 100755 --- a/make/scripts/make.jogl.all.linux-armv6hf.sh +++ b/make/scripts/make.jogl.all.linux-armv6hf.sh @@ -1,7 +1,7 @@ #! /bin/sh # arm-linux-gnueabihf == armhf triplet -PATH=`pwd`/../../gluegen/make/lib/linux/arm-linux-gnueabihf/bin:$PATH +PATH=`pwd`/../../gluegen/make/lib/toolchain/armhf-linux-gnueabi/bin:$PATH export PATH # -Dc.compiler.debug=true diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 65e070a99..b53c2f760 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -284,7 +284,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* @@ -363,7 +363,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch12AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestBug722GLContextDrawableSwitchNewt2AWT $* -- cgit v1.2.3 From 56b330db24338cb287f1c53b92a6e0b7bf521625 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 24 Apr 2013 05:15:36 +0200 Subject: Add scripts/make.jogl.all.sh --- make/scripts/make.jogl.all.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100755 make/scripts/make.jogl.all.sh (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.sh b/make/scripts/make.jogl.all.sh new file mode 100755 index 000000000..67d965dac --- /dev/null +++ b/make/scripts/make.jogl.all.sh @@ -0,0 +1,9 @@ +#! /bin/sh + +SDIR=`dirname $0` + +$SDIR/make.jogl.all.linux-armv6-cross.sh \ +&& $SDIR/make.jogl.all.linux-armv6hf-cross.sh \ +&& $SDIR/make.jogl.all.linux-x86_64.sh \ +&& $SDIR/make.jogl.all.linux-x86.sh \ +&& $SDIR/make.jogl.all.android-armv6-cross.sh \ -- cgit v1.2.3 From 75b3d37a3b15c071b49609921244bcb62d329fa9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 25 Apr 2013 06:08:01 +0200 Subject: Fix Bug 706 and Bug 520: Certain ATI GPU/driver require a current context when calling wglCreateContextAttribsARB (Windows) See discussion at https://jogamp.org/bugzilla/show_bug.cgi?id=520 https://jogamp.org/bugzilla/show_bug.cgi?id=706 --- make/scripts/tests-x64.bat | 6 +-- .../opengl/windows/wgl/WindowsWGLContext.java | 25 ++++++++--- .../windows/wgl/WindowsWGLDrawableFactory.java | 51 ++++++++++++++-------- .../opengl/x11/glx/X11GLXDrawableFactory.java | 14 +++--- .../native/win32/DeviceDriverQuery.txt | 41 +++++++++++++++++ 5 files changed, 103 insertions(+), 34 deletions(-) create mode 100644 src/nativewindow/native/win32/DeviceDriverQuery.txt (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index d196b1d29..0133859fd 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -33,7 +33,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAut REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT %* @@ -55,11 +55,11 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 77d06f548..92b12a7ff 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -218,7 +218,6 @@ public class WindowsWGLContext extends GLContextImpl { }; if ( major > 3 || major == 3 && minor >= 2 ) { - // FIXME: Verify with a None drawable binding (default framebuffer) attribs[idx_profile+0] = WGLExt.WGL_CONTEXT_PROFILE_MASK_ARB; if( ctBwdCompat ) { attribs[idx_profile+1] = WGLExt.WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; @@ -269,11 +268,12 @@ public class WindowsWGLContext extends GLContextImpl { */ @Override protected boolean createImpl(GLContextImpl shareWith) { - AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); - AbstractGraphicsDevice device = config.getScreen().getDevice(); - WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl(); - WindowsWGLContext sharedContext = (WindowsWGLContext) factory.getOrCreateSharedContextImpl(device); - GLCapabilitiesImmutable glCaps = drawable.getChosenGLCapabilities(); + final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); + final AbstractGraphicsDevice device = config.getScreen().getDevice(); + final WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl(); + final WindowsWGLDrawableFactory.SharedResource sharedResource = factory.getOrCreateSharedResource(device); + final WindowsWGLContext sharedContext = (WindowsWGLContext) ( null != sharedResource ? sharedResource.getContext() : null ); + final GLCapabilitiesImmutable glCaps = drawable.getChosenGLCapabilities(); isGLReadDrawableAvailable(); // trigger setup wglGLReadDrawableAvailable @@ -296,7 +296,18 @@ public class WindowsWGLContext extends GLContextImpl { // utilize the shared context's GLXExt in case it was using the ARB method and it already exists ; exclude BITMAP if( null != sharedContext && sharedContext.isCreatedWithARBMethod() && !glCaps.isBitmap() ) { - contextHandle = createContextARB(share, true); + if ( sharedResource.needsCurrenContext4ARBCreateContextAttribs() ) { + if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) { + throw new GLException("Could not make Shared Context current: "+sharedContext); + } + contextHandle = createContextARB(share, true); + sharedContext.release(); + if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { + throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError()); + } + } else { + contextHandle = createContextARB(share, true); + } createContextARBTried = true; if ( DEBUG && 0 != contextHandle ) { System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+share); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index e9742c4fe..483e31611 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -208,18 +208,19 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { static final VersionNumber winXPVersionNumber = new VersionNumber ( 5, 1, 0); static class SharedResource implements SharedResourceRunner.Resource { + private final boolean hasARBPixelFormat; + private final boolean hasARBMultisample; + private final boolean hasARBPBuffer; + private final boolean hasARBReadDrawable; + private final String vendor; + private final boolean isVendorATI; + private final boolean isVendorNVIDIA; + private final boolean needsCurrenContext4ARBPFDQueries; + private final boolean needsCurrenContext4ARBCreateContextAttribs; private WindowsGraphicsDevice device; private AbstractGraphicsScreen screen; private GLDrawableImpl drawable; private GLContextImpl context; - private boolean hasARBPixelFormat; - private boolean hasARBMultisample; - private boolean hasARBPBuffer; - private boolean hasARBReadDrawable; - private String vendor; - private boolean isVendorATI; - private boolean isVendorNVIDIA; - private boolean needsCurrenContext4ARBPFDQueries; SharedResource(WindowsGraphicsDevice dev, AbstractGraphicsScreen scrn, GLDrawableImpl draw, GLContextImpl ctx, boolean arbPixelFormat, boolean arbMultisample, boolean arbPBuffer, boolean arbReadDrawable, String glVendor) { @@ -235,20 +236,26 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { if(null != vendor) { isVendorNVIDIA = vendor.startsWith("NVIDIA") ; isVendorATI = vendor.startsWith("ATI") ; + } else { + isVendorNVIDIA = false; + isVendorATI = false; } - if ( isVendorATI() ) { + if ( isVendorATI ) { + needsCurrenContext4ARBCreateContextAttribs = true; final VersionNumber winVersion = Platform.getOSVersionNumber(); final boolean isWinXPOrLess = winVersion.compareTo(winXPVersionNumber) <= 0; - if(DEBUG) { - System.err.println("needsCurrenContext4ARBPFDQueries: "+winVersion+" <= "+winXPVersionNumber+" = "+isWinXPOrLess+" - "+Platform.getOSVersion()); - } needsCurrenContext4ARBPFDQueries = isWinXPOrLess; - } else { - if(DEBUG) { - System.err.println("needsCurrenContext4ARBPFDQueries: false"); + if(DEBUG) { + System.err.println("ATI && isWinXPOrLess = "+winVersion+" <= "+winXPVersionNumber+" = "+isWinXPOrLess+" - "+Platform.getOSVersion()); } + } else { needsCurrenContext4ARBPFDQueries = false; + needsCurrenContext4ARBCreateContextAttribs = false; + } + if(DEBUG) { + System.err.println("needsCurrenContext4ARBCreateContextAttribs: "+needsCurrenContext4ARBCreateContextAttribs); + System.err.println("needsCurrenContext4ARBPFDQueries: "+needsCurrenContext4ARBPFDQueries); } } @@ -273,12 +280,22 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { /** * Solves bug #480 * - * TODO: Validate if bug is actually relates to the 'old' ATI Windows driver for old GPU's like X300 etc - * and unrelated to the actual Windows version ! + * TODO: Validate if bug actually relates to the 'old' ATI Windows driver for old GPU's like X300 etc + * and not to the Windows version ! * * @return true if GL_VENDOR is ATI _and_ platform is Windows version XP or less! */ final boolean needsCurrentContext4ARBPFDQueries() { return needsCurrenContext4ARBPFDQueries; } + + /** + * Solves bug #706 and bug #520 + * + * TODO: Validate if quirk can be reduced to a certain range of GPUs and/or driver versions, + * where we would also need a method to query the latter (-> jogl/src/nativewindow/native/win32/DeviceDriverQuery.txt). + * + * @return true if GL_VENDOR is ATI + */ + final boolean needsCurrenContext4ARBCreateContextAttribs() { return needsCurrenContext4ARBCreateContextAttribs; } } class SharedResourceImplementation implements SharedResourceRunner.Implementation { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 19005e48c..0d89468a9 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -157,17 +157,17 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { private HashMap sharedMap; static class SharedResource implements SharedResourceRunner.Resource { + private final String glXServerVendorName; + private final boolean isGLXServerVendorATI; + private final boolean isGLXServerVendorNVIDIA; + private final VersionNumber glXServerVersion; + private final boolean glXServerVersionOneOneCapable; + private final boolean glXServerVersionOneThreeCapable; + private final boolean glXMultisampleAvailable; X11GraphicsDevice device; X11GraphicsScreen screen; GLDrawableImpl drawable; GLContextImpl context; - String glXServerVendorName; - boolean isGLXServerVendorATI; - boolean isGLXServerVendorNVIDIA; - VersionNumber glXServerVersion; - boolean glXServerVersionOneOneCapable; - boolean glXServerVersionOneThreeCapable; - boolean glXMultisampleAvailable; SharedResource(X11GraphicsDevice dev, X11GraphicsScreen scrn, GLDrawableImpl draw, GLContextImpl ctx, diff --git a/src/nativewindow/native/win32/DeviceDriverQuery.txt b/src/nativewindow/native/win32/DeviceDriverQuery.txt new file mode 100644 index 000000000..7401ed83b --- /dev/null +++ b/src/nativewindow/native/win32/DeviceDriverQuery.txt @@ -0,0 +1,41 @@ + + // INCOMPLETE ! + // + // See Bug 706 and Bug 520 + // https://jogamp.org/bugzilla/show_bug.cgi?id=520 + // https://jogamp.org/bugzilla/show_bug.cgi?id=706 + // + // Device Driver SDK + // http://msdn.microsoft.com/en-us/library/ff553567.aspx#ddk_setupdi_device_information_functions_dg + { + /** + System-Defined Device Setup Classes Available to Vendors (GUID) + + Display Adapters + Class = Display + ClassGuid = {4d36e968-e325-11ce-bfc1-08002be10318} + This class includes video adapters. Drivers for this class include display drivers and video miniport drivers. + + /opt-windows/mingw/include/devguid.h GUID_DEVCLASS_DISPLAY + GUID_DEVCLASS_DISPLAY + HDEVINFO SetupDiGetClassDevs( + _In_opt_ const GUID *ClassGuid, + _In_opt_ PCTSTR Enumerator, + _In_opt_ HWND hwndParent, + _In_ DWORD Flags + ); + + */ + const GUID devClassDisplay = GUID_DEVCLASS_DISPLAY; + // http://msdn.microsoft.com/en-us/library/ff551069.aspx + HDEVINFO DeviceInfoSet = SetupDiGetClassDevs(&GUID_DEVCLASS_DISPLAY, NULL /* bus */, NULL /* windows */, DIGCF_PRESENT | DIGCF_PROFILE /* flags */); + DWORD MemberIndex = 0; + SP_DEVINFO_DATA DeviceInfoData; + DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + while( TRUE == SetupDiEnumDeviceInfo(DeviceInfoSet, MemberIndex, &DeviceInfoData) ) { + SetupDiGetSelectedDevice(); + MemberIndex++; + } + SetupDiDestroyDeviceInfoList(hDevInfo); + } + -- cgit v1.2.3 From 6ebf649d1b87944257fe492e0aef842d1b8debc2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 6 May 2013 17:27:09 +0200 Subject: Fix Bug 600 and Bug 721: Adding support for multiple monitors w/ NEWT - Support for all monitor devices and their available modes - X11: Use RandR 1.3 if available - Retrieve information - Changing a monitor device's mode - Support for dedicated and spannig fullscreen - See - TODO: - X11 RandR does _not_ relayout the virtual screen size and neither the CRT's viewport. We may need to relayout them if they were covering a seamless region to achieve same experience! - OSX: No machine to attach a secondary CRT -> TEST! - Tested Manually for Regressions - Linux ARMv6hf (Rasp-Pi/BCM, Panda/X11) - Android (Huawei, Kindle) - Tested Manually and junit: - X11/Linux - NV, ATI-Catalyst w/ 2 CRTs - VBox w/ 4 CRTs - Win/Windows - NV, w/ 2 CRTs - VBox w/ 4 CRTs - X11/OpenIndiana, NV, 1 CRT --- make/build-newt.xml | 1 + make/scripts/java-win64-dbg.bat | 1 + make/scripts/tests-x64.bat | 13 +- make/scripts/tests.sh | 18 +- .../javax/media/nativewindow/util/Dimension.java | 5 + .../javax/media/nativewindow/util/Insets.java | 8 + .../javax/media/nativewindow/util/Point.java | 4 + .../javax/media/nativewindow/util/Rectangle.java | 86 ++- .../nativewindow/util/RectangleImmutable.java | 20 + .../javax/media/nativewindow/util/SurfaceSize.java | 4 +- .../classes/com/jogamp/newt/MonitorDevice.java | 235 ++++++++ src/newt/classes/com/jogamp/newt/MonitorMode.java | 346 ++++++++++++ src/newt/classes/com/jogamp/newt/Screen.java | 93 ++-- src/newt/classes/com/jogamp/newt/ScreenMode.java | 208 ------- src/newt/classes/com/jogamp/newt/Window.java | 38 +- .../com/jogamp/newt/event/MonitorEvent.java | 71 +++ .../com/jogamp/newt/event/MonitorModeListener.java | 37 ++ .../classes/com/jogamp/newt/event/NEWTEvent.java | 7 +- .../classes/com/jogamp/newt/event/OutputEvent.java | 51 ++ .../com/jogamp/newt/event/ScreenModeListener.java | 39 -- .../classes/com/jogamp/newt/opengl/GLWindow.java | 13 + .../classes/com/jogamp/newt/util/MonitorMode.java | 102 ---- .../com/jogamp/newt/util/MonitorModeUtil.java | 247 +++++++++ .../com/jogamp/newt/util/ScreenModeUtil.java | 341 ------------ .../classes/jogamp/newt/MonitorDeviceImpl.java | 147 +++++ src/newt/classes/jogamp/newt/MonitorModeProps.java | 355 ++++++++++++ src/newt/classes/jogamp/newt/OffscreenWindow.java | 13 +- src/newt/classes/jogamp/newt/ScreenImpl.java | 569 ++++++++++---------- src/newt/classes/jogamp/newt/ScreenModeStatus.java | 231 -------- .../classes/jogamp/newt/ScreenMonitorState.java | 195 +++++++ src/newt/classes/jogamp/newt/WindowImpl.java | 201 +++++-- .../jogamp/newt/driver/android/ScreenDriver.java | 99 +++- .../jogamp/newt/driver/android/WindowDriver.java | 16 +- .../jogamp/newt/driver/awt/ScreenDriver.java | 24 +- .../jogamp/newt/driver/bcm/egl/ScreenDriver.java | 56 +- .../jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java | 56 +- .../jogamp/newt/driver/intel/gdl/ScreenDriver.java | 56 +- .../jogamp/newt/driver/kd/ScreenDriver.java | 54 +- .../jogamp/newt/driver/macosx/ScreenDriver.java | 129 ++--- .../jogamp/newt/driver/macosx/WindowDriver.java | 15 +- .../jogamp/newt/driver/windows/ScreenDriver.java | 146 +++-- src/newt/classes/jogamp/newt/driver/x11/RandR.java | 47 +- .../classes/jogamp/newt/driver/x11/RandR11.java | 320 +++++++---- .../classes/jogamp/newt/driver/x11/RandR13.java | 276 +++++++++- .../jogamp/newt/driver/x11/ScreenDriver.java | 146 +++-- src/newt/native/MacWindow.m | 235 ++++---- src/newt/native/NewtMacWindow.h | 1 - src/newt/native/NewtMacWindow.m | 4 +- src/newt/native/ScreenMode.h | 15 +- src/newt/native/Window.h | 17 +- src/newt/native/WindowsWindow.c | 305 ++++++++--- src/newt/native/X11RandR11.c | 44 +- src/newt/native/X11RandR13.c | 597 ++++++++++++--------- src/newt/native/X11Screen.c | 31 +- src/newt/native/X11Screen.h | 1 + src/newt/native/X11Window.c | 18 +- .../opengl/test/android/NEWTElektronActivity.java | 16 +- .../opengl/test/android/NEWTGearsES1Activity.java | 16 +- .../opengl/test/android/NEWTGearsES2Activity.java | 16 +- .../test/android/NEWTGearsES2ActivityLauncher.java | 1 + .../test/android/NEWTGearsES2TransActivity.java | 16 +- .../opengl/test/android/NEWTGraphUI1pActivity.java | 16 +- .../opengl/test/android/NEWTGraphUI2pActivity.java | 16 +- .../test/android/NEWTRedSquareES1Activity.java | 16 +- .../test/android/NEWTRedSquareES2Activity.java | 16 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 16 +- .../test/junit/jogl/glsl/TestRulerNEWT01.java | 16 +- .../test/junit/newt/ManualScreenMode03NEWT.java | 32 +- .../test/junit/newt/TestScreenMode00NEWT.java | 119 ++-- .../test/junit/newt/TestScreenMode00bNEWT.java | 24 +- .../test/junit/newt/TestScreenMode01NEWT.java | 133 ++--- .../test/junit/newt/TestScreenMode01aNEWT.java | 212 ++++++++ .../test/junit/newt/TestScreenMode01bNEWT.java | 210 +++++--- .../test/junit/newt/TestScreenMode01cNEWT.java | 249 +++++++++ .../test/junit/newt/TestScreenMode02NEWT.java | 75 +-- 75 files changed, 5159 insertions(+), 2463 deletions(-) create mode 100644 src/newt/classes/com/jogamp/newt/MonitorDevice.java create mode 100644 src/newt/classes/com/jogamp/newt/MonitorMode.java delete mode 100644 src/newt/classes/com/jogamp/newt/ScreenMode.java create mode 100644 src/newt/classes/com/jogamp/newt/event/MonitorEvent.java create mode 100644 src/newt/classes/com/jogamp/newt/event/MonitorModeListener.java create mode 100644 src/newt/classes/com/jogamp/newt/event/OutputEvent.java delete mode 100644 src/newt/classes/com/jogamp/newt/event/ScreenModeListener.java delete mode 100644 src/newt/classes/com/jogamp/newt/util/MonitorMode.java create mode 100644 src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java delete mode 100644 src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java create mode 100644 src/newt/classes/jogamp/newt/MonitorDeviceImpl.java create mode 100644 src/newt/classes/jogamp/newt/MonitorModeProps.java delete mode 100644 src/newt/classes/jogamp/newt/ScreenModeStatus.java create mode 100644 src/newt/classes/jogamp/newt/ScreenMonitorState.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01cNEWT.java (limited to 'make/scripts') diff --git a/make/build-newt.xml b/make/build-newt.xml index 862b78422..30c2ddfd1 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -593,6 +593,7 @@ + diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat index 8669ba8f8..136fe4667 100755 --- a/make/scripts/java-win64-dbg.bat +++ b/make/scripts/java-win64-dbg.bat @@ -52,6 +52,7 @@ REM set D_ARGS="-Dnativewindow.debug.TraceLock" REM set D_ARGS="-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Djogl.debug.GLContext" REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.EDT" "-Dnativewindow.debug=all" +REM set D_ARGS="-Dnewt.debug.Screen" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 0133859fd..27ecfb2cc 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -55,7 +55,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -106,10 +106,13 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus01Swin REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT %* +REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b53c2f760..c6f69ab74 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,6 +135,8 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" + #D_ARGS="-Dnewt.debug.Screen" + #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" @@ -284,7 +286,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* @@ -384,10 +386,12 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT -#testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT $* +#testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* # # awt (testawt) @@ -509,7 +513,9 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # # Texture / TextureUtils # -#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture02AWT $* + #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index 0a5a94565..4fae98f08 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -57,7 +57,9 @@ public class Dimension implements Cloneable, DimensionImmutable { } } + @Override public int getWidth() { return width; } + @Override public int getHeight() { return height; } public void setWidth(int width) { @@ -77,10 +79,12 @@ public class Dimension implements Cloneable, DimensionImmutable { return this; } + @Override public String toString() { return new String(width+" x "+height); } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Dimension) { @@ -91,6 +95,7 @@ public class Dimension implements Cloneable, DimensionImmutable { return false; } + @Override public int hashCode() { // 31 * x == (x << 5) - x int hash = 31 + width; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index 199ec27cb..f22668f55 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -57,11 +57,17 @@ public class Insets implements Cloneable, InsetsImmutable { } } + @Override public final int getLeftWidth() { return l; } + @Override public final int getRightWidth() { return r; } + @Override public final int getTotalWidth() { return l + r; } + @Override public final int getTopHeight() { return t; } + @Override public final int getBottomHeight() { return b; } + @Override public final int getTotalHeight() { return t + b; } public void setLeftWidth(int left) { l = left; } @@ -69,6 +75,7 @@ public class Insets implements Cloneable, InsetsImmutable { public void setTopHeight(int top) { t = top; } public void setBottomHeight(int bottom) { b = bottom; } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Insets) { @@ -79,6 +86,7 @@ public class Insets implements Cloneable, InsetsImmutable { return false; } + @Override public int hashCode() { int sum1 = l + b; int sum2 = t + r; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index c53b16928..8e6caf72b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -54,6 +54,7 @@ public class Point implements Cloneable, PointImmutable { } } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Point) { @@ -63,14 +64,17 @@ public class Point implements Cloneable, PointImmutable { return false; } + @Override public final int getX() { return x; } + @Override public final int getY() { return y; } + @Override public int hashCode() { // 31 * x == (x << 5) - x int hash = 31 + x; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 8d6bfe48f..8e6fc8e36 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -28,6 +28,8 @@ package javax.media.nativewindow.util; +import java.util.List; + public class Rectangle implements Cloneable, RectangleImmutable { int x; int y; @@ -57,15 +59,90 @@ public class Rectangle implements Cloneable, RectangleImmutable { } } + @Override public final int getX() { return x; } + @Override public final int getY() { return y; } + @Override public final int getWidth() { return width; } + @Override public final int getHeight() { return height; } - public void setX(int x) { this.x = x; } - public void setY(int y) { this.y = y; } - public void setWidth(int width) { this.width = width; } - public void setHeight(int height) { this.height = height; } + + public final void setX(int x) { this.x = x; } + public final void setY(int y) { this.y = y; } + public final void setWidth(int width) { this.width = width; } + public final void setHeight(int height) { this.height = height; } + @Override + public final RectangleImmutable union(final RectangleImmutable r) { + return union(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight()); + } + @Override + public final RectangleImmutable union(final int rx1, final int ry1, final int rx2, final int ry2) { + final int x1 = Math.min(x, rx1); + final int y1 = Math.min(y, ry1); + final int x2 = Math.max(x + width, rx2); + final int y2 = Math.max(y + height, ry2); + return new Rectangle(x1, y1, x2 - x1, y2 - y1); + } + /** + * Calculates the union of the given rectangles, stores it in this instance and returns this instance. + * @param rectangles given list of rectangles + * @return this instance holding the union of given rectangles. + */ + public final Rectangle union(final List rectangles) { + int x1=Integer.MAX_VALUE, y1=Integer.MAX_VALUE; + int x2=Integer.MIN_VALUE, y2=Integer.MIN_VALUE; + for(int i=rectangles.size()-1; i>=0; i--) { + final RectangleImmutable vp = rectangles.get(i); + x1 = Math.min(x1, vp.getX()); + x2 = Math.max(x2, vp.getX() + vp.getWidth()); + y1 = Math.min(y1, vp.getY()); + y2 = Math.max(y2, vp.getY() + vp.getHeight()); + } + setX(x1); + setY(y1); + setWidth(x2 - x1); + setHeight(y2 - y1); + return this; + } + + @Override + public final RectangleImmutable intersection(RectangleImmutable r) { + return intersection(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight()); + } + @Override + public final RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2) { + final int x1 = Math.max(x, rx1); + final int y1 = Math.max(y, ry1); + final int x2 = Math.min(x + width, rx2); + final int y2 = Math.min(y + height, ry2); + final int ix, iy, iwidth, iheight; + if( x2 < x1 ) { + ix = 0; + iwidth = 0; + } else { + ix = x1; + iwidth = x2 - x1; + } + if( y2 < y1 ) { + iy = 0; + iheight = 0; + } else { + iy = y1; + iheight = y2 - y1; + } + return new Rectangle (ix, iy, iwidth, iheight); + } + @Override + public final float coverage(RectangleImmutable r) { + final RectangleImmutable isect = intersection(r); + final float sqI = (float) ( isect.getWidth()*isect.getHeight() ); + final float sqT = (float) ( width*height ); + return sqI / sqT; + } + + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Rectangle) { @@ -76,6 +153,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { return false; } + @Override public int hashCode() { int sum1 = x + height; int sum2 = width + y; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java index d3b43c864..7531989de 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java @@ -41,6 +41,26 @@ public interface RectangleImmutable extends WriteCloneable { int getY(); + /** Returns the union of this rectangle and the given rectangle. */ + RectangleImmutable union(final RectangleImmutable r); + /** Returns the union of this rectangleand the given coordinates. */ + RectangleImmutable union(final int rx1, final int ry1, final int rx2, final int ry2); + /** Returns the intersection of this rectangleand the given rectangle. */ + RectangleImmutable intersection(RectangleImmutable r); + /** Returns the intersection of this rectangleand the given coordinates. */ + RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2); + /** + * Returns the coverage of given rectangle w/ this this one, i.e. between 0.0 and 1.0. + *

    + * Coverage is computed by: + *

    +     *    isect = this.intersection(r);
    +     *    coverage = area( isect ) / area( this ) ;
    +     * 
    + *

    + */ + float coverage(RectangleImmutable r); + /** * Checks whether two rect objects are equal. Two instances * of Rectangle are equal if the four integer values diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index 8f21bc49b..d7e451af8 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -36,8 +36,8 @@ package javax.media.nativewindow.util; * */ public class SurfaceSize { - DimensionImmutable resolution; - int bitsPerPixel; + final DimensionImmutable resolution; + final int bitsPerPixel; public SurfaceSize(DimensionImmutable resolution, int bitsPerPixel) { if(null==resolution || bitsPerPixel<=0) { diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java new file mode 100644 index 000000000..fbe4d8cf0 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -0,0 +1,235 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt; + +import java.util.List; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; + +import com.jogamp.common.util.ArrayHashSet; + +/** + * Visual output device, i.e. a CRT, LED ..consisting of it's components:
    + * + *
  • Immutable + *
      + *
    • nativeId
    • + *
    • {@link DimensionImmutable} size in [mm]
    • + *
    • {@link MonitorMode} original mode
    • + *
    • List<MonitorMode> supportedModes
    • + *
  • + *
  • Mutable + *
      + *
    • {@link MonitorMode} current mode
    • + *
    • {@link RectangleImmutable} viewport (rotated)
    • + *
  • + * + */ +public abstract class MonitorDevice { + protected final Screen screen; // backref + protected final int nativeId; // unique monitor device ID + protected final DimensionImmutable sizeMM; // in [mm] + protected final MonitorMode originalMode; + protected final ArrayHashSet supportedModes; // FIXME: May need to support mutable mode, i.e. adding modes on the fly! + protected MonitorMode currentMode; + protected boolean modeChanged; + protected Rectangle viewport; + + protected MonitorDevice(Screen screen, int nativeId, DimensionImmutable sizeMM, Rectangle viewport, MonitorMode currentMode, ArrayHashSet supportedModes) { + this.screen = screen; + this.nativeId = nativeId; + this.sizeMM = sizeMM; + this.originalMode = currentMode; + this.supportedModes = supportedModes; + this.currentMode = currentMode; + this.viewport = viewport; + this.modeChanged = false; + } + + /** Returns the {@link Screen} owning this monitor. */ + public final Screen getScreen() { + return screen; + } + + /** + * Tests equality of two MonitorDevice objects + * by evaluating equality of it's components:
    + *
      + *
    • nativeID
    • + *
    + *
    + */ + public final boolean equals(Object obj) { + if (this == obj) { return true; } + if (obj instanceof MonitorDevice) { + MonitorDevice md = (MonitorDevice)obj; + return md.nativeId == nativeId; + } + return false; + } + + /** + * Returns a combined hash code of it's elements:
    + *
      + *
    • nativeID
    • + *
    + */ + public final int hashCode() { + return nativeId; + } + + /** @return the immutable unique native Id of this monitor device. */ + public final int getId() { return nativeId; } + + /** + * @return the immutable monitor size in millimeters. + */ + public final DimensionImmutable getSizeMM() { + return sizeMM; + } + + /** + * Return the immutable original {@link com.jogamp.newt.MonitorMode}, as used at NEWT initialization. + * @return original {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + */ + public final MonitorMode getOriginalMode() { + return originalMode; + } + + /** + * FIXME: May need to support mutable mode, i.e. adding modes on the fly! + * @return the immutable list of {@link MonitorMode}s supported by this monitor. Use w/ care, it's not a copy! + */ + public final List getSupportedModes() { + return supportedModes.getData(); + } + + /** @return the {@link RectangleImmutable rectangular} portion of the rotated virtual {@link Screen} size represented by this monitor. */ + public final RectangleImmutable getViewport() { + return viewport; + } + + /** Returns true if given coordinates are contained by this {@link #getViewport() viewport}, otherwise false. */ + public final boolean contains(int x, int y) { + return x >= viewport.getX() && + x < viewport.getX() + viewport.getWidth() && + y >= viewport.getY() && + y < viewport.getY() + viewport.getHeight() ; + } + + /** + * Returns the coverage of given rectangle w/ this this {@link #getViewport() viewport}, i.e. between 0.0 and 1.0. + *

    + * Coverage is computed by: + *

    +     *    isect = viewport.intersection(r);
    +     *    coverage = area( isect ) / area( viewport ) ;
    +     * 
    + *

    + */ + public final float coverage(RectangleImmutable r) { + return viewport.coverage(r); + } + + /** + * Returns the union of the given monitor's {@link #getViewport() viewport}. + * @param result storage for result, will be returned + * @param monitors given list of monitors + * @return viewport representing the union of given monitor's viewport. + */ + public static Rectangle unionOfViewports(final Rectangle result, final List monitors) { + int x1=Integer.MAX_VALUE, y1=Integer.MAX_VALUE; + int x2=Integer.MIN_VALUE, y2=Integer.MIN_VALUE; + for(int i=monitors.size()-1; i>=0; i--) { + final RectangleImmutable vp = monitors.get(i).getViewport(); + x1 = Math.min(x1, vp.getX()); + x2 = Math.max(x2, vp.getX() + vp.getWidth()); + y1 = Math.min(y1, vp.getY()); + y2 = Math.max(y2, vp.getY() + vp.getHeight()); + } + result.setX(x1); + result.setY(y1); + result.setWidth(x2 - x1); + result.setHeight(y2 - y1); + return result; + } + + public final boolean isOriginalMode() { + return currentMode.hashCode() == originalMode.hashCode(); + } + + /** + * Returns true if the {@link MonitorMode} + * has been changed programmatic via this API only, otherwise false. + *

    + * Note: We cannot guarantee that we won't interfere w/ another running + * application's screen mode change or vice versa. + *

    + */ + public final boolean isModeChangedByUs() { + return modeChanged && !isOriginalMode(); + } + + /** + * Return the current cached {@link MonitorMode} w/o native query. + *

    + * If {@link MonitorMode}s are not supported for this + * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

    + * + * @return current {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + */ + public final MonitorMode getCurrentMode() { + return currentMode; + } + + /** + * Return the current {@link MonitorMode} including a native query. + *

    + * If {@link MonitorMode}s are not supported for this + * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

    + * + * @return current {@link MonitorMode} which is element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + */ + public abstract MonitorMode queryCurrentMode(); + + /** + * Set the current {@link com.jogamp.newt.MonitorMode}. + * @param mode to be made current, must be element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}. + * @return true if successful, otherwise false + */ + public abstract boolean setCurrentMode(MonitorMode mode); + + public String toString() { + return "Monitor[Id "+Display.toHexString(nativeId)+", "+sizeMM+" mm, viewport "+viewport+ ", orig "+originalMode+", curr "+currentMode+ + ", modeChanged "+modeChanged+", modeCount "+supportedModes.size()+"]"; + } +} + diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java new file mode 100644 index 000000000..e5b329d47 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -0,0 +1,346 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.SurfaceSize; + + +/** Immutable MonitorMode Class, consisting of it's read only components:
    + *
      + *
    • nativeId
    • + *
    • {@link SizeAndRRate}, non rotated surfaceSize and refreshRate
    • + *
    • rotation, measured counter clockwise (CCW)
    • + *
    + * + * Aquire and filter MonitorMode
    + *
      + *
    • A List of read only MonitorModes is being returned by {@link com.jogamp.newt.Screen#getMonitorModes()}.
    • + *
    • You may utilize {@link com.jogamp.newt.util.MonitorModeUtil} to filter and select a desired ScreenMode.
    • + *
    • The current ScreenMode can be obtained via {@link com.jogamp.newt.Screen#getCurrentScreenMode()}.
    • + *
    • The initial original ScreenMode (at startup) can be obtained via {@link com.jogamp.newt.Screen#getOriginalScreenMode()}.
    • + *
    + *
    + * + * Changing ScreenModes
    + * FIXME!!!!! + *
      + *
    • Use {@link com.jogamp.newt.Screen#setCurrentScreenMode(com.jogamp.newt.MonitorMode)}
    • + * to change the current ScreenMode of all Screen's referenced via the full qualified name (FQN) + * {@link com.jogamp.newt.Screen#getFQName()}. + *
    • When the last FQN referenced Screen closes, the original ScreenMode ({@link com.jogamp.newt.Screen#getOriginalScreenMode()}) + * is restored.
    • + *
    + *
    + * Example for changing the ScreenMode: + *
    +        // determine target refresh rate
    +        ScreenMode orig = screen.getOriginalScreenMode();
    +        int freq = orig.getOutputMode().getRefreshRate();
    +
    +        // target resolution
    +        Dimension res = new Dimension(800, 600);
    +
    +        // target rotation
    +        int rot = 0;
    +
    +        // filter available ScreenModes
    +        List screenModes = screen.getScreenModes();
    +        screenModes = ScreenModeUtil.filterByRate(screenModes, freq); // get the nearest ones
    +        screenModes = ScreenModeUtil.filterByRotation(screenModes, rot);
    +        screenModes = ScreenModeUtil.filterByResolution(screenModes, res); // get the nearest ones
    +        screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
    +
    +        // pick 1st one ..
    +        screen.setCurrentScreenMode((ScreenMode) screenModes.get(0)); 
    + * 
    + * + * X11 / AMD just works
    + *
    + * X11 / NVidia difficulties + *
    +    NVidia RANDR RefreshRate Bug
    +        If NVidia's 'DynamicTwinView' is enabled, all refresh rates are
    +        unique, ie consequent numbers starting with the default refresh, ie 50, 51, ..
    +        The only way to workaround it is to disable 'DynamicTwinView'.
    +        Read: http://us.download.nvidia.com/XFree86/Linux-x86/260.19.12/README/configtwinview.html
    +
    +        Check to see if 'DynamicTwinView' is enable:
    +            nvidia-settings -q :0/DynamicTwinview
    +
    +        To disable it (workaround), add the following option to your xorg.conf device section:
    +            Option "DynamicTwinView" "False"
    +
    +    NVidia RANDR Rotation:
    +        To enable it, add the following option to your xorg.conf device section:
    +            Option "RandRRotation" "on"
    + * 
    + * + */ +public class MonitorMode { + /** + * Immutable surfaceSize and refreshRate Class, consisting of it's read only components:
    + *
      + *
    • nativeId
    • + *
    • {@link SurfaceSize} surface memory size
    • + *
    • refresh rate
    • + *
    + */ + public static class SizeAndRRate { + public final SurfaceSize surfaceSize; + public final float refreshRate; + public final int flags; + public final int hashCode; + + public SizeAndRRate(SurfaceSize surfaceSize, float refreshRate, int flags) { + if(null==surfaceSize) { + throw new IllegalArgumentException("surfaceSize must be set ("+surfaceSize+")"); + } + this.surfaceSize=surfaceSize; + this.refreshRate=refreshRate; + this.flags = flags; + this.hashCode = getHashCode(); + } + + private final static String STR_INTERLACE = "Interlace"; + private final static String STR_DOUBLESCAN = "DoubleScan"; + private final static String STR_SEP = ", "; + + public static final StringBuffer flags2String(int flags) { + final StringBuffer sb = new StringBuffer(); + boolean sp = false; + if( 0 != ( flags & FLAG_INTERLACE ) ) { + sb.append(STR_INTERLACE); + sp = true; + } + if( 0 != ( flags & FLAG_DOUBLESCAN ) ) { + if( sp ) { + sb.append(STR_SEP); + } + sb.append(STR_DOUBLESCAN); + sp = true; + } + return sb; + } + public final String toString() { + return new String(surfaceSize+" @ "+refreshRate+" Hz, flags ["+flags2String(flags).toString()+"]"); + } + + /** + * Tests equality of two {@link SizeAndRRate} objects + * by evaluating equality of it's components:
    + *
      + *
    • surfaceSize
    • + *
    • refreshRate
    • + *
    • flags
    • + *
    + */ + public final boolean equals(Object obj) { + if (this == obj) { return true; } + if (obj instanceof SizeAndRRate) { + final SizeAndRRate p = (SizeAndRRate)obj; + return surfaceSize.equals(p.surfaceSize) && + refreshRate == p.refreshRate && + flags == p.flags ; + } + return false; + } + + /** + * Returns a combined hash code of it's elements:
    + *
      + *
    • surfaceSize
    • + *
    • refreshRate
    • + *
    • flags
    • + *
    + */ + public final int hashCode() { + return hashCode; + } + private final int getHashCode() { + // 31 * x == (x << 5) - x + int hash = 31 + surfaceSize.hashCode(); + hash = ((hash << 5) - hash) + (int)(refreshRate*100.0f); + hash = ((hash << 5) - hash) + flags; + return hash; + } + } + + /** zero rotation, compared to normal settings */ + public static final int ROTATE_0 = 0; + + /** 90 degrees CCW rotation */ + public static final int ROTATE_90 = 90; + + /** 180 degrees CCW rotation */ + public static final int ROTATE_180 = 180; + + /** 270 degrees CCW rotation */ + public static final int ROTATE_270 = 270; + + /** Frame is split into two fields. See {@link #getFlags()}. */ + public static final int FLAG_INTERLACE = 1 << 0; + + /** Lines are doubled. See {@link #getFlags()}. */ + public static final int FLAG_DOUBLESCAN = 1 << 1; + + /** The immutable native Id of this instance, which may not be unique. */ + private final int nativeId; + private final SizeAndRRate sizeAndRRate; + private final int rotation; + private final int hashCode; + + public static boolean isRotationValid(int rotation) { + return rotation == MonitorMode.ROTATE_0 || rotation == MonitorMode.ROTATE_90 || + rotation == MonitorMode.ROTATE_180 || rotation == MonitorMode.ROTATE_270 ; + } + + /** + * @param sizeAndRRate the surface size and refresh rate mode + * @param rotation the screen rotation, measured counter clockwise (CCW) + */ + public MonitorMode(int nativeId, SizeAndRRate sizeAndRRate, int rotation) { + if ( !isRotationValid(rotation) ) { + throw new RuntimeException("invalid rotation: "+rotation); + } + this.nativeId = nativeId; + this.sizeAndRRate = sizeAndRRate; + this.rotation = rotation; + this.hashCode = getHashCode(); + } + + /** + * Creates a user instance w/o {@link #getId() identity} to filter our matching modes w/ identity. + *

    + * See {@link com.jogamp.newt.util.MonitorModeUtil} for filter utilities. + *

    + * @param surfaceSize + * @param refreshRate + * @param flags + * @param rotation + */ + public MonitorMode(SurfaceSize surfaceSize, float refreshRate, int flags, int rotation) { + this(0, new SizeAndRRate(surfaceSize, refreshRate, flags), rotation); + } + + /** @return the immutable native Id of this mode, may not be unique, may be 0. */ + public final int getId() { return nativeId; } + + /** Returns the surfaceSize and refreshRate instance. */ + public final SizeAndRRate getSizeAndRRate() { + return sizeAndRRate; + } + + /** Returns the unrotated {@link SurfaceSize} */ + public final SurfaceSize getSurfaceSize() { + return sizeAndRRate.surfaceSize; + } + + public final float getRefreshRate() { + return sizeAndRRate.refreshRate; + } + + /** Returns bitfield w/ flags, i.e. {@link #FLAG_DOUBLESCAN}, {@link #FLAG_INTERLACE}, .. */ + public final int getFlags() { + return sizeAndRRate.flags; + } + + /** Returns the CCW rotation of this mode */ + public final int getRotation() { + return rotation; + } + + /** Returns the rotated screen width, + * derived from getMonitorMode().getSurfaceSize().getResolution() + * and getRotation() + */ + public final int getRotatedWidth() { + return getRotatedWH(true); + } + + /** Returns the rotated screen height, + * derived from getMonitorMode().getSurfaceSize().getResolution() + * and getRotation() + */ + public final int getRotatedHeight() { + return getRotatedWH(false); + } + + public final String toString() { + return "[Id "+Display.toHexString(nativeId)+", " + sizeAndRRate + ", " + rotation + " degr]"; + } + + /** + * Tests equality of two {@link MonitorMode} objects + * by evaluating equality of it's components:
    + *
      + *
    • nativeId
    • + *
    • sizeAndRRate
    • + *
    • rotation
    • + *
    + */ + public final boolean equals(Object obj) { + if (this == obj) { return true; } + if (obj instanceof MonitorMode) { + MonitorMode sm = (MonitorMode)obj; + return sm.nativeId == this.nativeId && + sm.sizeAndRRate.equals(sizeAndRRate) && + sm.rotation == this.rotation ; + } + return false; + } + + /** + * Returns a combined hash code of it's elements:
    + *
      + *
    • nativeId
    • + *
    • sizeAndRRate
    • + *
    • rotation
    • + *
    + */ + public final int hashCode() { + return hashCode; + } + private final int getHashCode() { + // 31 * x == (x << 5) - x + int hash = 31 + getId(); + hash = ((hash << 5) - hash) + sizeAndRRate.hashCode(); + hash = ((hash << 5) - hash) + getRotation(); + return hash; + } + + private final int getRotatedWH(boolean width) { + final DimensionImmutable d = sizeAndRRate.surfaceSize.getResolution(); + final boolean swap = MonitorMode.ROTATE_90 == rotation || MonitorMode.ROTATE_270 == rotation ; + if ( ( width && swap ) || ( !width && !swap ) ) { + return d.getHeight(); + } + return d.getWidth(); + } +} diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index a09748d52..81a62d898 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -27,14 +27,19 @@ */ package com.jogamp.newt; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorModeListener; import jogamp.newt.Debug; import java.util.ArrayList; import java.util.Collection; import java.util.List; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; +/** + * A screen may span multiple {@link MonitorDevice}s representing their combined virtual size. + */ public abstract class Screen { /** @@ -122,25 +127,30 @@ public abstract class Screen { public abstract int getIndex(); /** - * @return the x position of the virtual top-left origin. + * @return the x position of the virtual viewport's top-left origin. */ public abstract int getX(); /** - * @return the y position of the virtual top-left origin. + * @return the y position of the virtual viewport's top-left origin. */ public abstract int getY(); /** - * @return the rotated virtual width. + * @return the rotated virtual viewport's width. */ public abstract int getWidth(); /** - * @return the rotated virtual height. + * @return the rotated virtual viewport's height. */ public abstract int getHeight(); + /** + * @return the rotated virtual viewport, i.e. origin and size. + */ + public abstract RectangleImmutable getViewport(); + /** * @return the associated Display */ @@ -152,48 +162,68 @@ public abstract class Screen { */ public abstract String getFQName(); - /** - * @param sml ScreenModeListener to be added for ScreenMode change events - */ - public abstract void addScreenModeListener(ScreenModeListener sml); - - /** - * @param sml ScreenModeListener to be removed from ScreenMode change events + /** + * Return a list of all available {@link MonitorMode}s for all {@link MonitorDevice}s. + *

    + * If {@link com.jogamp.newt.MonitorMode ScreenMode}s are not supported for this + * native type {@link com.jogamp.newt.Display#getType()}, it returns a list of size one with the current screen size.

    */ - public abstract void removeScreenModeListener(ScreenModeListener sml); + public abstract List getMonitorModes(); /** - * Return a list of available {@link com.jogamp.newt.ScreenMode ScreenMode}s. + * Return a list of all available {@link MonitorDevice}s. *

    - * If {@link com.jogamp.newt.ScreenMode ScreenMode}s are not supported for this + * If {@link com.jogamp.newt.MonitorMode ScreenMode}s are not supported for this * native type {@link com.jogamp.newt.Display#getType()}, it returns a list of size one with the current screen size.

    - * - * @return a shallow copy of the internal immutable {@link com.jogamp.newt.ScreenMode ScreenMode}s. */ - public abstract List getScreenModes(); + public abstract List getMonitorDevices(); /** - * Return the original {@link com.jogamp.newt.ScreenMode}, as used at NEWT initialization. - * @return original ScreenMode which is element of the list {@link #getScreenModes()}. + * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} + * {@link MonitorDevice#coverage(RectangleImmutable) covers} the given rectangle the most. + *

    + * If no coverage is detected the first {@link MonitorDevice} is returned. + *

    */ - public abstract ScreenMode getOriginalScreenMode(); + public final MonitorDevice getMainMonitor(RectangleImmutable r) { + MonitorDevice res = null; + float maxCoverage = Float.MIN_VALUE; + final List monitors = getMonitorDevices(); + for(int i=monitors.size()-1; i>=0; i--) { + final MonitorDevice monitor = monitors.get(i); + final float coverage = monitor.coverage(r); + if( coverage > maxCoverage ) { + maxCoverage = coverage; + res = monitor; + } + } + if( maxCoverage > 0.0f && null != res ) { + return res; + } + return monitors.get(0); + } /** - * Return the current {@link com.jogamp.newt.ScreenMode}. + * Returns the union of all monitor's {@link MonitorDevice#getViewport() viewport}. *

    - * If {@link com.jogamp.newt.ScreenMode ScreenMode}s are not supported for this - * native type {@link com.jogamp.newt.Display#getType()}, it returns one with the current screen size.

    - * - * @return current ScreenMode which is element of the list {@link #getScreenModes()}. + * Should be equal to {@link #getX()}, {@link #getY()}, {@link #getWidth()} and {@link #getHeight()}, + * however, some native toolkits may choose a different virtual screen area. + *

    + * @param result storage for result, will be returned + */ + public final Rectangle unionOfMonitorViewportSize(final Rectangle result) { + return MonitorDevice.unionOfViewports(result, getMonitorDevices()); + } + + /** + * @param sml {@link MonitorModeListener} to be added for {@link MonitorEvent} */ - public abstract ScreenMode getCurrentScreenMode(); + public abstract void addMonitorModeListener(MonitorModeListener sml); /** - * Set the current {@link com.jogamp.newt.ScreenMode}. - * @param screenMode to be made current, must be element of the list {@link #getScreenModes()}. - * @return true if successful, otherwise false + * @param sml {@link MonitorModeListener} to be removed from {@link MonitorEvent} */ - public abstract boolean setCurrentScreenMode(ScreenMode screenMode); + public abstract void removeMonitorModeListener(MonitorModeListener sml); // Global Screens protected static ArrayList screenList = new ArrayList(); @@ -236,6 +266,7 @@ public abstract class Screen { return null; } /** Returns the global display collection */ + @SuppressWarnings("unchecked") public static Collection getAllScreens() { ArrayList list; synchronized(screenList) { diff --git a/src/newt/classes/com/jogamp/newt/ScreenMode.java b/src/newt/classes/com/jogamp/newt/ScreenMode.java deleted file mode 100644 index 1f12217bb..000000000 --- a/src/newt/classes/com/jogamp/newt/ScreenMode.java +++ /dev/null @@ -1,208 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.newt; - -import javax.media.nativewindow.util.DimensionImmutable; - -import com.jogamp.newt.util.MonitorMode; - -/** Immutable ScreenMode Class, consisting of it's read only components:
    - *
      - *
    • {@link com.jogamp.newt.util.MonitorMode}, non rotated values
    • - *
    • rotation, measured counter clockwise (CCW)
    • - *
    - * - * Aquire and filter ScreenModes
    - *
      - *
    • A List of read only ScreenMode's is being returned by {@link com.jogamp.newt.Screen#getScreenModes()}.
    • - *
    • You may utilize {@link com.jogamp.newt.util.ScreenModeUtil} to filter and select a desired ScreenMode.
    • - *
    • The current ScreenMode can be obtained via {@link com.jogamp.newt.Screen#getCurrentScreenMode()}.
    • - *
    • The initial original ScreenMode (at startup) can be obtained via {@link com.jogamp.newt.Screen#getOriginalScreenMode()}.
    • - *
    - *
    - * - * Changing ScreenModes
    - *
      - *
    • Use {@link com.jogamp.newt.Screen#setCurrentScreenMode(com.jogamp.newt.ScreenMode)}
    • - * to change the current ScreenMode of all Screen's referenced via the full qualified name (FQN) - * {@link com.jogamp.newt.Screen#getFQName()}. - *
    • When the last FQN referenced Screen closes, the original ScreenMode ({@link com.jogamp.newt.Screen#getOriginalScreenMode()}) - * is restored.
    • - *
    - *
    - * Example for changing the ScreenMode: - *
    -        // determine target refresh rate
    -        ScreenMode orig = screen.getOriginalScreenMode();
    -        int freq = orig.getMonitorMode().getRefreshRate();
    -
    -        // target resolution
    -        Dimension res = new Dimension(800, 600);
    -
    -        // target rotation
    -        int rot = 0;
    -
    -        // filter available ScreenModes
    -        List screenModes = screen.getScreenModes();
    -        screenModes = ScreenModeUtil.filterByRate(screenModes, freq); // get the nearest ones
    -        screenModes = ScreenModeUtil.filterByRotation(screenModes, rot);
    -        screenModes = ScreenModeUtil.filterByResolution(screenModes, res); // get the nearest ones
    -        screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes);
    -
    -        // pick 1st one ..
    -        screen.setCurrentScreenMode((ScreenMode) screenModes.get(0)); 
    - * 
    - * - * X11 / AMD just works
    - *
    - * X11 / NVidia difficulties - *
    -    NVidia RANDR RefreshRate Bug
    -        If NVidia's 'DynamicTwinView' is enabled, all refresh rates are
    -        unique, ie consequent numbers starting with the default refresh, ie 50, 51, ..
    -        The only way to workaround it is to disable 'DynamicTwinView'.
    -        Read: http://us.download.nvidia.com/XFree86/Linux-x86/260.19.12/README/configtwinview.html
    -
    -        Check to see if 'DynamicTwinView' is enable:
    -            nvidia-settings -q :0/DynamicTwinview
    -
    -        To disable it (workaround), add the following option to your xorg.conf device section:
    -            Option "DynamicTwinView" "False"
    -
    -    NVidia RANDR Rotation:
    -        To enable it, add the following option to your xorg.conf device section:
    -            Option "RandRRotation" "on"
    - * 
    - * - */ -public class ScreenMode { - /** zero rotation, compared to normal settings */ - public static final int ROTATE_0 = 0; - - /** 90 degrees CCW rotation */ - public static final int ROTATE_90 = 90; - - /** 180 degrees CCW rotation */ - public static final int ROTATE_180 = 180; - - /** 270 degrees CCW rotation */ - public static final int ROTATE_270 = 270; - - MonitorMode monitorMode; - int rotation; - - public static boolean isRotationValid(int rotation) { - return rotation == ScreenMode.ROTATE_0 || rotation == ScreenMode.ROTATE_90 || - rotation == ScreenMode.ROTATE_180 || rotation == ScreenMode.ROTATE_270 ; - } - - /** - * @param monitorMode the monitor mode - * @param rotation the screen rotation, measured counter clockwise (CCW) - */ - public ScreenMode(MonitorMode monitorMode, int rotation) { - if ( !isRotationValid(rotation) ) { - throw new RuntimeException("invalid rotation: "+rotation); - } - this.monitorMode = monitorMode; - this.rotation = rotation; - } - - /** Returns the unrotated MonitorMode */ - public final MonitorMode getMonitorMode() { - return monitorMode; - } - - /** Returns the CCW rotation of this mode */ - public final int getRotation() { - return rotation; - } - - /** Returns the rotated screen width, - * derived from getMonitorMode().getSurfaceSize().getResolution() - * and getRotation() - */ - public final int getRotatedWidth() { - return getRotatedWH(true); - } - - /** Returns the rotated screen height, - * derived from getMonitorMode().getSurfaceSize().getResolution() - * and getRotation() - */ - public final int getRotatedHeight() { - return getRotatedWH(false); - } - - public final String toString() { - return "[ " + getMonitorMode() + ", " + rotation + " degr ]"; - } - - /** - * Tests equality of two ScreenMode objects - * by evaluating equality of it's components:
    - *
      - *
    • monitorMode
    • - *
    • rotation
    • - *
    - *
    - */ - public final boolean equals(Object obj) { - if (this == obj) { return true; } - if (obj instanceof ScreenMode) { - ScreenMode sm = (ScreenMode)obj; - return sm.getMonitorMode().equals(getMonitorMode()) && - sm.getRotation() == this.getRotation() ; - } - return false; - } - - /** - * Returns a combined hash code of it's elements:
    - *
      - *
    • monitorMode
    • - *
    • rotation
    • - *
    - */ - public final int hashCode() { - // 31 * x == (x << 5) - x - int hash = 31 + getMonitorMode().hashCode(); - hash = ((hash << 5) - hash) + getRotation(); - return hash; - } - - private final int getRotatedWH(boolean width) { - final DimensionImmutable d = getMonitorMode().getSurfaceSize().getResolution(); - final boolean swap = ScreenMode.ROTATE_90 == rotation || ScreenMode.ROTATE_270 == rotation ; - if ( ( width && swap ) || ( !width && !swap ) ) { - return d.getHeight(); - } - return d.getWidth(); - } -} diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index ab1eef308..0bebf330a 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -28,6 +28,8 @@ package com.jogamp.newt; +import java.util.List; + import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.KeyListener; @@ -41,6 +43,7 @@ import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.util.RectangleImmutable; /** * Specifying NEWT's Window functionality: @@ -80,10 +83,19 @@ public interface Window extends NativeWindow, WindowClosingProtocol { boolean isNativeValid(); /** - * @return The associated Screen + * @return The associated {@link Screen} */ Screen getScreen(); + /** + * Returns the {@link MonitorDevice} which {@link MonitorDevice#getViewport() viewport} + * {@link MonitorDevice#coverage(RectangleImmutable) covers} this window the most. + *

    + * If no coverage is detected the first {@link MonitorDevice} is returned. + *

    + */ + MonitorDevice getMainMonitor(); + /** * Set the CapabilitiesChooser to help determine the native visual type. * @@ -344,8 +356,32 @@ public interface Window extends NativeWindow, WindowClosingProtocol { ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate); + /** + * Enable or disable fullscreen mode for this window. + *

    + * Fullscreen mode is established on the {@link #getMainMonitor() main monitor}. + *

    + * @param fullscreen enable or disable fullscreen mode + * @return success + * @see #setFullscreen(List) + * @see #isFullscreen() + */ boolean setFullscreen(boolean fullscreen); + /** + * Enable fullscreen mode for this window spanning across the given {@link MonitorDevice}s + * or across all {@link MonitorDevice}s. + *

    + * Disable fullscreen via {@link #setFullscreen(boolean)}. + *

    + * @param monitors if null fullscreen will be spanned across all {@link MonitorDevice}s, + * otherwise across the given list of {@link MonitorDevice}. + * @return success + * @see #setFullscreen(boolean) + * @see #isFullscreen() + */ + boolean setFullscreen(List monitors); + boolean isFullscreen(); static interface FocusRunnable { diff --git a/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java new file mode 100644 index 000000000..c47936a7a --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/MonitorEvent.java @@ -0,0 +1,71 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt.event; + +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +@SuppressWarnings("serial") +public class MonitorEvent extends OutputEvent { + public static final short EVENT_MONITOR_MODE_CHANGE_NOTIFY = 600; + public static final short EVENT_MONITOR_MODE_CHANGED = 601; + + private final MonitorMode mode; + + public MonitorEvent (short eventType, MonitorDevice source, long when, MonitorMode mode) { + super(eventType, source, when); + this.mode = mode; + } + + /** Returns the {@link #getSource() source}, which is a {@link MonitorDevice}. */ + public final MonitorDevice getMonitor() { return (MonitorDevice)source; } + + public final MonitorMode getMode() { return mode; } + + public static String getEventTypeString(short type) { + switch(type) { + case EVENT_MONITOR_MODE_CHANGE_NOTIFY: return "EVENT_MONITOR_MODE_CHANGE_NOTIFY"; + case EVENT_MONITOR_MODE_CHANGED: return "EVENT_MONITOR_MODE_CHANGED"; + default: return "unknown (" + type + ")"; + } + } + + public final String toString() { + return toString(null).toString(); + } + + public final StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("MonitorEvent[").append(getEventTypeString(getEventType())).append(", source ").append(source) + .append(", mode ").append(mode).append(", "); + return super.toString(sb).append("]"); + } +} diff --git a/src/newt/classes/com/jogamp/newt/event/MonitorModeListener.java b/src/newt/classes/com/jogamp/newt/event/MonitorModeListener.java new file mode 100644 index 000000000..11e23def1 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/MonitorModeListener.java @@ -0,0 +1,37 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt.event; + +public interface MonitorModeListener { + /** called before the monitor mode will be changed */ + void monitorModeChangeNotify(MonitorEvent me); + + /** called after the monitor mode has been changed */ + void monitorModeChanged(MonitorEvent me, boolean success); +} diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index ea96f634f..c1bc791d8 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -41,9 +41,10 @@ package com.jogamp.newt.event; * * Event type registry:
    *
      - *
    • WindowEvent 100..10x
    • - *
    • MouseEvent 200..20x
    • - *
    • KeyEvent 300..30x
    • + *
    • WindowEvent 100..10x
    • + *
    • MouseEvent 200..20x
    • + *
    • KeyEvent 300..30x
    • + *
    • MonitorEvent 600..60x
    • *

    */ @SuppressWarnings("serial") diff --git a/src/newt/classes/com/jogamp/newt/event/OutputEvent.java b/src/newt/classes/com/jogamp/newt/event/OutputEvent.java new file mode 100644 index 000000000..86fa95877 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/OutputEvent.java @@ -0,0 +1,51 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt.event; + +@SuppressWarnings("serial") +public abstract class OutputEvent extends NEWTEvent +{ + protected OutputEvent(short eventType, Object source, long when) { + super(eventType, source, when); + } + + /** + public String toString() { + return toString(null).toString(); + } + + public StringBuilder toString(StringBuilder sb) { + if(null == sb) { + sb = new StringBuilder(); + } + sb.append("OutputEvent["); + super.toString(sb).append("]"); + return sb; + } */ +} diff --git a/src/newt/classes/com/jogamp/newt/event/ScreenModeListener.java b/src/newt/classes/com/jogamp/newt/event/ScreenModeListener.java deleted file mode 100644 index 7bca23cfe..000000000 --- a/src/newt/classes/com/jogamp/newt/event/ScreenModeListener.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.newt.event; - -import com.jogamp.newt.ScreenMode; - -public interface ScreenModeListener { - /** called before the screen mode will be changed */ - void screenModeChangeNotify(ScreenMode sm); - - /** called after the screen mode has been changed */ - void screenModeChanged(ScreenMode sm, boolean success); -} diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index de62747be..1500d48e6 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -34,6 +34,8 @@ package com.jogamp.newt.opengl; +import java.util.List; + import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.CapabilitiesChooser; import javax.media.nativewindow.CapabilitiesImmutable; @@ -64,6 +66,7 @@ import jogamp.opengl.GLDrawableImpl; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; @@ -224,6 +227,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return window.getScreen(); } + @Override + public final MonitorDevice getMainMonitor() { + return window.getMainMonitor(); + } + @Override public final void setTitle(String title) { window.setTitle(title); @@ -341,6 +349,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public final boolean setFullscreen(boolean fullscreen) { return window.setFullscreen(fullscreen); } + + @Override + public boolean setFullscreen(List monitors) { + return window.setFullscreen(monitors); + } @Override public final boolean isFullscreen() { diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorMode.java b/src/newt/classes/com/jogamp/newt/util/MonitorMode.java deleted file mode 100644 index 8104f207a..000000000 --- a/src/newt/classes/com/jogamp/newt/util/MonitorMode.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.newt.util; - -import javax.media.nativewindow.util.*; - -/** Immutable MonitorMode Class, consisting of it's read only components:
    - *
      - *
    • {@link javax.media.nativewindow.util.SurfaceSize} surface memory size
    • - *
    • {@link javax.media.nativewindow.util.DimensionImmutable} size in [mm]
    • - *
    • refresh rate
    • - *
    - */ -public class MonitorMode { - SurfaceSize surfaceSize; - DimensionImmutable screenSizeMM; // in [mm] - int refreshRate; - - public MonitorMode(SurfaceSize surfaceSize, DimensionImmutable screenSizeMM, int refreshRate) { - // Don't validate screenSizeMM and refreshRate, since they may not be supported by the OS - if(null==surfaceSize) { - throw new IllegalArgumentException("surfaceSize must be set ("+surfaceSize+")"); - } - this.surfaceSize=surfaceSize; - this.screenSizeMM=screenSizeMM; - this.refreshRate=refreshRate; - } - - public final SurfaceSize getSurfaceSize() { - return surfaceSize; - } - - public final DimensionImmutable getScreenSizeMM() { - return screenSizeMM; - } - - public final int getRefreshRate() { - return refreshRate; - } - - public final String toString() { - return new String("[ "+surfaceSize+" x "+refreshRate+" Hz, "+screenSizeMM+" mm ]"); - } - - /** - * Checks whether two size objects are equal. Two instances - * of MonitorMode are equal if the three components - * surfaceSize and refreshRate - * are equal. screenSizeMM is kept out intentional to reduce the requirements for finding the current mode. - * @return true if the two dimensions are equal; - * otherwise false. - */ - public final boolean equals(Object obj) { - if (this == obj) { return true; } - if (obj instanceof MonitorMode) { - MonitorMode p = (MonitorMode)obj; - return getSurfaceSize().equals(p.getSurfaceSize()) && - /* getScreenSizeMM().equals(p.getScreenSizeMM()) && */ - getRefreshRate() == p.getRefreshRate() ; - } - return false; - } - - /** - * returns a hash code over surfaceSize and refreshRate. - * screenSizeMM is kept out intentional to reduce the requirements for finding the current mode. - */ - public final int hashCode() { - // 31 * x == (x << 5) - x - int hash = 31 + getSurfaceSize().hashCode(); - /* hash = ((hash << 5) - hash) + getScreenSizeMM().hashCode(); */ - hash = ((hash << 5) - hash) + getRefreshRate(); - return hash; - } -} - diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java new file mode 100644 index 000000000..16ffe754f --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java @@ -0,0 +1,247 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.newt.util; + +import com.jogamp.newt.MonitorMode; + +import java.util.ArrayList; +import java.util.List; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.SurfaceSize; + +/** + * Convenient {@link com.jogamp.newt.MonitorMode} utility methods, + * filters etc. + */ +public class MonitorModeUtil { + + public static int getIndex(List monitorModes, MonitorMode search) { + return monitorModes.indexOf(search); + } + + public static int getIndexByHashCode(List monitorModes, MonitorMode search) { + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; i monitorModes, MonitorMode.SizeAndRRate sizeAndRate, int modeId, int rotation) { + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; i filterBySurfaceSize(List monitorModes, SurfaceSize surfaceSize) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; null!=monitorModes && i filterByRotation(List monitorModes, int rotation) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; null!=monitorModes && i filterByBpp(List monitorModes, int bitsPerPixel) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; null!=monitorModes && i filterByFlags(List monitorModes, int flags) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; null!=monitorModes && i filterByResolution(List monitorModes, DimensionImmutable resolution) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + final int resolution_sq = resolution.getHeight()*resolution.getWidth(); + int mode_dsq=Integer.MAX_VALUE, mode_dsq_idx=0; + + for (int i=0; null!=monitorModes && i filterByRate(List monitorModes, float refreshRate) { + final List out = new ArrayList(); + if( null!=monitorModes && monitorModes.size()>0 ) { + float mode_dr = Float.MAX_VALUE; + int mode_dr_idx = -1; + for (int i=0; null!=monitorModes && i getHighestAvailableBpp(List monitorModes) { + if( null!=monitorModes && monitorModes.size()>0 ) { + int highest = -1; + for (int i=0; null!=monitorModes && i < monitorModes.size(); i++) { + final MonitorMode mode = monitorModes.get(i); + final int bpp = mode.getSurfaceSize().getBitsPerPixel(); + if (bpp > highest) { + highest = bpp; + } + } + return filterByBpp(monitorModes, highest); + } + return new ArrayList(); + } + + /** + * + * @param monitorModes + * @return modes with highest available refresh rate. May return zero sized list for non. + */ + public static List getHighestAvailableRate(List monitorModes) { + if( null!=monitorModes && monitorModes.size()>0 ) { + float highest = -1; + for (int i=0; null!=monitorModes && i < monitorModes.size(); i++) { + final MonitorMode mode = monitorModes.get(i); + final float rate = mode.getRefreshRate(); + if (rate > highest) { + highest = rate; + } + } + return filterByRate(monitorModes, highest); + } + return new ArrayList(); + } + +} diff --git a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java b/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java deleted file mode 100644 index 93797c5fb..000000000 --- a/src/newt/classes/com/jogamp/newt/util/ScreenModeUtil.java +++ /dev/null @@ -1,341 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.newt.util; - -import com.jogamp.common.util.ArrayHashSet; -import com.jogamp.newt.ScreenMode; -import java.util.ArrayList; -import java.util.List; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.SurfaceSize; - -/** - * Convenient {@link com.jogamp.newt.ScreenMode} utility methods, - * filters etc. - */ -public class ScreenModeUtil { - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * 2: width and height - */ - public static final int NUM_RESOLUTION_PROPERTIES = 2; - - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * 1: bpp - */ - public static final int NUM_SURFACE_SIZE_PROPERTIES = 1; - - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * 3: ScreenSizeMM[width, height], refresh-rate - */ - public static final int NUM_MONITOR_MODE_PROPERTIES = 3; - - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * 1: rotation, native_mode_id - */ - public static final int NUM_SCREEN_MODE_PROPERTIES = 1; - - /** WARNING: must be synchronized with ScreenMode.h, native implementation - * count + all the above - */ - public static final int NUM_SCREEN_MODE_PROPERTIES_ALL = 8; - - public static int getIndex(List screenModes, ScreenMode search) { - return screenModes.indexOf(search); - } - - public static int getIndexByHashCode(List screenModes, ScreenMode search) { - for (int i=0; null!=screenModes && i filterByResolution(List screenModes, DimensionImmutable resolution) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - List out = new ArrayList(); - int resolution_sq = resolution.getHeight()*resolution.getWidth(); - int sm_dsq=resolution_sq, sm_dsq_idx=0; - - for (int i=0; null!=screenModes && i0) { - return out; - } - // nearest .. - resolution = screenModes.get(sm_dsq_idx).getMonitorMode().getSurfaceSize().getResolution(); - return filterByResolution(screenModes, resolution); - } - - public static List filterBySurfaceSize(List screenModes, SurfaceSize surfaceSize) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - List out = new ArrayList(); - for (int i=0; null!=screenModes && i0 ? out : null; - } - - public static List filterByRotation(List screenModes, int rotation) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - List out = new ArrayList(); - for (int i=0; null!=screenModes && i0 ? out : null; - } - - public static List filterByBpp(List screenModes, int bitsPerPixel) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - List out = new ArrayList(); - for (int i=0; null!=screenModes && i0 ? out : null; - } - - /** - * - * @param screenModes - * @param refreshRate - * @return modes with nearest refreshRate, or matching ones - */ - public static List filterByRate(List screenModes, int refreshRate) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - int sm_dr = refreshRate; - int sm_dr_idx = -1; - List out = new ArrayList(); - for (int i=0; null!=screenModes && i0) { - return out; - } - refreshRate = screenModes.get(sm_dr_idx).getMonitorMode().getRefreshRate(); - return filterByRate(screenModes, refreshRate); - } - - public static List getHighestAvailableBpp(List screenModes) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - int highest = -1; - for (int i=0; null!=screenModes && i < screenModes.size(); i++) { - ScreenMode sm = screenModes.get(i); - int bpp = sm.getMonitorMode().getSurfaceSize().getBitsPerPixel(); - if (bpp > highest) { - highest = bpp; - } - } - return filterByBpp(screenModes, highest); - } - - public static List getHighestAvailableRate(List screenModes) { - if(null==screenModes || screenModes.size()==0) { - return null; - } - int highest = -1; - for (int i=0; null!=screenModes && i < screenModes.size(); i++) { - ScreenMode sm = screenModes.get(i); - int rate = sm.getMonitorMode().getRefreshRate(); - if (rate > highest) { - highest = rate; - } - } - return filterByRate(screenModes, highest); - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static DimensionImmutable streamInResolution(int[] resolutionProperties, int offset) { - Dimension resolution = new Dimension(resolutionProperties[offset++], resolutionProperties[offset++]); - return resolution; - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static SurfaceSize streamInSurfaceSize(DimensionImmutable resolution, int[] sizeProperties, int offset) { - SurfaceSize surfaceSize = new SurfaceSize(resolution, sizeProperties[offset++]); - return surfaceSize; - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static MonitorMode streamInMonitorMode(SurfaceSize surfaceSize, DimensionImmutable screenSizeMM, int[] monitorProperties, int offset) { - int refreshRate = monitorProperties[offset++]; - return new MonitorMode(surfaceSize, screenSizeMM, refreshRate); - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static ScreenMode streamInScreenMode(MonitorMode monitorMode, int[] modeProperties, int offset) { - int rotation = modeProperties[offset++]; - return new ScreenMode(monitorMode, rotation); - } - - /** - * WARNING: must be synchronized with ScreenMode.h, native implementation - * - * @param modeProperties the input data - * @param offset the offset to the input data - * @return ScreenMode element matching the input modeProperties, - * or null if input could not be processed. - */ - public static ScreenMode streamIn(int[] modeProperties, int offset) { - return streamInImpl(null, null, null, null, null, modeProperties, offset); - } - - /** - * WARNING: must be synchronized with ScreenMode.h, native implementation - * - * @param resolutionPool hash array of unique resolutions, no duplicates - * @param surfaceSizePool hash array of unique SurfaceSize, no duplicates - * @param monitorModePool hash array of unique MonitorMode, no duplicates - * @param screenModePool hash array of unique ScreenMode, no duplicates - * @param modeProperties the input data - * @param offset the offset to the input data - * @return index of the identical (old or new) ScreenMode element in screenModePool, - * matching the input modeProperties, or -1 if input could not be processed. - */ - public static int streamIn(ArrayHashSet resolutionPool, - ArrayHashSet surfaceSizePool, - ArrayHashSet screenSizeMMPool, - ArrayHashSet monitorModePool, - ArrayHashSet screenModePool, - int[] modeProperties, int offset) { - ScreenMode screenMode = streamInImpl(resolutionPool, surfaceSizePool, screenSizeMMPool, monitorModePool, screenModePool, - modeProperties, offset); - return screenModePool.indexOf(screenMode); - } - - - private static ScreenMode streamInImpl(ArrayHashSet resolutionPool, - ArrayHashSet surfaceSizePool, - ArrayHashSet screenSizeMMPool, - ArrayHashSet monitorModePool, - ArrayHashSet screenModePool, - int[] modeProperties, int offset) { - int count = modeProperties[offset]; - if(NUM_SCREEN_MODE_PROPERTIES_ALL != count) { - throw new RuntimeException("NUM_SCREEN_MODE_PROPERTIES should be "+NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+count+", len "+(modeProperties.length-offset)); - } - if(NUM_SCREEN_MODE_PROPERTIES_ALL > modeProperties.length-offset) { - throw new RuntimeException("properties array too short, should be >= "+NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+(modeProperties.length-offset)); - } - offset++; - DimensionImmutable resolution = ScreenModeUtil.streamInResolution(modeProperties, offset); - offset += ScreenModeUtil.NUM_RESOLUTION_PROPERTIES; - if(null!=resolutionPool) { - resolution = resolutionPool.getOrAdd(resolution); - } - - SurfaceSize surfaceSize = ScreenModeUtil.streamInSurfaceSize(resolution, modeProperties, offset); - offset += ScreenModeUtil.NUM_SURFACE_SIZE_PROPERTIES; - if(null!=surfaceSizePool) { - surfaceSize = surfaceSizePool.getOrAdd(surfaceSize); - } - - DimensionImmutable screenSizeMM = ScreenModeUtil.streamInResolution(modeProperties, offset); - offset += ScreenModeUtil.NUM_RESOLUTION_PROPERTIES; - if(null!=screenSizeMMPool) { - screenSizeMM = screenSizeMMPool.getOrAdd(screenSizeMM); - } - - MonitorMode monitorMode = ScreenModeUtil.streamInMonitorMode(surfaceSize, screenSizeMM, modeProperties, offset); - offset += ScreenModeUtil.NUM_MONITOR_MODE_PROPERTIES - ScreenModeUtil.NUM_RESOLUTION_PROPERTIES; - if(null!=monitorModePool) { - monitorMode = monitorModePool.getOrAdd(monitorMode); - } - - ScreenMode screenMode = ScreenModeUtil.streamInScreenMode(monitorMode, modeProperties, offset); - if(null!=screenModePool) { - screenMode = screenModePool.getOrAdd(screenMode); - } - return screenMode; - } - - /** WARNING: must be synchronized with ScreenMode.h, native implementation */ - public static int[] streamOut (ScreenMode screenMode) { - int[] data = new int[NUM_SCREEN_MODE_PROPERTIES_ALL]; - int idx=0; - data[idx++] = NUM_SCREEN_MODE_PROPERTIES_ALL; - data[idx++] = screenMode.getMonitorMode().getSurfaceSize().getResolution().getWidth(); - data[idx++] = screenMode.getMonitorMode().getSurfaceSize().getResolution().getHeight(); - data[idx++] = screenMode.getMonitorMode().getSurfaceSize().getBitsPerPixel(); - data[idx++] = screenMode.getMonitorMode().getScreenSizeMM().getWidth(); - data[idx++] = screenMode.getMonitorMode().getScreenSizeMM().getHeight(); - data[idx++] = screenMode.getMonitorMode().getRefreshRate(); - data[idx++] = screenMode.getRotation(); - if(NUM_SCREEN_MODE_PROPERTIES_ALL != idx) { - throw new InternalError("wrong number of attributes: got "+idx+" != should "+NUM_SCREEN_MODE_PROPERTIES_ALL); - } - return data; - } - -} diff --git a/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java new file mode 100644 index 000000000..96daed54a --- /dev/null +++ b/src/newt/classes/jogamp/newt/MonitorDeviceImpl.java @@ -0,0 +1,147 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Rectangle; + +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.Screen; + +public class MonitorDeviceImpl extends MonitorDevice { + + public MonitorDeviceImpl(ScreenImpl screen, int nativeId, DimensionImmutable sizeMM, Rectangle viewport, MonitorMode currentMode, ArrayHashSet supportedModes) { + super(screen, nativeId, sizeMM, viewport, currentMode, supportedModes); + } + + @Override + public final MonitorMode queryCurrentMode() { + final ScreenImpl screenImpl = (ScreenImpl)screen; + final ScreenMonitorState sms = screenImpl.getScreenMonitorStatus(true); + sms.lock(); + try { + final MonitorMode mm0 = screenImpl.queryCurrentMonitorModeIntern(this); + if(null == mm0) { + throw new InternalError("getCurrentMonitorModeIntern() == null"); + } + MonitorMode mmU = supportedModes.get(mm0); // unified instance + if( null == mmU ) { + // add new mode avoiding exception! + mmU = sms.getMonitorModes().getOrAdd(mm0); + mmU = supportedModes.getOrAdd(mmU); + if( Screen.DEBUG ) { + System.err.println("Adding new mode: "+mm0+" -> "+mmU); + } + } + // if mode has changed somehow, update it .. + if( getCurrentMode().hashCode() != mmU.hashCode() ) { + setCurrentModeValue(mmU); + sms.fireScreenModeChanged(this, mmU, true); + } + return mmU; + } finally { + sms.unlock(); + } + } + + @Override + public final boolean setCurrentMode(MonitorMode mode) { + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode.0: "+this+" -> "+mode); + } + final ScreenImpl screenImpl = (ScreenImpl)screen; + final ScreenMonitorState sms = screenImpl.getScreenMonitorStatus(true); + sms.lock(); + try { + final MonitorMode mmC = queryCurrentMode(); + final MonitorMode mmU = supportedModes.get(mode); // unify via value hash + if( null == mmU ) { + throw new IllegalArgumentException("Given mode not in set of modes. Current mode "+mode+", "+this); + } + if( mmU.equals( mmC ) ) { + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode: 0.0 is-current (skip) "+mmU+" == "+mmC); + } + return true; + } + final long tStart; + if(Screen.DEBUG) { + tStart = System.nanoTime(); + } else { + tStart = 0; + } + + sms.fireScreenModeChangeNotify(this, mmU); + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireScreenModeChangeNotify() "+mmU); + } + + boolean success = screenImpl.setCurrentMonitorModeImpl(this, mmU); + if(success) { + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+mmU+", success(1): "+success); + } + } else { + // 2nd attempt validate! + final MonitorMode queriedCurrent = queryCurrentMode(); // may fireScreenModeChanged(..) if successful and differs! + success = queriedCurrent.hashCode() == mmU.hashCode() ; + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode.2: queried "+queriedCurrent); + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+mmU+", success(2): "+success); + } + } + if( success ) { + setCurrentModeValue(mmU); + modeChanged = !isOriginalMode(); + } + sms.fireScreenModeChanged(this, mmU, success); + if(Screen.DEBUG) { + System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+this+", success: "+success); + } + return success; + } finally { + sms.unlock(); + } + } + + private final void setCurrentModeValue(MonitorMode currentMode) { + this.currentMode = currentMode; + } + + /* pp */ final void setViewportValue(Rectangle viewport) { + this.viewport = viewport; + } + + /* pp */ ArrayHashSet getSupportedModesImpl() { + return supportedModes; + } + +} \ No newline at end of file diff --git a/src/newt/classes/jogamp/newt/MonitorModeProps.java b/src/newt/classes/jogamp/newt/MonitorModeProps.java new file mode 100644 index 000000000..820807e15 --- /dev/null +++ b/src/newt/classes/jogamp/newt/MonitorModeProps.java @@ -0,0 +1,355 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.newt; + +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.SurfaceSize; + +import jogamp.newt.MonitorDeviceImpl; +import jogamp.newt.ScreenImpl; + +/** + * Encodes and decodes {@link MonitorMode} and {@link MonitorDevice} properties. + */ +public class MonitorModeProps { + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 2: width, height + */ + public static final int NUM_RESOLUTION_PROPERTIES = 2; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 1: bpp + */ + public static final int NUM_SURFACE_SIZE_PROPERTIES = 1; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 2: refresh-rate (Hz*100), flags + */ + public static final int NUM_SIZEANDRATE_PROPERTIES = 2; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 2: id, rotation + */ + public static final int NUM_MONITOR_MODE_PROPERTIES = 2; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * count + all the above + */ + public static final int NUM_MONITOR_MODE_PROPERTIES_ALL = 8; + + public static final int IDX_MONITOR_MODE_BPP = 1 // count + + MonitorModeProps.NUM_RESOLUTION_PROPERTIES + ; + public static final int IDX_MONITOR_MODE_ROT = 1 // count + + MonitorModeProps.NUM_RESOLUTION_PROPERTIES + + MonitorModeProps.NUM_SURFACE_SIZE_PROPERTIES + + MonitorModeProps.NUM_SIZEANDRATE_PROPERTIES + + 1 // id of MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES + ; + + /** WARNING: must be synchronized with ScreenMode.h, native implementation + * 10: count + id, ScreenSizeMM[width, height], rotated Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ + */ + public static final int MIN_MONITOR_DEVICE_PROPERTIES = 11; + + public static final int IDX_MONITOR_DEVICE_VIEWPORT = 1 // count + + 1 // native mode + + MonitorModeProps.NUM_RESOLUTION_PROPERTIES // sizeMM + ; + + public static class Cache { + public final ArrayHashSet resolutions = new ArrayHashSet(); + public final ArrayHashSet surfaceSizes = new ArrayHashSet(); + public final ArrayHashSet sizeAndRates = new ArrayHashSet(); + public final ArrayHashSet monitorModes = new ArrayHashSet(); + public final ArrayHashSet monitorDevices = new ArrayHashSet(); + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + private static DimensionImmutable streamInResolution(int[] resolutionProperties, int offset) { + Dimension resolution = new Dimension(resolutionProperties[offset++], resolutionProperties[offset++]); + return resolution; + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + private static SurfaceSize streamInSurfaceSize(DimensionImmutable resolution, int[] sizeProperties, int offset) { + SurfaceSize surfaceSize = new SurfaceSize(resolution, sizeProperties[offset++]); + return surfaceSize; + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + private static MonitorMode.SizeAndRRate streamInSizeAndRRate(SurfaceSize surfaceSize, int[] sizeAndRRateProperties, int offset) { + final float refreshRate = sizeAndRRateProperties[offset++]/100.0f; + final int flags = sizeAndRRateProperties[offset++]; + return new MonitorMode.SizeAndRRate(surfaceSize, refreshRate, flags); + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + private static MonitorMode streamInMonitorMode0(MonitorMode.SizeAndRRate sizeAndRate, int[] modeProperties, int offset) { + final int id = modeProperties[offset++]; + final int rotation = modeProperties[offset++]; + return new MonitorMode(id, sizeAndRate, rotation); + } + + /** + * WARNING: must be synchronized with ScreenMode.h, native implementation + * + * @param mode_idx if not null and cache is given, returns the index of resulting {@link MonitorMode} within {@link Cache#monitorModes}. + * @param cache optional hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates + * @param modeProperties the input data + * @param offset the offset to the input data + * @return {@link MonitorMode} of the identical (old or new) element in {@link Cache#monitorModes}, + * matching the input modeProperties, or null if input could not be processed. + */ + public static MonitorMode streamInMonitorMode(int[] mode_idx, Cache cache, + int[] modeProperties, int offset) { + final int count = modeProperties[offset]; + if(NUM_MONITOR_MODE_PROPERTIES_ALL != count) { + throw new RuntimeException("property count should be "+NUM_MONITOR_MODE_PROPERTIES_ALL+", but is "+count+", len "+(modeProperties.length-offset)); + } + if(NUM_MONITOR_MODE_PROPERTIES_ALL > modeProperties.length-offset) { + throw new RuntimeException("properties array too short, should be >= "+NUM_MONITOR_MODE_PROPERTIES_ALL+", is "+(modeProperties.length-offset)); + } + offset++; + DimensionImmutable resolution = MonitorModeProps.streamInResolution(modeProperties, offset); + offset += MonitorModeProps.NUM_RESOLUTION_PROPERTIES; + if(null!=cache) { + resolution = cache.resolutions.getOrAdd(resolution); + } + + SurfaceSize surfaceSize = MonitorModeProps.streamInSurfaceSize(resolution, modeProperties, offset); + offset += MonitorModeProps.NUM_SURFACE_SIZE_PROPERTIES; + if(null!=cache) { + surfaceSize = cache.surfaceSizes.getOrAdd(surfaceSize); + } + + MonitorMode.SizeAndRRate sizeAndRate = MonitorModeProps.streamInSizeAndRRate(surfaceSize, modeProperties, offset); + offset += MonitorModeProps.NUM_SIZEANDRATE_PROPERTIES; + if(null!=cache) { + sizeAndRate = cache.sizeAndRates.getOrAdd(sizeAndRate); + } + + MonitorMode monitorMode = MonitorModeProps.streamInMonitorMode0(sizeAndRate, modeProperties, offset); + if(null!=cache) { + monitorMode = cache.monitorModes.getOrAdd(monitorMode); + } + if( null != mode_idx && null!=cache) { + int _modeIdx = cache.monitorModes.indexOf(monitorMode); + if( 0 > _modeIdx ) { + throw new InternalError("Invalid index of current unified mode "+monitorMode); + } + mode_idx[0] = _modeIdx; + } + return monitorMode; + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + public static int[] streamOutMonitorMode (MonitorMode monitorMode) { + int[] data = new int[NUM_MONITOR_MODE_PROPERTIES_ALL]; + int idx=0; + data[idx++] = NUM_MONITOR_MODE_PROPERTIES_ALL; + data[idx++] = monitorMode.getSurfaceSize().getResolution().getWidth(); + data[idx++] = monitorMode.getSurfaceSize().getResolution().getHeight(); + data[idx++] = monitorMode.getSurfaceSize().getBitsPerPixel(); + data[idx++] = (int)(monitorMode.getRefreshRate()*100.0f); // Hz*100 + data[idx++] = monitorMode.getFlags(); + data[idx++] = monitorMode.getId(); + data[idx++] = monitorMode.getRotation(); + if(NUM_MONITOR_MODE_PROPERTIES_ALL != idx) { + throw new InternalError("wrong number of attributes: got "+idx+" != should "+NUM_MONITOR_MODE_PROPERTIES_ALL); + } + return data; + } + + /** + * WARNING: must be synchronized with ScreenMode.h, native implementation + *

    + * Note: This variant only works for impl. w/ a unique mode key pair modeId, rotation. + *

    + * @param mode_idx if not null, returns the index of resulting {@link MonitorDevice} within {@link Cache#monitorDevices}. + * @param cache hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates + * @param modeProperties the input data + * @param offset the offset to the input data + * @return {@link MonitorDevice} of the identical (old or new) element in {@link Cache#monitorDevices}, + * matching the input modeProperties, or null if input could not be processed. + */ + public static MonitorDevice streamInMonitorDevice(int[] monitor_idx, Cache cache, ScreenImpl screen, int[] monitorProperties, int offset) { + // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ + final int count = monitorProperties[offset]; + if(MIN_MONITOR_DEVICE_PROPERTIES > count) { + throw new RuntimeException("property count should be >= "+MIN_MONITOR_DEVICE_PROPERTIES+", but is "+count+", len "+(monitorProperties.length-offset)); + } + if(MIN_MONITOR_DEVICE_PROPERTIES > monitorProperties.length-offset) { + throw new RuntimeException("properties array too short (min), should be >= "+MIN_MONITOR_DEVICE_PROPERTIES+", is "+(monitorProperties.length-offset)); + } + if(count > monitorProperties.length-offset) { + throw new RuntimeException("properties array too short (count), should be >= "+count+", is "+(monitorProperties.length-offset)); + } + final int limit = offset + count; + offset++; + final List allMonitorModes = cache.monitorModes.getData(); + final int id = monitorProperties[offset++]; + final DimensionImmutable sizeMM = streamInResolution(monitorProperties, offset); offset+=NUM_RESOLUTION_PROPERTIES; + final Rectangle viewport = new Rectangle(monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++]); + final MonitorMode currentMode; + { + final int modeId = monitorProperties[offset++]; + final int rotation = monitorProperties[offset++]; + currentMode = getByNativeIdAndRotation(allMonitorModes, modeId, rotation); + } + final ArrayHashSet supportedModes = new ArrayHashSet(); + while( offset < limit ) { + final int modeId = monitorProperties[offset++]; + for (int i=0; i _monitorIdx ) { + throw new InternalError("Invalid index of current unified mode "+monitorDevice); + } + monitor_idx[0] = _monitorIdx; + } + return monitorDevice; + } + private static MonitorMode getByNativeIdAndRotation(List monitorModes, int modeId, int rotation) { + if( null!=monitorModes && monitorModes.size()>0 ) { + for (int i=0; i + * This variant expects count to be {@link MIN_MONITOR_DEVICE_PROPERTIES} - 1 - {@link NUM_MONITOR_MODE_PROPERTIES}, + * due to lack of supported mode and current mode. + *

    + * + * @param mode_idx if not null, returns the index of resulting {@link MonitorDevice} within {@link Cache#monitorDevices}. + * @param cache hash arrays of unique {@link MonitorMode} components and {@link MonitorDevice}s, allowing to avoid duplicates + * @param supportedModes pre-assembled list of supported {@link MonitorMode}s from cache. + * @param currentMode pre-fetched current {@link MonitorMode}s from cache. + * @param modeProperties the input data minus supported modes! + * @param offset the offset to the input data + * @return {@link MonitorDevice} of the identical (old or new) element in {@link Cache#monitorDevices}, + * matching the input modeProperties, or null if input could not be processed. + */ + public static MonitorDevice streamInMonitorDevice(int[] monitor_idx, Cache cache, ScreenImpl screen, ArrayHashSet supportedModes, MonitorMode currentMode, int[] monitorProperties, int offset) { + // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ + final int count = monitorProperties[offset]; + if(MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES != count) { + throw new RuntimeException("property count should be == "+(MIN_MONITOR_DEVICE_PROPERTIES-1-NUM_MONITOR_MODE_PROPERTIES)+", but is "+count+", len "+(monitorProperties.length-offset)); + } + if(MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES > monitorProperties.length-offset) { + throw new RuntimeException("properties array too short (min), should be >= "+(MIN_MONITOR_DEVICE_PROPERTIES-1-NUM_MONITOR_MODE_PROPERTIES)+", is "+(monitorProperties.length-offset)); + } + if(count > monitorProperties.length-offset) { + throw new RuntimeException("properties array too short (count), should be >= "+count+", is "+(monitorProperties.length-offset)); + } + offset++; + final int id = monitorProperties[offset++]; + final DimensionImmutable sizeMM = streamInResolution(monitorProperties, offset); offset+=NUM_RESOLUTION_PROPERTIES; + final Rectangle viewport = new Rectangle(monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++], monitorProperties[offset++]); + MonitorDevice monitorDevice = new MonitorDeviceImpl(screen, id, sizeMM, viewport, currentMode, supportedModes); + if(null!=cache) { + monitorDevice = cache.monitorDevices.getOrAdd(monitorDevice); + } + if( null != monitor_idx ) { + int _monitorIdx = cache.monitorDevices.indexOf(monitorDevice); + if( 0 > _monitorIdx ) { + throw new InternalError("Invalid index of current unified mode "+monitorDevice); + } + monitor_idx[0] = _monitorIdx; + } + return monitorDevice; + } + + /** WARNING: must be synchronized with ScreenMode.h, native implementation */ + public static int[] streamOutMonitorDevice (MonitorDevice monitorDevice) { + // min 11: count, id, ScreenSizeMM[width, height], Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ + int supportedModeCount = monitorDevice.getSupportedModes().size(); + if( 0 == supportedModeCount ) { + throw new RuntimeException("no supported modes: "+monitorDevice); + } + int[] data = new int[MIN_MONITOR_DEVICE_PROPERTIES + supportedModeCount - 1]; + int idx=0; + data[idx++] = data.length; + data[idx++] = monitorDevice.getId(); + data[idx++] = monitorDevice.getSizeMM().getWidth(); + data[idx++] = monitorDevice.getSizeMM().getHeight(); + data[idx++] = monitorDevice.getViewport().getX(); + data[idx++] = monitorDevice.getViewport().getY(); + data[idx++] = monitorDevice.getViewport().getWidth(); + data[idx++] = monitorDevice.getViewport().getHeight(); + data[idx++] = monitorDevice.getCurrentMode().getId(); + data[idx++] = monitorDevice.getCurrentMode().getRotation(); + final List supportedModes = monitorDevice.getSupportedModes(); + for(int i=0; i monitors) { + return false; // nop + } + + protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { sizeChanged(false, width, height, false); if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 1282e5dc5..4d20fdb83 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -43,22 +43,19 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Point; -import javax.media.nativewindow.util.SurfaceSize; - +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; import com.jogamp.common.util.ArrayHashSet; -import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; -import com.jogamp.newt.util.MonitorMode; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; -public abstract class ScreenImpl extends Screen implements ScreenModeListener { +public abstract class ScreenImpl extends Screen implements MonitorModeListener { protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); public static final int default_sm_bpp = 32; @@ -73,11 +70,11 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { protected int hashCode; protected AbstractGraphicsScreen aScreen; protected int refCount; // number of Screen references by Window - protected Point vOrigin = new Point(0, 0); // virtual top-left origin - protected Dimension vSize = new Dimension(0, 0); // virtual rotated screen size + protected Rectangle vOriginSize = new Rectangle(0, 0, 0, 0); // virtual rotated screen origin and size protected static Dimension usrSize = null; // property values: newt.ws.swidth and newt.ws.sheight protected static volatile boolean usrSizeQueried = false; - private ArrayList referencedScreenModeListener = new ArrayList(); + private ArrayList referencedScreenModeListener = new ArrayList(); + private long tCreated; // creationTime static { @@ -160,10 +157,12 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { return true; } + @Override public int hashCode() { return hashCode; } + @Override public synchronized final void createNative() throws NativeWindowException { @@ -182,8 +181,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen"); } - initScreenModeStatus(); - updateVirtualScreenOriginAndSize(); + initScreenMonitorState(); if(DEBUG) { System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); } @@ -191,10 +189,11 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { screensActive++; } } - ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); + ScreenMonitorState sms = ScreenMonitorState.getScreenMonitorState(this.getFQName()); sms.addListener(this); } + @Override public synchronized final void destroy() { releaseScreenModeStatus(); @@ -213,6 +212,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { display.removeReference(); } + @Override public synchronized final int addReference() throws NativeWindowException { if(DEBUG) { System.err.println("Screen.addReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount+1)); @@ -227,6 +227,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { return ++refCount; } + @Override public synchronized final int removeReference() { if(DEBUG) { System.err.println("Screen.removeReference() ("+DisplayImpl.getThreadName()+"): "+refCount+" -> "+(refCount-1)); @@ -240,6 +241,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { return refCount; } + @Override public synchronized final int getReferenceCount() { return refCount; } @@ -259,14 +261,20 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { /** * Stores the virtual origin and virtual rotated screen size. *

    - * This method is called after the ScreenMode has been set, + * This method is called after the ScreenMode has been set or changed, * hence you may utilize it. - *

    - * @param virtualOrigin the store for the virtual origin - * @param virtualSize the store for the virtual rotated size + *

    + *

    + * Default implementation uses the union of all monitor's viewport, + * calculated via {@link #unionOfMonitorViewportSize()}. + *

    + * @param vOriginSize storage for result */ - protected abstract void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize); + protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) { + unionOfMonitorViewportSize(vOriginSize); + } + @Override public final String getFQName() { return fqname; } @@ -275,258 +283,227 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { * Updates the rotated virtual ScreenSize using the native impl. */ protected void updateVirtualScreenOriginAndSize() { - getVirtualScreenOriginAndSize(vOrigin, vSize); - if(DEBUG) { - System.err.println("Detected virtual screen origin "+vOrigin+", size "+vSize); + if(null != usrSize ) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(usrSize.getWidth()); + vOriginSize.setHeight(usrSize.getHeight()); + if(DEBUG) { + System.err.println("User virtual screen viewport "+vOriginSize); + } + } else { + calcVirtualScreenOriginAndSize(vOriginSize); + if(DEBUG) { + System.err.println("Detected virtual screen viewport "+vOriginSize); + } } } + @Override public final Display getDisplay() { return display; } + @Override public final int getIndex() { return screen_idx; } + @Override public final AbstractGraphicsScreen getGraphicsScreen() { return aScreen; } + @Override public synchronized final boolean isNativeValid() { return null != aScreen; } - public int getX() { return vOrigin.getX(); } - public int getY() { return vOrigin.getY(); } - - public final int getWidth() { - return (null != usrSize) ? usrSize.getWidth() : vSize.getWidth(); - } - - public final int getHeight() { - return (null != usrSize) ? usrSize.getHeight() : vSize.getHeight(); - } + @Override + public final int getX() { return vOriginSize.getX(); } + @Override + public final int getY() { return vOriginSize.getY(); } + @Override + public final int getWidth() { return vOriginSize.getWidth(); } + @Override + public final int getHeight() { return vOriginSize.getHeight(); } + @Override + public final RectangleImmutable getViewport() { return vOriginSize; } @Override public String toString() { - return "NEWT-Screen["+getFQName()+", idx "+screen_idx+", refCount "+refCount+", "+getWidth()+"x"+getHeight()+", "+aScreen+", "+display+"]"; + return "NEWT-Screen["+getFQName()+", idx "+screen_idx+", refCount "+refCount+", vsize "+vOriginSize+", "+aScreen+", "+display+ + ", monitors: "+getMonitorDevices()+"]"; } - public final List getScreenModes() { - ArrayHashSet screenModes = getScreenModesOrig(); - if(null != screenModes && 0 < screenModes.size()) { - return screenModes.toArrayList(); - } - return null; + // + // MonitorDevice and MonitorMode + // + + /** + * To be implemented by the native specification.
    + * Is called within a thread safe environment.
    + * Is called only to collect the {@link MonitorMode}s and {@link MonitorDevice}s, usually at startup setting up modes.
    + *
    + * WARNING: must be synchronized with + *
      + *
    • {@link MonitorModeProps#NUM_SCREEN_MODE_PROPERTIES} and
    • + *
    • {@link MonitorModeProps#MIN_MONITOR_DEVICE_PROPERTIES}
    • + *
    , i.e. + *
      + *
    • {@link MonitorModeProps#streamInMonitorDevice(int[], jogamp.newt.MonitorModeProps.Cache, ScreenImpl, int[], int)}
    • + *
    • {@link MonitorModeProps#streamInMonitorDevice(int[], jogamp.newt.MonitorModeProps.Cache, ScreenImpl, ArrayHashSet, int[], int)}
    • + *
    • {@link MonitorModeProps#streamInMonitorMode(int[], jogamp.newt.MonitorModeProps.Cache, int[], int)}
    • + *
    + * @param cache memory pool caching the result + */ + protected abstract void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache); + + protected Rectangle getNativeMonitorDeviceViewportImpl(MonitorDevice monitor) { return null; } + + /** + * To be implemented by the native specification.
    + * Is called within a thread safe environment.
    + *

    + * Implementation shall not unify the result w/ monitor's supported modes or a locally + * saved {@link MonitorModeProps.Cache}, since caller will perform such tasks. + *

    + */ + protected abstract MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor); + + /** + * To be implemented by the native specification.
    + * Is called within a thread safe environment.
    + */ + protected abstract boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode); + + @Override + public final List getMonitorModes() { + final ScreenMonitorState sms = getScreenMonitorStatus(false); + return null != sms ? sms.getMonitorModes().getData() : null; + } + + @Override + public final List getMonitorDevices() { + final ScreenMonitorState sms = getScreenMonitorStatus(false); + return null != sms ? sms.getMonitorDevices().getData() : null; } - private final ScreenModeStatus getScreenModeStatus(boolean throwException) { + final ScreenMonitorState getScreenMonitorStatus(boolean throwException) { final String key = this.getFQName(); - final ScreenModeStatus res = ScreenModeStatus.getScreenModeStatus(key); + final ScreenMonitorState res = ScreenMonitorState.getScreenMonitorState(key); if(null == res & throwException) { - throw new InternalError("ScreenModeStatus.getScreenModeStatus("+key+") == null"); + throw new InternalError("ScreenMonitorStatus.getScreenModeStatus("+key+") == null"); } return res; } - public ScreenMode getOriginalScreenMode() { - final ScreenModeStatus sms = getScreenModeStatus(false); - return ( null != sms ) ? sms.getOriginalScreenMode() : null ; - } - - public ScreenMode getCurrentScreenMode() { - ScreenMode smU = null; - final ScreenModeStatus sms = getScreenModeStatus(true); - final ScreenMode sm0 = getCurrentScreenModeIntern(); - if(null == sm0) { - throw new InternalError("getCurrentScreenModeImpl() == null"); + @Override + public void monitorModeChangeNotify(MonitorEvent me) { + if(DEBUG) { + System.err.println("monitorModeChangeNotify: "+me); } - sms.lock(); - try { - smU = sms.getScreenModes().getOrAdd(sm0); // unified instance, maybe new - - // if mode has changed somehow, update it .. - if( sms.getCurrentScreenMode().hashCode() != smU.hashCode() ) { - sms.fireScreenModeChanged(smU, true); - } - } finally { - sms.unlock(); + for(int i=0; i monitors = getMonitorDevices(); + for(int i=monitors.size()-1; i>=0; i--) { + final MonitorDeviceImpl monitor = (MonitorDeviceImpl) monitors.get(i); + final Rectangle newViewport = getNativeMonitorDeviceViewportImpl(monitor); + if( DEBUG ) { + System.err.println("Screen.updateMonitorViewport["+i+"]: "+monitor.getViewport()+" -> "+newViewport); } - - sms.fireScreenModeChangeNotify(smU); - if(DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireScreenModeChangeNotify() "+smU); + if( null != newViewport ) { + monitor.setViewportValue(newViewport); } - - success = setCurrentScreenModeImpl(smU); - if(success) { - if(DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success(1): "+success); - } - } else { - // 2nd attempt validate! - final ScreenMode queriedCurrent = getCurrentScreenMode(); // may fireScreenModeChanged(..) if successful and differs! - final ScreenMode smsCurrent = sms.getCurrentScreenMode(); - success = smsCurrent.hashCode() == smU.hashCode() && queriedCurrent.hashCode() == smU.hashCode() ; - if(DEBUG) { - System.err.println("Screen.setCurrentScreenMode.2: queried "+queriedCurrent); - System.err.println("Screen.setCurrentScreenMode.2: SMS "+smsCurrent); - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success(2): "+success); - } - } - sms.fireScreenModeChanged(smU, success); - if(DEBUG) { - System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+smU+", success: "+success); - } - } finally { - sms.unlock(); - } - return success; + } } - - public void screenModeChangeNotify(ScreenMode sm) { - for(int i=0; i getScreenModesOrig() { - ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); - if(null!=sms) { - return sms.getScreenModes(); - } - return null; - } - - /** ScreenModeStatus bridge to native implementation */ - protected final IntIntHashMap getScreenModesIdx2NativeIdx() { - ScreenModeStatus sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); - if(null!=sms) { - return sms.getScreenModesIdx2NativeIdx(); - } - return null; - } - - /** - * To be implemented by the native specification.
    - * Is called within a thread safe environment.
    - * Is called only to collect the ScreenModes, usually at startup setting up modes.
    - *
    - * WARNING: must be synchronized with {@link com.jogamp.newt.util.ScreenModeUtil#NUM_SCREEN_MODE_PROPERTIES}, - * ie {@link com.jogamp.newt.util.ScreenModeUtil#streamIn(com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, int[], int)}
    - *
    - * Note: Additional 1st element is native mode id. - */ - protected int[] getScreenModeFirstImpl() { - return null; - } - - /** - * To be implemented by the native specification.
    - * Is called within a thread safe environment.
    - * Is called only to collect the ScreenModes, usually at startup setting up modes.
    - *
    - * WARNING: must be synchronized with {@link com.jogamp.newt.util.ScreenModeUtil#NUM_SCREEN_MODE_PROPERTIES}, - * ie {@link com.jogamp.newt.util.ScreenModeUtil#streamIn(com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, com.jogamp.common.util.ArrayHashSet, int[], int)}
    - *
    - * Note: Additional 1st element is native mode id. - */ - protected int[] getScreenModeNextImpl() { - return null; + + private final MonitorMode getVirtualMonitorMode(int modeId) { + final int[] props = new int[MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = getWidth(); // width + props[i++] = getHeight(); // height + props[i++] = default_sm_bpp; + props[i++] = default_sm_rate * 100; + props[i++] = 0; // flags + props[i++] = modeId; + props[i++] = default_sm_rotation; + if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { + throw new InternalError("XX"); + } + return MonitorModeProps.streamInMonitorMode(null, null, props, 0); } - - /** - * To be implemented by the native specification.
    - * Is called within a thread safe environment.
    - */ - protected ScreenMode getCurrentScreenModeImpl() { - return null; + + private final MonitorDevice getVirtualMonitorDevice(int monitorId, MonitorMode currentMode) { + int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES]; + int i = 0; + props[i++] = MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES; + props[i++] = monitorId; + props[i++] = default_sm_widthmm; + props[i++] = default_sm_heightmm; + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = currentMode.getRotatedWidth(); // rotated viewport width + props[i++] = currentMode.getRotatedHeight(); // rotated viewport height + props[i++] = currentMode.getId(); // current mode id + props[i++] = currentMode.getRotation(); + props[i++] = currentMode.getId(); // supported mode id #1 + if( MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES != i ) { + throw new InternalError("XX"); + } + return MonitorModeProps.streamInMonitorDevice(null, null, this, props, 0); } /** - * Utilizes {@link #getCurrentScreenModeImpl()}, if the latter returns null it uses + * Utilizes {@link #getCurrentMonitorModeImpl()}, if the latter returns null it uses * the current screen size and dummy values. */ - protected ScreenMode getCurrentScreenModeIntern() { - ScreenMode res; + protected final MonitorMode queryCurrentMonitorModeIntern(MonitorDevice monitor) { + MonitorMode res; if(DEBUG_TEST_SCREENMODE_DISABLED) { res = null; } else { - res = getCurrentScreenModeImpl(); + res = queryCurrentMonitorModeImpl(monitor); } if(null == res) { if( 0>=getWidth() || 0>=getHeight() ) { updateVirtualScreenOriginAndSize(); } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; - int i = 0; - props[i++] = 0; // set later for verification of iterator - props[i++] = getWidth(); // width - props[i++] = getHeight(); // height - props[i++] = default_sm_bpp; - props[i++] = default_sm_widthmm; - props[i++] = default_sm_heightmm; - props[i++] = default_sm_rate; - props[i++] = default_sm_rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - res = ScreenModeUtil.streamIn(props, 0); + res = getVirtualMonitorMode(monitor.getCurrentMode().getId()); } return res; } - /** - * To be implemented by the native specification.
    - * Is called within a thread safe environment.
    - */ - protected boolean setCurrentScreenModeImpl(ScreenMode screenMode) { - return false; - } - - private ScreenModeStatus initScreenModeStatus() { + private final ScreenMonitorState initScreenMonitorState() { long t0; if(DEBUG) { t0 = System.nanoTime(); @@ -535,138 +512,139 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener { t0 = 0; } - ScreenModeStatus sms; - ScreenModeStatus.lockScreenModeStatus(); + boolean vScrnSizeUpdated = false; + ScreenMonitorState sms; + ScreenMonitorState.lockScreenMonitorState(); try { - sms = ScreenModeStatus.getScreenModeStatus(this.getFQName()); - if(null==sms) { - IntIntHashMap screenModesIdx2NativeIdx = new IntIntHashMap(); - final ScreenMode currentSM = getCurrentScreenModeIntern(); - if(null == currentSM) { - throw new InternalError("getCurrentScreenModeImpl() == null"); + sms = ScreenMonitorState.getScreenMonitorState(this.getFQName()); + if(null==sms) { + final MonitorModeProps.Cache cache = new MonitorModeProps.Cache(); + if( 0 >= collectNativeMonitorModes(cache) ) { + updateVirtualScreenOriginAndSize(); + vScrnSizeUpdated = true; + final MonitorMode mode = getVirtualMonitorMode(0); + cache.monitorModes.getOrAdd(mode); + final MonitorDevice monitor = getVirtualMonitorDevice(0, mode); + cache.monitorDevices.getOrAdd(monitor); } - - ArrayHashSet screenModes = collectNativeScreenModes(screenModesIdx2NativeIdx); - screenModes.getOrAdd(currentSM); if(DEBUG) { int i=0; - for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { - System.err.println(i+": "+iter.next()); + for(Iterator iMode=cache.monitorModes.iterator(); iMode.hasNext(); i++) { + System.err.println("All["+i+"]: "+iMode.next()); + } + i=0; + for(Iterator iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); i++) { + final MonitorDevice crt = iMonitor.next(); + System.err.println("["+i+"]: "+crt); + int j=0; + for(Iterator iMode=crt.getSupportedModes().iterator(); iMode.hasNext(); j++) { + System.err.println("["+i+"]["+j+"]: "+iMode.next()); + } } } - - sms = new ScreenModeStatus(screenModes, screenModesIdx2NativeIdx); - ScreenMode originalScreenMode0 = screenModes.get(currentSM); // unify via value hash - if(null == originalScreenMode0) { - throw new RuntimeException(currentSM+" could not be hashed from ScreenMode list"); - } - sms.setOriginalScreenMode(originalScreenMode0); - ScreenModeStatus.mapScreenModeStatus(this.getFQName(), sms); + sms = new ScreenMonitorState(cache.monitorDevices, cache.monitorModes); + ScreenMonitorState.mapScreenMonitorState(this.getFQName(), sms); } } finally { - ScreenModeStatus.unlockScreenModeStatus(); + ScreenMonitorState.unlockScreenMonitorState(); } if(DEBUG) { System.err.println("Screen.initScreenModeStatus() END dt "+ (System.nanoTime()-t0)/1e6 +"ms"); } + if( !vScrnSizeUpdated ) { + updateVirtualScreenOriginAndSize(); + } + return sms; } - /** ignores bpp < 15 */ - private ArrayHashSet collectNativeScreenModes(IntIntHashMap screenModesIdx2NativeId) { - ArrayHashSet resolutionPool = new ArrayHashSet(); - ArrayHashSet surfaceSizePool = new ArrayHashSet(); - ArrayHashSet screenSizeMMPool = new ArrayHashSet(); - ArrayHashSet monitorModePool = new ArrayHashSet(); - ArrayHashSet screenModePool = new ArrayHashSet(); - - int[] smProps = null; - int num = 0; - final int idxBpp = 1 // native mode - + 1 // count - + ScreenModeUtil.NUM_RESOLUTION_PROPERTIES - + ScreenModeUtil.NUM_SURFACE_SIZE_PROPERTIES - - 1 ; // index 0 based - do { - if(DEBUG_TEST_SCREENMODE_DISABLED) { - smProps = null; - } else if(0 == num) { - smProps = getScreenModeFirstImpl(); - } else { - smProps = getScreenModeNextImpl(); - } - if(null != smProps && 0 < smProps.length && smProps[idxBpp] >= 15) { - int nativeId = smProps[0]; - int screenModeIdx = ScreenModeUtil.streamIn(resolutionPool, surfaceSizePool, screenSizeMMPool, - monitorModePool, screenModePool, smProps, 1); - if(DEBUG) { - System.err.println("ScreenImpl.collectNativeScreenModes: #"+num+": idx: "+nativeId+" native -> "+screenModeIdx+" newt"); + /** + * Returns the number of successful collected {@link MonitorDevice}s. + *

    + * Collects {@link MonitorDevice}s and {@link MonitorMode}s within the given cache. + *

    + */ + private final int collectNativeMonitorModes(MonitorModeProps.Cache cache) { + if(!DEBUG_TEST_SCREENMODE_DISABLED) { + collectNativeMonitorModesAndDevicesImpl(cache); + } + // filter out insufficient modes + for(int i=cache.monitorModes.size()-1; i>=0; i--) { + final MonitorMode mode = cache.monitorModes.get(i); + if( 16 > mode.getSurfaceSize().getBitsPerPixel() ) { + boolean keep = false; + for(int j=cache.monitorDevices.size()-1; !keep && j>=0; j--) { + final MonitorDevice monitor = cache.monitorDevices.get(j); + keep = monitor.getCurrentMode().equals(mode); } - - if(screenModeIdx >= 0) { - screenModesIdx2NativeId.put(screenModeIdx, nativeId); + if(!keep) { + cache.monitorModes.remove(i); + for(int j=cache.monitorDevices.size()-1; j>=0; j--) { + final MonitorDeviceImpl monitor = (MonitorDeviceImpl) cache.monitorDevices.get(j); + monitor.getSupportedModesImpl().remove(mode); + } } - } else if(DEBUG) { - System.err.println("ScreenImpl.collectNativeScreenModes: #"+num+": smProps: "+(null!=smProps)+ - ", len: "+(null != smProps ? smProps.length : 0)+ - ", bpp: "+(null != smProps && 0 < smProps.length ? smProps[idxBpp] : 0)+ - " - DROPPING"); } - num++; - } while ( null != smProps && 0 < smProps.length ); - - if(DEBUG) { - System.err.println("ScreenImpl.collectNativeScreenModes: ScreenMode number : "+screenModePool.size()); - System.err.println("ScreenImpl.collectNativeScreenModes: MonitorMode number : "+monitorModePool.size()); - System.err.println("ScreenImpl.collectNativeScreenModes: ScreenSizeMM number: "+screenSizeMMPool.size()); - System.err.println("ScreenImpl.collectNativeScreenModes: SurfaceSize number : "+surfaceSizePool.size()); - System.err.println("ScreenImpl.collectNativeScreenModes: Resolution number : "+resolutionPool.size()); } - - return screenModePool; + if( DEBUG ) { + System.err.println("ScreenImpl.collectNativeMonitorModes: MonitorDevice number : "+cache.monitorDevices.size()); + System.err.println("ScreenImpl.collectNativeMonitorModes: MonitorMode number : "+cache.monitorModes.size()); + System.err.println("ScreenImpl.collectNativeMonitorModes: SizeAndRate number : "+cache.sizeAndRates.size()); + System.err.println("ScreenImpl.collectNativeMonitorModes: SurfaceSize number : "+cache.surfaceSizes.size()); + System.err.println("ScreenImpl.collectNativeMonitorModes: Resolution number : "+cache.resolutions.size()); + } + return cache.monitorDevices.size(); } private void releaseScreenModeStatus() { - ScreenModeStatus sms; - ScreenModeStatus.lockScreenModeStatus(); + ScreenMonitorState sms; + ScreenMonitorState.lockScreenMonitorState(); try { - sms = ScreenModeStatus.getScreenModeStatus(getFQName()); + sms = ScreenMonitorState.getScreenMonitorState(getFQName()); if(null != sms) { sms.lock(); try { if(0 == sms.removeListener(this)) { - if(sms.isOriginalModeChangedByOwner()) { - System.err.println("Screen.destroy(): "+sms.getCurrentScreenMode()+" -> "+sms.getOriginalScreenMode()); - try { - setCurrentScreenMode(sms.getOriginalScreenMode()); - } catch (Throwable t) { - // be verbose but continue - t.printStackTrace(); + final ArrayList monitorDevices = sms.getMonitorDevices().getData(); + for(int i=0; i "+sms.getOriginalScreenMode()); - setCurrentScreenModeImpl(sms.getOriginalScreenMode()); - } catch (Throwable t) { - // be quiet .. shutdown + final ArrayList monitorDevices = sms.getMonitorDevices().getData(); + for(int i=0; i screenModes; - private IntIntHashMap screenModesIdx2NativeIdx; - private ScreenMode currentScreenMode; - private ScreenMode originalScreenMode; - private boolean screenModeChangedByOwner; - private ArrayList listener = new ArrayList(); - - private static HashMap screenFQN2ScreenModeStatus = new HashMap(); - private static RecursiveLock screen2ScreenModeStatusLock = LockFactory.createRecursiveLock(); - - protected static void mapScreenModeStatus(String screenFQN, ScreenModeStatus sms) { - screen2ScreenModeStatusLock.lock(); - try { - ScreenModeStatus _sms = screenFQN2ScreenModeStatus.get(screenFQN); - if( null != _sms ) { - throw new RuntimeException("ScreenModeStatus "+_sms+" already mapped to "+screenFQN); - } - screenFQN2ScreenModeStatus.put(screenFQN, sms); - if(DEBUG) { - System.err.println("ScreenModeStatus.map "+screenFQN+" -> "+sms); - } - } finally { - screen2ScreenModeStatusLock.unlock(); - } - } - - /** - * @param screen the prev user - * @return true if mapping is empty, ie no more usage of the mapped ScreenModeStatus - */ - protected static void unmapScreenModeStatus(String screenFQN) { - screen2ScreenModeStatusLock.lock(); - try { - unmapScreenModeStatusUnlocked(screenFQN); - } finally { - screen2ScreenModeStatusLock.unlock(); - } - } - protected static void unmapScreenModeStatusUnlocked(String screenFQN) { - ScreenModeStatus sms = screenFQN2ScreenModeStatus.remove(screenFQN); - if(DEBUG) { - System.err.println("ScreenModeStatus.unmap "+screenFQN+" -> "+sms); - } - } - - protected static ScreenModeStatus getScreenModeStatus(String screenFQN) { - screen2ScreenModeStatusLock.lock(); - try { - return getScreenModeStatusUnlocked(screenFQN); - } finally { - screen2ScreenModeStatusLock.unlock(); - } - } - protected static ScreenModeStatus getScreenModeStatusUnlocked(String screenFQN) { - return screenFQN2ScreenModeStatus.get(screenFQN); - } - - protected static void lockScreenModeStatus() { - screen2ScreenModeStatusLock.lock(); - } - - protected static void unlockScreenModeStatus() { - screen2ScreenModeStatusLock.unlock(); - } - - public ScreenModeStatus(ArrayHashSet screenModes, - IntIntHashMap screenModesIdx2NativeIdx) { - this.screenModes = screenModes; - this.screenModesIdx2NativeIdx = screenModesIdx2NativeIdx; - this.screenModeChangedByOwner = false; - } - - protected final void setOriginalScreenMode(ScreenMode originalScreenMode) { - this.originalScreenMode = originalScreenMode; - this.currentScreenMode = originalScreenMode; - } - - public final ScreenMode getOriginalScreenMode() { - return originalScreenMode; - } - - public final ScreenMode getCurrentScreenMode() { - lock(); - try { - return currentScreenMode; - } finally { - unlock(); - } - } - - /** - * We cannot guarantee that we won't interfere w/ another running - * application's screen mode change. - *

    - * At least we only return true if the owner, ie. the Screen, - * has changed the screen mode and if the original screen mode - * is not current the current one. - *

    - * @return - */ - public final boolean isOriginalModeChangedByOwner() { - lock(); - try { - return screenModeChangedByOwner && !isCurrentModeOriginalMode(); - } finally { - unlock(); - } - } - - protected final boolean isCurrentModeOriginalMode() { - if(null != currentScreenMode && null != originalScreenMode) { - return currentScreenMode.hashCode() == originalScreenMode.hashCode(); - } - return true; - } - - protected final ArrayHashSet getScreenModes() { - return screenModes; - } - - protected final IntIntHashMap getScreenModesIdx2NativeIdx() { - return screenModesIdx2NativeIdx; - } - - protected final int addListener(ScreenModeListener l) { - lock(); - try { - listener.add(l); - if(DEBUG) { - System.err.println("ScreenModeStatus.addListener (size: "+listener.size()+"): "+l); - } - return listener.size(); - } finally { - unlock(); - } - } - - protected final int removeListener(ScreenModeListener l) { - lock(); - try { - if(!listener.remove(l)) { - throw new RuntimeException("ScreenModeListener "+l+" not contained"); - } - if(DEBUG) { - System.err.println("ScreenModeStatus.removeListener (size: "+listener.size()+"): "+l); - } - return listener.size(); - } finally { - unlock(); - } - } - - protected final void fireScreenModeChangeNotify(ScreenMode desiredScreenMode) { - lock(); - try { - for(int i=0; i allMonitors; + private final ArrayHashSet allMonitorModes; + private ArrayList listener = new ArrayList(); + + private static HashMap screenFQN2ScreenMonitorState = new HashMap(); + private static RecursiveLock screen2ScreenMonitorState = LockFactory.createRecursiveLock(); + + protected static void mapScreenMonitorState(String screenFQN, ScreenMonitorState sms) { + screen2ScreenMonitorState.lock(); + try { + ScreenMonitorState _sms = screenFQN2ScreenMonitorState.get(screenFQN); + if( null != _sms ) { + throw new RuntimeException("ScreenMonitorState "+_sms+" already mapped to "+screenFQN); + } + screenFQN2ScreenMonitorState.put(screenFQN, sms); + if(DEBUG) { + System.err.println("ScreenMonitorState.map "+screenFQN+" -> "+sms); + } + } finally { + screen2ScreenMonitorState.unlock(); + } + } + + /** + * @param screen the prev user + * @return true if mapping is empty, ie no more usage of the mapped ScreenMonitorState + */ + protected static void unmapScreenMonitorState(String screenFQN) { + screen2ScreenMonitorState.lock(); + try { + unmapScreenMonitorStateUnlocked(screenFQN); + } finally { + screen2ScreenMonitorState.unlock(); + } + } + protected static void unmapScreenMonitorStateUnlocked(String screenFQN) { + ScreenMonitorState sms = screenFQN2ScreenMonitorState.remove(screenFQN); + if(DEBUG) { + System.err.println("ScreenMonitorState.unmap "+screenFQN+" -> "+sms); + } + } + + protected static ScreenMonitorState getScreenMonitorState(String screenFQN) { + screen2ScreenMonitorState.lock(); + try { + return getScreenMonitorStateUnlocked(screenFQN); + } finally { + screen2ScreenMonitorState.unlock(); + } + } + protected static ScreenMonitorState getScreenMonitorStateUnlocked(String screenFQN) { + return screenFQN2ScreenMonitorState.get(screenFQN); + } + + protected static void lockScreenMonitorState() { + screen2ScreenMonitorState.lock(); + } + + protected static void unlockScreenMonitorState() { + screen2ScreenMonitorState.unlock(); + } + + public ScreenMonitorState(ArrayHashSet allMonitors, + ArrayHashSet allMonitorModes) { + this.allMonitors = allMonitors; + this.allMonitorModes = allMonitorModes; + } + + protected ArrayHashSet getMonitorDevices() { + return allMonitors; + } + + protected ArrayHashSet getMonitorModes() { + return allMonitorModes; + } + + protected final int addListener(MonitorModeListener l) { + lock(); + try { + listener.add(l); + if(DEBUG) { + System.err.println("ScreenMonitorState.addListener (size: "+listener.size()+"): "+l); + } + return listener.size(); + } finally { + unlock(); + } + } + + protected final int removeListener(MonitorModeListener l) { + lock(); + try { + if(!listener.remove(l)) { + throw new RuntimeException("ScreenModeListener "+l+" not contained"); + } + if(DEBUG) { + System.err.println("ScreenMonitorState.removeListener (size: "+listener.size()+"): "+l); + } + return listener.size(); + } finally { + unlock(); + } + } + + protected final MonitorDevice getMonitor(MonitorDevice monitor) { + return allMonitors.get(monitor); + } + + protected final void validateMonitor(MonitorDevice monitor) { + final MonitorDevice md = allMonitors.get(monitor); + if( null == md ) { + throw new InternalError("Monitor unknown: "+monitor); + } + } + + protected final void fireScreenModeChangeNotify(MonitorDevice monitor, MonitorMode desiredMode) { + lock(); + try { + validateMonitor(monitor); + final MonitorEvent me = new MonitorEvent(MonitorEvent.EVENT_MONITOR_MODE_CHANGE_NOTIFY, monitor, System.currentTimeMillis(), desiredMode); + for(int i=0; i default - private boolean fullscreen = false, brokenFocusChange = false; + private boolean fullscreen = false, brokenFocusChange = false; + private List fullscreenMonitors = null; + private boolean fullscreenUseMainMonitor = true; private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets @@ -294,19 +298,40 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer screenReferenceAdded = true; } if(canCreateNativeImpl()) { + final int wX, wY; + final boolean usePosition; + if( autoPosition ) { + wX = 0; + wY = 0; + usePosition = false; + } else { + wX = getX(); + wY = getY(); + usePosition = true; + } + final long t0 = System.currentTimeMillis(); createNativeImpl(); - screen.addScreenModeListener(screenModeListenerImpl); + screen.addMonitorModeListener(screenModeListenerImpl); setTitleImpl(title); setPointerVisibleImpl(pointerVisible); confinePointerImpl(pointerConfined); setKeyboardVisible(keyboardVisible); - if(waitForVisible(true, false)) { + final long remainingV = waitForVisible(true, false); + if( 0 <= remainingV ) { if(isFullscreen()) { synchronized(fullScreenAction) { fullscreen = false; // trigger a state change - fullScreenAction.init(true); + fullScreenAction.init(true, fullscreenUseMainMonitor, fullscreenMonitors); + fullscreenMonitors = null; // release references ASAP + fullscreenUseMainMonitor = true; fullScreenAction.run(); } + } else { + // Wait until position is reached within tolerances, either auto-position or custom position. + waitForPosition(usePosition, wX, wY, Window.TIMEOUT_NATIVEWINDOW); + } + if (DEBUG_IMPLEMENTATION) { + System.err.println("Window.createNative(): elapsed "+(System.currentTimeMillis()-t0)+" ms"); } postParentlockFocus = true; } @@ -463,8 +488,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public static final int FLAG_HAS_PARENT = 1 << 8; public static final int FLAG_IS_UNDECORATED = 1 << 9; public static final int FLAG_IS_FULLSCREEN = 1 << 10; - public static final int FLAG_IS_ALWAYSONTOP = 1 << 11; - public static final int FLAG_IS_VISIBLE = 1 << 12; + public static final int FLAG_IS_FULLSCREEN_SPAN = 1 << 11; + public static final int FLAG_IS_ALWAYSONTOP = 1 << 12; + public static final int FLAG_IS_VISIBLE = 1 << 13; /** * The native implementation should invoke the referenced java state callbacks @@ -509,6 +535,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } sb.append("FS_"); sb.append(0 != ( FLAG_IS_FULLSCREEN & flags)); + sb.append("_span_"); + sb.append(0 != ( FLAG_IS_FULLSCREEN_SPAN & flags)); sb.append(", "); if( 0 != ( FLAG_CHANGE_DECORATION & flags) ) { @@ -718,6 +746,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return screen; } + @Override + public final MonitorDevice getMainMonitor() { + return screen.getMainMonitor(new Rectangle(getX(), getY(), getWidth(), getHeight())); + } + protected final void setVisibleImpl(boolean visible, int x, int y, int width, int height) { reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_VISIBILITY, visible)); } @@ -904,7 +937,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if( isNativeValid() ) { - screen.removeScreenModeListener(screenModeListenerImpl); + screen.removeMonitorModeListener(screenModeListenerImpl); closeNativeImpl(); final AbstractGraphicsDevice cfgADevice = config.getScreen().getDevice(); if( cfgADevice != screen.getDisplay().getGraphicsDevice() ) { // don't pull display's device @@ -929,6 +962,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setWindowHandle(0); visible = false; fullscreen = false; + fullscreenMonitors = null; + fullscreenUseMainMonitor = true; hasFocus = false; parentWindowHandle = 0; @@ -1212,7 +1247,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer display.dispatchMessagesNative(); // status up2date if(wasVisible) { setVisibleImpl(true, x, y, width, height); - ok = WindowImpl.this.waitForVisible(true, false); + ok = 0 <= WindowImpl.this.waitForVisible(true, false); if(ok) { ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } @@ -1735,6 +1770,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(isNativeValid()) { // this.x/this.y will be set by sizeChanged, triggered by windowing event system reconfigureWindowImpl(x, y, getWidth(), getHeight(), getReconfigureFlags(0, isVisible())); + + // Wait until custom position is reached within tolerances + waitForPosition(true, x, y, Window.TIMEOUT_NATIVEWINDOW); } else { definePosition(x, y); // set pos for createNative(..) } @@ -1758,13 +1796,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class FullScreenAction implements Runnable { boolean fullscreen; + List monitors; + boolean useMainMonitor; - private boolean init(boolean fullscreen) { + private boolean init(boolean fullscreen, boolean useMainMonitor, List monitors) { if(isNativeValid()) { this.fullscreen = fullscreen; - return isFullscreen() != fullscreen; + if( isFullscreen() != fullscreen ) { + this.monitors = monitors; + this.useMainMonitor = useMainMonitor; + return true; + } else { + this.monitors = null; + this.useMainMonitor = true; + return false; + } } else { WindowImpl.this.fullscreen = fullscreen; // set current state for createNative(..) + WindowImpl.this.fullscreenMonitors = monitors; + WindowImpl.this.fullscreenUseMainMonitor = useMainMonitor; return false; } } @@ -1777,19 +1827,32 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // set current state WindowImpl.this.fullscreen = fullscreen; - final ScreenMode sm = screen.getCurrentScreenMode(); int x,y,w,h; + final RectangleImmutable viewport; + final int fs_span_flag; if(fullscreen) { + if( null == monitors ) { + if( useMainMonitor ) { + monitors = new ArrayList(); + monitors.add( getMainMonitor() ); + } else { + monitors = getScreen().getMonitorDevices(); + } + } + fs_span_flag = monitors.size() > 1 ? FLAG_IS_FULLSCREEN_SPAN : 0 ; + viewport = MonitorDevice.unionOfViewports(new Rectangle(), monitors); nfs_x = getX(); nfs_y = getY(); nfs_width = getWidth(); nfs_height = getHeight(); - x = screen.getX(); - y = screen.getY(); - w = sm.getRotatedWidth(); - h = sm.getRotatedHeight(); + x = viewport.getX(); + y = viewport.getY(); + w = viewport.getWidth(); + h = viewport.getHeight(); } else { + fs_span_flag = 0; + viewport = null; x = nfs_x; y = nfs_y; w = nfs_width; @@ -1809,9 +1872,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } + monitors = null; // clear references ASAP + useMainMonitor = true; if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ - ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", SM "+sm.getRotatedWidth()+"x"+sm.getRotatedHeight()); + ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", monitorsViewport "+viewport); } DisplayImpl display = (DisplayImpl) screen.getDisplay(); @@ -1831,7 +1896,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer try { reconfigureWindowImpl(x, y, w, h, getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | - FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, wasVisible) ); + fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, wasVisible) ); } finally { if(null!=parentWindowLocked) { parentWindowLocked.unlockSurface(); @@ -1860,8 +1925,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public boolean setFullscreen(boolean fullscreen) { + return setFullscreenImpl(fullscreen, true, null); + } + + @Override + public boolean setFullscreen(List monitors) { + return setFullscreenImpl(true, false, monitors); + } + + private boolean setFullscreenImpl(boolean fullscreen, boolean useMainMonitor, List monitors) { synchronized(fullScreenAction) { - if( fullScreenAction.init(fullscreen) ) { + if( fullScreenAction.init(fullscreen, useMainMonitor, monitors) ) { if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance if(null != parentWindow) { @@ -1887,13 +1961,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return this.fullscreen; } } - - private class ScreenModeListenerImpl implements ScreenModeListener { + + private class ScreenModeListenerImpl implements MonitorModeListener { boolean animatorPaused = false; - public void screenModeChangeNotify(ScreenMode sm) { + public void monitorModeChangeNotify(MonitorEvent me) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.screenModeChangeNotify: "+sm); + System.err.println("Window.screenModeChangeNotify: "+me); } if(null!=lifecycleHook) { @@ -1901,9 +1975,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - public void screenModeChanged(ScreenMode sm, boolean success) { + public void monitorModeChanged(MonitorEvent me, boolean success) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.screenModeChanged: "+sm+", success: "+success); + System.err.println("Window.screenModeChanged: "+me+", success: "+success); } if(success) { @@ -1911,10 +1985,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Didn't pass above notify method. probably detected screen change after it happened. animatorPaused = lifecycleHook.pauseRenderingAction(); } - DimensionImmutable screenSize = sm.getMonitorMode().getSurfaceSize().getResolution(); - if ( getHeight() > screenSize.getHeight() || - getWidth() > screenSize.getWidth() ) { - setSize(screenSize.getWidth(), screenSize.getHeight()); + if( !fullscreen ) { + // FIXME: Need to take all covered monitors into account + final MonitorDevice mainMonitor = getMainMonitor(); + final MonitorDevice eventMonitor = me.getMonitor(); + if( mainMonitor == eventMonitor ) { + final RectangleImmutable rect = new Rectangle(getX(), getY(), getWidth(), getHeight()); + final RectangleImmutable viewport = mainMonitor.getViewport(); + final RectangleImmutable isect = viewport.intersection(rect); + if ( getHeight() > isect.getHeight() || + getWidth() > isect.getWidth() ) { + setSize(isect.getWidth(), isect.getHeight()); + } + } } } @@ -2563,14 +2646,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } - private boolean waitForVisible(boolean visible, boolean failFast) { + /** Returns -1 if failed, otherwise remaining time until {@link #TIMEOUT_NATIVEWINDOW}, maybe zero. */ + private long waitForVisible(boolean visible, boolean failFast) { return waitForVisible(visible, failFast, TIMEOUT_NATIVEWINDOW); } - private boolean waitForVisible(boolean visible, boolean failFast, long timeOut) { + /** Returns -1 if failed, otherwise remaining time until timeOut, maybe zero. */ + private long waitForVisible(boolean visible, boolean failFast, long timeOut) { final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date - for(long sleep = timeOut; 0 + * Since WM may not obey our positional request exactly, we allow a tolerance of 2 times insets[left/top], or 64 pixels, whatever is greater. + *

    + */ + private boolean waitForPosition(boolean useCustomPosition, int x, int y, long timeOut) { + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); + final int maxDX, maxDY; + { + final InsetsImmutable insets = getInsets(); + maxDX = Math.max(64, insets.getLeftWidth() * 2); + maxDY = Math.max(64, insets.getTopHeight() * 2); + } + long remaining = timeOut; + boolean ok; + do { + if( useCustomPosition ) { + ok = Math.abs(x - getX()) <= maxDX && Math.abs(y - getY()) <= maxDY ; + } else { + ok = !autoPosition; + } + if( !ok ) { + try { Thread.sleep(10); } catch (InterruptedException ie) {} + display.dispatchMessagesNative(); // status up2date + remaining-=10; + } + } while ( 0getX() || 0>getY()) { diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java index 6b1283a00..8e584fc58 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java @@ -35,12 +35,15 @@ package jogamp.newt.driver.awt; import java.awt.DisplayMode; +import jogamp.newt.MonitorModeProps.Cache; import jogamp.newt.ScreenImpl; import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class ScreenDriver extends ScreenImpl { public ScreenDriver() { @@ -68,14 +71,19 @@ public class ScreenDriver extends ScreenImpl { return idx; // pass through ... } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); - if(null != mode) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(mode.getWidth()); - virtualSize.setHeight(mode.getHeight()); - } + @Override + protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { + final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { + return null; + } + + @Override + protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { + return false; } } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java index deb2a534b..afaedffe3 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/ScreenDriver.java @@ -35,8 +35,13 @@ package jogamp.newt.driver.bcm.egl; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; + +import jogamp.newt.MonitorModeProps; +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class ScreenDriver extends jogamp.newt.ScreenImpl { @@ -58,11 +63,48 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { return 0; // only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(fixedWidth); // FIXME - virtualSize.setHeight(fixedHeight); // FIXME + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = fixedWidth; // FIXME + props[i++] = fixedHeight; // FIXME + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = ScreenImpl.default_sm_rate * 100; // FIXME + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + + props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; + i = 0; + props[i++] = props.length; + props[i++] = 0; // crt_idx + props[i++] = ScreenImpl.default_sm_widthmm; // FIXME + props[i++] = ScreenImpl.default_sm_heightmm; // FIXME + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = fixedWidth; // FIXME rotated viewport width + props[i++] = fixedHeight; // FIXME rotated viewport height + MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { + return monitor.getSupportedModes().get(0); + } + + @Override + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { + return false; + } + + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(fixedWidth); // FIXME + vOriginSize.setHeight(fixedHeight); // FIXME } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java index 787d1a1b4..f7973def8 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/ScreenDriver.java @@ -29,9 +29,12 @@ package jogamp.newt.driver.bcm.vc.iv; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; public class ScreenDriver extends ScreenImpl { @@ -53,13 +56,52 @@ public class ScreenDriver extends ScreenImpl { return 0; // only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = cachedWidth; // width + props[i++] = cachedHeight; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = ScreenImpl.default_sm_rate * 100; // FIXME + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + + props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; + i = 0; + props[i++] = props.length; + props[i++] = 0; // crt_idx + props[i++] = ScreenImpl.default_sm_widthmm; // FIXME + props[i++] = ScreenImpl.default_sm_heightmm; // FIXME + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = cachedWidth; // rotated viewport width + props[i++] = cachedWidth; // rotated viewport height + MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { + return monitor.getSupportedModes().get(0); + } + + @Override + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { + return false; + } + + @Override + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(cachedWidth); + vOriginSize.setHeight(cachedHeight); } + /** Called from {@link #initNative()}. */ protected void setScreenSize(int width, int height) { cachedWidth = width; cachedHeight = height; diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java index 8eed14dde..4c47eb0d8 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/ScreenDriver.java @@ -36,8 +36,13 @@ package jogamp.newt.driver.intel.gdl; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; + +import jogamp.newt.MonitorModeProps; +import jogamp.newt.ScreenImpl; + +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class ScreenDriver extends jogamp.newt.ScreenImpl { @@ -60,11 +65,48 @@ public class ScreenDriver extends jogamp.newt.ScreenImpl { return 0; // only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = cachedWidth; // width + props[i++] = cachedHeight; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = ScreenImpl.default_sm_rate * 100; // FIXME + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + + props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; + i = 0; + props[i++] = props.length; + props[i++] = 0; // crt_idx + props[i++] = ScreenImpl.default_sm_widthmm; // FIXME + props[i++] = ScreenImpl.default_sm_heightmm; // FIXME + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = cachedWidth; // rotated viewport width + props[i++] = cachedWidth; // rotated viewport height + MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { + return monitor.getSupportedModes().get(0); + } + + @Override + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { + return false; + } + + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(cachedWidth); + vOriginSize.setHeight(cachedHeight); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java index 656bcf5c9..dc87c3c08 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/ScreenDriver.java @@ -35,9 +35,12 @@ package jogamp.newt.driver.kd; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; public class ScreenDriver extends ScreenImpl { @@ -58,11 +61,48 @@ public class ScreenDriver extends ScreenImpl { return 0; // only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(cachedWidth); - virtualSize.setHeight(cachedHeight); + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = cachedWidth; // width + props[i++] = cachedHeight; // height + props[i++] = ScreenImpl.default_sm_bpp; // FIXME + props[i++] = ScreenImpl.default_sm_rate * 100; // FIXME + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + + props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 - MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES]; + i = 0; + props[i++] = props.length; + props[i++] = 0; // crt_idx + props[i++] = ScreenImpl.default_sm_widthmm; // FIXME + props[i++] = ScreenImpl.default_sm_heightmm; // FIXME + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = cachedWidth; // rotated viewport width + props[i++] = cachedWidth; // rotated viewport height + MonitorModeProps.streamInMonitorDevice(null, cache, this, cache.monitorModes, currentMode, props, 0); + } + + @Override + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { + return monitor.getSupportedModes().get(0); + } + + @Override + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { + return false; + } + + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(cachedWidth); + vOriginSize.setHeight(cachedHeight); } protected void sizeChanged(int w, int h) { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java index 24e60ba0a..a3bb26731 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/ScreenDriver.java @@ -34,28 +34,19 @@ package jogamp.newt.driver.macosx; -import java.util.List; - import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Point; +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; -import com.jogamp.common.util.IntObjectHashMap; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class ScreenDriver extends ScreenImpl { - // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) - private static IntObjectHashMap/**/ scrnIdx2Dimension; - static { DisplayDriver.initSingleton(); - scrnIdx2Dimension = new IntObjectHashMap(); - scrnIdx2Dimension.setKeyNotFoundValue(null); } public ScreenDriver() { @@ -67,77 +58,67 @@ public class ScreenDriver extends ScreenImpl { protected void closeNativeImpl() { } - private static native int getWidthImpl0(int scrn_idx); - private static native int getHeightImpl0(int scrn_idx); - - private int[] getScreenModeIdx(int idx) { - // caching native CGDisplayScreenSize() results, since it's ridiculous slow (~6 ms each call) - DimensionImmutable dim = (DimensionImmutable) scrnIdx2Dimension.get(screen_idx); - if(null == dim) { - int[] res = getScreenSizeMM0(screen_idx); - if(null == res || 0 == res.length) { - return null; - } - dim = new Dimension(res[0], res[1]); - scrnIdx2Dimension.put(screen_idx, dim); - } - - int[] modeProps = getScreenMode0(screen_idx, idx, dim.getWidth(), dim.getHeight()); - if (null == modeProps || 0 == modeProps.length) { - return null; + private MonitorMode getMonitorModeImpl(MonitorModeProps.Cache cache, int crt_idx, int mode_idx) { + final int[] modeProps = getMonitorMode0(crt_idx, mode_idx); + final MonitorMode res; + if (null == modeProps || 0 >= modeProps.length) { + res = null; + } else { + res = MonitorModeProps.streamInMonitorMode(null, cache, modeProps, 0); } - if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { - throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); - } - return modeProps; + return res; } - - private int nativeModeIdx; - protected int[] getScreenModeFirstImpl() { - nativeModeIdx = 0; - return getScreenModeNextImpl(); - } - - protected int[] getScreenModeNextImpl() { - int[] modeProps = getScreenModeIdx(nativeModeIdx); - if (null != modeProps && 0 < modeProps.length) { - nativeModeIdx++; - return modeProps; - } - return null; + @Override + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int crtIdx = 0; + int modeIdx = 0; + ArrayHashSet supportedModes = new ArrayHashSet(); + do { + final MonitorMode mode = getMonitorModeImpl(cache, crtIdx, modeIdx); + if( null != mode ) { + supportedModes.getOrAdd(mode); + // next mode on same monitor + modeIdx++; + } else if( 0 < modeIdx ) { + // end of monitor modes - got at least one mode + final MonitorMode currentMode = getMonitorModeImpl(cache, crtIdx, -1); + if ( null == currentMode ) { + throw new InternalError("Could not gather current mode of device "+crtIdx+", but gathered "+modeIdx+" modes"); + } + final int[] monitorProps = getMonitorProps0(crtIdx); + if ( null == monitorProps ) { + throw new InternalError("Could not gather device "+crtIdx+", but gathered "+modeIdx+" modes"); + } + // merge monitor-props + supported modes + MonitorModeProps.streamInMonitorDevice(null, cache, this, supportedModes, currentMode, monitorProps, 0); + + // next monitor, 1st mode + supportedModes= new ArrayHashSet(); + crtIdx++; + modeIdx=0; + } else { + // end of monitor + break; + } + } while ( true ); } - protected ScreenMode getCurrentScreenModeImpl() { - int[] modeProps = getScreenModeIdx(-1); - if (null != modeProps && 0 < modeProps.length) { - return ScreenModeUtil.streamIn(modeProps, 0); - } - return null; + @Override + protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { + return getMonitorModeImpl(null, monitor.getId(), -1); } - protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { - final List screenModes = this.getScreenModesOrig(); - final int screenModeIdx = screenModes.indexOf(screenMode); - if(0>screenModeIdx) { - throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); - } - final int nativeModeIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - return setScreenMode0(screen_idx, nativeModeIdx); + @Override + protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { + return setMonitorMode0(monitor.getId(), mode.getId(), mode.getRotation()); } protected int validateScreenIndex(int idx) { - return idx; + return 0; // big-desktop w/ multiple monitor attached, only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(getWidthImpl0(screen_idx)); - virtualSize.setHeight(getHeightImpl0(screen_idx)); - } - - private native int[] getScreenSizeMM0(int screen_idx); - private native int[] getScreenMode0(int screen_index, int mode_index, int widthMM, int heightMM); - private native boolean setScreenMode0(int screen_index, int mode_idx); + private native int[] getMonitorProps0(int crt_idx); + private native int[] getMonitorMode0(int crt_index, int mode_idx); + private native boolean setMonitorMode0(int crt_index, int nativeId, int rot); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index bb72350e3..6370782df 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -478,7 +478,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl if( 0 != surfaceHandle ) { throw new NativeWindowException("Internal Error - create w/o window, but has Newt NSView"); } - surfaceHandle = createView0(pS.getX(), pS.getY(), width, height, fullscreen, getScreen().getIndex()); + surfaceHandle = createView0(pS.getX(), pS.getY(), width, height, fullscreen); if( 0 == surfaceHandle ) { throw new NativeWindowException("Could not create native view "+Thread.currentThread().getName()+" "+this); } @@ -487,7 +487,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl final long newWin = createWindow0( pS.getX(), pS.getY(), width, height, fullscreen, ( isUndecorated() || offscreenInstance ) ? NSBorderlessWindowMask : NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask, - NSBackingStoreBuffered, getScreen().getIndex(), surfaceHandle); + NSBackingStoreBuffered, surfaceHandle); if ( newWin == 0 ) { throw new NativeWindowException("Could not create native window "+Thread.currentThread().getName()+" "+this); } @@ -497,9 +497,8 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl // Non blocking initialization on main-thread! OSXUtil.RunOnMainThread(false, new Runnable() { public void run() { - initWindow0( parentWin, newWin, - pS.getX(), pS.getY(), width, height, - isOpaque, fullscreen, visible && !offscreenInstance, getScreen().getIndex(), surfaceHandle); + initWindow0( parentWin, newWin, pS.getX(), pS.getY(), width, height, + isOpaque, fullscreen, visible && !offscreenInstance, surfaceHandle); if( offscreenInstance ) { orderOut0(0!=parentWin ? parentWin : newWin); } else { @@ -514,11 +513,11 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } protected static native boolean initIDs0(); - private native long createView0(int x, int y, int w, int h, boolean fullscreen, int screen_idx); - private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, int screen_idx, long view); + private native long createView0(int x, int y, int w, int h, boolean fullscreen); + private native long createWindow0(int x, int y, int w, int h, boolean fullscreen, int windowStyle, int backingStoreType, long view); /** Must be called on Main-Thread */ private native void initWindow0(long parentWindow, long window, int x, int y, int w, int h, - boolean opaque, boolean fullscreen, boolean visible, int screen_idx, long view); + boolean opaque, boolean fullscreen, boolean visible, long view); private native boolean lockSurface0(long window, long view); private native boolean unlockSurface0(long window, long view); /** Must be called on Main-Thread */ diff --git a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java index 948b29460..342829691 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/ScreenDriver.java @@ -34,91 +34,143 @@ package jogamp.newt.driver.windows; import javax.media.nativewindow.DefaultGraphicsScreen; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.Rectangle; +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.Screen; public class ScreenDriver extends ScreenImpl { static { DisplayDriver.initSingleton(); + if( Screen.DEBUG ) { + dumpMonitorInfo0(); + } } public ScreenDriver() { } + @Override protected void createNativeImpl() { aScreen = new DefaultGraphicsScreen(getDisplay().getGraphicsDevice(), screen_idx); } + @Override protected void closeNativeImpl() { } - private int[] getScreenModeIdx(int idx) { - int[] modeProps = getScreenMode0(screen_idx, idx); - if (null == modeProps || 0 == modeProps.length) { + private final String getAdapterName(int crt_idx) { + return getAdapterName0(crt_idx); + } + private final String getActiveMonitorName(String adapterName, int monitor_idx) { + return getActiveMonitorName0(adapterName, monitor_idx); + } + + private final MonitorMode getMonitorModeImpl(MonitorModeProps.Cache cache, String adapterName, int crtModeIdx) { + if( null == adapterName ) { return null; } - if(modeProps.length < ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL) { - throw new RuntimeException("properties array too short, should be >= "+ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL+", is "+modeProps.length); + final String activeMonitorName = getActiveMonitorName(adapterName, 0); + final int[] modeProps = null != activeMonitorName ? getMonitorMode0(adapterName, crtModeIdx) : null; + if ( null == modeProps || 0 >= modeProps.length) { + return null; } - return modeProps; + return MonitorModeProps.streamInMonitorMode(null, cache, modeProps, 0); } - private int nativeModeIdx; - - protected int[] getScreenModeFirstImpl() { - nativeModeIdx = 0; - return getScreenModeNextImpl(); - } - - protected int[] getScreenModeNextImpl() { - int[] modeProps = getScreenModeIdx(nativeModeIdx); - if (null != modeProps && 0 < modeProps.length) { - nativeModeIdx++; - return modeProps; + @Override + protected void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + int crtIdx = 0; + ArrayHashSet supportedModes = new ArrayHashSet(); + String adapterName = getAdapterName(crtIdx); + while( null != adapterName ) { + int crtModeIdx = 0; + MonitorMode mode; + do { + mode = getMonitorModeImpl(cache, adapterName, crtModeIdx); + if( null != mode ) { + supportedModes.getOrAdd(mode); + // next mode on same monitor + crtModeIdx++; + } + } while( null != mode); + if( 0 < crtModeIdx ) { + // has at least one mode -> add device + final MonitorMode currentMode = getMonitorModeImpl(cache, adapterName, -1); + if ( null != currentMode ) { // enabled + final int[] monitorProps = getMonitorDevice0(adapterName, crtIdx); + // merge monitor-props + supported modes + MonitorModeProps.streamInMonitorDevice(null, cache, this, supportedModes, currentMode, monitorProps, 0); + + // next monitor, 1st mode + supportedModes= new ArrayHashSet(); + } + } + crtIdx++; + adapterName = getAdapterName(crtIdx); } - return null; } - - protected ScreenMode getCurrentScreenModeImpl() { - int[] modeProps = getScreenModeIdx(-1); - if (null != modeProps && 0 < modeProps.length) { - return ScreenModeUtil.streamIn(modeProps, 0); + + @Override + protected Rectangle getNativeMonitorDeviceViewportImpl(MonitorDevice monitor) { + final String adapterName = getAdapterName(monitor.getId()); + if( null != adapterName ) { + final String activeMonitorName = getActiveMonitorName(adapterName, 0); + if( null != activeMonitorName ) { + final int[] monitorProps = getMonitorDevice0(adapterName, monitor.getId()); + int offset = MonitorModeProps.IDX_MONITOR_DEVICE_VIEWPORT; + return new Rectangle(monitorProps[offset++], monitorProps[offset++], monitorProps[offset++], monitorProps[offset++]); + } } return null; } - protected boolean setCurrentScreenModeImpl(ScreenMode sm) { - return setScreenMode0(screen_idx, - sm.getMonitorMode().getSurfaceSize().getResolution().getWidth(), - sm.getMonitorMode().getSurfaceSize().getResolution().getHeight(), - sm.getMonitorMode().getSurfaceSize().getBitsPerPixel(), - sm.getMonitorMode().getRefreshRate(), - sm.getRotation()); + @Override + protected MonitorMode queryCurrentMonitorModeImpl(MonitorDevice monitor) { + return getMonitorModeImpl(null, getAdapterName(monitor.getId()), -1); + } + + @Override + protected boolean setCurrentMonitorModeImpl(MonitorDevice monitor, MonitorMode mode) { + return setMonitorMode0(monitor.getId(), + -1, -1, // no fixed position! + mode.getSurfaceSize().getResolution().getWidth(), + mode.getSurfaceSize().getResolution().getHeight(), + mode.getSurfaceSize().getBitsPerPixel(), + (int)mode.getRefreshRate(), // simply cut-off, orig is int + mode.getFlags(), + mode.getRotation()); } + @Override protected int validateScreenIndex(int idx) { - return 0; // big-desktop, only one screen available + return 0; // big-desktop w/ multiple monitor attached, only one screen available } - protected void getVirtualScreenOriginAndSize(Point virtualOrigin, Dimension virtualSize) { - virtualOrigin.setX(getOriginX0(screen_idx)); - virtualOrigin.setY(getOriginY0(screen_idx)); - virtualSize.setWidth(getWidthImpl0(screen_idx)); - virtualSize.setHeight(getHeightImpl0(screen_idx)); + @Override + protected void calcVirtualScreenOriginAndSize(Rectangle vOriginSize) { + vOriginSize.setX(getVirtualOriginX0()); + vOriginSize.setY(getVirtualOriginY0()); + vOriginSize.setWidth(getVirtualWidthImpl0()); + vOriginSize.setHeight(getVirtualHeightImpl0()); } // Native calls - private native int getOriginX0(int screen_idx); - private native int getOriginY0(int screen_idx); - private native int getWidthImpl0(int scrn_idx); - private native int getHeightImpl0(int scrn_idx); + private native int getVirtualOriginX0(); + private native int getVirtualOriginY0(); + private native int getVirtualWidthImpl0(); + private native int getVirtualHeightImpl0(); - private native int[] getScreenMode0(int screen_index, int mode_index); - private native boolean setScreenMode0(int screen_index, int width, int height, int bits, int freq, int rot); + private static native void dumpMonitorInfo0(); + private native String getAdapterName0(int crt_index); + private native String getActiveMonitorName0(String adapterName, int crtModeIdx); + private native int[] getMonitorMode0(String adapterName, int crtModeIdx); + private native int[] getMonitorDevice0(String adapterName, int monitor_index); + private native boolean setMonitorMode0(int monitor_index, int x, int y, int width, int height, int bits, int freq, int flags, int rot); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java index 485d976ec..c569e5fd8 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java @@ -27,13 +27,50 @@ */ package jogamp.newt.driver.x11; -import com.jogamp.newt.ScreenMode; +import java.util.List; + +import jogamp.newt.MonitorModeProps; + +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public interface RandR { - int[] getScreenModeFirstImpl(final long dpy, final int screen_idx); - int[] getScreenModeNextImpl(final long dpy, final int screen_idx); - ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx); - boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx); + void dumpInfo(final long dpy, final int screen_idx); + + /** + * Encapsulate initial device query allowing caching of internal data structures. + * Methods covered: + *
      + *
    • {@link #getMonitorDeviceCount(long, ScreenDriver)}
    • + *
    • {@link #getAvailableRotations(long, ScreenDriver, int)}
    • + *
    • {@link #getMonitorModeProps(long, ScreenDriver, int)}
    • + *
    • {@link #getCurrentMonitorModeProps(long, ScreenDriver, int)
    • + *
    • {@link #getMonitorDeviceProps(long, ScreenDriver, List, int, MonitorMode)}
    • + *
    + *

    + * Above methods may be called w/o begin/end, in which case no + * internal data structures can be cached: + *

    + * @param dpy TODO + * @param screen TODO + * @return TODO + */ + boolean beginInitialQuery(long dpy, ScreenDriver screen); + void endInitialQuery(long dpy, ScreenDriver screen); + int getMonitorDeviceCount(final long dpy, final ScreenDriver screen); + int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx); + /** + * + * @param dpy + * @param screen + * @param mode_idx w/o indexing rotation + * @return props w/o actual rotation + */ + int[] getMonitorModeProps(final long dpy, final ScreenDriver screen, final int mode_idx); + int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx); + int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx); + int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx); + boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java index ee67bd304..a938b4064 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -27,139 +27,257 @@ */ package jogamp.newt.driver.x11; +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.common.util.VersionNumber; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; public class RandR11 implements RandR { private static final boolean DEBUG = ScreenDriver.DEBUG; - private int[] nrotations; - private int nrotation_index; - private int nres_number; - private int nres_index; - private int[] nrates; - private int nrate_index; - private int nmode_number; + public static VersionNumber version = new VersionNumber(1, 1, 0); + + public static RandR11 createInstance(VersionNumber rAndRVersion) { + if( rAndRVersion.compareTo(version) >= 0 ) { + return new RandR11(); + } + return null; + } + private RandR11() { + } + + @Override + public void dumpInfo(final long dpy, final int screen_idx) { + // NOP + } + + private int widthMM=0, heightMM=0; + private int modeCount = 0; + private int resolutionCount = 0; + private int[][] nrates = null; // [nres_number][nrate_number] + private int[] idx_rate = null, idx_res = null; @Override - public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + public boolean beginInitialQuery(long dpy, ScreenDriver screen) { // initialize iterators and static data - nrotations = getAvailableScreenModeRotations0(dpy, screen_idx); - if(null==nrotations || 0==nrotations.length) { - return null; + final int screen_idx = screen.getIndex(); + resolutionCount = getNumScreenResolutions0(dpy, screen_idx); + if(0==resolutionCount) { + endInitialQuery(dpy, screen); + return false; } - nrotation_index = 0; - nres_number = getNumScreenModeResolutions0(dpy, screen_idx); - if(0==nres_number) { - return null; + nrates = new int[resolutionCount][]; + for(int i=0; i= modeCount ) { + return null; + } + final int screen_idx = screen.getIndex(); + + final int nres_index = idx_res[mode_idx]; + final int nrate_index = idx_rate[mode_idx]; + + final int[] res = getScreenResolution0(dpy, screen_idx, nres_index); if(null==res || 0==res.length) { return null; } if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+nres_number); + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_index+"/"+resolutionCount); + } + if( res[2] > widthMM ) { + widthMM = res[2]; } - int rate = nrates[nrate_index]; + if( res[3] > heightMM ) { + heightMM = res[3]; + } + + int rate = nrates[nres_index][nrate_index]; if(0>=rate) { rate = ScreenImpl.default_sm_rate; if(DEBUG) { System.err.println("Invalid rate: "+rate+" at index "+nrate_index+"/"+nrates.length+", using default: "+ScreenImpl.default_sm_rate); } } - int rotation = nrotations[nrotation_index]; - int[] props = new int[ 1 + ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL ]; + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; - props[i++] = nres_index; // use resolution index, not unique for native -> ScreenMode - props[i++] = 0; // set later for verification of iterator + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; props[i++] = res[0]; // width props[i++] = res[1]; // height - props[i++] = ScreenImpl.default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate - props[i++] = rotation; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i - 1; // count without extra element - - nmode_number++; - - // iteration: r -> f -> bpp -> [w x h] - nrotation_index++; - if(nrotation_index == nrotations.length) { - nrotation_index=0; - nrate_index++; - if(null == nrates || nrate_index == nrates.length){ - nres_index++; - if(nres_index == nres_number) { - // done - nrates=null; - nrotations=null; - return null; - } - - nrates = getScreenModeRates0(dpy, screen_idx, nres_index); - if(null==nrates || 0==nrates.length) { - return null; - } - nrate_index = 0; - } + props[i++] = ScreenImpl.default_sm_bpp; // bpp n/a in RandR11 + props[i++] = rate*100; // rate (Hz*100) + props[i++] = 0; // flags; + props[i++] = nres_index; + props[i++] = -1; // rotation placeholder; + if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { + throw new InternalError("XX"); + } + return props; + } + + @Override + public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, final MonitorModeProps.Cache cache, final int crt_idx) { + if( 0 < crt_idx ) { + // RandR11 only supports 1 CRT + return null; + } + final int[] currentModeProps = getCurrentMonitorModeProps(dpy, screen, crt_idx); + if( null == currentModeProps) { // disabled + return null; + } + final MonitorMode currentMode = MonitorModeProps.streamInMonitorMode(null, cache, currentModeProps, 0); + final int allModesCount = cache.monitorModes.size(); + final int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES - 1 + allModesCount]; + int i = 0; + props[i++] = props.length; + props[i++] = crt_idx; + props[i++] = widthMM; + props[i++] = heightMM; + props[i++] = 0; // rotated viewport x + props[i++] = 0; // rotated viewport y + props[i++] = currentMode.getRotatedWidth(); // rotated viewport width + props[i++] = currentMode.getRotatedHeight(); // rotated viewport height + props[i++] = currentMode.getId(); // current mode id + props[i++] = currentMode.getRotation(); + for(int j=0; jnres_idx) { + return null; + } + if(nres_idx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+nres_idx+" < "+resNumber); + } + res = getScreenResolution0(dpy, screen_idx, nres_idx); + if(null==res || 0==res.length) { + return null; + } + if(0>=res[0] || 0>=res[1]) { + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_idx+"/"+resNumber); + } + } finally { + freeScreenConfiguration0(screenConfigHandle); + } + int[] props = new int[4]; + int i = 0; + props[i++] = 0; + props[i++] = 0; + props[i++] = res[0]; // width + props[i++] = res[1]; // height + return props; + } + @Override - public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { + public int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx) { + if( 0 < crt_idx ) { + // RandR11 only supports 1 CRT + return null; + } + final int screen_idx = screen.getIndex(); long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); if(0 == screenConfigHandle) { return null; } int[] res; int rate, rot; + final int nres_idx; try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); + int resNumber = getNumScreenResolutions0(dpy, screen_idx); if(0==resNumber) { return null; } - int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle); - if(0>resIdx) { + nres_idx = getCurrentScreenResolutionIndex0(screenConfigHandle); + if(0>nres_idx) { return null; } - if(resIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber); + if(nres_idx>=resNumber) { + throw new RuntimeException("Invalid resolution index: ! "+nres_idx+" < "+resNumber); } - res = getScreenModeResolution0(dpy, screen_idx, resIdx); + res = getScreenResolution0(dpy, screen_idx, nres_idx); if(null==res || 0==res.length) { return null; } if(0>=res[0] || 0>=res[1]) { - throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber); + throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+nres_idx+"/"+resNumber); } rate = getCurrentScreenRate0(screenConfigHandle); if(0>rate) { @@ -172,40 +290,42 @@ public class RandR11 implements RandR { } finally { freeScreenConfiguration0(screenConfigHandle); } - int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL]; + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; int i = 0; - props[i++] = 0; // set later for verification of iterator + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; props[i++] = res[0]; // width props[i++] = res[1]; // height - props[i++] = ScreenImpl.default_sm_bpp; // FIXME - props[i++] = res[2]; // widthmm - props[i++] = res[3]; // heightmm - props[i++] = rate; // rate + props[i++] = ScreenImpl.default_sm_bpp; + props[i++] = rate*100; // rate (Hz*100) + props[i++] = 0; // flags; + props[i++] = nres_idx; // mode_idx; props[i++] = rot; - props[i - ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL] = i; // count - return ScreenModeUtil.streamIn(props, 0); + if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { + throw new InternalError("XX"); + } + return props; } @Override - public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { + public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode) { final long t0 = System.currentTimeMillis(); boolean done = false; + final int screen_idx = screen.getIndex(); long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx); if(0 == screenConfigHandle) { return Boolean.valueOf(done); } try { - int resNumber = getNumScreenModeResolutions0(dpy, screen_idx); - if(0>resolutionIdx || resolutionIdx>=resNumber) { - throw new RuntimeException("Invalid resolution index: ! 0 < "+resolutionIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode); - } - - final int f = screenMode.getMonitorMode().getRefreshRate(); - final int r = screenMode.getRotation(); + final int resId = mode.getId(); + if(0>resId || resId>=resolutionCount) { + throw new RuntimeException("Invalid resolution index: ! 0 < "+resId+" < "+resolutionCount+", "+monitor+", "+mode); + } + final int f = (int)mode.getRefreshRate(); // simply cut-off, orig is int + final int r = mode.getRotation(); - if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resolutionIdx, f, r) ) { + if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resId, f, r) ) { while(!done && System.currentTimeMillis()-t0 < ScreenImpl.SCREEN_MODE_CHANGE_TIMEOUT) { - done = setCurrentScreenModePollEnd0(dpy, screen_idx, resolutionIdx, f, r); + done = setCurrentScreenModePollEnd0(dpy, screen_idx, resId, f, r); if(!done) { try { Thread.sleep(10); } catch (InterruptedException e) { } } @@ -218,14 +338,14 @@ public class RandR11 implements RandR { } /** @return int[] { rot1, .. } */ - private static native int[] getAvailableScreenModeRotations0(long display, int screen_index); + private static native int[] getAvailableScreenRotations0(long display, int screen_index); - private static native int getNumScreenModeResolutions0(long display, int screen_index); + private static native int getNumScreenResolutions0(long display, int screen_index); /** @return int[] { width, height, widthmm, heightmm } */ - private static native int[] getScreenModeResolution0(long display, int screen_index, int mode_index); + private static native int[] getScreenResolution0(long display, int screen_index, int mode_index); - private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index); + private static native int[] getScreenRates0(long display, int screen_index, int mode_index); private static native long getScreenConfiguration0(long display, int screen_index); private static native void freeScreenConfiguration0(long screenConfiguration); diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java index 24c9806af..d10591381 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -27,25 +27,283 @@ */ package jogamp.newt.driver.x11; -import com.jogamp.newt.ScreenMode; +import java.util.Iterator; +import jogamp.newt.MonitorModeProps; + +import com.jogamp.common.util.IntLongHashMap; +import com.jogamp.common.util.VersionNumber; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; + +/** + * Mapping details: + *
    + * MonitorMode.id   == XRR mode-id (not index)
    + * MonitorDevice.id == XRR monitor-idx (not id)
    + * 
    + */ public class RandR13 implements RandR { + private static final boolean DEBUG = ScreenDriver.DEBUG; + + public static VersionNumber version = new VersionNumber(1, 3, 0); - public int[] getScreenModeFirstImpl(final long dpy, final int screen_idx) { + public static RandR13 createInstance(VersionNumber rAndRVersion) { + if( rAndRVersion.compareTo(version) >= 0 ) { + return new RandR13(); + } return null; + } + private RandR13() { + } + + @Override + public void dumpInfo(final long dpy, final int screen_idx) { + long screenResources = getScreenResources0(dpy, screen_idx); + if(0 == screenResources) { + return; + } + try { + dumpInfo0(dpy, screen_idx, screenResources); + } finally { + freeScreenResources0(screenResources); + } + } + + long sessionScreenResources = 0; + IntLongHashMap crtInfoHandleMap = null; + + @Override + public boolean beginInitialQuery(long dpy, ScreenDriver screen) { + final int screen_idx = screen.getIndex(); + sessionScreenResources = getScreenResources0(dpy, screen_idx); + if( 0 != sessionScreenResources ) { + crtInfoHandleMap = new IntLongHashMap(); + crtInfoHandleMap.setKeyNotFoundValue(0); + return true; + } else { + return false; + } + } + + @Override + public void endInitialQuery(long dpy, ScreenDriver screen) { + if( null != crtInfoHandleMap ) { + for(Iterator iter = crtInfoHandleMap.iterator(); iter.hasNext(); ) { + final IntLongHashMap.Entry entry = iter.next(); + freeMonitorInfoHandle0(entry.value); + } + crtInfoHandleMap.clear(); + crtInfoHandleMap = null; + } + if( 0 != sessionScreenResources ) { + freeScreenResources0( sessionScreenResources ); + sessionScreenResources = 0; + } } - public int[] getScreenModeNextImpl(final long dpy, final int screen_idx) { - return null; + + private final long getScreenResourceHandle(final long dpy, final int screen_idx) { + if( 0 != sessionScreenResources ) { + return sessionScreenResources; + } + return getScreenResources0(dpy, screen_idx); + } + private final void releaseScreenResourceHandle(final long screenResourceHandle) { + if( 0 == sessionScreenResources ) { + freeScreenResources0( screenResourceHandle ); + } } - public ScreenMode getCurrentScreenModeImpl(final long dpy, final int screen_idx) { - return null; + + private final long getMonitorInfoHandle(final long dpy, final int screen_idx, long screenResources, final int monitor_idx) { + if( null != crtInfoHandleMap ) { + long h = crtInfoHandleMap.get(monitor_idx); + if( 0 == h ) { + h = getMonitorInfoHandle0(dpy, screen_idx, screenResources, monitor_idx); + crtInfoHandleMap.put(monitor_idx, h); + } + return h; + } else { + return getMonitorInfoHandle0(dpy, screen_idx, screenResources, monitor_idx); + } } + private final void releaseMonitorInfoHandle(final long monitorInfoHandle) { + if( null == crtInfoHandleMap ) { + freeMonitorInfoHandle0(monitorInfoHandle); + } + } - public boolean setCurrentScreenModeImpl(final long dpy, final int screen_idx, final ScreenMode screenMode, final int screenModeIdx, final int resolutionIdx) { - return false; + @Override + public int getMonitorDeviceCount(final long dpy, final ScreenDriver screen) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + return getMonitorDeviceCount0(screenResources); + } finally { + releaseScreenResourceHandle(screenResources); + } } + @Override + public int[] getAvailableRotations(final long dpy, final ScreenDriver screen, final int crt_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx); + try { + final int[] availRotations = getAvailableRotations0(monitorInfo); + if(null==availRotations || 0==availRotations.length) { + return null; + } + return availRotations; + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public int[] getMonitorModeProps(final long dpy, final ScreenDriver screen, final int mode_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + return getMonitorMode0(screenResources, mode_idx); + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx); + try { + return getMonitorDevice0(dpy, screenResources, monitorInfo, crt_idx); + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx); + try { + return getMonitorViewport0(monitorInfo); + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, crt_idx); + try { + return getMonitorCurrentMode0(screenResources, monitorInfo); + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + } + + @Override + public boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + final boolean res; + try { + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, monitor.getId()); + try { + res = setMonitorMode0(dpy, screenResources, monitorInfo, monitor.getId(), mode.getId(), mode.getRotation(), + -1, -1); // no fixed position! + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + } finally { + releaseScreenResourceHandle(screenResources); + } + /*** + * TODO: Would need a complete re-layout of crt positions, + * which is _not_ implicit by XRandR .. sadly. + * + if( res ) { + updateScreenViewport(dpy, screen, monitor); + } */ + return res; + } + + /** See above .. + private final void updateScreenViewport(final long dpy, final ScreenDriver screen, MonitorDevice monitor) { + final int screen_idx = screen.getIndex(); + final long screenResources = getScreenResourceHandle(dpy, screen_idx); + try { + RectangleImmutable newViewp = null; + final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, monitor.getId()); + try { + final int[] vprops = getMonitorViewport0(monitorInfo); + if( null != vprops ) { + newViewp = new Rectangle(vprops[0], vprops[1], vprops[2], vprops[3]); + } + System.err.println("XXX setScreenViewport: newVp "+newViewp); + } finally { + releaseMonitorInfoHandle(monitorInfo); + } + if( null != newViewp ) { + final List monitors = screen.getMonitorDevices(); + final ArrayList viewports = new ArrayList(); + for(int i=0; i "+newScrnViewp); + setScreenViewport0(dpy, screen_idx, screenResources, newScrnViewp.getX(), newScrnViewp.getY(), newScrnViewp.getWidth(), newScrnViewp.getHeight()); + } + } finally { + dumpInfo0(dpy, screen_idx, screenResources); + releaseScreenResourceHandle(screenResources); + } + } */ + private static native long getScreenResources0(long display, int screen_index); - private static native void freeScreenResources0(long screenConfiguration); + private static native void freeScreenResources0(long screenResources); + private static native void dumpInfo0(long display, int screen_index, long screenResources); + + private static native int getMonitorDeviceCount0(long screenResources); + + private static native long getMonitorInfoHandle0(long display, int screen_index, long screenResources, int monitor_index); + private static native void freeMonitorInfoHandle0(long monitorInfoHandle); + + private static native int[] getAvailableRotations0(long monitorInfo); + private static native int[] getMonitorViewport0(long monitorInfo); + private static native int[] getMonitorCurrentMode0(long monitorInfo); + + private static native int[] getMonitorMode0(long screenResources, int mode_index); + private static native int[] getMonitorCurrentMode0(long screenResources, long monitorInfo); + private static native int[] getMonitorDevice0(long display, long screenResources, long monitorInfo, int monitor_idx); + private static native boolean setMonitorMode0(long display, long screenResources, long monitorInfo, int monitor_idx, int mode_id, int rotation, int x, int y); + private static native boolean setScreenViewport0(long display, int screen_index, long screenResources, int x, int y, int width, int height); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index cd8da9b60..ba22a6ce4 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -33,23 +33,29 @@ */ package jogamp.newt.driver.x11; +import java.util.ArrayList; import java.util.List; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.util.Rectangle; import jogamp.nativewindow.x11.X11Util; +import jogamp.newt.Debug; import jogamp.newt.DisplayImpl; +import jogamp.newt.MonitorModeProps; import jogamp.newt.DisplayImpl.DisplayRunnable; import jogamp.newt.ScreenImpl; +import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.VersionNumber; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; -import com.jogamp.newt.ScreenMode; - -public class ScreenDriver extends ScreenImpl { +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; +public class ScreenDriver extends ScreenImpl { + protected static final boolean DEBUG_TEST_RANDR13_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableRandR13", true); + static { DisplayDriver.initSingleton(); } @@ -57,12 +63,13 @@ public class ScreenDriver extends ScreenImpl { public ScreenDriver() { } + @Override protected void createNativeImpl() { // validate screen index Long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Long run(long dpy) { return new Long(GetScreen0(dpy, screen_idx)); - } } ); + } } ); if (handle.longValue() == 0) { throw new RuntimeException("Error creating screen: " + screen_idx); } @@ -73,73 +80,116 @@ public class ScreenDriver extends ScreenImpl { int v[] = getRandRVersion0(dpy); randrVersion = new VersionNumber(v[0], v[1], 0); } - if( DEBUG ) { - System.err.println("RandR "+randrVersion); + { + final RandR13 rAndR13 = DEBUG_TEST_RANDR13_DISABLED ? null : RandR13.createInstance(randrVersion); + if( null != rAndR13 ) { + rAndR = rAndR13; + } else { + rAndR = RandR11.createInstance(randrVersion); + } } - if( !randrVersion.isZero() ) { - rAndR = new RandR11(); - } else { - rAndR = null; + if( DEBUG ) { + System.err.println("RandR "+randrVersion+", "+rAndR); + rAndR.dumpInfo(dpy, screen_idx); } } + @Override protected void closeNativeImpl() { } private VersionNumber randrVersion; private RandR rAndR; - + @Override - protected int[] getScreenModeFirstImpl() { - if( null == rAndR ) { return null; } - - return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - public int[] run(long dpy) { - return rAndR.getScreenModeFirstImpl(dpy, screen_idx); - } } ); + protected final void collectNativeMonitorModesAndDevicesImpl(MonitorModeProps.Cache cache) { + if( null == rAndR ) { return; } + final AbstractGraphicsDevice device = getDisplay().getGraphicsDevice(); + device.lock(); + try { + if( rAndR.beginInitialQuery(device.getHandle(), this) ) { + try { + final int crtCount = rAndR.getMonitorDeviceCount(device.getHandle(), this); + + // Gather all available rotations + final ArrayHashSet availableRotations = new ArrayHashSet(); + for(int i = 0; i < crtCount; i++) { + final int[] rotations = rAndR.getAvailableRotations(device.getHandle(), this, i); + if( null != rotations ) { + final List rotationList = new ArrayList(rotations.length); + for(int j=0; j 0 ) { + for(int i = 0; i < crtCount; i++) { + final int[] monitorProps = rAndR.getMonitorDeviceProps(device.getHandle(), this, cache, i); + if( null != monitorProps ) { // enabled + MonitorModeProps.streamInMonitorDevice(null, cache, this, monitorProps, 0); + } + } + } + } finally { + rAndR.endInitialQuery(device.getHandle(), this); + } + } + } finally { + device.unlock(); + } } @Override - protected int[] getScreenModeNextImpl() { - if( null == rAndR ) { return null; } - - // assemble: w x h x bpp x f x r - return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - public int[] run(long dpy) { - return rAndR.getScreenModeNextImpl(dpy, screen_idx); - } } ); + protected Rectangle getNativeMonitorDeviceViewportImpl(MonitorDevice monitor) { + final AbstractGraphicsDevice device = getDisplay().getGraphicsDevice(); + device.lock(); + try { + int[] viewportProps = rAndR.getMonitorDeviceViewport(device.getHandle(), this, monitor.getId()); + return new Rectangle(viewportProps[0], viewportProps[1], viewportProps[2], viewportProps[3]); + } finally { + device.unlock(); + } } - + @Override - protected ScreenMode getCurrentScreenModeImpl() { + protected MonitorMode queryCurrentMonitorModeImpl(final MonitorDevice monitor) { if( null == rAndR ) { return null; } - return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - public ScreenMode run(long dpy) { - return rAndR.getCurrentScreenModeImpl(dpy, screen_idx); + return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public MonitorMode run(long dpy) { + final int[] currentModeProps = rAndR.getCurrentMonitorModeProps(dpy, ScreenDriver.this, monitor.getId()); + return MonitorModeProps.streamInMonitorMode(null, null, currentModeProps, 0); } } ); } @Override - protected boolean setCurrentScreenModeImpl(final ScreenMode screenMode) { + protected boolean setCurrentMonitorModeImpl(final MonitorDevice monitor, final MonitorMode mode) { if( null == rAndR ) { return false; } - final List screenModes = this.getScreenModesOrig(); - final int screenModeIdx = screenModes.indexOf(screenMode); - if(0>screenModeIdx) { - throw new RuntimeException("ScreenMode not element of ScreenMode list: "+screenMode); - } final long t0 = System.currentTimeMillis(); boolean done = runWithTempDisplayHandle( new DisplayImpl.DisplayRunnable() { public Boolean run(long dpy) { - final int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx); - return Boolean.valueOf( rAndR.setCurrentScreenModeImpl(dpy, screen_idx, screenMode, screenModeIdx, resIdx) ); + return Boolean.valueOf( rAndR.setCurrentMonitorMode(dpy, ScreenDriver.this, monitor, mode) ); } }).booleanValue(); if(DEBUG || !done) { System.err.println("X11Screen.setCurrentScreenModeImpl: TO ("+SCREEN_MODE_CHANGE_TIMEOUT+") reached: "+ - (System.currentTimeMillis()-t0)+"ms; Current: "+getCurrentScreenMode()+"; Desired: "+screenMode); + (System.currentTimeMillis()-t0)+"ms; "+monitor.getCurrentMode()+" -> "+mode); } return done; } @@ -149,6 +199,7 @@ public class ScreenDriver extends ScreenImpl { return new Boolean(X11Util.XineramaIsEnabled(dpy)); } }; + @Override protected int validateScreenIndex(final int idx) { final DisplayDriver x11Display = (DisplayDriver) getDisplay(); final Boolean r = x11Display.isXineramaEnabled(); @@ -159,13 +210,14 @@ public class ScreenDriver extends ScreenImpl { } } - protected void getVirtualScreenOriginAndSize(final Point virtualOrigin, final Dimension virtualSize) { + @Override + protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { - virtualOrigin.setX(0); - virtualOrigin.setY(0); - virtualSize.setWidth(getWidth0(dpy, screen_idx)); - virtualSize.setHeight(getHeight0(dpy, screen_idx)); + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(getWidth0(dpy, screen_idx)); + vOriginSize.setHeight(getHeight0(dpy, screen_idx)); return null; } } ); } diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index c0552216e..1c7064a66 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -285,47 +285,32 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_stopNSApplic [pool release]; } -static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx) { +static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx, BOOL cap) { NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; + if( screen_idx<0 || screen_idx>=[screens count] ) { + if( cap ) { + screen_idx=0; + } else { + return NULL; + } + } return (NSScreen *) [screens objectAtIndex: screen_idx]; } -/* - * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: getWidthImpl - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getWidthImpl0 - (JNIEnv *env, jclass clazz, jint screen_idx) -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)screen_idx); - NSRect rect = [screen frame]; - - [pool release]; - - return (jint) (rect.size.width); -} - -/* - * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: getHeightImpl - * Signature: (I)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getHeightImpl0 - (JNIEnv *env, jclass clazz, jint screen_idx) -{ - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)screen_idx); - NSRect rect = [screen frame]; - - [pool release]; - - return (jint) (rect.size.height); +static NSScreen * NewtScreen_getNSScreenByCoord(int x, int y) { + NSArray *screens = [NSScreen screens]; + int i; + for(i=[screens count]-1; i>=0; i--) { + NSScreen * screen = (NSScreen *) [screens objectAtIndex: i]; + NSRect frame = [screen frame]; + if( x >= frame.origin.x && + y >= frame.origin.y && + x < frame.origin.x + frame.size.width && + y < frame.origin.y + frame.size.height ) { + return screen; + } + } + return (NSScreen *) [screens objectAtIndex: 0]; } static CGDirectDisplayID NewtScreen_getCGDirectDisplayIDByNSScreen(NSScreen *screen) { @@ -362,11 +347,11 @@ static long GetDictionaryLong(CFDictionaryRef theDict, const void* key) /* * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: getScreenSizeMM0 + * Method: getMonitorProps0 * Signature: (I)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScreenSizeMM0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonitorProps0 + (JNIEnv *env, jobject obj, jint crt_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -376,33 +361,46 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree timespec_now(&t0); #endif - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)scrn_idx); #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "MacScreen_getScreenSizeMM0.1: %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "MacScreen_getMonitorProps0.1: %ld ms\n", td_ms); fflush(NULL); #endif - + NSScreen *screen = NewtScreen_getNSScreenByIndex((int)crt_idx, false); + if( NULL == screen ) { + [pool release]; + return NULL; + } CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "MacScreen_getScreenSizeMM0.2: %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "MacScreen_getMonitorProps0.2: %ld ms\n", td_ms); fflush(NULL); #endif - CGSize screenDim = CGDisplayScreenSize(display); + CGSize sizeMM = CGDisplayScreenSize(display); #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "MacScreen_getScreenSizeMM0.3: %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "MacScreen_getMonitorProps0.3: %ld ms\n", td_ms); fflush(NULL); #endif - jint prop[ 2 ]; - prop[0] = (jint) screenDim.width; - prop[1] = (jint) screenDim.height; - - jintArray properties = (*env)->NewIntArray(env, 2); + CGRect bounds = CGDisplayBounds (display); + + jsize propCount = MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES; + jint prop[ propCount ]; + int offset = 0; + prop[offset++] = propCount; + prop[offset++] = crt_idx; + prop[offset++] = (jint) sizeMM.width; + prop[offset++] = (jint) sizeMM.height; + prop[offset++] = (jint) bounds.origin.x; // rotated viewport x + prop[offset++] = (jint) bounds.origin.y; // rotated viewport y + prop[offset++] = (jint) bounds.size.width; // rotated viewport width + prop[offset++] = (jint) bounds.size.height; // rotated viewport height + + jintArray properties = (*env)->NewIntArray(env, propCount); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size 2"); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); } - (*env)->SetIntArrayRegion(env, properties, 0, 2, prop); + (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); [pool release]; @@ -411,16 +409,19 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree /* * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: getScreenMode0 - * Signature: (IIII)[I + * Method: getMonitorMode0 + * Signature: (II)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScreenMode0 - (JNIEnv *env, jobject obj, jint scrn_idx, jint mode_idx, jint widthMM, jint heightMM) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getMonitorMode0 + (JNIEnv *env, jobject obj, jint crt_idx, jint mode_idx) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - int prop_num = NUM_SCREEN_MODE_PROPERTIES_ALL; - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)scrn_idx); + NSScreen *screen = NewtScreen_getNSScreenByIndex((int)crt_idx, false); + if( NULL == screen ) { + [pool release]; + return NULL; + } CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); CFArrayRef availableModes = CGDisplayAvailableModes(display); @@ -429,12 +430,13 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree CFDictionaryRef mode = NULL; int currentCCWRot = (int)CGDisplayRotation(display); jint ccwRot = 0; + int nativeId = 0; #ifdef VERBOSE_ON if(0 >= mode_idx) { // only for current mode (-1) and first mode (scanning) DBG_PRINT( "getScreenMode0: scrn %d (%p, %p), mode %d, avail: %d/%d, current rot %d ccw\n", - (int)scrn_idx, screen, (void*)(intptr_t)display, (int)mode_idx, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots, currentCCWRot); + (int)crt_idx, screen, (void*)(intptr_t)display, (int)mode_idx, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots, currentCCWRot); } #endif @@ -443,16 +445,18 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree DBG_PRINT( "getScreenMode0: end of modes: mode %d, avail: %d/%d\n", (int)mode_idx, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots); [pool release]; - return (*env)->NewIntArray(env, 0); + return NULL; } else if(-1 < mode_idx) { // only at initialization time, where index >= 0 - prop_num++; // add 1st extra prop, mode_idx - mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, mode_idx / ROTMODES_PER_REALMODE); + nativeId = mode_idx / ROTMODES_PER_REALMODE; ccwRot = mode_idx % ROTMODES_PER_REALMODE * 90; + mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, nativeId); } else { // current mode mode = CGDisplayCurrentMode(display); ccwRot = currentCCWRot; + CFRange range = CFRangeMake (0, numberOfAvailableModes); + nativeId = CFArrayGetFirstIndexOfValue(availableModes, range, (CFDictionaryRef)mode); } // mode = CGDisplayModeRetain(mode); // 10.6 on CGDisplayModeRef @@ -466,36 +470,30 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree mHeight = tempWidth; } - jint prop[ prop_num ]; + jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; - int propIndexRes = 0; - if( -1 < mode_idx ) { - prop[propIndex++] = mode_idx; - } int refreshRate = CGDDGetModeRefreshRate(mode); int fRefreshRate = ( 0 < refreshRate ) ? refreshRate : 60; // default .. (experienced on OSX 10.6.8) - prop[propIndex++] = 0; // set later for verification of iterator - propIndexRes = propIndex; + prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; prop[propIndex++] = mWidth; prop[propIndex++] = mHeight; prop[propIndex++] = CGDDGetModeBitsPerPixel(mode); - prop[propIndex++] = widthMM; - prop[propIndex++] = heightMM; - prop[propIndex++] = fRefreshRate; + prop[propIndex++] = fRefreshRate * 100; // Hz*100 + prop[propIndex++] = 0; // flags + prop[propIndex++] = nativeId; prop[propIndex++] = ccwRot; - prop[propIndex - NUM_SCREEN_MODE_PROPERTIES_ALL] = ( -1 < mode_idx ) ? propIndex-1 : propIndex ; // count == NUM_SCREEN_MODE_PROPERTIES_ALL - DBG_PRINT( "getScreenMode0: Mode %d/%d (%d): %dx%d, %d bpp, %dx%d mm, %d / %d Hz, rot %d ccw\n", + DBG_PRINT( "getScreenMode0: Mode %d/%d (%d): %dx%d, %d bpp, %d / %d Hz, nativeId %d, rot %d ccw\n", (int)mode_idx, (int)numberOfAvailableModesRots, (int)numberOfAvailableModes, - (int)prop[propIndexRes+0], (int)prop[propIndexRes+1], (int)prop[propIndexRes+2], - (int)prop[propIndexRes+3], (int)prop[propIndexRes+4], (int)prop[propIndexRes+5], refreshRate, (int)prop[propIndexRes+6]); + (int)prop[1], (int)prop[2], (int)prop[3], + (int)prop[4], refreshRate, (int)prop[6], (int)prop[7]); - jintArray properties = (*env)->NewIntArray(env, prop_num); + jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", prop_num); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } - (*env)->SetIntArrayRegion(env, properties, 0, prop_num, prop); + (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); // CGDisplayModeRelease(mode); // 10.6 on CGDisplayModeRef [pool release]; @@ -505,36 +503,47 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_getScree /* * Class: jogamp_newt_driver_macosx_ScreenDriver - * Method: setScreenMode0 - * Signature: (II)Z + * Method: setMonitorMode0 + * Signature: (III)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_setScreenMode0 - (JNIEnv *env, jobject object, jint scrn_idx, jint mode_idx) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_ScreenDriver_setMonitorMode0 + (JNIEnv *env, jobject object, jint crt_idx, jint nativeId, jint ccwRot) { jboolean res = JNI_TRUE; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSScreen *screen = NewtScreen_getNSScreenByIndex((int)scrn_idx); + NSScreen *screen = NewtScreen_getNSScreenByIndex((int)crt_idx, false); + if( NULL == screen ) { + [pool release]; + return JNI_FALSE; + } CGDirectDisplayID display = NewtScreen_getCGDirectDisplayIDByNSScreen(screen); CFArrayRef availableModes = CGDisplayAvailableModes(display); -#ifdef VERBOSE_ON CFIndex numberOfAvailableModes = CFArrayGetCount(availableModes); +#ifdef VERBOSE_ON CFIndex numberOfAvailableModesRots = ROTMODES_PER_REALMODE * numberOfAvailableModes; #endif - CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, mode_idx / ROTMODES_PER_REALMODE); - // mode = CGDisplayModeRetain(mode); // 10.6 on CGDisplayModeRef - int ccwRot = mode_idx % ROTMODES_PER_REALMODE * 90; - DBG_PRINT( "setScreenMode0: scrn %d (%p, %p), mode %d, rot %d ccw, avail: %d/%d\n", - (int)scrn_idx, screen, (void*)(intptr_t)display, (int)mode_idx, ccwRot, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots); + DBG_PRINT( "setScreenMode0: scrn %d (%p, %p), nativeID %d, rot %d ccw, avail: %d/%d\n", + (int)crt_idx, screen, (void*)(intptr_t)display, (int)nativeId, ccwRot, (int)numberOfAvailableModes, (int)numberOfAvailableModesRots); + + CFDictionaryRef mode = NULL; - if(ccwRot!=0) { + if( 0 != ccwRot ) { // FIXME: How to rotate the display/screen on OSX programmatically ? DBG_PRINT( "setScreenMode0: Don't know how to rotate screen on OS X: rot %d ccw\n", ccwRot); res = JNI_FALSE; + } else { + if( numberOfAvailableModes <= nativeId ) { + res = JNI_FALSE; + } else { + mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, nativeId); + // mode = CGDisplayModeRetain(mode); // 10.6 on CGDisplayModeRef + } } - if(JNI_TRUE == res) { + + if( NULL != mode ) { CGError err = CGDisplaySwitchToMode(display, mode); if(kCGErrorSuccess != err) { DBG_PRINT( "setScreenMode0: SetMode failed: %d\n", (int)err); @@ -593,21 +602,18 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initIDs0 /** * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createView0 - * Signature: (IIIIZI)J + * Signature: (IIIIZ)J */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 (JNIEnv *env, jobject jthis, jint x, jint y, jint w, jint h, - jboolean fullscreen, jint screen_idx) + jboolean fullscreen) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - DBG_PRINT( "createView0 - %p (this), %d/%d %dx%d, fs %d, screenidx %d (START)\n", - (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, (int)screen_idx); + DBG_PRINT( "createView0 - %p (this), %d/%d %dx%d, fs %d (START)\n", + (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen); - NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; - NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; + NSScreen *myScreen = NewtScreen_getNSScreenByCoord(x, y); NSRect rectWin; if (fullscreen) { @@ -634,24 +640,21 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: createWindow0 - * Signature: (IIIIZIIIJ)J + * Signature: (IIIIZIIJ)J */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow0 (JNIEnv *env, jobject jthis, jint x, jint y, jint w, jint h, - jboolean fullscreen, jint styleMask, jint bufferingType, jint screen_idx, jlong jview) + jboolean fullscreen, jint styleMask, jint bufferingType, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* myView = (NewtView*) (intptr_t) jview ; DBG_PRINT( "createWindow0 - %p (this), %d/%d %dx%d, fs %d, style %X, buffType %X, screenidx %d, view %p (START)\n", (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, - (int)styleMask, (int)bufferingType, (int)screen_idx, myView); + (int)styleMask, (int)bufferingType, myView); (void)myView; - NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; - NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; + NSScreen *myScreen = NewtScreen_getNSScreenByCoord(x, y); NSRect rectWin; if (fullscreen) { @@ -670,7 +673,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow styleMask: (NSUInteger) styleMask backing: (NSBackingStoreType) bufferingType defer: YES - screen: myScreen isFullscreenWindow: fullscreen]; // DBG_PRINT( "createWindow0.1 - %p, isVisible %d\n", myWindow, [myWindow isVisible]); @@ -687,26 +689,23 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow * * Class: jogamp_newt_driver_macosx_WindowDriver * Method: initWindow0 - * Signature: (JJIIIIZZZIJ)V + * Signature: (JJIIIIZZZJ)V */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 (JNIEnv *env, jobject jthis, jlong parent, jlong window, jint x, jint y, jint w, jint h, - jboolean opaque, jboolean fullscreen, jboolean visible, jint screen_idx, jlong jview) + jboolean opaque, jboolean fullscreen, jboolean visible, jlong jview) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* myWindow = (NewtMacWindow*) ((intptr_t) window); NewtView* myView = (NewtView*) (intptr_t) jview ; - DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, visible %d, screenidx %d, view %p (START)\n", + DBG_PRINT( "initWindow0 - %p (this), %p (parent), %p (window), %d/%d %dx%d, opaque %d, fs %d, visible %d, view %p (START)\n", (void*)(intptr_t)jthis, (void*)(intptr_t)parent, myWindow, (int)x, (int)y, (int)w, (int)h, - (int) opaque, (int)fullscreen, (int)visible, (int)screen_idx, myView); + (int) opaque, (int)fullscreen, (int)visible, myView); - NSArray *screens = [NSScreen screens]; - if(screen_idx<0) screen_idx=0; - if(screen_idx>=[screens count]) screen_idx=0; - NSScreen *myScreen = (NSScreen *) [screens objectAtIndex: screen_idx]; - NSRect rectWin; + NSScreen *myScreen = NewtScreen_getNSScreenByCoord(x, y); + NSRect rectWin; if (fullscreen) { rectWin = [myScreen frame]; x = 0; diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index 09f4a1fd3..c9d53f53b 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -128,7 +128,6 @@ styleMask: (NSUInteger) windowStyle backing: (NSBackingStoreType) bufferingType defer: (BOOL) deferCreation - screen:(NSScreen *)screen isFullscreenWindow:(BOOL)isfs; #ifdef DBG_LIFECYCLE - (void) release; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 005e82d72..35d3ffbc5 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -439,14 +439,12 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { styleMask: (NSUInteger) windowStyle backing: (NSBackingStoreType) bufferingType defer: (BOOL) deferCreation - screen:(NSScreen *)screen isFullscreenWindow:(BOOL)isfs { id res = [super initWithContentRect: contentRect styleMask: windowStyle backing: bufferingType - defer: deferCreation - screen: screen]; + defer: deferCreation]; isFullscreenWindow = isfs; // Why is this necessary? Without it we don't get any of the // delegate methods like resizing and window movement. diff --git a/src/newt/native/ScreenMode.h b/src/newt/native/ScreenMode.h index bb782910e..110f1c493 100644 --- a/src/newt/native/ScreenMode.h +++ b/src/newt/native/ScreenMode.h @@ -33,12 +33,17 @@ #ifndef _SCREEN_MODE_H #define _SCREEN_MODE_H -#define NUM_RESOLUTION_PROPERTIES 2 /* width, height */ -#define NUM_SURFACE_SIZE_PROPERTIES 1 /* bpp */ -#define NUM_MONITOR_MODE_PROPERTIES 3 /* ScreenSizeMM[width, height], refresh-rate */ -#define NUM_SCREEN_MODE_PROPERTIES 1 /* rotation */ +#define NUM_RESOLUTION_PROPERTIES 2 /* width, height */ +#define NUM_SURFACE_SIZE_PROPERTIES 1 /* bpp */ +#define NUM_SIZEANDRATE_PROPERTIES 2 /* refresh-rate, flags */ +#define NUM_MONITOR_MODE_PROPERTIES 2 /* id, rotation */ -#define NUM_SCREEN_MODE_PROPERTIES_ALL 8 /* count + the above */ +#define NUM_MONITOR_MODE_PROPERTIES_ALL 8 /* count + the above */ + +#define MIN_MONITOR_DEVICE_PROPERTIES 11 /* count + id, ScreenSizeMM[width, height], rotated Viewport[x, y, width, height], currentMonitorModeId, rotation, supportedModeId+ */ + +#define FLAG_INTERLACE ( 1 << 0 ) +#define FLAG_DOUBLESCAN ( 1 << 1 ) #endif diff --git a/src/newt/native/Window.h b/src/newt/native/Window.h index 4755c4fc5..d9ee5fd1f 100644 --- a/src/newt/native/Window.h +++ b/src/newt/native/Window.h @@ -38,8 +38,9 @@ #define FLAG_HAS_PARENT ( 1 << 8 ) #define FLAG_IS_UNDECORATED ( 1 << 9 ) #define FLAG_IS_FULLSCREEN ( 1 << 10 ) -#define FLAG_IS_ALWAYSONTOP ( 1 << 11 ) -#define FLAG_IS_VISIBLE ( 1 << 12 ) +#define FLAG_IS_FULLSCREEN_SPAN ( 1 << 11 ) +#define FLAG_IS_ALWAYSONTOP ( 1 << 12 ) +#define FLAG_IS_VISIBLE ( 1 << 13 ) #define TST_FLAG_CHANGE_PARENTING(f) ( 0 != ( (f) & FLAG_CHANGE_PARENTING ) ) #define TST_FLAG_CHANGE_DECORATION(f) ( 0 != ( (f) & FLAG_CHANGE_DECORATION ) ) @@ -47,11 +48,11 @@ #define TST_FLAG_CHANGE_ALWAYSONTOP(f) ( 0 != ( (f) & FLAG_CHANGE_ALWAYSONTOP ) ) #define TST_FLAG_CHANGE_VISIBILITY(f) ( 0 != ( (f) & FLAG_CHANGE_VISIBILITY ) ) -#define TST_FLAG_HAS_PARENT(f) ( 0 != ( (f) & FLAG_HAS_PARENT ) ) -#define TST_FLAG_IS_UNDECORATED(f) ( 0 != ( (f) & FLAG_IS_UNDECORATED ) ) -#define TST_FLAG_IS_FULLSCREEN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN ) ) -#define TST_FLAG_IS_FULLSCREEN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN ) ) -#define TST_FLAG_IS_ALWAYSONTOP(f) ( 0 != ( (f) & FLAG_IS_ALWAYSONTOP ) ) -#define TST_FLAG_IS_VISIBLE(f) ( 0 != ( (f) & FLAG_IS_VISIBLE ) ) +#define TST_FLAG_HAS_PARENT(f) ( 0 != ( (f) & FLAG_HAS_PARENT ) ) +#define TST_FLAG_IS_UNDECORATED(f) ( 0 != ( (f) & FLAG_IS_UNDECORATED ) ) +#define TST_FLAG_IS_FULLSCREEN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN ) ) +#define TST_FLAG_IS_FULLSCREEN_SPAN(f) ( 0 != ( (f) & FLAG_IS_FULLSCREEN_SPAN ) ) +#define TST_FLAG_IS_ALWAYSONTOP(f) ( 0 != ( (f) & FLAG_IS_ALWAYSONTOP ) ) +#define TST_FLAG_IS_VISIBLE(f) ( 0 != ( (f) & FLAG_IS_VISIBLE ) ) #endif diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 5c1115592..7ede3a20d 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -101,6 +101,9 @@ #ifndef DISPLAY_DEVICE_ACTIVE #define DISPLAY_DEVICE_ACTIVE 0x00000001 #endif +#ifndef DM_INTERLACED +#define DM_INTERLACED 2 +#endif #include "jogamp_newt_driver_windows_DisplayDriver.h" #include "jogamp_newt_driver_windows_ScreenDriver.h" @@ -1116,11 +1119,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_DispatchMes /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getOriginX0 - * Signature: (I)I + * Method: getVirtualOriginX0 + * Signature: ()I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginX0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getVirtualOriginX0 + (JNIEnv *env, jobject obj) { if( GetSystemMetrics( SM_CMONITORS) > 1) { return (jint)GetSystemMetrics(SM_XVIRTUALSCREEN); @@ -1131,11 +1134,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginX0 /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getOriginY0 - * Signature: (I)I + * Method: getVirtualOriginY0 + * Signature: ()I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginY0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getVirtualOriginY0 + (JNIEnv *env, jobject obj) { if( GetSystemMetrics( SM_CMONITORS ) > 1) { return (jint)GetSystemMetrics(SM_YVIRTUALSCREEN); @@ -1146,11 +1149,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getOriginY0 /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getWidthImpl - * Signature: (I)I + * Method: getVirtualWidthImpl + * Signature: ()I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getWidthImpl0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getVirtualWidthImpl0 + (JNIEnv *env, jobject obj) { if( GetSystemMetrics( SM_CMONITORS) > 1) { return (jint)GetSystemMetrics(SM_CXVIRTUALSCREEN); @@ -1161,11 +1164,11 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getWidthImpl /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getHeightImpl - * Signature: (I)I + * Method: getVirtualHeightImpl + * Signature: ()I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getHeightImpl0 - (JNIEnv *env, jobject obj, jint scrn_idx) +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getVirtualHeightImpl0 + (JNIEnv *env, jobject obj) { if( GetSystemMetrics( SM_CMONITORS ) > 1) { return (jint)GetSystemMetrics(SM_CYVIRTUALSCREEN); @@ -1217,65 +1220,137 @@ static int NewtScreen_RotationNewtCCW2NativeCCW(JNIEnv *env, jint newt) { return native; } -/* -static void NewtScreen_scanDisplayDevices() { - DISPLAY_DEVICE device; - int i = 0; - LPCTSTR name; - while(NULL != (name = NewtScreen_getDisplayDeviceName(&device, i))) { - DBG_PRINT("*** [%d]: <%s> active %d\n", i, name, ( 0 != ( device.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); - i++; +static LPCTSTR NewtScreen_getAdapterName(DISPLAY_DEVICE * device, int crt_idx) { + memset(device, 0, sizeof(DISPLAY_DEVICE)); + device->cb = sizeof(DISPLAY_DEVICE); + if( FALSE == EnumDisplayDevices(NULL, crt_idx, device, 0) ) { + DBG_PRINT("*** WindowsWindow: getAdapterName.EnumDisplayDevices(crt_idx %d) -> FALSE\n", crt_idx); + return NULL; } -}*/ -static LPCTSTR NewtScreen_getDisplayDeviceName(DISPLAY_DEVICE * device, int scrn_idx) { - device->cb = sizeof(DISPLAY_DEVICE); - if( FALSE == EnumDisplayDevices(NULL, scrn_idx, device, 0) ) { - DBG_PRINT("*** WindowsWindow: getDisplayDeviceName.EnumDisplayDevices(scrn_idx %d) -> FALSE\n", scrn_idx); + if( NULL == device->DeviceName || 0 == _tcslen(device->DeviceName) ) { return NULL; } - if( 0 == ( device->StateFlags & DISPLAY_DEVICE_ACTIVE ) ) { - DBG_PRINT("*** WindowsWindow: !DISPLAY_DEVICE_ACTIVE(scrn_idx %d)\n", scrn_idx); + return device->DeviceName; +} + +static LPCTSTR NewtScreen_getMonitorName(LPCTSTR adapterName, DISPLAY_DEVICE * device, int monitor_idx, BOOL onlyActive) { + memset(device, 0, sizeof(DISPLAY_DEVICE)); + device->cb = sizeof(DISPLAY_DEVICE); + if( 0 == monitor_idx ) { + if( FALSE == EnumDisplayDevices(adapterName, monitor_idx, device, 0) ) { + DBG_PRINT("*** WindowsWindow: getDisplayName.EnumDisplayDevices(monitor_idx %d).adapter -> FALSE\n", monitor_idx); + return NULL; + } + } + + if( onlyActive && 0 == ( device->StateFlags & DISPLAY_DEVICE_ACTIVE ) ) { + DBG_PRINT("*** WindowsWindow: !DISPLAY_DEVICE_ACTIVE(monitor_idx %d).display\n", monitor_idx); + return NULL; + } + if( NULL == device->DeviceName || 0 == _tcslen(device->DeviceName) ) { return NULL; } return device->DeviceName; } +JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_dumpMonitorInfo0 + (JNIEnv *env, jclass clazz) +{ + DISPLAY_DEVICE aDevice, dDevice; + int i = 0, j; + LPCTSTR aName, dName; + while(NULL != (aName = NewtScreen_getAdapterName(&aDevice, i))) { + fprintf(stderr, "*** [%d]: <%s> flags 0x%X active %d\n", i, aName, aDevice.StateFlags, ( 0 != ( aDevice.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); + j=0; + while(NULL != (dName = NewtScreen_getMonitorName(aName, &dDevice, j, FALSE))) { + fprintf(stderr, "*** [%d][%d]: <%s> flags 0x%X active %d\n", i, j, dName, dDevice.StateFlags, ( 0 != ( dDevice.StateFlags & DISPLAY_DEVICE_ACTIVE ) ) ); + j++; + } + i++; + } +} + static HDC NewtScreen_createDisplayDC(LPCTSTR displayDeviceName) { return CreateDC("DISPLAY", displayDeviceName, NULL, NULL); } /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: getScreenMode0 - * Signature: (II)[I + * Method: getAdapterName0 + * Signature: (I)Ljava/lang/String; */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getScreenMode0 - (JNIEnv *env, jobject obj, jint scrn_idx, jint mode_idx) +JNIEXPORT jstring JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getAdapterName0 + (JNIEnv *env, jobject obj, jint crt_idx) { DISPLAY_DEVICE device; - int prop_num = NUM_SCREEN_MODE_PROPERTIES_ALL; - LPCTSTR deviceName = NewtScreen_getDisplayDeviceName(&device, scrn_idx); - if(NULL == deviceName) { - DBG_PRINT("*** WindowsWindow: getScreenMode.getDisplayDeviceName(scrn_idx %d) -> NULL\n", scrn_idx); - return (*env)->NewIntArray(env, 0); + LPCTSTR adapterName = NewtScreen_getAdapterName(&device, crt_idx); + DBG_PRINT("*** WindowsWindow: getAdapterName(crt_idx %d) -> %s, active %d\n", crt_idx, + (NULL==adapterName?"nil":adapterName), 0 == ( device.StateFlags & DISPLAY_DEVICE_ACTIVE )); + if(NULL == adapterName) { + return NULL; } +#ifdef UNICODE + return (*env)->NewString(env, adapterName, wcslen(adapterName)); +#else + return (*env)->NewStringUTF(env, adapterName); +#endif +} + +/* + * Class: jogamp_newt_driver_windows_ScreenDriver + * Method: getActiveMonitorName0 + * Signature: (Ljava/lang/String;I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getActiveMonitorName0 + (JNIEnv *env, jobject obj, jstring jAdapterName, jint monitor_idx) +{ + DISPLAY_DEVICE device; + LPCTSTR monitorName; +#ifdef UNICODE + LPCTSTR adapterName = NewtCommon_GetNullTerminatedStringChars(env, jAdapterName); + monitorName = NewtScreen_getMonitorName(adapterName, &device, monitor_idx, TRUE); + DBG_PRINT("*** WindowsWindow: getMonitorName(%s, monitor_idx %d) -> %s\n", adapterName, monitor_idx, (NULL==monitorName?"nil":monitorName)); + free((void*) adapterName); +#else + LPCTSTR adapterName = (*env)->GetStringUTFChars(env, jAdapterName, NULL); + monitorName = NewtScreen_getMonitorName(adapterName, &device, monitor_idx, TRUE); + DBG_PRINT("*** WindowsWindow: getMonitorName(%s, monitor_idx %d) -> %s\n", adapterName, monitor_idx, (NULL==monitorName?"nil":monitorName)); + (*env)->ReleaseStringUTFChars(env, jAdapterName, adapterName); +#endif + if(NULL == monitorName) { + return NULL; + } +#ifdef UNICODE + return (*env)->NewString(env, monitorName, wcslen(monitorName)); +#else + return (*env)->NewStringUTF(env, monitorName); +#endif +} +/* + * Class: jogamp_newt_driver_windows_ScreenDriver + * Method: getMonitorMode0 + * Signature: (Ljava/lang/String;I)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMonitorMode0 + (JNIEnv *env, jobject obj, jstring jAdapterName, jint mode_idx) +{ + DISPLAY_DEVICE device; + LPCTSTR adapterName; + { +#ifdef UNICODE + adapterName = NewtCommon_GetNullTerminatedStringChars(env, jAdapterName); +#else + adapterName = (*env)->GetStringUTFChars(env, jAdapterName, NULL); +#endif + } int devModeID; - int widthmm, heightmm; if(-1 < mode_idx) { - // only at initialization time, where index >= 0 - HDC hdc = NewtScreen_createDisplayDC(deviceName); - widthmm = GetDeviceCaps(hdc, HORZSIZE); - heightmm = GetDeviceCaps(hdc, VERTSIZE); - DeleteDC(hdc); devModeID = (int) mode_idx; - prop_num++; // add 1st extra prop, mode_idx } else { - widthmm = 0; - heightmm = 0; devModeID = ENUM_CURRENT_SETTINGS; } @@ -1283,11 +1358,18 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getScre ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); - if (0 == EnumDisplaySettingsEx(deviceName, devModeID, &dm, ( ENUM_CURRENT_SETTINGS == devModeID ) ? 0 : EDS_ROTATEDMODE)) { - DBG_PRINT("*** WindowsWindow: getScreenMode.EnumDisplaySettingsEx(mode_idx %d/%d) -> NULL\n", mode_idx, devModeID); + int res = EnumDisplaySettingsEx(adapterName, devModeID, &dm, ( ENUM_CURRENT_SETTINGS == devModeID ) ? 0 : EDS_ROTATEDMODE); + DBG_PRINT("*** WindowsWindow: getMonitorMode.EnumDisplaySettingsEx(%s, mode_idx %d/%d) -> %d\n", adapterName, mode_idx, devModeID, res); +#ifdef UNICODE + free((void*) adapterName); +#else + (*env)->ReleaseStringUTFChars(env, jAdapterName, adapterName); +#endif + + if (0 == res) { return (*env)->NewIntArray(env, 0); } - + // swap width and height, since Windows reflects rotated dimension, we don't if (DMDO_90 == dm.dmDisplayOrientation || DMDO_270 == dm.dmDisplayOrientation) { int tempWidth = dm.dmPelsWidth; @@ -1295,43 +1377,110 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getScre dm.dmPelsHeight = tempWidth; } - jint prop[ prop_num ]; + int flags = 0; + if( 0 != ( dm.dmDisplayFlags & DM_INTERLACED ) ) { + flags |= FLAG_INTERLACE; + } + + jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; - if( -1 < mode_idx ) { - prop[propIndex++] = mode_idx; - } - prop[propIndex++] = 0; // set later for verification of iterator + prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; prop[propIndex++] = dm.dmPelsWidth; prop[propIndex++] = dm.dmPelsHeight; prop[propIndex++] = dm.dmBitsPerPel; - prop[propIndex++] = widthmm; - prop[propIndex++] = heightmm; - prop[propIndex++] = dm.dmDisplayFrequency; + prop[propIndex++] = dm.dmDisplayFrequency * 100; // Hz*100 + prop[propIndex++] = flags; + prop[propIndex++] = 0; // not bound to id prop[propIndex++] = NewtScreen_RotationNativeCCW2NewtCCW(env, dm.dmDisplayOrientation); - prop[propIndex - NUM_SCREEN_MODE_PROPERTIES_ALL] = ( -1 < mode_idx ) ? propIndex-1 : propIndex ; // count == NUM_SCREEN_MODE_PROPERTIES_ALL - jintArray properties = (*env)->NewIntArray(env, prop_num); + jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", prop_num); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } - (*env)->SetIntArrayRegion(env, properties, 0, prop_num, prop); + (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; } /* * Class: jogamp_newt_driver_windows_ScreenDriver - * Method: setScreenMode0 - * Signature: (IIIIII)Z + * Method: getMonitorDevice0 + * Signature: (Ljava/lang/String;I)[I */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScreenMode0 - (JNIEnv *env, jobject object, jint scrn_idx, jint width, jint height, jint bits, jint rate, jint rot) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_getMonitorDevice0 + (JNIEnv *env, jobject obj, jstring jAdapterName, jint monitor_idx) { DISPLAY_DEVICE device; - LPCTSTR deviceName = NewtScreen_getDisplayDeviceName(&device, scrn_idx); - if(NULL == deviceName) { - DBG_PRINT("*** WindowsWindow: setScreenMode.getDisplayDeviceName(scrn_idx %d) -> NULL\n", scrn_idx); + LPCTSTR adapterName; + { +#ifdef UNICODE + adapterName = NewtCommon_GetNullTerminatedStringChars(env, jAdapterName); +#else + adapterName = (*env)->GetStringUTFChars(env, jAdapterName, NULL); +#endif + } + + HDC hdc = NewtScreen_createDisplayDC(adapterName); + int widthmm = GetDeviceCaps(hdc, HORZSIZE); + int heightmm = GetDeviceCaps(hdc, VERTSIZE); + DeleteDC(hdc); + int devModeID = ENUM_CURRENT_SETTINGS; + + DEVMODE dm; + ZeroMemory(&dm, sizeof(dm)); + dm.dmSize = sizeof(dm); + + int res = EnumDisplaySettingsEx(adapterName, devModeID, &dm, 0); + DBG_PRINT("*** WindowsWindow: getMonitorDevice.EnumDisplaySettingsEx(%s, devModeID %d) -> %d\n", adapterName, devModeID, res); +#ifdef UNICODE + free((void*) adapterName); +#else + (*env)->ReleaseStringUTFChars(env, jAdapterName, adapterName); +#endif + if (0 == res) { + return (*env)->NewIntArray(env, 0); + } + + jsize propCount = MIN_MONITOR_DEVICE_PROPERTIES - 1 - NUM_MONITOR_MODE_PROPERTIES; + jint prop[ propCount ]; + int propIndex = 0; + + prop[propIndex++] = propCount; + prop[propIndex++] = monitor_idx; + prop[propIndex++] = widthmm; + prop[propIndex++] = heightmm; + prop[propIndex++] = dm.dmPosition.x; // rotated viewport + prop[propIndex++] = dm.dmPosition.y; // rotated viewport + prop[propIndex++] = dm.dmPelsWidth; // rotated viewport + prop[propIndex++] = dm.dmPelsHeight; // rotated viewport + + jintArray properties = (*env)->NewIntArray(env, propCount); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); + } + (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); + + return properties; +} + +/* + * Class: jogamp_newt_driver_windows_ScreenDriver + * Method: setMonitorMode0 + * Signature: (IIIIIIIII)Z + */ +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setMonitorMode0 + (JNIEnv *env, jobject object, jint monitor_idx, jint x, jint y, jint width, jint height, jint bits, jint rate, jint flags, jint rot) +{ + DISPLAY_DEVICE adapterDevice, monitorDevice; + LPCTSTR adapterName = NewtScreen_getAdapterName(&adapterDevice, monitor_idx); + if(NULL == adapterName) { + DBG_PRINT("*** WindowsWindow: setMonitorMode.getAdapterName(monitor_idx %d) -> NULL\n", monitor_idx); + return JNI_FALSE; + } + LPCTSTR monitorName = NewtScreen_getMonitorName(adapterName, &monitorDevice, 0, TRUE); + if(NULL == monitorName) { + DBG_PRINT("*** WindowsWindow: setMonitorMode.getMonitorName(monitor_idx 0) -> NULL\n"); return JNI_FALSE; } @@ -1339,10 +1488,17 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScree // initialize the DEVMODE structure ZeroMemory(&dm, sizeof(dm)); dm.dmSize = sizeof(dm); + if( 0 <= x && 0 <= y ) { + dm.dmPosition.x = (int)x; + dm.dmPosition.y = (int)y; + } dm.dmPelsWidth = (int)width; dm.dmPelsHeight = (int)height; dm.dmBitsPerPel = (int)bits; dm.dmDisplayFrequency = (int)rate; + if( 0 != ( flags & FLAG_INTERLACE ) ) { + dm.dmDisplayFlags |= DM_INTERLACED; + } dm.dmDisplayOrientation = NewtScreen_RotationNewtCCW2NativeCCW(env, rot); // swap width and height, since Windows reflects rotated dimension, we don't @@ -1352,9 +1508,12 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_ScreenDriver_setScree dm.dmPelsHeight = tempWidth; } - dm.dmFields = DM_DISPLAYORIENTATION | DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY; + dm.dmFields = DM_DISPLAYORIENTATION | DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS; + if( 0 <= x && 0 <= y ) { + dm.dmFields |= DM_POSITION; + } - return ( DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettings(&dm, 0) ) ? JNI_TRUE : JNI_FALSE ; + return ( DISP_CHANGE_SUCCESSFUL == ChangeDisplaySettingsEx(adapterName, &dm, NULL, 0, NULL) ) ? JNI_TRUE : JNI_FALSE ; } /* diff --git a/src/newt/native/X11RandR11.c b/src/newt/native/X11RandR11.c index cbf911a38..81a6726b5 100644 --- a/src/newt/native/X11RandR11.c +++ b/src/newt/native/X11RandR11.c @@ -30,10 +30,10 @@ /* * Class: jogamp_newt_driver_x11_RandR11 - * Method: getAvailableScreenModeRotations0 + * Method: getAvailableScreenRotations0 * Signature: (JI)I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getAvailableScreenModeRotations0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getAvailableScreenRotations0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -75,10 +75,10 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getAvailableScre /* * Class: jogamp_newt_driver_x11_RandR11 - * Method: getNumScreenModeResolution0 + * Method: getNumScreenResolution0 * Signature: (JI)I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenModeResolutions0 +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenResolutions0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -90,7 +90,7 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenModeResol #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "X11Screen_getNumScreenResolution0.1: %ld ms\n", td_ms); fflush(NULL); #endif int num_sizes; @@ -98,20 +98,20 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR11_getNumScreenModeResol #ifdef DBG_PERF timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); + fprintf(stderr, "X11Screen_getNumScreenResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL); #endif - DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); + DBG_PRINT("getNumScreenResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes); return num_sizes; } /* * Class: jogamp_newt_driver_x11_RandR11 - * Method: getScreenModeResolutions0 + * Method: getScreenResolutions0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeResolution0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenResolution0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -145,10 +145,10 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeRes /* * Class: jogamp_newt_driver_x11_RandR11 - * Method: getScreenModeRates0 + * Method: getScreenRates0 * Signature: (JII)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenModeRates0 +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR11_getScreenRates0 (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) { Display *dpy = (Display *) (intptr_t) display; @@ -289,36 +289,20 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR11_setCurrentScreenM int num_sizes; XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - int rot; if( 0 > resMode_idx || resMode_idx >= num_sizes ) { NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); } - switch(rotation) { - case 0: - rot = RR_Rotate_0; - break; - case 90: - rot = RR_Rotate_90; - break; - case 180: - rot = RR_Rotate_180; - break; - case 270: - rot = RR_Rotate_270; - break; - default: - NewtCommon_throwNewRuntimeException(env, "Invalid rotation: %d", rotation); - } - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); + int xrot = NewtScreen_Degree2XRotation(env, rotation); + XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); + XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, xrot, (short)freq, CurrentTime); XSync(dpy, False); return JNI_TRUE; diff --git a/src/newt/native/X11RandR13.c b/src/newt/native/X11RandR13.c index ea72cd35d..92c20e893 100644 --- a/src/newt/native/X11RandR13.c +++ b/src/newt/native/X11RandR13.c @@ -38,22 +38,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenResources0 { Display *dpy = (Display *) (intptr_t) display; Window root = RootWindow(dpy, (int)screen_idx); -#ifdef DBG_PERF - struct timespec t0, t1, td; - long td_ms; - timespec_now(&t0); -#endif - -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenResources0.1: %ld ms\n", td_ms); fflush(NULL); -#endif - - XRRScreenResources *res = XRRGetScreenResourcesCurrent( dpy, root); -#ifdef DBG_PERF - timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td); - fprintf(stderr, "X11Screen_getScreenResources0.2 (XRRScreenResources): %ld ms\n", td_ms); fflush(NULL); -#endif + + XRRScreenResources *res = XRRGetScreenResourcesCurrent( dpy, root); // 1.3 + // XRRScreenResources *res = XRRGetScreenResources( dpy, root); // 1.2 return (jlong) (intptr_t) res; } @@ -66,48 +53,166 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenResources0 JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_freeScreenResources0 (JNIEnv *env, jclass clazz, jlong screenResources) { - XRRFreeScreenResources( (XRRScreenResources *) (intptr_t) screenResources ); + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + if( NULL != resources ) { + XRRFreeScreenResources( resources ); + } +} + +#define SAFE_STRING(s) (NULL==s?"":s) + +static void dumpOutputs(const char *prefix, Display *dpy, XRRScreenResources *resources, int noutput, RROutput * outputs) { + int i, j; + fprintf(stderr, "%s %p: Output count %d\n", prefix, resources, noutput); + for(i=0; icrtc, SAFE_STRING(xrrOutputInfo->name), xrrOutputInfo->nameLen, xrrOutputInfo->mm_width, xrrOutputInfo->mm_height, + xrrOutputInfo->ncrtc, xrrOutputInfo->nmode, xrrOutputInfo->npreferred); + for(j=0; jnmode; j++) { + fprintf(stderr, " Output[%d].Mode[%d].id %#lx\n", i, j, xrrOutputInfo->modes[j]); + } + XRRFreeOutputInfo (xrrOutputInfo); + } } -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getOrigin0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +/** Returns vertical refresh rate in hertz */ +static float getVRefresh(XRRModeInfo *mode) { + float rate; + unsigned int vTotal = mode->vTotal; + + if (mode->modeFlags & RR_DoubleScan) { + /* doublescan doubles the number of lines */ + vTotal *= 2; + } + + if (mode->modeFlags & RR_Interlace) { + /* interlace splits the frame into two fields */ + /* the field rate is what is typically reported by monitors */ + vTotal /= 2; + } + + if (mode->hTotal && vTotal) { + rate = ( (float) mode->dotClock / + ( (float) mode->hTotal * (float) vTotal ) + ); + } else { + rate = 0; + } + return rate; +} + + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_dumpInfo0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources) { Display * dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); + Window root = RootWindow(dpy, (int)screen_idx); + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; int pos[] = { 0, 0 } ; + int i, j, minWidth, minHeight, maxWidth, maxHeight; - int i; - XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); - fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); - for(i=0; incrtc; i++) { - RRCrtc crtc = xrrScreenResources->crtcs[i]; - XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); - fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); + int vs_width = DisplayWidth(dpy, screen_idx); + int vs_height = DisplayHeight(dpy, screen_idx); + int vs_width_mm = DisplayWidthMM(dpy, screen_idx); + int vs_height_mm = DisplayHeightMM(dpy, screen_idx); + fprintf(stderr, "ScreenVirtualSize: %dx%d %dx%d mm\n", vs_width, vs_height, vs_width_mm, vs_height_mm); + + XRRGetScreenSizeRange (dpy, root, &minWidth, &minHeight, &maxWidth, &maxHeight); + fprintf(stderr, "XRRGetScreenSizeRange: %dx%d .. %dx%d\n", minWidth, minHeight, maxWidth, maxHeight); + + if( NULL == resources ) { + fprintf(stderr, "XRRScreenResources NULL\n"); + return; + } + fprintf(stderr, "XRRScreenResources %p: Crtc count %d\n", resources, resources->ncrtc); + for(i=0; incrtc; i++) { + RRCrtc crtc = resources->crtcs[i]; + XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, resources, crtc); + fprintf(stderr, "Crtc[%d]: %d/%d %dx%d, rot 0x%X, mode.id %#lx\n", + i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height, xrrCrtcInfo->rotations, xrrCrtcInfo->mode); + for(j=0; jnoutput; j++) { + fprintf(stderr, " Crtc[%d].Output[%d].id %#lx\n", i, j, xrrCrtcInfo->outputs[j]); + } XRRFreeCrtcInfo(xrrCrtcInfo); } - jintArray jpos = (*env)->NewIntArray(env, num_rotations); - if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 2); + dumpOutputs("XRRScreenResources.outputs", dpy, resources, resources->noutput, resources->outputs); + + fprintf(stderr, "XRRScreenResources %p: Mode count %d\n", resources, resources->nmode); + for(i=0; inmode; i++) { + XRRModeInfo *mode = &resources->modes[i]; + + unsigned int dots = mode->hTotal * mode->vTotal; + float refresh = getVRefresh(mode); + fprintf(stderr, "Mode[%d, id %#lx]: %ux%u@%f, name %s\n", i, mode->id, mode->width, mode->height, refresh, SAFE_STRING(mode->name)); } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, jpos, 0, 2, pos); - return jpos; } -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableScreenModeRotations0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getMonitorDeviceCount0 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDeviceCount0 + (JNIEnv *env, jclass clazz, jlong screenResources) +{ + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + return ( NULL != resources ) ? resources->ncrtc : 0; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getMonitorInfoHandle0 + * Signature: (JIJI)J + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorInfoHandle0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources, jint crt_idx) { Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - int num_rotations = 0; - Rotation cur_rotation, rotations_supported; - int rotations[4]; - int major, minor; + Window root = RootWindow(dpy, (int)screen_idx); + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; - rotations_supported = XRRRotations (dpy, (int)scrn_idx, &cur_rotation); + if( NULL == resources || crt_idx >= resources->ncrtc ) { + return 0; + } + RRCrtc crtc = resources->crtcs[crt_idx]; + XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, resources, crtc); + return (jlong) (intptr_t) xrrCrtcInfo; +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: freeMonitorInfoHandle0 + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_RandR13_freeMonitorInfoHandle0 + (JNIEnv *env, jclass clazz, jlong monitorInfo) +{ + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; + if( NULL != xrrCrtcInfo ) { + XRRFreeCrtcInfo( xrrCrtcInfo ); + } +} + +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getAvailableRotations0 + * Signature: (J)I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableRotations0 + (JNIEnv *env, jclass clazz, jlong monitorInfo) +{ + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; + if( NULL == xrrCrtcInfo ) { + return NULL; + } + Rotation rotations_supported = xrrCrtcInfo->rotations; + + int num_rotations = 0; + int rotations[4]; if(0 != (rotations_supported & RR_Rotate_0)) { rotations[num_rotations++] = 0; } @@ -120,7 +225,7 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableScre if(0 != (rotations_supported & RR_Rotate_270)) { rotations[num_rotations++] = 270; } - + jintArray properties = NULL; if(num_rotations>0) { @@ -136,273 +241,275 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getAvailableScre return properties; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getNumScreenModeResolutions0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +/* + * Class: jogamp_newt_driver_x11_RandR13 + * Method: getMonitorViewport0 + * Signature: (J)[I + */ +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorViewport0 + (JNIEnv *env, jclass clazz, jlong monitorInfo) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions - - DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes); + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; - int i; - XRRScreenResources *xrrScreenResources = XRRGetScreenResources(dpy, root); - fprintf(stderr, "XRRScreenResources %p: RRCrtc crtcs %d\n", xrrScreenResources, xrrScreenResources->ncrtc); - for(i=0; incrtc; i++) { - RRCrtc crtc = xrrScreenResources->crtcs[i]; - XRRCrtcInfo *xrrCrtcInfo = XRRGetCrtcInfo (dpy, xrrScreenResources, crtc); - fprintf(stderr, "RRCrtc %d: %d/%d %dx%d\n", i, xrrCrtcInfo->x, xrrCrtcInfo->y, xrrCrtcInfo->width, xrrCrtcInfo->height); - XRRFreeCrtcInfo(xrrCrtcInfo); + if( NULL == xrrCrtcInfo ) { + // n/a + return NULL; } - fprintf(stderr, "XRRScreenResources %p: XRRModeInfo modes %d\n", xrrScreenResources, xrrScreenResources->nmode); - for(i=0; inmode; i++) { - XRRModeInfo xrrModeInfo = xrrScreenResources->modes[i]; - fprintf(stderr, "XRRModeInfo %d: %dx%d, %s, %X\n", i, xrrModeInfo.width, xrrModeInfo.height, xrrModeInfo.name, xrrModeInfo.id); + + if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { + // disabled + return NULL; } - XRRFreeScreenResources(xrrScreenResources); - return num_sizes; + jsize propCount = 4; + jint prop[ propCount ]; + int propIndex = 0; + + prop[propIndex++] = xrrCrtcInfo->x; + prop[propIndex++] = xrrCrtcInfo->y; + prop[propIndex++] = xrrCrtcInfo->width; + prop[propIndex++] = xrrCrtcInfo->height; + + jintArray properties = (*env)->NewIntArray(env, propCount); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); + } + (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); + + return properties; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: getScreenModeResolutions0 - * Signature: (JII)[I + * Method: getMonitorMode0 + * Signature: (JI)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenModeResolution0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorMode0 + (JNIEnv *env, jclass clazz, jlong screenResources, jint mode_idx) { - Display *dpy = (Display *) (intptr_t) display; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + + if( NULL == resources || mode_idx >= resources->nmode ) { + return NULL; + } - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + XRRModeInfo *mode = &resources->modes[mode_idx]; + unsigned int dots = mode->hTotal * mode->vTotal; + int refresh = (int) ( getVRefresh(mode) * 100.0f ); // Hz * 100 + int flags = 0; + if (mode->modeFlags & RR_Interlace) { + flags |= FLAG_INTERLACE; } - - // Fill the properties in temp jint array + if (mode->modeFlags & RR_DoubleScan) { + flags |= FLAG_DOUBLESCAN; + } + + jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; int propIndex = 0; - jint prop[4]; - - prop[propIndex++] = xrrs[(int)resMode_idx].width; - prop[propIndex++] = xrrs[(int)resMode_idx].height; - prop[propIndex++] = xrrs[(int)resMode_idx].mwidth; - prop[propIndex++] = xrrs[(int)resMode_idx].mheight; - - jintArray properties = (*env)->NewIntArray(env, 4); + + prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; + prop[propIndex++] = mode->width; + prop[propIndex++] = mode->height; + prop[propIndex++] = 32; // TODO: XRandR > 1.4 may support bpp + prop[propIndex++] = refresh; + prop[propIndex++] = flags; + prop[propIndex++] = mode->id; + prop[propIndex++] = -1; // rotation placeholder + + jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", 4); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, 4, prop); + (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: getScreenModeRates0 - * Signature: (JII)[I + * Method: getMonitorCurrentMode0 + * Signature: (JJ)[I */ -JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getScreenModeRates0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx, jint resMode_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorCurrentMode0 + (JNIEnv *env, jclass clazz, jlong screenResources, jlong monitorInfo) { - Display *dpy = (Display *) (intptr_t) display; - - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + if( NULL == resources || NULL == xrrCrtcInfo ) { + // n/a + return NULL; } - - int num_rates; - short *rates = XRRRates(dpy, (int)scrn_idx, (int)resMode_idx, &num_rates); - - jint prop[num_rates]; + + if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { + // disabled + return NULL; + } + + int modeId = xrrCrtcInfo->mode; + XRRModeInfo *mode = NULL; int i; - for(i=0; inmode; i++) { + XRRModeInfo *imode = &resources->modes[i]; + if( imode->id == modeId ) { + mode = imode; + break; + } } - - jintArray properties = (*env)->NewIntArray(env, num_rates); + if( NULL == mode ) { + // oops .. + return NULL; + } + + unsigned int dots = mode->hTotal * mode->vTotal; + int refresh = (int) ( getVRefresh(mode) * 100.0f ); // Hz * 100 + int flags = 0; + if (mode->modeFlags & RR_Interlace) { + flags |= FLAG_INTERLACE; + } + if (mode->modeFlags & RR_DoubleScan) { + flags |= FLAG_DOUBLESCAN; + } + + jint prop[ NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int propIndex = 0; + + prop[propIndex++] = NUM_MONITOR_MODE_PROPERTIES_ALL; + prop[propIndex++] = mode->width; + prop[propIndex++] = mode->height; + prop[propIndex++] = 32; // TODO: XRandR > 1.4 may support bpp + prop[propIndex++] = refresh; + prop[propIndex++] = flags; + prop[propIndex++] = mode->id; + prop[propIndex++] = NewtScreen_XRotation2Degree(env, xrrCrtcInfo->rotation); + + jintArray properties = (*env)->NewIntArray(env, NUM_MONITOR_MODE_PROPERTIES_ALL); if (properties == NULL) { - NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", num_rates); + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", NUM_MONITOR_MODE_PROPERTIES_ALL); } - - // move from the temp structure to the java structure - (*env)->SetIntArrayRegion(env, properties, 0, num_rates, prop); + (*env)->SetIntArrayRegion(env, properties, 0, NUM_MONITOR_MODE_PROPERTIES_ALL, prop); return properties; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: getCurrentScreenRate0 - * Signature: (JI)I + * Method: getMonitorDevice0 + * Signature: (JJJJ)[I */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenRate0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) +JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_RandR13_getMonitorDevice0 + (JNIEnv *env, jclass clazz, jlong display, jlong screenResources, jlong monitorInfo, jint crt_idx) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - // get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); + Display * dpy = (Display *) (intptr_t) display; + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; - //free - XRRFreeScreenConfigInfo(conf); - - DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate); + if( NULL == resources || NULL == xrrCrtcInfo || crt_idx >= resources->ncrtc ) { + // n/a + return NULL; + } - return (jint) original_rate; -} + if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { + // disabled + return NULL; + } -/* - * Class: jogamp_newt_driver_x11_RandR13 - * Method: getCurrentScreenRotation0 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenRotation0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - //get current resolutions and frequencies - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - - Rotation rotation; - XRRConfigCurrentConfiguration(conf, &rotation); + RROutput output = xrrCrtcInfo->outputs[0]; + XRROutputInfo * xrrOutputInfo = XRRGetOutputInfo (dpy, resources, output); + int numModes = xrrOutputInfo->nmode; - //free - XRRFreeScreenConfigInfo(conf); - - return NewtScreen_XRotation2Degree(env, rotation); -} + jsize propCount = MIN_MONITOR_DEVICE_PROPERTIES - 1 + numModes; + jint prop[ propCount ]; + int propIndex = 0; + prop[propIndex++] = propCount; + prop[propIndex++] = crt_idx; + prop[propIndex++] = xrrOutputInfo->mm_width; + prop[propIndex++] = xrrOutputInfo->mm_height; + prop[propIndex++] = xrrCrtcInfo->x; + prop[propIndex++] = xrrCrtcInfo->y; + prop[propIndex++] = xrrCrtcInfo->width; + prop[propIndex++] = xrrCrtcInfo->height; + prop[propIndex++] = xrrCrtcInfo->mode; // current mode id + prop[propIndex++] = NewtScreen_XRotation2Degree(env, xrrCrtcInfo->rotation); + int i; + for(i=0; imodes[i]; + } -/* - * Class: jogamp_newt_driver_x11_RandR13 - * Method: getCurrentScreenResolutionIndex0 - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_RandR13_getCurrentScreenResolutionIndex0 - (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx) -{ - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)scrn_idx); - - // get current resolutions and frequency configuration - XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root); - short original_rate = XRRConfigCurrentRate(conf); - - Rotation original_rotation; - SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation); - - //free - XRRFreeScreenConfigInfo(conf); - - DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id); - return (jint)original_size_id; + XRRFreeOutputInfo (xrrOutputInfo); + + jintArray properties = (*env)->NewIntArray(env, propCount); + if (properties == NULL) { + NewtCommon_throwNewRuntimeException(env, "Could not allocate int array of size %d", propCount); + } + (*env)->SetIntArrayRegion(env, properties, 0, propCount, prop); + + return properties; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: setCurrentScreenModeStart0 - * Signature: (JIIII)Z + * Method: setMonitorMode0 + * Signature: (JJJIIIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setCurrentScreenModeStart0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setMonitorMode0 + (JNIEnv *env, jclass clazz, jlong display, jlong screenResources, jlong monitorInfo, jint crt_idx, jint modeId, jint rotation, jint x, jint y) { - Display *dpy = (Display *) (intptr_t) display; - Window root = RootWindow(dpy, (int)screen_idx); + Display * dpy = (Display *) (intptr_t) display; + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + XRRCrtcInfo *xrrCrtcInfo = (XRRCrtcInfo *) (intptr_t) monitorInfo; + jboolean res = JNI_FALSE; - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - int rot; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + if( NULL == resources || NULL == xrrCrtcInfo || crt_idx >= resources->ncrtc ) { + // n/a + return res; } - conf = XRRGetScreenInfo(dpy, root); - - rot = int NewtScreen_Degree2XRotation(env, rotation); - - DBG_PRINT("X11Screen.setCurrentScreenMode0: CHANGED TO %d: %d x %d PIXELS, %d Hz, %d degree\n", - resMode_idx, xrrs[resMode_idx].width, xrrs[resMode_idx].height, (int)freq, rotation); + if( None == xrrCrtcInfo->mode || 0 == xrrCrtcInfo->noutput ) { + // disabled + return res; + } - XRRSelectInput (dpy, root, RRScreenChangeNotifyMask); + if( 0 >= modeId ) { + // oops .. + return res; + } - XSync(dpy, False); - XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime); - XSync(dpy, False); + if( 0 > x || 0 > y ) { + x = xrrCrtcInfo->x; + y = xrrCrtcInfo->y; + } - //free - XRRFreeScreenConfigInfo(conf); - XSync(dpy, False); + Status status = XRRSetCrtcConfig( dpy, resources, resources->crtcs[crt_idx], CurrentTime, + x, y, modeId, NewtScreen_Degree2XRotation(env, rotation), + xrrCrtcInfo->outputs, xrrCrtcInfo->noutput ); + res = status == RRSetConfigSuccess; - return JNI_TRUE; + return res; } /* * Class: jogamp_newt_driver_x11_RandR13 - * Method: setCurrentScreenModePollEnd0 - * Signature: (J)Z + * Method: setScreenViewport0 + * Signature: (JIJIIII)Z */ -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setCurrentScreenModePollEnd0 - (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation) +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_RandR13_setScreenViewport0 + (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenResources, jint x, jint y, jint width, jint height) { - Display *dpy = (Display *) (intptr_t) display; - int randr_event_base, randr_error_base; - XEvent evt; - XRRScreenChangeNotifyEvent * scn_event = (XRRScreenChangeNotifyEvent *) &evt; + Display * dpy = (Display *) (intptr_t) display; + Window root = RootWindow(dpy, (int)screen_idx); + XRRScreenResources *resources = (XRRScreenResources *) (intptr_t) screenResources; + jboolean res = JNI_FALSE; - int num_sizes; - XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions - XRRScreenConfiguration *conf; - - if( 0 > resMode_idx || resMode_idx >= num_sizes ) { - NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes); + if( NULL == resources ) { + // n/a + return JNI_FALSE; } - XRRQueryExtension(dpy, &randr_event_base, &randr_error_base); - - int done = 0; - int rot; - do { - if ( 0 >= XEventsQueued(dpy, QueuedAfterFlush) ) { - return; - } - XNextEvent(dpy, &evt); - - switch (evt.type - randr_event_base) { - case RRScreenChangeNotify: - rot = NewtScreen_XRotation2Degree(env, (int)scn_event->rotation); - DBG_PRINT( "XRANDR: event . RRScreenChangeNotify call %p (root %p) resIdx %d rot %d %dx%d\n", - (void*)scn_event->window, (void*)scn_event->root, - (int)scn_event->size_index, rot, - scn_event->width, scn_event->height); - // done = scn_event->size_index == resMode_idx; // not reliable .. - done = rot == rotation && - scn_event->width == xrrs[resMode_idx].width && - scn_event->height == xrrs[resMode_idx].height; - break; - default: - DBG_PRINT("RANDR: event . unhandled %d 0x%X call %p\n", (int)evt.type, (int)evt.type, (void*)evt.xany.window); - } - XRRUpdateConfiguration(&evt); - } while(!done); - - XSync(dpy, False); - + XRRSetScreenSize (dpy, root, width, height, DisplayWidthMM(dpy, screen_idx), DisplayHeightMM(dpy, screen_idx)); + return JNI_TRUE; } + diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c index 3d4b2a26c..152a092c9 100644 --- a/src/newt/native/X11Screen.c +++ b/src/newt/native/X11Screen.c @@ -75,22 +75,41 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_ScreenDriver_getHeight0 } int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation) { - int rot; + int degree; if(xrotation == RR_Rotate_0) { - rot = 0; + degree = 0; } else if(xrotation == RR_Rotate_90) { - rot = 90; + degree = 90; } else if(xrotation == RR_Rotate_180) { - rot = 180; + degree = 180; } else if(xrotation == RR_Rotate_270) { - rot = 270; + degree = 270; } else { NewtCommon_throwNewRuntimeException(env, "invalid native rotation: %d", xrotation); } - return rot; + return degree; +} + +int NewtScreen_Degree2XRotation(JNIEnv *env, int degree) { + int xrot; + if(degree == 0) { + xrot = RR_Rotate_0; + } + else if(degree == 90) { + xrot = RR_Rotate_90; + } + else if(degree == 180) { + xrot = RR_Rotate_180; + } + else if(degree == 270) { + xrot = RR_Rotate_270; + } else { + NewtCommon_throwNewRuntimeException(env, "invalid degree: %d", degree); + } + return xrot; } /* diff --git a/src/newt/native/X11Screen.h b/src/newt/native/X11Screen.h index 1a1440054..c81ee05d5 100644 --- a/src/newt/native/X11Screen.h +++ b/src/newt/native/X11Screen.h @@ -33,5 +33,6 @@ #include "X11Common.h" int NewtScreen_XRotation2Degree(JNIEnv *env, int xrotation); +int NewtScreen_Degree2XRotation(JNIEnv *env, int degree); #endif /* _X11SCREEN_H */ diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 9e96169f5..6c5a127b6 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -438,7 +438,7 @@ Status NewtWindows_updateInsets(JNIEnv *env, jobject jwindow, Display *dpy, Wind return 0; // Error } -static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, Window w, jboolean force) { +static void NewtWindows_requestFocus (Display *dpy, Window w, Bool force) { XWindowAttributes xwa; Window focus_return; int revert_to_return; @@ -447,7 +447,7 @@ static void NewtWindows_requestFocus (JNIEnv *env, jobject window, Display *dpy, XGetInputFocus(dpy, &focus_return, &revert_to_return); DBG_PRINT( "X11: requestFocus dpy %p,win %p, force %d, hasFocus %d\n", dpy, (void*)w, force, focus_return==w); - if( JNI_TRUE==force || focus_return!=w) { + if( True==force || focus_return!=w) { DBG_PRINT( "X11: XRaiseWindow dpy %p, win %p\n", dpy, (void*)w); XRaiseWindow(dpy, w); NewtWindows_setCWAbove(dpy, w); @@ -743,7 +743,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo Bool tempInvisible = ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_PARENTING(flags) ) && isVisible ; int fsEWMHFlags = 0; if( TST_FLAG_CHANGE_FULLSCREEN(flags) ) { - fsEWMHFlags |= _NET_WM_FULLSCREEN; + if( !TST_FLAG_IS_FULLSCREEN_SPAN(flags) ) { // doesn't work w/ spanning across monitors + fsEWMHFlags |= _NET_WM_FULLSCREEN; + } if( TST_FLAG_IS_FULLSCREEN(flags) ) { if( TST_FLAG_IS_ALWAYSONTOP(flags) ) { fsEWMHFlags |= _NET_WM_ABOVE; // fs on, above on @@ -756,12 +758,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo fsEWMHFlags |= _NET_WM_ABOVE; // toggle above } - DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d, alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d, tempInvisible %d, fsEWMHFlags %d\n", + DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d (span %d), alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d, tempInvisible %d, fsEWMHFlags %d\n", (void*)dpy, screen_index, (void*) jparent, (void*)parent, (void*)w, x, y, width, height, TST_FLAG_CHANGE_PARENTING(flags), TST_FLAG_HAS_PARENT(flags), TST_FLAG_CHANGE_DECORATION(flags), TST_FLAG_IS_UNDECORATED(flags), - TST_FLAG_CHANGE_FULLSCREEN(flags), TST_FLAG_IS_FULLSCREEN(flags), + TST_FLAG_CHANGE_FULLSCREEN(flags), TST_FLAG_IS_FULLSCREEN(flags), TST_FLAG_IS_FULLSCREEN_SPAN(flags), TST_FLAG_CHANGE_ALWAYSONTOP(flags), TST_FLAG_IS_ALWAYSONTOP(flags), TST_FLAG_CHANGE_VISIBILITY(flags), TST_FLAG_IS_VISIBLE(flags), tempInvisible, fsEWMHFlags); @@ -769,9 +771,13 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo // However, we have to consider other cases like reparenting and WM which don't support it. if( fsEWMHFlags && !TST_FLAG_CHANGE_PARENTING(flags) && isVisible && + !TST_FLAG_IS_FULLSCREEN_SPAN(flags) && ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_ALWAYSONTOP(flags) ) ) { Bool enable = TST_FLAG_CHANGE_FULLSCREEN(flags) ? TST_FLAG_IS_FULLSCREEN(flags) : TST_FLAG_IS_ALWAYSONTOP(flags) ; if( NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, enable) ) { + if ( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) { // FS off - restore decoration + NewtWindows_setDecorations (dpy, w, TST_FLAG_IS_UNDECORATED(flags) ? False : True); + } #ifdef FS_GRAB_KEYBOARD if(TST_FLAG_CHANGE_FULLSCREEN(flags)) { if(TST_FLAG_IS_FULLSCREEN(flags)) { @@ -866,7 +872,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_requestFocus0 (JNIEnv *env, jobject obj, jlong display, jlong window, jboolean force) { - NewtWindows_requestFocus ( env, obj, (Display *) (intptr_t) display, (Window)window, force ) ; + NewtWindows_requestFocus ( (Display *) (intptr_t) display, (Window)window, JNI_TRUE==force?True:False ) ; } /* diff --git a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java index 0dead125a..88cd9a719 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTElektronActivity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.ElektronenMultiplizierer; @@ -58,11 +58,13 @@ public class NEWTElektronActivity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new ElektronenMultiplizierer()); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java index c020413cf..f10cfc11f 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES1Activity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es1.GearsES1; @@ -63,11 +63,13 @@ public class NEWTGearsES1Activity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES1(-1)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java index 542912c08..2e9774565 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2Activity.java @@ -36,10 +36,10 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -75,11 +75,13 @@ public class NEWTGearsES2Activity extends NewtBaseActivity { GearsES2 demo = new GearsES2(-1); // demo.enableAndroidTrace(true); glWindow.addGLEventListener(demo); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); if( null != System.getProperty(forceKillProcessTest) ) { Log.d(TAG, "forceKillProcessTest"); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java index 5e7a5c489..c87e66189 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2ActivityLauncher.java @@ -57,6 +57,7 @@ public class NEWTGearsES2ActivityLauncher extends LauncherUtil.BaseActivityLaunc // props.setProperty("jogl.debug.DebugGL", "true"); // props.setProperty("jogl.debug.TraceGL", "true"); // props.setProperty("newt.debug", "all"); + props.setProperty("newt.debug.Screen", "true"); props.setProperty("newt.debug.Window", "true"); props.setProperty("newt.debug.Window.MouseEvent", "true"); props.setProperty("newt.debug.Window.KeyEvent", "true"); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java index 18c3cb042..98e6b7c5f 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGearsES2TransActivity.java @@ -34,8 +34,8 @@ import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -65,11 +65,13 @@ public class NEWTGearsES2TransActivity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GearsES2(-1)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); Animator animator = new Animator(glWindow); // glWindow.setSkipContextReleaseThread(animator.getThread()); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java index bbd4f9f20..42db9d8dd 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI1pActivity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A; @@ -61,11 +61,13 @@ public class NEWTGraphUI1pActivity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GPUUISceneGLListener0A(0)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java index 20ba3f484..c68de95cc 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTGraphUI2pActivity.java @@ -33,8 +33,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; import com.jogamp.graph.curve.Region; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.graph.demos.GPUUISceneGLListener0A; @@ -62,11 +62,13 @@ public class NEWTGraphUI2pActivity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new GPUUISceneGLListener0A(Region.VBAA_RENDERING_BIT)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java index 06ce75ac5..08fbf643d 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES1Activity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; @@ -57,11 +57,13 @@ public class NEWTRedSquareES1Activity extends NewtBaseActivity { setContentView(getWindow(), glWindow); glWindow.addGLEventListener(new RedSquareES1(-1)); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); glWindow.setVisible(true); Animator animator = new Animator(glWindow); diff --git a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java index 02e2d8f01..cefdd842b 100644 --- a/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java +++ b/src/test/com/jogamp/opengl/test/android/NEWTRedSquareES2Activity.java @@ -32,8 +32,8 @@ import javax.media.opengl.GLProfile; import jogamp.newt.driver.android.NewtBaseActivity; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.event.ScreenModeListener; +import com.jogamp.newt.event.MonitorEvent; +import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; @@ -62,11 +62,13 @@ public class NEWTRedSquareES2Activity extends NewtBaseActivity { final RedSquareES2 demo = new RedSquareES2(-1); // demo.enableAndroidTrace(true); glWindow.addGLEventListener(demo); - glWindow.getScreen().addScreenModeListener(new ScreenModeListener() { - public void screenModeChangeNotify(ScreenMode sm) { } - public void screenModeChanged(ScreenMode sm, boolean success) { - System.err.println("ScreenMode Changed: "+sm); - } + glWindow.getScreen().addMonitorModeListener(new MonitorModeListener() { + @Override + public void monitorModeChangeNotify(MonitorEvent me) { } + @Override + public void monitorModeChanged(MonitorEvent me, boolean success) { + System.err.println("MonitorMode Changed (success "+success+"): "+me); + } }); Animator animator = new Animator(glWindow); // animator.setRunAsFastAsPossible(true); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 50f759079..4c6cae501 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -163,13 +163,25 @@ public class TestGearsES2NEWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + @Override + public void keyPressed(final KeyEvent e) { + if( e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { final Thread t = glWindow.setExclusiveContextThread(null); System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setFullscreen(!glWindow.isFullscreen()); + if( glWindow.isFullscreen() ) { + glWindow.setFullscreen( false ); + } else { + if( e.isAltDown() ) { + glWindow.setFullscreen( null ); + } else { + glWindow.setFullscreen( true ); + } + } System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java index 98620e0c1..90d4a9c1f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestRulerNEWT01.java @@ -28,8 +28,8 @@ package com.jogamp.opengl.test.junit.jogl.glsl; import com.jogamp.common.nio.Buffers; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.MonitorMode; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.MonitorMode; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -109,11 +109,13 @@ public class TestRulerNEWT01 extends UITestCase { Assert.assertNotNull(winctx); Assert.assertNotNull(winctx.window); Assert.assertNotNull(winctx.window.getScreen()); - ScreenMode sm = winctx.window.getScreen().getCurrentScreenMode(); - Assert.assertNotNull(sm); - System.err.println(sm); - final MonitorMode mmode = sm.getMonitorMode(); - final DimensionImmutable sdim = mmode.getScreenSizeMM(); + final MonitorDevice monitor = winctx.window.getMainMonitor(); + Assert.assertNotNull(monitor); + System.err.println(monitor); + final MonitorMode mmode = monitor.getCurrentMode(); + Assert.assertNotNull(mmode); + System.err.println(mmode); + final DimensionImmutable sdim = monitor.getSizeMM(); final DimensionImmutable spix = mmode.getSurfaceSize().getResolution(); final GLUniformData rulerPixFreq = new GLUniformData("gcu_RulerPixFreq", 2, Buffers.newDirectFloatBuffer(2)); final FloatBuffer rulerPixFreqV = (FloatBuffer) rulerPixFreq.getBuffer(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java index 29ec443f7..a7b65545a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java @@ -35,11 +35,12 @@ import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.Animator; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; import java.util.List; @@ -72,8 +73,8 @@ public class ManualScreenMode03NEWT extends UITestCase { Screen screen = NewtFactory.createScreen(display, 0); // screen 0 GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - List screenModes = screen.getScreenModes(); - if(null==screenModes) { + List monitorModes = screen.getMonitorModes(); + if(null==monitorModes) { // no support .. System.err.println("Your platform has no ScreenMode change support, sorry"); return; @@ -81,18 +82,21 @@ public class ManualScreenMode03NEWT extends UITestCase { Animator animator = new Animator(window); animator.start(); - ScreenMode smCurrent = screen.getCurrentScreenMode(); - ScreenMode smOrig = screen.getOriginalScreenMode(); - System.err.println("[0] current/orig: "+smCurrent); + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + MonitorMode mmOrig = monitor.getOriginalMode(); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - ScreenMode sm = (ScreenMode) screenModes.get(0); - System.err.println("[0] set current: "+sm); - screen.setCurrentScreenMode(sm); + MonitorMode mm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+mm); + monitor.setCurrentMode(mm); System.err.print("[0] post setting .. wait <"); try { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java index 577119bcd..f64cf2eb8 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java @@ -35,18 +35,23 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import com.jogamp.common.util.ArrayHashSet; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; -import com.jogamp.newt.util.MonitorMode; -import com.jogamp.newt.util.ScreenModeUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import java.util.Iterator; import java.util.List; import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.SurfaceSize; +import javax.media.opengl.GLProfile; + +import jogamp.newt.MonitorDeviceImpl; +import jogamp.newt.MonitorModeProps; public class TestScreenMode00NEWT extends UITestCase { static int screenIdx = 0; @@ -59,6 +64,7 @@ public class TestScreenMode00NEWT extends UITestCase { @BeforeClass public static void initClass() { + GLProfile.initSingleton(); // hack to initialize GL for BCM_IV (Rasp.Pi) NativeWindowFactory.initSingleton(); width = 640; height = 480; @@ -66,31 +72,46 @@ public class TestScreenMode00NEWT extends UITestCase { @Test public void testScreenModeInfo00() throws InterruptedException { - DimensionImmutable res = new Dimension(640, 480); - SurfaceSize surfsz = new SurfaceSize(res, 32); - DimensionImmutable mm = new Dimension(500, 400); - MonitorMode mon = new MonitorMode(surfsz, mm, 60); - ScreenMode sm_out = new ScreenMode(mon, 90); - System.err.println("00 out: "+sm_out); - - int[] props = ScreenModeUtil.streamOut(sm_out); - ScreenMode sm_in = ScreenModeUtil.streamIn(props, 0); - System.err.println("00 in : "+sm_in); - - Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize().getResolution(), - sm_out.getMonitorMode().getSurfaceSize().getResolution()); - - Assert.assertEquals(sm_in.getMonitorMode().getSurfaceSize(), - sm_out.getMonitorMode().getSurfaceSize()); - - Assert.assertEquals(sm_in.getMonitorMode().getScreenSizeMM(), - sm_out.getMonitorMode().getScreenSizeMM()); - - Assert.assertEquals(sm_in.getMonitorMode(), sm_out.getMonitorMode()); - - Assert.assertEquals(sm_in, sm_out); + final DimensionImmutable res = new Dimension(640, 480); + final SurfaceSize surfsz = new SurfaceSize(res, 32); + final MonitorMode modeOut = new MonitorMode(surfsz, 60.0f, 0, 0); + System.err.println("00 out: "+modeOut); + final MonitorModeProps.Cache cache = new MonitorModeProps.Cache(); + cache.monitorModes.add(modeOut); + { + final int[] props = MonitorModeProps.streamOutMonitorMode(modeOut); + final MonitorMode modeIn = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + System.err.println("00 in : "+modeIn); + + Assert.assertEquals(modeOut.getSurfaceSize().getResolution(), modeIn.getSurfaceSize().getResolution()); + + Assert.assertEquals(modeOut.getSurfaceSize(), modeIn.getSurfaceSize()); + + Assert.assertEquals(modeOut.hashCode(), modeIn.hashCode()); + + Assert.assertEquals(modeOut, modeIn); + } - Assert.assertEquals(sm_out.hashCode(), sm_in.hashCode()); + final DimensionImmutable sizeMM = new Dimension(50, 50); + final Rectangle viewport = new Rectangle(0, 0, 1920, 1080); + final ArrayHashSet supportedModes = new ArrayHashSet(); + supportedModes.add(modeOut); + final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, modeOut, supportedModes); + System.err.println("01 out : "+monOut); + cache.monitorDevices.add(monOut); + { + final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut); + final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0); + System.err.println("01 in : "+monIn); + + Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode()); + Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes()); + Assert.assertEquals(monOut.getViewport(), monIn.getViewport()); + Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode()); + Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode()); + Assert.assertEquals(monOut.hashCode(), monIn.hashCode()); + Assert.assertEquals(monOut, monIn); + } } @Test @@ -101,21 +122,37 @@ public class TestScreenMode00NEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,screen.getDisplay().isNativeValid()); System.err.println("Screen: "+screen.toString()); - - List screenModes = screen.getScreenModes(); - Assert.assertTrue(screenModes.size()>0); - int i=0; - for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { - System.err.println(i+": "+iter.next()); + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + { + int i=0; + for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { + System.err.println("All["+i+"]: "+iMode.next()); + } + } + + List monitors = screen.getMonitorDevices(); + Assert.assertTrue(monitors.size()>0); + int j=0; + for(Iterator iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) { + MonitorDevice monitor = iMonitor.next(); + System.err.println(j+": "+monitor); + List modes = monitor.getSupportedModes(); + Assert.assertTrue(modes.size()>0); + int i=0; + for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { + System.err.println("["+j+"]["+i+"]: "+iMode.next()); + } + Assert.assertTrue(allMonitorModes.containsAll(modes)); + + MonitorMode sm_o = monitor.getOriginalMode(); + Assert.assertNotNull(sm_o); + MonitorMode sm_c = monitor.queryCurrentMode(); + System.err.println("[0] orig : "+sm_o); + System.err.println("[0] current: "+sm_c); + Assert.assertNotNull(sm_c); + Assert.assertEquals(sm_o, sm_c); } - ScreenMode sm_o = screen.getOriginalScreenMode(); - Assert.assertNotNull(sm_o); - ScreenMode sm_c = screen.getCurrentScreenMode(); - Assert.assertNotNull(sm_c); - System.err.println("orig SM: "+sm_o); - System.err.println("curr SM: "+sm_c); - System.err.println("curr sz: "+screen.getWidth()+"x"+screen.getHeight()); - Assert.assertEquals(sm_o, sm_c); screen.removeReference(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java index 75a312686..f4eaec5fa 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java @@ -36,9 +36,10 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -81,23 +82,24 @@ public class TestScreenMode00bNEWT extends UITestCase { Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,display.isNativeValid()); - List screenModes = screen.getScreenModes(); + List screenModes = screen.getMonitorModes(); Assert.assertTrue(screenModes.size()>0); int i=0; - for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { + for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { System.err.println(i+": "+iter.next()); } - ScreenMode sm_o = screen.getOriginalScreenMode(); + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mm_o = monitor.getOriginalMode(); - Assert.assertNotNull(sm_o); - ScreenMode sm_c = screen.getCurrentScreenMode(); - Assert.assertNotNull(sm_c); - System.err.println("orig: "+sm_o); - System.err.println("curr: "+sm_c); + Assert.assertNotNull(mm_o); + MonitorMode mm_c = monitor.queryCurrentMode(); + Assert.assertNotNull(mm_c); + System.err.println("orig: "+mm_o); + System.err.println("curr: "+mm_c); for(i=0; i<50; i++) { - sm_c = screen.getCurrentScreenMode(); - Assert.assertNotNull(sm_c); + mm_c = monitor.queryCurrentMode(); + Assert.assertNotNull(mm_c); System.err.print("."+i); } System.err.println("!"); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java index f253f3b58..78dd9fbc1 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java @@ -40,12 +40,13 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -149,14 +150,16 @@ public class TestScreenMode01NEWT extends UITestCase { Animator animator = new Animator(window); animator.start(); + final MonitorDevice monitor = window.getMainMonitor(); + Assert.assertEquals(false, window.isFullscreen()); Assert.assertEquals(width, window.getWidth()); Assert.assertEquals(height, window.getHeight()); window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - Assert.assertEquals(window.getScreen().getWidth(), window.getWidth()); - Assert.assertEquals(window.getScreen().getHeight(), window.getHeight()); + Assert.assertEquals(true, window.isFullscreen()); + Assert.assertEquals(monitor.getViewport().getWidth(), window.getWidth()); + Assert.assertEquals(monitor.getViewport().getHeight(), window.getHeight()); Thread.sleep(waitTimeShort); @@ -192,45 +195,53 @@ public class TestScreenMode01NEWT extends UITestCase { GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); Assert.assertNotNull(window); - List screenModes = screen.getScreenModes(); - if(screenModes.size()==1) { + MonitorDevice monitor = window.getMainMonitor(); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); + System.err.println("Your platform has no MonitorMode change support, sorry"); destroyWindow(window); return; } - Assert.assertTrue(screenModes.size()>0); Animator animator = new Animator(window); animator.start(); - ScreenMode smCurrent = screen.getCurrentScreenMode(); - Assert.assertNotNull(smCurrent); - ScreenMode smOrig = screen.getOriginalScreenMode(); - Assert.assertNotNull(smOrig); - Assert.assertEquals(smCurrent, smOrig); - System.err.println("[0] current/orig: "+smCurrent); - - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); - ScreenMode sm = (ScreenMode) screenModes.get(0); + MonitorMode sm = (MonitorMode) monitorModes.get(0); System.err.println("[0] set current: "+sm); - screen.setCurrentScreenMode(sm); - Assert.assertEquals(sm, screen.getCurrentScreenMode()); - Assert.assertNotSame(smOrig, screen.getCurrentScreenMode()); - + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + Thread.sleep(waitTimeLong); // check reset .. @@ -258,15 +269,14 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); - smCurrent = screen.getCurrentScreenMode(); - System.err.println("[1] current/orig: "+smCurrent); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); screen.destroy(); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - Assert.assertNotNull(smCurrent); - Assert.assertEquals(smCurrent, smOrig); - + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); cleanupGL(); } @@ -291,27 +301,30 @@ public class TestScreenMode01NEWT extends UITestCase { Animator animator = new Animator(window); animator.start(); - ScreenMode smCurrent = screen.getCurrentScreenMode(); - Assert.assertNotNull(smCurrent); - ScreenMode smOrig = screen.getOriginalScreenMode(); - Assert.assertNotNull(smOrig); - Assert.assertEquals(smCurrent, smOrig); - System.err.println("[0] current/orig: "+smCurrent); + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); - List screenModes = screen.getScreenModes(); - if(screenModes.size()==1) { + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { // no support .. destroyWindow(window); return; } - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); - - ScreenMode screenMode = (ScreenMode) screenModes.get(0); - Assert.assertNotNull(screenMode); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + + MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); + Assert.assertNotNull(monitorMode); if(preFS) { System.err.println("[0] set FS pre 0: "+window.isFullscreen()); @@ -321,8 +334,8 @@ public class TestScreenMode01NEWT extends UITestCase { System.err.println("[0] set FS pre X: "+window.isFullscreen()); } - System.err.println("[0] set current: "+screenMode); - screen.setCurrentScreenMode(screenMode); + System.err.println("[0] set current: "+monitorMode); + monitor.setCurrentMode(monitorMode); if(!preFS) { System.err.println("[0] set FS post 0: "+window.isFullscreen()); @@ -358,14 +371,14 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); - smCurrent = screen.getCurrentScreenMode(); - System.err.println("[1] current/orig: "+smCurrent); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); screen.destroy(); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - Assert.assertNotNull(smCurrent); - Assert.assertEquals(smCurrent, smOrig); + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); cleanupGL(); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java new file mode 100644 index 000000000..35390636f --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java @@ -0,0 +1,212 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Documents remedy B) for NV RANDR/GL bug + * + * @see TestScreenMode01NEWT#cleanupGL() + */ +public class TestScreenMode01aNEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static int waitTimeShort = 2000; + static int waitTimeLong = 2000; + + @BeforeClass + public static void initClass() { + width = 100; + height = 100; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static Window createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) { + Assert.assertNotNull(caps); + + GLWindow window = GLWindow.create(screen, caps); + // Window window = NewtFactory.createWindow(screen, caps); + window.setTitle(name); + window.setPosition(x, y); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testScreenModeChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height); + Assert.assertNotNull(window0); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + if(allMonitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (all), sorry"); + destroyWindow(window0); + return; + } + + MonitorDevice monitor = window0.getMainMonitor(); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); + destroyWindow(window0); + return; + } + Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); + + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+sm); + Assert.assertTrue(monitor.setCurrentMode(sm)); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + Thread.sleep(waitTimeShort); + + // check manual reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window0.isNativeValid()); + Assert.assertEquals(true,window0.isVisible()); + + screen.addReference(); // keep it alive ! + Assert.assertTrue(monitor.setCurrentMode(mmOrig)); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Assert.assertNotSame(sm, monitor.getCurrentMode()); + Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); + + destroyWindow(window0); + Assert.assertEquals(false,window0.isVisible()); + Assert.assertEquals(false,window0.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); // alive ! + Assert.assertEquals(true,display.isNativeValid()); + + Thread.sleep(waitTimeShort); + + Window window1 = createWindow(screen, caps, "win1", + width+window0.getInsets().getTotalWidth(), 0, + width, height); + Assert.assertNotNull(window1); + Assert.assertEquals(true,window1.isNativeValid()); + Assert.assertEquals(true,window1.isVisible()); + + Thread.sleep(waitTimeShort); + + destroyWindow(window1); + Assert.assertEquals(false,window1.isNativeValid()); + Assert.assertEquals(false,window1.isVisible()); + + screen.removeReference(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode01aNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java index 38612faa8..7e18f396a 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java @@ -1,5 +1,5 @@ /** - * Copyright 2010 JogAmp Community. All rights reserved. + * Copyright 2013 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: @@ -29,7 +29,6 @@ package com.jogamp.opengl.test.junit.newt; import java.io.IOException; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -39,34 +38,36 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; -import com.jogamp.newt.ScreenMode; +import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.ScreenModeUtil; +import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; import java.util.List; import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.RectangleImmutable; /** - * Documents remedy B) for NV RANDR/GL bug - * - * @see TestScreenMode01NEWT#cleanupGL() + * Mode change on separate monitors .. */ public class TestScreenMode01bNEWT extends UITestCase { static GLProfile glp; static int width, height; - static int waitTimeShort = 2000; - static int waitTimeLong = 2000; + static long waitTimeShort = 2000; + static long duration = 6000; @BeforeClass public static void initClass() { - width = 100; - height = 100; + width = 200; + height = 200; glp = GLProfile.getDefault(); } @@ -75,7 +76,7 @@ public class TestScreenMode01bNEWT extends UITestCase { Thread.sleep(waitTimeShort); } - static Window createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) { + static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) throws InterruptedException { Assert.assertNotNull(caps); GLWindow window = GLWindow.create(screen, caps); @@ -85,7 +86,9 @@ public class TestScreenMode01bNEWT extends UITestCase { window.setSize(width, height); window.addGLEventListener(new GearsES2()); Assert.assertNotNull(window); + final long t0 = System.currentTimeMillis(); window.setVisible(true); + System.err.println("Time for visible/pos: "+(System.currentTimeMillis()-t0)+" ms"); return window; } @@ -96,93 +99,150 @@ public class TestScreenMode01bNEWT extends UITestCase { } @Test - public void testScreenModeChange01() throws InterruptedException { + public void testScreenModeChangeSingleQ1() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport(); + testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY()); + } finally { + screen.removeReference(); + } + } + + @Test + public void testScreenModeChangeSingleQ2() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + if( 2 > screen.getMonitorDevices().size() ) { + System.err.println("Test Disabled (1): Monitor count < 2: "+screen); + return; + } + RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); + testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY()); + } finally { + screen.removeReference(); + } + } + + void testScreenModeChangeImpl(final Screen screen, int xpos, int ypos) throws InterruptedException { Thread.sleep(waitTimeShort); - GLCapabilities caps = new GLCapabilities(glp); + final GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height); + final Display display = screen.getDisplay(); + System.err.println("Test.0: Window screen: "+screen); + + System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); + + GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); Assert.assertNotNull(window0); + System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); - List screenModes = screen.getScreenModes(); - if(screenModes.size()==1) { + final Animator anim = new Animator(window0); + anim.start(); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + if(allMonitorModes.size()==1) { // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); + System.err.println("Your platform has no MonitorMode change support (all), sorry"); destroyWindow(window0); return; } - Assert.assertTrue(screenModes.size()>0); - - ScreenMode smCurrent = screen.getCurrentScreenMode(); - Assert.assertNotNull(smCurrent); - ScreenMode smOrig = screen.getOriginalScreenMode(); - Assert.assertNotNull(smOrig); - Assert.assertEquals(smCurrent, smOrig); - System.err.println("[0] current/orig: "+smCurrent); - - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 0); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - ScreenMode sm = (ScreenMode) screenModes.get(0); - System.err.println("[0] set current: "+sm); - screen.setCurrentScreenMode(sm); - Assert.assertEquals(sm, screen.getCurrentScreenMode()); - Assert.assertNotSame(smOrig, screen.getCurrentScreenMode()); - - Thread.sleep(waitTimeShort); - - // check reset .. + MonitorDevice monitor = window0.getMainMonitor(); + System.err.println("Test.0: Window monitor: "+monitor); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); + destroyWindow(window0); + return; + } + Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); + + MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[1] set current: "+sm); + Assert.assertTrue(monitor.setCurrentMode(sm)); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current: "+mmCurrent); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + System.err.println("Test.1: Window screen: "+screen); + System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.1: Window monitor: "+window0.getMainMonitor()); + + Thread.sleep(duration); Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window0.isNativeValid()); Assert.assertEquals(true,window0.isVisible()); - screen.addReference(); // keep it alive ! - screen.setCurrentScreenMode(smOrig); + Assert.assertTrue(monitor.setCurrentMode(mmOrig)); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Assert.assertNotSame(sm, monitor.getCurrentMode()); + Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); + + System.err.println("Test.2: Window screen: "+screen); + System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.2: Window monitor: "+window0.getMainMonitor()); + Thread.sleep(duration); + anim.stop(); destroyWindow(window0); Assert.assertEquals(false,window0.isVisible()); Assert.assertEquals(false,window0.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); // alive ! Assert.assertEquals(true,display.isNativeValid()); - - Thread.sleep(waitTimeShort); - - Window window1 = createWindow(screen, caps, "win1", - width+window0.getInsets().getTotalWidth(), 0, - width, height); - Assert.assertNotNull(window1); - Assert.assertEquals(true,window1.isNativeValid()); - Assert.assertEquals(true,window1.isVisible()); - - Thread.sleep(waitTimeShort); - - destroyWindow(window1); - Assert.assertEquals(false,window1.isNativeValid()); - Assert.assertEquals(false,window1.isVisible()); - - screen.removeReference(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); } public static void main(String args[]) throws IOException { + for(int i=0; i screen.getMonitorDevices().size() ) { + System.err.println("Test Disabled (1): Monitor count < 2: "+screen); + return; + } + RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); + testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null); + } finally { + screen.removeReference(); + } + } + + @Test + public void testScreenFullscreenSpanQ1Q2() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + final int crtCount = screen.getMonitorDevices().size(); + if( 2 >= crtCount ) { + System.err.println("Test Disabled (2): Spanning monitor count "+2+" >= screen monitor count: "+screen); + return; + } + final ArrayList monitors = new ArrayList(); + monitors.add(screen.getMonitorDevices().get(0)); // Q1 + monitors.add(screen.getMonitorDevices().get(1)); // Q2 + RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport(); + testScreenFullscreenImpl(screen, monitorVp.getX()+50, monitorVp.getY()+50, true, monitors); + } finally { + screen.removeReference(); + } + } + + @Test + public void testScreenFullscreenSpanALL() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + if( 2 > screen.getMonitorDevices().size() ) { + System.err.println("Test Disabled (3): Monitor count < 2: "+screen); + return; + } + RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); + testScreenFullscreenImpl(screen, monitorVp.getX()-50, monitorVp.getY()+50, true, null); + } finally { + screen.removeReference(); + } + } + + void testScreenFullscreenImpl(final Screen screen, int xpos, int ypos, boolean spanAcrossMonitors, List monitors) throws InterruptedException { + Thread.sleep(waitTimeShort); + + final GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + final Display display = screen.getDisplay(); + + System.err.println("Test.0: Window screen: "+screen); + + System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); + + GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); + Assert.assertNotNull(window0); + System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + + final Animator anim = new Animator(window0); + anim.start(); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + + MonitorDevice monitor = window0.getMainMonitor(); + System.err.println("Test.0: Window monitor: "+monitor); + if( !spanAcrossMonitors ) { + window0.setFullscreen(true); + } else { + window0.setFullscreen(monitors); + } + + monitor = window0.getMainMonitor(); + System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.1: Window monitor: "+monitor.getViewport()); + Rectangle window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight()); + if( !spanAcrossMonitors ) { + Assert.assertEquals(monitor.getViewport(), window0Rect); + } else { + List monitorsUsed = monitors; + if( null == monitorsUsed ) { + monitorsUsed = window0.getScreen().getMonitorDevices(); + } + Rectangle monitorsUsedViewport = MonitorDevice.unionOfViewports(new Rectangle(), monitorsUsed); + Assert.assertEquals(monitorsUsedViewport, window0Rect); + } + + Thread.sleep(duration); + + window0.setFullscreen(false); + + window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight()); + monitor = window0.getMainMonitor(); + System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.2: Window monitor: "+monitor.getViewport()); + + Thread.sleep(duration); + anim.stop(); + destroyWindow(window0); + Assert.assertEquals(false,window0.isVisible()); + Assert.assertEquals(false,window0.isNativeValid()); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i screenModes = screen.getScreenModes(); - if(screenModes.size()==1) { + MonitorDevice monitor = window.getMainMonitor(); + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { // no support .. System.err.println("Your platform has no ScreenMode change support, sorry"); destroyWindow(window); return; } - Assert.assertTrue(screenModes.size()>0); + Assert.assertTrue(monitorModes.size()>0); Animator animator = new Animator(window); animator.start(); - ScreenMode smCurrent = screen.getCurrentScreenMode(); - Assert.assertNotNull(smCurrent); - ScreenMode smOrig = screen.getOriginalScreenMode(); - Assert.assertNotNull(smOrig); - Assert.assertEquals(smCurrent, smOrig); - System.err.println("[0] current/orig: "+smCurrent); - - screenModes = ScreenModeUtil.filterByRate(screenModes, smOrig.getMonitorMode().getRefreshRate()); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByRotation(screenModes, 90); - if(null==screenModes) { + MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); + if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { // no rotation support .. System.err.println("Your platform has no rotation support, sorry"); destroyWindow(window); return; } - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.filterByResolution(screenModes, new Dimension(801, 601)); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - screenModes = ScreenModeUtil.getHighestAvailableBpp(screenModes); - Assert.assertNotNull(screenModes); - Assert.assertTrue(screenModes.size()>0); - - ScreenMode sm = (ScreenMode) screenModes.get(0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); System.err.println("[0] set current: "+sm); - screen.setCurrentScreenMode(sm); - Assert.assertEquals(sm, screen.getCurrentScreenMode()); - Assert.assertNotSame(smOrig, screen.getCurrentScreenMode()); + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); Thread.sleep(waitTimeLong); @@ -167,11 +176,11 @@ public class TestScreenMode02NEWT extends UITestCase { Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); - smCurrent = screen.getCurrentScreenMode(); - System.err.println("[1] current/orig: "+smCurrent); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); - Assert.assertNotNull(smCurrent); - Assert.assertEquals(smCurrent, smOrig); + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); screen.destroy(); -- cgit v1.2.3 From 5fb7f6322863e11892ace100e131ac7451ba8274 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 6 May 2013 23:20:48 +0200 Subject: MonitorMode Unit Tests: Perform 'filterByRate(..)' _after_ 'filterByResolution(..)' (desired resolution) --- make/scripts/tests.sh | 6 +++--- .../com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java | 2 +- .../com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java | 6 +++--- .../com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java | 6 +++--- .../com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java | 4 ++-- .../com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java | 5 ++--- 6 files changed, 14 insertions(+), 15 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c6f69ab74..a850ed6be 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,7 +135,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Screen" + D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -386,9 +386,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java index a7b65545a..875e4fe86 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java @@ -90,8 +90,8 @@ public class ManualScreenMode03NEWT extends UITestCase { monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); MonitorMode mm = (MonitorMode) monitorModes.get(0); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java index 78dd9fbc1..2dd16b9d2 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java @@ -223,10 +223,10 @@ public class TestScreenMode01NEWT extends UITestCase { monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); @@ -319,8 +319,8 @@ public class TestScreenMode01NEWT extends UITestCase { Assert.assertTrue(monitorModes.size()>0); monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java index 35390636f..96ada3c96 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java @@ -144,12 +144,12 @@ public class TestScreenMode01aNEWT extends UITestCase { monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); Assert.assertNotNull(monitorModes); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java index 7e18f396a..9108853e5 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java @@ -185,10 +185,10 @@ public class TestScreenMode01bNEWT extends UITestCase { monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java index d30f90e44..542297209 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java @@ -135,11 +135,10 @@ public class TestScreenMode02NEWT extends UITestCase { destroyWindow(window); return; } - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); -- cgit v1.2.3 From 061ce19983556a751471459a964d886e4d7e3908 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 7 May 2013 01:03:17 +0200 Subject: NEWT Multiple Monitor Mode: Add missing 'collect' impl. for NEWT/AWT impl. --- make/scripts/tests.sh | 4 +- .../jogamp/newt/driver/awt/ScreenDriver.java | 47 ++++++++++++++++++++-- 2 files changed, 45 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a850ed6be..2152aabac 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -294,7 +294,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* +testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* @@ -386,7 +386,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT $* diff --git a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java index 8e584fc58..126143e1e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/ScreenDriver.java @@ -34,11 +34,11 @@ package jogamp.newt.driver.awt; import java.awt.DisplayMode; +import java.awt.GraphicsDevice; import jogamp.newt.MonitorModeProps.Cache; +import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.nativewindow.awt.AWTGraphicsScreen; @@ -71,9 +71,48 @@ public class ScreenDriver extends ScreenImpl { return idx; // pass through ... } + private static MonitorMode getModeProps(Cache cache, DisplayMode mode) { + int rate = mode.getRefreshRate(); + if( DisplayMode.REFRESH_RATE_UNKNOWN == rate ) { + rate = ScreenImpl.default_sm_rate; + } + int bpp = mode.getBitDepth(); + if( DisplayMode.BIT_DEPTH_MULTI == bpp ) { + bpp= ScreenImpl.default_sm_bpp; + } + int[] props = new int[ MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL ]; + int i = 0; + props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; + props[i++] = mode.getWidth(); + props[i++] = mode.getHeight(); + props[i++] = bpp; + props[i++] = rate * 100; + props[i++] = 0; // flags + props[i++] = 0; // mode_idx + props[i++] = 0; // rotation + return MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + } + @Override - protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { - final DisplayMode mode = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice().getDisplayMode(); + protected void collectNativeMonitorModesAndDevicesImpl(Cache cache) { + final GraphicsDevice awtGD = ((AWTGraphicsDevice)getDisplay().getGraphicsDevice()).getGraphicsDevice(); + final DisplayMode[] awtModes = awtGD.getDisplayModes(); + for(int i=0; i Date: Tue, 7 May 2013 12:51:18 +0200 Subject: NEWT Multiple Monitor Mode: Fix monitorModeChanged(..) event id, WindowImpl.monitorModeChanged(): Resize/position if not fitting into virtual screen viewport. --- make/scripts/tests.sh | 4 ++-- src/newt/classes/jogamp/newt/ScreenMonitorState.java | 2 +- src/newt/classes/jogamp/newt/WindowImpl.java | 15 +++++++++------ src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java | 3 +-- 4 files changed, 13 insertions(+), 11 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2152aabac..8221f1da8 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -294,7 +294,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWTAnalyzeBug455 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* -testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* @@ -385,7 +385,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT +testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* diff --git a/src/newt/classes/jogamp/newt/ScreenMonitorState.java b/src/newt/classes/jogamp/newt/ScreenMonitorState.java index 7cda18521..66e75be16 100644 --- a/src/newt/classes/jogamp/newt/ScreenMonitorState.java +++ b/src/newt/classes/jogamp/newt/ScreenMonitorState.java @@ -176,7 +176,7 @@ public class ScreenMonitorState { lock(); try { validateMonitor(monitor); - final MonitorEvent me = new MonitorEvent(MonitorEvent.EVENT_MONITOR_MODE_CHANGE_NOTIFY, monitor, System.currentTimeMillis(), currentMode); + final MonitorEvent me = new MonitorEvent(MonitorEvent.EVENT_MONITOR_MODE_CHANGED, monitor, System.currentTimeMillis(), currentMode); for(int i=0; i 0 && viewport.getHeight() > 0 ) { // failsafe final RectangleImmutable rect = new Rectangle(getX(), getY(), getWidth(), getHeight()); - final RectangleImmutable viewport = mainMonitor.getViewport(); final RectangleImmutable isect = viewport.intersection(rect); if ( getHeight() > isect.getHeight() || getWidth() > isect.getWidth() ) { - setSize(isect.getWidth(), isect.getHeight()); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.monitorModeChanged: fit window "+rect+" into screen viewport "+viewport+ + ", due to minimal intersection "+isect); + } + setPosition(viewport.getX(), viewport.getY()); + setSize(viewport.getWidth(), viewport.getHeight()); } } } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 666d0cb5b..fcc5b2148 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -135,8 +135,7 @@ public class WindowDriver extends WindowImpl { protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { if(DEBUG_IMPLEMENTATION) { - System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ - getReconfigureFlagsAsString(null, flags)); + System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); } final int _x, _y; if(0 == ( FLAG_IS_UNDECORATED & flags)) { -- cgit v1.2.3 From ff08ebae2f6ed8788d481f4a21fc7a07a75733ee Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 8 May 2013 03:49:55 +0200 Subject: GLJPanel: Use PixelBufferProvider AWTPixelBufferProviderInt; PixelBufferProvider: Add 'dispose()' to interface. Transition reusing AWT specific PixelBufferProvider to allow a later user provided PixelBufferProvider. --- make/scripts/tests.sh | 3 +- .../com/jogamp/opengl/util/GLReadBufferUtil.java | 1 + .../jogamp/opengl/util/texture/TextureData.java | 8 + .../opengl/util/texture/awt/AWTTextureData.java | 11 + .../classes/javax/media/opengl/awt/GLJPanel.java | 62 ++--- .../demos/es2/awt/TestGearsES2GLJPanelAWT.java | 266 +++++++++++++++++++++ 6 files changed, 323 insertions(+), 28 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8221f1da8..3fae45fdb 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -280,6 +280,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -385,7 +386,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index 140c8691f..dc87c7ac9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -264,6 +264,7 @@ public class GLReadBufferUtil { readPixelBuffer = null; } readPixelSizeLast = 0; + pixelBufferProvider.dispose(); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java index 66fba98fe..2f0c86255 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java @@ -105,6 +105,9 @@ public class TextureData { *

    */ Buffer allocate(int width, int height, int minByteSize); + + /** Dispose resources. */ + void dispose(); } /** * Default {@link PixelBufferProvider} utilizing best match for {@link PixelAttributes} @@ -139,6 +142,11 @@ public class TextureData { public final Buffer allocate(int width, int height, int minByteSize) { return Buffers.newDirectByteBuffer(minByteSize); } + + @Override + public void dispose() { + // nop + } } protected int width; diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java index d77bd835e..7a0f00edf 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java @@ -104,11 +104,22 @@ public class AWTTextureData extends TextureData { return IntBuffer.wrap( readBackIntBuffer ); } + @Override + public void dispose() { + if(null != image) { + image.flush(); + image = null; + } + } + /** Returns the number source components being used as indicated at {@link #allocate(int, int, int)}. */ public int getComponentCount() { return componentCount; } /** Returns the underlying {@link BufferedImage} as allocated via {@link #allocate(int, int, int)}. */ public BufferedImage getImage() { return image; } + + /** Returns true if an underlying {@link BufferedImage} has been allocated via {@link #allocate(int, int, int)}. */ + public boolean hasImage() { return null != image; } } // Mechanism for lazily converting input BufferedImages with custom diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 383c40dc3..2543c5ec4 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -84,10 +84,12 @@ import jogamp.opengl.GLDrawableHelper; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.awt.Java2D; import jogamp.opengl.util.glsl.GLSLTextureRaster; - import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.util.GLBuffers; import com.jogamp.opengl.util.GLPixelStorageModes; +import com.jogamp.opengl.util.texture.TextureData.PixelAttributes; +import com.jogamp.opengl.util.texture.awt.AWTTextureData.AWTPixelBufferProviderInt; /** A lightweight Swing component which provides OpenGL rendering support. Provided for compatibility with Swing user interfaces @@ -920,17 +922,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // backends, both of which rely on reading back the OpenGL frame // buffer and drawing it with a BufferedImage class OffscreenBackend implements Backend { - // This image is exactly the correct size to render into the panel - protected BufferedImage offscreenImage; + protected AWTPixelBufferProviderInt pixelBufferProvider = new AWTPixelBufferProviderInt(); + private PixelAttributes pixelAttribs; + // One of these is used to store the read back pixels before storing // in the BufferedImage protected IntBuffer readBackInts; protected int readBackWidthInPixels; protected int readBackHeightInPixels; - private int glFormat; - private int glType; - // Implementation using software rendering private GLDrawableImpl offscreenDrawable; private FBObject fboFlipped; @@ -1049,10 +1049,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void setOpaque(boolean opaque) { if (opaque != isOpaque()) { - if (offscreenImage != null) { - offscreenImage.flush(); - offscreenImage = null; - } + pixelBufferProvider.dispose(); } } @@ -1065,32 +1062,44 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void postGL(Graphics g, boolean isDisplay) { if (isDisplay) { + final GL gl = offscreenContext.getGL(); + + final int componentCount; + final int alignment; + if( isOpaque() ) { + // w/o alpha + componentCount = 3; + alignment = 1; + } else { + // with alpha + componentCount = 4; + alignment = 4; + } + // Must now copy pixels from offscreen context into surface - if (offscreenImage == null) { + if ( !pixelBufferProvider.hasImage() ) { if (0 >= panelWidth || 0 >= panelHeight ) { return; } - final boolean withAlpha = !isOpaque(); - glFormat = GL.GL_BGRA; - glType = GL.GL_UNSIGNED_BYTE; // offscreenContext.getDefaultPixelDataType(); + pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); - offscreenImage = new BufferedImage(panelWidth, panelHeight, withAlpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); + final int[] tmp = { 0 }; + final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.format, pixelAttribs.type, panelWidth, panelHeight, 1, true); + final IntBuffer intBuffer = (IntBuffer) pixelBufferProvider.allocate(panelWidth, panelHeight, readPixelSize); if(!flipVertical || null != glslTextureRaster) { - final int[] readBackIntBuffer = ((DataBufferInt) offscreenImage.getRaster().getDataBuffer()).getData(); - readBackInts = IntBuffer.wrap(readBackIntBuffer); + readBackInts = intBuffer; } else { readBackInts = IntBuffer.allocate(readBackWidthInPixels * readBackHeightInPixels); } if(DEBUG) { + final BufferedImage offscreenImage = pixelBufferProvider.getImage(); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight +", readBackSizeInPixels "+readBackWidthInPixels+"x"+readBackHeightInPixels); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: offscreenImage "+offscreenImage.getWidth()+"x"+offscreenImage.getHeight()); } } - final GL gl = offscreenContext.getGL(); - if( DEBUG_VIEWPORT ) { int[] vp = new int[] { 0, 0, 0, 0 }; gl.glGetIntegerv(GL.GL_VIEWPORT, vp, 0); @@ -1098,7 +1107,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } // Save current modes - psm.setAlignment(gl, 1, 1); + psm.setAlignment(gl, alignment, alignment); if(gl.isGL2GL3()) { final GL2GL3 gl2gl3 = gl.getGL2GL3(); gl2gl3.glPixelStorei(GL2GL3.GL_PACK_ROW_LENGTH, readBackWidthInPixels); @@ -1117,11 +1126,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing gl.glBindTexture(GL.GL_TEXTURE_2D, fboTex.getName()); // gl.glClear(GL.GL_DEPTH_BUFFER_BIT); // fboFlipped runs w/o DEPTH! glslTextureRaster.display(gl.getGL2ES2()); - gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, glFormat, glType, readBackInts); + gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, pixelAttribs.format, pixelAttribs.type, readBackInts); fboFlipped.unbind(gl); } else { - gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, glFormat, glType, readBackInts); + gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, pixelAttribs.format, pixelAttribs.type, readBackInts); if ( flipVertical ) { // Copy temporary data into raster of BufferedImage for faster @@ -1129,6 +1138,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // where !offscreenContext.offscreenImageNeedsVerticalFlip(), // but that's the software rendering path which is very slow // anyway + final BufferedImage offscreenImage = pixelBufferProvider.getImage(); final Object src = readBackInts.array(); final Object dest = ((DataBufferInt) offscreenImage.getRaster().getDataBuffer()).getData(); final int srcIncr = readBackWidthInPixels; @@ -1153,7 +1163,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void doPaintComponent(Graphics g) { helper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction); - if (offscreenImage != null) { + final BufferedImage offscreenImage = pixelBufferProvider.getImage(); + if ( null != offscreenImage ) { // Draw resulting image in one shot g.drawImage(offscreenImage, 0, 0, offscreenImage.getWidth(), @@ -1204,10 +1215,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } - if (offscreenImage != null) { - offscreenImage.flush(); - offscreenImage = null; - } + pixelBufferProvider.dispose(); return _drawable.isRealized(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java new file mode 100644 index 000000000..eddf5126b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java @@ -0,0 +1,266 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.event.TraceKeyAdapter; +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.FPSAnimator; + +public class TestGearsES2GLJPanelAWT extends UITestCase { + static GLProfile glp; + static int width, height; + static boolean shallUsePBuffer = false; + static boolean shallUseBitmap = false; + static boolean useMSAA = false; + static int swapInterval = 1; + static boolean useAnimator = true; + static boolean manualTest = false; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2)) { + glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + width = 640; + height = 480; + } else { + setTestSupported(false); + } + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilities caps) + throws AWTException, InterruptedException, InvocationTargetException + { + final JFrame frame = new JFrame("Swing GLJPanel"); + Assert.assertNotNull(frame); + + final GLJPanel glJPanel = new GLJPanel(caps); + Assert.assertNotNull(glJPanel); + Dimension glc_sz = new Dimension(width, height); + glJPanel.setMinimumSize(glc_sz); + glJPanel.setPreferredSize(glc_sz); + glJPanel.setSize(glc_sz); + glJPanel.addGLEventListener(new GearsES2()); + final SnapshotGLEventListener snap = new SnapshotGLEventListener(); + glJPanel.addGLEventListener(snap); + + final FPSAnimator animator = useAnimator ? new FPSAnimator(glJPanel, 60) : null; + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.getContentPane().add(glJPanel, BorderLayout.CENTER); + frame.getContentPane().validate(); + frame.pack(); + frame.setVisible(true); + } } ) ; + + if( useAnimator ) { + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + } + + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + boolean triggerSnap = false; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + snap.getDisplayCount(); + if( !triggerSnap && snap.getDisplayCount() > 1 ) { + // Snapshot only after one frame has been rendered to suite FBO MSAA! + snap.setMakeSnapshot(); + triggerSnap = true; + } + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glJPanel); + Assert.assertNotNull(animator); + + if( useAnimator ) { + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + } + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.getContentPane().remove(glJPanel); + frame.remove(glJPanel); + glJPanel.destroy(); + frame.dispose(); + } } ); + } + + @Test + public void test01_DefaultNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + if(useMSAA) { + caps.setNumSamples(4); + caps.setSampleBuffers(true); + } + if(shallUsePBuffer) { + caps.setPBuffer(true); + } + if(shallUseBitmap) { + caps.setBitmap(true); + } + runTestGL(caps); + } + + @Test + public void test02_DefaultMsaa() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); + runTestGL(caps); + } + + @Test + public void test03_PbufferNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setPBuffer(true); + runTestGL(caps); + } + + @Test + public void test04_PbufferMsaa() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); + caps.setPBuffer(true); + runTestGL(caps); + } + + @Test + public void test05_BitmapNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setBitmap(true); + runTestGL(caps); + } + + @Test + public void test06_BitmapMsaa() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); + caps.setBitmap(true); + runTestGL(caps); + } + + static long duration = 500; // ms + + public static void main(String args[]) { + for(int i=0; i Date: Wed, 8 May 2013 05:49:41 +0200 Subject: Add TestGearsGLJPanelAWT, i.e. multiple JPanels w/ GLJPanel running GearsES2 in their own color. Note: JComponent will introduce flickering if using opaque rendering mode! --- make/scripts/tests.sh | 5 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 1 + .../opengl/test/junit/jogl/demos/GearsObject.java | 10 +- .../opengl/test/junit/jogl/demos/es1/GearsES1.java | 21 +- .../test/junit/jogl/demos/es1/GearsObjectES1.java | 8 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 33 ++- .../test/junit/jogl/demos/es2/GearsObjectES2.java | 8 +- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 4 +- .../demos/es2/awt/TestGearsES2GLJPanelAWT.java | 4 +- .../demos/es2/awt/TestGearsES2GLJPanelsAWT.java | 317 +++++++++++++++++++++ .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 1 + .../jogl/demos/gl2/awt/TestGearsGLJPanelAWT.java | 4 +- .../jogamp/opengl/test/junit/util/MiscUtils.java | 9 + 13 files changed, 392 insertions(+), 33 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3fae45fdb..7093ffa95 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,7 +135,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" - D_ARGS="-Dnewt.debug.Screen" + #D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -280,7 +280,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 2543c5ec4..65bcab100 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -1094,6 +1094,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } if(DEBUG) { final BufferedImage offscreenImage = pixelBufferProvider.getImage(); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelAttribs "+pixelAttribs); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight +", readBackSizeInPixels "+readBackWidthInPixels+"x"+readBackHeightInPixels); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: offscreenImage "+offscreenImage.getWidth()+"x"+offscreenImage.getHeight()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java index 44a74a367..82dd7071f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java @@ -36,7 +36,8 @@ public abstract class GearsObject { public static final FloatBuffer green = Buffers.newDirectFloatBuffer( new float[] { 0.0f, 0.8f, 0.2f, 0.7f } ); public static final FloatBuffer blue = Buffers.newDirectFloatBuffer( new float[] { 0.2f, 0.2f, 1.0f, 0.7f } ); public static final float M_PI = (float)Math.PI; - + + public final FloatBuffer gearColor; public GLArrayDataServer frontFace; public GLArrayDataServer frontSide; public GLArrayDataServer backFace; @@ -47,7 +48,7 @@ public abstract class GearsObject { public abstract GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage); public abstract void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components); - public abstract void draw(GL gl, float x, float y, float angle, FloatBuffer color); + public abstract void draw(GL gl, float x, float y, float angle); public void destroy(GL gl) { if(!isShared) { @@ -88,9 +89,11 @@ public abstract class GearsObject { backSide = shared.backSide; outwardFace = shared.outwardFace; insideRadiusCyl = shared.insideRadiusCyl; + gearColor = shared.gearColor; } public GearsObject ( + FloatBuffer gearColor, float inner_radius, float outer_radius, float width, @@ -107,7 +110,8 @@ public abstract class GearsObject { float normal[] = new float[3]; // final int tris_per_tooth = 32; - isShared = false; + this.isShared = false; + this.gearColor = gearColor; r0 = inner_radius; r1 = outer_radius - tooth_depth / 2.0f; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java index bf668879a..0cd45e53f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java @@ -21,6 +21,8 @@ package com.jogamp.opengl.test.junit.jogl.demos.es1; +import java.nio.FloatBuffer; + import javax.media.nativewindow.NativeWindow; import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; @@ -57,6 +59,7 @@ public class GearsES1 implements GLEventListener { private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; private GearsObject gear1=null, gear2=null, gear3=null; + private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue; private float angle = 0.0f; private int swapInterval; private MouseListener gearsMouse = new GearsMouseAdapter(); @@ -80,6 +83,12 @@ public class GearsES1 implements GLEventListener { this.traceFFPEmu = traceFFPEmu; } + public void setGearsColors(FloatBuffer gear1Color, FloatBuffer gear2Color, FloatBuffer gear3Color) { + this.gear1Color = gear1Color; + this.gear2Color = gear2Color; + this.gear3Color = gear3Color; + } + public void setGears(GearsObject g1, GearsObject g2, GearsObject g3) { gear1 = g1; gear2 = g2; @@ -153,21 +162,21 @@ public class GearsES1 implements GLEventListener { /* make the gears */ if(null == gear1) { - gear1 = new GearsObjectES1(1.0f, 4.0f, 1.0f, 20, 0.7f); + gear1 = new GearsObjectES1(gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f); System.err.println("gear1 created: "+gear1); } else { System.err.println("gear1 reused: "+gear1); } if(null == gear2) { - gear2 = new GearsObjectES1(0.5f, 2.0f, 2.0f, 10, 0.7f); + gear2 = new GearsObjectES1(gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f); System.err.println("gear2 created: "+gear2); } else { System.err.println("gear2 reused: "+gear2); } if(null == gear3) { - gear3 = new GearsObjectES1(1.3f, 2.0f, 0.5f, 10, 0.7f); + gear3 = new GearsObjectES1(gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f); System.err.println("gear3 created: "+gear3); } else { System.err.println("gear3 reused: "+gear3); @@ -268,9 +277,9 @@ public class GearsES1 implements GLEventListener { gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); - gear1.draw(gl, -3.0f, -2.0f, angle, GearsObject.red); - gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f, GearsObject.green); - gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f, GearsObject.blue); + gear1.draw(gl, -3.0f, -2.0f, angle); + gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f); + gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f); // Remember that every push needs a pop; this one is paired with // rotating the entire gear assembly diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java index 8276c6bb9..89e469799 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java @@ -36,9 +36,9 @@ import com.jogamp.opengl.util.GLArrayDataServer; */ public class GearsObjectES1 extends GearsObject { - public GearsObjectES1(float inner_radius, float outer_radius, float width, + public GearsObjectES1(FloatBuffer gearColor, float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) { - super(inner_radius, outer_radius, width, teeth, tooth_depth); + super(gearColor, inner_radius, outer_radius, width, teeth, tooth_depth); } @Override @@ -59,12 +59,12 @@ public class GearsObjectES1 extends GearsObject { } @Override - public void draw(GL _gl, float x, float y, float angle, FloatBuffer color) { + public void draw(GL _gl, float x, float y, float angle) { GL2ES1 gl = _gl.getGL2ES1(); gl.glPushMatrix(); gl.glTranslatef(x, y, 0f); gl.glRotatef(angle, 0f, 0f, 1f); - gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, color); + gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, gearColor); gl.glShadeModel(GL2ES1.GL_FLAT); draw(gl, frontFace, GL.GL_TRIANGLE_STRIP); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 4cf6f3764..f21e767fa 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -58,6 +58,7 @@ public class GearsES2 implements GLEventListener { private float panX = 0.0f, panY = 0.0f, panZ=0.0f; private int drawableHeight = 1; private GearsObjectES2 gear1=null, gear2=null, gear3=null; + private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue; private float angle = 0.0f; private int swapInterval = 0; private boolean pmvUseBackingArray = true; // the default for PMVMatrix now, since it's faster @@ -67,6 +68,7 @@ public class GearsES2 implements GLEventListener { private boolean doRotate = true; private boolean ignoreFocus = false; + private float[] clearColor = null; private boolean clearBuffers = true; private boolean verbose = true; @@ -87,6 +89,17 @@ public class GearsES2 implements GLEventListener { this.pmvUseBackingArray = pmvUseBackingArray; } + /** float[4] */ + public void setClearColor(float[] clearColor) { + this.clearColor = clearColor; + } + + public void setGearsColors(FloatBuffer gear1Color, FloatBuffer gear2Color, FloatBuffer gear3Color) { + this.gear1Color = gear1Color; + this.gear2Color = gear2Color; + this.gear3Color = gear3Color; + } + public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) { gear1 = g1; gear2 = g2; @@ -159,7 +172,7 @@ public class GearsES2 implements GLEventListener { st.uniform(gl, colorU); if(null == gear1) { - gear1 = new GearsObjectES2(st, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + gear1 = new GearsObjectES2(st, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); if(verbose) { System.err.println("gear1 created: "+gear1); } @@ -171,7 +184,7 @@ public class GearsES2 implements GLEventListener { } if(null == gear2) { - gear2 = new GearsObjectES2(st, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); if(verbose) { System.err.println("gear2 created: "+gear2); } @@ -183,7 +196,7 @@ public class GearsES2 implements GLEventListener { } if(null == gear3) { - gear3 = new GearsObjectES2(st, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); if(verbose) { System.err.println("gear3 created: "+gear3); } @@ -288,10 +301,10 @@ public class GearsES2 implements GLEventListener { hasFocus = true; } - gl.glEnable(GL.GL_CULL_FACE); - if( clearBuffers ) { - if( ignoreFocus || hasFocus ) { + if( null != clearColor ) { + gl.glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + } else if( ignoreFocus || hasFocus ) { gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } else { gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f); @@ -308,6 +321,8 @@ public class GearsES2 implements GLEventListener { } } + gl.glEnable(GL.GL_CULL_FACE); + st.useProgram(gl, true); pmvMatrix.glPushMatrix(); pmvMatrix.glTranslatef(panX, panY, panZ); @@ -315,9 +330,9 @@ public class GearsES2 implements GLEventListener { pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); - gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f, GearsObject.red); - gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f, GearsObject.green); - gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f, GearsObject.blue); + gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f); + gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f); + gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f); pmvMatrix.glPopMatrix(); st.useProgram(gl, false); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java index eb9647949..c5f5f7a44 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java @@ -41,13 +41,13 @@ public class GearsObjectES2 extends GearsObject { final GLUniformData colorUniform; final ShaderState st; - public GearsObjectES2(ShaderState st, float inner_radius, float outer_radius, + public GearsObjectES2(ShaderState st, FloatBuffer gearColor, float inner_radius, float outer_radius, float width, int teeth, float tooth_depth, PMVMatrix pmvMatrix, GLUniformData pmvMatrixUniform, GLUniformData colorUniform) { - super(inner_radius, outer_radius, width, teeth, tooth_depth); + super(gearColor, inner_radius, outer_radius, width, teeth, tooth_depth); this.pmvMatrix = pmvMatrix; this.pmvMatrixUniform = pmvMatrixUniform; this.colorUniform = colorUniform; @@ -95,7 +95,7 @@ public class GearsObjectES2 extends GearsObject { } @Override - public void draw(GL _gl, float x, float y, float angle, FloatBuffer color) { + public void draw(GL _gl, float x, float y, float angle) { final GL2ES2 gl = _gl.getGL2ES2(); pmvMatrix.glPushMatrix(); pmvMatrix.glTranslatef(x, y, 0f); @@ -106,7 +106,7 @@ public class GearsObjectES2 extends GearsObject { throw new InternalError("PMVMatrix.update() returns false after mutable operations"); } - colorUniform.setData(color); + colorUniform.setData(gearColor); st.uniform(gl, colorUniform); draw(gl, frontFace, GL.GL_TRIANGLE_STRIP); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index 3d8fa69ea..a51df5088 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -198,7 +198,9 @@ public class TestGearsES2AWT extends UITestCase { } frame.setTitle("Gears AWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); - glCanvas.addGLEventListener(new GearsES2(swapInterval)); + final GearsES2 demo = new GearsES2(swapInterval); + glCanvas.addGLEventListener(demo); + final SnapshotGLEventListener snap = new SnapshotGLEventListener(); glCanvas.addGLEventListener(snap); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java index eddf5126b..bbb9fde1b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelAWT.java @@ -60,7 +60,7 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { static boolean shallUsePBuffer = false; static boolean shallUseBitmap = false; static boolean useMSAA = false; - static int swapInterval = 1; + static int swapInterval = 0; static boolean useAnimator = true; static boolean manualTest = false; @@ -92,7 +92,7 @@ public class TestGearsES2GLJPanelAWT extends UITestCase { glJPanel.setMinimumSize(glc_sz); glJPanel.setPreferredSize(glc_sz); glJPanel.setSize(glc_sz); - glJPanel.addGLEventListener(new GearsES2()); + glJPanel.addGLEventListener(new GearsES2(swapInterval)); final SnapshotGLEventListener snap = new SnapshotGLEventListener(); glJPanel.addGLEventListener(snap); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java new file mode 100644 index 000000000..e4c0f47a4 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java @@ -0,0 +1,317 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.lang.reflect.InvocationTargetException; +import java.nio.FloatBuffer; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.FPSAnimator; + +public class TestGearsES2GLJPanelsAWT extends UITestCase { + static int demoCount = 4; + static boolean opaque = false; // always faster and flicker-less w/o opaque, i.e. w/ alpha channel due to JComponent _paintImmediately(..) + static float alpha = 0.3f; + static GLProfile glp; + static boolean shallUsePBuffer = false; + static boolean shallUseBitmap = false; + static boolean useMSAA = false; + static int swapInterval = 0; + static boolean useAnimator = true; + static boolean manualTest = false; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2)) { + glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + } else { + setTestSupported(false); + } + } + + @AfterClass + public static void releaseClass() { + } + + private void addPanel(GLCapabilitiesImmutable caps, GLAnimatorControl anim, final JFrame frame, boolean opaque, int x, int y, int w, int h, FloatBuffer color, float[] clearColor) + throws InterruptedException, InvocationTargetException + { + final GLJPanel canvas = new GLJPanel(caps); + canvas.setOpaque(opaque); + final Dimension glc_sz = new Dimension(w, h); + canvas.setMinimumSize(glc_sz); + canvas.setPreferredSize(glc_sz); + canvas.setSize(glc_sz); + GearsES2 demo = new GearsES2(swapInterval); + demo.setIgnoreFocus(true); + demo.setGearsColors(color, color, color); + demo.setClearColor(clearColor); + canvas.addGLEventListener(demo); + if( null != anim ) { + anim.add(canvas); + } + + final JPanel panel = new JPanel(new BorderLayout()); + panel.setBounds(x, y, w, h); + panel.setOpaque(opaque); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + panel.add(canvas, BorderLayout.CENTER); + frame.getContentPane().add(panel); + } } ) ; + } + + public static final FloatBuffer red = Buffers.newDirectFloatBuffer( new float[] { 1.0f, 0.0f, 0.0f, 1.0f } ); + public static final FloatBuffer green = Buffers.newDirectFloatBuffer( new float[] { 0.0f, 1.0f, 0.0f, 1.0f } ); + public static final FloatBuffer blue = Buffers.newDirectFloatBuffer( new float[] { 0.0f, 0.0f, 1.0f, 1.0f } ); + public static final FloatBuffer yellow = Buffers.newDirectFloatBuffer( new float[] { 1.0f, 1.0f, 0.0f, 1.0f } ); + public static final float grayf = 0.3f; + public static final float[] redish = new float[] { grayf, 0.0f, 0.0f, alpha }; + public static final float[] greenish = new float[] { 0.0f, grayf, 0.0f, alpha }; + public static final float[] blueish = new float[] { 0.0f, 0.0f, grayf, alpha }; + public static final float[] yellowish = new float[] { grayf, grayf, 0.0f, alpha }; + + protected void runTestGL(GLCapabilities caps) + throws AWTException, InterruptedException, InvocationTargetException + { + if( !opaque ) { + caps.setAlphaBits(caps.getRedBits()); + } + + final JFrame frame = new JFrame("Swing GLJPanel"); + Assert.assertNotNull(frame); + + final FPSAnimator animator = useAnimator ? new FPSAnimator(60) : null; + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.getContentPane().setLayout(null); + } } ); + + if( demoCount > 0 ) { + addPanel(caps, animator, frame, opaque, 50, 50, 300, 300, red, redish); // A + } + if( demoCount > 1 ) { + addPanel(caps, animator, frame, opaque, 200, 0, 150, 150, green, greenish); // B + } + if( demoCount > 2 ) { + addPanel(caps, animator, frame, opaque, 0, 250, 300, 300, blue, blueish); // C + } + if( demoCount > 3 ) { + addPanel(caps, animator, frame, opaque, 300, 300, 100, 100, yellow, yellowish); // D + } + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(600, 600); + frame.getContentPane().validate(); + // frame.pack(); + frame.setVisible(true); + } } ) ; + + if( useAnimator ) { + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + } + + QuitAdapter quitAdapter = new QuitAdapter(); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(animator); + + if( useAnimator ) { + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + } + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + // frame.getContentPane().removeAll(); + // frame.removeAll(); + frame.dispose(); + } } ); + } + + @Test + public void test01_DefaultNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + if(useMSAA) { + caps.setNumSamples(4); + caps.setSampleBuffers(true); + } + if(shallUsePBuffer) { + caps.setPBuffer(true); + } + if(shallUseBitmap) { + caps.setBitmap(true); + } + runTestGL(caps); + } + + @Test + public void test02_DefaultMsaa() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); + runTestGL(caps); + } + + @Test + public void test03_PbufferNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setPBuffer(true); + runTestGL(caps); + } + + @Test + public void test04_PbufferMsaa() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); + caps.setPBuffer(true); + runTestGL(caps); + } + + @Test + public void test05_BitmapNorm() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setBitmap(true); + runTestGL(caps); + } + + @Test + public void test06_BitmapMsaa() + throws AWTException, InterruptedException, InvocationTargetException + { + if( manualTest ) { + return; + } + GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); + caps.setNumSamples(4); + caps.setSampleBuffers(true); + caps.setBitmap(true); + runTestGL(caps); + } + + static long duration = 500; // ms + + public static void main(String args[]) { + for(int i=0; i Date: Wed, 8 May 2013 22:57:17 +0200 Subject: Refactor: TextureData's PixelAttributes/PixelBufferProvider -> GLPixelBuffer/.. and enhance usage; GLJPanel: Use GLPixelBuffer* API and SingleAWTGLPixelBufferProvider if possible. Refactor: TextureData's PixelAttributes/PixelBufferProvider -> GLPixelBuffer/.. and enhance usage - GLPixelBuffer, GLPixelAttributes and GLPixelBufferProvider have potential for wider audience, hence extract them to package 'com.jogamp.opengl.util'. - Using GLPixelBuffer, shall attempt to use pack/unpack row-stride, i.e. GL2GL3.GL_PACK_ROW_LENGTH, or GL2GL3.GL_UNPACK_ROW_LENGTH. See GLReadBufferUtil and GLJPanel - AWTGLPixelBuffer*: Attribute 'row-stride' allows reusing a bigger buffer than requested. GLJPanel: Use GLPixelBuffer* API and SingleAWTGLPixelBufferProvider if possible. - Use GLPixelBuffer API to remove redundancies - Attempts to use SingleAWTGLPixelBufferProvider to save JVM/CPU heap space for BuffereImage and IntBbuffer (readBack) Added unit new test demonstrating multiple overlapping GLJPanels reusing (or not) a singlton SingleAWTGLPixelBufferProvider. --- make/scripts/tests.sh | 3 +- .../com/jogamp/opengl/util/GLPixelBuffer.java | 253 +++++++++++++++++++++ .../com/jogamp/opengl/util/GLReadBufferUtil.java | 57 ++--- .../jogamp/opengl/util/awt/AWTGLPixelBuffer.java | 203 +++++++++++++++++ .../opengl/util/awt/AWTGLReadBufferUtil.java | 25 +- .../jogamp/opengl/util/texture/TextureData.java | 122 ++-------- .../opengl/util/texture/awt/AWTTextureData.java | 96 ++------ .../classes/javax/media/opengl/awt/GLJPanel.java | 190 ++++++++++------ .../awt/TestBug461FBOSupersamplingSwingAWT.java | 2 +- .../jogl/caps/TestBug605FlippedImageNEWT.java | 2 +- .../demos/es2/awt/TestGearsES2GLJPanelsAWT.java | 151 +++++++++--- .../jogl/util/texture/TestJPEGImage01NEWT.java | 3 +- .../texture/TestJPEGJoglAWTBenchmarkNewtAWT.java | 5 +- .../texture/TestJPEGJoglAWTCompareNewtAWT.java | 3 +- .../junit/jogl/util/texture/TestTexture01AWT.java | 2 +- .../junit/jogl/util/texture/TestTexture02AWT.java | 2 +- .../jogamp/opengl/test/junit/util/MiscUtils.java | 9 + 17 files changed, 796 insertions(+), 332 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java create mode 100644 src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7093ffa95..99eb2e077 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -183,7 +183,8 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" - #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" + D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java new file mode 100644 index 000000000..b2e0af2b5 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -0,0 +1,253 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util; + +import java.nio.Buffer; +import java.nio.ByteBuffer; + +import javax.media.opengl.GL; +import javax.media.opengl.GLContext; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.util.texture.TextureData; + +/** + * OpenGL pixel data buffer, allowing user to provide buffers via their {@link GLPixelBufferProvider} implementation. + *

    + * {@link GLPixelBufferProvider} produces a {@link GLPixelBuffer}. + *

    + *

    + * You may use {@link #defaultProvider}. + *

    + */ +public class GLPixelBuffer { + + /** Allows user to interface with another toolkit to define {@link GLPixelAttributes} and memory buffer to produce {@link TextureData}. */ + public static interface GLPixelBufferProvider { + /** Called first to determine {@link GLPixelAttributes}. */ + GLPixelAttributes getAttributes(GL gl, int componentCount); + + /** + * Allocates a new {@link GLPixelBuffer} object. + *

    + * Being called to gather the initial {@link GLPixelBuffer}, + * or a new replacement {@link GLPixelBuffer} if {@link GLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. + *

    + *

    + * The minimum required {@link Buffer#remaining() remaining} byte size equals to minByteSize, if > 0, + * otherwise utilize {@link GLBuffers#sizeof(GL, int[], int, int, int, int, int, boolean)} + * to calculate it. + *

    + * + * @param gl the corresponding current GL context object + * @param pixelAttributes the desired {@link GLPixelAttributes} + * @param width in pixels + * @param height in pixels + * @param depth in pixels + * @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU + * @param minByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. + */ + GLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize); + } + /** + * Default {@link GLPixelBufferProvider} utilizing best match for {@link GLPixelAttributes} + * and {@link GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocating} a {@link ByteBuffer}. + */ + public static GLPixelBufferProvider defaultProvider = new GLPixelBufferProvider() { + + @Override + public GLPixelAttributes getAttributes(GL gl, int componentCount) { + final GLContext ctx = gl.getContext(); + final int dFormat, dType; + + if(gl.isGL2GL3() && 3 == componentCount) { + dFormat = GL.GL_RGB; + dType = GL.GL_UNSIGNED_BYTE; + } else { + dFormat = ctx.getDefaultPixelDataFormat(); + dType = ctx.getDefaultPixelDataType(); + } + return new GLPixelAttributes(componentCount, dFormat, dType); + } + + /** + * {@inheritDoc} + *

    + * Returns an NIO {@link ByteBuffer}. + *

    + */ + @Override + public GLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { + if( minByteSize > 0 ) { + return new GLPixelBuffer(pixelAttributes, width, height, depth, pack, Buffers.newDirectByteBuffer(minByteSize)); + } else { + int[] tmp = { 0 }; + final int byteSize = GLBuffers.sizeof(gl, tmp, pixelAttributes.bytesPerPixel, width, height, depth, pack); + return new GLPixelBuffer(pixelAttributes, width, height, depth, pack, Buffers.newDirectByteBuffer(byteSize)); + } + } + }; + + /** Pixel attributes. */ + public static class GLPixelAttributes { + /** Undefined instance of {@link GLPixelAttributes}, having componentCount:=0, format:=0 and type:= 0. */ + public static final GLPixelAttributes UNDEF = new GLPixelAttributes(0, 0, 0); + + /** Pixel component count */ + public final int componentCount; + /** The OpenGL pixel data format */ + public final int format; + /** The OpenGL pixel data type */ + public final int type; + /** The OpenGL pixel size in bytes */ + public final int bytesPerPixel; + + /** + * Deriving {@link #componentCount} via GL dataFormat, i.e. {@link GLBuffers#componentCount(int)} if > 0. + * @param dataFormat GL data format + * @param dataType GL data type + */ + public GLPixelAttributes(int dataFormat, int dataType) { + this(0 < dataFormat ? GLBuffers.componentCount(dataFormat) : 0, dataFormat, dataType); + } + /** + * Using user specified source {@link #componentCount}. + * @param componentCount source component count + * @param dataFormat GL data format + * @param dataType GL data type + */ + public GLPixelAttributes(int componentCount, int dataFormat, int dataType) { + this.componentCount = componentCount; + this.format = dataFormat; + this.type = dataType; + this.bytesPerPixel = ( 0 < dataFormat && 0 < dataType ) ? GLBuffers.bytesPerPixel(dataFormat, dataType) : 0; + } + public String toString() { + return "PixelAttributes[comp "+componentCount+", fmt 0x"+Integer.toHexString(format)+", type 0x"+Integer.toHexString(type)+", bytesPerPixel "+bytesPerPixel+"]"; + } + } + + /** The {@link GLPixelAttributes}. */ + public final GLPixelAttributes pixelAttributes; + /** Width in pixels. */ + public final int width; + /** Height in pixels. */ + public final int height; + /** Depth in pixels. */ + public final int depth; + /** Data packing direction. If true for read mode GPU -> CPU, false for write mode CPU -> GPU. */ + public final boolean pack; + /** Byte size of the buffer. Actually the number of {@link Buffer#remaining()} bytes when passed in ctor. */ + public final int byteSize; + /** + * Buffer holding the pixel data. If {@link #rewind()}, it holds byteSize {@link Buffer#remaining()} bytes. + *

    + * By default the {@link Buffer} is a {@link ByteBuffer}, due to {@link DefProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int)}. + * However, other {@link GLPixelBufferProvider} may utilize different {@link Buffer} types. + *

    + */ + public final Buffer buffer; + /** Buffer element size in bytes. */ + public final int bufferElemSize; + + public StringBuffer toString(StringBuffer sb) { + if(null == sb) { + sb = new StringBuffer(); + } + sb.append(pixelAttributes).append(", dim ").append(width).append("x").append(height).append("x").append(depth).append(", pack ").append(pack) + .append(", buffer[sz [bytes ").append(byteSize).append(", elemSize ").append(bufferElemSize).append(", ").append(buffer).append("]"); + return sb; + } + public String toString() { + return "GLPixelBuffer["+toString(null).toString()+"]"; + } + + public GLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, Buffer buffer) { + this.pixelAttributes = pixelAttributes; + this.width = width; + this.height = height; + this.depth = depth; + this.pack = pack; + this.buffer = buffer; + this.byteSize = Buffers.remainingBytes(buffer); + this.bufferElemSize = Buffers.sizeOfBufferElem(buffer); + } + + public boolean isValid() { + return 0 < byteSize; + } + + public Buffer rewind() { + return buffer.rewind(); + } + + /** Returns the byte position of the {@link #buffer}. */ + public int position() { + return buffer.position() * bufferElemSize; + } + + /** Sets the byte position of the {@link #buffer}. */ + public Buffer position(int bytePos) { + return buffer.position( bytePos / bufferElemSize ); + } + + public Buffer flip() { + return buffer.flip(); + } + + public Buffer clear() { + return buffer.clear(); + } + + /** + * Returns true, if implementation requires a new buffer based on the new size + * due to pixel alignment or byte size, otherwise false. + *

    + * It is assumed that pixelAttributes, depth and pack stays the same! + *

    + *

    + * The minimum required byte size equals to minByteSize, if > 0, + * otherwise utilize {@link GLBuffers#sizeof(GL, int[], int, int, int, int, int, boolean) GLBuffers.sizeof(..)} + * to calculate it. + *

    + * @param gl the corresponding current GL context object + * @param newWidth new width in pixels + * @param newHeight new height in pixels + * @param minByteSize if > 0, the pre-calculated minimum byte-size for the resulting buffer, otherwise ignore. + * @see GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) + */ + public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int minByteSize) { + return this.byteSize < minByteSize; + } + + /** Dispose resources. */ + public void dispose() { + buffer.clear(); + } +} + diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index dc87c7ac9..602dbb095 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -30,10 +30,9 @@ package com.jogamp.opengl.util; import java.io.File; import java.io.IOException; -import java.nio.Buffer; -import java.nio.ByteBuffer; import javax.media.opengl.GL; +import javax.media.opengl.GL2GL3; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLException; @@ -41,9 +40,9 @@ import javax.media.opengl.GLException; import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureData.DefPixelBufferProvider; -import com.jogamp.opengl.util.texture.TextureData.PixelAttributes; -import com.jogamp.opengl.util.texture.TextureData.PixelBufferProvider; +import com.jogamp.opengl.util.GLPixelBuffer; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelBufferProvider; import com.jogamp.opengl.util.texture.TextureIO; /** @@ -51,13 +50,12 @@ import com.jogamp.opengl.util.texture.TextureIO; *

    May be used directly to write the TextureData to file (screenshot).

    */ public class GLReadBufferUtil { - protected final PixelBufferProvider pixelBufferProvider; + protected final GLPixelBufferProvider pixelBufferProvider; protected final int componentCount, alignment; protected final Texture readTexture; protected final GLPixelStorageModes psm; - protected int readPixelSizeLast = 0; - protected Buffer readPixelBuffer = null; + protected GLPixelBuffer readPixelBuffer = null; protected TextureData readTextureData = null; /** @@ -65,10 +63,10 @@ public class GLReadBufferUtil { * @param write2Texture true if readPixel's TextureData shall be written to a 2d Texture */ public GLReadBufferUtil(boolean alpha, boolean write2Texture) { - this(new DefPixelBufferProvider(), alpha, write2Texture); + this(GLPixelBuffer.defaultProvider, alpha, write2Texture); } - public GLReadBufferUtil(PixelBufferProvider pixelBufferProvider, boolean alpha, boolean write2Texture) { + public GLReadBufferUtil(GLPixelBufferProvider pixelBufferProvider, boolean alpha, boolean write2Texture) { this.pixelBufferProvider = pixelBufferProvider; this.componentCount = alpha ? 4 : 3 ; this.alignment = alpha ? 4 : 1 ; @@ -76,11 +74,11 @@ public class GLReadBufferUtil { this.psm = new GLPixelStorageModes(); } - /** Returns the {@link PixelBufferProvider} used by this instance. */ - public PixelBufferProvider getPixelBufferProvider() { return pixelBufferProvider; } + /** Returns the {@link GLPixelBufferProvider} used by this instance. */ + public GLPixelBufferProvider getPixelBufferProvider() { return pixelBufferProvider; } public boolean isValid() { - return null!=readTextureData && null!=readPixelBuffer ; + return null!=readTextureData && null!=readPixelBuffer && readPixelBuffer.isValid(); } public boolean hasAlpha() { return 4 == componentCount ? true : false ; } @@ -88,14 +86,9 @@ public class GLReadBufferUtil { public GLPixelStorageModes getGLPixelStorageModes() { return psm; } /** - * Returns the raw pixel Buffer, filled by {@link #readPixels(GLAutoDrawable, boolean)}. - *

    - * By default the {@link Buffer} is a {@link ByteBuffer}, due to {@link DefPixelBufferProvider#allocate(int, int, int)}. - * If the {@link PixelBufferProvider} has changed via {@link #setPixelBufferProvider(PixelBufferProvider)}. - * the {@link Buffer} type maybe different. - *

    + * Returns the {@link GLPixelBuffer}, created and filled by {@link #readPixels(GLAutoDrawable, boolean)}. */ - public Buffer getPixelBuffer() { return readPixelBuffer; } + public GLPixelBuffer getPixelBuffer() { return readPixelBuffer; } /** * rewind the raw pixel ByteBuffer @@ -163,7 +156,7 @@ public class GLReadBufferUtil { if(GL.GL_NO_ERROR != glerr0) { System.err.println("Info: GLReadBufferUtil.readPixels: pre-exisiting GL error 0x"+Integer.toHexString(glerr0)); } - final PixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); + final GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); final int internalFormat; if(gl.isGL2GL3() && 3 == componentCount) { internalFormat = GL.GL_RGB; @@ -191,13 +184,12 @@ public class GLReadBufferUtil { } final int tmp[] = new int[1]; - final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.format, pixelAttribs.type, width, height, 1, true); + final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.bytesPerPixel, width, height, 1, true); boolean newData = false; - if( readPixelSize > readPixelSizeLast || pixelBufferProvider.requiresNewBuffer(width, height) ) { - readPixelBuffer = pixelBufferProvider.allocate(width, height, readPixelSize); + if( null == readPixelBuffer || readPixelBuffer.requiresNewBuffer(gl, width, height, readPixelSize) ) { + readPixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, width, height, 1, true, readPixelSize); Buffers.rangeCheckBytes(readPixelBuffer, readPixelSize); - readPixelSizeLast = readPixelSize ; try { readTextureData = new TextureData( gl.getGLProfile(), @@ -207,13 +199,12 @@ public class GLReadBufferUtil { pixelAttribs, false, false, flipVertically, - readPixelBuffer, + readPixelBuffer.buffer, null /* Flusher */); newData = true; } catch (Exception e) { readTextureData = null; readPixelBuffer = null; - readPixelSizeLast = 0; throw new RuntimeException("can not fetch offscreen texture", e); } } else { @@ -222,14 +213,17 @@ public class GLReadBufferUtil { readTextureData.setHeight(height); readTextureData.setPixelAttributes(pixelAttribs); } - boolean res = null!=readPixelBuffer; + boolean res = null!=readPixelBuffer && readPixelBuffer.isValid(); if(res) { psm.setAlignment(gl, alignment, alignment); + if(gl.isGL2GL3()) { + gl.getGL2GL3().glPixelStorei(GL2GL3.GL_PACK_ROW_LENGTH, readPixelBuffer.width); + } readPixelBuffer.clear(); try { - gl.glReadPixels(inX, inY, width, height, pixelAttribs.format, pixelAttribs.type, readPixelBuffer); + gl.glReadPixels(inX, inY, width, height, pixelAttribs.format, pixelAttribs.type, readPixelBuffer.buffer); } catch(GLException gle) { res = false; gle.printStackTrace(); } - readPixelBuffer.position( readPixelSize / Buffers.sizeOfBufferElem(readPixelBuffer) ); + readPixelBuffer.position( readPixelSize ); readPixelBuffer.flip(); final int glerr1 = gl.glGetError(); if(GL.GL_NO_ERROR != glerr1) { @@ -261,10 +255,9 @@ public class GLReadBufferUtil { readTextureData = null; } if(null != readPixelBuffer) { + readPixelBuffer.dispose(); readPixelBuffer = null; } - readPixelSizeLast = 0; - pixelBufferProvider.dispose(); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java new file mode 100644 index 000000000..2af48cefd --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java @@ -0,0 +1,203 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.awt; + +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.nio.Buffer; +import java.nio.IntBuffer; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2GL3; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.util.GLPixelBuffer; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; + +/** + * AWT {@link GLPixelBuffer} backed by an {@link BufferedImage} of type + * {@link BufferedImage#TYPE_INT_ARGB} or {@link BufferedImage#TYPE_INT_RGB}. + *

    + * Implementation uses an array backed {@link IntBuffer}. + *

    + *

    + * {@link AWTGLPixelBuffer} can be produced via {@link AWTGLPixelBufferProvider}'s + * {@link AWTGLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocate(..)}. + *

    + *

    + * See {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)} for {@link #allowRowStride} details. + *

    + */ +public class AWTGLPixelBuffer extends GLPixelBuffer { + public static final GLPixelAttributes awtPixelAttributesIntRGB = new GLPixelAttributes(GL.GL_BGRA, GL.GL_UNSIGNED_BYTE); + + /** Allow {@link GL2GL3#GL_PACK_ROW_LENGTH}, or {@link GL2GL3#GL_UNPACK_ROW_LENGTH}. See {@link #requiresNewBuffer(GL, int, int, int)}. */ + public final boolean allowRowStride; + /** The underlying {@link BufferedImage}. */ + public final BufferedImage image; + + /** + * @param pixelAttributes the desired {@link GLPixelAttributes} + * @param width in pixels + * @param height in pixels + * @param depth in pixels + * @param pack true for read mode GPU -> CPU, otherwise false for write mode CPU -> GPU + * @param image the AWT image + * @param buffer the backing array + * @param allowRowStride If true, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}. + */ + public AWTGLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, BufferedImage image, + Buffer buffer, boolean allowRowStride) { + super(pixelAttributes, width, height, depth, pack, buffer); + this.allowRowStride = allowRowStride; + this.image = image; + } + + /** + * {@inheritDoc} + *

    + * If {@link #allowRowStride} = false, + * method returns true if the new size ≠ current size. + *

    + *

    + * If {@link #allowRowStride} = true, see {@link AWTGLPixelBufferProvider#AWTGLPixelBufferProvider(boolean)}, + * method returns true only if the new size > current size. Assuming user utilizes the row-stride + * when dealing w/ the data, i.e. {@link GL2GL3#GL_PACK_ROW_LENGTH}. + *

    + */ + @Override + public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int minByteSize) { + if( allowRowStride && gl.isGL2GL3() ) { + return width < newWidth || height < newHeight; + } else { + return width != newWidth || height != newHeight; + } + } + + @Override + public void dispose() { + image.flush(); + super.dispose(); + } + + public StringBuffer toString(StringBuffer sb) { + sb = super.toString(sb); + sb.append(", allowRowStride ").append(allowRowStride).append(", image [").append(image.getWidth()).append("x").append(image.getHeight()).append(", ").append(image.toString()).append("]"); + return sb; + } + public String toString() { + return "AWTGLPixelBuffer["+toString(null).toString()+"]"; + } + + /** + * Provider for {@link AWTGLPixelBuffer} instances. + */ + public static class AWTGLPixelBufferProvider implements GLPixelBufferProvider { + /** Allow {@link GL2GL3#GL_PACK_ROW_LENGTH}, or {@link GL2GL3#GL_UNPACK_ROW_LENGTH}. */ + public final boolean allowRowStride; + + /** + * @param allowRowStride If true, allow row-stride, otherwise not. See {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. + */ + public AWTGLPixelBufferProvider(boolean allowRowStride) { + this.allowRowStride = allowRowStride; + } + @Override + public GLPixelAttributes getAttributes(GL gl, int componentCount) { + return awtPixelAttributesIntRGB; + } + + /** + * {@inheritDoc} + *

    + * Returns an array backed {@link IntBuffer} of size

    width*height*{@link Buffers#SIZEOF_INT SIZEOF_INT}.
    +         * 

    + */ + @Override + public AWTGLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { + final BufferedImage image = new BufferedImage(width, height, 4 == pixelAttributes.componentCount ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); + final int[] readBackIntBuffer = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); + final Buffer ibuffer = IntBuffer.wrap( readBackIntBuffer ); + return new AWTGLPixelBuffer(pixelAttributes, width, height, depth, pack, image, ibuffer, allowRowStride); + } + } + + /** + * Provider for singleton {@link AWTGLPixelBuffer} instances. + *

    + * Provider instance holds the last {@link AWTGLPixelBuffer} instance + * {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated}. + * A new {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocation} + * will return same instance, if a new buffer is not {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int) required}. + * The latter is true if size are compatible, hence allowRowStride should be enabled, if possible. + *

    + */ + public static class SingleAWTGLPixelBufferProvider extends AWTGLPixelBufferProvider { + private AWTGLPixelBuffer single = null; + + /** + * @param allowRowStride If true, allow row-stride, otherwise not. See {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. + */ + public SingleAWTGLPixelBufferProvider(boolean allowRowStride) { + super(allowRowStride); + } + + /** + * {@inheritDoc} + *

    + * Returns an array backed {@link IntBuffer} of size

    width*height*{@link Buffers#SIZEOF_INT SIZEOF_INT}.
    +         * 

    + */ + @Override + public AWTGLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { + if( null == single || single.requiresNewBuffer(gl, width, height, minByteSize) ) { + single = allocateImpl(pixelAttributes, width, height, depth, pack, minByteSize); + } + return single; + } + + private AWTGLPixelBuffer allocateImpl(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { + final BufferedImage image = new BufferedImage(width, height, 4 == pixelAttributes.componentCount ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); + final int[] readBackIntBuffer = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); + final Buffer ibuffer = IntBuffer.wrap( readBackIntBuffer ); + return new AWTGLPixelBuffer(pixelAttributes, width, height, depth, pack, image, ibuffer, allowRowStride); + } + + /** + * Initializes the single {@link AWTGLPixelBuffer} w/ a given size, if not yet {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated}. + * @return the newly initialized single {@link AWTGLPixelBuffer}, or null if already allocated. + */ + public AWTGLPixelBuffer initSingleton(int width, int height, int depth, boolean pack) { + if( null != single ) { + return null; + } + single = allocateImpl(AWTGLPixelBuffer.awtPixelAttributesIntRGB, width, height, depth, pack, 0); + return single; + } + } +} \ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java index f26fec0d5..0edd53ca1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java @@ -28,14 +28,11 @@ package com.jogamp.opengl.util.awt; import java.awt.image.BufferedImage; -import java.nio.Buffer; -import java.nio.IntBuffer; import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.texture.awt.AWTTextureData.AWTPixelBufferProviderInt; /** * {@link GLReadBufferUtil} specialization allowing to @@ -48,25 +45,15 @@ public class AWTGLReadBufferUtil extends GLReadBufferUtil { * * @param alpha */ - public AWTGLReadBufferUtil(boolean alpha) { - super(new AWTPixelBufferProviderInt(), alpha, false); + public AWTGLReadBufferUtil(GLProfile glp, boolean alpha) { + super(new AWTGLPixelBuffer.AWTGLPixelBufferProvider( glp.isGL2GL3() /* allowRowStride */ ), alpha, false); } - /** - * Returns the raw pixel Buffer, filled by {@link #readPixels(GLAutoDrawable, boolean)}. - *

    - * Due to using {@link AWTPixelBufferProviderInt#allocate(int, int, int)}, - * returns an {@link IntBuffer} instance. - *

    - */ - @Override - public Buffer getPixelBuffer() { return readPixelBuffer; } - - public BufferedImage getImage() { return ((AWTPixelBufferProviderInt)pixelBufferProvider).getImage(); } + public AWTGLPixelBuffer getAWTGLPixelBuffer() { return (AWTGLPixelBuffer)this.getPixelBuffer(); } public BufferedImage readPixelsToBufferedImage(GL gl, boolean awtOrientation) { if( readPixels(gl, awtOrientation) ) { - final BufferedImage image = getImage(); + final BufferedImage image = getAWTGLPixelBuffer().image; if( getTextureData().getMustFlipVertically() ) { ImageUtil.flipImageVertically(image); } @@ -78,7 +65,7 @@ public class AWTGLReadBufferUtil extends GLReadBufferUtil { final int[] ioWidth = new int[] { inWidth }; final int[] ioHeight= new int[] { inHeight }; if( readPixels(gl, inX, inY, ioWidth, ioHeight, awtOrientation) ) { - final BufferedImage image = getImage(); + final BufferedImage image = getAWTGLPixelBuffer().image; if( getTextureData().getMustFlipVertically() ) { ImageUtil.flipImageVertically(image); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java index 2f0c86255..dec1b43cf 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureData.java @@ -38,14 +38,11 @@ package com.jogamp.opengl.util.texture; import java.nio.Buffer; -import java.nio.ByteBuffer; -import javax.media.opengl.GL; -import javax.media.opengl.GLContext; import javax.media.opengl.GLProfile; -import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.GLBuffers; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; /** * Represents the data for an OpenGL texture. This is separated from @@ -62,97 +59,10 @@ public class TextureData { /** ColorSpace of pixel data. */ public static enum ColorSpace { RGB, YCbCr, YCCK, CMYK }; - /** Pixel data attributes. */ - public static class PixelAttributes { - /** Undefinded instance of {@link PixelAttributes}, having format:=0 and type:= 0. */ - public static final PixelAttributes UNDEF = new PixelAttributes(0, 0); - - /** The OpenGL pixel data format */ - public final int format; - /** The OpenGL pixel data type */ - public final int type; - public PixelAttributes(int dataFormat, int dataType) { - this.format = dataFormat; - this.type = dataType; - } - public String toString() { - return "PixelAttributes[fFmt 0x"+Integer.toHexString(format)+", type 0x"+Integer.toHexString(type)+"]"; - } - } - /** Allows user to interface with another toolkit to define {@link PixelAttributes} and memory buffer to produce {@link TextureData}. */ - public static interface PixelBufferProvider { - /** Called first to determine {@link PixelAttributes}. */ - PixelAttributes getAttributes(GL gl, int componentCount); - - /** - * Returns true, if implementation requires a new buffer based on the new size - * and previous aquired {@link #getAttributes(GL, int) attributes} due to pixel alignment, otherwise false. - * @see #allocate(int, int, int) - */ - boolean requiresNewBuffer(int width, int height); - - /** - * Called after {@link #getAttributes(GL, int)} to retrieve the NIO or array backed pixel {@link Buffer}. - *

    - * Being called to gather the initial {@link Buffer}, if the existing {@link Buffer} size is not sufficient, - * or if {@link #requiresNewBuffer(int, int)} returns false. - *

    - *

    - * Number of components was passed via {@link #getAttributes(GL, int)}. - *

    - *

    - * The returned buffer must have at least minByteSize {@link Buffer#remaining() remaining}. - *

    - */ - Buffer allocate(int width, int height, int minByteSize); - - /** Dispose resources. */ - void dispose(); - } - /** - * Default {@link PixelBufferProvider} utilizing best match for {@link PixelAttributes} - * and {@link #allocate(int, int, int) allocating} a {@link ByteBuffer}. - */ - public static class DefPixelBufferProvider implements PixelBufferProvider { - @Override - public PixelAttributes getAttributes(GL gl, int componentCount) { - final GLContext ctx = gl.getContext(); - final int dFormat, dType; - - if(gl.isGL2GL3() && 3 == componentCount) { - dFormat = GL.GL_RGB; - dType = GL.GL_UNSIGNED_BYTE; - } else { - dFormat = ctx.getDefaultPixelDataFormat(); - dType = ctx.getDefaultPixelDataType(); - } - return new TextureData.PixelAttributes(dFormat, dType); - } - @Override - public boolean requiresNewBuffer(int width, int height) { - return false; - } - /** - * {@inheritDoc} - *

    - * Returns an NIO {@link ByteBuffer} of minByteSize. - *

    - */ - @Override - public final Buffer allocate(int width, int height, int minByteSize) { - return Buffers.newDirectByteBuffer(minByteSize); - } - - @Override - public void dispose() { - // nop - } - } - protected int width; protected int height; private int border; - protected PixelAttributes pixelAttributes; + protected GLPixelAttributes pixelAttributes; protected int internalFormat; // perhaps inferred from pixelFormat? protected boolean mipmap; // indicates whether mipmaps should be generated // (ignored if mipmaps are supplied from the file) @@ -225,7 +135,7 @@ public class TextureData { boolean mustFlipVertically, Buffer buffer, Flusher flusher) throws IllegalArgumentException { - this(glp, internalFormat, width, height, border, new PixelAttributes(pixelFormat, pixelType), + this(glp, internalFormat, width, height, border, new GLPixelAttributes(pixelFormat, pixelType), mipmap, dataIsCompressed, mustFlipVertically, buffer, flusher); } @@ -273,7 +183,7 @@ public class TextureData { int width, int height, int border, - PixelAttributes pixelAttributes, + GLPixelAttributes pixelAttributes, boolean mipmap, boolean dataIsCompressed, boolean mustFlipVertically, @@ -348,7 +258,7 @@ public class TextureData { boolean mustFlipVertically, Buffer[] mipmapData, Flusher flusher) throws IllegalArgumentException { - this(glp, internalFormat, width, height, border, new PixelAttributes(pixelFormat, pixelType), + this(glp, internalFormat, width, height, border, new GLPixelAttributes(pixelFormat, pixelType), dataIsCompressed, mustFlipVertically, mipmapData, flusher); } @@ -395,7 +305,7 @@ public class TextureData { int width, int height, int border, - PixelAttributes pixelAttributes, + GLPixelAttributes pixelAttributes, boolean dataIsCompressed, boolean mustFlipVertically, Buffer[] mipmapData, @@ -429,7 +339,7 @@ public class TextureData { public void setColorSpace(ColorSpace cs) { pixelCS = cs; } /** Used only by subclasses */ - protected TextureData(GLProfile glp) { this.glProfile = glp; this.pixelAttributes = PixelAttributes.UNDEF; } + protected TextureData(GLProfile glp) { this.glProfile = glp; this.pixelAttributes = GLPixelAttributes.UNDEF; } /** Returns the width in pixels of the texture data. */ public int getWidth() { return width; } @@ -439,8 +349,8 @@ public class TextureData { public int getBorder() { return border; } - /** Returns the intended OpenGL {@link PixelAttributes} of the texture data, i.e. format and type. */ - public PixelAttributes getPixelAttributes() { + /** Returns the intended OpenGL {@link GLPixelAttributes} of the texture data, i.e. format and type. */ + public GLPixelAttributes getPixelAttributes() { return pixelAttributes; } /** Returns the intended OpenGL pixel format of the texture data. */ @@ -495,27 +405,27 @@ public class TextureData { /** Sets the border in pixels of the texture data. */ public void setBorder(int border) { this.border = border; } /** Sets the intended OpenGL pixel format of the texture data. */ - public void setPixelAttributes(PixelAttributes pixelAttributes) { this.pixelAttributes = pixelAttributes; } + public void setPixelAttributes(GLPixelAttributes pixelAttributes) { this.pixelAttributes = pixelAttributes; } /** - * Sets the intended OpenGL pixel format component of {@link PixelAttributes} of the texture data. + * Sets the intended OpenGL pixel format component of {@link GLPixelAttributes} of the texture data. *

    - * Use {@link #setPixelAttributes(PixelAttributes)}, if setting format and type. + * Use {@link #setPixelAttributes(GLPixelAttributes)}, if setting format and type. *

    */ public void setPixelFormat(int pixelFormat) { if( pixelAttributes.format != pixelFormat ) { - pixelAttributes = new PixelAttributes(pixelFormat, pixelAttributes.type); + pixelAttributes = new GLPixelAttributes(pixelFormat, pixelAttributes.type); } } /** - * Sets the intended OpenGL pixel type component of {@link PixelAttributes} of the texture data. + * Sets the intended OpenGL pixel type component of {@link GLPixelAttributes} of the texture data. *

    - * Use {@link #setPixelAttributes(PixelAttributes)}, if setting format and type. + * Use {@link #setPixelAttributes(GLPixelAttributes)}, if setting format and type. *

    */ public void setPixelType(int pixelType) { if( pixelAttributes.type != pixelType) { - pixelAttributes = new PixelAttributes(pixelAttributes.format, pixelType); + pixelAttributes = new GLPixelAttributes(pixelAttributes.format, pixelType); } } /** Sets the intended OpenGL internal format of the texture data. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java index 7a0f00edf..d7e825c1d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/awt/AWTTextureData.java @@ -66,62 +66,10 @@ import javax.media.opengl.GL2GL3; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureData.PixelBufferProvider; public class AWTTextureData extends TextureData { - public static final PixelAttributes awtPixelAttributesIntRGB = new PixelAttributes(GL.GL_BGRA, GL.GL_UNSIGNED_BYTE); - - /** - * AWT {@link PixelBufferProvider} backed by a {@link BufferedImage} of type - * {@link BufferedImage#TYPE_INT_ARGB} or {@link BufferedImage#TYPE_INT_RGB} - * and {@link #allocate(int, int, int) allocating} am array backed {@link IntBuffer}. - */ - public static final class AWTPixelBufferProviderInt implements PixelBufferProvider { - private BufferedImage image = null; - private int componentCount = 0; - - @Override - public PixelAttributes getAttributes(GL gl, int componentCount) { - this.componentCount = componentCount; - return awtPixelAttributesIntRGB; - } - @Override - public boolean requiresNewBuffer(int width, int height) { - return null == image || image.getWidth() != width || image.getHeight() != height; - } - /** - * {@inheritDoc} - *

    - * Returns an array backed {@link IntBuffer} of size

    width*height*{@link Buffers#SIZEOF_INT SIZEOF_INT}.
    -         * 

    - */ - @Override - public Buffer allocate(int width, int height, int minByteSize) { - image = new BufferedImage(width, height, 4 == componentCount ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB); - final int[] readBackIntBuffer = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); - return IntBuffer.wrap( readBackIntBuffer ); - } - - @Override - public void dispose() { - if(null != image) { - image.flush(); - image = null; - } - } - - /** Returns the number source components being used as indicated at {@link #allocate(int, int, int)}. */ - public int getComponentCount() { return componentCount; } - - /** Returns the underlying {@link BufferedImage} as allocated via {@link #allocate(int, int, int)}. */ - public BufferedImage getImage() { return image; } - - /** Returns true if an underlying {@link BufferedImage} has been allocated via {@link #allocate(int, int, int)}. */ - public boolean hasImage() { return null != image; } - } - // Mechanism for lazily converting input BufferedImages with custom // ColorModels to standard ones for uploading to OpenGL, as well as // backing off from the optimizations of hoping that either @@ -198,7 +146,7 @@ public class AWTTextureData extends TextureData { } @Override - public PixelAttributes getPixelAttributes() { + public GLPixelAttributes getPixelAttributes() { validatePixelAttributes(); return super.getPixelAttributes(); } @@ -229,7 +177,7 @@ public class AWTTextureData extends TextureData { } private void createFromImage(GLProfile glp, BufferedImage image) { - pixelAttributes = PixelAttributes.UNDEF; // Determine from image + pixelAttributes = GLPixelAttributes.UNDEF; // Determine from image mustFlipVertically = true; width = image.getWidth(); @@ -259,21 +207,21 @@ public class AWTTextureData extends TextureData { if (glp.isGL2GL3()) { switch (image.getType()) { case BufferedImage.TYPE_INT_RGB: - pixelAttributes = new PixelAttributes(GL.GL_BGRA, GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV); + pixelAttributes = new GLPixelAttributes(GL.GL_BGRA, GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV); rowLength = scanlineStride; alignment = 4; expectingGL12 = true; setupLazyCustomConversion(image); break; case BufferedImage.TYPE_INT_ARGB_PRE: - pixelAttributes = new PixelAttributes(GL.GL_BGRA, GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV); + pixelAttributes = new GLPixelAttributes(GL.GL_BGRA, GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV); rowLength = scanlineStride; alignment = 4; expectingGL12 = true; setupLazyCustomConversion(image); break; case BufferedImage.TYPE_INT_BGR: - pixelAttributes = new PixelAttributes(GL.GL_RGBA, GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV); + pixelAttributes = new GLPixelAttributes(GL.GL_RGBA, GL2GL3.GL_UNSIGNED_INT_8_8_8_8_REV); rowLength = scanlineStride; alignment = 4; expectingGL12 = true; @@ -284,7 +232,7 @@ public class AWTTextureData extends TextureData { // we can pass the image data directly to OpenGL only if // we have an integral number of pixels in each scanline if ((scanlineStride % 3) == 0) { - pixelAttributes = new PixelAttributes(GL2GL3.GL_BGR, GL.GL_UNSIGNED_BYTE); + pixelAttributes = new GLPixelAttributes(GL2GL3.GL_BGR, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride / 3; alignment = 1; } else { @@ -304,7 +252,7 @@ public class AWTTextureData extends TextureData { // the necessary byte swapping (FIXME: needs more // investigation) if ((scanlineStride % 4) == 0 && glp.isGL2() && false) { - pixelAttributes = new PixelAttributes(GL2.GL_ABGR_EXT, GL.GL_UNSIGNED_BYTE); + pixelAttributes = new GLPixelAttributes(GL2.GL_ABGR_EXT, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride / 4; alignment = 4; @@ -320,26 +268,26 @@ public class AWTTextureData extends TextureData { } } case BufferedImage.TYPE_USHORT_565_RGB: - pixelAttributes = new PixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_SHORT_5_6_5); + pixelAttributes = new GLPixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_SHORT_5_6_5); rowLength = scanlineStride; alignment = 2; expectingGL12 = true; setupLazyCustomConversion(image); break; case BufferedImage.TYPE_USHORT_555_RGB: - pixelAttributes = new PixelAttributes(GL.GL_BGRA, GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV); + pixelAttributes = new GLPixelAttributes(GL.GL_BGRA, GL2GL3.GL_UNSIGNED_SHORT_1_5_5_5_REV); rowLength = scanlineStride; alignment = 2; expectingGL12 = true; setupLazyCustomConversion(image); break; case BufferedImage.TYPE_BYTE_GRAY: - pixelAttributes = new PixelAttributes(GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE); + pixelAttributes = new GLPixelAttributes(GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride; alignment = 1; break; case BufferedImage.TYPE_USHORT_GRAY: - pixelAttributes = new PixelAttributes(GL.GL_LUMINANCE, GL.GL_UNSIGNED_SHORT); + pixelAttributes = new GLPixelAttributes(GL.GL_LUMINANCE, GL.GL_UNSIGNED_SHORT); rowLength = scanlineStride; alignment = 2; break; @@ -354,11 +302,11 @@ public class AWTTextureData extends TextureData { default: java.awt.image.ColorModel cm = image.getColorModel(); if (cm.equals(rgbColorModel)) { - pixelAttributes = new PixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_BYTE); + pixelAttributes = new GLPixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride / 3; alignment = 1; } else if (cm.equals(rgbaColorModel)) { - pixelAttributes = new PixelAttributes(GL.GL_RGBA, GL.GL_UNSIGNED_BYTE); + pixelAttributes = new GLPixelAttributes(GL.GL_RGBA, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride / 4; // FIXME: correct? alignment = 4; } else { @@ -370,7 +318,7 @@ public class AWTTextureData extends TextureData { } else { switch (image.getType()) { case BufferedImage.TYPE_INT_RGB: - pixelAttributes = new PixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_BYTE); + pixelAttributes = new GLPixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride; alignment = 3; expectingGL12 = true; @@ -385,21 +333,21 @@ public class AWTTextureData extends TextureData { case BufferedImage.TYPE_4BYTE_ABGR_PRE: throw new GLException("INT_BGR n.a."); case BufferedImage.TYPE_USHORT_565_RGB: - pixelAttributes = new PixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_SHORT_5_6_5); + pixelAttributes = new GLPixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_SHORT_5_6_5); rowLength = scanlineStride; alignment = 2; expectingGL12 = true; setupLazyCustomConversion(image); break; case BufferedImage.TYPE_USHORT_555_RGB: - pixelAttributes = new PixelAttributes(GL.GL_RGBA, GL.GL_UNSIGNED_SHORT_5_5_5_1); + pixelAttributes = new GLPixelAttributes(GL.GL_RGBA, GL.GL_UNSIGNED_SHORT_5_5_5_1); rowLength = scanlineStride; alignment = 2; expectingGL12 = true; setupLazyCustomConversion(image); break; case BufferedImage.TYPE_BYTE_GRAY: - pixelAttributes = new PixelAttributes(GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE); + pixelAttributes = new GLPixelAttributes(GL.GL_LUMINANCE, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride; alignment = 1; break; @@ -416,11 +364,11 @@ public class AWTTextureData extends TextureData { default: java.awt.image.ColorModel cm = image.getColorModel(); if (cm.equals(rgbColorModel)) { - pixelAttributes = new PixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_BYTE); + pixelAttributes = new GLPixelAttributes(GL.GL_RGB, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride / 3; alignment = 1; } else if (cm.equals(rgbaColorModel)) { - pixelAttributes = new PixelAttributes(GL.GL_RGBA, GL.GL_UNSIGNED_BYTE); + pixelAttributes = new GLPixelAttributes(GL.GL_RGBA, GL.GL_UNSIGNED_BYTE); rowLength = scanlineStride / 4; // FIXME: correct? alignment = 4; } else { @@ -465,7 +413,7 @@ public class AWTTextureData extends TextureData { } else { throw new RuntimeException("Unexpected DataBuffer type?"); } - pixelAttributes = new PixelAttributes(pixelFormat, pixelType); + pixelAttributes = new GLPixelAttributes(pixelFormat, pixelType); } private void createFromCustom(BufferedImage image) { @@ -524,7 +472,7 @@ public class AWTTextureData extends TextureData { // and knowing we're in the process of doing the fallback code // path, re-infer a vanilla pixel format and type compatible with // OpenGL 1.1 - pixelAttributes = PixelAttributes.UNDEF; + pixelAttributes = GLPixelAttributes.UNDEF; setupLazyCustomConversion(imageForLazyCustomConversion); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 65bcab100..3f3e88977 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -86,10 +86,11 @@ import jogamp.opengl.awt.Java2D; import jogamp.opengl.util.glsl.GLSLTextureRaster; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.opengl.FBObject; -import com.jogamp.opengl.util.GLBuffers; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.GLPixelStorageModes; -import com.jogamp.opengl.util.texture.TextureData.PixelAttributes; -import com.jogamp.opengl.util.texture.awt.AWTTextureData.AWTPixelBufferProviderInt; +import com.jogamp.opengl.util.awt.AWTGLPixelBuffer; +import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; +import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider; /** A lightweight Swing component which provides OpenGL rendering support. Provided for compatibility with Swing user interfaces @@ -133,12 +134,58 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private static final boolean DEBUG_VIEWPORT = Debug.isPropertyDefined("jogl.debug.GLJPanel.Viewport", true); private static final boolean USE_GLSL_TEXTURE_RASTERIZER = !Debug.isPropertyDefined("jogl.gljpanel.noglsl", true); + /** Indicates whether the Java 2D OpenGL pipeline is requested by user. */ + private static final boolean java2dOGLEnabledByProp; + + /** Indicates whether the Java 2D OpenGL pipeline is enabled, resource-compatible and requested by user. */ + private static final boolean useJava2DGLPipeline; + + /** Indicates whether the Java 2D OpenGL pipeline's usage is error free. */ + private static boolean java2DGLPipelineOK; + + static { + boolean enabled = false; + final String sVal = System.getProperty("sun.java2d.opengl"); + if( null != sVal ) { + enabled = Boolean.valueOf(sVal); + } + java2dOGLEnabledByProp = enabled && !Debug.isPropertyDefined("jogl.gljpanel.noogl", true); + + enabled = false; + if( java2dOGLEnabledByProp ) { + // Force eager initialization of part of the Java2D class since + // otherwise it's likely it will try to be initialized while on + // the Queue Flusher Thread, which is not allowed + if (Java2D.isOGLPipelineResourceCompatible() && Java2D.isFBOEnabled()) { + if( null != Java2D.getShareContext(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()) ) { + enabled = true; + } + } + } + useJava2DGLPipeline = enabled; + java2DGLPipelineOK = enabled; + if( DEBUG ) { + System.err.println("GLJPanel: java2dOGLEnabledByProp "+java2dOGLEnabledByProp); + System.err.println("GLJPanel: useJava2DGLPipeline "+useJava2DGLPipeline); + System.err.println("GLJPanel: java2DGLPipelineOK "+java2DGLPipelineOK); + } + } + + private static SingleAWTGLPixelBufferProvider singleAWTGLPixelBufferProvider = null; + private static synchronized SingleAWTGLPixelBufferProvider getSingleAWTGLPixelBufferProvider() { + if( null == singleAWTGLPixelBufferProvider ) { + singleAWTGLPixelBufferProvider = new SingleAWTGLPixelBufferProvider( true /* allowRowStride */ ); + } + return singleAWTGLPixelBufferProvider; + } + private GLDrawableHelper helper = new GLDrawableHelper(); private volatile boolean isInitialized; // // Data used for either pbuffers or pixmap-based offscreen surfaces // + private AWTGLPixelBufferProvider customPixelBufferProvider = null; /** Single buffered offscreen caps */ private GLCapabilitiesImmutable offscreenCaps; private GLProfile glProfile; @@ -170,10 +217,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // Used by all backends either directly or indirectly to hook up callbacks private Updater updater = new Updater(); - // Indicates whether the Java 2D OpenGL pipeline is enabled and resource-compatible - private boolean oglPipelineUsable = - Java2D.isOGLPipelineResourceCompatible() && - !Debug.isPropertyDefined("jogl.gljpanel.noogl", true); + private boolean oglPipelineUsable() { + return null == customPixelBufferProvider && useJava2DGLPipeline && java2DGLPipelineOK; + } private AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @@ -183,17 +229,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } }, null); - static { - // Force eager initialization of part of the Java2D class since - // otherwise it's likely it will try to be initialized while on - // the Queue Flusher Thread, which is not allowed - if (Java2D.isOGLPipelineResourceCompatible() && Java2D.isFBOEnabled()) { - Java2D.getShareContext(GraphicsEnvironment. - getLocalGraphicsEnvironment(). - getDefaultScreenDevice()); - } - } - /** Creates a new GLJPanel component with a default set of OpenGL capabilities and using the default OpenGL capabilities selection mechanism. @@ -252,6 +287,23 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.setFocusable(true); // allow keyboard input! } + public AWTGLPixelBufferProvider getCustomPixelBufferProvider() { return customPixelBufferProvider; } + + /** + * @param custom custom {@link AWTGLPixelBufferProvider} + * @throws IllegalArgumentException if custom is null + * @throws IllegalStateException if backend is already realized, i.e. this instanced already painted once. + */ + public void setPixelBufferProvider(AWTGLPixelBufferProvider custom) throws IllegalArgumentException, IllegalStateException { + if( null == custom ) { + throw new IllegalArgumentException("Null PixelBufferProvider"); + } + if( null != backend ) { + throw new IllegalStateException("Backend already realized."); + } + customPixelBufferProvider = custom; + } + @Override public final Object getUpstreamWidget() { return this; @@ -629,7 +681,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing to perform OpenGL rendering using the GLJPanel into the same OpenGL drawable as the Swing implementation uses. */ public boolean shouldPreserveColorBufferIfTranslucent() { - return oglPipelineUsable; + return oglPipelineUsable(); } @Override @@ -701,10 +753,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } if ( null == backend ) { - if (oglPipelineUsable) { + if ( oglPipelineUsable() ) { backend = new J2DOGLBackend(); } else { - backend = new OffscreenBackend(); + backend = new OffscreenBackend(glProfile, customPixelBufferProvider); } isInitialized = false; } @@ -922,14 +974,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // backends, both of which rely on reading back the OpenGL frame // buffer and drawing it with a BufferedImage class OffscreenBackend implements Backend { - protected AWTPixelBufferProviderInt pixelBufferProvider = new AWTPixelBufferProviderInt(); - private PixelAttributes pixelAttribs; + private final AWTGLPixelBufferProvider pixelBufferProvider; + private AWTGLPixelBuffer pixelBuffer; + private boolean pixelBufferCheckSize; // One of these is used to store the read back pixels before storing // in the BufferedImage - protected IntBuffer readBackInts; - protected int readBackWidthInPixels; - protected int readBackHeightInPixels; + protected IntBuffer readBackInts; // Implementation using software rendering private GLDrawableImpl offscreenDrawable; @@ -943,6 +994,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // For saving/restoring of OpenGL state during ReadPixels private final GLPixelStorageModes psm = new GLPixelStorageModes(); + OffscreenBackend(GLProfile glp, AWTGLPixelBufferProvider custom) { + if(null == custom) { + pixelBufferProvider = glp.isGL2GL3() ? getSingleAWTGLPixelBufferProvider() : + new AWTGLPixelBufferProvider( true /* allowRowStride */ ); + } else { + pixelBufferProvider = custom; + } + } + @Override public boolean isUsingOwnLifecycle() { return false; } @@ -1049,7 +1109,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void setOpaque(boolean opaque) { if (opaque != isOpaque()) { - pixelBufferProvider.dispose(); + pixelBuffer.dispose(); + pixelBuffer = null; } } @@ -1076,30 +1137,38 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing alignment = 4; } + final GLPixelAttributes pixelAttribs; + + if( pixelBufferCheckSize ) { + pixelBufferCheckSize = false; + if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) { + pixelBuffer.dispose(); + pixelBuffer = null; + } + } + // Must now copy pixels from offscreen context into surface - if ( !pixelBufferProvider.hasImage() ) { + if ( null == pixelBuffer ) { if (0 >= panelWidth || 0 >= panelHeight ) { return; } pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); - - final int[] tmp = { 0 }; - final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.format, pixelAttribs.type, panelWidth, panelHeight, 1, true); - final IntBuffer intBuffer = (IntBuffer) pixelBufferProvider.allocate(panelWidth, panelHeight, readPixelSize); - if(!flipVertical || null != glslTextureRaster) { - readBackInts = intBuffer; + pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, panelWidth, panelHeight, 1, true, 0); + if( !flipVertical || null != glslTextureRaster ) { + readBackInts = (IntBuffer) pixelBuffer.buffer; } else { - readBackInts = IntBuffer.allocate(readBackWidthInPixels * readBackHeightInPixels); + readBackInts = IntBuffer.allocate(pixelBuffer.width * pixelBuffer.height); } if(DEBUG) { - final BufferedImage offscreenImage = pixelBufferProvider.getImage(); - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelAttribs "+pixelAttribs); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBufferProvider 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName()); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBuffer 0x"+Integer.toHexString(pixelBuffer.hashCode())+", "+pixelBuffer+", alignment "+alignment); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)); - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight +", readBackSizeInPixels "+readBackWidthInPixels+"x"+readBackHeightInPixels); - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: offscreenImage "+offscreenImage.getWidth()+"x"+offscreenImage.getHeight()); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight); } - } + } else { + pixelAttribs = pixelBuffer.pixelAttributes; + } if( DEBUG_VIEWPORT ) { int[] vp = new int[] { 0, 0, 0, 0 }; @@ -1111,7 +1180,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing psm.setAlignment(gl, alignment, alignment); if(gl.isGL2GL3()) { final GL2GL3 gl2gl3 = gl.getGL2GL3(); - gl2gl3.glPixelStorei(GL2GL3.GL_PACK_ROW_LENGTH, readBackWidthInPixels); + gl2gl3.glPixelStorei(GL2GL3.GL_PACK_ROW_LENGTH, pixelBuffer.width); gl2gl3.glReadBuffer(gl2gl3.getDefaultReadBuffer()); } @@ -1127,27 +1196,25 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing gl.glBindTexture(GL.GL_TEXTURE_2D, fboTex.getName()); // gl.glClear(GL.GL_DEPTH_BUFFER_BIT); // fboFlipped runs w/o DEPTH! glslTextureRaster.display(gl.getGL2ES2()); - gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, pixelAttribs.format, pixelAttribs.type, readBackInts); + gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts); fboFlipped.unbind(gl); } else { - gl.glReadPixels(0, 0, readBackWidthInPixels, readBackHeightInPixels, pixelAttribs.format, pixelAttribs.type, readBackInts); + gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts); if ( flipVertical ) { // Copy temporary data into raster of BufferedImage for faster // blitting Note that we could avoid this copy in the cases - // where !offscreenContext.offscreenImageNeedsVerticalFlip(), - // but that's the software rendering path which is very slow - // anyway - final BufferedImage offscreenImage = pixelBufferProvider.getImage(); - final Object src = readBackInts.array(); - final Object dest = ((DataBufferInt) offscreenImage.getRaster().getDataBuffer()).getData(); - final int srcIncr = readBackWidthInPixels; - final int destIncr = offscreenImage.getWidth(); + // where !offscreenDrawable.isGLOriented(), + // but that's the software rendering path which is very slow anyway. + final BufferedImage image = pixelBuffer.image; + final int[] src = readBackInts.array(); + final int[] dest = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); + final int incr = pixelBuffer.width; int srcPos = 0; - int destPos = (offscreenImage.getHeight() - 1) * destIncr; - for (; destPos >= 0; srcPos += srcIncr, destPos -= destIncr) { - System.arraycopy(src, srcPos, dest, destPos, destIncr); + int destPos = (panelHeight - 1) * pixelBuffer.width; + for (; destPos >= 0; srcPos += incr, destPos -= incr) { + System.arraycopy(src, srcPos, dest, destPos, incr); } } } @@ -1164,13 +1231,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void doPaintComponent(Graphics g) { helper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction); - final BufferedImage offscreenImage = pixelBufferProvider.getImage(); - if ( null != offscreenImage ) { + if ( null != pixelBuffer ) { + final BufferedImage image = pixelBuffer.image; // Draw resulting image in one shot - g.drawImage(offscreenImage, 0, 0, - offscreenImage.getWidth(), - offscreenImage.getHeight(), - null /* Null ImageObserver since image data is ready. */); + g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null); // Null ImageObserver since image data is ready. } } @@ -1201,8 +1265,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } panelWidth = _drawable.getWidth(); panelHeight = _drawable.getHeight(); - readBackWidthInPixels = panelWidth; - readBackHeightInPixels = panelHeight; if( null != glslTextureRaster ) { if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { @@ -1216,7 +1278,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } - pixelBufferProvider.dispose(); + pixelBufferCheckSize = true; return _drawable.isRealized(); } @@ -1618,7 +1680,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } isInitialized = false; backend = null; - oglPipelineUsable = false; + java2DGLPipelineOK = false; handleReshape = true; j2dContext.destroy(); j2dContext = null; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java index 81be58aa5..22c1f62dd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java @@ -84,7 +84,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL /* @Override */ public void init(GLAutoDrawable drawable) { - awtGLReadBufferUtil = new AWTGLReadBufferUtil(false); + awtGLReadBufferUtil = new AWTGLReadBufferUtil(drawable.getGLProfile(), false); } /* @Override */ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java index 3f593e908..dc1d528f8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java @@ -128,7 +128,7 @@ public class TestBug605FlippedImageNEWT extends UITestCase { glad.display(); System.err.println("XXX "+glad.getChosenGLCapabilities()); System.err.println("XXX "+glad.getContext().getGLVersion()); - testFlipped((ByteBuffer)rbu.getPixelBuffer(), glad.getWidth(), glad.getHeight(), 3); + testFlipped((ByteBuffer)rbu.getPixelBuffer().buffer, glad.getWidth(), glad.getHeight(), 3); glad.destroy(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java index e4c0f47a4..0b0030d99 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java @@ -30,7 +30,10 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; import java.awt.AWTException; import java.awt.BorderLayout; -import java.awt.Dimension; +import java.awt.Component; +import java.awt.Container; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; import java.lang.reflect.InvocationTargetException; import java.nio.FloatBuffer; @@ -39,8 +42,10 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLJPanel; +import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.JTextField; import javax.swing.SwingUtilities; import org.junit.AfterClass; @@ -54,11 +59,15 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.FPSAnimator; +import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; +import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider; public class TestGearsES2GLJPanelsAWT extends UITestCase { static int demoCount = 4; - static boolean opaque = false; // always faster and flicker-less w/o opaque, i.e. w/ alpha channel due to JComponent _paintImmediately(..) - static float alpha = 0.3f; + static boolean jOpaque = false; // flicker-less w/o opaque, opaque leads to overdraw w/ mixed clipRects -> flicker - due to JComponent _paintImmediately(..) (?) + static boolean glOpaque = true; // can be either .. + static float glAlpha = 0.3f; + static boolean jZOrder = false; static GLProfile glp; static boolean shallUsePBuffer = false; static boolean shallUseBitmap = false; @@ -66,7 +75,15 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { static int swapInterval = 0; static boolean useAnimator = true; static boolean manualTest = false; + static boolean useSingleBuffer = true; // default + /** + * Even though GLJPanel uses a SingleAWTGLPixelBufferProvider per default, + * we like to initialize it's size to a common maximum to ensure + * only one {@link AWTGLPixelBuffer} gets allocated. + */ + static SingleAWTGLPixelBufferProvider singleAWTGLPixelBufferProvider; + @BeforeClass public static void initClass() { if(GLProfile.isAvailable(GLProfile.GL2)) { @@ -75,21 +92,33 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { } else { setTestSupported(false); } + + if( useSingleBuffer ) { + singleAWTGLPixelBufferProvider = new SingleAWTGLPixelBufferProvider( glp.isGL2GL3() /* allowRowStride */); + singleAWTGLPixelBufferProvider.initSingleton(600, 600, 1, true); + } else { + singleAWTGLPixelBufferProvider = null; + } } @AfterClass public static void releaseClass() { } - private void addPanel(GLCapabilitiesImmutable caps, GLAnimatorControl anim, final JFrame frame, boolean opaque, int x, int y, int w, int h, FloatBuffer color, float[] clearColor) + final static boolean useInterPanel = true; + + /** Adds new JPanel to frame's content pane at index 0 */ + private JComponent addPanel(GLCapabilitiesImmutable caps, GLAnimatorControl anim, final JFrame frame, boolean opaque, int x, int y, int w, int h, FloatBuffer color, float[] clearColor) throws InterruptedException, InvocationTargetException { final GLJPanel canvas = new GLJPanel(caps); + if( useSingleBuffer ) { + canvas.setPixelBufferProvider( singleAWTGLPixelBufferProvider ); + } canvas.setOpaque(opaque); - final Dimension glc_sz = new Dimension(w, h); - canvas.setMinimumSize(glc_sz); - canvas.setPreferredSize(glc_sz); - canvas.setSize(glc_sz); + if ( !useInterPanel ) { + canvas.setBounds(x, y, w, h); + } GearsES2 demo = new GearsES2(swapInterval); demo.setIgnoreFocus(true); demo.setGearsColors(color, color, color); @@ -99,31 +128,62 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { anim.add(canvas); } - final JPanel panel = new JPanel(new BorderLayout()); - panel.setBounds(x, y, w, h); - panel.setOpaque(opaque); + final JPanel panel; + final JTextField text; + if ( useInterPanel ) { + panel = new JPanel(new BorderLayout()); + panel.setBounds(x, y, w, h); + panel.setOpaque(opaque); + text = new JTextField(x+"/"+y+" "+w+"x"+h); + text.setOpaque(true); + } else { + panel = null; + text = null; + } SwingUtilities.invokeAndWait(new Runnable() { public void run() { - panel.add(canvas, BorderLayout.CENTER); - frame.getContentPane().add(panel); + if ( useInterPanel ) { + panel.add(text, BorderLayout.NORTH); + panel.add(canvas, BorderLayout.CENTER); + frame.getContentPane().add(panel, 0); + } else { + frame.getContentPane().add(canvas, 0); + } } } ) ; + return useInterPanel ? panel : canvas; } public static final FloatBuffer red = Buffers.newDirectFloatBuffer( new float[] { 1.0f, 0.0f, 0.0f, 1.0f } ); public static final FloatBuffer green = Buffers.newDirectFloatBuffer( new float[] { 0.0f, 1.0f, 0.0f, 1.0f } ); public static final FloatBuffer blue = Buffers.newDirectFloatBuffer( new float[] { 0.0f, 0.0f, 1.0f, 1.0f } ); public static final FloatBuffer yellow = Buffers.newDirectFloatBuffer( new float[] { 1.0f, 1.0f, 0.0f, 1.0f } ); + public static final FloatBuffer grey = Buffers.newDirectFloatBuffer( new float[] { 0.5f, 0.5f, 0.5f, 1.0f } ); public static final float grayf = 0.3f; - public static final float[] redish = new float[] { grayf, 0.0f, 0.0f, alpha }; - public static final float[] greenish = new float[] { 0.0f, grayf, 0.0f, alpha }; - public static final float[] blueish = new float[] { 0.0f, 0.0f, grayf, alpha }; - public static final float[] yellowish = new float[] { grayf, grayf, 0.0f, alpha }; + public static final float[] redish = new float[] { grayf, 0.0f, 0.0f, glAlpha }; + public static final float[] greenish = new float[] { 0.0f, grayf, 0.0f, glAlpha }; + public static final float[] blueish = new float[] { 0.0f, 0.0f, grayf, glAlpha }; + public static final float[] yellowish = new float[] { grayf, grayf, 0.0f, glAlpha }; + public static final float[] greyish = new float[] { grayf, grayf, grayf, glAlpha }; + + protected void relayout(Container cont, float oW, float oH) { + final int count = cont.getComponentCount(); + final int nW = cont.getWidth(); + final int nH = cont.getHeight(); + for(int i = 0 ; i < count; i++ ) { + final Component comp = cont.getComponent(i); + float fx = comp.getX() / oW; + float fy = comp.getY() / oH; + float fw = comp.getWidth() / oW; + float fh = comp.getHeight() / oH; + comp.setBounds( (int)(fx * nW), (int)(fy * nH), (int)(fw * nW), (int)(fh * nH) ); + } + } protected void runTestGL(GLCapabilities caps) throws AWTException, InterruptedException, InvocationTargetException { - if( !opaque ) { + if( !glOpaque ) { caps.setAlphaBits(caps.getRedBits()); } @@ -137,22 +197,46 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { frame.getContentPane().setLayout(null); } } ); + final float[] oldSize = new float[] { 600f, 600f }; + + frame.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + final int count = frame.getComponentCount(); + for(int i = 0 ; i < count; i++ ) { + relayout(frame.getContentPane(), oldSize[0], oldSize[1]); + } + frame.getContentPane().invalidate(); + frame.getContentPane().validate(); + // frame.pack(); + oldSize[0] = frame.getContentPane().getWidth(); + oldSize[1] = frame.getContentPane().getHeight(); + } + } ) ; + if( demoCount > 0 ) { - addPanel(caps, animator, frame, opaque, 50, 50, 300, 300, red, redish); // A + addPanel(caps, animator, frame, jOpaque, 50, 50, 300, 300, red, redish); // A } if( demoCount > 1 ) { - addPanel(caps, animator, frame, opaque, 200, 0, 150, 150, green, greenish); // B + addPanel(caps, animator, frame, jOpaque, 0, 250, 300, 300, blue, blueish); // C } if( demoCount > 2 ) { - addPanel(caps, animator, frame, opaque, 0, 250, 300, 300, blue, blueish); // C + addPanel(caps, animator, frame, jOpaque, 300, 0, 150, 150, green, greenish); // B } if( demoCount > 3 ) { - addPanel(caps, animator, frame, opaque, 300, 300, 100, 100, yellow, yellowish); // D + addPanel(caps, animator, frame, jOpaque, 300, 300, 100, 100, yellow, yellowish); // D + } + if( jZOrder ) { + final Container cont = frame.getContentPane(); + final int count = cont.getComponentCount(); + for(int i = 0 ; i < count; i++ ) { + cont.setComponentZOrder(cont.getComponent(i), count - 1 - i); + } } SwingUtilities.invokeAndWait(new Runnable() { public void run() { - frame.setSize(600, 600); + frame.setSize((int)oldSize[0], (int)oldSize[1]); frame.getContentPane().validate(); // frame.pack(); frame.setVisible(true); @@ -284,11 +368,20 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { swapInterval = MiscUtils.atoi(args[i], swapInterval); } else if(args[i].equals("-msaa")) { useMSAA = true; - } else if(args[i].equals("-opaque")) { - opaque = true; + } else if(args[i].equals("-jOpaque")) { + i++; + jOpaque = MiscUtils.atob(args[i], jOpaque); + } else if(args[i].equals("-glOpaque")) { + i++; + glOpaque = MiscUtils.atob(args[i], glOpaque); } else if(args[i].equals("-alpha")) { i++; - alpha = MiscUtils.atof(args[i], alpha); + glAlpha = MiscUtils.atof(args[i], glAlpha); + } else if(args[i].equals("-singleBuffer")) { + i++; + useSingleBuffer = MiscUtils.atob(args[i], useSingleBuffer); + } else if(args[i].equals("-jZOrder")) { + jZOrder = true; } else if(args[i].equals("-noanim")) { useAnimator = false; } else if(args[i].equals("-pbuffer")) { @@ -303,14 +396,16 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { } } System.err.println("swapInterval "+swapInterval); - System.err.println("opaque "+opaque); - System.err.println("alpha "+alpha); + System.err.println("opaque gl "+glOpaque+", java/gljpanel "+jOpaque); + System.err.println("alpha "+glAlpha); + System.err.println("jZOrder "+jZOrder); System.err.println("demos "+demoCount); System.err.println("useMSAA "+useMSAA); System.err.println("useAnimator "+useAnimator); System.err.println("shallUsePBuffer "+shallUsePBuffer); System.err.println("shallUseBitmap "+shallUseBitmap); System.err.println("manualTest "+manualTest); + System.err.println("useSingleBuffer "+useSingleBuffer); org.junit.runner.JUnitCore.main(TestGearsES2GLJPanelsAWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java index 71a63a701..bf8323e88 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java @@ -21,6 +21,7 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.GLReadBufferUtil; import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureIO; @@ -49,7 +50,7 @@ public class TestJPEGImage01NEWT extends UITestCase { image.getWidth(), image.getHeight(), 0, - new TextureData.PixelAttributes(image.getGLFormat(), image.getGLType()), + new GLPixelAttributes(image.getGLFormat(), image.getGLType()), false /* mipmap */, false /* compressed */, false /* must flip-vert */, diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTBenchmarkNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTBenchmarkNewtAWT.java index 681667362..1e27f5dae 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTBenchmarkNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTBenchmarkNewtAWT.java @@ -36,6 +36,7 @@ import javax.imageio.ImageIO; import javax.media.opengl.GL; import javax.media.opengl.GLProfile; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.awt.AWTTextureData; import com.jogamp.opengl.util.texture.spi.JPEGImage; @@ -68,7 +69,7 @@ public class TestJPEGJoglAWTBenchmarkNewtAWT extends UITestCase { image.getWidth(), image.getHeight(), 0, - new TextureData.PixelAttributes(image.getGLFormat(), image.getGLType()), + new GLPixelAttributes(image.getGLFormat(), image.getGLType()), false /* mipmap */, false /* compressed */, false /* must flip-vert */, @@ -96,7 +97,7 @@ public class TestJPEGJoglAWTBenchmarkNewtAWT extends UITestCase { image.getWidth(), image.getHeight(), 0, - new TextureData.PixelAttributes(image.getGLFormat(), image.getGLType()), + new GLPixelAttributes(image.getGLFormat(), image.getGLType()), false /* mipmap */, false /* compressed */, false /* must flip-vert */, diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTCompareNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTCompareNewtAWT.java index 5d2969815..0df275652 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTCompareNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTCompareNewtAWT.java @@ -49,6 +49,7 @@ import com.jogamp.opengl.util.texture.TextureIO; import com.jogamp.opengl.util.texture.awt.AWTTextureData; import com.jogamp.opengl.util.texture.spi.JPEGImage; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.GLReadBufferUtil; import java.awt.image.BufferedImage; @@ -112,7 +113,7 @@ public class TestJPEGJoglAWTCompareNewtAWT extends UITestCase { image.getWidth(), image.getHeight(), 0, - new TextureData.PixelAttributes(image.getGLFormat(), image.getGLType()), + new GLPixelAttributes(image.getGLFormat(), image.getGLType()), false /* mipmap */, false /* compressed */, false /* must flip-vert */, diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java index 5b2876744..c33384611 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture01AWT.java @@ -122,7 +122,7 @@ public class TestTexture01AWT extends UITestCase { @Test public void test1() throws InterruptedException { - final AWTGLReadBufferUtil awtGLReadBufferUtil = new AWTGLReadBufferUtil(false); + final AWTGLReadBufferUtil awtGLReadBufferUtil = new AWTGLReadBufferUtil(caps.getGLProfile(), false); final Frame frame0 = new Frame("GL -> AWT"); final Canvas canvas = new Canvas(); frame0.add(canvas); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture02AWT.java index bdc8934fc..5948f5971 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTexture02AWT.java @@ -77,7 +77,7 @@ public class TestTexture02AWT extends UITestCase { @Test public void test1() throws InterruptedException { - final AWTGLReadBufferUtil awtGLReadBufferUtil = new AWTGLReadBufferUtil(false); + final AWTGLReadBufferUtil awtGLReadBufferUtil = new AWTGLReadBufferUtil(caps.getGLProfile(), false); final Frame frame0 = new Frame("GL -> AWT"); final ImageIcon imageIcon = new ImageIcon(); final JLabel imageLabel = new JLabel(imageIcon); diff --git a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java index d17914939..d6e9743e0 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java +++ b/src/test/com/jogamp/opengl/test/junit/util/MiscUtils.java @@ -33,6 +33,15 @@ import java.lang.reflect.*; import java.nio.FloatBuffer; public class MiscUtils { + public static boolean atob(String str, boolean def) { + try { + return Boolean.parseBoolean(str); + } catch (Exception ex) { + ex.printStackTrace(); + } + return def; + } + public static int atoi(String str, int def) { try { return Integer.parseInt(str); -- cgit v1.2.3 From ed732cddbcb979062c56e9c93534a232aaa7fa20 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 8 May 2013 23:39:17 +0200 Subject: Fix regression of commit 0a7bf77b8c0765f8a53dc72a8edab8e0496938ff - GLReadBufferUtil's GLPixelBuffer* usage. Ref GLJPanel SingleAWTGLPixelBufferProvider's screenshots. Ref GLJPanel SingleAWTGLPixelBufferProvider's screenshots: --- make/scripts/tests.sh | 6 +++--- src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 99eb2e077..da4698a8e 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -183,7 +183,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" - D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" @@ -282,7 +282,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -516,7 +516,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT # # Texture / TextureUtils # -#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index 602dbb095..ae1b459a6 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -189,7 +189,7 @@ public class GLReadBufferUtil { boolean newData = false; if( null == readPixelBuffer || readPixelBuffer.requiresNewBuffer(gl, width, height, readPixelSize) ) { readPixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, width, height, 1, true, readPixelSize); - Buffers.rangeCheckBytes(readPixelBuffer, readPixelSize); + Buffers.rangeCheckBytes(readPixelBuffer.buffer, readPixelSize); try { readTextureData = new TextureData( gl.getGLProfile(), -- cgit v1.2.3 From 5e0a5049d873b5896553ee530562c28ffd3fbe0c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 May 2013 02:57:09 +0200 Subject: Fix NEWT MultiMonitor Regression: Use case w/o attached monitor, and NPE (Cache) in ScreenImpl.getVirtualMonitorDevice(..). W/ RandR13, we can have a case of an Output/CRT w/o valid modes, indicating a switched off or detached monitor. ScreenImpl.getVirtualMonitorDevice(..) requires a Cache .. due to MonitorModeProps.streamInMonitorDevice(..) --- make/scripts/tests.sh | 6 ++--- src/newt/classes/jogamp/newt/ScreenImpl.java | 29 ++++++++++++++++------ .../jogamp/newt/driver/x11/ScreenDriver.java | 4 ++- 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index da4698a8e..73fa54f38 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,7 +135,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Screen" + D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -516,7 +516,7 @@ function testawtswt() { # # Texture / TextureUtils # -testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index d7bd326fe..7edf7b63a 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -446,7 +446,13 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { refMonitorModeListener.remove(sml); } - private final MonitorMode getVirtualMonitorMode(int modeId) { + /** + * + * @param cache optional .. + * @param modeId + * @return + */ + private final MonitorMode getVirtualMonitorMode(MonitorModeProps.Cache cache, int modeId) { final int[] props = new int[MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL]; int i = 0; props[i++] = MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL; @@ -460,10 +466,17 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( MonitorModeProps.NUM_MONITOR_MODE_PROPERTIES_ALL != i ) { throw new InternalError("XX"); } - return MonitorModeProps.streamInMonitorMode(null, null, props, 0); + return MonitorModeProps.streamInMonitorMode(null, cache, props, 0); } - - private final MonitorDevice getVirtualMonitorDevice(int monitorId, MonitorMode currentMode) { + + /** + * + * @param cache mandatory ! + * @param monitorId + * @param currentMode + * @return + */ + private final MonitorDevice getVirtualMonitorDevice(MonitorModeProps.Cache cache, int monitorId, MonitorMode currentMode) { int[] props = new int[MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES]; int i = 0; props[i++] = MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES; @@ -480,7 +493,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES != i ) { throw new InternalError("XX"); } - return MonitorModeProps.streamInMonitorDevice(null, null, this, props, 0); + return MonitorModeProps.streamInMonitorDevice(null, cache, this, props, 0); } /** @@ -498,7 +511,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( 0>=getWidth() || 0>=getHeight() ) { updateVirtualScreenOriginAndSize(); } - res = getVirtualMonitorMode(monitor.getCurrentMode().getId()); + res = getVirtualMonitorMode(null, monitor.getCurrentMode().getId()); } return res; } @@ -522,9 +535,9 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { if( 0 >= collectNativeMonitorModes(cache) ) { updateVirtualScreenOriginAndSize(); vScrnSizeUpdated = true; - final MonitorMode mode = getVirtualMonitorMode(0); + final MonitorMode mode = getVirtualMonitorMode(cache, 0); cache.monitorModes.getOrAdd(mode); - final MonitorDevice monitor = getVirtualMonitorDevice(0, mode); + final MonitorDevice monitor = getVirtualMonitorDevice(cache, 0, mode); cache.monitorDevices.getOrAdd(monitor); } if(DEBUG) { diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index f2836f190..b8b13939b 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -139,7 +139,9 @@ public class ScreenDriver extends ScreenImpl { if( cache.monitorModes.size() > 0 ) { for(int i = 0; i < crtCount; i++) { final int[] monitorProps = rAndR.getMonitorDeviceProps(device.getHandle(), this, cache, i); - if( null != monitorProps ) { // enabled + if( null != monitorProps && + MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps[0] && // Enabled ? I.e. contains active modes ? + MonitorModeProps.MIN_MONITOR_DEVICE_PROPERTIES <= monitorProps.length ) { MonitorModeProps.streamInMonitorDevice(null, cache, this, monitorProps, 0); } } -- cgit v1.2.3 From 890dabf77593732bd9833350b441a37c60f74d45 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 May 2013 04:49:29 +0200 Subject: Fix Bug 731: GLJPanel: Access global GLPixelBuffer via SingletonGLPixelBufferProvider, if provided - releasing prev. smaller GLPixelBuffer after resize. --- make/scripts/tests.sh | 6 +-- .../com/jogamp/opengl/util/GLPixelBuffer.java | 25 ++++++++-- .../jogamp/opengl/util/awt/AWTGLPixelBuffer.java | 49 ++++++++++++++----- .../classes/javax/media/opengl/awt/GLJPanel.java | 57 +++++++++++++++------- .../demos/es2/awt/TestGearsES2GLJPanelsAWT.java | 15 +++--- 5 files changed, 107 insertions(+), 45 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 73fa54f38..8fb6c20c6 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,7 +135,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" - D_ARGS="-Dnewt.debug.Screen" + #D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -282,9 +282,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java index b2e0af2b5..6b9d3bf2c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -74,6 +74,18 @@ public class GLPixelBuffer { */ GLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize); } + + /** Single {@link GLPixelBuffer} provider. */ + public static interface SingletonGLPixelBufferProvider extends GLPixelBufferProvider { + /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link GLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ + GLPixelBuffer getSingleBuffer(GLPixelAttributes pixelAttributes); + /** + * Initializes the single {@link GLPixelBuffer} w/ a given size, if not yet {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated}. + * @return the newly initialized single {@link GLPixelBuffer}, or null if already allocated. + */ + GLPixelBuffer initSingleton(int componentCount, int width, int height, int depth, boolean pack); + } + /** * Default {@link GLPixelBufferProvider} utilizing best match for {@link GLPixelAttributes} * and {@link GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocating} a {@link ByteBuffer}. @@ -118,7 +130,7 @@ public class GLPixelBuffer { /** Undefined instance of {@link GLPixelAttributes}, having componentCount:=0, format:=0 and type:= 0. */ public static final GLPixelAttributes UNDEF = new GLPixelAttributes(0, 0, 0); - /** Pixel component count */ + /** Pixel source component count, i.e. number of meaningful components. */ public final int componentCount; /** The OpenGL pixel data format */ public final int format; @@ -175,12 +187,14 @@ public class GLPixelBuffer { /** Buffer element size in bytes. */ public final int bufferElemSize; + private boolean disposed = false; + public StringBuffer toString(StringBuffer sb) { if(null == sb) { sb = new StringBuffer(); } sb.append(pixelAttributes).append(", dim ").append(width).append("x").append(height).append("x").append(depth).append(", pack ").append(pack) - .append(", buffer[sz [bytes ").append(byteSize).append(", elemSize ").append(bufferElemSize).append(", ").append(buffer).append("]"); + .append(", disposed ").append(disposed).append(", valid ").append(isValid()).append(", buffer[sz [bytes ").append(byteSize).append(", elemSize ").append(bufferElemSize).append(", ").append(buffer).append("]"); return sb; } public String toString() { @@ -198,8 +212,9 @@ public class GLPixelBuffer { this.bufferElemSize = Buffers.sizeOfBufferElem(buffer); } + /** Is not {@link #dispose()} and has {@link #byteSize} > 0. */ public boolean isValid() { - return 0 < byteSize; + return !disposed && 0 < byteSize; } public Buffer rewind() { @@ -226,7 +241,7 @@ public class GLPixelBuffer { /** * Returns true, if implementation requires a new buffer based on the new size - * due to pixel alignment or byte size, otherwise false. + * due to pixel alignment or byte size or if {@link #isValid() invalid}, otherwise false. *

    * It is assumed that pixelAttributes, depth and pack stays the same! *

    @@ -242,7 +257,7 @@ public class GLPixelBuffer { * @see GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) */ public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int minByteSize) { - return this.byteSize < minByteSize; + return !isValid() || this.byteSize < minByteSize; } /** Dispose resources. */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java index 2af48cefd..aceb609a1 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java @@ -54,7 +54,8 @@ import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; *

    */ public class AWTGLPixelBuffer extends GLPixelBuffer { - public static final GLPixelAttributes awtPixelAttributesIntRGB = new GLPixelAttributes(GL.GL_BGRA, GL.GL_UNSIGNED_BYTE); + public static final GLPixelAttributes awtPixelAttributesIntRGBA4 = new GLPixelAttributes(4, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE); + public static final GLPixelAttributes awtPixelAttributesIntRGB3 = new GLPixelAttributes(3, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE); /** Allow {@link GL2GL3#GL_PACK_ROW_LENGTH}, or {@link GL2GL3#GL_UNPACK_ROW_LENGTH}. See {@link #requiresNewBuffer(GL, int, int, int)}. */ public final boolean allowRowStride; @@ -92,6 +93,9 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { */ @Override public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int minByteSize) { + if( !isValid() ) { + return true; + } if( allowRowStride && gl.isGL2GL3() ) { return width < newWidth || height < newHeight; } else { @@ -129,7 +133,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { } @Override public GLPixelAttributes getAttributes(GL gl, int componentCount) { - return awtPixelAttributesIntRGB; + return 4 == componentCount ? awtPixelAttributesIntRGBA4 : awtPixelAttributesIntRGB3; } /** @@ -157,8 +161,9 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * The latter is true if size are compatible, hence allowRowStride should be enabled, if possible. *

    */ - public static class SingleAWTGLPixelBufferProvider extends AWTGLPixelBufferProvider { - private AWTGLPixelBuffer single = null; + public static class SingleAWTGLPixelBufferProvider extends AWTGLPixelBufferProvider implements SingletonGLPixelBufferProvider { + private AWTGLPixelBuffer singleRGBA4 = null; + private AWTGLPixelBuffer singleRGB3 = null; /** * @param allowRowStride If true, allow row-stride, otherwise not. See {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. @@ -175,10 +180,17 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { */ @Override public AWTGLPixelBuffer allocate(GL gl, GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { - if( null == single || single.requiresNewBuffer(gl, width, height, minByteSize) ) { - single = allocateImpl(pixelAttributes, width, height, depth, pack, minByteSize); + if( 4 == pixelAttributes.componentCount ) { + if( null == singleRGBA4 || singleRGBA4.requiresNewBuffer(gl, width, height, minByteSize) ) { + singleRGBA4 = allocateImpl(pixelAttributes, width, height, depth, pack, minByteSize); + } + return singleRGBA4; + } else { + if( null == singleRGB3 || singleRGB3.requiresNewBuffer(gl, width, height, minByteSize) ) { + singleRGB3 = allocateImpl(pixelAttributes, width, height, depth, pack, minByteSize); + } + return singleRGB3; } - return single; } private AWTGLPixelBuffer allocateImpl(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, int minByteSize) { @@ -188,16 +200,29 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { return new AWTGLPixelBuffer(pixelAttributes, width, height, depth, pack, image, ibuffer, allowRowStride); } + /** Return the last {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated} {@link AWTGLPixelBuffer} w/ {@link GLPixelAttributes#componentCount}. */ + public AWTGLPixelBuffer getSingleBuffer(GLPixelAttributes pixelAttributes) { + return 4 == pixelAttributes.componentCount ? singleRGBA4 : singleRGB3; + } + /** * Initializes the single {@link AWTGLPixelBuffer} w/ a given size, if not yet {@link #allocate(GL, GLPixelAttributes, int, int, int, boolean, int) allocated}. * @return the newly initialized single {@link AWTGLPixelBuffer}, or null if already allocated. */ - public AWTGLPixelBuffer initSingleton(int width, int height, int depth, boolean pack) { - if( null != single ) { - return null; + public AWTGLPixelBuffer initSingleton(int componentCount, int width, int height, int depth, boolean pack) { + if( 4 == componentCount ) { + if( null != singleRGBA4 ) { + return null; + } + singleRGBA4 = allocateImpl(AWTGLPixelBuffer.awtPixelAttributesIntRGBA4, width, height, depth, pack, 0); + return singleRGBA4; + } else { + if( null != singleRGB3 ) { + return null; + } + singleRGB3 = allocateImpl(AWTGLPixelBuffer.awtPixelAttributesIntRGB3, width, height, depth, pack, 0); + return singleRGB3; } - single = allocateImpl(AWTGLPixelBuffer.awtPixelAttributesIntRGB, width, height, depth, pack, 0); - return single; } } } \ No newline at end of file diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 3f3e88977..7359e1b47 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -87,6 +87,7 @@ import jogamp.opengl.util.glsl.GLSLTextureRaster; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; +import com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider; import com.jogamp.opengl.util.GLPixelStorageModes; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; @@ -301,7 +302,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if( null != backend ) { throw new IllegalStateException("Backend already realized."); } - customPixelBufferProvider = custom; + customPixelBufferProvider = custom; } @Override @@ -975,12 +976,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // buffer and drawing it with a BufferedImage class OffscreenBackend implements Backend { private final AWTGLPixelBufferProvider pixelBufferProvider; + private final boolean useSingletonBuffer; private AWTGLPixelBuffer pixelBuffer; private boolean pixelBufferCheckSize; // One of these is used to store the read back pixels before storing // in the BufferedImage - protected IntBuffer readBackInts; + protected IntBuffer readBackIntsForCPUVFlip; // Implementation using software rendering private GLDrawableImpl offscreenDrawable; @@ -997,10 +999,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing OffscreenBackend(GLProfile glp, AWTGLPixelBufferProvider custom) { if(null == custom) { pixelBufferProvider = glp.isGL2GL3() ? getSingleAWTGLPixelBufferProvider() : - new AWTGLPixelBufferProvider( true /* allowRowStride */ ); + new AWTGLPixelBufferProvider( false /* allowRowStride */ ) ; } else { pixelBufferProvider = custom; } + if( pixelBufferProvider instanceof SingletonGLPixelBufferProvider ) { + useSingletonBuffer = true; + } else { + useSingletonBuffer = false; + } } @Override @@ -1104,11 +1111,22 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing adevice.close(); } } + + if( null != readBackIntsForCPUVFlip ) { + readBackIntsForCPUVFlip.clear(); + readBackIntsForCPUVFlip = null; + } + if( null != pixelBuffer ) { + if( !useSingletonBuffer ) { + pixelBuffer.dispose(); + } + pixelBuffer = null; + } } @Override public void setOpaque(boolean opaque) { - if (opaque != isOpaque()) { + if ( opaque != isOpaque() && !useSingletonBuffer ) { pixelBuffer.dispose(); pixelBuffer = null; } @@ -1137,8 +1155,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing alignment = 4; } - final GLPixelAttributes pixelAttribs; + final GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); + if( useSingletonBuffer ) { // attempt to fetch the latest AWTGLPixelBuffer + pixelBuffer = (AWTGLPixelBuffer) ((SingletonGLPixelBufferProvider)pixelBufferProvider).getSingleBuffer(pixelAttribs); + } if( pixelBufferCheckSize ) { pixelBufferCheckSize = false; if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) { @@ -1147,28 +1168,28 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } - // Must now copy pixels from offscreen context into surface if ( null == pixelBuffer ) { if (0 >= panelWidth || 0 >= panelHeight ) { return; - } - - pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); + } pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, panelWidth, panelHeight, 1, true, 0); - if( !flipVertical || null != glslTextureRaster ) { - readBackInts = (IntBuffer) pixelBuffer.buffer; - } else { - readBackInts = IntBuffer.allocate(pixelBuffer.width * pixelBuffer.height); - } if(DEBUG) { - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBufferProvider 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName()); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBufferProvider isSingletonBufferProvider "+useSingletonBuffer+", 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName()); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBuffer 0x"+Integer.toHexString(pixelBuffer.hashCode())+", "+pixelBuffer+", alignment "+alignment); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)); System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight); } + } + final IntBuffer readBackInts; + + if( !flipVertical || null != glslTextureRaster ) { + readBackInts = (IntBuffer) pixelBuffer.buffer; } else { - pixelAttribs = pixelBuffer.pixelAttributes; - } + if( null == readBackIntsForCPUVFlip || pixelBuffer.width * pixelBuffer.height > readBackIntsForCPUVFlip.remaining() ) { + readBackIntsForCPUVFlip = IntBuffer.allocate(pixelBuffer.width * pixelBuffer.height); + } + readBackInts = readBackIntsForCPUVFlip; + } if( DEBUG_VIEWPORT ) { int[] vp = new int[] { 0, 0, 0, 0 }; @@ -1176,6 +1197,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: Viewport: "+vp[0]+"/"+vp[1]+" "+vp[2]+"x"+vp[3]); } + // Must now copy pixels from offscreen context into surface + // Save current modes psm.setAlignment(gl, alignment, alignment); if(gl.isGL2GL3()) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java index 0b0030d99..54dfe6726 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2GLJPanelsAWT.java @@ -59,7 +59,6 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.FPSAnimator; -import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider; public class TestGearsES2GLJPanelsAWT extends UITestCase { @@ -75,7 +74,7 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { static int swapInterval = 0; static boolean useAnimator = true; static boolean manualTest = false; - static boolean useSingleBuffer = true; // default + static boolean initSingleBuffer = false; /** * Even though GLJPanel uses a SingleAWTGLPixelBufferProvider per default, @@ -93,9 +92,9 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { setTestSupported(false); } - if( useSingleBuffer ) { + if( initSingleBuffer ) { singleAWTGLPixelBufferProvider = new SingleAWTGLPixelBufferProvider( glp.isGL2GL3() /* allowRowStride */); - singleAWTGLPixelBufferProvider.initSingleton(600, 600, 1, true); + singleAWTGLPixelBufferProvider.initSingleton(4, 600, 600, 1, true); } else { singleAWTGLPixelBufferProvider = null; } @@ -112,7 +111,7 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { throws InterruptedException, InvocationTargetException { final GLJPanel canvas = new GLJPanel(caps); - if( useSingleBuffer ) { + if( initSingleBuffer ) { canvas.setPixelBufferProvider( singleAWTGLPixelBufferProvider ); } canvas.setOpaque(opaque); @@ -377,9 +376,9 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { } else if(args[i].equals("-alpha")) { i++; glAlpha = MiscUtils.atof(args[i], glAlpha); - } else if(args[i].equals("-singleBuffer")) { + } else if(args[i].equals("-initSingleBuffer")) { i++; - useSingleBuffer = MiscUtils.atob(args[i], useSingleBuffer); + initSingleBuffer = MiscUtils.atob(args[i], initSingleBuffer); } else if(args[i].equals("-jZOrder")) { jZOrder = true; } else if(args[i].equals("-noanim")) { @@ -405,7 +404,7 @@ public class TestGearsES2GLJPanelsAWT extends UITestCase { System.err.println("shallUsePBuffer "+shallUsePBuffer); System.err.println("shallUseBitmap "+shallUseBitmap); System.err.println("manualTest "+manualTest); - System.err.println("useSingleBuffer "+useSingleBuffer); + System.err.println("useSingleBuffer "+initSingleBuffer); org.junit.runner.JUnitCore.main(TestGearsES2GLJPanelsAWT.class.getName()); } -- cgit v1.2.3 From 86a5460c5052cdab7b9f6294c46a0b4e30dfa260 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 16 May 2013 21:33:25 +0200 Subject: Fix Bug 723: Remove VK_KP_ numpad key-codes, use general VK_ key-codes; Respect numpad printable keys; Use keySym for numpad if possible. - KeyEvent keyCode/keySym values re-ordered! - Remove VK_KP_ numpad key-codes, use general VK_ key-codes. Numpad cursor keys are not supported on some platforms (Windows), or not configured on most X11 configurations. - Respect numpad printable keys, i.e. don't treat them as non-printable. - Use keySym for numpad if possible. Numpad keys require modifiers, hence X11 and Windows shall return keySym. --- make/scripts/tests-x64.bat | 4 +- make/scripts/tests.sh | 6 +-- .../classes/com/jogamp/newt/event/KeyEvent.java | 61 +++++++++------------- .../jogamp/newt/awt/event/AWTNewtEventFactory.java | 12 ++--- .../jogamp/newt/swt/event/SWTNewtEventFactory.java | 4 -- src/newt/native/KeyEvent.h | 20 +++---- src/newt/native/WindowsWindow.c | 42 +++++++++------ src/newt/native/X11Display.c | 24 +++++++-- 8 files changed, 88 insertions(+), 85 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 27ecfb2cc..401e7905b 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -55,7 +55,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsReali REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -109,7 +109,7 @@ REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRec REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* +REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT %* REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT %* REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8fb6c20c6..4ced71d3d 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -174,7 +174,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -282,9 +282,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 45bccf964..6e63ad3a3 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -327,7 +327,6 @@ public class KeyEvent extends InputEvent ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { return false; } - } else { if( ( nonPrintableKeys[0].inclKeyChar && nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || ( nonPrintableKeys[1].inclKeyChar && nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || @@ -391,12 +390,14 @@ public class KeyEvent extends InputEvent this.max = max; this.inclKeyChar = inclKeyChar; } - }; - /** Non printable key ranges, currently fixed to an aray of size 4. */ - public final static NonPrintableRange[] nonPrintableKeys = { new NonPrintableRange( (short)0x0000, (short)0x001F, true ), - new NonPrintableRange( (short)0x0061, (short)0x0078, false), - new NonPrintableRange( (short)0x007F, (short)0x009F, true ), - new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) }; + }; + /** Non printable key ranges, currently fixed to an array of size 4. */ + public final static NonPrintableRange[] nonPrintableKeys = { + new NonPrintableRange( (short)0x0000, (short)0x001F, true ), // Unicode: Non printable controls: [0x00 - 0x1F] + new NonPrintableRange( (short)0x0061, (short)0x0078, false), // Small 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym - Re-used for Fn (collision) + new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable! + new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) + }; // // Unicode: Non printable controls: [0x00 - 0x1F] @@ -657,7 +658,7 @@ public class KeyEvent extends InputEvent /** Constant for the "`" key */ public static final short VK_BACK_QUOTE = (short) 0x60; - /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ + /** Small UTF/ASCII 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym. */ /** * Constant for the Fn function keys. @@ -754,9 +755,11 @@ public class KeyEvent extends InputEvent // // Unicode: Non printable controls: [0x7F - 0x9F] // + // Numpad keys [0x7F - 0x8E] are printable + // - /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ - public static final short VK_DELETE = (short) 0x7F; + /** Numeric keypad decimal separator key. Non printable UTF control. */ + public static final short VK_SEPARATOR = (short) 0x7F; /** Numeric keypad VK_NUMPAD0 thru VK_NUMPAD9 are mapped to UTF control (0x80 - 0x89). Non printable UTF control. */ public static final short VK_NUMPAD0 = (short) 0x80; @@ -782,49 +785,37 @@ public class KeyEvent extends InputEvent /** Numeric keypad decimal separator key. Non printable UTF control. */ public static final short VK_DECIMAL = (short) 0x8A; - /** Numeric keypad decimal separator key. Non printable UTF control. */ - public static final short VK_SEPARATOR = (short) 0x8B; - /** Numeric keypad add key. Non printable UTF control. */ - public static final short VK_ADD = (short) 0x8C; + public static final short VK_ADD = (short) 0x8B; /** Numeric keypad subtract key. Non printable UTF control. */ - public static final short VK_SUBTRACT = (short) 0x8D; + public static final short VK_SUBTRACT = (short) 0x8C; /** Numeric keypad multiply key. Non printable UTF control. */ - public static final short VK_MULTIPLY = (short) 0x8E; + public static final short VK_MULTIPLY = (short) 0x8D; /** Numeric keypad divide key. Non printable UTF control. */ - public static final short VK_DIVIDE = (short) 0x8F; + public static final short VK_DIVIDE = (short) 0x8E; - /** Numeric keypad num lock key. Non printable UTF control. */ - public static final short VK_NUM_LOCK = (short) 0x90; + /** Constant for the DEL key, matching ASCII. Non printable UTF control. */ + public static final short VK_DELETE = (short) 0x93; - /** Numeric keypad left arrow key, for cursor pad see {@link #VK_LEFT}. Non printable UTF control. */ - public static final short VK_KP_LEFT = (short) 0x91; - - /** Numeric keypad up arrow key, for cursor pad see {@link #VK_UP}. Non printable UTF control. */ - public static final short VK_KP_UP = (short) 0x92; - - /** Constant for the numeric keypad right arrow key, for cursor pad see {@link #VK_RIGHT}. Non printable UTF control. */ - public static final short VK_KP_RIGHT = (short) 0x93; + /** Numeric keypad num lock key. Non printable UTF control. */ + public static final short VK_NUM_LOCK = (short) 0x94; - /** Numeric keypad down arrow key, for cursor pad see {@link #VK_DOWN}. Non printable UTF control. */ - public static final short VK_KP_DOWN = (short) 0x94; - - /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_LEFT}*/ + /** Constant for the cursor- or numerical-pad left arrow key. Non printable UTF control. */ public static final short VK_LEFT = (short) 0x95; - /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_UP}.*/ + /** Constant for the cursor- or numerical-pad up arrow key. Non printable UTF control. */ public static final short VK_UP = (short) 0x96; - /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_RIGHT}.*/ + /** Constant for the cursor- or numerical-pad right arrow key. Non printable UTF control. */ public static final short VK_RIGHT = (short) 0x97; - /** Constant for the cursor-pad left arrow key, for numerical pad see {@link #VK_KP_DOWN}.*/ + /** Constant for the cursor- or numerical pad down arrow key. Non printable UTF control. */ public static final short VK_DOWN = (short) 0x98; - /** Constant for the Context Menu key. */ + /** Constant for the Context Menu key. Non printable UTF control. */ public static final short VK_CONTEXT_MENU = (short) 0x99; /** diff --git a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java index ccbdc07bf..a1aa69e0a 100644 --- a/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/awt/event/AWTNewtEventFactory.java @@ -369,13 +369,13 @@ public class AWTNewtEventFactory { case java.awt.event.KeyEvent.VK_MULTIPLY : return com.jogamp.newt.event.KeyEvent.VK_MULTIPLY; case java.awt.event.KeyEvent.VK_DIVIDE : return com.jogamp.newt.event.KeyEvent.VK_DIVIDE; case java.awt.event.KeyEvent.VK_NUM_LOCK : return com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK; - case java.awt.event.KeyEvent.VK_KP_LEFT : return com.jogamp.newt.event.KeyEvent.VK_KP_LEFT; - case java.awt.event.KeyEvent.VK_KP_UP : return com.jogamp.newt.event.KeyEvent.VK_KP_UP; - case java.awt.event.KeyEvent.VK_KP_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT; - case java.awt.event.KeyEvent.VK_KP_DOWN : return com.jogamp.newt.event.KeyEvent.VK_KP_DOWN; + case java.awt.event.KeyEvent.VK_KP_LEFT : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_LEFT : return com.jogamp.newt.event.KeyEvent.VK_LEFT; + case java.awt.event.KeyEvent.VK_KP_UP : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_UP : return com.jogamp.newt.event.KeyEvent.VK_UP; + case java.awt.event.KeyEvent.VK_KP_RIGHT : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_RIGHT : return com.jogamp.newt.event.KeyEvent.VK_RIGHT; + case java.awt.event.KeyEvent.VK_KP_DOWN : /** Fall through intended .. */ case java.awt.event.KeyEvent.VK_DOWN : return com.jogamp.newt.event.KeyEvent.VK_DOWN; case java.awt.event.KeyEvent.VK_CONTEXT_MENU : return com.jogamp.newt.event.KeyEvent.VK_CONTEXT_MENU; case java.awt.event.KeyEvent.VK_WINDOWS : return com.jogamp.newt.event.KeyEvent.VK_WINDOWS; @@ -550,10 +550,6 @@ public class AWTNewtEventFactory { case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return java.awt.event.KeyEvent.VK_MULTIPLY; case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return java.awt.event.KeyEvent.VK_DIVIDE; case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return java.awt.event.KeyEvent.VK_NUM_LOCK; - case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT : return java.awt.event.KeyEvent.VK_KP_LEFT; - case com.jogamp.newt.event.KeyEvent.VK_KP_UP : return java.awt.event.KeyEvent.VK_KP_UP; - case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT : return java.awt.event.KeyEvent.VK_KP_RIGHT; - case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN : return java.awt.event.KeyEvent.VK_KP_DOWN; case com.jogamp.newt.event.KeyEvent.VK_LEFT : return java.awt.event.KeyEvent.VK_LEFT; case com.jogamp.newt.event.KeyEvent.VK_UP : return java.awt.event.KeyEvent.VK_UP; case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return java.awt.event.KeyEvent.VK_RIGHT; diff --git a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java index 5e240636d..24a5c41de 100644 --- a/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/swt/event/SWTNewtEventFactory.java @@ -189,13 +189,9 @@ public class SWTNewtEventFactory { case com.jogamp.newt.event.KeyEvent.VK_MULTIPLY : return SWT.KEYPAD_MULTIPLY; case com.jogamp.newt.event.KeyEvent.VK_DIVIDE : return SWT.KEYPAD_DIVIDE; case com.jogamp.newt.event.KeyEvent.VK_NUM_LOCK : return SWT.NUM_LOCK; - case com.jogamp.newt.event.KeyEvent.VK_KP_LEFT : case com.jogamp.newt.event.KeyEvent.VK_LEFT : return SWT.ARROW_LEFT; - case com.jogamp.newt.event.KeyEvent.VK_KP_UP : case com.jogamp.newt.event.KeyEvent.VK_UP : return SWT.ARROW_UP; - case com.jogamp.newt.event.KeyEvent.VK_KP_RIGHT : case com.jogamp.newt.event.KeyEvent.VK_RIGHT : return SWT.ARROW_RIGHT; - case com.jogamp.newt.event.KeyEvent.VK_KP_DOWN : case com.jogamp.newt.event.KeyEvent.VK_DOWN : return SWT.ARROW_DOWN; case com.jogamp.newt.event.KeyEvent.VK_HELP : return SWT.HELP; } diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h index 7a63b19ce..a182db973 100644 --- a/src/newt/native/KeyEvent.h +++ b/src/newt/native/KeyEvent.h @@ -161,7 +161,7 @@ // Unicode: Non printable controls: [0x7F - 0x9F] // -#define J_VK_DELETE ( 0x7FU ) +#define J_VK_SEPARATOR ( 0x7FU ) #define J_VK_NUMPAD0 ( 0x80U ) #define J_VK_NUMPAD1 ( 0x81U ) #define J_VK_NUMPAD2 ( 0x82U ) @@ -173,16 +173,13 @@ #define J_VK_NUMPAD8 ( 0x88U ) #define J_VK_NUMPAD9 ( 0x89U ) #define J_VK_DECIMAL ( 0x8AU ) -#define J_VK_SEPARATOR ( 0x8BU ) -#define J_VK_ADD ( 0x8CU ) -#define J_VK_SUBTRACT ( 0x8DU ) -#define J_VK_MULTIPLY ( 0x8EU ) -#define J_VK_DIVIDE ( 0x8FU ) -#define J_VK_NUM_LOCK ( 0x90U ) -#define J_VK_KP_LEFT ( 0x91U ) -#define J_VK_KP_UP ( 0x92U ) -#define J_VK_KP_RIGHT ( 0x93U ) -#define J_VK_KP_DOWN ( 0x94U ) +#define J_VK_ADD ( 0x8BU ) +#define J_VK_SUBTRACT ( 0x8CU ) +#define J_VK_MULTIPLY ( 0x8DU ) +#define J_VK_DIVIDE ( 0x8EU ) + +#define J_VK_DELETE ( 0x93U ) +#define J_VK_NUM_LOCK ( 0x94U ) #define J_VK_LEFT ( 0x95U ) #define J_VK_UP ( 0x96U ) #define J_VK_RIGHT ( 0x97U ) @@ -195,7 +192,6 @@ #define J_VK_BEGIN ( 0x9EU ) #define J_VK_STOP ( 0x9FU ) - // // Unicode: Printable [0x00A0 - 0xDFFF] // diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 7ede3a20d..ac0ebf07e 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -219,6 +219,7 @@ static KeyMapEntry keyMapTable[] = { {J_VK_INSERT, VK_INSERT, 0}, {J_VK_DELETE, VK_DELETE, 0}, {J_VK_HOME, VK_HOME, 0}, + // {J_VK_BEGIN, VK_BEGIN, 0}, // not mapped {J_VK_END, VK_END, 0}, {J_VK_PAGE_UP, VK_PRIOR, 0}, {J_VK_PAGE_DOWN, VK_NEXT, 0}, @@ -332,6 +333,8 @@ static KeyMapEntry keyMapTable[] = { #define MAPVK_VK_TO_VSC_EX 4 #endif +#define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b)) + static HKL kbdLayoutUS = 0; static const LPCSTR US_LAYOUT_NAME = "00000409"; @@ -398,23 +401,6 @@ static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags, kbdState[VK_SPACE] &= ~0x80; } - // Assume extended scan code 0xE0 if extended flags is set (no 0xE1 from WM_KEYUP/WM_KEYDOWN) - USHORT winScanCodeExt = winScanCode; - if( 0 != ( 0x01 & flags ) ) { - winScanCodeExt |= 0xE000; - } - - // - // winVKey, winScanCodeExt -> javaVKeyUS w/ US KeyboardLayout - // - for (i = 0; keyMapTable[i].windowsKey != 0; i++) { - if ( keyMapTable[i].windowsScanCodeUS == winScanCodeExt ) { - javaVKeyUS = keyMapTable[i].javaKey; - winVKeyUS = keyMapTable[i].windowsKey; - break; - } - } - // // winVKey -> javaVKeyXX // @@ -424,6 +410,28 @@ static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags, break; } } + if( IS_WITHIN( winVKey, VK_NUMPAD0, VK_DIVIDE ) ) { + // Use modded keySym for keypad for US and NN + winVKeyUS = winVKey; + javaVKeyUS = javaVKeyXX; + } else { + // Assume extended scan code 0xE0 if extended flags is set (no 0xE1 from WM_KEYUP/WM_KEYDOWN) + USHORT winScanCodeExt = winScanCode; + if( 0 != ( 0x01 & flags ) ) { + winScanCodeExt |= 0xE000; + } + + // + // winVKey, winScanCodeExt -> javaVKeyUS w/ US KeyboardLayout + // + for (i = 0; keyMapTable[i].windowsKey != 0; i++) { + if ( keyMapTable[i].windowsScanCodeUS == winScanCodeExt ) { + winVKeyUS = keyMapTable[i].windowsKey; + javaVKeyUS = keyMapTable[i].javaKey; + break; + } + } + } *outJavaVKeyUS = javaVKeyUS; *outJavaVKeyXX = javaVKeyXX; diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 56b7251d2..e2392a113 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -58,6 +58,10 @@ static jmethodID requestFocusID = NULL; #define IS_WITHIN(k,a,b) ((a)<=(k)&&(k)<=(b)) +/** + * QT Reference: + * + */ static short X11KeySym2NewtVKey(KeySym keySym) { if( IS_WITHIN( keySym, XK_a, XK_z ) ) { return ( keySym - XK_a ) + J_VK_A ; @@ -84,8 +88,6 @@ static short X11KeySym2NewtVKey(KeySym keySym) { return J_VK_TAB; case XK_Cancel: return J_VK_CANCEL; - case XK_Clear: - return J_VK_CLEAR; case XK_Shift_L: case XK_Shift_R: return J_VK_SHIFT; @@ -95,6 +97,7 @@ static short X11KeySym2NewtVKey(KeySym keySym) { case XK_Alt_L: return J_VK_ALT; case XK_Alt_R: + case XK_ISO_Level3_Shift: return J_VK_ALT_GRAPH; case XK_Super_L: case XK_Super_R: @@ -119,6 +122,10 @@ static short X11KeySym2NewtVKey(KeySym keySym) { case XK_End: case XK_KP_End: return J_VK_END; + case XK_Begin: + return J_VK_BEGIN; + case XK_KP_Begin: // NumPad 5 - equal behavior w/ QT/Windows + return J_VK_CLEAR; case XK_Home: case XK_KP_Home: return J_VK_HOME; @@ -146,6 +153,7 @@ static short X11KeySym2NewtVKey(KeySym keySym) { return J_VK_DECIMAL; case XK_KP_Divide: return J_VK_DIVIDE; + case XK_Clear: // equal behavior w/ QT case XK_Delete: case XK_KP_Delete: return J_VK_DELETE; @@ -450,7 +458,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage keyString = (*env)->NewStringUTF(env, text); } - if( 0 == keyChar ) { + #ifdef DEBUG_KEYS + fprintf(stderr, "NEWT X11 Key.0: keyCode 0x%X keySym 0x%X, (shifted: 0x%X)\n", + (int)keyCode, (int)keySym, (int) shiftedKeySym); + #endif + if( IS_WITHIN( shiftedKeySym, XK_KP_Space, XK_KP_9 ) ) { + // Use modded keySym for keypad for US and NN + keySym = shiftedKeySym; + unShiftedKeySym = shiftedKeySym; + } else if( 0 == keyChar ) { // Use keyCode's keySym for dead-key (aka modifiers, etc) unShiftedKeySym = keySym; } else if( 0 == ( evt.xkey.state & ShiftCtrlModMask ) ) { @@ -467,7 +483,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage modifiers |= X11InputState2NewtModifiers(xkey_state, javaVKeyNN, evt.type == KeyPress) | autoRepeatModifiers; #ifdef DEBUG_KEYS - fprintf(stderr, "NEWT X11 Key: keyCode 0x%X keySym 0x%X, (0x%X, shifted: 0x%X), keyChar '%c' 0x%X %d, javaVKey[US 0x%X, NN 0x%X], xstate 0x%X %u, jmods 0x%X\n", + fprintf(stderr, "NEWT X11 Key.X: keyCode 0x%X keySym 0x%X, (0x%X, shifted: 0x%X), keyChar '%c' 0x%X %d, javaVKey[US 0x%X, NN 0x%X], xstate 0x%X %u, jmods 0x%X\n", (int)keyCode, (int)keySym, (int) unShiftedKeySym, (int)shiftedKeySym, keyChar, keyChar, charCount, (int)javaVKeyUS, (int)javaVKeyNN, (int)xkey_state, (int)xkey_state, (int)modifiers); -- cgit v1.2.3 From 33abeb8097a8f80acd1a4ce94b4866e5dc41f0c0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 17 May 2013 04:52:32 +0200 Subject: Fix Bug 737: Add shader default precision for GLSL [1.30 .. 1.50[ - See GLSL Spec [1.30 - 1.40]. --- make/scripts/tests.sh | 7 +- .../com/jogamp/opengl/util/glsl/ShaderCode.java | 120 +++++++++++++++++++-- src/jogl/classes/javax/media/opengl/GLContext.java | 34 +++--- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 4 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 4 +- .../jogamp/opengl/util/glsl/GLSLTextureRaster.java | 4 +- .../util/glsl/fixedfunc/FixedFuncPipeline.java | 4 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 4 +- .../test/junit/jogl/demos/es2/PointsDemoES2.java | 4 +- .../test/junit/jogl/demos/es2/RedSquareES2.java | 4 +- .../jogl/demos/es2/TextureDraw01ES2Listener.java | 4 +- .../junit/jogl/demos/es2/awt/TestGearsES2AWT.java | 26 +++++ .../demos/es2/awt/TestGearsES2GLJPanelAWT.java | 116 +++++++++++++++++--- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 16 ++- .../jogl/demos/gl3/GeomShader01TextureGL3.java | 6 +- .../junit/jogl/glsl/TestGLSLShaderState01NEWT.java | 8 +- .../junit/jogl/glsl/TestGLSLShaderState02NEWT.java | 6 +- .../test/junit/jogl/glsl/TestRulerNEWT01.java | 4 +- 18 files changed, 304 insertions(+), 71 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4ced71d3d..71cf57565 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -88,6 +88,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" + D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" @@ -174,7 +175,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -281,10 +282,10 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 1e552c17f..80a7efaec 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -54,6 +54,7 @@ import jogamp.opengl.Debug; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; +import com.jogamp.common.util.VersionNumber; /** * Convenient shader code class to use and instantiate vertex or fragment programs. @@ -716,6 +717,7 @@ public class ShaderCode { return -1; } + @SuppressWarnings("resource") private static int readShaderSource(Class context, URLConnection conn, StringBuilder result, int lineno) throws IOException { if(DEBUG_CODE) { if(0 == lineno) { @@ -823,11 +825,74 @@ public class ShaderCode { } // Shall we use: #ifdef GL_FRAGMENT_PRECISION_HIGH .. #endif for using highp in fragment shader if avail ? - /** {@value #es2_default_precision_vp} */ + /** Default precision of {@link GL#isGLES2() ES2} for {@link GL2ES2#GL_VERTEX_SHADER vertex-shader}: {@value #es2_default_precision_vp} */ public static final String es2_default_precision_vp = "\nprecision highp float;\nprecision highp int;\n"; - /** {@value #es2_default_precision_fp} */ + /** Default precision of {@link GL#isGLES2() ES2} for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #es2_default_precision_fp} */ public static final String es2_default_precision_fp = "\nprecision mediump float;\nprecision mediump int;\n/*precision lowp sampler2D;*/\n"; + /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_VERTEX_SHADER vertex-shader} or {@link GL3#GL_GEOMETRY_SHADER geometry-shader}: {@value #gl3_default_precision_vp_gp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ + public static final String gl3_default_precision_vp_gp = "\nprecision highp float;\nprecision highp int;\n"; + /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #gl3_default_precision_fp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ + public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n"; + + /** + * Add GLSL version at the head of this shader source code. + *

    + * Note: The shader source to be edit must be created using a mutable StringBuilder. + *

    + * @param gl a GL context, which must have been made current once + * @return the index after the inserted data, maybe 0 if nothing has be inserted. + */ + public final int addGLSLVersion(GL2ES2 gl) { + return insertShaderSource(0, 0, gl.getContext().getGLSLVersionString()); + } + + /** + * Adds default precision to source code at given position if required, i.e. + * {@link #es2_default_precision_vp}, {@link #es2_default_precision_fp}, + * {@link #gl3_default_precision_vp_gp}, {@link #gl3_default_precision_fp} or none, + * depending on the {@link GLContext#getGLSLVersionNumber() GLSL version} being used. + *

    + * Note: The shader source to be edit must be created using a mutable StringBuilder. + *

    + * @param gl a GL context, which must have been made current once + * @param pos position within this mutable shader source. + * @return the index after the inserted data, maybe 0 if nothing has be inserted. + */ + public final int addDefaultShaderPrecision(GL2ES2 gl, int pos) { + final VersionNumber glslVersion = gl.getContext().getGLSLVersionNumber(); + final String defaultPrecision; + if( gl.isGLES2() ) { + switch ( shaderType ) { + case GL2ES2.GL_VERTEX_SHADER: + defaultPrecision = es2_default_precision_vp; break; + case GL2ES2.GL_FRAGMENT_SHADER: + defaultPrecision = es2_default_precision_vp; break; + default: + defaultPrecision = null; + break; + } + } else if( glslVersion.compareTo(GLContext.Version130) >= 0 && glslVersion.compareTo(GLContext.Version150) < 0 ) { + // GLSL [ 1.30 .. 1.50 [ needs at least fragement float default precision! + switch ( shaderType ) { + case GL2ES2.GL_VERTEX_SHADER: + case GL3.GL_GEOMETRY_SHADER: + defaultPrecision = gl3_default_precision_vp_gp; break; + case GL2ES2.GL_FRAGMENT_SHADER: + defaultPrecision = gl3_default_precision_fp; break; + default: + defaultPrecision = null; + break; + } + } else { + defaultPrecision = null; + } + if( null != defaultPrecision ) { + pos = insertShaderSource(0, pos, defaultPrecision); + } + return pos; + } + /** * Default customization of this shader source code. *

    @@ -835,18 +900,51 @@ public class ShaderCode { *

    * @param gl a GL context, which must have been made current once * @param preludeVersion if true {@link GLContext#getGLSLVersionString()} is preluded, otherwise not. - * @param es2DefaultPrecision optional default precision source code line(s) preluded if not null and if {@link GL#isGLES()}. + * @param addDefaultPrecision if true default precision source code line(s) are added, i.e. + * {@link #es2_default_precision_vp}, {@link #es2_default_precision_fp}, + * {@link #gl3_default_precision_vp_gp}, {@link #gl3_default_precision_fp} or none, + * depending on the {@link GLContext#getGLSLVersionNumber() GLSL version} being used. + * @return the index after the inserted data, maybe 0 if nothing has be inserted. + * @see #addGLSLVersion(GL2ES2) + * @see #addDefaultShaderPrecision(GL2ES2, int) + */ + public final int defaultShaderCustomization(GL2ES2 gl, boolean preludeVersion, boolean addDefaultPrecision) { + int pos; + if( preludeVersion ) { + pos = addGLSLVersion(gl); + } else { + pos = 0; + } + if( addDefaultPrecision ) { + pos = addDefaultShaderPrecision(gl, pos); + } + return pos; + } + + /** + * Default customization of this shader source code. + *

    + * Note: The shader source to be edit must be created using a mutable StringBuilder. + *

    + * @param gl a GL context, which must have been made current once + * @param preludeVersion if true {@link GLContext#getGLSLVersionString()} is preluded, otherwise not. + * @param esDefaultPrecision optional default precision source code line(s) preluded if not null and if {@link GL#isGLES()}. * You may use {@link #es2_default_precision_fp} for fragment shader and {@link #es2_default_precision_vp} for vertex shader. * @return the index after the inserted data, maybe 0 if nothing has be inserted. + * @see #addGLSLVersion(GL2ES2) + * @see #addDefaultShaderPrecision(GL2ES2, int) */ - public final int defaultShaderCustomization(GL2ES2 gl, boolean preludeVersion, String es2DefaultPrecision) { - int pos = 0; - if(preludeVersion) { - final String glslVersion_prelude = gl.getContext().getGLSLVersionString(); - pos = insertShaderSource(0, pos, glslVersion_prelude); - } - if( gl.isGLES() && null != es2DefaultPrecision ) { - pos = insertShaderSource(0, pos, es2DefaultPrecision); + public final int defaultShaderCustomization(GL2ES2 gl, boolean preludeVersion, String esDefaultPrecision) { + int pos; + if( preludeVersion ) { + pos = addGLSLVersion(gl); + } else { + pos = 0; + } + if( gl.isGLES2() && null != esDefaultPrecision ) { + pos = insertShaderSource(0, pos, esDefaultPrecision); + } else { + pos = addDefaultShaderPrecision(gl, pos); } return pos; } diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index bbe8d602b..ab966a70d 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -118,6 +118,19 @@ public abstract class GLContext { /** Indicates that a newly-created context was made current during the last call to {@link #makeCurrent makeCurrent}. */ public static final int CONTEXT_CURRENT_NEW = 2; + /* Version 1.00, i.e. GLSL 1.00 for ES 2.0. */ + public static final VersionNumber Version100 = new VersionNumber(1, 0, 0); + /* Version 1.10, i.e. GLSL 1.10 for GL 2.0. */ + public static final VersionNumber Version110 = new VersionNumber(1, 10, 0); + /* Version 1.20, i.e. GLSL 1.20 for GL 2.1. */ + public static final VersionNumber Version120 = new VersionNumber(1, 20, 0); + /* Version 1.30, i.e. GLSL 1.30 for GL 3.0. */ + public static final VersionNumber Version130 = new VersionNumber(1, 30, 0); + /* Version 1.40, i.e. GLSL 1.40 for GL 3.1. */ + public static final VersionNumber Version140 = new VersionNumber(1, 40, 0); + /* Version 1.50, i.e. GLSL 1.50 for GL 3.2. */ + public static final VersionNumber Version150 = new VersionNumber(1, 50, 0); + /** Version 3.2. As an OpenGL version, it qualifies for geometry shader */ public static final VersionNumber Version32 = new VersionNumber(3, 2, 0); @@ -733,27 +746,24 @@ public abstract class GLContext { return "#version " + ctxGLSLVersion.getMajor() + ( minor < 10 ? "0"+minor : minor ) + "\n" ; } - protected static final void getStaticGLSLVersionNumber(int glMajorVersion, int glMinorVersion, int ctxOptions, int[] res) { + protected static final VersionNumber getStaticGLSLVersionNumber(int glMajorVersion, int glMinorVersion, int ctxOptions) { if( 0 != ( CTX_PROFILE_ES & ctxOptions ) ) { - res[0] = 1; res[1] = 0; // ES 2.0 -> GLSL 1.00 + return Version100; // ES 2.0 -> GLSL 1.00 } else if( 1 == glMajorVersion ) { - res[0] = 1; res[1] = 10; // GL 1.x -> GLSL 1.10 + return Version110; // GL 1.x -> GLSL 1.10 } else if( 2 == glMajorVersion ) { - res[0] = 1; switch ( glMinorVersion ) { - case 0: res[1] = 10; break; // GL 2.0 -> GLSL 1.10 - default: res[1] = 20; break; // GL 2.1 -> GLSL 1.20 + case 0: return Version110; // GL 2.0 -> GLSL 1.10 + default: return Version120; // GL 2.1 -> GLSL 1.20 } } else if( 3 == glMajorVersion && 2 >= glMinorVersion ) { - res[0] = 1; switch ( glMinorVersion ) { - case 0: res[1] = 30; break; // GL 3.0 -> GLSL 1.30 - case 1: res[1] = 40; break; // GL 3.1 -> GLSL 1.40 - default: res[1] = 50; break; // GL 3.2 -> GLSL 1.50 + case 0: return Version130; // GL 3.0 -> GLSL 1.30 + case 1: return Version140; // GL 3.1 -> GLSL 1.40 + default: return Version150; // GL 3.2 -> GLSL 1.50 } } else { // >= 3.3 - res[0] = glMajorVersion; // GL M.N -> GLSL M.N - res[1] = glMinorVersion * 10; + return new VersionNumber(glMajorVersion, glMinorVersion * 10, 0); // GL M.N -> GLSL M.N } } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index f16834d28..8c9c12e21 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1056,9 +1056,7 @@ public abstract class GLContextImpl extends GLContext { } } if( ctxGLSLVersion.isZero() ) { - final int[] sver = new int[2]; - getStaticGLSLVersionNumber(major, minor, ctxOptions, sver); - ctxGLSLVersion = new VersionNumber(sver[0], sver[1], 0); + ctxGLSLVersion = getStaticGLSLVersionNumber(major, minor, ctxOptions); } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 666cd30af..b90609ff1 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -149,8 +149,8 @@ public class MacOSXCGLContext extends GLContextImpl "../../shader", "../../shader/bin", shaderBasename, true); final ShaderCode fp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, MacOSXCGLContext.class, "../../shader", "../../shader/bin", shaderBasename, true); - vp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); - fp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); + vp.defaultShaderCustomization(gl, true, true); + fp.defaultShaderCustomization(gl, true, true); sp.add(vp); sp.add(fp); if(!sp.link(gl, System.err)) { diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java index 20c251635..eaf8dc30a 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/GLSLTextureRaster.java @@ -69,8 +69,8 @@ public class GLSLTextureRaster { shaderSrcPath, shaderBinPath, shaderBasename, true); final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), shaderSrcPath, shaderBinPath, shaderBasename, true); - rsVp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); - rsFp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); + rsVp.defaultShaderCustomization(gl, true, true); + rsFp.defaultShaderCustomization(gl, true, true); // Create & Link the shader program sp = new ShaderProgram(); diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java index cc58f2363..f4f20ac7c 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -943,8 +943,8 @@ public class FixedFuncPipeline { private static final String constMaxTextures8 = "#define MAX_TEXTURE_UNITS 8\n"; private final void customizeShader(GL2ES2 gl, ShaderCode vp, ShaderCode fp, String maxTextureDefine) { - int rsVpPos = vp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); - int rsFpPos = fp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); + int rsVpPos = vp.defaultShaderCustomization(gl, true, true); + int rsFpPos = fp.defaultShaderCustomization(gl, true, true); vp.insertShaderSource(0, rsVpPos, maxTextureDefine); fp.insertShaderSource(0, rsFpPos, maxTextureDefine); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index f21e767fa..66a8082a6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -148,8 +148,8 @@ public class GearsES2 implements GLEventListener { "shader/bin", "gears", true); final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", "shader/bin", "gears", true); - vp0.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); - fp0.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); + vp0.defaultShaderCustomization(gl, true, true); + fp0.defaultShaderCustomization(gl, true, true); final ShaderProgram sp0 = new ShaderProgram(); sp0.add(gl, vp0, System.err); sp0.add(gl, fp0, System.err); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java index 43b919e78..52af4916c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/PointsDemoES2.java @@ -94,8 +94,8 @@ public class PointsDemoES2 extends PointsDemo { "shader/bin", "PointsShader", true); final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", "shader/bin", "PointsShader", true); - vp0.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); - fp0.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); + vp0.defaultShaderCustomization(gl, true, true); + fp0.defaultShaderCustomization(gl, true, true); final ShaderProgram sp0 = new ShaderProgram(); sp0.add(gl, vp0, System.err); sp0.add(gl, fp0, System.err); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 688653471..3f092e341 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -84,8 +84,8 @@ public class RedSquareES2 implements GLEventListener { "shader/bin", "RedSquareShader", true); final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", "shader/bin", "RedSquareShader", true); - vp0.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); - fp0.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); + vp0.defaultShaderCustomization(gl, true, true); + fp0.defaultShaderCustomization(gl, true, true); final ShaderProgram sp0 = new ShaderProgram(); sp0.add(gl, vp0, System.err); sp0.add(gl, fp0, System.err); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java index 4bcb073dc..622df8695 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java @@ -70,8 +70,8 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A "shader", "shader/bin", shaderBasename, true); ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", "shader/bin", shaderBasename, true); - rsVp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_vp); - rsFp.defaultShaderCustomization(gl, true, ShaderCode.es2_default_precision_fp); + rsVp.defaultShaderCustomization(gl, true, true); + rsFp.defaultShaderCustomization(gl, true, true); // Create & Link the shader program ShaderProgram sp = new ShaderProgram(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java index a51df5088..a63f2590a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/TestGearsES2AWT.java @@ -75,6 +75,7 @@ public class TestGearsES2AWT extends UITestCase { static boolean forceES2 = false; static boolean forceGL3 = false; + static boolean mainRun = false; static boolean shallUseOffscreenFBOLayer = false; static boolean shallUseOffscreenPBufferLayer = false; static boolean useMSAA = false; @@ -310,10 +311,35 @@ public class TestGearsES2AWT extends UITestCase { runTestGL(caps, resizeBy, frameLayout); } + @Test + public void test02_GLES2() throws InterruptedException, InvocationTargetException { + if(mainRun) return; + + if( !GLProfile.isAvailable(GLProfile.GLES2) ) { + System.err.println("GLES2 n/a"); + } + final GLProfile glp = GLProfile.get(GLProfile.GLES2); + final GLCapabilities caps = new GLCapabilities( glp ); + runTestGL(caps, resizeBy, frameLayout); + } + + @Test + public void test03_GL3() throws InterruptedException, InvocationTargetException { + if(mainRun) return; + + if( !GLProfile.isAvailable(GLProfile.GL3) ) { + System.err.println("GL3 n/a"); + } + final GLProfile glp = GLProfile.get(GLProfile.GL3); + final GLCapabilities caps = new GLCapabilities( glp ); + runTestGL(caps, resizeBy, frameLayout); + } + public static void main(String args[]) { boolean waitForKey = false; int rw=-1, rh=-1; + mainRun = true; for(int i=0; i Date: Fri, 17 May 2013 07:55:59 +0200 Subject: Fix Bug 711: Align Graphs's Curve Shader programmatically to used GL/GLSL version, following all other internal GLSL usage utilizing ShaderCode. --- make/scripts/tests.sh | 4 +- .../com/jogamp/graph/curve/opengl/Renderer.java | 35 +++++--- .../com/jogamp/opengl/util/glsl/ShaderCode.java | 28 ++++++- .../graph/curve/opengl/RegionRendererImpl01.java | 29 ++++--- .../graph/curve/opengl/TextRendererImpl01.java | 20 +++-- .../graph/curve/opengl/shader/attributes.glsl | 4 + .../opengl/shader/curverenderer01-1pass-weight.fp | 54 ++++++++++++ .../curve/opengl/shader/curverenderer01-1pass.fp | 48 +++++++++++ .../opengl/shader/curverenderer01-2pass-weight.fp | 95 ++++++++++++++++++++++ .../curve/opengl/shader/curverenderer01-2pass.fp | 89 ++++++++++++++++++++ .../opengl/shader/curverenderer01-es2-merged.vp | 19 ----- .../curve/opengl/shader/curverenderer01-es2.vp | 9 -- .../curve/opengl/shader/curverenderer01-gl2.vp | 6 -- .../curve/opengl/shader/curverenderer01-xxx.vp | 12 --- .../graph/curve/opengl/shader/curverenderer01.vp | 12 +++ .../opengl/shader/curverenderer01a-es2-merged.fp | 52 ------------ .../curve/opengl/shader/curverenderer01a-es2.fp | 13 --- .../curve/opengl/shader/curverenderer01a-gl2.fp | 6 -- .../curve/opengl/shader/curverenderer01a-xxx.fp | 42 ---------- .../curve/opengl/shader/curverenderer01b-es2.fp | 14 ---- .../curve/opengl/shader/curverenderer01b-gl2.fp | 6 -- .../curve/opengl/shader/curverenderer01b-xxx.fp | 82 ------------------- .../curve/opengl/shader/curverenderer02a-es2.fp | 14 ---- .../curve/opengl/shader/curverenderer02a-gl2.fp | 6 -- .../curve/opengl/shader/curverenderer02a-xxx.fp | 48 ----------- .../curve/opengl/shader/curverenderer02b-es2.fp | 14 ---- .../curve/opengl/shader/curverenderer02b-gl2.fp | 6 -- .../curve/opengl/shader/curverenderer02b-xxx.fp | 88 -------------------- .../jogamp/graph/curve/opengl/shader/varyings.glsl | 4 + .../test/junit/graph/TestTextRendererNEWT10.java | 19 ++++- 30 files changed, 403 insertions(+), 475 deletions(-) create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp create mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp delete mode 100644 src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 71cf57565..3f51411f2 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -282,7 +282,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -548,7 +548,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT # # Graph # -#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* +testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java index fcccf592e..998129551 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java @@ -33,6 +33,7 @@ import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; import javax.media.opengl.fixedfunc.GLMatrixFunc; +import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderState; import com.jogamp.opengl.util.PMVMatrix; @@ -263,21 +264,31 @@ public abstract class Renderer { return true; } - protected String getVertexShaderName(GL2ES2 gl) { - return "curverenderer01" + getShaderGLVersionSuffix(gl); + protected String getVertexShaderName() { + return "curverenderer" + getImplVersion(); } - protected String getFragmentShaderName(GL2ES2 gl) { - final String type = "01" ; // Region.isNonUniformWeight(renderModes) ? "02" : "01" ; - final String pass = Region.isVBAA(renderModes) ? "b" : "a" ; - return "curverenderer" + type + pass + getShaderGLVersionSuffix(gl); + protected String getFragmentShaderName() { + final String version = getImplVersion(); + final String pass = Region.isVBAA(renderModes) ? "-2pass" : "-1pass" ; + final String weight = Region.isNonUniformWeight(renderModes) ? "-weight" : "" ; + return "curverenderer" + version + pass + weight; } - - protected String getShaderGLVersionSuffix(GL2ES2 gl) { - if(gl.isGLES2()) { - return "-es2"; + + // FIXME: Really required to have sampler2D def. precision ? If not, we can drop getFragmentShaderPrecision(..) and use default ShaderCode .. + public static final String es2_precision_fp = "\nprecision mediump float;\nprecision mediump int;\nprecision mediump sampler2D;\n"; + + protected String getFragmentShaderPrecision(GL2ES2 gl) { + if( gl.isGLES2() ) { + return es2_precision_fp; } - return "-gl2"; - } + if( ShaderCode.requiresGL3DefaultPrecision(gl) ) { + return ShaderCode.gl3_default_precision_fp; + } + return null; + } + protected String getImplVersion() { + return "01"; + } } \ No newline at end of file diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 80a7efaec..edc3d2677 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -684,7 +684,7 @@ public class ShaderCode { * * @param shaderIdx the shader index to be used. * @param position in shader source segments of shader shaderIdx - * @param data the text to be inserted. Shall end with an EOL '\n' character. + * @param data the text to be inserted. Shall end with an EOL '\n' character * @return index after the inserted data * * @throws IllegalStateException if the shader source's CharSequence is immutable, i.e. not of type StringBuilder @@ -833,8 +833,11 @@ public class ShaderCode { /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_VERTEX_SHADER vertex-shader} or {@link GL3#GL_GEOMETRY_SHADER geometry-shader}: {@value #gl3_default_precision_vp_gp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ public static final String gl3_default_precision_vp_gp = "\nprecision highp float;\nprecision highp int;\n"; /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #gl3_default_precision_fp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ - public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n"; + public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n/*precision mediump sampler2D;*/\n"; + /** Prefer enable over require, since it won't force a failure. */ + public static final String extOESDerivativesEnable = "#extension GL_OES_standard_derivatives : enable\n"; + /** * Add GLSL version at the head of this shader source code. *

    @@ -860,7 +863,6 @@ public class ShaderCode { * @return the index after the inserted data, maybe 0 if nothing has be inserted. */ public final int addDefaultShaderPrecision(GL2ES2 gl, int pos) { - final VersionNumber glslVersion = gl.getContext().getGLSLVersionNumber(); final String defaultPrecision; if( gl.isGLES2() ) { switch ( shaderType ) { @@ -872,7 +874,7 @@ public class ShaderCode { defaultPrecision = null; break; } - } else if( glslVersion.compareTo(GLContext.Version130) >= 0 && glslVersion.compareTo(GLContext.Version150) < 0 ) { + } else if( requiresGL3DefaultPrecision(gl) ) { // GLSL [ 1.30 .. 1.50 [ needs at least fragement float default precision! switch ( shaderType ) { case GL2ES2.GL_VERTEX_SHADER: @@ -893,6 +895,24 @@ public class ShaderCode { return pos; } + /** Returns true, if GLSL version requires default precision, i.e. ES2 or GLSL [1.30 .. 1.50[. */ + public static final boolean requiresDefaultPrecision(GL2ES2 gl) { + if( gl.isGLES2() ) { + return true; + } + return requiresGL3DefaultPrecision(gl); + } + + /** Returns true, if GL3 GLSL version requires default precision, i.e. GLSL [1.30 .. 1.50[. */ + public static final boolean requiresGL3DefaultPrecision(GL2ES2 gl) { + if( gl.isGL3() ) { + final VersionNumber glslVersion = gl.getContext().getGLSLVersionNumber(); + return glslVersion.compareTo(GLContext.Version130) >= 0 && glslVersion.compareTo(GLContext.Version150) < 0 ; + } else { + return false; + } + } + /** * Default customization of this shader source code. *

    diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 2884aca2f..7f5afcd02 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -46,22 +46,25 @@ public class RegionRendererImpl01 extends RegionRenderer { } - @Override - protected String getFragmentShaderName(GL2ES2 gl) { - final String type = Region.isNonUniformWeight(renderModes) ? "02" : "01" ; - final String pass = Region.isVBAA(renderModes) ? "b" : "a" ; - return "curverenderer" + type + pass + getShaderGLVersionSuffix(gl); - } - protected boolean initShaderProgram(GL2ES2 gl) { final ShaderState st = rs.getShaderState(); - ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader", - "shader/bin", getVertexShaderName(gl), false); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RegionRendererImpl01.class, "shader", - "shader/bin", getFragmentShaderName(gl), false); - - ShaderProgram sp = new ShaderProgram(); + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RegionRendererImpl01.class, "shader", + "shader/bin", getVertexShaderName(), true); + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RegionRendererImpl01.class, "shader", + "shader/bin", getFragmentShaderName(), true); + rsVp.defaultShaderCustomization(gl, true, true); + // rsFp.defaultShaderCustomization(gl, true, true); + int pos = rsFp.addGLSLVersion(gl); + if( gl.isGLES2() ) { + pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); + } + final String rsFpDefPrecision = getFragmentShaderPrecision(gl); + if( null != rsFpDefPrecision ) { + rsFp.insertShaderSource(0, pos, rsFpDefPrecision); + } + + final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 0cf424cd2..81c421371 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -49,12 +49,22 @@ public class TextRendererImpl01 extends TextRenderer { protected boolean initShaderProgram(GL2ES2 gl){ final ShaderState st = rs.getShaderState(); - ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TextRendererImpl01.class, "shader", - "shader/bin", getVertexShaderName(gl), false); - ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TextRendererImpl01.class, "shader", - "shader/bin", getFragmentShaderName(gl), false); + final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, TextRendererImpl01.class, "shader", + "shader/bin", getVertexShaderName(), true); + final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, TextRendererImpl01.class, "shader", + "shader/bin", getFragmentShaderName(), true); + rsVp.defaultShaderCustomization(gl, true, true); + // rsFp.defaultShaderCustomization(gl, true, true); + int pos = rsFp.addGLSLVersion(gl); + if( gl.isGLES2() ) { + pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); + } + final String rsFpDefPrecision = getFragmentShaderPrecision(gl); + if( null != rsFpDefPrecision ) { + rsFp.insertShaderSource(0, pos, rsFpDefPrecision); + } - ShaderProgram sp = new ShaderProgram(); + final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); sp.add(rsFp); diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl index 108247c9c..ced118c1c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl @@ -2,6 +2,10 @@ #ifndef attributes_glsl #define attributes_glsl +#if __VERSION__ >= 130 + #define attribute in +#endif + // attribute vec3 gca_Vertices; attribute vec4 gca_Vertices; attribute vec2 gca_TexCoords; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp new file mode 100644 index 000000000..ca03e605c --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp @@ -0,0 +1,54 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 1-pass shader w/ weight +// + +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +void main (void) +{ + vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); + vec3 c = gcu_ColorStatic.rgb; + + float alpha = 0.0; + + if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { + alpha = gcu_Alpha; + } + else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { + rtex.y -= 0.1; + + if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { + // discard; // freezes NV tegra2 compiler + alpha = 0.0; + } else { + rtex.y = max(rtex.y, 0.0); + + vec2 dtx = dFdx(rtex); + vec2 dty = dFdy(rtex); + + float w = gcu_Weight; + float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0; + float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd); + + float aph = 2.0 - 2.0*w; + + float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0); + vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd)); + + // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! + float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + alpha = gcu_Alpha * a; + } + } + + mgl_FragColor = vec4(c, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp new file mode 100644 index 000000000..b978b62d1 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp @@ -0,0 +1,48 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 1-pass shader w/o weight +// + +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +void main (void) +{ + vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); + vec3 c = gcu_ColorStatic.rgb; + + float alpha = 0.0; + + if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { + alpha = gcu_Alpha; + } + else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { + rtex.y -= 0.1; + + if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { + // discard; // freezes NV tegra2 compiler + alpha = 0.0; + } else { + rtex.y = max(rtex.y, 0.0); + + vec2 dtx = dFdx(rtex); + vec2 dty = dFdy(rtex); + + vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); + float position = rtex.y - (rtex.x * (1.0 - rtex.x)); + + // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! + float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + alpha = gcu_Alpha * a; + } + } + + mgl_FragColor = vec4(c, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp new file mode 100644 index 000000000..9440f314c --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp @@ -0,0 +1,95 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 2-pass shader w/ weight +// + +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); + +void main (void) +{ + vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); + vec3 c = gcu_ColorStatic.rgb; + + float alpha = 0.0; + + if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { + alpha = gcu_Alpha; + } + else if((gcv_TexCoord.x >= 5.0)) { + vec2 dfx = dFdx(gcv_TexCoord); + vec2 dfy = dFdy(gcv_TexCoord); + + vec2 size = 1.0/gcu_TextureSize; + + rtex -= 5.0; + vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; + + t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*tex_weights.x; + t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*tex_weights.x; + t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*tex_weights.x; + t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*tex_weights.x; + + t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(1, 0)))*tex_weights.y; + t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*tex_weights.y; + t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*tex_weights.y; + t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*tex_weights.y; + + t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(1, 0)))*tex_weights.z; + t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*tex_weights.z; + t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*tex_weights.z; + t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*tex_weights.z; + + t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(1, 0)))*tex_weights.w; + t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*tex_weights.w; + t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w; + t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w; + + #if 0 + if(t.w == 0.0) { + discard; // discard freezes NV tegra2 compiler + } + #endif + + c = t.xyz; + alpha = gcu_Alpha * t.w; + } + /////////////////////////////////////////////////////////// + else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { + rtex.y -= 0.1; + + if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { + // discard; // freezes NV tegra2 compiler + alpha = 0.0; + } else { + rtex.y = max(rtex.y, 0.0); + + vec2 dtx = dFdx(rtex); + vec2 dty = dFdy(rtex); + + float w = gcu_Weight; + float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0; + float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd); + + float aph = 2.0 - 2.0*w; + + float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0); + vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd)); + + // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! + float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + alpha = gcu_Alpha * a; + } + } + + mgl_FragColor = vec4(c, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp new file mode 100644 index 000000000..0d878f2e4 --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp @@ -0,0 +1,89 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +// +// 2-pass shader w/o weight +// + +#if __VERSION__ >= 130 + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +#include uniforms.glsl +#include varyings.glsl + +const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); + +void main (void) +{ + vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); + vec3 c = gcu_ColorStatic.rgb; + + float alpha = 0.0; + float enable = 1.0; + + if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { + alpha = gcu_Alpha; + } + else if((gcv_TexCoord.x >= 5.0)) { + vec2 dfx = dFdx(gcv_TexCoord); + vec2 dfy = dFdy(gcv_TexCoord); + + vec2 size = 1.0/gcu_TextureSize; + + rtex -= 5.0; + vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; + + t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*tex_weights.x; + t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*tex_weights.x; + t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*tex_weights.x; + t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*tex_weights.x; + + t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(1, 0)))*tex_weights.y; + t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*tex_weights.y; + t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*tex_weights.y; + t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*tex_weights.y; + + t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(1, 0)))*tex_weights.z; + t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*tex_weights.z; + t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*tex_weights.z; + t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*tex_weights.z; + + t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(1, 0)))*tex_weights.w; + t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*tex_weights.w; + t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w; + t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w; + + #if 0 + if(t.w == 0.0){ + discard; // discard freezes NV tegra2 compiler + } + #endif + + c = t.xyz; + alpha = gcu_Alpha * t.w; + } + else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { + rtex.y -= 0.1; + + if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { + // discard; // freezes NV tegra2 compiler + alpha = 0.0; + } else { + rtex.y = max(rtex.y, 0.0); + + vec2 dtx = dFdx(rtex); + vec2 dty = dFdy(rtex); + + vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); + float position = rtex.y - (rtex.x * (1.0 - rtex.x)); + + // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! + float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); + alpha = gcu_Alpha * a; + } + } + + mgl_FragColor = vec4(c, alpha); +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp deleted file mode 100644 index 8fb985d69..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2-merged.vp +++ /dev/null @@ -1,19 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#ifdef GL_ES - precision highp float; - precision highp int; -#endif - -uniform mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi -varying vec2 gcv_TexCoord; - -attribute vec4 gca_Vertices; -attribute vec2 gca_TexCoords; - - -void main(void) -{ - gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * gca_Vertices; - gcv_TexCoord = gca_TexCoords; -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp deleted file mode 100644 index a5dc158ad..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-es2.vp +++ /dev/null @@ -1,9 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -precision highp float; -precision highp int; - -#include curverenderer01-xxx.vp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp deleted file mode 100644 index 1ac33e8b3..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-gl2.vp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer01-xxx.vp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp deleted file mode 100644 index 64a6835ec..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-xxx.vp +++ /dev/null @@ -1,12 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#include uniforms.glsl -#include attributes.glsl -#include varyings.glsl - -void main(void) -{ - // gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * vec4(gca_Vertices, 1); - gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * gca_Vertices; - gcv_TexCoord = gca_TexCoords; -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp new file mode 100644 index 000000000..64a6835ec --- /dev/null +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp @@ -0,0 +1,12 @@ +//Copyright 2010 JogAmp Community. All rights reserved. + +#include uniforms.glsl +#include attributes.glsl +#include varyings.glsl + +void main(void) +{ + // gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * vec4(gca_Vertices, 1); + gl_Position = gcu_PMVMatrix[0] * gcu_PMVMatrix[1] * gca_Vertices; + gcv_TexCoord = gca_TexCoords; +} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp deleted file mode 100644 index a57d8fc62..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2-merged.fp +++ /dev/null @@ -1,52 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#ifdef GL_ES - precision mediump float; - precision mediump int; -#endif - -uniform mat4 gcu_PMVMatrix[3]; // P, Mv, and Mvi -uniform vec3 gcu_ColorStatic; -uniform float gcu_Alpha; - -varying vec2 gcv_TexCoord; - -const vec3 b_color = vec3(1.0, 1.0, 1.0); - -void main (void) -{ - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - vec3 c = gcu_ColorStatic; - - float alpha = 0.0; - - if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { - alpha = gcu_Alpha; - } - else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { - vec2 dtx = dFdx(rtex); - vec2 dty = dFdy(rtex); - - rtex.y -= 0.1; - - if(rtex.y < 0.0) { - rtex.y = 0.0; - } - - vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); - float position = rtex.y - (rtex.x * (1.0 - rtex.x)); - float d = position/(length(f)); - - float a = (0.5 - d * sign(gcv_TexCoord.y)); - - if (a >= 1.0) { - alpha = gcu_Alpha; - } else if (a <= 0.0) { - alpha=0.0; - } else { - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp deleted file mode 100644 index e693891a6..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-es2.fp +++ /dev/null @@ -1,13 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; - -#include curverenderer01a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp deleted file mode 100644 index d187fea24..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer01a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp deleted file mode 100644 index f3a88adef..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01a-xxx.fp +++ /dev/null @@ -1,42 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 1-pass shader w/o weight -// - -#include uniforms.glsl -#include varyings.glsl - -void main (void) -{ - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - vec3 c = gcu_ColorStatic.rgb; - - float alpha = 0.0; - - if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { - alpha = gcu_Alpha; - } - else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { - rtex.y -= 0.1; - - if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { - // discard; // freezes NV tegra2 compiler - alpha = 0.0; - } else { - rtex.y = max(rtex.y, 0.0); - - vec2 dtx = dFdx(rtex); - vec2 dty = dFdy(rtex); - - vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); - float position = rtex.y - (rtex.x * (1.0 - rtex.x)); - - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! - float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp deleted file mode 100644 index d4748722d..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-es2.fp +++ /dev/null @@ -1,14 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; -precision mediump sampler2D; // default is lowp - -#include curverenderer01b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp deleted file mode 100644 index 01e08ff30..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer01b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp deleted file mode 100644 index 879e41e4c..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01b-xxx.fp +++ /dev/null @@ -1,82 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 2-pass shader w/o weight -// - -#include uniforms.glsl -#include varyings.glsl - -const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); - -void main (void) -{ - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - vec3 c = gcu_ColorStatic.rgb; - - float alpha = 0.0; - float enable = 1.0; - - if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { - alpha = gcu_Alpha; - } - else if((gcv_TexCoord.x >= 5.0)) { - vec2 dfx = dFdx(gcv_TexCoord); - vec2 dfy = dFdy(gcv_TexCoord); - - vec2 size = 1.0/gcu_TextureSize; - - rtex -= 5.0; - vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; - - t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*tex_weights.x; - t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*tex_weights.x; - t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*tex_weights.x; - t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*tex_weights.x; - - t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(1, 0)))*tex_weights.y; - t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*tex_weights.y; - t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*tex_weights.y; - t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*tex_weights.y; - - t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(1, 0)))*tex_weights.z; - t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*tex_weights.z; - t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*tex_weights.z; - t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*tex_weights.z; - - t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(1, 0)))*tex_weights.w; - t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*tex_weights.w; - t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w; - t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w; - - /** discard freezes NV tegra2 compiler - if(t.w == 0.0){ - discard; - } */ - - c = t.xyz; - alpha = gcu_Alpha * t.w; - } - else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { - rtex.y -= 0.1; - - if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { - // discard; // freezes NV tegra2 compiler - alpha = 0.0; - } else { - rtex.y = max(rtex.y, 0.0); - - vec2 dtx = dFdx(rtex); - vec2 dty = dFdy(rtex); - - vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); - float position = rtex.y - (rtex.x * (1.0 - rtex.x)); - - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! - float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp deleted file mode 100644 index 240a6c30f..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-es2.fp +++ /dev/null @@ -1,14 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; -precision mediump sampler2D; // default is lowp - -#include curverenderer02a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp deleted file mode 100644 index 01715daa5..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer02a-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp deleted file mode 100644 index d31bafb5a..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02a-xxx.fp +++ /dev/null @@ -1,48 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 1-pass shader w/ weight -// - -#include uniforms.glsl -#include varyings.glsl - -void main (void) -{ - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - vec3 c = gcu_ColorStatic.rgb; - - float alpha = 0.0; - - if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { - alpha = gcu_Alpha; - } - else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { - rtex.y -= 0.1; - - if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { - // discard; // freezes NV tegra2 compiler - alpha = 0.0; - } else { - rtex.y = max(rtex.y, 0.0); - - vec2 dtx = dFdx(rtex); - vec2 dty = dFdy(rtex); - - float w = gcu_Weight; - float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0; - float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd); - - float aph = 2.0 - 2.0*w; - - float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0); - vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd)); - - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! - float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp deleted file mode 100644 index 884e75674..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-es2.fp +++ /dev/null @@ -1,14 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 100 - -// we require dFdx/dFdy -// #extension OES_standard_derivatives : require -#extension GL_OES_standard_derivatives : enable - -precision mediump float; -precision mediump int; -precision mediump sampler2D; // default is lowp - -#include curverenderer02b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp deleted file mode 100644 index b1cc72188..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-gl2.fp +++ /dev/null @@ -1,6 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -#version 110 - -#include curverenderer02b-xxx.fp - diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp deleted file mode 100644 index be738498c..000000000 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer02b-xxx.fp +++ /dev/null @@ -1,88 +0,0 @@ -//Copyright 2010 JogAmp Community. All rights reserved. - -// -// 2-pass shader w/ weight -// - -#include uniforms.glsl -#include varyings.glsl - -const vec4 tex_weights = vec4(0.075, 0.06, 0.045, 0.025); - -void main (void) -{ - vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); - vec3 c = gcu_ColorStatic.rgb; - - float alpha = 0.0; - - if((gcv_TexCoord.x == 0.0) && (gcv_TexCoord.y == 0.0)) { - alpha = gcu_Alpha; - } - else if((gcv_TexCoord.x >= 5.0)) { - vec2 dfx = dFdx(gcv_TexCoord); - vec2 dfy = dFdy(gcv_TexCoord); - - vec2 size = 1.0/gcu_TextureSize; - - rtex -= 5.0; - vec4 t = texture2D(gcu_TextureUnit, rtex)* 0.18; - - t += texture2D(gcu_TextureUnit, rtex + size*(vec2(1, 0)))*tex_weights.x; - t += texture2D(gcu_TextureUnit, rtex - size*(vec2(1, 0)))*tex_weights.x; - t += texture2D(gcu_TextureUnit, rtex + size*(vec2(0, 1)))*tex_weights.x; - t += texture2D(gcu_TextureUnit, rtex - size*(vec2(0, 1)))*tex_weights.x; - - t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(1, 0)))*tex_weights.y; - t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(1, 0)))*tex_weights.y; - t += texture2D(gcu_TextureUnit, rtex + 2.0*size*(vec2(0, 1)))*tex_weights.y; - t += texture2D(gcu_TextureUnit, rtex - 2.0*size*(vec2(0, 1)))*tex_weights.y; - - t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(1, 0)))*tex_weights.z; - t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(1, 0)))*tex_weights.z; - t += texture2D(gcu_TextureUnit, rtex + 3.0*size*(vec2(0, 1)))*tex_weights.z; - t += texture2D(gcu_TextureUnit, rtex - 3.0*size*(vec2(0, 1)))*tex_weights.z; - - t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(1, 0)))*tex_weights.w; - t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(1, 0)))*tex_weights.w; - t += texture2D(gcu_TextureUnit, rtex + 4.0*size*(vec2(0, 1)))*tex_weights.w; - t += texture2D(gcu_TextureUnit, rtex - 4.0*size*(vec2(0, 1)))*tex_weights.w; - - /** discard freezes NV tegra2 compiler - if(t.w == 0.0) { - discard; - } */ - - c = t.xyz; - alpha = gcu_Alpha * t.w; - } - /////////////////////////////////////////////////////////// - else if ((gcv_TexCoord.x > 0.0) && (rtex.y > 0.0 || rtex.x == 1.0)) { - rtex.y -= 0.1; - - if(rtex.y < 0.0 && gcv_TexCoord.y < 0.0) { - // discard; // freezes NV tegra2 compiler - alpha = 0.0; - } else { - rtex.y = max(rtex.y, 0.0); - - vec2 dtx = dFdx(rtex); - vec2 dty = dFdy(rtex); - - float w = gcu_Weight; - float pd = ((2.0 - (2.0*w))*rtex.x*rtex.x) + 2.0*(w-1.0)*rtex.x + 1.0; - float position = rtex.y - ((w*rtex.x*(1.0 - rtex.x))/pd); - - float aph = 2.0 - 2.0*w; - - float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0); - vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd)); - - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! - float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); - alpha = gcu_Alpha * a; - } - } - - gl_FragColor = vec4(c, alpha); -} diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl index 7a9bc5a07..3b9a3b727 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl @@ -2,6 +2,10 @@ #ifndef varyings_glsl #define varyings_glsl +#if __VERSION__ >= 130 + #define varying out +#endif + //varying vec4 gcv_FrontColor; varying vec2 gcv_TexCoord; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java index 2d989ef65..eb2c7bf82 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT10.java @@ -54,6 +54,9 @@ public class TestTextRendererNEWT10 extends UITestCase { static final boolean DEBUG = false; static final boolean TRACE = false; static long duration = 100; // ms + static boolean forceES2 = false; + static boolean forceGL3 = false; + static boolean mainRun = false; static final float[] textPosition = new float[] {0,0,0}; static final int[] texSize = new int[] { 0 }; @@ -72,10 +75,15 @@ public class TestTextRendererNEWT10 extends UITestCase { } public static void main(String args[]) throws IOException { + mainRun = true; for(int i=0; i Date: Fri, 17 May 2013 08:48:57 +0200 Subject: GLPixelBuffer.dispose(): Set diposed:=true to allow isValid() to work properly; GLJPanel: Rely on GLPixelBuffer.requiresNewBuffer(..) for each frame, don't use local pixelBufferCheckSize (buggy w/ singleton) --- make/scripts/tests.sh | 8 ++++---- src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java | 11 ++++++----- src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 13 +++---------- 3 files changed, 13 insertions(+), 19 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3f51411f2..053e232ae 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -88,7 +88,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" - D_ARGS="-Djogl.debug.GLSLCode" + #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" @@ -184,7 +184,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" - #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" + D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" @@ -283,7 +283,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -548,7 +548,7 @@ function testawtswt() { # # Graph # -testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* +#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java index 6b9d3bf2c..b0fc7f332 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -212,7 +212,7 @@ public class GLPixelBuffer { this.bufferElemSize = Buffers.sizeOfBufferElem(buffer); } - /** Is not {@link #dispose()} and has {@link #byteSize} > 0. */ + /** Is not {@link #dispose() disposed} and has {@link #byteSize} > 0. */ public boolean isValid() { return !disposed && 0 < byteSize; } @@ -240,8 +240,8 @@ public class GLPixelBuffer { } /** - * Returns true, if implementation requires a new buffer based on the new size - * due to pixel alignment or byte size or if {@link #isValid() invalid}, otherwise false. + * Returns true, if {@link #isValid() invalid} or implementation requires a new buffer based on the new size + * due to pixel alignment or byte size, otherwise false. *

    * It is assumed that pixelAttributes, depth and pack stays the same! *

    @@ -257,11 +257,12 @@ public class GLPixelBuffer { * @see GLPixelBufferProvider#allocate(GL, GLPixelAttributes, int, int, int, boolean, int) */ public boolean requiresNewBuffer(GL gl, int newWidth, int newHeight, int minByteSize) { - return !isValid() || this.byteSize < minByteSize; + return !isValid() || byteSize < minByteSize; } - /** Dispose resources. */ + /** Dispose resources. See {@link #isValid()}. */ public void dispose() { + disposed = true; buffer.clear(); } } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 7359e1b47..b11f359be 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -978,7 +978,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final AWTGLPixelBufferProvider pixelBufferProvider; private final boolean useSingletonBuffer; private AWTGLPixelBuffer pixelBuffer; - private boolean pixelBufferCheckSize; // One of these is used to store the read back pixels before storing // in the BufferedImage @@ -1160,14 +1159,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if( useSingletonBuffer ) { // attempt to fetch the latest AWTGLPixelBuffer pixelBuffer = (AWTGLPixelBuffer) ((SingletonGLPixelBufferProvider)pixelBufferProvider).getSingleBuffer(pixelAttribs); } - if( pixelBufferCheckSize ) { - pixelBufferCheckSize = false; - if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) { - pixelBuffer.dispose(); - pixelBuffer = null; - } + if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) { + pixelBuffer.dispose(); + pixelBuffer = null; } - if ( null == pixelBuffer ) { if (0 >= panelWidth || 0 >= panelHeight ) { return; @@ -1300,8 +1295,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } } - - pixelBufferCheckSize = true; return _drawable.isRealized(); } -- cgit v1.2.3 From f650e6b37407aaa3ef6c16e7daf6423103b94ddf Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 18 May 2013 05:41:27 +0200 Subject: Fix regression of commit b2802021acf8aa9b363ebef383c8dc8c8079ffa4 (Bug 711): varying in/out mapping is different in vertex/fragment shader! Vertex shader: varying -> out Fragemnt shader: varying -> in NV GLSL compiler ignored in/out direction, where ATI GLSL compiler failed (could not find gcu_Weight, due to dead code). --- make/scripts/tests.sh | 9 ++++----- .../classes/jogamp/graph/curve/opengl/shader/attributes.glsl | 4 ---- .../graph/curve/opengl/shader/curverenderer01-1pass-weight.fp | 1 + .../jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp | 1 + .../graph/curve/opengl/shader/curverenderer01-2pass-weight.fp | 1 + .../jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp | 1 + .../classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp | 5 +++++ src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl | 4 ---- 8 files changed, 13 insertions(+), 13 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 053e232ae..840414c54 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -87,8 +87,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" - #D_ARGS="-Djogl.debug.GLSLCode" - #D_ARGS="-Djogl.debug.GLSLCode" + D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" @@ -184,7 +183,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" - D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" @@ -283,7 +282,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -550,7 +549,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT # #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $* -#testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* +testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 $* diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl index ced118c1c..108247c9c 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/attributes.glsl @@ -2,10 +2,6 @@ #ifndef attributes_glsl #define attributes_glsl -#if __VERSION__ >= 130 - #define attribute in -#endif - // attribute vec3 gca_Vertices; attribute vec4 gca_Vertices; attribute vec2 gca_TexCoords; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp index ca03e605c..7643dab7b 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp @@ -5,6 +5,7 @@ // #if __VERSION__ >= 130 + #define varying in out vec4 mgl_FragColor; #else #define mgl_FragColor gl_FragColor diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp index b978b62d1..e12eef4b1 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp @@ -5,6 +5,7 @@ // #if __VERSION__ >= 130 + #define varying in out vec4 mgl_FragColor; #else #define mgl_FragColor gl_FragColor diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp index 9440f314c..06edbeaee 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp @@ -5,6 +5,7 @@ // #if __VERSION__ >= 130 + #define varying in out vec4 mgl_FragColor; #else #define mgl_FragColor gl_FragColor diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp index 0d878f2e4..07a005709 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp @@ -5,6 +5,7 @@ // #if __VERSION__ >= 130 + #define varying in out vec4 mgl_FragColor; #else #define mgl_FragColor gl_FragColor diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp index 64a6835ec..4b5c8b1e2 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01.vp @@ -1,5 +1,10 @@ //Copyright 2010 JogAmp Community. All rights reserved. +#if __VERSION__ >= 130 + #define attribute in + #define varying out +#endif + #include uniforms.glsl #include attributes.glsl #include varyings.glsl diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl index 3b9a3b727..7a9bc5a07 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/varyings.glsl @@ -2,10 +2,6 @@ #ifndef varyings_glsl #define varyings_glsl -#if __VERSION__ >= 130 - #define varying out -#endif - //varying vec4 gcv_FrontColor; varying vec2 gcv_TexCoord; -- cgit v1.2.3 From 81afec4e963ac4372dc2b604d6f91237b81ee6f2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 31 May 2013 06:34:13 +0200 Subject: GLVersionNumber: Fix vendor version parser; Adapt to GlueGen commit 959d6d83ec26152343d538287c02eeebf0dcf238 Adapt to GlueGen commit 959d6d83ec26152343d538287c02eeebf0dcf238: - Use only RegExp and cache default (no wrapped whitespace tokenizer) - String match: Store end-of-match and flag defined components. - Remove manual parsing, utilize VersionNumber - No need to look further for 'updated' GL version, (probably the vendor version), since we utilize the ARB version number as set at creation. Fix vendor version parser: - Cut off GL version part of versionString (fixes case where GL version was interpreted as vendor version) - Loop through remaining string until a valid version number w/ major.minor has been found --- make/scripts/tests.sh | 5 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 2 +- .../classes/jogamp/opengl/GLVersionNumber.java | 137 +++++++---------- .../jogl/acore/TestGLVersionParsing00NEWT.java | 170 +++++++++++++++++++++ 4 files changed, 226 insertions(+), 88 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 840414c54..8fd7d2852 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -87,7 +87,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" - D_ARGS="-Djogl.debug.GLSLCode" + #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" @@ -312,6 +312,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -549,7 +550,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $* -testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* +#testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 $* #testnoawt com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 $* diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 314db292d..e7eef61e7 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1050,7 +1050,7 @@ public abstract class GLContextImpl extends GLContext { if( hasGLSL() ) { // >= ES2 || GL2.0 final String glslVersion = isGLES() ? null : gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) ; // Use static GLSL version for ES to be safe! if( null != glslVersion ) { - ctxGLSLVersion = new VersionNumber(glslVersion, "."); + ctxGLSLVersion = new VersionNumber(glslVersion); if( ctxGLSLVersion.getMajor() < 1 ) { ctxGLSLVersion = VersionNumber.zeroVersion; // failed .. } diff --git a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java index 990698667..a32fdfa77 100644 --- a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java +++ b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java @@ -28,98 +28,62 @@ package jogamp.opengl; -import java.util.StringTokenizer; - -import javax.media.opengl.GLContext; - +import com.jogamp.common.util.VersionNumber; import com.jogamp.common.util.VersionNumberString; /** * A class for storing and comparing OpenGL version numbers. * This only works for desktop OpenGL at the moment. */ -class GLVersionNumber extends VersionNumberString { +public class GLVersionNumber extends VersionNumberString { private final boolean valid; - private GLVersionNumber(int[] val, String versionString, boolean valid) { - super(val[0], val[1], val[2], versionString); + private GLVersionNumber(int[] val, int strEnd, short state, String versionString, boolean valid) { + super(val[0], val[1], val[2], strEnd, state, versionString); this.valid = valid; } - public static GLVersionNumber create(String versionString) { + private static java.util.regex.Pattern getUnderscorePattern() { + if( null == _Pattern ) { // volatile dbl-checked-locking OK + synchronized( VersionNumber.class ) { + if( null == _Pattern ) { + _Pattern = getVersionNumberPattern("_"); + } + } + } + return _Pattern; + } + private static volatile java.util.regex.Pattern _Pattern = null; + + public static final GLVersionNumber create(String versionString) { int[] val = new int[] { 0, 0, 0 }; - try { - if (versionString.startsWith("GL_VERSION_")) { - StringTokenizer tok = new StringTokenizer(versionString, "_"); - tok.nextToken(); // GL_ - tok.nextToken(); // VERSION_ - if (!tok.hasMoreTokens()) { - val[0] = 0; + int strEnd = 0; + short state = 0; + if (versionString != null && versionString.length() > 0) { + try { + final java.util.regex.Pattern versionPattern; + if (versionString.startsWith("GL_VERSION_")) { + versionPattern = getUnderscorePattern(); } else { - val[0] = Integer.valueOf(tok.nextToken()).intValue(); - if (!tok.hasMoreTokens()) { - val[1] = 0; - } else { - val[1] = Integer.valueOf(tok.nextToken()).intValue(); - if (!tok.hasMoreTokens()) { - val[2] = 0; - } else { - val[2] = Integer.valueOf(tok.nextToken()).intValue(); - } - } + versionPattern = VersionNumberString.getDefaultVersionNumberPattern(); } - } else { - int radix = 10; - if (versionString.length() > 2) { - if (Character.isDigit(versionString.charAt(0)) && versionString.charAt(1) == '.' && Character.isDigit(versionString.charAt(2))) { - val[0] = Character.digit(versionString.charAt(0), radix); - val[1] = Character.digit(versionString.charAt(2), radix); - // See if there's version-specific information which might - // imply a more recent OpenGL version - StringTokenizer tok = new StringTokenizer(versionString, " "); - if (tok.hasMoreTokens()) { - tok.nextToken(); - if (tok.hasMoreTokens()) { - String token = tok.nextToken(); - int i = 0; - while (i < token.length() && !Character.isDigit(token.charAt(i))) { - i++; - } - if (i < token.length() - 2 && Character.isDigit(token.charAt(i)) && token.charAt(i + 1) == '.' && Character.isDigit(token.charAt(i + 2))) { - int altMajor = Character.digit(token.charAt(i), radix); - int altMinor = Character.digit(token.charAt(i + 2), radix); - // Avoid possibly confusing situations by putting some - // constraints on the upgrades we do to the major and - // minor versions - if ( (altMajor == val[0] && altMinor > val[1]) || altMajor == val[0] + 1 ) { - if( GLContext.isValidGLVersion(altMajor, altMinor) ) { - val[0] = altMajor; - val[1] = altMinor; - } - } - } - } - } - } + final VersionNumberString version = new VersionNumberString(versionString, versionPattern); + if( version.hasMajor() && version.hasMinor() ) { // Requires at least a defined major and minor version component! + val[0] = version.getMajor(); + val[1] = version.getMinor(); + strEnd = version.endOfStringMatch(); + state = (short) ( ( version.hasMajor() ? VersionNumber.HAS_MAJOR : (short)0 ) | + ( version.hasMinor() ? VersionNumber.HAS_MINOR : (short)0 ) ); } + } catch (Exception e) { + e.printStackTrace(); + System.err.println("Info: ExtensionAvailabilityCache: FunctionAvailabilityCache.Version.: " + e); + val[0] = 1; + val[1] = 0; } - return new GLVersionNumber(val, versionString, true); - } catch (Exception e) { - e.printStackTrace(); - // FIXME: refactor desktop OpenGL dependencies and make this - // class work properly for OpenGL ES - System.err.println("Info: ExtensionAvailabilityCache: FunctionAvailabilityCache.Version.: " + e); - val[0] = 1; - val[1] = 0; - /* - throw (IllegalArgumentException) - new IllegalArgumentException( - "Illegally formatted version identifier: \"" + versionString + "\"") - .initCause(e); - */ - } - return new GLVersionNumber(val, versionString, false); + } + return new GLVersionNumber(val, strEnd, state, versionString, false); } public final boolean isValid() { @@ -131,6 +95,7 @@ class GLVersionNumber extends VersionNumberString { * GL_VERSION string if exists, otherwise the {@link VersionNumberString#zeroVersion zero version} instance. *
          *   2.1 Mesa 7.0.3-rc2 -> 7.0.3 (7.0.3-rc2)
    +     *   2.1 Mesa 7.12-devel (git-d6c318e) -> 7.12.0 (7.12-devel)
          *   4.2.12171 Compatibility Profile Context 9.01.8 -> 9.1.8 (9.01.8)
          *   4.2.12198 Compatibility Profile Context 12.102.3.0 -> 12.102.3 (12.102.3.0)
          *   4.3.0 NVIDIA 310.32 -> 310.32 (310.32)
    @@ -139,19 +104,21 @@ class GLVersionNumber extends VersionNumberString {
         public static final VersionNumberString createVendorVersion(String versionString) {
             if (versionString == null || versionString.length() <= 0) {
                 return null;
    -        }    
    -        final String[] strings = versionString.trim().split("\\s+");
    -        if ( strings.length <= 0 ) {
    -            return null;
             }
    -        // Test all segments backwards from [len-1..1], skipping the 1st entry (GL version)
    -        // If a segment represents a valid VersionNumber - use it.
    -        for(int i=strings.length-1; i>=1; i--) {
    -            final String s = strings[i];
    -            final VersionNumberString version = new VersionNumberString(s, ".");
    -            if( !version.isZero() ) {
    +        
    +        // Skip the 1st GL version
    +        String str;
    +        {
    +            final GLVersionNumber glv = create(versionString);
    +            str = versionString.substring(glv.endOfStringMatch());
    +        }
    +        
    +        while ( str.length() > 0 ) {
    +            final VersionNumberString version = new VersionNumberString(str, getDefaultVersionNumberPattern());
    +            if( version.hasMajor() && version.hasMinor() ) { // Requires at least a defined major and minor version component!
                     return version;
                 }
    +            str = str.substring(version.endOfStringMatch());
             }
             return VersionNumberString.zeroVersion;
         }
    diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java
    new file mode 100644
    index 000000000..394772135
    --- /dev/null
    +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java
    @@ -0,0 +1,170 @@
    +/**
    + * Copyright 2013 JogAmp Community. All rights reserved.
    + *
    + * Redistribution and use in source and binary forms, with or without modification, are
    + * permitted provided that the following conditions are met:
    + * 
    + *    1. Redistributions of source code must retain the above copyright notice, this list of
    + *       conditions and the following disclaimer.
    + * 
    + *    2. Redistributions in binary form must reproduce the above copyright notice, this list
    + *       of conditions and the following disclaimer in the documentation and/or other materials
    + *       provided with the distribution.
    + * 
    + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
    + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
    + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
    + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
    + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
    + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    + * 
    + * The views and conclusions contained in the software and documentation are those of the
    + * authors and should not be interpreted as representing official policies, either expressed
    + * or implied, of JogAmp Community.
    + */
    + 
    +package com.jogamp.opengl.test.junit.jogl.acore;
    +
    +import java.io.IOException;
    +
    +import org.junit.Assert;
    +import org.junit.Test;
    +
    +import jogamp.opengl.GLVersionNumber;
    +
    +import com.jogamp.common.util.VersionNumberString;
    +import com.jogamp.opengl.test.junit.util.UITestCase;
    +
    +public class TestGLVersionParsing00NEWT extends UITestCase {
    +
    +    public static final String[] glVersionStrings00 = new String[] {
    +        "GL_VERSION_2_1 DummyTool 1.2.3", // 0
    +        "2.1 Mesa 7.0.3-rc2",
    +        "4.2.12171 Compatibility Profile Context 9.01.8",
    +        "4.2.12198 Compatibility Profile Context 12.102.3.0",
    +        "2.1 Mesa 7.0.3-rc2 post odd",
    +        "4.2.12171 Compatibility Profile Context 9.01.8 post odd",
    +        "4.2.12198 Compatibility Profile Context 12.102.3.0 post odd",
    +        "OpenGL ES 2.0 Mesa 9.1.1", // 7
    +        "OpenGL ES 2.0 14.10.1",
    +        "OpenGL ES GLSL ES 2.0 14.10.1", // 9
    +        "OpenGL ES 2.0 3Com L3 11.33.44" // 10
    +    };
    +    public static final String[] glVersionStrings01 = new String[] {
    +        "GL_VERSION_2_1 Dummy Tool 1.2", // 0
    +        "2.1 Mesa 7.12",
    +        "2.1 Mesa 7.12-devel",
    +        "2.1 Mesa 7.12-devel (git-d6c318e)",
    +        "2.1 Mesa 7.12-devel la1 la2 li3",
    +        "4.3.0 NVIDIA 310.32",
    +        "OpenGL ES 2.0 Mesa 9.1", // 6
    +        "OpenGL ES 2.0 14.10",
    +        "OpenGL ES GLSL ES 2.0 14.10", // 8
    +        "OpenGL ES 2.0 3Com L3 11.33" // 9
    +    };
    +    public static final String[] glVersionStrings02 = new String[] {
    +        "GL_VERSION_2_1", // 0
    +        "OpenGL ES 2.0", // 1
    +        "OpenGL ES GLSL ES 2.0" // 2
    +    };
    +    
    +    public static final VersionNumberString[] glVersionNumbers = new VersionNumberString[] {
    +        new VersionNumberString(2, 1, 0, glVersionStrings00[0]), 
    +        new VersionNumberString(2, 1, 0, glVersionStrings00[1]), 
    +        new VersionNumberString(4, 2, 0, glVersionStrings00[2]),
    +        new VersionNumberString(4, 2, 0, glVersionStrings00[3]),
    +        new VersionNumberString(2, 1, 0, glVersionStrings00[4]), 
    +        new VersionNumberString(4, 2, 0, glVersionStrings00[5]),
    +        new VersionNumberString(4, 2, 0, glVersionStrings00[6]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings00[7]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings00[8]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings00[9]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings00[10]),
    +        
    +        new VersionNumberString(2, 1, 0, glVersionStrings01[0]),
    +        new VersionNumberString(2, 1, 0, glVersionStrings01[1]),
    +        new VersionNumberString(2, 1, 0, glVersionStrings01[2]),
    +        new VersionNumberString(2, 1, 0, glVersionStrings01[3]),
    +        new VersionNumberString(2, 1, 0, glVersionStrings01[4]),
    +        new VersionNumberString(4, 3, 0, glVersionStrings01[5]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings01[6]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings01[7]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings01[8]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings01[9]),
    +        
    +        new VersionNumberString(2, 1, 0, glVersionStrings02[0]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings02[1]),
    +        new VersionNumberString(2, 0, 0, glVersionStrings02[1])
    +    };
    +    public static final VersionNumberString[] glVendorVersionNumbersWithSub = new VersionNumberString[] {
    +        new VersionNumberString(1,     2,  3, glVersionStrings00[0]),
    +        new VersionNumberString(7,     0,  3, glVersionStrings00[1]),
    +        new VersionNumberString(9,     1,  8, glVersionStrings00[2]),
    +        new VersionNumberString(12,  102,  3, glVersionStrings00[3]),
    +        new VersionNumberString(7,     0,  3, glVersionStrings00[4]),
    +        new VersionNumberString(9,     1,  8, glVersionStrings00[5]),
    +        new VersionNumberString(12,  102,  3, glVersionStrings00[6]),
    +        new VersionNumberString(9,     1,  1, glVersionStrings00[7]),
    +        new VersionNumberString(14,   10,  1, glVersionStrings00[8]),
    +        new VersionNumberString(14,   10,  1, glVersionStrings00[9]),
    +        new VersionNumberString(11,   33, 44, glVersionStrings00[10])
    +    };
    +    public static final VersionNumberString[] glVendorVersionNumbersNoSub = new VersionNumberString[] {
    +        new VersionNumberString(1,     2, 0, glVersionStrings01[0]),
    +        new VersionNumberString(7,    12, 0, glVersionStrings01[1]),
    +        new VersionNumberString(7,    12, 0, glVersionStrings01[2]),
    +        new VersionNumberString(7,    12, 0, glVersionStrings01[3]),
    +        new VersionNumberString(7,    12, 0, glVersionStrings01[4]),
    +        new VersionNumberString(310,  32, 0, glVersionStrings01[5]),
    +        new VersionNumberString(9,     1, 0, glVersionStrings01[6]),
    +        new VersionNumberString(14,   10, 0, glVersionStrings01[7]),
    +        new VersionNumberString(14,   10, 0, glVersionStrings01[8]),
    +        new VersionNumberString(11,   33, 0, glVersionStrings01[9])
    +    };
    +    public static final VersionNumberString[] glVendorVersionNumbersNone = new VersionNumberString[] {
    +        new VersionNumberString(0,     0, 0, glVersionStrings02[0]),
    +        new VersionNumberString(0,     0, 0, glVersionStrings02[1]),
    +        new VersionNumberString(0,     0, 0, glVersionStrings02[2])
    +    };
    +    
    +    @Test
    +    public void test01GLVersion() throws InterruptedException {
    +        for(int i=0; i "+has+", define ["+has.hasMajor()+":"+has.hasMinor()+":"+has.hasSub()+"]");
    +            Assert.assertTrue(has.hasMajor());
    +            Assert.assertTrue(has.hasMinor());
    +            Assert.assertTrue(!has.hasSub());
    +            Assert.assertEquals(exp, has);
    +        }
    +    }
    +
    +    private void testGLVendorVersionImpl(VersionNumberString[] versionNumberString, boolean withMajor, boolean withMinor, boolean withSub) throws InterruptedException {
    +        for(int i=0; i "+has+", define ["+has.hasMajor()+":"+has.hasMinor()+":"+has.hasSub()+"]");
    +            Assert.assertEquals(withMajor, has.hasMajor());
    +            Assert.assertEquals(withMinor, has.hasMinor());
    +            Assert.assertEquals(withSub,   has.hasSub());
    +            Assert.assertEquals(exp, has);
    +        }
    +    }
    +    
    +    @Test
    +    public void test02GLVendorVersion() throws InterruptedException {
    +        testGLVendorVersionImpl(glVendorVersionNumbersWithSub, true, true, true);
    +        testGLVendorVersionImpl(glVendorVersionNumbersNoSub, true, true, false);
    +        testGLVendorVersionImpl(glVendorVersionNumbersNone, false, false, false);
    +    }
    +    
    +    public static void main(String args[]) throws IOException {
    +        String tstname = TestGLVersionParsing00NEWT.class.getName();
    +        org.junit.runner.JUnitCore.main(tstname);
    +    }
    +
    +}
    \ No newline at end of file
    -- 
    cgit v1.2.3
    
    
    From cbd7bf1d65a253381b0775d57c0c949c75aef008 Mon Sep 17 00:00:00 2001
    From: Sven Gothel 
    Date: Fri, 31 May 2013 11:16:01 +0200
    Subject: GLVersionNumber.createVendorVersion(): Only test match result and
     potentially continue matching if having a pattern-match (don't loop
     for-ever).
    
    ---
     make/scripts/tests.sh                              |  4 +-
     src/jogl/classes/com/jogamp/opengl/FBObject.java   | 15 ++--
     .../com/jogamp/opengl/GLRendererQuirks.java        | 42 ++++++++++-
     src/jogl/classes/javax/media/opengl/GLContext.java | 18 ++---
     src/jogl/classes/jogamp/opengl/GLContextImpl.java  | 84 +++++++++++++++-------
     .../classes/jogamp/opengl/GLVersionNumber.java     | 11 ++-
     .../jogl/acore/TestGLVersionParsing00NEWT.java     | 16 +++--
     7 files changed, 133 insertions(+), 57 deletions(-)
    
    (limited to 'make/scripts')
    
    diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
    index 8fd7d2852..071c56a9b 100755
    --- a/make/scripts/tests.sh
    +++ b/make/scripts/tests.sh
    @@ -281,7 +281,7 @@ function testawtswt() {
     #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $*
     #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $*
    -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
    +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $*
     #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $*
     #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $*
    @@ -312,7 +312,7 @@ function testawtswt() {
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $*
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $*
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $*
    -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $*
    +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $*
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $*
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $*
     #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $*
    diff --git a/src/jogl/classes/com/jogamp/opengl/FBObject.java b/src/jogl/classes/com/jogamp/opengl/FBObject.java
    index 6f2ac3e35..7060bb7d1 100644
    --- a/src/jogl/classes/com/jogamp/opengl/FBObject.java
    +++ b/src/jogl/classes/com/jogamp/opengl/FBObject.java
    @@ -60,7 +60,6 @@ import com.jogamp.opengl.FBObject.Attachment.Type;
      */
     public class FBObject {
         protected static final boolean DEBUG = Debug.debug("FBObject");
    -    private static final boolean forceMinimumFBOSupport = Debug.isPropertyDefined("jogl.fbo.force.min", true);
         private static final boolean FBOResizeQuirk = false;
         
         private static enum DetachAction { NONE, DISPOSE, RECREATE };
    @@ -813,6 +812,7 @@ public class FBObject {
             maxColorAttachments = 1;
             if( fullFBOSupport || NV_fbo_color_attachments ) {
                 try {
    +                val[0] = 0;
                     gl.glGetIntegerv(GL2ES2.GL_MAX_COLOR_ATTACHMENTS, val, 0);
                     realMaxColorAttachments = 1 <= val[0] ? val[0] : 1; // cap minimum to 1
                 } catch (GLException gle) { gle.printStackTrace(); }
    @@ -823,15 +823,10 @@ public class FBObject {
             colorAttachmentCount = 0;
             
             maxSamples = gl.getMaxRenderbufferSamples();
    -        if(!forceMinimumFBOSupport) {
    -            gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0);
    -            maxTextureSize = val[0];
    -            gl.glGetIntegerv(GL.GL_MAX_RENDERBUFFER_SIZE, val, 0);
    -            maxRenderbufferSize = val[0];
    -        } else {
    -            maxTextureSize = 2048;
    -            maxRenderbufferSize = 2048;
    -        }
    +        gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, val, 0);
    +        maxTextureSize = val[0];
    +        gl.glGetIntegerv(GL.GL_MAX_RENDERBUFFER_SIZE, val, 0);
    +        maxRenderbufferSize = val[0];
             
             checkPreGLError(gl);
             
    diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
    index 78bd62e42..36893f5ec 100644
    --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
    +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java
    @@ -27,6 +27,8 @@
      */
     package com.jogamp.opengl;
     
    +import java.util.List;
    +
     /** 
      * GLRendererQuirks contains information of known bugs of various GL renderer. 
      * This information allows us to workaround them.
    @@ -151,14 +153,36 @@ public class GLRendererQuirks {
          */
         public static final int NeedCurrCtx4ARBCreateContext = 10;
         
    +    /**
    +     * No full FBO support, i.e. not compliant w/
    +     * 
      + *
    • GL_ARB_framebuffer_object
    • + *
    • EXT_framebuffer_object
    • + *
    • EXT_framebuffer_multisample
    • + *
    • EXT_framebuffer_blit
    • + *
    • EXT_packed_depth_stencil
    • + *
    . + * Drivers known exposing such bug: + *
      + *
    • Mesa 7.12-devel on Windows with VMware SVGA3D renderer: + *
        + *
      • GL_VERSION: 2.1 Mesa 7.12-devel (git-d6c318e)
      • + *
      • GL_RENDERER: Gallium 0.4 on SVGA3D; build: RELEASE;
      • + *
    • + *
    + * Quirk can also be enabled via property: jogl.fbo.force.min. + */ + public static final int NoFullFBOSupport = 11; + /** Number of quirks known. */ - public static final int COUNT = 11; + public static final int COUNT = 12; private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", "GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display", - "NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext" + "NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext", + "NoFullFBOSupport" }; private final int _bitmask; @@ -182,6 +206,20 @@ public class GLRendererQuirks { _bitmask = bitmask; } + /** + * @param quirks a list of valid quirks + * @throws IllegalArgumentException if one of the quirks is out of range + */ + public GLRendererQuirks(List quirks) throws IllegalArgumentException { + int bitmask = 0; + for(int i=0; i */ public final boolean hasFullFBOSupport() { - return !FORCE_MIN_FBO_SUPPORT && hasBasicFBOSupport() && - ( isGL3() || // GL >= 3.0 - isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object - ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object* - isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) && - isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) && - isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil) - ) - ) ; + return hasBasicFBOSupport() && !hasRendererQuirk(GLRendererQuirks.NoFullFBOSupport) && + ( isGL3() || // GL >= 3.0 + isExtensionAvailable(GLExtensions.ARB_framebuffer_object) || // ARB_framebuffer_object + ( isExtensionAvailable(GLExtensions.EXT_framebuffer_object) && // All EXT_framebuffer_object* + isExtensionAvailable(GLExtensions.EXT_framebuffer_multisample) && + isExtensionAvailable(GLExtensions.EXT_framebuffer_blit) && + isExtensionAvailable(GLExtensions.EXT_packed_depth_stencil) + ) + ) ; } /** diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index e7eef61e7..cab629c3a 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1504,7 +1504,7 @@ public abstract class GLContextImpl extends GLContext { } private final void setRendererQuirks(final AbstractGraphicsDevice adevice, int major, int minor, int ctp, final VersionNumberString vendorVersion) { - int[] quirks = new int[GLRendererQuirks.COUNT]; + int[] quirks = new int[GLRendererQuirks.COUNT + 1]; // + 1 ( NoFullFBOSupport ) int i = 0; final String MesaSP = "Mesa "; @@ -1513,6 +1513,7 @@ public abstract class GLContextImpl extends GLContext { final boolean isDriverMesa = glRenderer.contains(MesaSP) || glRenderer.contains("Gallium "); final boolean isDriverATICatalyst = !isDriverMesa && ( glVendor.contains("ATI Technologies") || glRenderer.startsWith("ATI ") ); final boolean isDriverNVIDIAGeForce = !isDriverMesa && ( glVendor.contains("NVIDIA Corporation") || glRenderer.contains("NVIDIA ") ); + // // OS related quirks // @@ -1582,6 +1583,44 @@ public abstract class GLContextImpl extends GLContext { } } + // + // Windowing Toolkit related quirks + // + if( NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { + // + // X11 + // + { + // + // Quirk: DontCloseX11Display + // + final int quirk = GLRendererQuirks.DontCloseX11Display; + if( glRenderer.contains(MesaSP) ) { + if ( glRenderer.contains("X11") && vendorVersion.compareTo(Version80) < 0 ) { + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 Renderer=" + glRenderer + ", Version=[vendor " + vendorVersion + ", GL " + glVersion+"]"); + } + quirks[i++] = quirk; + } + } else if( isDriverATICatalyst ) { + { + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 Renderer=" + glRenderer); + } + quirks[i++] = quirk; + } + } else if( jogamp.nativewindow.x11.X11Util.getMarkAllDisplaysUnclosable() ) { + { + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11Util Downstream"); + } + quirks[i++] = quirk; + } + } + } + } + + // // RENDERER related quirks // @@ -1601,7 +1640,7 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - if( glRenderer.contains("Intel(R)") && compatCtx && ( major>3 || major==3 && minor>=1 ) ) + if( glRenderer.contains("Intel(R)") && compatCtx && ( major > 3 || major == 3 && minor >= 1 ) ) { // FIXME: Apply vendor version constraints! final int quirk = GLRendererQuirks.GLNonCompliant; @@ -1610,37 +1649,30 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - } - - // - // Quirk: DontCloseX11Display - // - if( NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { - final int quirk = GLRendererQuirks.DontCloseX11Display; - if( glRenderer.contains(MesaSP) ) { - if ( glRenderer.contains("X11") && vendorVersion.compareTo(Version80) < 0 ) { - if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 Renderer=" + glRenderer + ", Version=[vendor " + vendorVersion + ", GL " + glVersion+"]"); - } - quirks[i++] = quirk; - } - } else if( isDriverATICatalyst ) { - { - if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11 Renderer=" + glRenderer); - } - quirks[i++] = quirk; - } - } else if( jogamp.nativewindow.x11.X11Util.getMarkAllDisplaysUnclosable() ) { - { + if( Platform.getOSType() == Platform.OSType.WINDOWS && glRenderer.contains("SVGA3D") ) + { + final VersionNumber mesaSafeFBOVersion = new VersionNumber(8, 0, 0); + if ( vendorVersion.compareTo(mesaSafeFBOVersion) < 0 ) { // includes: vendorVersion.isZero() + final int quirk = GLRendererQuirks.NoFullFBOSupport; if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: X11Util Downstream"); + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + " / Renderer " + glRenderer + " / Mesa-Version "+vendorVersion); } quirks[i++] = quirk; } } } + // + // Property related quirks + // + if( FORCE_MIN_FBO_SUPPORT ) { + final int quirk = GLRendererQuirks.NoFullFBOSupport; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: property"); + } + quirks[i++] = quirk; + } + glRendererQuirks = new GLRendererQuirks(quirks, 0, i); } diff --git a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java index 0ce34a60d..cea3ac4ab 100644 --- a/src/jogl/classes/jogamp/opengl/GLVersionNumber.java +++ b/src/jogl/classes/jogamp/opengl/GLVersionNumber.java @@ -115,10 +115,15 @@ public class GLVersionNumber extends VersionNumberString { while ( str.length() > 0 ) { final VersionNumberString version = new VersionNumberString(str, getDefaultVersionNumberPattern()); - if( version.hasMajor() && version.hasMinor() ) { // Requires at least a defined major and minor version component! - return version; + final int eosm = version.endOfStringMatch(); + if( 0 < eosm ) { + if( version.hasMajor() && version.hasMinor() ) { // Requires at least a defined major and minor version component! + return version; + } + str = str.substring( eosm ); + } else { + break; // no match } - str = str.substring(version.endOfStringMatch()); } return VersionNumberString.zeroVersion; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java index f2f6e4aff..a39e68abf 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLVersionParsing00NEWT.java @@ -68,7 +68,9 @@ public class TestGLVersionParsing00NEWT extends UITestCase { public static final String[] glVersionStrings02 = new String[] { "GL_VERSION_2_1", // 0 "OpenGL ES 2.0", // 1 - "OpenGL ES GLSL ES 2.0" // 2 + "OpenGL ES GLSL ES 2.0", // 2 + "OpenGL 2.1 LaLa", // 3 + "4.2.11762 Compatibility Profile Context" // 4 }; public static final VersionNumberString[] glVersionNumbers = new VersionNumberString[] { @@ -97,7 +99,9 @@ public class TestGLVersionParsing00NEWT extends UITestCase { new VersionNumberString(2, 1, 0, glVersionStrings02[0]), new VersionNumberString(2, 0, 0, glVersionStrings02[1]), - new VersionNumberString(2, 0, 0, glVersionStrings02[1]) + new VersionNumberString(2, 0, 0, glVersionStrings02[2]), + new VersionNumberString(2, 1, 0, glVersionStrings02[3]), + new VersionNumberString(4, 2, 0, glVersionStrings02[4]) }; public static final VersionNumberString[] glVendorVersionNumbersWithSub = new VersionNumberString[] { new VersionNumberString(1, 2, 3, glVersionStrings00[0]), @@ -125,9 +129,11 @@ public class TestGLVersionParsing00NEWT extends UITestCase { new VersionNumberString(11, 33, 0, glVersionStrings01[9]) }; public static final VersionNumberString[] glVendorVersionNumbersNone = new VersionNumberString[] { - new VersionNumberString(0, 0, 0, glVersionStrings02[0]), - new VersionNumberString(0, 0, 0, glVersionStrings02[1]), - new VersionNumberString(0, 0, 0, glVersionStrings02[2]) + new VersionNumberString(0, 0, 0, glVersionStrings02[0]), + new VersionNumberString(0, 0, 0, glVersionStrings02[1]), + new VersionNumberString(0, 0, 0, glVersionStrings02[2]), + new VersionNumberString(0, 0, 0, glVersionStrings02[3]), + new VersionNumberString(0, 0, 0, glVersionStrings02[4]) }; @Test -- cgit v1.2.3 From a60e3b1a894c53abe7ab3a19f1f30cfa96886464 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 9 Jun 2013 06:07:15 +0200 Subject: Unit Tests: Group *math* tests in own test package --- make/scripts/tests.sh | 11 +- .../acore/TestFloatUtil01MatrixMatrixMultNOUI.java | 113 ----- .../test/junit/jogl/acore/TestPMVMatrix01NEWT.java | 466 --------------------- .../test/junit/jogl/acore/TestPMVMatrix02NEWT.java | 109 ----- .../junit/jogl/glu/TestGluUnprojectDoubleNOUI.java | 57 --- .../junit/jogl/glu/TestGluUnprojectFloatNOUI.java | 103 ----- .../math/TestFloatUtil01MatrixMatrixMultNOUI.java | 113 +++++ .../jogl/math/TestGluUnprojectDoubleNOUI.java | 57 +++ .../junit/jogl/math/TestGluUnprojectFloatNOUI.java | 103 +++++ .../test/junit/jogl/math/TestPMVMatrix01NEWT.java | 466 +++++++++++++++++++++ .../test/junit/jogl/math/TestPMVMatrix02NOUI.java | 109 +++++ 11 files changed, 855 insertions(+), 852 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01MatrixMatrixMultNOUI.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 071c56a9b..d49a0fc33 100755 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -309,9 +309,13 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* #testnoawt com.jogamp.newt.opengl.GLWindow $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFloatUtil01MatrixMatrixMultNOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestPMVMatrix02NEWT $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix02NOUI $* +#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectFloatNOUI $* +#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectDoubleNOUI $* +#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* @@ -376,7 +380,6 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -#testnoawt com.jogamp.opengl.test.junit.jogl.glu.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java deleted file mode 100644 index adeb700d7..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFloatUtil01MatrixMatrixMultNOUI.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.opengl.math.FloatUtil; - -public class TestFloatUtil01MatrixMatrixMultNOUI { - - final float[] m1 = new float[]{ 1, 3, 4, 0, - 6, 7, 8, 5, - 98, 7, 6, 9, - 54, 3, 2, 5 }; - - final float[] m2 = new float[]{ 1, 6, 98, 54, - 3, 7, 7, 3, - 4, 8, 6, 2, - 0, 5, 9, 5 }; - - final float[] m1xm2_RM = // m2xm1_CM - new float[]{ 26, 59, 143, 71, - 59, 174, 730, 386, - 143, 730, 9770, 5370, - 71, 386, 5370, 2954 }; - - final float[] m2xm1_RM = // m1xm2_CM - new float[]{12557, 893, 748, 1182, - 893, 116, 116, 113, - 748, 116, 120, 104, - 1182, 113, 104, 131 }; - - public static final void multMatrixf_RM(final float[] a, int a_off, final float[] b, int b_off, float[] d, int d_off) { - for (int i = 0; i < 4; i++) { - final float ai0=a[a_off+i*4+0], ai1=a[a_off+i*4+1], ai2=a[a_off+i*4+2], ai3=a[a_off+i*4+3]; - d[d_off+i*4+0] = ai0 * b[b_off+0*4+0] + ai1 * b[b_off+1*4+0] + ai2 * b[b_off+2*4+0] + ai3 * b[b_off+3*4+0] ; - d[d_off+i*4+1] = ai0 * b[b_off+0*4+1] + ai1 * b[b_off+1*4+1] + ai2 * b[b_off+2*4+1] + ai3 * b[b_off+3*4+1] ; - d[d_off+i*4+2] = ai0 * b[b_off+0*4+2] + ai1 * b[b_off+1*4+2] + ai2 * b[b_off+2*4+2] + ai3 * b[b_off+3*4+2] ; - d[d_off+i*4+3] = ai0 * b[b_off+0*4+3] + ai1 * b[b_off+1*4+3] + ai2 * b[b_off+2*4+3] + ai3 * b[b_off+3*4+3] ; - } - } - - @Test - public void testCM_m1xm2(){ - - float[] r = new float[16]; - - FloatUtil.multMatrixf(m1, 0, m2, 0, r, 0); - - Assert.assertArrayEquals(m2xm1_RM, r, 0f); - } - - @Test - public void testCM_m2xm1(){ - - float[] r = new float[16]; - - FloatUtil.multMatrixf(m2, 0, m1, 0, r, 0); - - Assert.assertArrayEquals(m1xm2_RM, r, 0f); - } - - @Test - public void testRM_m1xm2(){ - - float[] r = new float[16]; - - multMatrixf_RM(m1, 0, m2, 0, r, 0); - - Assert.assertArrayEquals(m1xm2_RM, r, 0f); - } - - @Test - public void testRM_m2xm1(){ - - float[] r = new float[16]; - - multMatrixf_RM(m2, 0, m1, 0, r, 0); - - Assert.assertArrayEquals(m2xm1_RM, r, 0f); - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestFloatUtil01MatrixMatrixMultNOUI.class.getName()); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java deleted file mode 100644 index c99bac9a4..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix01NEWT.java +++ /dev/null @@ -1,466 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.nio.FloatBuffer; - -import javax.media.opengl.GL2ES1; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLProfile; -import javax.media.opengl.fixedfunc.GLMatrixFunc; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.common.os.Platform; -import com.jogamp.opengl.math.FloatUtil; -import com.jogamp.opengl.math.geom.Frustum; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.PMVMatrix; - -public class TestPMVMatrix01NEWT extends UITestCase { - - static final float epsilon = 0.00001f; - - // matrix 2 rows x 3 columns - In row major order - static FloatBuffer matrix2x3R = FloatBuffer.wrap( new float[] { 1.0f, 2.0f, 3.0f, - 4.0f, 5.0f, 6.0f } ); - - // matrix 2 rows x 3 columns - In column major order - static FloatBuffer matrix2x3C = FloatBuffer.wrap( new float[] { 1.0f, 4.0f, - 2.0f, 5.0f, - 3.0f, 6.0f } ); - - // matrix 3 rows x 2 columns - In row major order - static FloatBuffer matrix3x2R = FloatBuffer.wrap( new float[] { 1.0f, 2.0f, - 3.0f, 4.0f, - 5.0f, 6.0f } ); - - // matrix 3 rows x 2 columns - In column major order - static FloatBuffer matrix3x2C = FloatBuffer.wrap( new float[] { 1.0f, 3.0f, 5.0f, - 2.0f, 4.0f, 6.0f } ); - - // Translated xyz 123 - Row - In row major order ! - static FloatBuffer translated123R = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 1.0f, - 0.0f, 1.0f, 0.0f, 2.0f, - 0.0f, 0.0f, 1.0f, 3.0f, - 0.0f, 0.0f, 0.0f, 1.0f } ); - - // Translated xyz 123 - Column - In column major order ! - static FloatBuffer translated123C = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 1.0f, 2.0f, 3.0f, 1.0f } ); - - // Translated xyz 123 - Inverse - In column major order ! - static FloatBuffer translated123I = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - -1.0f, -2.0f, -3.0f, 1.0f } ); - - // Translated xyz 123 - Inverse and Transposed - In column major order ! - static FloatBuffer translated123IT = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, -1.0f, - 0.0f, 1.0f, 0.0f, -2.0f, - 0.0f, 0.0f, 1.0f, -3.0f, - 0.0f, 0.0f, 0.0f, 1.0f } ); - - @Test - public void test00MatrixToString() { - final String s4x4Cpmv = PMVMatrix.matrixToString(null, "%10.5f", translated123C).toString(); - final String s4x4Cflu = FloatUtil.matrixToString(null, null, "%10.5f", translated123C, 0, 4, 4, false).toString(); - final String s4x4Rflu = FloatUtil.matrixToString(null, null, "%10.5f", translated123R, 0, 4, 4, true).toString(); - System.err.println("PMV-C-O 4x4: "); - System.err.println(s4x4Cpmv); - System.err.println(); - System.err.println("FLU-C-O 4x4: "); - System.err.println(s4x4Cflu); - System.err.println(); - System.err.println("FLU-R-O 4x4: "); - System.err.println(s4x4Rflu); - System.err.println(); - Assert.assertEquals(s4x4Cpmv, s4x4Cflu); - Assert.assertEquals(s4x4Cflu, s4x4Rflu); - - final String s2x3Rflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix2x3R, 0, 2, 3, true).toString(); - final String s2x3Cflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix2x3C, 0, 2, 3, false).toString(); - System.err.println("FLU-R-O 2x3: "); - System.err.println(s2x3Rflu); - System.err.println(); - System.err.println("FLU-C-O 2x3: "); - System.err.println(s2x3Cflu); - System.err.println(); - Assert.assertEquals(s2x3Cflu, s2x3Rflu); - - final String s3x2Rflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix3x2R, 0, 3, 2, true).toString(); - final String s3x2Cflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix3x2C, 0, 3, 2, false).toString(); - System.err.println("FLU-R-O 3x2: "); - System.err.println(s3x2Rflu); - System.err.println(); - System.err.println("FLU-C-O 3x2: "); - System.err.println(s3x2Cflu); - System.err.println(); - Assert.assertEquals(s3x2Cflu, s3x2Rflu); - } - - /** - * Test using traditional access workflow, i.e. 1) operation 2) get-matrix references - *

    - * The Mvi, Mvit and Frustum dirty-bits and request-mask will be validated. - *

    - */ - @SuppressWarnings("deprecation") - @Test - public void test01MviUpdateTraditionalAccess() { - FloatBuffer p, mv, mvi, mvit; - Frustum frustum; - boolean b; - final PMVMatrix pmv = new PMVMatrix(true); - // System.err.println("P0: "+pmv.toString()); - - Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); - - // - // Action #0 - // - final FloatBuffer ident; - { - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glLoadIdentity(); - ident = pmv.glGetPMatrixf(); - - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - } - Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test - Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); - - // - // Action #1 - // - pmv.glTranslatef(1f, 2f, 3f); // all dirty ! - Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test - Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); - // System.err.println("P1: "+pmv.toString()); - - b = pmv.update(); // will not clean dirty bits, since no request has been made -> false - Assert.assertEquals("Update has been perfomed, but non requested", false, b); - Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); - // System.err.println("P2: "+pmv.toString()); - - // - // Get - // - p = pmv.glGetPMatrixf(); - MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); - mv = pmv.glGetMvMatrixf(); - MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString(), translated123C, mv, epsilon); - mvi = pmv.glGetMviMatrixf(); - MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString(), translated123I, mvi, epsilon); - Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask()); - Assert.assertEquals("Remaining dirty bits not Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - - frustum = pmv.glGetFrustum(); - Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! - Assert.assertEquals("Remaining dirty bits not Mvit, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); - // System.err.println("P3: "+pmv.toString()); - - mvit = pmv.glGetMvitMatrixf(); - MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); - Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); - // System.err.println("P4: "+pmv.toString()); - - // - // Action #2 - // - pmv.glLoadIdentity(); // all dirty - Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test - Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); - MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); - MiscUtils.assertFloatBufferEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon); - MiscUtils.assertFloatBufferNotEqual("Mvi already identity w/o update, "+pmv.toString(), ident, mvi, epsilon); - MiscUtils.assertFloatBufferNotEqual("Mvit already identity w/o update, "+pmv.toString(), ident, mvit, epsilon); - MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); - MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); - Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! - - b = pmv.update(); // will clean dirty bits, since request has been made -> true - Assert.assertEquals("Update has not been perfomed, but requested", true, b); - Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); - MiscUtils.assertFloatBufferEquals("Mvi not identity after update, "+pmv.toString(), ident, mvi, epsilon); - MiscUtils.assertFloatBufferEquals("Mvit not identity after update, "+pmv.toString(), ident, mvit, epsilon); - Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! - } - - /** - * Test using shader access workflow, i.e. 1) get-matrix references 2) operations - *

    - * The Mvi, Mvit and Frustum dirty-bits and request-mask will be validated. - *

    - */ - @SuppressWarnings("deprecation") - @Test - public void test02MviUpdateShaderAccess() { - final FloatBuffer p, mv, mvi, mvit; - Frustum frustum; - boolean b; - final PMVMatrix pmv = new PMVMatrix(true); - // System.err.println("P0: "+pmv.toString()); - - Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); - - // - // Action #0 - // - final FloatBuffer ident; - { - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glLoadIdentity(); - ident = pmv.glGetPMatrixf(); - - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - } - // System.err.println("P0: "+pmv.toString()); - Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test - Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); - // System.err.println("P1: "+pmv.toString()); - - // - // Get - // - p = pmv.glGetPMatrixf(); - MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); - mv = pmv.glGetMvMatrixf(); - MiscUtils.assertFloatBufferEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon); - Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); - - mvi = pmv.glGetMviMatrixf(); - MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvi, epsilon); - Assert.assertEquals("Remaining dirty bits not Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask()); - - mvit = pmv.glGetMvitMatrixf(); - MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvit, epsilon); - Assert.assertEquals("Remaining dirty bits not Frustum, "+pmv.toString(), PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); - - frustum = pmv.glGetFrustum(); - Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! - Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); - - // - // Action #1 - // - pmv.glTranslatef(1f, 2f, 3f); // all dirty ! - Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test - Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); - Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); - MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString()+pmv.toString(), ident, p, epsilon); - MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString()+pmv.toString(), translated123C, mv, epsilon); - MiscUtils.assertFloatBufferNotEqual("Mvi already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); - MiscUtils.assertFloatBufferNotEqual("Mvit already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); - MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString()+pmv.toString(), ident, mvi, epsilon); - MiscUtils.assertFloatBufferEquals("Mvit not identity, "+pmv.toString()+pmv.toString(), ident, mvit, epsilon); - Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! - - b = pmv.update(); // will clean dirty bits, since all requests has been made -> true - Assert.assertEquals("Update has not been perfomed, but requested", true, b); - Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); - Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); - MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); - MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); - // System.err.println("P2: "+pmv.toString()); - } - - @SuppressWarnings("unused") - @Test - public void test03MvTranslate() { - final FloatBuffer pmvMv, pmvMvi, pmvMvit; - { - final PMVMatrix pmv = new PMVMatrix(true); - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glLoadIdentity(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(5f, 6f, 7f); - - pmvMv = pmv.glGetMvMatrixf(); - pmvMvi = pmv.glGetMviMatrixf(); - pmvMvit = pmv.glGetMvitMatrixf(); - } - - final FloatBuffer glMv = FloatBuffer.allocate(16); - { - GL2ES1 gl = dc.glc.getGL().getGL2ES1(); - gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - gl.glLoadIdentity(); - gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - gl.glLoadIdentity(); - gl.glTranslatef(5f, 6f, 7f); - - gl.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, glMv); - } - // System.err.println(PMVMatrix.matrixToString(null, "%10.5f", glMv, pmvMv).toString()); - - MiscUtils.assertFloatBufferEquals("Arrays not equal, expected"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", glMv).toString()+ - ", actual"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMv).toString(), - glMv, pmvMv, epsilon); - - // System.err.println("pmvMvi: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvi)); - // System.err.println("pmvMvit: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvit)); - } - - @SuppressWarnings("unused") - @Test - public void test04MvTranslateRotate() { - final FloatBuffer pmvMv, pmvMvi, pmvMvit; - { - final PMVMatrix pmv = new PMVMatrix(true); - pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmv.glLoadIdentity(); - pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmv.glLoadIdentity(); - pmv.glTranslatef(5f, 6f, 7f); - pmv.glRotatef(90f, 1f, 0f, 0f); - - pmvMv = pmv.glGetMvMatrixf(); - pmvMvi = pmv.glGetMviMatrixf(); - pmvMvit = pmv.glGetMvitMatrixf(); - } - - final FloatBuffer glMv = FloatBuffer.allocate(16); - { - GL2ES1 gl = dc.glc.getGL().getGL2ES1(); - gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - gl.glLoadIdentity(); - gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - gl.glLoadIdentity(); - gl.glTranslatef(5f, 6f, 7f); - gl.glRotatef(90f, 1f, 0f, 0f); - - gl.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, glMv); - } - // System.err.println(PMVMatrix.matrixToString(null, "%10.5f", glMv, pmvMv).toString()); - - MiscUtils.assertFloatBufferEquals("Arrays not equal, expected"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", glMv).toString()+ - ", actual"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMv).toString(), - glMv, pmvMv, epsilon); - - // System.err.println("pmvMvi: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvi)); - // System.err.println("pmvMvit: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvit)); - } - - static DrawableContext dc; - - @BeforeClass - public static void setup() throws Throwable { - try { - dc = createOffscreenDrawableAndCurrentFFPContext(); - } catch (Throwable t) { - setTestSupported(false); - throw t; - } - } - - @AfterClass - public static void cleanup() { - destroyDrawableContext(dc); - } - - static class DrawableContext { - DrawableContext(GLDrawable d, GLContext glc) { - this.d = d; - this.glc = glc; - } - GLDrawable d; - GLContext glc; - } - - private static DrawableContext createOffscreenDrawableAndCurrentFFPContext() throws Throwable { - GLProfile glp = GLProfile.getMaxFixedFunc(true); - GLCapabilities glCaps = new GLCapabilities(glp); - glCaps.setOnscreen(false); - glCaps.setPBuffer(true); - GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - GLDrawable d = factory.createOffscreenDrawable(null, glCaps, null, 64, 64); - d.setRealized(true); - GLContext glc = null; - try { - glc = d.createContext(null); - Assert.assertTrue("Context could not be made current", GLContext.CONTEXT_NOT_CURRENT < glc.makeCurrent()); - return new DrawableContext(d, glc); - } catch (Throwable t) { - if(null != glc) { - glc.destroy(); - } - d.setRealized(false); - throw t; - } - } - - private static void destroyDrawableContext(DrawableContext dc) { - if(null != dc.glc) { - dc.glc.destroy(); - dc.glc = null; - } - if(null != dc.d) { - dc.d.setRealized(false); - dc.d = null; - } - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestPMVMatrix01NEWT.class.getName()); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java deleted file mode 100644 index 4e959d460..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestPMVMatrix02NEWT.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.acore; - -import org.junit.Before; -import org.junit.Test; - -import com.jogamp.opengl.util.PMVMatrix; - -import javax.media.opengl.fixedfunc.GLMatrixFunc; -import java.nio.FloatBuffer; - -import static org.junit.Assert.assertArrayEquals; - -/** - * @author Thomas De Bodt - */ -public class TestPMVMatrix02NEWT { - - private PMVMatrix fMat; - - @Before - public void setUp() throws Exception { - fMat = new PMVMatrix(); - } - - @Test - public void testLookAtNegZIsNoOp() throws Exception { - fMat.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - // Look towards -z - fMat.gluLookAt( - 0, 0, 0, - 0, 0, -1, - 0, 1, 0 - ); - FloatBuffer mvMatrix = fMat.glGetMvMatrixf(); - float[] mvMatrixArr = new float[16]; - mvMatrix.asReadOnlyBuffer().get(mvMatrixArr); - assertArrayEquals( - /** - * The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward. - */ - new float[] { - 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 - }, - mvMatrixArr, - 1e-6f - ); - } - @Test - public void testLookAtPosY() throws Exception { - fMat.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - // Look towards +y - fMat.gluLookAt( - 0, 0, 0, - 0, 1, 0, - 0, 0, 1 - ); - FloatBuffer mvMatrix = fMat.glGetMvMatrixf(); - float[] mvMatrixArr = new float[16]; - mvMatrix.asReadOnlyBuffer().get(mvMatrixArr); - assertArrayEquals( - /** - * The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward. - */ - new float[] { - 1, 0, 0, 0, - 0, 0, -1, 0, - 0, 1, 0, 0, - 0, 0, 0, 1 - }, - mvMatrixArr, - 1e-6f - ); - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestPMVMatrix02NEWT.class.getName()); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java deleted file mode 100644 index 34b30f04e..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectDoubleNOUI.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.glu; - -import javax.media.opengl.glu.GLU; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Julien Gouesse - */ -public class TestGluUnprojectDoubleNOUI { - - @Test - public void test(){ - final GLU glu = new GLU(); - final int[] pickedPoint = new int[]{400,300}; - final double pickedPointDepth = 0; - final double[] sceneModelViewValues = new double[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; - final double[] projectionValues = new double[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; - final int[] viewport = new int[]{0,0,800,600}; - final double[] objCoords = new double[]{Double.NaN,Double.NaN,Double.NaN}; - glu.gluUnProject(pickedPoint[0], pickedPoint[1], pickedPointDepth, sceneModelViewValues, 0, projectionValues, 0, viewport, 0, objCoords, 0); - Assert.assertTrue(!Double.isNaN(objCoords[0])&&!Double.isNaN(objCoords[1])&&!Double.isNaN(objCoords[2])); - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestGluUnprojectDoubleNOUI.class.getName()); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java deleted file mode 100644 index 717d5e4b8..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestGluUnprojectFloatNOUI.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.glu; - -import javax.media.opengl.glu.GLU; - -import org.junit.Assert; -import org.junit.Test; - -public class TestGluUnprojectFloatNOUI { - - @Test - public void testNaN(){ - final GLU glu = new GLU(); - final int[] pickedPoint = new int[]{400,300}; - final float pickedPointDepth = 0; - final float[] sceneModelViewValues = new float[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; - final float[] projectionValues = new float[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; - final int[] viewport = new int[]{0,0,800,600}; - final float[] objCoords = new float[]{Float.NaN,Float.NaN,Float.NaN}; - glu.gluUnProject(pickedPoint[0], pickedPoint[1], pickedPointDepth, sceneModelViewValues, 0, projectionValues, 0, viewport, 0, objCoords, 0); - Assert.assertTrue(!Double.isNaN(objCoords[0])&&!Double.isNaN(objCoords[1])&&!Double.isNaN(objCoords[2])); - } - - @Test - public void test01(){ - float[] mv = new float[] { 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1 }; - - float[] p = new float[] { 2.3464675f, 0, 0, 0, - 0, 2.4142134f, 0, 0, - 0, 0, -1.0002f, -1, - 0, 0, -20.002f, 0 }; - - int[] v = new int[] { 0, 0, 1000, 1000 }; - - float[] s = new float[] { 250, 250, 0.5f }; - - float[] expected = new float[] { -4.2612f, -4.1417f, -19.9980f }; - float[] result = new float[] { 0, 0, 0 }; - - final GLU glu = new GLU(); - glu.gluUnProject(s[0], s[1], s[2], mv, 0, p, 0, v, 0, result, 0); - - Assert.assertArrayEquals(expected, result, 0.0001f); - } - - @Test - public void test02(){ - float[] mv = new float[] { 1, 0, 0, 0, - 0, 1, 0, 0, - 0, 0, 1, 0, - 0, 0, -200, 1 } ; - - float[] p = new float[] { 2.3464675f, 0, 0, 0, - 0, 2.4142134f, 0, 0, - 0, 0, -1.0002f, -1, - 0, 0, -20.002f, 0 }; - - int[] v = new int[] { 0, 0, 1000, 1000 }; - - float[] s = new float[] { 250, 250, 0.5f }; - float[] expected = new float[] { -4.2612f, -4.1417f, 180.002f }; - float[] result = new float[] { 0, 0, 0 }; - - final GLU glu = new GLU(); - glu.gluUnProject(s[0], s[1], s[2], mv, 0, p, 0, v, 0, result, 0); - - Assert.assertArrayEquals(expected, result, 0.0001f); - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestGluUnprojectFloatNOUI.class.getName()); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01MatrixMatrixMultNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01MatrixMatrixMultNOUI.java new file mode 100644 index 000000000..83a1be456 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestFloatUtil01MatrixMatrixMultNOUI.java @@ -0,0 +1,113 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.math; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.opengl.math.FloatUtil; + +public class TestFloatUtil01MatrixMatrixMultNOUI { + + final float[] m1 = new float[]{ 1, 3, 4, 0, + 6, 7, 8, 5, + 98, 7, 6, 9, + 54, 3, 2, 5 }; + + final float[] m2 = new float[]{ 1, 6, 98, 54, + 3, 7, 7, 3, + 4, 8, 6, 2, + 0, 5, 9, 5 }; + + final float[] m1xm2_RM = // m2xm1_CM + new float[]{ 26, 59, 143, 71, + 59, 174, 730, 386, + 143, 730, 9770, 5370, + 71, 386, 5370, 2954 }; + + final float[] m2xm1_RM = // m1xm2_CM + new float[]{12557, 893, 748, 1182, + 893, 116, 116, 113, + 748, 116, 120, 104, + 1182, 113, 104, 131 }; + + public static final void multMatrixf_RM(final float[] a, int a_off, final float[] b, int b_off, float[] d, int d_off) { + for (int i = 0; i < 4; i++) { + final float ai0=a[a_off+i*4+0], ai1=a[a_off+i*4+1], ai2=a[a_off+i*4+2], ai3=a[a_off+i*4+3]; + d[d_off+i*4+0] = ai0 * b[b_off+0*4+0] + ai1 * b[b_off+1*4+0] + ai2 * b[b_off+2*4+0] + ai3 * b[b_off+3*4+0] ; + d[d_off+i*4+1] = ai0 * b[b_off+0*4+1] + ai1 * b[b_off+1*4+1] + ai2 * b[b_off+2*4+1] + ai3 * b[b_off+3*4+1] ; + d[d_off+i*4+2] = ai0 * b[b_off+0*4+2] + ai1 * b[b_off+1*4+2] + ai2 * b[b_off+2*4+2] + ai3 * b[b_off+3*4+2] ; + d[d_off+i*4+3] = ai0 * b[b_off+0*4+3] + ai1 * b[b_off+1*4+3] + ai2 * b[b_off+2*4+3] + ai3 * b[b_off+3*4+3] ; + } + } + + @Test + public void testCM_m1xm2(){ + + float[] r = new float[16]; + + FloatUtil.multMatrixf(m1, 0, m2, 0, r, 0); + + Assert.assertArrayEquals(m2xm1_RM, r, 0f); + } + + @Test + public void testCM_m2xm1(){ + + float[] r = new float[16]; + + FloatUtil.multMatrixf(m2, 0, m1, 0, r, 0); + + Assert.assertArrayEquals(m1xm2_RM, r, 0f); + } + + @Test + public void testRM_m1xm2(){ + + float[] r = new float[16]; + + multMatrixf_RM(m1, 0, m2, 0, r, 0); + + Assert.assertArrayEquals(m1xm2_RM, r, 0f); + } + + @Test + public void testRM_m2xm1(){ + + float[] r = new float[16]; + + multMatrixf_RM(m2, 0, m1, 0, r, 0); + + Assert.assertArrayEquals(m2xm1_RM, r, 0f); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestFloatUtil01MatrixMatrixMultNOUI.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java new file mode 100644 index 000000000..32861f764 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectDoubleNOUI.java @@ -0,0 +1,57 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.math; + +import javax.media.opengl.glu.GLU; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Julien Gouesse + */ +public class TestGluUnprojectDoubleNOUI { + + @Test + public void test(){ + final GLU glu = new GLU(); + final int[] pickedPoint = new int[]{400,300}; + final double pickedPointDepth = 0; + final double[] sceneModelViewValues = new double[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; + final double[] projectionValues = new double[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; + final int[] viewport = new int[]{0,0,800,600}; + final double[] objCoords = new double[]{Double.NaN,Double.NaN,Double.NaN}; + glu.gluUnProject(pickedPoint[0], pickedPoint[1], pickedPointDepth, sceneModelViewValues, 0, projectionValues, 0, viewport, 0, objCoords, 0); + Assert.assertTrue(!Double.isNaN(objCoords[0])&&!Double.isNaN(objCoords[1])&&!Double.isNaN(objCoords[2])); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestGluUnprojectDoubleNOUI.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java new file mode 100644 index 000000000..9951500fc --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestGluUnprojectFloatNOUI.java @@ -0,0 +1,103 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.math; + +import javax.media.opengl.glu.GLU; + +import org.junit.Assert; +import org.junit.Test; + +public class TestGluUnprojectFloatNOUI { + + @Test + public void testNaN(){ + final GLU glu = new GLU(); + final int[] pickedPoint = new int[]{400,300}; + final float pickedPointDepth = 0; + final float[] sceneModelViewValues = new float[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; + final float[] projectionValues = new float[]{1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; + final int[] viewport = new int[]{0,0,800,600}; + final float[] objCoords = new float[]{Float.NaN,Float.NaN,Float.NaN}; + glu.gluUnProject(pickedPoint[0], pickedPoint[1], pickedPointDepth, sceneModelViewValues, 0, projectionValues, 0, viewport, 0, objCoords, 0); + Assert.assertTrue(!Double.isNaN(objCoords[0])&&!Double.isNaN(objCoords[1])&&!Double.isNaN(objCoords[2])); + } + + @Test + public void test01(){ + float[] mv = new float[] { 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 }; + + float[] p = new float[] { 2.3464675f, 0, 0, 0, + 0, 2.4142134f, 0, 0, + 0, 0, -1.0002f, -1, + 0, 0, -20.002f, 0 }; + + int[] v = new int[] { 0, 0, 1000, 1000 }; + + float[] s = new float[] { 250, 250, 0.5f }; + + float[] expected = new float[] { -4.2612f, -4.1417f, -19.9980f }; + float[] result = new float[] { 0, 0, 0 }; + + final GLU glu = new GLU(); + glu.gluUnProject(s[0], s[1], s[2], mv, 0, p, 0, v, 0, result, 0); + + Assert.assertArrayEquals(expected, result, 0.0001f); + } + + @Test + public void test02(){ + float[] mv = new float[] { 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, -200, 1 } ; + + float[] p = new float[] { 2.3464675f, 0, 0, 0, + 0, 2.4142134f, 0, 0, + 0, 0, -1.0002f, -1, + 0, 0, -20.002f, 0 }; + + int[] v = new int[] { 0, 0, 1000, 1000 }; + + float[] s = new float[] { 250, 250, 0.5f }; + float[] expected = new float[] { -4.2612f, -4.1417f, 180.002f }; + float[] result = new float[] { 0, 0, 0 }; + + final GLU glu = new GLU(); + glu.gluUnProject(s[0], s[1], s[2], mv, 0, p, 0, v, 0, result, 0); + + Assert.assertArrayEquals(expected, result, 0.0001f); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestGluUnprojectFloatNOUI.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java new file mode 100644 index 000000000..3d9bfed7e --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix01NEWT.java @@ -0,0 +1,466 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.math; + +import java.nio.FloatBuffer; + +import javax.media.opengl.GL2ES1; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; +import javax.media.opengl.fixedfunc.GLMatrixFunc; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.os.Platform; +import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.math.geom.Frustum; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.PMVMatrix; + +public class TestPMVMatrix01NEWT extends UITestCase { + + static final float epsilon = 0.00001f; + + // matrix 2 rows x 3 columns - In row major order + static FloatBuffer matrix2x3R = FloatBuffer.wrap( new float[] { 1.0f, 2.0f, 3.0f, + 4.0f, 5.0f, 6.0f } ); + + // matrix 2 rows x 3 columns - In column major order + static FloatBuffer matrix2x3C = FloatBuffer.wrap( new float[] { 1.0f, 4.0f, + 2.0f, 5.0f, + 3.0f, 6.0f } ); + + // matrix 3 rows x 2 columns - In row major order + static FloatBuffer matrix3x2R = FloatBuffer.wrap( new float[] { 1.0f, 2.0f, + 3.0f, 4.0f, + 5.0f, 6.0f } ); + + // matrix 3 rows x 2 columns - In column major order + static FloatBuffer matrix3x2C = FloatBuffer.wrap( new float[] { 1.0f, 3.0f, 5.0f, + 2.0f, 4.0f, 6.0f } ); + + // Translated xyz 123 - Row - In row major order ! + static FloatBuffer translated123R = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 1.0f, + 0.0f, 1.0f, 0.0f, 2.0f, + 0.0f, 0.0f, 1.0f, 3.0f, + 0.0f, 0.0f, 0.0f, 1.0f } ); + + // Translated xyz 123 - Column - In column major order ! + static FloatBuffer translated123C = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 2.0f, 3.0f, 1.0f } ); + + // Translated xyz 123 - Inverse - In column major order ! + static FloatBuffer translated123I = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 1.0f, 0.0f, + -1.0f, -2.0f, -3.0f, 1.0f } ); + + // Translated xyz 123 - Inverse and Transposed - In column major order ! + static FloatBuffer translated123IT = FloatBuffer.wrap( new float[] { 1.0f, 0.0f, 0.0f, -1.0f, + 0.0f, 1.0f, 0.0f, -2.0f, + 0.0f, 0.0f, 1.0f, -3.0f, + 0.0f, 0.0f, 0.0f, 1.0f } ); + + @Test + public void test00MatrixToString() { + final String s4x4Cpmv = PMVMatrix.matrixToString(null, "%10.5f", translated123C).toString(); + final String s4x4Cflu = FloatUtil.matrixToString(null, null, "%10.5f", translated123C, 0, 4, 4, false).toString(); + final String s4x4Rflu = FloatUtil.matrixToString(null, null, "%10.5f", translated123R, 0, 4, 4, true).toString(); + System.err.println("PMV-C-O 4x4: "); + System.err.println(s4x4Cpmv); + System.err.println(); + System.err.println("FLU-C-O 4x4: "); + System.err.println(s4x4Cflu); + System.err.println(); + System.err.println("FLU-R-O 4x4: "); + System.err.println(s4x4Rflu); + System.err.println(); + Assert.assertEquals(s4x4Cpmv, s4x4Cflu); + Assert.assertEquals(s4x4Cflu, s4x4Rflu); + + final String s2x3Rflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix2x3R, 0, 2, 3, true).toString(); + final String s2x3Cflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix2x3C, 0, 2, 3, false).toString(); + System.err.println("FLU-R-O 2x3: "); + System.err.println(s2x3Rflu); + System.err.println(); + System.err.println("FLU-C-O 2x3: "); + System.err.println(s2x3Cflu); + System.err.println(); + Assert.assertEquals(s2x3Cflu, s2x3Rflu); + + final String s3x2Rflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix3x2R, 0, 3, 2, true).toString(); + final String s3x2Cflu = FloatUtil.matrixToString(null, null, "%10.5f", matrix3x2C, 0, 3, 2, false).toString(); + System.err.println("FLU-R-O 3x2: "); + System.err.println(s3x2Rflu); + System.err.println(); + System.err.println("FLU-C-O 3x2: "); + System.err.println(s3x2Cflu); + System.err.println(); + Assert.assertEquals(s3x2Cflu, s3x2Rflu); + } + + /** + * Test using traditional access workflow, i.e. 1) operation 2) get-matrix references + *

    + * The Mvi, Mvit and Frustum dirty-bits and request-mask will be validated. + *

    + */ + @SuppressWarnings("deprecation") + @Test + public void test01MviUpdateTraditionalAccess() { + FloatBuffer p, mv, mvi, mvit; + Frustum frustum; + boolean b; + final PMVMatrix pmv = new PMVMatrix(true); + // System.err.println("P0: "+pmv.toString()); + + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + + // + // Action #0 + // + final FloatBuffer ident; + { + pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmv.glLoadIdentity(); + ident = pmv.glGetPMatrixf(); + + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + } + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + + // + // Action #1 + // + pmv.glTranslatef(1f, 2f, 3f); // all dirty ! + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + // System.err.println("P1: "+pmv.toString()); + + b = pmv.update(); // will not clean dirty bits, since no request has been made -> false + Assert.assertEquals("Update has been perfomed, but non requested", false, b); + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + // System.err.println("P2: "+pmv.toString()); + + // + // Get + // + p = pmv.glGetPMatrixf(); + MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); + mv = pmv.glGetMvMatrixf(); + MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString(), translated123C, mv, epsilon); + mvi = pmv.glGetMviMatrixf(); + MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString(), translated123I, mvi, epsilon); + Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask()); + Assert.assertEquals("Remaining dirty bits not Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + + frustum = pmv.glGetFrustum(); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! + Assert.assertEquals("Remaining dirty bits not Mvit, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); + // System.err.println("P3: "+pmv.toString()); + + mvit = pmv.glGetMvitMatrixf(); + MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); + Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); + // System.err.println("P4: "+pmv.toString()); + + // + // Action #2 + // + pmv.glLoadIdentity(); // all dirty + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); + MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); + MiscUtils.assertFloatBufferEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon); + MiscUtils.assertFloatBufferNotEqual("Mvi already identity w/o update, "+pmv.toString(), ident, mvi, epsilon); + MiscUtils.assertFloatBufferNotEqual("Mvit already identity w/o update, "+pmv.toString(), ident, mvit, epsilon); + MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); + MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! + + b = pmv.update(); // will clean dirty bits, since request has been made -> true + Assert.assertEquals("Update has not been perfomed, but requested", true, b); + Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); + MiscUtils.assertFloatBufferEquals("Mvi not identity after update, "+pmv.toString(), ident, mvi, epsilon); + MiscUtils.assertFloatBufferEquals("Mvit not identity after update, "+pmv.toString(), ident, mvit, epsilon); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! + } + + /** + * Test using shader access workflow, i.e. 1) get-matrix references 2) operations + *

    + * The Mvi, Mvit and Frustum dirty-bits and request-mask will be validated. + *

    + */ + @SuppressWarnings("deprecation") + @Test + public void test02MviUpdateShaderAccess() { + final FloatBuffer p, mv, mvi, mvit; + Frustum frustum; + boolean b; + final PMVMatrix pmv = new PMVMatrix(true); + // System.err.println("P0: "+pmv.toString()); + + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + + // + // Action #0 + // + final FloatBuffer ident; + { + pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmv.glLoadIdentity(); + ident = pmv.glGetPMatrixf(); + + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + } + // System.err.println("P0: "+pmv.toString()); + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + // System.err.println("P1: "+pmv.toString()); + + // + // Get + // + p = pmv.glGetPMatrixf(); + MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString(), ident, p, epsilon); + mv = pmv.glGetMvMatrixf(); + MiscUtils.assertFloatBufferEquals("Mv not identity, "+pmv.toString(), ident, mv, epsilon); + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Request bits not zero, "+pmv.toString(), 0, pmv.getRequestMask()); + + mvi = pmv.glGetMviMatrixf(); + MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvi, epsilon); + Assert.assertEquals("Remaining dirty bits not Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bit Mvi not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW, pmv.getRequestMask()); + + mvit = pmv.glGetMvitMatrixf(); + MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString(), ident, mvit, epsilon); + Assert.assertEquals("Remaining dirty bits not Frustum, "+pmv.toString(), PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi and Mvit not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW, pmv.getRequestMask()); + + frustum = pmv.glGetFrustum(); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! + Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); + + // + // Action #1 + // + pmv.glTranslatef(1f, 2f, 3f); // all dirty ! + Assert.assertTrue("Modified bits zero", 0 != pmv.getModifiedBits(true)); // clear & test + Assert.assertTrue("Dirty bits clean, "+pmv.toString(), 0 != pmv.getDirtyBits()); + Assert.assertEquals("Remaining dirty bits not Mvi|Mvit|Frustum, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW|PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getDirtyBits()); + MiscUtils.assertFloatBufferEquals("P not identity, "+pmv.toString()+pmv.toString(), ident, p, epsilon); + MiscUtils.assertFloatBufferEquals("Mv not translated123, "+pmv.toString()+pmv.toString(), translated123C, mv, epsilon); + MiscUtils.assertFloatBufferNotEqual("Mvi already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); + MiscUtils.assertFloatBufferNotEqual("Mvit already translated123 w/o update, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); + MiscUtils.assertFloatBufferEquals("Mvi not identity, "+pmv.toString()+pmv.toString(), ident, mvi, epsilon); + MiscUtils.assertFloatBufferEquals("Mvit not identity, "+pmv.toString()+pmv.toString(), ident, mvit, epsilon); + Assert.assertNotNull("Frustum is null"+pmv.toString(), frustum); // FIXME: Test Frustum value! + + b = pmv.update(); // will clean dirty bits, since all requests has been made -> true + Assert.assertEquals("Update has not been perfomed, but requested", true, b); + Assert.assertTrue("Dirty bits not clean, "+pmv.toString(), 0 == pmv.getDirtyBits()); + Assert.assertEquals("Request bits Mvi|Mvit|Frustum not set, "+pmv.toString(), PMVMatrix.DIRTY_INVERSE_MODELVIEW | PMVMatrix.DIRTY_INVERSE_TRANSPOSED_MODELVIEW | PMVMatrix.DIRTY_FRUSTUM, pmv.getRequestMask()); + MiscUtils.assertFloatBufferEquals("Mvi not translated123, "+pmv.toString()+pmv.toString(), translated123I, mvi, epsilon); + MiscUtils.assertFloatBufferEquals("Mvit not translated123, "+pmv.toString()+pmv.toString(), translated123IT, mvit, epsilon); + // System.err.println("P2: "+pmv.toString()); + } + + @SuppressWarnings("unused") + @Test + public void test03MvTranslate() { + final FloatBuffer pmvMv, pmvMvi, pmvMvit; + { + final PMVMatrix pmv = new PMVMatrix(true); + pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmv.glLoadIdentity(); + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + pmv.glTranslatef(5f, 6f, 7f); + + pmvMv = pmv.glGetMvMatrixf(); + pmvMvi = pmv.glGetMviMatrixf(); + pmvMvit = pmv.glGetMvitMatrixf(); + } + + final FloatBuffer glMv = FloatBuffer.allocate(16); + { + GL2ES1 gl = dc.glc.getGL().getGL2ES1(); + gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + gl.glLoadIdentity(); + gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + gl.glLoadIdentity(); + gl.glTranslatef(5f, 6f, 7f); + + gl.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, glMv); + } + // System.err.println(PMVMatrix.matrixToString(null, "%10.5f", glMv, pmvMv).toString()); + + MiscUtils.assertFloatBufferEquals("Arrays not equal, expected"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", glMv).toString()+ + ", actual"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMv).toString(), + glMv, pmvMv, epsilon); + + // System.err.println("pmvMvi: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvi)); + // System.err.println("pmvMvit: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvit)); + } + + @SuppressWarnings("unused") + @Test + public void test04MvTranslateRotate() { + final FloatBuffer pmvMv, pmvMvi, pmvMvit; + { + final PMVMatrix pmv = new PMVMatrix(true); + pmv.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmv.glLoadIdentity(); + pmv.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmv.glLoadIdentity(); + pmv.glTranslatef(5f, 6f, 7f); + pmv.glRotatef(90f, 1f, 0f, 0f); + + pmvMv = pmv.glGetMvMatrixf(); + pmvMvi = pmv.glGetMviMatrixf(); + pmvMvit = pmv.glGetMvitMatrixf(); + } + + final FloatBuffer glMv = FloatBuffer.allocate(16); + { + GL2ES1 gl = dc.glc.getGL().getGL2ES1(); + gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + gl.glLoadIdentity(); + gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + gl.glLoadIdentity(); + gl.glTranslatef(5f, 6f, 7f); + gl.glRotatef(90f, 1f, 0f, 0f); + + gl.glGetFloatv(GLMatrixFunc.GL_MODELVIEW_MATRIX, glMv); + } + // System.err.println(PMVMatrix.matrixToString(null, "%10.5f", glMv, pmvMv).toString()); + + MiscUtils.assertFloatBufferEquals("Arrays not equal, expected"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", glMv).toString()+ + ", actual"+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMv).toString(), + glMv, pmvMv, epsilon); + + // System.err.println("pmvMvi: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvi)); + // System.err.println("pmvMvit: "+Platform.NEWLINE+PMVMatrix.matrixToString(null, "%10.5f", pmvMvit)); + } + + static DrawableContext dc; + + @BeforeClass + public static void setup() throws Throwable { + try { + dc = createOffscreenDrawableAndCurrentFFPContext(); + } catch (Throwable t) { + setTestSupported(false); + throw t; + } + } + + @AfterClass + public static void cleanup() { + destroyDrawableContext(dc); + } + + static class DrawableContext { + DrawableContext(GLDrawable d, GLContext glc) { + this.d = d; + this.glc = glc; + } + GLDrawable d; + GLContext glc; + } + + private static DrawableContext createOffscreenDrawableAndCurrentFFPContext() throws Throwable { + GLProfile glp = GLProfile.getMaxFixedFunc(true); + GLCapabilities glCaps = new GLCapabilities(glp); + glCaps.setOnscreen(false); + glCaps.setPBuffer(true); + GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); + GLDrawable d = factory.createOffscreenDrawable(null, glCaps, null, 64, 64); + d.setRealized(true); + GLContext glc = null; + try { + glc = d.createContext(null); + Assert.assertTrue("Context could not be made current", GLContext.CONTEXT_NOT_CURRENT < glc.makeCurrent()); + return new DrawableContext(d, glc); + } catch (Throwable t) { + if(null != glc) { + glc.destroy(); + } + d.setRealized(false); + throw t; + } + } + + private static void destroyDrawableContext(DrawableContext dc) { + if(null != dc.glc) { + dc.glc.destroy(); + dc.glc = null; + } + if(null != dc.d) { + dc.d.setRealized(false); + dc.d = null; + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPMVMatrix01NEWT.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java new file mode 100644 index 000000000..0c66ad237 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix02NOUI.java @@ -0,0 +1,109 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.math; + +import org.junit.Before; +import org.junit.Test; + +import com.jogamp.opengl.util.PMVMatrix; + +import javax.media.opengl.fixedfunc.GLMatrixFunc; +import java.nio.FloatBuffer; + +import static org.junit.Assert.assertArrayEquals; + +/** + * @author Thomas De Bodt + */ +public class TestPMVMatrix02NOUI { + + private PMVMatrix fMat; + + @Before + public void setUp() throws Exception { + fMat = new PMVMatrix(); + } + + @Test + public void testLookAtNegZIsNoOp() throws Exception { + fMat.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + // Look towards -z + fMat.gluLookAt( + 0, 0, 0, + 0, 0, -1, + 0, 1, 0 + ); + FloatBuffer mvMatrix = fMat.glGetMvMatrixf(); + float[] mvMatrixArr = new float[16]; + mvMatrix.asReadOnlyBuffer().get(mvMatrixArr); + assertArrayEquals( + /** + * The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward. + */ + new float[] { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + }, + mvMatrixArr, + 1e-6f + ); + } + @Test + public void testLookAtPosY() throws Exception { + fMat.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + // Look towards +y + fMat.gluLookAt( + 0, 0, 0, + 0, 1, 0, + 0, 0, 1 + ); + FloatBuffer mvMatrix = fMat.glGetMvMatrixf(); + float[] mvMatrixArr = new float[16]; + mvMatrix.asReadOnlyBuffer().get(mvMatrixArr); + assertArrayEquals( + /** + * The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward. + */ + new float[] { + 1, 0, 0, 0, + 0, 0, -1, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 + }, + mvMatrixArr, + 1e-6f + ); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPMVMatrix02NOUI.class.getName()); + } +} -- cgit v1.2.3 From 50fc55b42f791840ce1ddee943351ccc61285a84 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 9 Jun 2013 08:50:06 +0200 Subject: Fix Bug 748 - PMVMatrix gluProject and gluUnProject broken w/ backingArray (default) ; Also: Use FloatUtil in-place multMatrixf. PMVMatrix gluProject(..) and gluUnProject(..) don't pass their position (offset) to the multMatrixf operation - even though they are sliced. The API doc actually emphasizes this. --- make/scripts/tests.sh | 3 +- .../classes/com/jogamp/opengl/util/PMVMatrix.java | 24 ++-- .../test/junit/jogl/math/TestPMVMatrix03NOUI.java | 125 +++++++++++++++++++++ 3 files changed, 139 insertions(+), 13 deletions(-) mode change 100755 => 100644 make/scripts/tests.sh create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh old mode 100755 new mode 100644 index d49a0fc33..693683827 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -281,7 +281,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -312,6 +312,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix02NOUI $* +testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix03NOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectDoubleNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java index bfc03d019..58151856f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java +++ b/src/jogl/classes/com/jogamp/opengl/util/PMVMatrix.java @@ -488,7 +488,7 @@ public class PMVMatrix implements GLMatrixFunc { if(matrixGetName==GL_MATRIX_MODE) { params.put((float)matrixMode); } else { - FloatBuffer matrix = glGetMatrixf(matrixGetName); + final FloatBuffer matrix = glGetMatrixf(matrixGetName); params.put(matrix); // matrix -> params matrix.reset(); } @@ -500,7 +500,7 @@ public class PMVMatrix implements GLMatrixFunc { if(matrixGetName==GL_MATRIX_MODE) { params[params_offset]=(float)matrixMode; } else { - FloatBuffer matrix = glGetMatrixf(matrixGetName); + final FloatBuffer matrix = glGetMatrixf(matrixGetName); matrix.get(params, params_offset, 16); // matrix -> params matrix.reset(); } @@ -619,15 +619,15 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glMultMatrixf(final FloatBuffer m) { if(matrixMode==GL_MODELVIEW) { - FloatUtil.multMatrixf(matrixMv, m, matrixMv); + FloatUtil.multMatrixf(matrixMv, m); dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { - FloatUtil.multMatrixf(matrixP, m, matrixP); + FloatUtil.multMatrixf(matrixP, m); dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { - FloatUtil.multMatrixf(matrixTex, m, matrixTex); + FloatUtil.multMatrixf(matrixTex, m); modifiedBits |= MODIFIED_TEXTURE; } } @@ -635,15 +635,15 @@ public class PMVMatrix implements GLMatrixFunc { @Override public final void glMultMatrixf(float[] m, int m_offset) { if(matrixMode==GL_MODELVIEW) { - FloatUtil.multMatrixf(matrixMv, m, m_offset, matrixMv); + FloatUtil.multMatrixf(matrixMv, m, m_offset); dirtyBits |= DIRTY_INVERSE_MODELVIEW | DIRTY_INVERSE_TRANSPOSED_MODELVIEW | DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_MODELVIEW; } else if(matrixMode==GL_PROJECTION) { - FloatUtil.multMatrixf(matrixP, m, m_offset, matrixP); + FloatUtil.multMatrixf(matrixP, m, m_offset); dirtyBits |= DIRTY_FRUSTUM ; modifiedBits |= MODIFIED_PROJECTION; } else if(matrixMode==GL.GL_TEXTURE) { - FloatUtil.multMatrixf(matrixTex, m, m_offset, matrixTex); + FloatUtil.multMatrixf(matrixTex, m, m_offset); modifiedBits |= MODIFIED_TEXTURE; } } @@ -813,8 +813,8 @@ public class PMVMatrix implements GLMatrixFunc { float[] win_pos, int win_pos_offset ) { if(usesBackingArray) { return projectFloat.gluProject(objx, objy, objz, - matrixMv.array(), 0, - matrixP.array(), 0, + matrixMv.array(), matrixMv.position(), + matrixP.array(), matrixP.position(), viewport, viewport_offset, win_pos, win_pos_offset); } else { @@ -843,8 +843,8 @@ public class PMVMatrix implements GLMatrixFunc { float[] obj_pos, int obj_pos_offset) { if(usesBackingArray) { return projectFloat.gluUnProject(winx, winy, winz, - matrixMv.array(), 0, - matrixP.array(), 0, + matrixMv.array(), matrixMv.position(), + matrixP.array(), matrixP.position(), viewport, viewport_offset, obj_pos, obj_pos_offset); } else { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java new file mode 100644 index 000000000..81242ce6e --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestPMVMatrix03NOUI.java @@ -0,0 +1,125 @@ +package com.jogamp.opengl.test.junit.jogl.math; + +import java.util.Arrays; + +import jogamp.opengl.ProjectFloat; + +import com.jogamp.opengl.math.FloatUtil; +import com.jogamp.opengl.util.PMVMatrix; + +import org.junit.Assert; +import org.junit.Test; + +public class TestPMVMatrix03NOUI { + + static final float epsilon = 0.00001f; + + // Simple 10 x 10 view port + static final int[] viewport = new int[] { 0,0,10,10}; + + @Test + public void test01() { + float[] winA00 = new float[4]; + float[] winA01 = new float[4]; + float[] winA10 = new float[4]; + float[] winA11 = new float[4]; + PMVMatrix m = new PMVMatrix(); + + m.gluProject(1f, 0f, 0f, viewport, 0, winA00, 0); + System.out.println("A.0.0 - Project 1,0 -->" + Arrays.toString(winA00)); + + m.gluProject(0f, 0f, 0f, viewport, 0, winA01, 0); + System.out.println("A.0.1 - Project 0,0 -->" + Arrays.toString(winA01)); + + m.glMatrixMode(PMVMatrix.GL_PROJECTION); + m.glOrthof(0, 10, 0, 10, 1, -1); + System.out.println("MATRIX - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale"); + System.out.println(m); + float[] projMatrixA = new float[16]; + float[] modelMatrixA = new float[16]; + m.glGetFloatv(PMVMatrix.GL_PROJECTION, projMatrixA, 0); + m.glGetFloatv(PMVMatrix.GL_MODELVIEW, modelMatrixA, 0); + + m.gluProject(1f, 0f, 0f, viewport, 0, winA10, 0); + System.out.println("A.1.0 - Project 1,0 -->" +Arrays.toString(winA10)); + + m.gluProject(0f, 0f, 0f, viewport, 0, winA11, 0); + System.out.println("A.1.1 - Project 0,0 -->" +Arrays.toString(winA11)); + + + //////////////////// + ///////////////////// + + float[] winB00 = new float[4]; + float[] winB01 = new float[4]; + float[] winB10 = new float[4]; + float[] winB11 = new float[4]; + float[] projMatrixB = new float[16]; + float[] modelMatrixB = new float[16]; + FloatUtil.makeIdentityf(projMatrixB, 0); + FloatUtil.makeIdentityf(modelMatrixB, 0); + final ProjectFloat projectFloat = new ProjectFloat(true); + + projectFloat.gluProject(1f, 0f, 0f, modelMatrixB, 0, projMatrixB, 0, viewport, 0, winB00, 0); + System.out.println("B.0.0 - Project 1,0 -->" +Arrays.toString(winB00)); + + projectFloat.gluProject(0f, 0f, 0f, modelMatrixB, 0, projMatrixB, 0, viewport, 0, winB01, 0); + System.out.println("B.0.1 - Project 0,0 -->" +Arrays.toString(winB01)); + + glOrthof(projMatrixB, 0, 10, 0, 10, 1, -1); + System.out.println("FloatUtil - Ortho 0,0,10,10 - Locate the origin in the bottom left and scale"); + System.out.println("Projection"); + System.err.println(FloatUtil.matrixToString(null, null, "%10.5f", projMatrixB, 0, 4, 4, false /* rowMajorOrder */)); + System.out.println("Modelview"); + System.err.println(FloatUtil.matrixToString(null, null, "%10.5f", modelMatrixB, 0, 4, 4, false /* rowMajorOrder */)); + + projectFloat.gluProject(1f, 0f, 0f, modelMatrixB, 0, projMatrixB, 0, viewport, 0, winB10, 0); + System.out.println("B.1.0 - Project 1,0 -->" +Arrays.toString(winB10)); + + projectFloat.gluProject(0f, 0f, 0f, modelMatrixB, 0, projMatrixB, 0, viewport, 0, winB11, 0); + System.out.println("B.1.1 - Project 0,0 -->" +Arrays.toString(winB11)); + + Assert.assertArrayEquals("A/B 0.0 Project 1,0 failure", winB00, winA00, epsilon); + Assert.assertArrayEquals("A/B 0.1 Project 0,0 failure", winB01, winA01, epsilon); + Assert.assertArrayEquals("A/B 1.0 Project 1,0 failure", winB10, winA10, epsilon); + Assert.assertArrayEquals("A/B 1.1 Project 0,0 failure", winB11, winA11, epsilon); + + Assert.assertEquals("A 0.0 Project 1,0 failure X", 10.0, winA00[0], epsilon); + Assert.assertEquals("A 0.0 Project 1,0 failure Y", 5.0, winA00[1], epsilon); + Assert.assertEquals("A.0.1 Project 0,0 failure X", 5.0, winA01[0], epsilon); + Assert.assertEquals("A.0.1 Project 0,0 failure Y", 5.0, winA01[1], epsilon); + Assert.assertEquals("A 1.0 Project 1,0 failure X", 1.0, winA10[0], epsilon); + Assert.assertEquals("A 1.0 Project 1,0 failure Y", 0.0, winA10[1], epsilon); + Assert.assertEquals("A.1.1 Project 0,0 failure X", 0.0, winA11[0], epsilon); + Assert.assertEquals("A.1.1 Project 0,0 failure Y", 0.0, winA11[1], epsilon); + } + + public final void glOrthof(final float[] m, final float left, final float right, final float bottom, final float top, final float zNear, final float zFar) { + // Ortho matrix: + // 2/dx 0 0 tx + // 0 2/dy 0 ty + // 0 0 2/dz tz + // 0 0 0 1 + final float dx=right-left; + final float dy=top-bottom; + final float dz=zFar-zNear; + final float tx=-1.0f*(right+left)/dx; + final float ty=-1.0f*(top+bottom)/dy; + final float tz=-1.0f*(zFar+zNear)/dz; + + float[] matrixOrtho = new float[16]; + FloatUtil.makeIdentityf(matrixOrtho, 0); + matrixOrtho[0+4*0] = 2.0f/dx; + matrixOrtho[1+4*1] = 2.0f/dy; + matrixOrtho[2+4*2] = -2.0f/dz; + matrixOrtho[0+4*3] = tx; + matrixOrtho[1+4*3] = ty; + matrixOrtho[2+4*3] = tz; + + FloatUtil.multMatrixf(m, 0, matrixOrtho, 0); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPMVMatrix03NOUI.class.getName()); + } +} -- cgit v1.2.3 From 05eef46e33f41f5c234ffb1563fd8f641208fe85 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 11 Jun 2013 16:29:48 +0200 Subject: Adapt to GlueGen commit 1a01dce6c42b398cdd68d405828774a3ab366456 --- make/config/jogl/cg-common-CustomJavaCode.java | 6 +++++- make/config/jogl/cg-common.cfg | 2 ++ make/scripts/tests.sh | 4 ++-- .../classes/com/jogamp/graph/font/FontFactory.java | 8 ++++--- .../font/typecast/TypecastFontConstructor.java | 2 +- src/jogl/classes/jogamp/opengl/Debug.java | 25 ++++++++++------------ .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 7 +++++- .../classes/jogamp/nativewindow/Debug.java | 24 +++++++++------------ .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 6 ++++-- src/newt/classes/jogamp/newt/Debug.java | 25 ++++++++++------------ 10 files changed, 57 insertions(+), 52 deletions(-) (limited to 'make/scripts') diff --git a/make/config/jogl/cg-common-CustomJavaCode.java b/make/config/jogl/cg-common-CustomJavaCode.java index 31d1961fc..cc1fefd1a 100644 --- a/make/config/jogl/cg-common-CustomJavaCode.java +++ b/make/config/jogl/cg-common-CustomJavaCode.java @@ -6,7 +6,11 @@ static { if(null==cgProcAddressTable) { throw new RuntimeException("Couldn't instantiate CgProcAddressTable"); } - cgDynamicLookupHelper = new DynamicLibraryBundle(new CgDynamicLibraryBundleInfo()); + + cgDynamicLookupHelper = AccessController.doPrivileged(new PrivilegedAction() { + public DynamicLibraryBundle run() { + return new DynamicLibraryBundle(new CgDynamicLibraryBundleInfo()); + } } ); if(null==cgDynamicLookupHelper) { throw new RuntimeException("Null CgDynamicLookupHelper"); } diff --git a/make/config/jogl/cg-common.cfg b/make/config/jogl/cg-common.cfg index 35805bf01..d6a5367a6 100644 --- a/make/config/jogl/cg-common.cfg +++ b/make/config/jogl/cg-common.cfg @@ -105,6 +105,8 @@ Import jogamp.opengl.* Import com.jogamp.common.os.DynamicLookupHelper Import com.jogamp.common.os.DynamicLibraryBundle Import com.jogamp.opengl.cg.CgDynamicLibraryBundleInfo +Import java.security.PrivilegedAction +Import java.security.AccessController # # NIODirectOnly directives for routines requiring them for semantic reasons diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 693683827..2a75ffc5b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -312,7 +312,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix02NOUI $* -testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix03NOUI $* +#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix03NOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectDoubleNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java index 33d487355..33a977bba 100644 --- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java +++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java @@ -33,13 +33,15 @@ import java.net.URLConnection; import com.jogamp.common.util.PropertyAccess; import com.jogamp.common.util.ReflectionUtil; -import com.jogamp.common.util.SecurityUtil; import jogamp.graph.font.FontConstructor; import jogamp.graph.font.JavaFontLoader; import jogamp.graph.font.UbuntuFontLoader; public class FontFactory { + public static final String FontConstructorPropKey = "jogamp.graph.font.ctor"; + public static final String DefaultFontConstructor = "jogamp.graph.font.typecast.TypecastFontConstructor"; + /** Ubuntu is the default font family */ public static final int UBUNTU = 0; @@ -54,9 +56,9 @@ public class FontFactory { * "jogamp.graph.font.typecast.TypecastFontFactory" (default) * "jogamp.graph.font.ttf.TTFFontImpl" */ - String fontImplName = PropertyAccess.getProperty("FontImpl", true, SecurityUtil.getCommonAccessControlContext(FontFactory.class)); + String fontImplName = PropertyAccess.getProperty(FontConstructorPropKey, true); if(null == fontImplName) { - fontImplName = "jogamp.graph.font.typecast.TypecastFontConstructor"; + fontImplName = DefaultFontConstructor; } fontConstr = (FontConstructor) ReflectionUtil.createInstance(fontImplName, FontFactory.class.getClassLoader()); } diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java index 0f762e79c..8479c08ca 100644 --- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java +++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFontConstructor.java @@ -71,7 +71,7 @@ public class TypecastFontConstructor implements FontConstructor { int len=0; Font f = null; try { - tf = IOUtil.createTempFile( "jogl.font", ".ttf", false, null); + tf = IOUtil.createTempFile( "jogl.font", ".ttf", false); len = IOUtil.copyURLConn2File(fconn, tf); if(len==0) { tf.delete(); diff --git a/src/jogl/classes/jogamp/opengl/Debug.java b/src/jogl/classes/jogamp/opengl/Debug.java index 4287c1960..f87f1bb3f 100644 --- a/src/jogl/classes/jogamp/opengl/Debug.java +++ b/src/jogl/classes/jogamp/opengl/Debug.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,6 +40,9 @@ package jogamp.opengl; +import java.security.AccessController; +import java.security.PrivilegedAction; + import com.jogamp.common.util.PropertyAccess; /** Helper routines for logging and debugging. */ @@ -49,7 +53,12 @@ public class Debug extends PropertyAccess { private static final boolean debugAll; static { - PropertyAccess.addTrustedPrefix("jogl.", Debug.class); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + PropertyAccess.addTrustedPrefix("jogl."); + return null; + } } ); + verbose = isPropertyDefined("jogl.verbose", true); debugAll = isPropertyDefined("jogl.debug", true); if (verbose) { @@ -60,18 +69,6 @@ public class Debug extends PropertyAccess { } } - public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) { - return PropertyAccess.isPropertyDefined(property, jnlpAlias, null); - } - - public static String getProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getProperty(property, jnlpAlias, null); - } - - public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getBooleanProperty(property, jnlpAlias, null); - } - public static boolean verbose() { return verbose; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index 32c863553..883c13f51 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -28,6 +28,8 @@ package jogamp.opengl.util.av.impl; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -132,7 +134,10 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { static boolean initSingleton() { return ready; } private static boolean initSymbols() { - final DynamicLibraryBundle dl = new DynamicLibraryBundle(new FFMPEGDynamicLibraryBundleInfo()); + final DynamicLibraryBundle dl = AccessController.doPrivileged(new PrivilegedAction() { + public DynamicLibraryBundle run() { + return new DynamicLibraryBundle(new FFMPEGDynamicLibraryBundleInfo()); + } } ); final boolean avutilLoaded = dl.isToolLibLoaded(0); final boolean avformatLoaded = dl.isToolLibLoaded(1); final boolean avcodecLoaded = dl.isToolLibLoaded(2); diff --git a/src/nativewindow/classes/jogamp/nativewindow/Debug.java b/src/nativewindow/classes/jogamp/nativewindow/Debug.java index e07fd1b57..95547c971 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/Debug.java +++ b/src/nativewindow/classes/jogamp/nativewindow/Debug.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,6 +40,9 @@ package jogamp.nativewindow; +import java.security.AccessController; +import java.security.PrivilegedAction; + import com.jogamp.common.util.PropertyAccess; /** Helper routines for logging and debugging. */ @@ -49,7 +53,11 @@ public class Debug extends PropertyAccess { private static final boolean debugAll; static { - PropertyAccess.addTrustedPrefix("nativewindow.", Debug.class); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + PropertyAccess.addTrustedPrefix("nativewindow."); + return null; + } } ); verbose = isPropertyDefined("nativewindow.verbose", true); debugAll = isPropertyDefined("nativewindow.debug", true); @@ -61,18 +69,6 @@ public class Debug extends PropertyAccess { } } - public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) { - return PropertyAccess.isPropertyDefined(property, jnlpAlias, null); - } - - public static String getProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getProperty(property, jnlpAlias, null); - } - - public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getBooleanProperty(property, jnlpAlias, null); - } - public static boolean verbose() { return verbose; } diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index c3ad51c96..091a1a5cf 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -164,12 +164,14 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { // Closing action: back to parent! @Override public void windowDestroyNotify(WindowEvent e) { - if( WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() ) { + if( isValid() && WindowClosingMode.DO_NOTHING_ON_CLOSE == glWindow.getDefaultCloseOperation() ) { if(null == glWindow.getParent()) { // we may be called directly by the native EDT new Thread(new Runnable() { public void run() { - glWindow.reparentWindow(awtParent); + if( glWindow.isNativeValid() ) { + glWindow.reparentWindow(awtParent); + } } }).start(); } diff --git a/src/newt/classes/jogamp/newt/Debug.java b/src/newt/classes/jogamp/newt/Debug.java index 3c83da4d9..676d9b758 100644 --- a/src/newt/classes/jogamp/newt/Debug.java +++ b/src/newt/classes/jogamp/newt/Debug.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2003-2005 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,6 +40,9 @@ package jogamp.newt; +import java.security.AccessController; +import java.security.PrivilegedAction; + import com.jogamp.common.util.PropertyAccess; /** Helper routines for logging and debugging. */ @@ -49,7 +53,12 @@ public class Debug extends PropertyAccess { private static final boolean debugAll; static { - PropertyAccess.addTrustedPrefix("newt.", Debug.class); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + PropertyAccess.addTrustedPrefix("newt."); + return null; + } } ); + verbose = isPropertyDefined("newt.verbose", true); debugAll = isPropertyDefined("newt.debug", true); if (verbose) { @@ -60,18 +69,6 @@ public class Debug extends PropertyAccess { } } - public static final boolean isPropertyDefined(final String property, final boolean jnlpAlias) { - return PropertyAccess.isPropertyDefined(property, jnlpAlias, null); - } - - public static final int getIntProperty(final String property, final boolean jnlpAlias, int defaultValue) { - return PropertyAccess.getIntProperty(property, jnlpAlias, null, defaultValue); - } - - public static final boolean getBooleanProperty(final String property, final boolean jnlpAlias) { - return PropertyAccess.getBooleanProperty(property, jnlpAlias, null); - } - public static boolean verbose() { return verbose; } -- cgit v1.2.3 From af097fb2d5d983eb703d01f56e471a64d5d2657c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 13 Jun 2013 12:16:01 +0200 Subject: TestX11DefaultDisplay: Validate the chosen default device, test only one GLDefault/RedSquareES1; Tested w/ Xvnc4 + build-in Mesa 4.0.4 --- make/scripts/tests.sh | 10 +- .../junit/jogl/acore/TestX11DefaultDisplay.java | 136 +++++++++------------ 2 files changed, 67 insertions(+), 79 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2a75ffc5b..809618ce1 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -340,15 +340,13 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestX11DefaultDisplay $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove02GLWindowNewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove03GLWindowNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* - #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT $* @@ -378,6 +376,9 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch21Newt2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestBug722GLContextDrawableSwitchNewt2AWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $* + #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT @@ -400,6 +401,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* # # awt (testawt) diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestX11DefaultDisplay.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestX11DefaultDisplay.java index bff0d418c..a2c620492 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestX11DefaultDisplay.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestX11DefaultDisplay.java @@ -28,6 +28,8 @@ package com.jogamp.opengl.test.junit.jogl.acore; +import javax.media.nativewindow.AbstractGraphicsDevice; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; @@ -36,10 +38,12 @@ import org.junit.BeforeClass; import org.junit.Test; import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.test.junit.jogl.demos.PointsDemo; -import com.jogamp.opengl.test.junit.jogl.demos.es1.PointsDemoES1; -import com.jogamp.opengl.test.junit.jogl.demos.es2.PointsDemoES2; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; +import com.jogamp.opengl.test.junit.util.DumpGLInfo; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; /** * This is a clone of TestGLPointsNEWT which uses the ability to specify @@ -48,6 +52,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase; * */ public class TestX11DefaultDisplay extends UITestCase { + static long duration = 500; // ms static int width = 512, height = 512; static String x11DefaultDisplay = ":0.0"; @@ -56,100 +61,81 @@ public class TestX11DefaultDisplay extends UITestCase { System.setProperty("nativewindow.x11.display.default", x11DefaultDisplay); } - protected void runTestGL0(GLCapabilities caps, PointsDemo demo) throws InterruptedException { - GLWindow glWindow = GLWindow.create(caps); + protected void runTestGL(GLCapabilities caps) throws InterruptedException { + final GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle(getSimpleTestName(".")); + glWindow.setSize(width, height); + final RedSquareES1 demo = new RedSquareES1(); glWindow.addGLEventListener(demo); + final SnapshotGLEventListener snap = new SnapshotGLEventListener(); snap.setPostSNDetail(demo.getClass().getSimpleName()); glWindow.addGLEventListener(snap); - - glWindow.setSize(width, height); - glWindow.setVisible(true); - demo.setSmoothPoints(false); - snap.setMakeSnapshot(); - snap.setPostSNDetail("flat"); - glWindow.display(); + Animator animator = new Animator(glWindow); + QuitAdapter quitAdapter = new QuitAdapter(); + + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + animator.start(); - demo.setSmoothPoints(true); - snap.setMakeSnapshot(); - snap.setPostSNDetail("smooth"); - glWindow.display(); + glWindow.setVisible(true); + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - demo.setPointParams(2f, 40f, 0.01f, 0.0f, 0.01f, 1f); + animator.setUpdateFPSFrames(60, System.err); snap.setMakeSnapshot(); - snap.setPostSNDetail("attn0"); - glWindow.display(); - - glWindow.removeGLEventListener(demo); - + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() Date: Thu, 13 Jun 2013 20:38:13 +0200 Subject: Android SDK changes: Add /build-tools/17.0.0 to PATH --- make/scripts/make.jogl.all.android-armv6-cross.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.android-armv6-cross.sh b/make/scripts/make.jogl.all.android-armv6-cross.sh index da1b95c78..2a7232cb8 100755 --- a/make/scripts/make.jogl.all.android-armv6-cross.sh +++ b/make/scripts/make.jogl.all.android-armv6-cross.sh @@ -79,7 +79,7 @@ export NDK_TOOLCHAIN_ROOT=$NDK_ROOT/toolchains/${TARGET_TRIPLE}-${GCC_VERSION}/p export TARGET_PLATFORM_ROOT=${NDK_ROOT}/platforms/android-${ANDROID_VERSION}/arch-arm # Need to add toolchain bins to the PATH. -export PATH="$NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin:$ANDROID_HOME/platform-tools:$PATH" +export PATH="$NDK_TOOLCHAIN_ROOT/$TARGET_TRIPLE/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools/17.0.0:$PATH" export GLUEGEN_CPPTASKS_FILE=`pwd`/../../gluegen/make/lib/gluegen-cpptasks-android-armv6.xml -- cgit v1.2.3 From a83aea49479818a1e5037d11a3e7f7d1f019c939 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 14 Jun 2013 17:51:45 +0200 Subject: Fix Bug 745: NPE - QTT definition shall be allowd to _follow_ SOF (frame) - Reference QTT via QTT[] passed to frame, validate after parsing. --- make/scripts/tests.sh | 7 +- .../jogamp/opengl/util/jpeg/JPEGDecoder.java | 72 +++++++++++++++------ .../util/texture/TestJPEGTextureFromFileNEWT.java | 21 +++++- .../jogl/util/texture/bug745_qttdef_post_frame.jpg | Bin 0 -> 8415 bytes 4 files changed, 75 insertions(+), 25 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/bug745_qttdef_post_frame.jpg (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 809618ce1..452f28016 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -205,7 +205,7 @@ function jrun() { #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.PNGImage" - #D_ARGS="-Djogl.debug.JPEGImage" + D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" @@ -340,7 +340,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestX11DefaultDisplay $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestX11DefaultDisplay $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer01GLCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestOffscreenLayer02NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* @@ -526,11 +526,10 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestX11DefaultDisplay $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTexture02AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* diff --git a/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java b/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java index 251291a14..833771dd1 100644 --- a/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java +++ b/src/jogl/classes/jogamp/opengl/util/jpeg/JPEGDecoder.java @@ -301,13 +301,15 @@ public class JPEGDecoder { private final ArrayHashSet compIDs; private final ComponentIn[] comps; private final int compCount; + /** quantization tables */ + final int[][] qtt; int maxCompID; int maxH; int maxV; int mcusPerLine; int mcusPerColumn; - Frame(boolean progressive, int precision, int scanLines, int samplesPerLine, int componentsCount) { + Frame(boolean progressive, int precision, int scanLines, int samplesPerLine, int componentsCount, int[][] qtt) { this.progressive = progressive; this.precision = precision; this.scanLines = scanLines; @@ -315,6 +317,7 @@ public class JPEGDecoder { compIDs = new ArrayHashSet(componentsCount); comps = new ComponentIn[componentsCount]; this.compCount = componentsCount; + this.qtt = qtt; } private final void checkBounds(int idx) { @@ -322,6 +325,17 @@ public class JPEGDecoder { throw new CodecException("Idx out of bounds "+idx+", "+this); } } + public final void validateComponents() { + for(int i=0; i null QTT"); + } + } + } public final int getCompCount() { return compCount; } public final int getMaxCompID() { return maxCompID; } @@ -357,7 +371,8 @@ public class JPEGDecoder { /** The JPEG encoded components */ class ComponentIn { final int h, v; - final int[] quantizationTable; + /** index to frame.qtt[] */ + final int qttIdx; int blocksPerColumn; int blocksPerColumnForMcu; int blocksPerLine; @@ -368,10 +383,10 @@ public class JPEGDecoder { BinObj huffmanTableAC; BinObj huffmanTableDC; - ComponentIn(int h, int v, int[] quantizationTable) { + ComponentIn(int h, int v, int qttIdx) { this.h = h; this.v = v; - this.quantizationTable = quantizationTable; + this.qttIdx = qttIdx; } public final void allocateBlocks(int blocksPerColumn, int blocksPerColumnForMcu, int blocksPerLine, int blocksPerLineForMcu) { @@ -389,7 +404,7 @@ public class JPEGDecoder { } public final String toString() { - return "CompIn[h "+h+", v "+v+", blocks["+blocksPerColumn+", mcu "+blocksPerColumnForMcu+"]["+blocksPerLine+", mcu "+blocksPerLineForMcu+"][64]]"; + return "CompIn[h "+h+", v "+v+", qttIdx "+qttIdx+", blocks["+blocksPerColumn+", mcu "+blocksPerColumnForMcu+"]["+blocksPerLine+", mcu "+blocksPerLineForMcu+"][64]]"; } } @@ -526,12 +541,14 @@ public class JPEGDecoder { } public synchronized JPEGDecoder parse(final InputStream inputStream) throws IOException { clear(inputStream); - Frame frame = null; - int resetInterval = 0; - int[][] quantizationTables = new int[0x0F][]; // 4 bits - ArrayList frames = new ArrayList(); + + final int[][] quantizationTables = new int[0x0F][]; // 4 bits final BinObj[] huffmanTablesAC = new BinObj[0x0F]; // Huffman table spec - 4 bits final BinObj[] huffmanTablesDC = new BinObj[0x0F]; // Huffman table spec - 4 bits + // final ArrayList frames = new ArrayList(); // JAU: max 1-frame + + Frame frame = null; + int resetInterval = 0; int fileMarker = readUint16(); if ( fileMarker != M_SOI ) { throw new CodecException("SOI not found, but has marker "+toHexString(fileMarker)); @@ -579,6 +596,7 @@ public class JPEGDecoder { while( count < quantizationTablesLength ) { final int quantizationTableSpec = readUint8(); count++; final int precisionID = quantizationTableSpec >> 4; + final int tableIdx = quantizationTableSpec & 0x0F; final int[] tableData = new int[64]; if ( precisionID == 0 ) { // 8 bit values for (int j = 0; j < 64; j++) { @@ -591,12 +609,15 @@ public class JPEGDecoder { tableData[z] = readUint16(); count+=2; } } else { - throw new CodecException("DQT: invalid table precision "+precisionID+", quantizationTableSpec "+quantizationTableSpec); + throw new CodecException("DQT: invalid table precision "+precisionID+", quantizationTableSpec "+quantizationTableSpec+", idx "+tableIdx); } - quantizationTables[quantizationTableSpec & 0x0F] = tableData; + quantizationTables[tableIdx] = tableData; + if( DEBUG ) { + System.err.println("JPEG.parse.QTT["+tableIdx+"]: spec "+quantizationTableSpec+", precision "+precisionID+", data "+count+"/"+quantizationTablesLength); + } } if(count!=quantizationTablesLength){ - throw new CodecException("ERROR: QTT format error [count!=Length]"); + throw new CodecException("ERROR: QTT format error [count!=Length]: "+count+"/"+quantizationTablesLength); } fileMarker = 0; // consumed and get-next } @@ -604,6 +625,9 @@ public class JPEGDecoder { case M_SOF0: case M_SOF2: { + if( null != frame ) { // JAU: max 1-frame + throw new CodecException("only single frame JPEGs supported"); + } int count = 0; final int sofLen = readUint16(); count+=2; // header length; final int componentsCount; @@ -613,7 +637,7 @@ public class JPEGDecoder { final int scanLines = readUint16(); count+=2; final int samplesPerLine = readUint16(); count+=2; componentsCount = readUint8(); count++; - frame = new Frame(progressive, precision, scanLines, samplesPerLine, componentsCount); + frame = new Frame(progressive, precision, scanLines, samplesPerLine, componentsCount, quantizationTables); width = frame.samplesPerLine; height = frame.scanLines; } @@ -622,14 +646,15 @@ public class JPEGDecoder { final int temp = readUint8(); count++; final int h = temp >> 4; final int v = temp & 0x0F; - final int qId = readUint8(); count++; - frame.putOrdered(componentId, new ComponentIn(h, v, quantizationTables[qId])); + final int qttIdx = readUint8(); count++; + final ComponentIn compIn = new ComponentIn(h, v, qttIdx); + frame.putOrdered(componentId, compIn); } if(count!=sofLen){ throw new CodecException("ERROR: SOF format error [count!=Length]"); } prepareComponents(frame); - frames.add(frame); + // frames.add(frame); // JAU: max 1-frame if(DEBUG) { System.err.println("JPG.parse.SOF[02]: Got frame "+frame); } fileMarker = 0; // consumed and get-next } @@ -711,14 +736,21 @@ public class JPEGDecoder { } } if(DEBUG) { System.err.println("JPG.parse.2: End of parsing input "+this); } + /** // JAU: max 1-frame if ( frames.size() != 1 ) { - throw new CodecException("only single frame JPEGs supported"); + throw new CodecException("only single frame JPEGs supported "+this); + } */ + if( null == frame ) { + throw new CodecException("no single frame found in stream "+this); } + frame.validateComponents(); final int compCount = frame.getCompCount(); this.components = new ComponentOut[compCount]; for (int i = 0; i < compCount; i++) { final ComponentIn component = frame.getCompByIndex(i); + // System.err.println("JPG.parse.buildComponentData["+i+"]: "+component); // JAU + // System.err.println("JPG.parse.buildComponentData["+i+"]: "+frame); // JAU this.components[i] = new ComponentOut( output.buildComponentData(frame, component), (float)component.h / (float)frame.maxH, (float)component.v / (float)frame.maxV ); @@ -834,12 +866,14 @@ public class JPEGDecoder { final byte[] r = new byte[64]; for (int blockRow = 0; blockRow < blocksPerColumn; blockRow++) { - int scanLine = blockRow << 3; + final int scanLine = blockRow << 3; + // System.err.println("JPG.buildComponentData: row "+blockRow+"/"+blocksPerColumn+" -> scanLine "+scanLine); // JAU for (int i = 0; i < 8; i++) { lines.add(new byte[samplesPerLine]); } for (int blockCol = 0; blockCol < blocksPerLine; blockCol++) { - quantizeAndInverse(component.getBlock(blockRow, blockCol), r, R, component.quantizationTable); + // System.err.println("JPG.buildComponentData: col "+blockCol+"/"+blocksPerLine+", comp.qttIdx "+component.qttIdx+", qtt "+frame.qtt[component.qttIdx]); // JAU + quantizeAndInverse(component.getBlock(blockRow, blockCol), r, R, frame.qtt[component.qttIdx]); final int sample = blockCol << 3; int offset = 0; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java index 55e8152ae..82867f9e6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java @@ -74,6 +74,8 @@ public class TestJPEGTextureFromFileNEWT extends UITestCase { InputStream testTextureStream03CMYK_01; InputStream testTextureStream03YCCK_01; + InputStream testTextureStream04QTTDefPostFrame; + @Before public void initTest() throws IOException { { @@ -132,6 +134,13 @@ public class TestJPEGTextureFromFileNEWT extends UITestCase { testTextureStream03YCCK_01 = testTextureUrlConn.getInputStream(); Assert.assertNotNull(testTextureStream03YCCK_01); } + { + URLConnection testTextureUrlConn = IOUtil.getResource(this.getClass(), "bug745_qttdef_post_frame.jpg"); + Assert.assertNotNull(testTextureUrlConn); + testTextureStream04QTTDefPostFrame = testTextureUrlConn.getInputStream(); + Assert.assertNotNull(testTextureStream04QTTDefPostFrame); + } + } @After @@ -142,7 +151,10 @@ public class TestJPEGTextureFromFileNEWT extends UITestCase { testTextureStream01YUV422h_Prog = null; testTextureStream02YUV420_Base = null; testTextureStream02YUV420_Prog = null; - testTextureStream02YUV420_BaseGray = null; + testTextureStream02YUV420_BaseGray = null; + testTextureStream03CMYK_01 = null; + testTextureStream03YCCK_01 = null; + testTextureStream04QTTDefPostFrame = null; } public void testImpl(boolean useFFP, final InputStream istream) throws InterruptedException, IOException { @@ -241,7 +253,7 @@ public class TestJPEGTextureFromFileNEWT extends UITestCase { @Test public void test02YUV420BaseGray_ES2() throws InterruptedException, IOException { testImpl(false, testTextureStream02YUV420_BaseGray); - } + } @Test public void test03CMYK_01_ES2() throws InterruptedException, IOException { @@ -251,6 +263,11 @@ public class TestJPEGTextureFromFileNEWT extends UITestCase { public void test03YCCK_01_ES2() throws InterruptedException, IOException { testImpl(false, testTextureStream03YCCK_01); } + + @Test + public void test04QTTDefPostFrame_ES2() throws InterruptedException, IOException { + testImpl(false, testTextureStream04QTTDefPostFrame); + } public static void main(String args[]) throws IOException { for(int i=0; i Date: Sun, 16 Jun 2013 04:14:56 +0200 Subject: Bug 735: Adding Andres test cases for analysis. OSX exposes diff. odd behaviors - See BugXYZ test cases. --- make/scripts/tests.sh | 12 +- .../opengl/test/bugs/Bug735Inv0AppletAWT.java | 427 ++++++++++++++++++++ .../opengl/test/bugs/Bug735Inv1AppletAWT.java | 429 +++++++++++++++++++++ .../opengl/test/bugs/Bug735Inv2AppletAWT.java | 253 ++++++++++++ .../opengl/test/bugs/Bug735Inv3AppletAWT.java | 203 ++++++++++ .../com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java | 188 +++++++++ .../test/junit/jogl/demos/es2/LandscapeES2.java | 184 +++++++++ .../jogl/demos/es2/newt/TestLandscapeES2NEWT.java | 175 +++++++++ .../es2/newt/TestLandscapeES2NewtCanvasAWT.java | 258 +++++++++++++ .../test/junit/jogl/demos/es2/shader/landscape.fp | 339 ++++++++++++++++ .../test/junit/jogl/demos/es2/shader/landscape.vp | 11 + 11 files changed, 2477 insertions(+), 2 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735Inv3AppletAWT.java create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/landscape.fp create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/landscape.vp (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 452f28016..17dccdcaf 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -205,7 +205,7 @@ function jrun() { #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.PNGImage" - D_ARGS="-Djogl.debug.JPEGImage" + #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" @@ -438,6 +438,14 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv2AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv4AppletAWT $* + # # swt (testswt) # @@ -529,7 +537,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGImage01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java new file mode 100644 index 000000000..b240f0cfb --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java @@ -0,0 +1,427 @@ +package com.jogamp.opengl.test.bugs; + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.nio.FloatBuffer; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLUniformData; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; + +/** + * Original test case. + *
    + * OSX Results: + *
    + *   - Only RED Clear Color
    + * 
    + */ +@SuppressWarnings("serial") +public class Bug735Inv0AppletAWT extends Applet implements Runnable { + static public int AWT = 0; + static public int NEWT = 1; + + static public int APPLET_WIDTH = 500; + static public int APPLET_HEIGHT = 290; + static public int TARGET_FPS = 120; + static public int TOOLKIT = NEWT; + static public boolean MANUAL_FRAME_HANDLING = true; + + ////////////////////////////////////////////////////////////////////////////// + + static private Frame frame; + static private Bug735Inv0AppletAWT applet; + private GLCanvas awtCanvas; + private GLWindow newtWindow; + private NewtCanvasAWT newtCanvas; + private DrawRunnable drawRunnable; + private GLContext context; + private GLU glu; + + private int width; + private int height; + private Thread thread; + + private boolean doneInit = false; + private boolean doneSetup = false; + + private long frameRatePeriod = 1000000000L / TARGET_FPS; + private long millisOffset; + private int frameCount; + private float frameRate; + + private ShaderCode vertShader; + private ShaderCode fragShader; + private ShaderProgram shaderProg; + private ShaderState shaderState; + private GLUniformData resolution; + private GLUniformData time; + private GLArrayDataServer vertices; + + private int fcount = 0, lastm = 0; + private int fint = 1; + + public void init() { + setSize(APPLET_WIDTH, APPLET_HEIGHT); + setPreferredSize(new Dimension(APPLET_WIDTH, APPLET_HEIGHT)); + width = APPLET_WIDTH; + height = APPLET_HEIGHT; + } + + public void start() { + thread = new Thread(this, "Animation Thread"); + thread.start(); + } + + public void run() { + int noDelays = 0; + // Number of frames with a delay of 0 ms before the + // animation thread yields to other running threads. + final int NO_DELAYS_PER_YIELD = 15; + final int TIMEOUT_SECONDS = 2; + + long beforeTime = System.nanoTime(); + long overSleepTime = 0L; + + millisOffset = System.currentTimeMillis(); + frameCount = 1; + while (Thread.currentThread() == thread) { + final CountDownLatch latch = new CountDownLatch(1); + requestDraw(latch); + try { + latch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + if (frameCount == 1) { + EventQueue.invokeLater(new Runnable() { + public void run() { + requestFocusInWindow(); + } + }); + } + + long afterTime = System.nanoTime(); + long timeDiff = afterTime - beforeTime; + long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime; + if (sleepTime > 0) { // some time left in this cycle + try { + Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L)); + noDelays = 0; // Got some sleep, not delaying anymore + } catch (InterruptedException ex) { } + overSleepTime = (System.nanoTime() - afterTime) - sleepTime; + } else { // sleepTime <= 0; the frame took longer than the period + overSleepTime = 0L; + noDelays++; + if (noDelays > NO_DELAYS_PER_YIELD) { + Thread.yield(); // give another thread a chance to run + noDelays = 0; + } + } + beforeTime = System.nanoTime(); + } + } + + public void requestDraw(CountDownLatch latch) { + if (!doneInit) { + initDraw(); + } + + if (TOOLKIT == AWT) { + awtCanvas.invoke(true, drawRunnable); + } else if (TOOLKIT == NEWT) { + newtWindow.invoke(true, drawRunnable); + } + + if (latch != null) { + latch.countDown(); + } + } + + private class DrawRunnable implements GLRunnable { + private boolean notCurrent; + + @Override + public boolean run(GLAutoDrawable drawable) { + if (MANUAL_FRAME_HANDLING) { + makeContextCurrent(); + } + + if (doneSetup) { + draw(drawable.getGL().getGL2ES2()); + } else { + setup(drawable.getGL().getGL2ES2()); + } + checkGLErrors(drawable.getGL()); + + if (MANUAL_FRAME_HANDLING) { + swapBuffers(); + releaseCurrentContext(); + } + + return true; + } + + private void makeContextCurrent() { + int MAX_CONTEXT_GRAB_ATTEMPTS = 10; + + if (context.isCurrent()) { + notCurrent = false; + } else { + notCurrent = true; + int value = GLContext.CONTEXT_NOT_CURRENT; + int attempt = 0; + do { + try { + value = context.makeCurrent(); + System.out.println("Made context current"); + } catch (final GLException gle) { + gle.printStackTrace(); + } finally { + attempt++; + if (attempt == MAX_CONTEXT_GRAB_ATTEMPTS) { + throw new RuntimeException("Failed to claim OpenGL context."); + } + } + try { + Thread.sleep(5); + } catch (final InterruptedException e) { + e.printStackTrace(); + } + + } while (value == GLContext.CONTEXT_NOT_CURRENT); + } + } + + private void swapBuffers() { + final GL gl = GLContext.getCurrentGL(); + gl.glFlush(); + GLContext.getCurrent().getGLDrawable().swapBuffers(); + } + + private void releaseCurrentContext() { + if (notCurrent) { + try { + context.release(); + System.out.println("Released context"); + } catch (final GLException gle) { + gle.printStackTrace(); + } + } + } + } + + private void initGL() { + GLProfile profile = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(profile); + caps.setBackgroundOpaque(true); + caps.setOnscreen(true); + caps.setSampleBuffers(false); + + if (TOOLKIT == AWT) { + awtCanvas = new GLCanvas(caps); + awtCanvas.setBounds(0, 0, applet.width, applet.height); + awtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + awtCanvas.setFocusable(true); + + applet.setLayout(new BorderLayout()); + applet.add(awtCanvas, BorderLayout.CENTER); + + if (MANUAL_FRAME_HANDLING) { + awtCanvas.setIgnoreRepaint(true); + awtCanvas.setAutoSwapBufferMode(false); + } + } else if (TOOLKIT == NEWT) { + newtWindow = GLWindow.create(caps); + newtCanvas = new NewtCanvasAWT(newtWindow); + newtCanvas.setBounds(0, 0, applet.width, applet.height); + newtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + newtCanvas.setFocusable(true); + + applet.setLayout(new BorderLayout()); + applet.add(newtCanvas, BorderLayout.CENTER); + + if (MANUAL_FRAME_HANDLING) { + newtCanvas.setIgnoreRepaint(true); + newtWindow.setAutoSwapBufferMode(false); + } + } + } + + private void initDraw() { + if (TOOLKIT == AWT) { + awtCanvas.setVisible(true); + // Force the realization + awtCanvas.display(); + if (awtCanvas.getDelegatedDrawable().isRealized()) { + // Request the focus here as it cannot work when the window is not visible + awtCanvas.requestFocus(); + context = awtCanvas.getContext(); + } + } else if (TOOLKIT == NEWT) { + newtCanvas.setVisible(true); + // Force the realization + newtWindow.display(); + if (newtWindow.isRealized()) { + // Request the focus here as it cannot work when the window is not visible + newtCanvas.requestFocus(); + context = newtWindow.getContext(); + } + } + + drawRunnable = new DrawRunnable(); + + doneInit = true; + } + + private void setup(GL2ES2 gl) { + if (60 < TARGET_FPS) { + // Disables vsync + gl.setSwapInterval(0); + } + glu = new GLU(); + + vertShader = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, LandscapeES2.class, "shader", "shader/bin", "landscape", true); + fragShader = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, LandscapeES2.class, "shader", "shader/bin", "landscape", true); + shaderProg = new ShaderProgram(); + shaderProg.add(gl, vertShader, System.err); + shaderProg.add(gl, fragShader, System.err); + + shaderState = new ShaderState(); + shaderState.attachShaderProgram(gl, shaderProg, true); + + resolution = new GLUniformData("iResolution", 3, FloatBuffer.wrap(new float[] {width, height, 0})); + shaderState.ownUniform(resolution); + shaderState.uniform(gl, resolution); + + time = new GLUniformData("iGlobalTime", 0.0f); + shaderState.ownUniform(time); + + vertices = GLArrayDataServer.createGLSL("inVertex", 2, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + vertices.putf(-1.0f); vertices.putf(-1.0f); + vertices.putf(+1.0f); vertices.putf(-1.0f); + vertices.putf(-1.0f); vertices.putf(+1.0f); + vertices.putf(+1.0f); vertices.putf(+1.0f); + vertices.seal(gl, true); + shaderState.ownAttribute(vertices, true); + shaderState.useProgram(gl, false); + + doneSetup = true; + } + + private void draw(GL2ES2 gl) { + gl.glClearColor(0.5f, 0.1f, 0.1f, 1); + gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT); + + shaderState.useProgram(gl, true); + + time.setData((System.currentTimeMillis() - millisOffset) / 1000.0f); + shaderState.uniform(gl, time); + vertices.enableBuffer(gl, true); + gl.glDrawArrays(GL2ES2.GL_TRIANGLE_STRIP, 0, 4); + vertices.enableBuffer(gl, false); + + shaderState.useProgram(gl, false); + + // Compute current framerate and printout. + frameCount++; + fcount += 1; + int m = (int) (System.currentTimeMillis() - millisOffset); + if (m - lastm > 1000 * fint) { + frameRate = (float)(fcount) / fint; + fcount = 0; + lastm = m; + } + if (frameCount % TARGET_FPS == 0) { + System.out.println("FrameCount: " + frameCount + " - " + + "FrameRate: " + frameRate); + } + } + + private void checkGLErrors(GL gl) { + int err = gl.glGetError(); + if (err != 0) { + String errString = glu.gluErrorString(err); + System.out.println(errString); + } + } + + static public void main(String[] args) { + GraphicsEnvironment environment = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice displayDevice = environment.getDefaultScreenDevice(); + + frame = new Frame(displayDevice.getDefaultConfiguration()); + frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); + frame.setTitle("TestBug735InvAppletAWT"); + + try { + Class c = Thread.currentThread().getContextClassLoader(). + loadClass(Bug735Inv0AppletAWT.class.getName()); + applet = (Bug735Inv0AppletAWT) c.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + frame.setLayout(null); + frame.add(applet); + frame.pack(); + frame.setResizable(false); + + applet.init(); + + Insets insets = frame.getInsets(); + int windowW = applet.width + insets.left + insets.right; + int windowH = applet.height + insets.top + insets.bottom; + frame.setSize(windowW, windowH); + + Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds(); + frame.setLocation(screenRect.x + (screenRect.width - applet.width) / 2, + screenRect.y + (screenRect.height - applet.height) / 2); + + int usableWindowH = windowH - insets.top - insets.bottom; + applet.setBounds((windowW - applet.width)/2, + insets.top + (usableWindowH - applet.height)/2, + applet.width, applet.height); + + // This allows to close the frame. + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + applet.initGL(); + frame.setVisible(true); + applet.start(); + } +} diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java new file mode 100644 index 000000000..e1bdbba77 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java @@ -0,0 +1,429 @@ +package com.jogamp.opengl.test.bugs; + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.nio.FloatBuffer; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLUniformData; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.glu.GLU; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; + +/** + * Difference to orig. Bug735Inv0AppletAWT: + *
    + *   - MANUAL_FRAME_HANDLING false
    + *   - MANUAL_FRAME_HANDLING: impl using pass through GLContext instead of static
    + * 
    + * OSX Results: + *
    + *   - Only RED Clear Color
    + * 
    + */ +@SuppressWarnings("serial") +public class Bug735Inv1AppletAWT extends Applet implements Runnable { + static public int AWT = 0; + static public int NEWT = 1; + + static public int APPLET_WIDTH = 500; + static public int APPLET_HEIGHT = 290; + static public int TARGET_FPS = 120; + static public int TOOLKIT = NEWT; + static public boolean MANUAL_FRAME_HANDLING = false; + + ////////////////////////////////////////////////////////////////////////////// + + static private Frame frame; + static private Bug735Inv1AppletAWT applet; + private GLCanvas awtCanvas; + private GLWindow newtWindow; + private NewtCanvasAWT newtCanvas; + private DrawRunnable drawRunnable; + // JAU private GLContext context; + private GLU glu; + + private int width; + private int height; + private Thread thread; + + private boolean doneInit = false; + private boolean doneSetup = false; + + private long frameRatePeriod = 1000000000L / TARGET_FPS; + private long millisOffset; + private int frameCount; + private float frameRate; + + private ShaderCode vertShader; + private ShaderCode fragShader; + private ShaderProgram shaderProg; + private ShaderState shaderState; + private GLUniformData resolution; + private GLUniformData time; + private GLArrayDataServer vertices; + + private int fcount = 0, lastm = 0; + private int fint = 1; + + public void init() { + setSize(APPLET_WIDTH, APPLET_HEIGHT); + setPreferredSize(new Dimension(APPLET_WIDTH, APPLET_HEIGHT)); + width = APPLET_WIDTH; + height = APPLET_HEIGHT; + } + + public void start() { + thread = new Thread(this, "Animation Thread"); + thread.start(); + } + + public void run() { + int noDelays = 0; + // Number of frames with a delay of 0 ms before the + // animation thread yields to other running threads. + final int NO_DELAYS_PER_YIELD = 15; + final int TIMEOUT_SECONDS = 2; + + long beforeTime = System.nanoTime(); + long overSleepTime = 0L; + + millisOffset = System.currentTimeMillis(); + frameCount = 1; + while (Thread.currentThread() == thread) { + final CountDownLatch latch = new CountDownLatch(1); + requestDraw(latch); + try { + latch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + if (frameCount == 1) { + EventQueue.invokeLater(new Runnable() { + public void run() { + requestFocusInWindow(); + } + }); + } + + long afterTime = System.nanoTime(); + long timeDiff = afterTime - beforeTime; + long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime; + if (sleepTime > 0) { // some time left in this cycle + try { + Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L)); + noDelays = 0; // Got some sleep, not delaying anymore + } catch (InterruptedException ex) { } + overSleepTime = (System.nanoTime() - afterTime) - sleepTime; + } else { // sleepTime <= 0; the frame took longer than the period + overSleepTime = 0L; + noDelays++; + if (noDelays > NO_DELAYS_PER_YIELD) { + Thread.yield(); // give another thread a chance to run + noDelays = 0; + } + } + beforeTime = System.nanoTime(); + } + } + + public void requestDraw(CountDownLatch latch) { + if (!doneInit) { + initDraw(); + } + + if (TOOLKIT == AWT) { + awtCanvas.invoke(true, drawRunnable); + } else if (TOOLKIT == NEWT) { + newtWindow.invoke(true, drawRunnable); + } + + if (latch != null) { + latch.countDown(); + } + } + + private class DrawRunnable implements GLRunnable { + private boolean notCurrent; + + @Override + public boolean run(GLAutoDrawable drawable) { + if (MANUAL_FRAME_HANDLING) { + makeContextCurrent(drawable.getContext()); + } + + if (!doneSetup) { + setup(drawable.getGL().getGL2ES2()); + } + draw(drawable.getGL().getGL2ES2()); + checkGLErrors(drawable.getGL()); + + if (MANUAL_FRAME_HANDLING) { + swapBuffers(drawable.getContext()); + releaseCurrentContext(drawable.getContext()); + } + + return true; + } + + private void makeContextCurrent(GLContext context) { + int MAX_CONTEXT_GRAB_ATTEMPTS = 10; + + if (context.isCurrent()) { + notCurrent = false; + } else { + notCurrent = true; + int value = GLContext.CONTEXT_NOT_CURRENT; + int attempt = 0; + do { + try { + value = context.makeCurrent(); + System.out.println("Made context current"); + } catch (final GLException gle) { + gle.printStackTrace(); + } finally { + attempt++; + if (attempt == MAX_CONTEXT_GRAB_ATTEMPTS) { + throw new RuntimeException("Failed to claim OpenGL context."); + } + } + try { + Thread.sleep(5); + } catch (final InterruptedException e) { + e.printStackTrace(); + } + + } while (value == GLContext.CONTEXT_NOT_CURRENT); + } + } + + private void swapBuffers(GLContext context) { + final GL gl = context.getGL(); + gl.glFlush(); + context.getGLDrawable().swapBuffers(); + } + + private void releaseCurrentContext(GLContext context) { + if (notCurrent) { + try { + context.release(); + System.out.println("Released context"); + } catch (final GLException gle) { + gle.printStackTrace(); + } + } + } + } + + private void initGL() { + GLProfile profile = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(profile); + caps.setBackgroundOpaque(true); + caps.setOnscreen(true); + caps.setSampleBuffers(false); + + if (TOOLKIT == AWT) { + awtCanvas = new GLCanvas(caps); + awtCanvas.setBounds(0, 0, applet.width, applet.height); + awtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + awtCanvas.setFocusable(true); + + applet.setLayout(new BorderLayout()); + applet.add(awtCanvas, BorderLayout.CENTER); + + if (MANUAL_FRAME_HANDLING) { + awtCanvas.setIgnoreRepaint(true); + awtCanvas.setAutoSwapBufferMode(false); + } + } else if (TOOLKIT == NEWT) { + newtWindow = GLWindow.create(caps); + newtCanvas = new NewtCanvasAWT(newtWindow); + newtCanvas.setBounds(0, 0, applet.width, applet.height); + newtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + newtCanvas.setFocusable(true); + + applet.setLayout(new BorderLayout()); + applet.add(newtCanvas, BorderLayout.CENTER); + + if (MANUAL_FRAME_HANDLING) { + newtCanvas.setIgnoreRepaint(true); + newtWindow.setAutoSwapBufferMode(false); + } + } + } + + private void initDraw() { + if (TOOLKIT == AWT) { + awtCanvas.setVisible(true); + // Force the realization + awtCanvas.display(); + if (awtCanvas.getDelegatedDrawable().isRealized()) { + // Request the focus here as it cannot work when the window is not visible + awtCanvas.requestFocus(); + } + } else if (TOOLKIT == NEWT) { + newtCanvas.setVisible(true); + // Force the realization + newtWindow.display(); + if (newtWindow.isRealized()) { + // Request the focus here as it cannot work when the window is not visible + newtCanvas.requestFocus(); + } + } + + drawRunnable = new DrawRunnable(); + + doneInit = true; + } + + private void setup(GL2ES2 gl) { + if (60 < TARGET_FPS) { + // Disables vsync + gl.setSwapInterval(0); + } + glu = new GLU(); + + vertShader = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, LandscapeES2.class, "shader", "shader/bin", "landscape", true); + fragShader = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, LandscapeES2.class, "shader", "shader/bin", "landscape", true); + vertShader.defaultShaderCustomization(gl, true, true); + fragShader.defaultShaderCustomization(gl, true, true); + shaderProg = new ShaderProgram(); + shaderProg.add(gl, vertShader, System.err); + shaderProg.add(gl, fragShader, System.err); + + shaderState = new ShaderState(); + shaderState.attachShaderProgram(gl, shaderProg, true); + + resolution = new GLUniformData("iResolution", 3, FloatBuffer.wrap(new float[] {width, height, 0})); + shaderState.ownUniform(resolution); + shaderState.uniform(gl, resolution); + + time = new GLUniformData("iGlobalTime", 0.0f); + shaderState.ownUniform(time); + + vertices = GLArrayDataServer.createGLSL("inVertex", 2, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + vertices.putf(-1.0f); vertices.putf(-1.0f); + vertices.putf(+1.0f); vertices.putf(-1.0f); + vertices.putf(-1.0f); vertices.putf(+1.0f); + vertices.putf(+1.0f); vertices.putf(+1.0f); + vertices.seal(gl, true); + shaderState.ownAttribute(vertices, true); + shaderState.useProgram(gl, false); + + doneSetup = true; + } + + private void draw(GL2ES2 gl) { + gl.glClearColor(0.5f, 0.1f, 0.1f, 1); + gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT); + + shaderState.useProgram(gl, true); + + time.setData((System.currentTimeMillis() - millisOffset) / 1000.0f); + shaderState.uniform(gl, time); + vertices.enableBuffer(gl, true); + gl.glDrawArrays(GL2ES2.GL_TRIANGLE_STRIP, 0, 4); + vertices.enableBuffer(gl, false); + + shaderState.useProgram(gl, false); + + // Compute current framerate and printout. + frameCount++; + fcount += 1; + int m = (int) (System.currentTimeMillis() - millisOffset); + if (m - lastm > 1000 * fint) { + frameRate = (float)(fcount) / fint; + fcount = 0; + lastm = m; + } + if (frameCount % TARGET_FPS == 0) { + System.out.println("FrameCount: " + frameCount + " - " + + "FrameRate: " + frameRate); + } + } + + private void checkGLErrors(GL gl) { + int err = gl.glGetError(); + if (err != 0) { + String errString = glu.gluErrorString(err); + System.out.println(errString); + } + } + + static public void main(String[] args) { + GraphicsEnvironment environment = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice displayDevice = environment.getDefaultScreenDevice(); + + frame = new Frame(displayDevice.getDefaultConfiguration()); + frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); + frame.setTitle("TestBug735InvAppletAWT"); + + try { + Class c = Thread.currentThread().getContextClassLoader(). + loadClass(Bug735Inv1AppletAWT.class.getName()); + applet = (Bug735Inv1AppletAWT) c.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + frame.setLayout(null); + frame.add(applet); + frame.pack(); + frame.setResizable(false); + + applet.init(); + + Insets insets = frame.getInsets(); + int windowW = applet.width + insets.left + insets.right; + int windowH = applet.height + insets.top + insets.bottom; + frame.setSize(windowW, windowH); + + Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds(); + frame.setLocation(screenRect.x + (screenRect.width - applet.width) / 2, + screenRect.y + (screenRect.height - applet.height) / 2); + + int usableWindowH = windowH - insets.top - insets.bottom; + applet.setBounds((windowW - applet.width)/2, + insets.top + (usableWindowH - applet.height)/2, + applet.width, applet.height); + + // This allows to close the frame. + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + applet.initGL(); + frame.setVisible(true); + applet.start(); + } +} diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java new file mode 100644 index 000000000..34a3513ce --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java @@ -0,0 +1,253 @@ +package com.jogamp.opengl.test.bugs; + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; + +/** + * Difference to orig. Bug735Inv0AppletAWT: + *
    + *   - Use GLEventListener
    + *   - Add GLEventListener to GLAutoDrawable
    + *   - Use GLAutoDrawable.display() instead of GLAutoDrawable.invoke(true, GLRunnable { init / render })
    + *   - Removed MANUAL_FRAME_HANDLING, obsolete due to GLAutoDrawable/GLEventListener 
    + * 
    + * OSX Results: + *
    + *   - Visible content
    + *   - Stuttering, non-fluent and slow animation
    + * 
    + */ +@SuppressWarnings("serial") +public class Bug735Inv2AppletAWT extends Applet implements Runnable { + static public int AWT = 0; + static public int NEWT = 1; + + static public int APPLET_WIDTH = 500; + static public int APPLET_HEIGHT = 290; + static public int TARGET_FPS = 120; + static public int TOOLKIT = NEWT; + static public boolean IGNORE_AWT_REPAINT = false; + static public boolean USE_ECT = false; + static public int SWAP_INTERVAL = 0; + + ////////////////////////////////////////////////////////////////////////////// + + static private Frame frame; + static private Bug735Inv2AppletAWT applet; + private GLCanvas awtCanvas; + private GLWindow newtWindow; + private GLAutoDrawable glad; + private NewtCanvasAWT newtCanvas; + private GLEventListener demo; + + private int width; + private int height; + private Thread thread; + + private long frameRatePeriod = 1000000000L / TARGET_FPS; + private int frameCount; + + public void init() { + setSize(APPLET_WIDTH, APPLET_HEIGHT); + setPreferredSize(new Dimension(APPLET_WIDTH, APPLET_HEIGHT)); + width = APPLET_WIDTH; + height = APPLET_HEIGHT; + initGL(); + } + + public void start() { + initDraw(); + thread = new Thread(this, "Animation Thread"); + thread.start(); + } + + public void run() { + int noDelays = 0; + // Number of frames with a delay of 0 ms before the + // animation thread yields to other running threads. + final int NO_DELAYS_PER_YIELD = 15; + final int TIMEOUT_SECONDS = 2; + + long beforeTime = System.nanoTime(); + long overSleepTime = 0L; + + frameCount = 1; + while (Thread.currentThread() == thread) { + if (frameCount == 1) { + EventQueue.invokeLater(new Runnable() { + public void run() { + requestFocusInWindow(); + } + }); + if( USE_ECT ) { + glad.setExclusiveContextThread(thread); + } + } + final CountDownLatch latch = new CountDownLatch(1); + requestDraw(latch); + try { + latch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + long afterTime = System.nanoTime(); + long timeDiff = afterTime - beforeTime; + long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime; + if (sleepTime > 0) { // some time left in this cycle + try { + Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L)); + noDelays = 0; // Got some sleep, not delaying anymore + } catch (InterruptedException ex) { } + overSleepTime = (System.nanoTime() - afterTime) - sleepTime; + } else { // sleepTime <= 0; the frame took longer than the period + overSleepTime = 0L; + noDelays++; + if (noDelays > NO_DELAYS_PER_YIELD) { + Thread.yield(); // give another thread a chance to run + noDelays = 0; + } + } + beforeTime = System.nanoTime(); + } + } + + public void requestDraw(CountDownLatch latch) { + glad.display(); + + if (latch != null) { + latch.countDown(); + } + } + + private void initGL() { + GLProfile profile = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(profile); + caps.setBackgroundOpaque(true); + caps.setOnscreen(true); + caps.setSampleBuffers(false); + + if (TOOLKIT == AWT) { + awtCanvas = new GLCanvas(caps); + awtCanvas.setBounds(0, 0, applet.width, applet.height); + awtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + awtCanvas.setFocusable(true); + + applet.setLayout(new BorderLayout()); + applet.add(awtCanvas, BorderLayout.CENTER); + + if (IGNORE_AWT_REPAINT) { + awtCanvas.setIgnoreRepaint(true); + } + glad = awtCanvas; + } else if (TOOLKIT == NEWT) { + newtWindow = GLWindow.create(caps); + newtCanvas = new NewtCanvasAWT(newtWindow); + newtCanvas.setBounds(0, 0, applet.width, applet.height); + newtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + newtCanvas.setFocusable(true); + + applet.setLayout(new BorderLayout()); + applet.add(newtCanvas, BorderLayout.CENTER); + + if (IGNORE_AWT_REPAINT) { + newtCanvas.setIgnoreRepaint(true); + } + glad = newtWindow; + } + + demo = new LandscapeES2(SWAP_INTERVAL); + glad.addGLEventListener(demo); + } + + private void initDraw() { + if (TOOLKIT == AWT) { + awtCanvas.setVisible(true); + // Force the realization + awtCanvas.display(); + if (awtCanvas.getDelegatedDrawable().isRealized()) { + // Request the focus here as it cannot work when the window is not visible + awtCanvas.requestFocus(); + } + } else if (TOOLKIT == NEWT) { + newtCanvas.setVisible(true); + // Force the realization + newtWindow.display(); + if (newtWindow.isRealized()) { + // Request the focus here as it cannot work when the window is not visible + newtCanvas.requestFocus(); + } + } + } + + static public void main(String[] args) { + GraphicsEnvironment environment = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice displayDevice = environment.getDefaultScreenDevice(); + + frame = new Frame(displayDevice.getDefaultConfiguration()); + frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); + frame.setTitle("TestBug735Inv2AppletAWT"); + + try { + Class c = Thread.currentThread().getContextClassLoader(). + loadClass(Bug735Inv2AppletAWT.class.getName()); + applet = (Bug735Inv2AppletAWT) c.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + frame.setLayout(null); + frame.add(applet); + frame.pack(); + frame.setResizable(false); + + applet.init(); + + Insets insets = frame.getInsets(); + int windowW = applet.width + insets.left + insets.right; + int windowH = applet.height + insets.top + insets.bottom; + frame.setSize(windowW, windowH); + + Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds(); + frame.setLocation(screenRect.x + (screenRect.width - applet.width) / 2, + screenRect.y + (screenRect.height - applet.height) / 2); + + int usableWindowH = windowH - insets.top - insets.bottom; + applet.setBounds((windowW - applet.width)/2, + insets.top + (usableWindowH - applet.height)/2, + applet.width, applet.height); + + // This allows to close the frame. + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + frame.setVisible(true); + applet.start(); + } +} diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv3AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv3AppletAWT.java new file mode 100644 index 000000000..132a6e464 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv3AppletAWT.java @@ -0,0 +1,203 @@ +package com.jogamp.opengl.test.bugs; + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.SwingUtilities; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.AnimatorBase; + +/** + * Difference to orig. Bug735Inv0AppletAWT: + *
    + *   - Use GLEventListener
    + *   - Add GLEventListener to GLAutoDrawable
    + *   - Use GLAutoDrawable.display() instead of GLAutoDrawable.invoke(true, GLRunnable { init / render })
    + *   - Removed MANUAL_FRAME_HANDLING, obsolete due to GLAutoDrawable/GLEventListener 
    + *   - Use Animator
    + *   - Remove applet, component sizes, use frame based size via validate
    + *   - Run frame validation/visibility on AWT-EDT
    + *   - Add Wait-For-Key after init (perf-test)
    + * 
    + * OSX Results: + *
    + *   - Visible content
    + *   - Stuttering, non-fluent and slow animation
    + * 
    + */ +@SuppressWarnings("serial") +public class Bug735Inv3AppletAWT extends Applet { + static public int AWT = 0; + static public int NEWT = 1; + + static public int APPLET_WIDTH = 500; + static public int APPLET_HEIGHT = 290; + static public int TOOLKIT = NEWT; + static public boolean IGNORE_AWT_REPAINT = false; + static public boolean USE_ECT = false; + static public int SWAP_INTERVAL = 0; + + ////////////////////////////////////////////////////////////////////////////// + + static boolean waitForKey = true; + static private Frame frame; + static private Bug735Inv3AppletAWT applet; + private GLCanvas awtCanvas; + private GLWindow newtWindow; + private GLAutoDrawable glad; + private NewtCanvasAWT newtCanvas; + private GLEventListener demo; + private AnimatorBase animator; + + private int width; + private int height; + + public void init() { + setSize(APPLET_WIDTH, APPLET_HEIGHT); + // JAU setPreferredSize(new Dimension(APPLET_WIDTH, APPLET_HEIGHT)); + width = APPLET_WIDTH; + height = APPLET_HEIGHT; + initGL(); + } + + public void start() { + if(waitForKey) { + UITestCase.waitForKey("Start"); + } + initDraw(); + animator.start(); + } + + private void initGL() { + GLProfile profile = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(profile); + caps.setBackgroundOpaque(true); + caps.setOnscreen(true); + caps.setSampleBuffers(false); + + if (TOOLKIT == AWT) { + awtCanvas = new GLCanvas(caps); + // JAU awtCanvas.setBounds(0, 0, applet.width, applet.height); + awtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + awtCanvas.setFocusable(true); + + applet.setLayout(new BorderLayout()); + applet.add(awtCanvas, BorderLayout.CENTER); + + if (IGNORE_AWT_REPAINT) { + awtCanvas.setIgnoreRepaint(true); + } + glad = awtCanvas; + } else if (TOOLKIT == NEWT) { + newtWindow = GLWindow.create(caps); + newtCanvas = new NewtCanvasAWT(newtWindow); + // JAU newtCanvas.setBounds(0, 0, applet.width, applet.height); + newtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + newtCanvas.setFocusable(true); + + applet.setLayout(new BorderLayout()); + applet.add(newtCanvas, BorderLayout.CENTER); + + if (IGNORE_AWT_REPAINT) { + newtCanvas.setIgnoreRepaint(true); + } + glad = newtWindow; + } + + demo = new LandscapeES2(SWAP_INTERVAL); + glad.addGLEventListener(demo); + animator = new Animator(glad); + animator.setExclusiveContext(USE_ECT); + } + + private void initDraw() { + if (TOOLKIT == AWT) { + // JAU awtCanvas.setVisible(true); + if (awtCanvas.getDelegatedDrawable().isRealized()) { + // Request the focus here as it cannot work when the window is not visible + awtCanvas.requestFocus(); + } + } else if (TOOLKIT == NEWT) { + // JAU newtCanvas.setVisible(true); + // Force the realization + // JAU newtWindow.display(); + if (newtWindow.isRealized()) { + // Request the focus here as it cannot work when the window is not visible + newtCanvas.requestFocus(); + } + } + } + + static public void main(String[] args) { + final GraphicsEnvironment environment = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + final GraphicsDevice displayDevice = environment.getDefaultScreenDevice(); + + frame = new Frame(displayDevice.getDefaultConfiguration()); + frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); + frame.setTitle("TestBug735Inv3AppletAWT"); + + // This allows to close the frame. + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + try { + Class c = Thread.currentThread().getContextClassLoader(). + loadClass(Bug735Inv3AppletAWT.class.getName()); + applet = (Bug735Inv3AppletAWT) c.newInstance(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + // JAU frame.setLayout(null); + frame.add(applet); + + applet.init(); + + Insets insets = frame.getInsets(); + final int windowW = applet.width + insets.left + insets.right; + final int windowH = applet.height + insets.top + insets.bottom; + + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(windowW, windowH); + frame.validate(); + // JAU frame.pack(); + Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds(); + frame.setLocation(screenRect.x + (screenRect.width - applet.width) / 2, + screenRect.y + (screenRect.height - applet.height) / 2); + + frame.setResizable(false); + frame.setVisible(true); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + + applet.start(); + } +} diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java new file mode 100644 index 000000000..1c98af7d4 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java @@ -0,0 +1,188 @@ +package com.jogamp.opengl.test.bugs; + +import java.awt.Color; +import java.awt.Frame; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.Insets; +import java.awt.Rectangle; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.SwingUtilities; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.AnimatorBase; + +/** + * Difference to orig. Bug735Inv0AppletAWT: + *
    + *   - Use GLEventListener
    + *   - Add GLEventListener to GLAutoDrawable
    + *   - Use GLAutoDrawable.display() instead of GLAutoDrawable.invoke(true, GLRunnable { init / render })
    + *   - Removed MANUAL_FRAME_HANDLING, obsolete due to GLAutoDrawable/GLEventListener 
    + *   - Use Animator
    + *   - Remove component sizes, use frame based size via validate
    + *   - Run frame validation/visibility on AWT-EDT
    + *   - Add Wait-For-Key after init (perf-test)
    + *   - Remove intermediate applet!
    + * 
    + * OSX Results: + *
    + *   - Visible content
    + *   - Fluent animation
    + * 
    + */ +public class Bug735Inv4AWT { + static public int AWT = 0; + static public int NEWT = 1; + + static public int APPLET_WIDTH = 500; + static public int APPLET_HEIGHT = 290; + static public int TOOLKIT = NEWT; + static public boolean NEWT_ROOT = false; + static public boolean IGNORE_AWT_REPAINT = false; + static public boolean USE_ECT = false; + static public int SWAP_INTERVAL = 0; + + ////////////////////////////////////////////////////////////////////////////// + + static boolean waitForKey = true; + static private Frame frame; + static private Bug735Inv4AWT applet; + private GLCanvas awtCanvas; + private GLWindow newtWindow; + private GLAutoDrawable glad; + private NewtCanvasAWT newtCanvas; + private GLEventListener demo; + private AnimatorBase animator; + + private int width; + private int height; + + public void init() { + width = APPLET_WIDTH; + height = APPLET_HEIGHT; + initGL(); + } + + public void start() { + if(waitForKey) { + UITestCase.waitForKey("Start"); + } + initDraw(); + animator.start(); + } + + private void initGL() { + GLProfile profile = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(profile); + caps.setBackgroundOpaque(true); + caps.setOnscreen(true); + caps.setSampleBuffers(false); + + if (TOOLKIT == AWT) { + awtCanvas = new GLCanvas(caps); + awtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + awtCanvas.setFocusable(true); + + if (IGNORE_AWT_REPAINT) { + awtCanvas.setIgnoreRepaint(true); + } + glad = awtCanvas; + } else if (TOOLKIT == NEWT) { + newtWindow = GLWindow.create(caps); + newtCanvas = new NewtCanvasAWT(newtWindow); + newtCanvas.setBackground(new Color(0xFFCCCCCC, true)); + newtCanvas.setFocusable(true); + + if (IGNORE_AWT_REPAINT) { + newtCanvas.setIgnoreRepaint(true); + } + glad = newtWindow; + } + + demo = new LandscapeES2(SWAP_INTERVAL); + // demo = new GearsES2(SWAP_INTERVAL); + glad.addGLEventListener(demo); + animator = new Animator(glad); + animator.setExclusiveContext(USE_ECT); + } + + private void initDraw() { + if (TOOLKIT == AWT) { + if (awtCanvas.getDelegatedDrawable().isRealized()) { + // Request the focus here as it cannot work when the window is not visible + awtCanvas.requestFocus(); + } + } else if (TOOLKIT == NEWT) { + // newtCanvas.repaint(); + // Force the realization + // newtWindow.display(); + if (newtWindow.isRealized()) { + // Request the focus here as it cannot work when the window is not visible + newtCanvas.requestFocus(); + } + } + } + + static public void main(String[] args) { + final GraphicsEnvironment environment = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + final GraphicsDevice displayDevice = environment.getDefaultScreenDevice(); + + frame = new Frame(displayDevice.getDefaultConfiguration()); + // JAU frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); + frame.setTitle("TestBug735Inv3AppletAWT"); + + // This allows to close the frame. + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + + applet = new Bug735Inv4AWT(); + applet.init(); + + if (TOOLKIT == AWT) { + frame.add(applet.awtCanvas); + } else if (TOOLKIT == NEWT) { + frame.add(applet.newtCanvas); + } + // frame.pack(); + // frame.setResizable(false); + + Insets insets = frame.getInsets(); + final int windowW = applet.width + insets.left + insets.right; + final int windowH = applet.height + insets.top + insets.bottom; + + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(windowW, windowH); + frame.validate(); + // frame.pack(); + Rectangle screenRect = displayDevice.getDefaultConfiguration().getBounds(); + frame.setLocation(screenRect.x + (screenRect.width - applet.width) / 2, + screenRect.y + (screenRect.height - applet.height) / 2); + + frame.setVisible(true); + } + }); + } catch (Exception e) { + e.printStackTrace(); + } + + applet.start(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java new file mode 100644 index 000000000..3b4187045 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/LandscapeES2.java @@ -0,0 +1,184 @@ +/** + * Copyright (C) 2013 JogAmp Community. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2; + +import com.jogamp.opengl.util.GLArrayDataServer; +import com.jogamp.opengl.util.glsl.ShaderCode; +import com.jogamp.opengl.util.glsl.ShaderProgram; +import com.jogamp.opengl.util.glsl.ShaderState; +import java.nio.FloatBuffer; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLUniformData; + +/** + * LandscapeES2 + */ +public class LandscapeES2 implements GLEventListener { + private int swapInterval = 0; + private boolean verbose = true; + + static public int TARGET_FPS = 120; + private long millisOffset; + private int frameCount; + private float frameRate; + private ShaderCode vertShader; + private ShaderCode fragShader; + private ShaderProgram shaderProg; + private ShaderState shaderState; + private float[] resolution; + private GLUniformData resolutionUni; + private GLUniformData timeUni; + private GLArrayDataServer vertices; + + private int fcount = 0, lastm = 0; + private int fint = 1; + + public LandscapeES2(int swapInterval) { + this.swapInterval = swapInterval; + } + + public LandscapeES2() { + this.swapInterval = 1; + } + + public void setVerbose(boolean v) { verbose = v; } + + public void init(GLAutoDrawable drawable) { + System.err.println(Thread.currentThread()+" LandscapeES2.init ..."); + GL2ES2 gl = drawable.getGL().getGL2ES2(); + + if(verbose) { + System.err.println("LandscapeES2 init on "+Thread.currentThread()); + System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); + System.err.println("INIT GL IS: " + gl.getClass().getName()); + System.err.println("GL_VENDOR: " + gl.glGetString(GL.GL_VENDOR)); + System.err.println("GL_RENDERER: " + gl.glGetString(GL.GL_RENDERER)); + System.err.println("GL_VERSION: " + gl.glGetString(GL.GL_VERSION)); + System.err.println("GL GLSL: "+gl.hasGLSL()+", has-compiler-func: "+gl.isFunctionAvailable("glCompileShader")+", version "+(gl.hasGLSL() ? gl.glGetString(GL2ES2.GL_SHADING_LANGUAGE_VERSION) : "none")+", "+gl.getContext().getGLSLVersionNumber()); + System.err.println("GL FBO: basic "+ gl.hasBasicFBOSupport()+", full "+gl.hasFullFBOSupport()); + System.err.println("GL Profile: "+gl.getGLProfile()); + System.err.println("GL Renderer Quirks:" + gl.getContext().getRendererQuirks().toString()); + System.err.println("GL:" + gl + ", " + gl.getContext().getGLVersion()); + } + + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + + vertShader = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader", "shader/bin", "landscape", true); + fragShader = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", "shader/bin", "landscape", true); + vertShader.defaultShaderCustomization(gl, true, true); + fragShader.defaultShaderCustomization(gl, true, true); + shaderProg = new ShaderProgram(); + shaderProg.add(gl, vertShader, System.err); + shaderProg.add(gl, fragShader, System.err); + + shaderState = new ShaderState(); + shaderState.attachShaderProgram(gl, shaderProg, true); + + resolution = new float[] { drawable.getWidth(), drawable.getHeight(), 0}; + resolutionUni = new GLUniformData("iResolution", 3, FloatBuffer.wrap(resolution)); + shaderState.ownUniform(resolutionUni); + shaderState.uniform(gl, resolutionUni); + + timeUni = new GLUniformData("iGlobalTime", 0.0f); + shaderState.ownUniform(timeUni); + + vertices = GLArrayDataServer.createGLSL("inVertex", 2, GL.GL_FLOAT, false, 4, GL.GL_STATIC_DRAW); + vertices.putf(-1.0f); vertices.putf(-1.0f); + vertices.putf(+1.0f); vertices.putf(-1.0f); + vertices.putf(-1.0f); vertices.putf(+1.0f); + vertices.putf(+1.0f); vertices.putf(+1.0f); + vertices.seal(gl, true); + shaderState.ownAttribute(vertices, true); + shaderState.useProgram(gl, false); + + millisOffset = System.currentTimeMillis(); + + System.err.println(Thread.currentThread()+" LandscapeES2.init FIN"); + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + System.err.println(Thread.currentThread()+" LandscapeES2.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); + + GL2ES2 gl = drawable.getGL().getGL2ES2(); + + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } + + shaderState.useProgram(gl, true); + + resolution[0] = drawable.getWidth(); + resolution[1] = drawable.getHeight(); + shaderState.uniform(gl, resolutionUni); + + shaderState.useProgram(gl, false); + } + + public void dispose(GLAutoDrawable drawable) { + System.err.println(Thread.currentThread()+" LandscapeES2.dispose ... "); + GL2ES2 gl = drawable.getGL().getGL2ES2(); + shaderState.useProgram(gl, false); + shaderState.destroy(gl); + shaderState = null; + + System.err.println(Thread.currentThread()+" LandscapeES2.dispose FIN"); + } + + public void display(GLAutoDrawable drawable) { + GL2ES2 gl = drawable.getGL().getGL2ES2(); + // gl.glClearColor(0.5f, 0.1f, 0.1f, 1); + // gl.glClear(GL.GL_COLOR_BUFFER_BIT); + // gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + shaderState.useProgram(gl, true); + + timeUni.setData((System.currentTimeMillis() - millisOffset) / 1000.0f); + shaderState.uniform(gl, timeUni); + vertices.enableBuffer(gl, true); + gl.glDrawArrays(GL2ES2.GL_TRIANGLE_STRIP, 0, 4); + vertices.enableBuffer(gl, false); + + shaderState.useProgram(gl, false); + + // Compute current framerate and printout. + frameCount++; + fcount += 1; + int m = (int) (System.currentTimeMillis() - millisOffset); + if (m - lastm > 1000 * fint) { + frameRate = (float)(fcount) / fint; + fcount = 0; + lastm = m; + } + if (frameCount % TARGET_FPS == 0) { + System.out.println("FrameCount: " + frameCount + " - " + "FrameRate: " + frameRate); + } + } + + boolean confinedFixedCenter = false; + + public void setConfinedFixedCenter(boolean v) { + confinedFixedCenter = v; + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java new file mode 100644 index 000000000..4ca70d7d3 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java @@ -0,0 +1,175 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; + +import com.jogamp.newt.event.KeyAdapter; +import com.jogamp.newt.event.KeyEvent; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.QuitAdapter; + +import com.jogamp.opengl.util.Animator; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.Test; + +public class TestLandscapeES2NEWT extends UITestCase { + static int width = 500, height = 290; + static int swapInterval = 1; + static boolean forceES2 = false; + static boolean forceGL3 = false; + static boolean mainRun = false; + static boolean exclusiveContext = false; + static boolean useAnimator = true; + + protected void runTestGL(GLCapabilities caps) throws InterruptedException { + System.err.println("requested: swapInterval "+swapInterval+", "+caps); + final GLWindow glWindow = GLWindow.create(caps); + glWindow.setTitle(getSimpleTestName(".")); + glWindow.setSize(width, height); + + final LandscapeES2 demo = new LandscapeES2(swapInterval); + glWindow.addGLEventListener(demo); + + final SnapshotGLEventListener snap = new SnapshotGLEventListener(); + snap.setPostSNDetail(demo.getClass().getSimpleName()); + glWindow.addGLEventListener(snap); + + final Animator animator = useAnimator ? new Animator() : null; + if( useAnimator ) { + animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); + animator.setExclusiveContext(exclusiveContext); + } + + QuitAdapter quitAdapter = new QuitAdapter(); + + //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); + //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + glWindow.addKeyListener(new KeyAdapter() { + public void keyTyped(KeyEvent e) { + if(e.getKeyChar()=='f') { + new Thread() { + public void run() { + glWindow.setFullscreen(!glWindow.isFullscreen()); + } }.start(); + } else if(e.getKeyChar()=='d') { + new Thread() { + public void run() { + glWindow.setUndecorated(!glWindow.isUndecorated()); + } }.start(); + } + } + }); + + if( useAnimator ) { + animator.add(glWindow); + animator.start(); + } + glWindow.setVisible(true); + if( useAnimator ) { + animator.setUpdateFPSFrames(60, System.err); + } + + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); + System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); + System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + + snap.setMakeSnapshot(); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()= 130 + #define varying in + out vec4 mgl_FragColor; +#else + #define mgl_FragColor gl_FragColor +#endif + +uniform vec3 iResolution; +uniform float iGlobalTime; + +// Created by inigo quilez - iq/2013 +// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. + +//stereo thanks to Croqueteer +//#define STEREO + +mat3 m = mat3( 0.00, 0.80, 0.60, + -0.80, 0.36, -0.48, + -0.60, -0.48, 0.64 ); + +float hash( float n ) +{ + return fract(sin(n)*43758.5453123); +} + + +float noise( in vec3 x ) +{ + vec3 p = floor(x); + vec3 f = fract(x); + + f = f*f*(3.0-2.0*f); + + float n = p.x + p.y*57.0 + 113.0*p.z; + + float res = mix(mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x), + mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y), + mix(mix( hash(n+113.0), hash(n+114.0),f.x), + mix( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z); + return res; +} + + + + +vec3 noised( in vec2 x ) +{ + vec2 p = floor(x); + vec2 f = fract(x); + + vec2 u = f*f*(3.0-2.0*f); + + float n = p.x + p.y*57.0; + + float a = hash(n+ 0.0); + float b = hash(n+ 1.0); + float c = hash(n+ 57.0); + float d = hash(n+ 58.0); + return vec3(a+(b-a)*u.x+(c-a)*u.y+(a-b-c+d)*u.x*u.y, + 30.0*f*f*(f*(f-2.0)+1.0)*(vec2(b-a,c-a)+(a-b-c+d)*u.yx)); + +} + +float noise( in vec2 x ) +{ + vec2 p = floor(x); + vec2 f = fract(x); + + f = f*f*(3.0-2.0*f); + + float n = p.x + p.y*57.0; + + float res = mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x), + mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y); + + return res; +} + +float fbm( vec3 p ) +{ + float f = 0.0; + + f += 0.5000*noise( p ); p = m*p*2.02; + f += 0.2500*noise( p ); p = m*p*2.03; + f += 0.1250*noise( p ); p = m*p*2.01; + f += 0.0625*noise( p ); + + return f/0.9375; +} + +mat2 m2 = mat2(1.6,-1.2,1.2,1.6); + +float fbm( vec2 p ) +{ + float f = 0.0; + + f += 0.5000*noise( p ); p = m2*p*2.02; + f += 0.2500*noise( p ); p = m2*p*2.03; + f += 0.1250*noise( p ); p = m2*p*2.01; + f += 0.0625*noise( p ); + + return f/0.9375; +} + +float terrain( in vec2 x ) +{ + vec2 p = x*0.003; + float a = 0.0; + float b = 1.0; + vec2 d = vec2(0.0); + for(int i=0;i<5; i++) + { + vec3 n = noised(p); + d += n.yz; + a += b*n.x/(1.0+dot(d,d)); + b *= 0.5; + p=mat2(1.6,-1.2,1.2,1.6)*p; + } + + return 140.0*a; +} + +float terrain2( in vec2 x ) +{ + vec2 p = x*0.003; + float a = 0.0; + float b = 1.0; + vec2 d = vec2(0.0); + for(int i=0;i<14; i++) + { + vec3 n = noised(p); + d += n.yz; + a += b*n.x/(1.0+dot(d,d)); + b *= 0.5; + p=m2*p; + } + + return 140.0*a; +} + + +float map( in vec3 p ) +{ + float h = terrain(p.xz); + + float ss = 0.03; + float hh = h*ss; + float fh = fract(hh); + float ih = floor(hh); + fh = mix( sqrt(fh), fh, smoothstep(50.0,140.0,h) ); + h = (ih+fh)/ss; + + return p.y - h; +} + +float map2( in vec3 p ) +{ + float h = terrain2(p.xz); + + + float ss = 0.03; + float hh = h*ss; + float fh = fract(hh); + float ih = floor(hh); + fh = mix( sqrt(fh), fh, smoothstep(50.0,140.0,h) ); + h = (ih+fh)/ss; + + return p.y - h; +} + +bool jinteresct(in vec3 rO, in vec3 rD, out float resT ) +{ + float h = 0.0; + float t = 0.0; + for( int j=0; j<120; j++ ) + { + //if( t>2000.0 ) break; + + vec3 p = rO + t*rD; +if( p.y>300.0 ) break; + h = map( p ); + + if( h<0.1 ) + { + resT = t; + return true; + } + t += max(0.1,0.5*h); + + } + + if( h<5.0 ) + { + resT = t; + return true; + } + return false; +} + +float sinteresct(in vec3 rO, in vec3 rD ) +{ + float res = 1.0; + float t = 0.0; + for( int j=0; j<50; j++ ) + { + //if( t>1000.0 ) break; + vec3 p = rO + t*rD; + + float h = map( p ); + + if( h<0.1 ) + { + return 0.0; + } + res = min( res, 16.0*h/t ); + t += h; + + } + + return clamp( res, 0.0, 1.0 ); +} + +vec3 calcNormal( in vec3 pos, float t ) +{ + float e = 0.001; + e = 0.001*t; + vec3 eps = vec3(e,0.0,0.0); + vec3 nor; + nor.x = map2(pos+eps.xyy) - map2(pos-eps.xyy); + nor.y = map2(pos+eps.yxy) - map2(pos-eps.yxy); + nor.z = map2(pos+eps.yyx) - map2(pos-eps.yyx); + return normalize(nor); +} + +vec3 camPath( float time ) +{ + vec2 p = 600.0*vec2( cos(1.4+0.37*time), + cos(3.2+0.31*time) ); + + return vec3( p.x, 0.0, p.y ); +} + +void main(void) +{ + vec2 xy = -1.0 + 2.0*gl_FragCoord.xy / iResolution.xy; + + vec2 s = xy*vec2(1.75,1.0); + + #ifdef STEREO + float isCyan = mod(gl_FragCoord.x + mod(gl_FragCoord.y,2.0),2.0); + #endif + + float time = iGlobalTime*.15; + + vec3 light1 = normalize( vec3( 0.4, 0.22, 0.6 ) ); + vec3 light2 = vec3( -0.707, 0.000, -0.707 ); + + + vec3 campos = camPath( time ); + vec3 camtar = camPath( time + 3.0 ); + campos.y = terrain( campos.xz ) + 15.0; + camtar.y = campos.y*0.5; + + float roll = 0.1*cos(0.1*time); + vec3 cw = normalize(camtar-campos); + vec3 cp = vec3(sin(roll), cos(roll),0.0); + vec3 cu = normalize(cross(cw,cp)); + vec3 cv = normalize(cross(cu,cw)); + vec3 rd = normalize( s.x*cu + s.y*cv + 1.6*cw ); + + #ifdef STEREO + campos += 2.0*cu*isCyan; // move camera to the right - the rd vector is still good + #endif + + float sundot = clamp(dot(rd,light1),0.0,1.0); + vec3 col; + float t; + if( !jinteresct(campos,rd,t) ) + { + col = 0.9*vec3(0.97,.99,1.0)*(1.0-0.3*rd.y); + col += 0.2*vec3(0.8,0.7,0.5)*pow( sundot, 4.0 ); + } + else + { + vec3 pos = campos + t*rd; + + vec3 nor = calcNormal( pos, t ); + + float dif1 = clamp( dot( light1, nor ), 0.0, 1.0 ); + float dif2 = clamp( 0.2 + 0.8*dot( light2, nor ), 0.0, 1.0 ); + float sh = 1.0; + if( dif1>0.001 ) + sh = sinteresct(pos+light1*20.0,light1); + + vec3 dif1v = vec3(dif1); + dif1v *= vec3( sh, sh*sh*0.5+0.5*sh, sh*sh ); + + float r = noise( 7.0*pos.xz ); + + col = (r*0.25+0.75)*0.9*mix( vec3(0.10,0.05,0.03), vec3(0.13,0.10,0.08), clamp(terrain2( vec2(pos.x,pos.y*48.0))/200.0,0.0,1.0) ); + col = mix( col, 0.17*vec3(0.5,.23,0.04)*(0.50+0.50*r),smoothstep(0.70,0.9,nor.y) ); + col = mix( col, 0.10*vec3(0.2,.30,0.00)*(0.25+0.75*r),smoothstep(0.95,1.0,nor.y) ); + col *= 0.75; + // snow + #if 1 + float h = smoothstep(55.0,80.0,pos.y + 25.0*fbm(0.01*pos.xz) ); + float e = smoothstep(1.0-0.5*h,1.0-0.1*h,nor.y); + float o = 0.3 + 0.7*smoothstep(0.0,0.1,nor.x+h*h); + float s = h*e*o; + s = smoothstep( 0.1, 0.9, s ); + col = mix( col, 0.4*vec3(0.6,0.65,0.7), s ); + #endif + + + vec3 brdf = 2.0*vec3(0.17,0.19,0.20)*clamp(nor.y,0.0,1.0); + brdf += 6.0*vec3(1.00,0.95,0.80)*dif1v; + brdf += 2.0*vec3(0.20,0.20,0.20)*dif2; + + col *= brdf; + + float fo = 1.0-exp(-pow(0.0015*t,1.5)); + vec3 fco = vec3(0.7) + 0.6*vec3(0.8,0.7,0.5)*pow( sundot, 4.0 ); + col = mix( col, fco, fo ); + } + + col = sqrt(col); + + vec2 uv = xy*0.5+0.5; + col *= 0.7 + 0.3*pow(16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y),0.1); + + #ifdef STEREO + col *= vec3( isCyan, 1.0-isCyan, 1.0-isCyan ); + #endif + + mgl_FragColor = vec4(col,1.0); +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/landscape.vp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/landscape.vp new file mode 100644 index 000000000..fc698f2a8 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/landscape.vp @@ -0,0 +1,11 @@ + +#if __VERSION__ >= 130 + #define attribute in + #define varying out +#endif + +attribute vec2 inVertex; + +void main() { + gl_Position = vec4(inVertex, 0, 1); +} \ No newline at end of file -- cgit v1.2.3 From 05d8a9490497413df11fd2faf07e34d648130966 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Jun 2013 04:31:02 +0200 Subject: Bug 735: Bug735Inv4AWT on Java7 is also stuttering! --- make/scripts/tests.sh | 4 ++-- .../com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java | 2 +- .../com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java | 2 +- .../com/jogamp/opengl/test/bugs/Bug735Inv3AppletAWT.java | 7 +++---- src/test/com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java | 12 ++++++------ 5 files changed, 13 insertions(+), 14 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 17dccdcaf..61ac63a3a 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -439,12 +439,12 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv2AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv4AppletAWT $* +testawt com.jogamp.opengl.test.bugs.Bug735Inv4AWT $* # # swt (testswt) diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java index b240f0cfb..64cfe2f32 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java @@ -382,7 +382,7 @@ public class Bug735Inv0AppletAWT extends Applet implements Runnable { frame = new Frame(displayDevice.getDefaultConfiguration()); frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); - frame.setTitle("TestBug735InvAppletAWT"); + frame.setTitle("TestBug735Inv0AppletAWT"); try { Class c = Thread.currentThread().getContextClassLoader(). diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java index e1bdbba77..201418035 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java @@ -384,7 +384,7 @@ public class Bug735Inv1AppletAWT extends Applet implements Runnable { frame = new Frame(displayDevice.getDefaultConfiguration()); frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); - frame.setTitle("TestBug735InvAppletAWT"); + frame.setTitle("TestBug735Inv1AppletAWT"); try { Class c = Thread.currentThread().getContextClassLoader(). diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv3AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv3AppletAWT.java index 132a6e464..be5083851 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv3AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv3AppletAWT.java @@ -3,7 +3,6 @@ package com.jogamp.opengl.test.bugs; import java.applet.Applet; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.Dimension; import java.awt.Frame; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; @@ -80,9 +79,6 @@ public class Bug735Inv3AppletAWT extends Applet { } public void start() { - if(waitForKey) { - UITestCase.waitForKey("Start"); - } initDraw(); animator.start(); } @@ -148,6 +144,9 @@ public class Bug735Inv3AppletAWT extends Applet { } static public void main(String[] args) { + if(waitForKey) { + UITestCase.waitForKey("Start"); + } final GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice displayDevice = environment.getDefaultScreenDevice(); diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java index 1c98af7d4..f07d000eb 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java @@ -39,7 +39,8 @@ import com.jogamp.opengl.util.AnimatorBase; * OSX Results: *
      *   - Visible content
    - *   - Fluent animation
    + *   - Java6: Fluent animation
    + *   - Java7: Stuttering, non-fluent and slow animation
      * 
    */ public class Bug735Inv4AWT { @@ -49,7 +50,6 @@ public class Bug735Inv4AWT { static public int APPLET_WIDTH = 500; static public int APPLET_HEIGHT = 290; static public int TOOLKIT = NEWT; - static public boolean NEWT_ROOT = false; static public boolean IGNORE_AWT_REPAINT = false; static public boolean USE_ECT = false; static public int SWAP_INTERVAL = 0; @@ -76,9 +76,6 @@ public class Bug735Inv4AWT { } public void start() { - if(waitForKey) { - UITestCase.waitForKey("Start"); - } initDraw(); animator.start(); } @@ -136,13 +133,16 @@ public class Bug735Inv4AWT { } static public void main(String[] args) { + if(waitForKey) { + UITestCase.waitForKey("Start"); + } final GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); final GraphicsDevice displayDevice = environment.getDefaultScreenDevice(); frame = new Frame(displayDevice.getDefaultConfiguration()); // JAU frame.setBackground(new Color(0xCC, 0xCC, 0xCC)); - frame.setTitle("TestBug735Inv3AppletAWT"); + frame.setTitle("TestBug735Inv4AWT"); // This allows to close the frame. frame.addWindowListener(new WindowAdapter() { -- cgit v1.2.3 From d7e2cb6fdec200d25a9189f7951c5f94c26a1ce4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Jun 2013 04:39:58 +0200 Subject: Fix Bug 753: Stuttering caused by lack of GL resource synchronization between Java GL- and CALayer thread ; Simplify / Fix waitUntilRenderSignal(). Stuttering caused by lack of GL resource synchronization between Java GL- and CALayer thread + // Required(?) to finish previous GL rendering to give CALayer proper result, + // i.e. synchronize both threads each w/ their GLContext sharing same resources. + // + // FIXME: IMHO this synchronization should be implicitly performed via 'CGL.flushBuffer(contextHandle)' above, + // in case this will be determined a driver bug - use a QUIRK entry in GLRendererQuirks! + gl.glFinish(); Simplify / Fix waitUntilRenderSignal() - remove loop and 'ready' condition -> nonsense - if too later, i.e. lastWaitTime+TO < now, use now+TO as max. vsync waiting time Bug735 Tests: - Make vsync, wait and ECT (exclusive context thread) configurable via main args. - Inv2*, Inv3* and Inv4*: Fluent Animation - Works w/ ECT --- make/scripts/tests.sh | 5 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 52 +- .../macosx/MacOSXWindowSystemInterface-calayer.m | 63 +- .../aaaa-m1-sync0-flush-wait-finish.log | 751 +++++++++++++++++++++ .../aaaa-m1-sync1-flush-wait-finish.log | 745 ++++++++++++++++++++ .../aaaa-m2-sync0-finish-wait-exclctx.log | 751 +++++++++++++++++++++ .../aaaa-m2-sync0-finish-wait.log | 751 +++++++++++++++++++++ .../aaaa-m2-sync1-finish-wait.log | 745 ++++++++++++++++++++ .../opengl/test/bugs/Bug735Inv2AppletAWT.java | 23 +- .../opengl/test/bugs/Bug735Inv3AppletAWT.java | 22 +- .../com/jogamp/opengl/test/bugs/Bug735Inv4AWT.java | 22 +- .../test/junit/jogl/demos/es2/LandscapeES2.java | 4 +- 12 files changed, 3887 insertions(+), 47 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m1-sync0-flush-wait-finish.log create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m1-sync1-flush-wait-finish.log create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync0-finish-wait-exclctx.log create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync0-finish-wait.log create mode 100644 src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync1-finish-wait.log (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 61ac63a3a..ee4411c08 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -440,11 +440,12 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv2AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* -testawt com.jogamp.opengl.test.bugs.Bug735Inv4AWT $* +testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv4AWT $* # # swt (testswt) diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 976056891..6b086ce44 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -81,7 +81,7 @@ import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; public class MacOSXCGLContext extends GLContextImpl -{ +{ // Abstract interface for implementation of this context (either // NSOpenGL-based or CGL-based) protected interface GLBackendImpl { @@ -1000,6 +1000,8 @@ public class MacOSXCGLContext extends GLContextImpl CGL.setNSOpenGLLayerSwapInterval(l, interval); if( 0 < interval ) { vsyncTimeout = interval * screenVSyncTimeout + 1000; // +1ms + } else { + vsyncTimeout = 1 * screenVSyncTimeout + 1000; // +1ms } if(DEBUG) { System.err.println("NS setSwapInterval: "+interval+" -> "+vsyncTimeout+" micros"); } } @@ -1008,6 +1010,14 @@ public class MacOSXCGLContext extends GLContextImpl } private int skipSync=0; + /** TODO: Remove after discussion + private boolean perfIterReset = false; + private int perfIter = 0; + private long waitGLS = 0; + private long finishGLS = 0; + private long frameXS = 0; + private long lastFrameStart = 0; + */ @Override public boolean swapBuffers() { @@ -1036,6 +1046,45 @@ public class MacOSXCGLContext extends GLContextImpl res = CGL.flushBuffer(contextHandle); if(res) { if(0 == skipSync) { + /** TODO: Remove after discussion + perfIter++; + if( !perfIterReset && 100 == perfIter ) { + perfIterReset = true; + perfIter = 1; + waitGLS = 0; + finishGLS = 0; + frameXS = 0; + } + final long lastFramePeriod0 = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()) - lastFrameStart; + gl.glFinish(); // Require to finish previous GL rendering to give CALayer proper result + final long lastFramePeriod1 = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()) - lastFrameStart; + + // If v-sync is disabled, frames will be drawn as quickly as possible w/o delay, + // while still synchronizing w/ CALayer. + // If v-sync is enabled wait until next swap interval (v-sync). + CGL.waitUntilNSOpenGLLayerIsReady(cmd.nsOpenGLLayer, vsyncTimeout); + final long lastFramePeriodX = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()) - lastFrameStart; + + final long finishGL = lastFramePeriod1 - lastFramePeriod0; + final long waitGL = lastFramePeriodX - lastFramePeriod1; + finishGLS += finishGL; + waitGLS += waitGL; + frameXS += lastFramePeriodX; + + System.err.println("XXX["+perfIter+"] TO "+vsyncTimeout/1000+" ms, "+ + "lFrame0 "+lastFramePeriod0/1000+" ms, "+ + "lFrameX "+lastFramePeriodX/1000+" / "+frameXS/1000+" ~"+(frameXS/perfIter)/1000.0+" ms, "+ + "finishGL "+finishGL/1000+" / "+finishGLS/1000+" ~"+(finishGLS/perfIter)/1000.0+" ms, "+ + "waitGL "+waitGL/1000+" / "+waitGLS/1000+" ~"+(waitGLS/perfIter)/1000.0+" ms"); + */ + // + // Required(?) to finish previous GL rendering to give CALayer proper result, + // i.e. synchronize both threads each w/ their GLContext sharing same resources. + // + // FIXME: IMHO this synchronization should be implicitly performed via 'CGL.flushBuffer(contextHandle)' above, + // in case this will be determined a driver bug - use a QUIRK entry in GLRendererQuirks! + gl.glFinish(); + // If v-sync is disabled, frames will be drawn as quickly as possible w/o delay, // while still synchronizing w/ CALayer. // If v-sync is enabled wait until next swap interval (v-sync). @@ -1050,6 +1099,7 @@ public class MacOSXCGLContext extends GLContextImpl // trigger CALayer to update incl. possible surface change (new pbuffer handle) CGL.setNSOpenGLLayerNeedsDisplayPBuffer(cmd.nsOpenGLLayer, drawable.getHandle()); } + // lastFrameStart = TimeUnit.NANOSECONDS.toMicros(System.nanoTime()); } } else { res = true; diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index 6738364a7..046171efc 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -818,40 +818,39 @@ static const GLfloat gl_verts[] = { - (void)waitUntilRenderSignal: (long) to_micros { - BOOL ready = NO; - int wr = 0; + struct timespec t0, to_until; + BOOL tooLate; + int wr; + if( 0 >= to_micros ) { + to_micros = 16666 + 1000; // defaults to 1/60s + 1ms + NSLog(@"MyNSOpenGLContext::waitUntilRenderSignal: to_micros was zero, using defaults"); + } pthread_mutex_lock(&renderLock); - SYNC_PRINT("{W %ld us", to_micros); - do { - if(0 >= swapInterval) { - ready = YES; - } - if(NO == ready) { - #ifdef DBG_SYNC - struct timespec t0, t1, td, td2; - timespec_now(&t0); - #endif - if( 0 >= to_micros ) { - to_micros = 16666 + 1000; // defaults to 1/60s + 1ms - NSLog(@"MyNSOpenGLContext::waitUntilRenderSignal: to_micros was zero, using defaults"); - } - struct timespec to_abs = lastWaitTime; - timespec_addmicros(&to_abs, to_micros); - #ifdef DBG_SYNC - timespec_subtract(&td, &to_abs, &t0); - fprintf(stderr, ", (%ld) / ", timespec_milliseconds(&td)); - #endif - wr = pthread_cond_timedwait(&renderSignal, &renderLock, &to_abs); - #ifdef DBG_SYNC - timespec_now(&t1); - timespec_subtract(&td, &t1, &t0); - timespec_subtract(&td2, &t1, &lastWaitTime); - fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); - #endif - ready = YES; + timespec_now(&t0); + to_until = lastWaitTime; + timespec_addmicros(&to_until, to_micros); + tooLate = timespec_compare(&to_until, &t0) < 0; + #ifdef DBG_SYNC + struct timespec td_until; + timespec_subtract(&td_until, &to_until, &t0); + SYNC_PRINT("{W %ld ms, to %ld ms, late %d", to_micros/1000, timespec_milliseconds(&td_until), tooLate); + #endif + if( 0 < swapInterval ) { + if( tooLate ) { + // adjust! + to_until = t0; + timespec_addmicros(&to_until, to_micros); } - } while (NO == ready && 0 == wr) ; - SYNC_PRINT("-%d-%d-%d}", shallDraw, wr, ready); + wr = pthread_cond_timedwait(&renderSignal, &renderLock, &to_until); + #ifdef DBG_SYNC + struct timespec t1, td, td2; + timespec_now(&t1); + timespec_subtract(&td, &t1, &t0); + timespec_subtract(&td2, &t1, &lastWaitTime); + fprintf(stderr, "(%ld) / (%ld) ms", timespec_milliseconds(&td), timespec_milliseconds(&td2)); + #endif + } + SYNC_PRINT("-%d-%d}\n", shallDraw, wr); timespec_now(&lastWaitTime); pthread_mutex_unlock(&renderLock); } diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m1-sync0-flush-wait-finish.log b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m1-sync0-flush-wait-finish.log new file mode 100644 index 000000000..2261a3caa --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m1-sync0-flush-wait-finish.log @@ -0,0 +1,751 @@ +NSZombieEnabled +NSTraceEvents YES +OBJC_PRINT_EXCEPTIONS +/usr/bin/java +java version "1.6.0_37" +Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909) +Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode) +LD_LIBRARY_PATH :../../gluegen/make/../build-macosx/obj:../build-macosx/lib +LIBXCB_ALLOW_SLOPPY_LOCK: +LIBGL_DRIVERS_PATH: +LIBGL_DEBUG: +LIBGL_ALWAYS_INDIRECT: +LIBGL_ALWAYS_SOFTWARE: +SWT_CLASSPATH: ../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar +/usr/bin/java -d64 -time 100000 -vsync 0 +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar + +Test Start: com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsync 0 + +/usr/bin/java -d64 -Djava.awt.headless=false -Djogl.debug.calayer.SwapM1 com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsync 0 +swapInterval 0 +exclusiveContext false +SWAP_M1 true +SWAP_M2 false +NewtCanvasAWT.attachNewtChild.2: size 500x268 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init ... +LandscapeES2 init on Thread[main-Display-.macosx_nil-1-EDT-1,5,main] +Chosen GLCapabilities: GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], offscr[fbo]] +INIT GL IS: jogamp.opengl.gl4.GL4bcImpl +GL_VENDOR: NVIDIA Corporation +GL_RENDERER: NVIDIA GeForce 320M OpenGL Engine +GL_VERSION: 2.1 NVIDIA-7.32.12 +GL GLSL: true, has-compiler-func: true, version 1.20, 1.20.0 +GL FBO: basic true, full true +GL Profile: GLProfile[GL2/GL2.hw] +GL Renderer Quirks:[NoOffscreenBitmap] +GL:jogamp.opengl.gl4.GL4bcImpl@6a6779e6, 2.1 (hardware) - 2.1 NVIDIA-7.32.12 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init FIN +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.reshape 0/0 500x268, swapInterval 0, drawable 0x7ff0e40a7db0 +Thread[AWT-EventQueue-0,6,main] LandscapeES2.reshape 0/0 500x268, swapInterval 0, drawable 0x7ff0e40a7db0 +XXX[1] TO 17 ms, lFrame0 119 ms, lFrameX 858 / 858 ~858.987 ms, flushGL 1 / 1 ~1.135 ms, waitGL 1 / 1 ~1.056 ms, finishGL 737 / 737 ~737.152 ms +XXX[2] TO 17 ms, lFrame0 104 ms, lFrameX 194 / 1053 ~526.583 ms, flushGL 0 / 1 ~0.57 ms, waitGL 0 / 1 ~0.531 ms, finishGL 89 / 826 ~413.413 ms +XXX[3] TO 17 ms, lFrame0 2 ms, lFrameX 83 / 1136 ~378.802 ms, flushGL 0 / 1 ~0.383 ms, waitGL 0 / 1 ~0.355 ms, finishGL 81 / 908 ~302.677 ms +XXX[4] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 1219 ~304.958 ms, flushGL 0 / 1 ~0.289 ms, waitGL 0 / 1 ~0.268 ms, finishGL 81 / 989 ~247.438 ms +XXX[5] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 1302 ~260.583 ms, flushGL 0 / 1 ~0.232 ms, waitGL 0 / 1 ~0.215 ms, finishGL 82 / 1071 ~214.354 ms +XXX[6] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1385 ~230.882 ms, flushGL 0 / 1 ~0.194 ms, waitGL 0 / 1 ~0.18 ms, finishGL 81 / 1153 ~192.227 ms +XXX[7] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 1467 ~209.645 ms, flushGL 0 / 1 ~0.169 ms, waitGL 0 / 1 ~0.155 ms, finishGL 80 / 1233 ~176.248 ms +XXX[8] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 1550 ~193.788 ms, flushGL 0 / 1 ~0.149 ms, waitGL 0 / 1 ~0.136 ms, finishGL 81 / 1314 ~164.348 ms +XXX[9] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1632 ~181.44 ms, flushGL 0 / 1 ~0.133 ms, waitGL 0 / 1 ~0.121 ms, finishGL 81 / 1396 ~155.19 ms +XXX[10] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1715 ~171.594 ms, flushGL 0 / 1 ~0.12 ms, waitGL 0 / 1 ~0.109 ms, finishGL 82 / 1478 ~147.892 ms +XXX[11] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 1814 ~164.944 ms, flushGL 0 / 1 ~0.109 ms, waitGL 0 / 1 ~0.099 ms, finishGL 97 / 1576 ~143.33 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1897 ~158.103 ms, flushGL 0 / 1 ~0.1 ms, waitGL 0 / 1 ~0.092 ms, finishGL 82 / 1658 ~138.232 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 1974 ~151.875 ms, flushGL 0 / 1 ~0.093 ms, waitGL 0 / 1 ~0.085 ms, finishGL 76 / 1735 ~133.461 ms +XXX[14] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 2078 ~148.498 ms, flushGL 0 / 1 ~0.086 ms, waitGL 0 / 1 ~0.079 ms, finishGL 104 / 1839 ~131.357 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2161 ~144.112 ms, flushGL 0 / 1 ~0.081 ms, waitGL 0 / 1 ~0.074 ms, finishGL 82 / 1921 ~128.079 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 2237 ~139.828 ms, flushGL 0 / 1 ~0.076 ms, waitGL 0 / 1 ~0.069 ms, finishGL 74 / 1995 ~124.741 ms +XXX[17] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 2327 ~136.929 ms, flushGL 0 / 1 ~0.071 ms, waitGL 0 / 1 ~0.065 ms, finishGL 90 / 2086 ~122.706 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 2427 ~134.845 ms, flushGL 0 / 1 ~0.068 ms, waitGL 0 / 1 ~0.062 ms, finishGL 98 / 2184 ~121.372 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2510 ~132.139 ms, flushGL 0 / 1 ~0.064 ms, waitGL 0 / 1 ~0.059 ms, finishGL 82 / 2267 ~119.34 ms +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 2586 ~129.322 ms, flushGL 0 / 1 ~0.061 ms, waitGL 0 / 1 ~0.056 ms, finishGL 75 / 2342 ~117.125 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 107 / 2693 ~128.273 ms, flushGL 0 / 1 ~0.058 ms, waitGL 0 / 1 ~0.053 ms, finishGL 106 / 2449 ~116.638 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2776 ~126.226 ms, flushGL 0 / 1 ~0.056 ms, waitGL 0 / 1 ~0.051 ms, finishGL 82 / 2532 ~115.096 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 2851 ~123.993 ms, flushGL 0 / 1 ~0.054 ms, waitGL 0 / 1 ~0.049 ms, finishGL 74 / 2606 ~113.316 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 105 / 2957 ~123.214 ms, flushGL 0 / 1 ~0.051 ms, waitGL 0 / 1 ~0.047 ms, finishGL 104 / 2711 ~112.961 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 3037 ~121.514 ms, flushGL 0 / 1 ~0.049 ms, waitGL 0 / 1 ~0.045 ms, finishGL 80 / 2791 ~111.652 ms +XXX[26] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 3108 ~119.541 ms, flushGL 0 / 1 ~0.048 ms, waitGL 0 / 1 ~0.044 ms, finishGL 69 / 2860 ~110.026 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 94 / 3202 ~118.618 ms, flushGL 0 / 1 ~0.046 ms, waitGL 0 / 1 ~0.042 ms, finishGL 93 / 2954 ~109.423 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3285 ~117.322 ms, flushGL 0 / 1 ~0.044 ms, waitGL 0 / 1 ~0.041 ms, finishGL 81 / 3036 ~108.439 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 3352 ~115.598 ms, flushGL 0 / 1 ~0.043 ms, waitGL 0 / 1 ~0.039 ms, finishGL 66 / 3102 ~106.999 ms +XXX[30] TO 17 ms, lFrame0 1 ms, lFrameX 97 / 3449 ~114.992 ms, flushGL 0 / 1 ~0.042 ms, waitGL 0 / 1 ~0.038 ms, finishGL 96 / 3199 ~106.644 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 3531 ~113.92 ms, flushGL 0 / 1 ~0.04 ms, waitGL 0 / 1 ~0.037 ms, finishGL 81 / 3280 ~105.828 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3596 ~112.392 ms, flushGL 0 / 1 ~0.039 ms, waitGL 0 / 1 ~0.036 ms, finishGL 64 / 3345 ~104.535 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 3680 ~111.53 ms, flushGL 0 / 1 ~0.038 ms, waitGL 0 / 1 ~0.035 ms, finishGL 83 / 3428 ~103.889 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3746 ~110.179 ms, flushGL 0 / 1 ~0.037 ms, waitGL 0 / 1 ~0.034 ms, finishGL 65 / 3493 ~102.75 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 3810 ~108.86 ms, flushGL 0 / 1 ~0.036 ms, waitGL 0 / 1 ~0.034 ms, finishGL 63 / 3556 ~101.622 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 3894 ~108.192 ms, flushGL 0 / 1 ~0.035 ms, waitGL 0 / 1 ~0.033 ms, finishGL 84 / 3641 ~101.141 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 3962 ~107.095 ms, flushGL 0 / 1 ~0.034 ms, waitGL 0 / 1 ~0.032 ms, finishGL 67 / 3708 ~100.222 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 4025 ~105.924 ms, flushGL 0 / 1 ~0.033 ms, waitGL 0 / 1 ~0.031 ms, finishGL 61 / 3770 ~99.213 ms +XXX[39] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 4111 ~105.414 ms, flushGL 0 / 1 ~0.033 ms, waitGL 0 / 1 ~0.03 ms, finishGL 85 / 3855 ~98.863 ms +XXX[40] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 4176 ~104.413 ms, flushGL 0 / 1 ~0.032 ms, waitGL 0 / 1 ~0.03 ms, finishGL 64 / 3920 ~98.012 ms +XXX[41] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 4237 ~103.353 ms, flushGL 0 / 1 ~0.031 ms, waitGL 0 / 1 ~0.029 ms, finishGL 60 / 3980 ~97.094 ms +XXX[42] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 4325 ~102.99 ms, flushGL 0 / 1 ~0.03 ms, waitGL 0 / 1 ~0.028 ms, finishGL 87 / 4068 ~96.868 ms +XXX[43] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4391 ~102.13 ms, flushGL 0 / 1 ~0.03 ms, waitGL 0 / 1 ~0.028 ms, finishGL 65 / 4134 ~96.14 ms +XXX[44] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 4451 ~101.179 ms, flushGL 0 / 1 ~0.029 ms, waitGL 0 / 1 ~0.027 ms, finishGL 59 / 4193 ~95.31 ms +XXX[45] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 4541 ~100.92 ms, flushGL 0 / 1 ~0.029 ms, waitGL 0 / 1 ~0.027 ms, finishGL 88 / 4282 ~95.166 ms +XXX[46] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 4607 ~100.161 ms, flushGL 0 / 1 ~0.028 ms, waitGL 0 / 1 ~0.026 ms, finishGL 65 / 4348 ~94.521 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 4667 ~99.304 ms, flushGL 0 / 1 ~0.027 ms, waitGL 0 / 1 ~0.026 ms, finishGL 59 / 4407 ~93.768 ms +XXX[48] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 4756 ~99.098 ms, flushGL 0 / 1 ~0.027 ms, waitGL 0 / 1 ~0.025 ms, finishGL 88 / 4496 ~93.666 ms +XXX[49] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4823 ~98.431 ms, flushGL 0 / 1 ~0.026 ms, waitGL 0 / 1 ~0.025 ms, finishGL 65 / 4561 ~93.099 ms +XXX[50] TO 17 ms, lFrame0 1 ms, lFrameX 59 / 4883 ~97.662 ms, flushGL 0 / 1 ~0.026 ms, waitGL 0 / 1 ~0.024 ms, finishGL 58 / 4620 ~92.415 ms +XXX[51] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 4972 ~97.49 ms, flushGL 0 / 1 ~0.025 ms, waitGL 0 / 1 ~0.024 ms, finishGL 88 / 4709 ~92.336 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5038 ~96.903 ms, flushGL 0 / 1 ~0.025 ms, waitGL 0 / 1 ~0.023 ms, finishGL 66 / 4775 ~91.84 ms +XXX[53] TO 17 ms, lFrame0 0 ms, lFrameX 58 / 5097 ~96.188 ms, flushGL 0 / 1 ~0.025 ms, waitGL 0 / 1 ~0.023 ms, finishGL 58 / 4834 ~91.211 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 5188 ~96.089 ms, flushGL 0 / 1 ~0.024 ms, waitGL 0 / 1 ~0.022 ms, finishGL 90 / 4924 ~91.197 ms +XXX[55] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 5254 ~95.534 ms, flushGL 0 / 1 ~0.024 ms, waitGL 0 / 1 ~0.022 ms, finishGL 65 / 4989 ~90.723 ms +XXX[56] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 5313 ~94.892 ms, flushGL 0 / 1 ~0.023 ms, waitGL 0 / 1 ~0.022 ms, finishGL 58 / 5048 ~90.152 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 5404 ~94.815 ms, flushGL 0 / 1 ~0.023 ms, waitGL 0 / 1 ~0.021 ms, finishGL 89 / 5138 ~90.148 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5471 ~94.336 ms, flushGL 0 / 1 ~0.023 ms, waitGL 0 / 1 ~0.021 ms, finishGL 66 / 5204 ~89.74 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 5531 ~93.755 ms, flushGL 0 / 1 ~0.022 ms, waitGL 0 / 1 ~0.021 ms, finishGL 59 / 5264 ~89.227 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 5620 ~93.682 ms, flushGL 0 / 1 ~0.022 ms, waitGL 0 / 1 ~0.02 ms, finishGL 88 / 5353 ~89.222 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5687 ~93.244 ms, flushGL 0 / 1 ~0.022 ms, waitGL 0 / 1 ~0.02 ms, finishGL 66 / 5419 ~88.848 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 5747 ~92.707 ms, flushGL 0 / 1 ~0.021 ms, waitGL 0 / 1 ~0.02 ms, finishGL 59 / 5479 ~88.371 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 5837 ~92.662 ms, flushGL 0 / 1 ~0.021 ms, waitGL 0 / 1 ~0.02 ms, finishGL 88 / 5568 ~88.381 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5905 ~92.267 ms, flushGL 0 / 1 ~0.021 ms, waitGL 0 / 1 ~0.019 ms, finishGL 66 / 5634 ~88.042 ms +XXX[65] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 5967 ~91.8 ms, flushGL 0 / 1 ~0.021 ms, waitGL 0 / 1 ~0.019 ms, finishGL 61 / 5695 ~87.629 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 6055 ~91.744 ms, flushGL 0 / 1 ~0.02 ms, waitGL 0 / 1 ~0.019 ms, finishGL 87 / 5783 ~87.626 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6122 ~91.376 ms, flushGL 0 / 1 ~0.02 ms, waitGL 0 / 1 ~0.019 ms, finishGL 66 / 5849 ~87.312 ms +XXX[68] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 6185 ~90.96 ms, flushGL 0 / 1 ~0.02 ms, waitGL 0 / 1 ~0.018 ms, finishGL 62 / 5912 ~86.945 ms +XXX[69] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 6272 ~90.899 ms, flushGL 0 / 1 ~0.019 ms, waitGL 0 / 1 ~0.018 ms, finishGL 86 / 5998 ~86.932 ms +XXX[70] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6338 ~90.547 ms, flushGL 0 / 1 ~0.019 ms, waitGL 0 / 1 ~0.018 ms, finishGL 65 / 6064 ~86.631 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 6400 ~90.149 ms, flushGL 0 / 1 ~0.019 ms, waitGL 0 / 1 ~0.018 ms, finishGL 61 / 6125 ~86.276 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 6486 ~90.094 ms, flushGL 0 / 1 ~0.019 ms, waitGL 0 / 1 ~0.017 ms, finishGL 85 / 6211 ~86.268 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6552 ~89.761 ms, flushGL 0 / 1 ~0.019 ms, waitGL 0 / 1 ~0.017 ms, finishGL 65 / 6276 ~85.98 ms +XXX[74] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 6613 ~89.376 ms, flushGL 0 / 1 ~0.018 ms, waitGL 0 / 1 ~0.017 ms, finishGL 60 / 6337 ~85.639 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 6702 ~89.368 ms, flushGL 0 / 1 ~0.018 ms, waitGL 0 / 1 ~0.017 ms, finishGL 88 / 6425 ~85.675 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6769 ~89.071 ms, flushGL 0 / 1 ~0.018 ms, waitGL 0 / 1 ~0.017 ms, finishGL 66 / 6491 ~85.42 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 6830 ~88.709 ms, flushGL 0 / 1 ~0.018 ms, waitGL 0 / 1 ~0.016 ms, finishGL 60 / 6552 ~85.097 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 6919 ~88.707 ms, flushGL 0 / 1 ~0.018 ms, waitGL 0 / 1 ~0.016 ms, finishGL 88 / 6640 ~85.135 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6986 ~88.437 ms, flushGL 0 / 1 ~0.017 ms, waitGL 0 / 1 ~0.016 ms, finishGL 66 / 6707 ~84.904 ms +XXX[80] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 7049 ~88.124 ms, flushGL 0 / 1 ~0.017 ms, waitGL 0 / 1 ~0.016 ms, finishGL 62 / 6769 ~84.624 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 7136 ~88.109 ms, flushGL 0 / 1 ~0.017 ms, waitGL 0 / 1 ~0.016 ms, finishGL 86 / 6856 ~84.647 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7203 ~87.846 ms, flushGL 0 / 1 ~0.017 ms, waitGL 0 / 1 ~0.016 ms, finishGL 65 / 6922 ~84.42 ms +XXX[83] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 7267 ~87.556 ms, flushGL 0 / 1 ~0.017 ms, waitGL 0 / 1 ~0.015 ms, finishGL 63 / 6985 ~84.164 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 7353 ~87.538 ms, flushGL 0 / 1 ~0.016 ms, waitGL 0 / 1 ~0.015 ms, finishGL 85 / 7071 ~84.181 ms +XXX[85] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 7419 ~87.287 ms, flushGL 0 / 1 ~0.016 ms, waitGL 0 / 1 ~0.015 ms, finishGL 65 / 7136 ~83.956 ms +XXX[86] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 7482 ~87.011 ms, flushGL 0 / 1 ~0.016 ms, waitGL 0 / 1 ~0.015 ms, finishGL 62 / 7199 ~83.711 ms +XXX[87] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 7569 ~87.002 ms, flushGL 0 / 1 ~0.016 ms, waitGL 0 / 1 ~0.015 ms, finishGL 85 / 7284 ~83.732 ms +XXX[88] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7635 ~86.767 ms, flushGL 0 / 1 ~0.016 ms, waitGL 0 / 1 ~0.015 ms, finishGL 65 / 7350 ~83.529 ms +XXX[89] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 7698 ~86.495 ms, flushGL 0 / 1 ~0.016 ms, waitGL 0 / 1 ~0.015 ms, finishGL 61 / 7412 ~83.287 ms +XXX[90] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 7784 ~86.498 ms, flushGL 0 / 1 ~0.016 ms, waitGL 0 / 1 ~0.014 ms, finishGL 86 / 7498 ~83.321 ms +XXX[91] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7851 ~86.278 ms, flushGL 0 / 1 ~0.015 ms, waitGL 0 / 1 ~0.014 ms, finishGL 65 / 7564 ~83.131 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 7914 ~86.024 ms, flushGL 0 / 1 ~0.015 ms, waitGL 0 / 1 ~0.014 ms, finishGL 62 / 7627 ~82.903 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 8000 ~86.024 ms, flushGL 0 / 1 ~0.015 ms, waitGL 0 / 1 ~0.014 ms, finishGL 85 / 7712 ~82.931 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8066 ~85.812 ms, flushGL 0 / 1 ~0.015 ms, waitGL 0 / 1 ~0.014 ms, finishGL 65 / 7778 ~82.748 ms +XXX[95] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 8127 ~85.556 ms, flushGL 0 / 1 ~0.015 ms, waitGL 0 / 1 ~0.014 ms, finishGL 60 / 7839 ~82.516 ms +XXX[96] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 8215 ~85.577 ms, flushGL 0 / 1 ~0.015 ms, waitGL 0 / 1 ~0.014 ms, finishGL 87 / 7926 ~82.563 ms +XXX[97] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8281 ~85.376 ms, flushGL 0 / 1 ~0.015 ms, waitGL 0 / 1 ~0.014 ms, finishGL 65 / 7991 ~82.388 ms +XXX[98] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 8342 ~85.123 ms, flushGL 0 / 1 ~0.014 ms, waitGL 0 / 1 ~0.013 ms, finishGL 59 / 8051 ~82.158 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 8431 ~85.161 ms, flushGL 0 / 1 ~0.014 ms, waitGL 0 / 1 ~0.013 ms, finishGL 88 / 8139 ~82.22 ms +XXX[1] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 66 ~66.288 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 65 / 65 ~65.79 ms +XXX[2] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 126 ~63.1 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 59 / 125 ~62.55 ms +XXX[3] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 216 ~72.024 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 89 / 214 ~71.495 ms +XXX[4] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 282 ~70.719 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 66 / 280 ~70.203 ms +XXX[5] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 344 ~68.97 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 61 / 342 ~68.43 ms +XXX[6] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 434 ~72.357 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 88 / 430 ~71.813 ms +XXX[7] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 499 ~71.382 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 65 / 495 ~70.842 ms +XXX[8] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 560 ~70.03 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 59 / 555 ~69.454 ms +XXX[9] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 648 ~72.085 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 88 / 643 ~71.521 ms +XXX[10] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 714 ~71.489 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 65 / 709 ~70.934 ms +XXX[11] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 774 ~70.434 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 59 / 768 ~69.865 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 864 ~72.036 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 88 / 857 ~71.454 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 931 ~71.665 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 66 / 924 ~71.094 ms +XXX[14] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 992 ~70.887 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 60 / 984 ~70.309 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 1081 ~72.122 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 88 / 1073 ~71.554 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1149 ~71.826 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 66 / 1140 ~71.265 ms +XXX[17] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 1211 ~71.277 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 62 / 1202 ~70.724 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 1300 ~72.24 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 88 / 1290 ~71.689 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1366 ~71.934 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 65 / 1356 ~71.388 ms +FrameCount: 120 - FrameRate: 15.0 +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 1430 ~71.539 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 63 / 1419 ~70.979 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 1516 ~72.228 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 85 / 1505 ~71.674 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 1582 ~71.935 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 65 / 1570 ~71.383 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 1647 ~71.614 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 63 / 1634 ~71.055 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 1732 ~72.202 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 85 / 1719 ~71.646 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 1798 ~71.927 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 64 / 1784 ~71.376 ms +XXX[26] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 1862 ~71.624 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 63 / 1847 ~71.063 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 1948 ~72.167 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 85 / 1933 ~71.601 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2015 ~71.976 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 66 / 1999 ~71.412 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 2079 ~71.695 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 63 / 2062 ~71.129 ms +XXX[30] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 2148 ~71.624 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 69 / 2131 ~71.061 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2213 ~71.415 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 64 / 2196 ~70.855 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 2281 ~71.295 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 67 / 2263 ~70.736 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2346 ~71.114 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 64 / 2328 ~70.558 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 2414 ~71.014 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 67 / 2395 ~70.461 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 2479 ~70.84 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 64 / 2460 ~70.289 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 2547 ~70.758 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 67 / 2527 ~70.209 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 2612 ~70.595 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 64 / 2591 ~70.048 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2678 ~70.489 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 66 / 2657 ~69.944 ms +XXX[39] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2743 ~70.352 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 64 / 2722 ~69.808 ms +XXX[40] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 2807 ~70.197 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 63 / 2786 ~69.656 ms +XXX[41] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 2871 ~70.035 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 63 / 2849 ~69.496 ms +XXX[42] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 2934 ~69.863 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 62 / 2911 ~69.326 ms +XXX[43] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 2995 ~69.661 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 60 / 2972 ~69.126 ms +XXX[44] TO 17 ms, lFrame0 0 ms, lFrameX 46 / 3042 ~69.141 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 46 / 3018 ~68.607 ms +XXX[45] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3091 ~68.708 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 49 / 3067 ~68.175 ms +XXX[46] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3140 ~68.274 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 48 / 3116 ~67.743 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3189 ~67.865 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 48 / 3164 ~67.334 ms +XXX[48] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3238 ~67.473 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 48 / 3213 ~66.944 ms +XXX[49] TO 17 ms, lFrame0 1 ms, lFrameX 41 / 3279 ~66.937 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 40 / 3253 ~66.396 ms +XXX[50] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 3354 ~67.082 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 73 / 3327 ~66.541 ms +XXX[51] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3403 ~66.729 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 48 / 3375 ~66.189 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 39 / 3442 ~66.203 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 38 / 3414 ~65.658 ms +XXX[53] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 3501 ~66.074 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 58 / 3473 ~65.529 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3550 ~65.758 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 48 / 3521 ~65.213 ms +XXX[55] TO 17 ms, lFrame0 1 ms, lFrameX 37 / 3588 ~65.249 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 36 / 3558 ~64.693 ms +XXX[56] TO 17 ms, lFrame0 0 ms, lFrameX 43 / 3632 ~64.869 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 43 / 3601 ~64.315 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 3697 ~64.87 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 64 / 3666 ~64.319 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3745 ~64.586 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 47 / 3714 ~64.036 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 3779 ~64.054 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 32 / 3746 ~63.502 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 3843 ~64.065 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 64 / 3810 ~63.515 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3892 ~63.804 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 47 / 3858 ~63.254 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 29 / 3921 ~63.257 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 29 / 3887 ~62.703 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 3973 ~63.067 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 50 / 3938 ~62.512 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4005 ~62.586 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 31 / 3970 ~62.032 ms +XXX[65] TO 17 ms, lFrame0 0 ms, lFrameX 27 / 4033 ~62.049 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 27 / 3997 ~61.494 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 54 / 4087 ~61.93 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 53 / 4050 ~61.376 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 31 / 4119 ~61.482 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 31 / 4082 ~60.93 ms +XXX[68] TO 17 ms, lFrame0 1 ms, lFrameX 25 / 4144 ~60.955 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 24 / 4106 ~60.396 ms +XXX[69] TO 17 ms, lFrame0 1 ms, lFrameX 39 / 4184 ~60.646 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 38 / 4145 ~60.074 ms +XXX[70] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4233 ~60.475 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 48 / 4193 ~59.904 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4265 ~60.081 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 32 / 4225 ~59.512 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 23 / 4289 ~59.578 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 23 / 4248 ~59.008 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 26 / 4316 ~59.127 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 25 / 4274 ~58.555 ms +XXX[74] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 4365 ~58.995 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 48 / 4323 ~58.422 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4398 ~58.646 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 32 / 4355 ~58.072 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 23 / 4422 ~58.189 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0020 ms, finishGL 23 / 4378 ~57.612 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 26 / 4448 ~57.777 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 25 / 4404 ~57.201 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 53 / 4501 ~57.717 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 52 / 4457 ~57.142 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 38 / 4540 ~57.476 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 38 / 4495 ~56.903 ms +XXX[80] TO 17 ms, lFrame0 0 ms, lFrameX 37 / 4578 ~57.226 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 36 / 4532 ~56.651 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 4647 ~57.373 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 68 / 4600 ~56.8 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 4698 ~57.303 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 51 / 4651 ~56.73 ms +XXX[83] TO 17 ms, lFrame0 0 ms, lFrameX 43 / 4742 ~57.134 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 42 / 4694 ~56.559 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 4816 ~57.335 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 73 / 4767 ~56.761 ms +XXX[85] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 4865 ~57.246 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 49 / 4817 ~56.674 ms +XXX[86] TO 17 ms, lFrame0 0 ms, lFrameX 43 / 4909 ~57.083 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 42 / 4859 ~56.51 ms +XXX[87] TO 17 ms, lFrame0 0 ms, lFrameX 73 / 4982 ~57.269 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 72 / 4932 ~56.696 ms +XXX[88] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5032 ~57.19 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 49 / 4982 ~56.618 ms +XXX[89] TO 17 ms, lFrame0 0 ms, lFrameX 43 / 5076 ~57.041 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 43 / 5025 ~56.469 ms +XXX[90] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 5149 ~57.214 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 71 / 5097 ~56.64 ms +XXX[91] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5199 ~57.141 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 50 / 5147 ~56.569 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 44 / 5244 ~57.002 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 43 / 5191 ~56.429 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 73 / 5317 ~57.174 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 72 / 5264 ~56.602 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 5368 ~57.111 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 50 / 5314 ~56.54 ms +XXX[95] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 5416 ~57.02 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 47 / 5362 ~56.449 ms +XXX[96] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 5487 ~57.157 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 69 / 5432 ~56.586 ms +XXX[97] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5554 ~57.266 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 67 / 5499 ~56.696 ms +XXX[98] TO 17 ms, lFrame0 0 ms, lFrameX 52 / 5607 ~57.216 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 51 / 5551 ~56.645 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 5690 ~57.484 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 5634 ~56.913 ms +XXX[100] TO 17 ms, lFrame0 0 ms, lFrameX 71 / 5762 ~57.624 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 70 / 5705 ~57.053 ms +XXX[101] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 5823 ~57.661 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 60 / 5765 ~57.088 ms +XXX[102] TO 17 ms, lFrame0 0 ms, lFrameX 91 / 5914 ~57.989 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 90 / 5856 ~57.415 ms +XXX[103] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5982 ~58.082 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 67 / 5923 ~57.509 ms +XXX[104] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 6045 ~58.13 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 62 / 5985 ~57.555 ms +XXX[105] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 6131 ~58.396 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 6071 ~57.82 ms +XXX[106] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6199 ~58.482 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 67 / 6138 ~57.907 ms +XXX[107] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6264 ~58.543 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 64 / 6202 ~57.966 ms +XXX[108] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 6351 ~58.805 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 86 / 6288 ~58.228 ms +XXX[109] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 6434 ~59.034 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 6372 ~58.459 ms +XXX[110] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6501 ~59.1 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 6437 ~58.523 ms +XXX[111] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 6600 ~59.465 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 99 / 6536 ~58.888 ms +XXX[112] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 6684 ~59.681 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 6619 ~59.105 ms +XXX[113] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6751 ~59.748 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 6686 ~59.172 ms +XXX[114] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 6851 ~60.104 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 99 / 6786 ~59.528 ms +XXX[115] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 6937 ~60.326 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 6871 ~59.75 ms +XXX[116] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 7010 ~60.433 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 71 / 6943 ~59.854 ms +XXX[117] TO 17 ms, lFrame0 0 ms, lFrameX 96 / 7107 ~60.744 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 96 / 7039 ~60.167 ms +XXX[118] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 7192 ~60.949 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 84 / 7123 ~60.372 ms +XXX[119] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 7269 ~61.085 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 76 / 7200 ~60.506 ms +XXX[120] TO 17 ms, lFrame0 0 ms, lFrameX 106 / 7376 ~61.467 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 106 / 7306 ~60.888 ms +XXX[121] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 7455 ~61.614 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 78 / 7385 ~61.036 ms +2013-06-17 03:02:44.695 java[63324:5f03] Persistent UI failed to open file file://localhost/Users/jogamp/Library/Saved%20Application%20State/com.apple.javajdk16.cmd.savedState/window_1.data: Operation not permitted (1) +XXX[122] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 7525 ~61.68 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 69 / 7454 ~61.102 ms +XXX[123] TO 17 ms, lFrame0 0 ms, lFrameX 93 / 7618 ~61.941 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 93 / 7547 ~61.363 ms +XXX[124] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 7699 ~62.095 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 80 / 7628 ~61.517 ms +XXX[125] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 7765 ~62.124 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 64 / 7693 ~61.544 ms +XXX[126] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 7864 ~62.413 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 98 / 7791 ~61.834 ms +XXX[127] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 7946 ~62.573 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 7873 ~61.995 ms +XXX[128] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 8010 ~62.584 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 63 / 7936 ~62.005 ms +XXX[129] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 8096 ~62.76 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 84 / 8021 ~62.181 ms +XXX[130] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8178 ~62.913 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 8103 ~62.333 ms +XXX[131] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 8243 ~62.924 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 63 / 8167 ~62.343 ms +XXX[132] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 8328 ~63.093 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 84 / 8251 ~62.511 ms +XXX[133] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8394 ~63.115 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 8317 ~62.534 ms +XXX[134] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 8457 ~63.117 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 62 / 8379 ~62.534 ms +XXX[135] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 8543 ~63.287 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 8465 ~62.703 ms +XXX[136] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 8609 ~63.306 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 8530 ~62.723 ms +XXX[137] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 8671 ~63.293 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 60 / 8591 ~62.709 ms +XXX[138] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 8758 ~63.466 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 86 / 8677 ~62.882 ms +XXX[139] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8825 ~63.489 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 8743 ~62.906 ms +FrameCount: 240 - FrameRate: 13.0 +XXX[140] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 8886 ~63.474 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 60 / 8804 ~62.889 ms +XXX[141] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 8974 ~63.649 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 87 / 8892 ~63.065 ms +XXX[142] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9040 ~63.667 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 8957 ~63.082 ms +XXX[143] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 9102 ~63.652 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 60 / 9018 ~63.066 ms +XXX[144] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 9190 ~63.824 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 87 / 9106 ~63.238 ms +XXX[145] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9257 ~63.841 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 9172 ~63.257 ms +XXX[146] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 9318 ~63.823 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 60 / 9232 ~63.238 ms +XXX[147] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 9407 ~63.995 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 88 / 9321 ~63.411 ms +XXX[148] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9473 ~64.008 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 9386 ~63.424 ms +XXX[149] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 9534 ~63.992 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 61 / 9447 ~63.408 ms +XXX[150] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 9622 ~64.151 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 87 / 9535 ~63.568 ms +XXX[151] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9688 ~64.161 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 9600 ~63.578 ms +XXX[152] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 9748 ~64.132 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 59 / 9659 ~63.548 ms +XXX[153] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 9837 ~64.297 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 88 / 9747 ~63.712 ms +XXX[154] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9903 ~64.306 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 9813 ~63.721 ms +XXX[155] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 9962 ~64.272 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 58 / 9871 ~63.687 ms +XXX[156] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 10052 ~64.439 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 89 / 9961 ~63.854 ms +XXX[157] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10118 ~64.451 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 10027 ~63.867 ms +XXX[158] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 10177 ~64.417 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 58 / 10085 ~63.832 ms +XXX[159] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 10268 ~64.583 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 90 / 10175 ~63.999 ms +XXX[160] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10335 ~64.597 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 10242 ~64.014 ms +XXX[161] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 10394 ~64.565 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 58 / 10300 ~63.981 ms +XXX[162] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 10485 ~64.727 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 90 / 10391 ~64.144 ms +XXX[163] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10552 ~64.741 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 10457 ~64.158 ms +XXX[164] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 10613 ~64.714 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 59 / 10517 ~64.131 ms +XXX[165] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 10702 ~64.862 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 88 / 10605 ~64.277 ms +XXX[166] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10768 ~64.873 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 10671 ~64.288 ms +XXX[167] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 10830 ~64.852 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 60 / 10732 ~64.266 ms +XXX[168] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 10920 ~65.003 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 89 / 10822 ~64.418 ms +XXX[169] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 10988 ~65.021 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 67 / 10889 ~64.436 ms +XXX[170] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 11052 ~65.014 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 63 / 10952 ~64.428 ms +XXX[171] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 11138 ~65.136 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 11038 ~64.55 ms +XXX[172] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11205 ~65.148 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 11104 ~64.562 ms +XXX[173] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11273 ~65.165 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 67 / 11172 ~64.578 ms +XXX[174] TO 17 ms, lFrame0 0 ms, lFrameX 101 / 11375 ~65.376 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 101 / 11273 ~64.789 ms +XXX[175] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 11460 ~65.49 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 11358 ~64.904 ms +XXX[176] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 11535 ~65.542 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 73 / 11432 ~64.955 ms +XXX[177] TO 17 ms, lFrame0 0 ms, lFrameX 97 / 11632 ~65.722 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 96 / 11528 ~65.134 ms +XXX[178] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 11717 ~65.827 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 11612 ~65.239 ms +XXX[179] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 11796 ~65.904 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 78 / 11691 ~65.315 ms +XXX[180] TO 17 ms, lFrame0 0 ms, lFrameX 105 / 11901 ~66.121 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 104 / 11795 ~65.532 ms +XXX[181] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 11985 ~66.216 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 11878 ~65.627 ms +XXX[182] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 12066 ~66.298 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 80 / 11958 ~65.708 ms +XXX[183] TO 17 ms, lFrame0 0 ms, lFrameX 103 / 12170 ~66.502 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 103 / 12062 ~65.912 ms +XXX[184] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12253 ~66.594 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 12144 ~66.004 ms +XXX[185] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 12332 ~66.662 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 78 / 12223 ~66.071 ms +XXX[186] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 12433 ~66.846 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 100 / 12323 ~66.254 ms +XXX[187] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 12515 ~66.929 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 12405 ~66.338 ms +XXX[188] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 12592 ~66.983 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 76 / 12481 ~66.391 ms +XXX[189] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 12696 ~67.179 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 103 / 12585 ~66.588 ms +XXX[190] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12780 ~67.264 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 12667 ~66.673 ms +XXX[191] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 12857 ~67.316 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 76 / 12744 ~66.724 ms +XXX[192] TO 17 ms, lFrame0 1 ms, lFrameX 105 / 12963 ~67.517 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 104 / 12849 ~66.922 ms +XXX[193] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13047 ~67.602 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 12932 ~67.008 ms +XXX[194] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 13122 ~67.64 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 74 / 13006 ~67.045 ms +XXX[195] TO 17 ms, lFrame0 0 ms, lFrameX 106 / 13228 ~67.837 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 105 / 13112 ~67.242 ms +XXX[196] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13309 ~67.908 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 13193 ~67.313 ms +XXX[197] TO 17 ms, lFrame0 0 ms, lFrameX 71 / 13381 ~67.928 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 71 / 13264 ~67.332 ms +XXX[198] TO 17 ms, lFrame0 0 ms, lFrameX 91 / 13473 ~68.046 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 90 / 13355 ~67.451 ms +XXX[199] TO 17 ms, lFrame0 1 ms, lFrameX 81 / 13554 ~68.114 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 79 / 13435 ~67.514 ms +XXX[200] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 13621 ~68.109 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 13501 ~67.508 ms +XXX[201] TO 17 ms, lFrame0 0 ms, lFrameX 96 / 13718 ~68.251 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 95 / 13597 ~67.649 ms +XXX[202] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13800 ~68.317 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 13678 ~67.716 ms +XXX[203] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 13864 ~68.296 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 63 / 13742 ~67.695 ms +XXX[204] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 13949 ~68.381 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 13827 ~67.781 ms +XXX[205] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 14015 ~68.369 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 13892 ~67.769 ms +XXX[206] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 14081 ~68.358 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 13958 ~67.757 ms +XXX[207] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 14170 ~68.455 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 88 / 14046 ~67.855 ms +XXX[208] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 14255 ~68.537 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 14131 ~67.938 ms +XXX[209] TO 17 ms, lFrame0 0 ms, lFrameX 73 / 14329 ~68.56 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 72 / 14203 ~67.961 ms +XXX[210] TO 17 ms, lFrame0 0 ms, lFrameX 97 / 14426 ~68.699 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 96 / 14300 ~68.099 ms +XXX[211] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 14511 ~68.774 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 14384 ~68.174 ms +XXX[212] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 14588 ~68.814 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 76 / 14461 ~68.214 ms +XXX[213] TO 17 ms, lFrame0 0 ms, lFrameX 105 / 14694 ~68.986 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 105 / 14566 ~68.387 ms +XXX[214] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 14777 ~69.051 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 14648 ~68.452 ms +XXX[215] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 14852 ~69.081 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 74 / 14723 ~68.482 ms +XXX[216] TO 17 ms, lFrame0 1 ms, lFrameX 106 / 14959 ~69.256 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 105 / 14829 ~68.653 ms +XXX[217] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15041 ~69.314 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 14910 ~68.712 ms +XXX[218] TO 17 ms, lFrame0 0 ms, lFrameX 73 / 15114 ~69.333 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 72 / 14983 ~68.73 ms +XXX[219] TO 17 ms, lFrame0 0 ms, lFrameX 91 / 15206 ~69.435 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 91 / 15074 ~68.833 ms +XXX[220] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15287 ~69.489 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 80 / 15155 ~68.888 ms +XXX[221] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 15356 ~69.486 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 68 / 15223 ~68.885 ms +XXX[222] TO 17 ms, lFrame0 0 ms, lFrameX 94 / 15451 ~69.599 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 94 / 15317 ~68.998 ms +XXX[223] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15532 ~69.652 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 80 / 15398 ~69.051 ms +XXX[224] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 15597 ~69.63 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 63 / 15462 ~69.028 ms +XXX[225] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 15677 ~69.678 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 79 / 15542 ~69.077 ms +XXX[226] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 15744 ~69.664 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 15608 ~69.062 ms +XXX[227] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 15807 ~69.637 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 62 / 15671 ~69.035 ms +XXX[228] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 15893 ~69.709 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 15756 ~69.107 ms +XXX[229] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 15960 ~69.696 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 15822 ~69.095 ms +XXX[230] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 16023 ~69.667 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 62 / 15884 ~69.064 ms +XXX[231] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 16109 ~69.738 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 15970 ~69.134 ms +XXX[232] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 16175 ~69.721 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 16035 ~69.119 ms +XXX[233] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 16237 ~69.687 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 61 / 16096 ~69.085 ms +XXX[234] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 16324 ~69.764 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 87 / 16184 ~69.162 ms +XXX[235] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16392 ~69.754 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 16250 ~69.152 ms +XXX[236] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 16456 ~69.729 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 63 / 16314 ~69.127 ms +XXX[237] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 16543 ~69.804 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 87 / 16401 ~69.203 ms +XXX[238] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16611 ~69.796 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 67 / 16468 ~69.196 ms +XXX[239] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16679 ~69.788 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 67 / 16535 ~69.187 ms +XXX[240] TO 17 ms, lFrame0 0 ms, lFrameX 103 / 16782 ~69.926 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 102 / 16638 ~69.326 ms +XXX[241] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 16868 ~69.993 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 85 / 16723 ~69.393 ms +XXX[242] TO 17 ms, lFrame0 0 ms, lFrameX 73 / 16942 ~70.009 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 73 / 16796 ~69.408 ms +XXX[243] TO 17 ms, lFrame0 0 ms, lFrameX 95 / 17037 ~70.113 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 94 / 16891 ~69.512 ms +XXX[244] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17122 ~70.173 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 84 / 16975 ~69.573 ms +XXX[245] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 17200 ~70.204 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 77 / 17053 ~69.604 ms +XXX[246] TO 17 ms, lFrame0 0 ms, lFrameX 107 / 17307 ~70.356 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 107 / 17160 ~69.756 ms +XXX[247] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17391 ~70.411 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 17243 ~69.811 ms +XXX[248] TO 17 ms, lFrame0 0 ms, lFrameX 78 / 17470 ~70.445 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 78 / 17321 ~69.845 ms +XXX[249] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 17574 ~70.58 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 103 / 17424 ~69.979 ms +XXX[250] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 17657 ~70.629 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 17507 ~70.029 ms +XXX[251] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 17735 ~70.658 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 77 / 17584 ~70.058 ms +XXX[252] TO 17 ms, lFrame0 0 ms, lFrameX 103 / 17839 ~70.789 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 103 / 17687 ~70.189 ms +XXX[253] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 17921 ~70.836 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 17769 ~70.236 ms +XXX[254] TO 17 ms, lFrame0 0 ms, lFrameX 76 / 17997 ~70.856 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 75 / 17845 ~70.256 ms +XXX[255] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 18102 ~70.988 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 103 / 17949 ~70.388 ms +XXX[256] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18184 ~71.032 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 18030 ~70.432 ms +XXX[257] TO 17 ms, lFrame0 0 ms, lFrameX 73 / 18257 ~71.04 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 72 / 18103 ~70.44 ms +XXX[258] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 18347 ~71.114 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 89 / 18192 ~70.514 ms +XXX[259] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18429 ~71.157 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 18274 ~70.557 ms +FrameCount: 360 - FrameRate: 12.0 +XXX[260] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 18499 ~71.152 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 69 / 18343 ~70.551 ms +XXX[261] TO 17 ms, lFrame0 0 ms, lFrameX 94 / 18594 ~71.241 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 94 / 18437 ~70.641 ms +XXX[262] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18676 ~71.285 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 18519 ~70.684 ms +XXX[263] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 18744 ~71.27 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 66 / 18586 ~70.67 ms +XXX[264] TO 17 ms, lFrame0 0 ms, lFrameX 97 / 18841 ~71.37 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 97 / 18683 ~70.77 ms +XXX[265] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 18923 ~71.409 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 18764 ~70.809 ms +XXX[266] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 18988 ~71.386 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 64 / 18829 ~70.786 ms +XXX[267] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 19071 ~71.43 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 18911 ~70.83 ms +XXX[268] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 19137 ~71.409 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 18977 ~70.809 ms +XXX[269] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 19201 ~71.38 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 62 / 19039 ~70.78 ms +XXX[270] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 19286 ~71.431 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 84 / 19124 ~70.831 ms +XXX[271] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 19351 ~71.407 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 64 / 19188 ~70.807 ms +XXX[272] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 19411 ~71.366 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 59 / 19248 ~70.765 ms +XXX[273] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 19499 ~71.426 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 87 / 19335 ~70.827 ms +XXX[274] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19564 ~71.404 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 64 / 19400 ~70.805 ms +XXX[275] TO 17 ms, lFrame0 0 ms, lFrameX 57 / 19622 ~71.353 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 56 / 19457 ~70.753 ms +XXX[276] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 19694 ~71.358 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 72 / 19529 ~70.759 ms +XXX[277] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19760 ~71.335 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 64 / 19594 ~70.737 ms +XXX[278] TO 17 ms, lFrame0 0 ms, lFrameX 53 / 19813 ~71.271 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 52 / 19647 ~70.672 ms +XXX[279] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 19891 ~71.294 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 77 / 19724 ~70.695 ms +XXX[280] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 19957 ~71.276 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 19789 ~70.677 ms +XXX[281] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 20008 ~71.205 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 50 / 19840 ~70.605 ms +XXX[282] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 20089 ~71.237 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 79 / 19920 ~70.638 ms +XXX[283] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20154 ~71.218 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 19985 ~70.62 ms +XXX[284] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 20204 ~71.141 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 48 / 20034 ~70.542 ms +XXX[285] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 20287 ~71.184 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 20117 ~70.585 ms +XXX[286] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20354 ~71.167 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 65 / 20182 ~70.569 ms +XXX[287] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 20404 ~71.095 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 49 / 20232 ~70.496 ms +XXX[288] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 20488 ~71.139 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 20315 ~70.541 ms +XXX[289] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 20556 ~71.129 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 67 / 20383 ~70.532 ms +XXX[290] TO 17 ms, lFrame0 0 ms, lFrameX 55 / 20611 ~71.074 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 54 / 20438 ~70.476 ms +XXX[291] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 20693 ~71.111 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 20519 ~70.513 ms +XXX[292] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 20762 ~71.105 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 68 / 20588 ~70.507 ms +XXX[293] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 20826 ~71.08 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 63 / 20651 ~70.483 ms +XXX[294] TO 17 ms, lFrame0 0 ms, lFrameX 94 / 20921 ~71.16 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 93 / 20745 ~70.562 ms +XXX[295] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 21010 ~71.221 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 88 / 20834 ~70.624 ms +XXX[296] TO 17 ms, lFrame0 0 ms, lFrameX 76 / 21086 ~71.239 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 75 / 20909 ~70.64 ms +XXX[297] TO 17 ms, lFrame0 0 ms, lFrameX 110 / 21197 ~71.372 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 110 / 21019 ~70.773 ms +XXX[298] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 21281 ~71.415 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 21103 ~70.816 ms +XXX[299] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 21360 ~71.441 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 78 / 21181 ~70.842 ms +XXX[300] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 21465 ~71.55 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 103 / 21285 ~70.951 ms +XXX[301] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 21549 ~71.592 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 21369 ~70.993 ms +XXX[302] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 21630 ~71.622 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 80 / 21449 ~71.023 ms +XXX[303] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 21734 ~71.731 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 104 / 21553 ~71.132 ms +XXX[304] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 21835 ~71.825 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 99 / 21653 ~71.227 ms +XXX[305] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 21915 ~71.855 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 80 / 21733 ~71.256 ms +XXX[306] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 22016 ~71.948 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 99 / 21832 ~71.349 ms +XXX[307] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22098 ~71.982 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 21914 ~71.383 ms +XXX[308] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 22178 ~72.006 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 79 / 21993 ~71.408 ms +XXX[309] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 22264 ~72.053 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 86 / 22079 ~71.455 ms +XXX[310] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22347 ~72.088 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 22162 ~71.49 ms +XXX[311] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22430 ~72.124 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 22245 ~71.527 ms +XXX[312] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22513 ~72.159 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 22327 ~71.562 ms +XXX[313] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 22597 ~72.195 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 22410 ~71.597 ms +XXX[314] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22680 ~72.23 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 22492 ~71.633 ms +XXX[315] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22763 ~72.265 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 22575 ~71.668 ms +XXX[316] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 22863 ~72.351 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 98 / 22674 ~71.754 ms +XXX[317] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 22947 ~72.39 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 84 / 22758 ~71.793 ms +XXX[318] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23031 ~72.425 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 22841 ~71.829 ms +XXX[319] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 23112 ~72.453 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 80 / 22922 ~71.857 ms +XXX[320] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 23196 ~72.49 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 83 / 23006 ~71.894 ms +XXX[321] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23279 ~72.522 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 23088 ~71.926 ms +XXX[322] TO 17 ms, lFrame0 5 ms, lFrameX 84 / 23363 ~72.557 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 78 / 23167 ~71.947 ms +XXX[323] TO 17 ms, lFrame0 0 ms, lFrameX 96 / 23460 ~72.632 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 96 / 23263 ~72.022 ms +XXX[324] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23542 ~72.662 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 81 / 23345 ~72.052 ms +XXX[325] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23625 ~72.694 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 23427 ~72.085 ms +XXX[326] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23708 ~72.726 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 0 ~0.0030 ms, finishGL 82 / 23510 ~72.117 ms +XXX[327] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23791 ~72.758 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 23592 ~72.149 ms +XXX[328] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23874 ~72.789 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 23675 ~72.18 ms +XXX[329] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23957 ~72.819 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 23757 ~72.21 ms +XXX[330] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24040 ~72.85 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 23840 ~72.243 ms +XXX[331] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24123 ~72.88 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 23922 ~72.273 ms +XXX[332] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24206 ~72.911 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 24005 ~72.304 ms +XXX[333] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24289 ~72.942 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 24087 ~72.335 ms +XXX[334] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24372 ~72.972 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 24170 ~72.365 ms +XXX[335] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24456 ~73.004 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 24253 ~72.398 ms +XXX[336] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24539 ~73.034 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 24335 ~72.428 ms +XXX[337] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24622 ~73.063 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 24418 ~72.457 ms +XXX[338] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24705 ~73.094 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 24501 ~72.488 ms +XXX[339] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24788 ~73.123 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 24583 ~72.518 ms +XXX[340] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24872 ~73.153 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 24666 ~72.548 ms +XXX[341] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24955 ~73.184 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 24749 ~72.579 ms +XXX[342] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25038 ~73.211 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 24831 ~72.606 ms +XXX[343] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 25121 ~73.24 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 24913 ~72.634 ms +XXX[344] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25204 ~73.268 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 24996 ~72.663 ms +XXX[345] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25288 ~73.299 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 25079 ~72.694 ms +XXX[346] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25371 ~73.328 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 25162 ~72.723 ms +XXX[347] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25454 ~73.355 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 25244 ~72.75 ms +XXX[348] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25537 ~73.384 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 25327 ~72.78 ms +XXX[349] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25621 ~73.414 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 25410 ~72.81 ms +XXX[350] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25704 ~73.442 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 25493 ~72.838 ms +XXX[351] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25788 ~73.472 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 25577 ~72.869 ms +XXX[352] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25871 ~73.499 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 25659 ~72.895 ms +XXX[353] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25955 ~73.527 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 25742 ~72.924 ms +XXX[354] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26037 ~73.553 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 25824 ~72.95 ms +XXX[355] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26121 ~73.582 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 25908 ~72.98 ms +XXX[356] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26204 ~73.608 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 25990 ~73.006 ms +XXX[357] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26287 ~73.634 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26072 ~73.033 ms +XXX[358] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 26369 ~73.657 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 26154 ~73.056 ms +XXX[359] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26452 ~73.683 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26236 ~73.083 ms +XXX[360] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26534 ~73.708 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26318 ~73.107 ms +XXX[361] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26618 ~73.734 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26401 ~73.134 ms +XXX[362] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26700 ~73.758 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 26483 ~73.159 ms +XXX[363] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26783 ~73.785 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26566 ~73.185 ms +XXX[364] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26866 ~73.809 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26648 ~73.21 ms +XXX[365] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26949 ~73.833 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26730 ~73.235 ms +XXX[366] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27031 ~73.857 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26812 ~73.259 ms +XXX[367] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27114 ~73.882 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26895 ~73.284 ms +XXX[368] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27197 ~73.906 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 26977 ~73.308 ms +XXX[369] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27279 ~73.928 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 27059 ~73.331 ms +XXX[370] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27362 ~73.954 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 27142 ~73.357 ms +XXX[371] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 27447 ~73.983 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 84 / 27226 ~73.387 ms +XXX[372] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 27532 ~74.01 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 27310 ~73.414 ms +XXX[373] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27615 ~74.035 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 27393 ~73.439 ms +XXX[374] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27698 ~74.06 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 27475 ~73.464 ms +XXX[375] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 27782 ~74.087 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 27559 ~73.492 ms +XXX[376] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 27868 ~74.117 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 84 / 27644 ~73.522 ms +XXX[377] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 27952 ~74.144 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 27728 ~73.549 ms +XXX[378] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28035 ~74.168 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 27811 ~73.574 ms +XXX[379] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28118 ~74.191 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 27893 ~73.597 ms +FrameCount: 480 - FrameRate: 12.0 +XXX[380] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28201 ~74.215 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 27976 ~73.621 ms +XXX[381] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28284 ~74.238 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 28058 ~73.645 ms +XXX[382] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28367 ~74.261 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 28141 ~73.667 ms +XXX[383] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28450 ~74.284 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 28223 ~73.691 ms +XXX[384] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28533 ~74.306 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 28306 ~73.714 ms +XXX[385] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28616 ~74.327 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 28388 ~73.735 ms +XXX[386] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28699 ~74.35 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 28470 ~73.758 ms +XXX[387] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28781 ~74.371 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 28552 ~73.779 ms +XXX[388] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 28863 ~74.39 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 28634 ~73.799 ms +XXX[389] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 28945 ~74.41 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 28715 ~73.818 ms +XXX[390] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29028 ~74.432 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 28797 ~73.84 ms +XXX[391] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29111 ~74.453 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 28880 ~73.862 ms +XXX[392] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29194 ~74.475 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 28962 ~73.884 ms +XXX[393] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29277 ~74.497 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 29045 ~73.906 ms +XXX[394] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29359 ~74.516 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 81 / 29127 ~73.926 ms +XXX[395] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29442 ~74.537 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 29209 ~73.947 ms +XXX[396] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29525 ~74.559 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 29291 ~73.969 ms +XXX[397] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29608 ~74.579 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 29373 ~73.989 ms +XXX[398] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29691 ~74.601 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 29456 ~74.011 ms +XXX[399] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29775 ~74.624 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 83 / 29539 ~74.034 ms +XXX[400] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29857 ~74.643 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 81 / 29621 ~74.054 ms +XXX[401] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29940 ~74.663 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 29704 ~74.074 ms +XXX[402] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30022 ~74.683 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 29786 ~74.095 ms +XXX[403] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30105 ~74.703 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 29868 ~74.115 ms +XXX[404] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30188 ~74.724 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 29951 ~74.136 ms +XXX[405] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30272 ~74.745 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 82 / 30034 ~74.158 ms +XXX[406] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30355 ~74.768 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 83 / 30117 ~74.18 ms +XXX[407] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 30439 ~74.79 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 83 / 30200 ~74.203 ms +XXX[408] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 30524 ~74.814 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 83 / 30284 ~74.227 ms +XXX[409] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30606 ~74.833 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 81 / 30366 ~74.246 ms +XXX[410] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 30686 ~74.846 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 79 / 30446 ~74.259 ms +XXX[411] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 30767 ~74.859 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 79 / 30526 ~74.273 ms +XXX[412] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 30847 ~74.872 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 79 / 30606 ~74.286 ms +XXX[413] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 30911 ~74.846 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 63 / 30669 ~74.26 ms +XXX[414] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 30977 ~74.825 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 30735 ~74.239 ms +XXX[415] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31043 ~74.802 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 65 / 30800 ~74.217 ms +XXX[416] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31108 ~74.78 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 65 / 30865 ~74.195 ms +XXX[417] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31174 ~74.759 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 65 / 30930 ~74.174 ms +XXX[418] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31240 ~74.738 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 65 / 30996 ~74.154 ms +XXX[419] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31306 ~74.718 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 65 / 31062 ~74.134 ms +XXX[420] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31373 ~74.697 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 65 / 31127 ~74.113 ms +XXX[421] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31438 ~74.675 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 64 / 31192 ~74.092 ms +XXX[422] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31504 ~74.656 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 65 / 31258 ~74.072 ms +XXX[423] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31570 ~74.635 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 65 / 31324 ~74.052 ms +XXX[424] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31637 ~74.617 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0020 ms, finishGL 66 / 31390 ~74.034 ms +XXX[425] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 31704 ~74.599 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 31457 ~74.016 ms +XXX[426] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31771 ~74.58 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 31523 ~73.997 ms +XXX[427] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31837 ~74.561 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 31588 ~73.978 ms +XXX[428] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 31905 ~74.544 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 67 / 31656 ~73.962 ms +XXX[429] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31971 ~74.526 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 31722 ~73.944 ms +XXX[430] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32038 ~74.508 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 31788 ~73.927 ms +XXX[431] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32105 ~74.49 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 31854 ~73.909 ms +XXX[432] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32172 ~74.473 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 31921 ~73.892 ms +XXX[433] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32238 ~74.453 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 31987 ~73.873 ms +XXX[434] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32305 ~74.435 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 32053 ~73.855 ms +XXX[435] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32371 ~74.416 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 32118 ~73.836 ms +XXX[436] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32438 ~74.399 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 32185 ~73.819 ms +XXX[437] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32504 ~74.381 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 32251 ~73.801 ms +XXX[438] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32570 ~74.362 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 32316 ~73.782 ms +XXX[439] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32636 ~74.342 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 32381 ~73.763 ms +XXX[440] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32702 ~74.323 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 32447 ~73.744 ms +XXX[441] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32768 ~74.303 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 32512 ~73.724 ms +XXX[442] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32833 ~74.284 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 32577 ~73.705 ms +XXX[443] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32898 ~74.263 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 64 / 32642 ~73.685 ms +XXX[444] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32964 ~74.244 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 32707 ~73.665 ms +XXX[445] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33030 ~74.224 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 32772 ~73.646 ms +XXX[446] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33096 ~74.206 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 32838 ~73.628 ms +XXX[447] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33161 ~74.186 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 64 / 32903 ~73.609 ms +XXX[448] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33226 ~74.167 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 64 / 32968 ~73.589 ms +XXX[449] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33292 ~74.148 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 33033 ~73.571 ms +XXX[450] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33358 ~74.129 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 33098 ~73.552 ms +XXX[451] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33423 ~74.11 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 64 / 33163 ~73.533 ms +XXX[452] TO 17 ms, lFrame0 0 ms, lFrameX 47 / 33471 ~74.052 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 47 / 33210 ~73.474 ms +XXX[453] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 33521 ~73.999 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 49 / 33260 ~73.422 ms +XXX[454] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 33570 ~73.944 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33308 ~73.367 ms +XXX[455] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 33619 ~73.888 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 47 / 33356 ~73.311 ms +XXX[456] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 33669 ~73.836 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 49 / 33406 ~73.259 ms +XXX[457] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 33718 ~73.781 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33454 ~73.205 ms +XXX[458] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33767 ~73.728 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33503 ~73.152 ms +XXX[459] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33816 ~73.674 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33552 ~73.099 ms +XXX[460] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33866 ~73.622 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 49 / 33601 ~73.046 ms +XXX[461] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33915 ~73.569 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33650 ~72.993 ms +XXX[462] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 33964 ~73.515 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33698 ~72.94 ms +XXX[463] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34013 ~73.462 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33747 ~72.887 ms +XXX[464] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34062 ~73.41 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33795 ~72.835 ms +XXX[465] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34111 ~73.357 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33844 ~72.783 ms +XXX[466] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34160 ~73.305 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33892 ~72.731 ms +XXX[467] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34209 ~73.253 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33941 ~72.679 ms +XXX[468] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34258 ~73.202 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 33989 ~72.628 ms +XXX[469] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34307 ~73.15 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 34038 ~72.576 ms +XXX[470] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34356 ~73.099 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 34087 ~72.525 ms +XXX[471] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34405 ~73.048 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 34135 ~72.474 ms +XXX[472] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34455 ~72.998 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 34184 ~72.424 ms +XXX[473] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34503 ~72.945 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 47 / 34232 ~72.372 ms +XXX[474] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 34553 ~72.897 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 49 / 34281 ~72.324 ms +XXX[475] TO 17 ms, lFrame0 2 ms, lFrameX 34 / 34588 ~72.816 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 31 / 34313 ~72.239 ms +XXX[476] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 34653 ~72.8 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 64 / 34378 ~72.223 ms +XXX[477] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 34703 ~72.754 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 50 / 34428 ~72.177 ms +XXX[478] TO 17 ms, lFrame0 1 ms, lFrameX 33 / 34737 ~72.672 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 32 / 34461 ~72.094 ms +XXX[479] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 34803 ~72.658 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 34526 ~72.08 ms +XXX[480] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34852 ~72.61 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 34575 ~72.031 ms +XXX[481] TO 17 ms, lFrame0 0 ms, lFrameX 34 / 34887 ~72.53 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 33 / 34608 ~71.951 ms +XXX[482] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 34954 ~72.519 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 34675 ~71.94 ms +XXX[483] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35004 ~72.473 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 49 / 34725 ~71.894 ms +XXX[484] TO 17 ms, lFrame0 0 ms, lFrameX 35 / 35040 ~72.396 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 34 / 34760 ~71.818 ms +XXX[485] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 35105 ~72.381 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 64 / 34824 ~71.803 ms +XXX[486] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35155 ~72.336 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 49 / 34874 ~71.757 ms +XXX[487] TO 17 ms, lFrame0 0 ms, lFrameX 37 / 35192 ~72.264 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 36 / 34911 ~71.685 ms +XXX[488] TO 17 ms, lFrame0 1 ms, lFrameX 46 / 35238 ~72.21 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 44 / 34955 ~71.629 ms +XXX[489] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35289 ~72.167 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 50 / 35005 ~71.585 ms +XXX[490] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 35356 ~72.156 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 35071 ~71.574 ms +XXX[491] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35406 ~72.111 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 49 / 35121 ~71.529 ms +XXX[492] TO 17 ms, lFrame0 0 ms, lFrameX 38 / 35445 ~72.043 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 37 / 35159 ~71.461 ms +XXX[493] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 35506 ~72.021 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 60 / 35220 ~71.44 ms +XXX[494] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35557 ~71.978 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 49 / 35269 ~71.396 ms +XXX[495] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35607 ~71.933 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 48 / 35318 ~71.35 ms +XXX[496] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35657 ~71.89 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 49 / 35368 ~71.307 ms +XXX[497] TO 17 ms, lFrame0 0 ms, lFrameX 41 / 35698 ~71.828 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 40 / 35408 ~71.244 ms +XXX[498] TO 17 ms, lFrame0 0 ms, lFrameX 76 / 35775 ~71.837 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 75 / 35484 ~71.254 ms +XXX[499] TO 17 ms, lFrame0 0 ms, lFrameX 53 / 35828 ~71.799 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 52 / 35537 ~71.216 ms +FrameCount: 600 - FrameRate: 20.0 +XXX[500] TO 17 ms, lFrame0 0 ms, lFrameX 47 / 35875 ~71.75 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 46 / 35583 ~71.167 ms +XXX[501] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 35950 ~71.756 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 73 / 35657 ~71.172 ms +XXX[502] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 36020 ~71.753 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 69 / 35727 ~71.169 ms +XXX[503] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 36080 ~71.73 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 59 / 35787 ~71.147 ms +XXX[504] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 36151 ~71.728 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 70 / 35857 ~71.145 ms +XXX[505] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 36241 ~71.766 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 90 / 35947 ~71.183 ms +XXX[506] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36325 ~71.789 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 36030 ~71.207 ms +XXX[507] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36408 ~71.811 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 36113 ~71.229 ms +XXX[508] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36491 ~71.833 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 36195 ~71.251 ms +XXX[509] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36575 ~71.856 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 36278 ~71.274 ms +XXX[510] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36658 ~71.878 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 36361 ~71.296 ms +XXX[511] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36740 ~71.899 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 36443 ~71.317 ms +XXX[512] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36823 ~71.921 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 36525 ~71.339 ms +XXX[513] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36906 ~71.942 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 36608 ~71.361 ms +XXX[514] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36990 ~71.965 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 36691 ~71.384 ms +XXX[515] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37073 ~71.987 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 36774 ~71.406 ms +XXX[516] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37156 ~72.009 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 36857 ~71.428 ms +XXX[517] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37240 ~72.031 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 36940 ~71.451 ms +XXX[518] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37323 ~72.053 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 37023 ~71.473 ms +XXX[519] TO 17 ms, lFrame0 6 ms, lFrameX 82 / 37406 ~72.073 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 76 / 37099 ~71.482 ms +XXX[520] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37488 ~72.092 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 37181 ~71.501 ms +XXX[521] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37571 ~72.113 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 37263 ~71.523 ms +XXX[522] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37654 ~72.134 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 37345 ~71.543 ms +XXX[523] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37736 ~72.154 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 37427 ~71.563 ms +XXX[524] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37819 ~72.174 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 37510 ~71.584 ms +XXX[525] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37902 ~72.195 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 37592 ~71.605 ms +XXX[526] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37985 ~72.215 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 37675 ~71.625 ms +XXX[527] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38068 ~72.237 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 37758 ~71.647 ms +XXX[528] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38152 ~72.258 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 37841 ~71.668 ms +XXX[529] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38235 ~72.278 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 37923 ~71.689 ms +XXX[530] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38319 ~72.3 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 38007 ~71.711 ms +XXX[531] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 38403 ~72.323 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 84 / 38091 ~71.734 ms +XXX[532] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38486 ~72.343 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 38173 ~71.755 ms +XXX[533] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 38571 ~72.366 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 38257 ~71.777 ms +XXX[534] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38654 ~72.387 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 38340 ~71.799 ms +XXX[535] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38738 ~72.408 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 38423 ~71.82 ms +XXX[536] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38822 ~72.429 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 38507 ~71.841 ms +XXX[537] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 38906 ~72.45 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 38590 ~71.862 ms +XXX[538] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38988 ~72.469 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 38672 ~71.881 ms +XXX[539] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39070 ~72.487 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 38754 ~71.9 ms +XXX[540] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39153 ~72.506 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 38836 ~71.919 ms +XXX[541] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39236 ~72.525 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 38918 ~71.938 ms +XXX[542] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39318 ~72.543 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 39000 ~71.956 ms +XXX[543] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 39398 ~72.557 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 80 / 39080 ~71.971 ms +XXX[544] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39481 ~72.575 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 39162 ~71.989 ms +XXX[545] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39564 ~72.594 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 39244 ~72.008 ms +XXX[546] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 39645 ~72.611 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 39325 ~72.025 ms +XXX[547] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 39727 ~72.627 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 39406 ~72.041 ms +XXX[548] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 39808 ~72.643 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 80 / 39487 ~72.057 ms +XXX[549] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 39889 ~72.659 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 80 / 39568 ~72.073 ms +XXX[550] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39971 ~72.676 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 39649 ~72.09 ms +XXX[551] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 40036 ~72.661 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 64 / 39714 ~72.076 ms +XXX[552] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40101 ~72.648 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 64 / 39778 ~72.063 ms +XXX[553] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40166 ~72.634 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 64 / 39843 ~72.049 ms +XXX[554] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40232 ~72.622 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 39908 ~72.037 ms +XXX[555] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40298 ~72.609 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 39973 ~72.024 ms +XXX[556] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40364 ~72.597 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 40039 ~72.012 ms +XXX[557] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 40431 ~72.588 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 40106 ~72.003 ms +XXX[558] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40497 ~72.576 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 40171 ~71.991 ms +XXX[559] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40563 ~72.565 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 40237 ~71.981 ms +XXX[560] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40630 ~72.554 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 40303 ~71.971 ms +XXX[561] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40697 ~72.544 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 66 / 40369 ~71.96 ms +XXX[562] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40763 ~72.532 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 65 / 40435 ~71.948 ms +XXX[563] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 40831 ~72.525 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 68 / 40503 ~71.942 ms +XXX[564] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 40901 ~72.52 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 69 / 40572 ~71.936 ms +XXX[565] TO 17 ms, lFrame0 0 ms, lFrameX 71 / 40973 ~72.518 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 71 / 40643 ~71.935 ms +XXX[566] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 41061 ~72.546 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 87 / 40731 ~71.963 ms +XXX[567] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 41148 ~72.571 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 86 / 40817 ~71.989 ms +XXX[568] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 41233 ~72.594 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 85 / 40903 ~72.012 ms +XXX[569] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 41317 ~72.614 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 40986 ~72.032 ms +XXX[570] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 41398 ~72.629 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 80 / 41066 ~72.047 ms +XXX[571] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 41480 ~72.644 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 80 / 41147 ~72.062 ms +XXX[572] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41562 ~72.661 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 41229 ~72.08 ms +XXX[573] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41645 ~72.679 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 41312 ~72.098 ms +XXX[574] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41728 ~72.697 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 41394 ~72.115 ms +XXX[575] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41810 ~72.713 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 41476 ~72.132 ms +XXX[576] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41893 ~72.731 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 41558 ~72.15 ms +XXX[577] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 41976 ~72.749 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 41641 ~72.169 ms +XXX[578] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42059 ~72.767 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 41724 ~72.187 ms +XXX[579] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42143 ~72.787 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 41807 ~72.206 ms +XXX[580] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42227 ~72.805 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 41890 ~72.225 ms +XXX[581] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42310 ~72.823 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 41973 ~72.243 ms +XXX[582] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 42395 ~72.844 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 84 / 42057 ~72.264 ms +XXX[583] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42478 ~72.862 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 42140 ~72.282 ms +XXX[584] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42562 ~72.88 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 42223 ~72.301 ms +XXX[585] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42644 ~72.896 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 42305 ~72.317 ms +XXX[586] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 42726 ~72.911 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 42386 ~72.332 ms +XXX[587] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 42808 ~72.926 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 42468 ~72.347 ms +XXX[588] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42890 ~72.942 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 42549 ~72.363 ms +XXX[589] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42973 ~72.959 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 42632 ~72.38 ms +XXX[590] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 43056 ~72.977 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 42715 ~72.398 ms +XXX[591] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43138 ~72.992 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 42796 ~72.413 ms +XXX[592] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 43221 ~73.01 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 42879 ~72.431 ms +XXX[593] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43304 ~73.026 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 42961 ~72.448 ms +XXX[594] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43387 ~73.042 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 43043 ~72.464 ms +XXX[595] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43470 ~73.059 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 43126 ~72.48 ms +XXX[596] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 43553 ~73.075 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 43208 ~72.497 ms +XXX[597] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43636 ~73.092 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 43290 ~72.514 ms +XXX[598] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43718 ~73.108 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 43373 ~72.53 ms +XXX[599] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 43802 ~73.126 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 43456 ~72.549 ms +XXX[600] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43885 ~73.142 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 81 / 43538 ~72.564 ms +XXX[601] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43968 ~73.158 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 43621 ~72.581 ms +XXX[602] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 44051 ~73.175 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 43704 ~72.598 ms +XXX[603] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 44135 ~73.193 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 43787 ~72.616 ms +XXX[604] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 44219 ~73.21 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 83 / 43870 ~72.633 ms +XXX[605] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 44302 ~73.227 ms, flushGL 0 / 2 ~0.0030 ms, waitGL 0 / 1 ~0.0030 ms, finishGL 82 / 43953 ~72.65 ms diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m1-sync1-flush-wait-finish.log b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m1-sync1-flush-wait-finish.log new file mode 100644 index 000000000..fe90a4ede --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m1-sync1-flush-wait-finish.log @@ -0,0 +1,745 @@ +NSZombieEnabled +NSTraceEvents YES +OBJC_PRINT_EXCEPTIONS +/usr/bin/java +java version "1.6.0_37" +Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909) +Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode) +LD_LIBRARY_PATH :../../gluegen/make/../build-macosx/obj:../build-macosx/lib +LIBXCB_ALLOW_SLOPPY_LOCK: +LIBGL_DRIVERS_PATH: +LIBGL_DEBUG: +LIBGL_ALWAYS_INDIRECT: +LIBGL_ALWAYS_SOFTWARE: +SWT_CLASSPATH: ../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar +/usr/bin/java -d64 -time 100000 -vsyncN 0 +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar + +Test Start: com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsyncN 0 + +/usr/bin/java -d64 -Djava.awt.headless=false -Djogl.debug.calayer.SwapM1 com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsyncN 0 +swapInterval 1 +exclusiveContext false +SWAP_M1 true +SWAP_M2 false +NewtCanvasAWT.attachNewtChild.2: size 500x268 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init ... +LandscapeES2 init on Thread[main-Display-.macosx_nil-1-EDT-1,5,main] +Chosen GLCapabilities: GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], offscr[fbo]] +INIT GL IS: jogamp.opengl.gl4.GL4bcImpl +GL_VENDOR: NVIDIA Corporation +GL_RENDERER: NVIDIA GeForce 320M OpenGL Engine +GL_VERSION: 2.1 NVIDIA-7.32.12 +GL GLSL: true, has-compiler-func: true, version 1.20, 1.20.0 +GL FBO: basic true, full true +GL Profile: GLProfile[GL2/GL2.hw] +GL Renderer Quirks:[NoOffscreenBitmap] +GL:jogamp.opengl.gl4.GL4bcImpl@57ac3379, 2.1 (hardware) - 2.1 NVIDIA-7.32.12 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init FIN +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.reshape 0/0 500x268, swapInterval 1, drawable 0x7ffd218cbca0 +Thread[AWT-EventQueue-0,6,main] LandscapeES2.reshape 0/0 500x268, swapInterval 1, drawable 0x7ffd218cbca0 +XXX[1] TO 17 ms, lFrame0 112 ms, lFrameX 850 / 850 ~850.044 ms, flushGL 1 / 1 ~1.124 ms, waitGL 5 / 5 ~5.544 ms, finishGL 731 / 731 ~731.319 ms +XXX[2] TO 17 ms, lFrame0 91 ms, lFrameX 179 / 1029 ~514.913 ms, flushGL 0 / 1 ~0.564 ms, waitGL 30 / 36 ~18.01 ms, finishGL 57 / 788 ~394.472 ms +XXX[3] TO 17 ms, lFrame0 2 ms, lFrameX 82 / 1112 ~370.819 ms, flushGL 0 / 1 ~0.379 ms, waitGL 0 / 36 ~12.319 ms, finishGL 79 / 868 ~289.378 ms +XXX[4] TO 17 ms, lFrame0 1 ms, lFrameX 85 / 1197 ~299.411 ms, flushGL 0 / 1 ~0.285 ms, waitGL 2 / 39 ~9.817 ms, finishGL 81 / 949 ~237.342 ms +XXX[5] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1279 ~255.977 ms, flushGL 0 / 1 ~0.229 ms, waitGL 1 / 40 ~8.166 ms, finishGL 79 / 1029 ~205.818 ms +XXX[6] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 1362 ~227.166 ms, flushGL 0 / 1 ~0.191 ms, waitGL 1 / 42 ~7.095 ms, finishGL 80 / 1109 ~184.917 ms +XXX[7] TO 17 ms, lFrame0 1 ms, lFrameX 81 / 1444 ~206.414 ms, flushGL 0 / 1 ~0.165 ms, waitGL 1 / 44 ~6.362 ms, finishGL 78 / 1187 ~169.699 ms +XXX[8] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 1527 ~190.994 ms, flushGL 0 / 1 ~0.145 ms, waitGL 3 / 48 ~6.0 ms, finishGL 79 / 1266 ~158.37 ms +XXX[9] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 1626 ~180.729 ms, flushGL 0 / 1 ~0.131 ms, waitGL 3 / 51 ~5.692 ms, finishGL 94 / 1361 ~151.302 ms +XXX[10] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 1709 ~170.991 ms, flushGL 0 / 1 ~0.118 ms, waitGL 4 / 56 ~5.623 ms, finishGL 77 / 1439 ~143.949 ms +XXX[11] TO 17 ms, lFrame0 0 ms, lFrameX 78 / 1788 ~162.557 ms, flushGL 0 / 1 ~0.108 ms, waitGL 4 / 60 ~5.514 ms, finishGL 72 / 1512 ~137.495 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 1892 ~157.681 ms, flushGL 0 / 1 ~0.099 ms, waitGL 8 / 69 ~5.801 ms, finishGL 94 / 1606 ~133.9 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1974 ~151.887 ms, flushGL 0 / 1 ~0.092 ms, waitGL 5 / 74 ~5.764 ms, finishGL 76 / 1683 ~129.467 ms +XXX[14] TO 17 ms, lFrame0 0 ms, lFrameX 76 / 2051 ~146.508 ms, flushGL 0 / 1 ~0.086 ms, waitGL 6 / 80 ~5.784 ms, finishGL 69 / 1752 ~125.199 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 2155 ~143.713 ms, flushGL 0 / 1 ~0.08 ms, waitGL 11 / 92 ~6.191 ms, finishGL 91 / 1844 ~122.975 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2238 ~139.928 ms, flushGL 0 / 1 ~0.076 ms, waitGL 8 / 101 ~6.326 ms, finishGL 74 / 1918 ~119.93 ms +XXX[17] TO 17 ms, lFrame0 1 ms, lFrameX 75 / 2314 ~136.122 ms, flushGL 0 / 1 ~0.071 ms, waitGL 7 / 108 ~6.397 ms, finishGL 66 / 1985 ~116.79 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 107 / 2421 ~134.528 ms, flushGL 0 / 1 ~0.068 ms, waitGL 14 / 123 ~6.866 ms, finishGL 91 / 2077 ~115.4 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2504 ~131.823 ms, flushGL 0 / 1 ~0.064 ms, waitGL 8 / 132 ~6.949 ms, finishGL 74 / 2151 ~113.231 ms +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 2580 ~129.009 ms, flushGL 0 / 1 ~0.061 ms, waitGL 7 / 139 ~6.994 ms, finishGL 66 / 2218 ~110.919 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 107 / 2687 ~127.962 ms, flushGL 0 / 1 ~0.058 ms, waitGL 14 / 154 ~7.365 ms, finishGL 91 / 2310 ~110.007 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2770 ~125.93 ms, flushGL 0 / 1 ~0.056 ms, waitGL 8 / 163 ~7.414 ms, finishGL 74 / 2384 ~108.382 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 2845 ~123.71 ms, flushGL 0 / 1 ~0.054 ms, waitGL 8 / 171 ~7.442 ms, finishGL 66 / 2450 ~106.547 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 105 / 2951 ~122.963 ms, flushGL 0 / 1 ~0.051 ms, waitGL 15 / 186 ~7.773 ms, finishGL 89 / 2540 ~105.845 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 3031 ~121.259 ms, flushGL 0 / 1 ~0.05 ms, waitGL 10 / 197 ~7.885 ms, finishGL 69 / 2609 ~104.382 ms +XXX[26] TO 17 ms, lFrame0 1 ms, lFrameX 70 / 3101 ~119.303 ms, flushGL 0 / 1 ~0.048 ms, waitGL 12 / 209 ~8.07 ms, finishGL 56 / 2666 ~102.545 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 94 / 3196 ~118.373 ms, flushGL 0 / 1 ~0.046 ms, waitGL 8 / 218 ~8.075 ms, finishGL 85 / 2751 ~101.909 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3278 ~117.099 ms, flushGL 0 / 1 ~0.045 ms, waitGL 13 / 231 ~8.283 ms, finishGL 67 / 2819 ~100.691 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 3346 ~115.386 ms, flushGL 0 / 1 ~0.043 ms, waitGL 14 / 246 ~8.511 ms, finishGL 51 / 2871 ~99.0 ms +XXX[30] TO 17 ms, lFrame0 0 ms, lFrameX 97 / 3443 ~114.777 ms, flushGL 0 / 1 ~0.042 ms, waitGL 13 / 260 ~8.668 ms, finishGL 83 / 2954 ~98.477 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 3525 ~113.715 ms, flushGL 0 / 1 ~0.041 ms, waitGL 16 / 276 ~8.926 ms, finishGL 64 / 3019 ~97.389 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 3589 ~112.176 ms, flushGL 0 / 1 ~0.041 ms, waitGL 1 / 278 ~8.689 ms, finishGL 62 / 3081 ~96.295 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 3673 ~111.319 ms, flushGL 0 / 1 ~0.04 ms, waitGL 2 / 280 ~8.499 ms, finishGL 80 / 3162 ~95.828 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3739 ~109.987 ms, flushGL 0 / 1 ~0.039 ms, waitGL 1 / 282 ~8.304 ms, finishGL 63 / 3225 ~94.878 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 3802 ~108.655 ms, flushGL 0 / 1 ~0.038 ms, waitGL 2 / 284 ~8.131 ms, finishGL 60 / 3286 ~93.897 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 3888 ~108.004 ms, flushGL 0 / 1 ~0.037 ms, waitGL 5 / 289 ~8.052 ms, finishGL 79 / 3365 ~93.496 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 3955 ~106.916 ms, flushGL 0 / 1 ~0.036 ms, waitGL 3 / 293 ~7.931 ms, finishGL 63 / 3429 ~92.691 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 4018 ~105.762 ms, flushGL 0 / 1 ~0.035 ms, waitGL 2 / 296 ~7.795 ms, finishGL 59 / 3489 ~91.822 ms +XXX[39] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 4104 ~105.241 ms, flushGL 0 / 1 ~0.034 ms, waitGL 5 / 301 ~7.731 ms, finishGL 79 / 3568 ~91.509 ms +XXX[40] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 4170 ~104.255 ms, flushGL 0 / 1 ~0.033 ms, waitGL 3 / 304 ~7.622 ms, finishGL 61 / 3630 ~90.771 ms +XXX[41] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 4230 ~103.185 ms, flushGL 0 / 1 ~0.033 ms, waitGL 4 / 308 ~7.535 ms, finishGL 55 / 3686 ~89.918 ms +XXX[42] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 4318 ~102.829 ms, flushGL 0 / 1 ~0.032 ms, waitGL 9 / 318 ~7.588 ms, finishGL 78 / 3764 ~89.635 ms +XXX[43] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4385 ~101.979 ms, flushGL 0 / 1 ~0.031 ms, waitGL 5 / 323 ~7.534 ms, finishGL 60 / 3825 ~88.959 ms +XXX[44] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 4444 ~101.014 ms, flushGL 0 / 1 ~0.031 ms, waitGL 5 / 329 ~7.486 ms, finishGL 53 / 3879 ~88.159 ms +XXX[45] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 4534 ~100.772 ms, flushGL 0 / 1 ~0.03 ms, waitGL 11 / 340 ~7.577 ms, finishGL 78 / 3957 ~87.933 ms +XXX[46] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4600 ~100.017 ms, flushGL 0 / 1 ~0.029 ms, waitGL 5 / 346 ~7.526 ms, finishGL 60 / 4017 ~87.333 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 4661 ~99.171 ms, flushGL 0 / 1 ~0.029 ms, waitGL 5 / 351 ~7.484 ms, finishGL 53 / 4071 ~86.623 ms +XXX[48] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 4750 ~98.961 ms, flushGL 0 / 1 ~0.028 ms, waitGL 11 / 363 ~7.565 ms, finishGL 77 / 4148 ~86.428 ms +XXX[49] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4816 ~98.297 ms, flushGL 0 / 1 ~0.028 ms, waitGL 6 / 369 ~7.534 ms, finishGL 59 / 4208 ~85.887 ms +XXX[50] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 4876 ~97.524 ms, flushGL 0 / 1 ~0.027 ms, waitGL 5 / 375 ~7.502 ms, finishGL 53 / 4261 ~85.231 ms +XXX[51] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 4965 ~97.36 ms, flushGL 0 / 1 ~0.027 ms, waitGL 12 / 387 ~7.595 ms, finishGL 76 / 4338 ~85.059 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5032 ~96.78 ms, flushGL 0 / 1 ~0.026 ms, waitGL 7 / 394 ~7.586 ms, finishGL 59 / 4397 ~84.57 ms +XXX[53] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 5091 ~96.069 ms, flushGL 0 / 1 ~0.026 ms, waitGL 5 / 400 ~7.554 ms, finishGL 52 / 4450 ~83.966 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 90 / 5182 ~95.967 ms, flushGL 0 / 1 ~0.025 ms, waitGL 12 / 413 ~7.649 ms, finishGL 77 / 4527 ~83.843 ms +XXX[55] TO 17 ms, lFrame0 1 ms, lFrameX 65 / 5247 ~95.414 ms, flushGL 0 / 1 ~0.025 ms, waitGL 6 / 419 ~7.626 ms, finishGL 58 / 4585 ~83.374 ms +XXX[56] TO 17 ms, lFrame0 0 ms, lFrameX 58 / 5306 ~94.761 ms, flushGL 0 / 1 ~0.025 ms, waitGL 6 / 426 ~7.609 ms, finishGL 51 / 4637 ~82.806 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 5396 ~94.675 ms, flushGL 0 / 1 ~0.024 ms, waitGL 13 / 439 ~7.717 ms, finishGL 75 / 4712 ~82.679 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5463 ~94.203 ms, flushGL 0 / 1 ~0.024 ms, waitGL 8 / 447 ~7.722 ms, finishGL 58 / 4771 ~82.269 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 5523 ~93.626 ms, flushGL 0 / 1 ~0.023 ms, waitGL 6 / 454 ~7.709 ms, finishGL 52 / 4824 ~81.765 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 5613 ~93.551 ms, flushGL 0 / 1 ~0.023 ms, waitGL 12 / 467 ~7.785 ms, finishGL 76 / 4900 ~81.672 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5679 ~93.106 ms, flushGL 0 / 1 ~0.023 ms, waitGL 7 / 474 ~7.773 ms, finishGL 58 / 4959 ~81.297 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 5739 ~92.578 ms, flushGL 0 / 1 ~0.022 ms, waitGL 6 / 480 ~7.757 ms, finishGL 52 / 5011 ~80.836 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 73 / 5813 ~92.276 ms, flushGL 0 / 1 ~0.022 ms, waitGL 12 / 493 ~7.833 ms, finishGL 60 / 5072 ~80.515 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5880 ~91.883 ms, flushGL 0 / 1 ~0.022 ms, waitGL 5 / 499 ~7.8 ms, finishGL 60 / 5133 ~80.208 ms +XXX[65] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5947 ~91.498 ms, flushGL 0 / 1 ~0.022 ms, waitGL 5 / 504 ~7.759 ms, finishGL 61 / 5194 ~79.917 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6013 ~91.121 ms, flushGL 0 / 1 ~0.021 ms, waitGL 4 / 508 ~7.711 ms, finishGL 61 / 5256 ~79.638 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6080 ~90.758 ms, flushGL 0 / 1 ~0.021 ms, waitGL 4 / 513 ~7.666 ms, finishGL 61 / 5317 ~79.37 ms +XXX[68] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6148 ~90.413 ms, flushGL 0 / 1 ~0.021 ms, waitGL 4 / 517 ~7.617 ms, finishGL 62 / 5380 ~79.122 ms +XXX[69] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6214 ~90.065 ms, flushGL 0 / 1 ~0.021 ms, waitGL 3 / 521 ~7.552 ms, finishGL 62 / 5443 ~78.886 ms +XXX[70] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6280 ~89.725 ms, flushGL 0 / 1 ~0.02 ms, waitGL 3 / 524 ~7.492 ms, finishGL 62 / 5505 ~78.649 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6347 ~89.396 ms, flushGL 0 / 1 ~0.02 ms, waitGL 3 / 528 ~7.439 ms, finishGL 62 / 5567 ~78.417 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6413 ~89.073 ms, flushGL 0 / 1 ~0.02 ms, waitGL 3 / 531 ~7.385 ms, finishGL 62 / 5629 ~78.19 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6479 ~88.753 ms, flushGL 0 / 1 ~0.02 ms, waitGL 4 / 536 ~7.343 ms, finishGL 60 / 5690 ~77.954 ms +XXX[74] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6544 ~88.442 ms, flushGL 0 / 1 ~0.019 ms, waitGL 4 / 540 ~7.307 ms, finishGL 60 / 5751 ~77.719 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6611 ~88.153 ms, flushGL 0 / 1 ~0.019 ms, waitGL 6 / 547 ~7.294 ms, finishGL 59 / 5811 ~77.483 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6677 ~87.867 ms, flushGL 0 / 1 ~0.019 ms, waitGL 5 / 552 ~7.265 ms, finishGL 60 / 5872 ~77.264 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6744 ~87.595 ms, flushGL 0 / 1 ~0.019 ms, waitGL 5 / 557 ~7.24 ms, finishGL 61 / 5933 ~77.055 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6812 ~87.341 ms, flushGL 0 / 1 ~0.018 ms, waitGL 5 / 562 ~7.217 ms, finishGL 61 / 5994 ~76.857 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6879 ~87.081 ms, flushGL 0 / 1 ~0.018 ms, waitGL 3 / 566 ~7.169 ms, finishGL 62 / 6057 ~76.68 ms +XXX[80] TO 17 ms, lFrame0 4 ms, lFrameX 66 / 6945 ~86.819 ms, flushGL 0 / 1 ~0.018 ms, waitGL 16 / 582 ~7.283 ms, finishGL 44 / 6102 ~76.282 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 7012 ~86.575 ms, flushGL 0 / 1 ~0.018 ms, waitGL 3 / 586 ~7.239 ms, finishGL 62 / 6165 ~76.118 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7078 ~86.325 ms, flushGL 0 / 1 ~0.018 ms, waitGL 3 / 589 ~7.188 ms, finishGL 62 / 6228 ~75.952 ms +XXX[83] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7145 ~86.089 ms, flushGL 0 / 1 ~0.018 ms, waitGL 3 / 593 ~7.145 ms, finishGL 62 / 6290 ~75.792 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7212 ~85.859 ms, flushGL 0 / 1 ~0.017 ms, waitGL 3 / 596 ~7.1 ms, finishGL 62 / 6353 ~75.638 ms +XXX[85] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7279 ~85.637 ms, flushGL 0 / 1 ~0.017 ms, waitGL 2 / 599 ~7.052 ms, finishGL 63 / 6417 ~75.496 ms +XXX[86] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7345 ~85.409 ms, flushGL 0 / 1 ~0.017 ms, waitGL 2 / 602 ~7.002 ms, finishGL 62 / 6480 ~75.349 ms +XXX[87] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7411 ~85.188 ms, flushGL 0 / 1 ~0.017 ms, waitGL 3 / 605 ~6.958 ms, finishGL 62 / 6542 ~75.202 ms +XXX[88] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7477 ~84.976 ms, flushGL 0 / 1 ~0.017 ms, waitGL 3 / 608 ~6.917 ms, finishGL 62 / 6605 ~75.059 ms +XXX[89] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7544 ~84.766 ms, flushGL 0 / 1 ~0.017 ms, waitGL 3 / 611 ~6.873 ms, finishGL 62 / 6668 ~74.922 ms +XXX[90] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7610 ~84.566 ms, flushGL 0 / 1 ~0.016 ms, waitGL 3 / 615 ~6.835 ms, finishGL 62 / 6730 ~74.788 ms +XXX[91] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 7676 ~84.361 ms, flushGL 0 / 1 ~0.016 ms, waitGL 3 / 618 ~6.796 ms, finishGL 62 / 6793 ~74.649 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7743 ~84.166 ms, flushGL 0 / 1 ~0.016 ms, waitGL 3 / 621 ~6.759 ms, finishGL 62 / 6855 ~74.518 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7810 ~83.979 ms, flushGL 0 / 1 ~0.016 ms, waitGL 3 / 625 ~6.728 ms, finishGL 62 / 6918 ~74.388 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7876 ~83.792 ms, flushGL 0 / 1 ~0.016 ms, waitGL 3 / 629 ~6.693 ms, finishGL 62 / 6980 ~74.261 ms +XXX[95] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 7942 ~83.603 ms, flushGL 0 / 1 ~0.016 ms, waitGL 3 / 632 ~6.657 ms, finishGL 62 / 7042 ~74.133 ms +XXX[96] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 8008 ~83.42 ms, flushGL 0 / 1 ~0.016 ms, waitGL 4 / 636 ~6.631 ms, finishGL 61 / 7104 ~74.0 ms +XXX[97] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8074 ~83.245 ms, flushGL 0 / 1 ~0.015 ms, waitGL 4 / 641 ~6.609 ms, finishGL 61 / 7165 ~73.871 ms +XXX[98] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8140 ~83.07 ms, flushGL 0 / 1 ~0.015 ms, waitGL 4 / 645 ~6.588 ms, finishGL 61 / 7226 ~73.741 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8207 ~82.9 ms, flushGL 0 / 1 ~0.015 ms, waitGL 4 / 650 ~6.57 ms, finishGL 60 / 7287 ~73.612 ms +XXX[1] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 66 ~66.068 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 5 ~5.429 ms, finishGL 60 / 60 ~60.167 ms +XXX[2] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 132 ~66.192 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 10 ~5.453 ms, finishGL 60 / 120 ~60.277 ms +XXX[3] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 198 ~66.248 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 16 ~5.506 ms, finishGL 60 / 180 ~60.269 ms +XXX[4] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 264 ~66.104 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 22 ~5.581 ms, finishGL 59 / 240 ~60.061 ms +XXX[5] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 330 ~66.144 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 6 / 28 ~5.786 ms, finishGL 59 / 299 ~59.896 ms +XXX[6] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 397 ~66.292 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 6 / 35 ~5.943 ms, finishGL 59 / 359 ~59.883 ms +XXX[7] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 464 ~66.376 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 6 / 41 ~5.974 ms, finishGL 60 / 419 ~59.933 ms +XXX[8] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 531 ~66.462 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 47 ~5.941 ms, finishGL 60 / 480 ~60.052 ms +XXX[9] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 599 ~66.638 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 53 ~5.912 ms, finishGL 61 / 542 ~60.257 ms +XXX[10] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 665 ~66.544 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 3 / 56 ~5.684 ms, finishGL 61 / 603 ~60.392 ms +XXX[11] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 731 ~66.491 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 4 / 61 ~5.563 ms, finishGL 61 / 665 ~60.459 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 797 ~66.436 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 4 / 66 ~5.511 ms, finishGL 60 / 725 ~60.457 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 863 ~66.445 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 71 ~5.515 ms, finishGL 60 / 786 ~60.463 ms +XXX[14] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 929 ~66.392 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 77 ~5.523 ms, finishGL 59 / 845 ~60.402 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 996 ~66.401 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 6 / 83 ~5.572 ms, finishGL 59 / 905 ~60.36 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1062 ~66.427 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 6 / 90 ~5.64 ms, finishGL 59 / 965 ~60.319 ms +XXX[17] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1130 ~66.474 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 96 ~5.66 ms, finishGL 60 / 1025 ~60.347 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1196 ~66.479 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 101 ~5.642 ms, finishGL 60 / 1086 ~60.369 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1263 ~66.504 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 5 / 106 ~5.618 ms, finishGL 61 / 1147 ~60.418 ms +FrameCount: 120 - FrameRate: 15.0 +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1330 ~66.516 ms, flushGL 0 / 0 ~0.0020 ms, waitGL 4 / 111 ~5.581 ms, finishGL 61 / 1209 ~60.461 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1397 ~66.566 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 115 ~5.523 ms, finishGL 62 / 1271 ~60.569 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1464 ~66.586 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 119 ~5.418 ms, finishGL 63 / 1335 ~60.694 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1531 ~66.586 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 122 ~5.318 ms, finishGL 63 / 1398 ~60.795 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1598 ~66.601 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 125 ~5.226 ms, finishGL 63 / 1461 ~60.903 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1665 ~66.609 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 128 ~5.14 ms, finishGL 63 / 1524 ~60.998 ms +XXX[26] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1731 ~66.586 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 130 ~5.009 ms, finishGL 63 / 1588 ~61.105 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1798 ~66.602 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 132 ~4.92 ms, finishGL 63 / 1652 ~61.21 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1864 ~66.603 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 135 ~4.839 ms, finishGL 63 / 1716 ~61.292 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 1930 ~66.575 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 137 ~4.738 ms, finishGL 63 / 1779 ~61.365 ms +XXX[30] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1997 ~66.575 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 139 ~4.666 ms, finishGL 63 / 1843 ~61.438 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2063 ~66.569 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 142 ~4.596 ms, finishGL 63 / 1906 ~61.502 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2129 ~66.557 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 144 ~4.531 ms, finishGL 63 / 1969 ~61.556 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 2197 ~66.575 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 147 ~4.479 ms, finishGL 63 / 2033 ~61.626 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2263 ~66.574 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 150 ~4.414 ms, finishGL 63 / 2097 ~61.689 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2329 ~66.556 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 152 ~4.352 ms, finishGL 63 / 2160 ~61.734 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2396 ~66.559 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 155 ~4.306 ms, finishGL 63 / 2224 ~61.783 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2462 ~66.558 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 157 ~4.257 ms, finishGL 63 / 2287 ~61.831 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2528 ~66.548 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 160 ~4.223 ms, finishGL 62 / 2350 ~61.856 ms +XXX[39] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2595 ~66.55 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 162 ~4.178 ms, finishGL 63 / 2414 ~61.903 ms +XXX[40] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2662 ~66.55 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 165 ~4.142 ms, finishGL 63 / 2477 ~61.939 ms +XXX[41] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2728 ~66.548 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 168 ~4.116 ms, finishGL 62 / 2540 ~61.962 ms +XXX[42] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2794 ~66.536 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 171 ~4.077 ms, finishGL 63 / 2603 ~61.987 ms +XXX[43] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2860 ~66.521 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 173 ~4.044 ms, finishGL 62 / 2666 ~62.005 ms +XXX[44] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2925 ~66.49 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 177 ~4.027 ms, finishGL 61 / 2727 ~61.987 ms +XXX[45] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 2990 ~66.456 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 181 ~4.043 ms, finishGL 59 / 2787 ~61.933 ms +XXX[46] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 3054 ~66.404 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 188 ~4.094 ms, finishGL 57 / 2844 ~61.83 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 3117 ~66.333 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 8 / 196 ~4.189 ms, finishGL 54 / 2898 ~61.665 ms +XXX[48] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 3180 ~66.252 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 11 / 208 ~4.349 ms, finishGL 50 / 2948 ~61.424 ms +XXX[49] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 3242 ~66.165 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 224 ~4.587 ms, finishGL 45 / 2993 ~61.099 ms +XXX[50] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3290 ~65.805 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 228 ~4.571 ms, finishGL 43 / 3037 ~60.756 ms +XXX[51] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3339 ~65.474 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 234 ~4.595 ms, finishGL 42 / 3080 ~60.401 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3388 ~65.155 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 240 ~4.634 ms, finishGL 41 / 3122 ~60.044 ms +XXX[53] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3437 ~64.853 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 248 ~4.682 ms, finishGL 41 / 3163 ~59.693 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3486 ~64.56 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 8 / 256 ~4.745 ms, finishGL 40 / 3204 ~59.336 ms +XXX[55] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3535 ~64.285 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 8 / 264 ~4.816 ms, finishGL 40 / 3244 ~58.991 ms +XXX[56] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3585 ~64.022 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 273 ~4.891 ms, finishGL 40 / 3284 ~58.653 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3634 ~63.762 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 283 ~4.966 ms, finishGL 39 / 3324 ~58.317 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3683 ~63.514 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 292 ~5.051 ms, finishGL 39 / 3363 ~57.986 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3733 ~63.271 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 303 ~5.139 ms, finishGL 38 / 3401 ~57.654 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3782 ~63.034 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 314 ~5.236 ms, finishGL 37 / 3439 ~57.32 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3831 ~62.805 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 11 / 325 ~5.341 ms, finishGL 36 / 3476 ~56.986 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3879 ~62.576 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 12 / 338 ~5.456 ms, finishGL 35 / 3511 ~56.642 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3928 ~62.356 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 351 ~5.585 ms, finishGL 34 / 3546 ~56.294 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3977 ~62.142 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 366 ~5.727 ms, finishGL 33 / 3580 ~55.938 ms +XXX[65] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4025 ~61.937 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 382 ~5.881 ms, finishGL 32 / 3612 ~55.579 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4074 ~61.731 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 382 ~5.794 ms, finishGL 47 / 3660 ~55.461 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 30 / 4104 ~61.265 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 384 ~5.736 ms, finishGL 27 / 3688 ~55.045 ms +XXX[68] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 4155 ~61.106 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 388 ~5.711 ms, finishGL 45 / 3733 ~54.911 ms +XXX[69] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4187 ~60.689 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 392 ~5.684 ms, finishGL 28 / 3761 ~54.521 ms +XXX[70] TO 17 ms, lFrame0 0 ms, lFrameX 28 / 4216 ~60.231 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 397 ~5.677 ms, finishGL 22 / 3784 ~54.069 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 53 / 4269 ~60.13 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 8 / 406 ~5.721 ms, finishGL 43 / 3828 ~53.925 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4301 ~59.745 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 412 ~5.727 ms, finishGL 25 / 3854 ~53.535 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 25 / 4327 ~59.278 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 418 ~5.739 ms, finishGL 18 / 3872 ~53.052 ms +XXX[74] TO 17 ms, lFrame0 0 ms, lFrameX 39 / 4366 ~59.011 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 432 ~5.845 ms, finishGL 25 / 3898 ~52.678 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4415 ~58.868 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 439 ~5.862 ms, finishGL 40 / 3938 ~52.519 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4447 ~58.52 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 449 ~5.913 ms, finishGL 22 / 3961 ~52.12 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 23 / 4471 ~58.069 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 459 ~5.968 ms, finishGL 12 / 3974 ~51.61 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 42 / 4513 ~57.866 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 462 ~5.932 ms, finishGL 38 / 4012 ~51.443 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4547 ~57.557 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 473 ~5.991 ms, finishGL 22 / 4034 ~51.074 ms +XXX[80] TO 17 ms, lFrame0 0 ms, lFrameX 23 / 4570 ~57.135 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 483 ~6.039 ms, finishGL 13 / 4047 ~50.599 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 42 / 4613 ~56.951 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 485 ~5.999 ms, finishGL 38 / 4086 ~50.453 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4646 ~56.659 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 496 ~6.053 ms, finishGL 22 / 4108 ~50.107 ms +XXX[83] TO 17 ms, lFrame0 1 ms, lFrameX 25 / 4671 ~56.288 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 505 ~6.094 ms, finishGL 15 / 4123 ~49.685 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 46 / 4718 ~56.169 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 505 ~6.023 ms, finishGL 45 / 4169 ~49.637 ms +XXX[85] TO 17 ms, lFrame0 0 ms, lFrameX 38 / 4756 ~55.957 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 510 ~6.002 ms, finishGL 33 / 4203 ~49.447 ms +XXX[86] TO 17 ms, lFrame0 0 ms, lFrameX 36 / 4793 ~55.733 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 525 ~6.11 ms, finishGL 20 / 4223 ~49.114 ms +XXX[87] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 4862 ~55.889 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 11 / 537 ~6.174 ms, finishGL 57 / 4280 ~49.206 ms +XXX[88] TO 17 ms, lFrame0 0 ms, lFrameX 52 / 4914 ~55.849 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 547 ~6.218 ms, finishGL 41 / 4322 ~49.122 ms +XXX[89] TO 17 ms, lFrame0 0 ms, lFrameX 42 / 4957 ~55.703 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 554 ~6.226 ms, finishGL 35 / 4358 ~48.967 ms +XXX[90] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 5031 ~55.911 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 567 ~6.304 ms, finishGL 60 / 4418 ~49.096 ms +XXX[91] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5082 ~55.846 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 573 ~6.297 ms, finishGL 43 / 4462 ~49.039 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 43 / 5125 ~55.711 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 578 ~6.289 ms, finishGL 37 / 4499 ~48.91 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 5198 ~55.892 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 11 / 590 ~6.344 ms, finishGL 60 / 4560 ~49.036 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5248 ~55.834 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 596 ~6.343 ms, finishGL 43 / 4604 ~48.979 ms +XXX[95] TO 17 ms, lFrame0 0 ms, lFrameX 44 / 5292 ~55.709 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 601 ~6.327 ms, finishGL 38 / 4642 ~48.87 ms +XXX[96] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 5365 ~55.885 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 611 ~6.371 ms, finishGL 61 / 4704 ~49.002 ms +XXX[97] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5415 ~55.831 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 617 ~6.36 ms, finishGL 44 / 4749 ~48.959 ms +XXX[98] TO 17 ms, lFrame0 0 ms, lFrameX 44 / 5460 ~55.717 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 620 ~6.335 ms, finishGL 40 / 4789 ~48.869 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 5532 ~55.886 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 8 / 629 ~6.358 ms, finishGL 63 / 4852 ~49.014 ms +XXX[100] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 5584 ~55.843 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 632 ~6.327 ms, finishGL 47 / 4900 ~49.001 ms +XXX[101] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 5632 ~55.771 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 634 ~6.282 ms, finishGL 46 / 4946 ~48.973 ms +XXX[102] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 5702 ~55.909 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 636 ~6.244 ms, finishGL 66 / 5013 ~49.147 ms +XXX[103] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5770 ~56.024 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 653 ~6.344 ms, finishGL 50 / 5063 ~49.161 ms +XXX[104] TO 17 ms, lFrame0 0 ms, lFrameX 52 / 5823 ~55.992 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 668 ~6.428 ms, finishGL 36 / 5100 ~49.043 ms +XXX[105] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 5906 ~56.252 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 11 / 679 ~6.472 ms, finishGL 71 / 5171 ~49.256 ms +XXX[106] TO 17 ms, lFrame0 0 ms, lFrameX 71 / 5977 ~56.391 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 12 / 691 ~6.527 ms, finishGL 58 / 5230 ~49.341 ms +XXX[107] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 6038 ~56.436 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 699 ~6.533 ms, finishGL 53 / 5283 ~49.381 ms +XXX[108] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 6114 ~56.613 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 11 / 710 ~6.582 ms, finishGL 63 / 5346 ~49.508 ms +XXX[109] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6181 ~56.713 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 713 ~6.549 ms, finishGL 64 / 5410 ~49.641 ms +XXX[110] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6248 ~56.803 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 715 ~6.507 ms, finishGL 64 / 5475 ~49.774 ms +XXX[111] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6314 ~56.885 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 717 ~6.464 ms, finishGL 63 / 5538 ~49.9 ms +XXX[112] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6381 ~56.976 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 719 ~6.427 ms, finishGL 64 / 5603 ~50.028 ms +XXX[113] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6448 ~57.067 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 721 ~6.386 ms, finishGL 65 / 5668 ~50.161 ms +XXX[114] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6514 ~57.146 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 722 ~6.341 ms, finishGL 64 / 5732 ~50.285 ms +XXX[115] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6582 ~57.239 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 724 ~6.298 ms, finishGL 66 / 5798 ~50.422 ms +XXX[116] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 6667 ~57.476 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 740 ~6.387 ms, finishGL 67 / 5866 ~50.57 ms +XXX[117] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 6749 ~57.69 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 756 ~6.462 ms, finishGL 66 / 5933 ~50.71 ms +XXX[118] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 6833 ~57.911 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 771 ~6.54 ms, finishGL 67 / 6000 ~50.852 ms +XXX[119] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 6917 ~58.13 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 786 ~6.613 ms, finishGL 68 / 6069 ~51.0 ms +XXX[120] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7001 ~58.341 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 801 ~6.677 ms, finishGL 68 / 6137 ~51.147 ms +XXX[121] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7084 ~58.552 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 815 ~6.738 ms, finishGL 69 / 6206 ~51.297 ms +XXX[122] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 7170 ~58.774 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 828 ~6.792 ms, finishGL 71 / 6278 ~51.465 ms +XXX[123] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 7255 ~58.988 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 839 ~6.825 ms, finishGL 73 / 6352 ~51.647 ms +XXX[124] TO 17 ms, lFrame0 1 ms, lFrameX 75 / 7331 ~59.122 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 847 ~6.832 ms, finishGL 66 / 6418 ~51.763 ms +XXX[125] TO 17 ms, lFrame0 0 ms, lFrameX 93 / 7424 ~59.396 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 864 ~6.912 ms, finishGL 76 / 6494 ~51.958 ms +XXX[126] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7508 ~59.588 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 870 ~6.907 ms, finishGL 76 / 6571 ~52.154 ms +XXX[127] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7591 ~59.773 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 876 ~6.9 ms, finishGL 76 / 6648 ~52.347 ms +2013-06-17 02:51:40.860 java[62528:5f07] Persistent UI failed to open file file://localhost/Users/jogamp/Library/Saved%20Application%20State/com.apple.javajdk16.cmd.savedState/window_1.data: Operation not permitted (1) +XXX[128] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 7671 ~59.93 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 882 ~6.892 ms, finishGL 73 / 6721 ~52.512 ms +XXX[129] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 7751 ~60.091 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 891 ~6.911 ms, finishGL 70 / 6792 ~52.655 ms +XXX[130] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 7834 ~60.261 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 11 / 903 ~6.948 ms, finishGL 70 / 6862 ~52.788 ms +XXX[131] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 7915 ~60.424 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 12 / 916 ~6.993 ms, finishGL 68 / 6930 ~52.907 ms +XXX[132] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 7997 ~60.583 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 930 ~7.048 ms, finishGL 66 / 6997 ~53.011 ms +XXX[133] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8079 ~60.751 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 946 ~7.116 ms, finishGL 66 / 7063 ~53.112 ms +XXX[134] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8162 ~60.912 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 963 ~7.187 ms, finishGL 65 / 7129 ~53.202 ms +XXX[135] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 8245 ~61.075 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 963 ~7.137 ms, finishGL 82 / 7211 ~53.415 ms +XXX[136] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8328 ~61.236 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 965 ~7.096 ms, finishGL 80 / 7292 ~53.618 ms +XXX[137] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 8393 ~61.266 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 966 ~7.051 ms, finishGL 63 / 7355 ~53.693 ms +XXX[138] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 8460 ~61.31 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 968 ~7.015 ms, finishGL 64 / 7420 ~53.774 ms +XXX[139] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8526 ~61.345 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 969 ~6.972 ms, finishGL 64 / 7485 ~53.851 ms +FrameCount: 240 - FrameRate: 13.0 +XXX[140] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8593 ~61.38 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 970 ~6.932 ms, finishGL 64 / 7549 ~53.926 ms +XXX[141] TO 17 ms, lFrame0 4 ms, lFrameX 69 / 8662 ~61.435 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 985 ~6.989 ms, finishGL 49 / 7599 ~53.894 ms +XXX[142] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 8742 ~61.566 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 1001 ~7.05 ms, finishGL 63 / 7663 ~53.965 ms +XXX[143] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8808 ~61.599 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1003 ~7.015 ms, finishGL 63 / 7726 ~54.032 ms +XXX[144] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 8874 ~61.628 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1005 ~6.983 ms, finishGL 62 / 7789 ~54.094 ms +XXX[145] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8940 ~61.659 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1008 ~6.955 ms, finishGL 62 / 7852 ~54.153 ms +XXX[146] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9006 ~61.69 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1011 ~6.931 ms, finishGL 62 / 7914 ~54.209 ms +XXX[147] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9073 ~61.726 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1015 ~6.909 ms, finishGL 62 / 7977 ~54.267 ms +XXX[148] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9139 ~61.755 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1019 ~6.89 ms, finishGL 61 / 8038 ~54.316 ms +XXX[149] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9206 ~61.787 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1024 ~6.874 ms, finishGL 61 / 8100 ~54.364 ms +XXX[150] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9272 ~61.818 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1027 ~6.852 ms, finishGL 62 / 8162 ~54.416 ms +XXX[151] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9339 ~61.85 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1031 ~6.831 ms, finishGL 62 / 8225 ~54.47 ms +XXX[152] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9405 ~61.878 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1035 ~6.81 ms, finishGL 62 / 8287 ~54.52 ms +XXX[153] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 9472 ~61.912 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1039 ~6.791 ms, finishGL 62 / 8349 ~54.573 ms +XXX[154] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9538 ~61.939 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1042 ~6.769 ms, finishGL 62 / 8412 ~54.623 ms +XXX[155] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 9606 ~61.974 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1046 ~6.748 ms, finishGL 63 / 8475 ~54.679 ms +XXX[156] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9672 ~62.0 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1048 ~6.723 ms, finishGL 62 / 8538 ~54.731 ms +XXX[157] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9738 ~62.028 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1052 ~6.701 ms, finishGL 62 / 8600 ~54.782 ms +XXX[158] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9804 ~62.054 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1055 ~6.679 ms, finishGL 62 / 8663 ~54.83 ms +XXX[159] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9870 ~62.08 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1058 ~6.66 ms, finishGL 62 / 8725 ~54.875 ms +XXX[160] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9936 ~62.103 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1062 ~6.643 ms, finishGL 61 / 8786 ~54.915 ms +XXX[161] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10002 ~62.127 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1067 ~6.63 ms, finishGL 60 / 8847 ~54.952 ms +XXX[162] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10068 ~62.152 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1072 ~6.622 ms, finishGL 60 / 8907 ~54.985 ms +XXX[163] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10135 ~62.178 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1078 ~6.616 ms, finishGL 60 / 8968 ~55.018 ms +XXX[164] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 10200 ~62.2 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1084 ~6.61 ms, finishGL 59 / 9027 ~55.047 ms +XXX[165] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10267 ~62.228 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 1090 ~6.61 ms, finishGL 59 / 9087 ~55.076 ms +XXX[166] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10334 ~62.253 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1096 ~6.606 ms, finishGL 59 / 9147 ~55.105 ms +XXX[167] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 10402 ~62.287 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 1102 ~6.603 ms, finishGL 61 / 9208 ~55.143 ms +XXX[168] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 10467 ~62.303 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1106 ~6.588 ms, finishGL 60 / 9268 ~55.172 ms +XXX[169] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10534 ~62.331 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1112 ~6.584 ms, finishGL 60 / 9329 ~55.204 ms +XXX[170] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10600 ~62.354 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1118 ~6.577 ms, finishGL 60 / 9389 ~55.234 ms +XXX[171] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10667 ~62.382 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1123 ~6.572 ms, finishGL 60 / 9450 ~55.267 ms +XXX[172] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10734 ~62.408 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1129 ~6.564 ms, finishGL 61 / 9511 ~55.301 ms +XXX[173] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10801 ~62.435 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1133 ~6.554 ms, finishGL 61 / 9573 ~55.339 ms +XXX[174] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 10867 ~62.455 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1138 ~6.541 ms, finishGL 61 / 9634 ~55.373 ms +XXX[175] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10934 ~62.48 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1143 ~6.531 ms, finishGL 61 / 9696 ~55.407 ms +XXX[176] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11000 ~62.501 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1147 ~6.519 ms, finishGL 61 / 9757 ~55.44 ms +XXX[177] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11067 ~62.529 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1152 ~6.509 ms, finishGL 62 / 9819 ~55.479 ms +XXX[178] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11135 ~62.559 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1155 ~6.494 ms, finishGL 63 / 9883 ~55.525 ms +XXX[179] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11203 ~62.588 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1158 ~6.471 ms, finishGL 64 / 9948 ~55.577 ms +XXX[180] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11270 ~62.613 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 1159 ~6.44 ms, finishGL 65 / 10014 ~55.633 ms +XXX[181] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 11354 ~62.732 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 1159 ~6.408 ms, finishGL 82 / 10097 ~55.784 ms +XXX[182] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 11438 ~62.849 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 1176 ~6.462 ms, finishGL 67 / 10164 ~55.848 ms +XXX[183] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 11523 ~62.97 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 1191 ~6.511 ms, finishGL 69 / 10233 ~55.92 ms +XXX[184] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 11607 ~63.082 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 1204 ~6.548 ms, finishGL 69 / 10302 ~55.994 ms +XXX[185] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 11694 ~63.211 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 1218 ~6.583 ms, finishGL 73 / 10376 ~56.088 ms +XXX[186] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 11780 ~63.334 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 1227 ~6.598 ms, finishGL 76 / 10452 ~56.197 ms +XXX[187] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 11865 ~63.452 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 1233 ~6.598 ms, finishGL 78 / 10530 ~56.315 ms +XXX[188] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 11950 ~63.565 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1238 ~6.585 ms, finishGL 80 / 10611 ~56.441 ms +XXX[189] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12034 ~63.673 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1240 ~6.564 ms, finishGL 80 / 10691 ~56.57 ms +XXX[190] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 12118 ~63.782 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1242 ~6.539 ms, finishGL 82 / 10774 ~56.705 ms +XXX[191] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 12217 ~63.968 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 1242 ~6.507 ms, finishGL 98 / 10872 ~56.922 ms +XXX[192] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12301 ~64.07 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1244 ~6.48 ms, finishGL 81 / 10953 ~57.051 ms +XXX[193] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 12383 ~64.163 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 1245 ~6.451 ms, finishGL 80 / 11034 ~57.174 ms +XXX[194] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 12468 ~64.271 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1247 ~6.428 ms, finishGL 82 / 11117 ~57.305 ms +XXX[195] TO 17 ms, lFrame0 0 ms, lFrameX 97 / 12566 ~64.441 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 17 / 1264 ~6.482 ms, finishGL 80 / 11197 ~57.422 ms +XXX[196] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 12647 ~64.529 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1266 ~6.461 ms, finishGL 78 / 11276 ~57.531 ms +XXX[197] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 12730 ~64.619 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1270 ~6.446 ms, finishGL 77 / 11354 ~57.634 ms +XXX[198] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12813 ~64.715 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1274 ~6.438 ms, finishGL 78 / 11432 ~57.738 ms +XXX[199] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 12896 ~64.806 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1279 ~6.428 ms, finishGL 77 / 11510 ~57.84 ms +XXX[200] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12979 ~64.899 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1284 ~6.42 ms, finishGL 78 / 11588 ~57.942 ms +XXX[201] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13063 ~64.99 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1288 ~6.411 ms, finishGL 78 / 11666 ~58.043 ms +XXX[202] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13145 ~65.079 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1293 ~6.401 ms, finishGL 78 / 11744 ~58.141 ms +XXX[203] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13229 ~65.167 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1297 ~6.392 ms, finishGL 77 / 11822 ~58.239 ms +XXX[204] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13311 ~65.251 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1302 ~6.384 ms, finishGL 77 / 11899 ~58.331 ms +XXX[205] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13393 ~65.332 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1308 ~6.381 ms, finishGL 75 / 11975 ~58.416 ms +XXX[206] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13475 ~65.414 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 1315 ~6.384 ms, finishGL 74 / 12050 ~58.495 ms +XXX[207] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13557 ~65.494 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 1323 ~6.392 ms, finishGL 73 / 12123 ~58.567 ms +XXX[208] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13639 ~65.572 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 1332 ~6.405 ms, finishGL 72 / 12195 ~58.633 ms +XXX[209] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13720 ~65.647 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 1343 ~6.426 ms, finishGL 69 / 12265 ~58.687 ms +XXX[210] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13802 ~65.725 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 12 / 1355 ~6.455 ms, finishGL 69 / 12334 ~58.736 ms +XXX[211] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13884 ~65.801 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 1369 ~6.489 ms, finishGL 67 / 12402 ~58.779 ms +XXX[212] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13965 ~65.875 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 1384 ~6.529 ms, finishGL 65 / 12468 ~58.812 ms +XXX[213] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 14047 ~65.952 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 1400 ~6.577 ms, finishGL 65 / 12533 ~58.842 ms +XXX[214] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 14113 ~65.949 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 1401 ~6.55 ms, finishGL 63 / 12597 ~58.866 ms +XXX[215] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 14180 ~65.957 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1403 ~6.529 ms, finishGL 65 / 12662 ~58.896 ms +XXX[216] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 14248 ~65.965 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 1404 ~6.503 ms, finishGL 66 / 12729 ~58.93 ms +XXX[217] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 14333 ~66.05 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 1421 ~6.548 ms, finishGL 67 / 12796 ~58.97 ms +XXX[218] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 14418 ~66.142 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 1436 ~6.587 ms, finishGL 70 / 12867 ~59.023 ms +XXX[219] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 14504 ~66.23 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 12 / 1448 ~6.613 ms, finishGL 72 / 12939 ~59.086 ms +XXX[220] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 14590 ~66.319 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 1458 ~6.628 ms, finishGL 75 / 13015 ~59.159 ms +XXX[221] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 14675 ~66.405 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 1465 ~6.631 ms, finishGL 77 / 13092 ~59.243 ms +XXX[222] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 14759 ~66.484 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1471 ~6.626 ms, finishGL 77 / 13170 ~59.328 ms +XXX[223] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 14842 ~66.559 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1475 ~6.616 ms, finishGL 78 / 13249 ~59.413 ms +XXX[224] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 14925 ~66.63 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1479 ~6.605 ms, finishGL 77 / 13326 ~59.494 ms +XXX[225] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15008 ~66.702 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1484 ~6.598 ms, finishGL 77 / 13404 ~59.574 ms +XXX[226] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15090 ~66.773 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1489 ~6.592 ms, finishGL 76 / 13481 ~59.651 ms +XXX[227] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15173 ~66.843 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1495 ~6.589 ms, finishGL 76 / 13557 ~59.724 ms +XXX[228] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15255 ~66.911 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 1502 ~6.587 ms, finishGL 75 / 13633 ~59.794 ms +XXX[229] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15338 ~66.978 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 1509 ~6.59 ms, finishGL 74 / 13707 ~59.859 ms +XXX[230] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15420 ~67.045 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 8 / 1517 ~6.596 ms, finishGL 73 / 13781 ~59.92 ms +XXX[231] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15501 ~67.107 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 8 / 1526 ~6.606 ms, finishGL 72 / 13853 ~59.972 ms +XXX[232] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15583 ~67.17 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 1536 ~6.624 ms, finishGL 70 / 13924 ~60.018 ms +XXX[233] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15665 ~67.233 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 12 / 1548 ~6.647 ms, finishGL 69 / 13993 ~60.058 ms +XXX[234] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15746 ~67.294 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 1562 ~6.676 ms, finishGL 67 / 14061 ~60.09 ms +XXX[235] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15828 ~67.357 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 1577 ~6.713 ms, finishGL 66 / 14127 ~60.116 ms +XXX[236] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15910 ~67.415 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 1593 ~6.753 ms, finishGL 64 / 14191 ~60.134 ms +XXX[237] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 15976 ~67.411 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1595 ~6.731 ms, finishGL 64 / 14256 ~60.152 ms +XXX[238] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16043 ~67.409 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1597 ~6.71 ms, finishGL 64 / 14321 ~60.172 ms +XXX[239] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 16109 ~67.402 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1598 ~6.686 ms, finishGL 64 / 14385 ~60.189 ms +XXX[240] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16176 ~67.4 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1599 ~6.666 ms, finishGL 64 / 14450 ~60.208 ms +XXX[241] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 16241 ~67.394 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1601 ~6.643 ms, finishGL 64 / 14514 ~60.224 ms +XXX[242] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16308 ~67.389 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1603 ~6.624 ms, finishGL 63 / 14577 ~60.239 ms +XXX[243] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16374 ~67.384 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1605 ~6.606 ms, finishGL 63 / 14641 ~60.252 ms +XXX[244] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 16440 ~67.377 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1607 ~6.589 ms, finishGL 62 / 14704 ~60.262 ms +XXX[245] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16507 ~67.376 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1611 ~6.575 ms, finishGL 63 / 14767 ~60.275 ms +XXX[246] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16573 ~67.372 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1613 ~6.559 ms, finishGL 63 / 14830 ~60.287 ms +XXX[247] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16640 ~67.371 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1616 ~6.543 ms, finishGL 63 / 14894 ~60.302 ms +XXX[248] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16708 ~67.372 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1618 ~6.525 ms, finishGL 65 / 14959 ~60.321 ms +XXX[249] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16776 ~67.373 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 1619 ~6.502 ms, finishGL 66 / 15026 ~60.345 ms +XXX[250] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 16860 ~67.442 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 1635 ~6.542 ms, finishGL 67 / 15093 ~60.374 ms +XXX[251] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 16945 ~67.513 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 1650 ~6.576 ms, finishGL 69 / 15163 ~60.411 ms +XXX[252] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17030 ~67.582 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 1663 ~6.602 ms, finishGL 71 / 15234 ~60.455 ms +XXX[253] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 17116 ~67.652 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 11 / 1675 ~6.621 ms, finishGL 73 / 15308 ~60.507 ms +XXX[254] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17200 ~67.719 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 1684 ~6.63 ms, finishGL 74 / 15383 ~60.563 ms +XXX[255] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17285 ~67.785 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 1691 ~6.635 ms, finishGL 76 / 15459 ~60.625 ms +XXX[256] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17369 ~67.85 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 1698 ~6.634 ms, finishGL 77 / 15537 ~60.692 ms +XXX[257] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17454 ~67.916 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1703 ~6.629 ms, finishGL 79 / 15616 ~60.763 ms +XXX[258] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17538 ~67.977 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1706 ~6.615 ms, finishGL 79 / 15696 ~60.837 ms +XXX[259] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17621 ~68.038 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1709 ~6.6 ms, finishGL 80 / 15776 ~60.913 ms +FrameCount: 360 - FrameRate: 15.0 +XXX[260] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 17704 ~68.095 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1712 ~6.587 ms, finishGL 79 / 15855 ~60.984 ms +XXX[261] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17787 ~68.153 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1715 ~6.571 ms, finishGL 80 / 15936 ~61.057 ms +XXX[262] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17871 ~68.21 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1717 ~6.556 ms, finishGL 79 / 16016 ~61.129 ms +XXX[263] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 17953 ~68.264 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1720 ~6.541 ms, finishGL 79 / 16095 ~61.199 ms +XXX[264] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18035 ~68.318 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1723 ~6.528 ms, finishGL 78 / 16174 ~61.265 ms +XXX[265] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18118 ~68.371 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1727 ~6.519 ms, finishGL 78 / 16252 ~61.329 ms +XXX[266] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18201 ~68.425 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 4 / 1732 ~6.512 ms, finishGL 77 / 16329 ~61.39 ms +XXX[267] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18283 ~68.478 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1737 ~6.507 ms, finishGL 77 / 16406 ~61.448 ms +XXX[268] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18366 ~68.53 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1743 ~6.504 ms, finishGL 75 / 16482 ~61.502 ms +XXX[269] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18448 ~68.582 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 1750 ~6.505 ms, finishGL 75 / 16558 ~61.554 ms +XXX[270] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 18529 ~68.627 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 1757 ~6.508 ms, finishGL 73 / 16631 ~61.597 ms +XXX[271] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18611 ~68.677 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 9 / 1766 ~6.519 ms, finishGL 71 / 16703 ~61.635 ms +XXX[272] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18694 ~68.728 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 1777 ~6.534 ms, finishGL 71 / 16774 ~61.672 ms +XXX[273] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 18775 ~68.775 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 11 / 1788 ~6.551 ms, finishGL 69 / 16844 ~61.701 ms +XXX[274] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18858 ~68.826 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 1801 ~6.575 ms, finishGL 69 / 16913 ~61.729 ms +XXX[275] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18940 ~68.875 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 1814 ~6.599 ms, finishGL 68 / 16982 ~61.755 ms +XXX[276] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19023 ~68.924 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 1828 ~6.626 ms, finishGL 68 / 17050 ~61.777 ms +XXX[277] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19105 ~68.973 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 1843 ~6.655 ms, finishGL 67 / 17117 ~61.797 ms +XXX[278] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19187 ~69.021 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 1858 ~6.686 ms, finishGL 66 / 17184 ~61.814 ms +XXX[279] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19270 ~69.069 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 16 / 1875 ~6.721 ms, finishGL 65 / 17249 ~61.827 ms +XXX[280] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19352 ~69.116 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 1875 ~6.699 ms, finishGL 81 / 17331 ~61.896 ms +XXX[281] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 19418 ~69.106 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 0 / 1876 ~6.679 ms, finishGL 64 / 17395 ~61.906 ms +XXX[282] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19484 ~69.094 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 1 / 1878 ~6.66 ms, finishGL 63 / 17459 ~61.913 ms +XXX[283] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19549 ~69.08 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 2 / 1880 ~6.645 ms, finishGL 62 / 17522 ~61.915 ms +XXX[284] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19615 ~69.067 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 3 / 1883 ~6.633 ms, finishGL 61 / 17583 ~61.914 ms +XXX[285] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19680 ~69.055 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1889 ~6.629 ms, finishGL 59 / 17643 ~61.906 ms +XXX[286] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19746 ~69.042 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 5 / 1894 ~6.625 ms, finishGL 59 / 17702 ~61.897 ms +XXX[287] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19811 ~69.03 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 6 / 1901 ~6.625 ms, finishGL 58 / 17761 ~61.886 ms +XXX[288] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19877 ~69.018 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 7 / 1908 ~6.627 ms, finishGL 57 / 17819 ~61.872 ms +XXX[289] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 19942 ~69.003 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 8 / 1917 ~6.634 ms, finishGL 55 / 17874 ~61.85 ms +XXX[290] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20007 ~68.992 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 1927 ~6.646 ms, finishGL 55 / 17929 ~61.827 ms +XXX[291] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20073 ~68.979 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 10 / 1938 ~6.661 ms, finishGL 53 / 17983 ~61.8 ms +XXX[292] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20138 ~68.968 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 12 / 1950 ~6.679 ms, finishGL 53 / 18037 ~61.771 ms +XXX[293] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20204 ~68.958 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 12 / 1962 ~6.699 ms, finishGL 52 / 18090 ~61.741 ms +XXX[294] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20270 ~68.946 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 13 / 1975 ~6.72 ms, finishGL 51 / 18142 ~61.707 ms +XXX[295] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20336 ~68.936 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 1990 ~6.746 ms, finishGL 51 / 18193 ~61.672 ms +XXX[296] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20402 ~68.926 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 2004 ~6.773 ms, finishGL 50 / 18244 ~61.636 ms +XXX[297] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20468 ~68.916 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 14 / 2019 ~6.8 ms, finishGL 50 / 18294 ~61.599 ms +XXX[298] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20534 ~68.909 ms, flushGL 0 / 0 ~0.0030 ms, waitGL 15 / 2035 ~6.829 ms, finishGL 50 / 18345 ~61.562 ms +XXX[299] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 20602 ~68.903 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 2050 ~6.859 ms, finishGL 51 / 18396 ~61.527 ms +XXX[300] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20669 ~68.896 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 14 / 2065 ~6.885 ms, finishGL 51 / 18448 ~61.495 ms +XXX[301] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 20736 ~68.892 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 14 / 2079 ~6.909 ms, finishGL 53 / 18501 ~61.466 ms +XXX[302] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 20804 ~68.889 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 12 / 2092 ~6.929 ms, finishGL 54 / 18556 ~61.444 ms +XXX[303] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 20873 ~68.889 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 2104 ~6.944 ms, finishGL 56 / 18612 ~61.428 ms +XXX[304] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 20942 ~68.888 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 2114 ~6.957 ms, finishGL 57 / 18670 ~61.415 ms +XXX[305] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 21012 ~68.892 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2121 ~6.957 ms, finishGL 62 / 18733 ~61.419 ms +XXX[306] TO 17 ms, lFrame0 0 ms, lFrameX 71 / 21083 ~68.9 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 2125 ~6.944 ms, finishGL 67 / 18800 ~61.439 ms +XXX[307] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 21171 ~68.963 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 2140 ~6.971 ms, finishGL 72 / 18873 ~61.475 ms +XXX[308] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 21258 ~69.02 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 2150 ~6.981 ms, finishGL 76 / 18949 ~61.523 ms +XXX[309] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 21343 ~69.073 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2157 ~6.98 ms, finishGL 78 / 19027 ~61.577 ms +XXX[310] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 21428 ~69.125 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2161 ~6.972 ms, finishGL 80 / 19107 ~61.637 ms +XXX[311] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 21512 ~69.17 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2163 ~6.957 ms, finishGL 80 / 19187 ~61.697 ms +XXX[312] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 21594 ~69.214 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2166 ~6.943 ms, finishGL 79 / 19267 ~61.755 ms +XXX[313] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 21678 ~69.259 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2169 ~6.93 ms, finishGL 80 / 19347 ~61.814 ms +XXX[314] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 21762 ~69.305 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2171 ~6.914 ms, finishGL 80 / 19428 ~61.874 ms +XXX[315] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 21846 ~69.353 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2173 ~6.899 ms, finishGL 81 / 19510 ~61.937 ms +XXX[316] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 21930 ~69.4 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 2174 ~6.879 ms, finishGL 82 / 19593 ~62.003 ms +XXX[317] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 22030 ~69.497 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 16 / 2190 ~6.91 ms, finishGL 83 / 19676 ~62.07 ms +XXX[318] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 22129 ~69.589 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 16 / 2206 ~6.939 ms, finishGL 81 / 19758 ~62.133 ms +XXX[319] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 22228 ~69.682 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 2207 ~6.92 ms, finishGL 98 / 19856 ~62.245 ms +XXX[320] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22311 ~69.722 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 2208 ~6.902 ms, finishGL 81 / 19937 ~62.304 ms +XXX[321] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22394 ~69.764 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 1 / 2210 ~6.885 ms, finishGL 80 / 20018 ~62.362 ms +XXX[322] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22476 ~69.803 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 1 / 2212 ~6.87 ms, finishGL 80 / 20098 ~62.417 ms +XXX[323] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22559 ~69.844 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2214 ~6.857 ms, finishGL 80 / 20178 ~62.472 ms +XXX[324] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22642 ~69.885 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2217 ~6.844 ms, finishGL 79 / 20258 ~62.525 ms +XXX[325] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22726 ~69.926 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2220 ~6.831 ms, finishGL 79 / 20338 ~62.579 ms +XXX[326] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22809 ~69.968 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2223 ~6.819 ms, finishGL 80 / 20418 ~62.633 ms +XXX[327] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22892 ~70.008 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2225 ~6.805 ms, finishGL 80 / 20498 ~62.687 ms +XXX[328] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22976 ~70.049 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2227 ~6.791 ms, finishGL 80 / 20579 ~62.742 ms +XXX[329] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 23057 ~70.084 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2229 ~6.778 ms, finishGL 78 / 20658 ~62.791 ms +XXX[330] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 23142 ~70.129 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 2233 ~6.768 ms, finishGL 80 / 20739 ~62.846 ms +XXX[331] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 23226 ~70.171 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 1 / 2235 ~6.753 ms, finishGL 81 / 20821 ~62.903 ms +XXX[332] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 23308 ~70.207 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 2236 ~6.735 ms, finishGL 80 / 20901 ~62.957 ms +XXX[333] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23392 ~70.248 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2238 ~6.721 ms, finishGL 81 / 20983 ~63.012 ms +XXX[334] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23475 ~70.285 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 1 / 2239 ~6.705 ms, finishGL 80 / 21063 ~63.065 ms +XXX[335] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23558 ~70.323 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 1 / 2241 ~6.69 ms, finishGL 80 / 21144 ~63.117 ms +XXX[336] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23640 ~70.359 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2243 ~6.676 ms, finishGL 79 / 21224 ~63.167 ms +XXX[337] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 23721 ~70.391 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 2246 ~6.665 ms, finishGL 77 / 21301 ~63.21 ms +XXX[338] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23804 ~70.427 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2251 ~6.66 ms, finishGL 77 / 21379 ~63.251 ms +XXX[339] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23887 ~70.465 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2257 ~6.658 ms, finishGL 76 / 21456 ~63.292 ms +XXX[340] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23971 ~70.503 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2262 ~6.654 ms, finishGL 77 / 21533 ~63.333 ms +XXX[341] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24053 ~70.538 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2267 ~6.648 ms, finishGL 77 / 21610 ~63.374 ms +XXX[342] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24136 ~70.574 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2272 ~6.646 ms, finishGL 76 / 21687 ~63.412 ms +XXX[343] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24219 ~70.611 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2279 ~6.644 ms, finishGL 76 / 21763 ~63.451 ms +XXX[344] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24302 ~70.646 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2284 ~6.642 ms, finishGL 76 / 21840 ~63.488 ms +XXX[345] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24385 ~70.683 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2291 ~6.641 ms, finishGL 76 / 21916 ~63.526 ms +XXX[346] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24468 ~70.718 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2297 ~6.64 ms, finishGL 76 / 21992 ~63.562 ms +XXX[347] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24551 ~70.754 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2304 ~6.641 ms, finishGL 75 / 22068 ~63.598 ms +XXX[348] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24635 ~70.791 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2311 ~6.641 ms, finishGL 76 / 22145 ~63.635 ms +XXX[349] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24718 ~70.826 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2317 ~6.64 ms, finishGL 76 / 22221 ~63.67 ms +XXX[350] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24801 ~70.861 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2323 ~6.639 ms, finishGL 76 / 22297 ~63.706 ms +XXX[351] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24884 ~70.896 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2330 ~6.639 ms, finishGL 76 / 22373 ~63.743 ms +XXX[352] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24967 ~70.931 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2336 ~6.637 ms, finishGL 76 / 22450 ~63.779 ms +XXX[353] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25051 ~70.967 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2342 ~6.636 ms, finishGL 76 / 22527 ~63.815 ms +XXX[354] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25134 ~71.001 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2348 ~6.634 ms, finishGL 76 / 22603 ~63.852 ms +XXX[355] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25217 ~71.035 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2354 ~6.633 ms, finishGL 76 / 22680 ~63.887 ms +XXX[356] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25300 ~71.068 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2360 ~6.631 ms, finishGL 76 / 22756 ~63.922 ms +XXX[357] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25383 ~71.102 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2367 ~6.631 ms, finishGL 76 / 22832 ~63.957 ms +XXX[358] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25466 ~71.136 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2373 ~6.63 ms, finishGL 76 / 22909 ~63.992 ms +XXX[359] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 25550 ~71.171 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2380 ~6.629 ms, finishGL 77 / 22986 ~64.028 ms +XXX[360] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25633 ~71.205 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2385 ~6.627 ms, finishGL 76 / 23063 ~64.064 ms +XXX[361] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25716 ~71.236 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2391 ~6.624 ms, finishGL 76 / 23139 ~64.099 ms +XXX[362] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 25800 ~71.271 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2397 ~6.622 ms, finishGL 77 / 23217 ~64.136 ms +XXX[363] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25884 ~71.306 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2402 ~6.618 ms, finishGL 78 / 23295 ~64.175 ms +XXX[364] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25967 ~71.339 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2406 ~6.612 ms, finishGL 78 / 23374 ~64.214 ms +XXX[365] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26051 ~71.372 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2411 ~6.606 ms, finishGL 78 / 23452 ~64.253 ms +XXX[366] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26133 ~71.404 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2415 ~6.599 ms, finishGL 77 / 23530 ~64.291 ms +XXX[367] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26217 ~71.436 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2420 ~6.595 ms, finishGL 78 / 23608 ~64.329 ms +XXX[368] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26300 ~71.468 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2424 ~6.588 ms, finishGL 78 / 23687 ~64.367 ms +XXX[369] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26383 ~71.499 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2429 ~6.582 ms, finishGL 77 / 23765 ~64.404 ms +XXX[370] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26467 ~71.532 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2433 ~6.577 ms, finishGL 78 / 23843 ~64.442 ms +XXX[371] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26549 ~71.561 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2438 ~6.571 ms, finishGL 77 / 23921 ~64.478 ms +XXX[372] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26631 ~71.59 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2442 ~6.566 ms, finishGL 76 / 23998 ~64.511 ms +XXX[373] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26714 ~71.62 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2448 ~6.563 ms, finishGL 76 / 24074 ~64.544 ms +XXX[374] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26797 ~71.651 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2454 ~6.562 ms, finishGL 76 / 24151 ~64.576 ms +XXX[375] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 26896 ~71.724 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2460 ~6.561 ms, finishGL 92 / 24244 ~64.651 ms +XXX[376] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26979 ~71.755 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2467 ~6.562 ms, finishGL 75 / 24320 ~64.681 ms +XXX[377] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27062 ~71.783 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2474 ~6.562 ms, finishGL 75 / 24395 ~64.709 ms +XXX[378] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27145 ~71.813 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2481 ~6.564 ms, finishGL 75 / 24470 ~64.737 ms +XXX[379] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27227 ~71.841 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2488 ~6.566 ms, finishGL 74 / 24545 ~64.763 ms +FrameCount: 480 - FrameRate: 12.0 +XXX[380] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27310 ~71.869 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2496 ~6.57 ms, finishGL 74 / 24619 ~64.787 ms +XXX[381] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27393 ~71.898 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2505 ~6.575 ms, finishGL 73 / 24692 ~64.81 ms +XXX[382] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27475 ~71.926 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 2514 ~6.582 ms, finishGL 73 / 24765 ~64.832 ms +XXX[383] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27558 ~71.955 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 2524 ~6.59 ms, finishGL 72 / 24838 ~64.853 ms +XXX[384] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27642 ~71.985 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 2533 ~6.598 ms, finishGL 73 / 24911 ~64.874 ms +XXX[385] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 27727 ~72.019 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 2543 ~6.606 ms, finishGL 75 / 24986 ~64.901 ms +XXX[386] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27811 ~72.049 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2551 ~6.609 ms, finishGL 75 / 25062 ~64.929 ms +XXX[387] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27894 ~72.078 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2558 ~6.61 ms, finishGL 75 / 25138 ~64.957 ms +XXX[388] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27978 ~72.108 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2564 ~6.609 ms, finishGL 76 / 25215 ~64.987 ms +XXX[389] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 28063 ~72.142 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2570 ~6.608 ms, finishGL 78 / 25293 ~65.022 ms +XXX[390] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 28147 ~72.172 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2574 ~6.602 ms, finishGL 78 / 25372 ~65.056 ms +XXX[391] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28231 ~72.202 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 2578 ~6.594 ms, finishGL 79 / 25451 ~65.094 ms +XXX[392] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28314 ~72.23 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2581 ~6.584 ms, finishGL 80 / 25531 ~65.132 ms +XXX[393] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28397 ~72.258 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2583 ~6.574 ms, finishGL 79 / 25611 ~65.17 ms +XXX[394] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28480 ~72.285 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2586 ~6.565 ms, finishGL 79 / 25691 ~65.206 ms +XXX[395] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28563 ~72.313 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2589 ~6.556 ms, finishGL 79 / 25771 ~65.243 ms +XXX[396] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28646 ~72.339 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 2592 ~6.547 ms, finishGL 79 / 25850 ~65.279 ms +XXX[397] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28729 ~72.366 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 2596 ~6.539 ms, finishGL 79 / 25929 ~65.314 ms +XXX[398] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28812 ~72.393 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 2599 ~6.531 ms, finishGL 79 / 26008 ~65.348 ms +XXX[399] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28895 ~72.418 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 2603 ~6.524 ms, finishGL 78 / 26087 ~65.381 ms +XXX[400] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28977 ~72.444 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2607 ~6.518 ms, finishGL 78 / 26165 ~65.413 ms +XXX[401] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29059 ~72.468 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2612 ~6.514 ms, finishGL 76 / 26242 ~65.442 ms +XXX[402] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 29141 ~72.491 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 2617 ~6.512 ms, finishGL 75 / 26317 ~65.467 ms +XXX[403] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29224 ~72.517 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2625 ~6.513 ms, finishGL 75 / 26393 ~65.491 ms +XXX[404] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29307 ~72.542 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2632 ~6.516 ms, finishGL 74 / 26467 ~65.514 ms +XXX[405] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29390 ~72.568 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2640 ~6.519 ms, finishGL 74 / 26542 ~65.537 ms +XXX[406] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29473 ~72.594 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2648 ~6.522 ms, finishGL 74 / 26617 ~65.559 ms +XXX[407] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29555 ~72.618 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2656 ~6.527 ms, finishGL 73 / 26690 ~65.578 ms +XXX[408] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29638 ~72.644 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 2665 ~6.533 ms, finishGL 73 / 26764 ~65.598 ms +XXX[409] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29721 ~72.669 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2674 ~6.539 ms, finishGL 73 / 26837 ~65.618 ms +XXX[410] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29804 ~72.693 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 2683 ~6.546 ms, finishGL 72 / 26910 ~65.635 ms +XXX[411] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29887 ~72.719 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 2694 ~6.554 ms, finishGL 72 / 26983 ~65.653 ms +XXX[412] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29970 ~72.744 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 2703 ~6.561 ms, finishGL 73 / 27056 ~65.671 ms +XXX[413] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30052 ~72.767 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 2713 ~6.569 ms, finishGL 72 / 27128 ~65.686 ms +XXX[414] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30136 ~72.792 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 2723 ~6.578 ms, finishGL 72 / 27200 ~65.702 ms +XXX[415] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30219 ~72.817 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 2734 ~6.588 ms, finishGL 71 / 27272 ~65.717 ms +XXX[416] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30301 ~72.84 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 2745 ~6.599 ms, finishGL 71 / 27343 ~65.73 ms +XXX[417] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30384 ~72.865 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 2756 ~6.61 ms, finishGL 71 / 27415 ~65.743 ms +XXX[418] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30468 ~72.89 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 2767 ~6.621 ms, finishGL 71 / 27486 ~65.757 ms +XXX[419] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30551 ~72.914 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 2779 ~6.633 ms, finishGL 71 / 27557 ~65.77 ms +XXX[420] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 30635 ~72.941 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 2790 ~6.644 ms, finishGL 72 / 27630 ~65.786 ms +XXX[421] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 30720 ~72.969 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 2801 ~6.653 ms, finishGL 73 / 27703 ~65.805 ms +XXX[422] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30803 ~72.993 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2809 ~6.658 ms, finishGL 73 / 27777 ~65.824 ms +XXX[423] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 30883 ~73.011 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2818 ~6.663 ms, finishGL 71 / 27848 ~65.836 ms +XXX[424] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 30964 ~73.028 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 2830 ~6.675 ms, finishGL 68 / 27917 ~65.842 ms +XXX[425] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 31044 ~73.046 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 14 / 2844 ~6.693 ms, finishGL 65 / 27982 ~65.842 ms +XXX[426] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 31124 ~73.063 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 2844 ~6.678 ms, finishGL 79 / 28062 ~65.874 ms +XXX[427] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31189 ~73.044 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 2848 ~6.67 ms, finishGL 61 / 28123 ~65.863 ms +XXX[428] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31256 ~73.028 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2852 ~6.665 ms, finishGL 61 / 28185 ~65.852 ms +XXX[429] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31321 ~73.01 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 2857 ~6.66 ms, finishGL 59 / 28244 ~65.839 ms +XXX[430] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31387 ~72.994 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2863 ~6.659 ms, finishGL 59 / 28304 ~65.824 ms +XXX[431] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31454 ~72.979 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2869 ~6.658 ms, finishGL 59 / 28364 ~65.809 ms +XXX[432] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31519 ~72.962 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2876 ~6.658 ms, finishGL 58 / 28422 ~65.793 ms +XXX[433] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31586 ~72.947 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2883 ~6.659 ms, finishGL 58 / 28481 ~65.777 ms +XXX[434] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31651 ~72.93 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2890 ~6.661 ms, finishGL 57 / 28539 ~65.759 ms +XXX[435] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31718 ~72.915 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2899 ~6.664 ms, finishGL 57 / 28597 ~65.74 ms +XXX[436] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31784 ~72.899 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2907 ~6.668 ms, finishGL 57 / 28654 ~65.72 ms +XXX[437] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31850 ~72.884 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2916 ~6.673 ms, finishGL 57 / 28711 ~65.701 ms +XXX[438] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31917 ~72.871 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2925 ~6.678 ms, finishGL 57 / 28769 ~65.682 ms +XXX[439] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31984 ~72.857 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2934 ~6.683 ms, finishGL 57 / 28826 ~65.664 ms +XXX[440] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32050 ~72.843 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2942 ~6.686 ms, finishGL 57 / 28884 ~65.646 ms +XXX[441] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32117 ~72.829 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 2950 ~6.689 ms, finishGL 58 / 28942 ~65.63 ms +XXX[442] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32185 ~72.817 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 2957 ~6.692 ms, finishGL 59 / 29002 ~65.615 ms +XXX[443] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32251 ~72.803 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2964 ~6.692 ms, finishGL 59 / 29061 ~65.601 ms +XXX[444] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32318 ~72.788 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2971 ~6.692 ms, finishGL 59 / 29120 ~65.586 ms +XXX[445] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32385 ~72.776 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2978 ~6.692 ms, finishGL 60 / 29180 ~65.574 ms +XXX[446] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32451 ~72.761 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2984 ~6.691 ms, finishGL 59 / 29240 ~65.561 ms +XXX[447] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32518 ~72.747 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2990 ~6.69 ms, finishGL 59 / 29299 ~65.547 ms +XXX[448] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32585 ~72.734 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 2997 ~6.689 ms, finishGL 60 / 29359 ~65.535 ms +XXX[449] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32651 ~72.72 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3002 ~6.688 ms, finishGL 59 / 29419 ~65.523 ms +XXX[450] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32718 ~72.707 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3009 ~6.686 ms, finishGL 60 / 29480 ~65.511 ms +XXX[451] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32784 ~72.692 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3014 ~6.684 ms, finishGL 59 / 29540 ~65.499 ms +XXX[452] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32850 ~72.677 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3021 ~6.683 ms, finishGL 59 / 29599 ~65.484 ms +XXX[453] TO 17 ms, lFrame0 1 ms, lFrameX 65 / 32915 ~72.662 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3027 ~6.682 ms, finishGL 58 / 29657 ~65.469 ms +XXX[454] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32981 ~72.645 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 3034 ~6.684 ms, finishGL 57 / 29714 ~65.451 ms +XXX[455] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33047 ~72.63 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 3043 ~6.689 ms, finishGL 56 / 29771 ~65.431 ms +XXX[456] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33112 ~72.614 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 3053 ~6.695 ms, finishGL 55 / 29826 ~65.409 ms +XXX[457] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 33178 ~72.6 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 3063 ~6.704 ms, finishGL 54 / 29881 ~65.386 ms +XXX[458] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33243 ~72.584 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 3074 ~6.713 ms, finishGL 53 / 29935 ~65.361 ms +XXX[459] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33309 ~72.569 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 12 / 3087 ~6.725 ms, finishGL 53 / 29988 ~65.334 ms +XXX[460] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33375 ~72.554 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 13 / 3100 ~6.739 ms, finishGL 52 / 30040 ~65.306 ms +XXX[461] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33440 ~72.539 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 13 / 3113 ~6.754 ms, finishGL 51 / 30092 ~65.275 ms +XXX[462] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33506 ~72.524 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 14 / 3128 ~6.771 ms, finishGL 50 / 30142 ~65.244 ms +XXX[463] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33571 ~72.509 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 3143 ~6.79 ms, finishGL 49 / 30192 ~65.21 ms +XXX[464] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33637 ~72.494 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 16 / 3160 ~6.81 ms, finishGL 48 / 30241 ~65.174 ms +XXX[465] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33702 ~72.479 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 0 / 3161 ~6.798 ms, finishGL 64 / 30305 ~65.172 ms +XXX[466] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 33751 ~72.428 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 1 / 3162 ~6.786 ms, finishGL 46 / 30352 ~65.133 ms +XXX[467] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33801 ~72.379 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 3165 ~6.778 ms, finishGL 46 / 30398 ~65.092 ms +XXX[468] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 33850 ~72.329 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 3168 ~6.77 ms, finishGL 45 / 30443 ~65.05 ms +XXX[469] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33899 ~72.28 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 3172 ~6.763 ms, finishGL 45 / 30488 ~65.008 ms +XXX[470] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33948 ~72.231 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3176 ~6.758 ms, finishGL 44 / 30533 ~64.963 ms +XXX[471] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33998 ~72.182 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3181 ~6.755 ms, finishGL 43 / 30576 ~64.919 ms +XXX[472] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34047 ~72.134 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3187 ~6.752 ms, finishGL 43 / 30620 ~64.874 ms +XXX[473] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34096 ~72.086 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3192 ~6.75 ms, finishGL 43 / 30663 ~64.827 ms +XXX[474] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34145 ~72.036 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3199 ~6.749 ms, finishGL 41 / 30705 ~64.779 ms +XXX[475] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34194 ~71.988 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 3206 ~6.75 ms, finishGL 41 / 30746 ~64.729 ms +XXX[476] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34243 ~71.94 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 3214 ~6.753 ms, finishGL 40 / 30787 ~64.678 ms +XXX[477] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34292 ~71.892 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 3223 ~6.758 ms, finishGL 39 / 30826 ~64.626 ms +XXX[478] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34341 ~71.845 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 3233 ~6.763 ms, finishGL 39 / 30866 ~64.573 ms +XXX[479] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34390 ~71.797 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 3243 ~6.77 ms, finishGL 38 / 30904 ~64.518 ms +XXX[480] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34439 ~71.749 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 3254 ~6.779 ms, finishGL 37 / 30941 ~64.461 ms +XXX[481] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34488 ~71.702 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 3266 ~6.79 ms, finishGL 36 / 30978 ~64.404 ms +XXX[482] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34537 ~71.655 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 12 / 3278 ~6.802 ms, finishGL 36 / 31014 ~64.345 ms +XXX[483] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34586 ~71.608 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 13 / 3292 ~6.815 ms, finishGL 35 / 31049 ~64.285 ms +XXX[484] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34635 ~71.561 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 14 / 3306 ~6.831 ms, finishGL 34 / 31084 ~64.223 ms +XXX[485] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34685 ~71.516 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 3321 ~6.848 ms, finishGL 33 / 31117 ~64.16 ms +XXX[486] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34735 ~71.471 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 16 / 3337 ~6.867 ms, finishGL 33 / 31150 ~64.096 ms +XXX[487] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34784 ~71.426 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 3352 ~6.884 ms, finishGL 33 / 31184 ~64.033 ms +XXX[488] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34834 ~71.381 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 3368 ~6.902 ms, finishGL 33 / 31218 ~63.971 ms +XXX[489] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 34884 ~71.338 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 17 / 3385 ~6.924 ms, finishGL 32 / 31250 ~63.906 ms +XXX[490] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 34934 ~71.295 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 3401 ~6.941 ms, finishGL 34 / 31284 ~63.846 ms +XXX[491] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34984 ~71.251 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 3416 ~6.958 ms, finishGL 34 / 31318 ~63.785 ms +XXX[492] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35034 ~71.207 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 3431 ~6.974 ms, finishGL 34 / 31352 ~63.725 ms +XXX[493] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35083 ~71.163 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 3446 ~6.991 ms, finishGL 33 / 31386 ~63.664 ms +XXX[494] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 35134 ~71.123 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 15 / 3462 ~7.008 ms, finishGL 35 / 31422 ~63.607 ms +XXX[495] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35185 ~71.081 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 14 / 3476 ~7.023 ms, finishGL 35 / 31457 ~63.55 ms +XXX[496] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35235 ~71.039 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 13 / 3489 ~7.036 ms, finishGL 36 / 31494 ~63.496 ms +XXX[497] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35285 ~70.997 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 13 / 3503 ~7.048 ms, finishGL 36 / 31530 ~63.442 ms +XXX[498] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35336 ~70.956 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 12 / 3515 ~7.059 ms, finishGL 37 / 31568 ~63.389 ms +XXX[499] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35386 ~70.914 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 12 / 3527 ~7.069 ms, finishGL 37 / 31605 ~63.338 ms +FrameCount: 600 - FrameRate: 19.0 +XXX[500] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35436 ~70.873 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 3538 ~7.077 ms, finishGL 38 / 31644 ~63.288 ms +XXX[501] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35486 ~70.831 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 3549 ~7.085 ms, finishGL 38 / 31683 ~63.239 ms +XXX[502] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35537 ~70.791 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 3560 ~7.092 ms, finishGL 39 / 31722 ~63.191 ms +XXX[503] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35587 ~70.749 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 3570 ~7.098 ms, finishGL 39 / 31761 ~63.144 ms +XXX[504] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35637 ~70.709 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 3580 ~7.104 ms, finishGL 39 / 31801 ~63.098 ms +XXX[505] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35687 ~70.667 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 3589 ~7.108 ms, finishGL 39 / 31841 ~63.052 ms +XXX[506] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35737 ~70.627 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 3599 ~7.113 ms, finishGL 40 / 31881 ~63.007 ms +XXX[507] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35788 ~70.588 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 3608 ~7.117 ms, finishGL 41 / 31923 ~62.964 ms +XXX[508] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35837 ~70.547 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 3616 ~7.119 ms, finishGL 40 / 31964 ~62.921 ms +XXX[509] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35888 ~70.507 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 3625 ~7.122 ms, finishGL 41 / 32005 ~62.878 ms +XXX[510] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35938 ~70.467 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 3633 ~7.123 ms, finishGL 41 / 32047 ~62.837 ms +XXX[511] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35989 ~70.429 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 3640 ~7.124 ms, finishGL 43 / 32090 ~62.799 ms +XXX[512] TO 17 ms, lFrame0 0 ms, lFrameX 52 / 36042 ~70.394 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3646 ~7.121 ms, finishGL 45 / 32136 ~62.766 ms +XXX[513] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 36093 ~70.358 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 3649 ~7.114 ms, finishGL 47 / 32184 ~62.737 ms +XXX[514] TO 17 ms, lFrame0 0 ms, lFrameX 53 / 36147 ~70.325 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 1 / 3651 ~7.103 ms, finishGL 51 / 32236 ~62.716 ms +XXX[515] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 36217 ~70.324 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 14 / 3665 ~7.117 ms, finishGL 54 / 32290 ~62.7 ms +XXX[516] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 36287 ~70.325 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 11 / 3676 ~7.125 ms, finishGL 59 / 32349 ~62.693 ms +XXX[517] TO 17 ms, lFrame0 0 ms, lFrameX 76 / 36363 ~70.336 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3683 ~7.124 ms, finishGL 68 / 32418 ~62.705 ms +XXX[518] TO 17 ms, lFrame0 0 ms, lFrameX 91 / 36455 ~70.376 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 13 / 3697 ~7.138 ms, finishGL 77 / 32495 ~62.732 ms +XXX[519] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36539 ~70.402 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3703 ~7.135 ms, finishGL 77 / 32573 ~62.761 ms +XXX[520] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36622 ~70.427 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3708 ~7.131 ms, finishGL 77 / 32650 ~62.79 ms +XXX[521] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36705 ~70.451 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3713 ~7.127 ms, finishGL 77 / 32728 ~62.818 ms +XXX[522] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36788 ~70.476 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3718 ~7.123 ms, finishGL 77 / 32806 ~62.847 ms +XXX[523] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36871 ~70.5 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3723 ~7.118 ms, finishGL 77 / 32883 ~62.875 ms +XXX[524] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36954 ~70.523 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3728 ~7.115 ms, finishGL 76 / 32960 ~62.902 ms +XXX[525] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37037 ~70.547 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3733 ~7.112 ms, finishGL 77 / 33037 ~62.929 ms +XXX[526] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37120 ~70.57 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3739 ~7.109 ms, finishGL 76 / 33114 ~62.955 ms +XXX[527] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37204 ~70.595 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3745 ~7.107 ms, finishGL 77 / 33191 ~62.982 ms +XXX[528] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37287 ~70.619 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3750 ~7.103 ms, finishGL 77 / 33269 ~63.01 ms +XXX[529] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37370 ~70.643 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3755 ~7.1 ms, finishGL 77 / 33346 ~63.037 ms +XXX[530] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37454 ~70.668 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3761 ~7.096 ms, finishGL 77 / 33424 ~63.065 ms +XXX[531] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37537 ~70.692 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3765 ~7.091 ms, finishGL 78 / 33502 ~63.094 ms +XXX[532] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37620 ~70.714 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3771 ~7.088 ms, finishGL 76 / 33579 ~63.119 ms +XXX[533] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37703 ~70.738 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3776 ~7.084 ms, finishGL 77 / 33657 ~63.146 ms +XXX[534] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 37786 ~70.761 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 3779 ~7.078 ms, finishGL 77 / 33735 ~63.174 ms +XXX[535] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37868 ~70.782 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3784 ~7.074 ms, finishGL 76 / 33811 ~63.199 ms +XXX[536] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37951 ~70.805 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3790 ~7.072 ms, finishGL 76 / 33888 ~63.224 ms +XXX[537] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38035 ~70.828 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3796 ~7.07 ms, finishGL 76 / 33964 ~63.249 ms +XXX[538] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38117 ~70.85 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3802 ~7.068 ms, finishGL 76 / 34041 ~63.273 ms +XXX[539] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38200 ~70.872 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3809 ~7.068 ms, finishGL 75 / 34116 ~63.295 ms +XXX[540] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38284 ~70.896 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 3817 ~7.068 ms, finishGL 76 / 34192 ~63.319 ms +XXX[541] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38367 ~70.919 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3823 ~7.067 ms, finishGL 76 / 34268 ~63.343 ms +XXX[542] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38450 ~70.942 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3830 ~7.066 ms, finishGL 76 / 34345 ~63.367 ms +XXX[543] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38534 ~70.965 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3836 ~7.064 ms, finishGL 76 / 34422 ~63.392 ms +XXX[544] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38617 ~70.988 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3842 ~7.062 ms, finishGL 76 / 34499 ~63.417 ms +XXX[545] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38700 ~71.01 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3847 ~7.06 ms, finishGL 77 / 34576 ~63.442 ms +XXX[546] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 38785 ~71.035 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3853 ~7.057 ms, finishGL 77 / 34654 ~63.469 ms +XXX[547] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38868 ~71.058 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3858 ~7.054 ms, finishGL 77 / 34731 ~63.495 ms +XXX[548] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38952 ~71.081 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3863 ~7.049 ms, finishGL 79 / 34811 ~63.523 ms +XXX[549] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39036 ~71.104 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 3866 ~7.042 ms, finishGL 79 / 34890 ~63.553 ms +XXX[550] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 39120 ~71.128 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 3869 ~7.035 ms, finishGL 80 / 34971 ~63.584 ms +XXX[551] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39203 ~71.149 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 3871 ~7.026 ms, finishGL 79 / 35051 ~63.614 ms +XXX[552] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39285 ~71.168 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 3874 ~7.018 ms, finishGL 79 / 35130 ~63.641 ms +XXX[553] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39367 ~71.189 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 3877 ~7.012 ms, finishGL 78 / 35208 ~63.668 ms +XXX[554] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39450 ~71.21 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3881 ~7.007 ms, finishGL 77 / 35286 ~63.694 ms +XXX[555] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39532 ~71.23 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3886 ~7.002 ms, finishGL 77 / 35363 ~63.718 ms +XXX[556] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39615 ~71.25 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3892 ~7.0 ms, finishGL 76 / 35440 ~63.741 ms +XXX[557] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 39695 ~71.266 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3898 ~6.999 ms, finishGL 73 / 35513 ~63.758 ms +XXX[558] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39778 ~71.287 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 3907 ~7.003 ms, finishGL 73 / 35586 ~63.775 ms +XXX[559] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 39860 ~71.306 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 3917 ~7.008 ms, finishGL 71 / 35658 ~63.789 ms +XXX[560] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 39941 ~71.324 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 10 / 3928 ~7.015 ms, finishGL 70 / 35728 ~63.801 ms +XXX[561] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 40023 ~71.342 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 12 / 3941 ~7.025 ms, finishGL 68 / 35796 ~63.808 ms +XXX[562] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 40104 ~71.36 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 14 / 3955 ~7.038 ms, finishGL 66 / 35863 ~63.813 ms +XXX[563] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 40186 ~71.379 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 16 / 3972 ~7.055 ms, finishGL 65 / 35928 ~63.815 ms +XXX[564] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40251 ~71.368 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 1 / 3973 ~7.045 ms, finishGL 63 / 35991 ~63.815 ms +XXX[565] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40316 ~71.356 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 3976 ~7.037 ms, finishGL 61 / 36053 ~63.811 ms +XXX[566] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40382 ~71.346 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3980 ~7.032 ms, finishGL 60 / 36113 ~63.805 ms +XXX[567] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40447 ~71.335 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 3985 ~7.028 ms, finishGL 60 / 36174 ~63.798 ms +XXX[568] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40513 ~71.326 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 3991 ~7.026 ms, finishGL 59 / 36233 ~63.791 ms +XXX[569] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40579 ~71.316 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 3997 ~7.025 ms, finishGL 58 / 36292 ~63.782 ms +XXX[570] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 40646 ~71.309 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4005 ~7.026 ms, finishGL 59 / 36351 ~63.774 ms +XXX[571] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40712 ~71.299 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 4011 ~7.025 ms, finishGL 58 / 36410 ~63.765 ms +XXX[572] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40778 ~71.291 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4018 ~7.025 ms, finishGL 58 / 36469 ~63.757 ms +XXX[573] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40845 ~71.283 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4025 ~7.025 ms, finishGL 59 / 36528 ~63.749 ms +XXX[574] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40912 ~71.275 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4032 ~7.026 ms, finishGL 59 / 36587 ~63.741 ms +XXX[575] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40977 ~71.265 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4039 ~7.026 ms, finishGL 58 / 36645 ~63.731 ms +XXX[576] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 41046 ~71.261 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4047 ~7.027 ms, finishGL 60 / 36706 ~63.725 ms +XXX[577] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 41116 ~71.259 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 4053 ~7.024 ms, finishGL 63 / 36770 ~63.726 ms +XXX[578] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 41187 ~71.258 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 4055 ~7.016 ms, finishGL 68 / 36838 ~63.734 ms +XXX[579] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 41276 ~71.288 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 14 / 4069 ~7.028 ms, finishGL 73 / 36912 ~63.751 ms +XXX[580] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 41363 ~71.316 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 9 / 4078 ~7.032 ms, finishGL 77 / 36989 ~63.775 ms +XXX[581] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 41449 ~71.34 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 4083 ~7.028 ms, finishGL 80 / 37070 ~63.804 ms +XXX[582] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 41533 ~71.362 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 2 / 4086 ~7.02 ms, finishGL 81 / 37151 ~63.834 ms +XXX[583] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 41613 ~71.378 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 1 / 4087 ~7.011 ms, finishGL 78 / 37230 ~63.859 ms +XXX[584] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 41695 ~71.396 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 3 / 4091 ~7.005 ms, finishGL 77 / 37307 ~63.883 ms +XXX[585] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41778 ~71.415 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 4096 ~7.002 ms, finishGL 76 / 37384 ~63.905 ms +XXX[586] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41860 ~71.434 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 4102 ~7.0 ms, finishGL 76 / 37460 ~63.925 ms +XXX[587] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41943 ~71.453 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 4109 ~7.0 ms, finishGL 75 / 37536 ~63.946 ms +XXX[588] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42026 ~71.473 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 4116 ~7.0 ms, finishGL 75 / 37611 ~63.965 ms +XXX[589] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42109 ~71.492 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4123 ~7.0 ms, finishGL 75 / 37686 ~63.984 ms +XXX[590] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42192 ~71.512 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4131 ~7.002 ms, finishGL 74 / 37761 ~64.002 ms +XXX[591] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42275 ~71.532 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 8 / 4140 ~7.005 ms, finishGL 74 / 37835 ~64.019 ms +XXX[592] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42358 ~71.551 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4147 ~7.006 ms, finishGL 74 / 37910 ~64.037 ms +XXX[593] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 42442 ~71.572 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 7 / 4155 ~7.007 ms, finishGL 75 / 37986 ~64.057 ms +XXX[594] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42526 ~71.592 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 4162 ~7.007 ms, finishGL 76 / 38062 ~64.078 ms +XXX[595] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 42610 ~71.614 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 6 / 4168 ~7.006 ms, finishGL 77 / 38139 ~64.1 ms +XXX[596] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42694 ~71.634 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 4 / 4173 ~7.003 ms, finishGL 77 / 38217 ~64.123 ms +XXX[597] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42778 ~71.655 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 4178 ~6.999 ms, finishGL 78 / 38296 ~64.147 ms +XXX[598] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42860 ~71.672 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 4184 ~6.996 ms, finishGL 76 / 38372 ~64.168 ms +XXX[599] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 42942 ~71.689 ms, flushGL 0 / 1 ~0.0030 ms, waitGL 5 / 4189 ~6.993 ms, finishGL 76 / 38448 ~64.188 ms diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync0-finish-wait-exclctx.log b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync0-finish-wait-exclctx.log new file mode 100644 index 000000000..cf5bd39f5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync0-finish-wait-exclctx.log @@ -0,0 +1,751 @@ +NSZombieEnabled +NSTraceEvents YES +OBJC_PRINT_EXCEPTIONS +/usr/bin/java +java version "1.6.0_37" +Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909) +Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode) +LD_LIBRARY_PATH :../../gluegen/make/../build-macosx/obj:../build-macosx/lib +LIBXCB_ALLOW_SLOPPY_LOCK: +LIBGL_DRIVERS_PATH: +LIBGL_DEBUG: +LIBGL_ALWAYS_INDIRECT: +LIBGL_ALWAYS_SOFTWARE: +SWT_CLASSPATH: ../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar +/usr/bin/java -d64 -time 100000 -vsync 0 -exclctx +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar + +Test Start: com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsync 0 -exclctx + +/usr/bin/java -d64 -Djava.awt.headless=false -Djogl.debug.calayer.SwapM2 com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsync 0 -exclctx +swapInterval 0 +exclusiveContext true +SWAP_M1 false +SWAP_M2 true +NewtCanvasAWT.attachNewtChild.2: size 500x268 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init ... +LandscapeES2 init on Thread[main-Display-.macosx_nil-1-EDT-1,5,main] +Chosen GLCapabilities: GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], offscr[fbo]] +INIT GL IS: jogamp.opengl.gl4.GL4bcImpl +GL_VENDOR: NVIDIA Corporation +GL_RENDERER: NVIDIA GeForce 320M OpenGL Engine +GL_VERSION: 2.1 NVIDIA-7.32.12 +GL GLSL: true, has-compiler-func: true, version 1.20, 1.20.0 +GL FBO: basic true, full true +GL Profile: GLProfile[GL2/GL2.hw] +GL Renderer Quirks:[NoOffscreenBitmap] +GL:jogamp.opengl.gl4.GL4bcImpl@57ac3379, 2.1 (hardware) - 2.1 NVIDIA-7.32.12 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init FIN +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.reshape 0/0 500x268, swapInterval 0, drawable 0x7f98910ac7d0 +Thread[AWT-EventQueue-0,6,main] LandscapeES2.reshape 0/0 500x268, swapInterval 0, drawable 0x7f98910ac7d0 +XXX[1] TO 17 ms, lFrame0 110 ms, lFrameX 848 / 848 ~848.189 ms, finishGL 736 / 736 ~736.724 ms, waitGL 1 / 1 ~1.131 ms +XXX[2] TO 17 ms, lFrame0 122 ms, lFrameX 211 / 1059 ~529.747 ms, finishGL 88 / 825 ~412.707 ms, waitGL 0 / 1 ~0.572 ms +XXX[3] TO 17 ms, lFrame0 2 ms, lFrameX 100 / 1159 ~386.566 ms, finishGL 97 / 923 ~307.754 ms, waitGL 0 / 1 ~0.395 ms +XXX[4] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 1259 ~314.909 ms, finishGL 99 / 1022 ~255.589 ms, waitGL 0 / 1 ~0.299 ms +XXX[5] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 1359 ~271.82 ms, finishGL 98 / 1121 ~224.2 ms, waitGL 0 / 1 ~0.242 ms +XXX[6] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 1440 ~240.077 ms, finishGL 80 / 1201 ~200.259 ms, waitGL 0 / 1 ~0.203 ms +XXX[7] TO 17 ms, lFrame0 2 ms, lFrameX 83 / 1524 ~217.736 ms, finishGL 81 / 1283 ~183.315 ms, waitGL 0 / 1 ~0.176 ms +XXX[8] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1606 ~200.869 ms, finishGL 82 / 1365 ~170.676 ms, waitGL 0 / 1 ~0.156 ms +XXX[9] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 1705 ~189.545 ms, finishGL 98 / 1463 ~162.626 ms, waitGL 0 / 1 ~0.14 ms +XXX[10] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1788 ~178.844 ms, finishGL 81 / 1545 ~154.52 ms, waitGL 0 / 1 ~0.128 ms +XXX[11] TO 17 ms, lFrame0 1 ms, lFrameX 78 / 1866 ~169.691 ms, finishGL 77 / 1622 ~147.48 ms, waitGL 0 / 1 ~0.118 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 1970 ~164.238 ms, finishGL 103 / 1725 ~143.819 ms, waitGL 0 / 1 ~0.109 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2052 ~157.921 ms, finishGL 81 / 1807 ~139.019 ms, waitGL 0 / 1 ~0.102 ms +XXX[14] TO 17 ms, lFrame0 1 ms, lFrameX 77 / 2130 ~152.18 ms, finishGL 76 / 1883 ~134.53 ms, waitGL 0 / 1 ~0.096 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 2235 ~149.003 ms, finishGL 104 / 1987 ~132.499 ms, waitGL 0 / 1 ~0.09 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2317 ~144.869 ms, finishGL 82 / 2069 ~129.364 ms, waitGL 0 / 1 ~0.086 ms +XXX[17] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 2393 ~140.812 ms, finishGL 74 / 2144 ~126.164 ms, waitGL 0 / 1 ~0.081 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 107 / 2501 ~138.947 ms, finishGL 106 / 2251 ~125.084 ms, waitGL 0 / 1 ~0.078 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2584 ~136.019 ms, finishGL 82 / 2334 ~122.861 ms, waitGL 0 / 1 ~0.074 ms +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 2659 ~132.991 ms, finishGL 74 / 2409 ~120.458 ms, waitGL 0 / 1 ~0.071 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 107 / 2767 ~131.792 ms, finishGL 107 / 2516 ~119.829 ms, waitGL 0 / 1 ~0.068 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2850 ~129.57 ms, finishGL 82 / 2598 ~118.129 ms, waitGL 0 / 1 ~0.066 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 73 / 2923 ~127.112 ms, finishGL 72 / 2671 ~116.144 ms, waitGL 0 / 1 ~0.064 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 104 / 3028 ~126.189 ms, finishGL 104 / 2775 ~115.653 ms, waitGL 0 / 1 ~0.062 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3111 ~124.449 ms, finishGL 82 / 2857 ~114.316 ms, waitGL 0 / 1 ~0.06 ms +XXX[26] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 3179 ~122.303 ms, finishGL 68 / 2925 ~112.537 ms, waitGL 0 / 1 ~0.058 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 96 / 3276 ~121.334 ms, finishGL 95 / 3021 ~111.912 ms, waitGL 0 / 1 ~0.056 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3358 ~119.931 ms, finishGL 81 / 3103 ~110.824 ms, waitGL 0 / 1 ~0.055 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 3425 ~118.108 ms, finishGL 66 / 3169 ~109.29 ms, waitGL 0 / 1 ~0.053 ms +XXX[30] TO 17 ms, lFrame0 0 ms, lFrameX 97 / 3522 ~117.427 ms, finishGL 97 / 3266 ~108.885 ms, waitGL 0 / 1 ~0.052 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3605 ~116.298 ms, finishGL 81 / 3348 ~108.018 ms, waitGL 0 / 1 ~0.051 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3670 ~114.699 ms, finishGL 64 / 3413 ~106.659 ms, waitGL 0 / 1 ~0.05 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 3753 ~113.755 ms, finishGL 83 / 3496 ~105.943 ms, waitGL 0 / 1 ~0.049 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3819 ~112.326 ms, finishGL 64 / 3560 ~104.731 ms, waitGL 0 / 1 ~0.047 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 3882 ~110.923 ms, finishGL 62 / 3623 ~103.536 ms, waitGL 0 / 1 ~0.046 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 3952 ~109.795 ms, finishGL 69 / 3693 ~102.601 ms, waitGL 0 / 1 ~0.046 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4018 ~108.616 ms, finishGL 65 / 3759 ~101.602 ms, waitGL 0 / 1 ~0.045 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 4084 ~107.492 ms, finishGL 65 / 3824 ~100.649 ms, waitGL 0 / 1 ~0.044 ms +XXX[39] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 4150 ~106.426 ms, finishGL 65 / 3890 ~99.745 ms, waitGL 0 / 1 ~0.043 ms +XXX[40] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 4216 ~105.406 ms, finishGL 65 / 3955 ~98.88 ms, waitGL 0 / 1 ~0.042 ms +XXX[41] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4282 ~104.446 ms, finishGL 65 / 4020 ~98.069 ms, waitGL 0 / 1 ~0.042 ms +XXX[42] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4348 ~103.54 ms, finishGL 65 / 4086 ~97.305 ms, waitGL 0 / 1 ~0.041 ms +XXX[43] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4415 ~102.674 ms, finishGL 65 / 4152 ~96.568 ms, waitGL 0 / 1 ~0.04 ms +XXX[44] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4481 ~101.854 ms, finishGL 66 / 4218 ~95.875 ms, waitGL 0 / 1 ~0.04 ms +XXX[45] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4547 ~101.064 ms, finishGL 65 / 4284 ~95.207 ms, waitGL 0 / 1 ~0.039 ms +XXX[46] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4614 ~100.307 ms, finishGL 65 / 4349 ~94.563 ms, waitGL 0 / 1 ~0.039 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4680 ~99.591 ms, finishGL 66 / 4416 ~93.958 ms, waitGL 0 / 1 ~0.038 ms +XXX[48] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 4746 ~98.887 ms, finishGL 65 / 4481 ~93.363 ms, waitGL 0 / 1 ~0.038 ms +XXX[49] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4813 ~98.226 ms, finishGL 66 / 4547 ~92.806 ms, waitGL 0 / 1 ~0.037 ms +XXX[50] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4879 ~97.587 ms, finishGL 65 / 4613 ~92.262 ms, waitGL 0 / 1 ~0.037 ms +XXX[51] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 4945 ~96.967 ms, finishGL 65 / 4678 ~91.737 ms, waitGL 0 / 1 ~0.037 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5011 ~96.381 ms, finishGL 66 / 4744 ~91.244 ms, waitGL 0 / 1 ~0.036 ms +XXX[53] TO 17 ms, lFrame0 9 ms, lFrameX 68 / 5080 ~95.852 ms, finishGL 58 / 4803 ~90.633 ms, waitGL 0 / 1 ~0.036 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 5145 ~95.284 ms, finishGL 64 / 4868 ~90.153 ms, waitGL 0 / 1 ~0.035 ms +XXX[55] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5211 ~94.762 ms, finishGL 65 / 4934 ~89.712 ms, waitGL 0 / 1 ~0.035 ms +XXX[56] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 5276 ~94.225 ms, finishGL 64 / 4998 ~89.255 ms, waitGL 0 / 1 ~0.035 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5342 ~93.732 ms, finishGL 65 / 5063 ~88.841 ms, waitGL 0 / 1 ~0.034 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5410 ~93.277 ms, finishGL 66 / 5130 ~88.463 ms, waitGL 0 / 1 ~0.034 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5477 ~92.831 ms, finishGL 66 / 5197 ~88.09 ms, waitGL 0 / 2 ~0.034 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5543 ~92.388 ms, finishGL 65 / 5263 ~87.717 ms, waitGL 0 / 2 ~0.033 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5609 ~91.963 ms, finishGL 65 / 5329 ~87.36 ms, waitGL 0 / 2 ~0.033 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5676 ~91.562 ms, finishGL 66 / 5395 ~87.026 ms, waitGL 0 / 2 ~0.033 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5743 ~91.161 ms, finishGL 65 / 5461 ~86.688 ms, waitGL 0 / 2 ~0.032 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5809 ~90.78 ms, finishGL 66 / 5527 ~86.37 ms, waitGL 0 / 2 ~0.032 ms +XXX[65] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5877 ~90.417 ms, finishGL 66 / 5594 ~86.067 ms, waitGL 0 / 2 ~0.032 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5944 ~90.064 ms, finishGL 66 / 5660 ~85.771 ms, waitGL 0 / 2 ~0.032 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6010 ~89.705 ms, finishGL 65 / 5726 ~85.47 ms, waitGL 0 / 2 ~0.031 ms +XXX[68] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6077 ~89.37 ms, finishGL 66 / 5792 ~85.189 ms, waitGL 0 / 2 ~0.031 ms +XXX[69] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6144 ~89.049 ms, finishGL 66 / 5859 ~84.922 ms, waitGL 0 / 2 ~0.031 ms +XXX[70] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6210 ~88.723 ms, finishGL 65 / 5925 ~84.65 ms, waitGL 0 / 2 ~0.031 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6277 ~88.41 ms, finishGL 65 / 5991 ~84.387 ms, waitGL 0 / 2 ~0.031 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6343 ~88.105 ms, finishGL 65 / 6057 ~84.13 ms, waitGL 0 / 2 ~0.03 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6409 ~87.8 ms, finishGL 65 / 6122 ~83.873 ms, waitGL 0 / 2 ~0.03 ms +XXX[74] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6475 ~87.502 ms, finishGL 65 / 6188 ~83.622 ms, waitGL 0 / 2 ~0.03 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6540 ~87.209 ms, finishGL 64 / 6252 ~83.371 ms, waitGL 0 / 2 ~0.03 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6606 ~86.932 ms, finishGL 65 / 6318 ~83.14 ms, waitGL 0 / 2 ~0.03 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6674 ~86.678 ms, finishGL 66 / 6385 ~82.928 ms, waitGL 0 / 2 ~0.029 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6740 ~86.422 ms, finishGL 66 / 6451 ~82.714 ms, waitGL 0 / 2 ~0.029 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6807 ~86.17 ms, finishGL 65 / 6517 ~82.502 ms, waitGL 0 / 2 ~0.029 ms +XXX[80] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6874 ~85.928 ms, finishGL 66 / 6584 ~82.3 ms, waitGL 0 / 2 ~0.029 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6941 ~85.692 ms, finishGL 66 / 6650 ~82.104 ms, waitGL 0 / 2 ~0.029 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 7008 ~85.471 ms, finishGL 67 / 6717 ~81.92 ms, waitGL 0 / 2 ~0.029 ms +XXX[83] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7075 ~85.242 ms, finishGL 65 / 6783 ~81.728 ms, waitGL 0 / 2 ~0.028 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7141 ~85.019 ms, finishGL 66 / 6849 ~81.54 ms, waitGL 0 / 2 ~0.028 ms +XXX[85] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7208 ~84.805 ms, finishGL 66 / 6915 ~81.361 ms, waitGL 0 / 2 ~0.028 ms +XXX[86] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7275 ~84.596 ms, finishGL 66 / 6982 ~81.187 ms, waitGL 0 / 2 ~0.028 ms +XXX[87] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7341 ~84.384 ms, finishGL 65 / 7047 ~81.009 ms, waitGL 0 / 2 ~0.028 ms +XXX[88] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7407 ~84.179 ms, finishGL 65 / 7113 ~80.836 ms, waitGL 0 / 2 ~0.028 ms +XXX[89] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7474 ~83.98 ms, finishGL 65 / 7179 ~80.669 ms, waitGL 0 / 2 ~0.028 ms +XXX[90] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7540 ~83.784 ms, finishGL 65 / 7245 ~80.504 ms, waitGL 0 / 2 ~0.028 ms +XXX[91] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 7607 ~83.599 ms, finishGL 66 / 7311 ~80.348 ms, waitGL 0 / 2 ~0.027 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 7673 ~83.407 ms, finishGL 65 / 7377 ~80.186 ms, waitGL 0 / 2 ~0.027 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7740 ~83.226 ms, finishGL 66 / 7443 ~80.035 ms, waitGL 0 / 2 ~0.027 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7806 ~83.051 ms, finishGL 66 / 7509 ~79.888 ms, waitGL 0 / 2 ~0.027 ms +XXX[95] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7872 ~82.873 ms, finishGL 65 / 7575 ~79.738 ms, waitGL 0 / 2 ~0.027 ms +XXX[96] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 7938 ~82.695 ms, finishGL 65 / 7640 ~79.588 ms, waitGL 0 / 2 ~0.027 ms +XXX[97] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8005 ~82.526 ms, finishGL 65 / 7706 ~79.446 ms, waitGL 0 / 2 ~0.027 ms +XXX[98] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8071 ~82.359 ms, finishGL 65 / 7771 ~79.305 ms, waitGL 0 / 2 ~0.027 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8137 ~82.197 ms, finishGL 65 / 7837 ~79.169 ms, waitGL 0 / 2 ~0.026 ms +XXX[1] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 66 ~66.612 ms, finishGL 66 / 66 ~66.069 ms, waitGL 0 / 0 ~0.017 ms +XXX[2] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 131 ~65.969 ms, finishGL 64 / 130 ~65.483 ms, waitGL 0 / 0 ~0.018 ms +XXX[3] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 198 ~66.176 ms, finishGL 66 / 197 ~65.684 ms, waitGL 0 / 0 ~0.017 ms +XXX[4] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 265 ~66.274 ms, finishGL 66 / 263 ~65.784 ms, waitGL 0 / 0 ~0.016 ms +XXX[5] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 331 ~66.257 ms, finishGL 65 / 328 ~65.765 ms, waitGL 0 / 0 ~0.016 ms +XXX[6] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 397 ~66.228 ms, finishGL 65 / 394 ~65.727 ms, waitGL 0 / 0 ~0.016 ms +XXX[7] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 464 ~66.289 ms, finishGL 66 / 460 ~65.791 ms, waitGL 0 / 0 ~0.015 ms +XXX[8] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 531 ~66.42 ms, finishGL 66 / 527 ~65.919 ms, waitGL 0 / 0 ~0.015 ms +XXX[9] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 598 ~66.459 ms, finishGL 66 / 593 ~65.961 ms, waitGL 0 / 0 ~0.016 ms +XXX[10] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 666 ~66.638 ms, finishGL 67 / 661 ~66.141 ms, waitGL 0 / 0 ~0.016 ms +XXX[11] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 732 ~66.562 ms, finishGL 65 / 726 ~66.062 ms, waitGL 0 / 0 ~0.016 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 798 ~66.515 ms, finishGL 65 / 792 ~66.004 ms, waitGL 0 / 0 ~0.016 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 863 ~66.433 ms, finishGL 64 / 856 ~65.919 ms, waitGL 0 / 0 ~0.016 ms +XXX[14] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 930 ~66.441 ms, finishGL 66 / 923 ~65.929 ms, waitGL 0 / 0 ~0.016 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 996 ~66.432 ms, finishGL 65 / 988 ~65.92 ms, waitGL 0 / 0 ~0.016 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1062 ~66.436 ms, finishGL 66 / 1054 ~65.926 ms, waitGL 0 / 0 ~0.015 ms +XXX[17] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1129 ~66.447 ms, finishGL 66 / 1120 ~65.94 ms, waitGL 0 / 0 ~0.015 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1196 ~66.495 ms, finishGL 66 / 1187 ~65.989 ms, waitGL 0 / 0 ~0.015 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1263 ~66.485 ms, finishGL 65 / 1253 ~65.979 ms, waitGL 0 / 0 ~0.015 ms +FrameCount: 120 - FrameRate: 15.0 +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1330 ~66.512 ms, finishGL 66 / 1320 ~66.002 ms, waitGL 0 / 0 ~0.015 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1397 ~66.528 ms, finishGL 66 / 1386 ~66.019 ms, waitGL 0 / 0 ~0.015 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1464 ~66.577 ms, finishGL 67 / 1453 ~66.069 ms, waitGL 0 / 0 ~0.015 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1531 ~66.581 ms, finishGL 66 / 1519 ~66.074 ms, waitGL 0 / 0 ~0.015 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1598 ~66.589 ms, finishGL 66 / 1585 ~66.082 ms, waitGL 0 / 0 ~0.015 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1665 ~66.601 ms, finishGL 66 / 1652 ~66.095 ms, waitGL 0 / 0 ~0.015 ms +XXX[26] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1732 ~66.617 ms, finishGL 66 / 1718 ~66.112 ms, waitGL 0 / 0 ~0.015 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1798 ~66.607 ms, finishGL 65 / 1784 ~66.103 ms, waitGL 0 / 0 ~0.016 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1864 ~66.599 ms, finishGL 65 / 1850 ~66.095 ms, waitGL 0 / 0 ~0.016 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1931 ~66.611 ms, finishGL 66 / 1917 ~66.107 ms, waitGL 0 / 0 ~0.016 ms +XXX[30] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 1997 ~66.589 ms, finishGL 65 / 1982 ~66.088 ms, waitGL 0 / 0 ~0.016 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2063 ~66.572 ms, finishGL 65 / 2048 ~66.074 ms, waitGL 0 / 0 ~0.015 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2130 ~66.576 ms, finishGL 66 / 2114 ~66.077 ms, waitGL 0 / 0 ~0.015 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2196 ~66.568 ms, finishGL 65 / 2180 ~66.069 ms, waitGL 0 / 0 ~0.016 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 2263 ~66.587 ms, finishGL 66 / 2247 ~66.089 ms, waitGL 0 / 0 ~0.015 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2330 ~66.58 ms, finishGL 65 / 2312 ~66.082 ms, waitGL 0 / 0 ~0.015 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2396 ~66.574 ms, finishGL 65 / 2378 ~66.077 ms, waitGL 0 / 0 ~0.015 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2463 ~66.57 ms, finishGL 65 / 2444 ~66.07 ms, waitGL 0 / 0 ~0.015 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2530 ~66.579 ms, finishGL 66 / 2510 ~66.078 ms, waitGL 0 / 0 ~0.015 ms +XXX[39] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2596 ~66.572 ms, finishGL 65 / 2576 ~66.072 ms, waitGL 0 / 0 ~0.015 ms +XXX[40] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2662 ~66.566 ms, finishGL 65 / 2642 ~66.062 ms, waitGL 0 / 0 ~0.016 ms +XXX[41] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2728 ~66.555 ms, finishGL 65 / 2708 ~66.052 ms, waitGL 0 / 0 ~0.016 ms +XXX[42] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2795 ~66.566 ms, finishGL 66 / 2774 ~66.063 ms, waitGL 0 / 0 ~0.016 ms +XXX[43] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2861 ~66.554 ms, finishGL 65 / 2840 ~66.052 ms, waitGL 0 / 0 ~0.016 ms +XXX[44] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2927 ~66.536 ms, finishGL 65 / 2905 ~66.035 ms, waitGL 0 / 0 ~0.015 ms +XXX[45] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2992 ~66.506 ms, finishGL 64 / 2970 ~66.001 ms, waitGL 0 / 0 ~0.016 ms +XXX[46] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3057 ~66.473 ms, finishGL 64 / 3034 ~65.966 ms, waitGL 0 / 0 ~0.016 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 3122 ~66.425 ms, finishGL 63 / 3098 ~65.918 ms, waitGL 0 / 0 ~0.016 ms +XXX[48] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 3185 ~66.364 ms, finishGL 63 / 3161 ~65.858 ms, waitGL 0 / 0 ~0.016 ms +XXX[49] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 3247 ~66.267 ms, finishGL 61 / 3222 ~65.763 ms, waitGL 0 / 0 ~0.016 ms +XXX[50] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 3309 ~66.196 ms, finishGL 62 / 3284 ~65.693 ms, waitGL 0 / 0 ~0.016 ms +XXX[51] TO 17 ms, lFrame0 0 ms, lFrameX 47 / 3357 ~65.831 ms, finishGL 47 / 3331 ~65.329 ms, waitGL 0 / 0 ~0.016 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3406 ~65.512 ms, finishGL 48 / 3380 ~65.011 ms, waitGL 0 / 0 ~0.016 ms +XXX[53] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3455 ~65.197 ms, finishGL 48 / 3428 ~64.697 ms, waitGL 0 / 0 ~0.016 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3504 ~64.902 ms, finishGL 48 / 3477 ~64.403 ms, waitGL 0 / 0 ~0.016 ms +XXX[55] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3553 ~64.612 ms, finishGL 48 / 3526 ~64.112 ms, waitGL 0 / 0 ~0.016 ms +XXX[56] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3602 ~64.335 ms, finishGL 48 / 3574 ~63.837 ms, waitGL 0 / 0 ~0.016 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3652 ~64.083 ms, finishGL 49 / 3624 ~63.583 ms, waitGL 0 / 0 ~0.016 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3701 ~63.821 ms, finishGL 48 / 3672 ~63.322 ms, waitGL 0 / 0 ~0.016 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3751 ~63.583 ms, finishGL 49 / 3722 ~63.084 ms, waitGL 0 / 0 ~0.016 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3800 ~63.342 ms, finishGL 48 / 3770 ~62.842 ms, waitGL 0 / 0 ~0.016 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3849 ~63.111 ms, finishGL 48 / 3819 ~62.611 ms, waitGL 0 / 1 ~0.016 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3898 ~62.875 ms, finishGL 48 / 3867 ~62.375 ms, waitGL 0 / 1 ~0.016 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3947 ~62.657 ms, finishGL 48 / 3915 ~62.158 ms, waitGL 0 / 1 ~0.016 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3996 ~62.439 ms, finishGL 48 / 3964 ~61.94 ms, waitGL 0 / 1 ~0.016 ms +XXX[65] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4044 ~62.229 ms, finishGL 48 / 4012 ~61.729 ms, waitGL 0 / 1 ~0.016 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4093 ~62.018 ms, finishGL 47 / 4060 ~61.519 ms, waitGL 0 / 1 ~0.016 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4141 ~61.82 ms, finishGL 48 / 4108 ~61.319 ms, waitGL 0 / 1 ~0.016 ms +XXX[68] TO 17 ms, lFrame0 0 ms, lFrameX 29 / 4171 ~61.351 ms, finishGL 29 / 4137 ~60.851 ms, waitGL 0 / 1 ~0.016 ms +XXX[69] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 4223 ~61.207 ms, finishGL 50 / 4188 ~60.706 ms, waitGL 0 / 1 ~0.016 ms +XXX[70] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4255 ~60.791 ms, finishGL 31 / 4220 ~60.289 ms, waitGL 0 / 1 ~0.016 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 28 / 4283 ~60.33 ms, finishGL 27 / 4247 ~59.828 ms, waitGL 0 / 1 ~0.016 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 53 / 4337 ~60.239 ms, finishGL 53 / 4301 ~59.736 ms, waitGL 0 / 1 ~0.016 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4369 ~59.853 ms, finishGL 31 / 4332 ~59.35 ms, waitGL 0 / 1 ~0.016 ms +XXX[74] TO 17 ms, lFrame0 0 ms, lFrameX 26 / 4395 ~59.4 ms, finishGL 25 / 4358 ~58.895 ms, waitGL 0 / 1 ~0.016 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 39 / 4434 ~59.13 ms, finishGL 38 / 4396 ~58.625 ms, waitGL 0 / 1 ~0.016 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4483 ~58.99 ms, finishGL 47 / 4444 ~58.481 ms, waitGL 0 / 1 ~0.016 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 31 / 4515 ~58.637 ms, finishGL 31 / 4476 ~58.129 ms, waitGL 0 / 1 ~0.016 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 22 / 4538 ~58.18 ms, finishGL 22 / 4498 ~57.673 ms, waitGL 0 / 1 ~0.016 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 26 / 4564 ~57.78 ms, finishGL 26 / 4524 ~57.273 ms, waitGL 0 / 1 ~0.016 ms +XXX[80] TO 17 ms, lFrame0 0 ms, lFrameX 22 / 4587 ~57.343 ms, finishGL 22 / 4547 ~56.84 ms, waitGL 0 / 1 ~0.016 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 43 / 4631 ~57.178 ms, finishGL 43 / 4590 ~56.675 ms, waitGL 0 / 1 ~0.016 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4664 ~56.885 ms, finishGL 32 / 4623 ~56.382 ms, waitGL 0 / 1 ~0.016 ms +XXX[83] TO 17 ms, lFrame0 0 ms, lFrameX 23 / 4688 ~56.487 ms, finishGL 23 / 4646 ~55.982 ms, waitGL 0 / 1 ~0.016 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 42 / 4730 ~56.317 ms, finishGL 41 / 4688 ~55.812 ms, waitGL 0 / 1 ~0.016 ms +XXX[85] TO 17 ms, lFrame0 0 ms, lFrameX 36 / 4766 ~56.079 ms, finishGL 35 / 4723 ~55.575 ms, waitGL 0 / 1 ~0.016 ms +XXX[86] TO 17 ms, lFrame0 0 ms, lFrameX 30 / 4797 ~55.783 ms, finishGL 29 / 4753 ~55.275 ms, waitGL 0 / 1 ~0.016 ms +XXX[87] TO 17 ms, lFrame0 0 ms, lFrameX 59 / 4856 ~55.824 ms, finishGL 58 / 4812 ~55.316 ms, waitGL 0 / 1 ~0.016 ms +XXX[88] TO 17 ms, lFrame0 0 ms, lFrameX 55 / 4912 ~55.82 ms, finishGL 55 / 4867 ~55.313 ms, waitGL 0 / 1 ~0.016 ms +XXX[89] TO 17 ms, lFrame0 0 ms, lFrameX 41 / 4953 ~55.662 ms, finishGL 41 / 4908 ~55.153 ms, waitGL 0 / 1 ~0.016 ms +XXX[90] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 5015 ~55.723 ms, finishGL 60 / 4969 ~55.211 ms, waitGL 0 / 1 ~0.016 ms +XXX[91] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 5066 ~55.677 ms, finishGL 51 / 5020 ~55.166 ms, waitGL 0 / 1 ~0.016 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 42 / 5109 ~55.532 ms, finishGL 41 / 5061 ~55.021 ms, waitGL 0 / 1 ~0.016 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 5183 ~55.732 ms, finishGL 73 / 5135 ~55.222 ms, waitGL 0 / 1 ~0.016 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5233 ~55.671 ms, finishGL 49 / 5185 ~55.161 ms, waitGL 0 / 1 ~0.016 ms +XXX[95] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5283 ~55.613 ms, finishGL 49 / 5234 ~55.103 ms, waitGL 0 / 1 ~0.016 ms +XXX[96] TO 17 ms, lFrame0 0 ms, lFrameX 43 / 5326 ~55.486 ms, finishGL 42 / 5277 ~54.974 ms, waitGL 0 / 1 ~0.016 ms +XXX[97] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 5399 ~55.667 ms, finishGL 72 / 5350 ~55.155 ms, waitGL 0 / 1 ~0.016 ms +XXX[98] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5449 ~55.61 ms, finishGL 49 / 5399 ~55.1 ms, waitGL 0 / 1 ~0.016 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5500 ~55.56 ms, finishGL 50 / 5450 ~55.051 ms, waitGL 0 / 1 ~0.016 ms +XXX[100] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 5550 ~55.5 ms, finishGL 49 / 5499 ~54.991 ms, waitGL 0 / 1 ~0.016 ms +XXX[101] TO 17 ms, lFrame0 0 ms, lFrameX 45 / 5595 ~55.402 ms, finishGL 45 / 5544 ~54.895 ms, waitGL 0 / 1 ~0.016 ms +XXX[102] TO 17 ms, lFrame0 0 ms, lFrameX 56 / 5652 ~55.411 ms, finishGL 55 / 5600 ~54.905 ms, waitGL 0 / 1 ~0.016 ms +XXX[103] TO 17 ms, lFrame0 0 ms, lFrameX 52 / 5704 ~55.379 ms, finishGL 51 / 5651 ~54.873 ms, waitGL 0 / 1 ~0.016 ms +XXX[104] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5771 ~55.496 ms, finishGL 67 / 5719 ~54.99 ms, waitGL 0 / 1 ~0.016 ms +XXX[105] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5838 ~55.609 ms, finishGL 66 / 5785 ~55.103 ms, waitGL 0 / 1 ~0.016 ms +XXX[106] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 5907 ~55.727 ms, finishGL 67 / 5853 ~55.221 ms, waitGL 0 / 1 ~0.016 ms +XXX[107] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 5975 ~55.846 ms, finishGL 67 / 5921 ~55.34 ms, waitGL 0 / 1 ~0.016 ms +XXX[108] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 6046 ~55.983 ms, finishGL 70 / 5991 ~55.478 ms, waitGL 0 / 1 ~0.016 ms +XXX[109] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 6115 ~56.107 ms, finishGL 69 / 6060 ~55.602 ms, waitGL 0 / 1 ~0.016 ms +XXX[110] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6182 ~56.207 ms, finishGL 66 / 6127 ~55.703 ms, waitGL 0 / 1 ~0.016 ms +XXX[111] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6249 ~56.303 ms, finishGL 66 / 6193 ~55.8 ms, waitGL 0 / 1 ~0.016 ms +XXX[112] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6317 ~56.405 ms, finishGL 67 / 6260 ~55.901 ms, waitGL 0 / 1 ~0.016 ms +XXX[113] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6383 ~56.49 ms, finishGL 65 / 6326 ~55.986 ms, waitGL 0 / 1 ~0.016 ms +XXX[114] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6450 ~56.579 ms, finishGL 66 / 6392 ~56.075 ms, waitGL 0 / 1 ~0.016 ms +XXX[115] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6517 ~56.673 ms, finishGL 66 / 6459 ~56.169 ms, waitGL 0 / 1 ~0.016 ms +XXX[116] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6584 ~56.761 ms, finishGL 66 / 6525 ~56.257 ms, waitGL 0 / 1 ~0.016 ms +XXX[117] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6651 ~56.848 ms, finishGL 66 / 6592 ~56.344 ms, waitGL 0 / 1 ~0.016 ms +XXX[118] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 6736 ~57.085 ms, finishGL 84 / 6676 ~56.581 ms, waitGL 0 / 1 ~0.016 ms +XXX[119] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 6818 ~57.298 ms, finishGL 81 / 6758 ~56.794 ms, waitGL 0 / 1 ~0.016 ms +XXX[120] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 6884 ~57.372 ms, finishGL 65 / 6823 ~56.863 ms, waitGL 0 / 1 ~0.015 ms +XXX[121] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 6985 ~57.731 ms, finishGL 100 / 6923 ~57.222 ms, waitGL 0 / 1 ~0.015 ms +XXX[122] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7068 ~57.939 ms, finishGL 82 / 7006 ~57.431 ms, waitGL 0 / 1 ~0.015 ms +XXX[123] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 7136 ~58.021 ms, finishGL 67 / 7074 ~57.513 ms, waitGL 0 / 1 ~0.015 ms +XXX[124] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 7221 ~58.24 ms, finishGL 84 / 7158 ~57.732 ms, waitGL 0 / 1 ~0.015 ms +XXX[125] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 7307 ~58.46 ms, finishGL 85 / 7244 ~57.952 ms, waitGL 0 / 1 ~0.015 ms +XXX[126] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 7391 ~58.666 ms, finishGL 83 / 7327 ~58.155 ms, waitGL 0 / 2 ~0.015 ms +XXX[127] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 7476 ~58.872 ms, finishGL 84 / 7411 ~58.361 ms, waitGL 0 / 2 ~0.015 ms +XXX[128] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 7561 ~59.076 ms, finishGL 84 / 7496 ~58.565 ms, waitGL 0 / 2 ~0.015 ms +XXX[129] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 7644 ~59.26 ms, finishGL 82 / 7578 ~58.749 ms, waitGL 0 / 2 ~0.016 ms +XXX[130] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 7724 ~59.419 ms, finishGL 79 / 7658 ~58.909 ms, waitGL 0 / 2 ~0.016 ms +2013-06-17 03:36:23.407 java[65080:5f07] Persistent UI failed to open file file://localhost/Users/jogamp/Library/Saved%20Application%20State/com.apple.javajdk16.cmd.savedState/window_1.data: Operation not permitted (1) +XXX[131] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 7805 ~59.58 ms, finishGL 80 / 7738 ~59.071 ms, waitGL 0 / 2 ~0.016 ms +XXX[132] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 7886 ~59.749 ms, finishGL 81 / 7819 ~59.239 ms, waitGL 0 / 2 ~0.016 ms +XXX[133] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 7968 ~59.913 ms, finishGL 81 / 7900 ~59.404 ms, waitGL 0 / 2 ~0.016 ms +XXX[134] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 8049 ~60.074 ms, finishGL 80 / 7981 ~59.565 ms, waitGL 0 / 2 ~0.016 ms +XXX[135] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8132 ~60.24 ms, finishGL 82 / 8063 ~59.731 ms, waitGL 0 / 2 ~0.016 ms +XXX[136] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8214 ~60.404 ms, finishGL 82 / 8145 ~59.895 ms, waitGL 0 / 2 ~0.016 ms +XXX[137] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 8298 ~60.57 ms, finishGL 82 / 8228 ~60.061 ms, waitGL 0 / 2 ~0.016 ms +XXX[138] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 8364 ~60.612 ms, finishGL 64 / 8293 ~60.097 ms, waitGL 0 / 2 ~0.016 ms +XXX[139] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 8463 ~60.888 ms, finishGL 98 / 8391 ~60.373 ms, waitGL 0 / 2 ~0.016 ms +FrameCount: 240 - FrameRate: 13.0 +XXX[140] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8529 ~60.926 ms, finishGL 65 / 8457 ~60.41 ms, waitGL 0 / 2 ~0.015 ms +XXX[141] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 8593 ~60.949 ms, finishGL 63 / 8520 ~60.43 ms, waitGL 0 / 2 ~0.015 ms +XXX[142] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 8679 ~61.12 ms, finishGL 84 / 8605 ~60.601 ms, waitGL 0 / 2 ~0.015 ms +XXX[143] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8745 ~61.156 ms, finishGL 65 / 8671 ~60.638 ms, waitGL 0 / 2 ~0.015 ms +XXX[144] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 8807 ~61.166 ms, finishGL 62 / 8733 ~60.648 ms, waitGL 0 / 2 ~0.015 ms +XXX[145] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 8878 ~61.23 ms, finishGL 69 / 8803 ~60.712 ms, waitGL 0 / 2 ~0.015 ms +XXX[146] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8944 ~61.263 ms, finishGL 65 / 8868 ~60.745 ms, waitGL 0 / 2 ~0.015 ms +XXX[147] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9010 ~61.293 ms, finishGL 65 / 8934 ~60.776 ms, waitGL 0 / 2 ~0.015 ms +XXX[148] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9076 ~61.329 ms, finishGL 65 / 9000 ~60.811 ms, waitGL 0 / 2 ~0.015 ms +XXX[149] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9143 ~61.365 ms, finishGL 66 / 9066 ~60.847 ms, waitGL 0 / 2 ~0.015 ms +XXX[150] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9208 ~61.393 ms, finishGL 65 / 9131 ~60.875 ms, waitGL 0 / 2 ~0.015 ms +XXX[151] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 9276 ~61.43 ms, finishGL 66 / 9197 ~60.913 ms, waitGL 0 / 2 ~0.015 ms +XXX[152] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9341 ~61.46 ms, finishGL 65 / 9263 ~60.943 ms, waitGL 0 / 2 ~0.015 ms +XXX[153] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 9409 ~61.497 ms, finishGL 66 / 9330 ~60.981 ms, waitGL 0 / 2 ~0.015 ms +XXX[154] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9475 ~61.529 ms, finishGL 65 / 9396 ~61.013 ms, waitGL 0 / 2 ~0.015 ms +XXX[155] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9541 ~61.555 ms, finishGL 65 / 9461 ~61.039 ms, waitGL 0 / 2 ~0.015 ms +XXX[156] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 9608 ~61.595 ms, finishGL 67 / 9528 ~61.08 ms, waitGL 0 / 2 ~0.015 ms +XXX[157] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9674 ~61.623 ms, finishGL 65 / 9594 ~61.109 ms, waitGL 0 / 2 ~0.015 ms +XXX[158] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 9742 ~61.659 ms, finishGL 66 / 9660 ~61.144 ms, waitGL 0 / 2 ~0.015 ms +XXX[159] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9808 ~61.691 ms, finishGL 66 / 9727 ~61.176 ms, waitGL 0 / 2 ~0.015 ms +XXX[160] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9874 ~61.718 ms, finishGL 65 / 9792 ~61.204 ms, waitGL 0 / 2 ~0.015 ms +XXX[161] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9940 ~61.743 ms, finishGL 65 / 9858 ~61.229 ms, waitGL 0 / 2 ~0.015 ms +XXX[162] TO 17 ms, lFrame0 7 ms, lFrameX 68 / 10009 ~61.788 ms, finishGL 61 / 9919 ~61.228 ms, waitGL 0 / 2 ~0.015 ms +XXX[163] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 10071 ~61.788 ms, finishGL 61 / 9980 ~61.229 ms, waitGL 0 / 2 ~0.015 ms +XXX[164] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10137 ~61.813 ms, finishGL 65 / 10045 ~61.255 ms, waitGL 0 / 2 ~0.015 ms +XXX[165] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10203 ~61.841 ms, finishGL 65 / 10111 ~61.283 ms, waitGL 0 / 2 ~0.015 ms +XXX[166] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 10269 ~61.866 ms, finishGL 65 / 10177 ~61.308 ms, waitGL 0 / 2 ~0.015 ms +XXX[167] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10336 ~61.893 ms, finishGL 65 / 10243 ~61.336 ms, waitGL 0 / 2 ~0.015 ms +XXX[168] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10402 ~61.918 ms, finishGL 65 / 10308 ~61.362 ms, waitGL 0 / 2 ~0.015 ms +XXX[169] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10469 ~61.949 ms, finishGL 66 / 10375 ~61.394 ms, waitGL 0 / 2 ~0.015 ms +XXX[170] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10535 ~61.974 ms, finishGL 65 / 10441 ~61.419 ms, waitGL 0 / 2 ~0.015 ms +XXX[171] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10602 ~62.005 ms, finishGL 66 / 10508 ~61.45 ms, waitGL 0 / 2 ~0.015 ms +XXX[172] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 10668 ~62.027 ms, finishGL 65 / 10573 ~61.473 ms, waitGL 0 / 2 ~0.015 ms +XXX[173] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10736 ~62.058 ms, finishGL 66 / 10640 ~61.505 ms, waitGL 0 / 2 ~0.015 ms +XXX[174] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10803 ~62.087 ms, finishGL 66 / 10706 ~61.534 ms, waitGL 0 / 2 ~0.015 ms +XXX[175] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10869 ~62.114 ms, finishGL 66 / 10773 ~61.561 ms, waitGL 0 / 2 ~0.015 ms +XXX[176] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 10935 ~62.135 ms, finishGL 65 / 10838 ~61.583 ms, waitGL 0 / 2 ~0.015 ms +XXX[177] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11002 ~62.163 ms, finishGL 66 / 10905 ~61.611 ms, waitGL 0 / 2 ~0.016 ms +XXX[178] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11070 ~62.193 ms, finishGL 66 / 10972 ~61.641 ms, waitGL 0 / 2 ~0.016 ms +XXX[179] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11137 ~62.222 ms, finishGL 66 / 11038 ~61.67 ms, waitGL 0 / 2 ~0.016 ms +XXX[180] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11205 ~62.254 ms, finishGL 67 / 11106 ~61.701 ms, waitGL 0 / 2 ~0.016 ms +XXX[181] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11273 ~62.284 ms, finishGL 67 / 11173 ~61.732 ms, waitGL 0 / 2 ~0.016 ms +XXX[182] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11340 ~62.31 ms, finishGL 66 / 11240 ~61.758 ms, waitGL 0 / 2 ~0.016 ms +XXX[183] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11407 ~62.334 ms, finishGL 66 / 11306 ~61.783 ms, waitGL 0 / 2 ~0.016 ms +XXX[184] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 11490 ~62.446 ms, finishGL 82 / 11388 ~61.895 ms, waitGL 0 / 2 ~0.016 ms +XXX[185] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 11558 ~62.479 ms, finishGL 67 / 11456 ~61.928 ms, waitGL 0 / 2 ~0.016 ms +XXX[186] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 11644 ~62.607 ms, finishGL 85 / 11542 ~62.056 ms, waitGL 0 / 2 ~0.016 ms +XXX[187] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 11730 ~62.727 ms, finishGL 84 / 11627 ~62.177 ms, waitGL 0 / 2 ~0.016 ms +XXX[188] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 11815 ~62.849 ms, finishGL 85 / 11712 ~62.299 ms, waitGL 0 / 3 ~0.016 ms +XXX[189] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 11901 ~62.97 ms, finishGL 85 / 11797 ~62.421 ms, waitGL 0 / 3 ~0.016 ms +XXX[190] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 11986 ~63.085 ms, finishGL 84 / 11881 ~62.535 ms, waitGL 0 / 3 ~0.016 ms +XXX[191] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 12070 ~63.197 ms, finishGL 84 / 11965 ~62.648 ms, waitGL 0 / 3 ~0.016 ms +XXX[192] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12154 ~63.303 ms, finishGL 83 / 12048 ~62.755 ms, waitGL 0 / 3 ~0.016 ms +XXX[193] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 12238 ~63.411 ms, finishGL 83 / 12132 ~62.863 ms, waitGL 0 / 3 ~0.016 ms +XXX[194] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 12320 ~63.509 ms, finishGL 81 / 12214 ~62.961 ms, waitGL 0 / 3 ~0.016 ms +XXX[195] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 12405 ~63.617 ms, finishGL 84 / 12298 ~63.07 ms, waitGL 0 / 3 ~0.016 ms +XXX[196] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 12505 ~63.801 ms, finishGL 99 / 12397 ~63.254 ms, waitGL 0 / 3 ~0.016 ms +XXX[197] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 12604 ~63.981 ms, finishGL 98 / 12496 ~63.434 ms, waitGL 0 / 3 ~0.016 ms +XXX[198] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 12685 ~64.067 ms, finishGL 80 / 12576 ~63.52 ms, waitGL 0 / 3 ~0.016 ms +XXX[199] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 12767 ~64.16 ms, finishGL 82 / 12659 ~63.613 ms, waitGL 0 / 3 ~0.016 ms +XXX[200] TO 17 ms, lFrame0 3 ms, lFrameX 80 / 12848 ~64.243 ms, finishGL 77 / 12736 ~63.682 ms, waitGL 0 / 3 ~0.016 ms +XXX[201] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 12927 ~64.317 ms, finishGL 78 / 12814 ~63.754 ms, waitGL 0 / 3 ~0.016 ms +XXX[202] TO 17 ms, lFrame0 0 ms, lFrameX 105 / 13033 ~64.52 ms, finishGL 104 / 12919 ~63.958 ms, waitGL 0 / 3 ~0.016 ms +XXX[203] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13115 ~64.608 ms, finishGL 81 / 13001 ~64.046 ms, waitGL 0 / 3 ~0.016 ms +XXX[204] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 13192 ~64.67 ms, finishGL 76 / 13077 ~64.107 ms, waitGL 0 / 3 ~0.016 ms +XXX[205] TO 17 ms, lFrame0 0 ms, lFrameX 105 / 13298 ~64.869 ms, finishGL 104 / 13182 ~64.306 ms, waitGL 0 / 3 ~0.016 ms +XXX[206] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13380 ~64.952 ms, finishGL 81 / 13264 ~64.39 ms, waitGL 0 / 3 ~0.016 ms +XXX[207] TO 17 ms, lFrame0 0 ms, lFrameX 74 / 13455 ~65.0 ms, finishGL 74 / 13338 ~64.437 ms, waitGL 0 / 3 ~0.016 ms +XXX[208] TO 17 ms, lFrame0 0 ms, lFrameX 106 / 13561 ~65.198 ms, finishGL 105 / 13444 ~64.634 ms, waitGL 0 / 3 ~0.016 ms +XXX[209] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13642 ~65.276 ms, finishGL 81 / 13525 ~64.713 ms, waitGL 0 / 3 ~0.016 ms +XXX[210] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 13713 ~65.303 ms, finishGL 70 / 13595 ~64.74 ms, waitGL 0 / 3 ~0.016 ms +XXX[211] TO 17 ms, lFrame0 0 ms, lFrameX 92 / 13806 ~65.434 ms, finishGL 92 / 13687 ~64.87 ms, waitGL 0 / 3 ~0.015 ms +XXX[212] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13888 ~65.509 ms, finishGL 81 / 13768 ~64.947 ms, waitGL 0 / 3 ~0.015 ms +XXX[213] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 13954 ~65.514 ms, finishGL 65 / 13834 ~64.95 ms, waitGL 0 / 3 ~0.016 ms +XXX[214] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 14053 ~65.668 ms, finishGL 97 / 13932 ~65.104 ms, waitGL 0 / 3 ~0.016 ms +XXX[215] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 14134 ~65.744 ms, finishGL 81 / 14013 ~65.18 ms, waitGL 0 / 3 ~0.015 ms +XXX[216] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 14198 ~65.731 ms, finishGL 62 / 14076 ~65.167 ms, waitGL 0 / 3 ~0.015 ms +XXX[217] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 14285 ~65.83 ms, finishGL 86 / 14162 ~65.266 ms, waitGL 0 / 3 ~0.015 ms +XXX[218] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 14351 ~65.833 ms, finishGL 65 / 14228 ~65.269 ms, waitGL 0 / 3 ~0.016 ms +XXX[219] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 14418 ~65.839 ms, finishGL 66 / 14295 ~65.274 ms, waitGL 0 / 3 ~0.016 ms +XXX[220] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 14506 ~65.938 ms, finishGL 86 / 14382 ~65.373 ms, waitGL 0 / 3 ~0.015 ms +XXX[221] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 14592 ~66.028 ms, finishGL 85 / 14467 ~65.463 ms, waitGL 0 / 3 ~0.015 ms +XXX[222] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 14667 ~66.069 ms, finishGL 74 / 14541 ~65.503 ms, waitGL 0 / 3 ~0.015 ms +XXX[223] TO 17 ms, lFrame0 0 ms, lFrameX 95 / 14763 ~66.203 ms, finishGL 95 / 14636 ~65.636 ms, waitGL 0 / 3 ~0.015 ms +XXX[224] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 14847 ~66.282 ms, finishGL 83 / 14719 ~65.714 ms, waitGL 0 / 3 ~0.015 ms +XXX[225] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 14924 ~66.331 ms, finishGL 76 / 14796 ~65.762 ms, waitGL 0 / 3 ~0.015 ms +XXX[226] TO 17 ms, lFrame0 0 ms, lFrameX 105 / 15029 ~66.503 ms, finishGL 104 / 14901 ~65.934 ms, waitGL 0 / 3 ~0.015 ms +XXX[227] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15112 ~66.574 ms, finishGL 82 / 14983 ~66.006 ms, waitGL 0 / 3 ~0.015 ms +XXX[228] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 15187 ~66.613 ms, finishGL 74 / 15058 ~66.044 ms, waitGL 0 / 3 ~0.015 ms +XXX[229] TO 17 ms, lFrame0 0 ms, lFrameX 106 / 15294 ~66.787 ms, finishGL 106 / 15164 ~66.218 ms, waitGL 0 / 3 ~0.015 ms +XXX[230] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15376 ~66.853 ms, finishGL 81 / 15245 ~66.285 ms, waitGL 0 / 3 ~0.015 ms +XXX[231] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 15449 ~66.88 ms, finishGL 72 / 15317 ~66.311 ms, waitGL 0 / 3 ~0.015 ms +XXX[232] TO 17 ms, lFrame0 0 ms, lFrameX 91 / 15540 ~66.985 ms, finishGL 90 / 15408 ~66.416 ms, waitGL 0 / 3 ~0.015 ms +XXX[233] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15622 ~67.047 ms, finishGL 80 / 15489 ~66.478 ms, waitGL 0 / 3 ~0.015 ms +XXX[234] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 15690 ~67.053 ms, finishGL 67 / 15556 ~66.482 ms, waitGL 0 / 3 ~0.015 ms +XXX[235] TO 17 ms, lFrame0 0 ms, lFrameX 95 / 15786 ~67.174 ms, finishGL 95 / 15652 ~66.605 ms, waitGL 0 / 3 ~0.015 ms +XXX[236] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15867 ~67.236 ms, finishGL 81 / 15733 ~66.666 ms, waitGL 0 / 3 ~0.015 ms +XXX[237] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 15932 ~67.225 ms, finishGL 63 / 15797 ~66.654 ms, waitGL 0 / 3 ~0.015 ms +XXX[238] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 16014 ~67.289 ms, finishGL 82 / 15879 ~66.719 ms, waitGL 0 / 3 ~0.015 ms +XXX[239] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16081 ~67.286 ms, finishGL 66 / 15945 ~66.716 ms, waitGL 0 / 3 ~0.015 ms +XXX[240] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 16144 ~67.268 ms, finishGL 62 / 16007 ~66.699 ms, waitGL 0 / 3 ~0.015 ms +XXX[241] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 16230 ~67.346 ms, finishGL 85 / 16093 ~66.778 ms, waitGL 0 / 3 ~0.015 ms +XXX[242] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16297 ~67.344 ms, finishGL 66 / 16159 ~66.776 ms, waitGL 0 / 3 ~0.015 ms +XXX[243] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 16360 ~67.327 ms, finishGL 62 / 16222 ~66.759 ms, waitGL 0 / 3 ~0.015 ms +XXX[244] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 16446 ~67.403 ms, finishGL 85 / 16307 ~66.834 ms, waitGL 0 / 3 ~0.015 ms +XXX[245] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 16512 ~67.397 ms, finishGL 65 / 16373 ~66.829 ms, waitGL 0 / 3 ~0.015 ms +XXX[246] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 16574 ~67.376 ms, finishGL 61 / 16434 ~66.807 ms, waitGL 0 / 3 ~0.015 ms +XXX[247] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 16662 ~67.458 ms, finishGL 86 / 16521 ~66.888 ms, waitGL 0 / 3 ~0.015 ms +XXX[248] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16730 ~67.46 ms, finishGL 67 / 16588 ~66.89 ms, waitGL 0 / 3 ~0.015 ms +XXX[249] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 16794 ~67.446 ms, finishGL 63 / 16652 ~66.877 ms, waitGL 0 / 3 ~0.015 ms +XXX[250] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 16881 ~67.525 ms, finishGL 86 / 16739 ~66.956 ms, waitGL 0 / 3 ~0.015 ms +XXX[251] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 16966 ~67.594 ms, finishGL 84 / 16823 ~67.025 ms, waitGL 0 / 3 ~0.015 ms +XXX[252] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 17035 ~67.599 ms, finishGL 68 / 16891 ~67.031 ms, waitGL 0 / 3 ~0.015 ms +XXX[253] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 17120 ~67.668 ms, finishGL 84 / 16976 ~67.1 ms, waitGL 0 / 3 ~0.015 ms +XXX[254] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17205 ~67.736 ms, finishGL 84 / 17060 ~67.168 ms, waitGL 0 / 3 ~0.015 ms +XXX[255] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17290 ~67.804 ms, finishGL 84 / 17145 ~67.236 ms, waitGL 0 / 4 ~0.015 ms +XXX[256] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17374 ~67.868 ms, finishGL 83 / 17229 ~67.301 ms, waitGL 0 / 4 ~0.015 ms +XXX[257] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17459 ~67.935 ms, finishGL 84 / 17313 ~67.367 ms, waitGL 0 / 4 ~0.015 ms +XXX[258] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17543 ~67.999 ms, finishGL 83 / 17397 ~67.432 ms, waitGL 0 / 4 ~0.015 ms +XXX[259] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17627 ~68.058 ms, finishGL 82 / 17480 ~67.492 ms, waitGL 0 / 4 ~0.015 ms +FrameCount: 360 - FrameRate: 14.0 +XXX[260] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17710 ~68.119 ms, finishGL 83 / 17563 ~67.553 ms, waitGL 0 / 4 ~0.015 ms +XXX[261] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 17793 ~68.176 ms, finishGL 82 / 17646 ~67.61 ms, waitGL 0 / 4 ~0.015 ms +XXX[262] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17877 ~68.234 ms, finishGL 82 / 17729 ~67.668 ms, waitGL 0 / 4 ~0.015 ms +XXX[263] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 17960 ~68.29 ms, finishGL 82 / 17811 ~67.725 ms, waitGL 0 / 4 ~0.015 ms +XXX[264] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 18042 ~68.342 ms, finishGL 81 / 17893 ~67.777 ms, waitGL 0 / 4 ~0.015 ms +XXX[265] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18125 ~68.396 ms, finishGL 82 / 17975 ~67.832 ms, waitGL 0 / 4 ~0.015 ms +XXX[266] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18207 ~68.451 ms, finishGL 82 / 18058 ~67.887 ms, waitGL 0 / 4 ~0.015 ms +XXX[267] TO 17 ms, lFrame0 8 ms, lFrameX 85 / 18293 ~68.514 ms, finishGL 76 / 18135 ~67.921 ms, waitGL 0 / 4 ~0.015 ms +XXX[268] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 18373 ~68.556 ms, finishGL 79 / 18214 ~67.964 ms, waitGL 0 / 4 ~0.015 ms +XXX[269] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18455 ~68.608 ms, finishGL 82 / 18296 ~68.016 ms, waitGL 0 / 4 ~0.015 ms +XXX[270] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 18537 ~68.656 ms, finishGL 80 / 18377 ~68.064 ms, waitGL 0 / 4 ~0.015 ms +XXX[271] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 18618 ~68.704 ms, finishGL 81 / 18458 ~68.112 ms, waitGL 0 / 4 ~0.015 ms +XXX[272] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18701 ~68.754 ms, finishGL 82 / 18540 ~68.163 ms, waitGL 0 / 4 ~0.015 ms +XXX[273] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18783 ~68.804 ms, finishGL 81 / 18622 ~68.212 ms, waitGL 0 / 4 ~0.015 ms +XXX[274] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 18865 ~68.851 ms, finishGL 81 / 18703 ~68.261 ms, waitGL 0 / 4 ~0.015 ms +XXX[275] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18947 ~68.901 ms, finishGL 82 / 18785 ~68.311 ms, waitGL 0 / 4 ~0.015 ms +XXX[276] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 19029 ~68.948 ms, finishGL 81 / 18867 ~68.359 ms, waitGL 0 / 4 ~0.015 ms +XXX[277] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19112 ~68.998 ms, finishGL 82 / 18949 ~68.408 ms, waitGL 0 / 4 ~0.015 ms +XXX[278] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19195 ~69.047 ms, finishGL 82 / 19031 ~68.459 ms, waitGL 0 / 4 ~0.015 ms +XXX[279] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19277 ~69.095 ms, finishGL 81 / 19113 ~68.507 ms, waitGL 0 / 4 ~0.015 ms +XXX[280] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19360 ~69.143 ms, finishGL 81 / 19195 ~68.555 ms, waitGL 0 / 4 ~0.015 ms +XXX[281] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19442 ~69.19 ms, finishGL 81 / 19277 ~68.602 ms, waitGL 0 / 4 ~0.015 ms +XXX[282] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 19508 ~69.179 ms, finishGL 65 / 19343 ~68.592 ms, waitGL 0 / 4 ~0.015 ms +XXX[283] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19574 ~69.166 ms, finishGL 65 / 19408 ~68.579 ms, waitGL 0 / 4 ~0.015 ms +XXX[284] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19639 ~69.152 ms, finishGL 64 / 19472 ~68.565 ms, waitGL 0 / 4 ~0.015 ms +XXX[285] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19704 ~69.139 ms, finishGL 65 / 19537 ~68.553 ms, waitGL 0 / 4 ~0.015 ms +XXX[286] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19770 ~69.128 ms, finishGL 65 / 19602 ~68.541 ms, waitGL 0 / 4 ~0.015 ms +XXX[287] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19836 ~69.116 ms, finishGL 65 / 19668 ~68.53 ms, waitGL 0 / 4 ~0.015 ms +XXX[288] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19901 ~69.103 ms, finishGL 64 / 19732 ~68.516 ms, waitGL 0 / 4 ~0.015 ms +XXX[289] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19966 ~69.089 ms, finishGL 64 / 19797 ~68.503 ms, waitGL 0 / 4 ~0.015 ms +XXX[290] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 20031 ~69.073 ms, finishGL 64 / 19861 ~68.488 ms, waitGL 0 / 4 ~0.015 ms +XXX[291] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20097 ~69.063 ms, finishGL 65 / 19927 ~68.478 ms, waitGL 0 / 4 ~0.015 ms +XXX[292] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20163 ~69.051 ms, finishGL 65 / 19992 ~68.466 ms, waitGL 0 / 4 ~0.015 ms +XXX[293] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20228 ~69.038 ms, finishGL 64 / 20057 ~68.454 ms, waitGL 0 / 4 ~0.015 ms +XXX[294] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20294 ~69.029 ms, finishGL 65 / 20123 ~68.446 ms, waitGL 0 / 4 ~0.015 ms +XXX[295] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20360 ~69.017 ms, finishGL 64 / 20188 ~68.434 ms, waitGL 0 / 4 ~0.015 ms +XXX[296] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20426 ~69.007 ms, finishGL 65 / 20253 ~68.424 ms, waitGL 0 / 4 ~0.015 ms +XXX[297] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20492 ~68.998 ms, finishGL 65 / 20319 ~68.415 ms, waitGL 0 / 4 ~0.015 ms +XXX[298] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20558 ~68.988 ms, finishGL 65 / 20384 ~68.405 ms, waitGL 0 / 4 ~0.015 ms +XXX[299] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20625 ~68.98 ms, finishGL 66 / 20451 ~68.399 ms, waitGL 0 / 4 ~0.015 ms +XXX[300] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 20692 ~68.975 ms, finishGL 66 / 20518 ~68.393 ms, waitGL 0 / 4 ~0.015 ms +XXX[301] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 20759 ~68.969 ms, finishGL 66 / 20585 ~68.388 ms, waitGL 0 / 4 ~0.015 ms +XXX[302] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 20827 ~68.965 ms, finishGL 67 / 20652 ~68.385 ms, waitGL 0 / 4 ~0.015 ms +XXX[303] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 20894 ~68.96 ms, finishGL 66 / 20719 ~68.38 ms, waitGL 0 / 4 ~0.015 ms +XXX[304] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 20964 ~68.962 ms, finishGL 69 / 20788 ~68.383 ms, waitGL 0 / 4 ~0.015 ms +XXX[305] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 21033 ~68.96 ms, finishGL 67 / 20856 ~68.381 ms, waitGL 0 / 4 ~0.015 ms +XXX[306] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 21103 ~68.966 ms, finishGL 70 / 20926 ~68.388 ms, waitGL 0 / 4 ~0.015 ms +XXX[307] TO 17 ms, lFrame0 0 ms, lFrameX 71 / 21175 ~68.974 ms, finishGL 70 / 20997 ~68.395 ms, waitGL 0 / 4 ~0.015 ms +XXX[308] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 21263 ~69.036 ms, finishGL 87 / 21085 ~68.457 ms, waitGL 0 / 4 ~0.015 ms +XXX[309] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 21349 ~69.092 ms, finishGL 85 / 21170 ~68.513 ms, waitGL 0 / 4 ~0.015 ms +XXX[310] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 21434 ~69.143 ms, finishGL 84 / 21255 ~68.565 ms, waitGL 0 / 4 ~0.015 ms +XXX[311] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 21520 ~69.197 ms, finishGL 85 / 21340 ~68.618 ms, waitGL 0 / 4 ~0.015 ms +XXX[312] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 21603 ~69.24 ms, finishGL 82 / 21422 ~68.662 ms, waitGL 0 / 4 ~0.015 ms +XXX[313] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 21685 ~69.283 ms, finishGL 82 / 21504 ~68.705 ms, waitGL 0 / 4 ~0.015 ms +XXX[314] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 21768 ~69.326 ms, finishGL 82 / 21587 ~68.748 ms, waitGL 0 / 4 ~0.015 ms +XXX[315] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 21853 ~69.374 ms, finishGL 84 / 21671 ~68.797 ms, waitGL 0 / 5 ~0.015 ms +XXX[316] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 21937 ~69.421 ms, finishGL 83 / 21755 ~68.845 ms, waitGL 0 / 5 ~0.015 ms +XXX[317] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 22021 ~69.469 ms, finishGL 83 / 21838 ~68.892 ms, waitGL 0 / 5 ~0.015 ms +XXX[318] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 22121 ~69.564 ms, finishGL 99 / 21938 ~68.987 ms, waitGL 0 / 5 ~0.015 ms +XXX[319] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 22220 ~69.655 ms, finishGL 98 / 22036 ~69.079 ms, waitGL 0 / 5 ~0.015 ms +XXX[320] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22303 ~69.697 ms, finishGL 82 / 22118 ~69.121 ms, waitGL 0 / 5 ~0.015 ms +XXX[321] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 22384 ~69.733 ms, finishGL 80 / 22199 ~69.158 ms, waitGL 0 / 5 ~0.015 ms +XXX[322] TO 17 ms, lFrame0 1 ms, lFrameX 84 / 22468 ~69.778 ms, finishGL 83 / 22282 ~69.201 ms, waitGL 0 / 5 ~0.015 ms +XXX[323] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22551 ~69.818 ms, finishGL 82 / 22365 ~69.241 ms, waitGL 0 / 5 ~0.015 ms +XXX[324] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22634 ~69.859 ms, finishGL 82 / 22447 ~69.282 ms, waitGL 0 / 5 ~0.015 ms +XXX[325] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22717 ~69.899 ms, finishGL 82 / 22530 ~69.323 ms, waitGL 0 / 5 ~0.015 ms +XXX[326] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22800 ~69.941 ms, finishGL 82 / 22613 ~69.365 ms, waitGL 0 / 5 ~0.015 ms +XXX[327] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22883 ~69.98 ms, finishGL 82 / 22695 ~69.404 ms, waitGL 0 / 5 ~0.015 ms +XXX[328] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22967 ~70.022 ms, finishGL 83 / 22778 ~69.447 ms, waitGL 0 / 5 ~0.015 ms +XXX[329] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 23049 ~70.058 ms, finishGL 81 / 22860 ~69.483 ms, waitGL 0 / 5 ~0.015 ms +XXX[330] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 23134 ~70.103 ms, finishGL 84 / 22944 ~69.528 ms, waitGL 0 / 5 ~0.015 ms +XXX[331] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23217 ~70.143 ms, finishGL 83 / 23027 ~69.569 ms, waitGL 0 / 5 ~0.015 ms +XXX[332] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 23301 ~70.186 ms, finishGL 83 / 23111 ~69.612 ms, waitGL 0 / 5 ~0.015 ms +XXX[333] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23384 ~70.222 ms, finishGL 81 / 23192 ~69.648 ms, waitGL 0 / 5 ~0.015 ms +XXX[334] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23467 ~70.262 ms, finishGL 83 / 23275 ~69.688 ms, waitGL 0 / 5 ~0.015 ms +XXX[335] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23550 ~70.299 ms, finishGL 82 / 23357 ~69.725 ms, waitGL 0 / 5 ~0.015 ms +XXX[336] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23633 ~70.336 ms, finishGL 82 / 23440 ~69.762 ms, waitGL 0 / 5 ~0.015 ms +XXX[337] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23715 ~70.373 ms, finishGL 82 / 23522 ~69.799 ms, waitGL 0 / 5 ~0.015 ms +XXX[338] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23798 ~70.409 ms, finishGL 81 / 23604 ~69.835 ms, waitGL 0 / 5 ~0.015 ms +XXX[339] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23881 ~70.445 ms, finishGL 82 / 23686 ~69.872 ms, waitGL 0 / 5 ~0.015 ms +XXX[340] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23964 ~70.483 ms, finishGL 82 / 23769 ~69.909 ms, waitGL 0 / 5 ~0.015 ms +XXX[341] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 24046 ~70.516 ms, finishGL 81 / 23850 ~69.943 ms, waitGL 0 / 5 ~0.015 ms +XXX[342] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24129 ~70.552 ms, finishGL 82 / 23933 ~69.979 ms, waitGL 0 / 5 ~0.015 ms +XXX[343] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24211 ~70.587 ms, finishGL 82 / 24015 ~70.014 ms, waitGL 0 / 5 ~0.015 ms +XXX[344] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24294 ~70.624 ms, finishGL 82 / 24097 ~70.052 ms, waitGL 0 / 5 ~0.015 ms +XXX[345] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24377 ~70.658 ms, finishGL 81 / 24179 ~70.085 ms, waitGL 0 / 5 ~0.015 ms +XXX[346] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24460 ~70.696 ms, finishGL 83 / 24262 ~70.122 ms, waitGL 0 / 5 ~0.015 ms +XXX[347] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24543 ~70.731 ms, finishGL 82 / 24345 ~70.158 ms, waitGL 0 / 5 ~0.015 ms +XXX[348] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24627 ~70.768 ms, finishGL 82 / 24427 ~70.195 ms, waitGL 0 / 5 ~0.015 ms +XXX[349] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24710 ~70.805 ms, finishGL 83 / 24511 ~70.232 ms, waitGL 0 / 5 ~0.015 ms +XXX[350] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24793 ~70.839 ms, finishGL 82 / 24593 ~70.266 ms, waitGL 0 / 5 ~0.015 ms +XXX[351] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24876 ~70.874 ms, finishGL 82 / 24675 ~70.301 ms, waitGL 0 / 5 ~0.015 ms +XXX[352] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24960 ~70.909 ms, finishGL 82 / 24758 ~70.337 ms, waitGL 0 / 5 ~0.015 ms +XXX[353] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25043 ~70.944 ms, finishGL 82 / 24841 ~70.372 ms, waitGL 0 / 5 ~0.015 ms +XXX[354] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25126 ~70.979 ms, finishGL 82 / 24924 ~70.407 ms, waitGL 0 / 5 ~0.015 ms +XXX[355] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25210 ~71.014 ms, finishGL 82 / 25007 ~70.442 ms, waitGL 0 / 5 ~0.015 ms +XXX[356] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25292 ~71.047 ms, finishGL 82 / 25089 ~70.475 ms, waitGL 0 / 5 ~0.015 ms +XXX[357] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25375 ~71.079 ms, finishGL 82 / 25171 ~70.508 ms, waitGL 0 / 5 ~0.015 ms +XXX[358] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25459 ~71.115 ms, finishGL 83 / 25254 ~70.544 ms, waitGL 0 / 5 ~0.015 ms +XXX[359] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25542 ~71.148 ms, finishGL 82 / 25337 ~70.578 ms, waitGL 0 / 5 ~0.015 ms +XXX[360] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25626 ~71.184 ms, finishGL 83 / 25421 ~70.614 ms, waitGL 0 / 5 ~0.015 ms +XXX[361] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25709 ~71.217 ms, finishGL 82 / 25503 ~70.647 ms, waitGL 0 / 5 ~0.015 ms +XXX[362] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25792 ~71.249 ms, finishGL 82 / 25586 ~70.679 ms, waitGL 0 / 5 ~0.015 ms +XXX[363] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25876 ~71.284 ms, finishGL 83 / 25669 ~70.714 ms, waitGL 0 / 5 ~0.015 ms +XXX[364] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 25960 ~71.319 ms, finishGL 83 / 25753 ~70.75 ms, waitGL 0 / 5 ~0.015 ms +XXX[365] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26043 ~71.352 ms, finishGL 82 / 25835 ~70.783 ms, waitGL 0 / 5 ~0.015 ms +XXX[366] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26126 ~71.384 ms, finishGL 82 / 25918 ~70.815 ms, waitGL 0 / 5 ~0.015 ms +XXX[367] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26209 ~71.415 ms, finishGL 82 / 26000 ~70.847 ms, waitGL 0 / 5 ~0.015 ms +XXX[368] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26293 ~71.448 ms, finishGL 83 / 26083 ~70.88 ms, waitGL 0 / 5 ~0.015 ms +XXX[369] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26376 ~71.481 ms, finishGL 82 / 26166 ~70.912 ms, waitGL 0 / 5 ~0.015 ms +XXX[370] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26459 ~71.511 ms, finishGL 82 / 26248 ~70.943 ms, waitGL 0 / 5 ~0.015 ms +XXX[371] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26542 ~71.542 ms, finishGL 82 / 26331 ~70.973 ms, waitGL 0 / 5 ~0.015 ms +XXX[372] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26625 ~71.574 ms, finishGL 82 / 26414 ~71.006 ms, waitGL 0 / 5 ~0.015 ms +XXX[373] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26707 ~71.603 ms, finishGL 81 / 26495 ~71.034 ms, waitGL 0 / 5 ~0.015 ms +XXX[374] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26790 ~71.633 ms, finishGL 82 / 26578 ~71.065 ms, waitGL 0 / 5 ~0.015 ms +XXX[375] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26873 ~71.663 ms, finishGL 82 / 26660 ~71.095 ms, waitGL 0 / 5 ~0.015 ms +XXX[376] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26956 ~71.694 ms, finishGL 82 / 26743 ~71.126 ms, waitGL 0 / 5 ~0.015 ms +XXX[377] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27039 ~71.723 ms, finishGL 82 / 26825 ~71.155 ms, waitGL 0 / 5 ~0.015 ms +XXX[378] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27122 ~71.751 ms, finishGL 81 / 26907 ~71.184 ms, waitGL 0 / 6 ~0.015 ms +XXX[379] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27205 ~71.781 ms, finishGL 82 / 26990 ~71.214 ms, waitGL 0 / 6 ~0.015 ms +FrameCount: 480 - FrameRate: 12.0 +XXX[380] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27287 ~71.81 ms, finishGL 82 / 27072 ~71.243 ms, waitGL 0 / 6 ~0.015 ms +XXX[381] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27370 ~71.838 ms, finishGL 82 / 27154 ~71.271 ms, waitGL 0 / 6 ~0.015 ms +XXX[382] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27453 ~71.867 ms, finishGL 82 / 27236 ~71.3 ms, waitGL 0 / 6 ~0.015 ms +XXX[383] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27535 ~71.894 ms, finishGL 81 / 27318 ~71.328 ms, waitGL 0 / 6 ~0.015 ms +XXX[384] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27618 ~71.922 ms, finishGL 82 / 27400 ~71.356 ms, waitGL 0 / 6 ~0.015 ms +XXX[385] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 27702 ~71.953 ms, finishGL 83 / 27484 ~71.387 ms, waitGL 0 / 6 ~0.015 ms +XXX[386] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27785 ~71.983 ms, finishGL 82 / 27567 ~71.417 ms, waitGL 0 / 6 ~0.015 ms +XXX[387] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27869 ~72.013 ms, finishGL 83 / 27650 ~71.447 ms, waitGL 0 / 6 ~0.015 ms +XXX[388] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27952 ~72.043 ms, finishGL 83 / 27733 ~71.478 ms, waitGL 0 / 6 ~0.015 ms +XXX[389] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 28038 ~72.077 ms, finishGL 84 / 27818 ~71.512 ms, waitGL 0 / 6 ~0.015 ms +XXX[390] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 28123 ~72.11 ms, finishGL 84 / 27902 ~71.545 ms, waitGL 0 / 6 ~0.015 ms +XXX[391] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 28207 ~72.141 ms, finishGL 83 / 27986 ~71.576 ms, waitGL 0 / 6 ~0.015 ms +XXX[392] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28290 ~72.17 ms, finishGL 83 / 28069 ~71.606 ms, waitGL 0 / 6 ~0.015 ms +XXX[393] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28374 ~72.198 ms, finishGL 82 / 28152 ~71.634 ms, waitGL 0 / 6 ~0.015 ms +XXX[394] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28457 ~72.227 ms, finishGL 82 / 28235 ~71.663 ms, waitGL 0 / 6 ~0.015 ms +XXX[395] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28540 ~72.254 ms, finishGL 82 / 28317 ~71.69 ms, waitGL 0 / 6 ~0.015 ms +XXX[396] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28623 ~72.281 ms, finishGL 82 / 28400 ~71.718 ms, waitGL 0 / 6 ~0.015 ms +XXX[397] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28706 ~72.309 ms, finishGL 83 / 28483 ~71.746 ms, waitGL 0 / 6 ~0.015 ms +XXX[398] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28789 ~72.336 ms, finishGL 82 / 28565 ~71.773 ms, waitGL 0 / 6 ~0.015 ms +XXX[399] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28872 ~72.362 ms, finishGL 82 / 28648 ~71.8 ms, waitGL 0 / 6 ~0.015 ms +XXX[400] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28955 ~72.388 ms, finishGL 82 / 28730 ~71.826 ms, waitGL 0 / 6 ~0.015 ms +XXX[401] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 29036 ~72.409 ms, finishGL 80 / 28810 ~71.847 ms, waitGL 0 / 6 ~0.015 ms +XXX[402] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29118 ~72.434 ms, finishGL 82 / 28893 ~71.873 ms, waitGL 0 / 6 ~0.015 ms +XXX[403] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29200 ~72.458 ms, finishGL 81 / 28974 ~71.897 ms, waitGL 0 / 6 ~0.015 ms +XXX[404] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29283 ~72.483 ms, finishGL 82 / 29056 ~71.922 ms, waitGL 0 / 6 ~0.015 ms +XXX[405] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29366 ~72.509 ms, finishGL 82 / 29139 ~71.948 ms, waitGL 0 / 6 ~0.015 ms +XXX[406] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29449 ~72.534 ms, finishGL 82 / 29221 ~71.973 ms, waitGL 0 / 6 ~0.015 ms +XXX[407] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29531 ~72.559 ms, finishGL 82 / 29303 ~71.998 ms, waitGL 0 / 6 ~0.015 ms +XXX[408] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29614 ~72.585 ms, finishGL 82 / 29385 ~72.024 ms, waitGL 0 / 6 ~0.015 ms +XXX[409] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29697 ~72.61 ms, finishGL 82 / 29468 ~72.049 ms, waitGL 0 / 6 ~0.015 ms +XXX[410] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29780 ~72.634 ms, finishGL 81 / 29550 ~72.073 ms, waitGL 0 / 6 ~0.015 ms +XXX[411] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29863 ~72.659 ms, finishGL 82 / 29632 ~72.099 ms, waitGL 0 / 6 ~0.015 ms +XXX[412] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29946 ~72.685 ms, finishGL 82 / 29715 ~72.125 ms, waitGL 0 / 6 ~0.015 ms +XXX[413] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 30030 ~72.713 ms, finishGL 83 / 29799 ~72.153 ms, waitGL 0 / 6 ~0.015 ms +XXX[414] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30113 ~72.738 ms, finishGL 82 / 29881 ~72.178 ms, waitGL 0 / 6 ~0.015 ms +XXX[415] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30196 ~72.762 ms, finishGL 82 / 29964 ~72.202 ms, waitGL 0 / 6 ~0.015 ms +XXX[416] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30279 ~72.787 ms, finishGL 82 / 30046 ~72.228 ms, waitGL 0 / 6 ~0.015 ms +XXX[417] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 30361 ~72.809 ms, finishGL 81 / 30128 ~72.25 ms, waitGL 0 / 6 ~0.015 ms +XXX[418] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30445 ~72.835 ms, finishGL 82 / 30211 ~72.275 ms, waitGL 0 / 6 ~0.015 ms +XXX[419] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30527 ~72.857 ms, finishGL 81 / 30292 ~72.297 ms, waitGL 0 / 6 ~0.015 ms +XXX[420] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 30611 ~72.884 ms, finishGL 83 / 30376 ~72.325 ms, waitGL 0 / 6 ~0.015 ms +XXX[421] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30695 ~72.911 ms, finishGL 83 / 30460 ~72.351 ms, waitGL 0 / 6 ~0.015 ms +XXX[422] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 30779 ~72.937 ms, finishGL 83 / 30543 ~72.378 ms, waitGL 0 / 6 ~0.015 ms +XXX[423] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30863 ~72.963 ms, finishGL 83 / 30627 ~72.404 ms, waitGL 0 / 6 ~0.015 ms +XXX[424] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 30945 ~72.984 ms, finishGL 81 / 30708 ~72.425 ms, waitGL 0 / 6 ~0.015 ms +XXX[425] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 31025 ~73.0 ms, finishGL 79 / 30787 ~72.441 ms, waitGL 0 / 6 ~0.015 ms +XXX[426] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 31105 ~73.017 ms, finishGL 79 / 30867 ~72.458 ms, waitGL 0 / 6 ~0.015 ms +XXX[427] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 31185 ~73.034 ms, finishGL 80 / 30947 ~72.476 ms, waitGL 0 / 6 ~0.015 ms +XXX[428] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 31250 ~73.015 ms, finishGL 64 / 31011 ~72.456 ms, waitGL 0 / 6 ~0.015 ms +XXX[429] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31316 ~72.999 ms, finishGL 65 / 31077 ~72.441 ms, waitGL 0 / 6 ~0.015 ms +XXX[430] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31382 ~72.982 ms, finishGL 65 / 31142 ~72.424 ms, waitGL 0 / 6 ~0.015 ms +XXX[431] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31448 ~72.966 ms, finishGL 65 / 31208 ~72.408 ms, waitGL 0 / 6 ~0.015 ms +XXX[432] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31514 ~72.95 ms, finishGL 65 / 31273 ~72.392 ms, waitGL 0 / 6 ~0.015 ms +XXX[433] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31580 ~72.933 ms, finishGL 65 / 31338 ~72.376 ms, waitGL 0 / 6 ~0.015 ms +XXX[434] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31646 ~72.918 ms, finishGL 65 / 31404 ~72.361 ms, waitGL 0 / 6 ~0.015 ms +XXX[435] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31712 ~72.901 ms, finishGL 64 / 31469 ~72.344 ms, waitGL 0 / 6 ~0.015 ms +XXX[436] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31778 ~72.886 ms, finishGL 66 / 31535 ~72.329 ms, waitGL 0 / 6 ~0.015 ms +XXX[437] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31844 ~72.871 ms, finishGL 65 / 31601 ~72.314 ms, waitGL 0 / 6 ~0.015 ms +XXX[438] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31911 ~72.856 ms, finishGL 65 / 31667 ~72.299 ms, waitGL 0 / 6 ~0.015 ms +XXX[439] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31977 ~72.842 ms, finishGL 66 / 31733 ~72.285 ms, waitGL 0 / 7 ~0.015 ms +XXX[440] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32044 ~72.827 ms, finishGL 65 / 31799 ~72.271 ms, waitGL 0 / 7 ~0.015 ms +XXX[441] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32111 ~72.815 ms, finishGL 66 / 31866 ~72.258 ms, waitGL 0 / 7 ~0.015 ms +XXX[442] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32178 ~72.801 ms, finishGL 66 / 31932 ~72.245 ms, waitGL 0 / 7 ~0.015 ms +XXX[443] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32245 ~72.788 ms, finishGL 66 / 31999 ~72.233 ms, waitGL 0 / 7 ~0.015 ms +XXX[444] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32312 ~72.775 ms, finishGL 66 / 32065 ~72.22 ms, waitGL 0 / 7 ~0.015 ms +XXX[445] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32378 ~72.761 ms, finishGL 65 / 32131 ~72.205 ms, waitGL 0 / 7 ~0.015 ms +XXX[446] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32446 ~72.749 ms, finishGL 66 / 32198 ~72.193 ms, waitGL 0 / 7 ~0.015 ms +XXX[447] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32512 ~72.734 ms, finishGL 66 / 32264 ~72.179 ms, waitGL 0 / 7 ~0.015 ms +XXX[448] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32578 ~72.72 ms, finishGL 65 / 32330 ~72.165 ms, waitGL 0 / 7 ~0.015 ms +XXX[449] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32645 ~72.707 ms, finishGL 66 / 32396 ~72.152 ms, waitGL 0 / 7 ~0.015 ms +XXX[450] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32711 ~72.692 ms, finishGL 65 / 32462 ~72.138 ms, waitGL 0 / 7 ~0.015 ms +XXX[451] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32777 ~72.678 ms, finishGL 65 / 32528 ~72.124 ms, waitGL 0 / 7 ~0.015 ms +XXX[452] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32844 ~72.665 ms, finishGL 66 / 32594 ~72.111 ms, waitGL 0 / 7 ~0.015 ms +XXX[453] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32910 ~72.65 ms, finishGL 65 / 32659 ~72.096 ms, waitGL 0 / 7 ~0.015 ms +XXX[454] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32976 ~72.635 ms, finishGL 65 / 32725 ~72.081 ms, waitGL 0 / 7 ~0.015 ms +XXX[455] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33042 ~72.621 ms, finishGL 65 / 32790 ~72.067 ms, waitGL 0 / 7 ~0.015 ms +XXX[456] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 33107 ~72.604 ms, finishGL 64 / 32855 ~72.05 ms, waitGL 0 / 7 ~0.015 ms +XXX[457] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33173 ~72.589 ms, finishGL 65 / 32920 ~72.036 ms, waitGL 0 / 7 ~0.015 ms +XXX[458] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33239 ~72.574 ms, finishGL 65 / 32985 ~72.021 ms, waitGL 0 / 7 ~0.015 ms +XXX[459] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33304 ~72.558 ms, finishGL 64 / 33050 ~72.005 ms, waitGL 0 / 7 ~0.015 ms +XXX[460] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33370 ~72.544 ms, finishGL 65 / 33115 ~71.991 ms, waitGL 0 / 7 ~0.015 ms +XXX[461] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33435 ~72.529 ms, finishGL 65 / 33181 ~71.976 ms, waitGL 0 / 7 ~0.015 ms +XXX[462] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33500 ~72.512 ms, finishGL 64 / 33245 ~71.96 ms, waitGL 0 / 7 ~0.015 ms +XXX[463] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 33567 ~72.499 ms, finishGL 65 / 33311 ~71.947 ms, waitGL 0 / 7 ~0.015 ms +XXX[464] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33632 ~72.484 ms, finishGL 64 / 33376 ~71.932 ms, waitGL 0 / 7 ~0.016 ms +XXX[465] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33698 ~72.469 ms, finishGL 65 / 33441 ~71.917 ms, waitGL 0 / 7 ~0.016 ms +XXX[466] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33764 ~72.455 ms, finishGL 65 / 33507 ~71.903 ms, waitGL 0 / 7 ~0.016 ms +XXX[467] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 33813 ~72.404 ms, finishGL 48 / 33555 ~71.853 ms, waitGL 0 / 7 ~0.016 ms +XXX[468] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33862 ~72.355 ms, finishGL 48 / 33604 ~71.803 ms, waitGL 0 / 7 ~0.016 ms +XXX[469] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33911 ~72.305 ms, finishGL 48 / 33652 ~71.754 ms, waitGL 0 / 7 ~0.016 ms +XXX[470] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33960 ~72.256 ms, finishGL 48 / 33701 ~71.704 ms, waitGL 0 / 7 ~0.016 ms +XXX[471] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34009 ~72.207 ms, finishGL 48 / 33749 ~71.655 ms, waitGL 0 / 7 ~0.016 ms +XXX[472] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34058 ~72.158 ms, finishGL 48 / 33798 ~71.606 ms, waitGL 0 / 7 ~0.016 ms +XXX[473] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34108 ~72.11 ms, finishGL 49 / 33847 ~71.559 ms, waitGL 0 / 7 ~0.016 ms +XXX[474] TO 17 ms, lFrame0 0 ms, lFrameX 47 / 34155 ~72.058 ms, finishGL 47 / 33894 ~71.507 ms, waitGL 0 / 7 ~0.016 ms +XXX[475] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 34206 ~72.014 ms, finishGL 50 / 33945 ~71.463 ms, waitGL 0 / 7 ~0.016 ms +XXX[476] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34255 ~71.965 ms, finishGL 48 / 33993 ~71.415 ms, waitGL 0 / 7 ~0.016 ms +XXX[477] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34305 ~71.918 ms, finishGL 48 / 34042 ~71.367 ms, waitGL 0 / 7 ~0.016 ms +XXX[478] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34353 ~71.869 ms, finishGL 48 / 34090 ~71.319 ms, waitGL 0 / 7 ~0.016 ms +XXX[479] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34403 ~71.822 ms, finishGL 48 / 34139 ~71.271 ms, waitGL 0 / 7 ~0.016 ms +XXX[480] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34452 ~71.775 ms, finishGL 48 / 34187 ~71.224 ms, waitGL 0 / 7 ~0.016 ms +XXX[481] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34500 ~71.727 ms, finishGL 48 / 34236 ~71.176 ms, waitGL 0 / 7 ~0.016 ms +XXX[482] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34550 ~71.681 ms, finishGL 48 / 34285 ~71.13 ms, waitGL 0 / 7 ~0.016 ms +XXX[483] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34599 ~71.634 ms, finishGL 48 / 34333 ~71.083 ms, waitGL 0 / 7 ~0.016 ms +XXX[484] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34648 ~71.587 ms, finishGL 48 / 34382 ~71.037 ms, waitGL 0 / 7 ~0.016 ms +XXX[485] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34697 ~71.54 ms, finishGL 48 / 34430 ~70.99 ms, waitGL 0 / 7 ~0.016 ms +XXX[486] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34746 ~71.495 ms, finishGL 48 / 34479 ~70.944 ms, waitGL 0 / 7 ~0.016 ms +XXX[487] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34796 ~71.45 ms, finishGL 49 / 34528 ~70.9 ms, waitGL 0 / 7 ~0.016 ms +XXX[488] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34845 ~71.405 ms, finishGL 49 / 34577 ~70.855 ms, waitGL 0 / 7 ~0.016 ms +XXX[489] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34895 ~71.36 ms, finishGL 48 / 34626 ~70.81 ms, waitGL 0 / 7 ~0.016 ms +XXX[490] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 34945 ~71.317 ms, finishGL 49 / 34675 ~70.767 ms, waitGL 0 / 7 ~0.016 ms +XXX[491] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34995 ~71.274 ms, finishGL 49 / 34725 ~70.723 ms, waitGL 0 / 7 ~0.016 ms +XXX[492] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35045 ~71.231 ms, finishGL 49 / 34775 ~70.68 ms, waitGL 0 / 7 ~0.016 ms +XXX[493] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35095 ~71.187 ms, finishGL 49 / 34824 ~70.637 ms, waitGL 0 / 7 ~0.016 ms +XXX[494] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35144 ~71.143 ms, finishGL 49 / 34873 ~70.593 ms, waitGL 0 / 7 ~0.016 ms +XXX[495] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35195 ~71.101 ms, finishGL 49 / 34922 ~70.551 ms, waitGL 0 / 7 ~0.016 ms +XXX[496] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 35246 ~71.06 ms, finishGL 50 / 34973 ~70.511 ms, waitGL 0 / 7 ~0.016 ms +XXX[497] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35296 ~71.019 ms, finishGL 49 / 35023 ~70.469 ms, waitGL 0 / 8 ~0.016 ms +XXX[498] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35346 ~70.976 ms, finishGL 49 / 35072 ~70.427 ms, waitGL 0 / 8 ~0.016 ms +XXX[499] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35396 ~70.935 ms, finishGL 49 / 35122 ~70.386 ms, waitGL 0 / 8 ~0.016 ms +FrameCount: 600 - FrameRate: 19.0 +XXX[500] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35447 ~70.894 ms, finishGL 49 / 35172 ~70.345 ms, waitGL 0 / 8 ~0.016 ms +XXX[501] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35497 ~70.853 ms, finishGL 49 / 35222 ~70.304 ms, waitGL 0 / 8 ~0.016 ms +XXX[502] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35547 ~70.812 ms, finishGL 50 / 35272 ~70.263 ms, waitGL 0 / 8 ~0.016 ms +XXX[503] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35598 ~70.771 ms, finishGL 49 / 35322 ~70.223 ms, waitGL 0 / 8 ~0.016 ms +XXX[504] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35648 ~70.73 ms, finishGL 49 / 35371 ~70.181 ms, waitGL 0 / 8 ~0.016 ms +XXX[505] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35698 ~70.69 ms, finishGL 49 / 35421 ~70.141 ms, waitGL 0 / 8 ~0.016 ms +XXX[506] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35748 ~70.649 ms, finishGL 49 / 35470 ~70.1 ms, waitGL 0 / 8 ~0.016 ms +XXX[507] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35798 ~70.609 ms, finishGL 49 / 35520 ~70.06 ms, waitGL 0 / 8 ~0.016 ms +XXX[508] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35849 ~70.568 ms, finishGL 49 / 35570 ~70.02 ms, waitGL 0 / 8 ~0.016 ms +XXX[509] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35899 ~70.528 ms, finishGL 49 / 35620 ~69.98 ms, waitGL 0 / 8 ~0.016 ms +XXX[510] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35949 ~70.488 ms, finishGL 49 / 35669 ~69.94 ms, waitGL 0 / 8 ~0.016 ms +XXX[511] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35999 ~70.449 ms, finishGL 49 / 35719 ~69.9 ms, waitGL 0 / 8 ~0.016 ms +XXX[512] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 36050 ~70.41 ms, finishGL 50 / 35769 ~69.862 ms, waitGL 0 / 8 ~0.016 ms +XXX[513] TO 17 ms, lFrame0 0 ms, lFrameX 52 / 36102 ~70.375 ms, finishGL 51 / 35821 ~69.827 ms, waitGL 0 / 8 ~0.016 ms +XXX[514] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 36153 ~70.338 ms, finishGL 50 / 35872 ~69.79 ms, waitGL 0 / 8 ~0.016 ms +XXX[515] TO 17 ms, lFrame0 0 ms, lFrameX 53 / 36207 ~70.306 ms, finishGL 53 / 35925 ~69.758 ms, waitGL 0 / 8 ~0.016 ms +XXX[516] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 36276 ~70.302 ms, finishGL 67 / 35993 ~69.755 ms, waitGL 0 / 8 ~0.016 ms +XXX[517] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 36346 ~70.302 ms, finishGL 69 / 36063 ~69.755 ms, waitGL 0 / 8 ~0.016 ms +XXX[518] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 36421 ~70.311 ms, finishGL 74 / 36137 ~69.764 ms, waitGL 0 / 8 ~0.016 ms +XXX[519] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 36497 ~70.322 ms, finishGL 75 / 36213 ~69.775 ms, waitGL 0 / 8 ~0.016 ms +XXX[520] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 36583 ~70.353 ms, finishGL 85 / 36299 ~69.806 ms, waitGL 0 / 8 ~0.016 ms +XXX[521] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36666 ~70.377 ms, finishGL 82 / 36381 ~69.83 ms, waitGL 0 / 8 ~0.016 ms +XXX[522] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36749 ~70.401 ms, finishGL 82 / 36464 ~69.855 ms, waitGL 0 / 8 ~0.016 ms +XXX[523] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36833 ~70.426 ms, finishGL 82 / 36547 ~69.879 ms, waitGL 0 / 8 ~0.016 ms +XXX[524] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36915 ~70.449 ms, finishGL 82 / 36629 ~69.903 ms, waitGL 0 / 8 ~0.016 ms +XXX[525] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36998 ~70.473 ms, finishGL 82 / 36711 ~69.927 ms, waitGL 0 / 8 ~0.016 ms +XXX[526] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37081 ~70.497 ms, finishGL 82 / 36794 ~69.951 ms, waitGL 0 / 8 ~0.016 ms +XXX[527] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37165 ~70.522 ms, finishGL 82 / 36877 ~69.976 ms, waitGL 0 / 8 ~0.016 ms +XXX[528] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37248 ~70.547 ms, finishGL 83 / 36960 ~70.001 ms, waitGL 0 / 8 ~0.016 ms +XXX[529] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37332 ~70.572 ms, finishGL 83 / 37043 ~70.026 ms, waitGL 0 / 8 ~0.016 ms +XXX[530] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37415 ~70.595 ms, finishGL 82 / 37126 ~70.049 ms, waitGL 0 / 8 ~0.016 ms +XXX[531] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37498 ~70.619 ms, finishGL 82 / 37209 ~70.073 ms, waitGL 0 / 8 ~0.016 ms +XXX[532] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37582 ~70.643 ms, finishGL 82 / 37291 ~70.097 ms, waitGL 0 / 8 ~0.016 ms +XXX[533] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37665 ~70.667 ms, finishGL 82 / 37374 ~70.121 ms, waitGL 0 / 8 ~0.016 ms +XXX[534] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37749 ~70.691 ms, finishGL 82 / 37457 ~70.145 ms, waitGL 0 / 8 ~0.016 ms +XXX[535] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37832 ~70.714 ms, finishGL 82 / 37540 ~70.168 ms, waitGL 0 / 8 ~0.016 ms +XXX[536] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37914 ~70.735 ms, finishGL 81 / 37621 ~70.19 ms, waitGL 0 / 8 ~0.016 ms +XXX[537] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37997 ~70.757 ms, finishGL 82 / 37704 ~70.212 ms, waitGL 0 / 8 ~0.016 ms +XXX[538] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38080 ~70.78 ms, finishGL 82 / 37786 ~70.235 ms, waitGL 0 / 8 ~0.016 ms +XXX[539] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38162 ~70.802 ms, finishGL 82 / 37868 ~70.257 ms, waitGL 0 / 8 ~0.016 ms +XXX[540] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38245 ~70.825 ms, finishGL 82 / 37951 ~70.279 ms, waitGL 0 / 8 ~0.016 ms +XXX[541] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38329 ~70.848 ms, finishGL 82 / 38034 ~70.303 ms, waitGL 0 / 8 ~0.016 ms +XXX[542] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38412 ~70.871 ms, finishGL 82 / 38116 ~70.325 ms, waitGL 0 / 8 ~0.016 ms +XXX[543] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38495 ~70.894 ms, finishGL 83 / 38199 ~70.349 ms, waitGL 0 / 8 ~0.016 ms +XXX[544] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38579 ~70.917 ms, finishGL 82 / 38282 ~70.372 ms, waitGL 0 / 8 ~0.016 ms +XXX[545] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38662 ~70.94 ms, finishGL 82 / 38365 ~70.395 ms, waitGL 0 / 8 ~0.016 ms +XXX[546] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38745 ~70.962 ms, finishGL 82 / 38447 ~70.417 ms, waitGL 0 / 8 ~0.016 ms +XXX[547] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 38829 ~70.986 ms, finishGL 83 / 38531 ~70.441 ms, waitGL 0 / 8 ~0.016 ms +XXX[548] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38913 ~71.01 ms, finishGL 83 / 38614 ~70.465 ms, waitGL 0 / 8 ~0.016 ms +XXX[549] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 38997 ~71.034 ms, finishGL 83 / 38698 ~70.488 ms, waitGL 0 / 8 ~0.016 ms +XXX[550] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 39081 ~71.057 ms, finishGL 83 / 38781 ~70.512 ms, waitGL 0 / 8 ~0.016 ms +XXX[551] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39165 ~71.08 ms, finishGL 83 / 38864 ~70.535 ms, waitGL 0 / 8 ~0.016 ms +XXX[552] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39248 ~71.101 ms, finishGL 82 / 38947 ~70.556 ms, waitGL 0 / 8 ~0.016 ms +XXX[553] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39331 ~71.123 ms, finishGL 82 / 39029 ~70.578 ms, waitGL 0 / 8 ~0.016 ms +XXX[554] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39413 ~71.143 ms, finishGL 81 / 39111 ~70.598 ms, waitGL 0 / 8 ~0.016 ms +XXX[555] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39495 ~71.163 ms, finishGL 82 / 39193 ~70.619 ms, waitGL 0 / 8 ~0.016 ms +XXX[556] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39578 ~71.183 ms, finishGL 81 / 39275 ~70.639 ms, waitGL 0 / 8 ~0.016 ms +XXX[557] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39660 ~71.203 ms, finishGL 81 / 39357 ~70.659 ms, waitGL 0 / 8 ~0.016 ms +XXX[558] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39742 ~71.223 ms, finishGL 81 / 39438 ~70.678 ms, waitGL 0 / 9 ~0.016 ms +XXX[559] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39824 ~71.243 ms, finishGL 81 / 39520 ~70.698 ms, waitGL 0 / 9 ~0.016 ms +XXX[560] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39907 ~71.263 ms, finishGL 82 / 39603 ~70.719 ms, waitGL 0 / 9 ~0.016 ms +XXX[561] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 39987 ~71.279 ms, finishGL 79 / 39682 ~70.735 ms, waitGL 0 / 9 ~0.016 ms +XXX[562] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 40069 ~71.297 ms, finishGL 80 / 39763 ~70.753 ms, waitGL 0 / 9 ~0.016 ms +XXX[563] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 40150 ~71.315 ms, finishGL 80 / 39844 ~70.771 ms, waitGL 0 / 9 ~0.016 ms +XXX[564] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 40231 ~71.332 ms, finishGL 80 / 39925 ~70.789 ms, waitGL 0 / 9 ~0.016 ms +XXX[565] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 40314 ~71.352 ms, finishGL 82 / 40007 ~70.809 ms, waitGL 0 / 9 ~0.016 ms +XXX[566] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 40378 ~71.339 ms, finishGL 63 / 40070 ~70.796 ms, waitGL 0 / 9 ~0.016 ms +XXX[567] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40444 ~71.329 ms, finishGL 65 / 40135 ~70.786 ms, waitGL 0 / 9 ~0.016 ms +XXX[568] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40509 ~71.319 ms, finishGL 64 / 40200 ~70.776 ms, waitGL 0 / 9 ~0.016 ms +XXX[569] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40575 ~71.309 ms, finishGL 65 / 40266 ~70.766 ms, waitGL 0 / 9 ~0.016 ms +XXX[570] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40640 ~71.299 ms, finishGL 65 / 40331 ~70.756 ms, waitGL 0 / 9 ~0.016 ms +XXX[571] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40707 ~71.291 ms, finishGL 65 / 40397 ~70.748 ms, waitGL 0 / 9 ~0.016 ms +XXX[572] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40773 ~71.281 ms, finishGL 65 / 40462 ~70.738 ms, waitGL 0 / 9 ~0.016 ms +XXX[573] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40838 ~71.271 ms, finishGL 65 / 40527 ~70.728 ms, waitGL 0 / 9 ~0.016 ms +XXX[574] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 40905 ~71.264 ms, finishGL 66 / 40594 ~70.721 ms, waitGL 0 / 9 ~0.016 ms +XXX[575] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 40973 ~71.257 ms, finishGL 66 / 40660 ~70.714 ms, waitGL 0 / 9 ~0.016 ms +XXX[576] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 41039 ~71.249 ms, finishGL 66 / 40727 ~70.706 ms, waitGL 0 / 9 ~0.016 ms +XXX[577] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 41107 ~71.243 ms, finishGL 66 / 40794 ~70.7 ms, waitGL 0 / 9 ~0.016 ms +XXX[578] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 41176 ~71.24 ms, finishGL 69 / 40863 ~70.697 ms, waitGL 0 / 9 ~0.016 ms +XXX[579] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 41246 ~71.238 ms, finishGL 69 / 40932 ~70.695 ms, waitGL 0 / 9 ~0.016 ms +XXX[580] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 41336 ~71.269 ms, finishGL 88 / 41021 ~70.726 ms, waitGL 0 / 9 ~0.016 ms +XXX[581] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 41424 ~71.298 ms, finishGL 87 / 41109 ~70.755 ms, waitGL 0 / 9 ~0.016 ms +XXX[582] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 41510 ~71.323 ms, finishGL 85 / 41194 ~70.78 ms, waitGL 0 / 9 ~0.016 ms +XXX[583] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 41594 ~71.345 ms, finishGL 83 / 41278 ~70.803 ms, waitGL 0 / 9 ~0.016 ms +XXX[584] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41676 ~71.364 ms, finishGL 81 / 41360 ~70.822 ms, waitGL 0 / 9 ~0.016 ms +XXX[585] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 41757 ~71.38 ms, finishGL 80 / 41440 ~70.838 ms, waitGL 0 / 9 ~0.016 ms +XXX[586] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 41839 ~71.398 ms, finishGL 81 / 41521 ~70.856 ms, waitGL 0 / 9 ~0.016 ms +XXX[587] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41922 ~71.417 ms, finishGL 82 / 41604 ~70.875 ms, waitGL 0 / 9 ~0.016 ms +XXX[588] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42004 ~71.436 ms, finishGL 81 / 41686 ~70.894 ms, waitGL 0 / 9 ~0.016 ms +XXX[589] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42088 ~71.456 ms, finishGL 82 / 41769 ~70.915 ms, waitGL 0 / 9 ~0.016 ms +XXX[590] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42170 ~71.475 ms, finishGL 81 / 41851 ~70.934 ms, waitGL 0 / 9 ~0.016 ms +XXX[591] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42253 ~71.495 ms, finishGL 82 / 41933 ~70.953 ms, waitGL 0 / 9 ~0.016 ms +XXX[592] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42336 ~71.514 ms, finishGL 82 / 42016 ~70.973 ms, waitGL 0 / 9 ~0.016 ms +XXX[593] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42420 ~71.535 ms, finishGL 83 / 42099 ~70.994 ms, waitGL 0 / 9 ~0.016 ms +XXX[594] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42503 ~71.555 ms, finishGL 82 / 42182 ~71.013 ms, waitGL 0 / 9 ~0.016 ms +XXX[595] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 42588 ~71.577 ms, finishGL 84 / 42266 ~71.035 ms, waitGL 0 / 9 ~0.016 ms +XXX[596] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 42672 ~71.597 ms, finishGL 83 / 42349 ~71.056 ms, waitGL 0 / 9 ~0.016 ms +XXX[597] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42755 ~71.617 ms, finishGL 82 / 42432 ~71.076 ms, waitGL 0 / 9 ~0.016 ms +XXX[598] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42839 ~71.638 ms, finishGL 83 / 42516 ~71.097 ms, waitGL 0 / 9 ~0.016 ms +XXX[599] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42922 ~71.657 ms, finishGL 82 / 42598 ~71.116 ms, waitGL 0 / 9 ~0.016 ms +XXX[600] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 43004 ~71.673 ms, finishGL 80 / 42679 ~71.132 ms, waitGL 0 / 9 ~0.016 ms +XXX[601] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 43085 ~71.689 ms, finishGL 81 / 42760 ~71.149 ms, waitGL 0 / 9 ~0.016 ms +XXX[602] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43167 ~71.707 ms, finishGL 81 / 42842 ~71.166 ms, waitGL 0 / 9 ~0.016 ms +XXX[603] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43250 ~71.725 ms, finishGL 82 / 42924 ~71.185 ms, waitGL 0 / 9 ~0.016 ms +XXX[604] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43333 ~71.743 ms, finishGL 82 / 43006 ~71.203 ms, waitGL 0 / 9 ~0.016 ms +XXX[605] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 43416 ~71.762 ms, finishGL 82 / 43089 ~71.222 ms, waitGL 0 / 9 ~0.016 ms diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync0-finish-wait.log b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync0-finish-wait.log new file mode 100644 index 000000000..3f9bb251d --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync0-finish-wait.log @@ -0,0 +1,751 @@ +NSZombieEnabled +NSTraceEvents YES +OBJC_PRINT_EXCEPTIONS +/usr/bin/java +java version "1.6.0_37" +Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909) +Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode) +LD_LIBRARY_PATH :../../gluegen/make/../build-macosx/obj:../build-macosx/lib +LIBXCB_ALLOW_SLOPPY_LOCK: +LIBGL_DRIVERS_PATH: +LIBGL_DEBUG: +LIBGL_ALWAYS_INDIRECT: +LIBGL_ALWAYS_SOFTWARE: +SWT_CLASSPATH: ../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar +/usr/bin/java -d64 -time 100000 -vsync 0 +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar + +Test Start: com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsync 0 + +/usr/bin/java -d64 -Djava.awt.headless=false -Djogl.debug.calayer.SwapM2 com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsync 0 +swapInterval 0 +exclusiveContext false +SWAP_M1 false +SWAP_M2 true +NewtCanvasAWT.attachNewtChild.2: size 500x268 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init ... +LandscapeES2 init on Thread[main-Display-.macosx_nil-1-EDT-1,5,main] +Chosen GLCapabilities: GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], offscr[fbo]] +INIT GL IS: jogamp.opengl.gl4.GL4bcImpl +GL_VENDOR: NVIDIA Corporation +GL_RENDERER: NVIDIA GeForce 320M OpenGL Engine +GL_VERSION: 2.1 NVIDIA-7.32.12 +GL GLSL: true, has-compiler-func: true, version 1.20, 1.20.0 +GL FBO: basic true, full true +GL Profile: GLProfile[GL2/GL2.hw] +GL Renderer Quirks:[NoOffscreenBitmap] +GL:jogamp.opengl.gl4.GL4bcImpl@3e018c74, 2.1 (hardware) - 2.1 NVIDIA-7.32.12 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init FIN +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.reshape 0/0 500x268, swapInterval 0, drawable 0x7fc3498bf2c0 +Thread[AWT-EventQueue-0,6,main] LandscapeES2.reshape 0/0 500x268, swapInterval 0, drawable 0x7fc3498bf2c0 +XXX[1] TO 17 ms, lFrame0 110 ms, lFrameX 848 / 848 ~848.637 ms, finishGL 736 / 736 ~736.829 ms, waitGL 1 / 1 ~1.296 ms +XXX[2] TO 17 ms, lFrame0 81 ms, lFrameX 169 / 1017 ~508.969 ms, finishGL 87 / 824 ~412.402 ms, waitGL 0 / 1 ~0.654 ms +XXX[3] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 1099 ~366.547 ms, finishGL 80 / 905 ~301.882 ms, waitGL 0 / 1 ~0.441 ms +XXX[4] TO 17 ms, lFrame0 1 ms, lFrameX 86 / 1185 ~296.444 ms, finishGL 84 / 990 ~247.652 ms, waitGL 0 / 1 ~0.334 ms +XXX[5] TO 17 ms, lFrame0 2 ms, lFrameX 83 / 1269 ~253.857 ms, finishGL 81 / 1071 ~214.388 ms, waitGL 0 / 1 ~0.27 ms +XXX[6] TO 17 ms, lFrame0 2 ms, lFrameX 82 / 1351 ~225.33 ms, finishGL 80 / 1152 ~192.095 ms, waitGL 0 / 1 ~0.227 ms +XXX[7] TO 17 ms, lFrame0 2 ms, lFrameX 83 / 1435 ~205.021 ms, finishGL 80 / 1233 ~176.15 ms, waitGL 0 / 1 ~0.196 ms +XXX[8] TO 17 ms, lFrame0 0 ms, lFrameX 97 / 1532 ~191.621 ms, finishGL 97 / 1330 ~166.297 ms, waitGL 0 / 1 ~0.174 ms +XXX[9] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1615 ~179.507 ms, finishGL 81 / 1412 ~156.923 ms, waitGL 0 / 1 ~0.156 ms +XXX[10] TO 17 ms, lFrame0 1 ms, lFrameX 79 / 1694 ~169.458 ms, finishGL 77 / 1490 ~149.019 ms, waitGL 0 / 1 ~0.141 ms +XXX[11] TO 17 ms, lFrame0 0 ms, lFrameX 103 / 1798 ~163.463 ms, finishGL 102 / 1592 ~144.812 ms, waitGL 0 / 1 ~0.129 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 1881 ~156.761 ms, finishGL 82 / 1675 ~139.611 ms, waitGL 0 / 1 ~0.12 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 77 / 1958 ~150.688 ms, finishGL 76 / 1752 ~134.783 ms, waitGL 0 / 1 ~0.111 ms +XXX[14] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 2046 ~146.155 ms, finishGL 86 / 1838 ~131.346 ms, waitGL 0 / 1 ~0.104 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 2144 ~142.991 ms, finishGL 98 / 1936 ~129.13 ms, waitGL 0 / 1 ~0.098 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2227 ~139.237 ms, finishGL 81 / 2018 ~126.184 ms, waitGL 0 / 1 ~0.093 ms +XXX[17] TO 17 ms, lFrame0 1 ms, lFrameX 75 / 2302 ~135.468 ms, finishGL 74 / 2093 ~123.12 ms, waitGL 0 / 1 ~0.089 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 107 / 2410 ~133.895 ms, finishGL 106 / 2199 ~122.184 ms, waitGL 0 / 1 ~0.085 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2493 ~131.251 ms, finishGL 82 / 2282 ~120.108 ms, waitGL 0 / 1 ~0.081 ms +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 2569 ~128.458 ms, finishGL 74 / 2356 ~117.844 ms, waitGL 0 / 1 ~0.077 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 107 / 2676 ~127.46 ms, finishGL 107 / 2463 ~117.328 ms, waitGL 0 / 1 ~0.074 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2760 ~125.462 ms, finishGL 83 / 2546 ~115.768 ms, waitGL 0 / 1 ~0.072 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 2836 ~123.307 ms, finishGL 75 / 2622 ~114.004 ms, waitGL 0 / 1 ~0.069 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 105 / 2941 ~122.558 ms, finishGL 104 / 2726 ~113.619 ms, waitGL 0 / 1 ~0.067 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 3020 ~120.817 ms, finishGL 78 / 2805 ~112.217 ms, waitGL 0 / 1 ~0.065 ms +XXX[26] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 3090 ~118.863 ms, finishGL 69 / 2875 ~110.579 ms, waitGL 0 / 1 ~0.063 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 3169 ~117.398 ms, finishGL 78 / 2953 ~109.402 ms, waitGL 0 / 1 ~0.061 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3251 ~116.14 ms, finishGL 81 / 3035 ~108.413 ms, waitGL 0 / 1 ~0.06 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3334 ~114.972 ms, finishGL 81 / 3117 ~107.495 ms, waitGL 0 / 1 ~0.058 ms +XXX[30] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3416 ~113.876 ms, finishGL 81 / 3199 ~106.633 ms, waitGL 0 / 1 ~0.057 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3498 ~112.869 ms, finishGL 82 / 3281 ~105.845 ms, waitGL 0 / 1 ~0.055 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3581 ~111.907 ms, finishGL 81 / 3362 ~105.085 ms, waitGL 0 / 1 ~0.054 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3646 ~110.507 ms, finishGL 64 / 3427 ~103.87 ms, waitGL 0 / 1 ~0.053 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3713 ~109.219 ms, finishGL 66 / 3493 ~102.763 ms, waitGL 0 / 1 ~0.052 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3779 ~107.986 ms, finishGL 65 / 3559 ~101.701 ms, waitGL 0 / 1 ~0.051 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3845 ~106.813 ms, finishGL 65 / 3624 ~100.684 ms, waitGL 0 / 1 ~0.05 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3911 ~105.716 ms, finishGL 65 / 3690 ~99.739 ms, waitGL 0 / 1 ~0.049 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3977 ~104.665 ms, finishGL 65 / 3755 ~98.825 ms, waitGL 0 / 1 ~0.048 ms +XXX[39] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 4044 ~103.71 ms, finishGL 66 / 3822 ~98.008 ms, waitGL 0 / 1 ~0.047 ms +XXX[40] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4111 ~102.777 ms, finishGL 65 / 3888 ~97.206 ms, waitGL 0 / 1 ~0.047 ms +XXX[41] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 4176 ~101.867 ms, finishGL 65 / 3953 ~96.42 ms, waitGL 0 / 1 ~0.046 ms +XXX[42] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4242 ~101.018 ms, finishGL 65 / 4018 ~95.689 ms, waitGL 0 / 1 ~0.045 ms +XXX[43] TO 17 ms, lFrame0 7 ms, lFrameX 68 / 4311 ~100.267 ms, finishGL 61 / 4080 ~94.884 ms, waitGL 0 / 1 ~0.044 ms +XXX[44] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 4375 ~99.44 ms, finishGL 63 / 4143 ~94.168 ms, waitGL 0 / 1 ~0.044 ms +XXX[45] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4441 ~98.703 ms, finishGL 64 / 4208 ~93.516 ms, waitGL 0 / 1 ~0.043 ms +XXX[46] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4508 ~98.0 ms, finishGL 65 / 4274 ~92.914 ms, waitGL 0 / 1 ~0.042 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4574 ~97.329 ms, finishGL 65 / 4340 ~92.341 ms, waitGL 0 / 1 ~0.042 ms +XXX[48] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4640 ~96.682 ms, finishGL 65 / 4405 ~91.788 ms, waitGL 0 / 2 ~0.041 ms +XXX[49] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4707 ~96.066 ms, finishGL 66 / 4471 ~91.262 ms, waitGL 0 / 2 ~0.041 ms +XXX[50] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4773 ~95.471 ms, finishGL 65 / 4537 ~90.753 ms, waitGL 0 / 2 ~0.04 ms +XXX[51] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4839 ~94.895 ms, finishGL 65 / 4603 ~90.259 ms, waitGL 0 / 2 ~0.04 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4905 ~94.343 ms, finishGL 65 / 4668 ~89.787 ms, waitGL 0 / 2 ~0.039 ms +XXX[53] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 4970 ~93.788 ms, finishGL 64 / 4733 ~89.308 ms, waitGL 0 / 2 ~0.039 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5037 ~93.294 ms, finishGL 66 / 4799 ~88.885 ms, waitGL 0 / 2 ~0.038 ms +XXX[55] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5104 ~92.8 ms, finishGL 65 / 4865 ~88.462 ms, waitGL 0 / 2 ~0.038 ms +XXX[56] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5170 ~92.332 ms, finishGL 66 / 4931 ~88.063 ms, waitGL 0 / 2 ~0.037 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5236 ~91.871 ms, finishGL 65 / 4997 ~87.668 ms, waitGL 0 / 2 ~0.037 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5303 ~91.442 ms, finishGL 66 / 5063 ~87.303 ms, waitGL 0 / 2 ~0.037 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5369 ~91.015 ms, finishGL 65 / 5129 ~86.938 ms, waitGL 0 / 2 ~0.036 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5436 ~90.614 ms, finishGL 66 / 5195 ~86.598 ms, waitGL 0 / 2 ~0.036 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5503 ~90.224 ms, finishGL 66 / 5262 ~86.266 ms, waitGL 0 / 2 ~0.036 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5570 ~89.839 ms, finishGL 65 / 5327 ~85.933 ms, waitGL 0 / 2 ~0.035 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5637 ~89.477 ms, finishGL 66 / 5394 ~85.625 ms, waitGL 0 / 2 ~0.035 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5703 ~89.118 ms, finishGL 66 / 5460 ~85.319 ms, waitGL 0 / 2 ~0.035 ms +XXX[65] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5770 ~88.771 ms, finishGL 65 / 5526 ~85.02 ms, waitGL 0 / 2 ~0.035 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5836 ~88.435 ms, finishGL 66 / 5592 ~84.734 ms, waitGL 0 / 2 ~0.034 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5904 ~88.122 ms, finishGL 66 / 5659 ~84.469 ms, waitGL 0 / 2 ~0.034 ms +XXX[68] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5970 ~87.805 ms, finishGL 66 / 5725 ~84.199 ms, waitGL 0 / 2 ~0.034 ms +XXX[69] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6037 ~87.498 ms, finishGL 66 / 5791 ~83.937 ms, waitGL 0 / 2 ~0.033 ms +XXX[70] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6104 ~87.206 ms, finishGL 66 / 5858 ~83.689 ms, waitGL 0 / 2 ~0.033 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6171 ~86.919 ms, finishGL 66 / 5924 ~83.445 ms, waitGL 0 / 2 ~0.033 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6237 ~86.636 ms, finishGL 65 / 5990 ~83.201 ms, waitGL 0 / 2 ~0.033 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6303 ~86.354 ms, finishGL 65 / 6056 ~82.96 ms, waitGL 0 / 2 ~0.032 ms +XXX[74] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6370 ~86.081 ms, finishGL 65 / 6121 ~82.725 ms, waitGL 0 / 2 ~0.032 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6435 ~85.806 ms, finishGL 64 / 6186 ~82.485 ms, waitGL 0 / 2 ~0.032 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6501 ~85.551 ms, finishGL 65 / 6251 ~82.261 ms, waitGL 0 / 2 ~0.032 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6567 ~85.298 ms, finishGL 65 / 6317 ~82.044 ms, waitGL 0 / 2 ~0.032 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6634 ~85.057 ms, finishGL 66 / 6383 ~81.839 ms, waitGL 0 / 2 ~0.031 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6701 ~84.826 ms, finishGL 66 / 6449 ~81.642 ms, waitGL 0 / 2 ~0.031 ms +XXX[80] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6768 ~84.601 ms, finishGL 66 / 6516 ~81.452 ms, waitGL 0 / 2 ~0.031 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6834 ~84.376 ms, finishGL 65 / 6582 ~81.259 ms, waitGL 0 / 2 ~0.031 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6901 ~84.162 ms, finishGL 66 / 6648 ~81.077 ms, waitGL 0 / 2 ~0.031 ms +XXX[83] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6968 ~83.956 ms, finishGL 66 / 6714 ~80.903 ms, waitGL 0 / 2 ~0.031 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 7035 ~83.759 ms, finishGL 66 / 6781 ~80.737 ms, waitGL 0 / 2 ~0.03 ms +XXX[85] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7102 ~83.556 ms, finishGL 65 / 6847 ~80.563 ms, waitGL 0 / 2 ~0.03 ms +XXX[86] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7168 ~83.355 ms, finishGL 65 / 6913 ~80.391 ms, waitGL 0 / 2 ~0.03 ms +XXX[87] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 7235 ~83.167 ms, finishGL 66 / 6980 ~80.23 ms, waitGL 0 / 2 ~0.03 ms +XXX[88] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7302 ~82.979 ms, finishGL 66 / 7046 ~80.07 ms, waitGL 0 / 2 ~0.03 ms +XXX[89] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7368 ~82.791 ms, finishGL 65 / 7111 ~79.909 ms, waitGL 0 / 2 ~0.029 ms +XXX[90] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 7435 ~82.616 ms, finishGL 66 / 7178 ~79.761 ms, waitGL 0 / 2 ~0.029 ms +XXX[91] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 7501 ~82.432 ms, finishGL 65 / 7243 ~79.603 ms, waitGL 0 / 2 ~0.029 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7567 ~82.258 ms, finishGL 65 / 7309 ~79.454 ms, waitGL 0 / 2 ~0.029 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7634 ~82.088 ms, finishGL 65 / 7375 ~79.309 ms, waitGL 0 / 2 ~0.029 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7700 ~81.921 ms, finishGL 65 / 7441 ~79.167 ms, waitGL 0 / 2 ~0.029 ms +XXX[95] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7767 ~81.758 ms, finishGL 65 / 7507 ~79.028 ms, waitGL 0 / 2 ~0.029 ms +XXX[96] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7833 ~81.601 ms, finishGL 66 / 7573 ~78.893 ms, waitGL 0 / 2 ~0.028 ms +XXX[97] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7899 ~81.443 ms, finishGL 65 / 7639 ~78.758 ms, waitGL 0 / 2 ~0.028 ms +XXX[98] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 7965 ~81.282 ms, finishGL 65 / 7704 ~78.62 ms, waitGL 0 / 2 ~0.028 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8031 ~81.129 ms, finishGL 65 / 7770 ~78.486 ms, waitGL 0 / 2 ~0.028 ms +XXX[1] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 66 ~66.634 ms, finishGL 66 / 66 ~66.169 ms, waitGL 0 / 0 ~0.015 ms +XXX[2] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 132 ~66.347 ms, finishGL 65 / 131 ~65.882 ms, waitGL 0 / 0 ~0.018 ms +XXX[3] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 198 ~66.312 ms, finishGL 65 / 197 ~65.839 ms, waitGL 0 / 0 ~0.017 ms +XXX[4] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 265 ~66.27 ms, finishGL 65 / 263 ~65.792 ms, waitGL 0 / 0 ~0.016 ms +XXX[5] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 331 ~66.372 ms, finishGL 66 / 329 ~65.865 ms, waitGL 0 / 0 ~0.016 ms +XXX[6] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 397 ~66.297 ms, finishGL 65 / 394 ~65.793 ms, waitGL 0 / 0 ~0.015 ms +XXX[7] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 464 ~66.324 ms, finishGL 65 / 460 ~65.82 ms, waitGL 0 / 0 ~0.015 ms +XXX[8] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 530 ~66.269 ms, finishGL 65 / 526 ~65.77 ms, waitGL 0 / 0 ~0.016 ms +XXX[9] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 597 ~66.378 ms, finishGL 66 / 592 ~65.88 ms, waitGL 0 / 0 ~0.016 ms +XXX[10] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 663 ~66.399 ms, finishGL 66 / 659 ~65.904 ms, waitGL 0 / 0 ~0.015 ms +XXX[11] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 732 ~66.55 ms, finishGL 67 / 726 ~66.051 ms, waitGL 0 / 0 ~0.015 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 798 ~66.573 ms, finishGL 66 / 792 ~66.075 ms, waitGL 0 / 0 ~0.015 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 864 ~66.529 ms, finishGL 65 / 858 ~66.03 ms, waitGL 0 / 0 ~0.015 ms +XXX[14] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 930 ~66.465 ms, finishGL 65 / 923 ~65.966 ms, waitGL 0 / 0 ~0.015 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 996 ~66.452 ms, finishGL 65 / 989 ~65.954 ms, waitGL 0 / 0 ~0.015 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1063 ~66.44 ms, finishGL 65 / 1055 ~65.943 ms, waitGL 0 / 0 ~0.015 ms +XXX[17] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1129 ~66.447 ms, finishGL 66 / 1121 ~65.95 ms, waitGL 0 / 0 ~0.016 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 1195 ~66.422 ms, finishGL 65 / 1186 ~65.925 ms, waitGL 0 / 0 ~0.015 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1262 ~66.442 ms, finishGL 66 / 1252 ~65.946 ms, waitGL 0 / 0 ~0.015 ms +FrameCount: 120 - FrameRate: 16.0 +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1329 ~66.479 ms, finishGL 66 / 1319 ~65.976 ms, waitGL 0 / 0 ~0.015 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1396 ~66.484 ms, finishGL 66 / 1385 ~65.981 ms, waitGL 0 / 0 ~0.015 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1463 ~66.515 ms, finishGL 66 / 1452 ~66.013 ms, waitGL 0 / 0 ~0.015 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1530 ~66.53 ms, finishGL 66 / 1518 ~66.028 ms, waitGL 0 / 0 ~0.015 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1597 ~66.567 ms, finishGL 66 / 1585 ~66.065 ms, waitGL 0 / 0 ~0.015 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1664 ~66.589 ms, finishGL 66 / 1652 ~66.087 ms, waitGL 0 / 0 ~0.015 ms +XXX[26] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1731 ~66.587 ms, finishGL 66 / 1718 ~66.086 ms, waitGL 0 / 0 ~0.015 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1798 ~66.595 ms, finishGL 66 / 1784 ~66.095 ms, waitGL 0 / 0 ~0.015 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1865 ~66.624 ms, finishGL 66 / 1851 ~66.124 ms, waitGL 0 / 0 ~0.015 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 1930 ~66.58 ms, finishGL 64 / 1916 ~66.081 ms, waitGL 0 / 0 ~0.015 ms +XXX[30] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1998 ~66.6 ms, finishGL 66 / 1983 ~66.101 ms, waitGL 0 / 0 ~0.015 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2064 ~66.593 ms, finishGL 65 / 2048 ~66.095 ms, waitGL 0 / 0 ~0.015 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2130 ~66.585 ms, finishGL 65 / 2114 ~66.085 ms, waitGL 0 / 0 ~0.015 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2197 ~66.581 ms, finishGL 65 / 2180 ~66.082 ms, waitGL 0 / 0 ~0.015 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2263 ~66.576 ms, finishGL 65 / 2246 ~66.078 ms, waitGL 0 / 0 ~0.015 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2330 ~66.571 ms, finishGL 65 / 2312 ~66.073 ms, waitGL 0 / 0 ~0.015 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2396 ~66.576 ms, finishGL 66 / 2378 ~66.077 ms, waitGL 0 / 0 ~0.015 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2462 ~66.558 ms, finishGL 65 / 2444 ~66.058 ms, waitGL 0 / 0 ~0.015 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2529 ~66.564 ms, finishGL 66 / 2510 ~66.066 ms, waitGL 0 / 0 ~0.015 ms +XXX[39] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2596 ~66.572 ms, finishGL 66 / 2576 ~66.074 ms, waitGL 0 / 0 ~0.015 ms +XXX[40] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2662 ~66.564 ms, finishGL 65 / 2642 ~66.067 ms, waitGL 0 / 0 ~0.015 ms +XXX[41] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2728 ~66.551 ms, finishGL 65 / 2708 ~66.054 ms, waitGL 0 / 0 ~0.015 ms +XXX[42] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 2795 ~66.567 ms, finishGL 66 / 2774 ~66.07 ms, waitGL 0 / 0 ~0.015 ms +XXX[43] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2861 ~66.558 ms, finishGL 65 / 2840 ~66.061 ms, waitGL 0 / 0 ~0.015 ms +XXX[44] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2928 ~66.556 ms, finishGL 65 / 2906 ~66.059 ms, waitGL 0 / 0 ~0.015 ms +XXX[45] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2994 ~66.547 ms, finishGL 65 / 2972 ~66.05 ms, waitGL 0 / 0 ~0.015 ms +XXX[46] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3060 ~66.525 ms, finishGL 65 / 3037 ~66.028 ms, waitGL 0 / 0 ~0.015 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3125 ~66.498 ms, finishGL 64 / 3101 ~65.999 ms, waitGL 0 / 0 ~0.015 ms +XXX[48] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 3190 ~66.461 ms, finishGL 64 / 3166 ~65.962 ms, waitGL 0 / 0 ~0.015 ms +XXX[49] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 3254 ~66.41 ms, finishGL 63 / 3229 ~65.912 ms, waitGL 0 / 0 ~0.015 ms +XXX[50] TO 17 ms, lFrame0 0 ms, lFrameX 62 / 3316 ~66.338 ms, finishGL 62 / 3291 ~65.839 ms, waitGL 0 / 0 ~0.015 ms +XXX[51] TO 17 ms, lFrame0 0 ms, lFrameX 61 / 3378 ~66.251 ms, finishGL 61 / 3353 ~65.755 ms, waitGL 0 / 0 ~0.015 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 46 / 3425 ~65.874 ms, finishGL 46 / 3399 ~65.378 ms, waitGL 0 / 0 ~0.015 ms +XXX[53] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3474 ~65.548 ms, finishGL 48 / 3447 ~65.053 ms, waitGL 0 / 0 ~0.015 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3522 ~65.238 ms, finishGL 48 / 3496 ~64.743 ms, waitGL 0 / 0 ~0.015 ms +XXX[55] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3571 ~64.941 ms, finishGL 48 / 3544 ~64.444 ms, waitGL 0 / 0 ~0.015 ms +XXX[56] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3621 ~64.662 ms, finishGL 48 / 3593 ~64.166 ms, waitGL 0 / 0 ~0.015 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3670 ~64.387 ms, finishGL 48 / 3641 ~63.891 ms, waitGL 0 / 0 ~0.015 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3719 ~64.131 ms, finishGL 48 / 3690 ~63.634 ms, waitGL 0 / 0 ~0.015 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3768 ~63.879 ms, finishGL 48 / 3739 ~63.382 ms, waitGL 0 / 0 ~0.016 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3818 ~63.639 ms, finishGL 48 / 3788 ~63.142 ms, waitGL 0 / 0 ~0.016 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3867 ~63.404 ms, finishGL 48 / 3837 ~62.907 ms, waitGL 0 / 0 ~0.016 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3916 ~63.174 ms, finishGL 48 / 3886 ~62.677 ms, waitGL 0 / 0 ~0.016 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3966 ~62.952 ms, finishGL 48 / 3934 ~62.455 ms, waitGL 0 / 1 ~0.016 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4014 ~62.732 ms, finishGL 48 / 3983 ~62.236 ms, waitGL 0 / 1 ~0.016 ms +XXX[65] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4063 ~62.517 ms, finishGL 48 / 4031 ~62.021 ms, waitGL 0 / 1 ~0.016 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4112 ~62.307 ms, finishGL 48 / 4079 ~61.811 ms, waitGL 0 / 1 ~0.016 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4161 ~62.107 ms, finishGL 48 / 4127 ~61.611 ms, waitGL 0 / 1 ~0.016 ms +XXX[68] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4209 ~61.911 ms, finishGL 48 / 4175 ~61.411 ms, waitGL 0 / 1 ~0.016 ms +XXX[69] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4258 ~61.713 ms, finishGL 47 / 4223 ~61.211 ms, waitGL 0 / 1 ~0.016 ms +XXX[70] TO 17 ms, lFrame0 1 ms, lFrameX 30 / 4289 ~61.272 ms, finishGL 29 / 4253 ~60.762 ms, waitGL 0 / 1 ~0.016 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 4339 ~61.117 ms, finishGL 49 / 4303 ~60.607 ms, waitGL 0 / 1 ~0.016 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4371 ~60.714 ms, finishGL 31 / 4334 ~60.203 ms, waitGL 0 / 1 ~0.016 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4404 ~60.329 ms, finishGL 32 / 4366 ~59.819 ms, waitGL 0 / 1 ~0.016 ms +XXX[74] TO 17 ms, lFrame0 0 ms, lFrameX 27 / 4431 ~59.881 ms, finishGL 26 / 4393 ~59.369 ms, waitGL 0 / 1 ~0.016 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 54 / 4485 ~59.812 ms, finishGL 53 / 4447 ~59.297 ms, waitGL 0 / 1 ~0.016 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4518 ~59.447 ms, finishGL 31 / 4478 ~58.932 ms, waitGL 0 / 1 ~0.016 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 25 / 4543 ~59.002 ms, finishGL 24 / 4503 ~58.485 ms, waitGL 0 / 1 ~0.016 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 40 / 4583 ~58.762 ms, finishGL 39 / 4543 ~58.245 ms, waitGL 0 / 1 ~0.016 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4632 ~58.633 ms, finishGL 47 / 4590 ~58.113 ms, waitGL 0 / 1 ~0.016 ms +XXX[80] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4664 ~58.309 ms, finishGL 32 / 4623 ~57.79 ms, waitGL 0 / 1 ~0.016 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 23 / 4688 ~57.883 ms, finishGL 22 / 4646 ~57.36 ms, waitGL 0 / 1 ~0.016 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 26 / 4715 ~57.503 ms, finishGL 26 / 4672 ~56.981 ms, waitGL 0 / 1 ~0.016 ms +XXX[83] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 4764 ~57.404 ms, finishGL 48 / 4721 ~56.882 ms, waitGL 0 / 1 ~0.016 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4797 ~57.113 ms, finishGL 32 / 4753 ~56.59 ms, waitGL 0 / 1 ~0.016 ms +XXX[85] TO 17 ms, lFrame0 0 ms, lFrameX 23 / 4821 ~56.72 ms, finishGL 22 / 4776 ~56.195 ms, waitGL 0 / 1 ~0.016 ms +XXX[86] TO 17 ms, lFrame0 0 ms, lFrameX 45 / 4866 ~56.59 ms, finishGL 45 / 4821 ~56.066 ms, waitGL 0 / 1 ~0.016 ms +XXX[87] TO 17 ms, lFrame0 0 ms, lFrameX 37 / 4904 ~56.373 ms, finishGL 37 / 4858 ~55.849 ms, waitGL 0 / 1 ~0.016 ms +XXX[88] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4937 ~56.111 ms, finishGL 32 / 4891 ~55.585 ms, waitGL 0 / 1 ~0.016 ms +XXX[89] TO 17 ms, lFrame0 0 ms, lFrameX 57 / 4994 ~56.123 ms, finishGL 56 / 4948 ~55.597 ms, waitGL 0 / 1 ~0.016 ms +XXX[90] TO 17 ms, lFrame0 0 ms, lFrameX 53 / 5048 ~56.092 ms, finishGL 52 / 5001 ~55.567 ms, waitGL 0 / 1 ~0.016 ms +XXX[91] TO 17 ms, lFrame0 0 ms, lFrameX 41 / 5089 ~55.932 ms, finishGL 40 / 5041 ~55.405 ms, waitGL 0 / 1 ~0.016 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 76 / 5166 ~56.159 ms, finishGL 76 / 5118 ~55.633 ms, waitGL 0 / 1 ~0.016 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5216 ~56.093 ms, finishGL 49 / 5167 ~55.567 ms, waitGL 0 / 1 ~0.016 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 43 / 5259 ~55.956 ms, finishGL 42 / 5210 ~55.427 ms, waitGL 0 / 1 ~0.016 ms +XXX[95] TO 17 ms, lFrame0 0 ms, lFrameX 73 / 5333 ~56.137 ms, finishGL 72 / 5282 ~55.606 ms, waitGL 0 / 1 ~0.016 ms +XXX[96] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5383 ~56.075 ms, finishGL 49 / 5332 ~55.545 ms, waitGL 0 / 1 ~0.016 ms +XXX[97] TO 17 ms, lFrame0 0 ms, lFrameX 43 / 5427 ~55.949 ms, finishGL 43 / 5375 ~55.416 ms, waitGL 0 / 1 ~0.016 ms +XXX[98] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 5499 ~56.116 ms, finishGL 71 / 5447 ~55.582 ms, waitGL 0 / 1 ~0.016 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5549 ~56.06 ms, finishGL 50 / 5497 ~55.526 ms, waitGL 0 / 1 ~0.016 ms +XXX[100] TO 17 ms, lFrame0 0 ms, lFrameX 44 / 5594 ~55.946 ms, finishGL 43 / 5541 ~55.41 ms, waitGL 0 / 1 ~0.016 ms +XXX[101] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 5667 ~56.112 ms, finishGL 72 / 5613 ~55.576 ms, waitGL 0 / 1 ~0.016 ms +XXX[102] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 5718 ~56.06 ms, finishGL 50 / 5663 ~55.525 ms, waitGL 0 / 1 ~0.016 ms +XXX[103] TO 17 ms, lFrame0 0 ms, lFrameX 46 / 5764 ~55.97 ms, finishGL 46 / 5709 ~55.433 ms, waitGL 0 / 1 ~0.016 ms +XXX[104] TO 17 ms, lFrame0 0 ms, lFrameX 72 / 5836 ~56.124 ms, finishGL 71 / 5781 ~55.588 ms, waitGL 0 / 1 ~0.016 ms +XXX[105] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 5905 ~56.239 ms, finishGL 67 / 5848 ~55.704 ms, waitGL 0 / 1 ~0.016 ms +XXX[106] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 5956 ~56.191 ms, finishGL 50 / 5899 ~55.653 ms, waitGL 0 / 1 ~0.016 ms +XXX[107] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 6040 ~56.453 ms, finishGL 83 / 5983 ~55.916 ms, waitGL 0 / 1 ~0.016 ms +XXX[108] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 6110 ~56.579 ms, finishGL 69 / 6052 ~56.041 ms, waitGL 0 / 1 ~0.016 ms +XXX[109] TO 17 ms, lFrame0 0 ms, lFrameX 60 / 6170 ~56.614 ms, finishGL 59 / 6112 ~56.075 ms, waitGL 0 / 1 ~0.016 ms +XXX[110] TO 17 ms, lFrame0 0 ms, lFrameX 94 / 6265 ~56.956 ms, finishGL 93 / 6206 ~56.418 ms, waitGL 0 / 1 ~0.016 ms +XXX[111] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 6333 ~57.058 ms, finishGL 67 / 6273 ~56.518 ms, waitGL 0 / 1 ~0.016 ms +XXX[112] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 6396 ~57.114 ms, finishGL 62 / 6336 ~56.571 ms, waitGL 0 / 1 ~0.016 ms +XXX[113] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 6483 ~57.373 ms, finishGL 85 / 6421 ~56.829 ms, waitGL 0 / 1 ~0.016 ms +XXX[114] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6549 ~57.455 ms, finishGL 66 / 6487 ~56.91 ms, waitGL 0 / 1 ~0.016 ms +XXX[115] TO 17 ms, lFrame0 0 ms, lFrameX 63 / 6613 ~57.507 ms, finishGL 62 / 6550 ~56.961 ms, waitGL 0 / 1 ~0.016 ms +XXX[116] TO 17 ms, lFrame0 0 ms, lFrameX 88 / 6702 ~57.775 ms, finishGL 88 / 6638 ~57.229 ms, waitGL 0 / 1 ~0.015 ms +XXX[117] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 6786 ~58.001 ms, finishGL 83 / 6722 ~57.453 ms, waitGL 0 / 1 ~0.015 ms +XXX[118] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6852 ~58.072 ms, finishGL 65 / 6787 ~57.522 ms, waitGL 0 / 1 ~0.015 ms +XXX[119] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 6952 ~58.425 ms, finishGL 99 / 6887 ~57.876 ms, waitGL 0 / 1 ~0.016 ms +XXX[120] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 7035 ~58.629 ms, finishGL 82 / 6969 ~58.081 ms, waitGL 0 / 1 ~0.015 ms +XXX[121] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 7102 ~58.699 ms, finishGL 66 / 7036 ~58.148 ms, waitGL 0 / 1 ~0.016 ms +XXX[122] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 7203 ~59.044 ms, finishGL 100 / 7136 ~58.494 ms, waitGL 0 / 1 ~0.016 ms +XXX[123] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 7287 ~59.249 ms, finishGL 83 / 7220 ~58.701 ms, waitGL 0 / 1 ~0.015 ms +XXX[124] TO 17 ms, lFrame0 0 ms, lFrameX 71 / 7359 ~59.349 ms, finishGL 70 / 7291 ~58.8 ms, waitGL 0 / 1 ~0.015 ms +XXX[125] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 7458 ~59.665 ms, finishGL 98 / 7389 ~59.114 ms, waitGL 0 / 1 ~0.015 ms +XXX[126] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 7542 ~59.86 ms, finishGL 83 / 7472 ~59.308 ms, waitGL 0 / 2 ~0.016 ms +XXX[127] TO 17 ms, lFrame0 0 ms, lFrameX 76 / 7618 ~59.989 ms, finishGL 75 / 7548 ~59.437 ms, waitGL 0 / 2 ~0.015 ms +XXX[128] TO 17 ms, lFrame0 0 ms, lFrameX 93 / 7712 ~60.252 ms, finishGL 93 / 7641 ~59.701 ms, waitGL 0 / 2 ~0.015 ms +XXX[129] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 7793 ~60.415 ms, finishGL 80 / 7722 ~59.865 ms, waitGL 0 / 2 ~0.015 ms +2013-06-17 03:01:17.725 java[63231:5f07] Persistent UI failed to open file file://localhost/Users/jogamp/Library/Saved%20Application%20State/com.apple.javajdk16.cmd.savedState/window_1.data: Operation not permitted (1) +XXX[130] TO 17 ms, lFrame0 0 ms, lFrameX 79 / 7873 ~60.562 ms, finishGL 79 / 7801 ~60.012 ms, waitGL 0 / 2 ~0.015 ms +XXX[131] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 7954 ~60.719 ms, finishGL 80 / 7882 ~60.168 ms, waitGL 0 / 2 ~0.015 ms +XXX[132] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8036 ~60.885 ms, finishGL 82 / 7964 ~60.335 ms, waitGL 0 / 2 ~0.015 ms +XXX[133] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 8118 ~61.038 ms, finishGL 80 / 8045 ~60.489 ms, waitGL 0 / 2 ~0.015 ms +XXX[134] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8200 ~61.195 ms, finishGL 81 / 8126 ~60.646 ms, waitGL 0 / 2 ~0.015 ms +XXX[135] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8282 ~61.353 ms, finishGL 81 / 8208 ~60.804 ms, waitGL 0 / 2 ~0.016 ms +XXX[136] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8365 ~61.51 ms, finishGL 82 / 8290 ~60.962 ms, waitGL 0 / 2 ~0.016 ms +XXX[137] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8448 ~61.666 ms, finishGL 82 / 8373 ~61.118 ms, waitGL 0 / 2 ~0.016 ms +XXX[138] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 8531 ~61.822 ms, finishGL 82 / 8456 ~61.275 ms, waitGL 0 / 2 ~0.016 ms +XXX[139] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 8614 ~61.973 ms, finishGL 82 / 8538 ~61.425 ms, waitGL 0 / 2 ~0.016 ms +FrameCount: 240 - FrameRate: 13.0 +XXX[140] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 8679 ~61.996 ms, finishGL 64 / 8602 ~61.448 ms, waitGL 0 / 2 ~0.016 ms +XXX[141] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 8746 ~62.032 ms, finishGL 66 / 8669 ~61.485 ms, waitGL 0 / 2 ~0.016 ms +XXX[142] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8812 ~62.063 ms, finishGL 65 / 8735 ~61.516 ms, waitGL 0 / 2 ~0.016 ms +XXX[143] TO 17 ms, lFrame0 5 ms, lFrameX 69 / 8882 ~62.114 ms, finishGL 64 / 8799 ~61.534 ms, waitGL 0 / 2 ~0.016 ms +XXX[144] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 8962 ~62.24 ms, finishGL 79 / 8879 ~61.661 ms, waitGL 0 / 2 ~0.016 ms +XXX[145] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9028 ~62.262 ms, finishGL 65 / 8944 ~61.684 ms, waitGL 0 / 2 ~0.016 ms +XXX[146] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9093 ~62.287 ms, finishGL 65 / 9009 ~61.709 ms, waitGL 0 / 2 ~0.016 ms +XXX[147] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9160 ~62.315 ms, finishGL 65 / 9075 ~61.737 ms, waitGL 0 / 2 ~0.016 ms +XXX[148] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9226 ~62.342 ms, finishGL 65 / 9141 ~61.766 ms, waitGL 0 / 2 ~0.016 ms +XXX[149] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9293 ~62.372 ms, finishGL 66 / 9207 ~61.794 ms, waitGL 0 / 2 ~0.016 ms +XXX[150] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 9361 ~62.406 ms, finishGL 67 / 9274 ~61.829 ms, waitGL 0 / 2 ~0.016 ms +XXX[151] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9426 ~62.427 ms, finishGL 64 / 9339 ~61.849 ms, waitGL 0 / 2 ~0.016 ms +XXX[152] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9493 ~62.453 ms, finishGL 66 / 9405 ~61.876 ms, waitGL 0 / 2 ~0.016 ms +XXX[153] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9559 ~62.479 ms, finishGL 65 / 9471 ~61.902 ms, waitGL 0 / 2 ~0.016 ms +XXX[154] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9625 ~62.501 ms, finishGL 65 / 9536 ~61.925 ms, waitGL 0 / 2 ~0.016 ms +XXX[155] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 9692 ~62.532 ms, finishGL 66 / 9603 ~61.956 ms, waitGL 0 / 2 ~0.016 ms +XXX[156] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9759 ~62.559 ms, finishGL 66 / 9669 ~61.983 ms, waitGL 0 / 2 ~0.016 ms +XXX[157] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9825 ~62.583 ms, finishGL 65 / 9735 ~62.008 ms, waitGL 0 / 2 ~0.016 ms +XXX[158] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9890 ~62.599 ms, finishGL 64 / 9799 ~62.024 ms, waitGL 0 / 2 ~0.015 ms +XXX[159] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9957 ~62.624 ms, finishGL 66 / 9866 ~62.051 ms, waitGL 0 / 2 ~0.015 ms +XXX[160] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10023 ~62.646 ms, finishGL 65 / 9931 ~62.072 ms, waitGL 0 / 2 ~0.015 ms +XXX[161] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 10089 ~62.665 ms, finishGL 65 / 9996 ~62.092 ms, waitGL 0 / 2 ~0.015 ms +XXX[162] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10155 ~62.687 ms, finishGL 65 / 10062 ~62.115 ms, waitGL 0 / 2 ~0.015 ms +XXX[163] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10221 ~62.709 ms, finishGL 65 / 10128 ~62.138 ms, waitGL 0 / 2 ~0.015 ms +XXX[164] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 10287 ~62.729 ms, finishGL 64 / 10193 ~62.155 ms, waitGL 0 / 2 ~0.015 ms +XXX[165] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10354 ~62.754 ms, finishGL 66 / 10259 ~62.179 ms, waitGL 0 / 2 ~0.015 ms +XXX[166] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 10420 ~62.772 ms, finishGL 65 / 10324 ~62.197 ms, waitGL 0 / 2 ~0.015 ms +XXX[167] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10486 ~62.793 ms, finishGL 65 / 10390 ~62.22 ms, waitGL 0 / 2 ~0.015 ms +XXX[168] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10553 ~62.816 ms, finishGL 66 / 10456 ~62.243 ms, waitGL 0 / 2 ~0.015 ms +XXX[169] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10619 ~62.839 ms, finishGL 66 / 10523 ~62.266 ms, waitGL 0 / 2 ~0.015 ms +XXX[170] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10686 ~62.861 ms, finishGL 66 / 10589 ~62.289 ms, waitGL 0 / 2 ~0.015 ms +XXX[171] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10753 ~62.884 ms, finishGL 66 / 10655 ~62.312 ms, waitGL 0 / 2 ~0.015 ms +XXX[172] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10819 ~62.906 ms, finishGL 66 / 10721 ~62.335 ms, waitGL 0 / 2 ~0.015 ms +XXX[173] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10887 ~62.931 ms, finishGL 66 / 10788 ~62.36 ms, waitGL 0 / 2 ~0.015 ms +XXX[174] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10953 ~62.951 ms, finishGL 65 / 10854 ~62.38 ms, waitGL 0 / 2 ~0.016 ms +XXX[175] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11020 ~62.972 ms, finishGL 66 / 10920 ~62.402 ms, waitGL 0 / 2 ~0.015 ms +XXX[176] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11086 ~62.99 ms, finishGL 65 / 10986 ~62.421 ms, waitGL 0 / 2 ~0.015 ms +XXX[177] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11153 ~63.012 ms, finishGL 66 / 11052 ~62.443 ms, waitGL 0 / 2 ~0.016 ms +XXX[178] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11220 ~63.035 ms, finishGL 66 / 11118 ~62.466 ms, waitGL 0 / 2 ~0.015 ms +XXX[179] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11288 ~63.061 ms, finishGL 67 / 11186 ~62.493 ms, waitGL 0 / 2 ~0.016 ms +XXX[180] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11355 ~63.088 ms, finishGL 67 / 11253 ~62.52 ms, waitGL 0 / 2 ~0.015 ms +XXX[181] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11422 ~63.107 ms, finishGL 65 / 11319 ~62.539 ms, waitGL 0 / 2 ~0.015 ms +XXX[182] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11490 ~63.132 ms, finishGL 67 / 11386 ~62.565 ms, waitGL 0 / 2 ~0.015 ms +XXX[183] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11557 ~63.154 ms, finishGL 66 / 11453 ~62.587 ms, waitGL 0 / 2 ~0.016 ms +XXX[184] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11624 ~63.177 ms, finishGL 66 / 11520 ~62.611 ms, waitGL 0 / 2 ~0.016 ms +XXX[185] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 11709 ~63.294 ms, finishGL 84 / 11604 ~62.728 ms, waitGL 0 / 2 ~0.016 ms +XXX[186] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 11794 ~63.412 ms, finishGL 84 / 11689 ~62.847 ms, waitGL 0 / 2 ~0.016 ms +XXX[187] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 11881 ~63.536 ms, finishGL 86 / 11775 ~62.971 ms, waitGL 0 / 2 ~0.016 ms +XXX[188] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 11967 ~63.657 ms, finishGL 85 / 11861 ~63.092 ms, waitGL 0 / 3 ~0.016 ms +XXX[189] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 12052 ~63.771 ms, finishGL 84 / 11946 ~63.206 ms, waitGL 0 / 3 ~0.016 ms +XXX[190] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 12137 ~63.882 ms, finishGL 84 / 12030 ~63.318 ms, waitGL 0 / 3 ~0.016 ms +XXX[191] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12221 ~63.986 ms, finishGL 83 / 12113 ~63.422 ms, waitGL 0 / 3 ~0.016 ms +XXX[192] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 12306 ~64.094 ms, finishGL 84 / 12197 ~63.53 ms, waitGL 0 / 3 ~0.016 ms +XXX[193] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 12405 ~64.276 ms, finishGL 98 / 12296 ~63.712 ms, waitGL 0 / 3 ~0.016 ms +XXX[194] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12489 ~64.376 ms, finishGL 83 / 12379 ~63.812 ms, waitGL 0 / 3 ~0.016 ms +XXX[195] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 12588 ~64.557 ms, finishGL 99 / 12478 ~63.994 ms, waitGL 0 / 3 ~0.016 ms +XXX[196] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 12671 ~64.648 ms, finishGL 81 / 12560 ~64.085 ms, waitGL 0 / 3 ~0.016 ms +XXX[197] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 12752 ~64.735 ms, finishGL 81 / 12642 ~64.173 ms, waitGL 0 / 3 ~0.016 ms +XXX[198] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 12835 ~64.823 ms, finishGL 81 / 12723 ~64.259 ms, waitGL 0 / 3 ~0.016 ms +XXX[199] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 12918 ~64.914 ms, finishGL 82 / 12805 ~64.35 ms, waitGL 0 / 3 ~0.016 ms +XXX[200] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13001 ~65.005 ms, finishGL 82 / 12888 ~64.441 ms, waitGL 0 / 3 ~0.016 ms +XXX[201] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13084 ~65.094 ms, finishGL 82 / 12970 ~64.531 ms, waitGL 0 / 3 ~0.016 ms +XXX[202] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13167 ~65.185 ms, finishGL 82 / 13053 ~64.622 ms, waitGL 0 / 3 ~0.016 ms +XXX[203] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13250 ~65.274 ms, finishGL 82 / 13136 ~64.711 ms, waitGL 0 / 3 ~0.016 ms +XXX[204] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13333 ~65.36 ms, finishGL 82 / 13218 ~64.798 ms, waitGL 0 / 3 ~0.016 ms +XXX[205] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13416 ~65.447 ms, finishGL 82 / 13301 ~64.885 ms, waitGL 0 / 3 ~0.016 ms +XXX[206] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13498 ~65.527 ms, finishGL 81 / 13383 ~64.966 ms, waitGL 0 / 3 ~0.016 ms +XXX[207] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13580 ~65.608 ms, finishGL 81 / 13464 ~65.047 ms, waitGL 0 / 3 ~0.016 ms +XXX[208] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13663 ~65.687 ms, finishGL 81 / 13546 ~65.126 ms, waitGL 0 / 3 ~0.016 ms +XXX[209] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13744 ~65.764 ms, finishGL 81 / 13627 ~65.204 ms, waitGL 0 / 3 ~0.016 ms +XXX[210] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13826 ~65.84 ms, finishGL 81 / 13708 ~65.279 ms, waitGL 0 / 3 ~0.016 ms +XXX[211] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13908 ~65.915 ms, finishGL 81 / 13789 ~65.354 ms, waitGL 0 / 3 ~0.016 ms +XXX[212] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 13989 ~65.99 ms, finishGL 81 / 13871 ~65.43 ms, waitGL 0 / 3 ~0.016 ms +XXX[213] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 14071 ~66.064 ms, finishGL 81 / 13952 ~65.504 ms, waitGL 0 / 3 ~0.016 ms +XXX[214] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 14153 ~66.137 ms, finishGL 81 / 14033 ~65.577 ms, waitGL 0 / 3 ~0.016 ms +XXX[215] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 14235 ~66.211 ms, finishGL 81 / 14115 ~65.652 ms, waitGL 0 / 3 ~0.016 ms +XXX[216] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 14301 ~66.212 ms, finishGL 65 / 14181 ~65.653 ms, waitGL 0 / 3 ~0.016 ms +XXX[217] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 14369 ~66.216 ms, finishGL 66 / 14247 ~65.658 ms, waitGL 0 / 3 ~0.016 ms +XXX[218] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 14452 ~66.296 ms, finishGL 83 / 14330 ~65.738 ms, waitGL 0 / 3 ~0.016 ms +XXX[219] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 14538 ~66.385 ms, finishGL 85 / 14416 ~65.827 ms, waitGL 0 / 3 ~0.016 ms +XXX[220] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 14624 ~66.473 ms, finishGL 85 / 14501 ~65.915 ms, waitGL 0 / 3 ~0.016 ms +XXX[221] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 14709 ~66.56 ms, finishGL 85 / 14586 ~66.003 ms, waitGL 0 / 3 ~0.016 ms +XXX[222] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 14795 ~66.648 ms, finishGL 85 / 14672 ~66.091 ms, waitGL 0 / 3 ~0.016 ms +XXX[223] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 14880 ~66.73 ms, finishGL 84 / 14756 ~66.173 ms, waitGL 0 / 3 ~0.016 ms +XXX[224] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 14964 ~66.804 ms, finishGL 82 / 14839 ~66.247 ms, waitGL 0 / 3 ~0.016 ms +XXX[225] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 15047 ~66.876 ms, finishGL 82 / 14921 ~66.319 ms, waitGL 0 / 3 ~0.016 ms +XXX[226] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15129 ~66.946 ms, finishGL 82 / 15004 ~66.389 ms, waitGL 0 / 3 ~0.016 ms +XXX[227] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15212 ~67.017 ms, finishGL 82 / 15086 ~66.46 ms, waitGL 0 / 3 ~0.016 ms +XXX[228] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15295 ~67.085 ms, finishGL 82 / 15168 ~66.529 ms, waitGL 0 / 3 ~0.016 ms +XXX[229] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15377 ~67.152 ms, finishGL 81 / 15250 ~66.596 ms, waitGL 0 / 3 ~0.016 ms +XXX[230] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15460 ~67.219 ms, finishGL 82 / 15332 ~66.663 ms, waitGL 0 / 3 ~0.016 ms +XXX[231] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15542 ~67.283 ms, finishGL 81 / 15414 ~66.727 ms, waitGL 0 / 3 ~0.016 ms +XXX[232] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15624 ~67.346 ms, finishGL 81 / 15495 ~66.791 ms, waitGL 0 / 3 ~0.016 ms +XXX[233] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15706 ~67.411 ms, finishGL 81 / 15577 ~66.856 ms, waitGL 0 / 3 ~0.016 ms +XXX[234] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15787 ~67.469 ms, finishGL 80 / 15658 ~66.915 ms, waitGL 0 / 3 ~0.016 ms +XXX[235] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 15869 ~67.529 ms, finishGL 81 / 15739 ~66.975 ms, waitGL 0 / 3 ~0.016 ms +XXX[236] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15951 ~67.591 ms, finishGL 81 / 15820 ~67.037 ms, waitGL 0 / 3 ~0.016 ms +XXX[237] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 16033 ~67.651 ms, finishGL 81 / 15902 ~67.097 ms, waitGL 0 / 3 ~0.016 ms +XXX[238] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 16115 ~67.711 ms, finishGL 81 / 15983 ~67.157 ms, waitGL 0 / 3 ~0.016 ms +XXX[239] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16181 ~67.705 ms, finishGL 65 / 16049 ~67.152 ms, waitGL 0 / 3 ~0.016 ms +XXX[240] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16248 ~67.7 ms, finishGL 66 / 16115 ~67.148 ms, waitGL 0 / 3 ~0.016 ms +XXX[241] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16314 ~67.694 ms, finishGL 65 / 16181 ~67.141 ms, waitGL 0 / 3 ~0.016 ms +XXX[242] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16381 ~67.69 ms, finishGL 66 / 16247 ~67.138 ms, waitGL 0 / 3 ~0.016 ms +XXX[243] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 16446 ~67.681 ms, finishGL 64 / 16312 ~67.129 ms, waitGL 0 / 3 ~0.016 ms +XXX[244] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16513 ~67.677 ms, finishGL 66 / 16378 ~67.125 ms, waitGL 0 / 3 ~0.016 ms +XXX[245] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16579 ~67.671 ms, finishGL 65 / 16444 ~67.119 ms, waitGL 0 / 3 ~0.016 ms +XXX[246] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 16645 ~67.664 ms, finishGL 65 / 16509 ~67.112 ms, waitGL 0 / 3 ~0.016 ms +XXX[247] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16712 ~67.661 ms, finishGL 66 / 16576 ~67.11 ms, waitGL 0 / 3 ~0.016 ms +XXX[248] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16779 ~67.657 ms, finishGL 66 / 16642 ~67.106 ms, waitGL 0 / 3 ~0.016 ms +XXX[249] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16846 ~67.656 ms, finishGL 66 / 16709 ~67.104 ms, waitGL 0 / 4 ~0.016 ms +XXX[250] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 16913 ~67.655 ms, finishGL 67 / 16776 ~67.105 ms, waitGL 0 / 4 ~0.016 ms +XXX[251] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 16998 ~67.723 ms, finishGL 84 / 16860 ~67.172 ms, waitGL 0 / 4 ~0.016 ms +XXX[252] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17083 ~67.79 ms, finishGL 84 / 16944 ~67.239 ms, waitGL 0 / 4 ~0.016 ms +XXX[253] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 17168 ~67.859 ms, finishGL 84 / 17029 ~67.309 ms, waitGL 0 / 4 ~0.016 ms +XXX[254] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 17253 ~67.928 ms, finishGL 84 / 17114 ~67.378 ms, waitGL 0 / 4 ~0.016 ms +XXX[255] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17338 ~67.994 ms, finishGL 84 / 17198 ~67.444 ms, waitGL 0 / 4 ~0.016 ms +XXX[256] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17423 ~68.06 ms, finishGL 84 / 17282 ~67.51 ms, waitGL 0 / 4 ~0.016 ms +XXX[257] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17507 ~68.123 ms, finishGL 83 / 17366 ~67.574 ms, waitGL 0 / 4 ~0.016 ms +XXX[258] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17592 ~68.188 ms, finishGL 84 / 17451 ~67.64 ms, waitGL 0 / 4 ~0.016 ms +XXX[259] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 17676 ~68.25 ms, finishGL 83 / 17534 ~67.702 ms, waitGL 0 / 4 ~0.016 ms +FrameCount: 360 - FrameRate: 15.0 +XXX[260] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17760 ~68.309 ms, finishGL 82 / 17617 ~67.76 ms, waitGL 0 / 4 ~0.016 ms +XXX[261] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17843 ~68.367 ms, finishGL 82 / 17700 ~67.818 ms, waitGL 0 / 4 ~0.016 ms +XXX[262] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17926 ~68.423 ms, finishGL 82 / 17783 ~67.875 ms, waitGL 0 / 4 ~0.016 ms +XXX[263] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18009 ~68.478 ms, finishGL 82 / 17865 ~67.93 ms, waitGL 0 / 4 ~0.016 ms +XXX[264] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18092 ~68.532 ms, finishGL 82 / 17947 ~67.984 ms, waitGL 0 / 4 ~0.016 ms +XXX[265] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18175 ~68.586 ms, finishGL 82 / 18030 ~68.038 ms, waitGL 0 / 4 ~0.016 ms +XXX[266] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18257 ~68.638 ms, finishGL 81 / 18111 ~68.089 ms, waitGL 0 / 4 ~0.016 ms +XXX[267] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18340 ~68.691 ms, finishGL 82 / 18194 ~68.143 ms, waitGL 0 / 4 ~0.016 ms +XXX[268] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18423 ~68.743 ms, finishGL 81 / 18276 ~68.194 ms, waitGL 0 / 4 ~0.016 ms +XXX[269] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18505 ~68.794 ms, finishGL 82 / 18358 ~68.246 ms, waitGL 0 / 4 ~0.016 ms +XXX[270] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18588 ~68.844 ms, finishGL 81 / 18440 ~68.296 ms, waitGL 0 / 4 ~0.016 ms +XXX[271] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 18669 ~68.892 ms, finishGL 81 / 18521 ~68.344 ms, waitGL 0 / 4 ~0.016 ms +XXX[272] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 18751 ~68.939 ms, finishGL 81 / 18602 ~68.391 ms, waitGL 0 / 4 ~0.016 ms +XXX[273] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18833 ~68.987 ms, finishGL 81 / 18684 ~68.44 ms, waitGL 0 / 4 ~0.016 ms +XXX[274] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18915 ~69.036 ms, finishGL 81 / 18766 ~68.489 ms, waitGL 0 / 4 ~0.016 ms +XXX[275] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18998 ~69.084 ms, finishGL 81 / 18847 ~68.537 ms, waitGL 0 / 4 ~0.016 ms +XXX[276] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19080 ~69.132 ms, finishGL 81 / 18929 ~68.585 ms, waitGL 0 / 4 ~0.016 ms +XXX[277] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19162 ~69.179 ms, finishGL 81 / 19011 ~68.633 ms, waitGL 0 / 4 ~0.016 ms +XXX[278] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19245 ~69.228 ms, finishGL 82 / 19093 ~68.682 ms, waitGL 0 / 4 ~0.016 ms +XXX[279] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19327 ~69.274 ms, finishGL 81 / 19175 ~68.728 ms, waitGL 0 / 4 ~0.016 ms +XXX[280] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19410 ~69.322 ms, finishGL 82 / 19257 ~68.777 ms, waitGL 0 / 4 ~0.016 ms +XXX[281] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19492 ~69.368 ms, finishGL 81 / 19339 ~68.823 ms, waitGL 0 / 4 ~0.016 ms +XXX[282] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 19575 ~69.415 ms, finishGL 82 / 19421 ~68.87 ms, waitGL 0 / 4 ~0.016 ms +XXX[283] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19640 ~69.402 ms, finishGL 65 / 19486 ~68.857 ms, waitGL 0 / 4 ~0.016 ms +XXX[284] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19706 ~69.389 ms, finishGL 65 / 19552 ~68.845 ms, waitGL 0 / 4 ~0.016 ms +XXX[285] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19772 ~69.375 ms, finishGL 64 / 19616 ~68.83 ms, waitGL 0 / 4 ~0.016 ms +XXX[286] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19837 ~69.362 ms, finishGL 65 / 19681 ~68.817 ms, waitGL 0 / 4 ~0.016 ms +XXX[287] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19902 ~69.348 ms, finishGL 64 / 19746 ~68.804 ms, waitGL 0 / 4 ~0.016 ms +XXX[288] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 19968 ~69.336 ms, finishGL 65 / 19812 ~68.792 ms, waitGL 0 / 4 ~0.016 ms +XXX[289] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20034 ~69.322 ms, finishGL 64 / 19877 ~68.778 ms, waitGL 0 / 4 ~0.016 ms +XXX[290] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 20098 ~69.306 ms, finishGL 64 / 19941 ~68.762 ms, waitGL 0 / 4 ~0.016 ms +XXX[291] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20163 ~69.292 ms, finishGL 64 / 20005 ~68.748 ms, waitGL 0 / 4 ~0.016 ms +XXX[292] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20230 ~69.281 ms, finishGL 65 / 20071 ~68.738 ms, waitGL 0 / 4 ~0.016 ms +XXX[293] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20295 ~69.267 ms, finishGL 64 / 20136 ~68.724 ms, waitGL 0 / 4 ~0.016 ms +XXX[294] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20361 ~69.257 ms, finishGL 65 / 20202 ~68.714 ms, waitGL 0 / 4 ~0.016 ms +XXX[295] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20427 ~69.244 ms, finishGL 65 / 20267 ~68.702 ms, waitGL 0 / 4 ~0.016 ms +XXX[296] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 20493 ~69.233 ms, finishGL 65 / 20332 ~68.691 ms, waitGL 0 / 4 ~0.016 ms +XXX[297] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20559 ~69.222 ms, finishGL 65 / 20398 ~68.68 ms, waitGL 0 / 4 ~0.016 ms +XXX[298] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20625 ~69.212 ms, finishGL 65 / 20463 ~68.67 ms, waitGL 0 / 4 ~0.016 ms +XXX[299] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20691 ~69.202 ms, finishGL 65 / 20529 ~68.66 ms, waitGL 0 / 4 ~0.016 ms +XXX[300] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20758 ~69.193 ms, finishGL 66 / 20595 ~68.652 ms, waitGL 0 / 4 ~0.016 ms +XXX[301] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 20825 ~69.187 ms, finishGL 66 / 20662 ~68.645 ms, waitGL 0 / 4 ~0.016 ms +XXX[302] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 20892 ~69.181 ms, finishGL 66 / 20729 ~68.64 ms, waitGL 0 / 4 ~0.016 ms +XXX[303] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 20960 ~69.177 ms, finishGL 67 / 20796 ~68.635 ms, waitGL 0 / 4 ~0.016 ms +XXX[304] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 21029 ~69.175 ms, finishGL 68 / 20864 ~68.634 ms, waitGL 0 / 4 ~0.016 ms +XXX[305] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 21097 ~69.172 ms, finishGL 67 / 20932 ~68.631 ms, waitGL 0 / 4 ~0.016 ms +XXX[306] TO 17 ms, lFrame0 0 ms, lFrameX 69 / 21166 ~69.173 ms, finishGL 68 / 21001 ~68.632 ms, waitGL 0 / 4 ~0.016 ms +XXX[307] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 21237 ~69.178 ms, finishGL 70 / 21072 ~68.638 ms, waitGL 0 / 4 ~0.016 ms +XXX[308] TO 17 ms, lFrame0 0 ms, lFrameX 71 / 21309 ~69.185 ms, finishGL 70 / 21142 ~68.645 ms, waitGL 0 / 4 ~0.016 ms +XXX[309] TO 17 ms, lFrame0 0 ms, lFrameX 87 / 21397 ~69.246 ms, finishGL 87 / 21230 ~68.706 ms, waitGL 0 / 4 ~0.016 ms +XXX[310] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 21482 ~69.298 ms, finishGL 85 / 21315 ~68.759 ms, waitGL 0 / 4 ~0.016 ms +XXX[311] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 21568 ~69.351 ms, finishGL 85 / 21400 ~68.811 ms, waitGL 0 / 5 ~0.016 ms +XXX[312] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 21652 ~69.398 ms, finishGL 83 / 21484 ~68.859 ms, waitGL 0 / 5 ~0.016 ms +XXX[313] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 21735 ~69.442 ms, finishGL 82 / 21566 ~68.903 ms, waitGL 0 / 5 ~0.016 ms +XXX[314] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 21818 ~69.485 ms, finishGL 82 / 21649 ~68.946 ms, waitGL 0 / 5 ~0.016 ms +XXX[315] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 21901 ~69.529 ms, finishGL 82 / 21731 ~68.99 ms, waitGL 0 / 5 ~0.016 ms +XXX[316] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 21985 ~69.575 ms, finishGL 83 / 21815 ~69.036 ms, waitGL 0 / 5 ~0.016 ms +XXX[317] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 22070 ~69.622 ms, finishGL 83 / 21899 ~69.083 ms, waitGL 0 / 5 ~0.016 ms +XXX[318] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 22171 ~69.72 ms, finishGL 100 / 21999 ~69.182 ms, waitGL 0 / 5 ~0.016 ms +XXX[319] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 22270 ~69.814 ms, finishGL 98 / 22098 ~69.274 ms, waitGL 0 / 5 ~0.016 ms +XXX[320] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 22369 ~69.904 ms, finishGL 98 / 22197 ~69.365 ms, waitGL 0 / 5 ~0.016 ms +XXX[321] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22451 ~69.942 ms, finishGL 81 / 22278 ~69.403 ms, waitGL 0 / 5 ~0.016 ms +XXX[322] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22534 ~69.982 ms, finishGL 82 / 22360 ~69.443 ms, waitGL 0 / 5 ~0.016 ms +XXX[323] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22617 ~70.022 ms, finishGL 82 / 22443 ~69.483 ms, waitGL 0 / 5 ~0.016 ms +XXX[324] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22700 ~70.063 ms, finishGL 82 / 22526 ~69.525 ms, waitGL 0 / 5 ~0.016 ms +XXX[325] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22783 ~70.102 ms, finishGL 82 / 22608 ~69.564 ms, waitGL 0 / 5 ~0.016 ms +XXX[326] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22866 ~70.143 ms, finishGL 83 / 22691 ~69.605 ms, waitGL 0 / 5 ~0.016 ms +XXX[327] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22950 ~70.183 ms, finishGL 82 / 22774 ~69.645 ms, waitGL 0 / 5 ~0.016 ms +XXX[328] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23033 ~70.223 ms, finishGL 82 / 22856 ~69.685 ms, waitGL 0 / 5 ~0.016 ms +XXX[329] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23116 ~70.263 ms, finishGL 83 / 22939 ~69.725 ms, waitGL 0 / 5 ~0.016 ms +XXX[330] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 23198 ~70.298 ms, finishGL 81 / 23021 ~69.761 ms, waitGL 0 / 5 ~0.016 ms +XXX[331] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 23283 ~70.343 ms, finishGL 84 / 23105 ~69.806 ms, waitGL 0 / 5 ~0.016 ms +XXX[332] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23367 ~70.383 ms, finishGL 83 / 23189 ~69.846 ms, waitGL 0 / 5 ~0.016 ms +XXX[333] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23450 ~70.422 ms, finishGL 82 / 23271 ~69.885 ms, waitGL 0 / 5 ~0.016 ms +XXX[334] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23533 ~70.459 ms, finishGL 82 / 23354 ~69.922 ms, waitGL 0 / 5 ~0.016 ms +XXX[335] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23616 ~70.495 ms, finishGL 82 / 23436 ~69.958 ms, waitGL 0 / 5 ~0.016 ms +XXX[336] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23699 ~70.534 ms, finishGL 82 / 23518 ~69.996 ms, waitGL 0 / 5 ~0.016 ms +XXX[337] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23782 ~70.569 ms, finishGL 82 / 23600 ~70.032 ms, waitGL 0 / 5 ~0.016 ms +XXX[338] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 23863 ~70.602 ms, finishGL 80 / 23681 ~70.064 ms, waitGL 0 / 5 ~0.016 ms +XXX[339] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23945 ~70.636 ms, finishGL 81 / 23763 ~70.098 ms, waitGL 0 / 5 ~0.016 ms +XXX[340] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24028 ~70.673 ms, finishGL 82 / 23846 ~70.135 ms, waitGL 0 / 5 ~0.016 ms +XXX[341] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24112 ~70.71 ms, finishGL 82 / 23928 ~70.172 ms, waitGL 0 / 5 ~0.016 ms +XXX[342] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24195 ~70.746 ms, finishGL 82 / 24011 ~70.208 ms, waitGL 0 / 5 ~0.016 ms +XXX[343] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24278 ~70.782 ms, finishGL 82 / 24093 ~70.243 ms, waitGL 0 / 5 ~0.016 ms +XXX[344] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24360 ~70.816 ms, finishGL 82 / 24175 ~70.278 ms, waitGL 0 / 5 ~0.016 ms +XXX[345] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24444 ~70.852 ms, finishGL 82 / 24258 ~70.314 ms, waitGL 0 / 5 ~0.016 ms +XXX[346] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24527 ~70.887 ms, finishGL 82 / 24340 ~70.349 ms, waitGL 0 / 5 ~0.016 ms +XXX[347] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24610 ~70.922 ms, finishGL 82 / 24423 ~70.384 ms, waitGL 0 / 5 ~0.016 ms +XXX[348] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24693 ~70.958 ms, finishGL 82 / 24506 ~70.42 ms, waitGL 0 / 5 ~0.016 ms +XXX[349] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24776 ~70.992 ms, finishGL 82 / 24588 ~70.454 ms, waitGL 0 / 5 ~0.016 ms +XXX[350] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24860 ~71.028 ms, finishGL 83 / 24671 ~70.491 ms, waitGL 0 / 5 ~0.016 ms +XXX[351] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24943 ~71.063 ms, finishGL 82 / 24754 ~70.525 ms, waitGL 0 / 5 ~0.016 ms +XXX[352] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25025 ~71.096 ms, finishGL 82 / 24836 ~70.559 ms, waitGL 0 / 5 ~0.016 ms +XXX[353] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25109 ~71.131 ms, finishGL 83 / 24919 ~70.594 ms, waitGL 0 / 5 ~0.016 ms +XXX[354] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25192 ~71.165 ms, finishGL 82 / 25002 ~70.629 ms, waitGL 0 / 5 ~0.016 ms +XXX[355] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25275 ~71.199 ms, finishGL 82 / 25085 ~70.662 ms, waitGL 0 / 5 ~0.016 ms +XXX[356] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25359 ~71.234 ms, finishGL 83 / 25168 ~70.698 ms, waitGL 0 / 5 ~0.016 ms +XXX[357] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25442 ~71.266 ms, finishGL 82 / 25250 ~70.73 ms, waitGL 0 / 5 ~0.016 ms +XXX[358] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25525 ~71.3 ms, finishGL 82 / 25333 ~70.764 ms, waitGL 0 / 5 ~0.016 ms +XXX[359] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25608 ~71.332 ms, finishGL 82 / 25416 ~70.796 ms, waitGL 0 / 5 ~0.016 ms +XXX[360] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25692 ~71.367 ms, finishGL 83 / 25499 ~70.831 ms, waitGL 0 / 5 ~0.016 ms +XXX[361] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25775 ~71.4 ms, finishGL 83 / 25582 ~70.865 ms, waitGL 0 / 5 ~0.016 ms +XXX[362] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25858 ~71.432 ms, finishGL 82 / 25664 ~70.896 ms, waitGL 0 / 5 ~0.016 ms +XXX[363] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25941 ~71.465 ms, finishGL 82 / 25747 ~70.929 ms, waitGL 0 / 5 ~0.016 ms +XXX[364] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26025 ~71.499 ms, finishGL 83 / 25830 ~70.963 ms, waitGL 0 / 5 ~0.016 ms +XXX[365] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26108 ~71.531 ms, finishGL 82 / 25913 ~70.996 ms, waitGL 0 / 5 ~0.016 ms +XXX[366] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 26192 ~71.565 ms, finishGL 83 / 25997 ~71.03 ms, waitGL 0 / 5 ~0.016 ms +XXX[367] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26275 ~71.596 ms, finishGL 82 / 26079 ~71.061 ms, waitGL 0 / 5 ~0.016 ms +XXX[368] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26359 ~71.628 ms, finishGL 82 / 26162 ~71.093 ms, waitGL 0 / 5 ~0.016 ms +XXX[369] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26442 ~71.658 ms, finishGL 82 / 26244 ~71.123 ms, waitGL 0 / 5 ~0.016 ms +XXX[370] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26526 ~71.691 ms, finishGL 83 / 26328 ~71.157 ms, waitGL 0 / 5 ~0.016 ms +XXX[371] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26608 ~71.722 ms, finishGL 82 / 26410 ~71.187 ms, waitGL 0 / 5 ~0.016 ms +XXX[372] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26691 ~71.752 ms, finishGL 82 / 26492 ~71.217 ms, waitGL 0 / 5 ~0.016 ms +XXX[373] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 26773 ~71.779 ms, finishGL 81 / 26574 ~71.245 ms, waitGL 0 / 5 ~0.016 ms +XXX[374] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26856 ~71.809 ms, finishGL 82 / 26656 ~71.274 ms, waitGL 0 / 6 ~0.016 ms +XXX[375] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26939 ~71.838 ms, finishGL 82 / 26738 ~71.303 ms, waitGL 0 / 6 ~0.016 ms +XXX[376] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27022 ~71.869 ms, finishGL 82 / 26821 ~71.334 ms, waitGL 0 / 6 ~0.016 ms +XXX[377] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27105 ~71.897 ms, finishGL 81 / 26903 ~71.362 ms, waitGL 0 / 6 ~0.016 ms +XXX[378] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27188 ~71.927 ms, finishGL 82 / 26986 ~71.393 ms, waitGL 0 / 6 ~0.016 ms +XXX[379] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27271 ~71.955 ms, finishGL 82 / 27068 ~71.421 ms, waitGL 0 / 6 ~0.016 ms +FrameCount: 480 - FrameRate: 12.0 +XXX[380] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27353 ~71.983 ms, finishGL 82 / 27150 ~71.449 ms, waitGL 0 / 6 ~0.016 ms +XXX[381] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27436 ~72.011 ms, finishGL 82 / 27232 ~71.477 ms, waitGL 0 / 6 ~0.016 ms +XXX[382] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27519 ~72.04 ms, finishGL 82 / 27315 ~71.506 ms, waitGL 0 / 6 ~0.016 ms +XXX[383] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27602 ~72.068 ms, finishGL 82 / 27397 ~71.534 ms, waitGL 0 / 6 ~0.016 ms +XXX[384] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27684 ~72.094 ms, finishGL 81 / 27479 ~71.56 ms, waitGL 0 / 6 ~0.016 ms +XXX[385] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27767 ~72.123 ms, finishGL 82 / 27562 ~71.59 ms, waitGL 0 / 6 ~0.016 ms +XXX[386] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 27852 ~72.157 ms, finishGL 84 / 27646 ~71.623 ms, waitGL 0 / 6 ~0.016 ms +XXX[387] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27936 ~72.187 ms, finishGL 83 / 27730 ~71.653 ms, waitGL 0 / 6 ~0.016 ms +XXX[388] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28020 ~72.216 ms, finishGL 83 / 27813 ~71.683 ms, waitGL 0 / 6 ~0.016 ms +XXX[389] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28103 ~72.244 ms, finishGL 82 / 27895 ~71.711 ms, waitGL 0 / 6 ~0.016 ms +XXX[390] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 28187 ~72.276 ms, finishGL 84 / 27979 ~71.743 ms, waitGL 0 / 6 ~0.016 ms +XXX[391] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 28272 ~72.309 ms, finishGL 84 / 28064 ~71.776 ms, waitGL 0 / 6 ~0.016 ms +XXX[392] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 28357 ~72.34 ms, finishGL 83 / 28148 ~71.807 ms, waitGL 0 / 6 ~0.016 ms +XXX[393] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 28440 ~72.368 ms, finishGL 82 / 28230 ~71.833 ms, waitGL 0 / 6 ~0.016 ms +XXX[394] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28523 ~72.395 ms, finishGL 82 / 28312 ~71.86 ms, waitGL 0 / 6 ~0.016 ms +XXX[395] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 28606 ~72.421 ms, finishGL 81 / 28394 ~71.885 ms, waitGL 0 / 6 ~0.016 ms +XXX[396] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28689 ~72.448 ms, finishGL 82 / 28477 ~71.912 ms, waitGL 0 / 6 ~0.016 ms +XXX[397] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28772 ~72.475 ms, finishGL 82 / 28559 ~71.939 ms, waitGL 0 / 6 ~0.016 ms +XXX[398] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28855 ~72.502 ms, finishGL 82 / 28642 ~71.966 ms, waitGL 0 / 6 ~0.016 ms +XXX[399] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28938 ~72.528 ms, finishGL 82 / 28725 ~71.992 ms, waitGL 0 / 6 ~0.016 ms +XXX[400] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29021 ~72.553 ms, finishGL 82 / 28807 ~72.017 ms, waitGL 0 / 6 ~0.016 ms +XXX[401] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29104 ~72.58 ms, finishGL 82 / 28889 ~72.044 ms, waitGL 0 / 6 ~0.016 ms +XXX[402] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29187 ~72.605 ms, finishGL 82 / 28971 ~72.069 ms, waitGL 0 / 6 ~0.016 ms +XXX[403] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 29269 ~72.627 ms, finishGL 81 / 29053 ~72.092 ms, waitGL 0 / 6 ~0.016 ms +XXX[404] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 29350 ~72.65 ms, finishGL 81 / 29134 ~72.115 ms, waitGL 0 / 6 ~0.016 ms +XXX[405] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29433 ~72.675 ms, finishGL 82 / 29216 ~72.14 ms, waitGL 0 / 6 ~0.016 ms +XXX[406] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29516 ~72.7 ms, finishGL 82 / 29299 ~72.165 ms, waitGL 0 / 6 ~0.016 ms +XXX[407] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29599 ~72.726 ms, finishGL 82 / 29381 ~72.191 ms, waitGL 0 / 6 ~0.016 ms +XXX[408] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29682 ~72.751 ms, finishGL 82 / 29464 ~72.216 ms, waitGL 0 / 6 ~0.016 ms +XXX[409] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29765 ~72.775 ms, finishGL 81 / 29546 ~72.239 ms, waitGL 0 / 6 ~0.016 ms +XXX[410] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29847 ~72.799 ms, finishGL 82 / 29628 ~72.264 ms, waitGL 0 / 6 ~0.016 ms +XXX[411] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29930 ~72.824 ms, finishGL 82 / 29710 ~72.289 ms, waitGL 0 / 6 ~0.016 ms +XXX[412] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30013 ~72.848 ms, finishGL 82 / 29793 ~72.313 ms, waitGL 0 / 6 ~0.016 ms +XXX[413] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30096 ~72.873 ms, finishGL 82 / 29875 ~72.338 ms, waitGL 0 / 6 ~0.016 ms +XXX[414] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30180 ~72.899 ms, finishGL 83 / 29959 ~72.365 ms, waitGL 0 / 6 ~0.016 ms +XXX[415] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30262 ~72.922 ms, finishGL 81 / 30040 ~72.387 ms, waitGL 0 / 6 ~0.016 ms +XXX[416] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30345 ~72.946 ms, finishGL 82 / 30123 ~72.411 ms, waitGL 0 / 6 ~0.016 ms +XXX[417] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30428 ~72.969 ms, finishGL 82 / 30205 ~72.434 ms, waitGL 0 / 6 ~0.016 ms +XXX[418] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 30511 ~72.992 ms, finishGL 82 / 30287 ~72.458 ms, waitGL 0 / 6 ~0.016 ms +XXX[419] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30594 ~73.017 ms, finishGL 82 / 30370 ~72.482 ms, waitGL 0 / 6 ~0.016 ms +XXX[420] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30677 ~73.041 ms, finishGL 82 / 30452 ~72.506 ms, waitGL 0 / 6 ~0.016 ms +XXX[421] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30761 ~73.067 ms, finishGL 83 / 30536 ~72.532 ms, waitGL 0 / 6 ~0.016 ms +XXX[422] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 30845 ~73.093 ms, finishGL 83 / 30619 ~72.558 ms, waitGL 0 / 6 ~0.016 ms +XXX[423] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 30929 ~73.12 ms, finishGL 83 / 30703 ~72.585 ms, waitGL 0 / 6 ~0.016 ms +XXX[424] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 31012 ~73.142 ms, finishGL 81 / 30785 ~72.607 ms, waitGL 0 / 6 ~0.016 ms +XXX[425] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 31092 ~73.159 ms, finishGL 79 / 30865 ~72.624 ms, waitGL 0 / 6 ~0.016 ms +XXX[426] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 31173 ~73.176 ms, finishGL 79 / 30945 ~72.641 ms, waitGL 0 / 6 ~0.016 ms +XXX[427] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 31253 ~73.192 ms, finishGL 79 / 31024 ~72.657 ms, waitGL 0 / 6 ~0.016 ms +XXX[428] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 31317 ~73.171 ms, finishGL 63 / 31088 ~72.636 ms, waitGL 0 / 6 ~0.016 ms +XXX[429] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31382 ~73.153 ms, finishGL 64 / 31153 ~72.618 ms, waitGL 0 / 6 ~0.016 ms +XXX[430] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31449 ~73.137 ms, finishGL 65 / 31218 ~72.602 ms, waitGL 0 / 6 ~0.016 ms +XXX[431] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31514 ~73.12 ms, finishGL 65 / 31284 ~72.585 ms, waitGL 0 / 6 ~0.016 ms +XXX[432] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31580 ~73.103 ms, finishGL 65 / 31349 ~72.568 ms, waitGL 0 / 6 ~0.016 ms +XXX[433] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31646 ~73.087 ms, finishGL 65 / 31415 ~72.552 ms, waitGL 0 / 6 ~0.016 ms +XXX[434] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31713 ~73.071 ms, finishGL 65 / 31480 ~72.536 ms, waitGL 0 / 7 ~0.016 ms +XXX[435] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31779 ~73.055 ms, finishGL 65 / 31546 ~72.521 ms, waitGL 0 / 7 ~0.016 ms +XXX[436] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 31844 ~73.038 ms, finishGL 64 / 31611 ~72.503 ms, waitGL 0 / 7 ~0.016 ms +XXX[437] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31911 ~73.023 ms, finishGL 65 / 31677 ~72.488 ms, waitGL 0 / 7 ~0.016 ms +XXX[438] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31977 ~73.007 ms, finishGL 65 / 31743 ~72.472 ms, waitGL 0 / 7 ~0.016 ms +XXX[439] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32043 ~72.992 ms, finishGL 66 / 31809 ~72.458 ms, waitGL 0 / 7 ~0.016 ms +XXX[440] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32110 ~72.979 ms, finishGL 66 / 31875 ~72.444 ms, waitGL 0 / 7 ~0.016 ms +XXX[441] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32177 ~72.964 ms, finishGL 66 / 31941 ~72.43 ms, waitGL 0 / 7 ~0.016 ms +XXX[442] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32243 ~72.95 ms, finishGL 66 / 32007 ~72.415 ms, waitGL 0 / 7 ~0.016 ms +XXX[443] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32311 ~72.937 ms, finishGL 66 / 32074 ~72.402 ms, waitGL 0 / 7 ~0.016 ms +XXX[444] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32378 ~72.923 ms, finishGL 66 / 32140 ~72.389 ms, waitGL 0 / 7 ~0.016 ms +XXX[445] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32444 ~72.909 ms, finishGL 66 / 32207 ~72.375 ms, waitGL 0 / 7 ~0.016 ms +XXX[446] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32511 ~72.895 ms, finishGL 66 / 32273 ~72.361 ms, waitGL 0 / 7 ~0.016 ms +XXX[447] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 32578 ~72.882 ms, finishGL 66 / 32339 ~72.348 ms, waitGL 0 / 7 ~0.016 ms +XXX[448] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32644 ~72.867 ms, finishGL 65 / 32405 ~72.333 ms, waitGL 0 / 7 ~0.016 ms +XXX[449] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32711 ~72.853 ms, finishGL 66 / 32471 ~72.32 ms, waitGL 0 / 7 ~0.016 ms +XXX[450] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32778 ~72.84 ms, finishGL 66 / 32537 ~72.306 ms, waitGL 0 / 7 ~0.016 ms +XXX[451] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32844 ~72.826 ms, finishGL 66 / 32604 ~72.292 ms, waitGL 0 / 7 ~0.016 ms +XXX[452] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32911 ~72.812 ms, finishGL 66 / 32670 ~72.279 ms, waitGL 0 / 7 ~0.016 ms +XXX[453] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32977 ~72.797 ms, finishGL 65 / 32735 ~72.264 ms, waitGL 0 / 7 ~0.016 ms +XXX[454] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33042 ~72.781 ms, finishGL 65 / 32800 ~72.248 ms, waitGL 0 / 7 ~0.016 ms +XXX[455] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33108 ~72.765 ms, finishGL 65 / 32865 ~72.232 ms, waitGL 0 / 7 ~0.016 ms +XXX[456] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 33174 ~72.751 ms, finishGL 65 / 32931 ~72.219 ms, waitGL 0 / 7 ~0.016 ms +XXX[457] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33240 ~72.735 ms, finishGL 64 / 32996 ~72.202 ms, waitGL 0 / 7 ~0.016 ms +XXX[458] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33305 ~72.719 ms, finishGL 64 / 33061 ~72.186 ms, waitGL 0 / 7 ~0.016 ms +XXX[459] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33371 ~72.704 ms, finishGL 65 / 33126 ~72.171 ms, waitGL 0 / 7 ~0.016 ms +XXX[460] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33436 ~72.688 ms, finishGL 65 / 33191 ~72.156 ms, waitGL 0 / 7 ~0.016 ms +XXX[461] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33502 ~72.674 ms, finishGL 65 / 33257 ~72.142 ms, waitGL 0 / 7 ~0.016 ms +XXX[462] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33568 ~72.658 ms, finishGL 64 / 33322 ~72.126 ms, waitGL 0 / 7 ~0.016 ms +XXX[463] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33633 ~72.643 ms, finishGL 64 / 33387 ~72.11 ms, waitGL 0 / 7 ~0.016 ms +XXX[464] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33699 ~72.628 ms, finishGL 65 / 33452 ~72.096 ms, waitGL 0 / 7 ~0.016 ms +XXX[465] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33765 ~72.613 ms, finishGL 65 / 33517 ~72.081 ms, waitGL 0 / 7 ~0.016 ms +XXX[466] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 33830 ~72.597 ms, finishGL 64 / 33582 ~72.065 ms, waitGL 0 / 7 ~0.016 ms +XXX[467] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 33878 ~72.545 ms, finishGL 47 / 33630 ~72.013 ms, waitGL 0 / 7 ~0.016 ms +XXX[468] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 33928 ~72.497 ms, finishGL 49 / 33680 ~71.965 ms, waitGL 0 / 7 ~0.016 ms +XXX[469] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 33977 ~72.447 ms, finishGL 48 / 33728 ~71.915 ms, waitGL 0 / 7 ~0.016 ms +XXX[470] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34026 ~72.397 ms, finishGL 48 / 33776 ~71.865 ms, waitGL 0 / 7 ~0.016 ms +XXX[471] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34076 ~72.349 ms, finishGL 49 / 33825 ~71.817 ms, waitGL 0 / 7 ~0.016 ms +XXX[472] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34125 ~72.299 ms, finishGL 48 / 33874 ~71.767 ms, waitGL 0 / 7 ~0.016 ms +XXX[473] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34174 ~72.251 ms, finishGL 48 / 33923 ~71.719 ms, waitGL 0 / 7 ~0.016 ms +XXX[474] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34223 ~72.202 ms, finishGL 48 / 33971 ~71.67 ms, waitGL 0 / 7 ~0.016 ms +XXX[475] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34272 ~72.151 ms, finishGL 47 / 34019 ~71.62 ms, waitGL 0 / 7 ~0.016 ms +XXX[476] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 34322 ~72.106 ms, finishGL 50 / 34069 ~71.574 ms, waitGL 0 / 7 ~0.016 ms +XXX[477] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34371 ~72.057 ms, finishGL 48 / 34117 ~71.525 ms, waitGL 0 / 7 ~0.016 ms +XXX[478] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34420 ~72.009 ms, finishGL 48 / 34166 ~71.478 ms, waitGL 0 / 7 ~0.016 ms +XXX[479] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34469 ~71.961 ms, finishGL 48 / 34215 ~71.43 ms, waitGL 0 / 7 ~0.016 ms +XXX[480] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34518 ~71.914 ms, finishGL 48 / 34263 ~71.383 ms, waitGL 0 / 7 ~0.016 ms +XXX[481] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34567 ~71.865 ms, finishGL 47 / 34311 ~71.334 ms, waitGL 0 / 7 ~0.016 ms +XXX[482] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34616 ~71.818 ms, finishGL 48 / 34360 ~71.288 ms, waitGL 0 / 7 ~0.016 ms +XXX[483] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34665 ~71.772 ms, finishGL 48 / 34409 ~71.241 ms, waitGL 0 / 7 ~0.016 ms +XXX[484] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34714 ~71.725 ms, finishGL 48 / 34458 ~71.194 ms, waitGL 0 / 7 ~0.016 ms +XXX[485] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34764 ~71.678 ms, finishGL 48 / 34506 ~71.148 ms, waitGL 0 / 7 ~0.016 ms +XXX[486] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 34813 ~71.631 ms, finishGL 48 / 34554 ~71.1 ms, waitGL 0 / 7 ~0.016 ms +XXX[487] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34862 ~71.586 ms, finishGL 48 / 34603 ~71.054 ms, waitGL 0 / 7 ~0.016 ms +XXX[488] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34912 ~71.541 ms, finishGL 49 / 34653 ~71.01 ms, waitGL 0 / 7 ~0.016 ms +XXX[489] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34961 ~71.495 ms, finishGL 48 / 34701 ~70.964 ms, waitGL 0 / 7 ~0.016 ms +XXX[490] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35011 ~71.451 ms, finishGL 49 / 34750 ~70.92 ms, waitGL 0 / 7 ~0.016 ms +XXX[491] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35061 ~71.408 ms, finishGL 49 / 34800 ~70.877 ms, waitGL 0 / 7 ~0.016 ms +XXX[492] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35111 ~71.365 ms, finishGL 49 / 34850 ~70.834 ms, waitGL 0 / 8 ~0.016 ms +XXX[493] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35161 ~71.321 ms, finishGL 49 / 34899 ~70.79 ms, waitGL 0 / 8 ~0.016 ms +XXX[494] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35211 ~71.277 ms, finishGL 48 / 34948 ~70.746 ms, waitGL 0 / 8 ~0.016 ms +XXX[495] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35260 ~71.234 ms, finishGL 49 / 34997 ~70.703 ms, waitGL 0 / 8 ~0.016 ms +XXX[496] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35311 ~71.193 ms, finishGL 50 / 35048 ~70.662 ms, waitGL 0 / 8 ~0.016 ms +XXX[497] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35362 ~71.151 ms, finishGL 50 / 35098 ~70.62 ms, waitGL 0 / 8 ~0.016 ms +XXX[498] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35412 ~71.109 ms, finishGL 49 / 35148 ~70.578 ms, waitGL 0 / 8 ~0.016 ms +XXX[499] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35462 ~71.067 ms, finishGL 49 / 35197 ~70.536 ms, waitGL 0 / 8 ~0.016 ms +FrameCount: 600 - FrameRate: 20.0 +XXX[500] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35513 ~71.026 ms, finishGL 49 / 35247 ~70.495 ms, waitGL 0 / 8 ~0.016 ms +XXX[501] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35563 ~70.984 ms, finishGL 49 / 35297 ~70.454 ms, waitGL 0 / 8 ~0.016 ms +XXX[502] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35613 ~70.944 ms, finishGL 50 / 35347 ~70.413 ms, waitGL 0 / 8 ~0.016 ms +XXX[503] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35664 ~70.903 ms, finishGL 49 / 35397 ~70.372 ms, waitGL 0 / 8 ~0.016 ms +XXX[504] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35714 ~70.861 ms, finishGL 49 / 35446 ~70.331 ms, waitGL 0 / 8 ~0.016 ms +XXX[505] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35764 ~70.82 ms, finishGL 49 / 35496 ~70.29 ms, waitGL 0 / 8 ~0.016 ms +XXX[506] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35814 ~70.78 ms, finishGL 49 / 35546 ~70.249 ms, waitGL 0 / 8 ~0.016 ms +XXX[507] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35864 ~70.738 ms, finishGL 48 / 35595 ~70.207 ms, waitGL 0 / 8 ~0.016 ms +XXX[508] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35914 ~70.698 ms, finishGL 50 / 35645 ~70.168 ms, waitGL 0 / 8 ~0.016 ms +XXX[509] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35965 ~70.658 ms, finishGL 49 / 35695 ~70.128 ms, waitGL 0 / 8 ~0.016 ms +XXX[510] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 36015 ~70.618 ms, finishGL 49 / 35744 ~70.088 ms, waitGL 0 / 8 ~0.016 ms +XXX[511] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 36065 ~70.578 ms, finishGL 49 / 35794 ~70.048 ms, waitGL 0 / 8 ~0.016 ms +XXX[512] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 36115 ~70.538 ms, finishGL 49 / 35844 ~70.008 ms, waitGL 0 / 8 ~0.016 ms +XXX[513] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 36166 ~70.5 ms, finishGL 50 / 35895 ~69.971 ms, waitGL 0 / 8 ~0.016 ms +XXX[514] TO 17 ms, lFrame0 0 ms, lFrameX 51 / 36218 ~70.464 ms, finishGL 51 / 35946 ~69.934 ms, waitGL 0 / 8 ~0.016 ms +XXX[515] TO 17 ms, lFrame0 0 ms, lFrameX 52 / 36270 ~70.429 ms, finishGL 51 / 35998 ~69.899 ms, waitGL 0 / 8 ~0.016 ms +XXX[516] TO 17 ms, lFrame0 0 ms, lFrameX 53 / 36324 ~70.396 ms, finishGL 53 / 36051 ~69.866 ms, waitGL 0 / 8 ~0.016 ms +XXX[517] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 36393 ~70.392 ms, finishGL 68 / 36119 ~69.863 ms, waitGL 0 / 8 ~0.016 ms +XXX[518] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 36463 ~70.392 ms, finishGL 69 / 36189 ~69.863 ms, waitGL 0 / 8 ~0.016 ms +XXX[519] TO 17 ms, lFrame0 0 ms, lFrameX 75 / 36539 ~70.402 ms, finishGL 75 / 36264 ~69.873 ms, waitGL 0 / 8 ~0.016 ms +XXX[520] TO 17 ms, lFrame0 0 ms, lFrameX 92 / 36631 ~70.444 ms, finishGL 91 / 36355 ~69.915 ms, waitGL 0 / 8 ~0.016 ms +XXX[521] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 36716 ~70.473 ms, finishGL 85 / 36441 ~69.944 ms, waitGL 0 / 8 ~0.016 ms +XXX[522] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 36799 ~70.496 ms, finishGL 81 / 36522 ~69.967 ms, waitGL 0 / 8 ~0.016 ms +XXX[523] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36882 ~70.521 ms, finishGL 83 / 36606 ~69.992 ms, waitGL 0 / 8 ~0.016 ms +XXX[524] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36965 ~70.545 ms, finishGL 82 / 36688 ~70.016 ms, waitGL 0 / 8 ~0.016 ms +XXX[525] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37048 ~70.569 ms, finishGL 82 / 36771 ~70.04 ms, waitGL 0 / 8 ~0.016 ms +XXX[526] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37131 ~70.592 ms, finishGL 82 / 36853 ~70.063 ms, waitGL 0 / 8 ~0.016 ms +XXX[527] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37215 ~70.616 ms, finishGL 82 / 36936 ~70.087 ms, waitGL 0 / 8 ~0.016 ms +XXX[528] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37298 ~70.64 ms, finishGL 82 / 37019 ~70.111 ms, waitGL 0 / 8 ~0.016 ms +XXX[529] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37381 ~70.665 ms, finishGL 82 / 37101 ~70.136 ms, waitGL 0 / 8 ~0.016 ms +XXX[530] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37465 ~70.688 ms, finishGL 82 / 37184 ~70.159 ms, waitGL 0 / 8 ~0.016 ms +XXX[531] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37548 ~70.712 ms, finishGL 82 / 37267 ~70.183 ms, waitGL 0 / 8 ~0.016 ms +XXX[532] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37632 ~70.737 ms, finishGL 83 / 37350 ~70.208 ms, waitGL 0 / 8 ~0.016 ms +XXX[533] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37714 ~70.759 ms, finishGL 82 / 37432 ~70.23 ms, waitGL 0 / 8 ~0.016 ms +XXX[534] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37798 ~70.782 ms, finishGL 82 / 37515 ~70.253 ms, waitGL 0 / 8 ~0.016 ms +XXX[535] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 37879 ~70.803 ms, finishGL 81 / 37596 ~70.274 ms, waitGL 0 / 8 ~0.016 ms +XXX[536] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37962 ~70.826 ms, finishGL 82 / 37679 ~70.296 ms, waitGL 0 / 8 ~0.016 ms +XXX[537] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38045 ~70.848 ms, finishGL 82 / 37761 ~70.319 ms, waitGL 0 / 8 ~0.016 ms +XXX[538] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38128 ~70.87 ms, finishGL 82 / 37843 ~70.341 ms, waitGL 0 / 8 ~0.016 ms +XXX[539] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38211 ~70.892 ms, finishGL 81 / 37925 ~70.362 ms, waitGL 0 / 8 ~0.016 ms +XXX[540] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38294 ~70.915 ms, finishGL 82 / 38007 ~70.385 ms, waitGL 0 / 8 ~0.016 ms +XXX[541] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38376 ~70.937 ms, finishGL 82 / 38090 ~70.406 ms, waitGL 0 / 8 ~0.016 ms +XXX[542] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38460 ~70.961 ms, finishGL 83 / 38173 ~70.43 ms, waitGL 0 / 8 ~0.016 ms +XXX[543] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38543 ~70.983 ms, finishGL 82 / 38255 ~70.452 ms, waitGL 0 / 8 ~0.016 ms +XXX[544] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38627 ~71.006 ms, finishGL 82 / 38338 ~70.475 ms, waitGL 0 / 8 ~0.016 ms +XXX[545] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38710 ~71.029 ms, finishGL 82 / 38421 ~70.498 ms, waitGL 0 / 8 ~0.016 ms +XXX[546] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38794 ~71.051 ms, finishGL 82 / 38504 ~70.521 ms, waitGL 0 / 8 ~0.016 ms +XXX[547] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 38878 ~71.076 ms, finishGL 83 / 38588 ~70.545 ms, waitGL 0 / 8 ~0.016 ms +XXX[548] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 38963 ~71.1 ms, finishGL 84 / 38672 ~70.57 ms, waitGL 0 / 8 ~0.016 ms +XXX[549] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39046 ~71.122 ms, finishGL 82 / 38755 ~70.592 ms, waitGL 0 / 8 ~0.016 ms +XXX[550] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 39130 ~71.147 ms, finishGL 83 / 38839 ~70.616 ms, waitGL 0 / 8 ~0.016 ms +XXX[551] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39214 ~71.169 ms, finishGL 83 / 38922 ~70.639 ms, waitGL 0 / 8 ~0.016 ms +XXX[552] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 39299 ~71.194 ms, finishGL 84 / 39006 ~70.664 ms, waitGL 0 / 8 ~0.016 ms +XXX[553] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39381 ~71.214 ms, finishGL 82 / 39088 ~70.684 ms, waitGL 0 / 9 ~0.016 ms +XXX[554] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 39463 ~71.233 ms, finishGL 80 / 39169 ~70.703 ms, waitGL 0 / 9 ~0.016 ms +XXX[555] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39545 ~71.253 ms, finishGL 82 / 39251 ~70.724 ms, waitGL 0 / 9 ~0.016 ms +XXX[556] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39628 ~71.274 ms, finishGL 82 / 39334 ~70.744 ms, waitGL 0 / 9 ~0.016 ms +XXX[557] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39710 ~71.293 ms, finishGL 81 / 39415 ~70.763 ms, waitGL 0 / 9 ~0.016 ms +XXX[558] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39793 ~71.313 ms, finishGL 81 / 39497 ~70.783 ms, waitGL 0 / 9 ~0.016 ms +XXX[559] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 39873 ~71.33 ms, finishGL 80 / 39577 ~70.8 ms, waitGL 0 / 9 ~0.016 ms +XXX[560] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39956 ~71.35 ms, finishGL 82 / 39659 ~70.82 ms, waitGL 0 / 9 ~0.016 ms +XXX[561] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 40038 ~71.369 ms, finishGL 81 / 39741 ~70.839 ms, waitGL 0 / 9 ~0.016 ms +XXX[562] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 40120 ~71.388 ms, finishGL 81 / 39822 ~70.858 ms, waitGL 0 / 9 ~0.016 ms +XXX[563] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 40201 ~71.406 ms, finishGL 80 / 39903 ~70.876 ms, waitGL 0 / 9 ~0.016 ms +XXX[564] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 40282 ~71.423 ms, finishGL 80 / 39983 ~70.893 ms, waitGL 0 / 9 ~0.016 ms +XXX[565] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 40364 ~71.441 ms, finishGL 81 / 40065 ~70.911 ms, waitGL 0 / 9 ~0.016 ms +XXX[566] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40429 ~71.43 ms, finishGL 64 / 40130 ~70.901 ms, waitGL 0 / 9 ~0.016 ms +XXX[567] TO 17 ms, lFrame0 0 ms, lFrameX 64 / 40494 ~71.419 ms, finishGL 64 / 40194 ~70.889 ms, waitGL 0 / 9 ~0.016 ms +XXX[568] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40560 ~71.408 ms, finishGL 64 / 40258 ~70.878 ms, waitGL 0 / 9 ~0.016 ms +XXX[569] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40625 ~71.398 ms, finishGL 65 / 40324 ~70.868 ms, waitGL 0 / 9 ~0.016 ms +XXX[570] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40691 ~71.388 ms, finishGL 65 / 40389 ~70.858 ms, waitGL 0 / 9 ~0.016 ms +XXX[571] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40756 ~71.378 ms, finishGL 64 / 40454 ~70.847 ms, waitGL 0 / 9 ~0.016 ms +XXX[572] TO 17 ms, lFrame0 0 ms, lFrameX 68 / 40825 ~71.372 ms, finishGL 67 / 40521 ~70.842 ms, waitGL 0 / 9 ~0.016 ms +XXX[573] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40890 ~71.362 ms, finishGL 64 / 40586 ~70.831 ms, waitGL 0 / 9 ~0.016 ms +XXX[574] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40956 ~71.353 ms, finishGL 65 / 40651 ~70.822 ms, waitGL 0 / 9 ~0.016 ms +XXX[575] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 41023 ~71.345 ms, finishGL 66 / 40718 ~70.814 ms, waitGL 0 / 9 ~0.016 ms +XXX[576] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 41089 ~71.336 ms, finishGL 65 / 40783 ~70.804 ms, waitGL 0 / 9 ~0.016 ms +XXX[577] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 41155 ~71.327 ms, finishGL 65 / 40848 ~70.795 ms, waitGL 0 / 9 ~0.016 ms +XXX[578] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 41223 ~71.321 ms, finishGL 67 / 40916 ~70.789 ms, waitGL 0 / 9 ~0.016 ms +XXX[579] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 41293 ~71.319 ms, finishGL 69 / 40985 ~70.787 ms, waitGL 0 / 9 ~0.016 ms +XXX[580] TO 17 ms, lFrame0 0 ms, lFrameX 70 / 41364 ~71.318 ms, finishGL 70 / 41056 ~70.786 ms, waitGL 0 / 9 ~0.016 ms +XXX[581] TO 17 ms, lFrame0 0 ms, lFrameX 89 / 41454 ~71.349 ms, finishGL 89 / 41145 ~70.818 ms, waitGL 0 / 9 ~0.016 ms +XXX[582] TO 17 ms, lFrame0 0 ms, lFrameX 86 / 41540 ~71.376 ms, finishGL 86 / 41231 ~70.844 ms, waitGL 0 / 9 ~0.016 ms +XXX[583] TO 17 ms, lFrame0 0 ms, lFrameX 85 / 41626 ~71.401 ms, finishGL 85 / 41317 ~70.869 ms, waitGL 0 / 9 ~0.016 ms +XXX[584] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 41710 ~71.422 ms, finishGL 83 / 41400 ~70.891 ms, waitGL 0 / 9 ~0.016 ms +XXX[585] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 41792 ~71.44 ms, finishGL 81 / 41481 ~70.909 ms, waitGL 0 / 9 ~0.016 ms +XXX[586] TO 17 ms, lFrame0 0 ms, lFrameX 80 / 41873 ~71.456 ms, finishGL 80 / 41562 ~70.925 ms, waitGL 0 / 9 ~0.016 ms +XXX[587] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 41955 ~71.474 ms, finishGL 81 / 41644 ~70.943 ms, waitGL 0 / 9 ~0.016 ms +XXX[588] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42038 ~71.494 ms, finishGL 82 / 41726 ~70.963 ms, waitGL 0 / 9 ~0.016 ms +XXX[589] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42121 ~71.513 ms, finishGL 82 / 41808 ~70.982 ms, waitGL 0 / 9 ~0.016 ms +XXX[590] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 42203 ~71.532 ms, finishGL 81 / 41890 ~71.0 ms, waitGL 0 / 9 ~0.016 ms +XXX[591] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42286 ~71.551 ms, finishGL 82 / 41972 ~71.019 ms, waitGL 0 / 9 ~0.016 ms +XXX[592] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42369 ~71.57 ms, finishGL 82 / 42054 ~71.038 ms, waitGL 0 / 9 ~0.016 ms +XXX[593] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 42453 ~71.591 ms, finishGL 83 / 42138 ~71.059 ms, waitGL 0 / 9 ~0.016 ms +XXX[594] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42536 ~71.609 ms, finishGL 81 / 42220 ~71.078 ms, waitGL 0 / 9 ~0.016 ms +XXX[595] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42620 ~71.63 ms, finishGL 83 / 42303 ~71.099 ms, waitGL 0 / 9 ~0.016 ms +XXX[596] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42703 ~71.65 ms, finishGL 83 / 42387 ~71.119 ms, waitGL 0 / 9 ~0.016 ms +XXX[597] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 42788 ~71.672 ms, finishGL 84 / 42471 ~71.141 ms, waitGL 0 / 9 ~0.016 ms +XXX[598] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42871 ~71.692 ms, finishGL 82 / 42554 ~71.16 ms, waitGL 0 / 9 ~0.016 ms +XXX[599] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 42956 ~71.713 ms, finishGL 83 / 42637 ~71.181 ms, waitGL 0 / 9 ~0.016 ms +XXX[600] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43038 ~71.73 ms, finishGL 81 / 42719 ~71.199 ms, waitGL 0 / 9 ~0.016 ms +XXX[601] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 43120 ~71.747 ms, finishGL 81 / 42800 ~71.216 ms, waitGL 0 / 9 ~0.016 ms +XXX[602] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 43202 ~71.764 ms, finishGL 81 / 42881 ~71.232 ms, waitGL 0 / 9 ~0.016 ms +XXX[603] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43284 ~71.781 ms, finishGL 81 / 42963 ~71.248 ms, waitGL 0 / 9 ~0.016 ms +XXX[604] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43366 ~71.799 ms, finishGL 82 / 43045 ~71.267 ms, waitGL 0 / 9 ~0.016 ms +XXX[605] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 43449 ~71.818 ms, finishGL 82 / 43128 ~71.285 ms, waitGL 0 / 9 ~0.016 ms diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync1-finish-wait.log b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync1-finish-wait.log new file mode 100644 index 000000000..940cad603 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735.OSX.CALayer.Perf.logs/aaaa-m2-sync1-finish-wait.log @@ -0,0 +1,745 @@ +NSZombieEnabled +NSTraceEvents YES +OBJC_PRINT_EXCEPTIONS +/usr/bin/java +java version "1.6.0_37" +Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909) +Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode) +LD_LIBRARY_PATH :../../gluegen/make/../build-macosx/obj:../build-macosx/lib +LIBXCB_ALLOW_SLOPPY_LOCK: +LIBGL_DRIVERS_PATH: +LIBGL_DEBUG: +LIBGL_ALWAYS_INDIRECT: +LIBGL_ALWAYS_SOFTWARE: +SWT_CLASSPATH: ../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar +/usr/bin/java -d64 -time 100000 -vsyncN 0 +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar +CLASSPATH .:../../gluegen/make/../build-macosx/gluegen-rt.jar:../build-macosx/jar/jogl-all.jar:../build-macosx/jar/jogl-test.jar:../build-macosx/../make/lib/swt/cocoa-macosx-x86_64/swt-debug.jar:../../gluegen/make/../make/lib/junit.jar:/opt-share/apache-ant/lib/ant.jar:/opt-share/apache-ant/lib/ant-junit.jar + +Test Start: com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsyncN 0 + +/usr/bin/java -d64 -Djava.awt.headless=false -Djogl.debug.calayer.SwapM2 com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT -time 100000 -vsyncN 0 +swapInterval 1 +exclusiveContext false +SWAP_M1 false +SWAP_M2 true +NewtCanvasAWT.attachNewtChild.2: size 500x268 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init ... +LandscapeES2 init on Thread[main-Display-.macosx_nil-1-EDT-1,5,main] +Chosen GLCapabilities: GLCaps[rgba 8/8/8/0, opaque, accum-rgba 0/0/0/0, dp/st/ms 24/0/0, dbl, mono , hw, GLProfile[GL2/GL2.hw], offscr[fbo]] +INIT GL IS: jogamp.opengl.gl4.GL4bcImpl +GL_VENDOR: NVIDIA Corporation +GL_RENDERER: NVIDIA GeForce 320M OpenGL Engine +GL_VERSION: 2.1 NVIDIA-7.32.12 +GL GLSL: true, has-compiler-func: true, version 1.20, 1.20.0 +GL FBO: basic true, full true +GL Profile: GLProfile[GL2/GL2.hw] +GL Renderer Quirks:[NoOffscreenBitmap] +GL:jogamp.opengl.gl4.GL4bcImpl@7b7a4989, 2.1 (hardware) - 2.1 NVIDIA-7.32.12 +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.init FIN +Thread[main-Display-.macosx_nil-1-EDT-1,5,main] LandscapeES2.reshape 0/0 500x268, swapInterval 1, drawable 0x7fd1cbcd7ed0 +Thread[AWT-EventQueue-0,6,main] LandscapeES2.reshape 0/0 500x268, swapInterval 1, drawable 0x7fd1cbcd7ed0 +XXX[1] TO 17 ms, lFrame0 110 ms, lFrameX 849 / 849 ~849.6 ms, finishGL 736 / 736 ~736.509 ms, waitGL 2 / 2 ~2.611 ms +XXX[2] TO 17 ms, lFrame0 89 ms, lFrameX 182 / 1031 ~515.996 ms, finishGL 88 / 825 ~412.638 ms, waitGL 3 / 6 ~3.222 ms +XXX[3] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 1115 ~371.971 ms, finishGL 80 / 905 ~301.799 ms, waitGL 2 / 8 ~2.84 ms +XXX[4] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 1214 ~303.748 ms, finishGL 95 / 1001 ~250.348 ms, waitGL 2 / 11 ~2.756 ms +XXX[5] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 1298 ~259.668 ms, finishGL 80 / 1081 ~216.348 ms, waitGL 2 / 13 ~2.67 ms +XXX[6] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 1381 ~230.176 ms, finishGL 79 / 1161 ~193.531 ms, waitGL 1 / 15 ~2.523 ms +XXX[7] TO 17 ms, lFrame0 1 ms, lFrameX 100 / 1481 ~211.599 ms, finishGL 93 / 1255 ~179.308 ms, waitGL 4 / 19 ~2.805 ms +XXX[8] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1564 ~195.509 ms, finishGL 78 / 1333 ~166.666 ms, waitGL 4 / 23 ~2.965 ms +XXX[9] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 1647 ~183.082 ms, finishGL 78 / 1411 ~156.839 ms, waitGL 4 / 28 ~3.128 ms +XXX[10] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1730 ~173.057 ms, finishGL 77 / 1489 ~148.941 ms, waitGL 4 / 32 ~3.258 ms +XXX[11] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1813 ~164.847 ms, finishGL 77 / 1566 ~142.424 ms, waitGL 4 / 37 ~3.391 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 1913 ~159.477 ms, finishGL 93 / 1659 ~138.306 ms, waitGL 6 / 44 ~3.681 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 1996 ~153.553 ms, finishGL 75 / 1735 ~133.48 ms, waitGL 5 / 50 ~3.853 ms +XXX[14] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2079 ~148.52 ms, finishGL 75 / 1810 ~129.351 ms, waitGL 6 / 56 ~4.045 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 2180 ~145.336 ms, finishGL 90 / 1901 ~126.785 ms, waitGL 9 / 65 ~4.378 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2262 ~141.415 ms, finishGL 74 / 1976 ~123.506 ms, waitGL 7 / 73 ~4.576 ms +XXX[17] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2345 ~137.958 ms, finishGL 74 / 2050 ~120.613 ms, waitGL 7 / 80 ~4.751 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 2446 ~135.894 ms, finishGL 90 / 2141 ~118.948 ms, waitGL 9 / 90 ~5.025 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2528 ~133.085 ms, finishGL 74 / 2215 ~116.618 ms, waitGL 7 / 97 ~5.149 ms +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2611 ~130.572 ms, finishGL 74 / 2290 ~114.523 ms, waitGL 7 / 105 ~5.273 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 2712 ~129.145 ms, finishGL 91 / 2381 ~113.407 ms, waitGL 9 / 114 ~5.456 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 2794 ~127.016 ms, finishGL 75 / 2456 ~111.662 ms, waitGL 6 / 121 ~5.517 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 2877 ~125.106 ms, finishGL 74 / 2531 ~110.048 ms, waitGL 7 / 129 ~5.619 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 2978 ~124.095 ms, finishGL 86 / 2617 ~109.073 ms, waitGL 13 / 142 ~5.948 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3061 ~122.451 ms, finishGL 69 / 2687 ~107.499 ms, waitGL 12 / 155 ~6.224 ms +XXX[26] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 3143 ~120.916 ms, finishGL 69 / 2756 ~106.024 ms, waitGL 12 / 168 ~6.469 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 3227 ~119.539 ms, finishGL 68 / 2824 ~104.617 ms, waitGL 15 / 183 ~6.797 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 3310 ~118.236 ms, finishGL 67 / 2891 ~103.284 ms, waitGL 15 / 198 ~7.097 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 3393 ~117.023 ms, finishGL 66 / 2958 ~102.005 ms, waitGL 16 / 214 ~7.411 ms +XXX[30] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 3476 ~115.89 ms, finishGL 65 / 3023 ~100.789 ms, waitGL 16 / 231 ~7.715 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3543 ~114.294 ms, finishGL 64 / 3088 ~99.614 ms, waitGL 1 / 233 ~7.516 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3608 ~112.769 ms, finishGL 63 / 3151 ~98.498 ms, waitGL 0 / 233 ~7.311 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 3692 ~111.899 ms, finishGL 79 / 3231 ~97.929 ms, waitGL 3 / 237 ~7.203 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3758 ~110.539 ms, finishGL 63 / 3295 ~96.913 ms, waitGL 1 / 239 ~7.047 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3824 ~109.274 ms, finishGL 63 / 3358 ~95.955 ms, waitGL 2 / 241 ~6.908 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 3908 ~108.567 ms, finishGL 78 / 3437 ~95.474 ms, waitGL 4 / 246 ~6.847 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 3974 ~107.41 ms, finishGL 63 / 3500 ~94.603 ms, waitGL 2 / 248 ~6.72 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4040 ~106.341 ms, finishGL 62 / 3562 ~93.755 ms, waitGL 3 / 252 ~6.638 ms +XXX[39] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4107 ~105.31 ms, finishGL 61 / 3624 ~92.927 ms, waitGL 3 / 255 ~6.558 ms +XXX[40] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4173 ~104.339 ms, finishGL 61 / 3685 ~92.135 ms, waitGL 4 / 259 ~6.498 ms +XXX[41] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4240 ~103.417 ms, finishGL 60 / 3746 ~91.37 ms, waitGL 4 / 264 ~6.454 ms +XXX[42] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4306 ~102.536 ms, finishGL 60 / 3806 ~90.628 ms, waitGL 5 / 269 ~6.424 ms +XXX[43] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4372 ~101.696 ms, finishGL 60 / 3866 ~89.923 ms, waitGL 5 / 274 ~6.391 ms +XXX[44] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4439 ~100.895 ms, finishGL 60 / 3926 ~89.245 ms, waitGL 5 / 280 ~6.365 ms +XXX[45] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4506 ~100.135 ms, finishGL 60 / 3986 ~88.596 ms, waitGL 5 / 285 ~6.349 ms +XXX[46] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4572 ~99.399 ms, finishGL 59 / 4046 ~87.965 ms, waitGL 5 / 291 ~6.331 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 4639 ~98.711 ms, finishGL 59 / 4106 ~87.361 ms, waitGL 6 / 298 ~6.341 ms +XXX[48] TO 17 ms, lFrame0 1 ms, lFrameX 65 / 4705 ~98.027 ms, finishGL 59 / 4165 ~86.771 ms, waitGL 5 / 303 ~6.329 ms +XXX[49] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4771 ~97.382 ms, finishGL 59 / 4224 ~86.213 ms, waitGL 6 / 310 ~6.329 ms +XXX[50] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 4838 ~96.763 ms, finishGL 59 / 4283 ~85.67 ms, waitGL 6 / 316 ~6.336 ms +XXX[51] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 4904 ~96.166 ms, finishGL 58 / 4342 ~85.145 ms, waitGL 6 / 323 ~6.336 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 4971 ~95.613 ms, finishGL 58 / 4400 ~84.625 ms, waitGL 8 / 331 ~6.383 ms +XXX[53] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5037 ~95.056 ms, finishGL 58 / 4459 ~84.139 ms, waitGL 6 / 338 ~6.389 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5104 ~94.527 ms, finishGL 58 / 4518 ~83.667 ms, waitGL 7 / 345 ~6.407 ms +XXX[55] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 5170 ~94.001 ms, finishGL 58 / 4576 ~83.211 ms, waitGL 6 / 352 ~6.407 ms +XXX[56] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 5236 ~93.515 ms, finishGL 58 / 4635 ~82.77 ms, waitGL 7 / 359 ~6.42 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5303 ~93.048 ms, finishGL 58 / 4693 ~82.348 ms, waitGL 7 / 367 ~6.443 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5370 ~92.591 ms, finishGL 58 / 4752 ~81.938 ms, waitGL 7 / 374 ~6.463 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5436 ~92.142 ms, finishGL 58 / 4811 ~81.548 ms, waitGL 6 / 381 ~6.464 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5502 ~91.713 ms, finishGL 59 / 4870 ~81.18 ms, waitGL 6 / 387 ~6.463 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5569 ~91.299 ms, finishGL 59 / 4930 ~80.821 ms, waitGL 6 / 394 ~6.467 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 5635 ~90.89 ms, finishGL 59 / 4989 ~80.482 ms, waitGL 5 / 400 ~6.453 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5701 ~90.504 ms, finishGL 59 / 5049 ~80.152 ms, waitGL 6 / 406 ~6.449 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5768 ~90.129 ms, finishGL 59 / 5109 ~79.837 ms, waitGL 6 / 412 ~6.444 ms +XXX[65] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5834 ~89.765 ms, finishGL 60 / 5169 ~79.537 ms, waitGL 5 / 417 ~6.429 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5901 ~89.412 ms, finishGL 60 / 5230 ~79.256 ms, waitGL 5 / 422 ~6.408 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5967 ~89.07 ms, finishGL 61 / 5292 ~78.986 ms, waitGL 4 / 427 ~6.386 ms +XXX[68] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6033 ~88.733 ms, finishGL 61 / 5353 ~78.728 ms, waitGL 4 / 432 ~6.353 ms +XXX[69] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6100 ~88.413 ms, finishGL 61 / 5415 ~78.484 ms, waitGL 4 / 436 ~6.323 ms +XXX[70] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6166 ~88.092 ms, finishGL 62 / 5477 ~78.254 ms, waitGL 3 / 439 ~6.279 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6233 ~87.802 ms, finishGL 62 / 5540 ~78.028 ms, waitGL 4 / 444 ~6.257 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6299 ~87.495 ms, finishGL 61 / 5602 ~77.805 ms, waitGL 3 / 447 ~6.216 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6366 ~87.213 ms, finishGL 61 / 5663 ~77.582 ms, waitGL 4 / 452 ~6.199 ms +XXX[74] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 6432 ~86.931 ms, finishGL 60 / 5724 ~77.354 ms, waitGL 4 / 457 ~6.177 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6499 ~86.656 ms, finishGL 60 / 5784 ~77.128 ms, waitGL 5 / 462 ~6.166 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6565 ~86.393 ms, finishGL 59 / 5844 ~76.902 ms, waitGL 6 / 468 ~6.164 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6632 ~86.135 ms, finishGL 60 / 5904 ~76.685 ms, waitGL 5 / 474 ~6.16 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6698 ~85.878 ms, finishGL 60 / 5965 ~76.476 ms, waitGL 5 / 479 ~6.148 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6765 ~85.634 ms, finishGL 60 / 6025 ~76.277 ms, waitGL 5 / 484 ~6.138 ms +XXX[80] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6831 ~85.388 ms, finishGL 60 / 6086 ~76.083 ms, waitGL 4 / 489 ~6.12 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6898 ~85.162 ms, finishGL 60 / 6147 ~75.896 ms, waitGL 5 / 495 ~6.115 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6964 ~84.932 ms, finishGL 61 / 6209 ~75.721 ms, waitGL 4 / 499 ~6.093 ms +XXX[83] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7030 ~84.709 ms, finishGL 62 / 6271 ~75.56 ms, waitGL 3 / 503 ~6.062 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7097 ~84.491 ms, finishGL 62 / 6333 ~75.399 ms, waitGL 3 / 506 ~6.032 ms +XXX[85] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7163 ~84.28 ms, finishGL 61 / 6395 ~75.241 ms, waitGL 3 / 510 ~6.007 ms +XXX[86] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7230 ~84.076 ms, finishGL 62 / 6458 ~75.095 ms, waitGL 3 / 514 ~5.977 ms +XXX[87] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7296 ~83.87 ms, finishGL 63 / 6521 ~74.958 ms, waitGL 2 / 516 ~5.938 ms +XXX[88] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7363 ~83.676 ms, finishGL 62 / 6584 ~74.819 ms, waitGL 3 / 520 ~5.913 ms +XXX[89] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7430 ~83.483 ms, finishGL 62 / 6646 ~74.684 ms, waitGL 3 / 523 ~5.881 ms +XXX[90] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7496 ~83.293 ms, finishGL 62 / 6709 ~74.544 ms, waitGL 3 / 527 ~5.859 ms +XXX[91] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7562 ~83.108 ms, finishGL 62 / 6771 ~74.411 ms, waitGL 3 / 531 ~5.835 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7629 ~82.927 ms, finishGL 62 / 6833 ~74.281 ms, waitGL 3 / 534 ~5.811 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7695 ~82.751 ms, finishGL 61 / 6895 ~74.146 ms, waitGL 4 / 538 ~5.792 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7762 ~82.579 ms, finishGL 61 / 6957 ~74.016 ms, waitGL 4 / 542 ~5.775 ms +XXX[95] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7828 ~82.408 ms, finishGL 62 / 7019 ~73.893 ms, waitGL 3 / 546 ~5.753 ms +XXX[96] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7895 ~82.243 ms, finishGL 62 / 7081 ~73.769 ms, waitGL 4 / 550 ~5.736 ms +XXX[97] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 7962 ~82.082 ms, finishGL 61 / 7143 ~73.641 ms, waitGL 4 / 555 ~5.727 ms +XXX[98] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8028 ~81.924 ms, finishGL 60 / 7204 ~73.511 ms, waitGL 5 / 560 ~5.721 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8095 ~81.77 ms, finishGL 60 / 7265 ~73.385 ms, waitGL 5 / 566 ~5.717 ms +XXX[1] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 66 ~66.52 ms, finishGL 60 / 60 ~60.267 ms, waitGL 5 / 5 ~5.535 ms +XXX[2] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 132 ~66.402 ms, finishGL 59 / 120 ~60.116 ms, waitGL 5 / 11 ~5.576 ms +XXX[3] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 198 ~66.297 ms, finishGL 59 / 180 ~60.016 ms, waitGL 5 / 16 ~5.646 ms +XXX[4] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 265 ~66.437 ms, finishGL 60 / 240 ~60.014 ms, waitGL 6 / 23 ~5.809 ms +XXX[5] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 332 ~66.458 ms, finishGL 59 / 299 ~59.909 ms, waitGL 6 / 29 ~5.929 ms +XXX[6] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 398 ~66.452 ms, finishGL 59 / 358 ~59.831 ms, waitGL 6 / 36 ~6.026 ms +XXX[7] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 465 ~66.461 ms, finishGL 58 / 417 ~59.693 ms, waitGL 7 / 43 ~6.184 ms +XXX[8] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 531 ~66.442 ms, finishGL 59 / 477 ~59.686 ms, waitGL 6 / 49 ~6.182 ms +XXX[9] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 597 ~66.442 ms, finishGL 59 / 537 ~59.686 ms, waitGL 6 / 55 ~6.196 ms +XXX[10] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 664 ~66.417 ms, finishGL 61 / 598 ~59.828 ms, waitGL 4 / 60 ~6.038 ms +XXX[11] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 730 ~66.425 ms, finishGL 61 / 659 ~59.986 ms, waitGL 4 / 64 ~5.896 ms +XXX[12] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 797 ~66.433 ms, finishGL 60 / 720 ~60.066 ms, waitGL 5 / 69 ~5.826 ms +XXX[13] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 863 ~66.411 ms, finishGL 60 / 780 ~60.063 ms, waitGL 5 / 75 ~5.792 ms +XXX[14] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 930 ~66.443 ms, finishGL 59 / 840 ~60.054 ms, waitGL 6 / 81 ~5.835 ms +XXX[15] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 996 ~66.419 ms, finishGL 59 / 900 ~60.025 ms, waitGL 5 / 87 ~5.845 ms +XXX[16] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1063 ~66.45 ms, finishGL 59 / 959 ~59.969 ms, waitGL 7 / 94 ~5.918 ms +XXX[17] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1129 ~66.444 ms, finishGL 59 / 1018 ~59.933 ms, waitGL 6 / 101 ~5.952 ms +XXX[18] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1195 ~66.444 ms, finishGL 59 / 1078 ~59.91 ms, waitGL 6 / 107 ~5.973 ms +XXX[19] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1262 ~66.438 ms, finishGL 60 / 1138 ~59.931 ms, waitGL 5 / 113 ~5.949 ms +FrameCount: 120 - FrameRate: 15.0 +XXX[20] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1328 ~66.439 ms, finishGL 60 / 1199 ~59.954 ms, waitGL 5 / 118 ~5.924 ms +XXX[21] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1395 ~66.459 ms, finishGL 61 / 1260 ~60.005 ms, waitGL 5 / 123 ~5.898 ms +XXX[22] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 1461 ~66.436 ms, finishGL 61 / 1321 ~60.064 ms, waitGL 3 / 127 ~5.802 ms +XXX[23] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1528 ~66.437 ms, finishGL 62 / 1383 ~60.164 ms, waitGL 3 / 131 ~5.71 ms +XXX[24] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1594 ~66.428 ms, finishGL 62 / 1446 ~60.279 ms, waitGL 2 / 134 ~5.592 ms +XXX[25] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1661 ~66.449 ms, finishGL 62 / 1509 ~60.379 ms, waitGL 3 / 137 ~5.519 ms +XXX[26] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1727 ~66.438 ms, finishGL 63 / 1572 ~60.495 ms, waitGL 2 / 140 ~5.397 ms +XXX[27] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 1794 ~66.47 ms, finishGL 63 / 1636 ~60.62 ms, waitGL 3 / 143 ~5.309 ms +XXX[28] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1860 ~66.46 ms, finishGL 63 / 1699 ~60.705 ms, waitGL 2 / 146 ~5.219 ms +XXX[29] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 1926 ~66.444 ms, finishGL 63 / 1763 ~60.801 ms, waitGL 1 / 148 ~5.106 ms +XXX[30] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 1993 ~66.448 ms, finishGL 63 / 1827 ~60.905 ms, waitGL 2 / 150 ~5.01 ms +XXX[31] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2060 ~66.46 ms, finishGL 63 / 1890 ~60.984 ms, waitGL 3 / 153 ~4.947 ms +XXX[32] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2126 ~66.45 ms, finishGL 63 / 1953 ~61.047 ms, waitGL 2 / 155 ~4.866 ms +XXX[33] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2193 ~66.463 ms, finishGL 62 / 2016 ~61.095 ms, waitGL 3 / 159 ~4.835 ms +XXX[34] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2259 ~66.454 ms, finishGL 62 / 2078 ~61.142 ms, waitGL 2 / 162 ~4.778 ms +XXX[35] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 2326 ~66.477 ms, finishGL 63 / 2142 ~61.22 ms, waitGL 3 / 165 ~4.727 ms +XXX[36] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 2392 ~66.457 ms, finishGL 63 / 2205 ~61.272 ms, waitGL 2 / 167 ~4.658 ms +XXX[37] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2458 ~66.459 ms, finishGL 63 / 2268 ~61.323 ms, waitGL 2 / 170 ~4.611 ms +XXX[38] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2525 ~66.457 ms, finishGL 63 / 2332 ~61.38 ms, waitGL 2 / 173 ~4.556 ms +XXX[39] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2591 ~66.459 ms, finishGL 63 / 2395 ~61.43 ms, waitGL 2 / 175 ~4.508 ms +XXX[40] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2658 ~66.458 ms, finishGL 63 / 2458 ~61.472 ms, waitGL 2 / 178 ~4.467 ms +XXX[41] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2725 ~66.47 ms, finishGL 63 / 2522 ~61.516 ms, waitGL 3 / 181 ~4.438 ms +XXX[42] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2791 ~66.471 ms, finishGL 63 / 2585 ~61.552 ms, waitGL 3 / 185 ~4.405 ms +XXX[43] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2857 ~66.464 ms, finishGL 63 / 2648 ~61.589 ms, waitGL 2 / 187 ~4.364 ms +XXX[44] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2924 ~66.466 ms, finishGL 62 / 2710 ~61.611 ms, waitGL 3 / 191 ~4.346 ms +XXX[45] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 2991 ~66.47 ms, finishGL 61 / 2772 ~61.615 ms, waitGL 4 / 195 ~4.347 ms +XXX[46] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3058 ~66.48 ms, finishGL 60 / 2833 ~61.592 ms, waitGL 5 / 201 ~4.383 ms +XXX[47] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3124 ~66.479 ms, finishGL 58 / 2891 ~61.531 ms, waitGL 7 / 208 ~4.444 ms +XXX[48] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3191 ~66.483 ms, finishGL 56 / 2948 ~61.417 ms, waitGL 10 / 219 ~4.563 ms +XXX[49] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3257 ~66.482 ms, finishGL 52 / 3000 ~61.228 ms, waitGL 13 / 232 ~4.751 ms +XXX[50] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3307 ~66.146 ms, finishGL 47 / 3047 ~60.945 ms, waitGL 2 / 234 ~4.698 ms +XXX[51] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 3373 ~66.144 ms, finishGL 59 / 3106 ~60.92 ms, waitGL 5 / 240 ~4.721 ms +XXX[52] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3422 ~65.821 ms, finishGL 42 / 3149 ~60.571 ms, waitGL 5 / 246 ~4.737 ms +XXX[53] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 3472 ~65.521 ms, finishGL 41 / 3191 ~60.216 ms, waitGL 7 / 253 ~4.782 ms +XXX[54] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 3539 ~65.552 ms, finishGL 57 / 3248 ~60.158 ms, waitGL 9 / 263 ~4.872 ms +XXX[55] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 3588 ~65.246 ms, finishGL 40 / 3288 ~59.799 ms, waitGL 7 / 270 ~4.925 ms +XXX[56] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 3638 ~64.97 ms, finishGL 40 / 3328 ~59.446 ms, waitGL 8 / 279 ~4.993 ms +XXX[57] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 3705 ~65.014 ms, finishGL 55 / 3384 ~59.376 ms, waitGL 11 / 290 ~5.104 ms +XXX[58] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3755 ~64.75 ms, finishGL 38 / 3423 ~59.018 ms, waitGL 10 / 301 ~5.193 ms +XXX[59] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3805 ~64.497 ms, finishGL 38 / 3461 ~58.667 ms, waitGL 10 / 311 ~5.285 ms +XXX[60] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3855 ~64.251 ms, finishGL 37 / 3499 ~58.319 ms, waitGL 11 / 323 ~5.386 ms +XXX[61] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3904 ~64.014 ms, finishGL 37 / 3536 ~57.97 ms, waitGL 11 / 334 ~5.491 ms +XXX[62] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 3954 ~63.784 ms, finishGL 36 / 3572 ~57.617 ms, waitGL 13 / 348 ~5.613 ms +XXX[63] TO 17 ms, lFrame0 0 ms, lFrameX 48 / 4003 ~63.545 ms, finishGL 34 / 3607 ~57.256 ms, waitGL 13 / 361 ~5.732 ms +XXX[64] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 4053 ~63.336 ms, finishGL 33 / 3640 ~56.886 ms, waitGL 15 / 376 ~5.889 ms +XXX[65] TO 17 ms, lFrame0 1 ms, lFrameX 50 / 4103 ~63.138 ms, finishGL 32 / 3673 ~56.51 ms, waitGL 16 / 393 ~6.059 ms +XXX[66] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 4153 ~62.935 ms, finishGL 31 / 3704 ~56.132 ms, waitGL 17 / 411 ~6.229 ms +XXX[67] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4186 ~62.489 ms, finishGL 30 / 3735 ~55.75 ms, waitGL 1 / 413 ~6.164 ms +XXX[68] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4219 ~62.058 ms, finishGL 29 / 3764 ~55.366 ms, waitGL 2 / 415 ~6.117 ms +XXX[69] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 4269 ~61.872 ms, finishGL 44 / 3808 ~55.202 ms, waitGL 4 / 420 ~6.093 ms +XXX[70] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4302 ~61.462 ms, finishGL 27 / 3836 ~54.811 ms, waitGL 4 / 425 ~6.075 ms +XXX[71] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4335 ~61.06 ms, finishGL 27 / 3864 ~54.424 ms, waitGL 4 / 430 ~6.06 ms +XXX[72] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 4385 ~60.91 ms, finishGL 42 / 3907 ~54.264 ms, waitGL 6 / 437 ~6.071 ms +XXX[73] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4418 ~60.527 ms, finishGL 25 / 3932 ~53.871 ms, waitGL 6 / 443 ~6.078 ms +XXX[74] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4451 ~60.15 ms, finishGL 25 / 3957 ~53.482 ms, waitGL 6 / 450 ~6.088 ms +XXX[75] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 4501 ~60.016 ms, finishGL 40 / 3998 ~53.31 ms, waitGL 9 / 459 ~6.128 ms +XXX[76] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4534 ~59.662 ms, finishGL 23 / 4021 ~52.916 ms, waitGL 9 / 468 ~6.169 ms +XXX[77] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4567 ~59.314 ms, finishGL 22 / 4044 ~52.527 ms, waitGL 9 / 478 ~6.209 ms +XXX[78] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 4617 ~59.204 ms, finishGL 38 / 4083 ~52.35 ms, waitGL 11 / 489 ~6.278 ms +XXX[79] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4651 ~58.873 ms, finishGL 23 / 4106 ~51.979 ms, waitGL 9 / 499 ~6.317 ms +XXX[80] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4683 ~58.54 ms, finishGL 23 / 4129 ~51.619 ms, waitGL 8 / 507 ~6.344 ms +XXX[81] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 4716 ~58.226 ms, finishGL 23 / 4152 ~51.269 ms, waitGL 9 / 516 ~6.379 ms +XXX[82] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 4767 ~58.135 ms, finishGL 38 / 4191 ~51.116 ms, waitGL 11 / 528 ~6.439 ms +XXX[83] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4799 ~57.826 ms, finishGL 26 / 4218 ~50.823 ms, waitGL 4 / 532 ~6.421 ms +XXX[84] TO 17 ms, lFrame0 0 ms, lFrameX 32 / 4832 ~57.528 ms, finishGL 30 / 4248 ~50.576 ms, waitGL 2 / 534 ~6.368 ms +XXX[85] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 4882 ~57.437 ms, finishGL 33 / 4281 ~50.375 ms, waitGL 15 / 550 ~6.477 ms +XXX[86] TO 17 ms, lFrame0 1 ms, lFrameX 50 / 4932 ~57.351 ms, finishGL 38 / 4320 ~50.233 ms, waitGL 10 / 561 ~6.527 ms +XXX[87] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 4981 ~57.262 ms, finishGL 40 / 4360 ~50.122 ms, waitGL 7 / 569 ~6.542 ms +XXX[88] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 5031 ~57.177 ms, finishGL 41 / 4402 ~50.023 ms, waitGL 7 / 576 ~6.55 ms +XXX[89] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 5081 ~57.094 ms, finishGL 43 / 4445 ~49.945 ms, waitGL 5 / 582 ~6.539 ms +XXX[90] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 5131 ~57.013 ms, finishGL 42 / 4487 ~49.862 ms, waitGL 6 / 588 ~6.535 ms +XXX[91] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 5181 ~56.934 ms, finishGL 42 / 4530 ~49.786 ms, waitGL 5 / 593 ~6.526 ms +XXX[92] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 5230 ~56.857 ms, finishGL 43 / 4573 ~49.715 ms, waitGL 6 / 600 ~6.522 ms +XXX[93] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 5280 ~56.781 ms, finishGL 42 / 4616 ~49.641 ms, waitGL 6 / 606 ~6.522 ms +XXX[94] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 5330 ~56.708 ms, finishGL 43 / 4660 ~49.575 ms, waitGL 5 / 612 ~6.516 ms +XXX[95] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 5380 ~56.635 ms, finishGL 43 / 4703 ~49.508 ms, waitGL 5 / 617 ~6.505 ms +XXX[96] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 5430 ~56.563 ms, finishGL 43 / 4746 ~49.442 ms, waitGL 5 / 623 ~6.495 ms +XXX[97] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 5480 ~56.494 ms, finishGL 43 / 4790 ~49.383 ms, waitGL 5 / 628 ~6.481 ms +XXX[98] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 5529 ~56.426 ms, finishGL 44 / 4834 ~49.332 ms, waitGL 4 / 633 ~6.459 ms +XXX[99] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 5579 ~56.358 ms, finishGL 44 / 4879 ~49.288 ms, waitGL 4 / 637 ~6.438 ms +XXX[100] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 5629 ~56.293 ms, finishGL 45 / 4925 ~49.253 ms, waitGL 3 / 641 ~6.41 ms +XXX[101] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 5679 ~56.228 ms, finishGL 46 / 4971 ~49.225 ms, waitGL 2 / 643 ~6.369 ms +XXX[102] TO 17 ms, lFrame0 1 ms, lFrameX 50 / 5729 ~56.174 ms, finishGL 47 / 5019 ~49.211 ms, waitGL 1 / 645 ~6.324 ms +XXX[103] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 5812 ~56.428 ms, finishGL 64 / 5084 ~49.365 ms, waitGL 16 / 661 ~6.423 ms +XXX[104] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 5879 ~56.533 ms, finishGL 49 / 5134 ~49.369 ms, waitGL 17 / 678 ~6.526 ms +XXX[105] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 5945 ~56.628 ms, finishGL 51 / 5185 ~49.388 ms, waitGL 14 / 693 ~6.6 ms +XXX[106] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 6011 ~56.711 ms, finishGL 53 / 5239 ~49.428 ms, waitGL 11 / 704 ~6.645 ms +XXX[107] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 6078 ~56.805 ms, finishGL 57 / 5296 ~49.503 ms, waitGL 8 / 712 ~6.659 ms +XXX[108] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6145 ~56.898 ms, finishGL 60 / 5356 ~49.601 ms, waitGL 6 / 718 ~6.656 ms +XXX[109] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6211 ~56.983 ms, finishGL 61 / 5417 ~49.705 ms, waitGL 4 / 723 ~6.638 ms +XXX[110] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6277 ~57.069 ms, finishGL 61 / 5479 ~49.817 ms, waitGL 3 / 727 ~6.613 ms +XXX[111] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6344 ~57.153 ms, finishGL 61 / 5541 ~49.926 ms, waitGL 3 / 731 ~6.589 ms +XXX[112] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6410 ~57.237 ms, finishGL 61 / 5603 ~50.032 ms, waitGL 3 / 735 ~6.565 ms +XXX[113] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6477 ~57.319 ms, finishGL 61 / 5665 ~50.136 ms, waitGL 4 / 739 ~6.543 ms +XXX[114] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 6543 ~57.398 ms, finishGL 63 / 5728 ~50.251 ms, waitGL 2 / 742 ~6.51 ms +XXX[115] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 6610 ~57.483 ms, finishGL 64 / 5793 ~50.374 ms, waitGL 2 / 744 ~6.474 ms +XXX[116] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 6693 ~57.705 ms, finishGL 65 / 5858 ~50.503 ms, waitGL 17 / 762 ~6.569 ms +XXX[117] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 6776 ~57.922 ms, finishGL 65 / 5923 ~50.632 ms, waitGL 16 / 778 ~6.658 ms +XXX[118] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 6859 ~58.133 ms, finishGL 65 / 5989 ~50.755 ms, waitGL 17 / 796 ~6.747 ms +XXX[119] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 6943 ~58.345 ms, finishGL 65 / 6054 ~50.877 ms, waitGL 17 / 813 ~6.838 ms +XXX[120] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7026 ~58.552 ms, finishGL 66 / 6120 ~51.006 ms, waitGL 16 / 830 ~6.916 ms +XXX[121] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7109 ~58.754 ms, finishGL 66 / 6187 ~51.135 ms, waitGL 15 / 845 ~6.988 ms +XXX[122] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 7191 ~58.948 ms, finishGL 67 / 6254 ~51.267 ms, waitGL 14 / 860 ~7.051 ms +XXX[123] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7275 ~59.149 ms, finishGL 69 / 6324 ~51.416 ms, waitGL 13 / 873 ~7.103 ms +XXX[124] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 7357 ~59.338 ms, finishGL 71 / 6395 ~51.578 ms, waitGL 10 / 884 ~7.131 ms +XXX[125] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7441 ~59.532 ms, finishGL 72 / 6468 ~51.748 ms, waitGL 10 / 894 ~7.157 ms +XXX[126] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 7524 ~59.718 ms, finishGL 74 / 6542 ~51.925 ms, waitGL 8 / 902 ~7.164 ms +XXX[127] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 7607 ~59.901 ms, finishGL 76 / 6618 ~52.116 ms, waitGL 6 / 909 ~7.158 ms +XXX[128] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7690 ~60.084 ms, finishGL 74 / 6693 ~52.293 ms, waitGL 8 / 917 ~7.164 ms +XXX[129] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 7774 ~60.264 ms, finishGL 72 / 6765 ~52.449 ms, waitGL 10 / 927 ~7.189 ms +2013-06-17 02:52:55.855 java[62619:cc07] Persistent UI failed to open file file://localhost/Users/jogamp/Library/Saved%20Application%20State/com.apple.javajdk16.cmd.savedState/window_1.data: Operation not permitted (1) +XXX[130] TO 17 ms, lFrame0 0 ms, lFrameX 81 / 7855 ~60.427 ms, finishGL 68 / 6834 ~52.574 ms, waitGL 12 / 939 ~7.228 ms +XXX[131] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 7937 ~60.593 ms, finishGL 68 / 6903 ~52.696 ms, waitGL 12 / 952 ~7.267 ms +XXX[132] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 8020 ~60.763 ms, finishGL 67 / 6970 ~52.805 ms, waitGL 14 / 966 ~7.325 ms +XXX[133] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 8104 ~60.932 ms, finishGL 65 / 7035 ~52.899 ms, waitGL 16 / 983 ~7.396 ms +XXX[134] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8170 ~60.973 ms, finishGL 64 / 7100 ~52.987 ms, waitGL 1 / 984 ~7.348 ms +XXX[135] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 8254 ~61.144 ms, finishGL 81 / 7181 ~53.199 ms, waitGL 2 / 986 ~7.309 ms +XXX[136] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 8337 ~61.305 ms, finishGL 80 / 7262 ~53.397 ms, waitGL 2 / 989 ~7.274 ms +XXX[137] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8404 ~61.343 ms, finishGL 63 / 7325 ~53.474 ms, waitGL 1 / 990 ~7.232 ms +XXX[138] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 8487 ~61.501 ms, finishGL 79 / 7405 ~53.662 ms, waitGL 3 / 994 ~7.203 ms +XXX[139] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 8553 ~61.532 ms, finishGL 63 / 7469 ~53.737 ms, waitGL 1 / 995 ~7.16 ms +FrameCount: 240 - FrameRate: 13.0 +XXX[140] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8619 ~61.565 ms, finishGL 62 / 7532 ~53.8 ms, waitGL 2 / 997 ~7.127 ms +XXX[141] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 8702 ~61.722 ms, finishGL 79 / 7611 ~53.984 ms, waitGL 3 / 1001 ~7.1 ms +XXX[142] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 8769 ~61.753 ms, finishGL 63 / 7674 ~54.047 ms, waitGL 2 / 1003 ~7.066 ms +XXX[143] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 8835 ~61.786 ms, finishGL 62 / 7737 ~54.106 ms, waitGL 2 / 1006 ~7.036 ms +XXX[144] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 8902 ~61.819 ms, finishGL 62 / 7799 ~54.164 ms, waitGL 2 / 1009 ~7.008 ms +XXX[145] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 8968 ~61.851 ms, finishGL 61 / 7861 ~54.215 ms, waitGL 3 / 1012 ~6.986 ms +XXX[146] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9034 ~61.883 ms, finishGL 61 / 7922 ~54.264 ms, waitGL 4 / 1017 ~6.97 ms +XXX[147] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9101 ~61.914 ms, finishGL 61 / 7983 ~54.312 ms, waitGL 4 / 1022 ~6.952 ms +XXX[148] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 9168 ~61.946 ms, finishGL 61 / 8045 ~54.359 ms, waitGL 4 / 1026 ~6.933 ms +XXX[149] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9234 ~61.976 ms, finishGL 61 / 8106 ~54.406 ms, waitGL 4 / 1030 ~6.918 ms +XXX[150] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9301 ~62.007 ms, finishGL 61 / 8167 ~54.451 ms, waitGL 5 / 1035 ~6.905 ms +XXX[151] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9367 ~62.036 ms, finishGL 60 / 8228 ~54.492 ms, waitGL 5 / 1040 ~6.893 ms +XXX[152] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 9433 ~62.065 ms, finishGL 61 / 8289 ~54.535 ms, waitGL 4 / 1045 ~6.876 ms +XXX[153] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 9500 ~62.093 ms, finishGL 61 / 8350 ~54.579 ms, waitGL 4 / 1049 ~6.857 ms +XXX[154] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 9566 ~62.122 ms, finishGL 60 / 8411 ~54.618 ms, waitGL 4 / 1054 ~6.844 ms +XXX[155] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9633 ~62.15 ms, finishGL 61 / 8472 ~54.66 ms, waitGL 4 / 1058 ~6.829 ms +XXX[156] TO 17 ms, lFrame0 1 ms, lFrameX 67 / 9700 ~62.184 ms, finishGL 61 / 8533 ~54.702 ms, waitGL 5 / 1063 ~6.818 ms +XXX[157] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 9766 ~62.208 ms, finishGL 60 / 8594 ~54.741 ms, waitGL 4 / 1068 ~6.805 ms +XXX[158] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9833 ~62.235 ms, finishGL 60 / 8654 ~54.777 ms, waitGL 5 / 1073 ~6.797 ms +XXX[159] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9899 ~62.259 ms, finishGL 60 / 8715 ~54.814 ms, waitGL 4 / 1078 ~6.783 ms +XXX[160] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 9965 ~62.286 ms, finishGL 60 / 8775 ~54.848 ms, waitGL 5 / 1084 ~6.777 ms +XXX[161] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10032 ~62.316 ms, finishGL 59 / 8835 ~54.88 ms, waitGL 6 / 1091 ~6.777 ms +XXX[162] TO 17 ms, lFrame0 1 ms, lFrameX 65 / 10098 ~62.338 ms, finishGL 58 / 8894 ~54.904 ms, waitGL 6 / 1097 ~6.772 ms +XXX[163] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 10165 ~62.367 ms, finishGL 58 / 8952 ~54.926 ms, waitGL 8 / 1105 ~6.78 ms +XXX[164] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10232 ~62.392 ms, finishGL 58 / 9011 ~54.946 ms, waitGL 7 / 1112 ~6.785 ms +XXX[165] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10298 ~62.416 ms, finishGL 58 / 9069 ~54.966 ms, waitGL 7 / 1120 ~6.791 ms +XXX[166] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10365 ~62.441 ms, finishGL 58 / 9127 ~54.985 ms, waitGL 7 / 1128 ~6.797 ms +XXX[167] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10431 ~62.465 ms, finishGL 57 / 9185 ~55.003 ms, waitGL 8 / 1136 ~6.805 ms +XXX[168] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10498 ~62.488 ms, finishGL 57 / 9243 ~55.02 ms, waitGL 7 / 1144 ~6.811 ms +XXX[169] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10564 ~62.511 ms, finishGL 58 / 9301 ~55.039 ms, waitGL 7 / 1151 ~6.815 ms +XXX[170] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10630 ~62.534 ms, finishGL 58 / 9360 ~55.059 ms, waitGL 7 / 1159 ~6.819 ms +XXX[171] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10697 ~62.557 ms, finishGL 58 / 9418 ~55.079 ms, waitGL 7 / 1166 ~6.822 ms +XXX[172] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10763 ~62.579 ms, finishGL 58 / 9477 ~55.1 ms, waitGL 7 / 1173 ~6.824 ms +XXX[173] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10829 ~62.6 ms, finishGL 59 / 9536 ~55.125 ms, waitGL 6 / 1180 ~6.82 ms +XXX[174] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10896 ~62.622 ms, finishGL 59 / 9596 ~55.151 ms, waitGL 6 / 1186 ~6.818 ms +XXX[175] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 10963 ~62.646 ms, finishGL 59 / 9655 ~55.174 ms, waitGL 6 / 1193 ~6.817 ms +XXX[176] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 11028 ~62.664 ms, finishGL 59 / 9715 ~55.199 ms, waitGL 5 / 1198 ~6.811 ms +XXX[177] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 11095 ~62.689 ms, finishGL 59 / 9774 ~55.222 ms, waitGL 7 / 1206 ~6.813 ms +XXX[178] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11162 ~62.708 ms, finishGL 60 / 9834 ~55.252 ms, waitGL 4 / 1211 ~6.803 ms +XXX[179] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11228 ~62.73 ms, finishGL 61 / 9896 ~55.287 ms, waitGL 4 / 1215 ~6.791 ms +XXX[180] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11294 ~62.749 ms, finishGL 62 / 9958 ~55.327 ms, waitGL 3 / 1218 ~6.77 ms +XXX[181] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11361 ~62.77 ms, finishGL 63 / 10022 ~55.37 ms, waitGL 3 / 1221 ~6.75 ms +XXX[182] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 11428 ~62.793 ms, finishGL 64 / 10086 ~55.418 ms, waitGL 2 / 1224 ~6.725 ms +XXX[183] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 11510 ~62.899 ms, finishGL 64 / 10150 ~55.469 ms, waitGL 16 / 1240 ~6.779 ms +XXX[184] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 11593 ~63.01 ms, finishGL 82 / 10233 ~55.615 ms, waitGL 0 / 1240 ~6.744 ms +XXX[185] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 11677 ~63.119 ms, finishGL 68 / 10301 ~55.685 ms, waitGL 14 / 1255 ~6.784 ms +XXX[186] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 11777 ~63.322 ms, finishGL 86 / 10388 ~55.85 ms, waitGL 13 / 1268 ~6.821 ms +XXX[187] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 11860 ~63.427 ms, finishGL 74 / 10462 ~55.951 ms, waitGL 7 / 1276 ~6.827 ms +XXX[188] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 11943 ~63.527 ms, finishGL 77 / 10540 ~56.066 ms, waitGL 3 / 1280 ~6.811 ms +XXX[189] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 12043 ~63.72 ms, finishGL 94 / 10635 ~56.269 ms, waitGL 4 / 1285 ~6.799 ms +XXX[190] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 12126 ~63.823 ms, finishGL 79 / 10714 ~56.39 ms, waitGL 2 / 1287 ~6.778 ms +XXX[191] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12209 ~63.924 ms, finishGL 80 / 10794 ~56.515 ms, waitGL 2 / 1290 ~6.756 ms +XXX[192] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12293 ~64.027 ms, finishGL 79 / 10873 ~56.633 ms, waitGL 3 / 1293 ~6.739 ms +XXX[193] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 12376 ~64.128 ms, finishGL 80 / 10954 ~56.759 ms, waitGL 2 / 1295 ~6.714 ms +XXX[194] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 12475 ~64.308 ms, finishGL 97 / 11051 ~56.968 ms, waitGL 1 / 1296 ~6.685 ms +XXX[195] TO 17 ms, lFrame0 0 ms, lFrameX 100 / 12576 ~64.495 ms, finishGL 97 / 11149 ~57.177 ms, waitGL 2 / 1299 ~6.664 ms +XXX[196] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 12675 ~64.67 ms, finishGL 95 / 11244 ~57.372 ms, waitGL 3 / 1302 ~6.645 ms +XXX[197] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 12758 ~64.764 ms, finishGL 77 / 11322 ~57.474 ms, waitGL 4 / 1307 ~6.635 ms +XXX[198] TO 17 ms, lFrame0 1 ms, lFrameX 84 / 12842 ~64.862 ms, finishGL 77 / 11399 ~57.573 ms, waitGL 5 / 1313 ~6.632 ms +XXX[199] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 12925 ~64.952 ms, finishGL 76 / 11475 ~57.667 ms, waitGL 5 / 1319 ~6.628 ms +XXX[200] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 13008 ~65.04 ms, finishGL 76 / 11552 ~57.762 ms, waitGL 4 / 1324 ~6.62 ms +XXX[201] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13091 ~65.131 ms, finishGL 77 / 11629 ~57.859 ms, waitGL 5 / 1329 ~6.613 ms +XXX[202] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13174 ~65.22 ms, finishGL 77 / 11706 ~57.954 ms, waitGL 5 / 1334 ~6.608 ms +XXX[203] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 13257 ~65.309 ms, finishGL 76 / 11783 ~58.046 ms, waitGL 5 / 1340 ~6.602 ms +XXX[204] TO 17 ms, lFrame0 2 ms, lFrameX 83 / 13341 ~65.397 ms, finishGL 76 / 11859 ~58.135 ms, waitGL 4 / 1345 ~6.593 ms +XXX[205] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 13424 ~65.483 ms, finishGL 75 / 11934 ~58.219 ms, waitGL 6 / 1351 ~6.594 ms +XXX[206] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13507 ~65.569 ms, finishGL 74 / 12009 ~58.299 ms, waitGL 8 / 1359 ~6.601 ms +XXX[207] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13590 ~65.654 ms, finishGL 73 / 12083 ~58.373 ms, waitGL 9 / 1368 ~6.613 ms +XXX[208] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13673 ~65.738 ms, finishGL 71 / 12155 ~58.439 ms, waitGL 10 / 1379 ~6.632 ms +XXX[209] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 13756 ~65.822 ms, finishGL 70 / 12225 ~58.497 ms, waitGL 11 / 1391 ~6.655 ms +XXX[210] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 13839 ~65.904 ms, finishGL 68 / 12294 ~58.546 ms, waitGL 13 / 1404 ~6.688 ms +XXX[211] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 13923 ~65.986 ms, finishGL 67 / 12362 ~58.588 ms, waitGL 14 / 1419 ~6.726 ms +XXX[212] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 14006 ~66.067 ms, finishGL 65 / 12428 ~58.623 ms, waitGL 16 / 1435 ~6.772 ms +XXX[213] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 14073 ~66.073 ms, finishGL 64 / 12492 ~58.65 ms, waitGL 2 / 1437 ~6.75 ms +XXX[214] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 14155 ~66.148 ms, finishGL 80 / 12572 ~58.75 ms, waitGL 1 / 1439 ~6.726 ms +XXX[215] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 14222 ~66.15 ms, finishGL 63 / 12636 ~58.772 ms, waitGL 2 / 1441 ~6.705 ms +XXX[216] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 14289 ~66.152 ms, finishGL 63 / 12699 ~58.795 ms, waitGL 2 / 1443 ~6.684 ms +XXX[217] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 14356 ~66.158 ms, finishGL 63 / 12763 ~58.819 ms, waitGL 2 / 1446 ~6.667 ms +XXX[218] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 14439 ~66.236 ms, finishGL 65 / 12829 ~58.85 ms, waitGL 16 / 1463 ~6.715 ms +XXX[219] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 14521 ~66.308 ms, finishGL 68 / 12898 ~58.896 ms, waitGL 12 / 1475 ~6.739 ms +XXX[220] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 14604 ~66.384 ms, finishGL 71 / 12969 ~58.951 ms, waitGL 11 / 1486 ~6.758 ms +XXX[221] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 14687 ~66.46 ms, finishGL 73 / 13042 ~59.017 ms, waitGL 8 / 1495 ~6.766 ms +XXX[222] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 14770 ~66.535 ms, finishGL 76 / 13118 ~59.094 ms, waitGL 5 / 1501 ~6.763 ms +XXX[223] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 14854 ~66.61 ms, finishGL 76 / 13195 ~59.173 ms, waitGL 5 / 1506 ~6.755 ms +XXX[224] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 14937 ~66.683 ms, finishGL 76 / 13272 ~59.252 ms, waitGL 5 / 1512 ~6.751 ms +XXX[225] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 15021 ~66.761 ms, finishGL 76 / 13349 ~59.33 ms, waitGL 6 / 1518 ~6.75 ms +XXX[226] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 15104 ~66.834 ms, finishGL 75 / 13424 ~59.401 ms, waitGL 7 / 1526 ~6.753 ms +XXX[227] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 15186 ~66.902 ms, finishGL 75 / 13499 ~59.47 ms, waitGL 6 / 1532 ~6.751 ms +XXX[228] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 15270 ~66.973 ms, finishGL 74 / 13574 ~59.537 ms, waitGL 7 / 1539 ~6.753 ms +XXX[229] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 15353 ~67.044 ms, finishGL 73 / 13648 ~59.6 ms, waitGL 8 / 1547 ~6.759 ms +XXX[230] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 15436 ~67.114 ms, finishGL 73 / 13721 ~59.658 ms, waitGL 9 / 1556 ~6.769 ms +XXX[231] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 15519 ~67.183 ms, finishGL 72 / 13793 ~59.714 ms, waitGL 9 / 1566 ~6.781 ms +XXX[232] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 15602 ~67.253 ms, finishGL 70 / 13864 ~59.761 ms, waitGL 11 / 1578 ~6.802 ms +XXX[233] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 15685 ~67.32 ms, finishGL 69 / 13933 ~59.801 ms, waitGL 12 / 1590 ~6.827 ms +XXX[234] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 15768 ~67.388 ms, finishGL 67 / 14001 ~59.836 ms, waitGL 14 / 1605 ~6.86 ms +XXX[235] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 15852 ~67.456 ms, finishGL 66 / 14067 ~59.863 ms, waitGL 15 / 1621 ~6.899 ms +XXX[236] TO 17 ms, lFrame0 1 ms, lFrameX 67 / 15919 ~67.455 ms, finishGL 65 / 14133 ~59.885 ms, waitGL 1 / 1622 ~6.874 ms +XXX[237] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 16001 ~67.518 ms, finishGL 79 / 14212 ~59.967 ms, waitGL 2 / 1624 ~6.854 ms +XXX[238] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16068 ~67.513 ms, finishGL 63 / 14275 ~59.98 ms, waitGL 2 / 1627 ~6.836 ms +XXX[239] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16134 ~67.509 ms, finishGL 63 / 14338 ~59.994 ms, waitGL 2 / 1629 ~6.817 ms +XXX[240] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16201 ~67.505 ms, finishGL 62 / 14401 ~60.006 ms, waitGL 2 / 1631 ~6.799 ms +XXX[241] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16267 ~67.5 ms, finishGL 63 / 14464 ~60.019 ms, waitGL 2 / 1633 ~6.779 ms +XXX[242] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16334 ~67.497 ms, finishGL 62 / 14527 ~60.03 ms, waitGL 2 / 1636 ~6.762 ms +XXX[243] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16400 ~67.492 ms, finishGL 62 / 14590 ~60.042 ms, waitGL 2 / 1639 ~6.745 ms +XXX[244] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16467 ~67.488 ms, finishGL 62 / 14652 ~60.05 ms, waitGL 3 / 1642 ~6.73 ms +XXX[245] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16533 ~67.484 ms, finishGL 61 / 14713 ~60.056 ms, waitGL 4 / 1646 ~6.721 ms +XXX[246] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16600 ~67.48 ms, finishGL 61 / 14775 ~60.063 ms, waitGL 3 / 1650 ~6.708 ms +XXX[247] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16666 ~67.476 ms, finishGL 61 / 14837 ~60.07 ms, waitGL 3 / 1653 ~6.695 ms +XXX[248] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16733 ~67.472 ms, finishGL 62 / 14899 ~60.08 ms, waitGL 2 / 1656 ~6.68 ms +XXX[249] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 16799 ~67.468 ms, finishGL 63 / 14963 ~60.093 ms, waitGL 1 / 1658 ~6.661 ms +XXX[250] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 16866 ~67.464 ms, finishGL 64 / 15027 ~60.11 ms, waitGL 1 / 1660 ~6.64 ms +XXX[251] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 16966 ~67.593 ms, finishGL 82 / 15110 ~60.201 ms, waitGL 16 / 1676 ~6.679 ms +XXX[252] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17049 ~67.655 ms, finishGL 68 / 15178 ~60.233 ms, waitGL 14 / 1690 ~6.709 ms +XXX[253] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 17132 ~67.717 ms, finishGL 69 / 15248 ~60.271 ms, waitGL 12 / 1703 ~6.731 ms +XXX[254] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 17215 ~67.779 ms, finishGL 72 / 15320 ~60.317 ms, waitGL 10 / 1713 ~6.746 ms +XXX[255] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 17298 ~67.838 ms, finishGL 73 / 15393 ~60.367 ms, waitGL 8 / 1722 ~6.753 ms +XXX[256] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17381 ~67.898 ms, finishGL 75 / 15468 ~60.425 ms, waitGL 7 / 1729 ~6.756 ms +XXX[257] TO 17 ms, lFrame0 1 ms, lFrameX 84 / 17466 ~67.961 ms, finishGL 76 / 15545 ~60.487 ms, waitGL 6 / 1736 ~6.755 ms +XXX[258] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 17548 ~68.018 ms, finishGL 76 / 15622 ~60.55 ms, waitGL 5 / 1741 ~6.75 ms +XXX[259] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 17632 ~68.078 ms, finishGL 78 / 15700 ~60.619 ms, waitGL 4 / 1745 ~6.74 ms +FrameCount: 360 - FrameRate: 13.0 +XXX[260] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 17714 ~68.134 ms, finishGL 78 / 15778 ~60.687 ms, waitGL 3 / 1749 ~6.729 ms +XXX[261] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 17797 ~68.19 ms, finishGL 78 / 15857 ~60.756 ms, waitGL 3 / 1752 ~6.715 ms +XXX[262] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17881 ~68.248 ms, finishGL 78 / 15936 ~60.825 ms, waitGL 3 / 1756 ~6.704 ms +XXX[263] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 17964 ~68.304 ms, finishGL 78 / 16015 ~60.894 ms, waitGL 3 / 1760 ~6.693 ms +XXX[264] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 18047 ~68.36 ms, finishGL 77 / 16093 ~60.958 ms, waitGL 4 / 1764 ~6.685 ms +XXX[265] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 18130 ~68.417 ms, finishGL 77 / 16170 ~61.02 ms, waitGL 5 / 1770 ~6.679 ms +XXX[266] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 18214 ~68.475 ms, finishGL 76 / 16247 ~61.08 ms, waitGL 6 / 1776 ~6.679 ms +XXX[267] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 18296 ~68.527 ms, finishGL 75 / 16323 ~61.136 ms, waitGL 5 / 1782 ~6.675 ms +XXX[268] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 18380 ~68.582 ms, finishGL 75 / 16399 ~61.19 ms, waitGL 6 / 1788 ~6.674 ms +XXX[269] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 18463 ~68.636 ms, finishGL 74 / 16473 ~61.241 ms, waitGL 7 / 1796 ~6.678 ms +XXX[270] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 18546 ~68.692 ms, finishGL 74 / 16548 ~61.289 ms, waitGL 8 / 1805 ~6.685 ms +XXX[271] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 18629 ~68.744 ms, finishGL 71 / 16619 ~61.327 ms, waitGL 10 / 1815 ~6.697 ms +XXX[272] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 18712 ~68.797 ms, finishGL 70 / 16690 ~61.362 ms, waitGL 11 / 1826 ~6.715 ms +XXX[273] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 18796 ~68.849 ms, finishGL 70 / 16760 ~61.394 ms, waitGL 12 / 1838 ~6.735 ms +XXX[274] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 18879 ~68.902 ms, finishGL 68 / 16829 ~61.42 ms, waitGL 13 / 1852 ~6.76 ms +XXX[275] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 18962 ~68.954 ms, finishGL 68 / 16897 ~61.444 ms, waitGL 14 / 1866 ~6.787 ms +XXX[276] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 19045 ~69.006 ms, finishGL 67 / 16964 ~61.465 ms, waitGL 14 / 1881 ~6.816 ms +XXX[277] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 19128 ~69.056 ms, finishGL 66 / 17030 ~61.483 ms, waitGL 15 / 1897 ~6.849 ms +XXX[278] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 19211 ~69.107 ms, finishGL 66 / 17096 ~61.499 ms, waitGL 16 / 1913 ~6.884 ms +XXX[279] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 19278 ~69.098 ms, finishGL 64 / 17161 ~61.512 ms, waitGL 0 / 1914 ~6.86 ms +XXX[280] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 19361 ~69.148 ms, finishGL 81 / 17243 ~61.584 ms, waitGL 1 / 1915 ~6.839 ms +XXX[281] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 19444 ~69.197 ms, finishGL 80 / 17324 ~61.652 ms, waitGL 1 / 1916 ~6.821 ms +XXX[282] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 19511 ~69.188 ms, finishGL 63 / 17387 ~61.659 ms, waitGL 2 / 1919 ~6.805 ms +XXX[283] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 19577 ~69.178 ms, finishGL 62 / 17450 ~61.662 ms, waitGL 3 / 1922 ~6.792 ms +XXX[284] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 19644 ~69.169 ms, finishGL 61 / 17512 ~61.662 ms, waitGL 4 / 1926 ~6.784 ms +XXX[285] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 19710 ~69.16 ms, finishGL 60 / 17573 ~61.659 ms, waitGL 5 / 1932 ~6.779 ms +XXX[286] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 19777 ~69.15 ms, finishGL 59 / 17632 ~61.651 ms, waitGL 5 / 1938 ~6.776 ms +XXX[287] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 19843 ~69.142 ms, finishGL 58 / 17690 ~61.639 ms, waitGL 7 / 1945 ~6.777 ms +XXX[288] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 19910 ~69.132 ms, finishGL 57 / 17748 ~61.625 ms, waitGL 7 / 1952 ~6.78 ms +XXX[289] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 19976 ~69.122 ms, finishGL 56 / 17804 ~61.607 ms, waitGL 8 / 1961 ~6.787 ms +XXX[290] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20043 ~69.115 ms, finishGL 54 / 17859 ~61.583 ms, waitGL 11 / 1973 ~6.804 ms +XXX[291] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20109 ~69.105 ms, finishGL 53 / 17912 ~61.555 ms, waitGL 11 / 1984 ~6.821 ms +XXX[292] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20176 ~69.096 ms, finishGL 52 / 17965 ~61.525 ms, waitGL 13 / 1997 ~6.842 ms +XXX[293] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20242 ~69.087 ms, finishGL 51 / 18017 ~61.492 ms, waitGL 13 / 2011 ~6.864 ms +XXX[294] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20308 ~69.078 ms, finishGL 51 / 18068 ~61.457 ms, waitGL 13 / 2025 ~6.888 ms +XXX[295] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20375 ~69.069 ms, finishGL 50 / 18119 ~61.42 ms, waitGL 14 / 2040 ~6.915 ms +XXX[296] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20442 ~69.061 ms, finishGL 49 / 18169 ~61.381 ms, waitGL 15 / 2055 ~6.945 ms +XXX[297] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20508 ~69.052 ms, finishGL 49 / 18218 ~61.341 ms, waitGL 15 / 2071 ~6.975 ms +XXX[298] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20575 ~69.043 ms, finishGL 49 / 18267 ~61.3 ms, waitGL 16 / 2087 ~7.006 ms +XXX[299] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20641 ~69.035 ms, finishGL 49 / 18316 ~61.26 ms, waitGL 15 / 2103 ~7.036 ms +XXX[300] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20707 ~69.026 ms, finishGL 49 / 18366 ~61.222 ms, waitGL 15 / 2119 ~7.064 ms +XXX[301] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20774 ~69.018 ms, finishGL 51 / 18417 ~61.188 ms, waitGL 14 / 2133 ~7.088 ms +XXX[302] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20840 ~69.009 ms, finishGL 51 / 18469 ~61.156 ms, waitGL 13 / 2147 ~7.111 ms +XXX[303] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 20907 ~69.001 ms, finishGL 52 / 18522 ~61.129 ms, waitGL 12 / 2160 ~7.128 ms +XXX[304] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 20973 ~68.993 ms, finishGL 55 / 18577 ~61.109 ms, waitGL 10 / 2170 ~7.139 ms +XXX[305] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 21040 ~68.985 ms, finishGL 57 / 18634 ~61.097 ms, waitGL 8 / 2178 ~7.143 ms +XXX[306] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 21106 ~68.977 ms, finishGL 60 / 18694 ~61.094 ms, waitGL 5 / 2183 ~7.136 ms +XXX[307] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 21173 ~68.968 ms, finishGL 65 / 18760 ~61.107 ms, waitGL 0 / 2184 ~7.114 ms +XXX[308] TO 17 ms, lFrame0 0 ms, lFrameX 99 / 21273 ~69.069 ms, finishGL 87 / 18847 ~61.192 ms, waitGL 12 / 2196 ~7.13 ms +XXX[309] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 21356 ~69.114 ms, finishGL 74 / 18922 ~61.236 ms, waitGL 7 / 2203 ~7.131 ms +XXX[310] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 21439 ~69.16 ms, finishGL 76 / 18998 ~61.286 ms, waitGL 5 / 2208 ~7.125 ms +XXX[311] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 21522 ~69.205 ms, finishGL 78 / 19077 ~61.341 ms, waitGL 3 / 2212 ~7.113 ms +XXX[312] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 21606 ~69.25 ms, finishGL 79 / 19156 ~61.398 ms, waitGL 3 / 2215 ~7.101 ms +XXX[313] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 21689 ~69.294 ms, finishGL 78 / 19235 ~61.454 ms, waitGL 3 / 2218 ~7.088 ms +XXX[314] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 21772 ~69.338 ms, finishGL 78 / 19313 ~61.509 ms, waitGL 3 / 2222 ~7.076 ms +XXX[315] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 21855 ~69.382 ms, finishGL 79 / 19393 ~61.565 ms, waitGL 3 / 2225 ~7.064 ms +XXX[316] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 21938 ~69.426 ms, finishGL 80 / 19473 ~61.624 ms, waitGL 1 / 2226 ~7.046 ms +XXX[317] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 22022 ~69.471 ms, finishGL 81 / 19554 ~61.687 ms, waitGL 1 / 2228 ~7.029 ms +XXX[318] TO 17 ms, lFrame0 0 ms, lFrameX 115 / 22138 ~69.617 ms, finishGL 98 / 19653 ~61.802 ms, waitGL 16 / 2245 ~7.059 ms +XXX[319] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22221 ~69.659 ms, finishGL 80 / 19734 ~61.862 ms, waitGL 1 / 2246 ~7.042 ms +XXX[320] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 22304 ~69.702 ms, finishGL 79 / 19814 ~61.919 ms, waitGL 2 / 2248 ~7.027 ms +XXX[321] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22387 ~69.744 ms, finishGL 79 / 19893 ~61.973 ms, waitGL 3 / 2251 ~7.015 ms +XXX[322] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22471 ~69.786 ms, finishGL 79 / 19972 ~62.026 ms, waitGL 3 / 2255 ~7.005 ms +XXX[323] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 22554 ~69.827 ms, finishGL 78 / 20050 ~62.077 ms, waitGL 3 / 2259 ~6.994 ms +XXX[324] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 22637 ~69.868 ms, finishGL 78 / 20129 ~62.128 ms, waitGL 3 / 2262 ~6.982 ms +XXX[325] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 22720 ~69.909 ms, finishGL 78 / 20207 ~62.178 ms, waitGL 3 / 2266 ~6.972 ms +XXX[326] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 22803 ~69.95 ms, finishGL 78 / 20286 ~62.227 ms, waitGL 3 / 2269 ~6.962 ms +XXX[327] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 22887 ~69.991 ms, finishGL 78 / 20365 ~62.278 ms, waitGL 4 / 2274 ~6.954 ms +XXX[328] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 22970 ~70.031 ms, finishGL 79 / 20444 ~62.33 ms, waitGL 3 / 2277 ~6.942 ms +XXX[329] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 23053 ~70.07 ms, finishGL 78 / 20522 ~62.379 ms, waitGL 3 / 2280 ~6.931 ms +XXX[330] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 23136 ~70.11 ms, finishGL 79 / 20602 ~62.432 ms, waitGL 2 / 2282 ~6.917 ms +XXX[331] TO 17 ms, lFrame0 1 ms, lFrameX 84 / 23220 ~70.152 ms, finishGL 79 / 20681 ~62.483 ms, waitGL 3 / 2286 ~6.907 ms +XXX[332] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23302 ~70.189 ms, finishGL 79 / 20761 ~62.535 ms, waitGL 2 / 2288 ~6.893 ms +XXX[333] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23386 ~70.229 ms, finishGL 80 / 20842 ~62.589 ms, waitGL 2 / 2290 ~6.879 ms +XXX[334] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 23469 ~70.267 ms, finishGL 80 / 20922 ~62.641 ms, waitGL 2 / 2293 ~6.866 ms +XXX[335] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 23552 ~70.305 ms, finishGL 79 / 21002 ~62.693 ms, waitGL 2 / 2295 ~6.852 ms +XXX[336] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 23635 ~70.344 ms, finishGL 79 / 21081 ~62.742 ms, waitGL 2 / 2298 ~6.841 ms +XXX[337] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 23718 ~70.382 ms, finishGL 78 / 21160 ~62.79 ms, waitGL 3 / 2301 ~6.83 ms +XXX[338] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23802 ~70.421 ms, finishGL 77 / 21238 ~62.834 ms, waitGL 5 / 2307 ~6.826 ms +XXX[339] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23885 ~70.459 ms, finishGL 76 / 21314 ~62.875 ms, waitGL 5 / 2313 ~6.823 ms +XXX[340] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 23969 ~70.497 ms, finishGL 77 / 21391 ~62.917 ms, waitGL 5 / 2319 ~6.82 ms +XXX[341] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24052 ~70.533 ms, finishGL 77 / 21468 ~62.958 ms, waitGL 5 / 2324 ~6.816 ms +XXX[342] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24135 ~70.57 ms, finishGL 76 / 21545 ~62.998 ms, waitGL 6 / 2330 ~6.814 ms +XXX[343] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24218 ~70.607 ms, finishGL 76 / 21621 ~63.037 ms, waitGL 6 / 2336 ~6.813 ms +XXX[344] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24301 ~70.644 ms, finishGL 76 / 21697 ~63.075 ms, waitGL 6 / 2343 ~6.812 ms +XXX[345] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24384 ~70.68 ms, finishGL 75 / 21773 ~63.112 ms, waitGL 6 / 2350 ~6.812 ms +XXX[346] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24467 ~70.715 ms, finishGL 76 / 21849 ~63.15 ms, waitGL 6 / 2356 ~6.811 ms +XXX[347] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24551 ~70.752 ms, finishGL 75 / 21925 ~63.186 ms, waitGL 7 / 2363 ~6.812 ms +XXX[348] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 24633 ~70.787 ms, finishGL 75 / 22001 ~63.222 ms, waitGL 6 / 2370 ~6.811 ms +XXX[349] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24717 ~70.822 ms, finishGL 75 / 22077 ~63.258 ms, waitGL 6 / 2377 ~6.811 ms +XXX[350] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24800 ~70.857 ms, finishGL 75 / 22153 ~63.295 ms, waitGL 6 / 2383 ~6.811 ms +XXX[351] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24883 ~70.892 ms, finishGL 75 / 22228 ~63.329 ms, waitGL 7 / 2391 ~6.812 ms +XXX[352] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 24966 ~70.927 ms, finishGL 75 / 22304 ~63.365 ms, waitGL 6 / 2397 ~6.812 ms +XXX[353] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25049 ~70.961 ms, finishGL 75 / 22380 ~63.399 ms, waitGL 6 / 2404 ~6.812 ms +XXX[354] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25131 ~70.993 ms, finishGL 75 / 22456 ~63.435 ms, waitGL 5 / 2410 ~6.809 ms +XXX[355] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25215 ~71.03 ms, finishGL 76 / 22532 ~63.471 ms, waitGL 7 / 2417 ~6.81 ms +XXX[356] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25298 ~71.062 ms, finishGL 76 / 22608 ~63.507 ms, waitGL 5 / 2423 ~6.807 ms +XXX[357] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25382 ~71.098 ms, finishGL 75 / 22684 ~63.541 ms, waitGL 7 / 2430 ~6.808 ms +XXX[358] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25465 ~71.131 ms, finishGL 76 / 22760 ~63.576 ms, waitGL 6 / 2437 ~6.807 ms +XXX[359] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25548 ~71.164 ms, finishGL 75 / 22836 ~63.61 ms, waitGL 6 / 2443 ~6.807 ms +XXX[360] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25631 ~71.198 ms, finishGL 76 / 22912 ~63.645 ms, waitGL 6 / 2450 ~6.806 ms +XXX[361] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25714 ~71.23 ms, finishGL 76 / 22988 ~63.681 ms, waitGL 5 / 2456 ~6.803 ms +XXX[362] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25797 ~71.263 ms, finishGL 76 / 23065 ~63.715 ms, waitGL 6 / 2462 ~6.803 ms +XXX[363] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 25880 ~71.297 ms, finishGL 76 / 23141 ~63.751 ms, waitGL 6 / 2468 ~6.801 ms +XXX[364] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 25963 ~71.327 ms, finishGL 77 / 23219 ~63.788 ms, waitGL 4 / 2473 ~6.794 ms +XXX[365] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26046 ~71.361 ms, finishGL 78 / 23297 ~63.827 ms, waitGL 5 / 2478 ~6.789 ms +XXX[366] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26129 ~71.393 ms, finishGL 77 / 23374 ~63.865 ms, waitGL 4 / 2483 ~6.784 ms +XXX[367] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26213 ~71.425 ms, finishGL 77 / 23451 ~63.901 ms, waitGL 5 / 2488 ~6.781 ms +XXX[368] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26296 ~71.457 ms, finishGL 77 / 23529 ~63.939 ms, waitGL 4 / 2493 ~6.775 ms +XXX[369] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26379 ~71.489 ms, finishGL 77 / 23607 ~63.977 ms, waitGL 4 / 2498 ~6.77 ms +XXX[370] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26462 ~71.52 ms, finishGL 78 / 23685 ~64.015 ms, waitGL 4 / 2502 ~6.763 ms +XXX[371] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26545 ~71.551 ms, finishGL 77 / 23763 ~64.052 ms, waitGL 4 / 2507 ~6.757 ms +XXX[372] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26628 ~71.583 ms, finishGL 77 / 23841 ~64.089 ms, waitGL 4 / 2512 ~6.753 ms +XXX[373] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26711 ~71.613 ms, finishGL 76 / 23918 ~64.123 ms, waitGL 5 / 2517 ~6.75 ms +XXX[374] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26795 ~71.645 ms, finishGL 76 / 23994 ~64.156 ms, waitGL 6 / 2524 ~6.75 ms +XXX[375] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 26878 ~71.675 ms, finishGL 75 / 24070 ~64.187 ms, waitGL 6 / 2531 ~6.75 ms +XXX[376] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 26961 ~71.706 ms, finishGL 75 / 24145 ~64.217 ms, waitGL 6 / 2538 ~6.75 ms +XXX[377] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27044 ~71.737 ms, finishGL 75 / 24220 ~64.246 ms, waitGL 7 / 2545 ~6.753 ms +XXX[378] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27128 ~71.767 ms, finishGL 75 / 24296 ~64.275 ms, waitGL 7 / 2553 ~6.754 ms +XXX[379] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27211 ~71.797 ms, finishGL 75 / 24371 ~64.303 ms, waitGL 7 / 2560 ~6.757 ms +FrameCount: 480 - FrameRate: 12.0 +XXX[380] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27294 ~71.827 ms, finishGL 74 / 24445 ~64.329 ms, waitGL 8 / 2569 ~6.761 ms +XXX[381] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27377 ~71.856 ms, finishGL 73 / 24518 ~64.353 ms, waitGL 9 / 2578 ~6.767 ms +XXX[382] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27460 ~71.885 ms, finishGL 73 / 24591 ~64.376 ms, waitGL 8 / 2587 ~6.773 ms +XXX[383] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27543 ~71.916 ms, finishGL 73 / 24664 ~64.399 ms, waitGL 9 / 2597 ~6.781 ms +XXX[384] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27626 ~71.945 ms, finishGL 72 / 24737 ~64.419 ms, waitGL 10 / 2607 ~6.79 ms +XXX[385] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27710 ~71.974 ms, finishGL 72 / 24809 ~64.441 ms, waitGL 9 / 2617 ~6.798 ms +XXX[386] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27793 ~72.002 ms, finishGL 73 / 24882 ~64.463 ms, waitGL 9 / 2626 ~6.805 ms +XXX[387] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 27876 ~72.031 ms, finishGL 73 / 24956 ~64.486 ms, waitGL 9 / 2636 ~6.812 ms +XXX[388] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 27959 ~72.059 ms, finishGL 73 / 25029 ~64.51 ms, waitGL 8 / 2644 ~6.816 ms +XXX[389] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28042 ~72.088 ms, finishGL 74 / 25104 ~64.535 ms, waitGL 8 / 2653 ~6.82 ms +XXX[390] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28125 ~72.115 ms, finishGL 75 / 25179 ~64.563 ms, waitGL 6 / 2660 ~6.82 ms +XXX[391] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28208 ~72.143 ms, finishGL 76 / 25256 ~64.594 ms, waitGL 5 / 2665 ~6.817 ms +XXX[392] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 28291 ~72.171 ms, finishGL 77 / 25334 ~64.628 ms, waitGL 4 / 2670 ~6.811 ms +XXX[393] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28374 ~72.199 ms, finishGL 78 / 25412 ~64.662 ms, waitGL 4 / 2674 ~6.805 ms +XXX[394] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 28457 ~72.226 ms, finishGL 78 / 25490 ~64.697 ms, waitGL 4 / 2678 ~6.798 ms +XXX[395] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28540 ~72.254 ms, finishGL 77 / 25568 ~64.73 ms, waitGL 5 / 2683 ~6.794 ms +XXX[396] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28623 ~72.282 ms, finishGL 77 / 25646 ~64.763 ms, waitGL 4 / 2688 ~6.789 ms +XXX[397] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28707 ~72.309 ms, finishGL 77 / 25724 ~64.795 ms, waitGL 4 / 2693 ~6.785 ms +XXX[398] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28790 ~72.337 ms, finishGL 77 / 25801 ~64.828 ms, waitGL 5 / 2698 ~6.781 ms +XXX[399] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28873 ~72.364 ms, finishGL 77 / 25879 ~64.86 ms, waitGL 4 / 2703 ~6.776 ms +XXX[400] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 28957 ~72.392 ms, finishGL 76 / 25956 ~64.89 ms, waitGL 6 / 2709 ~6.774 ms +XXX[401] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29039 ~72.418 ms, finishGL 76 / 26032 ~64.919 ms, waitGL 5 / 2715 ~6.771 ms +XXX[402] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29123 ~72.445 ms, finishGL 75 / 26108 ~64.945 ms, waitGL 7 / 2722 ~6.772 ms +XXX[403] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29206 ~72.472 ms, finishGL 74 / 26182 ~64.969 ms, waitGL 8 / 2730 ~6.776 ms +XXX[404] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29289 ~72.498 ms, finishGL 73 / 26256 ~64.99 ms, waitGL 9 / 2740 ~6.782 ms +XXX[405] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29372 ~72.524 ms, finishGL 73 / 26329 ~65.012 ms, waitGL 8 / 2748 ~6.786 ms +XXX[406] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29455 ~72.551 ms, finishGL 72 / 26402 ~65.03 ms, waitGL 10 / 2758 ~6.794 ms +XXX[407] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 29538 ~72.575 ms, finishGL 72 / 26475 ~65.049 ms, waitGL 9 / 2768 ~6.801 ms +XXX[408] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29621 ~72.602 ms, finishGL 72 / 26547 ~65.067 ms, waitGL 11 / 2779 ~6.811 ms +XXX[409] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 29705 ~72.628 ms, finishGL 71 / 26619 ~65.083 ms, waitGL 10 / 2789 ~6.821 ms +XXX[410] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 29787 ~72.651 ms, finishGL 71 / 26691 ~65.1 ms, waitGL 8 / 2798 ~6.826 ms +XXX[411] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 29870 ~72.677 ms, finishGL 72 / 26763 ~65.117 ms, waitGL 10 / 2808 ~6.834 ms +XXX[412] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 29953 ~72.702 ms, finishGL 71 / 26834 ~65.133 ms, waitGL 10 / 2819 ~6.842 ms +XXX[413] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 30036 ~72.728 ms, finishGL 72 / 26907 ~65.15 ms, waitGL 10 / 2829 ~6.851 ms +XXX[414] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30119 ~72.753 ms, finishGL 71 / 26978 ~65.165 ms, waitGL 10 / 2840 ~6.86 ms +XXX[415] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30203 ~72.778 ms, finishGL 70 / 27049 ~65.179 ms, waitGL 11 / 2851 ~6.87 ms +XXX[416] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30286 ~72.803 ms, finishGL 71 / 27120 ~65.193 ms, waitGL 10 / 2862 ~6.88 ms +XXX[417] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30369 ~72.828 ms, finishGL 70 / 27190 ~65.205 ms, waitGL 11 / 2874 ~6.892 ms +XXX[418] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30452 ~72.853 ms, finishGL 69 / 27260 ~65.216 ms, waitGL 12 / 2886 ~6.905 ms +XXX[419] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30535 ~72.877 ms, finishGL 69 / 27329 ~65.226 ms, waitGL 12 / 2898 ~6.918 ms +XXX[420] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30619 ~72.902 ms, finishGL 70 / 27400 ~65.239 ms, waitGL 11 / 2910 ~6.93 ms +XXX[421] TO 17 ms, lFrame0 1 ms, lFrameX 82 / 30702 ~72.926 ms, finishGL 70 / 27470 ~65.251 ms, waitGL 11 / 2922 ~6.941 ms +XXX[422] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30785 ~72.95 ms, finishGL 71 / 27542 ~65.266 ms, waitGL 10 / 2932 ~6.949 ms +XXX[423] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30868 ~72.974 ms, finishGL 72 / 27614 ~65.283 ms, waitGL 9 / 2942 ~6.955 ms +XXX[424] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 30951 ~72.998 ms, finishGL 71 / 27686 ~65.298 ms, waitGL 10 / 2952 ~6.963 ms +XXX[425] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 31034 ~73.023 ms, finishGL 68 / 27755 ~65.307 ms, waitGL 13 / 2965 ~6.978 ms +XXX[426] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 31117 ~73.046 ms, finishGL 65 / 27820 ~65.307 ms, waitGL 16 / 2982 ~7.0 ms +XXX[427] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31184 ~73.031 ms, finishGL 62 / 27883 ~65.3 ms, waitGL 3 / 2985 ~6.991 ms +XXX[428] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31250 ~73.016 ms, finishGL 60 / 27944 ~65.289 ms, waitGL 4 / 2990 ~6.986 ms +XXX[429] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31317 ~73.0 ms, finishGL 59 / 28003 ~65.277 ms, waitGL 5 / 2995 ~6.982 ms +XXX[430] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31383 ~72.985 ms, finishGL 59 / 28063 ~65.263 ms, waitGL 6 / 3001 ~6.98 ms +XXX[431] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31450 ~72.97 ms, finishGL 58 / 28121 ~65.248 ms, waitGL 6 / 3008 ~6.979 ms +XXX[432] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31516 ~72.955 ms, finishGL 58 / 28179 ~65.231 ms, waitGL 7 / 3015 ~6.98 ms +XXX[433] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31583 ~72.94 ms, finishGL 57 / 28237 ~65.214 ms, waitGL 7 / 3023 ~6.981 ms +XXX[434] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31649 ~72.926 ms, finishGL 57 / 28295 ~65.197 ms, waitGL 7 / 3030 ~6.983 ms +XXX[435] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31716 ~72.911 ms, finishGL 56 / 28352 ~65.178 ms, waitGL 8 / 3039 ~6.986 ms +XXX[436] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31782 ~72.896 ms, finishGL 56 / 28409 ~65.158 ms, waitGL 8 / 3048 ~6.99 ms +XXX[437] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31849 ~72.882 ms, finishGL 56 / 28465 ~65.137 ms, waitGL 9 / 3057 ~6.996 ms +XXX[438] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 31915 ~72.867 ms, finishGL 55 / 28520 ~65.116 ms, waitGL 9 / 3066 ~7.002 ms +XXX[439] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 31982 ~72.853 ms, finishGL 55 / 28576 ~65.093 ms, waitGL 10 / 3077 ~7.01 ms +XXX[440] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32047 ~72.836 ms, finishGL 56 / 28632 ~65.073 ms, waitGL 8 / 3086 ~7.014 ms +XXX[441] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32114 ~72.822 ms, finishGL 56 / 28689 ~65.055 ms, waitGL 8 / 3095 ~7.018 ms +XXX[442] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 32180 ~72.807 ms, finishGL 56 / 28746 ~65.036 ms, waitGL 8 / 3103 ~7.021 ms +XXX[443] TO 17 ms, lFrame0 1 ms, lFrameX 67 / 32248 ~72.795 ms, finishGL 57 / 28803 ~65.02 ms, waitGL 8 / 3112 ~7.025 ms +XXX[444] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 32313 ~72.779 ms, finishGL 57 / 28861 ~65.002 ms, waitGL 8 / 3120 ~7.027 ms +XXX[445] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32380 ~72.765 ms, finishGL 58 / 28919 ~64.987 ms, waitGL 7 / 3127 ~7.029 ms +XXX[446] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 32446 ~72.751 ms, finishGL 58 / 28977 ~64.972 ms, waitGL 7 / 3135 ~7.029 ms +XXX[447] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32513 ~72.737 ms, finishGL 59 / 29036 ~64.959 ms, waitGL 6 / 3141 ~7.027 ms +XXX[448] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 32579 ~72.722 ms, finishGL 58 / 29095 ~64.944 ms, waitGL 6 / 3148 ~7.027 ms +XXX[449] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32646 ~72.709 ms, finishGL 58 / 29154 ~64.931 ms, waitGL 7 / 3155 ~7.027 ms +XXX[450] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 32712 ~72.695 ms, finishGL 58 / 29212 ~64.917 ms, waitGL 6 / 3161 ~7.026 ms +XXX[451] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 32779 ~72.681 ms, finishGL 58 / 29271 ~64.903 ms, waitGL 6 / 3168 ~7.026 ms +XXX[452] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 32845 ~72.667 ms, finishGL 58 / 29330 ~64.889 ms, waitGL 6 / 3175 ~7.025 ms +XXX[453] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32912 ~72.654 ms, finishGL 58 / 29388 ~64.876 ms, waitGL 7 / 3182 ~7.026 ms +XXX[454] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 32978 ~72.64 ms, finishGL 57 / 29446 ~64.859 ms, waitGL 8 / 3190 ~7.028 ms +XXX[455] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 33045 ~72.627 ms, finishGL 56 / 29503 ~64.841 ms, waitGL 8 / 3199 ~7.032 ms +XXX[456] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 33111 ~72.613 ms, finishGL 55 / 29558 ~64.821 ms, waitGL 9 / 3209 ~7.037 ms +XXX[457] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 33178 ~72.6 ms, finishGL 55 / 29613 ~64.8 ms, waitGL 10 / 3219 ~7.045 ms +XXX[458] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 33244 ~72.586 ms, finishGL 53 / 29667 ~64.776 ms, waitGL 11 / 3230 ~7.054 ms +XXX[459] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 33311 ~72.573 ms, finishGL 53 / 29721 ~64.751 ms, waitGL 12 / 3243 ~7.066 ms +XXX[460] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 33377 ~72.56 ms, finishGL 52 / 29773 ~64.724 ms, waitGL 12 / 3256 ~7.079 ms +XXX[461] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 33444 ~72.547 ms, finishGL 51 / 29824 ~64.695 ms, waitGL 14 / 3270 ~7.094 ms +XXX[462] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 33510 ~72.533 ms, finishGL 50 / 29874 ~64.664 ms, waitGL 14 / 3285 ~7.111 ms +XXX[463] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 33577 ~72.52 ms, finishGL 49 / 29924 ~64.631 ms, waitGL 15 / 3301 ~7.13 ms +XXX[464] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 33627 ~72.473 ms, finishGL 48 / 29973 ~64.597 ms, waitGL 1 / 3302 ~7.117 ms +XXX[465] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 33693 ~72.46 ms, finishGL 63 / 30036 ~64.595 ms, waitGL 1 / 3304 ~7.105 ms +XXX[466] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 33760 ~72.448 ms, finishGL 63 / 30100 ~64.593 ms, waitGL 2 / 3306 ~7.096 ms +XXX[467] TO 17 ms, lFrame0 1 ms, lFrameX 48 / 33809 ~72.397 ms, finishGL 46 / 30146 ~64.554 ms, waitGL 1 / 3308 ~7.084 ms +XXX[468] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 33859 ~72.349 ms, finishGL 45 / 30192 ~64.513 ms, waitGL 3 / 3311 ~7.076 ms +XXX[469] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 33909 ~72.301 ms, finishGL 44 / 30237 ~64.472 ms, waitGL 3 / 3315 ~7.068 ms +XXX[470] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 33959 ~72.253 ms, finishGL 44 / 30281 ~64.428 ms, waitGL 4 / 3319 ~7.063 ms +XXX[471] TO 17 ms, lFrame0 1 ms, lFrameX 48 / 34007 ~72.202 ms, finishGL 43 / 30325 ~64.385 ms, waitGL 2 / 3322 ~7.054 ms +XXX[472] TO 17 ms, lFrame0 1 ms, lFrameX 50 / 34057 ~72.155 ms, finishGL 42 / 30368 ~64.339 ms, waitGL 6 / 3328 ~7.052 ms +XXX[473] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 34107 ~72.109 ms, finishGL 41 / 30409 ~64.291 ms, waitGL 8 / 3336 ~7.054 ms +XXX[474] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34157 ~72.061 ms, finishGL 41 / 30451 ~64.243 ms, waitGL 6 / 3343 ~7.054 ms +XXX[475] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 34206 ~72.014 ms, finishGL 41 / 30492 ~64.194 ms, waitGL 7 / 3351 ~7.055 ms +XXX[476] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 34256 ~71.967 ms, finishGL 40 / 30532 ~64.144 ms, waitGL 8 / 3359 ~7.057 ms +XXX[477] TO 17 ms, lFrame0 1 ms, lFrameX 50 / 34307 ~71.922 ms, finishGL 39 / 30572 ~64.093 ms, waitGL 9 / 3369 ~7.063 ms +XXX[478] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34356 ~71.874 ms, finishGL 38 / 30611 ~64.039 ms, waitGL 10 / 3379 ~7.069 ms +XXX[479] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34406 ~71.828 ms, finishGL 38 / 30649 ~63.987 ms, waitGL 10 / 3389 ~7.076 ms +XXX[480] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34455 ~71.782 ms, finishGL 38 / 30688 ~63.933 ms, waitGL 10 / 3400 ~7.084 ms +XXX[481] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34505 ~71.737 ms, finishGL 37 / 30725 ~63.878 ms, waitGL 11 / 3412 ~7.094 ms +XXX[482] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34555 ~71.691 ms, finishGL 35 / 30761 ~63.82 ms, waitGL 13 / 3425 ~7.107 ms +XXX[483] TO 17 ms, lFrame0 1 ms, lFrameX 50 / 34605 ~71.646 ms, finishGL 35 / 30796 ~63.761 ms, waitGL 13 / 3439 ~7.12 ms +XXX[484] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34655 ~71.601 ms, finishGL 34 / 30831 ~63.701 ms, waitGL 14 / 3453 ~7.135 ms +XXX[485] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 34704 ~71.556 ms, finishGL 33 / 30864 ~63.638 ms, waitGL 15 / 3468 ~7.151 ms +XXX[486] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34754 ~71.511 ms, finishGL 33 / 30898 ~63.576 ms, waitGL 16 / 3484 ~7.17 ms +XXX[487] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 34804 ~71.466 ms, finishGL 33 / 30931 ~63.513 ms, waitGL 15 / 3500 ~7.187 ms +XXX[488] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 34854 ~71.422 ms, finishGL 32 / 30963 ~63.45 ms, waitGL 16 / 3516 ~7.206 ms +XXX[489] TO 17 ms, lFrame0 1 ms, lFrameX 34 / 34888 ~71.346 ms, finishGL 32 / 30996 ~63.387 ms, waitGL 0 / 3517 ~7.192 ms +XXX[490] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 34953 ~71.334 ms, finishGL 48 / 31044 ~63.356 ms, waitGL 16 / 3533 ~7.211 ms +XXX[491] TO 17 ms, lFrame0 0 ms, lFrameX 33 / 34987 ~71.258 ms, finishGL 33 / 31077 ~63.294 ms, waitGL 0 / 3533 ~7.197 ms +XXX[492] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 35053 ~71.246 ms, finishGL 49 / 31127 ~63.266 ms, waitGL 15 / 3549 ~7.214 ms +XXX[493] TO 17 ms, lFrame0 0 ms, lFrameX 50 / 35104 ~71.204 ms, finishGL 33 / 31160 ~63.205 ms, waitGL 16 / 3566 ~7.234 ms +XXX[494] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35153 ~71.16 ms, finishGL 32 / 31192 ~63.142 ms, waitGL 15 / 3582 ~7.252 ms +XXX[495] TO 17 ms, lFrame0 1 ms, lFrameX 33 / 35187 ~71.085 ms, finishGL 32 / 31224 ~63.08 ms, waitGL 0 / 3582 ~7.238 ms +XXX[496] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 35252 ~71.074 ms, finishGL 50 / 31275 ~63.054 ms, waitGL 14 / 3597 ~7.253 ms +XXX[497] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35302 ~71.031 ms, finishGL 35 / 31310 ~62.998 ms, waitGL 13 / 3611 ~7.266 ms +XXX[498] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35352 ~70.988 ms, finishGL 34 / 31344 ~62.941 ms, waitGL 13 / 3625 ~7.279 ms +XXX[499] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35402 ~70.946 ms, finishGL 35 / 31380 ~62.887 ms, waitGL 13 / 3638 ~7.291 ms +FrameCount: 600 - FrameRate: 21.0 +XXX[500] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35452 ~70.904 ms, finishGL 37 / 31417 ~62.835 ms, waitGL 11 / 3649 ~7.299 ms +XXX[501] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35501 ~70.861 ms, finishGL 36 / 31454 ~62.783 ms, waitGL 12 / 3662 ~7.309 ms +XXX[502] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35551 ~70.82 ms, finishGL 37 / 31492 ~62.733 ms, waitGL 11 / 3673 ~7.317 ms +XXX[503] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35601 ~70.778 ms, finishGL 37 / 31529 ~62.683 ms, waitGL 11 / 3684 ~7.325 ms +XXX[504] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35651 ~70.736 ms, finishGL 38 / 31567 ~62.634 ms, waitGL 10 / 3695 ~7.331 ms +XXX[505] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35701 ~70.695 ms, finishGL 38 / 31606 ~62.586 ms, waitGL 10 / 3705 ~7.338 ms +XXX[506] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 35750 ~70.653 ms, finishGL 38 / 31644 ~62.538 ms, waitGL 10 / 3716 ~7.345 ms +XXX[507] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35800 ~70.612 ms, finishGL 38 / 31683 ~62.491 ms, waitGL 9 / 3726 ~7.35 ms +XXX[508] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35850 ~70.571 ms, finishGL 39 / 31722 ~62.445 ms, waitGL 9 / 3736 ~7.354 ms +XXX[509] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35900 ~70.53 ms, finishGL 40 / 31762 ~62.401 ms, waitGL 8 / 3744 ~7.356 ms +XXX[510] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 35950 ~70.49 ms, finishGL 39 / 31802 ~62.357 ms, waitGL 8 / 3753 ~7.359 ms +XXX[511] TO 17 ms, lFrame0 2 ms, lFrameX 48 / 35998 ~70.447 ms, finishGL 39 / 31841 ~62.313 ms, waitGL 6 / 3759 ~7.357 ms +XXX[512] TO 17 ms, lFrame0 1 ms, lFrameX 49 / 36048 ~70.406 ms, finishGL 41 / 31883 ~62.272 ms, waitGL 6 / 3766 ~7.356 ms +XXX[513] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 36098 ~70.366 ms, finishGL 42 / 31926 ~62.234 ms, waitGL 6 / 3772 ~7.353 ms +XXX[514] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 36147 ~70.326 ms, finishGL 44 / 31971 ~62.2 ms, waitGL 4 / 3776 ~7.347 ms +XXX[515] TO 17 ms, lFrame0 0 ms, lFrameX 49 / 36197 ~70.286 ms, finishGL 47 / 32018 ~62.172 ms, waitGL 1 / 3778 ~7.336 ms +XXX[516] TO 17 ms, lFrame0 0 ms, lFrameX 67 / 36265 ~70.281 ms, finishGL 49 / 32068 ~62.147 ms, waitGL 17 / 3795 ~7.355 ms +XXX[517] TO 17 ms, lFrame0 1 ms, lFrameX 65 / 36330 ~70.272 ms, finishGL 52 / 32120 ~62.129 ms, waitGL 11 / 3807 ~7.363 ms +XXX[518] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 36396 ~70.264 ms, finishGL 58 / 32179 ~62.122 ms, waitGL 6 / 3813 ~7.362 ms +XXX[519] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36480 ~70.289 ms, finishGL 68 / 32248 ~62.135 ms, waitGL 14 / 3827 ~7.375 ms +XXX[520] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36563 ~70.313 ms, finishGL 76 / 32324 ~62.161 ms, waitGL 6 / 3834 ~7.373 ms +XXX[521] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36646 ~70.338 ms, finishGL 76 / 32401 ~62.19 ms, waitGL 5 / 3839 ~7.37 ms +XXX[522] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36729 ~70.363 ms, finishGL 76 / 32477 ~62.217 ms, waitGL 6 / 3846 ~7.368 ms +XXX[523] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 36812 ~70.387 ms, finishGL 76 / 32553 ~62.244 ms, waitGL 6 / 3852 ~7.366 ms +XXX[524] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 36895 ~70.412 ms, finishGL 76 / 32630 ~62.271 ms, waitGL 5 / 3858 ~7.362 ms +XXX[525] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 36979 ~70.436 ms, finishGL 76 / 32706 ~62.297 ms, waitGL 5 / 3864 ~7.36 ms +XXX[526] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 37062 ~70.46 ms, finishGL 75 / 32782 ~62.323 ms, waitGL 6 / 3870 ~7.358 ms +XXX[527] TO 17 ms, lFrame0 1 ms, lFrameX 84 / 37146 ~70.486 ms, finishGL 75 / 32857 ~62.348 ms, waitGL 7 / 3877 ~7.358 ms +XXX[528] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 37228 ~70.508 ms, finishGL 74 / 32932 ~62.372 ms, waitGL 7 / 3884 ~7.357 ms +XXX[529] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 37311 ~70.532 ms, finishGL 75 / 33008 ~62.397 ms, waitGL 6 / 3890 ~7.355 ms +XXX[530] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37395 ~70.556 ms, finishGL 76 / 33084 ~62.423 ms, waitGL 6 / 3897 ~7.353 ms +XXX[531] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 37478 ~70.58 ms, finishGL 76 / 33160 ~62.449 ms, waitGL 6 / 3903 ~7.351 ms +XXX[532] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 37561 ~70.603 ms, finishGL 76 / 33237 ~62.476 ms, waitGL 5 / 3909 ~7.348 ms +XXX[533] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 37644 ~70.627 ms, finishGL 76 / 33313 ~62.502 ms, waitGL 5 / 3914 ~7.344 ms +XXX[534] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 37727 ~70.651 ms, finishGL 76 / 33390 ~62.528 ms, waitGL 5 / 3920 ~7.341 ms +XXX[535] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 37810 ~70.674 ms, finishGL 76 / 33466 ~62.554 ms, waitGL 5 / 3926 ~7.338 ms +XXX[536] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 37893 ~70.697 ms, finishGL 76 / 33542 ~62.579 ms, waitGL 5 / 3931 ~7.335 ms +XXX[537] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 37977 ~70.721 ms, finishGL 75 / 33618 ~62.604 ms, waitGL 6 / 3938 ~7.333 ms +XXX[538] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 38060 ~70.744 ms, finishGL 75 / 33694 ~62.628 ms, waitGL 6 / 3944 ~7.332 ms +XXX[539] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 38143 ~70.767 ms, finishGL 75 / 33769 ~62.651 ms, waitGL 6 / 3951 ~7.331 ms +XXX[540] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 38226 ~70.79 ms, finishGL 74 / 33843 ~62.673 ms, waitGL 7 / 3958 ~7.331 ms +XXX[541] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 38309 ~70.813 ms, finishGL 74 / 33918 ~62.695 ms, waitGL 7 / 3966 ~7.332 ms +XXX[542] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 38393 ~70.835 ms, finishGL 74 / 33992 ~62.717 ms, waitGL 7 / 3974 ~7.332 ms +XXX[543] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 38476 ~70.858 ms, finishGL 75 / 34067 ~62.74 ms, waitGL 6 / 3981 ~7.331 ms +XXX[544] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 38559 ~70.881 ms, finishGL 74 / 34142 ~62.762 ms, waitGL 7 / 3988 ~7.331 ms +XXX[545] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 38642 ~70.903 ms, finishGL 75 / 34218 ~62.786 ms, waitGL 6 / 3994 ~7.329 ms +XXX[546] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38725 ~70.926 ms, finishGL 75 / 34294 ~62.809 ms, waitGL 7 / 4001 ~7.329 ms +XXX[547] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 38809 ~70.95 ms, finishGL 75 / 34369 ~62.833 ms, waitGL 7 / 4009 ~7.329 ms +XXX[548] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 38892 ~70.97 ms, finishGL 76 / 34446 ~62.857 ms, waitGL 5 / 4014 ~7.326 ms +XXX[549] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 38975 ~70.993 ms, finishGL 77 / 34523 ~62.884 ms, waitGL 4 / 4019 ~7.321 ms +XXX[550] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 39058 ~71.015 ms, finishGL 77 / 34601 ~62.912 ms, waitGL 3 / 4023 ~7.315 ms +XXX[551] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39141 ~71.037 ms, finishGL 78 / 34680 ~62.94 ms, waitGL 4 / 4027 ~7.31 ms +XXX[552] TO 17 ms, lFrame0 0 ms, lFrameX 84 / 39225 ~71.06 ms, finishGL 79 / 34759 ~62.97 ms, waitGL 4 / 4031 ~7.304 ms +XXX[553] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39307 ~71.081 ms, finishGL 78 / 34837 ~62.997 ms, waitGL 3 / 4035 ~7.296 ms +XXX[554] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39391 ~71.103 ms, finishGL 77 / 34915 ~63.024 ms, waitGL 4 / 4040 ~7.292 ms +XXX[555] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39474 ~71.124 ms, finishGL 77 / 34992 ~63.05 ms, waitGL 5 / 4045 ~7.289 ms +XXX[556] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 39557 ~71.146 ms, finishGL 76 / 35069 ~63.074 ms, waitGL 5 / 4051 ~7.286 ms +XXX[557] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39640 ~71.168 ms, finishGL 75 / 35145 ~63.097 ms, waitGL 6 / 4057 ~7.284 ms +XXX[558] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39724 ~71.19 ms, finishGL 73 / 35219 ~63.116 ms, waitGL 9 / 4066 ~7.287 ms +XXX[559] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39807 ~71.212 ms, finishGL 73 / 35292 ~63.134 ms, waitGL 9 / 4076 ~7.292 ms +XXX[560] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 39890 ~71.233 ms, finishGL 72 / 35364 ~63.15 ms, waitGL 10 / 4086 ~7.297 ms +XXX[561] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 39974 ~71.255 ms, finishGL 71 / 35435 ~63.164 ms, waitGL 11 / 4098 ~7.305 ms +XXX[562] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 40057 ~71.276 ms, finishGL 69 / 35504 ~63.175 ms, waitGL 13 / 4112 ~7.316 ms +XXX[563] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 40140 ~71.297 ms, finishGL 67 / 35572 ~63.183 ms, waitGL 15 / 4127 ~7.33 ms +XXX[564] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 40223 ~71.318 ms, finishGL 65 / 35637 ~63.187 ms, waitGL 16 / 4144 ~7.347 ms +XXX[565] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40289 ~71.308 ms, finishGL 64 / 35702 ~63.189 ms, waitGL 0 / 4145 ~7.336 ms +XXX[566] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 40372 ~71.329 ms, finishGL 78 / 35780 ~63.217 ms, waitGL 3 / 4148 ~7.329 ms +XXX[567] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40438 ~71.32 ms, finishGL 61 / 35842 ~63.213 ms, waitGL 4 / 4153 ~7.324 ms +XXX[568] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 40504 ~71.311 ms, finishGL 60 / 35902 ~63.208 ms, waitGL 4 / 4157 ~7.32 ms +XXX[569] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 40588 ~71.333 ms, finishGL 74 / 35977 ~63.229 ms, waitGL 8 / 4166 ~7.322 ms +XXX[570] TO 17 ms, lFrame0 0 ms, lFrameX 65 / 40654 ~71.323 ms, finishGL 58 / 36035 ~63.22 ms, waitGL 6 / 4173 ~7.321 ms +XXX[571] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 40720 ~71.315 ms, finishGL 58 / 36094 ~63.212 ms, waitGL 6 / 4179 ~7.319 ms +XXX[572] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 40787 ~71.306 ms, finishGL 58 / 36152 ~63.204 ms, waitGL 7 / 4186 ~7.319 ms +XXX[573] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 40853 ~71.298 ms, finishGL 57 / 36210 ~63.193 ms, waitGL 8 / 4194 ~7.32 ms +XXX[574] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 40920 ~71.289 ms, finishGL 57 / 36267 ~63.184 ms, waitGL 7 / 4202 ~7.321 ms +XXX[575] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 40986 ~71.281 ms, finishGL 57 / 36325 ~63.174 ms, waitGL 8 / 4210 ~7.322 ms +XXX[576] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 41053 ~71.273 ms, finishGL 57 / 36382 ~63.164 ms, waitGL 8 / 4218 ~7.324 ms +XXX[577] TO 17 ms, lFrame0 0 ms, lFrameX 66 / 41120 ~71.265 ms, finishGL 57 / 36440 ~63.154 ms, waitGL 8 / 4227 ~7.325 ms +XXX[578] TO 17 ms, lFrame0 1 ms, lFrameX 66 / 41186 ~71.256 ms, finishGL 61 / 36501 ~63.151 ms, waitGL 3 / 4231 ~7.32 ms +XXX[579] TO 17 ms, lFrame0 1 ms, lFrameX 67 / 41253 ~71.25 ms, finishGL 64 / 36565 ~63.153 ms, waitGL 1 / 4232 ~7.31 ms +XXX[580] TO 17 ms, lFrame0 0 ms, lFrameX 98 / 41352 ~71.298 ms, finishGL 86 / 36652 ~63.194 ms, waitGL 11 / 4244 ~7.318 ms +XXX[581] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 41436 ~71.318 ms, finishGL 75 / 36728 ~63.215 ms, waitGL 6 / 4251 ~7.317 ms +XXX[582] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 41519 ~71.338 ms, finishGL 78 / 36807 ~63.242 ms, waitGL 4 / 4255 ~7.311 ms +XXX[583] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 41602 ~71.359 ms, finishGL 79 / 36886 ~63.269 ms, waitGL 2 / 4258 ~7.303 ms +XXX[584] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 41685 ~71.379 ms, finishGL 79 / 36965 ~63.297 ms, waitGL 2 / 4260 ~7.296 ms +XXX[585] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 41768 ~71.399 ms, finishGL 76 / 37042 ~63.319 ms, waitGL 5 / 4266 ~7.293 ms +XXX[586] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 41851 ~71.419 ms, finishGL 75 / 37117 ~63.339 ms, waitGL 6 / 4273 ~7.293 ms +XXX[587] TO 17 ms, lFrame0 1 ms, lFrameX 84 / 41935 ~71.441 ms, finishGL 74 / 37191 ~63.359 ms, waitGL 8 / 4282 ~7.294 ms +XXX[588] TO 17 ms, lFrame0 2 ms, lFrameX 83 / 42019 ~71.461 ms, finishGL 74 / 37266 ~63.379 ms, waitGL 5 / 4287 ~7.292 ms +XXX[589] TO 17 ms, lFrame0 0 ms, lFrameX 82 / 42101 ~71.479 ms, finishGL 73 / 37340 ~63.396 ms, waitGL 8 / 4296 ~7.294 ms +XXX[590] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42184 ~71.499 ms, finishGL 73 / 37414 ~63.414 ms, waitGL 8 / 4304 ~7.296 ms +XXX[591] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42267 ~71.519 ms, finishGL 73 / 37487 ~63.431 ms, waitGL 9 / 4313 ~7.299 ms +XXX[592] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 42351 ~71.538 ms, finishGL 73 / 37561 ~63.448 ms, waitGL 8 / 4322 ~7.301 ms +XXX[593] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 42434 ~71.558 ms, finishGL 73 / 37635 ~63.465 ms, waitGL 8 / 4330 ~7.302 ms +XXX[594] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 42517 ~71.578 ms, finishGL 73 / 37709 ~63.483 ms, waitGL 8 / 4338 ~7.303 ms +XXX[595] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 42600 ~71.597 ms, finishGL 74 / 37784 ~63.502 ms, waitGL 7 / 4345 ~7.303 ms +XXX[596] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 42683 ~71.616 ms, finishGL 75 / 37859 ~63.522 ms, waitGL 6 / 4352 ~7.302 ms +XXX[597] TO 17 ms, lFrame0 1 ms, lFrameX 83 / 42766 ~71.636 ms, finishGL 76 / 37935 ~63.544 ms, waitGL 5 / 4358 ~7.3 ms +XXX[598] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42850 ~71.655 ms, finishGL 76 / 38012 ~63.566 ms, waitGL 5 / 4363 ~7.297 ms +XXX[599] TO 17 ms, lFrame0 0 ms, lFrameX 83 / 42933 ~71.674 ms, finishGL 77 / 38090 ~63.589 ms, waitGL 5 / 4369 ~7.294 ms diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java index 34a3513ce..6340d2b64 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv2AppletAWT.java @@ -24,6 +24,8 @@ import javax.media.opengl.awt.GLCanvas; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; /** * Difference to orig. Bug735Inv0AppletAWT: @@ -36,7 +38,7 @@ import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; * OSX Results: *
      *   - Visible content
    - *   - Stuttering, non-fluent and slow animation
    + *   - Fluent animation
      * 
    */ @SuppressWarnings("serial") @@ -50,10 +52,11 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable { static public int TOOLKIT = NEWT; static public boolean IGNORE_AWT_REPAINT = false; static public boolean USE_ECT = false; - static public int SWAP_INTERVAL = 0; + static public int SWAP_INTERVAL = 1; ////////////////////////////////////////////////////////////////////////////// + static boolean waitForKey = false; static private Frame frame; static private Bug735Inv2AppletAWT applet; private GLCanvas awtCanvas; @@ -203,6 +206,22 @@ public class Bug735Inv2AppletAWT extends Applet implements Runnable { } static public void main(String[] args) { + for(int i=0; i * - Visible content - * - Stuttering, non-fluent and slow animation + * - Fluent animation * */ @SuppressWarnings("serial") @@ -53,11 +54,11 @@ public class Bug735Inv3AppletAWT extends Applet { static public int TOOLKIT = NEWT; static public boolean IGNORE_AWT_REPAINT = false; static public boolean USE_ECT = false; - static public int SWAP_INTERVAL = 0; + static public int SWAP_INTERVAL = 1; ////////////////////////////////////////////////////////////////////////////// - static boolean waitForKey = true; + static boolean waitForKey = false; static private Frame frame; static private Bug735Inv3AppletAWT applet; private GLCanvas awtCanvas; @@ -81,6 +82,7 @@ public class Bug735Inv3AppletAWT extends Applet { public void start() { initDraw(); animator.start(); + animator.setUpdateFPSFrames(60, System.err); } private void initGL() { @@ -120,6 +122,7 @@ public class Bug735Inv3AppletAWT extends Applet { } demo = new LandscapeES2(SWAP_INTERVAL); + // demo = new GearsES2(SWAP_INTERVAL); glad.addGLEventListener(demo); animator = new Animator(glad); animator.setExclusiveContext(USE_ECT); @@ -144,9 +147,22 @@ public class Bug735Inv3AppletAWT extends Applet { } static public void main(String[] args) { + for(int i=0; i * - Visible content - * - Java6: Fluent animation - * - Java7: Stuttering, non-fluent and slow animation + * - Fluent animation * */ public class Bug735Inv4AWT { @@ -52,11 +52,11 @@ public class Bug735Inv4AWT { static public int TOOLKIT = NEWT; static public boolean IGNORE_AWT_REPAINT = false; static public boolean USE_ECT = false; - static public int SWAP_INTERVAL = 0; + static public int SWAP_INTERVAL = 1; ////////////////////////////////////////////////////////////////////////////// - static boolean waitForKey = true; + static boolean waitForKey = false; static private Frame frame; static private Bug735Inv4AWT applet; private GLCanvas awtCanvas; @@ -78,6 +78,7 @@ public class Bug735Inv4AWT { public void start() { initDraw(); animator.start(); + animator.setUpdateFPSFrames(60, System.err); } private void initGL() { @@ -133,9 +134,22 @@ public class Bug735Inv4AWT { } static public void main(String[] args) { + for(int i=0; i Date: Mon, 17 Jun 2013 06:19:57 +0200 Subject: Solve Bug 735 Mystery: glViewport(..) was missing - duh :) --- make/scripts/tests.sh | 4 ++-- src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java | 2 ++ src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ee4411c08..5fd5d621d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -441,10 +441,10 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* +testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv2AppletAWT $* -testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv4AWT $* # diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java index 58ba03638..4cf342c0e 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java @@ -308,6 +308,8 @@ public class Bug735Inv0AppletAWT extends Applet implements Runnable { // Disables vsync gl.setSwapInterval(0); } + gl.glViewport(0, 0, width, height); + glu = new GLU(); vertShader = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, LandscapeES2.class, "shader", "shader/bin", "landscape", true); diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java index 8c8dd77da..a03afba7a 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java @@ -307,6 +307,8 @@ public class Bug735Inv1AppletAWT extends Applet implements Runnable { // Disables vsync gl.setSwapInterval(0); } + gl.glViewport(0, 0, width, height); + glu = new GLU(); vertShader = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, LandscapeES2.class, "shader", "shader/bin", "landscape", true); -- cgit v1.2.3 From 8b33170ec6fd3f215976875cb66d746fa1b48f61 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Jun 2013 09:01:23 +0200 Subject: Fix Bug 688: Removal of NEWT KeyEvent.EVENT_KEY_TYPED and KeyListener.keyTyped(KeyEvent) --- make/scripts/tests.sh | 13 ++----- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 11 ++---- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 7 ++-- .../classes/com/jogamp/newt/event/KeyAdapter.java | 2 -- .../classes/com/jogamp/newt/event/KeyEvent.java | 6 ---- .../classes/com/jogamp/newt/event/KeyListener.java | 18 ++++++---- .../com/jogamp/newt/event/TraceKeyAdapter.java | 4 --- src/newt/classes/jogamp/newt/WindowImpl.java | 34 +----------------- src/newt/native/KeyEvent.h | 1 - src/newt/native/X11Event.c | 6 ---- src/newt/native/X11Window.c | 1 - src/newt/native/XCBEvent.c | 6 ---- .../graph/demos/GPURendererListenerBase01.java | 1 - .../graph/demos/GPUTextRendererListenerBase01.java | 10 +++--- .../junit/graph/demos/ui/UIListenerBase01.java | 1 - .../junit/jogl/acore/TestFBOMix2DemosES2NEWT.java | 5 ++- .../test/junit/jogl/caps/TestTranslucencyNEWT.java | 5 ++- .../jogl/demos/es1/newt/TestGearsES1NEWT.java | 5 ++- .../jogl/demos/es1/newt/TestRedSquareES1NEWT.java | 5 ++- .../test/junit/jogl/demos/es2/av/MovieCube.java | 5 ++- .../es2/newt/TestElektronenMultipliziererNEWT.java | 5 ++- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 5 ++- .../demos/es2/newt/TestGearsES2NewtCanvasSWT.java | 5 ++- .../jogl/demos/es2/newt/TestLandscapeES2NEWT.java | 5 ++- .../es2/newt/TestLandscapeES2NewtCanvasAWT.java | 5 ++- .../jogl/demos/es2/newt/TestRedSquareES2NEWT.java | 5 ++- .../junit/jogl/demos/gl2/newt/TestGearsNEWT.java | 5 ++- .../TestNewtCanvasSWTBug628ResizeDeadlockAWT.java | 5 ++- .../newt/event/TestNewtKeyCodeModifiersAWT.java | 32 ++++++----------- .../test/junit/newt/event/TestNewtKeyCodesAWT.java | 3 -- .../newt/event/TestNewtKeyEventAutoRepeatAWT.java | 21 ++++++------ .../junit/newt/event/TestNewtKeyEventOrderAWT.java | 4 +-- .../TestNewtKeyPressReleaseUnmaskRepeatAWT.java | 5 --- .../test/junit/newt/parenting/KeyAction.java | 5 ++- .../parenting/NewtAWTReparentingKeyAdapter.java | 5 ++- .../TestParentingFocusTraversal01AWT.java | 5 ++- .../opengl/test/junit/util/AWTKeyAdapter.java | 19 ++-------- .../test/junit/util/KeyEventCountAdapter.java | 4 +-- .../opengl/test/junit/util/NEWTKeyAdapter.java | 26 +++----------- .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 40 ++++++---------------- .../jogamp/opengl/test/junit/util/QuitAdapter.java | 6 ++-- 41 files changed, 136 insertions(+), 225 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5fd5d621d..bf8615d6e 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -284,7 +284,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -438,15 +440,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* -testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv2AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* -#testawt com.jogamp.opengl.test.bugs.Bug735Inv4AWT $* - # # swt (testswt) # @@ -478,7 +471,7 @@ testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 32a92ec8b..692741a88 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -201,8 +201,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto }; class FocusTraversalKeyListener implements KeyListener { - boolean suppress = false; - public void keyPressed(KeyEvent e) { if( isParent() && !isFullscreen() ) { handleKey(e, false); @@ -213,21 +211,16 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto handleKey(e, true); } } - public void keyTyped(KeyEvent e) { - if(suppress) { - e.setConsumed(true); - suppress = false; // reset - } - } void handleKey(KeyEvent evt, boolean onRelease) { if(null == keyboardFocusManager) { throw new InternalError("XXX"); } final AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke(evt.getKeyCode(), evt.getModifiers(), onRelease); + boolean suppress = false; if(null != ks) { final Set fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); - final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); + final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if(fwdKeys.contains(ks)) { if(DEBUG) { System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()); diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 091a1a5cf..35199dc82 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -288,9 +288,10 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { public void keyPressed(KeyEvent e) { } - public void keyReleased(KeyEvent e) { - } - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='d') { glWindow.setUndecorated(!glWindow.isUndecorated()); } if(e.getKeyChar()=='f') { diff --git a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java index 93c8409b1..42ebea722 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyAdapter.java @@ -35,7 +35,5 @@ public abstract class KeyAdapter implements KeyListener } public void keyReleased(KeyEvent e) { } - public void keyTyped(KeyEvent e) { - } } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 6e63ad3a3..683a5ca54 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -217,7 +217,6 @@ public class KeyEvent extends InputEvent switch(type) { case EVENT_KEY_PRESSED: return "EVENT_KEY_PRESSED"; case EVENT_KEY_RELEASED: return "EVENT_KEY_RELEASED"; - case EVENT_KEY_TYPED: return "EVENT_KEY_TYPED"; default: return "unknown (" + type + ")"; } } @@ -365,11 +364,6 @@ public class KeyEvent extends InputEvent public static final short EVENT_KEY_PRESSED = 300; /** A key has been released, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. */ public static final short EVENT_KEY_RELEASED= 301; - /** - * A {@link #isPrintableKey() printable} key has been typed (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. - * @deprecated Redundant, will be removed soon. Use {@link #EVENT_KEY_RELEASED} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}. - */ - public static final short EVENT_KEY_TYPED = 302; /** * This value, {@code '\0'}, is used to indicate that the keyChar is unknown or not printable. diff --git a/src/newt/classes/com/jogamp/newt/event/KeyListener.java b/src/newt/classes/com/jogamp/newt/event/KeyListener.java index 5bca733d3..b3927d81a 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyListener.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyListener.java @@ -43,13 +43,19 @@ public interface KeyListener extends NEWTEventListener { /** A key has been {@link KeyEvent#EVENT_KEY_PRESSED pressed}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ public void keyPressed(KeyEvent e); - /** A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. */ - public void keyReleased(KeyEvent e); /** - * A {@link #isPrintableKey() printable} key has been {@link KeyEvent#EVENT_KEY_TYPED typed} (pressed and released), excluding {@link #isAutoRepeat() auto-repeat}. See {@link KeyEvent}. - * @deprecated Redundant, will be removed soon. Use {@link #keyReleased(KeyEvent)} and exclude non {@link #isPrintableKey() printable} keys and {@link #isAutoRepeat() auto-repeat}. - */ - public void keyTyped(KeyEvent e) ; + * A key has been {@link KeyEvent#EVENT_KEY_RELEASED released}, excluding {@link #isAutoRepeat() auto-repeat} {@link #isModifierKey() modifier} keys. See {@link KeyEvent}. + *

    + * To simulated the removed keyTyped(KeyEvent e) semantics, + * simply apply the following constraints upfront and bail out if not matched, i.e.: + *

    +        if( !e.isPrintableKey() || e.isAutoRepeat() ) {
    +            return;
    +        }            
    +     * 
    + *

    + */ + public void keyReleased(KeyEvent e); } diff --git a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java index 98ba5a24d..629dc50d7 100644 --- a/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java +++ b/src/newt/classes/com/jogamp/newt/event/TraceKeyAdapter.java @@ -48,9 +48,5 @@ public class TraceKeyAdapter implements KeyListener { System.err.println(e); if(null!=downstream) { downstream.keyReleased(e); } } - public void keyTyped(KeyEvent e) { - System.err.println(e); - if(null!=downstream) { downstream.keyTyped(e); } - } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 805ad08ad..dca287c6b 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2476,7 +2476,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return keyListeners.toArray(new KeyListener[keyListeners.size()]); } - @SuppressWarnings("deprecation") private final boolean propagateKeyEvent(KeyEvent e, KeyListener l) { switch(e.getEventType()) { case KeyEvent.EVENT_KEY_PRESSED: @@ -2485,40 +2484,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer case KeyEvent.EVENT_KEY_RELEASED: l.keyReleased(e); break; - case KeyEvent.EVENT_KEY_TYPED: - l.keyTyped(e); - break; default: throw new NativeWindowException("Unexpected key event type " + e.getEventType()); } return e.isConsumed(); } - @SuppressWarnings("deprecation") protected void consumeKeyEvent(KeyEvent e) { - boolean consumedE = false, consumedTyped = false; - if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { - throw new InternalError("Deprecated KeyEvent.EVENT_KEY_TYPED is synthesized - don't send/enqueue it!"); - } - - // Synthesize deprecated event KeyEvent.EVENT_KEY_TYPED - final KeyEvent eTyped; - if( KeyEvent.EVENT_KEY_RELEASED == e.getEventType() && e.isPrintableKey() && !e.isAutoRepeat() ) { - eTyped = KeyEvent.create(KeyEvent.EVENT_KEY_TYPED, e.getSource(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeySymbol(), e.getKeyChar()); - } else { - eTyped = null; - } + boolean consumedE = false; if(null != keyboardFocusHandler) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); if(DEBUG_KEY_EVENT) { System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumedE); } - if( null != eTyped ) { - consumedTyped = propagateKeyEvent(eTyped, keyboardFocusHandler); - if(DEBUG_KEY_EVENT) { - System.err.println("consumeKeyEvent: "+eTyped+", keyboardFocusHandler consumed: "+consumedTyped); - } - } } if(DEBUG_KEY_EVENT) { if( !consumedE ) { @@ -2528,16 +2506,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) { consumedE = propagateKeyEvent(e, keyListeners.get(i)); } - if( null != eTyped ) { - if(DEBUG_KEY_EVENT) { - if( !consumedTyped ) { - System.err.println("consumeKeyEvent: "+eTyped); - } - } - for(int i = 0; !consumedTyped && i < keyListeners.size(); i++ ) { - consumedTyped = propagateKeyEvent(eTyped, keyListeners.get(i)); - } - } } // diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h index a182db973..59977d565 100644 --- a/src/newt/native/KeyEvent.h +++ b/src/newt/native/KeyEvent.h @@ -31,7 +31,6 @@ #define EVENT_KEY_PRESSED 300 #define EVENT_KEY_RELEASED 301 -#define EVENT_KEY_TYPED 302 #define J_VK_UNDEFINED ( 0x0U ) #define J_VK_HOME ( 0x02U ) diff --git a/src/newt/native/X11Event.c b/src/newt/native/X11Event.c index 770f60e8f..32a55c67c 100644 --- a/src/newt/native/X11Event.c +++ b/src/newt/native/X11Event.c @@ -170,15 +170,9 @@ void X11EventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, modifiers, keySym, (jchar) -1); - - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, - modifiers, keySym, (jchar) keyChar); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, modifiers, keySym, (jchar) -1); - - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, - modifiers, keySym, (jchar) keyChar); #endif break; diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index e567781cf..3f50f27a4 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -699,7 +699,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CloseWindow0 XGetWindowAttributes(dpy, w, &xwa); // prefetch colormap to be destroyed after window destruction XSelectInput(dpy, w, 0); XUnmapWindow(dpy, w); - XSync(dpy, False); // Drain all events related to this window .. Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessages0(env, obj, display, javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now diff --git a/src/newt/native/XCBEvent.c b/src/newt/native/XCBEvent.c index f067f4b7a..d02d5a4ba 100644 --- a/src/newt/native/XCBEvent.c +++ b/src/newt/native/XCBEvent.c @@ -176,15 +176,9 @@ void XCBEventPoll(JNIEnv *env, jobject obj, Display *dpy, jlong javaObjectAtom, #ifdef USE_SENDIO_DIRECT (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_RELEASED, modifiers, X11KeySym2NewtVKey(_evt->state), (jchar) keyChar); - - (*env)->CallVoidMethod(env, jwindow, sendKeyEventID, (jint) EVENT_KEY_TYPED, - modifiers, (jint) -1, (jchar) keyChar); #else (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_RELEASED, modifiers, X11KeySym2NewtVKey(_evt->state), (jchar) keyChar); - - (*env)->CallVoidMethod(env, jwindow, enqueueKeyEventID, JNI_FALSE, (jint) EVENT_KEY_TYPED, - modifiers, (jint) -1, (jchar) keyChar); #endif } break; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java index 6378c1ee3..4ebb937a0 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPURendererListenerBase01.java @@ -293,7 +293,6 @@ public abstract class GPURendererListenerBase01 implements GLEventListener { } } } - public void keyTyped(KeyEvent arg0) {} public void keyReleased(KeyEvent arg0) {} } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java index 658d4a4f1..31377025a 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java @@ -295,10 +295,13 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } } - public void keyTyped(KeyEvent arg0) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(userInput) { - char c = arg0.getKeyChar(); - + char c = e.getKeyChar(); + if(c == 0x0d) { userInput = false; setIgnoreInput(false); @@ -309,6 +312,5 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } } } - public void keyReleased(KeyEvent arg0) {} } } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java index 15daf70cd..c94b63494 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIListenerBase01.java @@ -317,7 +317,6 @@ public abstract class UIListenerBase01 implements GLEventListener { } } } - public void keyTyped(KeyEvent arg0) {} public void keyReleased(KeyEvent arg0) {} } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java index b3c542c63..87d4df342 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOMix2DemosES2NEWT.java @@ -152,7 +152,10 @@ public class TestFBOMix2DemosES2NEWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } System.err.println("*** "+e); if(e.getKeyChar()=='f') { new Thread() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java index 67e8524a3..f184873be 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestTranslucencyNEWT.java @@ -85,7 +85,10 @@ public class TestTranslucencyNEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java index 05cc2aeb0..34fa79b5a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestGearsES1NEWT.java @@ -84,7 +84,10 @@ public class TestGearsES1NEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java index b0e6b2b00..478195c99 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/newt/TestRedSquareES1NEWT.java @@ -82,7 +82,10 @@ public class TestRedSquareES1NEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 7f2713354..b7c4e729e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -82,7 +82,10 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } private final KeyListener keyAction = new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } System.err.println("MC "+e); int pts0 = mPlayer.getCurrentPosition(); int pts1 = 0; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java index ed308bdfd..e22b00dff 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java @@ -103,7 +103,10 @@ public class TestElektronenMultipliziererNEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index bf47109fa..f12f02c5e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -269,7 +269,10 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { quitAdapter.enable(false); new Thread() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java index 9d9e3a876..eed2e1267 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasSWT.java @@ -178,7 +178,10 @@ public class TestGearsES2NewtCanvasSWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java index 4ca70d7d3..281ee54f9 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NEWT.java @@ -80,7 +80,10 @@ public class TestLandscapeES2NEWT extends UITestCase { glWindow.addWindowListener(quitAdapter); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java index c1df18c19..72357dc29 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java @@ -117,7 +117,10 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase { }); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { quitAdapter.enable(false); new Thread() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java index 0e5842b23..b880c2f3b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java @@ -93,7 +93,10 @@ public class TestRedSquareES2NEWT extends UITestCase { glWindow.addWindowListener(quitAdapter); glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java index 93dc885b6..3c33a4899 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/newt/TestGearsNEWT.java @@ -83,7 +83,10 @@ public class TestGearsNEWT extends UITestCase { final GLWindow f_glWindow = glWindow; glWindow.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='f') { new Thread() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java index d1b276105..0f9c50baa 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestNewtCanvasSWTBug628ResizeDeadlockAWT.java @@ -308,7 +308,10 @@ public class TestNewtCanvasSWTBug628ResizeDeadlockAWT extends UITestCase { glWindow.addGLEventListener( new BigFlashingX() ) ; glWindow.addKeyListener(new KeyAdapter() { @Override - public void keyTyped(com.jogamp.newt.event.KeyEvent e) { + public void keyReleased(com.jogamp.newt.event.KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } System.err.print("."); glWindow.display(); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java index b075af977..c1b572df3 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java @@ -159,48 +159,40 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { testNewtCanvasAWT_Impl(false); } - @SuppressWarnings("deprecation") static void testKeyCodeModifier(Robot robot, NEWTKeyAdapter keyAdapter, short modifierKey, int modifierMask, short keyCode, char keyCharOnly, char keyCharMod) { keyAdapter.reset(); AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode - AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 100); // release+typed keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 100); // release keyCode robot.waitForIdle(); - for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 2; j++) { // wait until events are collected robot.delay(100); } AWTRobotUtil.newtKeyPress(0, robot, true, modifierKey, 10); // press MOD AWTRobotUtil.newtKeyPress(0, robot, true, keyCode, 10); // press keyCode - AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 10); // release+typed keyCode + AWTRobotUtil.newtKeyPress(0, robot, false, keyCode, 10); // release keyCode AWTRobotUtil.newtKeyPress(0, robot, false, modifierKey, 100); // release MOD robot.waitForIdle(); - for(int j=0; j < 100 && keyAdapter.getQueueSize() < 3+5; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 2+4; j++) { // wait until events are collected robot.delay(100); } - final int modTypedCount = KeyEvent.NULL_CHAR != keyCharMod ? 2 : -1 ; // ignore due to mods 'isPrintable' impact. NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - 3 /* press-SI */, 3 /* release-SI */, modTypedCount /* typed-SI */, - 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); + 3 /* press-SI */, 3 /* release-SI */, + 0 /* press-AR */, 0 /* release-AR */ ); final List queue = keyAdapter.getQueued(); int i=0; NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, keyCode, keyCharOnly); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, keyCode, keyCharOnly); - NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_TYPED, 0, keyCode, keyCharOnly); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, modifierKey, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, modifierMask, keyCode, keyCharMod); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, modifierMask, keyCode, keyCharMod); KeyEvent e = (KeyEvent) queue.get(i++); - if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact. - NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, modifierMask, keyCode, keyCharMod); - e = (KeyEvent) queue.get(i++); - } NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, modifierMask, modifierKey, KeyEvent.NULL_CHAR); } - @SuppressWarnings("deprecation") static void testKeyCodeAllModifierV1(Robot robot, NEWTKeyAdapter keyAdapter) { final short m1k = KeyEvent.VK_ALT; final int m1m = InputEvent.ALT_MASK; @@ -215,18 +207,18 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { AWTRobotUtil.newtKeyPress(0, robot, true, m3k, 10); // press MOD3 AWTRobotUtil.newtKeyPress(0, robot, true, KeyEvent.VK_1, 10); // press P - AWTRobotUtil.newtKeyPress(0, robot, false, KeyEvent.VK_1, 100); // release+typed P + AWTRobotUtil.newtKeyPress(0, robot, false, KeyEvent.VK_1, 100); // release P AWTRobotUtil.newtKeyPress(0, robot, false, m3k, 10); // release MOD AWTRobotUtil.newtKeyPress(0, robot, false, m2k, 10); // release MOD AWTRobotUtil.newtKeyPress(0, robot, false, m1k, 10); // release MOD robot.waitForIdle(); - for(int j=0; j < 100 && keyAdapter.getQueueSize() < 4+4+1; j++) { // wait until events are collected + for(int j=0; j < 100 && keyAdapter.getQueueSize() < 4+4; j++) { // wait until events are collected robot.delay(100); } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - 4 /* press-SI */, 4 /* release-SI */, -1 /* typed-SI - ignored, since unknow whether printable w/ all mods */, - 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); + 4 /* press-SI */, 4 /* release-SI */, + 0 /* press-AR */, 0 /* release-AR */ ); final List queue = keyAdapter.getQueued(); int i=0; @@ -237,10 +229,6 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); KeyEvent e = (KeyEvent) queue.get(i++); - if( KeyEvent.EVENT_KEY_TYPED == e.getEventType() ) { // optional, due to mods 'isPrintable' impact. - NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_TYPED, m1m|m2m|m3m, KeyEvent.VK_1, KeyEvent.NULL_CHAR); - e = (KeyEvent) queue.get(i++); - } NEWTKeyUtil.validateKeyEvent(e, KeyEvent.EVENT_KEY_RELEASED, m1m|m2m|m3m, m3k, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m|m2m, m2k, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, m1m, m1k, KeyEvent.NULL_CHAR); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java index fb42141ea..a5f47e870 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java @@ -210,9 +210,6 @@ public class TestNewtKeyCodesAWT extends UITestCase { break; } eventCount++; - if( KeyEvent.isPrintableKey(c, false) ) { - eventCount++; - } robot.waitForIdle(); } for(int j=0; j < 20 && keyAdapter.getQueueSize() < eventCount; j++) { // wait until events are collected diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index d7de4e735..f3a5c4aa9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -153,7 +153,6 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { glWindow.destroy(); } - @SuppressWarnings("deprecation") static void testKeyEventAutoRepeat(Robot robot, NEWTKeyAdapter keyAdapter, int loops, int pressDurationMS) { System.err.println("KEY Event Auto-Repeat Test: "+loops); EventObject[][] first = new EventObject[loops][3]; @@ -167,8 +166,8 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { robot.waitForIdle(); AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_A, 500); // 1s .. no AR anymore robot.waitForIdle(); - final int minCodeCount = firstIdx + 3; - final int desiredCodeCount = firstIdx + 6; + final int minCodeCount = firstIdx + 2; + final int desiredCodeCount = firstIdx + 4; for(int j=0; j < 10 && keyAdapter.getQueueSize() < desiredCodeCount; j++) { // wait until events are collected robot.delay(100); } @@ -206,15 +205,15 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { final int expSI, expAR; if( hasAR ) { expSI = perLoopSI * loops; - expAR = ( keyEvents.size() - expSI*3 ) / 2; // AR: no typed -> 2, SI: typed -> 3 + expAR = ( keyEvents.size() - expSI*2 ) / 2; // auto-repeat release } else { - expSI = keyEvents.size() / 3; // all typed events + expSI = keyEvents.size() / 2; // all released events expAR = 0; } NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - expSI /* press-SI */, expSI /* release-SI */, expSI /* typed-SI */, - expAR /* press-AR */, expAR /* release-AR */, 0 /* typed-AR */ ); + expSI /* press-SI */, expSI /* release-SI */, + expAR /* press-AR */, expAR /* release-AR */ ); } if( !hasAR ) { @@ -246,17 +245,17 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { e = (KeyEvent) last[i][0]; Assert.assertTrue("last-2 Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); - Assert.assertTrue("last-2 Shall be PRESSED, but is "+e, KeyEvent.EVENT_KEY_PRESSED == e.getEventType() ); + Assert.assertTrue("last-2 Shall be RELEASED, but is "+e, KeyEvent.EVENT_KEY_RELEASED == e.getEventType() ); Assert.assertTrue("last-2 Shall be AR, but is "+e, 0 != ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); e = (KeyEvent) last[i][1]; Assert.assertTrue("last-1 Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); - Assert.assertTrue("last-1 Shall be RELEASED, but is "+e, KeyEvent.EVENT_KEY_RELEASED == e.getEventType() ); - Assert.assertTrue("last-1 Shall not be AR, but is "+e, 0 == ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); + Assert.assertTrue("last-1 Shall be PRESSED, but is "+e, KeyEvent.EVENT_KEY_PRESSED == e.getEventType() ); + Assert.assertTrue("last-1 Shall be AR, but is "+e, 0 != ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); e = (KeyEvent) last[i][2]; Assert.assertTrue("last-0 Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); - Assert.assertTrue("last-0 Shall be TYPED, but is "+e, KeyEvent.EVENT_KEY_TYPED == e.getEventType() ); + Assert.assertTrue("last-2 Shall be RELEASED, but is "+e, KeyEvent.EVENT_KEY_RELEASED == e.getEventType() ); Assert.assertTrue("last-0 Shall not be AR, but is "+e, 0 == ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java index bdf932904..68ccecf6b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventOrderAWT.java @@ -191,8 +191,8 @@ public class TestNewtKeyEventOrderAWT extends UITestCase { final int expTotal = 6*loops; // all typed events NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - expTotal /* press-SI */, expTotal /* release-SI */, expTotal /* typed-SI */, - 0 /* press-AR */, 0 /* release-AR */, 0 /* typed-AR */ ); + expTotal /* press-SI */, expTotal /* release-SI */, + 0 /* press-AR */, 0 /* release-AR */ ); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyPressReleaseUnmaskRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyPressReleaseUnmaskRepeatAWT.java index 2a35a15eb..d70259f13 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyPressReleaseUnmaskRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyPressReleaseUnmaskRepeatAWT.java @@ -215,11 +215,6 @@ public class TestNewtKeyPressReleaseUnmaskRepeatAWT extends UITestCase { System.err.println(seq+": "+e); } } - - @Override - public void keyTyped(KeyEvent e) { - } - } public static void main(String args[]) throws IOException { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/KeyAction.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/KeyAction.java index 3313ec65c..0ae94d7af 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/KeyAction.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/KeyAction.java @@ -38,7 +38,10 @@ class KeyAction extends KeyAdapter { this.eventFifo = eventFifo; } - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } eventFifo.put(e); } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 15393e8ea..9d08d8ff4 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -47,7 +47,10 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { this.glWindow = glWindow; } - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='i') { System.err.println(glWindow); } else if(e.getKeyChar()=='d') { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java index a1f07bda6..d340fc280 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java @@ -146,7 +146,10 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { glWindow1.addGLEventListener(demo1); glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); glWindow1.addKeyListener(new KeyAdapter() { - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if(e.getKeyChar()=='c') { System.err.println("Focus Clear"); if(glWindow1.getDelegatedWindow() instanceof DriverClearFocus) { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java index 837ba5da1..776c3c7eb 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTKeyAdapter.java @@ -36,7 +36,7 @@ import java.util.List; public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEventCountAdapter { String prefix; - int keyPressed, keyReleased, keyTyped; + int keyPressed, keyReleased; boolean pressed; List queue = new ArrayList(); boolean verbose = true; @@ -53,7 +53,7 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } public synchronized int getCount() { - return keyTyped; + return keyReleased; } public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { @@ -64,10 +64,6 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent return keyReleased; } - public synchronized int getKeyTypedCount(boolean autoRepeatOnly) { - return keyTyped; - } - public synchronized List getQueued() { return queue; } @@ -77,7 +73,6 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } public synchronized void reset() { - keyTyped = 0; keyPressed = 0; keyReleased = 0; pressed = false; @@ -102,14 +97,6 @@ public class AWTKeyAdapter extends java.awt.event.KeyAdapter implements KeyEvent } } - public synchronized void keyTyped(java.awt.event.KeyEvent e) { - keyTyped++; - queue.add(e); - if( verbose ) { - System.err.println("KEY AWT TYPED ["+keyTyped+"]: "+prefix+", "+e); - } - } - - public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } + public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+"]"; } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java index 832f5ae82..1d6d97a17 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/KeyEventCountAdapter.java @@ -31,8 +31,6 @@ package com.jogamp.opengl.test.junit.util; public interface KeyEventCountAdapter extends InputEventCountAdapter { public int getKeyPressedCount(boolean autoRepeatOnly); - public int getKeyReleasedCount(boolean autoRepeatOnly); - - public int getKeyTypedCount(boolean autoRepeatOnly); + public int getKeyReleasedCount(boolean autoRepeatOnly); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java index f19169b42..88ed74a3f 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java @@ -39,8 +39,8 @@ import com.jogamp.newt.event.KeyEvent; public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { String prefix; - int keyPressed, keyReleased, keyTyped; - int keyPressedAR, keyReleasedAR, keyTypedAR; + int keyPressed, keyReleased; + int keyPressedAR, keyReleasedAR; boolean pressed; List queue = new ArrayList(); boolean verbose = true; @@ -57,7 +57,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } public synchronized int getCount() { - return keyTyped; + return keyReleased; } public synchronized int getKeyPressedCount(boolean autoRepeatOnly) { @@ -68,10 +68,6 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { return autoRepeatOnly ? keyReleasedAR: keyReleased; } - public synchronized int getKeyTypedCount(boolean autoRepeatOnly) { - return autoRepeatOnly ? keyTypedAR: keyTyped; - } - public synchronized List getQueued() { return queue; } @@ -81,10 +77,8 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } public synchronized void reset() { - keyTyped = 0; keyPressed = 0; keyReleased = 0; - keyTypedAR = 0; keyPressedAR = 0; keyReleasedAR = 0; pressed = false; @@ -115,18 +109,6 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } } - @Override - public synchronized void keyTyped(KeyEvent e) { - keyTyped++; - if( 0 != ( e.getModifiers() & InputEvent.AUTOREPEAT_MASK ) ) { - keyTypedAR++; - } - queue.add(e); - if( verbose ) { - System.err.println("KEY NEWT TYPED ["+keyTyped+"]: "+prefix+", "+e); - } - } - - public String toString() { return prefix+"[pressed "+pressed+", typed "+keyTyped+"]"; } + public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+"]"; } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java index 1def57edf..990930994 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java @@ -104,11 +104,7 @@ public class NEWTKeyUtil { missCodes.add(new CodeEvent(c, codeSeg.description, e)); misses++; } - if( KeyEvent.isPrintableKey(c, false) ) { - evtIdx += 3; // w/ TYPED - } else { - evtIdx += 2; - } + evtIdx += 2; } } final boolean res = evtIdx == keyEvents.size() && 0 == missCodes.size(); @@ -133,16 +129,13 @@ public class NEWTKeyUtil { } } - @SuppressWarnings("deprecation") public static short getNextKeyEventType(KeyEvent e) { final int et = e.getEventType(); switch( et ) { case KeyEvent.EVENT_KEY_PRESSED: return KeyEvent.EVENT_KEY_RELEASED; case KeyEvent.EVENT_KEY_RELEASED: - return e.isPrintableKey() && !e.isAutoRepeat() ? KeyEvent.EVENT_KEY_TYPED : KeyEvent.EVENT_KEY_PRESSED; - case KeyEvent.EVENT_KEY_TYPED: - return KeyEvent.EVENT_KEY_PRESSED; + return KeyEvent.EVENT_KEY_PRESSED; default: Assert.assertTrue("Invalid event "+e, false); return 0; @@ -168,14 +161,12 @@ public class NEWTKeyUtil { * @param keyAdapter * @param expPressedCountSI number of single key press events * @param expReleasedCountSI number of single key release events - * @param expTypedCountSI number of single key types events, set to -1 to ignore * @param expPressedCountAR number of auto-repeat key press events * @param expReleasedCountAR number of auto-repeat key release events - * @param expTypedCountAR number of auto-repeat key types events, set to -1 to ignore */ public static void validateKeyAdapterStats(NEWTKeyAdapter keyAdapter, - int expPressedCountSI, int expReleasedCountSI, int expTypedCountSI, - int expPressedCountAR, int expReleasedCountAR, int expTypedCountAR) { + int expPressedCountSI, int expReleasedCountSI, + int expPressedCountAR, int expReleasedCountAR) { final int expPressReleaseCountSI = expPressedCountSI + expReleasedCountSI; final int expPressReleaseCountAR = expPressedCountAR + expReleasedCountAR; final int expPressReleaseCountALL = expPressReleaseCountSI + expPressReleaseCountAR; @@ -184,36 +175,25 @@ public class NEWTKeyUtil { final int keyPressedAR = keyAdapter.getKeyPressedCount(true); final int keyReleasedALL = keyAdapter.getKeyReleasedCount(false); final int keyReleasedAR = keyAdapter.getKeyReleasedCount(true); - final int keyTypedALL = keyAdapter.getKeyTypedCount(false); - final int keyTypedAR = keyAdapter.getKeyTypedCount(true); final int keyPressedSI = keyPressedALL-keyPressedAR; final int keyReleasedSI = keyReleasedALL-keyReleasedAR; - final int keyTypedSI = keyTypedALL-keyTypedAR; final int pressReleaseCountALL = keyPressedALL + keyReleasedALL; final int pressReleaseCountSI = keyPressedSI + keyReleasedSI; final int pressReleaseCountAR = keyPressedAR + keyReleasedAR; - System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI +", Typed "+expTypedCountSI); - System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR +", Typed "+expTypedCountAR); + System.err.println("Expec Single Press "+expPressedCountSI +", Release "+expReleasedCountSI); + System.err.println("Expec AutoRp Press "+expPressedCountAR +", Release "+expReleasedCountAR); - System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Typed "+keyTypedSI +", Events "+pressReleaseCountSI); - System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Typed "+keyTypedAR +", Events "+pressReleaseCountAR); - System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Typed "+keyTypedALL+", Events "+pressReleaseCountALL); + System.err.println("Total Single Press "+keyPressedSI +", Release "+keyReleasedSI +", Events "+pressReleaseCountSI); + System.err.println("Total AutoRp Press "+keyPressedAR +", Release "+keyReleasedAR +", Events "+pressReleaseCountAR); + System.err.println("Total ALL Press "+keyPressedALL +", Release "+keyReleasedALL +", Events "+pressReleaseCountALL); Assert.assertEquals("Internal Error: pressReleaseSI != pressReleaseALL - pressReleaseAR", pressReleaseCountSI, pressReleaseCountALL - pressReleaseCountAR); - Assert.assertEquals("Invalid: Has AR Typed events", 0, keyTypedAR); - if( 0 <= expTypedCountAR ) { - Assert.assertEquals("Invalid: Exp AR Typed events", 0, expTypedCountAR); - } - Assert.assertEquals("Key press count failure (SI)", expPressedCountSI, keyPressedSI); Assert.assertEquals("Key released count failure (SI)", expReleasedCountSI, keyReleasedSI); - if( 0 <= expTypedCountSI ) { - Assert.assertEquals("Key typed count failure (SI)", expTypedCountSI, keyTypedSI); - } Assert.assertEquals("Key press count failure (AR)", expPressedCountAR, keyPressedAR); Assert.assertEquals("Key released count failure (AR)", expReleasedCountAR, keyReleasedAR); @@ -224,6 +204,6 @@ public class NEWTKeyUtil { final List keyEvents = keyAdapter.getQueued(); Assert.assertEquals("Key pressRelease count failure (ALL) w/ list sum ", expPressReleaseCountALL, pressReleaseCountALL); - Assert.assertEquals("Key total count failure (ALL) w/ list size ", pressReleaseCountALL + keyTypedALL, keyEvents.size()); + Assert.assertEquals("Key total count failure (ALL) w/ list size ", pressReleaseCountALL, keyEvents.size()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java index 59e243171..b5864e39c 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/QuitAdapter.java @@ -47,7 +47,10 @@ public class QuitAdapter extends WindowAdapter implements WindowListener, KeyLis } } - public void keyTyped(KeyEvent e) { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } if( enabled ) { if(e.getKeyChar()=='q') { System.err.println("QUIT Key "+Thread.currentThread()); @@ -56,6 +59,5 @@ public class QuitAdapter extends WindowAdapter implements WindowListener, KeyLis } } public void keyPressed(KeyEvent e) {} - public void keyReleased(KeyEvent e) {} } -- cgit v1.2.3 From c7e53e52b03afbaa6fe02a2ee5a4c5b6e5ed9f5a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Jun 2013 11:19:05 +0200 Subject: Fix TestNewtKeyEventAutoRepeatAWT (Bug 688): Reduce head/tail event check to 2 events (Windows can't produce AR) --- make/scripts/tests.sh | 4 ++-- .../newt/event/TestNewtKeyEventAutoRepeatAWT.java | 20 ++++---------------- 2 files changed, 6 insertions(+), 18 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bf8615d6e..b5fb6ccb2 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -467,11 +467,11 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index fca1a4d93..b6c15231c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -154,8 +154,8 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { static void testKeyEventAutoRepeat(Robot robot, NEWTKeyAdapter keyAdapter, int loops, int pressDurationMS) { System.err.println("KEY Event Auto-Repeat Test: "+loops); - EventObject[][] first = new EventObject[loops][3]; - EventObject[][] last = new EventObject[loops][3]; + EventObject[][] first = new EventObject[loops][2]; + EventObject[][] last = new EventObject[loops][2]; keyAdapter.reset(); int firstIdx = 0; @@ -175,11 +175,9 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { final List keyEvents = keyAdapter.getQueued(); first[i][0] = (KeyEvent) keyEvents.get(firstIdx+0); first[i][1] = (KeyEvent) keyEvents.get(firstIdx+1); - first[i][2] = (KeyEvent) keyEvents.get(firstIdx+2); - firstIdx = keyEvents.size() - 3; + firstIdx = keyEvents.size() - 2; last[i][0] = (KeyEvent) keyEvents.get(firstIdx+0); last[i][1] = (KeyEvent) keyEvents.get(firstIdx+1); - last[i][2] = (KeyEvent) keyEvents.get(firstIdx+2); System.err.println("+++ KEY Event Auto-Repeat END Input Loop: "+i); // add a pair of normal press/release in between auto-repeat! @@ -237,22 +235,12 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { Assert.assertTrue("2nd Shall be RELEASED, but is "+e, KeyEvent.EVENT_KEY_RELEASED == e.getEventType() ); Assert.assertTrue("2nd Shall be AR, but is "+e, 0 != ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); - e = (KeyEvent) first[i][2]; - Assert.assertTrue("3rd Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); - Assert.assertTrue("3rd Shall be PRESSED, but is "+e, KeyEvent.EVENT_KEY_PRESSED == e.getEventType() ); - Assert.assertTrue("3rd Shall be AR, but is "+e, 0 != ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); - e = (KeyEvent) last[i][0]; - Assert.assertTrue("last-2 Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); - Assert.assertTrue("last-2 Shall be RELEASED, but is "+e, KeyEvent.EVENT_KEY_RELEASED == e.getEventType() ); - Assert.assertTrue("last-2 Shall be AR, but is "+e, 0 != ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); - - e = (KeyEvent) last[i][1]; Assert.assertTrue("last-1 Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); Assert.assertTrue("last-1 Shall be PRESSED, but is "+e, KeyEvent.EVENT_KEY_PRESSED == e.getEventType() ); Assert.assertTrue("last-1 Shall be AR, but is "+e, 0 != ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); - e = (KeyEvent) last[i][2]; + e = (KeyEvent) last[i][1]; Assert.assertTrue("last-0 Shall be A, but is "+e, KeyEvent.VK_A == e.getKeyCode() ); Assert.assertTrue("last-2 Shall be RELEASED, but is "+e, KeyEvent.EVENT_KEY_RELEASED == e.getEventType() ); Assert.assertTrue("last-0 Shall not be AR, but is "+e, 0 == ( InputEvent.AUTOREPEAT_MASK & e.getModifiers() ) ); -- cgit v1.2.3 From 343c3b3d0204c678156ce3b1a0a667bf90541c18 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Jun 2013 12:28:09 +0200 Subject: Scripts: Adapt finding gluegen .. --- make/scripts/setenv-jogl.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh index 4067e65c9..0945f44d1 100755 --- a/make/scripts/setenv-jogl.sh +++ b/make/scripts/setenv-jogl.sh @@ -35,9 +35,9 @@ else exit fi -gpf=`find ../../gluegen/make -name dynlink-unix.cfg` +gpf=`find ../../gluegen/make -name jogamp-env.xml` if [ -z "$gpf" ] ; then - gpf=`find .. -name dynlink-unix.cfg` + gpf=`find .. -name jogamp-env.xml` fi if [ -z "$gpf" ] ; then echo GLUEGEN_BUILDDIR not found -- cgit v1.2.3 From d846b04928ecfcfb319e75d7ed114d357edbeb89 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 17 Jun 2013 13:16:40 +0200 Subject: Fix Bug 735: GLAutoDrawable must issue glViewport(..) even w/o GLEventListener ; Optimize GLDrawableHelper's glViewportCall(..) GLAutoDrawable must issue glViewport(..) even w/o GLEventListener - Same behavior w/ or w/o GLEventListener requires to issue glViewport, always. Optimize GLDrawableHelper's glViewportCall(..) - 'private void init(..)' receives 'setViewport' argument to be passed to 'private void reshape(..)' allowing to only the the viewport once @ 'public void init(..)' and display. --- make/scripts/tests.sh | 8 ++++- .../classes/jogamp/opengl/GLDrawableHelper.java | 35 +++++++++++++--------- .../opengl/test/bugs/Bug735Inv0AppletAWT.java | 2 -- .../opengl/test/bugs/Bug735Inv1AppletAWT.java | 4 +-- 4 files changed, 29 insertions(+), 20 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b5fb6ccb2..8c3b16daa 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -440,6 +440,12 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* +testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv2AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv4AWT $* + # # swt (testswt) # @@ -467,7 +473,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index ed3a1593e..8be910c1a 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -531,10 +531,10 @@ public class GLDrawableHelper { } } - private final void init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape) { + private final void init(GLEventListener l, GLAutoDrawable drawable, boolean sendReshape, boolean setViewport) { l.init(drawable); if(sendReshape) { - reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), true /* setViewport */, false /* checkInit */); + reshape(l, drawable, 0, 0, drawable.getWidth(), drawable.getHeight(), setViewport, false /* checkInit */); } } @@ -545,14 +545,20 @@ public class GLDrawableHelper { public final void init(GLAutoDrawable drawable, boolean sendReshape) { synchronized(listenersLock) { final ArrayList _listeners = listeners; - for (int i=0; i < _listeners.size(); i++) { - final GLEventListener listener = _listeners.get(i) ; - - // If make ctx current, invoked by invokGL(..), results in a new ctx, init gets called. - // This may happen not just for initial setup, but for ctx recreation due to resource change (drawable/window), - // hence it must be called unconditional, always. - listenersToBeInit.remove(listener); // remove if exist, avoiding dbl init - init( listener, drawable, sendReshape); + final int listenerCount = _listeners.size(); + if( listenerCount > 0 ) { + for (int i=0; i < listenerCount; i++) { + final GLEventListener listener = _listeners.get(i) ; + + // If make ctx current, invoked by invokGL(..), results in a new ctx, init gets called. + // This may happen not just for initial setup, but for ctx recreation due to resource change (drawable/window), + // hence it must be called unconditional, always. + listenersToBeInit.remove(listener); // remove if exist, avoiding dbl init + init( listener, drawable, sendReshape, 0==i /* setViewport */); + } + } else { + // Expose same GL initialization if not using GLEventListener + drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); } } } @@ -566,12 +572,13 @@ public class GLDrawableHelper { private final void displayImpl(GLAutoDrawable drawable) { synchronized(listenersLock) { final ArrayList _listeners = listeners; - for (int i=0; i < _listeners.size(); i++) { + final int listenerCount = _listeners.size(); + for (int i=0; i < listenerCount; i++) { final GLEventListener listener = _listeners.get(i) ; // GLEventListener may need to be init, // in case this one is added after the realization of the GLAutoDrawable if( listenersToBeInit.remove(listener) ) { - init( listener, drawable, true /* sendReshape */) ; + init( listener, drawable, true /* sendReshape */, listenersToBeInit.size() + 1 == listenerCount /* setViewport if 1st init */ ); } listener.display(drawable); } @@ -585,7 +592,7 @@ public class GLDrawableHelper { // in case this one is added after the realization of the GLAutoDrawable synchronized(listenersLock) { if( listenersToBeInit.remove(listener) ) { - init( listener, drawable, false /* sendReshape */) ; + listener.init(drawable); } } } @@ -598,7 +605,7 @@ public class GLDrawableHelper { public final void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { synchronized(listenersLock) { for (int i=0; i < listeners.size(); i++) { - reshape((GLEventListener) listeners.get(i), drawable, x, y, width, height, 0==i, true); + reshape((GLEventListener) listeners.get(i), drawable, x, y, width, height, 0==i /* setViewport */, true /* checkInit */); } } } diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java index 1f98964c6..f443459c3 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv0AppletAWT.java @@ -309,8 +309,6 @@ public class Bug735Inv0AppletAWT extends Applet implements Runnable { // Disables vsync gl.setSwapInterval(0); } - gl.glViewport(0, 0, width, height); - glu = new GLU(); vertShader = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, LandscapeES2.class, "shader", "shader/bin", "landscape", true); diff --git a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java index 2b277dba0..e8cef5e16 100644 --- a/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java +++ b/src/test/com/jogamp/opengl/test/bugs/Bug735Inv1AppletAWT.java @@ -307,9 +307,7 @@ public class Bug735Inv1AppletAWT extends Applet implements Runnable { if (60 < TARGET_FPS) { // Disables vsync gl.setSwapInterval(0); - } - gl.glViewport(0, 0, width, height); - + } glu = new GLU(); vertShader = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, LandscapeES2.class, "shader", "shader/bin", "landscape", true); -- cgit v1.2.3 From af426c53f818a8dac39e43b441dde261aa360536 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 18 Jun 2013 19:48:51 +0200 Subject: Add optional JOAL dependency, enabling JOAL usage for our 'av' package. Note: May be relocated to external project later! Assumption: gluegen/ joal/ jogl/ For OpenAL / JOAL code: - use the package jogamp.opengl.openal (like jogamp.opengl.android) - will be build _before_ the other 2nd pass java files - do not expose OpenAL/JOAL APIs, if being used by other packages, since only this package is being compiled w/ JOAL jar files! --- .classpath | 1 + make/build-common.xml | 19 ++++++++++++++ make/build-jogl.xml | 29 +++++++++++++++++++--- make/scripts/setenv-jogl.sh | 28 ++++++++++++++++++--- make/scripts/tests.sh | 11 +++++--- .../jogamp/opengl/openal/av/ALDummyUsage.java | 19 ++++++++++++++ 6 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 src/jogl/classes/jogamp/opengl/openal/av/ALDummyUsage.java (limited to 'make/scripts') diff --git a/.classpath b/.classpath index 064f05938..41f50c091 100644 --- a/.classpath +++ b/.classpath @@ -32,5 +32,6 @@ + diff --git a/make/build-common.xml b/make/build-common.xml index dd33b1683..2061d55c9 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -19,6 +19,9 @@ + + + @@ -202,6 +205,8 @@ + + @@ -414,6 +419,13 @@ + + + + + + + @@ -427,6 +439,13 @@ + + + + + + + diff --git a/make/build-jogl.xml b/make/build-jogl.xml index ce532c2b4..f53c3ba29 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -125,6 +125,9 @@ + + @@ -1025,10 +1028,28 @@ + + + + + + + + + - + diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh index 0945f44d1..b6df348dc 100755 --- a/make/scripts/setenv-jogl.sh +++ b/make/scripts/setenv-jogl.sh @@ -56,6 +56,25 @@ GLUEGEN_JAR=$GLUEGEN_BUILDDIR/gluegen-rt.jar GLUEGEN_OS=$GLUEGEN_BUILDDIR/obj JUNIT_JAR=$GLUEGEN_DIR/make/lib/junit.jar +joalpf=`find ../../joal -name joal.iml` +if [ -z "$joalpf" ] ; then + joalpf=`find .. -name joal.iml` +fi +if [ -z "$joalpf" ] ; then + echo JOAL_BUILDDIR not found + print_usage + exit +fi + +JOAL_DIR=`dirname $joalpf` +JOAL_BUILDDIR=$JOAL_DIR/$JOGL_BUILDDIR_BASE +if [ ! -e "$JOAL_BUILDDIR" ] ; then + echo JOAL_BUILDDIR $JOAL_BUILDDIR does not exist + print_usage + exit +fi +JOAL_JAR=$JOAL_BUILDDIR/joal.jar + if [ -z "$ANT_PATH" ] ; then ANT_PATH=$(dirname $(dirname $(which ant))) if [ -e $ANT_PATH/lib/ant.jar ] ; then @@ -71,6 +90,7 @@ fi ANT_JARS=$ANT_PATH/lib/ant.jar:$ANT_PATH/lib/ant-junit.jar echo GLUEGEN BUILDDIR: $GLUEGEN_BUILDDIR +echo JOAL BUILDDIR: $JOAL_BUILDDIR echo JOGL DIR: $JOGL_DIR echo JOGL BUILDDIR: $JOGL_BUILDDIR echo JOGL BUILDDIR BASE: $JOGL_BUILDDIR_BASE @@ -84,12 +104,12 @@ CP_SEP=: LIB=$THISDIR/lib -JOGAMP_ALL_AWT_CLASSPATH=.:$GLUEGEN_JAR:$JOGL_ALL_AWT_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS -JOGAMP_ALL_NOAWT_CLASSPATH=.:$GLUEGEN_JAR:$JOGL_ALL_NOAWT_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS -JOGAMP_MOBILE_CLASSPATH=.:$GLUEGEN_JAR:$JOGL_MOBILE_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS +JOGAMP_ALL_AWT_CLASSPATH=.:$GLUEGEN_JAR:$JOAL_JAR:$JOGL_ALL_AWT_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS +JOGAMP_ALL_NOAWT_CLASSPATH=.:$GLUEGEN_JAR:$JOAL_JAR:$JOGL_ALL_NOAWT_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS +JOGAMP_MOBILE_CLASSPATH=.:$GLUEGEN_JAR:$JOAL_JAR:$JOGL_MOBILE_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS export JOGAMP_ALL_AWT_CLASSPATH JOGAMP_ALL_NOAWT_CLASSPATH JOGAMP_MOBILE_CLASSPATH -CLASSPATH=.:$GLUEGEN_JAR:$JOGL_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS +CLASSPATH=.:$GLUEGEN_JAR:$JOAL_JAR:$JOGL_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS export CLASSPATH # We use TempJarCache per default now! diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8c3b16daa..33270edc6 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -288,8 +288,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* @@ -304,6 +302,13 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* +# +# av demos +# +testnoawt jogamp.opengl.openal.av.ALDummyUsage $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* + # # core/newt (testnoawt and testawt) # @@ -440,7 +445,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* -testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* +#testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv2AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv3AppletAWT $* diff --git a/src/jogl/classes/jogamp/opengl/openal/av/ALDummyUsage.java b/src/jogl/classes/jogamp/opengl/openal/av/ALDummyUsage.java new file mode 100644 index 000000000..69223d0b9 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/openal/av/ALDummyUsage.java @@ -0,0 +1,19 @@ +package jogamp.opengl.openal.av; + +import jogamp.opengl.util.av.impl.FFMPEGMediaPlayer; + +import com.jogamp.openal.AL; +import com.jogamp.openal.JoalVersion; + +/** + * Demo JOAL usage w/ av dependency, i.e. FFMPEGMediaPlayer .. + */ +public class ALDummyUsage { + static AL al; + static FFMPEGMediaPlayer.PixelFormat pfmt; + + public static void main(String args[]) { + System.err.println("JOGL> Hello JOAL"); + System.err.println("JOAL: "+JoalVersion.getInstance().toString()); + } +} -- cgit v1.2.3 From 5b77c7f345d1e36c152d70982db0e022be6cfa2a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 19 Jun 2013 04:47:26 +0200 Subject: Bug 757 (URL / URI conversion for file scheme, encoded path): Make certain core scripts capable of allowing a SPACE character. --- etc/profile.jogl | 26 ++++++++++---------- make/scripts/setenv-jogl.sh | 58 ++++++++++++++++++++++----------------------- make/scripts/tests.sh | 14 +++++------ 3 files changed, 49 insertions(+), 49 deletions(-) (limited to 'make/scripts') diff --git a/etc/profile.jogl b/etc/profile.jogl index 413c0538d..16b3a3db0 100755 --- a/etc/profile.jogl +++ b/etc/profile.jogl @@ -7,15 +7,15 @@ function print_usage() function concat_jogl_list() { - ITEMDIR=$1 + ITEMDIR="$1" shift - for j in $ITEMDIR $ITEMDIR/jar ; do + for j in "$ITEMDIR" "$ITEMDIR"/jar ; do for i in $* ; do - if [ -e $j/$i ] ; then + if [ -e "$j"/$i ] ; then if [ -z "$JOGL_LIST" ] ; then - JOGL_LIST=$j/$i + JOGL_LIST="$j"/$i else - JOGL_LIST=$JOGL_LIST:$j/$i + JOGL_LIST="$JOGL_LIST":"$j"/$i fi fi done @@ -68,23 +68,23 @@ AUTOBUILD=0 if [ ! -z "$JOGL_BUILD_DIR" -a -e "$JOGL_BUILD_DIR" ] ; then AUTOBUILD=0 -elif [ -e $THISDIR/jar ] ; then +elif [ -e "$THISDIR"/jar ] ; then # Autobuild - JOGL_BUILD_DIR=$THISDIR/jar + JOGL_BUILD_DIR="$THISDIR"/jar AUTOBUILD=1 else - echo invalid JOGL_BUILD_DIR $JOGL_BUILD_DIR and no AUTOBUILD + echo invalid JOGL_BUILD_DIR "$JOGL_BUILD_DIR" and no AUTOBUILD print_usage fi export JOGL_BUILD_DIR -JOGL_LIB_DIR=$JOGL_BUILD_DIR/lib +JOGL_LIB_DIR="$JOGL_BUILD_DIR"/lib export JOGL_LIB_DIR -JOGL_ALL_AWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL $JOGL_TEST) -JOGL_ALL_NOAWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_NOAWT $JOGL_TEST) -JOGL_MOBILE_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_ALL_MOBILE $JOGL_TEST) -JOGL_SWT_CLASSPATH=$(concat_jogl_list $JOGL_BUILD_DIR $JOGL_JAR_SWT $JOGL_TEST) +JOGL_ALL_AWT_CLASSPATH=$(concat_jogl_list "$JOGL_BUILD_DIR" $JOGL_JAR_ALL $JOGL_TEST) +JOGL_ALL_NOAWT_CLASSPATH=$(concat_jogl_list "$JOGL_BUILD_DIR" $JOGL_JAR_ALL_NOAWT $JOGL_TEST) +JOGL_MOBILE_CLASSPATH=$(concat_jogl_list "$JOGL_BUILD_DIR" $JOGL_JAR_ALL_MOBILE $JOGL_TEST) +JOGL_SWT_CLASSPATH=$(concat_jogl_list "$JOGL_BUILD_DIR" $JOGL_JAR_SWT $JOGL_TEST) export JOGL_ALL_AWT_CLASSPATH JOGL_ALL_NOAWT_CLASSPATH JOGL_MOBILE_CLASSPATH JOGL_SWT_CLASSPATH if [ ! -z "$JOGL_PROFILE" ] ; then diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh index b6df348dc..5e4bb5707 100755 --- a/make/scripts/setenv-jogl.sh +++ b/make/scripts/setenv-jogl.sh @@ -14,7 +14,7 @@ if [ -e /opt-share/etc/profile.ant ] ; then . /opt-share/etc/profile.ant fi -JOGL_BUILDDIR=$1 +JOGL_BUILDDIR="$1" shift if [ -z "$1" ] ; then @@ -27,10 +27,10 @@ fi THISDIR=`pwd` if [ -e "$JOGL_BUILDDIR" ] ; then - JOGL_DIR=$JOGL_BUILDDIR/.. - JOGL_BUILDDIR_BASE=`basename $JOGL_BUILDDIR` + JOGL_DIR="$JOGL_BUILDDIR/.." + JOGL_BUILDDIR_BASE=`basename "$JOGL_BUILDDIR"` else - echo JOGL_BUILDDIR $JOGL_BUILDDIR not exist or not given + echo JOGL_BUILDDIR "$JOGL_BUILDDIR" not exist or not given print_usage exit fi @@ -46,15 +46,15 @@ if [ -z "$gpf" ] ; then fi GLUEGEN_DIR=`dirname $gpf`/.. -GLUEGEN_BUILDDIR=$GLUEGEN_DIR/$JOGL_BUILDDIR_BASE +GLUEGEN_BUILDDIR="$GLUEGEN_DIR"/"$JOGL_BUILDDIR_BASE" if [ ! -e "$GLUEGEN_BUILDDIR" ] ; then - echo GLUEGEN_BUILDDIR $GLUEGEN_BUILDDIR does not exist + echo GLUEGEN_BUILDDIR "$GLUEGEN_BUILDDIR" does not exist print_usage exit fi -GLUEGEN_JAR=$GLUEGEN_BUILDDIR/gluegen-rt.jar -GLUEGEN_OS=$GLUEGEN_BUILDDIR/obj -JUNIT_JAR=$GLUEGEN_DIR/make/lib/junit.jar +GLUEGEN_JAR="$GLUEGEN_BUILDDIR"/gluegen-rt.jar +GLUEGEN_OS="$GLUEGEN_BUILDDIR"/obj +JUNIT_JAR="$GLUEGEN_DIR"/make/lib/junit.jar joalpf=`find ../../joal -name joal.iml` if [ -z "$joalpf" ] ; then @@ -67,13 +67,13 @@ if [ -z "$joalpf" ] ; then fi JOAL_DIR=`dirname $joalpf` -JOAL_BUILDDIR=$JOAL_DIR/$JOGL_BUILDDIR_BASE +JOAL_BUILDDIR="$JOAL_DIR"/"$JOGL_BUILDDIR_BASE" if [ ! -e "$JOAL_BUILDDIR" ] ; then - echo JOAL_BUILDDIR $JOAL_BUILDDIR does not exist + echo JOAL_BUILDDIR "$JOAL_BUILDDIR" does not exist print_usage exit fi -JOAL_JAR=$JOAL_BUILDDIR/joal.jar +JOAL_JAR="$JOAL_BUILDDIR"/joal.jar if [ -z "$ANT_PATH" ] ; then ANT_PATH=$(dirname $(dirname $(which ant))) @@ -89,37 +89,37 @@ if [ -z "$ANT_PATH" ] ; then fi ANT_JARS=$ANT_PATH/lib/ant.jar:$ANT_PATH/lib/ant-junit.jar -echo GLUEGEN BUILDDIR: $GLUEGEN_BUILDDIR -echo JOAL BUILDDIR: $JOAL_BUILDDIR -echo JOGL DIR: $JOGL_DIR -echo JOGL BUILDDIR: $JOGL_BUILDDIR -echo JOGL BUILDDIR BASE: $JOGL_BUILDDIR_BASE -echo JOGL PROFILE: $JOGL_PROFILE +echo GLUEGEN BUILDDIR: "$GLUEGEN_BUILDDIR" +echo JOAL BUILDDIR: "$JOAL_BUILDDIR" +echo JOGL DIR: "$JOGL_DIR" +echo JOGL BUILDDIR: "$JOGL_BUILDDIR" +echo JOGL BUILDDIR BASE: "$JOGL_BUILDDIR_BASE" +echo JOGL PROFILE: "$JOGL_PROFILE" J2RE_HOME=$(dirname $(dirname $(which java))) JAVA_HOME=$(dirname $(dirname $(which javac))) CP_SEP=: -. $JOGL_DIR/etc/profile.jogl $JOGL_PROFILE $JOGL_BUILDDIR +. "$JOGL_DIR"/etc/profile.jogl $JOGL_PROFILE "$JOGL_BUILDDIR" LIB=$THISDIR/lib -JOGAMP_ALL_AWT_CLASSPATH=.:$GLUEGEN_JAR:$JOAL_JAR:$JOGL_ALL_AWT_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS -JOGAMP_ALL_NOAWT_CLASSPATH=.:$GLUEGEN_JAR:$JOAL_JAR:$JOGL_ALL_NOAWT_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS -JOGAMP_MOBILE_CLASSPATH=.:$GLUEGEN_JAR:$JOAL_JAR:$JOGL_MOBILE_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS +JOGAMP_ALL_AWT_CLASSPATH=.:"$GLUEGEN_JAR":"$JOAL_JAR":"$JOGL_ALL_AWT_CLASSPATH":"$SWT_CLASSPATH":"$JUNIT_JAR":"$ANT_JARS" +JOGAMP_ALL_NOAWT_CLASSPATH=.:"$GLUEGEN_JAR":"$JOAL_JAR":"$JOGL_ALL_NOAWT_CLASSPATH":"$SWT_CLASSPATH":"$JUNIT_JAR":"$ANT_JARS" +JOGAMP_MOBILE_CLASSPATH=.:"$GLUEGEN_JAR":"$JOAL_JAR":"$JOGL_MOBILE_CLASSPATH":"$SWT_CLASSPATH":"$JUNIT_JAR":"$ANT_JARS" export JOGAMP_ALL_AWT_CLASSPATH JOGAMP_ALL_NOAWT_CLASSPATH JOGAMP_MOBILE_CLASSPATH -CLASSPATH=.:$GLUEGEN_JAR:$JOAL_JAR:$JOGL_CLASSPATH:$SWT_CLASSPATH:$JUNIT_JAR:$ANT_JARS +CLASSPATH=.:"$GLUEGEN_JAR":"$JOAL_JAR":"$JOGL_CLASSPATH":"$SWT_CLASSPATH":"$JUNIT_JAR":"$ANT_JARS" export CLASSPATH # We use TempJarCache per default now! -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR -export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$GLUEGEN_OS:$JOGL_LIB_DIR +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$GLUEGEN_OS":"$JOGL_LIB_DIR" +export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH":"$GLUEGEN_OS:"$JOGL_LIB_DIR" -echo JOGAMP_ALL_AWT_CLASSPATH: $CLASSPATH -echo JOGAMP_ALL_NOAWT_CLASSPATH: $CLASSPATH -echo JOGAMP_MOBILE_CLASSPATH: $CLASSPATH -echo CLASSPATH: $CLASSPATH +echo JOGAMP_ALL_AWT_CLASSPATH: "$JOGAMP_ALL_AWT_CLASSPATH" +echo JOGAMP_ALL_NOAWT_CLASSPATH: "$JOGAMP_ALL_NOAWT_CLASSPATH" +echo JOGAMP_MOBILE_CLASSPATH: "$JOGAMP_MOBILE_CLASSPATH" +echo CLASSPATH: "$CLASSPATH" echo echo MacOSX REMEMBER to add the JVM arguments "-XstartOnFirstThread -Djava.awt.headless=true" for running demos without AWT, e.g. NEWT echo MacOSX REMEMBER to add the JVM arguments "-XstartOnFirstThread -Djava.awt.headless=true com.jogamp.newt.util.MainThread" for running demos with NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 33270edc6..9caddac38 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -9,15 +9,15 @@ javaexe="$1" shift javaxargs=$1 shift -bdir=$1 +bdir="$1" shift if [ ! -x "$javaexe" ] ; then echo java-exe "$javaexe" is not an executable exit 1 fi -if [ ! -d $bdir ] ; then - echo build-dir $bdir is not a directory +if [ ! -d "$bdir" ] ; then + echo build-dir "$bdir" is not a directory exit 1 fi @@ -25,7 +25,7 @@ rm -f java-run.log spath=`dirname $0` -. $spath/setenv-jogl.sh $bdir JOGL_ALL +. $spath/setenv-jogl.sh "$bdir" JOGL_ALL unset CLASSPATH MOSX=0 @@ -193,7 +193,7 @@ function jrun() { #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" - #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.gluegen.UseTempJarCache=false" #D_ARGS="-Dnewt.test.EDTMainThread -Dnewt.debug.MainThread" #C_ARG="com.jogamp.newt.util.MainThread" @@ -305,7 +305,7 @@ function testawtswt() { # # av demos # -testnoawt jogamp.opengl.openal.av.ALDummyUsage $* +#testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* @@ -315,7 +315,7 @@ testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* -#testnoawt com.jogamp.newt.opengl.GLWindow $* +testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix02NOUI $* -- cgit v1.2.3 From dc6b3b50f83bf8ed114f509a3d88855f1ff9e54a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 21 Jun 2013 03:50:41 +0200 Subject: Bug 758: Fix scripts and ant build files to work w/ Java7 (default now) producing Java6 bytecode ; Apply JAR Manifest tags: Sealed, Permissions and Codebase --- make/build-jogl.xml | 9 +- make/build-nativewindow.xml | 1 + make/build-newt.xml | 1 + make/build.xml | 24 ++- make/config/jogl/glu-gl2.cfg | 3 +- make/joglversion | 2 + make/joglversion-all | 16 ++ make/nativewindowversion | 3 + make/newtversion | 3 + make/scripts/java-win.bat | 4 + make/scripts/java-win32-dbg.bat | 46 ------ make/scripts/java-win32.bat | 25 --- make/scripts/java-win64-dbg.bat | 64 -------- make/scripts/java-win64.bat | 20 --- make/scripts/make.jogl.all.android-armv6-cross.sh | 7 + make/scripts/make.jogl.all.android-armv7-cross.sh | 7 + make/scripts/make.jogl.all.linux-armv6-cross.sh | 9 +- make/scripts/make.jogl.all.linux-armv6.sh | 3 + make/scripts/make.jogl.all.linux-armv6hf-cross.sh | 7 + make/scripts/make.jogl.all.linux-armv6hf.sh | 3 + make/scripts/make.jogl.all.linux-x86.sh | 8 + make/scripts/make.jogl.all.linux-x86_64.java7.sh | 61 ++++++++ make/scripts/make.jogl.all.linux-x86_64.sh | 12 +- make/scripts/make.jogl.all.macosx-java7.sh | 3 + make/scripts/make.jogl.all.macosx-java7u12ea.sh | 25 --- make/scripts/make.jogl.all.macosx.sh | 16 +- make/scripts/make.jogl.all.solaris-x86.sh | 7 + make/scripts/make.jogl.all.solaris-x86_64.sh | 7 + make/scripts/make.jogl.all.win32.bat | 11 +- make/scripts/make.jogl.all.win64.bat | 11 +- make/scripts/tests-javaws-x64.bat | 2 +- make/scripts/tests-win.bat | 159 +++++++++++++++++++ make/scripts/tests-x32-dbg.bat | 45 ++++++ make/scripts/tests-x32.bat | 133 +++------------- make/scripts/tests-x64-dbg.bat | 63 ++++++++ make/scripts/tests-x64.bat | 179 +++------------------- make/scripts/tests.sh | 4 +- 37 files changed, 525 insertions(+), 478 deletions(-) create mode 100644 make/joglversion-all create mode 100755 make/scripts/java-win.bat delete mode 100755 make/scripts/java-win32-dbg.bat delete mode 100755 make/scripts/java-win32.bat delete mode 100755 make/scripts/java-win64-dbg.bat delete mode 100755 make/scripts/java-win64.bat create mode 100755 make/scripts/make.jogl.all.linux-x86_64.java7.sh delete mode 100755 make/scripts/make.jogl.all.macosx-java7u12ea.sh create mode 100755 make/scripts/tests-win.bat create mode 100755 make/scripts/tests-x32-dbg.bat create mode 100755 make/scripts/tests-x64-dbg.bat (limited to 'make/scripts') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index f53c3ba29..9c017ed62 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -476,7 +476,7 @@ - + - + - + - + + diff --git a/make/build-nativewindow.xml b/make/build-nativewindow.xml index 6a42d72d4..49ef78bcc 100644 --- a/make/build-nativewindow.xml +++ b/make/build-nativewindow.xml @@ -799,6 +799,7 @@ + diff --git a/make/build-newt.xml b/make/build-newt.xml index 30c2ddfd1..94a448d3d 100644 --- a/make/build-newt.xml +++ b/make/build-newt.xml @@ -745,6 +745,7 @@ + diff --git a/make/build.xml b/make/build.xml index 0c6c97d34..2eb5a8654 100644 --- a/make/build.xml +++ b/make/build.xml @@ -96,10 +96,23 @@ + + + + + + + + + + + - + @@ -111,7 +124,7 @@ - + @@ -120,7 +133,7 @@ - + @@ -129,7 +142,7 @@ - + @@ -138,7 +151,7 @@ - + @@ -246,6 +259,7 @@ + diff --git a/make/config/jogl/glu-gl2.cfg b/make/config/jogl/glu-gl2.cfg index 9387b4c4a..2dcc15a94 100644 --- a/make/config/jogl/glu-gl2.cfg +++ b/make/config/jogl/glu-gl2.cfg @@ -24,9 +24,10 @@ CustomCCode #include CustomCCode #endif EmitProcAddressTable true -ProcAddressTablePackage jogamp.opengl.glu.gl2 +ProcAddressTablePackage javax.media.opengl.glu.gl2 ProcAddressTableClassName GLUgl2ProcAddressTable GetProcAddressTableExpr getGLUProcAddressTable() +AccessControl javax.media.opengl.glu.gl2.GLUgl2ProcAddressTable PACKAGE_PRIVATE CustomCCode /* Include the OpenGL GLU header */ CustomCCode #include diff --git a/make/joglversion b/make/joglversion index 3dc57cf32..84a9836fc 100644 --- a/make/joglversion +++ b/make/joglversion @@ -12,3 +12,5 @@ Implementation-URL: http://jogamp.org/ Extension-Name: javax.media.opengl Implementation-Vendor-Id: com.jogamp Trusted-Library: true +Permissions: all-permissions +@JAR_CODEBASE_TAG@ diff --git a/make/joglversion-all b/make/joglversion-all new file mode 100644 index 000000000..84a9836fc --- /dev/null +++ b/make/joglversion-all @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Specification-Title: Java Bindings for OpenGL API Specification +Specification-Version: @BASEVERSION@ +Specification-Vendor: JogAmp Community +Implementation-Title: Java Bindings for OpenGL Runtime Environment +Implementation-Version: @VERSION@ +Implementation-Build: @BUILD_VERSION@ +Implementation-Branch: @SCM_BRANCH@ +Implementation-Commit: @SCM_COMMIT@ +Implementation-Vendor: JogAmp Community +Implementation-URL: http://jogamp.org/ +Extension-Name: javax.media.opengl +Implementation-Vendor-Id: com.jogamp +Trusted-Library: true +Permissions: all-permissions +@JAR_CODEBASE_TAG@ diff --git a/make/nativewindowversion b/make/nativewindowversion index 3eb3bc2c2..3b3308a86 100644 --- a/make/nativewindowversion +++ b/make/nativewindowversion @@ -4,6 +4,7 @@ Specification-Version: @BASEVERSION@ Specification-Vendor: JogAmp Community Implementation-Title: Native Window Interface Runtime Environment Implementation-Version: @VERSION@ +Implementation-Build: @BUILD_VERSION@ Implementation-Branch: @SCM_BRANCH@ Implementation-Commit: @SCM_COMMIT@ Implementation-Vendor: JogAmp Community @@ -11,3 +12,5 @@ Implementation-URL: http://jogamp.org/ Extension-Name: javax.media.nativewindow Implementation-Vendor-Id: com.jogamp Trusted-Library: true +Permissions: all-permissions +@JAR_CODEBASE_TAG@ diff --git a/make/newtversion b/make/newtversion index e8aa60caa..8444a492a 100644 --- a/make/newtversion +++ b/make/newtversion @@ -4,6 +4,7 @@ Specification-Version: @BASEVERSION@ Specification-Vendor: JogAmp Community Implementation-Title: NEWT Runtime Environment Implementation-Version: @VERSION@ +Implementation-Build: @BUILD_VERSION@ Implementation-Branch: @SCM_BRANCH@ Implementation-Commit: @SCM_COMMIT@ Implementation-Vendor: JogAmp Community @@ -11,3 +12,5 @@ Implementation-URL: http://jogamp.org/ Extension-Name: com.jogamp.newt Implementation-Vendor-Id: com.jogamp Trusted-Library: true +Permissions: all-permissions +@JAR_CODEBASE_TAG@ diff --git a/make/scripts/java-win.bat b/make/scripts/java-win.bat new file mode 100755 index 000000000..47b8184b2 --- /dev/null +++ b/make/scripts/java-win.bat @@ -0,0 +1,4 @@ + +%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win.log 2>&1 +tail java-win.log + diff --git a/make/scripts/java-win32-dbg.bat b/make/scripts/java-win32-dbg.bat deleted file mode 100755 index cb2108b58..000000000 --- a/make/scripts/java-win32-dbg.bat +++ /dev/null @@ -1,46 +0,0 @@ - -set BLD_SUB=build-win32 -set J2RE_HOME=c:\jre1.6.0_35_x32 -set JAVA_HOME=c:\jdk1.6.0_35_x32 -set ANT_PATH=C:\apache-ant-1.8.2 - -set PROJECT_ROOT=D:\projects\jogamp\jogl -set BLD_DIR=..\%BLD_SUB% - -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20120127;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% - -REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj -REM set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 -REM set LIB_DIR=%FFMPEG_LIB% -set LIB_DIR= - -set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar - -echo CP_ALL %CP_ALL% - -REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.FBObject" "-Djogl.enable.ANGLE" -REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" -REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" -REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" -REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" -REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" -REM set D_ARGS="-Dnewt.debug.Window" "-Dnativewindow.debug.TraceLock" -REM set D_ARGS="-Dnativewindow.debug.TraceLock" -REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" -REM set D_ARGS="-Djogl.debug=all" -REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" -REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" "-Djogl.debug=all" -REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" -REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" -set D_ARGS="-Dnewt.debug.Window.KeyEvent" -REM set D_ARGS="-Xcheck:jni" "-Xint" "-verbose:jni" - -set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" - -%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win32-dbg.log 2>&1 - diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat deleted file mode 100755 index d35715707..000000000 --- a/make/scripts/java-win32.bat +++ /dev/null @@ -1,25 +0,0 @@ - -set BLD_SUB=build-win32 -set J2RE_HOME=c:\jre1.6.0_35_x32 -set JAVA_HOME=c:\jdk1.6.0_35_x32 -set ANT_PATH=C:\apache-ant-1.8.2 - -set PROJECT_ROOT=D:\projects\jogamp\jogl -set BLD_DIR=..\%BLD_SUB% - -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20120127;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% - -set BLD_DIR=..\%BLD_SUB% -REM set LIB_DIR=..\..\gluegen\%BLD_SUB%\obj;%BLD_DIR%\lib -REM set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 -REM set LIB_DIR=%FFMPEG_LIB% -set LIB_DIR= - -set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar - -echo CP_ALL %CP_ALL% - -%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %* > java-win32.log 2>&1 diff --git a/make/scripts/java-win64-dbg.bat b/make/scripts/java-win64-dbg.bat deleted file mode 100755 index 136fe4667..000000000 --- a/make/scripts/java-win64-dbg.bat +++ /dev/null @@ -1,64 +0,0 @@ - -set BLD_SUB=build-win64 -set J2RE_HOME=c:\jre1.6.0_35_x64 -set JAVA_HOME=c:\jdk1.6.0_35_x64 -set ANT_PATH=C:\apache-ant-1.8.2 - -set PROJECT_ROOT=D:\projects\jogamp\jogl -set BLD_DIR=..\%BLD_SUB% - -set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x64 - -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% -REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj -set LIB_DIR=%FFMPEG_LIB% - -set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar - -echo CP_ALL %CP_ALL% - -REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" -REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" -REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" -REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" -REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" -REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" -REM set D_ARGS="-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLSLCode" -REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" -REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" -REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" -REM set D_ARGS="-Djogl.debug.GLDrawable" "-Dnativewindow.debug.GraphicsConfiguration" "-Djogl.debug.CapabilitiesChooser" -REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock" -REM set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" -REM set D_ARGS="-Djogl.debug=all" -REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" -REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" -REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" -REM set D_ARGS="-Dnewt.debug.Window" -REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" -REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" -REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" -REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" -REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" -REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" -REM set D_ARGS="-Djogl.debug.GLContext" "-Dnewt.debug=all" -REM set D_ARGS="-Dnewt.debug.Window" "-Dnativewindow.debug.TraceLock" -REM set D_ARGS="-Dnativewindow.debug.TraceLock" -REM set D_ARGS="-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Dnewt.debug.Window" -REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Djogl.debug.GLContext" -REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.EDT" "-Dnativewindow.debug=all" -REM set D_ARGS="-Dnewt.debug.Screen" -REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" - -REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" -REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=false" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" -REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" - -%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win64-dbg.log 2>&1 -tail java-win64-dbg.log -REM %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* diff --git a/make/scripts/java-win64.bat b/make/scripts/java-win64.bat deleted file mode 100755 index 9dc1113a7..000000000 --- a/make/scripts/java-win64.bat +++ /dev/null @@ -1,20 +0,0 @@ - -set BLD_SUB=build-win64 -set J2RE_HOME=c:\jre1.6.0_35_x64 -set JAVA_HOME=c:\jdk1.6.0_35_x64 -set ANT_PATH=C:\apache-ant-1.8.2 - -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% - -set BLD_DIR=..\%BLD_SUB% -REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj -set LIB_DIR= - -set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar -echo CP_ALL %CP_ALL% - -set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" - -%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %X_ARGS% %* > java-win64.log 2>&1 -tail java-win64.log diff --git a/make/scripts/make.jogl.all.android-armv6-cross.sh b/make/scripts/make.jogl.all.android-armv6-cross.sh index 2a7232cb8..2b8f9a30e 100755 --- a/make/scripts/make.jogl.all.android-armv6-cross.sh +++ b/make/scripts/make.jogl.all.android-armv6-cross.sh @@ -1,5 +1,9 @@ #! /bin/sh +if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +fi + export NODE_LABEL=. export HOST_UID=jogamp @@ -86,6 +90,9 @@ export GLUEGEN_CPPTASKS_FILE=`pwd`/../../gluegen/make/lib/gluegen-cpptasks-andro #export JUNIT_DISABLED="true" #export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + # BUILD_ARCHIVE=true \ ant \ -Drootrel.build=build-android-armv6 \ diff --git a/make/scripts/make.jogl.all.android-armv7-cross.sh b/make/scripts/make.jogl.all.android-armv7-cross.sh index f37abcdfd..fd7bf2010 100755 --- a/make/scripts/make.jogl.all.android-armv7-cross.sh +++ b/make/scripts/make.jogl.all.android-armv7-cross.sh @@ -1,5 +1,9 @@ #! /bin/sh +if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +fi + export NODE_LABEL=. export HOST_UID=jogamp @@ -86,6 +90,9 @@ export GLUEGEN_CPPTASKS_FILE=`pwd`/../../gluegen/make/lib/gluegen-cpptasks-andro #export JUNIT_DISABLED="true" #export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + # BUILD_ARCHIVE=true \ ant \ -Drootrel.build=build-android-armv7 \ diff --git a/make/scripts/make.jogl.all.linux-armv6-cross.sh b/make/scripts/make.jogl.all.linux-armv6-cross.sh index d3fb2783a..acfc9642e 100755 --- a/make/scripts/make.jogl.all.linux-armv6-cross.sh +++ b/make/scripts/make.jogl.all.linux-armv6-cross.sh @@ -38,6 +38,13 @@ export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv #export JUNIT_DISABLED="true" export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + ant \ -Drootrel.build=build-linux-armv6 \ \ @@ -47,5 +54,3 @@ ant \ $* 2>&1 | tee make.jogl.all.linux-armv6-cross.log - - diff --git a/make/scripts/make.jogl.all.linux-armv6.sh b/make/scripts/make.jogl.all.linux-armv6.sh index 6f1852a32..561da2336 100755 --- a/make/scripts/make.jogl.all.linux-armv6.sh +++ b/make/scripts/make.jogl.all.linux-armv6.sh @@ -17,6 +17,9 @@ export TARGET_JAVA_LIBS=/usr/lib/jvm/default-java/jre/lib/arm export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6.xml" +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + ant \ -Drootrel.build=build-linux-armv6 \ -Dsetup.addNativeKD=true \ diff --git a/make/scripts/make.jogl.all.linux-armv6hf-cross.sh b/make/scripts/make.jogl.all.linux-armv6hf-cross.sh index fd5611ea7..0592f9a25 100755 --- a/make/scripts/make.jogl.all.linux-armv6hf-cross.sh +++ b/make/scripts/make.jogl.all.linux-armv6hf-cross.sh @@ -38,6 +38,13 @@ export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv #export JUNIT_DISABLED="true" export JUNIT_RUN_ARG0="-Dnewt.test.Screen.disableScreenMode" +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + ant \ -Drootrel.build=build-linux-armv6hf \ \ diff --git a/make/scripts/make.jogl.all.linux-armv6hf.sh b/make/scripts/make.jogl.all.linux-armv6hf.sh index ae554c59b..aeaea03ed 100755 --- a/make/scripts/make.jogl.all.linux-armv6hf.sh +++ b/make/scripts/make.jogl.all.linux-armv6hf.sh @@ -17,6 +17,9 @@ export TARGET_JAVA_LIBS=/usr/lib/jvm/java-6-openjdk-armhf/jre/lib/arm export GLUEGEN_CPPTASKS_FILE="../../gluegen/make/lib/gluegen-cpptasks-linux-armv6hf.xml" +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + ant \ -Drootrel.build=build-linux-armv6hf \ -Dsetup.addNativeKD=true \ diff --git a/make/scripts/make.jogl.all.linux-x86.sh b/make/scripts/make.jogl.all.linux-x86.sh index b79fffe33..f3ae281c8 100755 --- a/make/scripts/make.jogl.all.linux-x86.sh +++ b/make/scripts/make.jogl.all.linux-x86.sh @@ -41,6 +41,14 @@ echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF # -Dgluegen-cpptasks.file=`pwd`/../../gluegen/make/lib/gluegen-cpptasks-linux-32bit.xml \ # +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + + ant \ $CUSTOMLIBDIR \ -Drootrel.build=build-x86 \ diff --git a/make/scripts/make.jogl.all.linux-x86_64.java7.sh b/make/scripts/make.jogl.all.linux-x86_64.java7.sh new file mode 100755 index 000000000..17865bd37 --- /dev/null +++ b/make/scripts/make.jogl.all.linux-x86_64.java7.sh @@ -0,0 +1,61 @@ +#! /bin/sh + +SDIR=`dirname $0` + +if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +fi + + +if [ "$1" = "-libdir" ] ; then + shift + if [ -z "$1" ] ; then + echo libdir argument missing + print_usage + exit + fi + CUSTOMLIBDIR="-Dcustom.libdir=$1" + shift +fi + +# -Dc.compiler.debug=true \ + +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxAMD64=true \ +# -DisX11=true \ +# +# -Dtarget.sourcelevel=1.6 \ +# -Dtarget.targetlevel=1.6 \ +# -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ +# +# -Dsetup.addNativeOpenMAX=true \ +# -Dsetup.addNativeKD=true \ + + +#LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64 +#export LD_LIBRARY_PATH + +LOGF=make.jogl.all.linux-x86_64.java7.log +rm -f $LOGF + +# export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri +# export LIBGL_DEBUG=verbose +echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a $LOGF +echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $LOGF +echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + +# -Dc.compiler.debug=true \ +# -Djavacdebug="true" \ +# -Djavacdebuglevel="source,lines,vars" \ + +# BUILD_ARCHIVE=true \ +ant \ + $CUSTOMLIBDIR \ + -Drootrel.build=build-x86_64.java7 \ + $* 2>&1 | tee -a $LOGF + diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh index 0bdde6831..2488a7d4c 100755 --- a/make/scripts/make.jogl.all.linux-x86_64.sh +++ b/make/scripts/make.jogl.all.linux-x86_64.sh @@ -45,16 +45,16 @@ echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a $LOGF echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $LOGF echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF -# -Dc.compiler.debug=true \ -# -Djavacdebug="true" \ -# -Djavacdebuglevel="source,lines,vars" \ +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" # BUILD_ARCHIVE=true \ ant \ $CUSTOMLIBDIR \ - -Dtarget.sourcelevel=1.6 \ - -Dtarget.targetlevel=1.6 \ - -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ -Drootrel.build=build-x86_64 \ $* 2>&1 | tee -a $LOGF diff --git a/make/scripts/make.jogl.all.macosx-java7.sh b/make/scripts/make.jogl.all.macosx-java7.sh index fc7ace9d0..ad1e7afe1 100755 --- a/make/scripts/make.jogl.all.macosx-java7.sh +++ b/make/scripts/make.jogl.all.macosx-java7.sh @@ -17,6 +17,9 @@ JAVA_HOME=`/usr/libexec/java_home -version 1.7` PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + ant \ -Dtarget.sourcelevel=1.6 \ -Dtarget.targetlevel=1.6 \ diff --git a/make/scripts/make.jogl.all.macosx-java7u12ea.sh b/make/scripts/make.jogl.all.macosx-java7u12ea.sh deleted file mode 100755 index 88f23b8ee..000000000 --- a/make/scripts/make.jogl.all.macosx-java7u12ea.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh - -if [ -e /opt-share/etc/profile.ant ] ; then - . /opt-share/etc/profile.ant -fi - - -# -Dc.compiler.debug=true \ -# -Djavacdebug="true" \ -# -Djavacdebuglevel="source,lines,vars" \ -# -# -Dtarget.sourcelevel=1.6 \ -# -Dtarget.targetlevel=1.6 \ -# -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ - -JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_12` -PATH=$JAVA_HOME/bin:$PATH -export JAVA_HOME PATH - -ant \ - -Dtarget.sourcelevel=1.6 \ - -Dtarget.targetlevel=1.6 \ - -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ - -Drootrel.build=build-macosx-java7 \ - $* 2>&1 | tee make.jogl.all.macosx-java7u12ea.log diff --git a/make/scripts/make.jogl.all.macosx.sh b/make/scripts/make.jogl.all.macosx.sh index 23a276c72..c80b41d1d 100755 --- a/make/scripts/make.jogl.all.macosx.sh +++ b/make/scripts/make.jogl.all.macosx.sh @@ -4,19 +4,23 @@ if [ -e /opt-share/etc/profile.ant ] ; then . /opt-share/etc/profile.ant fi +JAVA_HOME=`/usr/libexec/java_home -version 1.7` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + # -Dc.compiler.debug=true \ # -Djavacdebug="true" \ # -Djavacdebuglevel="source,lines,vars" \ # -# -Dtarget.sourcelevel=1.6 \ -# -Dtarget.targetlevel=1.6 \ -# -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" ant \ - -Dtarget.sourcelevel=1.6 \ - -Dtarget.targetlevel=1.6 \ - -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ -Drootrel.build=build-macosx \ $* 2>&1 | tee make.jogl.all.macosx.log diff --git a/make/scripts/make.jogl.all.solaris-x86.sh b/make/scripts/make.jogl.all.solaris-x86.sh index a5b99e47b..d1a767cdd 100755 --- a/make/scripts/make.jogl.all.solaris-x86.sh +++ b/make/scripts/make.jogl.all.solaris-x86.sh @@ -41,6 +41,13 @@ echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF # -Djavacdebug="true" \ # -Djavacdebuglevel="source,lines,vars" \ +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + # BUILD_ARCHIVE=true \ ant \ $CUSTOMLIBDIR \ diff --git a/make/scripts/make.jogl.all.solaris-x86_64.sh b/make/scripts/make.jogl.all.solaris-x86_64.sh index ff6031957..9dc492e25 100755 --- a/make/scripts/make.jogl.all.solaris-x86_64.sh +++ b/make/scripts/make.jogl.all.solaris-x86_64.sh @@ -41,6 +41,13 @@ echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF # -Djavacdebug="true" \ # -Djavacdebuglevel="source,lines,vars" \ +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + # BUILD_ARCHIVE=true \ ant \ $CUSTOMLIBDIR \ diff --git a/make/scripts/make.jogl.all.win32.bat b/make/scripts/make.jogl.all.win32.bat index c4c80a75b..7b0243f1e 100755 --- a/make/scripts/make.jogl.all.win32.bat +++ b/make/scripts/make.jogl.all.win32.bat @@ -1,7 +1,7 @@ set THISDIR="C:\JOGL" -set J2RE_HOME=c:\jre1.6.0_35_x32 -set JAVA_HOME=c:\jdk1.6.0_35_x32 +set J2RE_HOME=c:\jre1.7.0_25_x32 +set JAVA_HOME=c:\jdk1.7.0_25_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% @@ -12,4 +12,11 @@ REM -Dc.compiler.debug=true REM -Dsetup.addNativeOpenMAX=true REM -Dsetup.addNativeKD=true +set SOURCE_LEVEL=1.6 +set TARGET_LEVEL=1.6 +set TARGET_RT_JAR=c:\jre1.6.0_30\lib\rt.jar + +REM set JOGAMP_JAR_CODEBASE=Codebase: *.jogamp.org +set JOGAMP_JAR_CODEBASE=Codebase: *.goethel.localnet + ant -Drootrel.build=build-win32 %1 %2 %3 %4 %5 %6 %7 %8 %9 > make.jogl.all.win32.log 2>&1 diff --git a/make/scripts/make.jogl.all.win64.bat b/make/scripts/make.jogl.all.win64.bat index e2b3a6b80..c08c5260e 100755 --- a/make/scripts/make.jogl.all.win64.bat +++ b/make/scripts/make.jogl.all.win64.bat @@ -1,7 +1,7 @@ set THISDIR="C:\JOGL" -set J2RE_HOME=c:\jre1.6.0_35_x64 -set JAVA_HOME=c:\jdk1.6.0_35_x64 +set J2RE_HOME=c:\jre1.7.0_25_x64 +set JAVA_HOME=c:\jdk1.7.0_25_x64 set ANT_PATH=C:\apache-ant-1.8.2 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%PATH% @@ -12,4 +12,11 @@ REM -Dc.compiler.debug=true REM -Dsetup.addNativeOpenMAX=true REM -Dsetup.addNativeKD=true +set SOURCE_LEVEL=1.6 +set TARGET_LEVEL=1.6 +set TARGET_RT_JAR=c:\jre1.6.0_30\lib\rt.jar + +REM set JOGAMP_JAR_CODEBASE=Codebase: *.jogamp.org +set JOGAMP_JAR_CODEBASE=Codebase: *.goethel.localnet + ant -Dc.compiler.debug=true -Drootrel.build=build-win64 %1 %2 %3 %4 %5 %6 %7 %8 %9 > make.jogl.all.win64.log 2>&1 diff --git a/make/scripts/tests-javaws-x64.bat b/make/scripts/tests-javaws-x64.bat index deef4ca37..c14ea5ffe 100755 --- a/make/scripts/tests-javaws-x64.bat +++ b/make/scripts/tests-javaws-x64.bat @@ -1,4 +1,4 @@ -set JRE_PATH=C:\jre1.6.0_35_x64\bin +set JRE_PATH=C:\jre1.7.0_25_x64\bin set LOG_PATH=%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\log %JRE_PATH%\javaws -uninstall diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat new file mode 100755 index 000000000..bcec0c5b6 --- /dev/null +++ b/make/scripts/tests-win.bat @@ -0,0 +1,159 @@ +REM scripts\java-win.bat jogamp.newt.awt.opengl.VersionApplet +REM scripts\java-win.bat com.jogamp.newt.opengl.GLWindow +REM scripts\java-win.bat javax.media.opengl.awt.GLCanvas +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT -time 5000 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT -time 5000 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAO %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT -time 2000 + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT + +REM scripts\java-win.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT %* +REM scripts\java-win.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT %* +REM scripts\java-win.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT %* +REM scripts\java-win.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT01GLn %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT -time 5000 + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 + diff --git a/make/scripts/tests-x32-dbg.bat b/make/scripts/tests-x32-dbg.bat new file mode 100755 index 000000000..3a9a1a7c6 --- /dev/null +++ b/make/scripts/tests-x32-dbg.bat @@ -0,0 +1,45 @@ + +set BLD_SUB=build-win32 +set J2RE_HOME=c:\jre1.7.0_25_x32 +set JAVA_HOME=c:\jdk1.7.0_25_x32 +set ANT_PATH=C:\apache-ant-1.8.2 + +set PROJECT_ROOT=D:\projects\jogamp\jogl +set BLD_DIR=..\%BLD_SUB% + +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20120127;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% + +REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj +REM set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 +REM set LIB_DIR=%FFMPEG_LIB% +set LIB_DIR= + +set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar + +echo CP_ALL %CP_ALL% + +REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.FBObject" "-Djogl.enable.ANGLE" +REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" +REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" +REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" +REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnativewindow.debug.TraceLock" +REM set D_ARGS="-Dnativewindow.debug.TraceLock" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" +REM set D_ARGS="-Djogl.debug=all" +REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" +REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" "-Djogl.debug=all" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" +REM set D_ARGS="-Xcheck:jni" "-Xint" "-verbose:jni" + +set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" + +scripts\tests-win.bat diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index adc4ece39..e3de934d7 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -1,108 +1,25 @@ -REM scripts\java-win32-dbg.bat jogamp.newt.awt.opengl.VersionApplet -REM scripts\java-win32-dbg.bat com.jogamp.newt.opengl.GLWindow -REM scripts\java-win32-dbg.bat javax.media.opengl.awt.GLCanvas -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT -time 5000 -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT -time 5000 -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT %* -scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT -time 5000 -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT -time 2000 - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT -time 100000 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 - -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleAWT -time 10000 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleNEWT -time 10000 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT - -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT $* - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn %* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT01GLn $* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT -time 5000 - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT - -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02 -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 - -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* - -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT - -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBODrawableNEWT %* -REM scripts\java-win32.bat com.jogamp.opengl.test.junit.jogl.glsl.TestFBOMRTNEWT01 - -REM scripts\java-win32-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* - + +set BLD_SUB=build-win32 +set J2RE_HOME=c:\jre1.7.0_25_x32 +set JAVA_HOME=c:\jdk1.7.0_25_x32 +set ANT_PATH=C:\apache-ant-1.8.2 + +set PROJECT_ROOT=D:\projects\jogamp\jogl +set BLD_DIR=..\%BLD_SUB% + +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20120127;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% + +set BLD_DIR=..\%BLD_SUB% +REM set LIB_DIR=..\..\gluegen\%BLD_SUB%\obj;%BLD_DIR%\lib +REM set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 +REM set LIB_DIR=%FFMPEG_LIB% +set LIB_DIR= + +set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar + +echo CP_ALL %CP_ALL% + +scripts\tests-win.bat diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat new file mode 100755 index 000000000..64c3938dc --- /dev/null +++ b/make/scripts/tests-x64-dbg.bat @@ -0,0 +1,63 @@ + +set BLD_SUB=build-win64 +set J2RE_HOME=c:\jre1.7.0_25_x64 +set JAVA_HOME=c:\jdk1.7.0_25_x64 +set ANT_PATH=C:\apache-ant-1.8.2 + +set PROJECT_ROOT=D:\projects\jogamp\jogl +set BLD_DIR=..\%BLD_SUB% + +set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x64 + +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% +REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj +set LIB_DIR=%FFMPEG_LIB% + +set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar + +echo CP_ALL %CP_ALL% + +REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" +REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" +REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" +REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" +REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" +REM set D_ARGS="-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLSLCode" +REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" +REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" +REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" +REM set D_ARGS="-Djogl.debug.GLDrawable" "-Dnativewindow.debug.GraphicsConfiguration" "-Djogl.debug.CapabilitiesChooser" +REM set D_ARGS="-Djogamp.debug.JNILibLoader=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLProfile=true" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.Lock" "-Djogamp.debug.Lock.TraceLock" +REM set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" +REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" +REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" +REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" +REM set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" +REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" +REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.GLSLCode" +REM set D_ARGS="-Djogl.debug.GLContext" "-Dnewt.debug=all" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnativewindow.debug.TraceLock" +REM set D_ARGS="-Dnativewindow.debug.TraceLock" +REM set D_ARGS="-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Djogl.debug.GLContext" +REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.EDT" "-Dnativewindow.debug=all" +REM set D_ARGS="-Dnewt.debug.Screen" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" + +REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" +REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=false" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" +REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" + +scripts\tests-win.bat + diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 401e7905b..2185d187d 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -1,159 +1,20 @@ -REM scripts\java-win64-dbg.bat jogamp.newt.awt.opengl.VersionApplet -REM scripts\java-win64-dbg.bat com.jogamp.newt.opengl.GLWindow -REM scripts\java-win64-dbg.bat javax.media.opengl.awt.GLCanvas -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT -time 5000 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT -time 5000 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch11NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAO %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimAWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT %* - -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT01GLn -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWT03GLCanvasRecreate01 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT -time 2000 - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestParenting01AWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT - -REM scripts\java-win64-dbg.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT %* -REM scripts\java-win64-dbg.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT %* -REM scripts\java-win64-dbg.bat testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT %* -REM scripts\java-win64-dbg.bat testawt com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyAWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461OffscreenSupersamplingSwingAWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT - -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol03NewtAWT %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT01GLn %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWT02GLn %* -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAWT01GLn %* -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT -time 5000 - -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT - -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT -REM scripts\java-win64-dbg.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLShaderState02NEWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.ui.UINewtDemo01 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo01 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPUTextNewtDemo02 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo01 -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.graph.demos.GPURegionNewtDemo02 - -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -REM scripts\java-win64.bat com.jogamp.opengl.test.junit.jogl.glsl.TestRulerNEWT01 - + +set BLD_SUB=build-win64 +set J2RE_HOME=c:\jre1.7.0_25_x64 +set JAVA_HOME=c:\jdk1.7.0_25_x64 +set ANT_PATH=C:\apache-ant-1.8.2 + +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% + +set BLD_DIR=..\%BLD_SUB% +REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj +set LIB_DIR= + +set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar +echo CP_ALL %CP_ALL% + +set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" + +scripts\tests-win.bat + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9caddac38..8403cfe7f 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -125,7 +125,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL" - #D_ARGS="-Djogamp.debug.NativeLibrary" + D_ARGS="-Djogamp.debug.NativeLibrary" #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" @@ -193,7 +193,7 @@ function jrun() { #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" - D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.gluegen.UseTempJarCache=false" #D_ARGS="-Dnewt.test.EDTMainThread -Dnewt.debug.MainThread" #C_ARG="com.jogamp.newt.util.MainThread" -- cgit v1.2.3 From 895ba533b0db32962881e4395457ed6b0ad3b9b8 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 21 Jun 2013 04:18:45 +0200 Subject: Scripts: Fix new windows single unit test scripts .. --- make/scripts/tests-x32-dbg.bat | 2 +- make/scripts/tests-x32.bat | 2 +- make/scripts/tests-x64-dbg.bat | 3 ++- make/scripts/tests-x64.bat | 2 +- make/scripts/tests.sh | 4 ++-- 5 files changed, 7 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x32-dbg.bat b/make/scripts/tests-x32-dbg.bat index 3a9a1a7c6..e5e64511d 100755 --- a/make/scripts/tests-x32-dbg.bat +++ b/make/scripts/tests-x32-dbg.bat @@ -42,4 +42,4 @@ REM set D_ARGS="-Xcheck:jni" "-Xint" "-verbose:jni" set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" -scripts\tests-win.bat +scripts\tests-win.bat %* diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index e3de934d7..6f262eb5f 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -22,4 +22,4 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluege echo CP_ALL %CP_ALL% -scripts\tests-win.bat +scripts\tests-win.bat %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 64c3938dc..a370ebfc8 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -27,6 +27,7 @@ REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" REM set D_ARGS="-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLSLCode" +set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper" "-Djogamp.debug.NativeLibrary" "-Djogamp.debug.NativeLibrary.Lookup" "-Djogamp.debug.JNILibLoader" "-Djogamp.debug.TempJarCache" "-Djogamp.debug.JarUtil" REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" @@ -59,5 +60,5 @@ REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=false" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" -scripts\tests-win.bat +scripts\tests-win.bat %* diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 2185d187d..899c69479 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -16,5 +16,5 @@ echo CP_ALL %CP_ALL% set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" -scripts\tests-win.bat +scripts\tests-win.bat %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8403cfe7f..b44b7f8ff 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -125,7 +125,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL -Djogl.debug.TraceGL" - D_ARGS="-Djogamp.debug.NativeLibrary" + #D_ARGS="-Djogamp.debug.NativeLibrary" #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" @@ -139,7 +139,7 @@ function jrun() { #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" - #D_ARGS="-Djogl.debug.ExtensionAvailabilityCache -Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper=true -Djogamp.debug.NativeLibrary=true -Djogamp.debug.NativeLibrary.Lookup=true" + D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" -- cgit v1.2.3 From 7ae47a845c625b9677b5879831d87a14d8e57311 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 21 Jun 2013 07:38:04 +0200 Subject: GL*ProcAddressTable: Fix regressions: getField(..) -> getDeclaredField(..), incl. access check; Move getAddressFor() from ctx -> private dbg-handler (sec); FFMPEGMediaPlayer: Missed fetching func-ptr 'glTexSubImage2D'. --- make/scripts/tests.sh | 7 ++--- .../com/jogamp/gluegen/opengl/GLEmitter.java | 31 ++++++++++++++++------ src/jogl/classes/jogamp/opengl/GLContextImpl.java | 16 ----------- .../jogamp/opengl/GLDebugMessageHandler.java | 18 +++++++++++-- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 1 + 5 files changed, 44 insertions(+), 29 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b44b7f8ff..46d7876d3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -139,7 +139,8 @@ function jrun() { #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" - D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogl.debug.GLContext -Djogamp.debug.NativeLibrary -Djogamp.debug.JNILibLoader -Djogl.debug.DebugGL -Djogl.debug.GLDebugMessageHandler" #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" @@ -306,7 +307,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # @@ -315,7 +316,7 @@ function testawtswt() { #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* -testnoawt com.jogamp.newt.opengl.GLWindow $* +#testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix02NOUI $* diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java index 356482581..7c49b62d7 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLEmitter.java @@ -39,7 +39,6 @@ */ package com.jogamp.gluegen.opengl; -import com.jogamp.common.util.SecurityUtil; import com.jogamp.gluegen.ConstantDefinition; import com.jogamp.gluegen.FunctionEmitter; import com.jogamp.gluegen.GlueEmitterControls; @@ -461,7 +460,7 @@ public class GLEmitter extends ProcAddressEmitter { @Override protected void endProcAddressTable() throws Exception { PrintWriter w = tableWriter; - + w.println(" @Override"); w.println(" protected boolean isFunctionAvailableImpl(String functionNameUsr) throws IllegalArgumentException {"); w.println(" final String functionNameBase = "+GLNameResolver.class.getName()+".normalizeVEN(com.jogamp.gluegen.runtime.opengl.GLNameResolver.normalizeARB(functionNameUsr, true), true);"); @@ -470,9 +469,17 @@ public class GLEmitter extends ProcAddressEmitter { w.println(" int funcNamePermNum = "+GLNameResolver.class.getName()+".getFuncNamePermutationNumber(functionNameBase);"); w.println(" for(int i = 0; null==addressField && i < funcNamePermNum; i++) {"); w.println(" final String addressFieldName = "+GLNameResolver.class.getName()+".getFuncNamePermutation(addressFieldNameBase, i);"); - w.println(" try {"); - w.println(" addressField = getClass().getField(addressFieldName);"); - w.println(" } catch (Exception e) { }"); + w.println(" addressField = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {"); + w.println(" public java.lang.reflect.Field run() {"); + w.println(" try {"); + w.println(" final java.lang.reflect.Field addressField = "+tableClassName+".class.getDeclaredField( addressFieldName );"); + w.println(" addressField.setAccessible(true); // we need to read the protected value!"); + w.println(" return addressField;"); + w.println(" } catch (NoSuchFieldException ex) {"); + w.println(" return null;"); + w.println(" }"); + w.println(" }"); + w.println(" } );"); w.println(" }"); w.println(); w.println(" if(null==addressField) {"); @@ -502,9 +509,17 @@ public class GLEmitter extends ProcAddressEmitter { w.println(" int funcNamePermNum = "+GLNameResolver.class.getName()+".getFuncNamePermutationNumber(functionNameBase);"); w.println(" for(int i = 0; null==addressField && i < funcNamePermNum; i++) {"); w.println(" final String addressFieldName = "+GLNameResolver.class.getName()+".getFuncNamePermutation(addressFieldNameBase, i);"); - w.println(" try {"); - w.println(" addressField = getClass().getField(addressFieldName);"); - w.println(" } catch (Exception e) { }"); + w.println(" addressField = java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {"); + w.println(" public java.lang.reflect.Field run() {"); + w.println(" try {"); + w.println(" final java.lang.reflect.Field addressField = "+tableClassName+".class.getDeclaredField( addressFieldName );"); + w.println(" addressField.setAccessible(true); // we need to read the protected value!"); + w.println(" return addressField;"); + w.println(" } catch (NoSuchFieldException ex) {"); + w.println(" return null;"); + w.println(" }"); + w.println(" }"); + w.println(" } );"); w.println(" }"); w.println(); w.println(" if(null==addressField) {"); diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 4ab051028..6254b6f44 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1155,22 +1155,6 @@ public abstract class GLContextImpl extends GLContext { } ); } - /** - * Catches IllegalArgumentException and returns 0 if functionName is n/a, - * otherwise the ProcAddressTable's field value. - */ - /* pp */ final long getAddressFor(final ProcAddressTable table, final String functionName) { - return AccessController.doPrivileged(new PrivilegedAction() { - public Long run() { - try { - return Long.valueOf( table.getAddressFor(functionName) ); - } catch (IllegalArgumentException iae) { - return Long.valueOf(0); - } - } - } ).longValue(); - } - private final boolean initGLRendererAndGLVersionStrings() { final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper(); final long _glGetString = glDynLookupHelper.dynamicLookupFunction("glGetString"); diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java index 392b5db28..4c7f414ca 100644 --- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java +++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java @@ -27,6 +27,8 @@ */ package jogamp.opengl; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import javax.media.nativewindow.NativeWindowException; @@ -105,6 +107,18 @@ public class GLDebugMessageHandler { } } + private final long getAddressFor(final ProcAddressTable table, final String functionName) { + return AccessController.doPrivileged(new PrivilegedAction() { + public Long run() { + try { + return Long.valueOf( table.getAddressFor(functionName) ); + } catch (IllegalArgumentException iae) { + return Long.valueOf(0); + } + } + } ).longValue(); + } + public void init() { ctx.validateCurrent(); if( isAvailable()) { @@ -149,10 +163,10 @@ public class GLDebugMessageHandler { if( ctx.isGL4() ) { switch(extType) { case EXT_ARB: - glDebugMessageCallbackProcAddress = ctx.getAddressFor(procAddressTable, "glDebugMessageCallbackARB"); + glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallbackARB"); break; case EXT_AMD: - glDebugMessageCallbackProcAddress = ctx.getAddressFor(procAddressTable, "glDebugMessageCallbackAMD"); + glDebugMessageCallbackProcAddress = getAddressFor(procAddressTable, "glDebugMessageCallbackAMD"); break; } } else { diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 0c578f97f..a4178967c 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -202,6 +202,7 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { setTextureType(GL.GL_UNSIGNED_BYTE); final GLContextImpl ctx = (GLContextImpl)gl.getContext(); final ProcAddressTable pt = ctx.getGLProcAddressTable(); + procAddrGLTexSubImage2D = getAddressFor(pt, "glTexSubImage2D"); if( 0 == procAddrGLTexSubImage2D ) { throw new InternalError("glTexSubImage2D n/a in ProcAddressTable: "+pt.getClass().getName()+" of "+ctx.getGLVersion()); } -- cgit v1.2.3 From 2d32b056c7b1b6b3d071d79fb4c2d4e9113b59d5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Jun 2013 01:21:30 +0200 Subject: Fix Bug 761 (part 2/2): NEWT registers one customShutdownHook @ NativeWindowFactory.shutdownHook head, allowing proper resource cleanup. 1 WindowImpl.shutdownAll(): - For all instances: - mark invalid (causes any user thread to disregard the window) 2 ScreenImpl.shutdownAll(): - Removed own shutdown-hook! - For all instances: - Reset ScreenMonitorState 3 DisplayImpl.shutdownAll(): - For all instances: - Remove EDT - closeNativeImpl Manually tested on X11 w/ NV and ATI Catalyst (fglrx) - DFLAGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" - java $DFLAGS com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -time 2000 -sysExit testExit - valid arguments for sysExit: testExit, testError, displayExit, displayError --- make/scripts/tests.sh | 6 +-- src/newt/classes/com/jogamp/newt/Display.java | 2 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 45 ++++++++++++++++-- src/newt/classes/jogamp/newt/ScreenImpl.java | 45 ++++++++---------- src/newt/classes/jogamp/newt/WindowImpl.java | 53 ++++++++++++++++++++-- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 46 +++++++++++++++++++ 6 files changed, 158 insertions(+), 39 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 46d7876d3..97fe1d2c9 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -109,7 +109,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" - #D_ARGS="-Dnativewindow.debug.X11Util" + D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" @@ -286,7 +286,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -307,7 +307,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 993aa33eb..d6ddd9613 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -178,7 +178,7 @@ public abstract class Display { public abstract void dispatchMessages(); // Global Displays - protected static ArrayList displayList = new ArrayList(); + protected static final ArrayList displayList = new ArrayList(); protected static int displaysActive = 0; public static void dumpDisplayList(String prefix) { diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index d4842ba2f..3edb532db 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -45,10 +45,24 @@ import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.NativeWindowFactory; public abstract class DisplayImpl extends Display { private static int serialno = 1; + static { + NativeWindowFactory.addCustomShutdownHook(true /* head */, new Runnable() { + public void run() { + WindowImpl.shutdownAll(); + ScreenImpl.shutdownAll(); + DisplayImpl.shutdownAll(); + } + }); + } + + /** Ensure static init has been run. */ + /* pp */static void initSingleton() { } + private static Class getDisplayClass(String type) throws ClassNotFoundException { @@ -232,11 +246,10 @@ public abstract class DisplayImpl extends Display { if(DEBUG) { System.err.println("Display.destroy(): "+this+" "+getThreadName()); } - final AbstractGraphicsDevice f_aDevice = aDevice; final DisplayImpl f_dpy = this; - removeEDT( new Runnable() { + removeEDT( new Runnable() { // blocks! public void run() { - if ( null != f_aDevice ) { + if ( null != aDevice ) { f_dpy.closeNativeImpl(); } } @@ -247,6 +260,32 @@ public abstract class DisplayImpl extends Display { dumpDisplayList("Display.destroy("+getFQName()+") END"); } } + + /** Maybe utilized at a shutdown hook, impl. does not synchronize, however the EDT removal blocks. */ + /* pp */ static final void shutdownAll() { + final int dCount = displayList.size(); + if(DEBUG) { + dumpDisplayList("Display.shutdownAll "+dCount+" instances, on thread "+getThreadName()); + } + for(int i=0; i0; i++) { // be safe .. + final DisplayImpl d = (DisplayImpl) displayList.remove(0); + if(0 < displaysActive) { + displaysActive--; + } + if(DEBUG) { + System.err.println("Display.shutdownAll["+(i+1)+"/"+dCount+"]: "+d); + } + d.removeEDT( new Runnable() { + public void run() { + if ( null != d.getGraphicsDevice() ) { + d.closeNativeImpl(); + } + } + } ); + d.aDevice = null; + d.refCount=0; + } + } public synchronized final int addReference() { if(DEBUG) { diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 7edf7b63a..f63d1499e 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -34,8 +34,6 @@ package jogamp.newt; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -64,6 +62,13 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { public static final int default_sm_rate = 60; public static final int default_sm_rotation = 0; + static { + DisplayImpl.initSingleton(); + } + + /** Ensure static init has been run. */ + /* pp */static void initSingleton() { } + protected DisplayImpl display; protected int screen_idx; protected String fqname; @@ -77,15 +82,6 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { private long tCreated; // creationTime - static { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - registerShutdownHook(); - return null; - } - }); - } - private static Class getScreenClass(String type) throws ClassNotFoundException { final Class screenClass = NewtFactory.getCustomClass(type, "ScreenDriver"); @@ -660,23 +656,18 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { ScreenMonitorState.unmapScreenMonitorStateUnlocked(getFQName()); } } - private static final void shutdownAll() { - for(int i=0; i < screenList.size(); i++) { - ((ScreenImpl)screenList.get(i)).shutdown(); - } - } - private static synchronized void registerShutdownHook() { - final Thread shutdownHook = new Thread(new Runnable() { - public void run() { - ScreenImpl.shutdownAll(); - } - }); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Runtime.getRuntime().addShutdownHook(shutdownHook); - return null; + /** pp */ static final void shutdownAll() { + final int sCount = screenList.size(); + if(DEBUG) { + System.err.println("Screen.shutdownAll "+sCount+" instances, on thread "+Display.getThreadName()); + } + for(int i=0; i0; i++) { // be safe .. + final ScreenImpl s = (ScreenImpl) screenList.remove(0); + if(DEBUG) { + System.err.println("Screen.shutdownAll["+(i+1)+"/"+sCount+"]: "+s); } - }); + s.shutdown(); + } } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index dca287c6b..1ac97b07c 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -82,6 +82,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer { public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true); + protected static final ArrayList windowList = new ArrayList(); + + static { + ScreenImpl.initSingleton(); + } + + /** Maybe utilized at a shutdown hook, impl. does not synchronize, however the Window destruction and EDT removal blocks. */ + public static final void shutdownAll() { + final int wCount = windowList.size(); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.shutdownAll "+wCount+" instances, on thread "+getThreadName()); + } + for(int i=0; i0; i++) { // be safe .. + final WindowImpl w = windowList.remove(0); + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(w.getWindowHandle())); + } + w.markInvalid(); + } + } + /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms @@ -186,6 +207,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); window.instantiationFinished(); + synchronized( windowList ) { + windowList.add(window); + } return window; } catch (Throwable t) { t.printStackTrace(); @@ -207,12 +231,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl window = (WindowImpl) ReflectionUtil.createInstance( windowClass, cstrArgumentTypes, cstrArguments ) ; window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); + window.instantiationFinished(); + synchronized( windowList ) { + windowList.add(window); + } return window; } catch (Throwable t) { throw new NativeWindowException(t); } } + /** Fast invalidation of instance w/o any blocking function call. */ + private final void markInvalid() { + setWindowHandle(0); + visible = false; + fullscreen = false; + fullscreenMonitors = null; + fullscreenUseMainMonitor = true; + hasFocus = false; + parentWindowHandle = 0; + } + protected final void setGraphicsConfiguration(AbstractGraphicsConfiguration cfg) { config = cfg; } @@ -233,9 +272,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** * Notifies the receiver to preserve resources (GL, ..) - * for the next destroy*() calls (only). + * for the next destroy*() calls (only), if supported and if value is true, otherwise clears preservation flag. + * @param value true to set the one-shot preservation if supported, otherwise clears it. */ - void preserveGLStateAtDestroy(); + void preserveGLStateAtDestroy(boolean value); /** * Invoked before Window destroy action, @@ -995,13 +1035,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public void destroy() { + synchronized( windowList ) { + windowList.remove(this); + } visible = false; // Immediately mark synchronized visibility flag, avoiding possible recreation runOnEDTIfAvail(true, destroyAction); } protected void destroy(boolean preserveResources) { - if( preserveResources && null != WindowImpl.this.lifecycleHook ) { - WindowImpl.this.lifecycleHook.preserveGLStateAtDestroy(); + if( null != lifecycleHook ) { + lifecycleHook.preserveGLStateAtDestroy( preserveResources ); } destroy(); } @@ -1108,7 +1151,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Destroy this window and use parent's Screen. // It may be created properly when the parent is made visible. - destroy(false); + destroy( false ); setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } else if(newParentWindow != getParent()) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 0756399c1..a876b5c96 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -90,6 +90,8 @@ public class TestGearsES2NEWT extends UITestCase { static boolean mainRun = false; static boolean exclusiveContext = false; static boolean useAnimator = true; + static enum SysExit { none, testExit, testError, displayExit, displayError }; + static SysExit sysExit = SysExit.none; @BeforeClass public static void initClass() { @@ -272,6 +274,36 @@ public class TestGearsES2NEWT extends UITestCase { Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); } + if( SysExit.displayError == sysExit || SysExit.displayExit == sysExit ) { + glWindow.addGLEventListener(new GLEventListener() { + + @Override + public void init(GLAutoDrawable drawable) {} + + @Override + public void dispose(GLAutoDrawable drawable) { } + + @Override + public void display(GLAutoDrawable drawable) { + final GLAnimatorControl anim = drawable.getAnimator(); + if( null != anim && anim.isAnimating() ) { + if( anim.getTotalFPSDuration() >= duration/2 ) { + if( SysExit.displayError == sysExit ) { + throw new Error("test error send from GLEventListener"); + } else if ( SysExit.displayExit == sysExit ) { + System.err.println("exit(0) send from GLEventListener"); + System.exit(0); + } + } + } else { + System.exit(0); + } + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + } + glWindow.setVisible(true); if( useAnimator ) { animator.setUpdateFPSFrames(60, showFPS ? System.err : null); @@ -296,6 +328,16 @@ public class TestGearsES2NEWT extends UITestCase { while(!quitAdapter.shouldQuit() && t1-t0= duration/2 ) { + if( SysExit.testError == sysExit || SysExit.testExit == sysExit ) { + if( SysExit.testError == sysExit ) { + throw new Error("test error send from test thread"); + } else if ( SysExit.testExit == sysExit ) { + System.err.println("exit(0) send from test thread"); + System.exit(0); + } + } + } } if( useAnimator ) { @@ -429,6 +471,9 @@ public class TestGearsES2NEWT extends UITestCase { loops = MiscUtils.atoi(args[i], 1); } else if(args[i].equals("-loop-shutdown")) { loop_shutdown = true; + } else if(args[i].equals("-sysExit")) { + i++; + sysExit = SysExit.valueOf(args[i]); } } wsize = new Dimension(w, h); @@ -458,6 +503,7 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("swapInterval "+swapInterval); System.err.println("exclusiveContext "+exclusiveContext); System.err.println("useAnimator "+useAnimator); + System.err.println("sysExitWithin "+sysExit); if(waitForKey) { UITestCase.waitForKey("Start"); -- cgit v1.2.3 From 70bf3a4ec44504b86294a332255aaae8d2e86bf4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Jun 2013 18:55:21 +0200 Subject: Fix NewtCanvasAWT focus traversal for Java7: All unit tests fail w/ Java7, i.e. AWT Component's transferFocus() does nothing if component does not hold the focus. .. this seems to be violating the AWT 'spec' .. however. Workaround: Request focus before transfering it to the next/previous element. --- make/scripts/tests.sh | 9 ++++----- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 12 ++++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 97fe1d2c9..eb88ba3ab 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -109,7 +109,7 @@ function jrun() { #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" - D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" + #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.Animator" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" @@ -181,7 +181,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -286,7 +286,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -513,7 +513,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* @@ -523,7 +523,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT $* #testawtswt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04SWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 65b44b141..e5db8fd14 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -223,16 +223,24 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if(fwdKeys.contains(ks)) { if(DEBUG) { - System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()); + System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()); } // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. + if(!hasFocus()) { + // Acquire the AWT focus 1st for proper AWT traversal + NewtCanvasAWT.super.requestFocus(); + } NewtCanvasAWT.this.transferFocus(); suppress = true; } else if(bwdKeys.contains(ks)) { if(DEBUG) { - System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()); + System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()); } // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. + if(!hasFocus()) { + // Acquire the AWT focus 1st for proper AWT traversal + NewtCanvasAWT.super.requestFocus(); + } NewtCanvasAWT.this.transferFocusBackward(); suppress = true; } -- cgit v1.2.3 From cb7118fc875b6722803e4b11d5681671962a8d3a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 23 Jun 2013 20:15:38 +0200 Subject: Fix NewtCanvasAWT focus traversal for Java7 (Take 2): Commit 70bf3a4ec44504b86294a332255aaae8d2e86bf4 was not sufficient. Commit 70bf3a4ec44504b86294a332255aaae8d2e86bf4 did not work out on Windows. Solution now gathers the next or previous 'to be focused' component, using the FocusTraversalPolicy of the visible/focusable/enabled container. Then we simply request it's focus. Works w/ Java7 on Linux and Windows. --- make/scripts/tests-win.bat | 4 +-- make/scripts/tests-x64-dbg.bat | 3 +- .../classes/jogamp/nativewindow/awt/AWTMisc.java | 39 ++++++++++++++++++++++ .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 19 ++++------- 4 files changed, 50 insertions(+), 15 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index bcec0c5b6..bdef9cc10 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -55,7 +55,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedCon REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -84,7 +84,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index a370ebfc8..cb40125f2 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -27,7 +27,7 @@ REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" REM set D_ARGS="-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLSLCode" -set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper" "-Djogamp.debug.NativeLibrary" "-Djogamp.debug.NativeLibrary.Lookup" "-Djogamp.debug.JNILibLoader" "-Djogamp.debug.TempJarCache" "-Djogamp.debug.JarUtil" +REM set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper" "-Djogamp.debug.NativeLibrary" "-Djogamp.debug.NativeLibrary.Lookup" "-Djogamp.debug.JNILibLoader" "-Djogamp.debug.TempJarCache" "-Djogamp.debug.JarUtil" REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.NativeLibrary=true" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.ExtensionAvailabilityCache" "-Djogamp.debug.ProcAddressHelper=true" @@ -41,6 +41,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Dnewt.debug.Window" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index d77cd75ef..2524f107a 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -27,6 +27,7 @@ */ package jogamp.nativewindow.awt; +import java.awt.FocusTraversalPolicy; import java.awt.Window; import java.awt.Component; import java.awt.Container; @@ -68,6 +69,44 @@ public class AWTMisc { return (Container) c; } + public static Component getNextFocus(Component comp) { + Container focusContainer = comp.getFocusCycleRootAncestor(); + while ( focusContainer != null && + ( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) ) + { + comp = focusContainer; + focusContainer = comp.getFocusCycleRootAncestor(); + } + Component next = null; + if (focusContainer != null) { + final FocusTraversalPolicy policy = focusContainer.getFocusTraversalPolicy(); + next = policy.getComponentAfter(focusContainer, comp); + if (next == null) { + next = policy.getDefaultComponent(focusContainer); + } + } + return next; + } + + public static Component getPrevFocus(Component comp) { + Container focusContainer = comp.getFocusCycleRootAncestor(); + while ( focusContainer != null && + ( !focusContainer.isShowing() || !focusContainer.isFocusable() || !focusContainer.isEnabled() ) ) + { + comp = focusContainer; + focusContainer = comp.getFocusCycleRootAncestor(); + } + Component prev = null; + if (focusContainer != null) { + final FocusTraversalPolicy policy = focusContainer.getFocusTraversalPolicy(); + prev = policy.getComponentBefore(focusContainer, comp); + if (prev == null) { + prev = policy.getDefaultComponent(focusContainer); + } + } + return prev; + } + /** * Issue this when your non AWT toolkit gains focus to clear AWT menu path */ diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index e5db8fd14..dd8939e43 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -31,6 +31,7 @@ package com.jogamp.newt.awt; import java.awt.AWTKeyStroke; import java.awt.Canvas; +import java.awt.Component; import java.awt.Graphics; import java.awt.GraphicsConfiguration; import java.awt.KeyboardFocusManager; @@ -222,26 +223,20 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final Set fwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); final Set bwdKeys = keyboardFocusManager.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); if(fwdKeys.contains(ks)) { + final Component nextFocus = AWTMisc.getNextFocus(NewtCanvasAWT.this); if(DEBUG) { - System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()); + System.err.println("NewtCanvasAWT.focusKey (fwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()+", nextFocus "+nextFocus); } // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. - if(!hasFocus()) { - // Acquire the AWT focus 1st for proper AWT traversal - NewtCanvasAWT.super.requestFocus(); - } - NewtCanvasAWT.this.transferFocus(); + nextFocus.requestFocus(); suppress = true; } else if(bwdKeys.contains(ks)) { + final Component prevFocus = AWTMisc.getPrevFocus(NewtCanvasAWT.this); if(DEBUG) { - System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()); + System.err.println("NewtCanvasAWT.focusKey (bwd): "+ks+", current focusOwner "+keyboardFocusManager.getFocusOwner()+", hasFocus: "+hasFocus()+", prevFocus "+prevFocus); } // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. - if(!hasFocus()) { - // Acquire the AWT focus 1st for proper AWT traversal - NewtCanvasAWT.super.requestFocus(); - } - NewtCanvasAWT.this.transferFocusBackward(); + prevFocus.requestFocus(); suppress = true; } } -- cgit v1.2.3 From f857d3f86be221fb5f8488a8419c4cac8d65fc89 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Jun 2013 09:48:11 +0200 Subject: scripts: osx make/test java7/6 fixes --- make/scripts/make.jogl.all.macosx-java7.sh | 6 ------ make/scripts/tests-osx-x64-java6.sh | 12 ++++++++++++ make/scripts/tests-osx-x64-java7.sh | 12 ------------ make/scripts/tests-osx-x64-java7OnJava6build.sh | 12 ------------ make/scripts/tests-osx-x64-java7u12ea.sh | 12 ------------ make/scripts/tests-osx-x64-java7u12eaOnJava6Build.sh | 12 ------------ make/scripts/tests-osx-x64.sh | 4 ++-- 7 files changed, 14 insertions(+), 56 deletions(-) create mode 100755 make/scripts/tests-osx-x64-java6.sh delete mode 100755 make/scripts/tests-osx-x64-java7.sh delete mode 100755 make/scripts/tests-osx-x64-java7OnJava6build.sh delete mode 100755 make/scripts/tests-osx-x64-java7u12ea.sh delete mode 100755 make/scripts/tests-osx-x64-java7u12eaOnJava6Build.sh (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.macosx-java7.sh b/make/scripts/make.jogl.all.macosx-java7.sh index ad1e7afe1..ee82bbc91 100755 --- a/make/scripts/make.jogl.all.macosx-java7.sh +++ b/make/scripts/make.jogl.all.macosx-java7.sh @@ -9,9 +9,6 @@ fi # -Djavacdebug="true" \ # -Djavacdebuglevel="source,lines,vars" \ # -# -Dtarget.sourcelevel=1.6 \ -# -Dtarget.targetlevel=1.6 \ -# -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ JAVA_HOME=`/usr/libexec/java_home -version 1.7` PATH=$JAVA_HOME/bin:$PATH @@ -21,8 +18,5 @@ export JAVA_HOME PATH export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" ant \ - -Dtarget.sourcelevel=1.6 \ - -Dtarget.targetlevel=1.6 \ - -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ -Drootrel.build=build-macosx-java7 \ $* 2>&1 | tee make.jogl.all.macosx-java7.log diff --git a/make/scripts/tests-osx-x64-java6.sh b/make/scripts/tests-osx-x64-java6.sh new file mode 100755 index 000000000..fe2d2c4ec --- /dev/null +++ b/make/scripts/tests-osx-x64-java6.sh @@ -0,0 +1,12 @@ +#! /bin/bash + +export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH + +JAVA_HOME=`/usr/libexec/java_home -version 1.6` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + +spath=`dirname $0` + +. $spath/tests.sh /usr/bin/java -d64 ../build-macosx $* + diff --git a/make/scripts/tests-osx-x64-java7.sh b/make/scripts/tests-osx-x64-java7.sh deleted file mode 100755 index e870d0752..000000000 --- a/make/scripts/tests-osx-x64-java7.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash - -export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH - -JAVA_HOME=`/usr/libexec/java_home -version 1.7` -PATH=$JAVA_HOME/bin:$PATH -export JAVA_HOME PATH - -spath=`dirname $0` - -. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx-java7 $* - diff --git a/make/scripts/tests-osx-x64-java7OnJava6build.sh b/make/scripts/tests-osx-x64-java7OnJava6build.sh deleted file mode 100755 index e1b07202b..000000000 --- a/make/scripts/tests-osx-x64-java7OnJava6build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash - -export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH - -JAVA_HOME=`/usr/libexec/java_home -version 1.7` -PATH=$JAVA_HOME/bin:$PATH -export JAVA_HOME PATH - -spath=`dirname $0` - -. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* - diff --git a/make/scripts/tests-osx-x64-java7u12ea.sh b/make/scripts/tests-osx-x64-java7u12ea.sh deleted file mode 100755 index a8c9bed77..000000000 --- a/make/scripts/tests-osx-x64-java7u12ea.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash - -export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH - -JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_12` -PATH=$JAVA_HOME/bin:$PATH -export JAVA_HOME PATH - -spath=`dirname $0` - -. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx-java7 $* - diff --git a/make/scripts/tests-osx-x64-java7u12eaOnJava6Build.sh b/make/scripts/tests-osx-x64-java7u12eaOnJava6Build.sh deleted file mode 100755 index dad9c430e..000000000 --- a/make/scripts/tests-osx-x64-java7u12eaOnJava6Build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/bash - -export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH - -JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_12` -PATH=$JAVA_HOME/bin:$PATH -export JAVA_HOME PATH - -spath=`dirname $0` - -. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* - diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh index fe2d2c4ec..e1b07202b 100755 --- a/make/scripts/tests-osx-x64.sh +++ b/make/scripts/tests-osx-x64.sh @@ -2,11 +2,11 @@ export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH -JAVA_HOME=`/usr/libexec/java_home -version 1.6` +JAVA_HOME=`/usr/libexec/java_home -version 1.7` PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH spath=`dirname $0` -. $spath/tests.sh /usr/bin/java -d64 ../build-macosx $* +. $spath/tests.sh $JAVA_HOME/bin/java -d64 ../build-macosx $* -- cgit v1.2.3 From 835cea627f80d8f8a851514734f53e6336d9d6d9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Jun 2013 09:48:56 +0200 Subject: TestSWTAccessor03AWTGLn: Fix SWT deadlock on Java7/Windows: Must perform AWT frame close on current thread .. --- make/scripts/tests-win.bat | 12 ++++++++---- make/scripts/tests.sh | 6 +++--- .../opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java | 8 ++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index bdef9cc10..dfe7b2887 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -59,7 +59,8 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 @@ -77,14 +78,16 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCode REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* @@ -92,11 +95,12 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index eb88ba3ab..defb61e50 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -181,7 +181,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" - D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -465,7 +465,7 @@ function testawtswt() { # with OSX: -XstartOnFirstThread # #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* -#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* +testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlockAWT $* @@ -513,7 +513,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java index 5803a1675..ee5dc7fea 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestSWTAccessor03AWTGLn.java @@ -120,14 +120,18 @@ public class TestSWTAccessor03AWTGLn extends UITestCase { Assert.assertNotNull( shell ); Assert.assertNotNull( composite ); Assert.assertNotNull( glcanvas ); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + final Runnable releaseAWT = new Runnable() { public void run() { + // deadlocks Java7 on Windows frame.setVisible(false); frame.remove(glcanvas); frame.dispose(); frame = null; glcanvas = null; - }}); + } }; + // Deadlocks Java7 on Windows + // javax.swing.SwingUtilities.invokeAndWait( releaseAWT ); + releaseAWT.run(); SWTAccessor.invoke(true, new Runnable() { public void run() { -- cgit v1.2.3 From 8f3b2a4cc14be60681a7bfae0507655cc5702836 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Jun 2013 15:50:27 +0200 Subject: Workaroung a Java7 AWT EDT/Robot bug: Validate whether AWT-EDT is alive before certain robot ops. We have experienced that w/o utilizing AWT components, i.e. NEWT tests, the AWT-EDT 'sometimes' dies. Performing AWT robot's waitForIdle() in this situation causes a deadlock, since the call will never complete it's EventQueue.invokeAndWait() call. While analyzing this issue, we created a test tool whether the the AWT EDT is still alive. This test issues EventQueue.invokeLater( .. { flag=true; } ); and polls up until 2s for the result. Turns out that the sporadic AWT-EDT issues are solved by this test itself, i.e. it probably cause it to be reinstated. (?!) We have to observe this behavior. Another proof that quantum mechanic rules also apply in the macro cosmos :) --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- .../junit/newt/event/BaseNewtEventModifiers.java | 9 +++- .../opengl/test/junit/util/AWTRobotUtil.java | 53 +++++++++++++++++++++- 4 files changed, 63 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index dfe7b2887..f8cecf46b 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -72,7 +72,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* @@ -95,7 +95,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index defb61e50..247cf9d2d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -465,7 +465,7 @@ function testawtswt() { # with OSX: -XstartOnFirstThread # #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* -testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* +#testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* #testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlockAWT $* @@ -479,7 +479,7 @@ testawtswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 3a2c4cc81..e6edd0da5 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -39,6 +39,7 @@ import org.junit.Test ; import com.jogamp.common.util.RunnableTask; import com.jogamp.newt.event.MouseEvent; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase ; /** @@ -519,7 +520,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { private void _doHoldOneButtonAndPressAnother( final int keyCode, final int keyModifierMask ) throws Exception { if( _debug ) { _debugPrintStream.println( "\n>>>> _doHoldOneButtonAndPressAnother" ) ; } - + _doKeyPress( keyCode ) ; for (int n = 0 ; n < _numButtonsToTest ; ++n) { @@ -561,7 +562,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { private void _doPressAllButtonsInSequence( final int keyCode, final int keyModifierMask ) throws Exception { if( _debug ) { _debugPrintStream.println( "\n>>>> _doPressAllButtonsInSequence" ) ; } - + _doKeyPress( keyCode ) ; { @@ -634,6 +635,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// private void _doKeyPress( int keyCode ) { + AWTRobotUtil.validateAWTEDTIsAlive(); if( keyCode != 0 ) { boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; _testMouseListener.setModifierCheckEnabled( false ) ; @@ -646,6 +648,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// private void _doKeyRelease( int keyCode ) { + AWTRobotUtil.validateAWTEDTIsAlive(); if( keyCode != 0 ) { boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; _testMouseListener.setModifierCheckEnabled( false ) ; @@ -697,6 +700,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { private void _releaseModifiers() { if (_robot != null) { + AWTRobotUtil.validateAWTEDTIsAlive(); _robot.setAutoDelay( MS_ROBOT_AUTO_DELAY ) ; @@ -721,6 +725,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { private void _escape() { if (_robot != null) { + AWTRobotUtil.validateAWTEDTIsAlive(); _robot.keyPress( java.awt.event.KeyEvent.VK_ESCAPE ) ; _robot.keyRelease( java.awt.event.KeyEvent.VK_ESCAPE ) ; } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index b5f8def3c..8a73d3363 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -31,8 +31,10 @@ package com.jogamp.opengl.test.junit.util; import jogamp.newt.WindowImplAccess; import jogamp.newt.awt.event.AWTNewtEventFactory; +import java.lang.Thread.UncaughtExceptionHandler; import java.lang.reflect.InvocationTargetException; import java.awt.AWTException; +import java.awt.EventQueue; import java.awt.Robot; import javax.media.nativewindow.NativeWindow; @@ -56,6 +58,50 @@ public class AWTRobotUtil { public static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ; public static Integer AWT_CLICK_TO = null; + static Object awtEDTAliveSync = new Object(); + static volatile boolean awtEDTAliveFlag = false; + + static class OurUncaughtExceptionHandler implements UncaughtExceptionHandler { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.err.println("*** AWTRobotUtil: UncaughtException (this Thread "+Thread.currentThread().getName()+") : Thread <"+t.getName()+">, "+e.getClass().getName()+": "+e.getMessage()); + e.printStackTrace(); + } + } + + static { + Thread.setDefaultUncaughtExceptionHandler( new OurUncaughtExceptionHandler() ); + // System.err.println("AWT EDT alive: "+isAWTEDTAlive()); + } + + public static boolean isAWTEDTAlive() { + if( EventQueue.isDispatchThread() ) { + return true; + } + synchronized ( awtEDTAliveSync ) { + awtEDTAliveFlag = false; + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + awtEDTAliveFlag = true; + } + }); + for (int wait=0; wait Date: Mon, 24 Jun 2013 19:30:06 +0200 Subject: TestFocus0[12]SwingAWTRobot: Fix Java7 'changed behavior': Relax focus traversal validation checks. - Remove Frame lost detection - Allow to have NEWT and it's NewtCanvasAWT claiming to have the focus --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- .../opengl/test/junit/newt/TestFocus01SwingAWTRobot.java | 13 ++++++++----- .../opengl/test/junit/newt/TestFocus02SwingAWTRobot.java | 16 ++++++++-------- 4 files changed, 20 insertions(+), 17 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index f8cecf46b..954d1663d 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -72,7 +72,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* @@ -106,7 +106,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 247cf9d2d..70139b6c1 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -476,10 +476,10 @@ function testawtswt() { # #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug -#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* +testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java index 672a44154..78be14dc6 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java @@ -127,8 +127,6 @@ public class TestFocus01SwingAWTRobot extends UITestCase { // Add the canvas to a frame, and make it all visible. final JFrame frame1 = new JFrame("Swing AWT Parent Frame: " + glWindow1.getTitle()); - AWTFocusAdapter frame1FA = new AWTFocusAdapter("frame1"); - frame1.addFocusListener(frame1FA); frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); final Button button = new Button("Click me .."); AWTFocusAdapter buttonFA = new AWTFocusAdapter("Button"); @@ -168,7 +166,7 @@ public class TestFocus01SwingAWTRobot extends UITestCase { System.err.println("FOCUS AWT Button request"); EventCountAdapterUtil.reset(eventCountAdapters); - AWTRobotUtil.assertRequestFocusAndWait(robot, button, button, buttonFA, frame1FA); // OSX sporadically button did not gain - major UI failure + AWTRobotUtil.assertRequestFocusAndWait(robot, button, button, buttonFA, null); // OSX sporadically button did not gain - major UI failure Assert.assertEquals(false, glWindow1FA.focusGained()); Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); System.err.println("FOCUS AWT Button sync"); @@ -183,8 +181,13 @@ public class TestFocus01SwingAWTRobot extends UITestCase { System.err.println("FOCUS NEWT Canvas/GLWindow request"); EventCountAdapterUtil.reset(eventCountAdapters); AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonFA); // OSX sporadically button did not loose - minor UI failure - Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA, - AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA)); + // Manually tested on Java7/[Linux,Windows] (where this assertion failed), + // Should be OK to have the AWT component assume it also has the focus. + // Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA, + // AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA)); + if( !AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA) ) { + System.err.println("Info: Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA); + } System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java index 5d0a0fbb5..a1f4221db 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java @@ -157,8 +157,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase { jPanel1.add(container1, BorderLayout.CENTER); final JFrame jFrame1 = new JFrame("Swing Parent JFrame"); - AWTFocusAdapter jFrame1FA = new AWTFocusAdapter("JFrame1"); - jFrame1.addFocusListener(jFrame1FA); // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! jFrame1.setContentPane(jPanel1); @@ -188,7 +186,7 @@ public class TestFocus02SwingAWTRobot extends UITestCase { Thread.sleep(100); // allow event sync System.err.println("FOCUS AWT Button Outer request"); EventCountAdapterUtil.reset(eventCountAdapters); - AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthOuter, buttonNorthOuter, buttonNorthOuterFA, jFrame1FA); // OSX sporadically buttonNorthOuter did not gain - major UI failure + AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthOuter, buttonNorthOuter, buttonNorthOuterFA, null); // OSX sporadically buttonNorthOuter did not gain - major UI failure Assert.assertEquals(false, glWindow1FA.focusGained()); Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); Assert.assertEquals(false, buttonNorthInnerFA.focusGained()); @@ -206,7 +204,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase { AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthOuterFA); Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); Assert.assertEquals(false, buttonNorthInnerFA.focusGained()); - Assert.assertEquals(false, jFrame1FA.focusGained()); System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); @@ -223,7 +220,6 @@ public class TestFocus02SwingAWTRobot extends UITestCase { AWTRobotUtil.assertRequestFocusAndWait(robot, buttonNorthInner, buttonNorthInner, buttonNorthInnerFA, glWindow1FA); Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); Assert.assertEquals(false, buttonNorthOuterFA.focusGained()); - Assert.assertEquals(false, jFrame1FA.focusGained()); System.err.println("FOCUS AWT Button sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, buttonNorthInner, buttonNorthInnerKA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, @@ -236,12 +232,16 @@ public class TestFocus02SwingAWTRobot extends UITestCase { System.err.println("FOCUS NEWT Canvas/GLWindow request"); EventCountAdapterUtil.reset(eventCountAdapters); AWTRobotUtil.assertRequestFocusAndWait(robot, newtCanvasAWT, newtCanvasAWT.getNEWTChild(), glWindow1FA, buttonNorthInnerFA); - Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA, - AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA)); + // Manually tested on Java7/[Linux,Windows] (where this assertion failed), + // Should be OK to have the AWT component assume it also has the focus. + // Assert.assertTrue("Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA, + // AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA)); + if( !AWTRobotUtil.waitForFocus(glWindow1FA, newtCanvasAWTFA) ) { + System.err.println("Info: Focus prev. gained, but NewtCanvasAWT didn't loose it. Gainer: "+glWindow1FA+"; Looser "+newtCanvasAWTFA); + } Assert.assertEquals(false, newtCanvasAWTFA.focusGained()); Assert.assertEquals(false, buttonNorthOuterFA.focusGained()); - Assert.assertEquals(false, jFrame1FA.focusGained()); System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); -- cgit v1.2.3 From 415f5c29ffae7cf5a26737da38e31cb84b652539 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 24 Jun 2013 19:47:06 +0200 Subject: NEWT: Don't invoke external keyboardFocusHandler for auto-repeat keys (NewtCanvasAWT, ..) .. otherwise an auto repeated key would cause fast focus traversal, not intended. --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/newt/classes/com/jogamp/newt/Window.java | 6 +++++- src/newt/classes/jogamp/newt/WindowImpl.java | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 954d1663d..ed0241035 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -87,7 +87,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* @@ -106,7 +106,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 70139b6c1..c50877d78 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -476,7 +476,7 @@ function testawtswt() { # #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug -testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* @@ -513,7 +513,7 @@ testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* # #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 0bebf330a..f63c03738 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -406,7 +406,11 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * Sets a {@link KeyListener} allowing focus traversal with a covered window toolkit like AWT. *

    * The {@link KeyListener} methods are invoked prior to all other {@link KeyListener}'s - * allowing to suppress the {@link KeyEvent} via the {@link InputEvent#consumedTag}. + * allowing to suppress the {@link KeyEvent} via the {@link InputEvent#consumedTag} + * and to perform focus traversal with a 3rd party toolkit. + *

    + *

    + * The {@link KeyListener} methods are not invoked for {@link KeyEvent#isAutoRepeat() auto-repeat} events. *

    * @param l */ diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 1ac97b07c..6787f0ab3 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2535,15 +2535,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected void consumeKeyEvent(KeyEvent e) { boolean consumedE = false; - if(null != keyboardFocusHandler) { + if( null != keyboardFocusHandler && !e.isAutoRepeat() ) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); if(DEBUG_KEY_EVENT) { - System.err.println("consumeKeyEvent: "+e+", keyboardFocusHandler consumed: "+consumedE); + System.err.println("consumeKeyEvent(kfh): "+e+", keyboardFocusHandler consumed: "+consumedE); } } if(DEBUG_KEY_EVENT) { if( !consumedE ) { - System.err.println("consumeKeyEvent: "+e); + System.err.println("consumeKeyEvent(usr): "+e); } } for(int i = 0; !consumedE && i < keyListeners.size(); i++ ) { -- cgit v1.2.3 From 7761702147a955807d56951b95ca03d0fedf6b7e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Jun 2013 16:35:52 +0200 Subject: Disable TestNewtEventModifiersNewtCanvasSWTAWT: Causes sporadic freezes on Window/Linux .. --- make/scripts/tests.sh | 4 ++-- .../junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c50877d78..c0ab5f41c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -486,7 +486,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* -#testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* +testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* @@ -513,7 +513,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java index 86e336e53..349d200d7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtEventModifiersNewtCanvasSWTAWT.java @@ -92,6 +92,10 @@ public class TestNewtEventModifiersNewtCanvasSWTAWT extends BaseNewtEventModifie @BeforeClass public static void beforeClass() throws Exception { + // FIXME: Hangs .. w/ Java7 .. every now and then! + setTestSupported(false); + + /*** SWTAccessor.invoke(true, new Runnable() { public void run() { _display = new Display(); @@ -135,12 +139,14 @@ public class TestNewtEventModifiersNewtCanvasSWTAWT extends BaseNewtEventModifie eventDispatchImpl(); _glWindow.addMouseListener( _testMouseListener ) ; + */ } //////////////////////////////////////////////////////////////////////////// @AfterClass public static void afterClass() throws Exception { + /** _glWindow.destroy() ; try { @@ -160,7 +166,7 @@ public class TestNewtEventModifiersNewtCanvasSWTAWT extends BaseNewtEventModifie catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } */ } //////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From cb6855409590a7229b5191017caad201c271b05c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 29 Jun 2013 11:35:27 +0200 Subject: Tests: Fix enumeration of monitor/screen mode tests, add tests description to class header. --- make/scripts/tests-win.bat | 14 +- make/scripts/tests.sh | 18 +- .../test/junit/newt/ManualScreenMode03NEWT.java | 114 ------ .../test/junit/newt/ManualScreenMode03aNEWT.java | 114 ++++++ .../test/junit/newt/TestScreenMode00NEWT.java | 179 ---------- .../test/junit/newt/TestScreenMode00aNEWT.java | 179 ++++++++++ .../test/junit/newt/TestScreenMode01NEWT.java | 392 --------------------- .../test/junit/newt/TestScreenMode01dNEWT.java | 392 +++++++++++++++++++++ .../test/junit/newt/TestScreenMode02NEWT.java | 197 ----------- .../test/junit/newt/TestScreenMode02aNEWT.java | 197 +++++++++++ 10 files changed, 900 insertions(+), 896 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00aNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01dNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index ed0241035..0b5f13661 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -61,6 +61,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 @@ -87,7 +90,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* @@ -110,13 +113,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRo REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00aNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01dNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02sNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03sNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c0ab5f41c..8cf4fb406 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -175,7 +175,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -400,14 +400,14 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01dNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* @@ -486,7 +486,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* -testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* +#testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* @@ -585,7 +585,7 @@ testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCan #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* # test rotation change -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02aNEWT # # regressions diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java deleted file mode 100644 index 875e4fe86..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03NEWT.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; - -import com.jogamp.opengl.util.Animator; - -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Screen; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.MonitorModeUtil; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.UITestCase; -import java.util.List; -import javax.media.nativewindow.util.Dimension; - -/** - * Manual testing the ScreenImpl shutdown hook, - * which shall reset the ScreenMode to it's original state - * when the application exists (normal or ctrl-c). - */ -public class ManualScreenMode03NEWT extends UITestCase { - static int waitTime = 7000; // 1 sec - - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { - caps.setOnscreen(onscreen); - - GLWindow window = GLWindow.create(screen, caps); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - window.setVisible(true); - return window; - } - - public void run() { - int width = 640; - int height = 480; - GLProfile glp = GLProfile.getDefault(); - GLCapabilities caps = new GLCapabilities(glp); - Display display = NewtFactory.createDisplay(null); // local display - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - - List monitorModes = screen.getMonitorModes(); - if(null==monitorModes) { - // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); - return; - } - Animator animator = new Animator(window); - animator.start(); - - MonitorDevice monitor = window.getMainMonitor(); - MonitorMode mmCurrent = monitor.queryCurrentMode(); - MonitorMode mmOrig = monitor.getOriginalMode(); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - - MonitorMode mm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+mm); - monitor.setCurrentMode(mm); - - System.err.print("[0] post setting .. wait <"); - try { - Thread.sleep(waitTime); - } catch (InterruptedException e) { - } - System.err.println("done>"); - System.exit(0); - } - - public static void main(String args[]) throws IOException { - ManualScreenMode03NEWT t = new ManualScreenMode03NEWT(); - t.run(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java new file mode 100644 index 000000000..875e4fe86 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java @@ -0,0 +1,114 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.Animator; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Manual testing the ScreenImpl shutdown hook, + * which shall reset the ScreenMode to it's original state + * when the application exists (normal or ctrl-c). + */ +public class ManualScreenMode03NEWT extends UITestCase { + static int waitTime = 7000; // 1 sec + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + caps.setOnscreen(onscreen); + + GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + window.setVisible(true); + return window; + } + + public void run() { + int width = 640; + int height = 480; + GLProfile glp = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(glp); + Display display = NewtFactory.createDisplay(null); // local display + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + + List monitorModes = screen.getMonitorModes(); + if(null==monitorModes) { + // no support .. + System.err.println("Your platform has no ScreenMode change support, sorry"); + return; + } + Animator animator = new Animator(window); + animator.start(); + + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + MonitorMode mmOrig = monitor.getOriginalMode(); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + + MonitorMode mm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+mm); + monitor.setCurrentMode(mm); + + System.err.print("[0] post setting .. wait <"); + try { + Thread.sleep(waitTime); + } catch (InterruptedException e) { + } + System.err.println("done>"); + System.exit(0); + } + + public static void main(String args[]) throws IOException { + ManualScreenMode03NEWT t = new ManualScreenMode03NEWT(); + t.run(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java deleted file mode 100644 index f64cf2eb8..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00NEWT.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.nativewindow.NativeWindowFactory; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.common.util.ArrayHashSet; -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.Screen; -import com.jogamp.opengl.test.junit.util.UITestCase; -import java.util.Iterator; -import java.util.List; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Rectangle; -import javax.media.nativewindow.util.SurfaceSize; -import javax.media.opengl.GLProfile; - -import jogamp.newt.MonitorDeviceImpl; -import jogamp.newt.MonitorModeProps; - -public class TestScreenMode00NEWT extends UITestCase { - static int screenIdx = 0; - static int width, height; - - static int waitTimeShort = 4; //1 sec - static int waitTimeLong = 6; //6 sec - - - - @BeforeClass - public static void initClass() { - GLProfile.initSingleton(); // hack to initialize GL for BCM_IV (Rasp.Pi) - NativeWindowFactory.initSingleton(); - width = 640; - height = 480; - } - - @Test - public void testScreenModeInfo00() throws InterruptedException { - final DimensionImmutable res = new Dimension(640, 480); - final SurfaceSize surfsz = new SurfaceSize(res, 32); - final MonitorMode modeOut = new MonitorMode(surfsz, 60.0f, 0, 0); - System.err.println("00 out: "+modeOut); - final MonitorModeProps.Cache cache = new MonitorModeProps.Cache(); - cache.monitorModes.add(modeOut); - { - final int[] props = MonitorModeProps.streamOutMonitorMode(modeOut); - final MonitorMode modeIn = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); - System.err.println("00 in : "+modeIn); - - Assert.assertEquals(modeOut.getSurfaceSize().getResolution(), modeIn.getSurfaceSize().getResolution()); - - Assert.assertEquals(modeOut.getSurfaceSize(), modeIn.getSurfaceSize()); - - Assert.assertEquals(modeOut.hashCode(), modeIn.hashCode()); - - Assert.assertEquals(modeOut, modeIn); - } - - final DimensionImmutable sizeMM = new Dimension(50, 50); - final Rectangle viewport = new Rectangle(0, 0, 1920, 1080); - final ArrayHashSet supportedModes = new ArrayHashSet(); - supportedModes.add(modeOut); - final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, modeOut, supportedModes); - System.err.println("01 out : "+monOut); - cache.monitorDevices.add(monOut); - { - final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut); - final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0); - System.err.println("01 in : "+monIn); - - Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode()); - Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes()); - Assert.assertEquals(monOut.getViewport(), monIn.getViewport()); - Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode()); - Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode()); - Assert.assertEquals(monOut.hashCode(), monIn.hashCode()); - Assert.assertEquals(monOut, monIn); - } - } - - @Test - public void testScreenModeInfo01() throws InterruptedException { - Display dpy = NewtFactory.createDisplay(null); - Screen screen = NewtFactory.createScreen(dpy, screenIdx); - screen.addReference(); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,screen.getDisplay().isNativeValid()); - System.err.println("Screen: "+screen.toString()); - List allMonitorModes = screen.getMonitorModes(); - Assert.assertTrue(allMonitorModes.size()>0); - { - int i=0; - for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { - System.err.println("All["+i+"]: "+iMode.next()); - } - } - - List monitors = screen.getMonitorDevices(); - Assert.assertTrue(monitors.size()>0); - int j=0; - for(Iterator iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) { - MonitorDevice monitor = iMonitor.next(); - System.err.println(j+": "+monitor); - List modes = monitor.getSupportedModes(); - Assert.assertTrue(modes.size()>0); - int i=0; - for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { - System.err.println("["+j+"]["+i+"]: "+iMode.next()); - } - Assert.assertTrue(allMonitorModes.containsAll(modes)); - - MonitorMode sm_o = monitor.getOriginalMode(); - Assert.assertNotNull(sm_o); - MonitorMode sm_c = monitor.queryCurrentMode(); - System.err.println("[0] orig : "+sm_o); - System.err.println("[0] current: "+sm_c); - Assert.assertNotNull(sm_c); - Assert.assertEquals(sm_o, sm_c); - } - - screen.removeReference(); - - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,screen.getDisplay().isNativeValid()); - } - - static int atoi(String a) { - try { - return Integer.parseInt(a); - } catch (Exception ex) { throw new RuntimeException(ex); } - } - - public static void main(String args[]) throws IOException { - for(int i=0; i supportedModes = new ArrayHashSet(); + supportedModes.add(modeOut); + final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, modeOut, supportedModes); + System.err.println("01 out : "+monOut); + cache.monitorDevices.add(monOut); + { + final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut); + final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0); + System.err.println("01 in : "+monIn); + + Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode()); + Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes()); + Assert.assertEquals(monOut.getViewport(), monIn.getViewport()); + Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode()); + Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode()); + Assert.assertEquals(monOut.hashCode(), monIn.hashCode()); + Assert.assertEquals(monOut, monIn); + } + } + + @Test + public void testScreenModeInfo01() throws InterruptedException { + Display dpy = NewtFactory.createDisplay(null); + Screen screen = NewtFactory.createScreen(dpy, screenIdx); + screen.addReference(); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,screen.getDisplay().isNativeValid()); + System.err.println("Screen: "+screen.toString()); + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + { + int i=0; + for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { + System.err.println("All["+i+"]: "+iMode.next()); + } + } + + List monitors = screen.getMonitorDevices(); + Assert.assertTrue(monitors.size()>0); + int j=0; + for(Iterator iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) { + MonitorDevice monitor = iMonitor.next(); + System.err.println(j+": "+monitor); + List modes = monitor.getSupportedModes(); + Assert.assertTrue(modes.size()>0); + int i=0; + for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { + System.err.println("["+j+"]["+i+"]: "+iMode.next()); + } + Assert.assertTrue(allMonitorModes.containsAll(modes)); + + MonitorMode sm_o = monitor.getOriginalMode(); + Assert.assertNotNull(sm_o); + MonitorMode sm_c = monitor.queryCurrentMode(); + System.err.println("[0] orig : "+sm_o); + System.err.println("[0] current: "+sm_c); + Assert.assertNotNull(sm_c); + Assert.assertEquals(sm_o, sm_c); + } + + screen.removeReference(); + + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,screen.getDisplay().isNativeValid()); + } + + static int atoi(String a) { + try { + return Integer.parseInt(a); + } catch (Exception ex) { throw new RuntimeException(ex); } + } + + public static void main(String args[]) throws IOException { + for(int i=0; i - * Also documents NV RANDR/GL bug, see {@link TestScreenMode01NEWT#cleanupGL()}.

    - */ -public class TestScreenMode01NEWT extends UITestCase { - static GLProfile glp; - static int width, height; - - static int waitTimeShort = 2000; // 2 sec - static int waitTimeLong = 8000; // 8 sec - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glp = GLProfile.getDefault(); - } - - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - - /** - * Following configurations results in a SIGSEGV: - *
    -     *   Ubuntu 11.04 (natty), NV GTX 460, driver [280.10* - 285.03]
    -     * 
    - * - * Situation: - *
    -     *   1 - Create Screen, GLWindow (w/ context)
    -     *   2 - ScreenMode change
    -     *   3 - Destroy GLWindow (w/ context), Screen
    -     *   4 - Create  Screen, GLWindow (w/ context) (*)
    -     * 
    - * - * Step 4 causes the exception within 1st 'glXMakeContextCurrent(..)' call - * on the the created GL context. - * - * Remedy: - *
    -     *   A) Releasing all resources before step 4 .. works.
    -     *   B) Holding the native Display/Screen in NEWT also works (ie screen.addReference()).
    -     * 
    - * - * Hence there must be some correlations with the screen randr mode - * and some of the glcontext/gldrawables. - * - *
    -     * Remedy A) is demonstrated here
    -     * Remedy B) is shown in {@link TestScreenMode01bNEWT}
    -     * 
    - */ - private void cleanupGL() throws InterruptedException { - System.err.println("*** cleanupGL.shutdown"); - GLProfile.shutdown(); - System.err.println("*** cleanupGL.initSingleton"); - GLProfile.initSingleton(); - System.err.println("*** cleanupGL.DONE"); - } - - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { - Assert.assertNotNull(caps); - caps.setOnscreen(onscreen); - - GLWindow window = GLWindow.create(screen, caps); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - Assert.assertNotNull(window); - window.setVisible(true); - return window; - } - - static void destroyWindow(Window window) { - if(null!=window) { - window.destroy(); - } - } - - @Test - public void testFullscreenChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - Animator animator = new Animator(window); - animator.start(); - - final MonitorDevice monitor = window.getMainMonitor(); - - Assert.assertEquals(false, window.isFullscreen()); - Assert.assertEquals(width, window.getWidth()); - Assert.assertEquals(height, window.getHeight()); - - window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - Assert.assertEquals(monitor.getViewport().getWidth(), window.getWidth()); - Assert.assertEquals(monitor.getViewport().getHeight(), window.getHeight()); - - Thread.sleep(waitTimeShort); - - window.setFullscreen(false); - Assert.assertEquals(false, window.isFullscreen()); - Assert.assertEquals(width, window.getWidth()); - Assert.assertEquals(height, window.getHeight()); - - Thread.sleep(waitTimeShort); - - animator.stop(); - Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isStarted()); - - destroyWindow(window); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); - Assert.assertEquals(false, window.isRealized()); - Assert.assertEquals(false, window.isNativeValid()); - - cleanupGL(); - } - - @Test - public void testScreenModeChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - - GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - Assert.assertNotNull(window); - - MonitorDevice monitor = window.getMainMonitor(); - - List monitorModes = monitor.getSupportedModes(); - Assert.assertTrue(monitorModes.size()>0); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no MonitorMode change support, sorry"); - destroyWindow(window); - return; - } - - Animator animator = new Animator(window); - animator.start(); - - MonitorMode mmCurrent = monitor.queryCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - monitor.setCurrentMode(sm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); - - Thread.sleep(waitTimeLong); - - // check reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(true,window.isVisible()); - - animator.stop(); - Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isStarted()); - - destroyWindow(window); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isRealized()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - screen.destroy(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - cleanupGL(); - } - - @Test - public void testScreenModeChangeWithFS01Pre() throws InterruptedException { - Thread.sleep(waitTimeShort); - testScreenModeChangeWithFS01Impl(true) ; - } - - @Test - public void testScreenModeChangeWithFS01Post() throws InterruptedException { - Thread.sleep(waitTimeShort); - testScreenModeChangeWithFS01Impl(false) ; - } - - protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException { - GLCapabilities caps = new GLCapabilities(glp); - Display display = NewtFactory.createDisplay(null); // local display - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - Animator animator = new Animator(window); - animator.start(); - - MonitorDevice monitor = window.getMainMonitor(); - MonitorMode mmCurrent = monitor.queryCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - List monitorModes = monitor.getSupportedModes(); - if(monitorModes.size()==1) { - // no support .. - destroyWindow(window); - return; - } - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - - MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); - Assert.assertNotNull(monitorMode); - - if(preFS) { - System.err.println("[0] set FS pre 0: "+window.isFullscreen()); - window.setFullscreen(true); - System.err.println("[0] set FS pre 1: "+window.isFullscreen()); - Assert.assertEquals(true, window.isFullscreen()); - System.err.println("[0] set FS pre X: "+window.isFullscreen()); - } - - System.err.println("[0] set current: "+monitorMode); - monitor.setCurrentMode(monitorMode); - - if(!preFS) { - System.err.println("[0] set FS post 0: "+window.isFullscreen()); - window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - System.err.println("[0] set FS post X: "+window.isFullscreen()); - } - - Thread.sleep(waitTimeLong); - - // check reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(true,window.isVisible()); - - animator.stop(); - Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isStarted()); - - destroyWindow(window); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isRealized()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - screen.destroy(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - cleanupGL(); - } - - public static void main(String args[]) throws IOException { - String tstname = TestScreenMode01NEWT.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01dNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01dNEWT.java new file mode 100644 index 000000000..a2ce7cec0 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01dNEWT.java @@ -0,0 +1,392 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.Animator; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Demonstrates fullscreen with and without ScreenMode change. + * + *

    + * Also documents NV RANDR/GL bug, see {@link TestScreenMode01NEWT#cleanupGL()}.

    + */ +public class TestScreenMode01NEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static int waitTimeShort = 2000; // 2 sec + static int waitTimeLong = 8000; // 8 sec + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + /** + * Following configurations results in a SIGSEGV: + *
    +     *   Ubuntu 11.04 (natty), NV GTX 460, driver [280.10* - 285.03]
    +     * 
    + * + * Situation: + *
    +     *   1 - Create Screen, GLWindow (w/ context)
    +     *   2 - ScreenMode change
    +     *   3 - Destroy GLWindow (w/ context), Screen
    +     *   4 - Create  Screen, GLWindow (w/ context) (*)
    +     * 
    + * + * Step 4 causes the exception within 1st 'glXMakeContextCurrent(..)' call + * on the the created GL context. + * + * Remedy: + *
    +     *   A) Releasing all resources before step 4 .. works.
    +     *   B) Holding the native Display/Screen in NEWT also works (ie screen.addReference()).
    +     * 
    + * + * Hence there must be some correlations with the screen randr mode + * and some of the glcontext/gldrawables. + * + *
    +     * Remedy A) is demonstrated here
    +     * Remedy B) is shown in {@link TestScreenMode01bNEWT}
    +     * 
    + */ + private void cleanupGL() throws InterruptedException { + System.err.println("*** cleanupGL.shutdown"); + GLProfile.shutdown(); + System.err.println("*** cleanupGL.initSingleton"); + GLProfile.initSingleton(); + System.err.println("*** cleanupGL.DONE"); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + Assert.assertNotNull(caps); + caps.setOnscreen(onscreen); + + GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testFullscreenChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Animator animator = new Animator(window); + animator.start(); + + final MonitorDevice monitor = window.getMainMonitor(); + + Assert.assertEquals(false, window.isFullscreen()); + Assert.assertEquals(width, window.getWidth()); + Assert.assertEquals(height, window.getHeight()); + + window.setFullscreen(true); + Assert.assertEquals(true, window.isFullscreen()); + Assert.assertEquals(monitor.getViewport().getWidth(), window.getWidth()); + Assert.assertEquals(monitor.getViewport().getHeight(), window.getHeight()); + + Thread.sleep(waitTimeShort); + + window.setFullscreen(false); + Assert.assertEquals(false, window.isFullscreen()); + Assert.assertEquals(width, window.getWidth()); + Assert.assertEquals(height, window.getHeight()); + + Thread.sleep(waitTimeShort); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + Assert.assertEquals(false, window.isRealized()); + Assert.assertEquals(false, window.isNativeValid()); + + cleanupGL(); + } + + @Test + public void testScreenModeChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Assert.assertNotNull(window); + + MonitorDevice monitor = window.getMainMonitor(); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support, sorry"); + destroyWindow(window); + return; + } + + Animator animator = new Animator(window); + animator.start(); + + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+sm); + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + Thread.sleep(waitTimeLong); + + // check reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isRealized()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + screen.createNative(); // trigger native re-creation + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); + screen.destroy(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + cleanupGL(); + } + + @Test + public void testScreenModeChangeWithFS01Pre() throws InterruptedException { + Thread.sleep(waitTimeShort); + testScreenModeChangeWithFS01Impl(true) ; + } + + @Test + public void testScreenModeChangeWithFS01Post() throws InterruptedException { + Thread.sleep(waitTimeShort); + testScreenModeChangeWithFS01Impl(false) ; + } + + protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException { + GLCapabilities caps = new GLCapabilities(glp); + Display display = NewtFactory.createDisplay(null); // local display + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Animator animator = new Animator(window); + animator.start(); + + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { + // no support .. + destroyWindow(window); + return; + } + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + + MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); + Assert.assertNotNull(monitorMode); + + if(preFS) { + System.err.println("[0] set FS pre 0: "+window.isFullscreen()); + window.setFullscreen(true); + System.err.println("[0] set FS pre 1: "+window.isFullscreen()); + Assert.assertEquals(true, window.isFullscreen()); + System.err.println("[0] set FS pre X: "+window.isFullscreen()); + } + + System.err.println("[0] set current: "+monitorMode); + monitor.setCurrentMode(monitorMode); + + if(!preFS) { + System.err.println("[0] set FS post 0: "+window.isFullscreen()); + window.setFullscreen(true); + Assert.assertEquals(true, window.isFullscreen()); + System.err.println("[0] set FS post X: "+window.isFullscreen()); + } + + Thread.sleep(waitTimeLong); + + // check reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isRealized()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + screen.createNative(); // trigger native re-creation + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); + screen.destroy(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + cleanupGL(); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode01NEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java deleted file mode 100644 index 58bce4cc9..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02NEWT.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; - -import com.jogamp.opengl.util.Animator; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.common.os.Platform; -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Screen; -import com.jogamp.newt.Window; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.MonitorModeUtil; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; -import java.util.List; -import javax.media.nativewindow.util.Dimension; - -public class TestScreenMode02NEWT extends UITestCase { - static GLProfile glp; - static int width, height; - - static int waitTimeShort = 2000; // 2 sec - static int waitTimeLong = 8000; // 8 sec - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glp = GLProfile.getDefault(); - } - - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { - Assert.assertNotNull(caps); - caps.setOnscreen(onscreen); - - GLWindow window = GLWindow.create(screen, caps); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - Assert.assertNotNull(window); - window.setVisible(true); - Assert.assertTrue(window.isVisible()); - return window; - } - - static void destroyWindow(Window window) { - if(null!=window) { - window.destroy(); - } - } - - @Test - public void testScreenRotationChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - - GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - Assert.assertNotNull(window); - - MonitorDevice monitor = window.getMainMonitor(); - List monitorModes = monitor.getSupportedModes(); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); - destroyWindow(window); - return; - } - Assert.assertTrue(monitorModes.size()>0); - - Animator animator = new Animator(window); - animator.start(); - - MonitorMode mmCurrent = monitor.getCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); - if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { - // no rotation support .. - System.err.println("Your platform has no rotation support, sorry"); - destroyWindow(window); - return; - } - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - monitor.setCurrentMode(sm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); - - Thread.sleep(waitTimeLong); - - // check reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(true,window.isVisible()); - - animator.stop(); - destroyWindow(window); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - screen.destroy(); - - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - } - - public static void main(String args[]) throws IOException { - String tstname = TestScreenMode02NEWT.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java new file mode 100644 index 000000000..58bce4cc9 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java @@ -0,0 +1,197 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.Animator; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.os.Platform; +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +public class TestScreenMode02NEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static int waitTimeShort = 2000; // 2 sec + static int waitTimeLong = 8000; // 8 sec + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + Assert.assertNotNull(caps); + caps.setOnscreen(onscreen); + + GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + Assert.assertTrue(window.isVisible()); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testScreenRotationChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Assert.assertNotNull(window); + + MonitorDevice monitor = window.getMainMonitor(); + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no ScreenMode change support, sorry"); + destroyWindow(window); + return; + } + Assert.assertTrue(monitorModes.size()>0); + + Animator animator = new Animator(window); + animator.start(); + + MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); + if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { + // no rotation support .. + System.err.println("Your platform has no rotation support, sorry"); + destroyWindow(window); + return; + } + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+sm); + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + Thread.sleep(waitTimeLong); + + // check reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + destroyWindow(window); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + screen.createNative(); // trigger native re-creation + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); + + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + screen.destroy(); + + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode02NEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + +} -- cgit v1.2.3 From 1a20ec143a7434ec035a567f73f7b3656edb4c3d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 29 Jun 2013 11:42:10 +0200 Subject: Tests: Put monitor/screen mode tests to own subpackage --- make/scripts/tests-win.bat | 16 +- make/scripts/tests.sh | 18 +- .../test/junit/newt/ManualScreenMode03aNEWT.java | 114 ------ .../test/junit/newt/TestScreenMode00aNEWT.java | 183 ---------- .../test/junit/newt/TestScreenMode00bNEWT.java | 127 ------- .../test/junit/newt/TestScreenMode01aNEWT.java | 218 ------------ .../test/junit/newt/TestScreenMode01bNEWT.java | 249 ------------- .../test/junit/newt/TestScreenMode01cNEWT.java | 249 ------------- .../test/junit/newt/TestScreenMode01dNEWT.java | 392 --------------------- .../test/junit/newt/TestScreenMode02aNEWT.java | 204 ----------- .../junit/newt/mm/ManualScreenMode03aNEWT.java | 114 ++++++ .../test/junit/newt/mm/TestScreenMode00aNEWT.java | 183 ++++++++++ .../test/junit/newt/mm/TestScreenMode00bNEWT.java | 127 +++++++ .../test/junit/newt/mm/TestScreenMode01aNEWT.java | 218 ++++++++++++ .../test/junit/newt/mm/TestScreenMode01bNEWT.java | 249 +++++++++++++ .../test/junit/newt/mm/TestScreenMode01cNEWT.java | 249 +++++++++++++ .../test/junit/newt/mm/TestScreenMode01dNEWT.java | 392 +++++++++++++++++++++ .../test/junit/newt/mm/TestScreenMode02aNEWT.java | 204 +++++++++++ 18 files changed, 1753 insertions(+), 1753 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00aNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00bNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01cNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01dNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/ManualScreenMode03aNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00bNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01cNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 0b5f13661..17ac9c784 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -113,14 +113,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRo REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00aNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode01dNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestScreenMode02sNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.ManualScreenMode03sNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02sNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8cf4fb406..84e536017 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -400,14 +400,14 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00aNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode00bNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01aNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01bNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01cNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode01dNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02aNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.ManualScreenMode03aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* @@ -585,7 +585,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* # test rotation change -#testnoawt com.jogamp.opengl.test.junit.newt.TestScreenMode02aNEWT +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT # # regressions diff --git a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java deleted file mode 100644 index 1b67f1fe5..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/ManualScreenMode03aNEWT.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; - -import com.jogamp.opengl.util.Animator; - -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Screen; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.MonitorModeUtil; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.UITestCase; -import java.util.List; -import javax.media.nativewindow.util.Dimension; - -/** - * Manual testing the ScreenImpl shutdown hook, - * which shall reset the ScreenMode to it's original state - * when the application exists (normal or ctrl-c). - */ -public class ManualScreenMode03aNEWT extends UITestCase { - static int waitTime = 7000; // 1 sec - - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { - caps.setOnscreen(onscreen); - - GLWindow window = GLWindow.create(screen, caps); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - window.setVisible(true); - return window; - } - - public void run() { - int width = 640; - int height = 480; - GLProfile glp = GLProfile.getDefault(); - GLCapabilities caps = new GLCapabilities(glp); - Display display = NewtFactory.createDisplay(null); // local display - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - - List monitorModes = screen.getMonitorModes(); - if(null==monitorModes) { - // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); - return; - } - Animator animator = new Animator(window); - animator.start(); - - MonitorDevice monitor = window.getMainMonitor(); - MonitorMode mmCurrent = monitor.queryCurrentMode(); - MonitorMode mmOrig = monitor.getOriginalMode(); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - - MonitorMode mm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+mm); - monitor.setCurrentMode(mm); - - System.err.print("[0] post setting .. wait <"); - try { - Thread.sleep(waitTime); - } catch (InterruptedException e) { - } - System.err.println("done>"); - System.exit(0); - } - - public static void main(String args[]) throws IOException { - ManualScreenMode03aNEWT t = new ManualScreenMode03aNEWT(); - t.run(); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00aNEWT.java deleted file mode 100644 index 353377292..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode00aNEWT.java +++ /dev/null @@ -1,183 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.nativewindow.NativeWindowFactory; - -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.common.util.ArrayHashSet; -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.Screen; -import com.jogamp.opengl.test.junit.util.UITestCase; -import java.util.Iterator; -import java.util.List; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.Rectangle; -import javax.media.nativewindow.util.SurfaceSize; -import javax.media.opengl.GLProfile; - -import jogamp.newt.MonitorDeviceImpl; -import jogamp.newt.MonitorModeProps; - -/** - * Validating consistency of MonitorMode data from Screen (all modes) - * and from a particular MonitorDevice. - */ -public class TestScreenMode00aNEWT extends UITestCase { - static int screenIdx = 0; - static int width, height; - - static int waitTimeShort = 4; //1 sec - static int waitTimeLong = 6; //6 sec - - - - @BeforeClass - public static void initClass() { - GLProfile.initSingleton(); // hack to initialize GL for BCM_IV (Rasp.Pi) - NativeWindowFactory.initSingleton(); - width = 640; - height = 480; - } - - @Test - public void testScreenModeInfo00() throws InterruptedException { - final DimensionImmutable res = new Dimension(640, 480); - final SurfaceSize surfsz = new SurfaceSize(res, 32); - final MonitorMode modeOut = new MonitorMode(surfsz, 60.0f, 0, 0); - System.err.println("00 out: "+modeOut); - final MonitorModeProps.Cache cache = new MonitorModeProps.Cache(); - cache.monitorModes.add(modeOut); - { - final int[] props = MonitorModeProps.streamOutMonitorMode(modeOut); - final MonitorMode modeIn = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); - System.err.println("00 in : "+modeIn); - - Assert.assertEquals(modeOut.getSurfaceSize().getResolution(), modeIn.getSurfaceSize().getResolution()); - - Assert.assertEquals(modeOut.getSurfaceSize(), modeIn.getSurfaceSize()); - - Assert.assertEquals(modeOut.hashCode(), modeIn.hashCode()); - - Assert.assertEquals(modeOut, modeIn); - } - - final DimensionImmutable sizeMM = new Dimension(50, 50); - final Rectangle viewport = new Rectangle(0, 0, 1920, 1080); - final ArrayHashSet supportedModes = new ArrayHashSet(); - supportedModes.add(modeOut); - final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, modeOut, supportedModes); - System.err.println("01 out : "+monOut); - cache.monitorDevices.add(monOut); - { - final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut); - final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0); - System.err.println("01 in : "+monIn); - - Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode()); - Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes()); - Assert.assertEquals(monOut.getViewport(), monIn.getViewport()); - Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode()); - Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode()); - Assert.assertEquals(monOut.hashCode(), monIn.hashCode()); - Assert.assertEquals(monOut, monIn); - } - } - - @Test - public void testScreenModeInfo01() throws InterruptedException { - Display dpy = NewtFactory.createDisplay(null); - Screen screen = NewtFactory.createScreen(dpy, screenIdx); - screen.addReference(); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,screen.getDisplay().isNativeValid()); - System.err.println("Screen: "+screen.toString()); - List allMonitorModes = screen.getMonitorModes(); - Assert.assertTrue(allMonitorModes.size()>0); - { - int i=0; - for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { - System.err.println("All["+i+"]: "+iMode.next()); - } - } - - List monitors = screen.getMonitorDevices(); - Assert.assertTrue(monitors.size()>0); - int j=0; - for(Iterator iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) { - MonitorDevice monitor = iMonitor.next(); - System.err.println(j+": "+monitor); - List modes = monitor.getSupportedModes(); - Assert.assertTrue(modes.size()>0); - int i=0; - for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { - System.err.println("["+j+"]["+i+"]: "+iMode.next()); - } - Assert.assertTrue(allMonitorModes.containsAll(modes)); - - MonitorMode sm_o = monitor.getOriginalMode(); - Assert.assertNotNull(sm_o); - MonitorMode sm_c = monitor.queryCurrentMode(); - System.err.println("[0] orig : "+sm_o); - System.err.println("[0] current: "+sm_c); - Assert.assertNotNull(sm_c); - Assert.assertEquals(sm_o, sm_c); - } - - screen.removeReference(); - - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,screen.getDisplay().isNativeValid()); - } - - static int atoi(String a) { - try { - return Integer.parseInt(a); - } catch (Exception ex) { throw new RuntimeException(ex); } - } - - public static void main(String args[]) throws IOException { - for(int i=0; i screenModes = screen.getMonitorModes(); - Assert.assertTrue(screenModes.size()>0); - int i=0; - for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { - System.err.println(i+": "+iter.next()); - } - MonitorDevice monitor = window.getMainMonitor(); - MonitorMode mm_o = monitor.getOriginalMode(); - - Assert.assertNotNull(mm_o); - MonitorMode mm_c = monitor.queryCurrentMode(); - Assert.assertNotNull(mm_c); - System.err.println("orig: "+mm_o); - System.err.println("curr: "+mm_c); - - for(i=0; i<50; i++) { - mm_c = monitor.queryCurrentMode(); - Assert.assertNotNull(mm_c); - System.err.print("."+i); - } - System.err.println("!"); - - // screen.removeReference(); - anim.stop(); - window.destroy(); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - } - - public static void main(String args[]) throws IOException { - String tstname = TestScreenMode00bNEWT.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java deleted file mode 100644 index 482a0cf34..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01aNEWT.java +++ /dev/null @@ -1,218 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Screen; -import com.jogamp.newt.Window; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.MonitorModeUtil; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.UITestCase; - -import java.util.List; -import javax.media.nativewindow.util.Dimension; - -/** - *

    - * Tests MonitorMode reset, by destroying the last Screen (reference), - * i.e. the original MonitorMode should get reinstated! - *

    - *

    - * Documents remedy B) for NV RANDR/GL bug - *

    - * - * @see TestScreenMode01dNEWT#cleanupGL() - */ -public class TestScreenMode01aNEWT extends UITestCase { - static GLProfile glp; - static int width, height; - - static int waitTimeShort = 2000; - static int waitTimeLong = 2000; - - @BeforeClass - public static void initClass() { - width = 100; - height = 100; - glp = GLProfile.getDefault(); - } - - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - - static Window createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) { - Assert.assertNotNull(caps); - - GLWindow window = GLWindow.create(screen, caps); - // Window window = NewtFactory.createWindow(screen, caps); - window.setTitle(name); - window.setPosition(x, y); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - Assert.assertNotNull(window); - window.setVisible(true); - return window; - } - - static void destroyWindow(Window window) { - if(null!=window) { - window.destroy(); - } - } - - @Test - public void testScreenModeChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - - GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height); - Assert.assertNotNull(window0); - - List allMonitorModes = screen.getMonitorModes(); - Assert.assertTrue(allMonitorModes.size()>0); - if(allMonitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no MonitorMode change support (all), sorry"); - destroyWindow(window0); - return; - } - - MonitorDevice monitor = window0.getMainMonitor(); - - List monitorModes = monitor.getSupportedModes(); - Assert.assertTrue(monitorModes.size()>0); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); - destroyWindow(window0); - return; - } - Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); - - MonitorMode mmCurrent = monitor.queryCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode mm = monitorModes.get(0); - System.err.println("[0] set current: "+mm); - Assert.assertTrue(monitor.setCurrentMode(mm)); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(mm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(mm, monitor.queryCurrentMode()); - - Thread.sleep(waitTimeShort); - - // check manual reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window0.isNativeValid()); - Assert.assertEquals(true,window0.isVisible()); - - screen.addReference(); // keep it alive ! - Assert.assertTrue(monitor.setCurrentMode(mmOrig)); - Assert.assertFalse(monitor.isModeChangedByUs()); - Assert.assertEquals(mmOrig, monitor.getCurrentMode()); - Assert.assertNotSame(mm, monitor.getCurrentMode()); - Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); - - destroyWindow(window0); - Assert.assertEquals(false,window0.isVisible()); - Assert.assertEquals(false,window0.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); // alive ! - Assert.assertEquals(true,display.isNativeValid()); - - Thread.sleep(waitTimeShort); - - Window window1 = createWindow(screen, caps, "win1", - width+window0.getInsets().getTotalWidth(), 0, - width, height); - Assert.assertNotNull(window1); - Assert.assertEquals(true,window1.isNativeValid()); - Assert.assertEquals(true,window1.isVisible()); - - Thread.sleep(waitTimeShort); - - destroyWindow(window1); - Assert.assertEquals(false,window1.isNativeValid()); - Assert.assertEquals(false,window1.isVisible()); - - screen.removeReference(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - } - - public static void main(String args[]) throws IOException { - String tstname = TestScreenMode01aNEWT.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java deleted file mode 100644 index 9108853e5..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode01bNEWT.java +++ /dev/null @@ -1,249 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Screen; -import com.jogamp.newt.Window; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.MonitorModeUtil; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; - -import java.util.List; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.RectangleImmutable; - -/** - * Mode change on separate monitors .. - */ -public class TestScreenMode01bNEWT extends UITestCase { - static GLProfile glp; - static int width, height; - - static long waitTimeShort = 2000; - static long duration = 6000; - - @BeforeClass - public static void initClass() { - width = 200; - height = 200; - glp = GLProfile.getDefault(); - } - - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - - static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) throws InterruptedException { - Assert.assertNotNull(caps); - - GLWindow window = GLWindow.create(screen, caps); - // Window window = NewtFactory.createWindow(screen, caps); - window.setTitle(name); - window.setPosition(x, y); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - Assert.assertNotNull(window); - final long t0 = System.currentTimeMillis(); - window.setVisible(true); - System.err.println("Time for visible/pos: "+(System.currentTimeMillis()-t0)+" ms"); - return window; - } - - static void destroyWindow(Window window) { - if(null!=window) { - window.destroy(); - } - } - - @Test - public void testScreenModeChangeSingleQ1() throws InterruptedException { - final Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - screen.addReference(); // trigger creation - try { - RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport(); - testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY()); - } finally { - screen.removeReference(); - } - } - - @Test - public void testScreenModeChangeSingleQ2() throws InterruptedException { - final Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - screen.addReference(); // trigger creation - try { - if( 2 > screen.getMonitorDevices().size() ) { - System.err.println("Test Disabled (1): Monitor count < 2: "+screen); - return; - } - RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); - testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY()); - } finally { - screen.removeReference(); - } - } - - void testScreenModeChangeImpl(final Screen screen, int xpos, int ypos) throws InterruptedException { - Thread.sleep(waitTimeShort); - - final GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - final Display display = screen.getDisplay(); - System.err.println("Test.0: Window screen: "+screen); - - System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); - - GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); - Assert.assertNotNull(window0); - System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); - - final Animator anim = new Animator(window0); - anim.start(); - - List allMonitorModes = screen.getMonitorModes(); - Assert.assertTrue(allMonitorModes.size()>0); - if(allMonitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no MonitorMode change support (all), sorry"); - destroyWindow(window0); - return; - } - - MonitorDevice monitor = window0.getMainMonitor(); - System.err.println("Test.0: Window monitor: "+monitor); - - List monitorModes = monitor.getSupportedModes(); - Assert.assertTrue(monitorModes.size()>0); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); - destroyWindow(window0); - return; - } - Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); - - MonitorMode mmCurrent = monitor.getCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[1] set current: "+sm); - Assert.assertTrue(monitor.setCurrentMode(sm)); - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current: "+mmCurrent); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); - - System.err.println("Test.1: Window screen: "+screen); - System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); - System.err.println("Test.1: Window monitor: "+window0.getMainMonitor()); - - Thread.sleep(duration); - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window0.isNativeValid()); - Assert.assertEquals(true,window0.isVisible()); - - Assert.assertTrue(monitor.setCurrentMode(mmOrig)); - Assert.assertFalse(monitor.isModeChangedByUs()); - Assert.assertEquals(mmOrig, monitor.getCurrentMode()); - Assert.assertNotSame(sm, monitor.getCurrentMode()); - Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); - - System.err.println("Test.2: Window screen: "+screen); - System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); - System.err.println("Test.2: Window monitor: "+window0.getMainMonitor()); - - Thread.sleep(duration); - anim.stop(); - destroyWindow(window0); - Assert.assertEquals(false,window0.isVisible()); - Assert.assertEquals(false,window0.isNativeValid()); - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - } - - public static void main(String args[]) throws IOException { - for(int i=0; i screen.getMonitorDevices().size() ) { - System.err.println("Test Disabled (1): Monitor count < 2: "+screen); - return; - } - RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); - testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null); - } finally { - screen.removeReference(); - } - } - - @Test - public void testScreenFullscreenSpanQ1Q2() throws InterruptedException { - final Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - screen.addReference(); // trigger creation - try { - final int crtCount = screen.getMonitorDevices().size(); - if( 2 >= crtCount ) { - System.err.println("Test Disabled (2): Spanning monitor count "+2+" >= screen monitor count: "+screen); - return; - } - final ArrayList monitors = new ArrayList(); - monitors.add(screen.getMonitorDevices().get(0)); // Q1 - monitors.add(screen.getMonitorDevices().get(1)); // Q2 - RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport(); - testScreenFullscreenImpl(screen, monitorVp.getX()+50, monitorVp.getY()+50, true, monitors); - } finally { - screen.removeReference(); - } - } - - @Test - public void testScreenFullscreenSpanALL() throws InterruptedException { - final Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - screen.addReference(); // trigger creation - try { - if( 2 > screen.getMonitorDevices().size() ) { - System.err.println("Test Disabled (3): Monitor count < 2: "+screen); - return; - } - RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); - testScreenFullscreenImpl(screen, monitorVp.getX()-50, monitorVp.getY()+50, true, null); - } finally { - screen.removeReference(); - } - } - - void testScreenFullscreenImpl(final Screen screen, int xpos, int ypos, boolean spanAcrossMonitors, List monitors) throws InterruptedException { - Thread.sleep(waitTimeShort); - - final GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - final Display display = screen.getDisplay(); - - System.err.println("Test.0: Window screen: "+screen); - - System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); - - GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); - Assert.assertNotNull(window0); - System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); - - final Animator anim = new Animator(window0); - anim.start(); - - List allMonitorModes = screen.getMonitorModes(); - Assert.assertTrue(allMonitorModes.size()>0); - - MonitorDevice monitor = window0.getMainMonitor(); - System.err.println("Test.0: Window monitor: "+monitor); - if( !spanAcrossMonitors ) { - window0.setFullscreen(true); - } else { - window0.setFullscreen(monitors); - } - - monitor = window0.getMainMonitor(); - System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); - System.err.println("Test.1: Window monitor: "+monitor.getViewport()); - Rectangle window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight()); - if( !spanAcrossMonitors ) { - Assert.assertEquals(monitor.getViewport(), window0Rect); - } else { - List monitorsUsed = monitors; - if( null == monitorsUsed ) { - monitorsUsed = window0.getScreen().getMonitorDevices(); - } - Rectangle monitorsUsedViewport = MonitorDevice.unionOfViewports(new Rectangle(), monitorsUsed); - Assert.assertEquals(monitorsUsedViewport, window0Rect); - } - - Thread.sleep(duration); - - window0.setFullscreen(false); - - window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight()); - monitor = window0.getMainMonitor(); - System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); - System.err.println("Test.2: Window monitor: "+monitor.getViewport()); - - Thread.sleep(duration); - anim.stop(); - destroyWindow(window0); - Assert.assertEquals(false,window0.isVisible()); - Assert.assertEquals(false,window0.isNativeValid()); - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - } - - public static void main(String args[]) throws IOException { - for(int i=0; i - * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.

    - */ -public class TestScreenMode01dNEWT extends UITestCase { - static GLProfile glp; - static int width, height; - - static int waitTimeShort = 2000; // 2 sec - static int waitTimeLong = 8000; // 8 sec - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glp = GLProfile.getDefault(); - } - - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - - /** - * Following configurations results in a SIGSEGV: - *
    -     *   Ubuntu 11.04 (natty), NV GTX 460, driver [280.10* - 285.03]
    -     * 
    - * - * Situation: - *
    -     *   1 - Create Screen, GLWindow (w/ context)
    -     *   2 - ScreenMode change
    -     *   3 - Destroy GLWindow (w/ context), Screen
    -     *   4 - Create  Screen, GLWindow (w/ context) (*)
    -     * 
    - * - * Step 4 causes the exception within 1st 'glXMakeContextCurrent(..)' call - * on the the created GL context. - * - * Remedy: - *
    -     *   A) Releasing all resources before step 4 .. works.
    -     *   B) Holding the native Display/Screen in NEWT also works (ie screen.addReference()).
    -     * 
    - * - * Hence there must be some correlations with the screen randr mode - * and some of the glcontext/gldrawables. - * - *
    -     * Remedy A) is demonstrated here
    -     * Remedy B) is shown in {@link TestScreenMode01bNEWT}
    -     * 
    - */ - private void cleanupGL() throws InterruptedException { - System.err.println("*** cleanupGL.shutdown"); - GLProfile.shutdown(); - System.err.println("*** cleanupGL.initSingleton"); - GLProfile.initSingleton(); - System.err.println("*** cleanupGL.DONE"); - } - - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { - Assert.assertNotNull(caps); - caps.setOnscreen(onscreen); - - GLWindow window = GLWindow.create(screen, caps); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - Assert.assertNotNull(window); - window.setVisible(true); - return window; - } - - static void destroyWindow(Window window) { - if(null!=window) { - window.destroy(); - } - } - - @Test - public void testFullscreenChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - Animator animator = new Animator(window); - animator.start(); - - final MonitorDevice monitor = window.getMainMonitor(); - - Assert.assertEquals(false, window.isFullscreen()); - Assert.assertEquals(width, window.getWidth()); - Assert.assertEquals(height, window.getHeight()); - - window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - Assert.assertEquals(monitor.getViewport().getWidth(), window.getWidth()); - Assert.assertEquals(monitor.getViewport().getHeight(), window.getHeight()); - - Thread.sleep(waitTimeShort); - - window.setFullscreen(false); - Assert.assertEquals(false, window.isFullscreen()); - Assert.assertEquals(width, window.getWidth()); - Assert.assertEquals(height, window.getHeight()); - - Thread.sleep(waitTimeShort); - - animator.stop(); - Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isStarted()); - - destroyWindow(window); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); - Assert.assertEquals(false, window.isRealized()); - Assert.assertEquals(false, window.isNativeValid()); - - cleanupGL(); - } - - @Test - public void testScreenModeChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - - GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - Assert.assertNotNull(window); - - MonitorDevice monitor = window.getMainMonitor(); - - List monitorModes = monitor.getSupportedModes(); - Assert.assertTrue(monitorModes.size()>0); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no MonitorMode change support, sorry"); - destroyWindow(window); - return; - } - - Animator animator = new Animator(window); - animator.start(); - - MonitorMode mmCurrent = monitor.queryCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - monitor.setCurrentMode(sm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); - - Thread.sleep(waitTimeLong); - - // check reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(true,window.isVisible()); - - animator.stop(); - Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isStarted()); - - destroyWindow(window); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isRealized()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - screen.destroy(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - cleanupGL(); - } - - @Test - public void testScreenModeChangeWithFS01Pre() throws InterruptedException { - Thread.sleep(waitTimeShort); - testScreenModeChangeWithFS01Impl(true) ; - } - - @Test - public void testScreenModeChangeWithFS01Post() throws InterruptedException { - Thread.sleep(waitTimeShort); - testScreenModeChangeWithFS01Impl(false) ; - } - - protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException { - GLCapabilities caps = new GLCapabilities(glp); - Display display = NewtFactory.createDisplay(null); // local display - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - Animator animator = new Animator(window); - animator.start(); - - MonitorDevice monitor = window.getMainMonitor(); - MonitorMode mmCurrent = monitor.queryCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - List monitorModes = monitor.getSupportedModes(); - if(monitorModes.size()==1) { - // no support .. - destroyWindow(window); - return; - } - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - - MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); - Assert.assertNotNull(monitorMode); - - if(preFS) { - System.err.println("[0] set FS pre 0: "+window.isFullscreen()); - window.setFullscreen(true); - System.err.println("[0] set FS pre 1: "+window.isFullscreen()); - Assert.assertEquals(true, window.isFullscreen()); - System.err.println("[0] set FS pre X: "+window.isFullscreen()); - } - - System.err.println("[0] set current: "+monitorMode); - monitor.setCurrentMode(monitorMode); - - if(!preFS) { - System.err.println("[0] set FS post 0: "+window.isFullscreen()); - window.setFullscreen(true); - Assert.assertEquals(true, window.isFullscreen()); - System.err.println("[0] set FS post X: "+window.isFullscreen()); - } - - Thread.sleep(waitTimeLong); - - // check reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(true,window.isVisible()); - - animator.stop(); - Assert.assertEquals(false, animator.isAnimating()); - Assert.assertEquals(false, animator.isStarted()); - - destroyWindow(window); - Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isRealized()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - screen.destroy(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - cleanupGL(); - } - - public static void main(String args[]) throws IOException { - String tstname = TestScreenMode01dNEWT.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java deleted file mode 100644 index 6b12a6bed..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestScreenMode02aNEWT.java +++ /dev/null @@ -1,204 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import java.io.IOException; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; - -import com.jogamp.opengl.util.Animator; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jogamp.common.os.Platform; -import com.jogamp.newt.Display; -import com.jogamp.newt.MonitorDevice; -import com.jogamp.newt.NewtFactory; -import com.jogamp.newt.Screen; -import com.jogamp.newt.Window; -import com.jogamp.newt.MonitorMode; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.newt.util.MonitorModeUtil; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; -import java.util.List; -import javax.media.nativewindow.util.Dimension; - -/** - * Tests MonitorMode change w/ changed rotation. - *

    - * Also tests MonitorMode reset after last Screen is dereferenced, - * i.e. MonitorMode should be reinstated. - *

    - */ -public class TestScreenMode02aNEWT extends UITestCase { - static GLProfile glp; - static int width, height; - - static int waitTimeShort = 2000; // 2 sec - static int waitTimeLong = 8000; // 8 sec - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glp = GLProfile.getDefault(); - } - - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { - Assert.assertNotNull(caps); - caps.setOnscreen(onscreen); - - GLWindow window = GLWindow.create(screen, caps); - window.setSize(width, height); - window.addGLEventListener(new GearsES2()); - Assert.assertNotNull(window); - window.setVisible(true); - Assert.assertTrue(window.isVisible()); - return window; - } - - static void destroyWindow(Window window) { - if(null!=window) { - window.destroy(); - } - } - - @Test - public void testScreenRotationChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - - GLCapabilities caps = new GLCapabilities(glp); - Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display - Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 - Assert.assertNotNull(screen); - GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); - Assert.assertNotNull(window); - - MonitorDevice monitor = window.getMainMonitor(); - List monitorModes = monitor.getSupportedModes(); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); - destroyWindow(window); - return; - } - Assert.assertTrue(monitorModes.size()>0); - - Animator animator = new Animator(window); - animator.start(); - - MonitorMode mmCurrent = monitor.getCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); - Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); - if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { - // no rotation support .. - System.err.println("Your platform has no rotation support, sorry"); - destroyWindow(window); - return; - } - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - monitor.setCurrentMode(sm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); - - Thread.sleep(waitTimeLong); - - // check reset .. - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - Assert.assertEquals(true,window.isNativeValid()); - Assert.assertEquals(true,window.isVisible()); - - animator.stop(); - destroyWindow(window); - - Assert.assertEquals(false,window.isVisible()); - Assert.assertEquals(false,window.isNativeValid()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - screen.destroy(); - - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - } - - public static void main(String args[]) throws IOException { - String tstname = TestScreenMode02aNEWT.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } - -} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/ManualScreenMode03aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/ManualScreenMode03aNEWT.java new file mode 100644 index 000000000..464efa5bb --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/ManualScreenMode03aNEWT.java @@ -0,0 +1,114 @@ +/** + * Copyright 2011 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.mm; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.Animator; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Manual testing the ScreenImpl shutdown hook, + * which shall reset the ScreenMode to it's original state + * when the application exists (normal or ctrl-c). + */ +public class ManualScreenMode03aNEWT extends UITestCase { + static int waitTime = 7000; // 1 sec + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + caps.setOnscreen(onscreen); + + GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + window.setVisible(true); + return window; + } + + public void run() { + int width = 640; + int height = 480; + GLProfile glp = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(glp); + Display display = NewtFactory.createDisplay(null); // local display + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + + List monitorModes = screen.getMonitorModes(); + if(null==monitorModes) { + // no support .. + System.err.println("Your platform has no ScreenMode change support, sorry"); + return; + } + Animator animator = new Animator(window); + animator.start(); + + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + MonitorMode mmOrig = monitor.getOriginalMode(); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + + MonitorMode mm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+mm); + monitor.setCurrentMode(mm); + + System.err.print("[0] post setting .. wait <"); + try { + Thread.sleep(waitTime); + } catch (InterruptedException e) { + } + System.err.println("done>"); + System.exit(0); + } + + public static void main(String args[]) throws IOException { + ManualScreenMode03aNEWT t = new ManualScreenMode03aNEWT(); + t.run(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java new file mode 100644 index 000000000..123199427 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java @@ -0,0 +1,183 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.mm; + +import java.io.IOException; +import javax.media.nativewindow.NativeWindowFactory; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.util.ArrayHashSet; +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.Screen; +import com.jogamp.opengl.test.junit.util.UITestCase; +import java.util.Iterator; +import java.util.List; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.SurfaceSize; +import javax.media.opengl.GLProfile; + +import jogamp.newt.MonitorDeviceImpl; +import jogamp.newt.MonitorModeProps; + +/** + * Validating consistency of MonitorMode data from Screen (all modes) + * and from a particular MonitorDevice. + */ +public class TestScreenMode00aNEWT extends UITestCase { + static int screenIdx = 0; + static int width, height; + + static int waitTimeShort = 4; //1 sec + static int waitTimeLong = 6; //6 sec + + + + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(); // hack to initialize GL for BCM_IV (Rasp.Pi) + NativeWindowFactory.initSingleton(); + width = 640; + height = 480; + } + + @Test + public void testScreenModeInfo00() throws InterruptedException { + final DimensionImmutable res = new Dimension(640, 480); + final SurfaceSize surfsz = new SurfaceSize(res, 32); + final MonitorMode modeOut = new MonitorMode(surfsz, 60.0f, 0, 0); + System.err.println("00 out: "+modeOut); + final MonitorModeProps.Cache cache = new MonitorModeProps.Cache(); + cache.monitorModes.add(modeOut); + { + final int[] props = MonitorModeProps.streamOutMonitorMode(modeOut); + final MonitorMode modeIn = MonitorModeProps.streamInMonitorMode(null, cache, props, 0); + System.err.println("00 in : "+modeIn); + + Assert.assertEquals(modeOut.getSurfaceSize().getResolution(), modeIn.getSurfaceSize().getResolution()); + + Assert.assertEquals(modeOut.getSurfaceSize(), modeIn.getSurfaceSize()); + + Assert.assertEquals(modeOut.hashCode(), modeIn.hashCode()); + + Assert.assertEquals(modeOut, modeIn); + } + + final DimensionImmutable sizeMM = new Dimension(50, 50); + final Rectangle viewport = new Rectangle(0, 0, 1920, 1080); + final ArrayHashSet supportedModes = new ArrayHashSet(); + supportedModes.add(modeOut); + final MonitorDevice monOut = new MonitorDeviceImpl(null, -1, sizeMM, viewport, modeOut, supportedModes); + System.err.println("01 out : "+monOut); + cache.monitorDevices.add(monOut); + { + final int[] props = MonitorModeProps.streamOutMonitorDevice(monOut); + final MonitorDevice monIn = MonitorModeProps.streamInMonitorDevice(null, cache, null, props, 0); + System.err.println("01 in : "+monIn); + + Assert.assertEquals(monOut.getCurrentMode(), monOut.getOriginalMode()); + Assert.assertEquals(monOut.getSupportedModes(), monIn.getSupportedModes()); + Assert.assertEquals(monOut.getViewport(), monIn.getViewport()); + Assert.assertEquals(monOut.getOriginalMode(), monIn.getOriginalMode()); + Assert.assertEquals(monOut.getCurrentMode(), monIn.getCurrentMode()); + Assert.assertEquals(monOut.hashCode(), monIn.hashCode()); + Assert.assertEquals(monOut, monIn); + } + } + + @Test + public void testScreenModeInfo01() throws InterruptedException { + Display dpy = NewtFactory.createDisplay(null); + Screen screen = NewtFactory.createScreen(dpy, screenIdx); + screen.addReference(); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,screen.getDisplay().isNativeValid()); + System.err.println("Screen: "+screen.toString()); + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + { + int i=0; + for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { + System.err.println("All["+i+"]: "+iMode.next()); + } + } + + List monitors = screen.getMonitorDevices(); + Assert.assertTrue(monitors.size()>0); + int j=0; + for(Iterator iMonitor=monitors.iterator(); iMonitor.hasNext(); j++) { + MonitorDevice monitor = iMonitor.next(); + System.err.println(j+": "+monitor); + List modes = monitor.getSupportedModes(); + Assert.assertTrue(modes.size()>0); + int i=0; + for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { + System.err.println("["+j+"]["+i+"]: "+iMode.next()); + } + Assert.assertTrue(allMonitorModes.containsAll(modes)); + + MonitorMode sm_o = monitor.getOriginalMode(); + Assert.assertNotNull(sm_o); + MonitorMode sm_c = monitor.queryCurrentMode(); + System.err.println("[0] orig : "+sm_o); + System.err.println("[0] current: "+sm_c); + Assert.assertNotNull(sm_c); + Assert.assertEquals(sm_o, sm_c); + } + + screen.removeReference(); + + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,screen.getDisplay().isNativeValid()); + } + + static int atoi(String a) { + try { + return Integer.parseInt(a); + } catch (Exception ex) { throw new RuntimeException(ex); } + } + + public static void main(String args[]) throws IOException { + for(int i=0; i screenModes = screen.getMonitorModes(); + Assert.assertTrue(screenModes.size()>0); + int i=0; + for(Iterator iter=screenModes.iterator(); iter.hasNext(); i++) { + System.err.println(i+": "+iter.next()); + } + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mm_o = monitor.getOriginalMode(); + + Assert.assertNotNull(mm_o); + MonitorMode mm_c = monitor.queryCurrentMode(); + Assert.assertNotNull(mm_c); + System.err.println("orig: "+mm_o); + System.err.println("curr: "+mm_c); + + for(i=0; i<50; i++) { + mm_c = monitor.queryCurrentMode(); + Assert.assertNotNull(mm_c); + System.err.print("."+i); + } + System.err.println("!"); + + // screen.removeReference(); + anim.stop(); + window.destroy(); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode00bNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java new file mode 100644 index 000000000..f431e099b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java @@ -0,0 +1,218 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.mm; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + *

    + * Tests MonitorMode reset, by destroying the last Screen (reference), + * i.e. the original MonitorMode should get reinstated! + *

    + *

    + * Documents remedy B) for NV RANDR/GL bug + *

    + * + * @see TestScreenMode01dNEWT#cleanupGL() + */ +public class TestScreenMode01aNEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static int waitTimeShort = 2000; + static int waitTimeLong = 2000; + + @BeforeClass + public static void initClass() { + width = 100; + height = 100; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static Window createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) { + Assert.assertNotNull(caps); + + GLWindow window = GLWindow.create(screen, caps); + // Window window = NewtFactory.createWindow(screen, caps); + window.setTitle(name); + window.setPosition(x, y); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testScreenModeChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height); + Assert.assertNotNull(window0); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + if(allMonitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (all), sorry"); + destroyWindow(window0); + return; + } + + MonitorDevice monitor = window0.getMainMonitor(); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); + destroyWindow(window0); + return; + } + Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); + + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode mm = monitorModes.get(0); + System.err.println("[0] set current: "+mm); + Assert.assertTrue(monitor.setCurrentMode(mm)); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(mm, monitor.queryCurrentMode()); + + Thread.sleep(waitTimeShort); + + // check manual reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window0.isNativeValid()); + Assert.assertEquals(true,window0.isVisible()); + + screen.addReference(); // keep it alive ! + Assert.assertTrue(monitor.setCurrentMode(mmOrig)); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Assert.assertNotSame(mm, monitor.getCurrentMode()); + Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); + + destroyWindow(window0); + Assert.assertEquals(false,window0.isVisible()); + Assert.assertEquals(false,window0.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); // alive ! + Assert.assertEquals(true,display.isNativeValid()); + + Thread.sleep(waitTimeShort); + + Window window1 = createWindow(screen, caps, "win1", + width+window0.getInsets().getTotalWidth(), 0, + width, height); + Assert.assertNotNull(window1); + Assert.assertEquals(true,window1.isNativeValid()); + Assert.assertEquals(true,window1.isVisible()); + + Thread.sleep(waitTimeShort); + + destroyWindow(window1); + Assert.assertEquals(false,window1.isNativeValid()); + Assert.assertEquals(false,window1.isVisible()); + + screen.removeReference(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode01aNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java new file mode 100644 index 000000000..c80760c1f --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java @@ -0,0 +1,249 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.mm; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.RectangleImmutable; + +/** + * Mode change on separate monitors .. + */ +public class TestScreenMode01bNEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static long waitTimeShort = 2000; + static long duration = 6000; + + @BeforeClass + public static void initClass() { + width = 200; + height = 200; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) throws InterruptedException { + Assert.assertNotNull(caps); + + GLWindow window = GLWindow.create(screen, caps); + // Window window = NewtFactory.createWindow(screen, caps); + window.setTitle(name); + window.setPosition(x, y); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + final long t0 = System.currentTimeMillis(); + window.setVisible(true); + System.err.println("Time for visible/pos: "+(System.currentTimeMillis()-t0)+" ms"); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testScreenModeChangeSingleQ1() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport(); + testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY()); + } finally { + screen.removeReference(); + } + } + + @Test + public void testScreenModeChangeSingleQ2() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + if( 2 > screen.getMonitorDevices().size() ) { + System.err.println("Test Disabled (1): Monitor count < 2: "+screen); + return; + } + RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); + testScreenModeChangeImpl(screen, monitorVp.getX(), monitorVp.getY()); + } finally { + screen.removeReference(); + } + } + + void testScreenModeChangeImpl(final Screen screen, int xpos, int ypos) throws InterruptedException { + Thread.sleep(waitTimeShort); + + final GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + final Display display = screen.getDisplay(); + System.err.println("Test.0: Window screen: "+screen); + + System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); + + GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); + Assert.assertNotNull(window0); + System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + + final Animator anim = new Animator(window0); + anim.start(); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + if(allMonitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (all), sorry"); + destroyWindow(window0); + return; + } + + MonitorDevice monitor = window0.getMainMonitor(); + System.err.println("Test.0: Window monitor: "+monitor); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); + destroyWindow(window0); + return; + } + Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); + + MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[1] set current: "+sm); + Assert.assertTrue(monitor.setCurrentMode(sm)); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current: "+mmCurrent); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + System.err.println("Test.1: Window screen: "+screen); + System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.1: Window monitor: "+window0.getMainMonitor()); + + Thread.sleep(duration); + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window0.isNativeValid()); + Assert.assertEquals(true,window0.isVisible()); + + Assert.assertTrue(monitor.setCurrentMode(mmOrig)); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Assert.assertNotSame(sm, monitor.getCurrentMode()); + Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); + + System.err.println("Test.2: Window screen: "+screen); + System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.2: Window monitor: "+window0.getMainMonitor()); + + Thread.sleep(duration); + anim.stop(); + destroyWindow(window0); + Assert.assertEquals(false,window0.isVisible()); + Assert.assertEquals(false,window0.isNativeValid()); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i screen.getMonitorDevices().size() ) { + System.err.println("Test Disabled (1): Monitor count < 2: "+screen); + return; + } + RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); + testScreenFullscreenImpl(screen, monitorVp.getX(), monitorVp.getY(), false, null); + } finally { + screen.removeReference(); + } + } + + @Test + public void testScreenFullscreenSpanQ1Q2() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + final int crtCount = screen.getMonitorDevices().size(); + if( 2 >= crtCount ) { + System.err.println("Test Disabled (2): Spanning monitor count "+2+" >= screen monitor count: "+screen); + return; + } + final ArrayList monitors = new ArrayList(); + monitors.add(screen.getMonitorDevices().get(0)); // Q1 + monitors.add(screen.getMonitorDevices().get(1)); // Q2 + RectangleImmutable monitorVp = screen.getMonitorDevices().get(0).getViewport(); + testScreenFullscreenImpl(screen, monitorVp.getX()+50, monitorVp.getY()+50, true, monitors); + } finally { + screen.removeReference(); + } + } + + @Test + public void testScreenFullscreenSpanALL() throws InterruptedException { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); // trigger creation + try { + if( 2 > screen.getMonitorDevices().size() ) { + System.err.println("Test Disabled (3): Monitor count < 2: "+screen); + return; + } + RectangleImmutable monitorVp = screen.getMonitorDevices().get(1).getViewport(); + testScreenFullscreenImpl(screen, monitorVp.getX()-50, monitorVp.getY()+50, true, null); + } finally { + screen.removeReference(); + } + } + + void testScreenFullscreenImpl(final Screen screen, int xpos, int ypos, boolean spanAcrossMonitors, List monitors) throws InterruptedException { + Thread.sleep(waitTimeShort); + + final GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + final Display display = screen.getDisplay(); + + System.err.println("Test.0: Window screen: "+screen); + + System.err.println("Test.0: Window bounds (pre): "+xpos+"/"+ypos+" "+width+"x"+height+" within "+screen.getViewport()); + + GLWindow window0 = createWindow(screen, caps, "win0", xpos, ypos, width, height); + Assert.assertNotNull(window0); + System.err.println("Test.0: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + + final Animator anim = new Animator(window0); + anim.start(); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + + MonitorDevice monitor = window0.getMainMonitor(); + System.err.println("Test.0: Window monitor: "+monitor); + if( !spanAcrossMonitors ) { + window0.setFullscreen(true); + } else { + window0.setFullscreen(monitors); + } + + monitor = window0.getMainMonitor(); + System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.1: Window monitor: "+monitor.getViewport()); + Rectangle window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight()); + if( !spanAcrossMonitors ) { + Assert.assertEquals(monitor.getViewport(), window0Rect); + } else { + List monitorsUsed = monitors; + if( null == monitorsUsed ) { + monitorsUsed = window0.getScreen().getMonitorDevices(); + } + Rectangle monitorsUsedViewport = MonitorDevice.unionOfViewports(new Rectangle(), monitorsUsed); + Assert.assertEquals(monitorsUsedViewport, window0Rect); + } + + Thread.sleep(duration); + + window0.setFullscreen(false); + + window0Rect = new Rectangle(window0.getX(), window0.getY(), window0.getWidth(), window0.getHeight()); + monitor = window0.getMainMonitor(); + System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); + System.err.println("Test.2: Window monitor: "+monitor.getViewport()); + + Thread.sleep(duration); + anim.stop(); + destroyWindow(window0); + Assert.assertEquals(false,window0.isVisible()); + Assert.assertEquals(false,window0.isNativeValid()); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i + * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.

    + */ +public class TestScreenMode01dNEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static int waitTimeShort = 2000; // 2 sec + static int waitTimeLong = 8000; // 8 sec + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + /** + * Following configurations results in a SIGSEGV: + *
    +     *   Ubuntu 11.04 (natty), NV GTX 460, driver [280.10* - 285.03]
    +     * 
    + * + * Situation: + *
    +     *   1 - Create Screen, GLWindow (w/ context)
    +     *   2 - ScreenMode change
    +     *   3 - Destroy GLWindow (w/ context), Screen
    +     *   4 - Create  Screen, GLWindow (w/ context) (*)
    +     * 
    + * + * Step 4 causes the exception within 1st 'glXMakeContextCurrent(..)' call + * on the the created GL context. + * + * Remedy: + *
    +     *   A) Releasing all resources before step 4 .. works.
    +     *   B) Holding the native Display/Screen in NEWT also works (ie screen.addReference()).
    +     * 
    + * + * Hence there must be some correlations with the screen randr mode + * and some of the glcontext/gldrawables. + * + *
    +     * Remedy A) is demonstrated here
    +     * Remedy B) is shown in {@link TestScreenMode01bNEWT}
    +     * 
    + */ + private void cleanupGL() throws InterruptedException { + System.err.println("*** cleanupGL.shutdown"); + GLProfile.shutdown(); + System.err.println("*** cleanupGL.initSingleton"); + GLProfile.initSingleton(); + System.err.println("*** cleanupGL.DONE"); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + Assert.assertNotNull(caps); + caps.setOnscreen(onscreen); + + GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testFullscreenChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Animator animator = new Animator(window); + animator.start(); + + final MonitorDevice monitor = window.getMainMonitor(); + + Assert.assertEquals(false, window.isFullscreen()); + Assert.assertEquals(width, window.getWidth()); + Assert.assertEquals(height, window.getHeight()); + + window.setFullscreen(true); + Assert.assertEquals(true, window.isFullscreen()); + Assert.assertEquals(monitor.getViewport().getWidth(), window.getWidth()); + Assert.assertEquals(monitor.getViewport().getHeight(), window.getHeight()); + + Thread.sleep(waitTimeShort); + + window.setFullscreen(false); + Assert.assertEquals(false, window.isFullscreen()); + Assert.assertEquals(width, window.getWidth()); + Assert.assertEquals(height, window.getHeight()); + + Thread.sleep(waitTimeShort); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + Assert.assertEquals(false, window.isRealized()); + Assert.assertEquals(false, window.isNativeValid()); + + cleanupGL(); + } + + @Test + public void testScreenModeChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Assert.assertNotNull(window); + + MonitorDevice monitor = window.getMainMonitor(); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support, sorry"); + destroyWindow(window); + return; + } + + Animator animator = new Animator(window); + animator.start(); + + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+sm); + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + Thread.sleep(waitTimeLong); + + // check reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isRealized()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + screen.createNative(); // trigger native re-creation + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); + screen.destroy(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + cleanupGL(); + } + + @Test + public void testScreenModeChangeWithFS01Pre() throws InterruptedException { + Thread.sleep(waitTimeShort); + testScreenModeChangeWithFS01Impl(true) ; + } + + @Test + public void testScreenModeChangeWithFS01Post() throws InterruptedException { + Thread.sleep(waitTimeShort); + testScreenModeChangeWithFS01Impl(false) ; + } + + protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException { + GLCapabilities caps = new GLCapabilities(glp); + Display display = NewtFactory.createDisplay(null); // local display + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Animator animator = new Animator(window); + animator.start(); + + MonitorDevice monitor = window.getMainMonitor(); + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { + // no support .. + destroyWindow(window); + return; + } + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + + MonitorMode monitorMode = (MonitorMode) monitorModes.get(0); + Assert.assertNotNull(monitorMode); + + if(preFS) { + System.err.println("[0] set FS pre 0: "+window.isFullscreen()); + window.setFullscreen(true); + System.err.println("[0] set FS pre 1: "+window.isFullscreen()); + Assert.assertEquals(true, window.isFullscreen()); + System.err.println("[0] set FS pre X: "+window.isFullscreen()); + } + + System.err.println("[0] set current: "+monitorMode); + monitor.setCurrentMode(monitorMode); + + if(!preFS) { + System.err.println("[0] set FS post 0: "+window.isFullscreen()); + window.setFullscreen(true); + Assert.assertEquals(true, window.isFullscreen()); + System.err.println("[0] set FS post X: "+window.isFullscreen()); + } + + Thread.sleep(waitTimeLong); + + // check reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + Assert.assertEquals(false, animator.isStarted()); + + destroyWindow(window); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isRealized()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + screen.createNative(); // trigger native re-creation + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); + screen.destroy(); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + cleanupGL(); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode01dNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java new file mode 100644 index 000000000..37ea499df --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java @@ -0,0 +1,204 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.mm; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import com.jogamp.opengl.util.Animator; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.os.Platform; +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Tests MonitorMode change w/ changed rotation. + *

    + * Also tests MonitorMode reset after last Screen is dereferenced, + * i.e. MonitorMode should be reinstated. + *

    + */ +public class TestScreenMode02aNEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static int waitTimeShort = 2000; // 2 sec + static int waitTimeLong = 8000; // 8 sec + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { + Assert.assertNotNull(caps); + caps.setOnscreen(onscreen); + + GLWindow window = GLWindow.create(screen, caps); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + Assert.assertTrue(window.isVisible()); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testScreenRotationChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); + Assert.assertNotNull(window); + + MonitorDevice monitor = window.getMainMonitor(); + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no ScreenMode change support, sorry"); + destroyWindow(window); + return; + } + Assert.assertTrue(monitorModes.size()>0); + + Animator animator = new Animator(window); + animator.start(); + + MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); + if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { + // no rotation support .. + System.err.println("Your platform has no rotation support, sorry"); + destroyWindow(window); + return; + } + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+sm); + monitor.setCurrentMode(sm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(sm, monitor.queryCurrentMode()); + + Thread.sleep(waitTimeLong); + + // check reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + destroyWindow(window); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + + screen.createNative(); // trigger native re-creation + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] current/orig: "+mmCurrent); + + Assert.assertNotNull(mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + screen.destroy(); + + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode02aNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + +} -- cgit v1.2.3 From 1c717a781702b0decb0c4da71a9dadc2a8255d5b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 30 Jun 2013 03:52:16 +0200 Subject: Add Comparable: Point*, Dimension*, Rectangle*, SurfaceSize* and MonitorMode* ; Sort List in descending order to be well determined. Add Comparable: Point*, Dimension*, Rectangle*, SurfaceSize* and MonitorMode*: - Compare square values - See API doc for order of special semantics (flags, rotation, ..) Sort List in descending order to be well determined: - Removes order by native mode id, give user a reliable natural order. --- make/scripts/tests.sh | 5 +- .../javax/media/nativewindow/util/Dimension.java | 13 +++ .../nativewindow/util/DimensionImmutable.java | 11 +- .../javax/media/nativewindow/util/Point.java | 13 +++ .../media/nativewindow/util/PointImmutable.java | 11 +- .../javax/media/nativewindow/util/Rectangle.java | 25 +++++ .../nativewindow/util/RectangleImmutable.java | 11 +- .../javax/media/nativewindow/util/SurfaceSize.java | 26 ++++- .../classes/com/jogamp/newt/MonitorDevice.java | 4 + src/newt/classes/com/jogamp/newt/MonitorMode.java | 115 +++++++++++++++++++-- src/newt/classes/com/jogamp/newt/Screen.java | 4 + .../com/jogamp/newt/util/MonitorModeUtil.java | 11 ++ src/newt/classes/jogamp/newt/ScreenImpl.java | 8 +- .../test/junit/newt/mm/TestScreenMode00aNEWT.java | 34 +++++- 14 files changed, 271 insertions(+), 20 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 84e536017..5acced4af 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -284,7 +284,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -400,13 +400,14 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index 4fae98f08..b52414146 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -84,6 +84,19 @@ public class Dimension implements Cloneable, DimensionImmutable { return new String(width+" x "+height); } + @Override + public int compareTo(final DimensionImmutable d) { + final int tsq = width*height; + final int xsq = d.getWidth()*d.getHeight(); + + if(tsq > xsq) { + return 1; + } else if(tsq < xsq) { + return -1; + } + return 0; + } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java index d14e94c10..22bd3f48b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java @@ -37,12 +37,21 @@ import com.jogamp.common.type.WriteCloneable; *
  • height
  • * */ -public interface DimensionImmutable extends WriteCloneable { +public interface DimensionImmutable extends WriteCloneable, Comparable { int getHeight(); int getWidth(); + /** + *

    + * Compares square of size. + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final DimensionImmutable d); + /** * Checks whether two dimensions objects are equal. Two instances * of DimensionReadOnly are equal if two components diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index 8e6caf72b..a30d3030e 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -54,6 +54,19 @@ public class Point implements Cloneable, PointImmutable { } } + @Override + public int compareTo(final PointImmutable d) { + final int sq = x*y; + final int xsq = d.getX()*d.getY(); + + if(sq > xsq) { + return 1; + } else if(sq < xsq) { + return -1; + } + return 0; + } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java index d7eb0e7b4..b00329bb5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java @@ -32,12 +32,21 @@ package javax.media.nativewindow.util; import com.jogamp.common.type.WriteCloneable; /** Immutable Point interface */ -public interface PointImmutable extends WriteCloneable { +public interface PointImmutable extends WriteCloneable, Comparable { int getX(); int getY(); + /** + *

    + * Compares the square of the position. + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final PointImmutable d); + /** * Checks whether two points objects are equal. Two instances * of PointReadOnly are equal if the two components diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 8e6fc8e36..7576f4ec7 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -142,6 +142,31 @@ public class Rectangle implements Cloneable, RectangleImmutable { return sqI / sqT; } + @Override + public int compareTo(final RectangleImmutable d) { + { + final int sq = width*height; + final int xsq = d.getWidth()*d.getHeight(); + + if(sq > xsq) { + return 1; + } else if(sq < xsq) { + return -1; + } + } + { + final int sq = x*y; + final int xsq = d.getX()*d.getY(); + + if(sq > xsq) { + return 1; + } else if(sq < xsq) { + return -1; + } + } + return 0; + } + @Override public boolean equals(Object obj) { if(this == obj) { return true; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java index 7531989de..440d9e000 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java @@ -31,7 +31,7 @@ package javax.media.nativewindow.util; import com.jogamp.common.type.WriteCloneable; /** Immutable Rectangle interface */ -public interface RectangleImmutable extends WriteCloneable { +public interface RectangleImmutable extends WriteCloneable, Comparable { int getHeight(); @@ -61,6 +61,15 @@ public interface RectangleImmutable extends WriteCloneable { */ float coverage(RectangleImmutable r); + /** + *

    + * Compares square of size 1st, if equal the square of position. + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final RectangleImmutable d); + /** * Checks whether two rect objects are equal. Two instances * of Rectangle are equal if the four integer values diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index d7e451af8..3084816a5 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -29,13 +29,14 @@ package javax.media.nativewindow.util; -/** Immutable SurfaceSize Class, consisting of it's read only components:
    +/** + * Immutable SurfaceSize Class, consisting of it's read only components:
    *
      *
    • {@link javax.media.nativewindow.util.DimensionImmutable} size in pixels
    • *
    • bits per pixel
    • *
    */ -public class SurfaceSize { +public class SurfaceSize implements Comparable { final DimensionImmutable resolution; final int bitsPerPixel; @@ -59,6 +60,27 @@ public class SurfaceSize { return new String("[ "+resolution+" x "+bitsPerPixel+" bpp ]"); } + /** + *

    + * Compares {@link DimensionImmutable#compareTo(DimensionImmutable) resolution} 1st, if equal the bitsPerPixel. + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final SurfaceSize ssz) { + final int rres = resolution.compareTo(ssz.getResolution()); + if( 0 != rres ) { + return rres; + } + final int xbpp = ssz.getBitsPerPixel(); + if(bitsPerPixel > xbpp) { + return 1; + } else if(bitsPerPixel < xbpp) { + return -1; + } + return 0; + } + /** * Checks whether two size objects are equal. Two instances * of SurfaceSize are equal if the two components diff --git a/src/newt/classes/com/jogamp/newt/MonitorDevice.java b/src/newt/classes/com/jogamp/newt/MonitorDevice.java index 4b0a760a4..8bc7f40e3 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorDevice.java +++ b/src/newt/classes/com/jogamp/newt/MonitorDevice.java @@ -129,6 +129,10 @@ public abstract class MonitorDevice { /** * Returns a list of immutable {@link MonitorMode}s supported by this monitor. *

    + * The list is ordered in descending order, + * see {@link MonitorMode#compareTo(MonitorMode)}. + *

    + *

    * Use w/ care, it's not a copy! *

    */ diff --git a/src/newt/classes/com/jogamp/newt/MonitorMode.java b/src/newt/classes/com/jogamp/newt/MonitorMode.java index 914aa880f..dc7ae2c03 100644 --- a/src/newt/classes/com/jogamp/newt/MonitorMode.java +++ b/src/newt/classes/com/jogamp/newt/MonitorMode.java @@ -28,6 +28,8 @@ package com.jogamp.newt; +import java.util.Comparator; + import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.RectangleImmutable; import javax.media.nativewindow.util.SurfaceSize; @@ -108,22 +110,36 @@ import com.jogamp.newt.util.MonitorModeUtil; monitor.setCurrentMode(mm); * */ -public class MonitorMode { +public class MonitorMode implements Comparable { + + /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the ascending order. */ + public static final Comparator monitorModeComparator = new Comparator() { + public int compare(MonitorMode mm1, MonitorMode mm2) { + return mm1.compareTo(mm2); + } }; + + /** Comparator for 2 {@link MonitorMode}s, following comparison order as described in {@link MonitorMode#compareTo(MonitorMode)}, returning the descending order. */ + public static final Comparator monitorModeComparatorInv = new Comparator() { + public int compare(MonitorMode mm1, MonitorMode mm2) { + return mm2.compareTo(mm1); + } }; + /** - * Immutable surfaceSize and refreshRate Class, consisting of it's read only components:
    + * Immutable surfaceSize, flags and refreshRate Class, consisting of it's read only components:
    *
      *
    • nativeId
    • *
    • {@link SurfaceSize} surface memory size
    • + *
    • flags
    • *
    • refresh rate
    • *
    */ - public static class SizeAndRRate { + public static class SizeAndRRate implements Comparable { /** Non rotated surface size */ public final SurfaceSize surfaceSize; - /** Vertical refresh rate */ - public final float refreshRate; /** Mode bitfield flags, i.e. {@link #FLAG_DOUBLESCAN}, {@link #FLAG_INTERLACE}, .. */ public final int flags; + /** Vertical refresh rate */ + public final float refreshRate; public final int hashCode; public SizeAndRRate(SurfaceSize surfaceSize, float refreshRate, int flags) { @@ -131,8 +147,8 @@ public class MonitorMode { throw new IllegalArgumentException("surfaceSize must be set ("+surfaceSize+")"); } this.surfaceSize=surfaceSize; - this.refreshRate=refreshRate; this.flags = flags; + this.refreshRate=refreshRate; this.hashCode = getHashCode(); } @@ -160,6 +176,49 @@ public class MonitorMode { return new String(surfaceSize+" @ "+refreshRate+" Hz, flags ["+flags2String(flags).toString()+"]"); } + /** + *

    + * Compares {@link SurfaceSize#compareTo(SurfaceSize) surfaceSize} 1st, then {@link #flags}, then {@link #refreshRate}. + *

    + *

    + * Flags are compared as follows: + *

    +         *   NONE > DOUBLESCAN > INTERLACE
    +         * 
    + *

    + *

    + * Refresh rate differences of < 0.01 are considered equal (epsilon). + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final SizeAndRRate sszr) { + final int rssz = surfaceSize.compareTo(sszr.surfaceSize); + if( 0 != rssz ) { + return rssz; + } + final int tflags = 0 == flags ? Integer.MAX_VALUE : flags; // normalize NONE + final int xflags = 0 == sszr.flags ? Integer.MAX_VALUE : sszr.flags; // normalize NONE + if( tflags == xflags ) { + final float refreshEpsilon = 0.01f; // reasonable sorting granularity of refresh rate + final float drate = refreshRate - sszr.refreshRate; + if( Math.abs(drate) < refreshEpsilon ) { + return 0; + } else if( drate > refreshEpsilon ) { + return 1; + } else { + return -1; + } + } else { + if(tflags > xflags) { + return 1; + } else if(tflags < xflags) { + return -1; + } + return 0; + } + } + /** * Tests equality of two {@link SizeAndRRate} objects * by evaluating equality of it's components:
    @@ -174,8 +233,8 @@ public class MonitorMode { if (obj instanceof SizeAndRRate) { final SizeAndRRate p = (SizeAndRRate)obj; return surfaceSize.equals(p.surfaceSize) && - refreshRate == p.refreshRate && - flags == p.flags ; + flags == p.flags && + refreshRate == p.refreshRate ; } return false; } @@ -184,8 +243,8 @@ public class MonitorMode { * Returns a combined hash code of it's elements:
    *
      *
    • surfaceSize
    • - *
    • refreshRate
    • *
    • flags
    • + *
    • refreshRate
    • *
    */ public final int hashCode() { @@ -194,8 +253,8 @@ public class MonitorMode { private final int getHashCode() { // 31 * x == (x << 5) - x int hash = 31 + surfaceSize.hashCode(); - hash = ((hash << 5) - hash) + (int)(refreshRate*100.0f); hash = ((hash << 5) - hash) + flags; + hash = ((hash << 5) - hash) + (int)(refreshRate*100.0f); return hash; } } @@ -305,6 +364,42 @@ public class MonitorMode { return "[Id "+Display.toHexString(nativeId)+", " + sizeAndRRate + ", " + rotation + " degr]"; } + /** + *

    + * Compares {@link SizeAndRRate#compareTo(SizeAndRRate) sizeAndRRate} 1st, then {@link #rotation}. + *

    + *

    + * Rotation is compared inverted, i.e. 360 - rotation, + * so the lowest rotation reflects a higher value. + *

    + *

    + * Order of comparing MonitorMode: + *

      + *
    • resolution
    • + *
    • bits per pixel
    • + *
    • flags
    • + *
    • refresh rate
    • + *
    • rotation
    • + *
    + *

    + * {@inheritDoc} + */ + @Override + public int compareTo(final MonitorMode mm) { + final int c = sizeAndRRate.compareTo(mm.sizeAndRRate); + if( 0 != c ) { + return c; + } + final int trot = 360 - rotation; // normalize rotation + final int xrot = 360 - mm.rotation; // normalize rotation + if(trot > xrot) { + return 1; + } else if(trot < xrot) { + return -1; + } + return 0; + } + /** * Tests equality of two {@link MonitorMode} objects * by evaluating equality of it's components:
    diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index f56aff964..9b349b527 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -164,6 +164,10 @@ public abstract class Screen { /** * Return a list of all {@link MonitorMode}s for all {@link MonitorDevice}s. + *

    + * The list is ordered in descending order, + * see {@link MonitorMode#compareTo(MonitorMode)}. + *

    */ public abstract List getMonitorModes(); diff --git a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java index 16ffe754f..c30b427d6 100644 --- a/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/MonitorModeUtil.java @@ -31,7 +31,9 @@ package com.jogamp.newt.util; import com.jogamp.newt.MonitorMode; import java.util.ArrayList; +import java.util.Collections; import java.util.List; + import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.SurfaceSize; @@ -68,6 +70,15 @@ public class MonitorModeUtil { return null; } + /** Sort the given {@link MonitorMode} collection w/ {@link MonitorMode#compareTo(MonitorMode)} function. */ + public static void sort(List monitorModes, boolean ascendingOrder) { + if( ascendingOrder ) { + Collections.sort(monitorModes); + } else { + Collections.sort(monitorModes, MonitorMode.monitorModeComparatorInv); + } + } + /** * * @param monitorModes diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index f63d1499e..28f3e876c 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -52,6 +52,7 @@ import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.event.MonitorEvent; import com.jogamp.newt.event.MonitorModeListener; +import com.jogamp.newt.util.MonitorModeUtil; public abstract class ScreenImpl extends Screen implements MonitorModeListener { protected static final boolean DEBUG_TEST_SCREENMODE_DISABLED = Debug.isPropertyDefined("newt.test.Screen.disableScreenMode", true); @@ -536,6 +537,11 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { final MonitorDevice monitor = getVirtualMonitorDevice(cache, 0, mode); cache.monitorDevices.getOrAdd(monitor); } + // Sort MonitorModes (all and per device) in descending order - default! + MonitorModeUtil.sort(cache.monitorModes.getData(), false /* ascendingOrder*/); + for(Iterator iMonitor=cache.monitorDevices.iterator(); iMonitor.hasNext(); ) { + MonitorModeUtil.sort(iMonitor.next().getSupportedModes(), false /* ascendingOrder*/); + } if(DEBUG) { int i=0; for(Iterator iMode=cache.monitorModes.iterator(); iMode.hasNext(); i++) { @@ -550,7 +556,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("["+i+"]["+j+"]: "+iMode.next()); } } - } + } sms = new ScreenMonitorState(cache.monitorDevices, cache.monitorModes); ScreenMonitorState.mapScreenMonitorState(this.getFQName(), sms); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java index 123199427..7a15971d5 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00aNEWT.java @@ -41,7 +41,9 @@ import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.MonitorMode; import com.jogamp.newt.Screen; +import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.util.UITestCase; + import java.util.Iterator; import java.util.List; import javax.media.nativewindow.util.Dimension; @@ -56,6 +58,9 @@ import jogamp.newt.MonitorModeProps; /** * Validating consistency of MonitorMode data from Screen (all modes) * and from a particular MonitorDevice. + *

    + * Also validates the descending order of the given MonitorMode lists. + *

    */ public class TestScreenMode00aNEWT extends UITestCase { static int screenIdx = 0; @@ -130,8 +135,27 @@ public class TestScreenMode00aNEWT extends UITestCase { Assert.assertTrue(allMonitorModes.size()>0); { int i=0; + MonitorMode mmPre = null; + for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { + final MonitorMode mm = iMode.next(); + System.err.println(String.format("All-0[%03d]: %s", i, mm)); + if( null != mmPre ) { + Assert.assertTrue("Wrong order", mmPre.compareTo(mm) >= 0); + } + mmPre = mm; + } + } + MonitorModeUtil.sort(allMonitorModes, true /* ascendingOrder*/); + { + int i=0; + MonitorMode mmPre = null; for(Iterator iMode=allMonitorModes.iterator(); iMode.hasNext(); i++) { - System.err.println("All["+i+"]: "+iMode.next()); + final MonitorMode mm = iMode.next(); + System.err.println(String.format("All-1[%03d]: %s", i, mm)); + if( null != mmPre ) { + Assert.assertTrue("Wrong order", mmPre.compareTo(mm) <= 0); + } + mmPre = mm; } } @@ -144,8 +168,14 @@ public class TestScreenMode00aNEWT extends UITestCase { List modes = monitor.getSupportedModes(); Assert.assertTrue(modes.size()>0); int i=0; + MonitorMode mmPre = null; for(Iterator iMode=modes.iterator(); iMode.hasNext(); i++) { - System.err.println("["+j+"]["+i+"]: "+iMode.next()); + final MonitorMode mm = iMode.next(); + System.err.println(String.format("[%02d][%03d]: %s", j, i, mm)); + if( null != mmPre ) { + Assert.assertTrue("Wrong order", mmPre.compareTo(mm) >= 0); + } + mmPre = mm; } Assert.assertTrue(allMonitorModes.containsAll(modes)); -- cgit v1.2.3 From 205a17de1abec614d3d06386f873170fc1691e86 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Jul 2013 15:10:20 +0200 Subject: Fix Bug 770 and 771 Bug 770: X11Window.c: - Request focus _before_ enabling EWMH flags (fullscreen or above) after resize and temporary invisibility. This actually allows us to keep the focus after resize and repositioning! - Set _NET_WM_BYPASS_COMPOSITOR implicit analog to _NET_WM_STATE_FLAG_ABOVE - Clean up _NET_WM_* flag names, avoiding name space collisions, i.e. adding FLAG! - Remove dead _NET_WM_STATE setting via direct window property (not working anyways) - Remove dead code: FS_GRAB_KEYBOARD X11/WindowDriver.java: - Enable _NET_WM_STATE_FLAG_ABOVE temporarily if FLAG_IS_FULLSCREEN && !FLAG_IS_ALWAYSONTOP - Override focusChanged(..) to react on focus lost/gained in case of temporarily enabled _NET_WM_STATE_FLAG_ABOVE. If focus is lost, disable _NET_WM_STATE_FLAG_ABOVE, otherwise re-enable it. WindowImpl.java: - FullscreenAction.run: Always use 'FLAG_IS_FULLSCREEN_SPAN' +++ Bug 771: WindowImpl.java: - Keep fullscreenMonitors and fullscreenUseMainMonitor values intact, allowing them to be tracked. Remove duplicates in FullscreenAction class. - MonitorModeListenerImpl.monitorModeChanged: Add fullscreen path: If the changed monitor is part of fullscreenMonitors, recalculate the viewport union and reset position and fullscreen-size. - MonitorModeListenerImpl: Try to regain focus after successful mode change. --- make/scripts/tests-win.bat | 5 +- make/scripts/tests.sh | 9 +- src/newt/classes/jogamp/newt/WindowImpl.java | 98 +++++++----- .../jogamp/newt/driver/x11/WindowDriver.java | 38 ++++- src/newt/native/X11Window.c | 159 +++++++----------- .../test/junit/newt/mm/TestScreenMode02aNEWT.java | 177 ++++++++++++--------- 6 files changed, 265 insertions(+), 221 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 17ac9c784..a5d368c48 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -61,7 +61,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* @@ -119,7 +119,8 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02sNEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5acced4af..c0d15b84b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -135,7 +135,8 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" - #D_ARGS="-Dnewt.debug.Screen" + #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -175,7 +176,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -400,13 +401,13 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 77ff21061..600035bf6 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -372,9 +372,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(isFullscreen()) { synchronized(fullScreenAction) { fullscreen = false; // trigger a state change - fullScreenAction.init(true, fullscreenUseMainMonitor, fullscreenMonitors); - fullscreenMonitors = null; // release references ASAP - fullscreenUseMainMonitor = true; + fullScreenAction.init(true); fullScreenAction.run(); } } else { @@ -892,17 +890,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class SetSizeAction implements Runnable { int width, height; + boolean disregardFS; - private SetSizeAction(int w, int h) { + private SetSizeAction(int w, int h, boolean disregardFS) { this.width = w; this.height = h; + this.disregardFS = disregardFS; } public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); try { - if ( !isFullscreen() && ( getWidth() != width || getHeight() != height ) ) { + if ( ( disregardFS || !isFullscreen() ) && ( getWidth() != width || getHeight() != height ) ) { if(DEBUG_IMPLEMENTATION) { System.err.println("Window setSize: START "+getWidth()+"x"+getHeight()+" -> "+width+"x"+height+", fs "+fullscreen+", windowHandle "+toHexString(windowHandle)+", visible "+visible); } @@ -937,9 +937,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } + private void setFullscreenSize(int width, int height) { + runOnEDTIfAvail(true, new SetSizeAction(width, height, true)); + } @Override public void setSize(int width, int height) { - runOnEDTIfAvail(true, new SetSizeAction(width, height)); + runOnEDTIfAvail(true, new SetSizeAction(width, height, false)); } @Override public void setTopLevelSize(int width, int height) { @@ -1850,25 +1853,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class FullScreenAction implements Runnable { boolean fullscreen; - List monitors; - boolean useMainMonitor; - private boolean init(boolean fullscreen, boolean useMainMonitor, List monitors) { + private boolean init(boolean fullscreen) { if(isNativeValid()) { this.fullscreen = fullscreen; - if( isFullscreen() != fullscreen ) { - this.monitors = monitors; - this.useMainMonitor = useMainMonitor; - return true; - } else { - this.monitors = null; - this.useMainMonitor = true; - return false; - } + return isFullscreen() != fullscreen; } else { WindowImpl.this.fullscreen = fullscreen; // set current state for createNative(..) - WindowImpl.this.fullscreenMonitors = monitors; - WindowImpl.this.fullscreenUseMainMonitor = useMainMonitor; return false; } } @@ -1886,16 +1877,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RectangleImmutable viewport; final int fs_span_flag; if(fullscreen) { - if( null == monitors ) { - if( useMainMonitor ) { - monitors = new ArrayList(); - monitors.add( getMainMonitor() ); + if( null == fullscreenMonitors ) { + if( fullscreenUseMainMonitor ) { + fullscreenMonitors = new ArrayList(); + fullscreenMonitors.add( getMainMonitor() ); } else { - monitors = getScreen().getMonitorDevices(); + fullscreenMonitors = getScreen().getMonitorDevices(); } } - fs_span_flag = monitors.size() > 1 ? FLAG_IS_FULLSCREEN_SPAN : 0 ; - viewport = MonitorDevice.unionOfViewports(new Rectangle(), monitors); + /** + * Bug 770: + * _NET_WM_STATE_FULLSCREEN may result in ConfigureNotify event w/ virtual screen size, instead of monitor-mode size (NV + Fglrx). + * ConfigureNotify reflects the actual size of the window and is being propagated + * to NEWT and the GLEventListener. + * With Mesa/Intel open-source driver, the correct desired monitor mode size is reported + * at least on one test machine here. + * + * Bug 771: Implementation requires not to use _NET_WM_STATE_FULLSCREEN! + */ + // fs_span_flag = monitors.size() > 1 ? FLAG_IS_FULLSCREEN_SPAN : 0 ; + fs_span_flag = FLAG_IS_FULLSCREEN_SPAN; + viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); nfs_x = getX(); nfs_y = getY(); nfs_width = getWidth(); @@ -1905,6 +1907,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer w = viewport.getWidth(); h = viewport.getHeight(); } else { + fullscreenUseMainMonitor = true; + fullscreenMonitors = null; fs_span_flag = 0; viewport = null; x = nfs_x; @@ -1926,16 +1930,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } - monitors = null; // clear references ASAP - useMainMonitor = true; if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", monitorsViewport "+viewport); } - DisplayImpl display = (DisplayImpl) screen.getDisplay(); + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date - boolean wasVisible = isVisible(); + final boolean wasVisible = isVisible(); // Lock parentWindow only during reparenting (attempt) final NativeWindow parentWindowLocked; @@ -1963,8 +1965,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.waitForVisible(true, false); display.dispatchMessagesNative(); // status up2date WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); - display.dispatchMessagesNative(); // status up2date - if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs done: " + WindowImpl.this); } @@ -1975,7 +1975,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener } } - private final FullScreenAction fullScreenAction = new FullScreenAction(); + private final FullScreenAction fullScreenAction = new FullScreenAction(); @Override public boolean setFullscreen(boolean fullscreen) { @@ -1989,7 +1989,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private boolean setFullscreenImpl(boolean fullscreen, boolean useMainMonitor, List monitors) { synchronized(fullScreenAction) { - if( fullScreenAction.init(fullscreen, useMainMonitor, monitors) ) { + fullscreenMonitors = monitors; + fullscreenUseMainMonitor = useMainMonitor; + if( fullScreenAction.init(fullscreen) ) { if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance if(null != parentWindow) { @@ -2008,8 +2010,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer nfs_parent = null; } - if(isVisible()) { - requestFocus(true /* wait */, this.fullscreen /* skipFocusAction */, true /* force */); + if( fullscreen && isVisible() ) { // force focus on fullscreen + requestFocus(true /* wait */, true /* skipFocusAction */, true /* force */); } } return this.fullscreen; @@ -2018,10 +2020,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class MonitorModeListenerImpl implements MonitorModeListener { boolean animatorPaused = false; + boolean hadFocus = false; public void monitorModeChangeNotify(MonitorEvent me) { + hadFocus = hasFocus(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.monitorModeChangeNotify: "+me); + System.err.println("Window.monitorModeChangeNotify: hadFocus "+hadFocus+", "+me); } if(null!=lifecycleHook) { @@ -2031,7 +2035,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void monitorModeChanged(MonitorEvent me, boolean success) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.monitorModeChanged: "+me+", success: "+success); + System.err.println("Window.monitorModeChanged: hadFocus "+hadFocus+", "+me+", success: "+success); } if(success) { @@ -2055,13 +2059,27 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setSize(viewport.getWidth(), viewport.getHeight()); } } + } else { + // If changed monitor is part of this fullscreen mode, reset size! (Bug 771) + final MonitorDevice md = me.getMonitor(); + if( fullscreenMonitors.contains(md) ) { + final RectangleImmutable viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); + if(DEBUG_IMPLEMENTATION) { + final RectangleImmutable rect = new Rectangle(getX(), getY(), getWidth(), getHeight()); + System.err.println("Window.monitorModeChanged: FS Monitor Match: Fit window "+rect+" into new viewport union "+viewport+", provoked by "+md); + } + definePosition(viewport.getX(), viewport.getY()); // set pos for setVisible(..) or createNative(..) - reduce EDT roundtrip + setFullscreenSize(viewport.getWidth(), viewport.getHeight()); + } } } - if(animatorPaused) { lifecycleHook.resumeRenderingAction(); } sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout and repaint to listener + if( hadFocus ) { + requestFocus(true); + } } } private final MonitorModeListenerImpl monitorModeListenerImpl = new MonitorModeListenerImpl(); diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 786587d65..aec7f310e 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -133,7 +133,7 @@ public class WindowDriver extends WindowImpl { } } - protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, final int flags) { + protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); } @@ -148,18 +148,52 @@ public class WindowDriver extends WindowImpl { _x = x; _y = y; } + if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { + tempAlwaysOnTop = true; + flags |= FLAG_IS_ALWAYSONTOP; + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig.2: temporary "+getReconfigureFlagsAsString(null, flags)); + } + } else { + tempAlwaysOnTop = false; + } + final int fflags = flags; final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { reconfigureWindow0( dpy, getScreenIndex(), getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), - _x, _y, width, height, flags); + _x, _y, width, height, fflags); return null; } }); return true; } + volatile boolean tempAlwaysOnTop = false; + /** + *

    + * Deal w/ tempAlwaysOnTop. + *

    + * {@inheritDoc} + */ + protected void focusChanged(boolean defer, boolean focusGained) { + if( tempAlwaysOnTop && hasFocus() != focusGained && isNativeValid() ) { + final int flags = getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible()) | ( focusGained ? FLAG_IS_ALWAYSONTOP : 0 ); + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + reconfigureWindow0( dpy, getScreenIndex(), + getParentWindowHandle(), getWindowHandle(), display.getWindowDeleteAtom(), + getX(), getY(), getWidth(), getHeight(), flags); + return null; + } + }); + } + super.focusChanged(defer, focusGained); + } + + protected void reparentNotify(long newParentWindowHandle) { if(DEBUG_IMPLEMENTATION) { final long p0 = getParentWindowHandle(); diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 3f50f27a4..4a95d0180 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -299,9 +299,8 @@ static void NewtWindows_setNormalWindowEWMH (Display *dpy, Window w) { #define _NET_WM_STATE_REMOVE 0 #define _NET_WM_STATE_ADD 1 - -#define _NET_WM_FULLSCREEN ( 1 << 0 ) -#define _NET_WM_ABOVE ( 1 << 1 ) +#define _NET_WM_STATE_FLAG_FULLSCREEN ( 1 << 0 ) +#define _NET_WM_STATE_FLAG_ABOVE ( 1 << 1 ) /** * Set fullscreen using Extended Window Manager Hints (EWMH) @@ -314,7 +313,9 @@ static void NewtWindows_setNormalWindowEWMH (Display *dpy, Window w) { * and resets it when leaving FS. * The same is assumed for the decoration state. */ -static int NewtWindows_isFullscreenEWMHSupported (Display *dpy, Window w) { +static int NewtWindows_getSupportedStackingEWMHFlags(Display *dpy, Window w) { +#ifdef VERBOSE_ON + // Code doesn't work reliable on KDE4 ... Atom _NET_WM_ALLOWED_ACTIONS = XInternAtom( dpy, "_NET_WM_ALLOWED_ACTIONS", False ); Atom _NET_WM_ACTION_FULLSCREEN = XInternAtom( dpy, "_NET_WM_ACTION_FULLSCREEN", False ); Atom _NET_WM_ACTION_ABOVE = XInternAtom( dpy, "_NET_WM_ACTION_ABOVE", False ); @@ -329,86 +330,75 @@ static int NewtWindows_isFullscreenEWMHSupported (Display *dpy, Window w) { for(i=0; i0) { - XChangeProperty( dpy, w, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char *)&types, ntypes); - XSync(dpy, False); - res = True; - } - } else { - if(enable) { - NewtWindows_setCWAbove(dpy, w); - } - XEvent xev; - long mask = SubstructureNotifyMask | SubstructureRedirectMask ; - int i=0; - - memset ( &xev, 0, sizeof(xev) ); - - xev.type = ClientMessage; - xev.xclient.window = w; - xev.xclient.message_type = _NET_WM_STATE; - xev.xclient.format = 32; + // _NET_WM_STATE: fullscreen and/or above + if( changeFullscreen || changeAbove ) { + { + // _NET_WM_STATE as event to root window + XEvent xev; + long mask = SubstructureNotifyMask | SubstructureRedirectMask ; + int i=0; - xev.xclient.data.l[i++] = ( True == enable ) ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE ; - if( 0 != ( ( _NET_WM_FULLSCREEN & ewmhMask ) & ewmhFlags ) ) { - xev.xclient.data.l[i++] = _NET_WM_STATE_FULLSCREEN; - } - if( 0 != ( ( _NET_WM_ABOVE & ewmhMask ) & ewmhFlags ) ) { - xev.xclient.data.l[i++] = _NET_WM_STATE_ABOVE; - } - xev.xclient.data.l[3] = 1; //source indication for normal applications + memset ( &xev, 0, sizeof(xev) ); + + xev.type = ClientMessage; + xev.xclient.window = w; + xev.xclient.message_type = _NET_WM_STATE; + xev.xclient.format = 32; + + xev.xclient.data.l[i++] = enable ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE ; + if( changeFullscreen ) { + xev.xclient.data.l[i++] = _NET_WM_STATE_FULLSCREEN; + } + if( changeAbove ) { + xev.xclient.data.l[i++] = _NET_WM_STATE_ABOVE; + } + xev.xclient.data.l[3] = 1; //source indication for normal applications - if(i>0) { XSendEvent ( dpy, root, False, mask, &xev ); - res = True; } + // If ABOVE is changed, also change _NET_WM_BYPASS_COMPOSITOR! + if( changeAbove ) { + Atom _NET_WM_BYPASS_COMPOSITOR = XInternAtom( dpy, "_NET_WM_BYPASS_COMPOSITOR", False ); + unsigned long value = enable ? 1 : 0; + XChangeProperty( dpy, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&value, 1); + } + XSync(dpy, False); + res = True; } - XSync(dpy, False); - DBG_PRINT( "X11: reconfigureWindow0 FULLSCREEN EWMH ON %d, ewmhMask 0x%X, ewmhFlags 0x%X, visible %d: %d\n", - enable, ewmhMask, ewmhFlags, isVisible, res); + DBG_PRINT( "X11: setStackingEWMHFlags ON %d, changeFullscreen %d, changeAbove %d, visible %d: %d\n", + enable, changeFullscreen, changeAbove, isVisible, res); return res; } @@ -657,7 +647,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 NewtWindows_setPosSize(dpy, window, x, y, width, height); if( TST_FLAG_IS_ALWAYSONTOP(flags) ) { - NewtWindows_setFullscreenEWMH(dpy, root, window, _NET_WM_ABOVE, True, True); + NewtWindows_setStackingEWMHFlags(dpy, root, window, _NET_WM_STATE_FLAG_ABOVE, True, True); } } @@ -720,15 +710,6 @@ static Bool WaitForReparentNotify( Display *dpy, XEvent *event, XPointer arg ) { } #endif -/** - * KDE cause lost input focus in fullscreen mode. - * Using 'XGrabKeyboard(..)' would prevent the loss, - * but also would disable WM task switcher etc. - * - * #define FS_GRAB_KEYBOARD 1 - * - */ - /* * Class: jogamp_newt_driver_x11_WindowDriver * Method: reconfigureWindow0 @@ -747,21 +728,22 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo XEvent event; Bool isVisible = !TST_FLAG_CHANGE_VISIBILITY(flags) && TST_FLAG_IS_VISIBLE(flags) ; Bool tempInvisible = ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_PARENTING(flags) ) && isVisible ; + // Bool tempInvisible = TST_FLAG_CHANGE_PARENTING(flags) && isVisible ; int fsEWMHFlags = 0; if( TST_FLAG_CHANGE_FULLSCREEN(flags) ) { - if( !TST_FLAG_IS_FULLSCREEN_SPAN(flags) ) { // doesn't work w/ spanning across monitors - fsEWMHFlags |= _NET_WM_FULLSCREEN; + if( !TST_FLAG_IS_FULLSCREEN_SPAN(flags) ) { // doesn't work w/ spanning across monitors. See also Bug 770 & Bug 771 + fsEWMHFlags |= _NET_WM_STATE_FLAG_FULLSCREEN; } if( TST_FLAG_IS_FULLSCREEN(flags) ) { if( TST_FLAG_IS_ALWAYSONTOP(flags) ) { - fsEWMHFlags |= _NET_WM_ABOVE; // fs on, above on - } // else { } // fs on, above off + fsEWMHFlags |= _NET_WM_STATE_FLAG_ABOVE; // fs on, above on + } // else { } // fs on, above off } else if( !TST_FLAG_IS_ALWAYSONTOP(flags) ) { - fsEWMHFlags |= _NET_WM_ABOVE; // fs off, above off - } // else { } // fs off, above on + fsEWMHFlags |= _NET_WM_STATE_FLAG_ABOVE; // fs off, above off + } // else { } // fs off, above on } if( TST_FLAG_CHANGE_ALWAYSONTOP(flags) ) { - fsEWMHFlags |= _NET_WM_ABOVE; // toggle above + fsEWMHFlags |= _NET_WM_STATE_FLAG_ABOVE; // toggle above } DBG_PRINT( "X11: reconfigureWindow0 dpy %p, scrn %d, parent %p/%p, win %p, %d/%d %dx%d, parentChange %d, hasParent %d, decorationChange %d, undecorated %d, fullscreenChange %d, fullscreen %d (span %d), alwaysOnTopChange %d, alwaysOnTop %d, visibleChange %d, visible %d, tempInvisible %d, fsEWMHFlags %d\n", @@ -780,21 +762,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo !TST_FLAG_IS_FULLSCREEN_SPAN(flags) && ( TST_FLAG_CHANGE_FULLSCREEN(flags) || TST_FLAG_CHANGE_ALWAYSONTOP(flags) ) ) { Bool enable = TST_FLAG_CHANGE_FULLSCREEN(flags) ? TST_FLAG_IS_FULLSCREEN(flags) : TST_FLAG_IS_ALWAYSONTOP(flags) ; - if( NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, enable) ) { + if( NewtWindows_setStackingEWMHFlags(dpy, root, w, fsEWMHFlags, isVisible, enable) ) { if ( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) { // FS off - restore decoration NewtWindows_setDecorations (dpy, w, TST_FLAG_IS_UNDECORATED(flags) ? False : True); } - #ifdef FS_GRAB_KEYBOARD - if(TST_FLAG_CHANGE_FULLSCREEN(flags)) { - if(TST_FLAG_IS_FULLSCREEN(flags)) { - XGrabKeyboard(dpy, w, True, GrabModeAsync, GrabModeAsync, CurrentTime); - } else { - XUngrabKeyboard(dpy, CurrentTime); - } - } else if(TST_FLAG_CHANGE_ALWAYSONTOP(flags) && !TST_FLAG_IS_ALWAYSONTOP(flags)) { - XUngrabKeyboard(dpy, CurrentTime); - } - #endif + DBG_PRINT( "X11: reconfigureWindow0 X (fast)\n"); return; } } @@ -808,10 +780,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo if( fsEWMHFlags && ( ( TST_FLAG_CHANGE_FULLSCREEN(flags) && !TST_FLAG_IS_FULLSCREEN(flags) ) || ( TST_FLAG_CHANGE_ALWAYSONTOP(flags) && !TST_FLAG_IS_ALWAYSONTOP(flags) ) ) ) { // FS off - NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, False); - #ifdef FS_GRAB_KEYBOARD - XUngrabKeyboard(dpy, CurrentTime); - #endif + NewtWindows_setStackingEWMHFlags(dpy, root, w, fsEWMHFlags, isVisible, False); } if( TST_FLAG_CHANGE_PARENTING(flags) && !TST_FLAG_HAS_PARENT(flags) ) { @@ -844,9 +813,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo XMapRaised(dpy, w); XIfEvent( dpy, &event, WaitForMapNotify, (XPointer) w ); // no need to notify the java side .. just temp change - } - - if( TST_FLAG_CHANGE_VISIBILITY(flags) ) { + } else if( TST_FLAG_CHANGE_VISIBILITY(flags) ) { if( TST_FLAG_IS_VISIBLE(flags) ) { DBG_PRINT( "X11: reconfigureWindow0 VISIBLE ON\n"); XMapRaised(dpy, w); @@ -859,15 +826,11 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo if( fsEWMHFlags && ( ( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) || ( TST_FLAG_CHANGE_ALWAYSONTOP(flags) && TST_FLAG_IS_ALWAYSONTOP(flags) ) ) ) { // FS on - NewtWindows_setFullscreenEWMH(dpy, root, w, fsEWMHFlags, isVisible, True); - #ifdef FS_GRAB_KEYBOARD - if(TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags)) { - XGrabKeyboard(dpy, w, True, GrabModeAsync, GrabModeAsync, CurrentTime); - } - #endif + NewtWindows_requestFocus (dpy, w, True); + NewtWindows_setStackingEWMHFlags(dpy, root, w, fsEWMHFlags, isVisible, True); } - DBG_PRINT( "X11: reconfigureWindow0 X\n"); + DBG_PRINT( "X11: reconfigureWindow0 X (full)\n"); } /* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java index 37ea499df..54c6bdd6c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java @@ -55,7 +55,8 @@ import java.util.List; import javax.media.nativewindow.util.Dimension; /** - * Tests MonitorMode change w/ changed rotation. + * Tests MonitorMode change w/ changed rotation, + * w/ and w/o fullscreen, pre and post MonitorMode change. *

    * Also tests MonitorMode reset after last Screen is dereferenced, * i.e. MonitorMode should be reinstated. @@ -75,21 +76,14 @@ public class TestScreenMode02aNEWT extends UITestCase { glp = GLProfile.getDefault(); } - @AfterClass - public static void releaseClass() throws InterruptedException { - Thread.sleep(waitTimeShort); - } - static GLWindow createWindow(Screen screen, GLCapabilities caps, int width, int height, boolean onscreen, boolean undecorated) { Assert.assertNotNull(caps); caps.setOnscreen(onscreen); GLWindow window = GLWindow.create(screen, caps); window.setSize(width, height); - window.addGLEventListener(new GearsES2()); + window.addGLEventListener(new GearsES2(1)); Assert.assertNotNull(window); - window.setVisible(true); - Assert.assertTrue(window.isVisible()); return window; } @@ -100,9 +94,26 @@ public class TestScreenMode02aNEWT extends UITestCase { } @Test - public void testScreenRotationChange01() throws InterruptedException { - Thread.sleep(waitTimeShort); - + public void testScreenRotationChange01_PreWin() throws InterruptedException { + testScreenRotationChangeImpl(true, true, false); + } + + @Test + public void testScreenRotationChange02_PreFull() throws InterruptedException { + testScreenRotationChangeImpl(true, true, true); + } + + @Test + public void testScreenRotationChange11_PostWin() throws InterruptedException { + testScreenRotationChangeImpl(true, false, false); + } + + @Test + public void testScreenRotationChange12_PostFull() throws InterruptedException { + testScreenRotationChangeImpl(true, false, true); + } + + void testScreenRotationChangeImpl(boolean changeMode, boolean preVis, boolean fullscreen) throws InterruptedException { GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); Display display = NewtFactory.createDisplay(null); // local display @@ -111,60 +122,92 @@ public class TestScreenMode02aNEWT extends UITestCase { Assert.assertNotNull(screen); GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); Assert.assertNotNull(window); - - MonitorDevice monitor = window.getMainMonitor(); - List monitorModes = monitor.getSupportedModes(); - if(monitorModes.size()==1) { - // no support .. - System.err.println("Your platform has no ScreenMode change support, sorry"); - destroyWindow(window); - return; + if( preVis ) { + window.setVisible(true); + if( fullscreen ) { + window.setFullscreen(true); + } + } else { + screen.createNative(); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); } - Assert.assertTrue(monitorModes.size()>0); Animator animator = new Animator(window); animator.start(); - - MonitorMode mmCurrent = monitor.getCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); + + final MonitorDevice monitor = window.getMainMonitor(); + final MonitorMode mmOrig = monitor.getOriginalMode(); Assert.assertNotNull(mmOrig); - System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); - if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { - // no rotation support .. - System.err.println("Your platform has no rotation support, sorry"); - destroyWindow(window); - return; + if(changeMode) { + List monitorModes = monitor.getSupportedModes(); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no ScreenMode change support, sorry"); + destroyWindow(window); + return; + } + Assert.assertTrue(monitorModes.size()>0); + + final MonitorMode mmCurrent = monitor.getCurrentMode(); + Assert.assertNotNull(mmCurrent); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); + if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { + // no rotation support .. + System.err.println("Your platform has no rotation support, sorry"); + destroyWindow(window); + return; + } + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode mm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+mm); + monitor.setCurrentMode(mm); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(mm, monitor.queryCurrentMode()); } - monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); - Assert.assertNotNull(monitorModes); - Assert.assertTrue(monitorModes.size()>0); - - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - monitor.setCurrentMode(sm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); - + + if( !preVis ) { + window.setVisible(true); + if( fullscreen ) { + window.setFullscreen(true); + } + } + Thread.sleep(waitTimeLong); - - // check reset .. - + + if( !preVis && fullscreen ) { + window.setFullscreen(false); + } + + if(changeMode) { + monitor.setCurrentMode(mmOrig); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Thread.sleep(waitTimeShort); + } + + if( preVis && fullscreen ) { + window.setFullscreen(false); + } + Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isNativeValid()); @@ -178,22 +221,6 @@ public class TestScreenMode02aNEWT extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - - screen.destroy(); - - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); } public static void main(String args[]) throws IOException { -- cgit v1.2.3 From 3a32a59045ced338b2c5098cfb1102f847420efc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Jul 2013 16:37:41 +0200 Subject: Bug 734: Bug could not be reproduced w/ TestScreenMode02bNEWT, however on some X11 tests systems, artifacts could be experienced. X11 Test systems w/ AMD fglrx and Intel Mesa, the rotated height is cut off .. probably due to bug of driver code and rotation. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- .../test/junit/newt/mm/TestScreenMode02aNEWT.java | 6 +- .../test/junit/newt/mm/TestScreenMode02bNEWT.java | 236 +++++++++++++++++++++ 4 files changed, 244 insertions(+), 6 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index a5d368c48..348b6053a 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -119,8 +119,8 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c0d15b84b..5f0cdf7fa 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -407,8 +407,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java index 54c6bdd6c..aee9c28c2 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java @@ -34,7 +34,6 @@ import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.Animator; -import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -58,6 +57,9 @@ import javax.media.nativewindow.util.Dimension; * Tests MonitorMode change w/ changed rotation, * w/ and w/o fullscreen, pre and post MonitorMode change. *

    + * MonitorMode change does not use highest resolution. + *

    + *

    * Also tests MonitorMode reset after last Screen is dereferenced, * i.e. MonitorMode should be reinstated. *

    @@ -185,10 +187,10 @@ public class TestScreenMode02aNEWT extends UITestCase { } if( !preVis ) { - window.setVisible(true); if( fullscreen ) { window.setFullscreen(true); } + window.setVisible(true); } Thread.sleep(waitTimeLong); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java new file mode 100644 index 000000000..bd7ac55db --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java @@ -0,0 +1,236 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.mm; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.common.os.Platform; +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +import java.util.List; +import javax.media.nativewindow.util.Dimension; + +/** + * Tests MonitorMode change w/ changed rotation and fullscreen. + *

    + * MonitorMode change uses highest resolution. + *

    + *

    + * Bug 734 could not be reproduced, however on tests systems + * here - AMD fglrx and Intel Mesa, the rotated height + * is cut off .. probably due to bug of driver code and rotation. + *

    + *

    + * Documents remedy B) for NV RANDR/GL bug + *

    + * + * @see TestScreenMode01NEWT#cleanupGL() + */ +public class TestScreenMode02bNEWT extends UITestCase { + static GLProfile glp; + + static int waitTimeShort = 2000; // 2 sec + static int waitTimeLong = 8000; // 8 sec + + @BeforeClass + public static void initClass() { + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static GLWindow createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) { + Assert.assertNotNull(caps); + + GLWindow window = GLWindow.create(screen, caps); + // Window window = NewtFactory.createWindow(screen, caps); + window.setTitle(name); + window.setPosition(x, y); + window.setSize(width, height); + window.addGLEventListener(new GearsES2(1)); + Assert.assertNotNull(window); + return window; + } + + static void destroyWindow(Window window) { + if(null!=window) { + window.destroy(); + } + } + + @Test + public void testScreenModeChange01_PreFull() throws InterruptedException { + testScreenModeChangeImpl(true); + } + + @Test + public void testScreenModeChange02_PostFull() throws InterruptedException { + testScreenModeChangeImpl(false); + } + + void testScreenModeChangeImpl(boolean preVis) throws InterruptedException { + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.createNative(); // instantiate for resolution query and keep it alive ! + final int swidth = screen.getWidth(); + final int sheight = screen.getHeight(); + + GLWindow window = createWindow(screen, caps, "win0", 0, 0, 640, 480); + if( preVis ) { + window.setVisible(true); + window.setFullscreen(true); + } + window.setUndecorated(true); + Assert.assertNotNull(window); + + List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + if(allMonitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (all), sorry"); + destroyWindow(window); + return; + } + + MonitorDevice monitor = window.getMainMonitor(); + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); + destroyWindow(window); + return; + } + Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); + + Animator animator = new Animator(window); + animator.start(); + + MonitorMode mmCurrent = monitor.queryCurrentMode(); + Assert.assertNotNull(mmCurrent); + final MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmCurrent); + Assert.assertEquals(mmCurrent, mmOrig); + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 90); + if(null==monitorModes || Platform.getOSType() == Platform.OSType.MACOS ) { + // no rotation support .. + System.err.println("Your platform has no rotation support, sorry"); + destroyWindow(window); + return; + } + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(swidth, sheight)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + MonitorMode mm = monitorModes.get(0); // highest resolution .. + System.err.println("[0] set current: "+mm); + Assert.assertTrue(monitor.setCurrentMode(mm)); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, monitor.getCurrentMode()); + Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(mm, monitor.queryCurrentMode()); + + if( !preVis ) { + window.setFullscreen(true); + window.setVisible(true); + } + + Thread.sleep(waitTimeLong); + + if( !preVis ) { + window.setFullscreen(false); + } + + monitor.setCurrentMode(mmOrig); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Thread.sleep(waitTimeShort); + + if( preVis ) { + window.setFullscreen(false); + } + + // check auto reset .. + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window.isNativeValid()); + Assert.assertEquals(true,window.isVisible()); + + animator.stop(); + destroyWindow(window); + + Assert.assertEquals(false,window.isVisible()); + Assert.assertEquals(false,window.isNativeValid()); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); + } + + public static void main(String args[]) throws IOException { + String tstname = TestScreenMode02bNEWT.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} -- cgit v1.2.3 From 35fcf49d1cb49e3844e7cee44f34d827d8a102ce Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 2 Jul 2013 22:24:08 +0200 Subject: Bug 724: Add manual unit test, incr. PNGImage verbosity. --- make/scripts/tests.sh | 7 +-- .../jogamp/opengl/util/texture/spi/PNGImage.java | 3 +- .../jogl/demos/es2/TextureDraw01ES2Listener.java | 13 +++-- .../jogl/util/texture/TestPNGImage00NEWT.java | 62 ++++++++++++++++++++++ .../jogl/util/texture/TestPNGImage01NEWT.java | 62 ---------------------- 5 files changed, 76 insertions(+), 71 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5f0cdf7fa..c0c4764fb 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -206,7 +206,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" - #D_ARGS="-Djogl.debug.PNGImage" + D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" @@ -408,7 +408,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* @@ -545,7 +545,8 @@ testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage00NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java index b4b00e744..93d37029e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java @@ -177,7 +177,8 @@ public class PNGImage { } if(DEBUG) { System.err.println("PNGImage: "+imgInfo); - System.err.println("PNGImage: indexed "+indexed+", alpha "+hasAlpha+", channels "+channels+", bytesPerPixel "+bytesPerPixel+ + System.err.println("PNGImage: indexed "+indexed+", alpha "+hasAlpha+", channels "+channels+"/"+imgInfo.channels+ + ", bytesPerPixel "+bytesPerPixel+"/"+imgInfo.bytesPixel+ ", pixels "+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+"x"+dpi[1]+", glFormat 0x"+Integer.toHexString(glFormat)); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java index 622df8695..f6b6d2873 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw01ES2Listener.java @@ -56,14 +56,18 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A PMVMatrix pmvMatrix; GLUniformData pmvMatrixUniform; GLArrayDataServer interleavedVBO; - + float[] clearColor = new float[] { 1.0f, 1.0f, 1.0f, 0.4f }; public TextureDraw01ES2Listener(TextureData td) { this.textureData = td; } + + public void setClearColor(float[] clearColor) { + this.clearColor = clearColor; + } static final String shaderBasename = "texture01_xxx"; - + private void initShader(GL2ES2 gl, boolean use_program) { // Create & Compile the shader objects ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), @@ -134,7 +138,7 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A st.ownAttribute(interleavedVBO, true); // OpenGL Render Settings - gl.glClearColor(0, 0, 0, 1); + gl.glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); gl.glEnable(GL2ES2.GL_DEPTH_TEST); st.useProgram(gl, false); } @@ -164,8 +168,7 @@ public class TextureDraw01ES2Listener implements GLEventListener, TextureDraw01A gl.glViewport(0, 0, width, height); // Clear background to white - gl.glClearColor(1.0f, 1.0f, 1.0f, 0.4f); - + gl.glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); if(null != st) { pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); pmvMatrix.glLoadIdentity(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java new file mode 100644 index 000000000..210d03afa --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java @@ -0,0 +1,62 @@ +package com.jogamp.opengl.test.junit.jogl.util.texture; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URLConnection; + +import org.junit.Assert; +import org.junit.Test; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.texture.spi.PNGImage; + +public class TestPNGImage00NEWT extends UITestCase { + @Test + public void testPNGReadWriteAndCompare() throws InterruptedException, IOException, MalformedURLException { + final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png"); + final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png"); + final File out2F_f=new File(getSimpleTestName(".")+"-PNGImageTest2Flipped.png"); + final File out2R_f=new File(getSimpleTestName(".")+"-PNGImageTest2Reversed.png"); + final File out2RF_f=new File(getSimpleTestName(".")+"-PNGImageTest2ReversedFlipped.png"); + final String url_s="jogl/util/data/av/test-ntsc01-160x90.png"; + URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader()); + PNGImage image1 = PNGImage.read(urlConn.getInputStream()); + System.err.println("PNGImage - Orig: "+image1); + image1.write(out1_f, true); + { + Assert.assertEquals(image1.getData(), PNGImage.read(out1_f.toURI().toURL().openStream()).getData()); + } + + final PNGImage image2 = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), false /* reverseChannels */, image1.isGLOriented(), image1.getData()); + image2.write(out2_f, true); + { + Assert.assertEquals(image1.getData(), PNGImage.read(out2_f.toURI().toURL().openStream()).getData()); + } + + // flipped + final PNGImage image2F = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), false /* reverseChannels */, !image1.isGLOriented(), image1.getData()); + image2F.write(out2F_f, true); + + // reversed channels + final PNGImage image2R = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), true /* reverseChannels */, image1.isGLOriented(), image1.getData()); + image2R.write(out2R_f, true); + + // reversed channels and flipped + final PNGImage image2RF = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), + image1.getDpi()[0], image1.getDpi()[1], + image1.getBytesPerPixel(), true /* reverseChannels */, !image1.isGLOriented(), image1.getData()); + image2RF.write(out2RF_f, true); + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPNGImage00NEWT.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java deleted file mode 100644 index 81f64f0ae..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.jogamp.opengl.test.junit.jogl.util.texture; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URLConnection; - -import org.junit.Assert; -import org.junit.Test; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.texture.spi.PNGImage; - -public class TestPNGImage01NEWT extends UITestCase { - @Test - public void testPNGReadWriteAndCompare() throws InterruptedException, IOException, MalformedURLException { - final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png"); - final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png"); - final File out2F_f=new File(getSimpleTestName(".")+"-PNGImageTest2Flipped.png"); - final File out2R_f=new File(getSimpleTestName(".")+"-PNGImageTest2Reversed.png"); - final File out2RF_f=new File(getSimpleTestName(".")+"-PNGImageTest2ReversedFlipped.png"); - final String url_s="jogl/util/data/av/test-ntsc01-160x90.png"; - URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader()); - PNGImage image1 = PNGImage.read(urlConn.getInputStream()); - System.err.println("PNGImage - Orig: "+image1); - image1.write(out1_f, true); - { - Assert.assertEquals(image1.getData(), PNGImage.read(out1_f.toURI().toURL().openStream()).getData()); - } - - final PNGImage image2 = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), false /* reverseChannels */, image1.isGLOriented(), image1.getData()); - image2.write(out2_f, true); - { - Assert.assertEquals(image1.getData(), PNGImage.read(out2_f.toURI().toURL().openStream()).getData()); - } - - // flipped - final PNGImage image2F = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), false /* reverseChannels */, !image1.isGLOriented(), image1.getData()); - image2F.write(out2F_f, true); - - // reversed channels - final PNGImage image2R = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), true /* reverseChannels */, image1.isGLOriented(), image1.getData()); - image2R.write(out2R_f, true); - - // reversed channels and flipped - final PNGImage image2RF = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), true /* reverseChannels */, !image1.isGLOriented(), image1.getData()); - image2RF.write(out2RF_f, true); - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestPNGImage01NEWT.class.getName()); - } -} -- cgit v1.2.3 From 4e6c2aadd7d652db3ba1f35eef1a3d61d6e692d0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 3 Jul 2013 23:06:43 +0200 Subject: Revise commit 4c34f5980bddcdc84b10cb3bcbb96b365b9d471e (Bug 767): TAB, BS and CR/ENTER are printable for NEWT KeyEvent and font handling. Fix regression. - Original behavior was treating CR/ENTER them as printable, lets keep it this way. - KeyEvent: Query these 3 whitespaces upfront, no need to incl. them in 'nonPrintableKeys'. - Fix regression: Native VK_ENTER was not change in commit 4c34f5980bddcdc84b10cb3bcbb96b365b9d471e. --- make/scripts/tests-win.bat | 4 +-- make/scripts/tests-x64-dbg.bat | 3 +-- make/scripts/tests.sh | 8 +++--- .../classes/com/jogamp/graph/font/FontFactory.java | 13 +++++---- .../classes/com/jogamp/newt/event/KeyEvent.java | 31 +++++++++++++--------- src/newt/native/KeyEvent.h | 2 +- .../graph/demos/GPUTextRendererListenerBase01.java | 30 +++++++++++---------- 7 files changed, 51 insertions(+), 40 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 348b6053a..b0815a5a6 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -61,7 +61,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* @@ -120,7 +120,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index cb40125f2..d0108fdf8 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -41,8 +41,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Dnewt.debug.Window" -set D_ARGS="-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.Window" -REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" +set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c0c4764fb..2e741b353 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -176,7 +176,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -206,7 +206,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" - D_ARGS="-Djogl.debug.PNGImage" + #D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" @@ -285,7 +285,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -546,7 +546,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage00NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* diff --git a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java index bbdfc0e9f..d2824b9dc 100644 --- a/src/jogl/classes/com/jogamp/graph/font/FontFactory.java +++ b/src/jogl/classes/com/jogamp/graph/font/FontFactory.java @@ -93,10 +93,13 @@ public class FontFactory { } public static boolean isPrintableChar( char c ) { - Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); - return (!Character.isISOControl(c)) && - c != 0 && - block != null && - block != Character.UnicodeBlock.SPECIALS; + if( Character.isWhitespace(c) ) { + return true; + } + if( 0 == c || Character.isISOControl(c) ) { + return false; + } + final Character.UnicodeBlock block = Character.UnicodeBlock.of( c ); + return block != null && block != Character.UnicodeBlock.SPECIALS; } } diff --git a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java index 156708779..085f598dc 100644 --- a/src/newt/classes/com/jogamp/newt/event/KeyEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/KeyEvent.java @@ -312,27 +312,25 @@ public class KeyEvent extends InputEvent * @param isKeyChar true if uniChar is a key character, otherwise a virtual key code */ public static boolean isPrintableKey(final short uniChar, final boolean isKeyChar) { - if( VK_UNDEFINED == uniChar ) { - return false; + if ( VK_BACK_SPACE == uniChar || VK_TAB == uniChar || VK_ENTER == uniChar ) { + return true; } if( !isKeyChar ) { if( ( nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || ( nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || - ( nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || - ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) || - ( nonPrintableKeys[4].min <= uniChar && uniChar <= nonPrintableKeys[4].max ) ) { + ( nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || + ( nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { return false; } } else { if( ( nonPrintableKeys[0].inclKeyChar && nonPrintableKeys[0].min <= uniChar && uniChar <= nonPrintableKeys[0].max ) || ( nonPrintableKeys[1].inclKeyChar && nonPrintableKeys[1].min <= uniChar && uniChar <= nonPrintableKeys[1].max ) || ( nonPrintableKeys[2].inclKeyChar && nonPrintableKeys[2].min <= uniChar && uniChar <= nonPrintableKeys[2].max ) || - ( nonPrintableKeys[3].inclKeyChar && nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) || - ( nonPrintableKeys[4].inclKeyChar && nonPrintableKeys[4].min <= uniChar && uniChar <= nonPrintableKeys[4].max ) ) { + ( nonPrintableKeys[3].inclKeyChar && nonPrintableKeys[3].min <= uniChar && uniChar <= nonPrintableKeys[3].max ) ) { return false; } } - return true; + return VK_UNDEFINED != uniChar; } /** @@ -383,10 +381,19 @@ public class KeyEvent extends InputEvent this.inclKeyChar = inclKeyChar; } }; - /** Non printable key ranges, currently fixed to an array of size 5. */ + /** + * Non printable key ranges, currently fixed to an array of size 4. + *

    + * Not included, queried upfront: + *

      + *
    • {@link #VK_BACK_SPACE}
    • + *
    • {@link #VK_TAB}
    • + *
    • {@link #VK_ENTER}
    • + *
    + *

    + */ public final static NonPrintableRange[] nonPrintableKeys = { - new NonPrintableRange( (short)0x0000, (short)0x0007, true ), // Unicode: Non printable controls: [0x00 - 0x07] - new NonPrintableRange( (short)0x000A, (short)0x001F, true ), // Unicode: Non printable controls: [0x0A - 0x1F] + new NonPrintableRange( (short)0x0000, (short)0x001F, true ), // Unicode: Non printable controls: [0x00 - 0x1F], see exclusion above new NonPrintableRange( (short)0x0061, (short)0x0078, false), // Small 'a' thru 'z' (0x61 - 0x7a) - Not used for keyCode / keySym - Re-used for Fn (collision) new NonPrintableRange( (short)0x008F, (short)0x009F, true ), // Unicode: Non printable controls: [0x7F - 0x9F], Numpad keys [0x7F - 0x8E] are printable! new NonPrintableRange( (short)0xE000, (short)0xF8FF, true ) // Unicode: Private 0xE000 - 0xF8FF (Marked Non-Printable) @@ -433,7 +440,7 @@ public class KeyEvent extends InputEvent /** Constant for the CLEAR key, i.e. FORM FEED, matching ASCII. */ public static final short VK_CLEAR = (short) 0x0C; - /** Constant for the ENTER key, i.e. CARRIAGE RETURN, matching ASCII. Non printable! */ + /** Constant for the ENTER key, i.e. CARRIAGE RETURN, matching ASCII. Printable! */ public static final short VK_ENTER = (short) 0x0D; static final short VK_FREE0E = (short) 0x0E; diff --git a/src/newt/native/KeyEvent.h b/src/newt/native/KeyEvent.h index 59977d565..c0a366a17 100644 --- a/src/newt/native/KeyEvent.h +++ b/src/newt/native/KeyEvent.h @@ -39,9 +39,9 @@ #define J_VK_PRINTSCREEN ( 0x05U ) #define J_VK_BACK_SPACE ( 0x08U ) #define J_VK_TAB ( 0x09U ) -#define J_VK_ENTER ( 0x0AU ) #define J_VK_PAGE_DOWN ( 0x0BU ) #define J_VK_CLEAR ( 0x0CU ) +#define J_VK_ENTER ( 0x0DU ) #define J_VK_SHIFT ( 0x0FU ) #define J_VK_PAGE_UP ( 0x10U ) #define J_VK_CONTROL ( 0x11U ) diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java index 31377025a..1dc104cbb 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java @@ -269,27 +269,27 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } public class KeyAction implements KeyListener { - public void keyPressed(KeyEvent arg0) { + public void keyPressed(KeyEvent e) { if(userInput) { return; } - - if(arg0.getKeyCode() == KeyEvent.VK_3) { + final short s = e.getKeySymbol(); + if(s == KeyEvent.VK_3) { fontIncr(10); } - else if(arg0.getKeyCode() == KeyEvent.VK_4) { + else if(s == KeyEvent.VK_4) { fontIncr(-10); } - else if(arg0.getKeyCode() == KeyEvent.VK_H) { + else if(s == KeyEvent.VK_H) { switchHeadBox(); } - else if(arg0.getKeyCode() == KeyEvent.VK_F) { + else if(s == KeyEvent.VK_F) { drawFPS = !drawFPS; } - else if(arg0.getKeyCode() == KeyEvent.VK_SPACE) { + else if(s == KeyEvent.VK_SPACE) { nextFontSet(); } - else if(arg0.getKeyCode() == KeyEvent.VK_I) { + else if(s == KeyEvent.VK_I) { userInput = true; setIgnoreInput(true); } @@ -300,15 +300,17 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB return; } if(userInput) { - char c = e.getKeyChar(); - - if(c == 0x0d) { + final short k = e.getKeySymbol(); + if( KeyEvent.VK_ENTER == k ) { userInput = false; setIgnoreInput(false); - } else if(c == 0x08 && userString.length()>0) { + } else if( KeyEvent.VK_BACK_SPACE == k && userString.length()>0) { userString.deleteCharAt(userString.length()-1); - } else if( font.isPrintableChar( c ) ) { - userString.append(c); + } else { + final char c = e.getKeyChar(); + if( font.isPrintableChar( c ) ) { + userString.append(c); + } } } } -- cgit v1.2.3 From 2f3be40737c15547e8c7c9e19ccdb2b3b1e2ea56 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 14:14:13 +0200 Subject: TestScreenMode* Cleanup (reset) - TestScreenMode01aNEWT and TestScreenMode01dNEWT test auto-reset (destroying last Screen ref. reinstates orig MonitorMode) - Other tests do manual reset. - Add ant test target 'junit.run.newt.monitormode' to test only monitor-mode / fullscreen cases --- make/build-test.xml | 38 +++++++++++ make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 5 +- make/scripts/tests.sh | 8 +-- .../test/junit/newt/mm/TestScreenMode01aNEWT.java | 68 +++++++++---------- .../test/junit/newt/mm/TestScreenMode01bNEWT.java | 3 + .../test/junit/newt/mm/TestScreenMode01dNEWT.java | 79 ++++++++++++---------- .../test/junit/newt/mm/TestScreenMode02aNEWT.java | 5 +- .../test/junit/newt/mm/TestScreenMode02bNEWT.java | 5 +- 9 files changed, 129 insertions(+), 86 deletions(-) (limited to 'make/scripts') diff --git a/make/build-test.xml b/make/build-test.xml index e00348c38..a42f97b3c 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -484,6 +484,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index b0815a5a6..da531dd66 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -61,7 +61,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* @@ -118,7 +118,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index d0108fdf8..c8b1ef5b0 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -40,8 +40,8 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" -REM set D_ARGS="-Dnewt.debug.Window" -set D_ARGS="-Dnewt.debug.Window.KeyEvent" +set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" @@ -54,6 +54,7 @@ REM set D_ARGS="-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.debug.EDT" "-Djogl.debug.GLContext" REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.EDT" "-Dnativewindow.debug=all" REM set D_ARGS="-Dnewt.debug.Screen" +REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2e741b353..640e6a01d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -136,7 +136,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -176,7 +176,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -285,7 +285,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -406,7 +406,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java index f431e099b..8846812e5 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java @@ -46,6 +46,7 @@ import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; import java.util.List; @@ -105,16 +106,16 @@ public class TestScreenMode01aNEWT extends UITestCase { public void testScreenModeChange01() throws InterruptedException { Thread.sleep(waitTimeShort); - GLCapabilities caps = new GLCapabilities(glp); + final GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); - Display display = NewtFactory.createDisplay(null); // local display + final Display display = NewtFactory.createDisplay(null); // local display Assert.assertNotNull(display); - Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 Assert.assertNotNull(screen); - Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height); + final Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height); Assert.assertNotNull(window0); - List allMonitorModes = screen.getMonitorModes(); + final List allMonitorModes = screen.getMonitorModes(); Assert.assertTrue(allMonitorModes.size()>0); if(allMonitorModes.size()==1) { // no support .. @@ -123,7 +124,7 @@ public class TestScreenMode01aNEWT extends UITestCase { return; } - MonitorDevice monitor = window0.getMainMonitor(); + final MonitorDevice monitor = screen.getMonitorDevices().get(0); List monitorModes = monitor.getSupportedModes(); Assert.assertTrue(monitorModes.size()>0); @@ -135,13 +136,13 @@ public class TestScreenMode01aNEWT extends UITestCase { } Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); - MonitorMode mmCurrent = monitor.queryCurrentMode(); - Assert.assertNotNull(mmCurrent); - MonitorMode mmOrig = monitor.getOriginalMode(); + final MonitorMode mmSet0 = monitor.queryCurrentMode(); + Assert.assertNotNull(mmSet0); + final MonitorMode mmOrig = monitor.getOriginalMode(); Assert.assertNotNull(mmOrig); System.err.println("[0] orig : "+mmOrig); - System.err.println("[0] current: "+mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); + System.err.println("[0] current: "+mmSet0); + Assert.assertEquals(mmSet0, mmOrig); monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc @@ -171,44 +172,43 @@ public class TestScreenMode01aNEWT extends UITestCase { Thread.sleep(waitTimeShort); - // check manual reset .. - Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window0.isNativeValid()); Assert.assertEquals(true,window0.isVisible()); - screen.addReference(); // keep it alive ! - Assert.assertTrue(monitor.setCurrentMode(mmOrig)); - Assert.assertFalse(monitor.isModeChangedByUs()); - Assert.assertEquals(mmOrig, monitor.getCurrentMode()); - Assert.assertNotSame(mm, monitor.getCurrentMode()); - Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); - + // Auto reset by destruction! destroyWindow(window0); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window0, false)); + Assert.assertEquals(false,window0.isVisible()); Assert.assertEquals(false,window0.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); // alive ! - Assert.assertEquals(true,display.isNativeValid()); + Assert.assertTrue(AWTRobotUtil.waitForRealized(screen, false)); + Assert.assertEquals(false,screen.isNativeValid()); + Assert.assertEquals(false,display.isNativeValid()); Thread.sleep(waitTimeShort); - - Window window1 = createWindow(screen, caps, "win1", - width+window0.getInsets().getTotalWidth(), 0, - width, height); - Assert.assertNotNull(window1); - Assert.assertEquals(true,window1.isNativeValid()); - Assert.assertEquals(true,window1.isVisible()); - Thread.sleep(waitTimeShort); + validateScreenModeReset(mmOrig, 0); + } + + void validateScreenModeReset(final MonitorMode mmOrig, int mmIdx) { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + Assert.assertEquals(false,display.isNativeValid()); + Assert.assertEquals(false,screen.isNativeValid()); + screen.addReference(); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); - destroyWindow(window1); - Assert.assertEquals(false,window1.isNativeValid()); - Assert.assertEquals(false,window1.isVisible()); + final MonitorDevice monitor = screen.getMonitorDevices().get(0); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); screen.removeReference(); + Assert.assertEquals(false,display.isNativeValid()); Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); } public static void main(String args[]) throws IOException { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java index c80760c1f..fbd08b619 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java @@ -46,6 +46,7 @@ import com.jogamp.newt.MonitorMode; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.newt.util.MonitorModeUtil; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; @@ -230,6 +231,8 @@ public class TestScreenMode01bNEWT extends UITestCase { Thread.sleep(duration); anim.stop(); destroyWindow(window0); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window0, false)); + Assert.assertEquals(false,window0.isVisible()); Assert.assertEquals(false,window0.isNativeValid()); Assert.assertEquals(true,display.isNativeValid()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java index 48ebaf86e..afb26d75c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java @@ -53,11 +53,17 @@ import com.jogamp.opengl.test.junit.util.UITestCase; import java.util.List; import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; /** * Demonstrates fullscreen without MonitorMode change * and fullscreen before and after MonitorMode change. *

    + * Also tests MonitorMode reset, by destroying the last Screen (reference), + * i.e. the original MonitorMode should get reinstated! + *

    + *

    * Also documents NV RANDR/GL bug, see {@link TestScreenMode01dNEWT#cleanupGL()}.

    */ public class TestScreenMode01dNEWT extends UITestCase { @@ -137,7 +143,7 @@ public class TestScreenMode01dNEWT extends UITestCase { } @Test - public void testFullscreenChange01() throws InterruptedException { + public void test01FullscreenChange01() throws InterruptedException { Thread.sleep(waitTimeShort); GLCapabilities caps = new GLCapabilities(glp); Assert.assertNotNull(caps); @@ -183,7 +189,7 @@ public class TestScreenMode01dNEWT extends UITestCase { } @Test - public void testScreenModeChange01() throws InterruptedException { + public void test02ScreenModeChange01() throws InterruptedException { Thread.sleep(waitTimeShort); GLCapabilities caps = new GLCapabilities(glp); @@ -195,7 +201,8 @@ public class TestScreenMode01dNEWT extends UITestCase { GLWindow window = createWindow(screen, caps, width, height, true /* onscreen */, false /* undecorated */); Assert.assertNotNull(window); - MonitorDevice monitor = window.getMainMonitor(); + final RectangleImmutable winRect = new Rectangle(window.getX(), window.getY(), window.getWidth(), window.getHeight()); + final MonitorDevice monitor = screen.getMainMonitor(winRect); List monitorModes = monitor.getSupportedModes(); Assert.assertTrue(monitorModes.size()>0); @@ -244,8 +251,6 @@ public class TestScreenMode01dNEWT extends UITestCase { Thread.sleep(waitTimeLong); - // check reset .. - Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isNativeValid()); @@ -265,33 +270,20 @@ public class TestScreenMode01dNEWT extends UITestCase { Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - screen.createNative(); // trigger native re-creation - - Assert.assertEquals(true,display.isNativeValid()); - Assert.assertEquals(true,screen.isNativeValid()); - - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - screen.destroy(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); - + validateScreenModeReset(mmOrig, winRect); cleanupGL(); } @Test - public void testScreenModeChangeWithFS01Pre() throws InterruptedException { + public void test03ScreenModeChangeWithFS01Post() throws InterruptedException { Thread.sleep(waitTimeShort); - testScreenModeChangeWithFS01Impl(true) ; + testScreenModeChangeWithFS01Impl(false) ; } @Test - public void testScreenModeChangeWithFS01Post() throws InterruptedException { + public void test04ScreenModeChangeWithFS01Pre() throws InterruptedException { Thread.sleep(waitTimeShort); - testScreenModeChangeWithFS01Impl(false) ; + testScreenModeChangeWithFS01Impl(true) ; } protected void testScreenModeChangeWithFS01Impl(boolean preFS) throws InterruptedException { @@ -302,7 +294,8 @@ public class TestScreenMode01dNEWT extends UITestCase { Animator animator = new Animator(window); animator.start(); - MonitorDevice monitor = window.getMainMonitor(); + final RectangleImmutable winRect = new Rectangle(window.getX(), window.getY(), window.getWidth(), window.getHeight()); + final MonitorDevice monitor = screen.getMainMonitor(winRect); MonitorMode mmCurrent = monitor.queryCurrentMode(); Assert.assertNotNull(mmCurrent); MonitorMode mmOrig = monitor.getOriginalMode(); @@ -347,8 +340,14 @@ public class TestScreenMode01dNEWT extends UITestCase { Thread.sleep(waitTimeLong); - // check reset .. - + if(!preFS) { + System.err.println("[0] set !FS post 0: "+window.isFullscreen()); + window.setFullscreen(false); + Assert.assertEquals(false, window.isFullscreen()); + System.err.println("[0] set !FS post X: "+window.isFullscreen()); + Thread.sleep(waitTimeShort); + } + Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isNativeValid()); @@ -368,23 +367,29 @@ public class TestScreenMode01dNEWT extends UITestCase { Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(false,display.isNativeValid()); - screen.createNative(); // trigger native re-creation + validateScreenModeReset(mmOrig, winRect); + cleanupGL(); + } + void validateScreenModeReset(final MonitorMode mmOrig, final RectangleImmutable rect) { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + Assert.assertEquals(false,display.isNativeValid()); + Assert.assertEquals(false,screen.isNativeValid()); + screen.addReference(); Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current/orig: "+mmCurrent); - screen.destroy(); - Assert.assertEquals(false,screen.isNativeValid()); - Assert.assertEquals(false,display.isNativeValid()); - - Assert.assertNotNull(mmCurrent); - Assert.assertEquals(mmCurrent, mmOrig); + final MonitorDevice monitor = screen.getMainMonitor(rect); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); - cleanupGL(); + screen.removeReference(); + Assert.assertEquals(false,display.isNativeValid()); + Assert.assertEquals(false,screen.isNativeValid()); } - + public static void main(String args[]) throws IOException { String tstname = TestScreenMode01dNEWT.class.getName(); org.junit.runner.JUnitCore.main(tstname); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java index aee9c28c2..f261a24a5 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java @@ -59,10 +59,6 @@ import javax.media.nativewindow.util.Dimension; *

    * MonitorMode change does not use highest resolution. *

    - *

    - * Also tests MonitorMode reset after last Screen is dereferenced, - * i.e. MonitorMode should be reinstated. - *

    */ public class TestScreenMode02aNEWT extends UITestCase { static GLProfile glp; @@ -200,6 +196,7 @@ public class TestScreenMode02aNEWT extends UITestCase { } if(changeMode) { + // manual restore! monitor.setCurrentMode(mmOrig); Assert.assertFalse(monitor.isModeChangedByUs()); Assert.assertEquals(mmOrig, monitor.getCurrentMode()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java index bd7ac55db..f0dbb1ffc 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java @@ -204,17 +204,16 @@ public class TestScreenMode02bNEWT extends UITestCase { window.setFullscreen(false); } + // manual restore! monitor.setCurrentMode(mmOrig); Assert.assertFalse(monitor.isModeChangedByUs()); - Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); Thread.sleep(waitTimeShort); if( preVis ) { window.setFullscreen(false); } - // check auto reset .. - Assert.assertEquals(true,display.isNativeValid()); Assert.assertEquals(true,screen.isNativeValid()); Assert.assertEquals(true,window.isNativeValid()); -- cgit v1.2.3 From fa6e868a72b8fb3de8c96afbd71ab4d3ad33f6b6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 14:46:28 +0200 Subject: Revisit Bug 770 and Bug 771: Only use FLAG_IS_FULLSCREEN_SPAN if required; At MonitoMode change, reset fullscreen if FLAG_IS_FULLSCREEN_SPAN is supported. - Bug 770: Only use FLAG_IS_FULLSCREEN_SPAN if required - If X11 WindowDriver _and_ virtual-screen-size > fullscreenViewport, - else we still use _NET_WM_STATE_FULLSCREEN on X11! - Bug 771: At MonitoMode change, reset fullscreen if FLAG_IS_FULLSCREEN_SPAN is supported - Since we may still use _NET_WM_STATE_FULLSCREEN on X11: - Pause fullscreen at monitorModeChangeNotify(..) - Resume fullscreen at monitorModeChanged(..) --- make/scripts/tests.sh | 4 +- src/newt/classes/jogamp/newt/ScreenImpl.java | 10 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 67 ++++++++++++++++------ src/newt/classes/jogamp/newt/driver/x11/RandR.java | 6 +- .../classes/jogamp/newt/driver/x11/RandR11.java | 7 +++ .../classes/jogamp/newt/driver/x11/RandR13.java | 46 +++------------ .../jogamp/newt/driver/x11/ScreenDriver.java | 34 ++++++++--- .../jogamp/newt/driver/x11/WindowDriver.java | 47 +++++++++++---- .../test/junit/newt/mm/TestScreenMode01dNEWT.java | 1 + .../test/junit/newt/mm/TestScreenMode02aNEWT.java | 4 ++ 10 files changed, 142 insertions(+), 84 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 640e6a01d..8137f5f0f 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -406,8 +406,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index 422d5b06c..c02f4f288 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -284,12 +284,12 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { vOriginSize.setWidth(usrSize.getWidth()); vOriginSize.setHeight(usrSize.getHeight()); if(DEBUG) { - System.err.println("User virtual screen viewport "+vOriginSize); + System.err.println("Update user virtual screen viewport @ "+Thread.currentThread().getName()+": "+vOriginSize); } } else { calcVirtualScreenOriginAndSize(vOriginSize); if(DEBUG) { - System.err.println("Detected virtual screen viewport "+vOriginSize); + System.err.println("Updated virtual screen viewport @ "+Thread.currentThread().getName()+": "+vOriginSize); } } } @@ -396,7 +396,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { @Override public void monitorModeChangeNotify(MonitorEvent me) { if(DEBUG) { - System.err.println("monitorModeChangeNotify: "+me); + System.err.println("monitorModeChangeNotify @ "+Thread.currentThread().getName()+": "+me); } for(int i=0; i "+newViewport); + System.err.println("Screen.updateMonitorViewport["+i+"] @ "+Thread.currentThread().getName()+": "+monitor.getViewport()+" -> "+newViewport); } if( null != newViewport ) { monitor.setViewportValue(newViewport); @@ -424,7 +424,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { updateVirtualScreenOriginAndSize(); } if(DEBUG) { - System.err.println("monitorModeChanged: success "+success+", "+me); + System.err.println("monitorModeChangeNotify @ "+Thread.currentThread().getName()+": success "+success+", "+me); } for(int i=0; i fullscreenMonitors = null; private boolean fullscreenUseMainMonitor = true; + private boolean fullscreenUseSpanningMode = true; // spanning mode: fake full screen, only on certain platforms private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets @@ -251,6 +252,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreen = false; fullscreenMonitors = null; fullscreenUseMainMonitor = true; + fullscreenUseSpanningMode = false; hasFocus = false; parentWindowHandle = 0; } @@ -560,6 +562,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @see #positionChanged(boolean,int, int) */ protected abstract boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags); + + /** + * Tests whether a single reconfigure flag is supported by implementation. + *

    + * Default is all but {@link #FLAG_IS_FULLSCREEN_SPAN} + *

    + */ + protected boolean isReconfigureFlagSupported(int changeFlags) { + return 0 == ( changeFlags & FLAG_IS_FULLSCREEN_SPAN ); + } protected int getReconfigureFlags(int changeFlags, boolean visible) { return changeFlags |= ( ( 0 != getParentWindowHandle() ) ? FLAG_HAS_PARENT : 0 ) | @@ -1018,6 +1030,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreen = false; fullscreenMonitors = null; fullscreenUseMainMonitor = true; + fullscreenUseSpanningMode = false; hasFocus = false; parentWindowHandle = 0; @@ -1874,7 +1887,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x,y,w,h; - final RectangleImmutable viewport; + final RectangleImmutable sviewport = screen.getViewport(); + final RectangleImmutable viewport; final int fs_span_flag; if(fullscreen) { if( null == fullscreenMonitors ) { @@ -1885,19 +1899,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreenMonitors = getScreen().getMonitorDevices(); } } - /** - * Bug 770: - * _NET_WM_STATE_FULLSCREEN may result in ConfigureNotify event w/ virtual screen size, instead of monitor-mode size (NV + Fglrx). - * ConfigureNotify reflects the actual size of the window and is being propagated - * to NEWT and the GLEventListener. - * With Mesa/Intel open-source driver, the correct desired monitor mode size is reported - * at least on one test machine here. - * - * Bug 771: Implementation requires not to use _NET_WM_STATE_FULLSCREEN! - */ - // fs_span_flag = monitors.size() > 1 ? FLAG_IS_FULLSCREEN_SPAN : 0 ; - fs_span_flag = FLAG_IS_FULLSCREEN_SPAN; viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); + if( isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN) && + ( fullscreenMonitors.size() > 1 || sviewport.compareTo(viewport) > 0 ) ) { + fullscreenUseSpanningMode = true; + fs_span_flag = FLAG_IS_FULLSCREEN_SPAN; + } else { + fullscreenUseSpanningMode = false; + fs_span_flag = 0; + } nfs_x = getX(); nfs_y = getY(); nfs_width = getWidth(); @@ -1908,6 +1918,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer h = viewport.getHeight(); } else { fullscreenUseMainMonitor = true; + fullscreenUseSpanningMode = false; fullscreenMonitors = null; fs_span_flag = 0; viewport = null; @@ -1932,7 +1943,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ - ", virtl-size: "+screen.getWidth()+"x"+screen.getHeight()+", monitorsViewport "+viewport); + ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+ + ", spanning "+fullscreenUseSpanningMode+" @ "+Thread.currentThread().getName()); } final DisplayImpl display = (DisplayImpl) screen.getDisplay(); @@ -1991,6 +2003,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer synchronized(fullScreenAction) { fullscreenMonitors = monitors; fullscreenUseMainMonitor = useMainMonitor; + fullscreenUseSpanningMode = false; if( fullScreenAction.init(fullscreen) ) { if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance @@ -2021,21 +2034,33 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class MonitorModeListenerImpl implements MonitorModeListener { boolean animatorPaused = false; boolean hadFocus = false; + boolean fullscreenPaused = false; + List _fullscreenMonitors = null; + boolean _fullscreenUseMainMonitor = true; public void monitorModeChangeNotify(MonitorEvent me) { hadFocus = hasFocus(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.monitorModeChangeNotify: hadFocus "+hadFocus+", "+me); + System.err.println("Window.monitorModeChangeNotify: hadFocus "+hadFocus+", "+me+" @ "+Thread.currentThread().getName()); } if(null!=lifecycleHook) { animatorPaused = lifecycleHook.pauseRenderingAction(); } + if( fullscreen && isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN) ) { + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.monitorModeChangeNotify: FS Pause"); + } + fullscreenPaused = true; + _fullscreenMonitors = fullscreenMonitors; + _fullscreenUseMainMonitor = fullscreenUseMainMonitor; + setFullscreenImpl(false, true, null); + } } public void monitorModeChanged(MonitorEvent me, boolean success) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.monitorModeChanged: hadFocus "+hadFocus+", "+me+", success: "+success); + System.err.println("Window.monitorModeChanged: hadFocus "+hadFocus+", "+me+", success: "+success+" @ "+Thread.currentThread().getName()); } if(success) { @@ -2043,7 +2068,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Didn't pass above notify method. probably detected screen change after it happened. animatorPaused = lifecycleHook.pauseRenderingAction(); } - if( !fullscreen ) { + if( !fullscreen && !fullscreenPaused ) { // Simply move/resize window to fit in virtual screen if required final RectangleImmutable viewport = screen.getViewport(); if( viewport.getWidth() > 0 && viewport.getHeight() > 0 ) { // failsafe @@ -2059,6 +2084,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setSize(viewport.getWidth(), viewport.getHeight()); } } + } else if( fullscreenPaused ){ + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.monitorModeChanged: FS Restore"); + } + setFullscreenImpl(true, _fullscreenUseMainMonitor, _fullscreenMonitors); + fullscreenPaused = false; + _fullscreenMonitors = null; + _fullscreenUseMainMonitor = true; } else { // If changed monitor is part of this fullscreen mode, reset size! (Bug 771) final MonitorDevice md = me.getMonitor(); diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR.java b/src/newt/classes/jogamp/newt/driver/x11/RandR.java index 769ebe225..e39a6c63a 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR.java @@ -29,6 +29,8 @@ package jogamp.newt.driver.x11; import java.util.List; +import javax.media.nativewindow.util.RectangleImmutable; + import jogamp.newt.MonitorModeProps; import com.jogamp.common.util.VersionNumber; @@ -78,5 +80,7 @@ public interface RandR { int[] getMonitorDeviceProps(final long dpy, final ScreenDriver screen, MonitorModeProps.Cache cache, final int crt_idx); int[] getMonitorDeviceViewport(final long dpy, final ScreenDriver screen, final int crt_idx); int[] getCurrentMonitorModeProps(final long dpy, final ScreenDriver screen, final int crt_idx); - boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode); + boolean setCurrentMonitorMode(final long dpy, final ScreenDriver screen, MonitorDevice monitor, final MonitorMode mode); + + public void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java index 58468e112..877607f72 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR11.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR11.java @@ -27,6 +27,8 @@ */ package jogamp.newt.driver.x11; +import javax.media.nativewindow.util.RectangleImmutable; + import jogamp.newt.MonitorModeProps; import jogamp.newt.ScreenImpl; @@ -333,6 +335,11 @@ class RandR11 implements RandR { } return done; } + + @Override + public final void updateScreenViewport(final long dpy, final ScreenDriver screen, RectangleImmutable viewport) { + // nop + } /** @return int[] { rot1, .. } */ private static native int[] getAvailableScreenRotations0(long display, int screen_index); diff --git a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java index 375cffe42..ac83fc5f2 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/RandR13.java +++ b/src/newt/classes/jogamp/newt/driver/x11/RandR13.java @@ -29,6 +29,8 @@ package jogamp.newt.driver.x11; import java.util.Iterator; +import javax.media.nativewindow.util.RectangleImmutable; + import jogamp.newt.MonitorModeProps; import com.jogamp.common.util.IntLongHashMap; @@ -235,54 +237,20 @@ class RandR13 implements RandR { } finally { releaseScreenResourceHandle(screenResources); } - /*** - * TODO: Would need a complete re-layout of crt positions, - * which is _not_ implicit by XRandR .. sadly. - * - if( res ) { - updateScreenViewport(dpy, screen, monitor); - } */ return res; } - /** See above .. - private final void updateScreenViewport(final long dpy, final ScreenDriver screen, MonitorDevice monitor) { + @Override + public final void updateScreenViewport(final long dpy, final ScreenDriver screen, final RectangleImmutable viewport) { final int screen_idx = screen.getIndex(); final long screenResources = getScreenResourceHandle(dpy, screen_idx); try { - RectangleImmutable newViewp = null; - final long monitorInfo = getMonitorInfoHandle(dpy, screen_idx, screenResources, monitor.getId()); - try { - final int[] vprops = getMonitorViewport0(monitorInfo); - if( null != vprops ) { - newViewp = new Rectangle(vprops[0], vprops[1], vprops[2], vprops[3]); - } - System.err.println("XXX setScreenViewport: newVp "+newViewp); - } finally { - releaseMonitorInfoHandle(monitorInfo); - } - if( null != newViewp ) { - final List monitors = screen.getMonitorDevices(); - final ArrayList viewports = new ArrayList(); - for(int i=0; i "+newScrnViewp); - setScreenViewport0(dpy, screen_idx, screenResources, newScrnViewp.getX(), newScrnViewp.getY(), newScrnViewp.getWidth(), newScrnViewp.getHeight()); - } + setScreenViewport0(dpy, screen_idx, screenResources, viewport.getX(), viewport.getY(), viewport.getWidth(), viewport.getHeight()); } finally { dumpInfo0(dpy, screen_idx, screenResources); releaseScreenResourceHandle(screenResources); - } - } */ + } + } private static native long getScreenResources0(long display, int screen_index); private static native void freeScreenResources0(long screenResources); diff --git a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java index 19a69a3f9..1335f5697 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/ScreenDriver.java @@ -38,6 +38,7 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.util.Rectangle; +import javax.media.nativewindow.util.RectangleImmutable; import jogamp.nativewindow.x11.X11Util; import jogamp.newt.Debug; @@ -218,14 +219,31 @@ public class ScreenDriver extends ScreenImpl { @Override protected void calcVirtualScreenOriginAndSize(final Rectangle vOriginSize) { - runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - public Object run(long dpy) { - vOriginSize.setX(0); - vOriginSize.setY(0); - vOriginSize.setWidth(getWidth0(dpy, screen_idx)); - vOriginSize.setHeight(getHeight0(dpy, screen_idx)); - return null; - } } ); + final RectangleImmutable ov = (RectangleImmutable) getViewport().cloneMutable(); + /** + if( null != rAndR && rAndR.getVersion().compareTo(RandR.version130) >= 0 && getMonitorDevices().size()>0 ) { + super.calcVirtualScreenOriginAndSize(vOriginSize); + if( DEBUG ) { + System.err.println("X11Screen.calcVirtualScreenOriginAndSize: UpdatingViewport "+ov+" -> "+vOriginSize); + } + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + rAndR.updateScreenViewport(dpy, ScreenDriver.this, vOriginSize); + return null; + } } ); + } else */ { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + public Object run(long dpy) { + vOriginSize.setX(0); + vOriginSize.setY(0); + vOriginSize.setWidth(getWidth0(dpy, screen_idx)); + vOriginSize.setHeight(getHeight0(dpy, screen_idx)); + return null; + } } ); + if( DEBUG ) { + System.err.println("X11Screen.calcVirtualScreenOriginAndSize: Querying X11: "+ov+" -> "+vOriginSize); + } + } } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index aec7f310e..4786ea04f 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -65,6 +65,7 @@ public class WindowDriver extends WindowImpl { public WindowDriver() { } + @Override protected void createNativeImpl() { final ScreenDriver screen = (ScreenDriver) getScreen(); final DisplayDriver display = (DisplayDriver) screen.getDisplay(); @@ -109,6 +110,7 @@ public class WindowDriver extends WindowImpl { } } + @Override protected void closeNativeImpl() { if(0!=windowHandleClose && null!=getScreen() ) { DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); @@ -133,6 +135,18 @@ public class WindowDriver extends WindowImpl { } } + /** + *

    + * X11 Window supports {@link #FLAG_IS_FULLSCREEN_SPAN} + *

    + * {@inheritDoc} + */ + @Override + protected boolean isReconfigureFlagSupported(int changeFlags) { + return true; // all flags! + } + + @Override protected boolean reconfigureWindowImpl(final int x, final int y, final int width, final int height, int flags) { if(DEBUG_IMPLEMENTATION) { System.err.println("X11Window reconfig: "+x+"/"+y+" "+width+"x"+height+", "+ getReconfigureFlagsAsString(null, flags)); @@ -148,14 +162,16 @@ public class WindowDriver extends WindowImpl { _x = x; _y = y; } - if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { - tempAlwaysOnTop = true; - flags |= FLAG_IS_ALWAYSONTOP; - if(DEBUG_IMPLEMENTATION) { - System.err.println("X11Window reconfig.2: temporary "+getReconfigureFlagsAsString(null, flags)); + if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags ) ) { + if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 != ( FLAG_IS_FULLSCREEN_SPAN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { + tempFSAlwaysOnTop = true; + flags |= FLAG_IS_ALWAYSONTOP; + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig.2: temporary "+getReconfigureFlagsAsString(null, flags)); + } + } else { + tempFSAlwaysOnTop = false; } - } else { - tempAlwaysOnTop = false; } final int fflags = flags; final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); @@ -169,7 +185,7 @@ public class WindowDriver extends WindowImpl { }); return true; } - volatile boolean tempAlwaysOnTop = false; + volatile boolean tempFSAlwaysOnTop = false; /** *

    @@ -177,9 +193,13 @@ public class WindowDriver extends WindowImpl { *

    * {@inheritDoc} */ + @Override protected void focusChanged(boolean defer, boolean focusGained) { - if( tempAlwaysOnTop && hasFocus() != focusGained && isNativeValid() ) { + if( tempFSAlwaysOnTop && hasFocus() != focusGained && isNativeValid() ) { final int flags = getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible()) | ( focusGained ? FLAG_IS_ALWAYSONTOP : 0 ); + if(DEBUG_IMPLEMENTATION) { + System.err.println("X11Window reconfig.3 (focus): temporary "+getReconfigureFlagsAsString(null, flags)); + } final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { @@ -192,8 +212,7 @@ public class WindowDriver extends WindowImpl { } super.focusChanged(defer, focusGained); } - - + protected void reparentNotify(long newParentWindowHandle) { if(DEBUG_IMPLEMENTATION) { final long p0 = getParentWindowHandle(); @@ -201,6 +220,7 @@ public class WindowDriver extends WindowImpl { } } + @Override protected void requestFocusImpl(final boolean force) { runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Object run(long dpy) { @@ -248,6 +268,7 @@ public class WindowDriver extends WindowImpl { }); } + @Override protected Point getLocationOnScreenImpl(final int x, final int y) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { public Point run(long dpy) { @@ -256,6 +277,7 @@ public class WindowDriver extends WindowImpl { } ); } + @Override protected void updateInsetsImpl(Insets insets) { // nop - using event driven insetsChange(..) } @@ -304,7 +326,8 @@ public class WindowDriver extends WindowImpl { } super.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } - + + /** Called by native TK */ protected final void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar0, String keyString) { // handleKeyEvent(true, false, eventType, modifiers, keyCode, keyChar); final boolean isModifierKey = KeyEvent.isModifierKey(keyCode); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java index afb26d75c..c480d1759 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java @@ -328,6 +328,7 @@ public class TestScreenMode01dNEWT extends UITestCase { System.err.println("[0] set FS pre X: "+window.isFullscreen()); } + Thread.sleep(waitTimeShort); System.err.println("[0] set current: "+monitorMode); monitor.setCurrentMode(monitorMode); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java index f261a24a5..f10477333 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java @@ -138,6 +138,8 @@ public class TestScreenMode02aNEWT extends UITestCase { final MonitorMode mmOrig = monitor.getOriginalMode(); Assert.assertNotNull(mmOrig); if(changeMode) { + Thread.sleep(waitTimeShort); + List monitorModes = monitor.getSupportedModes(); if(monitorModes.size()==1) { // no support .. @@ -196,6 +198,8 @@ public class TestScreenMode02aNEWT extends UITestCase { } if(changeMode) { + Thread.sleep(waitTimeShort); + // manual restore! monitor.setCurrentMode(mmOrig); Assert.assertFalse(monitor.isModeChangedByUs()); -- cgit v1.2.3 From 5b81a51c1f695b0e0750ec47149216e26b8ed14b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 15:39:00 +0200 Subject: X11Window FullScreen: Toggle _NET_WM_BYPASS_COMPOSITOR not only for ABOVE .. but also for FULLSCREEN WM state. --- make/scripts/tests.sh | 4 ++-- src/newt/native/X11Window.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8137f5f0f..640e6a01d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -406,8 +406,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 4a95d0180..e6e300d2e 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -388,8 +388,8 @@ static Bool NewtWindows_setStackingEWMHFlags (Display *dpy, Window root, Window XSendEvent ( dpy, root, False, mask, &xev ); } - // If ABOVE is changed, also change _NET_WM_BYPASS_COMPOSITOR! - if( changeAbove ) { + // Also change _NET_WM_BYPASS_COMPOSITOR! + { Atom _NET_WM_BYPASS_COMPOSITOR = XInternAtom( dpy, "_NET_WM_BYPASS_COMPOSITOR", False ); unsigned long value = enable ? 1 : 0; XChangeProperty( dpy, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&value, 1); -- cgit v1.2.3 From c6a20c623cc3f9fdf052a85ea0d779956a1ae954 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 17:17:08 +0200 Subject: TestScreenMode*: Be more verbose setting screen mode. --- make/scripts/tests.sh | 6 ++-- .../test/junit/newt/mm/TestScreenMode01aNEWT.java | 20 ++++++++---- .../test/junit/newt/mm/TestScreenMode01bNEWT.java | 37 ++++++++++++++-------- .../test/junit/newt/mm/TestScreenMode01dNEWT.java | 36 +++++++++++++++------ .../test/junit/newt/mm/TestScreenMode02aNEWT.java | 34 +++++++++++++------- .../test/junit/newt/mm/TestScreenMode02bNEWT.java | 32 +++++++++++++------ 6 files changed, 110 insertions(+), 55 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 640e6a01d..73012518d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -136,7 +136,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -406,8 +406,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java index 8846812e5..d756957d7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01aNEWT.java @@ -162,13 +162,19 @@ public class TestScreenMode01aNEWT extends UITestCase { Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - MonitorMode mm = monitorModes.get(0); - System.err.println("[0] set current: "+mm); - Assert.assertTrue(monitor.setCurrentMode(mm)); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(mm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(mm, monitor.queryCurrentMode()); + // set mode + { + MonitorMode mm = monitorModes.get(0); + System.err.println("[0] set current: "+mm); + final boolean smOk = monitor.setCurrentMode(mm); + MonitorMode mmCurrent = monitor.getCurrentMode(); + System.err.println("[0] has current: "+mmCurrent+", changeOK "+smOk); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, mmCurrent); + Assert.assertNotSame(mmOrig, mmCurrent); + Assert.assertEquals(mmCurrent, monitor.queryCurrentMode()); + Assert.assertTrue(smOk); + } Thread.sleep(waitTimeShort); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java index fbd08b619..2d70b42bb 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01bNEWT.java @@ -197,15 +197,19 @@ public class TestScreenMode01bNEWT extends UITestCase { Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[1] set current: "+sm); - Assert.assertTrue(monitor.setCurrentMode(sm)); - mmCurrent = monitor.getCurrentMode(); - System.err.println("[1] current: "+mmCurrent); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); + // set mode + { + MonitorMode mm = monitorModes.get(0); + System.err.println("[0] set current: "+mm); + final boolean smOk = monitor.setCurrentMode(mm); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[0] has current: "+mmCurrent+", changeOK "+smOk); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, mmCurrent); + Assert.assertNotSame(mmOrig, mmCurrent); + Assert.assertEquals(mmCurrent, monitor.queryCurrentMode()); + Assert.assertTrue(smOk); + } System.err.println("Test.1: Window screen: "+screen); System.err.println("Test.1: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); @@ -218,11 +222,16 @@ public class TestScreenMode01bNEWT extends UITestCase { Assert.assertEquals(true,window0.isNativeValid()); Assert.assertEquals(true,window0.isVisible()); - Assert.assertTrue(monitor.setCurrentMode(mmOrig)); - Assert.assertFalse(monitor.isModeChangedByUs()); - Assert.assertEquals(mmOrig, monitor.getCurrentMode()); - Assert.assertNotSame(sm, monitor.getCurrentMode()); - Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); + // manual restore! + { + System.err.println("[1] set orig: "+mmOrig); + final boolean smOk = monitor.setCurrentMode(mmOrig); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] has orig?: "+mmCurrent+", changeOK "+smOk); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, mmCurrent); + Assert.assertTrue(smOk); + } System.err.println("Test.2: Window screen: "+screen); System.err.println("Test.2: Window bounds: "+window0.getX()+"/"+window0.getY()+" "+window0.getWidth()+"x"+window0.getHeight()+" within "+screen.getViewport()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java index c480d1759..31829135b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode01dNEWT.java @@ -241,13 +241,19 @@ public class TestScreenMode01dNEWT extends UITestCase { Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - MonitorMode sm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+sm); - monitor.setCurrentMode(sm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(sm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(sm, monitor.queryCurrentMode()); + // set mode + { + MonitorMode sm = (MonitorMode) monitorModes.get(0); + System.err.println("[0] set current: "+sm); + final boolean smOk = monitor.setCurrentMode(sm); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[0] has current: "+mmCurrent+", changeOK "+smOk); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(sm, mmCurrent); + Assert.assertNotSame(mmOrig, mmCurrent); + Assert.assertEquals(mmCurrent, monitor.queryCurrentMode()); + Assert.assertTrue(smOk); + } Thread.sleep(waitTimeLong); @@ -327,10 +333,20 @@ public class TestScreenMode01dNEWT extends UITestCase { Assert.assertEquals(true, window.isFullscreen()); System.err.println("[0] set FS pre X: "+window.isFullscreen()); } - Thread.sleep(waitTimeShort); - System.err.println("[0] set current: "+monitorMode); - monitor.setCurrentMode(monitorMode); + + // set mode + { + System.err.println("[0] set current: "+monitorMode); + final boolean smOk = monitor.setCurrentMode(monitorMode); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[0] has current: "+mmCurrent+", changeOK "+smOk); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(monitorMode, mmCurrent); + Assert.assertNotSame(mmOrig, mmCurrent); + Assert.assertEquals(mmCurrent, monitor.queryCurrentMode()); + Assert.assertTrue(smOk); + } if(!preFS) { System.err.println("[0] set FS post 0: "+window.isFullscreen()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java index f10477333..ceb732fda 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02aNEWT.java @@ -149,7 +149,7 @@ public class TestScreenMode02aNEWT extends UITestCase { } Assert.assertTrue(monitorModes.size()>0); - final MonitorMode mmCurrent = monitor.getCurrentMode(); + MonitorMode mmCurrent = monitor.getCurrentMode(); Assert.assertNotNull(mmCurrent); System.err.println("[0] orig : "+mmOrig); System.err.println("[0] current: "+mmCurrent); @@ -175,13 +175,19 @@ public class TestScreenMode02aNEWT extends UITestCase { Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - MonitorMode mm = (MonitorMode) monitorModes.get(0); - System.err.println("[0] set current: "+mm); - monitor.setCurrentMode(mm); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(mm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(mm, monitor.queryCurrentMode()); + // set mode + { + MonitorMode mm = monitorModes.get(0); + System.err.println("[0] set current: "+mm); + final boolean smOk = monitor.setCurrentMode(mm); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[0] has current: "+mmCurrent+", changeOK "+smOk); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, mmCurrent); + Assert.assertNotSame(mmOrig, mmCurrent); + Assert.assertEquals(mmCurrent, monitor.queryCurrentMode()); + Assert.assertTrue(smOk); + } } if( !preVis ) { @@ -201,9 +207,15 @@ public class TestScreenMode02aNEWT extends UITestCase { Thread.sleep(waitTimeShort); // manual restore! - monitor.setCurrentMode(mmOrig); - Assert.assertFalse(monitor.isModeChangedByUs()); - Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + { + System.err.println("[1] set orig: "+mmOrig); + final boolean smOk = monitor.setCurrentMode(mmOrig); + MonitorMode mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] has orig?: "+mmCurrent+", changeOK "+smOk); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, mmCurrent); + Assert.assertTrue(smOk); + } Thread.sleep(waitTimeShort); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java index f0dbb1ffc..4e1007fde 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode02bNEWT.java @@ -185,13 +185,19 @@ public class TestScreenMode02bNEWT extends UITestCase { Assert.assertNotNull(monitorModes); Assert.assertTrue(monitorModes.size()>0); - MonitorMode mm = monitorModes.get(0); // highest resolution .. - System.err.println("[0] set current: "+mm); - Assert.assertTrue(monitor.setCurrentMode(mm)); - Assert.assertTrue(monitor.isModeChangedByUs()); - Assert.assertEquals(mm, monitor.getCurrentMode()); - Assert.assertNotSame(mmOrig, monitor.getCurrentMode()); - Assert.assertEquals(mm, monitor.queryCurrentMode()); + // set mode + { + MonitorMode mm = monitorModes.get(0); // highest resolution .. + System.err.println("[0] set current: "+mm); + final boolean smOk = monitor.setCurrentMode(mm); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[0] has current: "+mmCurrent+", changeOK "+smOk); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, mmCurrent); + Assert.assertNotSame(mmOrig, mmCurrent); + Assert.assertEquals(mmCurrent, monitor.queryCurrentMode()); + Assert.assertTrue(smOk); + } if( !preVis ) { window.setFullscreen(true); @@ -205,9 +211,15 @@ public class TestScreenMode02bNEWT extends UITestCase { } // manual restore! - monitor.setCurrentMode(mmOrig); - Assert.assertFalse(monitor.isModeChangedByUs()); - Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); + { + System.err.println("[1] set orig: "+mmOrig); + final boolean smOk = monitor.setCurrentMode(mmOrig); + mmCurrent = monitor.getCurrentMode(); + System.err.println("[1] has orig?: "+mmCurrent+", changeOK "+smOk); + Assert.assertFalse(monitor.isModeChangedByUs()); + Assert.assertEquals(mmOrig, mmCurrent); + Assert.assertTrue(smOk); + } Thread.sleep(waitTimeShort); if( preVis ) { -- cgit v1.2.3 From 99479bf3197cde8e89c5b499d135417863d521c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 4 Jul 2013 20:19:35 +0200 Subject: NEWT: Using WeakReferences for global cache of Display, Screen and Window instances; Removing ref. at API destroy() is wrong ; Allow GC to clear .. - Removing ref. at API destroy() is wrong - Since all instances can be recreated, removing ref at destroy() is simply wrong. - Keep weak references until GC collects, i.e. user does not claim them anymore. - Safe for Display, since it holds it's EDT thread. - Window/Screen .. if user abandons reference .. nothing we can do here. - Allow GC to clear .. No need to hold ref loonger than user. --- make/scripts/tests.sh | 5 +- .../opengl/macosx/cgl/MacOSXCGLDrawable.java | 6 +- src/newt/classes/com/jogamp/newt/Display.java | 66 ++++++++++++++++------ src/newt/classes/com/jogamp/newt/Screen.java | 56 ++++++++++++++---- src/newt/classes/jogamp/newt/DisplayImpl.java | 60 ++++++++++---------- src/newt/classes/jogamp/newt/ScreenImpl.java | 29 +++++----- src/newt/classes/jogamp/newt/WindowImpl.java | 33 +++++++---- 7 files changed, 169 insertions(+), 86 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 73012518d..1ba0a36c6 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -136,6 +136,7 @@ function jrun() { #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" @@ -400,14 +401,14 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT -#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT +testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03aNEWT $* #testnoawt -Djava.awt.headless=true com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index 910158d1f..4bd7bc994 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -117,8 +117,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { createdContexts.add(new WeakReference(osxCtx)); } else { for(int i=0; i ref = createdContexts.get(i); - final MacOSXCGLContext _ctx = ref.get(); + final MacOSXCGLContext _ctx = createdContexts.get(i).get(); if( _ctx == null || _ctx == ctx) { createdContexts.remove(i); } else { @@ -134,8 +133,7 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { if(doubleBuffered) { synchronized (createdContexts) { for(int i=0; i ref = createdContexts.get(i); - final MacOSXCGLContext ctx = ref.get(); + final MacOSXCGLContext ctx = createdContexts.get(i).get(); if (ctx != null) { ctx.swapBuffers(); i++; diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index d6ddd9613..4f5df6c70 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -31,6 +31,7 @@ package com.jogamp.newt; import com.jogamp.newt.util.EDTUtil; import jogamp.newt.Debug; +import java.lang.ref.WeakReference; import java.util.*; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -178,16 +179,16 @@ public abstract class Display { public abstract void dispatchMessages(); // Global Displays - protected static final ArrayList displayList = new ArrayList(); + protected static final ArrayList> displayList = new ArrayList>(); protected static int displaysActive = 0; public static void dumpDisplayList(String prefix) { synchronized(displayList) { - Iterator i = displayList.iterator(); System.err.println(prefix+" DisplayList[] entries: "+displayList.size()+" - "+getThreadName()); - for(int j=0; i.hasNext(); j++) { - Display d = i.next(); - System.err.println(" ["+j+"] : "+d); + final Iterator> ri = displayList.iterator(); + for(int j=0; ri.hasNext(); j++) { + final Display d = ri.next().get(); + System.err.println(" ["+j+"] : "+d+", GC'ed "+(null==d)); } } } @@ -216,29 +217,62 @@ public abstract class Display { return getDisplayOfImpl(type, name, fromIndex, -1, shared); } - private static Display getDisplayOfImpl(String type, String name, int fromIndex, int incr, boolean shared) { + private static Display getDisplayOfImpl(String type, String name, final int fromIndex, final int incr, boolean shared) { synchronized(displayList) { int i = fromIndex >= 0 ? fromIndex : displayList.size() - 1 ; while( ( incr > 0 ) ? i < displayList.size() : i >= 0 ) { - Display display = (Display) displayList.get(i); - if( display.getType().equals(type) && - display.getName().equals(name) && - ( !shared || shared && !display.isExclusive() ) - ) { - return display; + final Display display = (Display) displayList.get(i).get(); + if( null == display ) { + // Clear GC'ed dead reference entry! + displayList.remove(i); + if( incr < 0 ) { + // decrease + i+=incr; + } // else nop - remove shifted subsequent elements to the left + } else { + if( display.getType().equals(type) && + display.getName().equals(name) && + ( !shared || shared && !display.isExclusive() ) + ) { + return display; + } + i+=incr; } - i+=incr; } } return null; } - + + protected static void addDisplay2List(Display display) { + synchronized(displayList) { + // GC before add + int i=0; + while( i < displayList.size() ) { + if( null == displayList.get(i).get() ) { + displayList.remove(i); + } else { + i++; + } + } + displayList.add(new WeakReference(display)); + } + } + /** Returns the global display collection */ - @SuppressWarnings("unchecked") public static Collection getAllDisplays() { ArrayList list; synchronized(displayList) { - list = (ArrayList) displayList.clone(); + list = new ArrayList(); + int i = 0; + while( i < displayList.size() ) { + final Display d = displayList.get(i).get(); + if( null == d ) { + displayList.remove(i); + } else { + list.add( displayList.get(i).get() ); + i++; + } + } } return list; } diff --git a/src/newt/classes/com/jogamp/newt/Screen.java b/src/newt/classes/com/jogamp/newt/Screen.java index cf8145561..f56ee344b 100644 --- a/src/newt/classes/com/jogamp/newt/Screen.java +++ b/src/newt/classes/com/jogamp/newt/Screen.java @@ -29,6 +29,8 @@ package com.jogamp.newt; import com.jogamp.newt.event.MonitorModeListener; import jogamp.newt.Debug; + +import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -224,7 +226,7 @@ public abstract class Screen { public abstract void removeMonitorModeListener(MonitorModeListener sml); // Global Screens - protected static ArrayList screenList = new ArrayList(); + protected static final ArrayList> screenList = new ArrayList>(); protected static int screensActive = 0; /** @@ -253,26 +255,60 @@ public abstract class Screen { synchronized(screenList) { int i = fromIndex >= 0 ? fromIndex : screenList.size() - 1 ; while( ( incr > 0 ) ? i < screenList.size() : i >= 0 ) { - Screen screen = (Screen) screenList.get(i); - if( screen.getDisplay().equals(display) && - screen.getIndex() == idx ) { - return screen; + final Screen screen = (Screen) screenList.get(i).get(); + if( null == screen ) { + // Clear GC'ed dead reference entry! + screenList.remove(i); + if( incr < 0 ) { + // decrease + i+=incr; + } // else nop - remove shifted subsequent elements to the left + } else { + if( screen.getDisplay().equals(display) && + screen.getIndex() == idx ) { + return screen; + } + i+=incr; } - i+=incr; } } return null; } - /** Returns the global display collection */ - @SuppressWarnings("unchecked") + + protected static void addScreen2List(Screen screen) { + synchronized(screenList) { + // GC before add + int i=0; + while( i < screenList.size() ) { + if( null == screenList.get(i).get() ) { + screenList.remove(i); + } else { + i++; + } + } + screenList.add(new WeakReference(screen)); + } + } + + /** Returns the global screen collection */ public static Collection getAllScreens() { ArrayList list; synchronized(screenList) { - list = (ArrayList) screenList.clone(); + list = new ArrayList(); + int i = 0; + while( i < screenList.size() ) { + final Screen s = screenList.get(i).get(); + if( null == s ) { + screenList.remove(i); + } else { + list.add( screenList.get(i).get() ); + i++; + } + } } return list; } - + public static int getActiveScreenNumber() { synchronized(screenList) { return screensActive; diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 0d1dcf5ab..bb493cbbd 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -41,6 +41,7 @@ import com.jogamp.newt.event.NEWTEventConsumer; import jogamp.newt.event.NEWTEventTask; import com.jogamp.newt.util.EDTUtil; + import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -96,7 +97,7 @@ public abstract class DisplayImpl extends Display { display.id = serialno++; display.fqname = getFQName(display.type, display.name, display.id); display.hashCode = display.fqname.hashCode(); - displayList.add(display); + Display.addDisplay2List(display); } display.setEDTUtil(display.edtUtil); // device's default if EDT is used, or null @@ -155,11 +156,11 @@ public abstract class DisplayImpl extends Display { if(null==aDevice) { throw new NativeWindowException("Display.createNative() failed to instanciate an AbstractGraphicsDevice"); } - if(DEBUG) { - System.err.println("Display.createNative() END ("+getThreadName()+", "+this+")"); - } synchronized(displayList) { displaysActive++; + if(DEBUG) { + System.err.println("Display.createNative() END ("+getThreadName()+", "+this+", active "+displaysActive+")"); + } } } } @@ -238,13 +239,12 @@ public abstract class DisplayImpl extends Display { dumpDisplayList("Display.destroy("+getFQName()+") BEGIN"); } synchronized(displayList) { - displayList.remove(this); if(0 < displaysActive) { displaysActive--; } - } - if(DEBUG) { - System.err.println("Display.destroy(): "+this+" "+getThreadName()); + if(DEBUG) { + System.err.println("Display.destroy(): "+this+", active "+displaysActive+" "+getThreadName()); + } } final DisplayImpl f_dpy = this; removeEDT( new Runnable() { // blocks! @@ -268,32 +268,34 @@ public abstract class DisplayImpl extends Display { dumpDisplayList("Display.shutdownAll "+dCount+" instances, on thread "+getThreadName()); } for(int i=0; i0; i++) { // be safe .. - final DisplayImpl d = (DisplayImpl) displayList.remove(0); - if(0 < displaysActive) { - displaysActive--; - } + final DisplayImpl d = (DisplayImpl) displayList.remove(0).get(); if(DEBUG) { - System.err.println("Display.shutdownAll["+(i+1)+"/"+dCount+"]: "+d); + System.err.println("Display.shutdownAll["+(i+1)+"/"+dCount+"]: "+d+", GCed "+(null==d)); } - final Runnable closeNativeTask = new Runnable() { - public void run() { - if ( null != d.getGraphicsDevice() ) { - d.closeNativeImpl(); + if( null != d ) { // GC'ed ? + if(0 < displaysActive) { + displaysActive--; + } + final Runnable closeNativeTask = new Runnable() { + public void run() { + if ( null != d.getGraphicsDevice() ) { + d.closeNativeImpl(); + } } + }; + final EDTUtil edtUtil = d.getEDTUtil(); + if(null != edtUtil) { + final long coopSleep = edtUtil.getPollPeriod() * 2; + edtUtil.invokeStop(false, closeNativeTask); // don't block + try { + Thread.sleep( coopSleep < 50 ? coopSleep : 50 ); + } catch (InterruptedException e) { } + } else { + closeNativeTask.run(); } - }; - final EDTUtil edtUtil = d.getEDTUtil(); - if(null != edtUtil) { - final long coopSleep = edtUtil.getPollPeriod() * 2; - edtUtil.invokeStop(false, closeNativeTask); // don't block - try { - Thread.sleep( coopSleep < 50 ? coopSleep : 50 ); - } catch (InterruptedException e) { } - } else { - closeNativeTask.run(); + d.aDevice = null; + d.refCount=0; } - d.aDevice = null; - d.refCount=0; } } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index c02f4f288..fe9e91b57 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -125,7 +125,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { screen.screen_idx = idx; screen.fqname = display.getFQName()+"-s"+idx; screen.hashCode = screen.fqname.hashCode(); - screenList.add(screen); + Screen.addScreen2List(screen); if(DEBUG) { System.err.println("Screen.create() NEW: "+screen+" "+Display.getThreadName()); } @@ -169,8 +169,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("Screen.createNative() START ("+DisplayImpl.getThreadName()+", "+this+")"); } else { tCreated = 0; - } - + } display.addReference(); createNativeImpl(); @@ -179,11 +178,11 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { } initMonitorState(); - if(DEBUG) { - System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); - } synchronized(screenList) { screensActive++; + if(DEBUG) { + System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), active "+screensActive+", total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); + } } ScreenMonitorState.getScreenMonitorState(this.getFQName()).addListener(this); } @@ -192,10 +191,12 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { @Override public synchronized final void destroy() { synchronized(screenList) { - if( screenList.remove(this) ) { - if(0 < screensActive) { - screensActive--; - } + if(0 < screensActive) { + screensActive--; + } + if(DEBUG) { + System.err.println("Screen.destroy() ("+DisplayImpl.getThreadName()+"): active "+screensActive); + // Thread.dumpStack(); } } @@ -667,11 +668,13 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { System.err.println("Screen.shutdownAll "+sCount+" instances, on thread "+Display.getThreadName()); } for(int i=0; i0; i++) { // be safe .. - final ScreenImpl s = (ScreenImpl) screenList.remove(0); + final ScreenImpl s = (ScreenImpl) screenList.remove(0).get(); if(DEBUG) { - System.err.println("Screen.shutdownAll["+(i+1)+"/"+sCount+"]: "+s); + System.err.println("Screen.shutdownAll["+(i+1)+"/"+sCount+"]: "+s+", GCed "+(null==s)); + } + if( null != s ) { + s.shutdown(); } - s.shutdown(); } } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 7c4011f34..460763f47 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -36,6 +36,7 @@ package jogamp.newt; import java.util.ArrayList; import java.util.List; +import java.lang.ref.WeakReference; import java.lang.reflect.Method; import com.jogamp.common.util.IntBitfield; @@ -82,7 +83,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer { public static final boolean DEBUG_TEST_REPARENT_INCOMPATIBLE = Debug.isPropertyDefined("newt.test.Window.reparent.incompatible", true); - protected static final ArrayList windowList = new ArrayList(); + protected static final ArrayList> windowList = new ArrayList>(); static { ScreenImpl.initSingleton(); @@ -95,13 +96,28 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("Window.shutdownAll "+wCount+" instances, on thread "+getThreadName()); } for(int i=0; i0; i++) { // be safe .. - final WindowImpl w = windowList.remove(0); + final WindowImpl w = windowList.remove(0).get(); if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(w.getWindowHandle())); + final long wh = null != w ? w.getWindowHandle() : 0; + System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(wh)+", GCed "+(null==w)); } w.shutdown(); } } + private static void addWindow2List(WindowImpl window) { + synchronized(windowList) { + // GC before add + int i=0; + while( i < windowList.size() ) { + if( null == windowList.get(i).get() ) { + windowList.remove(i); + } else { + i++; + } + } + windowList.add(new WeakReference(window)); + } + } /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms @@ -208,9 +224,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); window.instantiationFinished(); - synchronized( windowList ) { - windowList.add(window); - } + addWindow2List(window); return window; } catch (Throwable t) { t.printStackTrace(); @@ -233,9 +247,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer window.screen = (ScreenImpl) screen; window.capsRequested = (CapabilitiesImmutable) caps.cloneMutable(); window.instantiationFinished(); - synchronized( windowList ) { - windowList.add(window); - } + addWindow2List(window); return window; } catch (Throwable t) { throw new NativeWindowException(t); @@ -1062,9 +1074,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public void destroy() { - synchronized( windowList ) { - windowList.remove(this); - } visible = false; // Immediately mark synchronized visibility flag, avoiding possible recreation runOnEDTIfAvail(true, destroyAction); } -- cgit v1.2.3 From b9a24308f3ebc6fae9ca79f6020970945936feab Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Jul 2013 06:25:52 +0200 Subject: Fix Bug 765: Add glMultiDrawElementsBaseVertex ; Restrict PointerBuffer usage to NIO only. Code snippet for PointerBuffer usage: Code snippet .. how to use PointerBuffer in this case: IntBuffer indices = Buffers.newDirectIntBuffer(count); indices.put(...); ... indices.rewind(); final PointerBuffer indicesP = PointerBuffer.allocateDirect(1); indicesP.referenceBuffer(indices); -> glMultiDrawElementsBaseVertex(int mode, IntBuffer count, int type, PointerBuffer indices, int primcount, IntBuffer basevertex) --- make/config/jogl/gl-common.cfg | 8 ++- make/scripts/gluegen-gl.sh | 109 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 115 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index 3eea23645..ad0b7d1d0 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -37,7 +37,6 @@ Ignore glGetVertexAttribPointerv Ignore glGetVertexAttribPointervARB Ignore glGetVertexAttribPointervNV Ignore glTracePointerRangeMESA -Ignore glMultiDrawElementsBaseVertex Ignore glDebugMessageCallbackARB Ignore glDebugMessageCallbackAMD @@ -400,6 +399,13 @@ NIODirectOnly glWeightPointerARB NIODirectOnly wglFreeMemoryNV NIODirectOnly glXFreeMemoryNV +# Native PointerBuffer usage: +NIODirectOnly glMultiDrawElements +NIODirectOnly glMultiDrawElementsBaseVertex +NIODirectOnly glVDPAUMapSurfacesNV +NIODirectOnly glVDPAUUnmapSurfacesNV +NIODirectOnly glExtGetBufferPointervQCOM + #NIO Review: No technical reason to constrain array access for these: #Return values #NIODirectOnly glGenBuffers diff --git a/make/scripts/gluegen-gl.sh b/make/scripts/gluegen-gl.sh index 111b70710..d44c7987a 100644 --- a/make/scripts/gluegen-gl.sh +++ b/make/scripts/gluegen-gl.sh @@ -84,9 +84,116 @@ copy_temp } +function gluegen_gl2() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-if-gl2.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gl2.c \ + +copy_temp + +} + +function gluegen_gl2gl3() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-if-gl3-subset.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gl3.c \ + +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-if-gl2_gl3.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gl2.c \ + +copy_temp + +} function gluegen_all() { - gluegen_if_gl +# gluegen_if_gl # gluegen_es2 +# gluegen_gl2 + gluegen_gl2gl3 } gluegen_all 2>&1 | tee $(basename $0 .sh).log -- cgit v1.2.3 From dec4b02fe4b93028c85de6a56b6af79601042d6e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 5 Jul 2013 11:32:12 +0200 Subject: NEWT Display.create: If reusing an existing instance, ensure EDT is running! --- make/scripts/tests.sh | 7 ++++--- src/newt/classes/jogamp/newt/DisplayImpl.java | 9 +++++---- .../test/junit/newt/parenting/TestParenting01NEWT.java | 18 ++++++++++++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 1ba0a36c6..c4520c8e7 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -150,8 +150,9 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" - #D_ARGS="-Dnativewindow.debug.NativeWindow" + #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" + #D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -401,7 +402,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT -testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT +#testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* @@ -514,7 +515,7 @@ testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT # # NEWT Parenting (w/ NEWT, AWT or SWT) # -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index bb493cbbd..09ea05e88 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -77,13 +77,14 @@ public abstract class DisplayImpl extends Display { /** Make sure to reuse a Display with the same name */ public static Display create(String type, String name, final long handle, boolean reuse) { try { - Class displayClass = getDisplayClass(type); - DisplayImpl display = (DisplayImpl) displayClass.newInstance(); + final Class displayClass = getDisplayClass(type); + final DisplayImpl display = (DisplayImpl) displayClass.newInstance(); name = display.validateDisplayName(name, handle); synchronized(displayList) { if(reuse) { - Display display0 = Display.getLastDisplayOf(type, name, -1, true /* shared only */); + final Display display0 = Display.getLastDisplayOf(type, name, -1, true /* shared only */); if(null != display0) { + display0.setEDTUtil(display0.getEDTUtil()); // ensures EDT is running if(DEBUG) { System.err.println("Display.create() REUSE: "+display0+" "+getThreadName()); } @@ -99,7 +100,7 @@ public abstract class DisplayImpl extends Display { display.hashCode = display.fqname.hashCode(); Display.addDisplay2List(display); } - display.setEDTUtil(display.edtUtil); // device's default if EDT is used, or null + display.setEDTUtil(display.edtUtil); // device's default if EDT is used, or null - ensures EDT is running if(DEBUG) { System.err.println("Display.create() NEW: "+display+" "+getThreadName()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java index 15c324e3e..e7fced5d9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java @@ -673,14 +673,28 @@ public class TestParenting01NEWT extends UITestCase { } public static void main(String args[]) throws IOException { + boolean asMain = false; for(int i=0; i Date: Fri, 5 Jul 2013 22:48:12 +0200 Subject: Fix SWTEDTUtil regression caused by dec4b02fe4b93028c85de6a56b6af79601042d6e, ensuring EDT is running for reused Display instances. Refine EDTUtil semantics of: - reset() - waitUntilStopped() AWTEDTUtil/SWTEDTUtil: Properly signal !running when shutdown SWTEDTUtil: Take SWT isDisposed() into account. --- make/scripts/tests.sh | 6 +-- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 15 ++++-- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 11 +++-- src/newt/classes/jogamp/newt/DisplayImpl.java | 2 +- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 25 ++++++---- src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 53 +++++++++++++--------- 6 files changed, 70 insertions(+), 42 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c4520c8e7..dbc795992 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -152,7 +152,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" - #D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT" + D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -461,7 +461,7 @@ function testawtswt() { # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # awtswt (testawtswt) @@ -515,7 +515,7 @@ function testawtswt() { # # NEWT Parenting (w/ NEWT, AWT or SWT) # -testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 0df815609..75848785c 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -65,14 +65,18 @@ public interface EDTUtil { public void setPollPeriod(long ms); /** - * Create a new EDT. One should invoke reset()
    - * after invokeStop(..) in case another start via invoke(..) - * is expected. + * Resets the stopped EDT, i.e. prepares it for a restart via + * the next invoke(..) call. + *

    + * One must stop the EDT first via {@link #invokeStop(boolean, Runnable)} + * and wait until it's stopped via {@link #waitUntilStopped()}. + *

    * * @see #invoke(boolean, java.lang.Runnable) * @see #invokeStop(boolean, java.lang.Runnable) + * @throws IllegalStateException if stop has not been issued, or EDT is still running (caller thread not being EDT or NEDT). */ - public void reset(); + public void reset() throws IllegalStateException; /** * Returns true if the current thread is the event dispatch thread (EDT). @@ -150,6 +154,9 @@ public interface EDTUtil { /** * Wait until EDT task is stopped.
    * No stop action is performed, {@link #invokeStop(boolean, java.lang.Runnable)} should be used before. + *

    + * If caller thread is EDT or NEDT, this call will not block. + *

    */ public void waitUntilStopped(); } diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index f8ee31a06..ecd94c278 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -76,9 +76,14 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final void reset() { - synchronized(edtLock) { - waitUntilStopped(); + public final void reset() throws IllegalStateException { + synchronized(edtLock) { + if( isRunning() ) { + if( !edt.shouldStop ) { + throw new IllegalStateException("EDT stop not issued."); + } + throw new IllegalStateException("EDT still running"); + } if(DEBUG) { if(edt.tasks.size()>0) { System.err.println(Thread.currentThread()+": Default-EDT reset, remaining tasks: "+edt.tasks.size()+" - "+edt); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 09ea05e88..884ddac57 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -208,7 +208,7 @@ public abstract class DisplayImpl extends Display { } private void removeEDT(final Runnable task) { - if(null!=edtUtil) { + if(null!=edtUtil) { edtUtil.invokeStop(true, task); // ready for restart .. edtUtil.waitUntilStopped(); diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index 0cc5ddb3e..abd47d17e 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -68,9 +68,18 @@ public class AWTEDTUtil implements EDTUtil { } @Override - final public void reset() { - synchronized(edtLock) { - waitUntilStopped(); + public final void reset() throws IllegalStateException { + synchronized(edtLock) { + final Thread curT = Thread.currentThread(); + final boolean onAWTEDT = EventQueue.isDispatchThread(); + if( nedt.isRunning() ) { + if( !nedt.shouldStop ) { + throw new IllegalStateException("EDT stop not issued."); + } + if( nedt != curT && !onAWTEDT ) { + throw new IllegalStateException("EDT still running: Curr "+curT.getName()+", NEDT "+nedt.getName()+", on AWT-EDT "+onAWTEDT); + } + } if(DEBUG) { System.err.println(Thread.currentThread()+": AWT-EDT reset - edt: "+nedt); } @@ -110,7 +119,7 @@ public class AWTEDTUtil implements EDTUtil { @Override final public boolean isRunning() { - return nedt.isRunning() ; // AWT is always running + return nedt.isRunning() ; } @Override @@ -203,7 +212,7 @@ public class AWTEDTUtil implements EDTUtil { @Override final public void waitUntilStopped() { synchronized(edtLock) { - if(nedt.isRunning() && nedt != Thread.currentThread() && !EventQueue.isDispatchThread()) { + if( nedt.isRunning() && nedt != Thread.currentThread() && !EventQueue.isDispatchThread() ) { while(nedt.isRunning()) { try { edtLock.wait(); @@ -278,10 +287,8 @@ public class AWTEDTUtil implements EDTUtil { System.err.println(getName()+": AWT-EDT run() END "+ getName()+", "+error); } synchronized(edtLock) { - isRunning = !shouldStop; - if(!isRunning) { - edtLock.notifyAll(); - } + isRunning = false; + edtLock.notifyAll(); } if(DEBUG) { System.err.println(getName()+": AWT-EDT run() EXIT "+ getName()+", exception: "+error); diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index 77049a010..a8e03c510 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -77,9 +77,19 @@ public class SWTEDTUtil implements EDTUtil { } @Override - public void reset() { - synchronized(edtLock) { - waitUntilStopped(); + public final void reset() throws IllegalStateException { + synchronized(edtLock) { + final Thread curT = Thread.currentThread(); + final Thread swtT = !swtDisplay.isDisposed() ? swtDisplay.getThread() : null; + final boolean onSWTEDT = swtT == curT; + if( nedt.isRunning() ) { + if( !nedt.shouldStop ) { + throw new IllegalStateException("EDT stop not issued."); + } + if( nedt != curT && !onSWTEDT ) { + throw new IllegalStateException("EDT still running: Curr "+curT.getName()+", NEDT "+nedt.getName()+", SWT-EDT "+swtT.getName()); + } + } if(DEBUG) { System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt); } @@ -104,7 +114,7 @@ public class SWTEDTUtil implements EDTUtil { @Override public boolean isCurrentThreadEDT() { - return swtDisplay.getThread() == Thread.currentThread(); + return !swtDisplay.isDisposed() && swtDisplay.getThread() == Thread.currentThread(); } @Override @@ -115,12 +125,12 @@ public class SWTEDTUtil implements EDTUtil { @Override public final boolean isCurrentThreadEDTorNEDT() { final Thread ct = Thread.currentThread(); - return ct == swtDisplay.getThread() || ct == nedt ; + return ( !swtDisplay.isDisposed() && ct == swtDisplay.getThread() ) || ct == nedt ; } @Override public boolean isRunning() { - return nedt.isRunning() ; // SWT is always running + return nedt.isRunning() ; } @Override @@ -142,33 +152,32 @@ public class SWTEDTUtil implements EDTUtil { if( nedt.shouldStop ) { // drop task .. if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt); - Thread.dumpStack(); + System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt+", isRunning "+nedt.isRunning()); + // Thread.dumpStack(); } return; } // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); // Thread.dumpStack(); if(stop) { + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt+", isRunning "+nedt.isRunning()); + } synchronized(nedt.sync) { nedt.shouldStop = true; nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) } - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); - } - } else if( !nedt.isRunning() ) { + } else if( !nedt.isRunning() && !swtDisplay.isDisposed() ) { // start if should not stop && not started yet startImpl(); } if( null == task ) { wait = false; + } else if( swtDisplay.isDisposed() ) { + wait = false; // drop task, SWT disposed } else if( isCurrentThreadEDT() ) { task.run(); wait = false; // running in same thread (EDT) -> no wait - } else if( swtDisplay.isDisposed() ) { - wait = false; // drop task, SWT disposed } else { rTask = new RunnableTask(task, wait ? rTaskLock : null, @@ -203,7 +212,7 @@ public class SWTEDTUtil implements EDTUtil { _nedt = nedt; } final Thread ct = Thread.currentThread(); - if(!_nedt.isRunning() || _nedt == ct || swtDisplay.getThread() == ct) { + if( !_nedt.isRunning() || _nedt == ct || swtDisplay.isDisposed() || swtDisplay.getThread() == ct ) { return; } try { @@ -216,8 +225,10 @@ public class SWTEDTUtil implements EDTUtil { @Override final public void waitUntilStopped() { synchronized(edtLock) { - final Thread ct = Thread.currentThread(); - if(nedt.isRunning() && nedt != ct && swtDisplay.getThread() != ct) { + final Thread curT = Thread.currentThread(); + final Thread swtT = !swtDisplay.isDisposed() ? swtDisplay.getThread() : null; + final boolean onSWTEDT = swtT == curT; + if( nedt.isRunning() && nedt != curT && !onSWTEDT ) { while(nedt.isRunning()) { try { edtLock.wait(); @@ -296,10 +307,8 @@ public class SWTEDTUtil implements EDTUtil { System.err.println(getName()+": SWT-EDT run() END "+ getName()+", "+error); } synchronized(edtLock) { - isRunning = !shouldStop; - if(!isRunning) { - edtLock.notifyAll(); - } + isRunning = false; + edtLock.notifyAll(); } if(DEBUG) { System.err.println(getName()+": SWT-EDT run() EXIT "+ getName()+", exception: "+error); -- cgit v1.2.3 From 453ccee8e3ce90956756d1582852b13f45cd2f38 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 9 Jul 2013 15:04:50 +0200 Subject: NEWT EDTUtil: Exposed weakness of EDTUtil usage due to usage of WeakReference, i.e. higher retention of Display instances. - WeakReference Change 99479bf3197cde8e89c5b499d135417863d521c7 - Refines commits: feb352145af1643a57eaae99c0342e6f5e0f2a2e dec4b02fe4b93028c85de6a56b6af79601042d6e 433e3914324b90c910b018bb7d9d80e814c67123 Reviews EDTUtil API and usage: - less confusing / more determined EDTUtil API - EDTUtil's thread shall only be reset and started when required (-> lazy) - EDTUtil's instance in Display shall be handled thread safe w/o extra blocking - EDTUtil's implementations (Default, SWT and AWT) shall be aligned / similar as much as possible Further note: SWT's EDTUtil (NewtCanvasSWT) shall not use a reused Display instance due to it's custom SWTEDTUtil. We may need to disable the ref. cache if custom EDTUtil (setEDTUtil) is intended (used). --- make/scripts/tests.sh | 6 +- src/newt/classes/com/jogamp/newt/Display.java | 17 +-- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 4 +- src/newt/classes/com/jogamp/newt/util/EDTUtil.java | 43 +++--- src/newt/classes/jogamp/newt/DefaultEDTUtil.java | 115 ++++++++------- src/newt/classes/jogamp/newt/DisplayImpl.java | 137 +++++++++++------- .../jogamp/newt/driver/android/DisplayDriver.java | 2 +- .../classes/jogamp/newt/driver/awt/AWTEDTUtil.java | 130 ++++++++++------- .../jogamp/newt/driver/awt/DisplayDriver.java | 4 +- .../jogamp/newt/driver/bcm/egl/DisplayDriver.java | 2 +- .../newt/driver/bcm/vc/iv/DisplayDriver.java | 2 +- .../newt/driver/intel/gdl/DisplayDriver.java | 2 +- .../jogamp/newt/driver/kd/DisplayDriver.java | 2 +- .../jogamp/newt/driver/macosx/DisplayDriver.java | 2 +- .../jogamp/newt/driver/windows/DisplayDriver.java | 2 +- .../jogamp/newt/driver/x11/DisplayDriver.java | 4 +- src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java | 161 +++++++++++++-------- .../junit/jogl/acore/InitConcurrentBaseNEWT.java | 6 +- .../junit/jogl/acore/TestInitConcurrent01NEWT.java | 11 +- .../junit/jogl/acore/TestInitConcurrent02NEWT.java | 3 +- .../demos/es2/newt/TestGearsES2NewtCanvasSWT.java | 6 +- .../TestNewtCanvasSWTBug628ResizeDeadlockAWT.java | 9 +- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 10 +- .../junit/jogl/swt/TestSWTBug643AsyncExec.java | 10 +- .../junit/newt/TestDisplayLifecycle01NEWT.java | 19 ++- .../junit/newt/parenting/TestParenting01NEWT.java | 2 +- .../junit/newt/parenting/TestParenting01aSWT.java | 7 +- .../junit/newt/parenting/TestParenting04SWT.java | 10 +- 28 files changed, 434 insertions(+), 294 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index dbc795992..a5ce8d2e9 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -152,7 +152,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" - D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT" + D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -461,7 +461,7 @@ function testawtswt() { # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # awtswt (testawtswt) @@ -515,7 +515,7 @@ testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* # # NEWT Parenting (w/ NEWT, AWT or SWT) # -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 4f5df6c70..c618405c2 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -154,26 +154,25 @@ public abstract class Display { /** * Sets a new {@link EDTUtil} and returns the previous one. *

    - * If newEDTUtil is null, + * If usrEDTUtil is null, * the device's default EDTUtil is created and used. *

    *

    - * If a previous one exists and it differs from the new one, - * it's being stopped, wait-until-idle and reset to allow a restart at a later time. + * If a previous one exists and it differs from usrEDTUtil, + * it's being stopped, wait-until-idle. *

    *

    - * If newEDTUtil is not null and equals the previous one, + * If usrEDTUtil is not null and equals the previous one, * no change is being made. *

    - *

    - * Note that newEDTUtil will be started by this method, - * if it is not running yet. - *

    */ - public abstract EDTUtil setEDTUtil(EDTUtil newEDTUtil); + public abstract EDTUtil setEDTUtil(EDTUtil usrEDTUtil); public abstract EDTUtil getEDTUtil(); + /** + * @return true if EDT is running and not subject to be stopped, otherwise false. + */ public abstract boolean isEDTRunning(); public abstract void dispatchMessages(); diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index dbe7c0d98..47dfca0f3 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -345,7 +345,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { // set SWT EDT and start it { final Display newtDisplay = newtChild.getScreen().getDisplay(); - newtDisplay.setEDTUtil( new SWTEDTUtil(newtDisplay, getDisplay()) ); + final EDTUtil edtUtil = new SWTEDTUtil(newtDisplay, getDisplay()); + edtUtil.restart(); + newtDisplay.setEDTUtil( edtUtil ); } newtChild.setSize(w, h); diff --git a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java index 75848785c..e86df2084 100644 --- a/src/newt/classes/com/jogamp/newt/util/EDTUtil.java +++ b/src/newt/classes/com/jogamp/newt/util/EDTUtil.java @@ -65,18 +65,19 @@ public interface EDTUtil { public void setPollPeriod(long ms); /** - * Resets the stopped EDT, i.e. prepares it for a restart via - * the next invoke(..) call. + * Starts or restarts the EDT. *

    - * One must stop the EDT first via {@link #invokeStop(boolean, Runnable)} - * and wait until it's stopped via {@link #waitUntilStopped()}. + * If the EDT is running, it must be stopped first via {@link #invokeStop(boolean, Runnable)} + * and the caller should wait until it's stopped via {@link #waitUntilStopped()}. *

    - * - * @see #invoke(boolean, java.lang.Runnable) + * + * @return true if EDT has been successfully restarted, otherwise false + * @throws IllegalStateException if EDT is running and not subject to be stopped, i.e. {@link #isRunning()} returns true + * * @see #invokeStop(boolean, java.lang.Runnable) - * @throws IllegalStateException if stop has not been issued, or EDT is still running (caller thread not being EDT or NEDT). + * @see #waitUntilStopped() */ - public void reset() throws IllegalStateException; + public boolean restart() throws IllegalStateException; /** * Returns true if the current thread is the event dispatch thread (EDT). @@ -111,7 +112,7 @@ public interface EDTUtil { public boolean isCurrentThreadEDTorNEDT(); /** - * @return True if EDT is running + * @return True if EDT is running and not subject to be stopped. */ public boolean isRunning(); @@ -129,27 +130,30 @@ public interface EDTUtil { *
  • All previous queued tasks will be finished.
  • *
  • No new tasks are allowed, an Exception is thrown.
  • *
  • Can be issued from within EDT, ie from within an enqueued task.
  • - *
  • {@link #reset()} may follow immediately, ie creating a new EDT
  • + *
  • {@link #restart()} may follow immediately, ie creating a new EDT
  • * *

    + * @return true if task has been executed or queued for later execution, otherwise false */ - public void invokeStop(boolean wait, Runnable finalTask); + public boolean invokeStop(boolean wait, Runnable finalTask); /** - * Shall start the thread if not running, task maybe null for this purpose.
    - * Append task to the EDT task queue.
    - * Wait until execution is finished if wait == true.
    + * Appends task to the EDT task queue if current thread is not EDT, + * otherwise execute task immediately. + *

    + * Wait until execution is finished if wait == true. + *

    * Can be issued from within EDT, ie from within an enqueued task.
    - * - * @throws RuntimeException in case EDT is stopped and not {@link #reset()} + * @return true if task has been executed or queued for later execution, otherwise false */ - public void invoke(boolean wait, Runnable task); + public boolean invoke(boolean wait, Runnable task); /** * Wait until the EDT task queue is empty.
    * The last task may still be in execution when this method returns. + * @return true if waited for idle, otherwise false, i.e. in case of current thread is EDT or NEDT */ - public void waitUntilIdle(); + public boolean waitUntilIdle(); /** * Wait until EDT task is stopped.
    @@ -157,7 +161,8 @@ public interface EDTUtil { *

    * If caller thread is EDT or NEDT, this call will not block. *

    + * @return true if stopped, otherwise false, i.e. in case of current thread is EDT or NEDT */ - public void waitUntilStopped(); + public boolean waitUntilStopped(); } diff --git a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java index ecd94c278..a229a0512 100644 --- a/src/newt/classes/jogamp/newt/DefaultEDTUtil.java +++ b/src/newt/classes/jogamp/newt/DefaultEDTUtil.java @@ -53,7 +53,7 @@ public class DefaultEDTUtil implements EDTUtil { private final ThreadGroup threadGroup; private final String name; private final Runnable dispatchMessages; - private EventDispatchThread edt = null; + private NEDT edt = null; private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; @@ -61,7 +61,7 @@ public class DefaultEDTUtil implements EDTUtil { this.threadGroup = tg; this.name=Thread.currentThread().getName()+"-"+name+"-EDT-"; this.dispatchMessages=dispatchMessages; - this.edt = new EventDispatchThread(threadGroup, name); + this.edt = new NEDT(threadGroup, name); this.edt.setDaemon(true); // don't stop JVM from shutdown .. } @@ -76,36 +76,34 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final void reset() throws IllegalStateException { + public final boolean restart() throws IllegalStateException { synchronized(edtLock) { - if( isRunning() ) { - if( !edt.shouldStop ) { - throw new IllegalStateException("EDT stop not issued."); - } - throw new IllegalStateException("EDT still running"); + if( edt.isRunning() ) { + throw new IllegalStateException("EDT still running and not subject to stop. Curr "+Thread.currentThread().getName()+", EDT "+edt.getName()+", isRunning "+edt.isRunning+", shouldStop "+edt.shouldStop); } if(DEBUG) { if(edt.tasks.size()>0) { System.err.println(Thread.currentThread()+": Default-EDT reset, remaining tasks: "+edt.tasks.size()+" - "+edt); - // Thread.dumpStack(); } System.err.println(Thread.currentThread()+": Default-EDT reset - edt: "+edt); } - this.edt = new EventDispatchThread(threadGroup, name); - this.edt.setDaemon(true); // don't stop JVM from shutdown .. + if( edt.getState() != Thread.State.NEW ) { + edt = new NEDT(threadGroup, name); + edt.setDaemon(true); // don't stop JVM from shutdown .. + } + startImpl(); } + return invoke(true, nullTask); } private final void startImpl() { if(edt.isAlive()) { - throw new RuntimeException("Default-EDT Thread.isAlive(): true, isRunning: "+edt.isRunning()+", edt: "+edt+", tasks: "+edt.tasks.size()); + throw new RuntimeException("Default-EDT Thread.isAlive(): true, isRunning: "+edt.isRunning+", shouldStop "+edt.shouldStop+", edt: "+edt+", tasks: "+edt.tasks.size()); } start_iter++; edt.setName(name+start_iter); - edt.shouldStop = false; if(DEBUG) { System.err.println(Thread.currentThread()+": Default-EDT START - edt: "+edt); - // Thread.dumpStack(); } edt.start(); } @@ -131,13 +129,13 @@ public class DefaultEDTUtil implements EDTUtil { } @Override - public final void invokeStop(boolean wait, Runnable task) { - invokeImpl(wait, task, true); + public final boolean invokeStop(boolean wait, Runnable task) { + return invokeImpl(wait, task, true); } @Override - public final void invoke(boolean wait, Runnable task) { - invokeImpl(wait, task, false); + public final boolean invoke(boolean wait, Runnable task) { + return invokeImpl(wait, task, false); } private static Runnable nullTask = new Runnable() { @@ -145,28 +143,26 @@ public class DefaultEDTUtil implements EDTUtil { public void run() { } }; - private void invokeImpl(boolean wait, Runnable task, boolean stop) { + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; - Object rTaskLock = new Object(); + final Object rTaskLock = new Object(); synchronized(rTaskLock) { // lock the optional task execution synchronized(edtLock) { // lock the EDT status if( edt.shouldStop ) { // drop task .. + System.err.println(Thread.currentThread()+": Warning: Default-EDT about (1) to stop, won't enqueue new task: "+edt); if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: Default-EDT about (1) to stop, won't enqueue new task: "+edt); Thread.dumpStack(); } - return; + return false; } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); if( isCurrentThreadEDT() ) { if(null != task) { task.run(); } wait = false; // running in same thread (EDT) -> no wait - if(stop) { + if( stop ) { edt.shouldStop = true; if( edt.tasks.size()>0 ) { System.err.println(Thread.currentThread()+": Warning: Default-EDT about (2) to stop, task executed. Remaining tasks: "+edt.tasks.size()+" - "+edt); @@ -176,21 +172,19 @@ public class DefaultEDTUtil implements EDTUtil { } } } else { - if( !edt.isRunning() ) { - if( !stop ) { - startImpl(); - if( wait && null == task ) { - task = nullTask; // ensures wait until started + if( !edt.isRunning ) { + if( null != task ) { + if( stop ) { + System.err.println(Thread.currentThread()+": Warning: Default-EDT is about (3) to stop and stopped already, dropping task. Remaining tasks: "+edt.tasks.size()+" - "+edt); + } else { + System.err.println(Thread.currentThread()+": Warning: Default-EDT is not running, dropping task. NEDT "+edt); } - } else { - // drop task and don't wait - task = null; - System.err.println(Thread.currentThread()+": Warning: Default-EDT is about (3) to stop and stopped already, dropping task. Remaining tasks: "+edt.tasks.size()+" - "+edt); if(DEBUG) { Thread.dumpStack(); } } - } else if(stop && null == task) { + return false; + } else if( stop && null == task ) { task = nullTask; // ensures execution triggering stop } @@ -228,23 +222,26 @@ public class DefaultEDTUtil implements EDTUtil { throw new RuntimeException(throwable); } } - } - if(DEBUG && stop) { - System.err.println(Thread.currentThread()+": Default-EDT signal STOP X edt: "+edt); + if(DEBUG) { + if( stop) { + System.err.println(Thread.currentThread()+": Default-EDT signal STOP X edt: "+edt); + } + } + return true; } } @Override - final public void waitUntilIdle() { - final EventDispatchThread _edt; + final public boolean waitUntilIdle() { + final NEDT _edt; synchronized(edtLock) { _edt = edt; } - if(!_edt.isRunning() || _edt == Thread.currentThread()) { - return; + if(!_edt.isRunning || _edt == Thread.currentThread()) { + return false; } synchronized(_edt.tasks) { - while(_edt.isRunning() && _edt.tasks.size()>0) { + while(_edt.isRunning && _edt.tasks.size()>0) { try { _edt.tasks.notifyAll(); _edt.tasks.wait(); @@ -252,35 +249,39 @@ public class DefaultEDTUtil implements EDTUtil { e.printStackTrace(); } } + return true; } } @Override - final public void waitUntilStopped() { + final public boolean waitUntilStopped() { synchronized(edtLock) { - if(edt.isRunning() && edt != Thread.currentThread() ) { - while(edt.isRunning()) { + if(edt.isRunning && edt != Thread.currentThread() ) { + while( edt.isRunning ) { try { edtLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } + return true; + } else { + return false; } } } - class EventDispatchThread extends Thread { + class NEDT extends Thread { volatile boolean shouldStop = false; volatile boolean isRunning = false; ArrayList tasks = new ArrayList(); // one shot tasks - public EventDispatchThread(ThreadGroup tg, String name) { + public NEDT(ThreadGroup tg, String name) { super(tg, name); } final public boolean isRunning() { - return isRunning; + return isRunning && !shouldStop; } @Override @@ -290,11 +291,9 @@ public class DefaultEDTUtil implements EDTUtil { } private final void validateNoRecursiveLocksHold() { - if(Lock.DEBUG) { - if(LockDebugUtil.getRecursiveLockTrace().size()>0) { - LockDebugUtil.dumpRecursiveLockTrace(System.err); - throw new InternalError("XXX"); - } + if(LockDebugUtil.getRecursiveLockTrace().size()>0) { + LockDebugUtil.dumpRecursiveLockTrace(System.err); + throw new InternalError("XXX"); } } @@ -307,7 +306,9 @@ public class DefaultEDTUtil implements EDTUtil { if(DEBUG) { System.err.println(getName()+": Default-EDT run() START "+ getName()); } - validateNoRecursiveLocksHold(); + if(Lock.DEBUG) { + validateNoRecursiveLocksHold(); + } RuntimeException error = null; try { do { @@ -337,7 +338,9 @@ public class DefaultEDTUtil implements EDTUtil { } if(null!=task) { task.run(); - validateNoRecursiveLocksHold(); + if(Lock.DEBUG) { + validateNoRecursiveLocksHold(); + } if(!task.hasWaiter() && null != task.getThrowable()) { // at least dump stack-trace in case nobody waits for result System.err.println("DefaultEDT.run(): Catched exception occured on thread "+Thread.currentThread().getName()+": "+task.toString()); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 884ddac57..8f792b23c 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -84,7 +84,6 @@ public abstract class DisplayImpl extends Display { if(reuse) { final Display display0 = Display.getLastDisplayOf(type, name, -1, true /* shared only */); if(null != display0) { - display0.setEDTUtil(display0.getEDTUtil()); // ensures EDT is running if(DEBUG) { System.err.println("Display.create() REUSE: "+display0+" "+getThreadName()); } @@ -98,9 +97,9 @@ public abstract class DisplayImpl extends Display { display.id = serialno++; display.fqname = getFQName(display.type, display.name, display.id); display.hashCode = display.fqname.hashCode(); + display.setEDTUtil( display.edtUtil ); // device's default if EDT is used, or null Display.addDisplay2List(display); } - display.setEDTUtil(display.edtUtil); // device's default if EDT is used, or null - ensures EDT is running if(DEBUG) { System.err.println("Display.create() NEW: "+display+" "+getThreadName()); @@ -138,10 +137,10 @@ public abstract class DisplayImpl extends Display { } @Override - public synchronized final void createNative() + public synchronized final void createNative() throws NativeWindowException { - if(null==aDevice) { + if( null == aDevice ) { if(DEBUG) { System.err.println("Display.createNative() START ("+getThreadName()+", "+this+")"); } @@ -154,7 +153,7 @@ public abstract class DisplayImpl extends Display { } catch (Throwable t) { throw new NativeWindowException(t); } - if(null==aDevice) { + if( null == aDevice ) { throw new NativeWindowException("Display.createNative() failed to instanciate an AbstractGraphicsDevice"); } synchronized(displayList) { @@ -180,25 +179,23 @@ public abstract class DisplayImpl extends Display { } @Override - public EDTUtil setEDTUtil(EDTUtil newEDTUtil) { + public synchronized EDTUtil setEDTUtil(final EDTUtil usrEDTUtil) { final EDTUtil oldEDTUtil = edtUtil; - if(null == newEDTUtil) { - if(DEBUG) { - System.err.println("Display.setEDTUtil(default): "+oldEDTUtil+" -> "+newEDTUtil); + final EDTUtil newEDTUtil; + if( null != usrEDTUtil && usrEDTUtil == oldEDTUtil ) { + if( DEBUG ) { + System.err.println("Display.setEDTUtil: "+usrEDTUtil+" - keep!"); } - edtUtil = createEDTUtil(); - } else if( newEDTUtil != edtUtil ) { + newEDTUtil = oldEDTUtil; + } else { if(DEBUG) { - System.err.println("Display.setEDTUtil(custom): "+oldEDTUtil+" -> "+newEDTUtil); + final String msg = ( null == usrEDTUtil ) ? "default" : "custom"; + System.err.println("Display.setEDTUtil("+msg+"): "+oldEDTUtil+" -> "+usrEDTUtil); } - removeEDT( null ); - edtUtil = newEDTUtil; - } else if( DEBUG ) { - System.err.println("Display.setEDTUtil: "+newEDTUtil+" - keep!"); - } - if( !edtUtil.isRunning() ) { // start EDT if not running yet - edtUtil.invoke(true, null); + stopEDT( oldEDTUtil, null ); + newEDTUtil = ( null == usrEDTUtil ) ? createEDTUtil() : usrEDTUtil; } + edtUtil = newEDTUtil; return oldEDTUtil; } @@ -207,29 +204,61 @@ public abstract class DisplayImpl extends Display { return edtUtil; } - private void removeEDT(final Runnable task) { - if(null!=edtUtil) { - edtUtil.invokeStop(true, task); - // ready for restart .. + private static void stopEDT(final EDTUtil edtUtil, final Runnable task) { + if( null != edtUtil ) { + if( edtUtil.isRunning() ) { + final boolean res = edtUtil.invokeStop(true, task); + if( DEBUG ) { + if ( !res ) { + System.err.println("Warning: invokeStop() failed"); + Thread.dumpStack(); + } + } + } edtUtil.waitUntilStopped(); - edtUtil.reset(); - } else { + // ready for restart .. + } else if( null != task ) { task.run(); } } public void runOnEDTIfAvail(boolean wait, final Runnable task) { - if( null!=edtUtil && !edtUtil.isCurrentThreadEDT()) { - edtUtil.invoke(wait, task); + final EDTUtil _edtUtil = edtUtil; + if( null != _edtUtil && !_edtUtil.isCurrentThreadEDT() ) { + if( !_edtUtil.isRunning() ) { // start EDT if not running yet + synchronized( this ) { + if( !_edtUtil.isRunning() ) { // // volatile dbl-checked-locking OK + _edtUtil.restart(); + if( DEBUG ) { + System.err.println("Info: EDT started "+Thread.currentThread().getName()+", "+this); + Thread.dumpStack(); + } + } + } + } + if( !_edtUtil.invoke(wait, task) ) { + if( DEBUG ) { + System.err.println("Warning: invoke(wait "+wait+", ..) on EDT failed .. invoke on current thread "+Thread.currentThread().getName()); + Thread.dumpStack(); + } + task.run(); + } } else { task.run(); } } public boolean validateEDT() { - if(0==refCount && null==aDevice && null != edtUtil && edtUtil.isRunning()) { - removeEDT( null ); - return true; + if( 0==refCount && null == aDevice ) { + final EDTUtil _edtUtil = edtUtil; + if( null != _edtUtil && _edtUtil.isRunning() ) { + synchronized( this ) { + if( null != edtUtil && edtUtil.isRunning() ) { // // volatile dbl-checked-locking OK + stopEDT( edtUtil, null ); + return true; + } + } + } } return false; } @@ -246,17 +275,18 @@ public abstract class DisplayImpl extends Display { if(DEBUG) { System.err.println("Display.destroy(): "+this+", active "+displaysActive+" "+getThreadName()); } - } + } final DisplayImpl f_dpy = this; - removeEDT( new Runnable() { // blocks! + final AbstractGraphicsDevice f_aDevice = aDevice; + aDevice = null; + refCount=0; + stopEDT( edtUtil, new Runnable() { // blocks! public void run() { - if ( null != aDevice ) { - f_dpy.closeNativeImpl(); + if ( null != f_aDevice ) { + f_dpy.closeNativeImpl(f_aDevice); } } } ); - aDevice = null; - refCount=0; if(DEBUG) { dumpDisplayList("Display.destroy("+getFQName()+") END"); } @@ -277,25 +307,28 @@ public abstract class DisplayImpl extends Display { if(0 < displaysActive) { displaysActive--; } + final EDTUtil edtUtil = d.getEDTUtil(); + final AbstractGraphicsDevice f_aDevice = d.aDevice; + d.aDevice = null; + d.refCount=0; final Runnable closeNativeTask = new Runnable() { public void run() { if ( null != d.getGraphicsDevice() ) { - d.closeNativeImpl(); + d.closeNativeImpl(f_aDevice); } } }; - final EDTUtil edtUtil = d.getEDTUtil(); if(null != edtUtil) { final long coopSleep = edtUtil.getPollPeriod() * 2; - edtUtil.invokeStop(false, closeNativeTask); // don't block + if( edtUtil.isRunning() ) { + edtUtil.invokeStop(false, closeNativeTask); // don't block + } try { Thread.sleep( coopSleep < 50 ? coopSleep : 50 ); } catch (InterruptedException e) { } } else { closeNativeTask.run(); } - d.aDevice = null; - d.refCount=0; } } } @@ -331,7 +364,7 @@ public abstract class DisplayImpl extends Display { } protected abstract void createNativeImpl(); - protected abstract void closeNativeImpl(); + protected abstract void closeNativeImpl(AbstractGraphicsDevice aDevice); @Override public final int getId() { @@ -399,15 +432,18 @@ public abstract class DisplayImpl extends Display { @Override public boolean isEDTRunning() { - if(null!=edtUtil) { - return edtUtil.isRunning(); + final EDTUtil _edtUtil = edtUtil; + if( null != _edtUtil ) { + return _edtUtil.isRunning(); } return false; } @Override public String toString() { - return "NEWT-Display["+getFQName()+", excl "+exclusive+", refCount "+refCount+", hasEDT "+(null!=edtUtil)+", edtRunning "+isEDTRunning()+", "+aDevice+"]"; + final EDTUtil _edtUtil = edtUtil; + final boolean _edtUtilRunning = ( null != _edtUtil ) ? _edtUtil.isRunning() : false; + return "NEWT-Display["+getFQName()+", excl "+exclusive+", refCount "+refCount+", hasEDT "+(null!=_edtUtil)+", edtRunning "+_edtUtilRunning+", "+aDevice+"]"; } /** Dispatch native Toolkit messageges */ @@ -500,17 +536,18 @@ public abstract class DisplayImpl extends Display { } public void enqueueEvent(boolean wait, NEWTEvent e) { - if(!isEDTRunning()) { + final EDTUtil _edtUtil = edtUtil; + if( !_edtUtil.isRunning() ) { // oops .. we are already dead if(DEBUG) { - Throwable t = new Throwable("Warning: EDT already stopped: wait:="+wait+", "+e); - t.printStackTrace(); + System.err.println("Warning: EDT already stopped: wait:="+wait+", "+e); + Thread.dumpStack(); } return; } // can't wait if we are on EDT or NEDT -> consume right away - if(wait && edtUtil.isCurrentThreadEDTorNEDT() ) { + if(wait && _edtUtil.isCurrentThreadEDTorNEDT() ) { dispatchMessage(e); return; } @@ -557,7 +594,7 @@ public abstract class DisplayImpl extends Display { return runWithLockedDevice(device, action); } - protected EDTUtil edtUtil = null; + protected volatile EDTUtil edtUtil = null; protected int id; protected String name; protected String type; diff --git a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java index a367462c4..a2877dba2 100644 --- a/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/android/DisplayDriver.java @@ -55,7 +55,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java index abd47d17e..80c72c008 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/driver/awt/AWTEDTUtil.java @@ -45,7 +45,7 @@ public class AWTEDTUtil implements EDTUtil { private final ThreadGroup threadGroup; private final String name; private final Runnable dispatchMessages; - private NewtEventDispatchThread nedt = null; + private NEDT nedt = null; private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; @@ -53,7 +53,7 @@ public class AWTEDTUtil implements EDTUtil { this.threadGroup = tg; this.name=Thread.currentThread().getName()+"-"+name+"-EDT-"; this.dispatchMessages=dispatchMessages; - this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt = new NEDT(threadGroup, name); this.nedt.setDaemon(true); // don't stop JVM from shutdown .. } @@ -68,33 +68,29 @@ public class AWTEDTUtil implements EDTUtil { } @Override - public final void reset() throws IllegalStateException { + public final boolean restart() throws IllegalStateException { synchronized(edtLock) { - final Thread curT = Thread.currentThread(); - final boolean onAWTEDT = EventQueue.isDispatchThread(); if( nedt.isRunning() ) { - if( !nedt.shouldStop ) { - throw new IllegalStateException("EDT stop not issued."); - } - if( nedt != curT && !onAWTEDT ) { - throw new IllegalStateException("EDT still running: Curr "+curT.getName()+", NEDT "+nedt.getName()+", on AWT-EDT "+onAWTEDT); - } + throw new IllegalStateException("EDT still running and not subject to stop. Curr "+Thread.currentThread().getName()+", NEDT "+nedt.getName()+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", on AWT-EDT "+EventQueue.isDispatchThread()); } if(DEBUG) { System.err.println(Thread.currentThread()+": AWT-EDT reset - edt: "+nedt); } - this.nedt = new NewtEventDispatchThread(threadGroup, name); - this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + if( nedt.getState() != Thread.State.NEW ) { + nedt = new NEDT(threadGroup, name); + nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + startImpl(); } + return invoke(true, nullTask); } private final void startImpl() { if(nedt.isAlive()) { - throw new RuntimeException("AWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + throw new RuntimeException("AWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", edt: "+nedt); } start_iter++; nedt.setName(name+start_iter); - nedt.shouldStop = false; if(DEBUG) { System.err.println(Thread.currentThread()+": AWT-EDT START - edt: "+nedt); // Thread.dumpStack(); @@ -123,55 +119,72 @@ public class AWTEDTUtil implements EDTUtil { } @Override - public final void invokeStop(boolean wait, Runnable task) { - invokeImpl(wait, task, true); + public final boolean invokeStop(boolean wait, Runnable task) { + return invokeImpl(wait, task, true); } @Override - public final void invoke(boolean wait, Runnable task) { - invokeImpl(wait, task, false); + public final boolean invoke(boolean wait, Runnable task) { + return invokeImpl(wait, task, false); } - private void invokeImpl(boolean wait, Runnable task, boolean stop) { + private static Runnable nullTask = new Runnable() { + @Override + public void run() { } + }; + + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; - Object rTaskLock = new Object(); + final Object rTaskLock = new Object(); synchronized(rTaskLock) { // lock the optional task execution synchronized(edtLock) { // lock the EDT status if( nedt.shouldStop ) { // drop task .. + System.err.println(Thread.currentThread()+": Warning: AWT-EDT about (1) to stop, won't enqueue new task: "+nedt); if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: AWT-EDT about (1) to stop, won't enqueue new task: "+nedt); Thread.dumpStack(); } - return; + return false; } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - synchronized(nedt.sync) { + if( isCurrentThreadEDT() ) { + if(null != task) { + task.run(); + } + wait = false; // running in same thread (EDT) -> no wait + if(stop) { nedt.shouldStop = true; - nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) } - if(DEBUG) { - System.err.println(Thread.currentThread()+": AWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt); - // Thread.dumpStack(); + } else { + if( !nedt.isRunning ) { + if( null != task ) { + if( stop ) { + System.err.println(Thread.currentThread()+": Warning: AWT-EDT is about (3) to stop and stopped already, dropping task. NEDT "+nedt); + } else { + System.err.println(Thread.currentThread()+": Warning: AWT-EDT is not running, dropping task. NEDT "+nedt); + } + if(DEBUG) { + Thread.dumpStack(); + } + } + return false; + } else if( stop ) { + if(DEBUG) { + System.err.println(Thread.currentThread()+": AWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop); + } + synchronized(nedt.sync) { + nedt.shouldStop = true; + nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) + } + } + + if(null != task) { + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */, + wait ? null : System.err); + AWTEDTExecutor.singleton.invoke(false, rTask); } - } else if( !nedt.isRunning() ) { - // start if should not stop && not started yet - startImpl(); - } - if( null == task ) { - wait = false; - } else if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else { - rTask = new RunnableTask(task, - wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */, - wait ? null : System.err); - AWTEDTExecutor.singleton.invoke(false, rTask); } } if( wait ) { @@ -190,51 +203,56 @@ public class AWTEDTUtil implements EDTUtil { throw new RuntimeException(throwable); } } + return true; } } @Override - final public void waitUntilIdle() { - final NewtEventDispatchThread _edt; + final public boolean waitUntilIdle() { + final NEDT _edt; synchronized(edtLock) { _edt = nedt; } - if(!_edt.isRunning() || _edt == Thread.currentThread() || EventQueue.isDispatchThread()) { - return; + if(!_edt.isRunning || _edt == Thread.currentThread() || EventQueue.isDispatchThread()) { + return false; } try { AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { } }); } catch (Exception e) { } + return true; } @Override - final public void waitUntilStopped() { + final public boolean waitUntilStopped() { synchronized(edtLock) { - if( nedt.isRunning() && nedt != Thread.currentThread() && !EventQueue.isDispatchThread() ) { - while(nedt.isRunning()) { + if( nedt.isRunning && nedt != Thread.currentThread() && !EventQueue.isDispatchThread() ) { + while( nedt.isRunning ) { try { edtLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } + return true; + } else { + return false; } } } - class NewtEventDispatchThread extends Thread { + class NEDT extends Thread { volatile boolean shouldStop = false; volatile boolean isRunning = false; Object sync = new Object(); - public NewtEventDispatchThread(ThreadGroup tg, String name) { + public NEDT(ThreadGroup tg, String name) { super(tg, name); } final public boolean isRunning() { - return isRunning; + return isRunning && !shouldStop; } @Override diff --git a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java index 4139951aa..30449f9bc 100644 --- a/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/awt/DisplayDriver.java @@ -34,6 +34,8 @@ package jogamp.newt.driver.awt; +import javax.media.nativewindow.AbstractGraphicsDevice; + import com.jogamp.nativewindow.awt.AWTGraphicsDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.util.EDTUtil; @@ -65,7 +67,7 @@ public class DisplayDriver extends DisplayImpl { return def; } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java index cc55c336e..112be2b04 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/egl/DisplayDriver.java @@ -69,7 +69,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice = new EGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, handle, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, null); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { if (aDevice.getHandle() != EGL.EGL_NO_DISPLAY) { DestroyDisplay(aDevice.getHandle()); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java index 08c5c573c..4872a9071 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -64,7 +64,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java index e370038d9..ee93eb932 100644 --- a/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/intel/gdl/DisplayDriver.java @@ -72,7 +72,7 @@ public class DisplayDriver extends jogamp.newt.DisplayImpl { aDevice = new DefaultGraphicsDevice(NativeWindowFactory.TYPE_DEFAULT, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT, displayHandle); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { if(0==displayHandle) { throw new NativeWindowException("displayHandle null; initCnt "+initCounter); } diff --git a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java index 745be5dae..3cd72e971 100644 --- a/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/kd/DisplayDriver.java @@ -64,7 +64,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index b49c6b6e0..a99bc4f23 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -72,7 +72,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = new MacOSXGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 1b9ec0f25..595d5e952 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -76,7 +76,7 @@ public class DisplayDriver extends DisplayImpl { aDevice = new WindowsGraphicsDevice(AbstractGraphicsDevice.DEFAULT_UNIT); } - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { sharedClassFactory.releaseSharedClass(); aDevice.close(); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 88d06f69c..d911483b0 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -82,13 +82,13 @@ public class DisplayDriver extends DisplayImpl { try { CompleteDisplay0(aDevice.getHandle()); } catch(RuntimeException e) { - closeNativeImpl(); + closeNativeImpl(aDevice); throw e; } } @Override - protected void closeNativeImpl() { + protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { DisplayRelease0(aDevice.getHandle(), javaObjectAtom, windowDeleteAtom /*, kbdHandle */); // XKB disabled for now javaObjectAtom = 0; windowDeleteAtom = 0; diff --git a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java index a8e03c510..d46562050 100644 --- a/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java +++ b/src/newt/classes/jogamp/newt/swt/SWTEDTUtil.java @@ -46,7 +46,7 @@ public class SWTEDTUtil implements EDTUtil { private final String name; private final Runnable dispatchMessages; private final org.eclipse.swt.widgets.Display swtDisplay; - private NewtEventDispatchThread nedt = null; + private NEDT nedt = null; private int start_iter=0; private static long pollPeriod = EDTUtil.defaultEDTPollPeriod; @@ -58,7 +58,7 @@ public class SWTEDTUtil implements EDTUtil { ((jogamp.newt.DisplayImpl) newtDisplay).dispatchMessages(); } }; this.swtDisplay = swtDisplay; - this.nedt = new NewtEventDispatchThread(threadGroup, name); + this.nedt = new NEDT(threadGroup, name); this.nedt.setDaemon(true); // don't stop JVM from shutdown .. } @@ -77,34 +77,39 @@ public class SWTEDTUtil implements EDTUtil { } @Override - public final void reset() throws IllegalStateException { + public final boolean restart() throws IllegalStateException { + final boolean swtDisposed = swtDisplay.isDisposed(); synchronized(edtLock) { - final Thread curT = Thread.currentThread(); - final Thread swtT = !swtDisplay.isDisposed() ? swtDisplay.getThread() : null; - final boolean onSWTEDT = swtT == curT; if( nedt.isRunning() ) { - if( !nedt.shouldStop ) { - throw new IllegalStateException("EDT stop not issued."); - } - if( nedt != curT && !onSWTEDT ) { - throw new IllegalStateException("EDT still running: Curr "+curT.getName()+", NEDT "+nedt.getName()+", SWT-EDT "+swtT.getName()); - } + final Thread curT = Thread.currentThread(); + final Thread swtT = !swtDisposed ? swtDisplay.getThread() : null; + final boolean onSWTEDT = swtT == curT; + throw new IllegalStateException("EDT still running and not subject to stop. Curr "+curT.getName()+", NEDT "+nedt.getName()+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", SWT-EDT "+swtT.getName()+", on SWT-EDT "+onSWTEDT); } if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt); + System.err.println(Thread.currentThread()+": SWT-EDT reset - edt: "+nedt+", swtDisposed (skipping) "+swtDisposed); + } + if( !swtDisposed ) { + if( nedt.getState() != Thread.State.NEW ) { + nedt = new NEDT(threadGroup, name); + nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + startImpl(); } - this.nedt = new NewtEventDispatchThread(threadGroup, name); - this.nedt.setDaemon(true); // don't stop JVM from shutdown .. + } + if( !swtDisposed ) { + return invoke(true, nullTask); + } else { + return false; } } private final void startImpl() { if(nedt.isAlive()) { - throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning()+", edt: "+nedt); + throw new RuntimeException("SWT-EDT Thread.isAlive(): true, isRunning: "+nedt.isRunning+", shouldStop "+nedt.shouldStop+", edt: "+nedt); } start_iter++; nedt.setName(name+start_iter); - nedt.shouldStop = false; if(DEBUG) { System.err.println(Thread.currentThread()+": SWT-EDT START - edt: "+nedt); // Thread.dumpStack(); @@ -130,60 +135,89 @@ public class SWTEDTUtil implements EDTUtil { @Override public boolean isRunning() { - return nedt.isRunning() ; + return nedt.isRunning(); } @Override - public final void invokeStop(boolean wait, Runnable task) { - invokeImpl(wait, task, true); + public final boolean invokeStop(boolean wait, Runnable task) { + return invokeImpl(wait, task, true); } @Override - public final void invoke(boolean wait, Runnable task) { - invokeImpl(wait, task, false); + public final boolean invoke(boolean wait, Runnable task) { + return invokeImpl(wait, task, false); } - private void invokeImpl(boolean wait, Runnable task, boolean stop) { + private static Runnable nullTask = new Runnable() { + @Override + public void run() { } + }; + + private final boolean invokeImpl(boolean wait, Runnable task, boolean stop) { Throwable throwable = null; RunnableTask rTask = null; - Object rTaskLock = new Object(); + final Object rTaskLock = new Object(); synchronized(rTaskLock) { // lock the optional task execution synchronized(edtLock) { // lock the EDT status if( nedt.shouldStop ) { // drop task .. if(DEBUG) { - System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt+", isRunning "+nedt.isRunning()); - // Thread.dumpStack(); + System.err.println(Thread.currentThread()+": Warning: SWT-EDT about (1) to stop, won't enqueue new task: "+nedt+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop); + Thread.dumpStack(); } - return; + return false; } - // System.err.println(Thread.currentThread()+" XXX stop: "+stop+", tasks: "+edt.tasks.size()+", task: "+task); - // Thread.dumpStack(); - if(stop) { - if(DEBUG) { - System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt+", isRunning "+nedt.isRunning()); + if( swtDisplay.isDisposed() ) { + stop = true; + } + + if( isCurrentThreadEDT() ) { + if(null != task) { + task.run(); } - synchronized(nedt.sync) { + wait = false; // running in same thread (EDT) -> no wait + if( stop ) { nedt.shouldStop = true; - nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) } - } else if( !nedt.isRunning() && !swtDisplay.isDisposed() ) { - // start if should not stop && not started yet - startImpl(); - } - if( null == task ) { - wait = false; - } else if( swtDisplay.isDisposed() ) { - wait = false; // drop task, SWT disposed - } else if( isCurrentThreadEDT() ) { - task.run(); - wait = false; // running in same thread (EDT) -> no wait - } else { - rTask = new RunnableTask(task, - wait ? rTaskLock : null, - true /* always catch and report Exceptions, don't disturb EDT */, - wait ? null : System.err); - swtDisplay.asyncExec(rTask); + } else { + if( !nedt.isRunning && !swtDisplay.isDisposed() ) { + if( null != task ) { + if( stop ) { + System.err.println(Thread.currentThread()+": Warning: SWT-EDT is about (3) to stop and stopped already, dropping task. NEDT "+nedt); + } else { + System.err.println(Thread.currentThread()+": Warning: SWT-EDT is not running, dropping task. NEDT "+nedt); + } + if(DEBUG) { + Thread.dumpStack(); + } + } + return false; + } else if( stop ) { + if( nedt.isRunning ) { + if(DEBUG) { + System.err.println(Thread.currentThread()+": SWT-EDT signal STOP (on edt: "+isCurrentThreadEDT()+") - "+nedt+", isRunning "+nedt.isRunning+", shouldStop "+nedt.shouldStop); + } + synchronized(nedt.sync) { + nedt.shouldStop = true; + nedt.sync.notifyAll(); // stop immediate if waiting (poll freq) + } + } + if( swtDisplay.isDisposed() ) { + System.err.println(Thread.currentThread()+": Warning: SWT-EDT is about (3) to stop and stopped already, dropping task. "+nedt); + if(DEBUG) { + Thread.dumpStack(); + } + return false; + } + } + + if( null != task ) { + rTask = new RunnableTask(task, + wait ? rTaskLock : null, + true /* always catch and report Exceptions, don't disturb EDT */, + wait ? null : System.err); + swtDisplay.asyncExec(rTask); + } } } if( wait ) { @@ -202,55 +236,60 @@ public class SWTEDTUtil implements EDTUtil { throw new RuntimeException(throwable); } } + return true; } } @Override - final public void waitUntilIdle() { - final NewtEventDispatchThread _nedt; + final public boolean waitUntilIdle() { + final NEDT _nedt; synchronized(edtLock) { _nedt = nedt; } final Thread ct = Thread.currentThread(); - if( !_nedt.isRunning() || _nedt == ct || swtDisplay.isDisposed() || swtDisplay.getThread() == ct ) { - return; + if( !_nedt.isRunning || _nedt == ct || swtDisplay.isDisposed() || swtDisplay.getThread() == ct ) { + return false; } try { swtDisplay.syncExec(new Runnable() { public void run() { } }); } catch (Exception e) { } + return true; } @Override - final public void waitUntilStopped() { + final public boolean waitUntilStopped() { synchronized(edtLock) { final Thread curT = Thread.currentThread(); final Thread swtT = !swtDisplay.isDisposed() ? swtDisplay.getThread() : null; final boolean onSWTEDT = swtT == curT; - if( nedt.isRunning() && nedt != curT && !onSWTEDT ) { - while(nedt.isRunning()) { + if( nedt.isRunning && nedt != curT && !onSWTEDT ) { + while( nedt.isRunning ) { try { edtLock.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } + return true; + } else { + return false; } } } - class NewtEventDispatchThread extends Thread { + class NEDT extends Thread { volatile boolean shouldStop = false; volatile boolean isRunning = false; Object sync = new Object(); - public NewtEventDispatchThread(ThreadGroup tg, String name) { + public NEDT(ThreadGroup tg, String name) { super(tg, name); } final public boolean isRunning() { - return isRunning; + return isRunning && !shouldStop; } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java index f8e6ee5d3..f1bc0ab7a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/InitConcurrentBaseNEWT.java @@ -184,6 +184,7 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { } protected void runJOGLTasks(int num, boolean reuse) throws InterruptedException { + System.err.println("InitConcurrentBaseNEWT "+num+" threads, reuse display: "+reuse); final String currentThreadName = Thread.currentThread().getName(); final Object syncDone = new Object(); final JOGLTask[] tasks = new JOGLTask[num]; @@ -198,13 +199,16 @@ public abstract class InitConcurrentBaseNEWT extends UITestCase { for(i=0; i */ public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT { - static boolean mainRun = false; - + @Test(timeout=180000) // TO 3 min public void test02TwoThreads() throws InterruptedException { runJOGLTasks(2, true); @@ -56,8 +55,7 @@ public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT { @Test(timeout=300000) // TO 5 min public void test16SixteenThreads() throws InterruptedException { - if( !mainRun && - Platform.getCPUFamily() != Platform.CPUFamily.ARM && + if( Platform.getCPUFamily() != Platform.CPUFamily.ARM && Platform.getOSType() != Platform.OSType.WINDOWS ) { runJOGLTasks(16, true); } else { @@ -66,11 +64,8 @@ public class TestInitConcurrent01NEWT extends InitConcurrentBaseNEWT { } public static void main(String args[]) throws IOException { - mainRun = true; for(int i=0; i Date: Tue, 9 Jul 2013 16:30:45 +0200 Subject: NEWT MonitorMode test cases: Add X11 XRandR commandline reset to UITestCase's AfterClass if available (X11). In case a MonitorMode test case fails, force XRandR reset '-s 0 -o normal' at end of test class if X11. Unit Test: TestScreenMode00cNEWT --- make/scripts/tests-win.bat | 3 +- make/scripts/tests.sh | 5 +- .../media/nativewindow/NativeWindowFactory.java | 5 +- .../test/junit/newt/mm/TestScreenMode00cNEWT.java | 221 +++++++++++++++++++++ .../jogamp/opengl/test/junit/util/MiscUtils.java | 30 +++ .../jogamp/opengl/test/junit/util/UITestCase.java | 20 ++ 6 files changed, 280 insertions(+), 4 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index da531dd66..872ba3716 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -115,10 +115,11 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursive REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01dNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a5ce8d2e9..bc37f2845 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -152,7 +152,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" - D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT -Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Window -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.X11Util.XErrorStackDump -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Dnativewindow.debug.X11Util" #D_ARGS="-Dnativewindow.debug.X11Util -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnewt.debug=all" @@ -405,6 +405,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* @@ -515,7 +516,7 @@ function testawtswt() { # # NEWT Parenting (w/ NEWT, AWT or SWT) # -testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index bf37b8d0c..07d1008b4 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -187,7 +187,7 @@ public abstract class NativeWindowFactory { } } - static boolean initialized = false; + private static boolean initialized = false; private static void initSingletonNativeImpl(final ClassLoader cl) { final String clazzName; @@ -295,6 +295,9 @@ public abstract class NativeWindowFactory { } } + /** Returns true if {@link #initSingleton()} has been called w/o subsequent {@link #shutdown(boolean)}. */ + public static synchronized boolean isInitialized() { return initialized; } + /** * Static one time initialization of this factory.
    * This initialization method must be called once by the program or utilizing modules! diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java new file mode 100644 index 000000000..dc3bf3c97 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java @@ -0,0 +1,221 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.mm; + +import java.io.IOException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jogamp.newt.Display; +import com.jogamp.newt.MonitorDevice; +import com.jogamp.newt.NewtFactory; +import com.jogamp.newt.Screen; +import com.jogamp.newt.Window; +import com.jogamp.newt.MonitorMode; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.newt.util.MonitorModeUtil; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import java.util.List; + +import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.util.Dimension; + +/** + * Tests X11 XRandR MonitorMode reset via {@link UITestCase#resetXRandRIfX11()}. + */ +public class TestScreenMode00cNEWT extends UITestCase { + static GLProfile glp; + static int width, height; + + static final int waitTimeShort = 2000; + static long duration = waitTimeShort; + + @BeforeClass + public static void initClass() { + NativeWindowFactory.initSingleton(); + if( NativeWindowFactory.TYPE_X11 != NativeWindowFactory.getNativeWindowType(true) ) { + setTestSupported(false); + return; + } + width = 100; + height = 100; + glp = GLProfile.getDefault(); + } + + @AfterClass + public static void releaseClass() throws InterruptedException { + Thread.sleep(waitTimeShort); + } + + static Window createWindow(Screen screen, GLCapabilities caps, String name, int x, int y, int width, int height) { + Assert.assertNotNull(caps); + + GLWindow window = GLWindow.create(screen, caps); + // Window window = NewtFactory.createWindow(screen, caps); + window.setTitle(name); + window.setPosition(x, y); + window.setSize(width, height); + window.addGLEventListener(new GearsES2()); + Assert.assertNotNull(window); + window.setVisible(true); + return window; + } + + static void destroyWindow(Window window) throws InterruptedException { + if(null!=window) { + window.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForRealized(window, false)); + } + } + + @Test + public void testScreenModeChange01() throws InterruptedException { + Thread.sleep(waitTimeShort); + + final GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + final Window window0 = createWindow(screen, caps, "win0", 0, 0, width, height); + Assert.assertNotNull(window0); + + final List allMonitorModes = screen.getMonitorModes(); + Assert.assertTrue(allMonitorModes.size()>0); + if(allMonitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (all), sorry"); + destroyWindow(window0); + return; + } + + final MonitorDevice monitor = screen.getMonitorDevices().get(0); + + List monitorModes = monitor.getSupportedModes(); + Assert.assertTrue(monitorModes.size()>0); + if(monitorModes.size()==1) { + // no support .. + System.err.println("Your platform has no MonitorMode change support (monitor), sorry"); + destroyWindow(window0); + return; + } + Assert.assertTrue(allMonitorModes.containsAll(monitorModes)); + + final MonitorMode mmSet0 = monitor.queryCurrentMode(); + Assert.assertNotNull(mmSet0); + final MonitorMode mmOrig = monitor.getOriginalMode(); + Assert.assertNotNull(mmOrig); + System.err.println("[0] orig : "+mmOrig); + System.err.println("[0] current: "+mmSet0); + Assert.assertEquals(mmSet0, mmOrig); + + + monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRotation(monitorModes, 0); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByResolution(monitorModes, new Dimension(801, 601)); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + monitorModes = MonitorModeUtil.filterByRate(monitorModes, mmOrig.getRefreshRate()); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); + Assert.assertNotNull(monitorModes); + Assert.assertTrue(monitorModes.size()>0); + + // set mode + { + MonitorMode mm = monitorModes.get(0); + System.err.println("[0] set current: "+mm); + final boolean smOk = monitor.setCurrentMode(mm); + MonitorMode mmCurrent = monitor.getCurrentMode(); + System.err.println("[0] has current: "+mmCurrent+", changeOK "+smOk); + Assert.assertTrue(monitor.isModeChangedByUs()); + Assert.assertEquals(mm, mmCurrent); + Assert.assertNotSame(mmOrig, mmCurrent); + Assert.assertEquals(mmCurrent, monitor.queryCurrentMode()); + Assert.assertTrue(smOk); + } + + Thread.sleep(duration); + + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + Assert.assertEquals(true,window0.isNativeValid()); + Assert.assertEquals(true,window0.isVisible()); + + UITestCase.resetXRandRIfX11(); + System.err.println("XRandR Reset :"+monitor.queryCurrentMode()); + validateScreenModeReset(mmOrig, 0); + + destroyWindow(window0); + + Thread.sleep(waitTimeShort); + } + + void validateScreenModeReset(final MonitorMode mmOrig, int mmIdx) { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + screen.addReference(); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + final MonitorDevice monitor = screen.getMonitorDevices().get(0); + Assert.assertEquals(mmOrig, monitor.queryCurrentMode()); + + screen.removeReference(); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i " + line); + } + } + catch (IOException ioe) { + System.err.println("Catched "+ioe.getClass().getName()+": "+ioe.getMessage()); + ioe.printStackTrace(); + } + } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java index 82a80ff49..90452ebfb 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java +++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java @@ -35,6 +35,7 @@ import java.io.InputStreamReader; import java.util.Iterator; import java.util.List; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilitiesImmutable; @@ -90,6 +91,24 @@ public abstract class UITestCase { testSupported = v; } + public static void resetXRandRIfX11() { + if( NativeWindowFactory.isInitialized() && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { + try { + final ProcessBuilder pb = new ProcessBuilder("xrandr", "-s", "0", "-o", "normal"); + pb.redirectErrorStream(true); + System.err.println("XRandR Reset cmd: "+pb.command()); + final Process p = pb.start(); + new MiscUtils.StreamDump( p.getInputStream(), "xrandr-reset" ).start(); + p.waitFor(); + System.err.println("XRandR Reset result "+p.exitValue()); + } catch (Exception e) { + System.err.println("Catched "+e.getClass().getName()+": "+e.getMessage()); + e.printStackTrace(); + } + System.err.println("XRandR Reset done"); + } + } + public int getMaxTestNameLen() { if(0 == maxMethodNameLen) { int ml = 0; @@ -125,6 +144,7 @@ public abstract class UITestCase { @AfterClass public static void oneTimeTearDown() { // one-time cleanup code + resetXRandRIfX11(); System.gc(); // force cleanup singletonInstance.unlock(); } -- cgit v1.2.3 From 18df35aa301c29bc6a85f8f8eabe0bd9407d8be6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 9 Jul 2013 16:41:45 +0200 Subject: PNGJ: Bump to git sha1 a0b1101ba2d37de39428ed55c8189502e24a3125 of https://code.google.com/p/pngj Part 2/2 - Started w/ 51427b92a2d9cd3fc619854e26536c9c6adad947 Missed rejected patches .. --- make/scripts/tests.sh | 4 +- .../classes/jogamp/opengl/util/pngj/PngReader.java | 1940 ++++++++++---------- .../opengl/util/pngj/chunks/ChunkHelper.java | 550 +++--- .../opengl/util/pngj/chunks/PngChunkTRNS.java | 284 ++- 4 files changed, 1440 insertions(+), 1338 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bc37f2845..ca4dc63ae 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -405,7 +405,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* @@ -551,7 +551,7 @@ testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java index 8cb4295a5..e42dd8733 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/PngReader.java @@ -1,940 +1,1000 @@ -package jogamp.opengl.util.pngj; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.HashSet; -import java.util.zip.CRC32; -import java.util.zip.InflaterInputStream; - -import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.ImageLine.SampleType; -import jogamp.opengl.util.pngj.chunks.ChunkHelper; -import jogamp.opengl.util.pngj.chunks.ChunkLoadBehaviour; -import jogamp.opengl.util.pngj.chunks.ChunkRaw; -import jogamp.opengl.util.pngj.chunks.ChunksList; -import jogamp.opengl.util.pngj.chunks.PngChunk; -import jogamp.opengl.util.pngj.chunks.PngChunkIDAT; -import jogamp.opengl.util.pngj.chunks.PngChunkIHDR; -import jogamp.opengl.util.pngj.chunks.PngChunkSkipped; -import jogamp.opengl.util.pngj.chunks.PngMetadata; - -/** - * Reads a PNG image, line by line. - *

    - * The reading sequence is as follows:
    - * 1. At construction time, the header and IHDR chunk are read (basic image info)
    - * 2. Afterwards you can set some additional global options. Eg. {@link #setUnpackedMode(boolean)}, - * {@link #setCrcCheckDisabled()}.
    - * 3. Optional: If you call getMetadata() or getChunksLisk() before start reading the rows, all the chunks before IDAT - * are automatically loaded and available
    - * 4a. The rows are read onen by one of the readRowXXX methods: {@link #readRowInt(int)}, - * {@link PngReader#readRowByte(int)}, etc, in order, from 0 to nrows-1 (you can skip or repeat rows, but not go - * backwards)
    - * 4b. Alternatively, you can read all rows, or a subset, in a single call: {@link #readRowsInt()}, - * {@link #readRowsByte()} ,etc. In general this consumes more memory, but for interlaced images this is equally - * efficient, and more so if reading a small subset of rows.
    - * 5. Read of the last row auyomatically loads the trailing chunks, and ends the reader.
    - * 6. end() forcibly finishes/aborts the reading and closes the stream - */ -public class PngReader { - /** - * Basic image info - final and inmutable. - */ - public final ImageInfo imgInfo; - - /** - * not necesarily a filename, can be a description - merely informative - */ - protected final String filename; - - private ChunkLoadBehaviour chunkLoadBehaviour = ChunkLoadBehaviour.LOAD_CHUNK_ALWAYS; // see setter/getter - - private boolean shouldCloseStream = true; // true: closes stream after ending - see setter/getter - - // some performance/defensive limits - private long maxTotalBytesRead = 200 * 1024 * 1024; // 200MB - private int maxBytesMetadata = 5 * 1024 * 1024; // for ancillary chunks - see setter/getter - private int skipChunkMaxSize = 2 * 1024 * 1024; // chunks exceeding this size will be skipped (nor even CRC checked) - private String[] skipChunkIds = { "fdAT" }; // chunks with these ids will be skipped (nor even CRC checked) - private HashSet skipChunkIdsSet; // lazily created from skipChunksById - - protected final PngMetadata metadata; // this a wrapper over chunks - protected final ChunksList chunksList; - - protected ImageLine imgLine; - - // line as bytes, counting from 1 (index 0 is reserved for filter type) - protected byte[] rowb = null; - protected byte[] rowbprev = null; // rowb previous - protected byte[] rowbfilter = null; // current line 'filtered': exactly as in uncompressed stream - - // only set for interlaced PNG - private final boolean interlaced; - private final PngDeinterlacer deinterlacer; - - private boolean crcEnabled = true; - - // this only influences the 1-2-4 bitdepth format - private boolean unpackedMode = false; - /** - * Current chunk group, (0-6) already read or reading - *

    - * see {@link ChunksList} - */ - protected int currentChunkGroup = -1; - - protected int rowNum = -1; // last read row number, starting from 0 - private long offset = 0; // offset in InputStream = bytes read - private int bytesChunksLoaded; // bytes loaded from anciallary chunks - - protected final InputStream inputStream; - protected InflaterInputStream idatIstream; - protected PngIDatChunkInputStream iIdatCstream; - - protected CRC32 crctest; // If set to non null, it gets a CRC of the unfiltered bytes, to check for images equality - - /** - * Constructs a PngReader from an InputStream. - *

    - * See also FileHelper.createPngReader(File f) if available. - * - * Reads only the signature and first chunk (IDHR) - * - * @param filenameOrDescription - * : Optional, can be a filename or a description. Just for error/debug messages - * - */ - public PngReader(InputStream inputStream, String filenameOrDescription) { - this.filename = filenameOrDescription == null ? "" : filenameOrDescription; - this.inputStream = inputStream; - this.chunksList = new ChunksList(null); - this.metadata = new PngMetadata(chunksList); - // starts reading: signature - byte[] pngid = new byte[8]; - PngHelperInternal.readBytes(inputStream, pngid, 0, pngid.length); - offset += pngid.length; - if (!Arrays.equals(pngid, PngHelperInternal.getPngIdSignature())) - throw new PngjInputException("Bad PNG signature"); - // reads first chunk - currentChunkGroup = ChunksList.CHUNK_GROUP_0_IDHR; - int clen = PngHelperInternal.readInt4(inputStream); - offset += 4; - if (clen != 13) - throw new PngjInputException("IDHR chunk len != 13 ?? " + clen); - byte[] chunkid = new byte[4]; - PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); - if (!Arrays.equals(chunkid, ChunkHelper.b_IHDR)) - throw new PngjInputException("IHDR not found as first chunk??? [" + ChunkHelper.toString(chunkid) + "]"); - offset += 4; - PngChunkIHDR ihdr = (PngChunkIHDR) readChunk(chunkid, clen, false); - boolean alpha = (ihdr.getColormodel() & 0x04) != 0; - boolean palette = (ihdr.getColormodel() & 0x01) != 0; - boolean grayscale = (ihdr.getColormodel() == 0 || ihdr.getColormodel() == 4); - // creates ImgInfo and imgLine, and allocates buffers - imgInfo = new ImageInfo(ihdr.getCols(), ihdr.getRows(), ihdr.getBitspc(), alpha, grayscale, palette); - // allocation: one extra byte for filter type one pixel - rowbfilter = new byte[imgInfo.bytesPerRow + 1]; - rowb = new byte[imgInfo.bytesPerRow + 1]; - rowbprev = new byte[rowb.length]; - interlaced = ihdr.getInterlaced() == 1; - deinterlacer = interlaced ? new PngDeinterlacer(imgInfo) : null; - // some checks - if (ihdr.getFilmeth() != 0 || ihdr.getCompmeth() != 0 || (ihdr.getInterlaced() & 0xFFFE) != 0) - throw new PngjInputException("compression method o filter method or interlaced unrecognized "); - if (ihdr.getColormodel() < 0 || ihdr.getColormodel() > 6 || ihdr.getColormodel() == 1 - || ihdr.getColormodel() == 5) - throw new PngjInputException("Invalid colormodel " + ihdr.getColormodel()); - if (ihdr.getBitspc() != 1 && ihdr.getBitspc() != 2 && ihdr.getBitspc() != 4 && ihdr.getBitspc() != 8 - && ihdr.getBitspc() != 16) - throw new PngjInputException("Invalid bit depth " + ihdr.getBitspc()); - } - - private boolean firstChunksNotYetRead() { - return currentChunkGroup < ChunksList.CHUNK_GROUP_1_AFTERIDHR; - } - - /** - * Reads last Internally called after having read the last line. It reads extra chunks after IDAT, if present. - */ - private void readLastAndClose() { - // offset = iIdatCstream.getOffset(); - if (currentChunkGroup < ChunksList.CHUNK_GROUP_5_AFTERIDAT) { - try { - idatIstream.close(); - } catch (Exception e) { - } - readLastChunks(); - } - close(); - } - - private void close() { - if (currentChunkGroup < ChunksList.CHUNK_GROUP_6_END) { // this could only happen if forced close - try { - idatIstream.close(); - } catch (Exception e) { - } - currentChunkGroup = ChunksList.CHUNK_GROUP_6_END; - } - if (shouldCloseStream) { - try { - inputStream.close(); - } catch (Exception e) { - throw new PngjInputException("error closing input stream!", e); - } - } - } - - // nbytes: NOT including the filter byte. leaves result in rowb - private void unfilterRow(int nbytes) { - int ftn = rowbfilter[0]; - FilterType ft = FilterType.getByVal(ftn); - if (ft == null) - throw new PngjInputException("Filter type " + ftn + " invalid"); - switch (ft) { - case FILTER_NONE: - unfilterRowNone(nbytes); - break; - case FILTER_SUB: - unfilterRowSub(nbytes); - break; - case FILTER_UP: - unfilterRowUp(nbytes); - break; - case FILTER_AVERAGE: - unfilterRowAverage(nbytes); - break; - case FILTER_PAETH: - unfilterRowPaeth(nbytes); - break; - default: - throw new PngjInputException("Filter type " + ftn + " not implemented"); - } - if (crctest != null) - crctest.update(rowb, 1, rowb.length - 1); - } - - private void unfilterRowAverage(final int nbytes) { - int i, j, x; - for (j = 1 - imgInfo.bytesPixel, i = 1; i <= nbytes; i++, j++) { - x = j > 0 ? (rowb[j] & 0xff) : 0; - rowb[i] = (byte) (rowbfilter[i] + (x + (rowbprev[i] & 0xFF)) / 2); - } - } - - private void unfilterRowNone(final int nbytes) { - for (int i = 1; i <= nbytes; i++) { - rowb[i] = (byte) (rowbfilter[i]); - } - } - - private void unfilterRowPaeth(final int nbytes) { - int i, j, x, y; - for (j = 1 - imgInfo.bytesPixel, i = 1; i <= nbytes; i++, j++) { - x = j > 0 ? (rowb[j] & 0xFF) : 0; - y = j > 0 ? (rowbprev[j] & 0xFF) : 0; - rowb[i] = (byte) (rowbfilter[i] + PngHelperInternal.filterPaethPredictor(x, rowbprev[i] & 0xFF, y)); - } - } - - private void unfilterRowSub(final int nbytes) { - int i, j; - for (i = 1; i <= imgInfo.bytesPixel; i++) { - rowb[i] = (byte) (rowbfilter[i]); - } - for (j = 1, i = imgInfo.bytesPixel + 1; i <= nbytes; i++, j++) { - rowb[i] = (byte) (rowbfilter[i] + rowb[j]); - } - } - - private void unfilterRowUp(final int nbytes) { - for (int i = 1; i <= nbytes; i++) { - rowb[i] = (byte) (rowbfilter[i] + rowbprev[i]); - } - } - - /** - * Reads chunks before first IDAT. Normally this is called automatically - *

    - * Position before: after IDHR (crc included) Position after: just after the first IDAT chunk id - *

    - * This can be called several times (tentatively), it does nothing if already run - *

    - * (Note: when should this be called? in the constructor? hardly, because we loose the opportunity to call - * setChunkLoadBehaviour() and perhaps other settings before reading the first row? but sometimes we want to access - * some metadata (plte, phys) before. Because of this, this method can be called explicitly but is also called - * implicititly in some methods (getMetatada(), getChunksList()) - */ - private final void readFirstChunks() { - if (!firstChunksNotYetRead()) - return; - int clen = 0; - boolean found = false; - byte[] chunkid = new byte[4]; // it's important to reallocate in each iteration - currentChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR; - while (!found) { - clen = PngHelperInternal.readInt4(inputStream); - offset += 4; - if (clen < 0) - break; - PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); - offset += 4; - if (Arrays.equals(chunkid, ChunkHelper.b_IDAT)) { - found = true; - currentChunkGroup = ChunksList.CHUNK_GROUP_4_IDAT; - // add dummy idat chunk to list - chunksList.appendReadChunk(new PngChunkIDAT(imgInfo, clen, offset - 8), currentChunkGroup); - break; - } else if (Arrays.equals(chunkid, ChunkHelper.b_IEND)) { - throw new PngjInputException("END chunk found before image data (IDAT) at offset=" + offset); - } - if (Arrays.equals(chunkid, ChunkHelper.b_PLTE)) - currentChunkGroup = ChunksList.CHUNK_GROUP_2_PLTE; - readChunk(chunkid, clen, false); - if (Arrays.equals(chunkid, ChunkHelper.b_PLTE)) - currentChunkGroup = ChunksList.CHUNK_GROUP_3_AFTERPLTE; - } - int idatLen = found ? clen : -1; - if (idatLen < 0) - throw new PngjInputException("first idat chunk not found!"); - iIdatCstream = new PngIDatChunkInputStream(inputStream, idatLen, offset); - idatIstream = new InflaterInputStream(iIdatCstream); - if (!crcEnabled) - iIdatCstream.disableCrcCheck(); - } - - /** - * Reads (and processes) chunks after last IDAT. - **/ - void readLastChunks() { - // PngHelper.logdebug("idat ended? " + iIdatCstream.isEnded()); - currentChunkGroup = ChunksList.CHUNK_GROUP_5_AFTERIDAT; - if (!iIdatCstream.isEnded()) - iIdatCstream.forceChunkEnd(); - int clen = iIdatCstream.getLenLastChunk(); - byte[] chunkid = iIdatCstream.getIdLastChunk(); - boolean endfound = false; - boolean first = true; - boolean skip = false; - while (!endfound) { - skip = false; - if (!first) { - clen = PngHelperInternal.readInt4(inputStream); - offset += 4; - if (clen < 0) - throw new PngjInputException("bad chuck len " + clen); - PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); - offset += 4; - } - first = false; - if (Arrays.equals(chunkid, ChunkHelper.b_IDAT)) { - skip = true; // extra dummy (empty?) idat chunk, it can happen, ignore it - } else if (Arrays.equals(chunkid, ChunkHelper.b_IEND)) { - currentChunkGroup = ChunksList.CHUNK_GROUP_6_END; - endfound = true; - } - readChunk(chunkid, clen, skip); - } - if (!endfound) - throw new PngjInputException("end chunk not found - offset=" + offset); - // PngHelper.logdebug("end chunk found ok offset=" + offset); - } - - /** - * Reads chunkd from input stream, adds to ChunksList, and returns it. If it's skipped, a PngChunkSkipped object is - * created - */ - private PngChunk readChunk(byte[] chunkid, int clen, boolean skipforced) { - if (clen < 0) - throw new PngjInputException("invalid chunk lenght: " + clen); - // skipChunksByIdSet is created lazyly, if fist IHDR has already been read - if (skipChunkIdsSet == null && currentChunkGroup > ChunksList.CHUNK_GROUP_0_IDHR) - skipChunkIdsSet = new HashSet(Arrays.asList(skipChunkIds)); - String chunkidstr = ChunkHelper.toString(chunkid); - boolean critical = ChunkHelper.isCritical(chunkidstr); - PngChunk pngChunk = null; - boolean skip = skipforced; - if (maxTotalBytesRead > 0 && clen + offset > maxTotalBytesRead) - throw new PngjInputException("Maximum total bytes to read exceeeded: " + maxTotalBytesRead + " offset:" - + offset + " clen=" + clen); - // an ancillary chunks can be skipped because of several reasons: - if (currentChunkGroup > ChunksList.CHUNK_GROUP_0_IDHR && !critical) - skip = skip || (skipChunkMaxSize > 0 && clen >= skipChunkMaxSize) || skipChunkIdsSet.contains(chunkidstr) - || (maxBytesMetadata > 0 && clen > maxBytesMetadata - bytesChunksLoaded) - || !ChunkHelper.shouldLoad(chunkidstr, chunkLoadBehaviour); - if (skip) { - PngHelperInternal.skipBytes(inputStream, clen); - PngHelperInternal.readInt4(inputStream); // skip - we dont call PngHelperInternal.skipBytes(inputStream, - // clen + 4) for risk of overflow - pngChunk = new PngChunkSkipped(chunkidstr, imgInfo, clen); - } else { - ChunkRaw chunk = new ChunkRaw(clen, chunkid, true); - chunk.readChunkData(inputStream, crcEnabled || critical); - pngChunk = PngChunk.factory(chunk, imgInfo); - if (!pngChunk.crit) - bytesChunksLoaded += chunk.len; - } - pngChunk.setOffset(offset - 8L); - chunksList.appendReadChunk(pngChunk, currentChunkGroup); - offset += clen + 4L; - return pngChunk; - } - - /** - * Logs/prints a warning. - *

    - * The default behaviour is print to stderr, but it can be overriden. - *

    - * This happens rarely - most errors are fatal. - */ - protected void logWarn(String warn) { - System.err.println(warn); - } - - /** - * @see #setChunkLoadBehaviour(ChunkLoadBehaviour) - */ - public ChunkLoadBehaviour getChunkLoadBehaviour() { - return chunkLoadBehaviour; - } - - /** - * Determines which ancillary chunks (metada) are to be loaded - * - * @param chunkLoadBehaviour - * {@link ChunkLoadBehaviour} - */ - public void setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour) { - this.chunkLoadBehaviour = chunkLoadBehaviour; - } - - /** - * All loaded chunks (metada). If we have not yet end reading the image, this will include only the chunks before - * the pixels data (IDAT) - *

    - * Critical chunks are included, except that all IDAT chunks appearance are replaced by a single dummy-marker IDAT - * chunk. These might be copied to the PngWriter - *

    - * - * @see #getMetadata() - */ - public ChunksList getChunksList() { - if (firstChunksNotYetRead()) - readFirstChunks(); - return chunksList; - } - - int getCurrentChunkGroup() { - return currentChunkGroup; - } - - /** - * High level wrapper over chunksList - * - * @see #getChunksList() - */ - public PngMetadata getMetadata() { - if (firstChunksNotYetRead()) - readFirstChunks(); - return metadata; - } - - /** - * If called for first time, calls readRowInt. Elsewhere, it calls the appropiate readRowInt/readRowByte - *

    - * In general, specifying the concrete readRowInt/readRowByte is preferrable - * - * @see #readRowInt(int) {@link #readRowByte(int)} - */ - public ImageLine readRow(int nrow) { - if (imgLine == null) - imgLine = new ImageLine(imgInfo, SampleType.INT, unpackedMode); - return imgLine.sampleType != SampleType.BYTE ? readRowInt(nrow) : readRowByte(nrow); - } - - /** - * Reads the row as INT, storing it in the {@link #imgLine} property and returning it. - * - * The row must be greater or equal than the last read row. - * - * @param nrow - * Row number, from 0 to rows-1. Increasing order. - * @return ImageLine object, also available as field. Data is in {@link ImageLine#scanline} (int) field. - */ - public ImageLine readRowInt(int nrow) { - if (imgLine == null) - imgLine = new ImageLine(imgInfo, SampleType.INT, unpackedMode); - if (imgLine.getRown() == nrow) // already read - return imgLine; - readRowInt(imgLine.scanline, nrow); - imgLine.setFilterUsed(FilterType.getByVal(rowbfilter[0])); - imgLine.setRown(nrow); - return imgLine; - } - - /** - * Reads the row as BYTES, storing it in the {@link #imgLine} property and returning it. - * - * The row must be greater or equal than the last read row. This method allows to pass the same row that was last - * read. - * - * @param nrow - * Row number, from 0 to rows-1. Increasing order. - * @return ImageLine object, also available as field. Data is in {@link ImageLine#scanlineb} (byte) field. - */ - public ImageLine readRowByte(int nrow) { - if (imgLine == null) - imgLine = new ImageLine(imgInfo, SampleType.BYTE, unpackedMode); - if (imgLine.getRown() == nrow) // already read - return imgLine; - readRowByte(imgLine.scanlineb, nrow); - imgLine.setFilterUsed(FilterType.getByVal(rowbfilter[0])); - imgLine.setRown(nrow); - return imgLine; - } - - /** - * @see #readRowInt(int[], int) - */ - public final int[] readRow(int[] buffer, final int nrow) { - return readRowInt(buffer, nrow); - } - - /** - * Reads a line and returns it as a int[] array. - *

    - * You can pass (optionally) a prealocatted buffer. - *

    - * If the bitdepth is less than 8, the bytes are packed - unless {@link #unpackedMode} is true. - * - * @param buffer - * Prealocated buffer, or null. - * @param nrow - * Row number (0 is top). Most be strictly greater than the last read row. - * - * @return The scanline in the same passwd buffer if it was allocated, a newly allocated one otherwise - */ - public final int[] readRowInt(int[] buffer, final int nrow) { - if (buffer == null) - buffer = new int[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; - if (!interlaced) { - if (nrow <= rowNum) - throw new PngjInputException("rows must be read in increasing order: " + nrow); - int bytesread = 0; - while (rowNum < nrow) - bytesread = readRowRaw(rowNum + 1); // read rows, perhaps skipping if necessary - decodeLastReadRowToInt(buffer, bytesread); - } else { // interlaced - if (deinterlacer.getImageInt() == null) - deinterlacer.setImageInt(readRowsInt().scanlines); // read all image and store it in deinterlacer - System.arraycopy(deinterlacer.getImageInt()[nrow], 0, buffer, 0, unpackedMode ? imgInfo.samplesPerRow - : imgInfo.samplesPerRowPacked); - } - return buffer; - } - - /** - * Reads a line and returns it as a byte[] array. - *

    - * You can pass (optionally) a prealocatted buffer. - *

    - * If the bitdepth is less than 8, the bytes are packed - unless {@link #unpackedMode} is true.
    - * If the bitdepth is 16, the least significant byte is lost. - *

    - * - * @param buffer - * Prealocated buffer, or null. - * @param nrow - * Row number (0 is top). Most be strictly greater than the last read row. - * - * @return The scanline in the same passwd buffer if it was allocated, a newly allocated one otherwise - */ - public final byte[] readRowByte(byte[] buffer, final int nrow) { - if (buffer == null) - buffer = new byte[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; - if (!interlaced) { - if (nrow <= rowNum) - throw new PngjInputException("rows must be read in increasing order: " + nrow); - int bytesread = 0; - while (rowNum < nrow) - bytesread = readRowRaw(rowNum + 1); // read rows, perhaps skipping if necessary - decodeLastReadRowToByte(buffer, bytesread); - } else { // interlaced - if (deinterlacer.getImageByte() == null) - deinterlacer.setImageByte(readRowsByte().scanlinesb); // read all image and store it in deinterlacer - System.arraycopy(deinterlacer.getImageByte()[nrow], 0, buffer, 0, unpackedMode ? imgInfo.samplesPerRow - : imgInfo.samplesPerRowPacked); - } - return buffer; - } - - /** - * @param nrow - * @deprecated Now {@link #readRow(int)} implements the same funcion. This method will be removed in future releases - */ - public ImageLine getRow(int nrow) { - return readRow(nrow); - } - - private void decodeLastReadRowToInt(int[] buffer, int bytesRead) { - if (imgInfo.bitDepth <= 8) - for (int i = 0, j = 1; i < bytesRead; i++) - buffer[i] = (rowb[j++] & 0xFF); // http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html - else - for (int i = 0, j = 1; j <= bytesRead; i++) - buffer[i] = ((rowb[j++] & 0xFF) << 8) + (rowb[j++] & 0xFF); // 16 bitspc - if (imgInfo.packed && unpackedMode) - ImageLine.unpackInplaceInt(imgInfo, buffer, buffer, false); - } - - private void decodeLastReadRowToByte(byte[] buffer, int bytesRead) { - if (imgInfo.bitDepth <= 8) - System.arraycopy(rowb, 1, buffer, 0, bytesRead); - else - for (int i = 0, j = 1; j < bytesRead; i++, j += 2) - buffer[i] = rowb[j];// 16 bits in 1 byte: this discards the LSB!!! - if (imgInfo.packed && unpackedMode) - ImageLine.unpackInplaceByte(imgInfo, buffer, buffer, false); - } - - /** - * Reads a set of lines and returns it as a ImageLines object, which wraps matrix. Internally it reads all lines, - * but decodes and stores only the wanted ones. This starts and ends the reading, and cannot be combined with other - * reading methods. - *

    - * This it's more efficient (speed an memory) that doing calling readRowInt() for each desired line only if the - * image is interlaced. - *

    - * Notice that the columns in the matrix is not the pixel width of the image, but rather pixels x channels - * - * @see #readRowInt(int) to read about the format of each row - * - * @param rowOffset - * Number of rows to be skipped - * @param nRows - * Total number of rows to be read. -1: read all available - * @param rowStep - * Row increment. If 1, we read consecutive lines; if 2, we read even/odd lines, etc - * @return Set of lines as a ImageLines, which wraps a matrix - */ - public ImageLines readRowsInt(int rowOffset, int nRows, int rowStep) { - if (nRows < 0) - nRows = (imgInfo.rows - rowOffset) / rowStep; - if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > imgInfo.rows) - throw new PngjInputException("bad args"); - ImageLines imlines = new ImageLines(imgInfo, SampleType.INT, unpackedMode, rowOffset, nRows, rowStep); - if (!interlaced) { - for (int j = 0; j < imgInfo.rows; j++) { - int bytesread = readRowRaw(j); // read and perhaps discards - int mrow = imlines.imageRowToMatrixRowStrict(j); - if (mrow >= 0) - decodeLastReadRowToInt(imlines.scanlines[mrow], bytesread); - } - } else { // and now, for something completely different (interlaced) - int[] buf = new int[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; - for (int p = 1; p <= 7; p++) { - deinterlacer.setPass(p); - for (int i = 0; i < deinterlacer.getRows(); i++) { - int bytesread = readRowRaw(i); - int j = deinterlacer.getCurrRowReal(); - int mrow = imlines.imageRowToMatrixRowStrict(j); - if (mrow >= 0) { - decodeLastReadRowToInt(buf, bytesread); - deinterlacer.deinterlaceInt(buf, imlines.scanlines[mrow], !unpackedMode); - } - } - } - } - end(); - return imlines; - } - - /** - * Same as readRowsInt(0, imgInfo.rows, 1) - * - * @see #readRowsInt(int, int, int) - */ - public ImageLines readRowsInt() { - return readRowsInt(0, imgInfo.rows, 1); - } - - /** - * Reads a set of lines and returns it as a ImageLines object, which wrapas a byte[][] matrix. Internally it reads - * all lines, but decodes and stores only the wanted ones. This starts and ends the reading, and cannot be combined - * with other reading methods. - *

    - * This it's more efficient (speed an memory) that doing calling readRowByte() for each desired line only if the - * image is interlaced. - *

    - * Notice that the columns in the matrix is not the pixel width of the image, but rather pixels x channels - * - * @see #readRowByte(int) to read about the format of each row. Notice that if the bitdepth is 16 this will lose - * information - * - * @param rowOffset - * Number of rows to be skipped - * @param nRows - * Total number of rows to be read. -1: read all available - * @param rowStep - * Row increment. If 1, we read consecutive lines; if 2, we read even/odd lines, etc - * @return Set of lines as a matrix - */ - public ImageLines readRowsByte(int rowOffset, int nRows, int rowStep) { - if (nRows < 0) - nRows = (imgInfo.rows - rowOffset) / rowStep; - if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > imgInfo.rows) - throw new PngjInputException("bad args"); - ImageLines imlines = new ImageLines(imgInfo, SampleType.BYTE, unpackedMode, rowOffset, nRows, rowStep); - if (!interlaced) { - for (int j = 0; j < imgInfo.rows; j++) { - int bytesread = readRowRaw(j); // read and perhaps discards - int mrow = imlines.imageRowToMatrixRowStrict(j); - if (mrow >= 0) - decodeLastReadRowToByte(imlines.scanlinesb[mrow], bytesread); - } - } else { // and now, for something completely different (interlaced) - byte[] buf = new byte[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; - for (int p = 1; p <= 7; p++) { - deinterlacer.setPass(p); - for (int i = 0; i < deinterlacer.getRows(); i++) { - int bytesread = readRowRaw(i); - int j = deinterlacer.getCurrRowReal(); - int mrow = imlines.imageRowToMatrixRowStrict(j); - if (mrow >= 0) { - decodeLastReadRowToByte(buf, bytesread); - deinterlacer.deinterlaceByte(buf, imlines.scanlinesb[mrow], !unpackedMode); - } - } - } - } - end(); - return imlines; - } - - /** - * Same as readRowsByte(0, imgInfo.rows, 1) - * - * @see #readRowsByte(int, int, int) - */ - public ImageLines readRowsByte() { - return readRowsByte(0, imgInfo.rows, 1); - } - - /* - * For the interlaced case, nrow indicates the subsampled image - the pass must be set already. - * - * This must be called in strict order, both for interlaced or no interlaced. - * - * Updates rowNum. - * - * Leaves raw result in rowb - * - * Returns bytes actually read (not including the filter byte) - */ - private int readRowRaw(final int nrow) { - // - if (nrow == 0 && firstChunksNotYetRead()) - readFirstChunks(); - if (nrow == 0 && interlaced) - Arrays.fill(rowb, (byte) 0); // new subimage: reset filters: this is enough, see the swap that happens lines - // below - int bytesRead = imgInfo.bytesPerRow; // NOT including the filter byte - if (interlaced) { - if (nrow < 0 || nrow > deinterlacer.getRows() || (nrow != 0 && nrow != deinterlacer.getCurrRowSubimg() + 1)) - throw new PngjInputException("invalid row in interlaced mode: " + nrow); - deinterlacer.setRow(nrow); - bytesRead = (imgInfo.bitspPixel * deinterlacer.getPixelsToRead() + 7) / 8; - if (bytesRead < 1) - throw new PngjExceptionInternal("wtf??"); - } else { // check for non interlaced - if (nrow < 0 || nrow >= imgInfo.rows || nrow != rowNum + 1) - throw new PngjInputException("invalid row: " + nrow); - } - rowNum = nrow; - // swap buffers - byte[] tmp = rowb; - rowb = rowbprev; - rowbprev = tmp; - // loads in rowbfilter "raw" bytes, with filter - PngHelperInternal.readBytes(idatIstream, rowbfilter, 0, bytesRead + 1); - offset = iIdatCstream.getOffset(); - if (offset < 0) - throw new PngjExceptionInternal("bad offset ??" + offset); - if (maxTotalBytesRead > 0 && offset >= maxTotalBytesRead) - throw new PngjInputException("Reading IDAT: Maximum total bytes to read exceeeded: " + maxTotalBytesRead - + " offset:" + offset); - rowb[0] = 0; - unfilterRow(bytesRead); - rowb[0] = rowbfilter[0]; - if ((rowNum == imgInfo.rows - 1 && !interlaced) || (interlaced && deinterlacer.isAtLastRow())) - readLastAndClose(); - return bytesRead; - } - - /** - * Reads all the (remaining) file, skipping the pixels data. This is much more efficient that calling readRow(), - * specially for big files (about 10 times faster!), because it doesn't even decompress the IDAT stream and disables - * CRC check Use this if you are not interested in reading pixels,only metadata. - */ - public void readSkippingAllRows() { - if (firstChunksNotYetRead()) - readFirstChunks(); - // we read directly from the compressed stream, we dont decompress nor chec CRC - iIdatCstream.disableCrcCheck(); - try { - int r; - do { - r = iIdatCstream.read(rowbfilter, 0, rowbfilter.length); - } while (r >= 0); - } catch (IOException e) { - throw new PngjInputException("error in raw read of IDAT", e); - } - offset = iIdatCstream.getOffset(); - if (offset < 0) - throw new PngjExceptionInternal("bad offset ??" + offset); - if (maxTotalBytesRead > 0 && offset >= maxTotalBytesRead) - throw new PngjInputException("Reading IDAT: Maximum total bytes to read exceeeded: " + maxTotalBytesRead - + " offset:" + offset); - readLastAndClose(); - } - - /** - * Set total maximum bytes to read (0: unlimited; default: 200MB).
    - * These are the bytes read (not loaded) in the input stream. If exceeded, an exception will be thrown. - */ - public void setMaxTotalBytesRead(long maxTotalBytesToRead) { - this.maxTotalBytesRead = maxTotalBytesToRead; - } - - /** - * @return Total maximum bytes to read. - */ - public long getMaxTotalBytesRead() { - return maxTotalBytesRead; - } - - /** - * Set total maximum bytes to load from ancillary chunks (0: unlimited; default: 5Mb).
    - * If exceeded, some chunks will be skipped - */ - public void setMaxBytesMetadata(int maxBytesChunksToLoad) { - this.maxBytesMetadata = maxBytesChunksToLoad; - } - - /** - * @return Total maximum bytes to load from ancillary ckunks. - */ - public int getMaxBytesMetadata() { - return maxBytesMetadata; - } - - /** - * Set maximum size in bytes for individual ancillary chunks (0: unlimited; default: 2MB).
    - * Chunks exceeding this length will be skipped (the CRC will not be checked) and the chunk will be saved as a - * PngChunkSkipped object. See also setSkipChunkIds - */ - public void setSkipChunkMaxSize(int skipChunksBySize) { - this.skipChunkMaxSize = skipChunksBySize; - } - - /** - * @return maximum size in bytes for individual ancillary chunks. - */ - public int getSkipChunkMaxSize() { - return skipChunkMaxSize; - } - - /** - * Chunks ids to be skipped.
    - * These chunks will be skipped (the CRC will not be checked) and the chunk will be saved as a PngChunkSkipped - * object. See also setSkipChunkMaxSize - */ - public void setSkipChunkIds(String[] skipChunksById) { - this.skipChunkIds = skipChunksById == null ? new String[] {} : skipChunksById; - } - - /** - * @return Chunk-IDs to be skipped. - */ - public String[] getSkipChunkIds() { - return skipChunkIds; - } - - /** - * if true, input stream will be closed after ending read - *

    - * default=true - */ - public void setShouldCloseStream(boolean shouldCloseStream) { - this.shouldCloseStream = shouldCloseStream; - } - - /** - * Normally this does nothing, but it can be used to force a premature closing. Its recommended practice to call it - * after reading the image pixels. - */ - public void end() { - if (currentChunkGroup < ChunksList.CHUNK_GROUP_6_END) - close(); - } - - /** - * Interlaced PNG is accepted -though not welcomed- now... - */ - public boolean isInterlaced() { - return interlaced; - } - - /** - * set/unset "unpackedMode"
    - * If false (default) packed types (bitdepth=1,2 or 4) will keep several samples packed in one element (byte or int)
    - * If true, samples will be unpacked on reading, and each element in the scanline will be sample. This implies more - * processing and memory, but it's the most efficient option if you intend to read individual pixels.
    - * This option should only be set before start reading. - * - * @param unPackedMode - */ - public void setUnpackedMode(boolean unPackedMode) { - this.unpackedMode = unPackedMode; - } - - /** - * @see PngReader#setUnpackedMode(boolean) - */ - public boolean isUnpackedMode() { - return unpackedMode; - } - - /** - * Disables the CRC integrity check in IDAT chunks and ancillary chunks, this gives a slight increase in reading - * speed for big files - */ - public void setCrcCheckDisabled() { - crcEnabled = false; - } - - /** - * Just for testing. TO be called after ending reading, only if initCrctest() was called before start - * - * @return CRC of the raw pixels values - */ - long getCrctestVal() { - return crctest.getValue(); - } - - /** - * Inits CRC object and enables CRC calculation - */ - void initCrctest() { - this.crctest = new CRC32(); - } - - /** - * Basic info, for debugging. - */ - public String toString() { // basic info - return "filename=" + filename + " " + imgInfo.toString(); - } - -} +package jogamp.opengl.util.pngj; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.HashSet; +import java.util.zip.CRC32; +import java.util.zip.Inflater; +import java.util.zip.InflaterInputStream; + +import jogamp.opengl.util.pngj.ImageLine.SampleType; +import jogamp.opengl.util.pngj.chunks.ChunkHelper; +import jogamp.opengl.util.pngj.chunks.ChunkLoadBehaviour; +import jogamp.opengl.util.pngj.chunks.ChunkRaw; +import jogamp.opengl.util.pngj.chunks.ChunksList; +import jogamp.opengl.util.pngj.chunks.PngChunk; +import jogamp.opengl.util.pngj.chunks.PngChunkIDAT; +import jogamp.opengl.util.pngj.chunks.PngChunkIHDR; +import jogamp.opengl.util.pngj.chunks.PngChunkSkipped; +import jogamp.opengl.util.pngj.chunks.PngMetadata; + +/** + * Reads a PNG image, line by line. + *

    + * The reading sequence is as follows:
    + * 1. At construction time, the header and IHDR chunk are read (basic image + * info)
    + * 2. Afterwards you can set some additional global options. Eg. + * {@link #setUnpackedMode(boolean)}, {@link #setCrcCheckDisabled()}.
    + * 3. Optional: If you call getMetadata() or getChunksLisk() before start + * reading the rows, all the chunks before IDAT are automatically loaded and + * available
    + * 4a. The rows are read onen by one of the readRowXXX methods: + * {@link #readRowInt(int)}, {@link PngReader#readRowByte(int)}, etc, in order, + * from 0 to nrows-1 (you can skip or repeat rows, but not go backwards)
    + * 4b. Alternatively, you can read all rows, or a subset, in a single call: + * {@link #readRowsInt()}, {@link #readRowsByte()} ,etc. In general this + * consumes more memory, but for interlaced images this is equally efficient, + * and more so if reading a small subset of rows.
    + * 5. Read of the last row auyomatically loads the trailing chunks, and ends the + * reader.
    + * 6. end() forcibly finishes/aborts the reading and closes the stream + */ +public class PngReader { + + /** + * Basic image info - final and inmutable. + */ + public final ImageInfo imgInfo; + /** + * not necesarily a filename, can be a description - merely informative + */ + protected final String filename; + private ChunkLoadBehaviour chunkLoadBehaviour = ChunkLoadBehaviour.LOAD_CHUNK_ALWAYS; // see setter/getter + private boolean shouldCloseStream = true; // true: closes stream after ending - see setter/getter + // some performance/defensive limits + private long maxTotalBytesRead = 200 * 1024 * 1024; // 200MB + private int maxBytesMetadata = 5 * 1024 * 1024; // for ancillary chunks - see setter/getter + private int skipChunkMaxSize = 2 * 1024 * 1024; // chunks exceeding this size will be skipped (nor even CRC checked) + private String[] skipChunkIds = { "fdAT" }; // chunks with these ids will be skipped (nor even CRC checked) + private HashSet skipChunkIdsSet; // lazily created from skipChunksById + protected final PngMetadata metadata; // this a wrapper over chunks + protected final ChunksList chunksList; + protected ImageLine imgLine; + // line as bytes, counting from 1 (index 0 is reserved for filter type) + protected final int buffersLen; // nominal length is imgInfo.bytesPerRow + 1 but it can be larger + protected byte[] rowb = null; + protected byte[] rowbprev = null; // rowb previous + protected byte[] rowbfilter = null; // current line 'filtered': exactly as in uncompressed stream + // only set for interlaced PNG + private final boolean interlaced; + private final PngDeinterlacer deinterlacer; + private boolean crcEnabled = true; + // this only influences the 1-2-4 bitdepth format + private boolean unpackedMode = false; + private Inflater inflater = null; // can be reused among several objects. see reuseBuffersFrom() + /** + * Current chunk group, (0-6) already read or reading + *

    + * see {@link ChunksList} + */ + protected int currentChunkGroup = -1; + protected int rowNum = -1; // last read row number, starting from 0 + private long offset = 0; // offset in InputStream = bytes read + private int bytesChunksLoaded; // bytes loaded from anciallary chunks + protected final InputStream inputStream; + protected InflaterInputStream idatIstream; + protected PngIDatChunkInputStream iIdatCstream; + protected CRC32 crctest; // If set to non null, it gets a CRC of the unfiltered bytes, to check for images equality + + /** + * Constructs a PngReader from an InputStream. + *

    + * See also FileHelper.createPngReader(File f) if available. + * + * Reads only the signature and first chunk (IDHR) + * + * @param filenameOrDescription + * : Optional, can be a filename or a description. Just for + * error/debug messages + * + */ + public PngReader(InputStream inputStream, String filenameOrDescription) { + this.filename = filenameOrDescription == null ? "" : filenameOrDescription; + this.inputStream = inputStream; + this.chunksList = new ChunksList(null); + this.metadata = new PngMetadata(chunksList); + // starts reading: signature + byte[] pngid = new byte[8]; + PngHelperInternal.readBytes(inputStream, pngid, 0, pngid.length); + offset += pngid.length; + if (!Arrays.equals(pngid, PngHelperInternal.getPngIdSignature())) + throw new PngjInputException("Bad PNG signature"); + // reads first chunk + currentChunkGroup = ChunksList.CHUNK_GROUP_0_IDHR; + int clen = PngHelperInternal.readInt4(inputStream); + offset += 4; + if (clen != 13) + throw new PngjInputException("IDHR chunk len != 13 ?? " + clen); + byte[] chunkid = new byte[4]; + PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); + if (!Arrays.equals(chunkid, ChunkHelper.b_IHDR)) + throw new PngjInputException("IHDR not found as first chunk??? [" + ChunkHelper.toString(chunkid) + "]"); + offset += 4; + PngChunkIHDR ihdr = (PngChunkIHDR) readChunk(chunkid, clen, false); + boolean alpha = (ihdr.getColormodel() & 0x04) != 0; + boolean palette = (ihdr.getColormodel() & 0x01) != 0; + boolean grayscale = (ihdr.getColormodel() == 0 || ihdr.getColormodel() == 4); + // creates ImgInfo and imgLine, and allocates buffers + imgInfo = new ImageInfo(ihdr.getCols(), ihdr.getRows(), ihdr.getBitspc(), alpha, grayscale, palette); + interlaced = ihdr.getInterlaced() == 1; + deinterlacer = interlaced ? new PngDeinterlacer(imgInfo) : null; + buffersLen = imgInfo.bytesPerRow + 1; + // some checks + if (ihdr.getFilmeth() != 0 || ihdr.getCompmeth() != 0 || (ihdr.getInterlaced() & 0xFFFE) != 0) + throw new PngjInputException("compression method o filter method or interlaced unrecognized "); + if (ihdr.getColormodel() < 0 || ihdr.getColormodel() > 6 || ihdr.getColormodel() == 1 + || ihdr.getColormodel() == 5) + throw new PngjInputException("Invalid colormodel " + ihdr.getColormodel()); + if (ihdr.getBitspc() != 1 && ihdr.getBitspc() != 2 && ihdr.getBitspc() != 4 && ihdr.getBitspc() != 8 + && ihdr.getBitspc() != 16) + throw new PngjInputException("Invalid bit depth " + ihdr.getBitspc()); + } + + private boolean firstChunksNotYetRead() { + return currentChunkGroup < ChunksList.CHUNK_GROUP_1_AFTERIDHR; + } + + private void allocateBuffers() { // only if needed + if (rowbfilter == null || rowbfilter.length < buffersLen) { + rowbfilter = new byte[buffersLen]; + rowb = new byte[buffersLen]; + rowbprev = new byte[buffersLen]; + } + } + + /** + * Reads last Internally called after having read the last line. It reads + * extra chunks after IDAT, if present. + */ + private void readLastAndClose() { + // offset = iIdatCstream.getOffset(); + if (currentChunkGroup < ChunksList.CHUNK_GROUP_5_AFTERIDAT) { + try { + idatIstream.close(); + } catch (Exception e) { + } + readLastChunks(); + } + close(); + } + + private void close() { + if (currentChunkGroup < ChunksList.CHUNK_GROUP_6_END) { // this could only happen if forced close + try { + idatIstream.close(); + } catch (Exception e) { + } + currentChunkGroup = ChunksList.CHUNK_GROUP_6_END; + } + if (shouldCloseStream) { + try { + inputStream.close(); + } catch (Exception e) { + throw new PngjInputException("error closing input stream!", e); + } + } + } + + // nbytes: NOT including the filter byte. leaves result in rowb + private void unfilterRow(int nbytes) { + int ftn = rowbfilter[0]; + FilterType ft = FilterType.getByVal(ftn); + if (ft == null) + throw new PngjInputException("Filter type " + ftn + " invalid"); + switch (ft) { + case FILTER_NONE: + unfilterRowNone(nbytes); + break; + case FILTER_SUB: + unfilterRowSub(nbytes); + break; + case FILTER_UP: + unfilterRowUp(nbytes); + break; + case FILTER_AVERAGE: + unfilterRowAverage(nbytes); + break; + case FILTER_PAETH: + unfilterRowPaeth(nbytes); + break; + default: + throw new PngjInputException("Filter type " + ftn + " not implemented"); + } + if (crctest != null) + crctest.update(rowb, 1, buffersLen - 1); + } + + private void unfilterRowAverage(final int nbytes) { + int i, j, x; + for (j = 1 - imgInfo.bytesPixel, i = 1; i <= nbytes; i++, j++) { + x = j > 0 ? (rowb[j] & 0xff) : 0; + rowb[i] = (byte) (rowbfilter[i] + (x + (rowbprev[i] & 0xFF)) / 2); + } + } + + private void unfilterRowNone(final int nbytes) { + for (int i = 1; i <= nbytes; i++) { + rowb[i] = (byte) (rowbfilter[i]); + } + } + + private void unfilterRowPaeth(final int nbytes) { + int i, j, x, y; + for (j = 1 - imgInfo.bytesPixel, i = 1; i <= nbytes; i++, j++) { + x = j > 0 ? (rowb[j] & 0xFF) : 0; + y = j > 0 ? (rowbprev[j] & 0xFF) : 0; + rowb[i] = (byte) (rowbfilter[i] + PngHelperInternal.filterPaethPredictor(x, rowbprev[i] & 0xFF, y)); + } + } + + private void unfilterRowSub(final int nbytes) { + int i, j; + for (i = 1; i <= imgInfo.bytesPixel; i++) { + rowb[i] = (byte) (rowbfilter[i]); + } + for (j = 1, i = imgInfo.bytesPixel + 1; i <= nbytes; i++, j++) { + rowb[i] = (byte) (rowbfilter[i] + rowb[j]); + } + } + + private void unfilterRowUp(final int nbytes) { + for (int i = 1; i <= nbytes; i++) { + rowb[i] = (byte) (rowbfilter[i] + rowbprev[i]); + } + } + + /** + * Reads chunks before first IDAT. Normally this is called automatically + *

    + * Position before: after IDHR (crc included) Position after: just after the + * first IDAT chunk id + *

    + * This can be called several times (tentatively), it does nothing if + * already run + *

    + * (Note: when should this be called? in the constructor? hardly, because we + * loose the opportunity to call setChunkLoadBehaviour() and perhaps other + * settings before reading the first row? but sometimes we want to access + * some metadata (plte, phys) before. Because of this, this method can be + * called explicitly but is also called implicititly in some methods + * (getMetatada(), getChunksList()) + */ + private final void readFirstChunks() { + if (!firstChunksNotYetRead()) + return; + int clen = 0; + boolean found = false; + byte[] chunkid = new byte[4]; // it's important to reallocate in each iteration + currentChunkGroup = ChunksList.CHUNK_GROUP_1_AFTERIDHR; + while (!found) { + clen = PngHelperInternal.readInt4(inputStream); + offset += 4; + if (clen < 0) + break; + PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); + offset += 4; + if (Arrays.equals(chunkid, ChunkHelper.b_IDAT)) { + found = true; + currentChunkGroup = ChunksList.CHUNK_GROUP_4_IDAT; + // add dummy idat chunk to list + chunksList.appendReadChunk(new PngChunkIDAT(imgInfo, clen, offset - 8), currentChunkGroup); + break; + } else if (Arrays.equals(chunkid, ChunkHelper.b_IEND)) { + throw new PngjInputException("END chunk found before image data (IDAT) at offset=" + offset); + } + if (Arrays.equals(chunkid, ChunkHelper.b_PLTE)) + currentChunkGroup = ChunksList.CHUNK_GROUP_2_PLTE; + readChunk(chunkid, clen, false); + if (Arrays.equals(chunkid, ChunkHelper.b_PLTE)) + currentChunkGroup = ChunksList.CHUNK_GROUP_3_AFTERPLTE; + } + int idatLen = found ? clen : -1; + if (idatLen < 0) + throw new PngjInputException("first idat chunk not found!"); + iIdatCstream = new PngIDatChunkInputStream(inputStream, idatLen, offset); + if(inflater == null) { + inflater = new Inflater(); + } else { + inflater.reset(); + } + idatIstream = new InflaterInputStream(iIdatCstream, inflater); + if (!crcEnabled) + iIdatCstream.disableCrcCheck(); + } + + /** + * Reads (and processes) chunks after last IDAT. + **/ + void readLastChunks() { + // PngHelper.logdebug("idat ended? " + iIdatCstream.isEnded()); + currentChunkGroup = ChunksList.CHUNK_GROUP_5_AFTERIDAT; + if (!iIdatCstream.isEnded()) + iIdatCstream.forceChunkEnd(); + int clen = iIdatCstream.getLenLastChunk(); + byte[] chunkid = iIdatCstream.getIdLastChunk(); + boolean endfound = false; + boolean first = true; + boolean skip = false; + while (!endfound) { + skip = false; + if (!first) { + clen = PngHelperInternal.readInt4(inputStream); + offset += 4; + if (clen < 0) + throw new PngjInputException("bad chuck len " + clen); + PngHelperInternal.readBytes(inputStream, chunkid, 0, 4); + offset += 4; + } + first = false; + if (Arrays.equals(chunkid, ChunkHelper.b_IDAT)) { + skip = true; // extra dummy (empty?) idat chunk, it can happen, ignore it + } else if (Arrays.equals(chunkid, ChunkHelper.b_IEND)) { + currentChunkGroup = ChunksList.CHUNK_GROUP_6_END; + endfound = true; + } + readChunk(chunkid, clen, skip); + } + if (!endfound) + throw new PngjInputException("end chunk not found - offset=" + offset); + // PngHelper.logdebug("end chunk found ok offset=" + offset); + } + + /** + * Reads chunkd from input stream, adds to ChunksList, and returns it. If + * it's skipped, a PngChunkSkipped object is created + */ + private PngChunk readChunk(byte[] chunkid, int clen, boolean skipforced) { + if (clen < 0) + throw new PngjInputException("invalid chunk lenght: " + clen); + // skipChunksByIdSet is created lazyly, if fist IHDR has already been read + if (skipChunkIdsSet == null && currentChunkGroup > ChunksList.CHUNK_GROUP_0_IDHR) + skipChunkIdsSet = new HashSet(Arrays.asList(skipChunkIds)); + String chunkidstr = ChunkHelper.toString(chunkid); + boolean critical = ChunkHelper.isCritical(chunkidstr); + PngChunk pngChunk = null; + boolean skip = skipforced; + if (maxTotalBytesRead > 0 && clen + offset > maxTotalBytesRead) + throw new PngjInputException("Maximum total bytes to read exceeeded: " + maxTotalBytesRead + " offset:" + + offset + " clen=" + clen); + // an ancillary chunks can be skipped because of several reasons: + if (currentChunkGroup > ChunksList.CHUNK_GROUP_0_IDHR && !critical) + skip = skip || (skipChunkMaxSize > 0 && clen >= skipChunkMaxSize) || skipChunkIdsSet.contains(chunkidstr) + || (maxBytesMetadata > 0 && clen > maxBytesMetadata - bytesChunksLoaded) + || !ChunkHelper.shouldLoad(chunkidstr, chunkLoadBehaviour); + if (skip) { + PngHelperInternal.skipBytes(inputStream, clen); + PngHelperInternal.readInt4(inputStream); // skip - we dont call PngHelperInternal.skipBytes(inputStream, + // clen + 4) for risk of overflow + pngChunk = new PngChunkSkipped(chunkidstr, imgInfo, clen); + } else { + ChunkRaw chunk = new ChunkRaw(clen, chunkid, true); + chunk.readChunkData(inputStream, crcEnabled || critical); + pngChunk = PngChunk.factory(chunk, imgInfo); + if (!pngChunk.crit) + bytesChunksLoaded += chunk.len; + } + pngChunk.setOffset(offset - 8L); + chunksList.appendReadChunk(pngChunk, currentChunkGroup); + offset += clen + 4L; + return pngChunk; + } + + /** + * Logs/prints a warning. + *

    + * The default behaviour is print to stderr, but it can be overriden. + *

    + * This happens rarely - most errors are fatal. + */ + protected void logWarn(String warn) { + System.err.println(warn); + } + + /** + * @see #setChunkLoadBehaviour(ChunkLoadBehaviour) + */ + public ChunkLoadBehaviour getChunkLoadBehaviour() { + return chunkLoadBehaviour; + } + + /** + * Determines which ancillary chunks (metada) are to be loaded + * + * @param chunkLoadBehaviour + * {@link ChunkLoadBehaviour} + */ + public void setChunkLoadBehaviour(ChunkLoadBehaviour chunkLoadBehaviour) { + this.chunkLoadBehaviour = chunkLoadBehaviour; + } + + /** + * All loaded chunks (metada). If we have not yet end reading the image, + * this will include only the chunks before the pixels data (IDAT) + *

    + * Critical chunks are included, except that all IDAT chunks appearance are + * replaced by a single dummy-marker IDAT chunk. These might be copied to + * the PngWriter + *

    + * + * @see #getMetadata() + */ + public ChunksList getChunksList() { + if (firstChunksNotYetRead()) + readFirstChunks(); + return chunksList; + } + + int getCurrentChunkGroup() { + return currentChunkGroup; + } + + /** + * High level wrapper over chunksList + * + * @see #getChunksList() + */ + public PngMetadata getMetadata() { + if (firstChunksNotYetRead()) + readFirstChunks(); + return metadata; + } + + /** + * If called for first time, calls readRowInt. Elsewhere, it calls the + * appropiate readRowInt/readRowByte + *

    + * In general, specifying the concrete readRowInt/readRowByte is preferrable + * + * @see #readRowInt(int) {@link #readRowByte(int)} + */ + public ImageLine readRow(int nrow) { + if (imgLine == null) + imgLine = new ImageLine(imgInfo, SampleType.INT, unpackedMode); + return imgLine.sampleType != SampleType.BYTE ? readRowInt(nrow) : readRowByte(nrow); + } + + /** + * Reads the row as INT, storing it in the {@link #imgLine} property and + * returning it. + * + * The row must be greater or equal than the last read row. + * + * @param nrow + * Row number, from 0 to rows-1. Increasing order. + * @return ImageLine object, also available as field. Data is in + * {@link ImageLine#scanline} (int) field. + */ + public ImageLine readRowInt(int nrow) { + if (imgLine == null) + imgLine = new ImageLine(imgInfo, SampleType.INT, unpackedMode); + if (imgLine.getRown() == nrow) // already read + return imgLine; + readRowInt(imgLine.scanline, nrow); + imgLine.setFilterUsed(FilterType.getByVal(rowbfilter[0])); + imgLine.setRown(nrow); + return imgLine; + } + + /** + * Reads the row as BYTES, storing it in the {@link #imgLine} property and + * returning it. + * + * The row must be greater or equal than the last read row. This method + * allows to pass the same row that was last read. + * + * @param nrow + * Row number, from 0 to rows-1. Increasing order. + * @return ImageLine object, also available as field. Data is in + * {@link ImageLine#scanlineb} (byte) field. + */ + public ImageLine readRowByte(int nrow) { + if (imgLine == null) + imgLine = new ImageLine(imgInfo, SampleType.BYTE, unpackedMode); + if (imgLine.getRown() == nrow) // already read + return imgLine; + readRowByte(imgLine.scanlineb, nrow); + imgLine.setFilterUsed(FilterType.getByVal(rowbfilter[0])); + imgLine.setRown(nrow); + return imgLine; + } + + /** + * @see #readRowInt(int[], int) + */ + public final int[] readRow(int[] buffer, final int nrow) { + return readRowInt(buffer, nrow); + } + + /** + * Reads a line and returns it as a int[] array. + *

    + * You can pass (optionally) a prealocatted buffer. + *

    + * If the bitdepth is less than 8, the bytes are packed - unless + * {@link #unpackedMode} is true. + * + * @param buffer + * Prealocated buffer, or null. + * @param nrow + * Row number (0 is top). Most be strictly greater than the last + * read row. + * + * @return The scanline in the same passwd buffer if it was allocated, a + * newly allocated one otherwise + */ + public final int[] readRowInt(int[] buffer, final int nrow) { + if (buffer == null) + buffer = new int[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + if (!interlaced) { + if (nrow <= rowNum) + throw new PngjInputException("rows must be read in increasing order: " + nrow); + int bytesread = 0; + while (rowNum < nrow) + bytesread = readRowRaw(rowNum + 1); // read rows, perhaps skipping if necessary + decodeLastReadRowToInt(buffer, bytesread); + } else { // interlaced + if (deinterlacer.getImageInt() == null) + deinterlacer.setImageInt(readRowsInt().scanlines); // read all image and store it in deinterlacer + System.arraycopy(deinterlacer.getImageInt()[nrow], 0, buffer, 0, unpackedMode ? imgInfo.samplesPerRow + : imgInfo.samplesPerRowPacked); + } + return buffer; + } + + /** + * Reads a line and returns it as a byte[] array. + *

    + * You can pass (optionally) a prealocatted buffer. + *

    + * If the bitdepth is less than 8, the bytes are packed - unless + * {@link #unpackedMode} is true.
    + * If the bitdepth is 16, the least significant byte is lost. + *

    + * + * @param buffer + * Prealocated buffer, or null. + * @param nrow + * Row number (0 is top). Most be strictly greater than the last + * read row. + * + * @return The scanline in the same passwd buffer if it was allocated, a + * newly allocated one otherwise + */ + public final byte[] readRowByte(byte[] buffer, final int nrow) { + if (buffer == null) + buffer = new byte[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + if (!interlaced) { + if (nrow <= rowNum) + throw new PngjInputException("rows must be read in increasing order: " + nrow); + int bytesread = 0; + while (rowNum < nrow) + bytesread = readRowRaw(rowNum + 1); // read rows, perhaps skipping if necessary + decodeLastReadRowToByte(buffer, bytesread); + } else { // interlaced + if (deinterlacer.getImageByte() == null) + deinterlacer.setImageByte(readRowsByte().scanlinesb); // read all image and store it in deinterlacer + System.arraycopy(deinterlacer.getImageByte()[nrow], 0, buffer, 0, unpackedMode ? imgInfo.samplesPerRow + : imgInfo.samplesPerRowPacked); + } + return buffer; + } + + /** + * @param nrow + * @deprecated Now {@link #readRow(int)} implements the same funcion. This + * method will be removed in future releases + */ + public ImageLine getRow(int nrow) { + return readRow(nrow); + } + + private void decodeLastReadRowToInt(int[] buffer, int bytesRead) { + if (imgInfo.bitDepth <= 8) + for (int i = 0, j = 1; i < bytesRead; i++) + buffer[i] = (rowb[j++] & 0xFF); // http://www.libpng.org/pub/png/spec/1.2/PNG-DataRep.html + else + for (int i = 0, j = 1; j <= bytesRead; i++) + buffer[i] = ((rowb[j++] & 0xFF) << 8) + (rowb[j++] & 0xFF); // 16 bitspc + if (imgInfo.packed && unpackedMode) + ImageLine.unpackInplaceInt(imgInfo, buffer, buffer, false); + } + + private void decodeLastReadRowToByte(byte[] buffer, int bytesRead) { + if (imgInfo.bitDepth <= 8) + System.arraycopy(rowb, 1, buffer, 0, bytesRead); + else + for (int i = 0, j = 1; j < bytesRead; i++, j += 2) + buffer[i] = rowb[j];// 16 bits in 1 byte: this discards the LSB!!! + if (imgInfo.packed && unpackedMode) + ImageLine.unpackInplaceByte(imgInfo, buffer, buffer, false); + } + + /** + * Reads a set of lines and returns it as a ImageLines object, which wraps + * matrix. Internally it reads all lines, but decodes and stores only the + * wanted ones. This starts and ends the reading, and cannot be combined + * with other reading methods. + *

    + * This it's more efficient (speed an memory) that doing calling + * readRowInt() for each desired line only if the image is interlaced. + *

    + * Notice that the columns in the matrix is not the pixel width of the + * image, but rather pixels x channels + * + * @see #readRowInt(int) to read about the format of each row + * + * @param rowOffset + * Number of rows to be skipped + * @param nRows + * Total number of rows to be read. -1: read all available + * @param rowStep + * Row increment. If 1, we read consecutive lines; if 2, we read + * even/odd lines, etc + * @return Set of lines as a ImageLines, which wraps a matrix + */ + public ImageLines readRowsInt(int rowOffset, int nRows, int rowStep) { + if (nRows < 0) + nRows = (imgInfo.rows - rowOffset) / rowStep; + if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > imgInfo.rows) + throw new PngjInputException("bad args"); + ImageLines imlines = new ImageLines(imgInfo, SampleType.INT, unpackedMode, rowOffset, nRows, rowStep); + if (!interlaced) { + for (int j = 0; j < imgInfo.rows; j++) { + int bytesread = readRowRaw(j); // read and perhaps discards + int mrow = imlines.imageRowToMatrixRowStrict(j); + if (mrow >= 0) + decodeLastReadRowToInt(imlines.scanlines[mrow], bytesread); + } + } else { // and now, for something completely different (interlaced) + int[] buf = new int[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + for (int p = 1; p <= 7; p++) { + deinterlacer.setPass(p); + for (int i = 0; i < deinterlacer.getRows(); i++) { + int bytesread = readRowRaw(i); + int j = deinterlacer.getCurrRowReal(); + int mrow = imlines.imageRowToMatrixRowStrict(j); + if (mrow >= 0) { + decodeLastReadRowToInt(buf, bytesread); + deinterlacer.deinterlaceInt(buf, imlines.scanlines[mrow], !unpackedMode); + } + } + } + } + end(); + return imlines; + } + + /** + * Same as readRowsInt(0, imgInfo.rows, 1) + * + * @see #readRowsInt(int, int, int) + */ + public ImageLines readRowsInt() { + return readRowsInt(0, imgInfo.rows, 1); + } + + /** + * Reads a set of lines and returns it as a ImageLines object, which wrapas + * a byte[][] matrix. Internally it reads all lines, but decodes and stores + * only the wanted ones. This starts and ends the reading, and cannot be + * combined with other reading methods. + *

    + * This it's more efficient (speed an memory) that doing calling + * readRowByte() for each desired line only if the image is interlaced. + *

    + * Notice that the columns in the matrix is not the pixel width of the + * image, but rather pixels x channels + * + * @see #readRowByte(int) to read about the format of each row. Notice that + * if the bitdepth is 16 this will lose information + * + * @param rowOffset + * Number of rows to be skipped + * @param nRows + * Total number of rows to be read. -1: read all available + * @param rowStep + * Row increment. If 1, we read consecutive lines; if 2, we read + * even/odd lines, etc + * @return Set of lines as a matrix + */ + public ImageLines readRowsByte(int rowOffset, int nRows, int rowStep) { + if (nRows < 0) + nRows = (imgInfo.rows - rowOffset) / rowStep; + if (rowStep < 1 || rowOffset < 0 || nRows * rowStep + rowOffset > imgInfo.rows) + throw new PngjInputException("bad args"); + ImageLines imlines = new ImageLines(imgInfo, SampleType.BYTE, unpackedMode, rowOffset, nRows, rowStep); + if (!interlaced) { + for (int j = 0; j < imgInfo.rows; j++) { + int bytesread = readRowRaw(j); // read and perhaps discards + int mrow = imlines.imageRowToMatrixRowStrict(j); + if (mrow >= 0) + decodeLastReadRowToByte(imlines.scanlinesb[mrow], bytesread); + } + } else { // and now, for something completely different (interlaced) + byte[] buf = new byte[unpackedMode ? imgInfo.samplesPerRow : imgInfo.samplesPerRowPacked]; + for (int p = 1; p <= 7; p++) { + deinterlacer.setPass(p); + for (int i = 0; i < deinterlacer.getRows(); i++) { + int bytesread = readRowRaw(i); + int j = deinterlacer.getCurrRowReal(); + int mrow = imlines.imageRowToMatrixRowStrict(j); + if (mrow >= 0) { + decodeLastReadRowToByte(buf, bytesread); + deinterlacer.deinterlaceByte(buf, imlines.scanlinesb[mrow], !unpackedMode); + } + } + } + } + end(); + return imlines; + } + + /** + * Same as readRowsByte(0, imgInfo.rows, 1) + * + * @see #readRowsByte(int, int, int) + */ + public ImageLines readRowsByte() { + return readRowsByte(0, imgInfo.rows, 1); + } + + /* + * For the interlaced case, nrow indicates the subsampled image - the pass must be set already. + * + * This must be called in strict order, both for interlaced or no interlaced. + * + * Updates rowNum. + * + * Leaves raw result in rowb + * + * Returns bytes actually read (not including the filter byte) + */ + private int readRowRaw(final int nrow) { + if (nrow == 0) { + if (firstChunksNotYetRead()) + readFirstChunks(); + allocateBuffers(); + if (interlaced) + Arrays.fill(rowb, (byte) 0); // new subimage: reset filters: this is enough, see the swap that happens lines + } + // below + int bytesRead = imgInfo.bytesPerRow; // NOT including the filter byte + if (interlaced) { + if (nrow < 0 || nrow > deinterlacer.getRows() || (nrow != 0 && nrow != deinterlacer.getCurrRowSubimg() + 1)) + throw new PngjInputException("invalid row in interlaced mode: " + nrow); + deinterlacer.setRow(nrow); + bytesRead = (imgInfo.bitspPixel * deinterlacer.getPixelsToRead() + 7) / 8; + if (bytesRead < 1) + throw new PngjExceptionInternal("wtf??"); + } else { // check for non interlaced + if (nrow < 0 || nrow >= imgInfo.rows || nrow != rowNum + 1) + throw new PngjInputException("invalid row: " + nrow); + } + rowNum = nrow; + // swap buffers + byte[] tmp = rowb; + rowb = rowbprev; + rowbprev = tmp; + // loads in rowbfilter "raw" bytes, with filter + PngHelperInternal.readBytes(idatIstream, rowbfilter, 0, bytesRead + 1); + offset = iIdatCstream.getOffset(); + if (offset < 0) + throw new PngjExceptionInternal("bad offset ??" + offset); + if (maxTotalBytesRead > 0 && offset >= maxTotalBytesRead) + throw new PngjInputException("Reading IDAT: Maximum total bytes to read exceeeded: " + maxTotalBytesRead + + " offset:" + offset); + rowb[0] = 0; + unfilterRow(bytesRead); + rowb[0] = rowbfilter[0]; + if ((rowNum == imgInfo.rows - 1 && !interlaced) || (interlaced && deinterlacer.isAtLastRow())) + readLastAndClose(); + return bytesRead; + } + + /** + * Reads all the (remaining) file, skipping the pixels data. This is much + * more efficient that calling readRow(), specially for big files (about 10 + * times faster!), because it doesn't even decompress the IDAT stream and + * disables CRC check Use this if you are not interested in reading + * pixels,only metadata. + */ + public void readSkippingAllRows() { + if (firstChunksNotYetRead()) + readFirstChunks(); + // we read directly from the compressed stream, we dont decompress nor chec CRC + iIdatCstream.disableCrcCheck(); + allocateBuffers(); + try { + int r; + do { + r = iIdatCstream.read(rowbfilter, 0, buffersLen); + } while (r >= 0); + } catch (IOException e) { + throw new PngjInputException("error in raw read of IDAT", e); + } + offset = iIdatCstream.getOffset(); + if (offset < 0) + throw new PngjExceptionInternal("bad offset ??" + offset); + if (maxTotalBytesRead > 0 && offset >= maxTotalBytesRead) + throw new PngjInputException("Reading IDAT: Maximum total bytes to read exceeeded: " + maxTotalBytesRead + + " offset:" + offset); + readLastAndClose(); + } + + /** + * Set total maximum bytes to read (0: unlimited; default: 200MB).
    + * These are the bytes read (not loaded) in the input stream. If exceeded, + * an exception will be thrown. + */ + public void setMaxTotalBytesRead(long maxTotalBytesToRead) { + this.maxTotalBytesRead = maxTotalBytesToRead; + } + + /** + * @return Total maximum bytes to read. + */ + public long getMaxTotalBytesRead() { + return maxTotalBytesRead; + } + + /** + * Set total maximum bytes to load from ancillary chunks (0: unlimited; + * default: 5Mb).
    + * If exceeded, some chunks will be skipped + */ + public void setMaxBytesMetadata(int maxBytesChunksToLoad) { + this.maxBytesMetadata = maxBytesChunksToLoad; + } + + /** + * @return Total maximum bytes to load from ancillary ckunks. + */ + public int getMaxBytesMetadata() { + return maxBytesMetadata; + } + + /** + * Set maximum size in bytes for individual ancillary chunks (0: unlimited; + * default: 2MB).
    + * Chunks exceeding this length will be skipped (the CRC will not be + * checked) and the chunk will be saved as a PngChunkSkipped object. See + * also setSkipChunkIds + */ + public void setSkipChunkMaxSize(int skipChunksBySize) { + this.skipChunkMaxSize = skipChunksBySize; + } + + /** + * @return maximum size in bytes for individual ancillary chunks. + */ + public int getSkipChunkMaxSize() { + return skipChunkMaxSize; + } + + /** + * Chunks ids to be skipped.
    + * These chunks will be skipped (the CRC will not be checked) and the chunk + * will be saved as a PngChunkSkipped object. See also setSkipChunkMaxSize + */ + public void setSkipChunkIds(String[] skipChunksById) { + this.skipChunkIds = skipChunksById == null ? new String[] {} : skipChunksById; + } + + /** + * @return Chunk-IDs to be skipped. + */ + public String[] getSkipChunkIds() { + return skipChunkIds; + } + + /** + * if true, input stream will be closed after ending read + *

    + * default=true + */ + public void setShouldCloseStream(boolean shouldCloseStream) { + this.shouldCloseStream = shouldCloseStream; + } + + /** + * Normally this does nothing, but it can be used to force a premature + * closing. Its recommended practice to call it after reading the image + * pixels. + */ + public void end() { + if (currentChunkGroup < ChunksList.CHUNK_GROUP_6_END) + close(); + } + + /** + * Interlaced PNG is accepted -though not welcomed- now... + */ + public boolean isInterlaced() { + return interlaced; + } + + /** + * set/unset "unpackedMode"
    + * If false (default) packed types (bitdepth=1,2 or 4) will keep several + * samples packed in one element (byte or int)
    + * If true, samples will be unpacked on reading, and each element in the + * scanline will be sample. This implies more processing and memory, but + * it's the most efficient option if you intend to read individual pixels.
    + * This option should only be set before start reading. + * + * @param unPackedMode + */ + public void setUnpackedMode(boolean unPackedMode) { + this.unpackedMode = unPackedMode; + } + + /** + * @see PngReader#setUnpackedMode(boolean) + */ + public boolean isUnpackedMode() { + return unpackedMode; + } + + /** + * Tries to reuse the allocated buffers from other already used PngReader + * object. This will have no effect if the buffers are smaller than necessary. + * It also reuses the inflater. + * + * @param other A PngReader that has already finished reading pixels. Can be null. + */ + public void reuseBuffersFrom(PngReader other) { + if(other==null) return; + if (other.currentChunkGroup < ChunksList.CHUNK_GROUP_5_AFTERIDAT) + throw new PngjInputException("PngReader to be reused have not yet ended reading pixels"); + if (other.rowbfilter != null && other.rowbfilter.length >= buffersLen) { + rowbfilter = other.rowbfilter; + rowb = other.rowb; + rowbprev = other.rowbprev; + } + inflater = other.inflater; + } + + /** + * Disables the CRC integrity check in IDAT chunks and ancillary chunks, + * this gives a slight increase in reading speed for big files + */ + public void setCrcCheckDisabled() { + crcEnabled = false; + } + + /** + * Just for testing. TO be called after ending reading, only if + * initCrctest() was called before start + * + * @return CRC of the raw pixels values + */ + long getCrctestVal() { + return crctest.getValue(); + } + + /** + * Inits CRC object and enables CRC calculation + */ + void initCrctest() { + this.crctest = new CRC32(); + } + + /** + * Basic info, for debugging. + */ + public String toString() { // basic info + return "filename=" + filename + " " + imgInfo.toString(); + } +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java index ed091d35a..a995e4481 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/ChunkHelper.java @@ -1,253 +1,297 @@ -package jogamp.opengl.util.pngj.chunks; - -// see http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html -// http://www.w3.org/TR/PNG/#5Chunk-naming-conventions -// http://www.w3.org/TR/PNG/#table53 -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.zip.DeflaterOutputStream; -import java.util.zip.InflaterInputStream; - -import jogamp.opengl.util.pngj.PngHelperInternal; -import jogamp.opengl.util.pngj.PngjException; - - -public class ChunkHelper { - public static final String IHDR = "IHDR"; - public static final String PLTE = "PLTE"; - public static final String IDAT = "IDAT"; - public static final String IEND = "IEND"; - public static final byte[] b_IHDR = toBytes(IHDR); - public static final byte[] b_PLTE = toBytes(PLTE); - public static final byte[] b_IDAT = toBytes(IDAT); - public static final byte[] b_IEND = toBytes(IEND); - - public static final String cHRM = "cHRM"; - public static final String gAMA = "gAMA"; - public static final String iCCP = "iCCP"; - public static final String sBIT = "sBIT"; - public static final String sRGB = "sRGB"; - public static final String bKGD = "bKGD"; - public static final String hIST = "hIST"; - public static final String tRNS = "tRNS"; - public static final String pHYs = "pHYs"; - public static final String sPLT = "sPLT"; - public static final String tIME = "tIME"; - public static final String iTXt = "iTXt"; - public static final String tEXt = "tEXt"; - public static final String zTXt = "zTXt"; - - /** - * Converts to bytes using Latin1 (ISO-8859-1) - */ - public static byte[] toBytes(String x) { - return x.getBytes(PngHelperInternal.charsetLatin1); - } - - /** - * Converts to String using Latin1 (ISO-8859-1) - */ - public static String toString(byte[] x) { - return new String(x, PngHelperInternal.charsetLatin1); - } - - /** - * Converts to String using Latin1 (ISO-8859-1) - */ - public static String toString(byte[] x, int offset, int len) { - return new String(x, offset, len, PngHelperInternal.charsetLatin1); - } - - /** - * Converts to bytes using UTF-8 - */ - public static byte[] toBytesUTF8(String x) { - return x.getBytes(PngHelperInternal.charsetUTF8); - } - - /** - * Converts to string using UTF-8 - */ - public static String toStringUTF8(byte[] x) { - return new String(x, PngHelperInternal.charsetUTF8); - } - - /** - * Converts to string using UTF-8 - */ - public static String toStringUTF8(byte[] x, int offset, int len) { - return new String(x, offset, len, PngHelperInternal.charsetUTF8); - } - - /** - * critical chunk : first letter is uppercase - */ - public static boolean isCritical(String id) { - return (Character.isUpperCase(id.charAt(0))); - } - - /** - * public chunk: second letter is uppercase - */ - public static boolean isPublic(String id) { // - return (Character.isUpperCase(id.charAt(1))); - } - - /** - * Safe to copy chunk: fourth letter is lower case - */ - public static boolean isSafeToCopy(String id) { - return (!Character.isUpperCase(id.charAt(3))); - } - - /** - * "Unknown" just means that our chunk factory (even when it has been augmented by client code) did not recognize - * its id - */ - public static boolean isUnknown(PngChunk c) { - return c instanceof PngChunkUNKNOWN; - } - - /** - * Finds position of null byte in array - * - * @param b - * @return -1 if not found - */ - public static int posNullByte(byte[] b) { - for (int i = 0; i < b.length; i++) - if (b[i] == 0) - return i; - return -1; - } - - /** - * Decides if a chunk should be loaded, according to a ChunkLoadBehaviour - * - * @param id - * @param behav - * @return true/false - */ - public static boolean shouldLoad(String id, ChunkLoadBehaviour behav) { - if (isCritical(id)) - return true; - boolean kwown = PngChunk.isKnown(id); - switch (behav) { - case LOAD_CHUNK_ALWAYS: - return true; - case LOAD_CHUNK_IF_SAFE: - return kwown || isSafeToCopy(id); - case LOAD_CHUNK_KNOWN: - return kwown; - case LOAD_CHUNK_NEVER: - return false; - } - return false; // should not reach here - } - - public final static byte[] compressBytes(byte[] ori, boolean compress) { - return compressBytes(ori, 0, ori.length, compress); - } - - public static byte[] compressBytes(byte[] ori, int offset, int len, boolean compress) { - try { - ByteArrayInputStream inb = new ByteArrayInputStream(ori, offset, len); - InputStream in = compress ? inb : new InflaterInputStream(inb); - ByteArrayOutputStream outb = new ByteArrayOutputStream(); - OutputStream out = compress ? new DeflaterOutputStream(outb) : outb; - shovelInToOut(in, out); - in.close(); - out.close(); - return outb.toByteArray(); - } catch (Exception e) { - throw new PngjException(e); - } - } - - /** - * Shovels all data from an input stream to an output stream. - */ - private static void shovelInToOut(InputStream in, OutputStream out) throws IOException { - byte[] buffer = new byte[1024]; - int len; - while ((len = in.read(buffer)) > 0) { - out.write(buffer, 0, len); - } - } - - public static boolean maskMatch(int v, int mask) { - return (v & mask) != 0; - } - - /** - * Returns only the chunks that "match" the predicate - * - * See also trimList() - */ - public static List filterList(List target, ChunkPredicate predicateKeep) { - List result = new ArrayList(); - for (PngChunk element : target) { - if (predicateKeep.match(element)) { - result.add(element); - } - } - return result; - } - - /** - * Remove (in place) the chunks that "match" the predicate - * - * See also filterList - */ - public static int trimList(List target, ChunkPredicate predicateRemove) { - Iterator it = target.iterator(); - int cont = 0; - while (it.hasNext()) { - PngChunk c = it.next(); - if (predicateRemove.match(c)) { - it.remove(); - cont++; - } - } - return cont; - } - - /** - * MY adhoc criteria: two chunks are "equivalent" ("practically equal") if they have same id and (perhaps, if - * multiple are allowed) if the match also in some "internal key" (eg: key for string values, palette for sPLT, etc) - * - * Notice that the use of this is optional, and that the PNG standard allows Text chunks that have same key - * - * @return true if "equivalent" - */ - public static final boolean equivalent(PngChunk c1, PngChunk c2) { - if (c1 == c2) - return true; - if (c1 == null || c2 == null || !c1.id.equals(c2.id)) - return false; - // same id - if (c1.getClass() != c2.getClass()) - return false; // should not happen - if (!c2.allowsMultiple()) - return true; - if (c1 instanceof PngChunkTextVar) { - return ((PngChunkTextVar) c1).getKey().equals(((PngChunkTextVar) c2).getKey()); - } - if (c1 instanceof PngChunkSPLT) { - return ((PngChunkSPLT) c1).getPalName().equals(((PngChunkSPLT) c2).getPalName()); - } - // unknown chunks that allow multiple? consider they don't match - return false; - } - - public static boolean isText(PngChunk c) { - return c instanceof PngChunkTextVar; - } - -} +package jogamp.opengl.util.pngj.chunks; + + +// see http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html +// http://www.w3.org/TR/PNG/#5Chunk-naming-conventions +// http://www.w3.org/TR/PNG/#table53 +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.zip.Deflater; +import java.util.zip.DeflaterOutputStream; +import java.util.zip.Inflater; +import java.util.zip.InflaterInputStream; + +import jogamp.opengl.util.pngj.PngHelperInternal; +import jogamp.opengl.util.pngj.PngjException; + + +public class ChunkHelper { + public static final String IHDR = "IHDR"; + public static final String PLTE = "PLTE"; + public static final String IDAT = "IDAT"; + public static final String IEND = "IEND"; + public static final byte[] b_IHDR = toBytes(IHDR); + public static final byte[] b_PLTE = toBytes(PLTE); + public static final byte[] b_IDAT = toBytes(IDAT); + public static final byte[] b_IEND = toBytes(IEND); + + public static final String cHRM = "cHRM"; + public static final String gAMA = "gAMA"; + public static final String iCCP = "iCCP"; + public static final String sBIT = "sBIT"; + public static final String sRGB = "sRGB"; + public static final String bKGD = "bKGD"; + public static final String hIST = "hIST"; + public static final String tRNS = "tRNS"; + public static final String pHYs = "pHYs"; + public static final String sPLT = "sPLT"; + public static final String tIME = "tIME"; + public static final String iTXt = "iTXt"; + public static final String tEXt = "tEXt"; + public static final String zTXt = "zTXt"; + + private static final ThreadLocal inflaterProvider = new ThreadLocal() { + protected Inflater initialValue() { + return new Inflater(); + } + }; + + private static final ThreadLocal deflaterProvider = new ThreadLocal() { + protected Deflater initialValue() { + return new Deflater(); + } + }; + + /* + * static auxiliary buffer. any method that uses this should synchronize against this + */ + private static byte[] tmpbuffer = new byte[4096]; + + /** + * Converts to bytes using Latin1 (ISO-8859-1) + */ + public static byte[] toBytes(String x) { + return x.getBytes(PngHelperInternal.charsetLatin1); + } + + /** + * Converts to String using Latin1 (ISO-8859-1) + */ + public static String toString(byte[] x) { + return new String(x, PngHelperInternal.charsetLatin1); + } + + /** + * Converts to String using Latin1 (ISO-8859-1) + */ + public static String toString(byte[] x, int offset, int len) { + return new String(x, offset, len, PngHelperInternal.charsetLatin1); + } + + /** + * Converts to bytes using UTF-8 + */ + public static byte[] toBytesUTF8(String x) { + return x.getBytes(PngHelperInternal.charsetUTF8); + } + + /** + * Converts to string using UTF-8 + */ + public static String toStringUTF8(byte[] x) { + return new String(x, PngHelperInternal.charsetUTF8); + } + + /** + * Converts to string using UTF-8 + */ + public static String toStringUTF8(byte[] x, int offset, int len) { + return new String(x, offset, len, PngHelperInternal.charsetUTF8); + } + + /** + * critical chunk : first letter is uppercase + */ + public static boolean isCritical(String id) { + return (Character.isUpperCase(id.charAt(0))); + } + + /** + * public chunk: second letter is uppercase + */ + public static boolean isPublic(String id) { // + return (Character.isUpperCase(id.charAt(1))); + } + + /** + * Safe to copy chunk: fourth letter is lower case + */ + public static boolean isSafeToCopy(String id) { + return (!Character.isUpperCase(id.charAt(3))); + } + + /** + * "Unknown" just means that our chunk factory (even when it has been + * augmented by client code) did not recognize its id + */ + public static boolean isUnknown(PngChunk c) { + return c instanceof PngChunkUNKNOWN; + } + + /** + * Finds position of null byte in array + * + * @param b + * @return -1 if not found + */ + public static int posNullByte(byte[] b) { + for (int i = 0; i < b.length; i++) + if (b[i] == 0) + return i; + return -1; + } + + /** + * Decides if a chunk should be loaded, according to a ChunkLoadBehaviour + * + * @param id + * @param behav + * @return true/false + */ + public static boolean shouldLoad(String id, ChunkLoadBehaviour behav) { + if (isCritical(id)) + return true; + boolean kwown = PngChunk.isKnown(id); + switch (behav) { + case LOAD_CHUNK_ALWAYS: + return true; + case LOAD_CHUNK_IF_SAFE: + return kwown || isSafeToCopy(id); + case LOAD_CHUNK_KNOWN: + return kwown; + case LOAD_CHUNK_NEVER: + return false; + } + return false; // should not reach here + } + + public final static byte[] compressBytes(byte[] ori, boolean compress) { + return compressBytes(ori, 0, ori.length, compress); + } + + public static byte[] compressBytes(byte[] ori, int offset, int len, boolean compress) { + try { + ByteArrayInputStream inb = new ByteArrayInputStream(ori, offset, len); + InputStream in = compress ? inb : new InflaterInputStream(inb, getInflater()); + ByteArrayOutputStream outb = new ByteArrayOutputStream(); + OutputStream out = compress ? new DeflaterOutputStream(outb) : outb; + shovelInToOut(in, out); + in.close(); + out.close(); + return outb.toByteArray(); + } catch (Exception e) { + throw new PngjException(e); + } + } + + /** + * Shovels all data from an input stream to an output stream. + */ + private static void shovelInToOut(InputStream in, OutputStream out) throws IOException { + synchronized (tmpbuffer) { + int len; + while ((len = in.read(tmpbuffer)) > 0) { + out.write(tmpbuffer, 0, len); + } + } + } + + public static boolean maskMatch(int v, int mask) { + return (v & mask) != 0; + } + + /** + * Returns only the chunks that "match" the predicate + * + * See also trimList() + */ + public static List filterList(List target, ChunkPredicate predicateKeep) { + List result = new ArrayList(); + for (PngChunk element : target) { + if (predicateKeep.match(element)) { + result.add(element); + } + } + return result; + } + + /** + * Remove (in place) the chunks that "match" the predicate + * + * See also filterList + */ + public static int trimList(List target, ChunkPredicate predicateRemove) { + Iterator it = target.iterator(); + int cont = 0; + while (it.hasNext()) { + PngChunk c = it.next(); + if (predicateRemove.match(c)) { + it.remove(); + cont++; + } + } + return cont; + } + + /** + * MY adhoc criteria: two chunks are "equivalent" ("practically equal") if + * they have same id and (perhaps, if multiple are allowed) if the match + * also in some "internal key" (eg: key for string values, palette for sPLT, + * etc) + * + * Notice that the use of this is optional, and that the PNG standard allows + * Text chunks that have same key + * + * @return true if "equivalent" + */ + public static final boolean equivalent(PngChunk c1, PngChunk c2) { + if (c1 == c2) + return true; + if (c1 == null || c2 == null || !c1.id.equals(c2.id)) + return false; + // same id + if (c1.getClass() != c2.getClass()) + return false; // should not happen + if (!c2.allowsMultiple()) + return true; + if (c1 instanceof PngChunkTextVar) { + return ((PngChunkTextVar) c1).getKey().equals(((PngChunkTextVar) c2).getKey()); + } + if (c1 instanceof PngChunkSPLT) { + return ((PngChunkSPLT) c1).getPalName().equals(((PngChunkSPLT) c2).getPalName()); + } + // unknown chunks that allow multiple? consider they don't match + return false; + } + + public static boolean isText(PngChunk c) { + return c instanceof PngChunkTextVar; + } + + /** + * thread-local inflater, just reset : this should be only used for short + * individual chunks compression + */ + public static Inflater getInflater() { + Inflater inflater = inflaterProvider.get(); + inflater.reset(); + return inflater; + } + + /** + * thread-local deflater, just reset : this should be only used for short + * individual chunks decompression + */ + public static Deflater getDeflater() { + Deflater deflater = deflaterProvider.get(); + deflater.reset(); + return deflater; + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java index 1de5c0833..b68776477 100644 --- a/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java +++ b/src/jogl/classes/jogamp/opengl/util/pngj/chunks/PngChunkTRNS.java @@ -1,143 +1,141 @@ -package jogamp.opengl.util.pngj.chunks; - -import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.PngHelperInternal; -import jogamp.opengl.util.pngj.PngjException; - -/** - * tRNS chunk. - *

    - * see http://www.w3.org/TR/PNG/#11tRNS - *

    - * this chunk structure depends on the image type - */ -public class PngChunkTRNS extends PngChunkSingle { - public final static String ID = ChunkHelper.tRNS; - - // http://www.w3.org/TR/PNG/#11tRNS - - // only one of these is meaningful, depending on the image type - private int gray; - private int red, green, blue; - private int[] paletteAlpha = new int[] {}; - - public PngChunkTRNS(ImageInfo info) { - super(ID, info); - } - - @Override - public ChunkOrderingConstraint getOrderingConstraint() { - return ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT; - } - - @Override - public ChunkRaw createRawChunk() { - ChunkRaw c = null; - if (imgInfo.greyscale) { - c = createEmptyChunk(2, true); - PngHelperInternal.writeInt2tobytes(gray, c.data, 0); - } else if (imgInfo.indexed) { - c = createEmptyChunk(paletteAlpha.length, true); - for (int n = 0; n < c.len; n++) { - c.data[n] = (byte) paletteAlpha[n]; - } - } else { - c = createEmptyChunk(6, true); - PngHelperInternal.writeInt2tobytes(red, c.data, 0); - PngHelperInternal.writeInt2tobytes(green, c.data, 0); - PngHelperInternal.writeInt2tobytes(blue, c.data, 0); - } - return c; - } - - @Override - public void parseFromRaw(ChunkRaw c) { - if (imgInfo.greyscale) { - gray = PngHelperInternal.readInt2fromBytes(c.data, 0); - } else if (imgInfo.indexed) { - int nentries = c.data.length; - paletteAlpha = new int[nentries]; - for (int n = 0; n < nentries; n++) { - paletteAlpha[n] = (int) (c.data[n] & 0xff); - } - } else { - red = PngHelperInternal.readInt2fromBytes(c.data, 0); - green = PngHelperInternal.readInt2fromBytes(c.data, 2); - blue = PngHelperInternal.readInt2fromBytes(c.data, 4); - } - } - - @Override - public void cloneDataFromRead(PngChunk other) { - PngChunkTRNS otherx = (PngChunkTRNS) other; - gray = otherx.gray; - red = otherx.red; - green = otherx.red; - blue = otherx.red; - if (otherx.paletteAlpha != null) { - paletteAlpha = new int[otherx.paletteAlpha.length]; - System.arraycopy(otherx.paletteAlpha, 0, paletteAlpha, 0, paletteAlpha.length); - } - } - - /** - * Set rgb values - * - */ - public void setRGB(int r, int g, int b) { - if (imgInfo.greyscale || imgInfo.indexed) - throw new PngjException("only rgb or rgba images support this"); - red = r; - green = g; - blue = b; - } - - public int[] getRGB() { - if (imgInfo.greyscale || imgInfo.indexed) - throw new PngjException("only rgb or rgba images support this"); - return new int[] { red, green, blue }; - } - - public void setGray(int g) { - if (!imgInfo.greyscale) - throw new PngjException("only grayscale images support this"); - gray = g; - } - - public int getGray() { - if (!imgInfo.greyscale) - throw new PngjException("only grayscale images support this"); - return gray; - } - - /** - * WARNING: non deep copy - */ - public void setPalletteAlpha(int[] palAlpha) { - if (!imgInfo.indexed) - throw new PngjException("only indexed images support this"); - paletteAlpha = palAlpha; - } - - /** - * to use when only one pallete index is set as totally transparent - */ - public void setIndexEntryAsTransparent(int palAlphaIndex) { - if (!imgInfo.indexed) - throw new PngjException("only indexed images support this"); - paletteAlpha = new int[] { palAlphaIndex + 1 }; - for (int i = 0; i < palAlphaIndex; i++) - paletteAlpha[i] = 255; - paletteAlpha[palAlphaIndex] = 0; - } - - /** - * WARNING: non deep copy - */ - public int[] getPalletteAlpha() { - if (!imgInfo.indexed) - throw new PngjException("only indexed images support this"); - return paletteAlpha; - } - -} +package jogamp.opengl.util.pngj.chunks; + +import jogamp.opengl.util.pngj.ImageInfo; +import jogamp.opengl.util.pngj.PngHelperInternal; +import jogamp.opengl.util.pngj.PngjException; + +/** + * tRNS chunk. + *

    + * see http://www.w3.org/TR/PNG/#11tRNS + *

    + * this chunk structure depends on the image type + */ +public class PngChunkTRNS extends PngChunkSingle { + public final static String ID = ChunkHelper.tRNS; + + // http://www.w3.org/TR/PNG/#11tRNS + + // only one of these is meaningful, depending on the image type + private int gray; + private int red, green, blue; + private int[] paletteAlpha = new int[] {}; + + public PngChunkTRNS(ImageInfo info) { + super(ID, info); + } + + @Override + public ChunkOrderingConstraint getOrderingConstraint() { + return ChunkOrderingConstraint.AFTER_PLTE_BEFORE_IDAT; + } + + @Override + public ChunkRaw createRawChunk() { + ChunkRaw c = null; + if (imgInfo.greyscale) { + c = createEmptyChunk(2, true); + PngHelperInternal.writeInt2tobytes(gray, c.data, 0); + } else if (imgInfo.indexed) { + c = createEmptyChunk(paletteAlpha.length, true); + for (int n = 0; n < c.len; n++) { + c.data[n] = (byte) paletteAlpha[n]; + } + } else { + c = createEmptyChunk(6, true); + PngHelperInternal.writeInt2tobytes(red, c.data, 0); + PngHelperInternal.writeInt2tobytes(green, c.data, 0); + PngHelperInternal.writeInt2tobytes(blue, c.data, 0); + } + return c; + } + + @Override + public void parseFromRaw(ChunkRaw c) { + if (imgInfo.greyscale) { + gray = PngHelperInternal.readInt2fromBytes(c.data, 0); + } else if (imgInfo.indexed) { + int nentries = c.data.length; + paletteAlpha = new int[nentries]; + for (int n = 0; n < nentries; n++) { + paletteAlpha[n] = (int) (c.data[n] & 0xff); + } + } else { + red = PngHelperInternal.readInt2fromBytes(c.data, 0); + green = PngHelperInternal.readInt2fromBytes(c.data, 2); + blue = PngHelperInternal.readInt2fromBytes(c.data, 4); + } + } + + @Override + public void cloneDataFromRead(PngChunk other) { + PngChunkTRNS otherx = (PngChunkTRNS) other; + gray = otherx.gray; + red = otherx.red; + green = otherx.green; + blue = otherx.blue; + if (otherx.paletteAlpha != null) { + paletteAlpha = new int[otherx.paletteAlpha.length]; + System.arraycopy(otherx.paletteAlpha, 0, paletteAlpha, 0, paletteAlpha.length); + } + } + + /** + * Set rgb values + * + */ + public void setRGB(int r, int g, int b) { + if (imgInfo.greyscale || imgInfo.indexed) + throw new PngjException("only rgb or rgba images support this"); + red = r; + green = g; + blue = b; + } + + public int[] getRGB() { + if (imgInfo.greyscale || imgInfo.indexed) + throw new PngjException("only rgb or rgba images support this"); + return new int[] { red, green, blue }; + } + + public void setGray(int g) { + if (!imgInfo.greyscale) + throw new PngjException("only grayscale images support this"); + gray = g; + } + + public int getGray() { + if (!imgInfo.greyscale) + throw new PngjException("only grayscale images support this"); + return gray; + } + + /** + * WARNING: non deep copy + */ + public void setPalletteAlpha(int[] palAlpha) { + if (!imgInfo.indexed) + throw new PngjException("only indexed images support this"); + paletteAlpha = palAlpha; + } + + /** + * to use when only one pallete index is set as totally transparent + */ + public void setIndexEntryAsTransparent(int palAlphaIndex) { + if (!imgInfo.indexed) + throw new PngjException("only indexed images support this"); + paletteAlpha = new int[] { palAlphaIndex + 1 }; + for (int i = 0; i < palAlphaIndex; i++) + paletteAlpha[i] = 255; + paletteAlpha[palAlphaIndex] = 0; + } + + /** + * WARNING: non deep copy + */ + public int[] getPalletteAlpha() { + return paletteAlpha; + } + +} -- cgit v1.2.3 From 1bf8c73cb5c76c0ecd7bf7a97cdde990b3ad384e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 9 Jul 2013 21:47:50 +0200 Subject: UITestCase.resetXRandRIfX11(): Iterate through all outputs and sets the preferred mode and normal rotation using RandR 1.3 .. using commandline processing w/ 'xrandr' --- make/scripts/tests.sh | 4 +- .../test/junit/newt/mm/TestScreenMode00cNEWT.java | 24 ++++- .../jogamp/opengl/test/junit/util/MiscUtils.java | 55 ++++++++--- .../jogamp/opengl/test/junit/util/UITestCase.java | 110 +++++++++++++++++++-- 4 files changed, 169 insertions(+), 24 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ca4dc63ae..bc37f2845 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -405,7 +405,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $* +testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* @@ -551,7 +551,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java index c2cb88b1c..461b3e1fa 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/mm/TestScreenMode00cNEWT.java @@ -185,16 +185,18 @@ public class TestScreenMode00cNEWT extends UITestCase { Assert.assertEquals(true,window0.isNativeValid()); Assert.assertEquals(true,window0.isVisible()); + // WARNING: See note in 'UITestCase.resetXRandRIfX11();' UITestCase.resetXRandRIfX11(); System.err.println("XRandR Reset :"+monitor.queryCurrentMode()); - validateScreenModeReset(mmOrig, 0); + validateScreenModeReset0(mmOrig); destroyWindow(window0); Thread.sleep(waitTimeShort); + validateScreenModeReset(mmOrig); } - void validateScreenModeReset(final MonitorMode mmOrig, int mmIdx) { + void validateScreenModeReset0(final MonitorMode mmOrig) { final Display display = NewtFactory.createDisplay(null); // local display Assert.assertNotNull(display); final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 @@ -208,6 +210,24 @@ public class TestScreenMode00cNEWT extends UITestCase { screen.removeReference(); } + void validateScreenModeReset(final MonitorMode mmOrig) { + final Display display = NewtFactory.createDisplay(null); // local display + Assert.assertNotNull(display); + final Screen screen = NewtFactory.createScreen(display, 0); // screen 0 + Assert.assertNotNull(screen); + Assert.assertEquals(false,display.isNativeValid()); + Assert.assertEquals(false,screen.isNativeValid()); + screen.addReference(); + Assert.assertEquals(true,display.isNativeValid()); + Assert.assertEquals(true,screen.isNativeValid()); + + final MonitorDevice monitor = screen.getMonitorDevices().get(0); + Assert.assertEquals(mmOrig, monitor.getCurrentMode()); + + screen.removeReference(); + Assert.assertEquals(false,display.isNativeValid()); + Assert.assertEquals(false,screen.isNativeValid()); + } public static void main(String args[]) throws IOException { for(int i=0; i " + line); + synchronized ( sync ) { + try { + final BufferedReader in = new BufferedReader( new InputStreamReader(is) ); + String line = null; + while ((line = in.readLine()) != null) { + if( null != outString ) { + outString.append(line).append(Platform.getNewline()); + } else if( null != outStream ) { + if( null != prefix ) { + outStream.write(prefix.getBytes()); + } + outStream.write(line.getBytes()); + outStream.write(Platform.getNewline().getBytes()); + outStream.flush(); + } + } + } catch (IOException ioe) { + System.err.println("Catched "+ioe.getClass().getName()+": "+ioe.getMessage()); + ioe.printStackTrace(); + } finally { + eos = true; + sync.notifyAll(); } } - catch (IOException ioe) { - System.err.println("Catched "+ioe.getClass().getName()+": "+ioe.getMessage()); - ioe.printStackTrace(); - } } } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java index d2ed7cd1e..839a0c7b8 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java +++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java @@ -32,8 +32,13 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.StringTokenizer; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GL; @@ -96,23 +101,112 @@ public abstract class UITestCase { resetXRandRIfX11AfterClass = true; } + /** + * Iterates through all outputs and sets the preferred mode and normal rotation using RandR 1.3. + *

    + * With NV drivers, one need to add the Modes in proper order to the Screen's Subsection "Display", + * otherwise they are either in unsorted resolution order or even n/a! + *

    + */ + @SuppressWarnings("unused") public static void resetXRandRIfX11() { if( NativeWindowFactory.isInitialized() && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { try { - final ProcessBuilder pb = new ProcessBuilder("xrandr", "-s", "0", "-o", "normal"); - pb.redirectErrorStream(true); - System.err.println("XRandR Reset cmd: "+pb.command()); - final Process p = pb.start(); - new MiscUtils.StreamDump( p.getInputStream(), "xrandr-reset" ).start(); - p.waitFor(); - System.err.println("XRandR Reset result "+p.exitValue()); + final List outputDevices = new ArrayList(); + // final List outputSizes = new ArrayList(); + final Object ioSync = new Object(); + synchronized ( ioSync ) { + final StringBuilder out = new StringBuilder(); + final ProcessBuilder pb = new ProcessBuilder("xrandr", "-q"); + pb.redirectErrorStream(true); + System.err.println("XRandR Query: "+pb.command()); + final Process p = pb.start(); + final MiscUtils.StreamDump dump = new MiscUtils.StreamDump( out, p.getInputStream(), ioSync ); + dump.start(); + while( !dump.eos() ) { + ioSync.wait(); + } + p.waitFor(); // should be fine by now .. + final int errorCode = p.exitValue(); + if( 0 == errorCode ) { + // Parse connected output devices ! + final BufferedReader in = new BufferedReader( new StringReader( out.toString() ) ); + String line = null; + while ( ( line = in.readLine() ) != null) { + final String lline = line.toLowerCase(); + if( lline.contains("connected") && !lline.contains("disconnected") ) { + final String od = getFirst(line); + if( null != od ) { + outputDevices.add( od ); + /** + if ( ( line = in.readLine() ) != null ) { + outputSizes.add( getFirst(line) ); + } else { + outputSizes.add( null ); + } */ + } + } + } + } else { + System.err.println("XRandR Query Error Code "+errorCode); + System.err.println(out.toString()); + } + } + for(int i=0; i "); + if( 0 != errorCode ) { + System.err.println("XRandR Reset Error Code "+errorCode); + } + } } catch (Exception e) { System.err.println("Catched "+e.getClass().getName()+": "+e.getMessage()); e.printStackTrace(); } - System.err.println("XRandR Reset done"); } } + private static String getFirst(String line) { + final StringTokenizer tok = new StringTokenizer(line); + if( tok.hasMoreTokens() ) { + final String s = tok.nextToken().trim(); + if( s.length() > 0 ) { + return s; + } + } + return null; + } + + public static int processCommand(String[] cmdline, OutputStream outstream, String outPrefix) { + int errorCode = 0; + final Object ioSync = new Object(); + try { + synchronized ( ioSync ) { + final ProcessBuilder pb = new ProcessBuilder(cmdline); + pb.redirectErrorStream(true); + final Process p = pb.start(); + final MiscUtils.StreamDump dump = new MiscUtils.StreamDump( outstream, outPrefix, p.getInputStream(), ioSync); + dump.start(); + while( !dump.eos() ) { + ioSync.wait(); + } + p.waitFor(); // should be fine by now .. + errorCode = p.exitValue(); + } + } catch (Exception e) { + System.err.println("Catched "+e.getClass().getName()+": "+e.getMessage()); + e.printStackTrace(); + errorCode = Integer.MIN_VALUE; + } + return errorCode; + } public int getMaxTestNameLen() { if(0 == maxMethodNameLen) { -- cgit v1.2.3 From 214a426cf52c10519cf82e5fa00c4c76d1224379 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 10 Jul 2013 02:27:29 +0200 Subject: TestGLWindows02NEWTAnimated: Give animator a chance to become paused after pulling GLAD from it. --- make/scripts/tests.sh | 4 ++-- .../jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bc37f2845..4e1c0dd52 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -399,13 +399,13 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* +testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java index 64c5e9c8d..e1c6c75c9 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows02NEWTAnimated.java @@ -131,6 +131,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertEquals(true, animator.isStarted()); animator.remove(window); + Thread.sleep(250); // give animator a chance to become paused Assert.assertEquals(false, animator.isAnimating()); Assert.assertEquals(true, animator.isPaused()); // zero drawables Assert.assertEquals(true, animator.isStarted()); @@ -145,6 +146,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Animator animator = new Animator(); animator.setUpdateFPSFrames(1, null); Assert.assertTrue(animator.start()); + Thread.sleep(250); // give animator a chance to become paused Assert.assertEquals(false, animator.isAnimating()); // zero drawables Assert.assertEquals(true, animator.isPaused()); // zero drawables animator.add(window); @@ -157,6 +159,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertEquals(true, animator.isStarted()); Assert.assertEquals(false, animator.isPaused()); animator.remove(window); + Thread.sleep(250); // give animator a chance to become paused Assert.assertEquals(false, animator.isAnimating()); Assert.assertEquals(true, animator.isStarted()); Assert.assertEquals(true, animator.isPaused()); // zero drawables @@ -189,6 +192,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertTrue(animator.start()); Assert.assertEquals(true, animator.isStarted()); + Thread.sleep(250); // give animator a chance to become paused Assert.assertEquals(false, animator.isAnimating()); // zero drawables Assert.assertEquals(true, animator.isPaused()); // zero drawables @@ -217,6 +221,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { window2.destroy(); animator.remove(window2); Assert.assertEquals(true, animator.isStarted()); + Thread.sleep(250); // give animator a chance to become paused Assert.assertEquals(false, animator.isAnimating()); // zero drawables Assert.assertEquals(true, animator.isPaused()); // zero drawables Assert.assertTrue(animator.stop()); @@ -253,6 +258,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { Assert.assertTrue(animator.start()); Assert.assertEquals(true, animator.isStarted()); + Thread.sleep(250); // give animator a chance to become paused Assert.assertEquals(false, animator.isAnimating()); // zero drawables Assert.assertEquals(true, animator.isPaused()); // zero drawables @@ -298,6 +304,7 @@ public class TestGLWindows02NEWTAnimated extends UITestCase { destroyWindow(window2); animator.remove(window2); Assert.assertEquals(true, animator.isStarted()); + Thread.sleep(250); // give animator a chance to become paused Assert.assertEquals(false, animator.isAnimating()); // zero drawables Assert.assertEquals(true, animator.isPaused()); // zero drawables -- cgit v1.2.3 From 2b6f60f67e470da2217dfc8ea9ddd566357715d4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 10 Jul 2013 13:58:00 +0200 Subject: TestMainVersionGLWindowNEWT: Add 'manual' version get/print for verification. --- make/scripts/tests.sh | 4 ++-- .../opengl/test/junit/jogl/acore/TestMainVersionGLWindowNEWT.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4e1c0dd52..9cae2ddeb 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -330,7 +330,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* @@ -399,7 +399,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLWindowNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLWindowNEWT.java index d178e34f4..41c6063dc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLWindowNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestMainVersionGLWindowNEWT.java @@ -32,12 +32,18 @@ import java.io.IOException; import org.junit.Test; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.test.junit.util.UITestCase; public class TestMainVersionGLWindowNEWT extends UITestCase { @Test public void testMain() throws InterruptedException { + JoglVersion j = JoglVersion.getInstance(); + System.out.println("Implementation-Version: "+j.getImplementationVersion()); + System.out.println("Implementation-Build: "+j.getImplementationBuild()); + System.out.println("Implementation-Branch: "+j.getImplementationBranch()); + System.out.println("Implementation-Commit: "+j.getImplementationCommit()); GLWindow.main(null); } -- cgit v1.2.3 From 3a0d7703da32e9a5ddf08a334f18588a78038d88 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 15 Jul 2013 13:39:22 +0200 Subject: Add Support for GL 4.3 (Bug 716) and ES 3.0 (Bug 717) ES3 / GL4.3: - Update all EGL, GLX, WGL and GL (desktop and mobile) khronos headers to latest version. - GL3/gl3* -> GL/glcorearb* - Explicitly preserve ES2_compatibility and ES3_compatibility in header, most extension grouping was removed in new headers. - Always load all GLHeader to ensure proper extension association across all profiles. - Unified method signatures - Added GL_EXT_map_buffer_range to core - Using common 'glMapBufferImpl(..)' for all glMapBuffer(..) and glMapBufferRange(..) impl. - Init necessary fields of GL instances via 'finalizeInit()' called by reflection, if exist. This allows removing initialization checks, i.e. for all buffer validations. - BuildStaticGLInfo: Can handle new GL header structure, i.e. one CPP extenstion block incl. define + funcs. - GLJavaMethodBindingEmitter: Simply print the - No GL duplication due to new intermediate interfaces, see below - OO lineare inheritance (Added GL2ES3, GL3ES3 and GL4ES3 intemediates): GLBase - GL - GL2ES2 - GLES2 GLBase - GL - GL2ES2 - GL2GL3 - [ GL2, GL3 ] GLBase - GL - GL2ES2 - GL2ES3 - GL3ES3 - [ GL3 ] GLBase - GL - GL2ES2 - GL2ES3 - GL3ES3 - GL4ES3 - [ GLES3, GL4, .. ] - Expose 'usable' intermediate interfaces GL3ES3 and GL4ES3 in GLBase/GLProfile/GLContext via is*() and get*(). - GLContext*: - isGL3core() is true if [ GL4, GL3, GLES3 ] (added GLES3) - Added ctxProfile argument to allow handling ES versions: - getMaxMajor(..), getMaxMinor(..), isValidGLVersion(..) and decrementGLVersion(..) - mapGLVersions(..) prepared for ES ARB/KHR validation - EGLContext checks ES3 (via old ctx's GL_VERSION) - ExtensionAvailabilityCache adds GL_ES_Version_X_Y for ES. - Prelim tests w/ Mesa 9.1.3 GL Version 3.0 (ES profile, ES2 compat, ES3 compat, FBO, hardware) - OpenGL ES 3.0 Mesa 9.1.3 [GL 3.0.0, vendor 9.1.3 (Mesa 9.1.3)] - TODO: - Use KHR_create_context in EGLContext.createContextARBImpl(..) - More tests (Mobile, ..) +++ Misc: - GLContext*: - Complete glAllocateMemoryNV w/ glFreeMemoryNV. --- make/build-jogl.xml | 189 +- make/config/jogl/gl-common-extensions.cfg | 26 +- make/config/jogl/gl-common.cfg | 173 +- make/config/jogl/gl-desktop.cfg | 5 - make/config/jogl/gl-es1.cfg | 12 - make/config/jogl/gl-es2.cfg | 90 - make/config/jogl/gl-es3.cfg | 98 + make/config/jogl/gl-gl4bc.cfg | 36 +- make/config/jogl/gl-headers.cfg | 3 +- make/config/jogl/gl-if-CustomJavaCode-es3.java | 14 + make/config/jogl/gl-if-CustomJavaCode-gl.java | 8 + make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java | 11 + make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java | 10 - .../jogl/gl-if-CustomJavaCode-gl_compat.java | 20 + make/config/jogl/gl-if-CustomJavaCode-gles2.java | 3 - make/config/jogl/gl-if-es2.cfg | 30 + make/config/jogl/gl-if-gl-ignores.cfg | 24 +- make/config/jogl/gl-if-gl.cfg | 12 +- make/config/jogl/gl-if-gl2.cfg | 5 +- make/config/jogl/gl-if-gl2_es1.cfg | 33 +- make/config/jogl/gl-if-gl2_es2-ignores.cfg | 48 + make/config/jogl/gl-if-gl2_es2.cfg | 57 +- make/config/jogl/gl-if-gl2_es3-ignores.cfg | 47 + make/config/jogl/gl-if-gl2_es3.cfg | 45 + make/config/jogl/gl-if-gl2_gl3.cfg | 15 +- make/config/jogl/gl-if-gl2es3-subset.cfg | 17 + make/config/jogl/gl-if-gl2gl3-subset.cfg | 18 + make/config/jogl/gl-if-gl3-subset.cfg | 17 - make/config/jogl/gl-if-gl3.cfg | 10 +- make/config/jogl/gl-if-gl3_es3.cfg | 43 + make/config/jogl/gl-if-gl3bc.cfg | 6 + make/config/jogl/gl-if-gl4-ignores.cfg | 2 + make/config/jogl/gl-if-gl4.cfg | 7 + make/config/jogl/gl-if-gl4_es3.cfg | 47 + make/config/jogl/gl-if-luminance-ignore.cfg | 7 + make/config/jogl/gl-impl-CustomCCode-gl4bc.c | 16 + make/config/jogl/gl-impl-CustomCCode-gles1.c | 16 + make/config/jogl/gl-impl-CustomCCode-gles2.c | 25 - make/config/jogl/gl-impl-CustomCCode-gles3.c | 41 + .../config/jogl/gl-impl-CustomJavaCode-common.java | 92 + .../jogl/gl-impl-CustomJavaCode-desktop.java | 148 - make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 326 +- make/config/jogl/gl-impl-CustomJavaCode-gles1.java | 80 +- make/config/jogl/gl-impl-CustomJavaCode-gles2.java | 262 - make/config/jogl/gl-impl-CustomJavaCode-gles3.java | 320 + make/config/jogl/gl2_es2-CustomJavaCode.cfg | 13 + make/config/jogl/gl2_es2-common.cfg | 16 +- make/config/jogl/gl2_es3-common.cfg | 9 + make/config/jogl/gl3-common.cfg | 9 + make/config/jogl/gl3-desktop.cfg | 5 - make/config/jogl/gl3-headers.cfg | 14 +- make/config/jogl/gl3ext-headers.cfg | 8 +- make/config/jogl/glx-x11.cfg | 1 - make/scripts/cmpOld2New.sh | 2 +- make/scripts/cmpOld2NewDups.sh | 121 + make/scripts/gluegen-gl.sh | 385 +- make/scripts/make.jogl.all.linux-x86_64.sh | 1 + make/scripts/tests.sh | 6 +- make/stub_includes/egl/EGL/eglext.h | 262 +- make/stub_includes/opengl/GL/gl-platform.h | 80 + make/stub_includes/opengl/GL/gl.h | 740 +- make/stub_includes/opengl/GL/glcorearb.h | 3262 +++ make/stub_includes/opengl/GL/glcorearbext.h | 351 + make/stub_includes/opengl/GL/glext.h | 20385 +++++++++---------- make/stub_includes/opengl/GL/glplatform.h | 67 - make/stub_includes/opengl/GL/glu.h | 252 +- make/stub_includes/opengl/GL/glx.h | 336 +- make/stub_includes/opengl/GL/glxext.h | 1495 +- make/stub_includes/opengl/GL/wglext.h | 1253 +- make/stub_includes/opengl/GL3/gl3.h | 3606 ---- make/stub_includes/opengl/GL3/gl3ext.h | 351 - make/stub_includes/opengl/GL3/glplatform.h | 63 - make/stub_includes/opengl/GLES/gl.h | 4 +- make/stub_includes/opengl/GLES/glext.h | 129 +- make/stub_includes/opengl/GLES2/gl2.h | 8 +- make/stub_includes/opengl/GLES2/gl2ext.h | 689 +- make/stub_includes/opengl/GLES3/gl3.h | 1073 + make/stub_includes/opengl/GLES3/gl3ext.h | 24 + make/stub_includes/opengl/GLES3/gl3platform.h | 30 + make/stub_includes/opengl/GLES3/khrplatform.h | 269 + make/stub_includes/opengl/gl-64bit-types.h | 21 - make/stub_includes/opengl/gl-types.h | 15 + make/stub_includes/opengl/gl2es12.c | 9 - make/stub_includes/opengl/gl3.c | 13 +- make/stub_includes/opengl/gl3bc.c | 13 +- make/stub_includes/opengl/gl4.c | 12 +- make/stub_includes/opengl/gl4bc.c | 13 +- make/stub_includes/opengl/gles3.c | 12 + make/stub_includes/win32/windows.h | 3 + make/stub_includes/x11/window-system1.c | 6 +- .../gluegen/opengl/BuildComposablePipeline.java | 42 +- .../jogamp/gluegen/opengl/BuildStaticGLInfo.java | 79 +- .../com/jogamp/gluegen/opengl/GLConfiguration.java | 61 +- .../gluegen/opengl/GLJavaMethodBindingEmitter.java | 8 +- .../classes/com/jogamp/opengl/GLExtensions.java | 3 +- src/jogl/classes/javax/media/opengl/GLBase.java | 49 +- src/jogl/classes/javax/media/opengl/GLContext.java | 183 +- .../classes/javax/media/opengl/GLDebugMessage.java | 74 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 333 +- .../jogamp/opengl/ExtensionAvailabilityCache.java | 20 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 124 +- .../jogamp/opengl/GLDebugMessageHandler.java | 4 +- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 51 +- .../jogamp/opengl/egl/EGLDrawableFactory.java | 114 +- .../opengl/egl/EGLDynamicLibraryBundleInfo.java | 2 +- .../opengl/egl/EGLES2DynamicLibraryBundleInfo.java | 28 +- .../jogamp/opengl/egl/EGLGLCapabilities.java | 6 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 14 +- .../opengl/windows/wgl/WindowsWGLContext.java | 10 +- .../jogamp/opengl/x11/glx/X11GLXContext.java | 9 +- src/jogl/native/GLDebugMessageHandler.c | 8 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 29 +- .../test/junit/jogl/acore/TestGLDebug00NEWT.java | 13 +- .../test/junit/jogl/acore/TestGLDebug01NEWT.java | 12 +- .../jogl/acore/TestMainVersionGLWindowNEWT.java | 6 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 6 + 116 files changed, 20959 insertions(+), 18279 deletions(-) delete mode 100644 make/config/jogl/gl-es2.cfg create mode 100644 make/config/jogl/gl-es3.cfg create mode 100644 make/config/jogl/gl-if-CustomJavaCode-es3.java delete mode 100644 make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java create mode 100644 make/config/jogl/gl-if-CustomJavaCode-gl_compat.java delete mode 100644 make/config/jogl/gl-if-CustomJavaCode-gles2.java create mode 100644 make/config/jogl/gl-if-es2.cfg create mode 100644 make/config/jogl/gl-if-gl2_es2-ignores.cfg create mode 100644 make/config/jogl/gl-if-gl2_es3-ignores.cfg create mode 100644 make/config/jogl/gl-if-gl2_es3.cfg create mode 100644 make/config/jogl/gl-if-gl2es3-subset.cfg create mode 100644 make/config/jogl/gl-if-gl2gl3-subset.cfg delete mode 100644 make/config/jogl/gl-if-gl3-subset.cfg create mode 100644 make/config/jogl/gl-if-gl3_es3.cfg create mode 100644 make/config/jogl/gl-if-gl4_es3.cfg create mode 100644 make/config/jogl/gl-if-luminance-ignore.cfg delete mode 100644 make/config/jogl/gl-impl-CustomCCode-gles2.c create mode 100644 make/config/jogl/gl-impl-CustomCCode-gles3.c delete mode 100644 make/config/jogl/gl-impl-CustomJavaCode-desktop.java delete mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gles2.java create mode 100644 make/config/jogl/gl-impl-CustomJavaCode-gles3.java create mode 100644 make/config/jogl/gl2_es2-CustomJavaCode.cfg create mode 100644 make/config/jogl/gl2_es3-common.cfg create mode 100644 make/config/jogl/gl3-common.cfg create mode 100644 make/scripts/cmpOld2NewDups.sh create mode 100644 make/stub_includes/opengl/GL/gl-platform.h create mode 100644 make/stub_includes/opengl/GL/glcorearb.h create mode 100644 make/stub_includes/opengl/GL/glcorearbext.h delete mode 100644 make/stub_includes/opengl/GL/glplatform.h delete mode 100644 make/stub_includes/opengl/GL3/gl3.h delete mode 100644 make/stub_includes/opengl/GL3/gl3ext.h delete mode 100644 make/stub_includes/opengl/GL3/glplatform.h create mode 100644 make/stub_includes/opengl/GLES3/gl3.h create mode 100644 make/stub_includes/opengl/GLES3/gl3ext.h create mode 100644 make/stub_includes/opengl/GLES3/gl3platform.h create mode 100644 make/stub_includes/opengl/GLES3/khrplatform.h delete mode 100644 make/stub_includes/opengl/gl-64bit-types.h create mode 100644 make/stub_includes/opengl/gl-types.h delete mode 100644 make/stub_includes/opengl/gl2es12.c create mode 100644 make/stub_includes/opengl/gles3.c (limited to 'make/scripts') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 9c017ed62..7b9b8a957 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -140,11 +140,11 @@ - + - + @@ -319,7 +319,11 @@ - + + + + + @@ -381,6 +385,12 @@ + + + + + @@ -398,6 +408,7 @@ + @@ -440,6 +451,20 @@ + + + + + + + + @@ -453,12 +478,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - @@ -527,48 +600,47 @@ - - + + - + emitter="com.jogamp.gluegen.opengl.GLEmitter"> - - + + - + emitter="com.jogamp.gluegen.opengl.GLEmitter"> - - + + - + emitter="com.jogamp.gluegen.opengl.GLEmitter" + debug="false"> - + - - + - + + + @@ -822,12 +883,6 @@ - the classpath reference id then running the task on each header. --> - - - - + + + + + + + + + + + + @@ -936,6 +1007,14 @@ + + + + + + + + @@ -972,7 +1051,7 @@ - + @@ -1013,7 +1092,7 @@ + @@ -1544,6 +1624,7 @@ + @@ -1603,12 +1684,12 @@ + includes="${java.part.egl} ${java.part.es1} ${java.part.es2es3}" + excludes="${java.part.awt} ${java.part.swt} ${java.part.es1.dbg} ${java.part.es2es3.dbg}"/> + includes="${java.part.es1.dbg} ${java.part.es2es3.dbg}"/> diff --git a/make/config/jogl/gl-common-extensions.cfg b/make/config/jogl/gl-common-extensions.cfg index 6631e035d..a723a9fd8 100644 --- a/make/config/jogl/gl-common-extensions.cfg +++ b/make/config/jogl/gl-common-extensions.cfg @@ -20,6 +20,7 @@ DropUniqVendorExtensions WIN # Drop some obsolete or mostly-integrated vendor extensions that the above directives let in # Note that some of these are in LWJGL, so perhaps there is justification for leaving them in +IgnoreExtension GL_APPLE_sync IgnoreExtension GL_APPLE_element_array IgnoreExtension GL_APPLE_vertex_array_object IgnoreExtension GL_ATI_element_array @@ -46,6 +47,7 @@ IgnoreExtension GL_NV_texture_rectangle IgnoreExtension GL_NV_vertex_program # This one would require more work -- has associated GLX and WGL bindings IgnoreExtension GL_NV_present_video +IgnoreExtension GL_OES_fixed_point # For the time being, ignore these extensions which are in the ES 2.0 spec IgnoreExtension GL_NV_framebuffer_vertex_attrib_array @@ -86,25 +88,11 @@ RenameExtensionIntoCore GL_NV_draw_buffers RenameExtensionIntoCore GL_NV_fbo_color_attachments RenameExtensionIntoCore GL_EXT_packed_float RenameExtensionIntoCore GL_EXT_texture_format_BGRA8888 - -# A mess w/ the ES2 definition .. sadly -# RenameExtensionIntoCore GL_EXT_texture_storage -RenameJavaSymbol glTexStorage1DEXT glTexStorage1D -RenameJavaSymbol glTexStorage2DEXT glTexStorage2D -RenameJavaSymbol glTexStorage3DEXT glTexStorage3D -RenameJavaSymbol GL_TEXTURE_IMMUTABLE_FORMAT_EXT GL_TEXTURE_IMMUTABLE_FORMAT -RenameJavaSymbol GL_RGBA32F_EXT GL_RGBA32F -RenameJavaSymbol GL_RGB32F_EXT GL_RGB32F -RenameJavaSymbol GL_ALPHA32F_EXT GL_ALPHA32F_ARB -RenameJavaSymbol GL_LUMINANCE32F_EXT GL_LUMINANCE32F_ARB -RenameJavaSymbol GL_LUMINANCE_ALPHA32F_EXT GL_LUMINANCE_ALPHA32F_ARB -RenameJavaSymbol GL_RGB16F_EXT GL_RGB16F -RenameJavaSymbol GL_ALPHA16F_EXT GL_ALPHA16F_ARB -RenameJavaSymbol GL_LUMINANCE16F_EXT GL_LUMINANCE16F_ARB -RenameJavaSymbol GL_LUMINANCE_ALPHA16F_EXT GL_LUMINANCE_ALPHA16F_ARB -RenameJavaSymbol GL_RGB10_A2_EXT GL_RGB10_A2 -RenameJavaSymbol GL_RGB10_EXT GL_RGB10 - +RenameExtensionIntoCore GL_OES_single_precision +RenameExtensionIntoCore GL_EXT_draw_buffers +RenameExtensionIntoCore GL_EXT_texture_storage +RenameExtensionIntoCore GL_ARB_texture_storage +RenameExtensionIntoCore GL_EXT_map_buffer_range # The following extensions have some differences requiring us to # manually rename some symbols and leave others alone for best diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index ad0b7d1d0..ddb312075 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -7,6 +7,19 @@ HierarchicalNativeOutput false RuntimeExceptionType GLException UnsupportedExceptionType GLException +# Inform the glue code generator of the association between #defines +# and functions and the extensions in which they are defined +GLHeader GL/gl.h +GLHeader GL/glext.h +GLHeader GL/glcorearb.h +GLHeader GL/glcorearbext.h +GLHeader GLES/gl.h +GLHeader GLES/glext.h +GLHeader GLES2/gl2.h +GLHeader GLES2/gl2ext.h +GLHeader GLES3/gl3.h +GLHeader GLES3/gl3ext.h + # Imports needed by all glue code Import java.util.* Import javax.media.opengl.* @@ -37,13 +50,17 @@ Ignore glGetVertexAttribPointerv Ignore glGetVertexAttribPointervARB Ignore glGetVertexAttribPointervNV Ignore glTracePointerRangeMESA -Ignore glDebugMessageCallbackARB Ignore glDebugMessageCallbackAMD +Ignore glDebugMessageCallbackARB +Ignore glDebugMessageCallbackKHR +Ignore glDebugMessageCallback -# Manually implement glMapBuffer as the size of the returned buffer +# Manually implement glMapBuffer and glMapBufferRange as the size of the returned buffer # can only be computed by calling another routine ManuallyImplement glMapBuffer ForceProcAddressGen glMapBuffer +ManuallyImplement glMapBufferRange +ForceProcAddressGen glMapBufferRange # Ignore the ATI_map_object_buffer extension for now unless someone # claims they need it, as it will undoubtedly require a similar @@ -249,7 +266,7 @@ RenameExtensionIntoCore GL_EXT_draw_buffers2 RenameExtensionIntoCore GL_ARB_texture_compression_rgtc IgnoreExtension GL_EXT_texture_compression_rgtc -RenameExtensionIntoCore GL_EXT_transform_feedback +IgnoreExtension GL_EXT_transform_feedback IgnoreExtension GL_NV_transform_feedback # gl.h uses GL_ARB_vertex_array_object @@ -277,6 +294,8 @@ IgnoreExtension GL_EXT_texture_buffer_object RenameExtensionIntoCore GL_EXT_texture_rectangle IgnoreExtension GL_NV_texture_rectangle RenameExtensionIntoCore GL_ARB_uniform_buffer_object +# Use Manual definition, otherwise GlueGen uses 'long' type +Ignore GL_INVALID_INDEX # <<< OpenGL 3.1 # >>> OpenGL 3.2 @@ -339,6 +358,17 @@ RenameExtensionIntoCore GL_ARB_viewport_array # Rename extension suffices (if exist) subsumed in OpenGL 4.2 (from OpenGL 4.2 spec, Appendix L.1) # <<< OpenGL 4.2 +# >>> OpenGL 4.3 +# Rename extension suffices (if exist) subsumed in OpenGL 4.3 (from OpenGL 4.3 spec, Appendix ?.1) +RenameExtensionIntoCore GL_ARB_debug_output +# <<< OpenGL 4.3 + +# >>> OpenGL ES 2.0 +# <<< OpenGL ES 2.0 + +# >>> OpenGL ES 3.0 +# <<< OpenGL ES 3.0 + # Ignore a few obsolete versions of extensions that have been subsumed into the core or ARB extensions IgnoreExtension GL_EXT_multisample IgnoreExtension GL_EXT_point_parameters @@ -352,6 +382,8 @@ IgnoreExtension GL_EXT_shader_image_load_store Opaque boolean GLboolean Opaque long GLsync Opaque long GLeglImageOES +Opaque long cl_context +Opaque long cl_event ReturnsString glGetString ReturnsString glGetStringi @@ -421,9 +453,6 @@ NIODirectOnly glExtGetBufferPointervQCOM ReturnValueCapacity wglAllocateMemoryNV {0} ReturnValueCapacity glXAllocateMemoryNV {0} -ReturnValueCapacity glMapBufferRange {2} -ReturnValueCapacity glMapNamedBufferRangeEXT {2} - # Pass arguments to ARB_vertex_program, ARB_fragment_program, # ARB_shader_objects, NV_vertex_program, NV_fragment_program, and # ARB_vertex_shader as Strings @@ -473,7 +502,7 @@ ArgumentIsString glGetFragDataIndex 1 ArgumentIsString glGetSubroutineIndex 2 ArgumentIsString glGetSubroutineUniformLocation 2 -ArgumentIsString glDebugMessageInsertARB 5 +ArgumentIsString glDebugMessageInsert 5 ArgumentIsString glDebugMessageInsertAMD 4 ArgumentIsString glNamedStringARB 2 4 @@ -702,78 +731,122 @@ RangeCheck glDeleteVertexArraysAPPLE 1 {0} # Javadoc for the GL class ClassJavadoc GL /** -ClassJavadoc GL *

    Common interface containing the subset of all profiles, GL3bc, GL3, GL2, GLES1 and GLES2.
    -ClassJavadoc GL * This interface reflects common data types, texture and framebuffer functionality.

    +ClassJavadoc GL *

    Common interface containing the subset of all profiles, GL3bc, GL3, GL2, GLES1 and GLES2.
    +ClassJavadoc GL * This interface reflects common data types, texture and framebuffer functionality.

    ClassJavadoc GL */ ClassJavadoc GL2ES1 /** -ClassJavadoc GL2ES1 *

    -ClassJavadoc GL2ES1 * Interface containing the common subset of GL2 and GLES1.
    -ClassJavadoc GL2ES1 * This interface reflects only the fixed functionality of OpenGL
    -ClassJavadoc GL2ES1 *

    +ClassJavadoc GL2ES1 *

    +ClassJavadoc GL2ES1 * Interface containing the common subset of GL2 and GLES1.
    +ClassJavadoc GL2ES1 * This interface reflects only the fixed functionality of OpenGL
    +ClassJavadoc GL2ES1 *

    ClassJavadoc GL2ES1 */ ClassJavadoc GL2ES2 /** -ClassJavadoc GL2ES2 *

    -ClassJavadoc GL2ES2 * Interface containing the common subset of GL3, GL2 and GLES2.
    -ClassJavadoc GL2ES2 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    -ClassJavadoc GL2ES2 *

    +ClassJavadoc GL2ES2 *

    +ClassJavadoc GL2ES2 * Interface containing the common subset of GL3, GL2 and GLES2.
    +ClassJavadoc GL2ES2 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    +ClassJavadoc GL2ES2 * This interface is almost GLES2 complete.
    +ClassJavadoc GL2ES2 *

    ClassJavadoc GL2ES2 */ +ClassJavadoc GL2ES3 /** +ClassJavadoc GL2ES3 *

    +ClassJavadoc GL2ES3 * Interface containing the common subset of core GL2 and GLES3 (OpenGL ES 3.0).
    +ClassJavadoc GL2ES3 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    +ClassJavadoc GL2ES3 * This interface is not GLES3 complete and merely exist to avoid duplicated definitions.
    +ClassJavadoc GL2ES3 *

    +ClassJavadoc GL2ES3 */ + +ClassJavadoc GL3ES3 /** +ClassJavadoc GL3ES3 *

    +ClassJavadoc GL3ES3 * Interface containing the common subset of core GL3 (OpenGL 3.1+) and GLES3 (OpenGL ES 3.0).
    +ClassJavadoc GL3ES3 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    +ClassJavadoc GL3ES3 * This interface is almost GLES3 complete, but lacks the GL_ARB_ES3_compatibility extension.
    +ClassJavadoc GL3ES3 *

    +ClassJavadoc GL3ES3 */ + +ClassJavadoc GL4ES3 /** +ClassJavadoc GL4ES3 *

    +ClassJavadoc GL4ES3 * Interface containing the common subset of core GL4 (OpenGL 4.0+) and GLES3 (OpenGL ES 3.0).
    +ClassJavadoc GL4ES3 * This interface reflects only the programmable shader functionality of desktop and embedded OpenGL
    +ClassJavadoc GL4ES3 * This interface is GLES3 complete.
    +ClassJavadoc GL4ES3 *

    +ClassJavadoc GL4ES3 */ + ClassJavadoc GL2GL3 /** -ClassJavadoc GL2GL3 *

    -ClassJavadoc GL2GL3 * Interface containing the common subset of core GL3 (OpenGL 3.1+) and GL2 (OpenGL 3.0), -ClassJavadoc GL2GL3 * also known as the OpenGL 3.0 forward compatible, non deprecated subset.
    -ClassJavadoc GL2GL3 * This interface reflects only the programmable shader functionality of desktop OpenGL
    -ClassJavadoc GL2GL3 *

    +ClassJavadoc GL2GL3 *

    +ClassJavadoc GL2GL3 * Interface containing the common subset of core GL3 (OpenGL 3.1) and GL2 (OpenGL 3.0), +ClassJavadoc GL2GL3 * also known as the OpenGL 3.0 forward compatible, non deprecated subset.
    +ClassJavadoc GL2GL3 * This interface reflects only the programmable shader functionality of desktop OpenGL
    +ClassJavadoc GL2GL3 *

    ClassJavadoc GL2GL3 */ ClassJavadoc GL2 /** -ClassJavadoc GL2 *

    +ClassJavadoc GL2 *

    ClassJavadoc GL2 * This interface contains all core desktop OpenGL methods through ClassJavadoc GL2 * version 3.0, inclusive, as well as most of it's extensions defined at the ClassJavadoc GL2 * time of this specification. Early OpenGL extensions whose functionality ClassJavadoc GL2 * was incorporated into core OpenGL by version 3.0, inclusive, are specifically -ClassJavadoc GL2 * excluded.
    +ClassJavadoc GL2 * excluded.
    ClassJavadoc GL2 * Note: OpenGL 3.0 is the last subsumed version in the specification. ClassJavadoc GL2 * You need to use a {@link GL3} or {@link GL3bc} OpenGL 3.1+ context to benefit ClassJavadoc GL2 * from new functionality and versions. -ClassJavadoc GL2 *

    +ClassJavadoc GL2 *

    ClassJavadoc GL2 */ -ClassJavadoc GL3bc /** -ClassJavadoc GL3bc *

    -ClassJavadoc GL3bc * This interface contains the OpenGL 3.x compatibility profile, ie includes all methods -ClassJavadoc GL3bc * as defined in {@link GL2} and {@link GL3}.
    -ClassJavadoc GL3bc *

    -ClassJavadoc GL3bc */ - ClassJavadoc GL3 /** -ClassJavadoc GL3 *

    -ClassJavadoc GL3 * This interface contains all core, forward compatible, OpenGL methods starting from 3.1, -ClassJavadoc GL3 * inclusive, as well as most of it's extensions defined at the time of this specification.
    +ClassJavadoc GL3 *

    +ClassJavadoc GL3 * This interface contains the core, forward compatible, OpenGL methods of GL 3.x, with x >=1, +ClassJavadoc GL3 * as well as most of it's extensions defined at the time of this specification.
    ClassJavadoc GL3 * Note: OpenGL 3.0 forward compatible, non deprecated functionality is included in the -ClassJavadoc GL3 * 3.1 specification, hence the {@link GL2GL3} implemented interface.
    -ClassJavadoc GL3 * Note: OpenGL 3.1 forward compatible no more includes fixed point functionality. -ClassJavadoc GL3 *

    +ClassJavadoc GL3 * 3.1 specification, hence the {@link GL2GL3} implemented interface.
    +ClassJavadoc GL3 * Note: OpenGL 3.1 forward compatible, core profile abandoned fixed point functionality. +ClassJavadoc GL3 *

    ClassJavadoc GL3 */ +ClassJavadoc GL3bc /** +ClassJavadoc GL3bc *

    +ClassJavadoc GL3bc * This interface containing all core and compatibility OpenGL methods of GL 3.x, with x >= 1,
    +ClassJavadoc GL3bc * as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GL3bc *

    +ClassJavadoc GL3bc */ + +ClassJavadoc GL4 /** +ClassJavadoc GL4 *

    +ClassJavadoc GL4 * This interface containing all core OpenGL methods of GL 4.x, with x >= 0,
    +ClassJavadoc GL4 * as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GL4 *

    +ClassJavadoc GL4 */ + +ClassJavadoc GL4bc /** +ClassJavadoc GL4bc *

    +ClassJavadoc GL4bc * This interface containing all core and compatibility OpenGL methods of GL 4.x, with x >= 0,
    +ClassJavadoc GL4bc * as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GL4bc *

    +ClassJavadoc GL4bc */ + ClassJavadoc GLES1 /** -ClassJavadoc GLES1 *

    +ClassJavadoc GLES1 *

    ClassJavadoc GLES1 * This interface contains all core embedded OpenGL methods of ES 1.x, with x >= 0, -ClassJavadoc GLES1 * inclusive, as well as most of it's extensions defined at the -ClassJavadoc GLES1 * time of this specification. -ClassJavadoc GLES1 *

    +ClassJavadoc GLES1 * as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GLES1 *

    ClassJavadoc GLES1 */ ClassJavadoc GLES2 /** -ClassJavadoc GLES2 *

    +ClassJavadoc GLES2 *

    ClassJavadoc GLES2 * This interface contains all core embedded OpenGL methods of ES 2.x, with x >= 0, -ClassJavadoc GLES2 * inclusive, as well as most of it's extensions defined at the -ClassJavadoc GLES2 * time of this specification. -ClassJavadoc GLES2 *

    +ClassJavadoc GLES2 * inclusive, as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GLES2 *

    ClassJavadoc GLES2 */ +ClassJavadoc GLES3 /** +ClassJavadoc GLES3 *

    +ClassJavadoc GLES3 * This interface contains all core embedded OpenGL methods of ES 3.x, with x >= 0, +ClassJavadoc GLES3 * inclusive, as well as most of it's extensions defined at the time of this specification. +ClassJavadoc GLES3 *

    +ClassJavadoc GLES3 */ + # Javadoc for the EGL class ClassJavadoc EGL /** ClassJavadoc EGL * Provides access to the embedded-specific OpenGL vendor extensions. @@ -805,11 +878,3 @@ ClassJavadoc XVisualInfo * extensions. No other access is provided to these dat ClassJavadoc XVisualInfo * this wrapper is not useful to end users, though it is used in the implementation. ClassJavadoc XVisualInfo */ -# Custom code for querying extensions and exposing -# wglAllocateMemoryNV/glXAllocateMemoryNV -CustomJavaCode GL2GL3 /** -CustomJavaCode GL2GL3 * Provides platform-independent access to the wglAllocateMemoryNV / -CustomJavaCode GL2GL3 * glXAllocateMemoryNV extension. -CustomJavaCode GL2GL3 */ -CustomJavaCode GL2GL3 public java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); - diff --git a/make/config/jogl/gl-desktop.cfg b/make/config/jogl/gl-desktop.cfg index a91f5ac5b..244271468 100644 --- a/make/config/jogl/gl-desktop.cfg +++ b/make/config/jogl/gl-desktop.cfg @@ -1,11 +1,6 @@ # This .cfg file provides common options used by the desktop OpenGL # implementation on all platforms. -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GL/gl.h -GLHeader GL/glext.h - #Include gl-desktop-tracker.cfg diff --git a/make/config/jogl/gl-es1.cfg b/make/config/jogl/gl-es1.cfg index 2a7b64dd3..b73b1a731 100644 --- a/make/config/jogl/gl-es1.cfg +++ b/make/config/jogl/gl-es1.cfg @@ -30,13 +30,6 @@ EmitProcAddressTable true ProcAddressTableClassName GLES1ProcAddressTable GetProcAddressTableExpr ((GLES1ProcAddressTable)_context.getGLProcAddressTable()) -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GLES/gl.h -GLHeader GLES/glext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - # 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 @@ -49,11 +42,6 @@ LocalProcAddressCallingConvention __ALL__ GL_APIENTRY # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true -# Ignore certain extensions that will be picked up by the dynamic -# lookup mechanism anyway if they are present -IgnoreExtension GL_OES_fixed_point -IgnoreExtension GL_OES_single_precision - # Add PixelStorei StateTracker # # Add input validation to glPixelStorei, just to be sure. diff --git a/make/config/jogl/gl-es2.cfg b/make/config/jogl/gl-es2.cfg deleted file mode 100644 index 8b6152bd0..000000000 --- a/make/config/jogl/gl-es2.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/es2 - -ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java -ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java -ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java - -Package javax.media.opengl -Style InterfaceAndImpl -JavaClass GLES2 -#Extends GLES2 GLBase -#Extends GLES2 GL -Extends GLES2 GL2ES2 -ImplPackage jogamp.opengl.es2 -ImplJavaClass GLES2Impl -Implements GLES2Impl GLBase -Implements GLES2Impl GL -Implements GLES2Impl GL2ES2 -HierarchicalNativeOutput false -Include gl-common.cfg -Include gl-common-extensions.cfg -Include gl2_es2-common.cfg - -RenameExtensionIntoCore GL_OES_texture_3D -RenameExtensionIntoCore GL_OES_get_program_binary - -EmitProcAddressTable true -ProcAddressTableClassName GLES2ProcAddressTable -GetProcAddressTableExpr ((GLES2ProcAddressTable)_context.getGLProcAddressTable()) - -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GLES2/gl2.h -GLHeader GLES2/gl2ext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - -# 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 GL_APIENTRY -LocalProcAddressCallingConvention __ALL__ GL_APIENTRY - -# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums -TagNativeBinding true - -# Add PixelStorei StateTracker -# -# Add input validation to glPixelStorei, just to be sure. -CustomJavaCode GLES2Impl 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; } - -IncludeAs CustomJavaCode GLES2 gl-if-CustomJavaCode-gles2.java - -CustomCCode #include /* android */ -CustomCCode /* Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -CustomCCode "glext.h" are parsed. */ -CustomCCode #define GL_GLEXT_PROTOTYPES - -CustomCCode /* Include the OpenGL headers */ -CustomCCode /* #define GL_APICALL __declspec(dllimport) */ -CustomCCode #include -CustomCCode #include -CustomCCode #include - -IncludeAs CustomJavaCode GLES2Impl gl-impl-CustomJavaCode-common.java -IncludeAs CustomJavaCode GLES2Impl gl-impl-CustomJavaCode-gles2.java -IncludeAs CustomJavaCode GLES2Impl gl-impl-CustomJavaCode-embedded.java -IncludeAs CustomJavaCode GLES2Impl gl-impl-CustomJavaCode-gl2_es2.java -IncludeAs CustomCCode gl-impl-CustomCCode-gles2.c - -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.common.nio.Buffers -Import com.jogamp.opengl.util.GLBuffers -Import java.io.PrintStream - diff --git a/make/config/jogl/gl-es3.cfg b/make/config/jogl/gl-es3.cfg new file mode 100644 index 000000000..997723d01 --- /dev/null +++ b/make/config/jogl/gl-es3.cfg @@ -0,0 +1,98 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl/es3 + +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/GLES2.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL4ES3.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +Package javax.media.opengl +Style InterfaceAndImpl +JavaClass GLES3 +#Extends GLES3 GLBase +#Extends GLES3 GL +#Extends GLES3 GL2ES2 +#Extends GLES3 GL2ES3 +#Extends GLES3 GL3ES3 +Extends GLES3 GLES2 +Extends GLES3 GL4ES3 +ImplPackage jogamp.opengl.es3 +ImplJavaClass GLES3Impl +Implements GLES3Impl GLBase +Implements GLES3Impl GL +Implements GLES3Impl GL2ES2 +Implements GLES3Impl GLES2 +Implements GLES3Impl GL2ES3 +Implements GLES3Impl GL3ES3 +Implements GLES3Impl GL4ES3 +HierarchicalNativeOutput false +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl2_es2-CustomJavaCode.cfg + +ForceExtension GL_ARB_ES3_compatibility + +EmitProcAddressTable true +ProcAddressTableClassName GLES3ProcAddressTable +GetProcAddressTableExpr ((GLES3ProcAddressTable)_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 GL_APIENTRY +LocalProcAddressCallingConvention __ALL__ GL_APIENTRY + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +# Add PixelStorei StateTracker +# +# Add input validation to glPixelStorei, just to be sure. +CustomJavaCode GLES3Impl 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; } + +CustomCCode #include /* android */ +CustomCCode /* Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in +CustomCCode "glext.h" are parsed. */ +CustomCCode #define GL_GLEXT_PROTOTYPES + +CustomCCode /* Include the OpenGL headers */ +CustomCCode /* #define GL_APICALL __declspec(dllimport) */ +CustomCCode #include +CustomCCode #include +CustomCCode #include +CustomCCode #include + +IncludeAs CustomJavaCode GLES3Impl gl-impl-CustomJavaCode-common.java +IncludeAs CustomJavaCode GLES3Impl gl-impl-CustomJavaCode-gles3.java +IncludeAs CustomJavaCode GLES3Impl gl-impl-CustomJavaCode-embedded.java +IncludeAs CustomJavaCode GLES3Impl gl-impl-CustomJavaCode-gl2_es2.java +IncludeAs CustomCCode gl-impl-CustomCCode-gles3.c + +Import javax.media.opengl.GLBase +Import javax.media.opengl.GL +Import javax.media.opengl.GL2ES2 +Import javax.media.opengl.GL2ES3 +Import javax.media.opengl.GL3ES3 +Import javax.media.opengl.GL4ES3 +Import javax.media.opengl.GLES3 +Import javax.media.opengl.GLArrayData +Import javax.media.opengl.GLUniformData +Import com.jogamp.common.nio.Buffers +Import com.jogamp.opengl.util.GLBuffers +Import java.io.PrintStream + diff --git a/make/config/jogl/gl-gl4bc.cfg b/make/config/jogl/gl-gl4bc.cfg index ce6883106..d1bd85641 100644 --- a/make/config/jogl/gl-gl4bc.cfg +++ b/make/config/jogl/gl-gl4bc.cfg @@ -5,6 +5,9 @@ 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/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL4ES3.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 @@ -22,6 +25,9 @@ JavaClass GL4bc #Extends GL4bc GL #Extends GL4bc GL2ES1 #Extends GL4bc GL2ES2 +#Extends GL4bc GL2ES3 +#Extends GL4bc GL3ES3 +#Extends GL4bc GL4ES3 #Extends GL4bc GL2GL3 #Extends GL4bc GL2 #Extends GL4bc GL3 @@ -33,6 +39,9 @@ Implements GL4bcImpl GLBase Implements GL4bcImpl GL Implements GL4bcImpl GL2ES1 Implements GL4bcImpl GL2ES2 +Implements GL4bcImpl GL2ES3 +Implements GL4bcImpl GL3ES3 +Implements GL4bcImpl GL4ES3 Implements GL4bcImpl GL2GL3 Implements GL4bcImpl GL2 Implements GL4bcImpl GL3 @@ -43,7 +52,8 @@ Include gl-common.cfg Include gl-common-extensions.cfg Include gl-desktop.cfg Include gl3-desktop.cfg -Include gl2_es2-common.cfg +Include gl3-common.cfg +Include gl2_es2-CustomJavaCode.cfg # Manually implement glMapNamedBufferEXT as the size of the returned buffer # can only be computed by calling another routine @@ -52,7 +62,7 @@ ForceProcAddressGen glMapNamedBufferEXT JavaEpilogue glNamedBufferDataEXT bufferSizeTracker.setDirectStateBufferSize({0}, this, {1}); # Manuall implement glDebugMessageCallback* using the proc address resolver -ForceProcAddressGen glDebugMessageCallbackARB +ForceProcAddressGen glDebugMessageCallback ForceProcAddressGen glDebugMessageCallbackAMD # Force all of the methods to be emitted using dynamic linking so we @@ -81,18 +91,22 @@ 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); } +JavaPrologue glFrustumf if ( !_context.hasFP32CompatAPI() ) { +JavaPrologue glFrustumf glFrustum((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); +JavaPrologue glFrustumf return; +JavaPrologue glFrustumf } -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); } +JavaPrologue glOrthof if ( !_context.hasFP32CompatAPI() ) { +JavaPrologue glOrthof glOrtho((double)left, (double)right, (double)bottom, (double)top, (double)zNear, (double)zFar); +JavaPrologue glOrthof return; +JavaPrologue glOrthof } -JavaPrologue glDepthRangef if ( !_context.isGLES2Compatible() ) { +JavaPrologue glDepthRangef if ( !_context.isGLES2Compatible() && !_context.hasFP32CompatAPI() ) { JavaPrologue glDepthRangef glDepthRange( (double)zNear, (double)zFar ); JavaPrologue glDepthRangef return; JavaPrologue glDepthRangef } -JavaPrologue glClearDepthf if ( !_context.isGLES2Compatible() ) { +JavaPrologue glClearDepthf if ( !_context.isGLES2Compatible() && !_context.hasFP32CompatAPI() ) { JavaPrologue glClearDepthf glClearDepth( (double)depth ); JavaPrologue glClearDepthf return; JavaPrologue glClearDepthf } @@ -102,12 +116,16 @@ Include gl3ext-headers.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.GL2ES1 +Import javax.media.opengl.GL2ES2 +Import javax.media.opengl.GL2ES3 +Import javax.media.opengl.GL3ES3 +Import javax.media.opengl.GL4ES3 Import javax.media.opengl.GL2GL3 Import javax.media.opengl.GL2 Import javax.media.opengl.GL3 diff --git a/make/config/jogl/gl-headers.cfg b/make/config/jogl/gl-headers.cfg index b80630c63..62f5e8dd4 100644 --- a/make/config/jogl/gl-headers.cfg +++ b/make/config/jogl/gl-headers.cfg @@ -1,7 +1,6 @@ CustomCCode #include CustomCCode #include /* android */ -CustomCCode /* Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -CustomCCode "glext.h" are parsed. */ +CustomCCode /** Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. */ CustomCCode #define GL_GLEXT_PROTOTYPES CustomCCode #if defined(_WIN32) CustomCCode #define WIN32_LEAN_AND_MEAN diff --git a/make/config/jogl/gl-if-CustomJavaCode-es3.java b/make/config/jogl/gl-if-CustomJavaCode-es3.java new file mode 100644 index 000000000..0a1c43085 --- /dev/null +++ b/make/config/jogl/gl-if-CustomJavaCode-es3.java @@ -0,0 +1,14 @@ + +/** Part of GL_ARB_uniform_buffer_object */ +public static final int GL_INVALID_INDEX = 0xFFFFFFFF ; + +/** Part of GL_ARB_sync */ +public static final long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFL ; + +/** Part of GL_ARB_shader_image_load_store */ +public static final int GL_ALL_BARRIER_BITS = 0xFFFFFFFF ; + +public boolean glIsPBOPackEnabled(); + +public boolean glIsPBOUnpackEnabled(); + diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl.java b/make/config/jogl/gl-if-CustomJavaCode-gl.java index 9ea4f98b4..f9f33eec9 100644 --- a/make/config/jogl/gl-if-CustomJavaCode-gl.java +++ b/make/config/jogl/gl-if-CustomJavaCode-gl.java @@ -57,3 +57,11 @@ earmarked for ES 3.0 (hence kept in GL while fixing Bug 590) */ public static final int GL_HALF_FLOAT = 0x140B; + /** Part of GL_VERSION_1_4, GL_ES_VERSION_2_0, GL_OES_required_internalformat. */ + public static final int GL_DEPTH_COMPONENT16 = 0x81A5; + /** Part of GL_VERSION_1_0, GL_OES_element_index_uint, GL_ES_VERSION_2_0 */ + public static final int GL_UNSIGNED_INT = 0x1405; + /** Part of GL_VERSION_1_0, GL_ES_VERSION_2_0 */ + public static final int GL_UNSIGNED_SHORT = 0x1403; + + diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java b/make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java index 4522d34c8..5ad235de5 100644 --- a/make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java +++ b/make/config/jogl/gl-if-CustomJavaCode-gl2_es2.java @@ -39,10 +39,21 @@ *
    Calls void {@native glDepthRange}(GLclampd zNear, GLclampd zFar); if no native implementation is available. */ public void glDepthRangef(float zNear, float zFar); + public void glDepthRange(double zNear, double zFar); + /** Entry point to C language function: * void {@native glClearDepthf}(GLclampf depth); *
    Part of GL_ES_VERSION_2_0 and GL_ARB_ES2_compatibility. *
    Calls void {@native glClearDepth}(GLclampd depth); if no native implementation is available. */ public void glClearDepthf(float depth); + public void glClearDepth( double depth ); + + public void glVertexAttribPointer(GLArrayData array); + + public void glUniform(GLUniformData data); + + /** Part of GL_VERSION_1_0, GL_ES_VERSION_2_0, GL_ANGLE_depth_texture */ + public static final int GL_DEPTH_COMPONENT = 0x1902; + /** End: GL_ARB_ES2_compatibility functions, which are part of ES2 core as well */ diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java b/make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java deleted file mode 100644 index 97fd6c4a6..000000000 --- a/make/config/jogl/gl-if-CustomJavaCode-gl2_gl3.java +++ /dev/null @@ -1,10 +0,0 @@ - -/** Part of GL_ARB_uniform_buffer_object */ -public static final int GL_INVALID_INDEX = 0xFFFFFFFF ; - -/** Part of GL_ARB_sync */ -public static final long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFL ; - -/** Part of GL_ARB_shader_image_load_store */ -public static final int GL_ALL_BARRIER_BITS = 0xFFFFFFFF ; - diff --git a/make/config/jogl/gl-if-CustomJavaCode-gl_compat.java b/make/config/jogl/gl-if-CustomJavaCode-gl_compat.java new file mode 100644 index 000000000..22ae54cbe --- /dev/null +++ b/make/config/jogl/gl-if-CustomJavaCode-gl_compat.java @@ -0,0 +1,20 @@ + +/** + * Part of GL_NV_vertex_array_range. + *

    + * Provides platform-independent access to the wglAllocateMemoryNV / + * glXAllocateMemoryNV. + *

    + */ +public java.nio.ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority); + +/** + * Part of GL_NV_vertex_array_range. + *

    + * Provides platform-independent access to the wglFreeMemoryNV / + * glXFreeMemoryNV. + *

    + */ +public void glFreeMemoryNV(java.nio.ByteBuffer pointer); + + diff --git a/make/config/jogl/gl-if-CustomJavaCode-gles2.java b/make/config/jogl/gl-if-CustomJavaCode-gles2.java deleted file mode 100644 index ea40f6329..000000000 --- a/make/config/jogl/gl-if-CustomJavaCode-gles2.java +++ /dev/null @@ -1,3 +0,0 @@ - - public static final int GL_NVIDIA_PLATFORM_BINARY_NV = 0x890B; - diff --git a/make/config/jogl/gl-if-es2.cfg b/make/config/jogl/gl-if-es2.cfg new file mode 100644 index 000000000..aabd2d5a7 --- /dev/null +++ b/make/config/jogl/gl-if-es2.cfg @@ -0,0 +1,30 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl/es2 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GLES2 +#Extends GLES2 GLBase +#Extends GLES2 GL +Extends GLES2 GL2ES2 +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es2-common.cfg +Include gl2_es2-CustomJavaCode.cfg + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ + +CustomJavaCode GLES2 public static final int GL_NVIDIA_PLATFORM_BINARY_NV = 0x890B; + diff --git a/make/config/jogl/gl-if-gl-ignores.cfg b/make/config/jogl/gl-if-gl-ignores.cfg index 25fbd5a6f..e6513cadb 100644 --- a/make/config/jogl/gl-if-gl-ignores.cfg +++ b/make/config/jogl/gl-if-gl-ignores.cfg @@ -13,6 +13,7 @@ DropUniqVendorExtensions IMG DropUniqVendorExtensions QCOM DropUniqVendorExtensions NV DropUniqVendorExtensions VIV +DropUniqVendorExtensions FJ IgnoreExtension GL_EXT_discard_framebuffer IgnoreExtension GL_OES_compressed_paletted_texture @@ -34,11 +35,14 @@ IgnoreExtension GL_EXT_multisampled_render_to_texture IgnoreExtension GL_EXT_framebuffer_multisample IgnoreExtension GL_OES_texture_half_float IgnoreExtension GL_OES_vertex_half_float -# IgnoreExtension GL_EXT_texture_storage IgnoreExtension GL_NV_draw_buffers IgnoreExtension GL_NV_fbo_color_attachments IgnoreExtension GL_OES_vertex_array_object IgnoreExtension GL_OES_texture_3D +IgnoreExtension GL_OES_surfaceless_context +IgnoreExtension GL_OES_required_internalformat +IgnoreExtension GL_EXT_unpack_subimage +IgnoreExtension GL_KHR_debug # includes GL_STATE_RESTORE, which hasn't the QCOM suffix IgnoreExtension GL_QCOM_extended_get @@ -46,12 +50,8 @@ Ignore GL_STATE_RESTORE # above ext mightbe subsumed, ignore the aliased ones Ignore GL_ACTIVE_PROGRAM -Ignore GL_ALPHA16F -Ignore GL_ALPHA32F -Ignore GL_ALPHA8 Ignore GL_ANY_SAMPLES_PASSED Ignore GL_ANY_SAMPLES_PASSED_CONSERVATIVE -Ignore GL_BGRA8 Ignore GL_BGRA8_EXT Ignore GL_BUFFER_OBJECT_EXT Ignore GL_COLOR_ATTACHMENT1 @@ -93,12 +93,6 @@ Ignore GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING Ignore GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT Ignore GL_INT_10_10_10_2 -Ignore GL_LUMINANCE16F -Ignore GL_LUMINANCE32F -Ignore GL_LUMINANCE8 -Ignore GL_LUMINANCE8_ALPHA8 -Ignore GL_LUMINANCE_ALPHA16F -Ignore GL_LUMINANCE_ALPHA32F Ignore GL_MAX_COLOR_ATTACHMENTS Ignore GL_MAX_DRAW_BUFFERS Ignore GL_PROGRAM_OBJECT_EXT @@ -108,15 +102,15 @@ Ignore GL_PROGRAM_SEPARABLE Ignore GL_QUERY_OBJECT_EXT Ignore GL_QUERY_RESULT Ignore GL_QUERY_RESULT_AVAILABLE +Ignore GL_R32F Ignore GL_R16F Ignore GL_R8 Ignore GL_RED Ignore GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES Ignore GL_RG +Ignore GL_RG32F Ignore GL_RG16F Ignore GL_RG8 -Ignore GL_RGB16F -Ignore GL_RGBA16F Ignore GL_SAMPLER_2D_SHADOW Ignore GL_SAMPLER_EXTERNAL_OES Ignore GL_SHADER_BINARY_DMP @@ -530,13 +524,9 @@ Ignore glFogxvOES Ignore glFramebufferVertexAttribArrayNV Ignore glFrustumf Ignore glFrustumfOES -#Ignore glGenerateMipmap -#Ignore glGenerateMipmapOES Ignore glGetActiveAttrib Ignore glGetActiveUniform Ignore glGetAttachedShaders -Ignore glGetClipPlanef -Ignore glGetClipPlanefOES Ignore glGetFixedv Ignore glGetFixedvOES Ignore glGetLightfv diff --git a/make/config/jogl/gl-if-gl.cfg b/make/config/jogl/gl-if-gl.cfg index 89233330a..4137cae8e 100644 --- a/make/config/jogl/gl-if-gl.cfg +++ b/make/config/jogl/gl-if-gl.cfg @@ -10,8 +10,8 @@ HierarchicalNativeOutput false Include gl-common.cfg Include gl-common-extensions.cfg Include gl-if-gl-ignores.cfg -Include gl-if-gl3-ignores.cfg -Include gl-if-gl4-ignores.cfg +Include gl-if-gl2_es2-ignores.cfg +Include gl-if-luminance-ignore.cfg JavaOutputDir gensrc/classes NativeOutputDir gensrc/native/jogl @@ -27,14 +27,6 @@ ProcAddressTableClassName DontGenerateProcAddressTableStuff GetProcAddressTableExpr DontGenerateProcAddressTableStuff ForceProcAddressGen __ALL__ -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined. -# This also gives a better API doc since it includes all extension names. -GLHeader GLES2/gl2.h -GLHeader GLES2/gl2ext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true diff --git a/make/config/jogl/gl-if-gl2.cfg b/make/config/jogl/gl-if-gl2.cfg index c58b73dfd..60efd73af 100644 --- a/make/config/jogl/gl-if-gl2.cfg +++ b/make/config/jogl/gl-if-gl2.cfg @@ -25,6 +25,8 @@ Include gl-desktop.cfg Include gl-if-gl3-ignores.cfg Include gl-if-gl4-ignores.cfg +IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl_compat.java + # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true @@ -37,8 +39,5 @@ ForceProcAddressGen __ALL__ # Ignore extensions that are already picked up via the GL2ES1 interface IgnoreExtension GL_EXT_point_parameters -CustomJavaCode GL2 public boolean glIsPBOPackEnabled(); -CustomJavaCode GL2 public boolean glIsPBOUnpackEnabled(); - Include gl-headers.cfg diff --git a/make/config/jogl/gl-if-gl2_es1.cfg b/make/config/jogl/gl-if-gl2_es1.cfg index ad8bbea7d..04d78f51e 100644 --- a/make/config/jogl/gl-if-gl2_es1.cfg +++ b/make/config/jogl/gl-if-gl2_es1.cfg @@ -17,6 +17,7 @@ ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/fixedfunc/ HierarchicalNativeOutput false Include gl-common.cfg Include gl-common-extensions.cfg +Include gl-if-luminance-ignore.cfg JavaOutputDir gensrc/classes NativeOutputDir gensrc/native/jogl @@ -39,11 +40,11 @@ IgnoreExtension GL_OES_EGL_image_external IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture IgnoreExtension GL_OES_draw_texture -IgnoreExtension GL_OES_fixed_point IgnoreExtension GL_OES_matrix_get IgnoreExtension GL_OES_point_size_array IgnoreExtension GL_OES_query_matrix IgnoreExtension GL_OES_vertex_half_float +IgnoreExtension GL_OES_matrix_palette IgnoreExtension GL_EXT_debug_marker IgnoreExtension GL_EXT_debug_label @@ -55,11 +56,6 @@ IgnoreExtension GL_QCOM_extended_get Ignore GL_STATE_RESTORE Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET -Ignore glGetFixedv - -# Ignore OES variants of single precision floating point routines -IgnoreExtension GL_OES_single_precision - # Ignore fixed point versions of routines in ES 1.x core Ignore glAlphaFuncx Ignore glClearColorx @@ -68,18 +64,28 @@ Ignore glClipPlanex Ignore glColor4x Ignore glDepthRangex Ignore glFogx +Ignore glFogxv Ignore glFrustumx Ignore glGetClipPlanex +Ignore glGetFixedv +Ignore glGetLightxv +Ignore glGetMaterialxv +Ignore glGetTexEnvxv +Ignore glGetTexParameterxv Ignore glLightModelx +Ignore glLightModelxv Ignore glLightx +Ignore glLightxv Ignore glLineWidthx Ignore glLoadMatrixx Ignore glMaterialx +Ignore glMaterialxv Ignore glMultMatrixx Ignore glMultiTexCoord4x Ignore glNormal3x Ignore glOrthox Ignore glPointParameterx +Ignore glPointParameterxv Ignore glPointSizex Ignore glPolygonOffsetx Ignore glQueryMatrixx @@ -87,21 +93,19 @@ Ignore glRotatex Ignore glSampleCoveragex Ignore glScalex Ignore glTexEnvx +Ignore glTexEnvxv Ignore glTexGenx Ignore glTexParameterx +Ignore glTexParameterxv Ignore glTranslatex #heavy float/double array diff to GL2 Ignore glClipPlanef Ignore ^glGetClipPlanef(OES)? - + #impl diff Ignore ^glEGL.* -Ignore ^gl.*(xv)(OES)? -Ignore glTexGenxOES Ignore GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES -Ignore glLoadPaletteFromModelViewMatrixOES -Ignore glGetFixedv CustomJavaCode GL2ES1 public void glOrtho(double left, double right, double bottom, double top, double near_val, double far_val); CustomJavaCode GL2ES1 public void glFrustum(double left, double right, double bottom, double top, double zNear, double zFar); @@ -112,13 +116,6 @@ ProcAddressTableClassName DontGenerateProcAddressTableStuff GetProcAddressTableExpr DontGenerateProcAddressTableStuff ForceProcAddressGen __ALL__ -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GLES/gl.h -GLHeader GLES/glext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true diff --git a/make/config/jogl/gl-if-gl2_es2-ignores.cfg b/make/config/jogl/gl-if-gl2_es2-ignores.cfg new file mode 100644 index 000000000..f08d8a51b --- /dev/null +++ b/make/config/jogl/gl-if-gl2_es2-ignores.cfg @@ -0,0 +1,48 @@ +# Ignore all ES 2.X only stuff .. +DropUniqVendorExtensions ANGLE +DropUniqVendorExtensions ARM +DropUniqVendorExtensions APPLE +DropUniqVendorExtensions ATI +DropUniqVendorExtensions IMG +DropUniqVendorExtensions QCOM +DropUniqVendorExtensions NV +DropUniqVendorExtensions VIV + +Ignore glEGL.* + +IgnoreExtension GL_AMD_compressed_3DC_texture +IgnoreExtension GL_AMD_compressed_ATC_texture +IgnoreExtension GL_AMD_program_binary_Z400 +IgnoreExtension GL_AMD_performance_monitor + +IgnoreExtension GL_KHR_texture_compression_astc_ldr +IgnoreExtension GL_ANGLE_depth_texture +IgnoreExtension GL_ANGLE_instanced_arrays +IgnoreExtension GL_ANGLE_pack_reverse_row_order +IgnoreExtension GL_ANGLE_program_binary +IgnoreExtension GL_ANGLE_texture_compression_dxt3 +IgnoreExtension GL_ANGLE_texture_compression_dxt5 +IgnoreExtension GL_ANGLE_texture_usage +IgnoreExtension GL_ANGLE_translated_shader_source +IgnoreExtension GL_EXT_debug_label +IgnoreExtension GL_EXT_debug_marker +IgnoreExtension GL_EXT_discard_framebuffer +IgnoreExtension GL_EXT_disjoint_timer_query +IgnoreExtension GL_EXT_draw_buffers +IgnoreExtension GL_EXT_multiview_draw_buffers +IgnoreExtension GL_EXT_multisampled_render_to_texture +IgnoreExtension GL_EXT_shader_framebuffer_fetch +IgnoreExtension GL_FJ_shader_binary_GCCSO +IgnoreExtension GL_OES_compressed_paletted_texture +IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture +IgnoreExtension GL_OES_vertex_array_object +IgnoreExtension GL_OES_vertex_half_float +IgnoreExtension GL_OES_surfaceless_context +IgnoreExtension GL_OES_texture_half_float +IgnoreExtension GL_OES_EGL_image_external + +# includes GL_STATE_RESTORE, which hasn't the QCOM suffix +IgnoreExtension GL_QCOM_extended_get +Ignore GL_STATE_RESTORE + +Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET diff --git a/make/config/jogl/gl-if-gl2_es2.cfg b/make/config/jogl/gl-if-gl2_es2.cfg index 85e799298..0ad140eb2 100644 --- a/make/config/jogl/gl-if-gl2_es2.cfg +++ b/make/config/jogl/gl-if-gl2_es2.cfg @@ -14,45 +14,9 @@ Extends GL2ES2 GL HierarchicalNativeOutput false Include gl-common.cfg Include gl-common-extensions.cfg -Include gl-if-gl3-ignores.cfg -Include gl-if-gl4-ignores.cfg - -RenameExtensionIntoCore GL_OES_texture_3D -RenameExtensionIntoCore GL_OES_get_program_binary - -# Ignore all ES 2.X only stuff .. -DropUniqVendorExtensions AMD -DropUniqVendorExtensions ANGLE -DropUniqVendorExtensions ARM -DropUniqVendorExtensions APPLE -DropUniqVendorExtensions ATI -DropUniqVendorExtensions IMG -DropUniqVendorExtensions QCOM -DropUniqVendorExtensions NV -DropUniqVendorExtensions VIV - -IgnoreExtension GL_EXT_discard_framebuffer -IgnoreExtension GL_OES_compressed_paletted_texture -IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture -IgnoreExtension GL_OES_vertex_array_object -IgnoreExtension GL_OES_texture_half_float -IgnoreExtension GL_OES_vertex_half_float -IgnoreExtension GL_OES_EGL_image_external -IgnoreExtension GL_EXT_debug_marker -IgnoreExtension GL_EXT_debug_label -IgnoreExtension GL_EXT_multisampled_render_to_texture - -# isn't included in GL2 -# includes GL_STATE_RESTORE, which hasn't the QCOM suffix -IgnoreExtension GL_QCOM_extended_get -Ignore GL_STATE_RESTORE -Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET - -# Ignore ^gl.*x(v)?(OES)? -Ignore glEGL.* -#Ignore glFramebufferVertexAttribArrayNV -#Ignore glCoverageOperationNV -#Ignore glCoverageMaskNV +Include gl2_es2-common.cfg +Include gl-if-gl2_es2-ignores.cfg +Include gl-if-luminance-ignore.cfg # Ignore GL_ARB_ES2_compatibility functions for interface code generation # since we need our own javadoc header for a detailed description @@ -62,9 +26,6 @@ Ignore glGetShaderPrecisionFormat Ignore glDepthRangef Ignore glClearDepthf -CustomJavaCode GL2ES2 public void glClearDepth( double depth ); -CustomJavaCode GL2ES2 public void glDepthRange(double zNear, double zFar); - IncludeAs CustomJavaCode GL2ES2 gl-if-CustomJavaCode-gl2_es2.java # dummy procaddress config / force procaddress for comments @@ -73,20 +34,8 @@ ProcAddressTableClassName DontGenerateProcAddressTableStuff GetProcAddressTableExpr DontGenerateProcAddressTableStuff ForceProcAddressGen __ALL__ -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -# This also gives a better API doc since it includes all extension names. -GLHeader GLES2/gl2.h -GLHeader GLES2/gl2ext.h -GLHeader GL/gl.h -GLHeader GL/glext.h - # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true -CustomJavaCode GL2ES2 public void glVertexAttribPointer(GLArrayData array); -CustomJavaCode GL2ES2 public void glUniform(GLUniformData data); -CustomJavaCode GL2ES2 - Import java.io.PrintStream diff --git a/make/config/jogl/gl-if-gl2_es3-ignores.cfg b/make/config/jogl/gl-if-gl2_es3-ignores.cfg new file mode 100644 index 000000000..172857840 --- /dev/null +++ b/make/config/jogl/gl-if-gl2_es3-ignores.cfg @@ -0,0 +1,47 @@ +# Ignore all ES 3.X only stuff .. +DropUniqVendorExtensions ANGLE +DropUniqVendorExtensions ARM +DropUniqVendorExtensions APPLE +DropUniqVendorExtensions ATI +DropUniqVendorExtensions IMG +DropUniqVendorExtensions QCOM +DropUniqVendorExtensions NV +DropUniqVendorExtensions VIV + +Ignore glEGL.* + +IgnoreExtension GL_AMD_compressed_3DC_texture +IgnoreExtension GL_AMD_compressed_ATC_texture +IgnoreExtension GL_AMD_program_binary_Z400 +IgnoreExtension GL_AMD_performance_monitor + +IgnoreExtension GL_ANGLE_depth_texture +IgnoreExtension GL_ANGLE_instanced_arrays +IgnoreExtension GL_ANGLE_pack_reverse_row_order +IgnoreExtension GL_ANGLE_program_binary +IgnoreExtension GL_ANGLE_texture_compression_dxt3 +IgnoreExtension GL_ANGLE_texture_compression_dxt5 +IgnoreExtension GL_ANGLE_texture_usage +IgnoreExtension GL_ANGLE_translated_shader_source +IgnoreExtension GL_EXT_debug_label +IgnoreExtension GL_EXT_debug_marker +IgnoreExtension GL_EXT_discard_framebuffer +IgnoreExtension GL_EXT_disjoint_timer_query +IgnoreExtension GL_EXT_draw_buffers +IgnoreExtension GL_EXT_multisampled_render_to_texture +IgnoreExtension GL_EXT_multiview_draw_buffers +IgnoreExtension GL_EXT_shader_framebuffer_fetch +IgnoreExtension GL_OES_compressed_paletted_texture +IgnoreExtension GL_OES_compressed_ETC1_RGB8_texture +IgnoreExtension GL_OES_vertex_array_object +IgnoreExtension GL_OES_vertex_half_float +IgnoreExtension GL_OES_surfaceless_context +IgnoreExtension GL_OES_texture_half_float +IgnoreExtension GL_OES_EGL_image_external +IgnoreExtension GL_FJ_shader_binary_GCCSO + +# includes GL_STATE_RESTORE, which hasn't the QCOM suffix +IgnoreExtension GL_QCOM_extended_get +Ignore GL_STATE_RESTORE + +Ignore GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET diff --git a/make/config/jogl/gl-if-gl2_es3.cfg b/make/config/jogl/gl-if-gl2_es3.cfg new file mode 100644 index 000000000..f44c9b393 --- /dev/null +++ b/make/config/jogl/gl-if-gl2_es3.cfg @@ -0,0 +1,45 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL2ES3 +#Extends GL2ES3 GLBase +#Extends GL2ES3 GL +Extends GL2ES3 GL2ES2 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2ES2.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +ExtendedInterfaceSymbolsOnly ../build-temp/gluegen-set/javax/media/opengl/GL2ES3Subset.java + +HierarchicalNativeOutput false +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl-if-gl2_es3-ignores.cfg +Include gl-if-gl4-ignores.cfg +Include gl-if-luminance-ignore.cfg + +IncludeAs CustomJavaCode GL2ES3 gl-if-CustomJavaCode-es3.java + +# +# Same name but different signature .. +# No collisions found .. good! + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to APIENTRY +LocalProcAddressCallingConvention __ALL__ APIENTRY + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +Import java.io.PrintStream diff --git a/make/config/jogl/gl-if-gl2_gl3.cfg b/make/config/jogl/gl-if-gl2_gl3.cfg index 0c51dfe9c..467919328 100644 --- a/make/config/jogl/gl-if-gl2_gl3.cfg +++ b/make/config/jogl/gl-if-gl2_gl3.cfg @@ -4,21 +4,23 @@ Style InterfaceOnly JavaClass GL2GL3 #Extends GL2GL3 GLBase #Extends GL2GL3 GL -Extends GL2GL3 GL2ES2 +#Extends GL2GL3 GL2ES2 +Extends GL2GL3 GL2ES3 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/GL2ES3.java ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java -ExtendedInterfaceSymbolsOnly ../build-temp/gluegen-set/javax/media/opengl/GL3Subset.java +ExtendedInterfaceSymbolsOnly ../build-temp/gluegen-set/javax/media/opengl/GL2GL3Subset.java HierarchicalNativeOutput false Include gl-common.cfg Include gl-common-extensions.cfg Include gl-desktop.cfg +Include gl3-common.cfg Include gl-if-gl4-ignores.cfg - -IncludeAs CustomJavaCode GL2GL3 gl-if-CustomJavaCode-gl2_gl3.java +Include gl-if-luminance-ignore.cfg JavaOutputDir gensrc/classes NativeOutputDir gensrc/native/jogl @@ -33,11 +35,6 @@ ProcAddressTableClassName DontGenerateProcAddressTableStuff GetProcAddressTableExpr DontGenerateProcAddressTableStuff ForceProcAddressGen __ALL__ -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GL/gl.h -GLHeader GL/glext.h - # Also force the calling conventions of the locally generated function # pointer typedefs for these routines to APIENTRY LocalProcAddressCallingConvention __ALL__ APIENTRY diff --git a/make/config/jogl/gl-if-gl2es3-subset.cfg b/make/config/jogl/gl-if-gl2es3-subset.cfg new file mode 100644 index 000000000..3e325e065 --- /dev/null +++ b/make/config/jogl/gl-if-gl2es3-subset.cfg @@ -0,0 +1,17 @@ +# This .cfg file is used to generate the common GL2 ES3 set +JavaOutputDir ../../build-temp/gluegen-set + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL2ES3Subset +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl-if-gl3-ignores.cfg +Include gl-if-gl4-ignores.cfg + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ diff --git a/make/config/jogl/gl-if-gl2gl3-subset.cfg b/make/config/jogl/gl-if-gl2gl3-subset.cfg new file mode 100644 index 000000000..ecb384ca3 --- /dev/null +++ b/make/config/jogl/gl-if-gl2gl3-subset.cfg @@ -0,0 +1,18 @@ +# This .cfg file is used to generate the common GL2 GL3 set +JavaOutputDir ../../build-temp/gluegen-set + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL2GL3Subset +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl3-desktop.cfg +Include gl3-common.cfg +Include gl-if-gl3-ignores.cfg +Include gl-if-gl4-ignores.cfg + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ diff --git a/make/config/jogl/gl-if-gl3-subset.cfg b/make/config/jogl/gl-if-gl3-subset.cfg deleted file mode 100644 index dae38ec0c..000000000 --- a/make/config/jogl/gl-if-gl3-subset.cfg +++ /dev/null @@ -1,17 +0,0 @@ -# This .cfg file is used to generate the common GL2 GL3 set -JavaOutputDir ../../build-temp/gluegen-set - -Package javax.media.opengl -Style InterfaceOnly -JavaClass GL3Subset -Include gl-common.cfg -Include gl-common-extensions.cfg -Include gl3-desktop.cfg -Include gl-if-gl3-ignores.cfg -Include gl-if-gl4-ignores.cfg - -# dummy procaddress config / force procaddress for comments -EmitProcAddressTable false -ProcAddressTableClassName DontGenerateProcAddressTableStuff -GetProcAddressTableExpr DontGenerateProcAddressTableStuff -ForceProcAddressGen __ALL__ diff --git a/make/config/jogl/gl-if-gl3.cfg b/make/config/jogl/gl-if-gl3.cfg index 649b35165..09f51d6b0 100644 --- a/make/config/jogl/gl-if-gl3.cfg +++ b/make/config/jogl/gl-if-gl3.cfg @@ -4,6 +4,8 @@ NativeOutputDir gensrc/native/jogl/gl3 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/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL2GL3.java ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java @@ -13,16 +15,14 @@ JavaClass GL3 #Extends GL3 GLBase #Extends GL3 GL #Extends GL3 GL2ES2 +#Extends GL3 GL2ES3 +Extends GL3 GL3ES3 Extends GL3 GL2GL3 ImplPackage jogamp.opengl.gl3 -ImplJavaClass GL3Impl -Implements GL3Impl GLBase -Implements GL3Impl GL -Implements GL3Impl GL2ES2 -Implements GL3Impl GL2GL3 Include gl-common.cfg Include gl-common-extensions.cfg Include gl3-desktop.cfg +Include gl3-common.cfg Include gl-if-gl4-ignores.cfg # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums diff --git a/make/config/jogl/gl-if-gl3_es3.cfg b/make/config/jogl/gl-if-gl3_es3.cfg new file mode 100644 index 000000000..a25d9112a --- /dev/null +++ b/make/config/jogl/gl-if-gl3_es3.cfg @@ -0,0 +1,43 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL3ES3 +#Extends GL3ES3 GLBase +#Extends GL3ES3 GL +#Extends GL3ES3 GL2ES2 +Extends GL3ES3 GL2ES3 + +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/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +HierarchicalNativeOutput false +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl-if-gl2_es3-ignores.cfg +Include gl-if-gl4-ignores.cfg +Include gl-if-luminance-ignore.cfg + +# +# Same name but different signature .. +# No collisions found .. good! + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to APIENTRY +LocalProcAddressCallingConvention __ALL__ APIENTRY + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +Import java.io.PrintStream diff --git a/make/config/jogl/gl-if-gl3bc.cfg b/make/config/jogl/gl-if-gl3bc.cfg index f07a9a417..bca3d61e6 100644 --- a/make/config/jogl/gl-if-gl3bc.cfg +++ b/make/config/jogl/gl-if-gl3bc.cfg @@ -5,6 +5,8 @@ NativeOutputDir gensrc/native/jogl/gl3 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/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.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 @@ -20,6 +22,8 @@ JavaClass GL3bc #Extends GL3bc GL #Extends GL3bc GL2ES1 #Extends GL3bc GL2ES2 +#Extends GL3bc GL2ES3 +#Extends GL3bc GL3ES3 #Extends GL3bc GL2GL3 Extends GL3bc GL2 Extends GL3bc GL3 @@ -30,6 +34,8 @@ Include gl-desktop.cfg Include gl3-desktop.cfg Include gl-if-gl4-ignores.cfg +IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl_compat.java + # Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums TagNativeBinding true diff --git a/make/config/jogl/gl-if-gl4-ignores.cfg b/make/config/jogl/gl-if-gl4-ignores.cfg index 4948b64df..619c82924 100644 --- a/make/config/jogl/gl-if-gl4-ignores.cfg +++ b/make/config/jogl/gl-if-gl4-ignores.cfg @@ -9,5 +9,7 @@ IgnoreExtension GL_VERSION_4_0 IgnoreExtension GL_VERSION_4_1 IgnoreExtension GL_VERSION_4_2 +IgnoreExtension GL_VERSION_4_3 +IgnoreExtension GL_VERSION_4_4 IgnoreExtension GL_ARB_shader_precision diff --git a/make/config/jogl/gl-if-gl4.cfg b/make/config/jogl/gl-if-gl4.cfg index 1e920ac7c..4b19b448e 100644 --- a/make/config/jogl/gl-if-gl4.cfg +++ b/make/config/jogl/gl-if-gl4.cfg @@ -4,6 +4,9 @@ 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/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL4ES3.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 @@ -14,11 +17,15 @@ JavaClass GL4 #Extends GL4 GLBase #Extends GL4 GL #Extends GL4 GL2ES2 +#Extends GL4 GL2ES3 +#Extends GL4 GL3ES3 #Extends GL4 GL2GL3 +Extends GL4 GL4ES3 Extends GL4 GL3 Include gl-common.cfg Include gl-common-extensions.cfg Include gl3-desktop.cfg +Include gl3-common.cfg # dummy procaddress config / force procaddress for comments EmitProcAddressTable false diff --git a/make/config/jogl/gl-if-gl4_es3.cfg b/make/config/jogl/gl-if-gl4_es3.cfg new file mode 100644 index 000000000..cd9c17f27 --- /dev/null +++ b/make/config/jogl/gl-if-gl4_es3.cfg @@ -0,0 +1,47 @@ +# This .cfg file is used to generate the GL interface and implementing class. +JavaOutputDir gensrc/classes +NativeOutputDir gensrc/native/jogl + +Package javax.media.opengl +Style InterfaceOnly +JavaClass GL4ES3 +#Extends GL4ES3 GLBase +#Extends GL4ES3 GL +#Extends GL4ES3 GL2ES2 +#Extends GL4ES3 GL2ES3 +Extends GL4ES3 GL3ES3 + +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/GL2ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3ES3.java +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/javax/media/opengl/GL3.java +ExtendedInterfaceSymbolsIgnore ../src/jogl/classes/javax/media/opengl/GLBase.java + +HierarchicalNativeOutput false +Include gl-common.cfg +Include gl-common-extensions.cfg +Include gl2_es3-common.cfg +Include gl-if-gl2_es3-ignores.cfg +Include gl-if-luminance-ignore.cfg + +ForceExtension GL_ARB_ES3_compatibility + +# +# Same name but different signature .. +# No collisions found .. good! + +# dummy procaddress config / force procaddress for comments +EmitProcAddressTable false +ProcAddressTableClassName DontGenerateProcAddressTableStuff +GetProcAddressTableExpr DontGenerateProcAddressTableStuff +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to APIENTRY +LocalProcAddressCallingConvention __ALL__ APIENTRY + +# Pick up on-line OpenGL javadoc thanks to user cylab on javagaming.org forums +TagNativeBinding true + +Import java.io.PrintStream diff --git a/make/config/jogl/gl-if-luminance-ignore.cfg b/make/config/jogl/gl-if-luminance-ignore.cfg new file mode 100644 index 000000000..4fb79fae9 --- /dev/null +++ b/make/config/jogl/gl-if-luminance-ignore.cfg @@ -0,0 +1,7 @@ +Ignore GL_LUMINANCE16F +Ignore GL_LUMINANCE32F +Ignore GL_LUMINANCE_ALPHA16F +Ignore GL_LUMINANCE_ALPHA32F +Ignore GL_LUMINANCE4_ALPHA4 +Ignore GL_LUMINANCE8 +Ignore GL_LUMINANCE8_ALPHA8 diff --git a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c index d389db298..4ddc27bf2 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c +++ b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c @@ -13,6 +13,22 @@ Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unu return (jlong) (intptr_t) _res; } +/* Java->C glue code: + * Java package: jogamp.opengl.gl4.GL4bcImpl + * Java method: java.nio.ByteBuffer dispatch_glMapBufferRange(int target, long offset, long length, int access) + * C function: void * glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + */ +JNIEXPORT jlong JNICALL +Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glMapBufferRange(JNIEnv *env, jobject _unused, jint target, jlong offset, jlong length, jint access, jlong procAddress) { + typedef void * (APIENTRY*_local_PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + _local_PFNGLMAPBUFFERRANGEPROC ptr_glMapBufferRange; + void * _res; + ptr_glMapBufferRange = (_local_PFNGLMAPBUFFERRANGEPROC) (intptr_t) procAddress; + assert(ptr_glMapBufferRange != NULL); + _res = (* ptr_glMapBufferRange) ((GLenum) target, (GLintptr) offset, (GLsizeiptr) length, (GLbitfield) access); + return (jlong) (intptr_t) _res; +} + /* Java->C glue code: * Java package: jogamp.opengl.gl4.GL4bcImpl * Java method: long dispatch_glMapNamedBufferEXT(int target, int access) diff --git a/make/config/jogl/gl-impl-CustomCCode-gles1.c b/make/config/jogl/gl-impl-CustomCCode-gles1.c index 0155c13f8..88cfe4418 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gles1.c +++ b/make/config/jogl/gl-impl-CustomCCode-gles1.c @@ -14,6 +14,22 @@ Java_jogamp_opengl_es1_GLES1Impl_dispatch_1glMapBuffer(JNIEnv *env, jobject _unu return (jlong) (intptr_t) _res; } +/* Java->C glue code: + * Java package: jogamp.opengl.es1.GLES1Impl + * Java method: java.nio.ByteBuffer dispatch_glMapBufferRange(int target, long offset, long length, int access) + * C function: void * glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + */ +JNIEXPORT jlong JNICALL +Java_jogamp_opengl_es1_GLES1Impl_dispatch_1glMapBufferRange(JNIEnv *env, jobject _unused, jint target, jlong offset, jlong length, jint access, jlong procAddress) { + typedef void * (GL_APIENTRY*_local_PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + _local_PFNGLMAPBUFFERRANGEPROC ptr_glMapBufferRange; + void * _res; + ptr_glMapBufferRange = (_local_PFNGLMAPBUFFERRANGEPROC) (intptr_t) procAddress; + assert(ptr_glMapBufferRange != NULL); + _res = (* ptr_glMapBufferRange) ((GLenum) target, (GLintptr) offset, (GLsizeiptr) length, (GLbitfield) access); + return (jlong) (intptr_t) _res; +} + /* Java->C glue code: * Java package: jogamp.opengl.es1.GLES1Impl * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); diff --git a/make/config/jogl/gl-impl-CustomCCode-gles2.c b/make/config/jogl/gl-impl-CustomCCode-gles2.c deleted file mode 100644 index e140df76b..000000000 --- a/make/config/jogl/gl-impl-CustomCCode-gles2.c +++ /dev/null @@ -1,25 +0,0 @@ -typedef GLvoid* (GL_APIENTRY* PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -/* Java->C glue code: - * Java package: jogamp.opengl.es2.GLES2Impl - * Java method: long dispatch_glMapBuffer(int target, int access) - * C function: void * glMapBuffer(GLenum target, GLenum access); - */ -JNIEXPORT jlong JNICALL -Java_jogamp_opengl_es2_GLES2Impl_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: jogamp.opengl.es2.GLES2Impl - * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); - * C function: jobject newDirectByteBuffer(jlong addr, jlong capacity); - */ -JNIEXPORT jobject JNICALL -Java_jogamp_opengl_es2_GLES2Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jlong capacity) { - return (*env)->NewDirectByteBuffer(env, (void*) (intptr_t) addr, capacity); -} diff --git a/make/config/jogl/gl-impl-CustomCCode-gles3.c b/make/config/jogl/gl-impl-CustomCCode-gles3.c new file mode 100644 index 000000000..2f3329bfa --- /dev/null +++ b/make/config/jogl/gl-impl-CustomCCode-gles3.c @@ -0,0 +1,41 @@ +typedef GLvoid* (GL_APIENTRY* PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +/* Java->C glue code: + * Java package: jogamp.opengl.es3.GLES3Impl + * Java method: long dispatch_glMapBuffer(int target, int access) + * C function: void * glMapBuffer(GLenum target, GLenum access); + */ +JNIEXPORT jlong JNICALL +Java_jogamp_opengl_es3_GLES3Impl_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: jogamp.opengl.es3.GLES3Impl + * Java method: java.nio.ByteBuffer dispatch_glMapBufferRange(int target, long offset, long length, int access) + * C function: void * glMapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + */ +JNIEXPORT jlong JNICALL +Java_jogamp_opengl_es3_GLES3Impl_dispatch_1glMapBufferRange(JNIEnv *env, jobject _unused, jint target, jlong offset, jlong length, jint access, jlong procAddress) { + typedef void * (GL_APIENTRY*_local_PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); + _local_PFNGLMAPBUFFERRANGEPROC ptr_glMapBufferRange; + void * _res; + ptr_glMapBufferRange = (_local_PFNGLMAPBUFFERRANGEPROC) (intptr_t) procAddress; + assert(ptr_glMapBufferRange != NULL); + _res = (* ptr_glMapBufferRange) ((GLenum) target, (GLintptr) offset, (GLsizeiptr) length, (GLbitfield) access); + return (jlong) (intptr_t) _res; +} + +/* Java->C glue code: + * Java package: jogamp.opengl.es3.GLES3Impl + * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); + * C function: jobject newDirectByteBuffer(jlong addr, jlong capacity); + */ +JNIEXPORT jobject JNICALL +Java_jogamp_opengl_es3_GLES3Impl_newDirectByteBuffer(JNIEnv *env, jobject _unused, jlong addr, jlong 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 8e8165fff..4024d8e1a 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -118,3 +118,95 @@ return _context.getDefaultReadBuffer(); } + private final HashMap arbMemCache = new HashMap(); + + /** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
    Part of GL_VERSION_1_5; GL_OES_mapbuffer */ + private final java.nio.ByteBuffer glMapBufferImpl(int target, boolean useRange, long offset, long length, int access, long glProcAddress) { + if (glProcAddress == 0) { + throw new GLException("Method \""+(useRange?"glMapBufferRange":"glMapBuffer")+"\" not available"); + } + final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); + if (0 == sz) { + return null; + } + if( !useRange ) { + length = sz; + offset = 0; + } else { + if( length + offset > sz ) { + throw new GLException("Out of range: offset "+offset+" + length "+length+" > size "+sz); + } + if( 0 > length || 0 > offset ) { + throw new GLException("Invalid values: offset "+offset+", length "+length); + } + if( 0 == length ) { + return null; + } + } + final long addr = useRange ? dispatch_glMapBufferRange(target, offset, length, access, glProcAddress) : + dispatch_glMapBuffer(target, access, glProcAddress); + if (0 == addr) { + return null; + } + ByteBuffer buffer; + MemoryObject memObj0 = new MemoryObject(addr, length); // object and key + MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); + if(memObj0 == memObj1) { + // just added .. + if(null != memObj0.getBuffer()) { + throw new InternalError(); + } + buffer = newDirectByteBuffer(addr, length); + Buffers.nativeOrder(buffer); + memObj0.setBuffer(buffer); + } else { + // already mapped + buffer = memObj1.getBuffer(); + if(null == buffer) { + throw new InternalError(); + } + } + buffer.position(0); + return buffer; + } + private native long dispatch_glMapBuffer(int target, int access, long glProcAddress); + private native long dispatch_glMapBufferRange(int target, long offset, long length, int access, long procAddress); + + + /** Entry point to C language function: GLvoid * {@native glMapNamedBufferEXT}(GLuint buffer, GLenum access);
    Part of GL_EXT_direct_state_access */ + private final java.nio.ByteBuffer glMapNamedBufferImpl(int bufferName, int access, long glProcAddress) { + if (glProcAddress == 0) { + throw new GLException("Method \"glMapNamedBufferEXT\" not available"); + } + final long sz = bufferSizeTracker.getDirectStateBufferSize(bufferName, this); + if (0 == sz) { + return null; + } + final long addr = dispatch_glMapNamedBufferEXT(bufferName, access, glProcAddress); + if (0 == addr) { + return null; + } + ByteBuffer buffer; + MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key + MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); + if(memObj0 == memObj1) { + // just added .. + if(null != memObj0.getBuffer()) { + throw new InternalError(); + } + buffer = newDirectByteBuffer(addr, sz); + Buffers.nativeOrder(buffer); + memObj0.setBuffer(buffer); + } else { + // already mapped + buffer = memObj1.getBuffer(); + if(null == buffer) { + throw new InternalError(); + } + } + buffer.position(0); + return buffer; + } + private native long dispatch_glMapNamedBufferEXT(int buffer, int access, long procAddress); + + private native ByteBuffer newDirectByteBuffer(long addr, long capacity); diff --git a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java b/make/config/jogl/gl-impl-CustomJavaCode-desktop.java deleted file mode 100644 index 6a74b80a6..000000000 --- a/make/config/jogl/gl-impl-CustomJavaCode-desktop.java +++ /dev/null @@ -1,148 +0,0 @@ - private int[] imageSizeTemp = new int[1]; - - private final int imageSizeInBytes(int format, int type, int width, int height, int depth, boolean pack) { - return GLBuffers.sizeof(this, imageSizeTemp, format, type, width, height, depth, pack) ; - } - - @Override - public final boolean isGL4bc() { - return _context.isGL4bc(); - } - - @Override - public final boolean isGL4() { - return _context.isGL4(); - } - - @Override - public final boolean isGL3bc() { - return _context.isGL3bc(); - } - - @Override - public final boolean isGL3() { - return _context.isGL3(); - } - - @Override - public final boolean isGL2() { - return _context.isGL2(); - } - - @Override - public final boolean isGL2ES1() { - return _context.isGL2ES1(); - } - - @Override - public final boolean isGL2ES2() { - return _context.isGL2ES2(); - } - - @Override - public final boolean isGLES2Compatible() { - return _context.isGLES2Compatible(); - } - - public final boolean isGL2GL3() { - return _context.isGL2GL3(); - } - - @Override - public final boolean hasGLSL() { - return _context.hasGLSL(); - } - - @Override - public final GL4bc getGL4bc() throws GLException { - if(!isGL4bc()) { - throw new GLException("Not a GL4bc implementation"); - } - return this; - } - - @Override - public final GL4 getGL4() throws GLException { - if(!isGL4()) { - throw new GLException("Not a GL4 implementation"); - } - return this; - } - - @Override - public final GL3bc getGL3bc() throws GLException { - if(!isGL3bc()) { - throw new GLException("Not a GL3bc implementation"); - } - return this; - } - - @Override - public final GL3 getGL3() throws GLException { - if(!isGL3()) { - throw new GLException("Not a GL3 implementation"); - } - return this; - } - - @Override - public final GL2 getGL2() throws GLException { - if(!isGL2()) { - throw new GLException("Not a GL2 implementation"); - } - return this; - } - - @Override - public final GL2ES1 getGL2ES1() throws GLException { - if(!isGL2ES1()) { - throw new GLException("Not a GL2ES1 implementation"); - } - return this; - } - - @Override - public final GL2ES2 getGL2ES2() throws GLException { - if(!isGL2ES2()) { - throw new GLException("Not a GL2ES2 implementation"); - } - return this; - } - - @Override - public final GL2GL3 getGL2GL3() throws GLException { - if(!isGL2GL3()) { - throw new GLException("Not a GL2GL3 implementation"); - } - return this; - } - - @Override - public final boolean isGLES1() { - return false; - } - - @Override - public final boolean isGLES2() { - return false; - } - - @Override - public final boolean isGLES() { - return false; - } - - @Override - public final GLES1 getGLES1() throws GLException { - throw new GLException("Not a GLES1 implementation"); - } - - @Override - public final GLES2 getGLES2() throws GLException { - throw new GLException("Not a GLES2 implementation"); - } - - @Override - public final boolean isNPOTTextureAvailable() { - return _context.isNPOTTextureAvailable(); - } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index fbe7484c4..cacea322a 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -29,12 +29,223 @@ public GL4bcImpl(GLProfile glp, GLContextImpl context) { this.glProfile = glp; } -/** - * Provides platform-independent access to the wglAllocateMemoryNV / - * glXAllocateMemoryNV extension. - */ -public final java.nio.ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { - return _context.glAllocateMemoryNV(arg0, arg1, arg2, arg3); +public final void finalizeInit() { + if(null != _context) { + 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"); + haveARBVertexArrayObject = _context.getGLVersionNumber().compareTo(GLContext.Version300) >= 0 || + isExtensionAvailable("GL_ARB_vertex_array_object"); + } else { + haveARBPixelBufferObject = false; + haveEXTPixelBufferObject = false; + haveGL15 = false; + haveGL21 = false; + haveARBVertexBufferObject = false; + haveARBVertexArrayObject = false; + } +} + +private int[] imageSizeTemp = new int[1]; + +private final int imageSizeInBytes(int format, int type, int width, int height, int depth, boolean pack) { + return GLBuffers.sizeof(this, imageSizeTemp, format, type, width, height, depth, pack) ; +} + +@Override +public final boolean isGL4bc() { + return _context.isGL4bc(); +} + +@Override +public final boolean isGL4() { + return _context.isGL4(); +} + +@Override +public final boolean isGL3bc() { + return _context.isGL3bc(); +} + +@Override +public final boolean isGL3() { + return _context.isGL3(); +} + +@Override +public final boolean isGL2() { + return _context.isGL2(); +} + +@Override +public final boolean isGL2ES1() { + return _context.isGL2ES1(); +} + +@Override +public final boolean isGL2ES2() { + return _context.isGL2ES2(); +} + +@Override +public final boolean isGL3ES3() { + return _context.isGL3ES3(); +} + +@Override +public final boolean isGL4ES3() { + return _context.isGL4ES3(); +} + +@Override +public final boolean isGLES2Compatible() { + return _context.isGLES2Compatible(); +} + +@Override +public final boolean isGLES3Compatible() { + return _context.isGLES3Compatible(); +} + +@Override +public final boolean isGL2GL3() { + return _context.isGL2GL3(); +} + +@Override +public final boolean hasGLSL() { + return _context.hasGLSL(); +} + +@Override +public final GL4bc getGL4bc() throws GLException { + if(!isGL4bc()) { + throw new GLException("Not a GL4bc implementation"); + } + return this; +} + +@Override +public final GL4 getGL4() throws GLException { + if(!isGL4()) { + throw new GLException("Not a GL4 implementation"); + } + return this; +} + +@Override +public final GL3bc getGL3bc() throws GLException { + if(!isGL3bc()) { + throw new GLException("Not a GL3bc implementation"); + } + return this; +} + +@Override +public final GL3 getGL3() throws GLException { + if(!isGL3()) { + throw new GLException("Not a GL3 implementation"); + } + return this; +} + +@Override +public final GL2 getGL2() throws GLException { + if(!isGL2()) { + throw new GLException("Not a GL2 implementation"); + } + return this; +} + +@Override +public final GL2ES1 getGL2ES1() throws GLException { + if(!isGL2ES1()) { + throw new GLException("Not a GL2ES1 implementation"); + } + return this; +} + +@Override +public final GL2ES2 getGL2ES2() throws GLException { + if(!isGL2ES2()) { + throw new GLException("Not a GL2ES2 implementation"); + } + return this; +} + +@Override +public final GL3ES3 getGL3ES3() throws GLException { + if(!isGL3ES3()) { + throw new GLException("Not a GL3ES3 implementation"); + } + return this; +} + +@Override +public final GL4ES3 getGL4ES3() throws GLException { + if(!isGL4ES3()) { + throw new GLException("Not a GL4ES3 implementation"); + } + return this; +} + +@Override +public final GL2GL3 getGL2GL3() throws GLException { + if(!isGL2GL3()) { + throw new GLException("Not a GL2GL3 implementation"); + } + return this; +} + +@Override +public final boolean isGLES1() { + return false; +} + +@Override +public final boolean isGLES2() { + return false; +} + +@Override +public final boolean isGLES3() { + return false; +} + +@Override +public final boolean isGLES() { + return false; +} + +@Override +public final GLES1 getGLES1() throws GLException { + throw new GLException("Not a GLES1 implementation"); +} + +@Override +public final GLES2 getGLES2() throws GLException { + throw new GLException("Not a GLES2 implementation"); +} + +@Override +public final GLES3 getGLES3() throws GLException { + throw new GLException("Not a GLES3 implementation"); +} + +@Override +public final boolean isNPOTTextureAvailable() { + return _context.isNPOTTextureAvailable(); +} +@Override +public final java.nio.ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + return _context.glAllocateMemoryNV(size, readFrequency, writeFrequency, priority); +} + +@Override +public final void glFreeMemoryNV(java.nio.ByteBuffer pointer) { + _context.glFreeMemoryNV(pointer); } // @@ -45,7 +256,6 @@ private final GLBufferSizeTracker bufferSizeTracker; private final GLBufferStateTracker bufferStateTracker; private final GLStateTracker glStateTracker; -private boolean bufferObjectExtensionsInitialized = false; private boolean haveARBPixelBufferObject; private boolean haveEXTPixelBufferObject; private boolean haveGL15; @@ -53,20 +263,6 @@ private boolean haveGL21; private boolean haveARBVertexBufferObject; private boolean haveARBVertexArrayObject; -private final 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"); - haveARBVertexArrayObject = _context.getGLVersionNumber().compareTo(GLContext.Version300) >= 0 || - isExtensionAvailable("GL_ARB_vertex_array_object"); -} - private final boolean checkBufferObject(boolean extensionAvail, boolean allowVAO, boolean enabled, @@ -111,7 +307,6 @@ private final boolean checkBufferObject(boolean extensionAvail, } private final boolean checkArrayVBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO false, // enable @@ -120,7 +315,6 @@ private final boolean checkArrayVBODisabled(boolean throwException) { } private final boolean checkArrayVBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO true, // enable @@ -129,7 +323,6 @@ private final boolean checkArrayVBOEnabled(boolean throwException) { } private final boolean checkElementVBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO false, // enable @@ -138,7 +331,6 @@ private final boolean checkElementVBODisabled(boolean throwException) { } private final boolean checkElementVBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO true, // enable @@ -147,7 +339,6 @@ private final boolean checkElementVBOEnabled(boolean throwException) { } private final boolean checkUnpackPBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL21 || haveARBPixelBufferObject || haveEXTPixelBufferObject, false, // allowVAO false, // enable @@ -156,7 +347,6 @@ private final boolean checkUnpackPBODisabled(boolean throwException) { } private final boolean checkUnpackPBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL21 || haveARBPixelBufferObject || haveEXTPixelBufferObject, false, // allowVAO true, // enable @@ -165,7 +355,6 @@ private final boolean checkUnpackPBOEnabled(boolean throwException) { } private final boolean checkPackPBODisabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL21 || haveARBPixelBufferObject || haveEXTPixelBufferObject, false, // allowVAO false, // enable @@ -174,7 +363,6 @@ private final boolean checkPackPBODisabled(boolean throwException) { } private final boolean checkPackPBOEnabled(boolean throwException) { - initBufferObjectExtensionChecks(); return checkBufferObject(haveGL21 || haveARBPixelBufferObject || haveEXTPixelBufferObject, false, // allowVAO true, // enable @@ -192,87 +380,21 @@ public final boolean glIsPBOUnpackEnabled() { return checkUnpackPBOEnabled(false); } -private final HashMap arbMemCache = new HashMap(); - -/** Entry point to C language function:
    LPVOID glMapBuffer(GLenum target, GLenum access); */ +/** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
    Part of GL_VERSION_1_5; GL_OES_mapbuffer */ public final 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"); - } - final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); - if (0 == sz) { - return null; - } - final long addr = dispatch_glMapBuffer(target, access, __addr_); - if (0 == addr) { - return null; - } - ByteBuffer buffer; - MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key - MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; + return glMapBufferImpl(target, false, 0, 0, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); } -/** Encapsulates function pointer for OpenGL function
    : LPVOID glMapBuffer(GLenum target, GLenum access); */ -native private long dispatch_glMapBuffer(int target, int access, long glProcAddress); +/** Entry point to C language function: void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
    Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_map_buffer_range */ +public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { + return glMapBufferImpl(target, true, offset, length, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); +} /** Entry point to C language function: GLvoid * {@native glMapNamedBufferEXT}(GLuint buffer, GLenum access);
    Part of GL_EXT_direct_state_access */ public final java.nio.ByteBuffer glMapNamedBufferEXT(int bufferName, int access) { - final long __addr_ = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT; - if (__addr_ == 0) { - throw new GLException("Method \"glMapNamedBufferEXT\" not available"); - } - final long sz = bufferSizeTracker.getDirectStateBufferSize(bufferName, this); - if (0 == sz) { - return null; - } - final long addr = dispatch_glMapNamedBufferEXT(bufferName, access, __addr_); - if (0 == addr) { - return null; - } - ByteBuffer buffer; - MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key - MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; + return glMapNamedBufferImpl(bufferName, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT); } -private native long dispatch_glMapNamedBufferEXT(int buffer, int access, long procAddress); - -native private ByteBuffer newDirectByteBuffer(long addr, long capacity); - @Override public final void glVertexPointer(GLArrayData array) { if(array.getComponentCount()==0) return; diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index 70425689a..2fa83dca6 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -47,6 +47,11 @@ public final boolean isGLES2() { return false; } +@Override +public final boolean isGLES3() { + return false; +} + @Override public final boolean isGLES() { return true; @@ -62,11 +67,26 @@ public final boolean isGL2ES2() { return false; } +@Override +public final boolean isGL3ES3() { + return false; +} + +@Override +public final boolean isGL4ES3() { + return false; +} + @Override public final boolean isGLES2Compatible() { return false; } +@Override +public final boolean isGLES3Compatible() { + return false; +} + @Override public final boolean isGL2GL3() { return false; @@ -117,6 +137,11 @@ public final GLES2 getGLES2() throws GLException { throw new GLException("Not a GLES2 implementation"); } +@Override +public final GLES3 getGLES3() throws GLException { + throw new GLException("Not a GLES3 implementation"); +} + @Override public final GL2ES1 getGL2ES1() throws GLException { return this; @@ -127,6 +152,16 @@ public final GL2ES2 getGL2ES2() throws GLException { throw new GLException("Not a GL2ES2 implementation"); } +@Override +public final GL3ES3 getGL3ES3() throws GLException { + throw new GLException("Not a GL3ES3 implementation"); +} + +@Override +public final GL4ES3 getGL4ES3() throws GLException { + throw new GLException("Not a GL4ES3 implementation"); +} + @Override public final GL2GL3 getGL2GL3() throws GLException { throw new GLException("Not a GL2GL3 implementation"); @@ -206,48 +241,15 @@ private final boolean checkPackPBOEnabled(boolean throwException) { return false; } -private final HashMap arbMemCache = new HashMap(); - -/** Entry point to C language function:
    LPVOID glMapBuffer(GLenum target, GLenum access); */ +/** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
    Part of GL_VERSION_1_5; GL_OES_mapbuffer */ public final java.nio.ByteBuffer glMapBuffer(int target, int access) { - final long __addr_ = ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer; - if (__addr_ == 0) { - throw new GLException("Method \"glMapBuffer\" not available"); - } - final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); - if (0 == sz) { - return null; - } - final long addr = dispatch_glMapBuffer(target, access, __addr_); - if (0 == addr) { - return null; - } - ByteBuffer buffer; - MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key - MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; + return glMapBufferImpl(target, false, 0, 0, access, ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); } -/** 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, long capacity); +/** Entry point to C language function: void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
    Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_map_buffer_range */ +public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { + return glMapBufferImpl(target, true, offset, length, access, ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); +} @Override public final void glVertexPointer(GLArrayData array) { diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java b/make/config/jogl/gl-impl-CustomJavaCode-gles2.java deleted file mode 100644 index 37f3f33aa..000000000 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles2.java +++ /dev/null @@ -1,262 +0,0 @@ - -public GLES2Impl(GLProfile glp, GLContextImpl context) { - this._context = context; - if(null != context) { - this.bufferSizeTracker = context.getBufferSizeTracker(); - this.bufferStateTracker = context.getBufferStateTracker(); - this.glStateTracker = context.getGLStateTracker(); - } else { - this.bufferSizeTracker = null; - this.bufferStateTracker = null; - this.glStateTracker = null; - } - this.glProfile = glp; -} - -@Override -public final boolean isGL4bc() { - return false; -} - -@Override -public final boolean isGL4() { - return false; -} - -@Override -public final boolean isGL3bc() { - return false; -} - -@Override -public final boolean isGL3() { - return false; -} - -public final boolean isGL2() { - return false; -} - -@Override -public final boolean isGLES1() { - return false; -} - -@Override -public final boolean isGLES2() { - return true; -} - -@Override -public final boolean isGLES() { - return true; -} - -@Override -public final boolean isGL2ES1() { - return false; -} - -@Override -public final boolean isGL2ES2() { - return true; -} - -@Override -public final boolean isGLES2Compatible() { - return true; -} - -@Override -public final boolean isGL2GL3() { - return false; -} - -@Override -public final boolean hasGLSL() { - return true; -} - -@Override -public boolean isNPOTTextureAvailable() { - return true; -} - -@Override -public final GL4bc getGL4bc() throws GLException { - throw new GLException("Not a GL4bc implementation"); -} - -@Override -public final GL4 getGL4() throws GLException { - throw new GLException("Not a GL4 implementation"); -} - -@Override -public final GL3bc getGL3bc() throws GLException { - throw new GLException("Not a GL3bc implementation"); -} - -@Override -public final GL3 getGL3() throws GLException { - throw new GLException("Not a GL3 implementation"); -} - -@Override -public final GL2 getGL2() throws GLException { - throw new GLException("Not a GL2 implementation"); -} - -@Override -public final GLES1 getGLES1() throws GLException { - throw new GLException("Not a GLES1 implementation"); -} - -@Override -public final GLES2 getGLES2() throws GLException { - return this; -} - -@Override -public final GL2ES1 getGL2ES1() throws GLException { - throw new GLException("Not a GL2ES1 implementation"); -} - -@Override -public final GL2ES2 getGL2ES2() throws GLException { - return this; -} - -@Override -public final GL2GL3 getGL2GL3() throws GLException { - throw new GLException("Not a GL2GL3 implementation"); -} - -// -// Helpers for ensuring the correct amount of texture data -// - -private final GLBufferSizeTracker bufferSizeTracker; -private final GLBufferStateTracker bufferStateTracker; -private final GLStateTracker glStateTracker; - -private final boolean checkBufferObject(boolean enabled, - int state, - String kind, boolean throwException) { - final int buffer = bufferStateTracker.getBoundBufferObject(state, this); - if (enabled) { - if (0 == buffer) { - if(throwException) { - throw new GLException(kind + " must be enabled to call this method"); - } - return false; - } - } else { - if (0 != buffer) { - if(throwException) { - throw new GLException(kind + " must be disabled to call this method"); - } - return false; - } - } - return true; -} - -private final boolean checkArrayVBODisabled(boolean throwException) { - return checkBufferObject(false, // enabled - GL.GL_ARRAY_BUFFER, - "array vertex_buffer_object", throwException); -} - -private final boolean checkArrayVBOEnabled(boolean throwException) { - return checkBufferObject(true, // enabled - GL.GL_ARRAY_BUFFER, - "array vertex_buffer_object", throwException); -} - -private final boolean checkElementVBODisabled(boolean throwException) { - return checkBufferObject(false, // enabled - GL.GL_ELEMENT_ARRAY_BUFFER, - "element vertex_buffer_object", throwException); -} - -private final boolean checkElementVBOEnabled(boolean throwException) { - return checkBufferObject(true, // enabled - GL.GL_ELEMENT_ARRAY_BUFFER, - "element vertex_buffer_object", throwException); -} - -private final boolean checkUnpackPBODisabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return true; -} - -private final boolean checkUnpackPBOEnabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return false; -} - -private final boolean checkPackPBODisabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return true; -} - -private final boolean checkPackPBOEnabled(boolean throwException) { - // PBO n/a for ES 1.1 or ES 2.0 - return false; -} - -private final HashMap arbMemCache = new HashMap(); - -/** Entry point to C language function:
    LPVOID glMapBuffer(GLenum target, GLenum access); */ -@Override -public final java.nio.ByteBuffer glMapBuffer(int target, int access) { - final long __addr_ = ((GLES2ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer; - if (__addr_ == 0) { - throw new GLException("Method \"glMapBuffer\" not available"); - } - final long sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); - if (0 == sz) { - return null; - } - final long addr = dispatch_glMapBuffer(target, access, __addr_); - if (0 == addr) { - return null; - } - ByteBuffer buffer; - MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key - MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; -} - -/** 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, long capacity); - -@Override -public final void glClearDepth(double depth) { - glClearDepthf((float)depth); -} - -@Override -public final void glDepthRange(double zNear, double zFar) { - glDepthRangef((float)zNear, (float)zFar); -} - diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java new file mode 100644 index 000000000..e0b0c6a09 --- /dev/null +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -0,0 +1,320 @@ + +public GLES3Impl(GLProfile glp, GLContextImpl context) { + this._context = context; + if(null != context) { + this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferStateTracker = context.getBufferStateTracker(); + this.glStateTracker = context.getGLStateTracker(); + } else { + this.bufferSizeTracker = null; + this.bufferStateTracker = null; + this.glStateTracker = null; + } + this.glProfile = glp; + this._isES3 = glp.getImplName() == GLProfile.GLES3; +} + +@Override +public final boolean isGL4bc() { + return false; +} + +@Override +public final boolean isGL4() { + return false; +} + +@Override +public final boolean isGL3bc() { + return false; +} + +@Override +public final boolean isGL3() { + return false; +} + +public final boolean isGL2() { + return false; +} + +@Override +public final boolean isGLES1() { + return false; +} + +@Override +public final boolean isGLES2() { + return true; +} + +@Override +public final boolean isGLES3() { + return _isES3; +} + +@Override +public final boolean isGLES() { + return true; +} + +@Override +public final boolean isGL2ES1() { + return false; +} + +@Override +public final boolean isGL2ES2() { + return true; +} + +@Override +public final boolean isGL3ES3() { + return _isES3; +} + +@Override +public final boolean isGL4ES3() { + return _isES3; +} + +@Override +public final boolean isGLES2Compatible() { + return true; +} + +@Override +public final boolean isGLES3Compatible() { + return _isES3; +} + + +@Override +public final boolean isGL2GL3() { + return false; +} + +@Override +public final boolean hasGLSL() { + return true; +} + +@Override +public boolean isNPOTTextureAvailable() { + return true; +} + +@Override +public final GL4bc getGL4bc() throws GLException { + throw new GLException("Not a GL4bc implementation"); +} + +@Override +public final GL4 getGL4() throws GLException { + throw new GLException("Not a GL4 implementation"); +} + +@Override +public final GL3bc getGL3bc() throws GLException { + throw new GLException("Not a GL3bc implementation"); +} + +@Override +public final GL3 getGL3() throws GLException { + throw new GLException("Not a GL3 implementation"); +} + +@Override +public final GL2 getGL2() throws GLException { + throw new GLException("Not a GL2 implementation"); +} + +@Override +public final GLES1 getGLES1() throws GLException { + throw new GLException("Not a GLES1 implementation"); +} + +@Override +public final GLES2 getGLES2() throws GLException { + return this; +} + +@Override +public final GLES3 getGLES3() throws GLException { + return this; +} + +@Override +public final GL2ES1 getGL2ES1() throws GLException { + throw new GLException("Not a GL2ES1 implementation"); +} + +@Override +public final GL2ES2 getGL2ES2() throws GLException { + return this; +} + +@Override +public final GL3ES3 getGL3ES3() throws GLException { + if(!_isES3) { + throw new GLException("Not a GL3ES3 implementation"); + } + return this; +} + +@Override +public final GL4ES3 getGL4ES3() throws GLException { + if(!_isES3) { + throw new GLException("Not a GL4ES3 implementation"); + } + return this; +} + +@Override +public final GL2GL3 getGL2GL3() throws GLException { + throw new GLException("Not a GL2GL3 implementation"); +} + +// +// Helpers for ensuring the correct amount of texture data +// + +private final boolean _isES3; +private final GLBufferSizeTracker bufferSizeTracker; +private final GLBufferStateTracker bufferStateTracker; +private final GLStateTracker glStateTracker; + +private final boolean checkBufferObject(boolean extensionAvail, + boolean allowVAO, + boolean enabled, + int state, + String kind, boolean throwException) { + if ( !extensionAvail ) { + 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 ( 0 != buffer ) { + return true; + } + if ( allowVAO ) { + buffer = bufferStateTracker.getBoundBufferObject(GLES3.GL_VERTEX_ARRAY_BINDING, this); + if( 0 != buffer && !_context.isDefaultVAO(buffer) ) { + return true; + } + } + if ( throwException ) { + throw new GLException(kind + " must be enabled to call this method"); + } + return false; + } else { + if ( 0 == buffer ) { + return true; + } + if ( throwException ) { + throw new GLException(kind + " must be disabled to call this method"); + } + return false; + } +} + +private final boolean checkArrayVBODisabled(boolean throwException) { + return checkBufferObject(true, + _isES3, // allowVAO + false, // enable + GL.GL_ARRAY_BUFFER, + "array vertex_buffer_object", throwException); +} + +private final boolean checkArrayVBOEnabled(boolean throwException) { + return checkBufferObject(true, + _isES3, // allowVAO + true, // enable + GL.GL_ARRAY_BUFFER, + "array vertex_buffer_object", throwException); +} + +private final boolean checkElementVBODisabled(boolean throwException) { + return checkBufferObject(true, + _isES3, // allowVAO + false, // enable + GL.GL_ELEMENT_ARRAY_BUFFER, + "element vertex_buffer_object", throwException); +} + +private final boolean checkElementVBOEnabled(boolean throwException) { + return checkBufferObject(true, + _isES3, // allowVAO + true, // enable + GL.GL_ELEMENT_ARRAY_BUFFER, + "element vertex_buffer_object", throwException); +} + +private final boolean checkUnpackPBODisabled(boolean throwException) { + return checkBufferObject(_isES3, + false, // allowVAO + false, // enable + GL2.GL_PIXEL_UNPACK_BUFFER, + "unpack pixel_buffer_object", throwException); +} + +private final boolean checkUnpackPBOEnabled(boolean throwException) { + return checkBufferObject(_isES3, + false, // allowVAO + true, // enable + GL2.GL_PIXEL_UNPACK_BUFFER, + "unpack pixel_buffer_object", throwException); +} + +private final boolean checkPackPBODisabled(boolean throwException) { + return checkBufferObject(_isES3, + false, // allowVAO + false, // enable + GL2.GL_PIXEL_PACK_BUFFER, + "pack pixel_buffer_object", throwException); +} + +private final boolean checkPackPBOEnabled(boolean throwException) { + return checkBufferObject(_isES3, + false, // allowVAO + true, // enable + GL2.GL_PIXEL_PACK_BUFFER, + "pack pixel_buffer_object", throwException); +} + +@Override +public final boolean glIsPBOPackEnabled() { + return checkPackPBOEnabled(false); +} + +@Override +public final boolean glIsPBOUnpackEnabled() { + return checkUnpackPBOEnabled(false); +} + +/** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
    Part of GL_VERSION_1_5; GL_OES_mapbuffer */ +public final java.nio.ByteBuffer glMapBuffer(int target, int access) { + return glMapBufferImpl(target, false, 0, 0, access, ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); +} + +/** Entry point to C language function: void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
    Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_map_buffer_range */ +public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { + return glMapBufferImpl(target, true, offset, length, access, ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); +} + +@Override +public final void glClearDepth(double depth) { + glClearDepthf((float)depth); +} + +@Override +public final void glDepthRange(double zNear, double zFar) { + glDepthRangef((float)zNear, (float)zFar); +} + diff --git a/make/config/jogl/gl2_es2-CustomJavaCode.cfg b/make/config/jogl/gl2_es2-CustomJavaCode.cfg new file mode 100644 index 000000000..b769f3b29 --- /dev/null +++ b/make/config/jogl/gl2_es2-CustomJavaCode.cfg @@ -0,0 +1,13 @@ + +JavaPrologue glReleaseShaderCompiler if ( !_context.isGLES2Compatible() ) { +JavaPrologue glReleaseShaderCompiler return; +JavaPrologue glReleaseShaderCompiler } + +JavaPrologue glShaderBinary if ( !_context.isGLES2Compatible() ) { +JavaPrologue glShaderBinary throw new GLException("Method \"glShaderBinary\" not available"); +JavaPrologue glShaderBinary } + +JavaPrologue glGetShaderPrecisionFormat if ( !_context.isGLES2Compatible() ) { +JavaPrologue glGetShaderPrecisionFormat throw new GLException("Method \"glGetShaderPrecisionFormat\" not available"); +JavaPrologue glGetShaderPrecisionFormat } + diff --git a/make/config/jogl/gl2_es2-common.cfg b/make/config/jogl/gl2_es2-common.cfg index b769f3b29..2ad7fd3fd 100644 --- a/make/config/jogl/gl2_es2-common.cfg +++ b/make/config/jogl/gl2_es2-common.cfg @@ -1,13 +1,11 @@ -JavaPrologue glReleaseShaderCompiler if ( !_context.isGLES2Compatible() ) { -JavaPrologue glReleaseShaderCompiler return; -JavaPrologue glReleaseShaderCompiler } +RenameExtensionIntoCore GL_KHR_debug +RenameExtensionIntoCore GL_OES_texture_3D +RenameExtensionIntoCore GL_OES_get_program_binary +RenameExtensionIntoCore GL_OES_required_internalformat +RenameExtensionIntoCore GL_EXT_unpack_subimage -JavaPrologue glShaderBinary if ( !_context.isGLES2Compatible() ) { -JavaPrologue glShaderBinary throw new GLException("Method \"glShaderBinary\" not available"); -JavaPrologue glShaderBinary } +ForceExtension GL_EXT_occlusion_query_boolean -JavaPrologue glGetShaderPrecisionFormat if ( !_context.isGLES2Compatible() ) { -JavaPrologue glGetShaderPrecisionFormat throw new GLException("Method \"glGetShaderPrecisionFormat\" not available"); -JavaPrologue glGetShaderPrecisionFormat } +ForceExtension GL_ARB_ES2_compatibility diff --git a/make/config/jogl/gl2_es3-common.cfg b/make/config/jogl/gl2_es3-common.cfg new file mode 100644 index 000000000..b5326b159 --- /dev/null +++ b/make/config/jogl/gl2_es3-common.cfg @@ -0,0 +1,9 @@ + +RenameExtensionIntoCore GL_KHR_debug +RenameExtensionIntoCore GL_OES_texture_3D +IgnoreExtension GL_OES_get_program_binary +RenameExtensionIntoCore GL_OES_required_internalformat +RenameExtensionIntoCore GL_EXT_unpack_subimage + +ForceExtension GL_EXT_occlusion_query_boolean + diff --git a/make/config/jogl/gl3-common.cfg b/make/config/jogl/gl3-common.cfg new file mode 100644 index 000000000..e11c50aa3 --- /dev/null +++ b/make/config/jogl/gl3-common.cfg @@ -0,0 +1,9 @@ + +ForceExtension GL_ARB_debug_output +RenameExtensionIntoCore GL_KHR_debug + +RenameExtensionIntoCore GL_OES_texture_3D +IgnoreExtension GL_OES_get_program_binary +RenameExtensionIntoCore GL_OES_required_internalformat +RenameExtensionIntoCore GL_EXT_unpack_subimage + diff --git a/make/config/jogl/gl3-desktop.cfg b/make/config/jogl/gl3-desktop.cfg index 96e59aa05..4a2c53371 100644 --- a/make/config/jogl/gl3-desktop.cfg +++ b/make/config/jogl/gl3-desktop.cfg @@ -1,11 +1,6 @@ # This .cfg file provides common options used by the desktop OpenGL # implementation on all platforms. -# Inform the glue code generator of the association between #defines -# and functions and the extensions in which they are defined -GLHeader GL3/gl3.h -GLHeader GL3/gl3ext.h - #Include gl-desktop-tracker.cfg # diff --git a/make/config/jogl/gl3-headers.cfg b/make/config/jogl/gl3-headers.cfg index 8b35a07b4..7ab5099c9 100644 --- a/make/config/jogl/gl3-headers.cfg +++ b/make/config/jogl/gl3-headers.cfg @@ -1,7 +1,6 @@ CustomCCode #include /* android */ -CustomCCode /* Define GL3_PROTOTYPES so that the OpenGL extension prototypes in -CustomCCode "gl3.h" are parsed. */ -CustomCCode #define GL3_PROTOTYPES +CustomCCode /** Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. */ +CustomCCode #define GL_GLEXT_PROTOTYPES CustomCCode #if defined(_WIN32) CustomCCode #define WIN32_LEAN_AND_MEAN CustomCCode #include @@ -9,11 +8,13 @@ CustomCCode #undef WIN32_LEAN_AND_MEAN CustomCCode #include CustomCCode #include CustomCCode #include -CustomCCode #include +CustomCCode #include +CustomCCode #include CustomCCode #elif defined(macosx) CustomCCode #include CustomCCode #include -CustomCCode #include +CustomCCode #include +CustomCCode #include CustomCCode #include CustomCCode /* Provide Windows typedefs */ CustomCCode typedef void* LPVOID; @@ -22,5 +23,6 @@ CustomCCode #elif defined(__unix__) CustomCCode #include CustomCCode #include CustomCCode #include -CustomCCode #include +CustomCCode #include +CustomCCode #include CustomCCode #endif diff --git a/make/config/jogl/gl3ext-headers.cfg b/make/config/jogl/gl3ext-headers.cfg index 5e2c7aa37..24b1ba518 100644 --- a/make/config/jogl/gl3ext-headers.cfg +++ b/make/config/jogl/gl3ext-headers.cfg @@ -1,6 +1,4 @@ CustomCCode #include /* android */ -CustomCCode /* Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -CustomCCode "gl3ext.h" are parsed. */ -CustomCCode #define GL_GL3EXT_PROTOTYPES -CustomCCode #include -CustomCCode #include +CustomCCode /** Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. */ +CustomCCode #define GL_GLEXT_PROTOTYPES +CustomCCode #include diff --git a/make/config/jogl/glx-x11.cfg b/make/config/jogl/glx-x11.cfg index 017b1e00b..5955e0a38 100644 --- a/make/config/jogl/glx-x11.cfg +++ b/make/config/jogl/glx-x11.cfg @@ -20,7 +20,6 @@ NIODirectOnly __ALL__ ForceProcAddressGen __ALL__ LocalProcAddressCallingConvention __ALL__ APIENTRY -AllowNonGLExtensions true EmitProcAddressTable true ProcAddressTableClassName GLXProcAddressTable GetProcAddressTableExpr glxProcAddressTable diff --git a/make/scripts/cmpOld2New.sh b/make/scripts/cmpOld2New.sh index 7d68cfc84..4a121a632 100755 --- a/make/scripts/cmpOld2New.sh +++ b/make/scripts/cmpOld2New.sh @@ -9,7 +9,7 @@ dircmp=cmp-old2new rm -rf $dircmp mkdir -p $dircmp -for i in GL GL2ES1 GL2ES2 GLES1 GLES2 GL2GL3 GL2 GL3 GL3bc GL4 GL4bc ; do +for i in GL GL2ES1 GLES1 GL2ES2 GLES2 GL2ES3 GL2GL3 GL2 GL3ES3 GL3 GL3bc GL4ES3 GLES3 GL4 GL4bc ; do echo echo processing $i awk -f $dirscript/strip-c-comments.awk $dirold/$i.java | sort -u > $dircmp/$i-old.java diff --git a/make/scripts/cmpOld2NewDups.sh b/make/scripts/cmpOld2NewDups.sh new file mode 100644 index 000000000..4d3e1e35a --- /dev/null +++ b/make/scripts/cmpOld2NewDups.sh @@ -0,0 +1,121 @@ +#! /bin/bash + +dircmp=cmp-old2new + +GLFILES="$dircmp/GL2ES1-new.java \ + $dircmp/GLES1-new.java \ + $dircmp/GL2ES2-new.java \ + $dircmp/GLES2-new.java \ + $dircmp/GL3ES3-new.java \ + $dircmp/GL2GL3-new.java \ + $dircmp/GL2-new.java \ + $dircmp/GL3-new.java \ + $dircmp/GL3bc-new.java \ + $dircmp/GL4ES3-new.java \ + $dircmp/GLES3-new.java \ + $dircmp/GL4-new.java \ + $dircmp/GL4bc-new.java \ + $dircmp/GL-new.java" + +GL4FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GL2ES3-new.java \ + $dircmp/GL3ES3-new.java \ + $dircmp/GL3-new.java \ + $dircmp/GL4ES3-new.java \ + $dircmp/GL4-new.java \ + $dircmp/GL-new.java" + +GLES3FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GL2ES3-new.java \ + $dircmp/GL3ES3-new.java \ + $dircmp/GL4ES3-new.java \ + $dircmp/GLES3-new.java \ + $dircmp/GL-new.java" + +GLES1FILES="$dircmp/GL2ES1-new.java \ + $dircmp/GLES1-new.java \ + $dircmp/GL-new.java" + +GLES2FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GLES2-new.java \ + $dircmp/GL-new.java" + +GL2ES2FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GLES2-new.java \ + $dircmp/GL2-new.java \ + $dircmp/GL-new.java" + +GL3ES3FILES="$dircmp/GL2ES2-new.java \ + $dircmp/GL3ES3-new.java \ + $dircmp/GL4ES3-new.java \ + $dircmp/GLES3-new.java \ + $dircmp/GL3-new.java \ + $dircmp/GL4-new.java \ + $dircmp/GL-new.java" + +echo Duplicates GL GL2ES1 GL2ES2 GL2GL3 GL3 GL3bc GL4 GL4bc > $dircmp/GL4Files.dups +cat $GL4FILES | sort | uniq -d >> $dircmp/GL4Files.dups + +echo Duplicates GL GL2ES1 GLES1 > $dircmp/GLES1Files.dups +cat $GLES1FILES | sort | uniq -d >> $dircmp/GLES1Files.dups + +echo Duplicates GL GL2ES2 GLES2 > $dircmp/GLES2Files.dups +cat $GLES2FILES | sort | uniq -d >> $dircmp/GLES2Files.dups + +echo Duplicates GL GL2ES2 GL3ES3 GLES3 > $dircmp/GLES3Files.dups +cat $GLES3FILES | sort | uniq -d >> $dircmp/GLES3Files.dups + +echo Duplicates GL GL2 GL2ES2 GLES2 > $dircmp/GL2ES2Files.dups +cat $GL2ES2FILES | sort | uniq -d >> $dircmp/GL2ES2Files.dups + +echo Duplicates GL GL3 GL2ES2 GL2ES3 GLES3 > $dircmp/GL3ES3Files.dups +cat $GL3ES3FILES | sort | uniq -d >> $dircmp/GL3ES3Files.dups + +## +## + +echo Duplicates GL3ES3 GLES3 > $dircmp/GLES3-GL3ES3.dups +cat $dircmp/GLES3-new.java $dircmp/GL3ES3-new.java | sort | uniq -d >> $dircmp/GLES3-GL3ES3.dups + +echo Diff GL3ES3 GLES3 > $dircmp/GLES3-GL3ES3.diff +diff -Nurdw $dircmp/GLES3-new.java $dircmp/GL3ES3-new.java >> $dircmp/GLES3-GL3ES3.diff + +## +## + +echo Duplicates GL2GL3 GLES3 > $dircmp/GLES3-GL2GL3.dups +cat $dircmp/GLES3-new.java $dircmp/GL2GL3-new.java | sort | uniq -d >> $dircmp/GLES3-GL2GL3.dups + +echo Diff GL2GL3 GLES3 > $dircmp/GLES3-GL2GL3.diff +diff -Nurdw $dircmp/GLES3-new.java $dircmp/GL2GL3-new.java >> $dircmp/GLES3-GL2GL3.diff + +## +## + +echo Duplicates GL2ES2 GLES3 > $dircmp/GLES3-GL2ES2.dups +cat $dircmp/GLES3-new.java $dircmp/GL2ES2-new.java | sort | uniq -d >> $dircmp/GLES3-GL2ES2.dups + +echo Diff GL2ES2 GLES3 > $dircmp/GLES3-GL2ES2.diff +diff -Nurdw $dircmp/GLES3-new.java $dircmp/GL2ES2-new.java >> $dircmp/GLES3-GL2ES2.diff + +## +## + +echo Duplicates GL2GL3 GL3ES3 > $dircmp/GL3ES3-GL2GL3.dups +cat $dircmp/GL3ES3-new.java $dircmp/GL2GL3-new.java | sort | uniq -d >> $dircmp/GL3ES3-GL2GL3.dups + +echo Diff GL2GL3 GL3ES3 > $dircmp/GL3ES3-GL2GL3.diff +diff -Nurdw $dircmp/GL3ES3-new.java $dircmp/GL2GL3-new.java >> $dircmp/GL3ES3-GL2GL3.diff + +## +## + +echo Duplicates GL2ES2 GL3ES3 > $dircmp/GL3ES3-GL2ES2.dups +cat $dircmp/GL3ES3-new.java $dircmp/GL2ES2-new.java | sort | uniq -d >> $dircmp/GL3ES3-GL2ES2.dups + +echo Diff GL2ES2 GL3ES3 > $dircmp/GL3ES3-GL2ES2.diff +diff -Nurdw $dircmp/GL3ES3-new.java $dircmp/GL2ES2-new.java >> $dircmp/GL3ES3-GL2ES2.diff + +## +## + diff --git a/make/scripts/gluegen-gl.sh b/make/scripts/gluegen-gl.sh index d44c7987a..2d40ddcd9 100644 --- a/make/scripts/gluegen-gl.sh +++ b/make/scripts/gluegen-gl.sh @@ -47,6 +47,114 @@ copy_temp } +function gluegen_gl2es1() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-if-gl2_es1.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles1.c \ + +copy_temp +} + +function gluegen_es1() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-es1.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles1.c \ + +copy_temp +} + +function gluegen_gl2es2() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-if-gl2_es2.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles2.c \ + +copy_temp +} + function gluegen_es2() { java \ -classpath \ @@ -84,6 +192,79 @@ copy_temp } +function gluegen_gl3es3() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-if-gl3_es3.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles3.c \ + +copy_temp + +} +function gluegen_es3() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-es3.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gles3.c \ + +copy_temp + +} + function gluegen_gl2() { java \ -classpath \ @@ -130,7 +311,7 @@ com.jogamp.gluegen.GlueGen \ --dumpCPP \ -O../$rootrel/jogl \ -Ecom.jogamp.gluegen.opengl.GLEmitter \ --C./config/jogl/gl-if-gl3-subset.cfg \ +-C./config/jogl/gl-if-gl2gl3-subset.cfg \ -Istub_includes/jni \ -Istub_includes/jni/macosx \ -Istub_includes/jni/win32 \ @@ -154,6 +335,8 @@ com.jogamp.gluegen.GlueGen \ -I../../gluegen/make/stub_includes/gluegen \ stub_includes/opengl/gl3.c \ +copy_temp + java \ -classpath \ ../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ @@ -189,11 +372,207 @@ stub_includes/opengl/gl2.c \ copy_temp } + +function gluegen_glx() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/glx-x11.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/x11/window-system1.c \ + +copy_temp + +} + +function gluegen_glxext() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/glxext.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/x11/glxext.c \ + +copy_temp + +} + +function gluegen_wgl() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/wgl-win32.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/win32/window-system1.c \ + +copy_temp + +} + +function gluegen_wglext() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/wglext.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/win32/wglext.c \ + +copy_temp + +} + +function gluegen_gl4bc() { +java \ +-classpath \ +../../gluegen/$rootrel/gluegen.jar:../$rootrel/jogl/gluegen-gl.jar \ +com.jogamp.gluegen.GlueGen \ +--debug \ +--dumpCPP \ +-O../$rootrel/jogl \ +-Ecom.jogamp.gluegen.opengl.GLEmitter \ +-C./config/jogl/gl-gl4bc.cfg \ +-Istub_includes/jni \ +-Istub_includes/jni/macosx \ +-Istub_includes/jni/win32 \ +-Istub_includes/jni/x11 \ +-Istub_includes/khr \ +-Istub_includes/khr/KD \ +-Istub_includes/khr/KHR \ +-Istub_includes/macosx \ +-Istub_includes/macosx/AppKit \ +-Istub_includes/macosx/OpenGL \ +-Istub_includes/macosx/QuartzCore \ +-Istub_includes/opengl \ +-Istub_includes/opengl/GL \ +-Istub_includes/opengl/GL3 \ +-Istub_includes/opengl/GLES \ +-Istub_includes/opengl/GLES2 \ +-Istub_includes/win32 \ +-Istub_includes/x11 \ +-Istub_includes/x11/X11 \ +-Istub_includes/x11/X11/extensions \ +-I../../gluegen/make/stub_includes/gluegen \ +stub_includes/opengl/gl4bc.c \ + +copy_temp + +} + function gluegen_all() { -# gluegen_if_gl +# gluegen_if_gl +# gluegen_gl2es1 +# gluegen_es1 + gluegen_gl2es2 # gluegen_es2 +# gluegen_gl3es3 +# gluegen_es3 # gluegen_gl2 - gluegen_gl2gl3 +# gluegen_gl2gl3 +# gluegen_gl4bc +# gluegen_glx +# gluegen_glxext +# gluegen_wgl +# gluegen_wglext } gluegen_all 2>&1 | tee $(basename $0 .sh).log diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh index 2488a7d4c..f59d6eabb 100755 --- a/make/scripts/make.jogl.all.linux-x86_64.sh +++ b/make/scripts/make.jogl.all.linux-x86_64.sh @@ -54,6 +54,7 @@ export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" # BUILD_ARCHIVE=true \ ant \ + -Dc.compiler.debug=true \ $CUSTOMLIBDIR \ -Drootrel.build=build-x86_64 \ $* 2>&1 | tee -a $LOGF diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9cae2ddeb..7484d5afe 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -147,6 +147,8 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" + ##D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" + ##D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" @@ -289,7 +291,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -330,7 +332,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* diff --git a/make/stub_includes/egl/EGL/eglext.h b/make/stub_includes/egl/EGL/eglext.h index 763403609..769edaa33 100644 --- a/make/stub_includes/egl/EGL/eglext.h +++ b/make/stub_includes/egl/EGL/eglext.h @@ -6,7 +6,7 @@ extern "C" { #endif /* -** Copyright (c) 2007-2012 The Khronos Group Inc. +** Copyright (c) 2007-2013 The Khronos Group Inc. ** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the @@ -34,8 +34,8 @@ extern "C" { /* Header file version number */ /* Current version at http://www.khronos.org/registry/egl/ */ -/* $Revision: 16473 $ on $Date: 2012-01-04 02:20:48 -0800 (Wed, 04 Jan 2012) $ */ -#define EGL_EGLEXT_VERSION 11 +/* $Revision: 21254 $ on $Date: 2013-04-25 03:11:55 -0700 (Thu, 25 Apr 2013) $ */ +#define EGL_EGLEXT_VERSION 16 #ifndef EGL_KHR_config_attribs #define EGL_KHR_config_attribs 1 @@ -208,12 +208,12 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EG typedef void* EGLSyncNV; typedef khronos_utime_nanoseconds_t EGLTimeNV; #ifdef EGL_EGLEXT_PROTOTYPES -EGLSyncNV eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); -EGLBoolean eglDestroySyncNV (EGLSyncNV sync); -EGLBoolean eglFenceNV (EGLSyncNV sync); -EGLint eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); -EGLBoolean eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); -EGLBoolean eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); +EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); #endif /* EGL_EGLEXT_PROTOTYPES */ typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); @@ -325,6 +325,86 @@ typedef EGLuint64 (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC)(void); typedef EGLuint64 (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC)(void); #endif +#if KHRONOS_SUPPORT_INT64 /* EGLuint64KHR requires 64-bit uint support */ +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 +typedef void* EGLStreamKHR; +typedef khronos_uint64_t EGLuint64KHR; +#define EGL_NO_STREAM_KHR ((EGLStreamKHR)0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR(EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC)(EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR(EGLDisplay dpy, EGLStreamKHR stream); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#define EGL_STREAM_BIT_KHR 0x0800 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#endif +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 +/* reuse EGLTimeKHR */ +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif + #ifndef EGL_EXT_create_context_robustness #define EGL_EXT_create_context_robustness 1 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF @@ -359,8 +439,170 @@ typedef EGLuint64 (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC)(void); #endif +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 +/* reuse EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE */ +#endif + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 +/* No tokens/entry points, just relaxes an error condition */ +#endif + +#ifdef EGL_KHR_stream /* Requires KHR_stream extension */ +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 +typedef int EGLNativeFileDescriptorKHR; +#define EGL_NO_FILE_DESCRIPTOR_KHR ((EGLNativeFileDescriptorKHR)(-1)) +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR(EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC)(EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif + +#ifndef EGL_EXT_multiview_window +#define EGL_EXT_multiview_window 1 +#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 +#endif + +#ifndef EGL_KHR_wait_sync +#define EGL_KHR_wait_sync 1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif + +#ifndef EGL_NV_post_convert_rounding +#define EGL_NV_post_convert_rounding 1 +/* No tokens or entry points, just relaxes behavior of SwapBuffers */ +#endif + +#ifndef EGL_NV_native_query +#define EGL_NV_native_query 1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV( EGLDisplay dpy, EGLNativeDisplayType* display_id); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV( EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType* window); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV( EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType* pixmap); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC)(EGLDisplay dpy, EGLNativeDisplayType *display_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC)(EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#endif + +#ifndef EGL_NV_3dvision_surface +#define EGL_NV_3dvision_surface 1 +#define EGL_AUTO_STEREO_NV 0x3136 +#endif + +#ifndef EGL_ANDROID_framebuffer_target +#define EGL_ANDROID_framebuffer_target 1 +#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 +#endif + +/** FIXME: If desired - need manual binding */ +#if 0 +#ifndef EGL_ANDROID_blob_cache +#define EGL_ANDROID_blob_cache 1 +typedef khronos_ssize_t EGLsizeiANDROID; +typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); +typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)(EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif +#endif + +#ifndef EGL_ANDROID_image_native_buffer +#define EGL_ANDROID_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_ANDROID 0x3140 +#endif + +#ifndef EGL_ANDROID_native_fence_sync +#define EGL_ANDROID_native_fence_sync 1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 +#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID( EGLDisplay dpy, EGLSyncKHR); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC)(EGLDisplay dpy, EGLSyncKHR); +#endif + +#ifndef EGL_ANDROID_recordable +#define EGL_ANDROID_recordable 1 +#define EGL_RECORDABLE_ANDROID 0x3142 +#endif + +#ifndef EGL_EXT_buffer_age +#define EGL_EXT_buffer_age 1 +#define EGL_BUFFER_AGE_EXT 0x313D +#endif + +#ifndef EGL_EXT_image_dma_buf_import +#define EGL_EXT_image_dma_buf_import 1 +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#endif + +#ifndef EGL_ARM_pixmap_multisample_discard +#define EGL_ARM_pixmap_multisample_discard 1 +#define EGL_DISCARD_SAMPLES_ARM 0x3286 +#endif + +#ifndef EGL_EXT_swap_buffers_with_damage +#define EGL_EXT_swap_buffers_with_damage 1 +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT( EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif /* EGL_EGLEXT_PROTOTYPES */ +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC)(EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif + + #ifdef __cplusplus } #endif -#endif +#endif /* __eglext_h_ */ diff --git a/make/stub_includes/opengl/GL/gl-platform.h b/make/stub_includes/opengl/GL/gl-platform.h new file mode 100644 index 000000000..58df2cfd3 --- /dev/null +++ b/make/stub_includes/opengl/GL/gl-platform.h @@ -0,0 +1,80 @@ +#ifndef __gl_platform_h_ +#define __gl_platform_h_ + +#if defined(__BEOS__) +#include /* to get some BeOS-isms */ +#endif + +#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO)) +#define OPENSTEP +#endif + +#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) +#define __WIN32__ +#endif + +#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) +# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define GLAPI __declspec(dllexport) +# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define GLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define GLAPI extern +# endif /* _STATIC_MESA support */ +# define APIENTRY __stdcall +#else +/* non-Windows compilation */ +# ifndef GLAPI +# define GLAPI extern +# endif +# define APIENTRY +#endif /* WIN32 / CYGWIN bracket */ + +#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__) +# define PRAGMA_EXPORT_SUPPORTED 1 +#endif + +/* + * WINDOWS: Include windows.h here to define APIENTRY. + * It is also useful when applications include this file by + * including only glut.h, since glut.h depends on windows.h. + * Applications needing to include windows.h with parms other + * than "WIN32_LEAN_AND_MEAN" may include windows.h before + * glut.h or gl.h. + */ +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__) +#include +#endif + +#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED +#pragma import on +#endif + +#ifdef CENTERLINE_CLPP +#define signed +#endif + +#if defined(PRAGMA_EXPORT_SUPPORTED) +#pragma export on +#endif + +/** + * The defaults for all .. + */ +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +#endif /* __gl_platform_h_ */ + diff --git a/make/stub_includes/opengl/GL/gl.h b/make/stub_includes/opengl/GL/gl.h index 0fe44172e..f6cfc7920 100644 --- a/make/stub_includes/opengl/GL/gl.h +++ b/make/stub_includes/opengl/GL/gl.h @@ -33,25 +33,9 @@ #ifndef __gl_h_ #define __gl_h_ -/* Function declaration macros - to move into glplatform.h */ -#include "glplatform.h" - -#ifndef GLAPIENTRY -#define GLAPIENTRY -#endif -#ifndef GLAPIENTRYP -#define GLAPIENTRYP GLAPIENTRY* -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -#ifndef APIENTRY -#define APIENTRY GLAPIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP GLAPIENTRYP -#endif +/* Function declaration macros - to move into gl-platform.h */ +#include "gl-platform.h" +#include "gl-types.h" #ifdef __cplusplus extern "C" { @@ -602,438 +586,438 @@ typedef double GLclampd; /* double precision float in [0,1] */ * Miscellaneous */ -GLAPI void GLAPIENTRY glClearIndex( GLfloat c ); +GLAPI void APIENTRY glClearIndex( GLfloat c ); -GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); +GLAPI void APIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ); -GLAPI void GLAPIENTRY glClear( GLbitfield mask ); +GLAPI void APIENTRY glClear( GLbitfield mask ); -GLAPI void GLAPIENTRY glIndexMask( GLuint mask ); +GLAPI void APIENTRY glIndexMask( GLuint mask ); -GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); +GLAPI void APIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); -GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref ); +GLAPI void APIENTRY glAlphaFunc( GLenum func, GLclampf ref ); -GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); +GLAPI void APIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor ); -GLAPI void GLAPIENTRY glLogicOp( GLenum opcode ); +GLAPI void APIENTRY glLogicOp( GLenum opcode ); -GLAPI void GLAPIENTRY glCullFace( GLenum mode ); +GLAPI void APIENTRY glCullFace( GLenum mode ); -GLAPI void GLAPIENTRY glFrontFace( GLenum mode ); +GLAPI void APIENTRY glFrontFace( GLenum mode ); -GLAPI void GLAPIENTRY glPointSize( GLfloat size ); +GLAPI void APIENTRY glPointSize( GLfloat size ); -GLAPI void GLAPIENTRY glLineWidth( GLfloat width ); +GLAPI void APIENTRY glLineWidth( GLfloat width ); -GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern ); +GLAPI void APIENTRY glLineStipple( GLint factor, GLushort pattern ); -GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode ); +GLAPI void APIENTRY glPolygonMode( GLenum face, GLenum mode ); -GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); +GLAPI void APIENTRY glPolygonOffset( GLfloat factor, GLfloat units ); -GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask ); +GLAPI void APIENTRY glPolygonStipple( const GLubyte *mask ); -GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask ); +GLAPI void APIENTRY glGetPolygonStipple( GLubyte *mask ); -GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag ); +GLAPI void APIENTRY glEdgeFlag( GLboolean flag ); -GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag ); +GLAPI void APIENTRY glEdgeFlagv( const GLboolean *flag ); -GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); +GLAPI void APIENTRY glClipPlane( GLenum plane, const GLdouble *equation ); -GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); +GLAPI void APIENTRY glGetClipPlane( GLenum plane, GLdouble *equation ); -GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode ); +GLAPI void APIENTRY glDrawBuffer( GLenum mode ); -GLAPI void GLAPIENTRY glReadBuffer( GLenum mode ); +GLAPI void APIENTRY glReadBuffer( GLenum mode ); -GLAPI void GLAPIENTRY glEnable( GLenum cap ); +GLAPI void APIENTRY glEnable( GLenum cap ); -GLAPI void GLAPIENTRY glDisable( GLenum cap ); +GLAPI void APIENTRY glDisable( GLenum cap ); -GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap ); +GLAPI GLboolean APIENTRY glIsEnabled( GLenum cap ); -GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); +GLAPI void APIENTRY glGetBooleanv( GLenum pname, GLboolean *params ); -GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params ); +GLAPI void APIENTRY glGetDoublev( GLenum pname, GLdouble *params ); -GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params ); +GLAPI void APIENTRY glGetFloatv( GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params ); +GLAPI void APIENTRY glGetIntegerv( GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask ); +GLAPI void APIENTRY glPushAttrib( GLbitfield mask ); -GLAPI void GLAPIENTRY glPopAttrib( void ); +GLAPI void APIENTRY glPopAttrib( void ); -GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode ); +GLAPI GLint APIENTRY glRenderMode( GLenum mode ); -GLAPI GLenum GLAPIENTRY glGetError( void ); +GLAPI GLenum APIENTRY glGetError( void ); -GLAPI const GLubyte* GLAPIENTRY glGetString( GLenum name ); +GLAPI const GLubyte* APIENTRY glGetString( GLenum name ); -GLAPI void GLAPIENTRY glFinish( void ); +GLAPI void APIENTRY glFinish( void ); -GLAPI void GLAPIENTRY glFlush( void ); +GLAPI void APIENTRY glFlush( void ); -GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode ); +GLAPI void APIENTRY glHint( GLenum target, GLenum mode ); /* * Depth Buffer */ -GLAPI void GLAPIENTRY glClearDepth( GLclampd depth ); +GLAPI void APIENTRY glClearDepth( GLclampd depth ); -GLAPI void GLAPIENTRY glDepthFunc( GLenum func ); +GLAPI void APIENTRY glDepthFunc( GLenum func ); -GLAPI void GLAPIENTRY glDepthMask( GLboolean flag ); +GLAPI void APIENTRY glDepthMask( GLboolean flag ); -GLAPI void GLAPIENTRY glDepthRange( GLclampd zNear, GLclampd zFar ); +GLAPI void APIENTRY glDepthRange( GLclampd zNear, GLclampd zFar ); /* * Accumulation Buffer */ -GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); +GLAPI void APIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); -GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value ); +GLAPI void APIENTRY glAccum( GLenum op, GLfloat value ); /* * Transformation */ -GLAPI void GLAPIENTRY glMatrixMode( GLenum mode ); +GLAPI void APIENTRY glMatrixMode( GLenum mode ); -GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right, +GLAPI void APIENTRY glOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); -GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right, +GLAPI void APIENTRY glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ); -GLAPI void GLAPIENTRY glViewport( GLint x, GLint y, +GLAPI void APIENTRY glViewport( GLint x, GLint y, GLsizei width, GLsizei height ); -GLAPI void GLAPIENTRY glPushMatrix( void ); +GLAPI void APIENTRY glPushMatrix( void ); -GLAPI void GLAPIENTRY glPopMatrix( void ); +GLAPI void APIENTRY glPopMatrix( void ); -GLAPI void GLAPIENTRY glLoadIdentity( void ); +GLAPI void APIENTRY glLoadIdentity( void ); -GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m ); -GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m ); +GLAPI void APIENTRY glLoadMatrixd( const GLdouble *m ); +GLAPI void APIENTRY glLoadMatrixf( const GLfloat *m ); -GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m ); -GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m ); +GLAPI void APIENTRY glMultMatrixd( const GLdouble *m ); +GLAPI void APIENTRY glMultMatrixf( const GLfloat *m ); -GLAPI void GLAPIENTRY glRotated( GLdouble angle, +GLAPI void APIENTRY glRotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glRotatef( GLfloat angle, +GLAPI void APIENTRY glRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void APIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void APIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void APIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void APIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z ); /* * Display Lists */ -GLAPI GLboolean GLAPIENTRY glIsList( GLuint list ); +GLAPI GLboolean APIENTRY glIsList( GLuint list ); -GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range ); +GLAPI void APIENTRY glDeleteLists( GLuint list, GLsizei range ); -GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range ); +GLAPI GLuint APIENTRY glGenLists( GLsizei range ); -GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode ); +GLAPI void APIENTRY glNewList( GLuint list, GLenum mode ); -GLAPI void GLAPIENTRY glEndList( void ); +GLAPI void APIENTRY glEndList( void ); -GLAPI void GLAPIENTRY glCallList( GLuint list ); +GLAPI void APIENTRY glCallList( GLuint list ); -GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type, +GLAPI void APIENTRY glCallLists( GLsizei n, GLenum type, const GLvoid *lists ); -GLAPI void GLAPIENTRY glListBase( GLuint base ); +GLAPI void APIENTRY glListBase( GLuint base ); /* * Drawing Functions */ -GLAPI void GLAPIENTRY glBegin( GLenum mode ); +GLAPI void APIENTRY glBegin( GLenum mode ); -GLAPI void GLAPIENTRY glEnd( void ); +GLAPI void APIENTRY glEnd( void ); -GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y ); -GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y ); -GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y ); -GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y ); +GLAPI void APIENTRY glVertex2d( GLdouble x, GLdouble y ); +GLAPI void APIENTRY glVertex2f( GLfloat x, GLfloat y ); +GLAPI void APIENTRY glVertex2i( GLint x, GLint y ); +GLAPI void APIENTRY glVertex2s( GLshort x, GLshort y ); -GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z ); -GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); +GLAPI void APIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void APIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void APIENTRY glVertex3i( GLint x, GLint y, GLint z ); +GLAPI void APIENTRY glVertex3s( GLshort x, GLshort y, GLshort z ); -GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); -GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); -GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); -GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); +GLAPI void APIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void APIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void APIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void APIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ); -GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glVertex2iv( const GLint *v ); -GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v ); +GLAPI void APIENTRY glVertex2dv( const GLdouble *v ); +GLAPI void APIENTRY glVertex2fv( const GLfloat *v ); +GLAPI void APIENTRY glVertex2iv( const GLint *v ); +GLAPI void APIENTRY glVertex2sv( const GLshort *v ); -GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glVertex3iv( const GLint *v ); -GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v ); +GLAPI void APIENTRY glVertex3dv( const GLdouble *v ); +GLAPI void APIENTRY glVertex3fv( const GLfloat *v ); +GLAPI void APIENTRY glVertex3iv( const GLint *v ); +GLAPI void APIENTRY glVertex3sv( const GLshort *v ); -GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glVertex4iv( const GLint *v ); -GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v ); +GLAPI void APIENTRY glVertex4dv( const GLdouble *v ); +GLAPI void APIENTRY glVertex4fv( const GLfloat *v ); +GLAPI void APIENTRY glVertex4iv( const GLint *v ); +GLAPI void APIENTRY glVertex4sv( const GLshort *v ); -GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); -GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); -GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); -GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); -GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); +GLAPI void APIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ); +GLAPI void APIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ); +GLAPI void APIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ); +GLAPI void APIENTRY glNormal3i( GLint nx, GLint ny, GLint nz ); +GLAPI void APIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz ); -GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v ); -GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glNormal3iv( const GLint *v ); -GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v ); +GLAPI void APIENTRY glNormal3bv( const GLbyte *v ); +GLAPI void APIENTRY glNormal3dv( const GLdouble *v ); +GLAPI void APIENTRY glNormal3fv( const GLfloat *v ); +GLAPI void APIENTRY glNormal3iv( const GLint *v ); +GLAPI void APIENTRY glNormal3sv( const GLshort *v ); -GLAPI void GLAPIENTRY glIndexd( GLdouble c ); -GLAPI void GLAPIENTRY glIndexf( GLfloat c ); -GLAPI void GLAPIENTRY glIndexi( GLint c ); -GLAPI void GLAPIENTRY glIndexs( GLshort c ); +GLAPI void APIENTRY glIndexd( GLdouble c ); +GLAPI void APIENTRY glIndexf( GLfloat c ); +GLAPI void APIENTRY glIndexi( GLint c ); +GLAPI void APIENTRY glIndexs( GLshort c ); -GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c ); -GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c ); -GLAPI void GLAPIENTRY glIndexiv( const GLint *c ); -GLAPI void GLAPIENTRY glIndexsv( const GLshort *c ); +GLAPI void APIENTRY glIndexdv( const GLdouble *c ); +GLAPI void APIENTRY glIndexfv( const GLfloat *c ); +GLAPI void APIENTRY glIndexiv( const GLint *c ); +GLAPI void APIENTRY glIndexsv( const GLshort *c ); -GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); -GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); -GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); -GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue ); -GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); -GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); -GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); -GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); +GLAPI void APIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue ); +GLAPI void APIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue ); +GLAPI void APIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue ); +GLAPI void APIENTRY glColor3i( GLint red, GLint green, GLint blue ); +GLAPI void APIENTRY glColor3s( GLshort red, GLshort green, GLshort blue ); +GLAPI void APIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue ); +GLAPI void APIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue ); +GLAPI void APIENTRY glColor3us( GLushort red, GLushort green, GLushort blue ); -GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green, +GLAPI void APIENTRY glColor4b( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ); -GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green, +GLAPI void APIENTRY glColor4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ); -GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green, +GLAPI void APIENTRY glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ); -GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green, +GLAPI void APIENTRY glColor4i( GLint red, GLint green, GLint blue, GLint alpha ); -GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green, +GLAPI void APIENTRY glColor4s( GLshort red, GLshort green, GLshort blue, GLshort alpha ); -GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green, +GLAPI void APIENTRY glColor4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ); -GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green, +GLAPI void APIENTRY glColor4ui( GLuint red, GLuint green, GLuint blue, GLuint alpha ); -GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green, +GLAPI void APIENTRY glColor4us( GLushort red, GLushort green, GLushort blue, GLushort alpha ); -GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v ); -GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glColor3iv( const GLint *v ); -GLAPI void GLAPIENTRY glColor3sv( const GLshort *v ); -GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v ); -GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v ); -GLAPI void GLAPIENTRY glColor3usv( const GLushort *v ); - -GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v ); -GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glColor4iv( const GLint *v ); -GLAPI void GLAPIENTRY glColor4sv( const GLshort *v ); -GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v ); -GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v ); -GLAPI void GLAPIENTRY glColor4usv( const GLushort *v ); - - -GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s ); -GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s ); -GLAPI void GLAPIENTRY glTexCoord1i( GLint s ); -GLAPI void GLAPIENTRY glTexCoord1s( GLshort s ); - -GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t ); -GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t ); -GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t ); -GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t ); - -GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); -GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); -GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); -GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); - -GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); -GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); -GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); -GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); - -GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v ); -GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v ); - - -GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y ); -GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y ); -GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y ); -GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y ); - -GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); -GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); -GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); -GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); - -GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); -GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); -GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); -GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); - -GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v ); -GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v ); -GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v ); - -GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v ); -GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v ); -GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v ); -GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v ); - - -GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); -GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); -GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); -GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); - - -GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); -GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); -GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 ); -GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); +GLAPI void APIENTRY glColor3bv( const GLbyte *v ); +GLAPI void APIENTRY glColor3dv( const GLdouble *v ); +GLAPI void APIENTRY glColor3fv( const GLfloat *v ); +GLAPI void APIENTRY glColor3iv( const GLint *v ); +GLAPI void APIENTRY glColor3sv( const GLshort *v ); +GLAPI void APIENTRY glColor3ubv( const GLubyte *v ); +GLAPI void APIENTRY glColor3uiv( const GLuint *v ); +GLAPI void APIENTRY glColor3usv( const GLushort *v ); + +GLAPI void APIENTRY glColor4bv( const GLbyte *v ); +GLAPI void APIENTRY glColor4dv( const GLdouble *v ); +GLAPI void APIENTRY glColor4fv( const GLfloat *v ); +GLAPI void APIENTRY glColor4iv( const GLint *v ); +GLAPI void APIENTRY glColor4sv( const GLshort *v ); +GLAPI void APIENTRY glColor4ubv( const GLubyte *v ); +GLAPI void APIENTRY glColor4uiv( const GLuint *v ); +GLAPI void APIENTRY glColor4usv( const GLushort *v ); + + +GLAPI void APIENTRY glTexCoord1d( GLdouble s ); +GLAPI void APIENTRY glTexCoord1f( GLfloat s ); +GLAPI void APIENTRY glTexCoord1i( GLint s ); +GLAPI void APIENTRY glTexCoord1s( GLshort s ); + +GLAPI void APIENTRY glTexCoord2d( GLdouble s, GLdouble t ); +GLAPI void APIENTRY glTexCoord2f( GLfloat s, GLfloat t ); +GLAPI void APIENTRY glTexCoord2i( GLint s, GLint t ); +GLAPI void APIENTRY glTexCoord2s( GLshort s, GLshort t ); + +GLAPI void APIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r ); +GLAPI void APIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r ); +GLAPI void APIENTRY glTexCoord3i( GLint s, GLint t, GLint r ); +GLAPI void APIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r ); + +GLAPI void APIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ); +GLAPI void APIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ); +GLAPI void APIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q ); +GLAPI void APIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ); + +GLAPI void APIENTRY glTexCoord1dv( const GLdouble *v ); +GLAPI void APIENTRY glTexCoord1fv( const GLfloat *v ); +GLAPI void APIENTRY glTexCoord1iv( const GLint *v ); +GLAPI void APIENTRY glTexCoord1sv( const GLshort *v ); + +GLAPI void APIENTRY glTexCoord2dv( const GLdouble *v ); +GLAPI void APIENTRY glTexCoord2fv( const GLfloat *v ); +GLAPI void APIENTRY glTexCoord2iv( const GLint *v ); +GLAPI void APIENTRY glTexCoord2sv( const GLshort *v ); + +GLAPI void APIENTRY glTexCoord3dv( const GLdouble *v ); +GLAPI void APIENTRY glTexCoord3fv( const GLfloat *v ); +GLAPI void APIENTRY glTexCoord3iv( const GLint *v ); +GLAPI void APIENTRY glTexCoord3sv( const GLshort *v ); + +GLAPI void APIENTRY glTexCoord4dv( const GLdouble *v ); +GLAPI void APIENTRY glTexCoord4fv( const GLfloat *v ); +GLAPI void APIENTRY glTexCoord4iv( const GLint *v ); +GLAPI void APIENTRY glTexCoord4sv( const GLshort *v ); + + +GLAPI void APIENTRY glRasterPos2d( GLdouble x, GLdouble y ); +GLAPI void APIENTRY glRasterPos2f( GLfloat x, GLfloat y ); +GLAPI void APIENTRY glRasterPos2i( GLint x, GLint y ); +GLAPI void APIENTRY glRasterPos2s( GLshort x, GLshort y ); + +GLAPI void APIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z ); +GLAPI void APIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z ); +GLAPI void APIENTRY glRasterPos3i( GLint x, GLint y, GLint z ); +GLAPI void APIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z ); + +GLAPI void APIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ); +GLAPI void APIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ); +GLAPI void APIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w ); +GLAPI void APIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ); + +GLAPI void APIENTRY glRasterPos2dv( const GLdouble *v ); +GLAPI void APIENTRY glRasterPos2fv( const GLfloat *v ); +GLAPI void APIENTRY glRasterPos2iv( const GLint *v ); +GLAPI void APIENTRY glRasterPos2sv( const GLshort *v ); + +GLAPI void APIENTRY glRasterPos3dv( const GLdouble *v ); +GLAPI void APIENTRY glRasterPos3fv( const GLfloat *v ); +GLAPI void APIENTRY glRasterPos3iv( const GLint *v ); +GLAPI void APIENTRY glRasterPos3sv( const GLshort *v ); + +GLAPI void APIENTRY glRasterPos4dv( const GLdouble *v ); +GLAPI void APIENTRY glRasterPos4fv( const GLfloat *v ); +GLAPI void APIENTRY glRasterPos4iv( const GLint *v ); +GLAPI void APIENTRY glRasterPos4sv( const GLshort *v ); + + +GLAPI void APIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ); +GLAPI void APIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ); +GLAPI void APIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 ); +GLAPI void APIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ); + + +GLAPI void APIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 ); +GLAPI void APIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 ); +GLAPI void APIENTRY glRectiv( const GLint *v1, const GLint *v2 ); +GLAPI void APIENTRY glRectsv( const GLshort *v1, const GLshort *v2 ); /* * Lighting */ -GLAPI void GLAPIENTRY glShadeModel( GLenum mode ); +GLAPI void APIENTRY glShadeModel( GLenum mode ); -GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname, +GLAPI void APIENTRY glLightf( GLenum light, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glLighti( GLenum light, GLenum pname, GLint param ); +GLAPI void APIENTRY glLightfv( GLenum light, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname, +GLAPI void APIENTRY glLightiv( GLenum light, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname, +GLAPI void APIENTRY glGetLightfv( GLenum light, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname, +GLAPI void APIENTRY glGetLightiv( GLenum light, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params ); +GLAPI void APIENTRY glLightModelf( GLenum pname, GLfloat param ); +GLAPI void APIENTRY glLightModeli( GLenum pname, GLint param ); +GLAPI void APIENTRY glLightModelfv( GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glLightModeliv( GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); +GLAPI void APIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glMateriali( GLenum face, GLenum pname, GLint param ); +GLAPI void APIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); +GLAPI void APIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ); +GLAPI void APIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode ); +GLAPI void APIENTRY glColorMaterial( GLenum face, GLenum mode ); /* * Raster functions */ -GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); +GLAPI void APIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor ); -GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param ); +GLAPI void APIENTRY glPixelStoref( GLenum pname, GLfloat param ); +GLAPI void APIENTRY glPixelStorei( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param ); +GLAPI void APIENTRY glPixelTransferf( GLenum pname, GLfloat param ); +GLAPI void APIENTRY glPixelTransferi( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLint mapsize, +GLAPI void APIENTRY glPixelMapfv( GLenum map, GLint mapsize, const GLfloat *values ); -GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLint mapsize, +GLAPI void APIENTRY glPixelMapuiv( GLenum map, GLint mapsize, const GLuint *values ); -GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLint mapsize, +GLAPI void APIENTRY glPixelMapusv( GLenum map, GLint mapsize, const GLushort *values ); -GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); -GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); -GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); +GLAPI void APIENTRY glGetPixelMapfv( GLenum map, GLfloat *values ); +GLAPI void APIENTRY glGetPixelMapuiv( GLenum map, GLuint *values ); +GLAPI void APIENTRY glGetPixelMapusv( GLenum map, GLushort *values ); -GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height, +GLAPI void APIENTRY glBitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap ); -GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y, +GLAPI void APIENTRY glReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels ); -GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height, +GLAPI void APIENTRY glDrawPixels( GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, +GLAPI void APIENTRY glCopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type ); @@ -1041,13 +1025,13 @@ GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y, * Stenciling */ -GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); +GLAPI void APIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask ); -GLAPI void GLAPIENTRY glStencilMask( GLuint mask ); +GLAPI void APIENTRY glStencilMask( GLuint mask ); -GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); +GLAPI void APIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass ); -GLAPI void GLAPIENTRY glClearStencil( GLint s ); +GLAPI void APIENTRY glClearStencil( GLint s ); @@ -1055,61 +1039,61 @@ GLAPI void GLAPIENTRY glClearStencil( GLint s ); * Texture mapping */ -GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); -GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); +GLAPI void APIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param ); +GLAPI void APIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); -GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); +GLAPI void APIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params ); +GLAPI void APIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); -GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); +GLAPI void APIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ); +GLAPI void APIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ); +GLAPI void APIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); +GLAPI void APIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); +GLAPI void APIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); +GLAPI void APIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ); +GLAPI void APIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); +GLAPI void APIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param ); +GLAPI void APIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname, +GLAPI void APIENTRY glTexParameterfv( GLenum target, GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname, +GLAPI void APIENTRY glTexParameteriv( GLenum target, GLenum pname, const GLint *params ); -GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target, +GLAPI void APIENTRY glGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params); -GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target, +GLAPI void APIENTRY glGetTexParameteriv( GLenum target, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, +GLAPI void APIENTRY glGetTexLevelParameterfv( GLenum target, GLint level, GLenum pname, GLfloat *params ); -GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, +GLAPI void APIENTRY glGetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ); -GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level, +GLAPI void APIENTRY glTexImage1D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level, +GLAPI void APIENTRY glTexImage2D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, +GLAPI void APIENTRY glGetTexImage( GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels ); @@ -1118,85 +1102,85 @@ GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level, * Evaluators */ -GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, +GLAPI void APIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points ); -GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, +GLAPI void APIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points ); -GLAPI void GLAPIENTRY glMap2d( GLenum target, +GLAPI void APIENTRY glMap2d( GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points ); -GLAPI void GLAPIENTRY glMap2f( GLenum target, +GLAPI void APIENTRY glMap2f( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points ); -GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); -GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); -GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); +GLAPI void APIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v ); +GLAPI void APIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v ); +GLAPI void APIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v ); -GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u ); -GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u ); +GLAPI void APIENTRY glEvalCoord1d( GLdouble u ); +GLAPI void APIENTRY glEvalCoord1f( GLfloat u ); -GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u ); -GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u ); +GLAPI void APIENTRY glEvalCoord1dv( const GLdouble *u ); +GLAPI void APIENTRY glEvalCoord1fv( const GLfloat *u ); -GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); -GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); +GLAPI void APIENTRY glEvalCoord2d( GLdouble u, GLdouble v ); +GLAPI void APIENTRY glEvalCoord2f( GLfloat u, GLfloat v ); -GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u ); -GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u ); +GLAPI void APIENTRY glEvalCoord2dv( const GLdouble *u ); +GLAPI void APIENTRY glEvalCoord2fv( const GLfloat *u ); -GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); -GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); +GLAPI void APIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ); +GLAPI void APIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ); -GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, +GLAPI void APIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2 ); -GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, +GLAPI void APIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2 ); -GLAPI void GLAPIENTRY glEvalPoint1( GLint i ); +GLAPI void APIENTRY glEvalPoint1( GLint i ); -GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j ); +GLAPI void APIENTRY glEvalPoint2( GLint i, GLint j ); -GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); +GLAPI void APIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 ); -GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); +GLAPI void APIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ); /* * Fog */ -GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param ); +GLAPI void APIENTRY glFogf( GLenum pname, GLfloat param ); -GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param ); +GLAPI void APIENTRY glFogi( GLenum pname, GLint param ); -GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params ); +GLAPI void APIENTRY glFogfv( GLenum pname, const GLfloat *params ); -GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params ); +GLAPI void APIENTRY glFogiv( GLenum pname, const GLint *params ); /* * Selection and Feedback */ -GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); +GLAPI void APIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ); -GLAPI void GLAPIENTRY glPassThrough( GLfloat token ); +GLAPI void APIENTRY glPassThrough( GLfloat token ); -GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); +GLAPI void APIENTRY glSelectBuffer( GLsizei size, GLuint *buffer ); -GLAPI void GLAPIENTRY glInitNames( void ); +GLAPI void APIENTRY glInitNames( void ); -GLAPI void GLAPIENTRY glLoadName( GLuint name ); +GLAPI void APIENTRY glLoadName( GLuint name ); -GLAPI void GLAPIENTRY glPushName( GLuint name ); +GLAPI void APIENTRY glPushName( GLuint name ); -GLAPI void GLAPIENTRY glPopName( void ); +GLAPI void APIENTRY glPopName( void ); #endif /* GL_VERSION_1_0 */ @@ -1296,37 +1280,37 @@ GLAPI void GLAPIENTRY glPopName( void ); #define GL_T2F_C4F_N3F_V3F 0x2A2C #define GL_T4F_C4F_N3F_V4F 0x2A2D -GLAPI void GLAPIENTRY glIndexub( GLubyte c ); -GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); - -GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); -GLAPI void GLAPIENTRY glPopClientAttrib( void ); -GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); -GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); -GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); -GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params ); -GLAPI void GLAPIENTRY glArrayElement( GLint i ); -GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); -GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); -GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer ); - -GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures ); -GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); -GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture ); -GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n, const GLuint *textures, const GLclampf *priorities ); -GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n, const GLuint *textures, GLboolean *residences ); -GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture ); -GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); -GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border ); -GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ); -GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ); -GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ); +GLAPI void APIENTRY glIndexub( GLubyte c ); +GLAPI void APIENTRY glIndexubv( const GLubyte *c ); + +GLAPI void APIENTRY glPushClientAttrib( GLbitfield mask ); +GLAPI void APIENTRY glPopClientAttrib( void ); +GLAPI void APIENTRY glEnableClientState( GLenum cap ); +GLAPI void APIENTRY glDisableClientState( GLenum cap ); +GLAPI void APIENTRY glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glNormalPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glIndexPointer( GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr ); +GLAPI void APIENTRY glGetPointerv( GLenum pname, GLvoid **params ); +GLAPI void APIENTRY glArrayElement( GLint i ); +GLAPI void APIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count ); +GLAPI void APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ); +GLAPI void APIENTRY glInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer ); + +GLAPI void APIENTRY glGenTextures( GLsizei n, GLuint *textures ); +GLAPI void APIENTRY glDeleteTextures( GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glBindTexture( GLenum target, GLuint texture ); +GLAPI void APIENTRY glPrioritizeTextures( GLsizei n, const GLuint *textures, const GLclampf *priorities ); +GLAPI GLboolean APIENTRY glAreTexturesResident( GLsizei n, const GLuint *textures, GLboolean *residences ); +GLAPI GLboolean APIENTRY glIsTexture( GLuint texture ); +GLAPI void APIENTRY glTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels ); +GLAPI void APIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels ); +GLAPI void APIENTRY glCopyTexImage1D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border ); +GLAPI void APIENTRY glCopyTexImage2D( GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border ); +GLAPI void APIENTRY glCopyTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width ); +GLAPI void APIENTRY glCopyTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height ); #endif /* GL_VERSION_1_1 */ diff --git a/make/stub_includes/opengl/GL/glcorearb.h b/make/stub_includes/opengl/GL/glcorearb.h new file mode 100644 index 000000000..9316b48da --- /dev/null +++ b/make/stub_includes/opengl/GL/glcorearb.h @@ -0,0 +1,3262 @@ +#ifndef __glcorearb_h_ +#define __glcorearb_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2013 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision$ on $Date$ +*/ + +/* Function declaration macros - to move into gl-platform.h */ +#include "gl-platform.h" +#include "gl-types.h" + +/* glcorearb.h is for use with OpenGL core profile implementations. +** It should should be placed in the same directory as gl.h and +** included as . +** +** glcorearb.h includes only APIs in the latest OpenGL core profile +** implementation together with APIs in newer ARB extensions which +** can be supported by the core profile. It does not, and never will +** include functionality removed from the core profile, such as +** fixed-function vertex and fragment processing. +** +** Do not #include both and either of or +** in the same source file. +*/ + +/* Generated C header for: + * API: gl + * Profile: core + * Versions considered: .* + * Versions emitted: .* + * Default extensions included: glcore + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif /* GL_ARB_imaging */ + +#ifndef GL_VERSION_1_0 +#define GL_VERSION_1_0 1 +typedef unsigned int GLenum; +typedef float GLfloat; +typedef int GLint; +typedef int GLsizei; +typedef void GLvoid; +typedef unsigned int GLbitfield; +typedef double GLdouble; +typedef unsigned int GLuint; +typedef unsigned char GLboolean; +typedef unsigned char GLubyte; +typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef void (APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size); +typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLFINISHPROC) (void); +typedef void (APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (APIENTRYP PFNGLLOGICOPPROC) (GLenum opcode); +typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *params); +typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) (GLdouble near, GLdouble far); +typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullFace (GLenum mode); +GLAPI void APIENTRY glFrontFace (GLenum mode); +GLAPI void APIENTRY glHint (GLenum target, GLenum mode); +GLAPI void APIENTRY glLineWidth (GLfloat width); +GLAPI void APIENTRY glPointSize (GLfloat size); +GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); +GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glDrawBuffer (GLenum mode); +GLAPI void APIENTRY glClear (GLbitfield mask); +GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glClearStencil (GLint s); +GLAPI void APIENTRY glClearDepth (GLdouble depth); +GLAPI void APIENTRY glStencilMask (GLuint mask); +GLAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GLAPI void APIENTRY glDepthMask (GLboolean flag); +GLAPI void APIENTRY glDisable (GLenum cap); +GLAPI void APIENTRY glEnable (GLenum cap); +GLAPI void APIENTRY glFinish (void); +GLAPI void APIENTRY glFlush (void); +GLAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GLAPI void APIENTRY glLogicOp (GLenum opcode); +GLAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GLAPI void APIENTRY glDepthFunc (GLenum func); +GLAPI void APIENTRY glPixelStoref (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); +GLAPI void APIENTRY glReadBuffer (GLenum mode); +GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetBooleanv (GLenum pname, GLboolean *params); +GLAPI void APIENTRY glGetDoublev (GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glGetError (void); +GLAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *params); +GLAPI const GLubyte *APIENTRY glGetString (GLenum name); +GLAPI void APIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); +GLAPI void APIENTRY glDepthRange (GLdouble near, GLdouble far); +GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_0 */ + +#ifndef GL_VERSION_1_1 +#define GL_VERSION_1_1 1 +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_QUADS 0x0007 +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_NONE 0 +#define GL_FRONT_LEFT 0x0400 +#define GL_FRONT_RIGHT 0x0401 +#define GL_BACK_LEFT 0x0402 +#define GL_BACK_RIGHT 0x0403 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_LEFT 0x0406 +#define GL_RIGHT 0x0407 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_POINT_SIZE 0x0B11 +#define GL_POINT_SIZE_RANGE 0x0B12 +#define GL_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_LINE_SMOOTH 0x0B20 +#define GL_LINE_WIDTH 0x0B21 +#define GL_LINE_WIDTH_RANGE 0x0B22 +#define GL_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_POLYGON_MODE 0x0B40 +#define GL_POLYGON_SMOOTH 0x0B41 +#define GL_CULL_FACE 0x0B44 +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_TEST 0x0B71 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_TEST 0x0B90 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_VIEWPORT 0x0BA2 +#define GL_DITHER 0x0BD0 +#define GL_BLEND_DST 0x0BE0 +#define GL_BLEND_SRC 0x0BE1 +#define GL_BLEND 0x0BE2 +#define GL_LOGIC_OP_MODE 0x0BF0 +#define GL_COLOR_LOGIC_OP 0x0BF2 +#define GL_DRAW_BUFFER 0x0C01 +#define GL_READ_BUFFER 0x0C02 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_DOUBLEBUFFER 0x0C32 +#define GL_STEREO 0x0C33 +#define GL_LINE_SMOOTH_HINT 0x0C52 +#define GL_POLYGON_SMOOTH_HINT 0x0C53 +#define GL_UNPACK_SWAP_BYTES 0x0CF0 +#define GL_UNPACK_LSB_FIRST 0x0CF1 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_SWAP_BYTES 0x0D00 +#define GL_PACK_LSB_FIRST 0x0D01 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_TEXTURE_1D 0x0DE0 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_POINT 0x2A01 +#define GL_POLYGON_OFFSET_LINE 0x2A02 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_1D 0x8068 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_DOUBLE 0x140A +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_CLEAR 0x1500 +#define GL_AND 0x1501 +#define GL_AND_REVERSE 0x1502 +#define GL_COPY 0x1503 +#define GL_AND_INVERTED 0x1504 +#define GL_NOOP 0x1505 +#define GL_XOR 0x1506 +#define GL_OR 0x1507 +#define GL_NOR 0x1508 +#define GL_EQUIV 0x1509 +#define GL_INVERT 0x150A +#define GL_OR_REVERSE 0x150B +#define GL_COPY_INVERTED 0x150C +#define GL_OR_INVERTED 0x150D +#define GL_NAND 0x150E +#define GL_SET 0x150F +#define GL_TEXTURE 0x1702 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_STENCIL_INDEX 0x1901 +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_RED 0x1903 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_POINT 0x1B00 +#define GL_LINE 0x1B01 +#define GL_FILL 0x1B02 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_PROXY_TEXTURE_1D 0x8063 +#define GL_PROXY_TEXTURE_2D 0x8064 +#define GL_REPEAT 0x2901 +#define GL_R3_G3_B2 0x2A10 +#define GL_RGB4 0x804F +#define GL_RGB5 0x8050 +#define GL_RGB8 0x8051 +#define GL_RGB10 0x8052 +#define GL_RGB12 0x8053 +#define GL_RGB16 0x8054 +#define GL_RGBA2 0x8055 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_RGBA12 0x805A +#define GL_RGBA16 0x805B +typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, GLvoid **params); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glGetPointerv (GLenum pname, GLvoid **params); +GLAPI void APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTexture (GLuint texture); +#endif +#endif /* GL_VERSION_1_1 */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_VERSION_1_2 */ + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#include +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +typedef short GLshort; +typedef signed char GLbyte; +typedef unsigned short GLushort; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif +#endif /* GL_VERSION_3_0 */ + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif +#endif /* GL_VERSION_3_1 */ + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif +typedef int64_t GLint64; +typedef struct __GLsync *GLsync; +typedef uint64_t GLuint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); +#endif +#endif /* GL_VERSION_3_2 */ + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif +#endif /* GL_VERSION_3_3 */ + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_VERSION_4_0 */ + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glClearDepthf (GLfloat depth); +#endif /* GL_GLEXT_PROTOTYPES */ +#endif /* GL_ARB_ES2_compatibility */ + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#endif /* GL_ARB_ES2_compatibility */ +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +#ifndef GL_ARB_ES2_compatibility +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +#endif /* GL_ARB_ES2_compatibility */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#ifdef GL_GLEXT_PROTOTYPES +#ifndef GL_ARB_ES2_compatibility +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glClearDepthf (GLfloat depth); +#endif /* GL_ARB_ES2_compatibility */ +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif +#endif /* GL_VERSION_4_1 */ + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#ifndef GL_ARB_ES3_compatibility +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif /* GL_ARB_ES3_compatibility */ +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +typedef struct _cl_context * cl_context; +typedef struct _cl_event * cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (cl_context context, cl_event event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (cl_context context, cl_event event, GLbitfield flags); +#endif +#endif /* GL_ARB_cl_event */ + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif +#endif /* GL_ARB_clear_buffer_object */ + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif +#endif /* GL_ARB_draw_buffers_blend */ + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_ARB_internalformat_query */ + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#endif /* GL_ARB_internalformat_query2 */ + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif +#endif /* GL_ARB_robustness */ + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif +#endif /* GL_ARB_sample_shading */ + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif +#endif /* GL_ARB_shading_language_include */ + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#endif /* GL_ARB_transform_feedback2 */ + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#endif /* GL_ARB_uniform_buffer_object */ + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/make/stub_includes/opengl/GL/glcorearbext.h b/make/stub_includes/opengl/GL/glcorearbext.h new file mode 100644 index 000000000..8fab1ddee --- /dev/null +++ b/make/stub_includes/opengl/GL/glcorearbext.h @@ -0,0 +1,351 @@ +#ifndef __glcorearbext_h_ +#define __glcorearbext_h_ 1 + +/* +** Copyright (c) 2010 JogAmp Developer Team +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/** + * This header files contains additional extensions not covered by the + * 'official' khronos glcorearbext.h + */ + +/* + * ------------------------------------------------ + * Everything here and below was added manually + * to the version of glext.h obtained from: + * http://oss.sgi.com/projects/ogl-sample/registry/index.html + * ------------------------------------------------ + * + * Structure is: + * #ifndef GL_EXTENSION_NAME + * Add DEFINES here + * #endif + * #ifndef GL_EXTENSION_NAME + * Add TYPEDEFS here + * #endif + * #ifndef GL_EXTENSION_NAME + * #define GL_EXTENSION_NAME 1 + * #ifdef GL_GLEXT_PROTOTYPES + * Add FUNCTION DECLARATIONS here + * #endif + * FUNCTION POINTER DECLARATIONS NOT NEEDED + * #endif + */ + +/** + * 47. http://www.opengl.org/registry/specs/ARB/geometry_shader4.txt + */ +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +#ifndef GL_MAX_VARYING_COMPONENTS +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#endif +#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#endif +#endif +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #187 +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +// #363 http://www.opengl.org/registry/specs/AMD/vertex_shader_tessellator.txt +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#endif +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD(GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD(GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #379 http://www.opengl.org/registry/specs/NV/shader_buffer_load.txt +#ifndef GL_NV_shader_buffer_load +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +#endif +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #380 http://www.opengl.org/registry/specs/NV/vertex_buffer_unified_memory.txt +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +#endif +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsEnabled( GLenum cap ); // extra requirement in core GL3 +GLAPI void APIENTRY glEnableClientState( GLenum cap ); // extra requirement in core GL3 +GLAPI void APIENTRY glDisableClientState( GLenum cap ); // extra requirement in core GL3 +GLAPI void APIENTRY glBufferAddressRangeNV(GLenum pname, GLuint index, GLuint64 address, GLsizeiptr length); +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #395 +#ifndef GL_AMD_debug_output +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +#endif +#ifndef GL_AMD_debug_output +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif + +// #401 +#ifndef GL_AMD_depth_clamp_separate +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#endif + +// #402 +#ifndef GL_EXT_texture_sRGB_decode +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#endif + +// #403 +#ifndef GL_NV_texture_multisample +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +#endif +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #404 +#ifndef GL_AMD_blend_minmax_factor +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#endif + +// #405 +#ifndef GL_AMD_sample_positions +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#endif +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#endif + +// #406 +#ifndef GL_EXT_x11_sync_object +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +#endif +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #408 +#ifndef GL_AMD_multi_draw_indirect +#endif +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +// #409 +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#endif + +// #410 GL_NV_path_rendering ? + +// #411 +#ifndef GL_AMD_pinned_memory +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#endif + +// #413 +#ifndef GL_AMD_stencil_operation_extended +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +#endif +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif /* GL_GLEXT_PROTOTYPES */ +/* No need for explicit function pointer: we force generation of ProcAddress .. */ +#endif + +#endif /* __glcorearbext_h_ */ + diff --git a/make/stub_includes/opengl/GL/glext.h b/make/stub_includes/opengl/GL/glext.h index 6048075f9..cba6c98fb 100644 --- a/make/stub_includes/opengl/GL/glext.h +++ b/make/stub_includes/opengl/GL/glext.h @@ -1,13 +1,13 @@ #ifndef __glext_h_ -#define __glext_h_ +#define __glext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** Copyright (c) 2007-2012 The Khronos Group Inc. -** +** Copyright (c) 2013 The Khronos Group Inc. +** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including @@ -15,10 +15,10 @@ extern "C" { ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are furnished to do so, subject to ** the following conditions: -** +** ** The above copyright notice and this permission notice shall be included ** in all copies or substantial portions of the Materials. -** +** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -27,78 +27,39 @@ extern "C" { ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision$ on $Date$ +*/ -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated $Date: 2012-01-26 02:44:56 -0800 (Thu, 26 Jan 2012) $ */ -/* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 75 -/* Function declaration macros - to move into glplatform.h */ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ +/* Function declaration macros - to move into gl-platform.h */ +#include "gl-platform.h" +#include "gl-types.h" -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif +#define GL_GLEXT_VERSION 20130615 -#ifndef GL_VERSION_1_2_DEPRECATED -#define GL_RESCALE_NORMAL 0x803A -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#endif +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ #ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +typedef unsigned int GLenum; +typedef int GLsizei; +typedef void GLvoid; +typedef float GLfloat; +typedef int GLint; +typedef unsigned char GLboolean; #define GL_CONSTANT_COLOR 0x8001 #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 #define GL_CONSTANT_ALPHA 0x8003 @@ -110,9 +71,6 @@ extern "C" { #define GL_BLEND_EQUATION 0x8009 #define GL_FUNC_SUBTRACT 0x800A #define GL_FUNC_REVERSE_SUBTRACT 0x800B -#endif - -#ifndef GL_ARB_imaging_DEPRECATED #define GL_CONVOLUTION_1D 0x8010 #define GL_CONVOLUTION_2D 0x8011 #define GL_SEPARABLE_2D 0x8012 @@ -177,9 +135,135 @@ extern "C" { #define GL_CONSTANT_BORDER 0x8151 #define GL_REPLICATE_BORDER 0x8153 #define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif +#endif /* GL_ARB_imaging */ + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif +#endif /* GL_VERSION_1_2 */ #ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 #define GL_TEXTURE0 0x84C0 #define GL_TEXTURE1 0x84C1 #define GL_TEXTURE2 0x84C2 @@ -239,9 +323,6 @@ extern "C" { #define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 #define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 #define GL_CLAMP_TO_BORDER 0x812D -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED #define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 #define GL_MAX_TEXTURE_UNITS 0x84E2 #define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 @@ -279,84 +360,270 @@ extern "C" { #define GL_PREVIOUS 0x8578 #define GL_DOT3_RGB 0x86AE #define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#endif - -#ifndef GL_VERSION_1_5_DEPRECATED +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif +#endif /* GL_VERSION_1_3 */ + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#include +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 #define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 #define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 #define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 @@ -378,11 +645,52 @@ extern "C" { #define GL_SRC1_RGB 0x8581 #define GL_SRC2_RGB 0x8582 #define GL_SRC0_ALPHA 0x8588 -#define GL_SRC1_ALPHA 0x8589 #define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid **params); #endif +#endif /* GL_VERSION_1_5 */ #ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; #define GL_BLEND_EQUATION_RGB 0x8009 #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 @@ -463,16 +771,202 @@ extern "C" { #define GL_STENCIL_BACK_REF 0x8CA3 #define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 #define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_0_DEPRECATED #define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 #define GL_POINT_SPRITE 0x8861 #define GL_COORD_REPLACE 0x8862 #define GL_MAX_TEXTURE_COORDS 0x8871 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); #endif +#endif /* GL_VERSION_2_0 */ #ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 #define GL_PIXEL_PACK_BUFFER 0x88EB #define GL_PIXEL_UNPACK_BUFFER 0x88EC #define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED @@ -489,9 +983,6 @@ extern "C" { #define GL_SRGB8_ALPHA8 0x8C43 #define GL_COMPRESSED_SRGB 0x8C48 #define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#endif - -#ifndef GL_VERSION_2_1_DEPRECATED #define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F #define GL_SLUMINANCE_ALPHA 0x8C44 #define GL_SLUMINANCE8_ALPHA8 0x8C45 @@ -499,9 +990,24 @@ extern "C" { #define GL_SLUMINANCE8 0x8C47 #define GL_COMPRESSED_SLUMINANCE 0x8C4A #define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); #endif +#endif /* GL_VERSION_2_1 */ #ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 #define GL_COMPARE_REF_TO_TEXTURE 0x884E #define GL_CLIP_DISTANCE0 0x3000 #define GL_CLIP_DISTANCE1 0x3001 @@ -516,11 +1022,9 @@ extern "C" { #define GL_MINOR_VERSION 0x821C #define GL_NUM_EXTENSIONS 0x821D #define GL_CONTEXT_FLAGS 0x821E -#define GL_DEPTH_BUFFER 0x8223 // n/a in spec, but other header files -#define GL_STENCIL_BUFFER 0x8224 // n/a in spec, but other header files #define GL_COMPRESSED_RED 0x8225 #define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 #define GL_RGBA32F 0x8814 #define GL_RGB32F 0x8815 #define GL_RGBA16F 0x881A @@ -604,10006 +1108,4758 @@ extern "C" { #define GL_BUFFER_ACCESS_FLAGS 0x911F #define GL_BUFFER_MAP_LENGTH 0x9120 #define GL_BUFFER_MAP_OFFSET 0x9121 -/* Reuse tokens from ARB_depth_buffer_float */ -/* reuse GL_DEPTH_COMPONENT32F */ -/* reuse GL_DEPTH32F_STENCIL8 */ -/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_DEFAULT */ -/* reuse GL_FRAMEBUFFER_UNDEFINED */ -/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ -/* reuse GL_INDEX */ -/* reuse GL_MAX_RENDERBUFFER_SIZE */ -/* reuse GL_DEPTH_STENCIL */ -/* reuse GL_UNSIGNED_INT_24_8 */ -/* reuse GL_DEPTH24_STENCIL8 */ -/* reuse GL_TEXTURE_STENCIL_SIZE */ -/* reuse GL_TEXTURE_RED_TYPE */ -/* reuse GL_TEXTURE_GREEN_TYPE */ -/* reuse GL_TEXTURE_BLUE_TYPE */ -/* reuse GL_TEXTURE_ALPHA_TYPE */ -/* reuse GL_TEXTURE_DEPTH_TYPE */ -/* reuse GL_UNSIGNED_NORMALIZED */ -/* reuse GL_FRAMEBUFFER_BINDING */ -/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_BINDING */ -/* reuse GL_READ_FRAMEBUFFER */ -/* reuse GL_DRAW_FRAMEBUFFER */ -/* reuse GL_READ_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_SAMPLES */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* reuse GL_FRAMEBUFFER_COMPLETE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ -/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ -/* reuse GL_MAX_COLOR_ATTACHMENTS */ -/* reuse GL_COLOR_ATTACHMENT0 */ -/* reuse GL_COLOR_ATTACHMENT1 */ -/* reuse GL_COLOR_ATTACHMENT2 */ -/* reuse GL_COLOR_ATTACHMENT3 */ -/* reuse GL_COLOR_ATTACHMENT4 */ -/* reuse GL_COLOR_ATTACHMENT5 */ -/* reuse GL_COLOR_ATTACHMENT6 */ -/* reuse GL_COLOR_ATTACHMENT7 */ -/* reuse GL_COLOR_ATTACHMENT8 */ -/* reuse GL_COLOR_ATTACHMENT9 */ -/* reuse GL_COLOR_ATTACHMENT10 */ -/* reuse GL_COLOR_ATTACHMENT11 */ -/* reuse GL_COLOR_ATTACHMENT12 */ -/* reuse GL_COLOR_ATTACHMENT13 */ -/* reuse GL_COLOR_ATTACHMENT14 */ -/* reuse GL_COLOR_ATTACHMENT15 */ -/* reuse GL_DEPTH_ATTACHMENT */ -/* reuse GL_STENCIL_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER */ -/* reuse GL_RENDERBUFFER */ -/* reuse GL_RENDERBUFFER_WIDTH */ -/* reuse GL_RENDERBUFFER_HEIGHT */ -/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ -/* reuse GL_STENCIL_INDEX1 */ -/* reuse GL_STENCIL_INDEX4 */ -/* reuse GL_STENCIL_INDEX8 */ -/* reuse GL_STENCIL_INDEX16 */ -/* reuse GL_RENDERBUFFER_RED_SIZE */ -/* reuse GL_RENDERBUFFER_GREEN_SIZE */ -/* reuse GL_RENDERBUFFER_BLUE_SIZE */ -/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ -/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ -/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ -/* reuse GL_MAX_SAMPLES */ -/* Reuse tokens from ARB_framebuffer_sRGB */ -/* reuse GL_FRAMEBUFFER_SRGB */ -/* Reuse tokens from ARB_half_float_vertex */ -/* reuse GL_HALF_FLOAT */ -/* Reuse tokens from ARB_map_buffer_range */ -/* reuse GL_MAP_READ_BIT */ -/* reuse GL_MAP_WRITE_BIT */ -/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ -/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ -/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ -/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ -/* Reuse tokens from ARB_texture_compression_rgtc */ -/* reuse GL_COMPRESSED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_RG_RGTC2 */ -/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ -/* Reuse tokens from ARB_texture_rg */ -/* reuse GL_RG */ -/* reuse GL_RG_INTEGER */ -/* reuse GL_R8 */ -/* reuse GL_R16 */ -/* reuse GL_RG8 */ -/* reuse GL_RG16 */ -/* reuse GL_R16F */ -/* reuse GL_R32F */ -/* reuse GL_RG16F */ -/* reuse GL_RG32F */ -/* reuse GL_R8I */ -/* reuse GL_R8UI */ -/* reuse GL_R16I */ -/* reuse GL_R16UI */ -/* reuse GL_R32I */ -/* reuse GL_R32UI */ -/* reuse GL_RG8I */ -/* reuse GL_RG8UI */ -/* reuse GL_RG16I */ -/* reuse GL_RG16UI */ -/* reuse GL_RG32I */ -/* reuse GL_RG32UI */ -/* Reuse tokens from ARB_vertex_array_object */ -/* reuse GL_VERTEX_ARRAY_BINDING */ -#endif - -#ifndef GL_VERSION_3_0_DEPRECATED -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_ALPHA_INTEGER 0x8D97 -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_TEXTURE_LUMINANCE_TYPE */ -/* reuse GL_TEXTURE_INTENSITY_TYPE */ -#endif - -#ifndef GL_VERSION_3_1 -/* #define GL_SAMPLER_2D_RECT 0x8B63 - we use subsumed GL_ARB_texture_rectangle */ -/* #define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 - we use subsumed GL_ARB_texture_rectangle */ -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -/* Reuse all tokens from ARB_texture_buffer_object */ -/* Reuse all tokens from ARB_texture_rectangle */ -/* Reuse tokens from GL_EXT_texture_snorm */ -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -/* Reuse tokens from ARB_copy_buffer */ -/* reuse GL_COPY_READ_BUFFER */ -/* reuse GL_COPY_WRITE_BUFFER */ -/* Reuse tokens from ARB_draw_instanced (none) */ -/* Reuse tokens from ARB_uniform_buffer_object */ -/* reuse GL_UNIFORM_BUFFER */ -/* reuse GL_UNIFORM_BUFFER_BINDING */ -/* reuse GL_UNIFORM_BUFFER_START */ -/* reuse GL_UNIFORM_BUFFER_SIZE */ -/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ -/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ -/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ -/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ -/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ -/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ -/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ -/* reuse GL_UNIFORM_TYPE */ -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_INDEX */ -/* reuse GL_UNIFORM_OFFSET */ -/* reuse GL_UNIFORM_ARRAY_STRIDE */ -/* reuse GL_UNIFORM_MATRIX_STRIDE */ -/* reuse GL_UNIFORM_IS_ROW_MAJOR */ -/* reuse GL_UNIFORM_BLOCK_BINDING */ -/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ -/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_INVALID_INDEX */ -#endif - -#ifndef GL_VERSION_3_2 -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* Reuse tokens from ARB_depth_clamp */ -/* reuse GL_DEPTH_CLAMP */ -/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ -/* Reuse tokens from ARB_fragment_coord_conventions (none) */ -/* Reuse tokens from ARB_provoking_vertex */ -/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -/* Reuse tokens from ARB_seamless_cube_map */ -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ -/* Reuse tokens from ARB_sync */ -/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ -/* reuse GL_OBJECT_TYPE */ -/* reuse GL_SYNC_CONDITION */ -/* reuse GL_SYNC_STATUS */ -/* reuse GL_SYNC_FLAGS */ -/* reuse GL_SYNC_FENCE */ -/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ -/* reuse GL_UNSIGNALED */ -/* reuse GL_SIGNALED */ -/* reuse GL_ALREADY_SIGNALED */ -/* reuse GL_TIMEOUT_EXPIRED */ -/* reuse GL_CONDITION_SATISFIED */ -/* reuse GL_WAIT_FAILED */ -/* reuse GL_TIMEOUT_IGNORED */ -/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ -/* reuse GL_TIMEOUT_IGNORED */ -/* Reuse tokens from ARB_texture_multisample */ -/* reuse GL_SAMPLE_POSITION */ -/* reuse GL_SAMPLE_MASK */ -/* reuse GL_SAMPLE_MASK_VALUE */ -/* reuse GL_MAX_SAMPLE_MASK_WORDS */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_SAMPLES */ -/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ -/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ -/* reuse GL_MAX_INTEGER_SAMPLES */ -/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -/* Reuse tokens from ARB_blend_func_extended */ -/* reuse GL_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_ALPHA */ -/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ -/* Reuse tokens from ARB_explicit_attrib_location (none) */ -/* Reuse tokens from ARB_occlusion_query2 */ -/* reuse GL_ANY_SAMPLES_PASSED */ -/* Reuse tokens from ARB_sampler_objects */ -/* reuse GL_SAMPLER_BINDING */ -/* Reuse tokens from ARB_shader_bit_encoding (none) */ -/* Reuse tokens from ARB_texture_rgb10_a2ui */ -/* reuse GL_RGB10_A2UI */ -/* Reuse tokens from ARB_texture_swizzle */ -/* reuse GL_TEXTURE_SWIZZLE_R */ -/* reuse GL_TEXTURE_SWIZZLE_G */ -/* reuse GL_TEXTURE_SWIZZLE_B */ -/* reuse GL_TEXTURE_SWIZZLE_A */ -/* reuse GL_TEXTURE_SWIZZLE_RGBA */ -/* Reuse tokens from ARB_timer_query */ -/* reuse GL_TIME_ELAPSED */ -/* reuse GL_TIMESTAMP */ -/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ -/* reuse GL_INT_2_10_10_10_REV */ -#endif - -#ifndef GL_VERSION_4_0 -/* Reuse all tokens from ARB_sample_shading */ -/* Reuse all tokens from ARB_texture_gather */ -/* Reuse all tokens from ARB_texture_cube_map_array */ -/* Reuse tokens from ARB_texture_query_lod (none) */ -/* Reuse tokens from ARB_draw_buffers_blend (none) */ -/* Reuse tokens from ARB_draw_indirect */ -/* reuse GL_DRAW_INDIRECT_BUFFER */ -/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ -/* Reuse tokens from ARB_gpu_shader5 */ -/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -/* Reuse tokens from ARB_gpu_shader_fp64 */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -/* Reuse tokens from ARB_shader_subroutine */ -/* reuse GL_ACTIVE_SUBROUTINES */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ -/* reuse GL_MAX_SUBROUTINES */ -/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ -/* reuse GL_COMPATIBLE_SUBROUTINES */ -/* Reuse tokens from ARB_tessellation_shader */ -/* reuse GL_PATCHES */ -/* reuse GL_PATCH_VERTICES */ -/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ -/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ -/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ -/* reuse GL_TESS_GEN_MODE */ -/* reuse GL_TESS_GEN_SPACING */ -/* reuse GL_TESS_GEN_VERTEX_ORDER */ -/* reuse GL_TESS_GEN_POINT_MODE */ -/* reuse GL_ISOLINES */ -/* reuse GL_FRACTIONAL_ODD */ -/* reuse GL_FRACTIONAL_EVEN */ -/* reuse GL_MAX_PATCH_VERTICES */ -/* reuse GL_MAX_TESS_GEN_LEVEL */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_CONTROL_SHADER */ -/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ -/* Reuse tokens from ARB_transform_feedback2 */ -/* reuse GL_TRANSFORM_FEEDBACK */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ -/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ -/* Reuse tokens from ARB_transform_feedback3 */ -/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_VERSION_4_1 -/* Reuse tokens from ARB_ES2_compatibility */ -/* reuse GL_FIXED */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ -/* reuse GL_LOW_FLOAT */ -/* reuse GL_MEDIUM_FLOAT */ -/* reuse GL_HIGH_FLOAT */ -/* reuse GL_LOW_INT */ -/* reuse GL_MEDIUM_INT */ -/* reuse GL_HIGH_INT */ -/* reuse GL_SHADER_COMPILER */ -/* reuse GL_NUM_SHADER_BINARY_FORMATS */ -/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ -/* reuse GL_MAX_VARYING_VECTORS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ -/* Reuse tokens from ARB_get_program_binary */ -/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ -/* reuse GL_PROGRAM_BINARY_LENGTH */ -/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ -/* reuse GL_PROGRAM_BINARY_FORMATS */ -/* Reuse tokens from ARB_separate_shader_objects */ -/* reuse GL_VERTEX_SHADER_BIT */ -/* reuse GL_FRAGMENT_SHADER_BIT */ -/* reuse GL_GEOMETRY_SHADER_BIT */ -/* reuse GL_TESS_CONTROL_SHADER_BIT */ -/* reuse GL_TESS_EVALUATION_SHADER_BIT */ -/* reuse GL_ALL_SHADER_BITS */ -/* reuse GL_PROGRAM_SEPARABLE */ -/* reuse GL_ACTIVE_PROGRAM */ -/* reuse GL_PROGRAM_PIPELINE_BINDING */ -/* Reuse tokens from ARB_shader_precision (none) */ -/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ -/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ -/* reuse GL_MAX_VIEWPORTS */ -/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ -/* reuse GL_VIEWPORT_BOUNDS_RANGE */ -/* reuse GL_LAYER_PROVOKING_VERTEX */ -/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ -/* reuse GL_UNDEFINED_VERTEX */ -#endif - -#ifndef GL_VERSION_4_2 -/* Reuse tokens from ARB_base_instance (none) */ -/* Reuse tokens from ARB_shading_language_420pack (none) */ -/* Reuse tokens from ARB_transform_feedback_instanced (none) */ -/* Reuse tokens from ARB_compressed_texture_pixel_storage */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ -/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ -/* Reuse tokens from ARB_conservative_depth (none) */ -/* Reuse tokens from ARB_internalformat_query */ -/* reuse GL_NUM_SAMPLE_COUNTS */ -/* Reuse tokens from ARB_map_buffer_alignment */ -/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ -/* Reuse tokens from ARB_shader_atomic_counters */ -/* reuse GL_ATOMIC_COUNTER_BUFFER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ -/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ -/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ -/* Reuse tokens from ARB_shader_image_load_store */ -/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ -/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ -/* reuse GL_UNIFORM_BARRIER_BIT */ -/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ -/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ -/* reuse GL_COMMAND_BARRIER_BIT */ -/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ -/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ -/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ -/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ -/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ -/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ -/* reuse GL_ALL_BARRIER_BITS */ -/* reuse GL_MAX_IMAGE_UNITS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ -/* reuse GL_IMAGE_BINDING_NAME */ -/* reuse GL_IMAGE_BINDING_LEVEL */ -/* reuse GL_IMAGE_BINDING_LAYERED */ -/* reuse GL_IMAGE_BINDING_LAYER */ -/* reuse GL_IMAGE_BINDING_ACCESS */ -/* reuse GL_IMAGE_1D */ -/* reuse GL_IMAGE_2D */ -/* reuse GL_IMAGE_3D */ -/* reuse GL_IMAGE_2D_RECT */ -/* reuse GL_IMAGE_CUBE */ -/* reuse GL_IMAGE_BUFFER */ -/* reuse GL_IMAGE_1D_ARRAY */ -/* reuse GL_IMAGE_2D_ARRAY */ -/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_IMAGE_1D */ -/* reuse GL_INT_IMAGE_2D */ -/* reuse GL_INT_IMAGE_3D */ -/* reuse GL_INT_IMAGE_2D_RECT */ -/* reuse GL_INT_IMAGE_CUBE */ -/* reuse GL_INT_IMAGE_BUFFER */ -/* reuse GL_INT_IMAGE_1D_ARRAY */ -/* reuse GL_INT_IMAGE_2D_ARRAY */ -/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D */ -/* reuse GL_UNSIGNED_INT_IMAGE_3D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ -/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_IMAGE_SAMPLES */ -/* reuse GL_IMAGE_BINDING_FORMAT */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ -/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ -/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ -/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ -/* Reuse tokens from ARB_shading_language_packing (none) */ -/* Reuse tokens from ARB_texture_storage */ -/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#endif - -#ifndef GL_ARB_draw_instanced -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#endif - -#ifndef GL_ARB_framebuffer_object_DEPRECATED -#define GL_INDEX 0x8222 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_HALF_FLOAT 0x140B -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -/* #define GL_INVALID_INDEX 0xFFFFFFFFu - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#endif - -#ifndef GL_ARB_compatibility -/* ARB_compatibility just defines tokens from core 3.0 */ -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#endif - -#ifndef GL_ARB_shader_texture_lod -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_DEPTH_CLAMP 0x864F -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#endif - -#ifndef GL_ARB_sync -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -#endif - -#ifndef GL_ARB_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_ARB_draw_buffers_blend -#endif - -#ifndef GL_ARB_sample_shading -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#endif - -#ifndef GL_ARB_texture_gather -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#endif - -#ifndef GL_ARB_texture_query_lod -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_SRC1_COLOR 0x88F9 -/* reuse GL_SRC1_ALPHA */ -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#endif - -#ifndef GL_ARB_explicit_attrib_location -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_SAMPLER_BINDING 0x8919 -#endif - -#ifndef GL_ARB_shader_bit_encoding -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_RGB10_A2UI 0x906F -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#endif - -#ifndef GL_ARB_timer_query -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ -#define GL_INT_2_10_10_10_REV 0x8D9F -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -/* reuse GL_TRIANGLES */ -/* reuse GL_QUADS */ -#define GL_ISOLINES 0x8E7A -/* reuse GL_EQUAL */ -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -/* reuse GL_CCW */ -/* reuse GL_CW */ -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -/* reuse GL_RGB32F */ -/* reuse GL_RGB32UI */ -/* reuse GL_RGB32I */ -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -#define GL_MAX_VERTEX_STREAMS 0x8E71 -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -/* #define GL_ALL_SHADER_BITS 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#endif - -#ifndef GL_ARB_shader_precision -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -/* reuse GL_RGB32I */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -#endif - -#ifndef GL_ARB_viewport_array -/* reuse GL_SCISSOR_BOX */ -/* reuse GL_VIEWPORT */ -/* reuse GL_DEPTH_RANGE */ -/* reuse GL_SCISSOR_TEST */ -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -#endif - -#ifndef GL_ARB_cl_event -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -#endif - -#ifndef GL_ARB_debug_output -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -#endif - -#ifndef GL_ARB_robustness -/* reuse GL_NO_ERROR */ -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 -#endif - -#ifndef GL_ARB_shader_stencil_export -#endif - -#ifndef GL_ARB_base_instance -#endif - -#ifndef GL_ARB_shading_language_420pack -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#endif - -#ifndef GL_ARB_conservative_depth -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -/* #define GL_ALL_BARRIER_BITS 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#endif - -#ifndef GL_ARB_shading_language_packing -#endif - -#ifndef GL_ARB_texture_storage -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8A0C -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CLIENT_APPLE 0x85B4 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif - -#ifndef GL_EXT_timer_query -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -#ifndef GL_EXT_gpu_program_parameters -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_LINES_ADJACENCY_EXT 0x000A -#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ -/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ -/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ -/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -/* reuse GL_LINES_ADJACENCY_EXT */ -/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ -/* reuse GL_TRIANGLES_ADJACENCY_EXT */ -/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -/* reuse GL_PROGRAM_POINT_SIZE_EXT */ -#endif - -#ifndef GL_NV_vertex_program4 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#endif - -#ifndef GL_EXT_draw_instanced -#endif - -#ifndef GL_EXT_packed_float -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif - -#ifndef GL_EXT_texture_array -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -#endif - -#ifndef GL_NV_fragment_program4 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif - -#ifndef GL_NV_geometry_shader4 -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -#endif - -#ifndef GL_EXT_draw_buffers2 -#endif - -#ifndef GL_NV_transform_feedback -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#define GL_LAYER_NV 0x8DAA -#define GL_NEXT_BUFFER_NV -2 -#define GL_SKIP_COMPONENTS4_NV -3 -#define GL_SKIP_COMPONENTS3_NV -4 -#define GL_SKIP_COMPONENTS2_NV -5 -#define GL_SKIP_COMPONENTS1_NV -6 -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -#endif - -#ifndef GL_EXT_texture_integer -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -#endif - -#ifndef GL_GREMEDY_frame_terminator -#endif - -#ifndef GL_NV_conditional_render -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -#endif - -#ifndef GL_NV_present_video -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -#endif - -#ifndef GL_EXT_transform_feedback -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#endif - -#ifndef GL_EXT_direct_state_access -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -#endif - -#ifndef GL_EXT_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_EXT_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif - -#ifndef GL_NV_explicit_multisample -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -#endif - -#ifndef GL_NV_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -#endif - -#ifndef GL_ATI_meminfo -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#endif - -#ifndef GL_AMD_performance_monitor -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -#endif - -#ifndef GL_AMD_texture_texture4 -#endif - -#ifndef GL_AMD_vertex_shader_tesselator -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -#endif - -#ifndef GL_EXT_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F -#endif - -#ifndef GL_EXT_texture_snorm -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#endif - -#ifndef GL_AMD_draw_buffers_blend -#endif - -#ifndef GL_APPLE_texture_range -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -/* reuse GL_STORAGE_CACHED_APPLE */ -/* reuse GL_STORAGE_SHARED_APPLE */ -#endif - -#ifndef GL_APPLE_float_pixels -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#endif - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 -#endif - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 -#endif - -#ifndef GL_APPLE_object_purgeable -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D -#endif - -#ifndef GL_APPLE_row_bytes -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 -#endif - -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ -/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ -#endif - -#ifndef GL_NV_video_capture -#define GL_VIDEO_BUFFER_NV 0x9020 -#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 -#define GL_FIELD_UPPER_NV 0x9022 -#define GL_FIELD_LOWER_NV 0x9023 -#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 -#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 -#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 -#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 -#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 -#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 -#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A -#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B -#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C -#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D -#define GL_PARTIAL_SUCCESS_NV 0x902E -#define GL_SUCCESS_NV 0x902F -#define GL_FAILURE_NV 0x9030 -#define GL_YCBYCR8_422_NV 0x9031 -#define GL_YCBAYCR8A_4224_NV 0x9032 -#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 -#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 -#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 -#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 -#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 -#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 -#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 -#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A -#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B -#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C -#endif - -#ifndef GL_NV_copy_image -#endif - -#ifndef GL_EXT_separate_shader_objects -#define GL_ACTIVE_PROGRAM_EXT 0x8B8D -#endif - -#ifndef GL_NV_parameter_buffer_object2 -#endif - -#ifndef GL_NV_shader_buffer_load -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -#endif - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -#endif - -#ifndef GL_NV_texture_barrier -#endif - -#ifndef GL_AMD_shader_stencil_export -#endif - -#ifndef GL_AMD_seamless_cubemap_per_texture -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS_ARB */ -#endif - -#ifndef GL_AMD_conservative_depth -#endif - -#ifndef GL_EXT_shader_image_load_store -#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 -#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A -#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B -#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C -#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D -#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E -#define GL_IMAGE_1D_EXT 0x904C -#define GL_IMAGE_2D_EXT 0x904D -#define GL_IMAGE_3D_EXT 0x904E -#define GL_IMAGE_2D_RECT_EXT 0x904F -#define GL_IMAGE_CUBE_EXT 0x9050 -#define GL_IMAGE_BUFFER_EXT 0x9051 -#define GL_IMAGE_1D_ARRAY_EXT 0x9052 -#define GL_IMAGE_2D_ARRAY_EXT 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 -#define GL_INT_IMAGE_1D_EXT 0x9057 -#define GL_INT_IMAGE_2D_EXT 0x9058 -#define GL_INT_IMAGE_3D_EXT 0x9059 -#define GL_INT_IMAGE_2D_RECT_EXT 0x905A -#define GL_INT_IMAGE_CUBE_EXT 0x905B -#define GL_INT_IMAGE_BUFFER_EXT 0x905C -#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D -#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C -#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D -#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 -#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 -/* #define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#endif - -#ifndef GL_EXT_vertex_attrib_64bit -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2_EXT 0x8FFC -#define GL_DOUBLE_VEC3_EXT 0x8FFD -#define GL_DOUBLE_VEC4_EXT 0x8FFE -#define GL_DOUBLE_MAT2_EXT 0x8F46 -#define GL_DOUBLE_MAT3_EXT 0x8F47 -#define GL_DOUBLE_MAT4_EXT 0x8F48 -#define GL_DOUBLE_MAT2x3_EXT 0x8F49 -#define GL_DOUBLE_MAT2x4_EXT 0x8F4A -#define GL_DOUBLE_MAT3x2_EXT 0x8F4B -#define GL_DOUBLE_MAT3x4_EXT 0x8F4C -#define GL_DOUBLE_MAT4x2_EXT 0x8F4D -#define GL_DOUBLE_MAT4x3_EXT 0x8F4E -#endif - -#ifndef GL_NV_gpu_program5 -#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C -#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F -#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 -#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 -#endif - -#ifndef GL_NV_gpu_shader5 -#define GL_INT64_NV 0x140E -#define GL_UNSIGNED_INT64_NV 0x140F -#define GL_INT8_NV 0x8FE0 -#define GL_INT8_VEC2_NV 0x8FE1 -#define GL_INT8_VEC3_NV 0x8FE2 -#define GL_INT8_VEC4_NV 0x8FE3 -#define GL_INT16_NV 0x8FE4 -#define GL_INT16_VEC2_NV 0x8FE5 -#define GL_INT16_VEC3_NV 0x8FE6 -#define GL_INT16_VEC4_NV 0x8FE7 -#define GL_INT64_VEC2_NV 0x8FE9 -#define GL_INT64_VEC3_NV 0x8FEA -#define GL_INT64_VEC4_NV 0x8FEB -#define GL_UNSIGNED_INT8_NV 0x8FEC -#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED -#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE -#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF -#define GL_UNSIGNED_INT16_NV 0x8FF0 -#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 -#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 -#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 -#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB -/* reuse GL_PATCHES */ -#endif - -#ifndef GL_NV_shader_buffer_store -#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 -/* reuse GL_READ_WRITE */ -/* reuse GL_WRITE_ONLY */ -#endif - -#ifndef GL_NV_tessellation_program5 -#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 -#define GL_TESS_CONTROL_PROGRAM_NV 0x891E -#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F -#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 -#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 -#endif - -#ifndef GL_NV_vertex_attrib_integer_64bit -/* reuse GL_INT64_NV */ -/* reuse GL_UNSIGNED_INT64_NV */ -#endif - -#ifndef GL_NV_multisample_coverage -#define GL_COVERAGE_SAMPLES_NV 0x80A9 -#define GL_COLOR_SAMPLES_NV 0x8E20 -#endif - -#ifndef GL_AMD_name_gen_delete -#define GL_DATA_BUFFER_AMD 0x9151 -#define GL_PERFORMANCE_MONITOR_AMD 0x9152 -#define GL_QUERY_OBJECT_AMD 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 -#define GL_SAMPLER_OBJECT_AMD 0x9155 -#endif - -#ifndef GL_AMD_debug_output -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -#endif - -#ifndef GL_NV_vdpau_interop -#define GL_SURFACE_STATE_NV 0x86EB -#define GL_SURFACE_REGISTERED_NV 0x86FD -#define GL_SURFACE_MAPPED_NV 0x8700 -#define GL_WRITE_DISCARD_NV 0x88BE -#endif - -#ifndef GL_AMD_transform_feedback3_lines_triangles -#endif - -#ifndef GL_AMD_depth_clamp_separate -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F -#endif - -#ifndef GL_EXT_texture_sRGB_decode -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif - -#ifndef GL_NV_texture_multisample -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -#endif - -#ifndef GL_AMD_blend_minmax_factor -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D -#endif - -#ifndef GL_AMD_sample_positions -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F -#endif - -#ifndef GL_EXT_x11_sync_object -#define GL_SYNC_X11_FENCE_EXT 0x90E1 -#endif - -#ifndef GL_AMD_multi_draw_indirect -#endif - -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#endif - -#ifndef GL_AMD_pinned_memory -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#endif - -#ifndef GL_AMD_stencil_operation_extended -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for program/shader text and shader object handles */ -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#endif - -/* GL type for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#include "gl-64bit-types.h" - -#ifndef GL_ARB_cl_event -/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event -struct _cl_context; -struct _cl_event; - */ -#endif - -#ifndef GL_ARB_debug_output -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_AMD_debug_output -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_NV_vdpau_interop -typedef GLintptr GLvdpauSurfaceNV; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_2_DEPRECATED -#define GL_VERSION_1_2_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogram (GLenum target); -GLAPI void APIENTRY glResetMinmax (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_3_DEPRECATED -#define GL_VERSION_1_3_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientActiveTexture (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_VERSION_1_4_DEPRECATED -#define GL_VERSION_1_4_DEPRECATED 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordf (GLfloat coord); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); -GLAPI void APIENTRY glFogCoordd (GLdouble coord); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2iv (const GLint *v); -GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); -GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3iv (const GLint *v); -GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQuery (GLuint id); -GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQuery (GLenum target); -GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgram (GLuint program); -GLAPI GLboolean APIENTRY glIsShader (GLuint shader); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glValidateProgram (GLuint program); -GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -/* OpenGL 3.0 also reuses entry points from these extensions: */ -/* ARB_framebuffer_object */ -/* ARB_map_buffer_range */ -/* ARB_vertex_array_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); -GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); -GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); -GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -#endif - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -/* OpenGL 3.1 also reuses entry points from these extensions: */ -/* ARB_copy_buffer */ -/* ARB_uniform_buffer_object */ -/* ARB_draw_instanced */ -/* ARB_texture_buffer_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -#endif - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -/* OpenGL 3.2 also reuses entry points from these extensions: */ -/* ARB_draw_elements_base_vertex */ -/* ARB_provoking_vertex */ -/* ARB_sync */ -/* ARB_texture_multisample */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -/* OpenGL 3.3 also reuses entry points from these extensions: */ -/* ARB_blend_func_extended */ -/* ARB_sampler_objects */ -/* ARB_explicit_attrib_location, but it has none */ -/* ARB_occlusion_query2 (no entry points) */ -/* ARB_shader_bit_encoding (no entry points) */ -/* ARB_texture_rgb10_a2ui (no entry points) */ -/* ARB_texture_swizzle (no entry points) */ -/* ARB_timer_query */ -/* ARB_vertex_type_2_10_10_10_rev */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 -/* OpenGL 4.0 also reuses entry points from these extensions: */ -/* ARB_texture_query_lod (no entry points) */ -/* ARB_draw_indirect */ -/* ARB_gpu_shader5 (no entry points) */ -/* ARB_gpu_shader_fp64 */ -/* ARB_shader_subroutine */ -/* ARB_tessellation_shader */ -/* ARB_texture_buffer_object_rgb32 (no entry points) */ -/* ARB_texture_cube_map_array (no entry points) */ -/* ARB_texture_gather (no entry points) */ -/* ARB_transform_feedback2 */ -/* ARB_transform_feedback3 */ -/* Susume ARB_sample_shading */ -/* Susume ARB_draw_buffers_blend */ -#endif - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 -/* OpenGL 4.1 reuses entry points from these extensions: */ -/* ARB_ES2_compatibility */ -/* ARB_get_program_binary */ -/* ARB_separate_shader_objects */ -/* ARB_shader_precision (no entry points) */ -/* ARB_vertex_attrib_64bit */ -/* ARB_viewport_array */ -#endif - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 -/* OpenGL 4.2 reuses entry points from these extensions: */ -/* ARB_base_instance */ -/* ARB_shading_language_420pack (no entry points) */ -/* ARB_transform_feedback_instanced */ -/* ARB_compressed_texture_pixel_storage (no entry points) */ -/* ARB_conservative_depth (no entry points) */ -/* ARB_internalformat_query */ -/* ARB_map_buffer_alignment (no entry points) */ -/* ARB_shader_atomic_counters */ -/* ARB_shader_image_load_store */ -/* ARB_shading_language_packing (no entry points) */ -/* ARB_texture_storage */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf value, GLboolean invert); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); -GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); -GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); -GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); -GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); -GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); -GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); -GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); -GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glVertexBlendARB (GLint count); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); -GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); -GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQueryARB (GLenum target); -GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmap (GLenum target); -GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertex (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); -GLAPI GLboolean APIENTRY glIsSync (GLsync sync); -GLAPI void APIENTRY glDeleteSync (GLsync sync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); -#endif - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLclampf value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#endif - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#endif - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); -#endif - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); -GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); -GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); -GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); -GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); -GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 -#endif - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); -GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); -GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); -GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); -GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); -GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); -GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedback (void); -GLAPI void APIENTRY glResumeTransformFeedback (void); -GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); -GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); -GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); -GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReleaseShaderCompiler (void); -GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GLAPI void APIENTRY glClearDepthf (GLclampf depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLclampf d); -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); -GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* *strings); -GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); -GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); -GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); -GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* *strings); -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); -#endif - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); -GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLclampd *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLclampd n, GLclampd f); -GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#endif - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 -#ifdef GL_GLEXT_PROTOTYPES -/* GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); */ -GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (void * context, void * event, GLbitfield flags); -#endif /* GL_GLEXT_PROTOTYPES */ -/* typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); */ -typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (void * context, void * event, GLbitfield flags); -#endif - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); -GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 -#endif - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 -#endif - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -#endif - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 -#endif - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogramEXT (GLenum target); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint i); -GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); -GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); -GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); -GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); -GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); -GLAPI void APIENTRY glTextureLightEXT (GLenum pname); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); #endif +#endif /* GL_VERSION_3_0 */ -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #endif +#endif /* GL_VERSION_3_1 */ -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif +typedef int64_t GLint64; +typedef struct __GLsync *GLsync; +typedef uint64_t GLuint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); #endif +#endif /* GL_VERSION_3_2 */ -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); #endif +#endif /* GL_VERSION_3_3 */ -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); #endif +#endif /* GL_VERSION_4_0 */ -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glClearDepthf (GLfloat depth); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif +#endif /* GL_ARB_ES2_compatibility */ -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#endif /* GL_ARB_ES2_compatibility */ +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +#ifndef GL_ARB_ES2_compatibility +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +#endif /* GL_ARB_ES2_compatibility */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifndef GL_ARB_ES2_compatibility +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glClearDepthf (GLfloat depth); +#endif /* GL_ARB_ES2_compatibility */ +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); #endif +#endif /* GL_VERSION_4_1 */ -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif +#endif /* GL_VERSION_4_2 */ + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif /* GL_ARB_ES3_compatibility */ + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#ifndef GL_ARB_ES3_compatibility +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif /* GL_ARB_ES3_compatibility */ +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +typedef struct _cl_context * cl_context; +typedef struct _cl_event * cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (cl_context context, cl_event event, GLbitfield flags); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); -GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); -GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); -GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (cl_context context, cl_event event, GLbitfield flags); #endif +#endif /* GL_ARB_cl_event */ -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); #endif +#endif /* GL_ARB_clear_buffer_object */ -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); #endif +#endif /* GL_ARB_color_buffer_float */ -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#endif /* GL_ARB_copy_buffer */ + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #endif +#endif /* GL_ARB_debug_output */ -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); #endif +#endif /* GL_ARB_draw_buffers */ -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #endif +#endif /* GL_ARB_draw_buffers_blend */ -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); #endif +#endif /* GL_ARB_draw_instanced */ -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif /* GL_ARB_fragment_program */ + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); #endif +#endif /* GL_ARB_framebuffer_no_attachments */ -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #endif +#endif /* GL_ARB_geometry_shader4 */ -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); #endif +#endif /* GL_ARB_gpu_shader_fp64 */ + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); #endif +#endif /* GL_ARB_instanced_arrays */ -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); #endif +#endif /* GL_ARB_internalformat_query */ -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#endif /* GL_ARB_internalformat_query2 */ -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); #endif +#endif /* GL_ARB_matrix_palette */ -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); #endif +#endif /* GL_ARB_multisample */ -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); #endif +#endif /* GL_ARB_multitexture */ -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); #endif +#endif /* GL_ARB_occlusion_query */ -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); #endif +#endif /* GL_ARB_point_parameters */ -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); #endif +#endif /* GL_ARB_robustness */ -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #endif +#endif /* GL_ARB_sample_shading */ -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); -GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); -GLAPI void APIENTRY glFinishFenceNV (GLuint fence); -GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; #endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); #endif +#endif /* GL_ARB_shader_objects */ -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); -GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); -GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); -GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); #endif +#endif /* GL_ARB_shading_language_include */ -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); #endif +#endif /* GL_ARB_texture_buffer_object */ -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); #endif +#endif /* GL_ARB_texture_buffer_range */ -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); -GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); #endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); -GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); -GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); -GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); -GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); -GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); -GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); -GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); -GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); -GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); -GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); -GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); #endif +#endif /* GL_ARB_texture_storage */ -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); -GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); -GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#endif /* GL_ARB_transform_feedback2 */ -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); #endif +#endif /* GL_ARB_transpose_matrix */ -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#endif /* GL_ARB_uniform_buffer_object */ -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); #endif +#endif /* GL_ARB_vertex_blend */ -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid **params); #endif +#endif /* GL_ARB_vertex_buffer_object */ -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid **pointer); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); #endif +#endif /* GL_ARB_vertex_program */ -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); #endif +#endif /* GL_ARB_vertex_shader */ -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); #endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +typedef GLint GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef float GLclampf; +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLfloat depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); +#endif +#endif /* GL_OES_single_precision */ -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); #endif +#endif /* GL_3DFX_tbuffer */ -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); #endif +#endif /* GL_AMD_debug_output */ -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); #endif +#endif /* GL_AMD_draw_buffers_blend */ -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); #endif +#endif /* GL_AMD_interleaved_elements */ -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); #endif +#endif /* GL_AMD_multi_draw_indirect */ -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); #endif +#endif /* GL_AMD_name_gen_delete */ -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #endif +#endif /* GL_AMD_performance_monitor */ -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); #endif +#endif /* GL_AMD_sample_positions */ -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); #endif +#endif /* GL_AMD_stencil_operation_extended */ -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); #endif +#endif /* GL_AMD_vertex_shader_tessellator */ -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); #endif +#endif /* GL_APPLE_element_array */ -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); #endif +#endif /* GL_APPLE_fence */ -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); #endif +#endif /* GL_APPLE_flush_buffer_range */ -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); #endif +#endif /* GL_APPLE_object_purgeable */ -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif /* GL_APPLE_rgb_422 */ -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid **params); #endif +#endif /* GL_APPLE_texture_range */ -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); #endif +#endif /* GL_APPLE_vertex_array_object */ -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); #endif +#endif /* GL_APPLE_vertex_array_range */ -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); #endif +#endif /* GL_APPLE_vertex_program_evaluators */ -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); #endif +#endif /* GL_ATI_draw_buffers */ -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); #endif +#endif /* GL_ATI_element_array */ -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif +#endif /* GL_ATI_envmap_bumpmap */ + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); #endif +#endif /* GL_ATI_fragment_shader */ -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); #endif +#endif /* GL_ATI_map_object_buffer */ -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); -#endif +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); #endif +#endif /* GL_ATI_pn_triangles */ -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); -GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); #endif +#endif /* GL_ATI_separate_stencil */ -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); -#endif +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); -#endif +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -#endif +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); #endif +#endif /* GL_ATI_vertex_array_object */ -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); #endif +#endif /* GL_ATI_vertex_attrib_array_object */ -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); #endif +#endif /* GL_ATI_vertex_streams */ -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#endif +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#endif +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#endif +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); -GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#endif - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); #endif +#endif /* GL_EXT_bindable_uniform */ -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #endif +#endif /* GL_EXT_blend_color */ -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); #endif +#endif /* GL_EXT_blend_equation_separate */ -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #endif +#endif /* GL_EXT_blend_func_separate */ -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); -GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); -GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); -GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); #endif +#endif /* GL_EXT_blend_minmax */ -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); -GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); -GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #endif +#endif /* GL_EXT_color_subtable */ -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); #endif +#endif /* GL_EXT_compiled_vertex_array */ -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); #endif +#endif /* GL_EXT_convolution */ -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRenderNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); #endif +#endif /* GL_EXT_coordinate_frame */ -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); -GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif +#endif /* GL_EXT_copy_texture */ -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackEXT (void); -GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); #endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +typedef double GLclampd; +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ #ifndef GL_EXT_direct_state_access #define GL_EXT_direct_state_access 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); -GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); -GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); -GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); -GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); -GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); -GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); -GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); -GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); -GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); -GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); -GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); -GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); -GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); -GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); @@ -10619,10 +5875,8 @@ typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); @@ -10643,29 +5897,7 @@ typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); @@ -10682,9 +5914,36 @@ typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum ta typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); -typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); @@ -10699,32 +5958,17 @@ typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texuni typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); @@ -10750,6 +5994,16 @@ typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); @@ -10758,20 +6012,33 @@ typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint l typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, GLvoid **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); @@ -10784,688 +6051,4760 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, GLvoid **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLvoid **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, GLvoid **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, GLvoid **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLvoid **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar **varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar **varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_shader_buffer_load */ + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif +#endif /* GL_NV_texture_barrier */ + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif +#endif /* GL_NV_transform_feedback */ + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif +#endif /* GL_NV_transform_feedback2 */ + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif +#endif /* GL_NV_vdpau_interop */ + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); +#endif +#endif /* GL_NV_vertex_array_range */ + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif +#endif /* GL_NV_vertex_buffer_unified_memory */ + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); #endif +#endif /* GL_NV_vertex_program */ -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 -#endif +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 -#endif +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); -GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); #endif +#endif /* GL_NV_vertex_program4 */ -#ifndef GL_NV_transform_feedback2 -#define GL_NV_transform_feedback2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedbackNV (void); -GLAPI void APIENTRY glResumeTransformFeedbackNV (void); -GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); #endif +#endif /* GL_NV_video_capture */ -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 -#endif +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 -#endif +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ -#ifndef GL_AMD_vertex_shader_tesselator -#define GL_AMD_vertex_shader_tesselator 1 +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); -GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); #endif +#endif /* GL_PGI_misc_hints */ -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); -#endif +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 -#endif +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); -GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); #endif +#endif /* GL_SGIS_detail_texture */ -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); #endif +#endif /* GL_SGIS_fog_function */ -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 -#endif +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); #endif +#endif /* GL_SGIS_multisample */ -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); #endif +#endif /* GL_SGIS_pixel_texture */ -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#endif +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ -#ifndef GL_NV_video_capture -#define GL_NV_video_capture 1 +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); -GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); #endif +#endif /* GL_SGIS_point_parameters */ -#ifndef GL_NV_copy_image -#define GL_NV_copy_image 1 +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); #endif +#endif /* GL_SGIS_sharpen_texture */ -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); -GLAPI void APIENTRY glActiveProgramEXT (GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); -typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); #endif +#endif /* GL_SGIS_texture4D */ -#ifndef GL_NV_parameter_buffer_object2 -#define GL_NV_parameter_buffer_object2 1 -#endif +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); -GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); -GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); -GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); -GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); -GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); -GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); -GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); -GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); -GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); -GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); -typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); -typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); -typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); -typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #endif +#endif /* GL_SGIS_texture_color_mask */ -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); -GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #endif +#endif /* GL_SGIS_texture_filter4 */ -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureBarrierNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); #endif +#endif /* GL_SGIX_async */ -#ifndef GL_AMD_shader_stencil_export -#define GL_AMD_shader_stencil_export 1 -#endif +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ -#ifndef GL_AMD_seamless_cubemap_per_texture -#define GL_AMD_seamless_cubemap_per_texture 1 -#endif +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ -#ifndef GL_AMD_conservative_depth -#define GL_AMD_conservative_depth 1 -#endif +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ -#ifndef GL_EXT_shader_image_load_store -#define GL_EXT_shader_image_load_store 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); -#endif +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ -#ifndef GL_EXT_vertex_attrib_64bit -#define GL_EXT_vertex_attrib_64bit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -#endif +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ -#ifndef GL_NV_gpu_program5 -#define GL_NV_gpu_program5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); -#endif +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ -#ifndef GL_NV_gpu_shader5 -#define GL_NV_gpu_shader5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); -GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); -GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); -GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); -GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); -GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ -#ifndef GL_NV_shader_buffer_store -#define GL_NV_shader_buffer_store 1 +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); #endif +#endif /* GL_SGIX_flush_raster */ -#ifndef GL_NV_tessellation_program5 -#define GL_NV_tessellation_program5 1 -#endif +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ -#ifndef GL_NV_vertex_attrib_integer_64bit -#define GL_NV_vertex_attrib_integer_64bit 1 +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); -GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); #endif +#endif /* GL_SGIX_fragment_lighting */ -#ifndef GL_NV_multisample_coverage -#define GL_NV_multisample_coverage 1 +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); #endif +#endif /* GL_SGIX_framezoom */ -#ifndef GL_AMD_name_gen_delete -#define GL_AMD_name_gen_delete 1 +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); -GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); -GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); -typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); -typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); #endif +#endif /* GL_SGIX_igloo_interface */ -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); #endif +#endif /* GL_SGIX_instruments */ -#ifndef GL_NV_vdpau_interop -#define GL_NV_vdpau_interop 1 +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); -GLAPI void APIENTRY glVDPAUFiniNV (void); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); -GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); -typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); -typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); #endif +#endif /* GL_SGIX_list_priority */ -#ifndef GL_AMD_transform_feedback3_lines_triangles -#define GL_AMD_transform_feedback3_lines_triangles 1 +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); #endif +#endif /* GL_SGIX_pixel_texture */ -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); #endif +#endif /* GL_SGIX_polynomial_ffd */ -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); #endif +#endif /* GL_SGIX_reference_plane */ -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif +#endif /* GL_SGIX_sprite */ + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); #endif +#endif /* GL_SGIX_tag_sample_buffer */ + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 -#endif +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); -#endif +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); #endif +#endif /* GL_SGI_color_table */ -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -#endif +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); #endif +#endif /* GL_SUNX_constant_data */ -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 -#endif +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); #endif +#endif /* GL_SUN_global_alpha */ - -#ifndef GL_EXT_Cg_shader -#define GL_CG_VERTEX_SHADER_EXT 0x890E -#define GL_CG_FRAGMENT_SHADER_EXT 0x890F -#endif -#ifndef GL_EXT_Cg_shader -#define GL_EXT_Cg_shader 1 +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); #endif +#endif /* GL_SUN_mesh_array */ -/** - * We rename EXT_texture_rectangle into core, - * so ARB_texture_rectangle will remain intact. - */ -#ifndef GL_EXT_texture_rectangle -#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 -#define GL_SAMPLER_2D_RECT_EXT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_EXT 0x8B64 -#endif -#ifndef GL_EXT_texture_rectangle -#define GL_EXT_texture_rectangle 1 -#endif +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ -#ifndef GL_APPLE_pixel_buffer -#define GL_MIN_PBUFFER_VIEWPORT_DIMS_APPLE 0x8A10 -#endif -#ifndef GL_APPLE_pixel_buffer -#define GL_APPLE_pixel_buffer 1 +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid **pointer); #endif +#endif /* GL_SUN_triangle_list */ -#ifndef GL_APPLE_flush_render -#define GL_APPLE_flush_render 1 +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRenderAPPLE(void); -GLAPI void APIENTRY glFinishRenderAPPLE(void); -GLAPI void APIENTRY glSwapAPPLE(void); -#endif -typedef void (APIENTRY * PFNGLFLUSHRENDERAPPLEPROC) (void); -typedef void (APIENTRY * PFNGLFINISHRENDERAPPLEPROC) (void); -typedef void (APIENTRY * PFNGLSWAPAPPLEPROC) (void); +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #endif +#endif /* GL_SUN_vertex */ +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ #ifdef __cplusplus } diff --git a/make/stub_includes/opengl/GL/glplatform.h b/make/stub_includes/opengl/GL/glplatform.h deleted file mode 100644 index 5d42943d7..000000000 --- a/make/stub_includes/opengl/GL/glplatform.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef __glplatform_h_ -#define __glplatform_h_ - -#if defined(__BEOS__) -#include /* to get some BeOS-isms */ -#endif - -#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO)) -#define OPENSTEP -#endif - -#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) -#define __WIN32__ -#endif - -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) -# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ -# define GLAPI __declspec(dllexport) -# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ -# define GLAPI __declspec(dllimport) -# else /* for use with static link lib build of Win32 edition only */ -# define GLAPI extern -# endif /* _STATIC_MESA support */ -# define GLAPIENTRY __stdcall -#else -/* non-Windows compilation */ -# ifndef GLAPI -# define GLAPI extern -# endif -# define GLAPIENTRY -#endif /* WIN32 / CYGWIN bracket */ - -#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__) -# define PRAGMA_EXPORT_SUPPORTED 1 -#endif - -/* - * WINDOWS: Include windows.h here to define APIENTRY. - * It is also useful when applications include this file by - * including only glut.h, since glut.h depends on windows.h. - * Applications needing to include windows.h with parms other - * than "WIN32_LEAN_AND_MEAN" may include windows.h before - * glut.h or gl.h. - */ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__) -#include -#endif - -#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED -#pragma import on -#endif - -#ifdef CENTERLINE_CLPP -#define signed -#endif - -#if defined(PRAGMA_EXPORT_SUPPORTED) -#pragma export on -#endif - -#endif /* __glplatform_h_ */ - diff --git a/make/stub_includes/opengl/GL/glu.h b/make/stub_includes/opengl/GL/glu.h index e3a16f304..758ba11ba 100644 --- a/make/stub_includes/opengl/GL/glu.h +++ b/make/stub_includes/opengl/GL/glu.h @@ -48,12 +48,14 @@ #include -#ifndef GLAPIENTRY -#define GLAPIENTRY +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY* #endif - #ifndef GLAPI -#define GLAPI +#define GLAPI extern #endif #ifdef __cplusplus @@ -280,133 +282,133 @@ typedef GLUtesselator GLUtriangulatorObj; #define GLU_TESS_MAX_COORD 1.0e150 /* Internal convenience typedefs */ -typedef void (GLAPIENTRY *_GLUfuncptr)(); +typedef void (APIENTRY *_GLUfuncptr)(); #endif /* GLX_VERSION_1_X */ #ifndef GLU_VERSION_1_X #define GLU_VERSION_1_X 1 -GLAPI void GLAPIENTRY gluBeginCurve (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluBeginPolygon (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluBeginSurface (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluBeginTrim (GLUnurbs* nurb); -GLAPI GLint GLAPIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -GLAPI GLint GLAPIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); -GLAPI GLint GLAPIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -GLAPI GLint GLAPIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); -GLAPI GLint GLAPIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -GLAPI GLint GLAPIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -GLAPI GLboolean GLAPIENTRY gluCheckExtension (const GLubyte *extName, const GLubyte *extString); -GLAPI void GLAPIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks); -GLAPI void GLAPIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluDeleteQuadric (GLUquadric* quad); -GLAPI void GLAPIENTRY gluDeleteTess (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops); -GLAPI void GLAPIENTRY gluEndCurve (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluEndPolygon (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluEndSurface (GLUnurbs* nurb); -GLAPI void GLAPIENTRY gluEndTrim (GLUnurbs* nurb); -GLAPI const GLubyte * GLAPIENTRY gluErrorString (GLenum error); -GLAPI void GLAPIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data); -GLAPI const GLubyte * GLAPIENTRY gluGetString (GLenum name); -GLAPI void GLAPIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data); -GLAPI void GLAPIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view); -GLAPI void GLAPIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ); -GLAPI GLUnurbs* GLAPIENTRY gluNewNurbsRenderer (void); -GLAPI GLUquadric* GLAPIENTRY gluNewQuadric (void); -GLAPI GLUtesselator* GLAPIENTRY gluNewTess (void); -GLAPI void GLAPIENTRY gluNextContour (GLUtesselator* tess, GLenum type); -GLAPI void GLAPIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc); -GLAPI void GLAPIENTRY gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData); -GLAPI void GLAPIENTRY gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData); -GLAPI void GLAPIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type); -GLAPI void GLAPIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value); -GLAPI void GLAPIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type); -GLAPI void GLAPIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); -GLAPI void GLAPIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep); -GLAPI void GLAPIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); -GLAPI void GLAPIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport); -GLAPI GLint GLAPIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); -GLAPI void GLAPIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type); -GLAPI void GLAPIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc); -GLAPI void GLAPIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw); -GLAPI void GLAPIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal); -GLAPI void GLAPIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation); -GLAPI void GLAPIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture); -GLAPI GLint GLAPIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut); -GLAPI void GLAPIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks); -GLAPI void GLAPIENTRY gluTessBeginContour (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data); -GLAPI void GLAPIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc); -GLAPI void GLAPIENTRY gluTessEndContour (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluTessEndPolygon (GLUtesselator* tess); -GLAPI void GLAPIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); -GLAPI void GLAPIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data); -GLAPI void GLAPIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data); -GLAPI GLint GLAPIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); -GLAPI GLint GLAPIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW); - - -typedef void (GLAPIENTRY * PFNGLUBEGINCURVEPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUBEGINPOLYGONPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUBEGINSURFACEPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUBEGINTRIMPROC) (GLUnurbs* nurb); -typedef GLint (GLAPIENTRY * PFNGLUBUILD1DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD1DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD2DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD2DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD3DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); -typedef GLint (GLAPIENTRY * PFNGLUBUILD3DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); -typedef GLboolean (GLAPIENTRY * PFNGLUCHECKEXTENSIONPROC) (const GLubyte *extName, const GLubyte *extString); -typedef void (GLAPIENTRY * PFNGLUCYLINDERPROC) (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks); -typedef void (GLAPIENTRY * PFNGLUDELETENURBSRENDERERPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUDELETEQUADRICPROC) (GLUquadric* quad); -typedef void (GLAPIENTRY * PFNGLUDELETETESSPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUDISKPROC) (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops); -typedef void (GLAPIENTRY * PFNGLUENDCURVEPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUENDPOLYGONPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUENDSURFACEPROC) (GLUnurbs* nurb); -typedef void (GLAPIENTRY * PFNGLUENDTRIMPROC) (GLUnurbs* nurb); -typedef const GLubyte * (GLAPIENTRY * PFNGLUERRORSTRINGPROC) (GLenum error); -typedef void (GLAPIENTRY * PFNGLUGETNURBSPROPERTYPROC) (GLUnurbs* nurb, GLenum property, GLfloat* data); -typedef const GLubyte * (GLAPIENTRY * PFNGLUGETSTRINGPROC) (GLenum name); -typedef void (GLAPIENTRY * PFNGLUGETTESSPROPERTYPROC) (GLUtesselator* tess, GLenum which, GLdouble* data); -typedef void (GLAPIENTRY * PFNGLULOADSAMPLINGMATRICESPROC) (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view); -typedef void (GLAPIENTRY * PFNGLULOOKATPROC) (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ); -typedef GLUnurbs* (GLAPIENTRY * PFNGLUNEWNURBSRENDERERPROC) (void); -typedef GLUquadric* (GLAPIENTRY * PFNGLUNEWQUADRICPROC) (void); -typedef GLUtesselator* (GLAPIENTRY * PFNGLUNEWTESSPROC) (void); -typedef void (GLAPIENTRY * PFNGLUNEXTCONTOURPROC) (GLUtesselator* tess, GLenum type); -typedef void (GLAPIENTRY * PFNGLUNURBSCALLBACKPROC) (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc); -typedef void (GLAPIENTRY * PFNGLUNURBSCALLBACKDATAPROC) (GLUnurbs* nurb, GLvoid* userData); -typedef void (GLAPIENTRY * PFNGLUNURBSCALLBACKDATAEXTPROC) (GLUnurbs* nurb, GLvoid* userData); -typedef void (GLAPIENTRY * PFNGLUNURBSCURVEPROC) (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type); -typedef void (GLAPIENTRY * PFNGLUNURBSPROPERTYPROC) (GLUnurbs* nurb, GLenum property, GLfloat value); -typedef void (GLAPIENTRY * PFNGLUNURBSSURFACEPROC) (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type); -typedef void (GLAPIENTRY * PFNGLUORTHO2DPROC) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); -typedef void (GLAPIENTRY * PFNGLUPARTIALDISKPROC) (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep); -typedef void (GLAPIENTRY * PFNGLUPERSPECTIVEPROC) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); -typedef void (GLAPIENTRY * PFNGLUPICKMATRIXPROC) (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport); -typedef GLint (GLAPIENTRY * PFNGLUPROJECTPROC) (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); -typedef void (GLAPIENTRY * PFNGLUPWLCURVEPROC) (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type); -typedef void (GLAPIENTRY * PFNGLUQUADRICCALLBACKPROC) (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc); -typedef void (GLAPIENTRY * PFNGLUQUADRICDRAWSTYLEPROC) (GLUquadric* quad, GLenum draw); -typedef void (GLAPIENTRY * PFNGLUQUADRICNORMALSPROC) (GLUquadric* quad, GLenum normal); -typedef void (GLAPIENTRY * PFNGLUQUADRICORIENTATIONPROC) (GLUquadric* quad, GLenum orientation); -typedef void (GLAPIENTRY * PFNGLUQUADRICTEXTUREPROC) (GLUquadric* quad, GLboolean texture); -typedef GLint (GLAPIENTRY * PFNGLUSCALEIMAGEPROC) (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut); -typedef void (GLAPIENTRY * PFNGLUSPHEREPROC) (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks); -typedef void (GLAPIENTRY * PFNGLUTESSBEGINCONTOURPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUTESSBEGINPOLYGONPROC) (GLUtesselator* tess, GLvoid* data); -typedef void (GLAPIENTRY * PFNGLUTESSCALLBACKPROC) (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc); -typedef void (GLAPIENTRY * PFNGLUTESSENDCONTOURPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUTESSENDPOLYGONPROC) (GLUtesselator* tess); -typedef void (GLAPIENTRY * PFNGLUTESSNORMALPROC) (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); -typedef void (GLAPIENTRY * PFNGLUTESSPROPERTYPROC) (GLUtesselator* tess, GLenum which, GLdouble data); -typedef void (GLAPIENTRY * PFNGLUTESSVERTEXPROC) (GLUtesselator* tess, GLdouble *location, GLvoid* data); -typedef GLint (GLAPIENTRY * PFNGLUUNPROJECTPROC) (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); -typedef GLint (GLAPIENTRY * PFNGLUUNPROJECT4PROC) (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW); +GLAPI void APIENTRY gluBeginCurve (GLUnurbs* nurb); +GLAPI void APIENTRY gluBeginPolygon (GLUtesselator* tess); +GLAPI void APIENTRY gluBeginSurface (GLUnurbs* nurb); +GLAPI void APIENTRY gluBeginTrim (GLUnurbs* nurb); +GLAPI GLint APIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +GLAPI GLint APIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); +GLAPI GLint APIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +GLAPI GLint APIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); +GLAPI GLint APIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +GLAPI GLint APIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI GLboolean APIENTRY gluCheckExtension (const GLubyte *extName, const GLubyte *extString); +GLAPI void APIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks); +GLAPI void APIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb); +GLAPI void APIENTRY gluDeleteQuadric (GLUquadric* quad); +GLAPI void APIENTRY gluDeleteTess (GLUtesselator* tess); +GLAPI void APIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops); +GLAPI void APIENTRY gluEndCurve (GLUnurbs* nurb); +GLAPI void APIENTRY gluEndPolygon (GLUtesselator* tess); +GLAPI void APIENTRY gluEndSurface (GLUnurbs* nurb); +GLAPI void APIENTRY gluEndTrim (GLUnurbs* nurb); +GLAPI const GLubyte * APIENTRY gluErrorString (GLenum error); +GLAPI void APIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data); +GLAPI const GLubyte * APIENTRY gluGetString (GLenum name); +GLAPI void APIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data); +GLAPI void APIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view); +GLAPI void APIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ); +GLAPI GLUnurbs* APIENTRY gluNewNurbsRenderer (void); +GLAPI GLUquadric* APIENTRY gluNewQuadric (void); +GLAPI GLUtesselator* APIENTRY gluNewTess (void); +GLAPI void APIENTRY gluNextContour (GLUtesselator* tess, GLenum type); +GLAPI void APIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc); +GLAPI void APIENTRY gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData); +GLAPI void APIENTRY gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData); +GLAPI void APIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type); +GLAPI void APIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value); +GLAPI void APIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type); +GLAPI void APIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); +GLAPI void APIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep); +GLAPI void APIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport); +GLAPI GLint APIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); +GLAPI void APIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type); +GLAPI void APIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc); +GLAPI void APIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw); +GLAPI void APIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal); +GLAPI void APIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation); +GLAPI void APIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture); +GLAPI GLint APIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut); +GLAPI void APIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks); +GLAPI void APIENTRY gluTessBeginContour (GLUtesselator* tess); +GLAPI void APIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data); +GLAPI void APIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc); +GLAPI void APIENTRY gluTessEndContour (GLUtesselator* tess); +GLAPI void APIENTRY gluTessEndPolygon (GLUtesselator* tess); +GLAPI void APIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); +GLAPI void APIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data); +GLAPI void APIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data); +GLAPI GLint APIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); +GLAPI GLint APIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW); + + +typedef void (APIENTRYP PFNGLUBEGINCURVEPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUBEGINPOLYGONPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUBEGINSURFACEPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUBEGINTRIMPROC) (GLUnurbs* nurb); +typedef GLint (APIENTRYP PFNGLUBUILD1DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD1DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD2DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD2DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD3DMIPMAPLEVELSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data); +typedef GLint (APIENTRYP PFNGLUBUILD3DMIPMAPSPROC) (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef GLboolean (APIENTRYP PFNGLUCHECKEXTENSIONPROC) (const GLubyte *extName, const GLubyte *extString); +typedef void (APIENTRYP PFNGLUCYLINDERPROC) (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks); +typedef void (APIENTRYP PFNGLUDELETENURBSRENDERERPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUDELETEQUADRICPROC) (GLUquadric* quad); +typedef void (APIENTRYP PFNGLUDELETETESSPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUDISKPROC) (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops); +typedef void (APIENTRYP PFNGLUENDCURVEPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUENDPOLYGONPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUENDSURFACEPROC) (GLUnurbs* nurb); +typedef void (APIENTRYP PFNGLUENDTRIMPROC) (GLUnurbs* nurb); +typedef const GLubyte * (APIENTRYP PFNGLUERRORSTRINGPROC) (GLenum error); +typedef void (APIENTRYP PFNGLUGETNURBSPROPERTYPROC) (GLUnurbs* nurb, GLenum property, GLfloat* data); +typedef const GLubyte * (APIENTRYP PFNGLUGETSTRINGPROC) (GLenum name); +typedef void (APIENTRYP PFNGLUGETTESSPROPERTYPROC) (GLUtesselator* tess, GLenum which, GLdouble* data); +typedef void (APIENTRYP PFNGLULOADSAMPLINGMATRICESPROC) (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view); +typedef void (APIENTRYP PFNGLULOOKATPROC) (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ); +typedef GLUnurbs* (APIENTRYP PFNGLUNEWNURBSRENDERERPROC) (void); +typedef GLUquadric* (APIENTRYP PFNGLUNEWQUADRICPROC) (void); +typedef GLUtesselator* (APIENTRYP PFNGLUNEWTESSPROC) (void); +typedef void (APIENTRYP PFNGLUNEXTCONTOURPROC) (GLUtesselator* tess, GLenum type); +typedef void (APIENTRYP PFNGLUNURBSCALLBACKPROC) (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc); +typedef void (APIENTRYP PFNGLUNURBSCALLBACKDATAPROC) (GLUnurbs* nurb, GLvoid* userData); +typedef void (APIENTRYP PFNGLUNURBSCALLBACKDATAEXTPROC) (GLUnurbs* nurb, GLvoid* userData); +typedef void (APIENTRYP PFNGLUNURBSCURVEPROC) (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type); +typedef void (APIENTRYP PFNGLUNURBSPROPERTYPROC) (GLUnurbs* nurb, GLenum property, GLfloat value); +typedef void (APIENTRYP PFNGLUNURBSSURFACEPROC) (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type); +typedef void (APIENTRYP PFNGLUORTHO2DPROC) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top); +typedef void (APIENTRYP PFNGLUPARTIALDISKPROC) (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep); +typedef void (APIENTRYP PFNGLUPERSPECTIVEPROC) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLUPICKMATRIXPROC) (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport); +typedef GLint (APIENTRYP PFNGLUPROJECTPROC) (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); +typedef void (APIENTRYP PFNGLUPWLCURVEPROC) (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type); +typedef void (APIENTRYP PFNGLUQUADRICCALLBACKPROC) (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc); +typedef void (APIENTRYP PFNGLUQUADRICDRAWSTYLEPROC) (GLUquadric* quad, GLenum draw); +typedef void (APIENTRYP PFNGLUQUADRICNORMALSPROC) (GLUquadric* quad, GLenum normal); +typedef void (APIENTRYP PFNGLUQUADRICORIENTATIONPROC) (GLUquadric* quad, GLenum orientation); +typedef void (APIENTRYP PFNGLUQUADRICTEXTUREPROC) (GLUquadric* quad, GLboolean texture); +typedef GLint (APIENTRYP PFNGLUSCALEIMAGEPROC) (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut); +typedef void (APIENTRYP PFNGLUSPHEREPROC) (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks); +typedef void (APIENTRYP PFNGLUTESSBEGINCONTOURPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUTESSBEGINPOLYGONPROC) (GLUtesselator* tess, GLvoid* data); +typedef void (APIENTRYP PFNGLUTESSCALLBACKPROC) (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc); +typedef void (APIENTRYP PFNGLUTESSENDCONTOURPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUTESSENDPOLYGONPROC) (GLUtesselator* tess); +typedef void (APIENTRYP PFNGLUTESSNORMALPROC) (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ); +typedef void (APIENTRYP PFNGLUTESSPROPERTYPROC) (GLUtesselator* tess, GLenum which, GLdouble data); +typedef void (APIENTRYP PFNGLUTESSVERTEXPROC) (GLUtesselator* tess, GLdouble *location, GLvoid* data); +typedef GLint (APIENTRYP PFNGLUUNPROJECTPROC) (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ); +typedef GLint (APIENTRYP PFNGLUUNPROJECT4PROC) (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW); #endif /* GLU_VERSION_1_X */ diff --git a/make/stub_includes/opengl/GL/glx.h b/make/stub_includes/opengl/GL/glx.h index 67225e043..a74cd23e8 100644 --- a/make/stub_includes/opengl/GL/glx.h +++ b/make/stub_includes/opengl/GL/glx.h @@ -56,17 +56,8 @@ extern "C" { #endif - /* For some reason gcc ignores #undef directives for these definitions when placed outside this file, - which are necessary when including both glx.h and glxext.h as is necessary to compile - X11GLImpl_JNI.c. Looks like a bug; couldn't boil down a smaller test case. - gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110) -#define GLX_VERSION_1_1 1 -#define GLX_VERSION_1_2 1 -#define GLX_VERSION_1_3 1 -#define GLX_VERSION_1_4 1 - */ - -#ifndef GLX_VERSION_1_X +#ifndef GLX_VERSION_1_0 +#define GLX_VERSION_1_0 1 #define GLX_EXTENSION_NAME "GLX" @@ -103,100 +94,9 @@ extern "C" { #define GLX_BAD_VALUE 6 #define GLX_BAD_ENUM 7 - -/* - * GLX 1.1 and later: - */ -#define GLX_VENDOR 1 -#define GLX_VERSION 2 -#define GLX_EXTENSIONS 3 - - -/* - * GLX 1.3 and later: - */ -#define GLX_CONFIG_CAVEAT 0x20 -#define GLX_DONT_CARE 0xFFFFFFFF -#define GLX_SLOW_CONFIG 0x8001 -#define GLX_NON_CONFORMANT_CONFIG 0x800D -#define GLX_X_VISUAL_TYPE 0x22 -#define GLX_TRANSPARENT_TYPE 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE 0x24 -#define GLX_TRANSPARENT_RED_VALUE 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 -#define GLX_MAX_PBUFFER_WIDTH 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT 0x8017 -#define GLX_MAX_PBUFFER_PIXELS 0x8018 -#define GLX_PRESERVED_CONTENTS 0x801B -#define GLX_LARGEST_PBUFFER 0x801C -#define GLX_WIDTH 0x801D -#define GLX_HEIGHT 0x801E -#define GLX_EVENT_MASK 0x801F -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_FBCONFIG_ID 0x8013 -#define GLX_VISUAL_ID 0x800B -#define GLX_WINDOW_BIT 0x00000001 -#define GLX_PIXMAP_BIT 0x00000002 -#define GLX_PBUFFER_BIT 0x00000004 -#define GLX_AUX_BUFFERS_BIT 0x00000010 -#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 -#define GLX_DEPTH_BUFFER_BIT 0x00000020 -#define GLX_STENCIL_BUFFER_BIT 0x00000040 -#define GLX_ACCUM_BUFFER_BIT 0x00000080 -#define GLX_DRAWABLE_TYPE 0x8010 -#define GLX_RENDER_TYPE 0x8011 -#define GLX_X_RENDERABLE 0x8012 -#define GLX_NONE 0x8000 -#define GLX_TRUE_COLOR 0x8002 -#define GLX_DIRECT_COLOR 0x8003 -#define GLX_PSEUDO_COLOR 0x8004 -#define GLX_STATIC_COLOR 0x8005 -#define GLX_GRAY_SCALE 0x8006 -#define GLX_STATIC_GRAY 0x8007 -#define GLX_TRANSPARENT_RGB 0x8008 -#define GLX_TRANSPARENT_INDEX 0x8009 -#define GLX_RGBA_TYPE 0x8014 -#define GLX_COLOR_INDEX_TYPE 0x8015 -#define GLX_COLOR_INDEX_BIT 0x00000002 -#define GLX_RGBA_BIT 0x00000001 -#define GLX_SCREEN 0x800C -#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 -#define GLX_DAMAGED 0x8020 -#define GLX_SAVED 0x8021 -#define GLX_WINDOW 0x8022 -#define GLX_PBUFFER 0x8023 -#define GLX_PBUFFER_HEIGHT 0x8040 -#define GLX_PBUFFER_WIDTH 0x8041 - - -/* - * GLX 1.4 and later: - */ -#define GLX_SAMPLE_BUFFERS 0x186a0 /*100000*/ -#define GLX_SAMPLES 0x186a1 /*100001*/ - - - typedef struct __GLXcontextRec *GLXContext; typedef XID GLXPixmap; typedef XID GLXDrawable; -/* GLX 1.3 and later */ -typedef struct __GLXFBConfigRec *GLXFBConfig; -typedef XID GLXFBConfigID; -typedef XID GLXContextID; -typedef XID GLXWindow; -typedef XID GLXPbuffer; - -#endif /* GLX_VERSION_1_X */ - - -#ifndef GLX_VERSION_1_X -#define GLX_VERSION_1_X 1 extern XVisualInfo* glXChooseVisual( Display *dpy, int screen, int *attribList ); @@ -239,226 +139,58 @@ extern void glXWaitX( void ); extern void glXUseXFont( Font font, int first, int count, int list ); +#endif /* GLX_VERSION_1_0 */ -/* GLX 1.1 and later */ -extern const char *glXQueryExtensionsString( Display *dpy, int screen ); - -extern const char *glXQueryServerString( Display *dpy, int screen, int name ); - -extern const char *glXGetClientString( Display *dpy, int name ); - - -/* GLX 1.2 and later */ -extern Display *glXGetCurrentDisplay( void ); - - -/* GLX 1.3 and later */ -extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen, - const int *attribList, int *nitems ); - -extern int glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, - int attribute, int *value ); - -extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen, - int *nelements ); - -extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy, - GLXFBConfig config ); - -extern GLXWindow glXCreateWindow( Display *dpy, GLXFBConfig config, - Window win, const int *attribList ); - -extern void glXDestroyWindow( Display *dpy, GLXWindow window ); - -extern GLXPixmap glXCreatePixmap( Display *dpy, GLXFBConfig config, - Pixmap pixmap, const int *attribList ); - -extern void glXDestroyPixmap( Display *dpy, GLXPixmap pixmap ); - -extern GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config, - const int *attribList ); - -extern void glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf ); - -extern void glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute, - unsigned int *value ); - -extern GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config, - int renderType, GLXContext shareList, - Bool direct ); - -extern Bool glXMakeContextCurrent( Display *dpy, GLXDrawable draw, - GLXDrawable read, GLXContext ctx ); - -extern GLXDrawable glXGetCurrentReadDrawable( void ); - -extern int glXQueryContext( Display *dpy, GLXContext ctx, int attribute, - int *value ); -extern void glXSelectEvent( Display *dpy, GLXDrawable drawable, - unsigned long mask ); +#ifndef GLX_VERSION_1_1 +#define GLX_VERSION_1_1 1 -extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable, - unsigned long *mask ); - -/* GLX 1.4 and later */ -extern void (*glXGetProcAddress(const GLubyte *procname))(); - -#endif /* GLX_VERSION_1_X */ - -#ifndef GLX_GLXEXT_LEGACY - -#include - -#else - - -/* - * 28. GLX_EXT_visual_info extension - */ -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 - -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 - -#endif /* 28. GLX_EXT_visual_info extension */ - - - -/* - * 41. GLX_SGI_video_sync - */ -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 - -extern int glXGetVideoSyncSGI(unsigned int *count); -extern int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count); - -#endif /* GLX_SGI_video_sync */ - - - -/* - * 42. GLX_EXT_visual_rating - */ -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 - -#define GLX_VISUAL_CAVEAT_EXT 0x20 -/*#define GLX_NONE_EXT 0x8000*/ -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D - -#endif /* GLX_EXT_visual_rating */ - - - -/* - * 47. GLX_EXT_import_context - */ -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 - -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C +#define GLX_VENDOR 1 +#define GLX_VERSION 2 +#define GLX_EXTENSIONS 3 -extern void glXFreeContextEXT(Display *dpy, GLXContext context); +extern const char *glXQueryExtensionsString( Display *dpy, int screen ); -extern GLXContextID glXGetContextIDEXT(const GLXContext context); +extern const char *glXQueryServerString( Display *dpy, int screen, int name ); -extern Display *glXGetCurrentDisplayEXT(void); +extern const char *glXGetClientString( Display *dpy, int name ); -extern GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID); +#endif /* GLX_VERSION_1_1 */ -extern int glXQueryContextInfoEXT(Display *dpy, GLXContext context, - int attribute,int *value); -#endif /* GLX_EXT_import_context */ +#ifndef GLX_VERSION_1_2 +#define GLX_VERSION_1_2 1 +extern Display *glXGetCurrentDisplay( void ); +#endif /* GLX_VERSION_1_2 */ -/* - * 215. GLX_MESA_copy_sub_buffer +/** + * We require 'glXGetProcAddress' and 'glXGetProcAddressARB' + * to be available in GLX, rather than GLXExt. */ -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 - -extern void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, - int x, int y, int width, int height ); - +#ifndef GLX_VERSION_1_4 +#define GLX_VERSION_1_4 1 + +typedef void ( *__GLXextFuncPtr)(void); +#define GLX_SAMPLE_BUFFERS 100000 +#define GLX_SAMPLES 100001 +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); +#ifdef GL_GLEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddress (const GLubyte *procName); #endif +#endif /* GLX_VERSION_1_4 */ - - -/* - * 216. GLX_MESA_pixmap_colormap - */ -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 - -extern GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual, - Pixmap pixmap, Colormap cmap ); - -#endif /* GLX_MESA_pixmap_colormap */ - - - -/* - * 217. GLX_MESA_release_buffers - */ -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 - -extern Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ); - -#endif /* GLX_MESA_release_buffers */ - - - -/* - * 218. GLX_MESA_set_3dfx_mode - */ -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 - -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 - -extern Bool glXSet3DfxModeMESA( int mode ); - -#endif /* GLX_MESA_set_3dfx_mode */ - - - -/* - * ARB 2. GLX_ARB_get_proc_address - */ #ifndef GLX_ARB_get_proc_address #define GLX_ARB_get_proc_address 1 - -extern void (*glXGetProcAddressARB(const GLubyte *procName))(); - +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); +#ifdef GL_GLEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName); +#endif #endif /* GLX_ARB_get_proc_address */ - -#endif /* GLX_GLXEXT_LEGACY */ +#include #ifdef __cplusplus } diff --git a/make/stub_includes/opengl/GL/glxext.h b/make/stub_includes/opengl/GL/glxext.h index 3d85521b9..c4805b7d4 100644 --- a/make/stub_includes/opengl/GL/glxext.h +++ b/make/stub_includes/opengl/GL/glxext.h @@ -1,885 +1,858 @@ #ifndef __glxext_h_ -#define __glxext_h_ +#define __glxext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** NOTE: The Original Code (as defined below) has been licensed to Sun -** Microsystems, Inc. ("Sun") under the SGI Free Software License B -** (Version 1.1), shown above ("SGI License"). Pursuant to Section -** 3.2(3) of the SGI License, Sun is distributing the Covered Code to -** you under an alternative license ("Alternative License"). This -** Alternative License includes all of the provisions of the SGI License -** except that Section 2.2 and 11 are omitted. Any differences between -** the Alternative License and the SGI License are offered solely by Sun -** and not by SGI. +** Copyright (c) 2013 The Khronos Group Inc. ** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision$ on $Date$ */ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glxext.h last updated 2009/01/08 */ -/* Current version at http://www.opengl.org/registry/ */ -#define GLX_GLXEXT_VERSION 21 +#define GLX_GLXEXT_VERSION 20130614 -#ifndef GLX_ARB_multisample -#define GLX_SAMPLE_BUFFERS_ARB 100000 -#define GLX_SAMPLES_ARB 100001 -#endif +/* Generated C header for: + * API: glx + * Versions considered: .* + * Versions emitted: 1\.[3-9] + * Default extensions included: glx + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ -#ifndef GLX_ARB_fbconfig_float -#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 -#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 -#endif +#ifndef GLX_VERSION_1_3 +#define GLX_VERSION_1_3 1 +typedef struct __GLXFBConfigRec *GLXFBConfig; +typedef XID GLXWindow; +typedef XID GLXPbuffer; +#define GLX_WINDOW_BIT 0x00000001 +#define GLX_PIXMAP_BIT 0x00000002 +#define GLX_PBUFFER_BIT 0x00000004 +#define GLX_RGBA_BIT 0x00000001 +#define GLX_COLOR_INDEX_BIT 0x00000002 +#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 +#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 +#define GLX_AUX_BUFFERS_BIT 0x00000010 +#define GLX_DEPTH_BUFFER_BIT 0x00000020 +#define GLX_STENCIL_BUFFER_BIT 0x00000040 +#define GLX_ACCUM_BUFFER_BIT 0x00000080 +#define GLX_CONFIG_CAVEAT 0x20 +#define GLX_X_VISUAL_TYPE 0x22 +#define GLX_TRANSPARENT_TYPE 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE 0x24 +#define GLX_TRANSPARENT_RED_VALUE 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 +#define GLX_DONT_CARE 0xFFFFFFFF +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_VISUAL_ID 0x800B +#define GLX_SCREEN 0x800C +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_DRAWABLE_TYPE 0x8010 +#define GLX_RENDER_TYPE 0x8011 +#define GLX_X_RENDERABLE 0x8012 +#define GLX_FBCONFIG_ID 0x8013 +#define GLX_RGBA_TYPE 0x8014 +#define GLX_COLOR_INDEX_TYPE 0x8015 +#define GLX_MAX_PBUFFER_WIDTH 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT 0x8017 +#define GLX_MAX_PBUFFER_PIXELS 0x8018 +#define GLX_PRESERVED_CONTENTS 0x801B +#define GLX_LARGEST_PBUFFER 0x801C +#define GLX_WIDTH 0x801D +#define GLX_HEIGHT 0x801E +#define GLX_EVENT_MASK 0x801F +#define GLX_DAMAGED 0x8020 +#define GLX_SAVED 0x8021 +#define GLX_WINDOW 0x8022 +#define GLX_PBUFFER 0x8023 +#define GLX_PBUFFER_HEIGHT 0x8040 +#define GLX_PBUFFER_WIDTH 0x8041 +typedef GLXFBConfig *( *PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); +typedef GLXFBConfig *( *PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef int ( *PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); +typedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); +typedef GLXWindow ( *PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +typedef void ( *PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); +typedef GLXPixmap ( *PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +typedef void ( *PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); +typedef GLXPbuffer ( *PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); +typedef void ( *PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); +typedef void ( *PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +typedef GLXContext ( *PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef Bool ( *PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable ( *PFNGLXGETCURRENTREADDRAWABLEPROC) (void); +typedef int ( *PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); +typedef void ( *PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); +typedef void ( *PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +#ifdef GL_GLEXT_PROTOTYPES +GLXFBConfig *glXGetFBConfigs (Display *dpy, int screen, int *nelements); +GLXFBConfig *glXChooseFBConfig (Display *dpy, int screen, const int *attrib_list, int *nelements); +int glXGetFBConfigAttrib (Display *dpy, GLXFBConfig config, int attribute, int *value); +XVisualInfo *glXGetVisualFromFBConfig (Display *dpy, GLXFBConfig config); +GLXWindow glXCreateWindow (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +void glXDestroyWindow (Display *dpy, GLXWindow win); +GLXPixmap glXCreatePixmap (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +void glXDestroyPixmap (Display *dpy, GLXPixmap pixmap); +GLXPbuffer glXCreatePbuffer (Display *dpy, GLXFBConfig config, const int *attrib_list); +void glXDestroyPbuffer (Display *dpy, GLXPbuffer pbuf); +void glXQueryDrawable (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +GLXContext glXCreateNewContext (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +Bool glXMakeContextCurrent (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +GLXDrawable glXGetCurrentReadDrawable (void); +int glXQueryContext (Display *dpy, GLXContext ctx, int attribute, int *value); +void glXSelectEvent (Display *dpy, GLXDrawable draw, unsigned long event_mask); +void glXGetSelectedEvent (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +#endif +#endif /* GLX_VERSION_1_3 */ + +#ifndef GLX_VERSION_1_4 +#define GLX_VERSION_1_4 1 +typedef void ( *__GLXextFuncPtr)(void); +#define GLX_SAMPLE_BUFFERS 100000 +#define GLX_SAMPLES 100001 +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); +#ifdef GL_GLEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddress (const GLubyte *procName); +#endif +#endif /* GLX_VERSION_1_4 */ #ifndef GLX_ARB_create_context -#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_ARB_create_context 1 +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 +typedef GLXContext ( *PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GLXContext glXCreateContextAttribsARB (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); +#endif +#endif /* GLX_ARB_create_context */ + +#ifndef GLX_ARB_create_context_profile +#define GLX_ARB_create_context_profile 1 +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define GLX_CONTEXT_FLAGS_ARB 0x2094 -#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 -#endif +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 +#endif /* GLX_ARB_create_context_profile */ #ifndef GLX_ARB_create_context_robustness -#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 -#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#endif +#define GLX_ARB_create_context_robustness 1 +#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* GLX_ARB_create_context_robustness */ -#ifndef GLX_EXT_create_context_es2_profile -#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#endif - -#ifndef GLX_SGIS_multisample -#define GLX_SAMPLE_BUFFERS_SGIS 100000 -#define GLX_SAMPLES_SGIS 100001 -#endif - -#ifndef GLX_EXT_visual_info -#define GLX_X_VISUAL_TYPE_EXT 0x22 -#define GLX_TRANSPARENT_TYPE_EXT 0x23 -#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 -#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 -#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 -#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 -#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 -#define GLX_NONE_EXT 0x8000 -#define GLX_TRUE_COLOR_EXT 0x8002 -#define GLX_DIRECT_COLOR_EXT 0x8003 -#define GLX_PSEUDO_COLOR_EXT 0x8004 -#define GLX_STATIC_COLOR_EXT 0x8005 -#define GLX_GRAY_SCALE_EXT 0x8006 -#define GLX_STATIC_GRAY_EXT 0x8007 -#define GLX_TRANSPARENT_RGB_EXT 0x8008 -#define GLX_TRANSPARENT_INDEX_EXT 0x8009 -#endif +#ifndef GLX_ARB_fbconfig_float +#define GLX_ARB_fbconfig_float 1 +#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 +#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 +#endif /* GLX_ARB_fbconfig_float */ -#ifndef GLX_SGI_swap_control -#endif +#ifndef GLX_ARB_framebuffer_sRGB +#define GLX_ARB_framebuffer_sRGB 1 +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 +#endif /* GLX_ARB_framebuffer_sRGB */ -#ifndef GLX_SGI_video_sync -#endif - -#ifndef GLX_SGI_make_current_read +#ifndef GLX_ARB_get_proc_address +#define GLX_ARB_get_proc_address 1 +typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); +#ifdef GL_GLEXT_PROTOTYPES +__GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName); #endif +#endif /* GLX_ARB_get_proc_address */ -#ifndef GLX_SGIX_video_source -#endif +#ifndef GLX_ARB_multisample +#define GLX_ARB_multisample 1 +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 +#endif /* GLX_ARB_multisample */ -#ifndef GLX_EXT_visual_rating -#define GLX_VISUAL_CAVEAT_EXT 0x20 -#define GLX_SLOW_VISUAL_EXT 0x8001 -#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D -/* reuse GLX_NONE_EXT */ -#endif +#ifndef GLX_ARB_robustness_application_isolation +#define GLX_ARB_robustness_application_isolation 1 +#define GLX_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* GLX_ARB_robustness_application_isolation */ -#ifndef GLX_EXT_import_context -#define GLX_SHARE_CONTEXT_EXT 0x800A -#define GLX_VISUAL_ID_EXT 0x800B -#define GLX_SCREEN_EXT 0x800C -#endif +#ifndef GLX_ARB_robustness_share_group_isolation +#define GLX_ARB_robustness_share_group_isolation 1 +#endif /* GLX_ARB_robustness_share_group_isolation */ -#ifndef GLX_SGIX_fbconfig -#define GLX_WINDOW_BIT_SGIX 0x00000001 -#define GLX_PIXMAP_BIT_SGIX 0x00000002 -#define GLX_RGBA_BIT_SGIX 0x00000001 -#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 -#define GLX_DRAWABLE_TYPE_SGIX 0x8010 -#define GLX_RENDER_TYPE_SGIX 0x8011 -#define GLX_X_RENDERABLE_SGIX 0x8012 -#define GLX_FBCONFIG_ID_SGIX 0x8013 -#define GLX_RGBA_TYPE_SGIX 0x8014 -#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 -/* reuse GLX_SCREEN_EXT */ -#endif +#ifndef GLX_ARB_vertex_buffer_object +#define GLX_ARB_vertex_buffer_object 1 +#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095 +#endif /* GLX_ARB_vertex_buffer_object */ -#ifndef GLX_SGIX_pbuffer -#define GLX_PBUFFER_BIT_SGIX 0x00000004 -#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 -#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 -#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 -#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 -#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 -#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 -#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 -#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 -#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 -#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 -#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 -#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 -#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 -#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 -#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A -#define GLX_PRESERVED_CONTENTS_SGIX 0x801B -#define GLX_LARGEST_PBUFFER_SGIX 0x801C -#define GLX_WIDTH_SGIX 0x801D -#define GLX_HEIGHT_SGIX 0x801E -#define GLX_EVENT_MASK_SGIX 0x801F -#define GLX_DAMAGED_SGIX 0x8020 -#define GLX_SAVED_SGIX 0x8021 -#define GLX_WINDOW_SGIX 0x8022 -#define GLX_PBUFFER_SGIX 0x8023 -#endif +#ifndef GLX_3DFX_multisample +#define GLX_3DFX_multisample 1 +#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 +#define GLX_SAMPLES_3DFX 0x8051 +#endif /* GLX_3DFX_multisample */ + +#ifndef GLX_AMD_gpu_association +#define GLX_AMD_gpu_association 1 +#define GLX_GPU_VENDOR_AMD 0x1F00 +#define GLX_GPU_RENDERER_STRING_AMD 0x1F01 +#define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define GLX_GPU_RAM_AMD 0x21A3 +#define GLX_GPU_CLOCK_AMD 0x21A4 +#define GLX_GPU_NUM_PIPES_AMD 0x21A5 +#define GLX_GPU_NUM_SIMD_AMD 0x21A6 +#define GLX_GPU_NUM_RB_AMD 0x21A7 +#define GLX_GPU_NUM_SPI_AMD 0x21A8 +#endif /* GLX_AMD_gpu_association */ + +#ifndef GLX_EXT_buffer_age +#define GLX_EXT_buffer_age 1 +#define GLX_BACK_BUFFER_AGE_EXT 0x20F4 +#endif /* GLX_EXT_buffer_age */ -#ifndef GLX_SGI_cushion -#endif +#ifndef GLX_EXT_create_context_es2_profile +#define GLX_EXT_create_context_es2_profile 1 +#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* GLX_EXT_create_context_es2_profile */ -#ifndef GLX_SGIX_video_resize -#define GLX_SYNC_FRAME_SGIX 0x00000000 -#define GLX_SYNC_SWAP_SGIX 0x00000001 -#endif +#ifndef GLX_EXT_create_context_es_profile +#define GLX_EXT_create_context_es_profile 1 +#define GLX_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* GLX_EXT_create_context_es_profile */ -#ifndef GLX_SGIX_dmbuffer -#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 -#endif +#ifndef GLX_EXT_fbconfig_packed_float +#define GLX_EXT_fbconfig_packed_float 1 +#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 +#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 +#endif /* GLX_EXT_fbconfig_packed_float */ -#ifndef GLX_SGIX_swap_group -#endif +#ifndef GLX_EXT_framebuffer_sRGB +#define GLX_EXT_framebuffer_sRGB 1 +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 +#endif /* GLX_EXT_framebuffer_sRGB */ -#ifndef GLX_SGIX_swap_barrier -#endif +#ifndef GLX_EXT_import_context +#define GLX_EXT_import_context 1 +typedef XID GLXContextID; +#define GLX_SHARE_CONTEXT_EXT 0x800A +#define GLX_VISUAL_ID_EXT 0x800B +#define GLX_SCREEN_EXT 0x800C +typedef Display *( *PFNGLXGETCURRENTDISPLAYEXTPROC) (void); +typedef int ( *PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value); +typedef GLXContextID ( *PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); +typedef GLXContext ( *PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID); +typedef void ( *PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context); +#ifdef GL_GLEXT_PROTOTYPES +Display *glXGetCurrentDisplayEXT (void); +int glXQueryContextInfoEXT (Display *dpy, GLXContext context, int attribute, int *value); +GLXContextID glXGetContextIDEXT (const GLXContext context); +GLXContext glXImportContextEXT (Display *dpy, GLXContextID contextID); +void glXFreeContextEXT (Display *dpy, GLXContext context); +#endif +#endif /* GLX_EXT_import_context */ + +#ifndef GLX_EXT_swap_control +#define GLX_EXT_swap_control 1 +#define GLX_SWAP_INTERVAL_EXT 0x20F1 +#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 +typedef void ( *PFNGLXSWAPINTERVALEXTPROC) (Display *dpy, GLXDrawable drawable, int interval); +#ifdef GL_GLEXT_PROTOTYPES +void glXSwapIntervalEXT (Display *dpy, GLXDrawable drawable, int interval); +#endif +#endif /* GLX_EXT_swap_control */ + +#ifndef GLX_EXT_swap_control_tear +#define GLX_EXT_swap_control_tear 1 +#define GLX_LATE_SWAPS_TEAR_EXT 0x20F3 +#endif /* GLX_EXT_swap_control_tear */ -#ifndef GLX_SGIS_blended_overlay -#define GLX_BLENDED_RGBA_SGIS 0x8025 -#endif +#ifndef GLX_EXT_texture_from_pixmap +#define GLX_EXT_texture_from_pixmap 1 +#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 +#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 +#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 +#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 +#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 +#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 +#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 +#define GLX_Y_INVERTED_EXT 0x20D4 +#define GLX_TEXTURE_FORMAT_EXT 0x20D5 +#define GLX_TEXTURE_TARGET_EXT 0x20D6 +#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 +#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 +#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 +#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA +#define GLX_TEXTURE_1D_EXT 0x20DB +#define GLX_TEXTURE_2D_EXT 0x20DC +#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD +#define GLX_FRONT_LEFT_EXT 0x20DE +#define GLX_FRONT_RIGHT_EXT 0x20DF +#define GLX_BACK_LEFT_EXT 0x20E0 +#define GLX_BACK_RIGHT_EXT 0x20E1 +#define GLX_FRONT_EXT 0x20DE +#define GLX_BACK_EXT 0x20E0 +#define GLX_AUX0_EXT 0x20E2 +#define GLX_AUX1_EXT 0x20E3 +#define GLX_AUX2_EXT 0x20E4 +#define GLX_AUX3_EXT 0x20E5 +#define GLX_AUX4_EXT 0x20E6 +#define GLX_AUX5_EXT 0x20E7 +#define GLX_AUX6_EXT 0x20E8 +#define GLX_AUX7_EXT 0x20E9 +#define GLX_AUX8_EXT 0x20EA +#define GLX_AUX9_EXT 0x20EB +typedef void ( *PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); +typedef void ( *PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, GLXDrawable drawable, int buffer); +#ifdef GL_GLEXT_PROTOTYPES +void glXBindTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer, const int *attrib_list); +void glXReleaseTexImageEXT (Display *dpy, GLXDrawable drawable, int buffer); +#endif +#endif /* GLX_EXT_texture_from_pixmap */ -#ifndef GLX_SGIS_shared_multisample -#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 -#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 -#endif +#ifndef GLX_EXT_visual_info +#define GLX_EXT_visual_info 1 +#define GLX_X_VISUAL_TYPE_EXT 0x22 +#define GLX_TRANSPARENT_TYPE_EXT 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 +#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 +#define GLX_NONE_EXT 0x8000 +#define GLX_TRUE_COLOR_EXT 0x8002 +#define GLX_DIRECT_COLOR_EXT 0x8003 +#define GLX_PSEUDO_COLOR_EXT 0x8004 +#define GLX_STATIC_COLOR_EXT 0x8005 +#define GLX_GRAY_SCALE_EXT 0x8006 +#define GLX_STATIC_GRAY_EXT 0x8007 +#define GLX_TRANSPARENT_RGB_EXT 0x8008 +#define GLX_TRANSPARENT_INDEX_EXT 0x8009 +#endif /* GLX_EXT_visual_info */ -#ifndef GLX_SUN_get_transparent_index -#endif +#ifndef GLX_EXT_visual_rating +#define GLX_EXT_visual_rating 1 +#define GLX_VISUAL_CAVEAT_EXT 0x20 +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D +#endif /* GLX_EXT_visual_rating */ + +#ifndef GLX_INTEL_swap_event +#define GLX_INTEL_swap_event 1 +#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000 +#define GLX_EXCHANGE_COMPLETE_INTEL 0x8180 +#define GLX_COPY_COMPLETE_INTEL 0x8181 +#define GLX_FLIP_COMPLETE_INTEL 0x8182 +#endif /* GLX_INTEL_swap_event */ -#ifndef GLX_3DFX_multisample -#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 -#define GLX_SAMPLES_3DFX 0x8051 +#ifndef GLX_MESA_agp_offset +#define GLX_MESA_agp_offset 1 +typedef unsigned int ( *PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +unsigned int glXGetAGPOffsetMESA (const void *pointer); #endif +#endif /* GLX_MESA_agp_offset */ #ifndef GLX_MESA_copy_sub_buffer +#define GLX_MESA_copy_sub_buffer 1 +typedef void ( *PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); +#ifdef GL_GLEXT_PROTOTYPES +void glXCopySubBufferMESA (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); #endif +#endif /* GLX_MESA_copy_sub_buffer */ #ifndef GLX_MESA_pixmap_colormap +#define GLX_MESA_pixmap_colormap 1 +typedef GLXPixmap ( *PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); +#ifdef GL_GLEXT_PROTOTYPES +GLXPixmap glXCreateGLXPixmapMESA (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); #endif +#endif /* GLX_MESA_pixmap_colormap */ #ifndef GLX_MESA_release_buffers +#define GLX_MESA_release_buffers 1 +typedef Bool ( *PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXReleaseBuffersMESA (Display *dpy, GLXDrawable drawable); #endif +#endif /* GLX_MESA_release_buffers */ #ifndef GLX_MESA_set_3dfx_mode -#define GLX_3DFX_WINDOW_MODE_MESA 0x1 -#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 -#endif - -#ifndef GLX_SGIX_visual_select_group -#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_SWAP_METHOD_OML 0x8060 -#define GLX_SWAP_EXCHANGE_OML 0x8061 -#define GLX_SWAP_COPY_OML 0x8062 -#define GLX_SWAP_UNDEFINED_OML 0x8063 +#define GLX_MESA_set_3dfx_mode 1 +#define GLX_3DFX_WINDOW_MODE_MESA 0x1 +#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 +typedef Bool ( *PFNGLXSET3DFXMODEMESAPROC) (int mode); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXSet3DfxModeMESA (int mode); #endif +#endif /* GLX_MESA_set_3dfx_mode */ -#ifndef GLX_OML_sync_control +#ifndef GLX_NV_copy_image +#define GLX_NV_copy_image 1 +typedef void ( *PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +void glXCopyImageSubDataNV (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); #endif +#endif /* GLX_NV_copy_image */ #ifndef GLX_NV_float_buffer -#define GLX_FLOAT_COMPONENTS_NV 0x20B0 -#endif - -#ifndef GLX_SGIX_hyperpipe -#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 -#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 -#define GLX_BAD_HYPERPIPE_SGIX 92 -#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 -#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 -#define GLX_PIPE_RECT_SGIX 0x00000001 -#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 -#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 -#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 -#define GLX_HYPERPIPE_ID_SGIX 0x8030 -#endif - -#ifndef GLX_MESA_agp_offset -#endif - - -/*************************************************************/ - -typedef void (*__GLXextFuncPtr)(void); - -#ifndef GLX_ARB_get_proc_address -#define GLX_ARB_get_proc_address 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *); -extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName); -typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); -#endif - - -#ifndef GLX_SGIX_video_source -typedef XID GLXVideoSourceSGIX; -#endif +#define GLX_NV_float_buffer 1 +#define GLX_FLOAT_COMPONENTS_NV 0x20B0 +#endif /* GLX_NV_float_buffer */ -#ifndef GLX_SGIX_fbconfig -typedef XID GLXFBConfigIDSGIX; -typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; -#endif +#ifndef GLX_NV_multisample_coverage +#define GLX_NV_multisample_coverage 1 +#define GLX_COVERAGE_SAMPLES_NV 100001 +#define GLX_COLOR_SAMPLES_NV 0x20B3 +#endif /* GLX_NV_multisample_coverage */ -#ifndef GLX_SGIX_pbuffer -typedef XID GLXPbufferSGIX; -typedef struct { - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came for SendEvent request */ - Display *display; /* display the event was read from */ - GLXDrawable drawable; /* i.d. of Drawable */ - int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */ - int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */ - unsigned int mask; /* mask indicating which buffers are affected*/ - int x, y; - int width, height; - int count; /* if nonzero, at least this many more */ -} GLXBufferClobberEventSGIX; +#ifndef GLX_NV_present_video +#define GLX_NV_present_video 1 +#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef unsigned int *( *PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements); +typedef int ( *PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +unsigned int *glXEnumerateVideoDevicesNV (Display *dpy, int screen, int *nelements); +int glXBindVideoDeviceNV (Display *dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); #endif +#endif /* GLX_NV_present_video */ #ifndef GLX_NV_swap_group -#endif - -#ifndef GLX_NV_video_out -/* - * GLXVideoDeviceNV is an opaque handle to a video device (part of the - * GLX_NV_video_out extension). - */ +#define GLX_NV_swap_group 1 +typedef Bool ( *PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint group); +typedef Bool ( *PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, GLuint group, GLuint barrier); +typedef Bool ( *PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); +typedef Bool ( *PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); +typedef Bool ( *PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, int screen, GLuint *count); +typedef Bool ( *PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXJoinSwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint group); +Bool glXBindSwapBarrierNV (Display *dpy, GLuint group, GLuint barrier); +Bool glXQuerySwapGroupNV (Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); +Bool glXQueryMaxSwapGroupsNV (Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); +Bool glXQueryFrameCountNV (Display *dpy, int screen, GLuint *count); +Bool glXResetFrameCountNV (Display *dpy, int screen); +#endif +#endif /* GLX_NV_swap_group */ + +#ifndef GLX_NV_video_capture +#define GLX_NV_video_capture 1 +typedef XID GLXVideoCaptureDeviceNV; +#define GLX_DEVICE_ID_NV 0x20CD +#define GLX_UNIQUE_ID_NV 0x20CE +#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef int ( *PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); +typedef GLXVideoCaptureDeviceNV *( *PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display *dpy, int screen, int *nelements); +typedef void ( *PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device); +typedef int ( *PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); +typedef void ( *PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display *dpy, GLXVideoCaptureDeviceNV device); +#ifdef GL_GLEXT_PROTOTYPES +int glXBindVideoCaptureDeviceNV (Display *dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); +GLXVideoCaptureDeviceNV *glXEnumerateVideoCaptureDevicesNV (Display *dpy, int screen, int *nelements); +void glXLockVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device); +int glXQueryVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); +void glXReleaseVideoCaptureDeviceNV (Display *dpy, GLXVideoCaptureDeviceNV device); +#endif +#endif /* GLX_NV_video_capture */ + +#ifndef GLX_NV_video_output +#define GLX_NV_video_output 1 typedef unsigned int GLXVideoDeviceNV; - -/* glXBindVideoImageNV iVideoBuffer values (NV_video_out) */ -#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 -#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 -#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 -#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 -#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 - -/* glXSendPbufferToVideoNV iBufferType values (NV_video_out) */ -#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 -#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 -#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA +#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 +#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 +#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 +#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 +#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 +#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA #define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB #define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC -#endif - -#ifndef GLX_EXT_fbconfig_packed_float -#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 -#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 -#endif - -#ifndef GLX_EXT_framebuffer_sRGB -#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 -#endif - -#ifndef GLX_EXT_texture_from_pixmap -/* New glXGetFBConfigAttrib tokens */ -#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 -#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 -#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 -#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 -#define GLX_Y_INVERTED_EXT 0x20D4 - -/* New glXCreatePixmap attributes and glXQueryDrawable attributes */ -#define GLX_TEXTURE_FORMAT_EXT 0x20D5 -#define GLX_TEXTURE_TARGET_EXT 0x20D6 -#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 - -/* Values for GLX_TEXTURE_FORMAT_EXT */ -#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 -#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 -#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA - -/* Bits for GLX_BIND_TO_TEXTURE_TARGETS_EXT mask */ -#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 -#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 -#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 - -/* Values for GLX_TEXTURE_TARGET_EXT */ -#define GLX_TEXTURE_1D_EXT 0x20DB -#define GLX_TEXTURE_2D_EXT 0x20DC -#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD +typedef int ( *PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); +typedef int ( *PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice); +typedef int ( *PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); +typedef int ( *PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, GLXPbuffer pbuf); +typedef int ( *PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); +typedef int ( *PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef GL_GLEXT_PROTOTYPES +int glXGetVideoDeviceNV (Display *dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); +int glXReleaseVideoDeviceNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice); +int glXBindVideoImageNV (Display *dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); +int glXReleaseVideoImageNV (Display *dpy, GLXPbuffer pbuf); +int glXSendPbufferToVideoNV (Display *dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); +int glXGetVideoInfoNV (Display *dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* GLX_NV_video_output */ /* - * Values for the buffer parameter of glXBindTexImageEXT and - * glXReleaseTexImageEXT - */ -#define GLX_FRONT_LEFT_EXT 0x20DE -#define GLX_FRONT_RIGHT_EXT 0x20DF -#define GLX_BACK_LEFT_EXT 0x20E0 -#define GLX_BACK_RIGHT_EXT 0x20E1 -#define GLX_FRONT_EXT GLX_FRONT_LEFT_EXT -#define GLX_BACK_EXT GLX_BACK_LEFT_EXT -#define GLX_AUX0_EXT 0x20E2 -#define GLX_AUX1_EXT 0x20E3 -#define GLX_AUX2_EXT 0x20E4 -#define GLX_AUX3_EXT 0x20E5 -#define GLX_AUX4_EXT 0x20E6 -#define GLX_AUX5_EXT 0x20E7 -#define GLX_AUX6_EXT 0x20E8 -#define GLX_AUX7_EXT 0x20E9 -#define GLX_AUX8_EXT 0x20EA -#define GLX_AUX9_EXT 0x20EB - -#endif + * GLX_NV_vertex_array_range is not a real extension name... + */ +#ifndef GLX_NV_vertex_array_range +#define GLX_NV_vertex_array_range 1 +typedef GLvoid* ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer); +#ifdef GL_GLEXT_PROTOTYPES +extern GLvoid* glXAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +extern void glXFreeMemoryNV (GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +#endif /* GLX_NV_vertex_array_range */ -#ifndef GLX_NV_multisample_coverage -#define GLX_COVERAGE_SAMPLES_NV GLX_SAMPLES_ARB -#define GLX_COLOR_SAMPLES_NV 0x20B3 -#endif +#ifndef GLX_OML_swap_method +#define GLX_OML_swap_method 1 +#define GLX_SWAP_METHOD_OML 0x8060 +#define GLX_SWAP_EXCHANGE_OML 0x8061 +#define GLX_SWAP_COPY_OML 0x8062 +#define GLX_SWAP_UNDEFINED_OML 0x8063 +#endif /* GLX_OML_swap_method */ -/* Define int32_t and int64_t types for UST/MSC */ +#ifndef GLX_OML_sync_control +#define GLX_OML_sync_control 1 #ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ +/* This code block is duplicated in glext.h, so must be protected */ #define GLEXT_64_TYPES_DEFINED -#include "gl-64bit-types.h" -#endif +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GLX_OML_sync_control extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif +typedef Bool ( *PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); +typedef Bool ( *PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); +typedef int64_t ( *PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); +typedef Bool ( *PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); +typedef Bool ( *PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXGetSyncValuesOML (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); +Bool glXGetMscRateOML (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); +int64_t glXSwapBuffersMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); +Bool glXWaitForMscOML (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); +Bool glXWaitForSbcOML (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); +#endif +#endif /* GLX_OML_sync_control */ -#ifndef GLX_ARB_get_proc_address -/* Moved to glx.h */ -#endif - -#ifndef GLX_ARB_multisample -#define GLX_ARB_multisample 1 -#endif - -#ifndef GLX_ARB_fbconfig_float -#define GLX_ARB_fbconfig_float 1 -#endif - -#ifndef GLX_ARB_create_context -#define GLX_ARB_create_context 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXContext glXCreateContextAttribsARB (Display *, GLXFBConfig, GLXContext, Bool, const int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); -#endif +#ifndef GLX_SGIS_blended_overlay +#define GLX_SGIS_blended_overlay 1 +#define GLX_BLENDED_RGBA_SGIS 0x8025 +#endif /* GLX_SGIS_blended_overlay */ #ifndef GLX_SGIS_multisample #define GLX_SGIS_multisample 1 -#endif - -#ifndef GLX_EXT_visual_info -#define GLX_EXT_visual_info 1 -#endif - -#ifndef GLX_MESA_swap_control -#define GLX_MESA_swap_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXSwapIntervalMESA(unsigned int interval); -extern int glXGetSwapIntervalMESA(void); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXSWAPINTERVALMESAPROC)(unsigned int interval); -typedef int ( * PFNGLXGETSWAPINTERVALMESAPROC)(void); -#endif - -#ifndef GLX_SGI_swap_control -#define GLX_SGI_swap_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXSwapIntervalSGI (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); -#endif - -#ifndef GLX_SGI_video_sync -#define GLX_SGI_video_sync 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetVideoSyncSGI (unsigned int *); -extern int glXWaitVideoSyncSGI (int, int, unsigned int *); -extern int glXGetRefreshRateSGI(unsigned int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count); -typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count); -typedef int ( * PFNGLXGETREFRESHRATESGIPROC) (unsigned int *); -#endif - -#ifndef GLX_SGI_make_current_read -#define GLX_SGI_make_current_read 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXMakeCurrentReadSGI (Display *, GLXDrawable, GLXDrawable, GLXContext); -extern GLXDrawable glXGetCurrentReadDrawableSGI (void); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); -typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); -#endif - -#ifndef GLX_SGIX_video_source -#define GLX_SGIX_video_source 1 -#ifdef _VL_H -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *, int, VLServer, VLPath, int, VLNode); -extern void glXDestroyGLXVideoSourceSGIX (Display *, GLXVideoSourceSGIX); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); -typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource); -#endif /* _VL_H */ -#endif - -#ifndef GLX_EXT_visual_rating -#define GLX_EXT_visual_rating 1 -#endif - -#ifndef GLX_EXT_import_context -#define GLX_EXT_import_context 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Display * glXGetCurrentDisplayEXT (void); -extern int glXQueryContextInfoEXT (Display *, GLXContext, int, int *); -extern GLXContextID glXGetContextIDEXT (const GLXContext); -extern GLXContext glXImportContextEXT (Display *, GLXContextID); -extern void glXFreeContextEXT (Display *, GLXContext); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void); -typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value); -typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); -typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID); -typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context); -#endif - -#ifndef GLX_SGIX_fbconfig -#define GLX_SGIX_fbconfig 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetFBConfigAttribSGIX (Display *, GLXFBConfigSGIX, int, int *); -extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *, int, int *, int *); -extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *, GLXFBConfigSGIX, Pixmap); -extern GLXContext glXCreateContextWithConfigSGIX (Display *, GLXFBConfigSGIX, int, GLXContext, Bool); -extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *, GLXFBConfigSGIX); -extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *, XVisualInfo *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); -typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements); -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); -typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); -typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config); -typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis); -#endif - -#ifndef GLX_SGIX_pbuffer -#define GLX_SGIX_pbuffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *); -extern void glXDestroyGLXPbufferSGIX (Display *, GLXPbufferSGIX); -extern int glXQueryGLXPbufferSGIX (Display *, GLXPbufferSGIX, int, unsigned int *); -extern void glXSelectEventSGIX (Display *, GLXDrawable, unsigned long); -extern void glXGetSelectedEventSGIX (Display *, GLXDrawable, unsigned long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); -typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); -typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); -typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); -typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); -#endif - -#ifndef GLX_SGI_cushion -#define GLX_SGI_cushion 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCushionSGI (Display *, Window, float); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion); -#endif +#define GLX_SAMPLE_BUFFERS_SGIS 100000 +#define GLX_SAMPLES_SGIS 100001 +#endif /* GLX_SGIS_multisample */ -#ifndef GLX_SGIX_video_resize -#define GLX_SGIX_video_resize 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXBindChannelToWindowSGIX (Display *, int, int, Window); -extern int glXChannelRectSGIX (Display *, int, int, int, int, int, int); -extern int glXQueryChannelRectSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXQueryChannelDeltasSGIX (Display *, int, int, int *, int *, int *, int *); -extern int glXChannelRectSyncSGIX (Display *, int, int, GLenum); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window); -typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h); -typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); -typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); -typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype); -#endif +#ifndef GLX_SGIS_shared_multisample +#define GLX_SGIS_shared_multisample 1 +#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 +#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 +#endif /* GLX_SGIS_shared_multisample */ +#if 0 /* Disabled: DMparams and DMbuffer undefined */ #ifndef GLX_SGIX_dmbuffer #define GLX_SGIX_dmbuffer 1 -#ifdef _DM_BUFFER_H_ -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXAssociateDMPbufferSGIX (Display *, GLXPbufferSGIX, DMparams *, DMbuffer); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); -#endif /* _DM_BUFFER_H_ */ -#endif - -#ifndef GLX_SGIX_swap_group -#define GLX_SGIX_swap_group 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXJoinSwapGroupSGIX (Display *, GLXDrawable, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); -#endif - -#ifndef GLX_SGIX_swap_barrier -#define GLX_SGIX_swap_barrier 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXBindSwapBarrierSGIX (Display *, GLXDrawable, int); -extern Bool glXQueryMaxSwapBarriersSGIX (Display *, int, int *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); -typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); -#endif - -#ifndef GLX_SUN_get_transparent_index -#define GLX_SUN_get_transparent_index 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Status glXGetTransparentIndexSUN (Display *, Window, Window, long *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); -#endif - -#ifndef GLX_MESA_copy_sub_buffer -#define GLX_MESA_copy_sub_buffer 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXCopySubBufferMESA (Display *, GLXDrawable, int, int, int, int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height); -#endif - -#ifndef GLX_MESA_pixmap_colormap -#define GLX_MESA_pixmap_colormap 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXPixmap glXCreateGLXPixmapMESA (Display *, XVisualInfo *, Pixmap, Colormap); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); -#endif - -#ifndef GLX_MESA_release_buffers -#define GLX_MESA_release_buffers 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXReleaseBuffersMESA (Display *, GLXDrawable); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable); -#endif - -#ifndef GLX_MESA_set_3dfx_mode -#define GLX_MESA_set_3dfx_mode 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXSet3DfxModeMESA (int); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode); -#endif - -#ifndef GLX_SGIX_visual_select_group -#define GLX_SGIX_visual_select_group 1 -#endif - -#ifndef GLX_OML_swap_method -#define GLX_OML_swap_method 1 +typedef XID GLXPbufferSGIX; +#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024 +typedef Bool ( *PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXAssociateDMPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer); #endif - -#ifndef GLX_OML_sync_control -#define GLX_OML_sync_control 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *); -extern Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *); -extern int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t); -extern Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *); -extern Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator); -typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); -typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc); -typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc); -#endif - -#ifndef GLX_NV_float_buffer -#define GLX_NV_float_buffer 1 +#endif /* GLX_SGIX_dmbuffer */ #endif +#ifndef GLX_SGIX_fbconfig +#define GLX_SGIX_fbconfig 1 +typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; +#define GLX_WINDOW_BIT_SGIX 0x00000001 +#define GLX_PIXMAP_BIT_SGIX 0x00000002 +#define GLX_RGBA_BIT_SGIX 0x00000001 +#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 +#define GLX_DRAWABLE_TYPE_SGIX 0x8010 +#define GLX_RENDER_TYPE_SGIX 0x8011 +#define GLX_X_RENDERABLE_SGIX 0x8012 +#define GLX_FBCONFIG_ID_SGIX 0x8013 +#define GLX_RGBA_TYPE_SGIX 0x8014 +#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 +typedef int ( *PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); +typedef GLXFBConfigSGIX *( *PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements); +typedef GLXPixmap ( *PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); +typedef GLXContext ( *PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); +typedef XVisualInfo *( *PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config); +typedef GLXFBConfigSGIX ( *PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis); +#ifdef GL_GLEXT_PROTOTYPES +int glXGetFBConfigAttribSGIX (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value); +GLXFBConfigSGIX *glXChooseFBConfigSGIX (Display *dpy, int screen, int *attrib_list, int *nelements); +GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap); +GLXContext glXCreateContextWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct); +XVisualInfo *glXGetVisualFromFBConfigSGIX (Display *dpy, GLXFBConfigSGIX config); +GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *dpy, XVisualInfo *vis); +#endif +#endif /* GLX_SGIX_fbconfig */ + +#if 0 #ifndef GLX_SGIX_hyperpipe #define GLX_SGIX_hyperpipe 1 - typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int networkId; } GLXHyperpipeNetworkSGIX; - typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int channel; - unsigned int - participationType; + unsigned int participationType; int timeSlice; } GLXHyperpipeConfigSGIX; - typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int srcXOrigin, srcYOrigin, srcWidth, srcHeight; int destXOrigin, destYOrigin, destWidth, destHeight; } GLXPipeRect; - typedef struct { char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; int XOrigin, YOrigin, maxHeight, maxWidth; } GLXPipeRectLimits; +#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 +#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 +#define GLX_BAD_HYPERPIPE_SGIX 92 +#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 +#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 +#define GLX_PIPE_RECT_SGIX 0x00000001 +#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 +#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 +#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 +#define GLX_HYPERPIPE_ID_SGIX 0x8030 +typedef GLXHyperpipeNetworkSGIX *( *PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); +typedef int ( *PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); +typedef GLXHyperpipeConfigSGIX *( *PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); +typedef int ( *PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); +typedef int ( *PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); +typedef int ( *PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); +typedef int ( *PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); +typedef int ( *PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); +#ifdef GL_GLEXT_PROTOTYPES +GLXHyperpipeNetworkSGIX *glXQueryHyperpipeNetworkSGIX (Display *dpy, int *npipes); +int glXHyperpipeConfigSGIX (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); +GLXHyperpipeConfigSGIX *glXQueryHyperpipeConfigSGIX (Display *dpy, int hpId, int *npipes); +int glXDestroyHyperpipeConfigSGIX (Display *dpy, int hpId); +int glXBindHyperpipeSGIX (Display *dpy, int hpId); +int glXQueryHyperpipeBestAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); +int glXHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *attribList); +int glXQueryHyperpipeAttribSGIX (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); +#endif +#endif /* GLX_SGIX_hyperpipe */ +#endif /* NOPE - GLX_SGIX_hyperpipe */ -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *, int *); -extern int glXHyperpipeConfigSGIX (Display *, int, int, GLXHyperpipeConfigSGIX *, int *); -extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *, int, int *); -extern int glXDestroyHyperpipeConfigSGIX (Display *, int); -extern int glXBindHyperpipeSGIX (Display *, int); -extern int glXQueryHyperpipeBestAttribSGIX (Display *, int, int, int, void *, void *); -extern int glXHyperpipeAttribSGIX (Display *, int, int, int, void *); -extern int glXQueryHyperpipeAttribSGIX (Display *, int, int, int, void *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); -typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); -typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); -typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); -typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); -typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); -typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); -#endif +#ifndef GLX_SGIX_pbuffer +#define GLX_SGIX_pbuffer 1 +#define GLX_PBUFFER_BIT_SGIX 0x00000004 +#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 +#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 +#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 +#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 +#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 +#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 +#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 +#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 +#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 +#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 +#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A +#define GLX_PRESERVED_CONTENTS_SGIX 0x801B +#define GLX_LARGEST_PBUFFER_SGIX 0x801C +#define GLX_WIDTH_SGIX 0x801D +#define GLX_HEIGHT_SGIX 0x801E +#define GLX_EVENT_MASK_SGIX 0x801F +#define GLX_DAMAGED_SGIX 0x8020 +#define GLX_SAVED_SGIX 0x8021 +#define GLX_WINDOW_SGIX 0x8022 +#define GLX_PBUFFER_SGIX 0x8023 -#ifndef GLX_MESA_agp_offset -#define GLX_MESA_agp_offset 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern unsigned int glXGetAGPOffsetMESA (const void *); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer); +#ifndef GLX_SGIX_dmbuffer +typedef XID GLXPbufferSGIX; #endif -/* - * GLX_NV_vertex_array_range is not a real extension name... - */ -#ifndef GLX_NV_vertex_array_range -#define GLX_NV_vertex_array_range 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern GLvoid* glXAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -extern void glXFreeMemoryNV (GLvoid *pointer); -#endif /* GLX_GLXEXT_PROTOTYPES */ -typedef GLvoid* ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer); +typedef GLXPbufferSGIX ( *PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); +typedef void ( *PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf); +typedef int ( *PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); +typedef void ( *PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask); +typedef void ( *PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask); +#ifdef GL_GLEXT_PROTOTYPES +GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list); +void glXDestroyGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf); +int glXQueryGLXPbufferSGIX (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value); +void glXSelectEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long mask); +void glXGetSelectedEventSGIX (Display *dpy, GLXDrawable drawable, unsigned long *mask); #endif +#endif /* GLX_SGIX_pbuffer */ -#ifndef GLX_NV_swap_group -#define GLX_NV_swap_group 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern Bool glXJoinSwapGroupNV(Display *dpy, GLXDrawable drawable, - GLuint group); - -extern Bool glXBindSwapBarrierNV(Display *dpy, GLuint group, GLuint barrier); - -extern Bool glXQuerySwapGroupNV(Display *dpy, GLXDrawable drawable, - GLuint *group, GLuint *barrier); - -extern Bool glXQueryMaxSwapGroupsNV(Display *dpy, int screen, - GLuint *maxGroups, GLuint *maxBarriers); - -extern Bool glXQueryFrameCountNV(Display *dpy, int screen, GLuint *count); - -extern Bool glXResetFrameCountNV(Display *dpy, int screen); +#ifndef GLX_SGIX_swap_barrier +#define GLX_SGIX_swap_barrier 1 +typedef void ( *PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); +typedef Bool ( *PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); +#ifdef GL_GLEXT_PROTOTYPES +void glXBindSwapBarrierSGIX (Display *dpy, GLXDrawable drawable, int barrier); +Bool glXQueryMaxSwapBarriersSGIX (Display *dpy, int screen, int *max); #endif -typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display *dpy, - GLXDrawable drawable, - GLuint group); - -typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display *dpy, - GLuint group, - GLuint barrier); - -typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display *dpy, - GLXDrawable drawable, - GLuint *group, - GLuint *barrier); +#endif /* GLX_SGIX_swap_barrier */ -typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display *dpy, - int screen, - GLuint *maxGroups, - GLuint *maxBarriers); - -typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display *dpy, - int screen, - GLuint *count); - -typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display *dpy, int screen); +#ifndef GLX_SGIX_swap_group +#define GLX_SGIX_swap_group 1 +typedef void ( *PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); +#ifdef GL_GLEXT_PROTOTYPES +void glXJoinSwapGroupSGIX (Display *dpy, GLXDrawable drawable, GLXDrawable member); #endif +#endif /* GLX_SGIX_swap_group */ -#ifndef GLX_NV_video_out -#define GLX_NV_video_out 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern int glXGetVideoDeviceNV(Display *dpy, int screen, int numVideoDevices, - GLXVideoDeviceNV *pVideoDevice); - -extern int glXReleaseVideoDeviceNV(Display *dpy, int screen, - GLXVideoDeviceNV VideoDevice); - -extern int glXBindVideoImageNV(Display *dpy, GLXVideoDeviceNV VideoDevice, - GLXPbuffer pbuf, int iVideoBuffer); - -extern int glXReleaseVideoImageNV(Display *dpy, GLXPbuffer pbuf); - -extern int glXSendPbufferToVideoNV(Display *dpy, GLXPbuffer pbuf, - int iBufferType, - unsigned long *pulCounterPbuffer, - GLboolean bBlock); - -extern int glXGetVideoInfoNV(Display *dpy, int screen, - GLXVideoDeviceNV VideoDevice, - unsigned long *pulCounterOutputPbuffer, - unsigned long *pulCounterOutputVideo); +#ifndef GLX_SGIX_video_resize +#define GLX_SGIX_video_resize 1 +#define GLX_SYNC_FRAME_SGIX 0x00000000 +#define GLX_SYNC_SWAP_SGIX 0x00000001 +typedef int ( *PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window); +typedef int ( *PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h); +typedef int ( *PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); +typedef int ( *PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); +typedef int ( *PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype); +#ifdef GL_GLEXT_PROTOTYPES +int glXBindChannelToWindowSGIX (Display *display, int screen, int channel, Window window); +int glXChannelRectSGIX (Display *display, int screen, int channel, int x, int y, int w, int h); +int glXQueryChannelRectSGIX (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); +int glXQueryChannelDeltasSGIX (Display *display, int screen, int channel, int *x, int *y, int *w, int *h); +int glXChannelRectSyncSGIX (Display *display, int screen, int channel, GLenum synctype); +#endif +#endif /* GLX_SGIX_video_resize */ + +#if 0 /* Disabled: VLServer and VLPath and VLNode undefined */ +#ifndef GLX_SGIX_video_source +#define GLX_SGIX_video_source 1 +typedef XID GLXVideoSourceSGIX; +typedef GLXVideoSourceSGIX ( *PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); +typedef void ( *PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource); +#ifdef GL_GLEXT_PROTOTYPES +GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode); +void glXDestroyGLXVideoSourceSGIX (Display *dpy, GLXVideoSourceSGIX glxvideosource); #endif -typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display *dpy, - int screen, - int numVideoDevices, - GLXVideoDeviceNV *pVideoDevice); - -typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display *dpy, - int screen, - GLXVideoDeviceNV VideoDevice); - -typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display *dpy, - GLXVideoDeviceNV VideoDevice, - GLXPbuffer pbuf, - int iVideoBuffer); - -typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display *dpy, - GLXPbuffer pbuf); - -typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display *dpy, - GLXPbuffer pbuf, - int iBufferType, - unsigned long *pulCounterPbuffer, - GLboolean bBlock); - -typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display *dpy, int screen, - GLXVideoDeviceNV VideoDevice, - unsigned long *pulCounterOutputPbuffer, - unsigned long *pulCounterOutputVideo); +#endif /* GLX_SGIX_video_source */ #endif -#ifndef GLX_EXT_fbconfig_packed_float -#define GLX_EXT_fbconfig_packed_float 1 +#ifndef GLX_SGIX_visual_select_group +#define GLX_SGIX_visual_select_group 1 +#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 +#endif /* GLX_SGIX_visual_select_group */ + +#ifndef GLX_SGI_cushion +#define GLX_SGI_cushion 1 +typedef void ( *PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion); +#ifdef GL_GLEXT_PROTOTYPES +void glXCushionSGI (Display *dpy, Window window, float cushion); #endif +#endif /* GLX_SGI_cushion */ -#ifndef GLX_EXT_framebuffer_sRGB -#define GLX_EXT_framebuffer_sRGB 1 +#ifndef GLX_SGI_make_current_read +#define GLX_SGI_make_current_read 1 +typedef Bool ( *PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef GLXDrawable ( *PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +Bool glXMakeCurrentReadSGI (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +GLXDrawable glXGetCurrentReadDrawableSGI (void); #endif +#endif /* GLX_SGI_make_current_read */ -#ifndef GLX_EXT_texture_from_pixmap -#define GLX_EXT_texture_from_pixmap -#ifdef GLX_GLXEXT_PROTOTYPES -extern void glXBindTexImageEXT(Display *dpy, GLXDrawable drawable, - int buffer, const int *attrib_list); -extern void glXReleaseTexImageEXT(Display *dpy, GLXDrawable drawable, - int buffer); -#endif -typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display *dpy, - GLXDrawable drawable, - int buffer, - const int *attrib_list); -typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display *dpy, - GLXDrawable drawable, - int buffer); +#ifndef GLX_SGI_swap_control +#define GLX_SGI_swap_control 1 +typedef int ( *PFNGLXSWAPINTERVALSGIPROC) (int interval); +#ifdef GL_GLEXT_PROTOTYPES +int glXSwapIntervalSGI (int interval); #endif +#endif /* GLX_SGI_swap_control */ -#ifndef GLX_NV_present_video -#define GLX_NV_present_video 1 -#ifdef GLX_GLXEXT_PROTOTYPES -extern unsigned int* glXEnumerateVideoDevicesNV(Display *dpy, - int screen, - int *nelements); -extern int glXBindVideoDeviceNV(Display *dpy, - unsigned int video_slot, - unsigned int video_device, - const int *attrib_list); -#endif -typedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, - int screen, - int *nelements); -typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display *dpy, - unsigned int video_slot, - unsigned int video_device, - const int *attrib_list); +#ifndef GLX_SGI_video_sync +#define GLX_SGI_video_sync 1 +typedef int ( *PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count); +typedef int ( *PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count); +#ifdef GL_GLEXT_PROTOTYPES +int glXGetVideoSyncSGI (unsigned int *count); +int glXWaitVideoSyncSGI (int divisor, int remainder, unsigned int *count); #endif +#endif /* GLX_SGI_video_sync */ -#ifndef GLX_NV_multisample_coverage -#define GLX_NV_multisample_coverage 1 +#ifndef GLX_SUN_get_transparent_index +#define GLX_SUN_get_transparent_index 1 +typedef Status ( *PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); +#ifdef GL_GLEXT_PROTOTYPES +Status glXGetTransparentIndexSUN (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex); #endif +#endif /* GLX_SUN_get_transparent_index */ #ifdef __cplusplus } #endif -#endif // __glxext_h_ +#endif diff --git a/make/stub_includes/opengl/GL/wglext.h b/make/stub_includes/opengl/GL/wglext.h index a34c63c43..ed5d6a7db 100644 --- a/make/stub_includes/opengl/GL/wglext.h +++ b/make/stub_includes/opengl/GL/wglext.h @@ -1,47 +1,39 @@ #ifndef __wglext_h_ -#define __wglext_h_ +#define __wglext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** NOTE: The Original Code (as defined below) has been licensed to Sun -** Microsystems, Inc. ("Sun") under the SGI Free Software License B -** (Version 1.1), shown above ("SGI License"). Pursuant to Section -** 3.2(3) of the SGI License, Sun is distributing the Covered Code to -** you under an alternative license ("Alternative License"). This -** Alternative License includes all of the provisions of the SGI License -** except that Section 2.2 and 11 are omitted. Any differences between -** the Alternative License and the SGI License are offered solely by Sun -** and not by SGI. +** Copyright (c) 2013 The Khronos Group Inc. ** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision$ on $Date$ */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) @@ -49,591 +41,505 @@ extern "C" { #include #endif -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number */ -/* wglext.h last updated 2006/08/17 */ -/* Current version at http://www.opengl.org/registry/ */ -#define WGL_WGLEXT_VERSION 8 - -#ifndef WGL_ARB_buffer_region -#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 -#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 -#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 -#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 -#endif - -#ifndef WGL_ARB_multisample -#define WGL_SAMPLE_BUFFERS_ARB 0x2041 -#define WGL_SAMPLES_ARB 0x2042 -#endif - -#ifndef WGL_ARB_extensions_string -#endif - -#ifndef WGL_ARB_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 -#define WGL_DRAW_TO_WINDOW_ARB 0x2001 -#define WGL_DRAW_TO_BITMAP_ARB 0x2002 -#define WGL_ACCELERATION_ARB 0x2003 -#define WGL_NEED_PALETTE_ARB 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 -#define WGL_SWAP_METHOD_ARB 0x2007 -#define WGL_NUMBER_OVERLAYS_ARB 0x2008 -#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 -#define WGL_TRANSPARENT_ARB 0x200A -#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 -#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 -#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 -#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A -#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B -#define WGL_SHARE_DEPTH_ARB 0x200C -#define WGL_SHARE_STENCIL_ARB 0x200D -#define WGL_SHARE_ACCUM_ARB 0x200E -#define WGL_SUPPORT_GDI_ARB 0x200F -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_STEREO_ARB 0x2012 -#define WGL_PIXEL_TYPE_ARB 0x2013 -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_RED_SHIFT_ARB 0x2016 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_GREEN_SHIFT_ARB 0x2018 -#define WGL_BLUE_BITS_ARB 0x2019 -#define WGL_BLUE_SHIFT_ARB 0x201A -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_ALPHA_SHIFT_ARB 0x201C -#define WGL_ACCUM_BITS_ARB 0x201D -#define WGL_ACCUM_RED_BITS_ARB 0x201E -#define WGL_ACCUM_GREEN_BITS_ARB 0x201F -#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 -#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 -#define WGL_AUX_BUFFERS_ARB 0x2024 -#define WGL_NO_ACCELERATION_ARB 0x2025 -#define WGL_GENERIC_ACCELERATION_ARB 0x2026 -#define WGL_FULL_ACCELERATION_ARB 0x2027 -#define WGL_SWAP_EXCHANGE_ARB 0x2028 -#define WGL_SWAP_COPY_ARB 0x2029 -#define WGL_SWAP_UNDEFINED_ARB 0x202A -#define WGL_TYPE_RGBA_ARB 0x202B -#define WGL_TYPE_COLORINDEX_ARB 0x202C -#endif - -#ifndef WGL_ARB_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 -#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 -#endif - -#ifndef WGL_ARB_pbuffer -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E -#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 -#define WGL_PBUFFER_LARGEST_ARB 0x2033 -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_PBUFFER_LOST_ARB 0x2036 -#endif - -#ifndef WGL_ARB_render_texture -#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_MIPMAP_TEXTURE_ARB 0x2074 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_NO_TEXTURE_ARB 0x2077 -#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 -#define WGL_TEXTURE_1D_ARB 0x2079 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_MIPMAP_LEVEL_ARB 0x207B -#define WGL_CUBE_MAP_FACE_ARB 0x207C -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 -#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 -#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 -#define WGL_FRONT_LEFT_ARB 0x2083 -#define WGL_FRONT_RIGHT_ARB 0x2084 -#define WGL_BACK_LEFT_ARB 0x2085 -#define WGL_BACK_RIGHT_ARB 0x2086 -#define WGL_AUX0_ARB 0x2087 -#define WGL_AUX1_ARB 0x2088 -#define WGL_AUX2_ARB 0x2089 -#define WGL_AUX3_ARB 0x208A -#define WGL_AUX4_ARB 0x208B -#define WGL_AUX5_ARB 0x208C -#define WGL_AUX6_ARB 0x208D -#define WGL_AUX7_ARB 0x208E -#define WGL_AUX8_ARB 0x208F -#define WGL_AUX9_ARB 0x2090 -#endif +#define WGL_WGLEXT_VERSION 20130614 -#ifndef WGL_ARB_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 -#endif - -#ifndef WGL_ARB_create_context -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#endif - -#ifndef WGL_ARB_create_context_robustness -#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 -#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#endif - -#ifndef WGL_EXT_create_context_es2_profile -#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 -#endif - -#ifndef WGL_EXT_make_current_read -#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 -#endif - -#ifndef WGL_EXT_pixel_format -#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 -#define WGL_DRAW_TO_WINDOW_EXT 0x2001 -#define WGL_DRAW_TO_BITMAP_EXT 0x2002 -#define WGL_ACCELERATION_EXT 0x2003 -#define WGL_NEED_PALETTE_EXT 0x2004 -#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 -#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 -#define WGL_SWAP_METHOD_EXT 0x2007 -#define WGL_NUMBER_OVERLAYS_EXT 0x2008 -#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 -#define WGL_TRANSPARENT_EXT 0x200A -#define WGL_TRANSPARENT_VALUE_EXT 0x200B -#define WGL_SHARE_DEPTH_EXT 0x200C -#define WGL_SHARE_STENCIL_EXT 0x200D -#define WGL_SHARE_ACCUM_EXT 0x200E -#define WGL_SUPPORT_GDI_EXT 0x200F -#define WGL_SUPPORT_OPENGL_EXT 0x2010 -#define WGL_DOUBLE_BUFFER_EXT 0x2011 -#define WGL_STEREO_EXT 0x2012 -#define WGL_PIXEL_TYPE_EXT 0x2013 -#define WGL_COLOR_BITS_EXT 0x2014 -#define WGL_RED_BITS_EXT 0x2015 -#define WGL_RED_SHIFT_EXT 0x2016 -#define WGL_GREEN_BITS_EXT 0x2017 -#define WGL_GREEN_SHIFT_EXT 0x2018 -#define WGL_BLUE_BITS_EXT 0x2019 -#define WGL_BLUE_SHIFT_EXT 0x201A -#define WGL_ALPHA_BITS_EXT 0x201B -#define WGL_ALPHA_SHIFT_EXT 0x201C -#define WGL_ACCUM_BITS_EXT 0x201D -#define WGL_ACCUM_RED_BITS_EXT 0x201E -#define WGL_ACCUM_GREEN_BITS_EXT 0x201F -#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 -#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 -#define WGL_DEPTH_BITS_EXT 0x2022 -#define WGL_STENCIL_BITS_EXT 0x2023 -#define WGL_AUX_BUFFERS_EXT 0x2024 -#define WGL_NO_ACCELERATION_EXT 0x2025 -#define WGL_GENERIC_ACCELERATION_EXT 0x2026 -#define WGL_FULL_ACCELERATION_EXT 0x2027 -#define WGL_SWAP_EXCHANGE_EXT 0x2028 -#define WGL_SWAP_COPY_EXT 0x2029 -#define WGL_SWAP_UNDEFINED_EXT 0x202A -#define WGL_TYPE_RGBA_EXT 0x202B -#define WGL_TYPE_COLORINDEX_EXT 0x202C -#endif - -#ifndef WGL_EXT_pbuffer -#define WGL_DRAW_TO_PBUFFER_EXT 0x202D -#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E -#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F -#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 -#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 -#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 -#define WGL_PBUFFER_LARGEST_EXT 0x2033 -#define WGL_PBUFFER_WIDTH_EXT 0x2034 -#define WGL_PBUFFER_HEIGHT_EXT 0x2035 -#endif - -#ifndef WGL_EXT_depth_float -#define WGL_DEPTH_FLOAT_EXT 0x2040 -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 -#define WGL_SAMPLES_3DFX 0x2061 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_SAMPLE_BUFFERS_EXT 0x2041 -#define WGL_SAMPLES_EXT 0x2042 -#endif - -#ifndef WGL_I3D_digital_video_control -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 -#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 -#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 -#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 -#endif - -#ifndef WGL_I3D_gamma -#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E -#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F -#endif - -#ifndef WGL_I3D_genlock -#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 -#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 -#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 -#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 -#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 -#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 -#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A -#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B -#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C -#endif - -#ifndef WGL_I3D_image_buffer -#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 -#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 -#endif - -#ifndef WGL_I3D_swap_frame_lock -#endif - -#ifndef WGL_NV_render_depth_texture -#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 -#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 -#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 -#define WGL_DEPTH_COMPONENT_NV 0x20A7 -#endif - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 -#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 -#define WGL_RGBA_FLOAT_MODE_ATI 0x8820 -#define WGL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef WGL_NV_float_buffer -#define WGL_FLOAT_COMPONENTS_NV 0x20B0 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 -#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 -#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 -#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 -#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 -#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 -#endif - -#ifndef WGL_3DL_stereo_control -#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 -#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 -#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 -#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 -#endif - -#ifndef WGL_NV_swap_group -#endif - -#ifndef WGL_NV_gpu_affinity -#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 -#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 -#endif - -/*************************************************************/ - -/* NOTE: following DECLARE_HANDLE macros have to be elided (PCPP - doesn't support them); effects placed in stub_includes/win32/windows.h */ -#ifndef SKIP_WGL_HANDLE_DEFINITIONS -#ifndef WGL_ARB_pbuffer -DECLARE_HANDLE(HPBUFFERARB); -#endif -#ifndef WGL_EXT_pbuffer -DECLARE_HANDLE(HPBUFFEREXT); -#endif -#endif /* !SKIP_WGL_HANDLE_DEFINITIONS */ - -#ifndef WGL_NV_gpu_affinity -#ifndef SKIP_WGL_HANDLE_DEFINITIONS -DECLARE_HANDLE(HGPUNV); -#endif /* !SKIP_WGL_HANDLE_DEFINITIONS */ -typedef struct _GPU_DEVICE { - DWORD cb; - CHAR DeviceName[32]; - CHAR DeviceString[128]; - DWORD Flags; - RECT rcVirtualScreen; -} GPU_DEVICE, *PGPU_DEVICE; -#endif +/* Generated C header for: + * API: wgl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: wgl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ #ifndef WGL_ARB_buffer_region #define WGL_ARB_buffer_region 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT); -extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE); -extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int); -extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +#ifdef GL_GLEXT_PROTOTYPES +HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); +VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); +BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); +BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); #endif +#endif /* WGL_ARB_buffer_region */ -#ifndef WGL_ARB_multisample -#define WGL_ARB_multisample 1 -#endif +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); +#ifdef GL_GLEXT_PROTOTYPES +HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); +#endif +#endif /* WGL_ARB_create_context */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif /* WGL_ARB_create_context_profile */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif /* WGL_ARB_create_context_robustness */ #ifndef WGL_ARB_extensions_string #define WGL_ARB_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringARB (HDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); +#ifdef GL_GLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringARB (HDC hdc); #endif +#endif /* WGL_ARB_extensions_string */ -#ifndef WGL_ARB_pixel_format -#define WGL_ARB_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -#endif +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif /* WGL_ARB_framebuffer_sRGB */ #ifndef WGL_ARB_make_current_read #define WGL_ARB_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCARB (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCARB (void); #endif +#endif /* WGL_ARB_make_current_read */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif /* WGL_ARB_multisample */ #ifndef WGL_ARB_pbuffer #define WGL_ARB_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB); -extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC); -extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB); -extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HPBUFFERARB); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#ifdef GL_GLEXT_PROTOTYPES +HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); +int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); +BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); +#endif +#endif /* WGL_ARB_pbuffer */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); #endif +#endif /* WGL_ARB_pixel_format */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif /* WGL_ARB_pixel_format_float */ #ifndef WGL_ARB_render_texture #define WGL_ARB_render_texture 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int); -extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); +BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); #endif +#endif /* WGL_ARB_render_texture */ -#ifndef WGL_ARB_pixel_format_float -#define WGL_ARB_pixel_format_float 1 -#endif +#ifndef WGL_ARB_robustness_application_isolation +#define WGL_ARB_robustness_application_isolation 1 +#define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 +#endif /* WGL_ARB_robustness_application_isolation */ -#ifndef WGL_ARB_create_context -#define WGL_ARB_create_context 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HGLRC WINAPI wglCreateContextAttribsARB(HDC hDC, HGLRC hshareContext, const int *attribList); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hshareContext, const int *attribList); -#endif +#ifndef WGL_ARB_robustness_share_group_isolation +#define WGL_ARB_robustness_share_group_isolation 1 +#endif /* WGL_ARB_robustness_share_group_isolation */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 +#endif /* WGL_3DFX_multisample */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); +#endif +#endif /* WGL_3DL_stereo_control */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); +INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); +UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); +HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); +HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); +BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); +BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); +HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); +VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* WGL_AMD_gpu_association */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#endif /* WGL_ATI_pixel_format_float */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es2_profile */ + +#ifndef WGL_EXT_create_context_es_profile +#define WGL_EXT_create_context_es_profile 1 +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif /* WGL_EXT_create_context_es_profile */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 +#define WGL_DEPTH_FLOAT_EXT 0x2040 +#endif /* WGL_EXT_depth_float */ #ifndef WGL_EXT_display_color_table #define WGL_EXT_display_color_table 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort); -extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint); -extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort); -extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +#ifdef GL_GLEXT_PROTOTYPES +GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); +GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); +GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); +VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); #endif +#endif /* WGL_EXT_display_color_table */ #ifndef WGL_EXT_extensions_string #define WGL_EXT_extensions_string 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern const char * WINAPI wglGetExtensionsStringEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +const char *WINAPI wglGetExtensionsStringEXT (void); #endif +#endif /* WGL_EXT_extensions_string */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 +#endif /* WGL_EXT_framebuffer_sRGB */ #ifndef WGL_EXT_make_current_read #define WGL_EXT_make_current_read 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC); -extern HDC WINAPI wglGetCurrentReadDCEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); +HDC WINAPI wglGetCurrentReadDCEXT (void); #endif +#endif /* WGL_EXT_make_current_read */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#endif /* WGL_EXT_multisample */ #ifndef WGL_EXT_pbuffer #define WGL_EXT_pbuffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *); -extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT); -extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC); -extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT); -extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HPBUFFEREXT); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); +#ifdef GL_GLEXT_PROTOTYPES +HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); +HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); +int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); +BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); +BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); #endif +#endif /* WGL_EXT_pbuffer */ #ifndef WGL_EXT_pixel_format #define WGL_EXT_pixel_format 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *); -extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *); -extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); +BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); +BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); #endif +#endif /* WGL_EXT_pixel_format */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 +#endif /* WGL_EXT_pixel_format_packed_float */ #ifndef WGL_EXT_swap_control #define WGL_EXT_swap_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglSwapIntervalEXT (int); -extern int WINAPI wglGetSwapIntervalEXT (void); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglSwapIntervalEXT (int interval); +int WINAPI wglGetSwapIntervalEXT (void); #endif +#endif /* WGL_EXT_swap_control */ -#ifndef WGL_EXT_depth_float -#define WGL_EXT_depth_float 1 -#endif - -#ifndef WGL_NV_vertex_array_range -#define WGL_NV_vertex_array_range 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat); -extern void WINAPI wglFreeMemoryNV (void *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); -typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); -#endif - -#ifndef WGL_3DFX_multisample -#define WGL_3DFX_multisample 1 -#endif - -#ifndef WGL_EXT_multisample -#define WGL_EXT_multisample 1 -#endif - -#ifndef WGL_OML_sync_control -#define WGL_OML_sync_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *); -extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64); -extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64); -extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *); -extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); -typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); -typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); -typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); -#endif +#ifndef WGL_EXT_swap_control_tear +#define WGL_EXT_swap_control_tear 1 +#endif /* WGL_EXT_swap_control_tear */ #ifndef WGL_I3D_digital_video_control #define WGL_I3D_digital_video_control 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); #endif +#endif /* WGL_I3D_digital_video_control */ #ifndef WGL_I3D_gamma #define WGL_I3D_gamma 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *); -extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *); -extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *); -extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); +BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); +BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); +BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); #endif +#endif /* WGL_I3D_gamma */ #ifndef WGL_I3D_genlock #define WGL_I3D_genlock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableGenlockI3D (HDC); -extern BOOL WINAPI wglDisableGenlockI3D (HDC); -extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *); -extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *); -extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT); -extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *); -extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); @@ -646,108 +552,283 @@ typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate) typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); -#endif +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglEnableGenlockI3D (HDC hDC); +BOOL WINAPI wglDisableGenlockI3D (HDC hDC); +BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); +BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); +BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); +BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); +BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); +BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); +BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); +BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); +BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); +BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); +#endif +#endif /* WGL_I3D_genlock */ #ifndef WGL_I3D_image_buffer #define WGL_I3D_image_buffer 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT); -extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID); -extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT); -extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT); -#endif /* WGL_WGLEXT_PROTOTYPES */ +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); +#ifdef GL_GLEXT_PROTOTYPES +LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); +BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); +BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); +BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); #endif +#endif /* WGL_I3D_image_buffer */ #ifndef WGL_I3D_swap_frame_lock #define WGL_I3D_swap_frame_lock 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnableFrameLockI3D (void); -extern BOOL WINAPI wglDisableFrameLockI3D (void); -extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *); -extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglEnableFrameLockI3D (void); +BOOL WINAPI wglDisableFrameLockI3D (void); +BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); +BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); #endif +#endif /* WGL_I3D_swap_frame_lock */ #ifndef WGL_I3D_swap_frame_usage #define WGL_I3D_swap_frame_usage 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglGetFrameUsageI3D (float *); -extern BOOL WINAPI wglBeginFrameTrackingI3D (void); -extern BOOL WINAPI wglEndFrameTrackingI3D (void); -extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); -#endif - -#ifndef WGL_ATI_pixel_format_float -#define WGL_ATI_pixel_format_float 1 -#endif +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); +BOOL WINAPI wglBeginFrameTrackingI3D (void); +BOOL WINAPI wglEndFrameTrackingI3D (void); +BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); +#endif +#endif /* WGL_I3D_swap_frame_usage */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 +#define WGL_ACCESS_READ_ONLY_NV 0x00000000 +#define WGL_ACCESS_READ_WRITE_NV 0x00000001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); +HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); +BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); +HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); +BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); +BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); +BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); +#endif +#endif /* WGL_NV_DX_interop */ + +#ifndef WGL_NV_DX_interop2 +#define WGL_NV_DX_interop2 1 +#endif /* WGL_NV_DX_interop2 */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* WGL_NV_copy_image */ #ifndef WGL_NV_float_buffer #define WGL_NV_float_buffer 1 -#endif +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 +#endif /* WGL_NV_float_buffer */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HGPUNV); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +}; +typedef struct _GPU_DEVICE *PGPU_DEVICE; +#define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); +BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); +BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +BOOL WINAPI wglDeleteDCNV (HDC hdc); +#endif +#endif /* WGL_NV_gpu_affinity */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 +#endif /* WGL_NV_multisample_coverage */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); +#ifdef GL_GLEXT_PROTOTYPES +int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); +BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); +BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); +#endif +#endif /* WGL_NV_present_video */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 +#endif /* WGL_NV_render_depth_texture */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 +#endif /* WGL_NV_render_texture_rectangle */ #ifndef WGL_NV_swap_group #define WGL_NV_swap_group 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglJoinSwapGroupNV(HDC hDC, GLuint group); -extern BOOL WINAPI wglBindSwapBarrierNV(GLuint group, GLuint barrier); -extern BOOL WINAPI wglQuerySwapGroupNV(HDC hDC, GLuint *group, GLuint *barrier); -extern BOOL WINAPI wglQueryMaxSwapGroupsNV(HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); -extern BOOL WINAPI wglQueryFrameCountNV(HDC hDC, GLuint *count); -extern BOOL WINAPI wglResetFrameCountNV(HDC hDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); +BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); +BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); +BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); +BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); +BOOL WINAPI wglResetFrameCountNV (HDC hDC); #endif +#endif /* WGL_NV_swap_group */ -#ifndef WGL_NV_gpu_affinity -#define WGL_NV_gpu_affinity 1 -#ifdef WGL_WGLEXT_PROTOTYPES -extern BOOL WINAPI wglEnumGpusNV (UINT iIndex, HGPUNV *hGpu); -extern BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iIndex, PGPU_DEVICE pGpuDevice); -extern HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *pGpuList); -extern BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iIndex, HGPUNV *hGpu); -extern BOOL WINAPI wglDeleteDCNV (HDC hAffinityDC); -#endif /* WGL_WGLEXT_PROTOTYPES */ -typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iIndex, PGPU_DEVICE pGpuDevice); -typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *pGpuList); -typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iIndex, HGPUNV *hGpu); -typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hAffinityDC); -#endif - -/* - * ----------------------------------------------------------- - * Everything here and below was added manually - * by ckline and kbr to the version of wglext.h obtained from: - * http://oss.sgi.com/projects/ogl-sample/registry/index.html - * ----------------------------------------------------------- - */ - -#ifndef WGL_NV_render_texture_rectangle -#define WGL_NV_render_texture_rectangle 1 +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 +typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +void WINAPI wglFreeMemoryNV (void *pointer); #endif +#endif /* WGL_NV_vertex_array_range */ -#ifndef WGL_NV_render_depth_texture -#define WGL_NV_render_depth_texture 1 -#endif +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); +BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); +BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +#endif +#endif /* WGL_NV_video_capture */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 +#ifndef SKIP_WGL_HANDLE_DEFINITIONS +DECLARE_HANDLE(HPVIDEODEV); +#endif /* SKIP_WGL_HANDLE_DEFINITIONS */ +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); +BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); +BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); +BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); +BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +#endif +#endif /* WGL_NV_video_output */ +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#ifdef GL_GLEXT_PROTOTYPES +BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); +INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); +BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); +#endif +#endif /* WGL_OML_sync_control */ #ifdef __cplusplus } diff --git a/make/stub_includes/opengl/GL3/gl3.h b/make/stub_includes/opengl/GL3/gl3.h deleted file mode 100644 index d66d49d91..000000000 --- a/make/stub_includes/opengl/GL3/gl3.h +++ /dev/null @@ -1,3606 +0,0 @@ -#ifndef __gl3_h_ -#define __gl3_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2012 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* This is a draft release of gl3.h, a header for use with OpenGL 3.1, and - * 3.2 and later core profile implementations. The current version is - * available at http://www.opengl.org/registry/ . Please don't package - * gl3.h for release with other software until it's out of draft status. - * The structure of the file may change significantly, and the details - * will probably change slightly as we make sure exactly the right set - * of interfaces is included. - * - * gl3.h last updated on $Date: 2012-01-26 02:57:23 -0800 (Thu, 26 Jan 2012) $ - * - * RELEASE NOTES - 2012/01/26 - * - * gl3.h should be placed under a directory 'GL3' and included as - * ''. - * - * gl3.h is supposed to only include APIs in a OpenGL 3.1 (without - * GL_ARB_compatibility) or OpenGL 3.2-4.2 (inclusive) core profile - * implementation, as well as interfaces for newer ARB extensions which - * can be supported by the core profile. It does not, and never will - * include functionality removed from the core profile, such as - * fixed-function vertex and fragment processing. - * - * Implementations of OpenGL 3.1 supporting the optional - * GL_ARB_compatibility extension continue to provide that functionality, - * as do implementations of the OpenGL 3.2+ compatibility profiles, and - * source code requiring it should use the traditional and - * headers instead of . - * - * It is not possible to #include both and either of - * or in the same source file. - * - * We welcome feedback on gl3.h. Please register for the Khronos Bugzilla - * (www.khronos.org/bugzilla) and file issues there under product - * "OpenGL", category "Registry". Feedback on the opengl.org forums - * may not be responded to in a timely fashion. - */ - -/* Function declaration macros - to move into glplatform.h */ -#include "glplatform.h" - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/* Base GL types */ - -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef signed char GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef unsigned char GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef unsigned short GLhalf; -typedef float GLfloat; -typedef float GLclampf; -typedef double GLdouble; -typedef double GLclampd; -typedef void GLvoid; - -/*************************************************************/ - -#ifndef GL_VERSION_1_1 -/* AttribMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 -/* AlphaFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 -/* BlendingFactorSrc */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* DrawBufferMode */ -#define GL_NONE 0 -#define GL_FRONT_LEFT 0x0400 -#define GL_FRONT_RIGHT 0x0401 -#define GL_BACK_LEFT 0x0402 -#define GL_BACK_RIGHT 0x0403 -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_LEFT 0x0406 -#define GL_RIGHT 0x0407 -#define GL_FRONT_AND_BACK 0x0408 -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 -/* GetPName */ -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_RANGE 0x0B12 -#define GL_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_LINE_WIDTH 0x0B21 -#define GL_LINE_WIDTH_RANGE 0x0B22 -#define GL_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_POLYGON_SMOOTH 0x0B41 -#define GL_CULL_FACE 0x0B44 -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_TEST 0x0B71 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_TEST 0x0B90 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_VIEWPORT 0x0BA2 -#define GL_DITHER 0x0BD0 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_BLEND 0x0BE2 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_DRAW_BUFFER 0x0C01 -#define GL_READ_BUFFER 0x0C02 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_DOUBLEBUFFER 0x0C32 -#define GL_STEREO 0x0C33 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_POLYGON_SMOOTH_HINT 0x0C53 -#define GL_UNPACK_SWAP_BYTES 0x0CF0 -#define GL_UNPACK_LSB_FIRST 0x0CF1 -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_SWAP_BYTES 0x0D00 -#define GL_PACK_LSB_FIRST 0x0D01 -#define GL_PACK_ROW_LENGTH 0x0D02 -#define GL_PACK_SKIP_ROWS 0x0D03 -#define GL_PACK_SKIP_PIXELS 0x0D04 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_TEXTURE_1D 0x0DE0 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_POINT 0x2A01 -#define GL_POLYGON_OFFSET_LINE 0x2A02 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_1D 0x8068 -#define GL_TEXTURE_BINDING_2D 0x8069 -/* GetTextureParameter */ -#define GL_TEXTURE_WIDTH 0x1000 -#define GL_TEXTURE_HEIGHT 0x1001 -#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 -#define GL_TEXTURE_BORDER_COLOR 0x1004 -#define GL_TEXTURE_RED_SIZE 0x805C -#define GL_TEXTURE_GREEN_SIZE 0x805D -#define GL_TEXTURE_BLUE_SIZE 0x805E -#define GL_TEXTURE_ALPHA_SIZE 0x805F -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_DOUBLE 0x140A -/* LogicOp */ -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F -/* MatrixMode (for gl3.h, FBO attachment type) */ -#define GL_TEXTURE 0x1702 -/* PixelCopyType */ -#define GL_COLOR 0x1800 -#define GL_DEPTH 0x1801 -#define GL_STENCIL 0x1802 -/* PixelFormat */ -#define GL_STENCIL_INDEX 0x1901 -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_RED 0x1903 -#define GL_GREEN 0x1904 -#define GL_BLUE 0x1905 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -/* PolygonMode */ -#define GL_POINT 0x1B00 -#define GL_LINE 0x1B01 -#define GL_FILL 0x1B02 -/* StencilOp */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 -/* TextureMinFilter */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -/* TextureTarget */ -#define GL_PROXY_TEXTURE_1D 0x8063 -#define GL_PROXY_TEXTURE_2D 0x8064 -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -/* PixelInternalFormat */ -#define GL_R3_G3_B2 0x2A10 -#define GL_RGB4 0x804F -#define GL_RGB5 0x8050 -#define GL_RGB8 0x8051 -#define GL_RGB10 0x8052 -#define GL_RGB12 0x8053 -#define GL_RGB16 0x8054 -#define GL_RGBA2 0x8055 -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGBA8 0x8058 -#define GL_RGB10_A2 0x8059 -#define GL_RGBA12 0x805A -#define GL_RGBA16 0x805B -#endif - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_VERSION_2_1 -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#endif - -#ifndef GL_VERSION_3_0 -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_CLIP_DISTANCE0 0x3000 -#define GL_CLIP_DISTANCE1 0x3001 -#define GL_CLIP_DISTANCE2 0x3002 -#define GL_CLIP_DISTANCE3 0x3003 -#define GL_CLIP_DISTANCE4 0x3004 -#define GL_CLIP_DISTANCE5 0x3005 -#define GL_CLIP_DISTANCE6 0x3006 -#define GL_CLIP_DISTANCE7 0x3007 -#define GL_MAX_CLIP_DISTANCES 0x0D32 -#define GL_MAJOR_VERSION 0x821B -#define GL_MINOR_VERSION 0x821C -#define GL_NUM_EXTENSIONS 0x821D -#define GL_CONTEXT_FLAGS 0x821E -#define GL_DEPTH_BUFFER 0x8223 // n/a in spec, but other header files -#define GL_STENCIL_BUFFER 0x8224 // n/a in spec, but other header files -#define GL_COMPRESSED_RED 0x8225 -#define GL_COMPRESSED_RG 0x8226 -#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 -#define GL_RGBA32F 0x8814 -#define GL_RGB32F 0x8815 -#define GL_RGBA16F 0x881A -#define GL_RGB16F 0x881B -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD -#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF -#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 -#define GL_CLAMP_READ_COLOR 0x891C -#define GL_FIXED_ONLY 0x891D -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#define GL_TEXTURE_1D_ARRAY 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 -#define GL_TEXTURE_2D_ARRAY 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D -#define GL_R11F_G11F_B10F 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B -#define GL_RGB9_E5 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E -#define GL_TEXTURE_SHARED_SIZE 0x8C3F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 -#define GL_PRIMITIVES_GENERATED 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 -#define GL_RASTERIZER_DISCARD 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B -#define GL_INTERLEAVED_ATTRIBS 0x8C8C -#define GL_SEPARATE_ATTRIBS 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F -#define GL_RGBA32UI 0x8D70 -#define GL_RGB32UI 0x8D71 -#define GL_RGBA16UI 0x8D76 -#define GL_RGB16UI 0x8D77 -#define GL_RGBA8UI 0x8D7C -#define GL_RGB8UI 0x8D7D -#define GL_RGBA32I 0x8D82 -#define GL_RGB32I 0x8D83 -#define GL_RGBA16I 0x8D88 -#define GL_RGB16I 0x8D89 -#define GL_RGBA8I 0x8D8E -#define GL_RGB8I 0x8D8F -#define GL_RED_INTEGER 0x8D94 -#define GL_GREEN_INTEGER 0x8D95 -#define GL_BLUE_INTEGER 0x8D96 -#define GL_RGB_INTEGER 0x8D98 -#define GL_RGBA_INTEGER 0x8D99 -#define GL_BGR_INTEGER 0x8D9A -#define GL_BGRA_INTEGER 0x8D9B -#define GL_SAMPLER_1D_ARRAY 0x8DC0 -#define GL_SAMPLER_2D_ARRAY 0x8DC1 -#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 -#define GL_UNSIGNED_INT_VEC2 0x8DC6 -#define GL_UNSIGNED_INT_VEC3 0x8DC7 -#define GL_UNSIGNED_INT_VEC4 0x8DC8 -#define GL_INT_SAMPLER_1D 0x8DC9 -#define GL_INT_SAMPLER_2D 0x8DCA -#define GL_INT_SAMPLER_3D 0x8DCB -#define GL_INT_SAMPLER_CUBE 0x8DCC -#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF -#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 -#define GL_QUERY_WAIT 0x8E13 -#define GL_QUERY_NO_WAIT 0x8E14 -#define GL_QUERY_BY_REGION_WAIT 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 -#define GL_BUFFER_ACCESS_FLAGS 0x911F -#define GL_BUFFER_MAP_LENGTH 0x9120 -#define GL_BUFFER_MAP_OFFSET 0x9121 -/* Reuse tokens from ARB_depth_buffer_float */ -/* reuse GL_DEPTH_COMPONENT32F */ -/* reuse GL_DEPTH32F_STENCIL8 */ -/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_DEFAULT */ -/* reuse GL_FRAMEBUFFER_UNDEFINED */ -/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ -/* reuse GL_INDEX */ -/* reuse GL_MAX_RENDERBUFFER_SIZE */ -/* reuse GL_DEPTH_STENCIL */ -/* reuse GL_UNSIGNED_INT_24_8 */ -/* reuse GL_DEPTH24_STENCIL8 */ -/* reuse GL_TEXTURE_STENCIL_SIZE */ -/* reuse GL_TEXTURE_RED_TYPE */ -/* reuse GL_TEXTURE_GREEN_TYPE */ -/* reuse GL_TEXTURE_BLUE_TYPE */ -/* reuse GL_TEXTURE_ALPHA_TYPE */ -/* reuse GL_TEXTURE_DEPTH_TYPE */ -/* reuse GL_UNSIGNED_NORMALIZED */ -/* reuse GL_FRAMEBUFFER_BINDING */ -/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_BINDING */ -/* reuse GL_READ_FRAMEBUFFER */ -/* reuse GL_DRAW_FRAMEBUFFER */ -/* reuse GL_READ_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_SAMPLES */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* reuse GL_FRAMEBUFFER_COMPLETE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ -/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ -/* reuse GL_MAX_COLOR_ATTACHMENTS */ -/* reuse GL_COLOR_ATTACHMENT0 */ -/* reuse GL_COLOR_ATTACHMENT1 */ -/* reuse GL_COLOR_ATTACHMENT2 */ -/* reuse GL_COLOR_ATTACHMENT3 */ -/* reuse GL_COLOR_ATTACHMENT4 */ -/* reuse GL_COLOR_ATTACHMENT5 */ -/* reuse GL_COLOR_ATTACHMENT6 */ -/* reuse GL_COLOR_ATTACHMENT7 */ -/* reuse GL_COLOR_ATTACHMENT8 */ -/* reuse GL_COLOR_ATTACHMENT9 */ -/* reuse GL_COLOR_ATTACHMENT10 */ -/* reuse GL_COLOR_ATTACHMENT11 */ -/* reuse GL_COLOR_ATTACHMENT12 */ -/* reuse GL_COLOR_ATTACHMENT13 */ -/* reuse GL_COLOR_ATTACHMENT14 */ -/* reuse GL_COLOR_ATTACHMENT15 */ -/* reuse GL_DEPTH_ATTACHMENT */ -/* reuse GL_STENCIL_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER */ -/* reuse GL_RENDERBUFFER */ -/* reuse GL_RENDERBUFFER_WIDTH */ -/* reuse GL_RENDERBUFFER_HEIGHT */ -/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ -/* reuse GL_STENCIL_INDEX1 */ -/* reuse GL_STENCIL_INDEX4 */ -/* reuse GL_STENCIL_INDEX8 */ -/* reuse GL_STENCIL_INDEX16 */ -/* reuse GL_RENDERBUFFER_RED_SIZE */ -/* reuse GL_RENDERBUFFER_GREEN_SIZE */ -/* reuse GL_RENDERBUFFER_BLUE_SIZE */ -/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ -/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ -/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ -/* reuse GL_MAX_SAMPLES */ -/* Reuse tokens from ARB_framebuffer_sRGB */ -/* reuse GL_FRAMEBUFFER_SRGB */ -/* Reuse tokens from ARB_half_float_vertex */ -/* reuse GL_HALF_FLOAT */ -/* Reuse tokens from ARB_map_buffer_range */ -/* reuse GL_MAP_READ_BIT */ -/* reuse GL_MAP_WRITE_BIT */ -/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ -/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ -/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ -/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ -/* Reuse tokens from ARB_texture_compression_rgtc */ -/* reuse GL_COMPRESSED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_RG_RGTC2 */ -/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ -/* Reuse tokens from ARB_texture_rg */ -/* reuse GL_RG */ -/* reuse GL_RG_INTEGER */ -/* reuse GL_R8 */ -/* reuse GL_R16 */ -/* reuse GL_RG8 */ -/* reuse GL_RG16 */ -/* reuse GL_R16F */ -/* reuse GL_R32F */ -/* reuse GL_RG16F */ -/* reuse GL_RG32F */ -/* reuse GL_R8I */ -/* reuse GL_R8UI */ -/* reuse GL_R16I */ -/* reuse GL_R16UI */ -/* reuse GL_R32I */ -/* reuse GL_R32UI */ -/* reuse GL_RG8I */ -/* reuse GL_RG8UI */ -/* reuse GL_RG16I */ -/* reuse GL_RG16UI */ -/* reuse GL_RG32I */ -/* reuse GL_RG32UI */ -/* Reuse tokens from ARB_vertex_array_object */ -/* reuse GL_VERTEX_ARRAY_BINDING */ -#endif - -#ifndef GL_VERSION_3_1 -/* #define GL_SAMPLER_2D_RECT 0x8B63 - we use subsumed GL_ARB_texture_rectangle */ -/* #define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 - we use subsumed GL_ARB_texture_rectangle */ -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -/* Reuse all tokens from ARB_texture_buffer_object */ -/* Reuse all tokens from ARB_texture_rectangle */ -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -/* Reuse tokens from ARB_copy_buffer */ -/* reuse GL_COPY_READ_BUFFER */ -/* reuse GL_COPY_WRITE_BUFFER */ -/* Reuse tokens from ARB_draw_instanced (none) */ -/* Reuse tokens from ARB_uniform_buffer_object */ -/* reuse GL_UNIFORM_BUFFER */ -/* reuse GL_UNIFORM_BUFFER_BINDING */ -/* reuse GL_UNIFORM_BUFFER_START */ -/* reuse GL_UNIFORM_BUFFER_SIZE */ -/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ -/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ -/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ -/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ -/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ -/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ -/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ -/* reuse GL_UNIFORM_TYPE */ -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_INDEX */ -/* reuse GL_UNIFORM_OFFSET */ -/* reuse GL_UNIFORM_ARRAY_STRIDE */ -/* reuse GL_UNIFORM_MATRIX_STRIDE */ -/* reuse GL_UNIFORM_IS_ROW_MAJOR */ -/* reuse GL_UNIFORM_BLOCK_BINDING */ -/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ -/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_INVALID_INDEX */ -#endif - -#ifndef GL_VERSION_3_2 -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* Reuse tokens from ARB_depth_clamp */ -/* reuse GL_DEPTH_CLAMP */ -/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ -/* Reuse tokens from ARB_fragment_coord_conventions (none) */ -/* Reuse tokens from ARB_provoking_vertex */ -/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -/* Reuse tokens from ARB_seamless_cube_map */ -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ -/* Reuse tokens from ARB_sync */ -/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ -/* reuse GL_OBJECT_TYPE */ -/* reuse GL_SYNC_CONDITION */ -/* reuse GL_SYNC_STATUS */ -/* reuse GL_SYNC_FLAGS */ -/* reuse GL_SYNC_FENCE */ -/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ -/* reuse GL_UNSIGNALED */ -/* reuse GL_SIGNALED */ -/* reuse GL_ALREADY_SIGNALED */ -/* reuse GL_TIMEOUT_EXPIRED */ -/* reuse GL_CONDITION_SATISFIED */ -/* reuse GL_WAIT_FAILED */ -/* reuse GL_TIMEOUT_IGNORED */ -/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ -/* reuse GL_TIMEOUT_IGNORED */ -/* Reuse tokens from ARB_texture_multisample */ -/* reuse GL_SAMPLE_POSITION */ -/* reuse GL_SAMPLE_MASK */ -/* reuse GL_SAMPLE_MASK_VALUE */ -/* reuse GL_MAX_SAMPLE_MASK_WORDS */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_SAMPLES */ -/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ -/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ -/* reuse GL_MAX_INTEGER_SAMPLES */ -/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -/* Reuse tokens from ARB_blend_func_extended */ -/* reuse GL_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_ALPHA */ -/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ -/* Reuse tokens from ARB_explicit_attrib_location (none) */ -/* Reuse tokens from ARB_occlusion_query2 */ -/* reuse GL_ANY_SAMPLES_PASSED */ -/* Reuse tokens from ARB_sampler_objects */ -/* reuse GL_SAMPLER_BINDING */ -/* Reuse tokens from ARB_shader_bit_encoding (none) */ -/* Reuse tokens from ARB_texture_rgb10_a2ui */ -/* reuse GL_RGB10_A2UI */ -/* Reuse tokens from ARB_texture_swizzle */ -/* reuse GL_TEXTURE_SWIZZLE_R */ -/* reuse GL_TEXTURE_SWIZZLE_G */ -/* reuse GL_TEXTURE_SWIZZLE_B */ -/* reuse GL_TEXTURE_SWIZZLE_A */ -/* reuse GL_TEXTURE_SWIZZLE_RGBA */ -/* Reuse tokens from ARB_timer_query */ -/* reuse GL_TIME_ELAPSED */ -/* reuse GL_TIMESTAMP */ -/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ -/* reuse GL_INT_2_10_10_10_REV */ -#endif - -#ifndef GL_VERSION_4_0 -/* Reuse all tokens from ARB_sample_shading */ -/* Reuse all tokens from ARB_texture_gather */ -/* Reuse all tokens from ARB_texture_cube_map_array */ -/* Reuse tokens from ARB_texture_query_lod (none) */ -/* Reuse tokens from ARB_draw_buffers_blend (none) */ -/* Reuse tokens from ARB_draw_indirect */ -/* reuse GL_DRAW_INDIRECT_BUFFER */ -/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ -/* Reuse tokens from ARB_gpu_shader5 */ -/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -/* Reuse tokens from ARB_gpu_shader_fp64 */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -/* Reuse tokens from ARB_shader_subroutine */ -/* reuse GL_ACTIVE_SUBROUTINES */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ -/* reuse GL_MAX_SUBROUTINES */ -/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ -/* reuse GL_COMPATIBLE_SUBROUTINES */ -/* Reuse tokens from ARB_tessellation_shader */ -/* reuse GL_PATCHES */ -/* reuse GL_PATCH_VERTICES */ -/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ -/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ -/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ -/* reuse GL_TESS_GEN_MODE */ -/* reuse GL_TESS_GEN_SPACING */ -/* reuse GL_TESS_GEN_VERTEX_ORDER */ -/* reuse GL_TESS_GEN_POINT_MODE */ -/* reuse GL_ISOLINES */ -/* reuse GL_FRACTIONAL_ODD */ -/* reuse GL_FRACTIONAL_EVEN */ -/* reuse GL_MAX_PATCH_VERTICES */ -/* reuse GL_MAX_TESS_GEN_LEVEL */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_CONTROL_SHADER */ -/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ -/* Reuse tokens from ARB_transform_feedback2 */ -/* reuse GL_TRANSFORM_FEEDBACK */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ -/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ -/* Reuse tokens from ARB_transform_feedback3 */ -/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_VERSION_4_1 -/* Reuse tokens from ARB_ES2_compatibility */ -/* reuse GL_FIXED */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ -/* reuse GL_LOW_FLOAT */ -/* reuse GL_MEDIUM_FLOAT */ -/* reuse GL_HIGH_FLOAT */ -/* reuse GL_LOW_INT */ -/* reuse GL_MEDIUM_INT */ -/* reuse GL_HIGH_INT */ -/* reuse GL_SHADER_COMPILER */ -/* reuse GL_NUM_SHADER_BINARY_FORMATS */ -/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ -/* reuse GL_MAX_VARYING_VECTORS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ -/* Reuse tokens from ARB_get_program_binary */ -/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ -/* reuse GL_PROGRAM_BINARY_LENGTH */ -/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ -/* reuse GL_PROGRAM_BINARY_FORMATS */ -/* Reuse tokens from ARB_separate_shader_objects */ -/* reuse GL_VERTEX_SHADER_BIT */ -/* reuse GL_FRAGMENT_SHADER_BIT */ -/* reuse GL_GEOMETRY_SHADER_BIT */ -/* reuse GL_TESS_CONTROL_SHADER_BIT */ -/* reuse GL_TESS_EVALUATION_SHADER_BIT */ -/* reuse GL_ALL_SHADER_BITS */ -/* reuse GL_PROGRAM_SEPARABLE */ -/* reuse GL_ACTIVE_PROGRAM */ -/* reuse GL_PROGRAM_PIPELINE_BINDING */ -/* Reuse tokens from ARB_shader_precision (none) */ -/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ -/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ -/* reuse GL_MAX_VIEWPORTS */ -/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ -/* reuse GL_VIEWPORT_BOUNDS_RANGE */ -/* reuse GL_LAYER_PROVOKING_VERTEX */ -/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ -/* reuse GL_UNDEFINED_VERTEX */ -#endif - -#ifndef GL_VERSION_4_2 -/* Reuse tokens from ARB_base_instance (none) */ -/* Reuse tokens from ARB_shading_language_420pack (none) */ -/* Reuse tokens from ARB_transform_feedback_instanced (none) */ -/* Reuse tokens from ARB_compressed_texture_pixel_storage */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ -/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ -/* Reuse tokens from ARB_conservative_depth (none) */ -/* Reuse tokens from ARB_internalformat_query */ -/* reuse GL_NUM_SAMPLE_COUNTS */ -/* Reuse tokens from ARB_map_buffer_alignment */ -/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ -/* Reuse tokens from ARB_shader_atomic_counters */ -/* reuse GL_ATOMIC_COUNTER_BUFFER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ -/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ -/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ -/* Reuse tokens from ARB_shader_image_load_store */ -/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ -/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ -/* reuse GL_UNIFORM_BARRIER_BIT */ -/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ -/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ -/* reuse GL_COMMAND_BARRIER_BIT */ -/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ -/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ -/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ -/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ -/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ -/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ -/* reuse GL_ALL_BARRIER_BITS */ -/* reuse GL_MAX_IMAGE_UNITS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ -/* reuse GL_IMAGE_BINDING_NAME */ -/* reuse GL_IMAGE_BINDING_LEVEL */ -/* reuse GL_IMAGE_BINDING_LAYERED */ -/* reuse GL_IMAGE_BINDING_LAYER */ -/* reuse GL_IMAGE_BINDING_ACCESS */ -/* reuse GL_IMAGE_1D */ -/* reuse GL_IMAGE_2D */ -/* reuse GL_IMAGE_3D */ -/* reuse GL_IMAGE_2D_RECT */ -/* reuse GL_IMAGE_CUBE */ -/* reuse GL_IMAGE_BUFFER */ -/* reuse GL_IMAGE_1D_ARRAY */ -/* reuse GL_IMAGE_2D_ARRAY */ -/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_IMAGE_1D */ -/* reuse GL_INT_IMAGE_2D */ -/* reuse GL_INT_IMAGE_3D */ -/* reuse GL_INT_IMAGE_2D_RECT */ -/* reuse GL_INT_IMAGE_CUBE */ -/* reuse GL_INT_IMAGE_BUFFER */ -/* reuse GL_INT_IMAGE_1D_ARRAY */ -/* reuse GL_INT_IMAGE_2D_ARRAY */ -/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D */ -/* reuse GL_UNSIGNED_INT_IMAGE_3D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ -/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_IMAGE_SAMPLES */ -/* reuse GL_IMAGE_BINDING_FORMAT */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ -/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ -/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ -/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ -/* Reuse tokens from ARB_shading_language_packing (none) */ -/* Reuse tokens from ARB_texture_storage */ -/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_HALF_FLOAT 0x140B -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -/* #define GL_INVALID_INDEX 0xFFFFFFFFu - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_DEPTH_CLAMP 0x864F -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#endif - -#ifndef GL_ARB_sync -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -#endif - -#ifndef GL_ARB_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_ARB_draw_buffers_blend -#endif - -#ifndef GL_ARB_sample_shading -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#endif - -#ifndef GL_ARB_texture_gather -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#endif - -#ifndef GL_ARB_texture_query_lod -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_SRC1_COLOR 0x88F9 -/* reuse GL_SRC1_ALPHA */ -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#endif - -#ifndef GL_ARB_explicit_attrib_location -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_SAMPLER_BINDING 0x8919 -#endif - -#ifndef GL_ARB_shader_bit_encoding -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_RGB10_A2UI 0x906F -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#endif - -#ifndef GL_ARB_timer_query -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ -#define GL_INT_2_10_10_10_REV 0x8D9F -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -/* reuse GL_TRIANGLES */ -/* reuse GL_QUADS */ -#define GL_ISOLINES 0x8E7A -/* reuse GL_EQUAL */ -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -/* reuse GL_CCW */ -/* reuse GL_CW */ -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -/* reuse GL_RGB32F */ -/* reuse GL_RGB32UI */ -/* reuse GL_RGB32I */ -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -#define GL_MAX_VERTEX_STREAMS 0x8E71 -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -/* #define GL_ALL_SHADER_BITS 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#endif - -#ifndef GL_ARB_shader_precision -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -/* reuse GL_RGB32I */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -#endif - -#ifndef GL_ARB_viewport_array -/* reuse GL_SCISSOR_BOX */ -/* reuse GL_VIEWPORT */ -/* reuse GL_DEPTH_RANGE */ -/* reuse GL_SCISSOR_TEST */ -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -#endif - -#ifndef GL_ARB_cl_event -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -#endif - -#ifndef GL_ARB_debug_output -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -#endif - -#ifndef GL_ARB_robustness -/* reuse GL_NO_ERROR */ -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 -#endif - -#ifndef GL_ARB_shader_stencil_export -#endif - -#ifndef GL_ARB_base_instance -#endif - -#ifndef GL_ARB_shading_language_420pack -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#endif - -#ifndef GL_ARB_conservative_depth -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -/* #define GL_ALL_BARRIER_BITS 0xFFFFFFFF - manual, due to fixed uint32_t size. GlueGen would create int64_t */ -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#endif - -#ifndef GL_ARB_shading_language_packing -#endif - -#ifndef GL_ARB_texture_storage -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for program/shader text and shader object handles */ -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#endif - -/* GL type for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#include "gl-64bit-types.h" - -#ifndef GL_ARB_cl_event -/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event -struct _cl_context; -struct _cl_event; - */ -#endif - -#ifndef GL_ARB_debug_output -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_NV_vdpau_interop -typedef GLintptr GLvdpauSurfaceNV; -#endif - -#ifndef GL_VERSION_1_0 -#define GL_VERSION_1_0 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glCullFace (GLenum mode); -GLAPI void APIENTRY glFrontFace (GLenum mode); -GLAPI void APIENTRY glHint (GLenum target, GLenum mode); -GLAPI void APIENTRY glLineWidth (GLfloat width); -GLAPI void APIENTRY glPointSize (GLfloat size); -GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); -GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexImage1D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glDrawBuffer (GLenum mode); -GLAPI void APIENTRY glClear (GLbitfield mask); -GLAPI void APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GLAPI void APIENTRY glClearStencil (GLint s); -GLAPI void APIENTRY glClearDepth (GLclampd depth); -GLAPI void APIENTRY glStencilMask (GLuint mask); -GLAPI void APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GLAPI void APIENTRY glDepthMask (GLboolean flag); -GLAPI void APIENTRY glDisable (GLenum cap); -GLAPI void APIENTRY glEnable (GLenum cap); -GLAPI void APIENTRY glFinish (void); -GLAPI void APIENTRY glFlush (void); -GLAPI void APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GLAPI void APIENTRY glLogicOp (GLenum opcode); -GLAPI void APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GLAPI void APIENTRY glDepthFunc (GLenum func); -GLAPI void APIENTRY glPixelStoref (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); -GLAPI void APIENTRY glReadBuffer (GLenum mode); -GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetBooleanv (GLenum pname, GLboolean *params); -GLAPI void APIENTRY glGetDoublev (GLenum pname, GLdouble *params); -GLAPI GLenum APIENTRY glGetError (void); -GLAPI void APIENTRY glGetFloatv (GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *params); -GLAPI const GLubyte * APIENTRY glGetString (GLenum name); -GLAPI void APIENTRY glGetTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); -GLAPI void APIENTRY glDepthRange (GLclampd zNear, GLclampd zFar); -GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); -typedef void (APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); -typedef void (APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size); -typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); -typedef void (APIENTRYP PFNGLCLEARDEPTHPROC) (GLclampd depth); -typedef void (APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); -typedef void (APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -typedef void (APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); -typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLFINISHPROC) (void); -typedef void (APIENTRYP PFNGLFLUSHPROC) (void); -typedef void (APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); -typedef void (APIENTRYP PFNGLLOGICOPPROC) (GLenum opcode); -typedef void (APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); -typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); -typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *params); -typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *params); -typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); -typedef void (APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); -typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); -typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) (GLclampd near, GLclampd far); -typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_1 -#define GL_VERSION_1_1 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void APIENTRY glGetPointerv (GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GLAPI void APIENTRY glCopyTexImage1D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); -GLAPI GLboolean APIENTRY glIsTexture (GLuint texture); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQuery (GLuint id); -GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQuery (GLenum target); -GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgram (GLuint program); -GLAPI GLboolean APIENTRY glIsShader (GLuint shader); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glValidateProgram (GLuint program); -GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -/* OpenGL 3.0 also reuses entry points from these extensions: */ -/* ARB_framebuffer_object */ -/* ARB_map_buffer_range */ -/* ARB_vertex_array_object */ -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); -GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); -GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); -GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -#endif - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -/* OpenGL 3.1 also reuses entry points from these extensions: */ -/* ARB_copy_buffer */ -/* ARB_uniform_buffer_object */ -/* ARB_draw_instanced */ -/* ARB_texture_buffer_object */ -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -#endif - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -/* OpenGL 3.2 also reuses entry points from these extensions: */ -/* ARB_draw_elements_base_vertex */ -/* ARB_provoking_vertex */ -/* ARB_sync */ -/* ARB_texture_multisample */ -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -/* OpenGL 3.3 also reuses entry points from these extensions: */ -/* ARB_blend_func_extended */ -/* ARB_sampler_objects */ -/* ARB_explicit_attrib_location, but it has none */ -/* ARB_occlusion_query2 (no entry points) */ -/* ARB_shader_bit_encoding (no entry points) */ -/* ARB_texture_rgb10_a2ui (no entry points) */ -/* ARB_texture_swizzle (no entry points) */ -/* ARB_timer_query */ -/* ARB_vertex_type_2_10_10_10_rev */ -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 -/* OpenGL 4.0 also reuses entry points from these extensions: */ -/* ARB_texture_query_lod (no entry points) */ -/* ARB_draw_indirect */ -/* ARB_gpu_shader5 (no entry points) */ -/* ARB_gpu_shader_fp64 */ -/* ARB_shader_subroutine */ -/* ARB_tessellation_shader */ -/* ARB_texture_buffer_object_rgb32 (no entry points) */ -/* ARB_texture_cube_map_array (no entry points) */ -/* ARB_texture_gather (no entry points) */ -/* ARB_transform_feedback2 */ -/* ARB_transform_feedback3 */ -/* Susume ARB_sample_shading */ -/* Susume ARB_draw_buffers_blend */ -#endif - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 -/* OpenGL 4.1 also reuses entry points from these extensions: */ -/* ARB_ES2_compatibility */ -/* ARB_get_program_binary */ -/* ARB_separate_shader_objects */ -/* ARB_shader_precision (no entry points) */ -/* ARB_vertex_attrib_64bit */ -/* ARB_viewport_array */ -#endif - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 -/* OpenGL 4.2 reuses entry points from these extensions: */ -/* ARB_base_instance */ -/* ARB_shading_language_420pack (no entry points) */ -/* ARB_transform_feedback_instanced */ -/* ARB_compressed_texture_pixel_storage (no entry points) */ -/* ARB_conservative_depth (no entry points) */ -/* ARB_internalformat_query */ -/* ARB_map_buffer_alignment (no entry points) */ -/* ARB_shader_atomic_counters */ -/* ARB_shader_image_load_store */ -/* ARB_shading_language_packing (no entry points) */ -/* ARB_texture_storage */ -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#ifdef GL3_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmap (GLenum target); -GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif /* GL3_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#ifdef GL3_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -#endif /* GL3_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* *uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex); -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glProvokingVertex (GLenum mode); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#ifdef GL3_PROTOTYPES -GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); -GLAPI GLboolean APIENTRY glIsSync (GLsync sync); -GLAPI void APIENTRY glDeleteSync (GLsync sync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif /* GL3_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); -#endif - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLclampf value); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLclampf value); -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#endif - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#endif - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); -#endif - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); -GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); -GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); -GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); -GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); -GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 -#endif - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); -GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); -GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); -GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 -#ifdef GL3_PROTOTYPES -GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); -GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); -GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif /* GL3_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); -GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedback (void); -GLAPI void APIENTRY glResumeTransformFeedback (void); -GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); -GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); -GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); -GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glReleaseShaderCompiler (void); -GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GLAPI void APIENTRY glClearDepthf (GLclampf depth); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLclampf n, GLclampf f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLclampf d); -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); -GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* *strings); -GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); -GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); -GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); -GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* *strings); -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); -#endif - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); -GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLclampd *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLclampd n, GLclampd f); -GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLclampd *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLclampd n, GLclampd f); -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#endif - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 -#ifdef GL3_PROTOTYPES -/* GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); */ -GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (void * context, void * event, GLbitfield flags); -#endif /* GL3_PROTOTYPES */ -/* typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); */ -typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (void * context, void * event, GLbitfield flags); -#endif - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 -#ifdef GL3_PROTOTYPES -GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); -GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif /* GL3_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 -#endif - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance); -#endif - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount); -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 -#endif - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -#endif - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 -#endif - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -#endif -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -/** - * Convenient names only .. actually subsumed into core - */ -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#endif -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -/** - * We rename EXT_texture_rectangle into core, - * so ARB_texture_rectangle will remain intact. - */ -#ifndef GL_EXT_texture_rectangle -#define GL_TEXTURE_RECTANGLE_EXT 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_EXT 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_EXT 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT 0x84F8 -#define GL_SAMPLER_2D_RECT_EXT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_EXT 0x8B64 -#endif -#ifndef GL_EXT_texture_rectangle -#define GL_EXT_texture_rectangle 1 -#endif - -#ifndef GL_ARB_draw_instanced -#endif -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -#ifdef GL3_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL3_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/make/stub_includes/opengl/GL3/gl3ext.h b/make/stub_includes/opengl/GL3/gl3ext.h deleted file mode 100644 index 8b05499c2..000000000 --- a/make/stub_includes/opengl/GL3/gl3ext.h +++ /dev/null @@ -1,351 +0,0 @@ -#ifndef __gl3ext_h_ -#define __gl3ext_h_ - -/* -** Copyright (c) 2010 JogAmp Developer Team -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/** - * This header files contains additional extensions not covered by the - * 'official' khronos gl3.h - */ - -/* - * ------------------------------------------------ - * Everything here and below was added manually - * to the version of glext.h obtained from: - * http://oss.sgi.com/projects/ogl-sample/registry/index.html - * ------------------------------------------------ - * - * Structure is: - * #ifndef GL_EXTENSION_NAME - * Add DEFINES here - * #endif - * #ifndef GL_EXTENSION_NAME - * Add TYPEDEFS here - * #endif - * #ifndef GL_EXTENSION_NAME - * #define GL_EXTENSION_NAME 1 - * #ifdef GL_GL3EXT_PROTOTYPES - * Add FUNCTION DECLARATIONS here - * #endif - * FUNCTION POINTER DECLARATIONS NOT NEEDED - * #endif - */ - -/** - * 47. http://www.opengl.org/registry/specs/ARB/geometry_shader4.txt - */ -#ifndef GL_ARB_geometry_shader4 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -#ifndef GL_MAX_VARYING_COMPONENTS -#define GL_MAX_VARYING_COMPONENTS 0x8B4B -#endif -#ifndef GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#endif -#endif -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #187 -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -// #363 http://www.opengl.org/registry/specs/AMD/vertex_shader_tessellator.txt -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#endif -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_AMD_vertex_shader_tessellator 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD(GLfloat factor); -GLAPI void APIENTRY glTessellationModeAMD(GLenum mode); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #379 http://www.opengl.org/registry/specs/NV/shader_buffer_load.txt -#ifndef GL_NV_shader_buffer_load -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -#endif -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); -GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); -GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); -GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); -GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); -GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); -GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); -GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); -GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); -GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); -GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #380 http://www.opengl.org/registry/specs/NV/vertex_buffer_unified_memory.txt -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -#endif -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsEnabled( GLenum cap ); // extra requirement in core GL3 -GLAPI void APIENTRY glEnableClientState( GLenum cap ); // extra requirement in core GL3 -GLAPI void APIENTRY glDisableClientState( GLenum cap ); // extra requirement in core GL3 -GLAPI void APIENTRY glBufferAddressRangeNV(GLenum pname, GLuint index, GLuint64 address, GLsizeiptr length); -GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); -GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #395 -#ifndef GL_AMD_debug_output -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -#endif -#ifndef GL_AMD_debug_output -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif /* GL_GL3EXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif - -// #401 -#ifndef GL_AMD_depth_clamp_separate -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F -#endif -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 -#endif - -// #402 -#ifndef GL_EXT_texture_sRGB_decode -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 -#endif - -// #403 -#ifndef GL_NV_texture_multisample -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -#endif -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #404 -#ifndef GL_AMD_blend_minmax_factor -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D -#endif -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 -#endif - -// #405 -#ifndef GL_AMD_sample_positions -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F -#endif -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); -#endif /* GL_GL3EXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); -#endif - -// #406 -#ifndef GL_EXT_x11_sync_object -#define GL_SYNC_X11_FENCE_EXT 0x90E1 -#endif -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #408 -#ifndef GL_AMD_multi_draw_indirect -#endif -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -// #409 -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#endif -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 -#endif - -// #410 GL_NV_path_rendering ? - -// #411 -#ifndef GL_AMD_pinned_memory -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#endif -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 -#endif - -// #413 -#ifndef GL_AMD_stencil_operation_extended -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -#endif -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 -#ifdef GL_GL3EXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); -#endif /* GL_GL3EXT_PROTOTYPES */ -/* No need for explicit function pointer: we force generation of ProcAddress .. */ -#endif - -#endif /* __gl3ext_h_ */ - diff --git a/make/stub_includes/opengl/GL3/glplatform.h b/make/stub_includes/opengl/GL3/glplatform.h deleted file mode 100644 index 958d95cb1..000000000 --- a/make/stub_includes/opengl/GL3/glplatform.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef __glplatform_h_ -#define __glplatform_h_ - -#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO)) -#define OPENSTEP -#endif - -#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) -#define __WIN32__ -#endif - -#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) -# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ -# define GLAPI __declspec(dllexport) -# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ -# define GLAPI __declspec(dllimport) -# else /* for use with static link lib build of Win32 edition only */ -# define GLAPI extern -# endif /* _STATIC_MESA support */ -# define APIENTRY __stdcall -#else -/* non-Windows compilation */ -# ifndef GLAPI -# define GLAPI extern -# endif -# define APIENTRY -#endif /* WIN32 / CYGWIN bracket */ - -#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__) -# define PRAGMA_EXPORT_SUPPORTED 1 -#endif - -/* - * WINDOWS: Include windows.h here to define APIENTRY. - * It is also useful when applications include this file by - * including only glut.h, since glut.h depends on windows.h. - * Applications needing to include windows.h with parms other - * than "WIN32_LEAN_AND_MEAN" may include windows.h before - * glut.h or gl.h. - */ -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__) -#include -#endif - -#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED -#pragma import on -#endif - -#ifdef CENTERLINE_CLPP -#define signed -#endif - -#if defined(PRAGMA_EXPORT_SUPPORTED) -#pragma export on -#endif - -#endif /* __glplatform_h_ */ - diff --git a/make/stub_includes/opengl/GLES/gl.h b/make/stub_includes/opengl/GLES/gl.h index 0d152474b..198bd4d5c 100644 --- a/make/stub_includes/opengl/GLES/gl.h +++ b/make/stub_includes/opengl/GLES/gl.h @@ -599,7 +599,7 @@ typedef khronos_ssize_t GLsizeiptr; /* Available only in Common profile */ GL_API void GL_APIENTRY glAlphaFunc (GLenum func, GLclampf ref); GL_API void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_API void GL_APIENTRY glClearDepthf (GLclampf depth); +GL_API void GL_APIENTRY glClearDepthf (GLfloat depth); GL_API void GL_APIENTRY glClipPlanef (GLenum plane, const GLfloat *equation); GL_API void GL_APIENTRY glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GL_API void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); @@ -608,7 +608,7 @@ GL_API void GL_APIENTRY glFogfv (GLenum pname, const GLfloat *params); GL_API void GL_APIENTRY glFrustumf (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); /* FIXME: GlueGen generates incorrect code for this one */ /* GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat eqn[4]); */ -GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, const GLfloat * eqn); +GL_API void GL_APIENTRY glGetClipPlanef (GLenum pname, GLfloat *equation); GL_API void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *params); GL_API void GL_APIENTRY glGetLightfv (GLenum light, GLenum pname, GLfloat *params); GL_API void GL_APIENTRY glGetMaterialfv (GLenum face, GLenum pname, GLfloat *params); diff --git a/make/stub_includes/opengl/GLES/glext.h b/make/stub_includes/opengl/GLES/glext.h index b3d6b712b..7a0a718ca 100644 --- a/make/stub_includes/opengl/GLES/glext.h +++ b/make/stub_includes/opengl/GLES/glext.h @@ -1,7 +1,7 @@ #ifndef __glext_h_ #define __glext_h_ -/* $Revision: 16481 $ on $Date:: 2012-01-04 10:43:56 -0800 #$ */ +/* $Revision: 20798 $ on $Date:: 2013-03-07 01:19:34 -0800 #$ */ #ifdef __cplusplus extern "C" { @@ -166,6 +166,9 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_DEPTH24_STENCIL8_OES 0x88F0 #endif +/* GL_OES_required_internalformat */ +/* No new tokens introduced by this extension. */ + /* GL_OES_rgb8_rgba8 */ #ifndef GL_OES_rgb8_rgba8 #define GL_RGB8_OES 0x8051 @@ -241,7 +244,7 @@ typedef struct __GLeglImageOES *GLeglImageOES; * APPLE extension tokens *------------------------------------------------------------------------*/ -/* GL_APPLE_texture_2D_limited_npot */ +/* GL_APPLE_copy_texture_levels */ /* No new tokens introduced by this extension. */ /* GL_APPLE_framebuffer_multisample */ @@ -255,6 +258,41 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA #endif +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync + +/* These types are defined with reference to + * in the Apple extension spec, but here we use the Khronos + * portable types in khrplatform.h, and assume those types + * are always defined. + * If any other extensions using these types are defined, + * the typedefs must move out of this block and be shared. + */ +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; + +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +#endif + +/* GL_APPLE_texture_2D_limited_npot */ +/* No new tokens introduced by this extension. */ + /* GL_APPLE_texture_format_BGRA8888 */ #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_BGRA_EXT 0x80E1 @@ -289,12 +327,23 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_STENCIL_EXT 0x1802 #endif +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +#endif + /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C -#define GL_RENDERBUFFER_SAMPLES_EXT 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x9134 -#define GL_MAX_SAMPLES_EXT 0x9135 +/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 #endif /* GL_EXT_multi_draw_arrays */ @@ -354,10 +403,10 @@ typedef struct __GLeglImageOES *GLeglImageOES; /* GL_EXT_texture_storage */ #ifndef GL_EXT_texture_storage #define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F -#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA8_EXT 0x803C #define GL_LUMINANCE8_EXT 0x8040 #define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_RGBA32F_EXT 0x8814 +#define GL_RGBA32F_EXT 0x8814 #define GL_RGB32F_EXT 0x8815 #define GL_ALPHA32F_EXT 0x8816 #define GL_LUMINANCE32F_EXT 0x8818 @@ -367,7 +416,7 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_ALPHA16F_EXT 0x881C #define GL_LUMINANCE16F_EXT 0x881E #define GL_LUMINANCE_ALPHA16F_EXT 0x881F -#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGB10_A2_EXT 0x8059 #define GL_RGB10_EXT 0x8052 #define GL_BGRA8_EXT 0x93A1 #endif @@ -776,6 +825,11 @@ typedef void (GL_APIENTRYP PFNGLWEIGHTPOINTEROESPROC) (GLint size, GLenum type, #define GL_OES_packed_depth_stencil 1 #endif +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#endif + /* GL_OES_query_matrix */ #ifndef GL_OES_query_matrix #define GL_OES_query_matrix 1 @@ -801,8 +855,8 @@ GL_API void GL_APIENTRY glDepthRangefOES (GLclampf zNear, GLclampf zFar); GL_API void GL_APIENTRY glFrustumfOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); GL_API void GL_APIENTRY glOrthofOES (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); GL_API void GL_APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); -GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum pname, GLfloat eqn[4]); -GL_API void GL_APIENTRY glClearDepthfOES (GLclampf depth); +GL_API void GL_APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GL_API void GL_APIENTRY glClearDepthfOES (GLfloat depth); #endif typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf zNear, GLclampf zFar); typedef void (GL_APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar); @@ -900,9 +954,13 @@ typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); * APPLE extension functions *------------------------------------------------------------------------*/ -/* GL_APPLE_texture_2D_limited_npot */ -#ifndef GL_APPLE_texture_2D_limited_npot -#define GL_APPLE_texture_2D_limited_npot 1 +/* GL_APPLE_copy_texture_levels */ +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); #endif /* GL_APPLE_framebuffer_multisample */ @@ -916,6 +974,32 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); #endif +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_API GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_API void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_API GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_API void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_API void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_API void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +/* GL_APPLE_texture_2D_limited_npot */ +#ifndef GL_APPLE_texture_2D_limited_npot +#define GL_APPLE_texture_2D_limited_npot 1 +#endif + /* GL_APPLE_texture_format_BGRA8888 */ #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_APPLE_texture_format_BGRA8888 1 @@ -953,6 +1037,17 @@ GL_API void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttac typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); #endif +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_API void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_API void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_EXT_multisampled_render_to_texture 1 @@ -968,10 +1063,10 @@ typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 #ifdef GL_GLEXT_PROTOTYPES -GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GL_API void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei); GL_API void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); #endif @@ -1076,8 +1171,8 @@ typedef void (GL_APIENTRYP PFNGLCLIPPLANEXIMGPROC) (GLenum p, const GLfixed *eqn GL_API void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); GL_API void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); #endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif /*------------------------------------------------------------------------* diff --git a/make/stub_includes/opengl/GLES2/gl2.h b/make/stub_includes/opengl/GLES2/gl2.h index 5c6d5f03e..89babc98d 100644 --- a/make/stub_includes/opengl/GLES2/gl2.h +++ b/make/stub_includes/opengl/GLES2/gl2.h @@ -1,7 +1,7 @@ #ifndef __gl2_h_ #define __gl2_h_ -/* $Revision: 16803 $ on $Date:: 2012-02-02 09:49:18 -0800 #$ */ +/* $Revision: 20555 $ on $Date:: 2013-02-12 14:32:47 -0800 #$ */ #include @@ -494,7 +494,7 @@ GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr off GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat depth); GL_APICALL void GL_APIENTRY glClearStencil (GLint s); GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); @@ -534,7 +534,7 @@ GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); -GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL GLenum GL_APIENTRY glGetError (void); @@ -553,7 +553,7 @@ GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum p GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); -GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); diff --git a/make/stub_includes/opengl/GLES2/gl2ext.h b/make/stub_includes/opengl/GLES2/gl2ext.h index 04c0a64e9..b658fc8ba 100644 --- a/make/stub_includes/opengl/GLES2/gl2ext.h +++ b/make/stub_includes/opengl/GLES2/gl2ext.h @@ -1,7 +1,7 @@ #ifndef __gl2ext_h_ #define __gl2ext_h_ -/* $Revision: 16619 $ on $Date:: 2012-01-18 10:00:14 -0800 #$ */ +/* $Revision: 22161 $ on $Date:: 2013-06-25 08:17:27 -0700 #$ */ #ifdef __cplusplus extern "C" { @@ -16,6 +16,20 @@ extern "C" { # define GL_APIENTRYP GL_APIENTRY* #endif +/* New types shared by several extensions */ + +#ifndef __gl3_h_ +/* These are defined with respect to in the + * Apple extension spec, but they are also used by non-APPLE + * extensions, and in the Khronos header we use the Khronos + * portable types in khrplatform.h, which must be defined. + */ +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + + /*------------------------------------------------------------------------* * OES extension tokens *------------------------------------------------------------------------*/ @@ -94,6 +108,25 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_DEPTH24_STENCIL8_OES 0x88F0 #endif +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_ALPHA8_OES 0x803C +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +/* reuse GL_DEPTH_COMPONENT24_OES */ +/* reuse GL_DEPTH24_STENCIL8_OES */ +/* reuse GL_DEPTH_COMPONENT32_OES */ +#define GL_LUMINANCE4_ALPHA4_OES 0x8043 +#define GL_LUMINANCE8_ALPHA8_OES 0x8045 +#define GL_LUMINANCE8_OES 0x8040 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +/* reuse GL_RGB8_OES */ +/* reuse GL_RGBA8_OES */ +/* reuse GL_RGB10_EXT */ +/* reuse GL_RGB10_A2_EXT */ +#endif + /* GL_OES_rgb8_rgba8 */ #ifndef GL_OES_rgb8_rgba8 #define GL_RGB8_OES 0x8051 @@ -115,6 +148,10 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_STENCIL_INDEX4_OES 0x8D47 #endif +#ifndef GL_OES_surfaceless_context +#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 +#endif + /* GL_OES_texture_3D */ #ifndef GL_OES_texture_3D #define GL_TEXTURE_WRAP_R_OES 0x8072 @@ -156,6 +193,85 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_INT_10_10_10_2_OES 0x8DF7 #endif +/*------------------------------------------------------------------------* + * KHR extension tokens + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +typedef void (GL_APIENTRYP GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 +#define GL_DEBUG_SOURCE_API_KHR 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A +#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B +#define GL_DEBUG_TYPE_ERROR_KHR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 +#define GL_DEBUG_TYPE_OTHER_KHR 0x8251 +#define GL_DEBUG_TYPE_MARKER_KHR 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D +#define GL_BUFFER_KHR 0x82E0 +#define GL_SHADER_KHR 0x82E1 +#define GL_PROGRAM_KHR 0x82E2 +#define GL_QUERY_KHR 0x82E3 +/* PROGRAM_PIPELINE only in GL */ +#define GL_SAMPLER_KHR 0x82E6 +/* DISPLAY_LIST only in GL */ +#define GL_MAX_LABEL_LENGTH_KHR 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 +#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 +#define GL_DEBUG_OUTPUT_KHR 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 +#define GL_STACK_OVERFLOW_KHR 0x0503 +#define GL_STACK_UNDERFLOW_KHR 0x0504 +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + /*------------------------------------------------------------------------* * AMD extension tokens *------------------------------------------------------------------------*/ @@ -193,6 +309,18 @@ typedef struct __GLeglImageOES *GLeglImageOES; * ANGLE extension tokens *------------------------------------------------------------------------*/ +/* GL_ANGLE_depth_texture */ +#ifndef GL_ANGLE_depth_texture +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_UNSIGNED_INT 0x1405 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif + /* GL_ANGLE_framebuffer_blit */ #ifndef GL_ANGLE_framebuffer_blit #define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 @@ -208,16 +336,48 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_MAX_SAMPLES_ANGLE 0x8D57 #endif +/* GL_ANGLE_instanced_arrays */ +#ifndef GL_ANGLE_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 +#endif + +/* GL_ANGLE_program_binary */ +#ifndef GL_ANGLE_program_binary +#define GL_PROGRAM_BINARY_ANGLE 0x93A6 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_TEXTURE_USAGE_ANGLE 0x93A2 +#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 +#endif + +/* GL_ANGLE_translated_shader_source */ +#ifndef GL_ANGLE_translated_shader_source +#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 +#endif + /*------------------------------------------------------------------------* * APPLE extension tokens *------------------------------------------------------------------------*/ -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif +/* GL_APPLE_copy_texture_levels */ +/* No new tokens introduced by this extension. */ /* GL_APPLE_framebuffer_multisample */ #ifndef GL_APPLE_framebuffer_multisample @@ -230,6 +390,34 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA #endif +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync + +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +#endif + /* GL_APPLE_texture_format_BGRA8888 */ #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_BGRA_EXT 0x80E1 @@ -244,6 +432,11 @@ typedef struct __GLeglImageOES *GLeglImageOES; * ARM extension tokens *------------------------------------------------------------------------*/ +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 +#endif + /* GL_ARM_mali_shader_binary */ #ifndef GL_ARM_mali_shader_binary #define GL_MALI_SHADER_BINARY_ARM 0x8F60 @@ -292,12 +485,80 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_STENCIL_EXT 0x1802 #endif +#ifndef GL_EXT_disjoint_timer_query +#define GL_QUERY_COUNTER_BITS_EXT 0x8864 +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#define GL_TIME_ELAPSED_EXT 0x88BF +#define GL_TIMESTAMP_EXT 0x8E28 +#define GL_GPU_DISJOINT_EXT 0x8FBB +#endif + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_DRAW_BUFFERS_EXT 0x8824 +#define GL_DRAW_BUFFER0_EXT 0x8825 +#define GL_DRAW_BUFFER1_EXT 0x8826 +#define GL_DRAW_BUFFER2_EXT 0x8827 +#define GL_DRAW_BUFFER3_EXT 0x8828 +#define GL_DRAW_BUFFER4_EXT 0x8829 +#define GL_DRAW_BUFFER5_EXT 0x882A +#define GL_DRAW_BUFFER6_EXT 0x882B +#define GL_DRAW_BUFFER7_EXT 0x882C +#define GL_DRAW_BUFFER8_EXT 0x882D +#define GL_DRAW_BUFFER9_EXT 0x882E +#define GL_DRAW_BUFFER10_EXT 0x882F +#define GL_DRAW_BUFFER11_EXT 0x8830 +#define GL_DRAW_BUFFER12_EXT 0x8831 +#define GL_DRAW_BUFFER13_EXT 0x8832 +#define GL_DRAW_BUFFER14_EXT 0x8833 +#define GL_DRAW_BUFFER15_EXT 0x8834 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#endif + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +#endif + /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C -#define GL_RENDERBUFFER_SAMPLES_EXT 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x9134 -#define GL_MAX_SAMPLES_EXT 0x9135 +/* reuse values from GL_EXT_framebuffer_multisample (desktop extension) */ +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_COLOR_ATTACHMENT_EXT 0x90F0 +#define GL_MULTIVIEW_EXT 0x90F1 +#define GL_DRAW_BUFFER_EXT 0x0C01 +#define GL_READ_BUFFER_EXT 0x0C02 +#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 #endif /* GL_EXT_multi_draw_arrays */ @@ -341,6 +602,11 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A #endif +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif + /* GL_EXT_shader_texture_lod */ /* No new tokens introduced by this extension. */ @@ -397,13 +663,19 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_LUMINANCE32F_EXT 0x8818 // -> ARB #define GL_LUMINANCE_ALPHA32F_EXT 0x8819 // -> ARB /* reuse GL_RGBA16F_EXT */ -#define GL_RGB16F_EXT 0x881B // remove EXT (duplicate in GL_EXT_color_buffer_half_float) -#define GL_ALPHA16F_EXT 0x881C // -> ARB -#define GL_LUMINANCE16F_EXT 0x881E // -> ARB -#define GL_LUMINANCE_ALPHA16F_EXT 0x881F // -> ARB -#define GL_RGB10_A2_EXT 0x8059 // remove EXT -#define GL_RGB10_EXT 0x8052 // remove EXT -#define GL_BGRA8_EXT 0x93A1 // keep +/* reuse GL_RGB16F_EXT */ +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGB10_EXT 0x8052 +#define GL_BGRA8_EXT 0x93A1 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +#define GL_R16F_EXT 0x822D +#define GL_RG16F_EXT 0x822F #endif /* GL_EXT_texture_type_2_10_10_10_REV */ @@ -413,9 +685,9 @@ typedef struct __GLeglImageOES *GLeglImageOES; /* GL_EXT_unpack_subimage */ #ifndef GL_EXT_unpack_subimage -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 +#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 #endif /*------------------------------------------------------------------------* @@ -427,6 +699,15 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_SHADER_BINARY_DMP 0x9250 #endif +/*------------------------------------------------------------------------* + * FJ extension tokens + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_GCCSO_SHADER_BINARY_FJ 0x9260 +#endif + /*------------------------------------------------------------------------* * IMG extension tokens *------------------------------------------------------------------------*/ @@ -455,6 +736,12 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 #endif +/* GL_IMG_texture_compression_pvrtc2 */ +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 +#endif + /* GL_IMG_multisampled_render_to_texture */ #ifndef GL_IMG_multisampled_render_to_texture #define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 @@ -484,7 +771,7 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 #define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 #define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 -#define GL_COVERAGE_BUFFER_BIT_NV 0x8000 +#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 #endif /* GL_NV_depth_nonlinear */ @@ -529,6 +816,9 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_COLOR_ATTACHMENT15_NV 0x8CEF #endif +/* GL_NV_draw_instanced */ +/* No new tokens introduced by this extension. */ + /* GL_NV_fbo_color_attachments */ #ifndef GL_NV_fbo_color_attachments #define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF @@ -542,6 +832,29 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_FENCE_CONDITION_NV 0x84F4 #endif +/* GL_NV_framebuffer_blit */ +#ifndef GL_NV_framebuffer_blit +#define GL_READ_FRAMEBUFFER_NV 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA +#endif + +/* GL_NV_framebuffer_multisample */ +#ifndef GL_NV_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 +#define GL_MAX_SAMPLES_NV 0x8D57 +#endif + +/* GL_NV_generate_mipmap_sRGB */ +/* No new tokens introduced by this extension. */ + +/* GL_NV_instanced_arrays */ +#ifndef GL_NV_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE +#endif + /* GL_NV_read_buffer */ #ifndef GL_NV_read_buffer #define GL_READ_BUFFER_NV 0x0C02 @@ -559,6 +872,36 @@ typedef struct __GLeglImageOES *GLeglImageOES; /* GL_NV_read_stencil */ /* No new tokens introduced by this extension. */ +/* GL_NV_shadow_samplers_array */ +#ifndef GL_NV_shadow_samplers_array +#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 +#endif + +/* GL_NV_shadow_samplers_cube */ +#ifndef GL_NV_shadow_samplers_cube +#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 +#endif + +/* GL_NV_sRGB_formats */ +#ifndef GL_NV_sRGB_formats +#define GL_SLUMINANCE_NV 0x8C46 +#define GL_SLUMINANCE_ALPHA_NV 0x8C44 +#define GL_SRGB8_NV 0x8C41 +#define GL_SLUMINANCE8_NV 0x8C47 +#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F +#define GL_ETC1_SRGB8_NV 0x88EE +#endif + +/* GL_NV_texture_border_clamp */ +#ifndef GL_NV_texture_border_clamp +#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 +#define GL_CLAMP_TO_BORDER_NV 0x812D +#endif + /* GL_NV_texture_compression_s3tc_update */ /* No new tokens introduced by this extension. */ @@ -576,6 +919,14 @@ typedef struct __GLeglImageOES *GLeglImageOES; #define GL_ALPHA_TEST_REF_QCOM 0x0BC2 #endif +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 +#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 +#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 +#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 +#endif + /* GL_QCOM_driver_control */ /* No new tokens introduced by this extension. */ @@ -746,6 +1097,11 @@ typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum #define GL_OES_packed_depth_stencil 1 #endif +/* GL_OES_required_internalformat */ +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#endif + /* GL_OES_rgb8_rgba8 */ #ifndef GL_OES_rgb8_rgba8 #define GL_OES_rgb8_rgba8 1 @@ -766,18 +1122,22 @@ typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum #define GL_OES_stencil4 1 #endif +#ifndef GL_OES_surfaceless_context +#define GL_OES_surfaceless_context 1 +#endif + /* GL_OES_texture_3D */ #ifndef GL_OES_texture_3D #define GL_OES_texture_3D 1 #ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); #endif -typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); @@ -835,6 +1195,43 @@ typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); #define GL_OES_vertex_type_10_10_10_2 1 #endif +/*------------------------------------------------------------------------* + * KHR extension functions + *------------------------------------------------------------------------*/ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void); +GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params); +#endif +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params); +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + + /*------------------------------------------------------------------------* * AMD extension functions *------------------------------------------------------------------------*/ @@ -887,6 +1284,11 @@ typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monito * ANGLE extension functions *------------------------------------------------------------------------*/ +/* GL_ANGLE_depth_texture */ +#ifndef GL_ANGLE_depth_texture +#define GL_ANGLE_depth_texture 1 +#endif + /* GL_ANGLE_framebuffer_blit */ #ifndef GL_ANGLE_framebuffer_blit #define GL_ANGLE_framebuffer_blit 1 @@ -905,13 +1307,62 @@ GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); #endif +#ifndef GL_ANGLE_instanced_arrays +#define GL_ANGLE_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); +#endif + +/* GL_ANGLE_pack_reverse_row_order */ +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_ANGLE_pack_reverse_row_order 1 +#endif + +/* GL_ANGLE_program_binary */ +#ifndef GL_ANGLE_program_binary +#define GL_ANGLE_program_binary 1 +#endif + +/* GL_ANGLE_texture_compression_dxt3 */ +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_ANGLE_texture_compression_dxt3 1 +#endif + +/* GL_ANGLE_texture_compression_dxt5 */ +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_ANGLE_texture_compression_dxt5 1 +#endif + +/* GL_ANGLE_texture_usage */ +#ifndef GL_ANGLE_texture_usage +#define GL_ANGLE_texture_usage 1 +#endif + +#ifndef GL_ANGLE_translated_shader_source +#define GL_ANGLE_translated_shader_source 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif +typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufsize, GLsizei *length, GLchar *source); +#endif + /*------------------------------------------------------------------------* * APPLE extension functions *------------------------------------------------------------------------*/ -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 +/* GL_APPLE_copy_texture_levels */ +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); #endif /* GL_APPLE_framebuffer_multisample */ @@ -925,6 +1376,32 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); #endif +/* GL_APPLE_rgb_422 */ +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +/* GL_APPLE_sync */ +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + /* GL_APPLE_texture_format_BGRA8888 */ #ifndef GL_APPLE_texture_format_BGRA8888 #define GL_APPLE_texture_format_BGRA8888 1 @@ -939,6 +1416,11 @@ typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); * ARM extension functions *------------------------------------------------------------------------*/ +/* GL_ARM_mali_program_binary */ +#ifndef GL_ARM_mali_program_binary +#define GL_ARM_mali_program_binary 1 +#endif + /* GL_ARM_mali_shader_binary */ #ifndef GL_ARM_mali_shader_binary #define GL_ARM_mali_shader_binary 1 @@ -996,6 +1478,53 @@ GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numA typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); #endif +#ifndef GL_EXT_disjoint_timer_query +#define GL_EXT_disjoint_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); +GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_EXT_disjoint_timer_query */ + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); +#endif +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); +#endif /* GL_EXT_draw_buffers */ + +/* GL_EXT_map_buffer_range */ +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void* GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +typedef void* (GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + /* GL_EXT_multisampled_render_to_texture */ #ifndef GL_EXT_multisampled_render_to_texture #define GL_EXT_multisampled_render_to_texture 1 @@ -1007,13 +1536,26 @@ typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum t typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif +/* GL_EXT_multiview_draw_buffers */ +#ifndef GL_EXT_multiview_draw_buffers +#define GL_EXT_multiview_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); +GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); +GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); +#endif +typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); +#endif + #ifndef GL_EXT_multi_draw_arrays #define GL_EXT_multi_draw_arrays 1 #ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, const GLint *, const GLsizei *, GLsizei); GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); #endif @@ -1125,6 +1667,11 @@ typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); #endif +/* GL_EXT_shader_framebuffer_fetch */ +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#endif + /* GL_EXT_shader_texture_lod */ #ifndef GL_EXT_shader_texture_lod #define GL_EXT_shader_texture_lod 1 @@ -1198,6 +1745,15 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum #define GL_DMP_shader_binary 1 #endif +/*------------------------------------------------------------------------* + * FJ extension functions + *------------------------------------------------------------------------*/ + +/* GL_FJ_shader_binary_GCCSO */ +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_FJ_shader_binary_GCCSO 1 +#endif + /*------------------------------------------------------------------------* * IMG extension functions *------------------------------------------------------------------------*/ @@ -1222,6 +1778,11 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum #define GL_IMG_texture_compression_pvrtc 1 #endif +/* GL_IMG_texture_compression_pvrtc2 */ +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_IMG_texture_compression_pvrtc2 1 +#endif + /* GL_IMG_multisampled_render_to_texture */ #ifndef GL_IMG_multisampled_render_to_texture #define GL_IMG_multisampled_render_to_texture 1 @@ -1229,8 +1790,8 @@ typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); #endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); #endif /*------------------------------------------------------------------------* @@ -1262,6 +1823,17 @@ GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); #endif +/* GL_NV_draw_instanced */ +#ifndef GL_NV_draw_instanced +#define GL_NV_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif +typedef void (GL_APIENTRYP PFNDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + /* GL_NV_fbo_color_attachments */ #ifndef GL_NV_fbo_color_attachments #define GL_NV_fbo_color_attachments 1 @@ -1288,6 +1860,38 @@ typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); #endif +/* GL_NV_framebuffer_blit */ +#ifndef GL_NV_framebuffer_blit +#define GL_NV_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferNV (int srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +typedef void (GL_APIENTRYP PFNBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +/* GL_NV_framebuffer_multisample */ +#ifndef GL_NV_framebuffer_multisample +#define GL_NV_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +typedef void (GL_APIENTRYP PFNRENDERBUFFERSTORAGEMULTISAMPLENVPROC) ( GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +/* GL_NV_generate_mipmap_sRGB */ +#ifndef GL_NV_generate_mipmap_sRGB +#define GL_NV_generate_mipmap_sRGB 1 +#endif + +/* GL_NV_instanced_arrays */ +#ifndef GL_NV_instanced_arrays +#define GL_NV_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); +#endif +typedef void (GL_APIENTRYP PFNVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); +#endif + /* GL_NV_read_buffer */ #ifndef GL_NV_read_buffer #define GL_NV_read_buffer 1 @@ -1317,6 +1921,26 @@ typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); #define GL_NV_read_stencil 1 #endif +/* GL_NV_shadow_samplers_array */ +#ifndef GL_NV_shadow_samplers_array +#define GL_NV_shadow_samplers_array 1 +#endif + +/* GL_NV_shadow_samplers_cube */ +#ifndef GL_NV_shadow_samplers_cube +#define GL_NV_shadow_samplers_cube 1 +#endif + +/* GL_NV_sRGB_formats */ +#ifndef GL_NV_sRGB_formats +#define GL_NV_sRGB_formats 1 +#endif + +/* GL_NV_texture_border_clamp */ +#ifndef GL_NV_texture_border_clamp +#define GL_NV_texture_border_clamp 1 +#endif + /* GL_NV_texture_compression_s3tc_update */ #ifndef GL_NV_texture_compression_s3tc_update #define GL_NV_texture_compression_s3tc_update 1 @@ -1340,6 +1964,11 @@ GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); #endif +/* GL_QCOM_binning_control */ +#ifndef GL_QCOM_binning_control +#define GL_QCOM_binning_control 1 +#endif + /* GL_QCOM_driver_control */ #ifndef GL_QCOM_driver_control #define GL_QCOM_driver_control 1 diff --git a/make/stub_includes/opengl/GLES3/gl3.h b/make/stub_includes/opengl/GLES3/gl3.h new file mode 100644 index 000000000..dc0409f54 --- /dev/null +++ b/make/stub_includes/opengl/GLES3/gl3.h @@ -0,0 +1,1073 @@ +#ifndef __gl3_h_ +#define __gl3_h_ + +/* + * gl3.h last updated on $Date: 2013-02-12 14:37:24 -0800 (Tue, 12 Feb 2013) $ + */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2013 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/*------------------------------------------------------------------------- + * Data type definitions + *-----------------------------------------------------------------------*/ + +/* OpenGL ES 2.0 */ + +typedef void GLvoid; +typedef char GLchar; +typedef unsigned int GLenum; +typedef unsigned char GLboolean; +typedef unsigned int GLbitfield; +typedef khronos_int8_t GLbyte; +typedef short GLshort; +typedef int GLint; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +typedef unsigned short GLushort; +typedef unsigned int GLuint; +typedef khronos_float_t GLfloat; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_intptr_t GLintptr; +typedef khronos_ssize_t GLsizeiptr; + +/* OpenGL ES 3.0 */ + +typedef unsigned short GLhalf; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; + +/*------------------------------------------------------------------------- + * Token definitions + *-----------------------------------------------------------------------*/ + +/* OpenGL ES 2.0 */ +#ifndef GL_ES_VERSION_2_0 + +/* ClearBufferMask */ +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 + +/* Boolean */ +#define GL_FALSE 0 +#define GL_TRUE 1 + +/* BeginMode */ +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 + +/* BlendingFactorDest */ +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 + +/* BlendingFactorSrc */ +/* GL_ZERO */ +/* GL_ONE */ +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +/* GL_SRC_ALPHA */ +/* GL_ONE_MINUS_SRC_ALPHA */ +/* GL_DST_ALPHA */ +/* GL_ONE_MINUS_DST_ALPHA */ + +/* BlendEquationSeparate */ +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ +#define GL_BLEND_EQUATION_ALPHA 0x883D + +/* BlendSubtract */ +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B + +/* Separate Blend Functions */ +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 + +/* Buffer Objects */ +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 + +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 + +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 + +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 + +/* CullFaceMode */ +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 + +/* DepthFunction */ +/* GL_NEVER */ +/* GL_LESS */ +/* GL_EQUAL */ +/* GL_LEQUAL */ +/* GL_GREATER */ +/* GL_NOTEQUAL */ +/* GL_GEQUAL */ +/* GL_ALWAYS */ + +/* EnableCap */ +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 + +/* ErrorCode */ +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 + +/* FrontFaceDirection */ +#define GL_CW 0x0900 +#define GL_CCW 0x0901 + +/* GetPName */ +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +/* GL_SCISSOR_TEST */ +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +/* GL_POLYGON_OFFSET_FILL */ +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB + +/* GetTextureParameter */ +/* GL_TEXTURE_MAG_FILTER */ +/* GL_TEXTURE_MIN_FILTER */ +/* GL_TEXTURE_WRAP_S */ +/* GL_TEXTURE_WRAP_T */ + +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 + +/* HintMode */ +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 + +/* HintTarget */ +#define GL_GENERATE_MIPMAP_HINT 0x8192 + +/* DataType */ +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C + +/* PixelFormat */ +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A + +/* PixelType */ +/* GL_UNSIGNED_BYTE */ +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 + +/* Shaders */ +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D + +/* StencilFunction */ +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 + +/* StencilOp */ +/* GL_ZERO */ +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 + +/* StringName */ +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 + +/* TextureMagFilter */ +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 + +/* TextureMinFilter */ +/* GL_NEAREST */ +/* GL_LINEAR */ +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 + +/* TextureParameterName */ +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 + +/* TextureTarget */ +/* GL_TEXTURE_2D */ +#define GL_TEXTURE 0x1702 + +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C + +/* TextureUnit */ +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 + +/* TextureWrapMode */ +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 + +/* Uniform Types */ +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 + +/* Vertex Arrays */ +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F + +/* Read Format */ +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B + +/* Shader Source */ +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA + +/* Shader Binary */ +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 + +/* Shader Precision-Specified Types */ +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 + +/* Framebuffer Object. */ +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 + +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 + +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 + +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 + +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 + +#define GL_NONE 0 + +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD + +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 + +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 + +#endif /* GL_ES_VERSION_2_0 */ + +/* OpenGL ES 3.0 */ +#ifndef GL_ES_VERSION_3_0 + +#define GL_READ_BUFFER 0x0C02 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_RED 0x1903 +#define GL_RGB8 0x8051 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_RG8 0x822B +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_COPY_READ_BUFFER_BINDING GL_COPY_READ_BUFFER +#define GL_COPY_WRITE_BUFFER_BINDING GL_COPY_WRITE_BUFFER +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF + +#endif /* GL_ES_VERSION_3_0 */ + +/* OpenGL ES 2.0 */ +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 + +/*------------------------------------------------------------------------- + * Entrypoint definitions + *-----------------------------------------------------------------------*/ + +/* OpenGL ES 2.0 */ + +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat depth); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat zNear, GLfloat zFar); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); +GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const* string, const GLint* length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); + +#endif /* GL_ES_VERSION_2_0 */ + +/* OpenGL ES 3.0 */ +#ifndef GL_ES_VERSION_3_0 +#define GL_ES_VERSION_3_0 1 + +GL_APICALL void GL_APIENTRY glReadBuffer (GLenum mode); +GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices); +GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); +GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint* ids); +GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint* ids); +GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQuery (GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint* params); +GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid** params); +GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum* bufs); +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); +GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GL_APICALL void* GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint* arrays); +GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint* arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint* data); +GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GL_APICALL void GL_APIENTRY glEndTransformFeedback (void); +GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode); +GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name); +GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); +GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint* params); +GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint* v); +GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint* v); +GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint* params); +GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint* value); +GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint* value); +GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint* value); +GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint* value); +GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint* value); +GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint* value); +GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat* value); +GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GL_APICALL const GLubyte* GL_APIENTRY glGetStringi (GLenum name, GLuint index); +GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices); +GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params); +GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar* uniformBlockName); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName); +GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instanceCount); +GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount); +GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64* params); +GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values); +GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64* data); +GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64* params); +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint* samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint* samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint* param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat* param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint* params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat* params); +GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint* ids); +GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint* ids); +GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id); +GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void); +GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void); +GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary); +GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length); +GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments); +GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params); + +#endif /* GL_ES_VERSION_3_0 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/make/stub_includes/opengl/GLES3/gl3ext.h b/make/stub_includes/opengl/GLES3/gl3ext.h new file mode 100644 index 000000000..4d4ea96c4 --- /dev/null +++ b/make/stub_includes/opengl/GLES3/gl3ext.h @@ -0,0 +1,24 @@ +#ifndef __gl3ext_h_ +#define __gl3ext_h_ + +/* $Revision: 17809 $ on $Date:: 2012-05-14 08:03:36 -0700 #$ */ + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* OpenGL ES 3 Extensions + * + * After an OES extension's interactions with OpenGl ES 3.0 have been documented, + * its tokens and function definitions should be added to this file in a manner + * that does not conflict with gl2ext.h or gl3.h. + * + * Tokens and function definitions for extensions that have become standard + * features in OpenGL ES 3.0 will not be added to this file. + * + * Applications using OpenGL-ES-2-only extensions should include gl2ext.h + */ + +#endif /* __gl3ext_h_ */ + diff --git a/make/stub_includes/opengl/GLES3/gl3platform.h b/make/stub_includes/opengl/GLES3/gl3platform.h new file mode 100644 index 000000000..1bd1a850f --- /dev/null +++ b/make/stub_includes/opengl/GLES3/gl3platform.h @@ -0,0 +1,30 @@ +#ifndef __gl3platform_h_ +#define __gl3platform_h_ + +/* $Revision: 18437 $ on $Date:: 2012-07-08 23:31:39 -0700 #$ */ + +/* + * This document is licensed under the SGI Free Software B License Version + * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . + */ + +/* Platform-specific types and definitions for OpenGL ES 3.X gl3.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) + * by filing a bug against product "OpenGL-ES" component "Registry". + */ + +#include + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __gl3platform_h_ */ diff --git a/make/stub_includes/opengl/GLES3/khrplatform.h b/make/stub_includes/opengl/GLES3/khrplatform.h new file mode 100644 index 000000000..8ec0d199f --- /dev/null +++ b/make/stub_includes/opengl/GLES3/khrplatform.h @@ -0,0 +1,269 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * $Revision: 9356 $ on $Date: 2009-10-21 02:52:25 -0700 (Wed, 21 Oct 2009) $ + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by sending them to the public Khronos Bugzilla + * (http://khronos.org/bugzilla) by filing a bug against product + * "Khronos (general)" component "Registry". + * + * A predefined template which fills in some of the bug fields can be + * reached using http://tinyurl.com/khrplatform-h-bugreport, but you + * must create a Bugzilla login first. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(_WIN32) && !defined(__SCITECH_SNAP__) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff --git a/make/stub_includes/opengl/gl-64bit-types.h b/make/stub_includes/opengl/gl-64bit-types.h deleted file mode 100644 index f40eeae55..000000000 --- a/make/stub_includes/opengl/gl-64bit-types.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef __gl_64bit_types_h_ -#define __gl_64bit_types_h_ - -#include - -#ifdef KHRONOS_SUPPORT_INT64 - - #ifndef GL_EXT_timer_query - typedef khronos_int64_t GLint64EXT; - typedef khronos_uint64_t GLuint64EXT; - #endif - - #ifndef GL_ARB_sync - typedef khronos_int64_t GLint64; - typedef khronos_uint64_t GLuint64; - typedef struct __GLsync *GLsync; - #endif - -#endif /* KHRONOS_SUPPORT_INT64 */ - -#endif /* __gl_64bit_types_h_ */ diff --git a/make/stub_includes/opengl/gl-types.h b/make/stub_includes/opengl/gl-types.h new file mode 100644 index 000000000..e7e869708 --- /dev/null +++ b/make/stub_includes/opengl/gl-types.h @@ -0,0 +1,15 @@ +#ifndef __gl_types_h_ +#define __gl_types_h_ + +#include + +#define GLEXT_64_TYPES_DEFINED 1 + +typedef khronos_int64_t GLint64EXT; +typedef khronos_uint64_t GLuint64EXT; + +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef struct __GLsync *GLsync; + +#endif /* __gl_types_h_ */ diff --git a/make/stub_includes/opengl/gl2es12.c b/make/stub_includes/opengl/gl2es12.c deleted file mode 100644 index 514393f0b..000000000 --- a/make/stub_includes/opengl/gl2es12.c +++ /dev/null @@ -1,9 +0,0 @@ -#define GLAPI - -// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -// "glext.h" are parsed. -#define GL_GLEXT_PROTOTYPES - -#include -#include - diff --git a/make/stub_includes/opengl/gl3.c b/make/stub_includes/opengl/gl3.c index ff035e40b..e145bf41d 100644 --- a/make/stub_includes/opengl/gl3.c +++ b/make/stub_includes/opengl/gl3.c @@ -1,13 +1,8 @@ #define GLAPI -// Define GL3_PROTOTYPES so that the OpenGL prototypes in -// "gl3.h" are parsed. -#define GL3_PROTOTYPES +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. +#define GL_GLEXT_PROTOTYPES -// Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -// "gl3ext.h" are parsed. -#define GL_GL3EXT_PROTOTYPES - -#include -#include +#include +#include diff --git a/make/stub_includes/opengl/gl3bc.c b/make/stub_includes/opengl/gl3bc.c index eed7c9c26..a40fe13c1 100644 --- a/make/stub_includes/opengl/gl3bc.c +++ b/make/stub_includes/opengl/gl3bc.c @@ -1,19 +1,10 @@ #define GLAPI -// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -// "glext.h" are parsed. +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. #define GL_GLEXT_PROTOTYPES #include #include -// Define GL3_PROTOTYPES so that the OpenGL prototypes in -// "gl3.h" are parsed. -#define GL3_PROTOTYPES - -// Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -// "gl3ext.h" are parsed. -#define GL_GL3EXT_PROTOTYPES - -#include +#include diff --git a/make/stub_includes/opengl/gl4.c b/make/stub_includes/opengl/gl4.c index 3a3adf0f4..e145bf41d 100644 --- a/make/stub_includes/opengl/gl4.c +++ b/make/stub_includes/opengl/gl4.c @@ -1,12 +1,8 @@ #define GLAPI -// Define GL3_PROTOTYPES so that the OpenGL prototypes in -// "gl3.h" are parsed. -#define GL3_PROTOTYPES +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. +#define GL_GLEXT_PROTOTYPES -// Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -// "gl3ext.h" are parsed. -#define GL_GL3EXT_PROTOTYPES +#include +#include -#include -#include diff --git a/make/stub_includes/opengl/gl4bc.c b/make/stub_includes/opengl/gl4bc.c index eed7c9c26..a40fe13c1 100644 --- a/make/stub_includes/opengl/gl4bc.c +++ b/make/stub_includes/opengl/gl4bc.c @@ -1,19 +1,10 @@ #define GLAPI -// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in -// "glext.h" are parsed. +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes are parsed. #define GL_GLEXT_PROTOTYPES #include #include -// Define GL3_PROTOTYPES so that the OpenGL prototypes in -// "gl3.h" are parsed. -#define GL3_PROTOTYPES - -// Define GL_GL3EXT_PROTOTYPES so that the OpenGL extension prototypes in -// "gl3ext.h" are parsed. -#define GL_GL3EXT_PROTOTYPES - -#include +#include diff --git a/make/stub_includes/opengl/gles3.c b/make/stub_includes/opengl/gles3.c new file mode 100644 index 000000000..3d2ad8c75 --- /dev/null +++ b/make/stub_includes/opengl/gles3.c @@ -0,0 +1,12 @@ +#define GL_APICALL +#define GL_APIENTRY + +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in +// "glext.h" are parsed. +#define GL_GLEXT_PROTOTYPES + +#include +#include + +/** We assume ES2 extensions maybe avail on ES3 .. */ +#include diff --git a/make/stub_includes/win32/windows.h b/make/stub_includes/win32/windows.h index 51ebbdcce..f7b141e31 100644 --- a/make/stub_includes/win32/windows.h +++ b/make/stub_includes/win32/windows.h @@ -46,4 +46,7 @@ typedef __int32 HRESULT; typedef HANDLE HPBUFFERARB; typedef HANDLE HPBUFFEREXT; typedef HANDLE HGPUNV; +typedef HANDLE HVIDEOOUTPUTDEVICENV; +typedef HANDLE HVIDEOINPUTDEVICENV; +typedef HANDLE HPVIDEODEV; diff --git a/make/stub_includes/x11/window-system1.c b/make/stub_includes/x11/window-system1.c index e718aee97..a06f39dae 100644 --- a/make/stub_includes/x11/window-system1.c +++ b/make/stub_includes/x11/window-system1.c @@ -1,6 +1,6 @@ -// Define GLX_GLXEXT_PROTOTYPES so that the OpenGL GLX extension prototypes in -// "glxext.h" are parsed. -#define GLX_GLXEXT_PROTOTYPES +// Define GL_GLEXT_PROTOTYPES so that the OpenGL extension prototypes in +// "glext.h" are parsed. +#define GL_GLEXT_PROTOTYPES #include #include diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 5334d45cf..b9096df3c 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -71,7 +71,7 @@ public class BuildComposablePipeline { // Only desktop OpenGL has immediate mode glBegin / glEnd private boolean hasImmediateMode; // Desktop OpenGL and GLES1 have GL_STACK_OVERFLOW and GL_STACK_UNDERFLOW errors - private boolean hasStackOverflow; + private boolean hasGL2ES1StackOverflow; public static Class getClass(String name) { Class clazz = null; @@ -155,7 +155,7 @@ public class BuildComposablePipeline { } try { - hasStackOverflow = + hasGL2ES1StackOverflow = hasImmediateMode && (classToComposeAround.getField("GL_STACK_OVERFLOW") != null); } catch (Exception e) { } @@ -602,13 +602,9 @@ public class BuildComposablePipeline { * Emits one of the isGL* methods. */ protected void emitGLIsMethod(PrintWriter output, String type) { + output.println(" @Override"); output.println(" public boolean is" + type + "() {"); - Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); - if (clazz.isAssignableFrom(baseInterfaceClass)) { - output.println(" return true;"); - } else { - output.println(" return false;"); - } + output.println(" return " + getDownstreamObjectName() + ".is" + type + "();"); output.println(" }"); } @@ -624,28 +620,24 @@ public class BuildComposablePipeline { emitGLIsMethod(output, "GL2"); emitGLIsMethod(output, "GLES1"); emitGLIsMethod(output, "GLES2"); + emitGLIsMethod(output, "GLES3"); emitGLIsMethod(output, "GL2ES1"); emitGLIsMethod(output, "GL2ES2"); + emitGLIsMethod(output, "GL3ES3"); + emitGLIsMethod(output, "GL4ES3"); emitGLIsMethod(output, "GL2GL3"); - output.println(" public boolean isGLES() {"); - output.println(" return isGLES2() || isGLES1();"); - output.println(" }"); - output.println(" public boolean isGLES2Compatible() {"); - output.println(" return " + getDownstreamObjectName() + ".isGLES2Compatible();"); - output.println(" }"); + emitGLIsMethod(output, "GLES"); + emitGLIsMethod(output, "GLES2Compatible"); + emitGLIsMethod(output, "GLES3Compatible"); } /** * Emits one of the getGL* methods. */ protected void emitGLGetMethod(PrintWriter output, String type) { + output.println(" @Override"); output.println(" public javax.media.opengl." + type + " get" + type + "() {"); - Class clazz = BuildComposablePipeline.getClass("javax.media.opengl." + type); - if (clazz.isAssignableFrom(baseInterfaceClass)) { - output.println(" return this;"); - } else { - output.println(" throw new GLException(\"Not a " + type + " implementation\");"); - } + output.println(" return " + getDownstreamObjectName() + ".get" + type + "();"); output.println(" }"); } @@ -661,9 +653,13 @@ public class BuildComposablePipeline { emitGLGetMethod(output, "GL2"); emitGLGetMethod(output, "GLES1"); emitGLGetMethod(output, "GLES2"); + emitGLGetMethod(output, "GLES3"); emitGLGetMethod(output, "GL2ES1"); emitGLGetMethod(output, "GL2ES2"); + emitGLGetMethod(output, "GL3ES3"); + emitGLGetMethod(output, "GL4ES3"); emitGLGetMethod(output, "GL2GL3"); + output.println(" @Override"); output.println(" public GLProfile getGLProfile() {"); output.println(" return " + getDownstreamObjectName() + ".getGLProfile();"); output.println(" }"); @@ -870,9 +866,9 @@ public class BuildComposablePipeline { output.println(" case GL_INVALID_ENUM: buf.append(\"GL_INVALID_ENUM \"); break;"); output.println(" case GL_INVALID_VALUE: buf.append(\"GL_INVALID_VALUE \"); break;"); output.println(" case GL_INVALID_OPERATION: buf.append(\"GL_INVALID_OPERATION \"); break;"); - if (hasStackOverflow) { - output.println(" case GL_STACK_OVERFLOW: buf.append(\"GL_STACK_OVERFLOW \"); break;"); - output.println(" case GL_STACK_UNDERFLOW: buf.append(\"GL_STACK_UNDERFLOW \"); break;"); + if (hasGL2ES1StackOverflow) { + output.println(" case GL2ES1.GL_STACK_OVERFLOW: buf.append(\"GL_STACK_OVERFLOW \"); break;"); + output.println(" case GL2ES1.GL_STACK_UNDERFLOW: buf.append(\"GL_STACK_UNDERFLOW \"); break;"); } output.println(" case GL_OUT_OF_MEMORY: buf.append(\"GL_OUT_OF_MEMORY \"); break;"); output.println(" case GL_NO_ERROR: throw new InternalError(\"Should not be treating GL_NO_ERROR as error\");"); diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java index 482d35cae..5298cc357 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildStaticGLInfo.java @@ -106,14 +106,21 @@ import java.util.regex.Pattern; public class BuildStaticGLInfo { // Handles function pointer - protected static int funcIdentifierGroup = 10; + protected static final int funcIdentifierGroup = 9; protected static Pattern funcPattern = - Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)((unsigned|const)\\s+)?(\\w+)(\\s*\\*)?(\\s+)(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)"); + Pattern.compile("^(GLAPI|GL_API|GL_APICALL|EGLAPI|extern)?(\\s*)((unsigned|const)\\s+)?(\\w+)(\\s+\\*\\s*|\\s*\\*\\s+|\\s+)?(GLAPIENTRY|GL_APIENTRY|APIENTRY|EGLAPIENTRY|WINAPI)?(\\s*)([ew]?gl\\w+)\\s?(\\(.*)"); protected static Pattern associationPattern = Pattern.compile("\\#ifndef ([CEW]?GL[XU]?_[A-Za-z0-9_]+)(.*)"); - protected static int defineIdentifierGroup = 1; + protected static Pattern ifPattern = + Pattern.compile("\\#if(.*)"); + protected static Pattern elsePattern = + Pattern.compile("\\#(elif|else)(.*)"); + protected static Pattern endifPattern = + Pattern.compile("\\#endif(.*)"); + + protected static final int defineIdentifierGroup = 1; protected static Pattern definePattern = Pattern.compile("\\#define ([CEW]?GL[XU]?_[A-Za-z0-9_]+)\\s*([A-Za-z0-9_]+)(.*)"); @@ -194,38 +201,62 @@ public class BuildStaticGLInfo { BufferedReader reader = new BufferedReader(new FileReader(cHeaderFilePath)); String line, activeAssociation = null; Matcher m = null; + int block = 0; while ((line = reader.readLine()) != null) { - int type = 0; // 1-define, 2-function - // see if we're inside a #ifndef GL_XXX block and matching a function - if (activeAssociation != null) { + int type = 0; // 1-define, 2-function + if ( 0 < block ) { // inside a #ifndef GL_XXX block and matching a function, if block > 0 String identifier = null; - if ((m = funcPattern.matcher(line)).matches()) { - identifier = m.group(funcIdentifierGroup).trim(); - type = 2; - } else if ((m = definePattern.matcher(line)).matches()) { - identifier = m.group(defineIdentifierGroup).trim(); - type = 1; - } else if (line.startsWith("#endif")) { - if (DEBUG) { - System.err.println("END ASSOCIATION BLOCK: <" + activeAssociation + ">"); + if( 2 >= block ) { // not within sub-blocks > 2, i.e. further typedefs + if ((m = funcPattern.matcher(line)).matches()) { + identifier = m.group(funcIdentifierGroup).trim(); + type = 2; + } else if ((m = definePattern.matcher(line)).matches()) { + identifier = m.group(defineIdentifierGroup).trim(); + type = 1; } - activeAssociation = null; } - if ((identifier != null) - && (activeAssociation != null) - && // Handles #ifndef GL_... #define GL_... - !identifier.equals(activeAssociation)) { + if ( identifier != null && + activeAssociation != null && + !identifier.equals(activeAssociation) // Handles #ifndef GL_... #define GL_... + ) + { addAssociation(identifier, activeAssociation); if (DEBUG) { - System.err.println(" ADDING ASSOCIATION: <" + identifier + "> <" + activeAssociation + "> ; type " + type); + System.err.println("<"+block+"> ADDING ASSOCIATION: <" + identifier + "> <" + activeAssociation + "> ; type " + type); + } + } else { + if ((m = ifPattern.matcher(line)).matches()) { + final String comment = m.group(1).trim(); + block++; + if (DEBUG) { + System.err.println("<"+block+"> BEGIN IF BLOCK: <" + comment + ">"); + } + } else if ((m = elsePattern.matcher(line)).matches()) { + final String comment = m.group(1).trim(); + if (DEBUG) { + System.err.println("<"+block+"> ELSE BLOCK: <" + comment + ">"); + } + } else if ((m = endifPattern.matcher(line)).matches()) { + final String comment = m.group(1).trim(); + block--; + if( 0 == block ) { + if (DEBUG) { + System.err.println("<"+block+"> END ASSOCIATION BLOCK: <" + activeAssociation + " <-> " + comment + ">"); + } + activeAssociation = null; + } else { + if (DEBUG) { + System.err.println("<"+block+"> END IF BLOCK: <" + comment + ">"); + } + } } } - } else if ((m = associationPattern.matcher(line)).matches()) { + } else if ((m = associationPattern.matcher(line)).matches()) { // found a new #ifndef GL_XXX block activeAssociation = m.group(1).trim(); - + block++; if (DEBUG) { - System.err.println("BEGIN ASSOCIATION BLOCK: <" + activeAssociation + ">"); + System.err.println("<"+block+"> BEGIN ASSOCIATION BLOCK: <" + activeAssociation + ">"); } } } diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java index ba025e18c..d4dca715b 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLConfiguration.java @@ -61,6 +61,7 @@ public class GLConfiguration extends ProcAddressConfiguration { // The following data members support ignoring an entire extension at a time private List glHeaders = new ArrayList(); private Set ignoredExtensions = new HashSet(); + private Set forcedExtensions = new HashSet(); private Set extensionsRenamedIntoCore = new HashSet(); private BuildStaticGLInfo glInfo; @@ -90,6 +91,9 @@ public class GLConfiguration extends ProcAddressConfiguration { if (cmd.equalsIgnoreCase("IgnoreExtension")) { String sym = readString("IgnoreExtension", tok, filename, lineNo); ignoredExtensions.add(sym); + } else if (cmd.equalsIgnoreCase("ForceExtension")) { + String sym = readString("ForceExtension", tok, filename, lineNo); + forcedExtensions.add(sym); } else if (cmd.equalsIgnoreCase("RenameExtensionIntoCore")) { String sym = readString("RenameExtensionIntoCore", tok, filename, lineNo); extensionsRenamedIntoCore.add(sym); @@ -202,16 +206,21 @@ public class GLConfiguration extends ProcAddressConfiguration { for (String str : ignoredExtensions) { System.err.println("\t" + str); } + System.err.println("GL Forced extensions: "); + for (String str : forcedExtensions) { + System.err.println("\t" + str); + } super.dumpIgnores(); } protected boolean shouldIgnoreExtension(String symbol, boolean criteria) { if (criteria && glInfo != null) { - Set extensionNames = glInfo.getExtension(symbol); - if(null!=extensionNames) { - for(Iterator i=extensionNames.iterator(); i.hasNext(); ) { - String extensionName = i.next(); - if (extensionName != null && ignoredExtensions.contains(extensionName)) { + final Set extensionNames = glInfo.getExtension(symbol); + if( null != extensionNames ) { + boolean ignoredExtension = false; + for(Iterator i=extensionNames.iterator(); !ignoredExtension && i.hasNext(); ) { + final String extensionName = i.next(); + if ( extensionName != null && ignoredExtensions.contains(extensionName) ) { if (DEBUG_IGNORES) { System.err.print("Ignore symbol <" + symbol + "> of extension <" + extensionName + ">"); if(extensionNames.size()==1) { @@ -220,9 +229,26 @@ public class GLConfiguration extends ProcAddressConfiguration { System.err.println(", WARNING MULTIPLE OCCURENCE: "+extensionNames); } } - return true; + ignoredExtension = true; + } + } + if( ignoredExtension ) { + ignoredExtension = !shouldForceExtension( symbol, true, symbol ); + if( ignoredExtension ) { + final Set origSymbols = getRenamedJavaSymbols( symbol ); + if(null != origSymbols) { + for(String origSymbol : origSymbols) { + if( shouldForceExtension( origSymbol, true, symbol ) ) { + ignoredExtension = false; + break; + } + } + } } } + if( ignoredExtension ) { + return true; + } } boolean isGLEnum = GLNameResolver.isGLEnumeration(symbol); boolean isGLFunc = GLNameResolver.isGLFunction(symbol); @@ -240,6 +266,29 @@ public class GLConfiguration extends ProcAddressConfiguration { } return false; } + + public boolean shouldForceExtension(final String symbol, final boolean criteria, final String renamedSymbol) { + if (criteria && glInfo != null) { + final Set extensionNames = glInfo.getExtension(symbol); + if( null != extensionNames ) { + for(Iterator i=extensionNames.iterator(); i.hasNext(); ) { + final String extensionName = i.next(); + if ( extensionName != null && forcedExtensions.contains(extensionName) ) { + if (DEBUG_IGNORES) { + System.err.print("Not Ignore symbol <" + symbol + " -> " + renamedSymbol + "> of extension <" + extensionName + ">"); + if(extensionNames.size()==1) { + System.err.println(", single ."); + } else { + System.err.println(", WARNING MULTIPLE OCCURENCE: "+extensionNames); + } + } + return true; + } + } + } + } + return false; + } @Override public boolean shouldIgnoreInInterface(String symbol) { diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java index 016674338..fdfaee8a6 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/GLJavaMethodBindingEmitter.java @@ -43,6 +43,7 @@ import com.jogamp.gluegen.CommentEmitter; import com.jogamp.gluegen.JavaEmitter; import com.jogamp.gluegen.JavaMethodBindingEmitter; import com.jogamp.gluegen.MethodBinding; +import com.jogamp.gluegen.cgram.types.FunctionSymbol; import com.jogamp.gluegen.cgram.types.Type; import com.jogamp.gluegen.procaddress.ProcAddressJavaMethodBindingEmitter; @@ -103,11 +104,14 @@ public class GLJavaMethodBindingEmitter extends ProcAddressJavaMethodBindingEmit @Override protected void emitBindingCSignature(MethodBinding binding, PrintWriter writer) { - super.emitBindingCSignature(binding, writer); - String symbolRenamed = binding.getName(); StringBuilder newComment = new StringBuilder(); + final FunctionSymbol funcSym = binding.getCSymbol(); + writer.print(" "); + writer.print(funcSym.getType().toString(symbolRenamed, tagNativeBinding)); + writer.print(" "); + newComment.append("
    Part of "); if (0 == glEmitter.addExtensionsOfSymbols2Buffer(newComment, ", ", "; ", symbolRenamed, binding.getAliasedNames())) { if (glEmitter.getGLConfig().getAllowNonGLExtensions()) { diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java index c0666d153..14f4be96a 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java +++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java @@ -51,6 +51,7 @@ public class GLExtensions { public static final String NV_fbo_color_attachments = "GL_NV_fbo_color_attachments"; public static final String ARB_ES2_compatibility = "GL_ARB_ES2_compatibility"; + public static final String ARB_ES3_compatibility = "GL_ARB_ES3_compatibility"; public static final String EXT_abgr = "GL_EXT_abgr"; public static final String OES_rgb8_rgba8 = "GL_OES_rgb8_rgba8"; @@ -69,7 +70,7 @@ public class GLExtensions { public static final String NV_texture_compression_vtc = "GL_NV_texture_compression_vtc"; public static final String SGIS_generate_mipmap = "GL_SGIS_generate_mipmap"; public static final String OES_read_format = "GL_OES_read_format"; - + public static final String OES_single_precision = "GL_OES_single_precision"; public static final String OES_EGL_image_external = "GL_OES_EGL_image_external"; public static final String ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64"; diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index 74c1b9609..49c5bf72d 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -130,6 +130,16 @@ public interface GLBase { */ public boolean isGLES2(); + /** + * Indicates whether this GL object conforms to the OpenGL ES2 ≥ 3.0 profile. + *

    + * Remark: ES3 compatible desktop profiles are not included. + * To query whether core ES3 functionality is provided, use {@link #isGLES3Compatible()}. + *

    + * @see #isGLES3Compatible() + */ + public boolean isGLES3(); + /** * Indicates whether this GL object conforms to one of the OpenGL ES profiles, * see {@link #isGLES1()} and {@link #isGLES2()}. @@ -146,6 +156,21 @@ public interface GLBase { */ public boolean isGL2ES2(); + /** + * Indicates whether this GL object conforms to a GL3ES3 compatible profile. + */ + public boolean isGL3ES3(); + + /** + * Indicates whether this GL object conforms to a GL4ES3 compatible profile. + */ + public boolean isGL4ES3(); + + /** + * Indicates whether this GL object conforms to a GL2GL3 compatible profile. + */ + public boolean isGL2GL3(); + /** * Indicates whether this GL object is compatible with the core OpenGL ES2 functionality. * @return true if this context is an ES2 context or implements @@ -154,9 +179,11 @@ public interface GLBase { public boolean isGLES2Compatible(); /** - * Indicates whether this GL object conforms to a GL2GL3 compatible profile. + * Indicates whether this GL object is compatible with the core OpenGL ES3 functionality. + * @return true if this context is an ES3 context or implements + * the extension GL_ARB_ES3_compatibility, otherwise false */ - public boolean isGL2GL3(); + public boolean isGLES3Compatible(); /** Indicates whether this GL object supports GLSL. */ public boolean hasGLSL(); @@ -209,6 +236,12 @@ public interface GLBase { */ public GLES2 getGLES2() throws GLException; + /** + * Casts this object to the GLES3 interface. + * @throws GLException if this GLObject is not a GLES3 implementation + */ + public GLES3 getGLES3() throws GLException; + /** * Casts this object to the GL2ES1 interface. * @throws GLException if this GLObject is not a GL2ES1 implementation @@ -221,6 +254,18 @@ public interface GLBase { */ public GL2ES2 getGL2ES2() throws GLException; + /** + * Casts this object to the GL3ES3 interface. + * @throws GLException if this GLObject is not a GL3ES3 implementation + */ + public GL3ES3 getGL3ES3() throws GLException; + + /** + * Casts this object to the GL4ES3 interface. + * @throws GLException if this GLObject is not a GL3ES3 implementation + */ + public GL4ES3 getGL4ES3() throws GLException; + /** * Casts this object to the GL2GL3 interface. * @throws GLException if this GLObject is not a GL2GL3 implementation diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index daede5ac0..b27db18af 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -142,6 +142,13 @@ public abstract class GLContext { protected static final VersionNumber Version800 = new VersionNumber(8, 0, 0); + // + // Cached keys, bits [0..15] + // + + /** Cached bit mask covering bits [0..15], i.e. {@value}. */ + protected static final int CTX_IMPL_CACHE_MASK = 0x0000FFFF; + /** ARB_create_context related: created via ARB_create_context. Cache key value. See {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ protected static final int CTX_IS_ARB_CREATED = 1 << 0; /** ARB_create_context related: desktop compatibility profile. Cache key value. See {@link #isGLCompatibilityProfile()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ @@ -154,20 +161,36 @@ public abstract class GLContext { protected static final int CTX_OPTION_FORWARD = 1 << 4; /** ARB_create_context related: flag debug. Cache key value. See {@link #setContextCreationFlags(int)}, {@link GLAutoDrawable#setContextCreationFlags(int)}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ public static final int CTX_OPTION_DEBUG = 1 << 5; + /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ + protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 6; + // + // Non cached keys, bits [16..31] + // + /** GL_ARB_ES2_compatibility implementation related: Context is compatible w/ ES2. Not a cache key. See {@link #isGLES2Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ - protected static final int CTX_IMPL_ES2_COMPAT = 1 << 8; + protected static final int CTX_IMPL_ES2_COMPAT = 1 << 16; - /** Context supports basic FBO, details see {@link #hasBasicFBOSupport()}. + /** GL_ARB_ES3_compatibility implementation related: Context is compatible w/ ES3. Not a cache key. See {@link #isGLES3Compatible()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ + protected static final int CTX_IMPL_ES3_COMPAT = 1 << 17; + + /** + * Context supports basic FBO, details see {@link #hasBasicFBOSupport()}. * Not a cache key. * @see #hasBasicFBOSupport() * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) */ - protected static final int CTX_IMPL_FBO = 1 << 9; - - /** Context uses software rasterizer, otherwise hardware rasterizer. Cache key value. See {@link #isHardwareRasterizer()}, {@link #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile)}. */ - protected static final int CTX_IMPL_ACCEL_SOFT = 1 << 15; + protected static final int CTX_IMPL_FBO = 1 << 18; + /** + * Context supports OES_single_precision, fp32, fixed function point (FFP) compatibility entry points, + * see {@link #hasFP32CompatAPI()}. + * Not a cache key. + * @see #hasFP32CompatAPI() + * @see #getAvailableContextProperties(AbstractGraphicsDevice, GLProfile) + */ + protected static final int CTX_IMPL_FP32_COMPAT_API = 1 << 19; + private static final ThreadLocal currentContext = new ThreadLocal(); private final HashMap attachedObjects = new HashMap(); @@ -778,10 +801,18 @@ public abstract class GLContext { /** * @return true if this context is an ES2 context or implements - * the extension GL_ARB_ES2_compatibility, otherwise false + * the extension GL_ARB_ES3_compatibility or GL_ARB_ES2_compatibility, otherwise false */ public final boolean isGLES2Compatible() { - return 0 != ( ctxOptions & CTX_IMPL_ES2_COMPAT ) ; + return 0 != ( ctxOptions & ( CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ) ) ; + } + + /** + * @return true if this context is an ES3 context or implements + * the extension GL_ARB_ES3_compatibility, otherwise false + */ + public final boolean isGLES3Compatible() { + return 0 != ( ctxOptions & CTX_IMPL_ES3_COMPAT ) ; } /** @@ -819,6 +850,15 @@ public abstract class GLContext { return 0 != ( ctxOptions & CTX_IMPL_FBO ) ; } + /** + * Returns true if OES_single_precision, fp32, fixed function point (FFP) compatibility entry points available, + * otherwise false. + * @see #CTX_IMPL_FP32_COMPAT_API + */ + public final boolean hasFP32CompatAPI() { + return 0 != ( ctxOptions & CTX_IMPL_FP32_COMPAT_API ) ; + } + /** * Returns true if full FBO support is available, otherwise false. *

    @@ -895,28 +935,30 @@ public abstract class GLContext { /** @see GLProfile#isGL3bc() */ public final boolean isGL3bc() { - return ctxVersion.compareTo(Version310) >= 0 - && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & CTX_PROFILE_COMPAT); + return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && + 0 != (ctxOptions & CTX_PROFILE_COMPAT) && + ctxVersion.compareTo(Version310) >= 0 ; } /** @see GLProfile#isGL3() */ public final boolean isGL3() { - return ctxVersion.compareTo(Version310) >= 0 - && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)); + return 0 != (ctxOptions & CTX_IS_ARB_CREATED) && + 0 != (ctxOptions & (CTX_PROFILE_COMPAT|CTX_PROFILE_CORE)) && + ctxVersion.compareTo(Version310) >= 0 ; } - /** Indicates whether this profile is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1

    Includes [ GL4, GL3 ].

    */ + /** Indicates whether this profile is capable of GL3 (core only). GL3 starts w/ OpenGL 3.1

    Includes [ GL4, GL3, GLES3 ].

    */ public final boolean isGL3core() { - return ctxVersion.compareTo(Version310) >= 0 - && 0 != (ctxOptions & CTX_IS_ARB_CREATED) - && 0 != (ctxOptions & CTX_PROFILE_CORE); + return ( 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ) || + ( 0 != ( ctxOptions & CTX_IS_ARB_CREATED ) && + 0 != ( ctxOptions & CTX_PROFILE_CORE ) && + ctxVersion.compareTo(Version310) >= 0 + ) ; } /** @see GLProfile#isGL2() */ public final boolean isGL2() { - return ctxVersion.getMajor()>=1 && 0!=(ctxOptions & CTX_PROFILE_COMPAT); + return 0 != ( ctxOptions & CTX_PROFILE_COMPAT ) && ctxVersion.getMajor()>=1 ; } /** @see GLProfile#isGL2GL3() */ @@ -926,12 +968,17 @@ public abstract class GLContext { /** @see GLProfile#isGLES1() */ public final boolean isGLES1() { - return ctxVersion.getMajor() == 1 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; + return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 1 ; } /** @see GLProfile#isGLES2() */ public final boolean isGLES2() { - return ctxVersion.getMajor() == 2 && 0 != ( ctxOptions & CTX_PROFILE_ES ) ; + return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 2 ; + } + + /** @see GLProfile#isGLES3() */ + public final boolean isGLES3() { + return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ; } /** @see GLProfile#isGLES() */ @@ -941,12 +988,22 @@ public abstract class GLContext { /** @see GLProfile#isGL2ES1() */ public final boolean isGL2ES1() { - return isGL2() || isGLES1() ; + return isGLES1() || isGL2(); } /** @see GLProfile#isGL2ES2() */ public final boolean isGL2ES2() { - return isGL2GL3() || isGLES2() ; + return isGLES2() || isGL2GL3(); + } + + /** @see GLProfile#isGL3ES3() */ + public final boolean isGL3ES3() { + return isGL4ES3() || isGL3(); + } + + /** @see GLProfile#isGL4ES3() */ + public final boolean isGL4ES3() { + return isGL4() || isGLES3() ; } /** @@ -1157,45 +1214,73 @@ public abstract class GLContext { /* 1.*/ { 0, 1, 2, 3, 4, 5 }, /* 2.*/ { 0, 1 }, /* 3.*/ { 0, 1, 2, 3 }, - /* 4.*/ { 0, 1, 2 } }; // FIXME add 4.3 ! + /* 4.*/ { 0, 1, 2, 3 } }; - private static final int GL_VERSIONS_VALID[][] = { + public static final int ES_VERSIONS[][] = { /* 0.*/ { -1 }, - /* 1.*/ { 0, 1, 2, 3, 4, 5 }, - /* 2.*/ { 0, 1 }, - /* 3.*/ { 0, 1, 2, 3 }, - /* 4.*/ { 0, 1, 2, 3, 4 } }; // 4.4 coming up soon ? + /* 1.*/ { 0, 1 }, + /* 2.*/ { 0 }, + /* 3.*/ { 0 } }; - public static final int getMaxMajor() { - return GL_VERSIONS.length-1; + public static final int getMaxMajor(int ctxProfile) { + return ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ? ES_VERSIONS.length-1 : GL_VERSIONS.length-1; } - public static final int getMaxMinor(int major) { - if(1>major || major>=GL_VERSIONS.length) return -1; - return GL_VERSIONS[major].length-1; + public static final int getMaxMinor(int ctxProfile, int major) { + if( 1>major ) { + return -1; + } + if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { + if( major>=ES_VERSIONS.length ) return -1; + return ES_VERSIONS[major].length-1; + } else { + if( major>=GL_VERSIONS.length ) return -1; + return GL_VERSIONS[major].length-1; + } } - public static final boolean isValidGLVersion(int major, int minor) { - if(1>major || major>=GL_VERSIONS_VALID.length) return false; - if(0>minor || minor>=GL_VERSIONS_VALID[major].length) return false; + public static final boolean isValidGLVersion(int ctxProfile, int major, int minor) { + if( 1>major || 0>minor ) { + return false; + } + if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { + if( major>=ES_VERSIONS.length) return false; + if( minor>=ES_VERSIONS[major].length) return false; + } else { + if( major>=GL_VERSIONS.length) return false; + if( minor>=GL_VERSIONS[major].length) return false; + } return true; } - public static final boolean decrementGLVersion(int major[], int minor[]) { + public static final boolean decrementGLVersion(int ctxProfile, int major[], int minor[]) { if(null==major || major.length<1 ||null==minor || minor.length<1) { throw new GLException("invalid array arguments"); } int m = major[0]; int n = minor[0]; - if(!isValidGLVersion(m, n)) return false; + if( !isValidGLVersion(ctxProfile, m, n) ) { + return false; + } // decrement .. n -= 1; if(n < 0) { - m -= 1; - n = GL_VERSIONS[m].length-1; + if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { + if( m >= 3) { + m -= 1; + } else { + m = 0; // major decr [1,2] -> 0 + } + n = ES_VERSIONS[m].length-1; + } else { + m -= 1; + n = GL_VERSIONS[m].length-1; + } + } + if( !isValidGLVersion(ctxProfile, m, n) ) { + return false; } - if(!isValidGLVersion(m, n)) return false; major[0]=m; minor[0]=n; @@ -1299,9 +1384,9 @@ public abstract class GLContext { } } - protected static StringBuffer dumpAvailableGLVersions(StringBuffer sb) { + protected static StringBuilder dumpAvailableGLVersions(StringBuilder sb) { if(null == sb) { - sb = new StringBuffer(); + sb = new StringBuilder(); } synchronized(deviceVersionAvailable) { final Set keys = deviceVersionAvailable.keySet(); @@ -1524,6 +1609,10 @@ public abstract class GLContext { return isGLVersionAvailable(device, 2, GLContext.CTX_PROFILE_ES, isHardware); } + public static boolean isGLES3Available(AbstractGraphicsDevice device, boolean isHardware[]) { + return isGLVersionAvailable(device, 3, GLContext.CTX_PROFILE_ES, isHardware); + } + public static boolean isGL4bcAvailable(AbstractGraphicsDevice device, boolean isHardware[]) { return isGLVersionAvailable(device, 4, CTX_PROFILE_COMPAT, isHardware); } @@ -1552,13 +1641,15 @@ public abstract class GLContext { sb.append(minor); sb.append(" ("); needColon = appendString(sb, "ES profile", needColon, 0 != ( CTX_PROFILE_ES & ctp )); - needColon = appendString(sb, "Compatibility profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp )); + needColon = appendString(sb, "Compat profile", needColon, 0 != ( CTX_PROFILE_COMPAT & ctp )); needColon = appendString(sb, "Core profile", needColon, 0 != ( CTX_PROFILE_CORE & ctp )); needColon = appendString(sb, "forward", needColon, 0 != ( CTX_OPTION_FORWARD & ctp )); needColon = appendString(sb, "arb", needColon, 0 != ( CTX_IS_ARB_CREATED & ctp )); needColon = appendString(sb, "debug", needColon, 0 != ( CTX_OPTION_DEBUG & ctp )); - needColon = appendString(sb, "ES2 compatible", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp )); + needColon = appendString(sb, "ES2 compat", needColon, 0 != ( CTX_IMPL_ES2_COMPAT & ctp )); + needColon = appendString(sb, "ES3 compat", needColon, 0 != ( CTX_IMPL_ES3_COMPAT & ctp )); needColon = appendString(sb, "FBO", needColon, 0 != ( CTX_IMPL_FBO & ctp )); + needColon = appendString(sb, "FP32 compat-api", needColon, 0 != ( CTX_IMPL_FP32_COMPAT_API & ctp )); if( 0 != ( CTX_IMPL_ACCEL_SOFT & ctp ) ) { needColon = appendString(sb, "software", needColon, true); } else { diff --git a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java index 3ab0683c6..f8959e653 100644 --- a/src/jogl/classes/javax/media/opengl/GLDebugMessage.java +++ b/src/jogl/classes/javax/media/opengl/GLDebugMessage.java @@ -73,8 +73,8 @@ public class GLDebugMessage { // AMD category == ARB source/type switch(amdDbgCategory) { case GL2GL3.GL_DEBUG_CATEGORY_API_ERROR_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_API_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_ERROR_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_API; + dbgType = GL2GL3.GL_DEBUG_TYPE_ERROR; break; // @@ -82,18 +82,18 @@ public class GLDebugMessage { // case GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; case GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; case GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_APPLICATION; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; break; @@ -102,24 +102,24 @@ public class GLDebugMessage { // case GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR; break; case GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR; break; case GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_PERFORMANCE_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_PERFORMANCE; break; case GL2GL3.GL_DEBUG_CATEGORY_OTHER_AMD: default: - dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB; - dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER_ARB; + dbgSource = GL2GL3.GL_DEBUG_SOURCE_OTHER; + dbgType = GL2GL3.GL_DEBUG_TYPE_OTHER; } return new GLDebugMessage(source, when, dbgSource, dbgType, dbgId, dbgSeverity, dbgMsg); @@ -127,24 +127,24 @@ public class GLDebugMessage { public static int translateARB2AMDCategory(int dbgSource, int dbgType) { switch (dbgSource) { - case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: + case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return GL2GL3.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD; - case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return GL2GL3.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD; - case GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB: + case GL2GL3.GL_DEBUG_SOURCE_APPLICATION: return GL2GL3.GL_DEBUG_CATEGORY_APPLICATION_AMD; } switch(dbgType) { - case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: + case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return GL2GL3.GL_DEBUG_CATEGORY_DEPRECATION_AMD; - case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: + case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return GL2GL3.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD; - case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE_ARB: + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return GL2GL3.GL_DEBUG_CATEGORY_PERFORMANCE_AMD; } @@ -204,33 +204,33 @@ public class GLDebugMessage { public static String getDbgSourceString(int dbgSource) { switch(dbgSource) { - case GL2GL3.GL_DEBUG_SOURCE_API_ARB: return "GL API"; - case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: return "GLSL or extension compiler"; - case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: return "Native Windowing binding"; - case GL2GL3.GL_DEBUG_SOURCE_THIRD_PARTY_ARB: return "Third party"; - case GL2GL3.GL_DEBUG_SOURCE_APPLICATION_ARB: return "Application"; - case GL2GL3.GL_DEBUG_SOURCE_OTHER_ARB: return "generic"; + case GL2GL3.GL_DEBUG_SOURCE_API: return "GL API"; + case GL2GL3.GL_DEBUG_SOURCE_SHADER_COMPILER: return "GLSL or extension compiler"; + case GL2GL3.GL_DEBUG_SOURCE_WINDOW_SYSTEM: return "Native Windowing binding"; + case GL2GL3.GL_DEBUG_SOURCE_THIRD_PARTY: return "Third party"; + case GL2GL3.GL_DEBUG_SOURCE_APPLICATION: return "Application"; + case GL2GL3.GL_DEBUG_SOURCE_OTHER: return "generic"; default: return "Unknown (" + toHexString(dbgSource) + ")"; } } public static String getDbgTypeString(int dbgType) { switch(dbgType) { - case GL2GL3.GL_DEBUG_TYPE_ERROR_ARB: return "Error"; - case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: return "Warning: marked for deprecation"; - case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: return "Warning: undefined behavior"; - case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE_ARB: return "Warning: implementation dependent performance"; - case GL2GL3.GL_DEBUG_TYPE_PORTABILITY_ARB: return "Warning: vendor-specific extension use"; - case GL2GL3.GL_DEBUG_TYPE_OTHER_ARB: return "Warning: generic"; + case GL2GL3.GL_DEBUG_TYPE_ERROR: return "Error"; + case GL2GL3.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR: return "Warning: marked for deprecation"; + case GL2GL3.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR: return "Warning: undefined behavior"; + case GL2GL3.GL_DEBUG_TYPE_PERFORMANCE: return "Warning: implementation dependent performance"; + case GL2GL3.GL_DEBUG_TYPE_PORTABILITY: return "Warning: vendor-specific extension use"; + case GL2GL3.GL_DEBUG_TYPE_OTHER: return "Warning: generic"; default: return "Unknown (" + toHexString(dbgType) + ")"; } } public static String getDbgSeverityString(int dbgSeverity) { switch(dbgSeverity) { - case GL2GL3.GL_DEBUG_SEVERITY_HIGH_ARB: return "High: dangerous undefined behavior"; - case GL2GL3.GL_DEBUG_SEVERITY_MEDIUM_ARB: return "Medium: Severe performance/deprecation/other warnings"; - case GL2GL3.GL_DEBUG_SEVERITY_LOW_ARB: return "Low: Performance warnings (redundancy/undefined)"; + case GL2GL3.GL_DEBUG_SEVERITY_HIGH: return "High: dangerous undefined behavior"; + case GL2GL3.GL_DEBUG_SEVERITY_MEDIUM: return "Medium: Severe performance/deprecation/other warnings"; + case GL2GL3.GL_DEBUG_SEVERITY_LOW: return "Low: Performance warnings (redundancy/undefined)"; default: return "Unknown (" + toHexString(dbgSeverity) + ")"; } } diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 1b6af22d4..17d9019da 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -132,7 +132,7 @@ public class GLProfile { ReflectionUtil.createInstance(getGLImplBaseClassName(GL4bc)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); } catch (Throwable t) {} try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GLES2)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); + ReflectionUtil.createInstance(getGLImplBaseClassName(GLES3)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); } catch (Throwable t) {} try { ReflectionUtil.createInstance(getGLImplBaseClassName(GLES1)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); @@ -165,7 +165,7 @@ public class GLProfile { initLock.unlock(); } if(DEBUG) { - if( justInitialized && ( hasGL234Impl || hasGLES1Impl || hasGLES2Impl ) ) { + if( justInitialized && ( hasGL234Impl || hasGLES1Impl || hasGLES3Impl ) ) { System.err.println(JoglVersion.getDefaultOpenGLInfo(defaultDevice, null, true)); } } @@ -298,6 +298,24 @@ public class GLProfile { glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE); } + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent); + } else { + sb.append(", GL4ES3 "); + } + sb.append(isAvailableImpl(map, GL4ES3)); + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES3").append(indent); + } else { + sb.append(", GLES3 "); + } + avail=isAvailableImpl(map, GLES3); + sb.append(avail); + if(avail) { + glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_ES); + } + if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3bc").append(indent); } else { @@ -332,39 +350,39 @@ public class GLProfile { } if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); } else { - sb.append(", GL2ES1 "); + sb.append(", GL2ES2 "); } - sb.append(isAvailableImpl(map, GL2ES1)); + sb.append(isAvailableImpl(map, GL2ES2)); if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent); } else { - sb.append(", GLES1 "); + sb.append(", GLES2 "); } - avail=isAvailableImpl(map, GLES1); + avail=isAvailableImpl(map, GLES2); sb.append(avail); if(avail) { - glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES); + glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES); } if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); } else { - sb.append(", GL2ES2 "); + sb.append(", GL2ES1 "); } - sb.append(isAvailableImpl(map, GL2ES2)); + sb.append(isAvailableImpl(map, GL2ES1)); if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent); } else { - sb.append(", GLES2 "); + sb.append(", GLES1 "); } - avail=isAvailableImpl(map, GLES2); + avail=isAvailableImpl(map, GLES1); sb.append(avail); if(avail) { - glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES); + glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES); } if(useIndent) { @@ -437,6 +455,9 @@ public class GLProfile { /** The embedded OpenGL profile ES 2.x, with x >= 0 */ public static final String GLES2 = "GLES2"; + /** The embedded OpenGL profile ES 3.x, with x >= 0 */ + public static final String GLES3 = "GLES3"; + /** The intersection of the desktop GL2 and embedded ES1 profile */ public static final String GL2ES1 = "GL2ES1"; @@ -446,6 +467,9 @@ public class GLProfile { /** The intersection of the desktop GL3 and GL2 profile */ public static final String GL2GL3 = "GL2GL3"; + /** The intersection of the desktop GL4 and ES3 profile */ + public static final String GL4ES3 = "GL4ES3"; + /** The default profile, used for the device default profile map */ private static final String GL_DEFAULT = "GL_DEFAULT"; @@ -456,62 +480,66 @@ public class GLProfile { *

    This includes the generic subset profiles GL2GL3, GL2ES2 and GL2ES1.

    * *
      - *
    • GL4bc - *
    • GL3bc - *
    • GL2 - *
    • GL4 - *
    • GL3 - *
    • GL2GL3 - *
    • GLES2 - *
    • GL2ES2 - *
    • GLES1 - *
    • GL2ES1 + *
    • GL4bc
    • + *
    • GL3bc
    • + *
    • GL2
    • + *
    • GL4
    • + *
    • GL3
    • + *
    • GLES3
    • + *
    • GL4ES3
    • + *
    • GL2GL3
    • + *
    • GLES2
    • + *
    • GL2ES2
    • + *
    • GLES1
    • + *
    • GL2ES1
    • *
    * */ - public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL4bc, GL3bc, GL2, GL4, GL3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 }; - + public static final String[] GL_PROFILE_LIST_ALL = new String[] { GL4bc, GL3bc, GL2, GL4, GL3, GLES3, GL4ES3, GL2GL3, GLES2, GL2ES2, GLES1, GL2ES1 }; + /** * Order of maximum profiles. * *
      - *
    • GL4bc - *
    • GL4 - *
    • GL3bc - *
    • GL3 - *
    • GL2 - *
    • GLES2 - *
    • GLES1 + *
    • GL4bc
    • + *
    • GL4
    • + *
    • GL3bc
    • + *
    • GL3
    • + *
    • GLES3
    • + *
    • GL2
    • + *
    • GLES2
    • + *
    • GLES1
    • *
    * */ - public static final String[] GL_PROFILE_LIST_MAX = new String[] { GL4bc, GL4, GL3bc, GL3, GL2, GLES2, GLES1 }; + public static final String[] GL_PROFILE_LIST_MAX = new String[] { GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GLES2, GLES1 }; /** * Order of minimum profiles. * *
      - *
    • GLES1 - *
    • GLES2 - *
    • GL2 - *
    • GL3 - *
    • GL3bc - *
    • GL4 - *
    • GL4bc + *
    • GLES1
    • + *
    • GLES2
    • + *
    • GL2
    • + *
    • GLES3
    • + *
    • GL3
    • + *
    • GL3bc
    • + *
    • GL4
    • + *
    • GL4bc
    • *
    * */ - public static final String[] GL_PROFILE_LIST_MIN = new String[] { GLES1, GLES2, GL2, GL3, GL3bc, GL4, GL4bc }; + public static final String[] GL_PROFILE_LIST_MIN = new String[] { GLES1, GLES2, GL2, GLES3, GL3, GL3bc, GL4, GL4bc }; /** * Order of minimum original desktop profiles. * *
      - *
    • GL2 - *
    • GL3bc - *
    • GL4bc - *
    • GL3 - *
    • GL4 + *
    • GL2
    • + *
    • GL3bc
    • + *
    • GL4bc
    • + *
    • GL3
    • + *
    • GL4
    • *
    * */ @@ -521,10 +549,10 @@ public class GLProfile { * Order of maximum fixed function profiles * *
      - *
    • GL4bc - *
    • GL3bc - *
    • GL2 - *
    • GLES1 + *
    • GL4bc
    • + *
    • GL3bc
    • + *
    • GL2
    • + *
    • GLES1
    • *
    * */ @@ -534,28 +562,30 @@ public class GLProfile { * Order of maximum programmable shader profiles * *
      - *
    • GL4bc - *
    • GL4 - *
    • GL3bc - *
    • GL3 - *
    • GL2 - *
    • GLES2 + *
    • GL4bc
    • + *
    • GL4
    • + *
    • GL3bc
    • + *
    • GL3
    • + *
    • GLES3
    • + *
    • GL2
    • + *
    • GLES2
    • *
    * */ - public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4bc, GL4, GL3bc, GL3, GL2, GLES2 }; + public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER = new String[] { GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GLES2 }; /** * Order of maximum programmable shader core only profiles * *
      - *
    • GL4 - *
    • GL3 - *
    • GLES2 + *
    • GL4
    • + *
    • GL3
    • + *
    • GLES3
    • + *
    • GLES2
    • *
    * */ - public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER_CORE = new String[] { GL4, GL3, GLES2 }; + public static final String[] GL_PROFILE_LIST_MAX_PROGSHADER_CORE = new String[] { GL4, GL3, GLES3, GLES2 }; /** Returns a default GLProfile object, reflecting the best for the running platform. * It selects the first of the set {@link GLProfile#GL_PROFILE_LIST_ALL} @@ -754,6 +784,36 @@ public class GLProfile { return get(defaultDevice, GL2ES2).getImpl(); } + /** + * Returns the GL4ES3 profile implementation, hence compatible w/ GL4ES3.
    + * It returns: + *
    +     *   GLProfile.get(device, GLProfile.GL4ES3).getImpl());
    +     * 
    + *

    Selection favors hardware rasterizer.

    + * + * @throws GLException if no GL4ES3 compatible profile is available for the default device. + * @see #isGL4ES3() + * @see #get(AbstractGraphicsDevice, String) + * @see #getImpl() + */ + public static GLProfile getGL4ES3(AbstractGraphicsDevice device) + throws GLException + { + return get(device, GL4ES3).getImpl(); + } + + /** + * Calls {@link #getGL4ES3(AbstractGraphicsDevice)} using the default device. + *

    Selection favors hardware rasterizer.

    + * @see #getGL4ES3(AbstractGraphicsDevice) + */ + public static GLProfile getGL4ES3() + throws GLException + { + return get(defaultDevice, GL4ES3).getImpl(); + } + /** * Returns the GL2GL3 profile implementation, hence compatible w/ GL2GL3.
    * It returns: @@ -872,13 +932,20 @@ public class GLProfile { return GLES1.equals(profileImpl); } - /** Indicates whether the native OpenGL ES2 profile is in use. - * This requires an EGL or ES2 compatible interface. + /** Indicates whether the native OpenGL ES3 or ES2 profile is in use. + * This requires an EGL, ES3 or ES2 compatible interface. */ public static boolean usesNativeGLES2(String profileImpl) { - return GLES2.equals(profileImpl); + return GLES3.equals(profileImpl) || GLES2.equals(profileImpl); } + /** Indicates whether the native OpenGL ES2 profile is in use. + * This requires an EGL, ES3 compatible interface. + */ + public static boolean usesNativeGLES3(String profileImpl) { + return GLES3.equals(profileImpl); + } + /** Indicates whether either of the native OpenGL ES profiles are in use. */ public static boolean usesNativeGLES(String profileImpl) { return usesNativeGLES2(profileImpl) || usesNativeGLES1(profileImpl); @@ -937,8 +1004,8 @@ public class GLProfile { } private static final String getGLImplBaseClassName(String profileImpl) { - if( GLES2 == profileImpl ) { - return "jogamp.opengl.es2.GLES2"; + if( GLES2 == profileImpl || GLES3 == profileImpl ) { + return "jogamp.opengl.es3.GLES3"; } else if( GLES1 == profileImpl ) { return "jogamp.opengl.es1.GLES1"; } else if ( GL4bc == profileImpl || @@ -1035,14 +1102,19 @@ public class GLProfile { return GLES1 == profile; } - /** Indicates whether this profile is capable of GLES2.

    Includes [ GLES2 ].

    */ + /** Indicates whether this profile is capable of GLES2.

    Includes [ GLES3, GLES2 ].

    */ public final boolean isGLES2() { - return GLES2 == profile; + return GLES3 == profile || GLES2 == profile; } - /** Indicates whether this profile is capable of GLES.

    Includes [ GLES1, GLES2 ].

    */ + /** Indicates whether this profile is capable of GLES3.

    Includes [ GLES3 ].

    */ + public final boolean isGLES3() { + return GLES3 == profile; + } + + /** Indicates whether this profile is capable of GLES.

    Includes [ GLES3, GLES1, GLES2 ].

    */ public final boolean isGLES() { - return GLES2 == profile || GLES1 == profile; + return GLES3 == profile || GLES2 == profile || GLES1 == profile; } /** Indicates whether this profile is capable of GL2ES1.

    Includes [ GL4bc, GL3bc, GL2, GLES1, GL2ES1 ].

    */ @@ -1050,17 +1122,27 @@ public class GLProfile { return GL2ES1 == profile || isGLES1() || isGL2(); } - /** Indicates whether this profile is capable os GL2GL3.

    Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].

    */ + /** Indicates whether this profile is capable of GL2GL3.

    Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3 ].

    */ public final boolean isGL2GL3() { return GL2GL3 == profile || isGL3() || isGL2(); } - - /** Indicates whether this profile is capable os GL2ES2.

    Includes [ GL4bc, GL4, GL3bc, GL3, GL2, GL2GL3, GL2ES2, GLES2 ].

    */ + + /** Indicates whether this profile is capable of GL2ES2.

    Includes [ GL4bc, GL4, GL3bc, GL3, GLES3, GL2, GL2GL3, GL2ES2, GLES2 ].

    */ public final boolean isGL2ES2() { return GL2ES2 == profile || isGLES2() || isGL2GL3(); } - /** Indicates whether this profile supports GLSL, ie. {@link #isGL2ES2()}. */ + /** Indicates whether this profile is capable of GL3ES3.

    Includes [ GL4bc, GL4, GL3bc, GL3, GLES3 ].

    */ + public final boolean isGL3ES3() { + return isGL4ES3() || isGL3(); + } + + /** Indicates whether this profile is capable of GL4ES3.

    Includes [ GL4bc, GL4, GLES3 ].

    */ + public final boolean isGL4ES3() { + return GL4ES3 == profile || isGLES3() || isGL4(); + } + + /** Indicates whether this profile supports GLSL, i.e. {@link #isGL2ES2()}. */ public final boolean hasGLSL() { return isGL2ES2() ; } @@ -1072,7 +1154,12 @@ public class GLProfile { /** Indicates whether this profile uses the native OpenGL ES2 implementations. */ public final boolean usesNativeGLES2() { - return GLES2 == getImplName(); + return GLES3 == getImplName() || GLES2 == getImplName(); + } + + /** Indicates whether this profile uses the native OpenGL ES2 implementations. */ + public final boolean usesNativeGLES3() { + return GLES3 == getImplName(); } /** Indicates whether this profile uses either of the native OpenGL ES implementations. */ @@ -1117,8 +1204,8 @@ public class GLProfile { public boolean isValidArrayDataType(int index, int comps, int type, boolean isVertexAttribPointer, boolean throwException) { - String arrayName = getGLArrayName(index); - if(isGLES1()) { + final String arrayName = getGLArrayName(index); + if( isGLES1() ) { if(isVertexAttribPointer) { if(throwException) { throw new GLException("Illegal array type for "+arrayName+" on profile GLES1: VertexAttribPointer"); @@ -1201,7 +1288,7 @@ public class GLProfile { } break; } - } else if(isGLES2()) { + } else if( isGLES2() ) { // simply ignore !isVertexAttribPointer case, since it is simulated anyway .. switch(type) { case GL.GL_UNSIGNED_BYTE: @@ -1386,7 +1473,7 @@ public class GLProfile { private static /*final*/ boolean hasDesktopGLFactory; private static /*final*/ boolean hasGL234Impl; private static /*final*/ boolean hasEGLFactory; - private static /*final*/ boolean hasGLES2Impl; + private static /*final*/ boolean hasGLES3Impl; private static /*final*/ boolean hasGLES1Impl; private static /*final*/ GLDrawableFactoryImpl eglFactory = null; @@ -1419,7 +1506,7 @@ public class GLProfile { // depends on hasEGLFactory hasGLES1Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es1.GLES1Impl", classloader); - hasGLES2Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es2.GLES2Impl", classloader); + hasGLES3Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es3.GLES3Impl", classloader); // // Iteration of desktop GL availability detection @@ -1471,8 +1558,8 @@ public class GLProfile { eglFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getFactoryImpl(GLES2); if(null != eglFactory) { hasEGLFactory = true; - // update hasGLES1Impl, hasGLES2Impl based on EGL - hasGLES2Impl = null!=eglFactory.getGLDynamicLookupHelper(2) && hasGLES2Impl; + // update hasGLES1Impl, hasGLES3Impl based on EGL + hasGLES3Impl = null!=eglFactory.getGLDynamicLookupHelper(2) && hasGLES3Impl; hasGLES1Impl = null!=eglFactory.getGLDynamicLookupHelper(1) && hasGLES1Impl; } } catch (LinkageError le) { @@ -1493,7 +1580,7 @@ public class GLProfile { final AbstractGraphicsDevice defaultEGLDevice; if(null == eglFactory) { - hasGLES2Impl = false; + hasGLES3Impl = false; hasGLES1Impl = false; defaultEGLDevice = null; if(DEBUG) { @@ -1532,7 +1619,7 @@ public class GLProfile { System.err.println("GLProfile.init hasGL234Impl "+hasGL234Impl); System.err.println("GLProfile.init hasEGLFactory "+hasEGLFactory); System.err.println("GLProfile.init hasGLES1Impl "+hasGLES1Impl); - System.err.println("GLProfile.init hasGLES2Impl "+hasGLES2Impl); + System.err.println("GLProfile.init hasGLES3Impl "+hasGLES3Impl); System.err.println("GLProfile.init defaultDevice "+defaultDevice); System.err.println("GLProfile.init defaultDevice Desktop "+defaultDesktopDevice); System.err.println("GLProfile.init defaultDevice EGL "+defaultEGLDevice); @@ -1609,8 +1696,8 @@ public class GLProfile { final boolean deviceIsEGLCompatible = hasEGLFactory && eglFactory.getIsDeviceCompatible(device); - // also test GLES1 and GLES2 on desktop, since we have implementations / emulations available. - if( deviceIsEGLCompatible && ( hasGLES2Impl || hasGLES1Impl ) ) { + // also test GLES1, GLES2 and GLES3 on desktop, since we have implementations / emulations available. + if( deviceIsEGLCompatible && ( hasGLES3Impl || hasGLES1Impl ) ) { // 1st pretend we have all EGL profiles .. computeProfileMap(device, false /* desktopCtxUndef*/, true /* esCtxUndef */); @@ -1629,7 +1716,7 @@ public class GLProfile { // but it seems even EGL.eglInitialize(eglDisplay, null, null) // fails in some scenarios (eg VirtualBox 4.1.6) w/ EGL error 0x3001 (EGL_NOT_INITIALIZED). hasEGLFactory = false; - hasGLES2Impl = false; + hasGLES3Impl = false; hasGLES1Impl = false; } if (DEBUG) { @@ -1647,7 +1734,7 @@ public class GLProfile { System.err.println("GLProfile: desktoplFactory "+desktopFactory); System.err.println("GLProfile: eglFactory "+eglFactory); System.err.println("GLProfile: hasGLES1Impl "+hasGLES1Impl); - System.err.println("GLProfile: hasGLES2Impl "+hasGLES2Impl); + System.err.println("GLProfile: hasGLES3Impl "+hasGLES3Impl); } } @@ -1725,18 +1812,18 @@ public class GLProfile { final boolean isHardwareRasterizer[] = new boolean[1]; GLProfile defaultGLProfileAny = null; GLProfile defaultGLProfileHW = null; - HashMap _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length + 1 /* default */); + final HashMap _mappedProfiles = new HashMap(GL_PROFILE_LIST_ALL.length + 1 /* default */); for(int i=0; i profileImpl "+profileImpl+" !!! not mapped "); } glProfile = new GLProfile(profile, _mglp, isHardwareRasterizer[0]); } @@ -1744,12 +1831,12 @@ public class GLProfile { if (DEBUG) { System.err.println("GLProfile.init map "+glProfile+" on device "+device.getConnection()); } - if(null==defaultGLProfileHW && isHardwareRasterizer[0]) { + if( null == defaultGLProfileHW && isHardwareRasterizer[0] ) { defaultGLProfileHW=glProfile; if (DEBUG) { System.err.println("GLProfile.init map defaultHW "+glProfile+" on device "+device.getConnection()); } - } else if(null==defaultGLProfileAny) { + } else if( null == defaultGLProfileAny ) { defaultGLProfileAny=glProfile; if (DEBUG) { System.err.println("GLProfile.init map defaultAny "+glProfile+" on device "+device.getConnection()); @@ -1761,9 +1848,9 @@ public class GLProfile { } } } - if(null!=defaultGLProfileHW) { + if( null != defaultGLProfileHW ) { _mappedProfiles.put(GL_DEFAULT, defaultGLProfileHW); - } else if(null!=defaultGLProfileAny) { + } else if( null != defaultGLProfileAny ) { _mappedProfiles.put(GL_DEFAULT, defaultGLProfileAny); } setProfileMap(device, _mappedProfiles); @@ -1805,23 +1892,18 @@ public class GLProfile { } } else if (GL2ES2.equals(profile)) { final boolean es2HardwareRasterizer[] = new boolean[1]; - final boolean gles2Available = hasGLES2Impl && ( esCtxUndef || GLContext.isGLES2Available(device, es2HardwareRasterizer) ); + final boolean gles2Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, es2HardwareRasterizer) ); final boolean gles2HWAvailable = gles2Available && es2HardwareRasterizer[0] ; if(hasGL234Impl) { if(!isOSX) { - if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { - if(!gles2HWAvailable || isHardwareRasterizer[0]) { - return GL4bc; - } - } if(GLContext.isGL4Available(device, isHardwareRasterizer)) { if(!gles2HWAvailable || isHardwareRasterizer[0]) { return GL4; } } - if(GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) { + if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { if(!gles2HWAvailable || isHardwareRasterizer[0]) { - return GL3bc; + return GL4bc; } } if(GLContext.isGL3Available(device, isHardwareRasterizer)) { @@ -1829,6 +1911,11 @@ public class GLProfile { return GL3; } } + if(GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) { + if(!gles2HWAvailable || isHardwareRasterizer[0]) { + return GL3bc; + } + } } if(desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer)) { if(!gles2HWAvailable || isHardwareRasterizer[0]) { @@ -1840,6 +1927,26 @@ public class GLProfile { isHardwareRasterizer[0] = es2HardwareRasterizer[0]; return GLES2; } + } else if (GL4ES3.equals(profile)) { + final boolean es3HardwareRasterizer[] = new boolean[1]; + final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) ); + final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ; + if(hasGL234Impl) { + if(GLContext.isGL4Available(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL4; + } + } + if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { + if(!gles3HWAvailable || isHardwareRasterizer[0]) { + return GL4bc; + } + } + } + if(gles3Available) { + isHardwareRasterizer[0] = es3HardwareRasterizer[0]; + return GLES3; + } } else if(GL2GL3.equals(profile)) { if(hasGL234Impl) { if(!isOSX && GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { @@ -1864,7 +1971,9 @@ public class GLProfile { return GL3; } else if(GL2.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) { return GL2; - } else if(GLES2.equals(profile) && hasGLES2Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) { + } else if(GLES3.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) { + return GLES3; + } else if(GLES2.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) { return GLES2; } else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) { return GLES1; diff --git a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java index 7c7ea1508..94acf93b0 100644 --- a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java +++ b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java @@ -219,17 +219,17 @@ final class ExtensionAvailabilityCache { System.err.println(getThreadName() + ":ExtensionAvailabilityCache: ALL EXTENSIONS: "+availableExtensionCache.size()); } - if(!context.isGLES()) { - final VersionNumber version = context.getGLVersionNumber(); - int major[] = new int[] { version.getMajor() }; - int minor[] = new int[] { version.getMinor() }; - while (GLContext.isValidGLVersion(major[0], minor[0])) { - availableExtensionCache.add("GL_VERSION_" + major[0] + "_" + minor[0]); - if (DEBUG) { - System.err.println(getThreadName() + ":ExtensionAvailabilityCache: Added GL_VERSION_" + major[0] + "_" + minor[0] + " to known extensions"); - } - if(!GLContext.decrementGLVersion(major, minor)) break; + final int ctxOptions = context.getCtxOptions(); + final VersionNumber version = context.getGLVersionNumber(); + int major[] = new int[] { version.getMajor() }; + int minor[] = new int[] { version.getMinor() }; + while (GLContext.isValidGLVersion(ctxOptions, major[0], minor[0])) { + final String GL_XX_VERSION = ( context.isGLES() ? "GL_ES_VERSION_" : "GL_VERSION_" ) + major[0] + "_" + minor[0]; + availableExtensionCache.add(GL_XX_VERSION); + if (DEBUG) { + System.err.println(getThreadName() + ":ExtensionAvailabilityCache: Added "+GL_XX_VERSION+" to known extensions"); } + if(!GLContext.decrementGLVersion(ctxOptions, major, minor)) break; } // put a dummy var in here so that the cache is no longer empty even if diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index f896c95ee..18e136815 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -40,6 +40,7 @@ package jogamp.opengl; +import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.security.AccessController; @@ -66,6 +67,7 @@ import javax.media.nativewindow.NativeSurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL2ES3; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -396,9 +398,10 @@ public abstract class GLContextImpl extends GLContext { associateDrawableException = t; } if ( 0 != defaultVAO ) { - int[] tmp = new int[] { defaultVAO }; - gl.getGL2GL3().glBindVertexArray(0); - gl.getGL2GL3().glDeleteVertexArrays(1, tmp, 0); + final int[] tmp = new int[] { defaultVAO }; + final GL2ES3 gl3es3 = gl.getGL3ES3(); + gl3es3.glBindVertexArray(0); + gl3es3.glDeleteVertexArrays(1, tmp, 0); defaultVAO = 0; } glDebugHandler.enable(false); @@ -640,9 +643,10 @@ public abstract class GLContextImpl extends GLContext { // to avoid INVALID_OPERATION at VertexAttribPointer. // More clear is GL 4.3 core spec: 10.4 (p 307). final int[] tmp = new int[1]; - gl.getGL2GL3().glGenVertexArrays(1, tmp, 0); + final GL2ES3 gl3es3 = gl.getGL3ES3(); + gl3es3.glGenVertexArrays(1, tmp, 0); defaultVAO = tmp[0]; - gl.getGL2GL3().glBindVertexArray(defaultVAO); + gl3es3.glBindVertexArray(defaultVAO); } } finally { if (null != shareWith) { @@ -836,6 +840,7 @@ public abstract class GLContextImpl extends GLContext { boolean hasGL2 = false; boolean hasGL4 = false; boolean hasGL3 = false; + boolean hasES3 = false; // Even w/ PROFILE_ALIASING, try to use true core GL profiles // ensuring proper user behavior across platforms due to different feature sets! @@ -904,6 +909,13 @@ public abstract class GLContextImpl extends GLContext { resetStates(); // clean this context states, since creation was temporary } } + if(!hasES3) { + hasES3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_ES); // ES3 + success |= hasES3; + if(hasES3) { + resetStates(); // clean this context states, since creation was temporary + } + } if(success) { // only claim GL versions set [and hence detected] if ARB context creation was successful GLContext.setAvailableGLVersionsSet(device); @@ -925,12 +937,7 @@ public abstract class GLContextImpl extends GLContext { **/ private final boolean createContextARBMapVersionsAvailable(int reqMajor, int reqProfile) { long _context; - int ctp = CTX_IS_ARB_CREATED; - if(CTX_PROFILE_COMPAT == reqProfile) { - ctp |= CTX_PROFILE_COMPAT ; - } else { - ctp |= CTX_PROFILE_CORE ; - } + int ctp = CTX_IS_ARB_CREATED | reqProfile; // To ensure GL profile compatibility within the JOGL application // we always try to map against the highest GL version, @@ -940,10 +947,10 @@ public abstract class GLContextImpl extends GLContext { int major[] = new int[1]; int minor[] = new int[1]; if( 4 == reqMajor ) { - majorMax=4; minorMax=GLContext.getMaxMinor(majorMax); + majorMax=4; minorMax=GLContext.getMaxMinor(ctp, majorMax); majorMin=4; minorMin=0; } else if( 3 == reqMajor ) { - majorMax=3; minorMax=GLContext.getMaxMinor(majorMax); + majorMax=3; minorMax=GLContext.getMaxMinor(ctp, majorMax); majorMin=3; minorMin=1; } else /* if( glp.isGL2() ) */ { // our minimum desktop OpenGL runtime requirements are 1.1, @@ -1003,7 +1010,7 @@ public abstract class GLContextImpl extends GLContext { minor[0]=minorMax; long _context=0; - while ( GLContext.isValidGLVersion(major[0], minor[0]) && + while ( GLContext.isValidGLVersion(ctxOptionFlags, major[0], minor[0]) && ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) { if (DEBUG) { System.err.println(getThreadName() + ": createContextARBVersions: share "+share+", direct "+direct+", version "+major[0]+"."+minor[0]); @@ -1019,7 +1026,7 @@ public abstract class GLContextImpl extends GLContext { } } - if(!GLContext.decrementGLVersion(major, minor)) { + if(!GLContext.decrementGLVersion(ctxOptionFlags, major, minor)) { break; } } @@ -1040,11 +1047,11 @@ public abstract class GLContextImpl extends GLContext { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - if (!GLContext.isValidGLVersion(major, minor)) { + if (!GLContext.isValidGLVersion(ctp, major, minor)) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } ctxVersion = new VersionNumber(major, minor, 0); - ctxVersionString = getGLVersion(major, minor, ctxOptions, glVersion); + ctxVersionString = getGLVersion(major, minor, ctp, glVersion); ctxVendorVersion = glVendorVersion; ctxOptions = ctp; if(useGL) { @@ -1087,6 +1094,27 @@ public abstract class GLContextImpl extends GLContext { */ return gl; } + + /** + * Finalizes GL instance initialization after this context has been initialized. + *

    + * Method calls 'void finalizeInit()' of instance 'gl' as retrieved by reflection, if exist. + *

    + */ + private void finalizeInit(GL gl) { + Method finalizeInit = null; + try { + finalizeInit = ReflectionUtil.getMethod(gl.getClass(), "finalizeInit", new Class[]{ }); + } catch ( Throwable t ) { + if(DEBUG) { + System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); + t.printStackTrace(); + } + } + if( null != finalizeInit ) { + ReflectionUtil.callMethod(gl, finalizeInit, new Object[]{ }); + } + } public final ProcAddressTable getGLProcAddressTable() { return glProcAddressTable; @@ -1097,8 +1125,24 @@ public abstract class GLContextImpl extends GLContext { * ie for GLXExt, EGLExt, .. */ public abstract ProcAddressTable getPlatformExtProcAddressTable(); + + /** + * Part of GL_NV_vertex_array_range. + *

    + * Provides platform-independent access to the wglAllocateMemoryNV / + * glXAllocateMemoryNV. + *

    + */ + public abstract ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority); - public abstract ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3); + /** + * Part of GL_NV_vertex_array_range. + *

    + * Provides platform-independent access to the wglFreeMemoryNV / + * glXFreeMemoryNV. + *

    + */ + public abstract void glFreeMemoryNV(ByteBuffer pointer); /** Maps the given "platform-independent" function name to a real function name. Currently this is only used to map "glAllocateMemoryNV" and @@ -1208,7 +1252,7 @@ public abstract class GLContextImpl extends GLContext { int[] major = new int[] { version.getMajor() }; int[] minor = new int[] { version.getMinor() }; limitNonARBContextVersion(major, minor, ctp); - if ( GLContext.isValidGLVersion(major[0], minor[0]) ) { + if ( GLContext.isValidGLVersion(ctp, major[0], minor[0]) ) { return new VersionNumber(major[0], minor[0], 0); } } @@ -1244,6 +1288,11 @@ public abstract class GLContextImpl extends GLContext { } } + protected final int getCtxOptions() { + return ctxOptions; + } + + /** * Sets the OpenGL implementation class and * the cache of which GL functions are available for calling through this @@ -1275,7 +1324,7 @@ public abstract class GLContextImpl extends GLContext { return true; // already done and not forced } - if ( 0 < major && !GLContext.isValidGLVersion(major, minor) ) { + if ( 0 < major && !GLContext.isValidGLVersion(ctxProfileBits, major, minor) ) { throw new GLException("Invalid GL Version Request "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)); } @@ -1336,7 +1385,7 @@ public abstract class GLContextImpl extends GLContext { } // Only validate if a valid int version was fetched, otherwise cont. w/ version-string method -> 3.0 > Version || Version > MAX! - if ( GLContext.isValidGLVersion(glIntMajor[0], glIntMinor[0]) ) { + if ( GLContext.isValidGLVersion(ctxProfileBits, glIntMajor[0], glIntMinor[0]) ) { if( glIntMajor[0] major ) { // there is no ES2-compat for a profile w/ major < 2 - ctxProfileBits &= ~GLContext.CTX_IMPL_ES2_COMPAT; + if( 2 > major ) { // there is no ES2/3-compat for a profile w/ major < 2 + ctxProfileBits &= ~ ( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_ES3_COMPAT ) ; } final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion); @@ -1468,13 +1517,28 @@ public abstract class GLContextImpl extends GLContext { } } - if( ( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && major >= 2 ) || isExtensionAvailable(GLExtensions.ARB_ES2_compatibility) ) { + if( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) ) { + if( major >= 3 ) { + ctxProfileBits |= CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ; + ctxProfileBits |= CTX_IMPL_FBO; + } else if( major >= 2 ) { + ctxProfileBits |= CTX_IMPL_ES2_COMPAT; + ctxProfileBits |= CTX_IMPL_FBO; + } + } else if( isExtensionAvailable( GLExtensions.ARB_ES3_compatibility ) ) { + ctxProfileBits |= CTX_IMPL_ES3_COMPAT | CTX_IMPL_ES2_COMPAT ; + ctxProfileBits |= CTX_IMPL_FBO; + } else if( isExtensionAvailable( GLExtensions.ARB_ES2_compatibility ) ) { ctxProfileBits |= CTX_IMPL_ES2_COMPAT; ctxProfileBits |= CTX_IMPL_FBO; } else if( hasFBOImpl(major, ctxProfileBits, extensionAvailability) ) { ctxProfileBits |= CTX_IMPL_FBO; } + if( ( 0 != ( CTX_PROFILE_ES & ctxProfileBits ) && major == 1 ) || isExtensionAvailable(GLExtensions.OES_single_precision) ) { + ctxProfileBits |= CTX_IMPL_FP32_COMPAT_API; + } + if(FORCE_NO_FBO_SUPPORT) { ctxProfileBits &= ~CTX_IMPL_FBO ; } @@ -1484,6 +1548,8 @@ public abstract class GLContextImpl extends GLContext { // setContextVersion(major, minor, ctxProfileBits, vendorVersion, true); + finalizeInit(gl); + setDefaultSwapInterval(); final int glErrX = gl.glGetError(); // clear GL error, maybe caused by above operations @@ -1813,7 +1879,7 @@ public abstract class GLContextImpl extends GLContext { protected static String getContextFQN(AbstractGraphicsDevice device, int major, int minor, int ctxProfileBits) { // remove non-key values - ctxProfileBits &= ~( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) ; + ctxProfileBits &= CTX_IMPL_CACHE_MASK; return device.getUniqueID() + "-" + toHexString(composeBits(major, minor, ctxProfileBits)); } @@ -1998,7 +2064,7 @@ public abstract class GLContextImpl extends GLContext { public final int getContextCreationFlags() { return additionalCtxCreationFlags; } - + @Override public final void setContextCreationFlags(int flags) { if(!isCreated()) { @@ -2041,7 +2107,7 @@ public abstract class GLContextImpl extends GLContext { @Override public final void glDebugMessageControl(int source, int type, int severity, int count, IntBuffer ids, boolean enabled) { if(glDebugHandler.isExtensionARB()) { - gl.getGL2GL3().glDebugMessageControlARB(source, type, severity, count, ids, enabled); + gl.getGL2GL3().glDebugMessageControl(source, type, severity, count, ids, enabled); } else if(glDebugHandler.isExtensionAMD()) { gl.getGL2GL3().glDebugMessageEnableAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, count, ids, enabled); } @@ -2050,7 +2116,7 @@ public abstract class GLContextImpl extends GLContext { @Override public final void glDebugMessageControl(int source, int type, int severity, int count, int[] ids, int ids_offset, boolean enabled) { if(glDebugHandler.isExtensionARB()) { - gl.getGL2GL3().glDebugMessageControlARB(source, type, severity, count, ids, ids_offset, enabled); + gl.getGL2GL3().glDebugMessageControl(source, type, severity, count, ids, ids_offset, enabled); } else if(glDebugHandler.isExtensionAMD()) { gl.getGL2GL3().glDebugMessageEnableAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, count, ids, ids_offset, enabled); } @@ -2060,7 +2126,7 @@ public abstract class GLContextImpl extends GLContext { public final void glDebugMessageInsert(int source, int type, int id, int severity, String buf) { final int len = (null != buf) ? buf.length() : 0; if(glDebugHandler.isExtensionARB()) { - gl.getGL2GL3().glDebugMessageInsertARB(source, type, id, severity, len, buf); + gl.getGL2GL3().glDebugMessageInsert(source, type, id, severity, len, buf); } else if(glDebugHandler.isExtensionAMD()) { gl.getGL2GL3().glDebugMessageInsertAMD(GLDebugMessage.translateARB2AMDCategory(source, type), severity, id, len, buf); } diff --git a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java index 10cdd512e..9ecaca75d 100644 --- a/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java +++ b/src/jogl/classes/jogamp/opengl/GLDebugMessageHandler.java @@ -224,9 +224,9 @@ public class GLDebugMessageHandler { private final void setSynchronousImpl() { if(isExtensionARB()) { if(synchronous) { - ctx.getGL().glEnable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + ctx.getGL().glEnable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS); } else { - ctx.getGL().glDisable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + ctx.getGL().glDisable(GL2GL3.GL_DEBUG_OUTPUT_SYNCHRONOUS); } if(DEBUG) { System.err.println("GLDebugMessageHandler: synchronous "+synchronous); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index b54ed6599..e7977e3fb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -171,7 +171,7 @@ public class EGLContext extends GLContextImpl { try { // might be unavailable on EGL < 1.2 - if(!EGL.eglBindAPI(EGL.EGL_OPENGL_ES_API)) { + if( !EGL.eglBindAPI(EGL.EGL_OPENGL_ES_API) ) { throw new GLException("Catched: eglBindAPI to ES failed , error "+toHexString(EGL.eglGetError())); } } catch (GLException glex) { @@ -188,18 +188,21 @@ public class EGLContext extends GLContextImpl { } final IntBuffer contextAttrsNIO; + final int contextVersionReq, contextVersionAttr; { - final int[] contextAttrs = new int[] { - EGL.EGL_CONTEXT_CLIENT_VERSION, -1, - EGL.EGL_NONE - }; - if (glProfile.usesNativeGLES2()) { - contextAttrs[1] = 2; - } else if (glProfile.usesNativeGLES1()) { - contextAttrs[1] = 1; + if ( glProfile.usesNativeGLES3() ) { + contextVersionReq = 3; + contextVersionAttr = 2; + } else if ( glProfile.usesNativeGLES2() ) { + contextVersionReq = 2; + contextVersionAttr = 2; + } else if ( glProfile.usesNativeGLES1() ) { + contextVersionReq = 1; + contextVersionAttr = 1; } else { throw new GLException("Error creating OpenGL context - invalid GLProfile: "+glProfile); } + final int[] contextAttrs = new int[] { EGL.EGL_CONTEXT_CLIENT_VERSION, contextVersionAttr, EGL.EGL_NONE }; contextAttrsNIO = Buffers.newDirectIntBuffer(contextAttrs); } contextHandle = EGL.eglCreateContext(eglDisplay, eglConfig, shareWithHandle, contextAttrsNIO); @@ -219,8 +222,7 @@ public class EGLContext extends GLContextImpl { throw new GLException("Error making context " + toHexString(contextHandle) + " current: error code " + toHexString(EGL.eglGetError())); } - setGLFunctionAvailability(true, glProfile.usesNativeGLES2() ? 2 : 1, 0, CTX_PROFILE_ES, false); - return true; + return setGLFunctionAvailability(true, contextVersionReq, 0, CTX_PROFILE_ES, contextVersionReq>=3); // strict match for es >= 3 } @Override @@ -292,16 +294,25 @@ public class EGLContext extends GLContextImpl { final GLProfile glp = caps.getGLProfile(); final int[] reqMajorCTP = new int[2]; GLContext.getRequestMajorAndCompat(glp, reqMajorCTP); - if(glp.isGLES() && reqMajorCTP[0] >= 2) { - reqMajorCTP[1] |= GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + if( glp.isGLES() ) { + if( reqMajorCTP[0] >= 3 ) { + reqMajorCTP[1] |= GLContext.CTX_IMPL_ES3_COMPAT | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + } else if( reqMajorCTP[0] >= 2 ) { + reqMajorCTP[1] |= GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + } } - if(!caps.getHardwareAccelerated()) { + if( !caps.getHardwareAccelerated() ) { reqMajorCTP[1] |= GLContext.CTX_IMPL_ACCEL_SOFT; } mapStaticGLVersion(device, reqMajorCTP[0], 0, reqMajorCTP[1]); } - /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, int major) { - int ctp = ( 2 == major ) ? ( GLContext.CTX_PROFILE_ES | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ) : ( GLContext.CTX_PROFILE_ES ); + /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, final int major) { + int ctp = GLContext.CTX_PROFILE_ES; + if( major >= 3 ) { + ctp |= GLContext.CTX_IMPL_ES3_COMPAT | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + } else if( major >= 2 ) { + ctp |= GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; + } mapStaticGLVersion(device, major, 0, ctp); } /* pp */ static void mapStaticGLVersion(AbstractGraphicsDevice device, int major, int minor, int ctp) { @@ -343,9 +354,13 @@ public class EGLContext extends GLContextImpl { throw new GLException("Not yet implemented"); } - @Override - public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + throw new GLException("Should not call this"); + } + + @Override + public final void glFreeMemoryNV(ByteBuffer pointer) { throw new GLException("Should not call this"); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 79d1fad62..465c8fa80 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -91,10 +91,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private static final boolean isANGLE(GLDynamicLookupHelper dl) { if(Platform.OSType.WINDOWS == Platform.OS_TYPE) { - final boolean r = dl.isFunctionAvailable("eglQuerySurfacePointerANGLE") || - dl.isFunctionAvailable("glBlitFramebufferANGLE") || - dl.isFunctionAvailable("glRenderbufferStorageMultisampleANGLE"); - return r; + return dl.isFunctionAvailable("eglQuerySurfacePointerANGLE") || + dl.isFunctionAvailable("glBlitFramebufferANGLE") || + dl.isFunctionAvailable("glRenderbufferStorageMultisampleANGLE"); } else { return false; } @@ -253,8 +252,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { String key = keyI.next(); SharedResource sr = sharedMap.get(key); System.err.println("EGLDrawableFactory.map["+i+"] "+key+" -> "+sr.getDevice()+", "+ - "es1 [avail "+sr.wasES1ContextCreated+", pbuffer "+sr.hasPBufferES1+", quirks "+sr.rendererQuirksES1+", ctp "+EGLContext.getGLVersion(1, 0, sr.ctpES1, null)+"], "+ - "es2 [avail "+sr.wasES2ContextCreated+", pbuffer "+sr.hasPBufferES2+", quirks "+sr.rendererQuirksES2+", ctp "+EGLContext.getGLVersion(2, 0, sr.ctpES2, null)+"]"); + "es1 [avail "+sr.wasES1ContextCreated+", pbuffer "+sr.hasPBufferES1+", quirks "+sr.rendererQuirksES1+", ctp "+EGLContext.getGLVersion(1, 0, sr.ctpES1, null)+"], "+ + "es2/3 [es2 "+sr.wasES2ContextCreated+", es3 "+sr.wasES3ContextCreated+", [pbuffer "+sr.hasPBufferES3ES2+", quirks "+sr.rendererQuirksES3ES2+", ctp "+EGLContext.getGLVersion(2, 0, sr.ctpES3ES2, null)+"]]"); } ; } @@ -271,38 +270,45 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private final EGLGraphicsDevice device; // private final EGLContext contextES1; // private final EGLContext contextES2; - private final GLRendererQuirks rendererQuirksES1; - private final GLRendererQuirks rendererQuirksES2; - private final int ctpES1; - private final int ctpES2; + // private final EGLContext contextES3; private final boolean wasES1ContextCreated; private final boolean wasES2ContextCreated; + private final boolean wasES3ContextCreated; + private final GLRendererQuirks rendererQuirksES1; + private final GLRendererQuirks rendererQuirksES3ES2; + private final int ctpES1; + private final int ctpES3ES2; private final boolean hasPBufferES1; - private final boolean hasPBufferES2; + private final boolean hasPBufferES3ES2; SharedResource(EGLGraphicsDevice dev, boolean wasContextES1Created, boolean hasPBufferES1, GLRendererQuirks rendererQuirksES1, int ctpES1, - boolean wasContextES2Created, boolean hasPBufferES2, GLRendererQuirks rendererQuirksES2, int ctpES2) { + boolean wasContextES2Created, boolean wasContextES3Created, + boolean hasPBufferES3ES2, GLRendererQuirks rendererQuirksES3ES2, int ctpES3ES2) { this.device = dev; // this.contextES1 = ctxES1; - // this.contextES2 = ctxES2; + this.wasES1ContextCreated = wasContextES1Created; + this.hasPBufferES1= hasPBufferES1; this.rendererQuirksES1 = rendererQuirksES1; - this.rendererQuirksES2 = rendererQuirksES2; this.ctpES1 = ctpES1; - this.ctpES2 = ctpES2; - this.wasES1ContextCreated = wasContextES1Created; + + // this.contextES2 = ctxES2; + // this.contextES3 = ctxES3; this.wasES2ContextCreated = wasContextES2Created; - this.hasPBufferES1= hasPBufferES1; - this.hasPBufferES2= hasPBufferES2; + this.wasES3ContextCreated = wasContextES3Created; + this.hasPBufferES3ES2= hasPBufferES3ES2; + this.rendererQuirksES3ES2 = rendererQuirksES3ES2; + this.ctpES3ES2 = ctpES3ES2; } @Override public final boolean isValid() { - return wasES1ContextCreated || wasES2ContextCreated; + return wasES1ContextCreated || wasES2ContextCreated || wasES3ContextCreated; } @Override public final EGLGraphicsDevice getDevice() { return device; } // final EGLContext getContextES1() { return contextES1; } // final EGLContext getContextES2() { return contextES2; } + // final EGLContext getContextES3() { return contextES3; } @Override public AbstractGraphicsScreen getScreen() { @@ -318,7 +324,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override public GLRendererQuirks getRendererQuirks() { - return null != rendererQuirksES2 ? rendererQuirksES2 : rendererQuirksES1 ; + return null != rendererQuirksES3ES2 ? rendererQuirksES3ES2 : rendererQuirksES1 ; } } @@ -353,18 +359,30 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { boolean[] hasPBuffer, GLRendererQuirks[] rendererQuirks, int[] ctp) { final String profileString; switch( esProfile ) { + case 3: + profileString = GLProfile.GLES3; break; + case 2: + profileString = GLProfile.GLES2; break; case 1: profileString = GLProfile.GLES1; break; - case 2: default: - profileString = GLProfile.GLES2; break; + throw new GLException("Invalid ES profile number "+esProfile); } if ( !GLProfile.isAvailable(adevice, profileString) ) { + if( DEBUG ) { + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+profileString+" n/a on "+adevice); + } return false; } final GLProfile glp = GLProfile.get(adevice, profileString) ; final GLDrawableFactoryImpl desktopFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory(); final boolean mapsADeviceToDefaultDevice = !QUERY_EGL_ES_NATIVE_TK || null == desktopFactory || adevice instanceof EGLGraphicsDevice ; + if( DEBUG ) { + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+profileString+" ( "+esProfile+" ), "+ + "defaultSharedResourceSet "+(null!=defaultSharedResource)+", mapsADeviceToDefaultDevice "+mapsADeviceToDefaultDevice+ + " (QUERY_EGL_ES_NATIVE_TK "+QUERY_EGL_ES_NATIVE_TK+", hasDesktopFactory "+(null != desktopFactory)+ + ", isEGLGraphicsDevice "+(adevice instanceof EGLGraphicsDevice)+")"); + } EGLGraphicsDevice eglDevice = null; NativeSurface surface = null; @@ -387,16 +405,29 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if( adevice != defaultDevice ) { if(null == defaultSharedResource) { return false; - } + } switch(esProfile) { + case 3: + if( !defaultSharedResource.wasES3ContextCreated ) { + return false; + } + rendererQuirks[0] = defaultSharedResource.rendererQuirksES3ES2; + ctp[0] = defaultSharedResource.ctpES3ES2; + break; + case 2: + if( !defaultSharedResource.wasES2ContextCreated ) { + return false; + } + rendererQuirks[0] = defaultSharedResource.rendererQuirksES3ES2; + ctp[0] = defaultSharedResource.ctpES3ES2; + break; case 1: + if( !defaultSharedResource.wasES1ContextCreated ) { + return false; + } rendererQuirks[0] = defaultSharedResource.rendererQuirksES1; ctp[0] = defaultSharedResource.ctpES1; break; - case 2: - rendererQuirks[0] = defaultSharedResource.rendererQuirksES2; - ctp[0] = defaultSharedResource.ctpES2; - break; } EGLContext.mapStaticGLVersion(adevice, esProfile, 0, ctp[0]); return true; @@ -421,7 +452,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { success = true; } if(DEBUG) { - System.err.println("EGLDrawableFactory.isEGLContextAvailable() no pbuffer config available, detected !pbuffer config: "+success); + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig() no pbuffer config available, detected !pbuffer config: "+success); EGLGraphicsConfigurationFactory.printCaps("!PBufferCaps", capsAnyL, System.err); } } @@ -457,13 +488,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } else { // Oops .. something is wrong if(DEBUG) { - System.err.println("EGLDrawableFactory.isEGLContextAvailable: "+eglDevice+", "+context.getGLVersion()+" - VERSION is null, dropping availability!"); + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+eglDevice+", "+context.getGLVersion()+" - VERSION is null, dropping availability!"); } } } } catch (GLException gle) { if (DEBUG) { - System.err.println("EGLDrawableFactory.createShared: INFO: context create/makeCurrent failed"); + System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: INFO: context create/makeCurrent failed"); gle.printStackTrace(); } } finally { @@ -557,14 +588,15 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private SharedResource createEGLSharedResourceImpl(AbstractGraphicsDevice adevice) { final boolean madeCurrentES1; final boolean madeCurrentES2; + final boolean madeCurrentES3; boolean[] hasPBufferES1 = new boolean[] { false }; - boolean[] hasPBufferES2 = new boolean[] { false }; + boolean[] hasPBufferES3ES2 = new boolean[] { false }; // EGLContext[] eglCtxES1 = new EGLContext[] { null }; // EGLContext[] eglCtxES2 = new EGLContext[] { null }; GLRendererQuirks[] rendererQuirksES1 = new GLRendererQuirks[] { null }; - GLRendererQuirks[] rendererQuirksES2 = new GLRendererQuirks[] { null }; + GLRendererQuirks[] rendererQuirksES3ES2 = new GLRendererQuirks[] { null }; int[] ctpES1 = new int[] { -1 }; - int[] ctpES2 = new int[] { -1 }; + int[] ctpES3ES2 = new int[] { -1 }; if (DEBUG) { @@ -577,9 +609,16 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { madeCurrentES1 = false; } if( null != eglES2DynamicLookupHelper ) { - madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES2, rendererQuirksES2, ctpES2); + madeCurrentES3 = mapAvailableEGLESConfig(adevice, 3, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); + if( madeCurrentES3 ) { + madeCurrentES2 = true; + EGLContext.mapStaticGLVersion(adevice, 2, 0, ctpES3ES2[0]); + } else { + madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); + } } else { madeCurrentES2 = false; + madeCurrentES3 = false; } if( !EGLContext.getAvailableGLVersionsSet(adevice) ) { @@ -589,10 +628,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } if( hasX11 ) { handleDontCloseX11DisplayQuirk(rendererQuirksES1[0]); - handleDontCloseX11DisplayQuirk(rendererQuirksES2[0]); + handleDontCloseX11DisplayQuirk(rendererQuirksES3ES2[0]); } final SharedResource sr = new SharedResource(defaultDevice, madeCurrentES1, hasPBufferES1[0], rendererQuirksES1[0], ctpES1[0], - madeCurrentES2, hasPBufferES2[0], rendererQuirksES2[0], ctpES2[0]); + madeCurrentES2, madeCurrentES3, hasPBufferES3ES2[0], rendererQuirksES3ES2[0], ctpES3ES2[0]); synchronized(sharedMap) { sharedMap.put(adevice.getUniqueID(), sr); @@ -600,7 +639,8 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if (DEBUG) { System.err.println("EGLDrawableFactory.createShared: devices: queried nativeTK "+QUERY_EGL_ES_NATIVE_TK+", adevice " + adevice + ", defaultDevice " + defaultDevice); System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]); - System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES2[0]); + System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES3ES2[0]); + System.err.println("EGLDrawableFactory.createShared: context ES3: " + madeCurrentES3 + ", hasPBuffer "+hasPBufferES3ES2[0]); dumpMap(); } return sr; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java index 9f4a4d2c2..778f0cb38 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDynamicLibraryBundleInfo.java @@ -39,7 +39,7 @@ import jogamp.opengl.*; * Abstract implementation of the DynamicLookupHelper for EGL, * which decouples it's dependencies to EGLDrawable. * - * Currently two implementations exist, one for ES1 and one for ES2. + * Currently two implementations exist, one for ES1 and one for ES3 and ES2. */ public abstract class EGLDynamicLibraryBundleInfo extends GLDynamicLibraryBundleInfo { static final List glueLibNames; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java index d83acdb6b..0d20fd4e8 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLES2DynamicLibraryBundleInfo.java @@ -30,6 +30,11 @@ package jogamp.opengl.egl; import java.util.*; +/** + *

    + * Covering ES3 and ES2. + *

    + */ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundleInfo { protected EGLES2DynamicLibraryBundleInfo() { super(); @@ -40,18 +45,33 @@ public final class EGLES2DynamicLibraryBundleInfo extends EGLDynamicLibraryBundl { final List libsGL = new ArrayList(); - // this is the default lib name, according to the spec + // ES3: This is the default lib name, according to the spec + libsGL.add("libGLESv3.so.3"); + + // ES3: Try these as well, if spec fails + libsGL.add("libGLESv3.so"); + libsGL.add("GLESv3"); + + // ES3: Alternative names + libsGL.add("GLES30"); + + // ES3: For windows distributions using the 'unlike' lib prefix + // where our tool does not add it. + libsGL.add("libGLESv3"); + libsGL.add("libGLES30"); + + // ES2: This is the default lib name, according to the spec libsGL.add("libGLESv2.so.2"); - // try these as well, if spec fails + // ES2: Try these as well, if spec fails libsGL.add("libGLESv2.so"); libsGL.add("GLESv2"); - // alternative names + // ES2: Alternative names libsGL.add("GLES20"); libsGL.add("GLESv2_CM"); - // for windows distributions using the 'unlike' lib prefix + // ES2: For windows distributions using the 'unlike' lib prefix // where our tool does not add it. libsGL.add("libGLESv2"); libsGL.add("libGLESv2_CM"); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java index f857c6b5c..b61624d79 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java @@ -101,12 +101,16 @@ public class EGLGLCapabilities extends GLCapabilities { if(null == glp) { return true; } - if(0 != (renderableType & EGL.EGL_OPENGL_ES_BIT) && glp.usesNativeGLES1()) { + /** FIXME: EGLExt.EGL_OPENGL_ES3_BIT_KHR OK ? */ + if(0 != (renderableType & EGLExt.EGL_OPENGL_ES3_BIT_KHR) && glp.usesNativeGLES3()) { return true; } if(0 != (renderableType & EGL.EGL_OPENGL_ES2_BIT) && glp.usesNativeGLES2()) { return true; } + if(0 != (renderableType & EGL.EGL_OPENGL_ES_BIT) && glp.usesNativeGLES1()) { + return true; + } if(0 != (renderableType & EGL.EGL_OPENGL_BIT) && !glp.usesNativeGLES()) { return true; } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 6b086ce44..9b163ae5b 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -52,7 +52,7 @@ import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.ProxySurface; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; -import javax.media.opengl.GL3; +import javax.media.opengl.GL3ES3; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; @@ -142,7 +142,7 @@ public class MacOSXCGLContext extends GLContextImpl private static final String shaderBasename = "texture01_xxx"; - private static ShaderProgram createCALayerShader(GL3 gl) { + private static ShaderProgram createCALayerShader(GL3ES3 gl) { // Create & Link the shader program final ShaderProgram sp = new ShaderProgram(); final ShaderCode vp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MacOSXCGLContext.class, @@ -420,11 +420,17 @@ public class MacOSXCGLContext extends GLContextImpl } @Override - public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { // FIXME: apparently the Apple extension doesn't require a custom memory allocator throw new GLException("Not yet implemented"); } + @Override + public final void glFreeMemoryNV(ByteBuffer pointer) { + // FIXME: apparently the Apple extension doesn't require a custom memory allocator + throw new GLException("Not yet implemented"); + } + @Override protected final void updateGLXProcAddressTable() { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); @@ -846,7 +852,7 @@ public class MacOSXCGLContext extends GLContextImpl } if( MacOSXCGLContext.this.isGL3core() ) { if( null == gl3ShaderProgram) { - gl3ShaderProgram = createCALayerShader(MacOSXCGLContext.this.gl.getGL3()); + gl3ShaderProgram = createCALayerShader(MacOSXCGLContext.this.gl.getGL3ES3()); } gl3ShaderProgramName = gl3ShaderProgram.program(); } else { diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index 94153d96d..b8979c91e 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -563,7 +563,13 @@ public class WindowsWGLContext extends GLContextImpl { } @Override - public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { - return getWGLExt().wglAllocateMemoryNV(arg0, arg1, arg2, arg3); + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + return getWGLExt().wglAllocateMemoryNV(size, readFrequency, writeFrequency, priority); } + + @Override + public final void glFreeMemoryNV(ByteBuffer pointer) { + getWGLExt().wglFreeMemoryNV(pointer); + } + } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index c37bcee50..5536ecd6a 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -633,10 +633,15 @@ public class X11GLXContext extends GLContextImpl { } @Override - public ByteBuffer glAllocateMemoryNV(int arg0, float arg1, float arg2, float arg3) { - return getGLXExt().glXAllocateMemoryNV(arg0, arg1, arg2, arg3); + public final ByteBuffer glAllocateMemoryNV(int size, float readFrequency, float writeFrequency, float priority) { + return getGLXExt().glXAllocateMemoryNV(size, readFrequency, writeFrequency, priority); } + @Override + public final void glFreeMemoryNV(ByteBuffer pointer) { + getGLXExt().glXFreeMemoryNV(pointer); + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); diff --git a/src/jogl/native/GLDebugMessageHandler.c b/src/jogl/native/GLDebugMessageHandler.c index fea9d90ce..2e9d6033a 100644 --- a/src/jogl/native/GLDebugMessageHandler.c +++ b/src/jogl/native/GLDebugMessageHandler.c @@ -21,11 +21,11 @@ static jmethodID glDebugMessageARB = NULL; // int source, int type, int id, int severity, String msg static jmethodID glDebugMessageAMD = NULL; // int id, int category, int severity, String msg -typedef void (GLAPIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); -typedef void (GLAPIENTRY* _local_GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +typedef void (APIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef void (APIENTRY* _local_GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -typedef void (GLAPIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, const GLvoid *userParam); -typedef void (GLAPIENTRY* _local_GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +typedef void (APIENTRY* _local_PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, const GLvoid *userParam); +typedef void (APIENTRY* _local_GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); /* * Class: jogamp_opengl_GLDebugMessageHandler diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 286840ed1..537b32355 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -830,14 +830,41 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind * A most simple JOGL AWT test entry */ public static void main(String args[]) { + boolean forceES2 = false; + boolean forceES3 = false; + boolean forceGL3 = false; + if( null != args ) { + for(int i=0; i Date: Tue, 16 Jul 2013 07:49:12 +0200 Subject: Tests: Cleanup for GL core usage p2 - (Proper GLSL version number) --- make/scripts/tests.sh | 10 +--------- .../test/junit/jogl/demos/es2/ElektronenMultiplizierer.java | 9 ++++++--- .../demos/es2/newt/TestElektronenMultipliziererNEWT.java | 2 -- .../test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java | 12 ++++++++---- .../test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java | 9 ++++++--- .../com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7484d5afe..9e7be06d9 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -88,7 +88,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" - #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL -Djogl.debug.TraceGL" + D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" @@ -614,14 +614,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* # NEW -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* - -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NEWT $* - -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* - $spath/count-edt-start.sh java-run.log diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java index cc8927c24..3120a1832 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/ElektronenMultiplizierer.java @@ -232,10 +232,13 @@ public class ElektronenMultiplizierer implements GLEventListener { st = new ShaderState(); final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader", - "shader/bin", "default", false); + "shader/bin", "default", true); final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", - "shader/bin", "elektronenmultiplizierer_development", false); - // "shader", "shader/bin", "elektronenmultiplizierer_port", false); + "shader/bin", "elektronenmultiplizierer_development", true); + // "shader", "shader/bin", "elektronenmultiplizierer_port", true); + vp0.defaultShaderCustomization(gl, true, true); + fp0.defaultShaderCustomization(gl, true, true); + final ShaderProgram sp0 = new ShaderProgram(); sp0.add(gl, vp0, System.err); sp0.add(gl, fp0, System.err); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java index e22b00dff..25e6f5ce6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestElektronenMultipliziererNEWT.java @@ -28,7 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; -import com.jogamp.common.os.Platform; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.TraceWindowAdapter; @@ -45,7 +44,6 @@ import javax.media.opengl.GLProfile; import org.junit.Assert; import org.junit.BeforeClass; -import org.junit.AfterClass; import org.junit.Test; /** diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java index 65b86c6ab..98acea6ac 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState01NEWT.java @@ -314,9 +314,11 @@ public class TestGLSLShaderState01NEWT extends UITestCase { final ShaderState st = new ShaderState(); final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader", - "shader/bin", "RedSquareShader", false); + "shader/bin", "RedSquareShader", true); final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader", - "shader/bin", "RedSquareShader", false); + "shader/bin", "RedSquareShader", true); + rsVp.defaultShaderCustomization(gl, true, true); + rsFp.defaultShaderCustomization(gl, true, true); final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); @@ -401,9 +403,11 @@ public class TestGLSLShaderState01NEWT extends UITestCase { final ShaderState st = new ShaderState(); final ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader", - "shader/bin", "RedSquareShader", false); + "shader/bin", "RedSquareShader", true); final ShaderCode rsFp = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader", - "shader/bin", "RedSquareShader", false); + "shader/bin", "RedSquareShader", true); + rsVp.defaultShaderCustomization(gl, true, true); + rsFp.defaultShaderCustomization(gl, true, true); final ShaderProgram sp = new ShaderProgram(); sp.add(rsVp); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java index 2e783e974..bd0e77e9b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glsl/TestGLSLShaderState02NEWT.java @@ -248,11 +248,14 @@ public class TestGLSLShaderState02NEWT extends UITestCase { final ShaderState st = new ShaderState(); final ShaderCode rsVp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, RedSquareES2.class, "shader", - "shader/bin", "RedSquareShader", false); + "shader/bin", "RedSquareShader", true); final ShaderCode rsFp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader", - "shader/bin", "RedSquareShader", false); + "shader/bin", "RedSquareShader", true); final ShaderCode rsFp1 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, RedSquareES2.class, "shader", - "shader/bin", "RedSquareShader2", false); + "shader/bin", "RedSquareShader2", true); + rsVp0.defaultShaderCustomization(gl, true, true); + rsFp0.defaultShaderCustomization(gl, true, true); + rsFp1.defaultShaderCustomization(gl, true, true); final ShaderProgram sp1 = new ShaderProgram(); sp1.add(rsVp0); diff --git a/src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java b/src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java index 989de6c7e..926d4490c 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java +++ b/src/test/com/jogamp/opengl/test/junit/util/GLSLSimpleProgram.java @@ -58,7 +58,7 @@ public class GLSLSimpleProgram { int fragShader = gl.glCreateShader(GL2ES2.GL_FRAGMENT_SHADER); Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - String[] vlines = new String[] { vertShaderCode }; + String[] vlines = new String[] { gl.getContext().getGLSLVersionString()+vertShaderCode }; int[] vlengths = new int[] { vlines[0].length() }; gl.glShaderSource(vertShader, vlines.length, vlines, vlengths, 0); gl.glCompileShader(vertShader); @@ -70,7 +70,7 @@ public class GLSLSimpleProgram { Assert.assertEquals(GL.GL_NO_ERROR, gl.glGetError()); - String[] flines = new String[] { fragShaderCode }; + String[] flines = new String[] { gl.getContext().getGLSLVersionString()+fragShaderCode }; int[] flengths = new int[] { flines[0].length() }; gl.glShaderSource(fragShader, flines.length, flines, flengths, 0); gl.glCompileShader(fragShader); -- cgit v1.2.3 From dba2faf8520a43a809eb756869c6c97a0a2ef2cd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 16 Jul 2013 10:18:54 +0200 Subject: Fix FFMPEGMediaPlayer: Only use RED for GL3ES3 profiles, otherwise stick w/ ALPHA (regression of e92e561df9673ce77783d6fa3815a942a39a53c0) GLES2 does not and GL2 may not support RED! --- make/scripts/tests.sh | 4 ++-- .../classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9e7be06d9..bb8d2463f 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -291,7 +291,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -312,7 +312,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 1264d8986..f416bb1f8 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -193,7 +193,13 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { System.out.println("setURL: p2 "+this); int tf, tif=GL.GL_RGBA; // texture format and internal format switch(vBytesPerPixelPerPlane) { - case 1: tf = GL2ES2.GL_RED; tif=GL2ES2.GL_RED; break; // RED shall be supported on ES2, ES3 and GL3-core! + case 1: + if( gl.isGL3ES3() ) { + tf = GL2ES2.GL_RED; tif=GL2ES2.GL_RED; // RED is supported on ES3 and >= GL3 [core]; ALPHA is deprecated on core! + } else { + tf = GL2ES2.GL_ALPHA; tif=GL2ES2.GL_ALPHA; // ALPHA is supported on ES2 and GL2 + } + break; case 3: tf = GL2ES2.GL_RGB; tif=GL.GL_RGB; break; case 4: tf = GL2ES2.GL_RGBA; tif=GL.GL_RGBA; break; default: throw new RuntimeException("Unsupported bytes-per-pixel / plane "+vBytesPerPixelPerPlane); -- cgit v1.2.3 From 78abc89be7f3935f26802cc0db33f61fc2c65de0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 17 Jul 2013 00:59:45 +0200 Subject: Fix OSX GL-core lack of pbuffer: GLDrawableFactory.canCreateGLPbuffer(..) add GLProfile argument, similar to canCreateFBO(..) In case a compatible non-core profile is requests, canCreateGLPbuffer(..) returns false on OSX. --- make/scripts/tests.sh | 13 ++++++++- .../javax/media/opengl/GLDrawableFactory.java | 18 +++++++----- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 2 +- .../jogamp/opengl/GLDrawableFactoryImpl.java | 4 +-- .../jogamp/opengl/GLGraphicsConfigurationUtil.java | 5 ++-- .../jogamp/opengl/egl/EGLDrawableFactory.java | 2 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 10 ------- .../macosx/cgl/MacOSXCGLDrawableFactory.java | 9 ++++-- .../windows/wgl/WindowsWGLDrawableFactory.java | 2 +- .../opengl/x11/glx/X11GLXDrawableFactory.java | 4 +-- .../acore/TestAddRemove01GLCanvasSwingAWT.java | 22 +++++++------- .../awt/TestBug461FBOSupersamplingSwingAWT.java | 2 +- .../TestBug461PBufferSupersamplingSwingAWT.java | 2 +- .../junit/jogl/caps/TestMultisampleES1NEWT.java | 34 +++++++++++----------- .../junit/jogl/caps/TestMultisampleES2NEWT.java | 4 --- .../offscreen/TestOffscreen01GLPBufferNEWT.java | 16 +++++----- 16 files changed, 79 insertions(+), 70 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bb8d2463f..5489b7944 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -89,6 +89,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" + #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" @@ -312,7 +313,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # @@ -615,5 +616,15 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* # NEW +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +#testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* + $spath/count-edt-start.sh java-run.log diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index f1d8ff95e..580d3a50b 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -443,7 +443,7 @@ public abstract class GLDrawableFactory { *

    *

    * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. *

    *

    * If not onscreen and neither FBO nor Pbuffer is available, @@ -454,7 +454,7 @@ public abstract class GLDrawableFactory { * @throws GLException if any window system-specific errors caused * the creation of the GLDrawable to fail. * - * @see #canCreateGLPbuffer(AbstractGraphicsDevice) + * @see #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) * @see GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) * @see javax.media.opengl.GLCapabilities#isOnscreen() * @see javax.media.opengl.GLCapabilities#isFBO() @@ -482,7 +482,7 @@ public abstract class GLDrawableFactory { *

    *

    * A Pbuffer based auto drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. *

    *

    * If neither FBO nor Pbuffer is available, @@ -520,7 +520,7 @@ public abstract class GLDrawableFactory { *

    *

    * A Pbuffer drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} - * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice) canCreateGLPbuffer(device)} is true. + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. *

    *

    * If neither FBO nor Pbuffer is available, @@ -590,12 +590,16 @@ public abstract class GLDrawableFactory { public abstract boolean canCreateFBO(AbstractGraphicsDevice device, GLProfile glp); /** - * Returns true if it is possible to create a GLPbuffer. Some older - * graphics cards do not have this capability. + * Returns true if it is possible to create an pbuffer surface. + *

    + * Some older graphics cards do not have this capability, + * as well as some new GL implementation, i.e. OpenGL 3 core on OSX. + *

    * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. + * @param glp {@link GLProfile} to check for FBO capabilities */ - public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device); + public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp); /** * Creates a GLPbuffer {@link GLAutoDrawable} with the given capabilites and dimensions. diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 6f4f6f271..996a47590 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1851,7 +1851,7 @@ public abstract class GLContextImpl extends GLContext { } @Override - public boolean isExtensionAvailable(String glExtensionName) { + public final boolean isExtensionAvailable(String glExtensionName) { if(null!=extensionAvailability) { return extensionAvailability.isExtensionAvailable(mapToRealGLExtensionName(glExtensionName)); } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 4ac413545..41ea06deb 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -247,7 +247,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { // @Override - public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device); + public abstract boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp); @Override public GLPbuffer createGLPbuffer(AbstractGraphicsDevice deviceReq, @@ -263,7 +263,7 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { if(null == device) { throw new GLException("No shared device for requested: "+deviceReq); } - if ( !canCreateGLPbuffer(device) ) { + if ( !canCreateGLPbuffer(device, capsRequested.getGLProfile()) ) { throw new GLException("Pbuffer not available with device: "+device); } diff --git a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java index 48b509263..d54da4d28 100644 --- a/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java +++ b/src/jogl/classes/jogamp/opengl/GLGraphicsConfigurationUtil.java @@ -200,8 +200,9 @@ public class GLGraphicsConfigurationUtil { if(null == device) { device = factory.getDefaultDevice(); } - final boolean fboAvailable = GLContext.isFBOAvailable(device, capsRequested.getGLProfile()); - final boolean pbufferAvailable = factory.canCreateGLPbuffer(device); + final GLProfile glp = capsRequested.getGLProfile(); + final boolean fboAvailable = GLContext.isFBOAvailable(device, glp); + final boolean pbufferAvailable = factory.canCreateGLPbuffer(device, glp); final GLRendererQuirks glrq = factory.getRendererQuirks(device); final boolean bitmapAvailable; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 465c8fa80..9c1cc7fc4 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -703,7 +703,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) { + public boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp) { // SharedResource sr = getOrCreateEGLSharedResource(device); // return sr.hasES1PBuffer() || sr.hasES2PBuffer(); return true; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 9b163ae5b..6787ef500 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -74,7 +74,6 @@ import com.jogamp.common.util.VersionNumber; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; -import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.GLRendererQuirks; import com.jogamp.opengl.util.PMVMatrix; import com.jogamp.opengl.util.glsl.ShaderCode; @@ -465,15 +464,6 @@ public class MacOSXCGLContext extends GLContextImpl return new StringBuilder(); } - @Override - public boolean isExtensionAvailable(String glExtensionName) { - if (glExtensionName.equals(GLExtensions.ARB_pbuffer) || - glExtensionName.equals(GLExtensions.ARB_pixel_format)) { - return true; - } - return super.isExtensionAvailable(glExtensionName); - } - // Support for "mode switching" as described in MacOSXCGLDrawable public void setOpenGLMode(GLBackendType mode) { if (mode == openGLMode) { diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java index c9402b33d..83d656475 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java @@ -332,8 +332,13 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) { - return true; + public boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp) { + if( glp.isGL2() ) { + // OSX only supports pbuffer w/ compatible, non-core, context. + return true; + } else { + return false; + } } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 45edda516..338a351cb 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -470,7 +470,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } @Override - public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device) { + public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp) { SharedResource sr = getOrCreateSharedResourceImpl( ( null != device ) ? device : defaultDevice ); if(null!=sr) { return sr.hasARBPBuffer(); diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index b3b02e23f..52069b88f 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -490,7 +490,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } @Override - public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device) { + public final boolean canCreateGLPbuffer(AbstractGraphicsDevice device, GLProfile glp) { if(null == device) { SharedResourceRunner.Resource sr = sharedResourceRunner.getOrCreateShared(defaultDevice); if(null!=sr) { @@ -551,7 +551,7 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { @Override public final boolean canCreateExternalGLDrawable(AbstractGraphicsDevice device) { - return canCreateGLPbuffer(device); + return canCreateGLPbuffer(device, null /* GLProfile not used for query on X11 */); } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java index c2eebbfd8..d96a49bb8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestAddRemove01GLCanvasSwingAWT.java @@ -63,20 +63,22 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { static boolean noOffscreenTest = false; static boolean offscreenPBufferOnly = false; static boolean offscreenFBOOnly = false; - static GLProfile glp; + static GLProfile glpGL2, glpGL2ES2; static int width, height; static boolean waitForKey = false; static boolean waitForKeyPost = false; @BeforeClass public static void initClass() { + width = 640; + height = 480; if(GLProfile.isAvailable(GLProfile.GL2ES2)) { - glp = GLProfile.get(GLProfile.GL2ES2); - Assert.assertNotNull(glp); - width = 640; - height = 480; - } else { - setTestSupported(false); + glpGL2ES2 = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glpGL2ES2); + } + if(GLProfile.isAvailable(GLProfile.GL2)) { + glpGL2 = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glpGL2); } } @@ -198,7 +200,7 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { System.err.println("No onscreen test requested or platform doesn't support onscreen rendering."); return; } - GLCapabilities caps = new GLCapabilities(glp); + GLCapabilities caps = new GLCapabilities(glpGL2ES2); runTestGL(true, caps, addRemoveCount); } @@ -214,7 +216,7 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { System.err.println("Only PBuffer test is requested."); return; } - GLCapabilities caps = new GLCapabilities(glp); + GLCapabilities caps = new GLCapabilities(glpGL2ES2); if(offscreenPBufferOnly) { caps.setPBuffer(true); caps.setOnscreen(true); // simulate normal behavior .. @@ -234,7 +236,7 @@ public class TestAddRemove01GLCanvasSwingAWT extends UITestCase { System.err.println("Only FBO test is requested."); return; } - GLCapabilities caps = new GLCapabilities(glp); + GLCapabilities caps = new GLCapabilities(glpGL2); caps.setPBuffer(true); caps.setOnscreen(true); // simulate normal behavior .. runTestGL(false, caps, addRemoveCount); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java index 22c1f62dd..56e308427 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java @@ -142,7 +142,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL GLDrawableFactory fac = GLDrawableFactory.getFactory(glp); Assert.assertNotNull(fac); - Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice()) ); + Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) ); GLCapabilities glCap = new GLCapabilities(glp); Assert.assertNotNull(glCap); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java index 5b7052c37..bda1a29fd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461PBufferSupersamplingSwingAWT.java @@ -126,7 +126,7 @@ public class TestBug461PBufferSupersamplingSwingAWT extends UITestCase implement GLDrawableFactory fac = GLDrawableFactory.getFactory(glp); Assert.assertNotNull(fac); - Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice()) ); + Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) ); GLCapabilities glCap = new GLCapabilities(glp); Assert.assertNotNull(glCap); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java index 5bbd6737c..bc4ee5502 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1NEWT.java @@ -72,54 +72,54 @@ public class TestMultisampleES1NEWT extends UITestCase { @Test public void testOnscreenMultiSampleAA0() throws InterruptedException { - testMultiSampleAAImpl(true, 0); + testMultiSampleAAImpl(false, false, 0); } @Test public void testOnscreenMultiSampleAA2() throws InterruptedException { - testMultiSampleAAImpl(true, 2); + testMultiSampleAAImpl(false, false, 2); } @Test public void testOnscreenMultiSampleAA4() throws InterruptedException { - testMultiSampleAAImpl(true, 4); + testMultiSampleAAImpl(false, false, 4); } @Test public void testOnscreenMultiSampleAA8() throws InterruptedException { - testMultiSampleAAImpl(true, 8); + testMultiSampleAAImpl(false, false, 8); } @Test - public void testOffscreenMultiSampleAA0() throws InterruptedException { - testMultiSampleAAImpl(false, 0); + public void testOffscreenPBufferMultiSampleAA0() throws InterruptedException { + testMultiSampleAAImpl(false, true, 0); } @Test - public void testOffscreenMultiSampleAA2() throws InterruptedException { - testMultiSampleAAImpl(false, 2); + public void testOffsreenPBufferMultiSampleAA8() throws InterruptedException { + testMultiSampleAAImpl(false, true, 8); } @Test - public void testOffscreenMultiSampleAA4() throws InterruptedException { - testMultiSampleAAImpl(false, 4); + public void testOffscreenFBOMultiSampleAA0() throws InterruptedException { + testMultiSampleAAImpl(true, false, 0); } @Test - public void testOffsreenMultiSampleAA8() throws InterruptedException { - testMultiSampleAAImpl(false, 8); + public void testOffsreenFBOMultiSampleAA8() throws InterruptedException { + testMultiSampleAAImpl(true, false, 8); } - private void testMultiSampleAAImpl(boolean onscreen, int reqSamples) throws InterruptedException { + private void testMultiSampleAAImpl(boolean useFBO, boolean usePBuffer, int reqSamples) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp = GLProfile.getMaxFixedFunc(true); GLCapabilities caps = new GLCapabilities(glp); GLCapabilitiesChooser chooser = new MultisampleChooser01(); - if(!onscreen) { - caps.setOnscreen(onscreen); - caps.setPBuffer(true); - } + caps.setAlphaBits(1); + caps.setFBO(useFBO); + caps.setPBuffer(usePBuffer); + if(reqSamples>0) { caps.setSampleBuffers(true); caps.setNumSamples(reqSamples); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java index c2e3215ae..f3d320dff 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES2NEWT.java @@ -100,10 +100,6 @@ public class TestMultisampleES2NEWT extends UITestCase { } private void testMultiSampleAAImpl(boolean useFBO, boolean usePBuffer, int reqSamples) throws InterruptedException { - if(useFBO) { - System.err.println("NEWT offscreen FBO Window n/a yet"); - return; - } final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); GLProfile glp = GLProfile.getGL2ES2(); GLCapabilities caps = new GLCapabilities(glp); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java index 2ed471436..f1408d38f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/offscreen/TestOffscreen01GLPBufferNEWT.java @@ -56,7 +56,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { glpDefault = GLProfile.getDefault(); Assert.assertNotNull(glpDefault); glDrawableFactory = GLDrawableFactory.getFactory(glpDefault); - System.out.println("INFO: PBuffer supported: "+ glDrawableFactory.canCreateGLPbuffer(null)); + System.out.println("INFO: PBuffer supported: "+ glDrawableFactory.canCreateGLPbuffer(null, glpDefault)); width = 640; height = 480; } @@ -108,7 +108,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { @Test public void test01aOffscreenWindowPBuffer() { - if(!glDrawableFactory.canCreateGLPbuffer(null)) { + if(!glDrawableFactory.canCreateGLPbuffer(null, capsDefault.getGLProfile())) { System.out.println("WARNING: PBuffer not supported on this platform - cannot test"); return; } @@ -118,7 +118,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { @Test public void test01bOffscreenWindowPBufferStencil() { - if(!glDrawableFactory.canCreateGLPbuffer(null)) { + if(!glDrawableFactory.canCreateGLPbuffer(null, capsDefault.getGLProfile())) { System.out.println("WARNING: PBuffer not supported on this platform - cannot test"); return; } @@ -129,7 +129,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { @Test public void test01cOffscreenWindowPBufferStencilAlpha() { - if(!glDrawableFactory.canCreateGLPbuffer(null)) { + if(!glDrawableFactory.canCreateGLPbuffer(null, capsDefault.getGLProfile())) { System.out.println("WARNING: PBuffer not supported on this platform - cannot test"); return; } @@ -141,7 +141,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { @Test public void test01cOffscreenWindowPBuffer555() { - if(!glDrawableFactory.canCreateGLPbuffer(null)) { + if(!glDrawableFactory.canCreateGLPbuffer(null, capsDefault.getGLProfile())) { System.out.println("WARNING: PBuffer not supported on this platform - cannot test"); return; } @@ -154,7 +154,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { @Test public void test02Offscreen3Windows1DisplayPBuffer() { - if(!glDrawableFactory.canCreateGLPbuffer(null)) { + if(!glDrawableFactory.canCreateGLPbuffer(null, capsDefault.getGLProfile())) { System.out.println("WARNING: PBuffer not supported on this platform - cannot test"); return; } @@ -207,7 +207,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { @Test public void test03Offscreen3Windows3DisplaysPBuffer() { - if(!glDrawableFactory.canCreateGLPbuffer(null)) { + if(!glDrawableFactory.canCreateGLPbuffer(null, capsDefault.getGLProfile())) { System.out.println("WARNING: PBuffer not supported on this platform - cannot test"); return; } @@ -260,7 +260,7 @@ public class TestOffscreen01GLPBufferNEWT extends UITestCase { @Test public void test04OffscreenSnapshotWithDemoPBuffer() { - if(!glDrawableFactory.canCreateGLPbuffer(null)) { + if(!glDrawableFactory.canCreateGLPbuffer(null, capsDefault.getGLProfile())) { System.out.println("WARNING: PBuffer not supported on this platform - cannot test"); return; } -- cgit v1.2.3 From bf84f193f9abcd9007939e966c30a958f9659cbf Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 17 Jul 2013 01:14:00 +0200 Subject: More shader fixes for core (GLSL 150): texture2D -> texture, texture3D is deprecated in 130 and removed in 150. --- make/scripts/tests.sh | 4 ++-- .../jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp | 1 + .../classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp | 1 + .../com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.fp | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5489b7944..0ad9d8a83 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -618,13 +618,13 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* $spath/count-edt-start.sh java-run.log diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp index 06edbeaee..fb71abd14 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp @@ -7,6 +7,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp index 07a005709..8e5600dd9 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp @@ -7,6 +7,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; + #define texture2D texture #else #define mgl_FragColor gl_FragColor #endif diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.fp b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.fp index 0087ca361..510096d66 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.fp +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/shader/fbo-mrt-2.fp @@ -3,6 +3,7 @@ #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragData[2]; + #define texture2D texture #else #define mgl_FragData gl_FragData #endif @@ -18,4 +19,4 @@ void main (void) vec2 rg = texture2D(gcs_TexUnit0, texCoord).rg + texture2D(gcs_TexUnit1, texCoord).rg; float b = frontColor.b - length(rg); mgl_FragData[0] = vec4( rg, b, 1.0 ); -} \ No newline at end of file +} -- cgit v1.2.3 From da7210c6498b6fcc2fbf829684ea399a6b4c3f65 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 19 Jul 2013 05:08:34 +0200 Subject: FFMPEGPlayer Audio Sink Refactoring .. - AudioSink w/ AudioFrame and formats public - ALAudioSink uses a circular buffer now, hence relaxes the one-threaded player mode - FFMPEGMediaPlayer uses multiple audio frames (equal to the ALAudioSink number) and wraps data to NIO buffer w/o copy. - FFMPEGMediaPlayer audio threading currently disabled: distorted sound Seems that the ALAudioSink's circular buffer usage is good enough for now. - Verbosity only w/ DEBUG flag - New SyncedRingbuffer for effcient synced buffering --- make/scripts/tests.sh | 15 +- .../com/jogamp/opengl/util/av/AudioSink.java | 168 +++++++ .../jogamp/opengl/util/av/AudioSinkFactory.java | 65 +++ .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 8 + .../opengl/util/av/GLMediaPlayerFactory.java | 26 +- .../android/av/AndroidGLMediaPlayerAPI14.java | 10 +- .../jogamp/opengl/openal/av/ALAudioSink.java | 484 ++++++++++++++++----- .../classes/jogamp/opengl/util/av/AudioSink.java | 13 - .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 4 +- .../jogamp/opengl/util/av/JavaSoundAudioSink.java | 120 +++-- .../jogamp/opengl/util/av/NullAudioSink.java | 41 +- .../jogamp/opengl/util/av/SyncedRingbuffer.java | 286 ++++++++++++ .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 245 ++++++----- src/jogl/native/libav/ffmpeg_tool.h | 4 +- .../jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c | 87 ++-- .../test/junit/jogl/demos/es2/av/MovieCube.java | 2 +- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 2 +- 17 files changed, 1222 insertions(+), 358 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java create mode 100644 src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java delete mode 100644 src/jogl/classes/jogamp/opengl/util/av/AudioSink.java create mode 100644 src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0ad9d8a83..4a326a3f7 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -88,7 +88,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" - D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" + #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" @@ -131,6 +131,7 @@ function jrun() { #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" + D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" @@ -313,7 +314,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # @@ -616,15 +617,5 @@ function testawtswt() { # NEW -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* - -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* -#testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* - -#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAddRemove01GLCanvasSwingAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES2NEWT $* - $spath/count-edt-start.sh java-run.log diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java new file mode 100644 index 000000000..5caeb969a --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java @@ -0,0 +1,168 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.av; + +import java.nio.ByteBuffer; + +import jogamp.opengl.Debug; + +public interface AudioSink { + public static final boolean DEBUG = Debug.debug("AudioSink"); + + /** Specifies the audio data type. Currently only PCM is supported. */ + public static enum AudioDataType { PCM }; + + /** + * Specifies the audio data format. + */ + public static class AudioDataFormat { + public AudioDataFormat(AudioDataType dataType, int sampleRate, int sampleSize, int channelCount, boolean signed, boolean littleEndian) { + this.dataType = dataType; + this.sampleRate = sampleRate; + this.sampleSize = sampleSize; + this.channelCount = channelCount; + this.signed = signed; + this.littleEndian = littleEndian; + } + /** Audio data type. */ + public final AudioDataType dataType; + /** Sample rate in Hz (1/s). */ + public final int sampleRate; + /** Sample size in bits. */ + public final int sampleSize; + /** Number of channels. */ + public final int channelCount; + public final boolean signed; + public final boolean littleEndian; + + public String toString() { + return "AudioDataFormat[type "+dataType+", sampleRate "+sampleRate+", sampleSize "+sampleSize+", channelCount "+channelCount+ + ", signed "+signed+", "+(littleEndian?"little":"big")+"endian]"; } + } + /** Default {@link AudioDataFormat}, [type PCM, sampleRate 44100, sampleSize 16, channelCount 2, signed, littleEndian]. */ + public static final AudioDataFormat DefaultFormat = new AudioDataFormat(AudioDataType.PCM, 44100, 16, 2, true /* signed */, true /* littleEndian */); + + public static class AudioFrame { + public final ByteBuffer data; + public final int dataSize; + public final int audioPTS; + + public AudioFrame(ByteBuffer data, int dataSize, int audioPTS) { + if( dataSize > data.remaining() ) { + throw new IllegalArgumentException("Give size "+dataSize+" exceeds remaining bytes in ls "+data+". "+this); + } + this.data=data; + this.dataSize=dataSize; + this.audioPTS=audioPTS; + } + + public String toString() { return "AudioFrame[apts "+audioPTS+", data "+data+", payloadSize "+dataSize+"]"; } + } + + /** + * Returns the initialized state of this instance. + *

    + * The initialized state is affected by this instance + * overall availability, i.e. after instantiation, + * as well as by {@link #destroy()}. + *

    + */ + public boolean isInitialized(); + + /** + * Returns the preferred {@link AudioDataFormat} by this sink. + *

    + * The preferred format shall reflect this sinks most native format, + * i.e. best performance w/o data conversion. + *

    + * @see #initSink(AudioDataFormat) + */ + public AudioDataFormat getPreferredFormat(); + + /** + * Initializes the sink. + *

    + * Implementation shall try to match the given requestedFormat {@link AudioDataFormat} + * as close as possible, regarding it's capabilities. + *

    + *

    + * A user may consider {@link #getPreferredFormat()} and pass this value + * to utilize best performance and behavior. + *

    + * The {@link #DefaultFormat} should be supported by all implementations. + *

    + * @param requestedFormat the requested {@link AudioDataFormat}. + * @param bufferCount number of buffers for sink + * @return if successful the chosen AudioDataFormat based on the requestedFormat and this sinks capabilities, otherwise null. + */ + public AudioDataFormat initSink(AudioDataFormat requestedFormat, int bufferCount); + + + /** Destroys this instance, i.e. closes all streams and devices allocated. */ + public void destroy(); + + /** + * Returns the number of bytes queued for playing. + *

    + * {@link #initSink(AudioDataFormat)} must be called first. + *

    + */ + public int getQueuedByteCount(); + + /** + * Returns the queued buffer time in milliseconds for playing. + *

    + * {@link #initSink(AudioDataFormat)} must be called first. + *

    + */ + public int getQueuedTime(); + + /** + * Returns the number of buffers in the sink available for writing. + *

    + * {@link #initSink(AudioDataFormat)} must be called first. + *

    + */ + public int getWritableBufferCount(); + + /** + * Returns true if data is available to be written in the sink. + *

    + * {@link #initSink(AudioDataFormat)} must be called first. + *

    + */ + public boolean isDataAvailable(int data_size); + + /** + * Writes the remaining bytes of the given direct ByteBuffer to this sink. + *

    + * The data must comply with the chosen {@link AudioDataFormat} as returned by {@link #initSink(AudioDataFormat)}. + *

    + */ + public void writeData(AudioFrame audioFrame); +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java new file mode 100644 index 000000000..40321fb6f --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSinkFactory.java @@ -0,0 +1,65 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.av; + +import jogamp.opengl.util.av.NullAudioSink; + +import com.jogamp.common.util.ReflectionUtil; + +public class AudioSinkFactory { + private static final String ALAudioSinkClazzName = "jogamp.opengl.openal.av.ALAudioSink"; + private static final String JavaAudioSinkClazzName = "jogamp.opengl.util.av.JavaSoundAudioSink"; + + public static AudioSink createDefault() { + final ClassLoader cl = GLMediaPlayerFactory.class.getClassLoader(); + AudioSink sink = create(cl, ALAudioSinkClazzName); + if( null == sink ) { + sink = create(cl, JavaAudioSinkClazzName); + } + if( null == sink ) { + sink = new NullAudioSink(); + } + return sink; + } + + public static AudioSink create(final ClassLoader cl, String implName) { + final AudioSink audioSink; + if(ReflectionUtil.isClassAvailable(implName, cl)){ + try { + audioSink = (AudioSink) ReflectionUtil.createInstance(implName, cl); + if( audioSink.isInitialized() ) { + return audioSink; + } + } catch (Throwable t) { + if(AudioSink.DEBUG) { System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); t.printStackTrace(); } + } + } + return null; + } + +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 3eca01986..1825dbd47 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -57,6 +57,14 @@ import com.jogamp.opengl.util.texture.TextureSequence; * *

    *

    + * Implementations of this interface must implement: + *

    + *    public static final boolean isAvailable();
    + * 
    + * to be properly considered by {@link GLMediaPlayerFactory#create(ClassLoader, String)} + * and {@link GLMediaPlayerFactory#createDefault()}. + *

    + *

    * Variable type, value range and dimension has been chosen to suit embedded CPUs * and characteristics of audio and video streaming. * Milliseconds of type integer with a maximum value of {@link Integer#MAX_VALUE} diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java index 6fcf20ed2..f09531f7f 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java @@ -38,18 +38,24 @@ public class GLMediaPlayerFactory { private static final String FFMPEGMediaPlayerClazzName = "jogamp.opengl.util.av.impl.FFMPEGMediaPlayer"; private static final String isAvailableMethodName = "isAvailable"; - public static GLMediaPlayer create() { + public static GLMediaPlayer createDefault() { final ClassLoader cl = GLMediaPlayerFactory.class.getClassLoader(); - if(Platform.OS_TYPE.equals(Platform.OSType.ANDROID)) { - if(AndroidVersion.SDK_INT >= 14) { - if(((Boolean)ReflectionUtil.callStaticMethod(AndroidGLMediaPlayerAPI14ClazzName, isAvailableMethodName, null, null, cl)).booleanValue()) { - return (GLMediaPlayer) ReflectionUtil.createInstance(AndroidGLMediaPlayerAPI14ClazzName, cl); - } - } + GLMediaPlayer sink = create(cl, AndroidGLMediaPlayerAPI14ClazzName); + if( null == sink ) { + sink = create(cl, FFMPEGMediaPlayerClazzName); } - if(((Boolean)ReflectionUtil.callStaticMethod(FFMPEGMediaPlayerClazzName, isAvailableMethodName, null, null, cl)).booleanValue()) { - return (GLMediaPlayer) ReflectionUtil.createInstance(FFMPEGMediaPlayerClazzName, cl); + if( null == sink ) { + sink = new NullGLMediaPlayer(); } - return new NullGLMediaPlayer(); + return sink; + } + + public static GLMediaPlayer create(final ClassLoader cl, String implName) { + try { + if(((Boolean)ReflectionUtil.callStaticMethod(implName, isAvailableMethodName, null, null, cl)).booleanValue()) { + return (GLMediaPlayer) ReflectionUtil.createInstance(implName, cl); + } + } catch (Throwable t) { if(GLMediaPlayer.DEBUG) { System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); t.printStackTrace(); } } + return null; } } diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 23f9161d4..8356a2bae 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -32,6 +32,8 @@ import java.io.IOException; import javax.media.opengl.GL; import javax.media.opengl.GLES2; +import com.jogamp.common.os.AndroidVersion; +import com.jogamp.common.os.Platform; import com.jogamp.opengl.util.texture.TextureSequence; import jogamp.common.os.android.StaticContext; @@ -60,7 +62,13 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { static final boolean available; static { - available = true; // default .. TODO: May restrict availability ? + boolean _avail = false; + if(Platform.OS_TYPE.equals(Platform.OSType.ANDROID)) { + if(AndroidVersion.SDK_INT >= 14) { + _avail = true; + } + } + available = _avail; } public static final boolean isAvailable() { return available; } diff --git a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java index 690948c5a..87c7b937a 100644 --- a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java @@ -1,176 +1,428 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ package jogamp.opengl.openal.av; -import java.nio.Buffer; -import java.nio.ByteBuffer; -import java.lang.InterruptedException; +import jogamp.opengl.util.av.SyncedRingbuffer; -import jogamp.opengl.util.av.AudioSink; - -import com.jogamp.common.nio.Buffers; -import com.jogamp.openal.*; +import com.jogamp.openal.AL; +import com.jogamp.openal.ALC; +import com.jogamp.openal.ALCcontext; +import com.jogamp.openal.ALCdevice; +import com.jogamp.openal.ALFactory; +import com.jogamp.opengl.util.av.AudioSink; +/*** + * OpenAL Audio Sink + */ public class ALAudioSink implements AudioSink { - static ALC alc; - static AL al; - static ALCdevice device; - static ALCcontext context; - - // AudioFormat parameters - public static final int SAMPLE_RATE = 44100; - - // Chunk of audio processed at one time - public static final int BUFFER_SIZE = 1000; + /** Chunk of audio processed at one time. FIXME: Parameterize .. */ + public static final int BUFFER_SIZE = 4096; public static final int SAMPLES_PER_BUFFER = BUFFER_SIZE / 2; - // Sample time values - public static final double SAMPLE_TIME_IN_SECS = 1.0 / SAMPLE_RATE; - public static final double BUFFER_TIME_IN_SECS = SAMPLE_TIME_IN_SECS * SAMPLES_PER_BUFFER; + private static final ALC alc; + private static final AL al; + private static final boolean staticAvailable; - private static int NUM_BUFFERS = 5; - private static int bufferNumber = 0; - private static int[] buffers = new int[NUM_BUFFERS]; - private static int[] source = new int[1]; - private static boolean initBuffer = true; - private static int frequency = 44100; - private static int format = AL.AL_FORMAT_STEREO16; + private String deviceSpecifier; + private ALCdevice device; + private ALCcontext context; + + /** Sample period in seconds */ + public float samplePeriod; + /** Buffer period in seconds */ + public float bufferPeriod; - private static boolean available = false; + static class ActiveBuffer { + ActiveBuffer(Integer name, int size) { + this.name = name; + this.size = size; + } + public final Integer name; + public final int size; + public String toString() { return "ABuffer[name "+name+", size "+size+"]"; } + } + int[] alBuffers = null; + private SyncedRingbuffer alBufferAvail = null; + private SyncedRingbuffer alBufferPlaying = null; + private int alBufferBytesQueued = 0; + + private int[] alSource = null; + private AudioDataFormat chosenFormat; + private int alFormat; + private boolean initialized; + static { - - boolean joalFound = false; + ALC _alc = null; + AL _al = null; try { - Class.forName("com.jogamp.openal.ALFactory"); - joalFound = true; - } catch(ClassNotFoundException e){ - // Joal not found on classpath - } - - if(joalFound) { + _alc = ALFactory.getALC(); + _al = ALFactory.getAL(); + } catch(Throwable t) { + if( DEBUG ) { + System.err.println("ALAudioSink: Catched "+t.getClass().getName()+": "+t.getMessage()); + t.printStackTrace(); + } + } + alc = _alc; + al = _al; + staticAvailable = null != alc && null != al; + } + + public ALAudioSink() { + initialized = false; + chosenFormat = null; - alc = ALFactory.getALC(); - String deviceSpecifier; - + if( !staticAvailable ) { + return; + } + + try { // Get handle to default device. device = alc.alcOpenDevice(null); if (device == null) { - throw new ALException("Error opening default OpenAL device"); + throw new RuntimeException("ALAudioSink: Error opening default OpenAL device"); } // Get the device specifier. deviceSpecifier = alc.alcGetString(device, ALC.ALC_DEVICE_SPECIFIER); if (deviceSpecifier == null) { - throw new ALException("Error getting specifier for default OpenAL device"); + throw new RuntimeException("ALAudioSink: Error getting specifier for default OpenAL device"); } // Create audio context. context = alc.alcCreateContext(device, null); if (context == null) { - throw new ALException("Error creating OpenAL context"); + throw new RuntimeException("ALAudioSink: Error creating OpenAL context"); } // Set active context. alc.alcMakeContextCurrent(context); // Check for an error. - if (alc.alcGetError(device) != ALC.ALC_NO_ERROR) { - throw new ALException("Error making OpenAL context current"); + if ( alc.alcGetError(device) != ALC.ALC_NO_ERROR ) { + throw new RuntimeException("ALAudioSink: Error making OpenAL context current"); } - al = ALFactory.getAL(); - - // Allocate buffers - al.alGenBuffers(NUM_BUFFERS, buffers, 0); - al.alGenSources(1, source, 0); + // Create source + { + alSource = new int[1]; + al.alGenSources(1, alSource, 0); + final int err = al.alGetError(); + if( err != AL.AL_NO_ERROR ) { + alSource = null; + throw new RuntimeException("ALAudioSink: Error generating Source: 0x"+Integer.toHexString(err)); + } + } - if(al.alGetError() != AL.AL_NO_ERROR) { - throw new ALException("Error generating :("); - } - - System.out.println("OpenAL audio sink using device: " + deviceSpecifier); - available = true; + if( DEBUG ) { + System.err.println("ALAudioSink: Using device: " + deviceSpecifier); + } + initialized = true; + return; + } catch ( Exception e ) { + if( DEBUG ) { + System.err.println(e.getMessage()); + } + destroy(); } } @Override - public boolean isDataAvailable(int data_size) { - return true; + public String toString() { + final int alSrcName = null != alSource ? alSource[0] : 0; + final int alBuffersLen = null != alBuffers ? alBuffers.length : 0; + return "ALAudioSink[init "+initialized+", device "+deviceSpecifier+", ctx "+context+", alSource "+alSrcName+ + ", chosen "+chosenFormat+", alFormat "+toHexString(alFormat)+ + ", buffers[total "+alBuffersLen+", avail "+alBufferAvail.size()+", "+alBufferPlaying.getFreeSlots()+ + ", queued[bufferCount "+alBufferPlaying.size()+", "+getQueuedTime() + " ms, " + alBufferBytesQueued+" bytes]"; } @Override - public void writeData(byte[] sampleData, int data_size) { - // OpenAL consumes buffers in the background - // we first need to initialize the OpenAL buffers then - // start continous playback. - alc.alcMakeContextCurrent(context); - if(initBuffer) { - - ByteBuffer data = Buffers.newDirectByteBuffer(sampleData); - al.alBufferData(buffers[bufferNumber], format, data, data_size, frequency); - int error = al.alGetError(); - if(error != AL.AL_NO_ERROR) { - System.out.println("bufferNumber"+bufferNumber+" Data "+sampleData+" size"+data_size); - throw new ALException("Error loading :( error code: " + error); + public AudioDataFormat getPreferredFormat() { + return DefaultFormat; + } + + @Override + public AudioDataFormat initSink(AudioDataFormat requestedFormat, int bufferCount) { + if( !staticAvailable ) { + return null; + } + samplePeriod = 1.0f / requestedFormat.sampleRate; + bufferPeriod = samplePeriod * SAMPLES_PER_BUFFER; + switch( requestedFormat.channelCount ) { + case 1: { + switch ( requestedFormat.sampleSize ) { + case 8: + alFormat = AL.AL_FORMAT_MONO8; break; + case 16: + alFormat = AL.AL_FORMAT_MONO16; break; + default: + return null; + } + } break; + case 2: + switch ( requestedFormat.sampleSize ) { + case 8: + alFormat = AL.AL_FORMAT_STEREO8; break; + case 16: + alFormat = AL.AL_FORMAT_STEREO16; break; + default: + return null; + } + } + // Allocate buffers + destroyBuffers(); + { + alBuffers = new int[bufferCount]; + al.alGenBuffers(bufferCount, alBuffers, 0); + final int err = al.alGetError(); + if( err != AL.AL_NO_ERROR ) { + alBuffers = null; + throw new RuntimeException("ALAudioSink: Error generating Buffers: 0x"+Integer.toHexString(err)); } - - if(bufferNumber==NUM_BUFFERS-1){ - // all buffers queued - al.alSourceQueueBuffers(source[0], NUM_BUFFERS, buffers, 0); - // start playback - al.alSourcePlay(source[0]); - if(al.alGetError() != AL.AL_NO_ERROR) { - throw new ALException("Error starting :("); + final Integer[] alBufferRingArray = new Integer[bufferCount]; + for(int i=0; i(alBufferRingArray, true /* full */); + alBufferPlaying = new SyncedRingbuffer(new ActiveBuffer[bufferCount], false /* full */); + } + + + chosenFormat = requestedFormat; + return chosenFormat; + } + + private void destroyBuffers() { + if( !staticAvailable ) { + return; + } + if( null != alBuffers ) { + try { + al.alDeleteBuffers(alBufferAvail.capacity(), alBuffers, 0); + } catch (Throwable t) { + if( DEBUG ) { + System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); + t.printStackTrace(); } - initBuffer=false; } - - // update buffer number to fill - bufferNumber=(bufferNumber+1)%NUM_BUFFERS; - } else { - // OpenAL is playing in the background. - // one new frame with audio data is ready - - // first wait for openal to release one buffer - int[] buffer=new int[1]; - int[] val=new int[1]; - do { - al.alGetSourcei(source[0], AL.AL_BUFFERS_PROCESSED, val, 0); - if(val[0] <= 0){ - try { - Thread.sleep(1); - } catch (InterruptedException e){ - } + alBufferAvail.clear(true); + alBufferAvail = null; + alBufferPlaying.clear(true); + alBufferPlaying = null; + alBufferBytesQueued = 0; + alBuffers = null; + } + } + + @Override + public void destroy() { + initialized = false; + if( !staticAvailable ) { + return; + } + if( null != alSource ) { + try { + al.alDeleteSources(1, alSource, 0); + } catch (Throwable t) { + if( DEBUG ) { + System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); + t.printStackTrace(); } - } while (val[0] <= 0); - - // fill and requeue the empty buffer - al.alSourceUnqueueBuffers(source[0], 1, buffer , 0); - Buffer data = Buffers.newDirectByteBuffer(sampleData); - al.alBufferData(buffer[0], format, data, data_size, frequency); - al.alSourceQueueBuffers(source[0], 1, buffer, 0); - if(al.alGetError() != AL.AL_NO_ERROR) { - throw new ALException("Error buffering :("); } + alSource = null; + } + + destroyBuffers(); - // Restart openal playback if needed - al.alGetSourcei(source[0], AL.AL_SOURCE_STATE, val, 0); - if(val[0] != al.AL_PLAYING) { - al.alSourcePlay(source[0]); + if( null != context ) { + try { + alc.alcDestroyContext(context); + } catch (Throwable t) { + if( DEBUG ) { + System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); + t.printStackTrace(); + } + } + context = null; + } + if( null != device ) { + try { + alc.alcCloseDevice(device); + } catch (Throwable t) { + if( DEBUG ) { + System.err.println("Catched "+t.getClass().getName()+": "+t.getMessage()); + t.printStackTrace(); + } } + device = null; } + chosenFormat = null; + } + + @Override + public boolean isInitialized() { + return initialized; } + + private final void dequeueBuffer(boolean wait) { + int alErr = AL.AL_NO_ERROR; + final int[] val=new int[1]; + do { + al.alGetSourcei(alSource[0], AL.AL_BUFFERS_PROCESSED, val, 0); + alErr = al.alGetError(); + if( AL.AL_NO_ERROR != alErr ) { + throw new RuntimeException("ALError "+toHexString(alErr)+" while quering processed buffers at source. "+this); + } + if( wait && val[0] <= 0 ) { + try { + Thread.sleep(1); + } catch (InterruptedException e){ + } + } + } while (val[0] <= 0); + final int processedBuffers = val[0]; + if( processedBuffers > 0 ) { + int[] buffers=new int[processedBuffers]; + al.alSourceUnqueueBuffers(alSource[0], processedBuffers, buffers, 0); + alErr = al.alGetError(); + if( AL.AL_NO_ERROR != alErr ) { + throw new RuntimeException("ALError "+toHexString(alErr)+" while dequeueing "+processedBuffers+" processed buffers. "+this); + } + for ( int i=0; i + * FIXME: Parameterize .. all configs .. best via an init-method, passing requested + * audio capabilities + *

    + */ +public class JavaSoundAudioSink implements AudioSink { // Chunk of audio processed at one time public static final int BUFFER_SIZE = 1000; public static final int SAMPLES_PER_BUFFER = BUFFER_SIZE / 2; + private static final boolean staticAvailable; // Sample time values - public static final double SAMPLE_TIME_IN_SECS = 1.0 / SAMPLE_RATE; - public static final double BUFFER_TIME_IN_SECS = SAMPLE_TIME_IN_SECS * SAMPLES_PER_BUFFER; + // public static final double SAMPLE_TIME_IN_SECS = 1.0 / DEFAULT_SAMPLE_RATE; + // public static final double BUFFER_TIME_IN_SECS = SAMPLE_TIME_IN_SECS * SAMPLES_PER_BUFFER; - private static AudioFormat format; - private static DataLine.Info info; - private static SourceDataLine auline; - private static int bufferCount; - private static byte [] sampleData = new byte[BUFFER_SIZE]; - - private static boolean available; + private javax.sound.sampled.AudioFormat format; + private DataLine.Info info; + private SourceDataLine auline; + private int bufferCount; + private byte [] sampleData = new byte[BUFFER_SIZE]; + private boolean initialized = false; + private AudioDataFormat chosenFormat = null; static { - // Create the audio format we wish to use - format = new AudioFormat(SAMPLE_RATE, SAMPLE_SIZE, CHANNELS, SIGNED, BIG_ENDIAN); + boolean ok = false; + try { + AudioSystem.getAudioFileTypes(); + ok = true; + } catch (Throwable t) { + + } + staticAvailable=ok; + } + + @Override + public String toString() { + return "JavaSoundSink[init "+initialized+", dataLine "+info+", source "+auline+", bufferCount "+bufferCount+ + ", chosen "+chosenFormat+", jsFormat "+format; + } + + @Override + public AudioDataFormat getPreferredFormat() { + return DefaultFormat; + } + + @Override + public AudioDataFormat initSink(AudioDataFormat requestedFormat, int bufferCount) { + if( !staticAvailable ) { + return null; + } + // Create the audio format we wish to use + format = new javax.sound.sampled.AudioFormat(requestedFormat.sampleRate, requestedFormat.sampleSize, requestedFormat.channelCount, requestedFormat.signed, !requestedFormat.littleEndian); // Create dataline info object describing line format info = new DataLine.Info(SourceDataLine.class, format); @@ -47,33 +75,61 @@ public class JavaSoundAudioSink implements AudioSink { auline.open(format); auline.start(); System.out.println("JavaSound audio sink"); - available=true; + initialized=true; + chosenFormat = requestedFormat; } catch (Exception e) { - available=false; + initialized=false; } - } + return chosenFormat; + } - public void writeData(byte[] sampleData, int data_size) { - int written = 0; - int len; - while (data_size > 0) { - len = auline.write(sampleData, written, data_size); + @Override + public boolean isInitialized() { + return initialized; + } + + @Override + public void destroy() { + initialized = false; + chosenFormat = null; + // FIXEM: complete code! + } + + public void writeData(AudioFrame audioFrame) { + int data_size = audioFrame.dataSize; + final byte[] lala = new byte[data_size]; + final int p = audioFrame.data.position(); + audioFrame.data.get(lala, 0, data_size); + audioFrame.data.position(p); + + int written = 0; + int len; + while (data_size > 0) { + // Nope: We don't make compromises for this crappy API ! + len = auline.write(lala, written, data_size); data_size -= len; written += len; } } - public int getDataAvailable() { + @Override + public int getQueuedByteCount() { return auline.available(); } - public boolean isDataAvailable(int data_size) { - return auline.available()>=data_size; + @Override + public int getQueuedTime() { + return 0; // FIXME } + @Override - public boolean isAudioSinkAvailable() { - return available; + public int getWritableBufferCount() { + return 1; + } + + public boolean isDataAvailable(int data_size) { + return auline.available()>=data_size; } } diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java index d92967849..cef1c3361 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullAudioSink.java @@ -1,23 +1,50 @@ package jogamp.opengl.util.av; + +import com.jogamp.opengl.util.av.AudioSink; + public class NullAudioSink implements AudioSink { @Override - public int getDataAvailable() { - return 0; + public boolean isInitialized() { + return true; } @Override - public boolean isDataAvailable(int data_size) { - return false; + public AudioDataFormat getPreferredFormat() { + return DefaultFormat; + } + + @Override + public AudioDataFormat initSink(AudioDataFormat requestedFormat, int bufferCount) { + return requestedFormat; + } + + @Override + public void destroy() { + } + + @Override + public int getQueuedByteCount() { + return 0; + } + + @Override + public int getQueuedTime() { + return 0; } @Override - public void writeData(byte[] sampleData, int data_size) { + public int getWritableBufferCount() { + return 1; + } + + @Override + public boolean isDataAvailable(int data_size) { + return false; } @Override - public boolean isAudioSinkAvailable() { - return true; + public void writeData(AudioFrame audioFrame) { } } diff --git a/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java b/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java new file mode 100644 index 000000000..5f5d69cf8 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java @@ -0,0 +1,286 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package jogamp.opengl.util.av; + +/** + * Simple synchronized ring buffer implementation. + *

    + * Caller can chose whether to block until get / put is able to proceed or not. + *

    + *

    + * Caller can chose whether to pass an empty array and clear references at get, + * or using a preset array for circular access of same objects. + *

    + *

    + * Circular write position is equal to the read position if buffer is full or if buffer is empty. + *

    + */ +public class SyncedRingbuffer { + + protected final Object sync = new Object(); + protected final T[] array; + protected final int capacity; + protected int readPos; + protected int writePos; + protected int size; + + public final String toString() { + return "SyncedRingbuffer[filled "+size+" / "+capacity+", writePos "+writePos+", readPos "+readPos+"]"; + } + + /** + * Create instance w/ the given array and it's capacity, e.g.: + *
    +     *      SyncedRingbuffer r = new SyncedRingbuffer(new Integer[10]);
    +     * 
    + *

    + * The array may either be clear, or preset w/ elements! + *

    + * @param full if true, given array is assumed to be full, i.e. {@link #isFull()} will return true. + * @param array + */ + public SyncedRingbuffer(T[] array, boolean full) { + this.array = array; + this.capacity = array.length; + clearImpl(false); + if(full) { + size = capacity; + } + } + + public final int capacity() { + return capacity; + } + + /** + * Resets all ring buffer pointer to zero. + *

    + * {@link #isEmpty()} will return true after calling this method. + *

    + *

    + * If clearRefs is true, all ring buffer slots will be set to null. + *

    + * @param clearRefs if true, all ring buffer slots will be flushed, otherwise they remain intact. + */ + public final void clear(boolean clearRefs) { + synchronized ( sync ) { + clearImpl(clearRefs); + } + } + + private final void clearImpl(boolean clearRefs) { + readPos = 0; + writePos = 0; + size = 0; + if( clearRefs ) { + for(int i=0; i + * Impl. returns the element at the current read position + * and advances the read position - if available. + *

    + *

    + * If clearRef is true, the returned ring buffer slot will be set to null. + *

    + *

    + * Method is non blocking and returns immediately;. + *

    + * @param clearRef if true, the returned ring buffer slot will be flushed, otherwise it remains intact. + * @return the oldest put element if available, otherwise null. + */ + public final T get(boolean clearRef) { + try { + return getImpl(clearRef, false, false); + } catch (InterruptedException ie) { throw new RuntimeException(ie); } + } + + /** + * Returns the oldest put element. + *

    + * Impl. returns the element at the current read position + * and advances the read position. + *

    + *

    + * If clearRef is true, the returned ring buffer slot will be set to null. + *

    + *

    + * Methods blocks until an element becomes available via put. + *

    + * @param clearRef if true, the returned ring buffer slot will be flushed, otherwise it remains intact. + * @return the oldest put element + * @throws InterruptedException + */ + public final T getBlocking(boolean clearRef) throws InterruptedException { + return getImpl(clearRef, true, false); + } + + public final T peek() throws InterruptedException { + return getImpl(false, false, true); + } + public final T peekBlocking() throws InterruptedException { + return getImpl(false, true, true); + } + + private final T getImpl(boolean clearRef, boolean blocking, boolean peek) throws InterruptedException { + synchronized ( sync ) { + if( 0 == size ) { + if( blocking ) { + while( 0 == size ) { + sync.wait(); + } + } else { + return null; + } + } + final T r = array[readPos]; + if( !peek ) { + if( clearRef ) { + array[readPos] = null; + } + readPos = (readPos + 1) % capacity; + size--; + sync.notifyAll(); // notify waiting putter + } + return r; + } + } + + /** + * Puts the element e at the current write position + * and advances the write position. + *

    + * Returns true if successful, otherwise false in case buffer is full. + *

    + *

    + * Method is non blocking and returns immediately;. + *

    + */ + public final boolean put(T e) { + try { + return putImpl(e, false, false); + } catch (InterruptedException ie) { throw new RuntimeException(ie); } + } + + /** + * Puts the element e at the current write position + * and advances the write position. + *

    + * Method blocks until a free slot becomes available via get. + *

    + * @throws InterruptedException + */ + public final void putBlocking(T e) throws InterruptedException { + if( !putImpl(e, false, true) ) { + throw new InternalError("Blocking put failed: "+this); + } + } + + /** + * Keeps the element at the current write position intact + * and advances the write position. + *

    + * Returns true if successful, otherwise false in case buffer is full. + *

    + *

    + * If blocking is true, method blocks until a free slot becomes available via get. + *

    + * @param blocking if true, wait until a free slot becomes available via get. + * @throws InterruptedException + */ + public final boolean putSame(boolean blocking) throws InterruptedException { + return putImpl(null, true, blocking); + } + + private final boolean putImpl(T e, boolean sameRef, boolean blocking) throws InterruptedException { + synchronized ( sync ) { + if( capacity <= size ) { + if( blocking ) { + while( capacity <= size ) { + sync.wait(); + } + } else { + return false; + } + } + if( !sameRef ) { + array[ writePos ] = e; + } + writePos = (writePos + 1) % capacity; + size++; + sync.notifyAll(); // notify waiting getter + return true; + } + } + + public final void waitForFreeSlots(int count) throws InterruptedException { + synchronized ( sync ) { + if( capacity - size < count ) { + while( capacity - size < count ) { + System.err.println("XXXX AAA XXX"); + sync.wait(); + } + } + } + } + +} diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 33b5b3b20..65b867ba1 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -38,20 +38,17 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; -import java.util.Arrays; -import java.util.Queue; - -import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.opengl.util.GLPixelStorageModes; -import com.jogamp.opengl.util.av.GLMediaPlayerFactory; +import com.jogamp.opengl.util.av.AudioSink; +import com.jogamp.opengl.util.av.AudioSinkFactory; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; import jogamp.opengl.GLContextImpl; -import jogamp.opengl.util.av.AudioSink; import jogamp.opengl.util.av.EGLMediaPlayerImpl; +import jogamp.opengl.util.av.SyncedRingbuffer; /*** * Implementation utilizes Libav @@ -111,13 +108,10 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { private static final int TEMP_BUFFER_COUNT = 20; // Instance data - private static AudioSink audioSink; - private static int maxAvailableAudio; - public static final VersionNumber avUtilVersion; public static final VersionNumber avFormatVersion; public static final VersionNumber avCodecVersion; - static boolean available; + static final boolean available; static { if(FFMPEGDynamicLibraryBundleInfo.initSingleton()) { @@ -129,24 +123,6 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { System.err.println("LIB_AV Codec : "+avCodecVersion); initIDs0(); available = true; - final ClassLoader cl = GLMediaPlayerFactory.class.getClassLoader(); - - if(ReflectionUtil.isClassAvailable("com.jogamp.openal.ALFactory", cl)){ - // Only instance ALAudioSink if JOAL is found on the classpath. - audioSink = (AudioSink) ReflectionUtil.createInstance("jogamp.opengl.openal.av.ALAudioSink", cl); - if(!audioSink.isAudioSinkAvailable()){ - // Failed to initialize OpenAL. - audioSink=null; - } - } - if(audioSink==null) { - audioSink = (AudioSink) ReflectionUtil.createInstance("jogamp.opengl.util.av.JavaSoundAudioSink", cl); - if(!audioSink.isAudioSinkAvailable()) { - audioSink = (AudioSink) ReflectionUtil.createInstance("jogamp.opengl.util.av.NullAudioSink", cl); - } - } - maxAvailableAudio = audioSink.getDataAvailable(); - } else { avUtilVersion = null; avFormatVersion = null; @@ -163,6 +139,10 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { ( vers >> 0 ) & 0xFF ); } + // + // Video + // + protected long moviePtr = 0; protected long procAddrGLTexSubImage2D = 0; protected EGLMediaPlayerImpl.EGLTextureFrame lastTex = null; @@ -176,17 +156,29 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { protected int texWidth, texHeight; // overall (stuffing planes in one texture) protected ByteBuffer texCopy; + // + // Audio + // + + protected final int AudioFrameCount = 8; + protected final AudioSink audioSink; + protected final int maxAvailableAudio; + protected AudioSink.AudioDataFormat chosenAudioFormat; + protected final SyncedRingbuffer audioFramesBuffer = new SyncedRingbuffer(new AudioSink.AudioFrame[AudioFrameCount], false /* full */); + public FFMPEGMediaPlayer() { super(TextureType.GL, false); if(!available) { throw new RuntimeException("FFMPEGMediaPlayer not available"); } setTextureCount(1); - moviePtr = createInstance0(true); + moviePtr = createInstance0(DEBUG); if(0==moviePtr) { throw new GLException("Couldn't create FFMPEGInstance"); } psm = new GLPixelStorageModes(); + audioSink = AudioSinkFactory.createDefault(); + maxAvailableAudio = audioSink.getQueuedByteCount(); } @Override @@ -221,9 +213,11 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { } final String urlS=urlConn.getURL().toExternalForm(); - System.out.println("setURL: p1 "+this); - setStream0(moviePtr, urlS, -1, -1); - System.out.println("setURL: p2 "+this); + chosenAudioFormat = audioSink.initSink(audioSink.getPreferredFormat(), AudioFrameCount); + System.err.println("setURL: p1 "+this); + setStream0(moviePtr, urlS, -1, -1, AudioFrameCount); + System.err.println("setURL: p2 "+this); + int tf, tif=GL.GL_RGBA; // texture format and internal format switch(vBytesPerPixelPerPlane) { case 1: @@ -264,74 +258,103 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { } - private class AudioFrame { - final byte[] sampleData; - final int data_size; - final int audio_pts; - AudioFrame(byte[] sampleData, int data_size, int audio_pts) { - this.sampleData=sampleData; - this.data_size=data_size; - this.audio_pts=audio_pts; + private final void pushSound(ByteBuffer sampleData, int data_size, int audio_pts) { + if( audioPusher != null && audioPusher.isRunning() ) { + try { + audioFramesBuffer.putBlocking(new AudioSink.AudioFrame(sampleData, data_size, audio_pts)); + } catch (InterruptedException e) { + e.printStackTrace(); // oops + } + if( null != audioPusher ) { + audioPusher.pushOne(); + } } } - static final Queue audioFrameBuffer = new java.util.LinkedList(); - - private void updateSound(byte[] sampleData, int data_size, int audio_pts) { -/* - // Visualize incomming data - int c=0; - for(byte b: sampleData){ - if(b<0) { - System.out.print(" "); - } else if(b<64) { - System.out.print("_"); - } else if(b < 128) { - System.out.print("-"); - } else if(b == 128) { - System.out.print("="); - } else if(b < 256-64) { - System.out.print("\""); - } else { - System.out.print("'"); + class AudioPusher extends Thread { + volatile boolean shallStop = false; + volatile boolean isBlocked = false; + + AudioPusher() { + setDaemon(true); + } + public void requestStop() { + shallStop = true; + if( isBlocked ) { + // interrupt(); } - - c++; - if(c>=40) - break; } - System.out.println("jA"); -*/ - - //TODO reduce GC - audioFrameBuffer.add(new AudioFrame(sampleData, data_size, audio_pts)); - pumpAudio(); - } - - private void pumpAudio() { - if(audioSink.getDataAvailable()==maxAvailableAudio){ - System.out.println("warning: audio buffer underrun"); + public boolean isRunning() { return !shallStop; } + + public void run() { + setName(getName()+"-AudioPusher_"+AudioPusherInstanceId); + AudioPusherInstanceId++; + + while( !shallStop ){ + pushOne(); + } } - while(audioFrameBuffer.peek()!=null){ - AudioFrame a = audioFrameBuffer.peek(); - - // poor mans audio sync .. TODO: off thread - final long now = System.currentTimeMillis(); - final long now_d = now - lastAudioTime; - final long pts_d = a.audio_pts - lastAudioPTS; - final long dt = (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ; - - System.err.println("s: pts-a "+a.audio_pts+", pts-d "+pts_d+", now_d "+now_d+", dt "+dt); - lastAudioTime = now; - if( (dt audio_dt_d && !shallStop; + final long sleepP = dt - ( audio_dt_d / 2 ); + if(DEBUG) { + final int qAT = audioSink.getQueuedTime(); + System.err.println("s: pts-a "+audioFrame.audioPTS+", qAT "+qAT+", pts-d "+pts_d+", now_d "+now_d+", dt "+dt+", sleep "+sleep+", sleepP "+sleepP+" ms"); + } + if( sleep ) { + try { + isBlocked = true; + Thread.sleep( sleepP ); + } catch (InterruptedException e) { + e.printStackTrace(); // oops + } + isBlocked = false; + lastAudioTime = System.currentTimeMillis(); + } else { + lastAudioTime = now; + } + if( !shallStop && audioSink.isDataAvailable(audioFrame.dataSize) ) { + audioSink.writeData(audioFrame); + lastAudioPTS=audioFrame.audioPTS; + } } } } + + static int AudioPusherInstanceId = 0; + private AudioPusher audioPusher = null; + + private final void stopAudioPusher() { + if( null != audioPusher ) { + audioPusher.requestStop(); + audioPusher = null; + } + audioFramesBuffer.clear(true); + } + private final void startAudioPusher() { + stopAudioPusher(); + audioPusher = new AudioPusher(); + // audioPusher.start(); + } private void updateAttributes2(int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, int lSz0, int lSz1, int lSz2, @@ -448,6 +471,7 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { if(0==moviePtr) { return false; } + startAudioPusher(); return true; } @@ -457,6 +481,7 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { if(0==moviePtr) { return false; } + stopAudioPusher(); return true; } @@ -466,6 +491,7 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { if(0==moviePtr) { return false; } + stopAudioPusher(); return true; } @@ -475,12 +501,13 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { if(0==moviePtr) { throw new GLException("FFMPEG native instance null"); } + stopAudioPusher(); int pts0 = getVideoPTS0(moviePtr); int pts1 = seek0(moviePtr, msec); System.err.println("Seek: "+pts0+" -> "+msec+" : "+pts1); - audioFrameBuffer.clear(); lastAudioPTS=pts1; lastVideoPTS=pts1; + startAudioPusher(); return pts1; } @@ -509,6 +536,12 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { tex.enable(gl); tex.bind(gl); + try { + audioFramesBuffer.waitForFreeSlots(2); + } catch (InterruptedException e) { + e.printStackTrace(); // oops + } + /* try decode 10 packets to find one containing video (res == 2) */ int res = 0; @@ -529,27 +562,27 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { final long pts_d = pts - lastAudioPTS - 444; /* hack 444 == play video 444ms ahead of audio */ final long dt = Math.min(47, (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ) ; //final long dt = (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ; - lastVideoTime = now; - System.err.println("s: pts-v "+pts+", pts-d "+pts_d+", now_d "+now_d+", dt "+dt); - - if(dt>video_dt_d && dt<1000 && audioSink.getDataAvailable()video_dt_d && dt<1000 && audioSink.getQueuedByteCount()pts_d) { - System.err.println("s: pts-v "+pts+", pts-d "+pts_d+", now_d "+now_d+", dt "+dt); - } */ + lastVideoTime = System.currentTimeMillis(); + } else { + lastVideoTime = now; + } } - pumpAudio(); lastVideoPTS = pts; } return lastTex; } - private void consumeAudio(int len) { - - } - private static native int getAvUtilVersion0(); private static native int getAvFormatVersion0(); private static native int getAvCodecVersion0(); @@ -557,7 +590,7 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { private native long createInstance0(boolean verbose); private native void destroyInstance0(long moviePtr); - private native void setStream0(long moviePtr, String url, int vid, int aid); + private native void setStream0(long moviePtr, String url, int vid, int aid, int audioFrameCount); private native int getVideoPTS0(long moviePtr); diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index 3181a8a8f..5560b8617 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -82,7 +82,9 @@ typedef struct { AVStream* pAStream; AVCodecContext* pACodecCtx; AVCodec* pACodec; - AVFrame* pAFrame; + AVFrame** pAFrames; + int32_t aFrameCount; + int32_t aFrameCurrent; int32_t aSampleRate; int32_t aChannels; int32_t aFrameSize; diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c index d93caa30b..623bdcac7 100644 --- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c +++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c @@ -38,7 +38,7 @@ typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLi static const char * const ClazzNameFFMPEGMediaPlayer = "jogamp/opengl/util/av/impl/FFMPEGMediaPlayer"; static jclass ffmpegMediaPlayerClazz = NULL; -static jmethodID jni_mid_updateSound = NULL; +static jmethodID jni_mid_pushSound = NULL; static jmethodID jni_mid_updateAttributes1 = NULL; static jmethodID jni_mid_updateAttributes2 = NULL; @@ -192,41 +192,6 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryB return JNI_TRUE; } -static void _updateSound(JNIEnv *env, jobject instance, int8_t *data, int32_t data_size, int32_t aPTS) { - if(NULL!=env) { - jbyteArray jbArray = (*env)->NewByteArray(env, data_size); - if (jbArray == NULL) { - fprintf(stderr, "FFMPEGMediaPlayer out of memory at native code _updateSound"); - return; /* out of memory error thrown */ - } - -/* - // Visualize sample waveform - int i; - for(i=0;i<40;i++){ - int8_t b = data[i]; - if(b<0) { - printf(" "); - } else if(b<64) { - printf("_"); - } else if(b < 128) { - printf("-"); - } else if(b == 128) { - printf("="); - } else if(b < 256-64) { - printf("\""); - } else { - printf("'"); - } - } - printf("nA\n"); -*/ - - (*env)->SetByteArrayRegion(env, jbArray, 0, data_size, data); - (*env)->CallVoidMethod(env, instance, jni_mid_updateSound, jbArray, data_size, aPTS); - } -} - static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasicAV_t* pAV) { // int shallBeDetached = 0; @@ -277,9 +242,12 @@ static void freeInstance(FFMPEGToolBasicAV_t* pAV) { sp_av_free(pAV->pVFrame); pAV->pVFrame = NULL; } - if(NULL != pAV->pAFrame) { - sp_av_free(pAV->pAFrame); - pAV->pAFrame = NULL; + if(NULL != pAV->pAFrames) { + for(i=0; iaFrameCount; i++) { + sp_av_free(pAV->pAFrames[i]); + } + free(pAV->pAFrames); + pAV->pAFrames = NULL; } // Close the video file @@ -370,11 +338,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_ini JoglCommon_FatalError(env, "JOGL FFMPEG: can't use %s", ClazzNameFFMPEGMediaPlayer); } - jni_mid_updateSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateSound", "([BII)V"); + jni_mid_pushSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "pushSound", "(Ljava/nio/ByteBuffer;II)V"); jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIFIILjava/lang/String;Ljava/lang/String;)V"); jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIII)V"); - if(jni_mid_updateSound == NULL || + if(jni_mid_pushSound == NULL || jni_mid_updateAttributes1 == NULL || jni_mid_updateAttributes2 == NULL) { return JNI_FALSE; @@ -415,7 +383,7 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_destroy } JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStream0 - (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jint vid, jint aid) + (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jint vid, jint aid, jint audioFrameCount) { int res, i; jboolean iscopy; @@ -525,11 +493,17 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre pAV->aChannels = pAV->pACodecCtx->channels; pAV->aFrameSize = pAV->pACodecCtx->frame_size; pAV->aSampleFmt = pAV->pACodecCtx->sample_fmt; - pAV->pAFrame=sp_avcodec_alloc_frame(); - if(pAV->pAFrame==NULL) { - JoglCommon_throwNewRuntimeException(env, "Couldn't alloc audio frame"); - return; + + pAV->aFrameCount = audioFrameCount; + pAV->pAFrames = calloc(audioFrameCount, sizeof(AVFrame*)); + for(i=0; iaFrameCount; i++) { + pAV->pAFrames[i]=sp_avcodec_alloc_frame(); + if(pAV->pAFrames[i]==NULL) { + JoglCommon_throwNewRuntimeException(env, "Couldn't alloc audio frame %d / %d", i, audioFrameCount); + return; + } } + pAV->aFrameCurrent = 0; } if(0<=pAV->vid) { @@ -622,11 +596,12 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex if(sp_av_read_frame(pAV->pFormatCtx, &packet)>=0) { if(packet.stream_index==pAV->aid) { // Decode audio frame - if(NULL == pAV->pAFrame) { + if(NULL == pAV->pAFrames) { // no audio registered sp_av_free_packet(&packet); return res; } - + AVFrame* pAFrameCurrent = pAV->pAFrames[pAV->aFrameCurrent]; + pAV->aFrameCurrent = ( pAV->aFrameCurrent + 1 ) % pAV->aFrameCount ; int new_packet = 1; int len1; int flush_complete = 0; @@ -636,7 +611,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex break; } if(HAS_FUNC(sp_avcodec_decode_audio4)) { - len1 = sp_avcodec_decode_audio4(pAV->pACodecCtx, pAV->pAFrame, &frameFinished, &packet); + len1 = sp_avcodec_decode_audio4(pAV->pACodecCtx, pAFrameCurrent, &frameFinished, &packet); } else { #if 0 len1 = sp_avcodec_decode_audio3(pAV->pACodecCtx, int16_t *samples, int *frame_size_ptr, &frameFinished, &packet); @@ -664,11 +639,11 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex if(HAS_FUNC(sp_av_samples_get_buffer_size)) { data_size = sp_av_samples_get_buffer_size(NULL /* linesize, may be NULL */, pAV->aChannels, - pAV->pAFrame->nb_samples, - pAV->pAFrame->format, + pAFrameCurrent->nb_samples, + pAFrameCurrent->format, 1 /* align */); } - int32_t pts = (int64_t) ( pAV->pAFrame->pkt_pts * (int64_t) 1000 * (int64_t) pAV->pAStream->time_base.num ) + int32_t pts = (int64_t) ( pAFrameCurrent->pkt_pts * (int64_t) 1000 * (int64_t) pAV->pAStream->time_base.num ) / (int64_t) pAV->pAStream->time_base.den; #if 0 printf("channels %d sample_rate %d \n", pAV->aChannels , pAV->aSampleRate); @@ -679,10 +654,10 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex if( pAV->verbose ) { printf("A pts %d - %d\n", pts, pAV->aPTS); } - // TODO: Wrap audio buffer data in a com.jogamp.openal.sound3d.Buffer or similar - // and hand it over to the user using a suitable API. - // TODO: OR send the audio buffer data down to sound card directly using JOAL. - _updateSound(env, instance, pAV->pAFrame->data[0], data_size, pAV->aPTS); + if( NULL != env ) { + jobject jSampleData = (*env)->NewDirectByteBuffer(env, pAFrameCurrent->data[0], data_size); + (*env)->CallVoidMethod(env, instance, jni_mid_pushSound, jSampleData, data_size, pAV->aPTS); + } res = 1; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index ad096c7a6..921710fed 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -138,7 +138,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { GL2ES2 gl = drawable.getGL().getGL2ES2(); System.err.println(JoglVersion.getGLInfo(gl, null)); - mPlayer = GLMediaPlayerFactory.create(); + mPlayer = GLMediaPlayerFactory.createDefault(); mPlayer.addEventListener(this); cube = new TextureSequenceCubeES2(mPlayer, false, zoom0, rotx, roty); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index 5bf3145d0..7e0dcd909 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -151,7 +151,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { mPlayerScaleOrig = false; mPlayerShared = false; mPlayerExternal = false; - mPlayer = GLMediaPlayerFactory.create(); + mPlayer = GLMediaPlayerFactory.createDefault(); mPlayer.addEventListener(this); this.stream = stream; System.out.println("pC.1 "+mPlayer); -- cgit v1.2.3 From 7f5ba25559f593cc7b46ed0a35acfd1f9d97128a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 20 Jul 2013 01:23:03 -0700 Subject: FFMPEGMediaPlayer: Cleanup AudioPusher 'usage', i.e. disabled for now (subject to be removed). --- make/scripts/tests.sh | 4 +- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 135 +++++++++++---------- 2 files changed, 73 insertions(+), 66 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4a326a3f7..454bf21f3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -314,8 +314,8 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index fea308255..b6708b379 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -161,11 +161,14 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { // Audio // + protected static final boolean USE_AUDIO_PUSHER = false; protected final int AudioFrameCount = 8; protected final AudioSink audioSink; protected final int maxAvailableAudio; - protected AudioSink.AudioDataFormat chosenAudioFormat; - protected final SyncedRingbuffer audioFramesBuffer = new SyncedRingbuffer(new AudioSink.AudioFrame[AudioFrameCount], false /* full */); + protected AudioSink.AudioDataFormat chosenAudioFormat; + protected final SyncedRingbuffer audioFramesBuffer = + USE_AUDIO_PUSHER ? new SyncedRingbuffer(new AudioSink.AudioFrame[AudioFrameCount], false /* full */) + : null; public FFMPEGMediaPlayer() { super(TextureType.GL, false); @@ -260,20 +263,48 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { } ).longValue(); } - private final void pushSound(ByteBuffer sampleData, int data_size, int audio_pts) { - if( audioPusher != null && audioPusher.isRunning() ) { + if( USE_AUDIO_PUSHER ) { + if( audioPusher != null && audioPusher.isRunning() ) { + try { + audioFramesBuffer.putBlocking(new AudioSink.AudioFrame(sampleData, data_size, audio_pts)); + } catch (InterruptedException e) { + e.printStackTrace(); // oops + } + } + } else { + pushAudioFrame(new AudioSink.AudioFrame(sampleData, data_size, audio_pts)); + } + } + + private final void pushAudioFrame(AudioSink.AudioFrame audioFrame) { + // poor mans audio sync .. + final long now = System.currentTimeMillis(); + final long now_d = now - lastAudioTime; + final long pts_d = audioFrame.audioPTS - lastAudioPTS; + final long dt = (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ; + final boolean sleep = dt > audio_dt_d; + final long sleepP = dt - ( audio_dt_d / 2 ); + if(DEBUG) { + final int qAT = audioSink.getQueuedTime(); + System.err.println("s: pts-a "+audioFrame.audioPTS+", qAT "+qAT+", pts-d "+pts_d+", now_d "+now_d+", dt "+dt+", sleep "+sleep+", sleepP "+sleepP+" ms"); + } + if( sleep ) { try { - audioFramesBuffer.putBlocking(new AudioSink.AudioFrame(sampleData, data_size, audio_pts)); + Thread.sleep( sleepP ); } catch (InterruptedException e) { e.printStackTrace(); // oops } - if( null != audioPusher ) { - audioPusher.pushOne(); - } + lastAudioTime = System.currentTimeMillis(); + } else { + lastAudioTime = now; + } + if( audioSink.isDataAvailable(audioFrame.dataSize) ) { + audioSink.writeData(audioFrame); + lastAudioPTS=audioFrame.audioPTS; } } - + class AudioPusher extends Thread { volatile boolean shallStop = false; volatile boolean isBlocked = false; @@ -284,7 +315,7 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { public void requestStop() { shallStop = true; if( isBlocked ) { - // interrupt(); + interrupt(); } } public boolean isRunning() { return !shallStop; } @@ -294,69 +325,43 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { AudioPusherInstanceId++; while( !shallStop ){ - pushOne(); - } - } - public void pushOne() { - final AudioSink.AudioFrame audioFrame; - try { - isBlocked = true; - audioFrame = audioFramesBuffer.getBlocking(true /* clearRef */); - } catch (InterruptedException e) { - if( !shallStop ) { - e.printStackTrace(); // oops - } - shallStop = true; - return; - } - isBlocked = false; - - if( null != audioFrame ) { - // poor mans audio sync .. - final long now = System.currentTimeMillis(); - final long now_d = now - lastAudioTime; - final long pts_d = audioFrame.audioPTS - lastAudioPTS; - final long dt = (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ; - final boolean sleep = dt > audio_dt_d && !shallStop; - final long sleepP = dt - ( audio_dt_d / 2 ); - if(DEBUG) { - final int qAT = audioSink.getQueuedTime(); - System.err.println("s: pts-a "+audioFrame.audioPTS+", qAT "+qAT+", pts-d "+pts_d+", now_d "+now_d+", dt "+dt+", sleep "+sleep+", sleepP "+sleepP+" ms"); - } - if( sleep ) { - try { - isBlocked = true; - Thread.sleep( sleepP ); - } catch (InterruptedException e) { + final AudioSink.AudioFrame audioFrame; + try { + isBlocked = true; + audioFrame = audioFramesBuffer.getBlocking(true /* clearRef */); + } catch (InterruptedException e) { + if( !shallStop ) { e.printStackTrace(); // oops } - isBlocked = false; - lastAudioTime = System.currentTimeMillis(); - } else { - lastAudioTime = now; + shallStop = true; + return; } - if( !shallStop && audioSink.isDataAvailable(audioFrame.dataSize) ) { - audioSink.writeData(audioFrame); - lastAudioPTS=audioFrame.audioPTS; + isBlocked = false; + + if( null != audioFrame ) { + FFMPEGMediaPlayer.this.pushAudioFrame(audioFrame); } } } - } - + } static int AudioPusherInstanceId = 0; private AudioPusher audioPusher = null; private final void stopAudioPusher() { - if( null != audioPusher ) { - audioPusher.requestStop(); - audioPusher = null; + if( USE_AUDIO_PUSHER ) { + if( null != audioPusher ) { + audioPusher.requestStop(); + audioPusher = null; + } + audioFramesBuffer.clear(true); } - audioFramesBuffer.clear(true); } private final void startAudioPusher() { - stopAudioPusher(); - audioPusher = new AudioPusher(); - // audioPusher.start(); + if( USE_AUDIO_PUSHER ) { + stopAudioPusher(); + audioPusher = new AudioPusher(); + audioPusher.start(); + } } private void updateAttributes2(int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, @@ -539,10 +544,12 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { tex.enable(gl); tex.bind(gl); - try { - audioFramesBuffer.waitForFreeSlots(2); - } catch (InterruptedException e) { - e.printStackTrace(); // oops + if( USE_AUDIO_PUSHER ) { + try { + audioFramesBuffer.waitForFreeSlots(2); + } catch (InterruptedException e) { + e.printStackTrace(); // oops + } } /* try decode 10 packets to find one containing video -- cgit v1.2.3 From 6332e13b2f0aa9818d37802302f04c90a4fa4239 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 10 Aug 2013 09:14:19 +0200 Subject: GLMediaPlayer: Add multithreaded decoding w/ textureCount > 2 where available EGL/FFMPeg. WIP! Off-thread decoding: If validated (impl) textureCount > 2, decoding happens on extra thread. If decoding requires GL context, a shared context is created for decoding thread. API Changes: - initGLStream(..): Adds 'textureCount' as argument. - TextureSequence.TexSeqEventListener.newFrameAvailable(..) exposes the new frame available - TextureSequence.TextureFrame exposes the PTS (video) Implementation: - 'int validateTextureCount(int)': implementation decides whether textureCount can be > 2, i.e. off-thread decoding allowed, default is NO w/ textureCount==2! - 'boolean requiresOffthreadGLCtx()': implementation decides whether shared context is required for off-thread decoding - 'syncFrame2Audio(TextureFrame frame)': implementation shall handle a/v sync, due to audio stream details (pts, buffered frames) - FFMPEGMediaPlayer extends GLMediaPlayerImpl, no more EGLMediaPlayerImpl (redundant) +++ - SyncedRingbuffer: Expose T[] array +++ TODO: - syncAV! - test Android --- make/scripts/tests.sh | 6 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 35 +- .../opengl/util/av/GLMediaPlayerFactory.java | 8 +- .../opengl/util/texture/TextureSequence.java | 17 +- .../android/av/AndroidGLMediaPlayerAPI14.java | 139 +++--- .../jogamp/opengl/util/av/EGLMediaPlayerImpl.java | 20 +- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 501 ++++++++++++++++----- .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 74 +-- .../jogamp/opengl/util/av/SyncedRingbuffer.java | 2 + .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 16 +- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 336 +++++--------- .../opengl/util/av/impl/OMXGLMediaPlayer.java | 44 +- src/jogl/native/libav/ffmpeg_tool.h | 8 + .../jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c | 59 ++- src/jogl/native/openmax/omx_tool.c | 8 +- .../jogl/demos/es2/TextureSequenceCubeES2.java | 2 +- .../test/junit/jogl/demos/es2/av/MovieCube.java | 18 +- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 19 +- 18 files changed, 798 insertions(+), 514 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 454bf21f3..ba4589d14 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -131,7 +131,7 @@ function jrun() { #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" - D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" @@ -314,8 +314,8 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 1825dbd47..a36bce305 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -40,12 +40,12 @@ import com.jogamp.opengl.util.texture.TextureSequence; /** * Lifecycle of an GLMediaPlayer: * - * - * - * - * - * - * + * + * + * + * + * + * *
    action state before state after
    {@link #initGLStream(GL, URLConnection)} Uninitialized Stopped
    {@link #start()} Stopped, Paused Playing
    {@link #stop()} Playing, Paused Stopped
    {@link #pause()} Playing Paused
    {@link #destroy(GL)} ANY Uninitialized
    action state before state after
    {@link #initGLStream(GL, int, URLConnection)} Uninitialized Stopped
    {@link #start()} Stopped, Paused Playing
    {@link #stop()} Playing, Paused Stopped
    {@link #pause()} Playing Paused
    {@link #destroy(GL)} ANY Uninitialized
    *

    * Current implementations (check each API doc link for details): @@ -105,8 +105,12 @@ public interface GLMediaPlayer extends TextureSequence { public int getTextureCount(); - /** Defaults to 0 */ + /** Returns the texture target used by implementation. */ + public int getTextureTarget(); + + /** Sets the texture unit. Defaults to 0. */ public void setTextureUnit(int u); + /** Sets the texture min-mag filter, defaults to {@link GL#GL_NEAREST}. */ public void setTextureMinMagFilter(int[] minMagFilter); /** Sets the texture min-mag filter, defaults to {@link GL#GL_CLAMP_TO_EDGE}. */ @@ -119,6 +123,7 @@ public interface GLMediaPlayer extends TextureSequence { * Uninitialized -> Stopped *

    * @param gl current GL object. If null, no video output and textures will be available. + * @param textureCount desired number of buffered textures to be decoded off-thread, use 1 for on-thread decoding. * @param urlConn the stream connection * @return the new state * @@ -126,7 +131,7 @@ public interface GLMediaPlayer extends TextureSequence { * @throws IOException in case of difficulties to open or process the stream * @throws GLException in case of difficulties to initialize the GL resources */ - public State initGLStream(GL gl, URLConnection urlConn) throws IllegalStateException, GLException, IOException; + public State initGLStream(GL gl, int textureCount, URLConnection urlConn) throws IllegalStateException, GLException, IOException; /** * Releases the GL and stream resources. @@ -161,10 +166,20 @@ public interface GLMediaPlayer extends TextureSequence { public State getState(); /** - * @return time current position in milliseconds + * @return current streaming position in milliseconds **/ public int getCurrentPosition(); + /** + * @return current video PTS in milliseconds of {@link #getLastTexture()} + **/ + public int getVideoPTS(); + + /** + * @return current audio PTS in milliseconds. + **/ + public int getAudioPTS(); + /** * Allowed in state Stopped, Playing and Paused, otherwise ignored. * @@ -187,7 +202,7 @@ public interface GLMediaPlayer extends TextureSequence { *

    * * @see #addEventListener(GLMediaEventListener) - * @see GLMediaEventListener#newFrameAvailable(GLMediaPlayer, long) + * @see GLMediaEventListener#newFrameAvailable(GLMediaPlayer, TextureFrame, long) */ @Override public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException; diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java index f09531f7f..2707dd6d2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java @@ -29,18 +29,20 @@ package com.jogamp.opengl.util.av; import jogamp.opengl.util.av.NullGLMediaPlayer; -import com.jogamp.common.os.AndroidVersion; -import com.jogamp.common.os.Platform; import com.jogamp.common.util.ReflectionUtil; public class GLMediaPlayerFactory { private static final String AndroidGLMediaPlayerAPI14ClazzName = "jogamp.opengl.android.av.AndroidGLMediaPlayerAPI14"; private static final String FFMPEGMediaPlayerClazzName = "jogamp.opengl.util.av.impl.FFMPEGMediaPlayer"; + private static final String OMXGLMediaPlayerClazzName = "jogamp.opengl.util.av.impl.OMXGLMediaPlayer"; private static final String isAvailableMethodName = "isAvailable"; public static GLMediaPlayer createDefault() { final ClassLoader cl = GLMediaPlayerFactory.class.getClassLoader(); - GLMediaPlayer sink = create(cl, AndroidGLMediaPlayerAPI14ClazzName); + GLMediaPlayer sink = create(cl, OMXGLMediaPlayerClazzName); + if( null == sink ) { + sink = create(cl, AndroidGLMediaPlayerAPI14ClazzName); + } if( null == sink ) { sink = create(cl, FFMPEGMediaPlayerClazzName); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index 9f951d5da..3f739b2cc 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -112,26 +112,35 @@ public interface TextureSequence { public static class TextureFrame { public TextureFrame(Texture t) { texture = t; + pts = 0; } public final Texture getTexture() { return texture; } + public final int getPTS() { return pts; } + public final void setPTS(int pts) { this.pts = pts; } public String toString() { - return "TextureFrame[" + texture + "]"; + return "TextureFrame[" + pts + "ms: " + texture + "]"; } protected final Texture texture; + protected int pts; } public interface TexSeqEventListener { /** - * Signaling listeners that {@link TextureSequence#getNextTexture(GL, boolean)} is able to deliver a new frame. + * Signaling listeners that a new {@link TextureFrame} is available. + *

    + * User shall utilize {@link TextureSequence#getNextTexture(GL, boolean)} to dequeue it to maintain + * a consistent queue. + *

    * @param ts the event source + * @param newFrame the newly enqueued frame * @param when system time in msec. **/ - public void newFrameAvailable(T ts, long when); + public void newFrameAvailable(T ts, TextureFrame newFrame, long when); } - /** Return the texture unit to be used with this frame. */ + /** Return the texture unit used to render the current frame. */ public int getTextureUnit(); public int[] getTextureMinMagFilter(); diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 8356a2bae..765cda084 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -28,12 +28,14 @@ package jogamp.opengl.android.av; import java.io.IOException; +import java.nio.Buffer; import javax.media.opengl.GL; import javax.media.opengl.GLES2; import com.jogamp.common.os.AndroidVersion; import com.jogamp.common.os.Platform; +import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; import jogamp.common.os.android.StaticContext; @@ -76,7 +78,6 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { MediaPlayer mp; volatile boolean updateSurface = false; Object updateSurfaceLock = new Object(); - TextureSequence.TextureFrame lastTexFrame = null; /** private static String toString(MediaPlayer m) { @@ -90,17 +91,16 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { throw new RuntimeException("AndroidGLMediaPlayerAPI14 not available"); } this.setTextureTarget(GLES2.GL_TEXTURE_EXTERNAL_OES); - this.setTextureCount(1); mp = new MediaPlayer(); } @Override - protected boolean setPlaySpeedImpl(float rate) { + protected final boolean setPlaySpeedImpl(float rate) { return false; } @Override - protected boolean startImpl() { + protected final boolean startImpl() { if(null != mp) { try { mp.start(); @@ -115,7 +115,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected boolean pauseImpl() { + protected final boolean pauseImpl() { if(null != mp) { wakeUp(false); try { @@ -131,7 +131,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected boolean stopImpl() { + protected final boolean stopImpl() { if(null != mp) { wakeUp(false); try { @@ -147,7 +147,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected int seekImpl(int msec) { + protected final int seekImpl(int msec) { if(null != mp) { mp.seekTo(msec); return mp.getCurrentPosition(); @@ -155,40 +155,6 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { return 0; } - @Override - protected TextureSequence.TextureFrame getLastTextureImpl() { - return lastTexFrame; - } - - @Override - protected TextureSequence.TextureFrame getNextTextureImpl(GL gl, boolean blocking) { - if(null != stex && null != mp) { - // Only block once, no while-loop. - // This relaxes locking code of non crucial resources/events. - boolean update = updateSurface; - if(!update && blocking) { - synchronized(updateSurfaceLock) { - if(!updateSurface) { // volatile OK. - try { - updateSurfaceLock.wait(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - updateSurface = false; - update = true; - } - } - if(update) { - stex.updateTexImage(); - // stex.getTransformMatrix(atex.getSTMatrix()); - lastTexFrame=texFrames[0]; - } - - } - return lastTexFrame; - } - private void wakeUp(boolean newFrame) { synchronized(updateSurfaceLock) { if(newFrame) { @@ -199,12 +165,13 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected int getCurrentPositionImpl() { - return null != mp ? mp.getCurrentPosition() : 0; - } + protected final int getCurrentPositionImpl() { return null != mp ? mp.getCurrentPosition() : 0; } + + @Override + protected final int getAudioPTSImpl() { return getCurrentPositionImpl(); } @Override - protected void destroyImpl(GL gl) { + protected final void destroyImpl(GL gl) { if(null != mp) { wakeUp(false); mp.release(); @@ -213,9 +180,25 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } SurfaceTexture stex = null; + public static class SurfaceTextureFrame extends TextureSequence.TextureFrame { + public SurfaceTextureFrame(Texture t, SurfaceTexture stex) { + super(t); + this.surfaceTex = stex; + this.surface = new Surface(stex); + } + + public final SurfaceTexture getSurfaceTexture() { return surfaceTex; } + public final Surface getSurface() { return surface; } + + public String toString() { + return "SurfaceTextureFrame[" + pts + "ms: " + texture + ", " + surfaceTex + "]"; + } + private final SurfaceTexture surfaceTex; + private final Surface surface; + } @Override - protected void initGLStreamImpl(GL gl, int[] texNames) throws IOException { + protected final void initGLStreamImpl(GL gl) throws IOException { if(null!=mp && null!=urlConn) { try { final Uri uri = Uri.parse(urlConn.getURL().toExternalForm()); @@ -227,44 +210,86 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } catch (IllegalStateException e) { throw new RuntimeException(e); } - stex = new SurfaceTexture(texNames[0]); // only 1 texture - stex.setOnFrameAvailableListener(onFrameAvailableListener); + if( null == stex ) { + throw new InternalError("XXX"); + } final Surface surf = new Surface(stex); mp.setSurface(surf); surf.release(); + mp.setSurface(null); try { mp.prepare(); } catch (IOException ioe) { throw new IOException("MediaPlayer failed to process stream <"+urlConn.getURL().toExternalForm()+">: "+ioe.getMessage(), ioe); } + final String icodec = "android"; updateAttributes(mp.getVideoWidth(), mp.getVideoHeight(), 0, 0, 0, 0f, 0, mp.getDuration(), - null, null); + icodec, icodec); + } + } + + @Override + protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking) { + if(null != stex && null != mp) { + final SurfaceTextureFrame nextSFrame = (SurfaceTextureFrame) nextFrame; + final Surface nextSurface = nextSFrame.getSurface(); + mp.setSurface(nextSurface); + nextSurface.release(); + + // Only block once, no while-loop. + // This relaxes locking code of non crucial resources/events. + boolean update = updateSurface; + if(!update && blocking) { + synchronized(updateSurfaceLock) { + if(!updateSurface) { // volatile OK. + try { + updateSurfaceLock.wait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + update = updateSurface; + updateSurface = false; + } + } + if(update) { + final SurfaceTexture nextSTex = nextSFrame.getSurfaceTexture(); + nextSTex.updateTexImage(); + // nextFrame.setPTS( (int) ( nextSTex.getTimestamp() / 1000000L ) ); // nano -9 -> milli -3 + nextFrame.setPTS( mp.getCurrentPosition() ); + // stex.getTransformMatrix(atex.getSTMatrix()); + } } + return true; } + @Override + protected final void syncFrame2Audio(TextureFrame frame) {} @Override - protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) { - lastTexFrame = new TextureSequence.TextureFrame( createTexImageImpl(gl, idx, tex, width, height, true) ); - return lastTexFrame; + protected final TextureSequence.TextureFrame createTexImage(GL gl, int texName) { + if( null != stex ) { + throw new InternalError("XXX"); + } + stex = new SurfaceTexture(texName); // only 1 texture + stex.setOnFrameAvailableListener(onFrameAvailableListener); + return new TextureSequence.TextureFrame( createTexImageImpl(gl, texName, width, height, true) ); } @Override - protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) { + protected final void destroyTexFrame(GL gl, TextureSequence.TextureFrame imgTex) { if(null != stex) { stex.release(); stex = null; } - lastTexFrame = null; - super.destroyTexImage(gl, imgTex); + super.destroyTexFrame(gl, imgTex); } protected OnFrameAvailableListener onFrameAvailableListener = new OnFrameAvailableListener() { @Override public void onFrameAvailable(SurfaceTexture surfaceTexture) { wakeUp(true); - AndroidGLMediaPlayerAPI14.this.newFrameAvailable(); } - }; + }; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java index 274ccffd5..57d5ff625 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java @@ -77,19 +77,19 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { } - protected EGLMediaPlayerImpl() { - this(TextureType.GL, false); - } - protected EGLMediaPlayerImpl(TextureType texType, boolean useKHRSync) { super(); this.texType = texType; this.useKHRSync = useKHRSync; } + @Override + protected final int validateTextureCount(int desiredTextureCount) { + return desiredTextureCount>1 ? desiredTextureCount : 2; + } @Override - protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) { - final Texture texture = super.createTexImageImpl(gl, idx, tex, width, height, false); + protected TextureSequence.TextureFrame createTexImage(GL gl, int texName) { + final Texture texture = super.createTexImageImpl(gl, texName, width, height, false); final Buffer clientBuffer; final long image; final long sync; @@ -117,7 +117,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { EGLExt.EGL_GL_TEXTURE_2D_KHR, clientBuffer, nioTmp); if (0==image) { - throw new RuntimeException("EGLImage creation failed: "+EGL.eglGetError()+", ctx "+eglCtx+", tex "+tex[idx]+", err "+toHexString(EGL.eglGetError())); + throw new RuntimeException("EGLImage creation failed: "+EGL.eglGetError()+", ctx "+eglCtx+", tex "+texName+", err "+toHexString(EGL.eglGetError())); } } else { clientBuffer = null; @@ -141,7 +141,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { } @Override - protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) { + protected void destroyTexFrame(GL gl, TextureSequence.TextureFrame frame) { final boolean eglUsage = TextureType.KHRImage == texType || useKHRSync ; final EGLContext eglCtx; final EGLExt eglExt; @@ -156,7 +156,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { eglExt = null; eglDrawable = null; } - final EGLTextureFrame eglTex = (EGLTextureFrame) imgTex; + final EGLTextureFrame eglTex = (EGLTextureFrame) frame; if(0!=eglTex.getImage()) { eglExt.eglDestroyImageKHR(eglDrawable.getNativeSurface().getDisplayHandle(), eglTex.getImage()); @@ -164,6 +164,6 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { if(0!=eglTex.getSync()) { eglExt.eglDestroySyncKHR(eglDrawable.getNativeSurface().getDisplayHandle(), eglTex.getSync()); } - super.destroyTexImage(gl, imgTex); + super.destroyTexFrame(gl, frame); } } diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 2ff91a3f6..bc297dc21 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -30,13 +30,17 @@ package jogamp.opengl.util.av; import java.io.IOException; import java.net.URLConnection; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; +import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GL; import javax.media.opengl.GL2; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLES2; import javax.media.opengl.GLException; +import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; @@ -45,7 +49,7 @@ import com.jogamp.opengl.util.texture.TextureSequence; /** * After object creation an implementation may customize the behavior: *
      - *
    • {@link #setTextureCount(int)}
    • + *
    • {@link #setDesTextureCount(int)}
    • *
    • {@link #setTextureTarget(int)}
    • *
    • {@link EGLMediaPlayerImpl#setEGLTexImageAttribs(boolean, boolean)}.
    • *
    @@ -59,6 +63,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected static final String unknown = "unknown"; protected State state; + protected int textureCount; protected int textureTarget; protected int textureFormat; @@ -74,35 +79,38 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected volatile float playSpeed = 1.0f; - /** Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected int width = 0; - /** Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected int height = 0; - /** Video fps. Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** Video fps. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected float fps = 0; - /** Stream bps. Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** Stream bps. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected int bps_stream = 0; - /** Video bps. Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** Video bps. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected int bps_video = 0; - /** Audio bps. Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** Audio bps. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected int bps_audio = 0; - /** In frames. Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** In frames. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected int totalFrames = 0; - /** In ms. Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** In ms. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected int duration = 0; - /** Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected String acodec = unknown; - /** Shall be set by the {@link #initGLStreamImpl(GL, int[])} method implementation. */ + /** Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ protected String vcodec = unknown; protected int frameNumber = 0; + protected int currentVideoPTS = 0; - protected TextureSequence.TextureFrame[] texFrames = null; - protected HashMap texFrameMap = new HashMap(); + protected SyncedRingbuffer videoFramesFree = null; + protected SyncedRingbuffer videoFramesDecoded = null; + protected volatile TextureFrame lastFrame = null; + private ArrayList eventListeners = new ArrayList(); protected GLMediaPlayerImpl() { - this.textureCount=3; + this.textureCount=0; this.textureTarget=GL.GL_TEXTURE_2D; this.textureFormat = GL.GL_RGBA; this.textureInternalFormat = GL.GL_RGBA; @@ -112,14 +120,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } @Override - public void setTextureUnit(int u) { texUnit = u; } + public final void setTextureUnit(int u) { texUnit = u; } @Override - public int getTextureUnit() { return texUnit; } + public final int getTextureUnit() { return texUnit; } + + @Override + public final int getTextureTarget() { return textureTarget; } - protected final void setTextureCount(int textureCount) { - this.textureCount=textureCount; - } @Override public final int getTextureCount() { return textureCount; } @@ -134,29 +142,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final int[] getTextureMinMagFilter() { return texMinMagFilter; } public final void setTextureWrapST(int[] wrapST) { texWrapST[0] = wrapST[0]; texWrapST[1] = wrapST[1];} - public final int[] getTextureWrapST() { return texWrapST; } - - @Override - public final TextureSequence.TextureFrame getLastTexture() throws IllegalStateException { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); - } - return getLastTextureImpl(); - } - protected abstract TextureSequence.TextureFrame getLastTextureImpl(); - - @Override - public final synchronized TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); - } - if(State.Playing == state) { - final TextureSequence.TextureFrame f = getNextTextureImpl(gl, blocking); - return f; - } - return getLastTextureImpl(); - } - protected abstract TextureSequence.TextureFrame getNextTextureImpl(GL gl, boolean blocking); + public final int[] getTextureWrapST() { return texWrapST; } @Override public String getRequiredExtensionsShaderStub() throws IllegalStateException { @@ -229,12 +215,15 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected abstract boolean setPlaySpeedImpl(float rate); public final State start() { - switch(state) { + switch( state ) { case Stopped: + /** fall-through intended */ case Paused: - if(startImpl()) { + if( startImpl() ) { + resumeFramePusher(); state = State.Playing; } + default: } if(DEBUG) { System.err.println("Start: "+toString()); } return state; @@ -242,7 +231,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected abstract boolean startImpl(); public final State pause() { - if(State.Playing == state && pauseImpl()) { + if( State.Playing == state && pauseImpl() ) { + pauseFramePusher(); state = State.Paused; } if(DEBUG) { System.err.println("Pause: "+toString()); } @@ -251,12 +241,15 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected abstract boolean pauseImpl(); public final State stop() { - switch(state) { + switch( state ) { case Playing: + /** fall-through intended */ case Paused: - if(stopImpl()) { + if( stopImpl() ) { + pauseFramePusher(); state = State.Stopped; } + default: } if(DEBUG) { System.err.println("Stop: "+toString()); } return state; @@ -265,61 +258,70 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final int getCurrentPosition() { - if(State.Uninitialized != state) { + if( State.Uninitialized != state ) { return getCurrentPositionImpl(); } return 0; } protected abstract int getCurrentPositionImpl(); + @Override + public final int getVideoPTS() { return currentVideoPTS; } + + @Override + public final int getAudioPTS() { + if( State.Uninitialized != state ) { + return getAudioPTSImpl(); + } + return 0; + } + protected abstract int getAudioPTSImpl(); + public final int seek(int msec) { - final int cp; + final int pts1; switch(state) { case Stopped: case Playing: case Paused: - cp = seekImpl(msec); + pauseFramePusher(); + pts1 = seekImpl(msec); + currentVideoPTS=pts1; + resumeFramePusher(); break; default: - cp = 0; + pts1 = 0; } if(DEBUG) { System.err.println("Seek("+msec+"): "+toString()); } - return cp; + return pts1; } protected abstract int seekImpl(int msec); public final State getState() { return state; } @Override - public final State initGLStream(GL gl, URLConnection urlConn) throws IllegalStateException, GLException, IOException { + public final State initGLStream(GL gl, int reqTextureCount, URLConnection urlConn) throws IllegalStateException, GLException, IOException { if(State.Uninitialized != state) { throw new IllegalStateException("Instance not in state "+State.Uninitialized+", but "+state+", "+this); } this.urlConn = urlConn; if (this.urlConn != null) { try { - if(null != gl) { - if(null!=texFrames) { - // re-init .. - removeAllImageTextures(gl); - } else { - texFrames = new TextureSequence.TextureFrame[textureCount]; - } - final int[] tex = new int[textureCount]; - { - gl.glGenTextures(textureCount, tex, 0); - final int err = gl.glGetError(); - if( GL.GL_NO_ERROR != err ) { - throw new RuntimeException("TextureNames creation failed (num: "+textureCount+"): err "+toHexString(err)); - } + if( null != gl ) { + removeAllTextureFrames(gl); + textureCount = validateTextureCount(reqTextureCount); + if( textureCount < 2 ) { + throw new InternalError("Validated texture count < 2: "+textureCount); } - initGLStreamImpl(gl, tex); - - for(int i=0; i(createTexFrames(gl, textureCount), true /* full */); + if( 2 < textureCount ) { + videoFramesDecoded = new SyncedRingbuffer(new TextureFrame[textureCount], false /* full */); + framePusher = new FramePusher(gl, requiresOffthreadGLCtx()); + framePusher.doStart(); + } else { + videoFramesDecoded = null; } + lastFrame = videoFramesFree.getBlocking(false /* clearRef */ ); } state = State.Stopped; return state; @@ -329,35 +331,42 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } return state; } + /** + * Returns the validated number of textures to be handled. + *

    + * Default is always 2 textures, last texture and the decoding texture. + *

    + */ + protected int validateTextureCount(int desiredTextureCount) { + return 2; + } + protected boolean requiresOffthreadGLCtx() { return false; } - /** - * Implementation shall set the following set of data here - * @param gl TODO - * @param texNames TODO - * @see #width - * @see #height - * @see #fps - * @see #bps_stream - * @see #totalFrames - * @see #acodec - * @see #vcodec - */ - protected abstract void initGLStreamImpl(GL gl, int[] texNames) throws IOException; - - protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) { - return new TextureSequence.TextureFrame( createTexImageImpl(gl, idx, tex, width, height, false) ); + private final TextureFrame[] createTexFrames(GL gl, final int count) { + final int[] texNames = new int[count]; + gl.glGenTextures(count, texNames, 0); + final int err = gl.glGetError(); + if( GL.GL_NO_ERROR != err ) { + throw new RuntimeException("TextureNames creation failed (num: "+count+"): err "+toHexString(err)); + } + final TextureFrame[] texFrames = new TextureFrame[count]; + for(int i=0; i tex[idx] ) { - throw new RuntimeException("TextureName "+toHexString(tex[idx])+" invalid."); + protected final Texture createTexImageImpl(GL gl, int texName, int tWidth, int tHeight, boolean mustFlipVertically) { + if( 0 > texName ) { + throw new RuntimeException("TextureName "+toHexString(texName)+" invalid."); } gl.glActiveTexture(GL.GL_TEXTURE0+getTextureUnit()); - gl.glBindTexture(textureTarget, tex[idx]); + gl.glBindTexture(textureTarget, texName); { final int err = gl.glGetError(); if( GL.GL_NO_ERROR != err ) { - throw new RuntimeException("Couldn't bind textureName "+toHexString(tex[idx])+" to 2D target, err "+toHexString(err)); + throw new RuntimeException("Couldn't bind textureName "+toHexString(texName)+" to 2D target, err "+toHexString(err)); } } @@ -389,30 +398,297 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_S, texWrapST[0]); gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_WRAP_T, texWrapST[1]); - return com.jogamp.opengl.util.texture.TextureIO.newTexture(tex[idx], - textureTarget, + return com.jogamp.opengl.util.texture.TextureIO.newTexture( + texName, textureTarget, tWidth, tHeight, width, height, mustFlipVertically); } + + private final void removeAllTextureFrames(GL gl) { + if( null != videoFramesFree ) { + final TextureFrame[] texFrames = videoFramesFree.getArray(); + videoFramesFree = null; + videoFramesDecoded = null; + lastFrame = null; + for(int i=0; i i = eventListeners.iterator(); i.hasNext(); ) { + i.next().newFrameAvailable(this, frame, System.currentTimeMillis()); + } + } + } + + class FramePusher extends Thread { + private volatile boolean isRunning = false; + private volatile boolean isActive = false; + + private volatile boolean shallPause = true; + private volatile boolean shallStop = false; + + private final GL gl; + private GLDrawable dummyDrawable = null; + private GLContext sharedGLCtx = null; + + FramePusher(GL gl, boolean createSharedCtx) { + setDaemon(true); + this.gl = createSharedCtx ? createSharedGL(gl) : gl; + } + + private GL createSharedGL(GL gl) { + final GLContext glCtx = gl.getContext(); + final boolean glCtxCurrent = glCtx.isCurrent(); + final GLProfile glp = gl.getGLProfile(); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); + final AbstractGraphicsDevice device = glCtx.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); + dummyDrawable = factory.createDummyDrawable(device, true, glp); // own device! + dummyDrawable.setRealized(true); + sharedGLCtx = dummyDrawable.createContext(glCtx); + makeCurrent(sharedGLCtx); + if( glCtxCurrent ) { + makeCurrent(glCtx); + } else { + sharedGLCtx.release(); + } + return sharedGLCtx.getGL(); + } + private void makeCurrent(GLContext ctx) { + if( GLContext.CONTEXT_NOT_CURRENT >= ctx.makeCurrent() ) { + throw new GLException("Couldn't make ctx current: "+ctx); + } + } + + private void destroySharedGL() { + if( null != sharedGLCtx ) { + if( sharedGLCtx.isCreated() ) { + // Catch dispose GLExceptions by GLEventListener, just 'print' them + // so we can continue with the destruction. + try { + sharedGLCtx.destroy(); + } catch (GLException gle) { + gle.printStackTrace(); + } + } + sharedGLCtx = null; + } + if( null != dummyDrawable ) { + final AbstractGraphicsDevice device = dummyDrawable.getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); + dummyDrawable.setRealized(false); + dummyDrawable = null; + device.close(); + } + } + + public synchronized void doPause() { + if( isActive ) { + shallPause = true; + while( isActive ) { + try { + this.wait(); // wait until paused + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + public synchronized void doResume() { + if( isRunning && !isActive ) { + shallPause = false; + while( !isActive ) { + this.notify(); // wake-up pause-block + try { + this.wait(); // wait until resumed + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + public synchronized void doStart() { + start(); + while( !isRunning ) { + try { + this.wait(); // wait until started + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + public synchronized void doStop() { + if( isRunning ) { + shallStop = true; + while( isRunning ) { + this.notify(); // wake-up pause-block (opt) + try { + this.wait(); // wait until stopped + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } + public boolean isRunning() { return isRunning; } + public boolean isActive() { return isActive; } + + public void run() { + setName(getName()+"-FramePusher_"+FramePusherInstanceId); + FramePusherInstanceId++; + + synchronized ( this ) { + if( null != sharedGLCtx ) { + makeCurrent( sharedGLCtx ); + } + isRunning = true; + this.notify(); // wake-up doStart() + } + + while( !shallStop ){ + if( shallPause ) { + synchronized ( this ) { + while( shallPause && !shallStop ) { + isActive = false; + this.notify(); // wake-up doPause() + try { + this.wait(); // wait until resumed + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + isActive = true; + this.notify(); // wake-up doResume() + } + } + + if( !shallStop ) { + TextureFrame nextFrame = null; + boolean ok = false; + try { + nextFrame = videoFramesFree.getBlocking(true /* clearRef */ ); + if( getNextTextureImpl(gl, nextFrame, true) ) { + gl.glFinish(); + videoFramesDecoded.putBlocking(nextFrame); + newFrameAvailable(nextFrame); + ok = true; + } + } catch (InterruptedException e) { + if( !shallStop && !shallPause ) { + e.printStackTrace(); // oops + shallPause = false; + shallStop = true; + } + } finally { + if( !ok && null != nextFrame ) { // put back + videoFramesFree.put(nextFrame); + } + } + } + } + destroySharedGL(); + synchronized ( this ) { + isRunning = false; + isActive = false; + this.notify(); // wake-up doStop() + } + } + } + static int FramePusherInstanceId = 0; + private FramePusher framePusher = null; + private final void pauseFramePusher() { + if( null != framePusher ) { + framePusher.doPause(); + } + } + private final void resumeFramePusher() { + if( null != framePusher ) { + framePusher.doResume(); + } + } + private final void destroyFramePusher() { + if( null != framePusher ) { + framePusher.doStop(); + framePusher = null; + } + } + protected final void updateAttributes(int width, int height, int bps_stream, int bps_video, int bps_audio, float fps, int totalFrames, int duration, String vcodec, String acodec) { @@ -458,19 +734,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - protected final void newFrameAvailable() { - frameNumber++; - synchronized(eventListenersLock) { - for(Iterator i = eventListeners.iterator(); i.hasNext(); ) { - i.next().newFrameAvailable(this, System.currentTimeMillis()); - } - } - } @Override public final synchronized State destroy(GL gl) { + destroyFramePusher(); destroyImpl(gl); - removeAllImageTextures(gl); + removeAllTextureFrames(gl); state = State.Uninitialized; return state; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index cd48c3962..f1ce42257 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -49,66 +49,68 @@ import com.jogamp.opengl.util.texture.TextureSequence; */ public class NullGLMediaPlayer extends GLMediaPlayerImpl { private TextureData texData = null; - private TextureSequence.TextureFrame frame = null; private int pos_ms = 0; private int pos_start = 0; public NullGLMediaPlayer() { super(); - this.setTextureCount(1); } @Override - protected boolean setPlaySpeedImpl(float rate) { + protected final boolean setPlaySpeedImpl(float rate) { return false; } @Override - protected boolean startImpl() { + protected final boolean startImpl() { pos_start = (int)System.currentTimeMillis(); return true; } @Override - protected boolean pauseImpl() { + protected final boolean pauseImpl() { return true; } @Override - protected boolean stopImpl() { + protected final boolean stopImpl() { return true; } @Override - protected int seekImpl(int msec) { + protected final int seekImpl(int msec) { pos_ms = msec; validatePos(); return pos_ms; } @Override - protected TextureSequence.TextureFrame getLastTextureImpl() { - return frame; + protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking) { + return true; } - @Override - protected TextureSequence.TextureFrame getNextTextureImpl(GL gl, boolean blocking) { - return frame; - } + protected final void syncFrame2Audio(TextureFrame frame) { } @Override - protected int getCurrentPositionImpl() { + protected final int getCurrentPositionImpl() { pos_ms = (int)System.currentTimeMillis() - pos_start; validatePos(); return pos_ms; } + @Override + protected final int getAudioPTSImpl() { return getCurrentPositionImpl(); } + @Override - protected void destroyImpl(GL gl) { + protected final void destroyImpl(GL gl) { + if(null != texData) { + texData.destroy(); + texData = null; + } } - + @Override - protected void initGLStreamImpl(GL gl, int[] texNames) throws IOException { + protected final void initGLStreamImpl(GL gl) throws IOException { try { URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader()); if(null != urlConn) { @@ -117,44 +119,44 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { } catch (Exception e) { e.printStackTrace(); } + final int _w, _h; if(null != texData) { - width = texData.getWidth(); - height = texData.getHeight(); + _w = texData.getWidth(); + _h = texData.getHeight(); } else { - width = 640; - height = 480; - ByteBuffer buffer = Buffers.newDirectByteBuffer(width*height*4); + _w = 640; + _h = 480; + ByteBuffer buffer = Buffers.newDirectByteBuffer(_w*_h*4); while(buffer.hasRemaining()) { buffer.put((byte) 0xEA); buffer.put((byte) 0xEA); buffer.put((byte) 0xEA); buffer.put((byte) 0xEA); } buffer.rewind(); texData = new TextureData(GLProfile.getGL2ES2(), - GL.GL_RGBA, width, height, 0, + GL.GL_RGBA, _w, _h, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, false, false, false, buffer, null); } - fps = 24f; - duration = 10*60*1000; // msec - totalFrames = (int) ( (duration/1000)*fps ); - vcodec = "png-static"; + final float _fps = 24f; + final int _duration = 10*60*1000; // msec + final int _totalFrames = (int) ( (_duration/1000)*_fps ); + updateAttributes(_w, _h, + 0, 0, 0, + _fps, _totalFrames, _duration, + "png-static", null); } @Override - protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) { - Texture texture = super.createTexImageImpl(gl, idx, tex, width, height, false); + protected final TextureSequence.TextureFrame createTexImage(GL gl, int texName) { + final Texture texture = super.createTexImageImpl(gl, texName, width, height, false); if(null != texData) { texture.updateImage(gl, texData); - texData.destroy(); - texData = null; } - frame = new TextureSequence.TextureFrame( texture ); - return frame; + return new TextureSequence.TextureFrame( texture ); } @Override - protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) { - frame = null; - super.destroyTexImage(gl, imgTex); + protected final void destroyTexFrame(GL gl, TextureSequence.TextureFrame frame) { + super.destroyTexFrame(gl, frame); } private void validatePos() { diff --git a/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java b/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java index 5f5d69cf8..ea67387a0 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java @@ -74,6 +74,8 @@ public class SyncedRingbuffer { } } + public final T[] getArray() { return array; } + public final int capacity() { return capacity; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index 852e5149c..3680da1a8 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -116,25 +116,32 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { private static long[] symbolAddr; private static final boolean ready; + private static final boolean libsLoaded; static { // native ffmpeg media player implementation is included in jogl_desktop and jogl_mobile GLProfile.initSingleton(); boolean _ready = false; + boolean[] _libsLoaded= { false }; try { - _ready = initSymbols(); + _ready = initSymbols(_libsLoaded); } catch (Throwable t) { t.printStackTrace(); } + libsLoaded = _libsLoaded[0]; ready = _ready; - if(!ready) { - System.err.println("FFMPEG: Not Available"); + if(!libsLoaded) { + System.err.println("LIB_AV Not Available"); + } else if(!ready) { + System.err.println("LIB_AV Not Matching"); } } + static boolean libsLoaded() { return libsLoaded; } static boolean initSingleton() { return ready; } - private static final boolean initSymbols() { + private static final boolean initSymbols(boolean[] libsLoaded) { + libsLoaded[0] = false; final DynamicLibraryBundle dl = AccessController.doPrivileged(new PrivilegedAction() { public DynamicLibraryBundle run() { return new DynamicLibraryBundle(new FFMPEGDynamicLibraryBundleInfo()); @@ -148,6 +155,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { if(!dl.isToolLibComplete()) { throw new RuntimeException("FFMPEG Tool libraries incomplete"); } + libsLoaded[0] = true; if(symbolNames.length != symbolCount) { throw new InternalError("XXX0 "+symbolNames.length+" != "+symbolCount); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index b6708b379..83a5960f1 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -44,11 +44,10 @@ import com.jogamp.opengl.util.GLPixelStorageModes; import com.jogamp.opengl.util.av.AudioSink; import com.jogamp.opengl.util.av.AudioSinkFactory; import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureSequence; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; import jogamp.opengl.GLContextImpl; -import jogamp.opengl.util.av.EGLMediaPlayerImpl; -import jogamp.opengl.util.av.SyncedRingbuffer; +import jogamp.opengl.util.av.GLMediaPlayerImpl; /*** * Implementation utilizes Libav @@ -102,7 +101,7 @@ import jogamp.opengl.util.av.SyncedRingbuffer; * * */ -public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { +public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { // Count of zeroed buffers to return before switching to real sample provider private static final int TEMP_BUFFER_COUNT = 20; @@ -114,21 +113,20 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { static final boolean available; static { - if(FFMPEGDynamicLibraryBundleInfo.initSingleton()) { + final boolean libAVGood = FFMPEGDynamicLibraryBundleInfo.initSingleton(); + if( FFMPEGDynamicLibraryBundleInfo.libsLoaded() ) { avUtilVersion = getAVVersion(getAvUtilVersion0()); avFormatVersion = getAVVersion(getAvFormatVersion0()); avCodecVersion = getAVVersion(getAvCodecVersion0()); System.err.println("LIB_AV Util : "+avUtilVersion); System.err.println("LIB_AV Format: "+avFormatVersion); System.err.println("LIB_AV Codec : "+avCodecVersion); - initIDs0(); - available = true; } else { avUtilVersion = null; avFormatVersion = null; avCodecVersion = null; - available = false; } + available = libAVGood ? initIDs0() : false; } public static final boolean isAvailable() { return available; } @@ -144,8 +142,6 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { // protected long moviePtr = 0; - protected long procAddrGLTexSubImage2D = 0; - protected EGLMediaPlayerImpl.EGLTextureFrame lastTex = null; protected GLPixelStorageModes psm; protected PixelFormat vPixelFmt = null; protected int vPlanes = 0; @@ -161,21 +157,15 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { // Audio // - protected static final boolean USE_AUDIO_PUSHER = false; protected final int AudioFrameCount = 8; protected final AudioSink audioSink; protected final int maxAvailableAudio; protected AudioSink.AudioDataFormat chosenAudioFormat; - protected final SyncedRingbuffer audioFramesBuffer = - USE_AUDIO_PUSHER ? new SyncedRingbuffer(new AudioSink.AudioFrame[AudioFrameCount], false /* full */) - : null; public FFMPEGMediaPlayer() { - super(TextureType.GL, false); if(!available) { throw new RuntimeException("FFMPEGMediaPlayer not available"); } - setTextureCount(1); moviePtr = createInstance0(DEBUG); if(0==moviePtr) { throw new GLException("Couldn't create FFMPEGInstance"); @@ -184,26 +174,15 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { audioSink = AudioSinkFactory.createDefault(); maxAvailableAudio = audioSink.getQueuedByteCount(); } - @Override - protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) { - if(TextureType.GL == texType) { - final Texture texture = super.createTexImageImpl(gl, idx, tex, texWidth, texHeight, true); - lastTex = new EGLTextureFrame(null, texture, 0, 0); - } else { - throw new InternalError("n/a"); - } - return lastTex; + protected final int validateTextureCount(int desiredTextureCount) { + return desiredTextureCount>1 ? desiredTextureCount : 2; } - @Override - protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) { - lastTex = null; - super.destroyTexImage(gl, imgTex); - } - + protected final boolean requiresOffthreadGLCtx() { return true; } + @Override - protected void destroyImpl(GL gl) { + protected final void destroyImpl(GL gl) { if (moviePtr != 0) { destroyInstance0(moviePtr); moviePtr = 0; @@ -211,15 +190,29 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected void initGLStreamImpl(GL gl, int[] texNames) throws IOException { + protected final void initGLStreamImpl(GL gl) throws IOException { if(0==moviePtr) { throw new GLException("FFMPEG native instance null"); } + { + final GLContextImpl ctx = (GLContextImpl)gl.getContext(); + final ProcAddressTable pt = ctx.getGLProcAddressTable(); + final long procAddrGLTexSubImage2D = getAddressFor(pt, "glTexSubImage2D"); + if( 0 == procAddrGLTexSubImage2D ) { + throw new InternalError("glTexSubImage2D n/a in ProcAddressTable: "+pt.getClass().getName()+" of "+ctx.getGLVersion()); + } + final long procAddrGLGetError = getAddressFor(pt, "glGetError"); + if( 0 == procAddrGLGetError ) { + throw new InternalError("glGetError n/a in ProcAddressTable: "+pt.getClass().getName()+" of "+ctx.getGLVersion()); + } + setGLFuncs0(moviePtr, procAddrGLTexSubImage2D, procAddrGLGetError); + } + final String urlS=urlConn.getURL().toExternalForm(); chosenAudioFormat = audioSink.initSink(audioSink.getPreferredFormat(), AudioFrameCount); System.err.println("setURL: p1 "+this); - setStream0(moviePtr, urlS, -1, -1, AudioFrameCount); + setStream0(moviePtr, urlS, -1, -1, AudioFrameCount); // issues updateAttributes*(..) System.err.println("setURL: p2 "+this); int tf, tif=GL.GL_RGBA; // texture format and internal format @@ -239,12 +232,10 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { } setTextureFormat(tif, tf); setTextureType(GL.GL_UNSIGNED_BYTE); - final GLContextImpl ctx = (GLContextImpl)gl.getContext(); - final ProcAddressTable pt = ctx.getGLProcAddressTable(); - procAddrGLTexSubImage2D = getAddressFor(pt, "glTexSubImage2D"); - if( 0 == procAddrGLTexSubImage2D ) { - throw new InternalError("glTexSubImage2D n/a in ProcAddressTable: "+pt.getClass().getName()+" of "+ctx.getGLVersion()); - } + } + @Override + protected final TextureFrame createTexImage(GL gl, int texName) { + return new TextureFrame( createTexImageImpl(gl, texName, texWidth, texHeight, true) ); } /** @@ -263,107 +254,6 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { } ).longValue(); } - private final void pushSound(ByteBuffer sampleData, int data_size, int audio_pts) { - if( USE_AUDIO_PUSHER ) { - if( audioPusher != null && audioPusher.isRunning() ) { - try { - audioFramesBuffer.putBlocking(new AudioSink.AudioFrame(sampleData, data_size, audio_pts)); - } catch (InterruptedException e) { - e.printStackTrace(); // oops - } - } - } else { - pushAudioFrame(new AudioSink.AudioFrame(sampleData, data_size, audio_pts)); - } - } - - private final void pushAudioFrame(AudioSink.AudioFrame audioFrame) { - // poor mans audio sync .. - final long now = System.currentTimeMillis(); - final long now_d = now - lastAudioTime; - final long pts_d = audioFrame.audioPTS - lastAudioPTS; - final long dt = (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ; - final boolean sleep = dt > audio_dt_d; - final long sleepP = dt - ( audio_dt_d / 2 ); - if(DEBUG) { - final int qAT = audioSink.getQueuedTime(); - System.err.println("s: pts-a "+audioFrame.audioPTS+", qAT "+qAT+", pts-d "+pts_d+", now_d "+now_d+", dt "+dt+", sleep "+sleep+", sleepP "+sleepP+" ms"); - } - if( sleep ) { - try { - Thread.sleep( sleepP ); - } catch (InterruptedException e) { - e.printStackTrace(); // oops - } - lastAudioTime = System.currentTimeMillis(); - } else { - lastAudioTime = now; - } - if( audioSink.isDataAvailable(audioFrame.dataSize) ) { - audioSink.writeData(audioFrame); - lastAudioPTS=audioFrame.audioPTS; - } - } - - class AudioPusher extends Thread { - volatile boolean shallStop = false; - volatile boolean isBlocked = false; - - AudioPusher() { - setDaemon(true); - } - public void requestStop() { - shallStop = true; - if( isBlocked ) { - interrupt(); - } - } - public boolean isRunning() { return !shallStop; } - - public void run() { - setName(getName()+"-AudioPusher_"+AudioPusherInstanceId); - AudioPusherInstanceId++; - - while( !shallStop ){ - final AudioSink.AudioFrame audioFrame; - try { - isBlocked = true; - audioFrame = audioFramesBuffer.getBlocking(true /* clearRef */); - } catch (InterruptedException e) { - if( !shallStop ) { - e.printStackTrace(); // oops - } - shallStop = true; - return; - } - isBlocked = false; - - if( null != audioFrame ) { - FFMPEGMediaPlayer.this.pushAudioFrame(audioFrame); - } - } - } - } - static int AudioPusherInstanceId = 0; - private AudioPusher audioPusher = null; - - private final void stopAudioPusher() { - if( USE_AUDIO_PUSHER ) { - if( null != audioPusher ) { - audioPusher.requestStop(); - audioPusher = null; - } - audioFramesBuffer.clear(true); - } - } - private final void startAudioPusher() { - if( USE_AUDIO_PUSHER ) { - stopAudioPusher(); - audioPusher = new AudioPusher(); - audioPusher.start(); - } - } - private void updateAttributes2(int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, int lSz0, int lSz1, int lSz2, int tWd0, int tWd1, int tWd2) { @@ -413,7 +303,7 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { * Otherwise the call is delegated to it's super class. */ @Override - public String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException { + public final String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException { if(State.Uninitialized == state) { throw new IllegalStateException("Instance not initialized: "+this); } @@ -434,7 +324,7 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { * e.g. YUV420P to RGB. Otherwise the call is delegated to it's super class. */ @Override - public String getTextureLookupFragmentShaderImpl() throws IllegalStateException { + public final String getTextureLookupFragmentShaderImpl() throws IllegalStateException { if(State.Uninitialized == state) { throw new IllegalStateException("Instance not initialized: "+this); } @@ -465,134 +355,131 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected synchronized int getCurrentPositionImpl() { + protected final synchronized int getCurrentPositionImpl() { return 0!=moviePtr ? getVideoPTS0(moviePtr) : 0; } @Override - protected synchronized boolean setPlaySpeedImpl(float rate) { + public final int getAudioPTSImpl() { return 0; } + + @Override + protected final synchronized boolean setPlaySpeedImpl(float rate) { return true; } @Override - public synchronized boolean startImpl() { + public final synchronized boolean startImpl() { if(0==moviePtr) { return false; } - startAudioPusher(); return true; } /** @return time position after issuing the command */ @Override - public synchronized boolean pauseImpl() { + public final synchronized boolean pauseImpl() { if(0==moviePtr) { return false; } - stopAudioPusher(); return true; } /** @return time position after issuing the command */ @Override - public synchronized boolean stopImpl() { + public final synchronized boolean stopImpl() { if(0==moviePtr) { return false; } - stopAudioPusher(); return true; } /** @return time position after issuing the command */ @Override - protected synchronized int seekImpl(int msec) { + protected final synchronized int seekImpl(int msec) { if(0==moviePtr) { throw new GLException("FFMPEG native instance null"); } - stopAudioPusher(); int pts0 = getVideoPTS0(moviePtr); int pts1 = seek0(moviePtr, msec); System.err.println("Seek: "+pts0+" -> "+msec+" : "+pts1); - lastAudioPTS=pts1; - lastVideoPTS=pts1; - startAudioPusher(); return pts1; } @Override - protected TextureSequence.TextureFrame getLastTextureImpl() { - return lastTex; + protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking) { + if(0==moviePtr) { + throw new GLException("FFMPEG native instance null"); + } + psm.setUnpackAlignment(gl, 1); // RGBA ? 4 : 1 + int avPTS = 0; + try { + final Texture tex = nextFrame.getTexture(); + gl.glActiveTexture(GL.GL_TEXTURE0+getTextureUnit()); + tex.enable(gl); + tex.bind(gl); + + /** Try decode up to 10 packets to find one containing video, i.e. vPTS > 0 */ + for(int retry=10; 0 >= avPTS && 0 < retry; retry--) { + avPTS = readNextPacket0(moviePtr, textureTarget, textureFormat, textureType); + retry--; + } + } finally { + psm.restore(gl); + } + if( 0 < avPTS ) { + vSTS = avPTS; + nextFrame.setPTS(avPTS); + return true; + } else { + return false; + } } + private final void pushSound(ByteBuffer sampleData, int data_size, int audio_pts) { + aSTS = audio_pts; + final AudioSink.AudioFrame frame = new AudioSink.AudioFrame(sampleData, data_size, audio_pts); + if( audioSink.isDataAvailable(frame.dataSize) ) { + audioSink.writeData(frame); + } + } + + /** last audio streaming TS */ + private int aSTS = 0; + /** last video streaming TS */ + private int vSTS = 0; + private long lastAudioTime = 0; - private int lastAudioPTS = 0; private static final int audio_dt_d = 400; private long lastVideoTime = 0; - private int lastVideoPTS = 0; private static final int video_dt_d = 9; @Override - protected TextureSequence.TextureFrame getNextTextureImpl(GL gl, boolean blocking) { - if(0==moviePtr) { - throw new GLException("FFMPEG native instance null"); - } - if(null != lastTex) { - psm.setUnpackAlignment(gl, 1); // RGBA ? 4 : 1 - try { - final Texture tex = lastTex.getTexture(); - gl.glActiveTexture(GL.GL_TEXTURE0+getTextureUnit()); - tex.enable(gl); - tex.bind(gl); - - if( USE_AUDIO_PUSHER ) { - try { - audioFramesBuffer.waitForFreeSlots(2); - } catch (InterruptedException e) { - e.printStackTrace(); // oops - } - } - - /* try decode 10 packets to find one containing video - (res == 2) */ - int res = 0; - int retry = 10; - while(res!=2 && retry >= 0) { - res = readNextPacket0(moviePtr, procAddrGLTexSubImage2D, textureTarget, textureFormat, textureType); - retry--; - } - } finally { - psm.restore(gl); - } - final int pts = getVideoPTS0(moviePtr); // this frame - if(blocking) { - // poor mans video sync .. TODO: off thread 'readNextPackage0(..)' on shared GLContext and multi textures/unit! - final long now = System.currentTimeMillis(); - // Try sync video to audio - final long now_d = now - lastAudioTime; - final long pts_d = pts - lastAudioPTS - 444; /* hack 444 == play video 444ms ahead of audio */ - final long dt = Math.min(47, (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ) ; - //final long dt = (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ; - final boolean sleep = dt>video_dt_d && dt<1000 && audioSink.getQueuedByteCount()video_dt_d && dt<1000 && audioSink.getQueuedByteCount() 0, invalid == 0 + */ + private native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); private native int seek0(long moviePtr, int position); @@ -720,6 +615,5 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl { return null; } } - } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java index aef98fcde..a21bb40a8 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java @@ -33,7 +33,6 @@ import java.net.URL; import javax.media.opengl.GL; import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.texture.TextureSequence; @@ -49,17 +48,17 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { static final boolean available; static { + available = false; + /** FIXME! // OMX binding is included in jogl_desktop and jogl_mobile GLProfile.initSingleton(); - available = initIDs0(); + available = initIDs0(); */ } public static final boolean isAvailable() { return available; } protected long moviePtr = 0; - protected TextureSequence.TextureFrame lastTex = null; - public OMXGLMediaPlayer() { super(TextureType.KHRImage, true); if(!available) { @@ -76,17 +75,15 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected TextureSequence.TextureFrame createTexImage(GL gl, int idx, int[] tex) { - final EGLTextureFrame eglTex = (EGLTextureFrame) super.createTexImage(gl, idx, tex); - _setStreamEGLImageTexture2D(moviePtr, idx, tex[idx], eglTex.getImage(), eglTex.getSync()); - lastTex = eglTex; + protected TextureSequence.TextureFrame createTexImage(GL gl, int texName) { + final EGLTextureFrame eglTex = (EGLTextureFrame) super.createTexImage(gl, texName); + _setStreamEGLImageTexture2D(moviePtr, texName, eglTex.getImage(), eglTex.getSync()); return eglTex; } @Override - protected void destroyTexImage(GL gl, TextureSequence.TextureFrame imgTex) { - lastTex = null; - super.destroyTexImage(gl, imgTex); + protected void destroyTexFrame(GL gl, TextureSequence.TextureFrame imgTex) { + super.destroyTexFrame(gl, imgTex); } @Override @@ -99,7 +96,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected void initGLStreamImpl(GL gl, int[] texNames) throws IOException { + protected void initGLStreamImpl(GL gl) throws IOException { if(0==moviePtr) { throw new GLException("OMX native instance null"); } @@ -119,6 +116,10 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { protected int getCurrentPositionImpl() { return 0!=moviePtr ? _getCurrentPosition(moviePtr) : 0; } + @Override + protected int getAudioPTSImpl() { + return getCurrentPositionImpl(); + } @Override protected boolean setPlaySpeedImpl(float rate) { @@ -168,24 +169,23 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected TextureSequence.TextureFrame getLastTextureImpl() { - return lastTex; - } - - @Override - protected TextureSequence.TextureFrame getNextTextureImpl(GL gl, boolean blocking) { + protected boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking) { if(0==moviePtr) { throw new GLException("OMX native instance null"); } final int nextTex = _getNextTextureID(moviePtr, blocking); if(0 < nextTex) { - final TextureSequence.TextureFrame eglImgTex = texFrameMap.get(new Integer(_getNextTextureID(moviePtr, blocking))); + /* FIXME + final TextureSequence.TextureFrame eglImgTex = + texFrameMap.get(new Integer(_getNextTextureID(moviePtr, blocking))); if(null!=eglImgTex) { lastTex = eglImgTex; - } + } */ } - return lastTex; + return true; } + @Override + protected void syncFrame2Audio(TextureFrame frame) { } private String replaceAll(String orig, String search, String repl) { String dest=null; @@ -216,7 +216,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { private native void _setStream(long moviePtr, int textureNum, String path); private native void _activateStream(long moviePtr); - private native void _setStreamEGLImageTexture2D(long moviePtr, int i, int tex, long image, long sync); + private native void _setStreamEGLImageTexture2D(long moviePtr, int tex, long image, long sync); private native int _seek(long moviePtr, int position); private native void _setPlaySpeed(long moviePtr, float rate); private native void _play(long moviePtr); diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index 5560b8617..2dff1110c 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -48,6 +48,11 @@ #include #include +#include + +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); + /** * AV_TIME_BASE 1000000 */ @@ -63,6 +68,9 @@ static inline int32_t my_av_q2i32(int32_t snum, AVRational a){ typedef struct { int32_t verbose; + PFNGLTEXSUBIMAGE2DPROC procAddrGLTexSubImage2D; + PFNGLGETERRORPROC procAddrGLGetError; + AVFormatContext* pFormatCtx; int32_t vid; AVStream* pVStream; diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c index 623bdcac7..346ba6c07 100644 --- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c +++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c @@ -33,8 +33,6 @@ #include #include -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); - static const char * const ClazzNameFFMPEGMediaPlayer = "jogamp/opengl/util/av/impl/FFMPEGMediaPlayer"; static jclass ffmpegMediaPlayerClazz = NULL; @@ -583,22 +581,29 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre _updateJavaAttributes(env, instance, pAV); } +JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setGLFuncs0 + (JNIEnv *env, jobject instance, jlong ptr, jlong jProcAddrGLTexSubImage2D, jlong jProcAddrGLGetError) +{ + FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); + pAV->procAddrGLTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) (intptr_t)jProcAddrGLTexSubImage2D; + pAV->procAddrGLGetError = (PFNGLGETERRORPROC) (intptr_t)jProcAddrGLGetError; +} + JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNextPacket0 - (JNIEnv *env, jobject instance, jlong ptr, jlong jProcAddrGLTexSubImage2D, jint texTarget, jint texFmt, jint texType) + (JNIEnv *env, jobject instance, jlong ptr, jint texTarget, jint texFmt, jint texType) { FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); - PFNGLTEXSUBIMAGE2DPROC procAddrGLTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) (intptr_t)jProcAddrGLTexSubImage2D; - jint res = 0; // 1 - audio, 2 - video AVPacket packet; int frameFinished; + jint resPTS = 0; // resulting current PTS: audio < 0, video > 0, invalid == 0 if(sp_av_read_frame(pAV->pFormatCtx, &packet)>=0) { if(packet.stream_index==pAV->aid) { // Decode audio frame if(NULL == pAV->pAFrames) { // no audio registered sp_av_free_packet(&packet); - return res; + return 0; } AVFrame* pAFrameCurrent = pAV->pAFrames[pAV->aFrameCurrent]; pAV->aFrameCurrent = ( pAV->aFrameCurrent + 1 ) % pAV->aFrameCount ; @@ -658,14 +663,13 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex jobject jSampleData = (*env)->NewDirectByteBuffer(env, pAFrameCurrent->data[0], data_size); (*env)->CallVoidMethod(env, instance, jni_mid_pushSound, jSampleData, data_size, pAV->aPTS); } - - res = 1; + resPTS = pAV->aPTS * -1; // Audio Frame! } } else if(packet.stream_index==pAV->vid) { // Decode video frame if(NULL == pAV->pVFrame) { sp_av_free_packet(&packet); - return res; + return 0; } int new_packet = 1; @@ -696,7 +700,6 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex continue; } - res = 2; // FIXME: Libav Binary compatibility! JAU01 const AVRational time_base = pAV->pVStream->time_base; const int64_t pts = pAV->pVFrame->pkt_pts; @@ -708,6 +711,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex pAV->vPTS, pAV->pVFrame->pkt_pts, time_base.num, time_base.den, (time_base.num/(double)time_base.den)); #endif } + resPTS = pAV->vPTS; // Video Frame! #if 0 printf("tex2D codec %dx%d - frame %dx%d - width %d tex / %d linesize, pixfmt 0x%X, texType 0x%x, texTarget 0x%x\n", @@ -718,24 +722,51 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex // 1st plane or complete packed frame // FIXME: Libav Binary compatibility! JAU01 - procAddrGLTexSubImage2D(texTarget, 0, + #if 0 + GLenum glerr = pAV->procAddrGLGetError(); + printf("TexSubImage2D.1 texTarget 0x%x, offset %d / %d, size %d x %d, fmt 0x%X, type 0x%X, pre-err 0x%X, ", + texTarget, 0, 0, pAV->vTexWidth[0], pAV->pVCodecCtx->height, texFmt, texType, glerr); + #endif + pAV->procAddrGLTexSubImage2D(texTarget, 0, 0, 0, pAV->vTexWidth[0], pAV->pVCodecCtx->height, texFmt, texType, pAV->pVFrame->data[0]); + #if 0 + glerr = pAV->procAddrGLGetError(); + printf("err 0x%X\n", glerr); + #endif if(pAV->vPixFmt == PIX_FMT_YUV420P) { // U plane // FIXME: Libav Binary compatibility! JAU01 - procAddrGLTexSubImage2D(texTarget, 0, + #if 0 + printf("TexSubImage2D.U texTarget 0x%x, offset %d / %d, size %d x %d, fmt 0x%X, type 0x%X, ", + texTarget, pAV->pVCodecCtx->width, 0, pAV->vTexWidth[1], pAV->pVCodecCtx->height/2, + texFmt, texType); + #endif + pAV->procAddrGLTexSubImage2D(texTarget, 0, pAV->pVCodecCtx->width, 0, pAV->vTexWidth[1], pAV->pVCodecCtx->height/2, texFmt, texType, pAV->pVFrame->data[1]); + #if 0 + glerr = pAV->procAddrGLGetError(); + printf("err 0x%X\n", glerr); + #endif // V plane // FIXME: Libav Binary compatibility! JAU01 - procAddrGLTexSubImage2D(texTarget, 0, + #if 0 + printf("TexSubImage2D.V texTarget 0x%x, offset %d / %d, size %d x %d, fmt 0x%X, type 0x%X, ", + texTarget, pAV->pVCodecCtx->width, pAV->pVCodecCtx->height/2, pAV->vTexWidth[2], pAV->pVCodecCtx->height/2, + texFmt, texType); + #endif + pAV->procAddrGLTexSubImage2D(texTarget, 0, pAV->pVCodecCtx->width, pAV->pVCodecCtx->height/2, pAV->vTexWidth[2], pAV->pVCodecCtx->height/2, texFmt, texType, pAV->pVFrame->data[2]); + #if 0 + glerr = pAV->procAddrGLGetError(); + printf("err 0x%X\n", glerr); + #endif } // FIXME: Add more planar formats ! } } @@ -745,7 +776,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex // TODO: check what release the packets memory. // sp_av_free_packet(&packet); } - return res; + return resPTS; } JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_seek0 diff --git a/src/jogl/native/openmax/omx_tool.c b/src/jogl/native/openmax/omx_tool.c index 16c43f6a8..26a3b93f1 100644 --- a/src/jogl/native/openmax/omx_tool.c +++ b/src/jogl/native/openmax/omx_tool.c @@ -1049,17 +1049,13 @@ void OMXToolBasicAV_SetStream(OMXToolBasicAV_t * pOMXAV, int vBufferNum, const K DBG_PRINT( "SetStream X\n"); } -void OMXToolBasicAV_SetStreamEGLImageTexture2D(OMXToolBasicAV_t * pOMXAV, KDint i, GLuint tex, EGLImageKHR image, EGLSyncKHR sync) +void OMXToolBasicAV_SetStreamEGLImageTexture2D(OMXToolBasicAV_t * pOMXAV, GLuint tex, EGLImageKHR image, EGLSyncKHR sync) { if(NULL==pOMXAV) { JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } - DBG_PRINT( "SetStreamEGLImg %p #%d/%d t:%d i:%p s:%p..\n", pOMXAV, i, pOMXAV->vBufferNum, tex, image, sync); - if(i<0||i>=pOMXAV->vBufferNum) { - JoglCommon_throwNewRuntimeException(0, "Buffer index out of range: %d\n", i); - return; - } + DBG_PRINT( "SetStreamEGLImg %p count %d t:%d i:%p s:%p..\n", pOMXAV, pOMXAV->vBufferNum, tex, image, sync); kdThreadMutexLock(pOMXAV->mutex); { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index 20c28c3ea..adccecba0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -136,7 +136,7 @@ public class TextureSequenceCubeES2 implements GLEventListener { } } public void mouseWheelMoved(MouseEvent e) { - System.err.println("XXX "+e); + // System.err.println("XXX "+e); if( !e.isShiftDown() ) { final float o = zoom; final float d = e.getRotation()[1]/10f; // vertical: wheel diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 921710fed..3f979e16f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -61,9 +61,11 @@ import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; import com.jogamp.opengl.util.av.GLMediaPlayerFactory; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; public class MovieCube implements GLEventListener, GLMediaEventListener { static boolean waitForKey = false; + int textureCount = 3; // default - threaded final URLConnection stream; final float zoom0, rotx, roty; TextureSequenceCubeES2 cube=null; @@ -81,6 +83,10 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { this.roty = roty; } + public void setTextureCount(int v) { + textureCount = v; + } + private final KeyListener keyAction = new KeyAdapter() { public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { @@ -130,7 +136,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } @Override - public void newFrameAvailable(GLMediaPlayer mp, long when) { + public void newFrameAvailable(GLMediaPlayer mp, TextureFrame newFrame, long when) { // System.out.println("newFrameAvailable: "+mp+", when "+when); } @@ -151,7 +157,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } try { System.out.println("p0 "+mPlayer); - mPlayer.initGLStream(gl, stream); + mPlayer.initGLStream(gl, textureCount, stream); System.out.println("p1 "+mPlayer); } catch (Exception e) { e.printStackTrace(); @@ -202,7 +208,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { public static void main(String[] args) throws MalformedURLException, IOException, InterruptedException { int width = 510; int height = 300; - System.err.println("TexCubeES2.run()"); + int textureCount = 3; // default - threaded boolean forceES2 = false; boolean forceES3 = false; @@ -217,6 +223,9 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } else if(args[i].equals("-height")) { i++; height = MiscUtils.atoi(args[i], height); + } else if(args[i].equals("-textureCount")) { + i++; + textureCount = MiscUtils.atoi(args[i], textureCount); } else if(args[i].equals("-url")) { i++; url_s = args[i]; @@ -232,6 +241,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { waitForKey = true; } } + System.err.println("textureCount "+textureCount); System.err.println("forceES2 "+forceES2); System.err.println("forceES3 "+forceES3); System.err.println("forceGL3 "+forceGL3); @@ -264,7 +274,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { anim.stop(); } }); - // anim.setUpdateFPSFrames(60, System.err); + anim.setUpdateFPSFrames(60, System.err); anim.start(); window.setVisible(true); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index 7e0dcd909..90c73661a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -66,9 +66,11 @@ import com.jogamp.opengl.util.glsl.ShaderState; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureCoords; import com.jogamp.opengl.util.texture.TextureSequence; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; public class MovieSimple implements GLEventListener, GLMediaEventListener { private int winWidth, winHeight; + int textureCount = 3; // default - threaded private int prevMouseX; // , prevMouseY; private int rotate = 0; private boolean orthoProjection = true; @@ -169,6 +171,9 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { public GLMediaPlayer getGLMediaPlayer() { return mPlayer; } + public void setTextureCount(int v) { + textureCount = v; + } public void setScaleOrig(boolean v) { mPlayerScaleOrig = v; } @@ -179,7 +184,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { } @Override - public void newFrameAvailable(GLMediaPlayer mp, long when) { + public void newFrameAvailable(GLMediaPlayer mp, TextureFrame newFrame, long when) { // System.out.println("newFrameAvailable: "+mp+", when "+when); } @@ -252,7 +257,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { try { System.out.println("p0 "+mPlayer+", shared "+mPlayerShared); if(!mPlayerShared) { - mPlayer.initGLStream(gl, stream); + mPlayer.initGLStream(gl, textureCount, stream); } tex = mPlayer.getLastTexture().getTexture(); System.out.println("p1 "+mPlayer+", shared "+mPlayerShared); @@ -263,7 +268,8 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { if(!mPlayerShared) { mPlayer.setTextureMinMagFilter( new int[] { GL.GL_NEAREST, GL.GL_LINEAR } ); } - } catch (Exception glex) { + } catch (Exception glex) { + glex.printStackTrace(); if(!mPlayerShared && null != mPlayer) { mPlayer.destroy(gl); mPlayer = null; @@ -506,6 +512,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { public static void main(String[] args) throws IOException, MalformedURLException { int width = 640; int height = 600; + int textureCount = 3; // default - threaded boolean ortho = true; boolean zoom = false; @@ -522,6 +529,9 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { } else if(args[i].equals("-height")) { i++; height = MiscUtils.atoi(args[i], height); + } else if(args[i].equals("-textureCount")) { + i++; + textureCount = MiscUtils.atoi(args[i], textureCount); } else if(args[i].equals("-es2")) { forceES2 = true; } else if(args[i].equals("-es3")) { @@ -539,12 +549,14 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { url_s = args[i]; } } + System.err.println("textureCount "+textureCount); System.err.println("forceES2 "+forceES2); System.err.println("forceES3 "+forceES3); System.err.println("forceGL3 "+forceGL3); System.err.println("forceGLDef "+forceGLDef); final MovieSimple ms = new MovieSimple(new URL(url_s).openConnection()); + ms.setTextureCount(textureCount); ms.setScaleOrig(!zoom); ms.setOrthoProjection(ortho); @@ -570,6 +582,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { window.setSize(width, height); window.setVisible(true); final Animator anim = new Animator(window); + anim.setUpdateFPSFrames(60, System.err); anim.start(); window.addWindowListener(new WindowAdapter() { public void windowDestroyed(WindowEvent e) { -- cgit v1.2.3 From c37629ea8fdcb11f7f8a18e37a4cde57d4ba6a01 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 14 Aug 2013 07:02:59 +0200 Subject: GLMediaPlayer Multithreaded Decoding: GLMediaPlayer* (Part-3) - WIP - GLMediaPlayer - Remove State.Stopped and method stop() - redundant, use pause() / destroy() - Add notion of stream IDs - Add API doc: State / Stream-ID incl. html-anchor - Expose video/audio PTS, .. - Expose optional AudioSink - Min multithreaded textureCount is 4 (EGL* and FFMPEG*) - GLMediaPlayerImpl - Move AudioSink rel. impl. to this class, allowing a tight video implementation reusing logic. - Remove 'synchronized' methods, synchronize on State where applicable - implement new methods (see above) - playSpeed is handled partially in AudioSink. If it exeeds AudioSink's capabilities, drop audio and rely solely on video sync. - video sync (WIP) - video pts delay based on geometric weight - reset video SCR if 'out of range', resync w/ PTS - - FramePusher - allow interruption when pausing/stopping, while waiting for next avail free frame to decode. - FFMPEGMediaPlayer - Add proper AudioDataFormat negotiation AudioSink <-> libav - Parse libav's SampleFormat - Remove AudioSink interaction (moved to GLMediaPlayerImpl) - Tests (MovieSimple, MovieCube): - Add aid/vid selection - Add KeyListener for actions: seek(..), play()/pause(), setPlaySpeed(..) - Dump perf-string each 2s - TODO: - Add audio sync in AudioSink, similar to GLMediaPlayer's weighted video delay, here: drop audio frames. --- make/scripts/tests.sh | 6 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 146 ++-- .../opengl/util/av/GLMediaPlayerFactory.java | 5 +- .../opengl/util/texture/TextureSequence.java | 5 +- .../android/av/AndroidGLMediaPlayerAPI14.java | 53 +- .../jogamp/opengl/util/av/EGLMediaPlayerImpl.java | 2 +- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 740 +++++++++++++++------ .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 27 +- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 232 ++++--- .../opengl/util/av/impl/OMXGLMediaPlayer.java | 25 +- src/jogl/native/libav/ffmpeg_tool.h | 19 +- .../jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c | 223 ++++--- .../opengl/test/android/MovieCubeActivity0.java | 3 +- .../opengl/test/android/MovieSimpleActivity0.java | 3 +- .../opengl/test/android/MovieSimpleActivity1.java | 4 +- .../jogl/demos/es2/TextureSequenceCubeES2.java | 23 +- .../test/junit/jogl/demos/es2/av/MovieCube.java | 157 +++-- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 228 +++++-- 18 files changed, 1283 insertions(+), 618 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ba4589d14..82e9fb92b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -131,7 +131,9 @@ function jrun() { #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" + #D_ARGS="-Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" @@ -314,8 +316,8 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index a36bce305..fae88ea18 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -34,19 +34,37 @@ import javax.media.opengl.GL; import javax.media.opengl.GLException; import jogamp.opengl.Debug; +import jogamp.opengl.util.av.GLMediaPlayerImpl; import com.jogamp.opengl.util.texture.TextureSequence; /** - * Lifecycle of an GLMediaPlayer: + * GLMediaPlayer interface specifies a {@link TextureSequence} + * with a video stream as it's source. + *

    + * Audio maybe supported and played back internally or via an {@link AudioSink} implementation, + * if an audio stream is selected in {@link #initGLStream(GL, int, URLConnection, int, int)}. + *

    + *
    GLMediaPlayer Lifecycle
    + *

    + * + * + * + * + * + * + * + *
    action state before state after
    {@link #initGLStream(GL, int, URLConnection, int, int)} Uninitialized Paused
    {@link #play()} Paused Playing
    {@link #pause()} Playing Paused
    {@link #seek(int)} Playing, Paused Unchanged
    {@link #destroy(GL)} ANY Uninitialized
    + *

    + *
    Audio and video Stream IDs
    + *

    * - * - * - * - * - * - * + * + * + * + * *
    action state before state after
    {@link #initGLStream(GL, int, URLConnection)} Uninitialized Stopped
    {@link #start()} Stopped, Paused Playing
    {@link #stop()} Playing, Paused Stopped
    {@link #pause()} Playing Paused
    {@link #destroy(GL)} ANY Uninitialized
    value request get
    {@link #STREAM_ID_NONE} mute not available
    {@link #STREAM_ID_AUTO} auto unspecified
    ≥0 specific stream specific stream
    + *

    *

    * Current implementations (check each API doc link for details): *

      @@ -76,14 +94,21 @@ import com.jogamp.opengl.util.texture.TextureSequence; */ public interface GLMediaPlayer extends TextureSequence { public static final boolean DEBUG = Debug.debug("GLMediaPlayer"); + + /** Constant {@value} for mute or not available. See Audio and video Stream IDs. */ + public static final int STREAM_ID_NONE = -2; + /** Constant {@value} for auto or unspecified. See Audio and video Stream IDs. */ + public static final int STREAM_ID_AUTO = -1; public interface GLMediaEventListener extends TexSeqEventListener { - static final int EVENT_CHANGE_SIZE = 1<<0; - static final int EVENT_CHANGE_FPS = 1<<1; - static final int EVENT_CHANGE_BPS = 1<<2; - static final int EVENT_CHANGE_LENGTH = 1<<3; - static final int EVENT_CHANGE_CODEC = 1<<3; + static final int EVENT_CHANGE_VID = 1<<0; + static final int EVENT_CHANGE_AID = 1<<1; + static final int EVENT_CHANGE_SIZE = 1<<2; + static final int EVENT_CHANGE_FPS = 1<<3; + static final int EVENT_CHANGE_BPS = 1<<4; + static final int EVENT_CHANGE_LENGTH = 1<<5; + static final int EVENT_CHANGE_CODEC = 1<<6; /** * @param mp the event source @@ -93,8 +118,11 @@ public interface GLMediaPlayer extends TextureSequence { public void attributesChanges(GLMediaPlayer mp, int event_mask, long when); } + /** + * See GLMediaPlayer Lifecycle. + */ public enum State { - Uninitialized(0), Stopped(1), Playing(2), Paused(3); + Uninitialized(0), Playing(1), Paused(2); public final int id; @@ -120,74 +148,106 @@ public interface GLMediaPlayer extends TextureSequence { * Sets the stream to be used. Initializes all stream related states inclusive OpenGL ones, * if gl is not null. *

      - * Uninitialized -> Stopped + * GLMediaPlayer Lifecycle: Uninitialized -> Paused *

      * @param gl current GL object. If null, no video output and textures will be available. * @param textureCount desired number of buffered textures to be decoded off-thread, use 1 for on-thread decoding. * @param urlConn the stream connection + * @param vid video stream id, see audio and video Stream IDs + * @param aid video stream id, see audio and video Stream IDs * @return the new state * * @throws IllegalStateException if not invoked in state Uninitialized * @throws IOException in case of difficulties to open or process the stream * @throws GLException in case of difficulties to initialize the GL resources */ - public State initGLStream(GL gl, int textureCount, URLConnection urlConn) throws IllegalStateException, GLException, IOException; + public State initGLStream(GL gl, int textureCount, URLConnection urlConn, int vid, int aid) throws IllegalStateException, GLException, IOException; + + /** + * If implementation uses a {@link AudioSink}, it's instance will be returned. + *

      + * The {@link AudioSink} instance is available after {@link #initGLStream(GL, int, URLConnection, int, int)}, + * if used by implementation. + *

      + */ + public AudioSink getAudioSink(); /** * Releases the GL and stream resources. *

      - * ANY -> Uninitialized + * GLMediaPlayer Lifecycle: ANY -> Uninitialized *

      */ public State destroy(GL gl); - public void setPlaySpeed(float rate); + /** + * Sets the playback speed. + *

      + * Play speed is set to normal, i.e. 1.0f + * if abs(1.0f - rate) < 0.01f to simplify test. + *

      + * @return true if successful, otherwise false, i.e. due to unsupported value range of implementation. + */ + public boolean setPlaySpeed(float rate); public float getPlaySpeed(); /** - * Stopped/Paused -> Playing + * GLMediaPlayer Lifecycle: Paused -> Playing */ - public State start(); + public State play(); /** - * Playing -> Paused + * GLMediaPlayer Lifecycle: Playing -> Paused */ public State pause(); /** - * Playing/Paused -> Stopped + * Allowed in state Playing and Paused, otherwise ignored, + * see GLMediaPlayer Lifecycle. + * + * @param msec absolute desired time position in milliseconds + * @return time current position in milliseconds, after seeking to the desired position + **/ + public int seek(int msec); + + /** + * See GLMediaPlayer Lifecycle. + * @return the current state, either Uninitialized, Playing, Paused */ - public State stop(); + public State getState(); /** - * @return the current state, either Uninitialized, Stopped, Playing, Paused + * Return the video stream id, see audio and video Stream IDs. */ - public State getState(); + public int getVID(); /** - * @return current streaming position in milliseconds - **/ - public int getCurrentPosition(); - + * Return the audio stream id, see audio and video Stream IDs. + */ + public int getAID(); + + /** + * @return the current decoded frame count since {@link #initGLStream(GL, int, URLConnection, int, int)}. + */ + public int getDecodedFrameCount(); + + /** + * @return the current presented frame count since {@link #initGLStream(GL, int, URLConnection, int, int)}, + * increased by {@link #getNextTexture(GL, boolean)}. + */ + public int getPresentedFrameCount(); + /** - * @return current video PTS in milliseconds of {@link #getLastTexture()} + * @return current video presentation timestamp (PTS) in milliseconds of {@link #getLastTexture()} **/ public int getVideoPTS(); /** - * @return current audio PTS in milliseconds. + * @return current audio presentation timestamp (PTS) in milliseconds. **/ public int getAudioPTS(); - /** - * Allowed in state Stopped, Playing and Paused, otherwise ignored. - * - * @param msec absolute desired time position in milliseconds - * @return time current position in milliseconds, after seeking to the desired position - **/ - public int seek(int msec); - /** * {@inheritDoc} */ @@ -225,7 +285,13 @@ public interface GLMediaPlayer extends TextureSequence { * Warning: Optional information, may not be supported by implementation. * @return the total number of video frames */ - public long getTotalFrames(); + public int getVideoFrames(); + + /** + * Warning: Optional information, may not be supported by implementation. + * @return the total number of audio frames + */ + public int getAudioFrames(); /** * @return total duration of stream in msec. @@ -262,6 +328,8 @@ public interface GLMediaPlayer extends TextureSequence { public String toString(); + public String getPerfString(); + public void addEventListener(GLMediaEventListener l); public void removeEventListener(GLMediaEventListener l); diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java index 2707dd6d2..c7e1ab5e6 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayerFactory.java @@ -47,10 +47,13 @@ public class GLMediaPlayerFactory { sink = create(cl, FFMPEGMediaPlayerClazzName); } if( null == sink ) { - sink = new NullGLMediaPlayer(); + sink = createNull(); } return sink; } + public static GLMediaPlayer createNull() { + return new NullGLMediaPlayer(); + } public static GLMediaPlayer create(final ClassLoader cl, String implName) { try { diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index 3f739b2cc..50801e791 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -110,9 +110,12 @@ public interface TextureSequence { * to associated related data. */ public static class TextureFrame { + /** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE {@value}. */ + public static final int INVALID_PTS = Integer.MIN_VALUE; + public TextureFrame(Texture t) { texture = t; - pts = 0; + pts = INVALID_PTS; } public final Texture getTexture() { return texture; } diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 765cda084..e14642c34 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -28,13 +28,13 @@ package jogamp.opengl.android.av; import java.io.IOException; -import java.nio.Buffer; import javax.media.opengl.GL; import javax.media.opengl.GLES2; import com.jogamp.common.os.AndroidVersion; import com.jogamp.common.os.Platform; +import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; @@ -100,7 +100,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected final boolean startImpl() { + protected final boolean playImpl() { if(null != mp) { try { mp.start(); @@ -130,22 +130,6 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { return false; } - @Override - protected final boolean stopImpl() { - if(null != mp) { - wakeUp(false); - try { - mp.stop(); - return true; - } catch (IllegalStateException ise) { - if(DEBUG) { - ise.printStackTrace(); - } - } - } - return false; - } - @Override protected final int seekImpl(int msec) { if(null != mp) { @@ -165,15 +149,19 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected final int getCurrentPositionImpl() { return null != mp ? mp.getCurrentPosition() : 0; } - - @Override - protected final int getAudioPTSImpl() { return getCurrentPositionImpl(); } + protected final int getAudioPTSImpl() { return null != mp ? mp.getCurrentPosition() : 0; } @Override protected final void destroyImpl(GL gl) { if(null != mp) { wakeUp(false); + try { + mp.stop(); + } catch (IllegalStateException ise) { + if(DEBUG) { + ise.printStackTrace(); + } + } mp.release(); mp = null; } @@ -198,8 +186,13 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected final void initGLStreamImpl(GL gl) throws IOException { + protected final void initGLStreamImpl(GL gl, int vid, int aid) throws IOException { if(null!=mp && null!=urlConn) { + if( GLMediaPlayer.STREAM_ID_NONE == aid ) { + mp.setVolume(0f, 0f); + // FIXME: Disable audio handling + } // else FIXME: Select aid ! + // Note: Both FIXMEs seem to be n/a via Android's MediaPlayer -> Switch to API level 16 MediaCodec/MediaExtractor .. try { final Uri uri = Uri.parse(urlConn.getURL().toExternalForm()); mp.setDataSource(StaticContext.getContext(), uri); @@ -213,20 +206,18 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { if( null == stex ) { throw new InternalError("XXX"); } - final Surface surf = new Surface(stex); - mp.setSurface(surf); - surf.release(); mp.setSurface(null); try { mp.prepare(); } catch (IOException ioe) { throw new IOException("MediaPlayer failed to process stream <"+urlConn.getURL().toExternalForm()+">: "+ioe.getMessage(), ioe); } + final int r_aid = GLMediaPlayer.STREAM_ID_NONE == aid ? GLMediaPlayer.STREAM_ID_NONE : GLMediaPlayer.STREAM_ID_AUTO; final String icodec = "android"; - updateAttributes(mp.getVideoWidth(), mp.getVideoHeight(), - 0, 0, 0, - 0f, 0, mp.getDuration(), - icodec, icodec); + updateAttributes(GLMediaPlayer.STREAM_ID_AUTO, r_aid, + mp.getVideoWidth(), mp.getVideoHeight(), 0, + 0, 0, 0f, + 0, 0, mp.getDuration(), icodec, icodec); } } @@ -264,8 +255,6 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } return true; } - @Override - protected final void syncFrame2Audio(TextureFrame frame) {} @Override protected final TextureSequence.TextureFrame createTexImage(GL gl, int texName) { diff --git a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java index 57d5ff625..db2146cdc 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java @@ -84,7 +84,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { } @Override protected final int validateTextureCount(int desiredTextureCount) { - return desiredTextureCount>1 ? desiredTextureCount : 2; + return desiredTextureCount>2 ? Math.max(4, desiredTextureCount) : 2; } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index bc297dc21..c1cfc0d95 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -42,6 +42,7 @@ import javax.media.opengl.GLES2; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import com.jogamp.opengl.util.av.AudioSink; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; @@ -62,7 +63,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected static final String unknown = "unknown"; - protected State state; + /** Default texture count w/o threading, value {@value}. */ + protected static final int TEXTURE_COUNT_DEFAULT = 2; + + protected volatile State state; + private Object stateLock = new Object(); protected int textureCount; protected int textureTarget; @@ -79,30 +84,72 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected volatile float playSpeed = 1.0f; - /** Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ + /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + protected int vid = GLMediaPlayer.STREAM_ID_AUTO; + /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + protected int aid = GLMediaPlayer.STREAM_ID_AUTO; + /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected int width = 0; - /** Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ + /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected int height = 0; - /** Video fps. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ + /** Video fps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected float fps = 0; - /** Stream bps. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ + protected int frame_period = 0; + /** Stream bps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected int bps_stream = 0; - /** Video bps. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ + /** Video bps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected int bps_video = 0; - /** Audio bps. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ + /** Audio bps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected int bps_audio = 0; - /** In frames. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ - protected int totalFrames = 0; - /** In ms. Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ + /** In frames. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + protected int videoFrames = 0; + /** In frames. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + protected int audioFrames = 0; + /** In ms. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected int duration = 0; - /** Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ + /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected String acodec = unknown; - /** Shall be set by the {@link #initGLStreamImpl(GL)} method implementation. */ + /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected String vcodec = unknown; - protected int frameNumber = 0; - protected int currentVideoPTS = 0; + protected volatile int decodedFrameCount = 0; + protected int presentedFrameCount = 0; + protected volatile int video_pts_last = 0; + + /** See {@link #getAudioSink()}. Set by implementation if used from within {@link #initGLStreamImpl(GL, int, int)}! */ + protected AudioSink audioSink = null; + protected boolean audioSinkPlaySpeedSet = false; + + /** System Clock Reference (SCR) of first audio PTS at start time. */ + private long audio_scr_t0 = 0; + private boolean audioSCR_reset = true; + /** System Clock Reference (SCR) of first video frame at start time. */ + private long video_scr_t0 = 0; + /** System Clock Reference (SCR) PTS offset, i.e. first video PTS at start time. */ + private int video_scr_pts = 0; + /** Cumulative video pts diff. */ + private float video_dpts_cum = 0; + /** Cumulative video frames. */ + private int video_dpts_count = 0; + /** Number of min frame count required for video cumulative sync. */ + private static final int VIDEO_DPTS_NUM = 20; + /** Cumulative coefficient, value {@value}. */ + private static final float VIDEO_DPTS_COEFF = 0.7943282f; // (float) Math.exp(Math.log(0.01) / VIDEO_DPTS_NUM); + /** Maximum valid video pts diff. */ + private static final int VIDEO_DPTS_MAX = 5000; // 5s max diff + /** Trigger video PTS reset with given cause as bitfield. */ + private volatile int videoSCR_reset = 0; + + private final boolean isSCRCause(int bit) { return 0 != ( bit & videoSCR_reset); } + /** SCR reset due to: Start, Resume, Seek, .. */ + private static final int SCR_RESET_FORCE = 1 << 0; + /** SCR reset due to: PlaySpeed */ + private static final int SCR_RESET_SPEED = 1 << 1; + + /** Latched video PTS reset, to wait until valid pts after invalidation of cached ones. Currently [1..{@link #VIDEO_DPTS_NUM}] frames. */ + private int videoSCR_reset_latch = 0; + protected SyncedRingbuffer videoFramesFree = null; protected SyncedRingbuffer videoFramesDecoded = null; protected volatile TextureFrame lastFrame = null; @@ -201,144 +248,205 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } @Override - public final float getPlaySpeed() { - return playSpeed; - } + public final int getDecodedFrameCount() { return decodedFrameCount; } + + @Override + public final int getPresentedFrameCount() { return this.presentedFrameCount; } + + @Override + public final int getVideoPTS() { return video_pts_last; } @Override - public final synchronized void setPlaySpeed(float rate) { - if(State.Uninitialized != state && setPlaySpeedImpl(rate)) { - playSpeed = rate; + public final int getAudioPTS() { + if( State.Uninitialized != state ) { + return getAudioPTSImpl(); } - if(DEBUG) { System.err.println("SetPlaySpeed: "+toString()); } + return 0; } - protected abstract boolean setPlaySpeedImpl(float rate); - - public final State start() { - switch( state ) { - case Stopped: - /** fall-through intended */ - case Paused: - if( startImpl() ) { - resumeFramePusher(); - state = State.Playing; - } - default: + /** Override if not using audioSink! */ + protected int getAudioPTSImpl() { + if( null != audioSink ) { + return audioSink.getPTS(); + } else { + return 0; } - if(DEBUG) { System.err.println("Start: "+toString()); } - return state; } - protected abstract boolean startImpl(); - public final State pause() { - if( State.Playing == state && pauseImpl() ) { - pauseFramePusher(); - state = State.Paused; + public final State getState() { return state; } + + public final State play() { + synchronized( stateLock ) { + switch( state ) { + case Paused: + if( playImpl() ) { + resetAudioVideoSCR(SCR_RESET_FORCE); + resumeFramePusher(); + if( null != audioSink ) { + audioSink.play(); + } + state = State.Playing; + } + default: + } + if(DEBUG) { System.err.println("Start: "+toString()); } + return state; } - if(DEBUG) { System.err.println("Pause: "+toString()); } - return state; } - protected abstract boolean pauseImpl(); + protected abstract boolean playImpl(); - public final State stop() { - switch( state ) { - case Playing: - /** fall-through intended */ - case Paused: - if( stopImpl() ) { + public final State pause() { + synchronized( stateLock ) { + if( State.Playing == state ) { + State _state = state; + state = State.Paused; + if( pauseImpl() ) { + _state = State.Paused; pauseFramePusher(); - state = State.Stopped; + if( null != audioSink ) { + audioSink.pause(); + } } - default: + state = _state; + } + if(DEBUG) { System.err.println("Pause: "+toString()); } + return state; } - if(DEBUG) { System.err.println("Stop: "+toString()); } - return state; } - protected abstract boolean stopImpl(); + protected abstract boolean pauseImpl(); - @Override - public final int getCurrentPosition() { - if( State.Uninitialized != state ) { - return getCurrentPositionImpl(); + public final int seek(int msec) { + synchronized( stateLock ) { + final int pts1; + switch(state) { + case Playing: + case Paused: + final State _state = state; + state = State.Paused; + pauseFramePusher(); + resetAudioVideoSCR(SCR_RESET_FORCE); + pts1 = seekImpl(msec); + if( null != audioSink ) { + audioSink.flush(); + if( State.Playing == _state ) { + audioSink.play(); // cont. w/ new data + } + } + resumeFramePusher(); + state = _state; + break; + default: + pts1 = 0; + } + if(DEBUG) { System.err.println("Seek("+msec+"): "+toString()); } + return pts1; } - return 0; } - protected abstract int getCurrentPositionImpl(); + protected abstract int seekImpl(int msec); @Override - public final int getVideoPTS() { return currentVideoPTS; } + public final float getPlaySpeed() { + return playSpeed; + } @Override - public final int getAudioPTS() { - if( State.Uninitialized != state ) { - return getAudioPTSImpl(); + public final boolean setPlaySpeed(float rate) { + synchronized( stateLock ) { + boolean res = false; + if(State.Uninitialized != state ) { + if( rate > 0.01f ) { + if( Math.abs(1.0f - rate) < 0.01f ) { + rate = 1.0f; + } + if( setPlaySpeedImpl(rate) ) { + resetAudioVideoSCR(SCR_RESET_SPEED); + playSpeed = rate; + if(DEBUG) { System.err.println("SetPlaySpeed: "+toString()); } + res = true; + } + } + } + return res; } - return 0; - } - protected abstract int getAudioPTSImpl(); - - public final int seek(int msec) { - final int pts1; - switch(state) { - case Stopped: - case Playing: - case Paused: - pauseFramePusher(); - pts1 = seekImpl(msec); - currentVideoPTS=pts1; - resumeFramePusher(); - break; - default: - pts1 = 0; + } + /** + * Override if not using AudioSink, or AudioSink's {@link AudioSink#setPlaySpeed(float)} is not sufficient! + *

      + * AudioSink shall respect !audioSinkPlaySpeedSet to determine data_size + * at {@link AudioSink#enqueueData(com.jogamp.opengl.util.av.AudioSink.AudioFrame)}. + *

      + */ + protected boolean setPlaySpeedImpl(float rate) { + if( null != audioSink ) { + audioSinkPlaySpeedSet = audioSink.setPlaySpeed(rate); } - if(DEBUG) { System.err.println("Seek("+msec+"): "+toString()); } - return pts1; + // still true, even if audioSink rejects command since we deal w/ video sync + // and AudioSink w/ audioSinkPlaySpeedSet at enqueueData(..). + return true; } - protected abstract int seekImpl(int msec); - - public final State getState() { return state; } - + @Override - public final State initGLStream(GL gl, int reqTextureCount, URLConnection urlConn) throws IllegalStateException, GLException, IOException { - if(State.Uninitialized != state) { - throw new IllegalStateException("Instance not in state "+State.Uninitialized+", but "+state+", "+this); - } - this.urlConn = urlConn; - if (this.urlConn != null) { - try { - if( null != gl ) { - removeAllTextureFrames(gl); - textureCount = validateTextureCount(reqTextureCount); - if( textureCount < 2 ) { - throw new InternalError("Validated texture count < 2: "+textureCount); - } - initGLStreamImpl(gl); // also initializes width, height, .. etc - videoFramesFree = new SyncedRingbuffer(createTexFrames(gl, textureCount), true /* full */); - if( 2 < textureCount ) { - videoFramesDecoded = new SyncedRingbuffer(new TextureFrame[textureCount], false /* full */); - framePusher = new FramePusher(gl, requiresOffthreadGLCtx()); - framePusher.doStart(); - } else { - videoFramesDecoded = null; + public final State initGLStream(GL gl, int reqTextureCount, URLConnection urlConn, int vid, int aid) throws IllegalStateException, GLException, IOException { + synchronized( stateLock ) { + if(State.Uninitialized != state) { + throw new IllegalStateException("Instance not in state "+State.Uninitialized+", but "+state+", "+this); + } + decodedFrameCount = 0; + presentedFrameCount = 0; + this.urlConn = urlConn; + if (this.urlConn != null) { + try { + if( null != gl ) { + removeAllTextureFrames(gl); + textureCount = validateTextureCount(reqTextureCount); + if( textureCount < TEXTURE_COUNT_DEFAULT ) { + throw new InternalError("Validated texture count < "+TEXTURE_COUNT_DEFAULT+": "+textureCount); + } + initGLStreamImpl(gl, vid, aid); // also initializes width, height, .. etc + videoFramesFree = new SyncedRingbuffer(createTexFrames(gl, textureCount), true /* full */); + if( TEXTURE_COUNT_DEFAULT < textureCount ) { + videoFramesDecoded = new SyncedRingbuffer(new TextureFrame[textureCount], false /* full */); + framePusher = new FramePusher(gl, requiresOffthreadGLCtx()); + framePusher.doStart(); + } else { + videoFramesDecoded = null; + } + lastFrame = videoFramesFree.getBlocking(false /* clearRef */ ); + state = State.Paused; } - lastFrame = videoFramesFree.getBlocking(false /* clearRef */ ); + return state; + } catch (Throwable t) { + throw new GLException("Error initializing GL resources", t); } - state = State.Stopped; - return state; - } catch (Throwable t) { - throw new GLException("Error initializing GL resources", t); } + return state; } - return state; } + /** + * Implementation shall set the following set of data here + * @see #vid + * @see #aid + * @see #width + * @see #height + * @see #fps + * @see #bps_stream + * @see #videoFrames + * @see #audioFrames + * @see #acodec + * @see #vcodec + */ + protected abstract void initGLStreamImpl(GL gl, int vid, int aid) throws IOException; + /** * Returns the validated number of textures to be handled. *

      - * Default is always 2 textures, last texture and the decoding texture. + * Default is 2 textures w/o threading, last texture and the decoding texture. + *

      + *

      + * > 2 textures is used for threaded decoding, a minimum of 4 textures seems reasonable in this case. *

      */ protected int validateTextureCount(int desiredTextureCount) { - return 2; + return TEXTURE_COUNT_DEFAULT; } protected boolean requiresOffthreadGLCtx() { return false; } @@ -405,6 +513,18 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { mustFlipVertically); } + protected void destroyTexFrame(GL gl, TextureFrame frame) { + frame.getTexture().destroy(gl); + } + + @Override + public final TextureFrame getLastTexture() throws IllegalStateException { + if(State.Uninitialized == state) { + throw new IllegalStateException("Instance not initialized: "+this); + } + return lastFrame; + } + private final void removeAllTextureFrames(GL gl) { if( null != videoFramesFree ) { final TextureFrame[] texFrames = videoFramesFree.getArray(); @@ -417,79 +537,209 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { destroyTexFrame(gl, frame); texFrames[i] = null; } + System.err.println(Thread.currentThread().getName()+"> Clear TexFrame["+i+"]: "+frame+" -> null"); } } textureCount=0; } - protected void destroyTexFrame(GL gl, TextureFrame frame) { - frame.getTexture().destroy(gl); - } - - /** - * Implementation shall set the following set of data here - * @param gl TODO - * @see #width - * @see #height - * @see #fps - * @see #bps_stream - * @see #totalFrames - * @see #acodec - * @see #vcodec - */ - protected abstract void initGLStreamImpl(GL gl) throws IOException; @Override - public final TextureFrame getLastTexture() throws IllegalStateException { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); + public final TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException { + synchronized( stateLock ) { + if(State.Uninitialized == state) { + throw new IllegalStateException("Instance not initialized: "+this); + } + if(State.Playing == state) { + TextureFrame nextFrame = null; + boolean ok = true; + boolean dropFrame = false; + try { + do { + if( TEXTURE_COUNT_DEFAULT < textureCount ) { + nextFrame = videoFramesDecoded.getBlocking(false /* clearRef */ ); + } else { + nextFrame = videoFramesFree.getBlocking(false /* clearRef */ ); + if( getNextTextureImpl(gl, nextFrame, blocking) ) { + newFrameAvailable(nextFrame); + } else { + ok = false; + } + } + if( ok ) { + presentedFrameCount++; + final int video_pts; + if( 0 != videoSCR_reset ) { + if( isSCRCause(SCR_RESET_FORCE) ) { + videoSCR_reset_latch = VIDEO_DPTS_NUM / 2; + resetVideoDPTS(); + resetAllVideoPTS(); + } else { + // SCR_RESET_SPEED + videoSCR_reset_latch = 1; + } + videoSCR_reset = 0; + video_pts = TextureFrame.INVALID_PTS; + } else { + video_pts = nextFrame.getPTS(); + } + if( video_pts != TextureFrame.INVALID_PTS ) { + final int frame_period_last = video_pts - video_pts_last; // rendering loop interrupted ? + if( videoSCR_reset_latch > 0 || frame_period_last > frame_period*10 ) { + if( videoSCR_reset_latch > 0 ) { + videoSCR_reset_latch--; + } + setFirstVideoPTS2SCR( video_pts ); + } + final int scr_pts = video_scr_pts + + (int) ( ( System.currentTimeMillis() - video_scr_t0 ) * playSpeed ); + final int d_vpts = video_pts - scr_pts; + if( -VIDEO_DPTS_MAX > d_vpts || d_vpts > VIDEO_DPTS_MAX ) { + if( DEBUG ) { + System.err.println( getPerfStringImpl( scr_pts, video_pts, d_vpts, 0 ) ); + } + } else { + video_dpts_count++; + video_dpts_cum = d_vpts + VIDEO_DPTS_COEFF * video_dpts_cum; + final int video_dpts_avg_diff = getVideoDPTSAvg(); + if( DEBUG ) { + System.err.println( getPerfStringImpl( scr_pts, video_pts, d_vpts, video_dpts_avg_diff ) ); + } + if( blocking && syncAVRequired() ) { + if( !syncAV( (int) ( video_dpts_avg_diff / playSpeed + 0.5f ) ) ) { + resetVideoDPTS(); + dropFrame = true; + } + } + video_pts_last = video_pts; + } + } + final TextureFrame _lastFrame = lastFrame; + lastFrame = nextFrame; + videoFramesFree.putBlocking(_lastFrame); + } + } while( dropFrame ); + } catch (InterruptedException e) { + ok = false; + e.printStackTrace(); + } finally { + if( !ok && null != nextFrame ) { // put back + videoFramesFree.put(nextFrame); + } + } + } + return lastFrame; } - return lastFrame; } + protected abstract boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking); + protected boolean syncAVRequired() { return false; } + /** + * {@inheritDoc} + *

      + * Note: All {@link AudioSink} operations are performed from {@link GLMediaPlayerImpl}, + * i.e. {@link #play()}, {@link #pause()}, {@link #seek(int)}, {@link #setPlaySpeed(float)}, {@link #getAudioPTS()}. + *

      + *

      + * Implementations using an {@link AudioSink} shall write it's instance to {@link #audioSink} + * from within their {@link #initGLStreamImpl(GL, int, int)} implementation. + *

      + */ @Override - public final synchronized TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); + public final AudioSink getAudioSink() { return audioSink; } + + /** + * To be called from implementation at 1st PTS after start + * w/ current pts value in milliseconds. + * @param audio_scr_t0 + */ + protected void setFirstAudioPTS2SCR(int pts) { + if( audioSCR_reset ) { + audio_scr_t0 = System.currentTimeMillis() - pts; + audioSCR_reset = false; } - if(State.Playing == state) { - TextureFrame nextFrame = null; - boolean ok = true; - try { - if( 2 < textureCount ) { - nextFrame = videoFramesDecoded.getBlocking(false /* clearRef */ ); - } else { - nextFrame = videoFramesFree.getBlocking(false /* clearRef */ ); - if( getNextTextureImpl(gl, nextFrame, blocking) ) { - newFrameAvailable(nextFrame); - } else { - ok = false; - } - } - if( ok ) { - currentVideoPTS = nextFrame.getPTS(); - if( blocking ) { - syncFrame2Audio(nextFrame); - } - final TextureFrame _lastFrame = lastFrame; - lastFrame = nextFrame; - videoFramesFree.putBlocking(_lastFrame); - } - } catch (InterruptedException e) { - ok = false; - e.printStackTrace(); - } finally { - if( !ok && null != nextFrame ) { // put back - videoFramesFree.put(nextFrame); - } + } + private void setFirstVideoPTS2SCR(int pts) { + // video_scr_t0 = System.currentTimeMillis() - pts; + video_scr_t0 = System.currentTimeMillis(); + video_scr_pts = pts; + } + private void resetAllVideoPTS() { + if( null != videoFramesFree ) { + final TextureFrame[] texFrames = videoFramesFree.getArray(); + for(int i=0; i + * https://en.wikipedia.org/wiki/Audio_to_video_synchronization + *
      +     *   d_av = v_pts - a_pts;
      +     * 
      + *

      + *

      + * Recommendation of audio/video pts time lead/lag at production: + *

        + *
      • Overall: +40ms and -60ms audio ahead video / audio after video
      • + *
      • Each stage: +5ms and -15ms. audio ahead video / audio after video
      • + *
      + *

      + *

      + * Recommendation of av pts time lead/lag at presentation: + *

        + *
      • TV: +15ms and -45ms. audio ahead video / audio after video.
      • + *
      • Film: +22ms and -22ms. audio ahead video / audio after video.
      • + *
      + *

      + *

      + * Maybe implemented as follows: + *

      +     *   d_av = vpts - apts;
      +     *   d_av < -22: audio after video == video ahead audio -> drop
      +     *   d_av >  22: audio ahead video == video after audio -> sleep(d_av - 10) 
      +     * 
      + *

      + *

      + * Returns true if audio is ahead of video, otherwise false (video is ahead of audio). + * In case of the latter (false), the video frame shall be dropped! + *

      + * @param frame + * @return true if audio is ahead of video, otherwise false (video is ahead of audio) + */ + protected boolean syncAV(int d_vpts) { + if( d_vpts > 22 ) { + if( DEBUG ) { + System.err.println("V (sleep): "+(d_vpts - 22 / 2)+" ms"); } + try { + Thread.sleep( d_vpts - 22 / 2 ); + } catch (InterruptedException e) { } } - return lastFrame; + return true; } - protected abstract boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking); - protected abstract void syncFrame2Audio(TextureFrame frame); private final void newFrameAvailable(TextureFrame frame) { - frameNumber++; + decodedFrameCount++; synchronized(eventListenersLock) { for(Iterator i = eventListeners.iterator(); i.hasNext(); ) { i.next().newFrameAvailable(this, frame, System.currentTimeMillis()); @@ -500,6 +750,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { class FramePusher extends Thread { private volatile boolean isRunning = false; private volatile boolean isActive = false; + private volatile boolean isBlocked = false; private volatile boolean shallPause = true; private volatile boolean shallStop = false; @@ -560,6 +811,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public synchronized void doPause() { if( isActive ) { shallPause = true; + if( isBlocked && isActive ) { + this.interrupt(); + } while( isActive ) { try { this.wait(); // wait until paused @@ -595,6 +849,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public synchronized void doStop() { if( isRunning ) { shallStop = true; + if( isBlocked && isRunning ) { + this.interrupt(); + } while( isRunning ) { this.notify(); // wake-up pause-block (opt) try { @@ -629,7 +886,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { try { this.wait(); // wait until resumed } catch (InterruptedException e) { - e.printStackTrace(); + if( !shallPause ) { + e.printStackTrace(); + } } } isActive = true; @@ -639,23 +898,30 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( !shallStop ) { TextureFrame nextFrame = null; - boolean ok = false; try { - nextFrame = videoFramesFree.getBlocking(true /* clearRef */ ); + isBlocked = true; + nextFrame = videoFramesFree.getBlocking(false /* clearRef */ ); + isBlocked = false; + nextFrame.setPTS( TextureFrame.INVALID_PTS ); // mark invalid until processed! if( getNextTextureImpl(gl, nextFrame, true) ) { - gl.glFinish(); - videoFramesDecoded.putBlocking(nextFrame); - newFrameAvailable(nextFrame); - ok = true; + // gl.glFinish(); + gl.glFlush(); // even better: sync object! + if( !videoFramesDecoded.put(nextFrame) ) { + throw new InternalError("XXX: "+GLMediaPlayerImpl.this); + } + final TextureFrame _nextFrame = nextFrame; + nextFrame = null; + newFrameAvailable(_nextFrame); } } catch (InterruptedException e) { + isBlocked = false; if( !shallStop && !shallPause ) { e.printStackTrace(); // oops shallPause = false; shallStop = true; } } finally { - if( !ok && null != nextFrame ) { // put back + if( null != nextFrame ) { // put back videoFramesFree.put(nextFrame); } } @@ -689,10 +955,18 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } - protected final void updateAttributes(int width, int height, int bps_stream, int bps_video, int bps_audio, - float fps, int totalFrames, int duration, - String vcodec, String acodec) { + protected final void updateAttributes(int vid, int aid, int width, int height, int bps_stream, + int bps_video, int bps_audio, float fps, + int videoFrames, int audioFrames, int duration, String vcodec, String acodec) { int event_mask = 0; + if( this.vid != vid ) { + event_mask |= GLMediaEventListener.EVENT_CHANGE_VID; + this.vid = vid; + } + if( this.aid != aid ) { + event_mask |= GLMediaEventListener.EVENT_CHANGE_AID; + this.aid = aid; + } if( this.width != width || this.height != height ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_SIZE; this.width = width; @@ -701,6 +975,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( this.fps != fps ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_FPS; this.fps = fps; + this.frame_period = (int) ( 1000f / fps + 0.5f ); } if( this.bps_stream != bps_stream || this.bps_video != bps_video || this.bps_audio != bps_audio ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_BPS; @@ -708,9 +983,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.bps_video = bps_video; this.bps_audio = bps_audio; } - if( this.totalFrames != totalFrames || this.duration != duration ) { + if( this.videoFrames != videoFrames || this.audioFrames != audioFrames || this.duration != duration ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_LENGTH; - this.totalFrames = totalFrames; + this.videoFrames = videoFrames; + this.audioFrames = audioFrames; this.duration = duration; } if( (null!=acodec && acodec.length()>0 && !this.acodec.equals(acodec)) ) { @@ -736,78 +1012,120 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } @Override - public final synchronized State destroy(GL gl) { - destroyFramePusher(); - destroyImpl(gl); - removeAllTextureFrames(gl); - state = State.Uninitialized; - return state; + public final State destroy(GL gl) { + synchronized( stateLock ) { + destroyFramePusher(); + destroyImpl(gl); + removeAllTextureFrames(gl); + state = State.Uninitialized; + return state; + } } protected abstract void destroyImpl(GL gl); @Override - public final synchronized URLConnection getURLConnection() { + public final URLConnection getURLConnection() { return urlConn; } @Override - public final synchronized String getVideoCodec() { + public final int getVID() { return vid; } + + @Override + public final int getAID() { return aid; } + + @Override + public final String getVideoCodec() { return vcodec; } @Override - public final synchronized String getAudioCodec() { + public final String getAudioCodec() { return acodec; } @Override - public final synchronized long getTotalFrames() { - return totalFrames; + public final int getVideoFrames() { + return videoFrames; + } + + public final int getAudioFrames() { + return audioFrames; } @Override - public final synchronized int getDuration() { + public final int getDuration() { return duration; } @Override - public final synchronized long getStreamBitrate() { + public final long getStreamBitrate() { return bps_stream; } @Override - public final synchronized int getVideoBitrate() { + public final int getVideoBitrate() { return bps_video; } @Override - public final synchronized int getAudioBitrate() { + public final int getAudioBitrate() { return bps_audio; } @Override - public final synchronized float getFramerate() { + public final float getFramerate() { return fps; } @Override - public final synchronized int getWidth() { + public final int getWidth() { return width; } @Override - public final synchronized int getHeight() { + public final int getHeight() { return height; } @Override - public final synchronized String toString() { - final float ct = getCurrentPosition() / 1000.0f, tt = getDuration() / 1000.0f; + public final String toString() { + final float tt = getDuration() / 1000.0f; final String loc = ( null != urlConn ) ? urlConn.getURL().toExternalForm() : "" ; - return "GLMediaPlayer["+state+", "+frameNumber+"/"+totalFrames+" frames, "+ct+"/"+tt+"s, speed "+playSpeed+", "+bps_stream+" bps, "+ - "Texture[count "+textureCount+", target "+toHexString(textureTarget)+", format "+toHexString(textureFormat)+", type "+toHexString(textureType)+"], "+ - "Stream[Video[<"+vcodec+">, "+width+"x"+height+", "+fps+" fps, "+bps_video+" bsp], "+ - "Audio[<"+acodec+">, "+bps_audio+" bsp]], "+loc+"]"; + final int freeVideoFrames = null != videoFramesFree ? videoFramesFree.size() : 0; + final int decVideoFrames = null != videoFramesDecoded ? videoFramesDecoded.size() : 0; + return "GLMediaPlayer["+state+", frames[p "+presentedFrameCount+", d "+decodedFrameCount+", t "+videoFrames+" ("+tt+" s)], "+ + "speed "+playSpeed+", "+bps_stream+" bps, "+ + "Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+", target "+toHexString(textureTarget)+", format "+toHexString(textureFormat)+", type "+toHexString(textureType)+"], "+ + "Video[id "+vid+", <"+vcodec+">, "+width+"x"+height+", "+fps+" fps, "+bps_video+" bps], "+ + "Audio[id "+aid+", <"+acodec+">, "+bps_audio+" bps, "+audioFrames+" frames], uri "+loc+"]"; + } + + @Override + public final String getPerfString() { + final int scr_pts = video_scr_pts + + (int) ( ( System.currentTimeMillis() - video_scr_t0 ) * playSpeed ); + final int d_vpts = video_pts_last - scr_pts; + return getPerfStringImpl( scr_pts, video_pts_last, d_vpts, getVideoDPTSAvg() ); + } + private final String getPerfStringImpl(final int scr_pts, final int video_pts, final int d_vpts, final int video_dpts_avg_diff) { + final float tt = getDuration() / 1000.0f; + final int audio_scr = (int) ( ( System.currentTimeMillis() - audio_scr_t0 ) * playSpeed ); + final int audio_pts = getAudioPTSImpl(); + final int d_apts = audio_pts - audio_scr; + final String audioSinkInfo; + final AudioSink audioSink = getAudioSink(); + if( null != audioSink ) { + audioSinkInfo = "AudioSink[frames [d "+audioSink.getEnqueuedFrameCount()+", q "+audioSink.getQueuedFrameCount()+", f "+audioSink.getFreeFrameCount()+"], time "+audioSink.getQueuedTime()+", bytes "+audioSink.getQueuedByteCount()+"]"; + } else { + audioSinkInfo = ""; + } + final int freeVideoFrames = null != videoFramesFree ? videoFramesFree.size() : 0; + final int decVideoFrames = null != videoFramesDecoded ? videoFramesDecoded.size() : 0; + return state+", frames[p "+presentedFrameCount+", d "+decodedFrameCount+", t "+videoFrames+" ("+tt+" s)], "+ + "speed " + playSpeed+", vSCR "+scr_pts+", vpts "+video_pts+", dSCR["+d_vpts+", avrg "+video_dpts_avg_diff+"], "+ + "aSCR "+audio_scr+", apts "+audio_pts+" ( "+d_apts+" ), "+audioSinkInfo+ + ", Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+"]"; } @Override @@ -831,7 +1149,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } @Override - public final synchronized GLMediaEventListener[] getEventListeners() { + public final GLMediaEventListener[] getEventListeners() { synchronized(eventListenersLock) { return eventListeners.toArray(new GLMediaEventListener[eventListeners.size()]); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index f1ce42257..5d70ca33d 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -38,6 +38,7 @@ import jogamp.opengl.util.av.GLMediaPlayerImpl; import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureIO; @@ -62,7 +63,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final boolean startImpl() { + protected final boolean playImpl() { pos_start = (int)System.currentTimeMillis(); return true; } @@ -72,11 +73,6 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { return true; } - @Override - protected final boolean stopImpl() { - return true; - } - @Override protected final int seekImpl(int msec) { pos_ms = msec; @@ -86,20 +82,16 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { @Override protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking) { + nextFrame.setPTS( getAudioPTSImpl() ); return true; } - @Override - protected final void syncFrame2Audio(TextureFrame frame) { } @Override - protected final int getCurrentPositionImpl() { + protected final int getAudioPTSImpl() { pos_ms = (int)System.currentTimeMillis() - pos_start; validatePos(); return pos_ms; } - @Override - protected final int getAudioPTSImpl() { return getCurrentPositionImpl(); } - @Override protected final void destroyImpl(GL gl) { @@ -110,7 +102,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final void initGLStreamImpl(GL gl) throws IOException { + protected final void initGLStreamImpl(GL gl, int vid, int aid) throws IOException { try { URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader()); if(null != urlConn) { @@ -136,13 +128,14 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, false, false, false, buffer, null); } + final int r_aid = GLMediaPlayer.STREAM_ID_NONE == aid ? GLMediaPlayer.STREAM_ID_NONE : GLMediaPlayer.STREAM_ID_AUTO; final float _fps = 24f; final int _duration = 10*60*1000; // msec final int _totalFrames = (int) ( (_duration/1000)*_fps ); - updateAttributes(_w, _h, - 0, 0, 0, - _fps, _totalFrames, _duration, - "png-static", null); + updateAttributes(GLMediaPlayer.STREAM_ID_AUTO, r_aid, + _w, _h, 0, + 0, 0, _fps, + _totalFrames, 0, _duration, "png-static", null); } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 83a5960f1..dc7ceae39 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -42,9 +42,11 @@ import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.opengl.util.GLPixelStorageModes; import com.jogamp.opengl.util.av.AudioSink; +import com.jogamp.opengl.util.av.AudioSink.AudioDataFormat; +import com.jogamp.opengl.util.av.AudioSink.AudioDataType; import com.jogamp.opengl.util.av.AudioSinkFactory; +import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; -import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; import jogamp.opengl.GLContextImpl; import jogamp.opengl.util.av.GLMediaPlayerImpl; @@ -136,13 +138,17 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { ( vers >> 8 ) & 0xFF, ( vers >> 0 ) & 0xFF ); } + + // + // General + // + + protected long moviePtr = 0; // // Video // - protected long moviePtr = 0; - protected GLPixelStorageModes psm; protected PixelFormat vPixelFmt = null; protected int vPlanes = 0; protected int vBitsPerPixel = 0; @@ -152,15 +158,17 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { protected int texWidth, texHeight; // overall (stuffing planes in one texture) protected ByteBuffer texCopy; protected String singleTexComp = "r"; + protected GLPixelStorageModes psm; // // Audio // - protected final int AudioFrameCount = 8; - protected final AudioSink audioSink; - protected final int maxAvailableAudio; - protected AudioSink.AudioDataFormat chosenAudioFormat; + protected static final int AFRAMES_PER_VFRAME = 8; + protected int aFrameCount = 0; + protected SampleFormat aSampleFmt = null; + protected AudioSink.AudioDataFormat avChosenAudioFormat; + protected AudioSink.AudioDataFormat sinkChosenAudioFormat; public FFMPEGMediaPlayer() { if(!available) { @@ -171,12 +179,11 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { throw new GLException("Couldn't create FFMPEGInstance"); } psm = new GLPixelStorageModes(); - audioSink = AudioSinkFactory.createDefault(); - maxAvailableAudio = audioSink.getQueuedByteCount(); + audioSink = null; } @Override protected final int validateTextureCount(int desiredTextureCount) { - return desiredTextureCount>1 ? desiredTextureCount : 2; + return desiredTextureCount>2 ? Math.max(4, desiredTextureCount) : 2; } @Override protected final boolean requiresOffthreadGLCtx() { return true; } @@ -187,10 +194,18 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { destroyInstance0(moviePtr); moviePtr = 0; } + destroyAudioSink(); + } + private final void destroyAudioSink() { + final AudioSink _audioSink = audioSink; + if( null != _audioSink ) { + audioSink = null; + _audioSink.destroy(); + } } @Override - protected final void initGLStreamImpl(GL gl) throws IOException { + protected final void initGLStreamImpl(GL gl, int vid, int aid) throws IOException { if(0==moviePtr) { throw new GLException("FFMPEG native instance null"); } @@ -209,11 +224,32 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } final String urlS=urlConn.getURL().toExternalForm(); + + aFrameCount = AFRAMES_PER_VFRAME * textureCount + AFRAMES_PER_VFRAME/2; - chosenAudioFormat = audioSink.initSink(audioSink.getPreferredFormat(), AudioFrameCount); System.err.println("setURL: p1 "+this); - setStream0(moviePtr, urlS, -1, -1, AudioFrameCount); // issues updateAttributes*(..) - System.err.println("setURL: p2 "+this); + destroyAudioSink(); + AudioSink _audioSink; + if( GLMediaPlayer.STREAM_ID_NONE == aid ) { + _audioSink = AudioSinkFactory.createNull(); + } else { + _audioSink = AudioSinkFactory.createDefault(); + } + final AudioDataFormat preferredAudioFormat = _audioSink.getPreferredFormat(); + // setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc + setStream0(moviePtr, urlS, vid, aid, aFrameCount, preferredAudioFormat.channelCount, preferredAudioFormat.sampleRate); + // final int audioBytesPerFrame = bps_audio/8000 * frame_period * textureCount; + + System.err.println("setURL: p2 preferred "+preferredAudioFormat+", avChosen "+avChosenAudioFormat+", "+this); + sinkChosenAudioFormat = _audioSink.initSink(avChosenAudioFormat, aFrameCount); + System.err.println("setURL: p3 avChosen "+avChosenAudioFormat+", chosen "+sinkChosenAudioFormat); + if( null == sinkChosenAudioFormat ) { + System.err.println("AudioSink "+_audioSink.getClass().getName()+" does not support "+avChosenAudioFormat+", using Null"); + _audioSink.destroy(); + _audioSink = AudioSinkFactory.createNull(); + sinkChosenAudioFormat = _audioSink.initSink(avChosenAudioFormat, aFrameCount); + } + audioSink = _audioSink; int tf, tif=GL.GL_RGBA; // texture format and internal format switch(vBytesPerPixelPerPlane) { @@ -256,7 +292,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { private void updateAttributes2(int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, int lSz0, int lSz1, int lSz2, - int tWd0, int tWd1, int tWd2) { + int tWd0, int tWd1, int tWd2, + int sampleFmt, int sampleRate, int channels) { vPixelFmt = PixelFormat.valueOf(pixFmt); vPlanes = planes; vBitsPerPixel = bitsPerPixel; @@ -286,12 +323,53 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { default: // FIXME: Add more planar formats ! throw new RuntimeException("Unsupported pixelformat: "+vPixelFmt); } + + aSampleFmt = SampleFormat.valueOf(sampleFmt); + final int sampleSize; + final boolean signed, fixedP; + switch( aSampleFmt ) { + case S32: + case S32P: + sampleSize = 32; + signed = true; + fixedP = true; + break; + case S16: + case S16P: + sampleSize = 16; + signed = true; + fixedP = true; + break; + case U8: + case U8P: + sampleSize = 8; + signed = false; + fixedP = true; + break; + case DBL: + case DBLP: + sampleSize = 64; + signed = true; + fixedP = true; + break; + case FLT: + case FLTP: + sampleSize = 32; + signed = true; + fixedP = true; + break; + default: // FIXME: Add more planar formats ! + throw new RuntimeException("Unsupported sampleformat: "+aSampleFmt); + } + avChosenAudioFormat = new AudioDataFormat(AudioDataType.PCM, sampleRate, sampleSize, channels, signed, fixedP, true /* littleEndian */); + if(DEBUG) { - System.err.println("XXX0: fmt "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane); + System.err.println("audio: fmt "+aSampleFmt+", "+avChosenAudioFormat); + System.err.println("video: fmt "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane); for(int i=0; i<3; i++) { - System.err.println("XXX0 "+i+": "+vTexWidth[i]+"/"+vLinesize[i]); + System.err.println("video: "+i+": "+vTexWidth[i]+"/"+vLinesize[i]); } - System.err.println("XXX0 total tex "+texWidth+"x"+texHeight); + System.err.println("video: total tex "+texWidth+"x"+texHeight); } } @@ -355,54 +433,27 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final synchronized int getCurrentPositionImpl() { - return 0!=moviePtr ? getVideoPTS0(moviePtr) : 0; - } - - @Override - public final int getAudioPTSImpl() { return 0; } - - @Override - protected final synchronized boolean setPlaySpeedImpl(float rate) { - return true; - } - - @Override - public final synchronized boolean startImpl() { + public final boolean playImpl() { if(0==moviePtr) { return false; } return true; } - /** @return time position after issuing the command */ @Override - public final synchronized boolean pauseImpl() { + public final boolean pauseImpl() { if(0==moviePtr) { return false; } return true; } - /** @return time position after issuing the command */ - @Override - public final synchronized boolean stopImpl() { - if(0==moviePtr) { - return false; - } - return true; - } - - /** @return time position after issuing the command */ @Override protected final synchronized int seekImpl(int msec) { if(0==moviePtr) { throw new GLException("FFMPEG native instance null"); } - int pts0 = getVideoPTS0(moviePtr); - int pts1 = seek0(moviePtr, msec); - System.err.println("Seek: "+pts0+" -> "+msec+" : "+pts1); - return pts1; + return seek0(moviePtr, msec); } @Override @@ -427,7 +478,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { psm.restore(gl); } if( 0 < avPTS ) { - vSTS = avPTS; nextFrame.setPTS(avPTS); return true; } else { @@ -436,50 +486,15 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } private final void pushSound(ByteBuffer sampleData, int data_size, int audio_pts) { - aSTS = audio_pts; - final AudioSink.AudioFrame frame = new AudioSink.AudioFrame(sampleData, data_size, audio_pts); - if( audioSink.isDataAvailable(frame.dataSize) ) { - audioSink.writeData(frame); + setFirstAudioPTS2SCR( audio_pts ); + if( 1.0f == playSpeed || audioSinkPlaySpeedSet ) { + audioSink.enqueueData( new AudioSink.AudioFrame(sampleData, data_size, audio_pts ) ); } } - - /** last audio streaming TS */ - private int aSTS = 0; - /** last video streaming TS */ - private int vSTS = 0; - - private long lastAudioTime = 0; - private static final int audio_dt_d = 400; - private long lastVideoTime = 0; - private static final int video_dt_d = 9; - + @Override - protected final void syncFrame2Audio(TextureFrame frame) { - /** - // poor mans video sync .. TODO: off thread 'readNextPackage0(..)' on shared GLContext and multi textures/unit! - final long now = System.currentTimeMillis(); - // Try sync video to audio - final long now_d = now - lastAudioTime; - final long pts_d = vSTS - aSTS - 444; // hack 444 == play video 444ms ahead of audio - final long dt = Math.min(47, (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ) ; - //final long dt = (long) ( (float) ( pts_d - now_d ) / getPlaySpeed() ) ; - final boolean sleep = dt>video_dt_d && dt<1000 && audioSink.getQueuedByteCount() + * Always uses {@link AudioSink.AudioDataFormat}: + *
      +     *   [type PCM, sampleRate [10000(?)..44100..48000], sampleSize 16, channelCount 1-2, signed, littleEndian]
      +     * 
      + *

      */ - private native void setStream0(long moviePtr, String url, int vid, int aid, int audioFrameCount); + private native void setStream0(long moviePtr, String url, int vid, int aid, int audioFrameCount, + int aChannelCount, int aSampleRate); private native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError); private native int getVideoPTS0(long moviePtr); @@ -505,6 +527,32 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { private native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); private native int seek0(long moviePtr, int position); + + public static enum SampleFormat { + // NONE = -1, + U8, ///< unsigned 8 bits + S16, ///< signed 16 bits + S32, ///< signed 32 bits + FLT, ///< float + DBL, ///< double + + U8P, ///< unsigned 8 bits, planar + S16P, ///< signed 16 bits, planar + S32P, ///< signed 32 bits, planar + FLTP, ///< float, planar + DBLP, ///< double, planar + + COUNT; ///< Number of sample formats. + + public static SampleFormat valueOf(int i) { + for (SampleFormat fmt : SampleFormat.values()) { + if(fmt.ordinal() == i) { + return fmt; + } + } + return null; + } + }; public static enum PixelFormat { // NONE= -1, diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java index a21bb40a8..d03cad28a 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java @@ -88,15 +88,16 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { @Override protected void destroyImpl(GL gl) { - _detachVideoRenderer(moviePtr); if (moviePtr != 0) { + _stop(moviePtr); + _detachVideoRenderer(moviePtr); _destroyInstance(moviePtr); moviePtr = 0; } } @Override - protected void initGLStreamImpl(GL gl) throws IOException { + protected void initGLStreamImpl(GL gl, int vid, int aid) throws IOException { if(0==moviePtr) { throw new GLException("OMX native instance null"); } @@ -112,13 +113,9 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { System.out.println("setURL: p2 "+this); } - @Override - protected int getCurrentPositionImpl() { - return 0!=moviePtr ? _getCurrentPosition(moviePtr) : 0; - } @Override protected int getAudioPTSImpl() { - return getCurrentPositionImpl(); + return 0!=moviePtr ? _getCurrentPosition(moviePtr) : 0; } @Override @@ -131,7 +128,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } @Override - public synchronized boolean startImpl() { + public synchronized boolean playImpl() { if(0==moviePtr) { return false; } @@ -149,16 +146,6 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { return true; } - /** @return time position after issuing the command */ - @Override - public synchronized boolean stopImpl() { - if(0==moviePtr) { - return false; - } - _stop(moviePtr); - return true; - } - /** @return time position after issuing the command */ @Override protected int seekImpl(int msec) { @@ -184,8 +171,6 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } return true; } - @Override - protected void syncFrame2Audio(TextureFrame frame) { } private String replaceAll(String orig, String search, String repl) { String dest=null; diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index 2dff1110c..081e17323 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -58,6 +58,18 @@ typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); */ #define AV_TIME_BASE_MSEC (AV_TIME_BASE/1000) +#define AV_VERSION_MAJOR(i) ( ( i >> 16 ) & 0xFF ) +#define AV_VERSION_MINOR(i) ( ( i >> 8 ) & 0xFF ) +#define AV_VERSION_SUB(i) ( ( i >> 0 ) & 0xFF ) + +/** Sync w/ GLMediaPlayer.STREAM_ID_NONE */ +#define AV_STREAM_ID_NONE -2 + +/** Sync w/ GLMediaPlayer.STREAM_ID_AUTO */ +#define AV_STREAM_ID_AUTO -1 + +#define AV_HAS_API_REQUEST_CHANNELS(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) < 55) + static inline float my_av_q2f(AVRational a){ return a.num / (float) a.den; } @@ -68,6 +80,10 @@ static inline int32_t my_av_q2i32(int32_t snum, AVRational a){ typedef struct { int32_t verbose; + uint32_t avcodecVersion; + uint32_t avformatVersion; + uint32_t avutilVersion; + PFNGLTEXSUBIMAGE2DPROC procAddrGLTexSubImage2D; PFNGLGETERRORPROC procAddrGLGetError; @@ -103,7 +119,8 @@ typedef struct { int32_t bps_stream; // bits per seconds int32_t bps_video; // bits per seconds int32_t bps_audio; // bits per seconds - int32_t totalFrames; + int32_t frames_video; + int32_t frames_audio; int32_t duration; // msec int32_t start_time; // msec diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c index 346ba6c07..bc376cebd 100644 --- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c +++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c @@ -31,6 +31,7 @@ #include "JoglCommon.h" #include "ffmpeg_tool.h" #include +#include #include static const char * const ClazzNameFFMPEGMediaPlayer = "jogamp/opengl/util/av/impl/FFMPEGMediaPlayer"; @@ -204,17 +205,18 @@ static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasic } (*env)->CallVoidMethod(env, instance, jni_mid_updateAttributes1, + pAV->vid, pAV->aid, w, h, pAV->bps_stream, pAV->bps_video, pAV->bps_audio, - pAV->fps, (int32_t)((pAV->duration/1000)*pAV->fps), pAV->duration, + pAV->fps, pAV->frames_video, pAV->frames_audio, pAV->duration, (*env)->NewStringUTF(env, pAV->vcodec), (*env)->NewStringUTF(env, pAV->acodec) ); (*env)->CallVoidMethod(env, instance, jni_mid_updateAttributes2, pAV->vPixFmt, pAV->vBufferPlanes, pAV->vBitsPerPixel, pAV->vBytesPerPixelPerPlane, pAV->vLinesize[0], pAV->vLinesize[1], pAV->vLinesize[2], - pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2]); - // JoglCommon_ReleaseJNIEnv (shallBeDetached); + pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2], + pAV->aSampleFmt, pAV->aSampleRate, pAV->aChannels); } } @@ -337,8 +339,8 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_ini } jni_mid_pushSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "pushSound", "(Ljava/nio/ByteBuffer;II)V"); - jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIFIILjava/lang/String;Ljava/lang/String;)V"); - jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIII)V"); + jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIIIFIIILjava/lang/String;Ljava/lang/String;)V"); + jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIII)V"); if(jni_mid_pushSound == NULL || jni_mid_updateAttributes1 == NULL || @@ -356,6 +358,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_create JoglCommon_throwNewRuntimeException(env, "Couldn't alloc instance"); return 0; } + pAV->avcodecVersion = sp_avcodec_version(); + pAV->avformatVersion = sp_avformat_version(); + pAV->avutilVersion = sp_avutil_version(); + // Register all formats and codecs sp_av_register_all(); // Network too .. @@ -364,8 +370,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_create } pAV->verbose = verbose; - pAV->vid=-1; - pAV->aid=-1; + pAV->vid=AV_STREAM_ID_AUTO; + pAV->aid=AV_STREAM_ID_AUTO; return (jlong) (intptr_t) pAV; } @@ -380,8 +386,23 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_destroy } } +static uint64_t getDefaultAudioChannelLayout(int channelCount) { + switch(channelCount) { + case 1: return AV_CH_LAYOUT_MONO; + case 2: return AV_CH_LAYOUT_STEREO; + case 3: return AV_CH_LAYOUT_SURROUND; + case 4: return AV_CH_LAYOUT_QUAD; + case 5: return AV_CH_LAYOUT_5POINT0; + case 6: return AV_CH_LAYOUT_5POINT1; + case 7: return AV_CH_LAYOUT_6POINT1; + case 8: return AV_CH_LAYOUT_7POINT1; + default: return AV_CH_LAYOUT_NATIVE; + } +} + JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStream0 - (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jint vid, jint aid, jint audioFrameCount) + (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jint vid, jint aid, jint audioFrameCount, + jint aChannelCount, jint aSampleRate) { int res, i; jboolean iscopy; @@ -434,27 +455,39 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre pAV->bps_stream = pAV->pFormatCtx->bit_rate; } - fprintf(stderr, "Streams: %d\n", pAV->pFormatCtx->nb_streams); // JAU + if(pAV->verbose) { + fprintf(stderr, "Streams: %d, req vid %d aid %d\n", pAV->pFormatCtx->nb_streams, vid, aid); + } // Find the first audio and video stream, or the one matching vid // FIXME: Libav Binary compatibility! JAU01 - for(i=0; ( -1==pAV->aid || -1==pAV->vid ) && ipFormatCtx->nb_streams; i++) { + for(i=0; ( AV_STREAM_ID_AUTO==pAV->aid || AV_STREAM_ID_AUTO==pAV->vid ) && ipFormatCtx->nb_streams; i++) { AVStream *st = pAV->pFormatCtx->streams[i]; - fprintf(stderr, "Stream: %d: is-video %d, is-audio %d\n", i, (AVMEDIA_TYPE_VIDEO == st->codec->codec_type), AVMEDIA_TYPE_AUDIO == st->codec->codec_type); // JAU + if(pAV->verbose) { + fprintf(stderr, "Stream: %d: is-video %d, is-audio %d\n", i, (AVMEDIA_TYPE_VIDEO == st->codec->codec_type), AVMEDIA_TYPE_AUDIO == st->codec->codec_type); + } if(AVMEDIA_TYPE_VIDEO == st->codec->codec_type) { - if(-1==pAV->vid && (-1==vid || vid == i) ) { + if(AV_STREAM_ID_AUTO==pAV->vid && (AV_STREAM_ID_AUTO==vid || vid == i) ) { pAV->pVStream = st; pAV->vid=i; } } else if(AVMEDIA_TYPE_AUDIO == st->codec->codec_type) { - if(-1==pAV->aid && (-1==aid || aid == i) ) { + if(AV_STREAM_ID_AUTO==pAV->aid && (AV_STREAM_ID_AUTO==aid || aid == i) ) { pAV->pAStream = st; pAV->aid=i; } } } + if( AV_STREAM_ID_AUTO == pAV->aid ) { + pAV->aid = AV_STREAM_ID_NONE; + } + if( AV_STREAM_ID_AUTO == pAV->vid ) { + pAV->vid = AV_STREAM_ID_NONE; + } - fprintf(stderr, "Found vid %d, aid %d\n", pAV->vid, pAV->aid); // JAU + if( pAV->verbose ) { + fprintf(stderr, "Found vid %d, aid %d\n", pAV->vid, pAV->aid); + } if(0<=pAV->aid) { // Get a pointer to the codec context for the audio stream @@ -465,6 +498,23 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre if (pAV->pACodecCtx->bit_rate) { pAV->bps_audio = pAV->pACodecCtx->bit_rate; } + + // Customize .. + // pAV->pACodecCtx->thread_count=2; + // pAV->pACodecCtx->thread_type=FF_THREAD_FRAME|FF_THREAD_SLICE; // Decode more than one frame at once + pAV->pACodecCtx->thread_count=1; + pAV->pACodecCtx->thread_type=0; + pAV->pACodecCtx->workaround_bugs=FF_BUG_AUTODETECT; + pAV->pACodecCtx->skip_frame=AVDISCARD_DEFAULT; + + pAV->pACodecCtx->request_channel_layout=getDefaultAudioChannelLayout(aChannelCount); + if( AV_HAS_API_REQUEST_CHANNELS(pAV) && 1 <= aChannelCount && aChannelCount <= 2 ) { + pAV->pACodecCtx->request_channels=aChannelCount; + } + pAV->pACodecCtx->request_sample_fmt=AV_SAMPLE_FMT_S16; + // ignored: aSampleRate ! + pAV->pACodecCtx->skip_frame=AVDISCARD_DEFAULT; + sp_avcodec_string(pAV->acodec, sizeof(pAV->acodec), pAV->pACodecCtx, 0); // Find the decoder for the audio stream @@ -489,8 +539,17 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre // FIXME: Libav Binary compatibility! JAU01 pAV->aSampleRate = pAV->pACodecCtx->sample_rate; pAV->aChannels = pAV->pACodecCtx->channels; - pAV->aFrameSize = pAV->pACodecCtx->frame_size; + pAV->aFrameSize = pAV->pACodecCtx->frame_size; // in samples! pAV->aSampleFmt = pAV->pACodecCtx->sample_fmt; + pAV->frames_audio = pAV->pAStream->nb_frames; + + if( pAV->verbose ) { + fprintf(stderr, "A channels %d, sample_rate %d, frame_size %d, frame_number %d, r_frame_rate %f, avg_frame_rate %f, nb_frames %d, \n", + pAV->aChannels, pAV->aSampleRate, pAV->aFrameSize, pAV->pACodecCtx->frame_number, + my_av_q2f(pAV->pAStream->r_frame_rate), + my_av_q2f(pAV->pAStream->avg_frame_rate), + pAV->pAStream->nb_frames); + } pAV->aFrameCount = audioFrameCount; pAV->pAFrames = calloc(audioFrameCount, sizeof(AVFrame*)); @@ -516,6 +575,15 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre // FIXME: Libav Binary compatibility! JAU01 pAV->bps_video = pAV->pVCodecCtx->bit_rate; } + + // Customize .. + // pAV->pVCodecCtx->thread_count=2; + // pAV->pVCodecCtx->thread_type=FF_THREAD_FRAME|FF_THREAD_SLICE; // Decode more than one frame at once + pAV->pVCodecCtx->thread_count=1; + pAV->pVCodecCtx->thread_type=0; + pAV->pVCodecCtx->workaround_bugs=FF_BUG_AUTODETECT; + pAV->pVCodecCtx->skip_frame=AVDISCARD_DEFAULT; + sp_avcodec_string(pAV->vcodec, sizeof(pAV->vcodec), pAV->pVCodecCtx, 0); // Find the decoder for the video stream @@ -542,8 +610,21 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre pAV->pVCodecCtx->time_base.den=1000; } // FIXME: Libav Binary compatibility! JAU01 - pAV->fps = my_av_q2f(pAV->pVStream->avg_frame_rate); + if( 0 < pAV->pVStream->avg_frame_rate.den ) { + pAV->fps = my_av_q2f(pAV->pVStream->avg_frame_rate); + } else { + pAV->fps = my_av_q2f(pAV->pVStream->r_frame_rate); + } + pAV->frames_video = pAV->pVStream->nb_frames; + if( pAV->verbose ) { + fprintf(stderr, "V frame_size %d, frame_number %d, r_frame_rate %f %d/%d, avg_frame_rate %f %d/%d, nb_frames %d, \n", + pAV->pVCodecCtx->frame_size, pAV->pVCodecCtx->frame_number, + my_av_q2f(pAV->pVStream->r_frame_rate), pAV->pVStream->r_frame_rate.num, pAV->pVStream->r_frame_rate.den, + my_av_q2f(pAV->pVStream->avg_frame_rate), pAV->pVStream->avg_frame_rate.num, pAV->pVStream->avg_frame_rate.den, + pAV->pVStream->nb_frames); + } + // Allocate video frames // FIXME: Libav Binary compatibility! JAU01 pAV->vPixFmt = pAV->pVCodecCtx->pix_fmt; @@ -589,6 +670,14 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setGLFu pAV->procAddrGLGetError = (PFNGLGETERRORPROC) (intptr_t)jProcAddrGLGetError; } +#if 0 +#define DBG_TEXSUBIMG2D_a(c,p,i) fprintf(stderr, "TexSubImage2D.%c offset %d / %d, size %d x %d, ", c, p->pVCodecCtx->width, p->pVCodecCtx->height/2, p->vTexWidth[i], p->pVCodecCtx->height/2) +#define DBG_TEXSUBIMG2D_b(p) fprintf(stderr, "err 0x%X\n", pAV->procAddrGLGetError()) +#else +#define DBG_TEXSUBIMG2D_a(c,p,i) +#define DBG_TEXSUBIMG2D_b(p) +#endif + JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNextPacket0 (JNIEnv *env, jobject instance, jlong ptr, jint texTarget, jint texFmt, jint texType) { @@ -607,11 +696,10 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex } AVFrame* pAFrameCurrent = pAV->pAFrames[pAV->aFrameCurrent]; pAV->aFrameCurrent = ( pAV->aFrameCurrent + 1 ) % pAV->aFrameCount ; - int new_packet = 1; - int len1; + int frameCount; int flush_complete = 0; - while (packet.size > 0 || (!packet.data && new_packet)) { - new_packet = 0; + for ( frameCount=0; 0 < packet.size || 0 == frameCount; frameCount++ ) { + int len1; if (flush_complete) { break; } @@ -640,7 +728,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex continue; } - int data_size = 0; + int32_t data_size = 0; if(HAS_FUNC(sp_av_samples_get_buffer_size)) { data_size = sp_av_samples_get_buffer_size(NULL /* linesize, may be NULL */, pAV->aChannels, @@ -648,16 +736,25 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex pAFrameCurrent->format, 1 /* align */); } - int32_t pts = (int64_t) ( pAFrameCurrent->pkt_pts * (int64_t) 1000 * (int64_t) pAV->pAStream->time_base.num ) - / (int64_t) pAV->pAStream->time_base.den; #if 0 - printf("channels %d sample_rate %d \n", pAV->aChannels , pAV->aSampleRate); - printf("data %d \n", pAV->aFrameSize); + fprintf(stderr, "channels %d sample_rate %d \n", pAV->aChannels , pAV->aSampleRate); + fprintf(stderr, "data %d \n", pAV->aFrameSize); #endif - pAV->aPTS += (int64_t) ( data_size * (int64_t) 1000 ) - / (int64_t) (2 * (int64_t) pAV->aChannels * (int64_t) pAV->aSampleRate); + + const AVRational time_base = pAV->pAStream->time_base; + const int64_t pkt_pts = pAFrameCurrent->pkt_pts; + int aptsMode; + if( 0 == frameCount && AV_NOPTS_VALUE != pkt_pts ) { // 1st frame only, discard invalid PTS .. + pAV->aPTS = (pkt_pts * (int64_t) 1000 * (int64_t) time_base.num) / (int64_t) time_base.den ; + aptsMode = 0; + } else { // subsequent frames or invalid PTS .. + const int32_t bytesPerSample = 2; // av_get_bytes_per_sample( pAV->pACodecCtx->sample_fmt ); + pAV->aPTS += data_size / ( pAV->aChannels * bytesPerSample * ( pAV->aSampleRate / 1000 ) ); + aptsMode = 1; + } if( pAV->verbose ) { - printf("A pts %d - %d\n", pts, pAV->aPTS); + fprintf(stderr, "A pts %d [pkt_pts %ld, pkt_dts %ld], dataSize %d, f# %d, pts-mode %d\n", + pAV->aPTS, pkt_pts, pAFrameCurrent->pkt_dts, data_size, frameCount, aptsMode); } if( NULL != env ) { jobject jSampleData = (*env)->NewDirectByteBuffer(env, pAFrameCurrent->data[0], data_size); @@ -671,19 +768,14 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex sp_av_free_packet(&packet); return 0; } - - int new_packet = 1; - int len1; + int frameCount; int flush_complete = 0; - while (packet.size > 0 || (!packet.data && new_packet)) { - - new_packet = 0; + for ( frameCount=0; 0 < packet.size || 0 == frameCount; frameCount++ ) { + int len1; if (flush_complete) { break; } - len1 = sp_avcodec_decode_video2(pAV->pVCodecCtx, pAV->pVFrame, &frameFinished, &packet); - if (len1 < 0) { // if error, we skip the frame packet.size = 0; @@ -702,71 +794,46 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex // FIXME: Libav Binary compatibility! JAU01 const AVRational time_base = pAV->pVStream->time_base; - const int64_t pts = pAV->pVFrame->pkt_pts; - if(AV_NOPTS_VALUE != pts) { // discard invalid PTS .. - pAV->vPTS = (pts * (int64_t) 1000 * (int64_t) time_base.num) / (int64_t) time_base.den ; - - #if 0 - printf("PTS %d = %ld * ( ( 1000 * %ld ) / %ld ) '1000 * time_base', time_base = %lf\n", - pAV->vPTS, pAV->pVFrame->pkt_pts, time_base.num, time_base.den, (time_base.num/(double)time_base.den)); - #endif + const int64_t pkt_pts = pAV->pVFrame->pkt_pts; + if(AV_NOPTS_VALUE != pkt_pts) { // discard invalid PTS .. + int32_t vPTS2 = (pAV->pVFrame->pkt_dts * (int64_t) 1000 * (int64_t) time_base.num) / (int64_t) time_base.den ; + pAV->vPTS = (pkt_pts * (int64_t) 1000 * (int64_t) time_base.num) / (int64_t) time_base.den ; + if( pAV->verbose ) { + fprintf(stderr, "V pts %d [pkt_pts %ld], pts2 %d [pkt_dts %ld]\n", pAV->vPTS, pkt_pts, vPTS2, pAV->pVFrame->pkt_dts); + } + } else { + if( pAV->verbose ) { + fprintf(stderr, "V pts ?? [pkt_pts %ld], pts2 ?? [pkt_dts %ld]\n", pkt_pts, pAV->pVFrame->pkt_dts); + } } resPTS = pAV->vPTS; // Video Frame! - #if 0 - printf("tex2D codec %dx%d - frame %dx%d - width %d tex / %d linesize, pixfmt 0x%X, texType 0x%x, texTarget 0x%x\n", - pAV->pVCodecCtx->width, pAV->pVCodecCtx->height, - pAV->pVFrame->width, pAV->pVFrame->height, pAV->vTexWidth[0], pAV->pVFrame->linesize[0], - texFmt, texType, texTarget); - #endif - // 1st plane or complete packed frame // FIXME: Libav Binary compatibility! JAU01 - #if 0 - GLenum glerr = pAV->procAddrGLGetError(); - printf("TexSubImage2D.1 texTarget 0x%x, offset %d / %d, size %d x %d, fmt 0x%X, type 0x%X, pre-err 0x%X, ", - texTarget, 0, 0, pAV->vTexWidth[0], pAV->pVCodecCtx->height, texFmt, texType, glerr); - #endif + DBG_TEXSUBIMG2D_a('Y',pAV,0); pAV->procAddrGLTexSubImage2D(texTarget, 0, 0, 0, pAV->vTexWidth[0], pAV->pVCodecCtx->height, texFmt, texType, pAV->pVFrame->data[0]); - #if 0 - glerr = pAV->procAddrGLGetError(); - printf("err 0x%X\n", glerr); - #endif + DBG_TEXSUBIMG2D_b(pAV); if(pAV->vPixFmt == PIX_FMT_YUV420P) { // U plane // FIXME: Libav Binary compatibility! JAU01 - #if 0 - printf("TexSubImage2D.U texTarget 0x%x, offset %d / %d, size %d x %d, fmt 0x%X, type 0x%X, ", - texTarget, pAV->pVCodecCtx->width, 0, pAV->vTexWidth[1], pAV->pVCodecCtx->height/2, - texFmt, texType); - #endif + DBG_TEXSUBIMG2D_a('U',pAV,1); pAV->procAddrGLTexSubImage2D(texTarget, 0, pAV->pVCodecCtx->width, 0, pAV->vTexWidth[1], pAV->pVCodecCtx->height/2, texFmt, texType, pAV->pVFrame->data[1]); - #if 0 - glerr = pAV->procAddrGLGetError(); - printf("err 0x%X\n", glerr); - #endif + DBG_TEXSUBIMG2D_b(pAV); // V plane // FIXME: Libav Binary compatibility! JAU01 - #if 0 - printf("TexSubImage2D.V texTarget 0x%x, offset %d / %d, size %d x %d, fmt 0x%X, type 0x%X, ", - texTarget, pAV->pVCodecCtx->width, pAV->pVCodecCtx->height/2, pAV->vTexWidth[2], pAV->pVCodecCtx->height/2, - texFmt, texType); - #endif + DBG_TEXSUBIMG2D_a('V',pAV,2); pAV->procAddrGLTexSubImage2D(texTarget, 0, pAV->pVCodecCtx->width, pAV->pVCodecCtx->height/2, pAV->vTexWidth[2], pAV->pVCodecCtx->height/2, texFmt, texType, pAV->pVFrame->data[2]); - #if 0 - glerr = pAV->procAddrGLGetError(); - printf("err 0x%X\n", glerr); - #endif + DBG_TEXSUBIMG2D_b(pAV); } // FIXME: Add more planar formats ! } } diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index 3e61e509c..e905bfeab 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -44,6 +44,7 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.av.GLMediaPlayer; import android.os.Bundle; import android.util.Log; @@ -84,7 +85,7 @@ public class MovieCubeActivity0 extends NewtBaseActivity { final Animator animator = new Animator(); // Main - final MovieCube demoMain = new MovieCube(urlConnection0, -2.3f, 0f, 0f); + final MovieCube demoMain = new MovieCube(urlConnection0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, -2.3f, 0f, 0f); final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); glWindowMain.setFullscreen(true); setContentView(getWindow(), glWindowMain); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index bcff3d5bd..7a92360fb 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -45,6 +45,7 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.av.GLMediaPlayer; import android.os.Bundle; import android.util.Log; @@ -84,7 +85,7 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { final Animator animator = new Animator(); // Main - final MovieSimple demoMain = new MovieSimple(urlConnection0); + final MovieSimple demoMain = new MovieSimple(urlConnection0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO); demoMain.setScaleOrig(true); final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); glWindowMain.setFullscreen(true); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index cb0fd0720..d0fb41828 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -111,7 +111,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { final Animator animator = new Animator(); // Main - final MovieSimple demoMain = new MovieSimple(urlConnection0); + final MovieSimple demoMain = new MovieSimple(urlConnection0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO); if(mPlayerHUD) { demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP); demoMain.setTransparency(0.9f); @@ -154,7 +154,7 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { glWindowHUD.addGLEventListener(new MovieSimple(sharedPlayer)); } else { try { - glWindowHUD.addGLEventListener(new MovieSimple(urlConnection1)); + glWindowHUD.addGLEventListener(new MovieSimple(urlConnection1, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO)); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index adccecba0..556d17992 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -332,22 +332,32 @@ public class TextureSequenceCubeES2 implements GLEventListener { } + @Override public void dispose(GLAutoDrawable drawable) { GL2ES2 gl = drawable.getGL().getGL2ES2(); texSeq = null; pmvMatrixUniform = null; - pmvMatrix.destroy(); - pmvMatrix=null; - st.destroy(gl); - st=null; + if( null != pmvMatrix ) { + pmvMatrix.destroy(); + pmvMatrix=null; + } + if( null != st ) { + st.destroy(gl); + st=null; + } } + @Override public void display(GLAutoDrawable drawable) { GL2ES2 gl = drawable.getGL().getGL2ES2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); - + + if( null == st ) { + return; + } + st.useProgram(gl, true); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); @@ -379,9 +389,6 @@ public class TextureSequenceCubeES2 implements GLEventListener { st.useProgram(gl, false); } - public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { - } - static final float[] light_position = { -50.f, 50.f, 50.f, 0.f }; static final float[] light_ambient = { 0.125f, 0.125f, 0.125f, 1.f }; static final float[] light_diffuse = { 1.0f, 1.0f, 1.0f, 1.f }; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 3f979e16f..fbbd77260 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -57,6 +57,7 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureSequenceCubeES2; import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; @@ -67,20 +68,25 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { static boolean waitForKey = false; int textureCount = 3; // default - threaded final URLConnection stream; + final int vid, aid; final float zoom0, rotx, roty; TextureSequenceCubeES2 cube=null; GLMediaPlayer mPlayer=null; public MovieCube() throws IOException { this(new URL("http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4").openConnection(), - -2.3f, 0f, 0f); + GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, -2.3f, 0f, 0f); } - public MovieCube(URLConnection stream, float zoom0, float rotx, float roty) throws IOException { + public MovieCube(URLConnection stream, int vid, int aid, float zoom0, float rotx, float roty) throws IOException { this.stream = stream; this.zoom0 = zoom0; this.rotx = rotx; this.roty = roty; + this.vid = vid; + this.aid = aid; + mPlayer = GLMediaPlayerFactory.createDefault(); + mPlayer.addEventListener(this); } public void setTextureCount(int v) { @@ -89,11 +95,11 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { private final KeyListener keyAction = new KeyAdapter() { public void keyReleased(KeyEvent e) { - if( !e.isPrintableKey() || e.isAutoRepeat() ) { + if( e.isAutoRepeat() ) { return; } System.err.println("MC "+e); - int pts0 = mPlayer.getCurrentPosition(); + int pts0 = mPlayer.getVideoPTS(); int pts1 = 0; switch(e.getKeyCode()) { case KeyEvent.VK_3: @@ -107,21 +113,37 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { case KeyEvent.VK_ESCAPE: case KeyEvent.VK_DELETE: case KeyEvent.VK_BACK_SPACE: { - mPlayer.seek(0); mPlayer.setPlaySpeed(1.0f); - mPlayer.start(); + mPlayer.seek(0); + mPlayer.play(); break; } case KeyEvent.VK_SPACE: { if(GLMediaPlayer.State.Paused == mPlayer.getState()) { - mPlayer.start(); + mPlayer.play(); } else { mPlayer.pause(); } break; } - case KeyEvent.VK_S: mPlayer.setPlaySpeed(mPlayer.getPlaySpeed()/2.0f); break; - case KeyEvent.VK_F: mPlayer.setPlaySpeed(mPlayer.getPlaySpeed()*2.0f); break; + case KeyEvent.VK_SUBTRACT: { + float playSpeed = mPlayer.getPlaySpeed(); + if( e.isShiftDown() ) { + playSpeed /= 2.0f; + } else { + playSpeed -= 0.1f; + } + mPlayer.setPlaySpeed(playSpeed); + } break; + case KeyEvent.VK_ADD: { + float playSpeed = mPlayer.getPlaySpeed(); + if( e.isShiftDown() ) { + playSpeed *= 2.0f; + } else { + playSpeed += 0.1f; + } + mPlayer.setPlaySpeed(playSpeed); + } break; } if( 0 != pts1 ) { @@ -140,25 +162,18 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { // System.out.println("newFrameAvailable: "+mp+", when "+when); } + @Override public void init(GLAutoDrawable drawable) { GL2ES2 gl = drawable.getGL().getGL2ES2(); System.err.println(JoglVersion.getGLInfo(gl, null)); - mPlayer = GLMediaPlayerFactory.createDefault(); - mPlayer.addEventListener(this); cube = new TextureSequenceCubeES2(mPlayer, false, zoom0, rotx, roty); if(waitForKey) { - BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); - System.err.println("Press enter to continue"); - try { - System.err.println(stdin.readLine()); - } catch (IOException e) { } + UITestCase.waitForKey("Init>"); } try { - System.out.println("p0 "+mPlayer); - mPlayer.initGLStream(gl, textureCount, stream); - System.out.println("p1 "+mPlayer); + mPlayer.initGLStream(gl, textureCount, stream, vid, aid); } catch (Exception e) { e.printStackTrace(); if(null != mPlayer) { @@ -169,7 +184,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } cube.init(drawable); - mPlayer.start(); + mPlayer.play(); boolean added; final Object upstreamWidget = drawable.getUpstreamWidget(); @@ -181,30 +196,38 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { System.err.println("MC.init: kl-added "+added+", "+drawable.getClass().getName()); } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { if(null == mPlayer) { return; } cube.reshape(drawable, x, y, width, height); } + @Override public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" MovieCube.dispose ... "); if(null == mPlayer) { return; } - mPlayer.stop(); - GL2ES2 gl = drawable.getGL().getGL2ES2(); + final GL2ES2 gl = drawable.getGL().getGL2ES2(); mPlayer.destroy(gl); mPlayer=null; cube.dispose(drawable); cube=null; } + long lastPerfPos = 0; + + @Override public void display(GLAutoDrawable drawable) { if(null == mPlayer) { return; } + + final long currentPos = System.currentTimeMillis(); + if( currentPos - lastPerfPos > 2000 ) { + System.err.println( mPlayer.getPerfString() ); + lastPerfPos = currentPos; + } + cube.display(drawable); } - public void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { - } - public static void main(String[] args) throws MalformedURLException, IOException, InterruptedException { int width = 510; int height = 300; @@ -214,40 +237,56 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { boolean forceES3 = false; boolean forceGL3 = false; boolean forceGLDef = false; + int vid = GLMediaPlayer.STREAM_ID_AUTO; + int aid = GLMediaPlayer.STREAM_ID_AUTO; + final boolean origSize; - String url_s="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"; - for(int i=0; iwinHeight/2) { final float dp = (float)(x-prevMouseX)/(float)winWidth; - mPlayer.seek(mPlayer.getCurrentPosition() + (int) (mPlayer.getDuration() * dp)); + mPlayer.seek(mPlayer.getVideoPTS() + (int) (mPlayer.getDuration() * dp)); } else { - mPlayer.start(); + mPlayer.play(); rotate = 1; zoom = zoom1; } @@ -149,13 +155,74 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { } }; - public MovieSimple(URLConnection stream) throws IOException { + private final KeyListener keyAction = new KeyAdapter() { + public void keyReleased(KeyEvent e) { + if( e.isAutoRepeat() ) { + return; + } + System.err.println("MC "+e); + int pts0 = mPlayer.getVideoPTS(); + int pts1 = 0; + switch(e.getKeyCode()) { + case KeyEvent.VK_3: + case KeyEvent.VK_RIGHT: pts1 = pts0 + 1000; break; + case KeyEvent.VK_4: + case KeyEvent.VK_UP: pts1 = pts0 + 10000; break; + case KeyEvent.VK_2: + case KeyEvent.VK_LEFT: pts1 = pts0 - 1000; break; + case KeyEvent.VK_1: + case KeyEvent.VK_DOWN: pts1 = pts0 - 10000; break; + case KeyEvent.VK_ESCAPE: + case KeyEvent.VK_DELETE: + case KeyEvent.VK_BACK_SPACE: { + mPlayer.setPlaySpeed(1.0f); + mPlayer.seek(0); + mPlayer.play(); + break; + } + case KeyEvent.VK_SPACE: { + if(GLMediaPlayer.State.Paused == mPlayer.getState()) { + mPlayer.play(); + } else { + mPlayer.pause(); + } + break; + } + case KeyEvent.VK_SUBTRACT: { + float playSpeed = mPlayer.getPlaySpeed(); + if( e.isShiftDown() ) { + playSpeed /= 2.0f; + } else { + playSpeed -= 0.1f; + } + mPlayer.setPlaySpeed(playSpeed); + } break; + case KeyEvent.VK_ADD: { + float playSpeed = mPlayer.getPlaySpeed(); + if( e.isShiftDown() ) { + playSpeed *= 2.0f; + } else { + playSpeed += 0.1f; + } + mPlayer.setPlaySpeed(playSpeed); + } break; + } + + if( 0 != pts1 ) { + mPlayer.seek(pts1); + } + } + }; + + public MovieSimple(URLConnection stream, int vid, int aid) throws IOException { mPlayerScaleOrig = false; mPlayerShared = false; mPlayerExternal = false; mPlayer = GLMediaPlayerFactory.createDefault(); mPlayer.addEventListener(this); this.stream = stream; + this.vid = vid; + this.aid = aid; System.out.println("pC.1 "+mPlayer); } @@ -166,6 +233,8 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { mPlayer = sharedMediaPlayer; mPlayer.addEventListener(this); this.stream = null; + this.vid = sharedMediaPlayer.getVID(); + this.aid = sharedMediaPlayer.getAID(); System.out.println("pC.2 shared "+mPlayerShared+", "+mPlayer); } @@ -188,20 +257,13 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { // System.out.println("newFrameAvailable: "+mp+", when "+when); } - public void start() { + public void play() { if(null!=mPlayer) { - mPlayer.start(); + mPlayer.play(); System.out.println("pStart "+mPlayer); } } - public void stop() { - if(null!=mPlayer) { - mPlayer.stop(); - System.out.println("pStop "+mPlayer); - } - } - ShaderState st; PMVMatrix pmvMatrix; GLUniformData pmvMatrixUniform; @@ -242,6 +304,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { st.attachShaderProgram(gl, sp, false); } + @Override public void init(GLAutoDrawable drawable) { zoom0 = orthoProjection ? 0f : -2.5f; zoom1 = orthoProjection ? 0f : -5f; @@ -252,12 +315,15 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { System.err.println("Alpha: "+alpha+", opaque "+drawable.getChosenGLCapabilities().isBackgroundOpaque()+ ", "+drawable.getClass().getName()+", "+drawable); + if(waitForKey) { + UITestCase.waitForKey("Init>"); + } final Texture tex; boolean useExternalTexture = false; try { System.out.println("p0 "+mPlayer+", shared "+mPlayerShared); if(!mPlayerShared) { - mPlayer.initGLStream(gl, textureCount, stream); + mPlayer.initGLStream(gl, textureCount, stream, vid, aid); } tex = mPlayer.getLastTexture().getTexture(); System.out.println("p1 "+mPlayer+", shared "+mPlayerShared); @@ -392,7 +458,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { System.out.println(st); if(null!=mPlayer) { - start(); + play(); System.out.println("p2 "+mPlayer); } @@ -402,11 +468,13 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.addMouseListener(mouseAction); + window.addKeyListener(keyAction); winWidth = window.getWidth(); winHeight = window.getHeight(); } } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { if(null == mPlayer) { return; } winWidth = width; @@ -442,34 +510,51 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { pmvMatrix.glTranslatef(0, 0, zoom0); } + @Override public void dispose(GLAutoDrawable drawable) { if(null == mPlayer) { return; } - stop(); - System.out.println("pD.1 "+mPlayer); - + System.out.println("pD.1 "+mPlayer); GL2ES2 gl = drawable.getGL().getGL2ES2(); - - mPlayer.removeEventListener(this); - if(!mPlayerExternal) { - mPlayer.destroy(gl); + if( null != mPlayer ) { + mPlayer.removeEventListener(this); + if(!mPlayerExternal) { + mPlayer.destroy(gl); + } } System.out.println("pD.X "+mPlayer); mPlayer=null; pmvMatrixUniform = null; - pmvMatrix.destroy(); - pmvMatrix=null; - st.destroy(gl); - st=null; + if(null != pmvMatrix) { + pmvMatrix.destroy(); + pmvMatrix=null; + } + if(null != st) { + st.destroy(gl); + st=null; + } } + long lastPerfPos = 0; + + @Override public void display(GLAutoDrawable drawable) { if(null == mPlayer) { return; } + final long currentPos = System.currentTimeMillis(); + if( currentPos - lastPerfPos > 2000 ) { + System.err.println( mPlayer.getPerfString() ); + lastPerfPos = currentPos; + } + GL2ES2 gl = drawable.getGL().getGL2ES2(); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + if(null == st) { + return; + } + st.useProgram(gl, true); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); @@ -506,9 +591,6 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { st.useProgram(gl, false); } - public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { - } - public static void main(String[] args) throws IOException, MalformedURLException { int width = 640; int height = 600; @@ -520,42 +602,60 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { boolean forceES3 = false; boolean forceGL3 = false; boolean forceGLDef = false; + int vid = GLMediaPlayer.STREAM_ID_AUTO; + int aid = GLMediaPlayer.STREAM_ID_AUTO; + final boolean origSize; - String url_s="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"; - for(int i=0; i Date: Fri, 16 Aug 2013 20:18:36 +0200 Subject: GLMediaPlayer Multithreaded Decoding: GLMediaPlayer* (Part-4) - WIP - Use Platform.currentTimeMillis() for accurate timing! - GLMediaPlayer / GLMediaPlayerImpl - Add DEBUG_NATIVE property jogl.debug.GLMediaPlayer.Native for verbose impl. messages, i.e. ffmpeg/libav - Add 'synchronization' section in GLMediaPlayer API doc (WIP) - Use passive non-blocking video synchronization, i.e. repeat frames instead of 'sleep'. Thx to Xerxes's suggestion. - Add flushing of cached decoded frames, allowing to remove complicated 'videoSCR_reset_latch' - FramePusher (threaded decoding): - Always create a shared context! - Release context while pausing - Pre/post 'getNextTextureImpl()' actions only at makeCurrent/release. - newFrameAvailable(..) signal after decoded frame is enqueued - FFMPEGDynamicLibraryBundleInfo - Bind add. functions of libavcodec: + "av_init_packet", + "av_new_packet", + "av_destruct_packet", - Bind add. functions of libavformat: + "avformat_seek_file", + "av_read_play", + "av_read_pause", - DEBUG property := FFMPEGMediaPlayer.DEBUG || DynamicLibraryBundleInfo.DEBUG; - FFMPEGMediaPlayer - Use libavformat's 'av_read_play()' and 'av_read_pause()', which may get utilized for network streams, e.g. RTSP - getNextTextureImpl(..): - Fix retry loop - Use postNextTextureImpl/preNextTextureImpl if desired (PSM) - Native: - Use fixed my_av_q2i32(..) macro (again) - Use INVALID_PTS marker (synced w/ Java code) - DEBUG: Dump more detailed frame information - TODO: Consider passing frame_delay, especially for repeated frames! - Tests (MovieSimple, MovieCube): - Refine KeyEvents control for seek and speed. - TODO: - Proper audio clock calculation - difficult w/ OpenAL ! - Video / Audio sync: - seek ! - streams w/ very async A/V frames - Test Streams: - Five-minute-sync-test.mp4 - Audio-Video-Sync-Test-Calibration-23.98fps-24fps.mp4 - sound_in_sync_test.mp4 - big_buck_bunny_1080p_surround.avi --- make/scripts/tests.sh | 6 +- .../com/jogamp/opengl/util/av/AudioSink.java | 3 + .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 51 ++- .../opengl/util/texture/TextureSequence.java | 14 +- .../android/av/AndroidGLMediaPlayerAPI14.java | 2 +- .../jogamp/opengl/openal/av/ALAudioSink.java | 18 +- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 354 ++++++++++----------- .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 9 +- .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 22 +- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 59 ++-- .../opengl/util/av/impl/OMXGLMediaPlayer.java | 2 +- src/jogl/native/libav/ffmpeg_tool.h | 7 +- .../jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c | 114 +++++-- .../test/junit/jogl/demos/es2/av/MovieCube.java | 15 +- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 13 +- 15 files changed, 411 insertions(+), 278 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 82e9fb92b..7aac0ca33 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -131,8 +131,9 @@ function jrun() { #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" - #D_ARGS="-Djogl.debug.GLMediaPlayer" - #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" + D_ARGS="-Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" + #D_ARGS="-Djogl.debug.GLMediaPlayer.Native -Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" #D_ARGS="-Djogl.debug.GLDrawable" @@ -564,6 +565,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestTextureSequence01AWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestBug817GLReadBufferUtilGLCTXDefFormatTypeES2NEWT $* # diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java index ba785ac31..d5db73c6b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/AudioSink.java @@ -71,6 +71,9 @@ public interface AudioSink { public static final AudioDataFormat DefaultFormat = new AudioDataFormat(AudioDataType.PCM, 44100, 16, 2, true /* signed */, true /* fixed point */, true /* littleEndian */); public static class AudioFrame { + /** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE 0x80000000 {@value}. */ + public static final int INVALID_PTS = 0x80000000 ; // == -2147483648 == Integer.MIN_VALUE; + public final ByteBuffer data; public final int dataSize; public final int pts; diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index fae88ea18..1b82bb994 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -34,7 +34,6 @@ import javax.media.opengl.GL; import javax.media.opengl.GLException; import jogamp.opengl.Debug; -import jogamp.opengl.util.av.GLMediaPlayerImpl; import com.jogamp.opengl.util.texture.TextureSequence; @@ -44,7 +43,8 @@ import com.jogamp.opengl.util.texture.TextureSequence; *

      * Audio maybe supported and played back internally or via an {@link AudioSink} implementation, * if an audio stream is selected in {@link #initGLStream(GL, int, URLConnection, int, int)}. - *

      + *

      + * *
      GLMediaPlayer Lifecycle
      *

      * @@ -56,6 +56,7 @@ import com.jogamp.opengl.util.texture.TextureSequence; * *
      {@link #destroy(GL)} ANY Uninitialized
      *

      + * *
      Audio and video Stream IDs
      *

      * @@ -91,14 +92,47 @@ import com.jogamp.opengl.util.texture.TextureSequence; * Milliseconds granularity is also more than enough to deal with A-V synchronization, * where the threshold usually lies within 100ms. *

      + * + *
      Audio and video synchronization
      + *

      + * The class follows a passive A/V synchronization pattern. + * Audio is being untouched, while {@link #getNextTexture(GL, boolean)} delivers a new video frame + * only, if its timestamp is less than 22ms ahead of time. + * Otherwise the early frame is cached for later retrieval and the previous frame is returned. + * FIXME: Refine! + *

      + *

      + * https://en.wikipedia.org/wiki/Audio_to_video_synchronization + *

      + *   d_av = v_pts - a_pts;
      + * 
      + *

      + *

      + * Recommendation of audio/video pts time lead/lag at production: + *

        + *
      • Overall: +40ms and -60ms audio ahead video / audio after video
      • + *
      • Each stage: +5ms and -15ms. audio ahead video / audio after video
      • + *
      + *

      + *

      + * Recommendation of av pts time lead/lag at presentation: + *

        + *
      • TV: +15ms and -45ms. audio ahead video / audio after video.
      • + *
      • Film: +22ms and -22ms. audio ahead video / audio after video.
      • + *
      + *

      */ public interface GLMediaPlayer extends TextureSequence { public static final boolean DEBUG = Debug.debug("GLMediaPlayer"); + public static final boolean DEBUG_NATIVE = Debug.debug("GLMediaPlayer.Native"); /** Constant {@value} for mute or not available. See Audio and video Stream IDs. */ public static final int STREAM_ID_NONE = -2; /** Constant {@value} for auto or unspecified. See Audio and video Stream IDs. */ public static final int STREAM_ID_AUTO = -1; + + /** Maximum video frame async .. */ + public static final int MAXIMUM_VIDEO_ASYNC = 22; public interface GLMediaEventListener extends TexSeqEventListener { @@ -228,13 +262,14 @@ public interface GLMediaPlayer extends TextureSequence { public int getAID(); /** - * @return the current decoded frame count since {@link #initGLStream(GL, int, URLConnection, int, int)}. + * @return the current decoded frame count since {@link #play()} and {@link #seek(int)} + * as increased by {@link #getNextTexture(GL, boolean)} or the decoding thread. */ public int getDecodedFrameCount(); /** - * @return the current presented frame count since {@link #initGLStream(GL, int, URLConnection, int, int)}, - * increased by {@link #getNextTexture(GL, boolean)}. + * @return the current presented frame count since {@link #play()} and {@link #seek(int)} + * as increased by {@link #getNextTexture(GL, boolean)} for new frames. */ public int getPresentedFrameCount(); @@ -250,6 +285,9 @@ public interface GLMediaPlayer extends TextureSequence { /** * {@inheritDoc} + *

      + * See audio and video synchronization. + *

      */ @Override public TextureSequence.TextureFrame getLastTexture() throws IllegalStateException; @@ -260,6 +298,9 @@ public interface GLMediaPlayer extends TextureSequence { *

      * In case the current state is not {@link State#Playing}, {@link #getLastTexture()} is returned. *

      + *

      + * See audio and video synchronization. + *

      * * @see #addEventListener(GLMediaEventListener) * @see GLMediaEventListener#newFrameAvailable(GLMediaPlayer, TextureFrame, long) diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index 50801e791..05fda99ae 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -110,23 +110,31 @@ public interface TextureSequence { * to associated related data. */ public static class TextureFrame { - /** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE {@value}. */ - public static final int INVALID_PTS = Integer.MIN_VALUE; + /** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE 0x80000000 {@value}. */ + public static final int INVALID_PTS = 0x80000000 ; // == -2147483648 == Integer.MIN_VALUE; public TextureFrame(Texture t) { texture = t; pts = INVALID_PTS; + duration = 0; } public final Texture getTexture() { return texture; } + /** Get this frame's presentation timestamp (PTS) in milliseconds. */ public final int getPTS() { return pts; } + /** Set this frame's presentation timestamp (PTS) in milliseconds. */ public final void setPTS(int pts) { this.pts = pts; } + /** Get this frame's duration in milliseconds. */ + public final int getDuration() { return duration; } + /** Set this frame's duration in milliseconds. */ + public final void setDuration(int duration) { this.duration = duration; } public String toString() { - return "TextureFrame[" + pts + "ms: " + texture + "]"; + return "TextureFrame[pts " + pts + " ms, l " + duration + " ms, "+ texture + "]"; } protected final Texture texture; protected int pts; + protected int duration; } public interface TexSeqEventListener { diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index e14642c34..86e6bc121 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -222,7 +222,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking) { + protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost) { if(null != stex && null != mp) { final SurfaceTextureFrame nextSFrame = (SurfaceTextureFrame) nextFrame; final Surface nextSurface = nextSFrame.getSurface(); diff --git a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java index 5783c32f1..217ab2954 100644 --- a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java @@ -80,7 +80,7 @@ public class ALAudioSink implements AudioSink { private SyncedRingbuffer alBufferAvail = null; private SyncedRingbuffer alBufferPlaying = null; private volatile int alBufferBytesQueued = 0; - private volatile int ptsPlaying = 0; + private volatile int playingPTS = AudioFrame.INVALID_PTS; private volatile int enqueuedFrameCount; private int[] alSource = null; @@ -207,11 +207,11 @@ public class ALAudioSink implements AudioSink { return "ALAudioSink[init "+initialized+", playRequested "+playRequested+", device "+deviceSpecifier+", ctx "+toHexString(ctxHash)+", alSource "+alSrcName+ ", chosen "+chosenFormat+", alFormat "+toHexString(alFormat)+ ", playSpeed "+playSpeed+", buffers[total "+alBuffersLen+", avail "+alBufferAvail.size()+", "+ - "queued["+alBufferPlaying.size()+", apts "+ptsPlaying+", "+getQueuedTime() + " ms, " + alBufferBytesQueued+" bytes]"; + "queued["+alBufferPlaying.size()+", apts "+getPTS()+", "+getQueuedTime() + " ms, " + alBufferBytesQueued+" bytes]"; } public final String getPerfString() { final int alBuffersLen = null != alBuffers ? alBuffers.length : 0; - return "Play [buffer "+alBufferPlaying.size()+"/"+alBuffersLen+", apts "+ptsPlaying+", "+getQueuedTime() + " ms, " + alBufferBytesQueued+" bytes]"; + return "Play [buffer "+alBufferPlaying.size()+"/"+alBuffersLen+", apts "+getPTS()+", "+getQueuedTime() + " ms, " + alBufferBytesQueued+" bytes]"; } @Override @@ -289,9 +289,9 @@ public class ALAudioSink implements AudioSink { t.printStackTrace(); } } - alBufferAvail.clear(true); + alBufferAvail.clear(); alBufferAvail = null; - alBufferPlaying.clear(true); + alBufferPlaying.clear(); alBufferPlaying = null; alBufferBytesQueued = 0; alBuffers = null; @@ -434,7 +434,11 @@ public class ALAudioSink implements AudioSink { } final int dequeuedBufferCount = dequeueBuffer( false /* all */, wait ); final ActiveBuffer currentBuffer = alBufferPlaying.peek(); - ptsPlaying = null != currentBuffer ? currentBuffer.pts : audioFrame.pts; + if( null != currentBuffer ) { + playingPTS = currentBuffer.pts; + } else { + playingPTS = audioFrame.pts; + } if( DEBUG ) { System.err.println(getThreadName()+": ALAudioSink: Write "+audioFrame.pts+", "+getQueuedTimeImpl(audioFrame.dataSize)+" ms, dequeued "+dequeuedBufferCount+", wait "+wait+", "+getPerfString()); } @@ -652,5 +656,5 @@ public class ALAudioSink implements AudioSink { } @Override - public final int getPTS() { return ptsPlaying; } + public final int getPTS() { return playingPTS; } } diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index c1cfc0d95..85b599c0e 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -42,7 +42,9 @@ import javax.media.opengl.GLES2; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import com.jogamp.common.os.Platform; import com.jogamp.opengl.util.av.AudioSink; +import com.jogamp.opengl.util.av.AudioSink.AudioFrame; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; @@ -92,9 +94,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected int width = 0; /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected int height = 0; - /** Video fps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Video avg. fps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected float fps = 0; - protected int frame_period = 0; + /** Video avg. frame duration in ms. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + protected float frame_duration = 0f; /** Stream bps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ protected int bps_stream = 0; /** Video bps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ @@ -114,6 +117,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected volatile int decodedFrameCount = 0; protected int presentedFrameCount = 0; + protected int displayedFrameCount = 0; protected volatile int video_pts_last = 0; /** See {@link #getAudioSink()}. Set by implementation if used from within {@link #initGLStreamImpl(GL, int, int)}! */ @@ -139,17 +143,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { /** Maximum valid video pts diff. */ private static final int VIDEO_DPTS_MAX = 5000; // 5s max diff /** Trigger video PTS reset with given cause as bitfield. */ - private volatile int videoSCR_reset = 0; + private boolean videoSCR_reset = false; - private final boolean isSCRCause(int bit) { return 0 != ( bit & videoSCR_reset); } - /** SCR reset due to: Start, Resume, Seek, .. */ - private static final int SCR_RESET_FORCE = 1 << 0; - /** SCR reset due to: PlaySpeed */ - private static final int SCR_RESET_SPEED = 1 << 1; - - /** Latched video PTS reset, to wait until valid pts after invalidation of cached ones. Currently [1..{@link #VIDEO_DPTS_NUM}] frames. */ - private int videoSCR_reset_latch = 0; - protected SyncedRingbuffer videoFramesFree = null; protected SyncedRingbuffer videoFramesDecoded = null; protected volatile TextureFrame lastFrame = null; @@ -279,16 +274,17 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { switch( state ) { case Paused: if( playImpl() ) { - resetAudioVideoSCR(SCR_RESET_FORCE); - resumeFramePusher(); + // FIXME + resetAudioVideoPTS(); if( null != audioSink ) { - audioSink.play(); - } + audioSink.play(); // cont. w/ new data + } + resumeFramePusher(); state = State.Playing; } default: } - if(DEBUG) { System.err.println("Start: "+toString()); } + if(DEBUG) { System.err.println("Play: "+toString()); } return state; } } @@ -297,16 +293,15 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final State pause() { synchronized( stateLock ) { if( State.Playing == state ) { - State _state = state; state = State.Paused; - if( pauseImpl() ) { - _state = State.Paused; - pauseFramePusher(); - if( null != audioSink ) { - audioSink.pause(); - } + // FIXME + pauseFramePusher(); + if( null != audioSink ) { + audioSink.pause(); + } + if( !pauseImpl() ) { + play(); } - state = _state; } if(DEBUG) { System.err.println("Pause: "+toString()); } return state; @@ -322,14 +317,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { case Paused: final State _state = state; state = State.Paused; + // FIXME pauseFramePusher(); - resetAudioVideoSCR(SCR_RESET_FORCE); pts1 = seekImpl(msec); - if( null != audioSink ) { - audioSink.flush(); - if( State.Playing == _state ) { - audioSink.play(); // cont. w/ new data - } + resetAllAudioVideoSync(); + if( null != audioSink && State.Playing == _state ) { + audioSink.play(); // cont. w/ new data } resumeFramePusher(); state = _state; @@ -358,7 +351,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { rate = 1.0f; } if( setPlaySpeedImpl(rate) ) { - resetAudioVideoSCR(SCR_RESET_SPEED); + resetAudioVideoPTS(); playSpeed = rate; if(DEBUG) { System.err.println("SetPlaySpeed: "+toString()); } res = true; @@ -392,6 +385,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } decodedFrameCount = 0; presentedFrameCount = 0; + displayedFrameCount = 0; this.urlConn = urlConn; if (this.urlConn != null) { try { @@ -405,7 +399,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { videoFramesFree = new SyncedRingbuffer(createTexFrames(gl, textureCount), true /* full */); if( TEXTURE_COUNT_DEFAULT < textureCount ) { videoFramesDecoded = new SyncedRingbuffer(new TextureFrame[textureCount], false /* full */); - framePusher = new FramePusher(gl, requiresOffthreadGLCtx()); + framePusher = new FramePusher(gl); framePusher.doStart(); } else { videoFramesDecoded = null; @@ -448,7 +442,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected int validateTextureCount(int desiredTextureCount) { return TEXTURE_COUNT_DEFAULT; } - protected boolean requiresOffthreadGLCtx() { return false; } private final TextureFrame[] createTexFrames(GL gl, final int count) { final int[] texNames = new int[count]; @@ -543,6 +536,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { textureCount=0; } + protected TextureFrame cachedFrame = null; + protected long lastTimeMillis = 0; + @Override public final TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException { synchronized( stateLock ) { @@ -554,68 +550,95 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { boolean ok = true; boolean dropFrame = false; try { - do { - if( TEXTURE_COUNT_DEFAULT < textureCount ) { + do { + final long currentTimeMillis; + final boolean playCached = null != cachedFrame; + if( dropFrame ) { + presentedFrameCount--; + dropFrame = false; + } + if( playCached ) { + nextFrame = cachedFrame; + cachedFrame = null; + presentedFrameCount--; + currentTimeMillis = Platform.currentTimeMillis(); + } else if( TEXTURE_COUNT_DEFAULT < textureCount ) { nextFrame = videoFramesDecoded.getBlocking(false /* clearRef */ ); + currentTimeMillis = Platform.currentTimeMillis(); } else { nextFrame = videoFramesFree.getBlocking(false /* clearRef */ ); - if( getNextTextureImpl(gl, nextFrame, blocking) ) { - newFrameAvailable(nextFrame); - } else { - ok = false; + nextFrame.setPTS( TextureFrame.INVALID_PTS ); // mark invalid until processed! + ok = getNextTextureImpl(gl, nextFrame, blocking, true /* issuePreAndPost */); + currentTimeMillis = Platform.currentTimeMillis(); + if( ok ) { + newFrameAvailable(nextFrame, currentTimeMillis); } } + if( DEBUG ) { + System.err.println("> "+currentTimeMillis+", d "+(currentTimeMillis-lastTimeMillis)+", playCached "+playCached); + } if( ok ) { presentedFrameCount++; - final int video_pts; - if( 0 != videoSCR_reset ) { - if( isSCRCause(SCR_RESET_FORCE) ) { - videoSCR_reset_latch = VIDEO_DPTS_NUM / 2; - resetVideoDPTS(); - resetAllVideoPTS(); + final int video_pts = nextFrame.getPTS(); + if( video_pts != TextureFrame.INVALID_PTS ) { + lastTimeMillis = currentTimeMillis; + + final int audio_pts = getAudioPTSImpl(); + final int audio_scr = (int) ( ( currentTimeMillis - audio_scr_t0 ) * playSpeed ); + final int d_apts; + if( audio_pts != AudioFrame.INVALID_PTS ) { + d_apts = audio_pts - audio_scr; } else { - // SCR_RESET_SPEED - videoSCR_reset_latch = 1; + d_apts = 0; } - videoSCR_reset = 0; - video_pts = TextureFrame.INVALID_PTS; - } else { - video_pts = nextFrame.getPTS(); - } - if( video_pts != TextureFrame.INVALID_PTS ) { + final int frame_period_last = video_pts - video_pts_last; // rendering loop interrupted ? - if( videoSCR_reset_latch > 0 || frame_period_last > frame_period*10 ) { - if( videoSCR_reset_latch > 0 ) { - videoSCR_reset_latch--; - } - setFirstVideoPTS2SCR( video_pts ); + if( videoSCR_reset || frame_period_last > frame_duration*10 ) { + videoSCR_reset = false; + video_scr_t0 = currentTimeMillis; + video_scr_pts = video_pts; } - final int scr_pts = video_scr_pts + - (int) ( ( System.currentTimeMillis() - video_scr_t0 ) * playSpeed ); - final int d_vpts = video_pts - scr_pts; + final int video_scr = video_scr_pts + (int) ( ( currentTimeMillis - video_scr_t0 ) * playSpeed ); + final int d_vpts = video_pts - video_scr; + // final int d_avpts = d_vpts - d_apts; if( -VIDEO_DPTS_MAX > d_vpts || d_vpts > VIDEO_DPTS_MAX ) { + // if( -VIDEO_DPTS_MAX > d_avpts || d_avpts > VIDEO_DPTS_MAX ) { if( DEBUG ) { - System.err.println( getPerfStringImpl( scr_pts, video_pts, d_vpts, 0 ) ); + System.err.println( "AV*: "+getPerfStringImpl( video_scr, video_pts, d_vpts, audio_scr, audio_pts, d_apts, 0 ) + ", "+nextFrame+", playCached " + playCached+ ", dropFrame "+dropFrame); } } else { + final int dpy_den = displayedFrameCount > 0 ? displayedFrameCount : 1; + final int avg_dpy_duration = ( (int) ( currentTimeMillis - video_scr_t0 ) ) / dpy_den ; // ms/f + final int maxVideoDelay = Math.min(avg_dpy_duration, MAXIMUM_VIDEO_ASYNC); video_dpts_count++; + // video_dpts_cum = d_avpts + VIDEO_DPTS_COEFF * video_dpts_cum; video_dpts_cum = d_vpts + VIDEO_DPTS_COEFF * video_dpts_cum; - final int video_dpts_avg_diff = getVideoDPTSAvg(); - if( DEBUG ) { - System.err.println( getPerfStringImpl( scr_pts, video_pts, d_vpts, video_dpts_avg_diff ) ); - } - if( blocking && syncAVRequired() ) { - if( !syncAV( (int) ( video_dpts_avg_diff / playSpeed + 0.5f ) ) ) { - resetVideoDPTS(); - dropFrame = true; - } + final int video_dpts_avg_diff = video_dpts_count >= VIDEO_DPTS_NUM ? getVideoDPTSAvg() : 0; + final int dt = (int) ( video_dpts_avg_diff / playSpeed + 0.5f ); + // final int dt = (int) ( d_vpts / playSpeed + 0.5f ); + // final int dt = (int) ( d_avpts / playSpeed + 0.5f ); + if( dt > maxVideoDelay ) { + cachedFrame = nextFrame; + nextFrame = null; + } else if ( dt < -maxVideoDelay ) { + dropFrame = true; } video_pts_last = video_pts; + if( DEBUG ) { + System.err.println( "AV_: "+getPerfStringImpl( video_scr, video_pts, d_vpts, + audio_scr, audio_pts, d_apts, + video_dpts_avg_diff ) + + ", avg dpy-fps "+avg_dpy_duration+" ms/f, maxD "+maxVideoDelay+" ms, "+nextFrame+", playCached " + playCached + ", dropFrame "+dropFrame); + } } + } else if( DEBUG ) { + System.err.println("Invalid PTS: "+nextFrame); + } + if( null != nextFrame ) { + final TextureFrame _lastFrame = lastFrame; + lastFrame = nextFrame; + videoFramesFree.putBlocking(_lastFrame); } - final TextureFrame _lastFrame = lastFrame; - lastFrame = nextFrame; - videoFramesFree.putBlocking(_lastFrame); } } while( dropFrame ); } catch (InterruptedException e) { @@ -623,14 +646,19 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { e.printStackTrace(); } finally { if( !ok && null != nextFrame ) { // put back - videoFramesFree.put(nextFrame); + if( !videoFramesFree.put(nextFrame) ) { + throw new InternalError("XXX: free "+videoFramesFree+", decoded "+videoFramesDecoded+", "+GLMediaPlayerImpl.this); + } } } } + displayedFrameCount++; return lastFrame; } } - protected abstract boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking); + protected void preNextTextureImpl(GL gl) {} + protected void postNextTextureImpl(GL gl) {} + protected abstract boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost); protected boolean syncAVRequired() { return false; } /** @@ -654,95 +682,49 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { */ protected void setFirstAudioPTS2SCR(int pts) { if( audioSCR_reset ) { - audio_scr_t0 = System.currentTimeMillis() - pts; + audio_scr_t0 = Platform.currentTimeMillis() - pts; audioSCR_reset = false; } } - private void setFirstVideoPTS2SCR(int pts) { - // video_scr_t0 = System.currentTimeMillis() - pts; - video_scr_t0 = System.currentTimeMillis(); - video_scr_pts = pts; - } - private void resetAllVideoPTS() { + private void flushAllVideoFrames() { if( null != videoFramesFree ) { - final TextureFrame[] texFrames = videoFramesFree.getArray(); - for(int i=0; i - * https://en.wikipedia.org/wiki/Audio_to_video_synchronization - *
      -     *   d_av = v_pts - a_pts;
      -     * 
      - *

      - *

      - * Recommendation of audio/video pts time lead/lag at production: - *

        - *
      • Overall: +40ms and -60ms audio ahead video / audio after video
      • - *
      • Each stage: +5ms and -15ms. audio ahead video / audio after video
      • - *
      - *

      - *

      - * Recommendation of av pts time lead/lag at presentation: - *

        - *
      • TV: +15ms and -45ms. audio ahead video / audio after video.
      • - *
      • Film: +22ms and -22ms. audio ahead video / audio after video.
      • - *
      - *

      - *

      - * Maybe implemented as follows: - *

      -     *   d_av = vpts - apts;
      -     *   d_av < -22: audio after video == video ahead audio -> drop
      -     *   d_av >  22: audio ahead video == video after audio -> sleep(d_av - 10) 
      -     * 
      - *

      - *

      - * Returns true if audio is ahead of video, otherwise false (video is ahead of audio). - * In case of the latter (false), the video frame shall be dropped! - *

      - * @param frame - * @return true if audio is ahead of video, otherwise false (video is ahead of audio) - */ - protected boolean syncAV(int d_vpts) { - if( d_vpts > 22 ) { - if( DEBUG ) { - System.err.println("V (sleep): "+(d_vpts - 22 / 2)+" ms"); - } - try { - Thread.sleep( d_vpts - 22 / 2 ); - } catch (InterruptedException e) { } - } - return true; + private final int getVideoDPTSAvg() { + return (int) ( video_dpts_cum * (1.0f - VIDEO_DPTS_COEFF) + 0.5f ); } - private final void newFrameAvailable(TextureFrame frame) { - decodedFrameCount++; + private final void newFrameAvailable(TextureFrame frame, long currentTimeMillis) { + decodedFrameCount++; + if( 0 == frame.getDuration() ) { // patch frame duration if not set already + frame.setDuration( (int) frame_duration ); + } synchronized(eventListenersLock) { for(Iterator i = eventListeners.iterator(); i.hasNext(); ) { - i.next().newFrameAvailable(this, frame, System.currentTimeMillis()); + i.next().newFrameAvailable(this, frame, currentTimeMillis); } } } @@ -759,12 +741,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private GLDrawable dummyDrawable = null; private GLContext sharedGLCtx = null; - FramePusher(GL gl, boolean createSharedCtx) { + FramePusher(GL gl) { setDaemon(true); - this.gl = createSharedCtx ? createSharedGL(gl) : gl; - } - - private GL createSharedGL(GL gl) { + final GLContext glCtx = gl.getContext(); final boolean glCtxCurrent = glCtx.isCurrent(); final GLProfile glp = gl.getGLProfile(); @@ -779,8 +758,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } else { sharedGLCtx.release(); } - return sharedGLCtx.getGL(); + this.gl = sharedGLCtx.getGL(); } + private void makeCurrent(GLContext ctx) { if( GLContext.CONTEXT_NOT_CURRENT >= ctx.makeCurrent() ) { throw new GLException("Couldn't make ctx current: "+ctx); @@ -789,6 +769,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private void destroySharedGL() { if( null != sharedGLCtx ) { + postNextTextureImpl(gl); if( sharedGLCtx.isCreated() ) { // Catch dispose GLExceptions by GLEventListener, just 'print' them // so we can continue with the destruction. @@ -870,9 +851,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { FramePusherInstanceId++; synchronized ( this ) { - if( null != sharedGLCtx ) { - makeCurrent( sharedGLCtx ); - } + makeCurrent( sharedGLCtx ); + preNextTextureImpl(gl); isRunning = true; this.notify(); // wake-up doStart() } @@ -880,10 +860,13 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { while( !shallStop ){ if( shallPause ) { synchronized ( this ) { + postNextTextureImpl(gl); + sharedGLCtx.release(); while( shallPause && !shallStop ) { isActive = false; this.notify(); // wake-up doPause() try { + System.err.println("!!! PAUSE ON"); // FIXME this.wait(); // wait until resumed } catch (InterruptedException e) { if( !shallPause ) { @@ -891,6 +874,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } + makeCurrent(sharedGLCtx); + preNextTextureImpl(gl); + System.err.println("!!! PAUSE OFF"); // FIXME isActive = true; this.notify(); // wake-up doResume() } @@ -903,15 +889,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { nextFrame = videoFramesFree.getBlocking(false /* clearRef */ ); isBlocked = false; nextFrame.setPTS( TextureFrame.INVALID_PTS ); // mark invalid until processed! - if( getNextTextureImpl(gl, nextFrame, true) ) { + if( getNextTextureImpl(gl, nextFrame, true, false /* issuePreAndPost */) ) { // gl.glFinish(); gl.glFlush(); // even better: sync object! if( !videoFramesDecoded.put(nextFrame) ) { - throw new InternalError("XXX: "+GLMediaPlayerImpl.this); + throw new InternalError("XXX: free "+videoFramesFree+", decoded "+videoFramesDecoded+", "+GLMediaPlayerImpl.this); } - final TextureFrame _nextFrame = nextFrame; + newFrameAvailable(nextFrame, Platform.currentTimeMillis()); nextFrame = null; - newFrameAvailable(_nextFrame); } } catch (InterruptedException e) { isBlocked = false; @@ -927,6 +912,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } + postNextTextureImpl(gl); destroySharedGL(); synchronized ( this ) { isRunning = false; @@ -975,7 +961,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( this.fps != fps ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_FPS; this.fps = fps; - this.frame_period = (int) ( 1000f / fps + 0.5f ); + this.frame_duration = 1000f / (float)fps; } if( this.bps_stream != bps_stream || this.bps_video != bps_video || this.bps_audio != bps_audio ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_BPS; @@ -1006,7 +992,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected final void attributesUpdated(int event_mask) { synchronized(eventListenersLock) { for(Iterator i = eventListeners.iterator(); i.hasNext(); ) { - i.next().attributesChanges(this, event_mask, System.currentTimeMillis()); + i.next().attributesChanges(this, event_mask, Platform.currentTimeMillis()); } } } @@ -1017,6 +1003,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { destroyFramePusher(); destroyImpl(gl); removeAllTextureFrames(gl); + if( null != videoFramesFree ) { + videoFramesFree.clear(); + } + if( null != videoFramesDecoded ) { + videoFramesDecoded.clear(); + } state = State.Uninitialized; return state; } @@ -1094,25 +1086,28 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final String loc = ( null != urlConn ) ? urlConn.getURL().toExternalForm() : "" ; final int freeVideoFrames = null != videoFramesFree ? videoFramesFree.size() : 0; final int decVideoFrames = null != videoFramesDecoded ? videoFramesDecoded.size() : 0; - return "GLMediaPlayer["+state+", frames[p "+presentedFrameCount+", d "+decodedFrameCount+", t "+videoFrames+" ("+tt+" s)], "+ + final int video_scr = video_scr_pts + (int) ( ( Platform.currentTimeMillis() - video_scr_t0 ) * playSpeed ); + return "GLMediaPlayer["+state+", vSCR "+video_scr+", frames[p "+presentedFrameCount+", d "+decodedFrameCount+", t "+videoFrames+" ("+tt+" s)], "+ "speed "+playSpeed+", "+bps_stream+" bps, "+ "Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+", target "+toHexString(textureTarget)+", format "+toHexString(textureFormat)+", type "+toHexString(textureType)+"], "+ - "Video[id "+vid+", <"+vcodec+">, "+width+"x"+height+", "+fps+" fps, "+bps_video+" bps], "+ + "Video[id "+vid+", <"+vcodec+">, "+width+"x"+height+", "+fps+" fps, "+frame_duration+" fdur, "+bps_video+" bps], "+ "Audio[id "+aid+", <"+acodec+">, "+bps_audio+" bps, "+audioFrames+" frames], uri "+loc+"]"; } @Override public final String getPerfString() { - final int scr_pts = video_scr_pts + - (int) ( ( System.currentTimeMillis() - video_scr_t0 ) * playSpeed ); - final int d_vpts = video_pts_last - scr_pts; - return getPerfStringImpl( scr_pts, video_pts_last, d_vpts, getVideoDPTSAvg() ); - } - private final String getPerfStringImpl(final int scr_pts, final int video_pts, final int d_vpts, final int video_dpts_avg_diff) { - final float tt = getDuration() / 1000.0f; - final int audio_scr = (int) ( ( System.currentTimeMillis() - audio_scr_t0 ) * playSpeed ); + final long currentTimeMillis = Platform.currentTimeMillis(); + final int video_scr = video_scr_pts + (int) ( ( currentTimeMillis - video_scr_t0 ) * playSpeed ); + final int d_vpts = video_pts_last - video_scr; + final int audio_scr = (int) ( ( currentTimeMillis - audio_scr_t0 ) * playSpeed ); final int audio_pts = getAudioPTSImpl(); final int d_apts = audio_pts - audio_scr; + return getPerfStringImpl( video_scr, video_pts_last, d_vpts, audio_scr, audio_pts, d_apts, getVideoDPTSAvg() ); + } + private final String getPerfStringImpl(final int video_scr, final int video_pts, final int d_vpts, + final int audio_scr, final int audio_pts, final int d_apts, + final int video_dpts_avg_diff) { + final float tt = getDuration() / 1000.0f; final String audioSinkInfo; final AudioSink audioSink = getAudioSink(); if( null != audioSink ) { @@ -1122,8 +1117,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } final int freeVideoFrames = null != videoFramesFree ? videoFramesFree.size() : 0; final int decVideoFrames = null != videoFramesDecoded ? videoFramesDecoded.size() : 0; - return state+", frames[p "+presentedFrameCount+", d "+decodedFrameCount+", t "+videoFrames+" ("+tt+" s)], "+ - "speed " + playSpeed+", vSCR "+scr_pts+", vpts "+video_pts+", dSCR["+d_vpts+", avrg "+video_dpts_avg_diff+"], "+ + return state+", frames[(p "+presentedFrameCount+", d "+decodedFrameCount+") / "+videoFrames+", "+tt+" s], "+ + "speed " + playSpeed+", dAV "+( d_vpts - d_apts )+", vSCR "+video_scr+", vpts "+video_pts+", dSCR["+d_vpts+", avrg "+video_dpts_avg_diff+"], "+ "aSCR "+audio_scr+", apts "+audio_pts+" ( "+d_apts+" ), "+audioSinkInfo+ ", Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+"]"; } @@ -1163,5 +1158,4 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected static final String toHexString(int v) { return "0x"+Integer.toHexString(v); } - } \ No newline at end of file diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index 5d70ca33d..ad8587e6b 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -37,6 +37,7 @@ import javax.media.opengl.GLProfile; import jogamp.opengl.util.av.GLMediaPlayerImpl; import com.jogamp.common.nio.Buffers; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.IOUtil; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; @@ -51,7 +52,7 @@ import com.jogamp.opengl.util.texture.TextureSequence; public class NullGLMediaPlayer extends GLMediaPlayerImpl { private TextureData texData = null; private int pos_ms = 0; - private int pos_start = 0; + private long pos_start = 0; public NullGLMediaPlayer() { super(); @@ -64,7 +65,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { @Override protected final boolean playImpl() { - pos_start = (int)System.currentTimeMillis(); + pos_start = Platform.currentTimeMillis(); return true; } @@ -81,14 +82,14 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking) { + protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost) { nextFrame.setPTS( getAudioPTSImpl() ); return true; } @Override protected final int getAudioPTSImpl() { - pos_ms = (int)System.currentTimeMillis() - pos_start; + pos_ms = (int) ( Platform.currentTimeMillis() - pos_start ); validatePos(); return pos_ms; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index 3680da1a8..cf864daa2 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -55,9 +55,11 @@ import com.jogamp.common.util.RunnableExecutor; * Tue Feb 28 12:07:53 2012 322537478b63c6bc01e640643550ff539864d790 minor 1 -> 2 */ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { + private static final boolean DEBUG = FFMPEGMediaPlayer.DEBUG || DynamicLibraryBundleInfo.DEBUG; + private static final List glueLibNames = new ArrayList(); // none - private static final int symbolCount = 32; + private static final int symbolCount = 38; private static final String[] symbolNames = { "avcodec_version", "avformat_version", @@ -71,17 +73,20 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avcodec_open", "avcodec_alloc_frame", "avcodec_default_get_buffer", - "avcodec_default_release_buffer", + "avcodec_default_release_buffer", + "av_init_packet", + "av_new_packet", + "av_destruct_packet", "av_free_packet", "avcodec_decode_audio4", // 53.25.0 (opt) "avcodec_decode_audio3", // 52.23.0 -/* 15 */ "avcodec_decode_video2", // 52.23.0 +/* 18 */ "avcodec_decode_video2", // 52.23.0 // libavutil "av_pix_fmt_descriptors", "av_free", "av_get_bits_per_pixel", -/* 19 */ "av_samples_get_buffer_size", +/* 22 */ "av_samples_get_buffer_size", // libavformat "avformat_alloc_context", @@ -93,10 +98,13 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "av_dump_format", "av_read_frame", "av_seek_frame", + "avformat_seek_file", + "av_read_play", + "av_read_pause", "avformat_network_init", // 53.13.0 (opt) "avformat_network_deinit", // 53.13.0 (opt) "avformat_find_stream_info", // 53.3.0 (opt) -/* 32 */ "av_find_stream_info", +/* 38 */ "av_find_stream_info", }; // alternate symbol names @@ -203,7 +211,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { for(int j=0; !ok && j, but has alternative <"+symbolNames[si]+">"); } } @@ -212,7 +220,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { System.err.println("Fail: Could not resolve symbol <"+symbolNames[i]+">: not optional, no alternatives."); return false; } - } else if(true || DEBUG ) { // keep it verbose per default for now .. + } else if(DEBUG) { System.err.println("OK: Unresolved optional symbol <"+symbolNames[i]+">"); } } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index dc7ceae39..8998f689a 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -156,7 +156,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { protected int[] vLinesize = { 0, 0, 0 }; // per plane protected int[] vTexWidth = { 0, 0, 0 }; // per plane protected int texWidth, texHeight; // overall (stuffing planes in one texture) - protected ByteBuffer texCopy; protected String singleTexComp = "r"; protected GLPixelStorageModes psm; @@ -174,7 +173,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(!available) { throw new RuntimeException("FFMPEGMediaPlayer not available"); } - moviePtr = createInstance0(DEBUG); + moviePtr = createInstance0( DEBUG_NATIVE ); if(0==moviePtr) { throw new GLException("Couldn't create FFMPEGInstance"); } @@ -185,8 +184,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { protected final int validateTextureCount(int desiredTextureCount) { return desiredTextureCount>2 ? Math.max(4, desiredTextureCount) : 2; } - @Override - protected final boolean requiresOffthreadGLCtx() { return true; } @Override protected final void destroyImpl(GL gl) { @@ -320,7 +317,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case BGRA: texWidth = vTexWidth[0]; texHeight = height; break; - default: // FIXME: Add more planar formats ! + default: // FIXME: Add more formats ! throw new RuntimeException("Unsupported pixelformat: "+vPixelFmt); } @@ -358,7 +355,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { signed = true; fixedP = true; break; - default: // FIXME: Add more planar formats ! + default: // FIXME: Add more formats ! throw new RuntimeException("Unsupported sampleformat: "+aSampleFmt); } avChosenAudioFormat = new AudioDataFormat(AudioDataType.PCM, sampleRate, sampleSize, channels, signed, fixedP, true /* littleEndian */); @@ -427,7 +424,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { " return vec4(r, g, b, 1);\n"+ "}\n" ; - default: // FIXME: Add more planar formats ! + default: // FIXME: Add more formats ! return super.getTextureLookupFragmentShaderImpl(); } } @@ -437,7 +434,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(0==moviePtr) { return false; } - return true; + return play0(moviePtr); } @Override @@ -445,7 +442,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(0==moviePtr) { return false; } - return true; + return pause0(moviePtr); } @Override @@ -457,28 +454,41 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking) { + protected void preNextTextureImpl(GL gl) { + psm.setUnpackAlignment(gl, 1); // RGBA ? 4 : 1 + } + + @Override + protected void postNextTextureImpl(GL gl) { + psm.restore(gl); + } + + @Override + protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost) { if(0==moviePtr) { throw new GLException("FFMPEG native instance null"); - } - psm.setUnpackAlignment(gl, 1); // RGBA ? 4 : 1 - int avPTS = 0; + } + if( issuePreAndPost ) { + preNextTextureImpl(gl); + } + int vPTS = TextureFrame.INVALID_PTS; try { final Texture tex = nextFrame.getTexture(); gl.glActiveTexture(GL.GL_TEXTURE0+getTextureUnit()); tex.enable(gl); tex.bind(gl); - /** Try decode up to 10 packets to find one containing video, i.e. vPTS > 0 */ - for(int retry=10; 0 >= avPTS && 0 < retry; retry--) { - avPTS = readNextPacket0(moviePtr, textureTarget, textureFormat, textureType); - retry--; + /** Try decode up to 10 packets to find one containing video. */ + for(int i=0; TextureFrame.INVALID_PTS == vPTS && 10 > i; i++) { + vPTS = readNextPacket0(moviePtr, textureTarget, textureFormat, textureType); } } finally { - psm.restore(gl); + if( issuePreAndPost ) { + postNextTextureImpl(gl); + } } - if( 0 < avPTS ) { - nextFrame.setPTS(avPTS); + if( TextureFrame.INVALID_PTS != vPTS ) { + nextFrame.setPTS(vPTS); return true; } else { return false; @@ -492,6 +502,11 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } } + private final int getBytesPerMS(int time) { + final int bytesPerSample = sinkChosenAudioFormat.sampleSize >>> 3; // /8 + return time * ( sinkChosenAudioFormat.channelCount * bytesPerSample * ( sinkChosenAudioFormat.sampleRate / 1000 ) ); + } + @Override protected final boolean syncAVRequired() { return true; } @@ -522,10 +537,12 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { private native Buffer getAudioBuffer0(long moviePtr, int plane); /** - * @return resulting current PTS: audio < 0, video > 0, invalid == 0 + * @return resulting current video PTS, or {@link TextureFrame#INVALID_PTS} */ private native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); + private native boolean play0(long moviePtr); + private native boolean pause0(long moviePtr); private native int seek0(long moviePtr, int position); public static enum SampleFormat { diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java index d03cad28a..c6f31d81e 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java @@ -156,7 +156,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking) { + protected boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost) { if(0==moviePtr) { throw new GLException("OMX native instance null"); } diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index 081e17323..06c3862db 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -68,13 +68,16 @@ typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); /** Sync w/ GLMediaPlayer.STREAM_ID_AUTO */ #define AV_STREAM_ID_AUTO -1 +/** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE 0x80000000 {@value}. Sync w/ TextureFrame.INVALID_PTS */ +#define INVALID_PTS 0x80000000 + #define AV_HAS_API_REQUEST_CHANNELS(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) < 55) static inline float my_av_q2f(AVRational a){ return a.num / (float) a.den; } -static inline int32_t my_av_q2i32(int32_t snum, AVRational a){ - return (snum * a.num) / a.den; +static inline int32_t my_av_q2i32(int64_t snum, AVRational a){ + return (int32_t) ( ( snum * (int64_t) a.num ) / (int64_t)a.den ); } typedef struct { diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c index bc376cebd..ca0bf9bb9 100644 --- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c +++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c @@ -62,6 +62,9 @@ typedef int (APIENTRYP AVCODEC_OPEN)(AVCodecContext *avctx, AVCodec *codec); typedef AVFrame *(APIENTRYP AVCODEC_ALLOC_FRAME)(void); typedef int (APIENTRYP AVCODEC_DEFAULT_GET_BUFFER)(AVCodecContext *s, AVFrame *pic); typedef void (APIENTRYP AVCODEC_DEFAULT_RELEASE_BUFFER)(AVCodecContext *s, AVFrame *pic); +typedef void (APIENTRYP AV_INIT_PACKET)(AVPacket *pkt); +typedef int (APIENTRYP AV_NEW_PACKET)(AVPacket *pkt, int size); +typedef void (APIENTRYP AV_DESTRUCT_PACKET)(AVPacket *pkt); typedef void (APIENTRYP AV_FREE_PACKET)(AVPacket *pkt); typedef int (APIENTRYP AVCODEC_DECODE_AUDIO4)(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt); // 53.25.0 typedef int (APIENTRYP AVCODEC_DECODE_AUDIO3)(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt); // 52.23.0 @@ -75,6 +78,9 @@ static AVCODEC_OPEN sp_avcodec_open; static AVCODEC_ALLOC_FRAME sp_avcodec_alloc_frame; static AVCODEC_DEFAULT_GET_BUFFER sp_avcodec_default_get_buffer; static AVCODEC_DEFAULT_RELEASE_BUFFER sp_avcodec_default_release_buffer; +static AV_INIT_PACKET sp_av_init_packet; +static AV_NEW_PACKET sp_av_new_packet; +static AV_DESTRUCT_PACKET sp_av_destruct_packet; static AV_FREE_PACKET sp_av_free_packet; static AVCODEC_DECODE_AUDIO4 sp_avcodec_decode_audio4; // 53.25.0 static AVCODEC_DECODE_AUDIO3 sp_avcodec_decode_audio3; // 52.23.0 @@ -89,7 +95,7 @@ static const AVPixFmtDescriptor* sp_av_pix_fmt_descriptors; static AV_FREE sp_av_free; static AV_GET_BITS_PER_PIXEL sp_av_get_bits_per_pixel; static AV_SAMPLES_GET_BUFFER_SIZE sp_av_samples_get_buffer_size; -// count: 19 +// count: 22 // libavformat typedef AVFormatContext *(APIENTRYP AVFORMAT_ALLOC_CONTEXT)(void); @@ -101,6 +107,9 @@ typedef int (APIENTRYP AVFORMAT_OPEN_INPUT)(AVFormatContext **ps, const char *fi typedef void (APIENTRYP AV_DUMP_FORMAT)(AVFormatContext *ic, int index, const char *url, int is_output); typedef int (APIENTRYP AV_READ_FRAME)(AVFormatContext *s, AVPacket *pkt); typedef int (APIENTRYP AV_SEEK_FRAME)(AVFormatContext *s, int stream_index, int64_t timestamp, int flags); +typedef int (APIENTRYP AVFORMAT_SEEK_FILE)(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); +typedef int (APIENTRYP AV_READ_PLAY)(AVFormatContext *s); +typedef int (APIENTRYP AV_READ_PAUSE)(AVFormatContext *s); typedef int (APIENTRYP AVFORMAT_NETWORK_INIT)(void); // 53.13.0 typedef int (APIENTRYP AVFORMAT_NETWORK_DEINIT)(void); // 53.13.0 typedef int (APIENTRYP AVFORMAT_FIND_STREAM_INFO)(AVFormatContext *ic, AVDictionary **options); // 53.3.0 @@ -115,13 +124,16 @@ static AVFORMAT_OPEN_INPUT sp_avformat_open_input; static AV_DUMP_FORMAT sp_av_dump_format; static AV_READ_FRAME sp_av_read_frame; static AV_SEEK_FRAME sp_av_seek_frame; +static AVFORMAT_SEEK_FILE sp_avformat_seek_file; +static AV_READ_PLAY sp_av_read_play; +static AV_READ_PAUSE sp_av_read_pause; static AVFORMAT_NETWORK_INIT sp_avformat_network_init; // 53.13.0 static AVFORMAT_NETWORK_DEINIT sp_avformat_network_deinit; // 53.13.0 static AVFORMAT_FIND_STREAM_INFO sp_avformat_find_stream_info; // 53.3.0 static AV_FIND_STREAM_INFO sp_av_find_stream_info; -// count: 32 +// count: 38 -#define SYMBOL_COUNT 32 +#define SYMBOL_COUNT 38 JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryBundleInfo_initSymbols0 (JNIEnv *env, jclass clazz, jobject jSymbols, jint count) @@ -152,17 +164,20 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryB sp_avcodec_alloc_frame = (AVCODEC_ALLOC_FRAME) (intptr_t) symbols[i++]; sp_avcodec_default_get_buffer = (AVCODEC_DEFAULT_GET_BUFFER) (intptr_t) symbols[i++]; sp_avcodec_default_release_buffer = (AVCODEC_DEFAULT_RELEASE_BUFFER) (intptr_t) symbols[i++]; + sp_av_init_packet = (AV_INIT_PACKET) (intptr_t) symbols[i++]; + sp_av_new_packet = (AV_NEW_PACKET) (intptr_t) symbols[i++]; + sp_av_destruct_packet = (AV_DESTRUCT_PACKET) (intptr_t) symbols[i++]; sp_av_free_packet = (AV_FREE_PACKET) (intptr_t) symbols[i++]; sp_avcodec_decode_audio4 = (AVCODEC_DECODE_AUDIO4) (intptr_t) symbols[i++]; sp_avcodec_decode_audio3 = (AVCODEC_DECODE_AUDIO3) (intptr_t) symbols[i++]; sp_avcodec_decode_video2 = (AVCODEC_DECODE_VIDEO2) (intptr_t) symbols[i++]; - // count: 15 + // count: 18 sp_av_pix_fmt_descriptors = (const AVPixFmtDescriptor*) (intptr_t) symbols[i++]; sp_av_free = (AV_FREE) (intptr_t) symbols[i++]; sp_av_get_bits_per_pixel = (AV_GET_BITS_PER_PIXEL) (intptr_t) symbols[i++]; sp_av_samples_get_buffer_size = (AV_SAMPLES_GET_BUFFER_SIZE) (intptr_t) symbols[i++]; - // count: 19 + // count: 22 sp_avformat_alloc_context = (AVFORMAT_ALLOC_CONTEXT) (intptr_t) symbols[i++];; sp_avformat_free_context = (AVFORMAT_FREE_CONTEXT) (intptr_t) symbols[i++]; @@ -173,11 +188,14 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryB sp_av_dump_format = (AV_DUMP_FORMAT) (intptr_t) symbols[i++]; sp_av_read_frame = (AV_READ_FRAME) (intptr_t) symbols[i++]; sp_av_seek_frame = (AV_SEEK_FRAME) (intptr_t) symbols[i++]; + sp_avformat_seek_file = (AVFORMAT_SEEK_FILE) (intptr_t) symbols[i++]; + sp_av_read_play = (AV_READ_PLAY) (intptr_t) symbols[i++]; + sp_av_read_pause = (AV_READ_PAUSE) (intptr_t) symbols[i++]; sp_avformat_network_init = (AVFORMAT_NETWORK_INIT) (intptr_t) symbols[i++]; sp_avformat_network_deinit = (AVFORMAT_NETWORK_DEINIT) (intptr_t) symbols[i++]; sp_avformat_find_stream_info = (AVFORMAT_FIND_STREAM_INFO) (intptr_t) symbols[i++]; sp_av_find_stream_info = (AV_FIND_STREAM_INFO) (intptr_t) symbols[i++]; - // count: 32 + // count: 38 (*env)->ReleasePrimitiveArrayCritical(env, jSymbols, symbols, 0); @@ -502,7 +520,7 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre // Customize .. // pAV->pACodecCtx->thread_count=2; // pAV->pACodecCtx->thread_type=FF_THREAD_FRAME|FF_THREAD_SLICE; // Decode more than one frame at once - pAV->pACodecCtx->thread_count=1; + pAV->pACodecCtx->thread_count=0; pAV->pACodecCtx->thread_type=0; pAV->pACodecCtx->workaround_bugs=FF_BUG_AUTODETECT; pAV->pACodecCtx->skip_frame=AVDISCARD_DEFAULT; @@ -579,7 +597,7 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre // Customize .. // pAV->pVCodecCtx->thread_count=2; // pAV->pVCodecCtx->thread_type=FF_THREAD_FRAME|FF_THREAD_SLICE; // Decode more than one frame at once - pAV->pVCodecCtx->thread_count=1; + pAV->pVCodecCtx->thread_count=0; pAV->pVCodecCtx->thread_type=0; pAV->pVCodecCtx->workaround_bugs=FF_BUG_AUTODETECT; pAV->pVCodecCtx->skip_frame=AVDISCARD_DEFAULT; @@ -684,10 +702,12 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); AVPacket packet; - int frameFinished; - jint resPTS = 0; // resulting current PTS: audio < 0, video > 0, invalid == 0 + int frameDecoded; + jint resPTS = INVALID_PTS; - if(sp_av_read_frame(pAV->pFormatCtx, &packet)>=0) { + sp_av_init_packet(&packet); + + if( sp_av_read_frame(pAV->pFormatCtx, &packet) >= 0 ) { if(packet.stream_index==pAV->aid) { // Decode audio frame if(NULL == pAV->pAFrames) { // no audio registered @@ -704,10 +724,10 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex break; } if(HAS_FUNC(sp_avcodec_decode_audio4)) { - len1 = sp_avcodec_decode_audio4(pAV->pACodecCtx, pAFrameCurrent, &frameFinished, &packet); + len1 = sp_avcodec_decode_audio4(pAV->pACodecCtx, pAFrameCurrent, &frameDecoded, &packet); } else { #if 0 - len1 = sp_avcodec_decode_audio3(pAV->pACodecCtx, int16_t *samples, int *frame_size_ptr, &frameFinished, &packet); + len1 = sp_avcodec_decode_audio3(pAV->pACodecCtx, int16_t *samples, int *frame_size_ptr, &frameDecoded, &packet); #endif JoglCommon_throwNewRuntimeException(env, "Unimplemented: FFMPEGMediaPlayer sp_avcodec_decode_audio3 fallback"); return 0; @@ -720,7 +740,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex packet.data += len1; packet.size -= len1; - if (!frameFinished) { + if (!frameDecoded) { // stop sending empty packets if the decoder is finished if (!packet.data && pAV->pACodecCtx->codec->capabilities & CODEC_CAP_DELAY) { flush_complete = 1; @@ -745,7 +765,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex const int64_t pkt_pts = pAFrameCurrent->pkt_pts; int aptsMode; if( 0 == frameCount && AV_NOPTS_VALUE != pkt_pts ) { // 1st frame only, discard invalid PTS .. - pAV->aPTS = (pkt_pts * (int64_t) 1000 * (int64_t) time_base.num) / (int64_t) time_base.den ; + pAV->aPTS = my_av_q2i32( pkt_pts * 1000, time_base); aptsMode = 0; } else { // subsequent frames or invalid PTS .. const int32_t bytesPerSample = 2; // av_get_bytes_per_sample( pAV->pACodecCtx->sample_fmt ); @@ -753,14 +773,15 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex aptsMode = 1; } if( pAV->verbose ) { - fprintf(stderr, "A pts %d [pkt_pts %ld, pkt_dts %ld], dataSize %d, f# %d, pts-mode %d\n", - pAV->aPTS, pkt_pts, pAFrameCurrent->pkt_dts, data_size, frameCount, aptsMode); + int32_t aDTS = my_av_q2i32( pAFrameCurrent->pkt_dts * 1000, time_base); + + fprintf(stderr, "A pts %d [pkt_pts %ld], dts %d [pkt_dts %ld], dataSize %d, f# %d, pts-mode %d\n", + pAV->aPTS, pkt_pts, aDTS, pAFrameCurrent->pkt_dts, data_size, frameCount, aptsMode); } if( NULL != env ) { jobject jSampleData = (*env)->NewDirectByteBuffer(env, pAFrameCurrent->data[0], data_size); (*env)->CallVoidMethod(env, instance, jni_mid_pushSound, jSampleData, data_size, pAV->aPTS); } - resPTS = pAV->aPTS * -1; // Audio Frame! } } else if(packet.stream_index==pAV->vid) { // Decode video frame @@ -775,7 +796,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex if (flush_complete) { break; } - len1 = sp_avcodec_decode_video2(pAV->pVCodecCtx, pAV->pVFrame, &frameFinished, &packet); + len1 = sp_avcodec_decode_video2(pAV->pVCodecCtx, pAV->pVFrame, &frameDecoded, &packet); if (len1 < 0) { // if error, we skip the frame packet.size = 0; @@ -784,7 +805,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex packet.data += len1; packet.size -= len1; - if (!frameFinished) { + if (!frameDecoded) { // stop sending empty packets if the decoder is finished if (!packet.data && pAV->pVCodecCtx->codec->capabilities & CODEC_CAP_DELAY) { flush_complete = 1; @@ -796,15 +817,25 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex const AVRational time_base = pAV->pVStream->time_base; const int64_t pkt_pts = pAV->pVFrame->pkt_pts; if(AV_NOPTS_VALUE != pkt_pts) { // discard invalid PTS .. - int32_t vPTS2 = (pAV->pVFrame->pkt_dts * (int64_t) 1000 * (int64_t) time_base.num) / (int64_t) time_base.den ; - pAV->vPTS = (pkt_pts * (int64_t) 1000 * (int64_t) time_base.num) / (int64_t) time_base.den ; + pAV->vPTS = my_av_q2i32( pkt_pts * 1000, time_base); if( pAV->verbose ) { - fprintf(stderr, "V pts %d [pkt_pts %ld], pts2 %d [pkt_dts %ld]\n", pAV->vPTS, pkt_pts, vPTS2, pAV->pVFrame->pkt_dts); - } - } else { - if( pAV->verbose ) { - fprintf(stderr, "V pts ?? [pkt_pts %ld], pts2 ?? [pkt_dts %ld]\n", pkt_pts, pAV->pVFrame->pkt_dts); + int32_t vDTS = my_av_q2i32( pAV->pVFrame->pkt_dts * 1000, time_base); + + double frame_delay_d = av_q2d(pAV->pVCodecCtx->time_base); + double frame_repeat_d = pAV->pVFrame->repeat_pict * (frame_delay_d * 0.5); + + int32_t frame_delay_i = my_av_q2i32(1000, pAV->pVCodecCtx->time_base); + int32_t frame_repeat_i = pAV->pVFrame->repeat_pict * (frame_delay_i / 2); + + const char * warn = frame_repeat_i > 0 ? "REPEAT" : "NORMAL" ; + + fprintf(stderr, "V pts %d [pkt_pts %ld], dts %d [pkt_dts %ld], time d(%lf s + r %lf = %lf s), i(%d ms + r %d = %d ms) - %s - f# %d\n", + pAV->vPTS, pkt_pts, vDTS, pAV->pVFrame->pkt_dts, + frame_delay_d, frame_repeat_d, (frame_delay_d + frame_repeat_d), + frame_delay_i, frame_repeat_i, (frame_delay_i + frame_repeat_i), warn, frameCount); } + } else if( pAV->verbose ) { + fprintf(stderr, "V pts ?? [pkt_pts %ld], pts2 ?? [pkt_dts %ld], f# %d\n", pkt_pts, pAV->pVFrame->pkt_dts, frameCount); } resPTS = pAV->vPTS; // Video Frame! @@ -846,6 +877,31 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex return resPTS; } +JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_play0 + (JNIEnv *env, jobject instance, jlong ptr) +{ + FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); + int res = sp_av_read_play(pAV->pFormatCtx); + if ( 0 != res && -ENOSYS != res ) { // Ignore ENOSYS (not impl.) + fprintf(stderr, "PLAY: err %d 0x%X\n", res, res); + return JNI_FALSE; + } else { + return JNI_TRUE; + } +} +JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_pause0 + (JNIEnv *env, jobject instance, jlong ptr) +{ + FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); + int res = sp_av_read_pause(pAV->pFormatCtx); + if ( 0 != res && -ENOSYS != res ) { // Ignore ENOSYS (not impl.) + fprintf(stderr, "PAUSE: err %d 0x%X\n", res, res); + return JNI_FALSE; + } else { + return JNI_TRUE; + } +} + JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_seek0 (JNIEnv *env, jobject instance, jlong ptr, jint pos1) { @@ -854,14 +910,14 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_seek0 int64_t pts0 = pAV->pVFrame->pkt_pts; int64_t pts1 = (int64_t) (pos1 * (int64_t) pAV->pVStream->time_base.den) / (1000 * (int64_t) pAV->pVStream->time_base.num); + int flags = 0; if(pos1 < pos0) { flags |= AVSEEK_FLAG_BACKWARD; } fprintf(stderr, "SEEK: pre : u %ld, p %ld -> u %ld, p %ld\n", pos0, pts0, pos1, pts1); sp_av_seek_frame(pAV->pFormatCtx, pAV->vid, pts1, flags); - pAV->vPTS = (int64_t) (pAV->pVFrame->pkt_pts * (int64_t) 1000 * (int64_t) pAV->pVStream->time_base.num) - / (int64_t) pAV->pVStream->time_base.den; + pAV->vPTS = my_av_q2i32( pAV->pVFrame->pkt_pts * 1000, pAV->pVStream->time_base); fprintf(stderr, "SEEK: post : u %ld, p %ld\n", pAV->vPTS, pAV->pVFrame->pkt_pts); return pAV->vPTS; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index fbbd77260..b673a9d2a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -33,9 +33,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; @@ -102,20 +100,16 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { int pts0 = mPlayer.getVideoPTS(); int pts1 = 0; switch(e.getKeyCode()) { - case KeyEvent.VK_3: case KeyEvent.VK_RIGHT: pts1 = pts0 + 1000; break; - case KeyEvent.VK_4: case KeyEvent.VK_UP: pts1 = pts0 + 10000; break; - case KeyEvent.VK_2: + case KeyEvent.VK_PAGE_UP: pts1 = pts0 + 30000; break; case KeyEvent.VK_LEFT: pts1 = pts0 - 1000; break; - case KeyEvent.VK_1: case KeyEvent.VK_DOWN: pts1 = pts0 - 10000; break; + case KeyEvent.VK_PAGE_DOWN: pts1 = pts0 - 30000; break; case KeyEvent.VK_ESCAPE: - case KeyEvent.VK_DELETE: + case KeyEvent.VK_HOME: case KeyEvent.VK_BACK_SPACE: { - mPlayer.setPlaySpeed(1.0f); mPlayer.seek(0); - mPlayer.play(); break; } case KeyEvent.VK_SPACE: { @@ -126,6 +120,9 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } break; } + case KeyEvent.VK_MULTIPLY: + mPlayer.setPlaySpeed(1.0f); + break; case KeyEvent.VK_SUBTRACT: { float playSpeed = mPlayer.getPlaySpeed(); if( e.isShiftDown() ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index f5490d19a..af9454464 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -164,20 +164,16 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { int pts0 = mPlayer.getVideoPTS(); int pts1 = 0; switch(e.getKeyCode()) { - case KeyEvent.VK_3: case KeyEvent.VK_RIGHT: pts1 = pts0 + 1000; break; - case KeyEvent.VK_4: case KeyEvent.VK_UP: pts1 = pts0 + 10000; break; - case KeyEvent.VK_2: + case KeyEvent.VK_PAGE_UP: pts1 = pts0 + 30000; break; case KeyEvent.VK_LEFT: pts1 = pts0 - 1000; break; - case KeyEvent.VK_1: case KeyEvent.VK_DOWN: pts1 = pts0 - 10000; break; + case KeyEvent.VK_PAGE_DOWN: pts1 = pts0 - 30000; break; case KeyEvent.VK_ESCAPE: - case KeyEvent.VK_DELETE: + case KeyEvent.VK_HOME: case KeyEvent.VK_BACK_SPACE: { - mPlayer.setPlaySpeed(1.0f); mPlayer.seek(0); - mPlayer.play(); break; } case KeyEvent.VK_SPACE: { @@ -188,6 +184,9 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { } break; } + case KeyEvent.VK_MULTIPLY: + mPlayer.setPlaySpeed(1.0f); + break; case KeyEvent.VK_SUBTRACT: { float playSpeed = mPlayer.getPlaySpeed(); if( e.isShiftDown() ) { -- cgit v1.2.3 From 474ce65081ecd452215bc07ab866666cb11ca8b1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 23 Aug 2013 01:02:33 +0200 Subject: GLMediaPlayer Multithreaded Decoding: GLMediaPlayer* (Part-5) - WIP - Update/fix GLMediaPlayer API doc - GLMediaEventListener: Add event bits for all state changes to be delivered via attributesChanged(..) - StreamWorker / Decoder Thread: - Use StreamWorker only ! - Handle exceptions on StreamWorker via StreamException - Handles stream initialization and decoding (-> initStream(..)) - Split initGLStream(..) -> initStream(..) + initGL(GL) - allow initStream(..)'s implementation being executed on StreamWorker - allow GL initialization to be 'postponed' when stream is read, i.e. non blocking stream initialization (UI .. etc) - Handle EOS via END_OF_STREAM_PTS -> pause/event - Video: Use lock-free LFRingbuffer, similar to ALAudioSink (commit f18a94b3defef16e98badd6d99f2422609aa56c5) +++ - FFMPEGDynamicLibraryBundleInfo - Add avcodec's: - avcodec_get_frame_defaults, avcodec_free_frame (54.28.0), avcodec_flush_buffers, - Add avutil's: - av_frame_unref (55.0.0) - Add avformat's: - avformat_seek_file (??) +++ - FFMPEGMediaPlayer Native: - add 'snoop' video frames for a/v frame count relation. disabled per default, since no more needed due to ALAudioSink's grow-buffer usage of LFRingbuffer. - use sp_avcodec_free_frame if available - 'useRefCountedFrames=1' for libav 55.0 to cache more than one audio frame, not used since ALAudioSink's OpenAL usage does not require it (copies data once). Note: the above snooped-video frame count is used here. - use only one cached audio-frame (-> see above, OpenAL copies data once), while reusing the NIO buffer! - Perform OpenGL sync (glFinish) in native code! - find proper PTS value, i.e. either frame's PTS or DTS, see 'PTSStats'. - FFMPEGMediaPlayer Java: - use private fields - simplified code due to above changes. +++ Working Tests: MovieSimple and MovieCube TODO-1: Fix - Android - OMXGLMediaPlayer TODO-2: - Fix issue where async audio frames arrive much later than 1st video frame, i.e. around 300ms. - Default TextureCount .. maybe 3 ? - Adding Audio synchronization ? - Find 'truth' about correlation of audio and video PTS values, currently, we assume both to be unrelated ? --- make/scripts/tests.sh | 9 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 210 +++++++-- .../android/av/AndroidGLMediaPlayerAPI14.java | 13 +- .../jogamp/opengl/util/av/EGLMediaPlayerImpl.java | 6 +- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 514 +++++++++++++-------- .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 9 +- .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 23 +- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 239 +++++----- .../opengl/util/av/impl/OMXGLMediaPlayer.java | 10 +- src/jogl/native/libav/ffmpeg_tool.h | 36 +- .../jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c | 463 ++++++++++++++++--- .../opengl/test/android/MovieCubeActivity0.java | 43 +- .../opengl/test/android/MovieSimpleActivity0.java | 61 ++- .../opengl/test/android/MovieSimpleActivity1.java | 191 +++++--- .../test/junit/jogl/demos/es2/av/MovieCube.java | 182 +++++--- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 205 ++++---- 16 files changed, 1511 insertions(+), 703 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7aac0ca33..6475f06b4 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -131,9 +131,10 @@ function jrun() { #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" - D_ARGS="-Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" - #D_ARGS="-Djogl.debug.GLMediaPlayer.Native -Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" #D_ARGS="-Djogl.debug.GLDrawable" @@ -317,8 +318,8 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 512567f33..726eddb01 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -27,7 +27,6 @@ */ package com.jogamp.opengl.util.av; -import java.io.IOException; import java.net.URI; import javax.media.opengl.GL; @@ -38,22 +37,56 @@ import jogamp.opengl.Debug; import com.jogamp.opengl.util.texture.TextureSequence; /** - * GLMediaPlayer interface specifies a {@link TextureSequence} - * with a video stream as it's source. + * GLMediaPlayer interface specifies a {@link TextureSequence} state machine + * using a multiplexed audio/video stream as it's source. *

      - * Audio maybe supported and played back internally or via an {@link AudioSink} implementation, - * if an audio stream is selected in {@link #initGLStream(GL, int, URI, int, int)}. + * Audio maybe supported and played back internally or via an {@link AudioSink} implementation. + *

      + *

      + * Audio and video streams can be selected or muted via {@link #initStream(URI, int, int, int)} + * using the appropriate stream id's. *

      * + *
      StreamWorker Decoding Thread
      + *

      + * Most of the stream processing is performed on the decoding thread, a.k.a. StreamWorker: + *

        + *
      • Stream initialization triggered by {@link #initStream(URI, int, int, int) initStream(..)} - User gets notified whether the stream has been initialized or not via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long) attributesChanges(..)}.
      • + *
      • Stream decoding - User gets notified of a new frame via {@link GLMediaEventListener#newFrameAvailable(GLMediaPlayer, com.jogamp.opengl.util.texture.TextureSequence.TextureFrame, long) newFrameAvailable(...)}.
      • + *
      • Caught exceptions on the decoding thread are delivered as {@link StreamException}s.
      • + *
      + * StreamWorker generates it's own {@link GLContext}, shared with the one passed to {@link #initGL(GL)}. + * The shared {@link GLContext} allows the decoding thread to push the video frame data directly into + * the designated {@link TextureFrame}, later returned via {@link #getNextTexture(GL)} and used by the user. + *

      + * StreamWorker Error Handling + *

      + * Caught exceptions on StreamWorker are delivered as {@link StreamException}s, + * which either degrades the {@link State} to {@link State#Uninitialized} or {@link State#Paused}. + *

      + *

      + * An occurring {@link StreamException} triggers a {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} event, + * which can be listened to via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long)}. + *

      + *

      + * An occurred {@link StreamException} can be read via {@link #getStreamException()}. + *

      + * + *

      *
      GLMediaPlayer Lifecycle
      *

      *

      - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * *
      action state before state after
      {@link #initGLStream(GL, int, URI, int, int)} Uninitialized Paused
      {@link #play()} Paused Playing
      {@link #pause()} Playing Paused
      {@link #seek(int)} Playing, Paused Unchanged
      {@link #destroy(GL)} ANY Uninitialized
      Action {@link State} Before {@link State} After {@link GLMediaEventListener Event}
      {@link #initStream(URI, int, int, int)} {@link State#Uninitialized Uninitialized} {@link State#Initialized Initialized}1, {@link State#Uninitialized Uninitialized} {@link GLMediaEventListener#EVENT_CHANGE_INIT EVENT_CHANGE_INIT} or ( {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} + {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT} )
      {@link #initGL(GL)} {@link State#Initialized Initialized} {@link State#Paused Paused}, {@link State#Initialized Initialized} {@link GLMediaEventListener#EVENT_CHANGE_PAUSE EVENT_CHANGE_PAUSE}
      {@link #play()} {@link State#Paused Paused} {@link State#Playing Playing} {@link GLMediaEventListener#EVENT_CHANGE_PLAY EVENT_CHANGE_PLAY}
      {@link #pause()} {@link State#Playing Playing} {@link State#Paused Paused} {@link GLMediaEventListener#EVENT_CHANGE_PAUSE EVENT_CHANGE_PAUSE}
      {@link #seek(int)} {@link State#Paused Paused}, {@link State#Playing Playing} {@link State#Paused Paused}, {@link State#Playing Playing} none
      {@link #getNextTexture(GL)} {@link State#Paused Paused}, {@link State#Playing Playing} {@link State#Paused Paused}, {@link State#Playing Playing} none
      {@link #getLastTexture()} {@link State#Paused Paused}, {@link State#Playing Playing} {@link State#Paused Paused}, {@link State#Playing Playing} none
      {@link TextureFrame#END_OF_STREAM_PTS END_OF_STREAM} {@link State#Playing Playing} {@link State#Paused Paused} {@link GLMediaEventListener#EVENT_CHANGE_EOS EVENT_CHANGE_EOS} + {@link GLMediaEventListener#EVENT_CHANGE_PAUSE EVENT_CHANGE_PAUSE}
      {@link StreamException} ANY {@link State#Paused Paused}, {@link State#Uninitialized Uninitialized} {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} + ( {@link GLMediaEventListener#EVENT_CHANGE_PAUSE EVENT_CHANGE_PAUSE} or {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT} )
      {@link #destroy(GL)} ANY {@link State#Uninitialized Uninitialized} {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT}
      *

      * @@ -90,16 +123,18 @@ import com.jogamp.opengl.util.texture.TextureSequence; * will allow tracking time up 2,147,483.647 seconds or * 24 days 20 hours 31 minutes and 23 seconds. * Milliseconds granularity is also more than enough to deal with A-V synchronization, - * where the threshold usually lies within 100ms. + * where the threshold usually lies within 22ms. *

      * *
      Audio and video synchronization
      *

      * The class follows a passive A/V synchronization pattern. - * Audio is being untouched, while {@link #getNextTexture(GL, boolean)} delivers a new video frame - * only, if its timestamp is less than 22ms ahead of time. - * Otherwise the early frame is cached for later retrieval and the previous frame is returned. - * FIXME: Refine! + * Audio is being untouched, while {@link #getNextTexture(GL)} delivers a new video frame + * only, if its timestamp is less than {@link #MAXIMUM_VIDEO_ASYNC} ahead of time. + * If its timestamp is more than {@link #MAXIMUM_VIDEO_ASYNC} ahead of time, + * the previous frame is returned. + * If its timestamp is more than {@link #MAXIMUM_VIDEO_ASYNC} after time, + * the frame is dropped and the next frame is being fetched. *

      *

      * https://en.wikipedia.org/wiki/Audio_to_video_synchronization @@ -149,37 +184,80 @@ public interface GLMediaPlayer extends TextureSequence { public static final boolean DEBUG = Debug.debug("GLMediaPlayer"); public static final boolean DEBUG_NATIVE = Debug.debug("GLMediaPlayer.Native"); + /** Minimum texture count, value {@value}. */ + public static final int TEXTURE_COUNT_MIN = 4; + /** Constant {@value} for mute or not available. See Audio and video Stream IDs. */ public static final int STREAM_ID_NONE = -2; /** Constant {@value} for auto or unspecified. See Audio and video Stream IDs. */ public static final int STREAM_ID_AUTO = -1; - /** Maximum video frame async .. */ + /** Maximum video frame async of {@value} milliseconds. */ public static final int MAXIMUM_VIDEO_ASYNC = 22; + /** + * A StreamException encapsulates a caught exception in the decoder thread, a.k.a StreamWorker, + * see See StreamWorker Error Handling. + */ + @SuppressWarnings("serial") + public static class StreamException extends Exception { + public StreamException(Throwable cause) { + super(cause); + } + public StreamException(String message, Throwable cause) { + super(message, cause); + } + } public interface GLMediaEventListener extends TexSeqEventListener { - static final int EVENT_CHANGE_VID = 1<<0; - static final int EVENT_CHANGE_AID = 1<<1; - static final int EVENT_CHANGE_SIZE = 1<<2; - static final int EVENT_CHANGE_FPS = 1<<3; - static final int EVENT_CHANGE_BPS = 1<<4; - static final int EVENT_CHANGE_LENGTH = 1<<5; - static final int EVENT_CHANGE_CODEC = 1<<6; + /** State changed to {@link State#Initialized}. See Lifecycle.*/ + static final int EVENT_CHANGE_INIT = 1<<0; + /** State changed to {@link State#Uninitialized}. See Lifecycle.*/ + static final int EVENT_CHANGE_UNINIT = 1<<1; + /** State changed to {@link State#Playing}. See Lifecycle.*/ + static final int EVENT_CHANGE_PLAY = 1<<2; + /** State changed to {@link State#Paused}. See Lifecycle.*/ + static final int EVENT_CHANGE_PAUSE = 1<<3; + /** End of stream reached. See Lifecycle.*/ + static final int EVENT_CHANGE_EOS = 1<<4; + /** An error occurred, e.g. during off-thread initialization. See {@link StreamException} and Lifecycle. */ + static final int EVENT_CHANGE_ERR = 1<<5; + + /** Stream video id change. */ + static final int EVENT_CHANGE_VID = 1<<16; + /** Stream audio id change. */ + static final int EVENT_CHANGE_AID = 1<<17; + /** TextureFrame size change. */ + static final int EVENT_CHANGE_SIZE = 1<<18; + /** Stream fps change. */ + static final int EVENT_CHANGE_FPS = 1<<19; + /** Stream bps change. */ + static final int EVENT_CHANGE_BPS = 1<<20; + /** Stream length change. */ + static final int EVENT_CHANGE_LENGTH = 1<<21; + /** Stream codec change. */ + static final int EVENT_CHANGE_CODEC = 1<<22; /** * @param mp the event source * @param event_mask the changes attributes * @param when system time in msec. */ - public void attributesChanges(GLMediaPlayer mp, int event_mask, long when); + public void attributesChanged(GLMediaPlayer mp, int event_mask, long when); } /** - * See GLMediaPlayer Lifecycle. + * See Lifecycle. */ public enum State { - Uninitialized(0), Playing(1), Paused(2); + /** Uninitialized player, no resources shall be hold. */ + Uninitialized(0), + /** Stream has been initialized, user may play or call {@link #initGL(GL)}. */ + Initialized(1), + /** Stream is playing. */ + Playing(2), + /** Stream is pausing. */ + Paused(3); public final int id; @@ -202,28 +280,62 @@ public interface GLMediaPlayer extends TextureSequence { public void setTextureWrapST(int[] wrapST); /** - * Sets the stream to be used. Initializes all stream related states inclusive OpenGL ones, - * if gl is not null. + * Issues asynchronous stream initialization. + *

      + * Lifecycle: {@link State#Uninitialized} -> {@link State#Initialized}1 or {@link State#Uninitialized} + *

      + *

      + * {@link State#Initialized} is reached asynchronous, + * i.e. user gets notified via {@link GLMediaEventListener#attributesChanged(GLMediaPlayer, int, long) attributesChanges(..)}. + *

      + *

      + * A possible caught asynchronous {@link StreamException} while initializing the stream off-thread + * will be thrown at {@link #initGL(GL)}. + *

      + *

      + * Muted audio can be achieved by passing {@link #STREAM_ID_NONE} to aid. + *

      *

      - * GLMediaPlayer Lifecycle: Uninitialized -> Paused + * Muted video can be achieved by passing {@link #STREAM_ID_NONE} to vid, + * in which case textureCount is ignored as well as the passed GL object of the subsequent {@link #initGL(GL)} call. *

      - * @param gl current GL object. If null, no video output and textures will be available. - * @param textureCount desired number of buffered textures to be decoded off-thread, use 1 for on-thread decoding. * @param streamLoc the stream location * @param vid video stream id, see audio and video Stream IDs * @param aid video stream id, see audio and video Stream IDs - * @return the new state + * @param textureCount desired number of buffered textures to be decoded off-thread, will be validated by implementation. + * The minimum value is {@link #TEXTURE_COUNT_MIN}. + * Ignored if video is muted. + * @throws IllegalStateException if not invoked in {@link State#Uninitialized} + * @throws IllegalArgumentException if arguments are invalid + */ + public void initStream(URI streamLoc, int vid, int aid, int textureCount) throws IllegalStateException, IllegalArgumentException; + + /** + * Returns the {@link StreamException} caught in the decoder thread, or null. + * @see GLMediaEventListener#EVENT_CHANGE_ERR + * @see StreamException + */ + public StreamException getStreamException(); + + /** + * Initializes OpenGL related resources. + *

      + * Lifecycle: {@link State#Initialized} -> {@link State#Paused} or {@link State#Initialized} + *

      + * Argument gl is ignored if video is muted, see {@link #initStream(URI, int, int, int)}. * - * @throws IllegalStateException if not invoked in state Uninitialized - * @throws IOException in case of difficulties to open or process the stream + * @param gl current GL object. Maybe null, for audio only. + * @throws IllegalStateException if not invoked in {@link State#Initialized}. + * @throws IllegalArgumentException if arguments are invalid + * @throws StreamException forwarded from the off-thread stream initialization * @throws GLException in case of difficulties to initialize the GL resources */ - public State initGLStream(GL gl, int textureCount, URI streamLoc, int vid, int aid) throws IllegalStateException, GLException, IOException; + public void initGL(GL gl) throws IllegalStateException, IllegalArgumentException, StreamException, GLException; /** * If implementation uses a {@link AudioSink}, it's instance will be returned. *

      - * The {@link AudioSink} instance is available after {@link #initGLStream(GL, int, URI, int, int)}, + * The {@link AudioSink} instance is available after {@link #initStream(URI, int, int, int)}, * if used by implementation. *

      */ @@ -232,7 +344,7 @@ public interface GLMediaPlayer extends TextureSequence { /** * Releases the GL and stream resources. *

      - * GLMediaPlayer Lifecycle: ANY -> Uninitialized + * Lifecycle: ANY -> {@link State#Uninitialized} *

      */ public State destroy(GL gl); @@ -250,18 +362,18 @@ public interface GLMediaPlayer extends TextureSequence { public float getPlaySpeed(); /** - * GLMediaPlayer Lifecycle: Paused -> Playing + * Lifecycle: {@link State#Paused} -> {@link State#Playing} */ public State play(); /** - * GLMediaPlayer Lifecycle: Playing -> Paused + * Lifecycle: {@link State#Playing} -> {@link State#Paused} */ public State pause(); /** - * Allowed in state Playing and Paused, otherwise ignored, - * see GLMediaPlayer Lifecycle. + * Allowed in state {@link State#Playing} and {@link State#Paused}, otherwise ignored, + * see Lifecycle. * * @param msec absolute desired time position in milliseconds * @return time current position in milliseconds, after seeking to the desired position @@ -269,8 +381,8 @@ public interface GLMediaPlayer extends TextureSequence { public int seek(int msec); /** - * See GLMediaPlayer Lifecycle. - * @return the current state, either Uninitialized, Playing, Paused + * See Lifecycle. + * @return the current state, either {@link State#Uninitialized}, {@link State#Initialized}, {@link State#Playing} or {@link State#Paused} */ public State getState(); @@ -286,13 +398,13 @@ public interface GLMediaPlayer extends TextureSequence { /** * @return the current decoded frame count since {@link #play()} and {@link #seek(int)} - * as increased by {@link #getNextTexture(GL, boolean)} or the decoding thread. + * as increased by {@link #getNextTexture(GL)} or the decoding thread. */ public int getDecodedFrameCount(); /** * @return the current presented frame count since {@link #play()} and {@link #seek(int)} - * as increased by {@link #getNextTexture(GL, boolean)} for new frames. + * as increased by {@link #getNextTexture(GL)} for new frames. */ public int getPresentedFrameCount(); @@ -311,6 +423,7 @@ public interface GLMediaPlayer extends TextureSequence { *

      * See audio and video synchronization. *

      + * @throws IllegalStateException if not invoked in {@link State#Paused} or {@link State#Playing} */ @Override public TextureSequence.TextureFrame getLastTexture() throws IllegalStateException; @@ -324,14 +437,15 @@ public interface GLMediaPlayer extends TextureSequence { *

      * See audio and video synchronization. *

      + * @throws IllegalStateException if not invoked in {@link State#Paused} or {@link State#Playing} * * @see #addEventListener(GLMediaEventListener) * @see GLMediaEventListener#newFrameAvailable(GLMediaPlayer, TextureFrame, long) */ @Override - public TextureSequence.TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException; + public TextureSequence.TextureFrame getNextTexture(GL gl) throws IllegalStateException; - /** Return the stream location, as set by {@link #initGLStream(GL, int, URI, int, int)}. */ + /** Return the stream location, as set by {@link #initStream(URI, int, int, int)}. */ public URI getURI(); /** diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index f87df950c..578a219e9 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -31,6 +31,7 @@ import java.io.IOException; import javax.media.opengl.GL; import javax.media.opengl.GLES2; +import javax.media.opengl.GLException; import com.jogamp.common.os.AndroidVersion; import com.jogamp.common.os.Platform; @@ -179,14 +180,14 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { public final Surface getSurface() { return surface; } public String toString() { - return "SurfaceTextureFrame[" + pts + "ms: " + texture + ", " + surfaceTex + "]"; + return "SurfaceTextureFrame[pts " + pts + " ms, l " + duration + " ms, texID "+ texture.getTextureObject() + ", " + surfaceTex + "]"; } private final SurfaceTexture surfaceTex; private final Surface surface; } @Override - protected final void initGLStreamImpl(GL gl, int vid, int aid) throws IOException { + protected final void initStreamImpl(int vid, int aid) throws IOException { if(null!=mp && null!=streamLoc) { if( GLMediaPlayer.STREAM_ID_NONE == aid ) { mp.setVolume(0f, 0f); @@ -220,9 +221,13 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { 0, 0, mp.getDuration(), icodec, icodec); } } + @Override + protected final void initGLImpl(GL gl) throws IOException, GLException { + // NOP + } @Override - protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost) { + protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame) { if(null != stex && null != mp) { final SurfaceTextureFrame nextSFrame = (SurfaceTextureFrame) nextFrame; final Surface nextSurface = nextSFrame.getSurface(); @@ -232,7 +237,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { // Only block once, no while-loop. // This relaxes locking code of non crucial resources/events. boolean update = updateSurface; - if(!update && blocking) { + if( !update ) { synchronized(updateSurfaceLock) { if(!updateSurface) { // volatile OK. try { diff --git a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java index db2146cdc..ec375406d 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java @@ -69,7 +69,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { public final long getSync() { return sync; } public String toString() { - return "EGLTextureFrame[" + texture + ", img "+ image + ", sync "+ sync+", clientBuffer "+clientBuffer+"]"; + return "EGLTextureFrame[pts " + pts + " ms, l " + duration + " ms, texID "+ texture.getTextureObject() + ", img "+ image + ", sync "+ sync+", clientBuffer "+clientBuffer+"]"; } protected final Buffer clientBuffer; protected final long image; @@ -82,10 +82,6 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { this.texType = texType; this.useKHRSync = useKHRSync; } - @Override - protected final int validateTextureCount(int desiredTextureCount) { - return desiredTextureCount>2 ? Math.max(4, desiredTextureCount) : 2; - } @Override protected TextureSequence.TextureFrame createTexImage(GL gl, int texName) { diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index a82c84d17..8193175b7 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -43,6 +43,8 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.LFRingbuffer; +import com.jogamp.common.util.Ringbuffer; import com.jogamp.opengl.util.av.AudioSink; import com.jogamp.opengl.util.av.AudioSink.AudioFrame; import com.jogamp.opengl.util.av.GLMediaPlayer; @@ -65,9 +67,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected static final String unknown = "unknown"; - /** Default texture count w/o threading, value {@value}. */ - protected static final int TEXTURE_COUNT_DEFAULT = 2; - protected volatile State state; private Object stateLock = new Object(); @@ -86,33 +85,33 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected volatile float playSpeed = 1.0f; - /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int vid = GLMediaPlayer.STREAM_ID_AUTO; - /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int aid = GLMediaPlayer.STREAM_ID_AUTO; - /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int width = 0; - /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int height = 0; - /** Video avg. fps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Video avg. fps. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected float fps = 0; - /** Video avg. frame duration in ms. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Video avg. frame duration in ms. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected float frame_duration = 0f; - /** Stream bps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Stream bps. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int bps_stream = 0; - /** Video bps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Video bps. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int bps_video = 0; - /** Audio bps. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Audio bps. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int bps_audio = 0; - /** In frames. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** In frames. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int videoFrames = 0; - /** In frames. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** In frames. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int audioFrames = 0; - /** In ms. Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** In ms. Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected int duration = 0; - /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected String acodec = unknown; - /** Shall be set by the {@link #initGLStreamImpl(GL, int, int)} method implementation. */ + /** Shall be set by the {@link #initStreamImpl(int, int)} method implementation. */ protected String vcodec = unknown; protected volatile int decodedFrameCount = 0; @@ -120,7 +119,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected int displayedFrameCount = 0; protected volatile int video_pts_last = 0; - /** See {@link #getAudioSink()}. Set by implementation if used from within {@link #initGLStreamImpl(GL, int, int)}! */ + /** See {@link #getAudioSink()}. Set by implementation if used from within {@link #initStreamImpl(int, int)}! */ protected AudioSink audioSink = null; protected boolean audioSinkPlaySpeedSet = false; @@ -145,12 +144,20 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { /** Trigger video PTS reset with given cause as bitfield. */ private boolean videoSCR_reset = false; - protected SyncedRingbuffer videoFramesFree = null; - protected SyncedRingbuffer videoFramesDecoded = null; + protected TextureFrame[] videoFramesOrig = null; + protected Ringbuffer videoFramesFree = null; + protected Ringbuffer videoFramesDecoded = null; protected volatile TextureFrame lastFrame = null; private ArrayList eventListeners = new ArrayList(); + private static Ringbuffer.AllocEmptyArray rbAllocTextureFrameArray = new Ringbuffer.AllocEmptyArray() { + @Override + public TextureFrame[] newArray(int size) { + return new TextureFrame[size]; + } + }; + protected GLMediaPlayerImpl() { this.textureCount=0; this.textureTarget=GL.GL_TEXTURE_2D; @@ -186,11 +193,21 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final void setTextureWrapST(int[] wrapST) { texWrapST[0] = wrapST[0]; texWrapST[1] = wrapST[1];} public final int[] getTextureWrapST() { return texWrapST; } + private final void checkStreamInit() { + if(State.Uninitialized == state ) { + throw new IllegalStateException("Stream not initialized: "+this); + } + } + + private final void checkGLInit() { + if(State.Uninitialized == state || State.Initialized == state ) { + throw new IllegalStateException("GL not initialized: "+this); + } + } + @Override public String getRequiredExtensionsShaderStub() throws IllegalStateException { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); - } + checkGLInit(); if(GLES2.GL_TEXTURE_EXTERNAL_OES == textureTarget) { return TextureSequence.GL_OES_EGL_image_external_Required_Prelude; } @@ -199,9 +216,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public String getTextureSampler2DType() throws IllegalStateException { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); - } + checkGLInit(); switch(textureTarget) { case GL.GL_TEXTURE_2D: case GL2.GL_TEXTURE_RECTANGLE: @@ -221,9 +236,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { */ @Override public String getTextureLookupFunctionName(String desiredFuncName) throws IllegalStateException { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); - } + checkGLInit(); return "texture2D"; } @@ -236,9 +249,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { */ @Override public String getTextureLookupFragmentShaderImpl() throws IllegalStateException { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); - } + checkGLInit(); return ""; } @@ -246,7 +257,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final int getDecodedFrameCount() { return decodedFrameCount; } @Override - public final int getPresentedFrameCount() { return this.presentedFrameCount; } + public final int getPresentedFrameCount() { return presentedFrameCount; } @Override public final int getVideoPTS() { return video_pts_last; } @@ -267,20 +278,21 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } + @Override public final State getState() { return state; } + @Override public final State play() { synchronized( stateLock ) { switch( state ) { case Paused: if( playImpl() ) { - // FIXME resetAudioVideoPTS(); if( null != audioSink ) { audioSink.play(); // cont. w/ new data - } - resumeFramePusher(); - state = State.Playing; + } + streamWorker.doResume(); + changeState(0, State.Playing); } default: } @@ -290,15 +302,20 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } protected abstract boolean playImpl(); + @Override public final State pause() { + return pauseImpl(0); + } + private final State pauseImpl(int event_mask) { synchronized( stateLock ) { if( State.Playing == state ) { + event_mask = addStateEventMask(event_mask, GLMediaPlayer.State.Paused); state = State.Paused; - // FIXME - pauseFramePusher(); + streamWorker.doPause(); if( null != audioSink ) { audioSink.pause(); } + attributesUpdated( event_mask ); if( !pauseImpl() ) { play(); } @@ -309,6 +326,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } protected abstract boolean pauseImpl(); + @Override public final int seek(int msec) { synchronized( stateLock ) { final int pts1; @@ -317,14 +335,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { case Paused: final State _state = state; state = State.Paused; - // FIXME - pauseFramePusher(); + streamWorker.doPause(); pts1 = seekImpl(msec); resetAllAudioVideoSync(); if( null != audioSink && State.Playing == _state ) { audioSink.play(); // cont. w/ new data } - resumeFramePusher(); + System.err.println("SEEK XXX: "+getPerfString()); + streamWorker.doResume(); state = _state; break; default: @@ -378,41 +396,31 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } @Override - public final State initGLStream(GL gl, int reqTextureCount, URI streamLoc, int vid, int aid) throws IllegalStateException, GLException, IOException { + public final void initStream(URI streamLoc, int vid, int aid, int reqTextureCount) throws IllegalStateException, IllegalArgumentException { synchronized( stateLock ) { if(State.Uninitialized != state) { - throw new IllegalStateException("Instance not in state "+State.Uninitialized+", but "+state+", "+this); + throw new IllegalStateException("Instance not unintialized: "+this); + } + if(null == streamLoc) { + throw new IllegalArgumentException("streamLock is null"); + } + if( STREAM_ID_NONE != vid ) { + textureCount = validateTextureCount(reqTextureCount); + if( textureCount < TEXTURE_COUNT_MIN ) { + throw new InternalError("Validated texture count < "+TEXTURE_COUNT_MIN+": "+textureCount); + } + } else { + textureCount = 0; } decodedFrameCount = 0; presentedFrameCount = 0; - displayedFrameCount = 0; + displayedFrameCount = 0; this.streamLoc = streamLoc; + this.vid = vid; + this.aid = aid; if (this.streamLoc != null) { - try { - if( null != gl ) { - removeAllTextureFrames(gl); - textureCount = validateTextureCount(reqTextureCount); - if( textureCount < TEXTURE_COUNT_DEFAULT ) { - throw new InternalError("Validated texture count < "+TEXTURE_COUNT_DEFAULT+": "+textureCount); - } - initGLStreamImpl(gl, vid, aid); // also initializes width, height, .. etc - videoFramesFree = new SyncedRingbuffer(createTexFrames(gl, textureCount), true /* full */); - if( TEXTURE_COUNT_DEFAULT < textureCount ) { - videoFramesDecoded = new SyncedRingbuffer(new TextureFrame[textureCount], false /* full */); - framePusher = new FramePusher(gl); - framePusher.doStart(); - } else { - videoFramesDecoded = null; - } - lastFrame = videoFramesFree.getBlocking(false /* clearRef */ ); - state = State.Paused; - } - return state; - } catch (Throwable t) { - throw new GLException("Error initializing GL resources", t); - } + streamWorker = new StreamWorker(); } - return state; } } /** @@ -428,19 +436,62 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { * @see #acodec * @see #vcodec */ - protected abstract void initGLStreamImpl(GL gl, int vid, int aid) throws IOException; + protected abstract void initStreamImpl(int vid, int aid) throws Exception; + + @Override + public final StreamException getStreamException() { + synchronized( stateLock ) { + if( null != streamWorker ) { + return streamWorker.getStreamErr(); + } else { + return null; + } + } + } + + @Override + public final void initGL(GL gl) throws IllegalStateException, StreamException, GLException { + synchronized( stateLock ) { + checkStreamInit(); + final StreamException streamInitErr = streamWorker.getStreamErr(); + if( null != streamInitErr ) { + streamWorker = null; + destroy(null); + throw streamInitErr; + } + try { + if( STREAM_ID_NONE != vid ) { + removeAllTextureFrames(gl); + initGLImpl(gl); + videoFramesOrig = createTexFrames(gl, textureCount); + videoFramesFree = new LFRingbuffer(videoFramesOrig, rbAllocTextureFrameArray); + videoFramesDecoded = new LFRingbuffer(textureCount, rbAllocTextureFrameArray); + lastFrame = videoFramesFree.getBlocking( ); + streamWorker.initGL(gl); + } else { + initGLImpl(null); + setTextureFormat(-1, -1); + setTextureType(-1); + videoFramesFree = null; + videoFramesDecoded = null; + lastFrame = null; + } + changeState(0, State.Paused); + } catch (Throwable t) { + throw new GLException("Error initializing GL resources", t); + } + } + } + protected abstract void initGLImpl(GL gl) throws IOException, GLException; /** * Returns the validated number of textures to be handled. *

      - * Default is 2 textures w/o threading, last texture and the decoding texture. - *

      - *

      - * > 2 textures is used for threaded decoding, a minimum of 4 textures seems reasonable in this case. + * Default is {@link #TEXTURE_COUNT_MIN} textures, last texture and the decoding texture. *

      */ protected int validateTextureCount(int desiredTextureCount) { - return TEXTURE_COUNT_DEFAULT; + return desiredTextureCount < TEXTURE_COUNT_MIN ? TEXTURE_COUNT_MIN : desiredTextureCount; } private final TextureFrame[] createTexFrames(GL gl, final int count) { @@ -512,42 +563,43 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final TextureFrame getLastTexture() throws IllegalStateException { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); + if( State.Paused != state && State.Playing != state ) { + throw new IllegalStateException("Instance not paused or playing: "+this); } return lastFrame; } private final void removeAllTextureFrames(GL gl) { - if( null != videoFramesFree ) { - final TextureFrame[] texFrames = videoFramesFree.getArray(); + if( null != videoFramesOrig ) { + final TextureFrame[] texFrames = videoFramesOrig; + videoFramesOrig = null; videoFramesFree = null; videoFramesDecoded = null; lastFrame = null; for(int i=0; i Clear TexFrame["+i+"]: "+frame+" -> null"); } } - textureCount=0; } protected TextureFrame cachedFrame = null; protected long lastTimeMillis = 0; @Override - public final TextureFrame getNextTexture(GL gl, boolean blocking) throws IllegalStateException { + public final TextureFrame getNextTexture(GL gl) throws IllegalStateException { synchronized( stateLock ) { - if(State.Uninitialized == state) { - throw new IllegalStateException("Instance not initialized: "+this); + if( State.Paused != state && State.Playing != state ) { + throw new IllegalStateException("Instance not paused or playing: "+this); } if(State.Playing == state) { TextureFrame nextFrame = null; - boolean ok = true; boolean dropFrame = false; try { do { @@ -561,23 +613,16 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { nextFrame = cachedFrame; cachedFrame = null; presentedFrameCount--; - currentTimeMillis = Platform.currentTimeMillis(); - } else if( TEXTURE_COUNT_DEFAULT < textureCount ) { - nextFrame = videoFramesDecoded.getBlocking(false /* clearRef */ ); - currentTimeMillis = Platform.currentTimeMillis(); - } else { - nextFrame = videoFramesFree.getBlocking(false /* clearRef */ ); - nextFrame.setPTS( TextureFrame.INVALID_PTS ); // mark invalid until processed! - ok = getNextTextureImpl(gl, nextFrame, blocking, true /* issuePreAndPost */); - currentTimeMillis = Platform.currentTimeMillis(); - if( ok ) { - newFrameAvailable(nextFrame, currentTimeMillis); - } + } else if( STREAM_ID_NONE != vid ) { + nextFrame = videoFramesDecoded.getBlocking(); } - if( ok ) { + currentTimeMillis = Platform.currentTimeMillis(); + if( null != nextFrame ) { presentedFrameCount++; final int video_pts = nextFrame.getPTS(); - if( video_pts != TextureFrame.INVALID_PTS ) { + if( video_pts == TextureFrame.END_OF_STREAM_PTS ) { + pauseImpl(GLMediaEventListener.EVENT_CHANGE_EOS); + } else if( video_pts != TextureFrame.INVALID_PTS ) { final int audio_pts = getAudioPTSImpl(); final int audio_scr = (int) ( ( currentTimeMillis - audio_scr_t0 ) * playSpeed ); final int d_apts; @@ -613,6 +658,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final int dt = (int) ( video_dpts_avg_diff / playSpeed + 0.5f ); // final int dt = (int) ( d_vpts / playSpeed + 0.5f ); // final int dt = (int) ( d_avpts / playSpeed + 0.5f ); + final TextureFrame _nextFrame = nextFrame; if( dt > maxVideoDelay ) { cachedFrame = nextFrame; nextFrame = null; @@ -625,7 +671,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { getPerfStringImpl( video_scr, video_pts, d_vpts, audio_scr, audio_pts, d_apts, video_dpts_avg_diff ) + - ", avg dpy-fps "+avg_dpy_duration+" ms/f, maxD "+maxVideoDelay+" ms, "+nextFrame+", playCached " + playCached + ", dropFrame "+dropFrame); + ", avg dpy-fps "+avg_dpy_duration+" ms/f, maxD "+maxVideoDelay+" ms, "+_nextFrame+", playCached " + playCached + ", dropFrame "+dropFrame); } } } else if( DEBUG ) { @@ -640,14 +686,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { lastTimeMillis = currentTimeMillis; } while( dropFrame ); } catch (InterruptedException e) { - ok = false; e.printStackTrace(); - } finally { - if( !ok && null != nextFrame ) { // put back - if( !videoFramesFree.put(nextFrame) ) { - throw new InternalError("XXX: free "+videoFramesFree+", decoded "+videoFramesDecoded+", "+GLMediaPlayerImpl.this); - } - } } } displayedFrameCount++; @@ -656,8 +695,13 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } protected void preNextTextureImpl(GL gl) {} protected void postNextTextureImpl(GL gl) {} - protected abstract boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost); - protected boolean syncAVRequired() { return false; } + /** + * Implementation shall care of OpenGL synchronization as required, e.g. glFinish()/glFlush()! + * @param gl + * @param nextFrame + * @return + */ + protected abstract boolean getNextTextureImpl(GL gl, TextureFrame nextFrame); /** * {@inheritDoc} @@ -667,7 +711,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { *

      *

      * Implementations using an {@link AudioSink} shall write it's instance to {@link #audioSink} - * from within their {@link #initGLStreamImpl(GL, int, int)} implementation. + * from within their {@link #initStreamImpl(int, int)} implementation. *

      */ @Override @@ -686,12 +730,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } private void flushAllVideoFrames() { if( null != videoFramesFree ) { - videoFramesFree.reset(true); + videoFramesFree.resetFull(videoFramesOrig); } if( null != videoFramesDecoded ) { - videoFramesDecoded.reset(false); + videoFramesDecoded.clear(); } - lastFrame = videoFramesFree.get(false /* clearRef */ ); + lastFrame = videoFramesFree.get( ); if( null == lastFrame ) { throw new InternalError("XXX"); } cachedFrame = null; } @@ -727,7 +771,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } - class FramePusher extends Thread { + class StreamWorker extends Thread { private volatile boolean isRunning = false; private volatile boolean isActive = false; private volatile boolean isBlocked = false; @@ -735,28 +779,21 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private volatile boolean shallPause = true; private volatile boolean shallStop = false; - private final GL gl; + private volatile StreamException streamErr = null; + private volatile GLContext sharedGLCtx = null; + private boolean sharedGLCtxCurrent = false; private GLDrawable dummyDrawable = null; - private GLContext sharedGLCtx = null; - FramePusher(GL gl) { + /** + * Starts this daemon thread, + * which initializes the stream first via {@link GLMediaPlayerImpl#initStreamImpl(int, int)} first. + *

      + * After stream initialization, this thread pauses! + *

      + **/ + StreamWorker() { setDaemon(true); - - final GLContext glCtx = gl.getContext(); - final boolean glCtxCurrent = glCtx.isCurrent(); - final GLProfile glp = gl.getGLProfile(); - final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - final AbstractGraphicsDevice device = glCtx.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); - dummyDrawable = factory.createDummyDrawable(device, true, glp); // own device! - dummyDrawable.setRealized(true); - sharedGLCtx = dummyDrawable.createContext(glCtx); - makeCurrent(sharedGLCtx); - if( glCtxCurrent ) { - makeCurrent(glCtx); - } else { - sharedGLCtx.release(); - } - this.gl = sharedGLCtx.getGL(); + start(); } private void makeCurrent(GLContext ctx) { @@ -767,7 +804,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private void destroySharedGL() { if( null != sharedGLCtx ) { - postNextTextureImpl(gl); if( sharedGLCtx.isCreated() ) { // Catch dispose GLExceptions by GLEventListener, just 'print' them // so we can continue with the destruction. @@ -787,6 +823,22 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } + public synchronized void initGL(GL gl) { + final GLContext glCtx = gl.getContext(); + final boolean glCtxCurrent = glCtx.isCurrent(); + final GLProfile glp = gl.getGLProfile(); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); + final AbstractGraphicsDevice device = glCtx.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); + dummyDrawable = factory.createDummyDrawable(device, true, glp); // own device! + dummyDrawable.setRealized(true); + sharedGLCtx = dummyDrawable.createContext(glCtx); + makeCurrent(sharedGLCtx); + if( glCtxCurrent ) { + makeCurrent(glCtx); + } else { + sharedGLCtx.release(); + } + } public synchronized void doPause() { if( isActive ) { shallPause = true; @@ -815,16 +867,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - public synchronized void doStart() { - start(); - while( !isRunning ) { - try { - this.wait(); // wait until started - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - } public synchronized void doStop() { if( isRunning ) { shallStop = true; @@ -843,28 +885,38 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } public boolean isRunning() { return isRunning; } public boolean isActive() { return isActive; } + public StreamException getStreamErr() { return streamErr; } public void run() { - setName(getName()+"-FramePusher_"+FramePusherInstanceId); - FramePusherInstanceId++; + setName(getName()+"-StreamWorker_"+StreamWorkerInstanceId); + StreamWorkerInstanceId++; synchronized ( this ) { - makeCurrent( sharedGLCtx ); - preNextTextureImpl(gl); isRunning = true; - this.notify(); // wake-up doStart() + try { + isBlocked = true; + initStreamImpl(vid, aid); + isBlocked = false; + } catch (Throwable t) { + streamErr = new StreamException(t.getClass().getSimpleName()+" while initializing: "+GLMediaPlayerImpl.this.toString(), t); + isBlocked = false; + isRunning = false; + changeState(GLMediaEventListener.EVENT_CHANGE_ERR, GLMediaPlayer.State.Uninitialized); + return; // end of thread! + } // also initializes width, height, .. etc } while( !shallStop ){ if( shallPause ) { synchronized ( this ) { - postNextTextureImpl(gl); - sharedGLCtx.release(); + if( sharedGLCtxCurrent ) { + postNextTextureImpl(sharedGLCtx.getGL()); + sharedGLCtx.release(); + } while( shallPause && !shallStop ) { isActive = false; this.notify(); // wake-up doPause() try { - System.err.println("!!! PAUSE ON"); // FIXME this.wait(); // wait until resumed } catch (InterruptedException e) { if( !shallPause ) { @@ -872,70 +924,119 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - makeCurrent(sharedGLCtx); - preNextTextureImpl(gl); - System.err.println("!!! PAUSE OFF"); // FIXME + if( sharedGLCtxCurrent ) { + makeCurrent(sharedGLCtx); + preNextTextureImpl(sharedGLCtx.getGL()); + } isActive = true; this.notify(); // wake-up doResume() } } + if( !sharedGLCtxCurrent && null != sharedGLCtx ) { + synchronized ( this ) { + if( null != sharedGLCtx ) { + makeCurrent( sharedGLCtx ); + preNextTextureImpl(sharedGLCtx.getGL()); + sharedGLCtxCurrent = true; + } + } + } if( !shallStop ) { TextureFrame nextFrame = null; - try { - isBlocked = true; - nextFrame = videoFramesFree.getBlocking(false /* clearRef */ ); - isBlocked = false; - nextFrame.setPTS( TextureFrame.INVALID_PTS ); // mark invalid until processed! - if( getNextTextureImpl(gl, nextFrame, true, false /* issuePreAndPost */) ) { - // gl.glFinish(); - gl.glFlush(); // even better: sync object! - if( !videoFramesDecoded.put(nextFrame) ) { - throw new InternalError("XXX: free "+videoFramesFree+", decoded "+videoFramesDecoded+", "+GLMediaPlayerImpl.this); + if( null != sharedGLCtx ) { + try { + isBlocked = true; + nextFrame = videoFramesFree.getBlocking( ); + isBlocked = false; + nextFrame.setPTS( TextureFrame.INVALID_PTS ); // mark invalid until processed! + final GL gl = sharedGLCtxCurrent ? sharedGLCtx.getGL() : null; + if( getNextTextureImpl(gl, nextFrame) ) { + if( !videoFramesDecoded.put(nextFrame) ) { + throw new InternalError("XXX: free "+videoFramesFree+", decoded "+videoFramesDecoded+", "+GLMediaPlayerImpl.this); + } + newFrameAvailable(nextFrame, Platform.currentTimeMillis()); + nextFrame = null; + } + } catch (InterruptedException e) { + isBlocked = false; + if( !shallStop && !shallPause ) { + streamErr = new StreamException("InterruptedException while decoding: "+GLMediaPlayerImpl.this.toString(), e); + } + } catch (Throwable t) { + streamErr = new StreamException(t.getClass().getSimpleName()+" while decoding: "+GLMediaPlayerImpl.this.toString(), t); + } finally { + if( null != nextFrame ) { // put back + videoFramesFree.put(nextFrame); + } + if( null != streamErr ) { + if( DEBUG ) { + final Throwable t = null != streamErr.getCause() ? streamErr.getCause() : streamErr; + System.err.println("Caught StreamException: "+t.getMessage()); + t.printStackTrace(); + } + // state transition incl. notification + shallPause = true; + isActive = false; + pause(); } - newFrameAvailable(nextFrame, Platform.currentTimeMillis()); - nextFrame = null; - } - } catch (InterruptedException e) { - isBlocked = false; - if( !shallStop && !shallPause ) { - e.printStackTrace(); // oops - shallPause = false; - shallStop = true; - } - } finally { - if( null != nextFrame ) { // put back - videoFramesFree.put(nextFrame); } + } else { + // audio only + getNextTextureImpl(null, null); } } } - postNextTextureImpl(gl); - destroySharedGL(); synchronized ( this ) { + if( sharedGLCtxCurrent ) { + postNextTextureImpl(sharedGLCtx.getGL()); + } + destroySharedGL(); isRunning = false; isActive = false; this.notify(); // wake-up doStop() } } } - static int FramePusherInstanceId = 0; - private FramePusher framePusher = null; - - private final void pauseFramePusher() { - if( null != framePusher ) { - framePusher.doPause(); + static int StreamWorkerInstanceId = 0; + private StreamWorker streamWorker = null; + + protected final int addStateEventMask(int event_mask, State newState) { + if( state != newState ) { + switch( newState ) { + case Uninitialized: + event_mask |= GLMediaEventListener.EVENT_CHANGE_UNINIT; + break; + case Initialized: + event_mask |= GLMediaEventListener.EVENT_CHANGE_INIT; + break; + case Playing: + event_mask |= GLMediaEventListener.EVENT_CHANGE_PLAY; + break; + case Paused: + event_mask |= GLMediaEventListener.EVENT_CHANGE_PAUSE; + break; + } } + return event_mask; } - private final void resumeFramePusher() { - if( null != framePusher ) { - framePusher.doResume(); + + protected final void attributesUpdated(int event_mask) { + if( 0 != event_mask ) { + final long now = Platform.currentTimeMillis(); + synchronized(eventListenersLock) { + for(Iterator i = eventListeners.iterator(); i.hasNext(); ) { + i.next().attributesChanged(this, event_mask, now); + } + } } } - private final void destroyFramePusher() { - if( null != framePusher ) { - framePusher.doStop(); - framePusher = null; + + protected final void changeState(int event_mask, State newState) { + event_mask = addStateEventMask(event_mask, newState); + if( 0 != event_mask ) { + state = newState; + attributesUpdated( event_mask ); } } @@ -943,10 +1044,20 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { int bps_video, int bps_audio, float fps, int videoFrames, int audioFrames, int duration, String vcodec, String acodec) { int event_mask = 0; + if( state == State.Uninitialized ) { + event_mask |= GLMediaEventListener.EVENT_CHANGE_INIT; + state = State.Initialized; + } + if( STREAM_ID_AUTO == vid ) { + vid = STREAM_ID_NONE; + } if( this.vid != vid ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_VID; this.vid = vid; } + if( STREAM_ID_AUTO == vid ) { + vid = STREAM_ID_NONE; + } if( this.aid != aid ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_AID; this.aid = aid; @@ -984,30 +1095,24 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if(0==event_mask) { return; } - attributesUpdated(event_mask); + attributesUpdated(event_mask); } - protected final void attributesUpdated(int event_mask) { - synchronized(eventListenersLock) { - for(Iterator i = eventListeners.iterator(); i.hasNext(); ) { - i.next().attributesChanges(this, event_mask, Platform.currentTimeMillis()); - } - } - } - @Override public final State destroy(GL gl) { synchronized( stateLock ) { - destroyFramePusher(); + streamWorker.doStop(); + streamWorker = null; destroyImpl(gl); removeAllTextureFrames(gl); + textureCount=0; if( null != videoFramesFree ) { videoFramesFree.clear(); } if( null != videoFramesDecoded ) { videoFramesDecoded.clear(); } - state = State.Uninitialized; + changeState(0, State.Uninitialized); return state; } } @@ -1039,6 +1144,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { return videoFrames; } + @Override public final int getAudioFrames() { return audioFrames; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index ad8587e6b..31ac55ec3 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -32,6 +32,7 @@ import java.net.URLConnection; import java.nio.ByteBuffer; import javax.media.opengl.GL; +import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import jogamp.opengl.util.av.GLMediaPlayerImpl; @@ -82,7 +83,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost) { + protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame) { nextFrame.setPTS( getAudioPTSImpl() ); return true; } @@ -103,7 +104,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final void initGLStreamImpl(GL gl, int vid, int aid) throws IOException { + protected final void initStreamImpl(int vid, int aid) throws IOException { try { URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader()); if(null != urlConn) { @@ -137,6 +138,10 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { _w, _h, 0, 0, 0, _fps, _totalFrames, 0, _duration, "png-static", null); + } + @Override + protected final void initGLImpl(GL gl) throws IOException, GLException { + // NOP } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index cf864daa2..8865d47be 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -59,7 +59,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { private static final List glueLibNames = new ArrayList(); // none - private static final int symbolCount = 38; + private static final int symbolCount = 42; private static final String[] symbolNames = { "avcodec_version", "avformat_version", @@ -71,22 +71,26 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avcodec_find_decoder", "avcodec_open2", // 53.6.0 (opt) "avcodec_open", - "avcodec_alloc_frame", + "avcodec_alloc_frame", + "avcodec_get_frame_defaults", + "avcodec_free_frame", // 54.28.0 (opt) "avcodec_default_get_buffer", "avcodec_default_release_buffer", + "avcodec_flush_buffers", "av_init_packet", "av_new_packet", "av_destruct_packet", "av_free_packet", "avcodec_decode_audio4", // 53.25.0 (opt) "avcodec_decode_audio3", // 52.23.0 -/* 18 */ "avcodec_decode_video2", // 52.23.0 +/* 21 */ "avcodec_decode_video2", // 52.23.0 // libavutil - "av_pix_fmt_descriptors", - "av_free", + "av_pix_fmt_descriptors", + "av_frame_unref", // 55.0.0 (opt) + "av_free", "av_get_bits_per_pixel", -/* 22 */ "av_samples_get_buffer_size", +/* 26 */ "av_samples_get_buffer_size", // libavformat "avformat_alloc_context", @@ -98,13 +102,13 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "av_dump_format", "av_read_frame", "av_seek_frame", - "avformat_seek_file", + "avformat_seek_file", // ??? (opt) "av_read_play", "av_read_pause", "avformat_network_init", // 53.13.0 (opt) "avformat_network_deinit", // 53.13.0 (opt) "avformat_find_stream_info", // 53.3.0 (opt) -/* 38 */ "av_find_stream_info", +/* 42 */ "av_find_stream_info", }; // alternate symbol names @@ -120,6 +124,9 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avformat_free_context", // 52.96.0 (opt) "avformat_network_init", // 53.13.0 (opt) "avformat_network_deinit", // 53.13.0 (opt) + "avformat_seek_file", // ??? (opt) + "avcodec_free_frame", // 54.28.0 (opt) + "av_frame_unref", // 55.0.0 (opt) }; private static long[] symbolAddr; diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 9838181ab..11073b2e3 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -108,14 +108,14 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { /** POSIX ENOSYS {@value}: Function not implemented. FIXME: Move to GlueGen ?!*/ private static final int ENOSYS = 38; - /** Count of zeroed buffers to return before switching to real sample provider */ - private static final int TEMP_BUFFER_COUNT = 20; + /** Default number of audio frames per video frame */ + private static final int AV_DEFAULT_AFRAMES = 8; // Instance data - public static final VersionNumber avUtilVersion; - public static final VersionNumber avFormatVersion; - public static final VersionNumber avCodecVersion; - static final boolean available; + private static final VersionNumber avUtilVersion; + private static final VersionNumber avFormatVersion; + private static final VersionNumber avCodecVersion; + private static final boolean available; static { final boolean libAVGood = FFMPEGDynamicLibraryBundleInfo.initSingleton(); @@ -146,31 +146,33 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { // General // - protected long moviePtr = 0; + private long moviePtr = 0; // // Video // - protected PixelFormat vPixelFmt = null; - protected int vPlanes = 0; - protected int vBitsPerPixel = 0; - protected int vBytesPerPixelPerPlane = 0; - protected int[] vLinesize = { 0, 0, 0 }; // per plane - protected int[] vTexWidth = { 0, 0, 0 }; // per plane - protected int texWidth, texHeight; // overall (stuffing planes in one texture) - protected String singleTexComp = "r"; - protected GLPixelStorageModes psm; + private PixelFormat vPixelFmt = null; + private int vPlanes = 0; + private int vBitsPerPixel = 0; + private int vBytesPerPixelPerPlane = 0; + private int[] vLinesize = { 0, 0, 0 }; // per plane + private int[] vTexWidth = { 0, 0, 0 }; // per plane + private int texWidth, texHeight; // overall (stuffing planes in one texture) + private String singleTexComp = "r"; + private GLPixelStorageModes psm; // // Audio // - protected static final int AFRAMES_PER_VFRAME = 8; - protected int aFrameCount = 0; - protected SampleFormat aSampleFmt = null; - protected AudioSink.AudioDataFormat avChosenAudioFormat; - protected AudioSink.AudioDataFormat sinkChosenAudioFormat; + /** Initial audio frame count, ALAudioSink may grow buffer! */ + private int initialAudioFrameCount = AV_DEFAULT_AFRAMES; + private final int audioFrameGrowAmount = 8; + private final int audioFrameLimit = 128; + private SampleFormat aSampleFmt = null; + private AudioSink.AudioDataFormat avChosenAudioFormat; + private AudioSink.AudioDataFormat sinkChosenAudioFormat; public FFMPEGMediaPlayer() { if(!available) { @@ -183,10 +185,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { psm = new GLPixelStorageModes(); audioSink = null; } - @Override - protected final int validateTextureCount(int desiredTextureCount) { - return desiredTextureCount>2 ? Math.max(4, desiredTextureCount) : 2; - } @Override protected final void destroyImpl(GL gl) { @@ -205,101 +203,108 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final void initGLStreamImpl(GL gl, int vid, int aid) throws IOException { + protected final void initStreamImpl(int vid, int aid) throws IOException { if(0==moviePtr) { throw new GLException("FFMPEG native instance null"); } - { - final GLContextImpl ctx = (GLContextImpl)gl.getContext(); - final ProcAddressTable pt = ctx.getGLProcAddressTable(); - final long procAddrGLTexSubImage2D = getAddressFor(pt, "glTexSubImage2D"); - if( 0 == procAddrGLTexSubImage2D ) { - throw new InternalError("glTexSubImage2D n/a in ProcAddressTable: "+pt.getClass().getName()+" of "+ctx.getGLVersion()); - } - final long procAddrGLGetError = getAddressFor(pt, "glGetError"); - if( 0 == procAddrGLGetError ) { - throw new InternalError("glGetError n/a in ProcAddressTable: "+pt.getClass().getName()+" of "+ctx.getGLVersion()); - } - setGLFuncs0(moviePtr, procAddrGLTexSubImage2D, procAddrGLGetError); - } - - final String streamLocS=streamLoc.toString(); - - aFrameCount = AFRAMES_PER_VFRAME * textureCount + AFRAMES_PER_VFRAME/2; - if(DEBUG) { - System.err.println("initGLStream: p1 "+this); + System.err.println("initStream: p1 "+this); } + + final String streamLocS=streamLoc.toString(); destroyAudioSink(); - AudioSink _audioSink; if( GLMediaPlayer.STREAM_ID_NONE == aid ) { - _audioSink = AudioSinkFactory.createNull(); + audioSink = AudioSinkFactory.createNull(); } else { - _audioSink = AudioSinkFactory.createDefault(); + audioSink = AudioSinkFactory.createDefault(); } - final AudioDataFormat preferredAudioFormat = _audioSink.getPreferredFormat(); - // setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc - setStream0(moviePtr, streamLocS, vid, aid, aFrameCount, preferredAudioFormat.channelCount, preferredAudioFormat.sampleRate); - // final int audioBytesPerFrame = bps_audio/8000 * frame_period * textureCount; - + final AudioDataFormat preferredAudioFormat = audioSink.getPreferredFormat(); if(DEBUG) { - System.err.println("initGLStream: p2 preferred "+preferredAudioFormat+", avChosen "+avChosenAudioFormat+", "+this); + System.err.println("initStream: p2 preferred "+preferredAudioFormat+", "+this); + } + // setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc + final int snoopVideoFrameCount = 0; // 10*textureCount + setStream0(moviePtr, streamLocS, vid, aid, snoopVideoFrameCount, preferredAudioFormat.channelCount, preferredAudioFormat.sampleRate); + } + + @Override + protected final void initGLImpl(GL gl) throws IOException, GLException { + if(0==moviePtr) { + throw new GLException("FFMPEG native instance null"); + } + if(null == audioSink) { + throw new GLException("AudioSink null"); } - sinkChosenAudioFormat = _audioSink.initSink(avChosenAudioFormat, aFrameCount); + if( null != gl ) { + final GLContextImpl ctx = (GLContextImpl)gl.getContext(); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + final ProcAddressTable pt = ctx.getGLProcAddressTable(); + final long procAddrGLTexSubImage2D = pt.getAddressFor("glTexSubImage2D"); + final long procAddrGLGetError = pt.getAddressFor("glGetError"); + final long procAddrGLFlush = pt.getAddressFor("glFlush"); + final long procAddrGLFinish = pt.getAddressFor("glFinish"); + setGLFuncs0(moviePtr, procAddrGLTexSubImage2D, procAddrGLGetError, procAddrGLFlush, procAddrGLFinish); + return null; + } } ); + } + + sinkChosenAudioFormat = audioSink.initSink(avChosenAudioFormat, initialAudioFrameCount, audioFrameGrowAmount, audioFrameLimit); if(DEBUG) { - System.err.println("initGLStream: p3 avChosen "+avChosenAudioFormat+", chosen "+sinkChosenAudioFormat); + System.err.println("initGL: p3 avChosen "+avChosenAudioFormat+", chosen "+sinkChosenAudioFormat); } if( null == sinkChosenAudioFormat ) { - System.err.println("AudioSink "+_audioSink.getClass().getName()+" does not support "+avChosenAudioFormat+", using Null"); - _audioSink.destroy(); - _audioSink = AudioSinkFactory.createNull(); - sinkChosenAudioFormat = _audioSink.initSink(avChosenAudioFormat, aFrameCount); + System.err.println("AudioSink "+audioSink.getClass().getName()+" does not support "+avChosenAudioFormat+", using Null"); + audioSink.destroy(); + audioSink = AudioSinkFactory.createNull(); + sinkChosenAudioFormat = audioSink.initSink(avChosenAudioFormat, initialAudioFrameCount, audioFrameGrowAmount, audioFrameLimit); } - audioSink = _audioSink; - int tf, tif=GL.GL_RGBA; // texture format and internal format - switch(vBytesPerPixelPerPlane) { - case 1: - if( gl.isGL3ES3() ) { - // RED is supported on ES3 and >= GL3 [core]; ALPHA is deprecated on core - tf = GL2ES2.GL_RED; tif=GL2ES2.GL_RED; singleTexComp = "r"; - } else { - // ALPHA is supported on ES2 and GL2, i.e. <= GL3 [core] or compatibility - tf = GL2ES2.GL_ALPHA; tif=GL2ES2.GL_ALPHA; singleTexComp = "a"; - } - break; - case 3: tf = GL2ES2.GL_RGB; tif=GL.GL_RGB; break; - case 4: tf = GL2ES2.GL_RGBA; tif=GL.GL_RGBA; break; - default: throw new RuntimeException("Unsupported bytes-per-pixel / plane "+vBytesPerPixelPerPlane); - } - setTextureFormat(tif, tf); - setTextureType(GL.GL_UNSIGNED_BYTE); - } + if( null != gl ) { + int tf, tif=GL.GL_RGBA; // texture format and internal format + switch(vBytesPerPixelPerPlane) { + case 1: + if( gl.isGL3ES3() ) { + // RED is supported on ES3 and >= GL3 [core]; ALPHA is deprecated on core + tf = GL2ES2.GL_RED; tif=GL2ES2.GL_RED; singleTexComp = "r"; + } else { + // ALPHA is supported on ES2 and GL2, i.e. <= GL3 [core] or compatibility + tf = GL2ES2.GL_ALPHA; tif=GL2ES2.GL_ALPHA; singleTexComp = "a"; + } + break; + case 3: tf = GL2ES2.GL_RGB; tif=GL.GL_RGB; break; + case 4: tf = GL2ES2.GL_RGBA; tif=GL.GL_RGBA; break; + default: throw new RuntimeException("Unsupported bytes-per-pixel / plane "+vBytesPerPixelPerPlane); + } + setTextureFormat(tif, tf); + setTextureType(GL.GL_UNSIGNED_BYTE); + } + } @Override protected final TextureFrame createTexImage(GL gl, int texName) { return new TextureFrame( createTexImageImpl(gl, texName, texWidth, texHeight, true) ); } /** - * Catches IllegalArgumentException and returns 0 if functionName is n/a, - * otherwise the ProcAddressTable's field value. + * @param pixFmt + * @param planes + * @param bitsPerPixel + * @param bytesPerPixelPerPlane + * @param lSz0 + * @param lSz1 + * @param lSz2 + * @param tWd0 + * @param tWd1 + * @param tWd2 + * @param audioFrameCount snooped audio-frame-count per video-frame, maybe 0 + * @param sampleFmt + * @param sampleRate + * @param channels */ - private final long getAddressFor(final ProcAddressTable table, final String functionName) { - return AccessController.doPrivileged(new PrivilegedAction() { - public Long run() { - try { - return Long.valueOf( table.getAddressFor(functionName) ); - } catch (IllegalArgumentException iae) { - return Long.valueOf(0); - } - } - } ).longValue(); - } - private void updateAttributes2(int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, int lSz0, int lSz1, int lSz2, int tWd0, int tWd1, int tWd2, - int sampleFmt, int sampleRate, int channels) { + int audioFrameCount, int sampleFmt, int sampleRate, int channels) { vPixelFmt = PixelFormat.valueOf(pixFmt); vPlanes = planes; vBitsPerPixel = bitsPerPixel; @@ -329,7 +334,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { default: // FIXME: Add more formats ! throw new RuntimeException("Unsupported pixelformat: "+vPixelFmt); } - + initialAudioFrameCount = audioFrameCount > 0 ? audioFrameCount : AV_DEFAULT_AFRAMES * 2; aSampleFmt = SampleFormat.valueOf(sampleFmt); final int sampleSize; final boolean signed, fixedP; @@ -370,7 +375,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { avChosenAudioFormat = new AudioDataFormat(AudioDataType.PCM, sampleRate, sampleSize, channels, signed, fixedP, true /* littleEndian */); if(DEBUG) { - System.err.println("audio: fmt "+aSampleFmt+", "+avChosenAudioFormat); + System.err.println("audio: fmt "+aSampleFmt+", "+avChosenAudioFormat+", aFrameCount "+audioFrameCount+" -> "+initialAudioFrameCount); System.err.println("video: fmt "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane); for(int i=0; i<3; i++) { System.err.println("video: "+i+": "+vTexWidth[i]+"/"+vLinesize[i]); @@ -473,6 +478,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { @Override protected void preNextTextureImpl(GL gl) { psm.setUnpackAlignment(gl, 1); // RGBA ? 4 : 1 + gl.glActiveTexture(GL.GL_TEXTURE0+getTextureUnit()); } @Override @@ -481,31 +487,25 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost) { + protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame) { if(0==moviePtr) { throw new GLException("FFMPEG native instance null"); } - if( issuePreAndPost ) { - preNextTextureImpl(gl); - } int vPTS = TextureFrame.INVALID_PTS; - try { + if( null != nextFrame ) { final Texture tex = nextFrame.getTexture(); - gl.glActiveTexture(GL.GL_TEXTURE0+getTextureUnit()); tex.enable(gl); tex.bind(gl); + } - /** Try decode up to 10 packets to find one containing video. */ - for(int i=0; TextureFrame.INVALID_PTS == vPTS && 10 > i; i++) { - vPTS = readNextPacket0(moviePtr, textureTarget, textureFormat, textureType); - } - } finally { - if( issuePreAndPost ) { - postNextTextureImpl(gl); - } + /** Try decode up to 10 packets to find one containing video. */ + for(int i=0; TextureFrame.INVALID_PTS == vPTS && 10 > i; i++) { + vPTS = readNextPacket0(moviePtr, textureTarget, textureFormat, textureType); } if( TextureFrame.INVALID_PTS != vPTS ) { - nextFrame.setPTS(vPTS); + if( null != nextFrame ) { + nextFrame.setPTS(vPTS); + } return true; } else { return false; @@ -524,9 +524,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { return time * ( sinkChosenAudioFormat.channelCount * bytesPerSample * ( sinkChosenAudioFormat.sampleRate / 1000 ) ); } - @Override - protected final boolean syncAVRequired() { return true; } - private static native int getAvUtilVersion0(); private static native int getAvFormatVersion0(); private static native int getAvCodecVersion0(); @@ -543,10 +540,18 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { * [type PCM, sampleRate [10000(?)..44100..48000], sampleSize 16, channelCount 1-2, signed, littleEndian] * *

      + * + * @param moviePtr + * @param url + * @param vid + * @param aid + * @param snoopVideoFrameCount snoop this number of video-frames to gather audio-frame-count per video-frame. + * If zero, gathering audio-frame-count is disabled! + * @param aChannelCount + * @param aSampleRate */ - private native void setStream0(long moviePtr, String url, int vid, int aid, int audioFrameCount, - int aChannelCount, int aSampleRate); - private native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError); + private native void setStream0(long moviePtr, String url, int vid, int aid, int snoopVideoFrameCount, int aChannelCount, int aSampleRate); + private native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); private native int getVideoPTS0(long moviePtr); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java index d0517fc5f..e1b773e9b 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java @@ -96,7 +96,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected void initGLStreamImpl(GL gl, int vid, int aid) throws IOException { + protected void initStreamImpl(int vid, int aid) throws IOException { if(0==moviePtr) { throw new GLException("OMX native instance null"); } @@ -116,6 +116,10 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { System.out.println("initGLStream: p2 "+this); } } + @Override + protected final void initGLImpl(GL gl) throws IOException, GLException { + // NOP + } @Override protected int getAudioPTSImpl() { @@ -160,11 +164,11 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected boolean getNextTextureImpl(GL gl, TextureFrame nextFrame, boolean blocking, boolean issuePreAndPost) { + protected boolean getNextTextureImpl(GL gl, TextureFrame nextFrame) { if(0==moviePtr) { throw new GLException("OMX native instance null"); } - final int nextTex = _getNextTextureID(moviePtr, blocking); + final int nextTex = _getNextTextureID(moviePtr, true); if(0 < nextTex) { /* FIXME final TextureSequence.TextureFrame eglImgTex = diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index 06c3862db..76de406ae 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -52,6 +52,8 @@ typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (APIENTRYP PFNGLFLUSH) (void); +typedef void (APIENTRYP PFNGLFINISH) (void); /** * AV_TIME_BASE 1000000 @@ -68,11 +70,21 @@ typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); /** Sync w/ GLMediaPlayer.STREAM_ID_AUTO */ #define AV_STREAM_ID_AUTO -1 -/** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE 0x80000000 {@value}. Sync w/ TextureFrame.INVALID_PTS */ +/** Default number of audio frames per video frame. Sync w/ FFMPEGMediaPlayer.AV_DEFAULT_AFRAMES. */ +#define AV_DEFAULT_AFRAMES 8 + +/** Constant PTS marking an invalid PTS, i.e. Integer.MIN_VALUE == 0x80000000 == {@value}. Sync w/ TextureFrame.INVALID_PTS */ #define INVALID_PTS 0x80000000 +/** Constant PTS marking the end of the stream, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ TextureFrame.END_OF_STREAM_PTS */ +#define END_OF_STREAM_PTS 0x7FFFFFFF + +/** Until 55.0.0 */ #define AV_HAS_API_REQUEST_CHANNELS(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) < 55) +/** Since 55.0.0 */ +#define AV_HAS_API_REFCOUNTED_FRAMES(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) >= 55) + static inline float my_av_q2f(AVRational a){ return a.num / (float) a.den; } @@ -80,6 +92,20 @@ static inline int32_t my_av_q2i32(int64_t snum, AVRational a){ return (int32_t) ( ( snum * (int64_t) a.num ) / (int64_t)a.den ); } +typedef struct { + void *origPtr; + jobject nioRef; + int32_t size; +} NIOBuffer_t; + +typedef struct { + int64_t ptsError; // Number of backward PTS values (earlier than last PTS, excluding AV_NOPTS_VALUE) + int64_t dtsError; // Number of backward DTS values (earlier than last PTS, excluding AV_NOPTS_VALUE) + int64_t ptsLast; // PTS of the last frame + int64_t dtsLast; // DTS of the last frame +} PTSStats; + + typedef struct { int32_t verbose; @@ -87,8 +113,12 @@ typedef struct { uint32_t avformatVersion; uint32_t avutilVersion; + int32_t useRefCountedFrames; + PFNGLTEXSUBIMAGE2DPROC procAddrGLTexSubImage2D; PFNGLGETERRORPROC procAddrGLGetError; + PFNGLFLUSH procAddrGLFlush; + PFNGLFINISH procAddrGLFinish; AVFormatContext* pFormatCtx; int32_t vid; @@ -101,6 +131,7 @@ typedef struct { uint32_t vBytesPerPixelPerPlane; enum PixelFormat vPixFmt; // native decoder fmt int32_t vPTS; // msec - overall last video PTS + PTSStats vPTSStats; int32_t vLinesize[3]; // decoded video linesize in bytes for each plane int32_t vTexWidth[3]; // decoded video tex width in bytes for each plane @@ -110,6 +141,7 @@ typedef struct { AVCodecContext* pACodecCtx; AVCodec* pACodec; AVFrame** pAFrames; + NIOBuffer_t* pANIOBuffers; int32_t aFrameCount; int32_t aFrameCurrent; int32_t aSampleRate; @@ -117,6 +149,8 @@ typedef struct { int32_t aFrameSize; enum AVSampleFormat aSampleFmt; // native decoder fmt int32_t aPTS; // msec - overall last audio PTS + PTSStats aPTSStats; + int32_t aFramesPerVideoFrame; // is 'snooped' float fps; // frames per seconds int32_t bps_stream; // bits per seconds diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c index 99b385e3c..99ef02da5 100644 --- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c +++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c @@ -60,8 +60,11 @@ typedef AVCodec *(APIENTRYP AVCODEC_FIND_DECODER)(enum CodecID id); typedef int (APIENTRYP AVCODEC_OPEN2)(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options); // 53.6.0 typedef int (APIENTRYP AVCODEC_OPEN)(AVCodecContext *avctx, AVCodec *codec); typedef AVFrame *(APIENTRYP AVCODEC_ALLOC_FRAME)(void); +typedef void (APIENTRYP AVCODEC_GET_FRAME_DEFAULTS)(AVFrame *frame); +typedef void (APIENTRYP AVCODEC_FREE_FRAME)(AVFrame **frame); typedef int (APIENTRYP AVCODEC_DEFAULT_GET_BUFFER)(AVCodecContext *s, AVFrame *pic); typedef void (APIENTRYP AVCODEC_DEFAULT_RELEASE_BUFFER)(AVCodecContext *s, AVFrame *pic); +typedef void (APIENTRYP AVCODEC_FLUSH_BUFFERS)(AVCodecContext *avctx); typedef void (APIENTRYP AV_INIT_PACKET)(AVPacket *pkt); typedef int (APIENTRYP AV_NEW_PACKET)(AVPacket *pkt, int size); typedef void (APIENTRYP AV_DESTRUCT_PACKET)(AVPacket *pkt); @@ -76,8 +79,11 @@ static AVCODEC_FIND_DECODER sp_avcodec_find_decoder; static AVCODEC_OPEN2 sp_avcodec_open2; // 53.6.0 static AVCODEC_OPEN sp_avcodec_open; static AVCODEC_ALLOC_FRAME sp_avcodec_alloc_frame; +static AVCODEC_GET_FRAME_DEFAULTS sp_avcodec_get_frame_defaults; +static AVCODEC_FREE_FRAME sp_avcodec_free_frame; static AVCODEC_DEFAULT_GET_BUFFER sp_avcodec_default_get_buffer; static AVCODEC_DEFAULT_RELEASE_BUFFER sp_avcodec_default_release_buffer; +static AVCODEC_FLUSH_BUFFERS sp_avcodec_flush_buffers; static AV_INIT_PACKET sp_av_init_packet; static AV_NEW_PACKET sp_av_new_packet; static AV_DESTRUCT_PACKET sp_av_destruct_packet; @@ -85,17 +91,19 @@ static AV_FREE_PACKET sp_av_free_packet; static AVCODEC_DECODE_AUDIO4 sp_avcodec_decode_audio4; // 53.25.0 static AVCODEC_DECODE_AUDIO3 sp_avcodec_decode_audio3; // 52.23.0 static AVCODEC_DECODE_VIDEO2 sp_avcodec_decode_video2; // 52.23.0 -// count: 15 +// count: 21 // libavutil +typedef void (APIENTRYP AV_FRAME_UNREF)(AVFrame *frame); typedef void (APIENTRYP AV_FREE)(void *ptr); typedef int (APIENTRYP AV_GET_BITS_PER_PIXEL)(const AVPixFmtDescriptor *pixdesc); typedef int (APIENTRYP AV_SAMPLES_GET_BUFFER_SIZE)(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align); static const AVPixFmtDescriptor* sp_av_pix_fmt_descriptors; +static AV_FRAME_UNREF sp_av_frame_unref; static AV_FREE sp_av_free; static AV_GET_BITS_PER_PIXEL sp_av_get_bits_per_pixel; static AV_SAMPLES_GET_BUFFER_SIZE sp_av_samples_get_buffer_size; -// count: 22 +// count: 26 // libavformat typedef AVFormatContext *(APIENTRYP AVFORMAT_ALLOC_CONTEXT)(void); @@ -131,9 +139,9 @@ static AVFORMAT_NETWORK_INIT sp_avformat_network_init; // 53.13.0 static AVFORMAT_NETWORK_DEINIT sp_avformat_network_deinit; // 53.13.0 static AVFORMAT_FIND_STREAM_INFO sp_avformat_find_stream_info; // 53.3.0 static AV_FIND_STREAM_INFO sp_av_find_stream_info; -// count: 38 +// count: 42 -#define SYMBOL_COUNT 38 +#define SYMBOL_COUNT 42 JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryBundleInfo_initSymbols0 (JNIEnv *env, jclass clazz, jobject jSymbols, jint count) @@ -162,8 +170,11 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryB sp_avcodec_open2 = (AVCODEC_OPEN2) (intptr_t) symbols[i++]; sp_avcodec_open = (AVCODEC_OPEN) (intptr_t) symbols[i++]; sp_avcodec_alloc_frame = (AVCODEC_ALLOC_FRAME) (intptr_t) symbols[i++]; + sp_avcodec_get_frame_defaults = (AVCODEC_GET_FRAME_DEFAULTS) (intptr_t) symbols[i++]; + sp_avcodec_free_frame = (AVCODEC_FREE_FRAME) (intptr_t) symbols[i++]; sp_avcodec_default_get_buffer = (AVCODEC_DEFAULT_GET_BUFFER) (intptr_t) symbols[i++]; sp_avcodec_default_release_buffer = (AVCODEC_DEFAULT_RELEASE_BUFFER) (intptr_t) symbols[i++]; + sp_avcodec_flush_buffers = (AVCODEC_FLUSH_BUFFERS) (intptr_t) symbols[i++]; sp_av_init_packet = (AV_INIT_PACKET) (intptr_t) symbols[i++]; sp_av_new_packet = (AV_NEW_PACKET) (intptr_t) symbols[i++]; sp_av_destruct_packet = (AV_DESTRUCT_PACKET) (intptr_t) symbols[i++]; @@ -174,6 +185,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryB // count: 18 sp_av_pix_fmt_descriptors = (const AVPixFmtDescriptor*) (intptr_t) symbols[i++]; + sp_av_frame_unref = (AV_FRAME_UNREF) (intptr_t) symbols[i++]; sp_av_free = (AV_FREE) (intptr_t) symbols[i++]; sp_av_get_bits_per_pixel = (AV_GET_BITS_PER_PIXEL) (intptr_t) symbols[i++]; sp_av_samples_get_buffer_size = (AV_SAMPLES_GET_BUFFER_SIZE) (intptr_t) symbols[i++]; @@ -234,11 +246,11 @@ static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasic pAV->vBitsPerPixel, pAV->vBytesPerPixelPerPlane, pAV->vLinesize[0], pAV->vLinesize[1], pAV->vLinesize[2], pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2], - pAV->aSampleFmt, pAV->aSampleRate, pAV->aChannels); + pAV->aFramesPerVideoFrame, pAV->aSampleFmt, pAV->aSampleRate, pAV->aChannels); } } -static void freeInstance(FFMPEGToolBasicAV_t* pAV) { +static void freeInstance(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { int i; if(NULL != pAV) { // Close the V codec @@ -257,12 +269,34 @@ static void freeInstance(FFMPEGToolBasicAV_t* pAV) { // Close the frames if(NULL != pAV->pVFrame) { - sp_av_free(pAV->pVFrame); + if(HAS_FUNC(sp_avcodec_free_frame)) { + sp_avcodec_free_frame(&pAV->pVFrame); + } else { + sp_av_free(pAV->pVFrame); + } pAV->pVFrame = NULL; } + if(NULL != pAV->pANIOBuffers) { + for(i=0; iaFrameCount; i++) { + NIOBuffer_t * pNIOBuffer = &pAV->pANIOBuffers[i]; + if( NULL != pNIOBuffer->nioRef ) { + if(pAV->verbose) { + fprintf(stderr, "A NIO: Free.X ptr %p / ref %p, %d bytes\n", + pNIOBuffer->origPtr, pNIOBuffer->nioRef, pNIOBuffer->size); + } + (*env)->DeleteGlobalRef(env, pNIOBuffer->nioRef); + } + } + free(pAV->pANIOBuffers); + pAV->pANIOBuffers = NULL; + } if(NULL != pAV->pAFrames) { for(i=0; iaFrameCount; i++) { - sp_av_free(pAV->pAFrames[i]); + if(HAS_FUNC(sp_avcodec_free_frame)) { + sp_avcodec_free_frame(&pAV->pAFrames[i]); + } else { + sp_av_free(pAV->pAFrames[i]); + } } free(pAV->pAFrames); pAV->pAFrames = NULL; @@ -358,7 +392,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_ini jni_mid_pushSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "pushSound", "(Ljava/nio/ByteBuffer;II)V"); jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIIIFIIILjava/lang/String;Ljava/lang/String;)V"); - jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIII)V"); + jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIII)V"); if(jni_mid_pushSound == NULL || jni_mid_updateAttributes1 == NULL || @@ -380,6 +414,16 @@ JNIEXPORT jlong JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_create pAV->avformatVersion = sp_avformat_version(); pAV->avutilVersion = sp_avutil_version(); + #if LIBAVCODEC_VERSION_MAJOR >= 55 + // TODO: We keep code on using 1 a/v frame per decoding cycle now. + // This is compatible w/ OpenAL's alBufferData(..) + // and w/ OpenGL's texture update command, both copy data immediatly. + // pAV->useRefCountedFrames = AV_HAS_API_REFCOUNTED_FRAMES(pAV); + pAV->useRefCountedFrames = 0; + #else + pAV->useRefCountedFrames = 0; + #endif + // Register all formats and codecs sp_av_register_all(); // Network too .. @@ -400,7 +444,7 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_destroy FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); if (pAV != NULL) { // stop assumed .. - freeInstance(pAV); + freeInstance(env, pAV); } } @@ -418,9 +462,14 @@ static uint64_t getDefaultAudioChannelLayout(int channelCount) { } } +static int countAudioPacketsTillVideo(const int maxPackets, FFMPEGToolBasicAV_t *pAV, AVPacket* pPacket, int packetFull, AVFrame* pAFrame, int * pAudioFrames, int *pMaxDataSize); +static int countVideoPacketsTillAudio(const int maxPackets, FFMPEGToolBasicAV_t *pAV, AVPacket* pPacket, int packetFull, int * pVideoFrames); +static void initPTSStats(PTSStats *ptsStats); +static int64_t evalPTS(PTSStats *ptsStats, int64_t inPTS, int64_t inDTS); + JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStream0 - (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jint vid, jint aid, jint audioFrameCount, - jint aChannelCount, jint aSampleRate) + (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jint vid, jint aid, + jint snoopVideoFrameCount, jint aChannelCount, jint aSampleRate) { int res, i; jboolean iscopy; @@ -437,8 +486,8 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre const char *urlPath = (*env)->GetStringUTFChars(env, jURL, &iscopy); res = sp_avformat_open_input(&pAV->pFormatCtx, urlPath, NULL, NULL); if(res != 0) { + JoglCommon_throwNewRuntimeException(env, "Couldn't open URI: %s", urlPath); (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); - JoglCommon_throwNewRuntimeException(env, "Couldn't open URL"); return; } @@ -508,6 +557,12 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre } if(0<=pAV->aid) { + AVFrame * pAFrame0 = sp_avcodec_alloc_frame(); + if( NULL == pAFrame0 ) { + JoglCommon_throwNewRuntimeException(env, "Couldn't alloc 1st audio frame\n"); + return; + } + // Get a pointer to the codec context for the audio stream // FIXME: Libav Binary compatibility! JAU01 pAV->pACodecCtx=pAV->pAStream->codec; @@ -543,6 +598,9 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre } // Open codec + #if LIBAVCODEC_VERSION_MAJOR >= 55 + pAV->pACodecCtx->refcounted_frames = pAV->useRefCountedFrames; + #endif if(HAS_FUNC(sp_avcodec_open2)) { res = sp_avcodec_open2(pAV->pACodecCtx, pAV->pACodec, NULL); } else { @@ -553,14 +611,11 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre return; } - // Allocate audio frames - // FIXME: Libav Binary compatibility! JAU01 pAV->aSampleRate = pAV->pACodecCtx->sample_rate; pAV->aChannels = pAV->pACodecCtx->channels; pAV->aFrameSize = pAV->pACodecCtx->frame_size; // in samples! pAV->aSampleFmt = pAV->pACodecCtx->sample_fmt; pAV->frames_audio = pAV->pAStream->nb_frames; - if( pAV->verbose ) { fprintf(stderr, "A channels %d, sample_rate %d, frame_size %d, frame_number %d, r_frame_rate %f, avg_frame_rate %f, nb_frames %d, \n", pAV->aChannels, pAV->aSampleRate, pAV->aFrameSize, pAV->pACodecCtx->frame_number, @@ -569,12 +624,97 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre pAV->pAStream->nb_frames); } - pAV->aFrameCount = audioFrameCount; - pAV->pAFrames = calloc(audioFrameCount, sizeof(AVFrame*)); - for(i=0; iaFrameCount; i++) { - pAV->pAFrames[i]=sp_avcodec_alloc_frame(); - if(pAV->pAFrames[i]==NULL) { - JoglCommon_throwNewRuntimeException(env, "Couldn't alloc audio frame %d / %d", i, audioFrameCount); + if( 0 >= snoopVideoFrameCount ) { + pAV->aFramesPerVideoFrame = 0; + } else { + if( 0<=pAV->vid ) { + int aFramesPerVideoFrame; + int aFramesSequential = 0; + int aMaxDataSize = 0; + AVPacket packet; + int packetFull = 0; + int _aFramesBeforeVideo; + int _audioFramesOverlap=0; + int _aMaxDataSize; + int _vFrames; + int _vFramesOverlap=0; + int _packetCount; + int totalVFrames = 0; + int totalAFrames = 0; + int totalPackets = 0; + + while( totalVFrames < snoopVideoFrameCount ) { + int _packetCount = countAudioPacketsTillVideo(40, pAV, &packet, packetFull, pAFrame0, &_aFramesBeforeVideo, &_aMaxDataSize); + if( _packetCount >= 0 ) { + totalPackets += _packetCount; + if( _aFramesBeforeVideo > 0 ) { + // one video frame! + _vFramesOverlap=1; + packetFull = 1; + } + _aFramesBeforeVideo += _audioFramesOverlap; + totalAFrames += _aFramesBeforeVideo; + if( _aFramesBeforeVideo > aFramesSequential ) { + aFramesSequential = _aFramesBeforeVideo; + } + if( _aMaxDataSize > aMaxDataSize ) { + aMaxDataSize = _aMaxDataSize; + } + _packetCount = countVideoPacketsTillAudio(40, pAV, &packet, packetFull, &_vFrames); + if( _packetCount >= 0 ) { + totalPackets += _packetCount; + if( _vFrames > 0 ) { + // one audio frame! + _audioFramesOverlap=1; + packetFull = 1; + } + _vFrames += _vFramesOverlap; + totalVFrames += _vFrames; + } + if( pAV->verbose ) { + fprintf(stderr, "Snoop Packet #%d, V-Frames: %d, A-frames %d Seq(now %d, max %d), max-size (now %d, max %d)\n", + totalPackets, totalVFrames, totalAFrames, _aFramesBeforeVideo, aFramesSequential, _aMaxDataSize, aMaxDataSize); + } + } + } + const int audioFramesReadAhead = totalAFrames - totalVFrames; + if( audioFramesReadAhead > aFramesSequential ) { + aFramesPerVideoFrame = audioFramesReadAhead; + } else { + aFramesPerVideoFrame = aFramesSequential; + } + if( AV_DEFAULT_AFRAMES > aFramesPerVideoFrame || aFramesPerVideoFrame > 10*AV_DEFAULT_AFRAMES ) { + aFramesPerVideoFrame = AV_DEFAULT_AFRAMES; + } + pAV->aFramesPerVideoFrame = aFramesPerVideoFrame; + sp_av_seek_frame(pAV->pFormatCtx, -1, 0, AVSEEK_FLAG_BACKWARD); + sp_avcodec_flush_buffers( pAV->pACodecCtx ); + if( pAV->verbose ) { + fprintf(stderr, "Snooped Packets %d, V-Frames: %d, A-frames %d Seq %d, readAhead %d -> Cached %d/%d, max-size %d\n", + totalPackets, totalVFrames, totalAFrames, aFramesSequential, audioFramesReadAhead, aFramesPerVideoFrame, pAV->aFramesPerVideoFrame, aMaxDataSize); + } + } else { + pAV->aFramesPerVideoFrame = AV_DEFAULT_AFRAMES; + if( pAV->verbose ) { + fprintf(stderr, "A-frame Count %d\n", pAV->aFramesPerVideoFrame); + } + } + } + + // Allocate audio frames + // FIXME: Libav Binary compatibility! JAU01 + if( pAV->useRefCountedFrames && pAV->aFramesPerVideoFrame > 0 ) { + pAV->aFrameCount = pAV->aFramesPerVideoFrame; + } else { + pAV->aFrameCount = 1; + } + pAV->pANIOBuffers = calloc(pAV->aFrameCount, sizeof(NIOBuffer_t)); + pAV->pAFrames = calloc(pAV->aFrameCount, sizeof(AVFrame*)); + pAV->pAFrames[0] = pAFrame0; + for(i=1; iaFrameCount; i++) { + pAV->pAFrames[i] = sp_avcodec_alloc_frame(); + if( NULL == pAV->pAFrames[i] ) { + JoglCommon_throwNewRuntimeException(env, "Couldn't alloc audio frame %d / %d", i, pAV->aFrameCount); return; } } @@ -612,6 +752,9 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre } // Open codec + #if LIBAVCODEC_VERSION_MAJOR >= 55 + pAV->pVCodecCtx->refcounted_frames = pAV->useRefCountedFrames; + #endif if(HAS_FUNC(sp_avcodec_open2)) { res = sp_avcodec_open2(pAV->pVCodecCtx, pAV->pVCodec, NULL); } else { @@ -643,7 +786,7 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre pAV->pVStream->nb_frames); } - // Allocate video frames + // Allocate video frame // FIXME: Libav Binary compatibility! JAU01 pAV->vPixFmt = pAV->pVCodecCtx->pix_fmt; { @@ -677,15 +820,19 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre } pAV->vPTS=0; pAV->aPTS=0; + initPTSStats(&pAV->vPTSStats); + initPTSStats(&pAV->aPTSStats); _updateJavaAttributes(env, instance, pAV); } JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setGLFuncs0 - (JNIEnv *env, jobject instance, jlong ptr, jlong jProcAddrGLTexSubImage2D, jlong jProcAddrGLGetError) + (JNIEnv *env, jobject instance, jlong ptr, jlong jProcAddrGLTexSubImage2D, jlong jProcAddrGLGetError, jlong jProcAddrGLFlush, jlong jProcAddrGLFinish) { FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); pAV->procAddrGLTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC) (intptr_t)jProcAddrGLTexSubImage2D; pAV->procAddrGLGetError = (PFNGLGETERRORPROC) (intptr_t)jProcAddrGLGetError; + pAV->procAddrGLFlush = (PFNGLFLUSH) (intptr_t)jProcAddrGLFlush; + pAV->procAddrGLFinish = (PFNGLFINISH) (intptr_t)jProcAddrGLFinish; } #if 0 @@ -707,15 +854,19 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex sp_av_init_packet(&packet); - if( sp_av_read_frame(pAV->pFormatCtx, &packet) >= 0 ) { + const int avRes = sp_av_read_frame(pAV->pFormatCtx, &packet); + if( AVERROR_EOF == avRes || ( pAV->pFormatCtx->pb && pAV->pFormatCtx->pb->eof_reached ) ) { + resPTS = END_OF_STREAM_PTS; + } else if( 0 <= avRes ) { + if( pAV->verbose ) { + fprintf(stderr, "P: ptr %p, size %d\n", packet.data, packet.size); + } if(packet.stream_index==pAV->aid) { // Decode audio frame if(NULL == pAV->pAFrames) { // no audio registered sp_av_free_packet(&packet); return 0; } - AVFrame* pAFrameCurrent = pAV->pAFrames[pAV->aFrameCurrent]; - pAV->aFrameCurrent = ( pAV->aFrameCurrent + 1 ) % pAV->aFrameCount ; int frameCount; int flush_complete = 0; for ( frameCount=0; 0 < packet.size || 0 == frameCount; frameCount++ ) { @@ -723,6 +874,13 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex if (flush_complete) { break; } + NIOBuffer_t * pNIOBufferCurrent = &pAV->pANIOBuffers[pAV->aFrameCurrent]; + AVFrame* pAFrameCurrent = pAV->pAFrames[pAV->aFrameCurrent]; + if( pAV->useRefCountedFrames ) { + sp_av_frame_unref(pAFrameCurrent); + pAV->aFrameCurrent = ( pAV->aFrameCurrent + 1 ) % pAV->aFrameCount ; + } + sp_avcodec_get_frame_defaults(pAFrameCurrent); if(HAS_FUNC(sp_avcodec_decode_audio4)) { len1 = sp_avcodec_decode_audio4(pAV->pACodecCtx, pAFrameCurrent, &frameDecoded, &packet); } else { @@ -763,24 +921,41 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex const AVRational time_base = pAV->pAStream->time_base; const int64_t pkt_pts = pAFrameCurrent->pkt_pts; - int aptsMode; if( 0 == frameCount && AV_NOPTS_VALUE != pkt_pts ) { // 1st frame only, discard invalid PTS .. pAV->aPTS = my_av_q2i32( pkt_pts * 1000, time_base); - aptsMode = 0; } else { // subsequent frames or invalid PTS .. const int32_t bytesPerSample = 2; // av_get_bytes_per_sample( pAV->pACodecCtx->sample_fmt ); pAV->aPTS += data_size / ( pAV->aChannels * bytesPerSample * ( pAV->aSampleRate / 1000 ) ); - aptsMode = 1; } if( pAV->verbose ) { int32_t aDTS = my_av_q2i32( pAFrameCurrent->pkt_dts * 1000, time_base); - fprintf(stderr, "A pts %d [pkt_pts %ld], dts %d [pkt_dts %ld], dataSize %d, f# %d, pts-mode %d\n", - pAV->aPTS, pkt_pts, aDTS, pAFrameCurrent->pkt_dts, data_size, frameCount, aptsMode); + fprintf(stderr, "A pts %d [pkt_pts %ld], dts %d [pkt_dts %ld], f# %d, aFrame %d/%d %p, dataPtr %p, dataSize %d\n", + pAV->aPTS, pkt_pts, aDTS, pAFrameCurrent->pkt_dts, frameCount, + pAV->aFrameCurrent, pAV->aFrameCount, pAFrameCurrent, pAFrameCurrent->data[0], data_size); } if( NULL != env ) { - jobject jSampleData = (*env)->NewDirectByteBuffer(env, pAFrameCurrent->data[0], data_size); - (*env)->CallVoidMethod(env, instance, jni_mid_pushSound, jSampleData, data_size, pAV->aPTS); + NIOBuffer_t * pNIOBufferCurrent = &pAV->pANIOBuffers[pAV->aFrameCurrent]; + int newNIO = NULL == pNIOBufferCurrent->nioRef; + if( !newNIO && ( pAFrameCurrent->data[0] != pNIOBufferCurrent->origPtr || data_size > pNIOBufferCurrent->size ) ) { + if(pAV->verbose) { + fprintf(stderr, "A NIO: Free.0 ptr %p / ref %p, %d bytes\n", + pNIOBufferCurrent->origPtr, pNIOBufferCurrent->nioRef, pNIOBufferCurrent->size); + } + (*env)->DeleteGlobalRef(env, pNIOBufferCurrent->nioRef); + newNIO = 1; + } + if( newNIO ) { + jobject jSampleData = (*env)->NewDirectByteBuffer(env, pAFrameCurrent->data[0], data_size); + pNIOBufferCurrent->nioRef = (*env)->NewGlobalRef(env, jSampleData); + pNIOBufferCurrent->origPtr = pAFrameCurrent->data[0]; + pNIOBufferCurrent->size = data_size; + if(pAV->verbose) { + fprintf(stderr, "A NIO: Alloc ptr %p / ref %p, %d bytes\n", + pNIOBufferCurrent->origPtr, pNIOBufferCurrent->nioRef, pNIOBufferCurrent->size); + } + } + (*env)->CallVoidMethod(env, instance, jni_mid_pushSound, pNIOBufferCurrent->nioRef, data_size, pAV->aPTS); } } } else if(packet.stream_index==pAV->vid) { @@ -796,6 +971,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex if (flush_complete) { break; } + sp_avcodec_get_frame_defaults(pAV->pVFrame); len1 = sp_avcodec_decode_video2(pAV->pVCodecCtx, pAV->pVFrame, &frameDecoded, &packet); if (len1 < 0) { // if error, we skip the frame @@ -816,26 +992,27 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex // FIXME: Libav Binary compatibility! JAU01 const AVRational time_base = pAV->pVStream->time_base; const int64_t pkt_pts = pAV->pVFrame->pkt_pts; - if(AV_NOPTS_VALUE != pkt_pts) { // discard invalid PTS .. - pAV->vPTS = my_av_q2i32( pkt_pts * 1000, time_base); - if( pAV->verbose ) { - int32_t vDTS = my_av_q2i32( pAV->pVFrame->pkt_dts * 1000, time_base); + const int64_t pkt_dts = pAV->pVFrame->pkt_dts; + const int64_t fix_pts = evalPTS(&pAV->vPTSStats, pkt_pts, pkt_dts); + if( AV_NOPTS_VALUE != fix_pts ) { // discard invalid PTS .. + pAV->vPTS = my_av_q2i32( fix_pts * 1000, time_base); + } + if( pAV->verbose ) { + const int32_t vPTS = AV_NOPTS_VALUE != pkt_pts ? my_av_q2i32( pkt_pts * 1000, time_base) : 0; + const int32_t vDTS = AV_NOPTS_VALUE != pkt_dts ? my_av_q2i32( pkt_dts * 1000, time_base) : 0; - double frame_delay_d = av_q2d(pAV->pVCodecCtx->time_base); - double frame_repeat_d = pAV->pVFrame->repeat_pict * (frame_delay_d * 0.5); + const double frame_delay_d = av_q2d(pAV->pVCodecCtx->time_base); + const double frame_repeat_d = pAV->pVFrame->repeat_pict * (frame_delay_d * 0.5); - int32_t frame_delay_i = my_av_q2i32(1000, pAV->pVCodecCtx->time_base); - int32_t frame_repeat_i = pAV->pVFrame->repeat_pict * (frame_delay_i / 2); + const int32_t frame_delay_i = my_av_q2i32(1000, pAV->pVCodecCtx->time_base); + const int32_t frame_repeat_i = pAV->pVFrame->repeat_pict * (frame_delay_i / 2); - const char * warn = frame_repeat_i > 0 ? "REPEAT" : "NORMAL" ; + const char * warn = frame_repeat_i > 0 ? "REPEAT" : "NORMAL" ; - fprintf(stderr, "V pts %d [pkt_pts %ld], dts %d [pkt_dts %ld], time d(%lf s + r %lf = %lf s), i(%d ms + r %d = %d ms) - %s - f# %d\n", - pAV->vPTS, pkt_pts, vDTS, pAV->pVFrame->pkt_dts, - frame_delay_d, frame_repeat_d, (frame_delay_d + frame_repeat_d), - frame_delay_i, frame_repeat_i, (frame_delay_i + frame_repeat_i), warn, frameCount); - } - } else if( pAV->verbose ) { - fprintf(stderr, "V pts ?? [pkt_pts %ld], pts2 ?? [pkt_dts %ld], f# %d\n", pkt_pts, pAV->pVFrame->pkt_dts, frameCount); + fprintf(stderr, "V fix_pts %d, pts %d [pkt_pts %ld], dts %d [pkt_dts %ld], time d(%lf s + r %lf = %lf s), i(%d ms + r %d = %d ms) - %s - f# %d\n", + pAV->vPTS, vPTS, pkt_pts, vDTS, pkt_dts, + frame_delay_d, frame_repeat_d, (frame_delay_d + frame_repeat_d), + frame_delay_i, frame_repeat_i, (frame_delay_i + frame_repeat_i), warn, frameCount); } resPTS = pAV->vPTS; // Video Frame! @@ -866,6 +1043,11 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex texFmt, texType, pAV->pVFrame->data[2]); DBG_TEXSUBIMG2D_b(pAV); } // FIXME: Add more planar formats ! + pAV->procAddrGLFinish(); + //pAV->procAddrGLFlush(); + if( pAV->useRefCountedFrames ) { + sp_av_frame_unref(pAV->pVFrame); + } } } @@ -877,6 +1059,135 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex return resPTS; } +static int countAudioPacketsTillVideo(const int maxPackets, FFMPEGToolBasicAV_t *pAV, AVPacket* pPacket, int packetFull, AVFrame* pAFrame, int * pAudioFrames, int *pMaxDataSize) { + int frameDecoded; + int audioFrames = 0; + int maxDataSize = 0; + int packetCount = 0; + + for( packetCount = 0; packetCount < maxPackets; packetCount++ ) { + int readRes; + if( !packetFull ) { + sp_av_init_packet(pPacket); + readRes = sp_av_read_frame(pAV->pFormatCtx, pPacket); + } else { + readRes = 1; + packetFull = 0; + } + if( readRes >= 0 ) { + if(pPacket->stream_index==pAV->aid) { + // Decode audio frame + int frameCount; + int flush_complete = 0; + for ( frameCount=0; 0 < pPacket->size || 0 == frameCount; frameCount++ ) { + int len1; + if (flush_complete) { + break; + } + if(HAS_FUNC(sp_avcodec_decode_audio4)) { + len1 = sp_avcodec_decode_audio4(pAV->pACodecCtx, pAFrame, &frameDecoded, pPacket); + } else { + #if 0 + len1 = sp_avcodec_decode_audio3(pAV->pACodecCtx, int16_t *samples, int *frame_size_ptr, &frameDecoded, pPacket); + #endif + return -1; + } + if (len1 < 0) { + // if error, we skip the frame + pPacket->size = 0; + break; + } + pPacket->data += len1; + pPacket->size -= len1; + + if (!frameDecoded) { + // stop sending empty packets if the decoder is finished + if (!pPacket->data && pAV->pACodecCtx->codec->capabilities & CODEC_CAP_DELAY) { + flush_complete = 1; + } + continue; + } + + int32_t data_size = 0; + if(HAS_FUNC(sp_av_samples_get_buffer_size)) { + data_size = sp_av_samples_get_buffer_size(NULL /* linesize, may be NULL */, + pAV->aChannels, + pAFrame->nb_samples, + pAFrame->format, + 1 /* align */); + if( data_size > maxDataSize ) { + maxDataSize = data_size; + } + } + if( pAV->useRefCountedFrames ) { + sp_av_frame_unref(pAFrame); + } + audioFrames++; + } + } else if(pPacket->stream_index==pAV->vid) { + if( 0 < audioFrames ) { + break; // done! + } + } + } + } + *pAudioFrames = audioFrames; + *pMaxDataSize = maxDataSize; + return packetCount; +} +static int countVideoPacketsTillAudio(const int maxPackets, FFMPEGToolBasicAV_t *pAV, AVPacket* pPacket, int packetFull, int * pVideoFrames) { + int videoFrames = 0; + int packetCount = 0; + + for( packetCount = 0; packetCount < maxPackets; packetCount++ ) { + int readRes; + if( !packetFull ) { + sp_av_init_packet(pPacket); + readRes = sp_av_read_frame(pAV->pFormatCtx, pPacket); + } else { + readRes = 1; + packetFull = 0; + } + if( readRes >= 0 ) { + if(pPacket->stream_index==pAV->aid) { + if( 0 < videoFrames ) { + break; // done! + } + } else if(pPacket->stream_index==pAV->vid) { + videoFrames++; + } + } + } + *pVideoFrames = videoFrames; + return packetCount; +} +static void initPTSStats(PTSStats *ptsStats) { + ptsStats->ptsError = 0; + ptsStats->dtsError = 0; + ptsStats->ptsLast = INT64_MIN; + ptsStats->dtsLast = INT64_MIN; +} +static int64_t evalPTS(PTSStats *ptsStats, int64_t inPTS, int64_t inDTS) { + int64_t resPTS = AV_NOPTS_VALUE; + + if ( inDTS != AV_NOPTS_VALUE ) { + ptsStats->dtsError += inDTS <= ptsStats->dtsLast; + ptsStats->dtsLast = inDTS; + } + if ( inPTS != AV_NOPTS_VALUE ) { + ptsStats->ptsError += inPTS <= ptsStats->ptsLast; + ptsStats->ptsLast = inPTS; + } + if ( inPTS != AV_NOPTS_VALUE && + ( ptsStats->ptsError<=ptsStats->dtsError || inDTS == AV_NOPTS_VALUE ) ) { + resPTS = inPTS; + } else { + resPTS = inDTS; + } + return resPTS; +} + + JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_play0 (JNIEnv *env, jobject instance, jlong ptr) { @@ -893,21 +1204,51 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_pause0 JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_seek0 (JNIEnv *env, jobject instance, jlong ptr, jint pos1) { - FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); - int64_t pos0 = pAV->vPTS; - int64_t pts0 = pAV->pVFrame->pkt_pts; - int64_t pts1 = (int64_t) (pos1 * (int64_t) pAV->pVStream->time_base.den) - / (1000 * (int64_t) pAV->pVStream->time_base.num); - + const FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); + const int64_t pos0 = pAV->vPTS; + const int64_t pts0 = pAV->pVFrame->pkt_pts; + int streamID; + AVRational time_base; + if( pAV->vid >= 0 ) { + streamID = pAV->vid; + time_base = pAV->pVStream->time_base; + } else if( pAV->aid >= 0 ) { + streamID = pAV->aid; + time_base = pAV->pAStream->time_base; + } else { + return pAV->vPTS; + } + int64_t pts1 = (int64_t) (pos1 * (int64_t) time_base.den) + / (1000 * (int64_t) time_base.num); int flags = 0; if(pos1 < pos0) { flags |= AVSEEK_FLAG_BACKWARD; } - fprintf(stderr, "SEEK: pre : u %ld, p %ld -> u %ld, p %ld\n", pos0, pts0, pos1, pts1); - sp_av_seek_frame(pAV->pFormatCtx, pAV->vid, pts1, flags); - pAV->vPTS = my_av_q2i32( pAV->pVFrame->pkt_pts * 1000, pAV->pVStream->time_base); - fprintf(stderr, "SEEK: post : u %ld, p %ld\n", pAV->vPTS, pAV->pVFrame->pkt_pts); - return pAV->vPTS; + int res; + if(HAS_FUNC(sp_av_seek_frame)) { + if(pos1 < pos0) { + flags |= AVSEEK_FLAG_BACKWARD; + } + fprintf(stderr, "SEEK.0: pre : s %ld / %ld -> t %ld / %ld\n", pos0, pts0, pos1, pts1); + sp_av_seek_frame(pAV->pFormatCtx, streamID, pts1, flags); + + } else if(HAS_FUNC(sp_avformat_seek_file)) { + int64_t ptsD = pts1 - pts0; + int64_t seek_min = ptsD > 0 ? pts1 - ptsD : INT64_MIN; + int64_t seek_max = ptsD < 0 ? pts1 - ptsD : INT64_MAX; + fprintf(stderr, "SEEK.1: pre : s %ld / %ld -> t %ld / %ld [%ld .. %ld]\n", + pos0, pts0, pos1, pts1, seek_min, seek_max); + res = sp_avformat_seek_file(pAV->pFormatCtx, -1, seek_min, pts1, seek_max, flags); + } + if(NULL != pAV->pVCodecCtx) { + sp_avcodec_flush_buffers( pAV->pVCodecCtx ); + } + if(NULL != pAV->pACodecCtx) { + sp_avcodec_flush_buffers( pAV->pACodecCtx ); + } + const jint vPTS = my_av_q2i32( pAV->pVFrame->pkt_pts * 1000, pAV->pVStream->time_base); + fprintf(stderr, "SEEK: post : res %d, u %ld, p %ld\n", res, vPTS, pAV->pVFrame->pkt_pts); + return vPTS; } JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_getVideoPTS0 diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index 2c434f38a..c9acab64b 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -48,6 +48,9 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; +import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; +import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; import android.os.Bundle; import android.util.Log; @@ -85,21 +88,45 @@ public class MovieCubeActivity0 extends NewtBaseActivity { scrn.addReference(); try { - final Animator animator = new Animator(); + final Animator anim = new Animator(); // Main - final MovieCube demoMain = new MovieCube(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, -2.3f, 0f, 0f); final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); glWindowMain.setFullscreen(true); setContentView(getWindow(), glWindowMain); - glWindowMain.addMouseListener(showKeyboardMouseListener); - glWindowMain.addGLEventListener(demoMain); - animator.add(glWindowMain); + anim.add(glWindowMain); glWindowMain.setVisible(true); + glWindowMain.addMouseListener(showKeyboardMouseListener); - // animator.setUpdateFPSFrames(60, System.err); - animator.setUpdateFPSFrames(-1, null); - animator.resetFPSCounter(); + final MovieCube demoMain = new MovieCube(-2.3f, 0f, 0f); + final GLMediaPlayer mPlayer = demoMain.getGLMediaPlayer(); + mPlayer.addEventListener(new GLMediaEventListener() { + @Override + public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { + } + + @Override + public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { + System.err.println("Player AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("Player State: "+mp); + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { + glWindowMain.addGLEventListener(demoMain); + anim.setUpdateFPSFrames(60, System.err); + anim.resetFPSCounter(); + } + if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { + final StreamException se = mPlayer.getStreamException(); + if( null != se ) { + se.printStackTrace(); + } + new Thread() { + public void run() { + glWindowMain.destroy(); + } }.start(); + } + } + }); + demoMain.initStream(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 0); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index 2c8f0eb50..d4cb226f2 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -27,7 +27,6 @@ */ package com.jogamp.opengl.test.android; -import java.io.IOException; import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; @@ -49,6 +48,9 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; +import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; +import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; import android.os.Bundle; import android.util.Log; @@ -84,25 +86,44 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { final com.jogamp.newt.Screen scrn = NewtFactory.createScreen(dpy, 0); scrn.addReference(); - try { - final Animator animator = new Animator(); - - // Main - final MovieSimple demoMain = new MovieSimple(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO); - demoMain.setScaleOrig(true); - final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); - glWindowMain.setFullscreen(true); - setContentView(getWindow(), glWindowMain); - glWindowMain.addGLEventListener(demoMain); - animator.add(glWindowMain); - glWindowMain.setVisible(true); - - animator.setUpdateFPSFrames(60, System.err); - // animator.setUpdateFPSFrames(-1, null); - animator.resetFPSCounter(); - } catch (IOException e) { - e.printStackTrace(); - } + final Animator anim = new Animator(); + + // Main + final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); + glWindowMain.setFullscreen(true); + setContentView(getWindow(), glWindowMain); + anim.add(glWindowMain); + glWindowMain.setVisible(true); + + final MovieSimple demoMain = new MovieSimple(); + demoMain.setScaleOrig(true); + final GLMediaPlayer mPlayer = demoMain.getGLMediaPlayer(); + mPlayer.addEventListener( new GLMediaPlayer.GLMediaEventListener() { + @Override + public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } + + @Override + public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) { + System.err.println("Player AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("Player State: "+mp); + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { + glWindowMain.addGLEventListener(demoMain); + anim.setUpdateFPSFrames(60, System.err); + anim.resetFPSCounter(); + } + if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { + final StreamException se = mPlayer.getStreamException(); + if( null != se ) { + se.printStackTrace(); + } + new Thread() { + public void run() { + glWindowMain.destroy(); + } }.start(); + } + } + }); + demoMain.initStream(streamLoc, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 0); scrn.removeReference(); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index df6b91582..4e86883e4 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -27,7 +27,6 @@ */ package com.jogamp.opengl.test.android; -import java.io.IOException; import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; @@ -51,6 +50,9 @@ import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.av.GLMediaPlayer; +import com.jogamp.opengl.util.av.GLMediaPlayer.GLMediaEventListener; +import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; import android.os.Bundle; import android.util.Log; @@ -110,82 +112,123 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { final com.jogamp.newt.Screen scrn = NewtFactory.createScreen(dpy, 0); scrn.addReference(); - try { - final Animator animator = new Animator(); - - // Main - final MovieSimple demoMain = new MovieSimple(streamLoc0, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO); - if(mPlayerHUD) { - demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP); - demoMain.setTransparency(0.9f); - } - demoMain.setScaleOrig(mPlayerNoZoom); - final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); - { - final int padding = mPlayerHUD ? 32 : 0; - final android.view.View androidView = ((jogamp.newt.driver.android.WindowDriver)glWindowMain.getDelegatedWindow()).getAndroidView(); - glWindowMain.setSize(scrn.getWidth()-padding, scrn.getHeight()-padding); - glWindowMain.setUndecorated(true); - // setContentView(getWindow(), glWindowMain); - viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(glWindowMain.getWidth(), glWindowMain.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); - registerNEWTWindow(glWindowMain); + final Animator anim = new Animator(); + + // Main + final GLWindow glWindowMain = GLWindow.create(scrn, capsMain); + { + final int padding = mPlayerHUD ? 32 : 0; + final android.view.View androidView = ((jogamp.newt.driver.android.WindowDriver)glWindowMain.getDelegatedWindow()).getAndroidView(); + glWindowMain.setSize(scrn.getWidth()-padding, scrn.getHeight()-padding); + glWindowMain.setUndecorated(true); + // setContentView(getWindow(), glWindowMain); + viewGroup.addView(androidView, new android.widget.FrameLayout.LayoutParams(glWindowMain.getWidth(), glWindowMain.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); + registerNEWTWindow(glWindowMain); + } + anim.add(glWindowMain); + glWindowMain.setVisible(true); + + final MovieSimple demoMain = new MovieSimple(); + final GLMediaPlayer mPlayerMain = demoMain.getGLMediaPlayer(); + if(mPlayerHUD) { + demoMain.setEffects(MovieSimple.EFFECT_GRADIENT_BOTTOM2TOP); + demoMain.setTransparency(0.9f); + } + demoMain.setScaleOrig(mPlayerNoZoom); + mPlayerMain.addEventListener( new GLMediaPlayer.GLMediaEventListener() { + @Override + public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } + + @Override + public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) { + System.err.println("Player AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("Player State: "+mp); + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { + glWindowMain.addGLEventListener(demoMain); + anim.setUpdateFPSFrames(60, System.err); + anim.resetFPSCounter(); + } + if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { + final StreamException se = mPlayerMain.getStreamException(); + if( null != se ) { + se.printStackTrace(); + } + new Thread() { + public void run() { + glWindowMain.destroy(); + } }.start(); + } } - - glWindowMain.addGLEventListener(demoMain); - animator.add(glWindowMain); - glWindowMain.setVisible(true); - - if(mPlayerHUD) { - final GLMediaPlayer sharedPlayer = mPlayerSharedHUD ? demoMain.getGLMediaPlayer() : null; - final GLCapabilities capsHUD = new GLCapabilities(GLProfile.getGL2ES2()); - capsHUD.setBackgroundOpaque(false); - final GLWindow glWindowHUD = GLWindow.create(scrn, capsHUD); - glWindowMain.invoke(false, new GLRunnable() { - @Override - public boolean run(GLAutoDrawable drawable) { - int x2 = scrn.getX(); - int y2 = scrn.getY(); - int w2 = scrn.getWidth()/3; - int h2 = scrn.getHeight()/3; - if(null != sharedPlayer) { - if(0 < sharedPlayer.getWidth() && sharedPlayer.getWidth()"); } + try { - mPlayer.initGLStream(gl, textureCount, streamLoc, vid, aid); - } catch (Exception e) { - e.printStackTrace(); + mPlayer.initGL(gl); + } catch (Exception e) { + e.printStackTrace(); if(null != mPlayer) { mPlayer.destroy(gl); mPlayer = null; } throw new GLException(e); } - cube.init(drawable); mPlayer.play(); + System.out.println("pStart "+mPlayer); boolean added; final Object upstreamWidget = drawable.getUpstreamWidget(); @@ -194,6 +217,10 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } if(null == mPlayer) { return; } cube.reshape(drawable, x, y, width, height); } @@ -209,8 +236,6 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { cube=null; } - long lastPerfPos = 0; - @Override public void display(GLAutoDrawable drawable) { if(null == mPlayer) { return; } @@ -225,6 +250,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } public static void main(String[] args) throws IOException, InterruptedException, URISyntaxException { + int swapInterval = 1; int width = 510; int height = 300; int textureCount = 3; // default - threaded @@ -237,7 +263,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { int aid = GLMediaPlayer.STREAM_ID_AUTO; final boolean origSize; - String url_s="http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"; + String url_s=null; { boolean _origSize = false; for(int i=0; i Date: Sat, 24 Aug 2013 17:56:49 +0200 Subject: GLMediaPlayer Multithreaded Decoding: GLMediaPlayer* (Part-6) - DONE Multithreaded decoding and API should be considered stable by now, minor changes may apply if Android/OMX impl. requires it. We still need to solve TODO's as listed below, copied from 474ce65081ecd452215bc07ab866666cb11ca8b1. +++ - *TextureFrame OO changes: - TextureFrame extends TimeFrameI - GLMediaPlayerImpl* - Adapt to Ringbuffer changes of GlueGen commit f9f881e59c78e3036cb3f956bc97cfc3197f620d - Fix impl. method's API doc - getNextTextureImpl(..) returns video PTS - Fix audio-only playback - frame dropping shall only happen if: - previous frame has not been dropped - frame is too later - one decoded frame is already available - Don't block for decoder anymore: - nextFrame = "videoFramesDecoded.getBlocking() -> videoFramesDecoded.get()"; No 'next decoded frame avail' only could mean: - slow decoding/hardware - slow transport hence we shall not block rendering. - Add DEBUG output if using last frame - Add integer property 'jogl.debug.GLMediaPlayer.StreamWorker.delay' in milliseconds to simulate slow decoding, i.e. delay is added in StreamWorker after decoding before pushing new frame to Ringbuffer. - FFMPEGMediaPlayer: - audioFrameLimitWithVideo 128 -> 64 - audioFrameLimitAudioOnly 128 -> 32 - uses AudioSink's 'enqueueData(int pts, ByteBuffer bytes, int byteCount)' - fixes for audio-only playback +++ Working Tests: MovieSimple and MovieCube TODO-1: Fix - Android - OMXGLMediaPlayer TODO-2: - Fix issue where async audio frames arrive much later than 1st video frame, i.e. around 300ms. - Default TextureCount .. maybe 3 ? - Adding Audio synchronization ? - Find 'truth' about correlation of audio and video PTS values, currently, we assume both to be unrelated ? --- make/scripts/tests.sh | 5 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 12 +- .../opengl/util/texture/TextureSequence.java | 28 +-- .../android/av/AndroidGLMediaPlayerAPI14.java | 9 +- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 253 +++++++++++++-------- .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 41 ++-- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 43 ++-- .../opengl/util/av/impl/OMXGLMediaPlayer.java | 5 +- src/jogl/native/libav/ffmpeg_tool.h | 4 +- .../jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c | 44 ++-- .../opengl/test/android/MovieCubeActivity0.java | 4 +- .../opengl/test/android/MovieSimpleActivity0.java | 4 +- .../opengl/test/android/MovieSimpleActivity1.java | 4 +- .../jogl/demos/es2/TextureSequenceCubeES2.java | 35 +-- .../test/junit/jogl/demos/es2/av/MovieCube.java | 24 +- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 74 +++--- 16 files changed, 322 insertions(+), 267 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6475f06b4..c7207bbcf 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -134,6 +134,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" @@ -318,8 +319,8 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 726eddb01..02fbd721c 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -35,6 +35,7 @@ import javax.media.opengl.GLException; import jogamp.opengl.Debug; import com.jogamp.opengl.util.texture.TextureSequence; +import com.jogamp.opengl.util.TimeFrameI; /** * GLMediaPlayer interface specifies a {@link TextureSequence} state machine @@ -116,14 +117,11 @@ import com.jogamp.opengl.util.texture.TextureSequence; * to be properly considered by {@link GLMediaPlayerFactory#create(ClassLoader, String)} * and {@link GLMediaPlayerFactory#createDefault()}. *

      + *
      Timestamp Accuracy
      *

      - * Variable type, value range and dimension has been chosen to suit embedded CPUs - * and characteristics of audio and video streaming. - * Milliseconds of type integer with a maximum value of {@link Integer#MAX_VALUE} - * will allow tracking time up 2,147,483.647 seconds or - * 24 days 20 hours 31 minutes and 23 seconds. - * Milliseconds granularity is also more than enough to deal with A-V synchronization, - * where the threshold usually lies within 22ms. + *

      + * Timestamp type and value range has been chosen to suit embedded CPUs + * and characteristics of audio and video streaming. See {@link TimeFrameI}. *

      * *
      Audio and video synchronization
      diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index e13e5ff13..8b6cc1bf9 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -29,6 +29,8 @@ package com.jogamp.opengl.util.texture; import javax.media.opengl.GL; +import com.jogamp.opengl.util.TimeFrameI; + /** * Protocol for texture sequences, like animations, movies, etc. *

      @@ -109,35 +111,21 @@ public interface TextureSequence { * Texture holder interface, maybe specialized by implementation * to associated related data. */ - public static class TextureFrame { - /** Constant marking an invalid PTS, i.e. Integer.MIN_VALUE == 0x80000000 == {@value}. Sync w/ native code. */ - public static final int INVALID_PTS = 0x80000000; - - /** Constant marking the end of the stream PTS, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ native code. */ - public static final int END_OF_STREAM_PTS = 0x7FFFFFFF; - + public static class TextureFrame extends TimeFrameI { + public TextureFrame(Texture t, int pts, int duration) { + super(pts, duration); + texture = t; + } public TextureFrame(Texture t) { texture = t; - pts = INVALID_PTS; - duration = 0; } public final Texture getTexture() { return texture; } - /** Get this frame's presentation timestamp (PTS) in milliseconds. */ - public final int getPTS() { return pts; } - /** Set this frame's presentation timestamp (PTS) in milliseconds. */ - public final void setPTS(int pts) { this.pts = pts; } - /** Get this frame's duration in milliseconds. */ - public final int getDuration() { return duration; } - /** Set this frame's duration in milliseconds. */ - public final void setDuration(int duration) { this.duration = duration; } public String toString() { - return "TextureFrame[pts " + pts + " ms, l " + duration + " ms, texID "+ texture.getTextureObject() + "]"; + return "TextureFrame[pts " + pts + " ms, l " + duration + " ms, texID "+ (null != texture ? texture.getTextureObject() : 0) + "]"; } protected final Texture texture; - protected int pts; - protected int duration; } public interface TexSeqEventListener { diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 578a219e9..63d9c8d22 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -35,6 +35,7 @@ import javax.media.opengl.GLException; import com.jogamp.common.os.AndroidVersion; import com.jogamp.common.os.Platform; +import com.jogamp.opengl.util.TimeFrameI; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; @@ -227,7 +228,8 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame) { + protected final int getNextTextureImpl(GL gl, TextureFrame nextFrame) { + int pts = TimeFrameI.INVALID_PTS; if(null != stex && null != mp) { final SurfaceTextureFrame nextSFrame = (SurfaceTextureFrame) nextFrame; final Surface nextSurface = nextSFrame.getSurface(); @@ -254,11 +256,12 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { final SurfaceTexture nextSTex = nextSFrame.getSurfaceTexture(); nextSTex.updateTexImage(); // nextFrame.setPTS( (int) ( nextSTex.getTimestamp() / 1000000L ) ); // nano -9 -> milli -3 - nextFrame.setPTS( mp.getCurrentPosition() ); + pts = mp.getCurrentPosition(); + nextFrame.setPTS( pts ); // stex.getTransformMatrix(atex.getSTMatrix()); } } - return true; + return pts; } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 8193175b7..238595d45 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -42,14 +42,17 @@ import javax.media.opengl.GLES2; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.opengl.Debug; + import com.jogamp.common.os.Platform; import com.jogamp.common.util.LFRingbuffer; import com.jogamp.common.util.Ringbuffer; +import com.jogamp.opengl.util.TimeFrameI; import com.jogamp.opengl.util.av.AudioSink; -import com.jogamp.opengl.util.av.AudioSink.AudioFrame; import com.jogamp.opengl.util.av.GLMediaPlayer; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; /** * After object creation an implementation may customize the behavior: @@ -64,6 +67,7 @@ import com.jogamp.opengl.util.texture.TextureSequence; *

      */ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { + private static final int STREAM_WORKER_DELAY = Debug.getIntProperty("jogl.debug.GLMediaPlayer.StreamWorker.delay", false, 0); protected static final String unknown = "unknown"; @@ -151,13 +155,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private ArrayList eventListeners = new ArrayList(); - private static Ringbuffer.AllocEmptyArray rbAllocTextureFrameArray = new Ringbuffer.AllocEmptyArray() { - @Override - public TextureFrame[] newArray(int size) { - return new TextureFrame[size]; - } - }; - protected GLMediaPlayerImpl() { this.textureCount=0; this.textureTarget=GL.GL_TEXTURE_2D; @@ -284,6 +281,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final State play() { synchronized( stateLock ) { + final State preState = state; switch( state ) { case Paused: if( playImpl() ) { @@ -296,7 +294,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } default: } - if(DEBUG) { System.err.println("Play: "+toString()); } + if(DEBUG) { System.err.println("Play: "+preState+" -> "+state+", "+toString()); } return state; } } @@ -308,6 +306,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } private final State pauseImpl(int event_mask) { synchronized( stateLock ) { + final State preState = state; if( State.Playing == state ) { event_mask = addStateEventMask(event_mask, GLMediaPlayer.State.Paused); state = State.Paused; @@ -320,7 +319,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { play(); } } - if(DEBUG) { System.err.println("Pause: "+toString()); } + if(DEBUG) { System.err.println("Pause: "+preState+" -> "+state+", "+toString()); } return state; } } @@ -329,6 +328,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final int seek(int msec) { synchronized( stateLock ) { + final State preState = state; final int pts1; switch(state) { case Playing: @@ -348,7 +348,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { default: pts1 = 0; } - if(DEBUG) { System.err.println("Seek("+msec+"): "+toString()); } + if(DEBUG) { System.err.println("Seek("+msec+"): "+preState+" -> "+state+", "+toString()); } return pts1; } } @@ -362,6 +362,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final boolean setPlaySpeed(float rate) { synchronized( stateLock ) { + final State preState = state; + final float preSpeed = playSpeed; boolean res = false; if(State.Uninitialized != state ) { if( rate > 0.01f ) { @@ -371,11 +373,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( setPlaySpeedImpl(rate) ) { resetAudioVideoPTS(); playSpeed = rate; - if(DEBUG) { System.err.println("SetPlaySpeed: "+toString()); } res = true; } } } + if(DEBUG) { System.err.println("setPlaySpeed("+rate+"): "+preState+"/"+preSpeed+" -> "+state+"/"+playSpeed+", "+toString()); } return res; } } @@ -464,14 +466,16 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { removeAllTextureFrames(gl); initGLImpl(gl); videoFramesOrig = createTexFrames(gl, textureCount); - videoFramesFree = new LFRingbuffer(videoFramesOrig, rbAllocTextureFrameArray); - videoFramesDecoded = new LFRingbuffer(textureCount, rbAllocTextureFrameArray); + videoFramesFree = new LFRingbuffer(videoFramesOrig); + videoFramesDecoded = new LFRingbuffer(TextureFrame[].class, textureCount); lastFrame = videoFramesFree.getBlocking( ); streamWorker.initGL(gl); } else { + removeAllTextureFrames(null); initGLImpl(null); setTextureFormat(-1, -1); setTextureType(-1); + videoFramesOrig = null; videoFramesFree = null; videoFramesDecoded = null; lastFrame = null; @@ -482,6 +486,15 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } + /** + * Shall initialize all GL related resources, if not audio-only. + *

      + * Shall also take care of {@link AudioSink} initialization if appropriate. + *

      + * @param gl null for audio-only, otherwise a valid and current GL object. + * @throws IOException + * @throws GLException + */ protected abstract void initGLImpl(GL gl) throws IOException, GLException; /** @@ -570,12 +583,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } private final void removeAllTextureFrames(GL gl) { - if( null != videoFramesOrig ) { - final TextureFrame[] texFrames = videoFramesOrig; - videoFramesOrig = null; - videoFramesFree = null; - videoFramesDecoded = null; - lastFrame = null; + final TextureFrame[] texFrames = videoFramesOrig; + videoFramesOrig = null; + videoFramesFree = null; + videoFramesDecoded = null; + lastFrame = null; + if( null != texFrames ) { for(int i=0; i maxVideoDelay ) { cachedFrame = nextFrame; nextFrame = null; - } else if ( dt < -maxVideoDelay ) { + } else if ( !droppedFrame && dt < -maxVideoDelay && videoFramesDecoded.size() > 0 ) { + // only drop if prev. frame has not been dropped and + // frame is too late and one decoded frame is already available. dropFrame = true; } video_pts_last = video_pts; @@ -682,6 +701,20 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { lastFrame = nextFrame; videoFramesFree.putBlocking(_lastFrame); } + } else if( DEBUG ) { + final int video_pts = lastFrame.getPTS(); + final int audio_pts = getAudioPTSImpl(); + final int audio_scr = (int) ( ( currentTimeMillis - audio_scr_t0 ) * playSpeed ); + final int d_apts; + if( audio_pts != TimeFrameI.INVALID_PTS ) { + d_apts = audio_pts - audio_scr; + } else { + d_apts = 0; + } + final int video_scr = video_scr_pts + (int) ( ( currentTimeMillis - video_scr_t0 ) * playSpeed ); + final int d_vpts = video_pts - video_scr; + System.err.println( "AV~: dT "+(currentTimeMillis-lastTimeMillis)+", "+ + getPerfStringImpl( video_scr, video_pts, d_vpts, audio_scr, audio_pts, d_apts, 0 ) + ", droppedFrame "+droppedFrame); } lastTimeMillis = currentTimeMillis; } while( dropFrame ); @@ -696,12 +729,27 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected void preNextTextureImpl(GL gl) {} protected void postNextTextureImpl(GL gl) {} /** + * Process stream until the next video frame, i.e. {@link TextureFrame}, has been reached. + * Audio frames, i.e. {@link AudioSink.AudioFrame}, shall be handled in the process. + *

      + * Video frames shall be ignored, if {@link #getVID()} is {@link #STREAM_ID_NONE}. + *

      + *

      + * Audio frames shall be ignored, if {@link #getAID()} is {@link #STREAM_ID_NONE}. + *

      + *

      + * Methods is invoked on the StreamWorker decoding thread. + *

      + *

      * Implementation shall care of OpenGL synchronization as required, e.g. glFinish()/glFlush()! - * @param gl - * @param nextFrame - * @return + *

      + * @param gl valid and current GL instance, shall be null for audio only. + * @param nextFrame the {@link TextureFrame} to store the video PTS and texture data, + * shall be null for audio only. + * @return the last processed video PTS value, maybe {@link TimeFrameI#INVALID_PTS} if video frame is invalid or n/a. + * Will be {@link TimeFrameI#END_OF_STREAM_PTS} if end of stream reached. */ - protected abstract boolean getNextTextureImpl(GL gl, TextureFrame nextFrame); + protected abstract int getNextTextureImpl(GL gl, TextureFrame nextFrame); /** * {@inheritDoc} @@ -731,12 +779,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private void flushAllVideoFrames() { if( null != videoFramesFree ) { videoFramesFree.resetFull(videoFramesOrig); + lastFrame = videoFramesFree.get(); + if( null == lastFrame ) { throw new InternalError("XXX"); } } if( null != videoFramesDecoded ) { videoFramesDecoded.clear(); } - lastFrame = videoFramesFree.get( ); - if( null == lastFrame ) { throw new InternalError("XXX"); } cachedFrame = null; } private void resetAllAudioVideoSync() { @@ -842,14 +890,16 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public synchronized void doPause() { if( isActive ) { shallPause = true; - if( isBlocked && isActive ) { - this.interrupt(); - } - while( isActive ) { - try { - this.wait(); // wait until paused - } catch (InterruptedException e) { - e.printStackTrace(); + if( Thread.currentThread() != this ) { + if( isBlocked && isActive ) { + this.interrupt(); + } + while( isActive ) { + try { + this.wait(); // wait until paused + } catch (InterruptedException e) { + e.printStackTrace(); + } } } } @@ -857,12 +907,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public synchronized void doResume() { if( isRunning && !isActive ) { shallPause = false; - while( !isActive ) { - this.notify(); // wake-up pause-block - try { - this.wait(); // wait until resumed - } catch (InterruptedException e) { - e.printStackTrace(); + if( Thread.currentThread() != this ) { + while( !isActive ) { + this.notify(); // wake-up pause-block + try { + this.wait(); // wait until resumed + } catch (InterruptedException e) { + e.printStackTrace(); + } } } } @@ -870,15 +922,17 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public synchronized void doStop() { if( isRunning ) { shallStop = true; - if( isBlocked && isRunning ) { - this.interrupt(); - } - while( isRunning ) { - this.notify(); // wake-up pause-block (opt) - try { - this.wait(); // wait until stopped - } catch (InterruptedException e) { - e.printStackTrace(); + if( Thread.currentThread() != this ) { + if( isBlocked && isRunning ) { + this.interrupt(); + } + while( isRunning ) { + this.notify(); // wake-up pause-block (opt) + try { + this.wait(); // wait until stopped + } catch (InterruptedException e) { + e.printStackTrace(); + } } } } @@ -939,51 +993,68 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { preNextTextureImpl(sharedGLCtx.getGL()); sharedGLCtxCurrent = true; } + if( null == videoFramesFree ) { + throw new InternalError("XXX videoFramesFree is null"); + } } } if( !shallStop ) { TextureFrame nextFrame = null; - if( null != sharedGLCtx ) { - try { - isBlocked = true; - nextFrame = videoFramesFree.getBlocking( ); - isBlocked = false; - nextFrame.setPTS( TextureFrame.INVALID_PTS ); // mark invalid until processed! - final GL gl = sharedGLCtxCurrent ? sharedGLCtx.getGL() : null; - if( getNextTextureImpl(gl, nextFrame) ) { + try { + final GL gl; + isBlocked = true; + if( null != videoFramesFree ) { + nextFrame = videoFramesFree.getBlocking(); + nextFrame.setPTS( TimeFrameI.INVALID_PTS ); // mark invalid until processed! + gl = sharedGLCtx.getGL(); + } else { + gl = null; + } + isBlocked = false; + final int vPTS = getNextTextureImpl(gl, nextFrame); + if( TimeFrameI.INVALID_PTS != vPTS ) { + if( null != nextFrame ) { + if( STREAM_WORKER_DELAY > 0 ) { + Thread.sleep(STREAM_WORKER_DELAY); + } if( !videoFramesDecoded.put(nextFrame) ) { throw new InternalError("XXX: free "+videoFramesFree+", decoded "+videoFramesDecoded+", "+GLMediaPlayerImpl.this); } newFrameAvailable(nextFrame, Platform.currentTimeMillis()); nextFrame = null; - } - } catch (InterruptedException e) { - isBlocked = false; - if( !shallStop && !shallPause ) { - streamErr = new StreamException("InterruptedException while decoding: "+GLMediaPlayerImpl.this.toString(), e); - } - } catch (Throwable t) { - streamErr = new StreamException(t.getClass().getSimpleName()+" while decoding: "+GLMediaPlayerImpl.this.toString(), t); - } finally { - if( null != nextFrame ) { // put back - videoFramesFree.put(nextFrame); - } - if( null != streamErr ) { - if( DEBUG ) { - final Throwable t = null != streamErr.getCause() ? streamErr.getCause() : streamErr; - System.err.println("Caught StreamException: "+t.getMessage()); - t.printStackTrace(); + } else { + // audio only + if( TimeFrameI.END_OF_STREAM_PTS == vPTS ) { + // state transition incl. notification + shallPause = true; + isActive = false; + pauseImpl(GLMediaEventListener.EVENT_CHANGE_EOS); } - // state transition incl. notification - shallPause = true; - isActive = false; - pause(); } } - } else { - // audio only - getNextTextureImpl(null, null); + } catch (InterruptedException e) { + isBlocked = false; + if( !shallStop && !shallPause ) { + streamErr = new StreamException("InterruptedException while decoding: "+GLMediaPlayerImpl.this.toString(), e); + } + } catch (Throwable t) { + streamErr = new StreamException(t.getClass().getSimpleName()+" while decoding: "+GLMediaPlayerImpl.this.toString(), t); + } finally { + if( null != nextFrame ) { // put back + videoFramesFree.put(nextFrame); + } + if( null != streamErr ) { + if( DEBUG ) { + final Throwable t = null != streamErr.getCause() ? streamErr.getCause() : streamErr; + System.err.println("Caught StreamException: "+t.getMessage()); + t.printStackTrace(); + } + // state transition incl. notification + shallPause = true; + isActive = false; + pauseImpl(GLMediaEventListener.EVENT_CHANGE_ERR); + } } } } @@ -1106,13 +1177,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { destroyImpl(gl); removeAllTextureFrames(gl); textureCount=0; - if( null != videoFramesFree ) { - videoFramesFree.clear(); - } - if( null != videoFramesDecoded ) { - videoFramesDecoded.clear(); - } - changeState(0, State.Uninitialized); + changeState(0, State.Uninitialized); return state; } } @@ -1215,7 +1280,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final String audioSinkInfo; final AudioSink audioSink = getAudioSink(); if( null != audioSink ) { - audioSinkInfo = "AudioSink[frames [d "+audioSink.getEnqueuedFrameCount()+", q "+audioSink.getQueuedFrameCount()+", f "+audioSink.getFreeFrameCount()+"], time "+audioSink.getQueuedTime()+", bytes "+audioSink.getQueuedByteCount()+"]"; + audioSinkInfo = "AudioSink[frames [p "+audioSink.getEnqueuedFrameCount()+", q "+audioSink.getQueuedFrameCount()+", f "+audioSink.getFreeFrameCount()+", c "+audioSink.getFrameCount()+"], time "+audioSink.getQueuedTime()+", bytes "+audioSink.getQueuedByteCount()+"]"; } else { audioSinkInfo = ""; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index 31ac55ec3..9066f3dd1 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -83,9 +83,10 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame) { - nextFrame.setPTS( getAudioPTSImpl() ); - return true; + protected final int getNextTextureImpl(GL gl, TextureFrame nextFrame) { + final int pts = getAudioPTSImpl(); + nextFrame.setPTS( pts ); + return pts; } @Override @@ -102,40 +103,42 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { texData = null; } } - - @Override - protected final void initStreamImpl(int vid, int aid) throws IOException { + + public final static TextureData createTestTextureData() { + TextureData res = null; try { - URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", this.getClass().getClassLoader()); + URLConnection urlConn = IOUtil.getResource("jogl/util/data/av/test-ntsc01-160x90.png", NullGLMediaPlayer.class.getClassLoader()); if(null != urlConn) { - texData = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG); + res = TextureIO.newTextureData(GLProfile.getGL2ES2(), urlConn.getInputStream(), false, TextureIO.PNG); } } catch (Exception e) { e.printStackTrace(); } - final int _w, _h; - if(null != texData) { - _w = texData.getWidth(); - _h = texData.getHeight(); - } else { - _w = 640; - _h = 480; - ByteBuffer buffer = Buffers.newDirectByteBuffer(_w*_h*4); + if(null == res) { + final int w = 160; + final int h = 90; + ByteBuffer buffer = Buffers.newDirectByteBuffer(w*h*4); while(buffer.hasRemaining()) { buffer.put((byte) 0xEA); buffer.put((byte) 0xEA); buffer.put((byte) 0xEA); buffer.put((byte) 0xEA); } buffer.rewind(); - texData = new TextureData(GLProfile.getGL2ES2(), - GL.GL_RGBA, _w, _h, 0, + res = new TextureData(GLProfile.getGL2ES2(), + GL.GL_RGBA, w, h, 0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, false, false, false, buffer, null); } + return res; + } + + @Override + protected final void initStreamImpl(int vid, int aid) throws IOException { + texData = createTestTextureData(); final int r_aid = GLMediaPlayer.STREAM_ID_NONE == aid ? GLMediaPlayer.STREAM_ID_NONE : GLMediaPlayer.STREAM_ID_AUTO; final float _fps = 24f; final int _duration = 10*60*1000; // msec final int _totalFrames = (int) ( (_duration/1000)*_fps ); updateAttributes(GLMediaPlayer.STREAM_ID_AUTO, r_aid, - _w, _h, 0, + texData.getWidth(), texData.getHeight(), 0, 0, 0, _fps, _totalFrames, 0, _duration, "png-static", null); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index f1213d751..a800f2a31 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -40,6 +40,7 @@ import javax.media.opengl.GLException; import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; +import com.jogamp.opengl.util.TimeFrameI; import com.jogamp.opengl.util.GLPixelStorageModes; import com.jogamp.opengl.util.av.AudioSink; import com.jogamp.opengl.util.av.AudioSink.AudioDataFormat; @@ -169,7 +170,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { /** Initial audio frame count, ALAudioSink may grow buffer! */ private int initialAudioFrameCount = AV_DEFAULT_AFRAMES; private final int audioFrameGrowAmount = 8; - private final int audioFrameLimit = 128; + private final int audioFrameLimitWithVideo = 64; // 128; + private final int audioFrameLimitAudioOnly = 32; // 64; private SampleFormat aSampleFmt = null; private AudioSink.AudioDataFormat avChosenAudioFormat; private AudioSink.AudioDataFormat sinkChosenAudioFormat; @@ -235,6 +237,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(null == audioSink) { throw new GLException("AudioSink null"); } + final int audioFrameLimit; if( null != gl ) { final GLContextImpl ctx = (GLContextImpl)gl.getContext(); AccessController.doPrivileged(new PrivilegedAction() { @@ -247,7 +250,10 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { setGLFuncs0(moviePtr, procAddrGLTexSubImage2D, procAddrGLGetError, procAddrGLFlush, procAddrGLFinish); return null; } } ); - } + audioFrameLimit = audioFrameLimitWithVideo; + } else { + audioFrameLimit = audioFrameLimitAudioOnly; + } sinkChosenAudioFormat = audioSink.initSink(avChosenAudioFormat, initialAudioFrameCount, audioFrameGrowAmount, audioFrameLimit); if(DEBUG) { @@ -303,7 +309,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { */ private void updateAttributes2(int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, int lSz0, int lSz1, int lSz2, - int tWd0, int tWd1, int tWd2, + int tWd0, int tWd1, int tWd2, int tH, int audioFrameCount, int sampleFmt, int sampleRate, int channels) { vPixelFmt = PixelFormat.valueOf(pixFmt); vPlanes = planes; @@ -320,7 +326,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { // w*h + 2 ( w/2 * h/2 ) // w*h + w*h/2 // 2*w/2 * h - texWidth = vTexWidth[0] + vTexWidth[1]; texHeight = height; + texWidth = vTexWidth[0] + vTexWidth[1]; texHeight = tH; break; // case PIX_FMT_YUYV422: case RGB24: @@ -329,7 +335,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case RGBA: case ABGR: case BGRA: - texWidth = vTexWidth[0]; texHeight = height; + texWidth = vTexWidth[0]; texHeight = tH; break; default: // FIXME: Add more formats ! throw new RuntimeException("Unsupported pixelformat: "+vPixelFmt); @@ -487,42 +493,33 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } @Override - protected final boolean getNextTextureImpl(GL gl, TextureFrame nextFrame) { + protected final int getNextTextureImpl(GL gl, TextureFrame nextFrame) { if(0==moviePtr) { throw new GLException("FFMPEG native instance null"); } - int vPTS = TextureFrame.INVALID_PTS; - if( null != nextFrame ) { + int vPTS = TimeFrameI.INVALID_PTS; + if( null != gl ) { final Texture tex = nextFrame.getTexture(); tex.enable(gl); tex.bind(gl); } /** Try decode up to 10 packets to find one containing video. */ - for(int i=0; TextureFrame.INVALID_PTS == vPTS && 10 > i; i++) { + for(int i=0; TimeFrameI.INVALID_PTS == vPTS && 10 > i; i++) { vPTS = readNextPacket0(moviePtr, textureTarget, textureFormat, textureType); } - if( TextureFrame.INVALID_PTS != vPTS ) { - if( null != nextFrame ) { - nextFrame.setPTS(vPTS); - } - return true; - } else { - return false; + if( null != nextFrame ) { + nextFrame.setPTS(vPTS); } - } + return vPTS; + } private final void pushSound(ByteBuffer sampleData, int data_size, int audio_pts) { setFirstAudioPTS2SCR( audio_pts ); if( 1.0f == playSpeed || audioSinkPlaySpeedSet ) { - audioSink.enqueueData( new AudioSink.AudioFrame(sampleData, data_size, audio_pts ) ); + audioSink.enqueueData( audio_pts, sampleData, data_size); } } - - private final int getBytesPerMS(int time) { - final int bytesPerSample = sinkChosenAudioFormat.sampleSize >>> 3; // /8 - return time * ( sinkChosenAudioFormat.channelCount * bytesPerSample * ( sinkChosenAudioFormat.sampleRate / 1000 ) ); - } private static native int getAvUtilVersion0(); private static native int getAvFormatVersion0(); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java index e1b773e9b..faa6a56c4 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java @@ -164,12 +164,13 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } @Override - protected boolean getNextTextureImpl(GL gl, TextureFrame nextFrame) { + protected int getNextTextureImpl(GL gl, TextureFrame nextFrame) { if(0==moviePtr) { throw new GLException("OMX native instance null"); } final int nextTex = _getNextTextureID(moviePtr, true); if(0 < nextTex) { + // FIXME set pts ! /* FIXME final TextureSequence.TextureFrame eglImgTex = texFrameMap.get(new Integer(_getNextTextureID(moviePtr, blocking))); @@ -177,7 +178,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { lastTex = eglImgTex; } */ } - return true; + return 0; // FIXME: return pts } private String replaceAll(String orig, String search, String repl) { diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index 76de406ae..013cc0cf2 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -73,10 +73,10 @@ typedef void (APIENTRYP PFNGLFINISH) (void); /** Default number of audio frames per video frame. Sync w/ FFMPEGMediaPlayer.AV_DEFAULT_AFRAMES. */ #define AV_DEFAULT_AFRAMES 8 -/** Constant PTS marking an invalid PTS, i.e. Integer.MIN_VALUE == 0x80000000 == {@value}. Sync w/ TextureFrame.INVALID_PTS */ +/** Constant PTS marking an invalid PTS, i.e. Integer.MIN_VALUE == 0x80000000 == {@value}. Sync w/ TimeFrameI.INVALID_PTS */ #define INVALID_PTS 0x80000000 -/** Constant PTS marking the end of the stream, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ TextureFrame.END_OF_STREAM_PTS */ +/** Constant PTS marking the end of the stream, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ TimeFrameI.END_OF_STREAM_PTS */ #define END_OF_STREAM_PTS 0x7FFFFFFF /** Until 55.0.0 */ diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c index 99ef02da5..63164e547 100644 --- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c +++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c @@ -234,6 +234,12 @@ static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasic w = 0; h = 0; } + (*env)->CallVoidMethod(env, instance, jni_mid_updateAttributes2, + pAV->vPixFmt, pAV->vBufferPlanes, + pAV->vBitsPerPixel, pAV->vBytesPerPixelPerPlane, + pAV->vLinesize[0], pAV->vLinesize[1], pAV->vLinesize[2], + pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2], h, + pAV->aFramesPerVideoFrame, pAV->aSampleFmt, pAV->aSampleRate, pAV->aChannels); (*env)->CallVoidMethod(env, instance, jni_mid_updateAttributes1, pAV->vid, pAV->aid, w, h, @@ -241,12 +247,6 @@ static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasic pAV->fps, pAV->frames_video, pAV->frames_audio, pAV->duration, (*env)->NewStringUTF(env, pAV->vcodec), (*env)->NewStringUTF(env, pAV->acodec) ); - (*env)->CallVoidMethod(env, instance, jni_mid_updateAttributes2, - pAV->vPixFmt, pAV->vBufferPlanes, - pAV->vBitsPerPixel, pAV->vBytesPerPixelPerPlane, - pAV->vLinesize[0], pAV->vLinesize[1], pAV->vLinesize[2], - pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2], - pAV->aFramesPerVideoFrame, pAV->aSampleFmt, pAV->aSampleRate, pAV->aChannels); } } @@ -392,7 +392,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_ini jni_mid_pushSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "pushSound", "(Ljava/nio/ByteBuffer;II)V"); jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIIIFIIILjava/lang/String;Ljava/lang/String;)V"); - jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIII)V"); + jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIIII)V"); if(jni_mid_pushSound == NULL || jni_mid_updateAttributes1 == NULL || @@ -858,9 +858,10 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex if( AVERROR_EOF == avRes || ( pAV->pFormatCtx->pb && pAV->pFormatCtx->pb->eof_reached ) ) { resPTS = END_OF_STREAM_PTS; } else if( 0 <= avRes ) { + /** if( pAV->verbose ) { fprintf(stderr, "P: ptr %p, size %d\n", packet.data, packet.size); - } + } */ if(packet.stream_index==pAV->aid) { // Decode audio frame if(NULL == pAV->pAFrames) { // no audio registered @@ -1206,38 +1207,43 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_seek0 { const FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); const int64_t pos0 = pAV->vPTS; - const int64_t pts0 = pAV->pVFrame->pkt_pts; + int64_t pts0; int streamID; AVRational time_base; if( pAV->vid >= 0 ) { streamID = pAV->vid; time_base = pAV->pVStream->time_base; + pts0 = pAV->pVFrame->pkt_pts; } else if( pAV->aid >= 0 ) { streamID = pAV->aid; time_base = pAV->pAStream->time_base; + pts0 = pAV->pAFrames[pAV->aFrameCurrent]->pkt_pts; } else { return pAV->vPTS; } int64_t pts1 = (int64_t) (pos1 * (int64_t) time_base.den) / (1000 * (int64_t) time_base.num); + if(pAV->verbose) { + fprintf(stderr, "SEEK: vid %d, aid %d, pos1 %d, pts: %ld -> %ld\n", pAV->vid, pAV->aid, pos1, pts0, pts1); + } int flags = 0; if(pos1 < pos0) { flags |= AVSEEK_FLAG_BACKWARD; } int res; if(HAS_FUNC(sp_av_seek_frame)) { - if(pos1 < pos0) { - flags |= AVSEEK_FLAG_BACKWARD; + if(pAV->verbose) { + fprintf(stderr, "SEEK.0: pre : s %ld / %ld -> t %d / %ld\n", pos0, pts0, pos1, pts1); } - fprintf(stderr, "SEEK.0: pre : s %ld / %ld -> t %ld / %ld\n", pos0, pts0, pos1, pts1); sp_av_seek_frame(pAV->pFormatCtx, streamID, pts1, flags); - } else if(HAS_FUNC(sp_avformat_seek_file)) { int64_t ptsD = pts1 - pts0; int64_t seek_min = ptsD > 0 ? pts1 - ptsD : INT64_MIN; int64_t seek_max = ptsD < 0 ? pts1 - ptsD : INT64_MAX; - fprintf(stderr, "SEEK.1: pre : s %ld / %ld -> t %ld / %ld [%ld .. %ld]\n", - pos0, pts0, pos1, pts1, seek_min, seek_max); + if(pAV->verbose) { + fprintf(stderr, "SEEK.1: pre : s %ld / %ld -> t %d / %ld [%ld .. %ld]\n", + pos0, pts0, pos1, pts1, seek_min, seek_max); + } res = sp_avformat_seek_file(pAV->pFormatCtx, -1, seek_min, pts1, seek_max, flags); } if(NULL != pAV->pVCodecCtx) { @@ -1246,9 +1252,11 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_seek0 if(NULL != pAV->pACodecCtx) { sp_avcodec_flush_buffers( pAV->pACodecCtx ); } - const jint vPTS = my_av_q2i32( pAV->pVFrame->pkt_pts * 1000, pAV->pVStream->time_base); - fprintf(stderr, "SEEK: post : res %d, u %ld, p %ld\n", res, vPTS, pAV->pVFrame->pkt_pts); - return vPTS; + const jint rPTS = my_av_q2i32( ( pAV->vid >= 0 ? pAV->pVFrame->pkt_pts : pAV->pAFrames[pAV->aFrameCurrent]->pkt_pts ) * 1000, time_base); + if(pAV->verbose) { + fprintf(stderr, "SEEK: post : res %d, u %ld\n", res, rPTS); + } + return rPTS; } JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_getVideoPTS0 diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java index c9acab64b..783742fec 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivity0.java @@ -107,8 +107,8 @@ public class MovieCubeActivity0 extends NewtBaseActivity { @Override public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { - System.err.println("Player AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); - System.err.println("Player State: "+mp); + System.err.println("MovieCubeActivity0 AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieCubeActivity0 State: "+mp); if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { glWindowMain.addGLEventListener(demoMain); anim.setUpdateFPSFrames(60, System.err); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java index d4cb226f2..467ad1e75 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity0.java @@ -104,8 +104,8 @@ public class MovieSimpleActivity0 extends NewtBaseActivity { @Override public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) { - System.err.println("Player AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); - System.err.println("Player State: "+mp); + System.err.println("MovieSimpleActivity0 AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieSimpleActivity0 State: "+mp); if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { glWindowMain.addGLEventListener(demoMain); anim.setUpdateFPSFrames(60, System.err); diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java index 4e86883e4..84e691e76 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivity1.java @@ -141,8 +141,8 @@ public class MovieSimpleActivity1 extends NewtBaseActivity { @Override public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) { - System.err.println("Player AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); - System.err.println("Player State: "+mp); + System.err.println("MovieSimpleActivity1 AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieSimpleActivity1 State: "+mp); if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { glWindowMain.addGLEventListener(demoMain); anim.setUpdateFPSFrames(60, System.err); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index 4172a2c20..e38b9c6e3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -52,6 +52,7 @@ import com.jogamp.opengl.util.glsl.ShaderState; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureCoords; import com.jogamp.opengl.util.texture.TextureSequence; +import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; public class TextureSequenceCubeES2 implements GLEventListener { public TextureSequenceCubeES2 (TextureSequence texSource, boolean innerCube, float zoom0, float rotx, float roty) { @@ -188,7 +189,11 @@ public class TextureSequenceCubeES2 implements GLEventListener { public void init(GLAutoDrawable drawable) { GL2ES2 gl = drawable.getGL().getGL2ES2(); System.err.println(JoglVersion.getGLInfo(gl, null)); - final Texture tex= texSeq.getLastTexture().getTexture(); + final TextureFrame frame = texSeq.getLastTexture(); + if( null == frame ) { + return; + } + final Texture tex= frame.getTexture(); final boolean useExternalTexture = GLES2.GL_TEXTURE_EXTERNAL_OES == tex.getTarget(); if(useExternalTexture && !gl.isExtensionAvailable("GL_OES_EGL_image_external")) { @@ -315,20 +320,22 @@ public class TextureSequenceCubeES2 implements GLEventListener { private void reshapePMV(int width, int height) { - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); - pmvMatrix.glLoadIdentity(); - if(!innerCube) { - pmvMatrix.gluPerspective(45.0f, (float)width / (float)height, 1f, 10.0f); - nearPlaneNormalized = 1f/(100f-1f); - } else { - pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 10.0f); - nearPlaneNormalized = 0f; + if(null != pmvMatrix) { + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + if(!innerCube) { + pmvMatrix.gluPerspective(45.0f, (float)width / (float)height, 1f, 10.0f); + nearPlaneNormalized = 1f/(100f-1f); + } else { + pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 10.0f); + nearPlaneNormalized = 0f; + } + System.err.println("XXX0: Perspective nearPlaneNormalized: "+nearPlaneNormalized); + + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glTranslatef(0, 0, zoom); } - System.err.println("XXX0: Perspective nearPlaneNormalized: "+nearPlaneNormalized); - - pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); - pmvMatrix.glLoadIdentity(); - pmvMatrix.glTranslatef(0, 0, zoom); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index c48c53189..7fa55f861 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -60,7 +60,7 @@ import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; /** * Simple cube movie player w/ aspect ration true projection on a cube. */ -public class MovieCube implements GLEventListener, GLMediaEventListener { +public class MovieCube implements GLEventListener { private static boolean waitForKey = false; private final float zoom0, rotx, roty; private TextureSequenceCubeES2 cube=null; @@ -89,11 +89,9 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { this.rotx = rotx; this.roty = roty; mPlayer = GLMediaPlayerFactory.createDefault(); - mPlayer.addEventListener(this); } public void initStream(URI streamLoc, int vid, int aid, int textureCount) { - mPlayer.addEventListener(this); mPlayer.initStream(streamLoc, vid, aid, textureCount); System.out.println("pC.1b "+mPlayer); } @@ -160,16 +158,6 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } }; - @Override - public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) { - System.out.println("attributesChanges: "+mp+", 0x"+Integer.toHexString(event_mask)+", when "+when); - } - - @Override - public void newFrameAvailable(GLMediaPlayer mp, TextureFrame newFrame, long when) { - // System.out.println("newFrameAvailable: "+mp+", when "+when); - } - @Override public void init(GLAutoDrawable drawable) { if(null == mPlayer) { @@ -179,8 +167,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { throw new IllegalStateException("mPlayer not in state initialized: "+mPlayer); } if( GLMediaPlayer.STREAM_ID_NONE == mPlayer.getVID() ) { - System.err.println("MovieCube: No VID/stream selected - no GL: "+mPlayer); - return; + // throw new IllegalStateException("mPlayer has no VID/stream selected: "+mPlayer); } GL2ES2 gl = drawable.getGL().getGL2ES2(); System.err.println(JoglVersion.getGLInfo(gl, null)); @@ -203,7 +190,7 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { } cube.init(drawable); mPlayer.play(); - System.out.println("pStart "+mPlayer); + System.out.println("play.0 "+mPlayer); boolean added; final Object upstreamWidget = drawable.getUpstreamWidget(); @@ -245,7 +232,6 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { System.err.println( mPlayer.getPerfString() ); lastPerfPos = currentPos; } - cube.display(drawable); } @@ -353,8 +339,8 @@ public class MovieCube implements GLEventListener, GLMediaEventListener { @Override public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { - System.err.println("Player AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); - System.err.println("Player State: "+mp); + System.err.println("MovieCube AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieCube State: "+mp); if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) && origSize ) { window.setSize(mp.getWidth(), mp.getHeight()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index ecf95f069..672500b1b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -75,7 +75,7 @@ import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; /** * Simple planar movie player w/ orthogonal 1:1 projection. */ -public class MovieSimple implements GLEventListener, GLMediaEventListener { +public class MovieSimple implements GLEventListener { public static final int EFFECT_NORMAL = 0; public static final int EFFECT_GRADIENT_BOTTOM2TOP = 1<<1; public static final int EFFECT_TRANSPARENT = 1<<3; @@ -234,12 +234,10 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { mPlayerShared = true; mPlayerExternal = true; mPlayer = sharedMediaPlayer; - mPlayer.addEventListener(this); System.out.println("pC.2 shared "+mPlayerShared+", "+mPlayer); } public void initStream(URI streamLoc, int vid, int aid, int textureCount) { - mPlayer.addEventListener(this); mPlayer.initStream(streamLoc, vid, aid, textureCount); System.out.println("pC.1b "+mPlayer); } @@ -263,16 +261,6 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { this.alpha = alpha; } - @Override - public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) { - System.out.println("attributesChanges: "+mp+", 0x"+Integer.toHexString(event_mask)+", when "+when); - } - - @Override - public void newFrameAvailable(GLMediaPlayer mp, TextureFrame newFrame, long when) { - // System.out.println("newFrameAvailable: "+mp+", when "+when); - } - private void initShader(GL2ES2 gl) { // Create & Compile the shader objects ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MovieSimple.class, @@ -316,8 +304,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { throw new IllegalStateException("mPlayer not in state initialized: "+mPlayer); } if( GLMediaPlayer.STREAM_ID_NONE == mPlayer.getVID() ) { - System.err.println("MovieSimple: No VID/stream selected - no GL: "+mPlayer); - return; + throw new IllegalStateException("mPlayer has no VID/stream selected: "+mPlayer); } zoom0 = orthoProjection ? 0f : -2.5f; zoom1 = orthoProjection ? 0f : -5f; @@ -338,8 +325,12 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { if(!mPlayerShared) { mPlayer.initGL(gl); } - tex = mPlayer.getLastTexture().getTexture(); System.out.println("p1 "+mPlayer+", shared "+mPlayerShared); + final TextureFrame frame = mPlayer.getLastTexture(); + if( null == frame ) { + throw new InternalError("XXX: "+mPlayer); + } + tex = mPlayer.getLastTexture().getTexture(); useExternalTexture = GLES2.GL_TEXTURE_EXTERNAL_OES == tex.getTarget(); if(useExternalTexture && !gl.isExtensionAvailable("GL_OES_EGL_image_external")) { throw new GLException("GL_OES_EGL_image_external requested but not available"); @@ -415,10 +406,9 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER); final FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer(); - final TextureCoords tc = tex.getImageTexCoords(); - final float aspect = tex.getAspectRatio(); + final TextureCoords tc = tex.getImageTexCoords(); System.err.println("XXX0: "+tc); - System.err.println("XXX0: tex aspect: "+aspect); + System.err.println("XXX0: tex aspect: "+tex.getAspectRatio()); System.err.println("XXX0: tex y-flip: "+tex.getMustFlipVertically()); // left-bottom @@ -472,7 +462,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { if(!mPlayerShared) { mPlayer.play(); - System.out.println("pStart "+mPlayer); + System.out.println("play.0 "+mPlayer); } startTime = System.currentTimeMillis(); @@ -493,9 +483,6 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) } if(null == mPlayer) { return; } - if( GLMediaPlayer.STREAM_ID_NONE == mPlayer.getVID() ) { - return; - } winWidth = width; winHeight = height; @@ -535,7 +522,6 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { System.out.println("pD.1 "+mPlayer); GL2ES2 gl = drawable.getGL().getGL2ES2(); if( null != mPlayer ) { - mPlayer.removeEventListener(this); if(!mPlayerExternal) { mPlayer.destroy(gl); } @@ -563,11 +549,7 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { if( currentPos - lastPerfPos > 2000 ) { System.err.println( mPlayer.getPerfString() ); lastPerfPos = currentPos; - } - - if( GLMediaPlayer.STREAM_ID_NONE == mPlayer.getVID() ) { - return; - } + } GL2ES2 gl = drawable.getGL().getGL2ES2(); @@ -721,31 +703,47 @@ public class MovieSimple implements GLEventListener, GLMediaEventListener { anim.start(); ms.mPlayer.addEventListener(new GLMediaEventListener() { + void destroyWindow() { + new Thread() { + public void run() { + window.destroy(); + } }.start(); + } + @Override public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } @Override public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { - System.err.println("Player AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); - System.err.println("Player State: "+mp); + System.err.println("MovieSimple AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieSimple State: "+mp); if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) && origSize ) { window.setSize(mp.getWidth(), mp.getHeight()); } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { - window.addGLEventListener(ms); - anim.setUpdateFPSFrames(60, System.err); - anim.resetFPSCounter(); + if( GLMediaPlayer.STREAM_ID_NONE != ms.mPlayer.getVID() ) { + window.addGLEventListener(ms); + anim.setUpdateFPSFrames(60, System.err); + anim.resetFPSCounter(); + } else { + try { + ms.mPlayer.initGL(null); + } catch (Exception e) { + e.printStackTrace(); + destroyWindow(); + return; + } + ms.mPlayer.play(); + System.out.println("play.1 "+ms.mPlayer); + } } if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { final StreamException se = ms.mPlayer.getStreamException(); if( null != se ) { se.printStackTrace(); } - new Thread() { - public void run() { - window.destroy(); - } }.start(); + destroyWindow(); } } }); -- cgit v1.2.3 From 1b4edb60e8c91621d93033b8732b2cdef0e7ebe7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 25 Aug 2013 09:12:19 +0200 Subject: libav/ffmpeg: Prepare for lavc54.lavf54.lavu52 - Add compile-time/runtime version check, fail if major versions do not match assuming binary incompatibility - Add: 'av_find_input_format' for future video input support - Manually map '/dev/video' to video input - not working yet. - WINDOWS: Set file to '' - Set input format string depending on OS --- make/scripts/tests-x64.sh | 1 + .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 5 +- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 67 ++++++++++++++++++++-- src/jogl/native/libav/ffmpeg_tool.h | 4 +- .../jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c | 52 ++++++++++++++--- 5 files changed, 111 insertions(+), 18 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.sh b/make/scripts/tests-x64.sh index c3c67624c..7370d06aa 100755 --- a/make/scripts/tests-x64.sh +++ b/make/scripts/tests-x64.sh @@ -3,6 +3,7 @@ SDIR=`dirname $0` #export LD_LIBRARY_PATH=/home/sven/libav/lib:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/home/sven/libav-0.X/lib:$LD_LIBRARY_PATH if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index 8865d47be..b0181bd7d 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -59,7 +59,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { private static final List glueLibNames = new ArrayList(); // none - private static final int symbolCount = 42; + private static final int symbolCount = 43; private static final String[] symbolNames = { "avcodec_version", "avformat_version", @@ -98,6 +98,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avformat_close_input", // 53.17.0 (opt) "av_close_input_file", "av_register_all", + "av_find_input_format", "avformat_open_input", "av_dump_format", "av_read_frame", @@ -108,7 +109,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avformat_network_init", // 53.13.0 (opt) "avformat_network_deinit", // 53.13.0 (opt) "avformat_find_stream_info", // 53.3.0 (opt) -/* 42 */ "av_find_stream_info", +/* 43 */ "av_find_stream_info", }; // alternate symbol names diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index e59a8849f..78f5954e5 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -38,6 +38,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.opengl.util.TimeFrameI; @@ -113,6 +114,9 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { private static final int AV_DEFAULT_AFRAMES = 8; // Instance data + private static final int avUtilMajorVersionCC; + private static final int avFormatMajorVersionCC; + private static final int avCodecMajorVersionCC; private static final VersionNumber avUtilVersion; private static final VersionNumber avFormatVersion; private static final VersionNumber avCodecVersion; @@ -120,19 +124,33 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { static { final boolean libAVGood = FFMPEGDynamicLibraryBundleInfo.initSingleton(); + final boolean libAVVersionGood; if( FFMPEGDynamicLibraryBundleInfo.libsLoaded() ) { + avUtilMajorVersionCC = getAvUtilMajorVersionCC0(); + avFormatMajorVersionCC = getAvFormatMajorVersionCC0(); + avCodecMajorVersionCC = getAvCodecMajorVersionCC0(); avUtilVersion = getAVVersion(getAvUtilVersion0()); avFormatVersion = getAVVersion(getAvFormatVersion0()); avCodecVersion = getAVVersion(getAvCodecVersion0()); - System.err.println("LIB_AV Util : "+avUtilVersion); - System.err.println("LIB_AV Format: "+avFormatVersion); - System.err.println("LIB_AV Codec : "+avCodecVersion); + System.err.println("LIB_AV Util : "+avUtilVersion+" [cc "+avUtilMajorVersionCC+"]"); + System.err.println("LIB_AV Format: "+avFormatVersion+" [cc "+avFormatMajorVersionCC+"]"); + System.err.println("LIB_AV Codec : "+avCodecVersion+" [cc "+avCodecMajorVersionCC+"]"); + libAVVersionGood = avUtilMajorVersionCC == avUtilVersion.getMajor() && + avFormatMajorVersionCC == avFormatVersion.getMajor() && + avCodecMajorVersionCC == avCodecVersion.getMajor(); + if( !libAVVersionGood ) { + System.err.println("LIB_AV Not Matching Compile-Time / Runtime Major-Version"); + } } else { + avUtilMajorVersionCC = 0; + avFormatMajorVersionCC = 0; + avCodecMajorVersionCC = 0; avUtilVersion = null; avFormatVersion = null; avCodecVersion = null; + libAVVersionGood = false; } - available = libAVGood ? initIDs0() : false; + available = libAVGood && libAVVersionGood ? initIDs0() : false; } public static final boolean isAvailable() { return available; } @@ -200,6 +218,9 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } } + public static final String dev_video = "/dev/video"; + private static final int dev_video_len = dev_video.length(); + @Override protected final void initStreamImpl(int vid, int aid) throws IOException { if(0==moviePtr) { @@ -222,7 +243,38 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } // setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc final int snoopVideoFrameCount = 0; // 10*textureCount - setStream0(moviePtr, streamLocS, vid, aid, snoopVideoFrameCount, preferredAudioFormat.channelCount, preferredAudioFormat.sampleRate); + + final int streamLocSLen = streamLocS.length(); + final String inFormat; + final String resStreamLocS; + if( streamLocSLen == dev_video_len + 1 && streamLocS.startsWith(dev_video) ) { + final int index = Integer.valueOf( streamLocS.substring(streamLocSLen-1) ).intValue(); + switch(Platform.OS_TYPE) { + case ANDROID: + // ?? + case FREEBSD: + case HPUX: + case LINUX: + case SUNOS: + resStreamLocS = streamLocS; + inFormat = "video4linux2"; + break; + case WINDOWS: + resStreamLocS = String.valueOf(index); + inFormat = "vfwcap"; + break; + case MACOS: + case OPENKODE: + default: + resStreamLocS = streamLocS; + inFormat = null; + break; + } + } else { + resStreamLocS = streamLocS; + inFormat = null; + } + setStream0(moviePtr, resStreamLocS, inFormat, vid, aid, snoopVideoFrameCount, preferredAudioFormat.channelCount, preferredAudioFormat.sampleRate); } @Override @@ -530,8 +582,11 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } private static native int getAvUtilVersion0(); + private static native int getAvUtilMajorVersionCC0(); private static native int getAvFormatVersion0(); + private static native int getAvFormatMajorVersionCC0(); private static native int getAvCodecVersion0(); + private static native int getAvCodecMajorVersionCC0(); private static native boolean initIDs0(); private native long createInstance0(boolean verbose); private native void destroyInstance0(long moviePtr); @@ -555,7 +610,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { * @param aChannelCount * @param aSampleRate */ - private native void setStream0(long moviePtr, String url, int vid, int aid, int snoopVideoFrameCount, int aChannelCount, int aSampleRate); + private native void setStream0(long moviePtr, String url, String inFormat, int vid, int aid, int snoopVideoFrameCount, int aChannelCount, int aSampleRate); private native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); private native int getVideoPTS0(long moviePtr); diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index d1320ac5d..783746378 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -79,8 +79,8 @@ typedef void (APIENTRYP PFNGLFINISH) (void); /** Constant PTS marking the end of the stream, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ TimeFrameI.END_OF_STREAM_PTS */ #define END_OF_STREAM_PTS 0x7FFFFFFF -/** Until 55.0.0 */ -#define AV_HAS_API_REQUEST_CHANNELS(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) < 55) +/** Until 55.0.0, but stopped working w/ 54 already :( */ +#define AV_HAS_API_REQUEST_CHANNELS(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) < 54) /** Since 55.0.0 */ #define AV_HAS_API_REFCOUNTED_FRAMES(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) >= 55) diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c index 6bbc33863..7bf936113 100644 --- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c +++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c @@ -30,8 +30,13 @@ #include "JoglCommon.h" #include "ffmpeg_tool.h" +#include #include #include +#if LIBAVUTIL_VERSION_MAJOR < 53 + #include + // 52: #include +#endif #include static const char * const ClazzNameFFMPEGMediaPlayer = "jogamp/opengl/util/av/impl/FFMPEGMediaPlayer"; @@ -111,6 +116,7 @@ typedef void (APIENTRYP AVFORMAT_FREE_CONTEXT)(AVFormatContext *s); // 52.96.0 typedef void (APIENTRYP AVFORMAT_CLOSE_INPUT)(AVFormatContext **s); // 53.17.0 typedef void (APIENTRYP AV_CLOSE_INPUT_FILE)(AVFormatContext *s); typedef void (APIENTRYP AV_REGISTER_ALL)(void); +typedef AVInputFormat *(APIENTRYP AV_FIND_INPUT_FORMAT)(const char *short_name); typedef int (APIENTRYP AVFORMAT_OPEN_INPUT)(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options); typedef void (APIENTRYP AV_DUMP_FORMAT)(AVFormatContext *ic, int index, const char *url, int is_output); typedef int (APIENTRYP AV_READ_FRAME)(AVFormatContext *s, AVPacket *pkt); @@ -128,6 +134,7 @@ static AVFORMAT_FREE_CONTEXT sp_avformat_free_context; // 52.96.0 static AVFORMAT_CLOSE_INPUT sp_avformat_close_input; // 53.17.0 static AV_CLOSE_INPUT_FILE sp_av_close_input_file; static AV_REGISTER_ALL sp_av_register_all; +static AV_FIND_INPUT_FORMAT sp_av_find_input_format; static AVFORMAT_OPEN_INPUT sp_avformat_open_input; static AV_DUMP_FORMAT sp_av_dump_format; static AV_READ_FRAME sp_av_read_frame; @@ -139,9 +146,9 @@ static AVFORMAT_NETWORK_INIT sp_avformat_network_init; // 53.13.0 static AVFORMAT_NETWORK_DEINIT sp_avformat_network_deinit; // 53.13.0 static AVFORMAT_FIND_STREAM_INFO sp_avformat_find_stream_info; // 53.3.0 static AV_FIND_STREAM_INFO sp_av_find_stream_info; -// count: 42 +// count: 43 -#define SYMBOL_COUNT 42 +#define SYMBOL_COUNT 43 JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryBundleInfo_initSymbols0 (JNIEnv *env, jclass clazz, jobject jSymbols, jint count) @@ -196,6 +203,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryB sp_avformat_close_input = (AVFORMAT_CLOSE_INPUT) (intptr_t) symbols[i++]; sp_av_close_input_file = (AV_CLOSE_INPUT_FILE) (intptr_t) symbols[i++]; sp_av_register_all = (AV_REGISTER_ALL) (intptr_t) symbols[i++]; + sp_av_find_input_format = (AV_FIND_INPUT_FORMAT) (intptr_t) symbols[i++]; sp_avformat_open_input = (AVFORMAT_OPEN_INPUT) (intptr_t) symbols[i++]; sp_av_dump_format = (AV_DUMP_FORMAT) (intptr_t) symbols[i++]; sp_av_read_frame = (AV_READ_FRAME) (intptr_t) symbols[i++]; @@ -359,16 +367,28 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_getAvUt (JNIEnv *env, jclass clazz) { return (jint) sp_avutil_version(); } +JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_getAvUtilMajorVersionCC0 + (JNIEnv *env, jclass clazz) { + return (jint) LIBAVUTIL_VERSION_MAJOR; +} JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_getAvFormatVersion0 (JNIEnv *env, jclass clazz) { return (jint) sp_avformat_version(); } +JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_getAvFormatMajorVersionCC0 + (JNIEnv *env, jclass clazz) { + return (jint) LIBAVFORMAT_VERSION_MAJOR; +} JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_getAvCodecVersion0 (JNIEnv *env, jclass clazz) { return (jint) sp_avcodec_version(); } +JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_getAvCodecMajorVersionCC0 + (JNIEnv *env, jclass clazz) { + return (jint) LIBAVCODEC_VERSION_MAJOR; +} JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_initIDs0 (JNIEnv *env, jclass clazz) @@ -468,7 +488,7 @@ static void initPTSStats(PTSStats *ptsStats); static int64_t evalPTS(PTSStats *ptsStats, int64_t inPTS, int64_t inDTS); JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStream0 - (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jint vid, jint aid, + (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jstring jInFmtStr, jint vid, jint aid, jint snoopVideoFrameCount, jint aChannelCount, jint aSampleRate) { int res, i; @@ -483,8 +503,17 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre pAV->pFormatCtx = sp_avformat_alloc_context(); // Open video file + AVInputFormat *inFmt = NULL; + const char *inFmtStr = NULL != jInFmtStr ? (*env)->GetStringUTFChars(env, jInFmtStr, &iscopy) : NULL; + if( NULL != inFmtStr ) { + inFmt = sp_av_find_input_format(inFmtStr); + if( NULL == inFmt ) { + fprintf(stderr, "Warning: Could not find input format '%s'\n", inFmtStr); + } + (*env)->ReleaseStringChars(env, jInFmtStr, (const jchar *)inFmtStr); + } const char *urlPath = (*env)->GetStringUTFChars(env, jURL, &iscopy); - res = sp_avformat_open_input(&pAV->pFormatCtx, urlPath, NULL, NULL); + res = sp_avformat_open_input(&pAV->pFormatCtx, urlPath, inFmt, NULL); if(res != 0) { JoglCommon_throwNewRuntimeException(env, "Couldn't open URI: %s", urlPath); (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); @@ -610,18 +639,25 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_setStre JoglCommon_throwNewRuntimeException(env, "Couldn't open audio codec %d, %s", pAV->pACodecCtx->codec_id, pAV->acodec); return; } - + if (!pAV->pACodecCtx->channel_layout) { + pAV->pACodecCtx->channel_layout = getDefaultAudioChannelLayout(pAV->pACodecCtx->channels); + } + if (!pAV->pACodecCtx->channel_layout) { + JoglCommon_throwNewRuntimeException(env, "Couldn't determine channel layout of %d channels\n", pAV->pACodecCtx->channels); + return; + } pAV->aSampleRate = pAV->pACodecCtx->sample_rate; pAV->aChannels = pAV->pACodecCtx->channels; pAV->aFrameSize = pAV->pACodecCtx->frame_size; // in samples per channel! pAV->aSampleFmt = pAV->pACodecCtx->sample_fmt; pAV->frames_audio = pAV->pAStream->nb_frames; if( pAV->verbose ) { - fprintf(stderr, "A channels %d, sample_rate %d, frame_size %d, frame_number %d, r_frame_rate %f, avg_frame_rate %f, nb_frames %d, \n", - pAV->aChannels, pAV->aSampleRate, pAV->aFrameSize, pAV->pACodecCtx->frame_number, + fprintf(stderr, "A channels %d [l %d], sample_rate %d, frame_size %d, frame_number %d, r_frame_rate %f, avg_frame_rate %f, nb_frames %d, [req_chan_layout %d, req_chan %d] \n", + pAV->aChannels, pAV->pACodecCtx->channel_layout, pAV->aSampleRate, pAV->aFrameSize, pAV->pACodecCtx->frame_number, my_av_q2f(pAV->pAStream->r_frame_rate), my_av_q2f(pAV->pAStream->avg_frame_rate), - pAV->pAStream->nb_frames); + pAV->pAStream->nb_frames, + pAV->pACodecCtx->request_channel_layout, pAV->pACodecCtx->request_channels); } if( 0 >= snoopVideoFrameCount ) { -- cgit v1.2.3 From 554ec0576432194f050191bdf248a1462d542a6d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 27 Aug 2013 19:21:17 +0200 Subject: GLMediaPlayer: Add camera input / FFMPEG: Fix 'av_packet' leak and add missing symbol 'av_realloc'. - Add camera input - Use URI w/ scheme 'camera' to determine camera input is desired, use URI host as camera id. E.g. 'camera://0' for 1st camera. - AndroidGLMediaPlayerAPI14: Via 'Camera' - FFMPEG*: Via libavdevice, device name and input format - TODO: Add controls to manipulate camera if available - FFMPEG* - Add symbols - avcodec_register_all - av_realloc (was missing) - avdevice_register_all - Load libavdevice (opt) - Camera: - Use (windows) and /dev/video other OS - simply find the input format in native code - Support YUYV422 (used in video4linux2, etc.) - Stuff 2x 16bpp (YUYV) into one RGBA pixel! - Add texture format for 16bpp - Add texture lookup shader - Fix av_packet leak in readNextImpl(..) - Restore orig pointer and size values, we may have moved along within packet. Then call av_free_packet(). - Use null AudioSink if audio-id is NONE --- make/build-jogl.xml | 1 + make/resources/android/AndroidManifest-jogl.xml | 3 +- make/resources/android/AndroidManifest-test.xml | 31 +++- make/resources/android/res-test/values/strings.xml | 4 +- make/scripts/tests.sh | 6 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 15 ++ .../android/av/AndroidGLMediaPlayerAPI14.java | 115 +++++++++++-- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 25 ++- .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 40 +++-- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 126 ++++++++++----- .../jogamp/opengl/util/av/impl/FFMPEGNatives.java | 2 +- .../opengl/util/av/impl/FFMPEGv08Natives.java | 2 +- .../opengl/util/av/impl/FFMPEGv09Natives.java | 2 +- src/jogl/native/libav/ffmpeg_tool.h | 3 +- .../jogamp_opengl_util_av_impl_FFMPEGvXXNatives.c | 180 ++++++++++++++------- .../test/android/MovieCubeActivityLauncher1a.java | 87 ++++++++++ .../test/android/MovieCubeActivityLauncher1b.java | 87 ++++++++++ .../android/MovieSimpleActivityLauncher00a.java | 87 ---------- .../android/MovieSimpleActivityLauncher00c.java | 86 ++++++++++ 19 files changed, 677 insertions(+), 225 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1a.java create mode 100644 src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java delete mode 100644 src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java create mode 100644 src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00c.java (limited to 'make/scripts') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index b384aebc2..ee40c7e10 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1479,6 +1479,7 @@ + diff --git a/make/resources/android/AndroidManifest-jogl.xml b/make/resources/android/AndroidManifest-jogl.xml index 1c08cc484..c07ee041b 100644 --- a/make/resources/android/AndroidManifest-jogl.xml +++ b/make/resources/android/AndroidManifest-jogl.xml @@ -4,7 +4,8 @@ package="javax.media.opengl"> - + + diff --git a/make/resources/android/AndroidManifest-test.xml b/make/resources/android/AndroidManifest-test.xml index 5357d0a18..d57913638 100644 --- a/make/resources/android/AndroidManifest-test.xml +++ b/make/resources/android/AndroidManifest-test.xml @@ -4,7 +4,8 @@ package="com.jogamp.opengl.test"> - + + @@ -120,8 +121,8 @@ - @@ -130,8 +131,8 @@ - @@ -180,6 +181,26 @@ + + + + + + + + + + + + diff --git a/make/resources/android/res-test/values/strings.xml b/make/resources/android/res-test/values/strings.xml index 0b7bd2d51..072cf47e6 100644 --- a/make/resources/android/res-test/values/strings.xml +++ b/make/resources/android/res-test/values/strings.xml @@ -23,12 +23,14 @@ GraphUI 2-pass Elektro Elektro - MovieSimple0a MovieSimple0b + CamSimple0 MovieSimple1a MovieSimple1b MovieSimple2 MovieSimple MovieCube0 + CamCube0 + CamCube1 MovieCube diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c7207bbcf..2be4d76b2 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -133,7 +133,7 @@ function jrun() { #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" - #D_ARGS="-Djogl.debug.GLMediaPlayer" + D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.AudioSink" @@ -319,8 +319,8 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 6235bdeb0..0feca9f45 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -47,6 +47,9 @@ import com.jogamp.opengl.util.TimeFrameI; * Audio and video streams can be selected or muted via {@link #initStream(URI, int, int, int)} * using the appropriate stream id's. *

      + *

      + * Camera input can be selected using the {@link #CameraInputScheme} URI. + *

      * *
      StreamWorker Decoding Thread
      *

      @@ -190,6 +193,18 @@ public interface GLMediaPlayer extends TextureSequence { /** Constant {@value} for auto or unspecified. See Audio and video Stream IDs. */ public static final int STREAM_ID_AUTO = -1; + /** + * {@link URI#getScheme() URI scheme} name {@value} for camera input. E.g. camera://0 + * for the 1st camera device. + *

      + * Note: the {@link URI#getHost() URI host} is being used to identify the camera: + *

      +     *    camera://
      +     * 
      + *

      + */ + public static final String CameraInputScheme = "camera"; + /** Maximum video frame async of {@value} milliseconds. */ public static final int MAXIMUM_VIDEO_ASYNC = 22; diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 39489cff4..056998c0c 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -28,6 +28,7 @@ package jogamp.opengl.android.av; import java.io.IOException; +import java.util.List; import javax.media.opengl.GL; import javax.media.opengl.GLES2; @@ -45,6 +46,7 @@ import jogamp.opengl.util.av.GLMediaPlayerImpl; import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture.OnFrameAvailableListener; +import android.hardware.Camera; import android.media.MediaPlayer; import android.media.MediaPlayer.OnCompletionListener; import android.net.Uri; @@ -85,6 +87,8 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { public static final boolean isAvailable() { return available; } private MediaPlayer mp; + private Camera cam; + private long playStart = 0; private volatile boolean updateSurface = false; private Object updateSurfaceLock = new Object(); private SurfaceTextureFrame singleSTexFrame = null; @@ -104,7 +108,6 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { throw new RuntimeException("AndroidGLMediaPlayerAPI14 not available"); } this.setTextureTarget(GLES2.GL_TEXTURE_EXTERNAL_OES); - mp = new MediaPlayer(); } @Override @@ -130,10 +133,11 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { @Override protected final boolean playImpl() { + playStart = Platform.currentTimeMillis(); if(null != mp) { try { mp.start(); - eos = false; + eos = false; mp.setOnCompletionListener(onCompletionListener); return true; } catch (IllegalStateException ise) { @@ -141,6 +145,17 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { ise.printStackTrace(); } } + } else if( null != cam ) { + try { + if( sTexFrameAttached ) { + cam.startPreview(); + } + return true; + } catch (IllegalStateException ise) { + if(DEBUG) { + ise.printStackTrace(); + } + } } return false; } @@ -157,6 +172,16 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { ise.printStackTrace(); } } + } else if( null != cam ) { + wakeUp(false); + try { + cam.stopPreview(); + return true; + } catch (IllegalStateException ise) { + if(DEBUG) { + ise.printStackTrace(); + } + } } return false; } @@ -196,6 +221,18 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { mp.release(); mp = null; } + if( null != cam ) { + wakeUp(false); + try { + cam.stopPreview(); + } catch (IllegalStateException ise) { + if(DEBUG) { + ise.printStackTrace(); + } + } + cam.release(); + cam = null; + } } public static class SurfaceTextureFrame extends TextureSequence.TextureFrame { @@ -212,7 +249,27 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { @Override protected final void initStreamImpl(int vid, int aid) throws IOException { - if(null!=mp && null!=streamLoc) { + + if( null == streamLoc ) { + return; + } + if( null == mp && null == cam ) { + if( null == cameraHostPart ) { + mp = new MediaPlayer(); + } else { + int cameraId = 0; + try { + cameraId = Integer.valueOf(cameraHostPart); + } catch (NumberFormatException nfe) {} + if( 0 <= cameraId && cameraId < Camera.getNumberOfCameras() ) { + cam = Camera.open(cameraId); + } else { + cam = Camera.open(); + } + } + } + + if(null!=mp) { if( GLMediaPlayer.STREAM_ID_NONE == aid ) { mp.setVolume(0f, 0f); // FIXME: Disable audio handling @@ -240,8 +297,31 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { mp.getVideoWidth(), mp.getVideoHeight(), 0, 0, 0, 0f, 0, 0, mp.getDuration(), icodec, icodec); + } else if( null != cam ) { + final String icodec = "android"; + final int[] fpsRange = { 0, 0 }; + final Camera.Parameters p = cam.getParameters(); + p.getPreviewFpsRange(fpsRange); + final Camera.Size size = p.getPreviewSize(); + if( DEBUG ) { + final int picFmt = p.getPictureFormat(); + final Camera.Size prefSize = p.getPreferredPreviewSizeForVideo(); + System.err.println("MediaPlayer.Camera: fps "+fpsRange[0]+".."+fpsRange[1]+", size[pref "+camSz2Str(prefSize)+", cur "+camSz2Str(size)+"], fmt "+picFmt); + List supSizes = p.getSupportedVideoSizes(); + for(int i=0; i: "+ioe.getMessage(), ioe); + } + } + if( null != surface ) { + surface.release(); + } surfTex.setOnFrameAvailableListener(onFrameAvailableListener); } - if( eos || !mp.isPlaying() ) { + if( eos || (null != mp && !mp.isPlaying() ) ) { eos = true; pts = TimeFrameI.END_OF_STREAM_PTS; } else { @@ -297,7 +390,11 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { if(update) { surfTex.updateTexImage(); // nextFrame.setPTS( (int) ( nextSTex.getTimestamp() / 1000000L ) ); // nano -9 -> milli -3 - pts = mp.getCurrentPosition(); + if( null != mp ) { + pts = mp.getCurrentPosition(); + } else { + pts = (int) ( Platform.currentTimeMillis() - playStart ); + } // stex.getTransformMatrix(atex.getSTMatrix()); } } diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 73d5e7748..5286c86b8 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -85,7 +85,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected int[] texMinMagFilter = { GL.GL_NEAREST, GL.GL_NEAREST }; protected int[] texWrapST = { GL.GL_CLAMP_TO_EDGE, GL.GL_CLAMP_TO_EDGE }; + /** User requested URI stream location. */ protected URI streamLoc = null; + /** + * In case {@link #streamLoc} is a {@link GLMediaPlayer#CameraInputScheme}, + * {@link #cameraHostPart} holds the URI's path portion + * as parsed in {@link #initStream(URI, int, int, int)}. + */ + protected String cameraHostPart = null; protected volatile float playSpeed = 1.0f; protected float audioVolume = 1.0f; @@ -463,6 +470,15 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { presentedFrameCount = 0; displayedFrameCount = 0; this.streamLoc = streamLoc; + + // Pre-parse for camera-input scheme + final String streamLocScheme = streamLoc.getScheme(); + if( null != streamLocScheme && streamLocScheme.equals(CameraInputScheme) ) { + cameraHostPart = streamLoc.getHost(); + } else { + cameraHostPart = null; + } + this.vid = vid; this.aid = aid; if (this.streamLoc != null) { @@ -598,7 +614,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { { final int err = gl.glGetError(); if( GL.GL_NO_ERROR != err ) { - throw new RuntimeException("Couldn't create TexImage2D RGBA "+tWidth+"x"+tHeight+", err "+toHexString(err)); + throw new RuntimeException("Couldn't create TexImage2D RGBA "+tWidth+"x"+tHeight+", target "+toHexString(textureTarget)+ + ", ifmt "+toHexString(GL.GL_RGBA)+", fmt "+toHexString(textureFormat)+", type "+toHexString(textureType)+ + ", err "+toHexString(err)); } } if(DEBUG) { @@ -1303,12 +1321,13 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final String loc = ( null != streamLoc ) ? streamLoc.toString() : "" ; final int freeVideoFrames = null != videoFramesFree ? videoFramesFree.size() : 0; final int decVideoFrames = null != videoFramesDecoded ? videoFramesDecoded.size() : 0; - final int video_scr = video_scr_pts + (int) ( ( Platform.currentTimeMillis() - video_scr_t0 ) * playSpeed ); + final int video_scr = video_scr_pts + (int) ( ( Platform.currentTimeMillis() - video_scr_t0 ) * playSpeed ); + final String camPath = null != cameraHostPart ? ", camera: "+cameraHostPart : ""; return "GLMediaPlayer["+state+", vSCR "+video_scr+", frames[p "+presentedFrameCount+", d "+decodedFrameCount+", t "+videoFrames+" ("+tt+" s)], "+ "speed "+playSpeed+", "+bps_stream+" bps, "+ "Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+", target "+toHexString(textureTarget)+", format "+toHexString(textureFormat)+", type "+toHexString(textureType)+"], "+ "Video[id "+vid+", <"+vcodec+">, "+width+"x"+height+", "+fps+" fps, "+frame_duration+" fdur, "+bps_video+" bps], "+ - "Audio[id "+aid+", <"+acodec+">, "+bps_audio+" bps, "+audioFrames+" frames], uri "+loc+"]"; + "Audio[id "+aid+", <"+acodec+">, "+bps_audio+" bps, "+audioFrames+" frames], uri "+loc+camPath+"]"; } @Override diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index ab16c5e5e..040d152f5 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -60,7 +60,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { private static final List glueLibNames = new ArrayList(); // none - private static final int symbolCount = 51; + private static final int symbolCount = 54; private static final String[] symbolNames = { "avcodec_version", "avformat_version", @@ -68,6 +68,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { /* 4 */ "avresample_version", // libavcodec + "avcodec_register_all", "avcodec_close", "avcodec_string", "avcodec_find_decoder", @@ -85,16 +86,17 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "av_free_packet", "avcodec_decode_audio4", // 53.25.0 (opt) "avcodec_decode_audio3", // 52.23.0 -/* 22 */ "avcodec_decode_video2", // 52.23.0 +/* 23 */ "avcodec_decode_video2", // 52.23.0 // libavutil "av_pix_fmt_descriptors", "av_frame_unref", // 55.0.0 (opt) + "av_realloc", "av_free", "av_get_bits_per_pixel", "av_samples_get_buffer_size", "av_get_bytes_per_sample", // 51.4.0 -/* 29 */ "av_opt_set_int", // 51.12.0 +/* 31 */ "av_opt_set_int", // 51.12.0 // libavformat "avformat_alloc_context", @@ -113,14 +115,17 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avformat_network_init", // 53.13.0 (opt) "avformat_network_deinit", // 53.13.0 (opt) "avformat_find_stream_info", // 53.3.0 (opt) -/* 46 */ "av_find_stream_info", +/* 48 */ "av_find_stream_info", + // libavdevice +/* 49 */ "avdevice_register_all", // ??? + // libavresample "avresample_alloc_context", // 1.0.1 "avresample_open", "avresample_close", "avresample_free", -/* 51 */ "avresample_convert" +/* 54 */ "avresample_convert" }; // alternate symbol names @@ -139,7 +144,8 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avformat_seek_file", // ??? (opt) "avcodec_free_frame", // 54.28.0 (opt) "av_frame_unref", // 55.0.0 (opt) - + // libavdevice + "avdevice_register_all", // 53.0.0 (opt) // libavresample "avresample_version", // 1.0.1 "avresample_alloc_context", // 1.0.1 @@ -153,6 +159,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { private static final boolean ready; private static final boolean libsLoaded; private static final boolean avresampleLoaded; // optional + private static final boolean avdeviceLoaded; // optional static final VersionNumber avCodecVersion; static final VersionNumber avFormatVersion; static final VersionNumber avUtilVersion; @@ -164,14 +171,16 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { GLProfile.initSingleton(); boolean _ready = false; boolean[] _libsLoaded= { false }; + boolean[] _avdeviceLoaded= { false }; boolean[] _avresampleLoaded= { false }; VersionNumber[] _versions = new VersionNumber[4]; try { - _ready = initSymbols(_libsLoaded, _avresampleLoaded, _versions); + _ready = initSymbols(_libsLoaded, _avdeviceLoaded, _avresampleLoaded, _versions); } catch (Throwable t) { t.printStackTrace(); } libsLoaded = _libsLoaded[0]; + avdeviceLoaded = _avdeviceLoaded[0]; avresampleLoaded = _avresampleLoaded[0]; avCodecVersion = _versions[0]; avFormatVersion = _versions[1]; @@ -205,11 +214,13 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { } static boolean libsLoaded() { return libsLoaded; } + static boolean avDeviceLoaded() { return avdeviceLoaded; } static boolean avResampleLoaded() { return avresampleLoaded; } static FFMPEGNatives getNatives() { return natives; } static boolean initSingleton() { return ready; } - private static final boolean initSymbols(boolean[] libsLoaded, boolean[] avresampleLoaded, VersionNumber[] versions) { + private static final boolean initSymbols(boolean[] libsLoaded, boolean[] avdeviceLoaded, boolean[] avresampleLoaded, + VersionNumber[] versions) { libsLoaded[0] = false; final DynamicLibraryBundle dl = AccessController.doPrivileged(new PrivilegedAction() { public DynamicLibraryBundle run() { @@ -221,7 +232,8 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { if(!avutilLoaded || !avformatLoaded || !avcodecLoaded) { throw new RuntimeException("FFMPEG Tool library incomplete: [ avutil "+avutilLoaded+", avformat "+avformatLoaded+", avcodec "+avcodecLoaded+"]"); } - avresampleLoaded[0] = dl.isToolLibLoaded(3); + avdeviceLoaded[0] = dl.isToolLibLoaded(3); + avresampleLoaded[0] = dl.isToolLibLoaded(4); libsLoaded[0] = true; if(symbolNames.length != symbolCount) { @@ -361,6 +373,16 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { avcodec.add("avcodec-52"); // 0.7 libsList.add(avcodec); + final List avdevice = new ArrayList(); + avdevice.add("avdevice"); // default + + avdevice.add("libavdevice.so.54"); // dummy future proof + avdevice.add("libavdevice.so.53"); // 8 && 9 + + avdevice.add("avdevice-54"); // dummy future proof + avdevice.add("avdevice-53"); // 8 && 9 + libsList.add(avdevice); + final List avresample = new ArrayList(); avresample.add("avresample"); // default diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index bcf4994b5..f46c5900c 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -129,7 +129,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println("LIB_AV Util : "+FFMPEGDynamicLibraryBundleInfo.avUtilVersion+" [cc "+avUtilMajorVersionCC+"]"); System.err.println("LIB_AV Format : "+FFMPEGDynamicLibraryBundleInfo.avFormatVersion+" [cc "+avFormatMajorVersionCC+"]"); System.err.println("LIB_AV Codec : "+FFMPEGDynamicLibraryBundleInfo.avCodecVersion+" [cc "+avCodecMajorVersionCC+"]"); - System.err.println("LIB_AV Resample: "+FFMPEGDynamicLibraryBundleInfo.avResampleVersion+" [cc "+avResampleMajorVersionCC+"]"); + System.err.println("LIB_AV Device : [loaded "+FFMPEGDynamicLibraryBundleInfo.avDeviceLoaded()+"]"); + System.err.println("LIB_AV Resample: "+FFMPEGDynamicLibraryBundleInfo.avResampleVersion+" [cc "+avResampleMajorVersionCC+", loaded "+FFMPEGDynamicLibraryBundleInfo.avResampleLoaded()+"]"); libAVVersionGood = avUtilMajorVersionCC == FFMPEGDynamicLibraryBundleInfo.avUtilVersion.getMajor() && avFormatMajorVersionCC == FFMPEGDynamicLibraryBundleInfo.avFormatVersion.getMajor() && avCodecMajorVersionCC == FFMPEGDynamicLibraryBundleInfo.avCodecVersion.getMajor() && @@ -160,6 +161,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { // Video // + private String texLookupFuncName = "ffmpegTexture2D"; + private boolean usesTexLookupShader = false; private PixelFormat vPixelFmt = null; private int vPlanes = 0; private int vBitsPerPixel = 0; @@ -205,8 +208,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } } - public static final String dev_video = "/dev/video"; - private static final int dev_video_len = dev_video.length(); + public static final String dev_video_linux = "/dev/video"; @Override protected final void initStreamImpl(int vid, int aid) throws IOException { @@ -229,40 +231,34 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println("initStream: p2 preferred "+preferredAudioFormat+", "+this); } - final int streamLocSLen = streamLocS.length(); - final String inFormat; + final boolean isCameraInput = null != cameraHostPart; final String resStreamLocS; - if( streamLocSLen == dev_video_len + 1 && streamLocS.startsWith(dev_video) ) { - final int index = Integer.valueOf( streamLocS.substring(streamLocSLen-1) ).intValue(); + if( isCameraInput ) { switch(Platform.OS_TYPE) { - case ANDROID: - // ?? - case FREEBSD: - case HPUX: - case LINUX: - case SUNOS: - resStreamLocS = streamLocS; - inFormat = "video4linux2"; - break; - case WINDOWS: - resStreamLocS = String.valueOf(index); - inFormat = "vfwcap"; - break; - case MACOS: - case OPENKODE: - default: - resStreamLocS = streamLocS; - inFormat = null; - break; + case ANDROID: + // ?? + case FREEBSD: + case HPUX: + case LINUX: + case SUNOS: + resStreamLocS = dev_video_linux + cameraHostPart; + break; + case WINDOWS: + resStreamLocS = cameraHostPart; + break; + case MACOS: + case OPENKODE: + default: + resStreamLocS = streamLocS; // FIXME: ?? + break; } } else { resStreamLocS = streamLocS; - inFormat = null; } final int aMaxChannelCount = audioSink.getMaxSupportedChannels(); final int aPrefSampleRate = preferredAudioFormat.sampleRate; // setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc - natives.setStream0(moviePtr, resStreamLocS, inFormat, vid, aid, aMaxChannelCount, aPrefSampleRate); + natives.setStream0(moviePtr, resStreamLocS, isCameraInput, vid, aid, aMaxChannelCount, aPrefSampleRate); } @Override @@ -300,6 +296,10 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println("initGL: p3 avChosen "+avChosenAudioFormat); } + if( STREAM_ID_NONE == aid ) { + audioSink.destroy(); + audioSink = AudioSinkFactory.createNull(); + } final boolean audioSinkOK = audioSink.init(avChosenAudioFormat, frameDuration, AudioSink.DefaultInitialQueueSize, AudioSink.DefaultQueueGrowAmount, audioQueueLimit); if( !audioSinkOK ) { System.err.println("AudioSink "+audioSink.getClass().getName()+" does not support "+avChosenAudioFormat+", using Null"); @@ -314,6 +314,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if( null != gl ) { int tf, tif=GL.GL_RGBA; // texture format and internal format + int tt = GL.GL_UNSIGNED_BYTE; switch(vBytesPerPixelPerPlane) { case 1: if( gl.isGL3ES3() ) { @@ -324,12 +325,20 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { tf = GL2ES2.GL_ALPHA; tif=GL2ES2.GL_ALPHA; singleTexComp = "a"; } break; - case 3: tf = GL2ES2.GL_RGB; tif=GL.GL_RGB; break; - case 4: tf = GL2ES2.GL_RGBA; tif=GL.GL_RGBA; break; + + case 2: if( vPixelFmt == PixelFormat.YUYV422 ) { + // YUYV422: // < packed YUV 4:2:2, 2x 16bpp, Y0 Cb Y1 Cr + // Stuffed into RGBA half width texture + tf = GL2ES2.GL_RGBA; tif=GL2ES2.GL_RGBA; break; + } else { + tf = GL2ES2.GL_RG; tif=GL2ES2.GL_RG; break; + } + case 3: tf = GL2ES2.GL_RGB; tif=GL.GL_RGB; break; + case 4: tf = GL2ES2.GL_RGBA; tif=GL.GL_RGBA; break; default: throw new RuntimeException("Unsupported bytes-per-pixel / plane "+vBytesPerPixelPerPlane); } setTextureFormat(tif, tf); - setTextureType(GL.GL_UNSIGNED_BYTE); + setTextureType(tt); } } @Override @@ -435,7 +444,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { */ void updateAttributes2(int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, int lSz0, int lSz1, int lSz2, - int tWd0, int tWd1, int tWd2, int tH, + int tWd0, int tWd1, int tWd2, int vW, int vH, int audioSampleFmt, int audioSampleRate, int audioChannels, int audioSamplesPerFrameAndChannel) { vPixelFmt = PixelFormat.valueOf(pixFmt); @@ -446,23 +455,28 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { vTexWidth[0] = tWd0; vTexWidth[1] = tWd1; vTexWidth[2] = tWd2; switch(vPixelFmt) { - case YUV420P: + case YUV420P: // < planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) + usesTexLookupShader = true; // YUV420P: Adding U+V on right side of fixed height texture, // since width is already aligned by decoder. // Y=w*h, Y=w/2*h/2, U=w/2*h/2 // w*h + 2 ( w/2 * h/2 ) // w*h + w*h/2 // 2*w/2 * h - texWidth = vTexWidth[0] + vTexWidth[1]; texHeight = tH; + texWidth = vTexWidth[0] + vTexWidth[1]; texHeight = vH; + break; + case YUYV422: // < packed YUV 4:2:2, 2x 16bpp, Y0 Cb Y1 Cr - stuffed into RGBA half width texture + usesTexLookupShader = true; + texWidth = vTexWidth[0]; texHeight = vH; break; - // case PIX_FMT_YUYV422: case RGB24: case BGR24: case ARGB: case RGBA: case ABGR: case BGRA: - texWidth = vTexWidth[0]; texHeight = tH; + usesTexLookupShader = false; + texWidth = vTexWidth[0]; texHeight = vH; break; default: // FIXME: Add more formats ! throw new RuntimeException("Unsupported pixelformat: "+vPixelFmt); @@ -474,7 +488,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(DEBUG) { System.err.println("audio: fmt "+aSampleFmt+", "+avChosenAudioFormat+", aFrameSize/fc "+audioSamplesPerFrameAndChannel); - System.err.println("video: fmt "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane); + System.err.println("video: fmt "+vW+"x"+vH+", "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane+", usesTexLookupShader "+usesTexLookupShader); for(int i=0; i<3; i++) { System.err.println("video: "+i+": "+vTexWidth[i]+"/"+vLinesize[i]); } @@ -494,15 +508,14 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(State.Uninitialized == state) { throw new IllegalStateException("Instance not initialized: "+this); } - if(PixelFormat.YUV420P == vPixelFmt) { + if( usesTexLookupShader ) { if(null != desiredFuncName && desiredFuncName.length()>0) { - textureLookupFunctionName = desiredFuncName; + texLookupFuncName = desiredFuncName; } - return textureLookupFunctionName; + return texLookupFuncName; } return super.getTextureLookupFunctionName(desiredFuncName); } - private String textureLookupFunctionName = "ffmpegTexture2D"; /** * {@inheritDoc} @@ -515,11 +528,14 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if(State.Uninitialized == state) { throw new IllegalStateException("Instance not initialized: "+this); } + if( !usesTexLookupShader ) { + return super.getTextureLookupFragmentShaderImpl(); + } final float tc_w_1 = (float)getWidth() / (float)texWidth; switch(vPixelFmt) { - case YUV420P: + case YUV420P: // < planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) return - "vec4 "+textureLookupFunctionName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " vec2 u_off = vec2("+tc_w_1+", 0.0);\n"+ " vec2 v_off = vec2("+tc_w_1+", 0.5);\n"+ " vec2 tc_half = texCoord*0.5;\n"+ @@ -536,8 +552,30 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { " return vec4(r, g, b, 1);\n"+ "}\n" ; + case YUYV422: // < packed YUV 4:2:2, 2 x 16bpp, [Y0 Cb] [Y1 Cr] + // Stuffed into RGBA half width texture + return + "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + " "+ + " float y1,u,y2,v,y,r,g,b;\n"+ + " vec2 tc_halfw = vec2(texCoord.x*0.5, texCoord.y);\n"+ + " vec4 yuyv = texture2D(image, tc_halfw).rgba;\n"+ + " y1 = yuyv.r;\n"+ + " u = yuyv.g;\n"+ + " y2 = yuyv.b;\n"+ + " v = yuyv.a;\n"+ + " y = mix( y1, y2, mod(gl_FragCoord.x, 2) ); /* avoid branching! */\n"+ + " y = 1.1643*(y-0.0625);\n"+ + " u = u-0.5;\n"+ + " v = v-0.5;\n"+ + " r = y+1.5958*v;\n"+ + " g = y-0.39173*u-0.81290*v;\n"+ + " b = y+2.017*u;\n"+ + " return vec4(r, g, b, 1);\n"+ + "}\n" + ; default: // FIXME: Add more formats ! - return super.getTextureLookupFragmentShaderImpl(); + throw new InternalError("Add proper mapping of: vPixelFmt "+vPixelFmt+", usesTexLookupShader "+usesTexLookupShader); } } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java index 89cefbf17..9dd1ac74a 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java @@ -59,7 +59,7 @@ interface FFMPEGNatives { * @param aPrefChannelCount * @param aPrefSampleRate */ - void setStream0(long moviePtr, String url, String inFormat, int vid, int aid, int aMaxChannelCount, int aPrefSampleRate); + void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, int aid, int aMaxChannelCount, int aPrefSampleRate); void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); int getVideoPTS0(long moviePtr); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java index 1c0f66e0c..3b2567655 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java @@ -53,7 +53,7 @@ class FFMPEGv08Natives implements FFMPEGNatives { public native void destroyInstance0(long moviePtr); @Override - public native void setStream0(long moviePtr, String url, String inFormat, int vid, int aid, int aMaxChannelCount, int aPrefSampleRate); + public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, int aid, int aMaxChannelCount, int aPrefSampleRate); @Override public native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java index 0bc26923c..6c56d3ccb 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java @@ -53,7 +53,7 @@ class FFMPEGv09Natives implements FFMPEGNatives { public native void destroyInstance0(long moviePtr); @Override - public native void setStream0(long moviePtr, String url, String inFormat, int vid, int aid, int aMaxChannelCount, int aPrefSampleRate); + public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, int aid, int aMaxChannelCount, int aPrefSampleRate); @Override public native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index d62cff60f..90d795b91 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -154,7 +154,8 @@ typedef struct { PTSStats vPTSStats; int32_t vLinesize[3]; // decoded video linesize in bytes for each plane int32_t vTexWidth[3]; // decoded video tex width in bytes for each plane - + int32_t vWidth; + int32_t vHeight; int32_t aid; AVStream* pAStream; diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGvXXNatives.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGvXXNatives.c index 54615c4b9..aaa26cfb1 100644 --- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGvXXNatives.c +++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGvXXNatives.c @@ -62,6 +62,7 @@ static AVRESAMPLE_VERSION sp_avresample_version; // count: 4 // libavcodec +typedef int (APIENTRYP AVCODEC_REGISTER_ALL)(void); typedef int (APIENTRYP AVCODEC_CLOSE)(AVCodecContext *avctx); typedef void (APIENTRYP AVCODEC_STRING)(char *buf, int buf_size, AVCodecContext *enc, int encode); typedef AVCodec *(APIENTRYP AVCODEC_FIND_DECODER)(enum CodecID id); @@ -81,6 +82,7 @@ typedef int (APIENTRYP AVCODEC_DECODE_AUDIO4)(AVCodecContext *avctx, AVFrame *fr typedef int (APIENTRYP AVCODEC_DECODE_AUDIO3)(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt); // 52.23.0 typedef int (APIENTRYP AVCODEC_DECODE_VIDEO2)(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt); // 52.23.0 +static AVCODEC_REGISTER_ALL sp_avcodec_register_all; static AVCODEC_CLOSE sp_avcodec_close; static AVCODEC_STRING sp_avcodec_string; static AVCODEC_FIND_DECODER sp_avcodec_find_decoder; @@ -99,10 +101,11 @@ static AV_FREE_PACKET sp_av_free_packet; static AVCODEC_DECODE_AUDIO4 sp_avcodec_decode_audio4; // 53.25.0 static AVCODEC_DECODE_AUDIO3 sp_avcodec_decode_audio3; // 52.23.0 static AVCODEC_DECODE_VIDEO2 sp_avcodec_decode_video2; // 52.23.0 -// count: 22 +// count: 23 // libavutil typedef void (APIENTRYP AV_FRAME_UNREF)(AVFrame *frame); +typedef void* (APIENTRYP AV_REALLOC)(void *ptr, size_t size); typedef void (APIENTRYP AV_FREE)(void *ptr); typedef int (APIENTRYP AV_GET_BITS_PER_PIXEL)(const AVPixFmtDescriptor *pixdesc); typedef int (APIENTRYP AV_SAMPLES_GET_BUFFER_SIZE)(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align); @@ -110,12 +113,13 @@ typedef int (APIENTRYP AV_GET_BYTES_PER_SAMPLE)(enum AVSampleFormat sample_fmt); typedef int (APIENTRYP AV_OPT_SET_INT)(void *obj, const char *name, int64_t val, int search_flags); static const AVPixFmtDescriptor* sp_av_pix_fmt_descriptors; static AV_FRAME_UNREF sp_av_frame_unref; +static AV_REALLOC sp_av_realloc; static AV_FREE sp_av_free; static AV_GET_BITS_PER_PIXEL sp_av_get_bits_per_pixel; static AV_SAMPLES_GET_BUFFER_SIZE sp_av_samples_get_buffer_size; static AV_GET_BYTES_PER_SAMPLE sp_av_get_bytes_per_sample; static AV_OPT_SET_INT sp_av_opt_set_int; -// count: 28 +// count: 30 // libavformat typedef AVFormatContext *(APIENTRYP AVFORMAT_ALLOC_CONTEXT)(void); @@ -153,7 +157,12 @@ static AVFORMAT_NETWORK_INIT sp_avformat_network_init; // 53.13.0 static AVFORMAT_NETWORK_DEINIT sp_avformat_network_deinit; // 53.13.0 static AVFORMAT_FIND_STREAM_INFO sp_avformat_find_stream_info; // 53.3.0 static AV_FIND_STREAM_INFO sp_av_find_stream_info; -// count: 46 +// count: 47 + +// libavdevice [53.0.0] +typedef int (APIENTRYP AVDEVICE_REGISTER_ALL)(void); +static AVDEVICE_REGISTER_ALL sp_avdevice_register_all; +// count: 49 // libavresample [1.0.1] typedef AVAudioResampleContext* (APIENTRYP AVRESAMPLE_ALLOC_CONTEXT)(void); // 1.0.1 @@ -168,9 +177,9 @@ static AVRESAMPLE_OPEN sp_avresample_open; static AVRESAMPLE_CLOSE sp_avresample_close; static AVRESAMPLE_FREE sp_avresample_free; static AVRESAMPLE_CONVERT sp_avresample_convert; -// count: 51 +// count: 54 -#define SYMBOL_COUNT 51 +#define SYMBOL_COUNT 54 JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) (JNIEnv *env, jobject instance, jobject jSymbols, jint count) @@ -194,6 +203,7 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) sp_avresample_version = (AVRESAMPLE_VERSION) (intptr_t) symbols[i++]; // count: 4 + sp_avcodec_register_all = (AVCODEC_REGISTER_ALL) (intptr_t) symbols[i++]; sp_avcodec_close = (AVCODEC_CLOSE) (intptr_t) symbols[i++]; sp_avcodec_string = (AVCODEC_STRING) (intptr_t) symbols[i++]; sp_avcodec_find_decoder = (AVCODEC_FIND_DECODER) (intptr_t) symbols[i++]; @@ -212,16 +222,17 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) sp_avcodec_decode_audio4 = (AVCODEC_DECODE_AUDIO4) (intptr_t) symbols[i++]; sp_avcodec_decode_audio3 = (AVCODEC_DECODE_AUDIO3) (intptr_t) symbols[i++]; sp_avcodec_decode_video2 = (AVCODEC_DECODE_VIDEO2) (intptr_t) symbols[i++]; - // count: 22 + // count: 23 sp_av_pix_fmt_descriptors = (const AVPixFmtDescriptor*) (intptr_t) symbols[i++]; sp_av_frame_unref = (AV_FRAME_UNREF) (intptr_t) symbols[i++]; + sp_av_realloc = (AV_REALLOC) (intptr_t) symbols[i++]; sp_av_free = (AV_FREE) (intptr_t) symbols[i++]; sp_av_get_bits_per_pixel = (AV_GET_BITS_PER_PIXEL) (intptr_t) symbols[i++]; sp_av_samples_get_buffer_size = (AV_SAMPLES_GET_BUFFER_SIZE) (intptr_t) symbols[i++]; sp_av_get_bytes_per_sample = (AV_GET_BYTES_PER_SAMPLE) (intptr_t) symbols[i++]; sp_av_opt_set_int = (AV_OPT_SET_INT) (intptr_t) symbols[i++]; - // count: 29 + // count: 31 sp_avformat_alloc_context = (AVFORMAT_ALLOC_CONTEXT) (intptr_t) symbols[i++];; sp_avformat_free_context = (AVFORMAT_FREE_CONTEXT) (intptr_t) symbols[i++]; @@ -240,14 +251,17 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) sp_avformat_network_deinit = (AVFORMAT_NETWORK_DEINIT) (intptr_t) symbols[i++]; sp_avformat_find_stream_info = (AVFORMAT_FIND_STREAM_INFO) (intptr_t) symbols[i++]; sp_av_find_stream_info = (AV_FIND_STREAM_INFO) (intptr_t) symbols[i++]; - // count: 46 + // count: 48 + + sp_avdevice_register_all = (AVDEVICE_REGISTER_ALL) (intptr_t) symbols[i++]; + // count: 49 sp_avresample_alloc_context = (AVRESAMPLE_ALLOC_CONTEXT) (intptr_t) symbols[i++]; sp_avresample_open = (AVRESAMPLE_OPEN) (intptr_t) symbols[i++]; sp_avresample_close = (AVRESAMPLE_CLOSE) (intptr_t) symbols[i++]; sp_avresample_free = (AVRESAMPLE_FREE) (intptr_t) symbols[i++]; sp_avresample_convert = (AVRESAMPLE_CONVERT) (intptr_t) symbols[i++]; - // count: 51 + // count: 54 (*env)->ReleasePrimitiveArrayCritical(env, jSymbols, symbols, 0); @@ -270,23 +284,16 @@ static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasic // int shallBeDetached = 0; // JNIEnv * env = JoglCommon_GetJNIEnv (&shallBeDetached); if(NULL!=env) { - int32_t w, h; - if( NULL != pAV->pVCodecCtx ) { - // FIXME: Libav Binary compatibility! JAU01 - w = pAV->pVCodecCtx->width; h = pAV->pVCodecCtx->height; - } else { - w = 0; h = 0; - } - (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_updateAttributes2, pAV->vPixFmt, pAV->vBufferPlanes, pAV->vBitsPerPixel, pAV->vBytesPerPixelPerPlane, pAV->vLinesize[0], pAV->vLinesize[1], pAV->vLinesize[2], - pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2], h, + pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2], + pAV->vWidth, pAV->vHeight, pAV->aSampleFmtOut, pAV->aSampleRateOut, pAV->aChannelsOut, pAV->aFrameSize); (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_updateAttributes1, pAV->vid, pAV->aid, - w, h, + pAV->vWidth, pAV->vHeight, pAV->bps_stream, pAV->bps_video, pAV->bps_audio, pAV->fps, pAV->frames_video, pAV->frames_audio, pAV->duration, (*env)->NewStringUTF(env, pAV->vcodec), @@ -455,7 +462,7 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initIDs0) jni_mid_pushSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "pushSound", "(Ljava/nio/ByteBuffer;II)V"); jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIIIFIIILjava/lang/String;Ljava/lang/String;)V"); - jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIIII)V"); + jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIIIII)V"); jni_mid_isAudioFormatSupported = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "isAudioFormatSupported", "(III)Z"); if(jni_mid_pushSound == NULL || @@ -495,6 +502,10 @@ JNIEXPORT jlong JNICALL FF_FUNC(createInstance0) #endif // Register all formats and codecs + sp_avcodec_register_all(); + if(HAS_FUNC(sp_avdevice_register_all)) { + sp_avdevice_register_all(); + } sp_av_register_all(); // Network too .. if(HAS_FUNC(sp_avformat_network_init)) { @@ -536,8 +547,47 @@ static uint64_t getDefaultAudioChannelLayout(int channelCount) { static void initPTSStats(PTSStats *ptsStats); static int64_t evalPTS(PTSStats *ptsStats, int64_t inPTS, int64_t inDTS); +static AVInputFormat* tryAVInputFormat(const char * name, int verbose) { + AVInputFormat* inFmt = sp_av_find_input_format(name); + if( verbose) { + if ( inFmt == NULL ) { + fprintf(stderr, "Warning: Could not find input format '%s'\n", name); + } else { + fprintf(stderr, "Info: Found input format '%s'\n", name); + } + } + return inFmt; +} +static const char * inFmtNames[] = { + "video4linux2", + "video4linux", + "vfwcap", + "dshow", + "mpg", + "yuv2", + "mjpeg", + "avi", + "wmv", + "libx264", + "h264", + "mpegts" +}; +static AVInputFormat* findAVInputFormat(int verbose) { + AVInputFormat* inFmt = NULL; + const char *inFmtName; + int i=0; + do { + inFmtName = inFmtNames[i++]; + if( NULL == inFmtName ) { + break; + } + inFmt = tryAVInputFormat(inFmtName, verbose); + } while ( NULL == inFmt ); + return inFmt; +} + JNIEXPORT void JNICALL FF_FUNC(setStream0) - (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jstring jInFmtStr, jint vid, jint aid, + (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jboolean jIsCameraInput, jint vid, jint aid, jint aMaxChannelCount, jint aPrefSampleRate) { int res, i; @@ -552,15 +602,8 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->pFormatCtx = sp_avformat_alloc_context(); // Open video file - AVInputFormat *inFmt = NULL; - const char *inFmtStr = NULL != jInFmtStr ? (*env)->GetStringUTFChars(env, jInFmtStr, &iscopy) : NULL; - if( NULL != inFmtStr ) { - inFmt = sp_av_find_input_format(inFmtStr); - if( NULL == inFmt ) { - fprintf(stderr, "Warning: Could not find input format '%s'\n", inFmtStr); - } - (*env)->ReleaseStringChars(env, jInFmtStr, (const jchar *)inFmtStr); - } + AVInputFormat* inFmt = jIsCameraInput ? findAVInputFormat(pAV->verbose) : NULL; + const char *urlPath = (*env)->GetStringUTFChars(env, jURL, &iscopy); res = sp_avformat_open_input(&pAV->pFormatCtx, urlPath, inFmt, NULL); if(res != 0) { @@ -838,22 +881,26 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) } pAV->frames_video = pAV->pVStream->nb_frames; - if( pAV->verbose ) { - fprintf(stderr, "V frame_size %d, frame_number %d, r_frame_rate %f %d/%d, avg_frame_rate %f %d/%d, nb_frames %d, \n", - pAV->pVCodecCtx->frame_size, pAV->pVCodecCtx->frame_number, - my_av_q2f(pAV->pVStream->r_frame_rate), pAV->pVStream->r_frame_rate.num, pAV->pVStream->r_frame_rate.den, - my_av_q2f(pAV->pVStream->avg_frame_rate), pAV->pVStream->avg_frame_rate.num, pAV->pVStream->avg_frame_rate.den, - pAV->pVStream->nb_frames); - } - // Allocate video frame // FIXME: Libav Binary compatibility! JAU01 + pAV->vWidth = pAV->pVCodecCtx->width; + pAV->vHeight = pAV->pVCodecCtx->height; pAV->vPixFmt = pAV->pVCodecCtx->pix_fmt; { AVPixFmtDescriptor pixDesc = sp_av_pix_fmt_descriptors[pAV->vPixFmt]; pAV->vBitsPerPixel = sp_av_get_bits_per_pixel(&pixDesc); pAV->vBufferPlanes = my_getPlaneCount(&pixDesc); } + + if( pAV->verbose ) { + fprintf(stderr, "V frame_size %d, frame_number %d, r_frame_rate %f %d/%d, avg_frame_rate %f %d/%d, nb_frames %d, size %dx%d, fmt 0x%X, bpp %d, planes %d\n", + pAV->pVCodecCtx->frame_size, pAV->pVCodecCtx->frame_number, + my_av_q2f(pAV->pVStream->r_frame_rate), pAV->pVStream->r_frame_rate.num, pAV->pVStream->r_frame_rate.den, + my_av_q2f(pAV->pVStream->avg_frame_rate), pAV->pVStream->avg_frame_rate.num, pAV->pVStream->avg_frame_rate.den, + pAV->pVStream->nb_frames, + pAV->vWidth, pAV->vHeight, pAV->vPixFmt, pAV->vBitsPerPixel, pAV->vBufferPlanes); + } + pAV->pVFrame=sp_avcodec_alloc_frame(); if( pAV->pVFrame == NULL ) { JoglCommon_throwNewRuntimeException(env, "Couldn't alloc video frame"); @@ -867,10 +914,20 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) } else { pAV->vBytesPerPixelPerPlane = 1; } - for(i=0; i<3; i++) { - // FIXME: Libav Binary compatibility! JAU01 - pAV->vLinesize[i] = pAV->pVFrame->linesize[i]; - pAV->vTexWidth[i] = pAV->vLinesize[i] / pAV->vBytesPerPixelPerPlane ; + if( pAV->vBufferPlanes > 1 ) { + for(i=0; i<3; i++) { + // FIXME: Libav Binary compatibility! JAU01 + pAV->vLinesize[i] = pAV->pVFrame->linesize[i]; + pAV->vTexWidth[i] = pAV->vLinesize[i] / pAV->vBytesPerPixelPerPlane ; + } + } else { + pAV->vLinesize[0] = pAV->pVCodecCtx->width * pAV->vBytesPerPixelPerPlane; + if( pAV->vPixFmt == PIX_FMT_YUYV422 ) { + // Stuff 2x 16bpp (YUYV) into one RGBA pixel! + pAV->vTexWidth[0] = pAV->pVCodecCtx->width / 2; + } else { + pAV->vTexWidth[0] = pAV->pVCodecCtx->width; + } } sp_avcodec_default_release_buffer(pAV->pVCodecCtx, pAV->pVFrame); } else { @@ -896,10 +953,10 @@ JNIEXPORT void JNICALL FF_FUNC(setGLFuncs0) } #if 0 -#define DBG_TEXSUBIMG2D_a(c,p,i) fprintf(stderr, "TexSubImage2D.%c offset %d / %d, size %d x %d, ", c, p->pVCodecCtx->width, p->pVCodecCtx->height/2, p->vTexWidth[i], p->pVCodecCtx->height/2) +#define DBG_TEXSUBIMG2D_a(c,p,d,i) fprintf(stderr, "TexSubImage2D.%c offset %d / %d, size %d x %d, ", c, p->pVCodecCtx->width, p->pVCodecCtx->height/d, p->vTexWidth[i], p->pVCodecCtx->height/d) #define DBG_TEXSUBIMG2D_b(p) fprintf(stderr, "err 0x%X\n", pAV->procAddrGLGetError()) #else -#define DBG_TEXSUBIMG2D_a(c,p,i) +#define DBG_TEXSUBIMG2D_a(c,p,d,i) #define DBG_TEXSUBIMG2D_b(p) #endif @@ -911,17 +968,22 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) AVPacket packet; int frameDecoded; jint resPTS = INVALID_PTS; + uint8_t * pkt_odata; + int pkt_osize; + packet.data = NULL; // minimum + packet.size = 0; // requirement sp_av_init_packet(&packet); const int avRes = sp_av_read_frame(pAV->pFormatCtx, &packet); + pkt_odata = packet.data; + pkt_osize = packet.size; if( AVERROR_EOF == avRes || ( pAV->pFormatCtx->pb && pAV->pFormatCtx->pb->eof_reached ) ) { resPTS = END_OF_STREAM_PTS; } else if( 0 <= avRes ) { - /** if( pAV->verbose ) { fprintf(stderr, "P: ptr %p, size %d\n", packet.data, packet.size); - } */ + } if(packet.stream_index==pAV->aid) { // Decode audio frame if(NULL == pAV->pAFrames) { // no audio registered @@ -932,9 +994,6 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) int flush_complete = 0; for ( frameCount=0; 0 < packet.size || 0 == frameCount; frameCount++ ) { int len1; - if (flush_complete) { - break; - } NIOBuffer_t * pNIOBufferCurrent = &pAV->pANIOBuffers[pAV->aFrameCurrent]; AVFrame* pAFrameCurrent = pAV->pAFrames[pAV->aFrameCurrent]; if( pAV->useRefCountedFrames ) { @@ -942,6 +1001,10 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) pAV->aFrameCurrent = ( pAV->aFrameCurrent + 1 ) % pAV->aFrameCount ; } sp_avcodec_get_frame_defaults(pAFrameCurrent); + + if (flush_complete) { + break; + } if(HAS_FUNC(sp_avcodec_decode_audio4)) { len1 = sp_avcodec_decode_audio4(pAV->pACodecCtx, pAFrameCurrent, &frameDecoded, &packet); } else { @@ -1013,7 +1076,7 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) nb_samples, pAV->aSampleFmtOut, 0 /* align */); - tmp_out = av_realloc(pAV->aResampleBuffer, out_size); + tmp_out = sp_av_realloc(pAV->aResampleBuffer, out_size); if (!tmp_out) { JoglCommon_throwNewRuntimeException(env, "Couldn't alloc resample buffer of size %d", out_size); return; @@ -1066,10 +1129,10 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) int flush_complete = 0; for ( frameCount=0; 0 < packet.size || 0 == frameCount; frameCount++ ) { int len1; + sp_avcodec_get_frame_defaults(pAV->pVFrame); if (flush_complete) { break; } - sp_avcodec_get_frame_defaults(pAV->pVFrame); len1 = sp_avcodec_decode_video2(pAV->pVCodecCtx, pAV->pVFrame, &frameDecoded, &packet); if (len1 < 0) { // if error, we skip the frame @@ -1116,7 +1179,7 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) // 1st plane or complete packed frame // FIXME: Libav Binary compatibility! JAU01 - DBG_TEXSUBIMG2D_a('Y',pAV,0); + DBG_TEXSUBIMG2D_a('Y',pAV,1,0); pAV->procAddrGLTexSubImage2D(texTarget, 0, 0, 0, pAV->vTexWidth[0], pAV->pVCodecCtx->height, @@ -1126,7 +1189,7 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) if(pAV->vPixFmt == PIX_FMT_YUV420P) { // U plane // FIXME: Libav Binary compatibility! JAU01 - DBG_TEXSUBIMG2D_a('U',pAV,1); + DBG_TEXSUBIMG2D_a('U',pAV,2,1); pAV->procAddrGLTexSubImage2D(texTarget, 0, pAV->pVCodecCtx->width, 0, pAV->vTexWidth[1], pAV->pVCodecCtx->height/2, @@ -1134,7 +1197,7 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) DBG_TEXSUBIMG2D_b(pAV); // V plane // FIXME: Libav Binary compatibility! JAU01 - DBG_TEXSUBIMG2D_a('V',pAV,2); + DBG_TEXSUBIMG2D_a('V',pAV,2,2); pAV->procAddrGLTexSubImage2D(texTarget, 0, pAV->pVCodecCtx->width, pAV->pVCodecCtx->height/2, pAV->vTexWidth[2], pAV->pVCodecCtx->height/2, @@ -1148,11 +1211,10 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) } } } - - // Free the packet that was allocated by av_read_frame - // This code cause a double free and have been commented out. - // TODO: check what release the packets memory. - // sp_av_free_packet(&packet); + // restore orig pointer and size values, we may have moved along within packet + packet.data = pkt_odata; + packet.size = pkt_osize; + sp_av_free_packet(&packet); } return resPTS; } diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1a.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1a.java new file mode 100644 index 000000000..87e8d7ecc --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1a.java @@ -0,0 +1,87 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.android; + +import java.util.Arrays; +import java.util.List; + +import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; + +public class MovieCubeActivityLauncher1a extends LauncherUtil.BaseActivityLauncher { + + static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0"; + static String[] sys_pkgs = new String[] { "com.jogamp.common", "javax.media.opengl" }; + static String[] usr_pkgs = new String[] { "com.jogamp.opengl.test" }; + + @Override + public void init() { + final OrderedProperties props = getProperties(); + props.setProperty("jnlp.media0_url2", "camera://0"); + props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"); + props.setProperty("jnlp.media0_url0", "file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4"); + props.setProperty("jnlp.media1_url0", "http://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"); + // props.setProperty("jogamp.debug.JNILibLoader", "true"); + // props.setProperty("jogamp.debug.NativeLibrary", "true"); + // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + // props.setProperty("jogamp.debug.Lock", "true"); + // props.setProperty("jogamp.debug.Lock.TraceLock", "true"); + // props.setProperty("nativewindow.debug", "all"); + // props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); + // props.setProperty("jogl.debug", "all"); + // props.setProperty("jogl.debug.GLProfile", "true"); + // props.setProperty("jogl.debug.GLDrawable", "true"); + // props.setProperty("jogl.debug.GLContext", "true"); + props.setProperty("jogl.debug.GLSLCode", "true"); + props.setProperty("jogl.debug.GLMediaPlayer", "true"); + // props.setProperty("jogl.debug.CapabilitiesChooser", "true"); + // props.setProperty("jogl.debug.GLSLState", "true"); + // props.setProperty("jogl.debug.DebugGL", "true"); + // props.setProperty("jogl.debug.TraceGL", "true"); + // props.setProperty("newt.debug", "all"); + // props.setProperty("newt.debug.Window", "true"); + // props.setProperty("newt.debug.Window.MouseEvent", "true"); + // props.setProperty("newt.debug.Window.KeyEvent", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + } + + @Override + public String getActivityName() { + return demo; + } + + @Override + public List getSysPackages() { + return Arrays.asList(sys_pkgs); + } + + @Override + public List getUsrPackages() { + return Arrays.asList(usr_pkgs); + } +} diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java new file mode 100644 index 000000000..f7a896a90 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java @@ -0,0 +1,87 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.android; + +import java.util.Arrays; +import java.util.List; + +import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; + +public class MovieCubeActivityLauncher1b extends LauncherUtil.BaseActivityLauncher { + + static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0"; + static String[] sys_pkgs = new String[] { "com.jogamp.common", "javax.media.opengl" }; + static String[] usr_pkgs = new String[] { "com.jogamp.opengl.test" }; + + @Override + public void init() { + final OrderedProperties props = getProperties(); + props.setProperty("jnlp.media0_url2", "camera://1"); + props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"); + props.setProperty("jnlp.media0_url0", "file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4"); + props.setProperty("jnlp.media1_url0", "http://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"); + // props.setProperty("jogamp.debug.JNILibLoader", "true"); + // props.setProperty("jogamp.debug.NativeLibrary", "true"); + // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + // props.setProperty("jogamp.debug.Lock", "true"); + // props.setProperty("jogamp.debug.Lock.TraceLock", "true"); + // props.setProperty("nativewindow.debug", "all"); + // props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); + // props.setProperty("jogl.debug", "all"); + // props.setProperty("jogl.debug.GLProfile", "true"); + // props.setProperty("jogl.debug.GLDrawable", "true"); + // props.setProperty("jogl.debug.GLContext", "true"); + props.setProperty("jogl.debug.GLSLCode", "true"); + props.setProperty("jogl.debug.GLMediaPlayer", "true"); + // props.setProperty("jogl.debug.CapabilitiesChooser", "true"); + // props.setProperty("jogl.debug.GLSLState", "true"); + // props.setProperty("jogl.debug.DebugGL", "true"); + // props.setProperty("jogl.debug.TraceGL", "true"); + // props.setProperty("newt.debug", "all"); + // props.setProperty("newt.debug.Window", "true"); + // props.setProperty("newt.debug.Window.MouseEvent", "true"); + // props.setProperty("newt.debug.Window.KeyEvent", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + } + + @Override + public String getActivityName() { + return demo; + } + + @Override + public List getSysPackages() { + return Arrays.asList(sys_pkgs); + } + + @Override + public List getUsrPackages() { + return Arrays.asList(usr_pkgs); + } +} diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java deleted file mode 100644 index e70e48ca3..000000000 --- a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00a.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.android; - -import java.util.Arrays; -import java.util.List; - -import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; - -public class MovieSimpleActivityLauncher00a extends LauncherUtil.BaseActivityLauncher { - - static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity0"; - static String[] sys_pkgs = new String[] { "com.jogamp.common", "javax.media.opengl" }; - static String[] usr_pkgs = new String[] { "com.jogamp.opengl.test" }; - - @Override - public void init() { - final OrderedProperties props = getProperties(); - props.setProperty("jnlp.mplayer.nozoom", "true"); - props.setProperty("jnlp.mplayer.hud", "false"); - props.setProperty("jnlp.mplayer.hud.shared", "false"); - // props.setProperty("jnlp.media0_url2", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v"); - props.setProperty("jnlp.media0_url2", "http://video.webmfiles.org/big-buck-bunny_trailer.webm"); - props.setProperty("jnlp.media0_url1", "http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4"); - props.setProperty("jnlp.media0_url0", "file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4"); - props.setProperty("jnlp.media1_url0", "http://archive.org/download/ElephantsDream/ed_1024_512kb.mp4"); - // props.setProperty("jogamp.debug.JNILibLoader", "true"); - // props.setProperty("jogamp.debug.NativeLibrary", "true"); - // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); - // props.setProperty("jogamp.debug.IOUtil", "true"); - // props.setProperty("nativewindow.debug", "all"); - props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); - // props.setProperty("jogl.debug", "all"); - // props.setProperty("jogl.debug.GLProfile", "true"); - props.setProperty("jogl.debug.GLDrawable", "true"); - props.setProperty("jogl.debug.GLContext", "true"); - props.setProperty("jogl.debug.GLSLCode", "true"); - // props.setProperty("jogl.debug.CapabilitiesChooser", "true"); - // props.setProperty("jogl.debug.GLSLState", "true"); - // props.setProperty("jogl.debug.DebugGL", "true"); - // props.setProperty("jogl.debug.TraceGL", "true"); - // props.setProperty("newt.debug", "all"); - // props.setProperty("newt.debug.Window", "true"); - // props.setProperty("newt.debug.Window.MouseEvent", "true"); - // props.setProperty("newt.debug.Window.KeyEvent", "true"); - props.setProperty("jogamp.debug.IOUtil", "true"); - } - - @Override - public String getActivityName() { - return demo; - } - @Override - public List getSysPackages() { - return Arrays.asList(sys_pkgs); - } - - @Override - public List getUsrPackages() { - return Arrays.asList(usr_pkgs); - } -} diff --git a/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00c.java b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00c.java new file mode 100644 index 000000000..2254b649a --- /dev/null +++ b/src/test/com/jogamp/opengl/test/android/MovieSimpleActivityLauncher00c.java @@ -0,0 +1,86 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.android; + +import java.util.Arrays; +import java.util.List; + +import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; + +public class MovieSimpleActivityLauncher00c extends LauncherUtil.BaseActivityLauncher { + + static String demo = "com.jogamp.opengl.test.android.MovieSimpleActivity1"; + static String[] sys_pkgs = new String[] { "com.jogamp.common", "javax.media.opengl" }; + static String[] usr_pkgs = new String[] { "com.jogamp.opengl.test" }; + + @Override + public void init() { + final OrderedProperties props = getProperties(); + props.setProperty("jnlp.mplayer.nozoom", "false"); + props.setProperty("jnlp.mplayer.hud", "false"); + props.setProperty("jnlp.mplayer.hud.shared", "false"); + props.setProperty("jnlp.media0_url2", "camera://0"); + props.setProperty("jnlp.media0_url1", "http://video.webmfiles.org/big-buck-bunny_trailer.webm"); + props.setProperty("jnlp.media0_url0", "file:///mnt/sdcard/Movies/BigBuckBunny_320x180.mp4"); + // props.setProperty("jogamp.debug.JNILibLoader", "true"); + // props.setProperty("jogamp.debug.NativeLibrary", "true"); + // props.setProperty("jogamp.debug.NativeLibrary.Lookup", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + // props.setProperty("nativewindow.debug", "all"); + // props.setProperty("nativewindow.debug.GraphicsConfiguration", "true"); + // props.setProperty("jogl.debug", "all"); + // props.setProperty("jogl.debug.GLProfile", "true"); + // props.setProperty("jogl.debug.GLDrawable", "true"); + // props.setProperty("jogl.debug.GLContext", "true"); + props.setProperty("jogl.debug.GLSLCode", "true"); + props.setProperty("jogl.debug.GLMediaPlayer", "true"); + // props.setProperty("jogl.debug.CapabilitiesChooser", "true"); + // props.setProperty("jogl.debug.GLSLState", "true"); + // props.setProperty("jogl.debug.DebugGL", "true"); + // props.setProperty("jogl.debug.TraceGL", "true"); + // props.setProperty("newt.debug", "all"); + // props.setProperty("newt.debug.Window", "true"); + // props.setProperty("newt.debug.Window.MouseEvent", "true"); + // props.setProperty("newt.debug.Window.KeyEvent", "true"); + // props.setProperty("jogamp.debug.IOUtil", "true"); + } + + @Override + public String getActivityName() { + return demo; + } + @Override + public List getSysPackages() { + return Arrays.asList(sys_pkgs); + } + + @Override + public List getUsrPackages() { + return Arrays.asList(usr_pkgs); + } +} -- cgit v1.2.3 From 9bf14f3c6bf98bd86913bec6e7feb54537f9b7d3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 28 Aug 2013 12:44:06 +0200 Subject: Fix libav/ffmpeg compilation; FFMPEGMediaPlayer Enahncements (More YUV*, Use def. high camera options, cleanup symbols) - Fix libav/ffmpeg compilation - Split native GLContext code from JoglCommon - JoglCommon is required for ffmpeg_* c-compile/link - Supported versions now: - 0.8 53.53.51 - 9.0 54.54.52 - FFMPEGMediaPlayer - Update API doc, add compatibility .. etc - Pixel format conversions (via shader texture lookup func): - YUV420P, YUVJ420P - YUV422P, YUVJ422P - YUYV422 - Properly handle aid/vid - In camera mode: set high default values - TODO: Make it configurable via camera URI: - video_size - framerate - ? - FFMPEGDynamicLibraryBundleInfo - Cleanup symbols / remove unused (pre 53) - Add av_dict_* methods --- make/build-jogl.xml | 3 + make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 20 +- make/scripts/tests-x64.bat | 8 +- make/scripts/tests.sh | 6 +- .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 38 +-- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 275 ++++++++++++++------- .../jogamp/opengl/util/av/impl/FFMPEGNatives.java | 127 ++++++---- src/jogl/native/GLContext.c | 46 ++++ src/jogl/native/JoglCommon.c | 40 --- src/jogl/native/libav/ffmpeg_impl_template.c | 160 ++++++------ 11 files changed, 440 insertions(+), 287 deletions(-) create mode 100644 src/jogl/native/GLContext.c (limited to 'make/scripts') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 58ce64b6f..582e8b654 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1424,6 +1424,7 @@ + @@ -1495,6 +1496,7 @@ + @@ -1519,6 +1521,7 @@ + diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 872ba3716..af01ee2e1 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -115,7 +115,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursive REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00bNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00cNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01aNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode01cNEWT %* @@ -124,7 +124,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index c8b1ef5b0..fb2a94e95 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -7,14 +7,14 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl set BLD_DIR=..\%BLD_SUB% -set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x64 +set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01\x64 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51\x64 -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% -REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj -set LIB_DIR=%FFMPEG_LIB% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% -set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar +set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\%BLD_SUB%\joal.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar echo CP_ALL %CP_ALL% @@ -25,7 +25,13 @@ REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" -REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" +REM set D_ARGS="-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" +REM set D_ARGS="-Djogl.debug.GLMediaPlayer" +REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.AudioSink" +set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.GLMediaPlayer.Native" +REM set D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25" "-Djogl.debug.GLMediaPlayer" +REM set D_ARGS="-Djogl.debug.GLMediaPlayer.Native" +REM set D_ARGS="-Djogl.debug.AudioSink" REM set D_ARGS="-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" "-Djogl.debug.GLSLCode" REM set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper" "-Djogamp.debug.NativeLibrary" "-Djogamp.debug.NativeLibrary.Lookup" "-Djogamp.debug.JNILibLoader" "-Djogamp.debug.TempJarCache" "-Djogamp.debug.JarUtil" REM set D_ARGS="-Djogl.debug.ExtensionAvailabilityCache" "-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug.ProcAddressHelper=true" "-Djogamp.debug.NativeLibrary=true" "-Djogamp.debug.NativeLibrary.Lookup=true" @@ -40,7 +46,7 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" -set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 899c69479..7ed47f635 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -4,14 +4,18 @@ set J2RE_HOME=c:\jre1.7.0_25_x64 set JAVA_HOME=c:\jdk1.7.0_25_x64 set ANT_PATH=C:\apache-ant-1.8.2 +set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01\x64 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51\x64 + REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% set BLD_DIR=..\%BLD_SUB% REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj set LIB_DIR= -set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar +set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\%BLD_SUB%\joal.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar echo CP_ALL %CP_ALL% set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2be4d76b2..aa17c2163 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -132,7 +132,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" - #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native -Djogl.debug.GLSLCode" D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" @@ -319,8 +319,8 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index 040d152f5..f327cddd4 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -46,14 +46,7 @@ import com.jogamp.common.util.RunnableExecutor; import com.jogamp.common.util.VersionNumber; /** - * FIXME: We need native structure access methods to deal with API changes - * in the libav headers, which break binary compatibility! - * Currently we are binary compatible w/ [0.6 ?, ] 0.7 and 0.8 but not w/ trunk. - * - * ChangeList for trunk: - * Thu Jan 12 11:21:02 2012 a17479dfce67fbea2d0a1bf303010dce1e79059f major 53 -> 54 - * Mon Feb 27 22:40:11 2012 ee42df8a35c2b795f524c856834d0823dbd4e75d reorder AVStream and AVFormatContext - * Tue Feb 28 12:07:53 2012 322537478b63c6bc01e640643550ff539864d790 minor 1 -> 2 + * See {@link FFMPEGMediaPlayer#compatibility}. */ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { private static final boolean DEBUG = FFMPEGMediaPlayer.DEBUG || DynamicLibraryBundleInfo.DEBUG; @@ -73,7 +66,6 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avcodec_string", "avcodec_find_decoder", "avcodec_open2", // 53.6.0 (opt) - "avcodec_open", "avcodec_alloc_frame", "avcodec_get_frame_defaults", "avcodec_free_frame", // 54.28.0 (opt) @@ -85,8 +77,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "av_destruct_packet", "av_free_packet", "avcodec_decode_audio4", // 53.25.0 (opt) - "avcodec_decode_audio3", // 52.23.0 -/* 23 */ "avcodec_decode_video2", // 52.23.0 +/* 21 */ "avcodec_decode_video2", // 52.23.0 // libavutil "av_pix_fmt_descriptors", @@ -96,13 +87,16 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "av_get_bits_per_pixel", "av_samples_get_buffer_size", "av_get_bytes_per_sample", // 51.4.0 -/* 31 */ "av_opt_set_int", // 51.12.0 - + "av_opt_set_int", // 51.12.0 + "av_dict_get", + "av_dict_count", // 54.* (opt) + "av_dict_set", +/* 33 */ "av_dict_free", + // libavformat "avformat_alloc_context", "avformat_free_context", // 52.96.0 (opt) "avformat_close_input", // 53.17.0 (opt) - "av_close_input_file", "av_register_all", "av_find_input_format", "avformat_open_input", @@ -114,8 +108,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "av_read_pause", "avformat_network_init", // 53.13.0 (opt) "avformat_network_deinit", // 53.13.0 (opt) - "avformat_find_stream_info", // 53.3.0 (opt) -/* 48 */ "av_find_stream_info", +/* 48 */ "avformat_find_stream_info", // 53.3.0 (opt) // libavdevice /* 49 */ "avdevice_register_all", // ??? @@ -130,20 +123,15 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { // alternate symbol names private static final String[][] altSymbolNames = { - { "avcodec_open", "avcodec_open2" }, // old, 53.6.0 - { "avcodec_decode_audio3", "avcodec_decode_audio4" }, // old, 53.25.0 - { "av_close_input_file", "avformat_close_input" }, // old, 53.17.0 - { "av_find_stream_info", "avformat_find_stream_info" }, // old, 53.3.0 + // { "av_find_stream_info", "avformat_find_stream_info" }, // old, 53.3.0 }; // optional symbol names private static final String[] optionalSymbolNames = { - "avformat_free_context", // 52.96.0 (opt) - "avformat_network_init", // 53.13.0 (opt) - "avformat_network_deinit", // 53.13.0 (opt) "avformat_seek_file", // ??? (opt) "avcodec_free_frame", // 54.28.0 (opt) "av_frame_unref", // 55.0.0 (opt) + "av_dict_count", // 54.* (opt) // libavdevice "avdevice_register_all", // 53.0.0 (opt) // libavresample @@ -377,10 +365,10 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { avdevice.add("avdevice"); // default avdevice.add("libavdevice.so.54"); // dummy future proof - avdevice.add("libavdevice.so.53"); // 8 && 9 + avdevice.add("libavdevice.so.53"); // 0.8 && 9 avdevice.add("avdevice-54"); // dummy future proof - avdevice.add("avdevice-53"); // 8 && 9 + avdevice.add("avdevice-53"); // 0.8 && 9 libsList.add(avdevice); final List avresample = new ArrayList(); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 952587ed9..2dd60074c 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -38,6 +38,7 @@ import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; import com.jogamp.common.os.Platform; +import com.jogamp.common.util.VersionNumber; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.opengl.util.TimeFrameI; import com.jogamp.opengl.util.GLPixelStorageModes; @@ -55,54 +56,87 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; /*** * Implementation utilizes Libav * or FFmpeg which is ubiquitous - * available and usually pre-installed on Unix platforms. Due to legal - * reasons we cannot deploy binaries of it, which contains patented codecs. + * available and usually pre-installed on Unix platforms. + *

      + * Due to legal reasons we cannot deploy binaries of it, which contains patented codecs. + *

      + *

      * Besides the default BSD/Linux/.. repositories and installations, - * precompiled binaries can be found at the listed location below. + * precompiled binaries can be found at the + * listed location below. + *

      + * + *
      Implementation specifics
      *

      - * Implements YUV420P to RGB fragment shader conversion - * and the usual packed RGB formats. * The decoded video frame is written directly into an OpenGL texture * on the GPU in it's native format. A custom fragment shader converts - * the native pixelformat to a usable RGB format if required. + * the native pixelformat to a usable RGB format if required. * Hence only 1 copy is required before bloating the picture - * from YUV to RGB, for example. + * from YUV* to RGB, for example. *

      *

      + * Implements pixel format conversion to RGB via + * fragment shader texture-lookup functions: + *

        + *
      • {@link PixelFormat#YUV420P}
      • + *
      • {@link PixelFormat#YUVJ420P}
      • + *
      • {@link PixelFormat#YUV422P}
      • + *
      • {@link PixelFormat#YUVJ422P}
      • + *
      • {@link PixelFormat#YUYV422}
      • + *
      + *

      + *

      + * + *

      Libav Specifics
      + *

      * Utilizes a slim dynamic and native binding to the Lib_av * libraries: *

        - *
      • libavutil
      • - *
      • libavformat
      • *
      • libavcodec
      • + *
      • libavformat
      • + *
      • libavutil
      • + *
      • libavresample (opt)
      • + *
      • libavdevice (opt)
      • *
      *

      + * + *
      LibAV Compatibility
      + *

      + * Currently we are binary compatible w/: + * + * + * + * + *
      releaselavclavflavulavr FFMPEG* class
      0.8 535351 FFMPEGv08
      9.0 54545201 FFMPEGv09
      + *

      *

      - * http://libav.org/ + * See http://upstream-tracker.org/versions/libav.html *

      *

      * Check tag 'FIXME: Add more planar formats !' * here and in the corresponding native code - * jogl/src/jogl/native/ffmpeg/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c + * jogl/src/jogl/native/libav/ffmpeg_impl_template.c *

      + * + * + *
      TODO:
      *

      - * TODO: *

        - *
      • Audio Output
      • - *
      • Off thread next frame processing using multiple target textures
      • *
      • better pts sync handling
      • - *
      • fix seek
      • *
      *

      - * Pre-compiled Libav / FFmpeg packages: + * + *
      LibAV Availability
      + *

      *

        - *
      • Windows: http://ffmpeg.zeranoe.com/builds/
      • - *
      • MacOSX: http://www.ffmpegx.com/
      • + *
      • Windows: http://win32.libav.org/releases/
      • + *
      • MacOSX: http://ffmpegmac.net/
      • *
      • OpenIndiana/Solaris:
          *       pkg set-publisher -p http://pkg.openindiana.org/sfe-encumbered.
          *       pkt install pkg:/video/ffmpeg
          *       
      • - *
      + * + *

      */ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { @@ -122,19 +156,24 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { final boolean libAVVersionGood; if( FFMPEGDynamicLibraryBundleInfo.libsLoaded() ) { natives = FFMPEGDynamicLibraryBundleInfo.getNatives(); - avUtilMajorVersionCC = natives.getAvUtilMajorVersionCC0(); - avFormatMajorVersionCC = natives.getAvFormatMajorVersionCC0(); avCodecMajorVersionCC = natives.getAvCodecMajorVersionCC0(); + avFormatMajorVersionCC = natives.getAvFormatMajorVersionCC0(); + avUtilMajorVersionCC = natives.getAvUtilMajorVersionCC0(); avResampleMajorVersionCC = natives.getAvResampleMajorVersionCC0(); - System.err.println("LIB_AV Util : "+FFMPEGDynamicLibraryBundleInfo.avUtilVersion+" [cc "+avUtilMajorVersionCC+"]"); - System.err.println("LIB_AV Format : "+FFMPEGDynamicLibraryBundleInfo.avFormatVersion+" [cc "+avFormatMajorVersionCC+"]"); - System.err.println("LIB_AV Codec : "+FFMPEGDynamicLibraryBundleInfo.avCodecVersion+" [cc "+avCodecMajorVersionCC+"]"); - System.err.println("LIB_AV Device : [loaded "+FFMPEGDynamicLibraryBundleInfo.avDeviceLoaded()+"]"); + final VersionNumber avCodecVersion = FFMPEGDynamicLibraryBundleInfo.avCodecVersion; + final VersionNumber avFormatVersion = FFMPEGDynamicLibraryBundleInfo.avFormatVersion; + final VersionNumber avUtilVersion = FFMPEGDynamicLibraryBundleInfo.avUtilVersion; + final VersionNumber avResampleVersion = FFMPEGDynamicLibraryBundleInfo.avResampleVersion; + System.err.println("LIB_AV Codec : "+avCodecVersion+" [cc "+avCodecMajorVersionCC+"]"); + System.err.println("LIB_AV Format : "+avFormatVersion+" [cc "+avFormatMajorVersionCC+"]"); + System.err.println("LIB_AV Util : "+avUtilVersion+" [cc "+avUtilMajorVersionCC+"]"); System.err.println("LIB_AV Resample: "+FFMPEGDynamicLibraryBundleInfo.avResampleVersion+" [cc "+avResampleMajorVersionCC+", loaded "+FFMPEGDynamicLibraryBundleInfo.avResampleLoaded()+"]"); - libAVVersionGood = avUtilMajorVersionCC == FFMPEGDynamicLibraryBundleInfo.avUtilVersion.getMajor() && - avFormatMajorVersionCC == FFMPEGDynamicLibraryBundleInfo.avFormatVersion.getMajor() && - avCodecMajorVersionCC == FFMPEGDynamicLibraryBundleInfo.avCodecVersion.getMajor() && - avResampleMajorVersionCC == FFMPEGDynamicLibraryBundleInfo.avResampleVersion.getMajor(); + System.err.println("LIB_AV Device : [loaded "+FFMPEGDynamicLibraryBundleInfo.avDeviceLoaded()+"]"); + System.err.println("LIB_AV Class : "+natives.getClass().getSimpleName()); + libAVVersionGood = avCodecMajorVersionCC == avCodecVersion.getMajor() && + avFormatMajorVersionCC == avFormatVersion.getMajor() && + avUtilMajorVersionCC == avUtilVersion.getMajor() && + avResampleMajorVersionCC == avResampleVersion.getMajor(); if( !libAVVersionGood ) { System.err.println("LIB_AV Not Matching Compile-Time / Runtime Major-Version"); } @@ -167,8 +206,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { private int vPlanes = 0; private int vBitsPerPixel = 0; private int vBytesPerPixelPerPlane = 0; - private int[] vLinesize = { 0, 0, 0 }; // per plane - private int[] vTexWidth = { 0, 0, 0 }; // per plane private int texWidth, texHeight; // overall (stuffing planes in one texture) private String singleTexComp = "r"; private GLPixelStorageModes psm; @@ -270,7 +307,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { throw new GLException("AudioSink null"); } final int audioQueueLimit; - if( null != gl ) { + if( null != gl && STREAM_ID_NONE != vid ) { final GLContextImpl ctx = (GLContextImpl)gl.getContext(); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { @@ -286,12 +323,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } else { audioQueueLimit = AudioSink.DefaultQueueLimitAudioOnly; } - final float frameDuration; - if( audioSamplesPerFrameAndChannel > 0 ) { - frameDuration= avChosenAudioFormat.getSamplesDuration(audioSamplesPerFrameAndChannel); - } else { - frameDuration = AudioSink.DefaultFrameDuration; - } if(DEBUG) { System.err.println("initGL: p3 avChosen "+avChosenAudioFormat); } @@ -299,20 +330,28 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { if( STREAM_ID_NONE == aid ) { audioSink.destroy(); audioSink = AudioSinkFactory.createNull(); - } - final boolean audioSinkOK = audioSink.init(avChosenAudioFormat, frameDuration, AudioSink.DefaultInitialQueueSize, AudioSink.DefaultQueueGrowAmount, audioQueueLimit); - if( !audioSinkOK ) { - System.err.println("AudioSink "+audioSink.getClass().getName()+" does not support "+avChosenAudioFormat+", using Null"); - audioSink.destroy(); - audioSink = AudioSinkFactory.createNull(); - audioSink.init(avChosenAudioFormat, 0, AudioSink.DefaultInitialQueueSize, AudioSink.DefaultQueueGrowAmount, audioQueueLimit); + audioSink.init(AudioSink.DefaultFormat, 0, AudioSink.DefaultInitialQueueSize, AudioSink.DefaultQueueGrowAmount, audioQueueLimit); + } else { + final float frameDuration; + if( audioSamplesPerFrameAndChannel > 0 ) { + frameDuration= avChosenAudioFormat.getSamplesDuration(audioSamplesPerFrameAndChannel); + } else { + frameDuration = AudioSink.DefaultFrameDuration; + } + final boolean audioSinkOK = audioSink.init(avChosenAudioFormat, frameDuration, AudioSink.DefaultInitialQueueSize, AudioSink.DefaultQueueGrowAmount, audioQueueLimit); + if( !audioSinkOK ) { + System.err.println("AudioSink "+audioSink.getClass().getName()+" does not support "+avChosenAudioFormat+", using Null"); + audioSink.destroy(); + audioSink = AudioSinkFactory.createNull(); + audioSink.init(avChosenAudioFormat, 0, AudioSink.DefaultInitialQueueSize, AudioSink.DefaultQueueGrowAmount, audioQueueLimit); + } } if(DEBUG) { System.err.println("initGL: p4 chosen "+avChosenAudioFormat); System.err.println("initGL: p4 chosen "+audioSink); } - if( null != gl ) { + if( null != gl && STREAM_ID_NONE != vid ) { int tf, tif=GL.GL_RGBA; // texture format and internal format int tt = GL.GL_UNSIGNED_BYTE; switch(vBytesPerPixelPerPlane) { @@ -325,7 +364,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { tf = GL2ES2.GL_ALPHA; tif=GL2ES2.GL_ALPHA; singleTexComp = "a"; } break; - + case 2: if( vPixelFmt == PixelFormat.YUYV422 ) { // YUYV422: // < packed YUV 4:2:2, 2x 16bpp, Y0 Cb Y1 Cr // Stuffed into RGBA half width texture @@ -426,6 +465,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { /** * Native callback + * @param vid * @param pixFmt * @param planes * @param bitsPerPixel @@ -436,58 +476,96 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { * @param tWd0 * @param tWd1 * @param tWd2 + * @param aid * @param audioSampleFmt * @param audioSampleRate * @param audioChannels * @param audioSamplesPerFrameAndChannel in audio samples per frame and channel */ - void updateAttributes2(int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, + void updateAttributes2(int vid, int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, int lSz0, int lSz1, int lSz2, int tWd0, int tWd1, int tWd2, int vW, int vH, - int audioSampleFmt, int audioSampleRate, + int aid, int audioSampleFmt, int audioSampleRate, int audioChannels, int audioSamplesPerFrameAndChannel) { - vPixelFmt = PixelFormat.valueOf(pixFmt); - vPlanes = planes; - vBitsPerPixel = bitsPerPixel; - vBytesPerPixelPerPlane = bytesPerPixelPerPlane; - vLinesize[0] = lSz0; vLinesize[1] = lSz1; vLinesize[2] = lSz2; - vTexWidth[0] = tWd0; vTexWidth[1] = tWd1; vTexWidth[2] = tWd2; + // defaults .. + vPixelFmt = null; + vPlanes = 0; + vBitsPerPixel = 0; + vBytesPerPixelPerPlane = 0; + usesTexLookupShader = false; + texWidth = 0; texHeight = 0; - switch(vPixelFmt) { - case YUV420P: // < planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) - usesTexLookupShader = true; - // YUV420P: Adding U+V on right side of fixed height texture, - // since width is already aligned by decoder. - // Y=w*h, Y=w/2*h/2, U=w/2*h/2 - // w*h + 2 ( w/2 * h/2 ) - // w*h + w*h/2 - // 2*w/2 * h - texWidth = vTexWidth[0] + vTexWidth[1]; texHeight = vH; - break; - case YUYV422: // < packed YUV 4:2:2, 2x 16bpp, Y0 Cb Y1 Cr - stuffed into RGBA half width texture - usesTexLookupShader = true; - texWidth = vTexWidth[0]; texHeight = vH; - break; - case RGB24: - case BGR24: - case ARGB: - case RGBA: - case ABGR: - case BGRA: - usesTexLookupShader = false; - texWidth = vTexWidth[0]; texHeight = vH; - break; - default: // FIXME: Add more formats ! - throw new RuntimeException("Unsupported pixelformat: "+vPixelFmt); + final int[] vLinesize = { 0, 0, 0 }; // per plane + final int[] vTexWidth = { 0, 0, 0 }; // per plane + + if( STREAM_ID_NONE != vid ) { + vPixelFmt = PixelFormat.valueOf(pixFmt); + vPlanes = planes; + vBitsPerPixel = bitsPerPixel; + vBytesPerPixelPerPlane = bytesPerPixelPerPlane; + vLinesize[0] = lSz0; vLinesize[1] = lSz1; vLinesize[2] = lSz2; + vTexWidth[0] = tWd0; vTexWidth[1] = tWd1; vTexWidth[2] = tWd2; + + switch(vPixelFmt) { + case YUVJ420P: + case YUV420P: // < planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) + usesTexLookupShader = true; + // YUV420P: Adding U+V on right side of fixed height texture, + // since width is already aligned by decoder. + // Splitting texture to 4 quadrants: + // Y covers left top/low quadrant + // U on top-right quadrant. + // V on low-right quadrant. + // Y=w*h, U=w/2*h/2, V=w/2*h/2 + // w*h + 2 ( w/2 * h/2 ) + // w*h + w*h/2 + texWidth = vTexWidth[0] + vTexWidth[1]; texHeight = vH; + break; + case YUVJ422P: + case YUV422P: + usesTexLookupShader = true; + // YUV422P: Adding U+V on right side of fixed height texture, + // since width is already aligned by decoder. + // Splitting texture to 4 columns + // Y covers columns 1+2 + // U covers columns 3 + // V covers columns 4 + texWidth = vTexWidth[0] + vTexWidth[1] + vTexWidth[2]; texHeight = vH; + break; + case YUYV422: // < packed YUV 4:2:2, 2x 16bpp, Y0 Cb Y1 Cr - stuffed into RGBA half width texture + usesTexLookupShader = true; + texWidth = vTexWidth[0]; texHeight = vH; + break; + case RGB24: + case BGR24: + case ARGB: + case RGBA: + case ABGR: + case BGRA: + usesTexLookupShader = false; + texWidth = vTexWidth[0]; texHeight = vH; + break; + default: // FIXME: Add more formats ! + throw new RuntimeException("Unsupported pixelformat: "+vPixelFmt); + } + } + + // defaults .. + final SampleFormat aSampleFmt; + avChosenAudioFormat = null;; + this.audioSamplesPerFrameAndChannel = 0; + + if( STREAM_ID_NONE != aid ) { + aSampleFmt = SampleFormat.valueOf(audioSampleFmt); + avChosenAudioFormat = avAudioFormat2Local(aSampleFmt, audioSampleRate, audioChannels); + this.audioSamplesPerFrameAndChannel = audioSamplesPerFrameAndChannel; + } else { + aSampleFmt = null; } - final SampleFormat aSampleFmt = SampleFormat.valueOf(audioSampleFmt); - avChosenAudioFormat = avAudioFormat2Local(aSampleFmt, audioSampleRate, audioChannels); - - this.audioSamplesPerFrameAndChannel = audioSamplesPerFrameAndChannel; if(DEBUG) { - System.err.println("audio: fmt "+aSampleFmt+", "+avChosenAudioFormat+", aFrameSize/fc "+audioSamplesPerFrameAndChannel); - System.err.println("video: fmt "+vW+"x"+vH+", "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane+", usesTexLookupShader "+usesTexLookupShader); + System.err.println("audio: id "+aid+", fmt "+aSampleFmt+", "+avChosenAudioFormat+", aFrameSize/fc "+audioSamplesPerFrameAndChannel); + System.err.println("video: id "+vid+", fmt "+vW+"x"+vH+", "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane+", usesTexLookupShader "+usesTexLookupShader); for(int i=0; i<3; i++) { System.err.println("video: "+i+": "+vTexWidth[i]+"/"+vLinesize[i]); } @@ -532,6 +610,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } final float tc_w_1 = (float)getWidth() / (float)texWidth; switch(vPixelFmt) { + case YUVJ420P: case YUV420P: // < planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) return "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ @@ -551,6 +630,28 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { " return vec4(r, g, b, 1);\n"+ "}\n" ; + + case YUVJ422P: + case YUV422P: ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) + return + "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + " vec2 u_off = vec2("+tc_w_1+" , 0.0);\n"+ + " vec2 v_off = vec2("+tc_w_1+" * 1.5, 0.0);\n"+ + " vec2 tc_halfw = vec2(texCoord.x*0.5, texCoord.y);\n"+ + " float y,u,v,r,g,b;\n"+ + " y = texture2D(image, texCoord)."+singleTexComp+";\n"+ + " u = texture2D(image, u_off+tc_halfw)."+singleTexComp+";\n"+ + " v = texture2D(image, v_off+tc_halfw)."+singleTexComp+";\n"+ + " y = 1.1643*(y-0.0625);\n"+ + " u = u-0.5;\n"+ + " v = v-0.5;\n"+ + " r = y+1.5958*v;\n"+ + " g = y-0.39173*u-0.81290*v;\n"+ + " b = y+2.017*u;\n"+ + " return vec4(r, g, b, 1);\n"+ + "}\n" + ; + case YUYV422: // < packed YUV 4:2:2, 2 x 16bpp, [Y0 Cb] [Y1 Cr] // Stuffed into RGBA half width texture return diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java index 9dd1ac74a..3ee87b5da 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java @@ -105,51 +105,94 @@ interface FFMPEGNatives { /** FFMPEG/libAV Pixel Format */ public static enum PixelFormat { // NONE= -1, - YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) - YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr - RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB... - BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR... - YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) - YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) - YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) - YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) - GRAY8, ///< Y , 8bpp - MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb - MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb - PAL8, ///< 8 bit with RGB32 palette - YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of YUV420P and setting color_range - YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of YUV422P and setting color_range - YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of YUV444P and setting color_range - XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing + /** planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) */ + YUV420P, + /** packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr ( sharing Cb and Cr w/ 2 pixels )*/ + YUYV422, + /** packed RGB 8:8:8, 24bpp, RGBRGB... */ + RGB24, + /** packed RGB 8:8:8, 24bpp, BGRBGR... */ + BGR24, + /** planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) */ + YUV422P, + /** planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) */ + YUV444P, + /** planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) */ + YUV410P, + /** planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) */ + YUV411P, + /** Y, 8bpp */ + GRAY8, + /** Y, 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb */ + MONOWHITE, + /** Y, 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb */ + MONOBLACK, + /** 8 bit with RGB32 palette */ + PAL8, + /** planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of YUV420P and setting color_range */ + YUVJ420P, + /** planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of YUV422P and setting color_range */ + YUVJ422P, + /** planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of YUV444P and setting color_range */ + YUVJ444P, + /** XVideo Motion Acceleration via common packet passing */ + XVMC_MPEG2_MC, + /** */ XVMC_MPEG2_IDCT, - UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 - UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 - BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) - BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits - BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) - RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) - RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits - RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) - NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) - NV21, ///< as above, but U and V bytes are swapped + /** packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 */ + UYVY422, + /** packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 */ + UYYVYY411, + /** packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) */ + BGR8, + /** packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits */ + BGR4, + /** packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) */ + BGR4_BYTE, + /** packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) */ + RGB8, + /** packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits */ + RGB4, + /** packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) */ + RGB4_BYTE, + /** planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) */ + NV12, + /** as above, but U and V bytes are swapped */ + NV21, - ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB... - RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA... - ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR... - BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA... + /** packed ARGB 8:8:8:8, 32bpp, ARGBARGB... */ + ARGB, + /** packed RGBA 8:8:8:8, 32bpp, RGBARGBA... */ + RGBA, + /** packed ABGR 8:8:8:8, 32bpp, ABGRABGR... */ + ABGR, + /** packed BGRA 8:8:8:8, 32bpp, BGRABGRA... */ + BGRA, - GRAY16BE, ///< Y , 16bpp, big-endian - GRAY16LE, ///< Y , 16bpp, little-endian - YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) - YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of YUV440P and setting color_range - YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) - VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers - VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers - VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers - VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers - VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers - RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian - RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian + /** Y, 16bpp, big-endian */ + GRAY16BE, + /** Y , 16bpp, little-endian */ + GRAY16LE, + /** planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) */ + YUV440P, + /** planar YUV 4:4:0 full scale (JPEG), deprecated in favor of YUV440P and setting color_range */ + YUVJ440P, + /** planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) */ + YUVA420P, + /** H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */ + VDPAU_H264, + /** MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */ + VDPAU_MPEG1, + /** MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */ + VDPAU_MPEG2, + /** WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */ + VDPAU_WMV3, + /** VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers */ + VDPAU_VC1, + /** packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian */ + RGB48BE, + /** packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian */ + RGB48LE, RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian diff --git a/src/jogl/native/GLContext.c b/src/jogl/native/GLContext.c new file mode 100644 index 000000000..f10d0e421 --- /dev/null +++ b/src/jogl/native/GLContext.c @@ -0,0 +1,46 @@ + +#include "jogamp_opengl_GLContextImpl.h" +#include "JoglCommon.h" + +#include +#include + +/* + * Class: jogamp_opengl_GLContextImpl + * Method: glGetStringInt + * Signature: (IJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_jogamp_opengl_GLContextImpl_glGetStringInt(JNIEnv *env, jclass _unused, jint name, jlong procAddress) { + typedef const khronos_uint8_t * (KHRONOS_APIENTRY*_local_PFNGLGETSTRINGPROC)(unsigned int name); + _local_PFNGLGETSTRINGPROC ptr_glGetString; + const khronos_uint8_t * _res; + ptr_glGetString = (_local_PFNGLGETSTRINGPROC) (intptr_t) procAddress; + assert(ptr_glGetString != NULL); + _res = (* ptr_glGetString) ((unsigned int) name); + if (NULL == _res) return NULL; + return (*env)->NewStringUTF(env, _res); +} + +/* + * Class: jogamp_opengl_GLContextImpl + * Method: glGetIntegervInt + * Signature: (ILjava/lang/Object;I)V + */ +JNIEXPORT void JNICALL +Java_jogamp_opengl_GLContextImpl_glGetIntegervInt(JNIEnv *env, jclass _unused, jint pname, jobject params, jint params_byte_offset, jlong procAddress) { + typedef void (KHRONOS_APIENTRY*_local_PFNGLGETINTEGERVPROC)(unsigned int pname, int * params); + + _local_PFNGLGETINTEGERVPROC ptr_glGetIntegerv; + int * _params_ptr = NULL; + if ( NULL != params ) { + _params_ptr = (int *) (((char*) (*env)->GetPrimitiveArrayCritical(env, params, NULL) ) + params_byte_offset); + } + ptr_glGetIntegerv = (_local_PFNGLGETINTEGERVPROC) (intptr_t) procAddress; + assert(ptr_glGetIntegerv != NULL); + (* ptr_glGetIntegerv) ((unsigned int) pname, (int *) _params_ptr); + if ( NULL != params ) { + (*env)->ReleasePrimitiveArrayCritical(env, params, _params_ptr, 0); + } +} + diff --git a/src/jogl/native/JoglCommon.c b/src/jogl/native/JoglCommon.c index 62dd8ef21..4170b13ec 100644 --- a/src/jogl/native/JoglCommon.c +++ b/src/jogl/native/JoglCommon.c @@ -1,5 +1,4 @@ -#include "jogamp_opengl_GLContextImpl.h" #include "JoglCommon.h" #include @@ -132,42 +131,3 @@ void JoglCommon_ReleaseJNIEnv (int shallBeDetached) { } } -/* - * Class: jogamp_opengl_GLContextImpl - * Method: glGetStringInt - * Signature: (IJ)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_jogamp_opengl_GLContextImpl_glGetStringInt(JNIEnv *env, jclass _unused, jint name, jlong procAddress) { - typedef const khronos_uint8_t * (KHRONOS_APIENTRY*_local_PFNGLGETSTRINGPROC)(unsigned int name); - _local_PFNGLGETSTRINGPROC ptr_glGetString; - const khronos_uint8_t * _res; - ptr_glGetString = (_local_PFNGLGETSTRINGPROC) (intptr_t) procAddress; - assert(ptr_glGetString != NULL); - _res = (* ptr_glGetString) ((unsigned int) name); - if (NULL == _res) return NULL; - return (*env)->NewStringUTF(env, _res); -} - -/* - * Class: jogamp_opengl_GLContextImpl - * Method: glGetIntegervInt - * Signature: (ILjava/lang/Object;I)V - */ -JNIEXPORT void JNICALL -Java_jogamp_opengl_GLContextImpl_glGetIntegervInt(JNIEnv *env, jclass _unused, jint pname, jobject params, jint params_byte_offset, jlong procAddress) { - typedef void (KHRONOS_APIENTRY*_local_PFNGLGETINTEGERVPROC)(unsigned int pname, int * params); - - _local_PFNGLGETINTEGERVPROC ptr_glGetIntegerv; - int * _params_ptr = NULL; - if ( NULL != params ) { - _params_ptr = (int *) (((char*) (*env)->GetPrimitiveArrayCritical(env, params, NULL) ) + params_byte_offset); - } - ptr_glGetIntegerv = (_local_PFNGLGETINTEGERVPROC) (intptr_t) procAddress; - assert(ptr_glGetIntegerv != NULL); - (* ptr_glGetIntegerv) ((unsigned int) pname, (int *) _params_ptr); - if ( NULL != params ) { - (*env)->ReleasePrimitiveArrayCritical(env, params, _params_ptr, 0); - } -} - diff --git a/src/jogl/native/libav/ffmpeg_impl_template.c b/src/jogl/native/libav/ffmpeg_impl_template.c index 60cddef45..822007136 100644 --- a/src/jogl/native/libav/ffmpeg_impl_template.c +++ b/src/jogl/native/libav/ffmpeg_impl_template.c @@ -67,7 +67,6 @@ typedef int (APIENTRYP AVCODEC_CLOSE)(AVCodecContext *avctx); typedef void (APIENTRYP AVCODEC_STRING)(char *buf, int buf_size, AVCodecContext *enc, int encode); typedef AVCodec *(APIENTRYP AVCODEC_FIND_DECODER)(enum CodecID id); typedef int (APIENTRYP AVCODEC_OPEN2)(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options); // 53.6.0 -typedef int (APIENTRYP AVCODEC_OPEN)(AVCodecContext *avctx, AVCodec *codec); typedef AVFrame *(APIENTRYP AVCODEC_ALLOC_FRAME)(void); typedef void (APIENTRYP AVCODEC_GET_FRAME_DEFAULTS)(AVFrame *frame); typedef void (APIENTRYP AVCODEC_FREE_FRAME)(AVFrame **frame); @@ -79,7 +78,6 @@ typedef int (APIENTRYP AV_NEW_PACKET)(AVPacket *pkt, int size); typedef void (APIENTRYP AV_DESTRUCT_PACKET)(AVPacket *pkt); typedef void (APIENTRYP AV_FREE_PACKET)(AVPacket *pkt); typedef int (APIENTRYP AVCODEC_DECODE_AUDIO4)(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt); // 53.25.0 -typedef int (APIENTRYP AVCODEC_DECODE_AUDIO3)(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, AVPacket *avpkt); // 52.23.0 typedef int (APIENTRYP AVCODEC_DECODE_VIDEO2)(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt); // 52.23.0 static AVCODEC_REGISTER_ALL sp_avcodec_register_all; @@ -87,7 +85,6 @@ static AVCODEC_CLOSE sp_avcodec_close; static AVCODEC_STRING sp_avcodec_string; static AVCODEC_FIND_DECODER sp_avcodec_find_decoder; static AVCODEC_OPEN2 sp_avcodec_open2; // 53.6.0 -static AVCODEC_OPEN sp_avcodec_open; static AVCODEC_ALLOC_FRAME sp_avcodec_alloc_frame; static AVCODEC_GET_FRAME_DEFAULTS sp_avcodec_get_frame_defaults; static AVCODEC_FREE_FRAME sp_avcodec_free_frame; @@ -99,9 +96,8 @@ static AV_NEW_PACKET sp_av_new_packet; static AV_DESTRUCT_PACKET sp_av_destruct_packet; static AV_FREE_PACKET sp_av_free_packet; static AVCODEC_DECODE_AUDIO4 sp_avcodec_decode_audio4; // 53.25.0 -static AVCODEC_DECODE_AUDIO3 sp_avcodec_decode_audio3; // 52.23.0 static AVCODEC_DECODE_VIDEO2 sp_avcodec_decode_video2; // 52.23.0 -// count: 23 +// count: 21 // libavutil typedef void (APIENTRYP AV_FRAME_UNREF)(AVFrame *frame); @@ -111,6 +107,11 @@ typedef int (APIENTRYP AV_GET_BITS_PER_PIXEL)(const AVPixFmtDescriptor *pixdesc) typedef int (APIENTRYP AV_SAMPLES_GET_BUFFER_SIZE)(int *linesize, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align); typedef int (APIENTRYP AV_GET_BYTES_PER_SAMPLE)(enum AVSampleFormat sample_fmt); typedef int (APIENTRYP AV_OPT_SET_INT)(void *obj, const char *name, int64_t val, int search_flags); +typedef AVDictionaryEntry* (APIENTRYP AV_DICT_GET)(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); +typedef int (APIENTRYP AV_DICT_COUNT)(AVDictionary **m); +typedef int (APIENTRYP AV_DICT_SET)(AVDictionary **pm, const char *key, const char *value, int flags); +typedef void (APIENTRYP AV_DICT_FREE)(AVDictionary **m); + static const AVPixFmtDescriptor* sp_av_pix_fmt_descriptors; static AV_FRAME_UNREF sp_av_frame_unref; static AV_REALLOC sp_av_realloc; @@ -119,13 +120,16 @@ static AV_GET_BITS_PER_PIXEL sp_av_get_bits_per_pixel; static AV_SAMPLES_GET_BUFFER_SIZE sp_av_samples_get_buffer_size; static AV_GET_BYTES_PER_SAMPLE sp_av_get_bytes_per_sample; static AV_OPT_SET_INT sp_av_opt_set_int; -// count: 30 +static AV_DICT_GET sp_av_dict_get; +static AV_DICT_COUNT sp_av_dict_count; +static AV_DICT_SET sp_av_dict_set; +static AV_DICT_FREE sp_av_dict_free; +// count: 33 // libavformat typedef AVFormatContext *(APIENTRYP AVFORMAT_ALLOC_CONTEXT)(void); typedef void (APIENTRYP AVFORMAT_FREE_CONTEXT)(AVFormatContext *s); // 52.96.0 typedef void (APIENTRYP AVFORMAT_CLOSE_INPUT)(AVFormatContext **s); // 53.17.0 -typedef void (APIENTRYP AV_CLOSE_INPUT_FILE)(AVFormatContext *s); typedef void (APIENTRYP AV_REGISTER_ALL)(void); typedef AVInputFormat *(APIENTRYP AV_FIND_INPUT_FORMAT)(const char *short_name); typedef int (APIENTRYP AVFORMAT_OPEN_INPUT)(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options); @@ -138,12 +142,10 @@ typedef int (APIENTRYP AV_READ_PAUSE)(AVFormatContext *s); typedef int (APIENTRYP AVFORMAT_NETWORK_INIT)(void); // 53.13.0 typedef int (APIENTRYP AVFORMAT_NETWORK_DEINIT)(void); // 53.13.0 typedef int (APIENTRYP AVFORMAT_FIND_STREAM_INFO)(AVFormatContext *ic, AVDictionary **options); // 53.3.0 -typedef int (APIENTRYP AV_FIND_STREAM_INFO)(AVFormatContext *ic); static AVFORMAT_ALLOC_CONTEXT sp_avformat_alloc_context; -static AVFORMAT_FREE_CONTEXT sp_avformat_free_context; // 52.96.0 +static AVFORMAT_FREE_CONTEXT sp_avformat_free_context; // 52.96.0 (not used, only for outfile cts) static AVFORMAT_CLOSE_INPUT sp_avformat_close_input; // 53.17.0 -static AV_CLOSE_INPUT_FILE sp_av_close_input_file; static AV_REGISTER_ALL sp_av_register_all; static AV_FIND_INPUT_FORMAT sp_av_find_input_format; static AVFORMAT_OPEN_INPUT sp_avformat_open_input; @@ -156,8 +158,7 @@ static AV_READ_PAUSE sp_av_read_pause; static AVFORMAT_NETWORK_INIT sp_avformat_network_init; // 53.13.0 static AVFORMAT_NETWORK_DEINIT sp_avformat_network_deinit; // 53.13.0 static AVFORMAT_FIND_STREAM_INFO sp_avformat_find_stream_info; // 53.3.0 -static AV_FIND_STREAM_INFO sp_av_find_stream_info; -// count: 47 +// count: 48 // libavdevice [53.0.0] typedef int (APIENTRYP AVDEVICE_REGISTER_ALL)(void); @@ -201,14 +202,12 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) sp_avformat_version = (AVFORMAT_VERSION) (intptr_t) symbols[i++]; sp_avutil_version = (AVUTIL_VERSION) (intptr_t) symbols[i++]; sp_avresample_version = (AVRESAMPLE_VERSION) (intptr_t) symbols[i++]; - // count: 4 sp_avcodec_register_all = (AVCODEC_REGISTER_ALL) (intptr_t) symbols[i++]; sp_avcodec_close = (AVCODEC_CLOSE) (intptr_t) symbols[i++]; sp_avcodec_string = (AVCODEC_STRING) (intptr_t) symbols[i++]; sp_avcodec_find_decoder = (AVCODEC_FIND_DECODER) (intptr_t) symbols[i++]; sp_avcodec_open2 = (AVCODEC_OPEN2) (intptr_t) symbols[i++]; - sp_avcodec_open = (AVCODEC_OPEN) (intptr_t) symbols[i++]; sp_avcodec_alloc_frame = (AVCODEC_ALLOC_FRAME) (intptr_t) symbols[i++]; sp_avcodec_get_frame_defaults = (AVCODEC_GET_FRAME_DEFAULTS) (intptr_t) symbols[i++]; sp_avcodec_free_frame = (AVCODEC_FREE_FRAME) (intptr_t) symbols[i++]; @@ -220,9 +219,7 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) sp_av_destruct_packet = (AV_DESTRUCT_PACKET) (intptr_t) symbols[i++]; sp_av_free_packet = (AV_FREE_PACKET) (intptr_t) symbols[i++]; sp_avcodec_decode_audio4 = (AVCODEC_DECODE_AUDIO4) (intptr_t) symbols[i++]; - sp_avcodec_decode_audio3 = (AVCODEC_DECODE_AUDIO3) (intptr_t) symbols[i++]; sp_avcodec_decode_video2 = (AVCODEC_DECODE_VIDEO2) (intptr_t) symbols[i++]; - // count: 23 sp_av_pix_fmt_descriptors = (const AVPixFmtDescriptor*) (intptr_t) symbols[i++]; sp_av_frame_unref = (AV_FRAME_UNREF) (intptr_t) symbols[i++]; @@ -232,12 +229,14 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) sp_av_samples_get_buffer_size = (AV_SAMPLES_GET_BUFFER_SIZE) (intptr_t) symbols[i++]; sp_av_get_bytes_per_sample = (AV_GET_BYTES_PER_SAMPLE) (intptr_t) symbols[i++]; sp_av_opt_set_int = (AV_OPT_SET_INT) (intptr_t) symbols[i++]; - // count: 31 + sp_av_dict_get = (AV_DICT_GET) (intptr_t) symbols[i++]; + sp_av_dict_count = (AV_DICT_COUNT) (intptr_t) symbols[i++]; + sp_av_dict_set = (AV_DICT_SET) (intptr_t) symbols[i++]; + sp_av_dict_free = (AV_DICT_FREE) (intptr_t) symbols[i++]; sp_avformat_alloc_context = (AVFORMAT_ALLOC_CONTEXT) (intptr_t) symbols[i++];; sp_avformat_free_context = (AVFORMAT_FREE_CONTEXT) (intptr_t) symbols[i++]; sp_avformat_close_input = (AVFORMAT_CLOSE_INPUT) (intptr_t) symbols[i++]; - sp_av_close_input_file = (AV_CLOSE_INPUT_FILE) (intptr_t) symbols[i++]; sp_av_register_all = (AV_REGISTER_ALL) (intptr_t) symbols[i++]; sp_av_find_input_format = (AV_FIND_INPUT_FORMAT) (intptr_t) symbols[i++]; sp_avformat_open_input = (AVFORMAT_OPEN_INPUT) (intptr_t) symbols[i++]; @@ -250,18 +249,14 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) sp_avformat_network_init = (AVFORMAT_NETWORK_INIT) (intptr_t) symbols[i++]; sp_avformat_network_deinit = (AVFORMAT_NETWORK_DEINIT) (intptr_t) symbols[i++]; sp_avformat_find_stream_info = (AVFORMAT_FIND_STREAM_INFO) (intptr_t) symbols[i++]; - sp_av_find_stream_info = (AV_FIND_STREAM_INFO) (intptr_t) symbols[i++]; - // count: 48 sp_avdevice_register_all = (AVDEVICE_REGISTER_ALL) (intptr_t) symbols[i++]; - // count: 49 sp_avresample_alloc_context = (AVRESAMPLE_ALLOC_CONTEXT) (intptr_t) symbols[i++]; sp_avresample_open = (AVRESAMPLE_OPEN) (intptr_t) symbols[i++]; sp_avresample_close = (AVRESAMPLE_CLOSE) (intptr_t) symbols[i++]; sp_avresample_free = (AVRESAMPLE_FREE) (intptr_t) symbols[i++]; sp_avresample_convert = (AVRESAMPLE_CONVERT) (intptr_t) symbols[i++]; - // count: 54 (*env)->ReleasePrimitiveArrayCritical(env, jSymbols, symbols, 0); @@ -285,12 +280,12 @@ static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasic // JNIEnv * env = JoglCommon_GetJNIEnv (&shallBeDetached); if(NULL!=env) { (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_updateAttributes2, - pAV->vPixFmt, pAV->vBufferPlanes, + pAV->vid, pAV->vPixFmt, pAV->vBufferPlanes, pAV->vBitsPerPixel, pAV->vBytesPerPixelPerPlane, pAV->vLinesize[0], pAV->vLinesize[1], pAV->vLinesize[2], pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2], pAV->vWidth, pAV->vHeight, - pAV->aSampleFmtOut, pAV->aSampleRateOut, pAV->aChannelsOut, pAV->aFrameSize); + pAV->aid, pAV->aSampleFmtOut, pAV->aSampleRateOut, pAV->aChannelsOut, pAV->aFrameSize); (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_updateAttributes1, pAV->vid, pAV->aid, pAV->vWidth, pAV->vHeight, @@ -365,14 +360,9 @@ static void freeInstance(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { // Close the video file if(NULL != pAV->pFormatCtx) { - if(HAS_FUNC(sp_avformat_close_input)) { - sp_avformat_close_input(&pAV->pFormatCtx); - } else { - sp_av_close_input_file(pAV->pFormatCtx); - if(HAS_FUNC(sp_avformat_free_context)) { - sp_avformat_free_context(pAV->pFormatCtx); - } - } + sp_avformat_close_input(&pAV->pFormatCtx); + // Only for output files! + // sp_avformat_free_context(pAV->pFormatCtx); pAV->pFormatCtx = NULL; } if( NULL != pAV->ffmpegMediaPlayer ) { @@ -462,7 +452,7 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initIDs0) jni_mid_pushSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "pushSound", "(Ljava/nio/ByteBuffer;II)V"); jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIIIFIIILjava/lang/String;Ljava/lang/String;)V"); - jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIIIII)V"); + jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIIIIIII)V"); jni_mid_isAudioFormatSupported = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "isAudioFormatSupported", "(III)Z"); if(jni_mid_pushSound == NULL || @@ -548,10 +538,10 @@ static AVInputFormat* tryAVInputFormat(const char * name, int verbose) { return inFmt; } static const char * inFmtNames[] = { - "video4linux2", - "video4linux", - "vfwcap", - "dshow", + "video4linux2", // linux + "video4linux", // linux (old) + "dshow", // windows + "vfwcap", // windows (old) "mpg", "yuv2", "mjpeg", @@ -601,30 +591,41 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->pFormatCtx = sp_avformat_alloc_context(); - // Open video file - AVInputFormat* inFmt = jIsCameraInput ? findAVInputFormat(pAV->verbose) : NULL; - const char *urlPath = (*env)->GetStringUTFChars(env, jURL, &iscopy); - res = sp_avformat_open_input(&pAV->pFormatCtx, urlPath, inFmt, NULL); + + // Open video file + AVDictionary *inOpts = NULL; + AVInputFormat* inFmt = NULL; + if( jIsCameraInput ) { + inFmt = findAVInputFormat(pAV->verbose); + if( NULL == inFmt ) { + JoglCommon_throwNewRuntimeException(env, "Couldn't find input format for camera: %s", urlPath); + (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); + return; + } + // set maximum values, driver shall 'degrade' .. + // sp_av_dict_set(&inOpts, "video_size", "640x480", 0); + // sp_av_dict_set(&inOpts, "video_size", "1280x720", 0); + sp_av_dict_set(&inOpts, "video_size", "hd720", 0); // video4linux, vfwcap, .. + // sp_av_dict_set(&inOpts, "video_size", "1280x1024", 0); + // sp_av_dict_set(&inOpts, "video_size", "320x240", 0); + sp_av_dict_set(&inOpts, "framerate", "60", 0); // not setting a framerate causes some drivers to crash! + } + res = sp_avformat_open_input(&pAV->pFormatCtx, urlPath, inFmt, NULL != inOpts ? &inOpts : NULL); + if( NULL != inOpts ) { + sp_av_dict_free(&inOpts); + } if(res != 0) { - JoglCommon_throwNewRuntimeException(env, "Couldn't open URI: %s", urlPath); + JoglCommon_throwNewRuntimeException(env, "Couldn't open URI: %s, err %d", urlPath, res); (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); return; } // Retrieve detailed stream information - if(HAS_FUNC(sp_avformat_find_stream_info)) { - if(sp_avformat_find_stream_info(pAV->pFormatCtx, NULL)<0) { - (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); - JoglCommon_throwNewRuntimeException(env, "Couldn't find stream information"); - return; - } - } else { - if(sp_av_find_stream_info(pAV->pFormatCtx)<0) { - (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); - JoglCommon_throwNewRuntimeException(env, "Couldn't find stream information"); - return; - } + if(sp_avformat_find_stream_info(pAV->pFormatCtx, NULL)<0) { + (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); + JoglCommon_throwNewRuntimeException(env, "Couldn't find stream information"); + return; } if(pAV->verbose) { @@ -725,11 +726,7 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) #if LIBAVCODEC_VERSION_MAJOR >= 55 pAV->pACodecCtx->refcounted_frames = pAV->useRefCountedFrames; #endif - if(HAS_FUNC(sp_avcodec_open2)) { - res = sp_avcodec_open2(pAV->pACodecCtx, pAV->pACodec, NULL); - } else { - res = sp_avcodec_open(pAV->pACodecCtx, pAV->pACodec); - } + res = sp_avcodec_open2(pAV->pACodecCtx, pAV->pACodec, NULL); if(res<0) { JoglCommon_throwNewRuntimeException(env, "Couldn't open audio codec %d, %s", pAV->pACodecCtx->codec_id, pAV->acodec); return; @@ -858,11 +855,7 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) #if LIBAVCODEC_VERSION_MAJOR >= 55 pAV->pVCodecCtx->refcounted_frames = pAV->useRefCountedFrames; #endif - if(HAS_FUNC(sp_avcodec_open2)) { - res = sp_avcodec_open2(pAV->pVCodecCtx, pAV->pVCodec, NULL); - } else { - res = sp_avcodec_open(pAV->pVCodecCtx, pAV->pVCodec); - } + res = sp_avcodec_open2(pAV->pVCodecCtx, pAV->pVCodec, NULL); if(res<0) { JoglCommon_throwNewRuntimeException(env, "Couldn't open video codec %d, %s", pAV->pVCodecCtx->codec_id, pAV->vcodec); return; @@ -953,10 +946,10 @@ JNIEXPORT void JNICALL FF_FUNC(setGLFuncs0) } #if 0 -#define DBG_TEXSUBIMG2D_a(c,p,d,i) fprintf(stderr, "TexSubImage2D.%c offset %d / %d, size %d x %d, ", c, p->pVCodecCtx->width, p->pVCodecCtx->height/d, p->vTexWidth[i], p->pVCodecCtx->height/d) +#define DBG_TEXSUBIMG2D_a(c,p,w1,w2,h,i) fprintf(stderr, "TexSubImage2D.%c offset %d / %d, size %d x %d, ", c, (w1*p->pVCodecCtx->width)/w2, p->pVCodecCtx->height/h, p->vTexWidth[i], p->pVCodecCtx->height/h) #define DBG_TEXSUBIMG2D_b(p) fprintf(stderr, "err 0x%X\n", pAV->procAddrGLGetError()) #else -#define DBG_TEXSUBIMG2D_a(c,p,d,i) +#define DBG_TEXSUBIMG2D_a(c,p,w1,w2,h,i) #define DBG_TEXSUBIMG2D_b(p) #endif @@ -1005,15 +998,7 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) if (flush_complete) { break; } - if(HAS_FUNC(sp_avcodec_decode_audio4)) { - len1 = sp_avcodec_decode_audio4(pAV->pACodecCtx, pAFrameCurrent, &frameDecoded, &packet); - } else { - #if 0 - len1 = sp_avcodec_decode_audio3(pAV->pACodecCtx, int16_t *samples, int *frame_size_ptr, &frameDecoded, &packet); - #endif - JoglCommon_throwNewRuntimeException(env, "Unimplemented: FFMPEGNatives sp_avcodec_decode_audio3 fallback"); - return 0; - } + len1 = sp_avcodec_decode_audio4(pAV->pACodecCtx, pAFrameCurrent, &frameDecoded, &packet); if (len1 < 0) { // if error, we skip the frame packet.size = 0; @@ -1179,17 +1164,17 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) // 1st plane or complete packed frame // FIXME: Libav Binary compatibility! JAU01 - DBG_TEXSUBIMG2D_a('Y',pAV,1,0); + DBG_TEXSUBIMG2D_a('Y',pAV,1,1,1,0); pAV->procAddrGLTexSubImage2D(texTarget, 0, 0, 0, pAV->vTexWidth[0], pAV->pVCodecCtx->height, texFmt, texType, pAV->pVFrame->data[0]); DBG_TEXSUBIMG2D_b(pAV); - if(pAV->vPixFmt == PIX_FMT_YUV420P) { + if( pAV->vPixFmt == PIX_FMT_YUV420P || pAV->vPixFmt == PIX_FMT_YUVJ420P ) { // U plane // FIXME: Libav Binary compatibility! JAU01 - DBG_TEXSUBIMG2D_a('U',pAV,2,1); + DBG_TEXSUBIMG2D_a('U',pAV,1,1,2,1); pAV->procAddrGLTexSubImage2D(texTarget, 0, pAV->pVCodecCtx->width, 0, pAV->vTexWidth[1], pAV->pVCodecCtx->height/2, @@ -1197,12 +1182,29 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) DBG_TEXSUBIMG2D_b(pAV); // V plane // FIXME: Libav Binary compatibility! JAU01 - DBG_TEXSUBIMG2D_a('V',pAV,2,2); + DBG_TEXSUBIMG2D_a('V',pAV,1,1,2,2); pAV->procAddrGLTexSubImage2D(texTarget, 0, pAV->pVCodecCtx->width, pAV->pVCodecCtx->height/2, pAV->vTexWidth[2], pAV->pVCodecCtx->height/2, texFmt, texType, pAV->pVFrame->data[2]); DBG_TEXSUBIMG2D_b(pAV); + } else if( pAV->vPixFmt == PIX_FMT_YUV422P || pAV->vPixFmt == PIX_FMT_YUVJ422P ) { + // U plane + // FIXME: Libav Binary compatibility! JAU01 + DBG_TEXSUBIMG2D_a('U',pAV,1,1,1,1); + pAV->procAddrGLTexSubImage2D(texTarget, 0, + pAV->pVCodecCtx->width, 0, + pAV->vTexWidth[1], pAV->pVCodecCtx->height, + texFmt, texType, pAV->pVFrame->data[1]); + DBG_TEXSUBIMG2D_b(pAV); + // V plane + // FIXME: Libav Binary compatibility! JAU01 + DBG_TEXSUBIMG2D_a('V',pAV,3,2,1,1); + pAV->procAddrGLTexSubImage2D(texTarget, 0, + pAV->pVCodecCtx->width+pAV->pVCodecCtx->width/2, 0, + pAV->vTexWidth[2], pAV->pVCodecCtx->height, + texFmt, texType, pAV->pVFrame->data[2]); + DBG_TEXSUBIMG2D_b(pAV); } // FIXME: Add more planar formats ! pAV->procAddrGLFinish(); //pAV->procAddrGLFlush(); -- cgit v1.2.3 From eca6a5cb1e2beda84dfbafc31ed225e272f4f3fb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 29 Aug 2013 22:46:57 +0200 Subject: Enhance GLMediaPlayer: Full FFMPeg support, 'dshow' camera support on windows, 2 more pixel formats, fail-safe data handling - add support for ffmpeg 2 / libav 10 -> lavc55_lavf55_lavu52_lavr01 - add support for ffmpeg libswresample (similar to libavresample) - handle BGRA (GL type) and BGR24 (texture shader) - Change Camera URI semantics, drop 'host' and use 'path' for camera ID and use 'query' for options. - add support for Window's DShow camera selection - our camera id -> index of list of video-input devices, this gives us same behavior as w/ Linux - requires windows libs: strmiids, uuid, ole32, oleaut32 - Compiles w/ MingW64, works w/ libav/ffmpeg - TODO: test compilation w/ MingW 32bit ! - don't push data to texture if (linesize <= 0) this may happen due to buggy decoder / setup .. Tested manually on GNU/Linux x64 and Windows x64: - GNU/Linux libav 0.8, libav 9, libav 10, ffmpeg 1.2, ffmpeg 2.0 - Windows libav 0.8, libav 9, ffmpeg 2.0 - videos and camera --- make/build-jogl.xml | 22 +- make/scripts/make.jogl.all.linux-x86_64.sh | 1 - make/scripts/tests-x64-dbg.bat | 5 +- make/scripts/tests-x64.bat | 5 +- make/scripts/tests-x64.sh | 9 +- make/scripts/tests.sh | 4 +- .../libswresample/swresample.h | 311 ++ .../libswresample/version.h | 45 + .../libavcodec/avcodec.h | 4277 ++++++++++++++++++++ .../lavc55_lavf55_lavu52_lavr01/libavcodec/avfft.h | 116 + .../lavc55_lavf55_lavu52_lavr01/libavcodec/dxva2.h | 88 + .../lavc55_lavf55_lavu52_lavr01/libavcodec/vaapi.h | 173 + .../lavc55_lavf55_lavu52_lavr01/libavcodec/vda.h | 142 + .../lavc55_lavf55_lavu52_lavr01/libavcodec/vdpau.h | 160 + .../libavcodec/version.h | 77 + .../lavc55_lavf55_lavu52_lavr01/libavcodec/xvmc.h | 168 + .../libavformat/avformat.h | 1708 ++++++++ .../lavc55_lavf55_lavu52_lavr01/libavformat/avio.h | 433 ++ .../libavformat/version.h | 52 + .../libavresample/avresample.h | 409 ++ .../libavresample/version.h | 52 + .../libavutil/adler32.h | 43 + .../lavc55_lavf55_lavu52_lavr01/libavutil/aes.h | 67 + .../libavutil/attributes.h | 122 + .../libavutil/audio_fifo.h | 146 + .../libavutil/audioconvert.h | 6 + .../libavutil/avassert.h | 66 + .../libavutil/avconfig.h | 6 + .../libavutil/avstring.h | 226 ++ .../lavc55_lavf55_lavu52_lavr01/libavutil/avutil.h | 308 ++ .../lavc55_lavf55_lavu52_lavr01/libavutil/base64.h | 65 + .../libavutil/blowfish.h | 76 + .../lavc55_lavf55_lavu52_lavr01/libavutil/bswap.h | 109 + .../lavc55_lavf55_lavu52_lavr01/libavutil/buffer.h | 267 ++ .../libavutil/channel_layout.h | 182 + .../lavc55_lavf55_lavu52_lavr01/libavutil/common.h | 405 ++ .../lavc55_lavf55_lavu52_lavr01/libavutil/cpu.h | 84 + .../lavc55_lavf55_lavu52_lavr01/libavutil/crc.h | 74 + .../lavc55_lavf55_lavu52_lavr01/libavutil/dict.h | 146 + .../lavc55_lavf55_lavu52_lavr01/libavutil/error.h | 83 + .../lavc55_lavf55_lavu52_lavr01/libavutil/eval.h | 113 + .../lavc55_lavf55_lavu52_lavr01/libavutil/fifo.h | 131 + .../lavc55_lavf55_lavu52_lavr01/libavutil/file.h | 54 + .../lavc55_lavf55_lavu52_lavr01/libavutil/frame.h | 491 +++ .../lavc55_lavf55_lavu52_lavr01/libavutil/hmac.h | 95 + .../libavutil/imgutils.h | 138 + .../libavutil/intfloat.h | 77 + .../libavutil/intfloat_readwrite.h | 40 + .../libavutil/intreadwrite.h | 549 +++ .../lavc55_lavf55_lavu52_lavr01/libavutil/lfg.h | 62 + .../lavc55_lavf55_lavu52_lavr01/libavutil/log.h | 173 + .../lavc55_lavf55_lavu52_lavr01/libavutil/lzo.h | 66 + .../libavutil/mathematics.h | 111 + .../lavc55_lavf55_lavu52_lavr01/libavutil/md5.h | 51 + .../lavc55_lavf55_lavu52_lavr01/libavutil/mem.h | 209 + .../libavutil/old_pix_fmts.h | 132 + .../lavc55_lavf55_lavu52_lavr01/libavutil/opt.h | 516 +++ .../libavutil/parseutils.h | 124 + .../libavutil/pixdesc.h | 276 ++ .../lavc55_lavf55_lavu52_lavr01/libavutil/pixfmt.h | 277 ++ .../libavutil/random_seed.h | 44 + .../libavutil/rational.h | 155 + .../libavutil/samplefmt.h | 220 + .../lavc55_lavf55_lavu52_lavr01/libavutil/sha.h | 76 + .../lavc55_lavf55_lavu52_lavr01/libavutil/time.h | 39 + .../libavutil/version.h | 96 + .../lavc55_lavf55_lavu52_lavr01/libavutil/xtea.h | 61 + .../libswresample/swresample.h | 311 ++ .../libswresample/version.h | 45 + .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 24 +- .../android/av/AndroidGLMediaPlayerAPI14.java | 4 +- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 45 +- .../av/impl/FFMPEGDynamicLibraryBundleInfo.java | 231 +- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 105 +- .../jogamp/opengl/util/av/impl/FFMPEGNatives.java | 19 +- .../opengl/util/av/impl/FFMPEGStaticNatives.java | 5 +- .../opengl/util/av/impl/FFMPEGv08Natives.java | 5 +- .../opengl/util/av/impl/FFMPEGv09Natives.java | 5 +- .../opengl/util/av/impl/FFMPEGv10Natives.java | 81 + src/jogl/native/libav/ffmpeg_dshow.c | 209 + src/jogl/native/libav/ffmpeg_dshow.h | 47 + src/jogl/native/libav/ffmpeg_impl_template.c | 416 +- .../libav/ffmpeg_lavc55_lavf55_lavu52_lavr01.c | 33 + src/jogl/native/libav/ffmpeg_static.c | 32 +- src/jogl/native/libav/ffmpeg_tool.h | 37 +- 85 files changed, 16459 insertions(+), 309 deletions(-) create mode 100644 make/stub_includes/libav/lavc54_lavf54_lavu52_lavr01/libswresample/swresample.h create mode 100644 make/stub_includes/libav/lavc54_lavf54_lavu52_lavr01/libswresample/version.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/avcodec.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/avfft.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/dxva2.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vaapi.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vda.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vdpau.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/version.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/xvmc.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/avformat.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/avio.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/version.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavresample/avresample.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavresample/version.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/adler32.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/aes.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/attributes.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/audio_fifo.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/audioconvert.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avassert.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avconfig.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avstring.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avutil.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/base64.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/blowfish.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/bswap.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/buffer.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/channel_layout.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/common.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/cpu.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/crc.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/dict.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/error.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/eval.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/fifo.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/file.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/frame.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/hmac.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/imgutils.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intfloat.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intfloat_readwrite.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intreadwrite.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/lfg.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/log.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/lzo.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/mathematics.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/md5.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/mem.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/old_pix_fmts.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/opt.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/parseutils.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/pixdesc.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/pixfmt.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/random_seed.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/rational.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/samplefmt.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/sha.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/time.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/version.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/xtea.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libswresample/swresample.h create mode 100644 make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libswresample/version.h create mode 100644 src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java create mode 100644 src/jogl/native/libav/ffmpeg_dshow.c create mode 100644 src/jogl/native/libav/ffmpeg_dshow.h create mode 100644 src/jogl/native/libav/ffmpeg_lavc55_lavf55_lavu52_lavr01.c (limited to 'make/scripts') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 582e8b654..5a461359a 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1225,12 +1225,12 @@ - + - + @@ -1425,6 +1425,7 @@ + @@ -1469,6 +1470,9 @@ + + + @@ -1492,6 +1496,7 @@ + @@ -1507,6 +1512,7 @@ + @@ -1525,6 +1531,7 @@ + @@ -1548,7 +1555,7 @@ - + @@ -1629,9 +1636,7 @@ - - - + @@ -1646,6 +1651,11 @@ output.lib.name="jogl_ffmpegv09" compiler.cfg.id="${compiler.cfg.id}" linker.cfg.id="${linker.cfg.id.os}"/> + + diff --git a/make/scripts/make.jogl.all.linux-x86_64.sh b/make/scripts/make.jogl.all.linux-x86_64.sh index f59d6eabb..2488a7d4c 100755 --- a/make/scripts/make.jogl.all.linux-x86_64.sh +++ b/make/scripts/make.jogl.all.linux-x86_64.sh @@ -54,7 +54,6 @@ export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" # BUILD_ARCHIVE=true \ ant \ - -Dc.compiler.debug=true \ $CUSTOMLIBDIR \ -Drootrel.build=build-x86_64 \ $* 2>&1 | tee -a $LOGF diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index fb2a94e95..986aba8ec 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -7,8 +7,9 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl set BLD_DIR=..\%BLD_SUB% -set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01\x64 -REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51\x64 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x64 +set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x64 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01-libav\x64 REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 7ed47f635..38ba28fa0 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -4,8 +4,9 @@ set J2RE_HOME=c:\jre1.7.0_25_x64 set JAVA_HOME=c:\jdk1.7.0_25_x64 set ANT_PATH=C:\apache-ant-1.8.2 -set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01\x64 -REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51\x64 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x64 +set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x64 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01-libav\x64 REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% diff --git a/make/scripts/tests-x64.sh b/make/scripts/tests-x64.sh index 7370d06aa..68937ca4b 100755 --- a/make/scripts/tests-x64.sh +++ b/make/scripts/tests-x64.sh @@ -2,8 +2,13 @@ SDIR=`dirname $0` -#export LD_LIBRARY_PATH=/home/sven/libav/lib:$LD_LIBRARY_PATH -#export LD_LIBRARY_PATH=/home/sven/libav-0.X/lib:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/home/sven/libav-0.8/lib:$LD_LIBRARY_PATH + +#export LD_LIBRARY_PATH=/home/sven/libav-9.x/lib:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/home/sven/ffmpeg-1.2/lib:$LD_LIBRARY_PATH + +#export LD_LIBRARY_PATH=/home/sven/libav-10.x/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=/home/sven/ffmpeg-2.x/lib:$LD_LIBRARY_PATH if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index aa17c2163..493fa2744 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -132,8 +132,8 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" - #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native -Djogl.debug.GLSLCode" - D_ARGS="-Djogl.debug.GLMediaPlayer" + D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.AudioSink" diff --git a/make/stub_includes/libav/lavc54_lavf54_lavu52_lavr01/libswresample/swresample.h b/make/stub_includes/libav/lavc54_lavf54_lavu52_lavr01/libswresample/swresample.h new file mode 100644 index 000000000..95e8a5a09 --- /dev/null +++ b/make/stub_includes/libav/lavc54_lavf54_lavu52_lavr01/libswresample/swresample.h @@ -0,0 +1,311 @@ +/* + * Copyright (C) 2011-2013 Michael Niedermayer (michaelni@gmx.at) + * + * This file is part of libswresample + * + * libswresample is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libswresample is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libswresample; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SWRESAMPLE_SWRESAMPLE_H +#define SWRESAMPLE_SWRESAMPLE_H + +/** + * @file + * @ingroup lswr + * libswresample public header + */ + +/** + * @defgroup lswr Libswresample + * @{ + * + * Libswresample (lswr) is a library that handles audio resampling, sample + * format conversion and mixing. + * + * Interaction with lswr is done through SwrContext, which is + * allocated with swr_alloc() or swr_alloc_set_opts(). It is opaque, so all parameters + * must be set with the @ref avoptions API. + * + * For example the following code will setup conversion from planar float sample + * format to interleaved signed 16-bit integer, downsampling from 48kHz to + * 44.1kHz and downmixing from 5.1 channels to stereo (using the default mixing + * matrix): + * @code + * SwrContext *swr = swr_alloc(); + * av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0); + * av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0); + * av_opt_set_int(swr, "in_sample_rate", 48000, 0); + * av_opt_set_int(swr, "out_sample_rate", 44100, 0); + * av_opt_set_sample_fmt(swr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); + * av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); + * @endcode + * + * Once all values have been set, it must be initialized with swr_init(). If + * you need to change the conversion parameters, you can change the parameters + * as described above, or by using swr_alloc_set_opts(), then call swr_init() + * again. + * + * The conversion itself is done by repeatedly calling swr_convert(). + * Note that the samples may get buffered in swr if you provide insufficient + * output space or if sample rate conversion is done, which requires "future" + * samples. Samples that do not require future input can be retrieved at any + * time by using swr_convert() (in_count can be set to 0). + * At the end of conversion the resampling buffer can be flushed by calling + * swr_convert() with NULL in and 0 in_count. + * + * The delay between input and output, can at any time be found by using + * swr_get_delay(). + * + * The following code demonstrates the conversion loop assuming the parameters + * from above and caller-defined functions get_input() and handle_output(): + * @code + * uint8_t **input; + * int in_samples; + * + * while (get_input(&input, &in_samples)) { + * uint8_t *output; + * int out_samples = av_rescale_rnd(swr_get_delay(swr, 48000) + + * in_samples, 44100, 48000, AV_ROUND_UP); + * av_samples_alloc(&output, NULL, 2, out_samples, + * AV_SAMPLE_FMT_S16, 0); + * out_samples = swr_convert(swr, &output, out_samples, + * input, in_samples); + * handle_output(output, out_samples); + * av_freep(&output); + * } + * @endcode + * + * When the conversion is finished, the conversion + * context and everything associated with it must be freed with swr_free(). + * There will be no memory leak if the data is not completely flushed before + * swr_free(). + */ + +#include +#include "libavutil/samplefmt.h" + +#include "libswresample/version.h" + +#if LIBSWRESAMPLE_VERSION_MAJOR < 1 +#define SWR_CH_MAX 32 ///< Maximum number of channels +#endif + +#define SWR_FLAG_RESAMPLE 1 ///< Force resampling even if equal sample rate +//TODO use int resample ? +//long term TODO can we enable this dynamically? + +enum SwrDitherType { + SWR_DITHER_NONE = 0, + SWR_DITHER_RECTANGULAR, + SWR_DITHER_TRIANGULAR, + SWR_DITHER_TRIANGULAR_HIGHPASS, + + SWR_DITHER_NS = 64, ///< not part of API/ABI + SWR_DITHER_NS_LIPSHITZ, + SWR_DITHER_NS_F_WEIGHTED, + SWR_DITHER_NS_MODIFIED_E_WEIGHTED, + SWR_DITHER_NS_IMPROVED_E_WEIGHTED, + SWR_DITHER_NS_SHIBATA, + SWR_DITHER_NS_LOW_SHIBATA, + SWR_DITHER_NS_HIGH_SHIBATA, + SWR_DITHER_NB, ///< not part of API/ABI +}; + +/** Resampling Engines */ +enum SwrEngine { + SWR_ENGINE_SWR, /**< SW Resampler */ + SWR_ENGINE_SOXR, /**< SoX Resampler */ + SWR_ENGINE_NB, ///< not part of API/ABI +}; + +/** Resampling Filter Types */ +enum SwrFilterType { + SWR_FILTER_TYPE_CUBIC, /**< Cubic */ + SWR_FILTER_TYPE_BLACKMAN_NUTTALL, /**< Blackman Nuttall Windowed Sinc */ + SWR_FILTER_TYPE_KAISER, /**< Kaiser Windowed Sinc */ +}; + +typedef struct SwrContext SwrContext; + +/** + * Get the AVClass for swrContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *swr_get_class(void); + +/** + * Allocate SwrContext. + * + * If you use this function you will need to set the parameters (manually or + * with swr_alloc_set_opts()) before calling swr_init(). + * + * @see swr_alloc_set_opts(), swr_init(), swr_free() + * @return NULL on error, allocated context otherwise + */ +struct SwrContext *swr_alloc(void); + +/** + * Initialize context after user parameters have been set. + * + * @return AVERROR error code in case of failure. + */ +int swr_init(struct SwrContext *s); + +/** + * Allocate SwrContext if needed and set/reset common parameters. + * + * This function does not require s to be allocated with swr_alloc(). On the + * other hand, swr_alloc() can use swr_alloc_set_opts() to set the parameters + * on the allocated context. + * + * @param s Swr context, can be NULL + * @param out_ch_layout output channel layout (AV_CH_LAYOUT_*) + * @param out_sample_fmt output sample format (AV_SAMPLE_FMT_*). + * @param out_sample_rate output sample rate (frequency in Hz) + * @param in_ch_layout input channel layout (AV_CH_LAYOUT_*) + * @param in_sample_fmt input sample format (AV_SAMPLE_FMT_*). + * @param in_sample_rate input sample rate (frequency in Hz) + * @param log_offset logging level offset + * @param log_ctx parent logging context, can be NULL + * + * @see swr_init(), swr_free() + * @return NULL on error, allocated context otherwise + */ +struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, + int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, + int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, + int log_offset, void *log_ctx); + +/** + * Free the given SwrContext and set the pointer to NULL. + */ +void swr_free(struct SwrContext **s); + +/** + * Convert audio. + * + * in and in_count can be set to 0 to flush the last few samples out at the + * end. + * + * If more input is provided than output space then the input will be buffered. + * You can avoid this buffering by providing more output space than input. + * Convertion will run directly without copying whenever possible. + * + * @param s allocated Swr context, with parameters set + * @param out output buffers, only the first one need be set in case of packed audio + * @param out_count amount of space available for output in samples per channel + * @param in input buffers, only the first one need to be set in case of packed audio + * @param in_count number of input samples available in one channel + * + * @return number of samples output per channel, negative value on error + */ +int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, + const uint8_t **in , int in_count); + +/** + * Convert the next timestamp from input to output + * timestamps are in 1/(in_sample_rate * out_sample_rate) units. + * + * @note There are 2 slightly differently behaving modes. + * First is when automatic timestamp compensation is not used, (min_compensation >= FLT_MAX) + * in this case timestamps will be passed through with delays compensated + * Second is when automatic timestamp compensation is used, (min_compensation < FLT_MAX) + * in this case the output timestamps will match output sample numbers + * + * @param pts timestamp for the next input sample, INT64_MIN if unknown + * @return the output timestamp for the next output sample + */ +int64_t swr_next_pts(struct SwrContext *s, int64_t pts); + +/** + * Activate resampling compensation. + */ +int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance); + +/** + * Set a customized input channel mapping. + * + * @param s allocated Swr context, not yet initialized + * @param channel_map customized input channel mapping (array of channel + * indexes, -1 for a muted channel) + * @return AVERROR error code in case of failure. + */ +int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map); + +/** + * Set a customized remix matrix. + * + * @param s allocated Swr context, not yet initialized + * @param matrix remix coefficients; matrix[i + stride * o] is + * the weight of input channel i in output channel o + * @param stride offset between lines of the matrix + * @return AVERROR error code in case of failure. + */ +int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride); + +/** + * Drops the specified number of output samples. + */ +int swr_drop_output(struct SwrContext *s, int count); + +/** + * Injects the specified number of silence samples. + */ +int swr_inject_silence(struct SwrContext *s, int count); + +/** + * Gets the delay the next input sample will experience relative to the next output sample. + * + * Swresample can buffer data if more input has been provided than available + * output space, also converting between sample rates needs a delay. + * This function returns the sum of all such delays. + * The exact delay is not necessarily an integer value in either input or + * output sample rate. Especially when downsampling by a large value, the + * output sample rate may be a poor choice to represent the delay, similarly + * for upsampling and the input sample rate. + * + * @param s swr context + * @param base timebase in which the returned delay will be + * if its set to 1 the returned delay is in seconds + * if its set to 1000 the returned delay is in milli seconds + * if its set to the input sample rate then the returned delay is in input samples + * if its set to the output sample rate then the returned delay is in output samples + * an exact rounding free delay can be found by using LCM(in_sample_rate, out_sample_rate) + * @returns the delay in 1/base units. + */ +int64_t swr_get_delay(struct SwrContext *s, int64_t base); + +/** + * Return the LIBSWRESAMPLE_VERSION_INT constant. + */ +unsigned swresample_version(void); + +/** + * Return the swr build-time configuration. + */ +const char *swresample_configuration(void); + +/** + * Return the swr license. + */ +const char *swresample_license(void); + +/** + * @} + */ + +#endif /* SWRESAMPLE_SWRESAMPLE_H */ diff --git a/make/stub_includes/libav/lavc54_lavf54_lavu52_lavr01/libswresample/version.h b/make/stub_includes/libav/lavc54_lavf54_lavu52_lavr01/libswresample/version.h new file mode 100644 index 000000000..df9df480c --- /dev/null +++ b/make/stub_includes/libav/lavc54_lavf54_lavu52_lavr01/libswresample/version.h @@ -0,0 +1,45 @@ +/* + * Version macros. + * + * This file is part of libswresample + * + * libswresample is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libswresample is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libswresample; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SWR_VERSION_H +#define SWR_VERSION_H + +/** + * @file + * Libswresample version macros + */ + +#include "libavutil/avutil.h" + +#define LIBSWRESAMPLE_VERSION_MAJOR 0 +#define LIBSWRESAMPLE_VERSION_MINOR 17 +#define LIBSWRESAMPLE_VERSION_MICRO 102 + +#define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ + LIBSWRESAMPLE_VERSION_MINOR, \ + LIBSWRESAMPLE_VERSION_MICRO) +#define LIBSWRESAMPLE_VERSION AV_VERSION(LIBSWRESAMPLE_VERSION_MAJOR, \ + LIBSWRESAMPLE_VERSION_MINOR, \ + LIBSWRESAMPLE_VERSION_MICRO) +#define LIBSWRESAMPLE_BUILD LIBSWRESAMPLE_VERSION_INT + +#define LIBSWRESAMPLE_IDENT "SwR" AV_STRINGIFY(LIBSWRESAMPLE_VERSION) + +#endif /* SWR_VERSION_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/avcodec.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/avcodec.h new file mode 100644 index 000000000..caf828496 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/avcodec.h @@ -0,0 +1,4277 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AVCODEC_H +#define AVCODEC_AVCODEC_H + +/** + * @file + * @ingroup libavc + * Libavcodec external API header + */ + +#include +#include "libavutil/samplefmt.h" +#include "libavutil/attributes.h" +#include "libavutil/avutil.h" +#include "libavutil/buffer.h" +#include "libavutil/cpu.h" +#include "libavutil/dict.h" +#include "libavutil/frame.h" +#include "libavutil/log.h" +#include "libavutil/pixfmt.h" +#include "libavutil/rational.h" + +#include "libavcodec/version.h" +/** + * @defgroup libavc Encoding/Decoding Library + * @{ + * + * @defgroup lavc_decoding Decoding + * @{ + * @} + * + * @defgroup lavc_encoding Encoding + * @{ + * @} + * + * @defgroup lavc_codec Codecs + * @{ + * @defgroup lavc_codec_native Native Codecs + * @{ + * @} + * @defgroup lavc_codec_wrappers External library wrappers + * @{ + * @} + * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge + * @{ + * @} + * @} + * @defgroup lavc_internal Internal + * @{ + * @} + * @} + * + */ + +/** + * @defgroup lavc_core Core functions/structures. + * @ingroup libavc + * + * Basic definitions, functions for querying libavcodec capabilities, + * allocating core structures, etc. + * @{ + */ + + +/** + * Identify the syntax and semantics of the bitstream. + * The principle is roughly: + * Two decoders with the same ID can decode the same streams. + * Two encoders with the same ID can encode compatible streams. + * There may be slight deviations from the principle due to implementation + * details. + * + * If you add a codec ID to this list, add it so that + * 1. no value of a existing codec ID changes (that would break ABI), + * 2. it is as close as possible to similar codecs. + * + * After adding new codec IDs, do not forget to add an entry to the codec + * descriptor list and bump libavcodec minor version. + */ +enum AVCodecID { + AV_CODEC_ID_NONE, + + /* video codecs */ + AV_CODEC_ID_MPEG1VIDEO, + AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding + AV_CODEC_ID_MPEG2VIDEO_XVMC, + AV_CODEC_ID_H261, + AV_CODEC_ID_H263, + AV_CODEC_ID_RV10, + AV_CODEC_ID_RV20, + AV_CODEC_ID_MJPEG, + AV_CODEC_ID_MJPEGB, + AV_CODEC_ID_LJPEG, + AV_CODEC_ID_SP5X, + AV_CODEC_ID_JPEGLS, + AV_CODEC_ID_MPEG4, + AV_CODEC_ID_RAWVIDEO, + AV_CODEC_ID_MSMPEG4V1, + AV_CODEC_ID_MSMPEG4V2, + AV_CODEC_ID_MSMPEG4V3, + AV_CODEC_ID_WMV1, + AV_CODEC_ID_WMV2, + AV_CODEC_ID_H263P, + AV_CODEC_ID_H263I, + AV_CODEC_ID_FLV1, + AV_CODEC_ID_SVQ1, + AV_CODEC_ID_SVQ3, + AV_CODEC_ID_DVVIDEO, + AV_CODEC_ID_HUFFYUV, + AV_CODEC_ID_CYUV, + AV_CODEC_ID_H264, + AV_CODEC_ID_INDEO3, + AV_CODEC_ID_VP3, + AV_CODEC_ID_THEORA, + AV_CODEC_ID_ASV1, + AV_CODEC_ID_ASV2, + AV_CODEC_ID_FFV1, + AV_CODEC_ID_4XM, + AV_CODEC_ID_VCR1, + AV_CODEC_ID_CLJR, + AV_CODEC_ID_MDEC, + AV_CODEC_ID_ROQ, + AV_CODEC_ID_INTERPLAY_VIDEO, + AV_CODEC_ID_XAN_WC3, + AV_CODEC_ID_XAN_WC4, + AV_CODEC_ID_RPZA, + AV_CODEC_ID_CINEPAK, + AV_CODEC_ID_WS_VQA, + AV_CODEC_ID_MSRLE, + AV_CODEC_ID_MSVIDEO1, + AV_CODEC_ID_IDCIN, + AV_CODEC_ID_8BPS, + AV_CODEC_ID_SMC, + AV_CODEC_ID_FLIC, + AV_CODEC_ID_TRUEMOTION1, + AV_CODEC_ID_VMDVIDEO, + AV_CODEC_ID_MSZH, + AV_CODEC_ID_ZLIB, + AV_CODEC_ID_QTRLE, + AV_CODEC_ID_TSCC, + AV_CODEC_ID_ULTI, + AV_CODEC_ID_QDRAW, + AV_CODEC_ID_VIXL, + AV_CODEC_ID_QPEG, + AV_CODEC_ID_PNG, + AV_CODEC_ID_PPM, + AV_CODEC_ID_PBM, + AV_CODEC_ID_PGM, + AV_CODEC_ID_PGMYUV, + AV_CODEC_ID_PAM, + AV_CODEC_ID_FFVHUFF, + AV_CODEC_ID_RV30, + AV_CODEC_ID_RV40, + AV_CODEC_ID_VC1, + AV_CODEC_ID_WMV3, + AV_CODEC_ID_LOCO, + AV_CODEC_ID_WNV1, + AV_CODEC_ID_AASC, + AV_CODEC_ID_INDEO2, + AV_CODEC_ID_FRAPS, + AV_CODEC_ID_TRUEMOTION2, + AV_CODEC_ID_BMP, + AV_CODEC_ID_CSCD, + AV_CODEC_ID_MMVIDEO, + AV_CODEC_ID_ZMBV, + AV_CODEC_ID_AVS, + AV_CODEC_ID_SMACKVIDEO, + AV_CODEC_ID_NUV, + AV_CODEC_ID_KMVC, + AV_CODEC_ID_FLASHSV, + AV_CODEC_ID_CAVS, + AV_CODEC_ID_JPEG2000, + AV_CODEC_ID_VMNC, + AV_CODEC_ID_VP5, + AV_CODEC_ID_VP6, + AV_CODEC_ID_VP6F, + AV_CODEC_ID_TARGA, + AV_CODEC_ID_DSICINVIDEO, + AV_CODEC_ID_TIERTEXSEQVIDEO, + AV_CODEC_ID_TIFF, + AV_CODEC_ID_GIF, + AV_CODEC_ID_DXA, + AV_CODEC_ID_DNXHD, + AV_CODEC_ID_THP, + AV_CODEC_ID_SGI, + AV_CODEC_ID_C93, + AV_CODEC_ID_BETHSOFTVID, + AV_CODEC_ID_PTX, + AV_CODEC_ID_TXD, + AV_CODEC_ID_VP6A, + AV_CODEC_ID_AMV, + AV_CODEC_ID_VB, + AV_CODEC_ID_PCX, + AV_CODEC_ID_SUNRAST, + AV_CODEC_ID_INDEO4, + AV_CODEC_ID_INDEO5, + AV_CODEC_ID_MIMIC, + AV_CODEC_ID_RL2, + AV_CODEC_ID_ESCAPE124, + AV_CODEC_ID_DIRAC, + AV_CODEC_ID_BFI, + AV_CODEC_ID_CMV, + AV_CODEC_ID_MOTIONPIXELS, + AV_CODEC_ID_TGV, + AV_CODEC_ID_TGQ, + AV_CODEC_ID_TQI, + AV_CODEC_ID_AURA, + AV_CODEC_ID_AURA2, + AV_CODEC_ID_V210X, + AV_CODEC_ID_TMV, + AV_CODEC_ID_V210, + AV_CODEC_ID_DPX, + AV_CODEC_ID_MAD, + AV_CODEC_ID_FRWU, + AV_CODEC_ID_FLASHSV2, + AV_CODEC_ID_CDGRAPHICS, + AV_CODEC_ID_R210, + AV_CODEC_ID_ANM, + AV_CODEC_ID_BINKVIDEO, + AV_CODEC_ID_IFF_ILBM, + AV_CODEC_ID_IFF_BYTERUN1, + AV_CODEC_ID_KGV1, + AV_CODEC_ID_YOP, + AV_CODEC_ID_VP8, + AV_CODEC_ID_PICTOR, + AV_CODEC_ID_ANSI, + AV_CODEC_ID_A64_MULTI, + AV_CODEC_ID_A64_MULTI5, + AV_CODEC_ID_R10K, + AV_CODEC_ID_MXPEG, + AV_CODEC_ID_LAGARITH, + AV_CODEC_ID_PRORES, + AV_CODEC_ID_JV, + AV_CODEC_ID_DFA, + AV_CODEC_ID_WMV3IMAGE, + AV_CODEC_ID_VC1IMAGE, + AV_CODEC_ID_UTVIDEO, + AV_CODEC_ID_BMV_VIDEO, + AV_CODEC_ID_VBLE, + AV_CODEC_ID_DXTORY, + AV_CODEC_ID_V410, + AV_CODEC_ID_XWD, + AV_CODEC_ID_CDXL, + AV_CODEC_ID_XBM, + AV_CODEC_ID_ZEROCODEC, + AV_CODEC_ID_MSS1, + AV_CODEC_ID_MSA1, + AV_CODEC_ID_TSCC2, + AV_CODEC_ID_MTS2, + AV_CODEC_ID_CLLC, + AV_CODEC_ID_MSS2, + AV_CODEC_ID_VP9, + AV_CODEC_ID_AIC, + AV_CODEC_ID_ESCAPE130, + AV_CODEC_ID_G2M, + + /* various PCM "codecs" */ + AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs + AV_CODEC_ID_PCM_S16LE = 0x10000, + AV_CODEC_ID_PCM_S16BE, + AV_CODEC_ID_PCM_U16LE, + AV_CODEC_ID_PCM_U16BE, + AV_CODEC_ID_PCM_S8, + AV_CODEC_ID_PCM_U8, + AV_CODEC_ID_PCM_MULAW, + AV_CODEC_ID_PCM_ALAW, + AV_CODEC_ID_PCM_S32LE, + AV_CODEC_ID_PCM_S32BE, + AV_CODEC_ID_PCM_U32LE, + AV_CODEC_ID_PCM_U32BE, + AV_CODEC_ID_PCM_S24LE, + AV_CODEC_ID_PCM_S24BE, + AV_CODEC_ID_PCM_U24LE, + AV_CODEC_ID_PCM_U24BE, + AV_CODEC_ID_PCM_S24DAUD, + AV_CODEC_ID_PCM_ZORK, + AV_CODEC_ID_PCM_S16LE_PLANAR, + AV_CODEC_ID_PCM_DVD, + AV_CODEC_ID_PCM_F32BE, + AV_CODEC_ID_PCM_F32LE, + AV_CODEC_ID_PCM_F64BE, + AV_CODEC_ID_PCM_F64LE, + AV_CODEC_ID_PCM_BLURAY, + AV_CODEC_ID_PCM_LXF, + AV_CODEC_ID_S302M, + AV_CODEC_ID_PCM_S8_PLANAR, + + /* various ADPCM codecs */ + AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, + AV_CODEC_ID_ADPCM_IMA_WAV, + AV_CODEC_ID_ADPCM_IMA_DK3, + AV_CODEC_ID_ADPCM_IMA_DK4, + AV_CODEC_ID_ADPCM_IMA_WS, + AV_CODEC_ID_ADPCM_IMA_SMJPEG, + AV_CODEC_ID_ADPCM_MS, + AV_CODEC_ID_ADPCM_4XM, + AV_CODEC_ID_ADPCM_XA, + AV_CODEC_ID_ADPCM_ADX, + AV_CODEC_ID_ADPCM_EA, + AV_CODEC_ID_ADPCM_G726, + AV_CODEC_ID_ADPCM_CT, + AV_CODEC_ID_ADPCM_SWF, + AV_CODEC_ID_ADPCM_YAMAHA, + AV_CODEC_ID_ADPCM_SBPRO_4, + AV_CODEC_ID_ADPCM_SBPRO_3, + AV_CODEC_ID_ADPCM_SBPRO_2, + AV_CODEC_ID_ADPCM_THP, + AV_CODEC_ID_ADPCM_IMA_AMV, + AV_CODEC_ID_ADPCM_EA_R1, + AV_CODEC_ID_ADPCM_EA_R3, + AV_CODEC_ID_ADPCM_EA_R2, + AV_CODEC_ID_ADPCM_IMA_EA_SEAD, + AV_CODEC_ID_ADPCM_IMA_EA_EACS, + AV_CODEC_ID_ADPCM_EA_XAS, + AV_CODEC_ID_ADPCM_EA_MAXIS_XA, + AV_CODEC_ID_ADPCM_IMA_ISS, + AV_CODEC_ID_ADPCM_G722, + AV_CODEC_ID_ADPCM_IMA_APC, + + /* AMR */ + AV_CODEC_ID_AMR_NB = 0x12000, + AV_CODEC_ID_AMR_WB, + + /* RealAudio codecs*/ + AV_CODEC_ID_RA_144 = 0x13000, + AV_CODEC_ID_RA_288, + + /* various DPCM codecs */ + AV_CODEC_ID_ROQ_DPCM = 0x14000, + AV_CODEC_ID_INTERPLAY_DPCM, + AV_CODEC_ID_XAN_DPCM, + AV_CODEC_ID_SOL_DPCM, + + /* audio codecs */ + AV_CODEC_ID_MP2 = 0x15000, + AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 + AV_CODEC_ID_AAC, + AV_CODEC_ID_AC3, + AV_CODEC_ID_DTS, + AV_CODEC_ID_VORBIS, + AV_CODEC_ID_DVAUDIO, + AV_CODEC_ID_WMAV1, + AV_CODEC_ID_WMAV2, + AV_CODEC_ID_MACE3, + AV_CODEC_ID_MACE6, + AV_CODEC_ID_VMDAUDIO, + AV_CODEC_ID_FLAC, + AV_CODEC_ID_MP3ADU, + AV_CODEC_ID_MP3ON4, + AV_CODEC_ID_SHORTEN, + AV_CODEC_ID_ALAC, + AV_CODEC_ID_WESTWOOD_SND1, + AV_CODEC_ID_GSM, ///< as in Berlin toast format + AV_CODEC_ID_QDM2, + AV_CODEC_ID_COOK, + AV_CODEC_ID_TRUESPEECH, + AV_CODEC_ID_TTA, + AV_CODEC_ID_SMACKAUDIO, + AV_CODEC_ID_QCELP, + AV_CODEC_ID_WAVPACK, + AV_CODEC_ID_DSICINAUDIO, + AV_CODEC_ID_IMC, + AV_CODEC_ID_MUSEPACK7, + AV_CODEC_ID_MLP, + AV_CODEC_ID_GSM_MS, /* as found in WAV */ + AV_CODEC_ID_ATRAC3, +#if FF_API_VOXWARE + AV_CODEC_ID_VOXWARE, +#endif + AV_CODEC_ID_APE, + AV_CODEC_ID_NELLYMOSER, + AV_CODEC_ID_MUSEPACK8, + AV_CODEC_ID_SPEEX, + AV_CODEC_ID_WMAVOICE, + AV_CODEC_ID_WMAPRO, + AV_CODEC_ID_WMALOSSLESS, + AV_CODEC_ID_ATRAC3P, + AV_CODEC_ID_EAC3, + AV_CODEC_ID_SIPR, + AV_CODEC_ID_MP1, + AV_CODEC_ID_TWINVQ, + AV_CODEC_ID_TRUEHD, + AV_CODEC_ID_MP4ALS, + AV_CODEC_ID_ATRAC1, + AV_CODEC_ID_BINKAUDIO_RDFT, + AV_CODEC_ID_BINKAUDIO_DCT, + AV_CODEC_ID_AAC_LATM, + AV_CODEC_ID_QDMC, + AV_CODEC_ID_CELT, + AV_CODEC_ID_G723_1, + AV_CODEC_ID_G729, + AV_CODEC_ID_8SVX_EXP, + AV_CODEC_ID_8SVX_FIB, + AV_CODEC_ID_BMV_AUDIO, + AV_CODEC_ID_RALF, + AV_CODEC_ID_IAC, + AV_CODEC_ID_ILBC, + AV_CODEC_ID_OPUS, + AV_CODEC_ID_COMFORT_NOISE, + AV_CODEC_ID_TAK, + AV_CODEC_ID_METASOUND, + + /* subtitle codecs */ + AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. + AV_CODEC_ID_DVD_SUBTITLE = 0x17000, + AV_CODEC_ID_DVB_SUBTITLE, + AV_CODEC_ID_TEXT, ///< raw UTF-8 text + AV_CODEC_ID_XSUB, + AV_CODEC_ID_SSA, + AV_CODEC_ID_MOV_TEXT, + AV_CODEC_ID_HDMV_PGS_SUBTITLE, + AV_CODEC_ID_DVB_TELETEXT, + AV_CODEC_ID_SRT, + + /* other specific kind of codecs (generally used for attachments) */ + AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. + AV_CODEC_ID_TTF = 0x18000, + + AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it + + AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS + * stream (only used by libavformat) */ + AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems + * stream (only used by libavformat) */ + AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. +}; + +/** + * This struct describes the properties of a single codec described by an + * AVCodecID. + * @see avcodec_get_descriptor() + */ +typedef struct AVCodecDescriptor { + enum AVCodecID id; + enum AVMediaType type; + /** + * Name of the codec described by this descriptor. It is non-empty and + * unique for each codec descriptor. It should contain alphanumeric + * characters and '_' only. + */ + const char *name; + /** + * A more descriptive name for this codec. May be NULL. + */ + const char *long_name; + /** + * Codec properties, a combination of AV_CODEC_PROP_* flags. + */ + int props; +} AVCodecDescriptor; + +/** + * Codec uses only intra compression. + * Video codecs only. + */ +#define AV_CODEC_PROP_INTRA_ONLY (1 << 0) +/** + * Codec supports lossy compression. Audio and video codecs only. + * @note a codec may support both lossy and lossless + * compression modes + */ +#define AV_CODEC_PROP_LOSSY (1 << 1) +/** + * Codec supports lossless compression. Audio and video codecs only. + */ +#define AV_CODEC_PROP_LOSSLESS (1 << 2) + +/** + * @ingroup lavc_decoding + * Required number of additionally allocated bytes at the end of the input bitstream for decoding. + * This is mainly needed because some optimized bitstream readers read + * 32 or 64 bit at once and could read over the end.
      + * Note: If the first 23 bits of the additional bytes are not 0, then damaged + * MPEG bitstreams could cause overread and segfault. + */ +#define FF_INPUT_BUFFER_PADDING_SIZE 8 + +/** + * @ingroup lavc_encoding + * minimum encoding buffer size + * Used to avoid some checks during header writing. + */ +#define FF_MIN_BUFFER_SIZE 16384 + + +/** + * @ingroup lavc_encoding + * motion estimation type. + */ +enum Motion_Est_ID { + ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed + ME_FULL, + ME_LOG, + ME_PHODS, + ME_EPZS, ///< enhanced predictive zonal search + ME_X1, ///< reserved for experiments + ME_HEX, ///< hexagon based search + ME_UMH, ///< uneven multi-hexagon search + ME_TESA, ///< transformed exhaustive search algorithm +}; + +/** + * @ingroup lavc_decoding + */ +enum AVDiscard{ + /* We leave some space between them for extensions (drop some + * keyframes for intra-only or drop just some bidir frames). */ + AVDISCARD_NONE =-16, ///< discard nothing + AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi + AVDISCARD_NONREF = 8, ///< discard all non reference + AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames + AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes + AVDISCARD_ALL = 48, ///< discard all +}; + +enum AVColorPrimaries{ + AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B + AVCOL_PRI_UNSPECIFIED = 2, + AVCOL_PRI_BT470M = 4, + AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM + AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC + AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above + AVCOL_PRI_FILM = 8, + AVCOL_PRI_NB , ///< Not part of ABI +}; + +enum AVColorTransferCharacteristic{ + AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361 + AVCOL_TRC_UNSPECIFIED = 2, + AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM + AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG + AVCOL_TRC_SMPTE240M = 7, + AVCOL_TRC_NB , ///< Not part of ABI +}; + +enum AVColorSpace{ + AVCOL_SPC_RGB = 0, + AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B + AVCOL_SPC_UNSPECIFIED = 2, + AVCOL_SPC_FCC = 4, + AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 + AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above + AVCOL_SPC_SMPTE240M = 7, + AVCOL_SPC_YCOCG = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 + AVCOL_SPC_NB , ///< Not part of ABI +}; + +enum AVColorRange{ + AVCOL_RANGE_UNSPECIFIED = 0, + AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges + AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges + AVCOL_RANGE_NB , ///< Not part of ABI +}; + +/** + * X X 3 4 X X are luma samples, + * 1 2 1-6 are possible chroma positions + * X X 5 6 X 0 is undefined/unknown position + */ +enum AVChromaLocation{ + AVCHROMA_LOC_UNSPECIFIED = 0, + AVCHROMA_LOC_LEFT = 1, ///< mpeg2/4, h264 default + AVCHROMA_LOC_CENTER = 2, ///< mpeg1, jpeg, h263 + AVCHROMA_LOC_TOPLEFT = 3, ///< DV + AVCHROMA_LOC_TOP = 4, + AVCHROMA_LOC_BOTTOMLEFT = 5, + AVCHROMA_LOC_BOTTOM = 6, + AVCHROMA_LOC_NB , ///< Not part of ABI +}; + +enum AVAudioServiceType { + AV_AUDIO_SERVICE_TYPE_MAIN = 0, + AV_AUDIO_SERVICE_TYPE_EFFECTS = 1, + AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2, + AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3, + AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4, + AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5, + AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6, + AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7, + AV_AUDIO_SERVICE_TYPE_KARAOKE = 8, + AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI +}; + +/** + * @ingroup lavc_encoding + */ +typedef struct RcOverride{ + int start_frame; + int end_frame; + int qscale; // If this is 0 then quality_factor will be used instead. + float quality_factor; +} RcOverride; + +#define FF_MAX_B_FRAMES 16 + +/* encoding support + These flags can be passed in AVCodecContext.flags before initialization. + Note: Not everything is supported yet. +*/ + +/** + * Allow decoders to produce frames with data planes that are not aligned + * to CPU requirements (e.g. due to cropping). + */ +#define CODEC_FLAG_UNALIGNED 0x0001 +#define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale. +#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263. +#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. +#define CODEC_FLAG_GMC 0x0020 ///< Use GMC. +#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. +/** + * The parent program guarantees that the input for B-frames containing + * streams is not written to for at least s->max_b_frames+1 frames, if + * this is not set the input will be copied. + */ +#define CODEC_FLAG_INPUT_PRESERVED 0x0100 +#define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. +#define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. +#define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. +#define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges. +#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. +#define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random + location instead of only at frame boundaries. */ +#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization. +#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. +#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. +#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. +#define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). +/* Fx : Flag for h263+ extra options */ +#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction +#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter +#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation +#define CODEC_FLAG_CLOSED_GOP 0x80000000 +#define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. +#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding. +#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. +#define CODEC_FLAG2_IGNORE_CROP 0x00010000 ///< Discard cropping information from SPS. + +#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. + +/* Unsupported options : + * Syntax Arithmetic coding (SAC) + * Reference Picture Selection + * Independent Segment Decoding */ +/* /Fx */ +/* codec capabilities */ + +#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback. +/** + * Codec uses get_buffer() for allocating buffers and supports custom allocators. + * If not set, it might not use get_buffer() at all or use operations that + * assume the buffer was allocated by avcodec_default_get_buffer. + */ +#define CODEC_CAP_DR1 0x0002 +#define CODEC_CAP_TRUNCATED 0x0008 +/* Codec can export data for HW decoding (XvMC). */ +#define CODEC_CAP_HWACCEL 0x0010 +/** + * Encoder or decoder requires flushing with NULL input at the end in order to + * give the complete and correct output. + * + * NOTE: If this flag is not set, the codec is guaranteed to never be fed with + * with NULL data. The user can still send NULL data to the public encode + * or decode function, but libavcodec will not pass it along to the codec + * unless this flag is set. + * + * Decoders: + * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to get the delayed data until the decoder no longer + * returns frames. + * + * Encoders: + * The encoder needs to be fed with NULL data at the end of encoding until the + * encoder no longer returns data. + * + * NOTE: For encoders implementing the AVCodec.encode2() function, setting this + * flag also means that the encoder must set the pts and duration for + * each output packet. If this flag is not set, the pts and duration will + * be determined by libavcodec from the input frame. + */ +#define CODEC_CAP_DELAY 0x0020 +/** + * Codec can be fed a final frame with a smaller size. + * This can be used to prevent truncation of the last audio samples. + */ +#define CODEC_CAP_SMALL_LAST_FRAME 0x0040 +#if FF_API_CAP_VDPAU +/** + * Codec can export data for HW decoding (VDPAU). + */ +#define CODEC_CAP_HWACCEL_VDPAU 0x0080 +#endif +/** + * Codec can output multiple frames per AVPacket + * Normally demuxers return one frame at a time, demuxers which do not do + * are connected to a parser to split what they return into proper frames. + * This flag is reserved to the very rare category of codecs which have a + * bitstream that cannot be split into frames without timeconsuming + * operations like full decoding. Demuxers carring such bitstreams thus + * may return multiple frames in a packet. This has many disadvantages like + * prohibiting stream copy in many cases thus it should only be considered + * as a last resort. + */ +#define CODEC_CAP_SUBFRAMES 0x0100 +/** + * Codec is experimental and is thus avoided in favor of non experimental + * encoders + */ +#define CODEC_CAP_EXPERIMENTAL 0x0200 +/** + * Codec should fill in channel configuration and samplerate instead of container + */ +#define CODEC_CAP_CHANNEL_CONF 0x0400 +/** + * Codec is able to deal with negative linesizes + */ +#define CODEC_CAP_NEG_LINESIZES 0x0800 +/** + * Codec supports frame-level multithreading. + */ +#define CODEC_CAP_FRAME_THREADS 0x1000 +/** + * Codec supports slice-based (or partition-based) multithreading. + */ +#define CODEC_CAP_SLICE_THREADS 0x2000 +/** + * Codec supports changed parameters at any point. + */ +#define CODEC_CAP_PARAM_CHANGE 0x4000 +/** + * Codec supports avctx->thread_count == 0 (auto). + */ +#define CODEC_CAP_AUTO_THREADS 0x8000 +/** + * Audio encoder supports receiving a different number of samples in each call. + */ +#define CODEC_CAP_VARIABLE_FRAME_SIZE 0x10000 + +//The following defines may change, don't expect compatibility if you use them. +#define MB_TYPE_INTRA4x4 0x0001 +#define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific +#define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific +#define MB_TYPE_16x16 0x0008 +#define MB_TYPE_16x8 0x0010 +#define MB_TYPE_8x16 0x0020 +#define MB_TYPE_8x8 0x0040 +#define MB_TYPE_INTERLACED 0x0080 +#define MB_TYPE_DIRECT2 0x0100 //FIXME +#define MB_TYPE_ACPRED 0x0200 +#define MB_TYPE_GMC 0x0400 +#define MB_TYPE_SKIP 0x0800 +#define MB_TYPE_P0L0 0x1000 +#define MB_TYPE_P1L0 0x2000 +#define MB_TYPE_P0L1 0x4000 +#define MB_TYPE_P1L1 0x8000 +#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) +#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) +#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) +#define MB_TYPE_QUANT 0x00010000 +#define MB_TYPE_CBP 0x00020000 +//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) + +/** + * Pan Scan area. + * This specifies the area which should be displayed. + * Note there may be multiple such areas for one frame. + */ +typedef struct AVPanScan{ + /** + * id + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int id; + + /** + * width and height in 1/16 pel + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int width; + int height; + + /** + * position of the top left corner in 1/16 pel for up to 3 fields/frames + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int16_t position[3][2]; +}AVPanScan; + +#define FF_QSCALE_TYPE_MPEG1 0 +#define FF_QSCALE_TYPE_MPEG2 1 +#define FF_QSCALE_TYPE_H264 2 +#define FF_QSCALE_TYPE_VP56 3 + +#if FF_API_GET_BUFFER +#define FF_BUFFER_TYPE_INTERNAL 1 +#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user) +#define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared. +#define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything. + +#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore). +#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer. +#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content. +#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update). +#endif + +/** + * The decoder will keep a reference to the frame and may reuse it later. + */ +#define AV_GET_BUFFER_FLAG_REF (1 << 0) + +/** + * @defgroup lavc_packet AVPacket + * + * Types and functions for working with AVPacket. + * @{ + */ +enum AVPacketSideDataType { + AV_PKT_DATA_PALETTE, + AV_PKT_DATA_NEW_EXTRADATA, + + /** + * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: + * @code + * u32le param_flags + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) + * s32le channel_count + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) + * u64le channel_layout + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) + * s32le sample_rate + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) + * s32le width + * s32le height + * @endcode + */ + AV_PKT_DATA_PARAM_CHANGE, + + /** + * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of + * structures with info about macroblocks relevant to splitting the + * packet into smaller packets on macroblock edges (e.g. as for RFC 2190). + * That is, it does not necessarily contain info about all macroblocks, + * as long as the distance between macroblocks in the info is smaller + * than the target payload size. + * Each MB info structure is 12 bytes, and is laid out as follows: + * @code + * u32le bit offset from the start of the packet + * u8 current quantizer at the start of the macroblock + * u8 GOB number + * u16le macroblock address within the GOB + * u8 horizontal MV predictor + * u8 vertical MV predictor + * u8 horizontal MV predictor for block number 3 + * u8 vertical MV predictor for block number 3 + * @endcode + */ + AV_PKT_DATA_H263_MB_INFO, +}; + +/** + * This structure stores compressed data. It is typically exported by demuxers + * and then passed as input to decoders, or received as output from encoders and + * then passed to muxers. + * + * For video, it should typically contain one compressed frame. For audio it may + * contain several compressed frames. + * + * AVPacket is one of the few structs in Libav, whose size is a part of public + * ABI. Thus it may be allocated on stack and no new fields can be added to it + * without libavcodec and libavformat major bump. + * + * The semantics of data ownership depends on the buf or destruct (deprecated) + * fields. If either is set, the packet data is dynamically allocated and is + * valid indefinitely until av_free_packet() is called (which in turn calls + * av_buffer_unref()/the destruct callback to free the data). If neither is set, + * the packet data is typically backed by some static buffer somewhere and is + * only valid for a limited time (e.g. until the next read call when demuxing). + * + * The side data is always allocated with av_malloc() and is freed in + * av_free_packet(). + */ +typedef struct AVPacket { + /** + * A reference to the reference-counted buffer where the packet data is + * stored. + * May be NULL, then the packet data is not reference-counted. + */ + AVBufferRef *buf; + /** + * Presentation timestamp in AVStream->time_base units; the time at which + * the decompressed packet will be presented to the user. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + * pts MUST be larger or equal to dts as presentation cannot happen before + * decompression, unless one wants to view hex dumps. Some formats misuse + * the terms dts and pts/cts to mean something different. Such timestamps + * must be converted to true pts/dts before they are stored in AVPacket. + */ + int64_t pts; + /** + * Decompression timestamp in AVStream->time_base units; the time at which + * the packet is decompressed. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + */ + int64_t dts; + uint8_t *data; + int size; + int stream_index; + /** + * A combination of AV_PKT_FLAG values + */ + int flags; + /** + * Additional packet data that can be provided by the container. + * Packet can contain several types of side information. + */ + struct { + uint8_t *data; + int size; + enum AVPacketSideDataType type; + } *side_data; + int side_data_elems; + + /** + * Duration of this packet in AVStream->time_base units, 0 if unknown. + * Equals next_pts - this_pts in presentation order. + */ + int duration; +#if FF_API_DESTRUCT_PACKET + attribute_deprecated + void (*destruct)(struct AVPacket *); + attribute_deprecated + void *priv; +#endif + int64_t pos; ///< byte position in stream, -1 if unknown + + /** + * Time difference in AVStream->time_base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current packet. + * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY + * set. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + */ + int64_t convergence_duration; +} AVPacket; +#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe +#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted + +enum AVSideDataParamChangeFlags { + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, + AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, +}; +/** + * @} + */ + +struct AVCodecInternal; + +enum AVFieldOrder { + AV_FIELD_UNKNOWN, + AV_FIELD_PROGRESSIVE, + AV_FIELD_TT, //< Top coded_first, top displayed first + AV_FIELD_BB, //< Bottom coded first, bottom displayed first + AV_FIELD_TB, //< Top coded first, bottom displayed first + AV_FIELD_BT, //< Bottom coded first, top displayed first +}; + +/** + * main external API structure. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVCodecContext) must not be used outside libav*. + */ +typedef struct AVCodecContext { + /** + * information on struct for av_log + * - set by avcodec_alloc_context3 + */ + const AVClass *av_class; + int log_level_offset; + + enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */ + const struct AVCodec *codec; + char codec_name[32]; + enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */ + + /** + * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * A demuxer should set this to what is stored in the field used to identify the codec. + * If there are multiple such fields in a container then the demuxer should choose the one + * which maximizes the information about the used codec. + * If the codec tag field in a container is larger than 32 bits then the demuxer should + * remap the longer ID to 32 bits with a table or other structure. Alternatively a new + * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated + * first. + * - encoding: Set by user, if not then the default based on codec_id will be used. + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + */ + unsigned int codec_tag; + + /** + * fourcc from the AVI stream header (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * - encoding: unused + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + */ + unsigned int stream_codec_tag; + + void *priv_data; + + /** + * Private context used for internal data. + * + * Unlike priv_data, this is not codec-specific. It is used in general + * libavcodec functions. + */ + struct AVCodecInternal *internal; + + /** + * Private data of the user, can be used to carry app specific stuff. + * - encoding: Set by user. + * - decoding: Set by user. + */ + void *opaque; + + /** + * the average bitrate + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream. + */ + int bit_rate; + + /** + * number of bits the bitstream is allowed to diverge from the reference. + * the reference can be CBR (for CBR pass1) or VBR (for pass2) + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: unused + */ + int bit_rate_tolerance; + + /** + * Global quality for codecs which cannot change it per frame. + * This should be proportional to MPEG-1/2/4 qscale. + * - encoding: Set by user. + * - decoding: unused + */ + int global_quality; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int compression_level; +#define FF_COMPRESSION_DEFAULT -1 + + /** + * CODEC_FLAG_*. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int flags; + + /** + * CODEC_FLAG2_* + * - encoding: Set by user. + * - decoding: Set by user. + */ + int flags2; + + /** + * some codecs need / can use extradata like Huffman tables. + * mjpeg: Huffman tables + * rv10: additional flags + * mpeg4: global headers (they can be in the bitstream or here) + * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger + * than extradata_size to avoid prolems if it is read with the bitstream reader. + * The bytewise contents of extradata must not depend on the architecture or CPU endianness. + * - encoding: Set/allocated/freed by libavcodec. + * - decoding: Set/allocated/freed by user. + */ + uint8_t *extradata; + int extradata_size; + + /** + * This is the fundamental unit of time (in seconds) in terms + * of which frame timestamps are represented. For fixed-fps content, + * timebase should be 1/framerate and timestamp increments should be + * identically 1. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + */ + AVRational time_base; + + /** + * For some codecs, the time base is closer to the field rate than the frame rate. + * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration + * if no telecine is used ... + * + * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. + */ + int ticks_per_frame; + + /** + * Codec delay. + * + * Video: + * Number of frames the decoded output will be delayed relative to the + * encoded input. + * + * Audio: + * For encoding, this is the number of "priming" samples added to the + * beginning of the stream. The decoded output will be delayed by this + * many samples relative to the input to the encoder. Note that this + * field is purely informational and does not directly affect the pts + * output by the encoder, which should always be based on the actual + * presentation time, including any delay. + * For decoding, this is the number of samples the decoder needs to + * output before the decoder's output is valid. When seeking, you should + * start decoding this many samples prior to your desired seek point. + * + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int delay; + + + /* video only */ + /** + * picture width / height. + * - encoding: MUST be set by user. + * - decoding: May be set by the user before opening the decoder if known e.g. + * from the container. Some decoders will require the dimensions + * to be set by the caller. During decoding, the decoder may + * overwrite those values as required. + */ + int width, height; + + /** + * Bitstream width / height, may be different from width/height e.g. when + * the decoded frame is cropped before being output. + * - encoding: unused + * - decoding: May be set by the user before opening the decoder if known + * e.g. from the container. During decoding, the decoder may + * overwrite those values as required. + */ + int coded_width, coded_height; + +#define FF_ASPECT_EXTENDED 15 + + /** + * the number of pictures in a group of pictures, or 0 for intra_only + * - encoding: Set by user. + * - decoding: unused + */ + int gop_size; + + /** + * Pixel format, see AV_PIX_FMT_xxx. + * May be set by the demuxer if known from headers. + * May be overriden by the decoder if it knows better. + * - encoding: Set by user. + * - decoding: Set by user if known, overridden by libavcodec if known + */ + enum AVPixelFormat pix_fmt; + + /** + * Motion estimation algorithm used for video coding. + * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), + * 8 (umh), 10 (tesa) [7, 8, 10 are x264 specific] + * - encoding: MUST be set by user. + * - decoding: unused + */ + int me_method; + + /** + * If non NULL, 'draw_horiz_band' is called by the libavcodec + * decoder to draw a horizontal band. It improves cache usage. Not + * all codecs can do that. You must check the codec capabilities + * beforehand. + * When multithreading is used, it may be called from multiple threads + * at the same time; threads might draw different parts of the same AVFrame, + * or multiple AVFrames, and there is no guarantee that slices will be drawn + * in order. + * The function is also used by hardware acceleration APIs. + * It is called at least once during frame decoding to pass + * the data needed for hardware render. + * In that mode instead of pixel data, AVFrame points to + * a structure specific to the acceleration API. The application + * reads the structure and can change some fields to indicate progress + * or mark state. + * - encoding: unused + * - decoding: Set by user. + * @param height the height of the slice + * @param y the y position of the slice + * @param type 1->top field, 2->bottom field, 3->frame + * @param offset offset into the AVFrame.data from which the slice should be read + */ + void (*draw_horiz_band)(struct AVCodecContext *s, + const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], + int y, int type, int height); + + /** + * callback to negotiate the pixelFormat + * @param fmt is the list of formats which are supported by the codec, + * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. + * The first is always the native one. + * @return the chosen format + * - encoding: unused + * - decoding: Set by user, if not set the native format will be chosen. + */ + enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt); + + /** + * maximum number of B-frames between non-B-frames + * Note: The output will be delayed by max_b_frames+1 relative to the input. + * - encoding: Set by user. + * - decoding: unused + */ + int max_b_frames; + + /** + * qscale factor between IP and B-frames + * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + */ + float b_quant_factor; + + /** obsolete FIXME remove */ + int rc_strategy; +#define FF_RC_STRATEGY_XVID 1 + + int b_frame_strategy; + + /** + * qscale offset between IP and B-frames + * - encoding: Set by user. + * - decoding: unused + */ + float b_quant_offset; + + /** + * Size of the frame reordering buffer in the decoder. + * For MPEG-2 it is 1 IPB or 0 low delay IP. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int has_b_frames; + + /** + * 0-> h263 quant 1-> mpeg quant + * - encoding: Set by user. + * - decoding: unused + */ + int mpeg_quant; + + /** + * qscale factor between P and I-frames + * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + */ + float i_quant_factor; + + /** + * qscale offset between P and I-frames + * - encoding: Set by user. + * - decoding: unused + */ + float i_quant_offset; + + /** + * luminance masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float lumi_masking; + + /** + * temporary complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float temporal_cplx_masking; + + /** + * spatial complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float spatial_cplx_masking; + + /** + * p block masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float p_masking; + + /** + * darkness masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float dark_masking; + + /** + * slice count + * - encoding: Set by libavcodec. + * - decoding: Set by user (or 0). + */ + int slice_count; + /** + * prediction method (needed for huffyuv) + * - encoding: Set by user. + * - decoding: unused + */ + int prediction_method; +#define FF_PRED_LEFT 0 +#define FF_PRED_PLANE 1 +#define FF_PRED_MEDIAN 2 + + /** + * slice offsets in the frame in bytes + * - encoding: Set/allocated by libavcodec. + * - decoding: Set/allocated by user (or NULL). + */ + int *slice_offset; + + /** + * sample aspect ratio (0 if unknown) + * That is the width of a pixel divided by the height of the pixel. + * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + AVRational sample_aspect_ratio; + + /** + * motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_cmp; + /** + * subpixel motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_sub_cmp; + /** + * macroblock comparison function (not supported yet) + * - encoding: Set by user. + * - decoding: unused + */ + int mb_cmp; + /** + * interlaced DCT comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int ildct_cmp; +#define FF_CMP_SAD 0 +#define FF_CMP_SSE 1 +#define FF_CMP_SATD 2 +#define FF_CMP_DCT 3 +#define FF_CMP_PSNR 4 +#define FF_CMP_BIT 5 +#define FF_CMP_RD 6 +#define FF_CMP_ZERO 7 +#define FF_CMP_VSAD 8 +#define FF_CMP_VSSE 9 +#define FF_CMP_NSSE 10 +#define FF_CMP_DCTMAX 13 +#define FF_CMP_DCT264 14 +#define FF_CMP_CHROMA 256 + + /** + * ME diamond size & shape + * - encoding: Set by user. + * - decoding: unused + */ + int dia_size; + + /** + * amount of previous MV predictors (2a+1 x 2a+1 square) + * - encoding: Set by user. + * - decoding: unused + */ + int last_predictor_count; + + /** + * prepass for motion estimation + * - encoding: Set by user. + * - decoding: unused + */ + int pre_me; + + /** + * motion estimation prepass comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_pre_cmp; + + /** + * ME prepass diamond size & shape + * - encoding: Set by user. + * - decoding: unused + */ + int pre_dia_size; + + /** + * subpel ME quality + * - encoding: Set by user. + * - decoding: unused + */ + int me_subpel_quality; + + /** + * DTG active format information (additional aspect ratio + * information only used in DVB MPEG-2 transport streams) + * 0 if not set. + * + * - encoding: unused + * - decoding: Set by decoder. + */ + int dtg_active_format; +#define FF_DTG_AFD_SAME 8 +#define FF_DTG_AFD_4_3 9 +#define FF_DTG_AFD_16_9 10 +#define FF_DTG_AFD_14_9 11 +#define FF_DTG_AFD_4_3_SP_14_9 13 +#define FF_DTG_AFD_16_9_SP_14_9 14 +#define FF_DTG_AFD_SP_4_3 15 + + /** + * maximum motion estimation search range in subpel units + * If 0 then no limit. + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_range; + + /** + * intra quantizer bias + * - encoding: Set by user. + * - decoding: unused + */ + int intra_quant_bias; +#define FF_DEFAULT_QUANT_BIAS 999999 + + /** + * inter quantizer bias + * - encoding: Set by user. + * - decoding: unused + */ + int inter_quant_bias; + + /** + * slice flags + * - encoding: unused + * - decoding: Set by user. + */ + int slice_flags; +#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display +#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG2 field pics) +#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1) + + /** + * XVideo Motion Acceleration + * - encoding: forbidden + * - decoding: set by decoder + */ + int xvmc_acceleration; + + /** + * macroblock decision mode + * - encoding: Set by user. + * - decoding: unused + */ + int mb_decision; +#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp +#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits +#define FF_MB_DECISION_RD 2 ///< rate distortion + + /** + * custom intra quantization matrix + * - encoding: Set by user, can be NULL. + * - decoding: Set by libavcodec. + */ + uint16_t *intra_matrix; + + /** + * custom inter quantization matrix + * - encoding: Set by user, can be NULL. + * - decoding: Set by libavcodec. + */ + uint16_t *inter_matrix; + + /** + * scene change detection threshold + * 0 is default, larger means fewer detected scene changes. + * - encoding: Set by user. + * - decoding: unused + */ + int scenechange_threshold; + + /** + * noise reduction strength + * - encoding: Set by user. + * - decoding: unused + */ + int noise_reduction; + + /** + * Motion estimation threshold below which no motion estimation is + * performed, but instead the user specified motion vectors are used. + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_threshold; + + /** + * Macroblock threshold below which the user specified macroblock types will be used. + * - encoding: Set by user. + * - decoding: unused + */ + int mb_threshold; + + /** + * precision of the intra DC coefficient - 8 + * - encoding: Set by user. + * - decoding: unused + */ + int intra_dc_precision; + + /** + * Number of macroblock rows at the top which are skipped. + * - encoding: unused + * - decoding: Set by user. + */ + int skip_top; + + /** + * Number of macroblock rows at the bottom which are skipped. + * - encoding: unused + * - decoding: Set by user. + */ + int skip_bottom; + + /** + * Border processing masking, raises the quantizer for mbs on the borders + * of the picture. + * - encoding: Set by user. + * - decoding: unused + */ + float border_masking; + + /** + * minimum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int mb_lmin; + + /** + * maximum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int mb_lmax; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_penalty_compensation; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int bidir_refine; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int brd_scale; + + /** + * minimum GOP size + * - encoding: Set by user. + * - decoding: unused + */ + int keyint_min; + + /** + * number of reference frames + * - encoding: Set by user. + * - decoding: Set by lavc. + */ + int refs; + + /** + * chroma qp offset from luma + * - encoding: Set by user. + * - decoding: unused + */ + int chromaoffset; + + /** + * Multiplied by qscale for each frame and added to scene_change_score. + * - encoding: Set by user. + * - decoding: unused + */ + int scenechange_factor; + + /** + * + * Note: Value depends upon the compare function used for fullpel ME. + * - encoding: Set by user. + * - decoding: unused + */ + int mv0_threshold; + + /** + * Adjust sensitivity of b_frame_strategy 1. + * - encoding: Set by user. + * - decoding: unused + */ + int b_sensitivity; + + /** + * Chromaticity coordinates of the source primaries. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorPrimaries color_primaries; + + /** + * Color Transfer Characteristic. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorTransferCharacteristic color_trc; + + /** + * YUV colorspace type. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorSpace colorspace; + + /** + * MPEG vs JPEG YUV range. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVColorRange color_range; + + /** + * This defines the location of chroma samples. + * - encoding: Set by user + * - decoding: Set by libavcodec + */ + enum AVChromaLocation chroma_sample_location; + + /** + * Number of slices. + * Indicates number of picture subdivisions. Used for parallelized + * decoding. + * - encoding: Set by user + * - decoding: unused + */ + int slices; + + /** Field order + * - encoding: set by libavcodec + * - decoding: Set by libavcodec + */ + enum AVFieldOrder field_order; + + /* audio only */ + int sample_rate; ///< samples per second + int channels; ///< number of audio channels + + /** + * audio sample format + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + enum AVSampleFormat sample_fmt; ///< sample format + + /* The following data should not be initialized. */ + /** + * Number of samples per channel in an audio frame. + * + * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame + * except the last must contain exactly frame_size samples per channel. + * May be 0 when the codec has CODEC_CAP_VARIABLE_FRAME_SIZE set, then the + * frame size is not restricted. + * - decoding: may be set by some decoders to indicate constant frame size + */ + int frame_size; + + /** + * Frame counter, set by libavcodec. + * + * - decoding: total number of frames returned from the decoder so far. + * - encoding: total number of frames passed to the encoder so far. + * + * @note the counter is not incremented if encoding/decoding resulted in + * an error. + */ + int frame_number; + + /** + * number of bytes per packet if constant and known or 0 + * Used by some WAV based audio codecs. + */ + int block_align; + + /** + * Audio cutoff bandwidth (0 means "automatic") + * - encoding: Set by user. + * - decoding: unused + */ + int cutoff; + +#if FF_API_REQUEST_CHANNELS + /** + * Decoder should decode to this many channels if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + * @deprecated Deprecated in favor of request_channel_layout. + */ + attribute_deprecated int request_channels; +#endif + + /** + * Audio channel layout. + * - encoding: set by user. + * - decoding: set by libavcodec. + */ + uint64_t channel_layout; + + /** + * Request decoder to use this channel layout if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + */ + uint64_t request_channel_layout; + + /** + * Type of service that the audio stream conveys. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + enum AVAudioServiceType audio_service_type; + + /** + * Used to request a sample format from the decoder. + * - encoding: unused. + * - decoding: Set by user. + */ + enum AVSampleFormat request_sample_fmt; + +#if FF_API_GET_BUFFER + /** + * Called at the beginning of each frame to get a buffer for it. + * + * The function will set AVFrame.data[], AVFrame.linesize[]. + * AVFrame.extended_data[] must also be set, but it should be the same as + * AVFrame.data[] except for planar audio with more channels than can fit + * in AVFrame.data[]. In that case, AVFrame.data[] shall still contain as + * many data pointers as it can hold. + * + * if CODEC_CAP_DR1 is not set then get_buffer() must call + * avcodec_default_get_buffer() instead of providing buffers allocated by + * some other means. + * + * AVFrame.data[] should be 32- or 16-byte-aligned unless the CPU doesn't + * need it. avcodec_default_get_buffer() aligns the output buffer properly, + * but if get_buffer() is overridden then alignment considerations should + * be taken into account. + * + * @see avcodec_default_get_buffer() + * + * Video: + * + * If pic.reference is set then the frame will be read later by libavcodec. + * avcodec_align_dimensions2() should be used to find the required width and + * height, as they normally need to be rounded up to the next multiple of 16. + * + * If frame multithreading is used and thread_safe_callbacks is set, + * it may be called from a different thread, but not from more than one at + * once. Does not need to be reentrant. + * + * @see release_buffer(), reget_buffer() + * @see avcodec_align_dimensions2() + * + * Audio: + * + * Decoders request a buffer of a particular size by setting + * AVFrame.nb_samples prior to calling get_buffer(). The decoder may, + * however, utilize only part of the buffer by setting AVFrame.nb_samples + * to a smaller value in the output frame. + * + * Decoders cannot use the buffer after returning from + * avcodec_decode_audio4(), so they will not call release_buffer(), as it + * is assumed to be released immediately upon return. In some rare cases, + * a decoder may need to call get_buffer() more than once in a single + * call to avcodec_decode_audio4(). In that case, when get_buffer() is + * called again after it has already been called once, the previously + * acquired buffer is assumed to be released at that time and may not be + * reused by the decoder. + * + * As a convenience, av_samples_get_buffer_size() and + * av_samples_fill_arrays() in libavutil may be used by custom get_buffer() + * functions to find the required data size and to fill data pointers and + * linesize. In AVFrame.linesize, only linesize[0] may be set for audio + * since all planes must be the same size. + * + * @see av_samples_get_buffer_size(), av_samples_fill_arrays() + * + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + * + * @deprecated use get_buffer2() + */ + attribute_deprecated + int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Called to release buffers which were allocated with get_buffer. + * A released buffer can be reused in get_buffer(). + * pic.data[*] must be set to NULL. + * May be called from a different thread if frame multithreading is used, + * but not by more than one thread at once, so does not need to be reentrant. + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + * + * @deprecated custom freeing callbacks should be set from get_buffer2() + */ + attribute_deprecated + void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Called at the beginning of a frame to get cr buffer for it. + * Buffer type (size, hints) must be the same. libavcodec won't check it. + * libavcodec will pass previous buffer in pic, function should return + * same buffer or new buffer with old frame "painted" into it. + * If pic.data[0] == NULL must behave like get_buffer(). + * if CODEC_CAP_DR1 is not set then reget_buffer() must call + * avcodec_default_reget_buffer() instead of providing buffers allocated by + * some other means. + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + */ + attribute_deprecated + int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic); +#endif + + /** + * This callback is called at the beginning of each frame to get data + * buffer(s) for it. There may be one contiguous buffer for all the data or + * there may be a buffer per each data plane or anything in between. What + * this means is, you may set however many entries in buf[] you feel necessary. + * Each buffer must be reference-counted using the AVBuffer API (see description + * of buf[] below). + * + * The following fields will be set in the frame before this callback is + * called: + * - format + * - width, height (video only) + * - sample_rate, channel_layout, nb_samples (audio only) + * Their values may differ from the corresponding values in + * AVCodecContext. This callback must use the frame values, not the codec + * context values, to calculate the required buffer size. + * + * This callback must fill the following fields in the frame: + * - data[] + * - linesize[] + * - extended_data: + * * if the data is planar audio with more than 8 channels, then this + * callback must allocate and fill extended_data to contain all pointers + * to all data planes. data[] must hold as many pointers as it can. + * extended_data must be allocated with av_malloc() and will be freed in + * av_frame_unref(). + * * otherwise exended_data must point to data + * - buf[] must contain one or more pointers to AVBufferRef structures. Each of + * the frame's data and extended_data pointers must be contained in these. That + * is, one AVBufferRef for each allocated chunk of memory, not necessarily one + * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(), + * and av_buffer_ref(). + * - extended_buf and nb_extended_buf must be allocated with av_malloc() by + * this callback and filled with the extra buffers if there are more + * buffers than buf[] can hold. extended_buf will be freed in + * av_frame_unref(). + * + * If CODEC_CAP_DR1 is not set then get_buffer2() must call + * avcodec_default_get_buffer2() instead of providing buffers allocated by + * some other means. + * + * Each data plane must be aligned to the maximum required by the target + * CPU. + * + * @see avcodec_default_get_buffer2() + * + * Video: + * + * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused + * (read and/or written to if it is writable) later by libavcodec. + * + * If CODEC_FLAG_EMU_EDGE is not set in s->flags, the buffer must contain an + * edge of the size returned by avcodec_get_edge_width() on all sides. + * + * avcodec_align_dimensions2() should be used to find the required width and + * height, as they normally need to be rounded up to the next multiple of 16. + * + * If frame multithreading is used and thread_safe_callbacks is set, + * this callback may be called from a different thread, but not from more + * than one at once. Does not need to be reentrant. + * + * @see avcodec_align_dimensions2() + * + * Audio: + * + * Decoders request a buffer of a particular size by setting + * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may, + * however, utilize only part of the buffer by setting AVFrame.nb_samples + * to a smaller value in the output frame. + * + * As a convenience, av_samples_get_buffer_size() and + * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2() + * functions to find the required data size and to fill data pointers and + * linesize. In AVFrame.linesize, only linesize[0] may be set for audio + * since all planes must be the same size. + * + * @see av_samples_get_buffer_size(), av_samples_fill_arrays() + * + * - encoding: unused + * - decoding: Set by libavcodec, user can override. + */ + int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags); + + /** + * If non-zero, the decoded audio and video frames returned from + * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted + * and are valid indefinitely. The caller must free them with + * av_frame_unref() when they are not needed anymore. + * Otherwise, the decoded frames must not be freed by the caller and are + * only valid until the next decode call. + * + * - encoding: unused + * - decoding: set by the caller before avcodec_open2(). + */ + int refcounted_frames; + + /* - encoding parameters */ + float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) + float qblur; ///< amount of qscale smoothing over time (0.0-1.0) + + /** + * minimum quantizer + * - encoding: Set by user. + * - decoding: unused + */ + int qmin; + + /** + * maximum quantizer + * - encoding: Set by user. + * - decoding: unused + */ + int qmax; + + /** + * maximum quantizer difference between frames + * - encoding: Set by user. + * - decoding: unused + */ + int max_qdiff; + + /** + * ratecontrol qmin qmax limiting method + * 0-> clipping, 1-> use a nice continuous function to limit qscale wthin qmin/qmax. + * - encoding: Set by user. + * - decoding: unused + */ + float rc_qsquish; + + float rc_qmod_amp; + int rc_qmod_freq; + + /** + * decoder bitstream buffer size + * - encoding: Set by user. + * - decoding: unused + */ + int rc_buffer_size; + + /** + * ratecontrol override, see RcOverride + * - encoding: Allocated/set/freed by user. + * - decoding: unused + */ + int rc_override_count; + RcOverride *rc_override; + + /** + * rate control equation + * - encoding: Set by user + * - decoding: unused + */ + const char *rc_eq; + + /** + * maximum bitrate + * - encoding: Set by user. + * - decoding: unused + */ + int rc_max_rate; + + /** + * minimum bitrate + * - encoding: Set by user. + * - decoding: unused + */ + int rc_min_rate; + + float rc_buffer_aggressivity; + + /** + * initial complexity for pass1 ratecontrol + * - encoding: Set by user. + * - decoding: unused + */ + float rc_initial_cplx; + + /** + * Ratecontrol attempt to use, at maximum, of what can be used without an underflow. + * - encoding: Set by user. + * - decoding: unused. + */ + float rc_max_available_vbv_use; + + /** + * Ratecontrol attempt to use, at least, times the amount needed to prevent a vbv overflow. + * - encoding: Set by user. + * - decoding: unused. + */ + float rc_min_vbv_overflow_use; + + /** + * Number of bits which should be loaded into the rc buffer before decoding starts. + * - encoding: Set by user. + * - decoding: unused + */ + int rc_initial_buffer_occupancy; + +#define FF_CODER_TYPE_VLC 0 +#define FF_CODER_TYPE_AC 1 +#define FF_CODER_TYPE_RAW 2 +#define FF_CODER_TYPE_RLE 3 +#define FF_CODER_TYPE_DEFLATE 4 + /** + * coder type + * - encoding: Set by user. + * - decoding: unused + */ + int coder_type; + + /** + * context model + * - encoding: Set by user. + * - decoding: unused + */ + int context_model; + + /** + * minimum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int lmin; + + /** + * maximum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int lmax; + + /** + * frame skip threshold + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_threshold; + + /** + * frame skip factor + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_factor; + + /** + * frame skip exponent + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_exp; + + /** + * frame skip comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_cmp; + + /** + * trellis RD quantization + * - encoding: Set by user. + * - decoding: unused + */ + int trellis; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int min_prediction_order; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int max_prediction_order; + + /** + * GOP timecode frame start number, in non drop frame format + * - encoding: Set by user. + * - decoding: unused + */ + int64_t timecode_frame_start; + + /* The RTP callback: This function is called */ + /* every time the encoder has a packet to send. */ + /* It depends on the encoder if the data starts */ + /* with a Start Code (it should). H.263 does. */ + /* mb_nb contains the number of macroblocks */ + /* encoded in the RTP payload. */ + void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); + + int rtp_payload_size; /* The size of the RTP payload: the coder will */ + /* do its best to deliver a chunk with size */ + /* below rtp_payload_size, the chunk will start */ + /* with a start code on some codecs like H.263. */ + /* This doesn't take account of any particular */ + /* headers inside the transmitted RTP payload. */ + + /* statistics, used for 2-pass encoding */ + int mv_bits; + int header_bits; + int i_tex_bits; + int p_tex_bits; + int i_count; + int p_count; + int skip_count; + int misc_bits; + + /** + * number of bits used for the previously encoded frame + * - encoding: Set by libavcodec. + * - decoding: unused + */ + int frame_bits; + + /** + * pass1 encoding statistics output buffer + * - encoding: Set by libavcodec. + * - decoding: unused + */ + char *stats_out; + + /** + * pass2 encoding statistics input buffer + * Concatenated stuff from stats_out of pass1 should be placed here. + * - encoding: Allocated/set/freed by user. + * - decoding: unused + */ + char *stats_in; + + /** + * Work around bugs in encoders which sometimes cannot be detected automatically. + * - encoding: Set by user + * - decoding: Set by user + */ + int workaround_bugs; +#define FF_BUG_AUTODETECT 1 ///< autodetection +#define FF_BUG_OLD_MSMPEG4 2 +#define FF_BUG_XVID_ILACE 4 +#define FF_BUG_UMP4 8 +#define FF_BUG_NO_PADDING 16 +#define FF_BUG_AMV 32 +#define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default. +#define FF_BUG_QPEL_CHROMA 64 +#define FF_BUG_STD_QPEL 128 +#define FF_BUG_QPEL_CHROMA2 256 +#define FF_BUG_DIRECT_BLOCKSIZE 512 +#define FF_BUG_EDGE 1024 +#define FF_BUG_HPEL_CHROMA 2048 +#define FF_BUG_DC_CLIP 4096 +#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. +#define FF_BUG_TRUNCATED 16384 + + /** + * strictly follow the standard (MPEG4, ...). + * - encoding: Set by user. + * - decoding: Set by user. + * Setting this to STRICT or higher means the encoder and decoder will + * generally do stupid things, whereas setting it to unofficial or lower + * will mean the encoder might produce output that is not supported by all + * spec-compliant decoders. Decoders don't differentiate between normal, + * unofficial and experimental (that is, they always try to decode things + * when they can) unless they are explicitly asked to behave stupidly + * (=strictly conform to the specs) + */ + int strict_std_compliance; +#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. +#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. +#define FF_COMPLIANCE_NORMAL 0 +#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions +#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. + + /** + * error concealment flags + * - encoding: unused + * - decoding: Set by user. + */ + int error_concealment; +#define FF_EC_GUESS_MVS 1 +#define FF_EC_DEBLOCK 2 + + /** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + */ + int debug; +#define FF_DEBUG_PICT_INFO 1 +#define FF_DEBUG_RC 2 +#define FF_DEBUG_BITSTREAM 4 +#define FF_DEBUG_MB_TYPE 8 +#define FF_DEBUG_QP 16 +#define FF_DEBUG_MV 32 +#define FF_DEBUG_DCT_COEFF 0x00000040 +#define FF_DEBUG_SKIP 0x00000080 +#define FF_DEBUG_STARTCODE 0x00000100 +#define FF_DEBUG_PTS 0x00000200 +#define FF_DEBUG_ER 0x00000400 +#define FF_DEBUG_MMCO 0x00000800 +#define FF_DEBUG_BUGS 0x00001000 +#define FF_DEBUG_VIS_QP 0x00002000 +#define FF_DEBUG_VIS_MB_TYPE 0x00004000 +#define FF_DEBUG_BUFFERS 0x00008000 +#define FF_DEBUG_THREADS 0x00010000 + + /** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + */ + int debug_mv; +#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames +#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames +#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames + + /** + * Error recognition; may misdetect some more or less valid parts as errors. + * - encoding: unused + * - decoding: Set by user. + */ + int err_recognition; +#define AV_EF_CRCCHECK (1<<0) +#define AV_EF_BITSTREAM (1<<1) +#define AV_EF_BUFFER (1<<2) +#define AV_EF_EXPLODE (1<<3) + + /** + * opaque 64bit number (generally a PTS) that will be reordered and + * output in AVFrame.reordered_opaque + * @deprecated in favor of pkt_pts + * - encoding: unused + * - decoding: Set by user. + */ + int64_t reordered_opaque; + + /** + * Hardware accelerator in use + * - encoding: unused. + * - decoding: Set by libavcodec + */ + struct AVHWAccel *hwaccel; + + /** + * Hardware accelerator context. + * For some hardware accelerators, a global context needs to be + * provided by the user. In that case, this holds display-dependent + * data Libav cannot instantiate itself. Please refer to the + * Libav HW accelerator documentation to know how to fill this + * is. e.g. for VA API, this is a struct vaapi_context. + * - encoding: unused + * - decoding: Set by user + */ + void *hwaccel_context; + + /** + * error + * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. + * - decoding: unused + */ + uint64_t error[AV_NUM_DATA_POINTERS]; + + /** + * DCT algorithm, see FF_DCT_* below + * - encoding: Set by user. + * - decoding: unused + */ + int dct_algo; +#define FF_DCT_AUTO 0 +#define FF_DCT_FASTINT 1 +#define FF_DCT_INT 2 +#define FF_DCT_MMX 3 +#define FF_DCT_ALTIVEC 5 +#define FF_DCT_FAAN 6 + + /** + * IDCT algorithm, see FF_IDCT_* below. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int idct_algo; +#define FF_IDCT_AUTO 0 +#define FF_IDCT_INT 1 +#define FF_IDCT_SIMPLE 2 +#define FF_IDCT_SIMPLEMMX 3 +#define FF_IDCT_ARM 7 +#define FF_IDCT_ALTIVEC 8 +#define FF_IDCT_SH4 9 +#define FF_IDCT_SIMPLEARM 10 +#define FF_IDCT_IPP 13 +#define FF_IDCT_XVIDMMX 14 +#define FF_IDCT_SIMPLEARMV5TE 16 +#define FF_IDCT_SIMPLEARMV6 17 +#define FF_IDCT_SIMPLEVIS 18 +#define FF_IDCT_FAAN 20 +#define FF_IDCT_SIMPLENEON 22 +#define FF_IDCT_SIMPLEALPHA 23 + + /** + * bits per sample/pixel from the demuxer (needed for huffyuv). + * - encoding: Set by libavcodec. + * - decoding: Set by user. + */ + int bits_per_coded_sample; + + /** + * Bits per sample/pixel of internal libavcodec pixel/sample format. + * - encoding: set by user. + * - decoding: set by libavcodec. + */ + int bits_per_raw_sample; + +#if FF_API_LOWRES + /** + * low resolution decoding, 1-> 1/2 size, 2->1/4 size + * - encoding: unused + * - decoding: Set by user. + * + * @deprecated use decoder private options instead + */ + attribute_deprecated int lowres; +#endif + + /** + * the picture in the bitstream + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + AVFrame *coded_frame; + + /** + * thread count + * is used to decide how many independent tasks should be passed to execute() + * - encoding: Set by user. + * - decoding: Set by user. + */ + int thread_count; + + /** + * Which multithreading methods to use. + * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread, + * so clients which cannot provide future frames should not use it. + * + * - encoding: Set by user, otherwise the default is used. + * - decoding: Set by user, otherwise the default is used. + */ + int thread_type; +#define FF_THREAD_FRAME 1 ///< Decode more than one frame at once +#define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once + + /** + * Which multithreading methods are in use by the codec. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int active_thread_type; + + /** + * Set by the client if its custom get_buffer() callback can be called + * synchronously from another thread, which allows faster multithreaded decoding. + * draw_horiz_band() will be called from other threads regardless of this setting. + * Ignored if the default get_buffer() is used. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int thread_safe_callbacks; + + /** + * The codec may call this to execute several independent things. + * It will return only after finishing all tasks. + * The user may replace this with some multithreaded implementation, + * the default implementation will execute the parts serially. + * @param count the number of things to execute + * - encoding: Set by libavcodec, user can override. + * - decoding: Set by libavcodec, user can override. + */ + int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size); + + /** + * The codec may call this to execute several independent things. + * It will return only after finishing all tasks. + * The user may replace this with some multithreaded implementation, + * the default implementation will execute the parts serially. + * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. + * @param c context passed also to func + * @param count the number of things to execute + * @param arg2 argument passed unchanged to func + * @param ret return values of executed functions, must have space for "count" values. May be NULL. + * @param func function that will be called count times, with jobnr from 0 to count-1. + * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no + * two instances of func executing at the same time will have the same threadnr. + * @return always 0 currently, but code should handle a future improvement where when any call to func + * returns < 0 no further calls to func may be done and < 0 is returned. + * - encoding: Set by libavcodec, user can override. + * - decoding: Set by libavcodec, user can override. + */ + int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); + + /** + * thread opaque + * Can be used by execute() to store some per AVCodecContext stuff. + * - encoding: set by execute() + * - decoding: set by execute() + */ + void *thread_opaque; + + /** + * noise vs. sse weight for the nsse comparsion function + * - encoding: Set by user. + * - decoding: unused + */ + int nsse_weight; + + /** + * profile + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int profile; +#define FF_PROFILE_UNKNOWN -99 +#define FF_PROFILE_RESERVED -100 + +#define FF_PROFILE_AAC_MAIN 0 +#define FF_PROFILE_AAC_LOW 1 +#define FF_PROFILE_AAC_SSR 2 +#define FF_PROFILE_AAC_LTP 3 +#define FF_PROFILE_AAC_HE 4 +#define FF_PROFILE_AAC_HE_V2 28 +#define FF_PROFILE_AAC_LD 22 +#define FF_PROFILE_AAC_ELD 38 +#define FF_PROFILE_MPEG2_AAC_LOW 128 +#define FF_PROFILE_MPEG2_AAC_HE 131 + +#define FF_PROFILE_DTS 20 +#define FF_PROFILE_DTS_ES 30 +#define FF_PROFILE_DTS_96_24 40 +#define FF_PROFILE_DTS_HD_HRA 50 +#define FF_PROFILE_DTS_HD_MA 60 + +#define FF_PROFILE_MPEG2_422 0 +#define FF_PROFILE_MPEG2_HIGH 1 +#define FF_PROFILE_MPEG2_SS 2 +#define FF_PROFILE_MPEG2_SNR_SCALABLE 3 +#define FF_PROFILE_MPEG2_MAIN 4 +#define FF_PROFILE_MPEG2_SIMPLE 5 + +#define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag +#define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag + +#define FF_PROFILE_H264_BASELINE 66 +#define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED) +#define FF_PROFILE_H264_MAIN 77 +#define FF_PROFILE_H264_EXTENDED 88 +#define FF_PROFILE_H264_HIGH 100 +#define FF_PROFILE_H264_HIGH_10 110 +#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA) +#define FF_PROFILE_H264_HIGH_422 122 +#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA) +#define FF_PROFILE_H264_HIGH_444 144 +#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244 +#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA) +#define FF_PROFILE_H264_CAVLC_444 44 + +#define FF_PROFILE_VC1_SIMPLE 0 +#define FF_PROFILE_VC1_MAIN 1 +#define FF_PROFILE_VC1_COMPLEX 2 +#define FF_PROFILE_VC1_ADVANCED 3 + +#define FF_PROFILE_MPEG4_SIMPLE 0 +#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1 +#define FF_PROFILE_MPEG4_CORE 2 +#define FF_PROFILE_MPEG4_MAIN 3 +#define FF_PROFILE_MPEG4_N_BIT 4 +#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5 +#define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6 +#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7 +#define FF_PROFILE_MPEG4_HYBRID 8 +#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9 +#define FF_PROFILE_MPEG4_CORE_SCALABLE 10 +#define FF_PROFILE_MPEG4_ADVANCED_CODING 11 +#define FF_PROFILE_MPEG4_ADVANCED_CORE 12 +#define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13 +#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14 +#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15 + +#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 0 +#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 1 +#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 2 +#define FF_PROFILE_JPEG2000_DCINEMA_2K 3 +#define FF_PROFILE_JPEG2000_DCINEMA_4K 4 + + /** + * level + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int level; +#define FF_LEVEL_UNKNOWN -99 + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_loop_filter; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_idct; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_frame; + + /** + * Header containing style information for text subtitles. + * For SUBTITLE_ASS subtitle type, it should contain the whole ASS + * [Script Info] and [V4+ Styles] section, plus the [Events] line and + * the Format line following. It shouldn't include any Dialogue line. + * - encoding: Set/allocated/freed by user (before avcodec_open2()) + * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2()) + */ + uint8_t *subtitle_header; + int subtitle_header_size; + + /** + * Simulates errors in the bitstream to test error concealment. + * - encoding: Set by user. + * - decoding: unused + */ + int error_rate; + + /** + * Current packet as passed into the decoder, to avoid having + * to pass the packet into every function. Currently only valid + * inside lavc and get/release_buffer callbacks. + * - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts + * - encoding: unused + */ + AVPacket *pkt; + + /** + * VBV delay coded in the last frame (in periods of a 27 MHz clock). + * Used for compliant TS muxing. + * - encoding: Set by libavcodec. + * - decoding: unused. + */ + uint64_t vbv_delay; +} AVCodecContext; + +/** + * AVProfile. + */ +typedef struct AVProfile { + int profile; + const char *name; ///< short name for the profile +} AVProfile; + +typedef struct AVCodecDefault AVCodecDefault; + +struct AVSubtitle; + +/** + * AVCodec. + */ +typedef struct AVCodec { + /** + * Name of the codec implementation. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + * This is the primary way to find a codec from the user perspective. + */ + const char *name; + /** + * Descriptive name for the codec, meant to be more human readable than name. + * You should use the NULL_IF_CONFIG_SMALL() macro to define it. + */ + const char *long_name; + enum AVMediaType type; + enum AVCodecID id; + /** + * Codec capabilities. + * see CODEC_CAP_* + */ + int capabilities; + const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} + const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 + const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 + const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 + const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 + attribute_deprecated uint8_t max_lowres; ///< maximum value for lowres supported by the decoder + const AVClass *priv_class; ///< AVClass for the private context + const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavcodec and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + int priv_data_size; + struct AVCodec *next; + /** + * @name Frame-level threading support functions + * @{ + */ + /** + * If defined, called on thread contexts when they are created. + * If the codec allocates writable tables in init(), re-allocate them here. + * priv_data will be set to a copy of the original. + */ + int (*init_thread_copy)(AVCodecContext *); + /** + * Copy necessary context variables from a previous thread context to the current one. + * If not defined, the next thread will start automatically; otherwise, the codec + * must call ff_thread_finish_setup(). + * + * dst and src will (rarely) point to the same context, in which case memcpy should be skipped. + */ + int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src); + /** @} */ + + /** + * Private codec-specific defaults. + */ + const AVCodecDefault *defaults; + + /** + * Initialize codec static data, called from avcodec_register(). + */ + void (*init_static_data)(struct AVCodec *codec); + + int (*init)(AVCodecContext *); + int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, + const struct AVSubtitle *sub); + /** + * Encode data to an AVPacket. + * + * @param avctx codec context + * @param avpkt output AVPacket (may contain a user-provided buffer) + * @param[in] frame AVFrame containing the raw data to be encoded + * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a + * non-empty packet was returned in avpkt. + * @return 0 on success, negative error code on failure + */ + int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, + int *got_packet_ptr); + int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); + int (*close)(AVCodecContext *); + /** + * Flush buffers. + * Will be called when seeking + */ + void (*flush)(AVCodecContext *); +} AVCodec; + +/** + * AVHWAccel. + */ +typedef struct AVHWAccel { + /** + * Name of the hardware accelerated codec. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + */ + const char *name; + + /** + * Type of codec implemented by the hardware accelerator. + * + * See AVMEDIA_TYPE_xxx + */ + enum AVMediaType type; + + /** + * Codec implemented by the hardware accelerator. + * + * See AV_CODEC_ID_xxx + */ + enum AVCodecID id; + + /** + * Supported pixel format. + * + * Only hardware accelerated formats are supported here. + */ + enum AVPixelFormat pix_fmt; + + /** + * Hardware accelerated codec capabilities. + * see FF_HWACCEL_CODEC_CAP_* + */ + int capabilities; + + struct AVHWAccel *next; + + /** + * Called at the beginning of each frame or field picture. + * + * Meaningful frame information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * Note that buf can be NULL along with buf_size set to 0. + * Otherwise, this means the whole frame is available at this point. + * + * @param avctx the codec context + * @param buf the frame data buffer base + * @param buf_size the size of the frame in bytes + * @return zero if successful, a negative value otherwise + */ + int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); + + /** + * Callback for each slice. + * + * Meaningful slice information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * @param avctx the codec context + * @param buf the slice data buffer base + * @param buf_size the size of the slice in bytes + * @return zero if successful, a negative value otherwise + */ + int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); + + /** + * Called at the end of each frame or field picture. + * + * The whole picture is parsed at this point and can now be sent + * to the hardware accelerator. This function is mandatory. + * + * @param avctx the codec context + * @return zero if successful, a negative value otherwise + */ + int (*end_frame)(AVCodecContext *avctx); + + /** + * Size of HW accelerator private data. + * + * Private data is allocated with av_mallocz() before + * AVCodecContext.get_buffer() and deallocated after + * AVCodecContext.release_buffer(). + */ + int priv_data_size; +} AVHWAccel; + +/** + * @defgroup lavc_picture AVPicture + * + * Functions for working with AVPicture + * @{ + */ + +/** + * four components are given, that's all. + * the last component is alpha + */ +typedef struct AVPicture { + uint8_t *data[AV_NUM_DATA_POINTERS]; + int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line +} AVPicture; + +/** + * @} + */ + +#define AVPALETTE_SIZE 1024 +#define AVPALETTE_COUNT 256 + +enum AVSubtitleType { + SUBTITLE_NONE, + + SUBTITLE_BITMAP, ///< A bitmap, pict will be set + + /** + * Plain text, the text field must be set by the decoder and is + * authoritative. ass and pict fields may contain approximations. + */ + SUBTITLE_TEXT, + + /** + * Formatted text, the ass field must be set by the decoder and is + * authoritative. pict and text fields may contain approximations. + */ + SUBTITLE_ASS, +}; + +#define AV_SUBTITLE_FLAG_FORCED 0x00000001 + +typedef struct AVSubtitleRect { + int x; ///< top left corner of pict, undefined when pict is not set + int y; ///< top left corner of pict, undefined when pict is not set + int w; ///< width of pict, undefined when pict is not set + int h; ///< height of pict, undefined when pict is not set + int nb_colors; ///< number of colors in pict, undefined when pict is not set + + /** + * data+linesize for the bitmap of this subtitle. + * can be set for text/ass as well once they where rendered + */ + AVPicture pict; + enum AVSubtitleType type; + + char *text; ///< 0 terminated plain UTF-8 text + + /** + * 0 terminated ASS/SSA compatible event line. + * The pressentation of this is unaffected by the other values in this + * struct. + */ + char *ass; + int flags; +} AVSubtitleRect; + +typedef struct AVSubtitle { + uint16_t format; /* 0 = graphics */ + uint32_t start_display_time; /* relative to packet pts, in ms */ + uint32_t end_display_time; /* relative to packet pts, in ms */ + unsigned num_rects; + AVSubtitleRect **rects; + int64_t pts; ///< Same as packet pts, in AV_TIME_BASE +} AVSubtitle; + +/** + * If c is NULL, returns the first registered codec, + * if c is non-NULL, returns the next registered codec after c, + * or NULL if c is the last one. + */ +AVCodec *av_codec_next(const AVCodec *c); + +/** + * Return the LIBAVCODEC_VERSION_INT constant. + */ +unsigned avcodec_version(void); + +/** + * Return the libavcodec build-time configuration. + */ +const char *avcodec_configuration(void); + +/** + * Return the libavcodec license. + */ +const char *avcodec_license(void); + +/** + * Register the codec codec and initialize libavcodec. + * + * @warning either this function or avcodec_register_all() must be called + * before any other libavcodec functions. + * + * @see avcodec_register_all() + */ +void avcodec_register(AVCodec *codec); + +/** + * Register all the codecs, parsers and bitstream filters which were enabled at + * configuration time. If you do not call this function you can select exactly + * which formats you want to support, by using the individual registration + * functions. + * + * @see avcodec_register + * @see av_register_codec_parser + * @see av_register_bitstream_filter + */ +void avcodec_register_all(void); + +/** + * Allocate an AVCodecContext and set its fields to default values. The + * resulting struct can be deallocated by calling avcodec_close() on it followed + * by av_free(). + * + * @param codec if non-NULL, allocate private data and initialize defaults + * for the given codec. It is illegal to then call avcodec_open2() + * with a different codec. + * If NULL, then the codec-specific defaults won't be initialized, + * which may result in suboptimal default settings (this is + * important mainly for encoders, e.g. libx264). + * + * @return An AVCodecContext filled with default values or NULL on failure. + * @see avcodec_get_context_defaults + */ +AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); + +/** + * Set the fields of the given AVCodecContext to default values corresponding + * to the given codec (defaults may be codec-dependent). + * + * Do not call this function if a non-NULL codec has been passed + * to avcodec_alloc_context3() that allocated this AVCodecContext. + * If codec is non-NULL, it is illegal to call avcodec_open2() with a + * different codec on this AVCodecContext. + */ +int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); + +/** + * Get the AVClass for AVCodecContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *avcodec_get_class(void); + +/** + * Copy the settings of the source AVCodecContext into the destination + * AVCodecContext. The resulting destination codec context will be + * unopened, i.e. you are required to call avcodec_open2() before you + * can use this AVCodecContext to decode/encode video/audio data. + * + * @param dest target codec context, should be initialized with + * avcodec_alloc_context3(), but otherwise uninitialized + * @param src source codec context + * @return AVERROR() on error (e.g. memory allocation error), 0 on success + */ +int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); + +/** + * Allocate an AVFrame and set its fields to default values. The resulting + * struct must be freed using avcodec_free_frame(). + * + * @return An AVFrame filled with default values or NULL on failure. + * @see avcodec_get_frame_defaults + */ +AVFrame *avcodec_alloc_frame(void); + +/** + * Set the fields of the given AVFrame to default values. + * + * @param frame The AVFrame of which the fields should be set to default values. + */ +void avcodec_get_frame_defaults(AVFrame *frame); + +/** + * Free the frame and any dynamically allocated objects in it, + * e.g. extended_data. + * + * @param frame frame to be freed. The pointer will be set to NULL. + * + * @warning this function does NOT free the data buffers themselves + * (it does not know how, since they might have been allocated with + * a custom get_buffer()). + */ +void avcodec_free_frame(AVFrame **frame); + +/** + * Initialize the AVCodecContext to use the given AVCodec. Prior to using this + * function the context has to be allocated with avcodec_alloc_context3(). + * + * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), + * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for + * retrieving a codec. + * + * @warning This function is not thread safe! + * + * @code + * avcodec_register_all(); + * av_dict_set(&opts, "b", "2.5M", 0); + * codec = avcodec_find_decoder(AV_CODEC_ID_H264); + * if (!codec) + * exit(1); + * + * context = avcodec_alloc_context3(codec); + * + * if (avcodec_open2(context, codec, opts) < 0) + * exit(1); + * @endcode + * + * @param avctx The context to initialize. + * @param codec The codec to open this context for. If a non-NULL codec has been + * previously passed to avcodec_alloc_context3() or + * avcodec_get_context_defaults3() for this context, then this + * parameter MUST be either NULL or equal to the previously passed + * codec. + * @param options A dictionary filled with AVCodecContext and codec-private options. + * On return this object will be filled with options that were not found. + * + * @return zero on success, a negative value on error + * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), + * av_dict_set(), av_opt_find(). + */ +int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); + +/** + * Close a given AVCodecContext and free all the data associated with it + * (but not the AVCodecContext itself). + * + * Calling this function on an AVCodecContext that hasn't been opened will free + * the codec-specific data allocated in avcodec_alloc_context3() / + * avcodec_get_context_defaults3() with a non-NULL codec. Subsequent calls will + * do nothing. + */ +int avcodec_close(AVCodecContext *avctx); + +/** + * Free all allocated data in the given subtitle struct. + * + * @param sub AVSubtitle to free. + */ +void avsubtitle_free(AVSubtitle *sub); + +/** + * @} + */ + +/** + * @addtogroup lavc_packet + * @{ + */ + +#if FF_API_DESTRUCT_PACKET +/** + * Default packet destructor. + * @deprecated use the AVBuffer API instead + */ +attribute_deprecated +void av_destruct_packet(AVPacket *pkt); +#endif + +/** + * Initialize optional fields of a packet with default values. + * + * Note, this does not touch the data and size members, which have to be + * initialized separately. + * + * @param pkt packet + */ +void av_init_packet(AVPacket *pkt); + +/** + * Allocate the payload of a packet and initialize its fields with + * default values. + * + * @param pkt packet + * @param size wanted payload size + * @return 0 if OK, AVERROR_xxx otherwise + */ +int av_new_packet(AVPacket *pkt, int size); + +/** + * Reduce packet size, correctly zeroing padding + * + * @param pkt packet + * @param size new size + */ +void av_shrink_packet(AVPacket *pkt, int size); + +/** + * Increase packet size, correctly zeroing padding + * + * @param pkt packet + * @param grow_by number of bytes by which to increase the size of the packet + */ +int av_grow_packet(AVPacket *pkt, int grow_by); + +/** + * Initialize a reference-counted packet from av_malloc()ed data. + * + * @param pkt packet to be initialized. This function will set the data, size, + * buf and destruct fields, all others are left untouched. + * @param data Data allocated by av_malloc() to be used as packet data. If this + * function returns successfully, the data is owned by the underlying AVBuffer. + * The caller may not access the data through other means. + * @param size size of data in bytes, without the padding. I.e. the full buffer + * size is assumed to be size + FF_INPUT_BUFFER_PADDING_SIZE. + * + * @return 0 on success, a negative AVERROR on error + */ +int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size); + +/** + * @warning This is a hack - the packet memory allocation stuff is broken. The + * packet is allocated if it was not really allocated. + */ +int av_dup_packet(AVPacket *pkt); + +/** + * Free a packet. + * + * @param pkt packet to free + */ +void av_free_packet(AVPacket *pkt); + +/** + * Allocate new information of a packet. + * + * @param pkt packet + * @param type side information type + * @param size side information size + * @return pointer to fresh allocated data or NULL otherwise + */ +uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, + int size); + +/** + * Shrink the already allocated side data buffer + * + * @param pkt packet + * @param type side information type + * @param size new side information size + * @return 0 on success, < 0 on failure + */ +int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, + int size); + +/** + * Get side information from packet. + * + * @param pkt packet + * @param type desired side information type + * @param size pointer for side information size to store (optional) + * @return pointer to data if present or NULL otherwise + */ +uint8_t* av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, + int *size); + +/** + * Convenience function to free all the side data stored. + * All the other fields stay untouched. + * + * @param pkt packet + */ +void av_packet_free_side_data(AVPacket *pkt); + +/** + * Setup a new reference to the data described by a given packet + * + * If src is reference-counted, setup dst as a new reference to the + * buffer in src. Otherwise allocate a new buffer in dst and copy the + * data from src into it. + * + * All the other fields are copied from src. + * + * @see av_packet_unref + * + * @param dst Destination packet + * @param src Source packet + * + * @return 0 on success, a negative AVERROR on error. + */ +int av_packet_ref(AVPacket *dst, AVPacket *src); + +/** + * Wipe the packet. + * + * Unreference the buffer referenced by the packet and reset the + * remaining packet fields to their default values. + * + * @param pkt The packet to be unreferenced. + */ +void av_packet_unref(AVPacket *pkt); + +/** + * Move every field in src to dst and reset src. + * + * @see av_packet_unref + * + * @param src Source packet, will be reset + * @param dst Destination packet + */ +void av_packet_move_ref(AVPacket *dst, AVPacket *src); + +/** + * Copy only "properties" fields from src to dst. + * + * Properties for the purpose of this function are all the fields + * beside those related to the packet data (buf, data, size) + * + * @param dst Destination packet + * @param src Source packet + * + * @return 0 on success AVERROR on failure. + * + */ +int av_packet_copy_props(AVPacket *dst, const AVPacket *src); + +/** + * @} + */ + +/** + * @addtogroup lavc_decoding + * @{ + */ + +/** + * Find a registered decoder with a matching codec ID. + * + * @param id AVCodecID of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder(enum AVCodecID id); + +/** + * Find a registered decoder with the specified name. + * + * @param name name of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder_by_name(const char *name); + +#if FF_API_GET_BUFFER +attribute_deprecated int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); +attribute_deprecated void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); +attribute_deprecated int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); +#endif + +/** + * The default callback for AVCodecContext.get_buffer2(). It is made public so + * it can be called by custom get_buffer2() implementations for decoders without + * CODEC_CAP_DR1 set. + */ +int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags); + +/** + * Return the amount of padding in pixels which the get_buffer callback must + * provide around the edge of the image for codecs which do not have the + * CODEC_FLAG_EMU_EDGE flag. + * + * @return Required padding in pixels. + */ +unsigned avcodec_get_edge_width(void); + +/** + * Modify width and height values so that they will result in a memory + * buffer that is acceptable for the codec if you do not use any horizontal + * padding. + * + * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased + * according to avcodec_get_edge_width() before. + */ +void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); + +/** + * Modify width and height values so that they will result in a memory + * buffer that is acceptable for the codec if you also ensure that all + * line sizes are a multiple of the respective linesize_align[i]. + * + * May only be used if a codec with CODEC_CAP_DR1 has been opened. + * If CODEC_FLAG_EMU_EDGE is not set, the dimensions must have been increased + * according to avcodec_get_edge_width() before. + */ +void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, + int linesize_align[AV_NUM_DATA_POINTERS]); + +/** + * Decode the audio frame of size avpkt->size from avpkt->data into frame. + * + * Some decoders may support multiple frames in a single AVPacket. Such + * decoders would then just decode the first frame. In this case, + * avcodec_decode_audio4 has to be called again with an AVPacket containing + * the remaining data in order to decode the second frame, etc... + * Even if no frames are returned, the packet needs to be fed to the decoder + * with remaining data until it is completely consumed or an error occurs. + * + * @warning The input buffer, avpkt->data must be FF_INPUT_BUFFER_PADDING_SIZE + * larger than the actual read bytes because some optimized bitstream + * readers read 32 or 64 bits at once and could read over the end. + * + * @note You might have to align the input buffer. The alignment requirements + * depend on the CPU and the decoder. + * + * @param avctx the codec context + * @param[out] frame The AVFrame in which to store decoded audio samples. + * The decoder will allocate a buffer for the decoded frame by + * calling the AVCodecContext.get_buffer2() callback. + * When AVCodecContext.refcounted_frames is set to 1, the frame is + * reference counted and the returned reference belongs to the + * caller. The caller must release the frame using av_frame_unref() + * when the frame is no longer needed. The caller may safely write + * to the frame if av_frame_is_writable() returns 1. + * When AVCodecContext.refcounted_frames is set to 0, the returned + * reference belongs to the decoder and is valid only until the + * next call to this function or until closing the decoder. + * The caller may not write to it. + * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is + * non-zero. + * @param[in] avpkt The input AVPacket containing the input buffer. + * At least avpkt->data and avpkt->size should be set. Some + * decoders might also require additional fields to be set. + * @return A negative error code is returned if an error occurred during + * decoding, otherwise the number of bytes consumed from the input + * AVPacket is returned. + */ +int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, + int *got_frame_ptr, AVPacket *avpkt); + +/** + * Decode the video frame of size avpkt->size from avpkt->data into picture. + * Some decoders may support multiple frames in a single AVPacket, such + * decoders would then just decode the first frame. + * + * @warning The input buffer must be FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer buf should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @note You might have to align the input buffer avpkt->data. + * The alignment requirements depend on the CPU: on some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. + * + * In practice, avpkt->data should have 4 byte alignment at minimum. + * + * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay + * between input and output, these need to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to return the remaining frames. + * + * @param avctx the codec context + * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * Use av_frame_alloc() to get an AVFrame. The codec will + * allocate memory for the actual bitmap by calling the + * AVCodecContext.get_buffer2() callback. + * When AVCodecContext.refcounted_frames is set to 1, the frame is + * reference counted and the returned reference belongs to the + * caller. The caller must release the frame using av_frame_unref() + * when the frame is no longer needed. The caller may safely write + * to the frame if av_frame_is_writable() returns 1. + * When AVCodecContext.refcounted_frames is set to 0, the returned + * reference belongs to the decoder and is valid only until the + * next call to this function or until closing the decoder. The + * caller may not write to it. + * + * @param[in] avpkt The input AVpacket containing the input buffer. + * You can create such packet with av_init_packet() and by then setting + * data and size, some decoders might in addition need other fields like + * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least + * fields possible. + * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + */ +int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + AVPacket *avpkt); + +/** + * Decode a subtitle message. + * Return a negative value on error, otherwise return the number of bytes used. + * If no subtitle could be decompressed, got_sub_ptr is zero. + * Otherwise, the subtitle is stored in *sub. + * Note that CODEC_CAP_DR1 is not available for subtitle codecs. This is for + * simplicity, because the performance difference is expect to be negligible + * and reusing a get_buffer written for video codecs would probably perform badly + * due to a potentially very different allocation pattern. + * + * @param avctx the codec context + * @param[out] sub The AVSubtitle in which the decoded subtitle will be stored, must be + freed with avsubtitle_free if *got_sub_ptr is set. + * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. + * @param[in] avpkt The input AVPacket containing the input buffer. + */ +int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + AVPacket *avpkt); + +/** + * @defgroup lavc_parsing Frame parsing + * @{ + */ + +enum AVPictureStructure { + AV_PICTURE_STRUCTURE_UNKNOWN, //< unknown + AV_PICTURE_STRUCTURE_TOP_FIELD, //< coded as top field + AV_PICTURE_STRUCTURE_BOTTOM_FIELD, //< coded as bottom field + AV_PICTURE_STRUCTURE_FRAME, //< coded as frame +}; + +typedef struct AVCodecParserContext { + void *priv_data; + struct AVCodecParser *parser; + int64_t frame_offset; /* offset of the current frame */ + int64_t cur_offset; /* current offset + (incremented by each av_parser_parse()) */ + int64_t next_frame_offset; /* offset of the next frame */ + /* video info */ + int pict_type; /* XXX: Put it back in AVCodecContext. */ + /** + * This field is used for proper frame duration computation in lavf. + * It signals, how much longer the frame duration of the current frame + * is compared to normal frame duration. + * + * frame_duration = (1 + repeat_pict) * time_base + * + * It is used by codecs like H.264 to display telecined material. + */ + int repeat_pict; /* XXX: Put it back in AVCodecContext. */ + int64_t pts; /* pts of the current frame */ + int64_t dts; /* dts of the current frame */ + + /* private data */ + int64_t last_pts; + int64_t last_dts; + int fetch_timestamp; + +#define AV_PARSER_PTS_NB 4 + int cur_frame_start_index; + int64_t cur_frame_offset[AV_PARSER_PTS_NB]; + int64_t cur_frame_pts[AV_PARSER_PTS_NB]; + int64_t cur_frame_dts[AV_PARSER_PTS_NB]; + + int flags; +#define PARSER_FLAG_COMPLETE_FRAMES 0x0001 +#define PARSER_FLAG_ONCE 0x0002 +/// Set if the parser has a valid file offset +#define PARSER_FLAG_FETCHED_OFFSET 0x0004 + + int64_t offset; ///< byte offset from starting packet start + int64_t cur_frame_end[AV_PARSER_PTS_NB]; + + /** + * Set by parser to 1 for key frames and 0 for non-key frames. + * It is initialized to -1, so if the parser doesn't set this flag, + * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames + * will be used. + */ + int key_frame; + + /** + * Time difference in stream time base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current frame. + * This field has no meaning if the packet does not have AV_PKT_FLAG_KEY + * set. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + */ + int64_t convergence_duration; + + // Timestamp generation support: + /** + * Synchronization point for start of timestamp generation. + * + * Set to >0 for sync point, 0 for no sync point and <0 for undefined + * (default). + * + * For example, this corresponds to presence of H.264 buffering period + * SEI message. + */ + int dts_sync_point; + + /** + * Offset of the current timestamp against last timestamp sync point in + * units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain a valid timestamp offset. + * + * Note that the timestamp of sync point has usually a nonzero + * dts_ref_dts_delta, which refers to the previous sync point. Offset of + * the next frame after timestamp sync point will be usually 1. + * + * For example, this corresponds to H.264 cpb_removal_delay. + */ + int dts_ref_dts_delta; + + /** + * Presentation delay of current frame in units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain valid non-negative timestamp delta (presentation time of a frame + * must not lie in the past). + * + * This delay represents the difference between decoding and presentation + * time of the frame. + * + * For example, this corresponds to H.264 dpb_output_delay. + */ + int pts_dts_delta; + + /** + * Position of the packet in file. + * + * Analogous to cur_frame_pts/dts + */ + int64_t cur_frame_pos[AV_PARSER_PTS_NB]; + + /** + * Byte position of currently parsed frame in stream. + */ + int64_t pos; + + /** + * Previous frame byte position. + */ + int64_t last_pos; + + /** + * Duration of the current frame. + * For audio, this is in units of 1 / AVCodecContext.sample_rate. + * For all other types, this is in units of AVCodecContext.time_base. + */ + int duration; + + enum AVFieldOrder field_order; + + /** + * Indicate whether a picture is coded as a frame, top field or bottom field. + * + * For example, H.264 field_pic_flag equal to 0 corresponds to + * AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag + * equal to 1 and bottom_field_flag equal to 0 corresponds to + * AV_PICTURE_STRUCTURE_TOP_FIELD. + */ + enum AVPictureStructure picture_structure; + + /** + * Picture number incremented in presentation or output order. + * This field may be reinitialized at the first picture of a new sequence. + * + * For example, this corresponds to H.264 PicOrderCnt. + */ + int output_picture_number; +} AVCodecParserContext; + +typedef struct AVCodecParser { + int codec_ids[5]; /* several codec IDs are permitted */ + int priv_data_size; + int (*parser_init)(AVCodecParserContext *s); + int (*parser_parse)(AVCodecParserContext *s, + AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size); + void (*parser_close)(AVCodecParserContext *s); + int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); + struct AVCodecParser *next; +} AVCodecParser; + +AVCodecParser *av_parser_next(AVCodecParser *c); + +void av_register_codec_parser(AVCodecParser *parser); +AVCodecParserContext *av_parser_init(int codec_id); + +/** + * Parse a packet. + * + * @param s parser context. + * @param avctx codec context. + * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished. + * @param poutbuf_size set to size of parsed buffer or zero if not yet finished. + * @param buf input buffer. + * @param buf_size input length, to signal EOF, this should be 0 (so that the last frame can be output). + * @param pts input presentation timestamp. + * @param dts input decoding timestamp. + * @param pos input byte position in stream. + * @return the number of bytes of the input bitstream used. + * + * Example: + * @code + * while(in_len){ + * len = av_parser_parse2(myparser, AVCodecContext, &data, &size, + * in_data, in_len, + * pts, dts, pos); + * in_data += len; + * in_len -= len; + * + * if(size) + * decode_frame(data, size); + * } + * @endcode + */ +int av_parser_parse2(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, + int64_t pts, int64_t dts, + int64_t pos); + +/** + * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed + * @deprecated use AVBitstreamFilter + */ +int av_parser_change(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); +void av_parser_close(AVCodecParserContext *s); + +/** + * @} + * @} + */ + +/** + * @addtogroup lavc_encoding + * @{ + */ + +/** + * Find a registered encoder with a matching codec ID. + * + * @param id AVCodecID of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder(enum AVCodecID id); + +/** + * Find a registered encoder with the specified name. + * + * @param name name of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder_by_name(const char *name); + +/** + * Encode a frame of audio. + * + * Takes input samples from frame and writes the next output packet, if + * available, to avpkt. The output packet does not necessarily contain data for + * the most recent frame, as encoders can delay, split, and combine input frames + * internally as needed. + * + * @param avctx codec context + * @param avpkt output AVPacket. + * The user can supply an output buffer by setting + * avpkt->data and avpkt->size prior to calling the + * function, but if the size of the user-provided data is not + * large enough, encoding will fail. All other AVPacket fields + * will be reset by the encoder using av_init_packet(). If + * avpkt->data is NULL, the encoder will allocate it. + * The encoder will set avpkt->size to the size of the + * output packet. + * + * If this function fails or produces no output, avpkt will be + * freed using av_free_packet() (i.e. avpkt->destruct will be + * called to free the user supplied buffer). + * @param[in] frame AVFrame containing the raw audio data to be encoded. + * May be NULL when flushing an encoder that has the + * CODEC_CAP_DELAY capability set. + * If CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame + * can have any number of samples. + * If it is not set, frame->nb_samples must be equal to + * avctx->frame_size for all frames except the last. + * The final frame may be smaller than avctx->frame_size. + * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the + * output packet is non-empty, and to 0 if it is + * empty. If the function returns an error, the + * packet can be assumed to be invalid, and the + * value of got_packet_ptr is undefined and should + * not be used. + * @return 0 on success, negative error code on failure + */ +int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet_ptr); + +/** + * Encode a frame of video. + * + * Takes input raw video data from frame and writes the next output packet, if + * available, to avpkt. The output packet does not necessarily contain data for + * the most recent frame, as encoders can delay and reorder input frames + * internally as needed. + * + * @param avctx codec context + * @param avpkt output AVPacket. + * The user can supply an output buffer by setting + * avpkt->data and avpkt->size prior to calling the + * function, but if the size of the user-provided data is not + * large enough, encoding will fail. All other AVPacket fields + * will be reset by the encoder using av_init_packet(). If + * avpkt->data is NULL, the encoder will allocate it. + * The encoder will set avpkt->size to the size of the + * output packet. The returned data (if any) belongs to the + * caller, he is responsible for freeing it. + * + * If this function fails or produces no output, avpkt will be + * freed using av_free_packet() (i.e. avpkt->destruct will be + * called to free the user supplied buffer). + * @param[in] frame AVFrame containing the raw video data to be encoded. + * May be NULL when flushing an encoder that has the + * CODEC_CAP_DELAY capability set. + * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the + * output packet is non-empty, and to 0 if it is + * empty. If the function returns an error, the + * packet can be assumed to be invalid, and the + * value of got_packet_ptr is undefined and should + * not be used. + * @return 0 on success, negative error code on failure + */ +int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet_ptr); + +int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVSubtitle *sub); + + +/** + * @} + */ + +/** + * @addtogroup lavc_picture + * @{ + */ + +/** + * Allocate memory for a picture. Call avpicture_free() to free it. + * + * @see avpicture_fill() + * + * @param picture the picture to be filled in + * @param pix_fmt the format of the picture + * @param width the width of the picture + * @param height the height of the picture + * @return zero if successful, a negative value if not + */ +int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height); + +/** + * Free a picture previously allocated by avpicture_alloc(). + * The data buffer used by the AVPicture is freed, but the AVPicture structure + * itself is not. + * + * @param picture the AVPicture to be freed + */ +void avpicture_free(AVPicture *picture); + +/** + * Fill in the AVPicture fields. + * The fields of the given AVPicture are filled in by using the 'ptr' address + * which points to the image data buffer. Depending on the specified picture + * format, one or multiple image data pointers and line sizes will be set. + * If a planar format is specified, several pointers will be set pointing to + * the different picture planes and the line sizes of the different planes + * will be stored in the lines_sizes array. + * Call with ptr == NULL to get the required size for the ptr buffer. + * + * To allocate the buffer and fill in the AVPicture fields in one call, + * use avpicture_alloc(). + * + * @param picture AVPicture whose fields are to be filled in + * @param ptr Buffer which will contain or contains the actual image data + * @param pix_fmt The format in which the picture data is stored. + * @param width the width of the image in pixels + * @param height the height of the image in pixels + * @return size of the image data in bytes + */ +int avpicture_fill(AVPicture *picture, uint8_t *ptr, + enum AVPixelFormat pix_fmt, int width, int height); + +/** + * Copy pixel data from an AVPicture into a buffer. + * The data is stored compactly, without any gaps for alignment or padding + * which may be applied by avpicture_fill(). + * + * @see avpicture_get_size() + * + * @param[in] src AVPicture containing image data + * @param[in] pix_fmt The format in which the picture data is stored. + * @param[in] width the width of the image in pixels. + * @param[in] height the height of the image in pixels. + * @param[out] dest A buffer into which picture data will be copied. + * @param[in] dest_size The size of 'dest'. + * @return The number of bytes written to dest, or a negative value (error code) on error. + */ +int avpicture_layout(const AVPicture* src, enum AVPixelFormat pix_fmt, + int width, int height, + unsigned char *dest, int dest_size); + +/** + * Calculate the size in bytes that a picture of the given width and height + * would occupy if stored in the given picture format. + * Note that this returns the size of a compact representation as generated + * by avpicture_layout(), which can be smaller than the size required for e.g. + * avpicture_fill(). + * + * @param pix_fmt the given picture format + * @param width the width of the image + * @param height the height of the image + * @return Image data size in bytes or -1 on error (e.g. too large dimensions). + */ +int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); + +#if FF_API_DEINTERLACE +/** + * deinterlace - if not supported return -1 + * + * @deprecated - use yadif (in libavfilter) instead + */ +attribute_deprecated +int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, + enum AVPixelFormat pix_fmt, int width, int height); +#endif +/** + * Copy image src to dst. Wraps av_picture_data_copy() above. + */ +void av_picture_copy(AVPicture *dst, const AVPicture *src, + enum AVPixelFormat pix_fmt, int width, int height); + +/** + * Crop image top and left side. + */ +int av_picture_crop(AVPicture *dst, const AVPicture *src, + enum AVPixelFormat pix_fmt, int top_band, int left_band); + +/** + * Pad image. + */ +int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt, + int padtop, int padbottom, int padleft, int padright, int *color); + +/** + * @} + */ + +/** + * @defgroup lavc_misc Utility functions + * @ingroup libavc + * + * Miscellaneous utility functions related to both encoding and decoding + * (or neither). + * @{ + */ + +/** + * @defgroup lavc_misc_pixfmt Pixel formats + * + * Functions for working with pixel formats. + * @{ + */ + +/** + * @deprecated Use av_pix_fmt_get_chroma_sub_sample + */ + +void attribute_deprecated avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift); + +/** + * Return a value representing the fourCC code associated to the + * pixel format pix_fmt, or 0 if no associated fourCC code can be + * found. + */ +unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt); + +#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ +#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ +#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ +#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ +#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ +#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ + +/** + * Compute what kind of losses will occur when converting from one specific + * pixel format to another. + * When converting from one pixel format to another, information loss may occur. + * For example, when converting from RGB24 to GRAY, the color information will + * be lost. Similarly, other losses occur when converting from some formats to + * other formats. These losses can involve loss of chroma, but also loss of + * resolution, loss of color depth, loss due to the color space conversion, loss + * of the alpha bits or loss due to color quantization. + * avcodec_get_fix_fmt_loss() informs you about the various types of losses + * which will occur when converting from one pixel format to another. + * + * @param[in] dst_pix_fmt destination pixel format + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @return Combination of flags informing you what kind of losses will occur. + */ +int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, + int has_alpha); + +/** + * Find the best pixel format to convert to given a certain source pixel + * format. When converting from one pixel format to another, information loss + * may occur. For example, when converting from RGB24 to GRAY, the color + * information will be lost. Similarly, other losses occur when converting from + * some formats to other formats. avcodec_find_best_pix_fmt2() searches which of + * the given pixel formats should be used to suffer the least amount of loss. + * The pixel formats from which it chooses one, are determined by the + * pix_fmt_list parameter. + * + * + * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. + * @return The best pixel format to convert to or -1 if none was found. + */ +enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat *pix_fmt_list, + enum AVPixelFormat src_pix_fmt, + int has_alpha, int *loss_ptr); + +enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt); + +/** + * @} + */ + +void avcodec_set_dimensions(AVCodecContext *s, int width, int height); + +/** + * Put a string representing the codec tag codec_tag in buf. + * + * @param buf_size size in bytes of buf + * @return the length of the string that would have been generated if + * enough space had been available, excluding the trailing null + */ +size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag); + +void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); + +/** + * Return a name for the specified profile, if available. + * + * @param codec the codec that is searched for the given profile + * @param profile the profile value for which a name is requested + * @return A name for the profile if found, NULL otherwise. + */ +const char *av_get_profile_name(const AVCodec *codec, int profile); + +int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); +int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); +//FIXME func typedef + +/** + * Fill audio frame data and linesize. + * AVFrame extended_data channel pointers are allocated if necessary for + * planar audio. + * + * @param frame the AVFrame + * frame->nb_samples must be set prior to calling the + * function. This function fills in frame->data, + * frame->extended_data, frame->linesize[0]. + * @param nb_channels channel count + * @param sample_fmt sample format + * @param buf buffer to use for frame data + * @param buf_size size of buffer + * @param align plane size sample alignment (0 = default) + * @return 0 on success, negative error code on failure + */ +int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, + enum AVSampleFormat sample_fmt, const uint8_t *buf, + int buf_size, int align); + +/** + * Flush buffers, should be called when seeking or when switching to a different stream. + */ +void avcodec_flush_buffers(AVCodecContext *avctx); + +/** + * Return codec bits per sample. + * + * @param[in] codec_id the codec + * @return Number of bits per sample or zero if unknown for the given codec. + */ +int av_get_bits_per_sample(enum AVCodecID codec_id); + +/** + * Return codec bits per sample. + * Only return non-zero if the bits per sample is exactly correct, not an + * approximation. + * + * @param[in] codec_id the codec + * @return Number of bits per sample or zero if unknown for the given codec. + */ +int av_get_exact_bits_per_sample(enum AVCodecID codec_id); + +/** + * Return audio frame duration. + * + * @param avctx codec context + * @param frame_bytes size of the frame, or 0 if unknown + * @return frame duration, in samples, if known. 0 if not able to + * determine. + */ +int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes); + + +typedef struct AVBitStreamFilterContext { + void *priv_data; + struct AVBitStreamFilter *filter; + AVCodecParserContext *parser; + struct AVBitStreamFilterContext *next; +} AVBitStreamFilterContext; + + +typedef struct AVBitStreamFilter { + const char *name; + int priv_data_size; + int (*filter)(AVBitStreamFilterContext *bsfc, + AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); + void (*close)(AVBitStreamFilterContext *bsfc); + struct AVBitStreamFilter *next; +} AVBitStreamFilter; + +void av_register_bitstream_filter(AVBitStreamFilter *bsf); +AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); +int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, + AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); +void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); + +AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); + +/* memory */ + +/** + * Reallocate the given block if it is not large enough, otherwise do nothing. + * + * @see av_realloc + */ +void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); + +/** + * Allocate a buffer, reusing the given one if large enough. + * + * Contrary to av_fast_realloc the current buffer contents might not be + * preserved and on error the old buffer is freed, thus no special + * handling to avoid memleaks is necessary. + * + * @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer + * @param size size of the buffer *ptr points to + * @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and + * *size 0 if an error occurred. + */ +void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); + +/** + * Allocate a buffer with padding, reusing the given one if large enough. + * + * Same behaviour av_fast_malloc but the buffer has additional + * FF_INPUT_PADDING_SIZE at the end which will always memset to 0. + * + */ +void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size); + +/** + * Encode extradata length to a buffer. Used by xiph codecs. + * + * @param s buffer to write to; must be at least (v/255+1) bytes long + * @param v size of extradata in bytes + * @return number of bytes written to the buffer. + */ +unsigned int av_xiphlacing(unsigned char *s, unsigned int v); + +#if FF_API_MISSING_SAMPLE +/** + * Log a generic warning message about a missing feature. This function is + * intended to be used internally by Libav (libavcodec, libavformat, etc.) + * only, and would normally not be used by applications. + * @param[in] avc a pointer to an arbitrary struct of which the first field is + * a pointer to an AVClass struct + * @param[in] feature string containing the name of the missing feature + * @param[in] want_sample indicates if samples are wanted which exhibit this feature. + * If want_sample is non-zero, additional verbage will be added to the log + * message which tells the user how to report samples to the development + * mailing list. + * @deprecated Use avpriv_report_missing_feature() instead. + */ +attribute_deprecated +void av_log_missing_feature(void *avc, const char *feature, int want_sample); + +/** + * Log a generic warning message asking for a sample. This function is + * intended to be used internally by Libav (libavcodec, libavformat, etc.) + * only, and would normally not be used by applications. + * @param[in] avc a pointer to an arbitrary struct of which the first field is + * a pointer to an AVClass struct + * @param[in] msg string containing an optional message, or NULL if no message + * @deprecated Use avpriv_request_sample() instead. + */ +attribute_deprecated +void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3); +#endif /* FF_API_MISSING_SAMPLE */ + +/** + * Register the hardware accelerator hwaccel. + */ +void av_register_hwaccel(AVHWAccel *hwaccel); + +/** + * If hwaccel is NULL, returns the first registered hardware accelerator, + * if hwaccel is non-NULL, returns the next registered hardware accelerator + * after hwaccel, or NULL if hwaccel is the last one. + */ +AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel); + + +/** + * Lock operation used by lockmgr + */ +enum AVLockOp { + AV_LOCK_CREATE, ///< Create a mutex + AV_LOCK_OBTAIN, ///< Lock the mutex + AV_LOCK_RELEASE, ///< Unlock the mutex + AV_LOCK_DESTROY, ///< Free mutex resources +}; + +/** + * Register a user provided lock manager supporting the operations + * specified by AVLockOp. mutex points to a (void *) where the + * lockmgr should store/get a pointer to a user allocated mutex. It's + * NULL upon AV_LOCK_CREATE and != NULL for all other ops. + * + * @param cb User defined callback. Note: Libav may invoke calls to this + * callback during the call to av_lockmgr_register(). + * Thus, the application must be prepared to handle that. + * If cb is set to NULL the lockmgr will be unregistered. + * Also note that during unregistration the previously registered + * lockmgr callback may also be invoked. + */ +int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); + +/** + * Get the type of the given codec. + */ +enum AVMediaType avcodec_get_type(enum AVCodecID codec_id); + +/** + * @return a positive value if s is open (i.e. avcodec_open2() was called on it + * with no corresponding avcodec_close()), 0 otherwise. + */ +int avcodec_is_open(AVCodecContext *s); + +/** + * @return a non-zero number if codec is an encoder, zero otherwise + */ +int av_codec_is_encoder(const AVCodec *codec); + +/** + * @return a non-zero number if codec is a decoder, zero otherwise + */ +int av_codec_is_decoder(const AVCodec *codec); + +/** + * @return descriptor for given codec ID or NULL if no descriptor exists. + */ +const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id); + +/** + * Iterate over all codec descriptors known to libavcodec. + * + * @param prev previous descriptor. NULL to get the first descriptor. + * + * @return next descriptor or NULL after the last descriptor + */ +const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev); + +/** + * @return codec descriptor with the given name or NULL if no such descriptor + * exists. + */ +const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name); + +/** + * @} + */ + +#endif /* AVCODEC_AVCODEC_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/avfft.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/avfft.h new file mode 100644 index 000000000..b89618258 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/avfft.h @@ -0,0 +1,116 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AVFFT_H +#define AVCODEC_AVFFT_H + +/** + * @file + * @ingroup lavc_fft + * FFT functions + */ + +/** + * @defgroup lavc_fft FFT functions + * @ingroup lavc_misc + * + * @{ + */ + +typedef float FFTSample; + +typedef struct FFTComplex { + FFTSample re, im; +} FFTComplex; + +typedef struct FFTContext FFTContext; + +/** + * Set up a complex FFT. + * @param nbits log2 of the length of the input array + * @param inverse if 0 perform the forward transform, if 1 perform the inverse + */ +FFTContext *av_fft_init(int nbits, int inverse); + +/** + * Do the permutation needed BEFORE calling ff_fft_calc(). + */ +void av_fft_permute(FFTContext *s, FFTComplex *z); + +/** + * Do a complex FFT with the parameters defined in av_fft_init(). The + * input data must be permuted before. No 1.0/sqrt(n) normalization is done. + */ +void av_fft_calc(FFTContext *s, FFTComplex *z); + +void av_fft_end(FFTContext *s); + +FFTContext *av_mdct_init(int nbits, int inverse, double scale); +void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input); +void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); +void av_mdct_end(FFTContext *s); + +/* Real Discrete Fourier Transform */ + +enum RDFTransformType { + DFT_R2C, + IDFT_C2R, + IDFT_R2C, + DFT_C2R, +}; + +typedef struct RDFTContext RDFTContext; + +/** + * Set up a real FFT. + * @param nbits log2 of the length of the input array + * @param trans the type of transform + */ +RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans); +void av_rdft_calc(RDFTContext *s, FFTSample *data); +void av_rdft_end(RDFTContext *s); + +/* Discrete Cosine Transform */ + +typedef struct DCTContext DCTContext; + +enum DCTTransformType { + DCT_II = 0, + DCT_III, + DCT_I, + DST_I, +}; + +/** + * Set up DCT. + * @param nbits size of the input array: + * (1 << nbits) for DCT-II, DCT-III and DST-I + * (1 << nbits) + 1 for DCT-I + * + * @note the first element of the input of DST-I is ignored + */ +DCTContext *av_dct_init(int nbits, enum DCTTransformType type); +void av_dct_calc(DCTContext *s, FFTSample *data); +void av_dct_end (DCTContext *s); + +/** + * @} + */ + +#endif /* AVCODEC_AVFFT_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/dxva2.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/dxva2.h new file mode 100644 index 000000000..d161eb9f5 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/dxva2.h @@ -0,0 +1,88 @@ +/* + * DXVA2 HW acceleration + * + * copyright (c) 2009 Laurent Aimar + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_DXVA_H +#define AVCODEC_DXVA_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_dxva2 + * Public libavcodec DXVA2 header. + */ + +#define _WIN32_WINNT 0x0600 +#include +#include +#include + +/** + * @defgroup lavc_codec_hwaccel_dxva2 DXVA2 + * @ingroup lavc_codec_hwaccel + * + * @{ + */ + +#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards + +/** + * This structure is used to provides the necessary configurations and data + * to the DXVA2 Libav HWAccel implementation. + * + * The application must make it available as AVCodecContext.hwaccel_context. + */ +struct dxva_context { + /** + * DXVA2 decoder object + */ + IDirectXVideoDecoder *decoder; + + /** + * DXVA2 configuration used to create the decoder + */ + const DXVA2_ConfigPictureDecode *cfg; + + /** + * The number of surface in the surface array + */ + unsigned surface_count; + + /** + * The array of Direct3D surfaces used to create the decoder + */ + LPDIRECT3DSURFACE9 *surface; + + /** + * A bit field configuring the workarounds needed for using the decoder + */ + uint64_t workaround; + + /** + * Private to the Libav AVHWAccel implementation + */ + unsigned report_id; +}; + +/** + * @} + */ + +#endif /* AVCODEC_DXVA_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vaapi.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vaapi.h new file mode 100644 index 000000000..39e88259d --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vaapi.h @@ -0,0 +1,173 @@ +/* + * Video Acceleration API (shared data between Libav and the video player) + * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1 + * + * Copyright (C) 2008-2009 Splitted-Desktop Systems + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VAAPI_H +#define AVCODEC_VAAPI_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_vaapi + * Public libavcodec VA API header. + */ + +#include + +/** + * @defgroup lavc_codec_hwaccel_vaapi VA API Decoding + * @ingroup lavc_codec_hwaccel + * @{ + */ + +/** + * This structure is used to share data between the Libav library and + * the client video application. + * This shall be zero-allocated and available as + * AVCodecContext.hwaccel_context. All user members can be set once + * during initialization or through each AVCodecContext.get_buffer() + * function call. In any case, they must be valid prior to calling + * decoding functions. + */ +struct vaapi_context { + /** + * Window system dependent data + * + * - encoding: unused + * - decoding: Set by user + */ + void *display; + + /** + * Configuration ID + * + * - encoding: unused + * - decoding: Set by user + */ + uint32_t config_id; + + /** + * Context ID (video decode pipeline) + * + * - encoding: unused + * - decoding: Set by user + */ + uint32_t context_id; + + /** + * VAPictureParameterBuffer ID + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t pic_param_buf_id; + + /** + * VAIQMatrixBuffer ID + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t iq_matrix_buf_id; + + /** + * VABitPlaneBuffer ID (for VC-1 decoding) + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t bitplane_buf_id; + + /** + * Slice parameter/data buffer IDs + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t *slice_buf_ids; + + /** + * Number of effective slice buffer IDs to send to the HW + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int n_slice_buf_ids; + + /** + * Size of pre-allocated slice_buf_ids + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int slice_buf_ids_alloc; + + /** + * Pointer to VASliceParameterBuffers + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + void *slice_params; + + /** + * Size of a VASliceParameterBuffer element + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int slice_param_size; + + /** + * Size of pre-allocated slice_params + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int slice_params_alloc; + + /** + * Number of slices currently filled in + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + unsigned int slice_count; + + /** + * Pointer to slice data buffer base + * - encoding: unused + * - decoding: Set by libavcodec + */ + const uint8_t *slice_data; + + /** + * Current size of slice data + * + * - encoding: unused + * - decoding: Set by libavcodec + */ + uint32_t slice_data_size; +}; + +/* @} */ + +#endif /* AVCODEC_VAAPI_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vda.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vda.h new file mode 100644 index 000000000..987b94f1f --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vda.h @@ -0,0 +1,142 @@ +/* + * VDA HW acceleration + * + * copyright (c) 2011 Sebastien Zwickert + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VDA_H +#define AVCODEC_VDA_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_vda + * Public libavcodec VDA header. + */ + +#include "libavcodec/version.h" + +#include + +// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes +// http://openradar.appspot.com/8026390 +#undef __GNUC_STDC_INLINE__ + +#define Picture QuickdrawPicture +#include +#undef Picture + +/** + * @defgroup lavc_codec_hwaccel_vda VDA + * @ingroup lavc_codec_hwaccel + * + * @{ + */ + +/** + * This structure is used to provide the necessary configurations and data + * to the VDA Libav HWAccel implementation. + * + * The application must make it available as AVCodecContext.hwaccel_context. + */ +struct vda_context { + /** + * VDA decoder object. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + VDADecoder decoder; + + /** + * The Core Video pixel buffer that contains the current image data. + * + * encoding: unused + * decoding: Set by libavcodec. Unset by user. + */ + CVPixelBufferRef cv_buffer; + + /** + * Use the hardware decoder in synchronous mode. + * + * encoding: unused + * decoding: Set by user. + */ + int use_sync_decoding; + + /** + * The frame width. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + int width; + + /** + * The frame height. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + int height; + + /** + * The frame format. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + int format; + + /** + * The pixel format for output image buffers. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + OSType cv_pix_fmt_type; + + /** + * The current bitstream buffer. + */ + uint8_t *priv_bitstream; + + /** + * The current size of the bitstream. + */ + int priv_bitstream_size; + + /** + * The reference size used for fast reallocation. + */ + int priv_allocated_size; +}; + +/** Create the video decoder. */ +int ff_vda_create_decoder(struct vda_context *vda_ctx, + uint8_t *extradata, + int extradata_size); + +/** Destroy the video decoder. */ +int ff_vda_destroy_decoder(struct vda_context *vda_ctx); + +/** + * @} + */ + +#endif /* AVCODEC_VDA_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vdpau.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vdpau.h new file mode 100644 index 000000000..8bedea54b --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/vdpau.h @@ -0,0 +1,160 @@ +/* + * The Video Decode and Presentation API for UNIX (VDPAU) is used for + * hardware-accelerated decoding of MPEG-1/2, H.264 and VC-1. + * + * Copyright (C) 2008 NVIDIA + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VDPAU_H +#define AVCODEC_VDPAU_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_vdpau + * Public libavcodec VDPAU header. + */ + + +/** + * @defgroup lavc_codec_hwaccel_vdpau VDPAU Decoder and Renderer + * @ingroup lavc_codec_hwaccel + * + * VDPAU hardware acceleration has two modules + * - VDPAU decoding + * - VDPAU presentation + * + * The VDPAU decoding module parses all headers using Libav + * parsing mechanisms and uses VDPAU for the actual decoding. + * + * As per the current implementation, the actual decoding + * and rendering (API calls) are done as part of the VDPAU + * presentation (vo_vdpau.c) module. + * + * @{ + */ + +#include +#include + +#if FF_API_BUFS_VDPAU +union AVVDPAUPictureInfo { + VdpPictureInfoH264 h264; + VdpPictureInfoMPEG1Or2 mpeg; + VdpPictureInfoVC1 vc1; + VdpPictureInfoMPEG4Part2 mpeg4; +}; +#endif + +/** + * This structure is used to share data between the libavcodec library and + * the client video application. + * The user shall zero-allocate the structure and make it available as + * AVCodecContext.hwaccel_context. Members can be set by the user once + * during initialization or through each AVCodecContext.get_buffer() + * function call. In any case, they must be valid prior to calling + * decoding functions. + */ +typedef struct AVVDPAUContext { + /** + * VDPAU decoder handle + * + * Set by user. + */ + VdpDecoder decoder; + + /** + * VDPAU decoder render callback + * + * Set by the user. + */ + VdpDecoderRender *render; + +#if FF_API_BUFS_VDPAU + /** + * VDPAU picture information + * + * Set by libavcodec. + */ + attribute_deprecated + union AVVDPAUPictureInfo info; + + /** + * Allocated size of the bitstream_buffers table. + * + * Set by libavcodec. + */ + attribute_deprecated + int bitstream_buffers_allocated; + + /** + * Useful bitstream buffers in the bitstream buffers table. + * + * Set by libavcodec. + */ + attribute_deprecated + int bitstream_buffers_used; + + /** + * Table of bitstream buffers. + * The user is responsible for freeing this buffer using av_freep(). + * + * Set by libavcodec. + */ + attribute_deprecated + VdpBitstreamBuffer *bitstream_buffers; +#endif +} AVVDPAUContext; + +#if FF_API_CAP_VDPAU +/** @brief The videoSurface is used for rendering. */ +#define FF_VDPAU_STATE_USED_FOR_RENDER 1 + +/** + * @brief The videoSurface is needed for reference/prediction. + * The codec manipulates this. + */ +#define FF_VDPAU_STATE_USED_FOR_REFERENCE 2 + +/** + * @brief This structure is used as a callback between the Libav + * decoder (vd_) and presentation (vo_) module. + * This is used for defining a video frame containing surface, + * picture parameter, bitstream information etc which are passed + * between the Libav decoder and its clients. + */ +struct vdpau_render_state { + VdpVideoSurface surface; ///< Used as rendered surface, never changed. + + int state; ///< Holds FF_VDPAU_STATE_* values. + + /** picture parameter information for all supported codecs */ + union AVVDPAUPictureInfo info; + + /** Describe size/location of the compressed video data. + Set to 0 when freeing bitstream_buffers. */ + int bitstream_buffers_allocated; + int bitstream_buffers_used; + /** The user is responsible for freeing this buffer using av_freep(). */ + VdpBitstreamBuffer *bitstream_buffers; +}; +#endif + +/* @}*/ + +#endif /* AVCODEC_VDPAU_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/version.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/version.h new file mode 100644 index 000000000..1c6efe6fe --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/version.h @@ -0,0 +1,77 @@ +/* + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VERSION_H +#define AVCODEC_VERSION_H + +/** + * @file + * @ingroup libavc + * Libavcodec version macros. + */ + +#define LIBAVCODEC_VERSION_MAJOR 55 +#define LIBAVCODEC_VERSION_MINOR 17 +#define LIBAVCODEC_VERSION_MICRO 0 + +#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ + LIBAVCODEC_VERSION_MINOR, \ + LIBAVCODEC_VERSION_MICRO) +#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \ + LIBAVCODEC_VERSION_MINOR, \ + LIBAVCODEC_VERSION_MICRO) +#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT + +#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + */ + +#ifndef FF_API_REQUEST_CHANNELS +#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 56) +#endif +#ifndef FF_API_DEINTERLACE +#define FF_API_DEINTERLACE (LIBAVCODEC_VERSION_MAJOR < 56) +#endif +#ifndef FF_API_DESTRUCT_PACKET +#define FF_API_DESTRUCT_PACKET (LIBAVCODEC_VERSION_MAJOR < 56) +#endif +#ifndef FF_API_GET_BUFFER +#define FF_API_GET_BUFFER (LIBAVCODEC_VERSION_MAJOR < 56) +#endif +#ifndef FF_API_MISSING_SAMPLE +#define FF_API_MISSING_SAMPLE (LIBAVCODEC_VERSION_MAJOR < 56) +#endif +#ifndef FF_API_LOWRES +#define FF_API_LOWRES (LIBAVCODEC_VERSION_MAJOR < 56) +#endif +#ifndef FF_API_CAP_VDPAU +#define FF_API_CAP_VDPAU (LIBAVCODEC_VERSION_MAJOR < 56) +#endif +#ifndef FF_API_BUFS_VDPAU +#define FF_API_BUFS_VDPAU (LIBAVCODEC_VERSION_MAJOR < 56) +#endif +#ifndef FF_API_VOXWARE +#define FF_API_VOXWARE (LIBAVCODEC_VERSION_MAJOR < 56) +#endif + +#endif /* AVCODEC_VERSION_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/xvmc.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/xvmc.h new file mode 100644 index 000000000..1f77e4efc --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavcodec/xvmc.h @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2003 Ivan Kalvachev + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_XVMC_H +#define AVCODEC_XVMC_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_xvmc + * Public libavcodec XvMC header. + */ + +#include + +#include "avcodec.h" + +/** + * @defgroup lavc_codec_hwaccel_xvmc XvMC + * @ingroup lavc_codec_hwaccel + * + * @{ + */ + +#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct + the number is 1337 speak for the letters IDCT MCo (motion compensation) */ + +struct xvmc_pix_fmt { + /** The field contains the special constant value AV_XVMC_ID. + It is used as a test that the application correctly uses the API, + and that there is no corruption caused by pixel routines. + - application - set during initialization + - libavcodec - unchanged + */ + int xvmc_id; + + /** Pointer to the block array allocated by XvMCCreateBlocks(). + The array has to be freed by XvMCDestroyBlocks(). + Each group of 64 values represents one data block of differential + pixel information (in MoCo mode) or coefficients for IDCT. + - application - set the pointer during initialization + - libavcodec - fills coefficients/pixel data into the array + */ + short* data_blocks; + + /** Pointer to the macroblock description array allocated by + XvMCCreateMacroBlocks() and freed by XvMCDestroyMacroBlocks(). + - application - set the pointer during initialization + - libavcodec - fills description data into the array + */ + XvMCMacroBlock* mv_blocks; + + /** Number of macroblock descriptions that can be stored in the mv_blocks + array. + - application - set during initialization + - libavcodec - unchanged + */ + int allocated_mv_blocks; + + /** Number of blocks that can be stored at once in the data_blocks array. + - application - set during initialization + - libavcodec - unchanged + */ + int allocated_data_blocks; + + /** Indicate that the hardware would interpret data_blocks as IDCT + coefficients and perform IDCT on them. + - application - set during initialization + - libavcodec - unchanged + */ + int idct; + + /** In MoCo mode it indicates that intra macroblocks are assumed to be in + unsigned format; same as the XVMC_INTRA_UNSIGNED flag. + - application - set during initialization + - libavcodec - unchanged + */ + int unsigned_intra; + + /** Pointer to the surface allocated by XvMCCreateSurface(). + It has to be freed by XvMCDestroySurface() on application exit. + It identifies the frame and its state on the video hardware. + - application - set during initialization + - libavcodec - unchanged + */ + XvMCSurface* p_surface; + +/** Set by the decoder before calling ff_draw_horiz_band(), + needed by the XvMCRenderSurface function. */ +//@{ + /** Pointer to the surface used as past reference + - application - unchanged + - libavcodec - set + */ + XvMCSurface* p_past_surface; + + /** Pointer to the surface used as future reference + - application - unchanged + - libavcodec - set + */ + XvMCSurface* p_future_surface; + + /** top/bottom field or frame + - application - unchanged + - libavcodec - set + */ + unsigned int picture_structure; + + /** XVMC_SECOND_FIELD - 1st or 2nd field in the sequence + - application - unchanged + - libavcodec - set + */ + unsigned int flags; +//}@ + + /** Number of macroblock descriptions in the mv_blocks array + that have already been passed to the hardware. + - application - zeroes it on get_buffer(). + A successful ff_draw_horiz_band() may increment it + with filled_mb_block_num or zero both. + - libavcodec - unchanged + */ + int start_mv_blocks_num; + + /** Number of new macroblock descriptions in the mv_blocks array (after + start_mv_blocks_num) that are filled by libavcodec and have to be + passed to the hardware. + - application - zeroes it on get_buffer() or after successful + ff_draw_horiz_band(). + - libavcodec - increment with one of each stored MB + */ + int filled_mv_blocks_num; + + /** Number of the next free data block; one data block consists of + 64 short values in the data_blocks array. + All blocks before this one have already been claimed by placing their + position into the corresponding block description structure field, + that are part of the mv_blocks array. + - application - zeroes it on get_buffer(). + A successful ff_draw_horiz_band() may zero it together + with start_mb_blocks_num. + - libavcodec - each decoded macroblock increases it by the number + of coded blocks it contains. + */ + int next_free_data_block_num; +}; + +/** + * @} + */ + +#endif /* AVCODEC_XVMC_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/avformat.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/avformat.h new file mode 100644 index 000000000..1399de052 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/avformat.h @@ -0,0 +1,1708 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_AVFORMAT_H +#define AVFORMAT_AVFORMAT_H + +/** + * @file + * @ingroup libavf + * Main libavformat public API header + */ + +/** + * @defgroup libavf I/O and Muxing/Demuxing Library + * @{ + * + * Libavformat (lavf) is a library for dealing with various media container + * formats. Its main two purposes are demuxing - i.e. splitting a media file + * into component streams, and the reverse process of muxing - writing supplied + * data in a specified container format. It also has an @ref lavf_io + * "I/O module" which supports a number of protocols for accessing the data (e.g. + * file, tcp, http and others). Before using lavf, you need to call + * av_register_all() to register all compiled muxers, demuxers and protocols. + * Unless you are absolutely sure you won't use libavformat's network + * capabilities, you should also call avformat_network_init(). + * + * A supported input format is described by an AVInputFormat struct, conversely + * an output format is described by AVOutputFormat. You can iterate over all + * registered input/output formats using the av_iformat_next() / + * av_oformat_next() functions. The protocols layer is not part of the public + * API, so you can only get the names of supported protocols with the + * avio_enum_protocols() function. + * + * Main lavf structure used for both muxing and demuxing is AVFormatContext, + * which exports all information about the file being read or written. As with + * most Libav structures, its size is not part of public ABI, so it cannot be + * allocated on stack or directly with av_malloc(). To create an + * AVFormatContext, use avformat_alloc_context() (some functions, like + * avformat_open_input() might do that for you). + * + * Most importantly an AVFormatContext contains: + * @li the @ref AVFormatContext.iformat "input" or @ref AVFormatContext.oformat + * "output" format. It is either autodetected or set by user for input; + * always set by user for output. + * @li an @ref AVFormatContext.streams "array" of AVStreams, which describe all + * elementary streams stored in the file. AVStreams are typically referred to + * using their index in this array. + * @li an @ref AVFormatContext.pb "I/O context". It is either opened by lavf or + * set by user for input, always set by user for output (unless you are dealing + * with an AVFMT_NOFILE format). + * + * @section lavf_options Passing options to (de)muxers + * Lavf allows to configure muxers and demuxers using the @ref avoptions + * mechanism. Generic (format-independent) libavformat options are provided by + * AVFormatContext, they can be examined from a user program by calling + * av_opt_next() / av_opt_find() on an allocated AVFormatContext (or its AVClass + * from avformat_get_class()). Private (format-specific) options are provided by + * AVFormatContext.priv_data if and only if AVInputFormat.priv_class / + * AVOutputFormat.priv_class of the corresponding format struct is non-NULL. + * Further options may be provided by the @ref AVFormatContext.pb "I/O context", + * if its AVClass is non-NULL, and the protocols layer. See the discussion on + * nesting in @ref avoptions documentation to learn how to access those. + * + * @defgroup lavf_decoding Demuxing + * @{ + * Demuxers read a media file and split it into chunks of data (@em packets). A + * @ref AVPacket "packet" contains one or more encoded frames which belongs to a + * single elementary stream. In the lavf API this process is represented by the + * avformat_open_input() function for opening a file, av_read_frame() for + * reading a single packet and finally avformat_close_input(), which does the + * cleanup. + * + * @section lavf_decoding_open Opening a media file + * The minimum information required to open a file is its URL or filename, which + * is passed to avformat_open_input(), as in the following code: + * @code + * const char *url = "in.mp3"; + * AVFormatContext *s = NULL; + * int ret = avformat_open_input(&s, url, NULL, NULL); + * if (ret < 0) + * abort(); + * @endcode + * The above code attempts to allocate an AVFormatContext, open the + * specified file (autodetecting the format) and read the header, exporting the + * information stored there into s. Some formats do not have a header or do not + * store enough information there, so it is recommended that you call the + * avformat_find_stream_info() function which tries to read and decode a few + * frames to find missing information. + * + * In some cases you might want to preallocate an AVFormatContext yourself with + * avformat_alloc_context() and do some tweaking on it before passing it to + * avformat_open_input(). One such case is when you want to use custom functions + * for reading input data instead of lavf internal I/O layer. + * To do that, create your own AVIOContext with avio_alloc_context(), passing + * your reading callbacks to it. Then set the @em pb field of your + * AVFormatContext to newly created AVIOContext. + * + * Since the format of the opened file is in general not known until after + * avformat_open_input() has returned, it is not possible to set demuxer private + * options on a preallocated context. Instead, the options should be passed to + * avformat_open_input() wrapped in an AVDictionary: + * @code + * AVDictionary *options = NULL; + * av_dict_set(&options, "video_size", "640x480", 0); + * av_dict_set(&options, "pixel_format", "rgb24", 0); + * + * if (avformat_open_input(&s, url, NULL, &options) < 0) + * abort(); + * av_dict_free(&options); + * @endcode + * This code passes the private options 'video_size' and 'pixel_format' to the + * demuxer. They would be necessary for e.g. the rawvideo demuxer, since it + * cannot know how to interpret raw video data otherwise. If the format turns + * out to be something different than raw video, those options will not be + * recognized by the demuxer and therefore will not be applied. Such unrecognized + * options are then returned in the options dictionary (recognized options are + * consumed). The calling program can handle such unrecognized options as it + * wishes, e.g. + * @code + * AVDictionaryEntry *e; + * if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) { + * fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key); + * abort(); + * } + * @endcode + * + * After you have finished reading the file, you must close it with + * avformat_close_input(). It will free everything associated with the file. + * + * @section lavf_decoding_read Reading from an opened file + * Reading data from an opened AVFormatContext is done by repeatedly calling + * av_read_frame() on it. Each call, if successful, will return an AVPacket + * containing encoded data for one AVStream, identified by + * AVPacket.stream_index. This packet may be passed straight into the libavcodec + * decoding functions avcodec_decode_video2(), avcodec_decode_audio4() or + * avcodec_decode_subtitle2() if the caller wishes to decode the data. + * + * AVPacket.pts, AVPacket.dts and AVPacket.duration timing information will be + * set if known. They may also be unset (i.e. AV_NOPTS_VALUE for + * pts/dts, 0 for duration) if the stream does not provide them. The timing + * information will be in AVStream.time_base units, i.e. it has to be + * multiplied by the timebase to convert them to seconds. + * + * If AVPacket.buf is set on the returned packet, then the packet is + * allocated dynamically and the user may keep it indefinitely. + * Otherwise, if AVPacket.buf is NULL, the packet data is backed by a + * static storage somewhere inside the demuxer and the packet is only valid + * until the next av_read_frame() call or closing the file. If the caller + * requires a longer lifetime, av_dup_packet() will make an av_malloc()ed copy + * of it. + * In both cases, the packet must be freed with av_free_packet() when it is no + * longer needed. + * + * @section lavf_decoding_seek Seeking + * @} + * + * @defgroup lavf_encoding Muxing + * @{ + * @} + * + * @defgroup lavf_io I/O Read/Write + * @{ + * @} + * + * @defgroup lavf_codec Demuxers + * @{ + * @defgroup lavf_codec_native Native Demuxers + * @{ + * @} + * @defgroup lavf_codec_wrappers External library wrappers + * @{ + * @} + * @} + * @defgroup lavf_protos I/O Protocols + * @{ + * @} + * @defgroup lavf_internal Internal + * @{ + * @} + * @} + * + */ + +#include +#include /* FILE */ +#include "libavcodec/avcodec.h" +#include "libavutil/dict.h" +#include "libavutil/log.h" + +#include "avio.h" +#include "libavformat/version.h" + +struct AVFormatContext; + + +/** + * @defgroup metadata_api Public Metadata API + * @{ + * @ingroup libavf + * The metadata API allows libavformat to export metadata tags to a client + * application when demuxing. Conversely it allows a client application to + * set metadata when muxing. + * + * Metadata is exported or set as pairs of key/value strings in the 'metadata' + * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs + * using the @ref lavu_dict "AVDictionary" API. Like all strings in Libav, + * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata + * exported by demuxers isn't checked to be valid UTF-8 in most cases. + * + * Important concepts to keep in mind: + * - Keys are unique; there can never be 2 tags with the same key. This is + * also meant semantically, i.e., a demuxer should not knowingly produce + * several keys that are literally different but semantically identical. + * E.g., key=Author5, key=Author6. In this example, all authors must be + * placed in the same tag. + * - Metadata is flat, not hierarchical; there are no subtags. If you + * want to store, e.g., the email address of the child of producer Alice + * and actor Bob, that could have key=alice_and_bobs_childs_email_address. + * - Several modifiers can be applied to the tag name. This is done by + * appending a dash character ('-') and the modifier name in the order + * they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng. + * - language -- a tag whose value is localized for a particular language + * is appended with the ISO 639-2/B 3-letter language code. + * For example: Author-ger=Michael, Author-eng=Mike + * The original/default language is in the unqualified "Author" tag. + * A demuxer should set a default if it sets any translated tag. + * - sorting -- a modified version of a tag that should be used for + * sorting will have '-sort' appended. E.g. artist="The Beatles", + * artist-sort="Beatles, The". + * + * - Demuxers attempt to export metadata in a generic format, however tags + * with no generic equivalents are left as they are stored in the container. + * Follows a list of generic tag names: + * + @verbatim + album -- name of the set this work belongs to + album_artist -- main creator of the set/album, if different from artist. + e.g. "Various Artists" for compilation albums. + artist -- main creator of the work + comment -- any additional description of the file. + composer -- who composed the work, if different from artist. + copyright -- name of copyright holder. + creation_time-- date when the file was created, preferably in ISO 8601. + date -- date when the work was created, preferably in ISO 8601. + disc -- number of a subset, e.g. disc in a multi-disc collection. + encoder -- name/settings of the software/hardware that produced the file. + encoded_by -- person/group who created the file. + filename -- original name of the file. + genre -- . + language -- main language in which the work is performed, preferably + in ISO 639-2 format. Multiple languages can be specified by + separating them with commas. + performer -- artist who performed the work, if different from artist. + E.g for "Also sprach Zarathustra", artist would be "Richard + Strauss" and performer "London Philharmonic Orchestra". + publisher -- name of the label/publisher. + service_name -- name of the service in broadcasting (channel name). + service_provider -- name of the service provider in broadcasting. + title -- name of the work. + track -- number of this work in the set, can be in form current/total. + variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of + @endverbatim + * + * Look in the examples section for an application example how to use the Metadata API. + * + * @} + */ + +/* packet functions */ + + +/** + * Allocate and read the payload of a packet and initialize its + * fields with default values. + * + * @param pkt packet + * @param size desired payload size + * @return >0 (read size) if OK, AVERROR_xxx otherwise + */ +int av_get_packet(AVIOContext *s, AVPacket *pkt, int size); + + +/** + * Read data and append it to the current content of the AVPacket. + * If pkt->size is 0 this is identical to av_get_packet. + * Note that this uses av_grow_packet and thus involves a realloc + * which is inefficient. Thus this function should only be used + * when there is no reasonable way to know (an upper bound of) + * the final size. + * + * @param pkt packet + * @param size amount of data to read + * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data + * will not be lost even if an error occurs. + */ +int av_append_packet(AVIOContext *s, AVPacket *pkt, int size); + +/*************************************************/ +/* fractional numbers for exact pts handling */ + +/** + * The exact value of the fractional number is: 'val + num / den'. + * num is assumed to be 0 <= num < den. + */ +typedef struct AVFrac { + int64_t val, num, den; +} AVFrac; + +/*************************************************/ +/* input/output formats */ + +struct AVCodecTag; + +/** + * This structure contains the data a format has to probe a file. + */ +typedef struct AVProbeData { + const char *filename; + unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */ + int buf_size; /**< Size of buf except extra allocated bytes */ +} AVProbeData; + +#define AVPROBE_SCORE_EXTENSION 50 ///< score for file extension +#define AVPROBE_SCORE_MAX 100 ///< maximum score + +#define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer + +/// Demuxer will use avio_open, no opened file should be provided by the caller. +#define AVFMT_NOFILE 0x0001 +#define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */ +#define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */ +#define AVFMT_RAWPICTURE 0x0020 /**< Format wants AVPicture structure for + raw picture data. */ +#define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */ +#define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */ +#define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */ +#define AVFMT_TS_DISCONT 0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */ +#define AVFMT_VARIABLE_FPS 0x0400 /**< Format allows variable fps. */ +#define AVFMT_NODIMENSIONS 0x0800 /**< Format does not need width/height */ +#define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */ +#define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fall back on binary search via read_timestamp */ +#define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fall back on generic search */ +#define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ +#define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */ +#define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly + increasing timestamps, but they must + still be monotonic */ +#define AVFMT_TS_NEGATIVE 0x40000 /**< Format allows muxing negative + timestamps. If not set the timestamp + will be shifted in av_write_frame and + av_interleaved_write_frame so they + start from 0. */ + +/** + * @addtogroup lavf_encoding + * @{ + */ +typedef struct AVOutputFormat { + const char *name; + /** + * Descriptive name for the format, meant to be more human-readable + * than name. You should use the NULL_IF_CONFIG_SMALL() macro + * to define it. + */ + const char *long_name; + const char *mime_type; + const char *extensions; /**< comma-separated filename extensions */ + /* output support */ + enum AVCodecID audio_codec; /**< default audio codec */ + enum AVCodecID video_codec; /**< default video codec */ + enum AVCodecID subtitle_codec; /**< default subtitle codec */ + /** + * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, + * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, + * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, + * AVFMT_TS_NONSTRICT + */ + int flags; + + /** + * List of supported codec_id-codec_tag pairs, ordered by "better + * choice first". The arrays are all terminated by AV_CODEC_ID_NONE. + */ + const struct AVCodecTag * const *codec_tag; + + + const AVClass *priv_class; ///< AVClass for the private context + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + struct AVOutputFormat *next; + /** + * size of private data so that it can be allocated in the wrapper + */ + int priv_data_size; + + int (*write_header)(struct AVFormatContext *); + /** + * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags, + * pkt can be NULL in order to flush data buffered in the muxer. + * When flushing, return 0 if there still is more data to flush, + * or 1 if everything was flushed and there is no more buffered + * data. + */ + int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); + int (*write_trailer)(struct AVFormatContext *); + /** + * Currently only used to set pixel format if not YUV420P. + */ + int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, + AVPacket *in, int flush); + /** + * Test if the given codec can be stored in this container. + * + * @return 1 if the codec is supported, 0 if it is not. + * A negative number if unknown. + */ + int (*query_codec)(enum AVCodecID id, int std_compliance); +} AVOutputFormat; +/** + * @} + */ + +/** + * @addtogroup lavf_decoding + * @{ + */ +typedef struct AVInputFormat { + /** + * A comma separated list of short names for the format. New names + * may be appended with a minor bump. + */ + const char *name; + + /** + * Descriptive name for the format, meant to be more human-readable + * than name. You should use the NULL_IF_CONFIG_SMALL() macro + * to define it. + */ + const char *long_name; + + /** + * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, + * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, + * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK. + */ + int flags; + + /** + * If extensions are defined, then no probe is done. You should + * usually not use extension format guessing because it is not + * reliable enough + */ + const char *extensions; + + const struct AVCodecTag * const *codec_tag; + + const AVClass *priv_class; ///< AVClass for the private context + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + struct AVInputFormat *next; + + /** + * Raw demuxers store their codec ID here. + */ + int raw_codec_id; + + /** + * Size of private data so that it can be allocated in the wrapper. + */ + int priv_data_size; + + /** + * Tell if a given file has a chance of being parsed as this format. + * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes + * big so you do not have to check for that unless you need more. + */ + int (*read_probe)(AVProbeData *); + + /** + * Read the format header and initialize the AVFormatContext + * structure. Return 0 if OK. Only used in raw format right + * now. 'avformat_new_stream' should be called to create new streams. + */ + int (*read_header)(struct AVFormatContext *); + + /** + * Read one packet and put it in 'pkt'. pts and flags are also + * set. 'avformat_new_stream' can be called only if the flag + * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a + * background thread). + * @return 0 on success, < 0 on error. + * When returning an error, pkt must not have been allocated + * or must be freed before returning + */ + int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); + + /** + * Close the stream. The AVFormatContext and AVStreams are not + * freed by this function + */ + int (*read_close)(struct AVFormatContext *); + + /** + * Seek to a given timestamp relative to the frames in + * stream component stream_index. + * @param stream_index Must not be -1. + * @param flags Selects which direction should be preferred if no exact + * match is available. + * @return >= 0 on success (but not necessarily the new offset) + */ + int (*read_seek)(struct AVFormatContext *, + int stream_index, int64_t timestamp, int flags); + + /** + * Get the next timestamp in stream[stream_index].time_base units. + * @return the timestamp or AV_NOPTS_VALUE if an error occurred + */ + int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index, + int64_t *pos, int64_t pos_limit); + + /** + * Start/resume playing - only meaningful if using a network-based format + * (RTSP). + */ + int (*read_play)(struct AVFormatContext *); + + /** + * Pause playing - only meaningful if using a network-based format + * (RTSP). + */ + int (*read_pause)(struct AVFormatContext *); + + /** + * Seek to timestamp ts. + * Seeking will be done so that the point from which all active streams + * can be presented successfully will be closest to ts and within min/max_ts. + * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. + */ + int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); +} AVInputFormat; +/** + * @} + */ + +enum AVStreamParseType { + AVSTREAM_PARSE_NONE, + AVSTREAM_PARSE_FULL, /**< full parsing and repack */ + AVSTREAM_PARSE_HEADERS, /**< Only parse headers, do not repack. */ + AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */ + AVSTREAM_PARSE_FULL_ONCE, /**< full parsing and repack of the first frame only, only implemented for H.264 currently */ +}; + +typedef struct AVIndexEntry { + int64_t pos; + int64_t timestamp; +#define AVINDEX_KEYFRAME 0x0001 + int flags:2; + int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment). + int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */ +} AVIndexEntry; + +#define AV_DISPOSITION_DEFAULT 0x0001 +#define AV_DISPOSITION_DUB 0x0002 +#define AV_DISPOSITION_ORIGINAL 0x0004 +#define AV_DISPOSITION_COMMENT 0x0008 +#define AV_DISPOSITION_LYRICS 0x0010 +#define AV_DISPOSITION_KARAOKE 0x0020 + +/** + * Track should be used during playback by default. + * Useful for subtitle track that should be displayed + * even when user did not explicitly ask for subtitles. + */ +#define AV_DISPOSITION_FORCED 0x0040 +#define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */ +#define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */ +#define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */ +/** + * The stream is stored in the file as an attached picture/"cover art" (e.g. + * APIC frame in ID3v2). The single packet associated with it will be returned + * among the first few packets read from the file unless seeking takes place. + * It can also be accessed at any time in AVStream.attached_pic. + */ +#define AV_DISPOSITION_ATTACHED_PIC 0x0400 + +/** + * Stream structure. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVStream) must not be used outside libav*. + */ +typedef struct AVStream { + int index; /**< stream index in AVFormatContext */ + /** + * Format-specific stream ID. + * decoding: set by libavformat + * encoding: set by the user, replaced by libavformat if left unset + */ + int id; + /** + * Codec context associated with this stream. Allocated and freed by + * libavformat. + * + * - decoding: The demuxer exports codec information stored in the headers + * here. + * - encoding: The user sets codec information, the muxer writes it to the + * output. Mandatory fields as specified in AVCodecContext + * documentation must be set even if this AVCodecContext is + * not actually used for encoding. + */ + AVCodecContext *codec; + void *priv_data; + + /** + * encoding: pts generation when outputting stream + */ + struct AVFrac pts; + + /** + * This is the fundamental unit of time (in seconds) in terms + * of which frame timestamps are represented. + * + * decoding: set by libavformat + * encoding: set by libavformat in avformat_write_header. The muxer may use the + * user-provided value of @ref AVCodecContext.time_base "codec->time_base" + * as a hint. + */ + AVRational time_base; + + /** + * Decoding: pts of the first frame of the stream, in stream time base. + * Only set this if you are absolutely 100% sure that the value you set + * it to really is the pts of the first frame. + * This may be undefined (AV_NOPTS_VALUE). + */ + int64_t start_time; + + /** + * Decoding: duration of the stream, in stream time base. + * If a source file does not specify a duration, but does specify + * a bitrate, this value will be estimated from bitrate and file size. + */ + int64_t duration; + + int64_t nb_frames; ///< number of frames in this stream if known or 0 + + int disposition; /**< AV_DISPOSITION_* bit field */ + + enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed. + + /** + * sample aspect ratio (0 if unknown) + * - encoding: Set by user. + * - decoding: Set by libavformat. + */ + AVRational sample_aspect_ratio; + + AVDictionary *metadata; + + /** + * Average framerate + */ + AVRational avg_frame_rate; + + /** + * For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet + * will contain the attached picture. + * + * decoding: set by libavformat, must not be modified by the caller. + * encoding: unused + */ + AVPacket attached_pic; + + /***************************************************************** + * All fields below this line are not part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + + /** + * Stream information used internally by av_find_stream_info() + */ +#define MAX_STD_TIMEBASES (60*12+5) + struct { + int nb_decoded_frames; + int found_decoder; + + /** + * Those are used for average framerate estimation. + */ + int64_t fps_first_dts; + int fps_first_dts_idx; + int64_t fps_last_dts; + int fps_last_dts_idx; + + } *info; + + int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ + + // Timestamp generation support: + /** + * Timestamp corresponding to the last dts sync point. + * + * Initialized when AVCodecParserContext.dts_sync_point >= 0 and + * a DTS is received from the underlying container. Otherwise set to + * AV_NOPTS_VALUE by default. + */ + int64_t reference_dts; + int64_t first_dts; + int64_t cur_dts; + int64_t last_IP_pts; + int last_IP_duration; + + /** + * Number of packets to buffer for codec probing + */ +#define MAX_PROBE_PACKETS 2500 + int probe_packets; + + /** + * Number of frames that have been demuxed during av_find_stream_info() + */ + int codec_info_nb_frames; + + /* av_read_frame() support */ + enum AVStreamParseType need_parsing; + struct AVCodecParserContext *parser; + + /** + * last packet in packet_buffer for this stream when muxing. + */ + struct AVPacketList *last_in_packet_buffer; + AVProbeData probe_data; +#define MAX_REORDER_DELAY 16 + int64_t pts_buffer[MAX_REORDER_DELAY+1]; + + AVIndexEntry *index_entries; /**< Only used if the format does not + support seeking natively. */ + int nb_index_entries; + unsigned int index_entries_allocated_size; +} AVStream; + +#define AV_PROGRAM_RUNNING 1 + +/** + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVProgram) must not be used outside libav*. + */ +typedef struct AVProgram { + int id; + int flags; + enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller + unsigned int *stream_index; + unsigned int nb_stream_indexes; + AVDictionary *metadata; +} AVProgram; + +#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present + (streams are added dynamically) */ + +typedef struct AVChapter { + int id; ///< unique ID to identify the chapter + AVRational time_base; ///< time base in which the start/end timestamps are specified + int64_t start, end; ///< chapter start/end time in time_base units + AVDictionary *metadata; +} AVChapter; + +/** + * Format I/O context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVFormatContext) must not be used outside libav*, use + * avformat_alloc_context() to create an AVFormatContext. + */ +typedef struct AVFormatContext { + /** + * A class for logging and AVOptions. Set by avformat_alloc_context(). + * Exports (de)muxer private options if they exist. + */ + const AVClass *av_class; + + /** + * Can only be iformat or oformat, not both at the same time. + * + * decoding: set by avformat_open_input(). + * encoding: set by the user. + */ + struct AVInputFormat *iformat; + struct AVOutputFormat *oformat; + + /** + * Format private data. This is an AVOptions-enabled struct + * if and only if iformat/oformat.priv_class is not NULL. + */ + void *priv_data; + + /** + * I/O context. + * + * decoding: either set by the user before avformat_open_input() (then + * the user must close it manually) or set by avformat_open_input(). + * encoding: set by the user. + * + * Do NOT set this field if AVFMT_NOFILE flag is set in + * iformat/oformat.flags. In such a case, the (de)muxer will handle + * I/O in some other way and this field will be NULL. + */ + AVIOContext *pb; + + /* stream info */ + int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ + + /** + * A list of all streams in the file. New streams are created with + * avformat_new_stream(). + * + * decoding: streams are created by libavformat in avformat_open_input(). + * If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also + * appear in av_read_frame(). + * encoding: streams are created by the user before avformat_write_header(). + */ + unsigned int nb_streams; + AVStream **streams; + + char filename[1024]; /**< input or output filename */ + + /** + * Decoding: position of the first frame of the component, in + * AV_TIME_BASE fractional seconds. NEVER set this value directly: + * It is deduced from the AVStream values. + */ + int64_t start_time; + + /** + * Decoding: duration of the stream, in AV_TIME_BASE fractional + * seconds. Only set this value if you know none of the individual stream + * durations and also do not set any of them. This is deduced from the + * AVStream values if not set. + */ + int64_t duration; + + /** + * Decoding: total stream bitrate in bit/s, 0 if not + * available. Never set it directly if the file_size and the + * duration are known as Libav can compute it automatically. + */ + int bit_rate; + + unsigned int packet_size; + int max_delay; + + int flags; +#define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames. +#define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index. +#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input. +#define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS +#define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container +#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled +#define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible +#define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it. +#define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted + + /** + * decoding: size of data to probe; encoding: unused. + */ + unsigned int probesize; + + /** + * decoding: maximum time (in AV_TIME_BASE units) during which the input should + * be analyzed in avformat_find_stream_info(). + */ + int max_analyze_duration; + + const uint8_t *key; + int keylen; + + unsigned int nb_programs; + AVProgram **programs; + + /** + * Forced video codec_id. + * Demuxing: Set by user. + */ + enum AVCodecID video_codec_id; + + /** + * Forced audio codec_id. + * Demuxing: Set by user. + */ + enum AVCodecID audio_codec_id; + + /** + * Forced subtitle codec_id. + * Demuxing: Set by user. + */ + enum AVCodecID subtitle_codec_id; + + /** + * Maximum amount of memory in bytes to use for the index of each stream. + * If the index exceeds this size, entries will be discarded as + * needed to maintain a smaller size. This can lead to slower or less + * accurate seeking (depends on demuxer). + * Demuxers for which a full in-memory index is mandatory will ignore + * this. + * muxing : unused + * demuxing: set by user + */ + unsigned int max_index_size; + + /** + * Maximum amount of memory in bytes to use for buffering frames + * obtained from realtime capture devices. + */ + unsigned int max_picture_buffer; + + unsigned int nb_chapters; + AVChapter **chapters; + + AVDictionary *metadata; + + /** + * Start time of the stream in real world time, in microseconds + * since the unix epoch (00:00 1st January 1970). That is, pts=0 + * in the stream was captured at this real world time. + * - encoding: Set by user. + * - decoding: Unused. + */ + int64_t start_time_realtime; + + /** + * decoding: number of frames used to probe fps + */ + int fps_probe_size; + + /** + * Error recognition; higher values will detect more errors but may + * misdetect some more or less valid parts as errors. + * - encoding: unused + * - decoding: Set by user. + */ + int error_recognition; + + /** + * Custom interrupt callbacks for the I/O layer. + * + * decoding: set by the user before avformat_open_input(). + * encoding: set by the user before avformat_write_header() + * (mainly useful for AVFMT_NOFILE formats). The callback + * should also be passed to avio_open2() if it's used to + * open the file. + */ + AVIOInterruptCB interrupt_callback; + + /** + * Flags to enable debugging. + */ + int debug; +#define FF_FDEBUG_TS 0x0001 + /***************************************************************** + * All fields below this line are not part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + + /** + * This buffer is only needed when packets were already buffered but + * not decoded, for example to get the codec parameters in MPEG + * streams. + */ + struct AVPacketList *packet_buffer; + struct AVPacketList *packet_buffer_end; + + /* av_seek_frame() support */ + int64_t data_offset; /**< offset of the first packet */ + + /** + * Raw packets from the demuxer, prior to parsing and decoding. + * This buffer is used for buffering packets until the codec can + * be identified, as parsing cannot be done without knowing the + * codec. + */ + struct AVPacketList *raw_packet_buffer; + struct AVPacketList *raw_packet_buffer_end; + /** + * Packets split by the parser get queued here. + */ + struct AVPacketList *parse_queue; + struct AVPacketList *parse_queue_end; + /** + * Remaining size available for raw_packet_buffer, in bytes. + */ +#define RAW_PACKET_BUFFER_SIZE 2500000 + int raw_packet_buffer_remaining_size; + + /** + * Offset to remap timestamps to be non-negative. + * Expressed in timebase units. + */ + int64_t offset; + + /** + * Timebase for the timestamp offset. + */ + AVRational offset_timebase; + +} AVFormatContext; + +typedef struct AVPacketList { + AVPacket pkt; + struct AVPacketList *next; +} AVPacketList; + + +/** + * @defgroup lavf_core Core functions + * @ingroup libavf + * + * Functions for querying libavformat capabilities, allocating core structures, + * etc. + * @{ + */ + +/** + * Return the LIBAVFORMAT_VERSION_INT constant. + */ +unsigned avformat_version(void); + +/** + * Return the libavformat build-time configuration. + */ +const char *avformat_configuration(void); + +/** + * Return the libavformat license. + */ +const char *avformat_license(void); + +/** + * Initialize libavformat and register all the muxers, demuxers and + * protocols. If you do not call this function, then you can select + * exactly which formats you want to support. + * + * @see av_register_input_format() + * @see av_register_output_format() + * @see av_register_protocol() + */ +void av_register_all(void); + +void av_register_input_format(AVInputFormat *format); +void av_register_output_format(AVOutputFormat *format); + +/** + * Do global initialization of network components. This is optional, + * but recommended, since it avoids the overhead of implicitly + * doing the setup for each session. + * + * Calling this function will become mandatory if using network + * protocols at some major version bump. + */ +int avformat_network_init(void); + +/** + * Undo the initialization done by avformat_network_init. + */ +int avformat_network_deinit(void); + +/** + * If f is NULL, returns the first registered input format, + * if f is non-NULL, returns the next registered input format after f + * or NULL if f is the last one. + */ +AVInputFormat *av_iformat_next(AVInputFormat *f); + +/** + * If f is NULL, returns the first registered output format, + * if f is non-NULL, returns the next registered output format after f + * or NULL if f is the last one. + */ +AVOutputFormat *av_oformat_next(AVOutputFormat *f); + +/** + * Allocate an AVFormatContext. + * avformat_free_context() can be used to free the context and everything + * allocated by the framework within it. + */ +AVFormatContext *avformat_alloc_context(void); + +/** + * Free an AVFormatContext and all its streams. + * @param s context to free + */ +void avformat_free_context(AVFormatContext *s); + +/** + * Get the AVClass for AVFormatContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *avformat_get_class(void); + +/** + * Add a new stream to a media file. + * + * When demuxing, it is called by the demuxer in read_header(). If the + * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also + * be called in read_packet(). + * + * When muxing, should be called by the user before avformat_write_header(). + * + * @param c If non-NULL, the AVCodecContext corresponding to the new stream + * will be initialized to use this codec. This is needed for e.g. codec-specific + * defaults to be set, so codec should be provided if it is known. + * + * @return newly created stream or NULL on error. + */ +AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c); + +AVProgram *av_new_program(AVFormatContext *s, int id); + +/** + * @} + */ + + +/** + * @addtogroup lavf_decoding + * @{ + */ + +/** + * Find AVInputFormat based on the short name of the input format. + */ +AVInputFormat *av_find_input_format(const char *short_name); + +/** + * Guess the file format. + * + * @param is_opened Whether the file is already opened; determines whether + * demuxers with or without AVFMT_NOFILE are probed. + */ +AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); + +/** + * Guess the file format. + * + * @param is_opened Whether the file is already opened; determines whether + * demuxers with or without AVFMT_NOFILE are probed. + * @param score_max A probe score larger that this is required to accept a + * detection, the variable is set to the actual detection + * score afterwards. + * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended + * to retry with a larger probe buffer. + */ +AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max); + +/** + * Probe a bytestream to determine the input format. Each time a probe returns + * with a score that is too low, the probe buffer size is increased and another + * attempt is made. When the maximum probe size is reached, the input format + * with the highest score is returned. + * + * @param pb the bytestream to probe + * @param fmt the input format is put here + * @param filename the filename of the stream + * @param logctx the log context + * @param offset the offset within the bytestream to probe from + * @param max_probe_size the maximum probe buffer size (zero for default) + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code otherwise + */ +int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, + const char *filename, void *logctx, + unsigned int offset, unsigned int max_probe_size); + +/** + * Open an input stream and read the header. The codecs are not opened. + * The stream must be closed with avformat_close_input(). + * + * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). + * May be a pointer to NULL, in which case an AVFormatContext is allocated by this + * function and written into ps. + * Note that a user-supplied AVFormatContext will be freed on failure. + * @param filename Name of the stream to open. + * @param fmt If non-NULL, this parameter forces a specific input format. + * Otherwise the format is autodetected. + * @param options A dictionary filled with AVFormatContext and demuxer-private options. + * On return this parameter will be destroyed and replaced with a dict containing + * options that were not found. May be NULL. + * + * @return 0 on success, a negative AVERROR on failure. + * + * @note If you want to use custom IO, preallocate the format context and set its pb field. + */ +int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options); + +/** + * Read packets of a media file to get stream information. This + * is useful for file formats with no headers such as MPEG. This + * function also computes the real framerate in case of MPEG-2 repeat + * frame mode. + * The logical file position is not changed by this function; + * examined packets may be buffered for later processing. + * + * @param ic media file handle + * @param options If non-NULL, an ic.nb_streams long array of pointers to + * dictionaries, where i-th member contains options for + * codec corresponding to i-th stream. + * On return each dictionary will be filled with options that were not found. + * @return >=0 if OK, AVERROR_xxx on error + * + * @note this function isn't guaranteed to open all the codecs, so + * options being non-empty at return is a perfectly normal behavior. + * + * @todo Let the user decide somehow what information is needed so that + * we do not waste time getting stuff the user does not need. + */ +int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options); + +/** + * Find the "best" stream in the file. + * The best stream is determined according to various heuristics as the most + * likely to be what the user expects. + * If the decoder parameter is non-NULL, av_find_best_stream will find the + * default decoder for the stream's codec; streams for which no decoder can + * be found are ignored. + * + * @param ic media file handle + * @param type stream type: video, audio, subtitles, etc. + * @param wanted_stream_nb user-requested stream number, + * or -1 for automatic selection + * @param related_stream try to find a stream related (eg. in the same + * program) to this one, or -1 if none + * @param decoder_ret if non-NULL, returns the decoder for the + * selected stream + * @param flags flags; none are currently defined + * @return the non-negative stream number in case of success, + * AVERROR_STREAM_NOT_FOUND if no stream with the requested type + * could be found, + * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder + * @note If av_find_best_stream returns successfully and decoder_ret is not + * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec. + */ +int av_find_best_stream(AVFormatContext *ic, + enum AVMediaType type, + int wanted_stream_nb, + int related_stream, + AVCodec **decoder_ret, + int flags); + +/** + * Return the next frame of a stream. + * This function returns what is stored in the file, and does not validate + * that what is there are valid frames for the decoder. It will split what is + * stored in the file into frames and return one for each call. It will not + * omit invalid data between valid frames so as to give the decoder the maximum + * information possible for decoding. + * + * If pkt->buf is NULL, then the packet is valid until the next + * av_read_frame() or until avformat_close_input(). Otherwise the packet + * is valid indefinitely. In both cases the packet must be freed with + * av_free_packet when it is no longer needed. For video, the packet contains + * exactly one frame. For audio, it contains an integer number of frames if each + * frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames + * have a variable size (e.g. MPEG audio), then it contains one frame. + * + * pkt->pts, pkt->dts and pkt->duration are always set to correct + * values in AVStream.time_base units (and guessed if the format cannot + * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format + * has B-frames, so it is better to rely on pkt->dts if you do not + * decompress the payload. + * + * @return 0 if OK, < 0 on error or end of file + */ +int av_read_frame(AVFormatContext *s, AVPacket *pkt); + +/** + * Seek to the keyframe at timestamp. + * 'timestamp' in 'stream_index'. + * @param stream_index If stream_index is (-1), a default + * stream is selected, and timestamp is automatically converted + * from AV_TIME_BASE units to the stream specific time_base. + * @param timestamp Timestamp in AVStream.time_base units + * or, if no stream is specified, in AV_TIME_BASE units. + * @param flags flags which select direction and seeking mode + * @return >= 0 on success + */ +int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, + int flags); + +/** + * Seek to timestamp ts. + * Seeking will be done so that the point from which all active streams + * can be presented successfully will be closest to ts and within min/max_ts. + * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. + * + * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and + * are the file position (this may not be supported by all demuxers). + * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames + * in the stream with stream_index (this may not be supported by all demuxers). + * Otherwise all timestamps are in units of the stream selected by stream_index + * or if stream_index is -1, in AV_TIME_BASE units. + * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as + * keyframes (this may not be supported by all demuxers). + * + * @param stream_index index of the stream which is used as time base reference + * @param min_ts smallest acceptable timestamp + * @param ts target timestamp + * @param max_ts largest acceptable timestamp + * @param flags flags + * @return >=0 on success, error code otherwise + * + * @note This is part of the new seek API which is still under construction. + * Thus do not use this yet. It may change at any time, do not expect + * ABI compatibility yet! + */ +int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); + +/** + * Start playing a network-based stream (e.g. RTSP stream) at the + * current position. + */ +int av_read_play(AVFormatContext *s); + +/** + * Pause a network-based stream (e.g. RTSP stream). + * + * Use av_read_play() to resume it. + */ +int av_read_pause(AVFormatContext *s); + +/** + * Close an opened input AVFormatContext. Free it and all its contents + * and set *s to NULL. + */ +void avformat_close_input(AVFormatContext **s); +/** + * @} + */ + +#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward +#define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes +#define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes +#define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number + +/** + * @addtogroup lavf_encoding + * @{ + */ +/** + * Allocate the stream private data and write the stream header to + * an output media file. + * + * @param s Media file handle, must be allocated with avformat_alloc_context(). + * Its oformat field must be set to the desired output format; + * Its pb field must be set to an already opened AVIOContext. + * @param options An AVDictionary filled with AVFormatContext and muxer-private options. + * On return this parameter will be destroyed and replaced with a dict containing + * options that were not found. May be NULL. + * + * @return 0 on success, negative AVERROR on failure. + * + * @see av_opt_find, av_dict_set, avio_open, av_oformat_next. + */ +int avformat_write_header(AVFormatContext *s, AVDictionary **options); + +/** + * Write a packet to an output media file. + * + * The packet shall contain one audio or video frame. + * The packet must be correctly interleaved according to the container + * specification, if not then av_interleaved_write_frame must be used. + * + * @param s media file handle + * @param pkt The packet, which contains the stream_index, buf/buf_size, + * dts/pts, ... + * This can be NULL (at any time, not just at the end), in + * order to immediately flush data buffered within the muxer, + * for muxers that buffer up data internally before writing it + * to the output. + * @return < 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush + */ +int av_write_frame(AVFormatContext *s, AVPacket *pkt); + +/** + * Write a packet to an output media file ensuring correct interleaving. + * + * The packet must contain one audio or video frame. + * If the packets are already correctly interleaved, the application should + * call av_write_frame() instead as it is slightly faster. It is also important + * to keep in mind that completely non-interleaved input will need huge amounts + * of memory to interleave with this, so it is preferable to interleave at the + * demuxer level. + * + * @param s media file handle + * @param pkt The packet containing the data to be written. pkt->buf must be set + * to a valid AVBufferRef describing the packet data. Libavformat takes + * ownership of this reference and will unref it when it sees fit. The caller + * must not access the data through this reference after this function returns. + * This can be NULL (at any time, not just at the end), to flush the + * interleaving queues. + * Packet's @ref AVPacket.stream_index "stream_index" field must be set to the + * index of the corresponding stream in @ref AVFormatContext.streams + * "s.streams". + * It is very strongly recommended that timing information (@ref AVPacket.pts + * "pts", @ref AVPacket.dts "dts" @ref AVPacket.duration "duration") is set to + * correct values. + * + * @return 0 on success, a negative AVERROR on error. + */ +int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); + +/** + * Write the stream trailer to an output media file and free the + * file private data. + * + * May only be called after a successful call to avformat_write_header. + * + * @param s media file handle + * @return 0 if OK, AVERROR_xxx on error + */ +int av_write_trailer(AVFormatContext *s); + +/** + * Return the output format in the list of registered output formats + * which best matches the provided parameters, or return NULL if + * there is no match. + * + * @param short_name if non-NULL checks if short_name matches with the + * names of the registered formats + * @param filename if non-NULL checks if filename terminates with the + * extensions of the registered formats + * @param mime_type if non-NULL checks if mime_type matches with the + * MIME type of the registered formats + */ +AVOutputFormat *av_guess_format(const char *short_name, + const char *filename, + const char *mime_type); + +/** + * Guess the codec ID based upon muxer and filename. + */ +enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, + const char *filename, const char *mime_type, + enum AVMediaType type); + +/** + * @} + */ + + +/** + * @defgroup lavf_misc Utility functions + * @ingroup libavf + * @{ + * + * Miscellaneous utility functions related to both muxing and demuxing + * (or neither). + */ + +/** + * Send a nice hexadecimal dump of a buffer to the specified file stream. + * + * @param f The file stream pointer where the dump should be sent to. + * @param buf buffer + * @param size buffer size + * + * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2 + */ +void av_hex_dump(FILE *f, const uint8_t *buf, int size); + +/** + * Send a nice hexadecimal dump of a buffer to the log. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param buf buffer + * @param size buffer size + * + * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2 + */ +void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size); + +/** + * Send a nice dump of a packet to the specified file stream. + * + * @param f The file stream pointer where the dump should be sent to. + * @param pkt packet to dump + * @param dump_payload True if the payload must be displayed, too. + * @param st AVStream that the packet belongs to + */ +void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st); + + +/** + * Send a nice dump of a packet to the log. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param pkt packet to dump + * @param dump_payload True if the payload must be displayed, too. + * @param st AVStream that the packet belongs to + */ +void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, + AVStream *st); + +/** + * Get the AVCodecID for the given codec tag tag. + * If no codec id is found returns AV_CODEC_ID_NONE. + * + * @param tags list of supported codec_id-codec_tag pairs, as stored + * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag + */ +enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag); + +/** + * Get the codec tag for the given codec id id. + * If no codec tag is found returns 0. + * + * @param tags list of supported codec_id-codec_tag pairs, as stored + * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag + */ +unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id); + +int av_find_default_stream_index(AVFormatContext *s); + +/** + * Get the index for a specific timestamp. + * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond + * to the timestamp which is <= the requested one, if backward + * is 0, then it will be >= + * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise + * @return < 0 if no such timestamp could be found + */ +int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); + +/** + * Add an index entry into a sorted list. Update the entry if the list + * already contains it. + * + * @param timestamp timestamp in the time base of the given stream + */ +int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, + int size, int distance, int flags); + + +/** + * Split a URL string into components. + * + * The pointers to buffers for storing individual components may be null, + * in order to ignore that component. Buffers for components not found are + * set to empty strings. If the port is not found, it is set to a negative + * value. + * + * @param proto the buffer for the protocol + * @param proto_size the size of the proto buffer + * @param authorization the buffer for the authorization + * @param authorization_size the size of the authorization buffer + * @param hostname the buffer for the host name + * @param hostname_size the size of the hostname buffer + * @param port_ptr a pointer to store the port number in + * @param path the buffer for the path + * @param path_size the size of the path buffer + * @param url the URL to split + */ +void av_url_split(char *proto, int proto_size, + char *authorization, int authorization_size, + char *hostname, int hostname_size, + int *port_ptr, + char *path, int path_size, + const char *url); + + +void av_dump_format(AVFormatContext *ic, + int index, + const char *url, + int is_output); + +/** + * Return in 'buf' the path with '%d' replaced by a number. + * + * Also handles the '%0nd' format where 'n' is the total number + * of digits and '%%'. + * + * @param buf destination buffer + * @param buf_size destination buffer size + * @param path numbered sequence string + * @param number frame number + * @return 0 if OK, -1 on format error + */ +int av_get_frame_filename(char *buf, int buf_size, + const char *path, int number); + +/** + * Check whether filename actually is a numbered sequence generator. + * + * @param filename possible numbered sequence string + * @return 1 if a valid numbered sequence string, 0 otherwise + */ +int av_filename_number_test(const char *filename); + +/** + * Generate an SDP for an RTP session. + * + * Note, this overwrites the id values of AVStreams in the muxer contexts + * for getting unique dynamic payload types. + * + * @param ac array of AVFormatContexts describing the RTP streams. If the + * array is composed by only one context, such context can contain + * multiple AVStreams (one AVStream per RTP stream). Otherwise, + * all the contexts in the array (an AVCodecContext per RTP stream) + * must contain only one AVStream. + * @param n_files number of AVCodecContexts contained in ac + * @param buf buffer where the SDP will be stored (must be allocated by + * the caller) + * @param size the size of the buffer + * @return 0 if OK, AVERROR_xxx on error + */ +int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size); + +/** + * Return a positive value if the given filename has one of the given + * extensions, 0 otherwise. + * + * @param extensions a comma-separated list of filename extensions + */ +int av_match_ext(const char *filename, const char *extensions); + +/** + * Test if the given container can store a codec. + * + * @param std_compliance standards compliance level, one of FF_COMPLIANCE_* + * + * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot. + * A negative number if this information is not available. + */ +int avformat_query_codec(AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance); + +/** + * @defgroup riff_fourcc RIFF FourCCs + * @{ + * Get the tables mapping RIFF FourCCs to libavcodec AVCodecIDs. The tables are + * meant to be passed to av_codec_get_id()/av_codec_get_tag() as in the + * following code: + * @code + * uint32_t tag = MKTAG('H', '2', '6', '4'); + * const struct AVCodecTag *table[] = { avformat_get_riff_video_tags(), 0 }; + * enum AVCodecID id = av_codec_get_id(table, tag); + * @endcode + */ +/** + * @return the table mapping RIFF FourCCs for video to libavcodec AVCodecID. + */ +const struct AVCodecTag *avformat_get_riff_video_tags(void); +/** + * @return the table mapping RIFF FourCCs for audio to AVCodecID. + */ +const struct AVCodecTag *avformat_get_riff_audio_tags(void); +/** + * @} + */ + +/** + * @} + */ + +#endif /* AVFORMAT_AVFORMAT_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/avio.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/avio.h new file mode 100644 index 000000000..b6d3cb33b --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/avio.h @@ -0,0 +1,433 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef AVFORMAT_AVIO_H +#define AVFORMAT_AVIO_H + +/** + * @file + * @ingroup lavf_io + * Buffered I/O operations + */ + +#include + +#include "libavutil/common.h" +#include "libavutil/dict.h" +#include "libavutil/log.h" + +#include "libavformat/version.h" + + +#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */ + +/** + * Callback for checking whether to abort blocking functions. + * AVERROR_EXIT is returned in this case by the interrupted + * function. During blocking operations, callback is called with + * opaque as parameter. If the callback returns 1, the + * blocking operation will be aborted. + * + * No members can be added to this struct without a major bump, if + * new elements have been added after this struct in AVFormatContext + * or AVIOContext. + */ +typedef struct AVIOInterruptCB { + int (*callback)(void*); + void *opaque; +} AVIOInterruptCB; + +/** + * Bytestream IO Context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVIOContext) must not be used outside libav*. + * + * @note None of the function pointers in AVIOContext should be called + * directly, they should only be set by the client application + * when implementing custom I/O. Normally these are set to the + * function pointers specified in avio_alloc_context() + */ +typedef struct AVIOContext { + /** + * A class for private options. + * + * If this AVIOContext is created by avio_open2(), av_class is set and + * passes the options down to protocols. + * + * If this AVIOContext is manually allocated, then av_class may be set by + * the caller. + * + * warning -- this field can be NULL, be sure to not pass this AVIOContext + * to any av_opt_* functions in that case. + */ + const AVClass *av_class; + unsigned char *buffer; /**< Start of the buffer. */ + int buffer_size; /**< Maximum buffer size */ + unsigned char *buf_ptr; /**< Current position in the buffer */ + unsigned char *buf_end; /**< End of the data, may be less than + buffer+buffer_size if the read function returned + less data than requested, e.g. for streams where + no more data has been received yet. */ + void *opaque; /**< A private pointer, passed to the read/write/seek/... + functions. */ + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); + int64_t (*seek)(void *opaque, int64_t offset, int whence); + int64_t pos; /**< position in the file of the current buffer */ + int must_flush; /**< true if the next seek should flush */ + int eof_reached; /**< true if eof reached */ + int write_flag; /**< true if open for writing */ + int max_packet_size; + unsigned long checksum; + unsigned char *checksum_ptr; + unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); + int error; /**< contains the error code or 0 if no error happened */ + /** + * Pause or resume playback for network streaming protocols - e.g. MMS. + */ + int (*read_pause)(void *opaque, int pause); + /** + * Seek to a given timestamp in stream with the specified stream_index. + * Needed for some network streaming protocols which don't support seeking + * to byte position. + */ + int64_t (*read_seek)(void *opaque, int stream_index, + int64_t timestamp, int flags); + /** + * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable. + */ + int seekable; +} AVIOContext; + +/* unbuffered I/O */ + +/** + * Return AVIO_FLAG_* access flags corresponding to the access permissions + * of the resource in url, or a negative value corresponding to an + * AVERROR code in case of failure. The returned access flags are + * masked by the value in flags. + * + * @note This function is intrinsically unsafe, in the sense that the + * checked resource may change its existence or permission status from + * one call to another. Thus you should not trust the returned value, + * unless you are sure that no other processes are accessing the + * checked resource. + */ +int avio_check(const char *url, int flags); + +/** + * Allocate and initialize an AVIOContext for buffered I/O. It must be later + * freed with av_free(). + * + * @param buffer Memory block for input/output operations via AVIOContext. + * The buffer must be allocated with av_malloc() and friends. + * @param buffer_size The buffer size is very important for performance. + * For protocols with fixed blocksize it should be set to this blocksize. + * For others a typical size is a cache page, e.g. 4kb. + * @param write_flag Set to 1 if the buffer should be writable, 0 otherwise. + * @param opaque An opaque pointer to user-specific data. + * @param read_packet A function for refilling the buffer, may be NULL. + * @param write_packet A function for writing the buffer contents, may be NULL. + * @param seek A function for seeking to specified byte position, may be NULL. + * + * @return Allocated AVIOContext or NULL on failure. + */ +AVIOContext *avio_alloc_context( + unsigned char *buffer, + int buffer_size, + int write_flag, + void *opaque, + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), + int64_t (*seek)(void *opaque, int64_t offset, int whence)); + +void avio_w8(AVIOContext *s, int b); +void avio_write(AVIOContext *s, const unsigned char *buf, int size); +void avio_wl64(AVIOContext *s, uint64_t val); +void avio_wb64(AVIOContext *s, uint64_t val); +void avio_wl32(AVIOContext *s, unsigned int val); +void avio_wb32(AVIOContext *s, unsigned int val); +void avio_wl24(AVIOContext *s, unsigned int val); +void avio_wb24(AVIOContext *s, unsigned int val); +void avio_wl16(AVIOContext *s, unsigned int val); +void avio_wb16(AVIOContext *s, unsigned int val); + +/** + * Write a NULL-terminated string. + * @return number of bytes written. + */ +int avio_put_str(AVIOContext *s, const char *str); + +/** + * Convert an UTF-8 string to UTF-16LE and write it. + * @return number of bytes written. + */ +int avio_put_str16le(AVIOContext *s, const char *str); + +/** + * Passing this as the "whence" parameter to a seek function causes it to + * return the filesize without seeking anywhere. Supporting this is optional. + * If it is not supported then the seek function will return <0. + */ +#define AVSEEK_SIZE 0x10000 + +/** + * Oring this flag as into the "whence" parameter to a seek function causes it to + * seek by any means (like reopening and linear reading) or other normally unreasonble + * means that can be extreemly slow. + * This may be ignored by the seek code. + */ +#define AVSEEK_FORCE 0x20000 + +/** + * fseek() equivalent for AVIOContext. + * @return new position or AVERROR. + */ +int64_t avio_seek(AVIOContext *s, int64_t offset, int whence); + +/** + * Skip given number of bytes forward + * @return new position or AVERROR. + */ +static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset) +{ + return avio_seek(s, offset, SEEK_CUR); +} + +/** + * ftell() equivalent for AVIOContext. + * @return position or AVERROR. + */ +static av_always_inline int64_t avio_tell(AVIOContext *s) +{ + return avio_seek(s, 0, SEEK_CUR); +} + +/** + * Get the filesize. + * @return filesize or AVERROR + */ +int64_t avio_size(AVIOContext *s); + +/** @warning currently size is limited */ +int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); + +void avio_flush(AVIOContext *s); + + +/** + * Read size bytes from AVIOContext into buf. + * @return number of bytes read or AVERROR + */ +int avio_read(AVIOContext *s, unsigned char *buf, int size); + +/** + * @name Functions for reading from AVIOContext + * @{ + * + * @note return 0 if EOF, so you cannot use it if EOF handling is + * necessary + */ +int avio_r8 (AVIOContext *s); +unsigned int avio_rl16(AVIOContext *s); +unsigned int avio_rl24(AVIOContext *s); +unsigned int avio_rl32(AVIOContext *s); +uint64_t avio_rl64(AVIOContext *s); +unsigned int avio_rb16(AVIOContext *s); +unsigned int avio_rb24(AVIOContext *s); +unsigned int avio_rb32(AVIOContext *s); +uint64_t avio_rb64(AVIOContext *s); +/** + * @} + */ + +/** + * Read a string from pb into buf. The reading will terminate when either + * a NULL character was encountered, maxlen bytes have been read, or nothing + * more can be read from pb. The result is guaranteed to be NULL-terminated, it + * will be truncated if buf is too small. + * Note that the string is not interpreted or validated in any way, it + * might get truncated in the middle of a sequence for multi-byte encodings. + * + * @return number of bytes read (is always <= maxlen). + * If reading ends on EOF or error, the return value will be one more than + * bytes actually read. + */ +int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen); + +/** + * Read a UTF-16 string from pb and convert it to UTF-8. + * The reading will terminate when either a null or invalid character was + * encountered or maxlen bytes have been read. + * @return number of bytes read (is always <= maxlen) + */ +int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen); +int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); + + +/** + * @name URL open modes + * The flags argument to avio_open must be one of the following + * constants, optionally ORed with other flags. + * @{ + */ +#define AVIO_FLAG_READ 1 /**< read-only */ +#define AVIO_FLAG_WRITE 2 /**< write-only */ +#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */ +/** + * @} + */ + +/** + * Use non-blocking mode. + * If this flag is set, operations on the context will return + * AVERROR(EAGAIN) if they can not be performed immediately. + * If this flag is not set, operations on the context will never return + * AVERROR(EAGAIN). + * Note that this flag does not affect the opening/connecting of the + * context. Connecting a protocol will always block if necessary (e.g. on + * network protocols) but never hang (e.g. on busy devices). + * Warning: non-blocking protocols is work-in-progress; this flag may be + * silently ignored. + */ +#define AVIO_FLAG_NONBLOCK 8 + +/** + * Create and initialize a AVIOContext for accessing the + * resource indicated by url. + * @note When the resource indicated by url has been opened in + * read+write mode, the AVIOContext can be used only for writing. + * + * @param s Used to return the pointer to the created AVIOContext. + * In case of failure the pointed to value is set to NULL. + * @param flags flags which control how the resource indicated by url + * is to be opened + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + */ +int avio_open(AVIOContext **s, const char *url, int flags); + +/** + * Create and initialize a AVIOContext for accessing the + * resource indicated by url. + * @note When the resource indicated by url has been opened in + * read+write mode, the AVIOContext can be used only for writing. + * + * @param s Used to return the pointer to the created AVIOContext. + * In case of failure the pointed to value is set to NULL. + * @param flags flags which control how the resource indicated by url + * is to be opened + * @param int_cb an interrupt callback to be used at the protocols level + * @param options A dictionary filled with protocol-private options. On return + * this parameter will be destroyed and replaced with a dict containing options + * that were not found. May be NULL. + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + */ +int avio_open2(AVIOContext **s, const char *url, int flags, + const AVIOInterruptCB *int_cb, AVDictionary **options); + +/** + * Close the resource accessed by the AVIOContext s and free it. + * This function can only be used if s was opened by avio_open(). + * + * The internal buffer is automatically flushed before closing the + * resource. + * + * @return 0 on success, an AVERROR < 0 on error. + * @see avio_closep + */ +int avio_close(AVIOContext *s); + +/** + * Close the resource accessed by the AVIOContext *s, free it + * and set the pointer pointing to it to NULL. + * This function can only be used if s was opened by avio_open(). + * + * The internal buffer is automatically flushed before closing the + * resource. + * + * @return 0 on success, an AVERROR < 0 on error. + * @see avio_close + */ +int avio_closep(AVIOContext **s); + + +/** + * Open a write only memory stream. + * + * @param s new IO context + * @return zero if no error. + */ +int avio_open_dyn_buf(AVIOContext **s); + +/** + * Return the written size and a pointer to the buffer. The buffer + * must be freed with av_free(). + * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer. + * + * @param s IO context + * @param pbuffer pointer to a byte buffer + * @return the length of the byte buffer + */ +int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); + +/** + * Iterate through names of available protocols. + * + * @param opaque A private pointer representing current protocol. + * It must be a pointer to NULL on first iteration and will + * be updated by successive calls to avio_enum_protocols. + * @param output If set to 1, iterate over output protocols, + * otherwise over input protocols. + * + * @return A static string containing the name of current protocol or NULL + */ +const char *avio_enum_protocols(void **opaque, int output); + +/** + * Pause and resume playing - only meaningful if using a network streaming + * protocol (e.g. MMS). + * @param pause 1 for pause, 0 for resume + */ +int avio_pause(AVIOContext *h, int pause); + +/** + * Seek to a given timestamp relative to some component stream. + * Only meaningful if using a network streaming protocol (e.g. MMS.). + * @param stream_index The stream index that the timestamp is relative to. + * If stream_index is (-1) the timestamp should be in AV_TIME_BASE + * units from the beginning of the presentation. + * If a stream_index >= 0 is used and the protocol does not support + * seeking based on component streams, the call will fail with ENOTSUP. + * @param timestamp timestamp in AVStream.time_base units + * or if there is no stream specified then in AV_TIME_BASE units. + * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE + * and AVSEEK_FLAG_ANY. The protocol may silently ignore + * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will + * fail with ENOTSUP if used and not supported. + * @return >= 0 on success + * @see AVInputFormat::read_seek + */ +int64_t avio_seek_time(AVIOContext *h, int stream_index, + int64_t timestamp, int flags); + +#endif /* AVFORMAT_AVIO_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/version.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/version.h new file mode 100644 index 000000000..ac675ce95 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavformat/version.h @@ -0,0 +1,52 @@ +/* + * Version macros. + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFORMAT_VERSION_H +#define AVFORMAT_VERSION_H + +/** + * @file + * @ingroup libavf + * Libavformat version macros + */ + +#include "libavutil/avutil.h" + +#define LIBAVFORMAT_VERSION_MAJOR 55 +#define LIBAVFORMAT_VERSION_MINOR 3 +#define LIBAVFORMAT_VERSION_MICRO 0 + +#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ + LIBAVFORMAT_VERSION_MINOR, \ + LIBAVFORMAT_VERSION_MICRO) +#define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \ + LIBAVFORMAT_VERSION_MINOR, \ + LIBAVFORMAT_VERSION_MICRO) +#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT + +#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + */ + +#endif /* AVFORMAT_VERSION_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavresample/avresample.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavresample/avresample.h new file mode 100644 index 000000000..d26f2ca22 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavresample/avresample.h @@ -0,0 +1,409 @@ +/* + * Copyright (c) 2012 Justin Ruggles + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVRESAMPLE_AVRESAMPLE_H +#define AVRESAMPLE_AVRESAMPLE_H + +/** + * @file + * @ingroup lavr + * external API header + */ + +/** + * @defgroup lavr Libavresample + * @{ + * + * Libavresample (lavr) is a library that handles audio resampling, sample + * format conversion and mixing. + * + * Interaction with lavr is done through AVAudioResampleContext, which is + * allocated with avresample_alloc_context(). It is opaque, so all parameters + * must be set with the @ref avoptions API. + * + * For example the following code will setup conversion from planar float sample + * format to interleaved signed 16-bit integer, downsampling from 48kHz to + * 44.1kHz and downmixing from 5.1 channels to stereo (using the default mixing + * matrix): + * @code + * AVAudioResampleContext *avr = avresample_alloc_context(); + * av_opt_set_int(avr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0); + * av_opt_set_int(avr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0); + * av_opt_set_int(avr, "in_sample_rate", 48000, 0); + * av_opt_set_int(avr, "out_sample_rate", 44100, 0); + * av_opt_set_int(avr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); + * av_opt_set_int(avr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); + * @endcode + * + * Once the context is initialized, it must be opened with avresample_open(). If + * you need to change the conversion parameters, you must close the context with + * avresample_close(), change the parameters as described above, then reopen it + * again. + * + * The conversion itself is done by repeatedly calling avresample_convert(). + * Note that the samples may get buffered in two places in lavr. The first one + * is the output FIFO, where the samples end up if the output buffer is not + * large enough. The data stored in there may be retrieved at any time with + * avresample_read(). The second place is the resampling delay buffer, + * applicable only when resampling is done. The samples in it require more input + * before they can be processed. Their current amount is returned by + * avresample_get_delay(). At the end of conversion the resampling buffer can be + * flushed by calling avresample_convert() with NULL input. + * + * The following code demonstrates the conversion loop assuming the parameters + * from above and caller-defined functions get_input() and handle_output(): + * @code + * uint8_t **input; + * int in_linesize, in_samples; + * + * while (get_input(&input, &in_linesize, &in_samples)) { + * uint8_t *output + * int out_linesize; + * int out_samples = avresample_available(avr) + + * av_rescale_rnd(avresample_get_delay(avr) + + * in_samples, 44100, 48000, AV_ROUND_UP); + * av_samples_alloc(&output, &out_linesize, 2, out_samples, + * AV_SAMPLE_FMT_S16, 0); + * out_samples = avresample_convert(avr, &output, out_linesize, out_samples, + * input, in_linesize, in_samples); + * handle_output(output, out_linesize, out_samples); + * av_freep(&output); + * } + * @endcode + * + * When the conversion is finished and the FIFOs are flushed if required, the + * conversion context and everything associated with it must be freed with + * avresample_free(). + */ + +#include "libavutil/avutil.h" +#include "libavutil/channel_layout.h" +#include "libavutil/dict.h" +#include "libavutil/log.h" + +#include "libavresample/version.h" + +#define AVRESAMPLE_MAX_CHANNELS 32 + +typedef struct AVAudioResampleContext AVAudioResampleContext; + +/** Mixing Coefficient Types */ +enum AVMixCoeffType { + AV_MIX_COEFF_TYPE_Q8, /** 16-bit 8.8 fixed-point */ + AV_MIX_COEFF_TYPE_Q15, /** 32-bit 17.15 fixed-point */ + AV_MIX_COEFF_TYPE_FLT, /** floating-point */ + AV_MIX_COEFF_TYPE_NB, /** Number of coeff types. Not part of ABI */ +}; + +/** Resampling Filter Types */ +enum AVResampleFilterType { + AV_RESAMPLE_FILTER_TYPE_CUBIC, /**< Cubic */ + AV_RESAMPLE_FILTER_TYPE_BLACKMAN_NUTTALL, /**< Blackman Nuttall Windowed Sinc */ + AV_RESAMPLE_FILTER_TYPE_KAISER, /**< Kaiser Windowed Sinc */ +}; + +enum AVResampleDitherMethod { + AV_RESAMPLE_DITHER_NONE, /**< Do not use dithering */ + AV_RESAMPLE_DITHER_RECTANGULAR, /**< Rectangular Dither */ + AV_RESAMPLE_DITHER_TRIANGULAR, /**< Triangular Dither*/ + AV_RESAMPLE_DITHER_TRIANGULAR_HP, /**< Triangular Dither with High Pass */ + AV_RESAMPLE_DITHER_TRIANGULAR_NS, /**< Triangular Dither with Noise Shaping */ + AV_RESAMPLE_DITHER_NB, /**< Number of dither types. Not part of ABI. */ +}; + +/** + * Return the LIBAVRESAMPLE_VERSION_INT constant. + */ +unsigned avresample_version(void); + +/** + * Return the libavresample build-time configuration. + * @return configure string + */ +const char *avresample_configuration(void); + +/** + * Return the libavresample license. + */ +const char *avresample_license(void); + +/** + * Get the AVClass for AVAudioResampleContext. + * + * Can be used in combination with AV_OPT_SEARCH_FAKE_OBJ for examining options + * without allocating a context. + * + * @see av_opt_find(). + * + * @return AVClass for AVAudioResampleContext + */ +const AVClass *avresample_get_class(void); + +/** + * Allocate AVAudioResampleContext and set options. + * + * @return allocated audio resample context, or NULL on failure + */ +AVAudioResampleContext *avresample_alloc_context(void); + +/** + * Initialize AVAudioResampleContext. + * + * @param avr audio resample context + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_open(AVAudioResampleContext *avr); + +/** + * Close AVAudioResampleContext. + * + * This closes the context, but it does not change the parameters. The context + * can be reopened with avresample_open(). It does, however, clear the output + * FIFO and any remaining leftover samples in the resampling delay buffer. If + * there was a custom matrix being used, that is also cleared. + * + * @see avresample_convert() + * @see avresample_set_matrix() + * + * @param avr audio resample context + */ +void avresample_close(AVAudioResampleContext *avr); + +/** + * Free AVAudioResampleContext and associated AVOption values. + * + * This also calls avresample_close() before freeing. + * + * @param avr audio resample context + */ +void avresample_free(AVAudioResampleContext **avr); + +/** + * Generate a channel mixing matrix. + * + * This function is the one used internally by libavresample for building the + * default mixing matrix. It is made public just as a utility function for + * building custom matrices. + * + * @param in_layout input channel layout + * @param out_layout output channel layout + * @param center_mix_level mix level for the center channel + * @param surround_mix_level mix level for the surround channel(s) + * @param lfe_mix_level mix level for the low-frequency effects channel + * @param normalize if 1, coefficients will be normalized to prevent + * overflow. if 0, coefficients will not be + * normalized. + * @param[out] matrix mixing coefficients; matrix[i + stride * o] is + * the weight of input channel i in output channel o. + * @param stride distance between adjacent input channels in the + * matrix array + * @param matrix_encoding matrixed stereo downmix mode (e.g. dplii) + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_build_matrix(uint64_t in_layout, uint64_t out_layout, + double center_mix_level, double surround_mix_level, + double lfe_mix_level, int normalize, double *matrix, + int stride, enum AVMatrixEncoding matrix_encoding); + +/** + * Get the current channel mixing matrix. + * + * If no custom matrix has been previously set or the AVAudioResampleContext is + * not open, an error is returned. + * + * @param avr audio resample context + * @param matrix mixing coefficients; matrix[i + stride * o] is the weight of + * input channel i in output channel o. + * @param stride distance between adjacent input channels in the matrix array + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_get_matrix(AVAudioResampleContext *avr, double *matrix, + int stride); + +/** + * Set channel mixing matrix. + * + * Allows for setting a custom mixing matrix, overriding the default matrix + * generated internally during avresample_open(). This function can be called + * anytime on an allocated context, either before or after calling + * avresample_open(), as long as the channel layouts have been set. + * avresample_convert() always uses the current matrix. + * Calling avresample_close() on the context will clear the current matrix. + * + * @see avresample_close() + * + * @param avr audio resample context + * @param matrix mixing coefficients; matrix[i + stride * o] is the weight of + * input channel i in output channel o. + * @param stride distance between adjacent input channels in the matrix array + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_set_matrix(AVAudioResampleContext *avr, const double *matrix, + int stride); + +/** + * Set a customized input channel mapping. + * + * This function can only be called when the allocated context is not open. + * Also, the input channel layout must have already been set. + * + * Calling avresample_close() on the context will clear the channel mapping. + * + * The map for each input channel specifies the channel index in the source to + * use for that particular channel, or -1 to mute the channel. Source channels + * can be duplicated by using the same index for multiple input channels. + * + * Examples: + * + * Reordering 5.1 AAC order (C,L,R,Ls,Rs,LFE) to Libav order (L,R,C,LFE,Ls,Rs): + * { 1, 2, 0, 5, 3, 4 } + * + * Muting the 3rd channel in 4-channel input: + * { 0, 1, -1, 3 } + * + * Duplicating the left channel of stereo input: + * { 0, 0 } + * + * @param avr audio resample context + * @param channel_map customized input channel mapping + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_set_channel_mapping(AVAudioResampleContext *avr, + const int *channel_map); + +/** + * Set compensation for resampling. + * + * This can be called anytime after avresample_open(). If resampling is not + * automatically enabled because of a sample rate conversion, the + * "force_resampling" option must have been set to 1 when opening the context + * in order to use resampling compensation. + * + * @param avr audio resample context + * @param sample_delta compensation delta, in samples + * @param compensation_distance compensation distance, in samples + * @return 0 on success, negative AVERROR code on failure + */ +int avresample_set_compensation(AVAudioResampleContext *avr, int sample_delta, + int compensation_distance); + +/** + * Convert input samples and write them to the output FIFO. + * + * The upper bound on the number of output samples is given by + * avresample_available() + (avresample_get_delay() + number of input samples) * + * output sample rate / input sample rate. + * + * The output data can be NULL or have fewer allocated samples than required. + * In this case, any remaining samples not written to the output will be added + * to an internal FIFO buffer, to be returned at the next call to this function + * or to avresample_read(). + * + * If converting sample rate, there may be data remaining in the internal + * resampling delay buffer. avresample_get_delay() tells the number of remaining + * samples. To get this data as output, call avresample_convert() with NULL + * input. + * + * At the end of the conversion process, there may be data remaining in the + * internal FIFO buffer. avresample_available() tells the number of remaining + * samples. To get this data as output, either call avresample_convert() with + * NULL input or call avresample_read(). + * + * @see avresample_available() + * @see avresample_read() + * @see avresample_get_delay() + * + * @param avr audio resample context + * @param output output data pointers + * @param out_plane_size output plane size, in bytes. + * This can be 0 if unknown, but that will lead to + * optimized functions not being used directly on the + * output, which could slow down some conversions. + * @param out_samples maximum number of samples that the output buffer can hold + * @param input input data pointers + * @param in_plane_size input plane size, in bytes + * This can be 0 if unknown, but that will lead to + * optimized functions not being used directly on the + * input, which could slow down some conversions. + * @param in_samples number of input samples to convert + * @return number of samples written to the output buffer, + * not including converted samples added to the internal + * output FIFO + */ +int avresample_convert(AVAudioResampleContext *avr, uint8_t **output, + int out_plane_size, int out_samples, uint8_t **input, + int in_plane_size, int in_samples); + +/** + * Return the number of samples currently in the resampling delay buffer. + * + * When resampling, there may be a delay between the input and output. Any + * unconverted samples in each call are stored internally in a delay buffer. + * This function allows the user to determine the current number of samples in + * the delay buffer, which can be useful for synchronization. + * + * @see avresample_convert() + * + * @param avr audio resample context + * @return number of samples currently in the resampling delay buffer + */ +int avresample_get_delay(AVAudioResampleContext *avr); + +/** + * Return the number of available samples in the output FIFO. + * + * During conversion, if the user does not specify an output buffer or + * specifies an output buffer that is smaller than what is needed, remaining + * samples that are not written to the output are stored to an internal FIFO + * buffer. The samples in the FIFO can be read with avresample_read() or + * avresample_convert(). + * + * @see avresample_read() + * @see avresample_convert() + * + * @param avr audio resample context + * @return number of samples available for reading + */ +int avresample_available(AVAudioResampleContext *avr); + +/** + * Read samples from the output FIFO. + * + * During conversion, if the user does not specify an output buffer or + * specifies an output buffer that is smaller than what is needed, remaining + * samples that are not written to the output are stored to an internal FIFO + * buffer. This function can be used to read samples from that internal FIFO. + * + * @see avresample_available() + * @see avresample_convert() + * + * @param avr audio resample context + * @param output output data pointers. May be NULL, in which case + * nb_samples of data is discarded from output FIFO. + * @param nb_samples number of samples to read from the FIFO + * @return the number of samples written to output + */ +int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int nb_samples); + +/** + * @} + */ + +#endif /* AVRESAMPLE_AVRESAMPLE_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavresample/version.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavresample/version.h new file mode 100644 index 000000000..3cc4441d8 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavresample/version.h @@ -0,0 +1,52 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVRESAMPLE_VERSION_H +#define AVRESAMPLE_VERSION_H + +/** + * @file + * @ingroup lavr + * Libavresample version macros. + */ + +#define LIBAVRESAMPLE_VERSION_MAJOR 1 +#define LIBAVRESAMPLE_VERSION_MINOR 1 +#define LIBAVRESAMPLE_VERSION_MICRO 0 + +#define LIBAVRESAMPLE_VERSION_INT AV_VERSION_INT(LIBAVRESAMPLE_VERSION_MAJOR, \ + LIBAVRESAMPLE_VERSION_MINOR, \ + LIBAVRESAMPLE_VERSION_MICRO) +#define LIBAVRESAMPLE_VERSION AV_VERSION(LIBAVRESAMPLE_VERSION_MAJOR, \ + LIBAVRESAMPLE_VERSION_MINOR, \ + LIBAVRESAMPLE_VERSION_MICRO) +#define LIBAVRESAMPLE_BUILD LIBAVRESAMPLE_VERSION_INT + +#define LIBAVRESAMPLE_IDENT "Lavr" AV_STRINGIFY(LIBAVRESAMPLE_VERSION) + +/** + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + */ + +#ifndef FF_API_RESAMPLE_CLOSE_OPEN +#define FF_API_RESAMPLE_CLOSE_OPEN (LIBAVRESAMPLE_VERSION_MAJOR < 2) +#endif + +#endif /* AVRESAMPLE_VERSION_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/adler32.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/adler32.h new file mode 100644 index 000000000..a8ff6f9d4 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/adler32.h @@ -0,0 +1,43 @@ +/* + * copyright (c) 2006 Mans Rullgard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_ADLER32_H +#define AVUTIL_ADLER32_H + +#include +#include "attributes.h" + +/** + * @ingroup lavu_crypto + * Calculate the Adler32 checksum of a buffer. + * + * Passing the return value to a subsequent av_adler32_update() call + * allows the checksum of multiple buffers to be calculated as though + * they were concatenated. + * + * @param adler initial checksum value + * @param buf pointer to input buffer + * @param len size of input buffer + * @return updated checksum + */ +unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, + unsigned int len) av_pure; + +#endif /* AVUTIL_ADLER32_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/aes.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/aes.h new file mode 100644 index 000000000..edff275b7 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/aes.h @@ -0,0 +1,67 @@ +/* + * copyright (c) 2007 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AES_H +#define AVUTIL_AES_H + +#include + +#include "attributes.h" +#include "version.h" + +/** + * @defgroup lavu_aes AES + * @ingroup lavu_crypto + * @{ + */ + +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_aes_size; +#endif + +struct AVAES; + +/** + * Allocate an AVAES context. + */ +struct AVAES *av_aes_alloc(void); + +/** + * Initialize an AVAES context. + * @param key_bits 128, 192 or 256 + * @param decrypt 0 for encryption, 1 for decryption + */ +int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * @param count number of 16 byte blocks + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param iv initialization vector for CBC mode, if NULL then ECB will be used + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt); + +/** + * @} + */ + +#endif /* AVUTIL_AES_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/attributes.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/attributes.h new file mode 100644 index 000000000..292a0a1a8 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/attributes.h @@ -0,0 +1,122 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Macro definitions for various function/variable attributes + */ + +#ifndef AVUTIL_ATTRIBUTES_H +#define AVUTIL_ATTRIBUTES_H + +#ifdef __GNUC__ +# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) +#else +# define AV_GCC_VERSION_AT_LEAST(x,y) 0 +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_always_inline __attribute__((always_inline)) inline +#elif defined(_MSC_VER) +# define av_always_inline __forceinline +#else +# define av_always_inline inline +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_noinline __attribute__((noinline)) +#else +# define av_noinline +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_pure __attribute__((pure)) +#else +# define av_pure +#endif + +#if AV_GCC_VERSION_AT_LEAST(2,6) +# define av_const __attribute__((const)) +#else +# define av_const +#endif + +#if AV_GCC_VERSION_AT_LEAST(4,3) +# define av_cold __attribute__((cold)) +#else +# define av_cold +#endif + +#if AV_GCC_VERSION_AT_LEAST(4,1) +# define av_flatten __attribute__((flatten)) +#else +# define av_flatten +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define attribute_deprecated __attribute__((deprecated)) +#else +# define attribute_deprecated +#endif + +#if defined(__GNUC__) +# define av_unused __attribute__((unused)) +#else +# define av_unused +#endif + +/** + * Mark a variable as used and prevent the compiler from optimizing it + * away. This is useful for variables accessed only from inline + * assembler without the compiler being aware. + */ +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_used __attribute__((used)) +#else +# define av_used +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,3) +# define av_alias __attribute__((may_alias)) +#else +# define av_alias +#endif + +#if defined(__GNUC__) && !defined(__ICC) +# define av_uninit(x) x=x +#else +# define av_uninit(x) x +#endif + +#ifdef __GNUC__ +# define av_builtin_constant_p __builtin_constant_p +# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos))) +#else +# define av_builtin_constant_p(x) 0 +# define av_printf_format(fmtpos, attrpos) +#endif + +#if AV_GCC_VERSION_AT_LEAST(2,5) +# define av_noreturn __attribute__((noreturn)) +#else +# define av_noreturn +#endif + +#endif /* AVUTIL_ATTRIBUTES_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/audio_fifo.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/audio_fifo.h new file mode 100644 index 000000000..8c7638825 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/audio_fifo.h @@ -0,0 +1,146 @@ +/* + * Audio FIFO + * Copyright (c) 2012 Justin Ruggles + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Audio FIFO Buffer + */ + +#ifndef AVUTIL_AUDIO_FIFO_H +#define AVUTIL_AUDIO_FIFO_H + +#include "avutil.h" +#include "fifo.h" +#include "samplefmt.h" + +/** + * @addtogroup lavu_audio + * @{ + */ + +/** + * Context for an Audio FIFO Buffer. + * + * - Operates at the sample level rather than the byte level. + * - Supports multiple channels with either planar or packed sample format. + * - Automatic reallocation when writing to a full buffer. + */ +typedef struct AVAudioFifo AVAudioFifo; + +/** + * Free an AVAudioFifo. + * + * @param af AVAudioFifo to free + */ +void av_audio_fifo_free(AVAudioFifo *af); + +/** + * Allocate an AVAudioFifo. + * + * @param sample_fmt sample format + * @param channels number of channels + * @param nb_samples initial allocation size, in samples + * @return newly allocated AVAudioFifo, or NULL on error + */ +AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, + int nb_samples); + +/** + * Reallocate an AVAudioFifo. + * + * @param af AVAudioFifo to reallocate + * @param nb_samples new allocation size, in samples + * @return 0 if OK, or negative AVERROR code on failure + */ +int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples); + +/** + * Write data to an AVAudioFifo. + * + * The AVAudioFifo will be reallocated automatically if the available space + * is less than nb_samples. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param af AVAudioFifo to write to + * @param data audio data plane pointers + * @param nb_samples number of samples to write + * @return number of samples actually written, or negative AVERROR + * code on failure. + */ +int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples); + +/** + * Read data from an AVAudioFifo. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param af AVAudioFifo to read from + * @param data audio data plane pointers + * @param nb_samples number of samples to read + * @return number of samples actually read, or negative AVERROR code + * on failure. + */ +int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples); + +/** + * Drain data from an AVAudioFifo. + * + * Removes the data without reading it. + * + * @param af AVAudioFifo to drain + * @param nb_samples number of samples to drain + * @return 0 if OK, or negative AVERROR code on failure + */ +int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples); + +/** + * Reset the AVAudioFifo buffer. + * + * This empties all data in the buffer. + * + * @param af AVAudioFifo to reset + */ +void av_audio_fifo_reset(AVAudioFifo *af); + +/** + * Get the current number of samples in the AVAudioFifo available for reading. + * + * @param af the AVAudioFifo to query + * @return number of samples available for reading + */ +int av_audio_fifo_size(AVAudioFifo *af); + +/** + * Get the current number of samples in the AVAudioFifo available for writing. + * + * @param af the AVAudioFifo to query + * @return number of samples available for writing + */ +int av_audio_fifo_space(AVAudioFifo *af); + +/** + * @} + */ + +#endif /* AVUTIL_AUDIO_FIFO_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/audioconvert.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/audioconvert.h new file mode 100644 index 000000000..300a67cd3 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/audioconvert.h @@ -0,0 +1,6 @@ + +#include "version.h" + +#if FF_API_AUDIOCONVERT +#include "channel_layout.h" +#endif diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avassert.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avassert.h new file mode 100644 index 000000000..b223d26e8 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avassert.h @@ -0,0 +1,66 @@ +/* + * copyright (c) 2010 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * simple assert() macros that are a bit more flexible than ISO C assert(). + * @author Michael Niedermayer + */ + +#ifndef AVUTIL_AVASSERT_H +#define AVUTIL_AVASSERT_H + +#include +#include "avutil.h" +#include "log.h" + +/** + * assert() equivalent, that is always enabled. + */ +#define av_assert0(cond) do { \ + if (!(cond)) { \ + av_log(NULL, AV_LOG_FATAL, "Assertion %s failed at %s:%d\n", \ + AV_STRINGIFY(cond), __FILE__, __LINE__); \ + abort(); \ + } \ +} while (0) + + +/** + * assert() equivalent, that does not lie in speed critical code. + * These asserts() thus can be enabled without fearing speedloss. + */ +#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 0 +#define av_assert1(cond) av_assert0(cond) +#else +#define av_assert1(cond) ((void)0) +#endif + + +/** + * assert() equivalent, that does lie in speed critical code. + */ +#if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1 +#define av_assert2(cond) av_assert0(cond) +#else +#define av_assert2(cond) ((void)0) +#endif + +#endif /* AVUTIL_AVASSERT_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avconfig.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avconfig.h new file mode 100644 index 000000000..f10aa6186 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avconfig.h @@ -0,0 +1,6 @@ +/* Generated by ffconf */ +#ifndef AVUTIL_AVCONFIG_H +#define AVUTIL_AVCONFIG_H +#define AV_HAVE_BIGENDIAN 0 +#define AV_HAVE_FAST_UNALIGNED 1 +#endif /* AVUTIL_AVCONFIG_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avstring.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avstring.h new file mode 100644 index 000000000..b7d10983c --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avstring.h @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2007 Mans Rullgard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AVSTRING_H +#define AVUTIL_AVSTRING_H + +#include +#include "attributes.h" + +/** + * @addtogroup lavu_string + * @{ + */ + +/** + * Return non-zero if pfx is a prefix of str. If it is, *ptr is set to + * the address of the first character in str after the prefix. + * + * @param str input string + * @param pfx prefix to test + * @param ptr updated if the prefix is matched inside str + * @return non-zero if the prefix matches, zero otherwise + */ +int av_strstart(const char *str, const char *pfx, const char **ptr); + +/** + * Return non-zero if pfx is a prefix of str independent of case. If + * it is, *ptr is set to the address of the first character in str + * after the prefix. + * + * @param str input string + * @param pfx prefix to test + * @param ptr updated if the prefix is matched inside str + * @return non-zero if the prefix matches, zero otherwise + */ +int av_stristart(const char *str, const char *pfx, const char **ptr); + +/** + * Locate the first case-independent occurrence in the string haystack + * of the string needle. A zero-length string needle is considered to + * match at the start of haystack. + * + * This function is a case-insensitive version of the standard strstr(). + * + * @param haystack string to search in + * @param needle string to search for + * @return pointer to the located match within haystack + * or a null pointer if no match + */ +char *av_stristr(const char *haystack, const char *needle); + +/** + * Locate the first occurrence of the string needle in the string haystack + * where not more than hay_length characters are searched. A zero-length + * string needle is considered to match at the start of haystack. + * + * This function is a length-limited version of the standard strstr(). + * + * @param haystack string to search in + * @param needle string to search for + * @param hay_length length of string to search in + * @return pointer to the located match within haystack + * or a null pointer if no match + */ +char *av_strnstr(const char *haystack, const char *needle, size_t hay_length); + +/** + * Copy the string src to dst, but no more than size - 1 bytes, and + * null-terminate dst. + * + * This function is the same as BSD strlcpy(). + * + * @param dst destination buffer + * @param src source string + * @param size size of destination buffer + * @return the length of src + * + * @warning since the return value is the length of src, src absolutely + * _must_ be a properly 0-terminated string, otherwise this will read beyond + * the end of the buffer and possibly crash. + */ +size_t av_strlcpy(char *dst, const char *src, size_t size); + +/** + * Append the string src to the string dst, but to a total length of + * no more than size - 1 bytes, and null-terminate dst. + * + * This function is similar to BSD strlcat(), but differs when + * size <= strlen(dst). + * + * @param dst destination buffer + * @param src source string + * @param size size of destination buffer + * @return the total length of src and dst + * + * @warning since the return value use the length of src and dst, these + * absolutely _must_ be a properly 0-terminated strings, otherwise this + * will read beyond the end of the buffer and possibly crash. + */ +size_t av_strlcat(char *dst, const char *src, size_t size); + +/** + * Append output to a string, according to a format. Never write out of + * the destination buffer, and always put a terminating 0 within + * the buffer. + * @param dst destination buffer (string to which the output is + * appended) + * @param size total size of the destination buffer + * @param fmt printf-compatible format string, specifying how the + * following parameters are used + * @return the length of the string that would have been generated + * if enough space had been available + */ +size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4); + +/** + * Convert a number to a av_malloced string. + */ +char *av_d2str(double d); + +/** + * Unescape the given string until a non escaped terminating char, + * and return the token corresponding to the unescaped string. + * + * The normal \ and ' escaping is supported. Leading and trailing + * whitespaces are removed, unless they are escaped with '\' or are + * enclosed between ''. + * + * @param buf the buffer to parse, buf will be updated to point to the + * terminating char + * @param term a 0-terminated list of terminating chars + * @return the malloced unescaped string, which must be av_freed by + * the user, NULL in case of allocation failure + */ +char *av_get_token(const char **buf, const char *term); + +/** + * Locale-independent conversion of ASCII isdigit. + */ +int av_isdigit(int c); + +/** + * Locale-independent conversion of ASCII isgraph. + */ +int av_isgraph(int c); + +/** + * Locale-independent conversion of ASCII isspace. + */ +int av_isspace(int c); + +/** + * Locale-independent conversion of ASCII characters to uppercase. + */ +static inline int av_toupper(int c) +{ + if (c >= 'a' && c <= 'z') + c ^= 0x20; + return c; +} + +/** + * Locale-independent conversion of ASCII characters to lowercase. + */ +static inline int av_tolower(int c) +{ + if (c >= 'A' && c <= 'Z') + c ^= 0x20; + return c; +} + +/** + * Locale-independent conversion of ASCII isxdigit. + */ +int av_isxdigit(int c); + +/* + * Locale-independent case-insensitive compare. + * @note This means only ASCII-range characters are case-insensitive + */ +int av_strcasecmp(const char *a, const char *b); + +/** + * Locale-independent case-insensitive compare. + * @note This means only ASCII-range characters are case-insensitive + */ +int av_strncasecmp(const char *a, const char *b, size_t n); + + +/** + * Thread safe basename. + * @param path the path, on DOS both \ and / are considered separators. + * @return pointer to the basename substring. + */ +const char *av_basename(const char *path); + +/** + * Thread safe dirname. + * @param path the path, on DOS both \ and / are considered separators. + * @return the path with the separator replaced by the string terminator or ".". + * @note the function may change the input string. + */ +const char *av_dirname(char *path); + +/** + * @} + */ + +#endif /* AVUTIL_AVSTRING_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avutil.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avutil.h new file mode 100644 index 000000000..ddb34a1dd --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/avutil.h @@ -0,0 +1,308 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AVUTIL_H +#define AVUTIL_AVUTIL_H + +/** + * @file + * external API header + */ + +/** + * @mainpage + * + * @section libav_intro Introduction + * + * This document describes the usage of the different libraries + * provided by Libav. + * + * @li @ref libavc "libavcodec" encoding/decoding library + * @li @ref lavfi "libavfilter" graph-based frame editing library + * @li @ref libavf "libavformat" I/O and muxing/demuxing library + * @li @ref lavd "libavdevice" special devices muxing/demuxing library + * @li @ref lavu "libavutil" common utility library + * @li @ref lavr "libavresample" audio resampling, format conversion and mixing + * @li @subpage libswscale color conversion and scaling library + * + * @section libav_versioning Versioning and compatibility + * + * Each of the Libav libraries contains a version.h header, which defines a + * major, minor and micro version number with the + * LIBRARYNAME_VERSION_{MAJOR,MINOR,MICRO} macros. The major version + * number is incremented with backward incompatible changes - e.g. removing + * parts of the public API, reordering public struct members, etc. The minor + * version number is incremented for backward compatible API changes or major + * new features - e.g. adding a new public function or a new decoder. The micro + * version number is incremented for smaller changes that a calling program + * might still want to check for - e.g. changing behavior in a previously + * unspecified situation. + * + * Libav guarantees backward API and ABI compatibility for each library as long + * as its major version number is unchanged. This means that no public symbols + * will be removed or renamed. Types and names of the public struct members and + * values of public macros and enums will remain the same (unless they were + * explicitly declared as not part of the public API). Documented behavior will + * not change. + * + * In other words, any correct program that works with a given Libav snapshot + * should work just as well without any changes with any later snapshot with the + * same major versions. This applies to both rebuilding the program against new + * Libav versions or to replacing the dynamic Libav libraries that a program + * links against. + * + * However, new public symbols may be added and new members may be appended to + * public structs whose size is not part of public ABI (most public structs in + * Libav). New macros and enum values may be added. Behavior in undocumented + * situations may change slightly (and be documented). All those are accompanied + * by an entry in doc/APIchanges and incrementing either the minor or micro + * version number. + */ + +/** + * @defgroup lavu Common utility functions + * + * @brief + * libavutil contains the code shared across all the other Libav + * libraries + * + * @note In order to use the functions provided by avutil you must include + * the specific header. + * + * @{ + * + * @defgroup lavu_crypto Crypto and Hashing + * + * @{ + * @} + * + * @defgroup lavu_math Maths + * @{ + * + * @} + * + * @defgroup lavu_string String Manipulation + * + * @{ + * + * @} + * + * @defgroup lavu_mem Memory Management + * + * @{ + * + * @} + * + * @defgroup lavu_data Data Structures + * @{ + * + * @} + * + * @defgroup lavu_audio Audio related + * + * @{ + * + * @} + * + * @defgroup lavu_error Error Codes + * + * @{ + * + * @} + * + * @defgroup lavu_misc Other + * + * @{ + * + * @defgroup lavu_internal Internal + * + * Not exported functions, for internal usage only + * + * @{ + * + * @} + */ + + +/** + * @defgroup preproc_misc Preprocessor String Macros + * + * String manipulation macros + * + * @{ + */ + +#define AV_STRINGIFY(s) AV_TOSTRING(s) +#define AV_TOSTRING(s) #s + +#define AV_GLUE(a, b) a ## b +#define AV_JOIN(a, b) AV_GLUE(a, b) + +#define AV_PRAGMA(s) _Pragma(#s) + +/** + * @} + */ + +/** + * @defgroup version_utils Library Version Macros + * + * Useful to check and match library version in order to maintain + * backward compatibility. + * + * @{ + */ + +#define AV_VERSION_INT(a, b, c) (a<<16 | b<<8 | c) +#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c +#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) + +/** + * @} + */ + +/** + * @addtogroup lavu_ver + * @{ + */ + +/** + * Return the LIBAVUTIL_VERSION_INT constant. + */ +unsigned avutil_version(void); + +/** + * Return the libavutil build-time configuration. + */ +const char *avutil_configuration(void); + +/** + * Return the libavutil license. + */ +const char *avutil_license(void); + +/** + * @} + */ + +/** + * @addtogroup lavu_media Media Type + * @brief Media Type + */ + +enum AVMediaType { + AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA + AVMEDIA_TYPE_VIDEO, + AVMEDIA_TYPE_AUDIO, + AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous + AVMEDIA_TYPE_SUBTITLE, + AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse + AVMEDIA_TYPE_NB +}; + +/** + * @defgroup lavu_const Constants + * @{ + * + * @defgroup lavu_enc Encoding specific + * + * @note those definition should move to avcodec + * @{ + */ + +#define FF_LAMBDA_SHIFT 7 +#define FF_LAMBDA_SCALE (1< + +/** + * @defgroup lavu_base64 Base64 + * @ingroup lavu_crypto + * @{ + */ + + +/** + * Decode a base64-encoded string. + * + * @param out buffer for decoded data + * @param in null-terminated input string + * @param out_size size in bytes of the out buffer, must be at + * least 3/4 of the length of in + * @return number of bytes written, or a negative value in case of + * invalid input + */ +int av_base64_decode(uint8_t *out, const char *in, int out_size); + +/** + * Encode data to base64 and null-terminate. + * + * @param out buffer for encoded data + * @param out_size size in bytes of the output buffer, must be at + * least AV_BASE64_SIZE(in_size) + * @param in_size size in bytes of the 'in' buffer + * @return 'out' or NULL in case of error + */ +char *av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size); + +/** + * Calculate the output size needed to base64-encode x bytes. + */ +#define AV_BASE64_SIZE(x) (((x)+2) / 3 * 4 + 1) + + /** + * @} + */ + +#endif /* AVUTIL_BASE64_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/blowfish.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/blowfish.h new file mode 100644 index 000000000..8c29536cf --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/blowfish.h @@ -0,0 +1,76 @@ +/* + * Blowfish algorithm + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_BLOWFISH_H +#define AVUTIL_BLOWFISH_H + +#include + +/** + * @defgroup lavu_blowfish Blowfish + * @ingroup lavu_crypto + * @{ + */ + +#define AV_BF_ROUNDS 16 + +typedef struct AVBlowfish { + uint32_t p[AV_BF_ROUNDS + 2]; + uint32_t s[4][256]; +} AVBlowfish; + +/** + * Initialize an AVBlowfish context. + * + * @param ctx an AVBlowfish context + * @param key a key + * @param key_len length of the key + */ +void av_blowfish_init(struct AVBlowfish *ctx, const uint8_t *key, int key_len); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * + * @param ctx an AVBlowfish context + * @param xl left four bytes halves of input to be encrypted + * @param xr right four bytes halves of input to be encrypted + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_blowfish_crypt_ecb(struct AVBlowfish *ctx, uint32_t *xl, uint32_t *xr, + int decrypt); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * + * @param ctx an AVBlowfish context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 8 byte blocks + * @param iv initialization vector for CBC mode, if NULL ECB will be used + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_blowfish_crypt(struct AVBlowfish *ctx, uint8_t *dst, const uint8_t *src, + int count, uint8_t *iv, int decrypt); + +/** + * @} + */ + +#endif /* AVUTIL_BLOWFISH_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/bswap.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/bswap.h new file mode 100644 index 000000000..8a350e1cd --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/bswap.h @@ -0,0 +1,109 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * byte swapping routines + */ + +#ifndef AVUTIL_BSWAP_H +#define AVUTIL_BSWAP_H + +#include +#include "libavutil/avconfig.h" +#include "attributes.h" + +#ifdef HAVE_AV_CONFIG_H + +#include "config.h" + +#if ARCH_ARM +# include "arm/bswap.h" +#elif ARCH_AVR32 +# include "avr32/bswap.h" +#elif ARCH_BFIN +# include "bfin/bswap.h" +#elif ARCH_SH4 +# include "sh4/bswap.h" +#elif ARCH_X86 +# include "x86/bswap.h" +#endif + +#endif /* HAVE_AV_CONFIG_H */ + +#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff)) +#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16)) +#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32)) + +#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x) + +#ifndef av_bswap16 +static av_always_inline av_const uint16_t av_bswap16(uint16_t x) +{ + x= (x>>8) | (x<<8); + return x; +} +#endif + +#ifndef av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) +{ + return AV_BSWAP32C(x); +} +#endif + +#ifndef av_bswap64 +static inline uint64_t av_const av_bswap64(uint64_t x) +{ + return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32); +} +#endif + +// be2ne ... big-endian to native-endian +// le2ne ... little-endian to native-endian + +#if AV_HAVE_BIGENDIAN +#define av_be2ne16(x) (x) +#define av_be2ne32(x) (x) +#define av_be2ne64(x) (x) +#define av_le2ne16(x) av_bswap16(x) +#define av_le2ne32(x) av_bswap32(x) +#define av_le2ne64(x) av_bswap64(x) +#define AV_BE2NEC(s, x) (x) +#define AV_LE2NEC(s, x) AV_BSWAPC(s, x) +#else +#define av_be2ne16(x) av_bswap16(x) +#define av_be2ne32(x) av_bswap32(x) +#define av_be2ne64(x) av_bswap64(x) +#define av_le2ne16(x) (x) +#define av_le2ne32(x) (x) +#define av_le2ne64(x) (x) +#define AV_BE2NEC(s, x) AV_BSWAPC(s, x) +#define AV_LE2NEC(s, x) (x) +#endif + +#define AV_BE2NE16C(x) AV_BE2NEC(16, x) +#define AV_BE2NE32C(x) AV_BE2NEC(32, x) +#define AV_BE2NE64C(x) AV_BE2NEC(64, x) +#define AV_LE2NE16C(x) AV_LE2NEC(16, x) +#define AV_LE2NE32C(x) AV_LE2NEC(32, x) +#define AV_LE2NE64C(x) AV_LE2NEC(64, x) + +#endif /* AVUTIL_BSWAP_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/buffer.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/buffer.h new file mode 100644 index 000000000..56b4d020e --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/buffer.h @@ -0,0 +1,267 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @ingroup lavu_buffer + * refcounted data buffer API + */ + +#ifndef AVUTIL_BUFFER_H +#define AVUTIL_BUFFER_H + +#include + +/** + * @defgroup lavu_buffer AVBuffer + * @ingroup lavu_data + * + * @{ + * AVBuffer is an API for reference-counted data buffers. + * + * There are two core objects in this API -- AVBuffer and AVBufferRef. AVBuffer + * represents the data buffer itself; it is opaque and not meant to be accessed + * by the caller directly, but only through AVBufferRef. However, the caller may + * e.g. compare two AVBuffer pointers to check whether two different references + * are describing the same data buffer. AVBufferRef represents a single + * reference to an AVBuffer and it is the object that may be manipulated by the + * caller directly. + * + * There are two functions provided for creating a new AVBuffer with a single + * reference -- av_buffer_alloc() to just allocate a new buffer, and + * av_buffer_create() to wrap an existing array in an AVBuffer. From an existing + * reference, additional references may be created with av_buffer_ref(). + * Use av_buffer_unref() to free a reference (this will automatically free the + * data once all the references are freed). + * + * The convention throughout this API and the rest of Libav is such that the + * buffer is considered writable if there exists only one reference to it (and + * it has not been marked as read-only). The av_buffer_is_writable() function is + * provided to check whether this is true and av_buffer_make_writable() will + * automatically create a new writable buffer when necessary. + * Of course nothing prevents the calling code from violating this convention, + * however that is safe only when all the existing references are under its + * control. + * + * @note Referencing and unreferencing the buffers is thread-safe and thus + * may be done from multiple threads simultaneously without any need for + * additional locking. + * + * @note Two different references to the same buffer can point to different + * parts of the buffer (i.e. their AVBufferRef.data will not be equal). + */ + +/** + * A reference counted buffer type. It is opaque and is meant to be used through + * references (AVBufferRef). + */ +typedef struct AVBuffer AVBuffer; + +/** + * A reference to a data buffer. + * + * The size of this struct is not a part of the public ABI and it is not meant + * to be allocated directly. + */ +typedef struct AVBufferRef { + AVBuffer *buffer; + + /** + * The data buffer. It is considered writable if and only if + * this is the only reference to the buffer, in which case + * av_buffer_is_writable() returns 1. + */ + uint8_t *data; + /** + * Size of data in bytes. + */ + int size; +} AVBufferRef; + +/** + * Allocate an AVBuffer of the given size using av_malloc(). + * + * @return an AVBufferRef of given size or NULL when out of memory + */ +AVBufferRef *av_buffer_alloc(int size); + +/** + * Same as av_buffer_alloc(), except the returned buffer will be initialized + * to zero. + */ +AVBufferRef *av_buffer_allocz(int size); + +/** + * Always treat the buffer as read-only, even when it has only one + * reference. + */ +#define AV_BUFFER_FLAG_READONLY (1 << 0) + +/** + * Create an AVBuffer from an existing array. + * + * If this function is successful, data is owned by the AVBuffer. The caller may + * only access data through the returned AVBufferRef and references derived from + * it. + * If this function fails, data is left untouched. + * @param data data array + * @param size size of data in bytes + * @param free a callback for freeing this buffer's data + * @param opaque parameter to be passed to free + * @param flags a combination of AV_BUFFER_FLAG_* + * + * @return an AVBufferRef referring to data on success, NULL on failure. + */ +AVBufferRef *av_buffer_create(uint8_t *data, int size, + void (*free)(void *opaque, uint8_t *data), + void *opaque, int flags); + +/** + * Default free callback, which calls av_free() on the buffer data. + * This function is meant to be passed to av_buffer_create(), not called + * directly. + */ +void av_buffer_default_free(void *opaque, uint8_t *data); + +/** + * Create a new reference to an AVBuffer. + * + * @return a new AVBufferRef referring to the same AVBuffer as buf or NULL on + * failure. + */ +AVBufferRef *av_buffer_ref(AVBufferRef *buf); + +/** + * Free a given reference and automatically free the buffer if there are no more + * references to it. + * + * @param buf the reference to be freed. The pointer is set to NULL on return. + */ +void av_buffer_unref(AVBufferRef **buf); + +/** + * @return 1 if the caller may write to the data referred to by buf (which is + * true if and only if buf is the only reference to the underlying AVBuffer). + * Return 0 otherwise. + * A positive answer is valid until av_buffer_ref() is called on buf. + */ +int av_buffer_is_writable(const AVBufferRef *buf); + +/** + * Create a writable reference from a given buffer reference, avoiding data copy + * if possible. + * + * @param buf buffer reference to make writable. On success, buf is either left + * untouched, or it is unreferenced and a new writable AVBufferRef is + * written in its place. On failure, buf is left untouched. + * @return 0 on success, a negative AVERROR on failure. + */ +int av_buffer_make_writable(AVBufferRef **buf); + +/** + * Reallocate a given buffer. + * + * @param buf a buffer reference to reallocate. On success, buf will be + * unreferenced and a new reference with the required size will be + * written in its place. On failure buf will be left untouched. *buf + * may be NULL, then a new buffer is allocated. + * @param size required new buffer size. + * @return 0 on success, a negative AVERROR on failure. + * + * @note the buffer is actually reallocated with av_realloc() only if it was + * initially allocated through av_buffer_realloc(NULL) and there is only one + * reference to it (i.e. the one passed to this function). In all other cases + * a new buffer is allocated and the data is copied. + */ +int av_buffer_realloc(AVBufferRef **buf, int size); + +/** + * @} + */ + +/** + * @defgroup lavu_bufferpool AVBufferPool + * @ingroup lavu_data + * + * @{ + * AVBufferPool is an API for a lock-free thread-safe pool of AVBuffers. + * + * Frequently allocating and freeing large buffers may be slow. AVBufferPool is + * meant to solve this in cases when the caller needs a set of buffers of the + * same size (the most obvious use case being buffers for raw video or audio + * frames). + * + * At the beginning, the user must call av_buffer_pool_init() to create the + * buffer pool. Then whenever a buffer is needed, call av_buffer_pool_get() to + * get a reference to a new buffer, similar to av_buffer_alloc(). This new + * reference works in all aspects the same way as the one created by + * av_buffer_alloc(). However, when the last reference to this buffer is + * unreferenced, it is returned to the pool instead of being freed and will be + * reused for subsequent av_buffer_pool_get() calls. + * + * When the caller is done with the pool and no longer needs to allocate any new + * buffers, av_buffer_pool_uninit() must be called to mark the pool as freeable. + * Once all the buffers are released, it will automatically be freed. + * + * Allocating and releasing buffers with this API is thread-safe as long as + * either the default alloc callback is used, or the user-supplied one is + * thread-safe. + */ + +/** + * The buffer pool. This structure is opaque and not meant to be accessed + * directly. It is allocated with av_buffer_pool_init() and freed with + * av_buffer_pool_uninit(). + */ +typedef struct AVBufferPool AVBufferPool; + +/** + * Allocate and initialize a buffer pool. + * + * @param size size of each buffer in this pool + * @param alloc a function that will be used to allocate new buffers when the + * pool is empty. May be NULL, then the default allocator will be used + * (av_buffer_alloc()). + * @return newly created buffer pool on success, NULL on error. + */ +AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)); + +/** + * Mark the pool as being available for freeing. It will actually be freed only + * once all the allocated buffers associated with the pool are released. Thus it + * is safe to call this function while some of the allocated buffers are still + * in use. + * + * @param pool pointer to the pool to be freed. It will be set to NULL. + * @see av_buffer_pool_can_uninit() + */ +void av_buffer_pool_uninit(AVBufferPool **pool); + +/** + * Allocate a new AVBuffer, reusing an old buffer from the pool when available. + * This function may be called simultaneously from multiple threads. + * + * @return a reference to the new buffer on success, NULL on error. + */ +AVBufferRef *av_buffer_pool_get(AVBufferPool *pool); + +/** + * @} + */ + +#endif /* AVUTIL_BUFFER_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/channel_layout.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/channel_layout.h new file mode 100644 index 000000000..15b6887a6 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/channel_layout.h @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2006 Michael Niedermayer + * Copyright (c) 2008 Peter Ross + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_CHANNEL_LAYOUT_H +#define AVUTIL_CHANNEL_LAYOUT_H + +#include + +/** + * @file + * audio channel layout utility functions + */ + +/** + * @addtogroup lavu_audio + * @{ + */ + +/** + * @defgroup channel_masks Audio channel masks + * @{ + */ +#define AV_CH_FRONT_LEFT 0x00000001 +#define AV_CH_FRONT_RIGHT 0x00000002 +#define AV_CH_FRONT_CENTER 0x00000004 +#define AV_CH_LOW_FREQUENCY 0x00000008 +#define AV_CH_BACK_LEFT 0x00000010 +#define AV_CH_BACK_RIGHT 0x00000020 +#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040 +#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080 +#define AV_CH_BACK_CENTER 0x00000100 +#define AV_CH_SIDE_LEFT 0x00000200 +#define AV_CH_SIDE_RIGHT 0x00000400 +#define AV_CH_TOP_CENTER 0x00000800 +#define AV_CH_TOP_FRONT_LEFT 0x00001000 +#define AV_CH_TOP_FRONT_CENTER 0x00002000 +#define AV_CH_TOP_FRONT_RIGHT 0x00004000 +#define AV_CH_TOP_BACK_LEFT 0x00008000 +#define AV_CH_TOP_BACK_CENTER 0x00010000 +#define AV_CH_TOP_BACK_RIGHT 0x00020000 +#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. +#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT. +#define AV_CH_WIDE_LEFT 0x0000000080000000ULL +#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL +#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL +#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL +#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL + +/** Channel mask value used for AVCodecContext.request_channel_layout + to indicate that the user requests the channel order of the decoder output + to be the native codec channel order. */ +#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL + +/** + * @} + * @defgroup channel_mask_c Audio channel convenience macros + * @{ + * */ +#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER) +#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) +#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) +#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) +#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) +#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER) +#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY) +#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) +#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT) +#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) + +enum AVMatrixEncoding { + AV_MATRIX_ENCODING_NONE, + AV_MATRIX_ENCODING_DOLBY, + AV_MATRIX_ENCODING_DPLII, + AV_MATRIX_ENCODING_NB +}; + +/** + * @} + */ + +/** + * Return a channel layout id that matches name, or 0 if no match is found. + * + * name can be one or several of the following notations, + * separated by '+' or '|': + * - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0, + * 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix); + * - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC, + * SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR); + * - a number of channels, in decimal, optionally followed by 'c', yielding + * the default channel layout for that number of channels (@see + * av_get_default_channel_layout); + * - a channel layout mask, in hexadecimal starting with "0x" (see the + * AV_CH_* macros). + * + * Example: "stereo+FC" = "2+FC" = "2c+1c" = "0x7" + */ +uint64_t av_get_channel_layout(const char *name); + +/** + * Return a description of a channel layout. + * If nb_channels is <= 0, it is guessed from the channel_layout. + * + * @param buf put here the string containing the channel layout + * @param buf_size size in bytes of the buffer + */ +void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout); + +/** + * Return the number of channels in the channel layout. + */ +int av_get_channel_layout_nb_channels(uint64_t channel_layout); + +/** + * Return default channel layout for a given number of channels. + */ +uint64_t av_get_default_channel_layout(int nb_channels); + +/** + * Get the index of a channel in channel_layout. + * + * @param channel a channel layout describing exactly one channel which must be + * present in channel_layout. + * + * @return index of channel in channel_layout on success, a negative AVERROR + * on error. + */ +int av_get_channel_layout_channel_index(uint64_t channel_layout, + uint64_t channel); + +/** + * Get the channel with the given index in channel_layout. + */ +uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index); + +/** + * Get the name of a given channel. + * + * @return channel name on success, NULL on error. + */ +const char *av_get_channel_name(uint64_t channel); + +/** + * @} + */ + +#endif /* AVUTIL_CHANNEL_LAYOUT_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/common.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/common.h new file mode 100644 index 000000000..caa6b1963 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/common.h @@ -0,0 +1,405 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * common internal and external API header + */ + +#ifndef AVUTIL_COMMON_H +#define AVUTIL_COMMON_H + +#include +#include +#include +#include +#include +#include +#include + +#include "attributes.h" +#include "version.h" +#include "libavutil/avconfig.h" + +#if AV_HAVE_BIGENDIAN +# define AV_NE(be, le) (be) +#else +# define AV_NE(be, le) (le) +#endif + +//rounded division & shift +#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) +/* assume b>0 */ +#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) +#define FFABS(a) ((a) >= 0 ? (a) : (-(a))) +#define FFSIGN(a) ((a) > 0 ? 1 : -1) + +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) + +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) +#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) + +/* misc math functions */ + +#if FF_API_AV_REVERSE +extern attribute_deprecated const uint8_t av_reverse[256]; +#endif + +#ifdef HAVE_AV_CONFIG_H +# include "config.h" +# include "intmath.h" +#endif + +/* Pull in unguarded fallback defines at the end of this file. */ +#include "common.h" + +#ifndef av_log2 +av_const int av_log2(unsigned v); +#endif + +#ifndef av_log2_16bit +av_const int av_log2_16bit(unsigned v); +#endif + +/** + * Clip a signed integer value into the amin-amax range. + * @param a value to clip + * @param amin minimum value of the clip range + * @param amax maximum value of the clip range + * @return clipped value + */ +static av_always_inline av_const int av_clip_c(int a, int amin, int amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} + +/** + * Clip a signed integer value into the 0-255 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const uint8_t av_clip_uint8_c(int a) +{ + if (a&(~0xFF)) return (-a)>>31; + else return a; +} + +/** + * Clip a signed integer value into the -128,127 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const int8_t av_clip_int8_c(int a) +{ + if ((a+0x80) & ~0xFF) return (a>>31) ^ 0x7F; + else return a; +} + +/** + * Clip a signed integer value into the 0-65535 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const uint16_t av_clip_uint16_c(int a) +{ + if (a&(~0xFFFF)) return (-a)>>31; + else return a; +} + +/** + * Clip a signed integer value into the -32768,32767 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const int16_t av_clip_int16_c(int a) +{ + if ((a+0x8000) & ~0xFFFF) return (a>>31) ^ 0x7FFF; + else return a; +} + +/** + * Clip a signed 64-bit integer value into the -2147483648,2147483647 range. + * @param a value to clip + * @return clipped value + */ +static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a) +{ + if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (a>>63) ^ 0x7FFFFFFF; + else return a; +} + +/** + * Clip a signed integer to an unsigned power of two range. + * @param a value to clip + * @param p bit position to clip at + * @return clipped value + */ +static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p) +{ + if (a & ~((1<> 31 & ((1< amax) return amax; + else return a; +} + +/** Compute ceil(log2(x)). + * @param x value used to compute ceil(log2(x)) + * @return computed ceiling of log2(x) + */ +static av_always_inline av_const int av_ceil_log2_c(int x) +{ + return av_log2((x - 1) << 1); +} + +/** + * Count number of bits set to one in x + * @param x value to count bits of + * @return the number of bits set to one in x + */ +static av_always_inline av_const int av_popcount_c(uint32_t x) +{ + x -= (x >> 1) & 0x55555555; + x = (x & 0x33333333) + ((x >> 2) & 0x33333333); + x = (x + (x >> 4)) & 0x0F0F0F0F; + x += x >> 8; + return (x + (x >> 16)) & 0x3F; +} + +/** + * Count number of bits set to one in x + * @param x value to count bits of + * @return the number of bits set to one in x + */ +static av_always_inline av_const int av_popcount64_c(uint64_t x) +{ + return av_popcount(x) + av_popcount(x >> 32); +} + +#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) +#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)) + +/** + * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. + * + * @param val Output value, must be an lvalue of type uint32_t. + * @param GET_BYTE Expression reading one byte from the input. + * Evaluated up to 7 times (4 for the currently + * assigned Unicode range). With a memory buffer + * input, this could be *ptr++. + * @param ERROR Expression to be evaluated on invalid input, + * typically a goto statement. + */ +#define GET_UTF8(val, GET_BYTE, ERROR)\ + val= GET_BYTE;\ + {\ + uint32_t top = (val & 128) >> 1;\ + if ((val & 0xc0) == 0x80)\ + ERROR\ + while (val & top) {\ + int tmp= GET_BYTE - 128;\ + if(tmp>>6)\ + ERROR\ + val= (val<<6) + tmp;\ + top <<= 5;\ + }\ + val &= (top << 1) - 1;\ + } + +/** + * Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form. + * + * @param val Output value, must be an lvalue of type uint32_t. + * @param GET_16BIT Expression returning two bytes of UTF-16 data converted + * to native byte order. Evaluated one or two times. + * @param ERROR Expression to be evaluated on invalid input, + * typically a goto statement. + */ +#define GET_UTF16(val, GET_16BIT, ERROR)\ + val = GET_16BIT;\ + {\ + unsigned int hi = val - 0xD800;\ + if (hi < 0x800) {\ + val = GET_16BIT - 0xDC00;\ + if (val > 0x3FFU || hi > 0x3FFU)\ + ERROR\ + val += (hi<<10) + 0x10000;\ + }\ + }\ + +/** + * @def PUT_UTF8(val, tmp, PUT_BYTE) + * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). + * @param val is an input-only argument and should be of type uint32_t. It holds + * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If + * val is given as a function it is executed only once. + * @param tmp is a temporary variable and should be of type uint8_t. It + * represents an intermediate value during conversion that is to be + * output by PUT_BYTE. + * @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. + * It could be a function or a statement, and uses tmp as the input byte. + * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be + * executed up to 4 times for values in the valid UTF-8 range and up to + * 7 times in the general case, depending on the length of the converted + * Unicode character. + */ +#define PUT_UTF8(val, tmp, PUT_BYTE)\ + {\ + int bytes, shift;\ + uint32_t in = val;\ + if (in < 0x80) {\ + tmp = in;\ + PUT_BYTE\ + } else {\ + bytes = (av_log2(in) + 4) / 5;\ + shift = (bytes - 1) * 6;\ + tmp = (256 - (256 >> bytes)) | (in >> shift);\ + PUT_BYTE\ + while (shift >= 6) {\ + shift -= 6;\ + tmp = 0x80 | ((in >> shift) & 0x3f);\ + PUT_BYTE\ + }\ + }\ + } + +/** + * @def PUT_UTF16(val, tmp, PUT_16BIT) + * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). + * @param val is an input-only argument and should be of type uint32_t. It holds + * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If + * val is given as a function it is executed only once. + * @param tmp is a temporary variable and should be of type uint16_t. It + * represents an intermediate value during conversion that is to be + * output by PUT_16BIT. + * @param PUT_16BIT writes the converted UTF-16 data to any proper destination + * in desired endianness. It could be a function or a statement, and uses tmp + * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" + * PUT_BYTE will be executed 1 or 2 times depending on input character. + */ +#define PUT_UTF16(val, tmp, PUT_16BIT)\ + {\ + uint32_t in = val;\ + if (in < 0x10000) {\ + tmp = in;\ + PUT_16BIT\ + } else {\ + tmp = 0xD800 | ((in - 0x10000) >> 10);\ + PUT_16BIT\ + tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ + PUT_16BIT\ + }\ + }\ + + + +#include "mem.h" + +#ifdef HAVE_AV_CONFIG_H +# include "internal.h" +#endif /* HAVE_AV_CONFIG_H */ + +#endif /* AVUTIL_COMMON_H */ + +/* + * The following definitions are outside the multiple inclusion guard + * to ensure they are immediately available in intmath.h. + */ + +#ifndef av_ceil_log2 +# define av_ceil_log2 av_ceil_log2_c +#endif +#ifndef av_clip +# define av_clip av_clip_c +#endif +#ifndef av_clip_uint8 +# define av_clip_uint8 av_clip_uint8_c +#endif +#ifndef av_clip_int8 +# define av_clip_int8 av_clip_int8_c +#endif +#ifndef av_clip_uint16 +# define av_clip_uint16 av_clip_uint16_c +#endif +#ifndef av_clip_int16 +# define av_clip_int16 av_clip_int16_c +#endif +#ifndef av_clipl_int32 +# define av_clipl_int32 av_clipl_int32_c +#endif +#ifndef av_clip_uintp2 +# define av_clip_uintp2 av_clip_uintp2_c +#endif +#ifndef av_sat_add32 +# define av_sat_add32 av_sat_add32_c +#endif +#ifndef av_sat_dadd32 +# define av_sat_dadd32 av_sat_dadd32_c +#endif +#ifndef av_clipf +# define av_clipf av_clipf_c +#endif +#ifndef av_popcount +# define av_popcount av_popcount_c +#endif +#ifndef av_popcount64 +# define av_popcount64 av_popcount64_c +#endif diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/cpu.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/cpu.h new file mode 100644 index 000000000..8f2af2854 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/cpu.h @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_CPU_H +#define AVUTIL_CPU_H + +#include "version.h" + +#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */ + + /* lower 16 bits - CPU features */ +#define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX +#define AV_CPU_FLAG_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext +#if FF_API_CPU_FLAG_MMX2 +#define AV_CPU_FLAG_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext +#endif +#define AV_CPU_FLAG_3DNOW 0x0004 ///< AMD 3DNOW +#define AV_CPU_FLAG_SSE 0x0008 ///< SSE functions +#define AV_CPU_FLAG_SSE2 0x0010 ///< PIV SSE2 functions +#define AV_CPU_FLAG_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster +#define AV_CPU_FLAG_3DNOWEXT 0x0020 ///< AMD 3DNowExt +#define AV_CPU_FLAG_SSE3 0x0040 ///< Prescott SSE3 functions +#define AV_CPU_FLAG_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster +#define AV_CPU_FLAG_SSSE3 0x0080 ///< Conroe SSSE3 functions +#define AV_CPU_FLAG_ATOM 0x10000000 ///< Atom processor, some SSSE3 instructions are slower +#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions +#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions +#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used +#define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions +#define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions +#define AV_CPU_FLAG_CMOV 0x1000 ///< i686 cmov + +#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard + +#define AV_CPU_FLAG_ARMV5TE (1 << 0) +#define AV_CPU_FLAG_ARMV6 (1 << 1) +#define AV_CPU_FLAG_ARMV6T2 (1 << 2) +#define AV_CPU_FLAG_VFP (1 << 3) +#define AV_CPU_FLAG_VFPV3 (1 << 4) +#define AV_CPU_FLAG_NEON (1 << 5) + +/** + * Return the flags which specify extensions supported by the CPU. + */ +int av_get_cpu_flags(void); + +/** + * Set a mask on flags returned by av_get_cpu_flags(). + * This function is mainly useful for testing. + * + * @warning this function is not thread safe. + */ +void av_set_cpu_flags_mask(int mask); + +/** + * Parse CPU flags from a string. + * + * @return a combination of AV_CPU_* flags, negative on error. + */ +int av_parse_cpu_flags(const char *s); + +/** + * @return the number of logical CPU cores present. + */ +int av_cpu_count(void); + +#endif /* AVUTIL_CPU_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/crc.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/crc.h new file mode 100644 index 000000000..0540619d2 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/crc.h @@ -0,0 +1,74 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_CRC_H +#define AVUTIL_CRC_H + +#include +#include +#include "attributes.h" + +typedef uint32_t AVCRC; + +typedef enum { + AV_CRC_8_ATM, + AV_CRC_16_ANSI, + AV_CRC_16_CCITT, + AV_CRC_32_IEEE, + AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */ + AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */ +}AVCRCId; + +/** + * Initialize a CRC table. + * @param ctx must be an array of size sizeof(AVCRC)*257 or sizeof(AVCRC)*1024 + * @param le If 1, the lowest bit represents the coefficient for the highest + * exponent of the corresponding polynomial (both for poly and + * actual CRC). + * If 0, you must swap the CRC parameter and the result of av_crc + * if you need the standard representation (can be simplified in + * most cases to e.g. bswap16): + * av_bswap32(crc << (32-bits)) + * @param bits number of bits for the CRC + * @param poly generator polynomial without the x**bits coefficient, in the + * representation as specified by le + * @param ctx_size size of ctx in bytes + * @return <0 on failure + */ +int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size); + +/** + * Get an initialized standard CRC table. + * @param crc_id ID of a standard CRC + * @return a pointer to the CRC table or NULL on failure + */ +const AVCRC *av_crc_get_table(AVCRCId crc_id); + +/** + * Calculate the CRC of a block. + * @param crc CRC of previous blocks if any or initial value for CRC + * @return CRC updated with the data from the given block + * + * @see av_crc_init() "le" parameter + */ +uint32_t av_crc(const AVCRC *ctx, uint32_t crc, + const uint8_t *buffer, size_t length) av_pure; + +#endif /* AVUTIL_CRC_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/dict.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/dict.h new file mode 100644 index 000000000..ab23f26e6 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/dict.h @@ -0,0 +1,146 @@ +/* + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Public dictionary API. + */ + +#ifndef AVUTIL_DICT_H +#define AVUTIL_DICT_H + +/** + * @addtogroup lavu_dict AVDictionary + * @ingroup lavu_data + * + * @brief Simple key:value store + * + * @{ + * Dictionaries are used for storing key:value pairs. To create + * an AVDictionary, simply pass an address of a NULL pointer to + * av_dict_set(). NULL can be used as an empty dictionary wherever + * a pointer to an AVDictionary is required. + * Use av_dict_get() to retrieve an entry or iterate over all + * entries and finally av_dict_free() to free the dictionary + * and all its contents. + * + * @code + * AVDictionary *d = NULL; // "create" an empty dictionary + * av_dict_set(&d, "foo", "bar", 0); // add an entry + * + * char *k = av_strdup("key"); // if your strings are already allocated, + * char *v = av_strdup("value"); // you can avoid copying them like this + * av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); + * + * AVDictionaryEntry *t = NULL; + * while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { + * <....> // iterate over all entries in d + * } + * + * av_dict_free(&d); + * @endcode + * + */ + +#define AV_DICT_MATCH_CASE 1 +#define AV_DICT_IGNORE_SUFFIX 2 +#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been + allocated with av_malloc() and children. */ +#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been + allocated with av_malloc() and chilren. */ +#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries. +#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no + delimiter is added, the strings are simply concatenated. */ + +typedef struct AVDictionaryEntry { + char *key; + char *value; +} AVDictionaryEntry; + +typedef struct AVDictionary AVDictionary; + +/** + * Get a dictionary entry with matching key. + * + * @param prev Set to the previous matching element to find the next. + * If set to NULL the first matching element is returned. + * @param flags Allows case as well as suffix-insensitive comparisons. + * @return Found entry or NULL, changing key or value leads to undefined behavior. + */ +AVDictionaryEntry * +av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); + +/** + * Get number of entries in dictionary. + * + * @param m dictionary + * @return number of entries in dictionary + */ +int av_dict_count(const AVDictionary *m); + +/** + * Set the given entry in *pm, overwriting an existing entry. + * + * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL + * a dictionary struct is allocated and put in *pm. + * @param key entry key to add to *pm (will be av_strduped depending on flags) + * @param value entry value to add to *pm (will be av_strduped depending on flags). + * Passing a NULL value will cause an existing entry to be deleted. + * @return >= 0 on success otherwise an error code <0 + */ +int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags); + +/** + * Parse the key/value pairs list and add to a dictionary. + * + * @param key_val_sep a 0-terminated list of characters used to separate + * key from value + * @param pairs_sep a 0-terminated list of characters used to separate + * two pairs from each other + * @param flags flags to use when adding to dictionary. + * AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL + * are ignored since the key/value tokens will always + * be duplicated. + * @return 0 on success, negative AVERROR code on failure + */ +int av_dict_parse_string(AVDictionary **pm, const char *str, + const char *key_val_sep, const char *pairs_sep, + int flags); + +/** + * Copy entries from one AVDictionary struct into another. + * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL, + * this function will allocate a struct for you and put it in *dst + * @param src pointer to source AVDictionary struct + * @param flags flags to use when setting entries in *dst + * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag + */ +void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags); + +/** + * Free all the memory allocated for an AVDictionary struct + * and all keys and values. + */ +void av_dict_free(AVDictionary **m); + +/** + * @} + */ + +#endif /* AVUTIL_DICT_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/error.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/error.h new file mode 100644 index 000000000..3dfd8807f --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/error.h @@ -0,0 +1,83 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * error code definitions + */ + +#ifndef AVUTIL_ERROR_H +#define AVUTIL_ERROR_H + +#include +#include +#include "avutil.h" + +/** + * @addtogroup lavu_error + * + * @{ + */ + + +/* error handling */ +#if EDOM > 0 +#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions. +#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value. +#else +/* Some platforms have E* and errno already negated. */ +#define AVERROR(e) (e) +#define AVUNERROR(e) (e) +#endif + +#define AVERROR_BSF_NOT_FOUND (-0x39acbd08) ///< Bitstream filter not found +#define AVERROR_DECODER_NOT_FOUND (-0x3cbabb08) ///< Decoder not found +#define AVERROR_DEMUXER_NOT_FOUND (-0x32babb08) ///< Demuxer not found +#define AVERROR_ENCODER_NOT_FOUND (-0x3cb1ba08) ///< Encoder not found +#define AVERROR_EOF (-0x5fb9b0bb) ///< End of file +#define AVERROR_EXIT (-0x2bb6a7bb) ///< Immediate exit was requested; the called function should not be restarted +#define AVERROR_FILTER_NOT_FOUND (-0x33b6b908) ///< Filter not found +#define AVERROR_INVALIDDATA (-0x3ebbb1b7) ///< Invalid data found when processing input +#define AVERROR_MUXER_NOT_FOUND (-0x27aab208) ///< Muxer not found +#define AVERROR_OPTION_NOT_FOUND (-0x2bafb008) ///< Option not found +#define AVERROR_PATCHWELCOME (-0x3aa8beb0) ///< Not yet implemented in Libav, patches welcome +#define AVERROR_PROTOCOL_NOT_FOUND (-0x30adaf08) ///< Protocol not found +#define AVERROR_STREAM_NOT_FOUND (-0x2dabac08) ///< Stream not found +#define AVERROR_BUG (-0x5fb8aabe) ///< Bug detected, please report the issue +#define AVERROR_UNKNOWN (-0x31b4b1ab) ///< Unknown error, typically from an external library +#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it. + +/** + * Put a description of the AVERROR code errnum in errbuf. + * In case of failure the global variable errno is set to indicate the + * error. Even in case of failure av_strerror() will print a generic + * error message indicating the errnum provided to errbuf. + * + * @param errnum error code to describe + * @param errbuf buffer to which description is written + * @param errbuf_size the size in bytes of errbuf + * @return 0 on success, a negative value if a description for errnum + * cannot be found + */ +int av_strerror(int errnum, char *errbuf, size_t errbuf_size); + +/** + * @} + */ + +#endif /* AVUTIL_ERROR_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/eval.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/eval.h new file mode 100644 index 000000000..ccb29e7a3 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/eval.h @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2002 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * simple arithmetic expression evaluator + */ + +#ifndef AVUTIL_EVAL_H +#define AVUTIL_EVAL_H + +#include "avutil.h" + +typedef struct AVExpr AVExpr; + +/** + * Parse and evaluate an expression. + * Note, this is significantly slower than av_expr_eval(). + * + * @param res a pointer to a double where is put the result value of + * the expression, or NAN in case of error + * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)" + * @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0} + * @param const_values a zero terminated array of values for the identifiers from const_names + * @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers + * @param funcs1 NULL terminated array of function pointers for functions which take 1 argument + * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers + * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments + * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2 + * @param log_ctx parent logging context + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code otherwise + */ +int av_expr_parse_and_eval(double *res, const char *s, + const char * const *const_names, const double *const_values, + const char * const *func1_names, double (* const *funcs1)(void *, double), + const char * const *func2_names, double (* const *funcs2)(void *, double, double), + void *opaque, int log_offset, void *log_ctx); + +/** + * Parse an expression. + * + * @param expr a pointer where is put an AVExpr containing the parsed + * value in case of successful parsing, or NULL otherwise. + * The pointed to AVExpr must be freed with av_expr_free() by the user + * when it is not needed anymore. + * @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)" + * @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0} + * @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers + * @param funcs1 NULL terminated array of function pointers for functions which take 1 argument + * @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers + * @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments + * @param log_ctx parent logging context + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code otherwise + */ +int av_expr_parse(AVExpr **expr, const char *s, + const char * const *const_names, + const char * const *func1_names, double (* const *funcs1)(void *, double), + const char * const *func2_names, double (* const *funcs2)(void *, double, double), + int log_offset, void *log_ctx); + +/** + * Evaluate a previously parsed expression. + * + * @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names + * @param opaque a pointer which will be passed to all functions from funcs1 and funcs2 + * @return the value of the expression + */ +double av_expr_eval(AVExpr *e, const double *const_values, void *opaque); + +/** + * Free a parsed expression previously created with av_expr_parse(). + */ +void av_expr_free(AVExpr *e); + +/** + * Parse the string in numstr and return its value as a double. If + * the string is empty, contains only whitespaces, or does not contain + * an initial substring that has the expected syntax for a + * floating-point number, no conversion is performed. In this case, + * returns a value of zero and the value returned in tail is the value + * of numstr. + * + * @param numstr a string representing a number, may contain one of + * the International System number postfixes, for example 'K', 'M', + * 'G'. If 'i' is appended after the postfix, powers of 2 are used + * instead of powers of 10. The 'B' postfix multiplies the value for + * 8, and can be appended after another postfix or used alone. This + * allows using for example 'KB', 'MiB', 'G' and 'B' as postfix. + * @param tail if non-NULL puts here the pointer to the char next + * after the last parsed character + */ +double av_strtod(const char *numstr, char **tail); + +#endif /* AVUTIL_EVAL_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/fifo.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/fifo.h new file mode 100644 index 000000000..ea30f5d2b --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/fifo.h @@ -0,0 +1,131 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * a very simple circular buffer FIFO implementation + */ + +#ifndef AVUTIL_FIFO_H +#define AVUTIL_FIFO_H + +#include +#include "avutil.h" +#include "attributes.h" + +typedef struct AVFifoBuffer { + uint8_t *buffer; + uint8_t *rptr, *wptr, *end; + uint32_t rndx, wndx; +} AVFifoBuffer; + +/** + * Initialize an AVFifoBuffer. + * @param size of FIFO + * @return AVFifoBuffer or NULL in case of memory allocation failure + */ +AVFifoBuffer *av_fifo_alloc(unsigned int size); + +/** + * Free an AVFifoBuffer. + * @param f AVFifoBuffer to free + */ +void av_fifo_free(AVFifoBuffer *f); + +/** + * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. + * @param f AVFifoBuffer to reset + */ +void av_fifo_reset(AVFifoBuffer *f); + +/** + * Return the amount of data in bytes in the AVFifoBuffer, that is the + * amount of data you can read from it. + * @param f AVFifoBuffer to read from + * @return size + */ +int av_fifo_size(AVFifoBuffer *f); + +/** + * Return the amount of space in bytes in the AVFifoBuffer, that is the + * amount of data you can write into it. + * @param f AVFifoBuffer to write into + * @return size + */ +int av_fifo_space(AVFifoBuffer *f); + +/** + * Feed data from an AVFifoBuffer to a user-supplied callback. + * @param f AVFifoBuffer to read from + * @param buf_size number of bytes to read + * @param func generic read function + * @param dest data destination + */ +int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int)); + +/** + * Feed data from a user-supplied callback to an AVFifoBuffer. + * @param f AVFifoBuffer to write to + * @param src data source; non-const since it may be used as a + * modifiable context by the function defined in func + * @param size number of bytes to write + * @param func generic write function; the first parameter is src, + * the second is dest_buf, the third is dest_buf_size. + * func must return the number of bytes written to dest_buf, or <= 0 to + * indicate no more data available to write. + * If func is NULL, src is interpreted as a simple byte array for source data. + * @return the number of bytes written to the FIFO + */ +int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int)); + +/** + * Resize an AVFifoBuffer. + * @param f AVFifoBuffer to resize + * @param size new AVFifoBuffer size in bytes + * @return <0 for failure, >=0 otherwise + */ +int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size); + +/** + * Read and discard the specified amount of data from an AVFifoBuffer. + * @param f AVFifoBuffer to read from + * @param size amount of data to read in bytes + */ +void av_fifo_drain(AVFifoBuffer *f, int size); + +/** + * Return a pointer to the data stored in a FIFO buffer at a certain offset. + * The FIFO buffer is not modified. + * + * @param f AVFifoBuffer to peek at, f must be non-NULL + * @param offs an offset in bytes, its absolute value must be less + * than the used buffer size or the returned pointer will + * point outside to the buffer data. + * The used buffer size can be checked with av_fifo_size(). + */ +static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs) +{ + uint8_t *ptr = f->rptr + offs; + if (ptr >= f->end) + ptr = f->buffer + (ptr - f->end); + else if (ptr < f->buffer) + ptr = f->end - (f->buffer - ptr); + return ptr; +} + +#endif /* AVUTIL_FIFO_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/file.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/file.h new file mode 100644 index 000000000..e3f02a830 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/file.h @@ -0,0 +1,54 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_FILE_H +#define AVUTIL_FILE_H + +#include + +#include "avutil.h" + +/** + * @file + * Misc file utilities. + */ + +/** + * Read the file with name filename, and put its content in a newly + * allocated buffer or map it with mmap() when available. + * In case of success set *bufptr to the read or mmapped buffer, and + * *size to the size in bytes of the buffer in *bufptr. + * The returned buffer must be released with av_file_unmap(). + * + * @param log_offset loglevel offset used for logging + * @param log_ctx context used for logging + * @return a non negative number in case of success, a negative value + * corresponding to an AVERROR error code in case of failure + */ +int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, + int log_offset, void *log_ctx); + +/** + * Unmap or free the buffer bufptr created by av_file_map(). + * + * @param size size in bytes of bufptr, must be the same as returned + * by av_file_map() + */ +void av_file_unmap(uint8_t *bufptr, size_t size); + +#endif /* AVUTIL_FILE_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/frame.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/frame.h new file mode 100644 index 000000000..d71948db0 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/frame.h @@ -0,0 +1,491 @@ +/* + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_FRAME_H +#define AVUTIL_FRAME_H + +#include + +#include "libavcodec/version.h" + +#include "avutil.h" +#include "buffer.h" +#include "dict.h" +#include "rational.h" +#include "samplefmt.h" + +enum AVFrameSideDataType { + /** + * The data is the AVPanScan struct defined in libavcodec. + */ + AV_FRAME_DATA_PANSCAN, +}; + +typedef struct AVFrameSideData { + enum AVFrameSideDataType type; + uint8_t *data; + int size; + AVDictionary *metadata; +} AVFrameSideData; + +/** + * This structure describes decoded (raw) audio or video data. + * + * AVFrame must be allocated using av_frame_alloc(). Not that this only + * allocates the AVFrame itself, the buffers for the data must be managed + * through other means (see below). + * AVFrame must be freed with av_frame_free(). + * + * AVFrame is typically allocated once and then reused multiple times to hold + * different data (e.g. a single AVFrame to hold frames received from a + * decoder). In such a case, av_frame_unref() will free any references held by + * the frame and reset it to its original clean state before it + * is reused again. + * + * The data described by an AVFrame is usually reference counted through the + * AVBuffer API. The underlying buffer references are stored in AVFrame.buf / + * AVFrame.extended_buf. An AVFrame is considered to be reference counted if at + * least one reference is set, i.e. if AVFrame.buf[0] != NULL. In such a case, + * every single data plane must be contained in one of the buffers in + * AVFrame.buf or AVFrame.extended_buf. + * There may be a single buffer for all the data, or one separate buffer for + * each plane, or anything in between. + * + * sizeof(AVFrame) is not a part of the public ABI, so new fields may be added + * to the end with a minor bump. + */ +typedef struct AVFrame { +#define AV_NUM_DATA_POINTERS 8 + /** + * pointer to the picture/channel planes. + * This might be different from the first allocated byte + */ + uint8_t *data[AV_NUM_DATA_POINTERS]; + + /** + * For video, size in bytes of each picture line. + * For audio, size in bytes of each plane. + * + * For audio, only linesize[0] may be set. For planar audio, each channel + * plane must be the same size. + */ + int linesize[AV_NUM_DATA_POINTERS]; + + /** + * pointers to the data planes/channels. + * + * For video, this should simply point to data[]. + * + * For planar audio, each channel has a separate data pointer, and + * linesize[0] contains the size of each channel buffer. + * For packed audio, there is just one data pointer, and linesize[0] + * contains the total size of the buffer for all channels. + * + * Note: Both data and extended_data should always be set in a valid frame, + * but for planar audio with more channels that can fit in data, + * extended_data must be used in order to access all channels. + */ + uint8_t **extended_data; + + /** + * width and height of the video frame + */ + int width, height; + + /** + * number of audio samples (per channel) described by this frame + */ + int nb_samples; + + /** + * format of the frame, -1 if unknown or unset + * Values correspond to enum AVPixelFormat for video frames, + * enum AVSampleFormat for audio) + */ + int format; + + /** + * 1 -> keyframe, 0-> not + */ + int key_frame; + + /** + * Picture type of the frame. + */ + enum AVPictureType pict_type; + +#if FF_API_AVFRAME_LAVC + attribute_deprecated + uint8_t *base[AV_NUM_DATA_POINTERS]; +#endif + + /** + * Sample aspect ratio for the video frame, 0/1 if unknown/unspecified. + */ + AVRational sample_aspect_ratio; + + /** + * Presentation timestamp in time_base units (time when frame should be shown to user). + */ + int64_t pts; + + /** + * PTS copied from the AVPacket that was decoded to produce this frame. + */ + int64_t pkt_pts; + + /** + * DTS copied from the AVPacket that triggered returning this frame. + */ + int64_t pkt_dts; + + /** + * picture number in bitstream order + */ + int coded_picture_number; + /** + * picture number in display order + */ + int display_picture_number; + + /** + * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) + */ + int quality; + +#if FF_API_AVFRAME_LAVC + attribute_deprecated + int reference; + + /** + * QP table + */ + attribute_deprecated + int8_t *qscale_table; + /** + * QP store stride + */ + attribute_deprecated + int qstride; + + attribute_deprecated + int qscale_type; + + /** + * mbskip_table[mb]>=1 if MB didn't change + * stride= mb_width = (width+15)>>4 + */ + attribute_deprecated + uint8_t *mbskip_table; + + /** + * motion vector table + * @code + * example: + * int mv_sample_log2= 4 - motion_subsample_log2; + * int mb_width= (width+15)>>4; + * int mv_stride= (mb_width << mv_sample_log2) + 1; + * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y]; + * @endcode + */ + attribute_deprecated + int16_t (*motion_val[2])[2]; + + /** + * macroblock type table + * mb_type_base + mb_width + 2 + */ + attribute_deprecated + uint32_t *mb_type; + + /** + * DCT coefficients + */ + attribute_deprecated + short *dct_coeff; + + /** + * motion reference frame index + * the order in which these are stored can depend on the codec. + */ + attribute_deprecated + int8_t *ref_index[2]; +#endif + + /** + * for some private data of the user + */ + void *opaque; + + /** + * error + */ + uint64_t error[AV_NUM_DATA_POINTERS]; + +#if FF_API_AVFRAME_LAVC + attribute_deprecated + int type; +#endif + + /** + * When decoding, this signals how much the picture must be delayed. + * extra_delay = repeat_pict / (2*fps) + */ + int repeat_pict; + + /** + * The content of the picture is interlaced. + */ + int interlaced_frame; + + /** + * If the content is interlaced, is top field displayed first. + */ + int top_field_first; + + /** + * Tell user application that palette has changed from previous frame. + */ + int palette_has_changed; + +#if FF_API_AVFRAME_LAVC + attribute_deprecated + int buffer_hints; + + /** + * Pan scan. + */ + attribute_deprecated + struct AVPanScan *pan_scan; +#endif + + /** + * reordered opaque 64bit (generally an integer or a double precision float + * PTS but can be anything). + * The user sets AVCodecContext.reordered_opaque to represent the input at + * that time, + * the decoder reorders values as needed and sets AVFrame.reordered_opaque + * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque + * @deprecated in favor of pkt_pts + */ + int64_t reordered_opaque; + +#if FF_API_AVFRAME_LAVC + /** + * @deprecated this field is unused + */ + attribute_deprecated void *hwaccel_picture_private; + + attribute_deprecated + struct AVCodecContext *owner; + attribute_deprecated + void *thread_opaque; + + /** + * log2 of the size of the block which a single vector in motion_val represents: + * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2) + */ + attribute_deprecated + uint8_t motion_subsample_log2; +#endif + + /** + * Sample rate of the audio data. + */ + int sample_rate; + + /** + * Channel layout of the audio data. + */ + uint64_t channel_layout; + + /** + * AVBuffer references backing the data for this frame. If all elements of + * this array are NULL, then this frame is not reference counted. + * + * There may be at most one AVBuffer per data plane, so for video this array + * always contains all the references. For planar audio with more than + * AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in + * this array. Then the extra AVBufferRef pointers are stored in the + * extended_buf array. + */ + AVBufferRef *buf[AV_NUM_DATA_POINTERS]; + + /** + * For planar audio which requires more than AV_NUM_DATA_POINTERS + * AVBufferRef pointers, this array will hold all the references which + * cannot fit into AVFrame.buf. + * + * Note that this is different from AVFrame.extended_data, which always + * contains all the pointers. This array only contains the extra pointers, + * which cannot fit into AVFrame.buf. + * + * This array is always allocated using av_malloc() by whoever constructs + * the frame. It is freed in av_frame_unref(). + */ + AVBufferRef **extended_buf; + /** + * Number of elements in extended_buf. + */ + int nb_extended_buf; + + AVFrameSideData **side_data; + int nb_side_data; +} AVFrame; + +/** + * Allocate an AVFrame and set its fields to default values. The resulting + * struct must be freed using av_frame_free(). + * + * @return An AVFrame filled with default values or NULL on failure. + * + * @note this only allocates the AVFrame itself, not the data buffers. Those + * must be allocated through other means, e.g. with av_frame_get_buffer() or + * manually. + */ +AVFrame *av_frame_alloc(void); + +/** + * Free the frame and any dynamically allocated objects in it, + * e.g. extended_data. If the frame is reference counted, it will be + * unreferenced first. + * + * @param frame frame to be freed. The pointer will be set to NULL. + */ +void av_frame_free(AVFrame **frame); + +/** + * Setup a new reference to the data described by an given frame. + * + * Copy frame properties from src to dst and create a new reference for each + * AVBufferRef from src. + * + * If src is not reference counted, new buffers are allocated and the data is + * copied. + * + * @return 0 on success, a negative AVERROR on error + */ +int av_frame_ref(AVFrame *dst, AVFrame *src); + +/** + * Create a new frame that references the same data as src. + * + * This is a shortcut for av_frame_alloc()+av_frame_ref(). + * + * @return newly created AVFrame on success, NULL on error. + */ +AVFrame *av_frame_clone(AVFrame *src); + +/** + * Unreference all the buffers referenced by frame and reset the frame fields. + */ +void av_frame_unref(AVFrame *frame); + +/** + * Move everythnig contained in src to dst and reset src. + */ +void av_frame_move_ref(AVFrame *dst, AVFrame *src); + +/** + * Allocate new buffer(s) for audio or video data. + * + * The following fields must be set on frame before calling this function: + * - format (pixel format for video, sample format for audio) + * - width and height for video + * - nb_samples and channel_layout for audio + * + * This function will fill AVFrame.data and AVFrame.buf arrays and, if + * necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf. + * For planar formats, one buffer will be allocated for each plane. + * + * @param frame frame in which to store the new buffers. + * @param align required buffer size alignment + * + * @return 0 on success, a negative AVERROR on error. + */ +int av_frame_get_buffer(AVFrame *frame, int align); + +/** + * Check if the frame data is writable. + * + * @return A positive value if the frame data is writable (which is true if and + * only if each of the underlying buffers has only one reference, namely the one + * stored in this frame). Return 0 otherwise. + * + * If 1 is returned the answer is valid until av_buffer_ref() is called on any + * of the underlying AVBufferRefs (e.g. through av_frame_ref() or directly). + * + * @see av_frame_make_writable(), av_buffer_is_writable() + */ +int av_frame_is_writable(AVFrame *frame); + +/** + * Ensure that the frame data is writable, avoiding data copy if possible. + * + * Do nothing if the frame is writable, allocate new buffers and copy the data + * if it is not. + * + * @return 0 on success, a negative AVERROR on error. + * + * @see av_frame_is_writable(), av_buffer_is_writable(), + * av_buffer_make_writable() + */ +int av_frame_make_writable(AVFrame *frame); + +/** + * Copy only "metadata" fields from src to dst. + * + * Metadata for the purpose of this function are those fields that do not affect + * the data layout in the buffers. E.g. pts, sample rate (for audio) or sample + * aspect ratio (for video), but not width/height or channel layout. + * Side data is also copied. + */ +int av_frame_copy_props(AVFrame *dst, const AVFrame *src); + +/** + * Get the buffer reference a given data plane is stored in. + * + * @param plane index of the data plane of interest in frame->extended_data. + * + * @return the buffer reference that contains the plane or NULL if the input + * frame is not valid. + */ +AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane); + +/** + * Add a new side data to a frame. + * + * @param frame a frame to which the side data should be added + * @param type type of the added side data + * @param size size of the side data + * + * @return newly added side data on success, NULL on error + */ +AVFrameSideData *av_frame_new_side_data(AVFrame *frame, + enum AVFrameSideDataType type, + int size); + +/** + * @return a pointer to the side data of a given type on success, NULL if there + * is no side data with such type in this frame. + */ +AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, + enum AVFrameSideDataType type); + +#endif /* AVUTIL_FRAME_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/hmac.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/hmac.h new file mode 100644 index 000000000..28c2062b1 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/hmac.h @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2012 Martin Storsjo + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HMAC_H +#define AVUTIL_HMAC_H + +#include + +/** + * @defgroup lavu_hmac HMAC + * @ingroup lavu_crypto + * @{ + */ + +enum AVHMACType { + AV_HMAC_MD5, + AV_HMAC_SHA1, +}; + +typedef struct AVHMAC AVHMAC; + +/** + * Allocate an AVHMAC context. + * @param type The hash function used for the HMAC. + */ +AVHMAC *av_hmac_alloc(enum AVHMACType type); + +/** + * Free an AVHMAC context. + * @param ctx The context to free, may be NULL + */ +void av_hmac_free(AVHMAC *ctx); + +/** + * Initialize an AVHMAC context with an authentication key. + * @param ctx The HMAC context + * @param key The authentication key + * @param keylen The length of the key, in bytes + */ +void av_hmac_init(AVHMAC *ctx, const uint8_t *key, unsigned int keylen); + +/** + * Hash data with the HMAC. + * @param ctx The HMAC context + * @param data The data to hash + * @param len The length of the data, in bytes + */ +void av_hmac_update(AVHMAC *ctx, const uint8_t *data, unsigned int len); + +/** + * Finish hashing and output the HMAC digest. + * @param ctx The HMAC context + * @param out The output buffer to write the digest into + * @param outlen The length of the out buffer, in bytes + * @return The number of bytes written to out, or a negative error code. + */ +int av_hmac_final(AVHMAC *ctx, uint8_t *out, unsigned int outlen); + +/** + * Hash an array of data with a key. + * @param ctx The HMAC context + * @param data The data to hash + * @param len The length of the data, in bytes + * @param key The authentication key + * @param keylen The length of the key, in bytes + * @param out The output buffer to write the digest into + * @param outlen The length of the out buffer, in bytes + * @return The number of bytes written to out, or a negative error code. + */ +int av_hmac_calc(AVHMAC *ctx, const uint8_t *data, unsigned int len, + const uint8_t *key, unsigned int keylen, + uint8_t *out, unsigned int outlen); + +/** + * @} + */ + +#endif /* AVUTIL_HMAC_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/imgutils.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/imgutils.h new file mode 100644 index 000000000..71510132a --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/imgutils.h @@ -0,0 +1,138 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_IMGUTILS_H +#define AVUTIL_IMGUTILS_H + +/** + * @file + * misc image utilities + * + * @addtogroup lavu_picture + * @{ + */ + +#include "avutil.h" +#include "pixdesc.h" + +/** + * Compute the max pixel step for each plane of an image with a + * format described by pixdesc. + * + * The pixel step is the distance in bytes between the first byte of + * the group of bytes which describe a pixel component and the first + * byte of the successive group in the same plane for the same + * component. + * + * @param max_pixsteps an array which is filled with the max pixel step + * for each plane. Since a plane may contain different pixel + * components, the computed max_pixsteps[plane] is relative to the + * component in the plane with the max pixel step. + * @param max_pixstep_comps an array which is filled with the component + * for each plane which has the max pixel step. May be NULL. + */ +void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], + const AVPixFmtDescriptor *pixdesc); + +/** + * Compute the size of an image line with format pix_fmt and width + * width for the plane plane. + * + * @return the computed size in bytes + */ +int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane); + +/** + * Fill plane linesizes for an image with pixel format pix_fmt and + * width width. + * + * @param linesizes array to be filled with the linesize for each plane + * @return >= 0 in case of success, a negative error code otherwise + */ +int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width); + +/** + * Fill plane data pointers for an image with pixel format pix_fmt and + * height height. + * + * @param data pointers array to be filled with the pointer for each image plane + * @param ptr the pointer to a buffer which will contain the image + * @param linesizes the array containing the linesize for each + * plane, should be filled by av_image_fill_linesizes() + * @return the size in bytes required for the image buffer, a negative + * error code in case of failure + */ +int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height, + uint8_t *ptr, const int linesizes[4]); + +/** + * Allocate an image with size w and h and pixel format pix_fmt, and + * fill pointers and linesizes accordingly. + * The allocated image buffer has to be freed by using + * av_freep(&pointers[0]). + * + * @param align the value to use for buffer size alignment + * @return the size in bytes required for the image buffer, a negative + * error code in case of failure + */ +int av_image_alloc(uint8_t *pointers[4], int linesizes[4], + int w, int h, enum AVPixelFormat pix_fmt, int align); + +/** + * Copy image plane from src to dst. + * That is, copy "height" number of lines of "bytewidth" bytes each. + * The first byte of each successive line is separated by *_linesize + * bytes. + * + * @param dst_linesize linesize for the image plane in dst + * @param src_linesize linesize for the image plane in src + */ +void av_image_copy_plane(uint8_t *dst, int dst_linesize, + const uint8_t *src, int src_linesize, + int bytewidth, int height); + +/** + * Copy image in src_data to dst_data. + * + * @param dst_linesizes linesizes for the image in dst_data + * @param src_linesizes linesizes for the image in src_data + */ +void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], + const uint8_t *src_data[4], const int src_linesizes[4], + enum AVPixelFormat pix_fmt, int width, int height); + +/** + * Check if the given dimension of an image is valid, meaning that all + * bytes of the image can be addressed with a signed int. + * + * @param w the width of the picture + * @param h the height of the picture + * @param log_offset the offset to sum to the log level for logging with log_ctx + * @param log_ctx the parent logging context, it may be NULL + * @return >= 0 if valid, a negative error code otherwise + */ +int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx); + +int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt); + +/** + * @} + */ + + +#endif /* AVUTIL_IMGUTILS_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intfloat.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intfloat.h new file mode 100644 index 000000000..38d26ad87 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intfloat.h @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2011 Mans Rullgard + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTFLOAT_H +#define AVUTIL_INTFLOAT_H + +#include +#include "attributes.h" + +union av_intfloat32 { + uint32_t i; + float f; +}; + +union av_intfloat64 { + uint64_t i; + double f; +}; + +/** + * Reinterpret a 32-bit integer as a float. + */ +static av_always_inline float av_int2float(uint32_t i) +{ + union av_intfloat32 v; + v.i = i; + return v.f; +} + +/** + * Reinterpret a float as a 32-bit integer. + */ +static av_always_inline uint32_t av_float2int(float f) +{ + union av_intfloat32 v; + v.f = f; + return v.i; +} + +/** + * Reinterpret a 64-bit integer as a double. + */ +static av_always_inline double av_int2double(uint64_t i) +{ + union av_intfloat64 v; + v.i = i; + return v.f; +} + +/** + * Reinterpret a double as a 64-bit integer. + */ +static av_always_inline uint64_t av_double2int(double f) +{ + union av_intfloat64 v; + v.f = f; + return v.i; +} + +#endif /* AVUTIL_INTFLOAT_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intfloat_readwrite.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intfloat_readwrite.h new file mode 100644 index 000000000..f093b92cd --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intfloat_readwrite.h @@ -0,0 +1,40 @@ +/* + * copyright (c) 2005 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTFLOAT_READWRITE_H +#define AVUTIL_INTFLOAT_READWRITE_H + +#include +#include "attributes.h" + +/* IEEE 80 bits extended float */ +typedef struct AVExtFloat { + uint8_t exponent[2]; + uint8_t mantissa[8]; +} AVExtFloat; + +attribute_deprecated double av_int2dbl(int64_t v) av_const; +attribute_deprecated float av_int2flt(int32_t v) av_const; +attribute_deprecated double av_ext2dbl(const AVExtFloat ext) av_const; +attribute_deprecated int64_t av_dbl2int(double d) av_const; +attribute_deprecated int32_t av_flt2int(float d) av_const; +attribute_deprecated AVExtFloat av_dbl2ext(double d) av_const; + +#endif /* AVUTIL_INTFLOAT_READWRITE_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intreadwrite.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intreadwrite.h new file mode 100644 index 000000000..f77fd60f3 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/intreadwrite.h @@ -0,0 +1,549 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTREADWRITE_H +#define AVUTIL_INTREADWRITE_H + +#include +#include "libavutil/avconfig.h" +#include "attributes.h" +#include "bswap.h" + +typedef union { + uint64_t u64; + uint32_t u32[2]; + uint16_t u16[4]; + uint8_t u8 [8]; + double f64; + float f32[2]; +} av_alias av_alias64; + +typedef union { + uint32_t u32; + uint16_t u16[2]; + uint8_t u8 [4]; + float f32; +} av_alias av_alias32; + +typedef union { + uint16_t u16; + uint8_t u8 [2]; +} av_alias av_alias16; + +/* + * Arch-specific headers can provide any combination of + * AV_[RW][BLN](16|24|32|64) and AV_(COPY|SWAP|ZERO)(64|128) macros. + * Preprocessor symbols must be defined, even if these are implemented + * as inline functions. + */ + +#ifdef HAVE_AV_CONFIG_H + +#include "config.h" + +#if ARCH_ARM +# include "arm/intreadwrite.h" +#elif ARCH_AVR32 +# include "avr32/intreadwrite.h" +#elif ARCH_MIPS +# include "mips/intreadwrite.h" +#elif ARCH_PPC +# include "ppc/intreadwrite.h" +#elif ARCH_TOMI +# include "tomi/intreadwrite.h" +#elif ARCH_X86 +# include "x86/intreadwrite.h" +#endif + +#endif /* HAVE_AV_CONFIG_H */ + +/* + * Map AV_RNXX <-> AV_R[BL]XX for all variants provided by per-arch headers. + */ + +#if AV_HAVE_BIGENDIAN + +# if defined(AV_RN16) && !defined(AV_RB16) +# define AV_RB16(p) AV_RN16(p) +# elif !defined(AV_RN16) && defined(AV_RB16) +# define AV_RN16(p) AV_RB16(p) +# endif + +# if defined(AV_WN16) && !defined(AV_WB16) +# define AV_WB16(p, v) AV_WN16(p, v) +# elif !defined(AV_WN16) && defined(AV_WB16) +# define AV_WN16(p, v) AV_WB16(p, v) +# endif + +# if defined(AV_RN24) && !defined(AV_RB24) +# define AV_RB24(p) AV_RN24(p) +# elif !defined(AV_RN24) && defined(AV_RB24) +# define AV_RN24(p) AV_RB24(p) +# endif + +# if defined(AV_WN24) && !defined(AV_WB24) +# define AV_WB24(p, v) AV_WN24(p, v) +# elif !defined(AV_WN24) && defined(AV_WB24) +# define AV_WN24(p, v) AV_WB24(p, v) +# endif + +# if defined(AV_RN32) && !defined(AV_RB32) +# define AV_RB32(p) AV_RN32(p) +# elif !defined(AV_RN32) && defined(AV_RB32) +# define AV_RN32(p) AV_RB32(p) +# endif + +# if defined(AV_WN32) && !defined(AV_WB32) +# define AV_WB32(p, v) AV_WN32(p, v) +# elif !defined(AV_WN32) && defined(AV_WB32) +# define AV_WN32(p, v) AV_WB32(p, v) +# endif + +# if defined(AV_RN64) && !defined(AV_RB64) +# define AV_RB64(p) AV_RN64(p) +# elif !defined(AV_RN64) && defined(AV_RB64) +# define AV_RN64(p) AV_RB64(p) +# endif + +# if defined(AV_WN64) && !defined(AV_WB64) +# define AV_WB64(p, v) AV_WN64(p, v) +# elif !defined(AV_WN64) && defined(AV_WB64) +# define AV_WN64(p, v) AV_WB64(p, v) +# endif + +#else /* AV_HAVE_BIGENDIAN */ + +# if defined(AV_RN16) && !defined(AV_RL16) +# define AV_RL16(p) AV_RN16(p) +# elif !defined(AV_RN16) && defined(AV_RL16) +# define AV_RN16(p) AV_RL16(p) +# endif + +# if defined(AV_WN16) && !defined(AV_WL16) +# define AV_WL16(p, v) AV_WN16(p, v) +# elif !defined(AV_WN16) && defined(AV_WL16) +# define AV_WN16(p, v) AV_WL16(p, v) +# endif + +# if defined(AV_RN24) && !defined(AV_RL24) +# define AV_RL24(p) AV_RN24(p) +# elif !defined(AV_RN24) && defined(AV_RL24) +# define AV_RN24(p) AV_RL24(p) +# endif + +# if defined(AV_WN24) && !defined(AV_WL24) +# define AV_WL24(p, v) AV_WN24(p, v) +# elif !defined(AV_WN24) && defined(AV_WL24) +# define AV_WN24(p, v) AV_WL24(p, v) +# endif + +# if defined(AV_RN32) && !defined(AV_RL32) +# define AV_RL32(p) AV_RN32(p) +# elif !defined(AV_RN32) && defined(AV_RL32) +# define AV_RN32(p) AV_RL32(p) +# endif + +# if defined(AV_WN32) && !defined(AV_WL32) +# define AV_WL32(p, v) AV_WN32(p, v) +# elif !defined(AV_WN32) && defined(AV_WL32) +# define AV_WN32(p, v) AV_WL32(p, v) +# endif + +# if defined(AV_RN64) && !defined(AV_RL64) +# define AV_RL64(p) AV_RN64(p) +# elif !defined(AV_RN64) && defined(AV_RL64) +# define AV_RN64(p) AV_RL64(p) +# endif + +# if defined(AV_WN64) && !defined(AV_WL64) +# define AV_WL64(p, v) AV_WN64(p, v) +# elif !defined(AV_WN64) && defined(AV_WL64) +# define AV_WN64(p, v) AV_WL64(p, v) +# endif + +#endif /* !AV_HAVE_BIGENDIAN */ + +/* + * Define AV_[RW]N helper macros to simplify definitions not provided + * by per-arch headers. + */ + +#if defined(__GNUC__) && !defined(__TI_COMPILER_VERSION__) + +union unaligned_64 { uint64_t l; } __attribute__((packed)) av_alias; +union unaligned_32 { uint32_t l; } __attribute__((packed)) av_alias; +union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias; + +# define AV_RN(s, p) (((const union unaligned_##s *) (p))->l) +# define AV_WN(s, p, v) ((((union unaligned_##s *) (p))->l) = (v)) + +#elif defined(__DECC) + +# define AV_RN(s, p) (*((const __unaligned uint##s##_t*)(p))) +# define AV_WN(s, p, v) (*((__unaligned uint##s##_t*)(p)) = (v)) + +#elif AV_HAVE_FAST_UNALIGNED + +# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s) +# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v)) + +#else + +#ifndef AV_RB16 +# define AV_RB16(x) \ + ((((const uint8_t*)(x))[0] << 8) | \ + ((const uint8_t*)(x))[1]) +#endif +#ifndef AV_WB16 +# define AV_WB16(p, d) do { \ + ((uint8_t*)(p))[1] = (d); \ + ((uint8_t*)(p))[0] = (d)>>8; \ + } while(0) +#endif + +#ifndef AV_RL16 +# define AV_RL16(x) \ + ((((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL16 +# define AV_WL16(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + } while(0) +#endif + +#ifndef AV_RB32 +# define AV_RB32(x) \ + (((uint32_t)((const uint8_t*)(x))[0] << 24) | \ + (((const uint8_t*)(x))[1] << 16) | \ + (((const uint8_t*)(x))[2] << 8) | \ + ((const uint8_t*)(x))[3]) +#endif +#ifndef AV_WB32 +# define AV_WB32(p, d) do { \ + ((uint8_t*)(p))[3] = (d); \ + ((uint8_t*)(p))[2] = (d)>>8; \ + ((uint8_t*)(p))[1] = (d)>>16; \ + ((uint8_t*)(p))[0] = (d)>>24; \ + } while(0) +#endif + +#ifndef AV_RL32 +# define AV_RL32(x) \ + (((uint32_t)((const uint8_t*)(x))[3] << 24) | \ + (((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL32 +# define AV_WL32(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; \ + } while(0) +#endif + +#ifndef AV_RB64 +# define AV_RB64(x) \ + (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ + (uint64_t)((const uint8_t*)(x))[7]) +#endif +#ifndef AV_WB64 +# define AV_WB64(p, d) do { \ + ((uint8_t*)(p))[7] = (d); \ + ((uint8_t*)(p))[6] = (d)>>8; \ + ((uint8_t*)(p))[5] = (d)>>16; \ + ((uint8_t*)(p))[4] = (d)>>24; \ + ((uint8_t*)(p))[3] = (d)>>32; \ + ((uint8_t*)(p))[2] = (d)>>40; \ + ((uint8_t*)(p))[1] = (d)>>48; \ + ((uint8_t*)(p))[0] = (d)>>56; \ + } while(0) +#endif + +#ifndef AV_RL64 +# define AV_RL64(x) \ + (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ + (uint64_t)((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL64 +# define AV_WL64(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; \ + ((uint8_t*)(p))[4] = (d)>>32; \ + ((uint8_t*)(p))[5] = (d)>>40; \ + ((uint8_t*)(p))[6] = (d)>>48; \ + ((uint8_t*)(p))[7] = (d)>>56; \ + } while(0) +#endif + +#if AV_HAVE_BIGENDIAN +# define AV_RN(s, p) AV_RB##s(p) +# define AV_WN(s, p, v) AV_WB##s(p, v) +#else +# define AV_RN(s, p) AV_RL##s(p) +# define AV_WN(s, p, v) AV_WL##s(p, v) +#endif + +#endif /* HAVE_FAST_UNALIGNED */ + +#ifndef AV_RN16 +# define AV_RN16(p) AV_RN(16, p) +#endif + +#ifndef AV_RN32 +# define AV_RN32(p) AV_RN(32, p) +#endif + +#ifndef AV_RN64 +# define AV_RN64(p) AV_RN(64, p) +#endif + +#ifndef AV_WN16 +# define AV_WN16(p, v) AV_WN(16, p, v) +#endif + +#ifndef AV_WN32 +# define AV_WN32(p, v) AV_WN(32, p, v) +#endif + +#ifndef AV_WN64 +# define AV_WN64(p, v) AV_WN(64, p, v) +#endif + +#if AV_HAVE_BIGENDIAN +# define AV_RB(s, p) AV_RN##s(p) +# define AV_WB(s, p, v) AV_WN##s(p, v) +# define AV_RL(s, p) av_bswap##s(AV_RN##s(p)) +# define AV_WL(s, p, v) AV_WN##s(p, av_bswap##s(v)) +#else +# define AV_RB(s, p) av_bswap##s(AV_RN##s(p)) +# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v)) +# define AV_RL(s, p) AV_RN##s(p) +# define AV_WL(s, p, v) AV_WN##s(p, v) +#endif + +#define AV_RB8(x) (((const uint8_t*)(x))[0]) +#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) + +#define AV_RL8(x) AV_RB8(x) +#define AV_WL8(p, d) AV_WB8(p, d) + +#ifndef AV_RB16 +# define AV_RB16(p) AV_RB(16, p) +#endif +#ifndef AV_WB16 +# define AV_WB16(p, v) AV_WB(16, p, v) +#endif + +#ifndef AV_RL16 +# define AV_RL16(p) AV_RL(16, p) +#endif +#ifndef AV_WL16 +# define AV_WL16(p, v) AV_WL(16, p, v) +#endif + +#ifndef AV_RB32 +# define AV_RB32(p) AV_RB(32, p) +#endif +#ifndef AV_WB32 +# define AV_WB32(p, v) AV_WB(32, p, v) +#endif + +#ifndef AV_RL32 +# define AV_RL32(p) AV_RL(32, p) +#endif +#ifndef AV_WL32 +# define AV_WL32(p, v) AV_WL(32, p, v) +#endif + +#ifndef AV_RB64 +# define AV_RB64(p) AV_RB(64, p) +#endif +#ifndef AV_WB64 +# define AV_WB64(p, v) AV_WB(64, p, v) +#endif + +#ifndef AV_RL64 +# define AV_RL64(p) AV_RL(64, p) +#endif +#ifndef AV_WL64 +# define AV_WL64(p, v) AV_WL(64, p, v) +#endif + +#ifndef AV_RB24 +# define AV_RB24(x) \ + ((((const uint8_t*)(x))[0] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[2]) +#endif +#ifndef AV_WB24 +# define AV_WB24(p, d) do { \ + ((uint8_t*)(p))[2] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[0] = (d)>>16; \ + } while(0) +#endif + +#ifndef AV_RL24 +# define AV_RL24(x) \ + ((((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#endif +#ifndef AV_WL24 +# define AV_WL24(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + } while(0) +#endif + +/* + * The AV_[RW]NA macros access naturally aligned data + * in a type-safe way. + */ + +#define AV_RNA(s, p) (((const av_alias##s*)(p))->u##s) +#define AV_WNA(s, p, v) (((av_alias##s*)(p))->u##s = (v)) + +#ifndef AV_RN16A +# define AV_RN16A(p) AV_RNA(16, p) +#endif + +#ifndef AV_RN32A +# define AV_RN32A(p) AV_RNA(32, p) +#endif + +#ifndef AV_RN64A +# define AV_RN64A(p) AV_RNA(64, p) +#endif + +#ifndef AV_WN16A +# define AV_WN16A(p, v) AV_WNA(16, p, v) +#endif + +#ifndef AV_WN32A +# define AV_WN32A(p, v) AV_WNA(32, p, v) +#endif + +#ifndef AV_WN64A +# define AV_WN64A(p, v) AV_WNA(64, p, v) +#endif + +/* + * The AV_COPYxxU macros are suitable for copying data to/from unaligned + * memory locations. + */ + +#define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s)); + +#ifndef AV_COPY16U +# define AV_COPY16U(d, s) AV_COPYU(16, d, s) +#endif + +#ifndef AV_COPY32U +# define AV_COPY32U(d, s) AV_COPYU(32, d, s) +#endif + +#ifndef AV_COPY64U +# define AV_COPY64U(d, s) AV_COPYU(64, d, s) +#endif + +#ifndef AV_COPY128U +# define AV_COPY128U(d, s) \ + do { \ + AV_COPY64U(d, s); \ + AV_COPY64U((char *)(d) + 8, (const char *)(s) + 8); \ + } while(0) +#endif + +/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be + * naturally aligned. They may be implemented using MMX, + * so emms_c() must be called before using any float code + * afterwards. + */ + +#define AV_COPY(n, d, s) \ + (((av_alias##n*)(d))->u##n = ((const av_alias##n*)(s))->u##n) + +#ifndef AV_COPY16 +# define AV_COPY16(d, s) AV_COPY(16, d, s) +#endif + +#ifndef AV_COPY32 +# define AV_COPY32(d, s) AV_COPY(32, d, s) +#endif + +#ifndef AV_COPY64 +# define AV_COPY64(d, s) AV_COPY(64, d, s) +#endif + +#ifndef AV_COPY128 +# define AV_COPY128(d, s) \ + do { \ + AV_COPY64(d, s); \ + AV_COPY64((char*)(d)+8, (char*)(s)+8); \ + } while(0) +#endif + +#define AV_SWAP(n, a, b) FFSWAP(av_alias##n, *(av_alias##n*)(a), *(av_alias##n*)(b)) + +#ifndef AV_SWAP64 +# define AV_SWAP64(a, b) AV_SWAP(64, a, b) +#endif + +#define AV_ZERO(n, d) (((av_alias##n*)(d))->u##n = 0) + +#ifndef AV_ZERO16 +# define AV_ZERO16(d) AV_ZERO(16, d) +#endif + +#ifndef AV_ZERO32 +# define AV_ZERO32(d) AV_ZERO(32, d) +#endif + +#ifndef AV_ZERO64 +# define AV_ZERO64(d) AV_ZERO(64, d) +#endif + +#ifndef AV_ZERO128 +# define AV_ZERO128(d) \ + do { \ + AV_ZERO64(d); \ + AV_ZERO64((char*)(d)+8); \ + } while(0) +#endif + +#endif /* AVUTIL_INTREADWRITE_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/lfg.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/lfg.h new file mode 100644 index 000000000..5e526c1da --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/lfg.h @@ -0,0 +1,62 @@ +/* + * Lagged Fibonacci PRNG + * Copyright (c) 2008 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_LFG_H +#define AVUTIL_LFG_H + +typedef struct AVLFG { + unsigned int state[64]; + int index; +} AVLFG; + +void av_lfg_init(AVLFG *c, unsigned int seed); + +/** + * Get the next random unsigned 32-bit number using an ALFG. + * + * Please also consider a simple LCG like state= state*1664525+1013904223, + * it may be good enough and faster for your specific use case. + */ +static inline unsigned int av_lfg_get(AVLFG *c){ + c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63]; + return c->state[c->index++ & 63]; +} + +/** + * Get the next random unsigned 32-bit number using a MLFG. + * + * Please also consider av_lfg_get() above, it is faster. + */ +static inline unsigned int av_mlfg_get(AVLFG *c){ + unsigned int a= c->state[(c->index-55) & 63]; + unsigned int b= c->state[(c->index-24) & 63]; + return c->state[c->index++ & 63] = 2*a*b+a+b; +} + +/** + * Get the next two numbers generated by a Box-Muller Gaussian + * generator using the random numbers issued by lfg. + * + * @param out array where the two generated numbers are placed + */ +void av_bmg_get(AVLFG *lfg, double out[2]); + +#endif /* AVUTIL_LFG_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/log.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/log.h new file mode 100644 index 000000000..7b173302f --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/log.h @@ -0,0 +1,173 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_LOG_H +#define AVUTIL_LOG_H + +#include +#include "avutil.h" +#include "attributes.h" + +/** + * Describe the class of an AVClass context structure. That is an + * arbitrary struct of which the first field is a pointer to an + * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). + */ +typedef struct AVClass { + /** + * The name of the class; usually it is the same name as the + * context structure type to which the AVClass is associated. + */ + const char* class_name; + + /** + * A pointer to a function which returns the name of a context + * instance ctx associated with the class. + */ + const char* (*item_name)(void* ctx); + + /** + * a pointer to the first option specified in the class if any or NULL + * + * @see av_set_default_options() + */ + const struct AVOption *option; + + /** + * LIBAVUTIL_VERSION with which this structure was created. + * This is used to allow fields to be added without requiring major + * version bumps everywhere. + */ + + int version; + + /** + * Offset in the structure where log_level_offset is stored. + * 0 means there is no such variable + */ + int log_level_offset_offset; + + /** + * Offset in the structure where a pointer to the parent context for + * logging is stored. For example a decoder could pass its AVCodecContext + * to eval as such a parent context, which an av_log() implementation + * could then leverage to display the parent context. + * The offset can be NULL. + */ + int parent_log_context_offset; + + /** + * Return next AVOptions-enabled child or NULL + */ + void* (*child_next)(void *obj, void *prev); + + /** + * Return an AVClass corresponding to the next potential + * AVOptions-enabled child. + * + * The difference between child_next and this is that + * child_next iterates over _already existing_ objects, while + * child_class_next iterates over _all possible_ children. + */ + const struct AVClass* (*child_class_next)(const struct AVClass *prev); +} AVClass; + +/* av_log API */ + +#define AV_LOG_QUIET -8 + +/** + * Something went really wrong and we will crash now. + */ +#define AV_LOG_PANIC 0 + +/** + * Something went wrong and recovery is not possible. + * For example, no header was found for a format which depends + * on headers or an illegal combination of parameters is used. + */ +#define AV_LOG_FATAL 8 + +/** + * Something went wrong and cannot losslessly be recovered. + * However, not all future data is affected. + */ +#define AV_LOG_ERROR 16 + +/** + * Something somehow does not look correct. This may or may not + * lead to problems. An example would be the use of '-vstrict -2'. + */ +#define AV_LOG_WARNING 24 + +#define AV_LOG_INFO 32 +#define AV_LOG_VERBOSE 40 + +/** + * Stuff which is only useful for libav* developers. + */ +#define AV_LOG_DEBUG 48 + +/** + * Send the specified message to the log if the level is less than or equal + * to the current av_log_level. By default, all logging messages are sent to + * stderr. This behavior can be altered by setting a different av_vlog callback + * function. + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct. + * @param level The importance level of the message, lower values signifying + * higher importance. + * @param fmt The format string (printf-compatible) that specifies how + * subsequent arguments are converted to output. + * @see av_vlog + */ +void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); + +void av_vlog(void *avcl, int level, const char *fmt, va_list); +int av_log_get_level(void); +void av_log_set_level(int); +void av_log_set_callback(void (*)(void*, int, const char*, va_list)); +void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); +const char* av_default_item_name(void* ctx); + +/** + * av_dlog macros + * Useful to print debug messages that shouldn't get compiled in normally. + */ + +#ifdef DEBUG +# define av_dlog(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) +#else +# define av_dlog(pctx, ...) +#endif + +/** + * Skip repeated messages, this requires the user app to use av_log() instead of + * (f)printf as the 2 would otherwise interfere and lead to + * "Last message repeated x times" messages below (f)printf messages with some + * bad luck. + * Also to receive the last, "last repeated" line if any, the user app must + * call av_log(NULL, AV_LOG_QUIET, ""); at the end + */ +#define AV_LOG_SKIP_REPEATED 1 +void av_log_set_flags(int arg); + +#endif /* AVUTIL_LOG_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/lzo.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/lzo.h new file mode 100644 index 000000000..9d7e8f1dc --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/lzo.h @@ -0,0 +1,66 @@ +/* + * LZO 1x decompression + * copyright (c) 2006 Reimar Doeffinger + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_LZO_H +#define AVUTIL_LZO_H + +/** + * @defgroup lavu_lzo LZO + * @ingroup lavu_crypto + * + * @{ + */ + +#include + +/** @name Error flags returned by av_lzo1x_decode + * @{ */ +/// end of the input buffer reached before decoding finished +#define AV_LZO_INPUT_DEPLETED 1 +/// decoded data did not fit into output buffer +#define AV_LZO_OUTPUT_FULL 2 +/// a reference to previously decoded data was wrong +#define AV_LZO_INVALID_BACKPTR 4 +/// a non-specific error in the compressed bitstream +#define AV_LZO_ERROR 8 +/** @} */ + +#define AV_LZO_INPUT_PADDING 8 +#define AV_LZO_OUTPUT_PADDING 12 + +/** + * @brief Decodes LZO 1x compressed data. + * @param out output buffer + * @param outlen size of output buffer, number of bytes left are returned here + * @param in input buffer + * @param inlen size of input buffer, number of bytes left are returned here + * @return 0 on success, otherwise a combination of the error flags above + * + * Make sure all buffers are appropriately padded, in must provide + * AV_LZO_INPUT_PADDING, out must provide AV_LZO_OUTPUT_PADDING additional bytes. + */ +int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); + +/** + * @} + */ + +#endif /* AVUTIL_LZO_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/mathematics.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/mathematics.h new file mode 100644 index 000000000..043dd0faf --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/mathematics.h @@ -0,0 +1,111 @@ +/* + * copyright (c) 2005 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_MATHEMATICS_H +#define AVUTIL_MATHEMATICS_H + +#include +#include +#include "attributes.h" +#include "rational.h" +#include "intfloat.h" + +#ifndef M_LOG2_10 +#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ +#endif +#ifndef M_PHI +#define M_PHI 1.61803398874989484820 /* phi / golden ratio */ +#endif +#ifndef NAN +#define NAN av_int2float(0x7fc00000) +#endif +#ifndef INFINITY +#define INFINITY av_int2float(0x7f800000) +#endif + +/** + * @addtogroup lavu_math + * @{ + */ + + +enum AVRounding { + AV_ROUND_ZERO = 0, ///< Round toward zero. + AV_ROUND_INF = 1, ///< Round away from zero. + AV_ROUND_DOWN = 2, ///< Round toward -infinity. + AV_ROUND_UP = 3, ///< Round toward +infinity. + AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero. +}; + +/** + * Return the greatest common divisor of a and b. + * If both a and b are 0 or either or both are <0 then behavior is + * undefined. + */ +int64_t av_const av_gcd(int64_t a, int64_t b); + +/** + * Rescale a 64-bit integer with rounding to nearest. + * A simple a*b/c isn't possible as it can overflow. + */ +int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; + +/** + * Rescale a 64-bit integer with specified rounding. + * A simple a*b/c isn't possible as it can overflow. + */ +int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const; + +/** + * Rescale a 64-bit integer by 2 rational numbers. + */ +int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; + +/** + * Rescale a 64-bit integer by 2 rational numbers with specified rounding. + */ +int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, + enum AVRounding) av_const; + +/** + * Compare 2 timestamps each in its own timebases. + * The result of the function is undefined if one of the timestamps + * is outside the int64_t range when represented in the others timebase. + * @return -1 if ts_a is before ts_b, 1 if ts_a is after ts_b or 0 if they represent the same position + */ +int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); + +/** + * Compare 2 integers modulo mod. + * That is we compare integers a and b for which only the least + * significant log2(mod) bits are known. + * + * @param mod must be a power of 2 + * @return a negative value if a is smaller than b + * a positive value if a is greater than b + * 0 if a equals b + */ +int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod); + +/** + * @} + */ + +#endif /* AVUTIL_MATHEMATICS_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/md5.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/md5.h new file mode 100644 index 000000000..29e4e7c2b --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/md5.h @@ -0,0 +1,51 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_MD5_H +#define AVUTIL_MD5_H + +#include + +#include "attributes.h" +#include "version.h" + +/** + * @defgroup lavu_md5 MD5 + * @ingroup lavu_crypto + * @{ + */ + +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_md5_size; +#endif + +struct AVMD5; + +struct AVMD5 *av_md5_alloc(void); +void av_md5_init(struct AVMD5 *ctx); +void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, const int len); +void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); +void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len); + +/** + * @} + */ + +#endif /* AVUTIL_MD5_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/mem.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/mem.h new file mode 100644 index 000000000..8a4fcd90a --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/mem.h @@ -0,0 +1,209 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * memory handling functions + */ + +#ifndef AVUTIL_MEM_H +#define AVUTIL_MEM_H + +#include +#include + +#include "attributes.h" +#include "avutil.h" + +/** + * @addtogroup lavu_mem + * @{ + */ + + +#if defined(__ICC) && __ICC < 1200 || defined(__SUNPRO_C) + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v +#elif defined(__TI_COMPILER_VERSION__) + #define DECLARE_ALIGNED(n,t,v) \ + AV_PRAGMA(DATA_ALIGN(v,n)) \ + t __attribute__((aligned(n))) v + #define DECLARE_ASM_CONST(n,t,v) \ + AV_PRAGMA(DATA_ALIGN(v,n)) \ + static const t __attribute__((aligned(n))) v +#elif defined(__GNUC__) + #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v +#elif defined(_MSC_VER) + #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v + #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v +#else + #define DECLARE_ALIGNED(n,t,v) t v + #define DECLARE_ASM_CONST(n,t,v) static const t v +#endif + +#if AV_GCC_VERSION_AT_LEAST(3,1) + #define av_malloc_attrib __attribute__((__malloc__)) +#else + #define av_malloc_attrib +#endif + +#if AV_GCC_VERSION_AT_LEAST(4,3) + #define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__))) +#else + #define av_alloc_size(...) +#endif + +/** + * Allocate a block of size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU). + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if the block cannot + * be allocated. + * @see av_mallocz() + */ +void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); + +/** + * Helper function to allocate a block of size * nmemb bytes with + * using av_malloc() + * @param nmemb Number of elements + * @param size Size of the single element + * @return Pointer to the allocated block, NULL if the block cannot + * be allocated. + * @see av_malloc() + */ +av_alloc_size(1, 2) static inline void *av_malloc_array(size_t nmemb, size_t size) +{ + if (size <= 0 || nmemb >= INT_MAX / size) + return NULL; + return av_malloc(nmemb * size); +} + +/** + * Allocate or reallocate a block of memory. + * If ptr is NULL and size > 0, allocate a new block. If + * size is zero, free the memory block pointed to by ptr. + * @param ptr Pointer to a memory block already allocated with + * av_malloc(z)() or av_realloc() or NULL. + * @param size Size in bytes for the memory block to be allocated or + * reallocated. + * @return Pointer to a newly reallocated block or NULL if the block + * cannot be reallocated or the function is used to free the memory block. + * @see av_fast_realloc() + */ +void *av_realloc(void *ptr, size_t size) av_alloc_size(2); + +/** + * Allocate or reallocate an array. + * If ptr is NULL and nmemb > 0, allocate a new block. If + * nmemb is zero, free the memory block pointed to by ptr. + * @param ptr Pointer to a memory block already allocated with + * av_malloc(z)() or av_realloc() or NULL. + * @param nmemb Number of elements + * @param size Size of the single element + * @return Pointer to a newly reallocated block or NULL if the block + * cannot be reallocated or the function is used to free the memory block. + */ +av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size); + +/** + * Allocate or reallocate an array. + * If *ptr is NULL and nmemb > 0, allocate a new block. If + * nmemb is zero, free the memory block pointed to by ptr. + * @param ptr Pointer to a pointer to a memory block already allocated + * with av_malloc(z)() or av_realloc(), or pointer to a pointer to NULL. + * The pointer is updated on success, or freed on failure. + * @param nmemb Number of elements + * @param size Size of the single element + * @return Zero on success, an AVERROR error code on failure. + */ +av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t size); + +/** + * Free a memory block which has been allocated with av_malloc(z)() or + * av_realloc(). + * @param ptr Pointer to the memory block which should be freed. + * @note ptr = NULL is explicitly allowed. + * @note It is recommended that you use av_freep() instead. + * @see av_freep() + */ +void av_free(void *ptr); + +/** + * Allocate a block of size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU) and + * zero all the bytes of the block. + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if it cannot be allocated. + * @see av_malloc() + */ +void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); + +/** + * Helper function to allocate a block of size * nmemb bytes with + * using av_mallocz() + * @param nmemb Number of elements + * @param size Size of the single element + * @return Pointer to the allocated block, NULL if the block cannot + * be allocated. + * @see av_mallocz() + * @see av_malloc_array() + */ +av_alloc_size(1, 2) static inline void *av_mallocz_array(size_t nmemb, size_t size) +{ + if (size <= 0 || nmemb >= INT_MAX / size) + return NULL; + return av_mallocz(nmemb * size); +} + +/** + * Duplicate the string s. + * @param s string to be duplicated + * @return Pointer to a newly allocated string containing a + * copy of s or NULL if the string cannot be allocated. + */ +char *av_strdup(const char *s) av_malloc_attrib; + +/** + * Free a memory block which has been allocated with av_malloc(z)() or + * av_realloc() and set the pointer pointing to it to NULL. + * @param ptr Pointer to the pointer to the memory block which should + * be freed. + * @see av_free() + */ +void av_freep(void *ptr); + +/** + * @brief deliberately overlapping memcpy implementation + * @param dst destination buffer + * @param back how many bytes back we start (the initial size of the overlapping window) + * @param cnt number of bytes to copy, must be >= 0 + * + * cnt > back is valid, this will copy the bytes we just copied, + * thus creating a repeating pattern with a period length of back. + */ +void av_memcpy_backptr(uint8_t *dst, int back, int cnt); + +/** + * @} + */ + +#endif /* AVUTIL_MEM_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/old_pix_fmts.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/old_pix_fmts.h new file mode 100644 index 000000000..a0ae06b89 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/old_pix_fmts.h @@ -0,0 +1,132 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_OLD_PIX_FMTS_H +#define AVUTIL_OLD_PIX_FMTS_H + +/* + * This header exists to prevent new pixel formats from being accidentally added + * to the deprecated list. + * Do not include it directly. It will be removed on next major bump + * + * Do not add new items to this list. Use the AVPixelFormat enum instead. + */ + PIX_FMT_NONE = AV_PIX_FMT_NONE, + PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) + PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr + PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB... + PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR... + PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) + PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) + PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) + PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) + PIX_FMT_GRAY8, ///< Y , 8bpp + PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb + PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb + PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette + PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range + PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range + PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range + PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing + PIX_FMT_XVMC_MPEG2_IDCT, + PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 + PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 + PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) + PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits + PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) + PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) + PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits + PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) + PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) + PIX_FMT_NV21, ///< as above, but U and V bytes are swapped + + PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB... + PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA... + PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR... + PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA... + + PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian + PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian + PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) + PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range + PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) +#if FF_API_VDPAU + PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers +#endif + PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian + PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian + + PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian + PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian + PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 + PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 + + PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian + PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian + PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 + PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 + + PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers + PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers + PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + + PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian +#if FF_API_VDPAU + PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers +#endif + PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer + + PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 + PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 + PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 + PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 + PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha + PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian + PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian + PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + PIX_FMT_VDA_VLD, ///< hardware decoding through VDA + PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp + PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big endian + PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little endian + PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big endian + PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little endian + PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big endian + PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little endian + PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions + +#endif /* AVUTIL_OLD_PIX_FMTS_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/opt.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/opt.h new file mode 100644 index 000000000..0181379b7 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/opt.h @@ -0,0 +1,516 @@ +/* + * AVOptions + * copyright (c) 2005 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_OPT_H +#define AVUTIL_OPT_H + +/** + * @file + * AVOptions + */ + +#include "rational.h" +#include "avutil.h" +#include "dict.h" +#include "log.h" + +/** + * @defgroup avoptions AVOptions + * @ingroup lavu_data + * @{ + * AVOptions provide a generic system to declare options on arbitrary structs + * ("objects"). An option can have a help text, a type and a range of possible + * values. Options may then be enumerated, read and written to. + * + * @section avoptions_implement Implementing AVOptions + * This section describes how to add AVOptions capabilities to a struct. + * + * All AVOptions-related information is stored in an AVClass. Therefore + * the first member of the struct must be a pointer to an AVClass describing it. + * The option field of the AVClass must be set to a NULL-terminated static array + * of AVOptions. Each AVOption must have a non-empty name, a type, a default + * value and for number-type AVOptions also a range of allowed values. It must + * also declare an offset in bytes from the start of the struct, where the field + * associated with this AVOption is located. Other fields in the AVOption struct + * should also be set when applicable, but are not required. + * + * The following example illustrates an AVOptions-enabled struct: + * @code + * typedef struct test_struct { + * AVClass *class; + * int int_opt; + * char *str_opt; + * uint8_t *bin_opt; + * int bin_len; + * } test_struct; + * + * static const AVOption test_options[] = { + * { "test_int", "This is a test option of int type.", offsetof(test_struct, int_opt), + * AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX }, + * { "test_str", "This is a test option of string type.", offsetof(test_struct, str_opt), + * AV_OPT_TYPE_STRING }, + * { "test_bin", "This is a test option of binary type.", offsetof(test_struct, bin_opt), + * AV_OPT_TYPE_BINARY }, + * { NULL }, + * }; + * + * static const AVClass test_class = { + * .class_name = "test class", + * .item_name = av_default_item_name, + * .option = test_options, + * .version = LIBAVUTIL_VERSION_INT, + * }; + * @endcode + * + * Next, when allocating your struct, you must ensure that the AVClass pointer + * is set to the correct value. Then, av_opt_set_defaults() must be called to + * initialize defaults. After that the struct is ready to be used with the + * AVOptions API. + * + * When cleaning up, you may use the av_opt_free() function to automatically + * free all the allocated string and binary options. + * + * Continuing with the above example: + * + * @code + * test_struct *alloc_test_struct(void) + * { + * test_struct *ret = av_malloc(sizeof(*ret)); + * ret->class = &test_class; + * av_opt_set_defaults(ret); + * return ret; + * } + * void free_test_struct(test_struct **foo) + * { + * av_opt_free(*foo); + * av_freep(foo); + * } + * @endcode + * + * @subsection avoptions_implement_nesting Nesting + * It may happen that an AVOptions-enabled struct contains another + * AVOptions-enabled struct as a member (e.g. AVCodecContext in + * libavcodec exports generic options, while its priv_data field exports + * codec-specific options). In such a case, it is possible to set up the + * parent struct to export a child's options. To do that, simply + * implement AVClass.child_next() and AVClass.child_class_next() in the + * parent struct's AVClass. + * Assuming that the test_struct from above now also contains a + * child_struct field: + * + * @code + * typedef struct child_struct { + * AVClass *class; + * int flags_opt; + * } child_struct; + * static const AVOption child_opts[] = { + * { "test_flags", "This is a test option of flags type.", + * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX }, + * { NULL }, + * }; + * static const AVClass child_class = { + * .class_name = "child class", + * .item_name = av_default_item_name, + * .option = child_opts, + * .version = LIBAVUTIL_VERSION_INT, + * }; + * + * void *child_next(void *obj, void *prev) + * { + * test_struct *t = obj; + * if (!prev && t->child_struct) + * return t->child_struct; + * return NULL + * } + * const AVClass child_class_next(const AVClass *prev) + * { + * return prev ? NULL : &child_class; + * } + * @endcode + * Putting child_next() and child_class_next() as defined above into + * test_class will now make child_struct's options accessible through + * test_struct (again, proper setup as described above needs to be done on + * child_struct right after it is created). + * + * From the above example it might not be clear why both child_next() + * and child_class_next() are needed. The distinction is that child_next() + * iterates over actually existing objects, while child_class_next() + * iterates over all possible child classes. E.g. if an AVCodecContext + * was initialized to use a codec which has private options, then its + * child_next() will return AVCodecContext.priv_data and finish + * iterating. OTOH child_class_next() on AVCodecContext.av_class will + * iterate over all available codecs with private options. + * + * @subsection avoptions_implement_named_constants Named constants + * It is possible to create named constants for options. Simply set the unit + * field of the option the constants should apply to to a string and + * create the constants themselves as options of type AV_OPT_TYPE_CONST + * with their unit field set to the same string. + * Their default_val field should contain the value of the named + * constant. + * For example, to add some named constants for the test_flags option + * above, put the following into the child_opts array: + * @code + * { "test_flags", "This is a test option of flags type.", + * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, "test_unit" }, + * { "flag1", "This is a flag with value 16", 0, AV_OPT_TYPE_CONST, { .i64 = 16 }, 0, 0, "test_unit" }, + * @endcode + * + * @section avoptions_use Using AVOptions + * This section deals with accessing options in an AVOptions-enabled struct. + * Such structs in Libav are e.g. AVCodecContext in libavcodec or + * AVFormatContext in libavformat. + * + * @subsection avoptions_use_examine Examining AVOptions + * The basic functions for examining options are av_opt_next(), which iterates + * over all options defined for one object, and av_opt_find(), which searches + * for an option with the given name. + * + * The situation is more complicated with nesting. An AVOptions-enabled struct + * may have AVOptions-enabled children. Passing the AV_OPT_SEARCH_CHILDREN flag + * to av_opt_find() will make the function search children recursively. + * + * For enumerating there are basically two cases. The first is when you want to + * get all options that may potentially exist on the struct and its children + * (e.g. when constructing documentation). In that case you should call + * av_opt_child_class_next() recursively on the parent struct's AVClass. The + * second case is when you have an already initialized struct with all its + * children and you want to get all options that can be actually written or read + * from it. In that case you should call av_opt_child_next() recursively (and + * av_opt_next() on each result). + * + * @subsection avoptions_use_get_set Reading and writing AVOptions + * When setting options, you often have a string read directly from the + * user. In such a case, simply passing it to av_opt_set() is enough. For + * non-string type options, av_opt_set() will parse the string according to the + * option type. + * + * Similarly av_opt_get() will read any option type and convert it to a string + * which will be returned. Do not forget that the string is allocated, so you + * have to free it with av_free(). + * + * In some cases it may be more convenient to put all options into an + * AVDictionary and call av_opt_set_dict() on it. A specific case of this + * are the format/codec open functions in lavf/lavc which take a dictionary + * filled with option as a parameter. This allows to set some options + * that cannot be set otherwise, since e.g. the input file format is not known + * before the file is actually opened. + */ + +enum AVOptionType{ + AV_OPT_TYPE_FLAGS, + AV_OPT_TYPE_INT, + AV_OPT_TYPE_INT64, + AV_OPT_TYPE_DOUBLE, + AV_OPT_TYPE_FLOAT, + AV_OPT_TYPE_STRING, + AV_OPT_TYPE_RATIONAL, + AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length + AV_OPT_TYPE_CONST = 128, +}; + +/** + * AVOption + */ +typedef struct AVOption { + const char *name; + + /** + * short English help text + * @todo What about other languages? + */ + const char *help; + + /** + * The offset relative to the context structure where the option + * value is stored. It should be 0 for named constants. + */ + int offset; + enum AVOptionType type; + + /** + * the default value for scalar options + */ + union { + int64_t i64; + double dbl; + const char *str; + /* TODO those are unused now */ + AVRational q; + } default_val; + double min; ///< minimum valid value for the option + double max; ///< maximum valid value for the option + + int flags; +#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding +#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding +#define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ... +#define AV_OPT_FLAG_AUDIO_PARAM 8 +#define AV_OPT_FLAG_VIDEO_PARAM 16 +#define AV_OPT_FLAG_SUBTITLE_PARAM 32 +//FIXME think about enc-audio, ... style flags + + /** + * The logical unit to which the option belongs. Non-constant + * options and corresponding named constants share the same + * unit. May be NULL. + */ + const char *unit; +} AVOption; + +/** + * Show the obj options. + * + * @param req_flags requested flags for the options to show. Show only the + * options for which it is opt->flags & req_flags. + * @param rej_flags rejected flags for the options to show. Show only the + * options for which it is !(opt->flags & req_flags). + * @param av_log_obj log context to use for showing the options + */ +int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags); + +/** + * Set the values of all AVOption fields to their default values. + * + * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass) + */ +void av_opt_set_defaults(void *s); + +/** + * Parse the key/value pairs list in opts. For each key/value pair + * found, stores the value in the field in ctx that is named like the + * key. ctx must be an AVClass context, storing is done using + * AVOptions. + * + * @param key_val_sep a 0-terminated list of characters used to + * separate key from value + * @param pairs_sep a 0-terminated list of characters used to separate + * two pairs from each other + * @return the number of successfully set key/value pairs, or a negative + * value corresponding to an AVERROR code in case of error: + * AVERROR(EINVAL) if opts cannot be parsed, + * the error code issued by av_set_string3() if a key/value pair + * cannot be set + */ +int av_set_options_string(void *ctx, const char *opts, + const char *key_val_sep, const char *pairs_sep); + +/** + * Free all string and binary options in obj. + */ +void av_opt_free(void *obj); + +/** + * Check whether a particular flag is set in a flags field. + * + * @param field_name the name of the flag field option + * @param flag_name the name of the flag to check + * @return non-zero if the flag is set, zero if the flag isn't set, + * isn't of the right type, or the flags field doesn't exist. + */ +int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name); + +/* + * Set all the options from a given dictionary on an object. + * + * @param obj a struct whose first element is a pointer to AVClass + * @param options options to process. This dictionary will be freed and replaced + * by a new one containing all options not found in obj. + * Of course this new dictionary needs to be freed by caller + * with av_dict_free(). + * + * @return 0 on success, a negative AVERROR if some option was found in obj, + * but could not be set. + * + * @see av_dict_copy() + */ +int av_opt_set_dict(void *obj, struct AVDictionary **options); + +/** + * @defgroup opt_eval_funcs Evaluating option strings + * @{ + * This group of functions can be used to evaluate option strings + * and get numbers out of them. They do the same thing as av_opt_set(), + * except the result is written into the caller-supplied pointer. + * + * @param obj a struct whose first element is a pointer to AVClass. + * @param o an option for which the string is to be evaluated. + * @param val string to be evaluated. + * @param *_out value of the string will be written here. + * + * @return 0 on success, a negative number on failure. + */ +int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out); +int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out); +int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out); +int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out); +int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out); +int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out); +/** + * @} + */ + +#define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the + given object first. */ +/** + * The obj passed to av_opt_find() is fake -- only a double pointer to AVClass + * instead of a required pointer to a struct containing AVClass. This is + * useful for searching for options without needing to allocate the corresponding + * object. + */ +#define AV_OPT_SEARCH_FAKE_OBJ 0x0002 + +/** + * Look for an option in an object. Consider only options which + * have all the specified flags set. + * + * @param[in] obj A pointer to a struct whose first element is a + * pointer to an AVClass. + * Alternatively a double pointer to an AVClass, if + * AV_OPT_SEARCH_FAKE_OBJ search flag is set. + * @param[in] name The name of the option to look for. + * @param[in] unit When searching for named constants, name of the unit + * it belongs to. + * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG). + * @param search_flags A combination of AV_OPT_SEARCH_*. + * + * @return A pointer to the option found, or NULL if no option + * was found. + * + * @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable + * directly with av_set_string3(). Use special calls which take an options + * AVDictionary (e.g. avformat_open_input()) to set options found with this + * flag. + */ +const AVOption *av_opt_find(void *obj, const char *name, const char *unit, + int opt_flags, int search_flags); + +/** + * Look for an option in an object. Consider only options which + * have all the specified flags set. + * + * @param[in] obj A pointer to a struct whose first element is a + * pointer to an AVClass. + * Alternatively a double pointer to an AVClass, if + * AV_OPT_SEARCH_FAKE_OBJ search flag is set. + * @param[in] name The name of the option to look for. + * @param[in] unit When searching for named constants, name of the unit + * it belongs to. + * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG). + * @param search_flags A combination of AV_OPT_SEARCH_*. + * @param[out] target_obj if non-NULL, an object to which the option belongs will be + * written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present + * in search_flags. This parameter is ignored if search_flags contain + * AV_OPT_SEARCH_FAKE_OBJ. + * + * @return A pointer to the option found, or NULL if no option + * was found. + */ +const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, + int opt_flags, int search_flags, void **target_obj); + +/** + * Iterate over all AVOptions belonging to obj. + * + * @param obj an AVOptions-enabled struct or a double pointer to an + * AVClass describing it. + * @param prev result of the previous call to av_opt_next() on this object + * or NULL + * @return next AVOption or NULL + */ +const AVOption *av_opt_next(void *obj, const AVOption *prev); + +/** + * Iterate over AVOptions-enabled children of obj. + * + * @param prev result of a previous call to this function or NULL + * @return next AVOptions-enabled child or NULL + */ +void *av_opt_child_next(void *obj, void *prev); + +/** + * Iterate over potential AVOptions-enabled children of parent. + * + * @param prev result of a previous call to this function or NULL + * @return AVClass corresponding to next potential child or NULL + */ +const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev); + +/** + * @defgroup opt_set_funcs Option setting functions + * @{ + * Those functions set the field of obj with the given name to value. + * + * @param[in] obj A struct whose first element is a pointer to an AVClass. + * @param[in] name the name of the field to set + * @param[in] val The value to set. In case of av_opt_set() if the field is not + * of a string type, then the given string is parsed. + * SI postfixes and some named scalars are supported. + * If the field is of a numeric type, it has to be a numeric or named + * scalar. Behavior with more than one scalar and +- infix operators + * is undefined. + * If the field is of a flags type, it has to be a sequence of numeric + * scalars or named flags separated by '+' or '-'. Prefixing a flag + * with '+' causes it to be set without affecting the other flags; + * similarly, '-' unsets a flag. + * @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN + * is passed here, then the option may be set on a child of obj. + * + * @return 0 if the value has been set, or an AVERROR code in case of + * error: + * AVERROR_OPTION_NOT_FOUND if no matching option exists + * AVERROR(ERANGE) if the value is out of range + * AVERROR(EINVAL) if the value is not valid + */ +int av_opt_set (void *obj, const char *name, const char *val, int search_flags); +int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags); +int av_opt_set_double(void *obj, const char *name, double val, int search_flags); +int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags); +int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags); +/** + * @} + */ + +/** + * @defgroup opt_get_funcs Option getting functions + * @{ + * Those functions get a value of the option with the given name from an object. + * + * @param[in] obj a struct whose first element is a pointer to an AVClass. + * @param[in] name name of the option to get. + * @param[in] search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN + * is passed here, then the option may be found in a child of obj. + * @param[out] out_val value of the option will be written here + * @return 0 on success, a negative error code otherwise + */ +/** + * @note the returned string will av_malloc()ed and must be av_free()ed by the caller + */ +int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val); +int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val); +int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val); +int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val); +/** + * @} + * @} + */ + +#endif /* AVUTIL_OPT_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/parseutils.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/parseutils.h new file mode 100644 index 000000000..0844abb2f --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/parseutils.h @@ -0,0 +1,124 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_PARSEUTILS_H +#define AVUTIL_PARSEUTILS_H + +#include + +#include "rational.h" + +/** + * @file + * misc parsing utilities + */ + +/** + * Parse str and put in width_ptr and height_ptr the detected values. + * + * @param[in,out] width_ptr pointer to the variable which will contain the detected + * width value + * @param[in,out] height_ptr pointer to the variable which will contain the detected + * height value + * @param[in] str the string to parse: it has to be a string in the format + * width x height or a valid video size abbreviation. + * @return >= 0 on success, a negative error code otherwise + */ +int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str); + +/** + * Parse str and store the detected values in *rate. + * + * @param[in,out] rate pointer to the AVRational which will contain the detected + * frame rate + * @param[in] str the string to parse: it has to be a string in the format + * rate_num / rate_den, a float number or a valid video rate abbreviation + * @return >= 0 on success, a negative error code otherwise + */ +int av_parse_video_rate(AVRational *rate, const char *str); + +/** + * Put the RGBA values that correspond to color_string in rgba_color. + * + * @param color_string a string specifying a color. It can be the name of + * a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence, + * possibly followed by "@" and a string representing the alpha + * component. + * The alpha component may be a string composed by "0x" followed by an + * hexadecimal number or a decimal number between 0.0 and 1.0, which + * represents the opacity value (0x00/0.0 means completely transparent, + * 0xff/1.0 completely opaque). + * If the alpha component is not specified then 0xff is assumed. + * The string "random" will result in a random color. + * @param slen length of the initial part of color_string containing the + * color. It can be set to -1 if color_string is a null terminated string + * containing nothing else than the color. + * @return >= 0 in case of success, a negative value in case of + * failure (for example if color_string cannot be parsed). + */ +int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, + void *log_ctx); + +/** + * Parse timestr and return in *time a corresponding number of + * microseconds. + * + * @param timeval puts here the number of microseconds corresponding + * to the string in timestr. If the string represents a duration, it + * is the number of microseconds contained in the time interval. If + * the string is a date, is the number of microseconds since 1st of + * January, 1970 up to the time of the parsed date. If timestr cannot + * be successfully parsed, set *time to INT64_MIN. + + * @param timestr a string representing a date or a duration. + * - If a date the syntax is: + * @code + * [{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH[:MM[:SS[.m...]]]}|{HH[MM[SS[.m...]]]}}[Z] + * now + * @endcode + * If the value is "now" it takes the current time. + * Time is local time unless Z is appended, in which case it is + * interpreted as UTC. + * If the year-month-day part is not specified it takes the current + * year-month-day. + * - If a duration the syntax is: + * @code + * [-]HH[:MM[:SS[.m...]]] + * [-]S+[.m...] + * @endcode + * @param duration flag which tells how to interpret timestr, if not + * zero timestr is interpreted as a duration, otherwise as a date + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code otherwise + */ +int av_parse_time(int64_t *timeval, const char *timestr, int duration); + +/** + * Attempt to find a specific tag in a URL. + * + * syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done. + * Return 1 if found. + */ +int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info); + +/** + * Convert the decomposed UTC time in tm to a time_t value. + */ +time_t av_timegm(struct tm *tm); + +#endif /* AVUTIL_PARSEUTILS_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/pixdesc.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/pixdesc.h new file mode 100644 index 000000000..b1ba03f08 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/pixdesc.h @@ -0,0 +1,276 @@ +/* + * pixel format descriptor + * Copyright (c) 2009 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_PIXDESC_H +#define AVUTIL_PIXDESC_H + +#include + +#include "attributes.h" +#include "pixfmt.h" + +typedef struct AVComponentDescriptor{ + uint16_t plane :2; ///< which of the 4 planes contains the component + + /** + * Number of elements between 2 horizontally consecutive pixels minus 1. + * Elements are bits for bitstream formats, bytes otherwise. + */ + uint16_t step_minus1 :3; + + /** + * Number of elements before the component of the first pixel plus 1. + * Elements are bits for bitstream formats, bytes otherwise. + */ + uint16_t offset_plus1 :3; + uint16_t shift :3; ///< number of least significant bits that must be shifted away to get the value + uint16_t depth_minus1 :4; ///< number of bits in the component minus 1 +}AVComponentDescriptor; + +/** + * Descriptor that unambiguously describes how the bits of a pixel are + * stored in the up to 4 data planes of an image. It also stores the + * subsampling factors and number of components. + * + * @note This is separate of the colorspace (RGB, YCbCr, YPbPr, JPEG-style YUV + * and all the YUV variants) AVPixFmtDescriptor just stores how values + * are stored not what these values represent. + */ +typedef struct AVPixFmtDescriptor{ + const char *name; + uint8_t nb_components; ///< The number of components each pixel has, (1-4) + + /** + * Amount to shift the luma width right to find the chroma width. + * For YV12 this is 1 for example. + * chroma_width = -((-luma_width) >> log2_chroma_w) + * The note above is needed to ensure rounding up. + * This value only refers to the chroma components. + */ + uint8_t log2_chroma_w; ///< chroma_width = -((-luma_width )>>log2_chroma_w) + + /** + * Amount to shift the luma height right to find the chroma height. + * For YV12 this is 1 for example. + * chroma_height= -((-luma_height) >> log2_chroma_h) + * The note above is needed to ensure rounding up. + * This value only refers to the chroma components. + */ + uint8_t log2_chroma_h; + uint8_t flags; + + /** + * Parameters that describe how pixels are packed. If the format + * has chroma components, they must be stored in comp[1] and + * comp[2]. + */ + AVComponentDescriptor comp[4]; +}AVPixFmtDescriptor; + +/** + * Pixel format is big-endian. + */ +#define AV_PIX_FMT_FLAG_BE (1 << 0) +/** + * Pixel format has a palette in data[1], values are indexes in this palette. + */ +#define AV_PIX_FMT_FLAG_PAL (1 << 1) +/** + * All values of a component are bit-wise packed end to end. + */ +#define AV_PIX_FMT_FLAG_BITSTREAM (1 << 2) +/** + * Pixel format is an HW accelerated format. + */ +#define AV_PIX_FMT_FLAG_HWACCEL (1 << 3) +/** + * At least one pixel component is not in the first data plane. + */ +#define AV_PIX_FMT_FLAG_PLANAR (1 << 4) +/** + * The pixel format contains RGB-like data (as opposed to YUV/grayscale). + */ +#define AV_PIX_FMT_FLAG_RGB (1 << 5) +/** + * The pixel format is "pseudo-paletted". This means that Libav treats it as + * paletted internally, but the palette is generated by the decoder and is not + * stored in the file. + */ +#define AV_PIX_FMT_FLAG_PSEUDOPAL (1 << 6) +/** + * The pixel format has an alpha channel. + */ +#define AV_PIX_FMT_FLAG_ALPHA (1 << 7) + +#if FF_API_PIX_FMT +/** + * @deprecate use the AV_PIX_FMT_FLAG_* flags + */ +#define PIX_FMT_BE AV_PIX_FMT_FLAG_BE +#define PIX_FMT_PAL AV_PIX_FMT_FLAG_PAL +#define PIX_FMT_BITSTREAM AV_PIX_FMT_FLAG_BITSTREAM +#define PIX_FMT_HWACCEL AV_PIX_FMT_FLAG_HWACCEL +#define PIX_FMT_PLANAR AV_PIX_FMT_FLAG_PLANAR +#define PIX_FMT_RGB AV_PIX_FMT_FLAG_RGB +#define PIX_FMT_PSEUDOPAL AV_PIX_FMT_FLAG_PSEUDOPAL +#define PIX_FMT_ALPHA AV_PIX_FMT_FLAG_ALPHA +#endif + +#if FF_API_PIX_FMT_DESC +/** + * The array of all the pixel format descriptors. + */ +extern attribute_deprecated const AVPixFmtDescriptor av_pix_fmt_descriptors[]; +#endif + +/** + * Read a line from an image, and write the values of the + * pixel format component c to dst. + * + * @param data the array containing the pointers to the planes of the image + * @param linesize the array containing the linesizes of the image + * @param desc the pixel format descriptor for the image + * @param x the horizontal coordinate of the first pixel to read + * @param y the vertical coordinate of the first pixel to read + * @param w the width of the line to read, that is the number of + * values to write to dst + * @param read_pal_component if not zero and the format is a paletted + * format writes the values corresponding to the palette + * component c in data[1] to dst, rather than the palette indexes in + * data[0]. The behavior is undefined if the format is not paletted. + */ +void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component); + +/** + * Write the values from src to the pixel format component c of an + * image line. + * + * @param src array containing the values to write + * @param data the array containing the pointers to the planes of the + * image to write into. It is supposed to be zeroed. + * @param linesize the array containing the linesizes of the image + * @param desc the pixel format descriptor for the image + * @param x the horizontal coordinate of the first pixel to write + * @param y the vertical coordinate of the first pixel to write + * @param w the width of the line to write, that is the number of + * values to write to the image line + */ +void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4], + const AVPixFmtDescriptor *desc, int x, int y, int c, int w); + +/** + * Return the pixel format corresponding to name. + * + * If there is no pixel format with name name, then looks for a + * pixel format with the name corresponding to the native endian + * format of name. + * For example in a little-endian system, first looks for "gray16", + * then for "gray16le". + * + * Finally if no pixel format has been found, returns PIX_FMT_NONE. + */ +enum AVPixelFormat av_get_pix_fmt(const char *name); + +/** + * Return the short name for a pixel format, NULL in case pix_fmt is + * unknown. + * + * @see av_get_pix_fmt(), av_get_pix_fmt_string() + */ +const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt); + +/** + * Print in buf the string corresponding to the pixel format with + * number pix_fmt, or an header if pix_fmt is negative. + * + * @param buf the buffer where to write the string + * @param buf_size the size of buf + * @param pix_fmt the number of the pixel format to print the + * corresponding info string, or a negative value to print the + * corresponding header. + */ +char *av_get_pix_fmt_string (char *buf, int buf_size, enum AVPixelFormat pix_fmt); + +/** + * Return the number of bits per pixel used by the pixel format + * described by pixdesc. Note that this is not the same as the number + * of bits per sample. + * + * The returned number of bits refers to the number of bits actually + * used for storing the pixel information, that is padding bits are + * not counted. + */ +int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc); + +/** + * @return a pixel format descriptor for provided pixel format or NULL if + * this pixel format is unknown. + */ +const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt); + +/** + * Iterate over all pixel format descriptors known to libavutil. + * + * @param prev previous descriptor. NULL to get the first descriptor. + * + * @return next descriptor or NULL after the last descriptor + */ +const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev); + +/** + * @return an AVPixelFormat id described by desc, or AV_PIX_FMT_NONE if desc + * is not a valid pointer to a pixel format descriptor. + */ +enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc); + +/** + * Utility function to access log2_chroma_w log2_chroma_h from + * the pixel format AVPixFmtDescriptor. + * + * @param[in] pix_fmt the pixel format + * @param[out] h_shift store log2_chroma_h + * @param[out] v_shift store log2_chroma_w + * + * @return 0 on success, AVERROR(ENOSYS) on invalid or unknown pixel format + */ +int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, + int *h_shift, int *v_shift); + +/** + * @return number of planes in pix_fmt, a negative AVERROR if pix_fmt is not a + * valid pixel format. + */ +int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt); + + +/** + * Utility function to swap the endianness of a pixel format. + * + * @param[in] pix_fmt the pixel format + * + * @return pixel format with swapped endianness if it exists, + * otherwise AV_PIX_FMT_NONE + */ +enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt); + + +#endif /* AVUTIL_PIXDESC_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/pixfmt.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/pixfmt.h new file mode 100644 index 000000000..77305cacd --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/pixfmt.h @@ -0,0 +1,277 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_PIXFMT_H +#define AVUTIL_PIXFMT_H + +/** + * @file + * pixel format definitions + * + */ + +#include "libavutil/avconfig.h" +#include "libavutil/version.h" + +/** + * Pixel format. + * + * @note + * PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA + * color is put together as: + * (A << 24) | (R << 16) | (G << 8) | B + * This is stored as BGRA on little-endian CPU architectures and ARGB on + * big-endian CPUs. + * + * @par + * When the pixel format is palettized RGB (PIX_FMT_PAL8), the palettized + * image data is stored in AVFrame.data[0]. The palette is transported in + * AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is + * formatted the same as in PIX_FMT_RGB32 described above (i.e., it is + * also endian-specific). Note also that the individual RGB palette + * components stored in AVFrame.data[1] should be in the range 0..255. + * This is important as many custom PAL8 video codecs that were designed + * to run on the IBM VGA graphics adapter use 6-bit palette components. + * + * @par + * For all the 8bit per pixel formats, an RGB32 palette is in data[1] like + * for pal8. This palette is filled in automatically by the function + * allocating the picture. + * + * @note + * Make sure that all newly added big-endian formats have pix_fmt & 1 == 1 + * and that all newly added little-endian formats have pix_fmt & 1 == 0. + * This allows simpler detection of big vs little-endian. + */ +enum AVPixelFormat { + AV_PIX_FMT_NONE = -1, + AV_PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) + AV_PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr + AV_PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB... + AV_PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR... + AV_PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) + AV_PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) + AV_PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) + AV_PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) + AV_PIX_FMT_GRAY8, ///< Y , 8bpp + AV_PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb + AV_PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb + AV_PIX_FMT_PAL8, ///< 8 bit with PIX_FMT_RGB32 palette + AV_PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_range + AV_PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_range + AV_PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_range + AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing + AV_PIX_FMT_XVMC_MPEG2_IDCT, + AV_PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 + AV_PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 + AV_PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) + AV_PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits + AV_PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) + AV_PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) + AV_PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits + AV_PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) + AV_PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) + AV_PIX_FMT_NV21, ///< as above, but U and V bytes are swapped + + AV_PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB... + AV_PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA... + AV_PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR... + AV_PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA... + + AV_PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian + AV_PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian + AV_PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) + AV_PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range + AV_PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) +#if FF_API_VDPAU + AV_PIX_FMT_VDPAU_H264,///< H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VDPAU_MPEG1,///< MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VDPAU_MPEG2,///< MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + AV_PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers +#endif + AV_PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian + AV_PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian + + AV_PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian + AV_PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian + AV_PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 + AV_PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 + + AV_PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian + AV_PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian + AV_PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1 + AV_PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1 + + AV_PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers + AV_PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers + AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers + + AV_PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + AV_PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + AV_PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + AV_PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + AV_PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + AV_PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian +#if FF_API_VDPAU + AV_PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers +#endif + AV_PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer + + AV_PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 + AV_PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 + AV_PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 + AV_PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 + AV_PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha + AV_PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian + AV_PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian + AV_PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + AV_PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + AV_PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian + AV_PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian + AV_PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + AV_PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + AV_PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + AV_PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + AV_PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian + AV_PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + AV_PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + AV_PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian + AV_PIX_FMT_VDA_VLD, ///< hardware decoding through VDA + AV_PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp + AV_PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big-endian + AV_PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little-endian + AV_PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big-endian + AV_PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little-endian + AV_PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big-endian + AV_PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little-endian + AV_PIX_FMT_YUVA422P, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples) + AV_PIX_FMT_YUVA444P, ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples) + AV_PIX_FMT_YUVA420P9BE, ///< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian + AV_PIX_FMT_YUVA420P9LE, ///< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian + AV_PIX_FMT_YUVA422P9BE, ///< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian + AV_PIX_FMT_YUVA422P9LE, ///< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian + AV_PIX_FMT_YUVA444P9BE, ///< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian + AV_PIX_FMT_YUVA444P9LE, ///< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian + AV_PIX_FMT_YUVA420P10BE, ///< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian) + AV_PIX_FMT_YUVA420P10LE, ///< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian) + AV_PIX_FMT_YUVA422P10BE, ///< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian) + AV_PIX_FMT_YUVA422P10LE, ///< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian) + AV_PIX_FMT_YUVA444P10BE, ///< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian) + AV_PIX_FMT_YUVA444P10LE, ///< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian) + AV_PIX_FMT_YUVA420P16BE, ///< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian) + AV_PIX_FMT_YUVA420P16LE, ///< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian) + AV_PIX_FMT_YUVA422P16BE, ///< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian) + AV_PIX_FMT_YUVA422P16LE, ///< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian) + AV_PIX_FMT_YUVA444P16BE, ///< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian) + AV_PIX_FMT_YUVA444P16LE, ///< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian) + AV_PIX_FMT_VDPAU, ///< HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface + AV_PIX_FMT_XYZ12LE, ///< packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as little-endian, the 4 lower bits are set to 0 + AV_PIX_FMT_XYZ12BE, ///< packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as big-endian, the 4 lower bits are set to 0 + AV_PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions + +#if FF_API_PIX_FMT +#include "old_pix_fmts.h" +#endif +}; + +#if AV_HAVE_BIGENDIAN +# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##be +#else +# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##le +#endif + +#define AV_PIX_FMT_RGB32 AV_PIX_FMT_NE(ARGB, BGRA) +#define AV_PIX_FMT_RGB32_1 AV_PIX_FMT_NE(RGBA, ABGR) +#define AV_PIX_FMT_BGR32 AV_PIX_FMT_NE(ABGR, RGBA) +#define AV_PIX_FMT_BGR32_1 AV_PIX_FMT_NE(BGRA, ARGB) + +#define AV_PIX_FMT_GRAY16 AV_PIX_FMT_NE(GRAY16BE, GRAY16LE) +#define AV_PIX_FMT_RGB48 AV_PIX_FMT_NE(RGB48BE, RGB48LE) +#define AV_PIX_FMT_RGB565 AV_PIX_FMT_NE(RGB565BE, RGB565LE) +#define AV_PIX_FMT_RGB555 AV_PIX_FMT_NE(RGB555BE, RGB555LE) +#define AV_PIX_FMT_RGB444 AV_PIX_FMT_NE(RGB444BE, RGB444LE) +#define AV_PIX_FMT_BGR48 AV_PIX_FMT_NE(BGR48BE, BGR48LE) +#define AV_PIX_FMT_BGR565 AV_PIX_FMT_NE(BGR565BE, BGR565LE) +#define AV_PIX_FMT_BGR555 AV_PIX_FMT_NE(BGR555BE, BGR555LE) +#define AV_PIX_FMT_BGR444 AV_PIX_FMT_NE(BGR444BE, BGR444LE) + +#define AV_PIX_FMT_YUV420P9 AV_PIX_FMT_NE(YUV420P9BE , YUV420P9LE) +#define AV_PIX_FMT_YUV422P9 AV_PIX_FMT_NE(YUV422P9BE , YUV422P9LE) +#define AV_PIX_FMT_YUV444P9 AV_PIX_FMT_NE(YUV444P9BE , YUV444P9LE) +#define AV_PIX_FMT_YUV420P10 AV_PIX_FMT_NE(YUV420P10BE, YUV420P10LE) +#define AV_PIX_FMT_YUV422P10 AV_PIX_FMT_NE(YUV422P10BE, YUV422P10LE) +#define AV_PIX_FMT_YUV444P10 AV_PIX_FMT_NE(YUV444P10BE, YUV444P10LE) +#define AV_PIX_FMT_YUV420P16 AV_PIX_FMT_NE(YUV420P16BE, YUV420P16LE) +#define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE) +#define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE) + +#define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE) +#define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE) +#define AV_PIX_FMT_GBRP16 AV_PIX_FMT_NE(GBRP16BE, GBRP16LE) + +#define AV_PIX_FMT_YUVA420P9 AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE) +#define AV_PIX_FMT_YUVA422P9 AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE) +#define AV_PIX_FMT_YUVA444P9 AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE) +#define AV_PIX_FMT_YUVA420P10 AV_PIX_FMT_NE(YUVA420P10BE, YUVA420P10LE) +#define AV_PIX_FMT_YUVA422P10 AV_PIX_FMT_NE(YUVA422P10BE, YUVA422P10LE) +#define AV_PIX_FMT_YUVA444P10 AV_PIX_FMT_NE(YUVA444P10BE, YUVA444P10LE) +#define AV_PIX_FMT_YUVA420P16 AV_PIX_FMT_NE(YUVA420P16BE, YUVA420P16LE) +#define AV_PIX_FMT_YUVA422P16 AV_PIX_FMT_NE(YUVA422P16BE, YUVA422P16LE) +#define AV_PIX_FMT_YUVA444P16 AV_PIX_FMT_NE(YUVA444P16BE, YUVA444P16LE) + +#define AV_PIX_FMT_XYZ12 AV_PIX_FMT_NE(XYZ12BE, XYZ12LE) + +#if FF_API_PIX_FMT +#define PixelFormat AVPixelFormat + +#define PIX_FMT_NE(be, le) AV_PIX_FMT_NE(be, le) + +#define PIX_FMT_RGB32 AV_PIX_FMT_RGB32 +#define PIX_FMT_RGB32_1 AV_PIX_FMT_RGB32_1 +#define PIX_FMT_BGR32 AV_PIX_FMT_BGR32 +#define PIX_FMT_BGR32_1 AV_PIX_FMT_BGR32_1 + +#define PIX_FMT_GRAY16 AV_PIX_FMT_GRAY16 +#define PIX_FMT_RGB48 AV_PIX_FMT_RGB48 +#define PIX_FMT_RGB565 AV_PIX_FMT_RGB565 +#define PIX_FMT_RGB555 AV_PIX_FMT_RGB555 +#define PIX_FMT_RGB444 AV_PIX_FMT_RGB444 +#define PIX_FMT_BGR48 AV_PIX_FMT_BGR48 +#define PIX_FMT_BGR565 AV_PIX_FMT_BGR565 +#define PIX_FMT_BGR555 AV_PIX_FMT_BGR555 +#define PIX_FMT_BGR444 AV_PIX_FMT_BGR444 + +#define PIX_FMT_YUV420P9 AV_PIX_FMT_YUV420P9 +#define PIX_FMT_YUV422P9 AV_PIX_FMT_YUV422P9 +#define PIX_FMT_YUV444P9 AV_PIX_FMT_YUV444P9 +#define PIX_FMT_YUV420P10 AV_PIX_FMT_YUV420P10 +#define PIX_FMT_YUV422P10 AV_PIX_FMT_YUV422P10 +#define PIX_FMT_YUV444P10 AV_PIX_FMT_YUV444P10 +#define PIX_FMT_YUV420P16 AV_PIX_FMT_YUV420P16 +#define PIX_FMT_YUV422P16 AV_PIX_FMT_YUV422P16 +#define PIX_FMT_YUV444P16 AV_PIX_FMT_YUV444P16 + +#define PIX_FMT_GBRP9 AV_PIX_FMT_GBRP9 +#define PIX_FMT_GBRP10 AV_PIX_FMT_GBRP10 +#define PIX_FMT_GBRP16 AV_PIX_FMT_GBRP16 +#endif + +#endif /* AVUTIL_PIXFMT_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/random_seed.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/random_seed.h new file mode 100644 index 000000000..b1fad13d0 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/random_seed.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2009 Baptiste Coudurier + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_RANDOM_SEED_H +#define AVUTIL_RANDOM_SEED_H + +#include +/** + * @addtogroup lavu_crypto + * @{ + */ + +/** + * Get random data. + * + * This function can be called repeatedly to generate more random bits + * as needed. It is generally quite slow, and usually used to seed a + * PRNG. As it uses /dev/urandom and /dev/random, the quality of the + * returned random data depends on the platform. + */ +uint32_t av_get_random_seed(void); + +/** + * @} + */ + +#endif /* AVUTIL_RANDOM_SEED_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/rational.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/rational.h new file mode 100644 index 000000000..5d7dab7fd --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/rational.h @@ -0,0 +1,155 @@ +/* + * rational numbers + * Copyright (c) 2003 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * rational numbers + * @author Michael Niedermayer + */ + +#ifndef AVUTIL_RATIONAL_H +#define AVUTIL_RATIONAL_H + +#include +#include +#include "attributes.h" + +/** + * @addtogroup lavu_math + * @{ + */ + +/** + * rational number numerator/denominator + */ +typedef struct AVRational{ + int num; ///< numerator + int den; ///< denominator +} AVRational; + +/** + * Compare two rationals. + * @param a first rational + * @param b second rational + * @return 0 if a==b, 1 if a>b, -1 if a>63)|1; + else if(b.den && a.den) return 0; + else if(a.num && b.num) return (a.num>>31) - (b.num>>31); + else return INT_MIN; +} + +/** + * Convert rational to double. + * @param a rational to convert + * @return (double) a + */ +static inline double av_q2d(AVRational a){ + return a.num / (double) a.den; +} + +/** + * Reduce a fraction. + * This is useful for framerate calculations. + * @param dst_num destination numerator + * @param dst_den destination denominator + * @param num source numerator + * @param den source denominator + * @param max the maximum allowed for dst_num & dst_den + * @return 1 if exact, 0 otherwise + */ +int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max); + +/** + * Multiply two rationals. + * @param b first rational + * @param c second rational + * @return b*c + */ +AVRational av_mul_q(AVRational b, AVRational c) av_const; + +/** + * Divide one rational by another. + * @param b first rational + * @param c second rational + * @return b/c + */ +AVRational av_div_q(AVRational b, AVRational c) av_const; + +/** + * Add two rationals. + * @param b first rational + * @param c second rational + * @return b+c + */ +AVRational av_add_q(AVRational b, AVRational c) av_const; + +/** + * Subtract one rational from another. + * @param b first rational + * @param c second rational + * @return b-c + */ +AVRational av_sub_q(AVRational b, AVRational c) av_const; + +/** + * Invert a rational. + * @param q value + * @return 1 / q + */ +static av_always_inline AVRational av_inv_q(AVRational q) +{ + AVRational r = { q.den, q.num }; + return r; +} + +/** + * Convert a double precision floating point number to a rational. + * inf is expressed as {1,0} or {-1,0} depending on the sign. + * + * @param d double to convert + * @param max the maximum allowed numerator and denominator + * @return (AVRational) d + */ +AVRational av_d2q(double d, int max) av_const; + +/** + * @return 1 if q1 is nearer to q than q2, -1 if q2 is nearer + * than q1, 0 if they have the same distance. + */ +int av_nearer_q(AVRational q, AVRational q1, AVRational q2); + +/** + * Find the nearest value in q_list to q. + * @param q_list an array of rationals terminated by {0, 0} + * @return the index of the nearest value found in the array + */ +int av_find_nearest_q_idx(AVRational q, const AVRational* q_list); + +/** + * @} + */ + +#endif /* AVUTIL_RATIONAL_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/samplefmt.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/samplefmt.h new file mode 100644 index 000000000..33cbdedf5 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/samplefmt.h @@ -0,0 +1,220 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_SAMPLEFMT_H +#define AVUTIL_SAMPLEFMT_H + +#include + +#include "avutil.h" +#include "attributes.h" + +/** + * Audio Sample Formats + * + * @par + * The data described by the sample format is always in native-endian order. + * Sample values can be expressed by native C types, hence the lack of a signed + * 24-bit sample format even though it is a common raw audio data format. + * + * @par + * The floating-point formats are based on full volume being in the range + * [-1.0, 1.0]. Any values outside this range are beyond full volume level. + * + * @par + * The data layout as used in av_samples_fill_arrays() and elsewhere in Libav + * (such as AVFrame in libavcodec) is as follows: + * + * For planar sample formats, each audio channel is in a separate data plane, + * and linesize is the buffer size, in bytes, for a single plane. All data + * planes must be the same size. For packed sample formats, only the first data + * plane is used, and samples for each channel are interleaved. In this case, + * linesize is the buffer size, in bytes, for the 1 plane. + */ +enum AVSampleFormat { + AV_SAMPLE_FMT_NONE = -1, + AV_SAMPLE_FMT_U8, ///< unsigned 8 bits + AV_SAMPLE_FMT_S16, ///< signed 16 bits + AV_SAMPLE_FMT_S32, ///< signed 32 bits + AV_SAMPLE_FMT_FLT, ///< float + AV_SAMPLE_FMT_DBL, ///< double + + AV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planar + AV_SAMPLE_FMT_S16P, ///< signed 16 bits, planar + AV_SAMPLE_FMT_S32P, ///< signed 32 bits, planar + AV_SAMPLE_FMT_FLTP, ///< float, planar + AV_SAMPLE_FMT_DBLP, ///< double, planar + + AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically +}; + +/** + * Return the name of sample_fmt, or NULL if sample_fmt is not + * recognized. + */ +const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt); + +/** + * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE + * on error. + */ +enum AVSampleFormat av_get_sample_fmt(const char *name); + +/** + * Get the packed alternative form of the given sample format. + * + * If the passed sample_fmt is already in packed format, the format returned is + * the same as the input. + * + * @return the packed alternative form of the given sample format or + AV_SAMPLE_FMT_NONE on error. + */ +enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt); + +/** + * Get the planar alternative form of the given sample format. + * + * If the passed sample_fmt is already in planar format, the format returned is + * the same as the input. + * + * @return the planar alternative form of the given sample format or + AV_SAMPLE_FMT_NONE on error. + */ +enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt); + +/** + * Generate a string corresponding to the sample format with + * sample_fmt, or a header if sample_fmt is negative. + * + * @param buf the buffer where to write the string + * @param buf_size the size of buf + * @param sample_fmt the number of the sample format to print the + * corresponding info string, or a negative value to print the + * corresponding header. + * @return the pointer to the filled buffer or NULL if sample_fmt is + * unknown or in case of other errors + */ +char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); + +/** + * Return number of bytes per sample. + * + * @param sample_fmt the sample format + * @return number of bytes per sample or zero if unknown for the given + * sample format + */ +int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt); + +/** + * Check if the sample format is planar. + * + * @param sample_fmt the sample format to inspect + * @return 1 if the sample format is planar, 0 if it is interleaved + */ +int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt); + +/** + * Get the required buffer size for the given audio parameters. + * + * @param[out] linesize calculated linesize, may be NULL + * @param nb_channels the number of channels + * @param nb_samples the number of samples in a single channel + * @param sample_fmt the sample format + * @param align buffer size alignment (0 = default, 1 = no alignment) + * @return required buffer size, or negative error code on failure + */ +int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, + enum AVSampleFormat sample_fmt, int align); + +/** + * Fill channel data pointers and linesize for samples with sample + * format sample_fmt. + * + * The pointers array is filled with the pointers to the samples data: + * for planar, set the start point of each channel's data within the buffer, + * for packed, set the start point of the entire buffer only. + * + * The linesize array is filled with the aligned size of each channel's data + * buffer for planar layout, or the aligned size of the buffer for all channels + * for packed layout. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param[out] audio_data array to be filled with the pointer for each channel + * @param[out] linesize calculated linesize, may be NULL + * @param buf the pointer to a buffer containing the samples + * @param nb_channels the number of channels + * @param nb_samples the number of samples in a single channel + * @param sample_fmt the sample format + * @param align buffer size alignment (0 = default, 1 = no alignment) + * @return 0 on success or a negative error code on failure + */ +int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, + const uint8_t *buf, + int nb_channels, int nb_samples, + enum AVSampleFormat sample_fmt, int align); + +/** + * Allocate a samples buffer for nb_samples samples, and fill data pointers and + * linesize accordingly. + * The allocated samples buffer can be freed by using av_freep(&audio_data[0]) + * Allocated data will be initialized to silence. + * + * @see enum AVSampleFormat + * The documentation for AVSampleFormat describes the data layout. + * + * @param[out] audio_data array to be filled with the pointer for each channel + * @param[out] linesize aligned size for audio buffer(s), may be NULL + * @param nb_channels number of audio channels + * @param nb_samples number of samples per channel + * @param align buffer size alignment (0 = default, 1 = no alignment) + * @return 0 on success or a negative error code on failure + * @see av_samples_fill_arrays() + */ +int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, + int nb_samples, enum AVSampleFormat sample_fmt, int align); + +/** + * Copy samples from src to dst. + * + * @param dst destination array of pointers to data planes + * @param src source array of pointers to data planes + * @param dst_offset offset in samples at which the data will be written to dst + * @param src_offset offset in samples at which the data will be read from src + * @param nb_samples number of samples to be copied + * @param nb_channels number of audio channels + * @param sample_fmt audio sample format + */ +int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset, + int src_offset, int nb_samples, int nb_channels, + enum AVSampleFormat sample_fmt); + +/** + * Fill an audio buffer with silence. + * + * @param audio_data array of pointers to data planes + * @param offset offset in samples at which to start filling + * @param nb_samples number of samples to fill + * @param nb_channels number of audio channels + * @param sample_fmt audio sample format + */ +int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, + int nb_channels, enum AVSampleFormat sample_fmt); + +#endif /* AVUTIL_SAMPLEFMT_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/sha.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/sha.h new file mode 100644 index 000000000..4c9a0c909 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/sha.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2007 Michael Niedermayer + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_SHA_H +#define AVUTIL_SHA_H + +#include + +#include "attributes.h" +#include "version.h" + +/** + * @defgroup lavu_sha SHA + * @ingroup lavu_crypto + * @{ + */ + +#if FF_API_CONTEXT_SIZE +extern attribute_deprecated const int av_sha_size; +#endif + +struct AVSHA; + +/** + * Allocate an AVSHA context. + */ +struct AVSHA *av_sha_alloc(void); + +/** + * Initialize SHA-1 or SHA-2 hashing. + * + * @param context pointer to the function context (of size av_sha_size) + * @param bits number of bits in digest (SHA-1 - 160 bits, SHA-2 224 or 256 bits) + * @return zero if initialization succeeded, -1 otherwise + */ +int av_sha_init(struct AVSHA* context, int bits); + +/** + * Update hash value. + * + * @param context hash function context + * @param data input data to update hash with + * @param len input data length + */ +void av_sha_update(struct AVSHA* context, const uint8_t* data, unsigned int len); + +/** + * Finish hashing and output digest value. + * + * @param context hash function context + * @param digest buffer where output digest value is stored + */ +void av_sha_final(struct AVSHA* context, uint8_t *digest); + +/** + * @} + */ + +#endif /* AVUTIL_SHA_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/time.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/time.h new file mode 100644 index 000000000..b01a97d77 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/time.h @@ -0,0 +1,39 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_TIME_H +#define AVUTIL_TIME_H + +#include + +/** + * Get the current time in microseconds. + */ +int64_t av_gettime(void); + +/** + * Sleep for a period of time. Although the duration is expressed in + * microseconds, the actual delay may be rounded to the precision of the + * system timer. + * + * @param usec Number of microseconds to sleep. + * @return zero on success or (negative) error code. + */ +int av_usleep(unsigned usec); + +#endif /* AVUTIL_TIME_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/version.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/version.h new file mode 100644 index 000000000..c760d8d75 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/version.h @@ -0,0 +1,96 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_VERSION_H +#define AVUTIL_VERSION_H + +#include "avutil.h" + +/** + * @file + * @ingroup lavu + * Libavutil version macros + */ + +/** + * @defgroup lavu_ver Version and Build diagnostics + * + * Macros and function useful to check at compiletime and at runtime + * which version of libavutil is in use. + * + * @{ + */ + +#define LIBAVUTIL_VERSION_MAJOR 52 +#define LIBAVUTIL_VERSION_MINOR 14 +#define LIBAVUTIL_VERSION_MICRO 0 + +#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ + LIBAVUTIL_VERSION_MINOR, \ + LIBAVUTIL_VERSION_MICRO) +#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \ + LIBAVUTIL_VERSION_MINOR, \ + LIBAVUTIL_VERSION_MICRO) +#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT + +#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) + +/** + * @} + * + * @defgroup depr_guards Deprecation guards + * FF_API_* defines may be placed below to indicate public API that will be + * dropped at a future version bump. The defines themselves are not part of + * the public API and may change, break or disappear at any time. + * + * @{ + */ + +#ifndef FF_API_PIX_FMT +#define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 53) +#endif +#ifndef FF_API_CONTEXT_SIZE +#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 53) +#endif +#ifndef FF_API_PIX_FMT_DESC +#define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 53) +#endif +#ifndef FF_API_AV_REVERSE +#define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 53) +#endif +#ifndef FF_API_AUDIOCONVERT +#define FF_API_AUDIOCONVERT (LIBAVUTIL_VERSION_MAJOR < 53) +#endif +#ifndef FF_API_CPU_FLAG_MMX2 +#define FF_API_CPU_FLAG_MMX2 (LIBAVUTIL_VERSION_MAJOR < 53) +#endif +#ifndef FF_API_LLS_PRIVATE +#define FF_API_LLS_PRIVATE (LIBAVUTIL_VERSION_MAJOR < 53) +#endif +#ifndef FF_API_AVFRAME_LAVC +#define FF_API_AVFRAME_LAVC (LIBAVUTIL_VERSION_MAJOR < 53) +#endif +#ifndef FF_API_VDPAU +#define FF_API_VDPAU (LIBAVUTIL_VERSION_MAJOR < 53) +#endif + +/** + * @} + */ + +#endif /* AVUTIL_VERSION_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/xtea.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/xtea.h new file mode 100644 index 000000000..7d2b07bbc --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libavutil/xtea.h @@ -0,0 +1,61 @@ +/* + * A 32-bit implementation of the XTEA algorithm + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_XTEA_H +#define AVUTIL_XTEA_H + +#include + +/** + * @defgroup lavu_xtea XTEA + * @ingroup lavu_crypto + * @{ + */ + +typedef struct AVXTEA { + uint32_t key[16]; +} AVXTEA; + +/** + * Initialize an AVXTEA context. + * + * @param ctx an AVXTEA context + * @param key a key of 16 bytes used for encryption/decryption + */ +void av_xtea_init(struct AVXTEA *ctx, const uint8_t key[16]); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * + * @param ctx an AVXTEA context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 8 byte blocks + * @param iv initialization vector for CBC mode, if NULL then ECB will be used + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_xtea_crypt(struct AVXTEA *ctx, uint8_t *dst, const uint8_t *src, + int count, uint8_t *iv, int decrypt); + +/** + * @} + */ + +#endif /* AVUTIL_XTEA_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libswresample/swresample.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libswresample/swresample.h new file mode 100644 index 000000000..95e8a5a09 --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libswresample/swresample.h @@ -0,0 +1,311 @@ +/* + * Copyright (C) 2011-2013 Michael Niedermayer (michaelni@gmx.at) + * + * This file is part of libswresample + * + * libswresample is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libswresample is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libswresample; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SWRESAMPLE_SWRESAMPLE_H +#define SWRESAMPLE_SWRESAMPLE_H + +/** + * @file + * @ingroup lswr + * libswresample public header + */ + +/** + * @defgroup lswr Libswresample + * @{ + * + * Libswresample (lswr) is a library that handles audio resampling, sample + * format conversion and mixing. + * + * Interaction with lswr is done through SwrContext, which is + * allocated with swr_alloc() or swr_alloc_set_opts(). It is opaque, so all parameters + * must be set with the @ref avoptions API. + * + * For example the following code will setup conversion from planar float sample + * format to interleaved signed 16-bit integer, downsampling from 48kHz to + * 44.1kHz and downmixing from 5.1 channels to stereo (using the default mixing + * matrix): + * @code + * SwrContext *swr = swr_alloc(); + * av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0); + * av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0); + * av_opt_set_int(swr, "in_sample_rate", 48000, 0); + * av_opt_set_int(swr, "out_sample_rate", 44100, 0); + * av_opt_set_sample_fmt(swr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); + * av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); + * @endcode + * + * Once all values have been set, it must be initialized with swr_init(). If + * you need to change the conversion parameters, you can change the parameters + * as described above, or by using swr_alloc_set_opts(), then call swr_init() + * again. + * + * The conversion itself is done by repeatedly calling swr_convert(). + * Note that the samples may get buffered in swr if you provide insufficient + * output space or if sample rate conversion is done, which requires "future" + * samples. Samples that do not require future input can be retrieved at any + * time by using swr_convert() (in_count can be set to 0). + * At the end of conversion the resampling buffer can be flushed by calling + * swr_convert() with NULL in and 0 in_count. + * + * The delay between input and output, can at any time be found by using + * swr_get_delay(). + * + * The following code demonstrates the conversion loop assuming the parameters + * from above and caller-defined functions get_input() and handle_output(): + * @code + * uint8_t **input; + * int in_samples; + * + * while (get_input(&input, &in_samples)) { + * uint8_t *output; + * int out_samples = av_rescale_rnd(swr_get_delay(swr, 48000) + + * in_samples, 44100, 48000, AV_ROUND_UP); + * av_samples_alloc(&output, NULL, 2, out_samples, + * AV_SAMPLE_FMT_S16, 0); + * out_samples = swr_convert(swr, &output, out_samples, + * input, in_samples); + * handle_output(output, out_samples); + * av_freep(&output); + * } + * @endcode + * + * When the conversion is finished, the conversion + * context and everything associated with it must be freed with swr_free(). + * There will be no memory leak if the data is not completely flushed before + * swr_free(). + */ + +#include +#include "libavutil/samplefmt.h" + +#include "libswresample/version.h" + +#if LIBSWRESAMPLE_VERSION_MAJOR < 1 +#define SWR_CH_MAX 32 ///< Maximum number of channels +#endif + +#define SWR_FLAG_RESAMPLE 1 ///< Force resampling even if equal sample rate +//TODO use int resample ? +//long term TODO can we enable this dynamically? + +enum SwrDitherType { + SWR_DITHER_NONE = 0, + SWR_DITHER_RECTANGULAR, + SWR_DITHER_TRIANGULAR, + SWR_DITHER_TRIANGULAR_HIGHPASS, + + SWR_DITHER_NS = 64, ///< not part of API/ABI + SWR_DITHER_NS_LIPSHITZ, + SWR_DITHER_NS_F_WEIGHTED, + SWR_DITHER_NS_MODIFIED_E_WEIGHTED, + SWR_DITHER_NS_IMPROVED_E_WEIGHTED, + SWR_DITHER_NS_SHIBATA, + SWR_DITHER_NS_LOW_SHIBATA, + SWR_DITHER_NS_HIGH_SHIBATA, + SWR_DITHER_NB, ///< not part of API/ABI +}; + +/** Resampling Engines */ +enum SwrEngine { + SWR_ENGINE_SWR, /**< SW Resampler */ + SWR_ENGINE_SOXR, /**< SoX Resampler */ + SWR_ENGINE_NB, ///< not part of API/ABI +}; + +/** Resampling Filter Types */ +enum SwrFilterType { + SWR_FILTER_TYPE_CUBIC, /**< Cubic */ + SWR_FILTER_TYPE_BLACKMAN_NUTTALL, /**< Blackman Nuttall Windowed Sinc */ + SWR_FILTER_TYPE_KAISER, /**< Kaiser Windowed Sinc */ +}; + +typedef struct SwrContext SwrContext; + +/** + * Get the AVClass for swrContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *swr_get_class(void); + +/** + * Allocate SwrContext. + * + * If you use this function you will need to set the parameters (manually or + * with swr_alloc_set_opts()) before calling swr_init(). + * + * @see swr_alloc_set_opts(), swr_init(), swr_free() + * @return NULL on error, allocated context otherwise + */ +struct SwrContext *swr_alloc(void); + +/** + * Initialize context after user parameters have been set. + * + * @return AVERROR error code in case of failure. + */ +int swr_init(struct SwrContext *s); + +/** + * Allocate SwrContext if needed and set/reset common parameters. + * + * This function does not require s to be allocated with swr_alloc(). On the + * other hand, swr_alloc() can use swr_alloc_set_opts() to set the parameters + * on the allocated context. + * + * @param s Swr context, can be NULL + * @param out_ch_layout output channel layout (AV_CH_LAYOUT_*) + * @param out_sample_fmt output sample format (AV_SAMPLE_FMT_*). + * @param out_sample_rate output sample rate (frequency in Hz) + * @param in_ch_layout input channel layout (AV_CH_LAYOUT_*) + * @param in_sample_fmt input sample format (AV_SAMPLE_FMT_*). + * @param in_sample_rate input sample rate (frequency in Hz) + * @param log_offset logging level offset + * @param log_ctx parent logging context, can be NULL + * + * @see swr_init(), swr_free() + * @return NULL on error, allocated context otherwise + */ +struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, + int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, + int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, + int log_offset, void *log_ctx); + +/** + * Free the given SwrContext and set the pointer to NULL. + */ +void swr_free(struct SwrContext **s); + +/** + * Convert audio. + * + * in and in_count can be set to 0 to flush the last few samples out at the + * end. + * + * If more input is provided than output space then the input will be buffered. + * You can avoid this buffering by providing more output space than input. + * Convertion will run directly without copying whenever possible. + * + * @param s allocated Swr context, with parameters set + * @param out output buffers, only the first one need be set in case of packed audio + * @param out_count amount of space available for output in samples per channel + * @param in input buffers, only the first one need to be set in case of packed audio + * @param in_count number of input samples available in one channel + * + * @return number of samples output per channel, negative value on error + */ +int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, + const uint8_t **in , int in_count); + +/** + * Convert the next timestamp from input to output + * timestamps are in 1/(in_sample_rate * out_sample_rate) units. + * + * @note There are 2 slightly differently behaving modes. + * First is when automatic timestamp compensation is not used, (min_compensation >= FLT_MAX) + * in this case timestamps will be passed through with delays compensated + * Second is when automatic timestamp compensation is used, (min_compensation < FLT_MAX) + * in this case the output timestamps will match output sample numbers + * + * @param pts timestamp for the next input sample, INT64_MIN if unknown + * @return the output timestamp for the next output sample + */ +int64_t swr_next_pts(struct SwrContext *s, int64_t pts); + +/** + * Activate resampling compensation. + */ +int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance); + +/** + * Set a customized input channel mapping. + * + * @param s allocated Swr context, not yet initialized + * @param channel_map customized input channel mapping (array of channel + * indexes, -1 for a muted channel) + * @return AVERROR error code in case of failure. + */ +int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map); + +/** + * Set a customized remix matrix. + * + * @param s allocated Swr context, not yet initialized + * @param matrix remix coefficients; matrix[i + stride * o] is + * the weight of input channel i in output channel o + * @param stride offset between lines of the matrix + * @return AVERROR error code in case of failure. + */ +int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride); + +/** + * Drops the specified number of output samples. + */ +int swr_drop_output(struct SwrContext *s, int count); + +/** + * Injects the specified number of silence samples. + */ +int swr_inject_silence(struct SwrContext *s, int count); + +/** + * Gets the delay the next input sample will experience relative to the next output sample. + * + * Swresample can buffer data if more input has been provided than available + * output space, also converting between sample rates needs a delay. + * This function returns the sum of all such delays. + * The exact delay is not necessarily an integer value in either input or + * output sample rate. Especially when downsampling by a large value, the + * output sample rate may be a poor choice to represent the delay, similarly + * for upsampling and the input sample rate. + * + * @param s swr context + * @param base timebase in which the returned delay will be + * if its set to 1 the returned delay is in seconds + * if its set to 1000 the returned delay is in milli seconds + * if its set to the input sample rate then the returned delay is in input samples + * if its set to the output sample rate then the returned delay is in output samples + * an exact rounding free delay can be found by using LCM(in_sample_rate, out_sample_rate) + * @returns the delay in 1/base units. + */ +int64_t swr_get_delay(struct SwrContext *s, int64_t base); + +/** + * Return the LIBSWRESAMPLE_VERSION_INT constant. + */ +unsigned swresample_version(void); + +/** + * Return the swr build-time configuration. + */ +const char *swresample_configuration(void); + +/** + * Return the swr license. + */ +const char *swresample_license(void); + +/** + * @} + */ + +#endif /* SWRESAMPLE_SWRESAMPLE_H */ diff --git a/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libswresample/version.h b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libswresample/version.h new file mode 100644 index 000000000..df9df480c --- /dev/null +++ b/make/stub_includes/libav/lavc55_lavf55_lavu52_lavr01/libswresample/version.h @@ -0,0 +1,45 @@ +/* + * Version macros. + * + * This file is part of libswresample + * + * libswresample is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * libswresample is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with libswresample; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SWR_VERSION_H +#define SWR_VERSION_H + +/** + * @file + * Libswresample version macros + */ + +#include "libavutil/avutil.h" + +#define LIBSWRESAMPLE_VERSION_MAJOR 0 +#define LIBSWRESAMPLE_VERSION_MINOR 17 +#define LIBSWRESAMPLE_VERSION_MICRO 102 + +#define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ + LIBSWRESAMPLE_VERSION_MINOR, \ + LIBSWRESAMPLE_VERSION_MICRO) +#define LIBSWRESAMPLE_VERSION AV_VERSION(LIBSWRESAMPLE_VERSION_MAJOR, \ + LIBSWRESAMPLE_VERSION_MINOR, \ + LIBSWRESAMPLE_VERSION_MICRO) +#define LIBSWRESAMPLE_BUILD LIBSWRESAMPLE_VERSION_INT + +#define LIBSWRESAMPLE_IDENT "SwR" AV_STRINGIFY(LIBSWRESAMPLE_VERSION) + +#endif /* SWR_VERSION_H */ diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 0feca9f45..7f57138a7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -197,13 +197,33 @@ public interface GLMediaPlayer extends TextureSequence { * {@link URI#getScheme() URI scheme} name {@value} for camera input. E.g. camera://0 * for the 1st camera device. *

      - * Note: the {@link URI#getHost() URI host} is being used to identify the camera: + * The {@link URI#getRawPath() URI path} is being used to identify the camera, + * where the root fwd-slash is being cut-off. + *

      + *

      + * The {@link URI#getRawQuery() URI query} is used to pass options to the camera. + *

      + *
      +     *    camera:/
      +     *    camera://somewhere/
      +     *    camera://somewhere/?width=640&height=480&rate=15
      +     * 
      *
      -     *    camera://
      +     *  URI: [scheme:][//authority][path][?query][#fragment]
      +     *  w/ authority: [user-info@]host[:port]
      +     *  Note: 'path' starts w/ fwd slash
            * 
      *

      */ public static final String CameraInputScheme = "camera"; + /** Camera property {@value}, size as string, e.g. 1280x720, hd720. May not be supported on all platforms. See {@link #CameraInputScheme}. */ + public static final String CameraPropSizeS = "size"; + /** Camera property {@value}. See {@link #CameraInputScheme}. */ + public static final String CameraPropWidth = "width"; + /** Camera property {@value}. See {@link #CameraInputScheme}. */ + public static final String CameraPropHeight = "height"; + /** Camera property {@value}. See {@link #CameraInputScheme}. */ + public static final String CameraPropRate = "rate"; /** Maximum video frame async of {@value} milliseconds. */ public static final int MAXIMUM_VIDEO_ASYNC = 22; diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 056998c0c..38faf62a6 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -254,12 +254,12 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { return; } if( null == mp && null == cam ) { - if( null == cameraHostPart ) { + if( null == cameraPath ) { mp = new MediaPlayer(); } else { int cameraId = 0; try { - cameraId = Integer.valueOf(cameraHostPart); + cameraId = Integer.valueOf(cameraPath); } catch (NumberFormatException nfe) {} if( 0 <= cameraId && cameraId < Camera.getNumberOfCameras() ) { cam = Camera.open(cameraId); diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 5286c86b8..ab0e2eebd 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -31,6 +31,7 @@ import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.Iterator; +import java.util.Map; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GL; @@ -44,6 +45,7 @@ import javax.media.opengl.GLProfile; import jogamp.opengl.Debug; +import com.jogamp.common.net.URIQueryProps; import com.jogamp.common.os.Platform; import com.jogamp.common.util.LFRingbuffer; import com.jogamp.common.util.Ringbuffer; @@ -89,10 +91,13 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected URI streamLoc = null; /** * In case {@link #streamLoc} is a {@link GLMediaPlayer#CameraInputScheme}, - * {@link #cameraHostPart} holds the URI's path portion + * {@link #cameraPath} holds the URI's path portion * as parsed in {@link #initStream(URI, int, int, int)}. + * @see #cameraProps */ - protected String cameraHostPart = null; + protected String cameraPath = null; + /** Optional camera properties, see {@link #cameraPath}. */ + protected Map cameraProps = null; protected volatile float playSpeed = 1.0f; protected float audioVolume = 1.0f; @@ -472,11 +477,19 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.streamLoc = streamLoc; // Pre-parse for camera-input scheme + cameraPath = null; + cameraProps = null; final String streamLocScheme = streamLoc.getScheme(); if( null != streamLocScheme && streamLocScheme.equals(CameraInputScheme) ) { - cameraHostPart = streamLoc.getHost(); - } else { - cameraHostPart = null; + final String rawPath = streamLoc.getRawPath(); + if( null != rawPath && rawPath.length() > 0 ) { + // cut-off root fwd-slash + cameraPath = rawPath.substring(1); + final URIQueryProps props = URIQueryProps.create(streamLoc); + cameraProps = props.getProperties(); + } else { + throw new IllegalArgumentException("Camera path is empty: "+streamLoc.toString()); + } } this.vid = vid; @@ -526,6 +539,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( STREAM_ID_NONE != vid ) { removeAllTextureFrames(gl); initGLImpl(gl); + if(DEBUG) { + System.err.println("initGLImpl.X "+this); + } videoFramesOrig = createTexFrames(gl, textureCount); videoFramesFree = new LFRingbuffer(videoFramesOrig); videoFramesDecoded = new LFRingbuffer(TextureFrame[].class, textureCount); @@ -615,13 +631,13 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final int err = gl.glGetError(); if( GL.GL_NO_ERROR != err ) { throw new RuntimeException("Couldn't create TexImage2D RGBA "+tWidth+"x"+tHeight+", target "+toHexString(textureTarget)+ - ", ifmt "+toHexString(GL.GL_RGBA)+", fmt "+toHexString(textureFormat)+", type "+toHexString(textureType)+ + ", ifmt "+toHexString(textureInternalFormat)+", fmt "+toHexString(textureFormat)+", type "+toHexString(textureType)+ ", err "+toHexString(err)); } } if(DEBUG) { System.err.println("Created TexImage2D RGBA "+tWidth+"x"+tHeight+", target "+toHexString(textureTarget)+ - ", ifmt "+toHexString(GL.GL_RGBA)+", fmt "+toHexString(textureFormat)+", type "+toHexString(textureType)); + ", ifmt "+toHexString(textureInternalFormat)+", fmt "+toHexString(textureFormat)+", type "+toHexString(textureType)); } } gl.glTexParameteri(textureTarget, GL.GL_TEXTURE_MIN_FILTER, texMinMagFilter[0]); @@ -1322,10 +1338,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final int freeVideoFrames = null != videoFramesFree ? videoFramesFree.size() : 0; final int decVideoFrames = null != videoFramesDecoded ? videoFramesDecoded.size() : 0; final int video_scr = video_scr_pts + (int) ( ( Platform.currentTimeMillis() - video_scr_t0 ) * playSpeed ); - final String camPath = null != cameraHostPart ? ", camera: "+cameraHostPart : ""; + final String camPath = null != cameraPath ? ", camera: "+cameraPath : ""; return "GLMediaPlayer["+state+", vSCR "+video_scr+", frames[p "+presentedFrameCount+", d "+decodedFrameCount+", t "+videoFrames+" ("+tt+" s)], "+ "speed "+playSpeed+", "+bps_stream+" bps, "+ - "Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+", target "+toHexString(textureTarget)+", format "+toHexString(textureFormat)+", type "+toHexString(textureType)+"], "+ + "Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+", tagt "+toHexString(textureTarget)+", ifmt "+toHexString(textureInternalFormat)+", fmt "+toHexString(textureFormat)+", type "+toHexString(textureType)+"], "+ "Video[id "+vid+", <"+vcodec+">, "+width+"x"+height+", "+fps+" fps, "+frame_duration+" fdur, "+bps_video+" bps], "+ "Audio[id "+aid+", <"+acodec+">, "+bps_audio+" bps, "+audioFrames+" frames], uri "+loc+camPath+"]"; } @@ -1394,4 +1410,15 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected static final String toHexString(int v) { return "0x"+Integer.toHexString(v); } + protected static final int getPropIntVal(Map props, String key) { + final String val = props.get(key); + try { + return Integer.valueOf(val).intValue(); + } catch (NumberFormatException nfe) { + if(DEBUG) { + System.err.println("Not a valid integer for <"+key+">: <"+val+">"); + } + } + return 0; + } } \ No newline at end of file diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java index f327cddd4..400788a24 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGDynamicLibraryBundleInfo.java @@ -32,10 +32,8 @@ import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; import javax.media.opengl.GLProfile; @@ -53,12 +51,13 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { private static final List glueLibNames = new ArrayList(); // none - private static final int symbolCount = 54; + private static final int symbolCount = 65; private static final String[] symbolNames = { - "avcodec_version", - "avformat_version", "avutil_version", -/* 4 */ "avresample_version", + "avformat_version", + "avcodec_version", + "avresample_version", +/* 5 */ "swresample_version", // libavcodec "avcodec_register_all", @@ -69,15 +68,20 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avcodec_alloc_frame", "avcodec_get_frame_defaults", "avcodec_free_frame", // 54.28.0 (opt) - "avcodec_default_get_buffer", - "avcodec_default_release_buffer", + "avcodec_default_get_buffer", // <= 54 (opt), else sp_avcodec_default_get_buffer2 + "avcodec_default_release_buffer", // <= 54 (opt), else sp_av_frame_unref + "avcodec_default_get_buffer2", // 55 (opt) + "avcodec_get_edge_width", + "av_image_fill_linesizes", + "avcodec_align_dimensions", + "avcodec_align_dimensions2", "avcodec_flush_buffers", "av_init_packet", "av_new_packet", "av_destruct_packet", "av_free_packet", "avcodec_decode_audio4", // 53.25.0 (opt) -/* 21 */ "avcodec_decode_video2", // 52.23.0 +/* 27 */ "avcodec_decode_video2", // 52.23.0 // libavutil "av_pix_fmt_descriptors", @@ -91,7 +95,7 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "av_dict_get", "av_dict_count", // 54.* (opt) "av_dict_set", -/* 33 */ "av_dict_free", +/* 28 */ "av_dict_free", // libavformat "avformat_alloc_context", @@ -108,22 +112,25 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "av_read_pause", "avformat_network_init", // 53.13.0 (opt) "avformat_network_deinit", // 53.13.0 (opt) -/* 48 */ "avformat_find_stream_info", // 53.3.0 (opt) +/* 54 */ "avformat_find_stream_info", // 53.3.0 (opt) // libavdevice -/* 49 */ "avdevice_register_all", // ??? +/* 55 */ "avdevice_register_all", // ??? // libavresample "avresample_alloc_context", // 1.0.1 "avresample_open", "avresample_close", "avresample_free", -/* 54 */ "avresample_convert" - }; - - // alternate symbol names - private static final String[][] altSymbolNames = { - // { "av_find_stream_info", "avformat_find_stream_info" }, // old, 53.3.0 +/* 60 */ "avresample_convert", + + // libavresample + "av_opt_set_sample_fmt", // actually lavu .. but exist only w/ swresample! + "swr_alloc", + "swr_init", + "swr_free", +/* 65 */ "swr_convert", + }; // optional symbol names @@ -132,8 +139,13 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avcodec_free_frame", // 54.28.0 (opt) "av_frame_unref", // 55.0.0 (opt) "av_dict_count", // 54.* (opt) + "avcodec_default_get_buffer", // <= 54 (opt), else sp_avcodec_default_get_buffer2 + "avcodec_default_release_buffer", // <= 54 (opt), else sp_av_frame_unref + "avcodec_default_get_buffer2", // 55 (opt) + // libavdevice "avdevice_register_all", // 53.0.0 (opt) + // libavresample "avresample_version", // 1.0.1 "avresample_alloc_context", // 1.0.1 @@ -141,41 +153,60 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { "avresample_close", "avresample_free", "avresample_convert", + + // libavresample + "av_opt_set_sample_fmt", // actually lavu .. but exist only w/ swresample! + "swresample_version", // 0 + "swr_alloc", + "swr_init", + "swr_free", + "swr_convert", }; private static final long[] symbolAddr = new long[symbolCount]; private static final boolean ready; - private static final boolean libsLoaded; + private static final boolean libsUFCLoaded; private static final boolean avresampleLoaded; // optional + private static final boolean swresampleLoaded; // optional private static final boolean avdeviceLoaded; // optional static final VersionNumber avCodecVersion; static final VersionNumber avFormatVersion; static final VersionNumber avUtilVersion; static final VersionNumber avResampleVersion; + static final VersionNumber swResampleVersion; private static final FFMPEGNatives natives; + private static final int LIB_IDX_UTI = 0; + private static final int LIB_IDX_FMT = 1; + private static final int LIB_IDX_COD = 2; + private static final int LIB_IDX_DEV = 3; + private static final int LIB_IDX_AVR = 4; + private static final int LIB_IDX_SWR = 5; + static { // native ffmpeg media player implementation is included in jogl_desktop and jogl_mobile GLProfile.initSingleton(); boolean _ready = false; - boolean[] _libsLoaded= { false }; - boolean[] _avdeviceLoaded= { false }; - boolean[] _avresampleLoaded= { false }; - VersionNumber[] _versions = new VersionNumber[4]; + /** util, format, codec, device, avresample, swresample */ + boolean[] _loaded= new boolean[6]; + /** util, format, codec, avresample, swresample */ + VersionNumber[] _versions = new VersionNumber[5]; try { - _ready = initSymbols(_libsLoaded, _avdeviceLoaded, _avresampleLoaded, _versions); + _ready = initSymbols(_loaded, _versions); } catch (Throwable t) { t.printStackTrace(); } - libsLoaded = _libsLoaded[0]; - avdeviceLoaded = _avdeviceLoaded[0]; - avresampleLoaded = _avresampleLoaded[0]; - avCodecVersion = _versions[0]; + libsUFCLoaded = _loaded[LIB_IDX_UTI] && _loaded[LIB_IDX_FMT] && _loaded[LIB_IDX_COD]; + avdeviceLoaded = _loaded[LIB_IDX_DEV]; + avresampleLoaded = _loaded[LIB_IDX_AVR]; + swresampleLoaded = _loaded[LIB_IDX_SWR]; + avUtilVersion = _versions[0]; avFormatVersion = _versions[1]; - avUtilVersion = _versions[2]; + avCodecVersion = _versions[2]; avResampleVersion = _versions[3]; - if(!libsLoaded) { - System.err.println("LIB_AV Not Available"); + swResampleVersion = _versions[4]; + if(!libsUFCLoaded) { + System.err.println("LIB_AV Not Available: lavu, lavc, lavu"); natives = null; ready = false; } else if(!_ready) { @@ -183,12 +214,15 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { natives = null; ready = false; } else { - if( avCodecVersion.getMajor() <= 53 && avFormatVersion.getMajor() <= 53 && avUtilVersion.getMajor() <= 51 ) { + if( avCodecVersion.getMajor() == 53 && avFormatVersion.getMajor() == 53 && avUtilVersion.getMajor() == 51 ) { // lavc53.lavf53.lavu51 natives = new FFMPEGv08Natives(); - } else if( avCodecVersion.getMajor() == 54 && avFormatVersion.getMajor() <= 54 && avUtilVersion.getMajor() <= 52 ) { + } else if( avCodecVersion.getMajor() == 54 && avFormatVersion.getMajor() == 54 && avUtilVersion.getMajor() == 52 ) { // lavc54.lavf54.lavu52.lavr01 natives = new FFMPEGv09Natives(); + } else if( avCodecVersion.getMajor() == 55 && avFormatVersion.getMajor() == 55 && avUtilVersion.getMajor() == 52 ) { + // lavc55.lavf55.lavu52.lavr01 + natives = new FFMPEGv10Natives(); } else { System.err.println("LIB_AV No Version/Native-Impl Match"); natives = null; @@ -201,29 +235,33 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { } } - static boolean libsLoaded() { return libsLoaded; } + static boolean libsLoaded() { return libsUFCLoaded; } static boolean avDeviceLoaded() { return avdeviceLoaded; } static boolean avResampleLoaded() { return avresampleLoaded; } + static boolean swResampleLoaded() { return swresampleLoaded; } static FFMPEGNatives getNatives() { return natives; } static boolean initSingleton() { return ready; } - - private static final boolean initSymbols(boolean[] libsLoaded, boolean[] avdeviceLoaded, boolean[] avresampleLoaded, - VersionNumber[] versions) { - libsLoaded[0] = false; + + /** + * @param loaded 6: util, format, codec, device, avresample, swresample + * @param versions 5: util, format, codec, avresample, swresample + * @return + */ + private static final boolean initSymbols(boolean[] loaded, VersionNumber[] versions) { + for(int i=0; i<6; i++) { + loaded[i] = false; + } final DynamicLibraryBundle dl = AccessController.doPrivileged(new PrivilegedAction() { public DynamicLibraryBundle run() { return new DynamicLibraryBundle(new FFMPEGDynamicLibraryBundleInfo()); } } ); - final boolean avutilLoaded = dl.isToolLibLoaded(0); - final boolean avformatLoaded = dl.isToolLibLoaded(1); - final boolean avcodecLoaded = dl.isToolLibLoaded(2); - if(!avutilLoaded || !avformatLoaded || !avcodecLoaded) { - throw new RuntimeException("FFMPEG Tool library incomplete: [ avutil "+avutilLoaded+", avformat "+avformatLoaded+", avcodec "+avcodecLoaded+"]"); + dl.toString(); + for(int i=0; i<6; i++) { + loaded[i] = dl.isToolLibLoaded(i); + } + if( !loaded[LIB_IDX_UTI] || !loaded[LIB_IDX_FMT] || !loaded[LIB_IDX_COD] ) { + throw new RuntimeException("FFMPEG Tool library incomplete: [ avutil "+loaded[LIB_IDX_UTI]+", avformat "+loaded[LIB_IDX_FMT]+", avcodec "+loaded[LIB_IDX_COD]+"]"); } - avdeviceLoaded[0] = dl.isToolLibLoaded(3); - avresampleLoaded[0] = dl.isToolLibLoaded(4); - libsLoaded[0] = true; - if(symbolNames.length != symbolCount) { throw new InternalError("XXX0 "+symbolNames.length+" != "+symbolCount); } @@ -232,20 +270,6 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { final Set optionalSymbolNameSet = new HashSet(); optionalSymbolNameSet.addAll(Arrays.asList(optionalSymbolNames)); - // alternate symbol name mapping to indexed array - final Map mAltSymbolNames = new HashMap(); - final int[][] iAltSymbolNames = new int[altSymbolNames.length][]; - { - final List symbolNameList = Arrays.asList(symbolNames); - for(int i=0; i() { public Object run() { @@ -262,33 +286,18 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { // no symbol, check optional and alternative symbols final String symbol = symbolNames[i]; if ( !optionalSymbolNameSet.contains(symbol) ) { - // check for API changed symbols - boolean ok = false; - final Integer cI = mAltSymbolNames.get(symbol); - if ( null != cI ) { - // check whether alternative symbol is available - final int ci = cI.intValue(); - for(int j=0; !ok && j, but has alternative <"+symbolNames[si]+">"); - } - } - } - if(!ok) { - System.err.println("Fail: Could not resolve symbol <"+symbolNames[i]+">: not optional, no alternatives."); - res = false; - } + System.err.println("Fail: Could not resolve symbol <"+symbolNames[i]+">: not optional, no alternatives."); + res = false; } else if(DEBUG) { System.err.println("OK: Unresolved optional symbol <"+symbolNames[i]+">"); } } } - versions[0] = FFMPEGStaticNatives.getAVVersion(FFMPEGStaticNatives.getAvCodecVersion0(symbolAddr[0])); - versions[1] = FFMPEGStaticNatives.getAVVersion(FFMPEGStaticNatives.getAvFormatVersion0(symbolAddr[1])); - versions[2] = FFMPEGStaticNatives.getAVVersion(FFMPEGStaticNatives.getAvUtilVersion0(symbolAddr[2])); - versions[3] = FFMPEGStaticNatives.getAVVersion(FFMPEGStaticNatives.getAvResampleVersion0(symbolAddr[3])); + versions[0] = FFMPEGStaticNatives.getAVVersion(FFMPEGStaticNatives.getAvVersion0(symbolAddr[0])); + versions[1] = FFMPEGStaticNatives.getAVVersion(FFMPEGStaticNatives.getAvVersion0(symbolAddr[1])); + versions[2] = FFMPEGStaticNatives.getAVVersion(FFMPEGStaticNatives.getAvVersion0(symbolAddr[2])); + versions[3] = FFMPEGStaticNatives.getAVVersion(FFMPEGStaticNatives.getAvVersion0(symbolAddr[3])); + versions[4] = FFMPEGStaticNatives.getAVVersion(FFMPEGStaticNatives.getAvVersion0(symbolAddr[4])); return res; } @@ -319,16 +328,18 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { public final List> getToolLibNames() { List> libsList = new ArrayList>(); + // 6: util, format, codec, device, avresample, swresample + final List avutil = new ArrayList(); avutil.add("avutil"); // default avutil.add("libavutil.so.53"); // dummy future proof - avutil.add("libavutil.so.52"); // 9 + avutil.add("libavutil.so.52"); // ffmpeg 1.2 + 2 / libav 9 + 10 avutil.add("libavutil.so.51"); // 0.8 avutil.add("libavutil.so.50"); // 0.7 avutil.add("avutil-53"); // dummy future proof - avutil.add("avutil-52"); // 9 + avutil.add("avutil-52"); // ffmpeg 1.2 + 2 / libav 9 + 10 avutil.add("avutil-51"); // 0.8 avutil.add("avutil-50"); // 0.7 libsList.add(avutil); @@ -336,51 +347,69 @@ class FFMPEGDynamicLibraryBundleInfo implements DynamicLibraryBundleInfo { final List avformat = new ArrayList(); avformat.add("avformat"); // default - avformat.add("libavformat.so.55"); // dummy future proof - avformat.add("libavformat.so.54"); // 9 + avformat.add("libavformat.so.56"); // dummy future proof + avformat.add("libavformat.so.55"); // ffmpeg 2 / libav 10 + avformat.add("libavformat.so.54"); // ffmpeg 1.2 / libav 9 avformat.add("libavformat.so.53"); // 0.8 avformat.add("libavformat.so.52"); // 0.7 - avformat.add("avformat-55"); // dummy future proof - avformat.add("avformat-54"); // 9 + avformat.add("avformat-56"); // dummy future proof + avformat.add("avformat-55"); // ffmpeg 2 / libav 10 + avformat.add("avformat-54"); // ffmpeg 1.2 / libav 9 avformat.add("avformat-53"); // 0.8 - avformat.add("avformat-52"); // 0.7 + avformat.add("avformat-52"); // 0.7 libsList.add(avformat); final List avcodec = new ArrayList(); avcodec.add("avcodec"); // default - avcodec.add("libavcodec.so.55"); // dummy future proof - avcodec.add("libavcodec.so.54"); // 9 + avcodec.add("libavcodec.so.56"); // dummy future proof + avcodec.add("libavcodec.so.55"); // ffmpeg 2/ libav 10 + avcodec.add("libavcodec.so.54"); // ffmpeg 1.2 / libav 9 avcodec.add("libavcodec.so.53"); // 0.8 avcodec.add("libavcodec.so.52"); // 0.7 - avcodec.add("avcodec-55"); // dummy future proof - avcodec.add("avcodec-54"); // 9 + avcodec.add("avcodec-56"); // dummy future proof + avcodec.add("avcodec-55"); // ffmpeg 2/ libav 10 + avcodec.add("avcodec-54"); // ffmpeg 1.2 / libav 9 avcodec.add("avcodec-53"); // 0.8 - avcodec.add("avcodec-52"); // 0.7 + avcodec.add("avcodec-52"); // 0.7 libsList.add(avcodec); final List avdevice = new ArrayList(); avdevice.add("avdevice"); // default - avdevice.add("libavdevice.so.54"); // dummy future proof - avdevice.add("libavdevice.so.53"); // 0.8 && 9 + avdevice.add("libavdevice.so.56"); // dummy future proof + avdevice.add("libavdevice.so.55"); // ffmpeg 2 + avdevice.add("libavdevice.so.54"); // ffmpeg 1.2 / libav 10 + avdevice.add("libavdevice.so.53"); // 0.8 && libav 9 - avdevice.add("avdevice-54"); // dummy future proof - avdevice.add("avdevice-53"); // 0.8 && 9 + avdevice.add("avdevice-56"); // dummy future proof + avdevice.add("avdevice-55"); // ffmpeg 2 + avdevice.add("avdevice-54"); // ffmpeg 1.2 / libav 10 + avdevice.add("avdevice-53"); // 0.8 && libav 9 libsList.add(avdevice); final List avresample = new ArrayList(); avresample.add("avresample"); // default avresample.add("libavresample.so.2"); // dummy future proof - avresample.add("libavresample.so.1"); // 9 + avresample.add("libavresample.so.1"); // libav 9 + 10 avresample.add("avresample-2"); // dummy future proof - avresample.add("avresample-1"); // 9 + avresample.add("avresample-1"); // libav 9 + 10 libsList.add(avresample); + final List swresample = new ArrayList(); + swresample.add("swresample"); // default + + swresample.add("libswresample.so.1"); // dummy future proof + swresample.add("libswresample.so.0"); // ffmpeg 1.2 + 2.x + + swresample.add("swresample-1"); // dummy future proof + swresample.add("swresample-0"); // ffmpeg 1.2 + 2.x + libsList.add(swresample); + return libsList; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 2dd60074c..269500399 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -55,7 +55,7 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; /*** * Implementation utilizes Libav - * or FFmpeg which is ubiquitous + * or FFmpeg which are ubiquitous * available and usually pre-installed on Unix platforms. *

      * Due to legal reasons we cannot deploy binaries of it, which contains patented codecs. @@ -83,6 +83,7 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; *

    • {@link PixelFormat#YUV422P}
    • *
    • {@link PixelFormat#YUVJ422P}
    • *
    • {@link PixelFormat#YUYV422}
    • + *
    • {@link PixelFormat#BGR24}
    • * *

      *

      @@ -104,9 +105,10 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; *

      * Currently we are binary compatible w/: * - * - * - * + * + * + * + * *
      releaselavclavflavulavr FFMPEG* class
      0.8 535351 FFMPEGv08
      9.0 54545201 FFMPEGv09
      libav / ffmpeglavclavflavulavr FFMPEG* class
      0.8 53 53 51 FFMPEGv08
      9.0 / 1.2 54 54 52 01/00 FFMPEGv09
      10 / 2 55 55 52 01/00 FFMPEGv10
      *

      *

      @@ -122,14 +124,19 @@ import jogamp.opengl.util.av.impl.FFMPEGNatives.SampleFormat; *

      TODO:
      *

      *

        - *
      • better pts sync handling
      • + *
      • better audio synchronization handling? (video is synchronized)
      • *
      *

      * - *
      LibAV Availability
      + *
      FFMPEG / LibAV Availability
      *

      *

        - *
      • Windows: http://win32.libav.org/releases/
      • + *
      • GNU/Linux: ffmpeg or libav are deployed in most distributions.
      • + *
      • Windows: + *
          + *
        • http://ffmpeg.zeranoe.com/builds/ (ffmpeg)
        • + *
        • http://win32.libav.org/releases/ (libav)
        • + *
      • *
      • MacOSX: http://ffmpegmac.net/
      • *
      • OpenIndiana/Solaris:
          *       pkg set-publisher -p http://pkg.openindiana.org/sfe-encumbered.
        @@ -148,7 +155,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
             private static final int avUtilMajorVersionCC;
             private static final int avFormatMajorVersionCC;
             private static final int avCodecMajorVersionCC;    
        -    private static final int avResampleMajorVersionCC;    
        +    private static final int avResampleMajorVersionCC;
        +    private static final int swResampleMajorVersionCC;
             private static final boolean available;
             
             static {
        @@ -156,24 +164,38 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                 final boolean libAVVersionGood;
                 if( FFMPEGDynamicLibraryBundleInfo.libsLoaded() ) {
                     natives = FFMPEGDynamicLibraryBundleInfo.getNatives();
        -            avCodecMajorVersionCC = natives.getAvCodecMajorVersionCC0();
        -            avFormatMajorVersionCC = natives.getAvFormatMajorVersionCC0();
        -            avUtilMajorVersionCC = natives.getAvUtilMajorVersionCC0();
        -            avResampleMajorVersionCC = natives.getAvResampleMajorVersionCC0();
        +            if( null != natives ) {
        +                avCodecMajorVersionCC = natives.getAvCodecMajorVersionCC0();
        +                avFormatMajorVersionCC = natives.getAvFormatMajorVersionCC0();
        +                avUtilMajorVersionCC = natives.getAvUtilMajorVersionCC0();
        +                avResampleMajorVersionCC = natives.getAvResampleMajorVersionCC0();
        +                swResampleMajorVersionCC = natives.getSwResampleMajorVersionCC0();
        +            } else {            
        +                avUtilMajorVersionCC = 0;
        +                avFormatMajorVersionCC = 0;
        +                avCodecMajorVersionCC = 0;
        +                avResampleMajorVersionCC = 0;
        +                swResampleMajorVersionCC = 0;
        +            }
                     final VersionNumber avCodecVersion = FFMPEGDynamicLibraryBundleInfo.avCodecVersion;
                     final VersionNumber avFormatVersion = FFMPEGDynamicLibraryBundleInfo.avFormatVersion;
                     final VersionNumber avUtilVersion = FFMPEGDynamicLibraryBundleInfo.avUtilVersion;
        -            final VersionNumber avResampleVersion = FFMPEGDynamicLibraryBundleInfo.avResampleVersion;            
        +            final VersionNumber avResampleVersion = FFMPEGDynamicLibraryBundleInfo.avResampleVersion;
        +            final boolean avResampleLoaded = FFMPEGDynamicLibraryBundleInfo.avResampleLoaded();
        +            final VersionNumber swResampleVersion = FFMPEGDynamicLibraryBundleInfo.swResampleVersion;
        +            final boolean swResampleLoaded = FFMPEGDynamicLibraryBundleInfo.swResampleLoaded();
                     System.err.println("LIB_AV Codec   : "+avCodecVersion+" [cc "+avCodecMajorVersionCC+"]");
                     System.err.println("LIB_AV Format  : "+avFormatVersion+" [cc "+avFormatMajorVersionCC+"]");
                     System.err.println("LIB_AV Util    : "+avUtilVersion+" [cc "+avUtilMajorVersionCC+"]");
        -            System.err.println("LIB_AV Resample: "+FFMPEGDynamicLibraryBundleInfo.avResampleVersion+" [cc "+avResampleMajorVersionCC+", loaded "+FFMPEGDynamicLibraryBundleInfo.avResampleLoaded()+"]");
        +            System.err.println("LIB_AV Resample: "+avResampleVersion+" [cc "+avResampleMajorVersionCC+", loaded "+avResampleLoaded+"]");
        +            System.err.println("LIB_SW Resample: "+swResampleVersion+" [cc "+swResampleMajorVersionCC+", loaded "+swResampleLoaded+"]");
                     System.err.println("LIB_AV Device  : [loaded "+FFMPEGDynamicLibraryBundleInfo.avDeviceLoaded()+"]");
        -            System.err.println("LIB_AV Class   : "+natives.getClass().getSimpleName());
        +            System.err.println("LIB_AV Class   : "+(null!= natives ? natives.getClass().getSimpleName() : "n/a"));
                     libAVVersionGood = avCodecMajorVersionCC  == avCodecVersion.getMajor() &&
                                        avFormatMajorVersionCC == avFormatVersion.getMajor() &&
                                        avUtilMajorVersionCC   == avUtilVersion.getMajor() &&
        -                               avResampleMajorVersionCC  == avResampleVersion.getMajor();
        +                               ( !avResampleLoaded || avResampleMajorVersionCC  == avResampleVersion.getMajor() ) &&
        +                               ( !swResampleLoaded || swResampleMajorVersionCC  == swResampleVersion.getMajor() ) ;
                     if( !libAVVersionGood ) {
                         System.err.println("LIB_AV Not Matching Compile-Time / Runtime Major-Version");
                     }
        @@ -183,6 +205,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                     avFormatMajorVersionCC = 0;
                     avCodecMajorVersionCC = 0;
                     avResampleMajorVersionCC = 0;
        +            swResampleMajorVersionCC = 0;
                     libAVVersionGood = false;
                 }
                 available = libAVGood && libAVVersionGood && null != natives ? natives.initIDs0() : false;
        @@ -268,8 +291,10 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                     System.err.println("initStream: p2 preferred "+preferredAudioFormat+", "+this);
                 }
                 
        -        final boolean isCameraInput = null != cameraHostPart;
        +        final boolean isCameraInput = null != cameraPath;
                 final String resStreamLocS;
        +        int rw=640, rh=480, rr=15;
        +        String sizes = null;
                 if( isCameraInput ) {
                     switch(Platform.OS_TYPE) {
                         case ANDROID:
        @@ -278,10 +303,10 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                         case HPUX:
                         case LINUX:
                         case SUNOS:
        -                    resStreamLocS = dev_video_linux + cameraHostPart;
        +                    resStreamLocS = dev_video_linux + cameraPath;
                             break;
                         case WINDOWS:
        -                    resStreamLocS = cameraHostPart;
        +                    resStreamLocS = cameraPath;
                             break;
                         case MACOS:
                         case OPENKODE:
        @@ -289,13 +314,22 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                             resStreamLocS = streamLocS; // FIXME: ??
                             break;            
                     }
        +            if( null != cameraProps ) {
        +                sizes = cameraProps.get(CameraPropSizeS);
        +                int v = getPropIntVal(cameraProps, CameraPropWidth);
        +                if( v > 0 ) { rw = v; }
        +                v = getPropIntVal(cameraProps, CameraPropHeight);
        +                if( v > 0 ) { rh = v; }
        +                v = getPropIntVal(cameraProps, CameraPropRate);
        +                if( v > 0 ) { rr = v; }
        +            }
                 } else {
                     resStreamLocS = streamLocS;
                 }
                 final int aMaxChannelCount = audioSink.getMaxSupportedChannels();
                 final int aPrefSampleRate = preferredAudioFormat.sampleRate;
                  // setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc
        -        natives.setStream0(moviePtr, resStreamLocS, isCameraInput, vid, aid, aMaxChannelCount, aPrefSampleRate);
        +        natives.setStream0(moviePtr, resStreamLocS, isCameraInput, vid, sizes, rw, rh, rr, aid, aMaxChannelCount, aPrefSampleRate);
             }
         
             @Override
        @@ -373,11 +407,19 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                                     tf = GL2ES2.GL_RG;   tif=GL2ES2.GL_RG; break;
                                 }
                         case 3: tf = GL2ES2.GL_RGB;   tif=GL.GL_RGB;   break;
        -                case 4: tf = GL2ES2.GL_RGBA;  tif=GL.GL_RGBA;  break;
        +                case 4: if( vPixelFmt == PixelFormat.BGRA ) {
        +                            tf = GL2ES2.GL_BGRA;  tif=GL.GL_RGBA;  break;
        +                        } else {
        +                            tf = GL2ES2.GL_RGBA;  tif=GL.GL_RGBA;  break;
        +                        }                    
                         default: throw new RuntimeException("Unsupported bytes-per-pixel / plane "+vBytesPerPixelPerPlane);
                     }        
                     setTextureFormat(tif, tf);
                     setTextureType(tt);
        +            if(DEBUG) {
        +                System.err.println("initGL: p5: video "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane+
        +                                   ", tex "+texWidth+"x"+texHeight+", usesTexLookupShader "+usesTexLookupShader);
        +            }
                 }
             }    
             @Override
        @@ -470,9 +512,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
              * @param planes
              * @param bitsPerPixel
              * @param bytesPerPixelPerPlane
        -     * @param lSz0
        -     * @param lSz1
        -     * @param lSz2
              * @param tWd0
              * @param tWd1
              * @param tWd2
        @@ -483,7 +522,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
              * @param audioSamplesPerFrameAndChannel in audio samples per frame and channel
              */
             void updateAttributes2(int vid, int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane,
        -                           int lSz0, int lSz1, int lSz2,
                                    int tWd0, int tWd1, int tWd2, int vW, int vH,
                                    int aid, int audioSampleFmt, int audioSampleRate, 
                                    int audioChannels, int audioSamplesPerFrameAndChannel) {
        @@ -495,7 +533,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                 usesTexLookupShader = false;
                 texWidth = 0; texHeight = 0;
                 
        -        final int[] vLinesize = { 0, 0, 0 }; // per plane
                 final int[] vTexWidth = { 0, 0, 0 }; // per plane
                 
                 if( STREAM_ID_NONE != vid ) {
        @@ -503,7 +540,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                     vPlanes = planes;
                     vBitsPerPixel = bitsPerPixel;
                     vBytesPerPixelPerPlane = bytesPerPixelPerPlane;                        
        -            vLinesize[0] = lSz0; vLinesize[1] = lSz1; vLinesize[2] = lSz2;
                     vTexWidth[0] = tWd0; vTexWidth[1] = tWd1; vTexWidth[2] = tWd2;
                     
                     switch(vPixelFmt) {
        @@ -533,11 +569,12 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                             texWidth = vTexWidth[0] + vTexWidth[1] + vTexWidth[2]; texHeight = vH;
                             break;
                         case YUYV422: // < packed YUV 4:2:2, 2x 16bpp, Y0 Cb Y1 Cr - stuffed into RGBA half width texture
        +                case BGR24:
                             usesTexLookupShader = true;
                             texWidth = vTexWidth[0]; texHeight = vH; 
                             break;
        +                    
                         case RGB24:
        -                case BGR24:
                         case ARGB:
                         case RGBA:
                         case ABGR:
        @@ -567,9 +604,10 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                     System.err.println("audio: id "+aid+", fmt "+aSampleFmt+", "+avChosenAudioFormat+", aFrameSize/fc "+audioSamplesPerFrameAndChannel);
                     System.err.println("video: id "+vid+", fmt "+vW+"x"+vH+", "+vPixelFmt+", planes "+vPlanes+", bpp "+vBitsPerPixel+"/"+vBytesPerPixelPerPlane+", usesTexLookupShader "+usesTexLookupShader);
                     for(int i=0; i<3; i++) {
        -                System.err.println("video: "+i+": "+vTexWidth[i]+"/"+vLinesize[i]);
        +                System.err.println("video: p["+i+"]: "+vTexWidth[i]);
                     }
                     System.err.println("video: total tex "+texWidth+"x"+texHeight);
        +            System.err.println(this.toString());
                 }
             }
             
        @@ -674,6 +712,15 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl {
                       "  return vec4(r, g, b, 1);\n"+
                       "}\n"
                   ;
        +        case BGR24:
        +          return
        +              "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+
        +              "  "+
        +              "  vec3 bgr = texture2D(image, texCoord).rgb;\n"+
        +              "  return vec4(bgr.b, bgr.g, bgr.r, 1);\n"+ /* just swizzle */
        +              "}\n"
        +          ;
        +
                 default: // FIXME: Add more formats !
                   throw new InternalError("Add proper mapping of: vPixelFmt "+vPixelFmt+", usesTexLookupShader "+usesTexLookupShader);
               }        
        diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java
        index 3ee87b5da..b919f22c7 100644
        --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java
        +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java
        @@ -27,7 +27,6 @@
          */
         package jogamp.opengl.util.av.impl;
         
        -import com.jogamp.opengl.util.av.AudioSink;
         import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame;
         
         interface FFMPEGNatives {
        @@ -37,6 +36,7 @@ interface FFMPEGNatives {
             int getAvFormatMajorVersionCC0();
             int getAvCodecMajorVersionCC0();
             int getAvResampleMajorVersionCC0();
        +    int getSwResampleMajorVersionCC0();
             boolean initIDs0();
             
             long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose);
        @@ -45,21 +45,22 @@ interface FFMPEGNatives {
             /**
              * Issues {@link #updateAttributes(int, int, int, int, int, int, int, float, int, int, String, String)}
              * and {@link #updateAttributes2(int, int, int, int, int, int, int, int, int, int)}.
        -     * 

        - * Always uses {@link AudioSink.AudioFormat}: - *

        -     *   [type PCM, sampleRate [10000(?)..44100..48000], sampleSize 16, channelCount 1-2, signed, littleEndian]
        -     * 
        - *

        * * @param moviePtr * @param url * @param vid + * @param sizes requested video size as string, i.e. 'hd720'. May be null to favor vWidth and vHeight. + * @param vWidth requested video width (for camera mode) + * @param vHeight requested video width (for camera mode) + * @param vRate requested video framerate (for camera mode) * @param aid - * @param aPrefChannelCount * @param aPrefSampleRate + * @param aPrefChannelCount */ - void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, int aid, int aMaxChannelCount, int aPrefSampleRate); + void setStream0(long moviePtr, String url, boolean isCameraInput, + int vid, String sizes, int vWidth, int vHeight, + int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); + void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); int getVideoPTS0(long moviePtr); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGStaticNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGStaticNatives.java index 9ee0198f4..16ee2dd4b 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGStaticNatives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGStaticNatives.java @@ -35,8 +35,5 @@ class FFMPEGStaticNatives { ( vers >> 8 ) & 0xFF, ( vers >> 0 ) & 0xFF ); } - static native int getAvUtilVersion0(long func); - static native int getAvFormatVersion0(long func); - static native int getAvCodecVersion0(long func); - static native int getAvResampleVersion0(long func); + static native int getAvVersion0(long func); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java index 3b2567655..2a0c9dc3d 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java @@ -43,6 +43,9 @@ class FFMPEGv08Natives implements FFMPEGNatives { @Override public native int getAvResampleMajorVersionCC0(); + @Override + public native int getSwResampleMajorVersionCC0(); + @Override public native boolean initIDs0(); @@ -53,7 +56,7 @@ class FFMPEGv08Natives implements FFMPEGNatives { public native void destroyInstance0(long moviePtr); @Override - public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, int aid, int aMaxChannelCount, int aPrefSampleRate); + public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); @Override public native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java index 6c56d3ccb..422f1ceb0 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java @@ -43,6 +43,9 @@ class FFMPEGv09Natives implements FFMPEGNatives { @Override public native int getAvResampleMajorVersionCC0(); + @Override + public native int getSwResampleMajorVersionCC0(); + @Override public native boolean initIDs0(); @@ -53,7 +56,7 @@ class FFMPEGv09Natives implements FFMPEGNatives { public native void destroyInstance0(long moviePtr); @Override - public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, int aid, int aMaxChannelCount, int aPrefSampleRate); + public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); @Override public native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java new file mode 100644 index 000000000..e3007ab69 --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java @@ -0,0 +1,81 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.opengl.util.av.impl; + +class FFMPEGv10Natives implements FFMPEGNatives { + @Override + public native boolean initSymbols0(long[] symbols, int count); + + @Override + public native int getAvUtilMajorVersionCC0(); + + @Override + public native int getAvFormatMajorVersionCC0(); + + @Override + public native int getAvCodecMajorVersionCC0(); + + @Override + public native int getAvResampleMajorVersionCC0(); + + @Override + public native int getSwResampleMajorVersionCC0(); + + @Override + public native boolean initIDs0(); + + @Override + public native long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose); + + @Override + public native void destroyInstance0(long moviePtr); + + @Override + public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); + + @Override + public native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); + + @Override + public native int getVideoPTS0(long moviePtr); + + @Override + public native int getAudioPTS0(long moviePtr); + + @Override + public native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); + + @Override + public native int play0(long moviePtr); + + @Override + public native int pause0(long moviePtr); + + @Override + public native int seek0(long moviePtr, int position); +} diff --git a/src/jogl/native/libav/ffmpeg_dshow.c b/src/jogl/native/libav/ffmpeg_dshow.c new file mode 100644 index 000000000..4f8fedb9f --- /dev/null +++ b/src/jogl/native/libav/ffmpeg_dshow.c @@ -0,0 +1,209 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#include "ffmpeg_dshow.h" + +#ifdef _WIN32 + +#include +#include +#include +#include + +static HRESULT EnumerateDevices(REFGUID category, IEnumMoniker **ppEnum) +{ + // Create the System Device Enumerator. + ICreateDevEnum *pDevEnum; + void *pv = NULL; + + HRESULT hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, &IID_ICreateDevEnum, (void**)&pDevEnum); + + if (SUCCEEDED(hr)) { + // Create an enumerator for the category. + hr = pDevEnum->lpVtbl->CreateClassEnumerator(pDevEnum, category, ppEnum,0); + if (hr == S_FALSE) + { + hr = VFW_E_NOT_FOUND; // The category is empty. Treat as an error. + } + pDevEnum->lpVtbl->Release(pDevEnum); + } + return hr; +} + +static void getBSTRChars(BSTR bstr, char *pDest, int destLen) { + + #ifdef UNICODE + _sntprintf(pDest, destLen, _T("%s"), bstr); + #else + _sntprintf(pDest, destLen, _T("%S"), bstr); + #endif +} + + +static int GetDeviceInformation(IEnumMoniker *pEnum, int verbose, int devIdx, + char *pDescr, int descrSize, + char *pName, int nameSize, + char *pPath, int pathSize, int *pWaveID) { + IMoniker *pMoniker = NULL; + int i=0; + int res = devIdx >= 0 ? -1 : 0; + + if( NULL != pDescr ) { + *pDescr=0; + } + if( NULL != pName ) { + *pName=0; + } + if( NULL != pPath ) { + *pPath=0; + } + if( NULL != pWaveID ) { + *pWaveID=0; + } + + while (pEnum->lpVtbl->Next(pEnum, 1, &pMoniker, NULL) == S_OK) { + IPropertyBag *pPropBag; + HRESULT hr; + + hr = pMoniker->lpVtbl->BindToStorage(pMoniker, 0, 0, &IID_IPropertyBag, (void**)&pPropBag); + if (FAILED(hr)) { + if( verbose ) { + fprintf(stderr, "DShowParser: Dev[%d]: bind failed ...\n", i); + } + pMoniker->lpVtbl->Release(pMoniker); + continue; + } + VARIANT var; + VariantInit(&var); + + // Get description or friendly name. + hr = pPropBag->lpVtbl->Read(pPropBag, L"Description", &var, 0); + if (SUCCEEDED(hr)) { + if( i == devIdx && NULL != pDescr ) { + res = 0; + getBSTRChars(var.bstrVal, pDescr, descrSize); + } + if( verbose ) { + fprintf(stderr, "DShowParser: Dev[%d]: Descr %S\n", i, var.bstrVal); + } + VariantClear(&var); + } else if( verbose ) { + fprintf(stderr, "DShowParser: Dev[%d]: cannot read Descr..\n", i); + } + + hr = pPropBag->lpVtbl->Read(pPropBag, L"FriendlyName", &var, 0); + if (SUCCEEDED(hr)) { + if( i == devIdx && NULL != pName ) { + res = 0; + getBSTRChars(var.bstrVal, pName, nameSize); + } + if( verbose ) { + fprintf(stderr, "DShowParser: Dev[%d]: FName %S\n", i, var.bstrVal); + } + VariantClear(&var); + } else if( verbose ) { + fprintf(stderr, "DShowParser: Dev[%d]: cannot read FName..\n", i); + } + + hr = pPropBag->lpVtbl->Write(pPropBag, L"FriendlyName", &var); + + // WaveInID applies only to audio capture devices. + hr = pPropBag->lpVtbl->Read(pPropBag, L"WaveInID", &var, 0); + if (SUCCEEDED(hr)) { + if( i == devIdx && NULL != pWaveID ) { + res = 0; + *pWaveID=(int)var.lVal; + } + if( verbose ) { + fprintf(stderr, "DShowParser: Dev[%d]: WaveInID %d\n", i, var.lVal); + } + VariantClear(&var); + } + + hr = pPropBag->lpVtbl->Read(pPropBag, L"DevicePath", &var, 0); + if (SUCCEEDED(hr)) { + if( i == devIdx && NULL != pPath ) { + res = 0; + getBSTRChars(var.bstrVal, pPath, pathSize); + } + if( verbose ) { + fprintf(stderr, "DShowParser: Dev[%d]: Path %S\n", i, var.bstrVal); + } + VariantClear(&var); + } + + pPropBag->lpVtbl->Release(pPropBag); + pMoniker->lpVtbl->Release(pMoniker); + + if( devIdx >= 0 && i == devIdx ) { + break; // done! + } + i++; + } + return res; +} + +int findDShowVideoDevice(char * dest, int destSize, int devIdx, int verbose) { + int res = -1; + + HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); + if (SUCCEEDED(hr)) { + IEnumMoniker *pEnum; + + hr = EnumerateDevices(&CLSID_VideoInputDeviceCategory, &pEnum); + if (SUCCEEDED(hr)) { + res = GetDeviceInformation(pEnum, verbose, devIdx, NULL /* pDescr */, 0, dest, destSize, NULL /* pPath */, 0, NULL /* pWaveID */); + pEnum->lpVtbl->Release(pEnum); + if( verbose ) { + fprintf(stderr, "DShowParser: Get VideoInputDevice: res %d, '%s'\n", res, dest); + } + } else if( verbose ) { + fprintf(stderr, "DShowParser: Get VideoInputDevice failed\n"); + } + /** + hr = EnumerateDevices(&CLSID_AudioInputDeviceCategory, &pEnum); + if (SUCCEEDED(hr)) { + res = GetDeviceInformation(pEnum, verbose, devIdx, NULL, 0, NULL, 0, NULL, 0, NULL); + pEnum->lpVtbl->Release(pEnum); + } else if( verbose ) { + fprintf(stderr, "DShowParser: Get AudioInputDevice failed\n"); + } */ + CoUninitialize(); + } else if( verbose ) { + fprintf(stderr, "DShowParser: CoInit failed\n"); + } + return res; +} + +#else + +int findDShowVideoDevice(char * dest, int destSize, int devIdx, int verbose) { + return -1; +} + +#endif diff --git a/src/jogl/native/libav/ffmpeg_dshow.h b/src/jogl/native/libav/ffmpeg_dshow.h new file mode 100644 index 000000000..e4ef7096b --- /dev/null +++ b/src/jogl/native/libav/ffmpeg_dshow.h @@ -0,0 +1,47 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#ifndef _FFMPEG_TOOL_H +#define _FFMPEG_TOOL_H + +#ifdef _WIN32 + +#include + +#endif // _WIN32 + +#include +#include +#include +#include + +extern int findDShowVideoDevice(char * dest, int destSize, int devIdx, int verbose); + + +#endif // _FFMPEG_TOOL_H + diff --git a/src/jogl/native/libav/ffmpeg_impl_template.c b/src/jogl/native/libav/ffmpeg_impl_template.c index 822007136..9f371a720 100644 --- a/src/jogl/native/libav/ffmpeg_impl_template.c +++ b/src/jogl/native/libav/ffmpeg_impl_template.c @@ -30,6 +30,7 @@ #include "JoglCommon.h" #include "ffmpeg_tool.h" +#include "ffmpeg_dshow.h" #include "libavutil/pixdesc.h" #include "libavutil/samplefmt.h" @@ -50,28 +51,35 @@ static jmethodID jni_mid_isAudioFormatSupported = NULL; #define HAS_FUNC(f) (NULL!=(f)) -typedef unsigned (APIENTRYP AVCODEC_VERSION)(void); typedef unsigned (APIENTRYP AVUTIL_VERSION)(void); typedef unsigned (APIENTRYP AVFORMAT_VERSION)(void); +typedef unsigned (APIENTRYP AVCODEC_VERSION)(void); typedef unsigned (APIENTRYP AVRESAMPLE_VERSION)(void); +typedef unsigned (APIENTRYP SWRESAMPLE_VERSION)(void); -static AVCODEC_VERSION sp_avcodec_version; -static AVFORMAT_VERSION sp_avformat_version; static AVUTIL_VERSION sp_avutil_version; +static AVFORMAT_VERSION sp_avformat_version; +static AVCODEC_VERSION sp_avcodec_version; static AVRESAMPLE_VERSION sp_avresample_version; -// count: 4 +static SWRESAMPLE_VERSION sp_swresample_version; +// count: 5 // libavcodec typedef int (APIENTRYP AVCODEC_REGISTER_ALL)(void); typedef int (APIENTRYP AVCODEC_CLOSE)(AVCodecContext *avctx); typedef void (APIENTRYP AVCODEC_STRING)(char *buf, int buf_size, AVCodecContext *enc, int encode); -typedef AVCodec *(APIENTRYP AVCODEC_FIND_DECODER)(enum CodecID id); +typedef AVCodec *(APIENTRYP AVCODEC_FIND_DECODER)(int avCodecID); // lavc 53: 'enum CodecID id', lavc 54: 'enum AVCodecID id' typedef int (APIENTRYP AVCODEC_OPEN2)(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options); // 53.6.0 typedef AVFrame *(APIENTRYP AVCODEC_ALLOC_FRAME)(void); typedef void (APIENTRYP AVCODEC_GET_FRAME_DEFAULTS)(AVFrame *frame); typedef void (APIENTRYP AVCODEC_FREE_FRAME)(AVFrame **frame); -typedef int (APIENTRYP AVCODEC_DEFAULT_GET_BUFFER)(AVCodecContext *s, AVFrame *pic); -typedef void (APIENTRYP AVCODEC_DEFAULT_RELEASE_BUFFER)(AVCodecContext *s, AVFrame *pic); +typedef int (APIENTRYP AVCODEC_DEFAULT_GET_BUFFER)(AVCodecContext *s, AVFrame *pic); // <= 54 (opt), else AVCODEC_DEFAULT_GET_BUFFER2 +typedef void (APIENTRYP AVCODEC_DEFAULT_RELEASE_BUFFER)(AVCodecContext *s, AVFrame *pic); // <= 54 (opt), else AV_FRAME_UNREF +typedef int (APIENTRYP AVCODEC_DEFAULT_GET_BUFFER2)(AVCodecContext *s, AVFrame *frame, int flags); // 55. (opt) +typedef int (APIENTRYP AVCODEC_GET_EDGE_WIDTH)(); +typedef int (APIENTRYP AV_IMAGE_FILL_LINESIZES)(int linesizes[4], int pix_fmt, int width); // lavu 51: 'enum PixelFormat pix_fmt', lavu 53: 'enum AVPixelFormat pix_fmt' +typedef void (APIENTRYP AVCODEC_ALIGN_DIMENSIONS)(AVCodecContext *s, int *width, int *height); +typedef void (APIENTRYP AVCODEC_ALIGN_DIMENSIONS2)(AVCodecContext *s, int *width, int *height, int linesize_align[AV_NUM_DATA_POINTERS]); typedef void (APIENTRYP AVCODEC_FLUSH_BUFFERS)(AVCodecContext *avctx); typedef void (APIENTRYP AV_INIT_PACKET)(AVPacket *pkt); typedef int (APIENTRYP AV_NEW_PACKET)(AVPacket *pkt, int size); @@ -88,8 +96,13 @@ static AVCODEC_OPEN2 sp_avcodec_open2; // 53.6.0 static AVCODEC_ALLOC_FRAME sp_avcodec_alloc_frame; static AVCODEC_GET_FRAME_DEFAULTS sp_avcodec_get_frame_defaults; static AVCODEC_FREE_FRAME sp_avcodec_free_frame; -static AVCODEC_DEFAULT_GET_BUFFER sp_avcodec_default_get_buffer; -static AVCODEC_DEFAULT_RELEASE_BUFFER sp_avcodec_default_release_buffer; +static AVCODEC_DEFAULT_GET_BUFFER sp_avcodec_default_get_buffer; // <= 54 (opt), else sp_avcodec_default_get_buffer2 +static AVCODEC_DEFAULT_RELEASE_BUFFER sp_avcodec_default_release_buffer; // <= 54 (opt), else sp_av_frame_unref +static AVCODEC_DEFAULT_GET_BUFFER2 sp_avcodec_default_get_buffer2; // 55. (opt) +static AVCODEC_GET_EDGE_WIDTH sp_avcodec_get_edge_width; +static AV_IMAGE_FILL_LINESIZES sp_av_image_fill_linesizes; +static AVCODEC_ALIGN_DIMENSIONS sp_avcodec_align_dimensions; +static AVCODEC_ALIGN_DIMENSIONS2 sp_avcodec_align_dimensions2; static AVCODEC_FLUSH_BUFFERS sp_avcodec_flush_buffers; static AV_INIT_PACKET sp_av_init_packet; static AV_NEW_PACKET sp_av_new_packet; @@ -97,7 +110,7 @@ static AV_DESTRUCT_PACKET sp_av_destruct_packet; static AV_FREE_PACKET sp_av_free_packet; static AVCODEC_DECODE_AUDIO4 sp_avcodec_decode_audio4; // 53.25.0 static AVCODEC_DECODE_VIDEO2 sp_avcodec_decode_video2; // 52.23.0 -// count: 21 +// count: 27 // libavutil typedef void (APIENTRYP AV_FRAME_UNREF)(AVFrame *frame); @@ -108,7 +121,7 @@ typedef int (APIENTRYP AV_SAMPLES_GET_BUFFER_SIZE)(int *linesize, int nb_channel typedef int (APIENTRYP AV_GET_BYTES_PER_SAMPLE)(enum AVSampleFormat sample_fmt); typedef int (APIENTRYP AV_OPT_SET_INT)(void *obj, const char *name, int64_t val, int search_flags); typedef AVDictionaryEntry* (APIENTRYP AV_DICT_GET)(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); -typedef int (APIENTRYP AV_DICT_COUNT)(AVDictionary **m); +typedef int (APIENTRYP AV_DICT_COUNT)(AVDictionary *m); typedef int (APIENTRYP AV_DICT_SET)(AVDictionary **pm, const char *key, const char *value, int flags); typedef void (APIENTRYP AV_DICT_FREE)(AVDictionary **m); @@ -124,7 +137,7 @@ static AV_DICT_GET sp_av_dict_get; static AV_DICT_COUNT sp_av_dict_count; static AV_DICT_SET sp_av_dict_set; static AV_DICT_FREE sp_av_dict_free; -// count: 33 +// count: 39 // libavformat typedef AVFormatContext *(APIENTRYP AVFORMAT_ALLOC_CONTEXT)(void); @@ -158,12 +171,12 @@ static AV_READ_PAUSE sp_av_read_pause; static AVFORMAT_NETWORK_INIT sp_avformat_network_init; // 53.13.0 static AVFORMAT_NETWORK_DEINIT sp_avformat_network_deinit; // 53.13.0 static AVFORMAT_FIND_STREAM_INFO sp_avformat_find_stream_info; // 53.3.0 -// count: 48 +// count: 54 // libavdevice [53.0.0] typedef int (APIENTRYP AVDEVICE_REGISTER_ALL)(void); static AVDEVICE_REGISTER_ALL sp_avdevice_register_all; -// count: 49 +// count: 55 // libavresample [1.0.1] typedef AVAudioResampleContext* (APIENTRYP AVRESAMPLE_ALLOC_CONTEXT)(void); // 1.0.1 @@ -178,9 +191,23 @@ static AVRESAMPLE_OPEN sp_avresample_open; static AVRESAMPLE_CLOSE sp_avresample_close; static AVRESAMPLE_FREE sp_avresample_free; static AVRESAMPLE_CONVERT sp_avresample_convert; -// count: 54 +// count: 60 + +// libswresample [1...] +typedef int (APIENTRYP AV_OPT_SET_SAMPLE_FMT)(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags); // actually lavu .. but exist only w/ swresample! +typedef struct SwrContext *(APIENTRYP SWR_ALLOC)(void); +typedef int (APIENTRYP SWR_INIT)(struct SwrContext *s); +typedef void (APIENTRYP SWR_FREE)(struct SwrContext **s); +typedef int (APIENTRYP SWR_CONVERT)(struct SwrContext *s, uint8_t **out, int out_count, const uint8_t **in , int in_count); -#define SYMBOL_COUNT 54 +static AV_OPT_SET_SAMPLE_FMT sp_av_opt_set_sample_fmt; +static SWR_ALLOC sp_swr_alloc; +static SWR_INIT sp_swr_init; +static SWR_FREE sp_swr_free; +static SWR_CONVERT sp_swr_convert; +// count: 65 + +#define SYMBOL_COUNT 65 JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) (JNIEnv *env, jobject instance, jobject jSymbols, jint count) @@ -198,10 +225,11 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) i = 0; symbols = (int64_t *) (*env)->GetPrimitiveArrayCritical(env, jSymbols, NULL); - sp_avcodec_version = (AVCODEC_VERSION) (intptr_t) symbols[i++]; - sp_avformat_version = (AVFORMAT_VERSION) (intptr_t) symbols[i++]; sp_avutil_version = (AVUTIL_VERSION) (intptr_t) symbols[i++]; + sp_avformat_version = (AVFORMAT_VERSION) (intptr_t) symbols[i++]; + sp_avcodec_version = (AVCODEC_VERSION) (intptr_t) symbols[i++]; sp_avresample_version = (AVRESAMPLE_VERSION) (intptr_t) symbols[i++]; + sp_swresample_version = (SWRESAMPLE_VERSION) (intptr_t) symbols[i++]; sp_avcodec_register_all = (AVCODEC_REGISTER_ALL) (intptr_t) symbols[i++]; sp_avcodec_close = (AVCODEC_CLOSE) (intptr_t) symbols[i++]; @@ -213,6 +241,11 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) sp_avcodec_free_frame = (AVCODEC_FREE_FRAME) (intptr_t) symbols[i++]; sp_avcodec_default_get_buffer = (AVCODEC_DEFAULT_GET_BUFFER) (intptr_t) symbols[i++]; sp_avcodec_default_release_buffer = (AVCODEC_DEFAULT_RELEASE_BUFFER) (intptr_t) symbols[i++]; + sp_avcodec_default_get_buffer2 = (AVCODEC_DEFAULT_GET_BUFFER2) (intptr_t) symbols[i++]; + sp_avcodec_get_edge_width = (AVCODEC_GET_EDGE_WIDTH) (intptr_t) symbols[i++]; + sp_av_image_fill_linesizes = (AV_IMAGE_FILL_LINESIZES) (intptr_t) symbols[i++]; + sp_avcodec_align_dimensions = (AVCODEC_ALIGN_DIMENSIONS) (intptr_t) symbols[i++]; + sp_avcodec_align_dimensions2 = (AVCODEC_ALIGN_DIMENSIONS2) (intptr_t) symbols[i++]; sp_avcodec_flush_buffers = (AVCODEC_FLUSH_BUFFERS) (intptr_t) symbols[i++]; sp_av_init_packet = (AV_INIT_PACKET) (intptr_t) symbols[i++]; sp_av_new_packet = (AV_NEW_PACKET) (intptr_t) symbols[i++]; @@ -258,6 +291,12 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) sp_avresample_free = (AVRESAMPLE_FREE) (intptr_t) symbols[i++]; sp_avresample_convert = (AVRESAMPLE_CONVERT) (intptr_t) symbols[i++]; + sp_av_opt_set_sample_fmt = (AV_OPT_SET_SAMPLE_FMT) (intptr_t) symbols[i++]; + sp_swr_alloc = (SWR_ALLOC) (intptr_t) symbols[i++]; + sp_swr_init = (SWR_INIT) (intptr_t) symbols[i++]; + sp_swr_free = (SWR_FREE) (intptr_t) symbols[i++]; + sp_swr_convert = (SWR_CONVERT) (intptr_t) symbols[i++]; + (*env)->ReleasePrimitiveArrayCritical(env, jSymbols, symbols, 0); if(SYMBOL_COUNT != i) { @@ -282,7 +321,6 @@ static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasic (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_updateAttributes2, pAV->vid, pAV->vPixFmt, pAV->vBufferPlanes, pAV->vBitsPerPixel, pAV->vBytesPerPixelPerPlane, - pAV->vLinesize[0], pAV->vLinesize[1], pAV->vLinesize[2], pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2], pAV->vWidth, pAV->vHeight, pAV->aid, pAV->aSampleFmtOut, pAV->aSampleRateOut, pAV->aChannelsOut, pAV->aFrameSize); @@ -300,9 +338,13 @@ static void freeInstance(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { int i; if(NULL != pAV) { // Close the A resampler - if( NULL != pAV->aResampleCtx ) { - sp_avresample_free(&pAV->aResampleCtx); - pAV->aResampleCtx = NULL; + if( NULL != pAV->avResampleCtx ) { + sp_avresample_free(&pAV->avResampleCtx); + pAV->avResampleCtx = NULL; + } + if( NULL != pAV->swResampleCtx ) { + sp_swr_free(&pAV->swResampleCtx); + pAV->swResampleCtx = NULL; } if( NULL != pAV->aResampleBuffer ) { sp_av_free(pAV->aResampleBuffer); @@ -430,9 +472,15 @@ JNIEXPORT jint JNICALL FF_FUNC(getAvResampleMajorVersionCC0) return (jint) LIBAVRESAMPLE_VERSION_MAJOR; } +JNIEXPORT jint JNICALL FF_FUNC(getSwResampleMajorVersionCC0) + (JNIEnv *env, jobject instance) { + return (jint) LIBSWRESAMPLE_VERSION_MAJOR; +} + JNIEXPORT jboolean JNICALL FF_FUNC(initIDs0) (JNIEnv *env, jobject instance) { + jboolean res = JNI_TRUE; JoglCommon_init(env); jclass c; @@ -452,7 +500,7 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initIDs0) jni_mid_pushSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "pushSound", "(Ljava/nio/ByteBuffer;II)V"); jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIIIFIIILjava/lang/String;Ljava/lang/String;)V"); - jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIIIIIII)V"); + jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIIII)V"); jni_mid_isAudioFormatSupported = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "isAudioFormatSupported", "(III)Z"); if(jni_mid_pushSound == NULL || @@ -461,7 +509,22 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initIDs0) jni_mid_isAudioFormatSupported == NULL) { return JNI_FALSE; } - return JNI_TRUE; + #if LIBAVCODEC_VERSION_MAJOR >= 55 + if(!HAS_FUNC(sp_avcodec_default_get_buffer2) || + !HAS_FUNC(sp_av_frame_unref) ) { + fprintf(stderr, "avcodec >= 55: avcodec_default_get_buffer2 %p, av_frame_unref %p\n", + sp_avcodec_default_get_buffer2, sp_av_frame_unref); + res = JNI_FALSE; + } + #else + if(!HAS_FUNC(sp_avcodec_default_get_buffer) || + !HAS_FUNC(sp_avcodec_default_release_buffer)) { + fprintf(stderr, "avcodec < 55: avcodec_default_get_buffer %p, sp_avcodec_default_release_buffer %p\n", + sp_avcodec_default_get_buffer2, sp_avcodec_default_release_buffer); + res = JNI_FALSE; + } + #endif + return res; } JNIEXPORT jlong JNICALL FF_FUNC(createInstance0) @@ -480,6 +543,11 @@ JNIEXPORT jlong JNICALL FF_FUNC(createInstance0) } else { pAV->avresampleVersion = 0; } + if(HAS_FUNC(sp_swresample_version)) { + pAV->swresampleVersion = sp_swresample_version(); + } else { + pAV->swresampleVersion = 0; + } #if LIBAVCODEC_VERSION_MAJOR >= 55 // TODO: We keep code on using 1 a/v frame per decoding cycle now. @@ -496,6 +564,10 @@ JNIEXPORT jlong JNICALL FF_FUNC(createInstance0) pAV->vid=AV_STREAM_ID_AUTO; pAV->aid=AV_STREAM_ID_AUTO; + if(pAV->verbose) { + fprintf(stderr, "Info: Use avresample %d, swresample %d, device %d, refCount %d\n", + AV_HAS_API_AVRESAMPLE(pAV), AV_HAS_API_SWRESAMPLE(pAV), HAS_FUNC(sp_avdevice_register_all), pAV->useRefCountedFrames); + } return (jlong) (intptr_t) pAV; } @@ -529,7 +601,7 @@ static int64_t evalPTS(PTSStats *ptsStats, int64_t inPTS, int64_t inDTS); static AVInputFormat* tryAVInputFormat(const char * name, int verbose) { AVInputFormat* inFmt = sp_av_find_input_format(name); if( verbose) { - if ( inFmt == NULL ) { + if ( NULL == inFmt ) { fprintf(stderr, "Warning: Could not find input format '%s'\n", name); } else { fprintf(stderr, "Info: Found input format '%s'\n", name); @@ -565,10 +637,41 @@ static AVInputFormat* findAVInputFormat(int verbose) { return inFmt; } +#if 0 +static void getAlignedLinesizes(AVCodecContext *avctx, int linesize[/*4*/]) { + int stride_align[AV_NUM_DATA_POINTERS]; + int w = avctx->width; + int h = avctx->height; + int unaligned; + int i; + + sp_avcodec_align_dimensions2(avctx, &w, &h, stride_align); + + if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) { + int edge_width = sp_avcodec_get_edge_width(); + w += edge_width * 2; + h += edge_width * 2; + } + + do { + // Get alignment for all planes (-> YUVP .. etc) + sp_av_image_fill_linesizes(linesize, avctx->pix_fmt, w); + // increase alignment of w for next try (rhs gives the lowest bit set in w) + w += w & ~(w - 1); + + unaligned = 0; + for (i = 0; i < 4; i++) + unaligned |= linesize[i] % stride_align[i]; + } while (unaligned); +} +#endif + JNIEXPORT void JNICALL FF_FUNC(setStream0) - (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jboolean jIsCameraInput, jint vid, jint aid, - jint aMaxChannelCount, jint aPrefSampleRate) + (JNIEnv *env, jobject instance, jlong ptr, jstring jURL, jboolean jIsCameraInput, + jint vid, jstring jSizeS, jint vWidth, jint vHeight, jint vRate, + jint aid, jint aMaxChannelCount, jint aPrefSampleRate) { + char cameraName[256]; int res, i; jboolean iscopy; FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)(intptr_t)ptr; @@ -592,31 +695,59 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->pFormatCtx = sp_avformat_alloc_context(); const char *urlPath = (*env)->GetStringUTFChars(env, jURL, &iscopy); + const char *filename = urlPath; // allow changing path for camera .. // Open video file AVDictionary *inOpts = NULL; AVInputFormat* inFmt = NULL; if( jIsCameraInput ) { + char buffer[256]; inFmt = findAVInputFormat(pAV->verbose); if( NULL == inFmt ) { JoglCommon_throwNewRuntimeException(env, "Couldn't find input format for camera: %s", urlPath); (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); return; } - // set maximum values, driver shall 'degrade' .. - // sp_av_dict_set(&inOpts, "video_size", "640x480", 0); - // sp_av_dict_set(&inOpts, "video_size", "1280x720", 0); - sp_av_dict_set(&inOpts, "video_size", "hd720", 0); // video4linux, vfwcap, .. - // sp_av_dict_set(&inOpts, "video_size", "1280x1024", 0); - // sp_av_dict_set(&inOpts, "video_size", "320x240", 0); - sp_av_dict_set(&inOpts, "framerate", "60", 0); // not setting a framerate causes some drivers to crash! + if(pAV->verbose) { + fprintf(stderr, "Camera: Format: %s (%s)\n", inFmt->long_name, inFmt->name); + } + if( 0 == strncmp(inFmt->name, "dshow", 255) ) { + int devIdx = atoi(urlPath); + strncpy(cameraName, "video=", sizeof(cameraName)); + res = findDShowVideoDevice(cameraName+6, sizeof(cameraName)-6, devIdx, pAV->verbose); + if( 0 == res ) { + if(pAV->verbose) { + fprintf(stderr, "Camera %d found: %s\n", devIdx, cameraName); + } + filename = cameraName; + } else if(pAV->verbose) { + fprintf(stderr, "Camera %d not found\n", devIdx); + } + } + + const char *sizeS = NULL != jSizeS ? (*env)->GetStringUTFChars(env, jSizeS, &iscopy) : NULL; + if( NULL != sizeS ) { + snprintf(buffer, sizeof(buffer), "%s", sizeS); + (*env)->ReleaseStringChars(env, jSizeS, (const jchar *)sizeS); + } else { + snprintf(buffer, sizeof(buffer), "%dx%d", vWidth, vHeight); + } + if(pAV->verbose) { + fprintf(stderr, "Camera: Size: %s\n", buffer); + } + sp_av_dict_set(&inOpts, "video_size", buffer, 0); + snprintf(buffer, sizeof(buffer), "%d", vRate); + if(pAV->verbose) { + fprintf(stderr, "Camera: FPS: %s\n", buffer); + } + sp_av_dict_set(&inOpts, "framerate", buffer, 0); // not setting a framerate causes some drivers to crash! } - res = sp_avformat_open_input(&pAV->pFormatCtx, urlPath, inFmt, NULL != inOpts ? &inOpts : NULL); + res = sp_avformat_open_input(&pAV->pFormatCtx, filename, inFmt, NULL != inOpts ? &inOpts : NULL); if( NULL != inOpts ) { sp_av_dict_free(&inOpts); } if(res != 0) { - JoglCommon_throwNewRuntimeException(env, "Couldn't open URI: %s, err %d", urlPath, res); + JoglCommon_throwNewRuntimeException(env, "Couldn't open URI: %s [%dx%d @ %d hz], err %d", filename, vWidth, vHeight, vRate, res); (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); return; } @@ -630,9 +761,11 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) if(pAV->verbose) { // Dump information about file onto standard error - sp_av_dump_format(pAV->pFormatCtx, 0, urlPath, JNI_FALSE); + sp_av_dump_format(pAV->pFormatCtx, 0, filename, JNI_FALSE); } (*env)->ReleaseStringChars(env, jURL, (const jchar *)urlPath); + + // FIXME: Libav Binary compatibility! JAU01 if (pAV->pFormatCtx->duration != AV_NOPTS_VALUE) { pAV->duration = pAV->pFormatCtx->duration / AV_TIME_BASE_MSEC; @@ -707,9 +840,10 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->pACodecCtx->request_sample_fmt=AV_SAMPLE_FMT_S16; if( 1 <= aMaxChannelCount && aMaxChannelCount <= 2 ) { pAV->pACodecCtx->request_channel_layout=getDefaultAudioChannelLayout(aMaxChannelCount); - if( AV_HAS_API_REQUEST_CHANNELS(pAV) ) { + #if LIBAVCODEC_VERSION_MAJOR < 54 + /** Until 55.0.0, but stopped working w/ 54 already :( */ pAV->pACodecCtx->request_channels=aMaxChannelCount; - } + #endif } pAV->pACodecCtx->skip_frame=AVDISCARD_DEFAULT; @@ -745,12 +879,23 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->frames_audio = pAV->pAStream->nb_frames; pAV->aSinkSupport = _isAudioFormatSupported(env, pAV->ffmpegMediaPlayer, pAV->aSampleFmt, pAV->aSampleRate, pAV->aChannels); if( pAV->verbose ) { - fprintf(stderr, "A channels %d [l %d], sample_rate %d, frame_size %d, frame_number %d, r_frame_rate %f, avg_frame_rate %f, nb_frames %d, [maxChan %d, prefRate %d, req_chan_layout %d, req_chan %d], sink-support %d \n", + fprintf(stderr, "A channels %d [l %d], sample_rate %d, frame_size %d, frame_number %d, [afps %f, rfps %f, cfps %f, sfps %f], nb_frames %d, [maxChan %d, prefRate %d, req_chan_layout %d, req_chan %d], sink-support %d \n", pAV->aChannels, pAV->pACodecCtx->channel_layout, pAV->aSampleRate, pAV->aFrameSize, pAV->pACodecCtx->frame_number, - my_av_q2f(pAV->pAStream->r_frame_rate), my_av_q2f(pAV->pAStream->avg_frame_rate), + #if LIBAVCODEC_VERSION_MAJOR < 55 + my_av_q2f(pAV->pVStream->r_frame_rate), + #else + 0.0f, + #endif + my_av_q2f_r(pAV->pAStream->codec->time_base), + my_av_q2f_r(pAV->pAStream->time_base), pAV->pAStream->nb_frames, - aMaxChannelCount, aPrefSampleRate, pAV->pACodecCtx->request_channel_layout, pAV->pACodecCtx->request_channels, + aMaxChannelCount, aPrefSampleRate, pAV->pACodecCtx->request_channel_layout, + #if LIBAVCODEC_VERSION_MAJOR < 54 + pAV->pACodecCtx->request_channels, + #else + 0, + #endif pAV->aSinkSupport); } @@ -759,11 +904,11 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->aChannelsOut = pAV->aChannels; pAV->aSampleRateOut = pAV->aSampleRate; - if( AV_HAS_API_AVRESAMPLE(pAV) && + if( ( AV_HAS_API_AVRESAMPLE(pAV) || AV_HAS_API_SWRESAMPLE(pAV) ) && ( pAV->aSampleFmt != AV_SAMPLE_FMT_S16 || - ( 0 != aPrefSampleRate && pAV->aSampleRate != aPrefSampleRate ) || - !pAV->aSinkSupport ) - ) { + ( 0 != aPrefSampleRate && pAV->aSampleRate != aPrefSampleRate ) || + !pAV->aSinkSupport ) ) { + if( 0 == aPrefSampleRate ) { aPrefSampleRate = pAV->aSampleRate; } @@ -782,25 +927,48 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) aSampleRateOut = aPrefSampleRate; aSinkSupport = 1; } + if( aSinkSupport ) { - pAV->aResampleCtx = sp_avresample_alloc_context(); - sp_av_opt_set_int(pAV->aResampleCtx, "in_channel_layout", pAV->pACodecCtx->channel_layout, 0); - sp_av_opt_set_int(pAV->aResampleCtx, "out_channel_layout", getDefaultAudioChannelLayout(aChannelsOut), 0); - sp_av_opt_set_int(pAV->aResampleCtx, "in_sample_rate", pAV->aSampleRate, 0); - sp_av_opt_set_int(pAV->aResampleCtx, "out_sample_rate", aSampleRateOut, 0); - sp_av_opt_set_int(pAV->aResampleCtx, "in_sample_fmt", pAV->aSampleFmt, 0); - sp_av_opt_set_int(pAV->aResampleCtx, "out_sample_fmt", aSampleFmtOut, 0); - - if ( sp_avresample_open(pAV->aResampleCtx) < 0 ) { - sp_avresample_free(&pAV->aResampleCtx); - pAV->aResampleCtx = NULL; - fprintf(stderr, "error initializing libavresample\n"); - } else { - // OK - pAV->aSampleFmtOut = aSampleFmtOut; - pAV->aChannelsOut = aChannelsOut; - pAV->aSampleRateOut = aSampleRateOut; - pAV->aSinkSupport = 1; + if( AV_HAS_API_AVRESAMPLE(pAV) ) { + pAV->avResampleCtx = sp_avresample_alloc_context(); + sp_av_opt_set_int(pAV->avResampleCtx, "in_channel_layout", pAV->pACodecCtx->channel_layout, 0); + sp_av_opt_set_int(pAV->avResampleCtx, "out_channel_layout", getDefaultAudioChannelLayout(aChannelsOut), 0); + sp_av_opt_set_int(pAV->avResampleCtx, "in_sample_rate", pAV->aSampleRate, 0); + sp_av_opt_set_int(pAV->avResampleCtx, "out_sample_rate", aSampleRateOut, 0); + sp_av_opt_set_int(pAV->avResampleCtx, "in_sample_fmt", pAV->aSampleFmt, 0); + sp_av_opt_set_int(pAV->avResampleCtx, "out_sample_fmt", aSampleFmtOut, 0); + + if ( sp_avresample_open(pAV->avResampleCtx) < 0 ) { + sp_avresample_free(&pAV->avResampleCtx); + pAV->avResampleCtx = NULL; + fprintf(stderr, "error initializing avresample ctx\n"); + } else { + // OK + pAV->aSampleFmtOut = aSampleFmtOut; + pAV->aChannelsOut = aChannelsOut; + pAV->aSampleRateOut = aSampleRateOut; + pAV->aSinkSupport = 1; + } + } else if( AV_HAS_API_SWRESAMPLE(pAV) ) { + pAV->swResampleCtx = sp_swr_alloc(); + sp_av_opt_set_int(pAV->swResampleCtx, "in_channel_layout", pAV->pACodecCtx->channel_layout, 0); + sp_av_opt_set_int(pAV->swResampleCtx, "out_channel_layout", getDefaultAudioChannelLayout(aChannelsOut), 0); + sp_av_opt_set_int(pAV->swResampleCtx, "in_sample_rate", pAV->aSampleRate, 0); + sp_av_opt_set_int(pAV->swResampleCtx, "out_sample_rate", aSampleRateOut, 0); + sp_av_opt_set_sample_fmt(pAV->swResampleCtx, "in_sample_fmt", pAV->aSampleFmt, 0); + sp_av_opt_set_sample_fmt(pAV->swResampleCtx, "out_sample_fmt", aSampleFmtOut, 0); + + if ( sp_swr_init(pAV->swResampleCtx) < 0 ) { + sp_swr_free(&pAV->swResampleCtx); + pAV->swResampleCtx = NULL; + fprintf(stderr, "error initializing swresample ctx\n"); + } else { + // OK + pAV->aSampleFmtOut = aSampleFmtOut; + pAV->aChannelsOut = aChannelsOut; + pAV->aSampleRateOut = aSampleRateOut; + pAV->aSinkSupport = 1; + } } } } @@ -867,10 +1035,18 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->pVCodecCtx->time_base.den=1000; } // FIXME: Libav Binary compatibility! JAU01 - if( 0 < pAV->pVStream->avg_frame_rate.den ) { + if( pAV->pVStream->avg_frame_rate.den && pAV->pVStream->avg_frame_rate.num ) { pAV->fps = my_av_q2f(pAV->pVStream->avg_frame_rate); - } else { + #if LIBAVCODEC_VERSION_MAJOR < 55 + } else if( pAV->pVStream->r_frame_rate.den && pAV->pVStream->r_frame_rate.num ) { pAV->fps = my_av_q2f(pAV->pVStream->r_frame_rate); + #endif + } else if( pAV->pVStream->codec->time_base.den && pAV->pVStream->codec->time_base.num ) { + pAV->fps = my_av_q2f_r(pAV->pVStream->codec->time_base); + } else if( pAV->pVStream->time_base.den && pAV->pVStream->time_base.num ) { + pAV->fps = my_av_q2f_r(pAV->pVStream->time_base); + } else { + pAV->fps = 0.0f; // duh! } pAV->frames_video = pAV->pVStream->nb_frames; @@ -886,35 +1062,78 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) } if( pAV->verbose ) { - fprintf(stderr, "V frame_size %d, frame_number %d, r_frame_rate %f %d/%d, avg_frame_rate %f %d/%d, nb_frames %d, size %dx%d, fmt 0x%X, bpp %d, planes %d\n", + fprintf(stderr, "V frame_size %d, frame_number %d, [afps %f, rfps %f, cfps %f, sfps %f] -> %f fps, nb_frames %d, size %dx%d, fmt 0x%X, bpp %d, planes %d, codecCaps 0x%X\n", pAV->pVCodecCtx->frame_size, pAV->pVCodecCtx->frame_number, - my_av_q2f(pAV->pVStream->r_frame_rate), pAV->pVStream->r_frame_rate.num, pAV->pVStream->r_frame_rate.den, - my_av_q2f(pAV->pVStream->avg_frame_rate), pAV->pVStream->avg_frame_rate.num, pAV->pVStream->avg_frame_rate.den, + my_av_q2f(pAV->pVStream->avg_frame_rate), + #if LIBAVCODEC_VERSION_MAJOR < 55 + my_av_q2f(pAV->pVStream->r_frame_rate), + #else + 0.0f, + #endif + my_av_q2f_r(pAV->pVStream->codec->time_base), + my_av_q2f_r(pAV->pVStream->time_base), + pAV->fps, pAV->pVStream->nb_frames, - pAV->vWidth, pAV->vHeight, pAV->vPixFmt, pAV->vBitsPerPixel, pAV->vBufferPlanes); + pAV->vWidth, pAV->vHeight, pAV->vPixFmt, pAV->vBitsPerPixel, pAV->vBufferPlanes, pAV->pVCodecCtx->codec->capabilities); + } + #if 0 + // Check CODEC_CAP_DR1, i.e. codec must handle get_buffer(), i.e. allocs 'em. + { + int codecHandlesBuffers = 0 != ( pAV->pVCodecCtx->codec->capabilities & CODEC_CAP_DR1 ); + if( !codecHandlesBuffers ) { + JoglCommon_throwNewRuntimeException(env, "Codec does not handle buffers (!CODEC_CAP_DR1)"); + return; + } } + #endif pAV->pVFrame=sp_avcodec_alloc_frame(); if( pAV->pVFrame == NULL ) { JoglCommon_throwNewRuntimeException(env, "Couldn't alloc video frame"); return; } - res = sp_avcodec_default_get_buffer(pAV->pVCodecCtx, pAV->pVFrame); - if(0==res) { + { const int32_t bytesPerPixel = ( pAV->vBitsPerPixel + 7 ) / 8 ; if(1 == pAV->vBufferPlanes) { pAV->vBytesPerPixelPerPlane = bytesPerPixel; } else { pAV->vBytesPerPixelPerPlane = 1; } + int32_t vLinesize[4]; if( pAV->vBufferPlanes > 1 ) { - for(i=0; i<3; i++) { - // FIXME: Libav Binary compatibility! JAU01 - pAV->vLinesize[i] = pAV->pVFrame->linesize[i]; - pAV->vTexWidth[i] = pAV->vLinesize[i] / pAV->vBytesPerPixelPerPlane ; - } + #if 0 + getAlignedLinesizes(pAV->pVCodecCtx, vLinesize); + for(i=0; ivBufferPlanes; i++) { + // FIXME: Libav Binary compatibility! JAU01 + pAV->vTexWidth[i] = vLinesize[i] / pAV->vBytesPerPixelPerPlane ; + } + #else + // Min. requirement for 'get_buffer2' ! + pAV->pVFrame->width = pAV->pVCodecCtx->width; + pAV->pVFrame->height = pAV->pVCodecCtx->height; + pAV->pVFrame->format = pAV->pVCodecCtx->pix_fmt; + #if LIBAVCODEC_VERSION_MAJOR >= 55 + res = sp_avcodec_default_get_buffer2(pAV->pVCodecCtx, pAV->pVFrame, 0); + #else + res = sp_avcodec_default_get_buffer(pAV->pVCodecCtx, pAV->pVFrame); + #endif + if(0!=res) { + JoglCommon_throwNewRuntimeException(env, "Couldn't peek video buffer dimension"); + return; + } + for(i=0; ivBufferPlanes; i++) { + // FIXME: Libav Binary compatibility! JAU01 + vLinesize[i] = pAV->pVFrame->linesize[i]; + pAV->vTexWidth[i] = vLinesize[i] / pAV->vBytesPerPixelPerPlane ; + } + #if LIBAVCODEC_VERSION_MAJOR >= 55 + sp_av_frame_unref(pAV->pVFrame); + #else + sp_avcodec_default_release_buffer(pAV->pVCodecCtx, pAV->pVFrame); + #endif + #endif } else { - pAV->vLinesize[0] = pAV->pVCodecCtx->width * pAV->vBytesPerPixelPerPlane; + vLinesize[0] = pAV->pVCodecCtx->width * pAV->vBytesPerPixelPerPlane; if( pAV->vPixFmt == PIX_FMT_YUYV422 ) { // Stuff 2x 16bpp (YUYV) into one RGBA pixel! pAV->vTexWidth[0] = pAV->pVCodecCtx->width / 2; @@ -922,10 +1141,11 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->vTexWidth[0] = pAV->pVCodecCtx->width; } } - sp_avcodec_default_release_buffer(pAV->pVCodecCtx, pAV->pVFrame); - } else { - JoglCommon_throwNewRuntimeException(env, "Couldn't peek video buffer dimension"); - return; + if( pAV->verbose ) { + for(i=0; ivBufferPlanes; i++) { + fprintf(stderr, "P[%d]: %d texw * %d bytesPP -> %d line\n", i, pAV->vTexWidth[i], pAV->vBytesPerPixelPerPlane, vLinesize[i]); + } + } } } pAV->vPTS=0; @@ -945,7 +1165,7 @@ JNIEXPORT void JNICALL FF_FUNC(setGLFuncs0) pAV->procAddrGLFinish = (PFNGLFINISH) (intptr_t)jProcAddrGLFinish; } -#if 0 +#if 1 #define DBG_TEXSUBIMG2D_a(c,p,w1,w2,h,i) fprintf(stderr, "TexSubImage2D.%c offset %d / %d, size %d x %d, ", c, (w1*p->pVCodecCtx->width)/w2, p->pVCodecCtx->height/h, p->vTexWidth[i], p->pVCodecCtx->height/h) #define DBG_TEXSUBIMG2D_b(p) fprintf(stderr, "err 0x%X\n", pAV->procAddrGLGetError()) #else @@ -1046,7 +1266,7 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) if( NULL != env ) { void* data_ptr = pAFrameCurrent->data[0]; // default - if( NULL != pAV->aResampleCtx ) { + if( NULL != pAV->avResampleCtx || NULL != pAV->swResampleCtx ) { enum AVSampleFormat aSampleFmtOut; // out fmt int32_t aChannelsOut; int32_t aSampleRateOut; @@ -1068,12 +1288,18 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) } pAV->aResampleBuffer = tmp_out; - out_samples = sp_avresample_convert(pAV->aResampleCtx, - &pAV->aResampleBuffer, - out_linesize, nb_samples, - pAFrameCurrent->data, - pAFrameCurrent->linesize[0], - pAFrameCurrent->nb_samples); + if( NULL != pAV->avResampleCtx ) { + out_samples = sp_avresample_convert(pAV->avResampleCtx, + &pAV->aResampleBuffer, + out_linesize, nb_samples, + pAFrameCurrent->data, + pAFrameCurrent->linesize[0], + pAFrameCurrent->nb_samples); + } else if( NULL != pAV->swResampleCtx ) { + out_samples = sp_swr_convert(pAV->swResampleCtx, + &pAV->aResampleBuffer, nb_samples, + (const uint8_t **)pAFrameCurrent->data, pAFrameCurrent->nb_samples); + } if (out_samples < 0) { JoglCommon_throwNewRuntimeException(env, "avresample_convert() failed"); return; @@ -1154,11 +1380,17 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) const int32_t frame_repeat_i = pAV->pVFrame->repeat_pict * (frame_delay_i / 2); const char * warn = frame_repeat_i > 0 ? "REPEAT" : "NORMAL" ; + const char * oopsLsz = pAV->pVFrame->linesize[0] <= 0 ? "Ooops LSZ" : "OK" ; - fprintf(stderr, "V fix_pts %d, pts %d [pkt_pts %ld], dts %d [pkt_dts %ld], time d(%lf s + r %lf = %lf s), i(%d ms + r %d = %d ms) - %s - f# %d\n", + fprintf(stderr, "V fix_pts %d, pts %d [pkt_pts %ld], dts %d [pkt_dts %ld], time d(%lf s + r %lf = %lf s), i(%d ms + r %d = %d ms) - %s - f# %d, data %p, lsz %d (%s)\n", pAV->vPTS, vPTS, pkt_pts, vDTS, pkt_dts, frame_delay_d, frame_repeat_d, (frame_delay_d + frame_repeat_d), - frame_delay_i, frame_repeat_i, (frame_delay_i + frame_repeat_i), warn, frameCount); + frame_delay_i, frame_repeat_i, (frame_delay_i + frame_repeat_i), warn, frameCount, + pAV->pVFrame->data[0], pAV->pVFrame->linesize[0], oopsLsz); + } + if( pAV->pVFrame->linesize[0] <= 0 ) { + // Ooops ! + continue; } resPTS = pAV->vPTS; // Video Frame! diff --git a/src/jogl/native/libav/ffmpeg_lavc55_lavf55_lavu52_lavr01.c b/src/jogl/native/libav/ffmpeg_lavc55_lavf55_lavu52_lavr01.c new file mode 100644 index 000000000..277100398 --- /dev/null +++ b/src/jogl/native/libav/ffmpeg_lavc55_lavf55_lavu52_lavr01.c @@ -0,0 +1,33 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +#include "jogamp_opengl_util_av_impl_FFMPEGv10Natives.h" + +#define FF_FUNC(METHOD) Java_jogamp_opengl_util_av_impl_FFMPEGv10Natives_ ## METHOD + +#include "ffmpeg_impl_template.c" diff --git a/src/jogl/native/libav/ffmpeg_static.c b/src/jogl/native/libav/ffmpeg_static.c index 171dda6a7..f079ee841 100644 --- a/src/jogl/native/libav/ffmpeg_static.c +++ b/src/jogl/native/libav/ffmpeg_static.c @@ -28,9 +28,6 @@ #ifdef _WIN32 #include - // __declspec(dllimport) void __stdcall Sleep(unsigned long dwMilliseconds); - - #define usleep(t) Sleep((t) / 1000) #endif #include @@ -46,34 +43,7 @@ typedef unsigned (APIENTRYP AV_GET_VERSION)(void); -JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGStaticNatives_getAvUtilVersion0 - (JNIEnv *env, jclass clazz, jlong func) { - if( 0 != func ) { - return (jint) ((AV_GET_VERSION)func)(); - } else { - return 0; - } -} - -JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGStaticNatives_getAvFormatVersion0 - (JNIEnv *env, jclass clazz, jlong func) { - if( 0 != func ) { - return (jint) ((AV_GET_VERSION)func)(); - } else { - return 0; - } -} - -JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGStaticNatives_getAvCodecVersion0 - (JNIEnv *env, jclass clazz, jlong func) { - if( 0 != func ) { - return (jint) ((AV_GET_VERSION)func)(); - } else { - return 0; - } -} - -JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGStaticNatives_getAvResampleVersion0 +JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGStaticNatives_getAvVersion0 (JNIEnv *env, jclass clazz, jlong func) { if( 0 != func ) { return (jint) ((AV_GET_VERSION)func)(); diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index ea9625da6..e4b10f95f 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -45,13 +45,20 @@ #include "libavformat/avformat.h" #include "libavutil/avutil.h" #if LIBAVCODEC_VERSION_MAJOR >= 54 -#include "libavresample/avresample.h" + #include "libavresample/avresample.h" + #include "libswresample/swresample.h" #endif #ifndef LIBAVRESAMPLE_VERSION_MAJOR -#define LIBAVRESAMPLE_VERSION_MAJOR 0 +#define LIBAVRESAMPLE_VERSION_MAJOR -1 +// Opaque typedef void* AVAudioResampleContext; #endif +#ifndef LIBSWRESAMPLE_VERSION_MAJOR +#define LIBSWRESAMPLE_VERSION_MAJOR -1 +// Opaque +typedef struct SwrContext SwrContext; +#endif #include #include @@ -88,24 +95,27 @@ typedef void (APIENTRYP PFNGLFINISH) (void); /** Constant PTS marking the end of the stream, i.e. Integer.MIN_VALUE - 1 == 0x7FFFFFFF == {@value}. Sync w/ TimeFrameI.END_OF_STREAM_PTS */ #define END_OF_STREAM_PTS 0x7FFFFFFF -/** Until 55.0.0, but stopped working w/ 54 already :( */ -#define AV_HAS_API_REQUEST_CHANNELS(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) < 54) - -/** Since 55.0.0 */ -#define AV_HAS_API_REFCOUNTED_FRAMES(pAV) (AV_VERSION_MAJOR(pAV->avcodecVersion) >= 55) - /** Since 54.0.0.1 */ -#define AV_HAS_API_AVRESAMPLE(pAV) (AV_VERSION_MAJOR(pAV->avresampleVersion) >= 1) +#define AV_HAS_API_AVRESAMPLE(pAV) ( pAV->avresampleVersion != 0 ) + +/** Since 55.0.0.1 */ +#define AV_HAS_API_SWRESAMPLE(pAV) ( pAV->swresampleVersion != 0 ) #define MAX_INT(a,b) ( (a >= b) ? a : b ) #define MIN_INT(a,b) ( (a <= b) ? a : b ) static inline float my_av_q2f(AVRational a){ - return a.num / (float) a.den; + return (float)a.num / (float)a.den; +} +static inline float my_av_q2f_r(AVRational a){ + return (float)a.den / (float)a.num; } static inline int32_t my_av_q2i32(int64_t snum, AVRational a){ return (int32_t) ( ( snum * (int64_t) a.num ) / (int64_t)a.den ); } +static inline int my_align(int v, int a){ + return ( v + a - 1 ) & ~( a - 1 ); +} typedef struct { void *origPtr; @@ -129,6 +139,7 @@ typedef struct { uint32_t avformatVersion; uint32_t avutilVersion; uint32_t avresampleVersion; + uint32_t swresampleVersion; int32_t useRefCountedFrames; @@ -149,8 +160,7 @@ typedef struct { enum PixelFormat vPixFmt; // native decoder fmt int32_t vPTS; // msec - overall last video PTS PTSStats vPTSStats; - int32_t vLinesize[3]; // decoded video linesize in bytes for each plane - int32_t vTexWidth[3]; // decoded video tex width in bytes for each plane + int32_t vTexWidth[AV_NUM_DATA_POINTERS]; // decoded video tex width in bytes for each plane int32_t vWidth; int32_t vHeight; @@ -167,7 +177,8 @@ typedef struct { int32_t aSampleRate; int32_t aChannels; int32_t aSinkSupport; // supported by AudioSink - AVAudioResampleContext *aResampleCtx; + AVAudioResampleContext* avResampleCtx; + struct SwrContext* swResampleCtx; uint8_t* aResampleBuffer; enum AVSampleFormat aSampleFmtOut; // out fmt int32_t aChannelsOut; -- cgit v1.2.3 From 4cb3763415bb5f82520fd02f56412076f80a84e6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 30 Aug 2013 17:31:34 +0200 Subject: GLMediaPlayer enhancements: State, Camera options, detect and act on orientation change (flipped), API-doc, - State - Fix state transition (initGL() error) - Camera options - options uses ';' as query separator - don't use 'default' options, driver should know - Detect and act on orientation change (flipped) - ffmpeg impl detects if flipped changes and triggers a SIZE update event. This allows application to react, i.e. re-init GL and use new TextureCoord's. Test: Works well on Windows w/ rawvideo dshow camera driver/codec. - API-doc - TexSeqEventListener/GLMediaEventListener usage / constraints (GL, ..) - State transition fix --- make/scripts/tests-x64.sh | 4 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 50 +++++++-- .../opengl/util/texture/TextureSequence.java | 23 +++- .../android/av/AndroidGLMediaPlayerAPI14.java | 2 +- .../jogamp/opengl/util/av/EGLMediaPlayerImpl.java | 2 +- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 72 ++++++++----- .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 5 +- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 28 +++-- .../opengl/util/av/impl/OMXGLMediaPlayer.java | 1 + src/jogl/native/libav/ffmpeg_impl_template.c | 80 ++++++++------ src/jogl/native/libav/ffmpeg_tool.h | 1 + .../test/junit/jogl/demos/es2/av/MovieCube.java | 65 ++++++++--- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 119 ++++++++++++++------- 13 files changed, 318 insertions(+), 134 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.sh b/make/scripts/tests-x64.sh index 68937ca4b..442458603 100755 --- a/make/scripts/tests-x64.sh +++ b/make/scripts/tests-x64.sh @@ -7,8 +7,8 @@ SDIR=`dirname $0` #export LD_LIBRARY_PATH=/home/sven/libav-9.x/lib:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH=/home/sven/ffmpeg-1.2/lib:$LD_LIBRARY_PATH -#export LD_LIBRARY_PATH=/home/sven/libav-10.x/lib:$LD_LIBRARY_PATH -export LD_LIBRARY_PATH=/home/sven/ffmpeg-2.x/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=/home/sven/libav-10.x/lib:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/home/sven/ffmpeg-2.x/lib:$LD_LIBRARY_PATH if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 1fb0608fb..5072c410d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -34,6 +34,7 @@ import javax.media.opengl.GLException; import jogamp.opengl.Debug; +import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; import com.jogamp.opengl.util.TimeFrameI; @@ -81,8 +82,8 @@ import com.jogamp.opengl.util.TimeFrameI; *

        * * - * - * + * + * * * * @@ -205,12 +206,14 @@ public interface GLMediaPlayer extends TextureSequence { * ranging from [0..max-number]. *

        *

        - * The {@link URI#getRawQuery() URI query} is used to pass options to the camera. + * The {@link URI#getRawQuery() URI query} is used to pass options to the camera + * using ; as the separator. The latter avoids trouble w/ escaping. *

        *
              *    camera:/
              *    camera://somewhere/
        -     *    camera://somewhere/?width=640&height=480&rate=15
        +     *    camera://somewhere/?width=640;height=480;rate=15
        +     *    camera://somewhere/?size=640x480;rate=15
              * 
        *
              *  URI: [scheme:][//authority][path][?query][#fragment]
        @@ -245,6 +248,13 @@ public interface GLMediaPlayer extends TextureSequence {
                     super(message, cause);
                 }
             }
        +    
        +    /**
        +     * {@inheritDoc}
        +     * 

        + * See {@link TexSeqEventListener} for semantics and usage. + *

        + */ public interface GLMediaEventListener extends TexSeqEventListener { /** State changed to {@link State#Initialized}. See Lifecycle.*/ @@ -264,7 +274,7 @@ public interface GLMediaPlayer extends TextureSequence { static final int EVENT_CHANGE_VID = 1<<16; /** Stream audio id change. */ static final int EVENT_CHANGE_AID = 1<<17; - /** TextureFrame size change. */ + /** TextureFrame size or vertical flip change. */ static final int EVENT_CHANGE_SIZE = 1<<18; /** Stream fps change. */ static final int EVENT_CHANGE_FPS = 1<<19; @@ -556,18 +566,44 @@ public interface GLMediaPlayer extends TextureSequence { */ public float getFramerate(); + /** + * Returns true if the video frame is oriented in + * OpenGL's coordinate system, origin at bottom left. + *

        + * Otherwise returns false, i.e. + * video frame is oriented origin at top left. + *

        + *

        + * false is the default assumption for videos, + * but user shall not rely on. + *

        + *

        + * false GL orientation leads to + * {@link Texture#getMustFlipVertically()} == true, + * as reflected by all {@link TextureFrame}'s {@link Texture}s + * retrieved via {@link #getLastTexture()} or {@link #getNextTexture(GL)}. + *

        + */ + public boolean isGLOriented(); + + /** Returns the width of the video. */ public int getWidth(); + /** Returns the height of the video. */ public int getHeight(); + /** Returns a string represantation of this player, incl. state and audio/video details. */ public String toString(); + /** Returns a string represantation of this player's performance values. */ public String getPerfString(); + /** Adds a {@link GLMediaEventListener} to this player. */ public void addEventListener(GLMediaEventListener l); + /** Removes a {@link GLMediaEventListener} to this player. */ public void removeEventListener(GLMediaEventListener l); - public GLMediaEventListener[] getEventListeners(); - + /** Return all {@link GLMediaEventListener} of this player. */ + public GLMediaEventListener[] getEventListeners(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index 8b6cc1bf9..5c6b63535 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -28,7 +28,9 @@ package com.jogamp.opengl.util.texture; import javax.media.opengl.GL; - +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLEventListener; import com.jogamp.opengl.util.TimeFrameI; /** @@ -128,6 +130,25 @@ public interface TextureSequence { protected final Texture texture; } + /** + * Event listener to notify users of updates regarding the {@link TextureSequence}. + *

        + * The implementation sending the events, and hence calling down to all listeners, + * does not necessarily make the user's OpenGL context current. + *

        + *

        + * Further more, the call may happen off-thread, possibly holding another, possibly shared, OpenGL context current. + *

        + * Hence a user shall not issue any OpenGL, time consuming + * or {@link TextureSequence} lifecycle operations directly.
        + * Instead, the user shall: + *
          + *
        • issue commands off-thread via spawning off another thread, or
        • + *
        • injecting {@link GLRunnable} objects via {@link GLAutoDrawable#invoke(boolean, GLRunnable)}, or
        • + *
        • simply changing a volatile state of their {@link GLEventListener} implementation.
        • + *
        + *

        + * */ public interface TexSeqEventListener { /** * Signaling listeners that a new {@link TextureFrame} is available. diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 38faf62a6..35084f1c5 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -433,7 +433,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { protected final TextureSequence.TextureFrame createTexImage(GL gl, int texName) { sTexFrameCount++; if( 1 == sTexFrameCount ) { - singleSTexFrame = new SurfaceTextureFrame( createTexImageImpl(gl, texName, width, height, true), new SurfaceTexture(texName) ); + singleSTexFrame = new SurfaceTextureFrame( createTexImageImpl(gl, texName, width, height), new SurfaceTexture(texName) ); } return singleSTexFrame; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java index ec375406d..31af8e4db 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/EGLMediaPlayerImpl.java @@ -85,7 +85,7 @@ public abstract class EGLMediaPlayerImpl extends GLMediaPlayerImpl { @Override protected TextureSequence.TextureFrame createTexImage(GL gl, int texName) { - final Texture texture = super.createTexImageImpl(gl, texName, width, height, false); + final Texture texture = super.createTexImageImpl(gl, texName, width, height); final Buffer clientBuffer; final long image; final long sync; diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index ab0e2eebd..205642eb0 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -165,6 +165,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected Ringbuffer videoFramesFree = null; protected Ringbuffer videoFramesDecoded = null; protected volatile TextureFrame lastFrame = null; + /** + * @see #isGLOriented() + */ + protected boolean isInGLOrientation = false; private ArrayList eventListeners = new ArrayList(); @@ -203,12 +207,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final void setTextureWrapST(int[] wrapST) { texWrapST[0] = wrapST[0]; texWrapST[1] = wrapST[1];} public final int[] getTextureWrapST() { return texWrapST; } - private final void checkStreamInit() { - if(State.Uninitialized == state ) { - throw new IllegalStateException("Stream not initialized: "+this); - } - } - private final void checkGLInit() { if(State.Uninitialized == state || State.Initialized == state ) { throw new IllegalStateException("GL not initialized: "+this); @@ -338,6 +336,23 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } protected abstract boolean pauseImpl(); + @Override + public final State destroy(GL gl) { + return destroyImpl(gl, 0); + } + private final State destroyImpl(GL gl, int event_mask) { + synchronized( stateLock ) { + streamWorker.doStop(); + streamWorker = null; + destroyImpl(gl); + removeAllTextureFrames(gl); + textureCount=0; + changeState(event_mask, State.Uninitialized); + return state; + } + } + protected abstract void destroyImpl(GL gl); + @Override public final int seek(int msec) { synchronized( stateLock ) { @@ -458,7 +473,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public final void initStream(URI streamLoc, int vid, int aid, int reqTextureCount) throws IllegalStateException, IllegalArgumentException { synchronized( stateLock ) { if(State.Uninitialized != state) { - throw new IllegalStateException("Instance not unintialized: "+this); + throw new IllegalStateException("Instance not in state unintialized: "+this); } if(null == streamLoc) { throw new IllegalArgumentException("streamLock is null"); @@ -485,7 +500,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( null != rawPath && rawPath.length() > 0 ) { // cut-off root fwd-slash cameraPath = rawPath.substring(1); - final URIQueryProps props = URIQueryProps.create(streamLoc); + final URIQueryProps props = URIQueryProps.create(streamLoc, ';'); cameraProps = props.getProperties(); } else { throw new IllegalArgumentException("Camera path is empty: "+streamLoc.toString()); @@ -528,10 +543,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final void initGL(GL gl) throws IllegalStateException, StreamException, GLException { synchronized( stateLock ) { - checkStreamInit(); + if(State.Initialized != state ) { + throw new IllegalStateException("Stream not in state initialized: "+this); + } final StreamException streamInitErr = streamWorker.getStreamErr(); if( null != streamInitErr ) { - streamWorker = null; + streamWorker = null; // already terminated! destroy(null); throw streamInitErr; } @@ -559,6 +576,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } changeState(0, State.Paused); } catch (Throwable t) { + destroyImpl(gl, GLMediaEventListener.EVENT_CHANGE_ERR); // -> GLMediaPlayer.State.Uninitialized throw new GLException("Error initializing GL resources", t); } } @@ -602,7 +620,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } protected abstract TextureFrame createTexImage(GL gl, int texName); - protected final Texture createTexImageImpl(GL gl, int texName, int tWidth, int tHeight, boolean mustFlipVertically) { + protected final Texture createTexImageImpl(GL gl, int texName, int tWidth, int tHeight) { if( 0 > texName ) { throw new RuntimeException("TextureName "+toHexString(texName)+" invalid."); } @@ -649,7 +667,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { texName, textureTarget, tWidth, tHeight, width, height, - mustFlipVertically); + !isInGLOrientation); } protected void destroyTexFrame(GL gl, TextureFrame frame) { @@ -1251,20 +1269,19 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { attributesUpdated(event_mask); } - @Override - public final State destroy(GL gl) { - synchronized( stateLock ) { - streamWorker.doStop(); - streamWorker = null; - destroyImpl(gl); - removeAllTextureFrames(gl); - textureCount=0; - changeState(0, State.Uninitialized); - return state; + protected void setIsGLOriented(boolean isGLOriented) { + if( isInGLOrientation != isGLOriented ) { + if( DEBUG ) { + System.err.println("XXX gl-orient "+isInGLOrientation+" -> "+isGLOriented); + } + isInGLOrientation = isGLOriented; + for(int i=0; i, "+width+"x"+height+", "+fps+" fps, "+frame_duration+" fdur, "+bps_video+" bps], "+ + "Video[id "+vid+", <"+vcodec+">, "+width+"x"+height+", glOrient "+isInGLOrientation+", "+fps+" fps, "+frame_duration+" fdur, "+bps_video+" bps], "+ "Audio[id "+aid+", <"+acodec+">, "+bps_audio+" bps, "+audioFrames+" frames], uri "+loc+camPath+"]"; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index 6fa7c7a54..1cddaa9cf 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -57,6 +57,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { public NullGLMediaPlayer() { super(); + } @Override @@ -143,7 +144,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { } @Override protected final void initGLImpl(GL gl) throws IOException, GLException { - // NOP + isInGLOrientation = true; } /** @@ -159,7 +160,7 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { @Override protected final TextureSequence.TextureFrame createTexImage(GL gl, int texName) { - final Texture texture = super.createTexImageImpl(gl, texName, width, height, false); + final Texture texture = super.createTexImageImpl(gl, texName, width, height); if(null != texData) { texture.updateImage(gl, texData); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 2737a0b6a..c329e880f 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -293,7 +293,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { final boolean isCameraInput = null != cameraPath; final String resStreamLocS; - int rw=640, rh=480, rr=15; + // int rw=640, rh=480, rr=15; + int rw=-1, rh=-1, rr=-1; String sizes = null; if( isCameraInput ) { switch(Platform.OS_TYPE) { @@ -424,7 +425,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } @Override protected final TextureFrame createTexImage(GL gl, int texName) { - return new TextureFrame( createTexImageImpl(gl, texName, texWidth, texHeight, true) ); + return new TextureFrame( createTexImageImpl(gl, texName, texWidth, texHeight) ); } /** @@ -521,10 +522,10 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { * @param audioChannels * @param audioSamplesPerFrameAndChannel in audio samples per frame and channel */ - void updateAttributes2(int vid, int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, - int tWd0, int tWd1, int tWd2, int vW, int vH, - int aid, int audioSampleFmt, int audioSampleRate, - int audioChannels, int audioSamplesPerFrameAndChannel) { + void setupFFAttributes(int vid, int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, + int tWd0, int tWd1, int tWd2, int vW, int vH, + int aid, int audioSampleFmt, int audioSampleRate, + int audioChannels, int audioSamplesPerFrameAndChannel) { // defaults .. vPixelFmt = null; vPlanes = 0; @@ -611,6 +612,21 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { } } + /** + * Native callback + * @param isInGLOrientation + * @param pixFmt + * @param planes + * @param bitsPerPixel + * @param bytesPerPixelPerPlane + * @param tWd0 + * @param tWd1 + * @param tWd2 + */ + void updateVidAttributes(boolean isInGLOrientation, int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane, + int tWd0, int tWd1, int tWd2, int vW, int vH) { + } + /** * {@inheritDoc} * diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java index faa6a56c4..a5a701a4f 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java @@ -119,6 +119,7 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { @Override protected final void initGLImpl(GL gl) throws IOException, GLException { // NOP + isInGLOrientation = true; } @Override diff --git a/src/jogl/native/libav/ffmpeg_impl_template.c b/src/jogl/native/libav/ffmpeg_impl_template.c index 6d28e77b6..7035545d0 100644 --- a/src/jogl/native/libav/ffmpeg_impl_template.c +++ b/src/jogl/native/libav/ffmpeg_impl_template.c @@ -45,8 +45,9 @@ static const char * const ClazzNameFFMPEGMediaPlayer = "jogamp/opengl/util/av/im static jclass ffmpegMediaPlayerClazz = NULL; static jmethodID jni_mid_pushSound = NULL; -static jmethodID jni_mid_updateAttributes1 = NULL; -static jmethodID jni_mid_updateAttributes2 = NULL; +static jmethodID jni_mid_updateAttributes = NULL; +static jmethodID jni_mid_setIsGLOriented = NULL; +static jmethodID jni_mid_setupFFAttributes = NULL; static jmethodID jni_mid_isAudioFormatSupported = NULL; #define HAS_FUNC(f) (NULL!=(f)) @@ -309,22 +310,18 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initSymbols0) return JNI_TRUE; } -static int _isAudioFormatSupported(JNIEnv *env, jobject ffmpegMediaPlayer, enum AVSampleFormat aSampleFmt, int32_t aSampleRate, int32_t aChannels) -{ +static int _isAudioFormatSupported(JNIEnv *env, jobject ffmpegMediaPlayer, enum AVSampleFormat aSampleFmt, int32_t aSampleRate, int32_t aChannels) { return JNI_TRUE == (*env)->CallBooleanMethod(env, ffmpegMediaPlayer, jni_mid_isAudioFormatSupported, aSampleFmt, aSampleRate, aChannels); } -static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasicAV_t* pAV) -{ - // int shallBeDetached = 0; - // JNIEnv * env = JoglCommon_GetJNIEnv (&shallBeDetached); +static void _updateJavaAttributes(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { if(NULL!=env) { - (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_updateAttributes2, + (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_setupFFAttributes, pAV->vid, pAV->vPixFmt, pAV->vBufferPlanes, pAV->vBitsPerPixel, pAV->vBytesPerPixelPerPlane, pAV->vTexWidth[0], pAV->vTexWidth[1], pAV->vTexWidth[2], pAV->vWidth, pAV->vHeight, pAV->aid, pAV->aSampleFmtOut, pAV->aSampleRateOut, pAV->aChannelsOut, pAV->aFrameSize); - (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_updateAttributes1, + (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_updateAttributes, pAV->vid, pAV->aid, pAV->vWidth, pAV->vHeight, pAV->bps_stream, pAV->bps_video, pAV->bps_audio, @@ -333,6 +330,11 @@ static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasic (*env)->NewStringUTF(env, pAV->acodec) ); } } +static void _setIsGLOriented(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { + if(NULL!=env) { + (*env)->CallVoidMethod(env, pAV->ffmpegMediaPlayer, jni_mid_setIsGLOriented, pAV->vFlipped); + } +} static void freeInstance(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { int i; @@ -499,13 +501,15 @@ JNIEXPORT jboolean JNICALL FF_FUNC(initIDs0) } jni_mid_pushSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "pushSound", "(Ljava/nio/ByteBuffer;II)V"); - jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIIIFIIILjava/lang/String;Ljava/lang/String;)V"); - jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIIIIIIII)V"); + jni_mid_updateAttributes = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIIIFIIILjava/lang/String;Ljava/lang/String;)V"); + jni_mid_setIsGLOriented = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "setIsGLOriented", "(Z)V"); + jni_mid_setupFFAttributes = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "setupFFAttributes", "(IIIIIIIIIIIIIII)V"); jni_mid_isAudioFormatSupported = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "isAudioFormatSupported", "(III)Z"); if(jni_mid_pushSound == NULL || - jni_mid_updateAttributes1 == NULL || - jni_mid_updateAttributes2 == NULL || + jni_mid_updateAttributes == NULL || + jni_mid_setIsGLOriented == NULL || + jni_mid_setupFFAttributes == NULL || jni_mid_isAudioFormatSupported == NULL) { return JNI_FALSE; } @@ -726,21 +730,28 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) } const char *sizeS = NULL != jSizeS ? (*env)->GetStringUTFChars(env, jSizeS, &iscopy) : NULL; + int hasSize = 0; if( NULL != sizeS ) { snprintf(buffer, sizeof(buffer), "%s", sizeS); (*env)->ReleaseStringChars(env, jSizeS, (const jchar *)sizeS); - } else { + hasSize = 1; + } else if( vWidth > 0 && vHeight > 0 ) { snprintf(buffer, sizeof(buffer), "%dx%d", vWidth, vHeight); + hasSize = 1; } - if(pAV->verbose) { - fprintf(stderr, "Camera: Size: %s\n", buffer); + if( hasSize ) { + if(pAV->verbose) { + fprintf(stderr, "Camera: Size: %s\n", buffer); + } + sp_av_dict_set(&inOpts, "video_size", buffer, 0); } - sp_av_dict_set(&inOpts, "video_size", buffer, 0); - snprintf(buffer, sizeof(buffer), "%d", vRate); - if(pAV->verbose) { - fprintf(stderr, "Camera: FPS: %s\n", buffer); + if( vRate > 0 ) { + snprintf(buffer, sizeof(buffer), "%d", vRate); + if(pAV->verbose) { + fprintf(stderr, "Camera: FPS: %s\n", buffer); + } + sp_av_dict_set(&inOpts, "framerate", buffer, 0); } - sp_av_dict_set(&inOpts, "framerate", buffer, 0); // not setting a framerate causes some drivers to crash! } res = sp_avformat_open_input(&pAV->pFormatCtx, filename, inFmt, NULL != inOpts ? &inOpts : NULL); if( NULL != inOpts ) { @@ -1055,6 +1066,7 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->vWidth = pAV->pVCodecCtx->width; pAV->vHeight = pAV->pVCodecCtx->height; pAV->vPixFmt = pAV->pVCodecCtx->pix_fmt; + pAV->vFlipped = JNI_FALSE; { AVPixFmtDescriptor pixDesc = sp_av_pix_fmt_descriptors[pAV->vPixFmt]; pAV->vBitsPerPixel = sp_av_get_bits_per_pixel(&pixDesc); @@ -1076,16 +1088,6 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->pVStream->nb_frames, pAV->vWidth, pAV->vHeight, pAV->vPixFmt, pAV->vBitsPerPixel, pAV->vBufferPlanes, pAV->pVCodecCtx->codec->capabilities); } - #if 0 - // Check CODEC_CAP_DR1, i.e. codec must handle get_buffer(), i.e. allocs 'em. - { - int codecHandlesBuffers = 0 != ( pAV->pVCodecCtx->codec->capabilities & CODEC_CAP_DR1 ); - if( !codecHandlesBuffers ) { - JoglCommon_throwNewRuntimeException(env, "Codec does not handle buffers (!CODEC_CAP_DR1)"); - return; - } - } - #endif pAV->pVFrame=sp_avcodec_alloc_frame(); if( pAV->pVFrame == NULL ) { @@ -1152,7 +1154,7 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->aPTS=0; initPTSStats(&pAV->vPTSStats); initPTSStats(&pAV->aPTSStats); - _updateJavaAttributes(env, instance, pAV); + _updateJavaAttributes(env, pAV); } JNIEXPORT void JNICALL FF_FUNC(setGLFuncs0) @@ -1179,7 +1181,6 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); AVPacket packet; - int frameDecoded; jint resPTS = INVALID_PTS; uint8_t * pkt_odata; int pkt_osize; @@ -1206,6 +1207,7 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) int frameCount; int flush_complete = 0; for ( frameCount=0; 0 < packet.size || 0 == frameCount; frameCount++ ) { + int frameDecoded; int len1; NIOBuffer_t * pNIOBufferCurrent = &pAV->pANIOBuffers[pAV->aFrameCurrent]; AVFrame* pAFrameCurrent = pAV->pAFrames[pAV->aFrameCurrent]; @@ -1339,6 +1341,7 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) int frameCount; int flush_complete = 0; for ( frameCount=0; 0 < packet.size || 0 == frameCount; frameCount++ ) { + int frameDecoded; int len1; sp_avcodec_get_frame_defaults(pAV->pVFrame); if (flush_complete) { @@ -1398,6 +1401,11 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) int p_offset[] = { 0, 0, 0, 0 }; if( pAV->pVFrame->linesize[0] < 0 ) { + if( JNI_FALSE == pAV->vFlipped ) { + pAV->vFlipped = JNI_TRUE; + _setIsGLOriented(env, pAV); + } + // image bottom-up int h_1 = pAV->pVCodecCtx->height - 1; p_offset[0] = pAV->pVFrame->linesize[0] * h_1; @@ -1411,7 +1419,11 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) if( pAV->vBufferPlanes > 3 ) { p_offset[3] = pAV->pVFrame->linesize[3] * h_1; } */ + } else if( JNI_TRUE == pAV->vFlipped ) { + pAV->vFlipped = JNI_FALSE; + _setIsGLOriented(env, pAV); } + // 1st plane or complete packed frame // FIXME: Libav Binary compatibility! JAU01 DBG_TEXSUBIMG2D_a('Y',pAV,1,1,1,0); diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index 72345fbb7..61d121f24 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -163,6 +163,7 @@ typedef struct { int32_t vTexWidth[4]; // decoded video tex width in bytes for each plane (max 4) int32_t vWidth; int32_t vHeight; + jboolean vFlipped; // false: !GL-Orientation, true: GL-Orientation int32_t aid; AVStream* pAStream; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 7647421a0..57da78131 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -67,6 +67,7 @@ public class MovieCube implements GLEventListener { private GLMediaPlayer mPlayer=null; private int swapInterval = 1; private long lastPerfPos = 0; + private volatile boolean resetGLState = false; /** Blender's Big Buck Bunny Trailer: 24f 640p VP8, Vorbis 44100Hz mono, WebM/Matroska Stream. */ public static final URI defURI; @@ -100,6 +101,10 @@ public class MovieCube implements GLEventListener { public GLMediaPlayer getGLMediaPlayer() { return mPlayer; } + public void resetGLState() { + resetGLState = true; + } + private final KeyListener keyAction = new KeyAdapter() { public void keyReleased(KeyEvent e) { if( e.isAutoRepeat() ) { @@ -172,12 +177,14 @@ public class MovieCube implements GLEventListener { if(null == mPlayer) { throw new InternalError("mPlayer null"); } - if( GLMediaPlayer.State.Initialized != mPlayer.getState() ) { - throw new IllegalStateException("mPlayer not in state initialized: "+mPlayer); + if( GLMediaPlayer.State.Uninitialized == mPlayer.getState() ) { + throw new IllegalStateException("mPlayer in uninitialized state: "+mPlayer); } if( GLMediaPlayer.STREAM_ID_NONE == mPlayer.getVID() ) { // throw new IllegalStateException("mPlayer has no VID/stream selected: "+mPlayer); } + resetGLState = false; + GL2ES2 gl = drawable.getGL().getGL2ES2(); System.err.println(JoglVersion.getGLInfo(gl, null)); @@ -186,16 +193,18 @@ public class MovieCube implements GLEventListener { if(waitForKey) { UITestCase.waitForKey("Init>"); } - - try { - mPlayer.initGL(gl); - } catch (Exception e) { - e.printStackTrace(); - if(null != mPlayer) { - mPlayer.destroy(gl); - mPlayer = null; + + if( GLMediaPlayer.State.Initialized == mPlayer.getState() ) { + try { + mPlayer.initGL(gl); + } catch (Exception e) { + e.printStackTrace(); + if(null != mPlayer) { + mPlayer.destroy(gl); + mPlayer = null; + } + throw new GLException(e); } - throw new GLException(e); } cube.init(drawable); mPlayer.play(); @@ -224,18 +233,38 @@ public class MovieCube implements GLEventListener { @Override public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" MovieCube.dispose ... "); + disposeImpl(drawable, true); + } + + private void disposeImpl(GLAutoDrawable drawable, boolean disposePlayer) { if(null == mPlayer) { return; } + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; + window.removeKeyListener(keyAction); + } final GL2ES2 gl = drawable.getGL().getGL2ES2(); - mPlayer.destroy(gl); - mPlayer=null; + if( disposePlayer ) { + mPlayer.destroy(gl); + mPlayer=null; + } cube.dispose(drawable); - cube=null; + cube=null; } + @Override public void display(GLAutoDrawable drawable) { if(null == mPlayer) { return; } + if( resetGLState ) { + resetGLState = false; + System.err.println("XXX resetGLState"); + disposeImpl(drawable, false); + init(drawable); + reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); + } + final long currentPos = System.currentTimeMillis(); if( currentPos - lastPerfPos > 2000 ) { System.err.println( mPlayer.getPerfString() ); @@ -350,8 +379,12 @@ public class MovieCube implements GLEventListener { public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { System.err.println("MovieCube AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); System.err.println("MovieCube State: "+mp); - if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) && origSize ) { - window.setSize(mp.getWidth(), mp.getHeight()); + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { + if( origSize ) { + window.setSize(mp.getWidth(), mp.getHeight()); + } + // window.disposeGLEventListener(ms, false /* remove */ ); + mc.resetGLState(); } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { window.addGLEventListener(mc); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index f0a11820e..b52e1fb21 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -98,7 +98,9 @@ public class MovieSimple implements GLEventListener { private boolean mPlayerExternal; private boolean mPlayerShared; private boolean mPlayerScaleOrig; + private float[] verts = null; private GLArrayDataServer interleavedVBO; + private volatile boolean resetGLState = false; private ShaderState st; private PMVMatrix pmvMatrix; @@ -270,6 +272,10 @@ public class MovieSimple implements GLEventListener { this.alpha = alpha; } + public void resetGLState() { + resetGLState = true; + } + private void initShader(GL2ES2 gl) { // Create & Compile the shader objects ShaderCode rsVp = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, MovieSimple.class, @@ -309,12 +315,14 @@ public class MovieSimple implements GLEventListener { if(null == mPlayer) { throw new InternalError("mPlayer null"); } - if( GLMediaPlayer.State.Initialized != mPlayer.getState() ) { - throw new IllegalStateException("mPlayer not in state initialized: "+mPlayer); + if( GLMediaPlayer.State.Uninitialized == mPlayer.getState() ) { + throw new IllegalStateException("mPlayer in uninitialized state: "+mPlayer); } if( GLMediaPlayer.STREAM_ID_NONE == mPlayer.getVID() ) { throw new IllegalStateException("mPlayer has no VID/stream selected: "+mPlayer); } + resetGLState = false; + zoom0 = orthoProjection ? 0f : -2.5f; zoom1 = orthoProjection ? 0f : -5f; zoom = zoom0; @@ -331,7 +339,7 @@ public class MovieSimple implements GLEventListener { boolean useExternalTexture = false; try { System.out.println("p0 "+mPlayer+", shared "+mPlayerShared); - if(!mPlayerShared) { + if(!mPlayerShared && GLMediaPlayer.State.Initialized == mPlayer.getState() ) { mPlayer.initGL(gl); } System.out.println("p1 "+mPlayer+", shared "+mPlayerShared); @@ -378,7 +386,6 @@ public class MovieSimple implements GLEventListener { float mHeight = mPlayer.getHeight(); float mAspect = mWidth/mHeight; System.err.println("XXX0: mov aspect: "+mAspect); - float[] verts; float xs, ys; if(orthoProjection) { if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) { @@ -406,14 +413,48 @@ public class MovieSimple implements GLEventListener { System.err.println("XXX0: win LB: "+winLB[0]+", "+winLB[1]+", "+winLB[2]); System.err.println("XXX0: win RT: "+winRT[0]+", "+winRT[1]+", "+winRT[2]); } - final float ss = 1f, ts = 1f; // scale tex-coord interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW); { interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER); interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER); - interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER); - + interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER); + } + updateInterleavedVBO(gl, tex); + + st.ownAttribute(interleavedVBO, true); + gl.glClearColor(0.3f, 0.3f, 0.3f, 0.3f); + + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + + st.useProgram(gl, false); + + // Let's show the completed shader state .. + System.out.println("iVBO: "+interleavedVBO); + System.out.println(st); + + if(!mPlayerShared) { + mPlayer.play(); + System.out.println("play.0 "+mPlayer); + } + startTime = System.currentTimeMillis(); + + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; + window.addMouseListener(mouseAction); + window.addKeyListener(keyAction); + winWidth = window.getWidth(); + winHeight = window.getHeight(); + } + } + + protected void updateInterleavedVBO(GL gl, Texture tex) { + final float ss = 1f, ts = 1f; // scale tex-coord + final boolean wasEnabled = interleavedVBO.enabled(); + interleavedVBO.seal(gl, false); + interleavedVBO.rewind(); + { final FloatBuffer ib = (FloatBuffer)interleavedVBO.getBuffer(); final TextureCoords tc = tex.getImageTexCoords(); System.err.println("XXX0: "+tc); @@ -457,31 +498,8 @@ public class MovieSimple implements GLEventListener { ib.put( tc.right() *ss); ib.put( tc.top() *ts); } interleavedVBO.seal(gl, true); - interleavedVBO.enableBuffer(gl, false); - st.ownAttribute(interleavedVBO, true); - gl.glClearColor(0.3f, 0.3f, 0.3f, 0.3f); - - gl.glEnable(GL2ES2.GL_DEPTH_TEST); - - st.useProgram(gl, false); - - // Let's show the completed shader state .. - System.out.println("iVBO: "+interleavedVBO); - System.out.println(st); - - if(!mPlayerShared) { - mPlayer.play(); - System.out.println("play.0 "+mPlayer); - } - startTime = System.currentTimeMillis(); - - final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { - final Window window = (Window) upstreamWidget; - window.addMouseListener(mouseAction); - window.addKeyListener(keyAction); - winWidth = window.getWidth(); - winHeight = window.getHeight(); + if( !wasEnabled ) { + interleavedVBO.enableBuffer(gl, false); } } @@ -526,17 +544,28 @@ public class MovieSimple implements GLEventListener { @Override public void dispose(GLAutoDrawable drawable) { + disposeImpl(drawable, true); + } + + private void disposeImpl(GLAutoDrawable drawable, boolean disposePlayer) { if(null == mPlayer) { return; } - System.out.println("pD.1 "+mPlayer); - GL2ES2 gl = drawable.getGL().getGL2ES2(); - if( null != mPlayer ) { + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; + window.removeMouseListener(mouseAction); + window.removeKeyListener(keyAction); + } + + System.out.println("pD.1 "+mPlayer+", disposePlayer "+disposePlayer); + GL2ES2 gl = drawable.getGL().getGL2ES2(); + if( disposePlayer ) { if(!mPlayerExternal) { mPlayer.destroy(gl); } + System.out.println("pD.X "+mPlayer); + mPlayer=null; } - System.out.println("pD.X "+mPlayer); - mPlayer=null; pmvMatrixUniform = null; if(null != pmvMatrix) { pmvMatrix.destroy(); @@ -554,6 +583,14 @@ public class MovieSimple implements GLEventListener { public void display(GLAutoDrawable drawable) { if(null == mPlayer) { return; } + if( resetGLState ) { + resetGLState = false; + System.err.println("XXX resetGLState"); + disposeImpl(drawable, false); + init(drawable); + reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); + } + final long currentPos = System.currentTimeMillis(); if( currentPos - lastPerfPos > 2000 ) { System.err.println( mPlayer.getPerfString() ); @@ -727,8 +764,12 @@ public class MovieSimple implements GLEventListener { public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { System.err.println("MovieSimple AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); System.err.println("MovieSimple State: "+mp); - if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) && origSize ) { - window.setSize(mp.getWidth(), mp.getHeight()); + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { + if( origSize ) { + window.setSize(mp.getWidth(), mp.getHeight()); + } + // window.disposeGLEventListener(ms, false /* remove */ ); + ms.resetGLState(); } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { if( GLMediaPlayer.STREAM_ID_NONE != ms.mPlayer.getVID() ) { -- cgit v1.2.3 From f5bc467cfa7deebabfdab6335c6c3704bc610609 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 31 Aug 2013 02:29:39 +0200 Subject: Scripts/Windows: Test x32 and x64 builds w/ ffmpeg 2.x ! --- make/scripts/tests-x32-dbg.bat | 12 ++++++++---- make/scripts/tests-x32.bat | 9 ++++++--- make/scripts/tests-x64.bat | 1 - make/scripts/tests-x64.sh | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x32-dbg.bat b/make/scripts/tests-x32-dbg.bat index e5e64511d..4c9c3421f 100755 --- a/make/scripts/tests-x32-dbg.bat +++ b/make/scripts/tests-x32-dbg.bat @@ -7,14 +7,17 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl set BLD_DIR=..\%BLD_SUB% +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x32 +set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x32 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01-libav\x32 + REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20120127;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% REM set LIB_DIR=%BLD_DIR%\lib;..\..\gluegen\%BLD_SUB%\obj -REM set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 -REM set LIB_DIR=%FFMPEG_LIB% set LIB_DIR= set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar @@ -37,7 +40,8 @@ REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" "-Djogl.debug=all" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" -set D_ARGS="-Dnewt.debug.Window.KeyEvent" +REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" +set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.GLMediaPlayer.Native" REM set D_ARGS="-Xcheck:jni" "-Xint" "-verbose:jni" set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index 6f262eb5f..1c646fd37 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -7,15 +7,18 @@ set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl set BLD_DIR=..\%BLD_SUB% +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x32 +set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x32 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01-libav\x32 + REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20120127;%PATH% -set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% set BLD_DIR=..\%BLD_SUB% REM set LIB_DIR=..\..\gluegen\%BLD_SUB%\obj;%BLD_DIR%\lib -REM set FFMPEG_LIB=%PROJECT_ROOT%\make\lib\ffmpeg\x32 -REM set LIB_DIR=%FFMPEG_LIB% set LIB_DIR= set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 38ba28fa0..2801e0eb5 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -8,7 +8,6 @@ REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x64 set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x64 REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01-libav\x64 -REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% diff --git a/make/scripts/tests-x64.sh b/make/scripts/tests-x64.sh index 442458603..68937ca4b 100755 --- a/make/scripts/tests-x64.sh +++ b/make/scripts/tests-x64.sh @@ -7,8 +7,8 @@ SDIR=`dirname $0` #export LD_LIBRARY_PATH=/home/sven/libav-9.x/lib:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH=/home/sven/ffmpeg-1.2/lib:$LD_LIBRARY_PATH -export LD_LIBRARY_PATH=/home/sven/libav-10.x/lib:$LD_LIBRARY_PATH -#export LD_LIBRARY_PATH=/home/sven/ffmpeg-2.x/lib:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/home/sven/libav-10.x/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=/home/sven/ffmpeg-2.x/lib:$LD_LIBRARY_PATH if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh -- cgit v1.2.3 From 87fe4c89d1b69773d62c1917594ddf7a724c6d71 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 1 Sep 2013 23:26:43 +0200 Subject: FFMPEGMediaPlayer: Handle use-case of having [av|sw]resample lib, but not compiled for it -> pass Scenario ffmpeg-0.10, where we are not prepared (compiled-in) for sw-resample support. Don't use if compiled in version (CC) is < 0 (n/a), and allow to pass at load time. --- make/scripts/tests-x64.sh | 5 +++-- src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java | 4 ++-- src/jogl/native/libav/ffmpeg_tool.h | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.sh b/make/scripts/tests-x64.sh index 68937ca4b..fe2fc4958 100755 --- a/make/scripts/tests-x64.sh +++ b/make/scripts/tests-x64.sh @@ -3,12 +3,13 @@ SDIR=`dirname $0` #export LD_LIBRARY_PATH=/home/sven/libav-0.8/lib:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/home/sven/ffmpeg-0.10/lib:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH=/home/sven/libav-9.x/lib:$LD_LIBRARY_PATH -#export LD_LIBRARY_PATH=/home/sven/ffmpeg-1.2/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=/home/sven/ffmpeg-1.2/lib:$LD_LIBRARY_PATH #export LD_LIBRARY_PATH=/home/sven/libav-10.x/lib:$LD_LIBRARY_PATH -export LD_LIBRARY_PATH=/home/sven/ffmpeg-2.x/lib:$LD_LIBRARY_PATH +#export LD_LIBRARY_PATH=/home/sven/ffmpeg-2.x/lib:$LD_LIBRARY_PATH if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index c329e880f..33b1867c8 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -194,8 +194,8 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { libAVVersionGood = avCodecMajorVersionCC == avCodecVersion.getMajor() && avFormatMajorVersionCC == avFormatVersion.getMajor() && avUtilMajorVersionCC == avUtilVersion.getMajor() && - ( !avResampleLoaded || avResampleMajorVersionCC == avResampleVersion.getMajor() ) && - ( !swResampleLoaded || swResampleMajorVersionCC == swResampleVersion.getMajor() ) ; + ( !avResampleLoaded || avResampleMajorVersionCC < 0 || avResampleMajorVersionCC == avResampleVersion.getMajor() ) && + ( !swResampleLoaded || swResampleMajorVersionCC < 0 || swResampleMajorVersionCC == swResampleVersion.getMajor() ) ; if( !libAVVersionGood ) { System.err.println("LIB_AV Not Matching Compile-Time / Runtime Major-Version"); } diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index 61d121f24..97e60afce 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -96,10 +96,10 @@ typedef void (APIENTRYP PFNGLFINISH) (void); #define END_OF_STREAM_PTS 0x7FFFFFFF /** Since 54.0.0.1 */ -#define AV_HAS_API_AVRESAMPLE(pAV) ( pAV->avresampleVersion != 0 ) +#define AV_HAS_API_AVRESAMPLE(pAV) ( ( LIBAVRESAMPLE_VERSION_MAJOR >= 0 ) && ( pAV->avresampleVersion != 0 ) ) /** Since 55.0.0.1 */ -#define AV_HAS_API_SWRESAMPLE(pAV) ( pAV->swresampleVersion != 0 ) +#define AV_HAS_API_SWRESAMPLE(pAV) ( ( LIBSWRESAMPLE_VERSION_MAJOR >= 0 ) && ( pAV->swresampleVersion != 0 ) ) #define MAX_INT(a,b) ( (a >= b) ? a : b ) #define MIN_INT(a,b) ( (a <= b) ? a : b ) -- cgit v1.2.3 From 4beef4fe856690b070ba06a6caf4515aebd7171b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 2 Sep 2013 09:11:50 +0200 Subject: X11GLXDrawableFactory.Shutdown: Disable shared context destruction since it may lead to a JVM freeze .. .. on ATI fglrx driver 32bit on 64bit w/ a frozen shared GL context involved. Hence we have to rely on the driver cleanup when JVM hits 'exit', equal to the Windows implementation. --- make/scripts/tests.sh | 9 ++++++--- .../classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java | 4 ++-- .../opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 493fa2744..4c2da6571 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -111,7 +111,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" - #D_ARGS="-Djogl.debug.Animator" + #D_ARGS="-Djogl.debug.Animator -Djogl.debug.GLDrawable -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" @@ -132,7 +132,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" - D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" @@ -320,7 +320,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # core/newt (testnoawt and testawt) @@ -620,6 +620,9 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # Most likely this is a multi-threaded client and XInitThreads has not been called # ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed. #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* # NEW diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java index 91beddb02..04e0fa60d 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXDrawableFactory.java @@ -336,8 +336,8 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl { } if (null != sr.context) { - // may cause JVM SIGSEGV: - sr.context.destroy(); // will also pull the dummy MutableSurface + // may cause JVM SIGSEGV, or freeze (ATI fglrx 32on64 shared ctx): + // sr.context.destroy(); // will also pull the dummy MutableSurface sr.context = null; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java index 0d1f58c1e..967c94ec6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListNEWT2.java @@ -136,9 +136,9 @@ public class TestSharedContextListNEWT2 extends UITestCase { f2.destroy(); f3.destroy(); - f1.getAnimator().stop(); - f2.getAnimator().stop(); - f3.getAnimator().stop(); + // f1.getAnimator().stop(); + // f2.getAnimator().stop(); + // f3.getAnimator().stop(); releaseShared(); } -- cgit v1.2.3 From 8215886492eca47c036ed35861956290d2f3e898 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 3 Sep 2013 16:29:00 +0200 Subject: Test scripts .. --- make/scripts/tests.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4c2da6571..c391f7cdc 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -315,6 +315,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.TestTiledRendering1GL2 $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.TestTiledRendering2GL2 $* + # # av demos # @@ -619,10 +622,8 @@ function testawtswt() { # ATI/Linux XCB Unknown request in queue while dequeuing # Most likely this is a multi-threaded client and XInitThreads has not been called # ../../src/xcb_io.c:178: dequeue_pending_request: Assertion `!xcb_xlib_unknown_req_in_deq' failed. -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT $* # NEW -- cgit v1.2.3 From b1c921edf01605e1626953c5cf76f72845b01746 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 4 Sep 2013 16:56:19 +0200 Subject: TileRenderer: Unify TileRenderer, add RandomTileRenderer (both utilizing GLPixelBuffer, and pre/post GLEventListener) --- make/scripts/tests.sh | 10 +- .../com/jogamp/opengl/util/RandomTileRenderer.java | 367 +++++++++++++++++++++ .../com/jogamp/opengl/util/TileRenderer.java | 347 ++++++++++++++----- .../com/jogamp/opengl/util/TileRenderer2.java | 129 -------- .../jogl/demos/gl2/TestTiledRendering1GL2.java | 172 ---------- .../jogl/demos/gl2/TestTiledRendering2GL2.java | 135 -------- .../jogl/tile/TestRandomTiledRendering2GL2.java | 167 ++++++++++ .../junit/jogl/tile/TestTiledRendering1GL2.java | 168 ++++++++++ .../junit/jogl/tile/TestTiledRendering2GL2.java | 154 +++++++++ 9 files changed, 1126 insertions(+), 523 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java delete mode 100644 src/jogl/classes/com/jogamp/opengl/util/TileRenderer2.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TestTiledRendering1GL2.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TestTiledRendering2GL2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c391f7cdc..bbb8c6ece 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -315,9 +315,6 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.TestTiledRendering1GL2 $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.TestTiledRendering2GL2 $* - # # av demos # @@ -325,6 +322,13 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.TestTiledRendering1GL2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +# +# tile rendring / printing w/ & w/o AWT +# +testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2 $* +testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2 $* +testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2 $* + # # core/newt (testnoawt and testawt) # diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java new file mode 100644 index 000000000..ac420da3d --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java @@ -0,0 +1,367 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util; + +import javax.media.nativewindow.util.Dimension; +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES3; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; + +/** + * Variation of {@link TileRenderer} w/o using fixed tiles but arbitrary rectangular regions. + */ +public class RandomTileRenderer { + private final Dimension imageSize = new Dimension(0, 0); + private final GLPixelStorageModes psm = new GLPixelStorageModes(); + + private GLPixelBuffer imageBuffer; + private GLPixelBuffer tileBuffer; + private PMVMatrixCallback pmvMatrixCB = null; + private int tX = 0; + private int tY = 0; + private int tWidth = 0; + private int tHeight = 0; + + private GLAutoDrawable glad; + private GLEventListener[] listeners; + private boolean[] listenersInit; + private GLEventListener glEventListenerPre = null; + private GLEventListener glEventListenerPost = null; + + public static interface PMVMatrixCallback { + void reshapePMVMatrix(GL gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight); + } + + /** + * Creates a new TileRenderer object + */ + public RandomTileRenderer() { + } + + public final void setPMVMatrixCallback(PMVMatrixCallback pmvMatrixCB) { + assert ( null != pmvMatrixCB ); + this.pmvMatrixCB = pmvMatrixCB; + } + + /** + * Specify a buffer the tiles to be copied to. This is not + * necessary for the creation of the final image, but useful if you + * want to inspect each tile in turn. + * + * @param buffer The buffer itself. Must be large enough to contain a random tile + */ + public final void setTileBuffer(GLPixelBuffer buffer) { + tileBuffer = buffer; + } + + /** @see #setTileBuffer(GLPixelBuffer) */ + public final GLPixelBuffer getTileBuffer() { return tileBuffer; } + + /** + * Sets the desired size of the final image + * + * @param width + * The width of the final image + * @param height + * The height of the final image + */ + public final void setImageSize(int width, int height) { + imageSize.setWidth(width); + imageSize.setHeight(height); + } + + /** @see #setImageSize(int, int) */ + public final Dimension getImageSize() { return imageSize; } + + /** + * Sets the buffer in which to store the final image + * + * @param buffer the buffer itself, must be large enough to hold the final image + */ + public final void setImageBuffer(GLPixelBuffer buffer) { + imageBuffer = buffer; + } + + /** @see #setImageBuffer(GLPixelBuffer) */ + public final GLPixelBuffer getImageBuffer() { return imageBuffer; } + + /** + * Begins rendering a tile. + *

        + * Methods modifies the viewport, hence user shall reset the viewport when finishing tile rendering. + *

        + *

        + * The projection matrix stack should be + * left alone after calling this method! + *

        + * + * @param gl The gl context + * @throws IllegalStateException + * @throws IllegalArgumentException + */ + public final void beginTile(GL2ES3 gl, int tX, int tY, int tWidth, int tHeight) throws IllegalStateException, IllegalArgumentException { + if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { + throw new IllegalStateException("Image size has not been set"); + } + if( null == this.pmvMatrixCB ) { + throw new IllegalStateException("pmvMatrixCB has not been set"); + } + if( 0 > tX || 0 > tX ) { + throw new IllegalArgumentException("Tile pos must be >= 0/0"); + } + if( 0 >= tWidth || 0 >= tHeight ) { + throw new IllegalArgumentException("Tile size must be > 0x0"); + } + + gl.glViewport( 0, 0, tWidth, tHeight ); + pmvMatrixCB.reshapePMVMatrix(gl, tX, tY, tWidth, tHeight, imageSize.getWidth(), imageSize.getHeight()); + + this.tX = tX; + this.tY = tY; + this.tWidth = tWidth; + this.tHeight = tHeight; + } + + /** + * Must be called after rendering the scene + * + * @param gl + * the gl context + * @return true if there are more tiles to be rendered, false if + * the final image is complete + */ + public void endTile( GL2ES3 gl ) { + if( 0 >= tWidth || 0 >= tHeight ) { + throw new IllegalStateException("beginTile(..) has not been called"); + } + + // be sure OpenGL rendering is finished + gl.glFlush(); + + // save current glPixelStore values + psm.save(gl); + + final int tmp[] = new int[1]; + + if( tileBuffer != null ) { + final GLPixelAttributes pixelAttribs = tileBuffer.pixelAttributes; + final int srcX = 0; + final int srcY = 0; + final int srcWidth = tWidth; + final int srcHeight = tHeight; + final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.bytesPerPixel, srcWidth, srcHeight, 1, true); + tileBuffer.clear(); + if( tileBuffer.requiresNewBuffer(gl, srcWidth, srcHeight, readPixelSize) ) { + throw new IndexOutOfBoundsException("Required " + readPixelSize + " bytes of buffer, only had " + tileBuffer); + } + gl.glReadPixels( srcX, srcY, srcWidth, srcHeight, pixelAttribs.format, pixelAttribs.type, tileBuffer.buffer); + // be sure OpenGL rendering is finished + gl.glFlush(); + tileBuffer.position( readPixelSize ); + tileBuffer.flip(); + } + + if( imageBuffer != null ) { + final GLPixelAttributes pixelAttribs = imageBuffer.pixelAttributes; + final int srcX = 0; + final int srcY = 0; + final int srcWidth = tWidth; + final int srcHeight = tHeight; + + /* setup pixel store for glReadPixels */ + final int rowLength = imageSize.getWidth(); + psm.setPackRowLength(gl, rowLength); + psm.setPackAlignment(gl, 1); + + /* read the tile into the final image */ + final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.bytesPerPixel, srcWidth, srcHeight, 1, true); + + final int ibPos = ( tX + ( tY * rowLength ) ) * pixelAttribs.bytesPerPixel; // skipPixels + skipRows + final int ibLim = ibPos + readPixelSize; + imageBuffer.clear(); + if( imageBuffer.requiresNewBuffer(gl, srcWidth, srcHeight, readPixelSize) ) { + throw new IndexOutOfBoundsException("Required " + ibLim + " bytes of buffer, only had " + imageBuffer); + } + imageBuffer.position(ibPos); + + gl.glReadPixels( srcX, srcY, srcWidth, srcHeight, pixelAttribs.format, pixelAttribs.type, imageBuffer.buffer); + // be sure OpenGL rendering is finished + gl.glFlush(); + imageBuffer.position( ibLim ); + imageBuffer.flip(); + } + + /* restore previous glPixelStore values */ + psm.restore(gl); + + this.tX = 0; + this.tY = 0; + this.tWidth = 0; + this.tHeight = 0; + } + + /** + * + *

        + * Sets the size of the tiles to use in rendering. The actual + * effective size of the tile depends on the border size, ie ( + * width - 2*border ) * ( height - 2 * border ) + *

        + * @param glad + * @throws IllegalStateException if an {@link GLAutoDrawable} is already attached + */ + public void attachAutoDrawable(GLAutoDrawable glad, PMVMatrixCallback pmvMatrixCB) throws IllegalStateException { + if( null != this.glad ) { + throw new IllegalStateException("GLAutoDrawable already attached"); + } + this.glad = glad; + setPMVMatrixCallback(pmvMatrixCB); + + final int aSz = glad.getGLEventListenerCount(); + listeners = new GLEventListener[aSz]; + listenersInit = new boolean[aSz]; + for(int i=0; ihttp://www.mesa3d.org/brianp/TR.html. + * + * Copyright (C) 1997-2005 Brian Paul. + * Licensed under BSD-compatible terms with permission of the author. + * See LICENSE.txt for license information. + */ package com.jogamp.opengl.util; -import java.nio.ByteBuffer; - import javax.media.nativewindow.util.Dimension; import javax.media.opengl.GL; import javax.media.opengl.GL2ES3; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; + +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; /** * A fairly direct port of Brian Paul's tile rendering library, found @@ -23,12 +61,6 @@ import javax.media.opengl.GL2ES3; * @author ryanm, sgothel */ public class TileRenderer { - - protected static final boolean DEBUG = true; - protected static final int DEFAULT_TILE_WIDTH = 256; - protected static final int DEFAULT_TILE_HEIGHT = 256; - protected static final int DEFAULT_TILE_BORDER = 0; - /** * The width of a tile */ @@ -86,29 +118,37 @@ public class TileRenderer { */ public static final int TR_BOTTOM_TO_TOP = 2; - protected final Dimension imageSize = new Dimension(0, 0); - protected final Dimension tileSize = new Dimension(DEFAULT_TILE_WIDTH, DEFAULT_TILE_HEIGHT); - protected final Dimension tileSizeNB = new Dimension(DEFAULT_TILE_WIDTH - 2 * DEFAULT_TILE_BORDER, DEFAULT_TILE_HEIGHT - 2 * DEFAULT_TILE_BORDER); - protected final int[] userViewport = new int[ 4 ]; - protected final GLPixelStorageModes psm = new GLPixelStorageModes(); - - protected int tileBorder = DEFAULT_TILE_BORDER; - protected int imageFormat; - protected int imageType; - protected ByteBuffer imageBuffer; - protected int tileFormat; - protected int tileType; - protected ByteBuffer tileBuffer; - protected int rowOrder = TR_BOTTOM_TO_TOP; - protected int rows; - protected int columns; - protected int currentTile = -1; - protected int currentTileWidth; - protected int currentTileHeight; - protected int currentRow; - protected int currentColumn; - protected PMVMatrixCallback pmvMatrixCB = null; - + private static final boolean DEBUG = true; + private static final int DEFAULT_TILE_WIDTH = 256; + private static final int DEFAULT_TILE_HEIGHT = 256; + private static final int DEFAULT_TILE_BORDER = 0; + + private final Dimension imageSize = new Dimension(0, 0); + private final Dimension tileSize = new Dimension(DEFAULT_TILE_WIDTH, DEFAULT_TILE_HEIGHT); + private final Dimension tileSizeNB = new Dimension(DEFAULT_TILE_WIDTH - 2 * DEFAULT_TILE_BORDER, DEFAULT_TILE_HEIGHT - 2 * DEFAULT_TILE_BORDER); + private final int[] userViewport = new int[ 4 ]; + private final GLPixelStorageModes psm = new GLPixelStorageModes(); + + private int tileBorder = DEFAULT_TILE_BORDER; + private GLPixelBuffer imageBuffer; + private GLPixelBuffer tileBuffer; + private int rowOrder = TR_BOTTOM_TO_TOP; + private int rows; + private int columns; + private int currentTile = -1; + private int currentTileWidth; + private int currentTileHeight; + private int currentRow; + private int currentColumn; + private PMVMatrixCallback pmvMatrixCB = null; + private boolean beginCalled = false; + + private GLAutoDrawable glad; + private GLEventListener[] listeners; + private boolean[] listenersInit; + private GLEventListener glEventListenerPre = null; + private GLEventListener glEventListenerPost = null; + public static interface PMVMatrixCallback { void reshapePMVMatrix(GL gl, int tileNum, int tileColumn, int tileRow, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight); } @@ -136,12 +176,12 @@ public class TileRenderer { * thickness > 1. */ public final void setTileSize(int width, int height, int border) { - assert ( border >= 0 ); - assert ( width >= 1 ); - assert ( height >= 1 ); - assert ( width >= 2 * border ); - assert ( height >= 2 * border ); - + if( 0 > border ) { + throw new IllegalArgumentException("Tile border must be >= 0"); + } + if( 2 * border >= width || 2 * border >= height ) { + throw new IllegalArgumentException("Tile size must be > 0x0 minus 2*border"); + } tileBorder = border; tileSize.setWidth( width ); tileSize.setHeight( height ); @@ -158,7 +198,7 @@ public class TileRenderer { /** * Sets up the number of rows and columns needed */ - protected final void setup() throws IllegalStateException { + private final void setup() throws IllegalStateException { columns = ( imageSize.getWidth() + tileSizeNB.getWidth() - 1 ) / tileSizeNB.getWidth(); rows = ( imageSize.getHeight() + tileSizeNB.getHeight() - 1 ) / tileSizeNB.getHeight(); currentTile = 0; @@ -182,20 +222,15 @@ public class TileRenderer { * necessary for the creation of the final image, but useful if you * want to inspect each tile in turn. * - * @param format - * Interpreted as in glReadPixels - * @param type - * Interpreted as in glReadPixels - * @param buffer - * The buffer itself. Must be large enough to contain a - * tile, minus any borders + * @param buffer The buffer itself. Must be large enough to contain a tile, minus any borders */ - public final void setTileBuffer(int format, int type, ByteBuffer buffer) { - tileFormat = format; - tileType = type; + public final void setTileBuffer(GLPixelBuffer buffer) { tileBuffer = buffer; } + /** @see #setTileBuffer(GLPixelBuffer) */ + public final GLPixelBuffer getTileBuffer() { return tileBuffer; } + /** * Sets the desired size of the final image * @@ -210,23 +245,21 @@ public class TileRenderer { setup(); } + /** @see #setImageSize(int, int) */ + public final Dimension getImageSize() { return imageSize; } + /** * Sets the buffer in which to store the final image * - * @param format - * Interpreted as in glReadPixels - * @param type - * Interpreted as in glReadPixels - * @param image - * the buffer itself, must be large enough to hold the - * final image + * @param image the buffer itself, must be large enough to hold the final image */ - public final void setImageBuffer(int format, int type, ByteBuffer buffer) { - imageFormat = format; - imageType = type; + public final void setImageBuffer(GLPixelBuffer buffer) { imageBuffer = buffer; } + /** @see #setImageBuffer(GLPixelBuffer) */ + public final GLPixelBuffer getImageBuffer() { return imageBuffer; } + /** * Gets the parameters of this TileRenderer object * @@ -294,8 +327,9 @@ public class TileRenderer { *

        * * @param gl The gl context + * @throws IllegalStateException */ - public final void beginTile( GL2ES3 gl ) { + public final void beginTile( GL2ES3 gl ) throws IllegalStateException { if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { throw new IllegalStateException("Image size has not been set"); } @@ -342,8 +376,8 @@ public class TileRenderer { tW = imageSize.getWidth() - ( columns - 1 ) * ( tileSizeNB.getWidth() ) + 2 * border; } - final int tX = currentColumn * tileSizeNB.getWidth() - border; - final int tY = currentRow * tileSizeNB.getHeight() - border; + final int tX = currentColumn * tileSizeNB.getWidth(); + final int tY = currentRow * tileSizeNB.getHeight(); final int preTileWidth = currentTileWidth; final int preTileHeight = currentTileHeight; @@ -359,6 +393,7 @@ public class TileRenderer { gl.glViewport( 0, 0, tW, tH ); pmvMatrixCB.reshapePMVMatrix(gl, currentTile, currentColumn, currentRow, tX, tY, tW, tH, imageSize.getWidth(), imageSize.getHeight()); + beginCalled = true; } /** @@ -368,9 +403,12 @@ public class TileRenderer { * the gl context * @return true if there are more tiles to be rendered, false if * the final image is complete + * @throws IllegalStateException */ - public boolean endTile( GL2ES3 gl ) { - assert ( currentTile >= 0 ); + public boolean endTile( GL2ES3 gl ) throws IllegalStateException { + if( !beginCalled ) { + throw new IllegalStateException("beginTile(..) has not been called"); + } // be sure OpenGL rendering is finished gl.glFlush(); @@ -381,17 +419,17 @@ public class TileRenderer { final int tmp[] = new int[1]; if( tileBuffer != null ) { - int srcX = tileBorder; - int srcY = tileBorder; - int srcWidth = tileSizeNB.getWidth(); - int srcHeight = tileSizeNB.getHeight(); - final int bytesPerPixel = GLBuffers.bytesPerPixel(tileFormat, tileType); - final int readPixelSize = GLBuffers.sizeof(gl, tmp, bytesPerPixel, srcWidth, srcHeight, 1, true); + final GLPixelAttributes pixelAttribs = tileBuffer.pixelAttributes; + final int srcX = tileBorder; + final int srcY = tileBorder; + final int srcWidth = tileSizeNB.getWidth(); + final int srcHeight = tileSizeNB.getHeight(); + final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.bytesPerPixel, srcWidth, srcHeight, 1, true); tileBuffer.clear(); - if( tileBuffer.limit() < readPixelSize ) { - throw new IndexOutOfBoundsException("Required " + readPixelSize + " bytes of buffer, only had " + tileBuffer.limit()); + if( tileBuffer.requiresNewBuffer(gl, srcWidth, srcHeight, readPixelSize) ) { + throw new IndexOutOfBoundsException("Required " + readPixelSize + " bytes of buffer, only had " + tileBuffer); } - gl.glReadPixels( srcX, srcY, srcWidth, srcHeight, tileFormat, tileType, tileBuffer ); + gl.glReadPixels( srcX, srcY, srcWidth, srcHeight, pixelAttribs.format, pixelAttribs.type, tileBuffer.buffer); // be sure OpenGL rendering is finished gl.glFlush(); tileBuffer.position( readPixelSize ); @@ -399,10 +437,11 @@ public class TileRenderer { } if( imageBuffer != null ) { - int srcX = tileBorder; - int srcY = tileBorder; - int srcWidth = currentTileWidth - 2 * tileBorder; - int srcHeight = currentTileHeight - 2 * tileBorder; + final GLPixelAttributes pixelAttribs = imageBuffer.pixelAttributes; + final int srcX = tileBorder; + final int srcY = tileBorder; + final int srcWidth = currentTileWidth - 2 * tileBorder; + final int srcHeight = currentTileHeight - 2 * tileBorder; /* setup pixel store for glReadPixels */ final int rowLength = imageSize.getWidth(); @@ -410,20 +449,19 @@ public class TileRenderer { psm.setPackAlignment(gl, 1); /* read the tile into the final image */ - final int bytesPerPixel = GLBuffers.bytesPerPixel(imageFormat, imageType); - final int readPixelSize = GLBuffers.sizeof(gl, tmp, bytesPerPixel, srcWidth, srcHeight, 1, true); + final int readPixelSize = GLBuffers.sizeof(gl, tmp, pixelAttribs.bytesPerPixel, srcWidth, srcHeight, 1, true); - final int skipPixels = tileSizeNB.getWidth() * currentColumn; - final int skipRows = tileSizeNB.getHeight() * currentRow; - final int ibPos = ( skipPixels + ( skipRows * rowLength ) ) * bytesPerPixel; + final int skipPixels = currentColumn * tileSizeNB.getWidth(); + final int skipRows = currentRow * tileSizeNB.getHeight(); + final int ibPos = ( skipPixels + ( skipRows * rowLength ) ) * pixelAttribs.bytesPerPixel; final int ibLim = ibPos + readPixelSize; imageBuffer.clear(); - if( imageBuffer.limit() < ibLim ) { - throw new IndexOutOfBoundsException("Required " + ibLim + " bytes of buffer, only had " + imageBuffer.limit()); + if( imageBuffer.requiresNewBuffer(gl, srcWidth, srcHeight, readPixelSize) ) { + throw new IndexOutOfBoundsException("Required " + ibLim + " bytes of buffer, only had " + imageBuffer); } imageBuffer.position(ibPos); - gl.glReadPixels( srcX, srcY, srcWidth, srcHeight, imageFormat, imageType, imageBuffer); + gl.glReadPixels( srcX, srcY, srcWidth, srcHeight, pixelAttribs.format, pixelAttribs.type, imageBuffer.buffer); // be sure OpenGL rendering is finished gl.glFlush(); imageBuffer.position( ibLim ); @@ -433,6 +471,8 @@ public class TileRenderer { /* restore previous glPixelStore values */ psm.restore(gl); + beginCalled = false; + /* increment tile counter, return 1 if more tiles left to render */ currentTile++; if( currentTile >= rows * columns ) { @@ -444,4 +484,143 @@ public class TileRenderer { return true; } } + + /** + * + *

        + * Sets the size of the tiles to use in rendering. The actual + * effective size of the tile depends on the border size, ie ( + * width - 2*border ) * ( height - 2 * border ) + *

        + * @param glad + * @param border + * The width of the borders on each tile. This is needed + * to avoid artifacts when rendering lines or points with + * thickness > 1. + * @throws IllegalStateException if an {@link GLAutoDrawable} is already attached + */ + public void attachAutoDrawable(GLAutoDrawable glad, int border, PMVMatrixCallback pmvMatrixCB) throws IllegalStateException { + if( null != this.glad ) { + throw new IllegalStateException("GLAutoDrawable already attached"); + } + this.glad = glad; + setTileSize(glad.getWidth(), glad.getHeight(), border); + setPMVMatrixCallback(pmvMatrixCB); + + final int aSz = glad.getGLEventListenerCount(); + listeners = new GLEventListener[aSz]; + listenersInit = new boolean[aSz]; + for(int i=0; i - * Enhanced for {@link GLAutoDrawable} usage. - *

        - */ -public class TileRenderer2 extends TileRenderer { - private GLAutoDrawable glad; - private GLEventListener[] listeners; - private boolean[] listenersInit; - - /** - * Creates a new TileRenderer object - */ - public TileRenderer2() { - glad = null; - listeners = null; - listenersInit = null; - } - - /** - * - *

        - * Sets the size of the tiles to use in rendering. The actual - * effective size of the tile depends on the border size, ie ( - * width - 2*border ) * ( height - 2 * border ) - *

        - * @param glad - * @param border - * The width of the borders on each tile. This is needed - * to avoid artifacts when rendering lines or points with - * thickness > 1. - * @throws IllegalStateException if an {@link GLAutoDrawable} is already attached - */ - public void attachAutoDrawable(GLAutoDrawable glad, int border, PMVMatrixCallback pmvMatrixCB) throws IllegalStateException { - if( null != this.glad ) { - throw new IllegalStateException("GLAutoDrawable already attached"); - } - this.glad = glad; - setTileSize(glad.getWidth(), glad.getHeight(), border); - setPMVMatrixCallback(pmvMatrixCB); - - final int aSz = glad.getGLEventListenerCount(); - listeners = new GLEventListener[aSz]; - listenersInit = new boolean[aSz]; - for(int i=0; i imageWidth ) { - float a = (float)imageHeight / (float)imageWidth; - left = -1.0f; - right = 1.0f; - bottom = -a; - top = a; - } else { - float a = (float)imageWidth / (float)imageHeight; - left = -a; - right = a; - bottom = -1.0f; - top = 1.0f; - } - final float w = right - left; - final float h = top - bottom; - final float l = left + w * tileX / imageWidth; - final float r = l + w * tileWidth / imageWidth; - final float b = bottom + h * tileY / imageHeight; - final float t = b + h * tileHeight / imageHeight; - - final float _w = r - l; - final float _h = t - b; - System.err.println(">> [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); - gl.glFrustum(l, r, b, t, 5.0f, 60.0f); - - gl.glMatrixMode(GL2.GL_MODELVIEW); - } - }; - - renderer.setTileSize(glad.getWidth(), glad.getHeight(), 0); - renderer.setPMVMatrixCallback(pmvMatrixCallback); - renderer.setImageSize(imageWidth, imageHeight); - renderer.setImageBuffer(GL2.GL_BGR, GL.GL_UNSIGNED_BYTE, buf); - - glad.addGLEventListener( new GLEventListener() { - @Override - public void init(GLAutoDrawable drawable) { - System.err.println("XXX2: "+drawable); - } - @Override - public void dispose(GLAutoDrawable drawable) { - } - @Override - public void display(GLAutoDrawable drawable) { - renderer.beginTile(drawable.getGL().getGL2()); - } - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - }); - final Gears gears = new Gears(); - gears.setDoRotation(false); - glad.addGLEventListener( gears ); - glad.addGLEventListener( new GLEventListener() { - @Override - public void init(GLAutoDrawable drawable) { - } - @Override - public void dispose(GLAutoDrawable drawable) { - } - @Override - public void display(GLAutoDrawable drawable) { - renderer.endTile(drawable.getGL().getGL2()); - } - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - }); - - do { - glad.display(); - } while ( !renderer.eot() ); - - glad.destroy(); - - // Close things up and/or write image using ImageIO - if (tga != null) { - tga.close(); - } else { - ImageUtil.flipImageVertically(img); - if (!ImageIO.write(img, IOUtil.getFileSuffix(file), file)) { - System.err.println("Error writing file using ImageIO (unsupported file format?)"); - } - } - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TestTiledRendering2GL2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TestTiledRendering2GL2.java deleted file mode 100644 index 2f04f5a0c..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TestTiledRendering2GL2.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.jogamp.opengl.test.junit.jogl.demos.gl2; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.util.TGAWriter; -import com.jogamp.opengl.util.TileRenderer; -import com.jogamp.opengl.util.TileRenderer2; - -import java.awt.image.BufferedImage; -import java.awt.image.DataBufferByte; -import java.io.File; -import java.io.IOException; -import java.nio.ByteBuffer; -import javax.imageio.ImageIO; -import javax.media.opengl.GL; -import javax.media.opengl.GL2; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLOffscreenAutoDrawable; - -/** Demonstrates the TileRenderer class by rendering a large version - of the Gears demo to the specified file. */ - -public class TestTiledRendering2GL2 { - - public static void main(String[] args) throws IOException { - - if (args.length != 1) { - System.out.println("Usage: java TiledRendering [output file name]"); - System.out.println("Writes output (a large version of the Gears demo) to"); - System.out.println("the specified file, using either ImageIO or the fast TGA writer"); - System.out.println("depending on the file extension."); - System.exit(1); - } - - String filename = args[0]; - File file = new File(filename); - - GLCapabilities caps = new GLCapabilities(null); - caps.setDoubleBuffered(false); - - if (!GLDrawableFactory.getFactory(caps.getGLProfile()).canCreateGLPbuffer(null, caps.getGLProfile())) { - System.out.println("Demo requires pbuffer support"); - System.exit(1); - } - - // Use a pbuffer for rendering - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); - - final Gears gears = new Gears(); - gears.setDoRotation(false); - glad.addGLEventListener( gears ); - - // Fix the image size for now - // final int imageWidth = glad.getWidth() * 16; - // final int imageHeight = glad.getHeight() * 12; - final int imageWidth = glad.getWidth() * 2; - final int imageHeight = glad.getHeight() * 2; - - // Figure out the file format - TGAWriter tga = null; - BufferedImage img = null; - ByteBuffer buf = null; - - if (filename.endsWith(".tga")) { - tga = new TGAWriter(); - tga.open(file, - imageWidth, - imageHeight, - false); - buf = tga.getImageData(); - } else { - img = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_3BYTE_BGR); - buf = ByteBuffer.wrap(((DataBufferByte) img.getRaster().getDataBuffer()).getData()); - } - - // Initialize the tile rendering library - final TileRenderer2 renderer = new TileRenderer2(); - final TileRenderer.PMVMatrixCallback pmvMatrixCallback = new TileRenderer.PMVMatrixCallback() { - public void reshapePMVMatrix(GL _gl, int tileNum, int tileColumn, int tileRow, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { - final GL2 gl = _gl.getGL2(); - gl.glMatrixMode( GL2.GL_PROJECTION ); - gl.glLoadIdentity(); - - /* compute projection parameters */ - float left, right, bottom, top; - if( imageHeight > imageWidth ) { - float a = (float)imageHeight / (float)imageWidth; - left = -1.0f; - right = 1.0f; - bottom = -a; - top = a; - } else { - float a = (float)imageWidth / (float)imageHeight; - left = -a; - right = a; - bottom = -1.0f; - top = 1.0f; - } - final float w = right - left; - final float h = top - bottom; - final float l = left + w * tileX / imageWidth; - final float r = l + w * tileWidth / imageWidth; - final float b = bottom + h * tileY / imageHeight; - final float t = b + h * tileHeight / imageHeight; - - final float _w = r - l; - final float _h = t - b; - System.err.println(">> [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); - gl.glFrustum(l, r, b, t, 5.0f, 60.0f); - - gl.glMatrixMode(GL2.GL_MODELVIEW); - } - }; - - renderer.attachAutoDrawable(glad, 0, pmvMatrixCallback); - renderer.setImageSize(imageWidth, imageHeight); - renderer.setImageBuffer(GL2.GL_BGR, GL.GL_UNSIGNED_BYTE, buf); - - while ( renderer.display() ); - - renderer.detachAutoDrawable(); - - glad.destroy(); - - // Close things up and/or write image using ImageIO - if (tga != null) { - tga.close(); - } else { - if (!ImageIO.write(img, IOUtil.getFileSuffix(file), file)) { - System.err.println("Error writing file using ImageIO (unsupported file format?)"); - } - } - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java new file mode 100644 index 000000000..1d917efb9 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java @@ -0,0 +1,167 @@ +package com.jogamp.opengl.test.junit.jogl.tile; + +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.GLPixelBuffer; +import com.jogamp.opengl.util.RandomTileRenderer; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; + +import java.io.File; +import java.io.IOException; +import javax.media.opengl.GL; +import javax.media.opengl.GL2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLOffscreenAutoDrawable; + +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +/** Demonstrates the RandomTileRenderer class by rendering a large version + of the Gears demo to the specified file. */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestRandomTiledRendering2GL2 extends UITestCase { + static long duration = 500; // ms + + @Test + public void test01() throws IOException { + doTest(); + } + + void doTest() throws IOException { + GLCapabilities caps = new GLCapabilities(null); + caps.setDoubleBuffered(false); + + // Use a pbuffer for rendering + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); + + final Gears gears = new Gears(); + gears.setDoRotation(false); + glad.addGLEventListener( gears ); + + // Fix the image size for now + final int imageWidth = glad.getWidth() * 6; + final int imageHeight = glad.getHeight() * 4; + + final String filename = this.getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); + final File file = new File(filename); + + // Initialize the tile rendering library + final RandomTileRenderer renderer = new RandomTileRenderer(); + final RandomTileRenderer.PMVMatrixCallback pmvMatrixCallback = new RandomTileRenderer.PMVMatrixCallback() { + public void reshapePMVMatrix(GL _gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { + final GL2 gl = _gl.getGL2(); + gl.glMatrixMode( GL2.GL_PROJECTION ); + gl.glLoadIdentity(); + + /* compute projection parameters */ + float left, right, bottom, top; + if( imageHeight > imageWidth ) { + float a = (float)imageHeight / (float)imageWidth; + left = -1.0f; + right = 1.0f; + bottom = -a; + top = a; + } else { + float a = (float)imageWidth / (float)imageHeight; + left = -a; + right = a; + bottom = -1.0f; + top = 1.0f; + } + final float w = right - left; + final float h = top - bottom; + final float l = left + w * tileX / imageWidth; + final float r = l + w * tileWidth / imageWidth; + final float b = bottom + h * tileY / imageHeight; + final float t = b + h * tileHeight / imageHeight; + + final float _w = r - l; + final float _h = t - b; + System.err.println(">> [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); + gl.glFrustum(l, r, b, t, 5.0f, 60.0f); + + gl.glMatrixMode(GL2.GL_MODELVIEW); + } + }; + renderer.attachAutoDrawable(glad, pmvMatrixCallback); + renderer.setImageSize(imageWidth, imageHeight); + + final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; + final boolean[] flipVertically = { false }; + + final GLEventListener preTileGLEL = new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); + System.err.println("XXX: "+pixelAttribs+", gl2gl3 "+gl.isGL2GL3()+", "+gl.getContext().getGLVersion()); + GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); + System.err.println("XXX: "+pixelBuffer); + renderer.setImageBuffer(pixelBuffer); + if( drawable.isGLOriented() ) { + flipVertically[0] = false; + } else { + flipVertically[0] = true; + } + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) {} + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }; + renderer.setGLEventListener(preTileGLEL, null); + + final int w = 50, h = 50; + int dx = 0, dy = 0; + while( dx+w <= imageWidth && dy+h <= imageHeight ) { + renderer.display(dx, dy, w, h); + dx+=w+w/2; + if( dx + w > imageWidth ) { + dx = 0; + dy+=h+h/2; + } + } + + renderer.detachAutoDrawable(); + + glad.destroy(); + + final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); + imageBuffer.clear(); // full size available + System.err.println("XXX2: "+imageBuffer); + final TextureData textureData = new TextureData( + caps.getGLProfile(), + 0 /* internalFormat */, + imageWidth, imageHeight, + 0, + imageBuffer.pixelAttributes, + false, false, + flipVertically[0], + imageBuffer.buffer, + null /* Flusher */); + System.err.println("XXX3: "+textureData.getPixelFormat()+", "+textureData.getPixelAttributes()); + + TextureIO.write(textureData, file); + } + + public static void main(String args[]) { + for(int i=0; i imageWidth ) { + float a = (float)imageHeight / (float)imageWidth; + left = -1.0f; + right = 1.0f; + bottom = -a; + top = a; + } else { + float a = (float)imageWidth / (float)imageHeight; + left = -a; + right = a; + bottom = -1.0f; + top = 1.0f; + } + final float w = right - left; + final float h = top - bottom; + final float l = left + w * tileX / imageWidth; + final float r = l + w * tileWidth / imageWidth; + final float b = bottom + h * tileY / imageHeight; + final float t = b + h * tileHeight / imageHeight; + + final float _w = r - l; + final float _h = t - b; + System.err.println(">> [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); + gl.glFrustum(l, r, b, t, 5.0f, 60.0f); + + gl.glMatrixMode(GL2.GL_MODELVIEW); + } + }; + + renderer.setTileSize(glad.getWidth(), glad.getHeight(), 0); + renderer.setPMVMatrixCallback(pmvMatrixCallback); + renderer.setImageSize(imageWidth, imageHeight); + + final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; + final boolean[] flipVertically = { false }; + + glad.addGLEventListener( new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); + GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); + renderer.setImageBuffer(pixelBuffer); + if( drawable.isGLOriented() ) { + flipVertically[0] = false; + } else { + flipVertically[0] = true; + } + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) { + renderer.beginTile(drawable.getGL().getGL2()); + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }); + final Gears gears = new Gears(); + gears.setDoRotation(false); + glad.addGLEventListener( gears ); + glad.addGLEventListener( new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) {} + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) { + renderer.endTile(drawable.getGL().getGL2()); + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }); + + do { + glad.display(); + } while ( !renderer.eot() ); + + glad.destroy(); + + final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); + final TextureData textureData = new TextureData( + caps.getGLProfile(), + 0 /* internalFormat */, + imageWidth, imageHeight, + 0, + imageBuffer.pixelAttributes, + false, false, + flipVertically[0], + imageBuffer.buffer, + null /* Flusher */); + + TextureIO.write(textureData, file); + } + + public static void main(String args[]) { + for(int i=0; i imageWidth ) { + float a = (float)imageHeight / (float)imageWidth; + left = -1.0f; + right = 1.0f; + bottom = -a; + top = a; + } else { + float a = (float)imageWidth / (float)imageHeight; + left = -a; + right = a; + bottom = -1.0f; + top = 1.0f; + } + final float w = right - left; + final float h = top - bottom; + final float l = left + w * tileX / imageWidth; + final float r = l + w * tileWidth / imageWidth; + final float b = bottom + h * tileY / imageHeight; + final float t = b + h * tileHeight / imageHeight; + + final float _w = r - l; + final float _h = t - b; + System.err.println(">> [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); + gl.glFrustum(l, r, b, t, 5.0f, 60.0f); + + gl.glMatrixMode(GL2.GL_MODELVIEW); + } + }; + + renderer.attachAutoDrawable(glad, 0, pmvMatrixCallback); + renderer.setImageSize(imageWidth, imageHeight); + + final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; + final boolean[] flipVertically = { false }; + + final GLEventListener preTileGLEL = new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); + GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); + renderer.setImageBuffer(pixelBuffer); + if( drawable.isGLOriented() ) { + flipVertically[0] = false; + } else { + flipVertically[0] = true; + } + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) {} + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }; + renderer.setGLEventListener(preTileGLEL, null); + + while ( renderer.display() ); + + renderer.detachAutoDrawable(); + + glad.destroy(); + + final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); + final TextureData textureData = new TextureData( + caps.getGLProfile(), + 0 /* internalFormat */, + imageWidth, imageHeight, + 0, + imageBuffer.pixelAttributes, + false, false, + flipVertically[0], + imageBuffer.buffer, + null /* Flusher */); + + TextureIO.write(textureData, file); + } + + public static void main(String args[]) { + for(int i=0; i Date: Thu, 5 Sep 2013 08:32:31 +0200 Subject: TileRenderer*: Enhance API Doc; Cleanup OO; Remove PMVMatrixCallback, use GLEventListener reshape(..) or manual reshape after beginTile(..) method. GLEventListener reshape(..) method should be aware of TileRenderer usage and get the missing tile position and image size from it (-> see Gears example). TestRandomTiledRendering3GL2AWT demos AWT GLCanvas onscreen being used for random tile rendering to produce a PNG file. TestTiledRendering1GL2 is now GLAutoDrawable/GLEventListener agnostic, hence demos plain GLDrawable tile rendering usage. --- make/scripts/tests.sh | 1 + .../com/jogamp/opengl/util/RandomTileRenderer.java | 83 +------ .../com/jogamp/opengl/util/TileRenderer.java | 105 ++------- .../com/jogamp/opengl/util/TileRendererBase.java | 178 ++++++++++---- .../classes/javax/media/opengl/awt/GLCanvas.java | 110 +++++++++ .../opengl/test/junit/jogl/demos/gl2/Gears.java | 115 ++++++--- .../jogl/tile/TestRandomTiledRendering2GL2.java | 102 ++++---- .../jogl/tile/TestRandomTiledRendering3GL2AWT.java | 261 +++++++++++++++++++++ .../junit/jogl/tile/TestTiledRendering1GL2.java | 194 +++++++-------- .../junit/jogl/tile/TestTiledRendering2GL2.java | 103 ++++---- 10 files changed, 844 insertions(+), 408 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bbb8c6ece..61b805215 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -328,6 +328,7 @@ function testawtswt() { testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2 $* testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2 $* testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2 $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java index 0fba1170d..4fcf0b6cc 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java @@ -29,12 +29,14 @@ package com.jogamp.opengl.util; import javax.media.opengl.GL2ES3; import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLEventListener; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; /** * Variation of {@link TileRenderer} w/o using fixed tiles but arbitrary rectangular regions. + *

        + * See {@link TileRendererBase} for details. + *

        */ public class RandomTileRenderer extends TileRendererBase { private boolean tileRectSet = false; @@ -47,8 +49,8 @@ public class RandomTileRenderer extends TileRendererBase { } @Override - public final int getParam(int param) { - switch (param) { + public final int getParam(int pname) { + switch (pname) { case TR_IMAGE_WIDTH: return imageSize.getWidth(); case TR_IMAGE_HEIGHT: @@ -62,7 +64,7 @@ public class RandomTileRenderer extends TileRendererBase { case TR_CURRENT_TILE_HEIGHT: return currentTileHeight; default: - throw new IllegalArgumentException("Invalid enumerant as argument"); + throw new IllegalArgumentException("Invalid pname: "+pname); } } @@ -94,15 +96,14 @@ public class RandomTileRenderer extends TileRendererBase { if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { throw new IllegalStateException("Image size has not been set"); } - if( null == this.pmvMatrixCB ) { - throw new IllegalStateException("pmvMatrixCB has not been set"); - } if( !tileRectSet ) { throw new IllegalStateException("tileRect has not been set"); } gl.glViewport( 0, 0, currentTileWidth, currentTileHeight ); - pmvMatrixCB.reshapePMVMatrix(gl, currentTileXPos, currentTileYPos, currentTileWidth, currentTileHeight, imageSize.getWidth(), imageSize.getHeight()); + // Do not forget to issue: + // reshape( 0, 0, tW, tH ); + // which shall reflect tile renderer fileds: currentTileXPos, currentTileYPos and imageSize beginCalled = true; } @@ -178,75 +179,11 @@ public class RandomTileRenderer extends TileRendererBase { /** * Rendering one tile, by simply calling {@link GLAutoDrawable#display()}. * - * @throws IllegalStateException if no {@link GLAutoDrawable} is {@link #attachToAutoDrawable(GLAutoDrawable, int) attached} + * @throws IllegalStateException if no {@link GLAutoDrawable} is {@link #attachToAutoDrawable(GLAutoDrawable) attached} * or imageSize is not set */ public void display(int tX, int tY, int tWidth, int tHeight) throws IllegalStateException { setTileRect(tX, tY, tWidth, tHeight); display(); } - - protected final GLEventListener getTiledGLEL() { return tiledGLEL; } - private final GLEventListener tiledGLEL = new GLEventListener() { - @Override - public void init(GLAutoDrawable drawable) { - if( null != glEventListenerPre ) { - glEventListenerPre.init(drawable); - } - final int aSz = listenersInit.length; - for(int i=0; i * Enhanced for {@link GL2ES3}. *

        + *

        + * See {@link TileRendererBase} for details. + *

        * * @author ryanm, sgothel */ public class TileRenderer extends TileRendererBase { /** - * The width of a tile + * The width of a tile. See {@link #getParam(int)}. */ public static final int TR_TILE_WIDTH = 7; /** - * The height of a tile + * The height of a tile. See {@link #getParam(int)}. */ public static final int TR_TILE_HEIGHT = 8; /** - * The width of the border around the tiles + * The width of the border around the tiles. See {@link #getParam(int)}. */ public static final int TR_TILE_BORDER = 9; /** - * The number of rows of tiles + * The number of rows of tiles. See {@link #getParam(int)}. */ public static final int TR_ROWS = 10; /** - * The number of columns of tiles + * The number of columns of tiles. See {@link #getParam(int)}. */ public static final int TR_COLUMNS = 11; /** - * The current row number + * The current row number. See {@link #getParam(int)}. */ public static final int TR_CURRENT_ROW = 12; /** - * The current column number + * The current column number. See {@link #getParam(int)}. */ public static final int TR_CURRENT_COLUMN = 13; /** - * The order that the rows are traversed + * The order that the rows are traversed. See {@link #getParam(int)}. */ public static final int TR_ROW_ORDER = 14; /** - * Indicates we are traversing rows from the top to the bottom + * Indicates we are traversing rows from the top to the bottom. See {@link #getParam(int)}. */ public static final int TR_TOP_TO_BOTTOM = 15; /** - * Indicates we are traversing rows from the bottom to the top + * Indicates we are traversing rows from the bottom to the top. See {@link #getParam(int)}. */ public static final int TR_BOTTOM_TO_TOP = 16; @@ -180,8 +182,8 @@ public class TileRenderer extends TileRendererBase { public final boolean eot() { return 0 > currentTile; } @Override - public final int getParam(int param) { - switch (param) { + public final int getParam(int pname) { + switch (pname) { case TR_TILE_WIDTH: return tileSize.getWidth(); case TR_TILE_HEIGHT: @@ -219,7 +221,7 @@ public class TileRenderer extends TileRendererBase { case TR_ROW_ORDER: return rowOrder; default: - throw new IllegalArgumentException("Invalid enumerant as argument"); + throw new IllegalArgumentException("Invalid pname: "+pname); } } @@ -243,9 +245,6 @@ public class TileRenderer extends TileRendererBase { if( 0 >= imageSize.getWidth() || 0 >= imageSize.getHeight() ) { throw new IllegalStateException("Image size has not been set"); } - if( null == this.pmvMatrixCB ) { - throw new IllegalStateException("pmvMatrixCB has not been set"); - } if (currentTile <= 0) { setup(); } @@ -297,7 +296,9 @@ public class TileRenderer extends TileRendererBase { } gl.glViewport( 0, 0, tW, tH ); - pmvMatrixCB.reshapePMVMatrix(gl, currentTileXPos, currentTileYPos, tW, tH, imageSize.getWidth(), imageSize.getHeight()); + // Do not forget to issue: + // reshape( 0, 0, tW, tH ); + // which shall reflect tile renderer fileds: currentTileXPos, currentTileYPos and imageSize beginCalled = true; } @@ -385,72 +386,8 @@ public class TileRenderer extends TileRendererBase { *

        */ @Override - public void attachToAutoDrawable(GLAutoDrawable glad, PMVMatrixCallback pmvMatrixCB) throws IllegalStateException { - super.attachToAutoDrawable(glad, pmvMatrixCB); + public void attachToAutoDrawable(GLAutoDrawable glad) throws IllegalStateException { + super.attachToAutoDrawable(glad); setTileSize(glad.getWidth(), glad.getHeight(), 0); } - - protected final GLEventListener getTiledGLEL() { return tiledGLEL; } - private final GLEventListener tiledGLEL = new GLEventListener() { - @Override - public void init(GLAutoDrawable drawable) { - if( null != glEventListenerPre ) { - glEventListenerPre.init(drawable); - } - final int aSz = listenersInit.length; - for(int i=0; i * Enhanced for {@link GL2ES3}, abstracted to suit {@link TileRenderer} and {@link RandomTileRenderer}. *

        + *
        PMV Matrix Considerations
        + *

        + * The PMV matrix needs to be reshaped in user code + * after calling {@link #beginTile(GL2ES3)}, See {@link #beginTile(GL2ES3)}. + *

        + *

        + * If {@link #attachToAutoDrawable(GLAutoDrawable) attaching to} an {@link GLAutoDrawable}, + * the {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int)} method + * is being called after {@link #beginTile(GL2ES3)}. + * It's implementation shall reshape the PMV matrix according to {@link #beginTile(GL2ES3)}. + *

        * * @author ryanm, sgothel */ public abstract class TileRendererBase { /** - * The width of the final image + * The width of the final image. See {@link #getParam(int)}. */ public static final int TR_IMAGE_WIDTH = 1; /** - * The height of the final image + * The height of the final image. See {@link #getParam(int)}. */ public static final int TR_IMAGE_HEIGHT = 2; /** - * The width of the current tile + * The width of the current tile. See {@link #getParam(int)}. */ public static final int TR_CURRENT_TILE_X_POS = 3; /** - * The height of the current tile + * The height of the current tile. See {@link #getParam(int)}. */ public static final int TR_CURRENT_TILE_Y_POS = 4; /** - * The width of the current tile + * The width of the current tile. See {@link #getParam(int)}. */ public static final int TR_CURRENT_TILE_WIDTH = 5; /** - * The height of the current tile + * The height of the current tile. See {@link #getParam(int)}. */ public static final int TR_CURRENT_TILE_HEIGHT = 6; @@ -88,7 +98,6 @@ public abstract class TileRendererBase { protected final GLPixelStorageModes psm = new GLPixelStorageModes(); protected GLPixelBuffer imageBuffer; protected GLPixelBuffer tileBuffer; - protected PMVMatrixCallback pmvMatrixCB = null; protected boolean beginCalled = false; protected int currentTileXPos; protected int currentTileYPos; @@ -100,33 +109,18 @@ public abstract class TileRendererBase { protected GLEventListener glEventListenerPre = null; protected GLEventListener glEventListenerPost = null; - public static interface PMVMatrixCallback { - void reshapePMVMatrix(GL gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight); - } - protected TileRendererBase() { } /** * Gets the parameters of this TileRenderer object * - * @param param The parameter that is to be retrieved + * @param pname The parameter name that is to be retrieved * @return the value of the parameter - * @throws IllegalArgumentException if param is not handled + * @throws IllegalArgumentException if pname is not handled */ - public abstract int getParam(int param) throws IllegalArgumentException; + public abstract int getParam(int pname) throws IllegalArgumentException; - /** - * @param pmvMatrixCB - * @throws IllegalArgumentException if pmvMatrixCB is null - */ - public final void setPMVMatrixCallback(PMVMatrixCallback pmvMatrixCB) throws IllegalArgumentException { - if( null == pmvMatrixCB ) { - throw new IllegalArgumentException("pmvMatrixCB is null"); - } - this.pmvMatrixCB = pmvMatrixCB; - } - /** * Specify a buffer the tiles to be copied to. This is not * necessary for the creation of the final image, but useful if you @@ -170,13 +164,26 @@ public abstract class TileRendererBase { /** * Begins rendering a tile. *

        - * Methods modifies the viewport. - * User shall reset the viewport when finishing tile rendering, - * i.e. after last call of {@link #endTile(GL2ES3)}! + * Methods modifies the viewport, see below. + * User shall reset the viewport when finishing all tile rendering, + * i.e. after very last call of {@link #endTile(GL2ES3)}! *

        - *

        - * The projection matrix stack should be - * left alone after calling this method! + *

        + * The PMV Matrix + * must be reshaped after this call using: + *

          + *
        • Current Viewport + *
            + *
          • x 0
          • + *
          • y 0
          • + *
          • {@link #TR_CURRENT_TILE_WIDTH tile width}
          • + *
          • {@link #TR_CURRENT_TILE_HEIGHT tile height}
          • + *
        • + *
        • {@link #TR_CURRENT_TILE_X_POS tile x-pos}
        • + *
        • {@link #TR_CURRENT_TILE_Y_POS tile y-pos}
        • + *
        • {@link #TR_IMAGE_WIDTH image width}
        • + *
        • {@link #TR_IMAGE_HEIGHT image height}
        • + *
        *

        *

        * Use shall render the scene afterwards, concluded with a call to @@ -200,23 +207,46 @@ public abstract class TileRendererBase { /** * Attaches this renderer to the {@link GLAutoDrawable}. *

        - * The {@link GLAutoDrawable}'s {@link GLEventListener} are removed first and stored locally. + * The {@link GLAutoDrawable}'s original {@link GLEventListener} are moved to local storage. * This renderer {@link GLEventListener} is then added to handle the tile rendering - * for the original {@link GLEventListener}. + * for the original {@link GLEventListener}, i.e. it's {@link GLEventListener#display(GLAutoDrawable) display} issues: + *

          + *
        • Optional {@link #setGLEventListener(GLEventListener, GLEventListener) pre-glel}.{@link GLEventListener#display(GLAutoDrawable) display(..)}
        • + *
        • {@link #beginTile(GL2ES3)}
        • + *
        • for all original {@link GLEventListener}: + *
            + *
          • {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape(0, 0, tile-width, tile-height)}
          • + *
          • {@link GLEventListener#display(GLAutoDrawable) display(autoDrawable)}
          • + *
        • + *
        • {@link #endTile(GL2ES3)}
        • + *
        • Optional {@link #setGLEventListener(GLEventListener, GLEventListener) post-glel}.{@link GLEventListener#display(GLAutoDrawable) display(..)}
        • + *
        + *

        + *

        + * Consider using {@link #setGLEventListener(GLEventListener, GLEventListener)} to add pre- and post + * hooks to be performed on this renderer {@link GLEventListener}.
        + * The pre-hook is able to allocate memory and setup parameters, since it's called before {@link #beginTile(GL2ES3)}.
        + * The post-hook is able to use the rendering result and can even shutdown tile-rendering, + * since it's called after {@link #endTile(GL2ES3)}. *

        *

        * Call {@link #detachFromAutoDrawable()} to remove this renderer from the {@link GLAutoDrawable} * and to restore it's original {@link GLEventListener}. *

        + *

        + * The PMV Matrix shall be reshaped in the + * original {@link GLEventListener}'s {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} + * method. The latter is called for each tile w/ the current viewport. + * The tile's position and image size can be utilized. See details in {@link #beginTile(GL2ES3)}. + *

        * @param glad * @throws IllegalStateException if an {@link GLAutoDrawable} is already attached */ - public void attachToAutoDrawable(GLAutoDrawable glad, PMVMatrixCallback pmvMatrixCB) throws IllegalStateException { + public void attachToAutoDrawable(GLAutoDrawable glad) throws IllegalStateException { if( null != this.glad ) { throw new IllegalStateException("GLAutoDrawable already attached"); } this.glad = glad; - setPMVMatrixCallback(pmvMatrixCB); final int aSz = glad.getGLEventListenerCount(); listeners = new GLEventListener[aSz]; @@ -226,18 +256,18 @@ public abstract class TileRendererBase { listenersInit[i] = glad.getGLEventListenerInitState(l); listeners[i] = glad.removeGLEventListener( l ); } - glad.addGLEventListener(getTiledGLEL()); + glad.addGLEventListener(tiledGLEL); } /** * Detaches this renderer from the {@link GLAutoDrawable}. *

        - * See {@link #attachToAutoDrawable(GLAutoDrawable, PMVMatrixCallback)}. + * See {@link #attachToAutoDrawable(GLAutoDrawable)}. *

        */ public void detachFromAutoDrawable() { if( null != glad ) { - glad.removeGLEventListener(getTiledGLEL()); + glad.removeGLEventListener(tiledGLEL); final int aSz = listenersInit.length; for(int i=0; i cpuVFlipIntBbuffer.remaining() ) { + cpuVFlipIntBbuffer = IntBuffer.allocate(pixelBuffer.width * pixelBuffer.height); + } + + tileRenderer.setImageBuffer(pixelBuffer); + + // Copy temporary data into raster of BufferedImage for faster + // blitting Note that we could avoid this copy in the cases + // where !offscreenDrawable.isGLOriented(), + // but that's the software rendering path which is very slow anyway. + final BufferedImage image = pixelBuffer.image; + final int[] src = cpuVFlipIntBbuffer.array(); + final int[] dest = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); + final int incr = pixelBuffer.width; + int srcPos = 0; + int destPos = (imageHeight - 1) * pixelBuffer.width; + for (; destPos >= 0; srcPos += incr, destPos -= incr) { + System.arraycopy(src, srcPos, dest, destPos, incr); + } + } + @Override public void addGLEventListener(GLEventListener listener) { helper.addGLEventListener(listener); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java index d3ab05e82..0c84fac39 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java @@ -17,6 +17,7 @@ import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTMouseAdapter; import com.jogamp.opengl.JoglVersion; +import com.jogamp.opengl.util.TileRendererBase; /** * Gears.java
        @@ -33,7 +34,8 @@ public class Gears implements GLEventListener { private int swapInterval; private MouseListener gearsMouse = new GearsMouseAdapter(); private KeyListener gearsKeys = new GearsKeyAdapter(); - + private TileRendererBase tileRendererInUse = null; + // private boolean mouseRButtonDown = false; private int prevMouseX, prevMouseY; @@ -45,6 +47,10 @@ public class Gears implements GLEventListener { this.swapInterval = 1; } + public void setTileRenderer(TileRendererBase tileRenderer) { + tileRendererInUse = tileRenderer; + } + public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void setGears(int g1, int g2, int g3) { @@ -75,7 +81,22 @@ public class Gears implements GLEventListener { System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); System.err.println("INIT GL IS: " + gl.getClass().getName()); System.err.println(JoglVersion.getGLStrings(gl, null, false).toString()); + + init(gl); + + final Object upstreamWidget = drawable.getUpstreamWidget(); + if (upstreamWidget instanceof Window) { + final Window window = (Window) upstreamWidget; + window.addMouseListener(gearsMouse); + window.addKeyListener(gearsKeys); + } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { + final java.awt.Component comp = (java.awt.Component) upstreamWidget; + new AWTMouseAdapter(gearsMouse).addTo(comp); + new AWTKeyAdapter(gearsKeys).addTo(comp); + } + } + public void init(GL2 gl) { float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; float red[] = { 0.8f, 0.1f, 0.0f, 0.7f }; float green[] = { 0.0f, 0.8f, 0.2f, 0.7f }; @@ -122,36 +143,64 @@ public class Gears implements GLEventListener { } gl.glEnable(GL2.GL_NORMALIZE); - - final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { - final Window window = (Window) upstreamWidget; - window.addMouseListener(gearsMouse); - window.addKeyListener(gearsKeys); - } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { - final java.awt.Component comp = (java.awt.Component) upstreamWidget; - new AWTMouseAdapter(gearsMouse).addTo(comp); - new AWTKeyAdapter(gearsKeys).addTo(comp); - } } - + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height); - GL2 gl = drawable.getGL().getGL2(); - - gl.setSwapInterval(swapInterval); + GL2 gl = drawable.getGL().getGL2(); + this.reshape(gl, x, y, width, height); + } + + public void reshape(GL2 gl, int x, int y, int width, int height) { + System.err.println("Gears: Reshape "+x+"/"+y+" "+width+"x"+height+", tileRendererInUse "+tileRendererInUse); gl.glMatrixMode(GL2.GL_PROJECTION); gl.glLoadIdentity(); - if(height>width) { - float h = (float)height / (float)width; - gl.glFrustum(-1.0f, 1.0f, -h, h, 5.0f, 60.0f); + + final int tileWidth = width; + final int tileHeight = height; + final int tileX, tileY, imageWidth, imageHeight; + if( null == tileRendererInUse ) { + gl.setSwapInterval(swapInterval); + tileX = 0; + tileY = 0; + imageWidth = width; + imageHeight = height; + } else { + gl.setSwapInterval(0); + tileX = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); + tileY = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); + imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); + imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); + } + /* compute projection parameters */ + float left, right, bottom, top; + if( imageHeight > imageWidth ) { + float a = (float)imageHeight / (float)imageWidth; + left = -1.0f; + right = 1.0f; + bottom = -a; + top = a; } else { - float h = (float)width / (float)height; - gl.glFrustum(-h, h, -1.0f, 1.0f, 5.0f, 60.0f); + float a = (float)imageWidth / (float)imageHeight; + left = -a; + right = a; + bottom = -1.0f; + top = 1.0f; } - gl.glMatrixMode(GL2.GL_MODELVIEW); + final float w = right - left; + final float h = top - bottom; + final float l = left + w * tileX / imageWidth; + final float r = l + w * tileWidth / imageWidth; + final float b = bottom + h * tileY / imageHeight; + final float t = b + h * tileHeight / imageHeight; + + final float _w = r - l; + final float _h = t - b; + System.err.println(">> angle "+angle+", [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); + gl.glFrustum(l, r, b, t, 5.0f, 60.0f); + + gl.glMatrixMode(GL2.GL_MODELVIEW); gl.glLoadIdentity(); gl.glTranslatef(0.0f, 0.0f, -40.0f); } @@ -170,11 +219,6 @@ public class Gears implements GLEventListener { } public void display(GLAutoDrawable drawable) { - if( doRotate ) { - // Turn the gears' teeth - angle += 2.0f; - } - // Get the GL corresponding to the drawable we are animating GL2 gl = drawable.getGL().getGL2(); @@ -190,7 +234,18 @@ public class Gears implements GLEventListener { } else { gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); } - + displayImpl(gl); + } + public void display(GL2 gl) { + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); + displayImpl(gl); + } + private void displayImpl(GL2 gl) { + if( doRotate ) { + // Turn the gears' teeth + angle += 2.0f; + } // Rotate the entire assembly of gears based on how the user // dragged the mouse around gl.glPushMatrix(); @@ -221,7 +276,7 @@ public class Gears implements GLEventListener { // Remember that every push needs a pop; this one is paired with // rotating the entire gear assembly - gl.glPopMatrix(); + gl.glPopMatrix(); } public static void gear(GL2 gl, diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java index d1fabfa6b..1efc95c9e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java @@ -1,9 +1,37 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ package com.jogamp.opengl.test.junit.jogl.tile; import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.GLPixelBuffer; import com.jogamp.opengl.util.RandomTileRenderer; +import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureIO; @@ -11,19 +39,35 @@ import com.jogamp.opengl.util.texture.TextureIO; import java.io.File; import java.io.IOException; import javax.media.opengl.GL; -import javax.media.opengl.GL2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLRunnable; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; -/** Demonstrates the RandomTileRenderer class by rendering a large version - of the Gears demo to the specified file. */ +/** + * Demos offscreen {@link GLAutoDrawable} being used for + * {@link RandomTileRenderer} rendering to produce a PNG file. + *

        + * {@link RandomTileRenderer} is being kicked off from the main thread. + *

        + *

        + * {@link RandomTileRenderer} buffer allocation is performed + * within the pre {@link GLEventListener} + * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} + * on the main thread. + *

        + *

        + * At tile rendering finish, the viewport and + * and the original {@link GLEventListener}'s PMV matrix as well. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + *

        +*/ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestRandomTiledRendering2GL2 extends UITestCase { static long duration = 500; // ms @@ -37,7 +81,6 @@ public class TestRandomTiledRendering2GL2 extends UITestCase { GLCapabilities caps = new GLCapabilities(null); caps.setDoubleBuffered(false); - // Use a pbuffer for rendering final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); @@ -54,43 +97,8 @@ public class TestRandomTiledRendering2GL2 extends UITestCase { // Initialize the tile rendering library final RandomTileRenderer renderer = new RandomTileRenderer(); - final RandomTileRenderer.PMVMatrixCallback pmvMatrixCallback = new RandomTileRenderer.PMVMatrixCallback() { - public void reshapePMVMatrix(GL _gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { - final GL2 gl = _gl.getGL2(); - gl.glMatrixMode( GL2.GL_PROJECTION ); - gl.glLoadIdentity(); - - /* compute projection parameters */ - float left, right, bottom, top; - if( imageHeight > imageWidth ) { - float a = (float)imageHeight / (float)imageWidth; - left = -1.0f; - right = 1.0f; - bottom = -a; - top = a; - } else { - float a = (float)imageWidth / (float)imageHeight; - left = -a; - right = a; - bottom = -1.0f; - top = 1.0f; - } - final float w = right - left; - final float h = top - bottom; - final float l = left + w * tileX / imageWidth; - final float r = l + w * tileWidth / imageWidth; - final float b = bottom + h * tileY / imageHeight; - final float t = b + h * tileHeight / imageHeight; - - final float _w = r - l; - final float _h = t - b; - System.err.println(">> [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); - gl.glFrustum(l, r, b, t, 5.0f, 60.0f); - - gl.glMatrixMode(GL2.GL_MODELVIEW); - } - }; - renderer.attachToAutoDrawable(glad, pmvMatrixCallback); + gears.setTileRenderer(renderer); + renderer.attachToAutoDrawable(glad); renderer.setImageSize(imageWidth, imageHeight); final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; @@ -130,6 +138,18 @@ public class TestRandomTiledRendering2GL2 extends UITestCase { } renderer.detachFromAutoDrawable(); + gears.setTileRenderer(null); + + // Restore viewport and Gear's PMV matrix + // .. even though we close the demo, this is for documentation! + glad.invoke(true, new GLRunnable() { + @Override + public boolean run(GLAutoDrawable drawable) { + drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); + return false; + } + }); glad.destroy(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java new file mode 100644 index 000000000..26e53c17b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering3GL2AWT.java @@ -0,0 +1,261 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.tile; + +import com.jogamp.newt.event.TraceKeyAdapter; +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLPixelBuffer; +import com.jogamp.opengl.util.RandomTileRenderer; +import com.jogamp.opengl.util.TileRendererBase; +import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; + +import java.awt.Dimension; +import java.awt.Frame; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.awt.GLCanvas; + +import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +/** + * Demos an onscreen AWT {@link GLCanvas} being used for + * {@link RandomTileRenderer} rendering to produce a PNG file. + *

        + * {@link RandomTileRenderer} is being kicked off from the main thread. + *

        + *

        + * {@link RandomTileRenderer} setup and finishing is performed + * within the pre- and post {@link GLEventListener} + * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} + * on the animation thread. + *

        + *

        + * At tile rendering finish, the viewport and + * and the original {@link GLEventListener}'s PMV matrix as well. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestRandomTiledRendering3GL2AWT extends UITestCase { + static long duration = 3500; // ms + static int width = 640; + static int height = 480; + + @Test + public void test01() throws IOException, InterruptedException, InvocationTargetException { + doTest(); + } + + void doTest() throws IOException, InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(null); + caps.setDoubleBuffered(false); + + final Frame frame = new Frame("Gears AWT Test"); + Assert.assertNotNull(frame); + + final GLCanvas glad = new GLCanvas(caps); + Assert.assertNotNull(glad); + Dimension glc_sz = new Dimension(width, height); + glad.setMinimumSize(glc_sz); + glad.setPreferredSize(glc_sz); + glad.setSize(glc_sz); + frame.add(glad); + + final Gears gears = new Gears(); + glad.addGLEventListener( gears ); + + final Animator animator = new Animator(glad); + final QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glad); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Fix the image size for now + final int imageWidth = glad.getWidth() * 3; + final int imageHeight = glad.getHeight() * 2; + + // Initialize the tile rendering library + final RandomTileRenderer renderer = new RandomTileRenderer(); + renderer.setImageSize(imageWidth, imageHeight); + final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; + final boolean[] flipVertically = { false }; + final boolean[] rendererActive = { true }; + + final GLEventListener preTileGLEL = new GLEventListener() { + final int w = 50, h = 50; + int dx = 0, dy = 0; + + @Override + public void init(GLAutoDrawable drawable) { + gears.setDoRotation(false); + final GL gl = drawable.getGL(); + GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); + GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); + renderer.setImageBuffer(pixelBuffer); + if( drawable.isGLOriented() ) { + flipVertically[0] = false; + } else { + flipVertically[0] = true; + } + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) { + if( dx+w <= imageWidth && dy+h <= imageHeight ) { + System.err.println("XXX setTileRect["+dx+"/"+dy+" "+w+"x"+h+"]"); + renderer.setTileRect(dx, dy, w, h); + dx+=w+w/2; + if( dx + w > imageWidth ) { + dx = 0; + dy+=h+h/2; + } + } else if( rendererActive[0] ) { + System.err.println("XXX active -> false"); + rendererActive[0] = false; + } + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }; + final GLEventListener postTileGLEL = new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) {} + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) { + if( !rendererActive[0] ) { + final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); + imageBuffer.clear(); // full size available + System.err.println("XXX !active -> save"); + System.err.println("XXX2: "+imageBuffer); + final TextureData textureData = new TextureData( + caps.getGLProfile(), + 0 /* internalFormat */, + imageWidth, imageHeight, + 0, + imageBuffer.pixelAttributes, + false, false, + flipVertically[0], + imageBuffer.buffer, + null /* Flusher */); + System.err.println("XXX3: "+textureData.getPixelFormat()+", "+textureData.getPixelAttributes()); + try { + final String filename = getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); + final File file = new File(filename); + TextureIO.write(textureData, file); + } catch (IOException e) { + e.printStackTrace(); + } + gears.setTileRenderer(null); + renderer.detachFromAutoDrawable(); + System.err.println("XXX detach: glel "+glad.getGLEventListener(0)); + System.err.println("XXX detach: "+animator); + drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + glad.getGLEventListener(0).reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); + gears.setDoRotation(true); + } + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }; + renderer.setGLEventListener(preTileGLEL, postTileGLEL); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + + boolean signalTileRenderer = true; + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && + ( rendererActive[0] || animator.getTotalFPSDuration() 90 ) { + signalTileRenderer = false; + // tile rendering ! + System.err.println("XXX START TILE RENDERING"); + gears.setTileRenderer(renderer); + renderer.attachToAutoDrawable(glad); + System.err.println("XXX attach: glel "+glad.getGLEventListener(0)); + System.err.println("XXX attach: "+animator); + } + Thread.sleep(100); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glad); + Assert.assertNotNull(animator); + + animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glad); + frame.dispose(); + }}); + } + + public static void main(String args[]) { + for(int i=0; i + * All {@link TileRenderer} operations are + * being performed from the main thread sequentially + * without {@link GLAutoDrawable} or {@link GLEventListener}. + *

        +*/ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestTiledRendering1GL2 extends UITestCase { static long duration = 500; // ms @@ -34,110 +72,78 @@ public class TestTiledRendering1GL2 extends UITestCase { doTest(); } - void doTest() throws IOException { - GLCapabilities caps = new GLCapabilities(null); - caps.setDoubleBuffered(false); + static class DrawableContext { + DrawableContext(GLDrawable d, GLContext glc) { + this.d = d; + this.glc = glc; + } + GLDrawable d; + GLContext glc; + } + + private static DrawableContext createDrawableAndCurrentCtx(GLCapabilities glCaps, int width, int height) { + GLDrawableFactory factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); + GLDrawable d = factory.createOffscreenDrawable(null, glCaps, null, width, height); + d.setRealized(true); + GLContext glc = null; + glc = d.createContext(null); + Assert.assertTrue("Context could not be made current", GLContext.CONTEXT_NOT_CURRENT < glc.makeCurrent()); + return new DrawableContext(d, glc); + } + + private static void destroyDrawableContext(DrawableContext dc) { + if(null != dc.glc) { + dc.glc.destroy(); + dc.glc = null; + } + if(null != dc.d) { + dc.d.setRealized(false); + dc.d = null; + } + } - // Use a pbuffer for rendering - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); - + void doTest() throws GLException, IOException { + GLProfile glp = GLProfile.getMaxFixedFunc(true); + GLCapabilities caps = new GLCapabilities(glp); + caps.setOnscreen(false); + + DrawableContext dc = createDrawableAndCurrentCtx(caps, 256, 256); + final GL2 gl = dc.glc.getGL().getGL2(); + // Fix the image size for now - final int imageWidth = glad.getWidth() * 6; - final int imageHeight = glad.getHeight() * 4; + final int imageWidth = dc.d.getWidth() * 6; + final int imageHeight = dc.d.getHeight() * 4; - final String filename = this.getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); + final String filename = this.getSnapshotFilename(0, "-tile", dc.d.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); final File file = new File(filename); // Initialize the tile rendering library - final TileRenderer renderer = new com.jogamp.opengl.util.TileRenderer(); - final TileRenderer.PMVMatrixCallback pmvMatrixCallback = new TileRenderer.PMVMatrixCallback() { - public void reshapePMVMatrix(GL _gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { - final GL2 gl = _gl.getGL2(); - gl.glMatrixMode( GL2.GL_PROJECTION ); - gl.glLoadIdentity(); - - /* compute projection parameters */ - float left, right, bottom, top; - if( imageHeight > imageWidth ) { - float a = (float)imageHeight / (float)imageWidth; - left = -1.0f; - right = 1.0f; - bottom = -a; - top = a; - } else { - float a = (float)imageWidth / (float)imageHeight; - left = -a; - right = a; - bottom = -1.0f; - top = 1.0f; - } - final float w = right - left; - final float h = top - bottom; - final float l = left + w * tileX / imageWidth; - final float r = l + w * tileWidth / imageWidth; - final float b = bottom + h * tileY / imageHeight; - final float t = b + h * tileHeight / imageHeight; - - final float _w = r - l; - final float _h = t - b; - System.err.println(">> [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); - gl.glFrustum(l, r, b, t, 5.0f, 60.0f); - - gl.glMatrixMode(GL2.GL_MODELVIEW); - } - }; - - renderer.setTileSize(glad.getWidth(), glad.getHeight(), 0); - renderer.setPMVMatrixCallback(pmvMatrixCallback); + final TileRenderer renderer = new com.jogamp.opengl.util.TileRenderer(); + renderer.setTileSize(dc.d.getWidth(), dc.d.getHeight(), 0); renderer.setImageSize(imageWidth, imageHeight); final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; final boolean[] flipVertically = { false }; - glad.addGLEventListener( new GLEventListener() { - @Override - public void init(GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); - GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); - renderer.setImageBuffer(pixelBuffer); - if( drawable.isGLOriented() ) { - flipVertically[0] = false; - } else { - flipVertically[0] = true; - } - } - @Override - public void dispose(GLAutoDrawable drawable) {} - @Override - public void display(GLAutoDrawable drawable) { - renderer.beginTile(drawable.getGL().getGL2()); - } - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} - }); + GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); + GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); + renderer.setImageBuffer(pixelBuffer); + flipVertically[0] = false; + final Gears gears = new Gears(); gears.setDoRotation(false); - glad.addGLEventListener( gears ); - glad.addGLEventListener( new GLEventListener() { - @Override - public void init(GLAutoDrawable drawable) {} - @Override - public void dispose(GLAutoDrawable drawable) {} - @Override - public void display(GLAutoDrawable drawable) { - renderer.endTile(drawable.getGL().getGL2()); - } - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} - }); - - do { - glad.display(); + gears.init(gl); + + gears.setTileRenderer(renderer); + do { + renderer.beginTile(dc.glc.getGL().getGL2ES3()); + gears.reshape(gl, 0, 0, renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT)); + gears.display(gl); + renderer.endTile(dc.glc.getGL().getGL2ES3()); } while ( !renderer.eot() ); - - glad.destroy(); + gears.setTileRenderer(null); + + destroyDrawableContext(dc); final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); final TextureData textureData = new TextureData( diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2.java index d750ca853..6fd13538b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2.java @@ -1,9 +1,37 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ package com.jogamp.opengl.test.junit.jogl.tile; import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.GLPixelBuffer; import com.jogamp.opengl.util.TileRenderer; +import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.texture.TextureData; import com.jogamp.opengl.util.texture.TextureIO; @@ -11,19 +39,35 @@ import com.jogamp.opengl.util.texture.TextureIO; import java.io.File; import java.io.IOException; import javax.media.opengl.GL; -import javax.media.opengl.GL2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLRunnable; import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; -/** Demonstrates the TileRenderer class by rendering a large version - of the Gears demo to the specified file. */ +/** + * Demos offscreen {@link GLAutoDrawable} being used for + * {@link TileRenderer} rendering to produce a PNG file. + *

        + * {@link TileRenderer} is being kicked off from the main thread. + *

        + *

        + * {@link TileRenderer} buffer allocation is performed + * within the pre {@link GLEventListener} + * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} + * on the main thread. + *

        + *

        + * At tile rendering finish, the viewport and + * and the original {@link GLEventListener}'s PMV matrix as well. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + *

        +*/ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestTiledRendering2GL2 extends UITestCase { static long duration = 500; // ms @@ -37,7 +81,6 @@ public class TestTiledRendering2GL2 extends UITestCase { GLCapabilities caps = new GLCapabilities(null); caps.setDoubleBuffered(false); - // Use a pbuffer for rendering final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); @@ -54,44 +97,8 @@ public class TestTiledRendering2GL2 extends UITestCase { // Initialize the tile rendering library final TileRenderer renderer = new TileRenderer(); - final TileRenderer.PMVMatrixCallback pmvMatrixCallback = new TileRenderer.PMVMatrixCallback() { - public void reshapePMVMatrix(GL _gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { - final GL2 gl = _gl.getGL2(); - gl.glMatrixMode( GL2.GL_PROJECTION ); - gl.glLoadIdentity(); - - /* compute projection parameters */ - float left, right, bottom, top; - if( imageHeight > imageWidth ) { - float a = (float)imageHeight / (float)imageWidth; - left = -1.0f; - right = 1.0f; - bottom = -a; - top = a; - } else { - float a = (float)imageWidth / (float)imageHeight; - left = -a; - right = a; - bottom = -1.0f; - top = 1.0f; - } - final float w = right - left; - final float h = top - bottom; - final float l = left + w * tileX / imageWidth; - final float r = l + w * tileWidth / imageWidth; - final float b = bottom + h * tileY / imageHeight; - final float t = b + h * tileHeight / imageHeight; - - final float _w = r - l; - final float _h = t - b; - System.err.println(">> [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); - gl.glFrustum(l, r, b, t, 5.0f, 60.0f); - - gl.glMatrixMode(GL2.GL_MODELVIEW); - } - }; - - renderer.attachToAutoDrawable(glad, pmvMatrixCallback); + gears.setTileRenderer(renderer); + renderer.attachToAutoDrawable(glad); renderer.setImageSize(imageWidth, imageHeight); final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; @@ -124,6 +131,18 @@ public class TestTiledRendering2GL2 extends UITestCase { } while ( !renderer.eot() ); renderer.detachFromAutoDrawable(); + gears.setTileRenderer(null); + + // Restore viewport and Gear's PMV matrix + // .. even though we close the demo, this is for documentation! + glad.invoke(true, new GLRunnable() { + @Override + public boolean run(GLAutoDrawable drawable) { + drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); + return false; + } + }); glad.destroy(); -- cgit v1.2.3 From 7ee9b87bdb025f98651c2685d416029a17fc3937 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 5 Sep 2013 09:56:40 +0200 Subject: TileRendererBase: Add toString(), Proper tile unit test names, i.e. add NEWT for UI agnostic (no-awt tests). --- make/scripts/tests.sh | 6 +- .../com/jogamp/opengl/util/GLPixelBuffer.java | 3 +- .../com/jogamp/opengl/util/TileRendererBase.java | 11 +- .../jogl/tile/TestRandomTiledRendering2GL2.java | 185 --------------------- .../tile/TestRandomTiledRendering2GL2NEWT.java | 185 +++++++++++++++++++++ .../jogl/tile/TestRandomTiledRendering3GL2AWT.java | 12 +- .../junit/jogl/tile/TestTiledRendering1GL2.java | 174 ------------------- .../jogl/tile/TestTiledRendering1GL2NEWT.java | 174 +++++++++++++++++++ .../junit/jogl/tile/TestTiledRendering2GL2.java | 175 ------------------- .../jogl/tile/TestTiledRendering2GL2NEWT.java | 175 +++++++++++++++++++ 10 files changed, 553 insertions(+), 547 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2GL2NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 61b805215..5e4506d36 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -325,9 +325,9 @@ function testawtswt() { # # tile rendring / printing w/ & w/o AWT # -testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2 $* -testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2 $* -testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* # diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java index 9a9b94fa9..71e284101 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -254,7 +254,8 @@ public class GLPixelBuffer { sb = new StringBuilder(); } sb.append(pixelAttributes).append(", dim ").append(width).append("x").append(height).append("x").append(depth).append(", pack ").append(pack) - .append(", disposed ").append(disposed).append(", valid ").append(isValid()).append(", buffer[sz [bytes ").append(byteSize).append(", elemSize ").append(bufferElemSize).append(", ").append(buffer).append("]"); + .append(", disposed ").append(disposed).append(", valid ").append(isValid()) + .append(", buffer[bytes ").append(byteSize).append(", elemSize ").append(bufferElemSize).append(", ").append(buffer).append("]"); return sb; } public String toString() { diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index 8779fa59f..b6774b6b7 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -37,6 +37,7 @@ package com.jogamp.opengl.util; import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.DimensionImmutable; import javax.media.opengl.GL2ES3; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; @@ -109,6 +110,14 @@ public abstract class TileRendererBase { protected GLEventListener glEventListenerPre = null; protected GLEventListener glEventListenerPost = null; + public String toString() { + final int gladListenerCount = null != listeners ? listeners.length : 0; + return getClass().getSimpleName()+ + "[tile["+currentTileXPos+"/"+currentTileYPos+" "+currentTileWidth+"x"+currentTileHeight+", buffer "+tileBuffer+"], "+ + ", image[size "+imageSize+", buffer "+imageBuffer+"], glad["+ + gladListenerCount+" listener, pre "+(null!=glEventListenerPre)+", post "+(null!=glEventListenerPost)+"]]"; + } + protected TileRendererBase() { } @@ -147,7 +156,7 @@ public abstract class TileRendererBase { } /** @see #setImageSize(int, int) */ - public final Dimension getImageSize() { return imageSize; } + public final DimensionImmutable getImageSize() { return imageSize; } /** * Sets the buffer in which to store the final image diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java deleted file mode 100644 index 1efc95c9e..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.jogl.tile; - -import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.GLPixelBuffer; -import com.jogamp.opengl.util.RandomTileRenderer; -import com.jogamp.opengl.util.TileRendererBase; -import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; -import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureIO; - -import java.io.File; -import java.io.IOException; -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLOffscreenAutoDrawable; -import javax.media.opengl.GLRunnable; - -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -/** - * Demos offscreen {@link GLAutoDrawable} being used for - * {@link RandomTileRenderer} rendering to produce a PNG file. - *

        - * {@link RandomTileRenderer} is being kicked off from the main thread. - *

        - *

        - * {@link RandomTileRenderer} buffer allocation is performed - * within the pre {@link GLEventListener} - * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} - * on the main thread. - *

        - *

        - * At tile rendering finish, the viewport and - * and the original {@link GLEventListener}'s PMV matrix as well. - * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. - *

        -*/ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestRandomTiledRendering2GL2 extends UITestCase { - static long duration = 500; // ms - - @Test - public void test01() throws IOException { - doTest(); - } - - void doTest() throws IOException { - GLCapabilities caps = new GLCapabilities(null); - caps.setDoubleBuffered(false); - - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); - - final Gears gears = new Gears(); - gears.setDoRotation(false); - glad.addGLEventListener( gears ); - - // Fix the image size for now - final int imageWidth = glad.getWidth() * 6; - final int imageHeight = glad.getHeight() * 4; - - final String filename = this.getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); - final File file = new File(filename); - - // Initialize the tile rendering library - final RandomTileRenderer renderer = new RandomTileRenderer(); - gears.setTileRenderer(renderer); - renderer.attachToAutoDrawable(glad); - renderer.setImageSize(imageWidth, imageHeight); - - final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; - final boolean[] flipVertically = { false }; - - final GLEventListener preTileGLEL = new GLEventListener() { - @Override - public void init(GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); - GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); - renderer.setImageBuffer(pixelBuffer); - if( drawable.isGLOriented() ) { - flipVertically[0] = false; - } else { - flipVertically[0] = true; - } - } - @Override - public void dispose(GLAutoDrawable drawable) {} - @Override - public void display(GLAutoDrawable drawable) {} - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} - }; - renderer.setGLEventListener(preTileGLEL, null); - - final int w = 50, h = 50; - int dx = 0, dy = 0; - while( dx+w <= imageWidth && dy+h <= imageHeight ) { - renderer.display(dx, dy, w, h); - dx+=w+w/2; - if( dx + w > imageWidth ) { - dx = 0; - dy+=h+h/2; - } - } - - renderer.detachFromAutoDrawable(); - gears.setTileRenderer(null); - - // Restore viewport and Gear's PMV matrix - // .. even though we close the demo, this is for documentation! - glad.invoke(true, new GLRunnable() { - @Override - public boolean run(GLAutoDrawable drawable) { - drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); - gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); - return false; - } - }); - - glad.destroy(); - - final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); - imageBuffer.clear(); // full size available - System.err.println("XXX2: "+imageBuffer); - final TextureData textureData = new TextureData( - caps.getGLProfile(), - 0 /* internalFormat */, - imageWidth, imageHeight, - 0, - imageBuffer.pixelAttributes, - false, false, - flipVertically[0], - imageBuffer.buffer, - null /* Flusher */); - System.err.println("XXX3: "+textureData.getPixelFormat()+", "+textureData.getPixelAttributes()); - - TextureIO.write(textureData, file); - } - - public static void main(String args[]) { - for(int i=0; i + * {@link RandomTileRenderer} is being kicked off from the main thread. + *

        + *

        + * {@link RandomTileRenderer} buffer allocation is performed + * within the pre {@link GLEventListener} + * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} + * on the main thread. + *

        + *

        + * At tile rendering finish, the viewport and + * and the original {@link GLEventListener}'s PMV matrix as well. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + *

        +*/ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestRandomTiledRendering2GL2NEWT extends UITestCase { + static long duration = 500; // ms + + @Test + public void test01() throws IOException { + doTest(); + } + + void doTest() throws IOException { + GLCapabilities caps = new GLCapabilities(null); + caps.setDoubleBuffered(false); + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); + + final Gears gears = new Gears(); + gears.setDoRotation(false); + glad.addGLEventListener( gears ); + + // Fix the image size for now + final int imageWidth = glad.getWidth() * 6; + final int imageHeight = glad.getHeight() * 4; + + final String filename = this.getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); + final File file = new File(filename); + + // Initialize the tile rendering library + final RandomTileRenderer renderer = new RandomTileRenderer(); + gears.setTileRenderer(renderer); + renderer.attachToAutoDrawable(glad); + renderer.setImageSize(imageWidth, imageHeight); + + final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; + final boolean[] flipVertically = { false }; + + final GLEventListener preTileGLEL = new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); + GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); + renderer.setImageBuffer(pixelBuffer); + if( drawable.isGLOriented() ) { + flipVertically[0] = false; + } else { + flipVertically[0] = true; + } + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) {} + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }; + renderer.setGLEventListener(preTileGLEL, null); + + final int w = 50, h = 50; + int dx = 0, dy = 0; + while( dx+w <= imageWidth && dy+h <= imageHeight ) { + renderer.display(dx, dy, w, h); + dx+=w+w/2; + if( dx + w > imageWidth ) { + dx = 0; + dy+=h+h/2; + } + } + + renderer.detachFromAutoDrawable(); + gears.setTileRenderer(null); + + // Restore viewport and Gear's PMV matrix + // .. even though we close the demo, this is for documentation! + glad.invoke(true, new GLRunnable() { + @Override + public boolean run(GLAutoDrawable drawable) { + drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); + return false; + } + }); + + glad.destroy(); + + final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); + imageBuffer.clear(); // full size available + System.err.println("XXX2: "+imageBuffer); + final TextureData textureData = new TextureData( + caps.getGLProfile(), + 0 /* internalFormat */, + imageWidth, imageHeight, + 0, + imageBuffer.pixelAttributes, + false, false, + flipVertically[0], + imageBuffer.buffer, + null /* Flusher */); + System.err.println("XXX3: "+textureData.getPixelFormat()+", "+textureData.getPixelAttributes()); + + TextureIO.write(textureData, file); + } + + public static void main(String args[]) { + for(int i=0; i imageWidth ) { @@ -153,9 +153,9 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { dy+=h+h/2; } } else if( rendererActive[0] ) { - System.err.println("XXX active -> false"); rendererActive[0] = false; } + System.err.println("XXX pre-display: "+renderer); } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} @@ -171,7 +171,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); imageBuffer.clear(); // full size available System.err.println("XXX !active -> save"); - System.err.println("XXX2: "+imageBuffer); + System.err.println("XXX post-display: "+renderer); final TextureData textureData = new TextureData( caps.getGLProfile(), 0 /* internalFormat */, @@ -182,7 +182,6 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { flipVertically[0], imageBuffer.buffer, null /* Flusher */); - System.err.println("XXX3: "+textureData.getPixelFormat()+", "+textureData.getPixelAttributes()); try { final String filename = getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); final File file = new File(filename); @@ -192,8 +191,7 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { } gears.setTileRenderer(null); renderer.detachFromAutoDrawable(); - System.err.println("XXX detach: glel "+glad.getGLEventListener(0)); - System.err.println("XXX detach: "+animator); + System.err.println("XXX post-display detached: "+renderer); drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); glad.getGLEventListener(0).reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); gears.setDoRotation(true); @@ -223,8 +221,6 @@ public class TestRandomTiledRendering3GL2AWT extends UITestCase { System.err.println("XXX START TILE RENDERING"); gears.setTileRenderer(renderer); renderer.attachToAutoDrawable(glad); - System.err.println("XXX attach: glel "+glad.getGLEventListener(0)); - System.err.println("XXX attach: "+animator); } Thread.sleep(100); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2.java deleted file mode 100644 index 24466e32e..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2.java +++ /dev/null @@ -1,174 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.jogl.tile; - -import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.GLPixelBuffer; -import com.jogamp.opengl.util.TileRenderer; -import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; -import com.jogamp.opengl.util.TileRendererBase; -import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureIO; - -import java.io.File; -import java.io.IOException; - -import javax.media.opengl.GL2; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; -import javax.media.opengl.GLDrawableFactory; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -/** - * Demos offscreen {@link GLDrawable} being used for - * {@link TileRenderer} rendering to produce a PNG file. - *

        - * All {@link TileRenderer} operations are - * being performed from the main thread sequentially - * without {@link GLAutoDrawable} or {@link GLEventListener}. - *

        -*/ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestTiledRendering1GL2 extends UITestCase { - static long duration = 500; // ms - - @Test - public void test01() throws IOException { - doTest(); - } - - static class DrawableContext { - DrawableContext(GLDrawable d, GLContext glc) { - this.d = d; - this.glc = glc; - } - GLDrawable d; - GLContext glc; - } - - private static DrawableContext createDrawableAndCurrentCtx(GLCapabilities glCaps, int width, int height) { - GLDrawableFactory factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); - GLDrawable d = factory.createOffscreenDrawable(null, glCaps, null, width, height); - d.setRealized(true); - GLContext glc = null; - glc = d.createContext(null); - Assert.assertTrue("Context could not be made current", GLContext.CONTEXT_NOT_CURRENT < glc.makeCurrent()); - return new DrawableContext(d, glc); - } - - private static void destroyDrawableContext(DrawableContext dc) { - if(null != dc.glc) { - dc.glc.destroy(); - dc.glc = null; - } - if(null != dc.d) { - dc.d.setRealized(false); - dc.d = null; - } - } - - void doTest() throws GLException, IOException { - GLProfile glp = GLProfile.getMaxFixedFunc(true); - GLCapabilities caps = new GLCapabilities(glp); - caps.setOnscreen(false); - - DrawableContext dc = createDrawableAndCurrentCtx(caps, 256, 256); - final GL2 gl = dc.glc.getGL().getGL2(); - - // Fix the image size for now - final int imageWidth = dc.d.getWidth() * 6; - final int imageHeight = dc.d.getHeight() * 4; - - final String filename = this.getSnapshotFilename(0, "-tile", dc.d.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); - final File file = new File(filename); - - // Initialize the tile rendering library - final TileRenderer renderer = new com.jogamp.opengl.util.TileRenderer(); - renderer.setTileSize(dc.d.getWidth(), dc.d.getHeight(), 0); - renderer.setImageSize(imageWidth, imageHeight); - - final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; - final boolean[] flipVertically = { false }; - - GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); - GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); - renderer.setImageBuffer(pixelBuffer); - flipVertically[0] = false; - - final Gears gears = new Gears(); - gears.setDoRotation(false); - gears.init(gl); - - gears.setTileRenderer(renderer); - do { - renderer.beginTile(dc.glc.getGL().getGL2ES3()); - gears.reshape(gl, 0, 0, renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT)); - gears.display(gl); - renderer.endTile(dc.glc.getGL().getGL2ES3()); - } while ( !renderer.eot() ); - gears.setTileRenderer(null); - - destroyDrawableContext(dc); - - final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); - final TextureData textureData = new TextureData( - caps.getGLProfile(), - 0 /* internalFormat */, - imageWidth, imageHeight, - 0, - imageBuffer.pixelAttributes, - false, false, - flipVertically[0], - imageBuffer.buffer, - null /* Flusher */); - - TextureIO.write(textureData, file); - } - - public static void main(String args[]) { - for(int i=0; i + * All {@link TileRenderer} operations are + * being performed from the main thread sequentially + * without {@link GLAutoDrawable} or {@link GLEventListener}. + *

        +*/ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestTiledRendering1GL2NEWT extends UITestCase { + static long duration = 500; // ms + + @Test + public void test01() throws IOException { + doTest(); + } + + static class DrawableContext { + DrawableContext(GLDrawable d, GLContext glc) { + this.d = d; + this.glc = glc; + } + GLDrawable d; + GLContext glc; + } + + private static DrawableContext createDrawableAndCurrentCtx(GLCapabilities glCaps, int width, int height) { + GLDrawableFactory factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); + GLDrawable d = factory.createOffscreenDrawable(null, glCaps, null, width, height); + d.setRealized(true); + GLContext glc = null; + glc = d.createContext(null); + Assert.assertTrue("Context could not be made current", GLContext.CONTEXT_NOT_CURRENT < glc.makeCurrent()); + return new DrawableContext(d, glc); + } + + private static void destroyDrawableContext(DrawableContext dc) { + if(null != dc.glc) { + dc.glc.destroy(); + dc.glc = null; + } + if(null != dc.d) { + dc.d.setRealized(false); + dc.d = null; + } + } + + void doTest() throws GLException, IOException { + GLProfile glp = GLProfile.getMaxFixedFunc(true); + GLCapabilities caps = new GLCapabilities(glp); + caps.setOnscreen(false); + + DrawableContext dc = createDrawableAndCurrentCtx(caps, 256, 256); + final GL2 gl = dc.glc.getGL().getGL2(); + + // Fix the image size for now + final int imageWidth = dc.d.getWidth() * 6; + final int imageHeight = dc.d.getHeight() * 4; + + final String filename = this.getSnapshotFilename(0, "-tile", dc.d.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); + final File file = new File(filename); + + // Initialize the tile rendering library + final TileRenderer renderer = new com.jogamp.opengl.util.TileRenderer(); + renderer.setTileSize(dc.d.getWidth(), dc.d.getHeight(), 0); + renderer.setImageSize(imageWidth, imageHeight); + + final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; + final boolean[] flipVertically = { false }; + + GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); + GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); + renderer.setImageBuffer(pixelBuffer); + flipVertically[0] = false; + + final Gears gears = new Gears(); + gears.setDoRotation(false); + gears.init(gl); + + gears.setTileRenderer(renderer); + do { + renderer.beginTile(dc.glc.getGL().getGL2ES3()); + gears.reshape(gl, 0, 0, renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT)); + gears.display(gl); + renderer.endTile(dc.glc.getGL().getGL2ES3()); + } while ( !renderer.eot() ); + gears.setTileRenderer(null); + + destroyDrawableContext(dc); + + final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); + final TextureData textureData = new TextureData( + caps.getGLProfile(), + 0 /* internalFormat */, + imageWidth, imageHeight, + 0, + imageBuffer.pixelAttributes, + false, false, + flipVertically[0], + imageBuffer.buffer, + null /* Flusher */); + + TextureIO.write(textureData, file); + } + + public static void main(String args[]) { + for(int i=0; i - * {@link TileRenderer} is being kicked off from the main thread. - *

        - *

        - * {@link TileRenderer} buffer allocation is performed - * within the pre {@link GLEventListener} - * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} - * on the main thread. - *

        - *

        - * At tile rendering finish, the viewport and - * and the original {@link GLEventListener}'s PMV matrix as well. - * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. - *

        -*/ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestTiledRendering2GL2 extends UITestCase { - static long duration = 500; // ms - - @Test - public void test01() throws IOException { - doTest(); - } - - void doTest() throws IOException { - GLCapabilities caps = new GLCapabilities(null); - caps.setDoubleBuffered(false); - - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); - - final Gears gears = new Gears(); - gears.setDoRotation(false); - glad.addGLEventListener( gears ); - - // Fix the image size for now - final int imageWidth = glad.getWidth() * 6; - final int imageHeight = glad.getHeight() * 4; - - final String filename = this.getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); - final File file = new File(filename); - - // Initialize the tile rendering library - final TileRenderer renderer = new TileRenderer(); - gears.setTileRenderer(renderer); - renderer.attachToAutoDrawable(glad); - renderer.setImageSize(imageWidth, imageHeight); - - final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; - final boolean[] flipVertically = { false }; - - final GLEventListener preTileGLEL = new GLEventListener() { - @Override - public void init(GLAutoDrawable drawable) { - final GL gl = drawable.getGL(); - GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); - GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); - renderer.setImageBuffer(pixelBuffer); - if( drawable.isGLOriented() ) { - flipVertically[0] = false; - } else { - flipVertically[0] = true; - } - } - @Override - public void dispose(GLAutoDrawable drawable) {} - @Override - public void display(GLAutoDrawable drawable) {} - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} - }; - renderer.setGLEventListener(preTileGLEL, null); - - do { - renderer.display(); - } while ( !renderer.eot() ); - - renderer.detachFromAutoDrawable(); - gears.setTileRenderer(null); - - // Restore viewport and Gear's PMV matrix - // .. even though we close the demo, this is for documentation! - glad.invoke(true, new GLRunnable() { - @Override - public boolean run(GLAutoDrawable drawable) { - drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); - gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); - return false; - } - }); - - glad.destroy(); - - final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); - final TextureData textureData = new TextureData( - caps.getGLProfile(), - 0 /* internalFormat */, - imageWidth, imageHeight, - 0, - imageBuffer.pixelAttributes, - false, false, - flipVertically[0], - imageBuffer.buffer, - null /* Flusher */); - - TextureIO.write(textureData, file); - } - - public static void main(String args[]) { - for(int i=0; i + * {@link TileRenderer} is being kicked off from the main thread. + *

        + *

        + * {@link TileRenderer} buffer allocation is performed + * within the pre {@link GLEventListener} + * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} + * on the main thread. + *

        + *

        + * At tile rendering finish, the viewport and + * and the original {@link GLEventListener}'s PMV matrix as well. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + *

        +*/ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestTiledRendering2GL2NEWT extends UITestCase { + static long duration = 500; // ms + + @Test + public void test01() throws IOException { + doTest(); + } + + void doTest() throws IOException { + GLCapabilities caps = new GLCapabilities(null); + caps.setDoubleBuffered(false); + + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); + + final Gears gears = new Gears(); + gears.setDoRotation(false); + glad.addGLEventListener( gears ); + + // Fix the image size for now + final int imageWidth = glad.getWidth() * 6; + final int imageHeight = glad.getHeight() * 4; + + final String filename = this.getSnapshotFilename(0, "-tile", glad.getChosenGLCapabilities(), imageWidth, imageHeight, false, TextureIO.PNG, null); + final File file = new File(filename); + + // Initialize the tile rendering library + final TileRenderer renderer = new TileRenderer(); + gears.setTileRenderer(renderer); + renderer.attachToAutoDrawable(glad); + renderer.setImageSize(imageWidth, imageHeight); + + final GLPixelBuffer.GLPixelBufferProvider pixelBufferProvider = GLPixelBuffer.defaultProviderWithRowStride; + final boolean[] flipVertically = { false }; + + final GLEventListener preTileGLEL = new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, 3); + GLPixelBuffer pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, imageWidth, imageHeight, 1, true, 0); + renderer.setImageBuffer(pixelBuffer); + if( drawable.isGLOriented() ) { + flipVertically[0] = false; + } else { + flipVertically[0] = true; + } + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) {} + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }; + renderer.setGLEventListener(preTileGLEL, null); + + do { + renderer.display(); + } while ( !renderer.eot() ); + + renderer.detachFromAutoDrawable(); + gears.setTileRenderer(null); + + // Restore viewport and Gear's PMV matrix + // .. even though we close the demo, this is for documentation! + glad.invoke(true, new GLRunnable() { + @Override + public boolean run(GLAutoDrawable drawable) { + drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); + gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); + return false; + } + }); + + glad.destroy(); + + final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); + final TextureData textureData = new TextureData( + caps.getGLProfile(), + 0 /* internalFormat */, + imageWidth, imageHeight, + 0, + imageBuffer.pixelAttributes, + false, false, + flipVertically[0], + imageBuffer.buffer, + null /* Flusher */); + + TextureIO.write(textureData, file); + } + + public static void main(String args[]) { + for(int i=0; i Date: Thu, 5 Sep 2013 12:47:15 +0200 Subject: TileRendererBase: Add interface TileRendererNotify, to notify implementing GLEventListener about attached/detached TileRenderer .. since GLEventListener's reshape(..) method must query certain tile renderer attributes (tile pos and image size), they have to be aware of the TileRendererBase. To simplify such awareness and hence automate this attachement and passing over the tile renderer reference, they should implement this new interface. Gears example implements the new interface, which caches the TR reference and pauses rotation. --- make/scripts/tests.sh | 7 ++-- .../com/jogamp/opengl/util/TileRendererBase.java | 48 ++++++++++++++++++---- .../opengl/test/junit/jogl/demos/gl2/Gears.java | 16 +++++--- .../tile/TestRandomTiledRendering2GL2NEWT.java | 3 -- .../jogl/tile/TestRandomTiledRendering3GL2AWT.java | 4 -- .../jogl/tile/TestTiledRendering1GL2NEWT.java | 5 +-- .../jogl/tile/TestTiledRendering2GL2NEWT.java | 3 -- 7 files changed, 57 insertions(+), 29 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5e4506d36..8f3f923d7 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -325,10 +325,11 @@ function testawtswt() { # # tile rendring / printing w/ & w/o AWT # -#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index b6774b6b7..8a339456a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -95,6 +95,18 @@ public abstract class TileRendererBase { */ public static final int TR_CURRENT_TILE_HEIGHT = 6; + /** + * Notifies {@link GLEventListener} implementing this interface + * that the owning {@link GLAutoDrawable} is {@link TileRendererBase#attachToAutoDrawable(GLAutoDrawable) attached} + * to a tile renderer or {@link TileRendererBase#detachFromAutoDrawable() detached} from it. + */ + public static interface TileRendererNotify { + /** The owning {@link GLAutoDrawable} is {@link TileRendererBase#attachToAutoDrawable(GLAutoDrawable) attached} to a {@link TileRendererBase}. */ + public void addTileRendererNotify(TileRendererBase tr); + /** The owning {@link GLAutoDrawable} is {@link TileRendererBase#detachFromAutoDrawable() detached} from a {@link TileRendererBase}. */ + public void removeTileRendererNotify(TileRendererBase tr); + } + protected final Dimension imageSize = new Dimension(0, 0); protected final GLPixelStorageModes psm = new GLPixelStorageModes(); protected GLPixelBuffer imageBuffer; @@ -216,8 +228,13 @@ public abstract class TileRendererBase { /** * Attaches this renderer to the {@link GLAutoDrawable}. *

        - * The {@link GLAutoDrawable}'s original {@link GLEventListener} are moved to local storage. - * This renderer {@link GLEventListener} is then added to handle the tile rendering + * The {@link GLAutoDrawable}'s original {@link GLEventListener} are moved to this tile renderer.
        + * It is highly recommended that the original {@link GLEventListener} implement + * {@link TileRendererNotify}, so they get {@link TileRendererNotify#addTileRendererNotify(TileRendererBase) notified} + * about this event. + *

        + *

        + * This tile renderer's {@link GLEventListener} is then added to handle the tile rendering * for the original {@link GLEventListener}, i.e. it's {@link GLEventListener#display(GLAutoDrawable) display} issues: *

          *
        • Optional {@link #setGLEventListener(GLEventListener, GLEventListener) pre-glel}.{@link GLEventListener#display(GLAutoDrawable) display(..)}
        • @@ -232,6 +249,16 @@ public abstract class TileRendererBase { *
        *

        *

        + * The PMV Matrix shall be reshaped in the + * original {@link GLEventListener}'s {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method + * according to the tile-position, -size and image-size
        + * The {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method is called for each tile + * w/ the current viewport of tile-size, where the tile-position and image-size can be retrieved by this tile renderer, + * see details in {@link #beginTile(GL2ES3)}.
        + * The original {@link GLEventListener} implementing {@link TileRendererNotify} is aware of this + * tile renderer instance. + *

        + *

        * Consider using {@link #setGLEventListener(GLEventListener, GLEventListener)} to add pre- and post * hooks to be performed on this renderer {@link GLEventListener}.
        * The pre-hook is able to allocate memory and setup parameters, since it's called before {@link #beginTile(GL2ES3)}.
        @@ -242,12 +269,6 @@ public abstract class TileRendererBase { * Call {@link #detachFromAutoDrawable()} to remove this renderer from the {@link GLAutoDrawable} * and to restore it's original {@link GLEventListener}. *

        - *

        - * The PMV Matrix shall be reshaped in the - * original {@link GLEventListener}'s {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} - * method. The latter is called for each tile w/ the current viewport. - * The tile's position and image size can be utilized. See details in {@link #beginTile(GL2ES3)}. - *

        * @param glad * @throws IllegalStateException if an {@link GLAutoDrawable} is already attached */ @@ -264,6 +285,9 @@ public abstract class TileRendererBase { final GLEventListener l = glad.getGLEventListener(0); listenersInit[i] = glad.getGLEventListenerInitState(l); listeners[i] = glad.removeGLEventListener( l ); + if( listeners[i] instanceof TileRendererNotify ) { + ((TileRendererNotify)listeners[i]).addTileRendererNotify(this); + } } glad.addGLEventListener(tiledGLEL); } @@ -271,6 +295,11 @@ public abstract class TileRendererBase { /** * Detaches this renderer from the {@link GLAutoDrawable}. *

        + * It is highly recommended that the original {@link GLEventListener} implement + * {@link TileRendererNotify}, so they get {@link TileRendererNotify#removeTileRendererNotify(TileRendererBase) notified} + * about this event. + *

        + *

        * See {@link #attachToAutoDrawable(GLAutoDrawable)}. *

        */ @@ -280,6 +309,9 @@ public abstract class TileRendererBase { final int aSz = listenersInit.length; for(int i=0; i Date: Thu, 5 Sep 2013 16:19:08 +0200 Subject: Test scripts .. --- make/scripts/tests.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8f3f923d7..a742bbe69 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -216,7 +216,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" - #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" + D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" @@ -325,11 +325,11 @@ function testawtswt() { # # tile rendring / printing w/ & w/o AWT # -testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* # # core/newt (testnoawt and testawt) -- cgit v1.2.3 From 3df81d611f2f2700f8c48d592d7ef0537a93986b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 5 Sep 2013 17:29:16 +0200 Subject: Add TestGLContextDrawableSwitch02AWT: Test AWT GLCanvas <-> GLOffscreenAutoDrawable switch, forth & back --- make/scripts/tests.sh | 4 +- .../glels/TestGLContextDrawableSwitch02AWT.java | 192 +++++++++++++++++++++ 2 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a742bbe69..12eddbf9b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -329,7 +329,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch02AWT $* # # core/newt (testnoawt and testawt) @@ -398,6 +399,7 @@ testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch10NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch11NewtAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java new file mode 100644 index 000000000..e568f87a1 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java @@ -0,0 +1,192 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore.glels; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; + +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLDrawableUtil; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +/** + * Test re-association (switching) of GLContext/GLDrawables, + * from GLCanvas to an GLOffscreenAutoDrawable and back. + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestGLContextDrawableSwitch02AWT extends UITestCase { + static int width, height; + + static GLCapabilities getCaps(String profile) { + if( !GLProfile.isAvailable(profile) ) { + System.err.println("Profile "+profile+" n/a"); + return null; + } + return new GLCapabilities(GLProfile.get(profile)); + } + + @BeforeClass + public static void initClass() { + width = 256; + height = 256; + } + + private GLAutoDrawable createGLAutoDrawable(final Frame frame, GLCapabilities caps, int width, int height) throws InterruptedException, InvocationTargetException { + final GLAutoDrawable glad; + if( caps.isOnscreen() ) { + GLCanvas glCanvas = new GLCanvas(caps); + Assert.assertNotNull(glCanvas); + Dimension glc_sz = new Dimension(width, height); + glCanvas.setMinimumSize(glc_sz); + glCanvas.setPreferredSize(glc_sz); + glCanvas.setSize(glc_sz); + glad = glCanvas; + + frame.setLayout(new BorderLayout()); + frame.add(glCanvas, BorderLayout.CENTER); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + + } else { + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height, null); + Assert.assertNotNull(glad); + } + return glad; + } + + @Test(timeout=30000) + public void testSwitch2AWTGLCanvas2OffscreenGL2ES2() throws InterruptedException, InvocationTargetException { + final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); + if(null == reqGLCaps) return; + testSwitch2AWTGLCanvas2OffscreenImpl(reqGLCaps); + } + + private void testSwitch2AWTGLCanvas2OffscreenImpl(GLCapabilities capsOnscreen) throws InterruptedException, InvocationTargetException { + final GLCapabilities capsOffscreen = (GLCapabilities) capsOnscreen.clone(); + capsOffscreen.setOnscreen(false); + + final QuitAdapter quitAdapter = new QuitAdapter(); + + final Frame frame = new Frame("Gears AWT Test"); + Assert.assertNotNull(frame); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + GLAutoDrawable glCanvas = createGLAutoDrawable(frame, capsOnscreen, width, height); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + GearsES2 gears = new GearsES2(1); + glCanvas.addGLEventListener(gears); + glCanvas.addGLEventListener(snapshotGLEventListener); + snapshotGLEventListener.setMakeSnapshot(); + + Animator animator = new Animator(); + animator.add(glCanvas); + animator.start(); + + int s = 0; + long t0 = System.currentTimeMillis(); + long t1 = t0; + + GLAutoDrawable glOffscreen = createGLAutoDrawable(null, capsOffscreen, width, height); + while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { + if( ( t1 - t0 ) / period > s) { + s++; + System.err.println(s+" - switch - START "+ ( t1 - t0 )); + + // switch context _and_ the demo synchronously + GLDrawableUtil.swapGLContextAndAllGLEventListener(glCanvas, glOffscreen); + snapshotGLEventListener.setMakeSnapshot(); + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); + } + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + animator.stop(); + // glCanvas.destroy(); + glOffscreen.destroy(); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + final Frame _frame = frame; + _frame.dispose(); + }}); + } + + // default timing for 2 switches + static long duration = 2900; // ms + static long period = 1000; // ms + + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Fri, 6 Sep 2013 04:36:19 +0200 Subject: GLCanvas Printing WIP: Swap to offscreen at setupPrint(); Use TileRenderer @ print(..); Test: Add auto-print w/o UI 72dpi and 300dpi NOTE: Tile raster is added at print plus lots of debug output - WIP! - Swap to offscreen at setupPrint() - Swap GLEventListener (GLEL) and GLContext to fixed size offscreen GLAutoDrawable (GLAD) - Destroy onscreen drawable/context - Setup TileRenderer w/ offscreen GLAD - @ releasePrint() restore onscreen .. This shall ensure we don't hog the GPU resources when resizing the AWT component (upscaling). - Use TileRenderer @ print(..) The clip-rect will be used as the TileRenderer's image-size and we perform a whole tile-rendering loop. This helps to limit resources, see above. - Test: Add auto-print w/o UI 72dpi and 300dpi --- make/scripts/tests.sh | 5 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 236 +++++++++++---------- .../junit/jogl/tile/TestTiledPrintingGearsAWT.java | 204 +++++++++++++----- 3 files changed, 278 insertions(+), 167 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 12eddbf9b..2921bd409 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -216,7 +216,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" - D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" @@ -329,8 +329,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.glels.TestGLContextDrawableSwitch02AWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 4cf3807c4..aa2936907 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -89,6 +89,7 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import javax.media.opengl.Threading; @@ -104,11 +105,12 @@ import com.jogamp.nativewindow.awt.AWTGraphicsScreen; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.nativewindow.awt.JAWTWindow; import com.jogamp.opengl.JoglVersion; -import com.jogamp.opengl.util.RandomTileRenderer; +import com.jogamp.opengl.util.GLDrawableUtil; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; +import com.jogamp.opengl.util.TileRenderer; import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer; -import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider; +import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; @@ -631,7 +633,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } private boolean validateGLDrawable() { - if( Beans.isDesignTime() || !isDisplayable() ) { + if( Beans.isDesignTime() || !isDisplayable() || printActive ) { return false; // early out! } final GLDrawable _drawable = drawable; @@ -733,67 +735,33 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing paint(g); } - private static SingleAWTGLPixelBufferProvider singleAWTGLPixelBufferProvider = null; - private static synchronized SingleAWTGLPixelBufferProvider getSingleAWTGLPixelBufferProvider() { - if( null == singleAWTGLPixelBufferProvider ) { - singleAWTGLPixelBufferProvider = new SingleAWTGLPixelBufferProvider( true /* allowRowStride */ ); - } - return singleAWTGLPixelBufferProvider; - } - private boolean printActive = false; - private boolean printAnimatorPaused = false; - private RandomTileRenderer printRenderer; - private Graphics2D printGraphics; - private int printWidth = 0; - private int printHeight = 0; - public void setupPrint (final double scaleX, final double scaleY) { - printActive = true; - // this.printWidth = scaleX; - // this.printHeight = scaleY; - } - private void initPrint() { - printActive = true; - final GLAnimatorControl animator = helper.getAnimator(); - if( animator.isAnimating() ) { - animator.pause(); - printAnimatorPaused = true; - } - if( 0 >= printWidth ) { - printWidth = getWidth(); - } - if( 0 >= printHeight ) { - printHeight = getHeight(); - } - System.err.println("AWT print.init: printSize "+printWidth+"x"+printHeight+", canvasSize "+getWidth()+"x"+getWidth()+ - ", drawableSize "+drawable.getWidth()+"x"+drawable.getHeight()+ - ", animatorPaused "+printAnimatorPaused); - { - final RenderingHints rHints = printGraphics.getRenderingHints(); - final Set> rEntries = rHints.entrySet(); - int count = 0; - for(Iterator> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { - final Entry rEntry = rEntryIter.next(); - System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); - } + private static final int PRINT_TILE_SIZE = 256; + private volatile boolean printActive = false; + private GLOffscreenAutoDrawable printGLAD = null; + private TileRenderer printRenderer = null; + private GLAnimatorControl printAnimator = null; + private AWTGLPixelBuffer printBuffer = null; + private BufferedImage printVFlipImage = null; + private Graphics2D printGraphics = null; + + public void setupPrint() { + printActive = true; + sendReshape = false; // clear reshape flag + printAnimator = helper.getAnimator(); + if( null != printAnimator ) { + printAnimator.remove(this); } - // final GraphicsConfiguration gc = printGraphics.getDeviceConfiguration(); - final AffineTransform aTrans = printGraphics.getTransform(); - System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); - System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); + caps.setOnscreen(false); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); + GLDrawableUtil.swapGLContextAndAllGLEventListener(this, printGLAD); + destroyOnEDTAction.run(); + printRenderer = new TileRenderer(); + printRenderer.setRowOrder(TileRenderer.TR_TOP_TO_BOTTOM); + printRenderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); + printRenderer.attachToAutoDrawable(printGLAD); - final SingleAWTGLPixelBufferProvider printBufferProvider = getSingleAWTGLPixelBufferProvider(); - printRenderer = new RandomTileRenderer(); - printRenderer.setImageSize(printWidth, printHeight); - printRenderer.attachToAutoDrawable(this); - final int componentCount; - if( isOpaque() ) { - // w/o alpha - componentCount = 3; - } else { - // with alpha - componentCount = 4; - } - final BufferedImage[] cpuVFlipImageStore = { null }; final GLEventListener preTileGLEL = new GLEventListener() { @Override public void init(GLAutoDrawable drawable) { @@ -803,22 +771,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing @Override public void display(GLAutoDrawable drawable) { final GL gl = drawable.getGL(); - final GLPixelAttributes pixelAttribs = printBufferProvider.getAttributes(gl, componentCount); - final int tileWidth = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH); - final int tileHeight = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); - AWTGLPixelBuffer pixelBuffer = printBufferProvider.getSingleBuffer(pixelAttribs); - if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, tileWidth, tileHeight, 0) ) { - pixelBuffer.dispose(); - pixelBuffer = null; - } - if ( null == pixelBuffer ) { - pixelBuffer = printBufferProvider.allocate(gl, pixelAttribs, tileWidth, tileHeight, 1, true, 0); - printRenderer.setTileBuffer(pixelBuffer); - } - - final BufferedImage cpuVFlipImage = cpuVFlipImageStore[0]; - if( null == cpuVFlipImage || pixelBuffer.width > cpuVFlipImage.getWidth() || pixelBuffer.height > cpuVFlipImage.getHeight() ) { - cpuVFlipImageStore[0] = new BufferedImage(pixelBuffer.width, pixelBuffer.height, pixelBuffer.image.getType()); + if( null == printBuffer ) { + final int componentCount = isOpaque() ? 3 : 4; + final AWTGLPixelBufferProvider printBufferProvider = new AWTGLPixelBufferProvider( true /* allowRowStride */ ); + final GLPixelAttributes pixelAttribs = printBufferProvider.getAttributes(gl, componentCount); + printBuffer = printBufferProvider.allocate(gl, pixelAttribs, printGLAD.getWidth(), printGLAD.getHeight(), 1, true, 0); + printRenderer.setTileBuffer(printBuffer); + printVFlipImage = new BufferedImage(printBuffer.width, printBuffer.height, printBuffer.image.getType()); } System.err.println("XXX tile-pre "+printRenderer); // FIXME } @@ -826,8 +785,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} }; final GLEventListener postTileGLEL = new GLEventListener() { + int tTopRowHeight = 0; @Override public void init(GLAutoDrawable drawable) { + tTopRowHeight = 0; } @Override public void dispose(GLAutoDrawable drawable) {} @@ -837,58 +798,119 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // blitting Note that we could avoid this copy in the cases // where !offscreenDrawable.isGLOriented(), // but that's the software rendering path which is very slow anyway. - final int tileHeight = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); - final AWTGLPixelBuffer pixelBuffer = (AWTGLPixelBuffer) printRenderer.getTileBuffer(); - final BufferedImage srcImage = pixelBuffer.image; - final BufferedImage dstImage = cpuVFlipImageStore[0]; + final int tHeight = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); + final int tWidth = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH); + // final BufferedImage dstImage = printBuffer.image; + final BufferedImage srcImage = printBuffer.image; + final BufferedImage dstImage = printVFlipImage; final int[] src = ((DataBufferInt) srcImage.getRaster().getDataBuffer()).getData(); final int[] dst = ((DataBufferInt) dstImage.getRaster().getDataBuffer()).getData(); - final int incr = pixelBuffer.width; + final int incr = printBuffer.width; int srcPos = 0; - int destPos = (tileHeight - 1) * pixelBuffer.width; + int destPos = (tHeight - 1) * printBuffer.width; for (; destPos >= 0; srcPos += incr, destPos -= incr) { System.arraycopy(src, srcPos, dst, destPos, incr); } - System.err.println("XXX tile-post dst-img "+dstImage); // FIXME // Draw resulting image in one shot - printGraphics.drawImage(dstImage, 0, 0, dstImage.getWidth(), dstImage.getHeight(), null); // Null ImageObserver since image data is ready. - System.err.println("XXX tile-post.X"); // FIXME + final int tCols = printRenderer.getParam(TileRenderer.TR_COLUMNS); + final int tRows = printRenderer.getParam(TileRenderer.TR_ROWS); + final int tCol = printRenderer.getParam(TileRenderer.TR_CURRENT_COLUMN); + final int tRow = printRenderer.getParam(TileRenderer.TR_CURRENT_ROW); + final int pX = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); + final int pY = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); + final int pYf; + if( tRow == tRows - 1 ) { + tTopRowHeight = tHeight; + pYf = 0; + } else if( tRow == tRows - 2 ){ + pYf = tTopRowHeight; + } else { + pYf = ( tRows - 2 - tRow ) * tHeight + tTopRowHeight; + } + printGraphics.drawImage(dstImage, pX, pYf, dstImage.getWidth(), dstImage.getHeight(), null); // Null ImageObserver since image data is ready. + printGraphics.setColor(Color.BLACK); + printGraphics.drawRect(pX, pYf, tWidth, tHeight); + System.err.println("XXX tile-post.X "+tCols+"x"+tRows+" ["+tCol+"]["+tRow+"] "+pX+"/"+pY+" "+tWidth+"x"+tHeight+" dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()+" -> "+pX+"/"+pYf); // +", "+dstImage); // FIXME } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} }; printRenderer.setGLEventListener(preTileGLEL, postTileGLEL); - System.err.println("AWT print.init: "+printRenderer); + + System.err.println("AWT print.setup "+printRenderer); // FIXME + System.err.println("AWT print.setup "+printGLAD); // FIXME } + public void releasePrint() { - System.err.println("AWT print.release: "+printRenderer); - printRenderer.detachFromAutoDrawable(); + if( !printActive || null == printGLAD ) { + throw new IllegalStateException("setupPrint() not called"); + } + printRenderer.detachFromAutoDrawable(); // tile-renderer -> printGLAD + createDrawableAndContext( false ); + GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, this); + printGLAD.destroy(); + if( null != printAnimator ) { + printAnimator.add(this); + } + printGLAD = null; printRenderer = null; - this.printGraphics = null; - singleAWTGLPixelBufferProvider = null; - final GLAnimatorControl animator = printAnimatorPaused ? helper.getAnimator() : null; - if( null != animator ) { - animator.resume(); + printAnimator = null; + if( null != printBuffer ) { + printBuffer.dispose(); + printBuffer = null; + } + if( null != printVFlipImage ) { + printVFlipImage.flush(); + printVFlipImage = null; } - printAnimatorPaused = false; + printGraphics = null; + System.err.println("AWT print.release "+printRenderer); // FIXME + System.err.println("AWT print.release "+this); // FIXME printActive = false; } @Override public void print(Graphics graphics) { - this.printGraphics = (Graphics2D)graphics; - if( null == printRenderer ) { - initPrint(); + if( !printActive || null == printGLAD ) { + throw new IllegalStateException("setupPrint() not called"); + } + sendReshape = false; // clear reshape flag + + printGraphics = (Graphics2D)graphics; + + System.err.println("AWT print.0: canvasSize "+getWidth()+"x"+getWidth()+", printAnimator "+printAnimator); + { + final RenderingHints rHints = printGraphics.getRenderingHints(); + final Set> rEntries = rHints.entrySet(); + int count = 0; + for(Iterator> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { + final Entry rEntry = rEntryIter.next(); + System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); + } + } + // final GraphicsConfiguration gc = printGraphics.getDeviceConfiguration(); + final AffineTransform aTrans = printGraphics.getTransform(); + System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); + System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + + final Rectangle gClipOrig = graphics.getClipBounds(); + final Rectangle gClip = new Rectangle(gClipOrig); + if( 0 > gClip.x ) { + gClip.width += gClip.x; + gClip.x = 0; } - if( null != printRenderer ) { - final Rectangle clip = graphics.getClipBounds(); - System.err.println("AWT print0.1: "+clip+", "+printRenderer); - printRenderer.setTileRect(clip.x, clip.y, clip.width, clip.height); + if( 0 > gClip.y ) { + gClip.height += gClip.y; + gClip.y = 0; } - System.err.println("AWT print0.2: "+printRenderer); - // super.print(graphics); - display(); - System.err.println("AWT print0.X: "+printRenderer); + printRenderer.setImageSize(gClip.width, gClip.height); + printRenderer.setTileOffset(gClip.x, gClip.y); + System.err.println("AWT print.0: "+gClipOrig+" -> "+gClip); + System.err.println("AWT print.0: "+printRenderer); + do { + printRenderer.display(); + } while ( !printRenderer.eot() ); + System.err.println("AWT print.X: "+printRenderer); } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java index 0f0f492b0..85ea0a3df 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java @@ -28,19 +28,6 @@ package com.jogamp.opengl.test.junit.jogl.tile; -import javax.media.opengl.*; - -import com.jogamp.opengl.util.Animator; -import javax.media.opengl.awt.GLCanvas; -import com.jogamp.newt.event.awt.AWTKeyAdapter; -import com.jogamp.newt.event.awt.AWTWindowAdapter; -import com.jogamp.newt.event.TraceKeyAdapter; -import com.jogamp.newt.event.TraceWindowAdapter; - -import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.test.junit.util.QuitAdapter; - import java.awt.BorderLayout; import java.awt.Button; import java.awt.Dimension; @@ -56,17 +43,37 @@ import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.print.StreamPrintService; +import javax.print.StreamPrintServiceFactory; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.MediaSizeName; + +import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; -import org.junit.AfterClass; -import org.junit.Test; import org.junit.FixMethodOrder; +import org.junit.Test; import org.junit.runners.MethodSorters; +import com.jogamp.newt.event.TraceKeyAdapter; +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestTiledPrintingGearsAWT extends UITestCase implements Printable { static GLProfile glp; @@ -137,44 +144,57 @@ public class TestTiledPrintingGearsAWT extends UITestCase implements Printable { */ Graphics2D g2d = (Graphics2D)g; - final int xScaleComp = (int) Math.round(printDPI/72.0); - final int yScaleComp = (int) Math.round(printDPI/72.0); + final int scaleComp; + { + final int xScaleComp = (int) Math.round(printDPI/72.0); + final int yScaleComp = (int) Math.round(printDPI/72.0); + scaleComp = Math.min(xScaleComp, yScaleComp); + } + final double scale; + { + final double xScale = 72.0/printDPI; + final double yScale = 72.0/printDPI; + scale = Math.min(xScale, yScale); + } - System.err.println("DPI: "+printDPI+", scaleComp "+xScaleComp+"/"+xScaleComp); - glCanvas.setupPrint(xScaleComp, yScaleComp); + System.err.println("DPI: "+printDPI+", scaleComp "+scaleComp); + glCanvas.setupPrint(); final int frameWidth = frame.getWidth(); final int frameHeight= frame.getHeight(); - if( xScaleComp != 1 || yScaleComp != 1 ) { - final double xScale = 72.0/printDPI; - final double yScale = 72.0/printDPI; - - final int frameWidthS = frameWidth*xScaleComp; - final int frameHeightS = frameHeight*yScaleComp; + final double moveX, moveY; + + if( scaleComp != 1 ) { + final int frameWidthS = frameWidth*(scaleComp-1); + final int frameHeightS = frameHeight*(scaleComp-1); - double xMargin = (pf.getImageableWidth() - frameWidthS*xScale)/2; - double yMargin = (pf.getImageableHeight() - frameHeightS*yScale)/2; - final double moveX, moveY; + double xMargin = (pf.getImageableWidth() - frameWidthS*scale)/2; + double yMargin = (pf.getImageableHeight() - frameHeightS*scale)/2; moveX = pf.getImageableX() + xMargin; moveY = pf.getImageableY() + yMargin; - System.err.println("DPI: "+printDPI+", scale "+xScale+"/"+yScale+", margin "+xMargin+"/"+yMargin+", move "+moveX+"/"+moveY+ + System.err.println("DPI: "+printDPI+", scale "+scale+", margin "+xMargin+"/"+yMargin+", move "+moveX+"/"+moveY+ ", frame: "+frameWidth+"x"+frameHeight+" -> "+frameWidthS+"x"+frameHeightS); - frame.setSize(frameWidthS, frameHeightS); - g2d.translate(moveX, moveY); - g2d.scale(xScale , yScale ); + frame.setSize(frameWidthS, frameHeightS); } else { - g2d.translate(pf.getImageableX(), pf.getImageableY()); + moveX = pf.getImageableX(); + moveY = pf.getImageableY(); + System.err.println("DPI: "+printDPI+", scale "+scale+", move "+moveX+"/"+moveY+ + ", frame: "+frameWidth+"x"+frameHeight); + } + g2d.translate(moveX, moveY); + if( scaleComp != 1 ) { + g2d.scale(scale , scale ); } frame.printAll(g); + glCanvas.releasePrint(); - if( xScaleComp != 1 || yScaleComp != 1 ) { + if( scaleComp != 1 ) { System.err.println("DPI: reset frame size "+frameWidth+"x"+frameHeight); frame.setSize(frameWidth, frameHeight); } - glCanvas.releasePrint(); /* tell the caller that this page is part of the printed document */ return PAGE_EXISTS; @@ -182,7 +202,88 @@ public class TestTiledPrintingGearsAWT extends UITestCase implements Printable { private Frame frame; private GLCanvas glCanvas; + + protected void doPrintAuto(int dpi, int pOrientation, Paper paper) { + final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); + aset.add(MediaSizeName.ISO_A1); // 594 × 841 mm + aset.add(MediaSizeName.ISO_A2); // 420 × 594 mm + aset.add(MediaSizeName.ISO_A3); // 297 × 420 mm + aset.add(MediaSizeName.ISO_A4); // 210 × 297 mm + + printCount++; + final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; + final String simpleTestName = getSimpleTestName("."); + + final String psMimeType = "application/postscript"; + final String pdfMimeType = "application/pdf"; + final PrinterJob pj = PrinterJob.getPrinterJob(); + StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(pdfMimeType); + if (factories.length > 0) { + final String fname = String.format("%-"+maxSimpleTestNameLen+"s-n%04d-dpi%03d.%s", simpleTestName, printCount, dpi, "pdf"); + System.err.println("doPrint: dpi "+dpi+", "+fname); + FileOutputStream outstream; + try { + outstream = new FileOutputStream(fname); + Assert.assertTrue(doPrintAutoImpl(pj, factories[0].getPrintService(outstream), dpi, pOrientation, paper)); + } catch (FileNotFoundException e) { + Assert.assertNull("Unexpected exception", e); + } + return; + } + System.err.println("No PDF"); + + factories = PrinterJob.lookupStreamPrintServices(psMimeType); + if (factories.length > 0) { + final String fname = String.format("%-"+maxSimpleTestNameLen+"s-n%04d-dpi%03d.%s", simpleTestName, printCount, dpi, "ps"); + System.err.println("doPrint: dpi "+dpi+", "+fname); + FileOutputStream outstream; + try { + outstream = new FileOutputStream(fname); + Assert.assertTrue(doPrintAutoImpl(pj, factories[0].getPrintService(outstream), dpi, pOrientation, paper)); + } catch (FileNotFoundException e) { + Assert.assertNull("Unexpected exception", e); + } + } + System.err.println("No PS"); + } + private int printCount = 0; + private boolean doPrintAutoImpl(PrinterJob job, StreamPrintService ps, int dpi, int pOrientation, Paper paper) { + printDPI = dpi; + boolean ok = true; + try { + PageFormat pageFormat = job.defaultPage(); + if( null != paper ) { + /** + Paper paper = new Paper(); + paper.setSize(500,500); // Large Address Dimension + paper.setImageableArea(20, 20, 450, 420); */ + pageFormat.setPaper(paper); + } + pageFormat.setOrientation(pOrientation); // PageFormat.LANDSCAPE or PageFormat.PORTRAIT + job.setPrintService(ps); + job.setPrintable(TestTiledPrintingGearsAWT.this, pageFormat); + job.print(); + } catch (PrinterException pe) { + pe.printStackTrace(); + ok = false; + } + return ok; + } + protected void doPrintManual(int dpi) { + printDPI = dpi; + PrinterJob job = PrinterJob.getPrinterJob(); + job.setPrintable(TestTiledPrintingGearsAWT.this); + boolean ok = job.printDialog(); + if (ok) { + try { + job.print(); + } catch (PrinterException ex) { + ex.printStackTrace(); + } + } + } + protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException { glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); @@ -196,31 +297,11 @@ public class TestTiledPrintingGearsAWT extends UITestCase implements Printable { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - PrinterJob job = PrinterJob.getPrinterJob(); - job.setPrintable(TestTiledPrintingGearsAWT.this); - boolean ok = job.printDialog(); - if (ok) { - try { - printDPI = 72; // default - job.print(); - } catch (PrinterException ex) { - ex.printStackTrace(); - } - } + doPrintAuto(72, PageFormat.PORTRAIT, null); // PageFormat.LANDSCAPE or PageFormat.PORTRAIT } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - PrinterJob job = PrinterJob.getPrinterJob(); - job.setPrintable(TestTiledPrintingGearsAWT.this); - boolean ok = job.printDialog(); - if (ok) { - try { - printDPI = 300; - job.print(); - } catch (PrinterException ex) { - ex.printStackTrace(); - } - } + doPrintAuto(300, PageFormat.PORTRAIT, null); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -251,8 +332,17 @@ public class TestTiledPrintingGearsAWT extends UITestCase implements Printable { animator.setUpdateFPSFrames(60, System.err); animator.start(); + boolean dpi72Done = false; + boolean dpi300Done = false; while(!quitAdapter.shouldQuit() && animator.isAnimating() && ( 0 == duration || animator.getTotalFPSDuration() Date: Fri, 6 Sep 2013 23:14:11 +0200 Subject: GLCanvas Printing WIP: Add GLJPanel; GLCanvas TILE_SIZE 512; print(Graphics): Don't force on AWT-EDT -> Deadlock; releasePrint(): perform reshape/display! --- make/scripts/tests.sh | 1 + .../classes/javax/media/opengl/awt/GLCanvas.java | 80 ++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 334 ++++++++++++++++++--- .../junit/jogl/tile/TestTiledPrintingGearsAWT.java | 9 +- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 226 ++++++++++++++ .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 9 +- .../opengl/test/junit/util/AWTRobotUtil.java | 18 +- 7 files changed, 589 insertions(+), 88 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2921bd409..65ec1d992 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -330,6 +330,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 14cc08feb..4ff25d0e6 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -736,7 +736,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing paint(g); } - private static final int PRINT_TILE_SIZE = 256; + private static final int PRINT_TILE_SIZE = 512; private volatile boolean printActive = false; private GLOffscreenAutoDrawable printGLAD = null; private TileRenderer printRenderer = null; @@ -874,7 +874,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( !printActive || null == printGLAD ) { throw new IllegalStateException("setupPrint() not called"); } + sendReshape = false; // clear reshape flag AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT); + sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized! + display(); } private final Runnable releasePrintOnEDT = new Runnable() { @Override @@ -908,49 +911,46 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( !printActive || null == printGLAD ) { throw new IllegalStateException("setupPrint() not called"); } + if(DEBUG && !EventQueue.isDispatchThread()) { + System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); + // we cannot dispatch print on AWT-EDT due to printing internal locking .. + } sendReshape = false; // clear reshape flag printGraphics = (Graphics2D)graphics; - AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, printOnEDT); - } - private final Runnable printOnEDT = new Runnable() { - @Override - public void run() { - sendReshape = false; // clear reshape flag - System.err.println("AWT print.0: canvasSize "+getWidth()+"x"+getWidth()+", printAnimator "+printAnimator); - { - final RenderingHints rHints = printGraphics.getRenderingHints(); - final Set> rEntries = rHints.entrySet(); - int count = 0; - for(Iterator> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { - final Entry rEntry = rEntryIter.next(); - System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); - } + System.err.println("AWT print.0: canvasSize "+getWidth()+"x"+getWidth()+", printAnimator "+printAnimator); + { + final RenderingHints rHints = printGraphics.getRenderingHints(); + final Set> rEntries = rHints.entrySet(); + int count = 0; + for(Iterator> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { + final Entry rEntry = rEntryIter.next(); + System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); } - // final GraphicsConfiguration gc = printGraphics.getDeviceConfiguration(); - final AffineTransform aTrans = printGraphics.getTransform(); - System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); - System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); - - final Rectangle gClipOrig = printGraphics.getClipBounds(); - final Rectangle gClip = new Rectangle(gClipOrig); - if( 0 > gClip.x ) { - gClip.width += gClip.x; - gClip.x = 0; - } - if( 0 > gClip.y ) { - gClip.height += gClip.y; - gClip.y = 0; - } - printRenderer.setImageSize(gClip.width, gClip.height); - printRenderer.setTileOffset(gClip.x, gClip.y); - System.err.println("AWT print.0: "+gClipOrig+" -> "+gClip); - System.err.println("AWT print.0: "+printRenderer); - do { - printRenderer.display(); - } while ( !printRenderer.eot() ); - System.err.println("AWT print.X: "+printRenderer); } - }; + // final GraphicsConfiguration gc = printGraphics.getDeviceConfiguration(); + final AffineTransform aTrans = printGraphics.getTransform(); + System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); + System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + + final Rectangle gClipOrig = printGraphics.getClipBounds(); + final Rectangle gClip = new Rectangle(gClipOrig); + if( 0 > gClip.x ) { + gClip.width += gClip.x; + gClip.x = 0; + } + if( 0 > gClip.y ) { + gClip.height += gClip.y; + gClip.y = 0; + } + printRenderer.setImageSize(gClip.width, gClip.height); + printRenderer.setTileOffset(gClip.x, gClip.y); + System.err.println("AWT print.0: "+gClipOrig+" -> "+gClip); + System.err.println("AWT print.0: "+printRenderer); + do { + printRenderer.display(); + } while ( !printRenderer.eot() ); + System.err.println("AWT print.X: "+printRenderer); + } @Override public void addGLEventListener(GLEventListener listener) { diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index a8235d396..84663cb3a 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -44,15 +44,22 @@ import java.awt.Color; import java.awt.EventQueue; import java.awt.FontMetrics; import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.Shape; +import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; import java.beans.Beans; import java.nio.IntBuffer; +import java.util.Iterator; import java.util.List; +import java.util.Set; +import java.util.Map.Entry; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; @@ -85,11 +92,15 @@ import jogamp.opengl.GLDrawableHelper; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.awt.Java2D; import jogamp.opengl.util.glsl.GLSLTextureRaster; + +import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider; import com.jogamp.opengl.util.GLPixelStorageModes; +import com.jogamp.opengl.util.TileRenderer; +import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider; @@ -138,7 +149,7 @@ import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvide */ @SuppressWarnings("serial") -public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol { +public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol, AWTPrintLifecycle { private static final boolean DEBUG; private static final boolean DEBUG_VIEWPORT; private static final boolean USE_GLSL_TEXTURE_RASTERIZER; @@ -430,9 +441,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing sendReshape = handleReshape(); } - if( isVisible() ) { + if( isVisible() && !printActive ) { updater.setGraphics(g); - backend.doPaintComponent(g); } } @@ -481,14 +491,237 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if (DEBUG) { System.err.println(getThreadName()+": GLJPanel.reshape: " +reshapeWidth+"x"+reshapeHeight + " -> " + width+"x"+height); - } - // reshapeX = x; - // reshapeY = y; - reshapeWidth = width; - reshapeHeight = height; - handleReshape = true; + } + if( !printActive ) { + // reshapeX = x; + // reshapeY = y; + reshapeWidth = width; + reshapeHeight = height; + handleReshape = true; + } + } + + private volatile boolean printActive = false; + private TileRenderer printRenderer = null; + private GLAnimatorControl printAnimator = null; + private AWTGLPixelBuffer printBuffer = null; + private BufferedImage printVFlipImage = null; + private Graphics2D printGraphics = null; + + @Override + public void setupPrint() { + if (!isInitialized) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet"); + } + return; // not yet available .. + } + if( !isVisible() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable visible"); + } + return; // not yet available .. + } + printActive = true; + sendReshape = false; // clear reshape flag + handleReshape = false; // ditto + AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } + private final Runnable setupPrintOnEDT = new Runnable() { + @Override + public void run() { + sendReshape = false; // clear reshape flag + handleReshape = false; // ditto + printAnimator = helper.getAnimator(); + if( null != printAnimator ) { + printAnimator.remove(GLJPanel.this); + } + final int tileWidth = getWidth(); + final int tileHeight = getHeight(); + + // FIXME final OffscreenBackend offscrBacken = (OffscreenBackend)backend; + final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); + caps.setOnscreen(false); + printRenderer = new TileRenderer(); + printRenderer.setRowOrder(TileRenderer.TR_TOP_TO_BOTTOM); + printRenderer.setTileSize(tileWidth, tileHeight, 0); + printRenderer.attachToAutoDrawable(GLJPanel.this); + + final GLEventListener preTileGLEL = new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) { + final GL gl = drawable.getGL(); + if( null == printBuffer ) { + final int componentCount = isOpaque() ? 3 : 4; + final AWTGLPixelBufferProvider printBufferProvider = new AWTGLPixelBufferProvider( true /* allowRowStride */ ); + final GLPixelAttributes pixelAttribs = printBufferProvider.getAttributes(gl, componentCount); + printBuffer = printBufferProvider.allocate(gl, pixelAttribs, tileWidth, tileHeight, 1, true, 0); + printRenderer.setTileBuffer(printBuffer); + printVFlipImage = new BufferedImage(printBuffer.width, printBuffer.height, printBuffer.image.getType()); + } + System.err.println("XXX tile-pre "+printRenderer); // FIXME + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }; + final GLEventListener postTileGLEL = new GLEventListener() { + int tTopRowHeight = 0; + @Override + public void init(GLAutoDrawable drawable) { + tTopRowHeight = 0; + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) { + // Copy temporary data into raster of BufferedImage for faster + // blitting Note that we could avoid this copy in the cases + // where !offscreenDrawable.isGLOriented(), + // but that's the software rendering path which is very slow anyway. + final int tHeight = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); + final int tWidth = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH); + // final BufferedImage dstImage = printBuffer.image; + final BufferedImage srcImage = printBuffer.image; + final BufferedImage dstImage = printVFlipImage; + final int[] src = ((DataBufferInt) srcImage.getRaster().getDataBuffer()).getData(); + final int[] dst = ((DataBufferInt) dstImage.getRaster().getDataBuffer()).getData(); + final int incr = printBuffer.width; + int srcPos = 0; + int destPos = (tHeight - 1) * printBuffer.width; + for (; destPos >= 0; srcPos += incr, destPos -= incr) { + System.arraycopy(src, srcPos, dst, destPos, incr); + } + // Draw resulting image in one shot + final int tRows = printRenderer.getParam(TileRenderer.TR_ROWS); + final int tRow = printRenderer.getParam(TileRenderer.TR_CURRENT_ROW); + final int pX = printRenderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); + final int pYf; + if( tRow == tRows - 1 ) { + tTopRowHeight = tHeight; + pYf = 0; + } else if( tRow == tRows - 2 ){ + pYf = tTopRowHeight; + } else { + pYf = ( tRows - 2 - tRow ) * tHeight + tTopRowHeight; + } + final Shape oClip = printGraphics.getClip(); + printGraphics.clipRect(pX, pYf, tWidth, tHeight); + final Shape clip = printGraphics.getClip(); + printGraphics.drawImage(dstImage, pX, pYf, dstImage.getWidth(), dstImage.getHeight(), null); // Null ImageObserver since image data is ready. + printGraphics.setColor(Color.BLACK); + printGraphics.drawRect(pX, pYf, tWidth, tHeight); + { + final Rectangle r = oClip.getBounds(); + printGraphics.setColor(Color.YELLOW); + printGraphics.drawRect(r.x, r.y, r.width, r.height); + } + printGraphics.setClip(oClip); + System.err.println("XXX tile-post.X clip "+oClip+" -> "+clip); + System.err.println("XXX tile-post.X "+printRenderer); + System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()+" -> "+pX+"/"+pYf); // +", "+dstImage); // FIXME + } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }; + printRenderer.setGLEventListener(preTileGLEL, postTileGLEL); + System.err.println("AWT print.setup "+printRenderer); // FIXME + } + }; + + @Override + public void releasePrint() { + if( !printActive ) { + throw new IllegalStateException("setupPrint() not called"); + } + sendReshape = false; // clear reshape flag + handleReshape = false; // ditto + AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT); + sendReshape = true; // trigger reshape, i.e. gl-viewport and -listener - this component might got resized! + handleReshape = true; // ditto + display(); + } + private final Runnable releasePrintOnEDT = new Runnable() { + @Override + public void run() { + printRenderer.detachFromAutoDrawable(); // tile-renderer -> printGLAD + if( null != printAnimator ) { + printAnimator.add(GLJPanel.this); + } + System.err.println("AWT print.release "+printRenderer); // FIXME + printRenderer = null; + printAnimator = null; + if( null != printBuffer ) { + printBuffer.dispose(); + printBuffer = null; + } + if( null != printVFlipImage ) { + printVFlipImage.flush(); + printVFlipImage = null; + } + printGraphics = null; + printActive = false; + } + }; + + @Override + public void print(Graphics graphics) { + if( !printActive ) { + throw new IllegalStateException("setupPrint() not called"); + } + if(DEBUG && !EventQueue.isDispatchThread()) { + System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); + // we cannot dispatch print on AWT-EDT due to printing internal locking .. + } + sendReshape = false; // clear reshape flag + handleReshape = false; // ditto + printGraphics = (Graphics2D)graphics; + System.err.println("AWT print.0: canvasSize "+getWidth()+"x"+getWidth()+", printAnimator "+printAnimator); + { + final RenderingHints rHints = printGraphics.getRenderingHints(); + final Set> rEntries = rHints.entrySet(); + int count = 0; + for(Iterator> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { + final Entry rEntry = rEntryIter.next(); + System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); + } + } + // final GraphicsConfiguration gc = printGraphics.getDeviceConfiguration(); + final AffineTransform aTrans = printGraphics.getTransform(); + System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); + System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + + final Rectangle gClipOrig = printGraphics.getClipBounds(); + final Rectangle gClip = new Rectangle(gClipOrig); + if( 0 > gClip.x ) { + gClip.width += gClip.x; + gClip.x = 0; + } + if( 0 > gClip.y ) { + gClip.height += gClip.y; + gClip.y = 0; + } + printRenderer.setImageSize(gClip.width, gClip.height); + printRenderer.setTileOffset(gClip.x, gClip.y); + System.err.println("AWT print.0: "+gClipOrig+" -> "+gClip); + System.err.println("AWT print.0: "+printRenderer); + do { + // printRenderer.display(); + backend.doPlainPaint(); + } while ( !printRenderer.eot() ); + System.err.println("AWT print.X: "+printRenderer); + } + @Override + protected void printComponent(Graphics g) { + System.err.println("AWT printComponent.X: "+printRenderer); + print(g); + } + @Override public void setOpaque(boolean opaque) { if (backend != null) { @@ -877,13 +1110,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing backend.postGL(g, true); } + public void print(GLAutoDrawable drawable) { + helper.display(GLJPanel.this); + } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { // This is handled above and dispatched directly to the appropriate context } - - public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { - } } @Override @@ -932,6 +1166,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } }; + private final Runnable updaterPlainDisplayAction = new Runnable() { + @Override + public void run() { + updater.print(GLJPanel.this); + } + }; + private final Runnable paintImmediatelyAction = new Runnable() { @Override public void run() { @@ -968,60 +1209,73 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // Implementations of the various backends // - // Abstraction of the different rendering backends: i.e., pure - // software / pixmap rendering, pbuffer-based acceleration, Java 2D - // / JOGL bridge + /** + * Abstraction of the different rendering backends: i.e., pure + * software / pixmap rendering, pbuffer-based acceleration, Java 2D + * JOGL bridge + */ static interface Backend { - // Create, Destroy, .. + /** Create, Destroy, .. */ public boolean isUsingOwnLifecycle(); - // Called each time the backend needs to initialize itself + /** Called each time the backend needs to initialize itself */ public void initialize(); - // Called when the backend should clean up its resources + /** Called when the backend should clean up its resources */ public void destroy(); - // Called when the opacity of the GLJPanel is changed + /** Called when the opacity of the GLJPanel is changed */ public void setOpaque(boolean opaque); - // Called to manually create an additional OpenGL context against - // this GLJPanel + /** + * Called to manually create an additional OpenGL context against + * this GLJPanel + */ public GLContext createContext(GLContext shareWith); - // Called to set the current backend's GLContext + /** Called to set the current backend's GLContext */ public void setContext(GLContext ctx); - // Called to get the current backend's GLContext + /** Called to get the current backend's GLContext */ public GLContext getContext(); - // Called to get the current backend's GLDrawable + /** Called to get the current backend's GLDrawable */ public GLDrawable getDrawable(); /** Returns the used texture unit, i.e. a value of [0..n], or -1 if non used. */ public int getTextureUnit(); - // Called to fetch the "real" GLCapabilities for the backend + /** Called to fetch the "real" GLCapabilities for the backend */ public GLCapabilitiesImmutable getChosenGLCapabilities(); - // Called to fetch the "real" GLProfile for the backend + /** Called to fetch the "real" GLProfile for the backend */ public GLProfile getGLProfile(); - // Called to handle a reshape event. When this is called, the - // OpenGL context associated with the backend is not current, to - // make it easier to destroy and re-create pbuffers if necessary. + /** + * Called to handle a reshape event. When this is called, the + * OpenGL context associated with the backend is not current, to + * make it easier to destroy and re-create pbuffers if necessary. + */ public boolean handleReshape(); - // Called before the OpenGL work is done in init() and display(). - // If false is returned, this render is aborted. + /** + * Called before the OpenGL work is done in init() and display(). + * If false is returned, this render is aborted. + */ public boolean preGL(Graphics g); - // Called after the OpenGL work is done in init() and display(). - // The isDisplay argument indicates whether this was called on - // behalf of a call to display() rather than init(). + /** + * Called after the OpenGL work is done in init() and display(). + * The isDisplay argument indicates whether this was called on + * behalf of a call to display() rather than init(). + */ public void postGL(Graphics g, boolean isDisplay); - // Called from within paintComponent() to initiate the render + /** Called from within paintComponent() to initiate the render */ public void doPaintComponent(Graphics g); + + /** Called from print .. no backend update desired onscreen */ + public void doPlainPaint(); } // Base class used by both the software (pixmap) and pbuffer @@ -1316,6 +1570,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null); // Null ImageObserver since image data is ready. } } + + @Override + public void doPlainPaint() { + helper.invokeGL(offscreenDrawable, offscreenContext, updaterPlainDisplayAction, updaterInitAction); + } @Override public boolean handleReshape() { @@ -1830,6 +2089,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing }); } + @Override + public void doPlainPaint() { + helper.invokeGL(joglDrawable, joglContext, updaterPlainDisplayAction, updaterInitAction); + } + private void captureJ2DState(GL gl, Graphics g) { gl.glGetIntegerv(GL2.GL_DRAW_BUFFER, drawBuffer, 0); gl.glGetIntegerv(GL2.GL_READ_BUFFER, readBuffer, 0); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java index 7d6135935..30967d75b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java @@ -58,6 +58,7 @@ import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; @@ -97,7 +98,7 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { final Gears gears = new Gears(); glCanvas.addGLEventListener(gears); - final Frame frame = new Frame("Gears AWT Test"); + final Frame frame = new Frame("AWT Print (offscr "+offscreenPrinting+")"); Assert.assertNotNull(frame); final ActionListener print72DPIAction = new ActionListener() { @@ -141,6 +142,9 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { frame.pack(); frame.setVisible(true); }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true)); + animator.setUpdateFPSFrames(60, System.err); animator.start(); @@ -157,6 +161,9 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { } } + try { + Thread.sleep(1000); // time to flush .. + } catch (InterruptedException e) { } Assert.assertNotNull(frame); Assert.assertNotNull(glCanvas); Assert.assertNotNull(animator); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java new file mode 100644 index 000000000..260c9e04c --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -0,0 +1,226 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.tile; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.print.PageFormat; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.newt.event.TraceKeyAdapter; +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.util.Animator; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { + + static boolean waitForKey = false; + static GLProfile glp; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2)) { + glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + width = 640; + height = 480; + } else { + setTestSupported(false); + } + // Runtime.getRuntime().traceInstructions(true); + // Runtime.getRuntime().traceMethodCalls(true); + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilities caps, final boolean offscreenPrinting) throws InterruptedException, InvocationTargetException { + final GLJPanel glJPanel = new GLJPanel(caps); + Assert.assertNotNull(glJPanel); + Dimension glc_sz = new Dimension(width, height); + glJPanel.setMinimumSize(glc_sz); + glJPanel.setPreferredSize(glc_sz); + glJPanel.setSize(glc_sz); + + final Gears gears = new Gears(); + glJPanel.addGLEventListener(gears); + + final JFrame frame = new JFrame("Swing Print (offscr "+offscreenPrinting+")"); + Assert.assertNotNull(frame); + + final ActionListener print72DPIAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + doPrintManual(frame, glJPanel, TestTiledPrintingGearsSwingAWT.this, offscreenPrinting, 72); + } }; + final ActionListener print300DPIAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + doPrintManual(frame, glJPanel, TestTiledPrintingGearsSwingAWT.this, offscreenPrinting, 300); + } }; + final Button print72DPIButton = new Button("72dpi"); + print72DPIButton.addActionListener(print72DPIAction); + final Button print300DPIButton = new Button("300dpi"); + print300DPIButton.addActionListener(print300DPIAction); + + final JPanel printPanel = new JPanel(); + printPanel.add(print72DPIButton); + printPanel.add(print300DPIButton); + final JPanel southPanel = new JPanel(); + southPanel.add(new Label("South")); + final JPanel eastPanel = new JPanel(); + eastPanel.add(new Label("East")); + final JPanel westPanel = new JPanel(); + westPanel.add(new Label("West")); + + Animator animator = new Animator(glJPanel); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + final Container fcont = frame.getContentPane(); + fcont.setLayout(new BorderLayout()); + fcont.add(printPanel, BorderLayout.NORTH); + fcont.add(glJPanel, BorderLayout.CENTER); + fcont.add(southPanel, BorderLayout.SOUTH); + fcont.add(eastPanel, BorderLayout.EAST); + fcont.add(westPanel, BorderLayout.WEST); + fcont.validate(); + frame.pack(); + frame.setVisible(true); + } } ) ; + + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel, true)); + + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + Assert.assertEquals(true, animator.isAnimating()); + + boolean dpi72Done = false; + boolean dpi300Done = false; + while(!quitAdapter.shouldQuit() && animator.isAnimating() && ( 0 == duration || animator.getTotalFPSDuration() drawable.setRealized(true); - if(wait=POLL_DIVIDER) { // for some reason GLCanvas hasn't been painted yet, force it! - System.err.println("XXX: FORCE REPAINT PRE - canvas: "+glcanvas); - glcanvas.repaint(); - for (wait=0; wait Date: Sat, 7 Sep 2013 19:59:15 +0200 Subject: TiledPrintingAWTBase: Fix scaling - Fit frame to page, add MSAA RenderingHints test; setupPrint(Graphics2D): Query RenderingHints to use MSAA rendering - AWTPrintLifecycle.setupPrint(Graphics2D): Query RenderingHints to use MSAA rendering - Impl. in GLCanvas - TODO GLJPanel (would need a new offscreen buffer) - TiledPrintingAWTBase: - Fix scaling - Fit frame to page - add MSAA RenderingHints test - GLCanvas: Remove dumpStack() DEBUG output --- make/scripts/tests.sh | 6 +- .../javax/media/opengl/awt/AWTPrintLifecycle.java | 12 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 62 +-- .../classes/javax/media/opengl/awt/GLJPanel.java | 6 +- .../classes/jogamp/opengl/GLFBODrawableImpl.java | 2 +- .../junit/jogl/demos/gl2/awt/TestGearsAWT.java | 12 +- .../junit/jogl/tile/TestTiledPrintingGearsAWT.java | 42 ++- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 29 +- .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 415 ++++++++++++--------- 9 files changed, 348 insertions(+), 238 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 65ec1d992..fee4b3ec0 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -216,7 +216,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" - #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel" + D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" #D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" @@ -326,11 +326,11 @@ function testawtswt() { # tile rendring / printing w/ & w/o AWT # #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2GL2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java b/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java index afa27dbd8..077ee42a9 100644 --- a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java +++ b/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java @@ -1,5 +1,3 @@ -package javax.media.opengl.awt; - /** * Copyright 2013 JogAmp Community. All rights reserved. * @@ -27,9 +25,12 @@ package javax.media.opengl.awt; * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ +package javax.media.opengl.awt; import javax.media.opengl.GLAutoDrawable; import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; /** * Interface describing print lifecycle to support AWT printing @@ -38,12 +39,13 @@ import java.awt.Component; public interface AWTPrintLifecycle { /** - * Shall be called before {@link Component#print(java.awt.Graphics)}. + * Shall be called before {@link Component#print(Graphics)}. + * @param g2d the {@link Graphics2D} instance, which will be used for printing. */ - void setupPrint(); + void setupPrint(Graphics2D g2d); /** - * Shall be called after very last {@link Component#print(java.awt.Graphics)}. + * Shall be called after very last {@link Component#print(Graphics)}. */ void releasePrint(); } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 5ada2d80f..8f9684db1 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -375,7 +375,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing System.err.println("Created Config (n): HAVE CF "+awtConfig); System.err.println("Created Config (n): Choosen CF "+config); System.err.println("Created Config (n): EQUALS CAPS "+equalCaps); - Thread.dumpStack(); + // Thread.dumpStack(); } if (compatible != null) { @@ -565,7 +565,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if(DEBUG) { System.err.println(getThreadName()+": Info: addNotify - start, bounds: "+this.getBounds()+", isBeansDesignTime "+isBeansDesignTime); - Thread.dumpStack(); + // Thread.dumpStack(); } if( isBeansDesignTime ) { @@ -642,7 +642,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final boolean res = _drawable.isRealized(); if(DEBUG) { System.err.println(getThreadName()+": Realized Drawable: isRealized "+res+", "+_drawable.toString()); - Thread.dumpStack(); + // Thread.dumpStack(); } return res; } @@ -662,7 +662,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing public void removeNotify() { if(DEBUG) { System.err.println(getThreadName()+": Info: removeNotify - start"); - Thread.dumpStack(); + // Thread.dumpStack(); } awtWindowClosingProtocol.removeClosingListener(); @@ -731,12 +731,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private static final int PRINT_TILE_SIZE = 512; private volatile boolean printActive = false; + private boolean printUseAA = false; private GLAnimatorControl printAnimator = null; private GLOffscreenAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint() { + public void setupPrint(Graphics2D g2d) { if( !validateGLDrawable() ) { if(DEBUG) { System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable not valid yet"); @@ -751,6 +752,25 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } printActive = true; sendReshape = false; // clear reshape flag + final RenderingHints rHints = g2d.getRenderingHints(); + { + final Object _useAA = rHints.get(RenderingHints.KEY_ANTIALIASING); + printUseAA = null != _useAA && ( _useAA == RenderingHints.VALUE_ANTIALIAS_DEFAULT || _useAA == RenderingHints.VALUE_ANTIALIAS_ON ); + } + if( DEBUG ) { + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", useAA "+printUseAA+", printAnimator "+printAnimator); + { + final Set> rEntries = rHints.entrySet(); + int count = 0; + for(Iterator> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { + final Entry rEntry = rEntryIter.next(); + System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); + } + } + final AffineTransform aTrans = g2d.getTransform(); + System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); + System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + } AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } private final Runnable setupPrintOnEDT = new Runnable() { @@ -762,6 +782,19 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printAnimator.remove(GLCanvas.this); } final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); + caps.setDoubleBuffered(false); + final GLProfile glp = caps.getGLProfile(); + if( printUseAA && !caps.getSampleBuffers() ) { + if ( !glp.isGL2ES3() ) { + if( DEBUG ) { + System.err.println("Ignore MSAA due to gl-profile < GL2ES3"); + } + printUseAA = false; + } else { + caps.setSampleBuffers(true); + caps.setNumSamples(8); // FIXME + } + } caps.setOnscreen(false); final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); @@ -775,6 +808,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printAWTTiles = new AWTTilePainter(printRenderer, componentCount, DEBUG); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); + System.err.println("AWT print.setup AA "+printUseAA+", "+caps); + System.err.println("AWT print.setup "+printGLAD); } } }; @@ -820,21 +855,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } sendReshape = false; // clear reshape flag final Graphics2D printGraphics = (Graphics2D)graphics; - if( DEBUG ) { - System.err.println("AWT print.0: canvasSize "+getWidth()+"x"+getWidth()+", printAnimator "+printAnimator); - { - final RenderingHints rHints = printGraphics.getRenderingHints(); - final Set> rEntries = rHints.entrySet(); - int count = 0; - for(Iterator> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { - final Entry rEntry = rEntryIter.next(); - System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); - } - } - final AffineTransform aTrans = printGraphics.getTransform(); - System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); - System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); - } printAWTTiles.updateGraphics2DAndClipBounds(printGraphics); final TileRenderer tileRenderer = printAWTTiles.getTileRenderer(); if( DEBUG ) { @@ -1070,7 +1090,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if(DEBUG) { System.err.println(getThreadName()+": Info: destroyOnEDTAction() - START, hasContext " + (null!=context) + ", hasDrawable " + (null!=drawable)+", "+animator); - Thread.dumpStack(); + // Thread.dumpStack(); } final boolean animatorPaused; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 1f9e65a7d..2488bd443 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -505,7 +505,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint() { + public void setupPrint(Graphics2D g2d) { if (!isInitialized) { if(DEBUG) { System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet"); @@ -1200,8 +1200,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing OffscreenBackend(GLProfile glp, AWTGLPixelBufferProvider custom) { if(null == custom) { - pixelBufferProvider = ( glp.isGL2GL3() || glp.isGL3ES3() ) ? getSingleAWTGLPixelBufferProvider() : - new AWTGLPixelBufferProvider( false /* allowRowStride */ ) ; + pixelBufferProvider = glp.isGL2ES3() ? getSingleAWTGLPixelBufferProvider() : + new AWTGLPixelBufferProvider( false /* allowRowStride */ ) ; } else { pixelBufferProvider = custom; } diff --git a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java index d7979efdb..f2248b388 100644 --- a/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLFBODrawableImpl.java @@ -43,7 +43,7 @@ public class GLFBODrawableImpl extends GLDrawableImpl implements GLFBODrawable { static { Debug.initSingleton(); DEBUG = GLDrawableImpl.DEBUG || Debug.debug("FBObject"); - DEBUG_SWAP = Debug.isPropertyDefined("jogl.debug.FBObject.Swap", true); + DEBUG_SWAP = DEBUG || Debug.isPropertyDefined("jogl.debug.FBObject.Swap", true); } private final GLDrawableImpl parent; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java index d23130d36..24a6d578c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/awt/TestGearsAWT.java @@ -60,6 +60,7 @@ public class TestGearsAWT extends UITestCase { static GLProfile glp; static int width, height; static boolean waitForKey = false; + static int msaaCount = 0; @BeforeClass public static void initClass() { @@ -132,6 +133,10 @@ public class TestGearsAWT extends UITestCase { @Test public void test01() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); + if( msaaCount > 0 ) { + caps.setSampleBuffers(true); + caps.setNumSamples(msaaCount); + } runTestGL(caps); } @@ -144,9 +149,14 @@ public class TestGearsAWT extends UITestCase { try { duration = Integer.parseInt(args[i]); } catch (Exception ex) { ex.printStackTrace(); } + } else if(args[i].equals("-msaa")) { + i++; + try { + msaaCount = Integer.parseInt(args[i]); + } catch (Exception ex) { ex.printStackTrace(); } } else if(args[i].equals("-wait")) { waitForKey = true; - } + } } if(waitForKey) { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java index 511880a0d..86c06247f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java @@ -103,20 +103,27 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, glCanvas, TestTiledPrintingGearsAWT.this, offscreenPrinting, 72); + doPrintManual(frame, glCanvas, TestTiledPrintingGearsAWT.this, offscreenPrinting, 72, false); + } }; + final ActionListener print150DPIAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + doPrintManual(frame, glCanvas, TestTiledPrintingGearsAWT.this, offscreenPrinting, 150, false); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, glCanvas, TestTiledPrintingGearsAWT.this, offscreenPrinting, 300); + doPrintManual(frame, glCanvas, TestTiledPrintingGearsAWT.this, offscreenPrinting, 300, false); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); + final Button print150DPIButton = new Button("150dpi"); + print150DPIButton.addActionListener(print150DPIAction); final Button print300DPIButton = new Button("300dpi"); print300DPIButton.addActionListener(print300DPIAction); frame.setLayout(new BorderLayout()); Panel printPanel = new Panel(); printPanel.add(print72DPIButton); + printPanel.add(print150DPIButton); printPanel.add(print300DPIButton); Panel southPanel = new Panel(); southPanel.add(new Label("South")); @@ -149,18 +156,24 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { animator.start(); boolean dpi72Done = false; - boolean dpi300Done = false; + boolean dpi150Done = false; while(!quitAdapter.shouldQuit() && animator.isAnimating() && ( 0 == duration || animator.getTotalFPSDuration() 0) { // We have only one page, and 'page' is zero-based - return NO_SUCH_PAGE; - } - - final Paper paper = pf.getPaper(); - final double paperWWidthInch = paper.getWidth() / 72.0; - final double paperWHeightInch = paper.getHeight() / 72.0; - final double paperIWidthInch = paper.getImageableWidth() / 72.0; - final double paperIHeightInch = paper.getImageableHeight() / 72.0; - final double paperWWidthMM = paperWWidthInch * mmPerInch; - final double paperWHeightMM = paperWHeightInch * mmPerInch; - final double paperIWidthMM = paperIWidthInch * mmPerInch; - final double paperIHeightMM = paperIHeightInch * mmPerInch; - - final double pfWWidthInch = pf.getWidth() / 72.0; - final double pfWHeightInch = pf.getHeight() / 72.0; - final double pfIWidthInch = pf.getImageableWidth() / 72.0;; - final double pfIHeightInch = pf.getImageableHeight() / 72.0; - final double pfWWidthMM = pfWWidthInch * mmPerInch; - final double pfWHeightMM = pfWHeightInch * mmPerInch; - final double pfIWidthMM = pfIWidthInch * mmPerInch; - final double pfIHeightMM = pfIHeightInch * mmPerInch; - - System.err.println("PF: Paper whole size "+Math.round(paperWWidthMM)+" x "+Math.round(paperWHeightMM)+" mm, "+Math.round(paperWWidthInch)+" x "+Math.round(paperWHeightInch)+" inch"); - System.err.println("PF: Paper image size "+paper.getImageableX()+" / "+paper.getImageableY()+" "+Math.round(paperIWidthMM)+" x "+Math.round(paperIHeightMM)+" mm, "+Math.round(paperIWidthInch)+" x "+Math.round(paperIHeightInch)+" inch"); - System.err.println("PF: Page whole size "+Math.round(pfWWidthMM)+" x "+Math.round(pfWHeightMM)+" mm, "+Math.round(pfWWidthInch)+" x "+Math.round(pfWHeightInch)+" inch"); - System.err.println("PF: Page image size "+pf.getImageableX()+" / "+pf.getImageableY()+" "+Math.round(pfIWidthMM)+" x "+Math.round(pfIHeightMM)+" mm, "+Math.round(pfIWidthInch)+" x "+Math.round(pfIHeightInch)+" inch"); - System.err.println("PF: Page orientation "+pf.getOrientation()); - - /** - * User (0,0) is typically outside the imageable area, so we must - * translate by the X and Y values in the PageFormat to avoid clipping - */ - - final int scaleComp; - { - final int xScaleComp = (int) Math.round(printDPI/72.0); - final int yScaleComp = (int) Math.round(printDPI/72.0); - scaleComp = Math.min(xScaleComp, yScaleComp); - } - final double scale; - { - final double xScale = 72.0/printDPI; - final double yScale = 72.0/printDPI; - scale = Math.min(xScale, yScale); - } + public int print(Graphics g, PageFormat pf, int page) throws PrinterException { + if (page > 0) { // We have only one page, and 'page' is zero-based + return NO_SUCH_PAGE; + } + + lockPrinting.lock(); + try { + final Paper paper = pf.getPaper(); + final double paperWWidthInch = paper.getWidth() / 72.0; + final double paperWHeightInch = paper.getHeight() / 72.0; + final double paperIWidthInch = paper.getImageableWidth() / 72.0; + final double paperIHeightInch = paper.getImageableHeight() / 72.0; + final double paperWWidthMM = paperWWidthInch * MM_PER_INCH; + final double paperWHeightMM = paperWHeightInch * MM_PER_INCH; + final double paperIWidthMM = paperIWidthInch * MM_PER_INCH; + final double paperIHeightMM = paperIHeightInch * MM_PER_INCH; - System.err.println("PRINT offscreen: "+printOffscreen+", thread "+Thread.currentThread().getName()); - System.err.println("PRINT DPI: "+printDPI+", scaleComp "+scaleComp); - awtPrintObject.setupPrint(); - - final int frameWidth = frame.getWidth(); - final int frameHeight= frame.getHeight(); - - final double moveX, moveY; - - if( scaleComp != 1 ) { - final int frameWidthS = frameWidth*(scaleComp-1); - final int frameHeightS = frameHeight*(scaleComp-1); - - double xMargin = (pf.getImageableWidth() - frameWidthS*scale)/2; - double yMargin = (pf.getImageableHeight() - frameHeightS*scale)/2; - moveX = pf.getImageableX() + xMargin; - moveY = pf.getImageableY() + yMargin; - System.err.println("PRINT DPI: "+printDPI+", scale "+scale+", margin "+xMargin+"/"+yMargin+", move "+moveX+"/"+moveY+ - ", frame: "+frameWidth+"x"+frameHeight+" -> "+frameWidthS+"x"+frameHeightS); - - AWTEDTExecutor.singleton.invoke(true, new Runnable() { - public void run() { - frame.setSize(frameWidthS, frameHeightS); - frame.invalidate(); - frame.validate(); - } - }); - } else { - moveX = pf.getImageableX(); - moveY = pf.getImageableY(); - System.err.println("PRINT DPI: "+printDPI+", scale "+scale+", move "+moveX+"/"+moveY+ - ", frame: "+frameWidth+"x"+frameHeight); - } - - final Graphics2D printG2D = (Graphics2D)g; - - final Graphics2D offscreenG2D; - final BufferedImage offscreenImage; - if( printOffscreen ) { - final int w = frame.getWidth(); - final int h = frame.getHeight(); - offscreenImage = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR); - offscreenG2D = (Graphics2D) offscreenImage.getGraphics(); - offscreenG2D.setClip(0, 0, w, h); + final double pfWWidthInch = pf.getWidth() / 72.0; + final double pfWHeightInch = pf.getHeight() / 72.0; + final double pfIWidthInch = pf.getImageableWidth() / 72.0; + final double pfIHeightInch = pf.getImageableHeight() / 72.0; + final double pfWWidthMM = pfWWidthInch * MM_PER_INCH; + final double pfWHeightMM = pfWHeightInch * MM_PER_INCH; + final double pfIWidthMM = pfIWidthInch * MM_PER_INCH; + final double pfIHeightMM = pfIHeightInch * MM_PER_INCH; + + System.err.println("PF: Paper whole size "+ + Math.round(paperWWidthMM)+" x "+Math.round(paperWHeightMM)+" mm, "+ + Math.round(paperWWidthInch)+" x "+Math.round(paperWHeightInch)+" inch"); + + System.err.println("PF: Paper image size "+paper.getImageableX()+" / "+paper.getImageableY()+" "+ + Math.round(paperIWidthMM)+" x "+Math.round(paperIHeightMM)+" mm, "+ + Math.round(paperIWidthInch)+" x "+Math.round(paperIHeightInch)+" inch, "+ + Math.round(paper.getImageableWidth())+"x"+Math.round(paper.getImageableHeight())+" 72dpi dots"); + + System.err.println("PF: Page whole size "+ + Math.round(pfWWidthMM)+" x "+Math.round(pfWHeightMM)+" mm, "+ + Math.round(pfWWidthInch)+" x "+Math.round(pfWHeightInch)+" inch"); + + System.err.println("PF: Page image size "+pf.getImageableX()+" / "+pf.getImageableY()+" "+ + Math.round(pfIWidthMM)+" x "+Math.round(pfIHeightMM)+" mm, "+ + Math.round(pfIWidthInch)+" x "+Math.round(pfIHeightInch)+" inch, "+ + Math.round(pf.getImageableWidth())+"x"+Math.round(pf.getImageableHeight())+" 72dpi dots"); + + System.err.println("PF: Page orientation "+pf.getOrientation()); + + /** + * We fit the frame into the imageable area with the desired DPI. + *

        + * We assume AWT painting happens w/ 72 dpi! + *

        + *

        + * The frame borders are considered. + *

        + */ + final Insets frameInsets = frame.getInsets(); + final int frameWidth = frame.getWidth(); + final int frameHeight= frame.getHeight(); + final int frameWidthS; + final int frameHeightS; + final double scaleComp; + { + final int frameBorderW = frameInsets.left + frameInsets.right; + final int frameBorderH = frameInsets.top + frameInsets.bottom; + final double sx = pf.getImageableWidth() / ( frameWidth + frameBorderW ); + final double sy = pf.getImageableHeight() / ( frameHeight + frameBorderH ); + scaleComp = Math.min(sx, sy) * ( printDPI/72.0 ); + if( 0f < scaleComp ) { + frameWidthS = (int) ( frameWidth*scaleComp ); // cut off FIXME + frameHeightS = (int) ( frameHeight*scaleComp ); // cut off FIXME } else { - offscreenG2D = null; - offscreenImage = null; - } - - final Graphics2D g2d = null != offscreenG2D ? offscreenG2D : printG2D; - - if( g2d != offscreenG2D ) { - g2d.translate(moveX, moveY); - g2d.scale(scale , scale ); + frameWidthS = frameWidth; + frameHeightS = frameHeight; } + } + // Since we fit the frame size into the imageable size respecting the DPI, + // we simply can scale the print graphics matrix to the DPI + // w/o the need to fiddle w/ the margins (matrix translation). + final double scaleGraphics = 72.0 / printDPI; + + System.err.println("PRINT offscreen: "+printOffscreen+", thread "+Thread.currentThread().getName()); + System.err.println("PRINT DPI: "+printDPI+", AA "+printAA+", scaleGraphics "+scaleGraphics+", scaleComp "+scaleComp+ + ", frame: border "+frameInsets+", size "+frameWidth+"x"+frameHeight+" -> "+frameWidthS+"x"+frameHeightS); + + final Graphics2D printG2D = (Graphics2D)g; + final Graphics2D offscreenG2D; + final BufferedImage offscreenImage; + final Graphics2D g2d; + if( printOffscreen ) { + offscreenImage = new BufferedImage(frameWidthS, frameHeightS, BufferedImage.TYPE_4BYTE_ABGR); + offscreenG2D = (Graphics2D) offscreenImage.getGraphics(); + offscreenG2D.setClip(0, 0, frameWidthS, frameHeightS); + g2d = offscreenG2D; + } else { + offscreenG2D = null; + offscreenImage = null; + g2d = printG2D; + g2d.translate(pf.getImageableX(), pf.getImageableY()); + g2d.scale(scaleGraphics, scaleGraphics); + } + if( printAA ) { + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + } + awtPrintObject.setupPrint(g2d); + try { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + frame.setSize(frameWidthS, frameHeightS); + frame.invalidate(); + frame.validate(); + } + }); + AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { frame.printAll(g2d); } } ); - if( scaleComp != 1 ) { - System.err.println("PRINT DPI: reset frame size "+frameWidth+"x"+frameHeight); - AWTEDTExecutor.singleton.invoke(true, new Runnable() { - public void run() { - frame.setSize(frameWidth, frameHeight); - frame.invalidate(); - frame.validate(); - } - }); - } + System.err.println("PRINT DPI: reset frame size "+frameWidth+"x"+frameHeight); + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + frame.setSize(frameWidth, frameHeight); + frame.invalidate(); + frame.validate(); + } + }); + } finally { awtPrintObject.releasePrint(); - - if( g2d == offscreenG2D ) { - printG2D.translate(moveX, moveY); - printG2D.scale(scale , scale ); - printG2D.drawImage(offscreenImage, 0, 0, offscreenImage.getWidth(), offscreenImage.getHeight(), null); // Null ImageObserver since image data is ready. - } - - /* tell the caller that this page is part of the printed document */ - return PAGE_EXISTS; } + + if( printOffscreen ) { + printG2D.translate(pf.getImageableX(), pf.getImageableY()); + printG2D.scale(scaleGraphics, scaleGraphics); + printG2D.drawImage(offscreenImage, 0, 0, offscreenImage.getWidth(), offscreenImage.getHeight(), null); // Null ImageObserver since image data is ready. + } + + /* tell the caller that this page is part of the printed document */ + return PAGE_EXISTS; + } finally { + lockPrinting.unlock(); + } + } + private RecursiveLock lock = LockFactory.createRecursiveLock(); private int printCount = 0; public TiledPrintingAWTBase() { super(); } - protected void doPrintAuto(Frame frame, AWTPrintLifecycle awtPrintObject, - Printable printable, int pOrientation, Paper paper, boolean offscreen, int dpi) { - final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); - aset.add(MediaSizeName.ISO_A1); // 594 × 841 mm - aset.add(MediaSizeName.ISO_A2); // 420 × 594 mm - aset.add(MediaSizeName.ISO_A3); // 297 × 420 mm - aset.add(MediaSizeName.ISO_A4); // 210 × 297 mm - - printCount++; - - final String psMimeType = "application/postscript"; - final String pdfMimeType = "application/pdf"; - final PrinterJob pj = PrinterJob.getPrinterJob(); - - StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(pdfMimeType); - if (factories.length > 0) { - final String fname = getPrintFilename(dpi, "pdf"); - System.err.println("doPrint: dpi "+dpi+", "+fname); - FileOutputStream outstream; - try { - outstream = new FileOutputStream(fname); - Assert.assertTrue(doPrintAutoImpl(frame, awtPrintObject, printable, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscreen, dpi)); - } catch (FileNotFoundException e) { - Assert.assertNull("Unexpected exception", e); - } - return; - } - System.err.println("No PDF"); + public void doPrintAuto(Frame frame, AWTPrintLifecycle awtPrintObject, + Printable printable, int pOrientation, Paper paper, boolean offscreen, int dpi, boolean antialiasing) { + lock.lock(); + try { + final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); + aset.add(MediaSizeName.ISO_A1); // 594 × 841 mm + aset.add(MediaSizeName.ISO_A2); // 420 × 594 mm + aset.add(MediaSizeName.ISO_A3); // 297 × 420 mm + aset.add(MediaSizeName.ISO_A4); // 210 × 297 mm + + printCount++; + + final String psMimeType = "application/postscript"; + final String pdfMimeType = "application/pdf"; + final PrinterJob pj = PrinterJob.getPrinterJob(); - factories = PrinterJob.lookupStreamPrintServices(psMimeType); - if (factories.length > 0) { - final String fname = getPrintFilename(dpi, "ps"); - System.err.println("doPrint: dpi "+dpi+", "+fname); - FileOutputStream outstream; - try { - outstream = new FileOutputStream(fname); - Assert.assertTrue(doPrintAutoImpl(frame, awtPrintObject, printable, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscreen, dpi)); - } catch (FileNotFoundException e) { - Assert.assertNull("Unexpected exception", e); - } - return; - } - System.err.println("No PS"); + StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(pdfMimeType); + if (factories.length > 0) { + final String fname = getPrintFilename(dpi, antialiasing, "pdf"); + System.err.println("doPrint: dpi "+dpi+", "+fname); + FileOutputStream outstream; + try { + outstream = new FileOutputStream(fname); + Assert.assertTrue(doPrintAutoImpl(frame, awtPrintObject, printable, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscreen, dpi, antialiasing)); + } catch (FileNotFoundException e) { + Assert.assertNull("Unexpected exception", e); + } + return; + } + System.err.println("No PDF"); + + factories = PrinterJob.lookupStreamPrintServices(psMimeType); + if (factories.length > 0) { + final String fname = getPrintFilename(dpi, antialiasing, "ps"); + System.err.println("doPrint: dpi "+dpi+", "+fname); + FileOutputStream outstream; + try { + outstream = new FileOutputStream(fname); + Assert.assertTrue(doPrintAutoImpl(frame, awtPrintObject, printable, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscreen, dpi, antialiasing)); + } catch (FileNotFoundException e) { + Assert.assertNull("Unexpected exception", e); + } + return; + } + System.err.println("No PS"); + } finally { + lock.unlock(); + } } - - private String getPrintFilename(int dpi, String suffix) { + private String getPrintFilename(int dpi, boolean antialiasing, String suffix) { final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; final String simpleTestName = getSimpleTestName("."); - return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-dpi%03d.%s", simpleTestName, printCount, dpi, suffix).replace(' ', '_'); + final String sAA = antialiasing ? "aa_" : "raw"; + return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-dpi%03d-%s.%s", simpleTestName, printCount, dpi, sAA, suffix).replace(' ', '_'); } - private boolean doPrintAutoImpl(Frame frame, AWTPrintLifecycle awtPrintObject, Printable printable, PrinterJob job, StreamPrintService ps, int pOrientation, - Paper paper, boolean offscreen, int dpi) { + Paper paper, boolean offscreen, int dpi, boolean antialiasing) { this.awtPrintObject = awtPrintObject; this.frame = frame; printOffscreen = offscreen; printDPI = dpi; + printAA = antialiasing; boolean ok = true; try { PageFormat pageFormat = job.defaultPage(); @@ -287,21 +314,37 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab return ok; } - protected void doPrintManual(Frame frame, AWTPrintLifecycle awtPrintObject, Printable printable, boolean offscreen, int dpi) { - this.awtPrintObject = awtPrintObject; - this.frame = frame; - printOffscreen = offscreen; - printDPI = dpi; - PrinterJob job = PrinterJob.getPrinterJob(); - job.setPrintable(printable); - boolean ok = job.printDialog(); - if (ok) { - try { - job.print(); - } catch (PrinterException ex) { - ex.printStackTrace(); + public void doPrintManual(Frame frame, AWTPrintLifecycle awtPrintObject, Printable printable, boolean offscreen, int dpi, boolean antialiasing) { + lock.lock(); + try { + this.awtPrintObject = awtPrintObject; + this.frame = frame; + printOffscreen = offscreen; + printDPI = dpi; + printAA = antialiasing; + PrinterJob job = PrinterJob.getPrinterJob(); + job.setPrintable(printable); + boolean ok = job.printDialog(); + if (ok) { + try { + job.print(); + } catch (PrinterException ex) { + ex.printStackTrace(); + } } - } + } finally { + lock.unlock(); + } } + /** Wait for idle .. simply acquiring all locks and releasing them. */ + public void waitUntilPrintJobsIdle() { + lock.lock(); + try { + lockPrinting.lock(); + lockPrinting.unlock(); + } finally { + lock.unlock(); + } + } } \ No newline at end of file -- cgit v1.2.3 From 76048cd784ea6df32f19e97bb228e4ead880ea07 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 8 Sep 2013 03:02:36 +0200 Subject: Test: Don't resize frame, tweek print-matrix; AWTPrintLifecycle: Add scale and convenient AWT container traversal context; GLCanvas/GLJPanel properly handle existing MSAA and req. AA; - Test: Don't resize frame, tweek print-matrix - Use scaleComp72 to scale the frame to fit on page, i.e. global print matrix - Use scaleGLMatXY = 72.0 / glDPI to locally scale on the GL drawable as being passed to AWTPrintLifecycle.setup(..) - Hence frame stays untouched/stable, no need for 'offscreen' print test, which is removed. - AWTPrintLifecycle: Add scale and convenient AWT container traversal context Use a simple decoration for all AWTPrintLifecycle impl. components within a container: final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, g2d, scaleGLMatXY, scaleGLMatXY); try { } finally { ctx.releasePrint(); } - GLCanvas/GLJPanel properly handle existing MSAA and req. AA; - GLCanvas: Workaround bug where onscreen MSAA cannot switch to offscreen FBO, i.e. stay 'onscreen' - GLJPanel: Use new offscreen FBO if MSAA is requested and not yet used. - GLJPanel.Offscreen.postGL(): always swapBufer(), was missing for !GLSL swapping Results GLCanvas / GLJPanel: - Good scaling - Stable behavior / visibility - High DPI mode works --- make/scripts/tests.sh | 4 +- .../javax/media/opengl/awt/AWTPrintLifecycle.java | 49 +++++++- .../classes/javax/media/opengl/awt/GLCanvas.java | 85 ++++++++------ .../classes/javax/media/opengl/awt/GLJPanel.java | 121 ++++++++++++++------ .../classes/jogamp/opengl/awt/AWTTilePainter.java | 53 ++++++--- .../classes/jogamp/nativewindow/awt/AWTMisc.java | 27 +++++ .../junit/jogl/tile/TestTiledPrintingGearsAWT.java | 59 +++++----- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 58 +++++----- .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 124 +++++++-------------- 9 files changed, 345 insertions(+), 235 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index fee4b3ec0..2b7a2563e 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -216,7 +216,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" - D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" #D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" @@ -330,7 +330,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java b/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java index 077ee42a9..293bdb809 100644 --- a/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java +++ b/src/jogl/classes/javax/media/opengl/awt/AWTPrintLifecycle.java @@ -29,9 +29,12 @@ package javax.media.opengl.awt; import javax.media.opengl.GLAutoDrawable; import java.awt.Component; +import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; +import jogamp.nativewindow.awt.AWTMisc; + /** * Interface describing print lifecycle to support AWT printing * on AWT {@link GLAutoDrawable}s. @@ -41,11 +44,55 @@ public interface AWTPrintLifecycle { /** * Shall be called before {@link Component#print(Graphics)}. * @param g2d the {@link Graphics2D} instance, which will be used for printing. + * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels + * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels */ - void setupPrint(Graphics2D g2d); + void setupPrint(Graphics2D g2d, double scaleMatX, double scaleMatY); /** * Shall be called after very last {@link Component#print(Graphics)}. */ void releasePrint(); + + public static class Context { + public static Context setupPrint(Container c, Graphics2D g2d, double scaleMatX, double scaleMatY) { + final Context t = new Context(c, g2d, scaleMatX, scaleMatY); + t.setupPrint(c); + return t; + } + + public void releasePrint() { + count = AWTMisc.performAction(cont, AWTPrintLifecycle.class, releaseAction); + } + + public int getCount() { return count; } + + private final Container cont; + private final Graphics2D g2d; + private final double scaleMatX; + private final double scaleMatY; + private int count; + + private final AWTMisc.ComponentAction setupAction = new AWTMisc.ComponentAction() { + @Override + public void run(Component c) { + ((AWTPrintLifecycle)c).setupPrint(g2d, scaleMatX, scaleMatY); + } }; + private final AWTMisc.ComponentAction releaseAction = new AWTMisc.ComponentAction() { + @Override + public void run(Component c) { + ((AWTPrintLifecycle)c).releasePrint(); + } }; + + private Context(Container c, Graphics2D g2d, double scaleMatX, double scaleMatY) { + this.cont = c; + this.g2d = g2d; + this.scaleMatX = scaleMatX; + this.scaleMatY = scaleMatY; + this.count = 0; + } + private void setupPrint(Container c) { + count = AWTMisc.performAction(c, AWTPrintLifecycle.class, setupAction); + } + } } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 8f9684db1..b2ffc17a2 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -86,7 +86,6 @@ import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; -import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; import javax.media.opengl.Threading; @@ -733,11 +732,11 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private volatile boolean printActive = false; private boolean printUseAA = false; private GLAnimatorControl printAnimator = null; - private GLOffscreenAutoDrawable printGLAD = null; + private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint(Graphics2D g2d) { + public void setupPrint(Graphics2D g2d, double scaleMatX, double scaleMatY) { if( !validateGLDrawable() ) { if(DEBUG) { System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable not valid yet"); @@ -758,7 +757,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printUseAA = null != _useAA && ( _useAA == RenderingHints.VALUE_ANTIALIAS_DEFAULT || _useAA == RenderingHints.VALUE_ANTIALIAS_ON ); } if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", useAA "+printUseAA+", printAnimator "+printAnimator); + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", useAA "+printUseAA+", printAnimator "+printAnimator); { final Set> rEntries = rHints.entrySet(); int count = 0; @@ -770,7 +769,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final AffineTransform aTrans = g2d.getTransform(); System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); - } + } + final int componentCount = isOpaque() ? 3 : 4; + final TileRenderer printRenderer = new TileRenderer(); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } private final Runnable setupPrintOnEDT = new Runnable() { @@ -782,30 +784,31 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printAnimator.remove(GLCanvas.this); } final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); - caps.setDoubleBuffered(false); final GLProfile glp = caps.getGLProfile(); - if( printUseAA && !caps.getSampleBuffers() ) { - if ( !glp.isGL2ES3() ) { - if( DEBUG ) { - System.err.println("Ignore MSAA due to gl-profile < GL2ES3"); + if( caps.getSampleBuffers() ) { + // bug / issue w/ swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + printGLAD = GLCanvas.this; + } else { + caps.setDoubleBuffered(false); + caps.setOnscreen(false); + if( printUseAA && !caps.getSampleBuffers() ) { + if ( !glp.isGL2ES3() ) { + if( DEBUG ) { + System.err.println("Ignore MSAA due to gl-profile < GL2ES3"); + } + printUseAA = false; + } else { + caps.setSampleBuffers(true); + caps.setNumSamples(8); } - printUseAA = false; - } else { - caps.setSampleBuffers(true); - caps.setNumSamples(8); // FIXME } + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); + GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); } - caps.setOnscreen(false); - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); - GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); - destroyOnEDTAction.run(); - final int componentCount = isOpaque() ? 3 : 4; - final TileRenderer printRenderer = new TileRenderer(); - printRenderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); - printRenderer.attachToAutoDrawable(printGLAD); - printAWTTiles = new AWTTilePainter(printRenderer, componentCount, DEBUG); + printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); + printAWTTiles.renderer.attachToAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); System.err.println("AWT print.setup AA "+printUseAA+", "+caps); @@ -832,9 +835,10 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } printAWTTiles.dispose(); printAWTTiles= null; - createDrawableAndContext( false ); - GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, GLCanvas.this); - printGLAD.destroy(); + if( printGLAD != GLCanvas.this ) { + GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, GLCanvas.this); + printGLAD.destroy(); + } printGLAD = null; if( null != printAnimator ) { printAnimator.add(GLCanvas.this); @@ -854,17 +858,26 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // we cannot dispatch print on AWT-EDT due to printing internal locking .. } sendReshape = false; // clear reshape flag - final Graphics2D printGraphics = (Graphics2D)graphics; - printAWTTiles.updateGraphics2DAndClipBounds(printGraphics); - final TileRenderer tileRenderer = printAWTTiles.getTileRenderer(); - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); + + final Graphics2D g2d = (Graphics2D)graphics; + printAWTTiles.setupGraphics2DAndClipBounds(g2d); + try { + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + do { + if( printGLAD != GLCanvas.this ) { + tileRenderer.display(); + } else { + Threading.invoke(true, displayOnEDTAction, getTreeLock()); + } + } while ( !tileRenderer.eot() ); + } finally { + printAWTTiles.resetGraphics2D(); } - do { - tileRenderer.display(); - } while ( !tileRenderer.eot() ); if( DEBUG ) { - System.err.println("AWT print.X: "+tileRenderer); + System.err.println("AWT print.X: "+printAWTTiles); } } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 2488bd443..b549ad30c 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -98,6 +98,7 @@ import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.opengl.FBObject; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider; +import com.jogamp.opengl.util.GLDrawableUtil; import com.jogamp.opengl.util.GLPixelStorageModes; import com.jogamp.opengl.util.TileRenderer; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer; @@ -500,12 +501,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } + private static final int PRINT_TILE_SIZE = 512; private volatile boolean printActive = false; + private boolean printUseAA = false; private GLAnimatorControl printAnimator = null; + private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint(Graphics2D g2d) { + public void setupPrint(Graphics2D g2d, double scaleMatX, double scaleMatY) { if (!isInitialized) { if(DEBUG) { System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable not valid yet"); @@ -521,6 +525,28 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printActive = true; sendReshape = false; // clear reshape flag handleReshape = false; // ditto + final RenderingHints rHints = g2d.getRenderingHints(); + { + final Object _useAA = rHints.get(RenderingHints.KEY_ANTIALIASING); + printUseAA = null != _useAA && ( _useAA == RenderingHints.VALUE_ANTIALIAS_DEFAULT || _useAA == RenderingHints.VALUE_ANTIALIAS_ON ); + } + if( DEBUG ) { + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", useAA "+printUseAA+", printAnimator "+printAnimator); + { + final Set> rEntries = rHints.entrySet(); + int count = 0; + for(Iterator> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { + final Entry rEntry = rEntryIter.next(); + System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); + } + } + final AffineTransform aTrans = g2d.getTransform(); + System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); + System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + } + final int componentCount = isOpaque() ? 3 : 4; + final TileRenderer printRenderer = new TileRenderer(); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } private final Runnable setupPrintOnEDT = new Runnable() { @@ -531,14 +557,34 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printAnimator = helper.getAnimator(); if( null != printAnimator ) { printAnimator.remove(GLJPanel.this); - } - final int componentCount = isOpaque() ? 3 : 4; - final TileRenderer printRenderer = new TileRenderer(); - printRenderer.setTileSize(getWidth(), getHeight(), 0); - printRenderer.attachToAutoDrawable(GLJPanel.this); - printAWTTiles = new AWTTilePainter(printRenderer, componentCount, DEBUG); + } + + printGLAD = GLJPanel.this; // default: re-use + final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); + final GLProfile glp = caps.getGLProfile(); + if( printUseAA && !caps.getSampleBuffers() ) { + if ( !glp.isGL2ES3() ) { + if( DEBUG ) { + System.err.println("Ignore MSAA due to gl-profile < GL2ES3"); + } + printUseAA = false; + } else { + // MSAA FBO .. + caps.setDoubleBuffered(false); + caps.setOnscreen(false); + caps.setSampleBuffers(true); + caps.setNumSamples(8); + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); + GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); + } + } + printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); + printAWTTiles.renderer.attachToAutoDrawable(printGLAD); if( DEBUG ) { System.err.println("AWT print.setup "+printAWTTiles); + System.err.println("AWT print.setup AA "+printUseAA+", "+caps); + System.err.println("AWT print.setup "+printGLAD); } } }; @@ -563,6 +609,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } printAWTTiles.dispose(); printAWTTiles= null; + if( printGLAD != GLJPanel.this ) { + GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, GLJPanel.this); + printGLAD.destroy(); + } + printGLAD = null; if( null != printAnimator ) { printAnimator.add(GLJPanel.this); printAnimator = null; @@ -582,33 +633,26 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } sendReshape = false; // clear reshape flag handleReshape = false; // ditto - final Graphics2D printGraphics = (Graphics2D)graphics; - if( DEBUG ) { - System.err.println("AWT print.0: canvasSize "+getWidth()+"x"+getWidth()+", printAnimator "+printAnimator); - { - final RenderingHints rHints = printGraphics.getRenderingHints(); - final Set> rEntries = rHints.entrySet(); - int count = 0; - for(Iterator> rEntryIter = rEntries.iterator(); rEntryIter.hasNext(); count++) { - final Entry rEntry = rEntryIter.next(); - System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); - } + + final Graphics2D g2d = (Graphics2D)graphics; + printAWTTiles.setupGraphics2DAndClipBounds(g2d); + try { + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); } - final AffineTransform aTrans = printGraphics.getTransform(); - System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); - System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); - } - printAWTTiles.updateGraphics2DAndClipBounds(printGraphics); - final TileRenderer tileRenderer = printAWTTiles.getTileRenderer(); - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); + do { + if( printGLAD != GLJPanel.this ) { + tileRenderer.display(); + } else { + backend.doPlainPaint(); + } + } while ( !tileRenderer.eot() ); + } finally { + printAWTTiles.resetGraphics2D(); } - do { - // printRenderer.display(); - backend.doPlainPaint(); - } while ( !tileRenderer.eot() ); if( DEBUG ) { - System.err.println("AWT print.X: "+tileRenderer); + System.err.println("AWT print.X: "+printAWTTiles); } } @Override @@ -803,6 +847,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // so swapping the buffers doesn't do anything. We also don't // currently have the provision to skip copying the data to the // Swing portion of the GLJPanel in any of the rendering paths. + if( printActive && isInitialized) { + final Backend b = backend; + if ( null != b ) { + b.getDrawable().swapBuffers(); + } + } } @Override @@ -1007,7 +1057,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing backend.postGL(g, true); } - public void print(GLAutoDrawable drawable) { + public void plainPaint(GLAutoDrawable drawable) { helper.display(GLJPanel.this); } @@ -1066,7 +1116,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final Runnable updaterPlainDisplayAction = new Runnable() { @Override public void run() { - updater.print(GLJPanel.this); + updater.plainPaint(GLJPanel.this); } }; @@ -1405,13 +1455,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing gl2es3.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, pixelBuffer.width); gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer()); } - + + offscreenDrawable.swapBuffers(); + if(null != glslTextureRaster) { // implies flippedVertical // perform vert-flipping via OpenGL/FBO final GLFBODrawable fboDrawable = (GLFBODrawable)offscreenDrawable; final FBObject.TextureAttachment fboTex = fboDrawable.getTextureBuffer(GL.GL_FRONT); - fboDrawable.swapBuffers(); fboFlipped.bind(gl); // gl.glActiveTexture(GL.GL_TEXTURE0 + fboDrawable.getTextureUnit()); // implicit by GLFBODrawableImpl: swapBuffers/contextMadeCurent -> swapFBOImpl diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 7493a19c5..8d07bdb8e 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -31,6 +31,7 @@ import java.awt.Color; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Shape; +import java.awt.geom.AffineTransform; import java.awt.image.BufferedImage; import java.awt.image.DataBufferInt; @@ -51,13 +52,15 @@ import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; *

        */ public class AWTTilePainter { - final private TileRenderer renderer; - final private int componentCount; - final private boolean verbose; + public final TileRenderer renderer; + public final int componentCount; + public final double scaleMatX, scaleMatY; + public final boolean verbose; private AWTGLPixelBuffer tBuffer = null; private BufferedImage vFlipImage = null; private Graphics2D g2d = null; + private AffineTransform saveAT = null; /** * Assumes a configured {@link TileRenderer}, i.e. @@ -69,30 +72,43 @@ public class AWTTilePainter { *

        * componentCount reflects opaque, i.e. 4 if non opaque. *

        + * @param renderer + * @param componentCount + * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels + * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels + * @param verbose */ - public AWTTilePainter(TileRenderer renderer, int componentCount, boolean verbose) { + public AWTTilePainter(TileRenderer renderer, int componentCount, double scaleMatX, double scaleMatY, boolean verbose) { this.renderer = renderer; this.renderer.setGLEventListener(preTileGLEL, postTileGLEL); this.componentCount = componentCount; + this.scaleMatX = scaleMatX; + this.scaleMatY = scaleMatY; this.verbose = verbose; this.renderer.setRowOrder(TileRenderer.TR_TOP_TO_BOTTOM); } public String toString() { return renderer.toString(); } - public TileRenderer getTileRenderer() { return renderer; } - /** * Caches the {@link Graphics2D} instance for rendering. *

        + * Copies the current {@link Graphics2D} {@link AffineTransform} + * and scales {@link Graphics2D} w/ scaleMatX x scaleMatY.
        + * After rendering, the {@link AffineTransform} should be reset via {@link #resetGraphics2D()}. + *

        + *

        * Sets the {@link TileRenderer}'s {@link TileRenderer#setImageSize(int, int) image size} * and {@link TileRenderer#setTileOffset(int, int) tile offset} according the * the {@link Graphics2D#getClipBounds() graphics clip bounds}. *

        * @param g2d */ - public void updateGraphics2DAndClipBounds(Graphics2D g2d) { + public void setupGraphics2DAndClipBounds(Graphics2D g2d) { this.g2d = g2d; + saveAT = g2d.getTransform(); + g2d.scale(scaleMatX, scaleMatY); + final Rectangle gClipOrig = g2d.getClipBounds(); final Rectangle gClip = new Rectangle(gClipOrig); if( 0 > gClip.x ) { @@ -106,10 +122,15 @@ public class AWTTilePainter { if( verbose ) { System.err.println("AWT print.0: "+gClipOrig+" -> "+gClip); } - renderer.setImageSize(gClip.width, gClip.height); + renderer.setImageSize(gClip.width, gClip.height); renderer.setTileOffset(gClip.x, gClip.y); } + /** See {@ #setupGraphics2DAndClipBounds(Graphics2D)}. */ + public void resetGraphics2D() { + g2d.setTransform(saveAT); + } + /** * Disposes resources and {@link TileRenderer#detachFromAutoDrawable() detaches} * the {@link TileRenderer}'s {@link GLAutoDrawable}. @@ -194,24 +215,20 @@ public class AWTTilePainter { } final Shape oClip = g2d.getClip(); g2d.clipRect(pX, pYf, tWidth, tHeight); - final Shape clip = g2d.getClip(); g2d.drawImage(dstImage, pX, pYf, dstImage.getWidth(), dstImage.getHeight(), null); // Null ImageObserver since image data is ready. - g2d.setColor(Color.BLACK); - g2d.drawRect(pX, pYf, tWidth, tHeight); - { + if( verbose ) { + System.err.println("XXX tile-post.X clip "+oClip+" -> "+g2d.getClip()); + g2d.setColor(Color.BLACK); + g2d.drawRect(pX, pYf, tWidth, tHeight); final Rectangle r = oClip.getBounds(); g2d.setColor(Color.YELLOW); g2d.drawRect(r.x, r.y, r.width, r.height); - } - g2d.setClip(oClip); - if( verbose ) { - System.err.println("XXX tile-post.X clip "+oClip+" -> "+clip); System.err.println("XXX tile-post.X "+renderer); System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()+" -> "+pX+"/"+pYf); } + g2d.setClip(oClip); } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} - }; - + }; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index 66be82a44..f38e7ea2b 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -69,6 +69,33 @@ public class AWTMisc { return (Container) c; } + public static interface ComponentAction { + /** + * @param c the component to perform the action on + */ + public void run(Component c); + } + + public static int performAction(Container c, Class cType, ComponentAction action) { + int count = 0; + final int cc = c.getComponentCount(); + for(int i=0; i - * We assume AWT painting happens w/ 72 dpi! - *

        + * We fit the frame into the imageable area with for 72 dpi, + * assuming that is the default AWT painting density. *

        * The frame borders are considered. *

        + *

        + * The frame's scale factor is used for the graphics print matrix + * of the overall print-job, hence no frame resize is required. + *

        + *

        + * The GL scale factor 'scaleGLMatXY', 72dpi/glDPI, is passed to the GL object + * which locally scales the print matrix and renders the scene with 1/scaleGLMatXY pixels. + *

        */ final Insets frameInsets = frame.getInsets(); final int frameWidth = frame.getWidth(); final int frameHeight= frame.getHeight(); - final int frameWidthS; - final int frameHeightS; - final double scaleComp; + final double scaleComp72; { final int frameBorderW = frameInsets.left + frameInsets.right; final int frameBorderH = frameInsets.top + frameInsets.bottom; final double sx = pf.getImageableWidth() / ( frameWidth + frameBorderW ); final double sy = pf.getImageableHeight() / ( frameHeight + frameBorderH ); - scaleComp = Math.min(sx, sy) * ( printDPI/72.0 ); - if( 0f < scaleComp ) { - frameWidthS = (int) ( frameWidth*scaleComp ); // cut off FIXME - frameHeightS = (int) ( frameHeight*scaleComp ); // cut off FIXME - } else { - frameWidthS = frameWidth; - frameHeightS = frameHeight; - } + scaleComp72 = Math.min(sx, sy); } - // Since we fit the frame size into the imageable size respecting the DPI, - // we simply can scale the print graphics matrix to the DPI - // w/o the need to fiddle w/ the margins (matrix translation). - final double scaleGraphics = 72.0 / printDPI; - - System.err.println("PRINT offscreen: "+printOffscreen+", thread "+Thread.currentThread().getName()); - System.err.println("PRINT DPI: "+printDPI+", AA "+printAA+", scaleGraphics "+scaleGraphics+", scaleComp "+scaleComp+ - ", frame: border "+frameInsets+", size "+frameWidth+"x"+frameHeight+" -> "+frameWidthS+"x"+frameHeightS); + final double scaleGLMatXY = 72.0 / glDPI; + System.err.println("PRINT thread "+Thread.currentThread().getName()); + System.err.println("PRINT DPI: "+glDPI+", AA "+printAA+", scaleGL "+scaleGLMatXY+", scaleComp72 "+scaleComp72+ + ", frame: border "+frameInsets+", size "+frameWidth+"x"+frameHeight); final Graphics2D printG2D = (Graphics2D)g; - final Graphics2D offscreenG2D; - final BufferedImage offscreenImage; - final Graphics2D g2d; - if( printOffscreen ) { - offscreenImage = new BufferedImage(frameWidthS, frameHeightS, BufferedImage.TYPE_4BYTE_ABGR); - offscreenG2D = (Graphics2D) offscreenImage.getGraphics(); - offscreenG2D.setClip(0, 0, frameWidthS, frameHeightS); - g2d = offscreenG2D; - } else { - offscreenG2D = null; - offscreenImage = null; - g2d = printG2D; + final Graphics2D g2d = printG2D; - g2d.translate(pf.getImageableX(), pf.getImageableY()); - g2d.scale(scaleGraphics, scaleGraphics); - } + g2d.translate(pf.getImageableX(), pf.getImageableY()); + g2d.scale(scaleComp72, scaleComp72); + if( printAA ) { g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); } - awtPrintObject.setupPrint(g2d); + final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, g2d, scaleGLMatXY, scaleGLMatXY); try { + System.err.println("PRINT AWTPrintLifecycle.setup.count "+ctx.getCount()); AWTEDTExecutor.singleton.invoke(true, new Runnable() { - public void run() { - frame.setSize(frameWidthS, frameHeightS); - frame.invalidate(); - frame.validate(); - } - }); - - AWTEDTExecutor.singleton.invoke(true, new Runnable() { - public void run() { - frame.printAll(g2d); - } } ); - - System.err.println("PRINT DPI: reset frame size "+frameWidth+"x"+frameHeight); - AWTEDTExecutor.singleton.invoke(true, new Runnable() { - public void run() { - frame.setSize(frameWidth, frameHeight); - frame.invalidate(); - frame.validate(); + public void run() { + frame.printAll(g2d); } }); } finally { - awtPrintObject.releasePrint(); - } - - if( printOffscreen ) { - printG2D.translate(pf.getImageableX(), pf.getImageableY()); - printG2D.scale(scaleGraphics, scaleGraphics); - printG2D.drawImage(offscreenImage, 0, 0, offscreenImage.getWidth(), offscreenImage.getHeight(), null); // Null ImageObserver since image data is ready. + ctx.releasePrint(); + System.err.println("PRINT AWTPrintLifecycle.release.count "+ctx.getCount()); } /* tell the caller that this page is part of the printed document */ @@ -230,8 +187,7 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab super(); } - public void doPrintAuto(Frame frame, AWTPrintLifecycle awtPrintObject, - Printable printable, int pOrientation, Paper paper, boolean offscreen, int dpi, boolean antialiasing) { + public void doPrintAuto(Frame frame, int pOrientation, Paper paper, int dpi, boolean antialiasing) { lock.lock(); try { final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); @@ -253,7 +209,7 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - Assert.assertTrue(doPrintAutoImpl(frame, awtPrintObject, printable, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscreen, dpi, antialiasing)); + Assert.assertTrue(doPrintAutoImpl(frame, pj, factories[0].getPrintService(outstream), pOrientation, paper, dpi, antialiasing)); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -268,7 +224,7 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - Assert.assertTrue(doPrintAutoImpl(frame, awtPrintObject, printable, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscreen, dpi, antialiasing)); + Assert.assertTrue(doPrintAutoImpl(frame, pj, factories[0].getPrintService(outstream), pOrientation, paper, dpi, antialiasing)); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -285,13 +241,11 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab final String sAA = antialiasing ? "aa_" : "raw"; return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-dpi%03d-%s.%s", simpleTestName, printCount, dpi, sAA, suffix).replace(' ', '_'); } - private boolean doPrintAutoImpl(Frame frame, AWTPrintLifecycle awtPrintObject, - Printable printable, PrinterJob job, StreamPrintService ps, int pOrientation, - Paper paper, boolean offscreen, int dpi, boolean antialiasing) { - this.awtPrintObject = awtPrintObject; + private boolean doPrintAutoImpl(Frame frame, PrinterJob job, + StreamPrintService ps, int pOrientation, Paper paper, int dpi, + boolean antialiasing) { this.frame = frame; - printOffscreen = offscreen; - printDPI = dpi; + glDPI = dpi; printAA = antialiasing; boolean ok = true; try { @@ -305,7 +259,7 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab } pageFormat.setOrientation(pOrientation); // PageFormat.LANDSCAPE or PageFormat.PORTRAIT job.setPrintService(ps); - job.setPrintable(printable, pageFormat); + job.setPrintable(this, pageFormat); job.print(); } catch (PrinterException pe) { pe.printStackTrace(); @@ -314,16 +268,14 @@ public abstract class TiledPrintingAWTBase extends UITestCase implements Printab return ok; } - public void doPrintManual(Frame frame, AWTPrintLifecycle awtPrintObject, Printable printable, boolean offscreen, int dpi, boolean antialiasing) { + public void doPrintManual(Frame frame, int dpi, boolean antialiasing) { lock.lock(); try { - this.awtPrintObject = awtPrintObject; this.frame = frame; - printOffscreen = offscreen; - printDPI = dpi; + glDPI = dpi; printAA = antialiasing; PrinterJob job = PrinterJob.getPrinterJob(); - job.setPrintable(printable); + job.setPrintable(this); boolean ok = job.printDialog(); if (ok) { try { -- cgit v1.2.3 From fb6440fb6e4fac31d03799d5cf804d02c78f2c38 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 8 Sep 2013 19:26:20 +0200 Subject: NewtCanvasAWT: Implement AWTPrintLifecycle and hence support for AWT printing. Note: Same bug existing as w/ GLCanvas, i.e. 'GLDrawableUtil.swapGLContextAndAllGLEventListener(gladPre, gladNew)': If 'gladPre' is onscreen and using MSAA (on NV/GLX), the ctx cannot be made current in it's new 'gladNew' location. Same workaround applied, i.e. use onscreen drawable while printing. --- make/scripts/tests.sh | 5 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 166 +++++++++++++- .../jogl/tile/TestTiledPrintingGearsNewtAWT.java | 241 +++++++++++++++++++++ 3 files changed, 408 insertions(+), 4 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2b7a2563e..a23ea46d6 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -329,8 +329,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index e4b5a25c4..2127c4096 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -32,9 +32,12 @@ package com.jogamp.newt.awt; import java.awt.AWTKeyStroke; import java.awt.Canvas; import java.awt.Component; +import java.awt.EventQueue; import java.awt.Graphics; +import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.KeyboardFocusManager; +import java.awt.RenderingHints; import java.beans.Beans; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; @@ -46,6 +49,12 @@ import java.util.Set; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.OffscreenLayerOption; import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.AWTPrintLifecycle; import javax.swing.MenuSelectionManager; import jogamp.nativewindow.awt.AWTMisc; @@ -54,6 +63,7 @@ import jogamp.newt.WindowImpl; import jogamp.newt.awt.NewtFactoryAWT; import jogamp.newt.awt.event.AWTParentWindowAdapter; import jogamp.newt.driver.DriverClearFocus; +import jogamp.opengl.awt.AWTTilePainter; import com.jogamp.common.os.Platform; import com.jogamp.common.util.awt.AWTEDTExecutor; @@ -69,6 +79,8 @@ import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.awt.AWTAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTMouseAdapter; +import com.jogamp.opengl.util.GLDrawableUtil; +import com.jogamp.opengl.util.TileRenderer; /** * AWT {@link java.awt.Canvas Canvas} containing a NEWT {@link Window} using native parenting. @@ -80,7 +92,7 @@ import com.jogamp.newt.event.awt.AWTMouseAdapter; * the underlying JAWT mechanism to composite the image, if supported. */ @SuppressWarnings("serial") -public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption { +public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption, AWTPrintLifecycle { public static final boolean DEBUG = Debug.debug("Window"); private JAWTWindow jawtWindow = null; @@ -419,7 +431,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void paint(Graphics g) { - if( validateComponent(true) ) { + if( validateComponent(true) && !printActive ) { newtChild.windowRepaint(0, 0, getWidth(), getHeight()); } } @@ -441,7 +453,155 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } + + private static final int PRINT_TILE_SIZE = 512; + private volatile boolean printActive = false; + private boolean printUseAA = false; + private GLAnimatorControl printAnimator = null; + private GLAutoDrawable printGLAD = null; + private AWTTilePainter printAWTTiles = null; + + @Override + public void setupPrint(Graphics2D g2d, double scaleMatX, double scaleMatY) { + if( !validateComponent(true) ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); + } + return; // not yet available .. + } + if( !isVisible() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + } + return; // not yet available .. + } + printActive = true; + final RenderingHints rHints = g2d.getRenderingHints(); + { + final Object _useAA = rHints.get(RenderingHints.KEY_ANTIALIASING); + printUseAA = null != _useAA && ( _useAA == RenderingHints.VALUE_ANTIALIAS_DEFAULT || _useAA == RenderingHints.VALUE_ANTIALIAS_ON ); + } + if( DEBUG ) { + System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+scaleMatX+" x "+scaleMatY+", useAA "+printUseAA+", printAnimator "+printAnimator); + AWTTilePainter.dumpHintsAndScale(g2d); + } + final int componentCount = isOpaque() ? 3 : 4; + final TileRenderer printRenderer = new TileRenderer(); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); + AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); + } + private final Runnable setupPrintOnEDT = new Runnable() { + @Override + public void run() { + final GLAutoDrawable glad; + if( null != newtChild && newtChild instanceof GLAutoDrawable ) { + glad = (GLAutoDrawable)newtChild; + } else { + if( DEBUG ) { + System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); + } + printAWTTiles = null; + printActive = false; + return; + } + printAnimator = glad.getAnimator(); + if( null != printAnimator ) { + printAnimator.remove(glad); + } + final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); + final GLProfile glp = caps.getGLProfile(); + if( caps.getSampleBuffers() ) { + // bug / issue w/ swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + printGLAD = glad; + } else { + caps.setDoubleBuffered(false); + caps.setOnscreen(false); + if( printUseAA && !caps.getSampleBuffers() ) { + if ( !glp.isGL2ES3() ) { + if( DEBUG ) { + System.err.println("Ignore MSAA due to gl-profile < GL2ES3"); + } + printUseAA = false; + } else { + caps.setSampleBuffers(true); + caps.setNumSamples(8); + } + } + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, PRINT_TILE_SIZE, PRINT_TILE_SIZE, null); + GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); + } + + printAWTTiles.renderer.setTileSize(printGLAD.getWidth(), printGLAD.getHeight(), 0); + printAWTTiles.renderer.attachToAutoDrawable(printGLAD); + if( DEBUG ) { + System.err.println("AWT print.setup "+printAWTTiles); + System.err.println("AWT print.setup AA "+printUseAA+", "+caps); + System.err.println("AWT print.setup "+printGLAD); + } + } + }; + + @Override + public void releasePrint() { + if( !printActive || null == printGLAD ) { + throw new IllegalStateException("setupPrint() not called"); + } + // sendReshape = false; // clear reshape flag + AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, releasePrintOnEDT); + newtChild.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); // trigger a resize/relayout to listener + } + private final Runnable releasePrintOnEDT = new Runnable() { + @Override + public void run() { + if( DEBUG ) { + System.err.println("AWT print.release "+printAWTTiles); + } + final GLAutoDrawable glad = (GLAutoDrawable)newtChild; + printAWTTiles.dispose(); + printAWTTiles= null; + if( printGLAD != glad ) { + GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, glad); + printGLAD.destroy(); + } + printGLAD = null; + if( null != printAnimator ) { + printAnimator.add(glad); + printAnimator = null; + } + printActive = false; + } + }; + + @Override + public void print(Graphics graphics) { + if( !printActive || null == printGLAD ) { + throw new IllegalStateException("setupPrint() not called"); + } + if(DEBUG && !EventQueue.isDispatchThread()) { + System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); + // we cannot dispatch print on AWT-EDT due to printing internal locking .. + } + + final Graphics2D g2d = (Graphics2D)graphics; + printAWTTiles.setupGraphics2DAndClipBounds(g2d); + try { + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + do { + tileRenderer.display(); + } while ( !tileRenderer.eot() ); + } finally { + printAWTTiles.resetGraphics2D(); + } + if( DEBUG ) { + System.err.println("AWT print.X: "+printAWTTiles); + } + } + private final void requestFocusNEWTChild() { if(null!=newtChild) { newtChild.setFocusAction(null); @@ -685,6 +845,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } } + + protected static String getThreadName() { return Thread.currentThread().getName(); } static String newtWinHandleToHexString(Window w) { return null != w ? toHexString(w.getWindowHandle()) : "nil"; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java new file mode 100644 index 000000000..820b62743 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java @@ -0,0 +1,241 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.tile; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.print.PageFormat; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.event.TraceKeyAdapter; +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.newt.event.awt.AWTKeyAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.util.Animator; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { + + static boolean waitForKey = false; + /** only when run manually .. */ + static boolean allow600dpi = false; + static GLProfile glp; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2)) { + glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + width = 640; + height = 480; + } else { + setTestSupported(false); + } + // Runtime.getRuntime().traceInstructions(true); + // Runtime.getRuntime().traceMethodCalls(true); + } + + @AfterClass + public static void releaseClass() { + } + + protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException { + final GLWindow glad = GLWindow.create(caps); + Assert.assertNotNull(glad); + + final NewtCanvasAWT canvas = new NewtCanvasAWT(glad); + Assert.assertNotNull(canvas); + Dimension glc_sz = new Dimension(width, height); + canvas.setMinimumSize(glc_sz); + canvas.setPreferredSize(glc_sz); + canvas.setSize(glc_sz); + + final Gears gears = new Gears(); + glad.addGLEventListener(gears); + + final Frame frame = new Frame("Newt/AWT Print"); + Assert.assertNotNull(frame); + + final ActionListener print72DPIAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + doPrintManual(frame, 72, false); + } }; + final ActionListener print300DPIAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + doPrintManual(frame, 300, false); + } }; + final ActionListener print600DPIAction = new ActionListener() { + public void actionPerformed(ActionEvent e) { + doPrintManual(frame, 600, false); + } }; + final Button print72DPIButton = new Button("72dpi"); + print72DPIButton.addActionListener(print72DPIAction); + final Button print300DPIButton = new Button("300dpi"); + print300DPIButton.addActionListener(print300DPIAction); + final Button print600DPIButton = new Button("600dpi"); + print600DPIButton.addActionListener(print600DPIAction); + + frame.setLayout(new BorderLayout()); + Panel printPanel = new Panel(); + printPanel.add(print72DPIButton); + printPanel.add(print300DPIButton); + printPanel.add(print600DPIButton); + Panel southPanel = new Panel(); + southPanel.add(new Label("South")); + Panel eastPanel = new Panel(); + eastPanel.add(new Label("East")); + Panel westPanel = new Panel(); + westPanel.add(new Label("West")); + frame.add(printPanel, BorderLayout.NORTH); + frame.add(canvas, BorderLayout.CENTER); + frame.add(southPanel, BorderLayout.SOUTH); + frame.add(eastPanel, BorderLayout.EAST); + frame.add(westPanel, BorderLayout.WEST); + frame.setTitle("Tiles Newt/AWT Print Test"); + + Animator animator = new Animator(glad); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(canvas); + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(canvas, true)); + + animator.setUpdateFPSFrames(60, System.err); + animator.start(); + + boolean printDone = false; + while(!quitAdapter.shouldQuit() && animator.isAnimating() && ( 0 == duration || animator.getTotalFPSDuration() Date: Tue, 10 Sep 2013 23:37:14 +0200 Subject: TestTiledPrintingGearsSwingAWT: Add a second demo GLEventListener showing it's working/scaling well; Adding TileRendererBase.TileRendererNotify to RedAquareES2 having a 3rd demo case. --- make/scripts/tests.sh | 4 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 10 +++- .../test/junit/jogl/demos/es2/RedSquareES2.java | 65 +++++++++++++++++++--- .../opengl/test/junit/jogl/demos/gl2/Gears.java | 11 +++- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 43 +++++++++----- 5 files changed, 106 insertions(+), 27 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a23ea46d6..db267816e 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -330,8 +330,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index d8e0347d8..3da53c4c0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -269,7 +269,8 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); } - /* compute projection parameters */ + + // compute projection parameters 'normal' float left, right, bottom, top; if( imageHeight > imageWidth ) { float a = (float)imageHeight / (float)imageWidth; @@ -286,6 +287,8 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN } final float w = right - left; final float h = top - bottom; + + // compute projection parameters 'tiled' final float l = left + tileX * w / imageWidth; final float r = l + tileWidth * w / imageWidth; final float b = bottom + tileY * h / imageHeight; @@ -293,7 +296,10 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererN final float _w = r - l; final float _h = t - b; - System.err.println(">> angle "+angle+", [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); + if(verbose) { + System.err.println(">> angle "+angle+", [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); + } + pmvMatrix.glFrustumf(l, r, b, t, 5.0f, 200.0f); pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java index 1ba4d126f..5315fe406 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/RedSquareES2.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; +import com.jogamp.opengl.util.TileRendererBase; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; @@ -39,7 +40,7 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLUniformData; -public class RedSquareES2 implements GLEventListener { +public class RedSquareES2 implements GLEventListener, TileRendererBase.TileRendererNotify { private ShaderState st; private PMVMatrix pmvMatrix; private GLUniformData pmvMatrixUniform; @@ -50,6 +51,8 @@ public class RedSquareES2 implements GLEventListener { private float aspect = 1.0f; private boolean doRotate = true; private boolean clearBuffers = true; + private TileRendererBase tileRendererInUse = null; + private boolean doRotateBeforePrinting; public RedSquareES2(int swapInterval) { this.swapInterval = swapInterval; @@ -59,6 +62,15 @@ public class RedSquareES2 implements GLEventListener { this.swapInterval = 1; } + public void addTileRendererNotify(TileRendererBase tr) { + tileRendererInUse = tr; + doRotateBeforePrinting = doRotate; + setDoRotation(false); + } + public void removeTileRendererNotify(TileRendererBase tr) { + tileRendererInUse = null; + setDoRotation(doRotateBeforePrinting); + } public void setAspect(float aspect) { this.aspect = aspect; } public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void setClearBuffers(boolean v) { clearBuffers = v; } @@ -131,7 +143,11 @@ public class RedSquareES2 implements GLEventListener { final GL2ES2 gl = glad.getGL().getGL2ES2(); if( clearBuffers ) { - gl.glClearColor(0, 0, 0, 0); + if( null != tileRendererInUse ) { + gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); + } else { + gl.glClearColor(0, 0, 0, 0); + } gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } if( !gl.hasGLSL() ) { @@ -166,15 +182,50 @@ public class RedSquareES2 implements GLEventListener { return; } - if(-1 != swapInterval) { - gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) - } - st.useProgram(gl, true); // Set location in front of camera pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); - pmvMatrix.gluPerspective(45.0F, ( (float) width / (float) height ) / aspect, 1.0F, 100.0F); + + final int tileWidth = width; + final int tileHeight = height; + final int tileX, tileY, imageWidth, imageHeight; + if( null == tileRendererInUse ) { + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); + } + tileX = 0; + tileY = 0; + imageWidth = width; + imageHeight = height; + } else { + gl.setSwapInterval(0); + tileX = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); + tileY = tileRendererInUse.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); + imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); + imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); + } + // compute projection parameters 'normal' perspective + final float fovy=45f; + final float aspect2 = ( (float) width / (float) height ) / aspect; + final float zNear=1f; + final float zFar=100f; + + // compute projection parameters 'normal' frustum + final float top=(float)Math.tan(fovy*((float)Math.PI)/360.0f)*zNear; + final float bottom=-1.0f*top; + final float left=aspect2*bottom; + final float right=aspect2*top; + final float w = right - left; + final float h = top - bottom; + + // compute projection parameters 'tiled' + final float l = left + tileX * w / imageWidth; + final float r = l + tileWidth * w / imageWidth; + final float b = bottom + tileY * h / imageHeight; + final float t = b + tileHeight * h / imageHeight; + + pmvMatrix.glFrustumf(l, r, b, t, zNear, zFar); //pmvMatrix.glOrthof(-4.0f, 4.0f, -4.0f, 4.0f, 1.0f, 100.0f); st.uniform(gl, pmvMatrixUniform); st.useProgram(gl, false); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java index 80e145c67..1d992de68 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java @@ -36,6 +36,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti private KeyListener gearsKeys = new GearsKeyAdapter(); private TileRendererBase tileRendererInUse = null; private boolean doRotateBeforePrinting; + private boolean verbose = true; // private boolean mouseRButtonDown = false; private int prevMouseX, prevMouseY; @@ -59,6 +60,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti } public void setDoRotation(boolean rotate) { doRotate = rotate; } + public void setVerbose(boolean v) { verbose = v; } public void setGears(int g1, int g2, int g3) { gear1 = g1; @@ -185,7 +187,8 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti imageWidth = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_WIDTH); imageHeight = tileRendererInUse.getParam(TileRendererBase.TR_IMAGE_HEIGHT); } - /* compute projection parameters */ + + // compute projection parameters 'normal' float left, right, bottom, top; if( imageHeight > imageWidth ) { float a = (float)imageHeight / (float)imageWidth; @@ -202,6 +205,8 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti } final float w = right - left; final float h = top - bottom; + + // compute projection parameters 'tiled' final float l = left + tileX * w / imageWidth; final float r = l + tileWidth * w / imageWidth; final float b = bottom + tileY * h / imageHeight; @@ -209,7 +214,9 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererNoti final float _w = r - l; final float _h = t - b; - System.err.println(">> angle "+angle+", [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); + if(verbose) { + System.err.println(">> angle "+angle+", [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); + } gl.glFrustum(l, r, b, t, 5.0f, 60.0f); gl.glMatrixMode(GL2.GL_MODELVIEW); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index d63f73924..da577ea1d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -60,6 +60,7 @@ import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.QuitAdapter; @@ -93,15 +94,24 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { } protected void runTestGL(GLCapabilities caps) throws InterruptedException, InvocationTargetException { - final GLJPanel glJPanel = new GLJPanel(caps); - Assert.assertNotNull(glJPanel); - Dimension glc_sz = new Dimension(width, height); - glJPanel.setMinimumSize(glc_sz); - glJPanel.setPreferredSize(glc_sz); - glJPanel.setSize(glc_sz); + final Dimension glc_sz = new Dimension(width/2, height); + final GLJPanel glJPanel1 = new GLJPanel(caps); + Assert.assertNotNull(glJPanel1); + glJPanel1.setMinimumSize(glc_sz); + glJPanel1.setPreferredSize(glc_sz); + glJPanel1.setSize(glc_sz); + glJPanel1.addGLEventListener(new Gears()); - final Gears gears = new Gears(); - glJPanel.addGLEventListener(gears); + final GLJPanel glJPanel2 = new GLJPanel(caps); + Assert.assertNotNull(glJPanel2); + glJPanel2.setMinimumSize(glc_sz); + glJPanel2.setPreferredSize(glc_sz); + glJPanel2.setSize(glc_sz); + glJPanel2.addGLEventListener(new RedSquareES2()); + + final JPanel demoPanel = new JPanel(); + demoPanel.add(glJPanel1); + demoPanel.add(glJPanel2); final JFrame frame = new JFrame("Swing Print"); Assert.assertNotNull(frame); @@ -136,10 +146,13 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { final JPanel westPanel = new JPanel(); westPanel.add(new Label("West")); - Animator animator = new Animator(glJPanel); + Animator animator = new Animator(); + animator.add(glJPanel1); + animator.add(glJPanel2); QuitAdapter quitAdapter = new QuitAdapter(); - new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel1); + new AWTKeyAdapter(new TraceKeyAdapter(quitAdapter)).addTo(glJPanel2); new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); SwingUtilities.invokeAndWait(new Runnable() { @@ -147,7 +160,7 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { final Container fcont = frame.getContentPane(); fcont.setLayout(new BorderLayout()); fcont.add(printPanel, BorderLayout.NORTH); - fcont.add(glJPanel, BorderLayout.CENTER); + fcont.add(demoPanel, BorderLayout.CENTER); fcont.add(southPanel, BorderLayout.SOUTH); fcont.add(eastPanel, BorderLayout.EAST); fcont.add(westPanel, BorderLayout.WEST); @@ -157,7 +170,8 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { } } ) ; Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel2, true)); animator.setUpdateFPSFrames(60, System.err); animator.start(); @@ -184,7 +198,8 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { // try { Thread.sleep(4000); } catch (InterruptedException e) { } // time to finish print jobs .. FIXME ?? Assert.assertNotNull(frame); - Assert.assertNotNull(glJPanel); + Assert.assertNotNull(glJPanel1); + Assert.assertNotNull(glJPanel2); Assert.assertNotNull(animator); animator.stop(); @@ -197,7 +212,7 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { final Frame _frame = frame; - _frame.remove(glJPanel); + _frame.remove(demoPanel); _frame.dispose(); }}); } -- cgit v1.2.3 From 5dce252bfcc49995c2bda1d91e010c4c73f71ddb Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 13 Sep 2013 19:21:52 +0200 Subject: Add support for clang ; Use __APPLE__ predefined macro --- make/config/jogl/gl-headers.cfg | 2 +- make/config/jogl/gl3-headers.cfg | 2 +- make/config/jogl/glu-gl2.cfg | 2 +- make/scripts/make.jogl.all.macosx-clang.sh | 28 +++++++++++++++++++++++ src/nativewindow/native/JAWT_DrawingSurfaceInfo.c | 2 +- 5 files changed, 32 insertions(+), 4 deletions(-) create mode 100755 make/scripts/make.jogl.all.macosx-clang.sh (limited to 'make/scripts') diff --git a/make/config/jogl/gl-headers.cfg b/make/config/jogl/gl-headers.cfg index 62f5e8dd4..073f9d9a0 100644 --- a/make/config/jogl/gl-headers.cfg +++ b/make/config/jogl/gl-headers.cfg @@ -15,7 +15,7 @@ CustomCCode #define WGL_GLEXT_PROTOTYPES CustomCCode /* Include the OpenGL headers */ CustomCCode #include CustomCCode #include -CustomCCode #elif defined(macosx) +CustomCCode #elif defined(__APPLE__) CustomCCode #include CustomCCode #include CustomCCode /* Include the OpenGL headers */ diff --git a/make/config/jogl/gl3-headers.cfg b/make/config/jogl/gl3-headers.cfg index 7ab5099c9..a4c5cf62a 100644 --- a/make/config/jogl/gl3-headers.cfg +++ b/make/config/jogl/gl3-headers.cfg @@ -10,7 +10,7 @@ CustomCCode #include CustomCCode #include CustomCCode #include CustomCCode #include -CustomCCode #elif defined(macosx) +CustomCCode #elif defined(__APPLE__) CustomCCode #include CustomCCode #include CustomCCode #include diff --git a/make/config/jogl/glu-gl2.cfg b/make/config/jogl/glu-gl2.cfg index 2dcc15a94..491d9224f 100644 --- a/make/config/jogl/glu-gl2.cfg +++ b/make/config/jogl/glu-gl2.cfg @@ -15,7 +15,7 @@ CustomCCode #include CustomCCode #undef WIN32_LEAN_AND_MEAN CustomCCode CustomCCode #include -CustomCCode #elif defined(macosx) +CustomCCode #elif defined(__APPLE__) CustomCCode #include CustomCCode #include CustomCCode #include diff --git a/make/scripts/make.jogl.all.macosx-clang.sh b/make/scripts/make.jogl.all.macosx-clang.sh new file mode 100755 index 000000000..af9f1e1fe --- /dev/null +++ b/make/scripts/make.jogl.all.macosx-clang.sh @@ -0,0 +1,28 @@ +#! /bin/sh + +if [ -e /opt-share/etc/profile.ant ] ; then + . /opt-share/etc/profile.ant +fi + +JAVA_HOME=`/usr/libexec/java_home -version 1.7` +PATH=$JAVA_HOME/bin:$PATH +export JAVA_HOME PATH + +# -Dc.compiler.debug=true \ +# -Djavacdebug="true" \ +# -Djavacdebuglevel="source,lines,vars" \ +# + +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +export GLUEGEN_PROPERTIES_FILE="../../gluegen/make/lib/gluegen-clang.properties" +# or -Dgcc.compat.compiler=clang + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + +ant \ + -Drootrel.build=build-macosx \ + $* 2>&1 | tee make.jogl.all.macosx.log diff --git a/src/nativewindow/native/JAWT_DrawingSurfaceInfo.c b/src/nativewindow/native/JAWT_DrawingSurfaceInfo.c index 2a6651007..5c77b6d46 100644 --- a/src/nativewindow/native/JAWT_DrawingSurfaceInfo.c +++ b/src/nativewindow/native/JAWT_DrawingSurfaceInfo.c @@ -43,7 +43,7 @@ #define PLATFORM_DSI_SIZE sizeof(JAWT_Win32DrawingSurfaceInfo) #elif defined(linux) || defined(__sun) || defined(__FreeBSD__) || defined(_HPUX) #define PLATFORM_DSI_SIZE sizeof(JAWT_X11DrawingSurfaceInfo) -#elif defined(macosx) +#elif defined(__APPLE__) #define PLATFORM_DSI_SIZE sizeof(JAWT_MacOSXDrawingSurfaceInfo) #else ERROR: port JAWT_DrawingSurfaceInfo.c to your platform -- cgit v1.2.3 From 06b47d1f738c94ca28c0959a12b05d880bc8a78b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 16 Sep 2013 02:59:30 +0200 Subject: Add 'DirectDataBufferInt' supporting NIO based BufferedImages - Contains convenient method to create an NIO backed BufferedImage 'BufferedImage createBufferedImage(int width, int height, int numComponents, Point location)' Standalone test TestTiledPrintingNIOImageSwingAWT 'prints', i.e. renders offscreen, the Frame into - a traditional array-backed BufferedImage - an NIO-backed backed BufferedImage --- make/scripts/tests.sh | 3 +- .../nativewindow/awt/DirectDataBufferInt.java | 238 +++++++++++++++++ .../tile/TestTiledPrintingNIOImageSwingAWT.java | 296 +++++++++++++++++++++ .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 4 +- 4 files changed, 538 insertions(+), 3 deletions(-) create mode 100644 src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index db267816e..9e2a06dac 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -330,8 +330,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java new file mode 100644 index 000000000..d9c3c3791 --- /dev/null +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java @@ -0,0 +1,238 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.nativewindow.awt; + +import java.awt.Point; +import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.DataBuffer; +import java.awt.image.DirectColorModel; +import java.awt.image.SampleModel; +import java.awt.image.SinglePixelPackedSampleModel; +import java.awt.image.WritableRaster; +import java.nio.IntBuffer; + +import com.jogamp.common.nio.Buffers; + +/** + * {@link DataBuffer} specialization using NIO direct buffer of type {@link DataBuffer#TYPE_INT} as storage. + */ +public final class DirectDataBufferInt extends DataBuffer { + + public static class DirectWritableRaster extends WritableRaster { + protected DirectWritableRaster(SampleModel sampleModel, DirectDataBufferInt dataBuffer, Point origin) { + super(sampleModel, dataBuffer, origin); + } + } + + /** + * Creates a {@link BufferedImage} using an RGB[A] {@link DirectColorModel} + * with an {@link DirectWritableRaster} utilizing a {@link DirectDataBufferInt} as storage. + * + * @param width + * @param height + * @param numComponents 3 or 4 components, i.e. {@link BufferedImage#TYPE_INT_RGB} or {@link BufferedImage#TYPE_INT_RGBA}. + * @param location origin, if null 0/0 is assumed. + * @return + */ + public static BufferedImage createBufferedImage(int width, int height, int numComponents, Point location) { + final int[] bandOffsets = new int[numComponents]; + for (int i=0; i < numComponents; i++) { + bandOffsets[i] = i; + } + final int bpp, rmask, gmask, bmask, amask; + final ColorModel cm; + if( 4 == numComponents ) { + bpp = 32; + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0xff000000; + cm = ColorModel.getRGBdefault(); + } else if( 3 == numComponents ) { + bpp = 24; + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0x0; + cm = new DirectColorModel(bpp, rmask, gmask, bmask, amask); + } else { + throw new IllegalArgumentException("numComponents must be [3..4], has "+numComponents); + } + final int[] bandMasks; + if ( 0 != amask ) { + bandMasks = new int[4]; + bandMasks[3] = amask; + } + else { + bandMasks = new int[3]; + } + bandMasks[0] = rmask; + bandMasks[1] = gmask; + bandMasks[2] = bmask; + + final DirectDataBufferInt dataBuffer = new DirectDataBufferInt(width*height); + if( null == location ) { + location = new Point(0,0); + } + final SinglePixelPackedSampleModel sppsm = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), + width, height, width /* scanLineStride */, bandMasks); + // IntegerComponentRasters must haveinteger DataBuffers: + // final WritableRaster raster = new IntegerInterleavedRaster(sppsm, dataBuffer, location); + // Not public: + // final WritableRaster raster = new SunWritableRaster(sppsm, dataBuffer, location); + final WritableRaster raster = new DirectWritableRaster(sppsm, dataBuffer, location); + + return new BufferedImage (cm, raster, false /* isRasterPremultiplied */, null /* properties */); + } + + /** Default data bank. */ + private IntBuffer data; + + /** All data banks */ + private IntBuffer bankdata[]; + + /** + * Constructs an nio integer-based {@link DataBuffer} with a single bank + * and the specified size. + * + * @param size The size of the {@link DataBuffer}. + */ + public DirectDataBufferInt(int size) { + super(TYPE_INT, size); + data = Buffers.newDirectIntBuffer(size); + bankdata = new IntBuffer[1]; + bankdata[0] = data; + } + + /** + * Constructs an nio integer-based {@link DataBuffer} with the specified number of + * banks, all of which are the specified size. + * + * @param size The size of the banks in the {@link DataBuffer}. + * @param numBanks The number of banks in the a{@link DataBuffer}. + */ + public DirectDataBufferInt(int size, int numBanks) { + super(TYPE_INT,size,numBanks); + bankdata = new IntBuffer[numBanks]; + for (int i= 0; i < numBanks; i++) { + bankdata[i] = Buffers.newDirectIntBuffer(size); + } + data = bankdata[0]; + } + + /** + * Constructs an nio integer-based {@link DataBuffer} with a single bank using the + * specified array. + *

        + * Only the first size elements should be used by accessors of + * this {@link DataBuffer}. dataArray must be large enough to + * hold size elements. + *

        + * + * @param dataArray The integer array for the {@link DataBuffer}. + * @param size The size of the {@link DataBuffer} bank. + */ + public DirectDataBufferInt(IntBuffer dataArray, int size) { + super(TYPE_INT,size); + data = dataArray; + bankdata = new IntBuffer[1]; + bankdata[0] = data; + } + + /** + * Returns the default (first) int data array in {@link DataBuffer}. + * + * @return The first integer data array. + */ + public IntBuffer getData() { + return data; + } + + /** + * Returns the data array for the specified bank. + * + * @param bank The bank whose data array you want to get. + * @return The data array for the specified bank. + */ + public IntBuffer getData(int bank) { + return bankdata[bank]; + } + + /** + * Returns the requested data array element from the first (default) bank. + * + * @param i The data array element you want to get. + * @return The requested data array element as an integer. + * @see #setElem(int, int) + * @see #setElem(int, int, int) + */ + public int getElem(int i) { + return data.get(i+offset); + } + + /** + * Returns the requested data array element from the specified bank. + * + * @param bank The bank from which you want to get a data array element. + * @param i The data array element you want to get. + * @return The requested data array element as an integer. + * @see #setElem(int, int) + * @see #setElem(int, int, int) + */ + public int getElem(int bank, int i) { + return bankdata[bank].get(i+offsets[bank]); + } + + /** + * Sets the requested data array element in the first (default) bank + * to the specified value. + * + * @param i The data array element you want to set. + * @param val The integer value to which you want to set the data array element. + * @see #getElem(int) + * @see #getElem(int, int) + */ + public void setElem(int i, int val) { + data.put(i+offset, val); + } + + /** + * Sets the requested data array element in the specified bank + * to the integer value i. + * @param bank The bank in which you want to set the data array element. + * @param i The data array element you want to set. + * @param val The integer value to which you want to set the specified data array element. + * @see #getElem(int) + * @see #getElem(int, int) + */ + public void setElem(int bank, int i, int val) { + bankdata[bank].put(i+offsets[bank], val); + } +} + diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java new file mode 100644 index 000000000..ad699c0f5 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java @@ -0,0 +1,296 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.tile; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.Label; +import java.awt.RenderingHints; +import java.awt.image.BufferedImage; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; + +import javax.imageio.ImageIO; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLayeredPane; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.common.util.awt.AWTEDTExecutor; +import com.jogamp.nativewindow.awt.AWTPrintLifecycle; +import com.jogamp.nativewindow.awt.DirectDataBufferInt; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.texture.TextureIO; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestTiledPrintingNIOImageSwingAWT extends UITestCase { + + static boolean waitForKey = false; + /** only when run manually .. */ + static boolean allow600dpi = false; + static GLProfile glp; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2)) { + glp = GLProfile.get(GLProfile.GL2); + Assert.assertNotNull(glp); + width = 640; + height = 480; + } else { + setTestSupported(false); + } + // Runtime.getRuntime().traceInstructions(true); + // Runtime.getRuntime().traceMethodCalls(true); + } + + @AfterClass + public static void releaseClass() { + } + + protected void printOffscreenToFile(final BufferedImage image, final Frame frame, final GLCapabilities caps, final int num, final String detail) { + final Insets frameInsets = frame.getInsets(); + final int frameWidth = frame.getWidth(); + final int frameHeight= frame.getHeight(); + final int imageWidth = image.getWidth(); + final int imageHeight= image.getHeight(); + final double scaleComp72; + { + final double frameBorderW = frameInsets.left + frameInsets.right; + final double frameBorderH = frameInsets.top + frameInsets.bottom; + final double sx = (double)imageWidth / ( frameWidth + frameBorderW ); + final double sy = (double)imageHeight / ( frameHeight + frameBorderH ); + scaleComp72 = Math.min(sx, sy); + } + System.err.println("PRINT DPI: scaleComp72 "+scaleComp72+", image-size "+imageWidth+"x"+imageHeight+", frame[border "+frameInsets+", size "+frameWidth+"x"+frameHeight+"]"); + + System.err.println("XXX: image "+image); + System.err.println("XXX: cm "+image.getColorModel()); + System.err.println("XXX: raster "+image.getRaster()); + System.err.println("XXX: dataBuffer "+image.getRaster().getDataBuffer()); + + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + final Graphics2D g2d = (Graphics2D) image.getGraphics(); + g2d.setClip(0, 0, image.getWidth(), image.getHeight()); + g2d.scale(scaleComp72, scaleComp72); + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + + // frame.paintAll(g2d); + final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, 1.0/scaleComp72, 1.0/scaleComp72, 0); + try { + frame.printAll(g2d); + } finally { + ctx.releasePrint(); + } + // to file + final String fname = getSnapshotFilename(num, detail, caps, image.getWidth(), image.getHeight(), false, TextureIO.PNG, null); + System.err.println("XXX file "+fname); + final File fout = new File(fname); + try { + ImageIO.write(image, "png", fout); + } catch (IOException e) { + e.printStackTrace(); + } + } }); + } + + protected void runTestGL(final GLCapabilities caps, final boolean layered) throws InterruptedException, InvocationTargetException { + final int layerStepX = width/6, layerStepY = height/6; + final Dimension glc_sz = new Dimension(layered ? width - 2*layerStepX : width/2, layered ? height - 2*layerStepY : height); + final GLJPanel glJPanel1 = new GLJPanel(caps); + Assert.assertNotNull(glJPanel1); + glJPanel1.setMinimumSize(glc_sz); + glJPanel1.setPreferredSize(glc_sz); + if( layered ) { + glJPanel1.setBounds(layerStepX/2, layerStepY/2, glc_sz.width, glc_sz.height); + } else { + glJPanel1.setBounds(0, 0, glc_sz.width, glc_sz.height); + } + glJPanel1.addGLEventListener(new Gears()); + + final GLJPanel glJPanel2 = new GLJPanel(caps); + Assert.assertNotNull(glJPanel2); + glJPanel2.setMinimumSize(glc_sz); + glJPanel2.setPreferredSize(glc_sz); + if( layered ) { + glJPanel2.setBounds(3*layerStepY, 2*layerStepY, glc_sz.width, glc_sz.height); + } else { + glJPanel2.setBounds(0, 0, glc_sz.width, glc_sz.height); + } + glJPanel2.addGLEventListener(new RedSquareES2()); + // glJPanel2.addGLEventListener(new Gears()); + + final JComponent demoPanel; + if( layered ) { + glJPanel1.setOpaque(true); + glJPanel2.setOpaque(false); + final Dimension lsz = new Dimension(width, height); + demoPanel = new JLayeredPane(); + demoPanel.setMinimumSize(lsz); + demoPanel.setPreferredSize(lsz); + demoPanel.setBounds(0, 0, lsz.width, lsz.height); + demoPanel.setBorder(BorderFactory.createTitledBorder("Layered Pane")); + demoPanel.add(glJPanel1, JLayeredPane.DEFAULT_LAYER); + demoPanel.add(glJPanel2, Integer.valueOf(1)); + final JButton tb = new JButton("On Top"); + tb.setBounds(4*layerStepY, 3*layerStepY, 100, 50); + demoPanel.add(tb, Integer.valueOf(2)); + } else { + demoPanel = new JPanel(); + demoPanel.add(glJPanel1); + demoPanel.add(glJPanel2); + } + + final JFrame frame = new JFrame("Swing Print"); + Assert.assertNotNull(frame); + + final Button print72DPIButton = new Button("72dpi"); // dummy + final Button print300DPIButton = new Button("300dpi"); // dummy + final Button print600DPIButton = new Button("600dpi"); // dummy + + final JPanel printPanel = new JPanel(); + printPanel.add(print72DPIButton); + printPanel.add(print300DPIButton); + printPanel.add(print600DPIButton); + final JPanel southPanel = new JPanel(); + southPanel.add(new Label("South")); + final JPanel eastPanel = new JPanel(); + eastPanel.add(new Label("East")); + final JPanel westPanel = new JPanel(); + westPanel.add(new Label("West")); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + final Container fcont = frame.getContentPane(); + fcont.setLayout(new BorderLayout()); + fcont.add(printPanel, BorderLayout.NORTH); + fcont.add(demoPanel, BorderLayout.CENTER); + fcont.add(southPanel, BorderLayout.SOUTH); + fcont.add(eastPanel, BorderLayout.EAST); + fcont.add(westPanel, BorderLayout.WEST); + fcont.validate(); + frame.pack(); + frame.setVisible(true); + } } ) ; + + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel2, true)); + + // paint offscreen: array 72dpi + { + final BufferedImage image = new BufferedImage(frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_ARGB); + printOffscreenToFile(image, frame, caps, 0, "array_072dpi"); + } + // paint offscreen: NIO 72dpi + { + final BufferedImage image = DirectDataBufferInt.createBufferedImage(frame.getWidth(), frame.getHeight(), 4, null /* location */); + printOffscreenToFile(image, frame, caps, 1, "newio_072dpi"); + } + // paint offscreen: NIO 600dpi + { + final int scale = (int) ( 600.0 / 72.0 + 0.5 ); + final BufferedImage image = DirectDataBufferInt.createBufferedImage(frame.getWidth()*scale, frame.getHeight()*scale, 4, null /* location */); + printOffscreenToFile(image, frame, caps, 2, "newio_600dpi"); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glJPanel1); + Assert.assertNotNull(glJPanel2); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + final Frame _frame = frame; + _frame.remove(demoPanel); + _frame.dispose(); + }}); + } + + @Test + public void test01_Offscreen_aa0() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, false); + } + + static long duration = 500; // ms + + public static void main(String args[]) { + allow600dpi = true; + for(int i=0; i Date: Wed, 18 Sep 2013 17:31:45 +0200 Subject: AWTTilePainter: Fix case with no GLOrientation, i.e. no vertical-flip. Tile location and destination must follow same math as w/ vertical-flip. .. clipping and tile-height was not considered. --- make/scripts/tests-win.bat | 9 +++++++++ make/scripts/tests-x64-dbg.bat | 3 ++- make/scripts/tests.sh | 6 +++--- .../classes/jogamp/opengl/awt/AWTTilePainter.java | 13 ++----------- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 19 +++++++++++++++++-- 5 files changed, 33 insertions(+), 17 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index af01ee2e1..6759994a2 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -52,6 +52,15 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 986aba8ec..ddecbc3f7 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -29,7 +29,7 @@ REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.Capabili REM set D_ARGS="-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" REM set D_ARGS="-Djogl.debug.GLMediaPlayer" REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.AudioSink" -set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.GLMediaPlayer.Native" +REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.GLMediaPlayer.Native" REM set D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25" "-Djogl.debug.GLMediaPlayer" REM set D_ARGS="-Djogl.debug.GLMediaPlayer.Native" REM set D_ARGS="-Djogl.debug.AudioSink" @@ -47,6 +47,7 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" +set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9e2a06dac..05f5f9652 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -216,7 +216,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" - #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" + D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" #D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" @@ -330,9 +330,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index a06dbcb3d..f3aba3902 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -212,11 +212,7 @@ public class AWTTilePainter { renderer.setImageSize(iImageSizeScaled.width, iImageSizeScaled.height); renderer.clipImageSize(iClipScaled.width, iClipScaled.height); final int clipH = Math.min(iImageSizeScaled.height, iClipScaled.height); - if( flipVertical ) { - renderer.setTileOffset(iClipScaled.x, iImageSizeScaled.height - ( iClipScaled.y + clipH )); - } else { - renderer.setTileOffset(iClipScaled.x, iClipScaled.y); - } + renderer.setTileOffset(iClipScaled.x, iImageSizeScaled.height - ( iClipScaled.y + clipH )); if( verbose ) { System.err.println("AWT print.0: image "+dImageSizeOrig + " -> " + dImageSizeScaled + " -> " + iImageSizeScaled); System.err.println("AWT print.0: clip "+gClipOrigR + " -> " + dClipOrig + " -> " + dClipScaled + " -> " + iClipScaled); @@ -290,12 +286,7 @@ public class AWTTilePainter { final int pX = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); final int pY = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); final int pYOff = renderer.getParam(TileRenderer.TR_TILE_Y_OFFSET); - final int pYf; - if( flipVertical ) { - pYf = cis.getHeight() - ( pY - pYOff + tHeight ) + scaledYOffset; - } else { - pYf = pY; - } + final int pYf = cis.getHeight() - ( pY - pYOff + tHeight ) + scaledYOffset; // Copy temporary data into raster of BufferedImage for faster // blitting Note that we could avoid this copy in the cases diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index 72f4871b8..f331f5d88 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -64,7 +64,7 @@ import com.jogamp.newt.event.TraceKeyAdapter; import com.jogamp.newt.event.TraceWindowAdapter; import com.jogamp.newt.event.awt.AWTKeyAdapter; import com.jogamp.newt.event.awt.AWTWindowAdapter; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.QuitAdapter; @@ -120,7 +120,7 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { } else { glJPanel2.setBounds(0, 0, glc_sz.width, glc_sz.height); } - glJPanel2.addGLEventListener(new RedSquareES2()); + glJPanel2.addGLEventListener(new RedSquareES1()); // glJPanel2.addGLEventListener(new Gears()); final JComponent demoPanel; @@ -272,6 +272,21 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { runTestGL(caps, true); } + @Test + public void test01_aa0_bitmap() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, false); + } + + @Test + public void test01_aa0_bitmap_layered() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + caps.setAlphaBits(8); + runTestGL(caps, true); + } + @Test public void test02_aa8() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); -- cgit v1.2.3 From 99e303b6bc7f87a31efb82856bd1baae9ba3e52b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 19 Sep 2013 04:17:51 +0200 Subject: Bump to JDK/JRE 7u40. --- make/scripts/make.jogl.all.win32.bat | 4 ++-- make/scripts/make.jogl.all.win64.bat | 4 ++-- make/scripts/tests-javaws-x64.bat | 2 +- make/scripts/tests-x32-dbg.bat | 4 ++-- make/scripts/tests-x32.bat | 4 ++-- make/scripts/tests-x64-dbg.bat | 4 ++-- make/scripts/tests-x64.bat | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.win32.bat b/make/scripts/make.jogl.all.win32.bat index 7b0243f1e..041d8c71f 100755 --- a/make/scripts/make.jogl.all.win32.bat +++ b/make/scripts/make.jogl.all.win32.bat @@ -1,7 +1,7 @@ set THISDIR="C:\JOGL" -set J2RE_HOME=c:\jre1.7.0_25_x32 -set JAVA_HOME=c:\jdk1.7.0_25_x32 +set J2RE_HOME=c:\jre1.7.0_40_x32 +set JAVA_HOME=c:\jdk1.7.0_40_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% diff --git a/make/scripts/make.jogl.all.win64.bat b/make/scripts/make.jogl.all.win64.bat index c08c5260e..d263f0c17 100755 --- a/make/scripts/make.jogl.all.win64.bat +++ b/make/scripts/make.jogl.all.win64.bat @@ -1,7 +1,7 @@ set THISDIR="C:\JOGL" -set J2RE_HOME=c:\jre1.7.0_25_x64 -set JAVA_HOME=c:\jdk1.7.0_25_x64 +set J2RE_HOME=c:\jre1.7.0_40_x64 +set JAVA_HOME=c:\jdk1.7.0_40_x64 set ANT_PATH=C:\apache-ant-1.8.2 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%PATH% diff --git a/make/scripts/tests-javaws-x64.bat b/make/scripts/tests-javaws-x64.bat index c14ea5ffe..87cf52990 100755 --- a/make/scripts/tests-javaws-x64.bat +++ b/make/scripts/tests-javaws-x64.bat @@ -1,4 +1,4 @@ -set JRE_PATH=C:\jre1.7.0_25_x64\bin +set JRE_PATH=C:\jre1.7.0_40_x64\bin set LOG_PATH=%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\log %JRE_PATH%\javaws -uninstall diff --git a/make/scripts/tests-x32-dbg.bat b/make/scripts/tests-x32-dbg.bat index 4c9c3421f..261f621a2 100755 --- a/make/scripts/tests-x32-dbg.bat +++ b/make/scripts/tests-x32-dbg.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win32 -set J2RE_HOME=c:\jre1.7.0_25_x32 -set JAVA_HOME=c:\jdk1.7.0_25_x32 +set J2RE_HOME=c:\jre1.7.0_40_x32 +set JAVA_HOME=c:\jdk1.7.0_40_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index 1c646fd37..1f932a85b 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win32 -set J2RE_HOME=c:\jre1.7.0_25_x32 -set JAVA_HOME=c:\jdk1.7.0_25_x32 +set J2RE_HOME=c:\jre1.7.0_40_x32 +set JAVA_HOME=c:\jdk1.7.0_40_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index ddecbc3f7..c9b98ffb8 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win64 -set J2RE_HOME=c:\jre1.7.0_25_x64 -set JAVA_HOME=c:\jdk1.7.0_25_x64 +set J2RE_HOME=c:\jre1.7.0_40_x64 +set JAVA_HOME=c:\jdk1.7.0_40_x64 set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 2801e0eb5..6e132e5d7 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win64 -set J2RE_HOME=c:\jre1.7.0_25_x64 -set JAVA_HOME=c:\jdk1.7.0_25_x64 +set J2RE_HOME=c:\jre1.7.0_40_x64 +set JAVA_HOME=c:\jdk1.7.0_40_x64 set ANT_PATH=C:\apache-ant-1.8.2 REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x64 -- cgit v1.2.3 From b1db882abfe6166abb5f06df8ff2d386e5f8f842 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 19 Sep 2013 09:20:03 +0200 Subject: Fix Bug 835: Use target.[sourcelevel,targetlevel,rt.jar] for all javac tasks. Before we bumped java language version to 1.6, i.e. target == 1.5, we required to compile some parts w/ the host level (1.6). This is no more required. --- make/build-jogl.xml | 6 +++--- make/build-staticglgen.xml | 4 +++- make/scripts/check-java-major-version.sh | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 80df63765..e83f33603 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -796,9 +796,9 @@ includeAntRuntime="true" memoryMaximumSize="${javac.memorymax}" encoding="UTF-8" - source="${host.sourcelevel}" - target="${host.targetlevel}" - bootclasspath="${host.rt.jar}" + source="${target.sourcelevel}" + target="${target.targetlevel}" + bootclasspath="${target.rt.jar}" debug="${javacdebug}" debuglevel="${javacdebuglevel}"> diff --git a/make/build-staticglgen.xml b/make/build-staticglgen.xml index 6d1511058..8256fb00e 100644 --- a/make/build-staticglgen.xml +++ b/make/build-staticglgen.xml @@ -59,7 +59,9 @@ includeAntRuntime="true" memoryMaximumSize="${javac.memorymax}" encoding="UTF-8" - source="${host.sourcelevel}"> + source="${target.sourcelevel}" + target="${target.targetlevel}" + bootclasspath="${target.rt.jar}"> diff --git a/make/scripts/check-java-major-version.sh b/make/scripts/check-java-major-version.sh index 08e3bc7b5..86a2c2832 100755 --- a/make/scripts/check-java-major-version.sh +++ b/make/scripts/check-java-major-version.sh @@ -24,4 +24,8 @@ function do_it() { } do_it $1 2>&1 | tee check-java-major-version.log +echo +echo VERSIONS found: +echo +grep 'major version' check-java-major-version.log | sort -u -- cgit v1.2.3 From c427ed22244df44b71a0f1f000b0f93e56c283c2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Sep 2013 12:18:48 +0200 Subject: Fix Bug 826: GLJPanel: Fully restore TextureState and Viewport In FBO mode save TextureState of current texture-unit, as well as for the fbo texture-unit if the latter is a different. In glslTextureRaster mode for verical flip (using FBO), set the viewport to drawable size if before flipping and restore afterward - if equired. TestGLJPanelTextureStateAWT fully tests use cases: - Keep texture bound w/ same or other texture-unit - Use 2 viewports within one drawable and keep it --- make/scripts/tests.sh | 5 +- .../jogamp/opengl/util/texture/TextureState.java | 167 ++++++++++++ .../classes/javax/media/opengl/awt/GLJPanel.java | 53 +++- .../jogl/awt/TestGLJPanelTextureStateAWT.java | 282 ++++++++++++++++++++ .../junit/jogl/demos/TextureDraw01Accessor.java | 1 + .../jogl/demos/es2/TextureDraw01ES2Listener.java | 82 ++++-- .../demos/es2/TextureDraw02ES2ListenerFBO.java | 285 +++++++++++++++++++++ .../jogl/demos/gl2/TextureDraw01GL2Listener.java | 34 ++- .../jogl/util/DemoGL2ES1TextureImmModeSink.java | 34 ++- .../jogl/util/texture/TestJPEGImage01NEWT.java | 2 +- .../texture/TestJPEGJoglAWTCompareNewtAWT.java | 4 +- .../util/texture/TestJPEGTextureFromFileNEWT.java | 2 +- .../jogl/util/texture/TestPNGImage01NEWT.java | 2 +- .../util/texture/TestPNGTextureFromFileAWT.java | 2 +- .../util/texture/TestPNGTextureFromFileNEWT.java | 2 +- .../util/texture/TestTGATextureFromFileNEWT.java | 2 +- 16 files changed, 901 insertions(+), 58 deletions(-) create mode 100644 src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureDraw02ES2ListenerFBO.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 05f5f9652..b94e23dc1 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -216,6 +216,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" #D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" @@ -330,7 +331,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -472,6 +474,7 @@ testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java new file mode 100644 index 000000000..4a5d368e3 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureState.java @@ -0,0 +1,167 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util.texture; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GL2GL3; +import javax.media.opengl.GL3; +import javax.media.opengl.GLException; + +/** + * Preserves a [ texture-unit, texture-target ] state. + *

        + * The states keys are the retrieved active texture-unit and the given texture-target + * for which the following states are being queried: + *

        + *   - texture-object
        + *   - GL.GL_TEXTURE_MAG_FILTER
        + *   - GL.GL_TEXTURE_MIN_FILTER
        + *   - GL.GL_TEXTURE_WRAP_S
        + *   - GL.GL_TEXTURE_WRAP_T            
        + * 
        + */ +public class TextureState { + /** + * Returns the pname to query the textureTarget currently bound to the active texture-unit. + *

        + * Returns 0 is textureTarget is not supported. + *

        + */ + public static final int getTextureTargetQueryName(int textureTarget) { + final int texBindQName; + switch(textureTarget) { + case GL.GL_TEXTURE_2D: texBindQName = GL.GL_TEXTURE_BINDING_2D; break; + case GL.GL_TEXTURE_CUBE_MAP: texBindQName = GL.GL_TEXTURE_BINDING_CUBE_MAP; break; + case GL2ES2.GL_TEXTURE_3D: texBindQName = GL2ES2.GL_TEXTURE_BINDING_3D; break; + case GL2GL3.GL_TEXTURE_1D: texBindQName = GL2GL3.GL_TEXTURE_BINDING_1D; break; + case GL2GL3.GL_TEXTURE_1D_ARRAY: texBindQName = GL2GL3.GL_TEXTURE_BINDING_1D_ARRAY; break; + case GL2GL3.GL_TEXTURE_2D_ARRAY: texBindQName = GL2GL3.GL_TEXTURE_BINDING_2D_ARRAY; break; + case GL2GL3.GL_TEXTURE_RECTANGLE: texBindQName = GL2GL3.GL_TEXTURE_BINDING_RECTANGLE; break; + case GL2GL3.GL_TEXTURE_BUFFER: texBindQName = GL2GL3.GL_TEXTURE_BINDING_BUFFER; break; + case GL3.GL_TEXTURE_2D_MULTISAMPLE: texBindQName = GL3.GL_TEXTURE_BINDING_2D_MULTISAMPLE; break; + case GL3.GL_TEXTURE_2D_MULTISAMPLE_ARRAY: texBindQName = GL3.GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY; break; + default: texBindQName = 0; + } + return texBindQName; + } + + private final int target; + /** + *
        +     *   0 - unit
        +     *   1 - texture object
        +     *   2 - GL.GL_TEXTURE_MAG_FILTER
        +     *   3 - GL.GL_TEXTURE_MIN_FILTER
        +     *   4 - GL.GL_TEXTURE_WRAP_S
        +     *   5 - GL.GL_TEXTURE_WRAP_T            
        +     * 
        + */ + private final int[] state = new int[] { 0, 0, 0, 0, 0, 0 }; + + private static final String toHexString(int i) { return "0x"+Integer.toHexString(i); } + + private static final int activeTexture(GL gl) { + final int[] vi = { 0 }; + gl.glGetIntegerv(GL.GL_ACTIVE_TEXTURE, vi, 0); + return vi[0]; + } + + /** + * Creates a texture state for the retrieved active texture-unit and the given texture-target. + * See {@link TextureState}. + * @param gl current GL context's GL object + * @param textureTarget + * @throws GLException if textureTarget is not supported + */ + public TextureState(GL gl, int textureTarget) throws GLException { + this(gl, activeTexture(gl), textureTarget); + } + + /** + * Creates a texture state for the given active texture-unit and the given texture-target. + * See {@link TextureState}. + * @param gl current GL context's GL object + * @param textureUnit of range [ {@link GL#GL_TEXTURE0}.. ] + * @param textureTarget + * @throws GLException if textureTarget is not supported + */ + public TextureState(GL gl, int textureUnit, int textureTarget) throws GLException { + target = textureTarget; + state[0] = textureUnit; + final int texBindQName = getTextureTargetQueryName(textureTarget); + if( 0 == texBindQName ) { + throw new GLException("Unsupported textureTarget "+toHexString(textureTarget)); + } + gl.glGetIntegerv(texBindQName, state, 1); + gl.glGetTexParameteriv(target, GL.GL_TEXTURE_MAG_FILTER, state, 2); + gl.glGetTexParameteriv(target, GL.GL_TEXTURE_MIN_FILTER, state, 3); + gl.glGetTexParameteriv(target, GL.GL_TEXTURE_WRAP_S, state, 4); + gl.glGetTexParameteriv(target, GL.GL_TEXTURE_WRAP_T, state, 5); + } + + /** + * Restores the texture-unit's texture-target state. + *

        + * First the texture-unit is activated, then all states are restored. + *

        + * @param gl current GL context's GL object + */ + public final void restore(GL gl) { + gl.glActiveTexture(state[0]); + gl.glBindTexture(target, state[1]); + gl.glTexParameteri(target, GL.GL_TEXTURE_MAG_FILTER, state[2]); + gl.glTexParameteri(target, GL.GL_TEXTURE_MIN_FILTER, state[3]); + gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_S, state[4]); + gl.glTexParameteri(target, GL.GL_TEXTURE_WRAP_T, state[5]); + } + + /** Returns the texture-unit of this state, key value. Unit is of range [ {@link GL#GL_TEXTURE0}.. ]. */ + public final int getUnit() { return state[0]; } + /** Returns the texture-target of this state, key value. */ + public final int getTarget() { return target; } + + /** Returns the state's texture-object. */ + public final int getObject() { return state[1]; } + /** Returns the state's mag-filter param. */ + public final int getMagFilter() { return state[2]; } + /** Returns the state's min-filter param. */ + public final int getMinFilter() { return state[3]; } + /** Returns the state's wrap-s param. */ + public final int getWrapS() { return state[4]; } + /** Returns the state's wrap-t param. */ + public final int getWrapT() { return state[5]; } + + + public final String toString() { + return "TextureState[unit "+(state[0] - GL.GL_TEXTURE0)+", target "+toHexString(target)+ + ": obj "+toHexString(state[1])+ + ", filter[mag "+toHexString(state[2])+", min "+toHexString(state[3])+"], "+ + ": wrap[s "+toHexString(state[4])+", t "+toHexString(state[5])+"]]"; + } +} diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index e9d1b38d2..61ff4997e 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -101,6 +101,7 @@ import com.jogamp.opengl.util.TileRenderer; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.AWTGLPixelBufferProvider; import com.jogamp.opengl.util.awt.AWTGLPixelBuffer.SingleAWTGLPixelBufferProvider; +import com.jogamp.opengl.util.texture.TextureState; /** A lightweight Swing component which provides OpenGL rendering support. Provided for compatibility with Swing user interfaces @@ -1219,6 +1220,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // Implementation using software rendering private GLDrawableImpl offscreenDrawable; + private boolean offscreenIsFBO; private FBObject fboFlipped; private GLSLTextureRaster glslTextureRaster; @@ -1264,7 +1266,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final GL gl = offscreenContext.getGL(); flipVertical = offscreenDrawable.isGLOriented(); final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities(); - if( USE_GLSL_TEXTURE_RASTERIZER && chosenCaps.isFBO() && flipVertical && gl.isGL2ES2() ) { + offscreenIsFBO = chosenCaps.isFBO(); + if( USE_GLSL_TEXTURE_RASTERIZER && offscreenIsFBO && flipVertical && gl.isGL2ES2() ) { final boolean _autoSwapBufferMode = helper.getAutoSwapBufferMode(); helper.setAutoSwapBufferMode(false); final GLFBODrawable fboDrawable = (GLFBODrawable) offscreenDrawable; @@ -1344,6 +1347,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing adevice.close(); } } + offscreenIsFBO = false; if( null != readBackIntsForCPUVFlip ) { readBackIntsForCPUVFlip.clear(); @@ -1420,10 +1424,23 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing readBackInts = readBackIntsForCPUVFlip; } - if( DEBUG_VIEWPORT ) { - int[] vp = new int[] { 0, 0, 0, 0 }; - gl.glGetIntegerv(GL.GL_VIEWPORT, vp, 0); - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: Viewport: "+vp[0]+"/"+vp[1]+" "+vp[2]+"x"+vp[3]); + final TextureState usrTexState, fboTexState; + final int fboTexUnit = GL.GL_TEXTURE0 + ( offscreenIsFBO ? ((GLFBODrawable)offscreenDrawable).getTextureUnit() : 0 ); + + if( offscreenIsFBO ) { + usrTexState = new TextureState(gl, GL.GL_TEXTURE_2D); + if( fboTexUnit != usrTexState.getUnit() ) { + // glActiveTexture(..) + glBindTexture(..) are implicit performed in GLFBODrawableImpl's + // swapBuffers/contextMadeCurent -> swapFBOImpl. + // We need to cache the texture unit's bound texture-id before it's overwritten. + gl.glActiveTexture(fboTexUnit); + fboTexState = new TextureState(gl, fboTexUnit, GL.GL_TEXTURE_2D); + } else { + fboTexState = usrTexState; + } + } else { + usrTexState = null; + fboTexState = null; } // Must now copy pixels from offscreen context into surface @@ -1439,6 +1456,20 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing offscreenDrawable.swapBuffers(); if(null != glslTextureRaster) { // implies flippedVertical + final boolean viewportChange; + final int[] usrViewport = new int[] { 0, 0, 0, 0 }; + gl.glGetIntegerv(GL.GL_VIEWPORT, usrViewport, 0); + viewportChange = 0 != usrViewport[0] || 0 != usrViewport[1] || + offscreenDrawable.getWidth() != usrViewport[2] || offscreenDrawable.getHeight() != usrViewport[3]; + if( DEBUG_VIEWPORT ) { + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: Viewport: change "+viewportChange+ + ", "+usrViewport[0]+"/"+usrViewport[1]+" "+usrViewport[2]+"x"+usrViewport[3]+ + " -> 0/0 "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()); + } + if( viewportChange ) { + gl.glViewport(0, 0, offscreenDrawable.getWidth(), offscreenDrawable.getHeight()); + } + // perform vert-flipping via OpenGL/FBO final GLFBODrawable fboDrawable = (GLFBODrawable)offscreenDrawable; final FBObject.TextureAttachment fboTex = fboDrawable.getTextureBuffer(GL.GL_FRONT); @@ -1446,12 +1477,17 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing fboFlipped.bind(gl); // gl.glActiveTexture(GL.GL_TEXTURE0 + fboDrawable.getTextureUnit()); // implicit by GLFBODrawableImpl: swapBuffers/contextMadeCurent -> swapFBOImpl - gl.glBindTexture(GL.GL_TEXTURE_2D, fboTex.getName()); + gl.glBindTexture(GL.GL_TEXTURE_2D, fboTex.getName()); // gl.glClear(GL.GL_DEPTH_BUFFER_BIT); // fboFlipped runs w/o DEPTH! + glslTextureRaster.display(gl.getGL2ES2()); gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts); - + fboFlipped.unbind(gl); + if( viewportChange ) { + gl.glViewport(usrViewport[0], usrViewport[1], usrViewport[2], usrViewport[3]); + } + fboTexState.restore(gl); } else { gl.glReadPixels(0, 0, panelWidth, panelHeight, pixelAttribs.format, pixelAttribs.type, readBackInts); @@ -1471,6 +1507,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } } } + if( offscreenIsFBO && fboTexUnit != usrTexState.getUnit() ) { + usrTexState.restore(gl); + } // Restore saved modes. psm.restore(gl); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java new file mode 100644 index 000000000..2d4c6da4d --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelTextureStateAWT.java @@ -0,0 +1,282 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw02ES2ListenerFBO; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; + +import javax.media.opengl.GL; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.JFrame; + +import com.jogamp.opengl.util.texture.TextureIO; +import com.jogamp.opengl.util.texture.TextureState; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.GLReadBufferUtil; + +import java.awt.Dimension; + +import java.io.IOException; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +/** + * Unit test for bug 826, test {@link GLJPanel}'s {@link TextureState} save and restore. + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestGLJPanelTextureStateAWT extends UITestCase { + static boolean showFPS = false; + static long duration = 100; // ms + + @BeforeClass + public static void initClass() { + } + + public void testImpl(final boolean keepTextureBound, final int texUnit) + throws InterruptedException, IOException + { + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + GLProfile glp; + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.getGL2ES2(); + } else { + System.err.println(getSimpleTestName(".")+": GLProfile n/a"); + return; + } + final GLCapabilities caps = new GLCapabilities(glp); + + final GLJPanel glc = new GLJPanel(caps); + Dimension glc_sz = new Dimension(800, 400); + glc.setMinimumSize(glc_sz); + glc.setPreferredSize(glc_sz); + final JFrame frame = new JFrame("TestGLJPanelTextureStateAWT"); + Assert.assertNotNull(frame); + frame.getContentPane().add(glc); + + final TextureDraw02ES2ListenerFBO gle0; + { + final GearsES2 gle0sub = new GearsES2( 0 ); + // gle1sub.setClearBuffers(false); + gle0 = new TextureDraw02ES2ListenerFBO(gle0sub, 1, texUnit ) ; + } + gle0.setKeepTextureBound(keepTextureBound); + gle0.setClearBuffers(false); + + final RedSquareES2 gle1 = new RedSquareES2( 1 ) ; + gle1.setClearBuffers(false); + + glc.addGLEventListener(new GLEventListener() { + int gle0X, gle0Y, gle0W, gle0H; + int gle1X, gle1Y, gle1W, gle1H; + int tX, tY, tW, tH; + int shot = 0; + + void setupTex(GL gl) { + // Note: FBObject uses diff defaults, i.e.: GL_NEAREST and GL_CLAMP_TO_EDGE + if( keepTextureBound ) { + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); + } + } + + @Override + public void init(GLAutoDrawable drawable) { + // Initialize w/ arbitrary values ! + GL2ES2 gl = drawable.getGL().getGL2ES2(); + gl.glActiveTexture(GL.GL_TEXTURE0 + 1); + gl.glBindTexture(GL.GL_TEXTURE_2D, 0); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); + gl.glActiveTexture(GL.GL_TEXTURE0 + 0); + gl.glBindTexture(GL.GL_TEXTURE_2D, 0); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); + gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); + + gle0.init(drawable); + gle1.init(drawable); + setupTex(gl); + } + + @Override + public void dispose(GLAutoDrawable drawable) { + gle0.dispose(drawable); + gle1.dispose(drawable); + } + @Override + public void display(GLAutoDrawable drawable) { + GL2ES2 gl = drawable.getGL().getGL2ES2(); + + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + + // restore viewport test + final int[] viewport = new int[] { 0, 0, 0, 0 }; + gl.glGetIntegerv(GL.GL_VIEWPORT, viewport, 0); + if( gle0X != viewport[0] || gle0Y != viewport[1] || gle0W != viewport[2] || gle0H != viewport[3] ) { + final String msg = "Expected "+viewport[0]+"/"+viewport[1]+" "+viewport[2]+"x"+viewport[3]+ + ", actual "+gle0X+"/"+gle0Y+" "+gle0W+"x"+gle0H; + Assert.assertTrue("Viewport not restored: "+msg, false); + } + + // gl.glViewport(gle0X, gle0Y, gle0W, gle0H); // restore viewport test + gle0.display(drawable); + + gl.glViewport(gle1X, gle1Y, gle1W, gle1H); + gle1.display(drawable); + + shot++; + if( 4 == shot ) { + gl.glViewport(tX, tY, tW, tH); + snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); + } + + gl.glViewport(gle0X, gle0Y, gle0W, gle0H); // restore viewport test + + final TextureState ts = new TextureState(drawable.getGL(), GL.GL_TEXTURE_2D); + // System.err.println("XXX: "+ts); + Assert.assertEquals("Texture unit changed", GL.GL_TEXTURE0+texUnit, ts.getUnit()); + if( keepTextureBound ) { + Assert.assertEquals("Texture mag-filter changed", GL.GL_LINEAR, ts.getMagFilter()); + Assert.assertEquals("Texture mag-filter changed", GL.GL_LINEAR, ts.getMinFilter()); + Assert.assertEquals("Texture wrap-s changed", GL.GL_REPEAT, ts.getWrapS()); + Assert.assertEquals("Texture wrap-t changed", GL.GL_REPEAT, ts.getWrapT()); + } + } + final int border = 5; + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + gle0X = x + border; + gle0Y = y; + gle0W = width/2 - 2*border; + gle0H = height; + + gle1X = gle0X + gle0W + 2*border; + gle1Y = y; + gle1W = width/2 - 2*border; + gle1H = height; + + tX = x; + tY = y; + tW = width; + tH = height; + + GL2ES2 gl = drawable.getGL().getGL2ES2(); + gl.glViewport(gle0X, gle0Y, gle0W, gle0H); + gle0.reshape(drawable, gle0X, gle0Y, gle0W, gle0H); + + gl.glViewport(gle1X, gle1Y, gle1W, gle1H); + gle1.reshape(drawable, gle1X, gle1Y, gle1W, gle1H); + + gl.glViewport(gle0X, gle0Y, gle0W, gle0H); // restore viewport test + + if( keepTextureBound ) { + setupTex(gl); + } + } + }); + + Animator animator = new Animator(glc); + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + QuitAdapter quitAdapter = new QuitAdapter(); + new com.jogamp.newt.event.awt.AWTKeyAdapter(quitAdapter).addTo(glc); + new com.jogamp.newt.event.awt.AWTWindowAdapter(quitAdapter).addTo(glc); + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + animator.start(); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()0) { + fbo0.attachColorbuffer(gl, 0, true); + fbo0.resetSamplingSink(gl); + fbo0Tex = fbo0.getSamplingSink(); + } else { + fbo0Tex = fbo0.attachTexture2D(gl, 0, true); + } + numSamples=fbo0.getNumSamples(); + fbo0.attachRenderbuffer(gl, Type.DEPTH, 24); + fbo0.unbind(gl); + } + + private void resetFBOs(GL gl, int width, int height) { + fbo0.reset(gl, width, height, numSamples, true); + numSamples = fbo0.getNumSamples(); + if(numSamples>0) { + fbo0Tex = fbo0.getSamplingSink(); + } else { + fbo0Tex = (TextureAttachment) fbo0.getColorbuffer(0); + } + } + + @Override + public void dispose(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + demo.dispose(drawable); + fbo0.destroy(gl); + st.destroy(gl); + + fbo0Tex = null; + sp0 = null; + pmvMatrixUniform = null; + interleavedVBO = null; + } + + @Override + public void display(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + + if( fbo0.getNumSamples() != numSamples ) { + System.err.println("**** NumSamples: "+fbo0.getNumSamples()+" -> "+numSamples); + resetFBOs(gl, drawable.getWidth(), drawable.getHeight()); + } + + if(0 < numSamples) { + gl.glEnable(GL.GL_MULTISAMPLE); + } + + fbo0.bind(gl); + demo.display(drawable); + fbo0.unbind(gl); + + st.useProgram(gl, true); + if( clearBuffers ) { + gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); + } + + if( !keepTextureBound ) { + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue()); + fbo0.use(gl, fbo0Tex); + if( !gl.isGLcore() ) { + gl.glEnable(GL.GL_TEXTURE_2D); + } + } + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue()); + interleavedVBO.enableBuffer(gl, true); + + gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, 4); + + interleavedVBO.enableBuffer(gl, false); + + if( !keepTextureBound ) { + fbo0.unuse(gl); + } + + st.useProgram(gl, false); + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + + if(-1 != swapInterval) { + gl.setSwapInterval(swapInterval); // in case switching the drawable (impl. may bound attribute there) + } + + if( !fbo0.isInitialized() ) { + System.err.println("**** Reshape.Init: "+width+"x"+height); + initFBOs(gl, width, height); + } else { + System.err.println("**** Reshape.Reset: "+width+"x"+height); + if( keepTextureBound ) { + fbo0.unuse(gl); + } + resetFBOs(gl, width, height); + } + + fbo0.bind(gl); + demo.reshape(drawable, x, y, width, height); + fbo0.unbind(gl); + + if( keepTextureBound ) { + gl.glActiveTexture(GL.GL_TEXTURE0 + texUnit0.intValue()); + fbo0.use(gl, fbo0Tex); + if( !gl.isGLcore() ) { + gl.glEnable(GL.GL_TEXTURE_2D); + } + } + + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); + pmvMatrix.glLoadIdentity(); + pmvMatrix.glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 10.0f); + + pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); + pmvMatrix.glLoadIdentity(); + + st.useProgram(gl, true); + st.uniform(gl, pmvMatrixUniform); + st.useProgram(gl, false); + + } + + private static final float[] s_quadVertices = { + -1f, -1f, 0f, // LB + 1f, -1f, 0f, // RB + -1f, 1f, 0f, // LT + 1f, 1f, 0f // RT + }; + private static final float[] s_quadColors = { + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f, + 1f, 1f, 1f, 1f }; + private static final float[] s_quadTexCoords = { + 0f, 0f, // LB + 1f, 0f, // RB + 0f, 1f, // LT + 1f, 1f // RT + }; +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java index af30c265b..fb8e6bfa3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/TextureDraw01GL2Listener.java @@ -43,21 +43,35 @@ public class TextureDraw01GL2Listener implements GLEventListener, TextureDraw01A private GLU glu = new GLU(); private TextureData textureData; private Texture texture; + boolean keepTextureBound; public TextureDraw01GL2Listener(TextureData td) { this.textureData = td; + this.keepTextureBound = false; } + @Override + public void setKeepTextureBound(boolean v) { + this.keepTextureBound = v; + } + @Override + public Texture getTexture( ) { + return this.texture; + } + + @Override public void init(GLAutoDrawable drawable) { + GL2 gl = drawable.getGL().getGL2(); if(null!=textureData) { this.texture = TextureIO.newTexture(drawable.getGL(), textureData); + if( keepTextureBound ) { + texture.enable(gl); + texture.bind(gl); + } } } - public Texture getTexture( ) { - return this.texture; - } - + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2 gl = drawable.getGL().getGL2(); gl.glMatrixMode(GL2ES1.GL_PROJECTION); @@ -67,6 +81,7 @@ public class TextureDraw01GL2Listener implements GLEventListener, TextureDraw01A gl.glLoadIdentity(); } + @Override public void dispose(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); if(null!=texture) { @@ -78,13 +93,16 @@ public class TextureDraw01GL2Listener implements GLEventListener, TextureDraw01A } } + @Override public void display(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); // draw one quad with the texture if(null!=texture) { - texture.enable(gl); - texture.bind(gl); + if( !keepTextureBound ) { + texture.enable(gl); + texture.bind(gl); + } gl.glTexEnvi(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); TextureCoords coords = texture.getImageTexCoords(); gl.glBegin(GL2.GL_QUADS); @@ -97,7 +115,9 @@ public class TextureDraw01GL2Listener implements GLEventListener, TextureDraw01A gl.glTexCoord2f(coords.left(), coords.top()); gl.glVertex3f(0, 1, 0); gl.glEnd(); - texture.disable(gl); + if( !keepTextureBound ) { + texture.disable(gl); + } } } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java index 75a98ed1e..3e58d3c79 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/DemoGL2ES1TextureImmModeSink.java @@ -58,9 +58,11 @@ public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDra private GLU glu = new GLU(); private TextureData textureData; private Texture texture; + boolean keepTextureBound; public DemoGL2ES1TextureImmModeSink() { this.ims = ImmModeSink.createFixed(32, 3, GL.GL_FLOAT, 4, GL.GL_FLOAT, 0, GL.GL_FLOAT, 2, GL.GL_FLOAT, GL.GL_STATIC_DRAW); + this.keepTextureBound = false; } public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) { @@ -70,6 +72,17 @@ public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDra this.traceFFPEmu = traceFFPEmu; } + + @Override + public void setKeepTextureBound(boolean v) { + this.keepTextureBound = v; + } + @Override + public Texture getTexture( ) { + return this.texture; + } + + @Override public void init(GLAutoDrawable drawable) { GL _gl = drawable.getGL(); if(debugFFPEmu) { @@ -87,15 +100,16 @@ public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDra InputStream testTextureStream = testTextureUrlConn.getInputStream(); textureData = TextureIO.newTextureData(gl.getGLProfile(), testTextureStream , false /* mipmap */, TextureIO.PNG); texture = TextureIO.newTexture(gl, textureData); + if( keepTextureBound && null != texture ) { + texture.enable(gl); + texture.bind(gl); + } } catch (Exception e) { e.printStackTrace(); } } - public Texture getTexture( ) { - return this.texture; - } - + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL2ES1 gl = drawable.getGL().getGL2ES1(); gl.glMatrixMode(GL2ES1.GL_PROJECTION); @@ -105,6 +119,7 @@ public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDra gl.glLoadIdentity(); } + @Override public void dispose(GLAutoDrawable drawable) { GL2ES1 gl = drawable.getGL().getGL2ES1(); if(null!=texture) { @@ -116,13 +131,16 @@ public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDra } } + @Override public void display(GLAutoDrawable drawable) { GL2ES1 gl = drawable.getGL().getGL2ES1(); // draw one quad with the texture if(null!=texture) { - texture.enable(gl); - texture.bind(gl); + if( !keepTextureBound ) { + texture.enable(gl); + texture.bind(gl); + } // gl.glTexEnvi(GL.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, GL2.GL_REPLACE); TextureCoords coords = texture.getImageTexCoords(); ims.glBegin(ImmModeSink.GL_QUADS); @@ -135,7 +153,9 @@ public class DemoGL2ES1TextureImmModeSink implements GLEventListener, TextureDra ims.glTexCoord2f(coords.left(), coords.top()); ims.glVertex3f(0, 1, 0); ims.glEnd(gl); - texture.disable(gl); + if( !keepTextureBound ) { + texture.disable(gl); + } } } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java index 8289cc381..c92174a77 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGImage01NEWT.java @@ -108,7 +108,7 @@ public class TestJPEGImage01NEWT extends UITestCase { // load texture from file inside current GL context to match the way // the bug submitter was doing it - final GLEventListener gle = new TextureDraw01ES2Listener( texData ) ; + final GLEventListener gle = new TextureDraw01ES2Listener( texData, 0 ) ; glad.addGLEventListener(gle); glad.addGLEventListener(new GLEventListener() { boolean shot = false; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTCompareNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTCompareNewtAWT.java index 653923bc4..dbb4002a3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTCompareNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGJoglAWTCompareNewtAWT.java @@ -137,7 +137,7 @@ public class TestJPEGJoglAWTCompareNewtAWT extends UITestCase { // load texture from file inside current GL context to match the way // the bug submitter was doing it - final GLEventListener gle = new TextureDraw01ES2Listener( texData ) ; + final GLEventListener gle = new TextureDraw01ES2Listener( texData, 0 ) ; glad1.addGLEventListener(gle); glad1.addGLEventListener(new GLEventListener() { boolean shot = false; @@ -193,7 +193,7 @@ public class TestJPEGJoglAWTCompareNewtAWT extends UITestCase { // the bug submitter was doing it final GLEventListener gle; if( texData != null ) { - gle = new TextureDraw01ES2Listener( texData ) ; + gle = new TextureDraw01ES2Listener( texData, 0 ) ; glad1.addGLEventListener(gle); } else { gle = null; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java index 13686cc22..60855e5be 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestJPEGTextureFromFileNEWT.java @@ -184,7 +184,7 @@ public class TestJPEGTextureFromFileNEWT extends UITestCase { // load texture from file inside current GL context to match the way // the bug submitter was doing it - final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ; + final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData, 0 ) ; glad.addGLEventListener(gle); glad.addGLEventListener(new GLEventListener() { boolean shot = false; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java index 91ace8420..29e041908 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java @@ -109,7 +109,7 @@ public class TestPNGImage01NEWT extends UITestCase { // load texture from file inside current GL context to match the way // the bug submitter was doing it - final TextureDraw01ES2Listener gle = new TextureDraw01ES2Listener( texData ) ; + final TextureDraw01ES2Listener gle = new TextureDraw01ES2Listener( texData, 0 ) ; // gle.setClearColor(new float[] { 1.0f, 0.0f, 0.0f, 1.0f } ); glad.addGLEventListener(gle); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java index 6a15300a7..191d67d31 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileAWT.java @@ -133,7 +133,7 @@ public class TestPNGTextureFromFileAWT extends UITestCase { // load texture from file inside current GL context to match the way // the bug submitter was doing it - final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ; + final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData, 0 ) ; glc.addGLEventListener(gle); glc.addGLEventListener(new GLEventListener() { boolean shot = false; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java index 1bc526429..ce363b612 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGTextureFromFileNEWT.java @@ -174,7 +174,7 @@ public class TestPNGTextureFromFileNEWT extends UITestCase { // load texture from file inside current GL context to match the way // the bug submitter was doing it - final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ; + final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData, 0 ) ; glad.addGLEventListener(gle); glad.addGLEventListener(new GLEventListener() { boolean shot = false; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTGATextureFromFileNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTGATextureFromFileNEWT.java index 3e1acdb39..859e4e4b5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTGATextureFromFileNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestTGATextureFromFileNEWT.java @@ -105,7 +105,7 @@ public class TestTGATextureFromFileNEWT extends UITestCase { // load texture from file inside current GL context to match the way // the bug submitter was doing it - final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData ) ; + final GLEventListener gle = useFFP ? new TextureDraw01GL2Listener( texData ) : new TextureDraw01ES2Listener( texData, 0 ) ; glad.addGLEventListener(gle); glad.addGLEventListener(new GLEventListener() { boolean shot = false; -- cgit v1.2.3 From 939d6304d464e69b1d1d2a104c3da5536d3bf326 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Sep 2013 12:29:49 +0200 Subject: AWT Printing: Fix non vertical-flipped printing, i.e. cut-off top-row's tile upper area, cleanup. TestTiledPrintingGearsSwingAWT2: Provoked !flipped bug where top-row was positioned too low due to using full size tile-height. Cutting of the unused top-row's upper area corrects this issue. vertical-flip mode does not expose this situation, since flipping shifts the payload to the upper tile area. TestTiledPrintingGearsSwingAWT2: Also tests an alternative transparent overlapping mode without layout. --- make/scripts/tests-win.bat | 3 +- make/scripts/tests-x64-dbg.bat | 1 + make/scripts/tests.sh | 4 +- .../classes/jogamp/opengl/awt/AWTTilePainter.java | 39 +-- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 11 +- .../jogl/tile/TestTiledPrintingGearsSwingAWT2.java | 340 +++++++++++++++++++++ .../test/junit/jogl/tile/TransparentPanel.java | 59 ++++ 7 files changed, 432 insertions(+), 25 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/tile/TransparentPanel.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 6759994a2..b3029f94c 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -57,7 +57,8 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRenderi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index c9b98ffb8..3447605c7 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -47,6 +47,7 @@ REM set D_ARGS="-Djogl.debug=all" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" +REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b94e23dc1..7c2d90075 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -332,7 +332,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -474,7 +474,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 0b24fadae..0aab049a0 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -196,6 +196,7 @@ public class AWTTilePainter { final Rectangle2D dImageSizeOrig = new Rectangle2D.Double(0, 0, width, height); // Retrieve scaled image-size and clip-bounds + // Note: Clip bounds lie within image-size! final Rectangle2D dImageSizeScaled, dClipScaled; { final AffineTransform scaledATI; @@ -212,13 +213,15 @@ public class AWTTilePainter { s0 = saveAT.createTransformedShape(dClipOrig); // user in dClipScaled = scaledATI.createTransformedShape(s0).getBounds2D(); // scaled out } - } + } final Rectangle iClipScaled = getRoundedRect(dClipScaled); final Rectangle iImageSizeScaled = getRoundedRect(dImageSizeScaled); - scaledYOffset = iClipScaled.y; renderer.setImageSize(iImageSizeScaled.width, iImageSizeScaled.height); renderer.clipImageSize(iClipScaled.width, iClipScaled.height); final int clipH = Math.min(iImageSizeScaled.height, iClipScaled.height); + // Clip bounds lie within image-size! + // GL y-offset is lower-left origin, AWT y-offset upper-left. + scaledYOffset = iClipScaled.y; renderer.setTileOffset(iClipScaled.x, iImageSizeScaled.height - ( iClipScaled.y + clipH )); // Scale actual Grahics2D matrix @@ -294,10 +297,11 @@ public class AWTTilePainter { final DimensionImmutable cis = renderer.getClippedImageSize(); final int tWidth = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH); final int tHeight = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); - final int pX = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); - final int pY = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); - final int pYOff = renderer.getParam(TileRenderer.TR_TILE_Y_OFFSET); - final int pYf = cis.getHeight() - ( pY - pYOff + tHeight ) + scaledYOffset; + final int tY = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); + final int tYOff = renderer.getParam(TileRenderer.TR_TILE_Y_OFFSET); + final int imgYOff = flipVertical ? 0 : renderer.getParam(TileRenderer.TR_TILE_HEIGHT) - tHeight; // imgYOff will be cut-off via sub-image + final int pX = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); // tileX == pX + final int pY = cis.getHeight() - ( tY - tYOff + tHeight ) + scaledYOffset; // Copy temporary data into raster of BufferedImage for faster // blitting Note that we could avoid this copy in the cases @@ -309,7 +313,7 @@ public class AWTTilePainter { _counter, renderer.getParam(TileRenderer.TR_CURRENT_COLUMN), renderer.getParam(TileRenderer.TR_CURRENT_ROW), tWidth, tHeight, - pX, pY, pYOff, pX, pYf).replace(' ', '_'); + pX, tY, tYOff, pX, pY).replace(' ', '_'); System.err.println("XXX file "+fname); final File fout = new File(fname); try { @@ -340,7 +344,7 @@ public class AWTTilePainter { _counter, renderer.getParam(TileRenderer.TR_CURRENT_COLUMN), renderer.getParam(TileRenderer.TR_CURRENT_ROW), tWidth, tHeight, - pX, pY, pYOff, pX, pYf).replace(' ', '_'); + pX, tY, tYOff, pX, pY).replace(' ', '_'); System.err.println("XXX file "+fname); final File fout = new File(fname); try { @@ -351,17 +355,15 @@ public class AWTTilePainter { _counter++; } // Draw resulting image in one shot - final Shape oClip = g2d.getClip(); - // g2d.clipRect(pX, pYf, tWidth, tHeight); - final BufferedImage outImage = dstImage.getSubimage(0, 0, tWidth, tHeight); // instead of clipping - final boolean drawDone = g2d.drawImage(outImage, pX, pYf, null); // Null ImageObserver since image data is ready. - // final boolean drawDone = g2d.drawImage(dstImage, pX, pYf, dstImage.getWidth(), dstImage.getHeight(), null); // Null ImageObserver since image data is ready. + final BufferedImage outImage = dstImage.getSubimage(0, imgYOff, tWidth, tHeight); + final boolean drawDone = g2d.drawImage(outImage, pX, pY, null); // Null ImageObserver since image data is ready. if( verbose ) { - System.err.println("XXX tile-post.X clippedImageSize "+cis); - System.err.println("XXX tile-post.X pYf "+cis.getHeight()+" - ( "+pY+" - "+pYOff+" + "+tHeight+" ) "+scaledYOffset+" = "+ pYf); - System.err.println("XXX tile-post.X clip "+oClip+" + "+pX+" / [pY "+pY+", pYOff "+pYOff+", pYf "+pYf+"] "+tWidth+"x"+tHeight+" -> "+g2d.getClip()); + final Shape oClip = g2d.getClip(); + System.err.println("XXX tile-post.X tile 0 / "+imgYOff+" "+tWidth+"x"+tHeight+", clippedImgSize "+cis); + System.err.println("XXX tile-post.X pYf "+cis.getHeight()+" - ( "+tY+" - "+tYOff+" + "+tHeight+" ) "+scaledYOffset+" = "+ pY); + System.err.println("XXX tile-post.X clip "+oClip+" + "+pX+" / [pY "+tY+", pYOff "+tYOff+", pYf "+pY+"] -> "+g2d.getClip()); g2d.setColor(Color.BLACK); - g2d.drawRect(pX, pYf, tWidth, tHeight); + g2d.drawRect(pX, pY, tWidth, tHeight); if( null != oClip ) { final Rectangle r = oClip.getBounds(); g2d.setColor(Color.YELLOW); @@ -370,9 +372,8 @@ public class AWTTilePainter { System.err.println("XXX tile-post.X "+renderer); System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()); System.err.println("XXX tile-post.X out-img "+outImage.getWidth()+"x"+outImage.getHeight()); - System.err.println("XXX tile-post.X y-flip "+flipVertical+" -> "+pX+"/"+pYf+", drawDone "+drawDone); + System.err.println("XXX tile-post.X y-flip "+flipVertical+" -> "+pX+"/"+pY+", drawDone "+drawDone); } - // g2d.setClip(oClip); } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index 476513207..b4f5ad988 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -68,6 +68,7 @@ import com.jogamp.newt.event.awt.AWTWindowAdapter; import com.jogamp.opengl.test.junit.jogl.demos.es1.RedSquareES1; import com.jogamp.opengl.test.junit.jogl.demos.gl2.Gears; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; @@ -306,9 +307,13 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { for(int i=0; i awtUtilitiesClass = + Class.forName("com.sun.awt.AWTUtilities"); + mSetComponentMixing = + awtUtilitiesClass.getMethod( + "setComponentMixingCutoutShape", + Component.class, Shape.class); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + // Cut out the shape + if (mSetComponentMixing != null) { + try { + mSetComponentMixing.invoke( null, this, s ); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } +} -- cgit v1.2.3 From 4ef07dc20a3d867feb1c51b4ce22ae3d06094781 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 21 Sep 2013 05:19:32 +0200 Subject: Fix Bug 839: Clarify whether resetStates(..) shall clearStates() - Pass 'isInit' flag. --- make/scripts/tests.sh | 6 ++-- src/jogl/classes/javax/media/opengl/GLContext.java | 9 +++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 39 +++++++++++----------- src/jogl/classes/jogamp/opengl/GLStateTracker.java | 1 + src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 4 +-- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 4 +-- .../opengl/windows/wgl/WindowsWGLContext.java | 4 +-- .../jogamp/opengl/x11/glx/X11GLXContext.java | 4 +-- 8 files changed, 37 insertions(+), 34 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7c2d90075..4702e98ef 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -217,7 +217,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" - D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" #D_ARGS="-Djogl.debug.PNGImage" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" @@ -303,7 +303,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* @@ -332,7 +332,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 854d96807..2dca2a685 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -208,7 +208,7 @@ public abstract class GLContext { protected long contextHandle; protected GLContext() { - resetStates(); + resetStates(true); } protected VersionNumber ctxVersion; @@ -222,9 +222,12 @@ public abstract class GLContext { /** Did the drawable association changed ? see {@link GLRendererQuirks#NoSetSwapIntervalPostRetarget} */ protected boolean drawableRetargeted; - protected void resetStates() { + /** + * @param isInit true if called for class initialization, otherwise false (re-init or destruction). + */ + protected void resetStates(boolean isInit) { if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.resetStates()"); + System.err.println(getThreadName() + ": GLContext.resetStates(isInit "+isInit+")"); // Thread.dumpStack(); } ctxVersion = VersionNumberString.zeroVersion; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index ff90966cd..77cbd0ed9 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -157,19 +157,16 @@ public abstract class GLContextImpl extends GLContext { if (bufferSizeTracker != null) { bufferSizeTracker.clearCachedBufferSizes(); } - if (bufferStateTracker != null) { // - bufferStateTracker.clearBufferObjectState(); - } - if (glStateTracker != null) { // - glStateTracker.setEnabled(false); - glStateTracker.clearStates(); - } + bufferStateTracker.clearBufferObjectState(); + glStateTracker.setEnabled(false); + glStateTracker.clearStates(); } @Override - protected void resetStates() { - clearStates(); - + protected void resetStates(boolean isInit) { + if( !isInit ) { + clearStates(); + } extensionAvailability = null; glProcAddressTable = null; gl = null; @@ -188,7 +185,7 @@ public abstract class GLContextImpl extends GLContext { pixelDataEvaluated = false; - super.resetStates(); + super.resetStates(isInit); } @Override @@ -435,6 +432,7 @@ public abstract class GLContextImpl extends GLContext { if(GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this)) { GLContextShareSet.unregisterSharing(this); } + resetStates(false); } finally { lock.unlock(); if ( DEBUG_TRACE_SWITCH ) { @@ -448,8 +446,9 @@ public abstract class GLContextImpl extends GLContext { if( null != associateDrawableException ) { throw new GLException("Exception @ destroy's associateDrawable(false)", associateDrawableException); } + } else { + resetStates(false); } - resetStates(); } protected abstract void destroyImpl() throws GLException; @@ -629,7 +628,7 @@ public abstract class GLContextImpl extends GLContext { */ } if( TRACE_SWITCH ) { - System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X3]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - "+makeCurrentResultToString(res)+" - "+lock); + System.err.println(getThreadName() +": GLContext.ContextSwitch[makeCurrent.X3]: obj " + toHexString(hashCode()) + ", ctx "+toHexString(contextHandle)+", surf "+toHexString(drawable.getHandle())+" - switch - "+makeCurrentResultToString(res)+" - stateTracker.on "+glStateTracker.isEnabled()+" - "+lock); } return res; } @@ -868,14 +867,14 @@ public abstract class GLContextImpl extends GLContext { if(PROFILE_ALIASING) { hasGL3 = true; } - resetStates(); // clean context states, since creation was temporary + resetStates(false); // clean context states, since creation was temporary } } if(!hasGL3) { hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 success |= hasGL3; if(hasGL3) { - resetStates(); // clean this context states, since creation was temporary + resetStates(false); // clean this context states, since creation was temporary } } if(!hasGL4bc) { @@ -897,7 +896,7 @@ public abstract class GLContextImpl extends GLContext { hasGL4 = true; hasGL3 = true; } - resetStates(); // clean this context states, since creation was temporary + resetStates(false); // clean this context states, since creation was temporary } } if(!hasGL3bc) { @@ -913,21 +912,21 @@ public abstract class GLContextImpl extends GLContext { hasGL2 = true; hasGL3 = true; } - resetStates(); // clean this context states, since creation was temporary + resetStates(false); // clean this context states, since creation was temporary } } if(!hasGL2) { hasGL2 = createContextARBMapVersionsAvailable(2, CTX_PROFILE_COMPAT); // GL2 success |= hasGL2; if(hasGL2) { - resetStates(); // clean this context states, since creation was temporary + resetStates(false); // clean this context states, since creation was temporary } } if(!hasES3) { hasES3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_ES); // ES3 success |= hasES3; if(hasES3) { - resetStates(); // clean this context states, since creation was temporary + resetStates(false); // clean this context states, since creation was temporary } } if(success) { @@ -946,7 +945,7 @@ public abstract class GLContextImpl extends GLContext { } /** - * Note: Since context creation is temporary, caller need to issue {@link #resetStates()}, if creation was successful, i.e. returns true. + * Note: Since context creation is temporary, caller need to issue {@link #resetStates(boolean)}, if creation was successful, i.e. returns true. * This method does not reset the states, allowing the caller to utilize the state variables. **/ private final boolean createContextARBMapVersionsAvailable(int reqMajor, int reqProfile) { diff --git a/src/jogl/classes/jogamp/opengl/GLStateTracker.java b/src/jogl/classes/jogamp/opengl/GLStateTracker.java index 69411979f..01c3716e0 100644 --- a/src/jogl/classes/jogamp/opengl/GLStateTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLStateTracker.java @@ -42,6 +42,7 @@ package jogamp.opengl; import javax.media.opengl.*; import com.jogamp.common.util.IntIntHashMap; + import java.nio.IntBuffer; import java.util.ArrayList; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index e7977e3fb..179cb7504 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -70,12 +70,12 @@ public class EGLContext extends GLContextImpl { } @Override - protected void resetStates() { + protected void resetStates(boolean isInit) { eglQueryStringInitialized = false; eglQueryStringAvailable = false; eglExtProcAddressTable = null; // no inner state _eglExt = null; - super.resetStates(); + super.resetStates(isInit); } @Override diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 6787ef500..e6334150b 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -193,10 +193,10 @@ public class MacOSXCGLContext extends GLContextImpl } @Override - protected void resetStates() { + protected void resetStates(boolean isInit) { // no inner state _cglExt = null; cglExtProcAddressTable = null; - super.resetStates(); + super.resetStates(isInit); } @Override diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index b8979c91e..3fad22d88 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -93,7 +93,7 @@ public class WindowsWGLContext extends GLContextImpl { } @Override - protected void resetStates() { + protected void resetStates(boolean isInit) { wglGetExtensionsStringEXTInitialized=false; wglGetExtensionsStringEXTAvailable=false; wglGLReadDrawableAvailableSet=false; @@ -102,7 +102,7 @@ public class WindowsWGLContext extends GLContextImpl { wglExtProcAddressTable=null; hasSwapIntervalSGI = 0; hasSwapGroupNV = 0; - super.resetStates(); + super.resetStates(isInit); } @Override diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 4bfe0cb86..0ecf11a43 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -100,7 +100,7 @@ public class X11GLXContext extends GLContextImpl { } @Override - protected void resetStates() { + protected void resetStates(boolean isInit) { // no inner state _glXExt=null; glXExtProcAddressTable = null; hasSwapInterval = 0; @@ -108,7 +108,7 @@ public class X11GLXContext extends GLContextImpl { isDirect = false; glXServerVersion = null; isGLXVersionGreaterEqualOneThree = false; - super.resetStates(); + super.resetStates(isInit); } @Override -- cgit v1.2.3 From 51ae910b9ad4f3691c2b91a912b94701d0ef98ac Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 24 Sep 2013 11:04:24 +0200 Subject: Bug 816: Add unit test 'TestBug816OSXCALayerPosAWT' --- make/scripts/tests-osx-x64.sh | 1 + make/scripts/tests.sh | 4 +- .../junit/jogl/awt/TestBug816OSXCALayerPosAWT.java | 363 +++++++++++++++++++++ 3 files changed, 367 insertions(+), 1 deletion(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh index e1b07202b..7585e68ad 100755 --- a/make/scripts/tests-osx-x64.sh +++ b/make/scripts/tests-osx-x64.sh @@ -3,6 +3,7 @@ export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH JAVA_HOME=`/usr/libexec/java_home -version 1.7` +#JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_25` PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4702e98ef..8c58efb3f 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -202,6 +202,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Dnativewindow.debug.NativeWindow" + #D_ARGS="-Dnativewindow.osx.calayer.bugfree" #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" @@ -303,7 +304,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* @@ -453,6 +454,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java new file mode 100644 index 000000000..f929b4d14 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java @@ -0,0 +1,363 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import javax.media.opengl.*; + +import com.jogamp.opengl.util.Animator; + +import javax.media.opengl.awt.GLCanvas; +import javax.swing.BoxLayout; +import javax.swing.JFrame; + +import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.QuitAdapter; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.GridLayout; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.lang.reflect.InvocationTargetException; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPosAWT extends UITestCase { + public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box }; + + static long duration = 500; // ms + static int width, height; + + static boolean forceES2 = false; + static boolean forceGL3 = false; + static int swapInterval = 1; + static Thread awtEDT; + static java.awt.Dimension rwsize; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + rwsize = new Dimension(800, 600); + try { + EventQueue.invokeAndWait(new Runnable() { + public void run() { + awtEDT = Thread.currentThread(); + } } ); + } catch (Exception e) { + e.printStackTrace(); + Assert.assertNull(e); + } + } + + @AfterClass + public static void releaseClass() { + } + + static void setComponentSize(final Frame frame, final Component comp1, final java.awt.Dimension new_sz1, final Component comp2, final java.awt.Dimension new_sz2) { + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + comp1.setMinimumSize(new_sz1); + comp1.setPreferredSize(new_sz1); + comp1.setSize(new_sz1); + if( null != comp2 ) { + comp2.setMinimumSize(new_sz2); + comp2.setPreferredSize(new_sz2); + comp2.setSize(new_sz2); + } + if( null != frame ) { + frame.pack(); + } + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout, final boolean twoCanvas) throws InterruptedException, InvocationTargetException { + final JFrame frame = new JFrame("Bug861 AWT Test"); + Assert.assertNotNull(frame); + final Container framePane = frame.getContentPane(); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + final GLCanvas glCanvas2; + if( twoCanvas ) { + glCanvas2 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas2); + } else { + glCanvas2 = null; + } + + final Dimension glcDim = new Dimension(width/2, height); + + setComponentSize(null, glCanvas1, glcDim, glCanvas2, glcDim); + + switch( frameLayout) { + case None: { + framePane.add(glCanvas1); + } + break; + case Flow: { + final Container c = new Container(); + c.setLayout(new FlowLayout()); + c.add(glCanvas1); + if( twoCanvas ) { + c.add(glCanvas2); + } + framePane.add(c); + } + break; + case DoubleBorderCenterSurrounded: { + final Container c = new Container(); + c.setLayout(new BorderLayout()); + c.add(new Button("north"), BorderLayout.NORTH); + c.add(new Button("south"), BorderLayout.SOUTH); + c.add(new Button("east"), BorderLayout.EAST); + c.add(new Button("west"), BorderLayout.WEST); + if( twoCanvas ) { + final Container c2 = new Container(); + c2.setLayout(new GridLayout(1, 2)); + c2.add(glCanvas1); + c2.add(glCanvas2); + c.add(c2, BorderLayout.CENTER); + } else { + c.add(glCanvas1, BorderLayout.CENTER); + } + framePane.setLayout(new BorderLayout()); + framePane.add(new Button("NORTH"), BorderLayout.NORTH); + framePane.add(new Button("SOUTH"), BorderLayout.SOUTH); + framePane.add(new Button("EAST"), BorderLayout.EAST); + framePane.add(new Button("WEST"), BorderLayout.WEST); + framePane.add(c, BorderLayout.CENTER); + } + break; + case Box: { + final Container c = new Container(); + c.setLayout(new BoxLayout(c, BoxLayout.X_AXIS)); + c.add(glCanvas1); + if( twoCanvas ) { + c.add(glCanvas2); + } + framePane.add(c); + } + break; + } + final GearsES2 demo1 = new GearsES2(swapInterval); + glCanvas1.addGLEventListener(demo1); + if( twoCanvas ) { + final RedSquareES2 demo2 = new RedSquareES2(swapInterval); + glCanvas2.addGLEventListener(demo2); + } + + final Animator animator = new Animator(); + animator.add(glCanvas1); + if( twoCanvas ) { + animator.add(glCanvas2); + } + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + if( twoCanvas ) { + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas2, true)); + } + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + System.err.println("canvas1 pos/siz: "+glCanvas1.getX()+"/"+glCanvas1.getY()+" "+glCanvas1.getWidth()+"x"+glCanvas1.getHeight()); + if( twoCanvas ) { + System.err.println("canvas2 pos/siz: "+glCanvas2.getX()+"/"+glCanvas2.getY()+" "+glCanvas2.getWidth()+"x"+glCanvas2.getHeight()); + } + + Thread.sleep(Math.max(1000, duration/2)); + final Dimension rwsizeHalf = new Dimension(rwsize.width/2, rwsize.height); + setComponentSize(frame, glCanvas1, rwsizeHalf, glCanvas2, rwsizeHalf); + System.err.println("resize canvas1 pos/siz: "+glCanvas1.getX()+"/"+glCanvas1.getY()+" "+glCanvas1.getWidth()+"x"+glCanvas1.getHeight()); + if( twoCanvas ) { + System.err.println("resize canvas2 pos/siz: "+glCanvas2.getX()+"/"+glCanvas2.getY()+" "+glCanvas2.getWidth()+"x"+glCanvas2.getHeight()); + } + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + if( twoCanvas ) { + Assert.assertNotNull(glCanvas2); + } else { + Assert.assertNull(glCanvas2); + } + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas1); + if( twoCanvas ) { + frame.remove(glCanvas2); + } + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + @Test + public void test00_None_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 0 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.None, false); + } + + @Test + public void test01_Flow_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 1 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Flow, false); + } + + @Test + public void test02_DblBrd_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 2 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, false); + } + + @Test + public void test03_Box_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 3 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Box, false); + } + + @Test + public void test04_Flow_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 4 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Flow, true); + } + + @Test + public void test05_DblBrd_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 5 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true); + } + + @Test + public void test06_Box_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 6 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Box, true); + } + + static int testNum = -1; + + public static void main(String args[]) { + boolean waitForKey = false; + + for(int i=0; i Date: Fri, 27 Sep 2013 01:53:18 +0200 Subject: DirectDataBufferInt: createBufferedImage(..) use BufferedImage type value instead of component-count, support all int types ; Add type 'BufferedImageInt' preserving the custom image-type, add note about TYPE_CUSTOM - createBufferedImage(..) use BufferedImage type value instead of component-count, support all int types - Support all integer data image-type, hence we need to pass image-type instead of component count (collision). - Also pass 'properties' to allow configuring all BufferedImage parameters (just in case) - Return BufferedImageInt to allow user to query the used image-type, see below. - Add type 'BufferedImageInt' preserving the custom image-type, add note about TYPE_CUSTOM - Simply extends BufferedImage w/ custom image-type, since BufferedImage's type is TYPE_CUSTOM due to our custom storage type (see API doc comment). Unit tests: - Testing all integer image-type's in - TestTiledPrintingGearsSwingAWT - TestTiledPrintingNIOImageSwingAWT - Disable all AA print-hints, all AWT text visible on X11. Probably has a regression on Windows / OSX .. TBD. --- make/scripts/tests.sh | 4 +- .../nativewindow/awt/DirectDataBufferInt.java | 107 ++++++++++++++++----- .../test/junit/jogl/tile/OffscreenPrintable.java | 15 +-- .../test/junit/jogl/tile/OnscreenPrintable.java | 4 +- .../junit/jogl/tile/TestTiledPrintingGearsAWT.java | 11 ++- .../jogl/tile/TestTiledPrintingGearsNewtAWT.java | 11 ++- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 30 ++++-- .../jogl/tile/TestTiledPrintingGearsSwingAWT2.java | 2 +- .../tile/TestTiledPrintingNIOImageSwingAWT.java | 41 +++++--- .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 28 +++--- 10 files changed, 176 insertions(+), 77 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8c58efb3f..442b12672 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -332,7 +332,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -454,7 +454,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java index d9c3c3791..1d66d67e7 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java @@ -28,6 +28,7 @@ package com.jogamp.nativewindow.awt; import java.awt.Point; +import java.awt.color.ColorSpace; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.DataBuffer; @@ -36,6 +37,7 @@ import java.awt.image.SampleModel; import java.awt.image.SinglePixelPackedSampleModel; import java.awt.image.WritableRaster; import java.nio.IntBuffer; +import java.util.Hashtable; import com.jogamp.common.nio.Buffers; @@ -50,40 +52,97 @@ public final class DirectDataBufferInt extends DataBuffer { } } + public static class BufferedImageInt extends BufferedImage { + final int customImageType; + public BufferedImageInt (int customImageType, ColorModel cm, WritableRaster raster, Hashtable properties) { + super(cm, raster, false /* isRasterPremultiplied */, properties); + this.customImageType = customImageType; + } + + /** + * @return one of the custom image-type values {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, + * {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, + * {@link BufferedImage#TYPE_INT_RGB TYPE_INT_RGB} or {@link BufferedImage#TYPE_INT_BGR TYPE_INT_BGR}. + */ + public int getCustomType() { + return customImageType; + } + + @Override + public String toString() { + return new String("BufferedImageInt@"+Integer.toHexString(hashCode()) + +": custum/internal type = "+customImageType+"/"+getType() + +" "+getColorModel()+" "+getRaster()); + } + } + /** - * Creates a {@link BufferedImage} using an RGB[A] {@link DirectColorModel} - * with an {@link DirectWritableRaster} utilizing a {@link DirectDataBufferInt} as storage. + * Creates a {@link BufferedImageInt} using a {@link DirectColorModel direct color model} in {@link ColorSpace#CS_sRGB sRGB color space}.
        + * It uses a {@link DirectWritableRaster} utilizing {@link DirectDataBufferInt} storage. + *

        + * Note that due to using the custom storage type {@link DirectDataBufferInt}, the resulting + * {@link BufferedImage}'s {@link BufferedImage#getType() image-type} is of {@link BufferedImage#TYPE_CUSTOM TYPE_CUSTOM}. + * We are not able to change this detail, since the AWT image implementation associates the {@link BufferedImage#getType() image-type} + * with a build-in storage-type. + * Use {@link BufferedImageInt#getCustomType()} to retrieve the custom image-type, which will return the imageType + * value passed here. + *

        * * @param width * @param height - * @param numComponents 3 or 4 components, i.e. {@link BufferedImage#TYPE_INT_RGB} or {@link BufferedImage#TYPE_INT_RGBA}. + * @param imageType one of {@link BufferedImage#TYPE_INT_ARGB TYPE_INT_ARGB}, {@link BufferedImage#TYPE_INT_ARGB_PRE TYPE_INT_ARGB_PRE}, + * {@link BufferedImage#TYPE_INT_RGB TYPE_INT_RGB} or {@link BufferedImage#TYPE_INT_BGR TYPE_INT_BGR}. * @param location origin, if null 0/0 is assumed. + * @param properties Hashtable of + * String/Object pairs. Used for {@link BufferedImage#getProperty(String)} etc. * @return */ - public static BufferedImage createBufferedImage(int width, int height, int numComponents, Point location) { - final int[] bandOffsets = new int[numComponents]; - for (int i=0; i < numComponents; i++) { + public static BufferedImageInt createBufferedImage(int width, int height, int imageType, Point location, Hashtable properties) { + final int[] bandOffsets = new int[imageType]; + for (int i=0; i < imageType; i++) { bandOffsets[i] = i; } + final ColorSpace colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB); + final int transferType = DataBuffer.TYPE_INT; final int bpp, rmask, gmask, bmask, amask; - final ColorModel cm; - if( 4 == numComponents ) { - bpp = 32; - rmask = 0x00ff0000; - gmask = 0x0000ff00; - bmask = 0x000000ff; - amask = 0xff000000; - cm = ColorModel.getRGBdefault(); - } else if( 3 == numComponents ) { - bpp = 24; - rmask = 0x00ff0000; - gmask = 0x0000ff00; - bmask = 0x000000ff; - amask = 0x0; - cm = new DirectColorModel(bpp, rmask, gmask, bmask, amask); - } else { - throw new IllegalArgumentException("numComponents must be [3..4], has "+numComponents); + final boolean alphaPreMul; + switch( imageType ) { + case BufferedImage.TYPE_INT_ARGB: + bpp = 32; + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0xff000000; + alphaPreMul = false; + break; + case BufferedImage.TYPE_INT_ARGB_PRE: + bpp = 32; + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0xff000000; + alphaPreMul = true; + break; + case BufferedImage.TYPE_INT_RGB: + bpp = 24; + rmask = 0x00ff0000; + gmask = 0x0000ff00; + bmask = 0x000000ff; + amask = 0x0; + alphaPreMul = false; + break; + case BufferedImage.TYPE_INT_BGR: + bpp = 24; + rmask = 0x000000ff; + gmask = 0x0000ff00; + bmask = 0x00ff0000; + amask = 0x0; + alphaPreMul = false; + break; + default: + throw new IllegalArgumentException("Unsupported imageType, must be [INT_ARGB, INT_ARGB_PRE, INT_RGB, INT_BGR], has "+imageType); } + final ColorModel colorModel = new DirectColorModel(colorSpace, bpp, rmask, gmask, bmask, amask, alphaPreMul, transferType); final int[] bandMasks; if ( 0 != amask ) { bandMasks = new int[4]; @@ -108,7 +167,7 @@ public final class DirectDataBufferInt extends DataBuffer { // final WritableRaster raster = new SunWritableRaster(sppsm, dataBuffer, location); final WritableRaster raster = new DirectWritableRaster(sppsm, dataBuffer, location); - return new BufferedImage (cm, raster, false /* isRasterPremultiplied */, null /* properties */); + return new BufferedImageInt(imageType, colorModel, raster, properties); } /** Default data bank. */ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java index 1517e0bd1..37ad8c361 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java @@ -31,7 +31,6 @@ import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; -import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Paper; @@ -55,6 +54,7 @@ import com.jogamp.nativewindow.awt.DirectDataBufferInt; */ public class OffscreenPrintable extends PrintableBase implements Printable { + public final int imageType; public final String pngFilename; /** @@ -62,11 +62,13 @@ public class OffscreenPrintable extends PrintableBase implements Printable { * @param job * @param printContainer * @param printDPI - * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param imageType AWT BufferedImage type (must be one of the integer types) * @param pngFilename TODO */ - public OffscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, String pngFilename) { + public OffscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int imageType, String pngFilename) { super(job, printContainer, printDPI, numSamples); + this.imageType = imageType; this.pngFilename = pngFilename; } @@ -141,13 +143,14 @@ public class OffscreenPrintable extends PrintableBase implements Printable { " -> total "+frameWidthT+ "x" + frameHeightT+ " -> scaled "+frameSWidthT+ "x" + frameSHeightT); - final BufferedImage image = DirectDataBufferInt.createBufferedImage(frameSWidthT, frameSHeightT, 4, null /* location */); + final BufferedImage image = DirectDataBufferInt.createBufferedImage(frameSWidthT, frameSHeightT, imageType, null /* location */, null /* properties */); { + System.err.println("PRINT.offscrn image "+image); final Graphics2D g2d = (Graphics2D) image.getGraphics(); g2d.setClip(0, 0, frameSWidthT, frameSHeightT); g2d.scale(scaleGraphics, scaleGraphics); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + // g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + // g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { cont.printAll(g2d); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java index 273da5c76..a23f7f8c3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java @@ -145,8 +145,8 @@ public class OnscreenPrintable extends PrintableBase implements Printable { System.err.println("PRINT at.pre: "+g2d.getTransform()); g2d.translate(pf.getImageableX(), pf.getImageableY()); g2d.scale(scaleComp72, scaleComp72); // WARNING: Produces rounding artifacts due to diff scale-factor of AWT/GL comps !!! - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + // g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + // g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java index 5c200a076..af4b41af2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java @@ -36,6 +36,7 @@ import java.awt.Label; import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.io.BufferedReader; import java.io.IOException; @@ -177,26 +178,26 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 72, 0); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 72, 8); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8); waitUntilPrintJobsIdle(p); } { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 300, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 300, -1); waitUntilPrintJobsIdle(p); } { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, true, 300, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 300, -1); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 600, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java index 1a5f8b922..d600c95a8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java @@ -36,6 +36,7 @@ import java.awt.Label; import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.io.BufferedReader; import java.io.IOException; @@ -182,26 +183,26 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 72, 0); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 72, 8); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8); waitUntilPrintJobsIdle(p); } { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 300, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 300, -1); waitUntilPrintJobsIdle(p); } { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, true, 300, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 300, -1); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 600, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index b4f5ad988..cd1ae8657 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -36,6 +36,7 @@ import java.awt.Frame; import java.awt.Label; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.io.BufferedReader; import java.io.IOException; @@ -216,26 +217,41 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 72, 0); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 72, 8); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8); waitUntilPrintJobsIdle(p); } { - // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 300, -1); + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1); waitUntilPrintJobsIdle(p); } { - // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, true, 300, -1); + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB /* offscreen-type */, 150, -1); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_RGB /* offscreen-type */, 150, -1); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_BGR /* offscreen-type */, 150, -1); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, false, 600, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java index f619ec9a1..a89f4dd6e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java @@ -220,7 +220,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { printDone = true; { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, false, 150, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, -1 /* offscreen-type */, 150, -1); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java index a0c50ac4b..3198212b5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java @@ -36,7 +36,6 @@ import java.awt.Frame; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.Label; -import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.File; @@ -125,8 +124,8 @@ public class TestTiledPrintingNIOImageSwingAWT extends UITestCase { final Graphics2D g2d = (Graphics2D) image.getGraphics(); g2d.setClip(0, 0, image.getWidth(), image.getHeight()); g2d.scale(scaleComp72, scaleComp72); - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + // g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + // g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); // frame.paintAll(g2d); final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, 1.0/scaleComp72, 1.0/scaleComp72, 0); @@ -230,21 +229,39 @@ public class TestTiledPrintingNIOImageSwingAWT extends UITestCase { Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel1, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel2, true)); - // paint offscreen: array 72dpi + // paint offscreen: array 72dpi ARGB { final BufferedImage image = new BufferedImage(frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_ARGB); - printOffscreenToFile(image, frame, caps, 0, "array_072dpi"); + printOffscreenToFile(image, frame, caps, 0, "array_072dpi_argb"); } - // paint offscreen: NIO 72dpi + // paint offscreen: NIO 72dpi ARGB { - final BufferedImage image = DirectDataBufferInt.createBufferedImage(frame.getWidth(), frame.getHeight(), 4, null /* location */); - printOffscreenToFile(image, frame, caps, 1, "newio_072dpi"); + final BufferedImage image = DirectDataBufferInt.createBufferedImage(frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_ARGB, null /* location */, null /* properties */); + printOffscreenToFile(image, frame, caps, 1, "newio_072dpi_argb"); } - // paint offscreen: NIO 300dpi + // paint offscreen: NIO 150dpi ARGB { - final int scale = (int) ( 300.0 / 72.0 + 0.5 ); - final BufferedImage image = DirectDataBufferInt.createBufferedImage(frame.getWidth()*scale, frame.getHeight()*scale, 4, null /* location */); - printOffscreenToFile(image, frame, caps, 2, "newio_300dpi"); + final int scale = (int) ( 150.0 / 72.0 + 0.5 ); + final BufferedImage image = DirectDataBufferInt.createBufferedImage(frame.getWidth()*scale, frame.getHeight()*scale, BufferedImage.TYPE_INT_ARGB, null /* location */, null /* properties */); + printOffscreenToFile(image, frame, caps, 2, "newio_150dpi_argb"); + } + // paint offscreen: NIO 150dpi ARGB_PRE + { + final int scale = (int) ( 150.0 / 72.0 + 0.5 ); + final BufferedImage image = DirectDataBufferInt.createBufferedImage(frame.getWidth()*scale, frame.getHeight()*scale, BufferedImage.TYPE_INT_ARGB_PRE, null /* location */, null /* properties */); + printOffscreenToFile(image, frame, caps, 2, "newio_150dpi_argbp"); + } + // paint offscreen: NIO 150dpi RGB + { + final int scale = (int) ( 150.0 / 72.0 + 0.5 ); + final BufferedImage image = DirectDataBufferInt.createBufferedImage(frame.getWidth()*scale, frame.getHeight()*scale, BufferedImage.TYPE_INT_RGB, null /* location */, null /* properties */); + printOffscreenToFile(image, frame, caps, 2, "newio_150dpi_rgb"); + } + // paint offscreen: NIO 150dpi BGR + { + final int scale = (int) ( 150.0 / 72.0 + 0.5 ); + final BufferedImage image = DirectDataBufferInt.createBufferedImage(frame.getWidth()*scale, frame.getHeight()*scale, BufferedImage.TYPE_INT_BGR, null /* location */, null /* properties */); + printOffscreenToFile(image, frame, caps, 2, "newio_150dpi_bgr"); } Assert.assertNotNull(frame); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java index 199a667a1..8393cf978 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java @@ -70,11 +70,11 @@ public abstract class TiledPrintingAWTBase extends UITestCase { * @param cont * @param pOrientation * @param paper - * @param offscrn TODO + * @param offscrnImageType if < 0 onscreen, otherwise integer BufferedImage type * @param dpi * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples */ - public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper, boolean offscrn, int dpi, int numSamples) { + public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper, int offscrnImageType, int dpi, int numSamples) { lock.lock(); try { final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); @@ -91,31 +91,29 @@ public abstract class TiledPrintingAWTBase extends UITestCase { StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(pdfMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(offscrn, dpi, numSamples, "pdf"); + final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "pdf"); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrn, dpi, numSamples); + return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } - return null; } System.err.println("No PDF"); factories = PrinterJob.lookupStreamPrintServices(psMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(offscrn, dpi, numSamples, "ps"); + final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "ps"); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrn, dpi, numSamples); + return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } - return null; } System.err.println("No PS"); return null; @@ -123,15 +121,15 @@ public abstract class TiledPrintingAWTBase extends UITestCase { lock.unlock(); } } - private String getPrintFilename(boolean offscrn, int dpi, int numSamples, String suffix) { + private String getPrintFilename(int offscrnImageType, int dpi, int numSamples, String suffix) { final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; final String simpleTestName = getSimpleTestName("."); - final String onoffscrn = offscrn ? "offscrn" : "on_scrn"; + final String onoffscrn = 0 > offscrnImageType ? "on_screen" : "offscrn_"+offscrnImageType; return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-%s-dpi%03d-aa%d.%s", simpleTestName, printCount, onoffscrn, dpi, numSamples, suffix).replace(' ', '_'); } private PrintableBase doPrintAutoImpl(Container cont, PrinterJob job, StreamPrintService ps, int pOrientation, Paper paper, - boolean offscrn, int dpi, int numSamples) { + int offscrnImageType, int dpi, int numSamples) { try { PageFormat pageFormat = job.defaultPage(); if( null != paper ) { @@ -143,8 +141,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase { } pageFormat.setOrientation(pOrientation); // PageFormat.LANDSCAPE or PageFormat.PORTRAIT job.setPrintService(ps); - final PrintableBase printable = offscrn ? new OffscreenPrintable(job, cont, dpi, numSamples, getPrintFilename(offscrn, dpi, numSamples, "png")) : - new OnscreenPrintable(job, cont, dpi, numSamples); + final PrintableBase printable; + if( 0 < offscrnImageType ) { + printable = new OffscreenPrintable(job, cont, dpi, numSamples, offscrnImageType, getPrintFilename(offscrnImageType, dpi, numSamples, "png")); + } else { + printable = new OnscreenPrintable(job, cont, dpi, numSamples); + } printable.job.setPrintable(printable, pageFormat); doPrintImpl(printable); return printable; -- cgit v1.2.3 From 9a8f9b9f7e6148b60b6f0f4326df8d213774284c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 27 Sep 2013 13:23:39 +0200 Subject: Bug 816: Fix JAWTWindow's getLocationOnScreenNonBlocking(); Derive CALayer position from AWT component's location on screen. Track fixedFrame size of root CALayer; Add Split layout to unit test, add [manual] Applet tests. - Fix JAWTWindow's getLocationOnScreenNonBlocking() Skip JRootPane while traversing up to root Container. JRootPane would duplicate the top-level container's offset (Window insets). - Derive CALayer position from AWT component's location on screen. Add Split layout to unit test, add [manual] Applet tests. AWT >= 7u40: - AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets. - Use getLocationOnScreenNonBlocking() to get location-on-screen w/o insets. - Native code: flip origin AWT < 7u40 still uses fixed position 0/0 for root and sub layer. - Track fixedFrame size of root CALayer - MyCALayer: - Override layoutSublayers to validate root and sub-layer pos/size - Override setFrame to use fixedFrame, if set (similar to MyNSOpenGLLayer) - Add Split layout to unit test, add [manual] Applet tests. - Thx to 'jimthev' and 'Manu' for providing Applet unit tests --- jnlp-files/jogl-applet-bug816_glcanvas01.html | 32 +++ jnlp-files/jogl-applet-bug816_glcanvas02.html | 32 +++ jnlp-files/jogl-test-applets.html | 11 + make/scripts/tests.sh | 4 +- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 46 ++-- .../classes/jogamp/nativewindow/awt/AWTMisc.java | 15 +- .../nativewindow/jawt/macosx/MacOSXJAWTWindow.java | 46 +++- .../jogamp/nativewindow/macosx/OSXUtil.java | 12 +- src/nativewindow/native/macosx/OSXmisc.m | 237 +++++++++++++-------- .../junit/jogl/awt/TestBug816OSXCALayerPosAWT.java | 98 +++++++-- .../jogl/demos/es2/awt/Bug816AppletGLCanvas01.java | 134 ++++++++++++ .../jogl/demos/es2/awt/Bug816AppletGLCanvas02.java | 85 ++++++++ 12 files changed, 611 insertions(+), 141 deletions(-) create mode 100644 jnlp-files/jogl-applet-bug816_glcanvas01.html create mode 100644 jnlp-files/jogl-applet-bug816_glcanvas02.html create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java (limited to 'make/scripts') diff --git a/jnlp-files/jogl-applet-bug816_glcanvas01.html b/jnlp-files/jogl-applet-bug816_glcanvas01.html new file mode 100644 index 000000000..c460ff12c --- /dev/null +++ b/jnlp-files/jogl-applet-bug816_glcanvas01.html @@ -0,0 +1,32 @@ + + + +Bug816 OSX CALayer Pos - Custom Bounds + + + +

        +Bug816 OSX CALayer Pos - Custom Bounds +

        + +

        + + + + + + Sorry, no Java support detected. + + + +

        + + diff --git a/jnlp-files/jogl-applet-bug816_glcanvas02.html b/jnlp-files/jogl-applet-bug816_glcanvas02.html new file mode 100644 index 000000000..850b9752a --- /dev/null +++ b/jnlp-files/jogl-applet-bug816_glcanvas02.html @@ -0,0 +1,32 @@ + + + +Bug816 OSX CALayer Pos - Box Layout + + + +

        +Bug816 OSX CALayer Pos - Box Layout +

        + +

        + + + + + + Sorry, no Java support detected. + + + +

        + + diff --git a/jnlp-files/jogl-test-applets.html b/jnlp-files/jogl-test-applets.html index 132945e4e..69fb70eca 100644 --- a/jnlp-files/jogl-test-applets.html +++ b/jnlp-files/jogl-test-applets.html @@ -198,6 +198,17 @@ Click on the Launch link to actually launch the demo.
        Action {@link State} Before {@link State} After {@link GLMediaEventListener Event}
        {@link #initStream(URI, int, int, int)} {@link State#Uninitialized Uninitialized} {@link State#Initialized Initialized}1, {@link State#Uninitialized Uninitialized} {@link GLMediaEventListener#EVENT_CHANGE_INIT EVENT_CHANGE_INIT} or ( {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} + {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT} )
        {@link #initGL(GL)} {@link State#Initialized Initialized} {@link State#Paused Paused}, {@link State#Initialized Initialized} {@link GLMediaEventListener#EVENT_CHANGE_PAUSE EVENT_CHANGE_PAUSE}
        {@link #initStream(URI, int, int, int)} {@link State#Uninitialized Uninitialized} {@link State#Initialized Initialized}1, {@link State#Uninitialized Uninitialized} {@link GLMediaEventListener#EVENT_CHANGE_INIT EVENT_CHANGE_INIT} or ( {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} + {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT} )
        {@link #initGL(GL)} {@link State#Initialized Initialized} {@link State#Paused Paused}, , {@link State#Uninitialized Uninitialized} {@link GLMediaEventListener#EVENT_CHANGE_PAUSE EVENT_CHANGE_PAUSE} or ( {@link GLMediaEventListener#EVENT_CHANGE_ERR EVENT_CHANGE_ERR} + {@link GLMediaEventListener#EVENT_CHANGE_UNINIT EVENT_CHANGE_UNINIT} )
        {@link #play()} {@link State#Paused Paused} {@link State#Playing Playing} {@link GLMediaEventListener#EVENT_CHANGE_PLAY EVENT_CHANGE_PLAY}
        {@link #pause()} {@link State#Playing Playing} {@link State#Paused Paused} {@link GLMediaEventListener#EVENT_CHANGE_PAUSE EVENT_CHANGE_PAUSE}
        {@link #seek(int)} {@link State#Paused Paused}, {@link State#Playing Playing} {@link State#Paused Paused}, {@link State#Playing Playing} none
        +

        +Misc tests: +

        +

        + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 442b12672..8c58efb3f 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -332,7 +332,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -454,7 +454,7 @@ testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index a71356b1c..576fcf4ed 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -46,6 +46,7 @@ import java.awt.Container; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.applet.Applet; + import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.CapabilitiesImmutable; @@ -60,6 +61,7 @@ import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; +import javax.swing.JRootPane; import jogamp.nativewindow.SurfaceUpdatedHelper; import jogamp.nativewindow.jawt.JAWT; @@ -227,9 +229,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if( !isOffscreenLayerSurfaceEnabled() ) { throw new NativeWindowException("Not an offscreen layer surface"); } - if(DEBUG) { - System.err.println("JAWTWindow.attachSurfaceHandle: "+toHexString(layerHandle) + ", bounds "+bounds); - } attachSurfaceLayerImpl(layerHandle); offscreenSurfaceLayer = layerHandle; component.repaint(); @@ -248,14 +247,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, * Call this method if any parent or ancestor's layout has been changed, * which could affects the layout of this surface. *

        - * @see #isOffscreenLayerSurfaceEnabled() + * @see #isOffscreenLayerSurfaceEnabled() * @throws NativeWindowException if {@link #isOffscreenLayerSurfaceEnabled()} == false */ - protected void layoutSurfaceLayerImpl(long layerHandle, int width, int height) {} + protected void layoutSurfaceLayerImpl(long layerHandle) {} private final void layoutSurfaceLayerIfEnabled() throws NativeWindowException { if( isOffscreenLayerSurfaceEnabled() && 0 != offscreenSurfaceLayer ) { - layoutSurfaceLayerImpl(offscreenSurfaceLayer, getWidth(), getHeight()); + layoutSurfaceLayerImpl(offscreenSurfaceLayer); } } @@ -533,7 +532,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, System.err.println("Warning: JAWT Lock hold, but not the AWT tree lock: "+this); Thread.dumpStack(); } - return getLocationOnScreenNonBlocking(storage, component); + if( null == storage ) { + storage = new Point(); + } + getLocationOnScreenNonBlocking(storage, component); + return storage; } java.awt.Point awtLOS = component.getLocationOnScreen(); if(null!=storage) { @@ -569,21 +572,28 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } protected abstract Point getLocationOnScreenNativeImpl(int x, int y); - protected static Point getLocationOnScreenNonBlocking(Point storage, Component comp) { - int x = 0; - int y = 0; + protected static Component getLocationOnScreenNonBlocking(Point storage, Component comp) { + Component last = null; while(null != comp) { - x += comp.getX(); - y += comp.getY(); + final int dx = comp.getX(); + final int dy = comp.getY(); + if( ! ( comp instanceof JRootPane ) ) { + if( DEBUG ) { + System.err.print("LOS: "+storage+" + "+comp.getClass().getSimpleName()+"["+dx+"/"+dy+"] -> "); + } + storage.translate(dx, dy); + if( DEBUG ) { + System.err.println(storage); + } + last = comp; + } else if( DEBUG ) { + System.err.println("LOS: ignore "+comp.getClass().getSimpleName()+"["+dx+"/"+dy+"]"); + } comp = comp.getParent(); } - if(null!=storage) { - storage.translate(x, y); - return storage; - } - return new Point(x, y); + return last; } - + @Override public boolean hasFocus() { return component.hasFocus(); diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index f38e7ea2b..e326b65bd 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -28,13 +28,16 @@ package jogamp.nativewindow.awt; import java.awt.FocusTraversalPolicy; +import java.awt.Insets; import java.awt.Window; import java.awt.Component; import java.awt.Container; import java.awt.Frame; + +import javax.swing.JComponent; import javax.swing.JFrame; +import javax.swing.JRootPane; import javax.swing.WindowConstants; - import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.WindowClosingProtocol; import javax.swing.MenuSelectionManager; @@ -68,6 +71,16 @@ public class AWTMisc { } return (Container) c; } + + public static Insets getInsets(Component c) { + if( c instanceof Window ) { + return ((Window)c).getInsets(); + } + if( c instanceof JComponent ) { + return ((JComponent)c).getInsets(); + } + return null; + } public static interface ComponentAction { /** diff --git a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java index 666f895f4..6d08078b6 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java +++ b/src/nativewindow/classes/jogamp/nativewindow/jawt/macosx/MacOSXJAWTWindow.java @@ -40,6 +40,7 @@ package jogamp.nativewindow.jawt.macosx; +import java.awt.Component; import java.nio.Buffer; import java.security.AccessController; import java.security.PrivilegedAction; @@ -49,11 +50,11 @@ import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.MutableSurface; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.awt.JAWTWindow; +import jogamp.nativewindow.awt.AWTMisc; import jogamp.nativewindow.jawt.JAWT; import jogamp.nativewindow.jawt.JAWTFactory; import jogamp.nativewindow.jawt.JAWTUtil; @@ -105,19 +106,42 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { @Override protected void attachSurfaceLayerImpl(final long layerHandle) { OSXUtil.RunOnMainThread(false, new Runnable() { - public void run() { - OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks()); + public void run() { + // AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets. + // Determine p0: components location on screen w/o insets. + // CALayer position will be determined in native code. + final Point p0 = new Point(); + final Component outterComp = getLocationOnScreenNonBlocking(p0, component); + final java.awt.Insets ins = AWTMisc.getInsets(outterComp); + if(null != ins) { + p0.translate(-ins.left, -ins.top); + } + if( DEBUG ) { + final java.awt.Point wP0 = outterComp.getLocationOnScreen(); + System.err.println("JAWTWindow.attachSurfaceHandleImpl: "+toHexString(layerHandle) + ", wP0 "+wP0+"[ins "+ins+"], p0 "+p0+", bounds "+bounds); + } + OSXUtil.AddCASublayer(rootSurfaceLayer, layerHandle, p0.getX(), p0.getY(), getWidth(), getHeight(), JAWTUtil.getOSXCALayerQuirks()); } } ); } @Override - protected void layoutSurfaceLayerImpl(long layerHandle, int width, int height) { + protected void layoutSurfaceLayerImpl(long layerHandle) { final int caLayerQuirks = JAWTUtil.getOSXCALayerQuirks(); if( 0 != caLayerQuirks ) { - if(DEBUG) { - System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", "+width+"x"+height+", caLayerQuirks "+caLayerQuirks+"; "+this); + // AWT position is top-left w/ insets, where CALayer position is bottom/left from root CALayer w/o insets. + // Determine p0: components location on screen w/o insets. + // CALayer position will be determined in native code. + final Point p0 = new Point(); + final Component outterComp = getLocationOnScreenNonBlocking(p0, component); + final java.awt.Insets ins = AWTMisc.getInsets(outterComp); + if( null != ins ) { + p0.translate(-ins.left, -ins.top); } - OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, width, height, caLayerQuirks); + if( DEBUG ) { + final java.awt.Point wP0 = outterComp.getLocationOnScreen(); + System.err.println("JAWTWindow.layoutSurfaceLayerImpl: "+toHexString(layerHandle) + ", wP0 "+wP0+"[ins "+ins+"], p0 "+p0+", bounds "+bounds); + } + OSXUtil.FixCALayerLayout(rootSurfaceLayer, layerHandle, p0.getX(), p0.getY(), getWidth(), getHeight(), caLayerQuirks); } } @@ -312,8 +336,12 @@ public class MacOSXJAWTWindow extends JAWTWindow implements MutableSurface { *

        */ @Override - public Point getLocationOnScreen(Point storage) { - return getLocationOnScreenNonBlocking(storage, component); + public Point getLocationOnScreen(Point storage) { + if( null == storage ) { + storage = new Point(); + } + getLocationOnScreenNonBlocking(storage, component); + return storage; } protected Point getLocationOnScreenNativeImpl(final int x0, final int y0) { return null; } diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java index de24a76db..2112131ed 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java @@ -163,14 +163,14 @@ public class OSXUtil implements ToolkitProperties { * @see #CreateCALayer(int, int) * @see #RemoveCASublayer(long, long, boolean) */ - public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int width, final int height, final int caLayerQuirks) { + public static void AddCASublayer(final long rootCALayer, final long subCALayer, final int x, final int y, final int width, final int height, final int caLayerQuirks) { if(0==rootCALayer || 0==subCALayer) { throw new IllegalArgumentException("rootCALayer 0x"+Long.toHexString(rootCALayer)+", subCALayer 0x"+Long.toHexString(subCALayer)); } if(DEBUG) { System.err.println("OSXUtil.AttachCALayer: caLayerQuirks "+caLayerQuirks+", 0x"+Long.toHexString(subCALayer)+" - "+Thread.currentThread().getName()); } - AddCASublayer0(rootCALayer, subCALayer, width, height, caLayerQuirks); + AddCASublayer0(rootCALayer, subCALayer, x, y, width, height, caLayerQuirks); } /** @@ -190,11 +190,11 @@ public class OSXUtil implements ToolkitProperties { * @param height the expected height * @param caLayerQuirks TODO */ - public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final int width, final int height, final int caLayerQuirks) { + public static void FixCALayerLayout(final long rootCALayer, final long subCALayer, final int x, final int y, final int width, final int height, final int caLayerQuirks) { if( 0==rootCALayer && 0==subCALayer ) { return; } - FixCALayerLayout0(rootCALayer, subCALayer, width, height, caLayerQuirks); + FixCALayerLayout0(rootCALayer, subCALayer, x, y, width, height, caLayerQuirks); } /** @@ -357,8 +357,8 @@ public class OSXUtil implements ToolkitProperties { private static native long GetNSView0(long nsWindow); private static native long GetNSWindow0(long nsView); private static native long CreateCALayer0(int width, int height); - private static native void AddCASublayer0(long rootCALayer, long subCALayer, int width, int height, int caLayerQuirks); - private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int width, int height, int caLayerQuirks); + private static native void AddCASublayer0(long rootCALayer, long subCALayer, int x, int y, int width, int height, int caLayerQuirks); + private static native void FixCALayerLayout0(long rootCALayer, long subCALayer, int x, int y, int width, int height, int caLayerQuirks); private static native void RemoveCASublayer0(long rootCALayer, long subCALayer); private static native void DestroyCALayer0(long caLayer); private static native void RunOnMainThread0(Runnable runnable); diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index fbe37be7d..fa40c871f 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -333,6 +333,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 */ @interface MyCALayer: CALayer { +@private + BOOL fixedFrameSet; + CGRect fixedFrame; } - (id)init; #ifdef DBG_LIFECYCLE @@ -341,6 +344,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 - (void)dealloc; #endif - (id)actionForKey:(NSString *)key ; +- (void)layoutSublayers; +- (void)setFrame:(CGRect) frame; +- (void)fixCALayerLayout: (CALayer*) subLayer x:(jint)x y:(jint)y width:(jint)width height:(jint)height caLayerQuirks:(jint)caLayerQuirks force:(jboolean) force; @end @@ -350,6 +356,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 { DBG_PRINT("MyCALayer::init.0\n"); MyCALayer * o = [super init]; + o->fixedFrameSet = 0; + o->fixedFrame = CGRectMake(0, 0, 0, 0); DBG_PRINT("MyCALayer::init.X: new %p\n", o); return o; } @@ -390,6 +398,127 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 // return [super actionForKey: key]; } +- (void)layoutSublayers +{ + if( fixedFrameSet ) { + NSArray* subs = [self sublayers]; + if( NULL != subs ) { + CGRect rFrame = [self frame]; + if( !CGRectEqualToRect(fixedFrame, rFrame) ) { + #ifdef VERBOSE + DBG_PRINT("CALayer::layoutSublayers.0: Root %p frame %lf/%lf %lfx%lf -> %lf/%lf %lfx%lf\n", + self, + rFrame.origin.x, rFrame.origin.y, rFrame.size.width, rFrame.size.height, + fixedFrame.origin.x, fixedFrame.origin.y, fixedFrame.size.width, fixedFrame.size.height); + #endif + [super setFrame: fixedFrame]; + } + NSUInteger i = 0; + for(i=0; i<[subs count]; i++) { + CALayer* sub = [subs objectAtIndex: i]; + CGRect sFrame = [sub frame]; + CGRect sFrame2 = CGRectMake(0, 0, fixedFrame.size.width, fixedFrame.size.height); + if( !CGRectEqualToRect(sFrame2, sFrame) ) { + #ifdef VERBOSE + DBG_PRINT("CALayer::layoutSublayers.1: Sub[%d] %p frame %lf/%lf %lfx%lf -> %lf/%lf %lfx%lf\n", + (int)i, sub, + sFrame.origin.x, sFrame.origin.y, sFrame.size.width, sFrame.size.height, + sFrame2.origin.x, sFrame2.origin.y, sFrame2.size.width, sFrame2.size.height); + #endif + [sub setFrame: sFrame2]; + } + #ifdef VERBOSE + DBG_PRINT("CALayer::layoutSublayers.X: Root %p . Sub[%d] %p : frame r: %lf/%lf %lfx%lf . s: %lf/%lf %lfx%lf\n", + self, (int)i, sub, + rFrame.origin.x, rFrame.origin.y, rFrame.size.width, rFrame.size.height, + sFrame.origin.x, sFrame.origin.y, sFrame.size.width, sFrame.size.height); + #endif + } + } + } else { + [super layoutSublayers]; + } +} + +- (void) setFrame:(CGRect) frame +{ + if( fixedFrameSet ) { + [super setFrame: fixedFrame]; + } else { + [super setFrame: frame]; + } +} + +- (void)fixCALayerLayout: (CALayer*) subLayer x:(jint)x y:(jint)y width:(jint)width height:(jint)height caLayerQuirks:(jint)caLayerQuirks force:(jboolean) force +{ + { + CALayer* superLayer = [self superlayer]; + CGRect superFrame = [superLayer frame]; + CGRect lFrame = [self frame]; + int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lFrame.origin.x!=0 || lFrame.origin.y!=0 ); + int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lFrame.size.width!=width || lFrame.size.height!=height ); + if( !posQuirk ) { + // Use root layer position, sub-layer will be on 0/0, + // Given AWT position is location on screen w/o insets and top/left origin! + fixedFrame.origin.x = x; + fixedFrame.origin.y = superFrame.size.height - height - y; // AWT's position top/left -> bottom/left + posQuirk |= 8; + } else { + // Buggy super layer position, always use 0/0 + fixedFrame.origin.x = 0; + fixedFrame.origin.y = 0; + } + if( !sizeQuirk ) { + fixedFrame.size.width = lFrame.size.width; + fixedFrame.size.height = lFrame.size.height; + } else { + fixedFrame.size.width = width; + fixedFrame.size.height = height; + } + DBG_PRINT("CALayer::FixCALayerLayout0.0: Quirks [%d, pos %d, size %d], Super %p frame %lf/%lf %lfx%lf, Root %p frame %lf/%lf %lfx%lf, usr %d/%d %dx%d -> %lf/%lf %lfx%lf\n", + caLayerQuirks, posQuirk, sizeQuirk, + superLayer, superFrame.origin.x, superFrame.origin.y, superFrame.size.width, superFrame.size.height, + self, lFrame.origin.x, lFrame.origin.y, lFrame.size.width, lFrame.size.height, + x, y, width, height, fixedFrame.origin.x, fixedFrame.origin.y, fixedFrame.size.width, fixedFrame.size.height); + if( posQuirk || sizeQuirk ) { + fixedFrameSet = 1; + [super setFrame: fixedFrame]; + } + } + if( NULL != subLayer ) { + CGRect lFrame = [subLayer frame]; + int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lFrame.size.width!=width || lFrame.size.height!=height ); + CGFloat _x, _y, _w, _h; + int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lFrame.origin.x!=0 || lFrame.origin.y!=0 ); + // Sub rel. to used root layer + _x = 0; + _y = 0; + posQuirk |= 8; + if( !sizeQuirk ) { + _w = lFrame.size.width; + _h = lFrame.size.height; + } else { + _w = width; + _h = height; + } + DBG_PRINT("CALayer::FixCALayerLayout1.0: Quirks [%d, pos %d, size %d], SubL %p frame %lf/%lf %lfx%lf, usr %dx%d -> %lf/%lf %lfx%lf\n", + caLayerQuirks, posQuirk, sizeQuirk, subLayer, lFrame.origin.x, lFrame.origin.y, lFrame.size.width, lFrame.size.height, + width, height, _x, _y, _w, _h); + if( force || posQuirk || sizeQuirk ) { + lFrame.origin.x = _x; + lFrame.origin.y = _y; + lFrame.size.width = _w; + lFrame.size.height = _h; + if( [subLayer conformsToProtocol:@protocol(NWDedicatedFrame)] ) { + CALayer * subLayerDS = (CALayer *) subLayer; + [subLayerDS setDedicatedFrame: lFrame quirks: caLayerQuirks]; + } else { + [subLayer setFrame: lFrame]; + } + } + } +} + @end /* @@ -409,98 +538,32 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 if(0 == height) { height = 32; } // initial dummy size ! - CGRect lRect = [layer frame]; - lRect.origin.x = 0; - lRect.origin.y = 0; - lRect.size.width = width; - lRect.size.height = height; - [layer setFrame: lRect]; + CGRect lFrame = [layer frame]; + lFrame.origin.x = 0; + lFrame.origin.y = 0; + lFrame.size.width = width; + lFrame.size.height = height; + [layer setFrame: lFrame]; // no animations for add/remove/swap sublayers etc // doesn't work: [layer removeAnimationForKey: kCAOnOrderIn, kCAOnOrderOut, kCATransition] [layer removeAllAnimations]; // [layer addAnimation:nil forKey:kCATransition]; [layer setAutoresizingMask: (kCALayerWidthSizable|kCALayerHeightSizable)]; [layer setNeedsDisplayOnBoundsChange: YES]; - DBG_PRINT("CALayer::CreateCALayer.1: root %p %lf/%lf %lfx%lf\n", layer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height); + DBG_PRINT("CALayer::CreateCALayer.1: root %p %lf/%lf %lfx%lf\n", layer, lFrame.origin.x, lFrame.origin.y, lFrame.size.width, lFrame.size.height); [pool release]; DBG_PRINT("CALayer::CreateCALayer.X: root %p (refcnt %d)\n", layer, (int)[layer retainCount]); return (jlong) ((intptr_t) layer); } -static void FixCALayerLayout0(MyCALayer* rootLayer, CALayer* subLayer, jint width, jint height, jint caLayerQuirks, jboolean force) { - if( NULL != rootLayer ) { - CGRect lRect = [rootLayer frame]; - int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lRect.origin.x!=0 || lRect.origin.y!=0 ); - int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lRect.size.width!=width || lRect.size.height!=height ); - CGFloat _x, _y, _w, _h; - // force root -> 0/0 - _x = 0; - _y = 0; - posQuirk |= 8; - if( sizeQuirk ) { - _w = width; - _h = height; - } else { - _w = lRect.size.width; - _h = lRect.size.height; - } - DBG_PRINT("CALayer::FixCALayerLayout0.0: Quirks [%d, pos %d, size %d], Root %p frame %lf/%lf %lfx%lf, usr %dx%d -> %lf/%lf %lfx%lf\n", - caLayerQuirks, posQuirk, sizeQuirk, rootLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, - width, height, _x, _y, _w, _h); - if( posQuirk || sizeQuirk ) { - lRect.origin.x = _x; - lRect.origin.y = _y; - lRect.size.width = _w; - lRect.size.height = _h; - [rootLayer setFrame: lRect]; - } - } - if( NULL != subLayer ) { - CGRect lRect = [subLayer frame]; - int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lRect.size.width!=width || lRect.size.height!=height ); - CGFloat _x, _y, _w, _h; - int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lRect.origin.x!=0 || lRect.origin.y!=0 ); - if( posQuirk ) { - _x = 0; - _y = 0; - } else { - // sub always rel to root - _x = lRect.origin.x; - _y = lRect.origin.y; - } - if( sizeQuirk ) { - _w = width; - _h = height; - } else { - _w = lRect.size.width; - _h = lRect.size.height; - } - DBG_PRINT("CALayer::FixCALayerLayout1.0: Quirks [%d, pos %d, size %d], SubL %p frame %lf/%lf %lfx%lf, usr %dx%d -> %lf/%lf %lfx%lf\n", - caLayerQuirks, posQuirk, sizeQuirk, subLayer, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, - width, height, _x, _y, _w, _h); - if( force || posQuirk || sizeQuirk ) { - lRect.origin.x = _x; - lRect.origin.y = _y; - lRect.size.width = _w; - lRect.size.height = _h; - if( [subLayer conformsToProtocol:@protocol(NWDedicatedFrame)] ) { - CALayer * subLayerDS = (CALayer *) subLayer; - [subLayerDS setDedicatedFrame: lRect quirks: caLayerQuirks]; - } else { - [subLayer setFrame: lRect]; - } - } - } -} - /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: AddCASublayer0 * Signature: (JJIIIII)V */ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 - (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height, jint caLayerQuirks) + (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint x, jint y, jint width, jint height, jint caLayerQuirks) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); @@ -513,23 +576,10 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 [subLayer retain]; // Pairs w/ RemoveCASublayer CGRect lRectRoot = [rootLayer frame]; - int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ); - int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ); - - DBG_PRINT("CALayer::AddCASublayer0.0: Quirks [%d, pos %d, size %d], Root %p (refcnt %d), Sub %p (refcnt %d), frame0: %lf/%lf %lfx%lf\n", - caLayerQuirks, posQuirk, sizeQuirk, rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount], + DBG_PRINT("CALayer::AddCASublayer0.0: Quirks %d, Root %p (refcnt %d), Sub %p (refcnt %d), frame0: %lf/%lf %lfx%lf\n", + caLayerQuirks, rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount], lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height); - CGPoint origin = lRectRoot.origin; // save - // force root to 0/0 - lRectRoot.origin.x = 0; - lRectRoot.origin.y = 0; - [rootLayer setFrame: lRectRoot]; - - // simple 1:1 layout rel. to root-layer ! - if( !posQuirk ) { - lRectRoot.origin = origin; - } [subLayer setFrame:lRectRoot]; [rootLayer addSublayer:subLayer]; @@ -545,7 +595,7 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 [subLayer setNeedsDisplayOnBoundsChange: YES]; if( 0 != caLayerQuirks ) { - FixCALayerLayout0(rootLayer, subLayer, width, height, caLayerQuirks, JNI_TRUE); + [rootLayer fixCALayerLayout: subLayer x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_TRUE]; } [CATransaction commit]; @@ -561,17 +611,20 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 * Signature: (JJIII)V */ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_FixCALayerLayout0 - (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint width, jint height, jint caLayerQuirks) + (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint x, jint y, jint width, jint height, jint caLayerQuirks) { if( 0 != caLayerQuirks ) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); + if( NULL == rootLayer ) { + NativewindowCommon_throwNewRuntimeException(env, "Argument \"rootLayer\" is null"); + } CALayer* subLayer = (CALayer*) ((intptr_t) subCALayer); [CATransaction begin]; [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - FixCALayerLayout0(rootLayer, subLayer, width, height, caLayerQuirks, JNI_FALSE); + [rootLayer fixCALayerLayout: subLayer x:x y:y width:width height:height caLayerQuirks:caLayerQuirks force:JNI_FALSE]; [CATransaction commit]; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java index 48340aa75..358e97622 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java @@ -33,8 +33,13 @@ import javax.media.opengl.*; import com.jogamp.opengl.util.Animator; import javax.media.opengl.awt.GLCanvas; +import javax.swing.BoundedRangeModel; import javax.swing.BoxLayout; import javax.swing.JFrame; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.ScrollPaneConstants; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.newt.event.awt.AWTWindowAdapter; @@ -68,9 +73,15 @@ import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +/** + * Bug 816: OSX CALayer Positioning Bug. + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBug816OSXCALayerPosAWT extends UITestCase { - public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box }; + public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box, Split }; static long duration = 1600; // ms static int width, height; @@ -113,7 +124,7 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { comp2.setPreferredSize(new_sz2); comp2.setSize(new_sz2); } - if( null != frame ) { + if( null != frame ) { frame.pack(); } } } ); @@ -206,6 +217,39 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { framePane.add(c); } break; + case Split: { + Dimension sbDim = new Dimension(16, 16); + JScrollPane vsp = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + { + JScrollBar vsb = vsp.getVerticalScrollBar(); + vsb.setPreferredSize(sbDim); + BoundedRangeModel model = vsb.getModel(); + model.setMinimum(0); + model.setMaximum(100); + model.setValue(50); + model.setExtent(1); + vsb.setEnabled(true); + } + JScrollPane hsp = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + { + JScrollBar hsb = hsp.getHorizontalScrollBar(); + hsb.setPreferredSize(sbDim); + BoundedRangeModel model = hsb.getModel(); + model.setMinimum(0); + model.setMaximum(100); + model.setValue(50); + model.setExtent(1); + hsb.setEnabled(true); + } + JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, + twoCanvas ? glCanvas2 : vsp, glCanvas1 ); + horizontalSplitPane.setResizeWeight(0.5); + JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + true, horizontalSplitPane, hsp); + verticalSplitPane.setResizeWeight(0.5); + framePane.add(verticalSplitPane); + } + break; } final GearsES2 demo1 = new GearsES2(swapInterval); glCanvas1.addGLEventListener(demo1); @@ -329,26 +373,40 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { } @Test - public void test04_Compo_Flow_Two() throws InterruptedException, InvocationTargetException { + public void test04_Compo_Split_One() throws InterruptedException, InvocationTargetException { if( testNum != -1 && testNum != 4 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Split, false /* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test05_Compo_Flow_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 5 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, true /* resizeByComp */); } @Test - public void test05_Compo_DblBrd_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 5 ) { return ; } + public void test06_Compo_DblBrd_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 6 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, true /* resizeByComp */); } @Test - public void test06_Compo_Box_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 6 ) { return ; } + public void test07_Compo_Box_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 7 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, true /* resizeByComp */); } + @Test + public void test08_Compo_Split_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 8 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Split, true/* twoCanvas */, true /* resizeByComp */); + } + @Test public void test10_Frame_None_One() throws InterruptedException, InvocationTargetException { if( testNum != -1 && testNum != 10 ) { return ; } @@ -378,26 +436,40 @@ public class TestBug816OSXCALayerPosAWT extends UITestCase { } @Test - public void test14_Frame_Flow_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 14 ) { return ; } + public void test14_Frame_Split_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 14) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Split, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test15_Frame_Flow_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 15 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, false /* resizeByComp */); } @Test - public void test15_Frame_DblBrd_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 15 ) { return ; } + public void test16_Frame_DblBrd_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 16 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, false /* resizeByComp */); } @Test - public void test16_Frame_Box_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 16 ) { return ; } + public void test17_Frame_Box_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 17 ) { return ; } final GLCapabilities caps = new GLCapabilities(getGLP()); runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, false /* resizeByComp */); } + @Test + public void test18_Frame_Split_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 18 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Split, true/* twoCanvas */, false /* resizeByComp */); + } + static int testNum = -1; public static void main(String args[]) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java new file mode 100644 index 000000000..175b053d1 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas01.java @@ -0,0 +1,134 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; + +import java.applet.Applet; +import java.awt.Color; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.JFrame; +import javax.swing.JPanel; + +/** + * Bug 816: OSX CALayer Positioning Bug. + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + *

        + * Test simply positions a GLCanvas via setBounds(..) within it's Applet. + *

        + */ +@SuppressWarnings("serial") +public class Bug816AppletGLCanvas01 extends Applet implements GLEventListener { + + public Bug816AppletGLCanvas01() { + } + + public static JFrame frame; + public static JPanel appletHolder; + public static boolean isApplet = true; + + static public void main(String args[]) { + Applet myApplet = null; + isApplet = false; + + myApplet = new Bug816AppletGLCanvas01(); + appletStarter(myApplet, "Bug861AppletGLCanvasTest01", 800, 600); + } + + static public void appletStarter(final Applet des, String frameName, int width, int height) { + appletHolder = new JPanel(); + if (frame != null) { + frame.dispose(); + frame = null; + } + frame = new JFrame(frameName); + frame.setVisible(false); + frame.getContentPane().add(appletHolder); + + appletHolder.setLayout(null); + des.setBounds(0, 0, width, height); + appletHolder.add(des); + + frame.setVisible(true); + int frameBorderSize = appletHolder.getLocationOnScreen().x - frame.getLocationOnScreen().x; + int titleBarHeight = appletHolder.getLocationOnScreen().y - frame.getLocationOnScreen().y; + int frameWidth = width + 2 * frameBorderSize; + int frameHeight = height + titleBarHeight + frameBorderSize; + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setSize(frameWidth, frameHeight); + frame.setVisible(true); + des.init(); + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + } + + public void init() { + initOpenGLAWT(); + } + + public void initOpenGLAWT() { + setBackground(Color.gray); + setLayout(null); + + GLProfile glp = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(glp); + GLCanvas canvas = new GLCanvas((GLCapabilitiesImmutable) caps); + canvas.setBounds(50, 50, 200, 450); + canvas.addGLEventListener(this); + add(canvas); + } + + public void init(GLAutoDrawable gLAutoDrawable) { + GL gl = gLAutoDrawable.getGL(); + gl.glClearColor(1.0f, 0.0f, 0.0f, 1.0f); + gl.glClear(GL.GL_COLOR_BUFFER_BIT); + gLAutoDrawable.swapBuffers(); + } + + public void dispose(GLAutoDrawable glad) { + } + + public void display(GLAutoDrawable glad) { + } + + public void reshape(GLAutoDrawable glad, int i, int i1, int i2, int i3) { + } + +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java new file mode 100644 index 000000000..9ae0a2bbd --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletGLCanvas02.java @@ -0,0 +1,85 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; + +import java.applet.Applet; +import java.util.ArrayList; +import java.util.List; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.BoxLayout; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.util.Animator; + +/** + * Bug 816: OSX CALayer Positioning Bug. + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + *

        + * Test uses a box layout within the Applet. + *

        + */ +@SuppressWarnings("serial") +public class Bug816AppletGLCanvas02 extends Applet { + private List animators = new ArrayList(2); + + @Override + public void init() { + System.err.println("GearsApplet: init() - begin"); + new BoxLayout(this, BoxLayout.X_AXIS); + setSize(600, 300); + add(createCanvas()); + add(createCanvas()); + System.err.println("GearsApplet: init() - end"); + } + + private GLCanvas createCanvas() { + GLCanvas canvas = new GLCanvas(); + canvas.addGLEventListener(new GearsES2(1)); + canvas.setSize(300, 300); + animators.add(new Animator(canvas)); + return canvas; + } + + @Override + public void start() { + for (GLAnimatorControl control : animators) { + control.start(); + } + } + + @Override + public void stop() { + for (GLAnimatorControl control : animators) { + control.stop(); + } + } +} -- cgit v1.2.3 From 469311764a1cb3c3af8439c1638160926741c1e5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 27 Sep 2013 13:49:59 +0200 Subject: Test AWT Printing: Frame size contains border/insets, use as-is for scaling; Only force TEXT AA print-rendering hint. --- make/scripts/tests-osx-x64.sh | 1 + make/scripts/tests.sh | 4 ++-- .../test/junit/jogl/tile/OffscreenPrintable.java | 21 ++++++++++----------- .../test/junit/jogl/tile/OnscreenPrintable.java | 16 +++++++--------- .../tile/TestTiledPrintingNIOImageSwingAWT.java | 10 +++++----- 5 files changed, 25 insertions(+), 27 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh index 7585e68ad..1204b8a7b 100755 --- a/make/scripts/tests-osx-x64.sh +++ b/make/scripts/tests-osx-x64.sh @@ -4,6 +4,7 @@ export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH JAVA_HOME=`/usr/libexec/java_home -version 1.7` #JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_25` +#JAVA_HOME=`/usr/libexec/java_home -version 1.6.0` PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8c58efb3f..442b12672 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -332,7 +332,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -454,7 +454,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java index 37ad8c361..bd526419c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java @@ -31,6 +31,7 @@ import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Insets; +import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.awt.print.PageFormat; import java.awt.print.Paper; @@ -121,36 +122,34 @@ public class OffscreenPrintable extends PrintableBase implements Printable { /** * See: 'Scaling of Frame and GL content' in Class description! + * Note: Frame size contains the frame border (i.e. insets)! */ final Insets frameInsets = cont.getInsets(); final int frameWidth = cont.getWidth(); final int frameHeight= cont.getHeight(); - final int frameWidthT = frameWidth + frameInsets.left + frameInsets.right; - final int frameHeightT = frameHeight + frameInsets.top + frameInsets.bottom; final double scaleGraphics = dpi / 72.0; - final int frameSWidthT = (int) ( frameWidthT * scaleGraphics ); - final int frameSHeightT = (int) ( frameHeightT * scaleGraphics ); + final int frameSWidth = (int) ( frameWidth * scaleGraphics ); + final int frameSHeight = (int) ( frameHeight * scaleGraphics ); final double scaleComp72; { - final double sx = pf.getImageableWidth() / (double)frameSWidthT; - final double sy = pf.getImageableHeight() / (double)frameSHeightT; + final double sx = pf.getImageableWidth() / (double)frameSWidth; + final double sy = pf.getImageableHeight() / (double)frameSHeight; scaleComp72 = Math.min(sx, sy); } System.err.println("PRINT.offscrn thread "+Thread.currentThread().getName()); System.err.println("PRINT.offscrn DPI: scaleGraphics "+scaleGraphics+", scaleComp72 "+scaleComp72); System.err.println("PRINT.offscrn DPI: frame: border "+frameInsets+", size "+frameWidth+"x"+frameHeight+ - " -> total "+frameWidthT+ "x" + frameHeightT+ - " -> scaled "+frameSWidthT+ "x" + frameSHeightT); + " -> scaled "+frameSWidth+ "x" + frameSHeight); - final BufferedImage image = DirectDataBufferInt.createBufferedImage(frameSWidthT, frameSHeightT, imageType, null /* location */, null /* properties */); + final BufferedImage image = DirectDataBufferInt.createBufferedImage(frameSWidth, frameSHeight, imageType, null /* location */, null /* properties */); { System.err.println("PRINT.offscrn image "+image); final Graphics2D g2d = (Graphics2D) image.getGraphics(); - g2d.setClip(0, 0, frameSWidthT, frameSHeightT); + g2d.setClip(0, 0, frameSWidth, frameSHeight); g2d.scale(scaleGraphics, scaleGraphics); // g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - // g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { cont.printAll(g2d); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java index a23f7f8c3..7e8bac295 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java @@ -120,33 +120,31 @@ public class OnscreenPrintable extends PrintableBase implements Printable { /** * See: 'Scaling of Frame and GL content' in Class description! + * Note: Frame size contains the frame border (i.e. insets)! */ final Insets frameInsets = cont.getInsets(); final int frameWidth = cont.getWidth(); final int frameHeight= cont.getHeight(); - final int frameWidthT = frameWidth + frameInsets.left + frameInsets.right; - final int frameHeightT = frameHeight + frameInsets.top + frameInsets.bottom; final double scaleGraphics = dpi / 72.0; - final int frameSWidthT = (int) ( frameWidthT * scaleGraphics ); - final int frameSHeightT = (int) ( frameHeightT * scaleGraphics ); + final int frameSWidth = (int) ( frameWidth * scaleGraphics ); + final int frameSHeight = (int) ( frameHeight * scaleGraphics ); final double scaleComp72; { - final double sx = pf.getImageableWidth() / (double)frameWidthT; - final double sy = pf.getImageableHeight() / (double)frameHeightT; + final double sx = pf.getImageableWidth() / (double)frameWidth; + final double sy = pf.getImageableHeight() / (double)frameHeight; scaleComp72 = Math.min(sx, sy); } System.err.println("PRINT.onscrn thread "+Thread.currentThread().getName()); System.err.println("PRINT.onscrn DPI: scaleGraphics "+scaleGraphics+", scaleComp72 "+scaleComp72); System.err.println("PRINT.onscrn DPI: frame: border "+frameInsets+", size "+frameWidth+"x"+frameHeight+ - " -> total "+frameWidthT+ "x" + frameHeightT+ - " -> scaled "+frameSWidthT+ "x" + frameSHeightT); + " -> scaled "+frameSWidth+ "x" + frameSHeight); final Graphics2D g2d = (Graphics2D)g; System.err.println("PRINT at.pre: "+g2d.getTransform()); g2d.translate(pf.getImageableX(), pf.getImageableY()); g2d.scale(scaleComp72, scaleComp72); // WARNING: Produces rounding artifacts due to diff scale-factor of AWT/GL comps !!! // g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - // g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java index 3198212b5..0fe08ebc2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java @@ -36,6 +36,7 @@ import java.awt.Frame; import java.awt.Graphics2D; import java.awt.Insets; import java.awt.Label; +import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.File; @@ -105,11 +106,10 @@ public class TestTiledPrintingNIOImageSwingAWT extends UITestCase { final int imageWidth = image.getWidth(); final int imageHeight= image.getHeight(); final double scaleComp72; + // Note: Frame size contains the frame border (i.e. insets)! { - final double frameBorderW = frameInsets.left + frameInsets.right; - final double frameBorderH = frameInsets.top + frameInsets.bottom; - final double sx = (double)imageWidth / ( frameWidth + frameBorderW ); - final double sy = (double)imageHeight / ( frameHeight + frameBorderH ); + final double sx = (double)imageWidth / frameWidth; + final double sy = (double)imageHeight / frameHeight; scaleComp72 = Math.min(sx, sy); } System.err.println("PRINT DPI: scaleComp72 "+scaleComp72+", image-size "+imageWidth+"x"+imageHeight+", frame[border "+frameInsets+", size "+frameWidth+"x"+frameHeight+"]"); @@ -125,7 +125,7 @@ public class TestTiledPrintingNIOImageSwingAWT extends UITestCase { g2d.setClip(0, 0, image.getWidth(), image.getHeight()); g2d.scale(scaleComp72, scaleComp72); // g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - // g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); // frame.paintAll(g2d); final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, 1.0/scaleComp72, 1.0/scaleComp72, 0); -- cgit v1.2.3 From 3abff83dbc0a99c8d227788c9dddbe59cd15b9ba Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 27 Sep 2013 15:31:17 +0200 Subject: Fix Bug 816: JAWTWindow.getLocationOnScreenNonBlocking(..) shall use JRootPane for last position offset; AWTMisc.getInsets(..) add special JRootPane case. Please note that we use JAWTWindow.getLocationOnScreenNonBlocking(..) to determine the location on the screen 'only' b/c we cannot allow AWT to aquire the tree-lock! The latter would be the case if using AWT's 'getLocationOnScreen()'. If anybody has a more reliable implementation to achieve the same .. please provide your patch! The following fix has been performed to fix the last issue w/ vZome. - JAWTWindow.getLocationOnScreenNonBlocking(..) shall use JRootPane for last position offset - w/ vZome, the frame's position was 0/0 (invalid), instead JRootPane's position is good. Use JRootPane's position and stop traversing here (LW top-level). - AWTMisc.getInsets(..) add special JRootPane case. + * Exception is JRootPane. + * Return it's parent's Window component's insets if available, + * otherwise return JRootPane's insets.
        + * This is due to experience that some JRootPane's + * do not expose valid insets value. - --- make/scripts/tests.sh | 4 ++-- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 24 ++++++++++++---------- .../classes/jogamp/nativewindow/awt/AWTMisc.java | 18 ++++++++++++++++ 3 files changed, 33 insertions(+), 13 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 442b12672..8c58efb3f 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -332,7 +332,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -454,7 +454,7 @@ testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 576fcf4ed..5b5df7f68 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -64,6 +64,7 @@ import javax.media.nativewindow.util.RectangleImmutable; import javax.swing.JRootPane; import jogamp.nativewindow.SurfaceUpdatedHelper; +import jogamp.nativewindow.awt.AWTMisc; import jogamp.nativewindow.jawt.JAWT; import jogamp.nativewindow.jawt.JAWTUtil; import jogamp.nativewindow.jawt.JAWT_Rectangle; @@ -577,17 +578,18 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, while(null != comp) { final int dx = comp.getX(); final int dy = comp.getY(); - if( ! ( comp instanceof JRootPane ) ) { - if( DEBUG ) { - System.err.print("LOS: "+storage+" + "+comp.getClass().getSimpleName()+"["+dx+"/"+dy+"] -> "); - } - storage.translate(dx, dy); - if( DEBUG ) { - System.err.println(storage); - } - last = comp; - } else if( DEBUG ) { - System.err.println("LOS: ignore "+comp.getClass().getSimpleName()+"["+dx+"/"+dy+"]"); + if( DEBUG ) { + final java.awt.Insets ins = AWTMisc.getInsets(comp); + System.err.print("LOS: "+storage+" + "+comp.getClass().getName()+"["+dx+"/"+dy+", vis "+comp.isVisible()+", ins "+ins+"] -> "); + } + storage.translate(dx, dy); + if( DEBUG ) { + System.err.println(storage); + } + last = comp; + if( comp instanceof JRootPane ) { + // LW JRootPane is considered a top-level component! + break; } comp = comp.getParent(); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index e326b65bd..611c13a22 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -72,10 +72,28 @@ public class AWTMisc { return (Container) c; } + /** + * Return insets of the component w/o traversing up to parent, + * i.e. trying Window and JComponent. + *

        + * Exception is JRootPane. + * Return it's parent's Window component's insets if available, + * otherwise return JRootPane's insets.
        + * This is due to experience that some JRootPane's + * do not expose valid insets value. + *

        + */ public static Insets getInsets(Component c) { if( c instanceof Window ) { return ((Window)c).getInsets(); } + if( c instanceof JRootPane ) { + final Window w = getWindow(c); + if( null != w ) { + return w.getInsets(); + } + return ((JRootPane)c).getInsets(); + } if( c instanceof JComponent ) { return ((JComponent)c).getInsets(); } -- cgit v1.2.3 From 67200852b972f244ecc19d0c54b2f8d8080b0824 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 28 Sep 2013 04:08:59 +0200 Subject: Fix TileRenderer regression of commit c8abb9d2c9a8c92f0c5c42aba13e3e80c69739dc: Test isSetup() _after_ running glEventListenerPre. glEventListenerPre may be utilized to setup the TileRenderer. --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8c58efb3f..b5804c02d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -330,7 +330,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* @@ -454,7 +454,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index f00e59347..f15c79f68 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -584,16 +584,16 @@ public abstract class TileRendererBase { } @Override public void display(GLAutoDrawable drawable) { + if( null != glEventListenerPre ) { + glEventListenerPre.reshape(drawable, 0, 0, currentTileWidth, currentTileHeight); + glEventListenerPre.display(drawable); + } if( !isSetup() ) { if( DEBUG ) { System.err.println("TileRenderer.glel.display: !setup: "+TileRendererBase.this); } return; } - if( null != glEventListenerPre ) { - glEventListenerPre.reshape(drawable, 0, 0, currentTileWidth, currentTileHeight); - glEventListenerPre.display(drawable); - } final GL gl = drawable.getGL(); beginTile(gl); -- cgit v1.2.3 From ac1901608c62ae1c5b82bccc3b2a70193031d5f0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 29 Sep 2013 10:25:32 +0200 Subject: GLJPanel/Printing: Perform backend.reshape immediatly after printing if resized; Add unit test for resize while printing. Perform immediatly reshape at releasePrint on AWT-EDT: - sendReshape = handleReshape(); // reshapeSize -> panelSize, backend reshape w/ GL reshape --- make/scripts/tests.sh | 4 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 24 ++++--- .../junit/jogl/tile/TestTiledPrintingGearsAWT.java | 24 +++++-- .../jogl/tile/TestTiledPrintingGearsNewtAWT.java | 24 +++++-- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 26 ++++--- .../jogl/tile/TestTiledPrintingGearsSwingAWT2.java | 2 +- .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 82 ++++++++++++++++------ 7 files changed, 129 insertions(+), 57 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b5804c02d..442b12672 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -330,9 +330,9 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 589cffeb5..84d085f76 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -489,12 +489,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void reshape(int x, int y, int width, int height) { super.reshape(x, y, width, height); - if (DEBUG) { - System.err.println(getThreadName()+": GLJPanel.reshape: " +reshapeWidth+"x"+reshapeHeight + " -> " + width+"x"+height); + if( DEBUG ) { + System.err.println(getThreadName()+": GLJPanel.reshape resize"+(printActive?"WithinPrint":"")+" [ panel "+ + panelWidth+"x"+panelHeight + + ", reshape: " +reshapeWidth+"x"+reshapeHeight + + "] -> "+(printActive?"skipped":"") + width+"x"+height); } if( !printActive ) { - // reshapeX = x; - // reshapeY = y; reshapeWidth = width; reshapeHeight = height; handleReshape = true; @@ -586,7 +587,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void run() { if( DEBUG ) { - System.err.println("AWT print.release "+printAWTTiles); + System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0 "+printAWTTiles); } printAWTTiles.dispose(); printAWTTiles= null; @@ -603,13 +604,18 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // trigger reshape, i.e. gl-viewport and -listener - this component might got resized! final int awtWidth = GLJPanel.this.getWidth(); final int awtHeight= GLJPanel.this.getHeight(); - if( panelWidth != awtWidth || panelHeight != awtHeight ) { + final GLDrawable drawable = GLJPanel.this.getDelegatedDrawable(); + if( awtWidth != panelWidth || awtHeight != panelHeight || + drawable.getWidth() != panelWidth || drawable.getHeight() != panelHeight ) { + // -> !( awtSize == panelSize == drawableSize ) if ( DEBUG ) { - System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0: reshape " +panelWidth+"x"+panelHeight + " -> " + awtWidth+"x"+awtHeight); - } + System.err.println(getThreadName()+": GLJPanel.releasePrintOnEDT.0: resizeWithinPrint panel " +panelWidth+"x"+panelHeight + + ", draw "+drawable.getWidth()+"x"+drawable.getHeight()+ + " -> " + awtWidth+"x"+awtHeight); + } reshapeWidth = awtWidth; reshapeHeight = awtHeight; - handleReshape = true; // complete resize, sendReshape will be set later + sendReshape = handleReshape(); // reshapeSize -> panelSize, backend reshape w/ GL reshape } else { sendReshape = true; // only GL reshape } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java index af4b41af2..4883df501 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java @@ -178,26 +178,36 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 300, -1); + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 300, -1); + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true/* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java index d600c95a8..a256d964f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java @@ -183,26 +183,36 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 300, -1); + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 300, -1); + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index cd1ae8657..f1759798b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -217,41 +217,51 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB /* offscreen-type */, 150, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_RGB /* offscreen-type */, 150, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_RGB /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_BGR /* offscreen-type */, 150, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_BGR /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java index a89f4dd6e..d18def075 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java @@ -220,7 +220,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { printDone = true; { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, -1 /* offscreen-type */, 150, -1); + final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, -1 /* offscreen-type */, 150, -1, false); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java index 1ec748805..e6179aa95 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java @@ -28,7 +28,10 @@ package com.jogamp.opengl.test.junit.jogl.tile; +import java.awt.Component; import java.awt.Container; +import java.awt.Rectangle; +import java.awt.Window; import java.awt.print.PageFormat; import java.awt.print.Paper; import java.awt.print.Printable; @@ -37,12 +40,15 @@ import java.awt.print.PrinterJob; import java.io.FileNotFoundException; import java.io.FileOutputStream; +import javax.media.opengl.GLAutoDrawable; import javax.print.StreamPrintService; import javax.print.StreamPrintServiceFactory; import javax.print.attribute.HashPrintRequestAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.MediaSizeName; +import jogamp.nativewindow.awt.AWTMisc; + import org.junit.Assert; import com.jogamp.common.util.awt.AWTEDTExecutor; @@ -73,8 +79,9 @@ public abstract class TiledPrintingAWTBase extends UITestCase { * @param offscrnImageType if < 0 onscreen, otherwise integer BufferedImage type * @param dpi * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param resizeWithinPrintTest TODO */ - public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper, int offscrnImageType, int dpi, int numSamples) { + public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper, int offscrnImageType, int dpi, int numSamples, boolean resizeWithinPrintTest) { lock.lock(); try { final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); @@ -91,12 +98,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase { StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(pdfMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "pdf"); + final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "pdf", resizeWithinPrintTest); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples); + return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, resizeWithinPrintTest); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -105,12 +112,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase { factories = PrinterJob.lookupStreamPrintServices(psMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "ps"); + final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "ps", resizeWithinPrintTest); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples); + return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, resizeWithinPrintTest); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -121,15 +128,17 @@ public abstract class TiledPrintingAWTBase extends UITestCase { lock.unlock(); } } - private String getPrintFilename(int offscrnImageType, int dpi, int numSamples, String suffix) { + private String getPrintFilename(int offscrnImageType, int dpi, int numSamples, String suffix, boolean resizeWithinPrintTest) { final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; final String simpleTestName = getSimpleTestName("."); final String onoffscrn = 0 > offscrnImageType ? "on_screen" : "offscrn_"+offscrnImageType; - return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-%s-dpi%03d-aa%d.%s", simpleTestName, printCount, onoffscrn, dpi, numSamples, suffix).replace(' ', '_'); + final String aa = 0 <= numSamples ? "aa"+numSamples : "aaN"; + return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-%s-dpi%03d-%s-resize%d.%s", + simpleTestName, printCount, onoffscrn, dpi, aa, resizeWithinPrintTest?1:0, suffix).replace(' ', '_'); } private PrintableBase doPrintAutoImpl(Container cont, PrinterJob job, StreamPrintService ps, int pOrientation, Paper paper, - int offscrnImageType, int dpi, int numSamples) { + int offscrnImageType, int dpi, int numSamples, boolean resizeWithinPrintTest) { try { PageFormat pageFormat = job.defaultPage(); if( null != paper ) { @@ -143,12 +152,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase { job.setPrintService(ps); final PrintableBase printable; if( 0 < offscrnImageType ) { - printable = new OffscreenPrintable(job, cont, dpi, numSamples, offscrnImageType, getPrintFilename(offscrnImageType, dpi, numSamples, "png")); + printable = new OffscreenPrintable(job, cont, dpi, numSamples, offscrnImageType, getPrintFilename(offscrnImageType, dpi, numSamples, "png", resizeWithinPrintTest)); } else { printable = new OnscreenPrintable(job, cont, dpi, numSamples); } printable.job.setPrintable(printable, pageFormat); - doPrintImpl(printable); + doPrintImpl(printable, resizeWithinPrintTest); return printable; } catch (PrinterException pe) { pe.printStackTrace(); @@ -169,7 +178,7 @@ public abstract class TiledPrintingAWTBase extends UITestCase { printable.job.setPrintable(printable); boolean ok = printable.job.printDialog(); if (ok) { - doPrintImpl(printable); + doPrintImpl(printable, false); } return printable; } finally { @@ -177,36 +186,63 @@ public abstract class TiledPrintingAWTBase extends UITestCase { } } - static final boolean resizeAfterSetupPrint = false; - - private void doPrintImpl(final PrintableBase printable) { + private final AWTMisc.ComponentAction resizePlusAction = new AWTMisc.ComponentAction() { + @Override + public void run(Component c) { + final Rectangle r = c.getBounds(); + r.width += 64; + r.height += 64; + c.setBounds(r); + } }; + private final AWTMisc.ComponentAction resizeMinusAction = new AWTMisc.ComponentAction() { + @Override + public void run(Component c) { + final Rectangle r = c.getBounds(); + r.width -= 64; + r.height -= 64; + c.setBounds(r); + } }; + + private void doPrintImpl(final PrintableBase printable, final boolean resizeWithinPrintTest) { final double scaleGLMatXY = 72.0 / printable.dpi; System.err.println("PRINTable: "+printable.getClass().getSimpleName()); System.err.println("PRINT DPI: "+printable.dpi+", AA "+printable.numSamples+", scaleGL "+scaleGLMatXY); final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(printable.cont, scaleGLMatXY, scaleGLMatXY, printable.numSamples); System.err.println("PRINT AWTPrintLifecycle.setup.count "+ctx.getCount()); + final int w = printable.cont.getWidth(); + final int h = printable.cont.getHeight(); try { AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { try { - final int w = printable.cont.getWidth(); - final int h = printable.cont.getHeight(); - if( resizeAfterSetupPrint ) { - printable.cont.setSize(w+64, h+64); + if( resizeWithinPrintTest ) { + System.err.println("PRINT resizeWithinPrint size+ "+(w+64)+"x"+(h+64)); + AWTMisc.performAction(printable.cont, GLAutoDrawable.class, resizePlusAction); printable.cont.validate(); + if( printable.cont instanceof Window ) { + ((Window)printable.cont).pack(); + } } printable.job.print(); - if( resizeAfterSetupPrint ) { - printable.cont.repaint(); - printable.cont.setSize(w, h); - printable.cont.validate(); - } } catch (PrinterException ex) { ex.printStackTrace(); } } }); } finally { ctx.releasePrint(); + if( resizeWithinPrintTest ) { + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + System.err.println("PRINT resizeWithinPrint repaint"); + printable.cont.repaint(); + System.err.println("PRINT resizeWithinPrint size- "+w+"x"+h); + AWTMisc.performAction(printable.cont, GLAutoDrawable.class, resizeMinusAction); + printable.cont.validate(); + if( printable.cont instanceof Window ) { + ((Window)printable.cont).pack(); + } + } }); + } System.err.println("PRINT AWTPrintLifecycle.release.count "+ctx.getCount()); } } -- cgit v1.2.3 From 00062e490f0b0cc2944a2167f2f00149c8ba352e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 1 Oct 2013 15:36:56 +0200 Subject: test scripts/setenv-jogl.sh: Remove JogAmp *LD_LIBRARY_PATH components. --- make/scripts/setenv-jogl.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh index 5e4bb5707..186da5505 100755 --- a/make/scripts/setenv-jogl.sh +++ b/make/scripts/setenv-jogl.sh @@ -113,8 +113,8 @@ CLASSPATH=.:"$GLUEGEN_JAR":"$JOAL_JAR":"$JOGL_CLASSPATH":"$SWT_CLASSPATH":"$JUNI export CLASSPATH # We use TempJarCache per default now! -export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$GLUEGEN_OS":"$JOGL_LIB_DIR" -export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH":"$GLUEGEN_OS:"$JOGL_LIB_DIR" +#export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$GLUEGEN_OS":"$JOGL_LIB_DIR" +#export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH":"$GLUEGEN_OS:"$JOGL_LIB_DIR" echo JOGAMP_ALL_AWT_CLASSPATH: "$JOGAMP_ALL_AWT_CLASSPATH" echo JOGAMP_ALL_NOAWT_CLASSPATH: "$JOGAMP_ALL_NOAWT_CLASSPATH" -- cgit v1.2.3 From 543c8649f43fdc43028075d7472ad553299271bf Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 2 Oct 2013 01:12:20 +0200 Subject: GLJPanel/AWTGLPixelBuffer: Reused BufferedImage didn't account for row-stride (regression of b33bdf41cf53f37203643a8551bf5d94b42a8fab) SingleAWTGLPixelBufferProvider w/ allowing row-stride reuses the AWTGLPixelBuffer and it's BufferedImage even w/ different width. This leads to distortion if using the BufferedImage unhandled. GLJPanel also set GL_PACK_ROW_LENGTH to pixelBuffer.width, which leads to an 'out-of-bounds' exception if ReadPixels is used w/ panelwidth and panelHeight. ++ Introduce AWTGLPixelBuffer.getAlignedImage(width, height) which returns an aligned BufferedImage while reusing the DataBuffer. GLJPanel fetches a new alignedImage if required. This allows a more efficient single buffer usage as intended, w/o the need of copying data. --- make/scripts/tests.sh | 4 +-- .../jogamp/opengl/util/awt/AWTGLPixelBuffer.java | 39 +++++++++++++++++++++- .../classes/javax/media/opengl/awt/GLJPanel.java | 26 ++++++++++----- 3 files changed, 57 insertions(+), 12 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 442b12672..068859b55 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -296,7 +296,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* @@ -332,7 +332,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java index 1f5bb6acc..9d2ef6572 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java @@ -28,7 +28,11 @@ package com.jogamp.opengl.util.awt; import java.awt.image.BufferedImage; +import java.awt.image.ColorModel; +import java.awt.image.DataBuffer; import java.awt.image.DataBufferInt; +import java.awt.image.SinglePixelPackedSampleModel; +import java.awt.image.WritableRaster; import java.nio.Buffer; import java.nio.IntBuffer; @@ -36,7 +40,6 @@ import javax.media.opengl.GL; import com.jogamp.common.nio.Buffers; import com.jogamp.opengl.util.GLPixelBuffer; -import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; /** * AWT {@link GLPixelBuffer} backed by an {@link BufferedImage} of type @@ -51,6 +54,10 @@ import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; *

        * See {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)} for {@link #allowRowStride} details. *

        + *

        + * If using allowRowStride == true, user may needs to get the {@link #getAlignedImage(int, int) aligned image} + * since {@link #requiresNewBuffer(GL, int, int, int)} will allow different width in this case. + *

        */ public class AWTGLPixelBuffer extends GLPixelBuffer { public static final GLPixelAttributes awtPixelAttributesIntRGBA4 = new GLPixelAttributes(4, GL.GL_BGRA, GL.GL_UNSIGNED_BYTE); @@ -60,6 +67,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { public final BufferedImage image; /** + * * @param pixelAttributes the desired {@link GLPixelAttributes} * @param width in pixels * @param height in pixels @@ -68,6 +76,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { * @param image the AWT image * @param buffer the backing array * @param allowRowStride If true, allow row-stride, otherwise not. See {@link #requiresNewBuffer(GL, int, int, int)}. + * If true, user shall decide whether to use a {@link #getAlignedImage(int, int) width-aligned image}. */ public AWTGLPixelBuffer(GLPixelAttributes pixelAttributes, int width, int height, int depth, boolean pack, BufferedImage image, Buffer buffer, boolean allowRowStride) { @@ -81,6 +90,33 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { super.dispose(); } + /** + * Returns a width- and height-aligned image representation sharing data w/ {@link #image}. + * @param width + * @param height + * @return + * @throws IllegalArgumentException if requested size exceeds image size + */ + public BufferedImage getAlignedImage(int width, int height) throws IllegalArgumentException { + if( width * height > image.getWidth() * image.getHeight() ) { + throw new IllegalArgumentException("Requested size exceeds image size: "+width+"x"+height+" > "+image.getWidth()+"x"+image.getHeight()); + } + if( width == image.getWidth() ) { + if( height == image.getHeight() ) { + return image; + } + return image.getSubimage(0, 0, width, height); + } + final ColorModel cm = image.getColorModel(); + final WritableRaster raster = image.getRaster(); + final DataBuffer dataBuffer = raster.getDataBuffer(); + final SinglePixelPackedSampleModel sppsm0 = (SinglePixelPackedSampleModel) raster.getSampleModel(); + final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), + width, height, width /* scanLineStride */, sppsm0.getBitMasks()); + final WritableRaster raster1 = WritableRaster.createWritableRaster(sppsm1, dataBuffer, null); + return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null); + } + public StringBuilder toString(StringBuilder sb) { sb = super.toString(sb); sb.append(", allowRowStride ").append(allowRowStride).append(", image [").append(image.getWidth()).append("x").append(image.getHeight()).append(", ").append(image.toString()).append("]"); @@ -99,6 +135,7 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { /** * @param allowRowStride If true, allow row-stride, otherwise not. * See {@link #getAllowRowStride()} and {@link AWTGLPixelBuffer#requiresNewBuffer(GL, int, int, int)}. + * If true, user shall decide whether to use a {@link AWTGLPixelBuffer#getAlignedImage(int, int) width-aligned image}. */ public AWTGLPixelBufferProvider(boolean allowRowStride) { this.allowRowStride = allowRowStride; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 84d085f76..7002fabb6 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -1236,6 +1236,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final AWTGLPixelBufferProvider pixelBufferProvider; private final boolean useSingletonBuffer; private AWTGLPixelBuffer pixelBuffer; + private BufferedImage alignedImage; // One of these is used to store the read back pixels before storing // in the BufferedImage @@ -1255,8 +1256,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing OffscreenBackend(GLProfile glp, AWTGLPixelBufferProvider custom) { if(null == custom) { - pixelBufferProvider = glp.isGL2ES3() ? getSingleAWTGLPixelBufferProvider() : - new AWTGLPixelBufferProvider( false /* allowRowStride */ ) ; + pixelBufferProvider = getSingleAWTGLPixelBufferProvider(); } else { pixelBufferProvider = custom; } @@ -1382,6 +1382,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } pixelBuffer = null; } + alignedImage = null; } @Override @@ -1389,6 +1390,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if ( opaque != isOpaque() && !useSingletonBuffer ) { pixelBuffer.dispose(); pixelBuffer = null; + alignedImage = null; } } @@ -1423,6 +1425,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if( null != pixelBuffer && pixelBuffer.requiresNewBuffer(gl, panelWidth, panelHeight, 0) ) { pixelBuffer.dispose(); pixelBuffer = null; + alignedImage = null; } if ( null == pixelBuffer ) { if (0 >= panelWidth || 0 >= panelHeight ) { @@ -1439,6 +1442,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if( offscreenDrawable.getWidth() != panelWidth || offscreenDrawable.getHeight() != panelHeight ) { throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()+", on thread "+getThreadName()); } + if( null == alignedImage || panelWidth != alignedImage.getWidth() || panelHeight != alignedImage.getHeight() ) { + alignedImage = pixelBuffer.getAlignedImage(panelWidth, panelHeight); + if(DEBUG) { + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: alignedImage "+alignedImage.getWidth()+"x"+alignedImage.getHeight()+", pixelBuffer "+pixelBuffer.width+"x"+pixelBuffer.height); + } + } final IntBuffer readBackInts; if( !flipVertical || null != glslTextureRaster ) { @@ -1475,7 +1484,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing psm.setAlignment(gl, alignment, alignment); if(gl.isGL2ES3()) { final GL2ES3 gl2es3 = gl.getGL2ES3(); - gl2es3.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, pixelBuffer.width); + gl2es3.glPixelStorei(GL2ES3.GL_PACK_ROW_LENGTH, panelWidth); gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer()); } @@ -1522,12 +1531,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // blitting Note that we could avoid this copy in the cases // where !offscreenDrawable.isGLOriented(), // but that's the software rendering path which is very slow anyway. - final BufferedImage image = pixelBuffer.image; + final BufferedImage image = alignedImage; final int[] src = readBackInts.array(); final int[] dest = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); - final int incr = pixelBuffer.width; + final int incr = panelWidth; int srcPos = 0; - int destPos = (panelHeight - 1) * pixelBuffer.width; + int destPos = (panelHeight - 1) * panelWidth; for (; destPos >= 0; srcPos += incr, destPos -= incr) { System.arraycopy(src, srcPos, dest, destPos, incr); } @@ -1557,10 +1566,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing public void doPaintComponent(Graphics g) { helper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction); - if ( null != pixelBuffer ) { - final BufferedImage image = pixelBuffer.image; + if ( null != alignedImage ) { // Draw resulting image in one shot - g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null); // Null ImageObserver since image data is ready. + g.drawImage(alignedImage, 0, 0, alignedImage.getWidth(), alignedImage.getHeight(), null); // Null ImageObserver since image data is ready. } } -- cgit v1.2.3 From 60968cdc388b6a7464da3a6b58f25cb61e29f681 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 3 Oct 2013 15:07:07 +0200 Subject: Bug 816: Add 2 more unit tests (Swing JFrame w/ 2 JRootPanes, AWT Frame BorderLayout w/ Checkbox North, GLCanvas Center) Thx to Emmanuel Puybaret --- make/scripts/tests.sh | 6 +- .../jogl/awt/TestBug816OSXCALayerPos01AWT.java | 486 ++++++++++++++++++++ .../jogl/awt/TestBug816OSXCALayerPos02AWT.java | 150 ++++++ .../jogl/awt/TestBug816OSXCALayerPos03AWT.java | 152 ++++++ .../junit/jogl/awt/TestBug816OSXCALayerPosAWT.java | 509 --------------------- 5 files changed, 792 insertions(+), 511 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPosAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 068859b55..d4e367759 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -296,7 +296,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* @@ -454,7 +454,9 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPosAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java new file mode 100644 index 000000000..c103b4b86 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java @@ -0,0 +1,486 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import javax.media.opengl.*; + +import com.jogamp.opengl.util.Animator; + +import javax.media.opengl.awt.GLCanvas; +import javax.swing.BoundedRangeModel; +import javax.swing.BoxLayout; +import javax.swing.JFrame; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.ScrollPaneConstants; + +import com.jogamp.common.util.awt.AWTEDTExecutor; +import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.util.QuitAdapter; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.GridLayout; +import java.lang.reflect.InvocationTargetException; + +import org.junit.Assert; +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +/** + * Bug 816: OSX CALayer Positioning Bug. + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos01AWT extends UITestCase { + public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box, Split }; + + static long duration = 1600; // ms + static int width, height; + + static boolean forceES2 = false; + static boolean forceGL3 = false; + static int swapInterval = 1; + static java.awt.Dimension rwsize; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + rwsize = new Dimension(800, 600); + } + + @AfterClass + public static void releaseClass() { + } + + static void setComponentSize(final Frame frame, final Component comp1, final java.awt.Dimension new_sz1, final Component comp2, final java.awt.Dimension new_sz2) { + try { + AWTEDTExecutor.singleton.invoke(true /* wait */, new Runnable() { + public void run() { + comp1.setMinimumSize(new_sz1); + comp1.setPreferredSize(new_sz1); + comp1.setSize(new_sz1); + if( null != comp2 ) { + comp2.setMinimumSize(new_sz2); + comp2.setPreferredSize(new_sz2); + comp2.setSize(new_sz2); + } + if( null != frame ) { + frame.pack(); + } + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + static void setFrameSize(final Frame frame, final boolean frameLayout, final java.awt.Dimension new_sz) { + try { + AWTEDTExecutor.singleton.invoke(true /* wait */, new Runnable() { + public void run() { + frame.setSize(new_sz); + if( frameLayout ) { + frame.validate(); + } + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + } + + protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout, final boolean twoCanvas, final boolean resizeByComp) throws InterruptedException, InvocationTargetException { + final JFrame frame = new JFrame("Bug861: "+this.getTestMethodName()); + Assert.assertNotNull(frame); + final Container framePane = frame.getContentPane(); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + final GLCanvas glCanvas2; + if( twoCanvas ) { + glCanvas2 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas2); + } else { + glCanvas2 = null; + } + + final Dimension glcDim = new Dimension(width/2, height); + final Dimension frameDim = new Dimension(twoCanvas ? width + 64: width/2 + 64, height + 64); + + setComponentSize(null, glCanvas1, glcDim, glCanvas2, glcDim); + + switch( frameLayout) { + case None: { + framePane.add(glCanvas1); + } + break; + case Flow: { + final Container c = new Container(); + c.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); + c.add(glCanvas1); + if( twoCanvas ) { + c.add(glCanvas2); + } + framePane.add(c); + } + break; + case DoubleBorderCenterSurrounded: { + final Container c = new Container(); + c.setLayout(new BorderLayout()); + c.add(new Button("north"), BorderLayout.NORTH); + c.add(new Button("south"), BorderLayout.SOUTH); + c.add(new Button("east"), BorderLayout.EAST); + c.add(new Button("west"), BorderLayout.WEST); + if( twoCanvas ) { + final Container c2 = new Container(); + c2.setLayout(new GridLayout(1, 2)); + c2.add(glCanvas1); + c2.add(glCanvas2); + c.add(c2, BorderLayout.CENTER); + } else { + c.add(glCanvas1, BorderLayout.CENTER); + } + framePane.setLayout(new BorderLayout()); + framePane.add(new Button("NORTH"), BorderLayout.NORTH); + framePane.add(new Button("SOUTH"), BorderLayout.SOUTH); + framePane.add(new Button("EAST"), BorderLayout.EAST); + framePane.add(new Button("WEST"), BorderLayout.WEST); + framePane.add(c, BorderLayout.CENTER); + } + break; + case Box: { + final Container c = new Container(); + c.setLayout(new BoxLayout(c, BoxLayout.X_AXIS)); + c.add(glCanvas1); + if( twoCanvas ) { + c.add(glCanvas2); + } + framePane.add(c); + } + break; + case Split: { + Dimension sbDim = new Dimension(16, 16); + JScrollPane vsp = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + { + JScrollBar vsb = vsp.getVerticalScrollBar(); + vsb.setPreferredSize(sbDim); + BoundedRangeModel model = vsb.getModel(); + model.setMinimum(0); + model.setMaximum(100); + model.setValue(50); + model.setExtent(1); + vsb.setEnabled(true); + } + JScrollPane hsp = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + { + JScrollBar hsb = hsp.getHorizontalScrollBar(); + hsb.setPreferredSize(sbDim); + BoundedRangeModel model = hsb.getModel(); + model.setMinimum(0); + model.setMaximum(100); + model.setValue(50); + model.setExtent(1); + hsb.setEnabled(true); + } + JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, + twoCanvas ? glCanvas2 : vsp, glCanvas1 ); + horizontalSplitPane.setResizeWeight(0.5); + JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + true, horizontalSplitPane, hsp); + verticalSplitPane.setResizeWeight(0.5); + framePane.add(verticalSplitPane); + } + break; + } + final GearsES2 demo1 = new GearsES2(swapInterval); + glCanvas1.addGLEventListener(demo1); + if( twoCanvas ) { + final RedSquareES2 demo2 = new RedSquareES2(swapInterval); + glCanvas2.addGLEventListener(demo2); + } + + final Animator animator = new Animator(); + animator.add(glCanvas1); + if( twoCanvas ) { + animator.add(glCanvas2); + } + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + if( resizeByComp ) { + frame.pack(); + } else { + setFrameSize(frame, true, frameDim); + } + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + if( twoCanvas ) { + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas2, true)); + } + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + System.err.println("canvas1 pos/siz: "+glCanvas1.getX()+"/"+glCanvas1.getY()+" "+glCanvas1.getWidth()+"x"+glCanvas1.getHeight()); + if( twoCanvas ) { + System.err.println("canvas2 pos/siz: "+glCanvas2.getX()+"/"+glCanvas2.getY()+" "+glCanvas2.getWidth()+"x"+glCanvas2.getHeight()); + } + + Thread.sleep(Math.max(1000, duration/2)); + final Dimension compRSizeHalf = new Dimension(rwsize.width/2, rwsize.height); + final Dimension frameRSizeHalf = new Dimension(twoCanvas ? rwsize.width + 64: rwsize.width/2 + 64, rwsize.height + 64); + if( resizeByComp ) { + setComponentSize(frame, glCanvas1, compRSizeHalf, glCanvas2, compRSizeHalf); + } else { + setFrameSize(frame, true, frameRSizeHalf); + } + System.err.println("resize canvas1 pos/siz: "+glCanvas1.getX()+"/"+glCanvas1.getY()+" "+glCanvas1.getWidth()+"x"+glCanvas1.getHeight()); + if( twoCanvas ) { + System.err.println("resize canvas2 pos/siz: "+glCanvas2.getX()+"/"+glCanvas2.getY()+" "+glCanvas2.getWidth()+"x"+glCanvas2.getHeight()); + } + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + if( twoCanvas ) { + Assert.assertNotNull(glCanvas2); + } else { + Assert.assertNull(glCanvas2); + } + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas1); + if( twoCanvas ) { + frame.remove(glCanvas2); + } + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + @Test + public void test00_Compo_None_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 0 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.None, false /* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test01_Compo_Flow_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 1 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Flow, false /* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test02_Compo_DblBrd_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 2 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, false /* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test03_Compo_Box_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 3 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Box, false /* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test04_Compo_Split_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 4 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Split, false /* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test05_Compo_Flow_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 5 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test06_Compo_DblBrd_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 6 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test07_Compo_Box_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 7 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test08_Compo_Split_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 8 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Split, true/* twoCanvas */, true /* resizeByComp */); + } + + @Test + public void test10_Frame_None_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 10 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.None, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test11_Frame_Flow_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 11 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Flow, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test12_Frame_DblBrd_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 12 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test13_Frame_Box_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 13 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Box, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test14_Frame_Split_One() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 14) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Split, false /* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test15_Frame_Flow_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 15 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test16_Frame_DblBrd_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 16 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test17_Frame_Box_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 17 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, false /* resizeByComp */); + } + + @Test + public void test18_Frame_Split_Two() throws InterruptedException, InvocationTargetException { + if( testNum != -1 && testNum != 18 ) { return ; } + final GLCapabilities caps = new GLCapabilities(getGLP()); + runTestGL(caps, FrameLayout.Split, true/* twoCanvas */, false /* resizeByComp */); + } + + static int testNum = -1; + + public static void main(String args[]) { + for(int i=0; i + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos02AWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final JFrame frame = new JFrame("Bug861: "+this.getTestMethodName()); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Build a GUI where the canvas 3D is located at top right of the frame + // and can be resized with split panes dividers + JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + true, new JScrollPane(), glCanvas1); + verticalSplitPane.setResizeWeight(0.5); + JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, + true, new JScrollPane(), verticalSplitPane); + horizontalSplitPane.setResizeWeight(0.5); + JRootPane intermediateRootPane = new JRootPane(); + intermediateRootPane.setContentPane(horizontalSplitPane); + frame.add(intermediateRootPane); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas1); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos03AWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final Frame frame = new Frame("Bug861: "+this.getTestMethodName()); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Create a check box that hides / shows canvas + final Checkbox checkbox = new Checkbox("Visible canvas", true); + checkbox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent ev) { + glCanvas1.setVisible(checkbox.getState()); + System.out.println(glCanvas1.isVisible()); + } + }); + + // Build a GUI that displays canvas and check box + frame.setLayout(new BorderLayout()); + frame.add(glCanvas1, BorderLayout.CENTER); + frame.add(checkbox, BorderLayout.NORTH); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas1); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i - * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 - *

        - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBug816OSXCALayerPosAWT extends UITestCase { - public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box, Split }; - - static long duration = 1600; // ms - static int width, height; - - static boolean forceES2 = false; - static boolean forceGL3 = false; - static int swapInterval = 1; - static Thread awtEDT; - static java.awt.Dimension rwsize; - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - rwsize = new Dimension(800, 600); - try { - EventQueue.invokeAndWait(new Runnable() { - public void run() { - awtEDT = Thread.currentThread(); - } } ); - } catch (Exception e) { - e.printStackTrace(); - Assert.assertNull(e); - } - } - - @AfterClass - public static void releaseClass() { - } - - static void setComponentSize(final Frame frame, final Component comp1, final java.awt.Dimension new_sz1, final Component comp2, final java.awt.Dimension new_sz2) { - try { - AWTEDTExecutor.singleton.invoke(true /* wait */, new Runnable() { - public void run() { - comp1.setMinimumSize(new_sz1); - comp1.setPreferredSize(new_sz1); - comp1.setSize(new_sz1); - if( null != comp2 ) { - comp2.setMinimumSize(new_sz2); - comp2.setPreferredSize(new_sz2); - comp2.setSize(new_sz2); - } - if( null != frame ) { - frame.pack(); - } - } } ); - } catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - } - static void setFrameSize(final Frame frame, final boolean frameLayout, final java.awt.Dimension new_sz) { - try { - AWTEDTExecutor.singleton.invoke(true /* wait */, new Runnable() { - public void run() { - frame.setSize(new_sz); - if( frameLayout ) { - frame.validate(); - } - } } ); - } catch( Throwable throwable ) { - throwable.printStackTrace(); - Assume.assumeNoException( throwable ); - } - } - - protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout, final boolean twoCanvas, final boolean resizeByComp) throws InterruptedException, InvocationTargetException { - final JFrame frame = new JFrame("Bug861: "+this.getTestMethodName()); - Assert.assertNotNull(frame); - final Container framePane = frame.getContentPane(); - - final GLCanvas glCanvas1 = new GLCanvas(caps); - Assert.assertNotNull(glCanvas1); - final GLCanvas glCanvas2; - if( twoCanvas ) { - glCanvas2 = new GLCanvas(caps); - Assert.assertNotNull(glCanvas2); - } else { - glCanvas2 = null; - } - - final Dimension glcDim = new Dimension(width/2, height); - final Dimension frameDim = new Dimension(twoCanvas ? width + 64: width/2 + 64, height + 64); - - setComponentSize(null, glCanvas1, glcDim, glCanvas2, glcDim); - - switch( frameLayout) { - case None: { - framePane.add(glCanvas1); - } - break; - case Flow: { - final Container c = new Container(); - c.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - c.add(glCanvas1); - if( twoCanvas ) { - c.add(glCanvas2); - } - framePane.add(c); - } - break; - case DoubleBorderCenterSurrounded: { - final Container c = new Container(); - c.setLayout(new BorderLayout()); - c.add(new Button("north"), BorderLayout.NORTH); - c.add(new Button("south"), BorderLayout.SOUTH); - c.add(new Button("east"), BorderLayout.EAST); - c.add(new Button("west"), BorderLayout.WEST); - if( twoCanvas ) { - final Container c2 = new Container(); - c2.setLayout(new GridLayout(1, 2)); - c2.add(glCanvas1); - c2.add(glCanvas2); - c.add(c2, BorderLayout.CENTER); - } else { - c.add(glCanvas1, BorderLayout.CENTER); - } - framePane.setLayout(new BorderLayout()); - framePane.add(new Button("NORTH"), BorderLayout.NORTH); - framePane.add(new Button("SOUTH"), BorderLayout.SOUTH); - framePane.add(new Button("EAST"), BorderLayout.EAST); - framePane.add(new Button("WEST"), BorderLayout.WEST); - framePane.add(c, BorderLayout.CENTER); - } - break; - case Box: { - final Container c = new Container(); - c.setLayout(new BoxLayout(c, BoxLayout.X_AXIS)); - c.add(glCanvas1); - if( twoCanvas ) { - c.add(glCanvas2); - } - framePane.add(c); - } - break; - case Split: { - Dimension sbDim = new Dimension(16, 16); - JScrollPane vsp = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - { - JScrollBar vsb = vsp.getVerticalScrollBar(); - vsb.setPreferredSize(sbDim); - BoundedRangeModel model = vsb.getModel(); - model.setMinimum(0); - model.setMaximum(100); - model.setValue(50); - model.setExtent(1); - vsb.setEnabled(true); - } - JScrollPane hsp = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); - { - JScrollBar hsb = hsp.getHorizontalScrollBar(); - hsb.setPreferredSize(sbDim); - BoundedRangeModel model = hsb.getModel(); - model.setMinimum(0); - model.setMaximum(100); - model.setValue(50); - model.setExtent(1); - hsb.setEnabled(true); - } - JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, - twoCanvas ? glCanvas2 : vsp, glCanvas1 ); - horizontalSplitPane.setResizeWeight(0.5); - JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, - true, horizontalSplitPane, hsp); - verticalSplitPane.setResizeWeight(0.5); - framePane.add(verticalSplitPane); - } - break; - } - final GearsES2 demo1 = new GearsES2(swapInterval); - glCanvas1.addGLEventListener(demo1); - if( twoCanvas ) { - final RedSquareES2 demo2 = new RedSquareES2(swapInterval); - glCanvas2.addGLEventListener(demo2); - } - - final Animator animator = new Animator(); - animator.add(glCanvas1); - if( twoCanvas ) { - animator.add(glCanvas2); - } - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - if( resizeByComp ) { - frame.pack(); - } else { - setFrameSize(frame, true, frameDim); - } - frame.setVisible(true); - }}); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); - if( twoCanvas ) { - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas2, true)); - } - - animator.start(); - Assert.assertTrue(animator.isStarted()); - Assert.assertTrue(animator.isAnimating()); - animator.setUpdateFPSFrames(60, System.err); - - System.err.println("canvas1 pos/siz: "+glCanvas1.getX()+"/"+glCanvas1.getY()+" "+glCanvas1.getWidth()+"x"+glCanvas1.getHeight()); - if( twoCanvas ) { - System.err.println("canvas2 pos/siz: "+glCanvas2.getX()+"/"+glCanvas2.getY()+" "+glCanvas2.getWidth()+"x"+glCanvas2.getHeight()); - } - - Thread.sleep(Math.max(1000, duration/2)); - final Dimension compRSizeHalf = new Dimension(rwsize.width/2, rwsize.height); - final Dimension frameRSizeHalf = new Dimension(twoCanvas ? rwsize.width + 64: rwsize.width/2 + 64, rwsize.height + 64); - if( resizeByComp ) { - setComponentSize(frame, glCanvas1, compRSizeHalf, glCanvas2, compRSizeHalf); - } else { - setFrameSize(frame, true, frameRSizeHalf); - } - System.err.println("resize canvas1 pos/siz: "+glCanvas1.getX()+"/"+glCanvas1.getY()+" "+glCanvas1.getWidth()+"x"+glCanvas1.getHeight()); - if( twoCanvas ) { - System.err.println("resize canvas2 pos/siz: "+glCanvas2.getX()+"/"+glCanvas2.getY()+" "+glCanvas2.getWidth()+"x"+glCanvas2.getHeight()); - } - - final long t0 = System.currentTimeMillis(); - long t1 = t0; - while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - Assert.assertNotNull(frame); - Assert.assertNotNull(glCanvas1); - if( twoCanvas ) { - Assert.assertNotNull(glCanvas2); - } else { - Assert.assertNull(glCanvas2); - } - - Assert.assertNotNull(animator); - animator.stop(); - Assert.assertFalse(animator.isAnimating()); - Assert.assertFalse(animator.isStarted()); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - }}); - Assert.assertEquals(false, frame.isVisible()); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.remove(glCanvas1); - if( twoCanvas ) { - frame.remove(glCanvas2); - } - frame.dispose(); - }}); - } - - static GLProfile getGLP() { - return GLProfile.getMaxProgrammableCore(true); - } - - @Test - public void test00_Compo_None_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 0 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.None, false /* twoCanvas */, true /* resizeByComp */); - } - - @Test - public void test01_Compo_Flow_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 1 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Flow, false /* twoCanvas */, true /* resizeByComp */); - } - - @Test - public void test02_Compo_DblBrd_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 2 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, false /* twoCanvas */, true /* resizeByComp */); - } - - @Test - public void test03_Compo_Box_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 3 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Box, false /* twoCanvas */, true /* resizeByComp */); - } - - @Test - public void test04_Compo_Split_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 4 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Split, false /* twoCanvas */, true /* resizeByComp */); - } - - @Test - public void test05_Compo_Flow_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 5 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, true /* resizeByComp */); - } - - @Test - public void test06_Compo_DblBrd_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 6 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, true /* resizeByComp */); - } - - @Test - public void test07_Compo_Box_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 7 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, true /* resizeByComp */); - } - - @Test - public void test08_Compo_Split_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 8 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Split, true/* twoCanvas */, true /* resizeByComp */); - } - - @Test - public void test10_Frame_None_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 10 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.None, false /* twoCanvas */, false /* resizeByComp */); - } - - @Test - public void test11_Frame_Flow_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 11 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Flow, false /* twoCanvas */, false /* resizeByComp */); - } - - @Test - public void test12_Frame_DblBrd_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 12 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, false /* twoCanvas */, false /* resizeByComp */); - } - - @Test - public void test13_Frame_Box_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 13 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Box, false /* twoCanvas */, false /* resizeByComp */); - } - - @Test - public void test14_Frame_Split_One() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 14) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Split, false /* twoCanvas */, false /* resizeByComp */); - } - - @Test - public void test15_Frame_Flow_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 15 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Flow, true/* twoCanvas */, false /* resizeByComp */); - } - - @Test - public void test16_Frame_DblBrd_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 16 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.DoubleBorderCenterSurrounded, true/* twoCanvas */, false /* resizeByComp */); - } - - @Test - public void test17_Frame_Box_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 17 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Box, true/* twoCanvas */, false /* resizeByComp */); - } - - @Test - public void test18_Frame_Split_Two() throws InterruptedException, InvocationTargetException { - if( testNum != -1 && testNum != 18 ) { return ; } - final GLCapabilities caps = new GLCapabilities(getGLP()); - runTestGL(caps, FrameLayout.Split, true/* twoCanvas */, false /* resizeByComp */); - } - - static int testNum = -1; - - public static void main(String args[]) { - boolean waitForKey = false; - - for(int i=0; i Date: Thu, 3 Oct 2013 20:21:23 +0200 Subject: Bug 818: Enable new quirk GLSLNonCompliant on OSX < 10.7 w/ NV GPU; GLJPanel: Don't use GLSL flip if quirk GLSLNonCompliant is present. --- make/scripts/tests.sh | 4 ++-- .../com/jogamp/opengl/GLRendererQuirks.java | 13 ++++++++++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 11 ++++++++++- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 22 ++++++++++++++++------ 4 files changed, 38 insertions(+), 12 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d4e367759..f49ae4a42 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -296,7 +296,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* @@ -454,7 +454,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 023a8a1aa..6ef1e0805 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -181,15 +181,22 @@ public class GLRendererQuirks { */ public static final int NoFullFBOSupport = 11; - + /** + * GLSL is not compliant or even not stable (crash) + *
          + *
        • OSX < 10.7.0 (?) - NVidia Driver. Bug 818 @ https://jogamp.org/bugzilla/.
        • + *
        + */ + public static final int GLSLNonCompliant = 12; + /** Number of quirks known. */ - public static final int COUNT = 12; + public static final int COUNT = 13; private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", "GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display", "NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext", - "NoFullFBOSupport" + "NoFullFBOSupport", "GLSLNonCompliant" }; private final int _bitmask; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index dae631f2a..fb39143b4 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -93,6 +93,7 @@ import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.nativewindow.awt.AWTPrintLifecycle; import com.jogamp.nativewindow.awt.AWTWindowClosingProtocol; import com.jogamp.opengl.FBObject; +import com.jogamp.opengl.GLRendererQuirks; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.GLPixelBuffer.SingletonGLPixelBufferProvider; import com.jogamp.opengl.util.GLDrawableUtil; @@ -1296,7 +1297,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing flipVertical = offscreenDrawable.isGLOriented(); final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities(); offscreenIsFBO = chosenCaps.isFBO(); - if( USE_GLSL_TEXTURE_RASTERIZER && offscreenIsFBO && flipVertical && gl.isGL2ES2() ) { + final boolean glslCompliant = !offscreenContext.hasRendererQuirk(GLRendererQuirks.GLSLNonCompliant); + final boolean useGLSLFlip = flipVertical && offscreenIsFBO && gl.isGL2ES2() && USE_GLSL_TEXTURE_RASTERIZER && glslCompliant; + if( DEBUG ) { + System.err.println(getThreadName()+": OffscreenBackend.initialize: useGLSLFlip "+useGLSLFlip+ + " [flip "+flipVertical+", isFBO "+offscreenIsFBO+", isGL2ES2 "+gl.isGL2ES2()+ + ", noglsl "+!USE_GLSL_TEXTURE_RASTERIZER+", glslNonCompliant "+!glslCompliant+ + ", isGL2ES2 " + gl.isGL2ES2()+"]"); + } + if( useGLSLFlip ) { final boolean _autoSwapBufferMode = helper.getAutoSwapBufferMode(); helper.setAutoSwapBufferMode(false); final GLFBODrawable fboDrawable = (GLFBODrawable) offscreenDrawable; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index deb80fe7e..7f9f20a21 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1604,13 +1604,23 @@ public abstract class GLContextImpl extends GLContext { quirks[i++] = quirk; } - final VersionNumber osxVersionNVFlushClean = new VersionNumber(10,7,3); // < OSX 10.7.3 w/ NV needs glFlush - if( Platform.getOSVersionNumber().compareTo(osxVersionNVFlushClean) < 0 && isDriverNVIDIAGeForce ) { - final int quirk = GLRendererQuirks.GLFlushBeforeRelease; - if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer); + if( isDriverNVIDIAGeForce ) { + final VersionNumber osxVersionNVFlushClean = new VersionNumber(10,7,3); // < OSX 10.7.3 w/ NV needs glFlush + if( Platform.getOSVersionNumber().compareTo(osxVersionNVFlushClean) < 0 ) { + final int quirk = GLRendererQuirks.GLFlushBeforeRelease; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer); + } + quirks[i++] = quirk; + } + final VersionNumber osxVersionNVGLSLGood = new VersionNumber(10,7,0); // < OSX 10.7.0 w/ NV has instable GLSL + if( Platform.getOSVersionNumber().compareTo(osxVersionNVGLSLGood) < 0 ) { + final int quirk = GLRendererQuirks.GLSLNonCompliant; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer); + } + quirks[i++] = quirk; } - quirks[i++] = quirk; } } else if( Platform.getOSType() == Platform.OSType.WINDOWS ) { // -- cgit v1.2.3 From 50bc843365f65bc6b84a57baa429e32f53fa26e5 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 3 Oct 2013 23:39:43 +0200 Subject: AWTTilePainter: Avoid NPE if Graphic2D's AffineTransform is null, use identity tranform in such case. --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f49ae4a42..434ad5e85 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -296,7 +296,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestOlympicES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestRedSquareES1NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* @@ -332,7 +332,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 2b921f799..fbf6faf08 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -88,10 +88,14 @@ public class AWTTilePainter { System.err.println("Hint["+count+"]: "+rEntry.getKey()+" -> "+rEntry.getValue()); } final AffineTransform aTrans = g2d.getTransform(); - System.err.println(" type "+aTrans.getType()); - System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); - System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); - System.err.println(" mat "+aTrans); + if( null != aTrans ) { + System.err.println(" type "+aTrans.getType()); + System.err.println(" scale "+aTrans.getScaleX()+" x "+aTrans.getScaleY()); + System.err.println(" move "+aTrans.getTranslateX()+" x "+aTrans.getTranslateY()); + System.err.println(" mat "+aTrans); + } else { + System.err.println(" null transform"); + } } /** @@ -188,6 +192,9 @@ public class AWTTilePainter { public void setupGraphics2DAndClipBounds(Graphics2D g2d, int width, int height) throws NoninvertibleTransformException { this.g2d = g2d; saveAT = g2d.getTransform(); + if( null == saveAT ) { + saveAT = new AffineTransform(); // use identity + } // We use double precision for scaling // // Setup original rectangles @@ -201,7 +208,7 @@ public class AWTTilePainter { { final AffineTransform scaledATI; { - final AffineTransform scaledAT = g2d.getTransform(); + final AffineTransform scaledAT = new AffineTransform(saveAT); scaledAT.scale(scaleMatX, scaleMatY); scaledATI = scaledAT.createInverse(); // -> NoninvertibleTransformException } -- cgit v1.2.3 From 703fcd2a237f26c11421bf3ca85beaca4479c9e2 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 5 Oct 2013 13:45:40 +0200 Subject: test scripts (test Bug 729 w/ TestAWTCardLayoutAnimatorStartStopBug532) --- make/scripts/tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 434ad5e85..92730fa8d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -332,7 +332,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -474,7 +474,7 @@ testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug694ScaleImageUnpackBufferSizeAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* -- cgit v1.2.3 From ae103ba597464ca25071950af7afe012e2b86c13 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 5 Oct 2013 16:13:56 +0200 Subject: Bug816 OSX CALayer: getLocationOnScreenNonBlocking(..) stop traversing at top-level heavyweight Window, fixes [J]Dialog use case. Top-level heavyweight Window's position is it's position on screen, hence stop traversing. Thx to Emmanuel Puybaret for pointing this out. Adding Dialog and JDialog unit tests as inspired by Emmanuel Puybaret. --- make/scripts/tests.sh | 4 +- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 4 + .../jogl/awt/TestBug816OSXCALayerPos01AWT.java | 2 +- .../jogl/awt/TestBug816OSXCALayerPos02AWT.java | 2 +- .../jogl/awt/TestBug816OSXCALayerPos03AWT.java | 2 +- .../jogl/awt/TestBug816OSXCALayerPos04aAWT.java | 152 +++++++++++++++++++++ .../jogl/awt/TestBug816OSXCALayerPos04bAWT.java | 152 +++++++++++++++++++++ 7 files changed, 314 insertions(+), 4 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04bAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 92730fa8d..2789c9ea1 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -457,6 +457,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* @@ -474,7 +476,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug694ScaleImageUnpackBufferSizeAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index d9f36901b..069147d26 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -43,6 +43,7 @@ import com.jogamp.nativewindow.MutableGraphicsConfiguration; import java.awt.Component; import java.awt.Container; +import java.awt.Window; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import java.applet.Applet; @@ -598,6 +599,9 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, System.err.println(storage); } last = comp; + if( comp instanceof Window ) { // top-level heavy-weight ? + break; + } comp = comp.getParent(); } return last; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java index c103b4b86..fade6c33a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java @@ -135,7 +135,7 @@ public class TestBug816OSXCALayerPos01AWT extends UITestCase { } protected void runTestGL(GLCapabilities caps, FrameLayout frameLayout, final boolean twoCanvas, final boolean resizeByComp) throws InterruptedException, InvocationTargetException { - final JFrame frame = new JFrame("Bug861: "+this.getTestMethodName()); + final JFrame frame = new JFrame("Bug816: "+this.getTestMethodName()); Assert.assertNotNull(frame); final Container framePane = frame.getContentPane(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java index f82983050..43d536afa 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java @@ -68,7 +68,7 @@ public class TestBug816OSXCALayerPos02AWT extends UITestCase { public void test() throws InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(getGLP()); - final JFrame frame = new JFrame("Bug861: "+this.getTestMethodName()); + final JFrame frame = new JFrame("TestBug816OSXCALayerPos02AWT"); Assert.assertNotNull(frame); final GLCanvas glCanvas1 = new GLCanvas(caps); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java index 09c7669d9..6589cac1e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java @@ -68,7 +68,7 @@ public class TestBug816OSXCALayerPos03AWT extends UITestCase { public void test() throws InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(getGLP()); - final Frame frame = new Frame("Bug861: "+this.getTestMethodName()); + final Frame frame = new Frame("TestBug816OSXCALayerPos03AWT"); Assert.assertNotNull(frame); final GLCanvas glCanvas1 = new GLCanvas(caps); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java new file mode 100644 index 000000000..b558b1680 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos04aAWT.java @@ -0,0 +1,152 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.awt; + +import java.awt.BorderLayout; +import java.awt.Dialog; +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; + +import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.newt.event.awt.AWTWindowAdapter; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Bug 816: OSX CALayer Positioning Bug - AWT Frame w/ (top-level) Dialog child containing the GLCanvas + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos04aAWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final Frame frame = new Frame("TestBug816OSXCALayerPos04aAWT"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Display the canvas 3D in a dialog child of a frame + frame.setSize(400, 400); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setLocation(100, 100); + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + + final Dialog dialog = new Dialog(frame, "Bug 816 AWT Top-Level Dialog"); + dialog.setLayout(new BorderLayout()); + dialog.add(glCanvas1, BorderLayout.CENTER); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + dialog.setLocation(200, 200); + dialog.setSize(width/2, height/2); + dialog.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(dialog, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas1); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos04bAWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final JFrame frame = new JFrame("TestBug816OSXCALayerPos04bAWT"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Display the canvas 3D in a dialog child of a frame + frame.setSize(400, 400); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setLocation(100, 100); + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + + final JDialog dialog = new JDialog(frame, "Bug 816 AWT Top-Level JDialog"); + dialog.setLayout(new BorderLayout()); + dialog.add(glCanvas1, BorderLayout.CENTER); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + dialog.setLocation(200, 200); + dialog.setSize(width/2, height/2); + dialog.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(dialog, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas1); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i Date: Sun, 6 Oct 2013 02:28:14 +0200 Subject: Bug 729: OSX CALayer invisible needs to have opacity 0 to not show hidden component. Completes commit 3b02a219b1b9e446e87df1beb7da4266f74824fa See unit test: TestBug816OSXCALayerPos03AWT --- make/scripts/tests.sh | 4 ++-- src/nativewindow/native/macosx/OSXmisc.m | 13 ++++++++----- .../test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java | 5 ++++- 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2789c9ea1..f3b535058 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -456,9 +456,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index 889e1efd3..3b19440d7 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -336,6 +336,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 @private BOOL fixedFrameSet; CGRect fixedFrame; + float visibleOpacity; } - (id)init; #ifdef DBG_LIFECYCLE @@ -358,6 +359,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 MyCALayer * o = [super init]; o->fixedFrameSet = 0; o->fixedFrame = CGRectMake(0, 0, 0, 0); + o->visibleOpacity = 1.0; DBG_PRINT("MyCALayer::init.X: new %p\n", o); return o; } @@ -457,16 +459,17 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 CGRect superFrame = [superLayer frame]; CGRect lFrame = [self frame]; if( visible ) { - // Setting opacity should not be required, otherwise we should save the opacity value. - // [subLayer setOpacity: 1.0]; - // [self setOpacity: 1.0]; + // Opacity must be 0 to see through the disabled CALayer + [subLayer setOpacity: visibleOpacity]; + [self setOpacity: visibleOpacity]; [self setHidden: NO]; [subLayer setHidden: NO]; } else { [subLayer setHidden: YES]; [self setHidden: YES]; - // [subLayer setOpacity: 0.0]; - // [self setOpacity: 0.0]; + visibleOpacity = [self opacity]; + [subLayer setOpacity: 0.0]; + [self setOpacity: 0.0]; } int posQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & caLayerQuirks ) && ( lFrame.origin.x!=0 || lFrame.origin.y!=0 ); int sizeQuirk = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & caLayerQuirks ) && ( lFrame.size.width!=width || lFrame.size.height!=height ); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java index 6589cac1e..92d24e417 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java @@ -86,7 +86,10 @@ public class TestBug816OSXCALayerPos03AWT extends UITestCase { checkbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { glCanvas1.setVisible(checkbox.getState()); - System.out.println(glCanvas1.isVisible()); + System.out.println("Canvas visible: "+glCanvas1.isVisible()); + if( glCanvas1.isVisible() ) { + frame.validate(); // take care of resized frame while hidden + } } }); -- cgit v1.2.3 From e33e6374e0be0454f7e9732b5f897f84dbc3c4dc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 6 Oct 2013 21:25:42 +0200 Subject: Bug 729, Bug 849: Honor JAWTWindow's [parent] visibility state JAWTWindow snoops HierarchyEvents for SHOWING_CHANGED to track local component's visibility state as well as it's global visibility state. The later is determined by it's parent's visibility change. If 'removeNotify()' is called, component's visibility is reset to it's local visibility state. Fixes OSX CALayer component's visibility if parent's visibility changes (Bug 729). Fixes continuous GL rendering if parent is invisible (Bug 849). --- make/scripts/tests.sh | 4 +- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 122 +++++++++++---- .../jogl/awt/TestBug816OSXCALayerPos03AWT.java | 155 ------------------ .../jogl/awt/TestBug816OSXCALayerPos03aAWT.java | 165 ++++++++++++++++++++ .../jogl/awt/TestBug816OSXCALayerPos03bAWT.java | 171 ++++++++++++++++++++ .../jogl/awt/TestBug816OSXCALayerPos03cAWT.java | 173 +++++++++++++++++++++ 6 files changed, 608 insertions(+), 182 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f3b535058..81f89d531 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -456,7 +456,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 069147d26..6e198d961 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -37,6 +37,7 @@ package com.jogamp.nativewindow.awt; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.MutableGraphicsConfiguration; @@ -46,6 +47,8 @@ import java.awt.Container; import java.awt.Window; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; import java.applet.Applet; import javax.media.nativewindow.AbstractGraphicsConfiguration; @@ -76,10 +79,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, protected boolean shallUseOffscreenLayer = false; // lifetime: forever - protected Component component; - private AWTGraphicsConfiguration config; // control access due to delegation - private SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); - private RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); + protected final Component component; + private final AWTGraphicsConfiguration config; // control access due to delegation + private final SurfaceUpdatedHelper surfaceUpdatedHelper = new SurfaceUpdatedHelper(); + private final RecursiveLock surfaceLock = LockFactory.createRecursiveLock(); + private final JAWTComponentListener jawtComponentListener; // lifetime: valid after lock but may change with each 1st lock, purges after invalidate private boolean isApplet; @@ -106,39 +110,110 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(! ( config instanceof AWTGraphicsConfiguration ) ) { throw new NativeWindowException("Error: AbstractGraphicsConfiguration is not an AWTGraphicsConfiguration: "+config); } + this.component = (Component)comp; this.config = (AWTGraphicsConfiguration) config; - init((Component)comp); - } - - private void init(Component windowObject) throws NativeWindowException { + this.jawtComponentListener = new JAWTComponentListener(); + this.component.addComponentListener(jawtComponentListener); + this.component.addHierarchyListener(jawtComponentListener); invalidate(); - this.component = windowObject; this.isApplet = false; this.offscreenSurfaceLayer = 0; - this.component.addComponentListener(new ComponentListener() { - private boolean visible = component.isVisible(); + } + private class JAWTComponentListener implements ComponentListener, HierarchyListener { + private boolean localVisibility = component.isVisible(); + private boolean globalVisibility = localVisibility; + private boolean visibilityPropagation = false; + + private String s(ComponentEvent e) { + return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"],"+Platform.getNewline()+ + " ** COMP "+e.getComponent()+Platform.getNewline()+ + " ** SOURCE "+e.getSource()+Platform.getNewline()+ + " ** THIS "+component; + } + private String s(HierarchyEvent e) { + return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"], changeBits 0x"+Long.toHexString(e.getChangeFlags())+Platform.getNewline()+ + " ** COMP "+e.getComponent()+Platform.getNewline()+ + " ** SOURCE "+e.getSource()+Platform.getNewline()+ + " ** CHANGED "+e.getChanged()+Platform.getNewline()+ + " ** CHANGEDPARENT "+e.getChangedParent()+Platform.getNewline()+ + " ** THIS "+component; + } + @Override public void componentResized(ComponentEvent e) { - layoutSurfaceLayerIfEnabled(visible); + if(DEBUG) { + System.err.println("JAWTWindow.componentResized: "+s(e)); + } + layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); } @Override public void componentMoved(ComponentEvent e) { - layoutSurfaceLayerIfEnabled(visible); + if(DEBUG) { + System.err.println("JAWTWindow.componentMoved: "+s(e)); + } + layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); } @Override public void componentShown(ComponentEvent e) { - visible = true; - layoutSurfaceLayerIfEnabled(visible); + if(DEBUG) { + System.err.println("JAWTWindow.componentShown: "+s(e)); + } + layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); } @Override public void componentHidden(ComponentEvent e) { - visible = false; - layoutSurfaceLayerIfEnabled(visible); - } - }); + if(DEBUG) { + System.err.println("JAWTWindow.componentHidden: "+s(e)); + } + layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); + } + + @Override + public void hierarchyChanged(HierarchyEvent e) { + final long bits = e.getChangeFlags(); + final java.awt.Component changed = e.getChanged(); + if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { + final boolean displayable = changed.isDisplayable(); + final boolean resetLocalVisibility = changed == component && !displayable && localVisibility != component.isVisible(); + if( resetLocalVisibility ) { + // Reset components local state if detached from parent, i.e. 'removeNotify()' + visibilityPropagation = true; + if(DEBUG) { + System.err.println("JAWTWindow.hierarchyChanged DISPLAYABILITY_CHANGED (1): displayable "+displayable+", "+s(e)); + } + component.setVisible(localVisibility); + } else if(DEBUG) { + System.err.println("JAWTWindow.hierarchyChanged DISPLAYABILITY_CHANGED (x): displayable "+displayable+", "+s(e)); + } + } else if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) { + final boolean showing = changed.isShowing(); + final boolean propagateVisibility = changed != component && ( showing && localVisibility ) != component.isVisible(); + if( propagateVisibility ) { + // Propagate parent's visibility + final boolean _visible = showing && localVisibility; + visibilityPropagation = true; + globalVisibility = showing; + if(DEBUG) { + System.err.println("JAWTWindow.hierarchyChanged SHOWING_CHANGED (1): showing "+showing+" -> visible "+_visible+", "+s(e)); + } + component.setVisible(_visible); + } else if( changed == component ) { + // Update component's local visibility state + if(!visibilityPropagation) { + localVisibility = showing; + } + visibilityPropagation = false; + if(DEBUG) { + System.err.println("JAWTWindow.hierarchyChanged SHOWING_CHANGED (0): showing "+showing+" -> visible "+(showing && localVisibility)+", "+s(e)); + } + } else if(DEBUG) { + System.err.println("JAWTWindow.hierarchyChanged SHOWING_CHANGED (x): showing "+showing+" -> visible "+(showing && localVisibility)+", "+s(e)); + } + } + } } protected synchronized void invalidate() { @@ -488,7 +563,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, surfaceLock.lock(); try { invalidate(); - component = null; // don't dispose the AWT component, since we are merely an immutable uplink } finally { surfaceLock.unlock(); } @@ -638,12 +712,8 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, ", surfaceHandle "+toHexString(getSurfaceHandle())+ ", bounds "+bounds+", insets "+insets ); - if(null!=component) { - sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ - ", visible "+component.isVisible()); - } else { - sb.append(", component NULL"); - } + sb.append(", pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ + ", visible "+component.isVisible()); sb.append(", lockedExt "+isSurfaceLockedByOtherThread()+ ",\n\tconfig "+getPrivateGraphicsConfiguration()+ ",\n\tawtComponent "+getAWTComponent()+ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java deleted file mode 100644 index 92d24e417..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03AWT.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.awt; - -import java.awt.BorderLayout; -import java.awt.Checkbox; -import java.awt.Frame; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.lang.reflect.InvocationTargetException; - -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; -import javax.media.opengl.awt.GLCanvas; - -import org.junit.Assert; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import com.jogamp.newt.event.TraceWindowAdapter; -import com.jogamp.newt.event.awt.AWTWindowAdapter; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.QuitAdapter; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; - -/** - * Bug 816: OSX CALayer Positioning Bug - AWT Frame BorderLayout w/ Checkbox North, GLCanvas Center - *

        - * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 - *

        - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBug816OSXCALayerPos03AWT extends UITestCase { - static long duration = 1600; // ms - static int width=640, height=480; - - @Test - public void test() throws InterruptedException, InvocationTargetException { - final GLCapabilities caps = new GLCapabilities(getGLP()); - - final Frame frame = new Frame("TestBug816OSXCALayerPos03AWT"); - Assert.assertNotNull(frame); - - final GLCanvas glCanvas1 = new GLCanvas(caps); - Assert.assertNotNull(glCanvas1); - glCanvas1.addGLEventListener(new GearsES2(1)); - - final Animator animator = new Animator(); - animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - - // Create a check box that hides / shows canvas - final Checkbox checkbox = new Checkbox("Visible canvas", true); - checkbox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent ev) { - glCanvas1.setVisible(checkbox.getState()); - System.out.println("Canvas visible: "+glCanvas1.isVisible()); - if( glCanvas1.isVisible() ) { - frame.validate(); // take care of resized frame while hidden - } - } - }); - - // Build a GUI that displays canvas and check box - frame.setLayout(new BorderLayout()); - frame.add(glCanvas1, BorderLayout.CENTER); - frame.add(checkbox, BorderLayout.NORTH); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setSize(width, height); - frame.setVisible(true); - }}); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); - - animator.start(); - Assert.assertTrue(animator.isStarted()); - Assert.assertTrue(animator.isAnimating()); - animator.setUpdateFPSFrames(60, System.err); - - final long t0 = System.currentTimeMillis(); - long t1 = t0; - while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - Assert.assertNotNull(frame); - Assert.assertNotNull(glCanvas1); - - Assert.assertNotNull(animator); - animator.stop(); - Assert.assertFalse(animator.isAnimating()); - Assert.assertFalse(animator.isStarted()); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - }}); - Assert.assertEquals(false, frame.isVisible()); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.remove(glCanvas1); - frame.dispose(); - }}); - } - - static GLProfile getGLP() { - return GLProfile.getMaxProgrammableCore(true); - } - - public static void main(String args[]) { - for(int i=0; i + * Checkbox toggles GLCanvas visibility state. + *

        + *

        + * Validates bugs: + *

          + *
        • Bug 816: OSX CALayer Positioning Bug
        • + *
        • Bug 729: OSX CALayer shall honor the Component's visibility state
        • + *
        + *

        + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos03aAWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final Frame frame = new Frame("TestBug816OSXCALayerPos03aAWT"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Create a check box that hides / shows canvas + final Checkbox checkbox = new Checkbox("Visible canvas", true); + checkbox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent ev) { + glCanvas1.setVisible(checkbox.getState()); + System.out.println("Canvas visible: "+glCanvas1.isVisible()); + if( glCanvas1.isVisible() ) { + frame.validate(); // take care of resized frame while hidden + } + } + }); + + // Build a GUI that displays canvas and check box + frame.setLayout(new BorderLayout()); + frame.add(glCanvas1, BorderLayout.CENTER); + frame.add(checkbox, BorderLayout.NORTH); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas1); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i + * Checkbox toggles GLCanvas's parent panel's visibility state. + *

        + *

        + * Validates bugs: + *

          + *
        • Bug 816: OSX CALayer Positioning Bug
        • + *
        • Bug 729: OSX CALayer shall honor the Component's visibility state
        • + *
        • Bug 849: AWT GLAutoDrawables (JAWTWindow) shall honor it's parent visibility state
        • + *
        + *

        + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos03bAWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final Frame frame = new Frame("TestBug816OSXCALayerPos03bAWT"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + // Put it in a panel + final Panel panel = new Panel(new GridLayout(1, 1)); + panel.add(glCanvas1); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Create a check box that hides / shows canvas + final Checkbox checkbox = new Checkbox("Visible canvas", true); + checkbox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent ev) { + panel.setVisible(checkbox.getState()); + System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); + if( panel.isVisible() ) { + frame.validate(); // take care of resized frame while hidden + } + } + }); + + // Build a GUI that displays canvas and check box + frame.setLayout(new BorderLayout()); + frame.add(panel, BorderLayout.CENTER); + frame.add(checkbox, BorderLayout.NORTH); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(panel); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i + * Checkbox toggles GLCanvas's parent jpanel's visibility state. + *

        + *

        + * Validates bugs: + *

          + *
        • Bug 816: OSX CALayer Positioning Bug
        • + *
        • Bug 729: OSX CALayer shall honor the Component's visibility state
        • + *
        • Bug 849: AWT GLAutoDrawables (JAWTWindow) shall honor it's parent visibility state
        • + *
        + *

        + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos03cAWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final JFrame frame = new JFrame("TestBug816OSXCALayerPos03cAWT"); + Assert.assertNotNull(frame); + final Container framePane = frame.getContentPane(); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + // Put it in a panel + final JPanel panel = new JPanel(new GridLayout(1, 1)); + panel.add(glCanvas1); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Create a check box that hides / shows canvas + final JCheckBox checkbox = new JCheckBox("Visible canvas", true); + checkbox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent ev) { + panel.setVisible(checkbox.getSelectedObjects()!=null); + System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); + if( panel.isVisible() ) { + frame.validate(); // take care of resized frame while hidden + } + } + }); + + // Build a GUI that displays canvas and check box + framePane.setLayout(new BorderLayout()); + framePane.add(panel, BorderLayout.CENTER); + framePane.add(checkbox, BorderLayout.NORTH); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + framePane.remove(panel); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i Date: Mon, 7 Oct 2013 07:41:30 +0200 Subject: NEWT/Fullscreen (Bug 836): Exit re-parenting fullscreen w/ [invisible-exit-visible] (-> like reparent); Always force focus; X11: Always use ALWAYSONTOP. - Remove unused 'fullscreenUseSpanningMode' state - Exit re-parenting fullscreen w/ [invisible-exit-visible] (-> like reparent) solves X11 issue, where the NEWT window doesn't 'return to it's parent'. Probably also fixes Bug 836! - Always force focus when enter and exit FS - X11: Always use ALWAYSONTOP No reason to behave different (spanning and normal-fs) --- make/scripts/tests.sh | 6 +-- src/newt/classes/jogamp/newt/WindowImpl.java | 53 +++++++++++++--------- .../jogamp/newt/driver/x11/WindowDriver.java | 2 +- 3 files changed, 36 insertions(+), 25 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 81f89d531..5c693f33c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -144,7 +144,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Screen" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -298,7 +298,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -457,7 +457,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index caa461e41..a2338b93d 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -154,7 +154,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private boolean fullscreen = false, brokenFocusChange = false; private List fullscreenMonitors = null; private boolean fullscreenUseMainMonitor = true; - private boolean fullscreenUseSpanningMode = true; // spanning mode: fake full screen, only on certain platforms private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets @@ -273,7 +272,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreen = false; fullscreenMonitors = null; fullscreenUseMainMonitor = true; - fullscreenUseSpanningMode = false; hasFocus = false; parentWindowHandle = 0; } @@ -1051,7 +1049,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreen = false; fullscreenMonitors = null; fullscreenUseMainMonitor = true; - fullscreenUseSpanningMode = false; hasFocus = false; parentWindowHandle = 0; @@ -1903,6 +1900,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // set current state WindowImpl.this.fullscreen = fullscreen; + final int oldX = getX(); + final int oldY = getY(); + final int oldWidth = getWidth(); + final int oldHeight = getHeight(); + int x,y,w,h; final RectangleImmutable sviewport = screen.getViewport(); @@ -1920,23 +1922,20 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer viewport = MonitorDevice.unionOfViewports(new Rectangle(), fullscreenMonitors); if( isReconfigureFlagSupported(FLAG_IS_FULLSCREEN_SPAN) && ( fullscreenMonitors.size() > 1 || sviewport.compareTo(viewport) > 0 ) ) { - fullscreenUseSpanningMode = true; fs_span_flag = FLAG_IS_FULLSCREEN_SPAN; } else { - fullscreenUseSpanningMode = false; fs_span_flag = 0; } - nfs_x = getX(); - nfs_y = getY(); - nfs_width = getWidth(); - nfs_height = getHeight(); + nfs_x = oldX; + nfs_y = oldY; + nfs_width = oldWidth; + nfs_height = oldHeight; x = viewport.getX(); y = viewport.getY(); w = viewport.getWidth(); h = viewport.getHeight(); } else { fullscreenUseMainMonitor = true; - fullscreenUseSpanningMode = false; fullscreenMonitors = null; fs_span_flag = 0; viewport = null; @@ -1962,16 +1961,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+ - ", spanning "+fullscreenUseSpanningMode+" @ "+Thread.currentThread().getName()); + ", spanning "+(0!=fs_span_flag)+" @ "+Thread.currentThread().getName()); } final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date final boolean wasVisible = isVisible(); - + // Lock parentWindow only during reparenting (attempt) final NativeWindow parentWindowLocked; if( null != parentWindow ) { + if(wasVisible && !fullscreen) { // fullscreen-off -> !visible first (fixes unsuccessful return to parent window) + setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); + WindowImpl.this.waitForVisible(false, false); + // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, + // even though we do exactly that (KDE+Composite) + try { Thread.sleep(100); } catch (InterruptedException e) { } + display.dispatchMessagesNative(); // status up2date + } parentWindowLocked = parentWindow; if( NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) { throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow); @@ -1982,7 +1989,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer try { reconfigureWindowImpl(x, y, w, h, getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | - fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, wasVisible) ); + fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, isVisible()) ); } finally { if(null!=parentWindowLocked) { parentWindowLocked.unlockSurface(); @@ -1992,11 +1999,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(wasVisible) { setVisibleImpl(true, x, y, w, h); - WindowImpl.this.waitForVisible(true, false); - display.dispatchMessagesNative(); // status up2date - WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); + boolean ok = 0 <= WindowImpl.this.waitForVisible(true, false); + if(ok) { + ok = WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); + } + if(ok) { + requestFocusInt(fullscreen /* skipFocusAction */); + display.dispatchMessagesNative(); // status up2date + } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window fs done: " + WindowImpl.this); + System.err.println("Window fs done: ok " + ok + ", " + WindowImpl.this); } } } finally { @@ -2021,13 +2033,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer synchronized(fullScreenAction) { fullscreenMonitors = monitors; fullscreenUseMainMonitor = useMainMonitor; - fullscreenUseSpanningMode = false; if( fullScreenAction.init(fullscreen) ) { if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { // enable fullscreen on offscreen instance if(null != parentWindow) { nfs_parent = parentWindow; - reparentWindow(null, true); + reparentWindow(null, true /* forceDestroyCreate */); } else { throw new InternalError("Offscreen instance w/o parent unhandled"); } @@ -2037,11 +2048,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!fullScreenAction.fsOn() && null != nfs_parent) { // disable fullscreen on offscreen instance - reparentWindow(nfs_parent, true); + reparentWindow(nfs_parent, true /* forceDestroyCreate */); nfs_parent = null; } - if( fullscreen && isVisible() ) { // force focus on fullscreen + if( isVisible() ) { // force focus requestFocus(true /* wait */, true /* skipFocusAction */, true /* force */); } } diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 4786ea04f..806dd270c 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -163,7 +163,7 @@ public class WindowDriver extends WindowImpl { _y = y; } if( 0 != ( FLAG_CHANGE_FULLSCREEN & flags ) ) { - if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 != ( FLAG_IS_FULLSCREEN_SPAN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { + if( 0 != ( FLAG_IS_FULLSCREEN & flags) && 0 == ( FLAG_IS_ALWAYSONTOP & flags) ) { tempFSAlwaysOnTop = true; flags |= FLAG_IS_ALWAYSONTOP; if(DEBUG_IMPLEMENTATION) { -- cgit v1.2.3 From 8be1fc983e584082b9960b4da19c56af5834d08e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Oct 2013 05:24:45 +0200 Subject: NEWT Reparent/Fullscreen: Fixes X11 unsuccessful return to parent window; Add reparentWindow(..) top-level position arguments; Misc - Fixes X11 unsuccessful return to parent window On X11 when returning to parent window (-> CHILD), we have to set the window invisible and wait for the result. Otherwise it sometimes happens that the WM's reparent operation fails, i.e. the window won't become a child of desired parent and is positioned randomly. - Add reparentWindow(..) top-level position arguments .. allows bringing the child-window to top-level w/ a desired position. Otherwise the window would be positioned elsewhere as a top-level as the plain reparenting operation. X11 needs to set position and size _after_ making the window visible, otherwise WM may ignore the XConfigureWindow request. - Reparent recreate shall always store the desired position and size On OSX/CALayer when recreation is being used, we need to store the pos/size for later creation. - Tests: Use 'NewtAWTReparentingKeyAdapter' where possible (reparent/fullscreen) instead of duplicating such code. NewtAWTReparentingKeyAdapter: Performs reparenting and fullscreen operations off-thread (i.e. not on AWT/NEW EDT) while decorating the action w/ revoking/restoring the ExclusiveContextThread (ECT). Manually tested 'TestGearsES2NewtCanvasAWT' reparenting and fullscreen on X11, Windows and OSX/CALayer w/ JDK 7u40 successful. --- make/scripts/tests-x64-dbg.bat | 4 +- make/scripts/tests.sh | 3 +- src/newt/classes/com/jogamp/newt/Window.java | 19 +++- .../classes/com/jogamp/newt/opengl/GLWindow.java | 4 +- src/newt/classes/jogamp/newt/WindowImpl.java | 95 ++++++++++-------- src/newt/native/X11Window.c | 6 +- .../acore/TestOffscreenLayer02NewtCanvasAWT.java | 2 +- .../demos/es2/newt/TestGearsES2NewtCanvasAWT.java | 53 +--------- .../es2/newt/TestLandscapeES2NewtCanvasAWT.java | 53 +--------- .../parenting/NewtAWTReparentingKeyAdapter.java | 111 ++++++++++++++------- .../junit/newt/parenting/TestParenting01NEWT.java | 8 +- .../junit/newt/parenting/TestParenting03AWT.java | 4 +- .../TestParentingFocusTraversal01AWT.java | 2 +- 13 files changed, 170 insertions(+), 194 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 3447605c7..c1a14c1a2 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -48,8 +48,8 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" "-Djogl.windows.useWGLVersionOf5WGLGDIFuncSet" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" -set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" -REM set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" +set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5c693f33c..4bafdf15d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -144,7 +144,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Screen" - D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" @@ -194,6 +193,8 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index f63c03738..8a43ef153 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -351,10 +351,27 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * @param newParent The new parent NativeWindow. If null, this Window becomes a top level window. * * @return The issued reparent action type (strategy) as defined in Window.ReparentAction + * @see #reparentWindow(NativeWindow, int, int, boolean) */ ReparentOperation reparentWindow(NativeWindow newParent); - ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate); + /** + * Change this window's parent window.
        + *

        + * In case the old parent is not null and a Window, + * this window is removed from it's list of children.
        + * In case the new parent is not null and a Window, + * this window is added to it's list of children.

        + * + * @param newParent The new parent NativeWindow. If null, this Window becomes a top level window. + * @param x new top-level position, use -1 for default position. + * @param y new top-level position, use -1 for default position. + * @param forceDestroyCreate if true, uses re-creation strategy for reparenting, default is false. + * + * @return The issued reparent action type (strategy) as defined in Window.ReparentAction + * @see #reparentWindow(NativeWindow) + */ + ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate); /** * Enable or disable fullscreen mode for this window. diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 45ab2a44c..eace0f2af 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -390,8 +390,8 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } @Override - public final ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) { - return window.reparentWindow(newParent, forceDestroyCreate); + public final ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) { + return window.reparentWindow(newParent, x, y, forceDestroyCreate); } @Override diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index a2338b93d..300ca5c3f 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -414,7 +414,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(postParentlockFocus) { // harmonize focus behavior for all platforms: focus on creation - requestFocusInt(isFullscreen() /* skipFocusAction */); + requestFocusInt(isFullscreen() /* skipFocusAction if fullscreen */); ((DisplayImpl) screen.getDisplay()).dispatchMessagesNative(); // status up2date } if(DEBUG_IMPLEMENTATION) { @@ -1033,7 +1033,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer removeScreenReference(); Display dpy = screen.getDisplay(); if(null != dpy) { - dpy.validateEDT(); + dpy.validateEDTStopped(); } // send synced destroyed notification @@ -1112,12 +1112,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private class ReparentAction implements Runnable { - NativeWindow newParentWindow; + final NativeWindow newParentWindow; + final int topLevelX, topLevelY; boolean forceDestroyCreate; ReparentOperation operation; - private ReparentAction(NativeWindow newParentWindow, boolean forceDestroyCreate) { + private ReparentAction(NativeWindow newParentWindow, int topLevelX, int topLevelY, boolean forceDestroyCreate) { this.newParentWindow = newParentWindow; + this.topLevelX = topLevelX; + this.topLevelY = topLevelY; this.forceDestroyCreate = forceDestroyCreate | DEBUG_TEST_REPARENT_INCOMPATIBLE; this.operation = ReparentOperation.ACTION_INVALID; // ensure it's set } @@ -1144,10 +1147,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private void reparent() { // mirror pos/size so native change notification can get overwritten - int x = getX(); - int y = getY(); - int width = getWidth(); - int height = getHeight(); + final int oldX = getX(); + final int oldY = getY(); + final int oldWidth = getWidth(); + final int oldHeight = getHeight(); + final int x, y; + int width = oldWidth; + int height = oldHeight; boolean wasVisible; final RecursiveLock _lock = windowLock; @@ -1168,10 +1174,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer long newParentWindowHandle = 0 ; if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate+", "+x+"/"+y+" "+width+"x"+height); + System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate); } if(null!=newParentWindow) { + // REPARENT TO CHILD WINDOW + // reset position to 0/0 within parent space x = 0; y = 0; @@ -1233,12 +1241,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer operation = ReparentOperation.ACTION_NOP; } } else { - if( null != parentWindow ) { + // REPARENT TO TOP-LEVEL WINDOW + if( 0 <= topLevelX && 0 <= topLevelY ) { + x = topLevelX; + y = topLevelY; + } else if( null != parentWindow ) { // child -> top // put client to current parent+child position final Point p = getLocationOnScreen(null); x = p.getX(); y = p.getY(); + } else { + x = oldX; + y = oldY; } // Case: Top Window @@ -1264,18 +1279,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if ( ReparentOperation.ACTION_INVALID == operation ) { throw new NativeWindowException("Internal Error: reparentAction not set"); } - + + if(DEBUG_IMPLEMENTATION) { + System.err.println("Window.reparent: ACTION ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", reparentAction "+operation+", pos/size "+x+"/"+y+" "+width+"x"+height+", visible "+wasVisible); + } + if( ReparentOperation.ACTION_NOP == operation ) { - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: NO CHANGE ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", visible "+wasVisible); - } return; } - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: ACTION ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" new parentWindowHandle "+toHexString(newParentWindowHandle)+", reparentAction "+operation+", visible "+wasVisible); - } - // rearrange window tree if(null!=parentWindow && parentWindow instanceof Window) { ((Window)parentWindow).removeChild(WindowImpl.this); @@ -1285,19 +1297,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ((Window)parentWindow).addChild(WindowImpl.this); } - if( ReparentOperation.ACTION_NATIVE_CREATION_PENDING == operation ) { - // make size and position persistent for proper recreation - definePosition(x, y); - defineSize(width, height); - return; - } - if( ReparentOperation.ACTION_NATIVE_REPARENTING == operation ) { final DisplayImpl display = (DisplayImpl) screen.getDisplay(); display.dispatchMessagesNative(); // status up2date - if(wasVisible) { - setVisibleImpl(false, x, y, width, height); + // TOP -> CLIENT: !visible first (fixes X11 unsuccessful return to parent window) + if( null != parentWindow && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { + setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); WindowImpl.this.waitForVisible(false, false); // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, // even though we do exactly that (KDE+Composite) @@ -1337,7 +1343,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } if(ok) { - requestFocusInt(false /* skipFocusAction */); + requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); display.dispatchMessagesNative(); // status up2date } } @@ -1358,6 +1364,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer destroy( wasVisible ); operation = ReparentOperation.ACTION_NATIVE_CREATION ; } + } else { + // Case + // ACTION_NATIVE_CREATION + // ACTION_NATIVE_CREATION_PENDING; + + // make size and position persistent for proper [re]creation + definePosition(x, y); + defineSize(width, height); } if(DEBUG_IMPLEMENTATION) { @@ -1398,7 +1412,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparentWindow: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow)); } - setVisible(true); // native creation + setVisibleActionImpl(true); // native creation + requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); } finally { _lock.unlock(); } @@ -1408,11 +1423,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final ReparentOperation reparentWindow(NativeWindow newParent) { - return reparentWindow(newParent, false); + return reparentWindow(newParent, -1, -1, false); } - public ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate) { - final ReparentAction reparentAction = new ReparentAction(newParent, forceDestroyCreate); + @Override + public ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) { + final ReparentAction reparentAction = new ReparentAction(newParent, x, y, forceDestroyCreate); runOnEDTIfAvail(true, reparentAction); return reparentAction.getOp(); } @@ -1800,7 +1816,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private void requestFocusInt(boolean skipFocusAction) { if( skipFocusAction || !focusAction() ) { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.RequestFocusInt: forcing - ("+getThreadName()+"): "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); + System.err.println("Window.RequestFocusInt: forcing - ("+getThreadName()+"): skipFocusAction "+skipFocusAction+", focus "+hasFocus+" -> true - windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)); } requestFocusImpl(true); } @@ -1971,7 +1987,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Lock parentWindow only during reparenting (attempt) final NativeWindow parentWindowLocked; if( null != parentWindow ) { - if(wasVisible && !fullscreen) { // fullscreen-off -> !visible first (fixes unsuccessful return to parent window) + // fullscreen off: !visible first (fixes X11 unsuccessful return to parent window) + if( !fullscreen && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); WindowImpl.this.waitForVisible(false, false); // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, @@ -2004,7 +2021,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ok = WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); } if(ok) { - requestFocusInt(fullscreen /* skipFocusAction */); + requestFocusInt(fullscreen /* skipFocusAction if fullscreen */); display.dispatchMessagesNative(); // status up2date } if(DEBUG_IMPLEMENTATION) { @@ -2038,7 +2055,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // enable fullscreen on offscreen instance if(null != parentWindow) { nfs_parent = parentWindow; - reparentWindow(null, true /* forceDestroyCreate */); + reparentWindow(null, -1, -1, true /* forceDestroyCreate */); } else { throw new InternalError("Offscreen instance w/o parent unhandled"); } @@ -2048,13 +2065,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(!fullScreenAction.fsOn() && null != nfs_parent) { // disable fullscreen on offscreen instance - reparentWindow(nfs_parent, true /* forceDestroyCreate */); + reparentWindow(nfs_parent, -1, -1, true /* forceDestroyCreate */); nfs_parent = null; } - - if( isVisible() ) { // force focus - requestFocus(true /* wait */, true /* skipFocusAction */, true /* force */); - } } return this.fullscreen; } diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index e6e300d2e..f195c5616 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -817,11 +817,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo if( TST_FLAG_IS_VISIBLE(flags) ) { DBG_PRINT( "X11: reconfigureWindow0 VISIBLE ON\n"); XMapRaised(dpy, w); + XSync(dpy, False); + // WM may disregard pos/size XConfigureWindow requests for invisible windows! + DBG_PRINT( "X11: reconfigureWindow0 setPosSize.2 %d/%d %dx%d\n", x, y, width, height); + NewtWindows_setPosSize(dpy, w, x, y, width, height); } else { DBG_PRINT( "X11: reconfigureWindow0 VISIBLE OFF\n"); XUnmapWindow(dpy, w); + XSync(dpy, False); } - XSync(dpy, False); } if( fsEWMHFlags && ( ( TST_FLAG_CHANGE_FULLSCREEN(flags) && TST_FLAG_IS_FULLSCREEN(flags) ) || diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java index cea104e2f..5335d858e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestOffscreenLayer02NewtCanvasAWT.java @@ -162,7 +162,7 @@ public class TestOffscreenLayer02NewtCanvasAWT extends UITestCase { } setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); frame1.setSize(frameSize0); setupFrameAndShow(frame1, newtCanvasAWT1); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java index 3fc1eb61d..5d091bb6d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NewtCanvasAWT.java @@ -42,8 +42,6 @@ import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.awt.NewtCanvasAWT; -import com.jogamp.newt.event.KeyAdapter; -import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; @@ -51,17 +49,14 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; - import com.jogamp.opengl.util.Animator; - import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.newt.parenting.NewtAWTReparentingKeyAdapter; import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.DimensionImmutable; - import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLProfile; @@ -271,50 +266,8 @@ public class TestGearsES2NewtCanvasAWT extends UITestCase { } }); - glWindow.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent e) { - if( !e.isPrintableKey() || e.isAutoRepeat() ) { - return; - } - if(e.getKeyChar()=='f') { - quitAdapter.enable(false); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setFullscreen(!glWindow.isFullscreen()); - System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setExclusiveContextThread(t); - quitAdapter.clear(); - quitAdapter.enable(true); - } }.start(); - } else if(e.getKeyChar()=='r') { - quitAdapter.enable(false); - if(glWindow.getParent()==null) { - System.err.println("XXX glWin to home"); - glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); - } else { - final InsetsImmutable nInsets = glWindow.getInsets(); - java.awt.Insets aInsets = frame.getInsets(); - System.err.println("XXX glWin to TOP - insets " + nInsets + ", " + aInsets); - glWindow.reparentWindow(null); - int dx, dy; - if(nInsets.getTotalHeight()==0) { - dx = aInsets.left; - dy = aInsets.top; - } else { - dx = nInsets.getLeftWidth(); - dy = nInsets.getTopHeight(); - } - glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy); - } - glWindow.requestFocus(); - quitAdapter.clear(); - quitAdapter.enable(true); - } - } - }); - + glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter)); + if( useAnimator ) { animator.add(glWindow); animator.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java index 37172822b..adc2b23ae 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestLandscapeES2NewtCanvasAWT.java @@ -36,23 +36,18 @@ import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.awt.NewtCanvasAWT; -import com.jogamp.newt.event.KeyAdapter; -import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; - import com.jogamp.opengl.util.Animator; - import com.jogamp.opengl.test.junit.jogl.demos.es2.LandscapeES2; +import com.jogamp.opengl.test.junit.newt.parenting.NewtAWTReparentingKeyAdapter; import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.DimensionImmutable; - import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLProfile; @@ -119,50 +114,8 @@ public class TestLandscapeES2NewtCanvasAWT extends UITestCase { } }); - glWindow.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent e) { - if( !e.isPrintableKey() || e.isAutoRepeat() ) { - return; - } - if(e.getKeyChar()=='f') { - quitAdapter.enable(false); - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setFullscreen(!glWindow.isFullscreen()); - System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); - glWindow.setExclusiveContextThread(t); - quitAdapter.clear(); - quitAdapter.enable(true); - } }.start(); - } else if(e.getKeyChar()=='r') { - quitAdapter.enable(false); - if(glWindow.getParent()==null) { - System.err.println("XXX glWin to home"); - glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); - } else { - final InsetsImmutable nInsets = glWindow.getInsets(); - java.awt.Insets aInsets = frame.getInsets(); - System.err.println("XXX glWin to TOP - insets " + nInsets + ", " + aInsets); - glWindow.reparentWindow(null); - int dx, dy; - if(nInsets.getTotalHeight()==0) { - dx = aInsets.left; - dy = aInsets.top; - } else { - dx = nInsets.getLeftWidth(); - dy = nInsets.getTopHeight(); - } - glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy); - } - glWindow.requestFocus(); - quitAdapter.clear(); - quitAdapter.enable(true); - } - } - }); - + glWindow.addKeyListener(new NewtAWTReparentingKeyAdapter(frame, newtCanvasAWT, glWindow, quitAdapter)); + if( useAnimator ) { animator.add(glWindow); animator.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 9d08d8ff4..4bf1f95c3 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -35,33 +35,58 @@ import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.QuitAdapter; public class NewtAWTReparentingKeyAdapter extends KeyAdapter { - Frame frame; - NewtCanvasAWT newtCanvasAWT; - GLWindow glWindow; + final Frame frame; + final NewtCanvasAWT newtCanvasAWT; + final GLWindow glWindow; + final QuitAdapter quitAdapter; - public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow) { + public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) { this.frame = frame; this.newtCanvasAWT = newtCanvasAWT; this.glWindow = glWindow; + this.quitAdapter = quitAdapter; } public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; } - if(e.getKeyChar()=='i') { + if( e.getKeySymbol() == KeyEvent.VK_I ) { System.err.println(glWindow); - } else if(e.getKeyChar()=='d') { - glWindow.setUndecorated(!glWindow.isUndecorated()); - } else if(e.getKeyChar()=='f') { - glWindow.setFullscreen(!glWindow.isFullscreen()); - } else if(e.getKeyChar()=='l') { + } else if( e.getKeySymbol() == KeyEvent.VK_L ) { javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null); javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null); System.err.println("NewtCanvasAWT position: "+p0+", "+p1); - } else if(e.getKeyChar()=='p') { + } else if( e.getKeySymbol() == KeyEvent.VK_D ) { + glWindow.setUndecorated(!glWindow.isUndecorated()); + } else if( e.getKeySymbol() == KeyEvent.VK_S ) { + if(glWindow.getParent()==null) { + System.err.println("XXX glWin to 100/100"); + glWindow.setPosition(100, 100); + } else { + System.err.println("XXX glWin to 0/0"); + glWindow.setPosition(0, 0); + } + } else if( e.getKeySymbol() == KeyEvent.VK_F ) { + if( null != quitAdapter ) { + quitAdapter.enable(false); + } + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set fullscreen pre]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("[set fullscreen post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); + glWindow.setExclusiveContextThread(t); + if( null != quitAdapter ) { + quitAdapter.clear(); + quitAdapter.enable(true); + } + } }.start(); + } else if( e.getKeySymbol() == KeyEvent.VK_P ) { new Thread() { public void run() { if(glWindow.getAnimator().isPaused()) { @@ -71,34 +96,44 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } } }.run(); - } else if(e.getKeyChar()=='r') { - if(glWindow.getParent()==null) { - System.err.println("XXX glWin to home"); - glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); - } else { - final InsetsImmutable nInsets = glWindow.getInsets(); - java.awt.Insets aInsets = frame.getInsets(); - System.err.println("XXX glWin to TOP - insets " + nInsets + ", " + aInsets); - glWindow.reparentWindow(null); - int dx, dy; - if(nInsets.getTotalHeight()==0) { - dx = aInsets.left; - dy = aInsets.top; - } else { - dx = nInsets.getLeftWidth(); - dy = nInsets.getTopHeight(); - } - glWindow.setPosition(frame.getX()+frame.getWidth()+dx, frame.getY()+dy); - } - glWindow.requestFocus(); - } else if(e.getKeyChar()=='s') { - if(glWindow.getParent()==null) { - System.err.println("XXX glWin to 100/100"); - glWindow.setPosition(100, 100); - } else { - System.err.println("XXX glWin to 0/0"); - glWindow.setPosition(0, 0); + } else if( e.getKeySymbol() == KeyEvent.VK_R ) { + if( null != quitAdapter ) { + quitAdapter.enable(false); } + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + if(glWindow.getParent()==null) { + System.err.println("XXX glWin to HOME"); + glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); + } else { + if( null != frame ) { + final InsetsImmutable nInsets = glWindow.getInsets(); + final java.awt.Insets aInsets = frame.getInsets(); + int dx, dy; + if( nInsets.getTotalHeight()==0 ) { + dx = aInsets.left; + dy = aInsets.top; + } else { + dx = nInsets.getLeftWidth(); + dy = nInsets.getTopHeight(); + } + final int topLevelX = frame.getX()+frame.getWidth()+dx; + final int topLevelY = frame.getY()+dy; + System.err.println("XXX glWin to TOP.1 "+topLevelX+"/"+topLevelY+" - insets " + nInsets + ", " + aInsets); + glWindow.reparentWindow(null, topLevelX, topLevelY, false); + } else { + System.err.println("XXX glWin to TOP.0"); + glWindow.reparentWindow(null); + } + } + glWindow.requestFocus(); + glWindow.setExclusiveContextThread(t); + if( null != quitAdapter ) { + quitAdapter.clear(); + quitAdapter.enable(true); + } + } }.start(); } } } \ No newline at end of file diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java index 41a6b77fa..1f19241d8 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java @@ -379,7 +379,7 @@ public class TestParenting01NEWT extends UITestCase { // glWindow2 -- child --> glWindow1: compatible Assert.assertEquals(true, glWindow2.isVisible()); System.err.println("Frames(1) "+glWindow2.getTotalFPSFrames()); - reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate); System.err.println("Frames(2) "+glWindow2.getTotalFPSFrames()); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); @@ -405,7 +405,7 @@ public class TestParenting01NEWT extends UITestCase { // glWindow2 --> top Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(null, reparentRecreate); + reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); @@ -567,7 +567,7 @@ public class TestParenting01NEWT extends UITestCase { switch(state) { case 0: Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(null, reparentRecreate); + reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); @@ -582,7 +582,7 @@ public class TestParenting01NEWT extends UITestCase { break; case 1: Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(glWindow1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java index 60c2b702c..30ee0f129 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java @@ -88,7 +88,7 @@ public class TestParenting03AWT extends UITestCase { GLEventListener demo1 = new GearsES2(1); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); GLAnimatorControl animator1 = new Animator(glWindow1); animator1.start(); @@ -104,7 +104,7 @@ public class TestParenting03AWT extends UITestCase { GLEventListener demo2 = new GearsES2(1); setDemoFields(demo2, glWindow2, false); glWindow2.addGLEventListener(demo2); - glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2)); + glWindow2.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT2, glWindow2, null)); animator2 = new Animator(glWindow2); animator2.start(); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java index 58dafba15..693dd1448 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java @@ -147,7 +147,7 @@ public class TestParentingFocusTraversal01AWT extends UITestCase { GLEventListener demo1 = new GearsES2(1); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1)); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); glWindow1.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { -- cgit v1.2.3 From 364af76f2ba3e05ba041997e97f4e342fd6f5827 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Oct 2013 07:17:37 +0200 Subject: Bug816 OSX CALayer: Issue w/ JSplitPane within Apple (Firefox, Safari - not appletviewer) when move horizontal slider (vertical: ok) Moving horizontal slider if run as applet (Firefox, Safari - not appletviewer) doesn't move the GLCanvas even though it is resized. --- jnlp-files/jogl-applet-bug816_layerpos03a.html | 32 +++++++ jnlp-files/jogl-applet-bug816_layerpos03b.html | 32 +++++++ jnlp-files/jogl-test-applets.html | 2 + make/scripts/tests.sh | 6 +- .../macosx/MacOSXWindowSystemInterface-calayer.m | 7 +- .../jogl/awt/TestBug816OSXCALayerPos02AWT.java | 5 +- .../es2/awt/Bug816AppletOSXCALayerPos03a.java | 103 +++++++++++++++++++++ .../es2/awt/Bug816AppletOSXCALayerPos03b.java | 101 ++++++++++++++++++++ 8 files changed, 281 insertions(+), 7 deletions(-) create mode 100644 jnlp-files/jogl-applet-bug816_layerpos03a.html create mode 100644 jnlp-files/jogl-applet-bug816_layerpos03b.html create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03b.java (limited to 'make/scripts') diff --git a/jnlp-files/jogl-applet-bug816_layerpos03a.html b/jnlp-files/jogl-applet-bug816_layerpos03a.html new file mode 100644 index 000000000..432a2b39d --- /dev/null +++ b/jnlp-files/jogl-applet-bug816_layerpos03a.html @@ -0,0 +1,32 @@ + + + +Bug816 OSX CALayer Pos - Applet w/ 1 JRootPanes and 2 JSplitPanes + + + +

        +Bug816 OSX CALayer Pos - AWT Applet w/ 1 JRootPanes and 2 JSplitPanes +

        + +

        + + + + + + Sorry, no Java support detected. + + + +

        + + diff --git a/jnlp-files/jogl-applet-bug816_layerpos03b.html b/jnlp-files/jogl-applet-bug816_layerpos03b.html new file mode 100644 index 000000000..43b13a8df --- /dev/null +++ b/jnlp-files/jogl-applet-bug816_layerpos03b.html @@ -0,0 +1,32 @@ + + + +Bug816 OSX CALayer Pos - JApplet w/ 2 JRootPanes and 2 JSplitPanes + + + +

        +Bug816 OSX CALayer Pos - Swing JApplet w/ 2 JRootPanes and 2 JSplitPanes +

        + +

        + + + + + + Sorry, no Java support detected. + + + +

        + + diff --git a/jnlp-files/jogl-test-applets.html b/jnlp-files/jogl-test-applets.html index be0a5be81..76cd6effe 100644 --- a/jnlp-files/jogl-test-applets.html +++ b/jnlp-files/jogl-test-applets.html @@ -207,6 +207,8 @@ Misc tests:
      • 01: Custom bounds within applet
      • 02a: Box layout within applet
      • 02b: Grid layout within applet
      • +
      • 03a: Applet w/ 1 JRootPanes and 2 JSplitPanes
      • +
      • 03b: JApplet w/ 2 JRootPanes and 2 JSplitPanes
    • Misc Issues
        diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4bafdf15d..9ca5374e4 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -194,7 +194,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" - D_ARGS="-Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -299,7 +299,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -456,7 +456,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cAWT $* diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m index d15c8e038..75917d2dc 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface-calayer.m @@ -570,11 +570,12 @@ static const GLfloat gl_verts[] = { CGRect lRect = [self frame]; Bool dedicatedFramePosSet = 0 != ( NW_DEDICATEDFRAME_QUIRK_POSITION & quirks ); Bool dedicatedFrameSizeSet = 0 != ( NW_DEDICATEDFRAME_QUIRK_SIZE & quirks ); - dedicatedFrameSet = dedicatedFramePosSet || dedicatedFrameSizeSet; + Bool dedicatedLayoutSet = 0 != ( NW_DEDICATEDFRAME_QUIRK_LAYOUT & quirks ); + dedicatedFrameSet = dedicatedFramePosSet || dedicatedFrameSizeSet || dedicatedLayoutSet; dedicatedFrame = dFrame; - DBG_PRINT("MyNSOpenGLLayer::setDedicatedFrame: Quirks [%d, pos %d, size %d], %p, texSize %dx%d, %lf/%lf %lfx%lf -> %lf/%lf %lfx%lf\n", - quirks, dedicatedFramePosSet, dedicatedFrameSizeSet, self, texWidth, texHeight, + DBG_PRINT("MyNSOpenGLLayer::setDedicatedFrame: Quirks [%d, pos %d, size %d, lout %d], %p, texSize %dx%d, %lf/%lf %lfx%lf -> %lf/%lf %lfx%lf\n", + quirks, dedicatedFramePosSet, dedicatedFrameSizeSet, dedicatedLayoutSet, self, texWidth, texHeight, lRect.origin.x, lRect.origin.y, lRect.size.width, lRect.size.height, dFrame.origin.x, dFrame.origin.y, dFrame.size.width, dFrame.size.height); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java index 43d536afa..073956459 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos02AWT.java @@ -54,10 +54,13 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; /** - * Bug 816: OSX CALayer Positioning Bug - Swing JFrame w/ 2 JRootPanes + * Bug 816: OSX CALayer Positioning Bug - Swing JFrame w/ 2 JRootPanes and 2 JSplitPanes *

        * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 *

        + *

        + * See also {@link com.jogamp.opengl.test.junit.jogl.demos.es2.awt.Bug816AppletOSXCALayerPos03b} + *

        */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBug816OSXCALayerPos02AWT extends UITestCase { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java new file mode 100644 index 000000000..a70625129 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java @@ -0,0 +1,103 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; + +import java.applet.Applet; +import java.awt.BorderLayout; +import java.awt.Button; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.JRootPane; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.util.Animator; + +/** + * Bug 816: OSX CALayer Positioning Bug - AWT Applet w/ 1 JRootPane and 2 JSplitPanes + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + *

        + * See also {@link com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT} + *

        + * Bug persists in browser (Firefox, Safari) and not in appletviewer! + */ +@SuppressWarnings("serial") +public class Bug816AppletOSXCALayerPos03a extends Applet { + GLAnimatorControl animator; + boolean added = false; + + @Override + public void init() { + System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + GLProfile glp = GLProfile.getDefault(); + final GLCapabilities caps = new GLCapabilities(glp); + final GLCanvas glCanvas1 = new GLCanvas(caps); + glCanvas1.addGLEventListener(new GearsES2(1)); + + animator = new Animator(); + animator.add(glCanvas1); + setLayout(new BorderLayout()); + + // Build a GUI where the canvas 3D is located at top right of the frame + // and can be resized with split panes dividers + JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + true, new JScrollPane(), glCanvas1); + verticalSplitPane.setResizeWeight(0.5); + JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, + true, new JScrollPane(), verticalSplitPane); + horizontalSplitPane.setResizeWeight(0.5); + JRootPane intermediateRootPane = new JRootPane(); + intermediateRootPane.setContentPane(horizontalSplitPane); + add(intermediateRootPane, BorderLayout.CENTER); + System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + } + + String currentThreadName() { + return Thread.currentThread().getName(); + } + + @Override + public void start() { + System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator.start(); + animator.setUpdateFPSFrames(60, System.err); + System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + } + + @Override + public void stop() { + System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator.stop(); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03b.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03b.java new file mode 100644 index 000000000..48dac25e8 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03b.java @@ -0,0 +1,101 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.JApplet; +import javax.swing.JRootPane; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.util.Animator; + +/** + * Bug 816: OSX CALayer Positioning Bug - Swing JApplet w/ 2 JRootPanes and 2 JSplitPanes + *

        + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

        + *

        + * See also {@link com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT} + *

        + * Bug persists in browser (Firefox, Safari) and not in appletviewer! + */ +@SuppressWarnings("serial") +public class Bug816AppletOSXCALayerPos03b extends JApplet { + GLAnimatorControl animator; + boolean added = false; + + @Override + public void init() { + System.err.println("GearsApplet: init() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + GLProfile glp = GLProfile.getDefault(); + final GLCapabilities caps = new GLCapabilities(glp); + final GLCanvas glCanvas1 = new GLCanvas(caps); + glCanvas1.addGLEventListener(new GearsES2(1)); + + animator = new Animator(); + animator.add(glCanvas1); + setSize(640, 480); + + // Build a GUI where the canvas 3D is located at top right of the frame + // and can be resized with split panes dividers + JSplitPane verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, + true, new JScrollPane(), glCanvas1); + verticalSplitPane.setResizeWeight(0.5); + JSplitPane horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, + true, new JScrollPane(), verticalSplitPane); + horizontalSplitPane.setResizeWeight(0.5); + JRootPane intermediateRootPane = new JRootPane(); + intermediateRootPane.setContentPane(horizontalSplitPane); + intermediateRootPane.setSize(640, 480); + this.add(intermediateRootPane); + System.err.println("GearsApplet: init() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + } + + String currentThreadName() { + return Thread.currentThread().getName(); + } + + @Override + public void start() { + System.err.println("GearsApplet: start() - begin [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator.start(); + animator.setUpdateFPSFrames(60, System.err); + System.err.println("GearsApplet: start() - end [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + } + + @Override + public void stop() { + System.err.println("GearsApplet: stop() - [visible "+isVisible()+", displayable "+isDisplayable()+"] - "+currentThreadName()); + animator.stop(); + } +} -- cgit v1.2.3 From e96b2d648e7d69b95325fb6b80c6eb508e1e8a14 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Oct 2013 17:12:33 +0200 Subject: NEWT Reparent/Fullscreen: Add 'waitForPosition(..)' when reparenting or back from fullscreen; JOGLNewtAppletBase: Reparent to pos 32/32, trying to avoid browser window focus/top stealing on X11. --- make/scripts/make.jogl.all.macosx-clang.sh | 1 + make/scripts/make.jogl.all.macosx-java7.sh | 22 ---------------------- make/scripts/make.jogl.all.macosx.sh | 1 + make/scripts/tests.sh | 4 ++-- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 13 ++++++++++++- src/newt/classes/jogamp/newt/WindowImpl.java | 12 +++++++++--- .../es2/awt/Bug816AppletOSXCALayerPos03a.java | 1 - 7 files changed, 25 insertions(+), 29 deletions(-) delete mode 100755 make/scripts/make.jogl.all.macosx-java7.sh (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.macosx-clang.sh b/make/scripts/make.jogl.all.macosx-clang.sh index af9f1e1fe..eb633f5a6 100755 --- a/make/scripts/make.jogl.all.macosx-clang.sh +++ b/make/scripts/make.jogl.all.macosx-clang.sh @@ -5,6 +5,7 @@ if [ -e /opt-share/etc/profile.ant ] ; then fi JAVA_HOME=`/usr/libexec/java_home -version 1.7` +#JAVA_HOME=`/usr/libexec/java_home -version 1.6` PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH diff --git a/make/scripts/make.jogl.all.macosx-java7.sh b/make/scripts/make.jogl.all.macosx-java7.sh deleted file mode 100755 index ee82bbc91..000000000 --- a/make/scripts/make.jogl.all.macosx-java7.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh - -if [ -e /opt-share/etc/profile.ant ] ; then - . /opt-share/etc/profile.ant -fi - - -# -Dc.compiler.debug=true \ -# -Djavacdebug="true" \ -# -Djavacdebuglevel="source,lines,vars" \ -# - -JAVA_HOME=`/usr/libexec/java_home -version 1.7` -PATH=$JAVA_HOME/bin:$PATH -export JAVA_HOME PATH - -#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" -export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" - -ant \ - -Drootrel.build=build-macosx-java7 \ - $* 2>&1 | tee make.jogl.all.macosx-java7.log diff --git a/make/scripts/make.jogl.all.macosx.sh b/make/scripts/make.jogl.all.macosx.sh index c80b41d1d..0c7fd7842 100755 --- a/make/scripts/make.jogl.all.macosx.sh +++ b/make/scripts/make.jogl.all.macosx.sh @@ -5,6 +5,7 @@ if [ -e /opt-share/etc/profile.ant ] ; then fi JAVA_HOME=`/usr/libexec/java_home -version 1.7` +#JAVA_HOME=`/usr/libexec/java_home -version 1.6` PATH=$JAVA_HOME/bin:$PATH export JAVA_HOME PATH diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9ca5374e4..023d37d74 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -299,7 +299,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -456,7 +456,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cAWT $* diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 25ddfad48..1004adb8e 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -33,6 +33,7 @@ import java.security.PrivilegedAction; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.WindowClosingProtocol.WindowClosingMode; +import javax.media.nativewindow.util.InsetsImmutable; import javax.media.opengl.FPSCounter; import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; @@ -301,7 +302,17 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { if(null == glWindow.getParent()) { glWindow.reparentWindow(awtParent); } else { - glWindow.reparentWindow(null); + final InsetsImmutable insets = glWindow.getInsets(); + final int x, y; + if ( 0 >= insets.getTopHeight() ) { + // fail safe .. + x = 32; + y = 32; + } else { + x = insets.getLeftWidth(); + y = insets.getTopHeight(); + } + glWindow.reparentWindow(null, x, y, false /* forceDestroyCreate */); glWindow.setDefaultCloseOperation( glClosable ? WindowClosingMode.DISPOSE_ON_CLOSE : WindowClosingMode.DO_NOTHING_ON_CLOSE ); } } diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 300ca5c3f..b7357863f 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1342,6 +1342,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(ok) { ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } + if(ok) { + ok = WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); + } if(ok) { requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); display.dispatchMessagesNative(); // status up2date @@ -1375,7 +1378,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparentWindow: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); + System.err.println("Window.reparent: END-1 ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } } finally { if(null!=lifecycleHook) { @@ -1399,7 +1402,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparentWindow: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); + System.err.println("Window.reparent: END-X ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+ Display.hashCodeNullSafe(parentWindow)+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } } } @@ -1410,7 +1413,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer _lock.lock(); try { if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparentWindow: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow)); + System.err.println("Window.reparent: ReparentActionRecreate ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+", visible: "+visible+", parentWindowHandle "+toHexString(parentWindowHandle)+", parentWindow "+Display.hashCodeNullSafe(parentWindow)); } setVisibleActionImpl(true); // native creation requestFocusInt( 0 == parentWindowHandle /* skipFocusAction if top-level */); @@ -2020,6 +2023,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(ok) { ok = WindowImpl.this.waitForSize(w, h, false, TIMEOUT_NATIVEWINDOW); } + if(ok && !fullscreen) { + ok = WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); + } if(ok) { requestFocusInt(fullscreen /* skipFocusAction if fullscreen */); display.dispatchMessagesNative(); // status up2date diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java index a70625129..a0ce938fe 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/awt/Bug816AppletOSXCALayerPos03a.java @@ -29,7 +29,6 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.awt; import java.applet.Applet; import java.awt.BorderLayout; -import java.awt.Button; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLCapabilities; -- cgit v1.2.3 From 8363df5da5794faf10478789954992cef0c0d50f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 10 Oct 2013 13:16:39 +0200 Subject: Bug 852: Validate CPU sourced data API is allowed, throw exception if not. GLContext: isCPUSourcedAvail() -> isCPUDataSourcingAvail() --- make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 15 +++++++++++++++ make/config/jogl/gl-impl-CustomJavaCode-gles3.java | 12 ++++++++++++ make/scripts/tests.sh | 4 ++-- src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java | 6 +++--- src/jogl/classes/javax/media/opengl/GLContext.java | 4 ++-- .../opengl/util/glsl/fixedfunc/FixedFuncPipeline.java | 4 ++-- .../junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java | 1 - 7 files changed, 36 insertions(+), 10 deletions(-) (limited to 'make/scripts') diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index c769ddcfa..30047278b 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -334,7 +334,16 @@ private final boolean checkBufferObject(boolean extensionAvail, } } +private final void validateCPUSourcedAvail() { + if(!_context.isCPUDataSourcingAvail()) { + throw new GLException("CPU data sourcing n/a w/ "+_context); + } +} + private final boolean checkArrayVBOUnbound(boolean throwException) { + if(throwException) { + validateCPUSourcedAvail(); + } return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO false, // bound @@ -351,6 +360,9 @@ private final boolean checkArrayVBOBound(boolean throwException) { } private final boolean checkElementVBOUnbound(boolean throwException) { + if(throwException) { + validateCPUSourcedAvail(); + } return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO false, // bound @@ -367,6 +379,9 @@ private final boolean checkElementVBOBound(boolean throwException) { } private final boolean checkIndirectVBOUnbound(boolean throwException) { + if(throwException) { + validateCPUSourcedAvail(); + } return checkBufferObject(haveGL15 || haveARBVertexBufferObject, haveARBVertexArrayObject, // allowVAO false, // bound diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java index 38deb3399..83bdd7691 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -255,7 +255,16 @@ private final boolean checkBufferObject(boolean extensionAvail, } } +private final void validateCPUSourcedAvail() { + if(!_context.isCPUDataSourcingAvail()) { + throw new GLException("CPU data sourcing n/a w/ "+_context); + } +} + private final boolean checkArrayVBOUnbound(boolean throwException) { + if(throwException) { + validateCPUSourcedAvail(); + } return checkBufferObject(true, _isES3, // allowVAO false, // bound @@ -272,6 +281,9 @@ private final boolean checkArrayVBOBound(boolean throwException) { } private final boolean checkElementVBOUnbound(boolean throwException) { + if(throwException) { + validateCPUSourcedAvail(); + } return checkBufferObject(true, _isES3, // allowVAO false, // bound diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 023d37d74..eb8a119a7 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -299,14 +299,14 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java index dbe916877..111e2509e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java +++ b/src/jogl/classes/com/jogamp/opengl/util/ImmModeSink.java @@ -522,9 +522,9 @@ public class ImmModeSink { gl.glDrawArrays(mode, 0, vElems); } } else { - // FIXME: Impl. VBO usage .. or unroll (see above)! - if( !gl.getContext().isCPUSourcedAvail() ) { - throw new GLException("CPU sourcing n/a w/ "+gl.getContext()); + // FIXME: Impl. VBO usage .. or unroll. + if( !gl.getContext().isCPUDataSourcingAvail() ) { + throw new GLException("CPU data sourcing n/a w/ "+gl.getContext()); } final int type; if(indices instanceof ByteBuffer) { diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index 3a72319bb..f4dbde6b2 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -1010,12 +1010,12 @@ public abstract class GLContext { } /** - * Indicates whether this GLContext allows CPU sourced data (indices, vertices ..) as opposed to a GPU buffer source (VBO), + * Indicates whether this GLContext allows CPU data sourcing (indices, vertices ..) as opposed to using a GPU buffer source (VBO), * e.g. {@link GL2#glDrawElements(int, int, int, java.nio.Buffer)}. *

        Includes [GL2ES1, GLES2] == [ GL4bc, GL3bc, GL2, GLES1, GL2ES1, GLES2 ].

        *

        See Bug 852 - https://jogamp.org/bugzilla/show_bug.cgi?id=852

        */ - public final boolean isCPUSourcedAvail() { + public final boolean isCPUDataSourcingAvail() { return isGL2ES1() || isGLES2(); } diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java index 173f7b3c6..5349745ea 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncPipeline.java @@ -744,8 +744,8 @@ public class FixedFuncPipeline { } } else { // FIXME: Impl. VBO usage .. or unroll (see above)! - if( !gl.getContext().isCPUSourcedAvail() ) { - throw new GLException("CPU sourcing n/a w/ "+gl.getContext()); + if( !gl.getContext().isCPUDataSourcingAvail() ) { + throw new GLException("CPU data sourcing n/a w/ "+gl.getContext()); } if( GL2ES1.GL_POINTS != mode ) { ((GLES2)gl).glDrawElements(mode, count, type, indices); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java index b2f72b7c3..69879ddb2 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestRedSquareES2NEWT.java @@ -35,7 +35,6 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; -import com.jogamp.opengl.test.junit.util.UITestCase.SnapshotGLEventListener; import com.jogamp.opengl.util.Animator; -- cgit v1.2.3 From 2634ce35031be322cb355e4d6055aace6a2c0619 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 12 Oct 2013 19:00:15 +0200 Subject: Bug 859: Let TileRenderer detect zero columns and rows in eot() where beginTile() throws an EOT IllegalStateException to avoid division by zero --- make/scripts/tests.sh | 4 +- .../com/jogamp/opengl/util/RandomTileRenderer.java | 23 +++++- .../com/jogamp/opengl/util/TileRenderer.java | 95 ++++++++++++++++------ .../com/jogamp/opengl/util/TileRendererBase.java | 41 +++++++++- .../classes/javax/media/opengl/awt/GLCanvas.java | 32 +++++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 29 ++++--- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 24 ++++-- .../opengl/test/junit/jogl/demos/gl2/Gears.java | 23 +++--- .../jogl/tile/TestTiledRendering1GL2NEWT.java | 93 ++++++++++++++++++--- .../junit/jogl/tile/TestTiledRendering2NEWT.java | 4 +- 10 files changed, 282 insertions(+), 86 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index eb8a119a7..4b96bd470 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -306,7 +306,7 @@ function testawtswt() { #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testswt com.jogamp.opengl.test.junit.jogl.demos.es2.swt.TestGearsES2SWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT $* @@ -336,7 +336,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java index 8fc7916c7..a2b7ba343 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/RandomTileRenderer.java @@ -96,7 +96,28 @@ public class RandomTileRenderer extends TileRendererBase { /** * {@inheritDoc} - * @throws IllegalStateException if image-size or tileRect has not been set + * + *

        + * end of tiling is never reached w/ {@link RandomRileRenderer}, + * i.e. method always returns false. + *

        + */ + @Override + public final boolean eot() { return false; } + + /** + * {@inheritDoc} + * + * Reset internal states of {@link RandomTileRenderer} are: none. + */ + @Override + public final void reset() { } + + /** + * {@inheritDoc} + * + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or + * {@link #setTileRect(int, int, int, int) tile-rect} has not been set. */ @Override public final void beginTile(GL gl) throws IllegalStateException, GLException { diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java index f126eb7f5..deab8bc3e 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRenderer.java @@ -101,7 +101,7 @@ public class TileRenderer extends TileRendererBase { */ public static final int TR_COLUMNS = 15; /** - * The current tile number. See {@link #getParam(int)}. + * The current tile number. Has value -1 if {@link #eot()}. See {@link #getParam(int)}. */ public static final int TR_CURRENT_TILE_NUM = 16; /** @@ -132,12 +132,13 @@ public class TileRenderer extends TileRendererBase { private final Dimension tileSize = new Dimension(DEFAULT_TILE_WIDTH, DEFAULT_TILE_HEIGHT); private final Dimension tileSizeNB = new Dimension(DEFAULT_TILE_WIDTH - 2 * DEFAULT_TILE_BORDER, DEFAULT_TILE_HEIGHT - 2 * DEFAULT_TILE_BORDER); - protected Dimension imageClippingDim = null; // not set - default + private boolean isInit = false; + private Dimension imageClippingDim = null; // not set - default private int tileBorder = DEFAULT_TILE_BORDER; private int rowOrder = TR_BOTTOM_TO_TOP; private int rows; private int columns; - private int currentTile = -1; + private int currentTile = 0; private int currentRow; private int currentColumn; private int offsetX; @@ -157,6 +158,18 @@ public class TileRenderer extends TileRendererBase { super(); } + /** + * {@inheritDoc} + *

        + * Implementation {@link #reset()} internal states. + *

        + */ + @Override + public final void setImageSize(int width, int height) { + super.setImageSize(width, height); + reset(); + } + /** * Clips the image-size this tile-renderer iterates through, * which can be retrieved via {@link #getClippedImageSize()}. @@ -164,7 +177,7 @@ public class TileRenderer extends TileRendererBase { * Original image-size stored in this tile-renderer is unmodified. *

        *

        - * Method resets internal state and {@link #TR_ROWS} {@link #TR_COLUMNS} count. + * Implementation {@link #reset()} internal states. *

        * * @param width The image-clipping.width @@ -178,7 +191,7 @@ public class TileRenderer extends TileRendererBase { imageClippingDim.setWidth(width); imageClippingDim.setHeight(height); } - setup(); + reset(); } /** @@ -210,7 +223,7 @@ public class TileRenderer extends TileRendererBase { * effective size of the tile depends on the border size, ie ( * width - 2*border ) * ( height - 2 * border ) *

        - * Method resets internal state and {@link #TR_ROWS} {@link #TR_COLUMNS} count. + * Implementation {@link #reset()} internal states. *

        * * @param width @@ -236,7 +249,7 @@ public class TileRenderer extends TileRendererBase { tileSize.setHeight( height ); tileSizeNB.setWidth( width - 2 * border ); tileSizeNB.setHeight( height - 2 * border ); - setup(); + reset(); } /** @@ -251,32 +264,43 @@ public class TileRenderer extends TileRendererBase { } /** - * Sets up the number of rows and columns needed + * {@inheritDoc} + * + * Reset internal states of {@link TileRenderer} are: + *
          + *
        • {@link #TR_ROWS}
        • + *
        • {@link #TR_COLUMNS}
        • + *
        • {@link #TR_CURRENT_COLUMN}
        • + *
        • {@link #TR_CURRENT_ROW}
        • + *
        • {@link #TR_CURRENT_TILE_NUM}
        • + *
        • {@link #TR_CURRENT_TILE_X_POS}
        • + *
        • {@link #TR_CURRENT_TILE_Y_POS}
        • + *
        • {@link #TR_CURRENT_TILE_WIDTH}
        • + *
        • {@link #TR_CURRENT_TILE_HEIGHT}
        • + *
        */ - private final void setup() throws IllegalStateException { + @Override + public final void reset() { final DimensionImmutable clippedImageSize = getClippedImageSize(); columns = ( clippedImageSize.getWidth() + tileSizeNB.getWidth() - 1 ) / tileSizeNB.getWidth(); rows = ( clippedImageSize.getHeight() + tileSizeNB.getHeight() - 1 ) / tileSizeNB.getHeight(); + currentRow = 0; + currentColumn = 0; currentTile = 0; currentTileXPos = 0; currentTileYPos = 0; currentTileWidth = 0; currentTileHeight = 0; - currentRow = 0; - currentColumn = 0; assert columns >= 0; assert rows >= 0; + + beginCalled = false; + isInit = true; } /* pp */ final int getCurrentTile() { return currentTile; } - /** - * Returns true if all tiles have been rendered or {@link #setup()} - * has not been called, otherwise false. - */ - public final boolean eot() { return 0 > currentTile; } - @Override public final int getParam(int pname) { switch (pname) { @@ -341,16 +365,41 @@ public class TileRenderer extends TileRendererBase { return 0 < imageSize.getWidth() && 0 < imageSize.getHeight(); } + /** + * {@inheritDoc} + * + *

        + * end of tiling is reached w/ {@link TileRenderer}, if at least one of the following is true: + *

          + *
        • all tiles have been rendered, i.e. {@link #TR_CURRENT_TILE_NUM} is -1
        • + *
        • no tiles to render, i.e. {@link #TR_COLUMNS} or {@link #TR_ROWS} is 0
        • + *
        + *

        + */ + @Override + public final boolean eot() { + if ( !isInit ) { // ensure at least one reset-call + reset(); + } + return 0 > currentTile || 0 >= columns*rows; + } + + /** + * {@inheritDoc} + * + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} has not been set or + * {@link #eot() end-of-tiling} has been reached. + */ @Override public final void beginTile( GL gl ) throws IllegalStateException, GLException { if( !isSetup() ) { - throw new IllegalStateException("Image size has not been set"); + throw new IllegalStateException("Image size has not been set: "+this); } - validateGL(gl); - if (currentTile <= 0) { - setup(); + if ( eot() ) { + throw new IllegalStateException("EOT reached: "+this); } - + validateGL(gl); + /* which tile (by row and column) we're about to render */ if (rowOrder == TR_BOTTOM_TO_TOP) { currentRow = currentTile / columns; @@ -390,7 +439,7 @@ public class TileRenderer extends TileRendererBase { gl.glViewport( 0, 0, tW, tH ); if( DEBUG ) { - System.err.println("TileRenderer.begin.X: "+this.toString()); + System.err.println("TileRenderer.begin: "+this.toString()); } // Do not forget to issue: diff --git a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java index f15c79f68..d6c36aa14 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/TileRendererBase.java @@ -241,6 +241,7 @@ public abstract class TileRendererBase { tileDetails(sb); sb.append("], image[size "+imageSize+", buffer "+hashStr(imageBuffer)+"], glad["+ gladListenerCount+" listener, pre "+(null!=glEventListenerPre)+", post "+(null!=glEventListenerPost)+", preSwap "+gladRequiresPreSwap+"]"); + sb.append(", isSetup "+isSetup()); return sb; } public String toString() { @@ -284,7 +285,7 @@ public abstract class TileRendererBase { * @param width The width of the final image * @param height The height of the final image */ - public final void setImageSize(int width, int height) { + public void setImageSize(int width, int height) { imageSize.setWidth(width); imageSize.setHeight(height); } @@ -320,6 +321,27 @@ public abstract class TileRendererBase { */ public abstract boolean isSetup(); + /** + * Returns true if end of tiling has been reached, otherwise false. + *

        + * end of tiling criteria is implementation specific and may never be reached. + *

        + *

        + * User needs to {@link #reset()} tiling after reaching end of tiling + * before calling {@link #beginTile(GL)} again. + *

        + */ + public abstract boolean eot(); + + /** + * Method resets implementation's internal state to start of tiling + * as required for {@link #beginTile(GL)} if {@link #eot() end of tiling} has been reached. + *

        + * Implementation is a nop where {@link #eot() end of tiling} is never reached. + *

        + */ + public abstract void reset(); + /** * Begins rendering a tile. *

        @@ -351,10 +373,19 @@ public abstract class TileRendererBase { *

        * User has to comply with the GL profile requirement. *

        + *

        + * If {@link #eot() end of tiling} has been reached, + * user needs to {@link #reset()} tiling before calling this method. + *

        * * @param gl The gl context - * @throws IllegalStateException if image-size has not been set + * @throws IllegalStateException if {@link #setImageSize(int, int) image-size} is undefined, + * an {@link #isSetup() implementation related setup} has not be performed + * or {@ link #eot()} has been reached. See implementing classes. * @throws GLException if {@link #setImageBuffer(GLPixelBuffer) image buffer} is used but gl instance is < {@link GL2ES3} + * @see #isSetup() + * @see #eot() + * @see #reset() */ public abstract void beginTile(GL gl) throws IllegalStateException, GLException; @@ -594,6 +625,12 @@ public abstract class TileRendererBase { } return; } + if( eot() ) { + if( DEBUG ) { + System.err.println("TileRenderer.glel.display: EOT: "+TileRendererBase.this); + } + return; + } final GL gl = drawable.getGL(); beginTile(gl); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index f86a6a347..20dd802fb 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -837,20 +837,26 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final Graphics2D g2d = (Graphics2D)graphics; try { printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); - try { - final TileRenderer tileRenderer = printAWTTiles.renderer; - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); - } - do { - if( printGLAD != GLCanvas.this ) { - tileRenderer.display(); - } else { - Threading.invoke(true, displayOnEDTAction, getTreeLock()); + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + if( !tileRenderer.eot() ) { + try { + do { + if( printGLAD != GLCanvas.this ) { + tileRenderer.display(); + } else { + Threading.invoke(true, displayOnEDTAction, getTreeLock()); + } + } while ( !tileRenderer.eot() ); + if( DEBUG ) { + System.err.println("AWT print.1: "+printAWTTiles); } - } while ( !tileRenderer.eot() ); - } finally { - printAWTTiles.resetGraphics2D(); + } finally { + tileRenderer.reset(); + printAWTTiles.resetGraphics2D(); + } } } catch (NoninvertibleTransformException nte) { System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index fb39143b4..673f22aff 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -646,17 +646,26 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final Graphics2D g2d = (Graphics2D)graphics; try { printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); - try { - final TileRenderer tileRenderer = printAWTTiles.renderer; - do { - if( printGLAD != GLJPanel.this ) { - tileRenderer.display(); - } else { - backend.doPlainPaint(); + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + if( !tileRenderer.eot() ) { + try { + do { + if( printGLAD != GLJPanel.this ) { + tileRenderer.display(); + } else { + backend.doPlainPaint(); + } + } while ( !tileRenderer.eot() ); + if( DEBUG ) { + System.err.println("AWT print.1: "+printAWTTiles); } - } while ( !tileRenderer.eot() ); - } finally { - printAWTTiles.resetGraphics2D(); + } finally { + tileRenderer.reset(); + printAWTTiles.resetGraphics2D(); + } } } catch (NoninvertibleTransformException nte) { System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 86faea35f..73b3bc368 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -598,16 +598,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final Graphics2D g2d = (Graphics2D)graphics; try { printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); - try { - final TileRenderer tileRenderer = printAWTTiles.renderer; - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + if( !tileRenderer.eot() ) { + try { + do { + tileRenderer.display(); + } while ( !tileRenderer.eot() ); + if( DEBUG ) { + System.err.println("AWT print.1: "+printAWTTiles); + } + tileRenderer.reset(); + } finally { + printAWTTiles.resetGraphics2D(); } - do { - tileRenderer.display(); - } while ( !tileRenderer.eot() ); - } finally { - printAWTTiles.resetGraphics2D(); } } catch (NoninvertibleTransformException nte) { System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java index 74089c2fd..031d6a1c1 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/gl2/Gears.java @@ -97,11 +97,6 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); - System.err.println(Thread.currentThread()+" Gears.init: tileRendererInUse "+tileRendererInUse); - System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); - System.err.println("INIT GL IS: " + gl.getClass().getName()); - System.err.println(JoglVersion.getGLStrings(gl, null, false).toString()); - init(gl); final Object upstreamWidget = drawable.getUpstreamWidget(); @@ -122,6 +117,14 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList float green[] = { 0.0f, 0.8f, 0.2f, 0.7f }; float blue[] = { 0.2f, 0.2f, 1.0f, 0.7f }; + System.err.println(Thread.currentThread()+" Gears.init: tileRendererInUse "+tileRendererInUse); + if(verbose) { + System.err.println("GearsES2 init on "+Thread.currentThread()); + System.err.println("Chosen GLCapabilities: " + gl.getContext().getGLDrawable().getChosenGLCapabilities()); + System.err.println("INIT GL IS: " + gl.getClass().getName()); + System.err.println(JoglVersion.getGLStrings(gl, null, false).toString()); + } + gl.glLightfv(GL2.GL_LIGHT0, GL2.GL_POSITION, pos, 0); gl.glEnable(GL2.GL_CULL_FACE); gl.glEnable(GL2.GL_LIGHTING); @@ -171,11 +174,7 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList if(-1 != swapInterval) { gl.setSwapInterval(swapInterval); } - reshapeImpl(gl, x, y, width, height, width, height); - } - - public void reshape(GL2 gl, int x, int y, int width, int height) { - reshapeImpl(gl, x, y, width, height, width, height); + reshape(gl, x, y, width, height, width, height); } @Override @@ -184,10 +183,10 @@ public class Gears implements GLEventListener, TileRendererBase.TileRendererList int imageWidth, int imageHeight) { final GL2 gl = tr.getAttachedDrawable().getGL().getGL2(); gl.setSwapInterval(0); - reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); + reshape(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); } - void reshapeImpl(GL2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { + public void reshape(GL2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); System.err.println(Thread.currentThread()+" Gears.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java index c38140ce0..e0fabc3cc 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering1GL2NEWT.java @@ -46,7 +46,6 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import org.junit.Assert; @@ -67,11 +66,6 @@ import org.junit.runners.MethodSorters; public class TestTiledRendering1GL2NEWT extends UITestCase { static long duration = 500; // ms - @Test - public void test01() throws IOException { - doTest(); - } - static class DrawableContext { DrawableContext(GLDrawable d, GLContext glc) { this.d = d; @@ -102,7 +96,8 @@ public class TestTiledRendering1GL2NEWT extends UITestCase { } } - void doTest() throws GLException, IOException { + @Test + public void test01() throws IOException { GLProfile glp = GLProfile.getMaxFixedFunc(true); GLCapabilities caps = new GLCapabilities(glp); caps.setOnscreen(false); @@ -132,15 +127,19 @@ public class TestTiledRendering1GL2NEWT extends UITestCase { flipVertically[0] = false; final Gears gears = new Gears(); + gears.setVerbose(false); gears.init(gl); gears.addTileRendererNotify(renderer); - do { - renderer.beginTile(dc.glc.getGL().getGL2ES3()); - gears.reshape(gl, 0, 0, renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT)); + while( !renderer.eot() ) { + renderer.beginTile(gl); + gears.reshape(gl, + renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS), + renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT), + renderer.getParam(TileRendererBase.TR_IMAGE_WIDTH), renderer.getParam(TileRendererBase.TR_IMAGE_HEIGHT)); gears.display(gl); - renderer.endTile(dc.glc.getGL().getGL2ES3()); - } while ( !renderer.eot() ); + renderer.endTile(gl); + } gears.removeTileRendererNotify(renderer); destroyDrawableContext(dc); @@ -160,6 +159,76 @@ public class TestTiledRendering1GL2NEWT extends UITestCase { TextureIO.write(textureData, file); } + @Test + public void test02_EOT_01() throws IOException { + GLProfile glp = GLProfile.getMaxFixedFunc(true); + GLCapabilities caps = new GLCapabilities(glp); + caps.setOnscreen(false); + + final int maxTileSize = 256; + DrawableContext dc = createDrawableAndCurrentCtx(caps, maxTileSize, maxTileSize); + final GL2 gl = dc.glc.getGL().getGL2(); + + // Fix the image size for now + final int imageWidth = dc.d.getWidth() * 6; + final int imageHeight = dc.d.getHeight() * 4; + + // Initialize the tile rendering library + final TileRenderer renderer = new com.jogamp.opengl.util.TileRenderer(); + renderer.setTileSize(dc.d.getWidth(), dc.d.getHeight(), 0); + + IllegalStateException ise = null; + try { + renderer.beginTile(gl); // Image size has not been set + } catch (IllegalStateException _ise) { + ise = _ise; + System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage()); + } + Assert.assertNotNull("TileRenderer.beginTile: Image-size exception missing", ise); + + renderer.setImageSize(imageWidth, imageHeight); + + renderer.clipImageSize(0, 0); + try { + renderer.beginTile(gl); // EOT reached (1) + } catch (IllegalStateException _ise) { + ise = _ise; + System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage()); + } + Assert.assertNotNull("TileRenderer.beginTile: EOT (1) exception missing", ise); + + renderer.clipImageSize(imageWidth, imageHeight); // back to full size + + final Gears gears = new Gears(); + gears.setVerbose(false); + gears.init(gl); + + gears.addTileRendererNotify(renderer); + int numTiles = 0; + while( !renderer.eot() ) { + renderer.beginTile(gl); + gears.reshape(gl, + renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS), + renderer.getParam(TileRendererBase.TR_CURRENT_TILE_WIDTH), renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT), + renderer.getParam(TileRendererBase.TR_IMAGE_WIDTH), renderer.getParam(TileRendererBase.TR_IMAGE_HEIGHT)); + gears.display(gl); + renderer.endTile(gl); + numTiles++; + } + try { + renderer.beginTile(gl); // EOT reached (2) + } catch (IllegalStateException _ise) { + ise = _ise; + System.err.println("Expected "+ise.getClass().getSimpleName()+": "+ise.getMessage()); + } + Assert.assertNotNull("TileRenderer.beginTile: EOT (2) exception missing", ise); + gears.removeTileRendererNotify(renderer); + + Assert.assertTrue("TileRenderer not rendered more than one tile but "+numTiles, numTiles > 1); + + destroyDrawableContext(dc); + } + public static void main(String args[]) { for(int i=0; i Date: Sat, 12 Oct 2013 20:00:01 +0200 Subject: Bug 860 - AWT Printing (AWTTilePainter): Shall use the enclosing integer rectangle of the scaled double precision clipping rect AWTTilePainter simply rounds the scaled double precision clipping rectangle to receive the integer rectangle. This leads to uncovered drawing areas, since the integer rectangle position could be greater - and the size could be smaller than the double precision source. To get the enclosing rectangle, we need to use iPos = floor(position) iSize = ceil(position+size) - floor(position) .. turns our that the double precision 'Rectangle Rectangle2D.getBounds()' already performs this math. --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java | 9 ++------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4b96bd470..be5bd08b9 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -333,10 +333,10 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # # core/newt (testnoawt and testawt) diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index fbf6faf08..0600d99f5 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -148,11 +148,6 @@ public class AWTTilePainter { flipVertical = v; } - private static Rectangle getRoundedRect(Rectangle2D r) { - if( null == r ) { return null; } - return new Rectangle((int)Math.round(r.getX()), (int)Math.round(r.getY()), - (int)Math.round(r.getWidth()), (int)Math.round(r.getHeight())); - } private static Rectangle2D getClipBounds2D(Graphics2D g) { final Shape shape = g.getClip(); return null != shape ? shape.getBounds2D() : null; @@ -221,8 +216,8 @@ public class AWTTilePainter { dClipScaled = scaledATI.createTransformedShape(s0).getBounds2D(); // scaled out } } - final Rectangle iClipScaled = getRoundedRect(dClipScaled); - final Rectangle iImageSizeScaled = getRoundedRect(dImageSizeScaled); + final Rectangle iClipScaled = dClipScaled.getBounds(); + final Rectangle iImageSizeScaled = dImageSizeScaled.getBounds(); renderer.setImageSize(iImageSizeScaled.width, iImageSizeScaled.height); renderer.clipImageSize(iClipScaled.width, iClipScaled.height); final int clipH = Math.min(iImageSizeScaled.height, iClipScaled.height); -- cgit v1.2.3 From 74c5332456c6faf48c0a81809969d54e056f346c Mon Sep 17 00:00:00 2001 From: Michael Esemplare Date: Sun, 13 Oct 2013 00:06:07 +0200 Subject: Bug 365: Add unit test, which run's through most of the ScaleInternal functions for a single column image. --- make/scripts/tests.sh | 3 +- .../jogl/glu/TestBug365TextureGenerateMipMaps.java | 272 +++++++++++++++++++++ 2 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index be5bd08b9..fa44190c0 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -333,7 +333,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -479,6 +479,7 @@ testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug694ScaleImageUnpackBufferSizeAWT $* +testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug365TextureGenerateMipMaps $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java new file mode 100644 index 000000000..4d9b750c4 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java @@ -0,0 +1,272 @@ +package com.jogamp.opengl.test.junit.jogl.glu; + +import java.nio.ByteBuffer; + +import javax.media.opengl.GL2; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import jogamp.opengl.glu.mipmap.Mipmap; +import jogamp.opengl.glu.mipmap.ScaleInternal; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.texture.Texture; +import com.jogamp.opengl.util.texture.TextureData; +import com.jogamp.opengl.util.texture.TextureIO; + +/** + * This test creates a {@link Texture} from {@link TextureData} of various pixel formats + * and pixel types with auto generate mipmaps set to {@code true}. + *

        + * Bug Reference: https://jogamp.org/bugzilla/show_bug.cgi?id=365 + *

        + * The bug pertains to mipmap generation from a Texture and exists in {@link ScaleInternal} + * where a {@link java.nio.BufferUnderflowException} is thrown. + *

        + *
          This suite of test cases test: + *
        • {@link ScaleInternal#scale_internal_ubyte(int, int, int, ByteBuffer, int, int, ByteBuffer, int, int, int)}
        • + *
        • {@link ScaleInternal#scale_internal_byte(int, int, int, ByteBuffer, int, int, ByteBuffer, int, int, int)}
        • + *
        • {@link ScaleInternal#scale_internal_ushort(int, int, int, ByteBuffer, int, int, java.nio.ShortBuffer, int, int, int, boolean)}
        • + *
        • {@link ScaleInternal#scale_internal_short(int, int, int, ByteBuffer, int, int, java.nio.ShortBuffer, int, int, int, boolean)}
        • + *
        • {@link ScaleInternal#scale_internal_uint(int, int, int, ByteBuffer, int, int, java.nio.IntBuffer, int, int, int, boolean)}
        • + *
        • {@link ScaleInternal#scale_internal_int(int, int, int, ByteBuffer, int, int, java.nio.IntBuffer, int, int, int, boolean)}
        • + *
        • {@link ScaleInternal#scale_internal_float(int, int, int, ByteBuffer, int, int, java.nio.FloatBuffer, int, int, int, boolean)}
        • + *
        + * + * @author Michael Esemplare, et.al. + * + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug365TextureGenerateMipMaps extends UITestCase { + static GLOffscreenAutoDrawable drawable; + + @BeforeClass + public static void setup() throws Throwable { + // disableNPOT + System.setProperty("jogl.texture.nonpot", "true"); + try { + setUpOffscreenAutoDrawable(); + } catch (Throwable t) { + throw t; + } + } + + @AfterClass + public static void teardown() { + tearDownOffscreenAutoDrawable(); + } + + private static void setUpOffscreenAutoDrawable() throws Throwable { + GLProfile glp = GLProfile.getDefault(); + GLCapabilities caps = new GLCapabilities(glp); + + GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); + + // Make a drawable to get an offscreen context + drawable = factory.createOffscreenAutoDrawable(null, caps, null, 2, 2, null); + + drawable.setRealized(true); + + GLContext glContext = drawable.getContext(); + try { + Assert.assertTrue("Could not make context current", GLContext.CONTEXT_NOT_CURRENT < glContext.makeCurrent()); + } catch (Throwable t) { + tearDownOffscreenAutoDrawable(); + throw t; + } + } + + private static void tearDownOffscreenAutoDrawable() { + if(drawable != null) { + drawable.getContext().release(); + drawable.destroy(); + drawable = null; + } + } + + private static void testTextureMipMapGeneration(int width, int height, int pixelFormat, int pixelType) { + int internalFormat = pixelFormat; + int border = 0; + boolean mipmap = true; + boolean dataIsCompressed = false; + boolean mustFlipVertically = false; + + int memReq = Mipmap.image_size( width, height, pixelFormat, pixelType ); + ByteBuffer buffer = Buffers.newDirectByteBuffer( memReq ); + + TextureData data = new TextureData(drawable.getGLProfile(), + internalFormat, + width, + height, + border, + pixelFormat, + pixelType, + mipmap, + dataIsCompressed, + mustFlipVertically, + buffer, + null); + + Texture texture = TextureIO.newTexture(drawable.getGL(), data); + // Cleanup + texture.destroy(drawable.getGL()); + data.destroy(); + buffer.clear(); + buffer = null; + } + + @Test + public void test00_MipMap_ScaleInternal_RGB_UBYTE () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGB; + int pixelType = GL2.GL_UNSIGNED_BYTE; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test01_MipMap_ScaleInternal_RGBA_UBYTE () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGBA; + int pixelType = GL2.GL_UNSIGNED_BYTE; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test02_MipMap_ScaleInternal_RGB_BYTE () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGB; + int pixelType = GL2.GL_BYTE; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test03_MipMap_ScaleInternal_RGBA_BYTE () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGBA; + int pixelType = GL2.GL_BYTE; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test04_MipMap_ScaleInternal_RGB_USHORT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGB; + int pixelType = GL2.GL_UNSIGNED_SHORT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test05_MipMap_ScaleInternal_RGBA_USHORT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGBA; + int pixelType = GL2.GL_UNSIGNED_SHORT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test06_MipMap_ScaleInternal_RGB_SHORT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGB; + int pixelType = GL2.GL_SHORT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test07_MipMap_ScaleInternal_RGBA_SHORT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGBA; + int pixelType = GL2.GL_SHORT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test08_MipMap_ScaleInternal_RGB_UINT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGB; + int pixelType = GL2.GL_UNSIGNED_INT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test09_MipMap_ScaleInternal_RGBA_UINT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGBA; + int pixelType = GL2.GL_UNSIGNED_INT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test10_MipMap_ScaleInternal_RGB_INT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGB; + int pixelType = GL2.GL_INT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test11_MipMap_ScaleInternal_RGBA_INT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGBA; + int pixelType = GL2.GL_INT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test12_MipMap_ScaleInternal_RGB_FLOAT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGB; + int pixelType = GL2.GL_FLOAT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + @Test + public void test13_MipMap_ScaleInternal_RGBA_FLOAT () { + int width = 1; + int height = 7; + int pixelFormat = GL2.GL_RGBA; + int pixelType = GL2.GL_FLOAT; + + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); + } + + public static void main(String[] args) { + org.junit.runner.JUnitCore.main(TestBug365TextureGenerateMipMaps.class.getName()); + } +} \ No newline at end of file -- cgit v1.2.3 From bc72e232a4b74c2be8c91c540a7b6153bfefb8c0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 15 Oct 2013 15:36:03 +0200 Subject: Bug 861 - NEWT: Unify MouseEvent Processing incl. gesture processing We processed MouseEvents within NEWT as follows: sendMouseEvent/enqueueMouseEvent -> doMouseEvent, - called by native code to be delivered via consumeMouseEvent (now or later) - events are validated (move/drag, boundaries) - missing events are synthesized (click, enter, ..) as well as in several factories, i.e.: - AWTNewtEventFactory (1:1) - AndroidNewtEventFactory - synthesized events .. (click, ..) - android typed gesture detection (drag -> 1 finger scroll..) The latter enqueues events do Window/Display directly to be consumed by WindowImpl. Then users may have their own gesture detection etc. +++ This change unifies mouse/pointer event processing within NEWT within consumeEvent(..) which represents a common entry point. Gesture processing is now realized w/ a public API - GestureHandler - GestureHandler.GestureListener - GestureHandler.GesureEvent which supplies: - default impl. of optional gesture handlers (scroll, .. - default: enabled) - public API to add/remove gesture-handler and -listener +++ This allows our impl. to scale better in support of more multiple pointer devices (-> Win7/Win8, X11, ..). --- make/scripts/tests.sh | 6 +- src/newt/classes/com/jogamp/newt/Window.java | 62 ++- .../jogamp/newt/event/DoubleTapScrollGesture.java | 346 +++++++++++++ .../com/jogamp/newt/event/GestureHandler.java | 143 ++++++ .../classes/com/jogamp/newt/event/InputEvent.java | 8 + .../classes/com/jogamp/newt/event/MouseEvent.java | 238 +++++++-- .../classes/com/jogamp/newt/event/NEWTEvent.java | 1 + .../com/jogamp/newt/event/PinchToZoomGesture.java | 217 ++++++++ .../classes/com/jogamp/newt/opengl/GLWindow.java | 34 ++ src/newt/classes/jogamp/newt/WindowImpl.java | 555 +++++++++++++++++---- .../android/event/AndroidNewtEventFactory.java | 301 ++--------- .../android/event/AndroidNewtEventTranslator.java | 15 +- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 124 ++--- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 6 +- 14 files changed, 1531 insertions(+), 525 deletions(-) create mode 100644 src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java create mode 100644 src/newt/classes/com/jogamp/newt/event/GestureHandler.java create mode 100644 src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index fa44190c0..84f487c38 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -187,7 +187,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window.MouseEvent" + D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -299,7 +299,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -479,7 +479,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug694ScaleImageUnpackBufferSizeAWT $* -testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug365TextureGenerateMipMaps $* +#testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug365TextureGenerateMipMaps $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 8a43ef153..02727353f 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -30,12 +30,14 @@ package com.jogamp.newt; import java.util.List; +import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.MouseListener; + import jogamp.newt.Debug; import jogamp.newt.WindowImpl; @@ -553,15 +555,12 @@ public interface Window extends NativeWindow, WindowClosingProtocol { // /** - * - * Appends the given {@link com.jogamp.newt.event.MouseListener} to the end of - * the list. + * Appends the given {@link MouseListener} to the end of the list. */ void addMouseListener(MouseListener l); /** - * - * Inserts the given {@link com.jogamp.newt.event.MouseListener} at the + * Inserts the given {@link MouseListener} at the * specified position in the list.
        * * @param index Position where the listener will be inserted. @@ -572,10 +571,61 @@ public interface Window extends NativeWindow, WindowClosingProtocol { */ void addMouseListener(int index, MouseListener l); + /** + * Removes the given {@link MouseListener} from the list. + */ void removeMouseListener(MouseListener l); + /** + * Returns the {@link MouseListener} from the list at the given index. + */ MouseListener getMouseListener(int index); + /** + * Returns all {@link MouseListener} + */ MouseListener[] getMouseListeners(); - + + /** Enable or disable default {@link GestureHandler}. Default is enabled. */ + void setDefaultGesturesEnabled(boolean enable); + /** Return true if default {@link GestureHandler} are enabled. */ + boolean areDefaultGesturesEnabled(); + /** + * Appends the given {@link GestureHandler} to the end of the list. + */ + void addGestureHandler(GestureHandler gh); + /** + * Inserts the given {@link GestureHandler} at the + * specified position in the list.
        + * + * @param index Position where the listener will be inserted. + * Should be within (0 <= index && index <= size()). + * An index value of -1 is interpreted as the end of the list, size(). + * @param l The listener object to be inserted + * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1 + */ + void addGestureHandler(int index, GestureHandler gh); + /** + * Removes the given {@link GestureHandler} from the list. + */ + void removeGestureHandler(GestureHandler gh); + /** + * Appends the given {@link GestureHandler.GestureListener} to the end of the list. + */ + void addGestureListener(GestureHandler.GestureListener gl); + /** + * Inserts the given {@link GestureHandler.GestureListener} at the + * specified position in the list.
        + * + * @param index Position where the listener will be inserted. + * Should be within (0 <= index && index <= size()). + * An index value of -1 is interpreted as the end of the list, size(). + * @param l The listener object to be inserted + * @throws IndexOutOfBoundsException If the index is not within (0 <= index && index <= size()), or -1 + */ + void addGestureListener(int index, GestureHandler.GestureListener gl); + /** + * Removes the given {@link GestureHandler.GestureListener} from the list. + */ + void removeGestureListener(GestureHandler.GestureListener gl); } diff --git a/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java new file mode 100644 index 000000000..bc67cbee6 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/DoubleTapScrollGesture.java @@ -0,0 +1,346 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.event; + +import jogamp.newt.Debug; + +/** + * 2 pointer scroll/rotate gesture handler processing {@link MouseEvent}s + * while producing {@link MouseEvent#EVENT_MOUSE_WHEEL_MOVED} events if gesture is completed. + *

        + * Criteria related to parameters: + *

        + *    - doubleTapSlop (scaled in pixels):
        + *       - Max 2 finger distance to start 'scroll' mode
        + *       - Max. distance diff of current 2-pointer middle and initiated 2-pointer middle.
        + *
        + *    - touchSlop (scaled in pixels):
        + *       - Min. movement w/ 2 pointer within ScaledDoubleTapSlop starting 'scroll' mode
        + *       
        + *    - Avoid computation if not within gesture, especially for MOVE/DRAG
        + *    
        + *    - Only allow gesture to start with PRESS
        + *    
        + *    - Leave gesture completely with RELEASE of both/all fingers, or dist-diff exceeds doubleTapSlop 
        + *    
        + *    - Tolerate temporary lift 1 of 2 pointer
        + *    
        + *     - Always validate pointer-id
        + * 
        + *

        + * Implementation uses a n-state to get detect gesture: + *

        + * + * + * + * + * + * + * + *
        from to action
        NONE 1PRESS 1-pointer-pressed
        1PRESS 2PRESS_T 2-pointer-pressed within doubleTapSlope
        2PRESS_T SCROLL 2-pointer dragged, dist-diff within doubleTapSlop and scrollLen >= scrollSlop
        2PRESS_C SCROLL 2-pointer dragged, dist-diff within doubleTapSlop
        SCROLL SCROLL 2-pointer dragged, dist-diff within doubleTapSlop
        + * State ST_2PRESS_C merely exist to pick up gesture after one pointer has been lost temporarily. + *

        + *

        + * {@link #isWithinGesture()} returns gestureState >= 2PRESS_C + *

        + */ +public class DoubleTapScrollGesture implements GestureHandler { + /** Scroll threshold in pixels (fallback), defaults to 16 pixels. Can be overriden by integer property newt.event.scroll_slop_pixel.*/ + public static final int SCROLL_SLOP_PIXEL; + /** Two pointer 'double tap' slop in pixels (fallback), defaults to 104 pixels. Can be overriden by integer property newt.event.double_tap_slop_pixel.*/ + public static final int DOUBLE_TAP_SLOP_PIXEL; + + /** Scroll threshold in millimeter, defaults to 3 mm. Can be overriden by integer property newt.event.scroll_slop_mm.*/ + public static final float SCROLL_SLOP_MM; + /** Two pointer 'double tap' slop in millimeter, defaults to 20 mm. Can be overriden by integer property newt.event.double_tap_slop_mm.*/ + public static final float DOUBLE_TAP_SLOP_MM; + + static { + Debug.initSingleton(); + + SCROLL_SLOP_PIXEL = Debug.getIntProperty("newt.event.scroll_slop_pixel", true, 16); + DOUBLE_TAP_SLOP_PIXEL = Debug.getIntProperty("newt.event.double_tap_slop_pixel", true, 104); + SCROLL_SLOP_MM = Debug.getIntProperty("newt.event.scroll_slop_mm", true, 3); + DOUBLE_TAP_SLOP_MM = Debug.getIntProperty("newt.event.double_tap_slop_mm", true, 20); + } + + private static final int ST_NONE = 0; + private static final int ST_1PRESS = 1; + private static final int ST_2PRESS_T = 2; + private static final int ST_2PRESS_C = 3; + private static final int ST_SCROLL = 4; + + private final int scrollSlop, scrollSlopSquare, doubleTapSlop, doubleTapSlopSquare; + private final float[] scrollDistance = new float[] { 0f, 0f }; + private int[] pIds = new int[] { -1, -1 }; + /** See class docu */ + private int gestureState; + private int sqStartDist; + private int lastX, lastY; + private int pointerDownCount; + private MouseEvent hitGestureEvent; + + private static final int getSquareDistance(float x1, float y1, float x2, float y2) { + final int deltaX = (int) x1 - (int) x2; + final int deltaY = (int) y1 - (int) y2; + return deltaX * deltaX + deltaY * deltaY; + } + + private int gesturePointers(final MouseEvent e, final int excludeIndex) { + int j = 0; + for(int i=e.getPointerCount()-1; i>=0; i--) { + if( excludeIndex != i ) { + final int id = e.getPointerId(i); + if( pIds[0] == id || pIds[1] == id ) { + j++; + } + } + } + return j; + } + + /** + * scaledScrollSlop < scaledDoubleTapSlop + * @param scaledScrollSlop Distance a pointer can wander before we think the user is scrolling in pixels. + * @param scaledDoubleTapSlop Distance in pixels between the first touch and second touch to still be considered a double tap. + */ + public DoubleTapScrollGesture(int scaledScrollSlop, int scaledDoubleTapSlop) { + scrollSlop = scaledScrollSlop; + scrollSlopSquare = scaledScrollSlop * scaledScrollSlop; + doubleTapSlop = scaledDoubleTapSlop; + doubleTapSlopSquare = scaledDoubleTapSlop * scaledDoubleTapSlop; + pointerDownCount = 0; + clear(true); + if(DEBUG) { + System.err.println("DoubleTapScroll scrollSlop (scaled) "+scrollSlop); + System.err.println("DoubleTapScroll doubleTapSlop (scaled) "+doubleTapSlop); + } + } + + public String toString() { + return "DoubleTapScroll[state "+gestureState+", in "+isWithinGesture()+", has "+(null!=hitGestureEvent)+", pc "+pointerDownCount+"]"; + } + + @Override + public void clear(boolean clearStarted) { + scrollDistance[0] = 0f; + scrollDistance[1] = 0f; + hitGestureEvent = null; + if( clearStarted ) { + gestureState = ST_NONE; + sqStartDist = 0; + pIds[0] = -1; + pIds[1] = -1; + lastX = 0; + lastY = 0; + } + } + + @Override + public boolean isWithinGesture() { + return ST_2PRESS_C <= gestureState; + } + + @Override + public boolean hasGesture() { + return null != hitGestureEvent; + } + + @Override + public InputEvent getGestureEvent() { + if( null != hitGestureEvent ) { + final MouseEvent ge = hitGestureEvent; + int modifiers = ge.getModifiers(); + final float[] rotationXYZ = ge.getRotation(); + rotationXYZ[0] = scrollDistance[0] / scrollSlop; + rotationXYZ[1] = scrollDistance[1] / scrollSlop; + if( rotationXYZ[0]*rotationXYZ[0] > rotationXYZ[1]*rotationXYZ[1] ) { + // Horizontal scroll -> SHIFT + modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + } + return new MouseEvent(MouseEvent.EVENT_MOUSE_WHEEL_MOVED, ge.getSource(), ge.getWhen(), modifiers, + ge.getAllPointerTypes(), ge.getAllPointerIDs(), + ge.getAllX(), ge.getAllY(), ge.getAllPressures(), ge.getMaxPressure(), + ge.getButton(), ge.getClickCount(), rotationXYZ, scrollSlop); + } + return null; + } + + public final float[] getScrollDistanceXY() { + return scrollDistance; + } + + @Override + public boolean process(final InputEvent in) { + if( null != hitGestureEvent || !(in instanceof MouseEvent) ) { + return true; + } + final MouseEvent pe = (MouseEvent)in; + if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen ) { + return false; + } + pointerDownCount = pe.getPointerCount(); + final int eventType = pe.getEventType(); + final int x0 = pe.getX(0); + final int y0 = pe.getY(0); + switch ( eventType ) { + case MouseEvent.EVENT_MOUSE_PRESSED: { + int gPtr = 0; + if( ST_NONE == gestureState && 1 == pointerDownCount ) { + pIds[0] = pe.getPointerId(0); + pIds[1] = -1; + gestureState = ST_1PRESS; + } else if( ST_NONE < gestureState && 2 == pointerDownCount && 1 == gesturePointers(pe, 0) /* w/o pressed pointer */ ) { + final int x1 = pe.getX(1); + final int y1 = pe.getY(1); + final int xm = (x0+x1)/2; + final int ym = (y0+y1)/2; + + if( ST_1PRESS == gestureState ) { + final int sqDist = getSquareDistance(x0, y0, x1, y1); + final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; + if( isDistWithinDoubleTapSlop ) { + // very first 2-finger touch-down + gPtr = 2; + pIds[0] = pe.getPointerId(0); + pIds[1] = pe.getPointerId(1); + lastX = xm; + lastY = ym; + sqStartDist = sqDist; + gestureState = ST_2PRESS_T; + } + if(DEBUG) { + final int dist = (int)Math.round(Math.sqrt(sqDist)); + System.err.println(this+".pressed.1: dist "+dist+", gPtr "+gPtr+", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", last "+lastX+"/"+lastY+", "+pe); + } + } else if( ST_2PRESS_C == gestureState ) { // pick up gesture after temp loosing one pointer + gPtr = gesturePointers(pe, -1); + if( 2 == gPtr ) { + // same pointers re-touch-down + lastX = xm; + lastY = ym; + } else { + // other 2 pointers .. should rarely happen! + clear(true); + } + } + } + if(DEBUG) { + System.err.println(this+".pressed: gPtr "+gPtr+", this "+lastX+"/"+lastY+", "+pe); + } + } break; + + case MouseEvent.EVENT_MOUSE_RELEASED: { + pointerDownCount--; // lifted + final int gPtr = gesturePointers(pe, 0); // w/o lifted pointer + if ( 1 == gPtr ) { + // tolerate lifting 1 of 2 gesture pointers temporary + gestureState = ST_2PRESS_C; + } else if( 0 == gPtr ) { + // all lifted + clear(true); + } + if(DEBUG) { + System.err.println(this+".released: gPtr "+gPtr+", "+pe); + } + } break; + + case MouseEvent.EVENT_MOUSE_DRAGGED: { + if( 2 == pointerDownCount && ST_1PRESS < gestureState ) { + final int gPtr = gesturePointers(pe, -1); + if( 2 == gPtr ) { + // same pointers + final int x1 = pe.getX(1); + final int y1 = pe.getY(1); + final int xm = (x0+x1)/2; + final int ym = (y0+y1)/2; + final int sqDist = getSquareDistance(x0, y0, x1, y1); + final boolean isDistDiffWithinDoubleTapSlop = Math.abs(sqDist - sqStartDist) <= doubleTapSlopSquare; + if( isDistDiffWithinDoubleTapSlop ) { + switch( gestureState ) { + case ST_2PRESS_T: { + final int sqScrollLen = getSquareDistance(lastX, lastY, xm, ym); + if( sqScrollLen > scrollSlopSquare ) { // min. scrolling threshold reached + gestureState = ST_SCROLL; + } + } break; + + case ST_2PRESS_C: + gestureState = ST_SCROLL; + break; + + case ST_SCROLL: + scrollDistance[0] = lastX - xm; + scrollDistance[1] = lastY - ym; + hitGestureEvent = pe; + break; + } + if(DEBUG) { + final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; + final int dist = (int)Math.round(Math.sqrt(sqDist)); + final int sqScrollLen = getSquareDistance(lastX, lastY, xm, ym); + final int scrollLen = (int)Math.round(Math.sqrt(sqScrollLen)); + System.err.println(this+".dragged.1: pDist "+dist+", scrollLen "+scrollLen+", gPtr "+gPtr+" ["+pIds[0]+", "+pIds[1]+"]"+ + ", diffDistWithinTapSlop "+isDistDiffWithinDoubleTapSlop+ + ", distWithin2DTSlop "+isDistWithinDoubleTapSlop+ + ", this "+xm+"/"+ym+", last "+lastX+"/"+lastY+", d "+scrollDistance[0]+"/"+scrollDistance[1]); + } + } else { + // distance too big .. + if(DEBUG) { + final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; + final int dist = (int)Math.round(Math.sqrt(sqDist)); + final int startDist = (int)Math.round(Math.sqrt(sqStartDist)); + System.err.println(this+".dragged.X1: pDist "+dist+", distStart "+startDist+", gPtr "+gPtr+" ["+pIds[0]+", "+pIds[1]+"]"+ + ", diffDistWithinTapSlop "+isDistDiffWithinDoubleTapSlop+ + ", distWithin2DTSlop "+isDistWithinDoubleTapSlop+ + ", this "+xm+"/"+ym+", last "+lastX+"/"+lastY+", d "+scrollDistance[0]+"/"+scrollDistance[1]); + } + clear(true); + } + if( ST_2PRESS_T < gestureState ) { + // state ST_2PRESS_T waits for min scroll threshold ! + lastX = xm; + lastY = ym; + } + } else { + // other 2 pointers .. should rarely happen! + if(DEBUG) { + System.err.println(this+".dragged.X2: gPtr "+gPtr+" ["+pIds[0]+", "+pIds[1]+"]"+ + ", last "+lastX+"/"+lastY+", d "+scrollDistance[0]+"/"+scrollDistance[1]); + } + clear(true); + } + } + } break; + + default: + } + return null != hitGestureEvent; + } +} diff --git a/src/newt/classes/com/jogamp/newt/event/GestureHandler.java b/src/newt/classes/com/jogamp/newt/event/GestureHandler.java new file mode 100644 index 000000000..2c8f29bb7 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/GestureHandler.java @@ -0,0 +1,143 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.event; + +import jogamp.newt.Debug; + +/** + * Generic gesture handler interface designed to allow pass-through + * filtering of {@link InputEvent}s. + *

        + * To avoid negative impact on event processing, + * implementation shall restrict computation as much as possible + * and only within it's appropriate gesture states. + *

        + *

        + * To allow custom user events, other than the normal {@link InputEvent}s, + * a user may return a {@link GestureEvent} in it's implementation. + *

        + */ +public interface GestureHandler { + public static final boolean DEBUG = Debug.debug("Window.MouseEvent"); + + /** A custom gesture event */ + @SuppressWarnings("serial") + public static class GestureEvent extends InputEvent { + /** A gesture has been detected. */ + public static final short EVENT_GESTURE_DETECTED = 400; + + private final GestureHandler handler; + + /** + * Creates a gesture event with default type {@link #EVENT_GESTURE_DETECTED}. + * + * @param source + * @param when + * @param modifiers + * @param handler + */ + public GestureEvent(Object source, long when, int modifiers, GestureHandler handler) { + super(EVENT_GESTURE_DETECTED, source, when, modifiers); + this.handler = handler; + } + + /** + * Creates a gesture event with custom event_type ! + * @param event_type must lie within [400..599] + * @param source + * @param when + * @param modifiers + * @param handler + */ + public GestureEvent(short event_type, Object source, long when, int modifiers, GestureHandler handler) { + super(event_type, source, when, modifiers); + this.handler = handler; + } + + /** Return the {@link GestureHandler}, which produced the event. */ + public final GestureHandler getHandler() { return handler; } + } + + /** + * Listener for {@link GestureEvent}s. + * + * @see GestureEvent + */ + public static interface GestureListener extends NEWTEventListener + { + /** {@link GestureHandler} {@link GestureHandler#hasGesture() has detected} the gesture. */ + public void gestureDetected(GestureEvent gh); + } + + /** + * Clears state of handler, i.e. resets all states incl. previous detected gesture. + * @param clearStarted if true, also clears {@link #isWithinGesture() started} state, + * otherwise stay within gesture - if appropriate. + * Staying within a gesture allows fluent continuous gesture sequence, + * e.g. for scrolling. + */ + public void clear(boolean clearStarted); + + /** + * Returns true if a previous {@link #process(InputEvent)} command produced a gesture, + * which has not been {@link #clear(boolean) cleared}. + * Otherwise returns false. + */ + public boolean hasGesture(); + + /** + * Returns the corresponding {@link InputEvent} for the gesture as detected by + * a previous {@link #process(InputEvent)}, which has not been {@link #clear(boolean) cleared}. + * Otherwise returns null. + *

        + * Only implemented for gestures mapping to {@link InputEvent}s. + *

        + */ + public InputEvent getGestureEvent(); + + /** + * Returns true if within a gesture as detected by a previous {@link #process(InputEvent)} command, + * which has not been {@link #clear(boolean) cleared}. + * Otherwise returns false. + */ + public boolean isWithinGesture(); + + /** + * Process the given {@link InputEvent} and returns true if it produced the gesture. + * Otherwise returns false. + *

        + * If a gesture was already detected previously and has not been cleared, + * method does not process the event and returns true. + *

        + *

        + * Besides validation of the event's details, + * the handler may also validate the {@link InputEvent.InputClass} and/or {@link InputEvent.InputType}. + *

        + */ + public boolean process(InputEvent e); +} diff --git a/src/newt/classes/com/jogamp/newt/event/InputEvent.java b/src/newt/classes/com/jogamp/newt/event/InputEvent.java index b04ebc1af..7712b77e7 100644 --- a/src/newt/classes/com/jogamp/newt/event/InputEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/InputEvent.java @@ -39,6 +39,14 @@ import com.jogamp.newt.Window; @SuppressWarnings("serial") public abstract class InputEvent extends NEWTEvent { + /** Interface marking class of input types */ + public static interface InputClass { + } + + /** Interface marking type of input devices */ + public static interface InputType { + } + public static final int SHIFT_MASK = 1 << 0; public static final int CTRL_MASK = 1 << 1; public static final int META_MASK = 1 << 2; diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 8533a37c6..2c137ab77 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -40,8 +40,8 @@ package com.jogamp.newt.event; * http://www.w3.org/Submission/pointer-events/#pointerevent-interface *

        *

        - * In case an instance represents multi-touch events, i.e. {@link #getPointerCount()} is > 1, - * the first data element represents the pointer which triggered the action if individual to one pointer.
        + * In case an instance represents a multiple-pointer event, i.e. {@link #getPointerCount()} is > 1, + * the first data element of the multiple-pointer fields represents the pointer which triggered the action.
        * For example {@link #getX(int) e.getX(0)} at {@link #EVENT_MOUSE_PRESSED} returns the data of the pressed pointer, etc. *

        */ @@ -49,12 +49,12 @@ package com.jogamp.newt.event; public class MouseEvent extends InputEvent { /** Class of pointer types */ - public static enum PointerClass{ + public static enum PointerClass implements InputEvent.InputClass { Offscreen, Onscreen, Undefined; } /** Type of pointer devices */ - public static enum PointerType{ + public static enum PointerType implements InputEvent.InputType { /** {@link PointerClass#Offscreen} mouse. */ Mouse(PointerClass.Offscreen), /** {@link PointerClass#Offscreen} touch pad, usually using fingers. */ @@ -110,7 +110,7 @@ public class MouseEvent extends InputEvent return 300; } - /** Constructor for tradition 1-pointer mouse events. */ + /** Constructor for traditional one-pointer event. */ public MouseEvent(short eventType, Object source, long when, int modifiers, int x, int y, short clickCount, short button, float[] rotationXYZ, float rotationScale) @@ -120,25 +120,48 @@ public class MouseEvent extends InputEvent this.y = new int[]{y}; this.pressure = constMousePressure; this.maxPressure= 1.0f; - this.pointerIDs = constMousePointerIDs; + this.pointerID = constMousePointerIDs; this.clickCount=clickCount; this.button=button; this.rotationXYZ = rotationXYZ; this.rotationScale = rotationScale; - this.pointerTypes = constMousePointerTypes; + this.pointerType = constMousePointerTypes; } - /** Constructor for multi-touch pointer events. */ - public MouseEvent(short eventType, Object source, long when, - int modifiers, int[] x, int[] y, float[] pressure, float maxPressure, PointerType pointerTypes[], short[] pointerids, short clickCount, - short button, float[] rotationXYZ, float rotationScale) + /** + * Constructor for a multiple-pointer event. + *

        + * First element of multiple-pointer arrays represents the pointer which triggered the event! + *

        + * + * @param eventType + * @param source + * @param when + * @param modifiers + * @param pointerType PointerType for each pointer (multiple pointer) + * @param pointerID Pointer ID for each pointer (multiple pointer) + * @param x X-axis for each pointer (multiple pointer) + * @param y Y-axis for each pointer (multiple pointer) + * @param pressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + * @param button Corresponding mouse-button + * @param clickCount Mouse-button click-count + * @param rotationXYZ Rotation of all axis + * @param rotationScale Rotation scale + */ + public MouseEvent(short eventType, Object source, long when, int modifiers, + PointerType pointerType[], short[] pointerID, + int[] x, int[] y, float[] pressure, float maxPressure, + short button, short clickCount, float[] rotationXYZ, float rotationScale) { super(eventType, source, when, modifiers); this.x = x; this.y = y; - if(pointerids.length != pressure.length || - pointerids.length != x.length || - pointerids.length != y.length) { + final int pointerCount = pointerType.length; + if(pointerCount != pointerID.length || + pointerCount != x.length || + pointerCount != y.length || + pointerCount != pressure.length) { throw new IllegalArgumentException("All multiple pointer arrays must be of same size"); } if( 0.0f >= maxPressure ) { @@ -146,55 +169,148 @@ public class MouseEvent extends InputEvent } this.pressure = pressure; this.maxPressure= maxPressure; - this.pointerIDs = pointerids; + this.pointerID = pointerID; this.clickCount=clickCount; this.button=button; this.rotationXYZ = rotationXYZ; this.rotationScale = rotationScale; - this.pointerTypes = pointerTypes; + this.pointerType = pointerType; + } + + public MouseEvent createVariant(short newEventType) { + return new MouseEvent(newEventType, source, getWhen(), getModifiers(), pointerType, pointerID, + x, y, pressure, maxPressure, button, clickCount, rotationXYZ, rotationScale); + } + + /** + * Factory for a multiple-pointer event. + *

        + * The index for the element of multiple-pointer arrays represents the pointer which triggered the event + * is passed via actionIdx. + *

        + * + * @param eventType + * @param source + * @param when + * @param modifiers + * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event + * @param pointerType PointerType for each pointer (multiple pointer) + * @param pointerID Pointer ID for each pointer (multiple pointer) + * @param x X-axis for each pointer (multiple pointer) + * @param y Y-axis for each pointer (multiple pointer) + * @param pressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + * @param button Corresponding mouse-button + * @param clickCount Mouse-button click-count + * @param rotationXYZ Rotation of all axis + * @param rotationScale Rotation scale + */ + public static MouseEvent create(short eventType, Object source, long when, int modifiers, + int actionIdx, PointerType pointerType[], short[] pointerID, + int[] x, int[] y, float[] pressure, float maxPressure, + short button, short clickCount, float[] rotationXYZ, float rotationScale) { + if( 0 <= actionIdx && actionIdx < pointerType.length) { + if( 0 < actionIdx ) { + { + final PointerType aType = pointerType[actionIdx]; + pointerType[actionIdx] = pointerType[0]; + pointerType[0] = aType; + } + { + final short s = pointerID[actionIdx]; + pointerID[actionIdx] = pointerID[0]; + pointerID[0] = s; + } + { + int s = x[actionIdx]; + x[actionIdx] = x[0]; + x[0] = s; + s = y[actionIdx]; + y[actionIdx] = y[0]; + y[0] = s; + } + { + final float aPress = pressure[actionIdx]; + pressure[actionIdx] = pressure[0]; + pressure[0] = aPress; + } + } + return new MouseEvent(eventType, source, when, modifiers, + pointerType, pointerID, x, y, pressure, maxPressure, + button, clickCount, rotationXYZ, rotationScale); + } + throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pointerType.length-1)+"]"); } /** * @return the count of pointers involved in this event */ - public int getPointerCount() { - return x.length; + public final int getPointerCount() { + return pointerType.length; } /** * @return the {@link PointerType} for the data at index. * return null if index not available. */ - public PointerType getPointerType(int index) { - if(index >= pointerIDs.length) { + public final PointerType getPointerType(int index) { + if(0 > index || index >= pointerType.length) { return null; } - return pointerTypes[index]; + return pointerType[index]; + } + + /** + * @return array of all {@link PointerType}s for all pointers + */ + public final PointerType[] getAllPointerTypes() { + return pointerType; } /** - * @return the pointer id for the data at index. + * @return the pointer id for the given index. * return -1 if index not available. */ - public short getPointerId(int index) { - if(index >= pointerIDs.length) { + public final short getPointerId(int index) { + if(0 > index || index >= pointerID.length) { return -1; } - return pointerIDs[index]; + return pointerID[index]; } - public short getButton() { + /** + * @return the pointer index for the given pointer id. + * return -1 if id not available. + */ + public final int getPointerIdx(short id) { + for(int i=pointerID.length-1; i>=0; i--) { + if( pointerID[i] == id ) { + return i; + } + } + return -1; + } + + /** + * @return array of all pointer IDs for all pointers + */ + public final short[] getAllPointerIDs() { + return pointerID; + } + + public final short getButton() { return button; } - public short getClickCount() { + public final short getClickCount() { return clickCount; } - public int getX() { + + public final int getX() { return x[0]; } - public int getY() { + public final int getY() { return y[0]; } @@ -203,7 +319,7 @@ public class MouseEvent extends InputEvent * @return X-Coord associated with the pointer-index. * @see getPointerId(index) */ - public int getX(int index) { + public final int getX(int index) { return x[index]; } @@ -212,20 +328,41 @@ public class MouseEvent extends InputEvent * @return Y-Coord associated with the pointer-index. * @see getPointerId(index) */ - public int getY(int index) { + public final int getY(int index) { return y[index]; } + /** + * @return array of all X-Coords for all pointers + */ + public final int[] getAllX() { + return x; + } + + /** + * @return array of all Y-Coords for all pointers + */ + public final int[] getAllY() { + return y; + } + /** * @param normalized if true, method returns the normalized pressure, i.e. pressure / maxPressure * @return The pressure associated with the pointer-index 0. * The value of zero is return if not available. * @see #getMaxPressure() */ - public float getPressure(boolean normalized){ + public final float getPressure(boolean normalized){ return normalized ? pressure[0] / maxPressure : pressure[0]; } + /** + * @return array of all raw, un-normalized pressures for all pointers + */ + public final float[] getAllPressures() { + return pressure; + } + /** * Returns the maximum pressure known for the input device generating this event. *

        @@ -239,7 +376,7 @@ public class MouseEvent extends InputEvent *

      *

      */ - public float getMaxPressure() { + public final float getMaxPressure() { return maxPressure; } @@ -250,7 +387,7 @@ public class MouseEvent extends InputEvent * The value of zero is return if not available. * @see #getMaxPressure() */ - public float getPressure(int index, boolean normalized){ + public final float getPressure(int index, boolean normalized){ return normalized ? pressure[index] / maxPressure : pressure[index]; } @@ -294,7 +431,7 @@ public class MouseEvent extends InputEvent * see {@link #getRotationScale()} for semantics. *

      */ - public float[] getRotation() { + public final float[] getRotation() { return rotationXYZ; } @@ -311,15 +448,15 @@ public class MouseEvent extends InputEvent * Hence scale * rotation reproduces the screen distance in pixels the finger[s] have moved. *

      */ - public float getRotationScale() { + public final float getRotationScale() { return rotationScale; } - public String toString() { + public final String toString() { return toString(null).toString(); } - public StringBuilder toString(StringBuilder sb) { + public final StringBuilder toString(StringBuilder sb) { if(null == sb) { sb = new StringBuilder(); } @@ -327,13 +464,13 @@ public class MouseEvent extends InputEvent .append(", ").append(x).append("/").append(y) .append(", button ").append(button).append(", count ") .append(clickCount).append(", rotation [").append(rotationXYZ[0]).append(", ").append(rotationXYZ[1]).append(", ").append(rotationXYZ[2]).append("] * ").append(rotationScale); - if(pointerIDs.length>0) { - sb.append(", pointer<").append(pointerIDs.length).append(">["); - for(int i=0; i0) { + sb.append(", pointer<").append(pointerID.length).append(">["); + for(int i=0; i0) { sb.append(", "); } - sb.append(pointerIDs[i]).append("/").append(pointerTypes[i]).append(": ") + sb.append(pointerID[i]).append("/").append(pointerType[i]).append(": ") .append(x[i]).append("/").append(y[i]).append(", ") .append("p[").append(pressure[i]).append("/").append(maxPressure).append("=").append(pressure[i]/maxPressure).append("]"); } @@ -356,15 +493,24 @@ public class MouseEvent extends InputEvent default: return "unknown (" + type + ")"; } } - private final int x[], y[]; + + /** PointerType for each pointer (multiple pointer) */ + private final PointerType pointerType[]; + /** Pointer-ID for each pointer (multiple pointer) */ + private final short pointerID[]; + /** X-axis for each pointer (multiple pointer) */ + private final int x[]; + /** Y-axis for each pointer (multiple pointer) */ + private final int y[]; + /** Pressure for each pointer (multiple pointer) */ + private final float pressure[]; // private final short tiltX[], tiltY[]; // TODO: A generic way for pointer axis information, see Android MotionEvent! private final short clickCount, button; + /** Rotation around the X, Y and X axis */ private final float[] rotationXYZ; + /** Rotation scale */ private final float rotationScale; - private final float pressure[]; private final float maxPressure; - private final short pointerIDs[]; - private final PointerType pointerTypes[]; private static final float[] constMousePressure = new float[]{0f}; private static final short[] constMousePointerIDs = new short[]{0}; diff --git a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java index c1bc791d8..02bb4f929 100644 --- a/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/NEWTEvent.java @@ -44,6 +44,7 @@ package com.jogamp.newt.event; *
    • WindowEvent 100..10x
    • *
    • MouseEvent 200..20x
    • *
    • KeyEvent 300..30x
    • + *
    • GestureEvent 400..5xx
    • *
    • MonitorEvent 600..60x
    • *
      */ diff --git a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java new file mode 100644 index 000000000..3a34c6253 --- /dev/null +++ b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java @@ -0,0 +1,217 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.newt.event; + +import javax.media.nativewindow.NativeSurface; + +import jogamp.newt.Debug; + +/** + * 2 pointer zoom, a.k.a. pinch to zoom, gesture handler processing {@link MouseEvent}s + * while producing {@link ZoomEvent}s if gesture is completed. + *

      + * Zoom value lies within [0..2], with 1 as 1:1. + *

      + *
      + *   - choosing the smallest surface edge (width/height -> x/y)
      + *   - tolerating other fingers to be pressed and hence user to add functionality (scale, ..)
      + * 
      + */ +public class PinchToZoomGesture implements GestureHandler { + public static final boolean DEBUG = Debug.debug("Window.MouseEvent"); + + /** A {@link GestureHandler.GestureEvent} denominating zoom. */ + @SuppressWarnings("serial") + public static class ZoomEvent extends GestureEvent { + private final MouseEvent pe; + private final float zoom; + public ZoomEvent(Object source, long when, int modifiers, GestureHandler handler, MouseEvent pe, float zoom) { + super(source, when, modifiers, handler); + this.pe = pe; + this.zoom = zoom; + } + /** Triggering {@link MouseEvent} */ + public final MouseEvent getTrigger() { return pe; } + /** Zoom value lies within [0..2], with 1 as 1:1. */ + public final float getZoom() { return zoom; } + } + + private final NativeSurface surface; + private float zoom; + private int zoomLastEdgeDist; + private boolean zoomFirstTouch; + private boolean zoomMode; + private ZoomEvent zoomEvent; + private short[] pIds = new short[] { -1, -1 }; + + public PinchToZoomGesture(NativeSurface surface) { + clear(true); + this.surface = surface; + this.zoom = 1f; + } + + public String toString() { + return "PinchZoom[1stTouch "+zoomFirstTouch+", in "+isWithinGesture()+", has "+(null!=zoomEvent)+", zoom "+zoom+"]"; + } + + private int gesturePointers(final MouseEvent e, final int excludeIndex) { + int j = 0; + for(int i=e.getPointerCount()-1; i>=0; i--) { + if( excludeIndex != i ) { + final int id = e.getPointerId(i); + if( pIds[0] == id || pIds[1] == id ) { + j++; + } + } + } + return j; + } + + @Override + public void clear(boolean clearStarted) { + zoomEvent = null; + if( clearStarted ) { + zoomLastEdgeDist = 0; + zoomFirstTouch = true; + zoomMode = false; + pIds[0] = -1; + pIds[1] = -1; + } + } + + @Override + public boolean isWithinGesture() { + return zoomMode; + } + + @Override + public boolean hasGesture() { + return null != zoomEvent; + } + + @Override + public InputEvent getGestureEvent() { + return zoomEvent; + } + + /** Zoom value lies within [0..2], with 1 as 1:1. */ + public final float getZoom() { + return zoom; + } + /** Set zoom value within [0..2], with 1 as 1:1. */ + public final void setZoom(float zoom) { + this.zoom=zoom; + } + + @Override + public boolean process(final InputEvent in) { + if( null != zoomEvent || !(in instanceof MouseEvent) ) { + return true; + } + final MouseEvent pe = (MouseEvent)in; + if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen ) { + return false; + } + + final int pointerDownCount = pe.getPointerCount(); + final int eventType = pe.getEventType(); + final boolean useY = surface.getWidth() >= surface.getHeight(); // use smallest dimension + switch ( eventType ) { + case MouseEvent.EVENT_MOUSE_PRESSED: { + if( 1 == pointerDownCount ) { + pIds[0] = pe.getPointerId(0); + pIds[1] = -1; + } else if ( 2 <= pointerDownCount ) { // && 1 == gesturePointers(pe, 0) /* w/o pressed pointer */) { + pIds[0] = pe.getPointerId(0); + pIds[1] = pe.getPointerId(1); + } + if(DEBUG) { + System.err.println("XXX1: id0 "+pIds[0]+" -> idx0 "+0+", id1 "+pIds[1]+" -> idx1 "+1); + System.err.println(this+".pressed: down "+pointerDownCount+", gPtr "+gesturePointers(pe, -1)+", event "+pe); + } + } break; + + case MouseEvent.EVENT_MOUSE_RELEASED: { + final int gPtr = gesturePointers(pe, 0); // w/o lifted pointer + if ( 1 == gPtr ) { + zoomFirstTouch = true; + zoomMode = false; + } else if( 0 == gPtr ) { + // all lifted + clear(true); + } + if(DEBUG) { + System.err.println(this+".released: down "+pointerDownCount+", gPtr "+gPtr+", event "+pe); + } + } break; + + case MouseEvent.EVENT_MOUSE_DRAGGED: { + if( 2 <= pointerDownCount ) { + final int gPtr = gesturePointers(pe, -1); + if( 2 == gPtr ) { + // same pointers + final int p0Idx = pe.getPointerIdx(pIds[0]); + final int p1Idx = pe.getPointerIdx(pIds[1]); + final int edge0 = useY ? pe.getY(p0Idx) : pe.getX(p0Idx); + final int edge1 = useY ? pe.getY(p1Idx) : pe.getX(p1Idx); + // Diff. 1:1 Zoom: finger-distance to screen-coord + if(zoomFirstTouch) { + zoomLastEdgeDist = Math.abs(edge0-edge1); + zoomFirstTouch=false; + zoomMode = true; + } else if( zoomMode ) { + final int d = Math.abs(edge0-edge1); + final int dd = d - zoomLastEdgeDist; + final float screenEdge = useY ? surface.getHeight() : surface.getWidth(); + final float incr = (float)dd / screenEdge; // [-1..1] + if(DEBUG) { + System.err.println("XXX2: id0 "+pIds[0]+" -> idx0 "+p0Idx+", id1 "+pIds[1]+" -> idx1 "+p1Idx); + System.err.println("XXX3: d "+d+", ld "+zoomLastEdgeDist+", dd "+dd+", screen "+screenEdge+" -> incr "+incr+", zoom "+zoom+" -> "+(zoom+incr)); + } + zoom += incr; + // clip value + if( 2f < zoom ) { + zoom = 2f; + } else if( 0 > zoom ) { + zoom = 0; + } + zoomLastEdgeDist = d; + zoomEvent = new ZoomEvent(pe.getSource(), pe.getWhen(), pe.getModifiers(), this, pe, zoom); + } + } + if(DEBUG) { + System.err.println(this+".dragged: down "+pointerDownCount+", gPtr "+gPtr+", event "+pe); + } + } + } break; + + default: + } + return null != zoomEvent; + } +} diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index eace0f2af..cae1a06a2 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -77,6 +77,7 @@ import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; +import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.NEWTEvent; @@ -774,6 +775,39 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return window.getMouseListeners(); } + @Override + public void setDefaultGesturesEnabled(boolean enable) { + window.setDefaultGesturesEnabled(enable); + } + @Override + public boolean areDefaultGesturesEnabled() { + return window.areDefaultGesturesEnabled(); + } + @Override + public final void addGestureHandler(GestureHandler gh) { + window.addGestureHandler(gh); + } + @Override + public final void addGestureHandler(int index, GestureHandler gh) { + window.addGestureHandler(index, gh); + } + @Override + public final void removeGestureHandler(GestureHandler gh) { + window.removeGestureHandler(gh); + } + @Override + public final void addGestureListener(GestureHandler.GestureListener gl) { + window.addGestureListener(-1, gl); + } + @Override + public final void addGestureListener(int index, GestureHandler.GestureListener gl) { + window.addGestureListener(index, gl); + } + @Override + public final void removeGestureListener(GestureHandler.GestureListener gl) { + window.removeGestureListener(gl); + } + //---------------------------------------------------------------------- // NativeWindow completion // diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index b7357863f..66ce46ed0 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -48,6 +48,8 @@ import com.jogamp.newt.Screen; import com.jogamp.newt.Window; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.newt.event.DoubleTapScrollGesture; +import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.KeyListener; @@ -60,6 +62,7 @@ import com.jogamp.newt.event.MonitorModeListener; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; import com.jogamp.newt.event.WindowUpdateEvent; +import com.jogamp.newt.event.MouseEvent.PointerType; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -71,6 +74,7 @@ import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; import javax.media.nativewindow.util.Point; @@ -176,13 +180,41 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList childWindows = new ArrayList(); private ArrayList mouseListeners = new ArrayList(); - private short mouseButtonPressed = (short)0; // current pressed mouse button number - private int mouseButtonModMask = 0; // current pressed mouse button modifier mask - private long lastMousePressed = 0; // last time when a mouse button was pressed - private short lastMouseClickCount = (short)0; // last mouse button click count - private boolean mouseInWindow = false;// mouse entered window - is inside the window (may be synthetic) - private Point lastMousePosition = new Point(); - + + private static class PointerState0 { + /** current pressed mouse button number */ + private short buttonPressed = (short)0; + /** current pressed mouse button modifier mask */ + private int buttonModMask = 0; + /** last time when a mouse button was pressed */ + private long lastButtonPressTime = 0; + /** last mouse button click count */ + private short lastButtonClickCount = (short)0; + /** mouse entered window - is inside the window (may be synthetic) */ + private boolean insideWindow = false; + /** last mouse-move position */ + private Point lastMovePosition = new Point(); + } + private static class PointerState1 { + /** current pressed mouse button number */ + private short buttonPressed = (short)0; + /** last time when a mouse button was pressed */ + private long lastButtonPressTime = 0; + /** mouse entered window - is inside the window (may be synthetic) */ + private boolean insideWindow = false; + /** last mouse-move position */ + private Point lastMovePosition = new Point(); + } + /** doMouseEvent */ + private PointerState0 pState0 = new PointerState0(); + /** consumeMouseEvent */ + private PointerState1 pState1 = new PointerState1(); + private boolean defaultGestureHandlerEnabled = true; + private DoubleTapScrollGesture gesture2PtrTouchScroll = null; + private ArrayList pointerGestureHandler = new ArrayList(); + + private ArrayList gestureListeners = new ArrayList(); + private ArrayList keyListeners = new ArrayList(); private ArrayList windowListeners = new ArrayList(); @@ -1754,6 +1786,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer for (int i = 0; i < mouseListeners.size(); i++ ) { sb.append(mouseListeners.get(i)+", "); } + sb.append("], PointerGestures default "+defaultGestureHandlerEnabled+", custom "+pointerGestureHandler.size()+" ["); + for (int i = 0; i < pointerGestureHandler.size(); i++ ) { + sb.append(pointerGestureHandler.get(i)+", "); + } sb.append("], KeyListeners num "+keyListeners.size()+" ["); for (int i = 0; i < keyListeners.size(); i++ ) { sb.append(keyListeners.get(i)+", "); @@ -2166,7 +2202,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private final MonitorModeListenerImpl monitorModeListenerImpl = new MonitorModeListenerImpl(); - //---------------------------------------------------------------------- // Child Window Management // @@ -2286,17 +2321,22 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // // MouseListener/Event Support // + + // + // Native MouseEvents pre-processed to be enqueued or consumed directly + // + public final void sendMouseEvent(short eventType, int modifiers, int x, int y, short button, float rotation) { - doMouseEvent(false, false, eventType, modifiers, x, y, button, rotation); + doMouseEvent(false, false, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers, int x, int y, short button, float rotation) { - doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotation); + doMouseEvent(true, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, int x, int y, short button, float rotation) { - this.doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); + doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } /** public final void sendMouseEvent(short eventType, int modifiers, @@ -2309,57 +2349,73 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } */ protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, int x, int y, short button, float[] rotationXYZ, float rotationScale) { - if( eventType == MouseEvent.EVENT_MOUSE_ENTERED || eventType == MouseEvent.EVENT_MOUSE_EXITED ) { - if( eventType == MouseEvent.EVENT_MOUSE_EXITED && x==-1 && y==-1 ) { - x = lastMousePosition.getX(); - y = lastMousePosition.getY(); - } - // clip coordinates to window dimension - x = Math.min(Math.max(x, 0), getWidth()-1); - y = Math.min(Math.max(y, 0), getHeight()-1); - mouseInWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - // clear states - lastMousePressed = 0; - lastMouseClickCount = (short)0; - mouseButtonPressed = 0; - mouseButtonModMask = 0; - } - if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { - return; // .. invalid .. - } - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+lastMousePosition); + if( 0 > button || button > MouseEvent.BUTTON_NUMBER ) { + throw new NativeWindowException("Invalid mouse button number" + button); } + + // + // Remove redundant events, determine ENTERED state and reset states if applicable + // final long when = System.currentTimeMillis(); - MouseEvent eEntered = null; - if(eventType == MouseEvent.EVENT_MOUSE_MOVED) { - if(!mouseInWindow) { - mouseInWindow = true; - eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, this, when, - modifiers, x, y, (short)0, (short)0, rotationXYZ, rotationScale); + switch( eventType ) { + case MouseEvent.EVENT_MOUSE_EXITED: + if( x==-1 && y==-1 ) { + x = pState0.lastMovePosition.getX(); + y = pState0.lastMovePosition.getY(); + } + // Fall through intended! + + case MouseEvent.EVENT_MOUSE_ENTERED: + // clip coordinates to window dimension + x = Math.min(Math.max(x, 0), getWidth()-1); + y = Math.min(Math.max(y, 0), getHeight()-1); + pState0.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; // clear states - lastMousePressed = 0; - lastMouseClickCount = (short)0; - mouseButtonPressed = 0; - mouseButtonModMask = 0; - } else if( lastMousePosition.getX() == x && lastMousePosition.getY()==y ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+lastMousePosition); + pState0.lastButtonPressTime = 0; + pState0.lastButtonClickCount = (short)0; + pState0.buttonPressed = 0; + pState0.buttonModMask = 0; + break; + + case MouseEvent.EVENT_MOUSE_MOVED: + case MouseEvent.EVENT_MOUSE_DRAGGED: + if( pState0.insideWindow && pState0.lastMovePosition.getX() == x && pState0.lastMovePosition.getY() == y ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+pState0.lastMovePosition); + } + return; // skip same position } - return; // skip same position + pState0.lastMovePosition.setX(x); + pState0.lastMovePosition.setY(y); + + // Fall through intended ! + + default: + if(!pState0.insideWindow) { + pState0.insideWindow = true; + + // clear states + pState0.lastButtonPressTime = 0; + pState0.lastButtonClickCount = (short)0; + pState0.buttonPressed = 0; + pState0.buttonModMask = 0; + } + } + + if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("doMouseEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+pState0.lastMovePosition); } - lastMousePosition.setX(x); - lastMousePosition.setY(y); + return; // .. invalid .. } - if( 0 > button || button > MouseEvent.BUTTON_NUMBER ) { - throw new NativeWindowException("Invalid mouse button number" + button); + if(DEBUG_MOUSE_EVENT) { + System.err.println("doMouseEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+pState0.lastMovePosition); } + modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) - modifiers |= mouseButtonModMask; // Always add currently pressed mouse buttons to modifier mask - - MouseEvent eClicked = null; - MouseEvent e = null; + modifiers |= pState0.buttonModMask; // Always add currently pressed mouse buttons to modifier mask if( isPointerConfined() ) { modifiers |= InputEvent.CONFINED_MASK; @@ -2368,64 +2424,86 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer modifiers |= InputEvent.INVISIBLE_MASK; } - if( MouseEvent.EVENT_MOUSE_PRESSED == eventType ) { - if( when - lastMousePressed < MouseEvent.getClickTimeout() ) { - lastMouseClickCount++; - } else { - lastMouseClickCount=(short)1; - } - lastMousePressed = when; - mouseButtonPressed = button; - mouseButtonModMask |= MouseEvent.getButtonMask(button); - e = new MouseEvent(eventType, this, when, - modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale); - } else if( MouseEvent.EVENT_MOUSE_RELEASED == eventType ) { - e = new MouseEvent(eventType, this, when, - modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale); - if( when - lastMousePressed < MouseEvent.getClickTimeout() ) { - eClicked = new MouseEvent(MouseEvent.EVENT_MOUSE_CLICKED, this, when, - modifiers, x, y, lastMouseClickCount, button, rotationXYZ, rotationScale); - } else { - lastMouseClickCount = (short)0; - lastMousePressed = 0; - } - mouseButtonPressed = 0; - mouseButtonModMask &= ~MouseEvent.getButtonMask(button); - } else if( MouseEvent.EVENT_MOUSE_MOVED == eventType ) { - if ( mouseButtonPressed > 0 ) { - e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, - modifiers, x, y, (short)1, mouseButtonPressed, rotationXYZ, rotationScale); - } else { + final MouseEvent e; + + switch( eventType ) { + case MouseEvent.EVENT_MOUSE_PRESSED: + if( when - pState0.lastButtonPressTime < MouseEvent.getClickTimeout() ) { + pState0.lastButtonClickCount++; + } else { + pState0.lastButtonClickCount=(short)1; + } + pState0.lastButtonPressTime = when; + pState0.buttonPressed = button; + pState0.buttonModMask |= MouseEvent.getButtonMask(button); e = new MouseEvent(eventType, this, when, - modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); - } - } else if( MouseEvent.EVENT_MOUSE_WHEEL_MOVED == eventType ) { - e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); - } else { - e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); - } - if( null != eEntered ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: synthesized MOUSE_ENTERED event: "+eEntered); - } - doEvent(enqueue, wait, eEntered); + modifiers, x, y, pState0.lastButtonClickCount, button, rotationXYZ, rotationScale); + break; + case MouseEvent.EVENT_MOUSE_RELEASED: + e = new MouseEvent(eventType, this, when, + modifiers, x, y, pState0.lastButtonClickCount, button, rotationXYZ, rotationScale); + if( when - pState0.lastButtonPressTime >= MouseEvent.getClickTimeout() ) { + pState0.lastButtonClickCount = (short)0; + pState0.lastButtonPressTime = 0; + } + pState0.buttonPressed = 0; + pState0.buttonModMask &= ~MouseEvent.getButtonMask(button); + break; + case MouseEvent.EVENT_MOUSE_MOVED: + if ( pState0.buttonPressed > 0 ) { + e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, + modifiers, x, y, (short)1, pState0.buttonPressed, rotationXYZ, rotationScale); + } else { + e = new MouseEvent(eventType, this, when, + modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); + } + break; + default: + e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); } doEvent(enqueue, wait, e); // actual mouse event - if( null != eClicked ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: synthesized MOUSE_CLICKED event: "+eClicked); - } - doEvent(enqueue, wait, eClicked); - } } + /** + * Send multiple-pointer event directly to be consumed + *

      + * The index for the element of multiple-pointer arrays represents the pointer which triggered the event + * is passed via actionIdx. + *

      + * + * @param eventType + * @param source + * @param when + * @param modifiers + * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event + * @param pointerType PointerType for each pointer (multiple pointer) + * @param pointerID Pointer ID for each pointer (multiple pointer) + * @param x X-axis for each pointer (multiple pointer) + * @param y Y-axis for each pointer (multiple pointer) + * @param pressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + * @param button Corresponding mouse-button + * @param clickCount Mouse-button click-count + * @param rotationXYZ Rotation of all axis + * @param rotationScale Rotation scale + */ + public void sendMouseEvent(short eventType, Object source, long when, int modifiers, + int actionIdx, PointerType pointerType[], short[] pointerID, + int[] x, int[] y, float[] pressure, float maxPressure, + short button, short clickCount, float[] rotationXYZ, float rotationScale) { + final MouseEvent pe = MouseEvent.create(eventType, source, when, modifiers, actionIdx, + pointerType, pointerID, x, y, pressure, maxPressure, button, clickCount, + rotationXYZ, rotationScale); + consumeMouseEvent(pe); + } + @Override - public void addMouseListener(MouseListener l) { + public final void addMouseListener(MouseListener l) { addMouseListener(-1, l); } @Override - public void addMouseListener(int index, MouseListener l) { + public final void addMouseListener(int index, MouseListener l) { if(l == null) { return; } @@ -2439,7 +2517,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public void removeMouseListener(MouseListener l) { + public final void removeMouseListener(MouseListener l) { if (l == null) { return; } @@ -2450,7 +2528,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public MouseListener getMouseListener(int index) { + public final MouseListener getMouseListener(int index) { @SuppressWarnings("unchecked") ArrayList clonedListeners = (ArrayList) mouseListeners.clone(); if(0>index) { @@ -2460,14 +2538,273 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public MouseListener[] getMouseListeners() { + public final MouseListener[] getMouseListeners() { return mouseListeners.toArray(new MouseListener[mouseListeners.size()]); } - protected void consumeMouseEvent(MouseEvent e) { + @Override + public final void setDefaultGesturesEnabled(boolean enable) { + defaultGestureHandlerEnabled = enable; + } + @Override + public final boolean areDefaultGesturesEnabled() { + return defaultGestureHandlerEnabled; + } + + @Override + public final void addGestureHandler(GestureHandler gh) { + addGestureHandler(-1, gh); + } + @Override + public final void addGestureHandler(int index, GestureHandler gh) { + if(gh == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) pointerGestureHandler.clone(); + if(0>index) { + index = cloned.size(); + } + cloned.add(index, gh); + pointerGestureHandler = cloned; + } + @Override + public final void removeGestureHandler(GestureHandler gh) { + if (gh == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) pointerGestureHandler.clone(); + cloned.remove(gh); + pointerGestureHandler = cloned; + } + @Override + public final void addGestureListener(GestureHandler.GestureListener gl) { + addGestureListener(-1, gl); + } + @Override + public final void addGestureListener(int index, GestureHandler.GestureListener gl) { + if(gl == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) gestureListeners.clone(); + if(0>index) { + index = cloned.size(); + } + cloned.add(index, gl); + gestureListeners = cloned; + } + @Override + public final void removeGestureListener(GestureHandler.GestureListener gl) { + if (gl == null) { + return; + } + @SuppressWarnings("unchecked") + ArrayList cloned = (ArrayList) gestureListeners.clone(); + cloned.remove(gl); + gestureListeners= cloned; + } + + private static int step(int lower, int edge, int value) { + return value < edge ? lower : value; + } + + /** + * Consume the {@link MouseEvent}, i.e. + *
      +     *   - validate
      +     *   - handle gestures
      +     *   - synthesize events if applicable (like gestures)
      +     *   - dispatch event to listener
      +     * 
      + */ + protected void consumeMouseEvent(MouseEvent pe) { + final int x = pe.getX(); + final int y = pe.getY(); + + if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.drop: "+pe); + } + return; // .. invalid .. + } if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent: event: "+e); + System.err.println("consumeMouseEvent.in: "+pe); } + + // + // - Remove redundant events + // - Determine ENTERED/EXITED state + // - synthesize ENTERED event + // - fix MOVED/DRAGGED event + // - Reset states if applicable + // + final long when = pe.getWhen(); + int eventType = pe.getEventType(); + final MouseEvent eEntered; + switch( eventType ) { + case MouseEvent.EVENT_MOUSE_EXITED: + case MouseEvent.EVENT_MOUSE_ENTERED: + pState1.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; + // clear states + pState1.lastButtonPressTime = 0; + pState1.buttonPressed = 0; + eEntered = null; + break; + + case MouseEvent.EVENT_MOUSE_MOVED: + if ( pState1.buttonPressed > 0 ) { + pe = pe.createVariant(MouseEvent.EVENT_MOUSE_DRAGGED); + eventType = pe.getEventType(); + } + // Fall through intended ! + case MouseEvent.EVENT_MOUSE_DRAGGED: + if( pState1.insideWindow && pState1.lastMovePosition.getX() == x && pState1.lastMovePosition.getY() == y ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+pState1.lastMovePosition); + } + return; // skip same position + } + pState1.lastMovePosition.setX(x); + pState1.lastMovePosition.setY(y); + // Fall through intended ! + default: + if(!pState1.insideWindow) { + pState1.insideWindow = true; + eEntered = pe.createVariant(MouseEvent.EVENT_MOUSE_ENTERED); + // clear states + pState1.lastButtonPressTime = 0; + pState1.buttonPressed = 0; + } else { + eEntered = null; + } + } + if( null != eEntered ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.send.0: "+eEntered); + } + dispatchMouseEvent(eEntered); + } + + // + // Handle Default Gestures + // + if( defaultGestureHandlerEnabled && + pe.getPointerType(0).getPointerClass() == MouseEvent.PointerClass.Onscreen ) + { + if( null == gesture2PtrTouchScroll ) { + final int scaledScrollSlop; + final int scaledDoubleTapSlop; + final MonitorDevice monitor = getMainMonitor(); + if ( null != monitor ) { + final DimensionImmutable mm = monitor.getSizeMM(); + final float pixWPerMM = (float)monitor.getCurrentMode().getRotatedWidth() / (float)mm.getWidth(); + final float pixHPerMM = (float)monitor.getCurrentMode().getRotatedHeight() / (float)mm.getHeight(); + final float pixPerMM = Math.min(pixHPerMM, pixWPerMM); + scaledScrollSlop = Math.round(DoubleTapScrollGesture.SCROLL_SLOP_MM * pixPerMM); + scaledDoubleTapSlop = Math.round(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_MM * pixPerMM); + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.gscroll: scrollSlop "+scaledScrollSlop+", doubleTapSlop "+scaledDoubleTapSlop+", pixPerMM "+pixPerMM+", "+monitor); + } + } else { + scaledScrollSlop = DoubleTapScrollGesture.SCROLL_SLOP_PIXEL; + scaledDoubleTapSlop = DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL; + } + gesture2PtrTouchScroll = new DoubleTapScrollGesture(step(DoubleTapScrollGesture.SCROLL_SLOP_PIXEL, DoubleTapScrollGesture.SCROLL_SLOP_PIXEL/2, scaledScrollSlop), + step(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL, DoubleTapScrollGesture.DOUBLE_TAP_SLOP_PIXEL/2, scaledDoubleTapSlop)); + } + if( gesture2PtrTouchScroll.process(pe) ) { + pe = (MouseEvent) gesture2PtrTouchScroll.getGestureEvent(); + gesture2PtrTouchScroll.clear(false); + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.gscroll: "+pe); + } + dispatchMouseEvent(pe); + return; + } + if( gesture2PtrTouchScroll.isWithinGesture() ) { + return; // within gesture .. need more input .. + } + } + // + // Handle Custom Gestures + // + { + final int pointerGestureHandlerCount = pointerGestureHandler.size(); + if( pointerGestureHandlerCount > 0 ) { + boolean withinGesture = false; + for(int i = 0; !pe.isConsumed() && i < pointerGestureHandlerCount; i++ ) { + final GestureHandler gh = pointerGestureHandler.get(i); + if( gh.process(pe) ) { + final InputEvent ieG = gh.getGestureEvent(); + gh.clear(false); + if( ieG instanceof MouseEvent ) { + dispatchMouseEvent((MouseEvent)ieG); + } else if( ieG instanceof GestureHandler.GestureEvent) { + final GestureHandler.GestureEvent ge = (GestureHandler.GestureEvent) ieG; + for(int j = 0; !ge.isConsumed() && j < gestureListeners.size(); j++ ) { + gestureListeners.get(j).gestureDetected(ge); + } + } + return; + } + withinGesture |= gh.isWithinGesture(); + } + if( withinGesture ) { + return; + } + } + } + + // + // Synthesize mouse click + // + final MouseEvent eClicked; + switch( eventType ) { + case MouseEvent.EVENT_MOUSE_PRESSED: + if( 1 == pe.getPointerCount() ) { + pState1.lastButtonPressTime = when; + } + pState1.buttonPressed = pe.getButton(); + eClicked = null; + break; + case MouseEvent.EVENT_MOUSE_RELEASED: + if( 1 == pe.getPointerCount() && when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { + eClicked = pe.createVariant(MouseEvent.EVENT_MOUSE_CLICKED); + } else { + eClicked = null; + pState1.lastButtonPressTime = 0; + } + pState1.buttonPressed = 0; + break; + case MouseEvent.EVENT_MOUSE_CLICKED: + // ignore - synthesized here .. + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent: drop recv'ed (synth here) "+pe); + } + pe = null; + eClicked = null; + break; + default: + eClicked = null; + } + + if( null != pe ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.send.1: "+pe); + } + dispatchMouseEvent(pe); // actual mouse event + } + if( null != eClicked ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.send.2: "+eClicked); + } + dispatchMouseEvent(eClicked); + } + } + + private final void dispatchMouseEvent(MouseEvent e) { for(int i = 0; !e.isConsumed() && i < mouseListeners.size(); i++ ) { MouseListener l = mouseListeners.get(i); switch(e.getEventType()) { @@ -2537,12 +2874,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); + consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState0.buttonModMask, keyCode, keySym, keyChar) ); } public void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | mouseButtonModMask, keyCode, keySym, keyChar) ); + enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState0.buttonModMask, keyCode, keySym, keyChar) ); } @Override diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 364a348ee..0e76db374 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -59,19 +59,16 @@ public class AndroidNewtEventFactory { private static final short aMotionEventType2Newt(int aType) { switch( aType ) { case android.view.MotionEvent.ACTION_DOWN: + case android.view.MotionEvent.ACTION_POINTER_DOWN: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; case android.view.MotionEvent.ACTION_UP: + case android.view.MotionEvent.ACTION_POINTER_UP: + case android.view.MotionEvent.ACTION_CANCEL: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; case android.view.MotionEvent.ACTION_MOVE: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_DRAGGED; - case android.view.MotionEvent.ACTION_CANCEL: - return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; case android.view.MotionEvent.ACTION_OUTSIDE: return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_MOVED; - case android.view.MotionEvent.ACTION_POINTER_DOWN: - return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_PRESSED; - case android.view.MotionEvent.ACTION_POINTER_UP: - return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED; // case ACTION_HOVER_MOVE case ACTION_SCROLL: // API Level 12 ! return com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_WHEEL_MOVED; @@ -244,18 +241,15 @@ public class AndroidNewtEventFactory { return maxPressure; } - private final int touchSlop, touchSlopSquare, doubleTapSlop, doubleTapSlopSquare; - + private final int touchSlop; public AndroidNewtEventFactory(android.content.Context context, android.os.Handler handler) { final android.view.ViewConfiguration configuration = android.view.ViewConfiguration.get(context); touchSlop = configuration.getScaledTouchSlop(); - touchSlopSquare = touchSlop * touchSlop; - doubleTapSlop = configuration.getScaledDoubleTapSlop(); - doubleTapSlopSquare = doubleTapSlop * doubleTapSlop; + final int doubleTapSlop = configuration.getScaledDoubleTapSlop(); if(DEBUG_MOUSE_EVENT) { - System.err.println("GestureListener touchSlop (scaled) "+touchSlop); - System.err.println("GestureListener doubleTapSlop (scaled) "+doubleTapSlop); - } + System.err.println("AndroidNewtEventFactory scrollSlop (scaled) "+touchSlop); + System.err.println("AndroidNewtEventFactory doubleTapSlop (scaled) "+doubleTapSlop); + } } private static void collectPointerData(MotionEvent e, int eIdx, int dIdx, final int[] x, final int[] y, final float[] pressure, short[] pointerIds, final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes) { @@ -272,8 +266,8 @@ public class AndroidNewtEventFactory { } } - public com.jogamp.newt.event.MouseEvent[] createMouseEvents(boolean isOnTouchEvent, - android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { + public com.jogamp.newt.event.MouseEvent createMouseEvents(boolean isOnTouchEvent, + android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: isOnTouchEvent "+isOnTouchEvent+", "+event); } @@ -285,67 +279,17 @@ public class AndroidNewtEventFactory { // // Prefilter Android Event (Gesture, ..) and determine final type // - final int aType; - final short nType; + final int aType = event.getActionMasked(); + final short nType = aMotionEventType2Newt(aType); final float rotationScale = touchSlop; final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; - int rotationSource = 0; // 1 - Gesture, 2 - ACTION_SCROLL - { - final int aType0 = event.getActionMasked(); - if( isOnTouchEvent ) { - switch ( aType0 ) { - case MotionEvent.ACTION_DOWN: - case MotionEvent.ACTION_POINTER_DOWN: - gesture2FingerScrl.onDown(event); - break; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_POINTER_UP: - gesture2FingerScrl.onUp(event); - break; - case MotionEvent.ACTION_MOVE: - gesture2FingerScrl.onMove(event); - break; - } - } - - if( gesture2FingerScrl.gestureStarted() ) { - if( gesture2FingerScrl.hasGesture(true) ) { - final float[] rot = gesture2FingerScrl.getScrollDistanceXY(); - rotationXYZ[0] = rot[0] / rotationScale; - rotationXYZ[1] = rot[1] / rotationScale; - aType = ACTION_SCROLL; // 8 - rotationSource = 1; - } else { - return new com.jogamp.newt.event.MouseEvent[0]; // skip, but cont. sending events - } - } else { - aType = aType0; - } - nType = aMotionEventType2Newt(aType); - } if( (short)0 != nType ) { final short clickCount = 1; int modifiers = 0; - if( 0 == rotationSource && AndroidVersion.SDK_INT >= 12 && ACTION_SCROLL == aType ) { // API Level 12 - rotationXYZ[0] = event.getAxisValue(android.view.MotionEvent.AXIS_X) / rotationScale; - rotationXYZ[1] = event.getAxisValue(android.view.MotionEvent.AXIS_Y) / rotationScale; - rotationSource = 2; - } - - if( 0 != rotationSource ) { - if( rotationXYZ[0]*rotationXYZ[0] > rotationXYZ[1]*rotationXYZ[1] ) { - // Horizontal - modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; - } - if(DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: Gesture2FingerScrl Scroll "+rotationXYZ[0]+"/"+rotationXYZ[1]+", "+rotationScale+", mods "+modifiers+", source "+rotationSource); - } - } - // - // Determine newt-button and whether dedicated pointer is pressed + // Determine SDK 12 SCROLL, newt-button and whether dedicated pointer is pressed // final int pIndex; final short button; @@ -361,6 +305,22 @@ public class AndroidNewtEventFactory { } } break; + + case ACTION_SCROLL: + if( AndroidVersion.SDK_INT >= 12 ) { // API Level 12 + rotationXYZ[0] = event.getAxisValue(android.view.MotionEvent.AXIS_X) / rotationScale; + rotationXYZ[1] = event.getAxisValue(android.view.MotionEvent.AXIS_Y) / rotationScale; + + if( rotationXYZ[0]*rotationXYZ[0] > rotationXYZ[1]*rotationXYZ[1] ) { + // Horizontal + modifiers |= com.jogamp.newt.event.InputEvent.SHIFT_MASK; + } + if(DEBUG_MOUSE_EVENT) { + System.err.println("createMouseEvent: SDK-12 Scroll "+rotationXYZ[0]+"/"+rotationXYZ[1]+", "+rotationScale+", mods "+modifiers); + } + } + // Fall through intended! + default: { pIndex = 0; button = com.jogamp.newt.event.MouseEvent.BUTTON1; @@ -378,9 +338,9 @@ public class AndroidNewtEventFactory { final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes = new com.jogamp.newt.event.MouseEvent.PointerType[pCount]; if( 0 < pCount ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: collect ptr-data [0.."+(pCount-1)+", count "+pCount+", action "+pIndex+"], aType "+aType+", button "+button+", twoFingerScrollGesture "+gesture2FingerScrl); + System.err.println("createMouseEvent: collect ptr-data [0.."+(pCount-1)+", count "+pCount+", action "+pIndex+"], aType "+aType+", button "+button); } - int j = 0; + int j = 0; // Always put action-pointer data at index 0 collectPointerData(event, pIndex, j++, x, y, pressure, pointerIds, pointerTypes); for(int i=0; i < pCount; i++) { @@ -402,202 +362,11 @@ public class AndroidNewtEventFactory { final Object src = (null==newtSource)?null:(Object)newtSource; final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); - final com.jogamp.newt.event.MouseEvent me1 = new com.jogamp.newt.event.MouseEvent( - nType, src, unixTime, - modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds, - clickCount, button, rotationXYZ, rotationScale); - - if( com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_RELEASED == nType ) { - return new com.jogamp.newt.event.MouseEvent[] { me1, - new com.jogamp.newt.event.MouseEvent( - com.jogamp.newt.event.MouseEvent.EVENT_MOUSE_CLICKED, - src, unixTime, modifiers, x, y, pressure, maxPressure, pointerTypes, pointerIds, - clickCount, button, rotationXYZ, rotationScale) }; - } else { - return new com.jogamp.newt.event.MouseEvent[] { me1 }; - } - } + return new com.jogamp.newt.event.MouseEvent(nType, src, unixTime, + modifiers, pointerTypes, pointerIds, x, y, pressure, maxPressure, + button, clickCount, rotationXYZ, rotationScale); + } return null; // no mapping .. } - - static interface GestureHandler { - /** - * Returns true if last on* command produced a gesture, otherwise false. - * @param clear if true, method clears the gesture flag. - */ - public boolean hasGesture(boolean clear); - /** Returns true if the gesture has started */ - public boolean gestureStarted(); - /** Returns distance of the last consecutive double-tab scrolling. */ - public float[] getScrollDistanceXY(); - public void onDown(android.view.MotionEvent e); - public void onUp(android.view.MotionEvent e); - public void onMove(android.view.MotionEvent e); - } - - /** - * Criteria related to Android parameter: - * - ScaledDoubleTapSlop: - * - Max 2 finger distance to start 'scroll' mode - * - * - ScaledTouchSlop: - * - Min. movement w/ 2 pointer withing ScaledDoubleTapSlop starting 'scroll' mode - * - Max. distance growth in respect to initiated 2-finger distance. - * - * - Tolerate temporary lift of 1/2 pointer - * - * - Always validate pointer-id - */ - private final GestureHandler gesture2FingerScrl = new GestureHandler() { - private final float[] scrollDistance = new float[] { 0f, 0f }; - private int[] pIds = new int[] { -1, -1 }; - private int startDist = -1; - private float downY = 0; - private float downX = 0; - private float lastY = 0; - private float lastX = 0; - private int pointerDownCount = 0; - private boolean withinGesture = false; - private boolean hasGesture = false; - - public String toString() { - return "Gesture2FingerScrl[in "+withinGesture+", has "+hasGesture+", pc "+pointerDownCount+"]"; - } - - private void clear() { - downX = 0f; - downY = 0f; - lastX = 0f; - lastY = 0f; - startDist = -1; - withinGesture = false; - hasGesture = false; - pIds[0] = -1; - pIds[1] = -1; - } - - private final int getSquareDistance(float x1, float y1, float x2, float y2) { - final int deltaX = (int) x1 - (int) x2; - final int deltaY = (int) y1 - (int) y2; - return deltaX * deltaX + deltaY * deltaY; - } - - private int gesturePointers(final android.view.MotionEvent e, final int excludeIndex) { - int j = 0; - for(int i=e.getPointerCount()-1; i>=0; i--) { - if( excludeIndex != i ) { - final int id = e.getPointerId(i); - if( pIds[0] == id || pIds[1] == id ) { - j++; - } - } - } - return j; - } - - @Override - public boolean gestureStarted() { - return 0 <= startDist && withinGesture; - } - - @Override - public boolean hasGesture(boolean clear) { - final boolean r = hasGesture; - if( clear ) { - hasGesture = false; - } - return r; - } - - @Override - public final float[] getScrollDistanceXY() { - return scrollDistance; - } - - @Override - public void onDown(android.view.MotionEvent e) { - pointerDownCount = e.getPointerCount(); - final int gPtr = gesturePointers(e, -1); - if( 2 <= gPtr ) { // pick-up dLast coordinate to cont. gesture after temp loosing 1/2 pointers - lastX = e.getX(0); - lastY = e.getY(0); - } - if(DEBUG_MOUSE_EVENT) { - System.err.println(this+".onDown: gPtr "+gPtr+", "+e); - } - } - - @Override - public void onUp(android.view.MotionEvent e) { - pointerDownCount = e.getPointerCount(); - final int gPtr = gesturePointers(e, e.getActionIndex()); // w/o lifted pointer - if( 1 > gPtr ) { // tolerate lifting 1/2 gesture pointers temporary - clear(); - } - pointerDownCount--; // lifted now! - if(DEBUG_MOUSE_EVENT) { - System.err.println(this+".onUp: gPtr "+gPtr+", "+e); - } - } - - @Override - public void onMove(android.view.MotionEvent e) { - pointerDownCount = e.getPointerCount(); - if( 2 <= pointerDownCount ) { - final float x0 = e.getX(0); - final float y0 = e.getY(0); - final int sqDist = getSquareDistance(x0, y0, e.getX(1), e.getY(1)); - final boolean isDistWithinDoubleTapSlop = sqDist < doubleTapSlopSquare; - final int dist = (int)Math.sqrt(sqDist); - if( !withinGesture ) { - int gPtr = 0; - if( isDistWithinDoubleTapSlop ) { - if( 0 > startDist ) { - gPtr = 2; - pIds[0] = e.getPointerId(0); - pIds[1] = e.getPointerId(1); - downX = x0; - downY = y0; - lastX = x0; - lastY = y0; - startDist = dist; - } else { - gPtr = gesturePointers(e, -1); - if( 2 <= gPtr ) { - final int dX = (int) (x0 - downX); - final int dY = (int) (y0 - downY); - final int d = (dX * dX) + (dY * dY); - withinGesture = d > touchSlopSquare; - } - } - } - if(DEBUG_MOUSE_EVENT) { - final double dX = x0 - downX; - final double dY = y0 - downY; - final double d = Math.sqrt( (dX * dX) + (dY * dY) ); - System.err.println(this+".onMove.0: mDist "+d+", pStartDist "+dist+", gPtr "+gPtr+", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", dLast "+lastX+"/"+lastY+", "+e); - } - } - if( withinGesture ) { - final int gPtr = gesturePointers(e, -1); - final boolean isDistGrowthWithinTouchSlop = dist - startDist <= touchSlop; - if( 2 > gPtr || !isDistGrowthWithinTouchSlop ) { - clear(); - } else { - scrollDistance[0] = lastX - x0; - scrollDistance[1] = lastY - y0; - lastX = x0; - lastY = y0; - hasGesture = true; - } - if(DEBUG_MOUSE_EVENT) { - System.err.println(this+".onMove.1: pStartDist "+startDist+", pDist "+dist+", gPtr "+gPtr+" ["+pIds[0]+", "+pIds[1]+"]"+ - ", distWithin2DTSlop "+isDistWithinDoubleTapSlop+", distGrowthWithinTSlop "+isDistGrowthWithinTouchSlop+ - ", dLast "+lastX+"/"+lastY+", d "+scrollDistance[0]+"/"+scrollDistance[1]+", "+e); - } - } - } - } - }; } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java index 93735863e..df52208df 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -13,13 +13,16 @@ public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTo } private final boolean processTouchMotionEvents(View v, android.view.MotionEvent event, boolean isOnTouchEvent) { - final com.jogamp.newt.event.MouseEvent[] newtEvents = factory.createMouseEvents(isOnTouchEvent, event, newtWindow); - if(null != newtEvents) { - newtWindow.focusChanged(false, true); - for(int i=0; i [-30f .. 30f] + } + }; @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { @@ -266,7 +284,6 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); System.err.println(Thread.currentThread()+" GearsES2.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); - drawableHeight = imageHeight; if( !gl.hasGLSL() ) { return; @@ -326,6 +343,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); + window.removeGestureHandler(pinchToZoomGesture); + pinchToZoomGesture = null; + window.removeGestureListener(pinchToZoomListener); } final GL2ES2 gl = drawable.getGL().getGL2ES2(); if( !gl.hasGLSL() ) { @@ -432,69 +452,6 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } } - interface GestureHandler { - /** Returns true if within the gesture */ - public boolean isWithinGesture(); - /** Returns true if within the gesture */ - public boolean onReleased(MouseEvent e); - /** Returns true if within the gesture */ - public boolean onDragged(MouseEvent e); - } - final GestureHandler gesture2PtrZoom = new GestureHandler() { - private int zoomLastYDist; - private boolean zoomFirstTouch = true; - private boolean zoomMode = false; - - @Override - public boolean isWithinGesture() { - return zoomMode; - } - - @Override - public boolean onReleased(MouseEvent e) { - if( zoomMode && e.getPointerCount()==1 ) { - zoomFirstTouch = true; - zoomMode = false; - System.err.println("panZ.X: "+e); - } - return zoomMode; - } - - @Override - public boolean onDragged(MouseEvent e) { - if( e.getPointerCount() >=2 ) { - // 2 pointers zoom .. [ -15 .. 15 ], range 30 - /** - // Simple 1:1 Zoom: finger-distance to screen-coord - final int dy = Math.abs(e.getY(0)-e.getY(1)); - float scale = (float)dy / (float)drawableHeight; - panZ = 30f * scale - 15f; - System.err.println("panZ: scale "+scale+" ["+dy+"/"+drawableHeight+"] -> "+panZ); - */ - // Diff. 1:1 Zoom: finger-distance to screen-coord - if(zoomFirstTouch) { - zoomLastYDist = Math.abs(e.getY(0)-e.getY(1)); - zoomFirstTouch=false; - zoomMode = true; - System.err.println("panZ: 1st pinch "+zoomLastYDist+", "+e); - } else if( zoomMode ) { - final int dy = Math.abs(e.getY(0)-e.getY(1)); - final int ddy = dy - zoomLastYDist; - - final float incr = ( (float)ddy / (float)drawableHeight ) * 15.0f; - panZ += incr; - if( e.getPointerCount() > 2 ) { - panZ += incr; - } - System.err.println("panZ.1: ddy "+ddy+", incr "+incr+" ["+dy+"/"+drawableHeight+"], dblZoom "+(e.getPointerCount() > 2)+" -> "+panZ); - - zoomLastYDist = dy; - } - } - return zoomMode; - } - }; - class GearsMouseAdapter implements MouseListener{ private int prevMouseX, prevMouseY; @@ -526,40 +483,33 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } public void mousePressed(MouseEvent e) { - if( !gesture2PtrZoom.isWithinGesture() ) { - if( e.getPointerCount()==1 ) { - prevMouseX = e.getX(); - prevMouseY = e.getY(); - } else if( e.getPointerCount() == 4 ) { - final Object src = e.getSource(); - if( e.getPressure(true) > 0.7f && src instanceof Window) { // show Keyboard - ((Window) src).setKeyboardVisible(true); - } + if( e.getPointerCount()==1 ) { + prevMouseX = e.getX(); + prevMouseY = e.getY(); + } else if( e.getPointerCount() == 4 ) { + final Object src = e.getSource(); + if( e.getPressure(true) > 0.7f && src instanceof Window) { // show Keyboard + ((Window) src).setKeyboardVisible(true); } } } public void mouseReleased(MouseEvent e) { - gesture2PtrZoom.onReleased(e); } public void mouseMoved(MouseEvent e) { - if( !gesture2PtrZoom.isWithinGesture() && e.getPointerCount()==1 ) { - if( e.isConfined() ) { - navigate(e); - } else { - // track prev. position so we don't have 'jumps' - // in case we move to confined navigation. - prevMouseX = e.getX(); - prevMouseY = e.getY(); - } + if( e.isConfined() ) { + navigate(e); + } else { + // track prev. position so we don't have 'jumps' + // in case we move to confined navigation. + prevMouseX = e.getX(); + prevMouseY = e.getY(); } } public void mouseDragged(MouseEvent e) { - if( !gesture2PtrZoom.onDragged(e) && e.getPointerCount()==1 ) { - navigate(e); - } + navigate(e); } private void navigate(MouseEvent e) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index fe2c0f31a..74be176da 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -266,8 +266,10 @@ public class TestGearsES2NEWT extends UITestCase { }); glWindow.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { - glWindow.setFullscreen(!glWindow.isFullscreen()); - System.err.println("setFullscreen: "+glWindow.isFullscreen()); + if(e.getClickCount() == 2 && e.getPointerCount() == 1) { + glWindow.setFullscreen(!glWindow.isFullscreen()); + System.err.println("setFullscreen: "+glWindow.isFullscreen()); + } } }); -- cgit v1.2.3 From a05b87a369441d9ef38f97929f866b3d4ced0e57 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 15 Oct 2013 17:04:35 +0200 Subject: AWTPrintLifecycle.setupPrint(..): Add optional tileWidth and tileHeight, allowing user to set custom tile size for performance evaluation/tweak --- make/scripts/tests.sh | 4 +-- .../classes/javax/media/opengl/awt/GLCanvas.java | 27 +++++++++----- .../classes/javax/media/opengl/awt/GLJPanel.java | 29 +++++++++------ .../classes/jogamp/opengl/awt/AWTTilePainter.java | 21 ++++++----- .../jogamp/nativewindow/awt/AWTPrintLifecycle.java | 30 ++++++++++------ .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 27 +++++++++----- .../test/junit/jogl/tile/OffscreenPrintable.java | 7 ++-- .../test/junit/jogl/tile/OnscreenPrintable.java | 8 +++-- .../opengl/test/junit/jogl/tile/PrintableBase.java | 8 ++++- .../junit/jogl/tile/TestTiledPrintingGearsAWT.java | 25 +++++++------ .../jogl/tile/TestTiledPrintingGearsNewtAWT.java | 25 +++++++------ .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 31 +++++++++------- .../jogl/tile/TestTiledPrintingGearsSwingAWT2.java | 8 ++--- .../tile/TestTiledPrintingNIOImageSwingAWT.java | 2 +- .../test/junit/jogl/tile/TiledPrintingAWTBase.java | 42 ++++++++++++++-------- 15 files changed, 187 insertions(+), 107 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 84f487c38..a302666f7 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -299,7 +299,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -333,7 +333,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 20dd802fb..b9576b8d6 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -723,18 +723,16 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } private volatile boolean printActive = false; - private int printNumSamples = 0; private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { + public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { printActive = true; - printNumSamples = numSamples; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); - printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } private final Runnable setupPrintOnEDT = new Runnable() { @@ -760,10 +758,18 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printAnimator.remove(GLCanvas.this); } final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); - final int reqNumSamples = printNumSamples; - printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps); + final int printNumSamples = printAWTTiles.getNumSamples(caps); + GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); + final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ; if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ + ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ + ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } if( caps.getSampleBuffers() ) { // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX @@ -776,10 +782,13 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing caps.setNumSamples(printNumSamples); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, + null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); } - final GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 673f22aff..1ec0ad7bc 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -510,18 +510,16 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } private volatile boolean printActive = false; - private int printNumSamples = 0; private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @Override - public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { + public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { printActive = true; - printNumSamples = numSamples; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); - printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } private final Runnable setupPrintOnEDT = new Runnable() { @@ -553,21 +551,32 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printGLAD = GLJPanel.this; // default: re-use final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); - final int reqNumSamples = printNumSamples; - printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps); + final int printNumSamples = printAWTTiles.getNumSamples(caps); + GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); + final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLAD = reqNewGLADSamples || reqNewGLADSize ; if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ + ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ + ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } - if( printNumSamples != caps.getNumSamples() ) { + if( reqNewGLAD ) { caps.setDoubleBuffered(false); caps.setOnscreen(false); caps.setSampleBuffers(0 < printNumSamples); caps.setNumSamples(printNumSamples); final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, + null); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); } - final GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index 0600d99f5..9bdceff48 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -71,6 +71,7 @@ public class AWTTilePainter { public final TileRenderer renderer; public final int componentCount; public final double scaleMatX, scaleMatY; + public final int customTileWidth, customTileHeight, customNumSamples; public final boolean verbose; public boolean flipVertical; @@ -99,18 +100,16 @@ public class AWTTilePainter { } /** - * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples - * @param caps used capabilties - * @return resulting number of samples, 0 if disabled + * @return resulting number of samples by comparing w/ {@link #customNumSamples} and the caps-config, 0 if disabled */ - public static int getNumSamples(int numSamples, GLCapabilitiesImmutable caps) { - if( 0 > numSamples ) { + public int getNumSamples(GLCapabilitiesImmutable caps) { + if( 0 > customNumSamples ) { return 0; - } else if( 0 < numSamples ) { + } else if( 0 < customNumSamples ) { if ( !caps.getGLProfile().isGL2ES3() ) { return 0; } - return Math.max(caps.getNumSamples(), numSamples); + return Math.max(caps.getNumSamples(), customNumSamples); } else { return caps.getNumSamples(); } @@ -130,14 +129,20 @@ public class AWTTilePainter { * @param componentCount * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels + * @param numSamples custom multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param verbose */ - public AWTTilePainter(TileRenderer renderer, int componentCount, double scaleMatX, double scaleMatY, boolean verbose) { + public AWTTilePainter(TileRenderer renderer, int componentCount, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight, boolean verbose) { this.renderer = renderer; this.renderer.setGLEventListener(preTileGLEL, postTileGLEL); this.componentCount = componentCount; this.scaleMatX = scaleMatX; this.scaleMatY = scaleMatY; + this.customNumSamples = numSamples; + this.customTileWidth= tileWidth; + this.customTileHeight = tileHeight; this.verbose = verbose; this.flipVertical = true; } diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java index 65e5ab3f0..e5290aee1 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/AWTPrintLifecycle.java @@ -47,9 +47,9 @@ import jogamp.nativewindow.awt.AWTMisc; *

      * Users attempting to print an AWT {@link Container} containing {@link AWTPrintLifecycle} elements * shall consider decorating the {@link Container#printAll(Graphics)} call with
      - * {@link #setupPrint(double, double, int) setupPrint(..)} and {@link #releasePrint()} + * {@link #setupPrint(double, double, int, int, int) setupPrint(..)} and {@link #releasePrint()} * on all {@link AWTPrintLifecycle} elements in the {@link Container}.
      - * To minimize this burden, a user can use {@link Context#setupPrint(Container, double, double, int) Context.setupPrint(..)}: + * To minimize this burden, a user can use {@link Context#setupPrint(Container, double, double, int, int, int) Context.setupPrint(..)}: *

        *  Container cont;
        *  double scaleGLMatXY = 72.0/glDPI;
      @@ -75,7 +75,7 @@ import jogamp.nativewindow.awt.AWTMisc;
        */
       public interface AWTPrintLifecycle {
       
      -    public static final int DEFAULT_PRINT_TILE_SIZE = 512;
      +    public static final int DEFAULT_PRINT_TILE_SIZE = 1024;
           
           
           /**
      @@ -86,8 +86,10 @@ public interface AWTPrintLifecycle {
            * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels
            * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels
            * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples 
      +     * @param tileWidth custom tile width for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
      +     * @param tileHeight custom tile height for {@link com.jogamp.opengl.util.TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default.
            */
      -    void setupPrint(double scaleMatX, double scaleMatY, int numSamples);
      +    void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight);
           
           /**
            * Shall be called after {@link PrinterJob#print()}.
      @@ -98,7 +100,7 @@ public interface AWTPrintLifecycle {
           void releasePrint();
       
           /**
      -     * Convenient {@link AWTPrintLifecycle} context simplifying calling {@link AWTPrintLifecycle#setupPrint(double, double, int) setupPrint(..)}
      +     * Convenient {@link AWTPrintLifecycle} context simplifying calling {@link AWTPrintLifecycle#setupPrint(double, double, int, int, int) setupPrint(..)}
            * and {@link AWTPrintLifecycle#releasePrint()} on all {@link AWTPrintLifecycle} elements of a {@link Container}.
            * 

      * See Usage. @@ -110,14 +112,16 @@ public interface AWTPrintLifecycle { * See Usage. *

      * - * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(double, double, int) setupPrint(..)} on all {@link AWTPrintLifecycle} elements. + * @param c container to be traversed through to perform {@link AWTPrintLifecycle#setupPrint(double, double, int, int, int) setupPrint(..)} on all {@link AWTPrintLifecycle} elements. * @param scaleMatX {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatX * width pixels * @param scaleMatY {@link Graphics2D} {@link Graphics2D#scale(double, double) scaling factor}, i.e. rendering 1/scaleMatY * height pixels * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @return the context */ - public static Context setupPrint(Container c, double scaleMatX, double scaleMatY, int numSamples) { - final Context t = new Context(c, scaleMatX, scaleMatY, numSamples); + public static Context setupPrint(Container c, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { + final Context t = new Context(c, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight); t.setupPrint(c); return t; } @@ -132,7 +136,7 @@ public interface AWTPrintLifecycle { } /** - * @return count of performed actions of last {@link #setupPrint(Container, double, double, int) setupPrint(..)} or {@link #releasePrint()}. + * @return count of performed actions of last {@link #setupPrint(Container, double, double, int, int, int) setupPrint(..)} or {@link #releasePrint()}. */ public int getCount() { return count; } @@ -140,12 +144,14 @@ public interface AWTPrintLifecycle { private final double scaleMatX; private final double scaleMatY; private final int numSamples; + private final int tileWidth; + private final int tileHeight; private int count; private final AWTMisc.ComponentAction setupAction = new AWTMisc.ComponentAction() { @Override public void run(Component c) { - ((AWTPrintLifecycle)c).setupPrint(scaleMatX, scaleMatY, numSamples); + ((AWTPrintLifecycle)c).setupPrint(scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight); } }; private final AWTMisc.ComponentAction releaseAction = new AWTMisc.ComponentAction() { @Override @@ -153,11 +159,13 @@ public interface AWTPrintLifecycle { ((AWTPrintLifecycle)c).releasePrint(); } }; - private Context(Container c, double scaleMatX, double scaleMatY, int numSamples) { + private Context(Container c, double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { this.cont = c; this.scaleMatX = scaleMatX; this.scaleMatY = scaleMatY; this.numSamples = numSamples; + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; this.count = 0; } private void setupPrint(Container c) { diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 73b3bc368..767533d40 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -471,7 +471,6 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } private volatile boolean printActive = false; - private int printNumSamples = 0; private GLAnimatorControl printAnimator = null; private GLAutoDrawable printGLAD = null; private AWTTilePainter printAWTTiles = null; @@ -484,12 +483,11 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } @Override - public void setupPrint(double scaleMatX, double scaleMatY, int numSamples) { + public void setupPrint(double scaleMatX, double scaleMatY, int numSamples, int tileWidth, int tileHeight) { printActive = true; - printNumSamples = numSamples; final int componentCount = isOpaque() ? 3 : 4; final TileRenderer printRenderer = new TileRenderer(); - printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, DEBUG); + printAWTTiles = new AWTTilePainter(printRenderer, componentCount, scaleMatX, scaleMatY, numSamples, tileWidth, tileHeight, DEBUG); AWTEDTExecutor.singleton.invoke(getTreeLock(), true /* allowOnNonEDT */, true /* wait */, setupPrintOnEDT); } private final Runnable setupPrintOnEDT = new Runnable() { @@ -522,10 +520,18 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto printAnimator.remove(glad); } final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); - final int reqNumSamples = printNumSamples; - printNumSamples = AWTTilePainter.getNumSamples(reqNumSamples, caps); + final int printNumSamples = printAWTTiles.getNumSamples(caps); + GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); + final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ; if( DEBUG ) { - System.err.println("AWT print.setup: canvasSize "+getWidth()+"x"+getWidth()+", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+", numSamples "+reqNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ + ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ + ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } if( caps.getSampleBuffers() ) { // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX @@ -538,10 +544,13 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto caps.setNumSamples(printNumSamples); } final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, DEFAULT_PRINT_TILE_SIZE, DEFAULT_PRINT_TILE_SIZE, null); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, + null); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); } - final GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java index bd526419c..78fdde3ee 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OffscreenPrintable.java @@ -45,6 +45,7 @@ import javax.imageio.ImageIO; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.nativewindow.awt.DirectDataBufferInt; +import com.jogamp.opengl.util.TileRenderer; /** * {@link Printable} implementation using NIO {@link DirectDataBufferInt} {@link BufferedImage} @@ -64,11 +65,13 @@ public class OffscreenPrintable extends PrintableBase implements Printable { * @param printContainer * @param printDPI * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param imageType AWT BufferedImage type (must be one of the integer types) * @param pngFilename TODO */ - public OffscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int imageType, String pngFilename) { - super(job, printContainer, printDPI, numSamples); + public OffscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int tileWidth, int tileHeight, int imageType, String pngFilename) { + super(job, printContainer, printDPI, numSamples, tileWidth, tileHeight); this.imageType = imageType; this.pngFilename = pngFilename; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java index 7e8bac295..6f73ef2b4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/OnscreenPrintable.java @@ -39,6 +39,7 @@ import java.awt.print.PrinterException; import java.awt.print.PrinterJob; import com.jogamp.common.util.awt.AWTEDTExecutor; +import com.jogamp.opengl.util.TileRenderer; /** *
      Scaling of Frame and GL content
      @@ -66,11 +67,14 @@ public class OnscreenPrintable extends PrintableBase implements Printable { * @param printContainer * @param printDPI * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. */ - public OnscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples) { - super(job, printContainer, printDPI, numSamples); + public OnscreenPrintable(PrinterJob job, Container printContainer, int printDPI, int numSamples, int tileWidth, int tileHeight) { + super(job, printContainer, printDPI, numSamples, tileWidth, tileHeight); } + @Override public int print(Graphics g, PageFormat pf, int page) throws PrinterException { if (page > 0) { // We have only one page, and 'page' is zero-based diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java index 830ded960..dd9de60c3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/PrintableBase.java @@ -33,6 +33,7 @@ import java.awt.print.PrinterJob; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; +import com.jogamp.opengl.util.TileRenderer; /** * Base {@link Printable} implementation class. @@ -58,6 +59,7 @@ public abstract class PrintableBase implements Printable { public final Container cont; public final int dpi; public final int numSamples; + public final int tileWidth, tileHeight; protected final RecursiveLock lockPrinting = LockFactory.createRecursiveLock(); /** @@ -66,12 +68,16 @@ public abstract class PrintableBase implements Printable { * @param printContainer * @param printDPI * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. */ - public PrintableBase(PrinterJob job, Container printContainer, int printDPI, int numSamples) { + public PrintableBase(PrinterJob job, Container printContainer, int printDPI, int numSamples, int tileWidth, int tileHeight) { this.job = job; this.cont = printContainer; this.dpi = printDPI; this.numSamples = numSamples; + this.tileWidth = tileWidth; + this.tileHeight = tileHeight; } /** Wait for idle .. simply acquiring all locks and releasing them. */ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java index 4883df501..30e0ba4e6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsAWT.java @@ -116,15 +116,15 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, 0); + doPrintManual(frame, 72, 0, -1, -1); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, -1); + doPrintManual(frame, 300, -1, -1, -1); } }; final ActionListener print600DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 600, -1); + doPrintManual(frame, 600, -1, -1, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -178,36 +178,41 @@ public class TestTiledPrintingGearsAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true/* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true/* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java index a256d964f..ec1d7b1d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsNewtAWT.java @@ -121,15 +121,15 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, 0); + doPrintManual(frame, 72, 0, -1, -1); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, -1); + doPrintManual(frame, 300, -1, -1, -1); } }; final ActionListener print600DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 600, -1); + doPrintManual(frame, 600, -1, -1, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -183,36 +183,41 @@ public class TestTiledPrintingGearsNewtAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index f1759798b..72cb219ab 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -152,15 +152,15 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, 0); + doPrintManual(frame, 72, 0, -1, -1); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, -1); + doPrintManual(frame, 300, -1, -1, -1); } }; final ActionListener print600DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 600, -1); + doPrintManual(frame, 600, -1, -1, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -217,51 +217,56 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { if( !printDone ) { printDone = true; { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 0, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 72, 8, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, 2048, 2048, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_RGB /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_BGR /* offscreen-type */, 150, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_RGB /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); + waitUntilPrintJobsIdle(p); + } + { + // No AA needed for 150 dpi and greater :) + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_BGR /* offscreen-type */, 150, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, true /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, BufferedImage.TYPE_INT_ARGB_PRE /* offscreen-type */, 150, -1, -1, -1, true /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } if( allow600dpi ) { // No AA needed for 300 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, false /* resizeWithinPrint */); + final PrintableBase p = doPrintAuto(frame, PageFormat.LANDSCAPE, null, -1 /* offscreen-type */, 600, -1, -1, -1, false /* resizeWithinPrint */); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java index d18def075..2d4973d6b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java @@ -142,15 +142,15 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 72, 0); + doPrintManual(frame, 72, 0, -1, -1); } }; final ActionListener print150DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 150, -1); + doPrintManual(frame, 150, -1, -1, -1); } }; final ActionListener print300DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { - doPrintManual(frame, 300, -1); + doPrintManual(frame, 300, -1, -1, -1); } }; final Button print72DPIButton = new Button("72dpi"); print72DPIButton.addActionListener(print72DPIAction); @@ -220,7 +220,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { printDone = true; { // No AA needed for 150 dpi and greater :) - final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, -1 /* offscreen-type */, 150, -1, false); + final PrintableBase p = doPrintAuto(frame, PageFormat.PORTRAIT, null, -1 /* offscreen-type */, 150, -1, -1, -1, false); waitUntilPrintJobsIdle(p); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java index 0fe08ebc2..b51bfae87 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingNIOImageSwingAWT.java @@ -128,7 +128,7 @@ public class TestTiledPrintingNIOImageSwingAWT extends UITestCase { g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); // frame.paintAll(g2d); - final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, 1.0/scaleComp72, 1.0/scaleComp72, 0); + final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(frame, 1.0/scaleComp72, 1.0/scaleComp72, 0, -1, -1); try { frame.printAll(g2d); } finally { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java index e6179aa95..4e9d4bdbe 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TiledPrintingAWTBase.java @@ -51,11 +51,13 @@ import jogamp.nativewindow.awt.AWTMisc; import org.junit.Assert; +import com.jogamp.common.os.Platform; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.nativewindow.awt.AWTPrintLifecycle; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.TileRenderer; /** * Base unit test class implementing @@ -79,9 +81,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase { * @param offscrnImageType if < 0 onscreen, otherwise integer BufferedImage type * @param dpi * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. * @param resizeWithinPrintTest TODO */ - public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper, int offscrnImageType, int dpi, int numSamples, boolean resizeWithinPrintTest) { + public PrintableBase doPrintAuto(Container cont, int pOrientation, Paper paper, + int offscrnImageType, int dpi, int numSamples, int tileWidth, int tileHeight, boolean resizeWithinPrintTest) { lock.lock(); try { final PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); @@ -98,12 +103,13 @@ public abstract class TiledPrintingAWTBase extends UITestCase { StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(pdfMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "pdf", resizeWithinPrintTest); + final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, tileWidth, tileHeight, "pdf", resizeWithinPrintTest); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, resizeWithinPrintTest); + return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, + offscrnImageType, dpi, numSamples, tileWidth, tileHeight, resizeWithinPrintTest); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -112,12 +118,12 @@ public abstract class TiledPrintingAWTBase extends UITestCase { factories = PrinterJob.lookupStreamPrintServices(psMimeType); if (factories.length > 0) { - final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, "ps", resizeWithinPrintTest); + final String fname = getPrintFilename(offscrnImageType, dpi, numSamples, tileWidth, tileHeight, "ps", resizeWithinPrintTest); System.err.println("doPrint: dpi "+dpi+", "+fname); FileOutputStream outstream; try { outstream = new FileOutputStream(fname); - return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, resizeWithinPrintTest); + return doPrintAutoImpl(cont, pj, factories[0].getPrintService(outstream), pOrientation, paper, offscrnImageType, dpi, numSamples, tileWidth, tileHeight, resizeWithinPrintTest); } catch (FileNotFoundException e) { Assert.assertNull("Unexpected exception", e); } @@ -128,17 +134,17 @@ public abstract class TiledPrintingAWTBase extends UITestCase { lock.unlock(); } } - private String getPrintFilename(int offscrnImageType, int dpi, int numSamples, String suffix, boolean resizeWithinPrintTest) { + private String getPrintFilename(int offscrnImageType, int dpi, int numSamples, int tileWidth, int tileHeight, String suffix, boolean resizeWithinPrintTest) { final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; final String simpleTestName = getSimpleTestName("."); final String onoffscrn = 0 > offscrnImageType ? "on_screen" : "offscrn_"+offscrnImageType; final String aa = 0 <= numSamples ? "aa"+numSamples : "aaN"; - return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-%s-dpi%03d-%s-resize%d.%s", - simpleTestName, printCount, onoffscrn, dpi, aa, resizeWithinPrintTest?1:0, suffix).replace(' ', '_'); + return String.format("%-"+maxSimpleTestNameLen+"s-n%04d-%s-dpi%03d-%s-tSz%04dx%04d-resize%d.%s", + simpleTestName, printCount, onoffscrn, dpi, aa, tileWidth, tileHeight, resizeWithinPrintTest?1:0, suffix).replace(' ', '_'); } private PrintableBase doPrintAutoImpl(Container cont, PrinterJob job, StreamPrintService ps, int pOrientation, Paper paper, - int offscrnImageType, int dpi, int numSamples, boolean resizeWithinPrintTest) { + int offscrnImageType, int dpi, int numSamples, int tileWidth, int tileHeight, boolean resizeWithinPrintTest) { try { PageFormat pageFormat = job.defaultPage(); if( null != paper ) { @@ -152,9 +158,9 @@ public abstract class TiledPrintingAWTBase extends UITestCase { job.setPrintService(ps); final PrintableBase printable; if( 0 < offscrnImageType ) { - printable = new OffscreenPrintable(job, cont, dpi, numSamples, offscrnImageType, getPrintFilename(offscrnImageType, dpi, numSamples, "png", resizeWithinPrintTest)); + printable = new OffscreenPrintable(job, cont, dpi, numSamples, tileWidth, tileHeight, offscrnImageType, getPrintFilename(offscrnImageType, dpi, numSamples, tileWidth, tileHeight, "png", resizeWithinPrintTest)); } else { - printable = new OnscreenPrintable(job, cont, dpi, numSamples); + printable = new OnscreenPrintable(job, cont, dpi, numSamples, tileWidth, tileHeight); } printable.job.setPrintable(printable, pageFormat); doPrintImpl(printable, resizeWithinPrintTest); @@ -166,15 +172,16 @@ public abstract class TiledPrintingAWTBase extends UITestCase { } /** - * * @param cont * @param dpi * @param numSamples multisampling value: < 0 turns off, == 0 leaves as-is, > 0 enables using given num samples + * @param tileWidth custom tile width for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. + * @param tileHeight custom tile height for {@link TileRenderer#setTileSize(int, int, int) tile renderer}, pass -1 for default. */ - public PrintableBase doPrintManual(Container cont, int dpi, int numSamples) { + public PrintableBase doPrintManual(Container cont, int dpi, int numSamples, int tileWidth, int tileHeight) { lock.lock(); try { - final OnscreenPrintable printable = new OnscreenPrintable(PrinterJob.getPrinterJob(), cont, dpi, numSamples); + final OnscreenPrintable printable = new OnscreenPrintable(PrinterJob.getPrinterJob(), cont, dpi, numSamples, tileWidth, tileHeight); printable.job.setPrintable(printable); boolean ok = printable.job.printDialog(); if (ok) { @@ -207,10 +214,13 @@ public abstract class TiledPrintingAWTBase extends UITestCase { final double scaleGLMatXY = 72.0 / printable.dpi; System.err.println("PRINTable: "+printable.getClass().getSimpleName()); System.err.println("PRINT DPI: "+printable.dpi+", AA "+printable.numSamples+", scaleGL "+scaleGLMatXY); - final AWTPrintLifecycle.Context ctx = AWTPrintLifecycle.Context.setupPrint(printable.cont, scaleGLMatXY, scaleGLMatXY, printable.numSamples); + final AWTPrintLifecycle.Context ctx = + AWTPrintLifecycle.Context.setupPrint(printable.cont, scaleGLMatXY, scaleGLMatXY, + printable.numSamples, printable.tileWidth, printable.tileHeight); System.err.println("PRINT AWTPrintLifecycle.setup.count "+ctx.getCount()); final int w = printable.cont.getWidth(); final int h = printable.cont.getHeight(); + final long t0 = Platform.currentTimeMillis(); try { AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { @@ -230,6 +240,8 @@ public abstract class TiledPrintingAWTBase extends UITestCase { } }); } finally { ctx.releasePrint(); + final long td = Platform.currentTimeMillis() - t0; + System.err.println("PRINT Duration "+td+" ms"); if( resizeWithinPrintTest ) { AWTEDTExecutor.singleton.invoke(true, new Runnable() { public void run() { -- cgit v1.2.3 From a90bf31f8747dd38c61d518f8af4d4d4a64a8e90 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 07:56:20 +0200 Subject: NEWT PointerEvent: Unify event processing in new doPointerEvent(..) and consumePointerEvent(..) - Unifies native mouse and Android's pointer event, ready for Win7 touch Unify event processing in new doPointerEvent(..), which is also invoked from doMouseEvent(..), and consumePointerEvent(). doPointerEvent(..): Validates and modifies event data and finally creates the event, where consumePointerEvent(..) calls gesture handlers and may synthesize events. Unifies native mouse and Android's pointer event, ready for Win7 touch. AndroidNewtEventFactory calls doPointerEvent(..) directly. Removed lots of duplicated pointer event handling code. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 4 +- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 98 ++--- src/newt/classes/jogamp/newt/WindowImpl.java | 409 ++++++++++++--------- .../android/event/AndroidNewtEventFactory.java | 64 ++-- .../android/event/AndroidNewtEventTranslator.java | 14 +- 7 files changed, 303 insertions(+), 294 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index b3029f94c..099768f7c 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -58,14 +58,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledR REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index c1a14c1a2..bab911e37 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -49,9 +49,9 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" -set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" -REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" +set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a302666f7..129b0deab 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -301,7 +301,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -333,7 +333,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index fd5e27bdd..cb9e7a290 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -145,9 +145,17 @@ public class MouseEvent extends InputEvent super(eventType, source, when, modifiers); this.x = new int[]{x}; this.y = new int[]{y}; - this.pressure = constMousePressure; + switch(eventType) { + case EVENT_MOUSE_CLICKED: + case EVENT_MOUSE_PRESSED: + case EVENT_MOUSE_DRAGGED: + this.pressure = constMousePressure1; + break; + default: + this.pressure = constMousePressure0; + } this.maxPressure= 1.0f; - this.pointerID = constMousePointerIDs; + this.pointerID = new short[] { (short)(button - 1) }; this.clickCount=clickCount; this.button=button; this.rotationXYZ = rotationXYZ; @@ -212,70 +220,6 @@ public class MouseEvent extends InputEvent x, y, pressure, maxPressure, button, clickCount, rotationXYZ, rotationScale); } - /** - * Factory for a multiple-pointer event. - *

      - * The index for the multiple-pointer fields representing the triggering pointer is passed via actionIdx. - * If actionIdx is not 0, all multiple-pointer fields values of index 0 - * and actionIdx are swapped so that the pointer-index 0 will represent the triggering pointer. - *

      - *

      - * See details for multiple-pointer events. - *

      - * - * @param eventType - * @param source - * @param when - * @param modifiers - * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pointerType PointerType for each pointer (multiple pointer) - * @param pointerID Pointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. - * @param x X-axis for each pointer (multiple pointer) - * @param y Y-axis for each pointer (multiple pointer) - * @param pressure Pressure for each pointer (multiple pointer) - * @param maxPressure Maximum pointer pressure for all pointer - * @param button Corresponding mouse-button - * @param clickCount Mouse-button click-count - * @param rotationXYZ Rotation of all axis - * @param rotationScale Rotation scale - */ - public static MouseEvent create(short eventType, Object source, long when, int modifiers, - int actionIdx, PointerType pointerType[], short[] pointerID, - int[] x, int[] y, float[] pressure, float maxPressure, - short button, short clickCount, float[] rotationXYZ, float rotationScale) { - if( 0 <= actionIdx && actionIdx < pointerType.length) { - if( 0 < actionIdx ) { - { - final PointerType aType = pointerType[actionIdx]; - pointerType[actionIdx] = pointerType[0]; - pointerType[0] = aType; - } - { - final short s = pointerID[actionIdx]; - pointerID[actionIdx] = pointerID[0]; - pointerID[0] = s; - } - { - int s = x[actionIdx]; - x[actionIdx] = x[0]; - x[0] = s; - s = y[actionIdx]; - y[actionIdx] = y[0]; - y[0] = s; - } - { - final float aPress = pressure[actionIdx]; - pressure[actionIdx] = pressure[0]; - pressure[0] = aPress; - } - } - return new MouseEvent(eventType, source, when, modifiers, - pointerType, pointerID, x, y, pressure, maxPressure, - button, clickCount, rotationXYZ, rotationScale); - } - throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pointerType.length-1)+"]"); - } - /** * @return the count of pointers involved in this event */ @@ -528,15 +472,15 @@ public class MouseEvent extends InputEvent public static String getEventTypeString(short type) { switch(type) { - case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED"; - case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED"; - case EVENT_MOUSE_EXITED: return "EVENT_MOUSE_EXITED"; - case EVENT_MOUSE_PRESSED: return "EVENT_MOUSE_PRESSED"; - case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED"; - case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED"; - case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED"; - case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED"; - default: return "unknown (" + type + ")"; + case EVENT_MOUSE_CLICKED: return "EVENT_MOUSE_CLICKED"; + case EVENT_MOUSE_ENTERED: return "EVENT_MOUSE_ENTERED"; + case EVENT_MOUSE_EXITED: return "EVENT_MOUSE_EXITED"; + case EVENT_MOUSE_PRESSED: return "EVENT_MOUSE_PRESSED"; + case EVENT_MOUSE_RELEASED: return "EVENT_MOUSE_RELEASED"; + case EVENT_MOUSE_MOVED: return "EVENT_MOUSE_MOVED"; + case EVENT_MOUSE_DRAGGED: return "EVENT_MOUSE_DRAGGED"; + case EVENT_MOUSE_WHEEL_MOVED: return "EVENT_MOUSE_WHEEL_MOVED"; + default: return "unknown (" + type + ")"; } } @@ -558,8 +502,8 @@ public class MouseEvent extends InputEvent private final float rotationScale; private final float maxPressure; - private static final float[] constMousePressure = new float[]{0f}; - private static final short[] constMousePointerIDs = new short[]{0}; + private static final float[] constMousePressure0 = new float[]{0f}; + private static final float[] constMousePressure1 = new float[]{1f}; private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; public static final short EVENT_MOUSE_CLICKED = 200; diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 66ce46ed0..b0df2d894 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -135,6 +135,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** Timeout of queued events (repaint and resize) */ static final long QUEUED_EVENT_TO = 1200; // ms + private static final int[] constMousePointerTypes = new int[] { PointerType.Mouse.ordinal() }; + // // Volatile: Multithread Mutable Access // @@ -181,34 +183,50 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private ArrayList mouseListeners = new ArrayList(); + /** from event passing: {@link WindowImpl#consumePointerEvent(MouseEvent)}. */ private static class PointerState0 { - /** current pressed mouse button number */ - private short buttonPressed = (short)0; - /** current pressed mouse button modifier mask */ - private int buttonModMask = 0; - /** last time when a mouse button was pressed */ - private long lastButtonPressTime = 0; - /** last mouse button click count */ - private short lastButtonClickCount = (short)0; /** mouse entered window - is inside the window (may be synthetic) */ - private boolean insideWindow = false; - /** last mouse-move position */ - private Point lastMovePosition = new Point(); - } - private static class PointerState1 { - /** current pressed mouse button number */ - private short buttonPressed = (short)0; + boolean insideWindow = false; + /** last time when a mouse button was pressed */ - private long lastButtonPressTime = 0; - /** mouse entered window - is inside the window (may be synthetic) */ - private boolean insideWindow = false; - /** last mouse-move position */ - private Point lastMovePosition = new Point(); + long lastButtonPressTime = 0; + + void clearButton() { + lastButtonPressTime = 0; + } } - /** doMouseEvent */ private PointerState0 pState0 = new PointerState0(); - /** consumeMouseEvent */ + + /** from direct input: {@link WindowImpl#doPointerEvent(boolean, boolean, int[], short, int, int, short[], int[], int[], float[], float, float[], float)}. */ + private static class PointerState1 extends PointerState0 { + /** current pressed mouse button number */ + short buttonPressed = (short)0; + /** current pressed mouse button modifier mask */ + int buttonPressedMask = 0; + /** last mouse button click count */ + short lastButtonClickCount = (short)0; + + final void clearButton() { + super.clearButton(); + lastButtonPressTime = 0; + lastButtonClickCount = (short)0; + buttonPressed = 0; + buttonPressedMask = 0; + } + + /** last pointer-move position for 8 touch-down pointers */ + final Point[] movePositions = new Point[] { + new Point(), new Point(), new Point(), new Point(), + new Point(), new Point(), new Point(), new Point() }; + final Point getMovePosition(int id) { + if( 0 <= id && id < movePositions.length ) { + return movePositions[id]; + } + return null; + } + } private PointerState1 pState1 = new PointerState1(); + private boolean defaultGestureHandlerEnabled = true; private DoubleTapScrollGesture gesture2PtrTouchScroll = null; private ArrayList pointerGestureHandler = new ArrayList(); @@ -2247,7 +2265,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } @Override - public boolean consumeEvent(NEWTEvent e) { + public final boolean consumeEvent(NEWTEvent e) { switch(e.getEventType()) { // special repaint treatment case WindowEvent.EVENT_WINDOW_REPAINT: @@ -2288,7 +2306,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if(e instanceof KeyEvent) { consumeKeyEvent((KeyEvent)e); } else if(e instanceof MouseEvent) { - consumeMouseEvent((MouseEvent)e); + consumePointerEvent((MouseEvent)e); } else { throw new NativeWindowException("Unexpected NEWTEvent type " + e); } @@ -2347,21 +2365,115 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x, int y, short button, float[] rotationXYZ, float rotationScale) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } */ + + /** + * Send mouse event (one-pointer) either to be directly consumed or to be enqueued + * + * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, + * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. + * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. + */ protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, int x, int y, short button, float[] rotationXYZ, float rotationScale) { - if( 0 > button || button > MouseEvent.BUTTON_NUMBER ) { + if( 0 > button || button > MouseEvent.BUTTON_COUNT ) { throw new NativeWindowException("Invalid mouse button number" + button); + } else if( 0 == button ) { + button = 1; + } + doPointerEvent(enqueue, wait, constMousePointerTypes, eventType, modifiers, + 0 /*actionIdx*/, new short[] { (short)(button-1) }, + new int[]{x}, new int[]{y}, new float[]{0f} /*pressure*/, 1f /*maxPressure*/, + rotationXYZ, rotationScale); + } + + /** + * Send multiple-pointer event either to be directly consumed or to be enqueued + *

      + * The index for the element of multiple-pointer arrays represents the pointer which triggered the event + * is passed via actionIdx. + *

      + * + * @param enqueue if true, event will be {@link #enqueueEvent(boolean, NEWTEvent) enqueued}, + * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. + * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. + * @param pTypesOrdinal {@link MouseEvent.PointerType#ordinal()} for each pointer (multiple pointer) + * @param eventType + * @param modifiers + * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event + * @param pID Pointer ID for each pointer (multiple pointer), we assume pointerID's starts w/ 0 + * @param pX X-axis for each pointer (multiple pointer) + * @param pY Y-axis for each pointer (multiple pointer) + * @param pPressure Pressure for each pointer (multiple pointer) + * @param maxPressure Maximum pointer pressure for all pointer + */ + public void doPointerEvent(boolean enqueue, boolean wait, + int[] pTypesOrdinal, short eventType, int modifiers, + int actionIdx, short[] pID, + int[] pX, int[] pY, float[] pPressure, float maxPressure, + float[] rotationXYZ, float rotationScale) { + final long when = System.currentTimeMillis(); + final int pointerCount = pTypesOrdinal.length; + + if( 0 > actionIdx || actionIdx >= pointerCount) { + throw new IllegalArgumentException("actionIdx out of bounds [0.."+(pointerCount-1)+"]"); + } + if( 0 < actionIdx ) { + // swap values to make idx 0 the triggering pointer + { + final int aType = pTypesOrdinal[actionIdx]; + pTypesOrdinal[actionIdx] = pTypesOrdinal[0]; + pTypesOrdinal[0] = aType; + } + { + final short s = pID[actionIdx]; + pID[actionIdx] = pID[0]; + pID[0] = s; + } + { + int s = pX[actionIdx]; + pX[actionIdx] = pX[0]; + pX[0] = s; + s = pY[actionIdx]; + pY[actionIdx] = pY[0]; + pY[0] = s; + } + { + final float aPress = pPressure[actionIdx]; + pPressure[actionIdx] = pPressure[0]; + pPressure[0] = aPress; + } + } + final PointerType[] pointerType = new PointerType[pointerCount]; + for(int i=pointerCount-1; i>=0; i--) { + pointerType[i] = PointerType.valueOf(pTypesOrdinal[i]); + } + final short id = pID[0]; + final short button; + { + final int b = id + 1; + if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { + button = (short)b; + } else { + button = com.jogamp.newt.event.MouseEvent.BUTTON1; + } } // - // Remove redundant events, determine ENTERED state and reset states if applicable + // - Determine ENTERED/EXITED state + // - Remove redundant move/drag events + // - Reset states if applicable // - final long when = System.currentTimeMillis(); + int x = pX[0]; + int y = pY[0]; + final Point movePositionP0 = pState1.getMovePosition(id); switch( eventType ) { case MouseEvent.EVENT_MOUSE_EXITED: - if( x==-1 && y==-1 ) { - x = pState0.lastMovePosition.getX(); - y = pState0.lastMovePosition.getY(); + if( null != movePositionP0 ) { + if( x==-1 && y==-1 ) { + x = movePositionP0.getX(); + y = movePositionP0.getY(); + } + movePositionP0.set(0, 0); } // Fall through intended! @@ -2369,54 +2481,46 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // clip coordinates to window dimension x = Math.min(Math.max(x, 0), getWidth()-1); y = Math.min(Math.max(y, 0), getHeight()-1); - pState0.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - // clear states - pState0.lastButtonPressTime = 0; - pState0.lastButtonClickCount = (short)0; - pState0.buttonPressed = 0; - pState0.buttonModMask = 0; + pState1.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; + pState1.clearButton(); break; case MouseEvent.EVENT_MOUSE_MOVED: case MouseEvent.EVENT_MOUSE_DRAGGED: - if( pState0.insideWindow && pState0.lastMovePosition.getX() == x && pState0.lastMovePosition.getY() == y ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("doMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+pState0.lastMovePosition); + if( null != movePositionP0 ) { + if( pState1.insideWindow && movePositionP0.getX() == x && movePositionP0.getY() == y ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("doMouseEvent: skip "+MouseEvent.getEventTypeString(eventType)+" w/ same position: "+movePositionP0); + } + return; // skip same position } - return; // skip same position + movePositionP0.set(x, y); } - pState0.lastMovePosition.setX(x); - pState0.lastMovePosition.setY(y); // Fall through intended ! default: - if(!pState0.insideWindow) { - pState0.insideWindow = true; - - // clear states - pState0.lastButtonPressTime = 0; - pState0.lastButtonClickCount = (short)0; - pState0.buttonPressed = 0; - pState0.buttonModMask = 0; + if(!pState1.insideWindow) { + pState1.insideWindow = true; + pState1.clearButton(); } } if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+pState0.lastMovePosition); + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); } return; // .. invalid .. } if(DEBUG_MOUSE_EVENT) { System.err.println("doMouseEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+pState0.lastMovePosition); + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); } - - modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) - modifiers |= pState0.buttonModMask; // Always add currently pressed mouse buttons to modifier mask + modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) + modifiers |= pState1.buttonPressedMask; // Always add currently pressed mouse buttons to modifier mask + if( isPointerConfined() ) { modifiers |= InputEvent.CONFINED_MASK; } @@ -2424,78 +2528,79 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer modifiers |= InputEvent.INVISIBLE_MASK; } - final MouseEvent e; - + pX[0] = x; + pY[0] = y; + + // + // - Determine CLICK COUNT + // - Ignore sent CLICKED + // - Track buttonPressed incl. buttonPressedMask + // - Fix MOVED/DRAGGED event + // + final MouseEvent e; switch( eventType ) { + case MouseEvent.EVENT_MOUSE_CLICKED: + e = null; + break; + case MouseEvent.EVENT_MOUSE_PRESSED: - if( when - pState0.lastButtonPressTime < MouseEvent.getClickTimeout() ) { - pState0.lastButtonClickCount++; + if( 0 >= pPressure[0] ) { + pPressure[0] = maxPressure; + } + pState1.buttonPressedMask |= InputEvent.getButtonMask(button); + if( 1 == pointerCount ) { + if( when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { + pState1.lastButtonClickCount++; + } else { + pState1.lastButtonClickCount=(short)1; + } + pState1.lastButtonPressTime = when; + pState1.buttonPressed = button; + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); } else { - pState0.lastButtonClickCount=(short)1; + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } - pState0.lastButtonPressTime = when; - pState0.buttonPressed = button; - pState0.buttonModMask |= MouseEvent.getButtonMask(button); - e = new MouseEvent(eventType, this, when, - modifiers, x, y, pState0.lastButtonClickCount, button, rotationXYZ, rotationScale); break; case MouseEvent.EVENT_MOUSE_RELEASED: - e = new MouseEvent(eventType, this, when, - modifiers, x, y, pState0.lastButtonClickCount, button, rotationXYZ, rotationScale); - if( when - pState0.lastButtonPressTime >= MouseEvent.getClickTimeout() ) { - pState0.lastButtonClickCount = (short)0; - pState0.lastButtonPressTime = 0; - } - pState0.buttonPressed = 0; - pState0.buttonModMask &= ~MouseEvent.getButtonMask(button); + if( 1 == pointerCount ) { + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); + if( when - pState1.lastButtonPressTime >= MouseEvent.getClickTimeout() ) { + pState1.lastButtonClickCount = (short)0; + pState1.lastButtonPressTime = 0; + } + pState1.buttonPressed = 0; + } else { + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); + } + pState1.buttonPressedMask &= ~InputEvent.getButtonMask(button); + if( null != movePositionP0 ) { + movePositionP0.set(0, 0); + } break; case MouseEvent.EVENT_MOUSE_MOVED: - if ( pState0.buttonPressed > 0 ) { - e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, - modifiers, x, y, (short)1, pState0.buttonPressed, rotationXYZ, rotationScale); + if ( 0 != pState1.buttonPressedMask ) { // any button or pointer move -> drag + e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, pState1.buttonPressed, (short)1, rotationXYZ, rotationScale); } else { - e = new MouseEvent(eventType, this, when, - modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } break; + case MouseEvent.EVENT_MOUSE_DRAGGED: + if( 0 >= pPressure[0] ) { + pPressure[0] = maxPressure; + } + // Fall through intended! default: - e = new MouseEvent(eventType, this, when, modifiers, x, y, (short)0, button, rotationXYZ, rotationScale); + e = new MouseEvent(eventType, this, when, modifiers, pointerType, pID, + pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); } doEvent(enqueue, wait, e); // actual mouse event } - - /** - * Send multiple-pointer event directly to be consumed - *

      - * The index for the element of multiple-pointer arrays represents the pointer which triggered the event - * is passed via actionIdx. - *

      - * - * @param eventType - * @param source - * @param when - * @param modifiers - * @param actionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pointerType PointerType for each pointer (multiple pointer) - * @param pointerID Pointer ID for each pointer (multiple pointer) - * @param x X-axis for each pointer (multiple pointer) - * @param y Y-axis for each pointer (multiple pointer) - * @param pressure Pressure for each pointer (multiple pointer) - * @param maxPressure Maximum pointer pressure for all pointer - * @param button Corresponding mouse-button - * @param clickCount Mouse-button click-count - * @param rotationXYZ Rotation of all axis - * @param rotationScale Rotation scale - */ - public void sendMouseEvent(short eventType, Object source, long when, int modifiers, - int actionIdx, PointerType pointerType[], short[] pointerID, - int[] x, int[] y, float[] pressure, float maxPressure, - short button, short clickCount, float[] rotationXYZ, float rotationScale) { - final MouseEvent pe = MouseEvent.create(eventType, source, when, modifiers, actionIdx, - pointerType, pointerID, x, y, pressure, maxPressure, button, clickCount, - rotationXYZ, rotationScale); - consumeMouseEvent(pe); - } @Override public final void addMouseListener(MouseListener l) { @@ -2619,25 +2724,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * - dispatch event to listener *
      */ - protected void consumeMouseEvent(MouseEvent pe) { - final int x = pe.getX(); - final int y = pe.getY(); + private final void consumePointerEvent(MouseEvent pe) { + int x = pe.getX(); + int y = pe.getY(); - if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent.drop: "+pe); - } - return; // .. invalid .. - } if(DEBUG_MOUSE_EVENT) { System.err.println("consumeMouseEvent.in: "+pe); } // - // - Remove redundant events // - Determine ENTERED/EXITED state - // - synthesize ENTERED event - // - fix MOVED/DRAGGED event + // - Synthesize ENTERED event // - Reset states if applicable // final long when = pe.getWhen(); @@ -2646,36 +2743,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer switch( eventType ) { case MouseEvent.EVENT_MOUSE_EXITED: case MouseEvent.EVENT_MOUSE_ENTERED: - pState1.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - // clear states - pState1.lastButtonPressTime = 0; - pState1.buttonPressed = 0; + // clip coordinates to window dimension + x = Math.min(Math.max(x, 0), getWidth()-1); + y = Math.min(Math.max(y, 0), getHeight()-1); + pState0.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; + pState0.clearButton(); eEntered = null; break; - case MouseEvent.EVENT_MOUSE_MOVED: - if ( pState1.buttonPressed > 0 ) { - pe = pe.createVariant(MouseEvent.EVENT_MOUSE_DRAGGED); - eventType = pe.getEventType(); - } - // Fall through intended ! - case MouseEvent.EVENT_MOUSE_DRAGGED: - if( pState1.insideWindow && pState1.lastMovePosition.getX() == x && pState1.lastMovePosition.getY() == y ) { - if(DEBUG_MOUSE_EVENT) { - System.err.println("consumeMouseEvent: skip EVENT_MOUSE_MOVED w/ same position: "+pState1.lastMovePosition); - } - return; // skip same position - } - pState1.lastMovePosition.setX(x); - pState1.lastMovePosition.setY(y); - // Fall through intended ! default: - if(!pState1.insideWindow) { - pState1.insideWindow = true; + if(!pState0.insideWindow) { + pState0.insideWindow = true; + pState0.clearButton(); eEntered = pe.createVariant(MouseEvent.EVENT_MOUSE_ENTERED); - // clear states - pState1.lastButtonPressTime = 0; - pState1.buttonPressed = 0; } else { eEntered = null; } @@ -2685,6 +2765,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer System.err.println("consumeMouseEvent.send.0: "+eEntered); } dispatchMouseEvent(eEntered); + } else if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumeMouseEvent.drop: "+pe); + } + return; // .. invalid .. } // @@ -2758,25 +2843,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // - // Synthesize mouse click - // + // - Synthesize mouse CLICKED + // - Ignore sent CLICKED + // final MouseEvent eClicked; switch( eventType ) { case MouseEvent.EVENT_MOUSE_PRESSED: if( 1 == pe.getPointerCount() ) { - pState1.lastButtonPressTime = when; + pState0.lastButtonPressTime = when; } - pState1.buttonPressed = pe.getButton(); eClicked = null; break; case MouseEvent.EVENT_MOUSE_RELEASED: - if( 1 == pe.getPointerCount() && when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { + if( 1 == pe.getPointerCount() && when - pState0.lastButtonPressTime < MouseEvent.getClickTimeout() ) { eClicked = pe.createVariant(MouseEvent.EVENT_MOUSE_CLICKED); } else { eClicked = null; - pState1.lastButtonPressTime = 0; + pState0.lastButtonPressTime = 0; } - pState1.buttonPressed = 0; break; case MouseEvent.EVENT_MOUSE_CLICKED: // ignore - synthesized here .. @@ -2874,12 +2958,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer public void sendKeyEvent(short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState0.buttonModMask, keyCode, keySym, keyChar) ); + consumeKeyEvent( KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState1.buttonPressedMask, keyCode, keySym, keyChar) ); } public void enqueueKeyEvent(boolean wait, short eventType, int modifiers, short keyCode, short keySym, char keyChar) { // Always add currently pressed mouse buttons to modifier mask - enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState0.buttonModMask, keyCode, keySym, keyChar) ); + enqueueEvent(wait, KeyEvent.create(eventType, this, System.currentTimeMillis(), modifiers | pState1.buttonPressedMask, keyCode, keySym, keyChar) ); } @Override @@ -2980,7 +3064,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return e.isConsumed(); } - protected void consumeKeyEvent(KeyEvent e) { + private final void consumeKeyEvent(KeyEvent e) { boolean consumedE = false; if( null != keyboardFocusHandler && !e.isAutoRepeat() ) { consumedE = propagateKeyEvent(e, keyboardFocusHandler); @@ -3059,7 +3143,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer return windowListeners.toArray(new WindowListener[windowListeners.size()]); } - protected void consumeWindowEvent(WindowEvent e) { + private final void consumeWindowEvent(WindowEvent e) { if(DEBUG_IMPLEMENTATION) { System.err.println("consumeWindowEvent: "+e+", visible "+isVisible()+" "+getX()+"/"+getY()+" "+getWidth()+"x"+getHeight()); } @@ -3266,10 +3350,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if ( (left != insets.getLeftWidth() || right != insets.getRightWidth() || top != insets.getTopHeight() || bottom != insets.getBottomHeight() ) ) { - insets.setLeftWidth(left); - insets.setRightWidth(right); - insets.setTopHeight(top); - insets.setBottomHeight(bottom); + insets.set(left, right, top, bottom); if(DEBUG_IMPLEMENTATION) { System.err.println("Window.insetsChanged: (defer: "+defer+") "+insets); } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java index 0e76db374..23c32993f 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventFactory.java @@ -252,22 +252,22 @@ public class AndroidNewtEventFactory { } } - private static void collectPointerData(MotionEvent e, int eIdx, int dIdx, final int[] x, final int[] y, final float[] pressure, short[] pointerIds, final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes) { - x[dIdx] = (int)e.getX(eIdx); - y[dIdx] = (int)e.getY(eIdx); - pressure[dIdx] = e.getPressure(eIdx); - pointerIds[dIdx] = (short)e.getPointerId(eIdx); - if( pressure[dIdx] > maxPressure ) { - maxPressure = pressure[dIdx]; + private static void collectPointerData(MotionEvent e, int idx, final int[] x, final int[] y, final float[] pressure, short[] pointerIds, final int[] pointerTypes) { + x[idx] = (int)e.getX(idx); + y[idx] = (int)e.getY(idx); + pressure[idx] = e.getPressure(idx); + pointerIds[idx] = (short)e.getPointerId(idx); + if( pressure[idx] > maxPressure ) { + maxPressure = pressure[idx]; } - pointerTypes[dIdx] = aToolType2PointerType( e.getToolType(eIdx) ); + pointerTypes[idx] = aToolType2PointerType( e.getToolType(idx) ).ordinal(); if(DEBUG_MOUSE_EVENT) { - System.err.println("createMouseEvent: ptr-data["+eIdx+" -> "+dIdx+"] "+x[dIdx]+"/"+y[dIdx]+", pressure "+pressure[dIdx]+", id "+pointerIds[dIdx]+", type "+pointerTypes[dIdx]); + System.err.println("createMouseEvent: ptr-data["+idx+"] "+x[idx]+"/"+y[idx]+", pressure "+pressure[idx]+", id "+pointerIds[idx]+", type "+pointerTypes[idx]); } } - public com.jogamp.newt.event.MouseEvent createMouseEvents(boolean isOnTouchEvent, - android.view.MotionEvent event, com.jogamp.newt.Window newtSource) { + public boolean sendPointerEvent(boolean enqueue, boolean wait, boolean setFocusOnDown, boolean isOnTouchEvent, + android.view.MotionEvent event, jogamp.newt.driver.android.WindowDriver newtSource) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: isOnTouchEvent "+isOnTouchEvent+", "+event); } @@ -285,7 +285,6 @@ public class AndroidNewtEventFactory { final float[] rotationXYZ = new float[] { 0f, 0f, 0f }; if( (short)0 != nType ) { - final short clickCount = 1; int modifiers = 0; // @@ -298,7 +297,7 @@ public class AndroidNewtEventFactory { case android.view.MotionEvent.ACTION_POINTER_UP: { pIndex = event.getActionIndex(); final int b = event.getPointerId(pIndex) + 1; // FIXME: Assumption that Pointer-ID starts w/ 0 ! - if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_NUMBER ) { + if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { button = (short)b; } else { button = com.jogamp.newt.event.MouseEvent.BUTTON1; @@ -328,6 +327,15 @@ public class AndroidNewtEventFactory { } final int pCount = event.getPointerCount(); // all + switch( aType ) { + case android.view.MotionEvent.ACTION_DOWN: + case android.view.MotionEvent.ACTION_POINTER_DOWN: + modifiers |= InputEvent.getButtonMask(button); + if( setFocusOnDown ) { + newtSource.focusChanged(false, true); + } + } + // // Collect common data // @@ -335,38 +343,20 @@ public class AndroidNewtEventFactory { final int[] y = new int[pCount]; final float[] pressure = new float[pCount]; final short[] pointerIds = new short[pCount]; - final com.jogamp.newt.event.MouseEvent.PointerType[] pointerTypes = new com.jogamp.newt.event.MouseEvent.PointerType[pCount]; + final int[] pointerTypes = new int[pCount]; if( 0 < pCount ) { if(DEBUG_MOUSE_EVENT) { System.err.println("createMouseEvent: collect ptr-data [0.."+(pCount-1)+", count "+pCount+", action "+pIndex+"], aType "+aType+", button "+button); } - int j = 0; - // Always put action-pointer data at index 0 - collectPointerData(event, pIndex, j++, x, y, pressure, pointerIds, pointerTypes); for(int i=0; i < pCount; i++) { - if( pIndex != i ) { - collectPointerData(event, i, j++, x, y, pressure, pointerIds, pointerTypes); - } + collectPointerData(event, i, x, y, pressure, pointerIds, pointerTypes); } } - - if(null!=newtSource) { - if(newtSource.isPointerConfined()) { - modifiers |= InputEvent.CONFINED_MASK; - } - if(!newtSource.isPointerVisible()) { - modifiers |= InputEvent.INVISIBLE_MASK; - } - } - - final Object src = (null==newtSource)?null:(Object)newtSource; - final long unixTime = System.currentTimeMillis() + ( event.getEventTime() - android.os.SystemClock.uptimeMillis() ); - - return new com.jogamp.newt.event.MouseEvent(nType, src, unixTime, - modifiers, pointerTypes, pointerIds, x, y, pressure, maxPressure, - button, clickCount, rotationXYZ, rotationScale); + newtSource.doPointerEvent(enqueue, wait, pointerTypes, nType, modifiers, + pIndex, pointerIds, x, y, pressure, maxPressure, rotationXYZ, rotationScale); + return true; } - return null; // no mapping .. + return false; // no mapping .. } } diff --git a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java index df52208df..5a4743f73 100644 --- a/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java +++ b/src/newt/classes/jogamp/newt/driver/android/event/AndroidNewtEventTranslator.java @@ -13,16 +13,10 @@ public class AndroidNewtEventTranslator implements View.OnKeyListener, View.OnTo } private final boolean processTouchMotionEvents(View v, android.view.MotionEvent event, boolean isOnTouchEvent) { - final com.jogamp.newt.event.MouseEvent newtEvent = factory.createMouseEvents(isOnTouchEvent, event, newtWindow); - if(null != newtEvent) { - switch( event.getActionMasked() ) { - case android.view.MotionEvent.ACTION_DOWN: - case android.view.MotionEvent.ACTION_POINTER_DOWN: - newtWindow.focusChanged(false, true); - break; - } - newtWindow.enqueueEvent(false, newtEvent); - try { Thread.sleep((long) (100.0F/3.0F)); } // 33 ms + final boolean eventSent = factory.sendPointerEvent(true /*enqueue*/, false /*wait*/, true /*setFocusOnDown*/, + isOnTouchEvent, event, newtWindow); + if( eventSent ) { + try { Thread.sleep((long) (100.0F/3.0F)); } // 33 ms - FIXME ?? catch(InterruptedException e) { } return true; // consumed/handled, further interest in events } -- cgit v1.2.3 From 3c56d9346b9077b5eb65ec9e111917cfe17e9173 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 17 Oct 2013 23:02:04 +0200 Subject: Bug 800: Windows 7 Touch Event Support for NEWT: Fix Focus and LBUTTON[DOWN|UP] issues - w/ TOUCH, Win8 may steal focus (KILLFOCUS), quickly grab FOCUS again when on TOUCH operation - track 'touchDownLastUp', and don't act on LBUTTON[UP|DOWN] and MOUSEMOVE if just lifted last finger - don't use GetMessageExtraInfo() to distinguish MOUSE/TOUCH, simply use tracked touchDownCount - Also track mouseInside in TOUCH operation, i.e. true if _all_ fingers are inside, otherwise don't send TOUCH event --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- src/newt/native/WindowsWindow.c | 125 ++++++++++++++++++++++++---------------- 3 files changed, 78 insertions(+), 55 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 099768f7c..9f7d7953e 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -65,13 +65,13 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 129b0deab..84f487c38 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -299,9 +299,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index ec7f5dbab..a19efbc7a 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -170,6 +170,7 @@ typedef struct { int setPointerVisible; int mouseInside; int touchDownCount; + int touchDownLastUp; // mitigate LBUTTONUP after last TOUCH lift int supportsMTouch; } WindowUserData; @@ -966,11 +967,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_LBUTTONDOWN: { - BOOL isMouse = 0 == GetMessageExtraInfo(); - DBG_PRINT("*** WindowsWindow: WM_LBUTTONDOWN %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + DBG_PRINT("*** WindowsWindow: WM_LBUTTONDOWN %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); - if( isMouse ) { + wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + if( 0 == wud->touchDownLastUp && 0 == wud->touchDownCount ) { wud->mouseInside = 1; (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, @@ -984,11 +984,13 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_LBUTTONUP: { - BOOL isMouse = 0 == GetMessageExtraInfo(); - DBG_PRINT("*** WindowsWindow: WM_LBUTTONUP %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + DBG_PRINT("*** WindowsWindow: WM_LBUTTONUP %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); - if( isMouse ) { + wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + if( 0 < wud->touchDownLastUp ) { + // mitigate LBUTTONUP after last TOUCH lift + wud->touchDownLastUp = 0; + } else if( 0 == wud->touchDownCount ) { wud->mouseInside = 1; (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, @@ -1001,11 +1003,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MBUTTONDOWN: { - BOOL isMouse = 0 == GetMessageExtraInfo(); - DBG_PRINT("*** WindowsWindow: WM_MBUTTONDOWN %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + DBG_PRINT("*** WindowsWindow: WM_MBUTTONDOWN %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); - if( isMouse ) { + wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + if( 0 == wud->touchDownCount ) { wud->mouseInside = 1; (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, @@ -1019,11 +1020,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MBUTTONUP: { - BOOL isMouse = 0 == GetMessageExtraInfo(); - DBG_PRINT("*** WindowsWindow: WM_MBUTTONUP %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + DBG_PRINT("*** WindowsWindow: WM_MBUTTONUP %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); - if( isMouse ) { + wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + if( 0 == wud->touchDownCount ) { wud->mouseInside = 1; (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, @@ -1036,11 +1036,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_RBUTTONDOWN: { - BOOL isMouse = 0 == GetMessageExtraInfo(); - DBG_PRINT("*** WindowsWindow: WM_RBUTTONDOWN: %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + DBG_PRINT("*** WindowsWindow: WM_RBUTTONDOWN %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); - if( isMouse ) { + wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + if( 0 == wud->touchDownCount ) { wud->mouseInside = 1; (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, @@ -1054,11 +1053,10 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_RBUTTONUP: { - BOOL isMouse = 0 == GetMessageExtraInfo(); - DBG_PRINT("*** WindowsWindow: WM_RBUTTONUP %d/%d [%dx%d] inside %d, isMouse %d, tDown %d\n", + DBG_PRINT("*** WindowsWindow: WM_RBUTTONUP %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, isMouse, wud->touchDownCount); - if( isMouse ) { + wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + if( 0 == wud->touchDownCount ) { wud->mouseInside = 1; (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, @@ -1071,11 +1069,11 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MOUSEMOVE: { - wud->mouseInside = 1; - DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d [%dx%d] inside %d, tDown %d\n", + DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount); - if( wud->touchDownCount == 0 ) { + wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + if( 0 == wud->touchDownLastUp && 0 == wud->touchDownCount ) { + wud->mouseInside = 1; NewtWindows_trackPointerLeave(wnd); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, @@ -1087,16 +1085,18 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP } break; case WM_MOUSELEAVE: { - wud->mouseInside = 0; - DBG_PRINT("*** WindowsWindow: WM_MOUSELEAVE %d/%d [%dx%d] inside %d, tDown %d\n", + DBG_PRINT("*** WindowsWindow: WM_MOUSELEAVE %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount); - (*env)->CallVoidMethod(env, window, sendMouseEventID, - (jshort) EVENT_MOUSE_EXITED, - 0, - (jint) -1, (jint) -1, // fake - (jshort) 0, (jfloat) 0.0f); - useDefWindowProc = 1; + wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + if( 0 == wud->touchDownCount ) { + wud->mouseInside = 0; + (*env)->CallVoidMethod(env, window, sendMouseEventID, + (jshort) EVENT_MOUSE_EXITED, + 0, + (jint) -1, (jint) -1, // fake + (jshort) 0, (jfloat) 0.0f); + useDefWindowProc = 1; + } } break; // Java synthesizes EVENT_MOUSE_ENTERED @@ -1173,10 +1173,11 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP jint x[cInputs], y[cInputs]; jfloat pressure[cInputs]; jfloat maxPressure = 1.0F; // FIXME: n/a on windows ? + int allPInside = 0 < cInputs; + int sendFocus = 0; for (i=0; i < cInputs; i++) { PTOUCHINPUT pTi = & pInputs[i]; - int inside; POINT eventPt; int isDown = pTi->dwFlags & TOUCHEVENTF_DOWN; int isUp = pTi->dwFlags & TOUCHEVENTF_UP; @@ -1184,6 +1185,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP int isPrim = pTi->dwFlags & TOUCHEVENTF_PRIMARY; int isNoCoalesc = pTi->dwFlags & TOUCHEVENTF_NOCOALESCE; + int isPInside; #ifdef VERBOSE_ON const char * touchAction; @@ -1202,31 +1204,46 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP eventPt.x = TOUCH_COORD_TO_PIXEL(pTi->x); eventPt.y = TOUCH_COORD_TO_PIXEL(pTi->y); ScreenToClient(wnd, &eventPt); + + isPInside = 0 <= eventPt.x && 0 <= eventPt.y && eventPt.x < wud->width && eventPt.y < wud->height; + allPInside &= isPInside; + x[i] = (jint)eventPt.x; y[i] = (jint)eventPt.y; pressure[i] = 1.0F; // FIXME: n/a on windows ? if(isDown) { + sendFocus = 0 == wud->touchDownCount; eventType[i] = (jshort) EVENT_MOUSE_PRESSED; + wud->touchDownCount++; + wud->touchDownLastUp = 0; } else if(isUp) { eventType[i] = (jshort) EVENT_MOUSE_RELEASED; + wud->touchDownCount--; + // mitigate LBUTTONUP after last TOUCH lift + wud->touchDownLastUp = 0 == wud->touchDownCount; } else if(isMove) { eventType[i] = (jshort) EVENT_MOUSE_MOVED; + wud->touchDownLastUp = 0; } else { eventType[i] = (jshort) 0; } if(isPrim) { actionIdx = (jint)i; } - inside = 0 <= x[i] && 0 <= y[i] && x[i] < wud->width && y[i] < wud->height; #ifdef VERBOSE_ON - DBG_PRINT("*** WindowsWindow: WM_TOUCH[%d/%d].%s name 0x%x, prim %d, nocoalsc %d, %d/%d [%dx%d] inside %d/%d, tDown %d\n", - (i+1), cInputs, touchAction, (int)(pTi->dwID), isPrim, isNoCoalesc, x[i], y[i], wud->width, wud->height, inside, wud->mouseInside, wud->touchDownCount); + DBG_PRINT("*** WindowsWindow: WM_TOUCH[%d/%d].%s name 0x%x, prim %d, nocoalsc %d, %d/%d [%dx%d] inside [%d/%d], tDown [c %d, lastUp %d]\n", + (i+1), cInputs, touchAction, (int)(pTi->dwID), isPrim, isNoCoalesc, x[i], y[i], wud->width, wud->height, + isPInside, allPInside, wud->touchDownCount, wud->touchDownLastUp); #endif } + wud->mouseInside = allPInside; + if( sendFocus && allPInside ) { + (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); + } int sentCount = 0, updownCount=0, moveCount=0; // Primary first, if available! - if( 0 <= actionIdx ) { + if( 0 <= actionIdx && allPInside ) { sendTouchScreenEvent(env, window, eventType[actionIdx], modifiers, actionIdx, cInputs, pointerNames, x, y, pressure, maxPressure); sentCount++; @@ -1235,7 +1252,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP for (i=0; i < cInputs; i++) { short et = eventType[i]; if( (jshort) EVENT_MOUSE_MOVED == et ) { - if( i != actionIdx && 0 == moveCount ) { + if( i != actionIdx && 0 == moveCount && allPInside ) { sendTouchScreenEvent(env, window, et, modifiers, i, cInputs, pointerNames, x, y, pressure, maxPressure); sentCount++; @@ -1247,7 +1264,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP for (i=0; i < cInputs; i++) { short et = eventType[i]; if( (jshort) EVENT_MOUSE_MOVED != et ) { - if( i != actionIdx ) { + if( i != actionIdx && allPInside ) { sendTouchScreenEvent(env, window, et, modifiers, i, cInputs, pointerNames, x, y, pressure, maxPressure); sentCount++; @@ -1255,8 +1272,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP updownCount++; } } - DBG_PRINT("*** WindowsWindow: WM_TOUCH.summary pCount %d, prim %d, updown %d, move %d, sent %d\n", - cInputs, actionIdx, updownCount, moveCount, sentCount); + DBG_PRINT("*** WindowsWindow: WM_TOUCH.summary pCount %d, prim %d, updown %d, move %d, sent %d, inside %d, tDown [c %d, lastUp %d]\n", + cInputs, actionIdx, updownCount, moveCount, sentCount, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); // Message processed - close it CloseTouchInputHandle(hTouch); @@ -1275,11 +1292,16 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_KILLFOCUS: - DBG_PRINT("*** WindowsWindow: WM_KILLFOCUS window %p, received %p\n", wnd, (HWND)wParam); - wud->touchDownCount=0; - wud->mouseInside=0; - (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE, JNI_FALSE); - useDefWindowProc = 1; + DBG_PRINT("*** WindowsWindow: WM_KILLFOCUS window %p, received %p, inside %d, tDown %d\n", + wnd, (HWND)wParam, wud->mouseInside, wud->touchDownCount); + if( wud->touchDownCount == 0 ) { + wud->mouseInside=0; + (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE, JNI_FALSE); + useDefWindowProc = 1; + } else { + // quick focus .. we had it already, are enabled .. + SetFocus(wnd);// Sets Keyboard Focus To Window (activates parent window if exist, or this window) + } break; case WM_SHOWWINDOW: @@ -1909,6 +1931,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo wud->setPointerVisible = 0; wud->mouseInside = 0; wud->touchDownCount = 0; + wud->touchDownLastUp = 0; wud->supportsMTouch = 0; if ( winMajor > 6 || ( winMajor == 6 && winMinor >= 1 ) ) { int value = GetSystemMetrics(SM_DIGITIZER); -- cgit v1.2.3 From 77b0adbdb6e361e4d5d6ca31432e8fc625d02b24 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 18 Oct 2013 01:21:46 +0200 Subject: AWTPrintLifecycle.setupPrint(..): Fix regression of commit a05b87a369441d9ef38f97929f866b3d4ced0e57: NULL printGLAD of GLCanvas and NewtCanvasAWT We have to pre-init printGLAD w/ current GLAD (similiar w/ GLJPanel). Also properly define reqNewGLAD: reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); where '!caps.getSampleBuffers() && ( .. )' is due to Bug 830, swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX does not work. --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/javax/media/opengl/awt/GLCanvas.java | 13 +++++++------ src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 14 ++++++++------ 3 files changed, 17 insertions(+), 14 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 84f487c38..1884c7c1b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -299,7 +299,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* @@ -335,7 +335,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index b9576b8d6..6828beb10 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -757,24 +757,25 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing if( null != printAnimator ) { printAnimator.remove(GLCanvas.this); } + printGLAD = GLCanvas.this; // _not_ default, shall be replaced by offscreen GLAD final GLCapabilities caps = (GLCapabilities)getChosenGLCapabilities().cloneMutable(); final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); - final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ; + final boolean reqNewGLADOnscrn = caps.isOnscreen(); + // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. + // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); if( DEBUG ) { - System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } - if( caps.getSampleBuffers() ) { - // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX - printGLAD = GLCanvas.this; - } else { + if( reqNewGLAD ) { caps.setDoubleBuffered(false); caps.setOnscreen(false); if( printNumSamples != caps.getNumSamples() ) { diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 767533d40..13affdf49 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -519,24 +519,26 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if( null != printAnimator ) { printAnimator.remove(glad); } + printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); final int printNumSamples = printAWTTiles.getNumSamples(caps); GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); - final boolean reqNewGLAD = !caps.getSampleBuffers(); // reqNewGLADSamples || reqNewGLADSize ; + final boolean reqNewGLADOnscrn = caps.isOnscreen(); + + // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. + // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); if( DEBUG ) { - System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } - if( caps.getSampleBuffers() ) { - // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX - printGLAD = glad; - } else { + if( reqNewGLAD ) { caps.setDoubleBuffered(false); caps.setOnscreen(false); if( printNumSamples != caps.getNumSamples() ) { -- cgit v1.2.3 From 2ebf1bf35928e35ded6e38df64dee7aa578ae3c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 18 Oct 2013 02:27:33 +0200 Subject: MouseEvent: Clarify button-number and pointer-ID relation incl. case 'no button/pointer', i.e. button == 0, pointer-ID == -1 doPointerEvent: - allow id==-1 -> button==0 for no button, i.e. mouse move doMouseEvent: - keep button 0 value, i.e. map to pointer-ID -1 --- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 83 ++++++++++++++++++---- src/newt/classes/jogamp/newt/WindowImpl.java | 14 ++-- 3 files changed, 78 insertions(+), 23 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 1884c7c1b..99c19c9ad 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -335,7 +335,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # @@ -523,7 +523,7 @@ testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 85c65b39c..57dd7e68c 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -49,9 +49,21 @@ package com.jogamp.newt.event; * For example {@link #getX(int) e.getX(0)} at {@link #EVENT_MOUSE_PRESSED} returns the data of the pressed pointer, etc. *

      *

      - * If representing a multiple-pointer event, the {@link #getButton() button number} is equal to the first {@link #getPointerId(int) pointer ID} + * A {@link #getButton() button value} of 0 denotes no button activity, i.e. {@link PointerType#Mouse} move. + *

      + *

      + * A {@link #getPointerId(int) pointer-ID} of -1 denotes no pointer/button activity, i.e. {@link PointerType#Mouse} move. + *

      + *

      + * {@link #getButton() Button values} are mapped from and to {@link #getPointerId(int) pointer-IDs} as follows: + * + * getPointerId(0) == getButton() - 1 + * . + *

      + *

      + * If representing a multiple-pointer event, the {@link #getButton() button number} is mapped to the first {@link #getPointerId(int) pointer ID} * triggering the event and the {@link InputEvent#BUTTON1_MASK button mask bits} in the {@link #getModifiers() modifiers} - * field represents the pressed pointer IDs.
      + * field represent the pressed pointer IDs.
      * Hence users can query the pressed button count as well as the pressed pointer count via {@link InputEvent#getButtonDownCount()} * or use the simple query {@link InputEvent#isAnyButtonDown()}. *

      @@ -162,7 +174,21 @@ public class MouseEvent extends InputEvent return 300; } - /** Constructor for traditional one-pointer event. */ + /** + * Constructor for traditional one-pointer event. + * + * @param eventType + * @param source + * @param when + * @param modifiers + * @param x X-axis + * @param y Y-axis + * @param clickCount Mouse-button click-count + * @param button button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1]. + * A button value of 0 denotes no button activity, i.e. {@link PointerType#Mouse} move. + * @param rotationXYZ Rotation of all axis + * @param rotationScale Rotation scale + */ public MouseEvent(short eventType, Object source, long when, int modifiers, int x, int y, short clickCount, short button, float[] rotationXYZ, float rotationScale) @@ -203,6 +229,7 @@ public class MouseEvent extends InputEvent * @param modifiers * @param pointerType PointerType for each pointer (multiple pointer) * @param pointerID Pointer ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. + * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. * @param x X-axis for each pointer (multiple pointer) * @param y Y-axis for each pointer (multiple pointer) * @param pressure Pressure for each pointer (multiple pointer) @@ -246,6 +273,7 @@ public class MouseEvent extends InputEvent } /** + * See details for multiple-pointer events. * @return the count of pointers involved in this event */ public final int getPointerCount() { @@ -253,8 +281,8 @@ public class MouseEvent extends InputEvent } /** - * @return the {@link PointerType} for the data at index. - * return null if index not available. + * See details for multiple-pointer events. + * @return the {@link PointerType} for the data at index or null if index not available. */ public final PointerType getPointerType(int index) { if(0 > index || index >= pointerType.length) { @@ -264,6 +292,7 @@ public class MouseEvent extends InputEvent } /** + * See details for multiple-pointer events. * @return array of all {@link PointerType}s for all pointers */ public final PointerType[] getAllPointerTypes() { @@ -271,8 +300,16 @@ public class MouseEvent extends InputEvent } /** - * @return the pointer id for the given index. - * return -1 if index not available. IDs start w/ 0 and are consecutive numbers. + * Return the pointer id for the given index or -1 if index not available. + *

      + * IDs start w/ 0 and are consecutive numbers. + *

      + *

      + * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. + *

      + *

      + * See details for multiple-pointer events. + *

      */ public final short getPointerId(int index) { if(0 > index || index >= pointerID.length) { @@ -282,19 +319,22 @@ public class MouseEvent extends InputEvent } /** - * @return the pointer index for the given pointer id. - * return -1 if id not available. + * See details for multiple-pointer events. + * @return the pointer index for the given pointer id or -1 if id not available. */ public final int getPointerIdx(short id) { - for(int i=pointerID.length-1; i>=0; i--) { - if( pointerID[i] == id ) { - return i; + if( id >= 0 ) { + for(int i=pointerID.length-1; i>=0; i--) { + if( pointerID[i] == id ) { + return i; + } } } return -1; } /** + * See details for multiple-pointer events. * @return array of all pointer IDs for all pointers. IDs start w/ 0 and are consecutive numbers. */ public final short[] getAllPointerIDs() { @@ -304,6 +344,9 @@ public class MouseEvent extends InputEvent /** * Returns the button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1]. *

      + * A button value of 0 denotes no button activity, i.e. {@link PointerType#Mouse} move. + *

      + *

      * See details for multiple-pointer events. *

      */ @@ -511,7 +554,12 @@ public class MouseEvent extends InputEvent /** PointerType for each pointer (multiple pointer) */ private final PointerType pointerType[]; - /** Pointer-ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. */ + /** + * Pointer-ID for each pointer (multiple pointer). IDs start w/ 0 and are consecutive numbers. + *

      + * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. + *

      + */ private final short pointerID[]; /** X-axis for each pointer (multiple pointer) */ private final int x[]; @@ -520,7 +568,14 @@ public class MouseEvent extends InputEvent /** Pressure for each pointer (multiple pointer) */ private final float pressure[]; // private final short tiltX[], tiltY[]; // TODO: A generic way for pointer axis information, see Android MotionEvent! - private final short clickCount, button; + private final short clickCount; + /** + * Returns the button number, e.g. [{@link #BUTTON1}..{@link #BUTTON_COUNT}-1]. + *

      + * A button value of 0 denotes no button activity, i.e. {@link PointerType#Mouse} move. + *

      + */ + private final short button; /** Rotation around the X, Y and X axis */ private final float[] rotationXYZ; /** Rotation scale */ diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 3f59da553..a35d89408 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2381,8 +2381,6 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int x, int y, short button, final float[] rotationXYZ, float rotationScale) { if( 0 > button || button > MouseEvent.BUTTON_COUNT ) { throw new NativeWindowException("Invalid mouse button number" + button); - } else if( 0 == button ) { - button = 1; } doPointerEvent(enqueue, wait, constMousePointerTypes, eventType, modifiers, 0 /*actionIdx*/, new short[] { (short)(button-1) }, @@ -2467,7 +2465,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param eventType * @param modifiers * @param pActionIdx index of multiple-pointer arrays representing the pointer which triggered the event - * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. + * @param pID Pointer ID for each pointer (multiple pointer). We assume consecutive pointerIDs starting w/ 0. + * A pointer-ID of -1 may also denote no pointer/button activity, i.e. {@link PointerType#Mouse} move. * @param pX X-axis for each pointer (multiple pointer) * @param pY Y-axis for each pointer (multiple pointer) * @param pPressure Pressure for each pointer (multiple pointer) @@ -2513,7 +2512,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final short button; { final int b = id + 1; - if( com.jogamp.newt.event.MouseEvent.BUTTON1 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { + if( 0 <= b && b <= com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { // we allow id==-1 -> button==0 for no button, i.e. mouse move button = (short)b; } else { button = com.jogamp.newt.event.MouseEvent.BUTTON1; @@ -2580,7 +2579,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); } - modifiers |= InputEvent.getButtonMask(button); // Always add current button to modifier mask (Bug 571) + final int buttonMask = InputEvent.getButtonMask(button); + modifiers |= buttonMask; // Always add current button to modifier mask (Bug 571) modifiers |= pState1.buttonPressedMask; // Always add currently pressed mouse buttons to modifier mask if( isPointerConfined() ) { @@ -2609,7 +2609,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 >= pPressure[0] ) { pPressure[0] = maxPressure; } - pState1.buttonPressedMask |= InputEvent.getButtonMask(button); + pState1.buttonPressedMask |= buttonMask; if( 1 == pCount ) { if( when - pState1.lastButtonPressTime < MouseEvent.getClickTimeout() ) { pState1.lastButtonClickCount++; @@ -2638,7 +2638,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); } - pState1.buttonPressedMask &= ~InputEvent.getButtonMask(button); + pState1.buttonPressedMask &= ~buttonMask; if( null != movePositionP0 ) { movePositionP0.set(0, 0); } -- cgit v1.2.3 From 47d73819a71b7d9c4d2182a4de5712435832c5a1 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 18 Oct 2013 07:36:38 +0200 Subject: Bump 7u45 --- make/scripts/make.jogl.all.win32.bat | 4 ++-- make/scripts/make.jogl.all.win64.bat | 4 ++-- make/scripts/tests-javaws-x64.bat | 2 +- make/scripts/tests-win.bat | 2 +- make/scripts/tests-x32-dbg.bat | 4 ++-- make/scripts/tests-x32.bat | 4 ++-- make/scripts/tests-x64-dbg.bat | 7 ++++--- make/scripts/tests-x64.bat | 7 ++++--- make/scripts/tests.sh | 6 +++--- 9 files changed, 21 insertions(+), 19 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.win32.bat b/make/scripts/make.jogl.all.win32.bat index 041d8c71f..3e84d01af 100755 --- a/make/scripts/make.jogl.all.win32.bat +++ b/make/scripts/make.jogl.all.win32.bat @@ -1,7 +1,7 @@ set THISDIR="C:\JOGL" -set J2RE_HOME=c:\jre1.7.0_40_x32 -set JAVA_HOME=c:\jdk1.7.0_40_x32 +set J2RE_HOME=c:\jre1.7.0_45_x32 +set JAVA_HOME=c:\jdk1.7.0_45_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% diff --git a/make/scripts/make.jogl.all.win64.bat b/make/scripts/make.jogl.all.win64.bat index d263f0c17..5e36c267a 100755 --- a/make/scripts/make.jogl.all.win64.bat +++ b/make/scripts/make.jogl.all.win64.bat @@ -1,7 +1,7 @@ set THISDIR="C:\JOGL" -set J2RE_HOME=c:\jre1.7.0_40_x64 -set JAVA_HOME=c:\jdk1.7.0_40_x64 +set J2RE_HOME=c:\jre1.7.0_45_x64 +set JAVA_HOME=c:\jdk1.7.0_45_x64 set ANT_PATH=C:\apache-ant-1.8.2 set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%PATH% diff --git a/make/scripts/tests-javaws-x64.bat b/make/scripts/tests-javaws-x64.bat index 87cf52990..6186bc501 100755 --- a/make/scripts/tests-javaws-x64.bat +++ b/make/scripts/tests-javaws-x64.bat @@ -1,4 +1,4 @@ -set JRE_PATH=C:\jre1.7.0_40_x64\bin +set JRE_PATH=C:\jre1.7.0_45_x64\bin set LOG_PATH=%USERPROFILE%\AppData\LocalLow\Sun\Java\Deployment\log %JRE_PATH%\javaws -uninstall diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 9f7d7953e..c1da671b1 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -71,7 +71,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* diff --git a/make/scripts/tests-x32-dbg.bat b/make/scripts/tests-x32-dbg.bat index 261f621a2..93069c019 100755 --- a/make/scripts/tests-x32-dbg.bat +++ b/make/scripts/tests-x32-dbg.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win32 -set J2RE_HOME=c:\jre1.7.0_40_x32 -set JAVA_HOME=c:\jdk1.7.0_40_x32 +set J2RE_HOME=c:\jre1.7.0_45_x32 +set JAVA_HOME=c:\jdk1.7.0_45_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl diff --git a/make/scripts/tests-x32.bat b/make/scripts/tests-x32.bat index 1f932a85b..c8ead0ad5 100755 --- a/make/scripts/tests-x32.bat +++ b/make/scripts/tests-x32.bat @@ -1,7 +1,7 @@ set BLD_SUB=build-win32 -set J2RE_HOME=c:\jre1.7.0_40_x32 -set JAVA_HOME=c:\jdk1.7.0_40_x32 +set J2RE_HOME=c:\jre1.7.0_45_x32 +set JAVA_HOME=c:\jdk1.7.0_45_x32 set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index bab911e37..f7ee7b995 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -1,14 +1,15 @@ set BLD_SUB=build-win64 -set J2RE_HOME=c:\jre1.7.0_40_x64 -set JAVA_HOME=c:\jdk1.7.0_40_x64 +set J2RE_HOME=c:\jre1.7.0_45_x64 +set JAVA_HOME=c:\jdk1.7.0_45_x64 set ANT_PATH=C:\apache-ant-1.8.2 set PROJECT_ROOT=D:\projects\jogamp\jogl set BLD_DIR=..\%BLD_SUB% REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x64 -set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x64 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x64 +set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg-2013-10-09\x64 REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01-libav\x64 REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw\bin;%PATH% diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 6e132e5d7..ac74f4c94 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -1,11 +1,12 @@ set BLD_SUB=build-win64 -set J2RE_HOME=c:\jre1.7.0_40_x64 -set JAVA_HOME=c:\jdk1.7.0_40_x64 +set J2RE_HOME=c:\jre1.7.0_45_x64 +set JAVA_HOME=c:\jdk1.7.0_45_x64 set ANT_PATH=C:\apache-ant-1.8.2 REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x64 -set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x64 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x64 +set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg-2013-10-09\x64 REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01-libav\x64 REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_64;%PATH% diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 99c19c9ad..9ada56c45 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -187,7 +187,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - D_ARGS="-Dnewt.debug.Window.MouseEvent" + #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -323,7 +323,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # tile rendring / printing w/ & w/o AWT @@ -523,7 +523,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* -- cgit v1.2.3 From 34b35c5a0a379a6b4c0b23b9d347a0b1338f0239 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 19 Oct 2013 02:49:15 +0200 Subject: Fix Bug 862: Fix GL Version Validation / NVidia GTX550 driver 331.13 - 64bit Linux - No compatibility GLProfile (GL2, >= GL3bc) Fix GL Version Validation: We shall not rely on our known good versions when validating a queried GL context version, but allow some 'room' for a higher version post JOGL release while still cutting off 'odd versions'. While GL version detection, we always iterate from the highest known version down to the lowest. Hence 'GLContext.isValidGLVersion(..)' is satisfied by validating the lowest version number but allowing a higher than known one. Now we would return 'invalid' for a version >= 6. It is enough to clip to the maximum known version when iterating, allowing the highest unknown version to be available. GLContext.isValidGLVersion(..): Returns true, if the major.minor is not inferior to the lowest valid version and does not exceed the highest known major number by more than one. The minor version number is ignored by the upper limit validation and the major version number may exceed by one. The upper limit check is relaxed since we don't want to cut-off unforseen new GL version since the release of JOGL. Hence it is important to iterate through GL version from the upper limit and 'decrementGLVersion(..)' until invalid. Add GL Version 4.4 to valid known versions. Remove ES3 desktop detection, which is impossible Regression of commit 3a0d7703da32e9a5ddf08a334f18588a78038d88 (ES3 support) --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 3 +- make/scripts/tests.sh | 9 +- src/jogl/classes/javax/media/opengl/GLContext.java | 111 +++++++++++++++------ .../jogamp/opengl/ExtensionAvailabilityCache.java | 7 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 83 ++++++--------- 6 files changed, 119 insertions(+), 98 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index c1da671b1..90226c28d 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -65,7 +65,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -134,7 +134,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index f7ee7b995..7c30d4db3 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -20,6 +20,7 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\% echo CP_ALL %CP_ALL% +set D_ARGS="-Djogamp.debug=all" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" @@ -52,7 +53,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.Til REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" -set D_ARGS="-Dnewt.debug.Window.MouseEvent" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9ada56c45..ece235a60 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -153,10 +153,9 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" - ##D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" - ##D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" + D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" @@ -314,7 +313,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* @@ -323,7 +322,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # tile rendring / printing w/ & w/o AWT diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index bd6867359..9f2e96781 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -1362,7 +1362,7 @@ public abstract class GLContext { /* 1.*/ { 0, 1, 2, 3, 4, 5 }, /* 2.*/ { 0, 1 }, /* 3.*/ { 0, 1, 2, 3 }, - /* 4.*/ { 0, 1, 2, 3 } }; + /* 4.*/ { 0, 1, 2, 3, 4 } }; public static final int ES_VERSIONS[][] = { /* 0.*/ { -1 }, @@ -1387,51 +1387,100 @@ public abstract class GLContext { } } + /** + * Returns true, if the major.minor is not inferior to the lowest + * valid version and does not exceed the highest known major number by more than one. + *

      + * The minor version number is ignored by the upper limit validation + * and the major version number may exceed by one. + *

      + *

      + * The upper limit check is relaxed since we don't want to cut-off + * unforseen new GL version since the release of JOGL. + *

      + *

      + * Hence it is important to iterate through GL version from the upper limit + * and {@link #decrementGLVersion(int, int[], int[])} until invalid. + *

      + */ public static final boolean isValidGLVersion(int ctxProfile, int major, int minor) { if( 1>major || 0>minor ) { return false; } - if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { - if( major>=ES_VERSIONS.length) return false; - if( minor>=ES_VERSIONS[major].length) return false; + if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) { + if( major >= ES_VERSIONS.length + 1 ) return false; } else { - if( major>=GL_VERSIONS.length) return false; - if( minor>=GL_VERSIONS[major].length) return false; + if( major>=GL_VERSIONS.length + 1 ) return false; } return true; } - public static final boolean decrementGLVersion(int ctxProfile, int major[], int minor[]) { - if(null==major || major.length<1 ||null==minor || minor.length<1) { - throw new GLException("invalid array arguments"); - } - int m = major[0]; - int n = minor[0]; - if( !isValidGLVersion(ctxProfile, m, n) ) { - return false; + /** + * Clip the given GL version to the maximum known valid version if exceeding. + * @return true if clipped, i.e. given value exceeds maximum, otherwise false. + */ + public static final boolean clipGLVersion(int ctxProfile, int major[], int minor[]) { + final int m = major[0]; + final int n = minor[0]; + + if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) { + if( m >= ES_VERSIONS.length ) { + major[0] = ES_VERSIONS.length - 1; + minor[0] = ES_VERSIONS[major[0]].length - 1; + return true; + } + if( n >= ES_VERSIONS[m].length ) { + minor[0] = ES_VERSIONS[m].length - 1; + return true; + } + } else if( m >= GL_VERSIONS.length ) { // !isES + major[0] = GL_VERSIONS.length - 1; + minor[0] = GL_VERSIONS[major[0]].length - 1; + return true; + } else if( n >= GL_VERSIONS[m].length ) { // !isES + minor[0] = GL_VERSIONS[m].length - 1; + return true; } + return false; + } - // decrement .. - n -= 1; - if(n < 0) { - if( ( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) ) { - if( m >= 3) { - m -= 1; + /** + * Decrement the given GL version by one + * and return true if still valid, otherwise false. + *

      + * If the given version exceeds the maximum known valid version, + * it is {@link #clipGLVersion(int, int[], int[]) clipped} and + * true is returned. + *

      + * + * @param ctxProfile + * @param major + * @param minor + * @return + */ + public static final boolean decrementGLVersion(int ctxProfile, int major[], int minor[]) { + if( !clipGLVersion(ctxProfile, major, minor) ) { + int m = major[0]; + int n = minor[0] - 1; + if(n < 0) { + if( 0 != ( CTX_PROFILE_ES & ctxProfile ) ) { + if( m >= 3 ) { + m -= 1; + } else { + m = 0; // major decr [1,2] -> 0 + } + n = ES_VERSIONS[m].length-1; } else { - m = 0; // major decr [1,2] -> 0 + m -= 1; + n = GL_VERSIONS[m].length-1; } - n = ES_VERSIONS[m].length-1; - } else { - m -= 1; - n = GL_VERSIONS[m].length-1; } + if( !isValidGLVersion(ctxProfile, m, n) ) { + return false; + } + major[0]=m; + minor[0]=n; } - if( !isValidGLVersion(ctxProfile, m, n) ) { - return false; - } - major[0]=m; - minor[0]=n; - return true; } diff --git a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java index b8bcd2e78..8d3d207ee 100644 --- a/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java +++ b/src/jogl/classes/jogamp/opengl/ExtensionAvailabilityCache.java @@ -223,14 +223,13 @@ final class ExtensionAvailabilityCache { final VersionNumber version = context.getGLVersionNumber(); int major[] = new int[] { version.getMajor() }; int minor[] = new int[] { version.getMinor() }; - while (GLContext.isValidGLVersion(ctxOptions, major[0], minor[0])) { + do{ final String GL_XX_VERSION = ( context.isGLES() ? "GL_ES_VERSION_" : "GL_VERSION_" ) + major[0] + "_" + minor[0]; availableExtensionCache.add(GL_XX_VERSION); if (DEBUG) { System.err.println(getThreadName() + ":ExtensionAvailabilityCache: Added "+GL_XX_VERSION+" to known extensions"); } - if(!GLContext.decrementGLVersion(ctxOptions, major, minor)) break; - } + } while( GLContext.decrementGLVersion(ctxOptions, major, minor) ); // put a dummy var in here so that the cache is no longer empty even if // no extensions are in the GL_EXTENSIONS string @@ -248,7 +247,7 @@ final class ExtensionAvailabilityCache { private int glExtensionCount = 0; private String glXExtensions = null; private int glXExtensionCount = 0; - private HashSet availableExtensionCache = new HashSet(50); + private final HashSet availableExtensionCache = new HashSet(50); static String getThreadName() { return Thread.currentThread().getName(); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 5f487fa6d..911a4c2be 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -853,7 +853,6 @@ public abstract class GLContextImpl extends GLContext { boolean hasGL2 = false; boolean hasGL4 = false; boolean hasGL3 = false; - boolean hasES3 = false; // Even w/ PROFILE_ALIASING, try to use true core GL profiles // ensuring proper user behavior across platforms due to different feature sets! @@ -922,13 +921,6 @@ public abstract class GLContextImpl extends GLContext { resetStates(false); // clean this context states, since creation was temporary } } - if(!hasES3) { - hasES3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_ES); // ES3 - success |= hasES3; - if(hasES3) { - resetStates(false); // clean this context states, since creation was temporary - } - } if(success) { // only claim GL versions set [and hence detected] if ARB context creation was successful GLContext.setAvailableGLVersionsSet(device); @@ -1023,8 +1015,7 @@ public abstract class GLContextImpl extends GLContext { minor[0]=minorMax; long _context=0; - while ( GLContext.isValidGLVersion(ctxOptionFlags, major[0], minor[0]) && - ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) ) { + do { if (DEBUG) { System.err.println(getThreadName() + ": createContextARBVersions: share "+share+", direct "+direct+", version "+major[0]+"."+minor[0]); } @@ -1039,10 +1030,8 @@ public abstract class GLContextImpl extends GLContext { } } - if(!GLContext.decrementGLVersion(ctxOptionFlags, major, minor)) { - break; - } - } + } while ( ( major[0]>majorMin || major[0]==majorMin && minor[0] >=minorMin ) && + GLContext.decrementGLVersion(ctxOptionFlags, major, minor) ); return _context; } @@ -1059,10 +1048,6 @@ public abstract class GLContextImpl extends GLContext { if ( 0 == ctp ) { throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); } - - if (!GLContext.isValidGLVersion(ctp, major, minor)) { - throw new GLException("Invalid GL Version "+major+"."+minor+", ctp "+toHexString(ctp)); - } ctxVersion = new VersionNumber(major, minor, 0); ctxVersionString = getGLVersion(major, minor, ctp, glVersion); ctxVendorVersion = glVendorVersion; @@ -1243,16 +1228,6 @@ public abstract class GLContextImpl extends GLContext { } } - /** - * We cannot promote a non ARB context to >= 3.1, reduce it to 3.0 then. - */ - private static void limitNonARBContextVersion(int[] major, int[] minor, int ctp) { - if ( 0 == (ctp & CTX_IS_ARB_CREATED) && ( major[0] > 3 || major[0] == 3 && minor[0] >= 1 ) ) { - major[0] = 3; - minor[0] = 0; - } - } - /** * Returns null if version string is invalid, otherwise a valid instance. *

      @@ -1265,7 +1240,6 @@ public abstract class GLContextImpl extends GLContext { if ( version.isValid() ) { int[] major = new int[] { version.getMajor() }; int[] minor = new int[] { version.getMinor() }; - limitNonARBContextVersion(major, minor, ctp); if ( GLContext.isValidGLVersion(ctp, major[0], minor[0]) ) { return new VersionNumber(major[0], minor[0], 0); } @@ -1297,7 +1271,6 @@ public abstract class GLContextImpl extends GLContext { } else { glGetIntegervInt(GL2GL3.GL_MAJOR_VERSION, glIntMajor, 0, _glGetIntegerv); glGetIntegervInt(GL2GL3.GL_MINOR_VERSION, glIntMinor, 0, _glGetIntegerv); - limitNonARBContextVersion(glIntMajor, glIntMinor, ctp); return true; } } @@ -1395,21 +1368,21 @@ public abstract class GLContextImpl extends GLContext { } } if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (Int): "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (Int): "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); } // Only validate if a valid int version was fetched, otherwise cont. w/ version-string method -> 3.0 > Version || Version > MAX! if ( GLContext.isValidGLVersion(ctxProfileBits, glIntMajor[0], glIntMinor[0]) ) { - if( glIntMajor[0] "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); - } - return false; + // relaxed match for versions major < 3 requests, last resort! + if( strictMatch && major >= 3 && glIntMajor[0] "+glVersion+", "+glIntMajor[0]+"."+glIntMinor[0]); } - major = glIntMajor[0]; - minor = glIntMinor[0]; + return false; } + // Use returned GL version! + major = glIntMajor[0]; + minor = glIntMinor[0]; versionValidated = true; } else { versionGL3IntFailed = true; @@ -1417,44 +1390,44 @@ public abstract class GLContextImpl extends GLContext { } if( !versionValidated ) { // Validate the requested version w/ the GL-version from the version string. - final VersionNumber setGLVersionNumber = new VersionNumber(major, minor, 0); - final VersionNumber strGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); + final VersionNumber expGLVersionNumber = new VersionNumber(major, minor, 0); + final VersionNumber hasGLVersionNumber = getGLVersionNumber(ctxProfileBits, glVersion); if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: version verification (String): "+glVersion+", "+strGLVersionNumber); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (String): "+glVersion+", "+hasGLVersionNumber); } // Only validate if a valid string version was fetched -> MIN > Version || Version > MAX! - if( null != strGLVersionNumber ) { - if( strGLVersionNumber.compareTo(setGLVersionNumber) < 0 || 0 == major ) { - if( strictMatch && 2 < major ) { // relaxed match for versions major < 3 requests, last resort! - if(DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (String): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+strGLVersionNumber); - } - return false; + if( null != hasGLVersionNumber ) { + // relaxed match for versions major < 3 requests, last resort! + if( strictMatch && major >= 3 && hasGLVersionNumber.compareTo(expGLVersionNumber) < 0 ) { + if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (String): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionNumber); } - major = strGLVersionNumber.getMajor(); - minor = strGLVersionNumber.getMinor(); + return false; } if( strictMatch && versionGL3IntFailed && major >= 3 ) { if(DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL3 version Int failed, String: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+strGLVersionNumber); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL3 version Int failed, String: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionNumber); } return false; } + // Use returned GL version! + major = hasGLVersionNumber.getMajor(); + minor = hasGLVersionNumber.getMinor(); versionValidated = true; } } - if( strictMatch && !versionValidated && 0 < major ) { + if( strictMatch && !versionValidated ) { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, No GL version validation possible: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion); } return false; } if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); } - if( 2 > major ) { // there is no ES2/3-compat for a profile w/ major < 2 + if( major < 2 ) { // there is no ES2/3-compat for a profile w/ major < 2 ctxProfileBits &= ~ ( GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_ES3_COMPAT ) ; } -- cgit v1.2.3 From 0ba264e878993d8f24254257d39a189b4ebf3937 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 19 Oct 2013 03:40:31 +0200 Subject: PinchToZoomGesture: Add ctor arg 'allowMorePointer', should be false to be more stable (i.e. only 2 pointer pressed) --- make/scripts/tests-x64-dbg.bat | 4 +- make/scripts/tests.sh | 6 +- .../com/jogamp/newt/event/PinchToZoomGesture.java | 18 ++- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 124 +++++++++++---------- 4 files changed, 81 insertions(+), 71 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 7c30d4db3..726be54ba 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -20,7 +20,7 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\% echo CP_ALL %CP_ALL% -set D_ARGS="-Djogamp.debug=all" +REM set D_ARGS="-Djogamp.debug=all" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" @@ -53,7 +53,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.Til REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" -REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" +set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ece235a60..fd79b028e 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -155,7 +155,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" - D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" @@ -300,7 +300,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -313,7 +313,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsGLJPanelAWTBug450 $* #testawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestTeapotNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT $* diff --git a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java index b4e1341da..42f006f08 100644 --- a/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java +++ b/src/newt/classes/com/jogamp/newt/event/PinchToZoomGesture.java @@ -62,16 +62,22 @@ public class PinchToZoomGesture implements GestureHandler { } private final NativeSurface surface; + private final boolean allowMorePointer; private float zoom; private int zoomLastEdgeDist; private boolean zoomFirstTouch; private boolean zoomMode; private ZoomEvent zoomEvent; - private short[] pIds = new short[] { -1, -1 }; + private final short[] pIds = new short[] { -1, -1 }; - public PinchToZoomGesture(NativeSurface surface) { + /** + * @param surface the {@link NativeSurface}, which size is used to compute the relative zoom factor + * @param allowMorePointer if false, allow only 2 pressed pointers (safe and recommended), otherwise accept other pointer to be pressed. + */ + public PinchToZoomGesture(NativeSurface surface, boolean allowMorePointer) { clear(true); this.surface = surface; + this.allowMorePointer = allowMorePointer; this.zoom = 1f; } @@ -135,11 +141,13 @@ public class PinchToZoomGesture implements GestureHandler { return true; } final MouseEvent pe = (MouseEvent)in; - if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen ) { + final int pointerDownCount = pe.getPointerCount(); + + if( pe.getPointerType(0).getPointerClass() != MouseEvent.PointerClass.Onscreen || + ( !allowMorePointer && pointerDownCount > 2 ) ) { return false; } - final int pointerDownCount = pe.getPointerCount(); final int eventType = pe.getEventType(); final boolean useY = surface.getWidth() >= surface.getHeight(); // use smallest dimension switch ( eventType ) { @@ -190,7 +198,7 @@ public class PinchToZoomGesture implements GestureHandler { final int d = Math.abs(edge0-edge1); final int dd = d - zoomLastEdgeDist; final float screenEdge = useY ? surface.getHeight() : surface.getWidth(); - final float incr = (float)dd / screenEdge; // [-1..1] + final float incr = dd / screenEdge; // [-1..1] if(DEBUG) { System.err.println("XXX2: id0 "+pIds[0]+" -> idx0 "+p0Idx+", id1 "+pIds[1]+" -> idx1 "+p1Idx); System.err.println("XXX3: d "+d+", ld "+zoomLastEdgeDist+", dd "+dd+", screen "+screenEdge+" -> incr "+incr+", zoom "+zoom+" -> "+(zoom+incr)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 53c813563..9817ea57f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -7,10 +7,10 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -55,12 +55,14 @@ import javax.media.opengl.GLUniformData; */ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererListener { private final FloatBuffer lightPos = Buffers.newDirectFloatBuffer( new float[] { 5.0f, 5.0f, 10.0f } ); - + private ShaderState st = null; private PMVMatrix pmvMatrix = null; private GLUniformData pmvMatrixUniform = null; private GLUniformData colorU = null; - private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; + private float view_rotx = 20.0f, view_roty = 30.0f; + + private final float view_rotz = 0.0f; private float panX = 0.0f, panY = 0.0f, panZ=0.0f; private GearsObjectES2 gear1=null, gear2=null, gear3=null; private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue; @@ -68,7 +70,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private int swapInterval = 0; private boolean pmvUseBackingArray = true; // the default for PMVMatrix now, since it's faster // private MouseListener gearsMouse = new TraceMouseAdapter(new GearsMouseAdapter()); - public MouseListener gearsMouse = new GearsMouseAdapter(); + public MouseListener gearsMouse = new GearsMouseAdapter(); public KeyListener gearsKeys = new GearsKeyAdapter(); private TileRendererBase tileRendererInUse = null; private boolean doRotateBeforePrinting; @@ -78,7 +80,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private float[] clearColor = null; private boolean clearBuffers = true; private boolean verbose = true; - + private PinchToZoomGesture pinchToZoomGesture = null; @@ -94,12 +96,12 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void addTileRendererNotify(TileRendererBase tr) { tileRendererInUse = tr; doRotateBeforePrinting = doRotate; - setDoRotation(false); + setDoRotation(false); } @Override public void removeTileRendererNotify(TileRendererBase tr) { tileRendererInUse = null; - setDoRotation(doRotateBeforePrinting); + setDoRotation(doRotateBeforePrinting); } @Override public void startTileRendering(TileRendererBase tr) { @@ -109,27 +111,27 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void endTileRendering(TileRendererBase tr) { System.err.println("GearsES2.endTileRendering: "+tr); } - + public void setIgnoreFocus(boolean v) { ignoreFocus = v; } public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void setClearBuffers(boolean v) { clearBuffers = v; } public void setVerbose(boolean v) { verbose = v; } - + public void setPMVUseBackingArray(boolean pmvUseBackingArray) { this.pmvUseBackingArray = pmvUseBackingArray; } - + /** float[4] */ public void setClearColor(float[] clearColor) { - this.clearColor = clearColor; + this.clearColor = clearColor; } - + public void setGearsColors(FloatBuffer gear1Color, FloatBuffer gear2Color, FloatBuffer gear3Color) { this.gear1Color = gear1Color; this.gear2Color = gear2Color; this.gear3Color = gear3Color; } - + public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) { gear1 = g1; gear2 = g2; @@ -162,14 +164,14 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); System.err.println("INIT GL IS: " + gl.getClass().getName()); System.err.println(JoglVersion.getGLStrings(gl, null, false).toString()); - } + } if( !gl.hasGLSL() ) { System.err.println("No GLSL available, no rendering."); return; } gl.glEnable(GL.GL_DEPTH_TEST); - + st = new ShaderState(); // st.setVerbose(true); final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader", @@ -184,7 +186,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.attachShaderProgram(gl, sp0, true); // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); - + pmvMatrix = new PMVMatrix(pmvUseBackingArray); st.attachObject("pmvMatrix", pmvMatrix); pmvMatrixUniform = new GLUniformData("pmvMatrix", 4, 4, pmvMatrix.glGetPMvMvitMatrixf()); // P, Mv, Mvi and Mvit @@ -210,7 +212,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL System.err.println("gear1 reused: "+gear1); } } - + if(null == gear2) { gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); if(verbose) { @@ -222,7 +224,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL System.err.println("gear2 reused: "+gear2); } } - + if(null == gear3) { gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); if(verbose) { @@ -234,31 +236,31 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL System.err.println("gear3 reused: "+gear3); } } - + final Object upstreamWidget = drawable.getUpstreamWidget(); if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.addMouseListener(gearsMouse); window.addKeyListener(gearsKeys); window.addGestureListener(pinchToZoomListener); - pinchToZoomGesture = new PinchToZoomGesture(drawable.getNativeSurface()); + pinchToZoomGesture = new PinchToZoomGesture(drawable.getNativeSurface(), false); window.addGestureHandler(pinchToZoomGesture); } else if (GLProfile.isAWTAvailable() && upstreamWidget instanceof java.awt.Component) { final java.awt.Component comp = (java.awt.Component) upstreamWidget; new com.jogamp.newt.event.awt.AWTMouseAdapter(gearsMouse).addTo(comp); new com.jogamp.newt.event.awt.AWTKeyAdapter(gearsKeys).addTo(comp); } - + st.useProgram(gl, false); - + System.err.println(Thread.currentThread()+" GearsES2.init FIN"); } - - private final GestureHandler.GestureListener pinchToZoomListener = new GestureHandler.GestureListener() { + + private final GestureHandler.GestureListener pinchToZoomListener = new GestureHandler.GestureListener() { @Override public void gestureDetected(GestureEvent gh) { final PinchToZoomGesture.ZoomEvent ze = (PinchToZoomGesture.ZoomEvent) gh; - final float zoom = ze.getZoom() * ( ze.getTrigger().getPointerCount() - 1 ); + final float zoom = ze.getZoom(); // * ( ze.getTrigger().getPointerCount() - 1 ); <- too much .. panZ = zoom * 30f - 30f; // [0 .. 2] -> [-30f .. 30f] } }; @@ -266,35 +268,35 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { final GL2ES2 gl = glad.getGL().getGL2ES2(); - if(-1 != swapInterval) { + if(-1 != swapInterval) { gl.setSwapInterval(swapInterval); } reshapeImpl(gl, x, y, width, height, width, height); } - + @Override public void reshapeTile(TileRendererBase tr, - int tileX, int tileY, int tileWidth, int tileHeight, + int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2(); gl.setSwapInterval(0); reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); } - + void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); System.err.println(Thread.currentThread()+" GearsES2.reshape "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); - + if( !gl.hasGLSL() ) { return; } - + st.useProgram(gl, true); pmvMatrix.glMatrixMode(PMVMatrix.GL_PROJECTION); pmvMatrix.glLoadIdentity(); - + // compute projection parameters 'normal' - float left, right, bottom, top; + float left, right, bottom, top; if( imageHeight > imageWidth ) { float a = (float)imageHeight / (float)imageWidth; left = -1.0f; @@ -310,27 +312,27 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } final float w = right - left; final float h = top - bottom; - + // compute projection parameters 'tiled' final float l = left + tileX * w / imageWidth; final float r = l + tileWidth * w / imageWidth; final float b = bottom + tileY * h / imageHeight; final float t = b + tileHeight * h / imageHeight; - + final float _w = r - l; final float _h = t - b; if(verbose) { System.err.println(">> angle "+angle+", [l "+left+", r "+right+", b "+bottom+", t "+top+"] "+w+"x"+h+" -> [l "+l+", r "+r+", b "+b+", t "+t+"] "+_w+"x"+_h); } - + pmvMatrix.glFrustumf(l, r, b, t, 5.0f, 200.0f); - + pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0.0f, 0.0f, -40.0f); st.uniform(gl, pmvMatrixUniform); st.useProgram(gl, false); - + // System.err.println(Thread.currentThread()+" GearsES2.reshape FIN"); } // private boolean useAndroidDebug = false; @@ -339,7 +341,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES2.dispose: tileRendererInUse "+tileRendererInUse); final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { + if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); @@ -357,12 +359,12 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL gear2.destroy(gl); gear2 = null; gear3.destroy(gl); - gear3 = null; + gear3 = null; pmvMatrix = null; - colorU = null; + colorU = null; st.destroy(gl); st = null; - + System.err.println(Thread.currentThread()+" GearsES2.dispose FIN"); } @@ -387,7 +389,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } else { hasFocus = true; } - + if( clearBuffers ) { if( null != clearColor ) { gl.glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); @@ -400,7 +402,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content - if (GLProfile.isAWTAvailable() && + if (GLProfile.isAWTAvailable() && (drawable instanceof javax.media.opengl.awt.GLJPanel) && !((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() && ((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { @@ -408,13 +410,13 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL } else { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } - } + } if( !gl.hasGLSL() ) { return; } gl.glEnable(GL.GL_CULL_FACE); - + st.useProgram(gl, true); pmvMatrix.glPushMatrix(); pmvMatrix.glTranslatef(panX, panY, panZ); @@ -424,20 +426,20 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f); gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f); - gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f); + gear3.draw(gl, -3.1f, 4.2f, -2f * angle - 25.0f); pmvMatrix.glPopMatrix(); st.useProgram(gl, false); - + gl.glDisable(GL.GL_CULL_FACE); } - + boolean confinedFixedCenter = false; - + public void setConfinedFixedCenter(boolean v) { confinedFixedCenter = v; } - - class GearsKeyAdapter extends KeyAdapter { + + class GearsKeyAdapter extends KeyAdapter { public void keyPressed(KeyEvent e) { int kc = e.getKeyCode(); if(KeyEvent.VK_LEFT == kc) { @@ -454,7 +456,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL class GearsMouseAdapter implements MouseListener{ private int prevMouseX, prevMouseY; - + @Override public void mouseClicked(MouseEvent e) { } @@ -476,12 +478,12 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL panZ += incr; System.err.println("panZ.2: incr "+incr+", dblZoom "+e.isShiftDown()+" -> "+panZ); } else { - // panning + // panning panX -= rot[0]; // positive -> left panY += rot[1]; // positive -> up } } - + public void mousePressed(MouseEvent e) { if( e.getPointerCount()==1 ) { prevMouseX = e.getX(); @@ -507,15 +509,15 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL prevMouseY = e.getY(); } } - + public void mouseDragged(MouseEvent e) { navigate(e); } - + private void navigate(MouseEvent e) { int x = e.getX(); int y = e.getY(); - + int width, height; Object source = e.getSource(); Window window = null; @@ -533,12 +535,12 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL height=comp.getHeight(); } else { throw new RuntimeException("Event source neither Window nor Component: "+source); - } + } final float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width); final float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height); view_rotx += thetaX; view_roty += thetaY; - if(e.isConfined() && confinedFixedCenter && null!=window) { + if(e.isConfined() && confinedFixedCenter && null!=window) { x=window.getWidth()/2; y=window.getHeight()/2; window.warpPointer(x, y); -- cgit v1.2.3 From dc2deb071ca192594426791e95804a208e030ce3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 25 Oct 2013 00:01:12 +0200 Subject: Bug 867 OSX [Common Code]: Trigger GLRendererQuirks.GL4NeedsGL3Request and make it sticky; Only alias profiles if HW-Accelerated! Only alias profiles if HW-Accelerated! GLContextImpl.mapGLVersions(..) shall not map a higher profile to a lower if it is a software renderer. +++ GLContextImpl.mapGLVersions(..) attempts to trigger GLRendererQuirks.GL4NeedsGL3Request if OSX 10.9 by creating a GL3 core context first. +++ GLContextImpl.setGLFunctionAvailability(): - On OSX 10.9: Detect GLRendererQuirks.GL4NeedsGL3Request and make it sticky (per device) while 'withinGLVersionsMapping' - Merge sticky quirks w/ local quirks +++ TestGearsES2NEWT: Add cmdline '-gl2' to force GL2 profile. --- make/scripts/tests.sh | 2 +- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 146 ++++++++++++++------- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 4 +- .../jogamp/opengl/egl/EGLExternalContext.java | 2 +- .../macosx/cgl/MacOSXExternalCGLContext.java | 2 +- .../windows/wgl/WindowsExternalWGLContext.java | 2 +- .../opengl/windows/wgl/WindowsWGLContext.java | 2 +- .../opengl/x11/glx/X11ExternalGLXContext.java | 2 +- .../jogamp/opengl/x11/glx/X11GLXContext.java | 4 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 68 +++++----- 10 files changed, 149 insertions(+), 85 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index fd79b028e..a1cb4d8e5 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -206,7 +206,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" - #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.debug.IOUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.gluegen.UseTempJarCache=false" #D_ARGS="-Dnewt.test.EDTMainThread -Dnewt.debug.MainThread" diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 911a4c2be..241d5a217 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -828,6 +828,9 @@ public abstract class GLContextImpl extends GLContext { final int[] reqMajorCTP = new int[] { 0, 0 }; getRequestMajorAndCompat(glCaps.getGLProfile(), reqMajorCTP); + if(DEBUG) { + System.err.println(getThreadName() + ": createContextARB: Requested "+GLContext.getGLVersion(reqMajorCTP[0], 0, reqMajorCTP[0], null)); + } int _major[] = { 0 }; int _minor[] = { 0 }; int _ctp[] = { 0 }; @@ -835,9 +838,12 @@ public abstract class GLContextImpl extends GLContext { if( GLContext.getAvailableGLVersion(device, reqMajorCTP[0], reqMajorCTP[1], _major, _minor, _ctp)) { _ctp[0] |= additionalCtxCreationFlags; + if(DEBUG) { + System.err.println(getThreadName() + ": createContextARB: Mapped "+GLContext.getGLVersion(_major[0], _minor[0], _ctp[0], null)); + } _ctx = createContextARBImpl(share, direct, _ctp[0], _major[0], _minor[0]); if(0!=_ctx) { - setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0], false); + setGLFunctionAvailability(true, _major[0], _minor[0], _ctp[0], false /* strictMatch */, false /* withinGLVersionsMapping */); } } return _ctx; @@ -857,67 +863,95 @@ public abstract class GLContextImpl extends GLContext { // Even w/ PROFILE_ALIASING, try to use true core GL profiles // ensuring proper user behavior across platforms due to different feature sets! // - if(!hasGL4) { + if( Platform.OSType.MACOS == Platform.getOSType() && + Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Mavericks) >= 0 ) { + /** + * OSX 10.9 GLRendererQuirks.GL4NeedsGL3Request, quirk is added as usual @ setRendererQuirks(..) + */ + if( !hasGL4 && !hasGL3 ) { + hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 + success |= hasGL3; + if( hasGL3 ) { + final boolean isHWAccel = 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ); + if( isHWAccel && ctxVersion.getMajor() >= 4 ) { + // Gotcha: Creating a '3.2' ctx delivers a >= 4 ctx. + GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + hasGL4 = true; + if(DEBUG) { + System.err.println("Quirk Triggerd: "+GLRendererQuirks.toString(GLRendererQuirks.GL4NeedsGL3Request)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()); + } + } + resetStates(false); // clean this context states, since creation was temporary + } + } + } + if( !hasGL4 ) { hasGL4 = createContextARBMapVersionsAvailable(4, CTX_PROFILE_CORE); // GL4 success |= hasGL4; - if(hasGL4) { - // Map all lower compatible profiles: GL3 - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - if(PROFILE_ALIASING) { - hasGL3 = true; + if( hasGL4 ) { + if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ) ) { + // Map hw-accel GL4 to all lower core profiles: GL3 + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + if( PROFILE_ALIASING ) { + hasGL3 = true; + } } resetStates(false); // clean context states, since creation was temporary } } - if(!hasGL3) { + if( !hasGL3 ) { hasGL3 = createContextARBMapVersionsAvailable(3, CTX_PROFILE_CORE); // GL3 success |= hasGL3; - if(hasGL3) { + if( hasGL3 ) { resetStates(false); // clean this context states, since creation was temporary } } - if(!hasGL4bc) { + if( !hasGL4bc ) { hasGL4bc = createContextARBMapVersionsAvailable(4, CTX_PROFILE_COMPAT); // GL4bc success |= hasGL4bc; - if(hasGL4bc) { - // Map all lower compatible profiles: GL3bc, GL2, GL4, GL3 - GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - if(!hasGL4) { + if( hasGL4bc ) { + if( !hasGL4 ) { // last chance .. ignore hw-accel GLContext.mapAvailableGLVersion(device, 4, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + hasGL4 = true; } - if(!hasGL3) { + if( !hasGL3 ) { // last chance .. ignore hw-accel GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - } - if(PROFILE_ALIASING) { - hasGL3bc = true; - hasGL2 = true; - hasGL4 = true; hasGL3 = true; } + if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ) ) { + // Map hw-accel GL4bc to all lower compatible profiles: GL3bc, GL2 + GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + if(PROFILE_ALIASING) { + hasGL3bc = true; + hasGL2 = true; + } + } resetStates(false); // clean this context states, since creation was temporary } } - if(!hasGL3bc) { + if( !hasGL3bc ) { hasGL3bc = createContextARBMapVersionsAvailable(3, CTX_PROFILE_COMPAT); // GL3bc success |= hasGL3bc; - if(hasGL3bc) { - // Map all lower compatible profiles: GL2 and GL3 - GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - if(!hasGL3) { + if( hasGL3bc ) { + if(!hasGL3) { // last chance .. ignore hw-accel GLContext.mapAvailableGLVersion(device, 3, CTX_PROFILE_CORE, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); - } - if(PROFILE_ALIASING) { - hasGL2 = true; hasGL3 = true; } + if( 0 == ( CTX_IMPL_ACCEL_SOFT & ctxOptions ) ) { + // Map hw-accel GL3bc to all lower compatible profiles: GL2 + GLContext.mapAvailableGLVersion(device, 2, CTX_PROFILE_COMPAT, ctxVersion.getMajor(), ctxVersion.getMinor(), ctxOptions); + if(PROFILE_ALIASING) { + hasGL2 = true; + } + } resetStates(false); // clean this context states, since creation was temporary } } - if(!hasGL2) { + if( !hasGL2 ) { hasGL2 = createContextARBMapVersionsAvailable(2, CTX_PROFILE_COMPAT); // GL2 success |= hasGL2; - if(hasGL2) { + if( hasGL2 ) { resetStates(false); // clean this context states, since creation was temporary } } @@ -1022,7 +1056,7 @@ public abstract class GLContextImpl extends GLContext { _context = createContextARBImpl(share, direct, ctxOptionFlags, major[0], minor[0]); if(0 != _context) { - if( setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true) ) { + if( setGLFunctionAvailability(true, major[0], minor[0], ctxOptionFlags, true /* strictMatch */, true /* withinGLVersionsMapping */) ) { break; } else { destroyContextARBImpl(_context); @@ -1291,14 +1325,15 @@ public abstract class GLContextImpl extends GLContext { * * @param force force the setting, even if is already being set. * This might be useful if you change the OpenGL implementation. - * @param major OpenGL major version - * @param minor OpenGL minor version - * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY} - * @param strictMatch if true the ctx must + * @param major OpenGL major version + * @param minor OpenGL minor version + * @param ctxProfileBits OpenGL context profile and option bits, see {@link javax.media.opengl.GLContext#CTX_OPTION_ANY} + * @param strictMatch if true the ctx must *

        *
      • be greater or equal than the requested major.minor version, and
      • *
      • match the ctxProfileBits
      • *
      , otherwise method aborts and returns false. + * @param withinGLVersionsMapping TODO * @return returns true if successful, otherwise false. See strictMatch. * If false is returned, no data has been cached or mapped, i.e. ProcAddressTable, Extensions, Version, etc. * @see #setContextVersion @@ -1306,7 +1341,8 @@ public abstract class GLContextImpl extends GLContext { * @see javax.media.opengl.GLContext#CTX_PROFILE_COMPAT * @see javax.media.opengl.GLContext#CTX_IMPL_ES2_COMPAT */ - protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits, boolean strictMatch) { + protected final boolean setGLFunctionAvailability(boolean force, int major, int minor, int ctxProfileBits, + boolean strictMatch, boolean withinGLVersionsMapping) { if(null!=this.gl && null!=glProcAddressTable && !force) { return true; // already done and not forced } @@ -1322,7 +1358,7 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsConfiguration aconfig = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); - + final int reqMajor = major, reqMinor = minor, reqCtxProfileBits = ctxProfileBits; { final boolean initGLRendererAndGLVersionStringsOK = initGLRendererAndGLVersionStrings(); if( !initGLRendererAndGLVersionStringsOK ) { @@ -1424,7 +1460,10 @@ public abstract class GLContextImpl extends GLContext { return false; } if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification req "+ + GLContext.getGLVersion(reqMajor, reqMinor, reqCtxProfileBits, null)+" -> has "+ + GLContext.getGLVersion(major, minor, ctxProfileBits, null)+ + ", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); } if( major < 2 ) { // there is no ES2/3-compat for a profile w/ major < 2 @@ -1433,7 +1472,7 @@ public abstract class GLContextImpl extends GLContext { final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion); - setRendererQuirks(adevice, major, minor, ctxProfileBits, vendorVersion); + setRendererQuirks(adevice, reqMajor, reqMinor, reqCtxProfileBits, major, minor, ctxProfileBits, vendorVersion, withinGLVersionsMapping); if( strictMatch && glRendererQuirks.exist(GLRendererQuirks.GLNonCompliant) ) { if(DEBUG) { @@ -1550,7 +1589,10 @@ public abstract class GLContextImpl extends GLContext { return true; } - private final void setRendererQuirks(final AbstractGraphicsDevice adevice, int major, int minor, int ctp, final VersionNumberString vendorVersion) { + private final void setRendererQuirks(final AbstractGraphicsDevice adevice, + int reqMajor, int reqMinor, int reqCTP, + int major, int minor, int ctp, final VersionNumberString vendorVersion, + boolean withinGLVersionsMapping) { int[] quirks = new int[GLRendererQuirks.COUNT + 1]; // + 1 ( NoFullFBOSupport ) int i = 0; @@ -1577,7 +1619,17 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - + if( Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Mavericks) >= 0 && 3==reqMajor && 4==major ) { + final int quirk = GLRendererQuirks.GL4NeedsGL3Request; + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", req "+reqMajor+"."+reqMinor); + } + quirks[i++] = quirk; + if( withinGLVersionsMapping ) { + // Thread safe due to single threaded initialization! + GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1); + } + } if( isDriverNVIDIAGeForce ) { final VersionNumber osxVersionNVFlushClean = new VersionNumber(10,7,3); // < OSX 10.7.3 w/ NV needs glFlush if( Platform.getOSVersionNumber().compareTo(osxVersionNVFlushClean) < 0 ) { @@ -1587,8 +1639,7 @@ public abstract class GLContextImpl extends GLContext { } quirks[i++] = quirk; } - final VersionNumber osxVersionNVGLSLGood = new VersionNumber(10,7,0); // < OSX 10.7.0 w/ NV has instable GLSL - if( Platform.getOSVersionNumber().compareTo(osxVersionNVGLSLGood) < 0 ) { + if( Platform.getOSVersionNumber().compareTo(Platform.OSXVersion.Lion) < 0 ) { // < OSX 10.7.0 w/ NV has unstable GLSL final int quirk = GLRendererQuirks.GLSLNonCompliant; if(DEBUG) { System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType()+", OS Version "+Platform.getOSVersionNumber()+", Renderer "+glRenderer); @@ -1732,6 +1783,11 @@ public abstract class GLContextImpl extends GLContext { } glRendererQuirks = new GLRendererQuirks(quirks, 0, i); + GLRendererQuirks.pushStickyDeviceQuirks(adevice, glRendererQuirks); // Thread safe due to single threaded initialization! + if(DEBUG) { + System.err.println("Quirks local: "+glRendererQuirks); + System.err.println("Quirks sticky on "+adevice+": "+GLRendererQuirks.getStickyDeviceQuirks(adevice)); + } } private static final boolean hasFBOImpl(int major, int ctp, ExtensionAvailabilityCache extCache) { @@ -1785,7 +1841,7 @@ public abstract class GLContextImpl extends GLContext { if(!drawable.getChosenGLCapabilities().getHardwareAccelerated()) { isHardwareRasterizer = false; } else { - isHardwareRasterizer = ! ( glRendererLowerCase.contains("software") /* Mesa3D */ || + isHardwareRasterizer = ! ( glRendererLowerCase.contains("software") /* Mesa3D, Apple */ || glRendererLowerCase.contains("mesa x11") /* Mesa3D */ || glRendererLowerCase.contains("softpipe") /* Gallium */ || glRendererLowerCase.contains("llvmpipe") /* Gallium */ diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 3de910369..d8bb2e9eb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -222,7 +222,9 @@ public class EGLContext extends GLContextImpl { throw new GLException("Error making context " + toHexString(contextHandle) + " current: error code " + toHexString(EGL.eglGetError())); } - return setGLFunctionAvailability(true, contextVersionReq, 0, CTX_PROFILE_ES, contextVersionReq>=3); // strict match for es >= 3 + return setGLFunctionAvailability(true, contextVersionReq, 0, CTX_PROFILE_ES, + contextVersionReq>=3 /* strictMatch */, // strict match for es >= 3 + false /* withinGLVersionsMapping */); } @Override diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java index 4685e8bf1..d54a80ae3 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLExternalContext.java @@ -45,7 +45,7 @@ public class EGLExternalContext extends EGLContext { public EGLExternalContext(AbstractGraphicsScreen screen) { super(null, null); GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES, false); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_ES, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index d23d8a7e1..a2cf334ce 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -63,7 +63,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { setOpenGLMode(isNSContext ? GLBackendType.NSOPENGL : GLBackendType.CGL ); this.contextHandle = handle; GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java index 966a8b28a..95d7d8b82 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLContext.java @@ -64,7 +64,7 @@ public class WindowsExternalWGLContext extends WindowsWGLContext { System.err.println(getThreadName() + ": Created external OpenGL context " + toHexString(ctx) + " for " + this); } GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index d936308af..82be3e2b9 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -325,7 +325,7 @@ public class WindowsWGLContext extends GLContextImpl { if ( !WGL.wglMakeCurrent(drawable.getHandle(), temp_ctx) ) { throw new GLException("Error making temp context current: 0x" + toHexString(temp_ctx) + ", werr: "+GDI.GetLastError()); } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION WGL.wglMakeCurrent(0, 0); // release temp context if( !createContextARBTried ) { diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index ba88ff3c4..a04d1989d 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -63,7 +63,7 @@ public class X11ExternalGLXContext extends X11GLXContext { super(drawable, null); this.contextHandle = ctx; GLContextShareSet.contextCreated(this); - setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false); + setGLFunctionAvailability(false, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION getGLStateTracker().setEnabled(false); // external context usage can't track state in Java } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 22a48e093..42bb6b964 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -320,7 +320,7 @@ public class X11GLXContext extends GLContextImpl { if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), contextHandle) ) { throw new GLException(getThreadName()+": Error making temp context(0) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION isDirect = GLX.glXIsDirect(display, contextHandle); if (DEBUG) { System.err.println(getThreadName() + ": createContextImpl: OK (old-1) share "+share+", direct "+isDirect+"/"+direct); @@ -350,7 +350,7 @@ public class X11GLXContext extends GLContextImpl { if ( !glXMakeContextCurrent(display, drawable.getHandle(), drawableRead.getHandle(), temp_ctx) ) { throw new GLException(getThreadName()+": Error making temp context(1) current: display "+toHexString(display)+", context "+toHexString(temp_ctx)+", drawable "+drawable); } - setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false); // use GL_VERSION + setGLFunctionAvailability(true, 0, 0, CTX_PROFILE_COMPAT, false /* strictMatch */, false /* withinGLVersionsMapping */); // use GL_VERSION glXMakeContextCurrent(display, 0, 0, 0); // release temp context if( !createContextARBTried ) { // is*Available calls are valid since setGLFunctionAvailability(..) was called diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 74be176da..b54a2cd19 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; import java.io.IOException; @@ -70,7 +70,7 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestGearsES2NEWT extends UITestCase { +public class TestGearsES2NEWT extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; static DimensionImmutable wsize, rwsize=null; @@ -92,12 +92,13 @@ public class TestGearsES2NEWT extends UITestCase { static boolean forceES2 = false; static boolean forceES3 = false; static boolean forceGL3 = false; + static boolean forceGL2 = false; static boolean mainRun = false; static boolean exclusiveContext = false; static boolean useAnimator = true; static enum SysExit { none, testExit, testError, displayExit, displayError }; static SysExit sysExit = SysExit.none; - + @BeforeClass public static void initClass() { if(null == wsize) { @@ -129,7 +130,7 @@ public class TestGearsES2NEWT extends UITestCase { final GearsES2 demo = new GearsES2(swapInterval); demo.setPMVUseBackingArray(pmvUseBackingArray); glWindow.addGLEventListener(demo); - + final SnapshotGLEventListener snap = new SnapshotGLEventListener(); glWindow.addGLEventListener(snap); if(waitForKey) { @@ -154,7 +155,7 @@ public class TestGearsES2NEWT extends UITestCase { animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); animator.setExclusiveContext(exclusiveContext); } - + QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); @@ -167,9 +168,9 @@ public class TestGearsES2NEWT extends UITestCase { } public void windowMoved(WindowEvent e) { System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); - } + } }); - + glWindow.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { @@ -299,7 +300,7 @@ public class TestGearsES2NEWT extends UITestCase { throw new Error("test error send from GLEventListener"); } else if ( SysExit.displayExit == sysExit ) { System.err.println("exit(0) send from GLEventListener"); - System.exit(0); + System.exit(0); } } } else { @@ -307,29 +308,29 @@ public class TestGearsES2NEWT extends UITestCase { } } @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); } - + glWindow.setVisible(true); if( useAnimator ) { animator.setUpdateFPSFrames(60, showFPS ? System.err : null); } - + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - + snap.setMakeSnapshot(); if( null != rwsize ) { - Thread.sleep(500); // 500ms delay + Thread.sleep(500); // 500ms delay glWindow.setSize(rwsize.getWidth(), rwsize.getHeight()); System.err.println("window resize pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); } - + snap.setMakeSnapshot(); - + final long t0 = System.currentTimeMillis(); long t1 = t0; while(!quitAdapter.shouldQuit() && t1-t0 Date: Fri, 25 Oct 2013 01:39:51 +0200 Subject: GLProfile: Fix native profile mapping, i.e. use actual mapped profile-impl as detected and mapped by GLContext ; Enhance glAvailabilityToString(..) We shall not map profile == profile-impl, i.e. GL3 -> GL3, but use GLContext.getAvailableGLProfileName(device, reqMajor, reqProfileBits). The latter reflects the actual mapped context as detected. glAvailabilityToString(..) - Partition result in [Natives, Common and Mappings] - Mappings dumps mapped keys to profiles, while excluding default. Default is added at last. - Add count. --- make/scripts/tests.sh | 4 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 129 ++++++++++++++------- .../test/junit/jogl/acore/TestGLProfile00NEWT.java | 12 +- 3 files changed, 96 insertions(+), 49 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a1cb4d8e5..3f4fe9c19 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -300,7 +300,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -355,7 +355,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 35dcce0f7..c04971176 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -61,8 +61,8 @@ import javax.media.opengl.fixedfunc.GLPointerFunc; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; -import java.util.Iterator; import java.util.List; +import java.util.Map; /** * Specifies the the OpenGL profile. @@ -267,138 +267,182 @@ public class GLProfile { initSingleton(); + int allCount = 0; + int nativeCount = 0; + if(null==device) { device = defaultDevice; } final HashMap map = getProfileMap(device, false); if(useIndent) { - doIndent(sb, indent, indentCount).append("Native"); + doIndent(sb, indent, indentCount).append("Natives"); indentCount++; - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4bc").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4bc).append(indent); } else { - sb.append("Native[GL4bc "); + sb.append("Natives["+GL4bc+" "); } avail=isAvailableImpl(map, GL4bc); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_COMPAT); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4).append(indent); } else { - sb.append(", GL4 "); + sb.append(", "+GL4+" "); } avail=isAvailableImpl(map, GL4); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 4, GLContext.CTX_PROFILE_CORE); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES3").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES3).append(indent); } else { - sb.append(", GLES3 "); + sb.append(", "+GLES3+" "); } avail=isAvailableImpl(map, GLES3); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_ES); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3bc").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3bc).append(indent); } else { - sb.append(", GL3bc "); + sb.append(", "+GL3bc+" "); } avail=isAvailableImpl(map, GL3bc); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_COMPAT); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL3").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3).append(indent); } else { - sb.append(", GL3 "); + sb.append(", "+GL3+" "); } avail=isAvailableImpl(map, GL3); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 3, GLContext.CTX_PROFILE_CORE); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2).append(indent); } else { - sb.append(", GL2 "); + sb.append(", "+GL2+" "); } avail=isAvailableImpl(map, GL2); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_COMPAT); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES2).append(indent); } else { - sb.append(", GLES2 "); + sb.append(", "+GLES2+" "); } avail=isAvailableImpl(map, GLES2); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 2, GLContext.CTX_PROFILE_ES); } + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GLES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES1).append(indent); } else { - sb.append(", GLES1 "); + sb.append(", "+GLES1+" "); } avail=isAvailableImpl(map, GLES1); sb.append(avail); if(avail) { + nativeCount++; glAvailabilityToString(device, sb.append(" "), 1, GLContext.CTX_PROFILE_ES); } + allCount++; + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+nativeCount+" / "+allCount); + indentCount--; + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Common"); + indentCount++; + } else { + sb.append(", count "+nativeCount+" / "+allCount+"], Common["); + } if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL4ES3").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4ES3).append(indent); } else { - sb.append(", GL4ES3 "); + sb.append(", "+GL4ES3+" "); } sb.append(isAvailableImpl(map, GL4ES3)); + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES2").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2GL3).append(indent); } else { - sb.append(", GL2ES2 "); + sb.append(", "+GL2GL3+" "); + } + sb.append(isAvailableImpl(map, GL2GL3)); + allCount++; + + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES2).append(indent); + } else { + sb.append(", "+GL2ES2+" "); } sb.append(isAvailableImpl(map, GL2ES2)); + allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("GL2ES1").append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES1).append(indent); } else { - sb.append(", GL2ES1 "); + sb.append(", "+GL2ES1+" "); } sb.append(isAvailableImpl(map, GL2ES1)); + allCount++; if(useIndent) { indentCount--; - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Profiles"); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Mappings"); indentCount++; } else { - sb.append("], Profiles["); + sb.append("], Mappings["); } + int profileCount = 0; + if(null != map) { - for(Iterator i=map.values().iterator(); i.hasNext(); ) { - if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount); - } - sb.append(i.next().toString()); - if(!useIndent) { - sb.append(", "); + for (Map.Entry entry : map.entrySet()) { + if( !GL_DEFAULT.equals(entry.getKey()) ) { + if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount); + } + sb.append(entry.getKey()+(useIndent?"\t":" ")+entry.getValue()); + if(!useIndent) { + sb.append(", "); + } + profileCount++; } } if(useIndent) { @@ -413,9 +457,10 @@ public class GLProfile { } } if(useIndent) { + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append("Count\t"+profileCount+" / "+allCount); sb.append(Platform.getNewline()); } else { - sb.append("]"); + sb.append(", count "+profileCount+" / "+allCount+"]"); } return sb; @@ -1979,21 +2024,21 @@ public class GLProfile { } } } else if(GL4bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4bcAvailable(device, isHardwareRasterizer))) { - return GL4bc; + return desktopCtxUndef ? GL4bc : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_COMPAT); } else if(GL4.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL4Available(device, isHardwareRasterizer))) { - return GL4; + return desktopCtxUndef ? GL4 : GLContext.getAvailableGLProfileName(device, 4, GLContext.CTX_PROFILE_CORE); } else if(GL3bc.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3bcAvailable(device, isHardwareRasterizer))) { - return GL3bc; + return desktopCtxUndef ? GL3bc : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_COMPAT); } else if(GL3.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL3Available(device, isHardwareRasterizer))) { - return GL3; + return desktopCtxUndef ? GL3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_CORE); } else if(GL2.equals(profile) && hasGL234Impl && ( desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer))) { - return GL2; + return desktopCtxUndef ? GL2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_COMPAT); } else if(GLES3.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, isHardwareRasterizer))) { - return GLES3; + return esCtxUndef ? GLES3 : GLContext.getAvailableGLProfileName(device, 3, GLContext.CTX_PROFILE_ES); } else if(GLES2.equals(profile) && hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, isHardwareRasterizer))) { - return GLES2; + return esCtxUndef ? GLES2 : GLContext.getAvailableGLProfileName(device, 2, GLContext.CTX_PROFILE_ES); } else if(GLES1.equals(profile) && hasGLES1Impl && ( esCtxUndef || GLContext.isGLES1Available(device, isHardwareRasterizer))) { - return GLES1; + return esCtxUndef ? GLES1 : GLContext.getAvailableGLProfileName(device, 1, GLContext.CTX_PROFILE_ES); } return null; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java index 7a48fbb2a..68562de4e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile00NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; @@ -36,6 +36,7 @@ import org.junit.runners.MethodSorters; import javax.media.opengl.*; +import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.test.junit.util.UITestCase; @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -44,6 +45,7 @@ public class TestGLProfile00NEWT extends UITestCase { @Test public void testInitSingleton() throws InterruptedException { GLProfile.initSingleton(); + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false)); } public static void main(String args[]) throws IOException { -- cgit v1.2.3 From 7f7a23dd0ddf106e6f0c69fc2a05ff92ac56200e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 27 Oct 2013 17:51:08 +0100 Subject: Bug 776 GLContext Sharing: Refine API for relaxed and lazy GLContext sharing ; Fix GLContext memory contract (volatile) (Unit test remarks see below) - Add shared GLContext queries - Refined GLContextShareSet: - Use IdentityHashMap since GLContext's can only be identical w/ same reference (footprint, performance) - Add API doc for clarification - Add methods: - ArrayList getCreatedShares(final GLContext context) - ArrayList getDestroyedShares(final GLContext context) - Use 'final' where possible - Add GLContext methods: - boolean isShared() - List getCreatedShares() - List getDestroyedShares() - Add GLSharedContextSetter interface defining setting a shared GLContext directly (GLContext) or via a GLAutoDrawable: - setSharedContext(GLContext) - setSharedAutoDrawable(GLAutoDrawable) Both cause initialization/creation of GLAutoDrawable's drawable/context to be postponed, if the shared GLContext is not yet created natively or the shared GLAutoDrawable's GLContext does not yet exist. Most of impl. resides in GLDrawableHelper Implemented in: - GLAutoDrawableBase, GLOffscreenAutoDrawable - GLWindow - AWT GLCanvas TODO: - GLJPanel - SWT GLCanvas - GLDrawableFactory: - Add 'GLOffscreenAutoDrawable createOffscreenAutoDrawable(..)' variant w/o passing the optional shared GLContext _and_ specifying lazy GLContext creation. This allows to benefit from GLSharedContextSetter contract. Lazy GLContext creation is performed at 2st display() call at the latest. All JOGL code and unit tests use this new method now. - Mark 'createOffscreenAutoDrawable(..)' w/ shared GLContext argument and immediate GLContext creation deprecated - shall be removed in 2.2.0 - Make reference to GLContext and it's native handle volatile Since we rely on the query 'GLContext.isCreated()' to properly allow GLAutoDrawable's to query whether a shared GLContext is natively created (already), the handle must be volatile since such query and the actual creation may operate on different threads. +++++ - Add/Refine shared GLContext unit tests demonstrating diff. sharing methods. All variants of using shared GLContext: com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBO* Most convenient way to share via setSharedAutoDrawable(GLAutoDrawable): com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2[NEWT|AWT]3 AWT use w/ JTabbedPane using setSharedAutoDrawable(GLAutoDrawable): com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT --- make/scripts/tests.sh | 32 +- .../com/jogamp/opengl/GLAutoDrawableDelegate.java | 9 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 4 +- .../com/jogamp/opengl/util/awt/TextRenderer.java | 32 +- src/jogl/classes/javax/media/opengl/GLContext.java | 21 +- .../javax/media/opengl/GLDrawableFactory.java | 55 +++- .../media/opengl/GLOffscreenAutoDrawable.java | 2 +- .../javax/media/opengl/GLSharedContextSetter.java | 78 +++++ .../classes/javax/media/opengl/awt/GLCanvas.java | 122 +++++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 46 +-- .../classes/jogamp/opengl/GLAutoDrawableBase.java | 72 +++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 4 +- .../classes/jogamp/opengl/GLContextShareSet.java | 150 ++++++---- .../jogamp/opengl/GLDrawableFactoryImpl.java | 13 + .../classes/jogamp/opengl/GLDrawableHelper.java | 60 +++- .../jogamp/opengl/GLOffscreenAutoDrawableImpl.java | 2 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 7 +- .../classes/com/jogamp/newt/opengl/GLWindow.java | 45 ++- .../jogl/acore/TestFBOAutoDrawableDeadlockAWT.java | 28 +- .../jogl/acore/TestFBOAutoDrawableFactoryNEWT.java | 130 ++++----- ...tFBOOffThreadSharedContextMix2DemosES2NEWT.java | 100 +++---- .../TestFBOOnThreadSharedContext1DemoES2NEWT.java | 89 +++--- .../jogl/acore/TestGLAutoDrawableDelegateNEWT.java | 46 +-- ...estGLAutoDrawableFactoryES2OffscrnCapsNEWT.java | 106 +++---- ...estGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java | 118 ++++---- ...TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java | 66 ++--- .../jogl/acore/TestGLExtensionQueryOffscreen.java | 22 +- .../jogl/acore/TestNEWTCloseX11DisplayBug565.java | 24 +- .../junit/jogl/acore/TestSharedContextListAWT.java | 43 +-- .../jogl/acore/TestSharedContextListNEWT.java | 20 +- .../jogl/acore/TestSharedContextNewtAWTBug523.java | 94 +++--- .../jogl/acore/TestSharedContextVBOES1NEWT.java | 75 +++-- .../jogl/acore/TestSharedContextVBOES2AWT3.java | 321 +++++++++++++++++++++ .../jogl/acore/TestSharedContextVBOES2NEWT.java | 245 ---------------- .../jogl/acore/TestSharedContextVBOES2NEWT0.java | 270 +++++++++++++++++ .../jogl/acore/TestSharedContextVBOES2NEWT1.java | 295 +++++++++++++++++++ .../jogl/acore/TestSharedContextVBOES2NEWT2.java | 315 ++++++++++++++++++++ .../jogl/acore/TestSharedContextVBOES2NEWT3.java | 296 +++++++++++++++++++ .../acore/TestSharedContextWithJTabbedPaneAWT.java | 264 +++++++++++++++++ .../acore/glels/GLContextDrawableSwitchBase.java | 96 +++--- .../glels/TestGLContextDrawableSwitch02AWT.java | 52 ++-- .../awt/TestBug461FBOSupersamplingSwingAWT.java | 46 +-- .../junit/jogl/caps/TestBug605FlippedImageAWT.java | 2 +- .../jogl/caps/TestBug605FlippedImageNEWT.java | 2 +- .../junit/jogl/caps/TestMultisampleES1AWT.java | 18 +- .../opengl/test/junit/jogl/demos/es1/GearsES1.java | 85 +++--- .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 114 ++++++-- .../jogl/glu/TestBug365TextureGenerateMipMaps.java | 108 ++++--- .../tile/TestRandomTiledRendering2GL2NEWT.java | 26 +- .../junit/jogl/tile/TestTiledRendering2NEWT.java | 36 +-- .../opengl/test/junit/util/AWTRobotUtil.java | 230 ++++++++------- .../jogamp/opengl/test/junit/util/MiscUtils.java | 73 +++-- 52 files changed, 3301 insertions(+), 1308 deletions(-) create mode 100644 src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3f4fe9c19..23477b254 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -353,9 +353,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* @@ -368,10 +367,25 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAO $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLExtensionQueryOffscreen $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* + +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLPointsNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug651NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLMesaBug658NEWT $* @@ -391,12 +405,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableNewtCanvasAWTOnOffscrnCapsAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* - #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext01VSyncAnimAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext02FPSAnimNEWT $* @@ -418,6 +426,9 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* + #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* @@ -447,9 +458,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testawt jogamp.newt.awt.opengl.VersionApplet $* #testawt javax.media.opengl.awt.GLCanvas $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java index ce58d29c1..6b1bb0e5e 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java +++ b/src/jogl/classes/com/jogamp/opengl/GLAutoDrawableDelegate.java @@ -64,11 +64,18 @@ import jogamp.opengl.GLDrawableImpl; */ public class GLAutoDrawableDelegate extends GLAutoDrawableBase implements GLAutoDrawable { /** + *

      + * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)} + * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
      + * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account + * which has been set {@link #setSharedContext(GLContext) directly} + * or {@link #setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}. + *

      * @param drawable a valid {@link GLDrawable}, may not be {@link GLDrawable#isRealized() realized} yet. * @param context a valid {@link GLContext}, * may not have been made current (created) yet, * may not be associated w/ drawable yet, - * may be null for lazy initialization + * may be null for lazy initialization at 1st {@link #display()}. * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. * @param ownDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, * otherwise pass false. Closing the device is required in case diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 1a3e1e0c0..5e3731984 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -242,7 +242,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private class DisposeGLEventListenerAction implements Runnable { private GLEventListener listener; - private boolean remove; + private final boolean remove; private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { this.listener = listener; this.remove = remove; @@ -677,7 +677,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public GLContext getContext() { - return null != drawable ? context : null; + return context; } @Override diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java index 3662223f4..46dc73003 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java @@ -159,20 +159,20 @@ public class TextRenderer { static final int kTotalBufferSizeBytesTex = kTotalBufferSizeCoordsTex * 4; static final int kSizeInBytes_OneVertices_VertexData = kCoordsPerVertVerts * 4; static final int kSizeInBytes_OneVertices_TexData = kCoordsPerVertTex * 4; - private Font font; - private boolean antialiased; - private boolean useFractionalMetrics; + private final Font font; + private final boolean antialiased; + private final boolean useFractionalMetrics; // Whether we're attempting to use automatic mipmap generation support private boolean mipmap; private RectanglePacker packer; private boolean haveMaxSize; - private RenderDelegate renderDelegate; + private final RenderDelegate renderDelegate; private TextureRenderer cachedBackingStore; private Graphics2D cachedGraphics; private FontRenderContext cachedFontRenderContext; - private Map stringLocations = new HashMap(); - private GlyphProducer mGlyphProducer; + private final Map stringLocations = new HashMap(); + private final GlyphProducer mGlyphProducer; private int numRenderCycles; @@ -905,8 +905,8 @@ public class TextRenderer { private void debug(GL gl) { dbgFrame = new Frame("TextRenderer Debug Output"); - GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(gl.getGLProfile()), null, - GLContext.getCurrent(), null); + GLCanvas dbgCanvas = new GLCanvas(new GLCapabilities(gl.getGLProfile())); + dbgCanvas.setSharedContext(GLContext.getCurrent()); dbgCanvas.addGLEventListener(new DebugListener(gl, dbgFrame)); dbgFrame.add(dbgCanvas); @@ -1085,7 +1085,7 @@ public class TextRenderer { static class TextData { // Back-pointer to String this TextData describes, if it // represents a String rather than a single glyph - private String str; + private final String str; // If this TextData represents a single glyph, this is its // unicode ID @@ -1096,7 +1096,7 @@ public class TextRenderer { // 2D coordinate system) at which the string must be rasterized in // order to fit within the rectangle -- the leftmost point of the // baseline. - private Point origin; + private final Point origin; // This represents the pre-normalized rectangle, which fits // within the rectangle on the backing store. We keep a @@ -1104,7 +1104,7 @@ public class TextRenderer { // prevent bleeding of adjacent letters when using GL_LINEAR // filtering for rendering. The origin of this rectangle is // equivalent to the origin above. - private Rectangle2D origRect; + private final Rectangle2D origRect; private boolean used; // Whether this text was used recently @@ -1375,7 +1375,7 @@ public class TextRenderer { // // A temporary to prevent excessive garbage creation - private char[] singleUnicode = new char[1]; + private final char[] singleUnicode = new char[1]; /** A Glyph represents either a single unicode glyph or a substring of characters to be drawn. The reason for the dual @@ -1497,10 +1497,10 @@ public class TextRenderer { int width = (int) origRect.getWidth(); int height = (int) origRect.getHeight(); - float tx1 = xScale * (float) texturex / (float) renderer.getWidth(); + float tx1 = xScale * texturex / renderer.getWidth(); float ty1 = yScale * (1.0f - ((float) texturey / (float) renderer.getHeight())); - float tx2 = xScale * (float) (texturex + width) / (float) renderer.getWidth(); + float tx2 = xScale * (texturex + width) / renderer.getWidth(); float ty2 = yScale * (1.0f - ((float) (texturey + height) / (float) renderer.getHeight())); @@ -1829,7 +1829,7 @@ public class TextRenderer { GL2 gl = GLContext.getCurrentGL().getGL2(); TextureRenderer renderer = getBackingStore(); - Texture texture = renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? + renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? mVertCoords.rewind(); mTexCoords.rewind(); @@ -1872,7 +1872,7 @@ public class TextRenderer { private void drawIMMEDIATE() { if (mOutstandingGlyphsVerticesPipeline > 0) { TextureRenderer renderer = getBackingStore(); - Texture texture = renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? + renderer.getTexture(); // triggers texture uploads. Maybe this should be more obvious? GL2 gl = GLContext.getCurrentGL().getGL2(); gl.glBegin(GL2.GL_QUADS); diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index e83d60b66..5c6c7073a 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -44,12 +44,14 @@ import java.nio.IntBuffer; import java.util.HashMap; import java.util.IdentityHashMap; import java.util.Iterator; +import java.util.List; import java.util.Set; import javax.media.nativewindow.AbstractGraphicsDevice; import jogamp.opengl.Debug; import jogamp.opengl.GLContextImpl; +import jogamp.opengl.GLContextShareSet; import com.jogamp.common.os.Platform; import com.jogamp.common.util.VersionNumber; @@ -205,7 +207,7 @@ public abstract class GLContext { protected final RecursiveLock lock = LockFactory.createRecursiveLock(); /** The underlying native OpenGL context */ - protected long contextHandle; + protected volatile long contextHandle; protected GLContext() { resetStates(true); @@ -242,6 +244,21 @@ public abstract class GLContext { drawableRetargeted = false; } + /** Returns true if this GLContext is shared, otherwise false. */ + public final boolean isShared() { + return GLContextShareSet.isShared(this); + } + + /** Returns a new list of created GLContext shared with this GLContext. */ + public final List getCreatedShares() { + return GLContextShareSet.getCreatedShares(this); + } + + /** Returns a new list of destroyed GLContext shared with this GLContext. */ + public final List getDestroyedShares() { + return GLContextShareSet.getDestroyedShares(this); + } + /** * Returns the instance of {@link GLRendererQuirks}, allowing one to determine workarounds. * @return instance of {@link GLRendererQuirks} if context was made current once, otherwise null. @@ -590,7 +607,7 @@ public abstract class GLContext { sb.append(toHexString(hashCode())); sb.append(", handle "); sb.append(toHexString(contextHandle)); - sb.append(", "); + sb.append(", isShared "+isShared()+", "); sb.append(getGL()); sb.append(",\n\t quirks: "); if(null != glRendererQuirks) { diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 26bafd961..817dff8ad 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -475,7 +475,8 @@ public abstract class GLDrawableFactory { *

      * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true, - * it is auto-configured. The latter will set offscreen and also FBO or Pbuffer, whichever is available in that order. + * it is auto-configured. Auto configuration will set {@link GLCapabilitiesImmutable caps} to offscreen + * and FBO or Pbuffer, whichever is available in that order. *

      *

      * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} @@ -501,12 +502,62 @@ public abstract class GLDrawableFactory { * the creation of the Offscreen to fail. * * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) + * @deprecated Use {@link #createOffscreenAutoDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) */ public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, GLCapabilitiesImmutable caps, GLCapabilitiesChooser chooser, int width, int height, GLContext shareWith) throws GLException; + + /** + * Creates a {@link GLDrawable#isRealized() realized} {@link GLOffscreenAutoDrawable} + * incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. + *

      + * The {@link GLOffscreenAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized} + * without an assigned {@link GLContext}.
      + * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)} + * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
      + * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account + * which has been set {@link GLOffscreenAutoDrawable#setSharedContext(GLContext) directly} + * or {@link GLOffscreenAutoDrawable#setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}. + *

      + *

      + * In case the passed {@link GLCapabilitiesImmutable} contains default values, i.e. + * {@link GLCapabilitiesImmutable#isOnscreen() caps.isOnscreen()} == true, + * it is auto-configured. Auto configuration will set {@link GLCapabilitiesImmutable caps} to offscreen + * and FBO or Pbuffer, whichever is available in that order. + *

      + *

      + * A FBO based auto drawable, {@link GLOffscreenAutoDrawable.FBO}, is created if both {@link GLCapabilitiesImmutable#isFBO() caps.isFBO()} + * and {@link GLContext#isFBOAvailable(AbstractGraphicsDevice, GLProfile) canCreateFBO(device, caps.getGLProfile())} is true. + *

      + *

      + * A Pbuffer based auto drawable is created if both {@link GLCapabilitiesImmutable#isPBuffer() caps.isPBuffer()} + * and {@link #canCreateGLPbuffer(AbstractGraphicsDevice, GLProfile) canCreateGLPbuffer(device)} is true. + *

      + *

      + * If neither FBO nor Pbuffer is available, + * a simple pixmap/bitmap auto drawable is created, which is unlikely to be hardware accelerated. + *

      + * + * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. + * @param caps the requested GLCapabilties + * @param chooser the custom chooser, may be null for default + * @param width the requested offscreen width + * @param height the requested offscreen height + * @return the created and initialized offscreen {@link GLOffscreenAutoDrawable} instance + * + * @throws GLException if any window system-specific errors caused + * the creation of the Offscreen to fail. + * + * @see #createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) + */ + public abstract GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice device, + GLCapabilitiesImmutable caps, + GLCapabilitiesChooser chooser, + int width, int height) throws GLException; + /** * Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable} * incl it's offscreen {@link javax.media.nativewindow.NativeSurface} with the given capabilites and dimensions. @@ -625,7 +676,7 @@ public abstract class GLDrawableFactory { *

      * * See the note in the overview documentation on - * context sharing. + * context sharing. * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. * @param capabilities the requested capabilities diff --git a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java index be90d935f..d34edaf2e 100644 --- a/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/GLOffscreenAutoDrawable.java @@ -40,7 +40,7 @@ import com.jogamp.opengl.FBObject; * with it's {@link #setSize(int, int)} functionality. *

      */ -public interface GLOffscreenAutoDrawable extends GLAutoDrawable { +public interface GLOffscreenAutoDrawable extends GLAutoDrawable, GLSharedContextSetter { /** * Resize this auto drawable. diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java new file mode 100644 index 000000000..d5a10931e --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -0,0 +1,78 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package javax.media.opengl; + +/** + * Adds capabilities to set a shared {@link GLContext} directly or via an {@link GLAutoDrawable}. + *

      + * Warning: Don't reference this interface directly, since it may end up in {@link GLAutoDrawable} + *

      + */ +public interface GLSharedContextSetter extends GLAutoDrawable { + /** + * Specifies an {@link GLContext OpenGL context}, which shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + *

      + * Since the {@link GLDrawable drawable} and {@link GLContext context} is created + * at {@link GLAutoDrawable#initialization GLAutoDrawable initialization} + * this method shall be called beforehand to have any effect. + *

      + *

      + * A set sharedContext will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization}, + * as long it is not {@link GLContext#isCreated() created natively}. + *

      + * + * @param sharedContext The OpenGL context to be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext} + * or {@link #setSharedAutoDrawable(GLAutoDrawable) shared GLAutoDrawable} is already set, + * the given sharedContext is null or equal to this {@link GLAutoDrawable}'s context. + * @see #setSharedAutoDrawable(GLAutoDrawable) + */ + void setSharedContext(GLContext sharedContext) throws IllegalStateException; + + /** + * Specifies an {@link GLAutoDrawable}, which {@link GLContext OpenGL context} shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + *

      + * Since the {@link GLDrawable drawable} and {@link GLContext context} is created + * at {@link GLAutoDrawable#initialization GLAutoDrawable initialization} + * this method shall be called beforehand to have any effect. + *

      + *

      + * A set sharedAutoDrawable will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization}, + * as long it's {@link GLContext} is null + * or has not been {@link GLContext#isCreated() created natively}. + *

      + * + * @param sharedContext The GLAutoDrawable, which OpenGL context shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. + * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext} + * or {@link #setSharedAutoDrawable(GLAutoDrawable) shared GLAutoDrawable} is already set, + * the given sharedAutoDrawable is null or equal to this GLAutoDrawable. + * @see #setSharedContext(GLContext) + */ + void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException; +} diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 8757c7a26..b070ddd7d 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -81,6 +81,7 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLSharedContextSetter; import javax.media.opengl.Threading; import com.jogamp.common.GlueGenVersion; @@ -114,7 +115,7 @@ import jogamp.opengl.awt.AWTTilePainter; interfaces when adding a heavyweight doesn't work either because of Z-ordering or LayoutManager problems. * - *
      Offscreen Layer Remarks
      + *
      Offscreen Layer Remarks
      * * {@link OffscreenLayerOption#setShallUseOffscreenLayer(boolean) setShallUseOffscreenLayer(true)} * maybe called to use an offscreen drawable (FBO or PBuffer) allowing @@ -124,7 +125,7 @@ import jogamp.opengl.awt.AWTTilePainter; * is being called if {@link GLCapabilitiesImmutable#isOnscreen()} is false. *

      * - *
      Java2D OpenGL Remarks
      + *
      Java2D OpenGL Remarks
      * * To avoid any conflicts with a potential Java2D OpenGL context,
      * you shall consider setting the following JVM properties:
      @@ -141,7 +142,7 @@ import jogamp.opengl.awt.AWTTilePainter; *
    • sun.java2d.noddraw=true
    • * * - *
      Disable Background Erase
      + *
      Disable Background Erase
      * * GLCanvas tries to disable background erase for the AWT Canvas * before native peer creation (X11) and after it (Windows),
      @@ -153,7 +154,7 @@ import jogamp.opengl.awt.AWTTilePainter; */ @SuppressWarnings("serial") -public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosingProtocol, OffscreenLayerOption, AWTPrintLifecycle { +public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosingProtocol, OffscreenLayerOption, AWTPrintLifecycle, GLSharedContextSetter { private static final boolean DEBUG = Debug.debug("GLCanvas"); @@ -162,18 +163,20 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private AWTGraphicsConfiguration awtConfig; private volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access private volatile JAWTWindow jawtWindow; // the JAWTWindow presentation of this AWT Canvas, bound to the 'drawable' lifecycle - private GLContextImpl context; + private volatile GLContextImpl context; private volatile boolean sendReshape = false; // volatile: maybe written by EDT w/o locking // copy of the cstr args, mainly for recreation - private GLCapabilitiesImmutable capsReqUser; - private GLCapabilitiesChooser chooser; - private GLContext shareWith; + private final GLCapabilitiesImmutable capsReqUser; + private final GLCapabilitiesChooser chooser; private int additionalCtxCreationFlags = 0; - private GraphicsDevice device; + private final GraphicsDevice device; private boolean shallUseOffscreenLayer = false; - private AWTWindowClosingProtocol awtWindowClosingProtocol = + protected GLContext sharedContext = null; + protected GLAutoDrawable sharedAutoDrawable = null; + + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { @@ -207,6 +210,8 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing * * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. * @see GLCanvas#GLCanvas(javax.media.opengl.GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, javax.media.opengl.GLContext, java.awt.GraphicsDevice) + * @deprecated Use {@link #GLCanvas(GLCapabilitiesImmutable)} + * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. */ public GLCanvas(GLCapabilitiesImmutable capsReqUser, GLContext shareWith) throws GLException @@ -214,6 +219,26 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing this(capsReqUser, null, shareWith, null); } + /** Creates a new GLCanvas component. The passed GLCapabilities + specifies the OpenGL capabilities for the component; if null, a + default set of capabilities is used. The GLCapabilitiesChooser + specifies the algorithm for selecting one of the available + GLCapabilities for the component; a DefaultGLCapabilitesChooser + is used if null is passed for this argument. + The passed GraphicsDevice indicates the screen on + which to create the GLCanvas; the GLDrawableFactory uses the + default screen device of the local GraphicsEnvironment if null + is passed for this argument. + * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. + */ + public GLCanvas(GLCapabilitiesImmutable capsReqUser, + GLCapabilitiesChooser chooser, + GraphicsDevice device) + throws GLException + { + this(capsReqUser, chooser, null, device); + } + /** Creates a new GLCanvas component. The passed GLCapabilities specifies the OpenGL capabilities for the component; if null, a default set of capabilities is used. The GLCapabilitiesChooser @@ -224,12 +249,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing textures, display lists and other OpenGL state, and may be null if sharing is not desired. See the note in the overview documentation on context + href="../../../spec-summary.html#SHARING">context sharing. The passed GraphicsDevice indicates the screen on which to create the GLCanvas; the GLDrawableFactory uses the default screen device of the local GraphicsEnvironment if null is passed for this argument. * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. + * @deprecated Use {@link #GLCanvas(GLCapabilitiesImmutable, GLCapabilitiesChooser, GraphicsDevice)} + * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. */ public GLCanvas(GLCapabilitiesImmutable capsReqUser, GLCapabilitiesChooser chooser, @@ -266,10 +293,20 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // instantiation will be issued in addNotify() this.capsReqUser = capsReqUser; this.chooser = chooser; - this.shareWith = shareWith; + this.sharedContext = shareWith; this.device = device; } + @Override + public final void setSharedContext(GLContext sharedContext) throws IllegalStateException { + helper.setSharedContext(this.context, sharedContext); + } + + @Override + public final void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { + helper.setSharedAutoDrawable(this, sharedAutoDrawable); + } + @Override public final Object getUpstreamWidget() { return this; @@ -383,7 +420,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing destroyImpl( true ); // recreation! awtConfig = config; - createDrawableAndContext( true ); + createJAWTDrawableAndContext(); validateGLDrawable(); } else { awtConfig = config; @@ -592,7 +629,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing // after native peer is valid: Windows disableBackgroundErase(); - createDrawableAndContext( true ); + createJAWTDrawableAndContext(); // init drawable by paint/display makes the init sequence more equal // for all launch flavors (applet/javaws/..) @@ -608,22 +645,35 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } - private void createDrawableAndContext(boolean createJAWTWindow) { + private void createJAWTDrawableAndContext() { if ( !Beans.isDesignTime() ) { - if( createJAWTWindow ) { - jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); - jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - } + jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(this, awtConfig); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); jawtWindow.lockSurface(); try { drawable = (GLDrawableImpl) GLDrawableFactory.getFactory(capsReqUser.getGLProfile()).createGLDrawable(jawtWindow); - context = (GLContextImpl) drawable.createContext(shareWith); - context.setContextCreationFlags(additionalCtxCreationFlags); + createContextImpl(drawable); } finally { jawtWindow.unlockSurface(); } } } + private boolean createContextImpl(final GLDrawable drawable) { + final GLContext[] shareWith = { null }; + if( !helper.isSharedGLContextPending(shareWith) ) { + context = (GLContextImpl) drawable.createContext(shareWith[0]); + context.setContextCreationFlags(additionalCtxCreationFlags); + if(DEBUG) { + System.err.println(getThreadName()+": Context created: has shared "+(null != shareWith[0])); + } + return true; + } else { + if(DEBUG) { + System.err.println(getThreadName()+": Context !created: pending share"); + } + return false; + } + } private boolean validateGLDrawable() { if( Beans.isDesignTime() || !isDisplayable() ) { @@ -631,17 +681,22 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } final GLDrawable _drawable = drawable; if ( null != _drawable ) { - if( _drawable.isRealized() ) { - return true; - } - if( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { - return false; // early out! + boolean res = _drawable.isRealized(); + if( !res ) { + // re-try drawable creation + if( 0 >= _drawable.getWidth() || 0 >= _drawable.getHeight() ) { + return false; // early out! + } + setRealized(true); + res = _drawable.isRealized(); + if(DEBUG) { + System.err.println(getThreadName()+": Realized Drawable: isRealized "+res+", "+_drawable.toString()); + // Thread.dumpStack(); + } } - setRealized(true); - final boolean res = _drawable.isRealized(); - if(DEBUG) { - System.err.println(getThreadName()+": Realized Drawable: isRealized "+res+", "+_drawable.toString()); - // Thread.dumpStack(); + if( res && null == context ) { + // re-try context creation + res = createContextImpl(_drawable); // pending creation. } return res; } @@ -791,8 +846,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, - null); + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } @@ -1251,7 +1305,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private class DisposeGLEventListenerAction implements Runnable { GLEventListener listener; - private boolean remove; + private final boolean remove; private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { this.listener = listener; this.remove = remove; diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 84db62515..93e8b2c0b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -108,22 +108,23 @@ import com.jogamp.opengl.util.texture.TextureState; support. Provided for compatibility with Swing user interfaces when adding a heavyweight doesn't work either because of Z-ordering or LayoutManager problems. -

      +

      The GLJPanel can be made transparent by creating it with a GLCapabilities object with alpha bits specified and calling {@link #setOpaque}(false). Pixels with resulting OpenGL alpha values less - than 1.0 will be overlaid on any underlying Swing rendering.

      -

      + than 1.0 will be overlaid on any underlying Swing rendering. +

      +

      This component attempts to use hardware-accelerated rendering via FBO or pbuffers and falls back on to software rendering if none of the former are available using {@link GLDrawableFactory#createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) GLDrawableFactory.createOffscreenDrawable(..)}.
      -

      -

      +

      +

      In case FBO is used and GLSL is available, a fragment shader is utilized to flip the FBO texture vertically. This hardware-accelerated step can be disabled via system property jogl.gljpanel.noglsl. See details here. -

      -

      +

      +

      The OpenGL path is concluded by copying the rendered pixels an {@link BufferedImage} via {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)} for later Java2D composition.

      @@ -210,7 +211,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return singleAWTGLPixelBufferProvider; } - private GLDrawableHelper helper = new GLDrawableHelper(); + private final GLDrawableHelper helper = new GLDrawableHelper(); private volatile boolean isInitialized; // @@ -219,10 +220,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private AWTGLPixelBufferProvider customPixelBufferProvider = null; /** Single buffered offscreen caps */ private GLCapabilitiesImmutable offscreenCaps; - private GLProfile glProfile; - private GLDrawableFactoryImpl factory; - private GLCapabilitiesChooser chooser; - private GLContext shareWith; + private final GLProfile glProfile; + private final GLDrawableFactoryImpl factory; + private final GLCapabilitiesChooser chooser; + private final GLContext shareWith; private int additionalCtxCreationFlags = 0; // Lazy reshape notification: reshapeWidth -> panelWidth -> backend.width @@ -248,13 +249,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private volatile Backend backend; // Used by all backends either directly or indirectly to hook up callbacks - private Updater updater = new Updater(); + private final Updater updater = new Updater(); private boolean oglPipelineUsable() { return null == customPixelBufferProvider && useJava2DGLPipeline && java2DGLPipelineOK; } - private AWTWindowClosingProtocol awtWindowClosingProtocol = + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { @@ -289,7 +290,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing GLContext specifies an OpenGL context with which to share textures, display lists and other OpenGL state, and may be null if sharing is not desired. See the note in the overview documentation on - context sharing. + context sharing.

      Note: Sharing cannot be enabled using J2D OpenGL FBO sharing, since J2D GL Context must be shared and we can only share one context. @@ -572,8 +573,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, - null); + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } @@ -1158,7 +1158,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private class DisposeGLEventListenerAction implements Runnable { GLEventListener listener; - private boolean remove; + private final boolean remove; private DisposeGLEventListenerAction(GLEventListener listener, boolean remove) { this.listener = listener; this.remove = remove; @@ -1268,12 +1268,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing protected IntBuffer readBackIntsForCPUVFlip; // Implementation using software rendering - private GLDrawableImpl offscreenDrawable; + private volatile GLDrawableImpl offscreenDrawable; private boolean offscreenIsFBO; private FBObject fboFlipped; private GLSLTextureRaster glslTextureRaster; - private GLContextImpl offscreenContext; + private volatile GLContextImpl offscreenContext; private boolean flipVertical; // For saving/restoring of OpenGL state during ReadPixels @@ -1694,11 +1694,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private GLContext joglContext; // State captured from Java2D OpenGL context necessary in order to // properly render into Java2D back buffer - private int[] drawBuffer = new int[1]; - private int[] readBuffer = new int[1]; + private final int[] drawBuffer = new int[1]; + private final int[] readBuffer = new int[1]; // This is required when the FBO option of the Java2D / OpenGL // pipeline is active - private int[] frameBuffer = new int[1]; + private final int[] frameBuffer = new int[1]; // Current (as of this writing) NVidia drivers have a couple of bugs // relating to the sharing of framebuffer and renderbuffer objects // between contexts. It appears we have to (a) reattach the color diff --git a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java index bb2983399..42d0a2ec4 100644 --- a/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java +++ b/src/jogl/classes/jogamp/opengl/GLAutoDrawableBase.java @@ -45,8 +45,10 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; +import javax.media.opengl.GLOffscreenAutoDrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLSharedContextSetter; import com.jogamp.common.util.locks.RecursiveLock; import com.jogamp.opengl.GLAutoDrawableDelegate; @@ -59,17 +61,18 @@ import com.jogamp.opengl.GLStateKeeper; * * @see GLAutoDrawable * @see GLAutoDrawableDelegate + * @see GLOffscreenAutoDrawable + * @see GLOffscreenAutoDrawableImpl * @see GLPBufferImpl - * @see GLWindow + * @see com.jogamp.newt.opengl.GLWindow */ -public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeeper, FPSCounter { +public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeeper, FPSCounter, GLSharedContextSetter { public static final boolean DEBUG = GLDrawableImpl.DEBUG; - protected final GLDrawableHelper helper = new GLDrawableHelper(); protected final FPSCounterImpl fpsCounter = new FPSCounterImpl(); protected volatile GLDrawableImpl drawable; // volatile: avoid locking for read-only access - protected GLContextImpl context; + protected volatile GLContextImpl context; protected boolean preserveGLELSAtDestroy; protected GLEventListenerState glels; protected GLStateKeeper.Listener glStateKeeperListener; @@ -79,12 +82,19 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe protected volatile boolean sendDestroy = false; // volatile: maybe written by WindowManager thread w/o locking /** + *

      + * The {@link GLContext} can be assigned later manually via {@link GLAutoDrawable#setContext(GLContext, boolean) setContext(ctx)} + * or it will be created lazily at the 1st {@link GLAutoDrawable#display() display()} method call.
      + * Lazy {@link GLContext} creation will take a shared {@link GLContext} into account + * which has been set {@link #setSharedContext(GLContext) directly} + * or {@link #setSharedAutoDrawable(GLAutoDrawable) via another GLAutoDrawable}. + *

      * @param drawable upstream {@link GLDrawableImpl} instance, * may be null for lazy initialization * @param context upstream {@link GLContextImpl} instance, * may not have been made current (created) yet, * may not be associated w/ drawable yet, - * may be null for lazy initialization + * may be null for lazy initialization at 1st {@link #display()}. * @param ownsDevice pass true if {@link AbstractGraphicsDevice#close()} shall be issued, * otherwise pass false. Closing the device is required in case * the drawable is created w/ it's own new instance, e.g. offscreen drawables, @@ -103,6 +113,16 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe resetFPSCounter(); } + @Override + public final void setSharedContext(GLContext sharedContext) throws IllegalStateException { + helper.setSharedContext(this.context, sharedContext); + } + + @Override + public final void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { + helper.setSharedAutoDrawable(this, sharedAutoDrawable); + } + /** Returns the recursive lock object of the upstream implementation, which synchronizes multithreaded access on top of {@link NativeSurface#lockSurface()}. */ protected abstract RecursiveLock getLock(); @@ -142,16 +162,16 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } /** - * Pulls the {@link GLEventListenerState} from this {@link GLAutoDrawable}. + * Preserves the {@link GLEventListenerState} from this {@link GLAutoDrawable}. * - * @return true if the {@link GLEventListenerState} is pulled successfully from this {@link GLAutoDrawable}, + * @return true if the {@link GLEventListenerState} is preserved successfully from this {@link GLAutoDrawable}, * otherwise false. * - * @throws IllegalStateException if the {@link GLEventListenerState} is already pulled + * @throws IllegalStateException if the {@link GLEventListenerState} is already preserved * - * @see #pushGLEventListenerState() + * @see #restoreGLEventListenerState() */ - protected final boolean pullGLEventListenerState() throws IllegalStateException { + protected final boolean preserveGLEventListenerState() throws IllegalStateException { if( null != glels ) { throw new IllegalStateException("GLEventListenerState already pulled"); } @@ -166,15 +186,15 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe } /** - * Pushes a previously {@link #pullGLEventListenerState() pulled} {@link GLEventListenerState} to this {@link GLAutoDrawable}. + * Restores a previously {@link #preserveGLEventListenerState() preserved} {@link GLEventListenerState} to this {@link GLAutoDrawable}. * - * @return true if the {@link GLEventListenerState} was previously {@link #pullGLEventListenerState() pulled} - * and is pushed successfully to this {@link GLAutoDrawable}, + * @return true if the {@link GLEventListenerState} was previously {@link #preserveGLEventListenerState() preserved} + * and is moved successfully to this {@link GLAutoDrawable}, * otherwise false. * - * @see #pullGLEventListenerState() + * @see #preserveGLEventListenerState() */ - protected final boolean pushGLEventListenerState() { + protected final boolean restoreGLEventListenerState() { if( null != glels ) { glels.moveTo(this); glels = null; @@ -320,7 +340,7 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe protected void destroyImplInLock() { if( preserveGLELSAtDestroy ) { preserveGLStateAtDestroy(false); - pullGLEventListenerState(); + preserveGLEventListenerState(); } if( null != context ) { if( context.isCreated() ) { @@ -389,7 +409,25 @@ public abstract class GLAutoDrawableBase implements GLAutoDrawable, GLStateKeepe final RecursiveLock _lock = getLock(); _lock.lock(); try { - if( null != context ) { + if( null == context ) { + boolean contextCreated = false; + final GLDrawableImpl _drawable = drawable; + if ( null != _drawable && _drawable.isRealized() && 0<_drawable.getWidth()*_drawable.getHeight() ) { + final GLContext[] shareWith = { null }; + if( !helper.isSharedGLContextPending(shareWith) ) { + if( !restoreGLEventListenerState() ) { + context = (GLContextImpl) _drawable.createContext(shareWith[0]); + context.setContextCreationFlags(additionalCtxCreationFlags); + contextCreated = true; + // surface is locked/unlocked implicit by context's makeCurrent/release + helper.invokeGL(_drawable, context, defaultDisplayAction, defaultInitAction); + } + } + } + if(DEBUG) { + System.err.println("GLAutoDrawableBase.defaultDisplay: contextCreated "+contextCreated); + } + } else { // surface is locked/unlocked implicit by context's makeCurrent/release helper.invokeGL(drawable, context, defaultDisplayAction, defaultInitAction); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index dff55488d..377ebd9f5 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -429,7 +429,7 @@ public abstract class GLContextImpl extends GLContext { contextHandle = 0; glDebugHandler = null; // this maybe impl. in a platform specific way to release remaining shared ctx. - if(GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this)) { + if( GLContextShareSet.contextDestroyed(this) && !GLContextShareSet.hasCreatedSharedLeft(this) ) { GLContextShareSet.unregisterSharing(this); } resetStates(false); @@ -647,7 +647,7 @@ public abstract class GLContextImpl extends GLContext { additionalCtxCreationFlags |= GLContext.CTX_OPTION_DEBUG ; } - final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getShareContext(this); + final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getCreatedShare(this); if (null != shareWith) { shareWith.getDrawableImpl().lockSurface(); } diff --git a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java index 70ade34b7..483767b44 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextShareSet.java +++ b/src/jogl/classes/jogamp/opengl/GLContextShareSet.java @@ -40,7 +40,8 @@ package jogamp.opengl; -import java.util.HashMap; +import java.util.ArrayList; +import java.util.IdentityHashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -59,15 +60,15 @@ public class GLContextShareSet { // This class is implemented using a HashMap which maps from all shared contexts // to a share set, containing all shared contexts itself. - private static final Map shareMap = new HashMap(); + private static final Map shareMap = new IdentityHashMap(); private static final Object dummyValue = new Object(); private static class ShareSet { - private Map allShares = new HashMap(); - private Map createdShares = new HashMap(); - private Map destroyedShares = new HashMap(); + private final Map allShares = new IdentityHashMap(); + private final Map createdShares = new IdentityHashMap(); + private final Map destroyedShares = new IdentityHashMap(); - public void add(GLContext ctx) { + public void add(final GLContext ctx) { if (allShares.put(ctx, dummyValue) == null) { if (ctx.isCreated()) { createdShares.put(ctx, dummyValue); @@ -85,9 +86,9 @@ public class GLContextShareSet { return destroyedShares.keySet(); } - public GLContext getCreatedShare(GLContext ignore) { - for (Iterator iter = createdShares.keySet().iterator(); iter.hasNext(); ) { - GLContext ctx = iter.next(); + public GLContext getCreatedShare(final GLContext ignore) { + for (final Iterator iter = createdShares.keySet().iterator(); iter.hasNext(); ) { + final GLContext ctx = iter.next(); if (ctx != ignore) { return ctx; } @@ -95,21 +96,21 @@ public class GLContextShareSet { return null; } - public void contextCreated(GLContext ctx) { - Object res = destroyedShares.remove(ctx); + public void contextCreated(final GLContext ctx) { + final Object res = destroyedShares.remove(ctx); assert res != null : "State of ShareSet corrupted; thought context " + ctx + " should have been in destroyed set but wasn't"; - res = createdShares.put(ctx, dummyValue); - assert res == null : "State of ShareSet corrupted; thought context " + + final Object res2 = createdShares.put(ctx, dummyValue); + assert res2 == null : "State of ShareSet corrupted; thought context " + ctx + " shouldn't have been in created set but was"; } - public void contextDestroyed(GLContext ctx) { - Object res = createdShares.remove(ctx); + public void contextDestroyed(final GLContext ctx) { + final Object res = createdShares.remove(ctx); assert res != null : "State of ShareSet corrupted; thought context " + ctx + " should have been in created set but wasn't"; - res = destroyedShares.put(ctx, dummyValue); - assert res == null : "State of ShareSet corrupted; thought context " + + final Object res2 = destroyedShares.put(ctx, dummyValue); + assert res2 == null : "State of ShareSet corrupted; thought context " + ctx + " shouldn't have been in destroyed set but was"; } } @@ -117,7 +118,7 @@ public class GLContextShareSet { /** Indicate that contexts share1 and share2 will share textures and display lists. Both must be non-null. */ - public static synchronized void registerSharing(GLContext share1, GLContext share2) { + public static synchronized void registerSharing(final GLContext share1, final GLContext share2) { if (share1 == null || share2 == null) { throw new IllegalArgumentException("Both share1 and share2 must be non-null"); } @@ -138,7 +139,7 @@ public class GLContextShareSet { } } - public static synchronized void unregisterSharing(GLContext lastContext) { + public static synchronized void unregisterSharing(final GLContext lastContext) { if (lastContext == null) { throw new IllegalArgumentException("Last context is null"); } @@ -166,7 +167,25 @@ public class GLContextShareSet { } } - private static synchronized Set getCreatedSharedImpl(GLContext context) { + /** Returns true if the given GLContext is shared, otherwise false. */ + public static synchronized boolean isShared(final GLContext context) { + if (context == null) { + throw new IllegalArgumentException("context is null"); + } + final ShareSet share = entryFor(context); + return share != null; + } + + /** Returns one created GLContext shared with the given context, otherwise return null. */ + public static synchronized GLContext getCreatedShare(final GLContext context) { + final ShareSet share = entryFor(context); + if (share == null) { + return null; + } + return share.getCreatedShare(context); + } + + private static synchronized Set getCreatedSharesImpl(final GLContext context) { if (context == null) { throw new IllegalArgumentException("context is null"); } @@ -176,50 +195,56 @@ public class GLContextShareSet { } return null; } - - public static synchronized boolean isShared(GLContext context) { + private static synchronized Set getDestroyedSharesImpl(final GLContext context) { if (context == null) { throw new IllegalArgumentException("context is null"); } final ShareSet share = entryFor(context); - return share != null; + if (share != null) { + return share.getDestroyedShares(); + } + return null; } + /** Returns true if the given GLContext has shared and created GLContext left including itself, otherwise false. */ public static synchronized boolean hasCreatedSharedLeft(GLContext context) { - final Set s = getCreatedSharedImpl(context); - return null != s && s.size()>0 ; + final Set s = getCreatedSharesImpl(context); + return null != s && s.size() > 0; } - /** currently not used .. - public static synchronized Set getCreatedShared(GLContext context) { - final Set s = getCreatedSharedImpl(context); - if (s == null) { - throw new GLException("context is unknown: "+context); - } - return s; + /** Returns a new array-list of created GLContext shared with the given GLContext. */ + public static synchronized ArrayList getCreatedShares(final GLContext context) { + final ArrayList otherShares = new ArrayList(); + final Set createdShares = getCreatedSharesImpl(context); + if( null != createdShares ) { + for (final Iterator iter = createdShares.iterator(); iter.hasNext(); ) { + final GLContext ctx = iter.next(); + if (ctx != context) { + otherShares.add(ctx); + } + } + } + return otherShares; } - public static synchronized Set getDestroyedShared(GLContext context) { - if (context == null) { - throw new IllegalArgumentException("context is null"); - } - ShareSet share = entryFor(context); - if (share == null) { - throw new GLException("context is unknown: "+context); - } - return share.getDestroyedShares(); - } */ - - public static synchronized GLContext getShareContext(GLContext contextToCreate) { - ShareSet share = entryFor(contextToCreate); - if (share == null) { - return null; - } - return share.getCreatedShare(contextToCreate); + /** Returns a new array-list of destroyed GLContext shared with the given GLContext. */ + public static synchronized ArrayList getDestroyedShares(final GLContext context) { + final ArrayList otherShares = new ArrayList(); + final Set destroyedShares = getDestroyedSharesImpl(context); + if( null != destroyedShares ) { + for (final Iterator iter = destroyedShares.iterator(); iter.hasNext(); ) { + final GLContext ctx = iter.next(); + if (ctx != context) { + otherShares.add(ctx); + } + } + } + return otherShares; } - public static synchronized boolean contextCreated(GLContext context) { - ShareSet share = entryFor(context); + /** Mark the given GLContext as being created. */ + public static synchronized boolean contextCreated(final GLContext context) { + final ShareSet share = entryFor(context); if (share != null) { share.contextCreated(context); return true; @@ -227,8 +252,9 @@ public class GLContextShareSet { return false; } - public static synchronized boolean contextDestroyed(GLContext context) { - ShareSet share = entryFor(context); + /** Mark the given GLContext as being destroyed. */ + public static synchronized boolean contextDestroyed(final GLContext context) { + final ShareSet share = entryFor(context); if (share != null) { share.contextDestroyed(context); return true; @@ -245,9 +271,9 @@ public class GLContextShareSet { currently only needed in a fairly esoteric case, when the Java2D/JOGL bridge is active, but the GLBufferSizeTracker mechanism is now always required.) */ - public static void synchronizeBufferObjectSharing(GLContext olderContextOrNull, GLContext newContext) { - GLContextImpl older = (GLContextImpl) olderContextOrNull; - GLContextImpl newer = (GLContextImpl) newContext; + public static void synchronizeBufferObjectSharing(final GLContext olderContextOrNull, final GLContext newContext) { + final GLContextImpl older = (GLContextImpl) olderContextOrNull; + final GLContextImpl newer = (GLContextImpl) newContext; GLBufferSizeTracker tracker = null; if (older != null) { tracker = older.getBufferSizeTracker(); @@ -264,20 +290,20 @@ public class GLContextShareSet { // Internals only below this point - private static ShareSet entryFor(GLContext context) { - return (ShareSet) shareMap.get(context); + private static ShareSet entryFor(final GLContext context) { + return shareMap.get(context); } - private static void addEntry(GLContext context, ShareSet share) { + private static void addEntry(final GLContext context, final ShareSet share) { if (shareMap.get(context) == null) { shareMap.put(context, share); } } - private static ShareSet removeEntry(GLContext context) { - return (ShareSet) shareMap.remove(context); + private static ShareSet removeEntry(final GLContext context) { + return shareMap.remove(context); } - protected static String toHexString(long hex) { + private static String toHexString(long hex) { return "0x" + Long.toHexString(hex); } } diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index 1e4cb38fa..ecb9f7dd1 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -312,6 +312,19 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { return new GLOffscreenAutoDrawableImpl( drawable, context, null, null); } + @Override + public final GLOffscreenAutoDrawable createOffscreenAutoDrawable(AbstractGraphicsDevice deviceReq, + GLCapabilitiesImmutable capsRequested, + GLCapabilitiesChooser chooser, + int width, int height) { + final GLDrawable drawable = createOffscreenDrawable( deviceReq, capsRequested, chooser, width, height ); + drawable.setRealized(true); + if(drawable instanceof GLFBODrawableImpl) { + return new GLOffscreenAutoDrawableImpl.FBOImpl( (GLFBODrawableImpl)drawable, null, null, null ); + } + return new GLOffscreenAutoDrawableImpl( drawable, null, null, null); + } + @Override public final GLDrawable createOffscreenDrawable(AbstractGraphicsDevice deviceReq, GLCapabilitiesImmutable capsRequested, diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java index 4ce6a7121..cf5d7a206 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableHelper.java @@ -82,6 +82,10 @@ public class GLDrawableHelper { private GLAnimatorControl animatorCtrl; private static Runnable nop = new Runnable() { @Override public void run() {} }; + private GLContext sharedContext; + private GLAutoDrawable sharedAutoDrawable; + + public GLDrawableHelper() { reset(); } @@ -98,6 +102,60 @@ public class GLDrawableHelper { glRunnables.clear(); } animatorCtrl = null; + sharedContext = null; + sharedAutoDrawable = null; + } + + public final void setSharedContext(GLContext thisContext, GLContext sharedContext) throws IllegalStateException { + if( null == sharedContext ) { + throw new IllegalStateException("Null shared GLContext"); + } + if( thisContext == sharedContext ) { + throw new IllegalStateException("Shared GLContext same as local"); + } + if( null != this.sharedContext ) { + throw new IllegalStateException("Shared GLContext already set"); + } + if( null != this.sharedAutoDrawable ) { + throw new IllegalStateException("Shared GLAutoDrawable already set"); + } + this.sharedContext = sharedContext; + } + + public final void setSharedAutoDrawable(GLAutoDrawable thisAutoDrawable, GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { + if( null == sharedAutoDrawable ) { + throw new IllegalStateException("Null shared GLAutoDrawable"); + } + if( thisAutoDrawable == sharedAutoDrawable ) { + throw new IllegalStateException("Shared GLAutoDrawable same as this"); + } + if( null != this.sharedContext ) { + throw new IllegalStateException("Shared GLContext already set"); + } + if( null != this.sharedAutoDrawable ) { + throw new IllegalStateException("Shared GLAutoDrawable already set"); + } + this.sharedAutoDrawable = sharedAutoDrawable; + } + + /** + * @param shared returns the shared GLContext, based on set shared GLAutoDrawable + * or GLContext. Maybe null if none is set. + * @return true if initialization is pending due to a set shared GLAutoDrawable or GLContext + * which is not ready yet. Otherwise false. + */ + public boolean isSharedGLContextPending(GLContext[] shared) { + final GLContext shareWith; + final boolean pending; + if ( null != sharedAutoDrawable ) { + shareWith = sharedAutoDrawable.getContext(); + pending = null == shareWith || !shareWith.isCreated(); + } else { + shareWith = sharedContext; + pending = null != shareWith && !shareWith.isCreated(); + } + shared[0] = shareWith; + return pending; } @Override @@ -612,7 +670,7 @@ public class GLDrawableHelper { public final void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { synchronized(listenersLock) { for (int i=0; i < listeners.size(); i++) { - reshape((GLEventListener) listeners.get(i), drawable, x, y, width, height, 0==i /* setViewport */, true /* checkInit */); + reshape(listeners.get(i), drawable, x, y, width, height, 0==i /* setViewport */, true /* checkInit */); } } } diff --git a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java index f175acf28..345f08e4c 100644 --- a/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLOffscreenAutoDrawableImpl.java @@ -48,7 +48,7 @@ public class GLOffscreenAutoDrawableImpl extends GLAutoDrawableDelegate implemen * @param context a valid {@link GLContext}, * may not have been made current (created) yet, * may not be associated w/ drawable yet, - * may be null for lazy initialization + * may be null for lazy initialization at 1st {@link #display()}. * @param upstreamWidget optional UI element holding this instance, see {@link #getUpstreamWidget()}. * @param lock optional upstream lock, may be null */ diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 1f5c26f27..70157fe4b 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -105,7 +105,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private AWTAdapter awtMouseAdapter = null; private AWTAdapter awtKeyAdapter = null; - private AWTWindowClosingProtocol awtWindowClosingProtocol = + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override public void run() { @@ -204,7 +204,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto return false; // NEWT shall proceed requesting the native focus } } - private FocusAction focusAction = new FocusAction(); + private final FocusAction focusAction = new FocusAction(); WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { @Override @@ -559,8 +559,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE, - null); + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 8c1110ed3..4f259fe9a 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -499,21 +499,24 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind if( ( null != context ) ) { throw new InternalError("GLWindow.LifecycleHook.setVisiblePost: "+WindowImpl.getThreadName()+" - Null drawable, but valid context - "+GLWindow.this); } - final NativeSurface ns; - { - final NativeSurface wrapped_ns = window.getWrappedSurface(); - ns = null != wrapped_ns ? wrapped_ns : window; - } - final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities(); - if(null==factory) { - factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); - } - drawable = (GLDrawableImpl) factory.createGLDrawable(ns); - drawable.setRealized(true); + final GLContext[] shareWith = { null }; + if( !helper.isSharedGLContextPending(shareWith) ) { + final NativeSurface ns; + { + final NativeSurface wrapped_ns = window.getWrappedSurface(); + ns = null != wrapped_ns ? wrapped_ns : window; + } + final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) ns.getGraphicsConfiguration().getChosenCapabilities(); + if(null==factory) { + factory = GLDrawableFactory.getFactory(glCaps.getGLProfile()); + } + drawable = (GLDrawableImpl) factory.createGLDrawable(ns); + drawable.setRealized(true); - if( !GLWindow.this.pushGLEventListenerState() ) { - context = (GLContextImpl) drawable.createContext(sharedContext); - context.setContextCreationFlags(additionalCtxCreationFlags); + if( !GLWindow.this.restoreGLEventListenerState() ) { + context = (GLContextImpl) drawable.createContext(shareWith[0]); + context.setContextCreationFlags(additionalCtxCreationFlags); + } } } if(Window.DEBUG_IMPLEMENTATION) { @@ -573,25 +576,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind // OpenGL-related methods and state // - private GLContext sharedContext = null; - @Override protected final RecursiveLock getLock() { return window.getLock(); } - /** - * Specifies an {@link javax.media.opengl.GLContext OpenGL context} to share with.
      - * At native creation, {@link #setVisible(boolean) setVisible(true)}, - * a {@link javax.media.opengl.GLDrawable drawable} and {@link javax.media.opengl.GLContext context} is created besides the native Window itself,
      - * hence you shall set the shared context before. - * - * @param sharedContext The OpenGL context shared by this GLWindow's one - */ - public void setSharedContext(GLContext sharedContext) { - this.sharedContext = sharedContext; - } - @Override public void display() { if( !isNativeValid() || !isVisible() ) { return; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java index 2df14d151..1548c08b5 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableDeadlockAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -61,12 +61,8 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { } protected void runTestGL( GLCapabilities caps ) throws InterruptedException, InvocationTargetException { - final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable( - null, - caps, new DefaultGLCapabilitiesChooser(), - 512, 512, - null - ); + final GLOffscreenAutoDrawable fbod = GLDrawableFactory.getFactory(caps.getGLProfile()).createOffscreenAutoDrawable( + null, caps, new DefaultGLCapabilitiesChooser(), 512, 512); final boolean[] done = {false}; final Runnable pbufferCreationAction = new Runnable() { @@ -77,30 +73,30 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { System.err.println("AA.X"); } }; - + EventQueue.invokeAndWait(new Runnable() { public void run() { Assert.assertTrue(EventQueue.isDispatchThread()); JAWTUtil.lockToolkit(); try { - final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null); + final RunnableTask rTask = new RunnableTask(pbufferCreationAction, new Object(), false, null); System.err.println("BB.0: "+rTask.getSyncObject()); synchronized (rTask.getSyncObject()) { System.err.println("BB.1: "+rTask.getSyncObject()); - new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); + new Thread(rTask, Thread.currentThread().getName()+"-Pbuffer_Creation").start(); try { System.err.println("BB.2"); rTask.getSyncObject().wait(); System.err.println("BB.3"); } catch (InterruptedException e) { throw new RuntimeException(e); - } + } System.err.println("BB.X"); } } finally { JAWTUtil.unlockToolkit(); } - } + } }); Assert.assertTrue(done[0]); fbod.destroy(); @@ -128,4 +124,4 @@ public class TestFBOAutoDrawableDeadlockAWT extends UITestCase { } org.junit.runner.JUnitCore.main( TestFBOAutoDrawableDeadlockAWT.class.getName() ); } -} +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java index 9151a88a5..cc06136d6 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOAutoDrawableFactoryNEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; @@ -52,53 +52,53 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; /** - * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the - * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. *

      - * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. *

      *

      * Extensive FBO reconfiguration (size and sample buffer count) and validation are performed. - *

      + *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { - + static final int widthStep = 800/4; static final int heightStep = 600/4; volatile int szStep = 2; - + interface MyGLEventListener extends GLEventListener { void setMakeSnapshot(); } - + @Test - public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException { + public void testGL2ES2_Demo1_SingleBuffer_Normal() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities(glp); caps.setDoubleBuffered(false); testGLFBODrawableImpl(caps, new GearsES2(0)); } - + @Test - public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException { + public void testGL2ES2_Demo1_DoubleBuffer_Normal() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities(glp); caps.setDoubleBuffered(true); // default testGLFBODrawableImpl(caps, new GearsES2(0)); } - + @Test - public void testGL2ES2_Demo2MSAA4() throws InterruptedException { + public void testGL2ES2_Demo2MSAA4() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final GLCapabilities caps = new GLCapabilities(glp); caps.setSampleBuffers(true); caps.setNumSamples(4); testGLFBODrawableImpl(caps, new MultisampleDemoES2(true)); } - + @Test - public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { + public void testGL2ES2_FBODemoMSAA4() throws InterruptedException { final GLProfile glp = GLProfile.getGL2ES2(); final FBOMix2DemosES2 demo = new FBOMix2DemosES2(0); demo.setDoRotation(false); @@ -107,9 +107,9 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { caps.setNumSamples(4); testGLFBODrawableImpl(caps, demo); } - + @Test - public void testEGLES2_Demo0Normal() throws InterruptedException { + public void testEGLES2_Demo0Normal() throws InterruptedException { if( GLProfile.isAvailable(GLProfile.GLES2) ) { final GLProfile glp = GLProfile.get(GLProfile.GLES2); final GLCapabilities caps = new GLCapabilities(glp); @@ -118,9 +118,9 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { System.err.println("EGL ES2 n/a"); } } - + @Test - public void testEGLES2_Demo0MSAA4() throws InterruptedException { + public void testEGLES2_Demo0MSAA4() throws InterruptedException { if( GLProfile.isAvailable(GLProfile.GLES2) ) { final GLProfile glp = GLProfile.get(GLProfile.GLES2); final GLCapabilities caps = new GLCapabilities(glp); @@ -136,71 +136,71 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { caps.setFBO(true); final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); final GLOffscreenAutoDrawable.FBO glad = (GLOffscreenAutoDrawable.FBO) - factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep, null); + factory.createOffscreenAutoDrawable(null, caps, null, widthStep*szStep, heightStep*szStep); Assert.assertNotNull(glad); - + System.out.println("Realized GLAD: "+glad); System.out.println("Realized GLAD: "+glad.getChosenGLCapabilities()); Assert.assertTrue("FBO drawable is initialized before ctx creation", !glad.isInitialized()); - + glad.display(); // initial display incl. init! { final GLContext context = glad.getContext(); Assert.assertNotNull(context); Assert.assertTrue(context.isCreated()); } - Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized()); - + Assert.assertTrue("FBO drawable is not initialized after ctx creation", glad.isInitialized()); + // // FBO incl. MSAA is fully initialized now // - + final GLCapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); System.out.println("Init GLAD: "+glad); System.out.println("Init GLAD: "+chosenCaps); - + final FBObject fboFront = glad.getFBObject(GL.GL_FRONT); final FBObject fboBack = glad.getFBObject(GL.GL_BACK); - + System.out.println("Init front FBO: "+fboFront); System.out.println("Init back FBO: "+fboBack); - + Assert.assertTrue("FBO drawable is not initialized before ctx creation", glad.isInitialized()); Assert.assertTrue("FBO Front is not initialized before ctx creation", fboFront.isInitialized()); Assert.assertTrue("FBO Back is not initialized before ctx creation", fboBack.isInitialized()); - + if( chosenCaps.getDoubleBuffered() ) { Assert.assertTrue("FBO are equal: "+fboFront+" == "+fboBack, !fboFront.equals(fboBack)); Assert.assertNotSame(fboFront, fboBack); } else { Assert.assertTrue("FBO are not equal: "+fboFront+" != "+fboBack, fboFront.equals(fboBack)); - Assert.assertSame(fboFront, fboBack); + Assert.assertSame(fboFront, fboBack); } - + final FBObject.TextureAttachment texAttachA, texAttachB; - + texAttachA = glad.getTextureBuffer(GL.GL_FRONT); if(0==glad.getNumSamples()) { texAttachB = glad.getTextureBuffer(GL.GL_BACK); } else { texAttachB = null; } - + final FBObject.Colorbuffer colorA, colorB; final FBObject.RenderAttachment depthA, depthB; - + colorA = fboFront.getColorbuffer(0); Assert.assertNotNull(colorA); colorB = fboBack.getColorbuffer(0); Assert.assertNotNull(colorB); - + depthA = fboFront.getDepthAttachment(); Assert.assertNotNull(depthA); depthB = fboBack.getDepthAttachment(); Assert.assertNotNull(depthB); glad.display(); // SWAP_ODD - + if( chosenCaps.getDoubleBuffered() ) { // double buffer or MSAA Assert.assertTrue("Color attachments are equal: "+colorB+" == "+colorA, !colorB.equals(colorA)); @@ -214,16 +214,16 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { Assert.assertEquals(depthA, depthB); Assert.assertSame(depthA, depthB); } - + Assert.assertEquals(texAttachA, colorA); Assert.assertSame(texAttachA, colorA); if(0==glad.getNumSamples()) { Assert.assertEquals(texAttachB, colorB); - Assert.assertSame(texAttachB, colorB); + Assert.assertSame(texAttachB, colorB); } if( chosenCaps.getNumSamples() > 0 ) { - // MSAA + // MSAA FBObject _fboFront = glad.getFBObject(GL.GL_FRONT); FBObject _fboBack = glad.getFBObject(GL.GL_BACK); Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboFront, fboFront.equals(_fboFront)); @@ -251,22 +251,22 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { Assert.assertTrue("FBO are not equal: "+fboFront+" != "+_fboBack, fboFront.equals(_fboBack)); Assert.assertSame(fboFront, _fboBack); } - + glad.addGLEventListener(demo); - + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); glad.addGLEventListener(snapshotGLEventListener); - + glad.display(); // - SWAP_EVEN // 1 - szStep = 2 snapshotGLEventListener.setMakeSnapshot(); glad.display(); // - SWAP_ODD - + // 2, 3 (resize + display) szStep = 1; glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_EVEN - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); // - SWAP_ODD @@ -283,34 +283,34 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { Assert.assertSame(fboFront, _fboFront); Assert.assertEquals(fboBack, _fboBack); Assert.assertSame(fboBack, _fboBack); - + FBObject.Colorbuffer _color = _fboFront.getColorbuffer(0); Assert.assertNotNull(_color); Assert.assertEquals(colorA, _color); Assert.assertSame(colorA, _color); - + FBObject.RenderAttachment _depth = _fboFront.getDepthAttachment(); System.err.println("Resize1.oldDepth "+depthA); System.err.println("Resize1.newDepth "+_depth); Assert.assertNotNull(_depth); - + Assert.assertEquals(depthA, _depth); Assert.assertSame(depthA, _depth); _depth = _fboBack.getDepthAttachment(); Assert.assertNotNull(_depth); Assert.assertEquals(depthB, _depth); Assert.assertSame(depthB, _depth); - + _color = _fboFront.getColorbuffer(colorA); Assert.assertNotNull(_color); Assert.assertEquals(colorA, _color); Assert.assertSame(colorA, _color); } - + // 4, 5 (resize + display) szStep = 4; glad.setSize(widthStep*szStep, heightStep*szStep); // SWAP_ODD - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); // - SWAP_EVEN @@ -330,47 +330,47 @@ public class TestFBOAutoDrawableFactoryNEWT extends UITestCase { } else { // single or MSAA Assert.assertEquals(fboFront, _fboFront); - Assert.assertEquals(fboBack, _fboBack); + Assert.assertEquals(fboBack, _fboBack); } - + FBObject.Colorbuffer _color = fboBack.getColorbuffer(0); Assert.assertNotNull(_color); Assert.assertEquals(colorB, _color); Assert.assertSame(colorB, _color); - + FBObject.RenderAttachment _depth = fboBack.getDepthAttachment(); - Assert.assertNotNull(_depth); // MSAA back w/ depth + Assert.assertNotNull(_depth); // MSAA back w/ depth Assert.assertEquals(depthB, _depth); Assert.assertSame(depthB, _depth); - + _depth = fboFront.getDepthAttachment(); Assert.assertNotNull(_depth); Assert.assertEquals(depthA, _depth); Assert.assertSame(depthA, _depth); - + _color = fboBack.getColorbuffer(colorB); Assert.assertNotNull(_color); Assert.assertEquals(colorB, _color); Assert.assertSame(colorB, _color); } - + // 6 + 7 (samples + display) glad.setNumSamples(glad.getGL(), chosenCaps.getNumSamples() > 0 ? 0 : 4); // triggers repaint snapshotGLEventListener.setMakeSnapshot(); glad.display(); // actual screenshot - + // 8, 9 (resize + samples + display) szStep = 3; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + glad.destroy(); System.out.println("Fin: "+glad); } - + public static void main(String args[]) throws IOException { org.junit.runner.JUnitCore.main(TestFBOAutoDrawableFactoryNEWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java index b3e5e95b0..51dd9df37 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestFBOOffThreadSharedContextMix2DemosES2NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.BufferedReader; @@ -68,10 +68,10 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; /** - * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the - * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + * Toolkit agnostic {@link GLOffscreenAutoDrawable.FBO} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. *

      - * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. *

      *

      * This test simulates shared off-thread GL context / texture usage, @@ -81,7 +81,7 @@ import org.junit.runners.MethodSorters; *

        *
      • 2 {@link GLOffscreenAutoDrawable.FBO} double buffered *
          - *
        • each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)
        • + *
        • each with their own {@link GLContext}, which is shares the {@link GLWindow} one (see below)
        • *
        • both run within one {@link FPSAnimator} @ 30fps
        • *
        • produce a texture
        • *
        • notify the onscreen renderer about new textureID (swapping double buffer)
        • @@ -91,18 +91,18 @@ import org.junit.runners.MethodSorters; *
        • shares it's {@link GLContext} w/ above FBOs
        • *
        • running within one {@link Animator} at v-sync
        • *
        • uses the shared FBO textures and blends them onscreen
        • - *
      • - *
      - *

      + * + * + *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { +public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { static long duration = 500; // ms static int swapInterval = 1; static boolean showFPS = false; static boolean forceES2 = false; static boolean mainRun = false; - + @AfterClass public static void releaseClass() { } @@ -110,37 +110,38 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); System.err.println("requested: vsync "+swapInterval+", "+caps); - + final GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); if(mainRun) { - glWindow.setSize(512, 512); + glWindow.setSize(512, 512); } else { glWindow.setSize(256, 256); } // eager initialization of context glWindow.setVisible(true); - glWindow.display(); + glWindow.display(); final int fbod1_texUnit = 0; final int fbod2_texUnit = 1; - + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable(); // fbodCaps.setDoubleBuffered(false); - + final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, fbod2_texUnit); - // FBOD1 + // FBOD1 final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO) - factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight()); + fbod1.setSharedAutoDrawable(glWindow); fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen! fbod1.setTextureUnit(fbod1_texUnit); { GearsES2 demo0 = new GearsES2(-1); fbod1.addGLEventListener(demo0); - fbod1.addGLEventListener(new GLFinishOnDisplay()); + fbod1.addGLEventListener(new GLFinishOnDisplay()); demo0.setIgnoreFocus(true); } fbod1.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { @@ -151,13 +152,14 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { fbod1.display(); // init System.err.println("FBOD1 "+fbod1); Assert.assertTrue(fbod1.isInitialized()); - + // FBOD2 final GLOffscreenAutoDrawable.FBO fbod2 = (GLOffscreenAutoDrawable.FBO) - factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight()); + fbod2.setSharedAutoDrawable(glWindow); fbod2.setTextureUnit(fbod2_texUnit); fbod2.addGLEventListener(new RedSquareES2(-1)); - fbod2.addGLEventListener(new GLFinishOnDisplay()); + fbod2.addGLEventListener(new GLFinishOnDisplay()); fbod2.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { @Override public void surfaceUpdated(Object updater, NativeSurface ns, long when) { @@ -170,7 +172,7 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { // preinit texIDs mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); mixerDemo.setTexID1(fbod2.getTextureBuffer(GL.GL_FRONT).getName()); - + glWindow.addGLEventListener(mixerDemo); glWindow.addGLEventListener(new GLEventListener() { int i=0, c=0; @@ -178,39 +180,39 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { if(mainRun) return; - + final int dw = drawable.getWidth(); final int dh = drawable.getHeight(); c++; - + if(dw<800) { System.err.println("XXX: "+dw+"x"+dh+", c "+c); if(8 == c) { - snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); + snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); } if(9 == c) { c=0; - new Thread() { + new Thread() { @Override public void run() { glWindow.setSize(dw+256, dh+256); - } }.start(); + } }.start(); } } } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { fbod1.setSize(width, height); fbod2.setSize(width, height); } }); - + final FPSAnimator animator0 = new FPSAnimator(30); animator0.add(fbod1); animator0.add(fbod2); - + final Animator animator1 = new Animator(); animator1.add(glWindow); - + QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); @@ -224,22 +226,22 @@ public class TestFBOOffThreadSharedContextMix2DemosES2NEWT extends UITestCase { } public void windowMoved(WindowEvent e) { System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); - } + } }); - + animator0.start(); animator1.start(); // glWindow.setSkipContextReleaseThread(animator.getThread()); glWindow.setVisible(true); - + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - + animator0.setUpdateFPSFrames(30, showFPS ? System.err : null); animator1.setUpdateFPSFrames(60, showFPS ? System.err : null); - + while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration() - * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. + * The created {@link GLOffscreenAutoDrawable.FBO} is being used to run the {@link GLEventListener}. *

      *

      * This test simulates shared on-thread GL context / texture usage, @@ -79,7 +79,7 @@ import org.junit.runners.MethodSorters; *

        *
      • 1 {@link GLOffscreenAutoDrawable.FBO} double buffered *
          - * + * *
        • running within common {@link Animator} @ 60fps
        • *
        • produce a texture
        • *
        • notify the onscreen renderer about new textureID (swapping double buffer)
        • @@ -89,18 +89,18 @@ import org.junit.runners.MethodSorters; *
        • shares it's {@link GLContext} w/ above FBO
        • *
        • running within common {@link Animator} @ 60fps
        • *
        • uses the shared FBO texture and draws it onscreen
        • - *
      • - *
      - *

      + * + * + *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { +public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { static long duration = 500; // ms static int swapInterval = 1; static boolean showFPS = false; static boolean forceES2 = false; static boolean mainRun = false; - + @AfterClass public static void releaseClass() { } @@ -108,30 +108,31 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); System.err.println("requested: vsync "+swapInterval+", "+caps); - + final GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test (translucent "+!caps.isBackgroundOpaque()+"), swapInterval "+swapInterval); if(mainRun) { - glWindow.setSize(512, 512); + glWindow.setSize(512, 512); } else { glWindow.setSize(256, 256); } // eager initialization of context glWindow.setVisible(true); - glWindow.display(); + glWindow.display(); final int fbod1_texUnit = 0; - + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); GLCapabilities fbodCaps = (GLCapabilities) caps.cloneMutable(); // fbodCaps.setDoubleBuffered(false); - + final Mix2TexturesES2 mixerDemo = new Mix2TexturesES2(1, fbod1_texUnit, 0); - // FBOD1 + // FBOD1 final GLOffscreenAutoDrawable.FBO fbod1 = (GLOffscreenAutoDrawable.FBO) - factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight(), glWindow.getContext()); + factory.createOffscreenAutoDrawable(null, fbodCaps, null, glWindow.getWidth(), glWindow.getHeight()); + fbod1.setSharedAutoDrawable(glWindow); fbod1.setUpstreamWidget(glWindow); // connect the real GLWindow (mouse/key) to offscreen! fbod1.setTextureUnit(fbod1_texUnit); { @@ -148,10 +149,10 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { fbod1.display(); // init System.err.println("FBOD1 "+fbod1); Assert.assertTrue(fbod1.isInitialized()); - + // preinit texIDs mixerDemo.setTexID0(fbod1.getTextureBuffer(GL.GL_FRONT).getName()); - + glWindow.addWindowListener(new WindowAdapter() { @Override public void windowResized(WindowEvent e) { @@ -165,33 +166,33 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { public void dispose(GLAutoDrawable drawable) {} public void display(GLAutoDrawable drawable) { if(mainRun) return; - + final int dw = drawable.getWidth(); final int dh = drawable.getHeight(); c++; - + if(dw<800) { System.err.println("XXX: "+dw+"x"+dh+", c "+c); if(8 == c) { - snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); + snapshot(i++, "msaa"+fbod1.getNumSamples(), drawable.getGL(), screenshot, TextureIO.PNG, null); } if(9 == c) { c=0; - new Thread() { + new Thread() { @Override public void run() { glWindow.setSize(dw+256, dh+256); - } }.start(); + } }.start(); } } } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); - + final Animator animator1 = new Animator(); animator1.add(fbod1); animator1.add(glWindow); - + QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); @@ -205,20 +206,20 @@ public class TestFBOOnThreadSharedContext1DemoES2NEWT extends UITestCase { } public void windowMoved(WindowEvent e) { System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); - } + } }); - + animator1.start(); // glWindow.setSkipContextReleaseThread(animator.getThread()); glWindow.setVisible(true); - + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - + animator1.setUpdateFPSFrames(60, showFPS ? System.err : null); - + while(!quitAdapter.shouldQuit() && animator1.isAnimating() && animator1.getTotalFPSDuration() - * Creates a {@link GLDrawable} using the + * Creates a {@link GLDrawable} using the * {@link GLDrawableFactory#createGLDrawable(javax.media.nativewindow.NativeSurface) factory model}. * The {@link GLContext} is derived {@link GLDrawable#createContext(GLContext) from the drawable}. *

      *

      * Finally a {@link GLAutoDrawableDelegate} is created with the just created {@link GLDrawable} and {@link GLContext}. - * It is being used to run the {@link GLEventListener}. - *

      + * It is being used to run the {@link GLEventListener}. + *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLAutoDrawableDelegateNEWT extends UITestCase { static long duration = 500; // ms - + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); - + // // Create native windowing resources .. X11/Win/OSX - // + // final Window window = NewtFactory.createWindow(reqGLCaps); Assert.assertNotNull(window); window.setSize(640, 400); @@ -85,24 +85,24 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForVisible(window, true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(window, true)); System.out.println("Window: "+window.getClass().getName()); - + final GLDrawable drawable = factory.createGLDrawable(window); Assert.assertNotNull(drawable); drawable.setRealized(true); - - final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, drawable.createContext(null), window, false, null) { + + final GLAutoDrawableDelegate glad = new GLAutoDrawableDelegate(drawable, null, window, false, null) { @Override protected void destroyImplInLock() { super.destroyImplInLock(); // destroys drawable/context window.destroy(); // destroys the actual window, incl. the device } }; - + window.setWindowDestroyNotifyAction( new Runnable() { public void run() { glad.windowDestroyNotifyOp(); } } ); - + window.addWindowListener(new WindowAdapter() { @Override public void windowRepaint(WindowUpdateEvent e) { @@ -116,13 +116,13 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { }); glad.addGLEventListener(demo); - + QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); window.addKeyListener(quitAdapter); window.addWindowListener(quitAdapter); - + Animator animator = new Animator(); animator.setUpdateFPSFrames(60, System.err); animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); @@ -130,17 +130,17 @@ public class TestGLAutoDrawableDelegateNEWT extends UITestCase { animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); - + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() - * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. - *

      + * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { @@ -71,7 +71,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { } return new GLCapabilities(GLProfile.get(profile)); } - + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { System.out.println("Requested GL Caps: "+reqGLCaps); final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); @@ -79,15 +79,15 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { System.out.println("Expected GL Caps: "+expGLCaps); // - // Create native OpenGL resources .. XGL/WGL/CGL .. + // Create native OpenGL resources .. XGL/WGL/CGL .. // equivalent to GLAutoDrawable methods: setVisible(true) // - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null); - + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep); + Assert.assertNotNull(glad); - System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); Assert.assertTrue(glad.isRealized()); - + // Check caps of NativeWindow config w/o GL final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); System.out.println("Drawable Caps Pre_GL : "+chosenCaps); @@ -95,7 +95,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { Assert.assertTrue(chosenCaps.getGreenBits()>4); Assert.assertTrue(chosenCaps.getBlueBits()>4); Assert.assertTrue(chosenCaps.getRedBits()>4); - + glad.display(); // force native context creation // Check caps of GLDrawable after realization @@ -113,45 +113,45 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); - /** Single/Double buffer cannot be checked since result may vary .. + /** Single/Double buffer cannot be checked since result may vary .. if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { // dbl buffer may be disabled w/ offscreen pbuffer and bitmap Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); - } */ + } */ glad.addGLEventListener(demo); - + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); glad.addGLEventListener(snapshotGLEventListener); - + glad.display(); // initial resize/display - + // 1 - szStep = 2 - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 2, 3 (resize + display) szStep = 1; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 4, 5 (resize + display) szStep = 4; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + Thread.sleep(50); - + glad.destroy(); - System.out.println("Fin Drawable: "+glad); + System.out.println("Fin Drawable: "+glad); } @Test @@ -164,8 +164,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { if(null != f) { System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); } - } - + } + @Test public void testES2OffScreenAutoDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -182,7 +182,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setFBO(true); doTest(reqGLCaps, new GearsES2(1)); } - + @Test public void testES2OffScreenFBOSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -191,8 +191,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setFBO(true); reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); - } - + } + @Test public void testES2OffScreenFBODblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -202,7 +202,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new GearsES2(1)); } - + @Test public void testES2OffScreenFBODblBufMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -212,8 +212,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } - + } + @Test public void testES2OffScreenFBODblBufStencilMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -224,8 +224,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } - + } + @Test public void testES2OffScreenPbufferDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -233,8 +233,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setOnscreen(false); reqGLCaps.setPBuffer(true); doTest(reqGLCaps, new GearsES2(1)); - } - + } + @Test public void testES2OffScreenPbufferSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -244,7 +244,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new GearsES2(1)); } - + // Might be reduced to !stencil @Test public void testES2OffScreenPbufferDblBufStencil() throws InterruptedException { @@ -255,7 +255,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new GearsES2(1)); } - + // Might be reduced to !MSAA @Test public void testES2OffScreenPbufferDblBufMSAA() throws InterruptedException { @@ -266,8 +266,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } - + } + // Might be reduced to !stencil && !MSAA @Test public void testES2OffScreenPbufferDblBufStencilMSAA() throws InterruptedException { @@ -279,9 +279,9 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } + } - /** NOT Implemented: + /** NOT Implemented: // Might be reduced to !double-buff @Test public void testES2OffScreenBitmapDblBuf() throws InterruptedException { @@ -291,7 +291,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testES2OffScreenBitmapSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GLES2); @@ -301,7 +301,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !stencil @Test public void testES2OffScreenBitmapDblBufStencil() throws InterruptedException { @@ -312,7 +312,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new GearsES2(1)); } - + // Might be reduced to !MSAA @Test public void testES2OffScreenBitmapDblBufMSAA() throws InterruptedException { @@ -323,8 +323,8 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); - } - + } + // Might be reduced to !stencil && !MSAA @Test public void testES2OffScreenBitmapDblBufStencilMSAA() throws InterruptedException { @@ -337,7 +337,7 @@ public class TestGLAutoDrawableFactoryES2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new GearsES2(1)); } */ - + public static void main(String args[]) throws IOException { org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryES2OffscrnCapsNEWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java index 06dc7c83e..09e211332 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; @@ -52,11 +52,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; /** - * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the - * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. *

      - * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. - *

      + * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { @@ -71,7 +71,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { } return new GLCapabilities(GLProfile.get(profile)); } - + void doTest(GLCapabilitiesImmutable reqGLCaps, GLEventListener demo) throws InterruptedException { System.out.println("Requested GL Caps: "+reqGLCaps); final GLDrawableFactory factory = GLDrawableFactory.getFactory(reqGLCaps.getGLProfile()); @@ -79,15 +79,15 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { System.out.println("Expected GL Caps: "+expGLCaps); // - // Create native OpenGL resources .. XGL/WGL/CGL .. + // Create native OpenGL resources .. XGL/WGL/CGL .. // equivalent to GLAutoDrawable methods: setVisible(true) // - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null); - + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep); + Assert.assertNotNull(glad); - System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); Assert.assertTrue(glad.isRealized()); - + // Check caps of NativeWindow config w/o GL final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); System.out.println("Drawable Caps Pre_GL : "+chosenCaps); @@ -95,7 +95,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { Assert.assertTrue(chosenCaps.getGreenBits()>4); Assert.assertTrue(chosenCaps.getBlueBits()>4); Assert.assertTrue(chosenCaps.getRedBits()>4); - + glad.display(); // force native context creation // Check caps of GLDrawable after realization @@ -113,45 +113,45 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); - /** Single/Double buffer cannot be checked since result may vary .. + /** Single/Double buffer cannot be checked since result may vary .. if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { // dbl buffer may be disabled w/ offscreen pbuffer and bitmap Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); - } */ + } */ glad.addGLEventListener(demo); - + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); glad.addGLEventListener(snapshotGLEventListener); - + glad.display(); // initial resize/display - + // 1 - szStep = 2 - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 2, 3 (resize + display) szStep = 1; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 4, 5 (resize + display) szStep = 4; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + Thread.sleep(50); - + glad.destroy(); - System.out.println("Fin Drawable: "+glad); + System.out.println("Fin Drawable: "+glad); } @Test @@ -164,8 +164,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { if(null != f) { System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); } - } - + } + @Test public void testGL2OffScreenAutoDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -182,7 +182,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setFBO(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenFBOSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -191,8 +191,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setFBO(true); reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new Gears(1)); - } - + } + @Test public void testGL2OffScreenFBODblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -202,7 +202,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenFBODblBufMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -212,8 +212,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + @Test public void testGL2OffScreenFBODblBufStencilMSAA() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -224,8 +224,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + @Test public void testGL2OffScreenPbufferDblBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -233,8 +233,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setOnscreen(false); reqGLCaps.setPBuffer(true); doTest(reqGLCaps, new Gears(1)); - } - + } + @Test public void testGL2OffScreenPbufferSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -244,8 +244,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new Gears(1)); } - - // Might be reduced to !stencil + + // Might be reduced to !stencil @Test public void testGL2OffScreenPbufferDblBufStencil() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -255,7 +255,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !MSAA @Test public void testGL2OffScreenPbufferDblBufMSAA() throws InterruptedException { @@ -266,8 +266,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + // Might be reduced to !stencil && !MSAA @Test public void testGL2OffScreenPbufferDblBufStencilMSAA() throws InterruptedException { @@ -279,9 +279,9 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - - + } + + // Might be reduced to !double-buff @Test public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { @@ -291,7 +291,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenBitmapDblBufRGBA8881() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -304,7 +304,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenBitmapDblBufRGB555() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -317,7 +317,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenBitmapDblBufRGBA5551() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -330,7 +330,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + @Test public void testGL2OffScreenBitmapSglBuf() throws InterruptedException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2); @@ -340,7 +340,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setDoubleBuffered(false); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !stencil @Test public void testGL2OffScreenBitmapDblBufStencil() throws InterruptedException { @@ -351,7 +351,7 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setStencilBits(1); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !MSAA @Test public void testGL2OffScreenBitmapDblBufMSAA() throws InterruptedException { @@ -362,8 +362,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + // Might be reduced to !stencil && !MSAA @Test public void testGL2OffScreenBitmapDblBufStencilMSAA() throws InterruptedException { @@ -375,8 +375,8 @@ public class TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + public static void main(String args[]) throws IOException { org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java index 75609224e..f35f8c8b0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; @@ -52,11 +52,11 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.UITestCase; /** - * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the - * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. + * Toolkit agnostic {@link GLOffscreenAutoDrawable} tests using the + * {@link GLDrawableFactory#createOffscreenAutoDrawable(javax.media.nativewindow.AbstractGraphicsDevice, GLCapabilitiesImmutable, javax.media.opengl.GLCapabilitiesChooser, int, int, GLContext) factory model}. *

      - * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. - *

      + * The created {@link GLOffscreenAutoDrawable} is being used to run the {@link GLEventListener}. + *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { @@ -71,15 +71,15 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { System.out.println("Expected GL Caps: "+expGLCaps); // - // Create native OpenGL resources .. XGL/WGL/CGL .. + // Create native OpenGL resources .. XGL/WGL/CGL .. // equivalent to GLAutoDrawable methods: setVisible(true) // - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep, null); - + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, reqGLCaps, null, widthStep*szStep, heightStep*szStep); + Assert.assertNotNull(glad); - System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); + System.out.println("Drawable Pre-GL(0): "+glad.getClass().getName()+", "+glad.getNativeSurface().getClass().getName()); Assert.assertTrue(glad.isRealized()); - + // Check caps of NativeWindow config w/o GL final CapabilitiesImmutable chosenCaps = glad.getChosenGLCapabilities(); System.out.println("Drawable Caps Pre_GL : "+chosenCaps); @@ -87,7 +87,7 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { Assert.assertTrue(chosenCaps.getGreenBits()>4); Assert.assertTrue(chosenCaps.getBlueBits()>4); Assert.assertTrue(chosenCaps.getRedBits()>4); - + glad.display(); // force native context creation // Check caps of GLDrawable after realization @@ -105,45 +105,45 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { Assert.assertEquals(expGLCaps.isFBO(), chosenGLCaps.isFBO()); Assert.assertEquals(expGLCaps.isPBuffer(), chosenGLCaps.isPBuffer()); Assert.assertEquals(expGLCaps.isBitmap(), chosenGLCaps.isBitmap()); - /** Single/Double buffer cannot be checked since result may vary .. + /** Single/Double buffer cannot be checked since result may vary .. if(chosenGLCaps.isOnscreen() || chosenGLCaps.isFBO()) { // dbl buffer may be disabled w/ offscreen pbuffer and bitmap Assert.assertEquals(expGLCaps.getDoubleBuffered(), chosenGLCaps.getDoubleBuffered()); - } */ + } */ glad.addGLEventListener(demo); - + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); glad.addGLEventListener(snapshotGLEventListener); - + glad.display(); // initial resize/display - + // 1 - szStep = 2 - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 2, 3 (resize + display) szStep = 1; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + // 4, 5 (resize + display) szStep = 4; glad.setSize(widthStep*szStep, heightStep*szStep); - Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), + Assert.assertTrue("Size not reached: Expected "+(widthStep*szStep)+"x"+(heightStep*szStep)+", Is "+glad.getWidth()+"x"+glad.getHeight(), AWTRobotUtil.waitForSize(glad, widthStep*szStep, heightStep*szStep)); snapshotGLEventListener.setMakeSnapshot(); glad.display(); - + Thread.sleep(50); - + glad.destroy(); - System.out.println("Fin Drawable: "+glad); + System.out.println("Fin Drawable: "+glad); } @Test @@ -156,8 +156,8 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { if(null != f) { System.err.println(JoglVersion.getDefaultOpenGLInfo(f.getDefaultDevice(), null, true).toString()); } - } - + } + // Might be reduced to !double-buff @Test public void testGL2OffScreenBitmapDblBuf() throws InterruptedException { @@ -166,7 +166,7 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { reqGLCaps.setBitmap(true); doTest(reqGLCaps, new Gears(1)); } - + // Might be reduced to !MSAA @Test public void testGL2OffScreenBitmapDblBufMSAA() throws InterruptedException { @@ -176,8 +176,8 @@ public class TestGLAutoDrawableFactoryGLnBitmapCapsNEWT extends UITestCase { reqGLCaps.setSampleBuffers(true); reqGLCaps.setNumSamples(4); doTest(reqGLCaps, new Gears(1)); - } - + } + public static void main(String args[]) throws IOException { org.junit.runner.JUnitCore.main(TestGLAutoDrawableFactoryGLnBitmapCapsNEWT.class.getName()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java index f9ab6c4b3..4bc8e7ee3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLExtensionQueryOffscreen.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.util.Collections; @@ -47,14 +47,14 @@ import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLExtensionQueryOffscreen { - + public static void main(String[] args) { TestGLExtensionQueryOffscreen instance = new TestGLExtensionQueryOffscreen(); instance.testJogl2ExtensionCheck1(); instance.testJogl2ExtensionCheck2(); } - /** + /** * @deprecated This test uses a non public API in jogamp.opengl.* and hence is not recommended */ @Test @@ -74,13 +74,13 @@ public class TestGLExtensionQueryOffscreen { System.out.println("SharedContext: "+sharedContext); System.out.println("SharedContext: "+setExtensions); } - + @Test public void testJogl2ExtensionCheck2() { final GLCapabilities caps = new GLCapabilities(GLProfile.getDefault()); - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); - + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + final GLOffscreenAutoDrawable drawable = factory.createOffscreenAutoDrawable(null, caps, null, 256, 256); + drawable.display(); // trigger context creation .. final GLContext context = drawable.getContext(); context.makeCurrent(); String extensions; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java index c8cc294a2..83e55b7e0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestNEWTCloseX11DisplayBug565.java @@ -30,16 +30,16 @@ public class TestNEWTCloseX11DisplayBug565 { try { for ( int j = 0; j < 10; j++ ) { final int open0; - if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { open0 = X11Util.getOpenDisplayConnectionNumber(); } else { open0 = 0; } - + GLCapabilitiesImmutable caps = new GLCapabilities( GLProfile.getDefault( ) ); - + GLWindow window = GLWindow.create(caps); - window.setTitle("NEWT Resource X11 Leak - #" + j ); + window.setTitle("NEWT Resource X11 Leak - #" + j ); window.setSize( 128, 128 ); window.setVisible(true); window.display(); @@ -69,7 +69,7 @@ public class TestNEWTCloseX11DisplayBug565 { try { for ( int j = 0; j < 10; j++ ) { final int open0; - if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { open0 = X11Util.getOpenDisplayConnectionNumber(); } else { open0 = 0; @@ -111,7 +111,7 @@ public class TestNEWTCloseX11DisplayBug565 { try { for ( int j = 0; j < 10; j++ ) { final int open0; - if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { + if(NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(false)) { open0 = X11Util.getOpenDisplayConnectionNumber(); } else { open0 = 0; @@ -121,13 +121,7 @@ public class TestNEWTCloseX11DisplayBug565 { GLOffscreenAutoDrawable buffer = GLDrawableFactory.getFactory( glp ).createOffscreenAutoDrawable( - null, - caps, - new DefaultGLCapabilitiesChooser(), - 256, - 256, - null - ); + null, caps, new DefaultGLCapabilitiesChooser(), 256, 256); buffer.display(); buffer.destroy(); @@ -146,10 +140,10 @@ public class TestNEWTCloseX11DisplayBug565 { Assert.fail(e.getMessage()); } } - + public static void main(String args[]) { org.junit.runner.JUnitCore.main(TestNEWTCloseX11DisplayBug565.class.getName()); } - + } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java index a3eb6db84..77657f6f1 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextListAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import javax.media.opengl.GLCapabilities; @@ -73,7 +73,7 @@ public class TestSharedContextListAWT extends UITestCase { } private void initShared() { - sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null); + sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height); Assert.assertNotNull(sharedDrawable); sharedGears = new Gears(); Assert.assertNotNull(sharedGears); @@ -86,8 +86,8 @@ public class TestSharedContextListAWT extends UITestCase { Assert.assertNotNull(sharedDrawable); sharedDrawable.destroy(); } - - protected void setFrameTitle(final Frame f, final boolean useShared) + + protected void setFrameTitle(final Frame f, final boolean useShared) throws InterruptedException, InvocationTargetException { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -99,12 +99,13 @@ public class TestSharedContextListAWT extends UITestCase { protected GLCanvas runTestGL(final Frame frame, final Animator animator, final int x, final int y, final boolean useShared, final boolean vsync) throws InterruptedException, InvocationTargetException { - final GLCanvas glCanvas = new GLCanvas(caps, useShared ? sharedDrawable.getContext() : null); + final GLCanvas glCanvas = new GLCanvas(caps); Assert.assertNotNull(glCanvas); + glCanvas.setSharedAutoDrawable(sharedDrawable); frame.add(glCanvas); frame.setLocation(x, y); frame.setSize(width, height); - + Gears gears = new Gears(vsync ? 1 : 0); if(useShared) { gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3()); @@ -133,22 +134,22 @@ public class TestSharedContextListAWT extends UITestCase { final GLCanvas glc1 = runTestGL(f1, animator, 0, 0, true, false); int x0 = f1.getX(); int y0 = f1.getY(); - - final GLCanvas glc2 = runTestGL(f2, animator, + + final GLCanvas glc2 = runTestGL(f2, animator, x0+width, - y0+0, + y0+0, true, false); - - final GLCanvas glc3 = runTestGL(f3, animator, - x0+0, - y0+height, + + final GLCanvas glc3 = runTestGL(f3, animator, + x0+0, + y0+height, false, true); setFrameTitle(f1, true); setFrameTitle(f2, true); setFrameTitle(f3, false); - - animator.setUpdateFPSFrames(1, null); + + animator.setUpdateFPSFrames(1, null); animator.start(); while(animator.isAnimating() && animator.getTotalFPSDuration() + * This is achieved by creating a master GLContext to an offscreen invisible GLAutoDrawable, + * which is then shared by the 3 GLContext of the three GLWindow instances. + *

      + *

      + * The original VBO is created by attaching a GearsES1 instance to + * the master GLAutoDrawable and initializing it. + *

      + *

      + * Above method allows random creation of all GLWindow instances. + *

      + *

      + * One animator is being used, hence the GLWindow, GLDrawable and GLContext + * creation of all 3 GLWindows is sequential. + *

      + */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestSharedContextVBOES1NEWT extends UITestCase { static GLProfile glp; static GLCapabilities caps; static int width, height; - GLOffscreenAutoDrawable sharedDrawable; + GLAutoDrawable sharedDrawable; GearsES1 sharedGears; @BeforeClass @@ -69,14 +91,22 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { } } - private void initShared() { - sharedDrawable = GLDrawableFactory.getFactory(glp).createOffscreenAutoDrawable(null, caps, null, width, height, null); + private void initShared() throws InterruptedException { + GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile()); + dummyDrawable.setRealized(true); + sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { }; Assert.assertNotNull(sharedDrawable); + Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true)); + sharedGears = new GearsES1(); Assert.assertNotNull(sharedGears); sharedDrawable.addGLEventListener(sharedGears); // init and render one frame, which will setup the Gears display lists sharedDrawable.display(); + final GLContext ctxM = sharedDrawable.getContext(); + Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true)); + Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared()); + Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears()); } private void releaseShared() { @@ -87,6 +117,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException { GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared); if(useShared) { glWindow.setSharedContext(sharedDrawable.getContext()); @@ -96,7 +127,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { GearsES1 gears = new GearsES1(vsync ? 1 : 0); if(useShared) { - gears.setGears(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3()); + gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3()); } glWindow.addGLEventListener(gears); @@ -105,9 +136,17 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { glWindow.setVisible(true); Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); - - glWindow.setPosition(x, y); - + Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + + System.err.println("Master Context: "); + MiscUtils.dumpSharedGLContext(sharedDrawable.getContext()); + System.err.println("New Context: "); + MiscUtils.dumpSharedGLContext(glWindow.getContext()); + if( useShared ) { + Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared()); + } + Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared()); + Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears()); return glWindow; } @@ -117,11 +156,11 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { Animator animator = new Animator(); GLWindow f1 = runTestGL(animator, 0, 0, true, false); InsetsImmutable insets = f1.getInsets(); - GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), + GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), f1.getY()+0, true, false); - GLWindow f3 = runTestGL(animator, f1.getX()+0, - f1.getY()+height+insets.getTotalHeight(), false, true); - animator.setUpdateFPSFrames(1, null); + GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), false, true); + animator.setUpdateFPSFrames(1, null); animator.start(); while(animator.isAnimating() && animator.getTotalFPSDuration() + * This is achieved by using the 1st GLCanvas as the master + * and using the build-in blocking mechanism to postpone creation + * of the 2nd and 3rd GLCanvas until the 1st GLCanvas's GLContext becomes created. + *

      + *

      + * Above method allows random creation of the 1st GLCanvas, which triggers + * creation of the dependent other GLCanvas sharing it's GLContext. + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2AWT3 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + protected GLCanvas createGLCanvas(final Frame frame, int x, int y, GearsES2 gears) throws InterruptedException { + final GLCanvas glCanvas = new GLCanvas(caps); + Assert.assertNotNull(glCanvas); + glCanvas.addGLEventListener(gears); + frame.add(glCanvas); + frame.setLocation(x, y); + frame.setSize(width, height); + frame.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true"); + return glCanvas; + } + + @Test + public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + final Frame f1 = new Frame(); + final Animator animator = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1); + animator.add(c1); + + final Frame f2 = new Frame(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLCanvas c2 = createGLCanvas(f2, f1.getX()+width, + f1.getY()+0, g2); + c2.setSharedAutoDrawable(c1); + animator.add(c2); + + final Frame f3 = new Frame(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLCanvas c3 = createGLCanvas(f3, f1.getX()+0, + f1.getY()+height, g3); + c3.setSharedAutoDrawable(c1); + animator.add(c3); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f2.setVisible(true); // shall wait until f1 is ready + f1.setVisible(true); // master .. + f3.setVisible(true); // shall wait until f1 is ready + } } ); + animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = c1.getContext(); + final GLContext ctx2 = c2.getContext(); + final GLContext ctx3 = c3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + f1.dispose(); + f2.dispose(); + f3.dispose(); + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false)); + } + + @Test + public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + final Frame f1 = new Frame(); + final Animator a1 = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLCanvas c1 = createGLCanvas(f1, 0, 0, g1); + a1.add(c1); + a1.start(); + // f1.setVisible(true); // we do this post f2 .. to test pending creation! + + final Frame f2 = new Frame(); + final Animator a2 = new Animator(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLCanvas c2 = createGLCanvas(f2, f1.getX()+width, f1.getY()+0, g2); + c2.setSharedAutoDrawable(c1); + a2.add(c2); + a2.start(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f2.setVisible(true); + } } ); + + Thread.sleep(200); // wait a while .. + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f1.setVisible(true); // test pending creation of f2 + } } ); + + final Frame f3 = new Frame(); + final Animator a3 = new Animator(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLCanvas c3 = createGLCanvas(f3, f1.getX()+0, f1.getY()+height, g3); + c3.setSharedAutoDrawable(c1); + a3.add(c3); + a3.start(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f3.setVisible(true); + } } ); + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = c1.getContext(); + final GLContext ctx2 = c2.getContext(); + final GLContext ctx3 = c3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + a1.stop(); + a2.stop(); + a3.stop(); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + f1.dispose(); + f2.dispose(); + f3.dispose(); + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false)); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i 0 ) { - // instable on OSX .. driver/OS bug when multi threading (3 animator) - System.err.println("Shared context w/ 3 context each running in there own thread is instable here on OSX 10.7.4/NVidia,"); - System.err.println("SIGSEGV @ glDrawArrays / glBindBuffer .. any shared VBO."); - System.err.println("Seems to run fine on 10.6.8/NVidia."); - return; - } - initShared(false); - Animator animator1 = new Animator(); - Animator animator2 = new Animator(); - Animator animator3 = new Animator(); - GLWindow f1 = runTestGL(animator1, 0, 0, true, false); - InsetsImmutable insets = f1.getInsets(); - GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(), - f1.getY()+0, true, false); - GLWindow f3 = runTestGL(animator3, f1.getX()+0, - f1.getY()+height+insets.getTotalHeight(), true, false); - - try { - Thread.sleep(duration); - } catch(Exception e) { - e.printStackTrace(); - } - animator1.stop(); - animator2.stop(); - animator3.stop(); - - f1.destroy(); - f2.destroy(); - f3.destroy(); - Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - - releaseShared(); - } - - static long duration = 2000; // ms - - public static void main(String args[]) { - for(int i=0; i + * This is achieved by relying on the sequential creation + * of the 3 GLWindows with their GLDrawable and GLContext. + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2NEWT0 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + protected GLWindow runTestGL(Animator animator, int x, int y, GearsES2 gears, GLContext sharedContext) throws InterruptedException { + final boolean useShared = null != sharedContext; + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); + glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared); + if(useShared) { + glWindow.setSharedContext(sharedContext); + } + glWindow.setSize(width, height); + glWindow.addGLEventListener(gears); + + animator.add(glWindow); + glWindow.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); + glWindow.display(); + Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + Assert.assertTrue("Gears not initialized", gears.waitForInit(true)); + + return glWindow; + } + + @Test + public void testCommonAnimatorShared() throws InterruptedException { + final Animator animator = new Animator(); + + // + // 1st + // + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = runTestGL(animator, 0, 0, g1, null); + final GLContext ctx1 = f1.getContext(); + Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared()); + final InsetsImmutable insets = f1.getInsets(); + + System.err.println("XXX-C-2.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + + // + // 2nd + // + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3()); + final GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2, f1.getContext()); + final GLContext ctx2 = f2.getContext(); + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + System.err.println("XXX-C-2.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-2.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + + Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size()); + } + + // + // 3rd + // + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGearsObjects(g1.getGear1(), g1.getGear2(), g1.getGear3()); + final GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3, f1.getContext()); + + final GLContext ctx3 = f3.getContext(); + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + animator.start(); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-D-2.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-D-2.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-D-2.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 1, ctx3Shares.size()); + } + + f2.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-D-1.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-D-1.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-D-1.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 1, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 1, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 0, ctx3Shares.size()); + } + + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-D-0.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-D-0.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-D-0.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is shared", !ctx1.isShared()); + Assert.assertTrue("Ctx2 is shared", !ctx2.isShared()); + Assert.assertTrue("Ctx3 is shared", !ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 0, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 0, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 0, ctx3Shares.size()); + } + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i + * This is achieved by creating a master GLContext to an offscreen invisible GLAutoDrawable, + * which is then shared by the 3 GLContext of the three GLWindow instances. + *

      + *

      + * The original VBO is created by attaching a GearsES2 instance to + * the master GLAutoDrawable and initializing it. + *

      + *

      + * Above method allows random creation of all GLWindow instances. + *

      + *

      + * One tests uses only one animator, where the GLWindow, GLDrawable and GLContext + * creation of all 3 GLWindows is sequential. + *

      + *

      + * Another tests uses 3 animator, one for each GLWindow, + * where the GLWindow, GLDrawable and GLContext creation + * of all 3 GLWindows is random. + * This fact benefits from the master GLContext/GLAutoDrawable, + * since it is guaranteed it exist and is realized at the time of the shared + * GLWindow creation. + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2NEWT1 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + GLAutoDrawable sharedDrawable; + GearsES2 sharedGears; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + private void initShared(boolean onscreen) throws InterruptedException { + if(onscreen) { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setSize(width, height); + glWindow.setVisible(true); + sharedDrawable = glWindow; + } else { + GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile()); + dummyDrawable.setRealized(true); + sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { }; + } + Assert.assertNotNull(sharedDrawable); + Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true)); + + sharedGears = new GearsES2(); + Assert.assertNotNull(sharedGears); + sharedDrawable.addGLEventListener(sharedGears); + // init and render one frame, which will setup the Gears display lists + sharedDrawable.display(); + final GLContext ctxM = sharedDrawable.getContext(); + Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true)); + Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared()); + Assert.assertTrue("Master Gears not initialized", sharedGears.waitForInit(true)); + Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears()); + } + + private void releaseShared() { + Assert.assertNotNull(sharedDrawable); + sharedDrawable.destroy(); + sharedDrawable = null; + } + + protected GLWindow runTestGL(Animator animator, int x, int y, boolean useShared, boolean vsync) throws InterruptedException { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); + glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared "+useShared); + if(useShared) { + glWindow.setSharedContext(sharedDrawable.getContext()); + } + + glWindow.setSize(width, height); + + GearsES2 gears = new GearsES2(vsync ? 1 : 0); + if(useShared) { + gears.setSharedGearsObjects(sharedGears.getGear1(), sharedGears.getGear2(), sharedGears.getGear3()); + } + glWindow.addGLEventListener(gears); + + animator.add(glWindow); + animator.start(); + glWindow.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + + System.err.println("Master Context: "); + MiscUtils.dumpSharedGLContext(sharedDrawable.getContext()); + System.err.println("New Context: "); + MiscUtils.dumpSharedGLContext(glWindow.getContext()); + if( useShared ) { + Assert.assertEquals("Master Context not shared as expected", true, sharedDrawable.getContext().isShared()); + } + Assert.assertEquals("New Context not shared as expected", useShared, glWindow.getContext().isShared()); + + Assert.assertTrue("Gears not initialized", sharedGears.waitForInit(true)); + Assert.assertEquals("Gears is not shared as expected", useShared, gears.usesSharedGears()); + + return glWindow; + } + + @Test + public void test01CommonAnimatorSharedOnscreen() throws InterruptedException { + initShared(true); + Animator animator = new Animator(); + GLWindow f1 = runTestGL(animator, 0, 0, true, false); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + + releaseShared(); + } + + @Test + public void test02CommonAnimatorSharedOffscreen() throws InterruptedException { + initShared(false); + Animator animator = new Animator(); + GLWindow f1 = runTestGL(animator, 0, 0, true, false); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + + releaseShared(); + } + + @Test + public void test03EachWithAnimatorSharedOffscreen() throws InterruptedException { + initShared(false); + Animator animator1 = new Animator(); + Animator animator2 = new Animator(); + Animator animator3 = new Animator(); + GLWindow f1 = runTestGL(animator1, 0, 0, true, false); + InsetsImmutable insets = f1.getInsets(); + GLWindow f2 = runTestGL(animator2, f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, true, false); + GLWindow f3 = runTestGL(animator3, f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), true, false); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator1.stop(); + animator2.stop(); + animator3.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + + releaseShared(); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i + * This is achieved by using the 1st GLWindow's GLContext as the master + * and manually triggering creation of the 2nd and 3rd GLWindow when the 1st GLWindow's + * GLContext becomes created. The trigger is performed by simply + * inserting a GLRunnable in the 1st GLWindow, which makes the other visible. + *

      + *

      + * Above method allows random creation of the 1st GLWindow, which triggers + * creation of the dependent other GLWindow sharing it's GLContext. + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2NEWT2 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + protected GLWindow createGLWindow(int x, int y, GearsES2 gears) throws InterruptedException { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); + glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true"); + glWindow.setSize(width, height); + glWindow.addGLEventListener(gears); + + return glWindow; + } + + @Test + public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException { + final Animator animator = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = createGLWindow(0, 0, g1); + animator.add(f1); + InsetsImmutable insets = f1.getInsets(); + + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2); + animator.add(f2); + + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLWindow f3 = createGLWindow(f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3); + animator.add(f3); + + // f1's shared GLContext is ready ! + f1.invoke(false, new GLRunnable() { + @Override + public boolean run(GLAutoDrawable drawable) { + final GLContext ctx1 = f1.getContext(); + Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared()); + f2.setSharedContext(ctx1); + f2.setVisible(true); + f2.display(); // kick off GLContext .. + f3.setSharedContext(ctx1); + f3.setVisible(true); + f3.display(); // kick off GLContext .. + return true; + } + }); + + f1.setVisible(true); + f1.display(); // kick off GLContext .. and hence f2 + f3 creation + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + animator.start(); // post start animator, otherwise display will be suppressed + + final GLContext ctx1 = f1.getContext(); + final GLContext ctx2 = f2.getContext(); + final GLContext ctx3 = f3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + } + + @Test + public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException { + final Animator a1 = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = createGLWindow(0, 0, g1); + a1.add(f1); + a1.start(); + f1.setVisible(true); + + InsetsImmutable insets = f1.getInsets(); + + final Animator a2 = new Animator(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2); + a2.add(f2); + a2.start(); + + final Animator a3 = new Animator(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLWindow f3 = createGLWindow(f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3); + a3.add(f3); + a3.start(); + + // f1's shared GLContext is ready ! + f1.invoke(false, new GLRunnable() { + @Override + public boolean run(GLAutoDrawable drawable) { + final GLContext ctx1 = f1.getContext(); + Assert.assertTrue("Ctx is shared before shared creation", !ctx1.isShared()); + f2.setSharedContext(ctx1); + f2.setVisible(true); + f3.setSharedContext(ctx1); + f3.setVisible(true); + return true; + } + }); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = f1.getContext(); + final GLContext ctx2 = f2.getContext(); + final GLContext ctx3 = f3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + a1.stop(); + a2.stop(); + a3.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i + * This is achieved by using the 1st GLWindow as the master + * and using the build-in blocking mechanism to postpone creation + * of the 2nd and 3rd GLWindow until the 1st GLWindow's GLContext becomes created. + *

      + *

      + * Above method allows random creation of the 1st GLWindow, which triggers + * creation of the dependent other GLWindow sharing it's GLContext. + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2NEWT3 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + protected GLWindow createGLWindow(int x, int y, GearsES2 gears) throws InterruptedException { + GLWindow glWindow = GLWindow.create(caps); + Assert.assertNotNull(glWindow); + glWindow.setPosition(x, y); + glWindow.setTitle("Shared Gears NEWT Test: "+x+"/"+y+" shared true"); + glWindow.setSize(width, height); + glWindow.addGLEventListener(gears); + + return glWindow; + } + + @Test + public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException { + final Animator animator = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = createGLWindow(0, 0, g1); + animator.add(f1); + InsetsImmutable insets = f1.getInsets(); + + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2); + f2.setSharedAutoDrawable(f1); + animator.add(f2); + + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLWindow f3 = createGLWindow(f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3); + f3.setSharedAutoDrawable(f1); + animator.add(f3); + + f2.setVisible(true); // shall wait until f1 is ready + f1.setVisible(true); // master .. + f3.setVisible(true); // shall wait until f1 is ready + animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = f1.getContext(); + final GLContext ctx2 = f2.getContext(); + final GLContext ctx3 = f3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + } + + @Test + public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException { + final Animator a1 = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLWindow f1 = createGLWindow(0, 0, g1); + a1.add(f1); + a1.start(); + // f1.setVisible(true); // we do this post f2 .. to test pending creation! + + InsetsImmutable insets = f1.getInsets(); + + final Animator a2 = new Animator(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLWindow f2 = createGLWindow(f1.getX()+width+insets.getTotalWidth(), + f1.getY()+0, g2); + f2.setSharedAutoDrawable(f1); + a2.add(f2); + a2.start(); + f2.setVisible(true); + + f1.setVisible(true); // test pending creation of f2 + + final Animator a3 = new Animator(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLWindow f3 = createGLWindow(f1.getX()+0, + f1.getY()+height+insets.getTotalHeight(), g3); + f3.setSharedAutoDrawable(f1); + a3.add(f3); + a3.start(); + f3.setVisible(true); + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = f1.getContext(); + final GLContext ctx2 = f2.getContext(); + final GLContext ctx3 = f3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + a1.stop(); + a2.stop(); + a3.stop(); + + f1.destroy(); + f2.destroy(); + f3.destroy(); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i0; w-=100) { + Thread.sleep(100); + } + } else { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + demo.tabbedPanel.setSelectedIndex(0); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + demo.tabbedPanel.setSelectedIndex(1); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + demo.tabbedPanel.setSelectedIndex(0); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + demo.tabbedPanel.setSelectedIndex(1); + }}); + Thread.sleep(durationPerTest/4); + } + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + System.err.println("XXX SetVisible XXX"); + f.dispose(); + } }); + } + + public static void main(String args[]) { + for(int i=0; i - * Test utilizes {@link GLEventListenerState} for preserving the - * GLAutoDrawable state, i.e. GLContext, all GLEventListener + * Test utilizes {@link GLEventListenerState} for preserving the + * GLAutoDrawable state, i.e. GLContext, all GLEventListener * and the GLAnimatorControl association. *

      *

      @@ -70,7 +70,7 @@ import org.junit.BeforeClass; */ public abstract class GLContextDrawableSwitchBase extends UITestCase { static protected enum GLADType { GLCanvasOnscreen, GLCanvasOffscreen, GLWindow, GLOffscreen }; - + // default period for 1 GLAD cycle static long duration = 1000; // ms @@ -83,7 +83,7 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } return new GLCapabilities(GLProfile.get(profile)); } - + @BeforeClass public static void initClass() { width = 256; @@ -101,37 +101,37 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } } - + static void setFrameVisible(final Frame frame) throws InterruptedException { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.pack(); - frame.setVisible(true); - }}); + frame.setVisible(true); + }}); } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } } - + static void destroyFrame(final Frame frame) throws InterruptedException { try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.dispose(); - }}); + }}); } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } } - + private GLOffscreenAutoDrawable createGLOffscreenAutoDrawable(GLCapabilities caps, int width, int height) throws InterruptedException { final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - return factory.createOffscreenAutoDrawable(null, caps, null, width, height, null); + return factory.createOffscreenAutoDrawable(null, caps, null, width, height); } protected static boolean validateOnOffscreenLayer(GLADType gladType1, GLADType gladType2) { @@ -150,37 +150,37 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } return true; } - - protected void testGLADOneLifecycle(Screen screen, GLCapabilities caps, GLADType gladType, int width, + + protected void testGLADOneLifecycle(Screen screen, GLCapabilities caps, GLADType gladType, int width, int height, GLEventListenerCounter glelTracker, - SnapshotGLEventListener snapshotGLEventListener, final GLEventListenerState glelsIn, final GLEventListenerState glelsOut[], GLAnimatorControl animator) + SnapshotGLEventListener snapshotGLEventListener, final GLEventListenerState glelsIn, final GLEventListenerState glelsOut[], GLAnimatorControl animator) throws InterruptedException { - + System.err.println("GLAD Lifecycle.0 "+gladType+", restoring "+((null!=glelsIn)?true:false)+", preserving "+((null!=glelsOut)?true:false)); final Frame frame; final GLAutoDrawable glad; - if( GLADType.GLCanvasOnscreen == gladType ) { + if( GLADType.GLCanvasOnscreen == gladType ) { if( jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerRequired() ) { throw new InternalError("Platform requires offscreen rendering, but onscreen requested: "+gladType); } frame = new Frame("AWT GLCanvas"); - + glad = new GLCanvas(caps); setGLCanvasSize((GLCanvas)glad, new Dimension(width, height)); frame.add((GLCanvas)glad); - } else if( GLADType.GLCanvasOffscreen == gladType ) { + } else if( GLADType.GLCanvasOffscreen == gladType ) { if( !jogamp.nativewindow.jawt.JAWTUtil.isOffscreenLayerSupported() ) { throw new InternalError("Platform doesn't support offscreen rendering: "+gladType); } frame = new Frame("AWT GLCanvas"); - + glad = new GLCanvas(caps); ((GLCanvas)glad).setShallUseOffscreenLayer(true); setGLCanvasSize((GLCanvas)glad, new Dimension(width, height)); frame.add((GLCanvas)glad); } else if( GLADType.GLWindow == gladType ) { frame = null; - + if( null != screen ) { glad = GLWindow.create(screen, caps); } else { @@ -190,60 +190,60 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { ((GLWindow)glad).setSize(width, height); } else if( GLADType.GLOffscreen == gladType ) { frame = null; - + glad = this.createGLOffscreenAutoDrawable(caps, width, height); } else { throw new InternalError("Unsupported: "+gladType); } - + if( null == glelsIn ) { if( null != animator ) { animator.add(glad); } glad.addGLEventListener(glelTracker); glad.addGLEventListener(new GearsES2(1)); - glad.addGLEventListener(snapshotGLEventListener); + glad.addGLEventListener(snapshotGLEventListener); } snapshotGLEventListener.setMakeSnapshot(); - - if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) { - setFrameVisible(frame); + + if( GLADType.GLCanvasOnscreen == gladType || GLADType.GLCanvasOffscreen == gladType ) { + setFrameVisible(frame); Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); } else if( GLADType.GLWindow == gladType ) { ((GLWindow)glad).setVisible(true); - } - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, true)); + } + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, true)); Assert.assertNotNull(glad.getContext()); Assert.assertTrue(glad.isRealized()); - + if( null != glelsIn ) { Assert.assertEquals(0, glad.getGLEventListenerCount()); System.err.println(".. restoring.0"); - glelsIn.moveTo(glad); + glelsIn.moveTo(glad); System.err.println(".. restoring.X"); - + Assert.assertEquals(1, glelTracker.initCount); Assert.assertTrue(1 <= glelTracker.reshapeCount); Assert.assertTrue(1 <= glelTracker.displayCount); Assert.assertEquals(0, glelTracker.disposeCount); Assert.assertEquals(3, glad.getGLEventListenerCount()); - + Assert.assertEquals(glelsIn.context, glad.getContext()); Assert.assertEquals(glelsIn.listenerCount(), glad.getGLEventListenerCount()); Assert.assertEquals(glelsIn.context.getGLReadDrawable(), glad.getDelegatedDrawable()); Assert.assertEquals(glelsIn.context.getGLDrawable(), glad.getDelegatedDrawable()); Assert.assertEquals(false, glelsIn.isOwner()); } - - for (int wait=0; wait glelTracker.initCount || 1 > glelTracker.reshapeCount || 1 > glelTracker.displayCount ); wait++) { Thread.sleep(AWTRobotUtil.TIME_SLICE); } - + final long t0 = System.currentTimeMillis(); long t1 = t0; - + while( ( t1 - t0 ) < duration ) { Thread.sleep(100); t1 = System.currentTimeMillis(); @@ -253,13 +253,13 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { Assert.assertTrue(1 <= glelTracker.reshapeCount); Assert.assertTrue(1 <= glelTracker.displayCount); Assert.assertEquals(0, glelTracker.disposeCount); - + if( null != glelsOut ) { final GLContext context1 = glad.getContext(); System.err.println(".. preserving.0"); glelsOut[0] = GLEventListenerState.moveFrom(glad); System.err.println(".. preserving.X"); - + Assert.assertEquals(context1, glelsOut[0].context); Assert.assertNull(context1.getGLReadDrawable()); Assert.assertNull(context1.getGLDrawable()); @@ -276,8 +276,8 @@ public abstract class GLContextDrawableSwitchBase extends UITestCase { } else if( GLADType.GLOffscreen == gladType ) { glad.destroy(); } - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, false)); - + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glad, false)); + Assert.assertEquals(1, glelTracker.initCount); Assert.assertTrue(1 <= glelTracker.reshapeCount); Assert.assertTrue(1 <= glelTracker.displayCount); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java index e568f87a1..316199d07 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/glels/TestGLContextDrawableSwitch02AWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore.glels; import java.awt.BorderLayout; @@ -71,7 +71,7 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { } return new GLCapabilities(GLProfile.get(profile)); } - + @BeforeClass public static void initClass() { width = 256; @@ -82,13 +82,13 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { final GLAutoDrawable glad; if( caps.isOnscreen() ) { GLCanvas glCanvas = new GLCanvas(caps); - Assert.assertNotNull(glCanvas); + Assert.assertNotNull(glCanvas); Dimension glc_sz = new Dimension(width, height); glCanvas.setMinimumSize(glc_sz); glCanvas.setPreferredSize(glc_sz); glCanvas.setSize(glc_sz); glad = glCanvas; - + frame.setLayout(new BorderLayout()); frame.add(glCanvas, BorderLayout.CENTER); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -96,48 +96,48 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { frame.pack(); frame.setVisible(true); }}); - - } else { + + } else { final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height, null); + glad = factory.createOffscreenAutoDrawable(null, caps, null, width, height); Assert.assertNotNull(glad); } return glad; } - + @Test(timeout=30000) public void testSwitch2AWTGLCanvas2OffscreenGL2ES2() throws InterruptedException, InvocationTargetException { final GLCapabilities reqGLCaps = getCaps(GLProfile.GL2ES2); if(null == reqGLCaps) return; testSwitch2AWTGLCanvas2OffscreenImpl(reqGLCaps); } - + private void testSwitch2AWTGLCanvas2OffscreenImpl(GLCapabilities capsOnscreen) throws InterruptedException, InvocationTargetException { final GLCapabilities capsOffscreen = (GLCapabilities) capsOnscreen.clone(); capsOffscreen.setOnscreen(false); - + final QuitAdapter quitAdapter = new QuitAdapter(); - + final Frame frame = new Frame("Gears AWT Test"); Assert.assertNotNull(frame); new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - + GLAutoDrawable glCanvas = createGLAutoDrawable(frame, capsOnscreen, width, height); - - final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); + + final SnapshotGLEventListener snapshotGLEventListener = new SnapshotGLEventListener(); GearsES2 gears = new GearsES2(1); glCanvas.addGLEventListener(gears); glCanvas.addGLEventListener(snapshotGLEventListener); snapshotGLEventListener.setMakeSnapshot(); - + Animator animator = new Animator(); animator.add(glCanvas); animator.start(); - + int s = 0; long t0 = System.currentTimeMillis(); long t1 = t0; - + GLAutoDrawable glOffscreen = createGLAutoDrawable(null, capsOffscreen, width, height); while( !quitAdapter.shouldQuit() && ( t1 - t0 ) < duration ) { if( ( t1 - t0 ) / period > s) { @@ -147,8 +147,8 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { // switch context _and_ the demo synchronously GLDrawableUtil.swapGLContextAndAllGLEventListener(glCanvas, glOffscreen); snapshotGLEventListener.setMakeSnapshot(); - - System.err.println(s+" - switch - END "+ ( t1 - t0 )); + + System.err.println(s+" - switch - END "+ ( t1 - t0 )); } Thread.sleep(100); t1 = System.currentTimeMillis(); @@ -157,14 +157,14 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { animator.stop(); // glCanvas.destroy(); glOffscreen.destroy(); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { final Frame _frame = frame; _frame.dispose(); }}); } - + // default timing for 2 switches static long duration = 2900; // ms static long period = 1000; // ms @@ -186,7 +186,7 @@ public class TestGLContextDrawableSwitch02AWT extends UITestCase { /** BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); System.err.println("Press enter to continue"); - System.err.println(stdin.readLine()); */ + System.err.println(stdin.readLine()); */ org.junit.runner.JUnitCore.main(TestGLContextDrawableSwitch02AWT.class.getName()); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java index 033e55da3..96ec8ab75 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug461FBOSupersamplingSwingAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -31,7 +31,7 @@ package com.jogamp.opengl.test.junit.jogl.awt; import java.awt.Container; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; - + import java.awt.image.BufferedImage; import java.lang.reflect.InvocationTargetException; @@ -68,11 +68,11 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL JFrame jframe; GLOffscreenAutoDrawable offScreenBuffer; AWTGLReadBufferUtil awtGLReadBufferUtil; - + private void render(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); Assert.assertNotNull(gl); - gl.glClear(GL.GL_COLOR_BUFFER_BIT); + gl.glClear(GL.GL_COLOR_BUFFER_BIT); // draw a triangle filling the window gl.glBegin(GL.GL_TRIANGLES); @@ -84,7 +84,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL gl.glVertex2d(1, -1); gl.glEnd(); } - + /* @Override */ public void init(GLAutoDrawable drawable) { awtGLReadBufferUtil = new AWTGLReadBufferUtil(drawable.getGLProfile(), false); @@ -92,16 +92,16 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL /* @Override */ public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - + } + /* @Override */ - public void display(GLAutoDrawable drawable) { + public void display(GLAutoDrawable drawable) { render(offScreenBuffer); // BufferedImage outputImage = com.jogamp.opengl.util.awt.Screenshot.readToBufferedImage(200, 200, false); BufferedImage outputImage = awtGLReadBufferUtil.readPixelsToBufferedImage(drawable.getGL(), 0, 0, 200, 200, true /* awtOrientation */); Assert.assertNotNull(outputImage); ImageIcon imageIcon = new ImageIcon(outputImage); - final JLabel imageLabel = new JLabel(imageIcon); + final JLabel imageLabel = new JLabel(imageIcon); try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -116,7 +116,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL } /* @Override */ - public void dispose(GLAutoDrawable drawable) { + public void dispose(GLAutoDrawable drawable) { try { awtGLReadBufferUtil.dispose(drawable.getGL()); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -141,29 +141,29 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL GLProfile glp = GLProfile.get(GLProfile.GL2); Assert.assertNotNull(glp); - + GLDrawableFactory fac = GLDrawableFactory.getFactory(glp); Assert.assertNotNull(fac); - + Assert.assertTrue( fac.canCreateGLPbuffer(GLProfile.getDefaultDevice(), glp) ); - + GLCapabilities glCap = new GLCapabilities(glp); Assert.assertNotNull(glCap); - - // COMMENTING OUT THIS LINE FIXES THE ISSUE. + + // COMMENTING OUT THIS LINE FIXES THE ISSUE. // Setting this in JOGL1 works. Thus this is a JOGL2 issue. glCap.setSampleBuffers(true); - + // Without line below, there is an error on Windows. // glCap.setDoubleBuffered(false); // implicit double buffer -> MSAA + FBO - + // Needed for drop shadows glCap.setStencilBits(1); //makes a new buffer - offScreenBuffer = fac.createOffscreenAutoDrawable(GLProfile.getDefaultDevice(), glCap, null, 200, 200, null); + offScreenBuffer = fac.createOffscreenAutoDrawable(GLProfile.getDefaultDevice(), glCap, null, 200, 200); Assert.assertNotNull(offScreenBuffer); - offScreenBuffer.addGLEventListener(this); + offScreenBuffer.addGLEventListener(this); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { jframe.setSize( 300, 300); @@ -171,7 +171,7 @@ public class TestBug461FBOSupersamplingSwingAWT extends UITestCase implements GL }}); offScreenBuffer.display(); // read from front buffer due to FBO+MSAA -> double-buffer offScreenBuffer.display(); // now we have prev. image in front buffer to be read out - + Thread.sleep(durationPerTest); offScreenBuffer.destroy(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java index 89470a922..e87c34419 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageAWT.java @@ -132,7 +132,7 @@ public class TestBug605FlippedImageAWT extends UITestCase { private void test(GLCapabilitiesImmutable caps) { final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); + final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256); final FlippedImageTest tglel = new FlippedImageTest(); glad.addGLEventListener(tglel); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java index 8d4710ad3..28fcb9885 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestBug605FlippedImageNEWT.java @@ -119,7 +119,7 @@ public class TestBug605FlippedImageNEWT extends UITestCase { private void test(GLCapabilitiesImmutable caps) { final GLReadBufferUtil rbu = new GLReadBufferUtil(false, false); final GLDrawableFactory glFactory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256, null); + final GLAutoDrawable glad = glFactory.createOffscreenAutoDrawable(null, caps, null, 256, 256); final FlippedImageTest tglel = new FlippedImageTest(); glad.addGLEventListener(tglel); final SnapshotGLEventListener snap = new SnapshotGLEventListener(rbu); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java index 521224c01..ba93dcdcd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/caps/TestMultisampleES1AWT.java @@ -1,22 +1,22 @@ /* * Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved. * Copyright (c) 2010 JogAmp Community. All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * - Redistribution of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * + * * - Redistribution in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * Neither the name of Sun Microsystems, Inc. or the names of * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * This software is provided "AS IS," without a warranty of any kind. ALL * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A @@ -29,11 +29,11 @@ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * + * * You acknowledge that this software is not designed or intended for use * in the design, construction, operation or maintenance of any nuclear * facility. - * + * * Sun gratefully acknowledges that this software was originally authored * and developed by Kenneth Bradley Russell and Christopher John Kline. */ @@ -104,7 +104,7 @@ public class TestMultisampleES1AWT extends UITestCase { caps.setNumSamples(reqSamples); } - canvas = new GLCanvas(caps, chooser, null, null); + canvas = new GLCanvas(caps, chooser, null); canvas.addGLEventListener(new MultisampleDemoES1(reqSamples>0?true:false)); canvas.addGLEventListener(new GLEventListener() { int displayCount = 0; @@ -115,7 +115,7 @@ public class TestMultisampleES1AWT extends UITestCase { } public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } }); - + final Frame frame = new Frame("Multi Samples "+reqSamples); frame.setLayout(new BorderLayout()); canvas.setSize(512, 512); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java index 63e89952f..db1f217ba 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsES1.java @@ -7,10 +7,10 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -55,16 +55,18 @@ public class GearsES1 implements GLEventListener { private boolean forceFFPEmu = false; private boolean debug = false ; private boolean trace = false ; - + private final float pos[] = { 5.0f, 5.0f, 10.0f, 0.0f }; - private float view_rotx = 20.0f, view_roty = 30.0f, view_rotz = 0.0f; + private float view_rotx = 20.0f, view_roty = 30.0f; + private final float view_rotz = 0.0f; private GearsObject gear1=null, gear2=null, gear3=null; private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue; + private volatile boolean usesSharedGears = false; private float angle = 0.0f; - private int swapInterval; - private MouseListener gearsMouse = new GearsMouseAdapter(); - private KeyListener gearsKeys = new GearsKeyAdapter(); + private final int swapInterval; + private final MouseListener gearsMouse = new GearsMouseAdapter(); + private final KeyListener gearsKeys = new GearsKeyAdapter(); private int prevMouseX, prevMouseY; @@ -76,21 +78,21 @@ public class GearsES1 implements GLEventListener { public GearsES1() { this.swapInterval = 1; } - + public void setForceFFPEmu(boolean forceFFPEmu, boolean verboseFFPEmu, boolean debugFFPEmu, boolean traceFFPEmu) { this.forceFFPEmu = forceFFPEmu; this.verboseFFPEmu = verboseFFPEmu; this.debugFFPEmu = debugFFPEmu; this.traceFFPEmu = traceFFPEmu; } - + public void setGearsColors(FloatBuffer gear1Color, FloatBuffer gear2Color, FloatBuffer gear3Color) { this.gear1Color = gear1Color; this.gear2Color = gear2Color; this.gear3Color = gear3Color; } - - public void setGears(GearsObject g1, GearsObject g2, GearsObject g3) { + + public void setSharedGearsObjects(GearsObject g1, GearsObject g2, GearsObject g3) { gear1 = g1; gear2 = g2; gear3 = g3; @@ -110,15 +112,17 @@ public class GearsES1 implements GLEventListener { * @return gear3 */ public GearsObject getGear3() { return gear3; } - + + public boolean usesSharedGears() { return usesSharedGears; } + public void init(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES1.init ..."); - + // Use debug pipeline // drawable.setGL(new DebugGL(drawable.getGL())); GL _gl = drawable.getGL(); - + if(debugFFPEmu) { // Debug .. _gl = _gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES2.class, _gl, null) ); @@ -130,12 +134,12 @@ public class GearsES1 implements GLEventListener { trace = false; } GL2ES1 gl = FixedFuncUtil.wrapFixedFuncEmul(_gl, ShaderSelectionMode.AUTO, null, forceFFPEmu, verboseFFPEmu); - + if(debug) { try { // Debug .. gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Debug", GL2ES1.class, gl, null) ); - } catch (Exception e) {e.printStackTrace();} + } catch (Exception e) {e.printStackTrace();} } if(trace) { try { @@ -143,7 +147,7 @@ public class GearsES1 implements GLEventListener { gl = (GL2ES1) gl.getContext().setGL( GLPipelineFactory.create("javax.media.opengl.Trace", GL2ES1.class, gl, new Object[] { System.err } ) ); } catch (Exception e) {e.printStackTrace();} } - + System.err.println("GearsES1 init on "+Thread.currentThread()); System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); System.err.println("INIT GL IS: " + gl.getClass().getName()); @@ -154,33 +158,36 @@ public class GearsES1 implements GLEventListener { gl.glEnable(GL2ES1.GL_LIGHTING); gl.glEnable(GL2ES1.GL_LIGHT0); gl.glEnable(GL2ES1.GL_DEPTH_TEST); - + /* make the gears */ if(null == gear1) { gear1 = new GearsObjectES1(gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f); System.err.println("gear1 created: "+gear1); } else { + usesSharedGears = true; System.err.println("gear1 reused: "+gear1); } - + if(null == gear2) { gear2 = new GearsObjectES1(gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f); System.err.println("gear2 created: "+gear2); } else { + usesSharedGears = true; System.err.println("gear2 reused: "+gear2); } - + if(null == gear3) { gear3 = new GearsObjectES1(gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f); System.err.println("gear3 created: "+gear3); } else { + usesSharedGears = true; System.err.println("gear3 reused: "+gear3); } - + gl.glEnable(GL2ES1.GL_NORMALIZE); - + final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { + if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.addMouseListener(gearsMouse); window.addKeyListener(gearsKeys); @@ -191,7 +198,7 @@ public class GearsES1 implements GLEventListener { } System.err.println(Thread.currentThread()+" GearsES1.init FIN"); } - + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { System.err.println(Thread.currentThread()+" GearsES1.reshape "+x+"/"+y+" "+width+"x"+height+", swapInterval "+swapInterval); GL2ES1 gl = drawable.getGL().getGL2ES1(); @@ -217,7 +224,7 @@ public class GearsES1 implements GLEventListener { public void dispose(GLAutoDrawable drawable) { System.err.println(Thread.currentThread()+" GearsES1.dispose ... "); final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { + if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.removeMouseListener(gearsMouse); window.removeKeyListener(gearsKeys); @@ -232,7 +239,7 @@ public class GearsES1 implements GLEventListener { System.err.println(Thread.currentThread()+" GearsES1.dispose FIN"); } - public void display(GLAutoDrawable drawable) { + public void display(GLAutoDrawable drawable) { // Turn the gears' teeth angle += 2.0f; @@ -251,10 +258,10 @@ public class GearsES1 implements GLEventListener { } else { gl.glClearColor(0.2f, 0.2f, 0.2f, 0.0f); } - + // Special handling for the case where the GLJPanel is translucent // and wants to be composited with other Java 2D content - if (GLProfile.isAWTAvailable() && + if (GLProfile.isAWTAvailable() && (drawable instanceof javax.media.opengl.awt.GLJPanel) && !((javax.media.opengl.awt.GLJPanel) drawable).isOpaque() && ((javax.media.opengl.awt.GLJPanel) drawable).shouldPreserveColorBufferIfTranslucent()) { @@ -264,25 +271,25 @@ public class GearsES1 implements GLEventListener { } gl.glNormal3f(0.0f, 0.0f, 1.0f); - + // Rotate the entire assembly of gears based on how the user // dragged the mouse around gl.glPushMatrix(); gl.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); gl.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); gl.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); - - gear1.draw(gl, -3.0f, -2.0f, angle); - gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f); + + gear1.draw(gl, -3.0f, -2.0f, angle); + gear2.draw(gl, 3.1f, -2.0f, -2.0f * angle - 9.0f); gear3.draw(gl, -3.1f, 4.2f, -2.0f * angle - 25.0f); - + // Remember that every push needs a pop; this one is paired with // rotating the entire gear assembly gl.glPopMatrix(); } - - class GearsKeyAdapter extends KeyAdapter { + + class GearsKeyAdapter extends KeyAdapter { public void keyPressed(KeyEvent e) { int kc = e.getKeyCode(); if(KeyEvent.VK_LEFT == kc) { @@ -296,16 +303,16 @@ public class GearsES1 implements GLEventListener { } } } - + class GearsMouseAdapter extends MouseAdapter { public void mousePressed(MouseEvent e) { prevMouseX = e.getX(); prevMouseY = e.getY(); } - + public void mouseReleased(MouseEvent e) { } - + public void mouseDragged(MouseEvent e) { int x = e.getX(); int y = e.getY(); @@ -324,7 +331,7 @@ public class GearsES1 implements GLEventListener { } float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width); float thetaX = 360.0f * ( (float)(prevMouseY-y)/(float)height); - + prevMouseX = x; prevMouseY = y; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 9817ea57f..60242d604 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -45,6 +45,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.GLUniformData; @@ -64,7 +65,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private final float view_rotz = 0.0f; private float panX = 0.0f, panY = 0.0f, panZ=0.0f; - private GearsObjectES2 gear1=null, gear2=null, gear3=null; + private volatile GearsObjectES2 gear1=null, gear2=null, gear3=null; + private GearsES2 sharedGears = null; + private volatile boolean usesSharedGears = false; private FloatBuffer gear1Color=GearsObject.red, gear2Color=GearsObject.green, gear3Color=GearsObject.blue; private float angle = 0.0f; private int swapInterval = 0; @@ -80,6 +83,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private float[] clearColor = null; private boolean clearBuffers = true; private boolean verbose = true; + private volatile boolean isInit = false; private PinchToZoomGesture pinchToZoomGesture = null; @@ -132,12 +136,16 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL this.gear3Color = gear3Color; } - public void setGears(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) { + public void setSharedGearsObjects(GearsObjectES2 g1, GearsObjectES2 g2, GearsObjectES2 g3) { gear1 = g1; gear2 = g2; gear3 = g3; } + public void setSharedGears(GearsES2 shared) { + sharedGears = shared; + } + /** * @return gear1 */ @@ -153,12 +161,33 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL */ public GearsObjectES2 getGear3() { return gear3; } + public boolean usesSharedGears() { return usesSharedGears; } + + private static final int TIME_OUT = 2000; // 2s + private static final int POLL_DIVIDER = 20; // TO/20 + private static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ; + + /** + * @return True if this GLEventListener became initialized within TIME_OUT 2s + */ + public boolean waitForInit(boolean initialized) throws InterruptedException { + int wait; + for (wait=0; wait "+gear1); + System.err.println("gear2 created w/ share: "+sharedGears.getGear2()+" -> "+gear2); + System.err.println("gear3 created w/ share: "+sharedGears.getGear3()+" -> "+gear3); + } } else { - gear1 = new GearsObjectES2(gear1, st, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear1 reused: "+gear1); + if(null == gear1) { + gear1 = new GearsObjectES2(st, gear1Color, 1.0f, 4.0f, 1.0f, 20, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + if(verbose) { + System.err.println("gear1 created: "+gear1); + } + } else { + final GearsObjectES2 _gear1 = gear1; + gear1 = new GearsObjectES2(_gear1, st, pmvMatrix, pmvMatrixUniform, colorU); + usesSharedGears = true; + if(verbose) { + System.err.println("gear1 created w/ share: "+_gear1+" -> "+gear1); + } } - } - if(null == gear2) { - gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear2 created: "+gear2); - } - } else { - gear2 = new GearsObjectES2(gear2, st, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear2 reused: "+gear2); + if(null == gear2) { + gear2 = new GearsObjectES2(st, gear2Color, 0.5f, 2.0f, 2.0f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + if(verbose) { + System.err.println("gear2 created: "+gear2); + } + } else { + final GearsObjectES2 _gear2 = gear2; + gear2 = new GearsObjectES2(_gear2, st, pmvMatrix, pmvMatrixUniform, colorU); + usesSharedGears = true; + if(verbose) { + System.err.println("gear2 created w/ share: "+_gear2+" -> "+gear2); + } } - } - if(null == gear3) { - gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear3 created: "+gear3); - } - } else { - gear3 = new GearsObjectES2(gear3, st, pmvMatrix, pmvMatrixUniform, colorU); - if(verbose) { - System.err.println("gear3 reused: "+gear3); + if(null == gear3) { + gear3 = new GearsObjectES2(st, gear3Color, 1.3f, 2.0f, 0.5f, 10, 0.7f, pmvMatrix, pmvMatrixUniform, colorU); + if(verbose) { + } + } else { + final GearsObjectES2 _gear3 = gear3; + gear3 = new GearsObjectES2(_gear3, st, pmvMatrix, pmvMatrixUniform, colorU); + usesSharedGears = true; + if(verbose) { + System.err.println("gear3 created w/ share: "+_gear3+" -> "+gear3); + } } } @@ -254,6 +300,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.useProgram(gl, false); System.err.println(Thread.currentThread()+" GearsES2.init FIN"); + isInit = true; } private final GestureHandler.GestureListener pinchToZoomListener = new GestureHandler.GestureListener() { @@ -267,6 +314,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) { + if( !isInit ) { return; } final GL2ES2 gl = glad.getGL().getGL2ES2(); if(-1 != swapInterval) { gl.setSwapInterval(swapInterval); @@ -278,6 +326,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void reshapeTile(TileRendererBase tr, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { + if( !isInit ) { return; } final GL2ES2 gl = tr.getAttachedDrawable().getGL().getGL2ES2(); gl.setSwapInterval(0); reshapeImpl(gl, tileX, tileY, tileWidth, tileHeight, imageWidth, imageHeight); @@ -339,6 +388,8 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void dispose(GLAutoDrawable drawable) { + if( !isInit ) { return; } + isInit = false; System.err.println(Thread.currentThread()+" GearsES2.dispose: tileRendererInUse "+tileRendererInUse); final Object upstreamWidget = drawable.getUpstreamWidget(); if (upstreamWidget instanceof Window) { @@ -370,6 +421,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void display(GLAutoDrawable drawable) { + if( !isInit ) { return; } GLAnimatorControl anim = drawable.getAnimator(); if( verbose && ( null == anim || !anim.isAnimating() ) ) { System.err.println(Thread.currentThread()+" GearsES2.display "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java index 4d9b750c4..b9e64e1da 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/glu/TestBug365TextureGenerateMipMaps.java @@ -31,7 +31,7 @@ import com.jogamp.opengl.util.texture.TextureIO; *

      * Bug Reference: https://jogamp.org/bugzilla/show_bug.cgi?id=365 *

      - * The bug pertains to mipmap generation from a Texture and exists in {@link ScaleInternal} + * The bug pertains to mipmap generation from a Texture and exists in {@link ScaleInternal} * where a {@link java.nio.BufferUnderflowException} is thrown. *

      *

        This suite of test cases test: @@ -43,14 +43,14 @@ import com.jogamp.opengl.util.texture.TextureIO; *
      • {@link ScaleInternal#scale_internal_int(int, int, int, ByteBuffer, int, int, java.nio.IntBuffer, int, int, int, boolean)}
      • *
      • {@link ScaleInternal#scale_internal_float(int, int, int, ByteBuffer, int, int, java.nio.FloatBuffer, int, int, int, boolean)}
      • *
      - * + * * @author Michael Esemplare, et.al. * */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestBug365TextureGenerateMipMaps extends UITestCase { static GLOffscreenAutoDrawable drawable; - + @BeforeClass public static void setup() throws Throwable { // disableNPOT @@ -61,23 +61,21 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase { throw t; } } - + @AfterClass public static void teardown() { tearDownOffscreenAutoDrawable(); } - + private static void setUpOffscreenAutoDrawable() throws Throwable { GLProfile glp = GLProfile.getDefault(); GLCapabilities caps = new GLCapabilities(glp); - + GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - - // Make a drawable to get an offscreen context - drawable = factory.createOffscreenAutoDrawable(null, caps, null, 2, 2, null); - - drawable.setRealized(true); + // Make a drawable to get an offscreen context + drawable = factory.createOffscreenAutoDrawable(null, caps, null, 2, 2); + drawable.display(); // trigger context creation GLContext glContext = drawable.getContext(); try { Assert.assertTrue("Could not make context current", GLContext.CONTEXT_NOT_CURRENT < glContext.makeCurrent()); @@ -86,7 +84,7 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase { throw t; } } - + private static void tearDownOffscreenAutoDrawable() { if(drawable != null) { drawable.getContext().release(); @@ -94,30 +92,30 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase { drawable = null; } } - + private static void testTextureMipMapGeneration(int width, int height, int pixelFormat, int pixelType) { int internalFormat = pixelFormat; int border = 0; boolean mipmap = true; boolean dataIsCompressed = false; boolean mustFlipVertically = false; - + int memReq = Mipmap.image_size( width, height, pixelFormat, pixelType ); ByteBuffer buffer = Buffers.newDirectByteBuffer( memReq ); - - TextureData data = new TextureData(drawable.getGLProfile(), - internalFormat, - width, - height, - border, - pixelFormat, - pixelType, - mipmap, - dataIsCompressed, - mustFlipVertically, - buffer, + + TextureData data = new TextureData(drawable.getGLProfile(), + internalFormat, + width, + height, + border, + pixelFormat, + pixelType, + mipmap, + dataIsCompressed, + mustFlipVertically, + buffer, null); - + Texture texture = TextureIO.newTexture(drawable.getGL(), data); // Cleanup texture.destroy(drawable.getGL()); @@ -125,144 +123,144 @@ public class TestBug365TextureGenerateMipMaps extends UITestCase { buffer.clear(); buffer = null; } - + @Test public void test00_MipMap_ScaleInternal_RGB_UBYTE () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_UNSIGNED_BYTE; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test01_MipMap_ScaleInternal_RGBA_UBYTE () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_UNSIGNED_BYTE; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test02_MipMap_ScaleInternal_RGB_BYTE () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_BYTE; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test03_MipMap_ScaleInternal_RGBA_BYTE () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_BYTE; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test04_MipMap_ScaleInternal_RGB_USHORT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_UNSIGNED_SHORT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test05_MipMap_ScaleInternal_RGBA_USHORT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_UNSIGNED_SHORT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test06_MipMap_ScaleInternal_RGB_SHORT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_SHORT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test07_MipMap_ScaleInternal_RGBA_SHORT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_SHORT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test08_MipMap_ScaleInternal_RGB_UINT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_UNSIGNED_INT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test09_MipMap_ScaleInternal_RGBA_UINT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_UNSIGNED_INT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test10_MipMap_ScaleInternal_RGB_INT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_INT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test11_MipMap_ScaleInternal_RGBA_INT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_INT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test12_MipMap_ScaleInternal_RGB_FLOAT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGB; int pixelType = GL2.GL_FLOAT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } - + @Test public void test13_MipMap_ScaleInternal_RGBA_FLOAT () { int width = 1; int height = 7; int pixelFormat = GL2.GL_RGBA; int pixelType = GL2.GL_FLOAT; - + testTextureMipMapGeneration(width, height, pixelFormat, pixelType); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java index d539b5e55..16c1b33f4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestRandomTiledRendering2GL2NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -60,14 +60,14 @@ import org.junit.runners.MethodSorters; *

      *

      * {@link RandomTileRenderer} buffer allocation is performed - * within the pre {@link GLEventListener} + * within the pre {@link GLEventListener} * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} - * on the main thread. + * on the main thread. *

      *

      * At tile rendering finish, the viewport and * and the original {@link GLEventListener}'s PMV matrix as well. - * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -83,7 +83,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { doTest(8); } - void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException { + void doTest(int msaaCount) throws IOException, InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(null); caps.setDoubleBuffered(true); if( msaaCount > 0 ) { @@ -93,7 +93,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { final int maxTileSize = 64; final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize, null); + final GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize); final Gears gears = new Gears(); glad.addGLEventListener( gears ); @@ -156,7 +156,7 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); gears.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); return false; - } + } }); glad.destroy(); @@ -168,9 +168,9 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { caps.getGLProfile(), 0 /* internalFormat */, imageWidth, imageHeight, - 0, + 0, imageBuffer.pixelAttributes, - false, false, + false, false, flipVertically[0], imageBuffer.buffer, null /* Flusher */); @@ -189,5 +189,5 @@ public class TestRandomTiledRendering2GL2NEWT extends UITestCase { } } org.junit.runner.JUnitCore.main(TestRandomTiledRendering2GL2NEWT.class.getName()); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java index 74909dc8c..2220c1fb3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledRendering2NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -60,14 +60,14 @@ import org.junit.runners.MethodSorters; *

      *

      * {@link TileRenderer} buffer allocation is performed - * within the pre {@link GLEventListener} + * within the pre {@link GLEventListener} * set via {@link TileRendererBase#setGLEventListener(GLEventListener, GLEventListener)} - * on the main thread. + * on the main thread. *

      *

      * At tile rendering finish, the viewport and * and the original {@link GLEventListener}'s PMV matrix as well. - * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. + * The latter is done by calling it's {@link GLEventListener#reshape(GLAutoDrawable, int, int, int, int) reshape} method. *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -88,8 +88,8 @@ public class TestTiledRendering2NEWT extends UITestCase { return null; } return glp; - } - + } + @Test public void test001_off_gl2___aa0() throws IOException { GLProfile glp = getGLProfile(GLProfile.GL2); @@ -155,8 +155,8 @@ public class TestTiledRendering2NEWT extends UITestCase { doTest(true, new GearsES2(), glp, 8); } - void doTest(boolean onscreen, final GLEventListener demo, GLProfile glp, final int msaaCount) throws IOException { - GLCapabilities caps = new GLCapabilities(glp); + void doTest(boolean onscreen, final GLEventListener demo, GLProfile glp, final int msaaCount) throws IOException { + GLCapabilities caps = new GLCapabilities(glp); caps.setDoubleBuffered(onscreen); if( msaaCount > 0 ) { caps.setSampleBuffers(true); @@ -172,7 +172,7 @@ public class TestTiledRendering2NEWT extends UITestCase { glad = glWin; } else { final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); - glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize, null); + glad = factory.createOffscreenAutoDrawable(null, caps, null, maxTileSize, maxTileSize); } glad.addGLEventListener( demo ); @@ -220,7 +220,7 @@ public class TestTiledRendering2NEWT extends UITestCase { } renderer.detachAutoDrawable(); - + // Restore viewport and Gear's PMV matrix // .. even though we close the demo, this is for documentation! glad.invoke(true, new GLRunnable() { @@ -229,7 +229,7 @@ public class TestTiledRendering2NEWT extends UITestCase { drawable.getGL().glViewport(0, 0, drawable.getWidth(), drawable.getHeight()); demo.reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); return false; - } + } }); final GLPixelBuffer imageBuffer = renderer.getImageBuffer(); @@ -237,15 +237,15 @@ public class TestTiledRendering2NEWT extends UITestCase { caps.getGLProfile(), 0 /* internalFormat */, imageWidth, imageHeight, - 0, + 0, imageBuffer.pixelAttributes, - false, false, + false, false, flipVertically[0], imageBuffer.buffer, null /* Flusher */); TextureIO.write(textureData, file); - + glad.destroy(); } @@ -259,5 +259,5 @@ public class TestTiledRendering2NEWT extends UITestCase { } } org.junit.runner.JUnitCore.main(TestTiledRendering2NEWT.class.getName()); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index e85052d08..b1e9f477e 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.util; import jogamp.newt.WindowImplAccess; @@ -40,6 +40,7 @@ import java.awt.Robot; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawable; import org.junit.Assert; @@ -50,17 +51,17 @@ import com.jogamp.newt.event.WindowEvent; public class AWTRobotUtil { static final boolean DEBUG = false; - + public static final int RETRY_NUMBER = 5; public static final int ROBOT_DELAY = 100; // ms public static final int TIME_OUT = 2000; // 2s public static final int POLL_DIVIDER = 20; // TO/20 public static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ; - public static Integer AWT_CLICK_TO = null; - + public static Integer AWT_CLICK_TO = null; + static Object awtEDTAliveSync = new Object(); - static volatile boolean awtEDTAliveFlag = false; - + static volatile boolean awtEDTAliveFlag = false; + static class OurUncaughtExceptionHandler implements UncaughtExceptionHandler { @Override public void uncaughtException(Thread t, Throwable e) { @@ -68,16 +69,16 @@ public class AWTRobotUtil { e.printStackTrace(); } } - + static { Thread.setDefaultUncaughtExceptionHandler( new OurUncaughtExceptionHandler() ); // System.err.println("AWT EDT alive: "+isAWTEDTAlive()); } - + /** Probes whether AWT's EDT is alive or not. */ public static boolean isAWTEDTAlive() { if( EventQueue.isDispatchThread() ) { - return true; + return true; } synchronized ( awtEDTAliveSync ) { awtEDTAliveFlag = false; @@ -85,7 +86,7 @@ public class AWTRobotUtil { @Override public void run() { awtEDTAliveFlag = true; - } + } }); for (int wait=0; wait tc && j tc && j delta ) { throw new AssertionError(msg+"; Expected @ ["+a0+"+"+i+"] has "+ai+", but actual @ ["+b0+"+"+i+"] has "+bi+", it's delta "+daibi+" > "+delta); } } } - + public static void assertFloatBufferNotEqual(String errmsg, FloatBuffer expected, FloatBuffer actual, float delta) { if(null == expected || null == actual) { return; } if(expected.remaining() != actual.remaining()) { - return; + return; } String msg = null != errmsg ? errmsg + " " : ""; final int a0 = expected.position(); @@ -131,14 +135,14 @@ public class MiscUtils { for(int i=0; i delta ) { return; } } throw new AssertionError(msg+"; Expected and actual are equal."); } - + public static boolean setFieldIfExists(Object instance, String fieldName, Object value) { try { Field f = instance.getClass().getField(fieldName); @@ -155,14 +159,14 @@ public class MiscUtils { } return false; } - + public static class StreamDump extends Thread { final InputStream is; final StringBuilder outString; final OutputStream outStream; final String prefix; final Object sync; - volatile boolean eos = false; + volatile boolean eos = false; public StreamDump(OutputStream out, String prefix, InputStream is, Object sync) { this.is = is; @@ -178,7 +182,7 @@ public class MiscUtils { this.prefix = null; this.sync = sync; } - + public final boolean eos() { return eos; } @Override @@ -208,7 +212,28 @@ public class MiscUtils { } } } - } + } + + public static void dumpSharedGLContext(GLContext self) { + int i = 0, j = 0; + System.err.println("Myself: hash 0x"+Integer.toHexString(self.hashCode())+", \t(isShared "+self.isShared()+", created "+self.isCreated()+")"); + { + final List set = self.getCreatedShares(); + for (final Iterator iter = set.iterator(); iter.hasNext(); ) { + final GLContext c = iter.next(); + System.err.println("Ctx #"+(i++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")"); + } + } + { + final List set = self.getDestroyedShares(); + for (final Iterator iter = set.iterator(); iter.hasNext(); ) { + final GLContext c = iter.next(); + System.err.println("Ctx #"+(j++)+": hash 0x"+Integer.toHexString(c.hashCode())+", \t(created "+c.isCreated()+")"); + } + } + System.err.println("\t Total created "+i+" + destroyed "+j+" = "+(i+j)); + System.err.println(); + } } -- cgit v1.2.3 From f73c10f71be979d214537679f85f1897c5642e11 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 27 Oct 2013 18:57:02 +0100 Subject: Bug 776 GLContext Sharing: Add GLSharedContextSetter to GLJPanel --- make/scripts/tests.sh | 3 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 48 ++- .../jogl/acore/TestSharedContextVBOES2AWT3.java | 2 +- .../jogl/acore/TestSharedContextVBOES2AWT3b.java | 321 +++++++++++++++++++++ 4 files changed, 367 insertions(+), 7 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 23477b254..4d87136c3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -376,7 +376,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 93e8b2c0b..faf00c19a 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -77,6 +77,7 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLFBODrawable; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLSharedContextSetter; import javax.media.opengl.Threading; import javax.swing.JPanel; @@ -160,7 +161,7 @@ import com.jogamp.opengl.util.texture.TextureState; */ @SuppressWarnings("serial") -public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol, AWTPrintLifecycle { +public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosingProtocol, AWTPrintLifecycle, GLSharedContextSetter { private static final boolean DEBUG; private static final boolean DEBUG_VIEWPORT; private static final boolean USE_GLSL_TEXTURE_RASTERIZER; @@ -223,7 +224,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final GLProfile glProfile; private final GLDrawableFactoryImpl factory; private final GLCapabilitiesChooser chooser; - private final GLContext shareWith; private int additionalCtxCreationFlags = 0; // Lazy reshape notification: reshapeWidth -> panelWidth -> backend.width @@ -296,6 +296,29 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing since J2D GL Context must be shared and we can only share one context. * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. */ + public GLJPanel(GLCapabilitiesImmutable userCapsRequest, GLCapabilitiesChooser chooser) + throws GLException + { + this(userCapsRequest, chooser, null); + } + + /** Creates a new GLJPanel component. The passed GLCapabilities + specifies the OpenGL capabilities for the component; if null, a + default set of capabilities is used. The GLCapabilitiesChooser + specifies the algorithm for selecting one of the available + GLCapabilities for the component; a DefaultGLCapabilitesChooser + is used if null is passed for this argument. The passed + GLContext specifies an OpenGL context with which to share + textures, display lists and other OpenGL state, and may be null + if sharing is not desired. See the note in the overview documentation on + context sharing. +

      + Note: Sharing cannot be enabled using J2D OpenGL FBO sharing, + since J2D GL Context must be shared and we can only share one context. + * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. + * @deprecated Use {@link #GLJPanel(GLCapabilitiesImmutable, GLCapabilitiesChooser)} + * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. + */ public GLJPanel(GLCapabilitiesImmutable userCapsRequest, GLCapabilitiesChooser chooser, GLContext shareWith) throws GLException { @@ -316,11 +339,22 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.glProfile = offscreenCaps.getGLProfile(); this.factory = GLDrawableFactoryImpl.getFactoryImpl(glProfile); this.chooser = ((chooser != null) ? chooser : new DefaultGLCapabilitiesChooser()); - this.shareWith = shareWith; - + if( null != shareWith ) { + helper.setSharedContext(null, shareWith); + } this.setFocusable(true); // allow keyboard input! } + @Override + public final void setSharedContext(GLContext sharedContext) throws IllegalStateException { + helper.setSharedContext(this.getContext(), sharedContext); + } + + @Override + public final void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { + helper.setSharedAutoDrawable(this, sharedAutoDrawable); + } + public AWTGLPixelBufferProvider getCustomPixelBufferProvider() { return customPixelBufferProvider; } /** @@ -1301,13 +1335,17 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing System.err.println(getThreadName()+": OffscreenBackend: initialize()"); } try { + final GLContext[] shareWith = { null }; + if( helper.isSharedGLContextPending(shareWith) ) { + return; // pending .. + } offscreenDrawable = (GLDrawableImpl) factory.createOffscreenDrawable( null /* default platform device */, offscreenCaps, chooser, panelWidth, panelHeight); offscreenDrawable.setRealized(true); - offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith); + offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith[0]); offscreenContext.setContextCreationFlags(additionalCtxCreationFlags); if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { isInitialized = true; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java index 6b9169510..b2d88f8e0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java @@ -88,7 +88,7 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { frame.add(glCanvas); frame.setLocation(x, y); frame.setSize(width, height); - frame.setTitle("Shared Gears AWT GLCanvas Test: "+x+"/"+y+" shared true"); + frame.setTitle("AWT GLCanvas Shared Gears Test: "+x+"/"+y+" shared true"); return glCanvas; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java new file mode 100644 index 000000000..fcfe4d512 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java @@ -0,0 +1,321 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.Frame; +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLJPanel; + +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +/** + * Sharing the VBO of 3 GearsES2 instances, each in their own GLJPanel. + *

      + * This is achieved by using the 1st GLJPanel as the master + * and using the build-in blocking mechanism to postpone creation + * of the 2nd and 3rd GLJPanel until the 1st GLJPanel 's GLContext becomes created. + *

      + *

      + * Above method allows random creation of the 1st GLJPanel, which triggers + * creation of the dependent other GLJPanel sharing it's GLContext. + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2AWT3b extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + protected GLJPanel createGLJPanel(final Frame frame, int x, int y, GearsES2 gears) throws InterruptedException { + final GLJPanel glCanvas = new GLJPanel(caps); + Assert.assertNotNull(glCanvas); + glCanvas.addGLEventListener(gears); + frame.add(glCanvas); + frame.setLocation(x, y); + frame.setSize(width, height); + frame.setTitle("AWT GLJPanel Shared Gears Test: "+x+"/"+y+" shared true"); + return glCanvas; + } + + @Test + public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + final Frame f1 = new Frame(); + final Animator animator = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLJPanel c1 = createGLJPanel(f1, 0, 0, g1); + animator.add(c1); + + final Frame f2 = new Frame(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLJPanel c2 = createGLJPanel(f2, f1.getX()+width, + f1.getY()+0, g2); + c2.setSharedAutoDrawable(c1); + animator.add(c2); + + final Frame f3 = new Frame(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLJPanel c3 = createGLJPanel(f3, f1.getX()+0, + f1.getY()+height, g3); + c3.setSharedAutoDrawable(c1); + animator.add(c3); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f2.setVisible(true); // shall wait until f1 is ready + f1.setVisible(true); // master .. + f3.setVisible(true); // shall wait until f1 is ready + } } ); + animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = c1.getContext(); + final GLContext ctx2 = c2.getContext(); + final GLContext ctx3 = c3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + f1.dispose(); + f2.dispose(); + f3.dispose(); + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false)); + } + + @Test + public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + final Frame f1 = new Frame(); + final Animator a1 = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLJPanel c1 = createGLJPanel(f1, 0, 0, g1); + a1.add(c1); + a1.start(); + // f1.setVisible(true); // we do this post f2 .. to test pending creation! + + final Frame f2 = new Frame(); + final Animator a2 = new Animator(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLJPanel c2 = createGLJPanel(f2, f1.getX()+width, f1.getY()+0, g2); + c2.setSharedAutoDrawable(c1); + a2.add(c2); + a2.start(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f2.setVisible(true); + } } ); + + Thread.sleep(200); // wait a while .. + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f1.setVisible(true); // test pending creation of f2 + } } ); + + final Frame f3 = new Frame(); + final Animator a3 = new Animator(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLJPanel c3 = createGLJPanel(f3, f1.getX()+0, f1.getY()+height, g3); + c3.setSharedAutoDrawable(c1); + a3.add(c3); + a3.start(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f3.setVisible(true); + } } ); + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); + Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = c1.getContext(); + final GLContext ctx2 = c2.getContext(); + final GLContext ctx3 = c3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + a1.stop(); + a2.stop(); + a3.stop(); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + f1.dispose(); + f2.dispose(); + f3.dispose(); + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, false)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, false)); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i Date: Mon, 28 Oct 2013 03:58:01 +0100 Subject: Bug 776 GLContext Sharing: Add note about driver stability (destruction order) ; Fix unit tests (Shared Gears, wait for created context and destruction order) - Add note about driver stability (destruction order) - See GLSharedContextSetter: Don't destroy master context before slaves! - Fix spec-overview.html#SHARED links, add link to GLSharedContextSetter in SHARED subsection. - Fix unit tests (Shared Gears, wait for created context and destruction order) - The GearsObject sharing was completly bogus! It simply used the _same_ GLArrayDataServer instance for sharing, but it should use a _copy_ of the shared GLArrayDataServer while only preserving the VBO object! Fixed, while adding required methods to GLArrayDataServer. - Waiting for the created GLContext of a GLAutoDrawable required us to pass the latter _and_ check whether it's GLContext exists and is natively created. - Accomodated the destruction order - see above! --- make/build-test.xml | 42 +++++++- make/doc/jogl/spec-overview.html | 5 + make/scripts/tests-win.bat | 43 +++++--- make/scripts/tests.sh | 7 +- .../com/jogamp/opengl/util/GLArrayDataServer.java | 45 ++++++++ .../javax/media/opengl/GLDrawableFactory.java | 4 +- .../javax/media/opengl/GLSharedContextSetter.java | 30 +++++- .../classes/javax/media/opengl/awt/GLCanvas.java | 2 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 11 +- .../jogl/acore/TestSharedContextVBOES1NEWT.java | 4 +- .../jogl/acore/TestSharedContextVBOES2AWT3.java | 114 ++++++++++++++++++--- .../jogl/acore/TestSharedContextVBOES2AWT3b.java | 24 ++--- .../jogl/acore/TestSharedContextVBOES2NEWT0.java | 8 +- .../jogl/acore/TestSharedContextVBOES2NEWT1.java | 22 ++-- .../jogl/acore/TestSharedContextVBOES2NEWT2.java | 69 ++++++++++--- .../jogl/acore/TestSharedContextVBOES2NEWT3.java | 64 +++++++++--- .../opengl/test/junit/jogl/demos/GearsObject.java | 84 +++++++++------ .../test/junit/jogl/demos/es1/GearsObjectES1.java | 30 ++++-- .../test/junit/jogl/demos/es2/GearsObjectES2.java | 54 ++++++---- .../opengl/test/junit/util/AWTRobotUtil.java | 16 ++- 20 files changed, 511 insertions(+), 167 deletions(-) (limited to 'make/scripts') diff --git a/make/build-test.xml b/make/build-test.xml index 066d41401..b7220aed6 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -449,7 +449,45 @@
      - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -487,7 +525,7 @@ - + diff --git a/make/doc/jogl/spec-overview.html b/make/doc/jogl/spec-overview.html index 952e8f8e0..1a63fb7dd 100644 --- a/make/doc/jogl/spec-overview.html +++ b/make/doc/jogl/spec-overview.html @@ -332,6 +332,11 @@ to the underlying native engine.

      Sharing of server-side OpenGL objects such as buffer objects, e.g. VBOs, and textures among OpenGL contexts is supported in this specification. +

      +See {@link javax.media.opengl.GLSharedContextSetter GLSharedContextSetter} interface +for details. +

      +

      Criteria Used for Inclusion of APIs into the Java Bindings

      OpenGL API Inclusion Criteria

      diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 90226c28d..71ac8c43d 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,10 +6,35 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCom REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT -time 5000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT -time 5000 + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile02NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLContextDrawableSwitch01NEWT %* @@ -29,18 +54,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLCanvasOnOffscrnCapsAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGL2OffscrnCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryGLnBitmapCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableFactoryES2OffscrnCapsNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableOffThreadSharedContextES2NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT %* - REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4d87136c3..0f3388fb3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -84,6 +84,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG" #D_ARGS="-Djogl.disable.opengles" + #D_ARGS="-Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" @@ -375,9 +376,11 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java index e30fea2f4..96643ae72 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLArrayDataServer.java @@ -230,6 +230,28 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE return ads; } + /** + * Create a VBO for fixed function interleaved array data + * starting with a given Buffer object incl it's stride + *

      User needs to configure the interleaved segments via {@link #addFixedSubArray(int, int, int)}.

      + * + * @param comps The total number of all interleaved components. + * @param dataType The array index GL data type + * @param normalized Whether the data shall be normalized + * @param initialElementCount + * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} + */ + public static GLArrayDataServer createFixedInterleaved(int comps, int dataType, boolean normalized, int stride, Buffer buffer, + int vboUsage) + throws GLException + { + GLArrayDataServer ads = new GLArrayDataServer(); + GLArrayHandler glArrayHandler = new GLArrayHandlerInterleaved(ads); + ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, normalized, stride, buffer, buffer.limit(), false, glArrayHandler, + 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, false); + return ads; + } + /** * Configure a segment of this fixed function interleaved array (see {@link #createFixedInterleaved(int, int, boolean, int, int)}). *

      @@ -286,6 +308,29 @@ public class GLArrayDataServer extends GLArrayDataClient implements GLArrayDataE return ads; } + /** + * Create a VBO for GLSL interleaved array data + * starting with a given Buffer object incl it's stride + *

      User needs to configure the interleaved segments via {@link #addGLSLSubArray(int, int, int)}.

      + * + * @param comps The total number of all interleaved components. + * @param dataType The array index GL data type + * @param normalized Whether the data shall be normalized + * @param stride + * @param buffer the user define data + * @param vboUsage {@link GL2ES2#GL_STREAM_DRAW}, {@link GL#GL_STATIC_DRAW} or {@link GL#GL_DYNAMIC_DRAW} + */ + public static GLArrayDataServer createGLSLInterleaved(int comps, int dataType, boolean normalized, int stride, Buffer buffer, + int vboUsage) + throws GLException + { + GLArrayDataServer ads = new GLArrayDataServer(); + GLArrayHandler glArrayHandler = new GLSLArrayHandlerInterleaved(ads); + ads.init(GLPointerFuncUtil.mgl_InterleaveArray, -1, comps, dataType, normalized, stride, buffer, buffer.limit(), false, glArrayHandler, + 0, 0, vboUsage, GL.GL_ARRAY_BUFFER, true); + return ads; + } + /** * Configure a segment of this GLSL interleaved array (see {@link #createGLSLInterleaved(int, int, boolean, int, int)}). *

      diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 817dff8ad..98eb9bdde 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -675,8 +675,8 @@ public abstract class GLDrawableFactory { * The GLPbuffer drawable is realized and initialized eagerly. *

      * - * See the note in the overview documentation on - * context sharing. + * See the note in the overview documentation in {@link GLSharedContextSetter} and on + * context sharing. * * @param device which {@link javax.media.nativewindow.AbstractGraphicsDevice#getConnection() connection} denotes the shared the target device, may be null for the platform's default device. * @param capabilities the requested capabilities diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java index d5a10931e..8c2311329 100644 --- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -31,7 +31,29 @@ package javax.media.opengl; /** * Adds capabilities to set a shared {@link GLContext} directly or via an {@link GLAutoDrawable}. *

      - * Warning: Don't reference this interface directly, since it may end up in {@link GLAutoDrawable} + * Sharing of server-side OpenGL objects such as buffer objects, e.g. VBOs, + * and textures among OpenGL contexts is supported with this interface. + *

      + *

      + * A master {@link GLContext} is the {@link GLContext} which is created first, + * shared {@link GLContext} w/ this master are referred as slave {@link GLContext}. + *

      + *
      Driver stability constraints
      + *

      + * Be aware that the master {@link GLContext} and related resources, i.e. the {@link GLAutoDrawable}, + * shall not be destroyed before it's slave {@link GLContext} instances.
      + * Otherwise the OpenGL driver implementation may crash w/ SIGSEGV if shared resources are still used!
      + * Note that this is not specified within OpenGL and should work, however, some drivers + * do not seem to handle this situation well, i.e. they do not postpone resource destruction + * until the last reference is removed.
      + * Since pending destruction of {@link GLContext} and it's {@link GLDrawable} is complex and nearly impossible + * for us at the top level, considering the different windowing systems and {@link GLAutoDrawable} types, + * the user shall take care of proper destruction order. + *

      + *

      + * Users may use a {@link GLDrawableFactory#createDummyDrawable(javax.media.nativewindow.AbstractGraphicsDevice, boolean, GLProfile) dummy} + * {@link GLDrawable} and it's {@link GLContext} as the master of all shared slave {@link GLContext}. + * Same constraints as above apply, i.e. it shall be destroyed after all shared slaves. *

      */ public interface GLSharedContextSetter extends GLAutoDrawable { @@ -46,6 +68,9 @@ public interface GLSharedContextSetter extends GLAutoDrawable { * A set sharedContext will block context creation, i.e. {@link GLAutoDrawable#initialization GLAutoDrawable initialization}, * as long it is not {@link GLContext#isCreated() created natively}. *

      + *

      + * See driver stability constraints. + *

      * * @param sharedContext The OpenGL context to be shared by this {@link GLAutoDrawable}'s {@link GLContext}. * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext} @@ -67,6 +92,9 @@ public interface GLSharedContextSetter extends GLAutoDrawable { * as long it's {@link GLContext} is null * or has not been {@link GLContext#isCreated() created natively}. *

      + *

      + * See driver stability constraints. + *

      * * @param sharedContext The GLAutoDrawable, which OpenGL context shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. * @throws IllegalStateException if a {@link #setSharedContext(GLContext) shared GLContext} diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index c2d8e0535..439a5bd30 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -246,7 +246,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing textures, display lists and other OpenGL state, and may be null if sharing is not desired. See the note in the overview documentation on context + href="../../../spec-overview.html#SHARING">context sharing. The passed GraphicsDevice indicates the screen on which to create the GLCanvas; the GLDrawableFactory uses the default screen device of the local GraphicsEnvironment if null diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index faf00c19a..8b1467268 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -286,14 +286,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing default set of capabilities is used. The GLCapabilitiesChooser specifies the algorithm for selecting one of the available GLCapabilities for the component; a DefaultGLCapabilitesChooser - is used if null is passed for this argument. The passed - GLContext specifies an OpenGL context with which to share - textures, display lists and other OpenGL state, and may be null - if sharing is not desired. See the note in the overview documentation on - context sharing. -

      - Note: Sharing cannot be enabled using J2D OpenGL FBO sharing, - since J2D GL Context must be shared and we can only share one context. + is used if null is passed for this argument. * @throws GLException if no GLCapabilities are given and no default profile is available for the default desktop device. */ public GLJPanel(GLCapabilitiesImmutable userCapsRequest, GLCapabilitiesChooser chooser) @@ -311,7 +304,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing GLContext specifies an OpenGL context with which to share textures, display lists and other OpenGL state, and may be null if sharing is not desired. See the note in the overview documentation on - context sharing. + context sharing.

      Note: Sharing cannot be enabled using J2D OpenGL FBO sharing, since J2D GL Context must be shared and we can only share one context. diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java index 05d060f0b..59bb13c87 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java @@ -104,7 +104,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { // init and render one frame, which will setup the Gears display lists sharedDrawable.display(); final GLContext ctxM = sharedDrawable.getContext(); - Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true)); + Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForContextCreated(sharedDrawable, true)); Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared()); Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears()); } @@ -136,7 +136,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { glWindow.setVisible(true); Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true)); System.err.println("Master Context: "); MiscUtils.dumpSharedGLContext(sharedDrawable.getContext()); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java index b2d88f8e0..5cf2e4b24 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java @@ -93,7 +93,17 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } @Test - public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + public void test01SyncedOneAnimatorCleanDtorOrder() throws InterruptedException, InvocationTargetException { + syncedOneAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException, InvocationTargetException { + syncedOneAnimator(false); + } + + public void syncedOneAnimator(final boolean destroyCleanOrder) throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator animator = new Animator(); final GearsES2 g1 = new GearsES2(0); @@ -128,17 +138,17 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); @@ -174,12 +184,45 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } animator.stop(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. Ma trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + if( destroyCleanOrder ) { + f3.dispose(); + } else { + f1.dispose(); + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + if( destroyCleanOrder ) { + f2.dispose(); + } else { + f2.dispose(); + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { - f1.dispose(); - f2.dispose(); - f3.dispose(); + if( destroyCleanOrder ) { + f1.dispose(); + } else { + f3.dispose(); + } } catch (Throwable t) { throw new RuntimeException(t); } @@ -191,7 +234,17 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } @Test - public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + public void test11SyncEachAnimatorCleanDtorOrder() throws InterruptedException, InvocationTargetException { + syncedOneAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test12SyncEachAnimatorDirtyDtorOrder() throws InterruptedException, InvocationTargetException { + asyncEachOneAnimator(false); + } + + public void asyncEachOneAnimator(final boolean destroyCleanOrder) throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); @@ -237,17 +290,17 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); @@ -285,12 +338,45 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { a2.stop(); a3.stop(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. Ma trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + if( destroyCleanOrder ) { + f3.dispose(); + } else { + f1.dispose(); + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + try { + if( destroyCleanOrder ) { + f2.dispose(); + } else { + f2.dispose(); + } + } catch (Throwable t) { + throw new RuntimeException(t); + } + }}); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { - f1.dispose(); - f2.dispose(); - f3.dispose(); + if( destroyCleanOrder ) { + f1.dispose(); + } else { + f3.dispose(); + } } catch (Throwable t) { throw new RuntimeException(t); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java index fcfe4d512..07b9fd4eb 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java @@ -93,7 +93,7 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { } @Test - public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + public void test01SyncedOneAnimator() throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator animator = new Animator(); final GearsES2 g1 = new GearsES2(0); @@ -128,17 +128,17 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); @@ -177,9 +177,9 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { - f1.dispose(); - f2.dispose(); f3.dispose(); + f2.dispose(); + f1.dispose(); } catch (Throwable t) { throw new RuntimeException(t); } @@ -191,7 +191,7 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { } @Test - public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException, InvocationTargetException { + public void test02AsyncEachAnimator() throws InterruptedException, InvocationTargetException { final Frame f1 = new Frame(); final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); @@ -237,17 +237,17 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(c1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c2, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c2.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(c3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(c3, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(c3.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = c1.getContext(); @@ -288,9 +288,9 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { try { - f1.dispose(); - f2.dispose(); f3.dispose(); + f2.dispose(); + f1.dispose(); } catch (Throwable t) { throw new RuntimeException(t); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java index 76ae5c69d..a8c069f36 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT0.java @@ -93,7 +93,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); glWindow.display(); - Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true)); Assert.assertTrue("Gears not initialized", gears.waitForInit(true)); return glWindow; @@ -183,7 +183,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase { f1.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false)); { final List ctx1Shares = ctx1.getCreatedShares(); final List ctx2Shares = ctx2.getCreatedShares(); @@ -206,7 +206,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase { f2.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false)); { final List ctx1Shares = ctx1.getCreatedShares(); final List ctx2Shares = ctx2.getCreatedShares(); @@ -229,7 +229,7 @@ public class TestSharedContextVBOES2NEWT0 extends UITestCase { f3.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false)); { final List ctx1Shares = ctx1.getCreatedShares(); final List ctx2Shares = ctx2.getCreatedShares(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java index e3b1fe396..827601869 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java @@ -120,7 +120,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { // init and render one frame, which will setup the Gears display lists sharedDrawable.display(); final GLContext ctxM = sharedDrawable.getContext(); - Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForCreated(ctxM, true)); + Assert.assertTrue("Master ctx not created", AWTRobotUtil.waitForContextCreated(sharedDrawable, true)); Assert.assertTrue("Master Ctx is shared before shared creation", !ctxM.isShared()); Assert.assertTrue("Master Gears not initialized", sharedGears.waitForInit(true)); Assert.assertTrue("Master Gears is shared", !sharedGears.usesSharedGears()); @@ -154,7 +154,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { glWindow.setVisible(true); Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(glWindow.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(glWindow, true)); System.err.println("Master Context: "); MiscUtils.dumpSharedGLContext(sharedDrawable.getContext()); @@ -193,13 +193,13 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { f3.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false)); releaseShared(); } @@ -226,13 +226,13 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { f3.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false)); releaseShared(); } @@ -264,13 +264,13 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { f3.destroy(); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, false)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), false)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, false)); releaseShared(); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java index 9b283d6cd..d9fe2a949 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java @@ -96,7 +96,17 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { } @Test - public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException { + public void test01SyncedOneAnimatorCleanDtorOrder() throws InterruptedException { + syncedOneAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException { + syncedOneAnimator(false); + } + + public void syncedOneAnimator(boolean destroyCleanOrder) throws InterruptedException { final Animator animator = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLWindow f1 = createGLWindow(0, 0, g1); @@ -133,19 +143,20 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { f1.setVisible(true); f1.display(); // kick off GLContext .. and hence f2 + f3 creation + Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); animator.start(); // post start animator, otherwise display will be suppressed @@ -182,10 +193,19 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { e.printStackTrace(); } animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); - f1.destroy(); - f2.destroy(); - f3.destroy(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + f3.destroy(); + f2.destroy(); + f1.destroy(); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + f1.destroy(); + f2.destroy(); + f3.destroy(); + } Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); @@ -195,7 +215,17 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { } @Test - public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException { + public void test11ASyncEachAnimatorCleanDtorOrder() throws InterruptedException { + asyncEachAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test12AsyncEachAnimatorDirtyDtorOrder() throws InterruptedException { + asyncEachAnimator(false); + } + + public void asyncEachAnimator(boolean destroyCleanOrder) throws InterruptedException { final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLWindow f1 = createGLWindow(0, 0, g1); @@ -237,16 +267,16 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = f1.getContext(); @@ -281,12 +311,23 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { e.printStackTrace(); } a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); - f1.destroy(); - f2.destroy(); - f3.destroy(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + f3.destroy(); + f2.destroy(); + f1.destroy(); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + f1.destroy(); + f2.destroy(); + f3.destroy(); + } Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java index e2928855c..adadf85e3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java @@ -93,7 +93,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } @Test - public void test01SyncedCommonAnimatorSharedOffscreen() throws InterruptedException { + public void test01SyncedOneAnimatorCleanDtorOrder() throws InterruptedException { + syncedOneAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException { + syncedOneAnimator(false); + } + + public void syncedOneAnimator(boolean destroyCleanOrder) throws InterruptedException { final Animator animator = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLWindow f1 = createGLWindow(0, 0, g1); @@ -123,17 +133,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = f1.getContext(); @@ -169,9 +179,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } animator.stop(); - f1.destroy(); - f2.destroy(); - f3.destroy(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + f3.destroy(); + f2.destroy(); + f1.destroy(); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. Ma trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + f1.destroy(); + f2.destroy(); + f3.destroy(); + } Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); @@ -181,7 +199,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } @Test - public void test02AsyncEachWithAnimatorSharedOffscreen() throws InterruptedException { + public void test11ASyncEachAnimatorCleanDtorOrder() throws InterruptedException { + asyncEachAnimator(true); + } + + // Don't test erroneous test case ! + // @Test + public void test12AsyncEachAnimatorDirtyDtorOrder() throws InterruptedException { + asyncEachAnimator(false); + } + + public void asyncEachAnimator(boolean destroyCleanOrder) throws InterruptedException { final Animator a1 = new Animator(); final GearsES2 g1 = new GearsES2(0); final GLWindow f1 = createGLWindow(0, 0, g1); @@ -217,17 +245,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f1.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f1, true)); Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f2, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f2.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f2, true)); Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f3, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f3, true)); - Assert.assertTrue(AWTRobotUtil.waitForCreated(f3.getContext(), true)); + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(f3, true)); Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); final GLContext ctx1 = f1.getContext(); @@ -265,9 +293,17 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { a2.stop(); a3.stop(); - f1.destroy(); - f2.destroy(); - f3.destroy(); + if( destroyCleanOrder ) { + System.err.println("XXX Destroy in clean order NOW"); + f3.destroy(); + f2.destroy(); + f1.destroy(); + } else { + System.err.println("XXX Destroy in creation order NOW - Driver Impl. May trigger driver Bug i.e. not postponing GL ctx destruction after releasing all refs."); + f1.destroy(); + f2.destroy(); + f3.destroy(); + } Assert.assertTrue(AWTRobotUtil.waitForVisible(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForRealized(f1, false)); Assert.assertTrue(AWTRobotUtil.waitForVisible(f2, false)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java index 82dd7071f..7adcce2ae 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/GearsObject.java @@ -7,10 +7,10 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -37,7 +37,7 @@ public abstract class GearsObject { public static final FloatBuffer blue = Buffers.newDirectFloatBuffer( new float[] { 0.2f, 0.2f, 1.0f, 0.7f } ); public static final float M_PI = (float)Math.PI; - public final FloatBuffer gearColor; + public final FloatBuffer gearColor; public GLArrayDataServer frontFace; public GLArrayDataServer frontSide; public GLArrayDataServer backFace; @@ -46,10 +46,11 @@ public abstract class GearsObject { public GLArrayDataServer insideRadiusCyl; public boolean isShared; + public abstract GLArrayDataServer createInterleaveClone(GLArrayDataServer ads); public abstract GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage); public abstract void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components); public abstract void draw(GL gl, float x, float y, float angle); - + public void destroy(GL gl) { if(!isShared) { // could be already destroyed by shared configuration @@ -77,21 +78,27 @@ public abstract class GearsObject { backFace=null; backSide=null; outwardFace=null; - insideRadiusCyl=null; + insideRadiusCyl=null; isShared = false; } - + public GearsObject ( GearsObject shared ) { isShared = true; - frontFace = shared.frontFace; - frontSide = shared.frontSide; - backFace = shared.backFace; - backSide = shared.backSide; - outwardFace = shared.outwardFace; - insideRadiusCyl = shared.insideRadiusCyl; + frontFace = createInterleaveClone(shared.frontFace); + addInterleavedVertexAndNormalArrays(frontFace, 3); + backFace = createInterleaveClone(shared.backFace); + addInterleavedVertexAndNormalArrays(backFace, 3); + frontSide = createInterleaveClone(shared.frontSide); + addInterleavedVertexAndNormalArrays(frontSide, 3); + backSide= createInterleaveClone(shared.backSide); + addInterleavedVertexAndNormalArrays(backSide, 3); + outwardFace = createInterleaveClone(shared.outwardFace); + addInterleavedVertexAndNormalArrays(outwardFace, 3); + insideRadiusCyl = createInterleaveClone(shared.insideRadiusCyl); + addInterleavedVertexAndNormalArrays(insideRadiusCyl, 3); gearColor = shared.gearColor; } - + public GearsObject ( FloatBuffer gearColor, float inner_radius, @@ -100,7 +107,7 @@ public abstract class GearsObject { int teeth, float tooth_depth) { - final float dz = width * 0.5f; + final float dz = width * 0.5f; int i; float r0, r1, r2; float angle, da; @@ -112,7 +119,7 @@ public abstract class GearsObject { this.isShared = false; this.gearColor = gearColor; - + r0 = inner_radius; r1 = outer_radius - tooth_depth / 2.0f; r2 = outer_radius + tooth_depth / 2.0f; @@ -121,7 +128,7 @@ public abstract class GearsObject { s[4] = 0; // sin(0f) c[4] = 1; // cos(0f) - + final int vboUsage = GL.GL_STATIC_DRAW; frontFace = createInterleaved(6, GL.GL_FLOAT, false, 4*teeth+2, vboUsage); @@ -143,45 +150,45 @@ public abstract class GearsObject { sincos(angle + da * 1f, s, 1, c, 1); sincos(angle + da * 2f, s, 2, c, 2); sincos(angle + da * 3f, s, 3, c, 3); - + /* front */ normal[0] = 0.0f; normal[1] = 0.0f; normal[2] = 1.0f; - + /* front face - GL.GL_TRIANGLE_STRIP */ vert(frontFace, r0 * c[0], r0 * s[0], dz, normal); vert(frontFace, r1 * c[0], r1 * s[0], dz, normal); vert(frontFace, r0 * c[0], r0 * s[0], dz, normal); vert(frontFace, r1 * c[3], r1 * s[3], dz, normal); - + /* front sides of teeth - GL.GL_TRIANGLES */ vert(frontSide, r1 * c[0], r1 * s[0], dz, normal); - vert(frontSide, r2 * c[1], r2 * s[1], dz, normal); + vert(frontSide, r2 * c[1], r2 * s[1], dz, normal); vert(frontSide, r2 * c[2], r2 * s[2], dz, normal); vert(frontSide, r1 * c[0], r1 * s[0], dz, normal); - vert(frontSide, r2 * c[2], r2 * s[2], dz, normal); + vert(frontSide, r2 * c[2], r2 * s[2], dz, normal); vert(frontSide, r1 * c[3], r1 * s[3], dz, normal); - + /* back */ normal[0] = 0.0f; normal[1] = 0.0f; normal[2] = -1.0f; - + /* back face - GL.GL_TRIANGLE_STRIP */ vert(backFace, r1 * c[0], r1 * s[0], -dz, normal); vert(backFace, r0 * c[0], r0 * s[0], -dz, normal); vert(backFace, r1 * c[3], r1 * s[3], -dz, normal); vert(backFace, r0 * c[0], r0 * s[0], -dz, normal); - + /* back sides of teeth - GL.GL_TRIANGLES*/ vert(backSide, r1 * c[3], r1 * s[3], -dz, normal); vert(backSide, r2 * c[2], r2 * s[2], -dz, normal); vert(backSide, r2 * c[1], r2 * s[1], -dz, normal); vert(backSide, r1 * c[3], r1 * s[3], -dz, normal); - vert(backSide, r2 * c[1], r2 * s[1], -dz, normal); + vert(backSide, r2 * c[1], r2 * s[1], -dz, normal); vert(backSide, r1 * c[0], r1 * s[0], -dz, normal); - + /* outward faces of teeth */ u = r2 * c[1] - r1 * c[0]; v = r2 * s[1] - r1 * s[0]; @@ -207,7 +214,7 @@ public abstract class GearsObject { normal[0] = ( r1 * s[3] - r2 * s[2] ); normal[1] = ( r1 * c[3] - r2 * c[2] ) * -1.0f ; vert(outwardFace, r2 * c[2], r2 * s[2], dz, normal); - vert(outwardFace, r2 * c[2], r2 * s[2], -dz, normal); + vert(outwardFace, r2 * c[2], r2 * s[2], -dz, normal); vert(outwardFace, r1 * c[3], r1 * s[3], dz, normal); vert(outwardFace, r1 * c[3], r1 * s[3], -dz, normal); @@ -217,7 +224,7 @@ public abstract class GearsObject { vert(outwardFace, r1 * c[3], r1 * s[3], -dz, normal); vert(outwardFace, r1 * c[0], r1 * s[0], dz, normal); vert(outwardFace, r1 * c[0], r1 * s[0], -dz, normal); - + /* inside radius cylinder */ normal[0] = c[0] * -1.0f; normal[1] = s[0] * -1.0f; @@ -232,16 +239,16 @@ public abstract class GearsObject { vert(frontFace, r0 * c[4], r0 * s[4], dz, normal); vert(frontFace, r1 * c[4], r1 * s[4], dz, normal); frontFace.seal(true); - + /* finish back face */ - normal[2] = -1.0f; + normal[2] = -1.0f; vert(backFace, r1 * c[4], r1 * s[4], -dz, normal); vert(backFace, r0 * c[4], r0 * s[4], -dz, normal); backFace.seal(true); - + backSide.seal(true); frontSide.seal(true); - + /* finish outward face */ sincos(da * 1f, s, 1, c, 1); u = r2 * c[1] - r1 * c[4]; @@ -253,7 +260,7 @@ public abstract class GearsObject { normal[1] = -u; normal[2] = 0.0f; vert(outwardFace, r1 * c[4], r1 * s[4], dz, normal); - vert(outwardFace, r1 * c[4], r1 * s[4], -dz, normal); + vert(outwardFace, r1 * c[4], r1 * s[4], -dz, normal); outwardFace.seal(true); /* finish inside radius cylinder */ @@ -265,6 +272,15 @@ public abstract class GearsObject { insideRadiusCyl.seal(true); } + @Override + public String toString() { + final int ffVBO = null != frontFace ? frontFace.getVBOName() : 0; + final int fsVBO = null != frontSide ? frontSide.getVBOName() : 0; + final int bfVBO = null != backFace ? backFace.getVBOName() : 0; + final int bsVBO = null != backSide ? backSide.getVBOName() : 0; + return "GearsObj[0x"+Integer.toHexString(hashCode())+", vbo ff "+ffVBO+", fs "+fsVBO+", bf "+bfVBO+", bs "+bsVBO+"]"; + } + static void vert(GLArrayDataServer array, float x, float y, float z, float n[]) { array.putf(x); array.putf(y); @@ -273,7 +289,7 @@ public abstract class GearsObject { array.putf(n[1]); array.putf(n[2]); } - + static void sincos(float x, float sin[], int sinIdx, float cos[], int cosIdx) { sin[sinIdx] = (float) Math.sin(x); cos[cosIdx] = (float) Math.cos(x); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java index 89e469799..6c9587931 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java @@ -7,10 +7,10 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -26,7 +26,6 @@ import javax.media.opengl.GL; import javax.media.opengl.GL2ES1; import javax.media.opengl.fixedfunc.GLPointerFunc; - import com.jogamp.opengl.test.junit.jogl.demos.GearsObject; import com.jogamp.opengl.util.GLArrayDataServer; @@ -41,11 +40,26 @@ public class GearsObjectES1 extends GearsObject { super(gearColor, inner_radius, outer_radius, width, teeth, tooth_depth); } + @Override + public GLArrayDataServer createInterleaveClone(GLArrayDataServer ads) { + final FloatBuffer fb0 = (FloatBuffer) ads.getBuffer(); + final FloatBuffer fb1 = fb0.slice(); + // manual 'unseal' + fb1.position(fb1.limit()); + fb1.limit(fb1.capacity()); + + final GLArrayDataServer adsClone = GLArrayDataServer.createFixedInterleaved(ads.getComponentCount(), ads.getComponentType(), ads.getNormalized(), + ads.getStride(), fb1, ads.getVBOUsage()); + adsClone.setVBOName(ads.getVBOName()); + adsClone.seal(true); + return adsClone; + } + @Override public GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage) { return GLArrayDataServer.createFixedInterleaved(comps, dataType, normalized, initialSize, vboUsage); } - + @Override public void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components) { array.addFixedSubArray(GLPointerFunc.GL_VERTEX_ARRAY, components, GL.GL_ARRAY_BUFFER); @@ -60,20 +74,20 @@ public class GearsObjectES1 extends GearsObject { @Override public void draw(GL _gl, float x, float y, float angle) { - GL2ES1 gl = _gl.getGL2ES1(); + GL2ES1 gl = _gl.getGL2ES1(); gl.glPushMatrix(); gl.glTranslatef(x, y, 0f); gl.glRotatef(angle, 0f, 0f, 1f); gl.glMaterialfv(GL2ES1.GL_FRONT_AND_BACK, GL2ES1.GL_AMBIENT_AND_DIFFUSE, gearColor); - + gl.glShadeModel(GL2ES1.GL_FLAT); draw(gl, frontFace, GL.GL_TRIANGLE_STRIP); draw(gl, frontSide, GL.GL_TRIANGLES); draw(gl, backFace, GL.GL_TRIANGLE_STRIP); draw(gl, backSide, GL.GL_TRIANGLES); draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP); - gl.glShadeModel(GL2ES1.GL_SMOOTH); + gl.glShadeModel(GL2ES1.GL_SMOOTH); draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP); gl.glPopMatrix(); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java index c5f5f7a44..89006d28c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java @@ -7,10 +7,10 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -40,12 +40,12 @@ public class GearsObjectES2 extends GearsObject { final GLUniformData pmvMatrixUniform; final GLUniformData colorUniform; final ShaderState st; - + public GearsObjectES2(ShaderState st, FloatBuffer gearColor, float inner_radius, float outer_radius, float width, int teeth, - float tooth_depth, + float tooth_depth, PMVMatrix pmvMatrix, - GLUniformData pmvMatrixUniform, GLUniformData colorUniform) + GLUniformData pmvMatrixUniform, GLUniformData colorUniform) { super(gearColor, inner_radius, outer_radius, width, teeth, tooth_depth); this.pmvMatrix = pmvMatrix; @@ -56,9 +56,9 @@ public class GearsObjectES2 extends GearsObject { } public GearsObjectES2(GearsObjectES2 shared, - ShaderState st, + ShaderState st, PMVMatrix pmvMatrix, - GLUniformData pmvMatrixUniform, GLUniformData colorUniform) + GLUniformData pmvMatrixUniform, GLUniformData colorUniform) { super(shared); this.pmvMatrix = pmvMatrix; @@ -67,29 +67,45 @@ public class GearsObjectES2 extends GearsObject { this.st = st; associate(st); } - + private void associate(ShaderState st) { frontFace.associate(st, true); frontSide.associate(st, true); backFace.associate(st, true); backSide.associate(st, true); outwardFace.associate(st, true); - insideRadiusCyl.associate(st, true); + insideRadiusCyl.associate(st, true); + } + + @Override + public GLArrayDataServer createInterleaveClone(GLArrayDataServer ads) { + final FloatBuffer fb0 = (FloatBuffer) ads.getBuffer(); + final FloatBuffer fb1 = fb0.slice(); + // manual 'unseal' + fb1.position(fb1.limit()); + fb1.limit(fb1.capacity()); + + final GLArrayDataServer adsClone = GLArrayDataServer.createGLSLInterleaved(ads.getComponentCount(), ads.getComponentType(), ads.getNormalized(), + ads.getStride(), fb1, ads.getVBOUsage()); + adsClone.setVBOName(ads.getVBOName()); + adsClone.seal(true); + return adsClone; } @Override public GLArrayDataServer createInterleaved(int comps, int dataType, boolean normalized, int initialSize, int vboUsage) { return GLArrayDataServer.createGLSLInterleaved(comps, dataType, normalized, initialSize, vboUsage); } - + @Override public void addInterleavedVertexAndNormalArrays(GLArrayDataServer array, int components) { array.addGLSLSubArray("vertices", components, GL.GL_ARRAY_BUFFER); array.addGLSLSubArray("normals", components, GL.GL_ARRAY_BUFFER); } - private void draw(GL2ES2 gl, GLArrayDataServer array, int mode) { + private void draw(GL2ES2 gl, GLArrayDataServer array, int mode, int face) { array.enableBuffer(gl, true); + // System.err.println("XXX Draw face "+face+" of "+this); gl.glDrawArrays(mode, 0, array.getElementCount()); array.enableBuffer(gl, false); } @@ -109,13 +125,13 @@ public class GearsObjectES2 extends GearsObject { colorUniform.setData(gearColor); st.uniform(gl, colorUniform); - draw(gl, frontFace, GL.GL_TRIANGLE_STRIP); - draw(gl, frontSide, GL.GL_TRIANGLES); - draw(gl, backFace, GL.GL_TRIANGLE_STRIP); - draw(gl, backSide, GL.GL_TRIANGLES); - draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP); - draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP); - + draw(gl, frontFace, GL.GL_TRIANGLE_STRIP, 0); + draw(gl, frontSide, GL.GL_TRIANGLES, 1); + draw(gl, backFace, GL.GL_TRIANGLE_STRIP, 2); + draw(gl, backSide, GL.GL_TRIANGLES, 3); + draw(gl, outwardFace, GL.GL_TRIANGLE_STRIP, 4); + draw(gl, insideRadiusCyl, GL.GL_TRIANGLE_STRIP, 5); + pmvMatrix.glPopMatrix(); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index b1e9f477e..cd14835bb 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -735,12 +735,22 @@ public class AWTRobotUtil { * * @return True if the GLContext becomes created or not within TIME_OUT */ - public static boolean waitForCreated(GLContext context, boolean created) throws InterruptedException { - if( null == context ) { + public static boolean waitForContextCreated(GLAutoDrawable autoDrawable, boolean created) throws InterruptedException { + if( null == autoDrawable ) { return !created; } int wait; - for (wait=0; wait Date: Mon, 28 Oct 2013 19:34:20 +0100 Subject: Bug 776 GLContext Sharing: Add GLSharedContextSetter to SWT GLCanvas --- make/build-test.xml | 2 +- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/opengl/swt/GLCanvas.java | 183 +++++++--- .../jogl/acore/TestSharedContextVBOES2AWT3.java | 2 +- .../jogl/acore/TestSharedContextVBOES2AWT3b.java | 2 +- .../jogl/acore/TestSharedContextVBOES2SWT3.java | 367 +++++++++++++++++++++ .../junit/jogl/demos/es2/swt/TestGearsES2SWT.java | 58 ++-- .../junit/jogl/swt/TestSWTBug643AsyncExec.java | 2 +- .../junit/jogl/swt/TestSWTJOGLGLCanvas01GLn.java | 42 +-- 10 files changed, 571 insertions(+), 95 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java (limited to 'make/scripts') diff --git a/make/build-test.xml b/make/build-test.xml index b7220aed6..d4274cd76 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -478,7 +478,7 @@ - + diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 71ac8c43d..0632c24b0 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -14,10 +14,10 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedConte REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 0f3388fb3..6a8ff80ca 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -377,10 +377,10 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java index 5e3731984..1268e9569 100644 --- a/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java +++ b/src/jogl/classes/com/jogamp/opengl/swt/GLCanvas.java @@ -52,6 +52,7 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import javax.media.opengl.GLRunnable; +import javax.media.opengl.GLSharedContextSetter; import javax.media.opengl.Threading; import jogamp.nativewindow.x11.X11Util; @@ -85,7 +86,7 @@ import com.jogamp.opengl.JoglVersion; * Implementation allows use of custom {@link GLCapabilities}. *

      */ -public class GLCanvas extends Canvas implements GLAutoDrawable { +public class GLCanvas extends Canvas implements GLAutoDrawable, GLSharedContextSetter { private static final boolean DEBUG = Debug.debug("GLCanvas"); /* @@ -103,7 +104,6 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final RecursiveLock lock = LockFactory.createRecursiveLock(); private final GLDrawableHelper helper = new GLDrawableHelper(); - private final GLContext shareWith; private final GLCapabilitiesImmutable capsRequested; private final GLCapabilitiesChooser capsChooser; @@ -124,6 +124,10 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { /* Flag indicating whether an unprocessed reshape is pending. */ private volatile boolean sendReshape; // volatile: maybe written by WindowManager thread w/o locking + private static String getThreadName() { return Thread.currentThread().getName(); } + private static String toHexString(int v) { return "0x"+Integer.toHexString(v); } + private static String toHexString(long v) { return "0x"+Long.toHexString(v); } + /* * Invokes init(...) on all GLEventListeners. Assumes context is current when run. */ @@ -262,6 +266,36 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } }; + /** + * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser)} + * on the SWT thread. + * + * @param parent + * Required (non-null) parent Composite. + * @param style + * Optional SWT style bit-field. The {@link SWT#NO_BACKGROUND} bit is set before passing this up to the + * Canvas constructor, so OpenGL handles the background. + * @param caps + * Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the + * graphics device determined by the parent Composite are used. Note that the GLCapabilities that are + * actually used may differ based on the capabilities of the graphics device. + * @param chooser + * Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the + * requested GLCapabilities, and the available capabilities of the graphics device. + * @return a new instance + */ + public static GLCanvas create(final Composite parent, final int style, final GLCapabilitiesImmutable caps, + final GLCapabilitiesChooser chooser) { + final GLCanvas[] res = new GLCanvas[] { null }; + parent.getDisplay().syncExec(new Runnable() { + @Override + public void run() { + res[0] = new GLCanvas( parent, style, caps, chooser ); + } + }); + return res[0]; + } + /** * Creates an instance using {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser, GLContext)} * on the SWT thread. @@ -281,6 +315,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * @param shareWith * Optional GLContext to share state (textures, vbos, shaders, etc.) with. * @return a new instance + * @deprecated Use {@link #create(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser)} + * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. */ public static GLCanvas create(final Composite parent, final int style, final GLCapabilitiesImmutable caps, final GLCapabilitiesChooser chooser, final GLContext shareWith) { @@ -294,6 +330,27 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { return res[0]; } + /** + * Creates a new SWT GLCanvas. + * + * @param parent + * Required (non-null) parent Composite. + * @param style + * Optional SWT style bit-field. The {@link SWT#NO_BACKGROUND} bit is set before passing this up to the + * Canvas constructor, so OpenGL handles the background. + * @param capsReqUser + * Optional GLCapabilities. If not provided, the default capabilities for the default GLProfile for the + * graphics device determined by the parent Composite are used. Note that the GLCapabilities that are + * actually used may differ based on the capabilities of the graphics device. + * @param capsChooser + * Optional GLCapabilitiesChooser to customize the selection of the used GLCapabilities based on the + * requested GLCapabilities, and the available capabilities of the graphics device. + */ + public GLCanvas(final Composite parent, final int style, GLCapabilitiesImmutable capsReqUser, + final GLCapabilitiesChooser capsChooser) { + this(parent, style, capsReqUser, capsChooser, null); + } + /** * Creates a new SWT GLCanvas. * @@ -311,6 +368,8 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { * requested GLCapabilities, and the available capabilities of the graphics device. * @param shareWith * Optional GLContext to share state (textures, vbos, shaders, etc.) with. + * @deprecated Use {@link #GLCanvas(Composite, int, GLCapabilitiesImmutable, GLCapabilitiesChooser)} + * and set shared GLContext via {@link #setSharedContext(GLContext)} or {@link #setSharedAutoDrawable(GLAutoDrawable)}. */ public GLCanvas(final Composite parent, final int style, GLCapabilitiesImmutable capsReqUser, final GLCapabilitiesChooser capsChooser, final GLContext shareWith) { @@ -347,7 +406,9 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { this.capsRequested = capsReqUser; this.capsChooser = capsChooser; - this.shareWith = shareWith; + if( null != shareWith ) { + helper.setSharedContext(null, shareWith); + } // post create .. when ready gdkWindow = 0; @@ -376,6 +437,16 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { addListener (SWT.Dispose, listener); } + @Override + public final void setSharedContext(GLContext sharedContext) throws IllegalStateException { + helper.setSharedContext(this.context, sharedContext); + } + + @Override + public final void setSharedAutoDrawable(GLAutoDrawable sharedAutoDrawable) throws IllegalStateException { + helper.setSharedAutoDrawable(this, sharedAutoDrawable); + } + private final UpstreamSurfaceHook swtCanvasUpStreamHook = new UpstreamSurfaceHook() { @Override public final void create(ProxySurface s) { /* nop */ } @@ -411,7 +482,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final boolean drawableOK = null != _drawable && _drawable.isRealized(); if(DEBUG) { final long dh = drawableOK ? _drawable.getHandle() : 0; - System.err.println("GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+nClientArea.x+"/"+nClientArea.y+" "+nClientArea.width+"x"+nClientArea.height+" - drawableHandle 0x"+Long.toHexString(dh)); + System.err.println(getThreadName()+": GLCanvas.sizeChanged: ("+Thread.currentThread().getName()+"): "+nClientArea.x+"/"+nClientArea.y+" "+nClientArea.width+"x"+nClientArea.height+" - drawableHandle "+toHexString(dh)); } if( drawableOK ) { if( ! _drawable.getChosenGLCapabilities().isOnscreen() ) { @@ -451,7 +522,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { } } - /** assumes drawable == null || !drawable.isRealized() ! Checks of !isDispose() and isVisible() */ + /** assumes drawable == null (implying !drawable.isRealized()) ! Checks of !isDispose() and isVisible() */ protected final boolean validateDrawableAndContextWithCheck() { if( !isValidAndVisibleOnEDT() ) { return false; @@ -459,41 +530,55 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { return validateDrawableAndContextPostCheck(); } - /** assumes drawable == null || !drawable.isRealized() ! No check of !isDispose() and isVisible() */ - protected final boolean validateDrawableAndContextPostCheck() { - final Rectangle nClientArea = clientArea; - if(0 >= nClientArea.width || 0 >= nClientArea.height) { - return false; - } + private final boolean isDrawableAndContextValid() { + // drawable != null implies drawable.isRealized()==true + return null != drawable && null != context; + } - final boolean res; + /** assumes drawable == null (implying !drawable.isRealized()) || context == null ! No check of !isDispose() and isVisible() */ + private final boolean validateDrawableAndContextPostCheck() { + boolean res; final RecursiveLock _lock = lock; _lock.lock(); try { if(null == drawable) { - createDrawableAndContext(); + // 'displayable' (isValidAndVisibleOnEDT()) must have been checked upfront if appropriate! + createDrawableImpl(); // checks clientArea size (i.e. drawable size) and perf. realization } - if(null != drawable) { - drawable.setRealized(true); - res = drawable.isRealized(); + final GLDrawable _drawable = drawable; + if ( null != _drawable ) { + // drawable realization goes in-hand w/ it's construction + if( null == context ) { + // re-try context creation + res = createContextImpl(_drawable); // pending creation. + } else { + res = true; + } + if(res) { + sendReshape = true; + } } else { + if(DEBUG) { + System.err.println(getThreadName()+": SWT.GLCanvas.validate "+toHexString(hashCode())+": null drawable"); + } res = false; } - } finally { - _lock.unlock(); - } - - if(res) { - sendReshape = true; if(DEBUG) { - System.err.println("SWT GLCanvas realized! "+this+", "+drawable); - // Thread.dumpStack(); + System.err.println(getThreadName()+": SWT.GLCanvas.validate.X "+toHexString(hashCode())+": "+res+", drawable-realized "+drawable.isRealized()+", has context "+(null!=context)); } + } finally { + _lock.unlock(); } return res; } - - private final void createDrawableAndContext() { + private final void createDrawableImpl() { + final Rectangle nClientArea = clientArea; + if(0 >= nClientArea.width || 0 >= nClientArea.height) { + if(DEBUG) { + System.err.println(getThreadName()+": SWT.GLCanvas.validate.X "+toHexString(hashCode())+": drawable could not be created: size < 0x0"); + } + return; // early out + } final AbstractGraphicsDevice device = screen.getDevice(); device.open(); @@ -503,7 +588,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { final AbstractGraphicsConfiguration cfg = factory.chooseGraphicsConfiguration( capsRequested, capsRequested, capsChooser, screen, VisualIDHolder.VID_UNDEFINED); if(DEBUG) { - System.err.println("SWT.GLCanvas.X11 factory: "+factory+", chosen config: "+cfg); + System.err.println(getThreadName()+": SWT.GLCanvas.X11 "+toHexString(hashCode())+": factory: "+factory+", chosen config: "+cfg); } if (null == cfg) { throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this); @@ -515,7 +600,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { x11Window = SWTAccessor.createCompatibleX11ChildWindow(screen, this, visualID, clientArea.width, clientArea.height); nativeWindowHandle = x11Window; } else { - throw new GLException("Could not choose valid visualID: 0x"+Integer.toHexString(visualID)+", "+this); + throw new GLException("Could not choose valid visualID: "+toHexString(visualID)+", "+this); } } else { nativeWindowHandle = SWTAccessor.getWindowHandle(this); @@ -526,9 +611,35 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { ProxySurface proxySurface = glFactory.createProxySurface(device, screen.getIndex(), nativeWindowHandle, capsRequested, capsChooser, swtCanvasUpStreamHook); // Associate a GL surface with the proxy - drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); - context = (GLContextImpl) drawable.createContext(shareWith); - context.setContextCreationFlags(additionalCtxCreationFlags); + final GLDrawableImpl _drawable = (GLDrawableImpl) glFactory.createGLDrawable(proxySurface); + _drawable.setRealized(true); + if(!_drawable.isRealized()) { + // oops + if(DEBUG) { + System.err.println(getThreadName()+": SWT.GLCanvas.validate.X "+toHexString(hashCode())+": Drawable could not be realized: "+_drawable); + } + } else { + if(DEBUG) { + System.err.println(getThreadName()+": SWT.GLCanvas.validate "+toHexString(hashCode())+": Drawable created and realized"); + } + drawable = _drawable; + } + } + private boolean createContextImpl(final GLDrawable drawable) { + final GLContext[] shareWith = { null }; + if( !helper.isSharedGLContextPending(shareWith) ) { + context = (GLContextImpl) drawable.createContext(shareWith[0]); + context.setContextCreationFlags(additionalCtxCreationFlags); + if(DEBUG) { + System.err.println(getThreadName()+": SWT.GLCanvas.validate "+toHexString(hashCode())+": Context created: has shared "+(null != shareWith[0])); + } + return true; + } else { + if(DEBUG) { + System.err.println(getThreadName()+": SWT.GLCanvas.validate "+toHexString(hashCode())+": Context !created: pending share"); + } + return false; + } } @Override @@ -555,8 +666,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { private final void displayIfNoAnimatorNoCheck() { if ( !helper.isAnimatorAnimatingOnOtherThread() ) { - final boolean drawableOK = null != drawable && drawable.isRealized(); - if( drawableOK || validateDrawableAndContextPostCheck() ) { + if( isDrawableAndContextValid() || validateDrawableAndContextPostCheck() ) { runInGLThread(makeCurrentAndDisplayOnGLAction); } } @@ -568,8 +678,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { @Override public void display() { - final boolean drawableOK = null != drawable && drawable.isRealized(); - if( drawableOK || validateDrawableAndContextWithCheck() ) { + if( isDrawableAndContextValid() || validateDrawableAndContextWithCheck() ) { runInGLThread(makeCurrentAndDisplayOnGLAction); } } @@ -876,7 +985,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { return "SWT-GLCanvas[Realized "+isRealized()+ ",\n\t"+((null!=_drawable)?_drawable.getClass().getName():"null-drawable")+ ",\n\tFactory "+getFactory()+ - ",\n\thandle 0x"+Long.toHexString(getHandle())+ + ",\n\thandle "+toHexString(getHandle())+ ",\n\tDrawable size "+dw+"x"+dh+ ",\n\tSWT size "+getWidth()+"x"+getHeight()+"]"; } @@ -895,7 +1004,7 @@ public class GLCanvas extends Canvas implements GLAutoDrawable { shell.setSize(128,128); shell.setLayout(new FillLayout()); - final GLCanvas canvas = new GLCanvas(shell, 0, caps, null, null); + final GLCanvas canvas = new GLCanvas(shell, 0, caps, null); canvas.addGLEventListener(new GLEventListener() { @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java index 5cf2e4b24..710a9772b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java @@ -50,7 +50,7 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; /** - * Sharing the VBO of 3 GearsES2 instances, each in their own GLCanvas. + * Sharing the VBO of 3 GearsES2 instances, each in their own AWT GLCanvas. *

      * This is achieved by using the 1st GLCanvas as the master * and using the build-in blocking mechanism to postpone creation diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java index 07b9fd4eb..c35b0658c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java @@ -50,7 +50,7 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; /** - * Sharing the VBO of 3 GearsES2 instances, each in their own GLJPanel. + * Sharing the VBO of 3 GearsES2 instances, each in their own AWT GLJPanel. *

      * This is achieved by using the 1st GLJPanel as the master * and using the build-in blocking mechanism to postpone creation diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java new file mode 100644 index 000000000..9b6ab88fa --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java @@ -0,0 +1,367 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.util.List; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLProfile; + +import com.jogamp.nativewindow.swt.SWTAccessor; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.swt.GLCanvas; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.junit.After; +import org.junit.Assert; +import org.junit.Assume; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +/** + * Sharing the VBO of 3 GearsES2 instances, each in their own SWT GLCanvas. + *

      + * This is achieved by using the 1st GLCanvas as the master + * and using the build-in blocking mechanism to postpone creation + * of the 2nd and 3rd GLCanvas until the 1st GLCanvas's GLContext becomes created. + *

      + *

      + * Above method allows random creation of the 1st GLCanvas in theory, which triggers + * creation of the dependent other GLCanvas sharing it's GLContext.
      + * However, since this test may perform on the main thread we have + * to initialize all in order, since otherwise the test main thread + * itself blocks SWT GLCanvas creation .. + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestSharedContextVBOES2SWT3 extends UITestCase { + static GLProfile glp; + static GLCapabilities caps; + static int width, height; + + @BeforeClass + public static void initClass() { + if(GLProfile.isAvailable(GLProfile.GL2ES2)) { + glp = GLProfile.get(GLProfile.GL2ES2); + Assert.assertNotNull(glp); + caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + width = 256; + height = 256; + } else { + setTestSupported(false); + } + } + + Display display = null; + Shell shell1 = null; + Composite composite1 = null; + Shell shell2 = null; + Composite composite2 = null; + Shell shell3 = null; + Composite composite3 = null; + + @Before + public void init() { + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display = new Display(); + Assert.assertNotNull( display ); + }}); + display.syncExec(new Runnable() { + public void run() { + shell1 = new Shell( display ); + shell1.setLayout( new FillLayout() ); + composite1 = new Composite( shell1, SWT.NO_BACKGROUND ); + composite1.setLayout( new FillLayout() ); + + shell2 = new Shell( display ); + shell2.setLayout( new FillLayout() ); + composite2 = new Composite( shell2, SWT.NO_BACKGROUND ); + composite2.setLayout( new FillLayout() ); + + shell3 = new Shell( display ); + shell3.setLayout( new FillLayout() ); + composite3 = new Composite( shell3, SWT.NO_BACKGROUND ); + composite3.setLayout( new FillLayout() ); + }}); + } + + @After + public void release() { + Assert.assertNotNull( display ); + Assert.assertNotNull( shell1 ); + Assert.assertNotNull( composite1 ); + Assert.assertNotNull( shell2 ); + Assert.assertNotNull( composite2 ); + Assert.assertNotNull( shell3 ); + Assert.assertNotNull( composite3 ); + try { + display.syncExec(new Runnable() { + public void run() { + composite3.dispose(); + shell3.dispose(); + composite2.dispose(); + shell2.dispose(); + composite1.dispose(); + shell1.dispose(); + }}); + SWTAccessor.invoke(true, new Runnable() { + public void run() { + display.dispose(); + }}); + } + catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + display = null; + shell1 = null; + composite1 = null; + shell2 = null; + composite2 = null; + shell3 = null; + composite3 = null; + } + + protected GLCanvas createGLCanvas(final Shell shell, final Composite composite, final int x, final int y, GearsES2 gears) throws InterruptedException { + final GLCanvas glCanvas = GLCanvas.create( composite, 0, caps, null); + Assert.assertNotNull( glCanvas ); + glCanvas.addGLEventListener(gears); + display.syncExec(new Runnable() { + public void run() { + shell.setText("SWT GLCanvas Shared Gears Test"); + shell.setSize( width, height); + shell.setLocation(x, y); + } } ); + return glCanvas; + } + + @Test + public void test01SyncedOneAnimator() throws InterruptedException { + final Animator animator = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLCanvas c1 = createGLCanvas(shell1, composite1, 0, 0, g1); + animator.add(c1); + + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLCanvas c2 = createGLCanvas(shell2, composite2, 0+width, 0+0, g2); + c2.setSharedAutoDrawable(c1); + animator.add(c2); + + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLCanvas c3 = createGLCanvas(shell3, composite3, 0, height, g3); + c3.setSharedAutoDrawable(c1); + animator.add(c3); + + display.syncExec(new Runnable() { + public void run() { + shell1.open(); // master .. + shell2.open(); // shall wait until f1 is ready + shell3.open(); // shall wait until f1 is ready + } } ); + animator.start(); // kicks off GLContext .. and hence gears of f2 + f3 completion + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c2, true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c3, true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = c1.getContext(); + final GLContext ctx2 = c2.getContext(); + final GLContext ctx3 = c3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + animator.stop(); + + display.syncExec(new Runnable() { + public void run() { + c3.dispose(); + c2.dispose(); + c1.dispose(); + } } ); + } + + @Test + public void test02AsyncEachAnimator() throws InterruptedException { + final Animator a1 = new Animator(); + final GearsES2 g1 = new GearsES2(0); + final GLCanvas c1 = createGLCanvas(shell1, composite1, 0, 0, g1); + a1.add(c1); + display.syncExec(new Runnable() { + public void run() { + shell1.open(); + } } ); + a1.start(); + + + Thread.sleep(1000/60*10); // wait ~10 frames giving a chance to create (blocking until master share is valid) + + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c1, true)); + Assert.assertTrue("Gears1 not initialized", g1.waitForInit(true)); + + final Animator a2 = new Animator(); + final GearsES2 g2 = new GearsES2(0); + g2.setSharedGears(g1); + final GLCanvas c2 = createGLCanvas(shell2, composite2, width, 0, g2); + c2.setSharedAutoDrawable(c1); + a2.add(c2); + display.syncExec(new Runnable() { + public void run() { + shell2.open(); + } } ); + a2.start(); + + Thread.sleep(200); // wait a while .. + + final Animator a3 = new Animator(); + final GearsES2 g3 = new GearsES2(0); + g3.setSharedGears(g1); + final GLCanvas c3 = createGLCanvas(shell3, composite3, 0, height, g3); + c3.setSharedAutoDrawable(c1); + a3.add(c3); + display.syncExec(new Runnable() { + public void run() { + shell3.open(); + } } ); + a3.start(); + + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c2, true)); + Assert.assertTrue("Gears2 not initialized", g2.waitForInit(true)); + + Assert.assertTrue(AWTRobotUtil.waitForContextCreated(c3, true)); + Assert.assertTrue("Gears3 not initialized", g3.waitForInit(true)); + + final GLContext ctx1 = c1.getContext(); + final GLContext ctx2 = c2.getContext(); + final GLContext ctx3 = c3.getContext(); + { + final List ctx1Shares = ctx1.getCreatedShares(); + final List ctx2Shares = ctx2.getCreatedShares(); + final List ctx3Shares = ctx3.getCreatedShares(); + System.err.println("XXX-C-3.1:"); + MiscUtils.dumpSharedGLContext(ctx1); + System.err.println("XXX-C-3.2:"); + MiscUtils.dumpSharedGLContext(ctx2); + System.err.println("XXX-C-3.3:"); + MiscUtils.dumpSharedGLContext(ctx3); + + Assert.assertTrue("Ctx1 is not shared", ctx1.isShared()); + Assert.assertTrue("Ctx2 is not shared", ctx2.isShared()); + Assert.assertTrue("Ctx3 is not shared", ctx3.isShared()); + Assert.assertEquals("Ctx1 has unexpected number of created shares", 2, ctx1Shares.size()); + Assert.assertEquals("Ctx2 has unexpected number of created shares", 2, ctx2Shares.size()); + Assert.assertEquals("Ctx3 has unexpected number of created shares", 2, ctx3Shares.size()); + } + + Assert.assertTrue("Gears1 is shared", !g1.usesSharedGears()); + Assert.assertTrue("Gears2 is not shared", g2.usesSharedGears()); + Assert.assertTrue("Gears3 is not shared", g3.usesSharedGears()); + + try { + Thread.sleep(duration); + } catch(Exception e) { + e.printStackTrace(); + } + a1.stop(); + a2.stop(); + a3.stop(); + + display.syncExec(new Runnable() { + public void run() { + c3.dispose(); + c2.dispose(); + c1.dispose(); + } } ); + } + + static long duration = 1000; // ms + + public static void main(String args[]) { + for(int i=0; i + *

      * Uses JOGL's new SWT GLCanvas, * which allows utilizing custom GLCapability settings, * independent from the already instantiated SWT visual. *

      *

      - * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ + * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ * SWT running on Mac OSX, i.e. to enforce UI action on the main thread. *

      * @author Wade Walker, et al. @@ -76,7 +76,7 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { static int duration = 250; static boolean doAnimation = true; - + static final int iwidth = 640; static final int iheight = 480; @@ -92,12 +92,12 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { @Before public void init() { SWTAccessor.invoke(true, new Runnable() { - public void run() { + public void run() { display = new Display(); Assert.assertNotNull( display ); }}); display.syncExec(new Runnable() { - public void run() { + public void run() { shell = new Shell( display ); Assert.assertNotNull( shell ); shell.setLayout( new FillLayout() ); @@ -134,14 +134,14 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { protected void runTestAGL( GLCapabilitiesImmutable caps, GLEventListener demo ) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - - final GLCanvas canvas = GLCanvas.create( composite, 0, caps, null, null); + + final GLCanvas canvas = GLCanvas.create( composite, 0, caps, null); Assert.assertNotNull( canvas ); canvas.addGLEventListener( demo ); canvas.addGLEventListener(new GLEventListener() { int displayCount = 0; - public void init(final GLAutoDrawable drawable) { } + public void init(final GLAutoDrawable drawable) { } public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } public void display(final GLAutoDrawable drawable) { if(displayCount < 3) { @@ -149,21 +149,21 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { } } public void dispose(final GLAutoDrawable drawable) { } - }); - + }); + display.syncExec(new Runnable() { public void run() { shell.setText( getSimpleTestName(".") ); shell.setSize( 640, 480 ); shell.open(); } } ); - + Animator anim = new Animator(); if(doAnimation) { anim.add(canvas); anim.start(); - } - + } + long lStartTime = System.currentTimeMillis(); long lEndTime = lStartTime + duration; try { @@ -177,9 +177,9 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } - + anim.stop(); - + display.syncExec(new Runnable() { public void run() { canvas.dispose(); @@ -198,7 +198,7 @@ public class TestSWTJOGLGLCanvas01GLn extends UITestCase { caps.setNumSamples(2); runTestAGL( caps, new MultisampleDemoES2(true) ); } - + static int atoi(String a) { int i=0; try { -- cgit v1.2.3 From 5cb08416a6ed44814065771f469a94f79c49ab3f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Oct 2013 00:58:58 +0100 Subject: Bug 776 GLContext Sharing: GLSharedContextSetter API Doc: No 'Driver stability constraints' ; Fixing Test cases: Enable all, GearsObject*: Check VBO - GLSharedContextSetter API Doc: No 'Driver stability constraints' - No driver issues .. - Use 'Lifecycle Considerations' to describe usage issues .. - Fixing Test cases: Enable all, GearsObject*: Check VBO - GearsObject* needs to check whether VBO is 'still alive' if sharing is enabled. - Enable all unit tests. --- make/scripts/tests.sh | 8 ++-- .../javax/media/opengl/GLSharedContextSetter.java | 46 +++++++++++++++------- .../jogl/acore/TestSharedContextVBOES2AWT3.java | 10 ++--- .../jogl/acore/TestSharedContextVBOES2NEWT1.java | 6 +-- .../jogl/acore/TestSharedContextVBOES2NEWT2.java | 8 ++-- .../jogl/acore/TestSharedContextVBOES2NEWT3.java | 6 +-- .../test/junit/jogl/demos/es1/GearsObjectES1.java | 8 ++-- .../test/junit/jogl/demos/es2/GearsObjectES2.java | 10 +++-- 8 files changed, 57 insertions(+), 45 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6a8ff80ca..8a59e68e3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -84,8 +84,10 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG" #D_ARGS="-Djogl.disable.opengles" - #D_ARGS="-Djogl.debug.DebugGL" + #D_ARGS="-Djogl.debug.DebugGL -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" + #D_ARGS="-Djogl.debug.TraceGL" + #D_ARGS="-Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" @@ -376,10 +378,10 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java index 8c2311329..fd48d12bf 100644 --- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -36,24 +36,40 @@ package javax.media.opengl; *

      *

      * A master {@link GLContext} is the {@link GLContext} which is created first, - * shared {@link GLContext} w/ this master are referred as slave {@link GLContext}. + * shared {@link GLContext} w/ this master are referred as slave {@link GLContext} + * and controls the shared object's lifecycle, i.e. their construction and destruction. *

      - *
      Driver stability constraints
      + *
      Lifecycle Considerations
      *

      - * Be aware that the master {@link GLContext} and related resources, i.e. the {@link GLAutoDrawable}, - * shall not be destroyed before it's slave {@link GLContext} instances.
      - * Otherwise the OpenGL driver implementation may crash w/ SIGSEGV if shared resources are still used!
      - * Note that this is not specified within OpenGL and should work, however, some drivers - * do not seem to handle this situation well, i.e. they do not postpone resource destruction - * until the last reference is removed.
      - * Since pending destruction of {@link GLContext} and it's {@link GLDrawable} is complex and nearly impossible - * for us at the top level, considering the different windowing systems and {@link GLAutoDrawable} types, - * the user shall take care of proper destruction order. + * Be aware that the master {@link GLContext} and related resources + * shall not be destroyed before it's slave {@link GLContext} instances while they are using them.
      + * Otherwise the OpenGL driver implementation may crash w/ SIGSEGV, since using already destroyed resources, + * e.g. OpenGL buffer objects, may not be validated by the driver!
      *

      *

      - * Users may use a {@link GLDrawableFactory#createDummyDrawable(javax.media.nativewindow.AbstractGraphicsDevice, boolean, GLProfile) dummy} + * Either proper lifecycle synchronization is implemented, e.g. by notifying the slaves about the loss of the shared resources, + * or the slaves validate whether the resources are still valid. + *

      + *

      + * To simplify above lifecycle issues, one may use a {@link GLDrawableFactory#createDummyDrawable(javax.media.nativewindow.AbstractGraphicsDevice, boolean, GLProfile) dummy} * {@link GLDrawable} and it's {@link GLContext} as the master of all shared slave {@link GLContext}. - * Same constraints as above apply, i.e. it shall be destroyed after all shared slaves. + * Since this dummy instance does not depend on any native windowing system, it can be controlled easily w/o being in sight.
      + * Below code creates a {@link GLAutoDrawable} based on a dummy GLDrawable: + *

      +        // GLProfile and GLCapabilities should be equal across all shared GL drawable/context.
      +        final GLCapabilitiesImmutable caps = ... ;
      +        final GLProfile glp = caps.getGLProfile();
      +        ..
      +        final boolean createNewDevice = true; // use 'own' display device!
      +        final GLAutoDrawable sharedDrawable = GLDrawableFactory.getFactory(glp).createDummyAutoDrawable(null, createNewDevice, glp);
      +        sharedDrawable.display(); // triggers GLContext object creation and native realization.
      +        ...
      +        // Later a shared 'slave' can be created e.g.:
      +        GLWindow glad = GLWindow.create(caps); // or any other GLAutoDrawable supporting GLSharedContextSetter
      +        glad.setSharedAutoDrawable(sharedDrawable);
      +        glad.addGLEventListener(..);
      +        glad.setVisible(true); // GLWindow creation ..
      + * 
      *

      */ public interface GLSharedContextSetter extends GLAutoDrawable { @@ -69,7 +85,7 @@ public interface GLSharedContextSetter extends GLAutoDrawable { * as long it is not {@link GLContext#isCreated() created natively}. *

      *

      - * See driver stability constraints. + * See Lifecycle Considerations. *

      * * @param sharedContext The OpenGL context to be shared by this {@link GLAutoDrawable}'s {@link GLContext}. @@ -93,7 +109,7 @@ public interface GLSharedContextSetter extends GLAutoDrawable { * or has not been {@link GLContext#isCreated() created natively}. *

      *

      - * See driver stability constraints. + * See Lifecycle Considerations. *

      * * @param sharedContext The GLAutoDrawable, which OpenGL context shall be shared by this {@link GLAutoDrawable}'s {@link GLContext}. diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java index 710a9772b..ede01b52f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java @@ -97,8 +97,7 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { syncedOneAnimator(true); } - // Don't test erroneous test case ! - // @Test + @Test public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException, InvocationTargetException { syncedOneAnimator(false); } @@ -234,13 +233,12 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } @Test - public void test11SyncEachAnimatorCleanDtorOrder() throws InterruptedException, InvocationTargetException { + public void test11AsyncEachAnimatorCleanDtorOrder() throws InterruptedException, InvocationTargetException { syncedOneAnimator(true); } - // Don't test erroneous test case ! - // @Test - public void test12SyncEachAnimatorDirtyDtorOrder() throws InterruptedException, InvocationTargetException { + @Test + public void test12AsyncEachAnimatorDirtyDtorOrder() throws InterruptedException, InvocationTargetException { asyncEachOneAnimator(false); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java index 827601869..3cd26028b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java @@ -34,11 +34,9 @@ import javax.media.nativewindow.util.InsetsImmutable; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLContext; -import javax.media.opengl.GLDrawable; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLProfile; -import com.jogamp.opengl.GLAutoDrawableDelegate; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; @@ -107,9 +105,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { glWindow.setVisible(true); sharedDrawable = glWindow; } else { - GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile()); - dummyDrawable.setRealized(true); - sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { }; + sharedDrawable = GLDrawableFactory.getFactory(glp).createDummyAutoDrawable(null, true /* createNewDevice */, caps.getGLProfile()); } Assert.assertNotNull(sharedDrawable); Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true)); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java index d9fe2a949..24dc09ffb 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java @@ -100,8 +100,7 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { syncedOneAnimator(true); } - // Don't test erroneous test case ! - // @Test + @Test public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException { syncedOneAnimator(false); } @@ -215,12 +214,11 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { } @Test - public void test11ASyncEachAnimatorCleanDtorOrder() throws InterruptedException { + public void test11AsyncEachAnimatorCleanDtorOrder() throws InterruptedException { asyncEachAnimator(true); } - // Don't test erroneous test case ! - // @Test + @Test public void test12AsyncEachAnimatorDirtyDtorOrder() throws InterruptedException { asyncEachAnimator(false); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java index adadf85e3..96a8a5094 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java @@ -97,8 +97,7 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { syncedOneAnimator(true); } - // Don't test erroneous test case ! - // @Test + @Test public void test02SyncedOneAnimatorDirtyDtorOrder() throws InterruptedException { syncedOneAnimator(false); } @@ -203,8 +202,7 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { asyncEachAnimator(true); } - // Don't test erroneous test case ! - // @Test + @Test public void test12AsyncEachAnimatorDirtyDtorOrder() throws InterruptedException { asyncEachAnimator(false); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java index 1edf1c3a8..fb9251e75 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es1/GearsObjectES1.java @@ -52,9 +52,11 @@ public class GearsObjectES1 extends GearsObject { } private void draw(GL2ES1 gl, GLArrayDataServer array, int mode) { - array.enableBuffer(gl, true); - gl.glDrawArrays(mode, 0, array.getElementCount()); - array.enableBuffer(gl, false); + if( !isShared || gl.glIsBuffer(array.getVBOName()) ) { + array.enableBuffer(gl, true); + gl.glDrawArrays(mode, 0, array.getElementCount()); + array.enableBuffer(gl, false); + } } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java index 82e9089cf..f3367ad1c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsObjectES2.java @@ -89,10 +89,12 @@ public class GearsObjectES2 extends GearsObject { } private void draw(GL2ES2 gl, GLArrayDataServer array, int mode, int face) { - array.enableBuffer(gl, true); - // System.err.println("XXX Draw face "+face+" of "+this); - gl.glDrawArrays(mode, 0, array.getElementCount()); - array.enableBuffer(gl, false); + if( !isShared || gl.glIsBuffer(array.getVBOName()) ) { + array.enableBuffer(gl, true); + // System.err.println("XXX Draw face "+face+" of "+this); + gl.glDrawArrays(mode, 0, array.getElementCount()); + array.enableBuffer(gl, false); + } } @Override -- cgit v1.2.3 From c53440b808ecf8ea066479c004cac4cdbb1e989d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 30 Oct 2013 01:57:34 +0100 Subject: Bug 776 GLContext Sharing: GLSharedContextSetter API Doc: Add 'glFinish()' to lifecycle considerations ; GearsES2: Add glFinish() after init(). --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java | 5 +++++ .../opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java | 8 ++++++++ .../test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java | 8 ++++++++ .../test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java | 2 ++ .../test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java | 8 ++++++++ .../opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java | 8 ++++++++ .../com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java | 3 +++ 8 files changed, 44 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 8a59e68e3..ee93334d4 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -377,8 +377,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java index fd48d12bf..873e4cd9f 100644 --- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -41,6 +41,11 @@ package javax.media.opengl; *

      *
      Lifecycle Considerations
      *

      + * After shared objects are created on the master, the OpenGL pipeline + * might need to be synchronized w/ the slaves, e.g. via {@link GL#glFinish()}. + * At least this has been experienced w/ OSX 10.9. + *

      + *

      * Be aware that the master {@link GLContext} and related resources * shall not be destroyed before it's slave {@link GLContext} instances while they are using them.
      * Otherwise the OpenGL driver implementation may crash w/ SIGSEGV, since using already destroyed resources, diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java index ede01b52f..3b576fabd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3.java @@ -181,7 +181,10 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); if( destroyCleanOrder ) { System.err.println("XXX Destroy in clean order NOW"); @@ -332,9 +335,14 @@ public class TestSharedContextVBOES2AWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); if( destroyCleanOrder ) { System.err.println("XXX Destroy in clean order NOW"); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java index c35b0658c..d4079e30c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2AWT3b.java @@ -172,7 +172,10 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -281,9 +284,14 @@ public class TestSharedContextVBOES2AWT3b extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java index 24dc09ffb..e8e4cc739 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT2.java @@ -308,6 +308,8 @@ public class TestSharedContextVBOES2NEWT2 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); Assert.assertEquals(false, a1.isAnimating()); a2.stop(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java index 96a8a5094..c94ae1140 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT3.java @@ -176,7 +176,10 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); if( destroyCleanOrder ) { System.err.println("XXX Destroy in clean order NOW"); @@ -287,9 +290,14 @@ public class TestSharedContextVBOES2NEWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); if( destroyCleanOrder ) { System.err.println("XXX Destroy in clean order NOW"); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java index 9b6ab88fa..9ccfd394f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2SWT3.java @@ -244,7 +244,10 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' animator.stop(); + Assert.assertEquals(false, animator.isAnimating()); display.syncExec(new Runnable() { public void run() { @@ -335,9 +338,14 @@ public class TestSharedContextVBOES2SWT3 extends UITestCase { } catch(Exception e) { e.printStackTrace(); } + // Stopped animator allows native windowing system 'repaint' event + // to trigger GLAD 'display' a1.stop(); + Assert.assertEquals(false, a1.isAnimating()); a2.stop(); + Assert.assertEquals(false, a2.isAnimating()); a3.stop(); + Assert.assertEquals(false, a3.isAnimating()); display.syncExec(new Runnable() { public void run() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 6c5ddf6e6..be7fcee07 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -304,6 +304,8 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.useProgram(gl, false); + gl.glFinish(); // make sure .. for shared context (impacts OSX 10.9) + System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+" FIN "+this); isInit = true; } @@ -429,6 +431,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL @Override public void display(GLAutoDrawable drawable) { if( !isInit ) { return; } + if(null != sharedGears && !sharedGears.isInit() ) { return; } GLAnimatorControl anim = drawable.getAnimator(); if( verbose && ( null == anim || !anim.isAnimating() ) ) { System.err.println(Thread.currentThread()+" GearsES2.display "+sid()+" "+drawable.getWidth()+"x"+drawable.getHeight()+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(drawable.getHandle())); -- cgit v1.2.3 From 24485ead77a368ae3b77108248e067ad1f44ef0a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 31 Oct 2013 04:32:28 +0100 Subject: Test Rename: Add Bug 729 / Bug 849 to Bug 816 Unit Test Names - Allowing a better unit test lookup --- make/scripts/tests.sh | 11 +- .../acore/TestSharedContextWithJTabbedPaneAWT.java | 3 +- .../jogl/awt/TestBug816OSXCALayerPos03aAWT.java | 165 -------------------- .../awt/TestBug816OSXCALayerPos03aB729AWT.java | 165 ++++++++++++++++++++ .../jogl/awt/TestBug816OSXCALayerPos03bAWT.java | 171 -------------------- .../awt/TestBug816OSXCALayerPos03bB849AWT.java | 171 ++++++++++++++++++++ .../jogl/awt/TestBug816OSXCALayerPos03cAWT.java | 173 --------------------- .../awt/TestBug816OSXCALayerPos03cB849AWT.java | 173 +++++++++++++++++++++ 8 files changed, 517 insertions(+), 515 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ee93334d4..db16343c3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -180,6 +180,7 @@ function jrun() { #D_ARGS="-Dnewt.debug=all -Djogamp.common.utils.locks.Lock.timeout=600000" #D_ARGS="-Djogl.debug.Animator -Dnewt.debug=all" #D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Display -Dnativewindow.debug.X11Util -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLDrawable -Djogl.debug.GLProfile" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.EDT -Djogamp.debug.Lock" @@ -304,6 +305,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -377,7 +379,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* @@ -470,9 +472,10 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $ #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java index 71993a023..d6a6f7bed 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextWithJTabbedPaneAWT.java @@ -202,7 +202,6 @@ public class TestSharedContextWithJTabbedPaneAWT extends UITestCase { static long durationPerTest = 500*4; // ms static boolean manual = false; - static volatile boolean shouldStop = false; @Test public void test01() throws InterruptedException, InvocationTargetException { @@ -216,7 +215,7 @@ public class TestSharedContextWithJTabbedPaneAWT extends UITestCase { } }); if(manual) { - for(long w=durationPerTest; !shouldStop && w>0; w-=100) { + for(long w=durationPerTest; w>0; w-=100) { Thread.sleep(100); } } else { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aAWT.java deleted file mode 100644 index 3451b75cc..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aAWT.java +++ /dev/null @@ -1,165 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.jogl.awt; - -import java.awt.BorderLayout; -import java.awt.Checkbox; -import java.awt.Frame; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.lang.reflect.InvocationTargetException; - -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; -import javax.media.opengl.awt.GLCanvas; - -import org.junit.Assert; -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runners.MethodSorters; - -import com.jogamp.newt.event.TraceWindowAdapter; -import com.jogamp.newt.event.awt.AWTWindowAdapter; -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.AWTRobotUtil; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.QuitAdapter; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; - -/** - * AWT Frame BorderLayout w/ Checkbox North, GLCanvas Center. - *

      - * Checkbox toggles GLCanvas visibility state. - *

      - *

      - * Validates bugs: - *

        - *
      • Bug 816: OSX CALayer Positioning Bug
      • - *
      • Bug 729: OSX CALayer shall honor the Component's visibility state
      • - *
      - *

      - *

      - * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 - *

      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBug816OSXCALayerPos03aAWT extends UITestCase { - static long duration = 1600; // ms - static int width=640, height=480; - - @Test - public void test() throws InterruptedException, InvocationTargetException { - final GLCapabilities caps = new GLCapabilities(getGLP()); - - final Frame frame = new Frame("TestBug816OSXCALayerPos03aAWT"); - Assert.assertNotNull(frame); - - final GLCanvas glCanvas1 = new GLCanvas(caps); - Assert.assertNotNull(glCanvas1); - glCanvas1.addGLEventListener(new GearsES2(1)); - - final Animator animator = new Animator(); - animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - - // Create a check box that hides / shows canvas - final Checkbox checkbox = new Checkbox("Visible canvas", true); - checkbox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent ev) { - glCanvas1.setVisible(checkbox.getState()); - System.out.println("Canvas visible: "+glCanvas1.isVisible()); - if( glCanvas1.isVisible() ) { - frame.validate(); // take care of resized frame while hidden - } - } - }); - - // Build a GUI that displays canvas and check box - frame.setLayout(new BorderLayout()); - frame.add(glCanvas1, BorderLayout.CENTER); - frame.add(checkbox, BorderLayout.NORTH); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setSize(width, height); - frame.setVisible(true); - }}); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); - - animator.start(); - Assert.assertTrue(animator.isStarted()); - Assert.assertTrue(animator.isAnimating()); - animator.setUpdateFPSFrames(60, System.err); - - final long t0 = System.currentTimeMillis(); - long t1 = t0; - while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - Assert.assertNotNull(frame); - Assert.assertNotNull(glCanvas1); - - Assert.assertNotNull(animator); - animator.stop(); - Assert.assertFalse(animator.isAnimating()); - Assert.assertFalse(animator.isStarted()); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - }}); - Assert.assertEquals(false, frame.isVisible()); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.remove(glCanvas1); - frame.dispose(); - }}); - } - - static GLProfile getGLP() { - return GLProfile.getMaxProgrammableCore(true); - } - - public static void main(String args[]) { - for(int i=0; i + * Checkbox toggles GLCanvas visibility state. + *

      + *

      + * Validates bugs: + *

        + *
      • Bug 816: OSX CALayer Positioning Bug
      • + *
      • Bug 729: OSX CALayer shall honor the Component's visibility state
      • + *
      + *

      + *

      + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos03aB729AWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final Frame frame = new Frame("TestBug816OSXCALayerPos03aAWT"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Create a check box that hides / shows canvas + final Checkbox checkbox = new Checkbox("Visible canvas", true); + checkbox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent ev) { + glCanvas1.setVisible(checkbox.getState()); + System.out.println("Canvas visible: "+glCanvas1.isVisible()); + if( glCanvas1.isVisible() ) { + frame.validate(); // take care of resized frame while hidden + } + } + }); + + // Build a GUI that displays canvas and check box + frame.setLayout(new BorderLayout()); + frame.add(glCanvas1, BorderLayout.CENTER); + frame.add(checkbox, BorderLayout.NORTH); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(glCanvas1); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i - * Checkbox toggles GLCanvas's parent panel's visibility state. - *

      - *

      - * Validates bugs: - *

        - *
      • Bug 816: OSX CALayer Positioning Bug
      • - *
      • Bug 729: OSX CALayer shall honor the Component's visibility state
      • - *
      • Bug 849: AWT GLAutoDrawables (JAWTWindow) shall honor it's parent visibility state
      • - *
      - *

      - *

      - * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 - *

      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBug816OSXCALayerPos03bAWT extends UITestCase { - static long duration = 1600; // ms - static int width=640, height=480; - - @Test - public void test() throws InterruptedException, InvocationTargetException { - final GLCapabilities caps = new GLCapabilities(getGLP()); - - final Frame frame = new Frame("TestBug816OSXCALayerPos03bAWT"); - Assert.assertNotNull(frame); - - final GLCanvas glCanvas1 = new GLCanvas(caps); - Assert.assertNotNull(glCanvas1); - glCanvas1.addGLEventListener(new GearsES2(1)); - // Put it in a panel - final Panel panel = new Panel(new GridLayout(1, 1)); - panel.add(glCanvas1); - - final Animator animator = new Animator(); - animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - - // Create a check box that hides / shows canvas - final Checkbox checkbox = new Checkbox("Visible canvas", true); - checkbox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent ev) { - panel.setVisible(checkbox.getState()); - System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); - if( panel.isVisible() ) { - frame.validate(); // take care of resized frame while hidden - } - } - }); - - // Build a GUI that displays canvas and check box - frame.setLayout(new BorderLayout()); - frame.add(panel, BorderLayout.CENTER); - frame.add(checkbox, BorderLayout.NORTH); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setSize(width, height); - frame.setVisible(true); - }}); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); - - animator.start(); - Assert.assertTrue(animator.isStarted()); - Assert.assertTrue(animator.isAnimating()); - animator.setUpdateFPSFrames(60, System.err); - - final long t0 = System.currentTimeMillis(); - long t1 = t0; - while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - Assert.assertNotNull(frame); - Assert.assertNotNull(glCanvas1); - - Assert.assertNotNull(animator); - animator.stop(); - Assert.assertFalse(animator.isAnimating()); - Assert.assertFalse(animator.isStarted()); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - }}); - Assert.assertEquals(false, frame.isVisible()); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.remove(panel); - frame.dispose(); - }}); - } - - static GLProfile getGLP() { - return GLProfile.getMaxProgrammableCore(true); - } - - public static void main(String args[]) { - for(int i=0; i + * Checkbox toggles GLCanvas's parent panel's visibility state. + *

      + *

      + * Validates bugs: + *

        + *
      • Bug 816: OSX CALayer Positioning Bug
      • + *
      • Bug 729: OSX CALayer shall honor the Component's visibility state
      • + *
      • Bug 849: AWT GLAutoDrawables (JAWTWindow) shall honor it's parent visibility state
      • + *
      + *

      + *

      + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos03bB849AWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final Frame frame = new Frame("TestBug816OSXCALayerPos03bAWT"); + Assert.assertNotNull(frame); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + // Put it in a panel + final Panel panel = new Panel(new GridLayout(1, 1)); + panel.add(glCanvas1); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Create a check box that hides / shows canvas + final Checkbox checkbox = new Checkbox("Visible canvas", true); + checkbox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent ev) { + panel.setVisible(checkbox.getState()); + System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); + if( panel.isVisible() ) { + frame.validate(); // take care of resized frame while hidden + } + } + }); + + // Build a GUI that displays canvas and check box + frame.setLayout(new BorderLayout()); + frame.add(panel, BorderLayout.CENTER); + frame.add(checkbox, BorderLayout.NORTH); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.remove(panel); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i - * Checkbox toggles GLCanvas's parent jpanel's visibility state. - *

      - *

      - * Validates bugs: - *

        - *
      • Bug 816: OSX CALayer Positioning Bug
      • - *
      • Bug 729: OSX CALayer shall honor the Component's visibility state
      • - *
      • Bug 849: AWT GLAutoDrawables (JAWTWindow) shall honor it's parent visibility state
      • - *
      - *

      - *

      - * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 - *

      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBug816OSXCALayerPos03cAWT extends UITestCase { - static long duration = 1600; // ms - static int width=640, height=480; - - @Test - public void test() throws InterruptedException, InvocationTargetException { - final GLCapabilities caps = new GLCapabilities(getGLP()); - - final JFrame frame = new JFrame("TestBug816OSXCALayerPos03cAWT"); - Assert.assertNotNull(frame); - final Container framePane = frame.getContentPane(); - - final GLCanvas glCanvas1 = new GLCanvas(caps); - Assert.assertNotNull(glCanvas1); - glCanvas1.addGLEventListener(new GearsES2(1)); - // Put it in a panel - final JPanel panel = new JPanel(new GridLayout(1, 1)); - panel.add(glCanvas1); - - final Animator animator = new Animator(); - animator.add(glCanvas1); - QuitAdapter quitAdapter = new QuitAdapter(); - - new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); - - // Create a check box that hides / shows canvas - final JCheckBox checkbox = new JCheckBox("Visible canvas", true); - checkbox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent ev) { - panel.setVisible(checkbox.getSelectedObjects()!=null); - System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); - if( panel.isVisible() ) { - frame.validate(); // take care of resized frame while hidden - } - } - }); - - // Build a GUI that displays canvas and check box - framePane.setLayout(new BorderLayout()); - framePane.add(panel, BorderLayout.CENTER); - framePane.add(checkbox, BorderLayout.NORTH); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setSize(width, height); - frame.setVisible(true); - }}); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); - - animator.start(); - Assert.assertTrue(animator.isStarted()); - Assert.assertTrue(animator.isAnimating()); - animator.setUpdateFPSFrames(60, System.err); - - final long t0 = System.currentTimeMillis(); - long t1 = t0; - while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { - Thread.sleep(100); - t1 = System.currentTimeMillis(); - } - - Assert.assertNotNull(frame); - Assert.assertNotNull(glCanvas1); - - Assert.assertNotNull(animator); - animator.stop(); - Assert.assertFalse(animator.isAnimating()); - Assert.assertFalse(animator.isStarted()); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - }}); - Assert.assertEquals(false, frame.isVisible()); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - framePane.remove(panel); - frame.dispose(); - }}); - } - - static GLProfile getGLP() { - return GLProfile.getMaxProgrammableCore(true); - } - - public static void main(String args[]) { - for(int i=0; i + * Checkbox toggles GLCanvas's parent jpanel's visibility state. + *

      + *

      + * Validates bugs: + *

        + *
      • Bug 816: OSX CALayer Positioning Bug
      • + *
      • Bug 729: OSX CALayer shall honor the Component's visibility state
      • + *
      • Bug 849: AWT GLAutoDrawables (JAWTWindow) shall honor it's parent visibility state
      • + *
      + *

      + *

      + * Diff. OSX CALayer positioning w/ java6, [7uxx..7u40[, and >= 7u40 + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816OSXCALayerPos03cB849AWT extends UITestCase { + static long duration = 1600; // ms + static int width=640, height=480; + + @Test + public void test() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(getGLP()); + + final JFrame frame = new JFrame("TestBug816OSXCALayerPos03cAWT"); + Assert.assertNotNull(frame); + final Container framePane = frame.getContentPane(); + + final GLCanvas glCanvas1 = new GLCanvas(caps); + Assert.assertNotNull(glCanvas1); + glCanvas1.addGLEventListener(new GearsES2(1)); + // Put it in a panel + final JPanel panel = new JPanel(new GridLayout(1, 1)); + panel.add(glCanvas1); + + final Animator animator = new Animator(); + animator.add(glCanvas1); + QuitAdapter quitAdapter = new QuitAdapter(); + + new AWTWindowAdapter(new TraceWindowAdapter(quitAdapter)).addTo(frame); + + // Create a check box that hides / shows canvas + final JCheckBox checkbox = new JCheckBox("Visible canvas", true); + checkbox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent ev) { + panel.setVisible(checkbox.getSelectedObjects()!=null); + System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); + if( panel.isVisible() ) { + frame.validate(); // take care of resized frame while hidden + } + } + }); + + // Build a GUI that displays canvas and check box + framePane.setLayout(new BorderLayout()); + framePane.add(panel, BorderLayout.CENTER); + framePane.add(checkbox, BorderLayout.NORTH); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(width, height); + frame.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas1, true)); + + animator.start(); + Assert.assertTrue(animator.isStarted()); + Assert.assertTrue(animator.isAnimating()); + animator.setUpdateFPSFrames(60, System.err); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1 - t0 < duration) { + Thread.sleep(100); + t1 = System.currentTimeMillis(); + } + + Assert.assertNotNull(frame); + Assert.assertNotNull(glCanvas1); + + Assert.assertNotNull(animator); + animator.stop(); + Assert.assertFalse(animator.isAnimating()); + Assert.assertFalse(animator.isStarted()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + }}); + Assert.assertEquals(false, frame.isVisible()); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + framePane.remove(panel); + frame.dispose(); + }}); + } + + static GLProfile getGLP() { + return GLProfile.getMaxProgrammableCore(true); + } + + public static void main(String args[]) { + for(int i=0; i Date: Thu, 31 Oct 2013 10:46:47 +0100 Subject: Bug 754 - Remove Ubuntu fonts from jogl-all.jar, provide it separately to reduce footprint for the masses. Remove the ubuntu fonts from atomic/jogl-util-graph.jar and hence all derivated 'all' JAR files. The Android jar files still contain the fonts as assets! atomic/jogl-util-graph-fonts-p0.jar contains the fonts and is either referenced by: - UbuntuFontLoader: Using class based Jar URI derivation using TempJarCache to [down]load and extract the jar file (similar to native lib-loading). - Explicitly via traditional classpath, see jnlp-files/jogl-applet-runner-newt-GraphTextDemo01b-napplet.html The pack200 jogl-all.jar file is now below 1MB --- ...pplet-runner-newt-GraphTextDemo01b-napplet.html | 68 +++++++++++++++++ jnlp-files/jogl-test-applets.html | 6 +- make/build-common.xml | 1 + make/build-jogl.xml | 7 +- make/scripts/tests.sh | 5 +- .../jogamp/graph/font/UbuntuFontLoader.java | 89 +++++++++++++++++++--- 6 files changed, 160 insertions(+), 16 deletions(-) create mode 100644 jnlp-files/jogl-applet-runner-newt-GraphTextDemo01b-napplet.html (limited to 'make/scripts') diff --git a/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01b-napplet.html b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01b-napplet.html new file mode 100644 index 000000000..c4c949487 --- /dev/null +++ b/jnlp-files/jogl-applet-runner-newt-GraphTextDemo01b-napplet.html @@ -0,0 +1,68 @@ + + + +JOGL Graph Text Demo 01b (NApplet) + + + +

      +JOGL Graph Text Demo 01b (w/ atomic/jogl-fonts-p0.jar in path) +

      + +

      + + + + + + + + + + + + + + + Sorry, no Java support detected. + + + +

      + +

      +Graph Text Demo Keys:
      +

        +
      • 1/2 - zoom in/out red-text
      • +
      • 6/7 - edit texture size if using VBAA (nope)
      • +
      • 0/9 - rotate the red-text
      • +
      • v - toggle vsync
      • +
      • i - live text input (CR ends it, backspace supported)
      • +
      • f - toggle fps
      • +
      • h - change text
      • +
      • space - change font
      • +
      +

      + + + diff --git a/jnlp-files/jogl-test-applets.html b/jnlp-files/jogl-test-applets.html index 76cd6effe..3ac2d5952 100644 --- a/jnlp-files/jogl-test-applets.html +++ b/jnlp-files/jogl-test-applets.html @@ -127,10 +127,12 @@ See Legend below table Dual
      - NApplet
      + NApplet + (cp-fonts)
      - GPU accelerated Text Demo using JOGL's new Graph package. + GPU accelerated Text Demo using JOGL's new Graph package.
      + cp-fonts fonts via classpath, otherwise via URI. diff --git a/make/build-common.xml b/make/build-common.xml index e790ab42b..658359302 100644 --- a/make/build-common.xml +++ b/make/build-common.xml @@ -280,6 +280,7 @@ + diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 8c30bb038..28b738b10 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1837,7 +1837,12 @@ + includes="${java.part.util.graph}" + excludes="${java.part.util.graph.fonts}"/> + + + () { + @Override + public Object run() { + try { + TempJarCache.addResources(UbuntuFontLoader.class, uri); + } catch (Exception e) { privErr[0] = e; } + return null; + } } ); + if( null == privErr[0] ) { + useTempJarCache = true; + final Font f1 = abspathImpl(fname, family, style); + if(null != f1) { + return f1; + } + } + } + } + } catch(Exception e) { + throw new IOException(err, e); + } + if( null != privErr[0] ) { + throw new IOException(err, privErr[0]); + } + throw new IOException(err); + } + private Font abspathImpl(final String fname, final int family, final int style) throws IOException { + final URLConnection conn; + if( useTempJarCache ) { + // this code-path throws .. all exceptions + final Exception[] privErr = { null }; + final URLConnection[] privConn = { null }; + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Object run() { + try { + final URI uri = TempJarCache.getResource(absFontPath+fname); + privConn[0] = null != uri ? uri.toURL().openConnection() : null; + } catch (Exception e) { privErr[0] = e; } + return null; + } } ); + if( null != privErr[0] ) { + throw new IOException(privErr[0]); } + conn = privConn[0]; + } else { + // no exceptions .. + conn = IOUtil.getResource(UbuntuFontLoader.class, relFontPath+fname); + } + if(null != conn) { final Font f= FontFactory.get ( conn ) ; if(null != f) { fontMap.put( ( family << 8 ) | style, f ); return f; } - throw new IOException(err); - } catch(IOException ioe) { - throw new IOException(err, ioe); } + return null; } } -- cgit v1.2.3 From 93ec063abaf2d1ff7a4947a4f9732635e0a99316 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 31 Oct 2013 11:26:53 +0100 Subject: TestBinary16NOUI: Remove hardship from test node - Disable 'verbose' avoids 'out of memory' and saves most of the time; Also run test exclusively. --- make/scripts/tests.sh | 5 +- .../test/junit/jogl/math/TestBinary16NOUI.java | 128 +++++++++++++-------- 2 files changed, 82 insertions(+), 51 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 00d34e5a9..a458d0a64 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -210,7 +210,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.ToolkitLock" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" - D_ARGS="-Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.debug.IOUtil" + #D_ARGS="-Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.debug.IOUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.debug.IOUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.gluegen.UseTempJarCache=false" @@ -357,6 +357,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectDoubleNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* +testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary16NOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* @@ -625,7 +626,7 @@ function testawtswt() { # # Graph # -testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* +#testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT10 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT00 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestRegionRendererNEWT01 $* #testnoawt com.jogamp.opengl.test.junit.graph.TestTextRendererNEWT01 $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary16NOUI.java b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary16NOUI.java index b6abcf6ee..8f56c133e 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary16NOUI.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/math/TestBinary16NOUI.java @@ -29,12 +29,20 @@ package com.jogamp.opengl.test.junit.jogl.math; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import com.jogamp.opengl.math.Binary16; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; -public final class TestBinary16NOUI +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public final class TestBinary16NOUI extends UITestCase /* due to hardship on machine, we want to run this test exclusively! */ { + static int stepping = 1; + static boolean verbose = false; + /** * Exponents in the range [-15, 16] are encoded and decoded correctly. */ @@ -45,9 +53,9 @@ public final class TestBinary16NOUI for (int e = -15; e <= 16; ++e) { final char p = Binary16.packSetExponentUnbiasedUnchecked(e); final int u = Binary16.unpackGetExponentUnbiased(p); - System.out.println("e: " + e); - System.out.println("p: " + Integer.toHexString(p)); - System.out.println("u: " + u); + if( verbose ) { + System.out.println("e: " + e +", p: "+Integer.toHexString(p)+", u: "+u); + } Assert.assertEquals(e, u); } } @@ -62,7 +70,7 @@ public final class TestBinary16NOUI Assert.assertTrue(Binary16.isInfinite(Binary16.NEGATIVE_INFINITY)); Assert.assertFalse(Binary16.isInfinite(Binary16.exampleNaN())); - for (int i = 0; i <= 65535; ++i) { + for (int i = 0; i <= 65535; i+=stepping) { Assert.assertFalse(Binary16.isInfinite(Binary16.packDouble(i))); } } @@ -226,16 +234,18 @@ public final class TestBinary16NOUI void testPackDoubleUnpackFloat() { - for (int i = 0; i <= 65536; ++i) { + for (int i = 0; i <= 65536; i+=stepping) { final double in = i; final char packed = Binary16.packDouble(in); final float r = Binary16.unpackFloat(packed); - System.out.println(String.format( - "packed: 0x%04x 0b%s in: %f unpacked: %f", - (int) packed, - Binary16.toRawBinaryString(packed), - in, - r)); + if( verbose ) { + System.out.println(String.format( + "packed: 0x%04x 0b%s in: %f unpacked: %f", + (int) packed, + Binary16.toRawBinaryString(packed), + in, + r)); + } if (i <= 2048) { Assert.assertEquals(in, r, 0.0); @@ -269,21 +279,23 @@ public final class TestBinary16NOUI void testPackFloatDoubleEquivalent() { - for (int i = 0; i <= 65536; ++i) { + for (int i = 0; i <= 65536; i+=stepping) { final float f_in = i; final double d_in = i; final char pf = Binary16.packFloat(f_in); final char pd = Binary16.packDouble(d_in); - System.out.println("i: " + i); - System.out.println(String.format( - "pack_f: 0x%04x 0b%s", - (int) pf, - Binary16.toRawBinaryString(pf))); - System.out.println(String.format( - "pack_d: 0x%04x 0b%s", - (int) pd, - Binary16.toRawBinaryString(pd))); + if( verbose ) { + System.out.println("i: " + i); + System.out.println(String.format( + "pack_f: 0x%04x 0b%s", + (int) pf, + Binary16.toRawBinaryString(pf))); + System.out.println(String.format( + "pack_d: 0x%04x 0b%s", + (int) pd, + Binary16.toRawBinaryString(pd))); + } Assert.assertEquals(pf, pd); } @@ -354,16 +366,18 @@ public final class TestBinary16NOUI void testPackFloatUnpackDouble() { - for (int i = 0; i <= 65536; ++i) { + for (int i = 0; i <= 65536; i+=stepping) { final float in = i; final char packed = Binary16.packFloat(in); final double r = Binary16.unpackDouble(packed); - System.out.println(String.format( - "packed: 0x%04x 0b%s in: %f unpacked: %f", - (int) packed, - Binary16.toRawBinaryString(packed), - in, - r)); + if( verbose ) { + System.out.println(String.format( + "packed: 0x%04x 0b%s in: %f unpacked: %f", + (int) packed, + Binary16.toRawBinaryString(packed), + in, + r)); + } if (i <= 2048) { Assert.assertEquals(in, r, 0.0); @@ -397,16 +411,18 @@ public final class TestBinary16NOUI void testPackUnpackDouble() { - for (int i = 0; i <= 65536; ++i) { + for (int i = 0; i <= 65536; i+=stepping) { final double in = i; final char packed = Binary16.packDouble(in); final double r = Binary16.unpackDouble(packed); - System.out.println(String.format( - "packed: 0x%04x 0b%s in: %f unpacked: %f", - (int) packed, - Binary16.toRawBinaryString(packed), - in, - r)); + if( verbose ) { + System.out.println(String.format( + "packed: 0x%04x 0b%s in: %f unpacked: %f", + (int) packed, + Binary16.toRawBinaryString(packed), + in, + r)); + } if (i <= 2048) { Assert.assertEquals(in, r, 0.0); @@ -440,16 +456,18 @@ public final class TestBinary16NOUI void testPackUnpackFloat() { - for (int i = 0; i <= 65536; ++i) { + for (int i = 0; i <= 65536; i+=stepping) { final float in = i; final char packed = Binary16.packFloat(in); final float r = Binary16.unpackFloat(packed); - System.out.println(String.format( - "packed: 0x%04x 0b%s in: %f unpacked: %f", - (int) packed, - Binary16.toRawBinaryString(packed), - in, - r)); + if( verbose ) { + System.out.println(String.format( + "packed: 0x%04x 0b%s in: %f unpacked: %f", + (int) packed, + Binary16.toRawBinaryString(packed), + in, + r)); + } if (i <= 2048) { Assert.assertEquals(in, r, 0.0); } @@ -484,9 +502,9 @@ public final class TestBinary16NOUI for (int e = 0; e <= 1; ++e) { final char p = Binary16.packSetSignUnchecked(e); final int u = Binary16.unpackGetSign(p); - System.out.println("e: " + e); - System.out.println("p: " + Integer.toHexString(p)); - System.out.println("u: " + u); + if( verbose ) { + System.out.println("e: " + e +", p: "+Integer.toHexString(p)+", u: "+u); + } Assert.assertEquals(e, u); } } @@ -503,9 +521,9 @@ public final class TestBinary16NOUI for (int e = 0; e <= 1023; ++e) { final char p = Binary16.packSetSignificandUnchecked(e); final int u = Binary16.unpackGetSignificand(p); - System.out.println("e: " + e); - System.out.println("p: " + Integer.toHexString(p)); - System.out.println("u: " + u); + if( verbose ) { + System.out.println("e: " + e +", p: "+Integer.toHexString(p)+", u: "+u); + } Assert.assertEquals(e, u); } } @@ -682,4 +700,16 @@ public final class TestBinary16NOUI System.out.println(String.format("0x%04x -> %f", (int) one, r)); Assert.assertEquals(r, -1.0, 0.0); } + + public static void main(String args[]) { + for(int i=0; i Date: Thu, 31 Oct 2013 13:12:10 +0100 Subject: GLDrawableFactory: createDummy*(..) Pass GLCapabilitiesImmutable + GLCapabilitiesChooser instead of GLProfile, allowing using same or similar caps - important for sharing ctx --- make/scripts/tests.sh | 4 ++-- .../javax/media/opengl/GLDrawableFactory.java | 19 ++++++++++++------ .../javax/media/opengl/GLSharedContextSetter.java | 23 ++++++++++++++++++++-- .../jogamp/opengl/GLDrawableFactoryImpl.java | 9 ++++----- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 10 +++++----- .../jogl/acore/TestSharedContextVBOES1NEWT.java | 2 +- .../jogl/acore/TestSharedContextVBOES2NEWT1.java | 2 +- 7 files changed, 47 insertions(+), 22 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a458d0a64..b03f0fa68 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -327,7 +327,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # @@ -357,7 +357,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectFloatNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestGluUnprojectDoubleNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* -testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary16NOUI $* +#testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary16NOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java index 3e53a1819..2af4ba306 100644 --- a/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java +++ b/src/jogl/classes/javax/media/opengl/GLDrawableFactory.java @@ -561,7 +561,7 @@ public abstract class GLDrawableFactory { /** * Creates a {@link GLDrawable#isRealized() realized} dummy {@link GLAutoDrawable} * incl it's dummy, invisible {@link NativeSurface} - * as created with {@link #createDummyDrawable(AbstractGraphicsDevice, boolean, GLProfile)}. + * as created with {@link #createDummyDrawable(AbstractGraphicsDevice, boolean, GLCapabilitiesImmutable, GLCapabilitiesChooser)}. *

      * The dummy {@link GLAutoDrawable}'s {@link GLDrawable} is {@link GLDrawable#isRealized() realized} * without an assigned {@link GLContext}, hence not initialized completely.
      @@ -574,12 +574,15 @@ public abstract class GLDrawableFactory { * * @param deviceReq which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. * @param createNewDevice if true a new independent device instance is created from the deviceReq, otherwise deviceReq is used as-is and must be valid! - * @param glp the desired {@link GLProfile} + * @param capsRequested the desired {@link GLCapabilitiesImmutable}, incl. it's {@link GLProfile}. + * For shared context, same {@link GLCapabilitiesImmutable#getVisualID(javax.media.nativewindow.VisualIDHolder.VIDType)} + * across shared drawables will yield best compatibility. + * @param chooser the custom chooser, may be null for default * @return the created and realized dummy {@link GLAutoDrawable} instance * - * @see #createDummyDrawable(AbstractGraphicsDevice, boolean, GLProfile) + * @see #createDummyDrawable(AbstractGraphicsDevice, boolean, GLCapabilitiesImmutable, GLCapabilitiesChooser) */ - public abstract GLAutoDrawable createDummyAutoDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLProfile glp); + public abstract GLAutoDrawable createDummyAutoDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser); /** * Creates an {@link GLDrawable#isRealized() unrealized} offscreen {@link GLDrawable} @@ -629,10 +632,14 @@ public abstract class GLDrawableFactory { *

      * @param deviceReq which {@link AbstractGraphicsDevice#getConnection() connection} denotes the shared device to be used, may be null for the platform's default device. * @param createNewDevice if true a new independent device instance is created from the deviceReq, otherwise deviceReq is used as-is and must be valid! - * @param glp the desired {@link GLProfile} + * @param capsRequested the desired {@link GLCapabilitiesImmutable}, incl. it's {@link GLProfile}. + * For shared context, same {@link GLCapabilitiesImmutable#getVisualID(javax.media.nativewindow.VisualIDHolder.VIDType) visual ID} + * or {@link GLCapabilitiesImmutable caps} + * across shared drawables will yield best compatibility. + * @param chooser the custom chooser, may be null for default * @return the created unrealized dummy {@link GLDrawable} */ - public abstract GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLProfile glp); + public abstract GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser); /** * Creates a proxy {@link NativeSurface} w/ defined surface handle, diff --git a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java index 873e4cd9f..78dd693cb 100644 --- a/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java +++ b/src/jogl/classes/javax/media/opengl/GLSharedContextSetter.java @@ -39,6 +39,10 @@ package javax.media.opengl; * shared {@link GLContext} w/ this master are referred as slave {@link GLContext} * and controls the shared object's lifecycle, i.e. their construction and destruction. *

      + *

      + * Using the nearest or same {@link GLCapabilitiesImmutable#getVisualID(javax.media.nativewindow.VisualIDHolder.VIDType) visual ID} + * or {@link GLCapabilitiesImmutable caps} across the shared {@link GLDrawable}s will yield best compatibility. + *

      *
      Lifecycle Considerations
      *

      * After shared objects are created on the master, the OpenGL pipeline @@ -56,7 +60,7 @@ package javax.media.opengl; * or the slaves validate whether the resources are still valid. *

      *

      - * To simplify above lifecycle issues, one may use a {@link GLDrawableFactory#createDummyDrawable(javax.media.nativewindow.AbstractGraphicsDevice, boolean, GLProfile) dummy} + * To simplify above lifecycle issues, one may use a {@link GLDrawableFactory#createDummyDrawable(javax.media.nativewindow.AbstractGraphicsDevice, boolean, GLCapabilitiesImmutable, GLCapabilitiesChooser) dummy} * {@link GLDrawable} and it's {@link GLContext} as the master of all shared slave {@link GLContext}. * Since this dummy instance does not depend on any native windowing system, it can be controlled easily w/o being in sight.
      * Below code creates a {@link GLAutoDrawable} based on a dummy GLDrawable: @@ -66,7 +70,7 @@ package javax.media.opengl; final GLProfile glp = caps.getGLProfile(); .. final boolean createNewDevice = true; // use 'own' display device! - final GLAutoDrawable sharedDrawable = GLDrawableFactory.getFactory(glp).createDummyAutoDrawable(null, createNewDevice, glp); + final GLAutoDrawable sharedDrawable = GLDrawableFactory.getFactory(glp).createDummyAutoDrawable(null, createNewDevice, caps, null); sharedDrawable.display(); // triggers GLContext object creation and native realization. ... // Later a shared 'slave' can be created e.g.: @@ -76,6 +80,21 @@ package javax.media.opengl; glad.setVisible(true); // GLWindow creation .. * *

      + *
      Known Driver Issues
      + * Intel's Mesa >= 9.1.2 Backend for [Sandybridge/Ivybridge] on GNU/Linux + *

      + *

      + * Error: 'intel_do_flush_locked: No such file or directory'
      + * JogAmp: 
      + * freedesktop.org: 
      + * 
      + * Shared context seems not to be supported w/ lock-free bound X11 display connections + * per OpenGL drawable/context. The error message above is thrown in this case. + * Hence the driver bug renders shared context use w/ JOGL impossible. + *

      + * Hisilicon's Immersion.16 + *

      + *

      */ public interface GLSharedContextSetter extends GLAutoDrawable { /** diff --git a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java index a9f12b17e..cadf40f02 100644 --- a/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLDrawableFactoryImpl.java @@ -328,8 +328,8 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } @Override - public final GLAutoDrawable createDummyAutoDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLProfile glp) { - final GLDrawable drawable = createDummyDrawable(deviceReq, createNewDevice, glp); + public final GLAutoDrawable createDummyAutoDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { + final GLDrawable drawable = createDummyDrawable(deviceReq, createNewDevice, capsRequested, chooser); drawable.setRealized(true); final GLAutoDrawable sharedDrawable = new GLAutoDrawableDelegate(drawable, null, null, true /*ownDevice*/, null) { }; return sharedDrawable; @@ -366,15 +366,14 @@ public abstract class GLDrawableFactoryImpl extends GLDrawableFactory { } @Override - public final GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLProfile glp) { + public final GLDrawable createDummyDrawable(AbstractGraphicsDevice deviceReq, boolean createNewDevice, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser) { final AbstractGraphicsDevice device = createNewDevice ? getOrCreateSharedDevice(deviceReq) : deviceReq; if(null == device) { throw new GLException("No shared device for requested: "+deviceReq+", createNewDevice "+createNewDevice); } device.lock(); try { - final GLCapabilities caps = new GLCapabilities(glp); - final ProxySurface dummySurface = createDummySurfaceImpl(device, createNewDevice, caps, caps, null, 64, 64); + final ProxySurface dummySurface = createDummySurfaceImpl(device, createNewDevice, capsRequested, capsRequested, chooser, 64, 64); return createOnscreenDrawableImpl(dummySurface); } finally { device.unlock(); diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 7e41c3fce..1d73d1a44 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -74,7 +74,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected static final String unknown = "unknown"; protected volatile State state; - private Object stateLock = new Object(); + private final Object stateLock = new Object(); protected int textureCount; protected int textureTarget; @@ -170,7 +170,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { */ protected boolean isInGLOrientation = false; - private ArrayList eventListeners = new ArrayList(); + private final ArrayList eventListeners = new ArrayList(); protected GLMediaPlayerImpl() { this.textureCount=0; @@ -983,7 +983,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final GLProfile glp = gl.getGLProfile(); final GLDrawableFactory factory = GLDrawableFactory.getFactory(glp); final AbstractGraphicsDevice device = glCtx.getGLDrawable().getNativeSurface().getGraphicsConfiguration().getScreen().getDevice(); - dummyDrawable = factory.createDummyDrawable(device, true, glp); // own device! + dummyDrawable = factory.createDummyDrawable(device, true, glCtx.getGLDrawable().getChosenGLCapabilities(), null); // own device! dummyDrawable.setRealized(true); sharedGLCtx = dummyDrawable.createContext(glCtx); makeCurrent(sharedGLCtx); @@ -1248,7 +1248,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( this.fps != fps ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_FPS; this.fps = fps; - this.frame_duration = 1000f / (float)fps; + this.frame_duration = 1000f / fps; } if( this.bps_stream != bps_stream || this.bps_video != bps_video || this.bps_audio != bps_audio ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_BPS; @@ -1431,7 +1431,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } - private Object eventListenersLock = new Object(); + private final Object eventListenersLock = new Object(); protected static final String toHexString(long v) { return "0x"+Long.toHexString(v); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java index 59bb13c87..0f4f8fc34 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES1NEWT.java @@ -92,7 +92,7 @@ public class TestSharedContextVBOES1NEWT extends UITestCase { } private void initShared() throws InterruptedException { - GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps.getGLProfile()); + GLDrawable dummyDrawable = GLDrawableFactory.getFactory(glp).createDummyDrawable(null, true /* createNewDevice */, caps, null); dummyDrawable.setRealized(true); sharedDrawable = new GLAutoDrawableDelegate(dummyDrawable, null, null, true /*ownDevice*/, null) { }; Assert.assertNotNull(sharedDrawable); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java index 928b03703..7051bac13 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestSharedContextVBOES2NEWT1.java @@ -105,7 +105,7 @@ public class TestSharedContextVBOES2NEWT1 extends UITestCase { glWindow.setVisible(true); sharedDrawable = glWindow; } else { - sharedDrawable = GLDrawableFactory.getFactory(glp).createDummyAutoDrawable(null, true /* createNewDevice */, caps.getGLProfile()); + sharedDrawable = GLDrawableFactory.getFactory(glp).createDummyAutoDrawable(null, true /* createNewDevice */, caps, null); } Assert.assertNotNull(sharedDrawable); Assert.assertTrue(AWTRobotUtil.waitForRealized(sharedDrawable, true)); -- cgit v1.2.3 From 85878162940067b39b17c71878446dff0759040d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 1 Nov 2013 01:25:32 +0100 Subject: Bug 882 - Crash on OSX when closing NEWT window - Fix: Release NewtMacWindow manually in close0() Release NewtMacWindow manually in close0() - Mark [NewtMacWindow setReleasedWhenClosed: NO] in init0(..) - Release NewtMacWindow manually in close0(..) Check pointer args in close0(..) --- make/scripts/tests.sh | 4 +- src/newt/native/MacWindow.m | 28 +++-- .../newt/DemoCreateAndDisposeOnCloseNEWT.java | 140 +++++++++++++++++++++ 3 files changed, 164 insertions(+), 8 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/DemoCreateAndDisposeOnCloseNEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b03f0fa68..641c3a906 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -327,7 +327,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # @@ -557,6 +557,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT +testnoawt com.jogamp.opengl.test.junit.newt.DemoCreateAndDisposeOnCloseNEWT $* +#testawt com.jogamp.opengl.test.junit.newt.DemoCreateAndDisposeOnCloseNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index f8988cf15..f0ed170f0 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -716,8 +716,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_initWindow0 rectWin = NSMakeRect(x, y, w, h); } - [myWindow setReleasedWhenClosed: YES]; // default + [myWindow setReleasedWhenClosed: NO]; // We control NSWindow destruction! [myWindow setPreservesContentDuringLiveResize: NO]; +NS_DURING + if ( [myWindow respondsToSelector:@selector(setRestorable:)] ) { + // Available >= 10.7 - Removes restauration 'feature', really close + [myWindow setRestorable: NO]; + } +NS_HANDLER +NS_ENDHANDLER NSObject* nsParentObj = (NSObject*) ((intptr_t) parent); NSWindow* parentWindow = NULL; @@ -857,8 +864,19 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window); + if( NULL == mWin ) { + DBG_PRINT( "windowClose.0 - NULL NEWT win - abort\n"); + return; + } + BOOL isNSWin = [mWin isKindOfClass:[NSWindow class]]; + BOOL isNewtWin = [mWin isKindOfClass:[NewtMacWindow class]]; + NSWindow *pWin = [mWin parentWindow]; + DBG_PRINT( "windowClose.0 - %p [isNSWindow %d, isNewtWin %d], parent %p\n", mWin, isNSWin, isNewtWin, pWin); + if( !isNewtWin ) { + DBG_PRINT( "windowClose.0 - Not a NEWT win - abort\n"); + return; + } NewtView* mView = (NewtView *)[mWin contentView]; - NSWindow* pWin = [mWin parentWindow]; BOOL destroyNotifySent, isNSView, isNewtView; if( NULL != mView ) { isNSView = [mView isKindOfClass:[NSView class]]; @@ -905,11 +923,7 @@ NS_ENDHANDLER DBG_PRINT( "windowClose.1 - %p view %p, parent %p\n", mWin, mView, pWin); - // Only release window, if release is not yet in process. - // E.g. destroyNotifySent:=true set by NewtMacWindow::windowWillClose(), i.e. window-close was clicked. - if(!destroyNotifySent) { - [mWin release]; - } + [mWin release]; DBG_PRINT( "windowClose.Xp\n"); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/DemoCreateAndDisposeOnCloseNEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/DemoCreateAndDisposeOnCloseNEWT.java new file mode 100644 index 000000000..e82204fd0 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/DemoCreateAndDisposeOnCloseNEWT.java @@ -0,0 +1,140 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.newt; + +import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import com.jogamp.newt.event.WindowEvent; +import com.jogamp.newt.event.WindowAdapter; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.util.Animator; + +/** + * Manual test case validating closing behavior. + *

      + * Validates bugs: + *

        + *
      • Bug 882: Crash on OSX when closing NEWT window
      • + *
      + *

      + * + */ +public class DemoCreateAndDisposeOnCloseNEWT { + public static void main(String[] args) { + int closeMode = 0; // 0 - none, 1 - window, animator, 2 - animator, window, 3 - System.exit + + for(int i=0; i Date: Fri, 1 Nov 2013 05:24:23 +0100 Subject: Clarify Bug 692: Unbinding a VAO does _not_ imply unbinding of set VBOs (spec doesn't mention it, and it does not show results w/ CPU sourced rendering) ; Clean up GLBuffer*Tracker + * Note that VAO initialization does unbind the VBO .. since otherwise they are still bound + * and the CPU_SRC test will fail!
      + * The OpenGL spec does not mention that unbinding a VAO will also unbind the bound VBOs + * during their setup.
      + * Local tests here on NV and AMD proprietary driver resulted in no ourput image + * when not unbinding said VBOs before the CPU_SRC tests.
      + * Hence Bug 692 Comment 5 is invalid, i.e. , + * and we should throw an exception to give users a hint! Leaving uncommented code in GLBufferStateTracker .. +++ - Clean up GLBuffer*Tracker - Use final - Use static final keyNotFound value. --- make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 2 +- make/config/jogl/gl-impl-CustomJavaCode-gles3.java | 2 +- make/scripts/tests.sh | 9 +- .../classes/jogamp/opengl/GLBufferSizeTracker.java | 11 +- .../jogamp/opengl/GLBufferStateTracker.java | 30 +- .../test/junit/jogl/acore/TestBug692GL3VAO.java | 354 ---------------- .../junit/jogl/acore/TestBug692GL3VAONEWT.java | 445 +++++++++++++++++++++ 7 files changed, 482 insertions(+), 371 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAONEWT.java (limited to 'make/scripts') diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index 30047278b..e7389de10 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -314,7 +314,7 @@ private final boolean checkBufferObject(boolean extensionAvail, return true; } if ( allowVAO ) { - buffer = bufferStateTracker.getBoundBufferObject(GL2GL3.GL_VERTEX_ARRAY_BINDING, this); + buffer = bufferStateTracker.getBoundBufferObject(GL2ES3.GL_VERTEX_ARRAY_BINDING, this); if( 0 != buffer && _context.getDefaultVAO() != buffer ) { return true; } diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java index 83bdd7691..1a1d7abe3 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -235,7 +235,7 @@ private final boolean checkBufferObject(boolean extensionAvail, return true; } if ( allowVAO ) { - buffer = bufferStateTracker.getBoundBufferObject(GLES3.GL_VERTEX_ARRAY_BINDING, this); + buffer = bufferStateTracker.getBoundBufferObject(GL2ES3.GL_VERTEX_ARRAY_BINDING, this); if( 0 != buffer && _context.getDefaultVAO() != buffer ) { return true; } diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 641c3a906..9d6a6b2ef 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -81,13 +81,14 @@ function jrun() { swton=$1 shift + D_ARGS="-Djogl.debug.DebugGL" + #D_ARGS="-Djogl.debug.TraceGL" + #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG" #D_ARGS="-Djogl.disable.opengles" #D_ARGS="-Djogl.debug.DebugGL -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" - #D_ARGS="-Djogl.debug.TraceGL" - #D_ARGS="-Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" @@ -373,7 +374,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAO $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAONEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLExtensionQueryOffscreen $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* @@ -557,7 +558,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.caps.TestBug605FlippedImageAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glsl.TestShaderCompilationBug459AWT -testnoawt com.jogamp.opengl.test.junit.newt.DemoCreateAndDisposeOnCloseNEWT $* +#testnoawt com.jogamp.opengl.test.junit.newt.DemoCreateAndDisposeOnCloseNEWT $* #testawt com.jogamp.opengl.test.junit.newt.DemoCreateAndDisposeOnCloseNEWT $* #testawt com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT #testawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol01AWT $* diff --git a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java index 73a864304..fa05902d5 100644 --- a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java @@ -101,11 +101,12 @@ public class GLBufferSizeTracker { // objects, which is probably sub-optimal. The expected usage // pattern of buffer objects indicates that the fact that this map // never shrinks is probably not that bad. - private IntLongHashMap bufferSizeMap; + private final IntLongHashMap bufferSizeMap; + private final long keyNotFount = 0xFFFFFFFFFFFFFFFFL; public GLBufferSizeTracker() { bufferSizeMap = new IntLongHashMap(); - bufferSizeMap.setKeyNotFoundValue(0xFFFFFFFFFFFFFFFFL); + bufferSizeMap.setKeyNotFoundValue(keyNotFount); } public final void setBufferSize(GLBufferStateTracker bufferStateTracker, @@ -142,7 +143,7 @@ public class GLBufferSizeTracker { if (DEBUG) { System.err.println("GLBufferSizeTracker.getBufferSize(): no cached buffer information"); } - return (long) tmp[0]; + return tmp[0]; } public final long getDirectStateBufferSize(int buffer, GL caller) { @@ -154,7 +155,7 @@ public class GLBufferSizeTracker { // point we almost certainly should if the application is // written correctly long sz = bufferSizeMap.get(buffer); - if (0xFFFFFFFFFFFFFFFFL == sz) { + if (keyNotFount == sz) { // For robustness, try to query this value from the GL as we used to // FIXME: both functions return 'int' types, which is not suitable, // since buffer lenght is 64bit ? @@ -176,7 +177,7 @@ public class GLBufferSizeTracker { " was zero; probably application error"); } // Assume we just don't know what's happening - sz = (long) tmp[0]; + sz = tmp[0]; bufferSizeMap.put(buffer, sz); if (DEBUG) { System.err.println("GLBufferSizeTracker.getBufferSize(): made slow query to cache size " + diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java index cd9eea287..16b7edca8 100644 --- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java @@ -41,6 +41,7 @@ package jogamp.opengl; import javax.media.opengl.*; + import com.jogamp.common.util.IntIntHashMap; /** @@ -88,16 +89,17 @@ public class GLBufferStateTracker { // known that no buffer is bound to the target, according to the // OpenGL specifications. // http://www.opengl.org/sdk/docs/man/xhtml/glBindBuffer.xml - private IntIntHashMap bindingMap; + private final IntIntHashMap bindingMap; + private final int keyNotFound = 0xFFFFFFFF; - private int[] bufTmp = new int[1]; + private final int[] bufTmp = new int[1]; public GLBufferStateTracker() { bindingMap = new IntIntHashMap(); - bindingMap.setKeyNotFoundValue(0xFFFFFFFF); + bindingMap.setKeyNotFoundValue(keyNotFound); // Start with known unbound targets for known keys - // setBoundBufferObject(GL2GL3.GL_VERTEX_ARRAY_BINDING, 0); // not using default VAO (removed in GL3 core) - only explicit + // setBoundBufferObject(GL2ES3.GL_VERTEX_ARRAY_BINDING, 0); // not using default VAO (removed in GL3 core) - only explicit setBoundBufferObject(GL.GL_ARRAY_BUFFER, 0); setBoundBufferObject(GL.GL_ELEMENT_ARRAY_BUFFER, 0); setBoundBufferObject(GL2.GL_PIXEL_PACK_BUFFER, 0); @@ -107,6 +109,22 @@ public class GLBufferStateTracker { public final void setBoundBufferObject(int target, int value) { bindingMap.put(target, value); + /*** + * Test for clearing bound buffer states when unbinding VAO, + * Bug 692 Comment 5 is invalid, i.e. . + * However spec doesn't mention such behavior, and rendering w/ CPU sourced data + * after unbinding a VAO w/o unbinding the VBOs resulted to no visible image. + * Leaving code in here for discussion - in case I am wrong. + * + final int pre = bindingMap.put(target, value); + if( GL2ES3.GL_VERTEX_ARRAY_BINDING == target && keyNotFound != pre && 0 == value ) { + // Unbinding a previous bound VAO leads to unbinding of all buffers! + bindingMap.put(GL.GL_ARRAY_BUFFER, 0); + bindingMap.put(GL.GL_ELEMENT_ARRAY_BUFFER, 0); + bindingMap.put(GL2.GL_PIXEL_PACK_BUFFER, 0); + bindingMap.put(GL2.GL_PIXEL_UNPACK_BUFFER, 0); + bindingMap.put(GL4.GL_DRAW_INDIRECT_BUFFER, 0); + } */ if (DEBUG) { System.err.println("GLBufferStateTracker.setBoundBufferObject() target 0x" + Integer.toHexString(target) + " -> mapped bound buffer 0x" + @@ -121,14 +139,14 @@ public class GLBufferStateTracker { return value is valid. */ public final int getBoundBufferObject(int target, GL caller) { int value = bindingMap.get(target); - if (0xFFFFFFFF == value) { + if (keyNotFound == value) { // User probably either called glPushClientAttrib / // glPopClientAttrib or is querying an unknown target. See // whether we know how to fetch this state. boolean gotQueryTarget = true; int queryTarget = 0; switch (target) { - case GL2GL3.GL_VERTEX_ARRAY_BINDING: queryTarget = GL2GL3.GL_VERTEX_ARRAY_BINDING; break; + case GL2ES3.GL_VERTEX_ARRAY_BINDING: queryTarget = GL2ES3.GL_VERTEX_ARRAY_BINDING; break; case GL.GL_ARRAY_BUFFER: queryTarget = GL.GL_ARRAY_BUFFER_BINDING; break; case GL.GL_ELEMENT_ARRAY_BUFFER: queryTarget = GL.GL_ELEMENT_ARRAY_BUFFER_BINDING; break; case GL2.GL_PIXEL_PACK_BUFFER: queryTarget = GL2.GL_PIXEL_PACK_BUFFER_BINDING; break; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java deleted file mode 100644 index 29b48fecd..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAO.java +++ /dev/null @@ -1,354 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.jogl.acore; - -import java.io.IOException; -import java.nio.FloatBuffer; -import java.nio.ShortBuffer; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.media.opengl.DebugGL3; -import javax.media.opengl.GL3; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.FixMethodOrder; -import org.junit.runners.MethodSorters; - -import com.jogamp.common.nio.Buffers; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.QuitAdapter; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLBuffers; - -/** - * Test Vertex Array Object (VAO) Usage. - *

      - * testGL3() tests VAO alone, i.e. w/o VBO enable/disabling. - *

      - *

      - * testGL3bc() tests VAO and VBO while alternating between both methods. - *

      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBug692GL3VAO extends UITestCase { - static long duration = 500; // ms - - static class GL3VAODemo implements GLEventListener { - /** Different modes of displaying the geometry */ - public enum Mode { - /** Traditional one without using VAO */ - NON_VAO { - @Override - void display(GL3VAODemo t, GL3 gl) { - t.displayNonVAO(gl); - } - }, - - /** Using VAOs throws [incorrectly as of JOGL 2.0rc11] a GLException */ - VAO_NORMAL { - @Override - void display(GL3VAODemo t, GL3 gl) { - t.displayVAONormal(gl); - } - }; - - abstract void display(GL3VAODemo t, GL3 gl); - } - - private final Mode[] allModes; - private Mode currentMode; - private int currentModeIdx; - - public GL3VAODemo(Mode[] modes) { - allModes = modes; - currentMode = allModes[0]; - currentModeIdx = 0; - } - - private final static float[] vertexData = new float[]{ - 0.0f, 0.75f, 0.0f, 1,0,0, - -0.5f, -0.75f, 0.0f, 0,1,0, - 0.9f, -0.75f, 0.0f, 0,0,1 - }; - - private int ibo = -1; - private int vbo = -1; - private int vertID = -1; - private int fragID = -1; - private int progID = -1; - - private int vaoNormal = -1; - - private static int createShader(final GL3 gl, int type, - final String[] srcLines){ - int shaderID = gl.glCreateShader(type); - assert shaderID > 0; - int[] lengths = new int[srcLines.length]; - for (int i = 0; i < srcLines.length; i++) { - lengths[i] = srcLines[i].length(); - } - gl.glShaderSource(shaderID, srcLines.length, srcLines, lengths, 0); - gl.glCompileShader(shaderID); - return shaderID; - } - - private void initBuffers(GL3 gl) { - // IDs for 2 buffers - int[] buffArray = new int[2]; - gl.glGenBuffers(buffArray.length, buffArray, 0); - vbo = buffArray[0]; - assert vbo > 0; - - // Bind buffer and upload data - gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo); - FloatBuffer buffer = GLBuffers.newDirectFloatBuffer(vertexData); - assert buffer.remaining() == vertexData.length; - gl.glBufferData(GL3.GL_ARRAY_BUFFER, vertexData.length * Buffers.SIZEOF_FLOAT, - buffer, GL3.GL_STATIC_DRAW); - gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0); - - // Buffer with the 3 indices required for one triangle - ibo = buffArray[1]; - assert ibo > 0; - final short[] indices = new short[]{0, 1, 2}; - ShortBuffer shortBuffer = GLBuffers.newDirectShortBuffer(indices); - assert shortBuffer.remaining() == indices.length; - gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibo); - gl.glBufferData(GL3.GL_ELEMENT_ARRAY_BUFFER,indices.length*Buffers.SIZEOF_SHORT, - shortBuffer, GL3.GL_STATIC_DRAW); - gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, 0); - } - private void initShaders(GL3 gl) { - final String[] vertSrc = new String[]{ - "#version 150\n", - "in vec4 vPosition;\n", - "in vec4 vColor;\n", - "out vec4 pColor;\n", - "void main() {\n", - " pColor = vColor;\n", - " gl_Position = vPosition;\n", - "}\n" - }; - vertID = createShader(gl, GL3.GL_VERTEX_SHADER, vertSrc); - - final String[] fragSrc = new String[]{ - "#version 150\n", - "in vec4 pColor;\n", - "void main() {\n", - " gl_FragColor = pColor;\n", - "}\n" - }; - fragID = createShader(gl, GL3.GL_FRAGMENT_SHADER, fragSrc); - - // We're done with the compiler - gl.glReleaseShaderCompiler(); - - progID = gl.glCreateProgram(); - assert progID > 0; - gl.glAttachShader(progID, vertID); - gl.glAttachShader(progID, fragID); - gl.glLinkProgram(progID); - gl.glValidateProgram(progID); - } - - private int initVAO(GL3 gl) { - int[] buff = new int[1]; - gl.glGenVertexArrays(1, buff, 0); - int vao = buff[0]; - Assert.assertTrue("Invalid VAO: "+vao, vao > 0); - - - gl.glUseProgram(progID); - final int posLoc = gl.glGetAttribLocation(progID, "vPosition"); - final int colorLoc = gl.glGetAttribLocation(progID, "vColor"); - gl.glUseProgram(0); - - gl.glBindVertexArray(vao); - gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo); - gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibo); - - gl.glEnableVertexAttribArray(posLoc); - gl.glEnableVertexAttribArray(colorLoc); - - final int stride = 6 * Buffers.SIZEOF_FLOAT; - final int cOff = 3 * Buffers.SIZEOF_FLOAT; - gl.glVertexAttribPointer(posLoc, 3, GL3.GL_FLOAT, false, stride, 0L); - gl.glVertexAttribPointer(colorLoc,3, GL3.GL_FLOAT, false, stride, cOff); - - gl.glBindVertexArray(0); - return vao; - } - - @Override - public void init(GLAutoDrawable drawable) { - drawable.setGL(new DebugGL3(drawable.getGL().getGL3())); - - final GL3 gl = drawable.getGL().getGL3(); - gl.glEnable(GL3.GL_DEPTH_TEST); - gl.glDisable(GL3.GL_CULL_FACE); - initBuffers(gl); - initShaders(gl); - - vaoNormal = initVAO(gl); - - gl.setSwapInterval(1); - } - - @Override - public void dispose(GLAutoDrawable drawable) { - final GL3 gl = drawable.getGL().getGL3(); - gl.glDeleteBuffers(2, new int[]{vbo, ibo}, 0); - gl.glDetachShader(progID, fragID); - gl.glDetachShader(progID, vertID); - gl.glDeleteProgram(progID); - gl.glDeleteShader(fragID); - gl.glDeleteShader(vertID); - } - - private void displayNonVAO(final GL3 gl) { - final int posLoc = gl.glGetAttribLocation(progID, "vPosition"); - final int colorLoc = gl.glGetAttribLocation(progID, "vColor"); - gl.glEnableVertexAttribArray(posLoc); - gl.glEnableVertexAttribArray(colorLoc); - - gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo); - final int stride = 6 * Buffers.SIZEOF_FLOAT; - final int cOff = 3 * Buffers.SIZEOF_FLOAT; - gl.glVertexAttribPointer(posLoc, 3, GL3.GL_FLOAT, false, stride, 0L); - gl.glVertexAttribPointer(colorLoc,3, GL3.GL_FLOAT, false, stride, cOff); - gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibo); - gl.glDrawElements(GL3.GL_TRIANGLES, 3, GL3.GL_UNSIGNED_SHORT, 0L); - - gl.glDisableVertexAttribArray(posLoc); - gl.glDisableVertexAttribArray(colorLoc); - gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0); - gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, 0); - } - - private void displayVAONormal(final GL3 gl) { - try { - gl.glBindVertexArray(vaoNormal); - gl.glDrawElements(GL3.GL_TRIANGLES, 3, GL3.GL_UNSIGNED_SHORT, 0L); - gl.glBindVertexArray(0); - } catch (GLException ex) { - Logger.getLogger(TestBug692GL3VAO.class.getName()).log(Level.SEVERE,null,ex); - } - } - - @Override - public void display(GLAutoDrawable drawable) { - final GL3 gl = drawable.getGL().getGL3(); - float color = ((float) currentMode.ordinal() + 1) / (Mode.values().length + 2); - gl.glClearColor(color, color, color, 0); - gl.glClear(GL3.GL_COLOR_BUFFER_BIT | GL3.GL_DEPTH_BUFFER_BIT); - gl.glUseProgram(progID); - final Mode newMode; - { - currentModeIdx = ( currentModeIdx + 1 ) % allModes.length; - newMode = allModes[ currentModeIdx ]; - } - if (newMode != currentMode) { - currentMode = newMode; - System.out.println("Display mode: " + currentMode); - } - currentMode.display(this, gl); - gl.glUseProgram(0); - } - - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { - } - } - - private void testImpl(GLProfile profile, GL3VAODemo.Mode[] modes) throws InterruptedException { - final GLCapabilities capabilities = new GLCapabilities(profile); - final GLWindow glWindow = GLWindow.create(capabilities); - glWindow.setSize(512, 512); - - Animator anim = new Animator(glWindow); - - QuitAdapter quitAdapter = new QuitAdapter(); - glWindow.addKeyListener(quitAdapter); - glWindow.addWindowListener(quitAdapter); - - final GL3VAODemo vaoTest = new GL3VAODemo(modes); - glWindow.addGLEventListener(vaoTest); - glWindow.setVisible(true); - anim.start(); - - final long t0 = System.currentTimeMillis(); - long t1 = t0; - while(!quitAdapter.shouldQuit() && t1-t0 + * All combinations of CPU_SRC, VBO_ONLY and VBO_VAO are tested + * and validate the fix for Bug 692, i.e. . + *

      + *

      + * Test order is important! + *

      + *

      + * Note that VAO initialization does unbind the VBO .. since otherwise they are still bound + * and the CPU_SRC test will fail!
      + * The OpenGL spec does not mention that unbinding a VAO will also unbind the bound VBOs + * during their setup.
      + * Local tests here on NV and AMD proprietary driver resulted in no ourput image + * when not unbinding said VBOs before the CPU_SRC tests.
      + * Hence Bug 692 Comment 5 is invalid, i.e. , + * and we should throw an exception to give users a hint! + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug692GL3VAONEWT extends UITestCase { + static long duration = 500; // ms + + static class GL3VAODemo implements GLEventListener { + /** Different modes of displaying the geometry */ + public enum Mode { + CPU_SRC { + @Override + void display(GL3VAODemo t, GL3bc gl) { + t.displayCPUSourcing(gl); + } + }, + + /** Traditional one without using VAO */ + VBO_ONLY { + @Override + void display(GL3VAODemo t, GL3bc gl) { + t.displayVBOOnly(gl); + } + }, + + /** Using VAOs throws [incorrectly as of JOGL 2.0rc11] a GLException */ + VBO_VAO { + @Override + void display(GL3VAODemo t, GL3bc gl) { + t.displayVBOVAO(gl); + } + }; + + abstract void display(GL3VAODemo t, GL3bc gl); + } + + private final Mode[] allModes; + private Mode currentMode; + private int currentModeIdx; + + public GL3VAODemo(Mode[] modes) { + allModes = modes; + currentMode = allModes[0]; + currentModeIdx = 0; + } + + private final static float[] vertexColorData = new float[]{ + 0.0f, 0.75f, 0.0f, 1,0,0, + -0.5f, -0.75f, 0.0f, 0,1,0, + 0.9f, -0.75f, 0.0f, 0,0,1 + }; + private final FloatBuffer vertexColorDataBuffer = GLBuffers.newDirectFloatBuffer(vertexColorData); + + private final short[] indices = new short[]{0, 1, 2}; + private final ShortBuffer indicesBuffer = GLBuffers.newDirectShortBuffer(indices); + + + private int ibo = -1; + private int vbo = -1; + private int vertID = -1; + private int fragID = -1; + private int progID = -1; + + private int vao = -1; + + private static int createShader(final GL3 gl, int type, + final String[] srcLines){ + int shaderID = gl.glCreateShader(type); + assert shaderID > 0; + int[] lengths = new int[srcLines.length]; + for (int i = 0; i < srcLines.length; i++) { + lengths[i] = srcLines[i].length(); + } + gl.glShaderSource(shaderID, srcLines.length, srcLines, lengths, 0); + gl.glCompileShader(shaderID); + return shaderID; + } + + private void initBuffers(GL3 gl) { + // IDs for 2 buffers + int[] buffArray = new int[2]; + gl.glGenBuffers(buffArray.length, buffArray, 0); + vbo = buffArray[0]; + assert vbo > 0; + + // Bind buffer and upload data + gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo); + gl.glBufferData(GL3.GL_ARRAY_BUFFER, vertexColorData.length * Buffers.SIZEOF_FLOAT, + vertexColorDataBuffer, GL3.GL_STATIC_DRAW); + gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0); + + // Buffer with the 3 indices required for one triangle + ibo = buffArray[1]; + assert ibo > 0; + gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibo); + gl.glBufferData(GL3.GL_ELEMENT_ARRAY_BUFFER,indices.length*Buffers.SIZEOF_SHORT, + indicesBuffer, GL3.GL_STATIC_DRAW); + gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, 0); + } + private void initShaders(GL3 gl) { + final String[] vertSrc = new String[]{ + "#version 150\n", + "in vec4 vPosition;\n", + "in vec4 vColor;\n", + "out vec4 pColor;\n", + "void main() {\n", + " pColor = vColor;\n", + " gl_Position = vPosition;\n", + "}\n" + }; + vertID = createShader(gl, GL3.GL_VERTEX_SHADER, vertSrc); + + final String[] fragSrc = new String[]{ + "#version 150\n", + "in vec4 pColor;\n", + "void main() {\n", + " gl_FragColor = pColor;\n", + "}\n" + }; + fragID = createShader(gl, GL3.GL_FRAGMENT_SHADER, fragSrc); + + // We're done with the compiler + gl.glReleaseShaderCompiler(); + + progID = gl.glCreateProgram(); + assert progID > 0; + gl.glAttachShader(progID, vertID); + gl.glAttachShader(progID, fragID); + gl.glLinkProgram(progID); + gl.glValidateProgram(progID); + } + + private int initVAO(GL3 gl) { + int[] buff = new int[1]; + gl.glGenVertexArrays(1, buff, 0); + int vao = buff[0]; + Assert.assertTrue("Invalid VAO: "+vao, vao > 0); + + + gl.glUseProgram(progID); + final int posLoc = gl.glGetAttribLocation(progID, "vPosition"); + final int colorLoc = gl.glGetAttribLocation(progID, "vColor"); + gl.glUseProgram(0); + + gl.glBindVertexArray(vao); + gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo); + gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibo); + + gl.glEnableVertexAttribArray(posLoc); + gl.glEnableVertexAttribArray(colorLoc); + + final int stride = 6 * Buffers.SIZEOF_FLOAT; + final int cOff = 3 * Buffers.SIZEOF_FLOAT; + gl.glVertexAttribPointer(posLoc, 3, GL3.GL_FLOAT, false, stride, 0L); + gl.glVertexAttribPointer(colorLoc,3, GL3.GL_FLOAT, false, stride, cOff); + + gl.glBindVertexArray(0); + // See class documentation above! + gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0); + gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, 0); + return vao; + } + + @Override + public void init(GLAutoDrawable drawable) { + drawable.setGL(new DebugGL3(drawable.getGL().getGL3())); + + final GL3 gl = drawable.getGL().getGL3(); + gl.glEnable(GL3.GL_DEPTH_TEST); + gl.glDisable(GL3.GL_CULL_FACE); + initBuffers(gl); + initShaders(gl); + + vao = initVAO(gl); + + gl.setSwapInterval(1); + } + + @Override + public void dispose(GLAutoDrawable drawable) { + final GL3 gl = drawable.getGL().getGL3(); + gl.glDeleteBuffers(2, new int[]{vbo, ibo}, 0); + gl.glDetachShader(progID, fragID); + gl.glDetachShader(progID, vertID); + gl.glDeleteProgram(progID); + gl.glDeleteShader(fragID); + gl.glDeleteShader(vertID); + } + + private void displayCPUSourcing(final GL3bc gl) { + final int posLoc = gl.glGetAttribLocation(progID, "vPosition"); + final int colorLoc = gl.glGetAttribLocation(progID, "vColor"); + gl.glEnableVertexAttribArray(posLoc); + gl.glEnableVertexAttribArray(colorLoc); + + final int stride = 6 * Buffers.SIZEOF_FLOAT; + // final int cOff = 3 * Buffers.SIZEOF_FLOAT; + gl.glVertexAttribPointer(posLoc, 3, GL3.GL_FLOAT, false, stride, vertexColorDataBuffer); + vertexColorDataBuffer.position(3); // move to cOff + gl.glVertexAttribPointer(colorLoc,3, GL3.GL_FLOAT, false, stride, vertexColorDataBuffer); + vertexColorDataBuffer.position(0); // rewind cOff + + gl.glDrawElements(GL3.GL_TRIANGLES, 3, GL3.GL_UNSIGNED_SHORT, indicesBuffer); + + gl.glDisableVertexAttribArray(posLoc); + gl.glDisableVertexAttribArray(colorLoc); + } + + private void displayVBOOnly(final GL3 gl) { + final int posLoc = gl.glGetAttribLocation(progID, "vPosition"); + final int colorLoc = gl.glGetAttribLocation(progID, "vColor"); + gl.glEnableVertexAttribArray(posLoc); + gl.glEnableVertexAttribArray(colorLoc); + + gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, vbo); + final int stride = 6 * Buffers.SIZEOF_FLOAT; + final int cOff = 3 * Buffers.SIZEOF_FLOAT; + gl.glVertexAttribPointer(posLoc, 3, GL3.GL_FLOAT, false, stride, 0L); + gl.glVertexAttribPointer(colorLoc,3, GL3.GL_FLOAT, false, stride, cOff); + gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, ibo); + gl.glDrawElements(GL3.GL_TRIANGLES, 3, GL3.GL_UNSIGNED_SHORT, 0L); + + gl.glDisableVertexAttribArray(posLoc); + gl.glDisableVertexAttribArray(colorLoc); + gl.glBindBuffer(GL3.GL_ARRAY_BUFFER, 0); + gl.glBindBuffer(GL3.GL_ELEMENT_ARRAY_BUFFER, 0); + } + + private void displayVBOVAO(final GL3 gl) { + try { + gl.glBindVertexArray(vao); + gl.glDrawElements(GL3.GL_TRIANGLES, 3, GL3.GL_UNSIGNED_SHORT, 0L); + gl.glBindVertexArray(0); + } catch (GLException ex) { + Logger.getLogger(TestBug692GL3VAONEWT.class.getName()).log(Level.SEVERE,null,ex); + } + } + + @Override + public void display(GLAutoDrawable drawable) { + final GL3bc gl = drawable.getGL().getGL3bc(); + float color = ((float) currentMode.ordinal() + 1) / (Mode.values().length + 2); + gl.glClearColor(color, color, color, 0); + gl.glClear(GL3.GL_COLOR_BUFFER_BIT | GL3.GL_DEPTH_BUFFER_BIT); + gl.glUseProgram(progID); + final Mode newMode; + { + currentModeIdx = ( currentModeIdx + 1 ) % allModes.length; + newMode = allModes[ currentModeIdx ]; + } + if (newMode != currentMode) { + currentMode = newMode; + System.out.println("Display mode: " + currentMode); + } + currentMode.display(this, gl); + gl.glUseProgram(0); + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { + } + } + + private void testImpl(GLProfile profile, GL3VAODemo.Mode[] modes) throws InterruptedException { + final GLCapabilities capabilities = new GLCapabilities(profile); + final GLWindow glWindow = GLWindow.create(capabilities); + glWindow.setSize(512, 512); + + Animator anim = new Animator(glWindow); + + QuitAdapter quitAdapter = new QuitAdapter(); + glWindow.addKeyListener(quitAdapter); + glWindow.addWindowListener(quitAdapter); + + final GL3VAODemo vaoTest = new GL3VAODemo(modes); + glWindow.addGLEventListener(vaoTest); + glWindow.setVisible(true); + anim.start(); + + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while(!quitAdapter.shouldQuit() && t1-t0 Date: Fri, 1 Nov 2013 05:55:27 +0100 Subject: Bug 852: Add unit test TestCPUSourcingAPINEWT validating CPU sourcing, i.e. expecting exception w/ core profile! --- make/scripts/tests.sh | 5 +- .../junit/jogl/acore/TestBug692GL3VAONEWT.java | 3 - .../junit/jogl/acore/TestCPUSourcingAPINEWT.java | 225 +++++++++++++++++++++ 3 files changed, 228 insertions(+), 5 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestCPUSourcingAPINEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9d6a6b2ef..aa1450dc9 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -81,7 +81,7 @@ function jrun() { swton=$1 shift - D_ARGS="-Djogl.debug.DebugGL" + #D_ARGS="-Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" @@ -374,7 +374,8 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAONEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAONEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestCPUSourcingAPINEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLExtensionQueryOffscreen $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAONEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAONEWT.java index d6f8803e6..5337b64a0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAONEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestBug692GL3VAONEWT.java @@ -33,7 +33,6 @@ import java.nio.ShortBuffer; import java.util.logging.Level; import java.util.logging.Logger; -import javax.media.opengl.DebugGL3; import javax.media.opengl.GL3; import javax.media.opengl.GL3bc; import javax.media.opengl.GLAutoDrawable; @@ -237,8 +236,6 @@ public class TestBug692GL3VAONEWT extends UITestCase { @Override public void init(GLAutoDrawable drawable) { - drawable.setGL(new DebugGL3(drawable.getGL().getGL3())); - final GL3 gl = drawable.getGL().getGL3(); gl.glEnable(GL3.GL_DEPTH_TEST); gl.glDisable(GL3.GL_CULL_FACE); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestCPUSourcingAPINEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestCPUSourcingAPINEWT.java new file mode 100644 index 000000000..388c57904 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestCPUSourcingAPINEWT.java @@ -0,0 +1,225 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.nio.FloatBuffer; +import java.nio.ShortBuffer; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.GLBuffers; + +import javax.media.opengl.GL2; +import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLException; +import javax.media.opengl.GLOffscreenAutoDrawable; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestCPUSourcingAPINEWT extends UITestCase { + static long duration = 500; // ms + + static class Demo implements GLEventListener { + private final static float[] vertexColorData = new float[]{ + 0.0f, 0.75f, 0.0f, 1,0,0, + -0.5f, -0.75f, 0.0f, 0,1,0, + 0.9f, -0.75f, 0.0f, 0,0,1 + }; + private final FloatBuffer vertexColorDataBuffer = GLBuffers.newDirectFloatBuffer(vertexColorData); + + private final short[] indices = new short[]{0, 1, 2}; + private final ShortBuffer indicesBuffer = GLBuffers.newDirectShortBuffer(indices); + + + private int vertID = -1; + private int fragID = -1; + private int progID = -1; + + private static int createShader(final GL2ES2 gl, int type, + final String[] srcLines){ + int shaderID = gl.glCreateShader(type); + assert shaderID > 0; + int[] lengths = new int[srcLines.length]; + for (int i = 0; i < srcLines.length; i++) { + lengths[i] = srcLines[i].length(); + } + gl.glShaderSource(shaderID, srcLines.length, srcLines, lengths, 0); + gl.glCompileShader(shaderID); + return shaderID; + } + + private void initShaders(GL2ES2 gl) { + final String[] vertSrc = new String[]{ + "#version 150\n", + "in vec4 vPosition;\n", + "in vec4 vColor;\n", + "out vec4 pColor;\n", + "void main() {\n", + " pColor = vColor;\n", + " gl_Position = vPosition;\n", + "}\n" + }; + vertID = createShader(gl, GL2ES2.GL_VERTEX_SHADER, vertSrc); + + final String[] fragSrc = new String[]{ + "#version 150\n", + "in vec4 pColor;\n", + "void main() {\n", + " gl_FragColor = pColor;\n", + "}\n" + }; + fragID = createShader(gl, GL2ES2.GL_FRAGMENT_SHADER, fragSrc); + + // We're done with the compiler + gl.glReleaseShaderCompiler(); + + progID = gl.glCreateProgram(); + assert progID > 0; + gl.glAttachShader(progID, vertID); + gl.glAttachShader(progID, fragID); + gl.glLinkProgram(progID); + gl.glValidateProgram(progID); + } + + @Override + public void init(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + gl.glEnable(GL2ES2.GL_DEPTH_TEST); + gl.glDisable(GL2ES2.GL_CULL_FACE); + initShaders(gl); + + gl.setSwapInterval(1); + } + + @Override + public void dispose(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + gl.glDetachShader(progID, fragID); + gl.glDetachShader(progID, vertID); + gl.glDeleteProgram(progID); + gl.glDeleteShader(fragID); + gl.glDeleteShader(vertID); + } + + private void displayCPUSourcing(final GL2 gl) { + final int posLoc = gl.glGetAttribLocation(progID, "vPosition"); + final int colorLoc = gl.glGetAttribLocation(progID, "vColor"); + gl.glEnableVertexAttribArray(posLoc); + gl.glEnableVertexAttribArray(colorLoc); + + final int stride = 6 * Buffers.SIZEOF_FLOAT; + // final int cOff = 3 * Buffers.SIZEOF_FLOAT; + gl.glVertexAttribPointer(posLoc, 3, GL2ES2.GL_FLOAT, false, stride, vertexColorDataBuffer); + vertexColorDataBuffer.position(3); // move to cOff + gl.glVertexAttribPointer(colorLoc,3, GL2ES2.GL_FLOAT, false, stride, vertexColorDataBuffer); + vertexColorDataBuffer.position(0); // rewind cOff + + gl.glDrawElements(GL2ES2.GL_TRIANGLES, 3, GL2ES2.GL_UNSIGNED_SHORT, indicesBuffer); + + gl.glDisableVertexAttribArray(posLoc); + gl.glDisableVertexAttribArray(colorLoc); + } + + @Override + public void display(GLAutoDrawable drawable) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + gl.glClearColor(0x44, 0x44, 0x44, 0); + gl.glClear(GL2ES2.GL_COLOR_BUFFER_BIT | GL2ES2.GL_DEPTH_BUFFER_BIT); + gl.glUseProgram(progID); + + // Hard casting is of course invalid! + // But we need to 'fake' compatibility mode to trigger CPU-sourcing w/ GL3 core + displayCPUSourcing((GL2) gl); + + gl.glUseProgram(0); + } + + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { + } + } + + private void testImpl(GLProfile profile) throws InterruptedException { + final GLCapabilities capabilities = new GLCapabilities(profile); + GLDrawableFactory factory = GLDrawableFactory.getFactory(profile); + GLOffscreenAutoDrawable glad = factory.createOffscreenAutoDrawable(null, capabilities, null, 512, 512); + + final Demo vaoTest = new Demo(); + glad.addGLEventListener(vaoTest); + glad.display(); + + glad.destroy(); + } + + @Test + public void test01GL2CPUSource() throws GLException, InterruptedException { + if( ! GLProfile.isAvailable(GLProfile.GL2) ) { + System.err.println("GL2 n/a"); + return; + } + testImpl(GLProfile.get(GLProfile.GL2)); + } + + @Test + public void test02GL3CPUSource() throws GLException, InterruptedException { + final GLProfile glp = GLProfile.getMaxProgrammableCore(true); + if( !glp.isGL3ES3() && !glp.isGL2ES2() ) { + System.err.println("No GL core profile available, got "+glp); + return; + } + GLException exp = null; + try { + testImpl(glp); + } catch(GLException gle) { + exp = gle; + System.err.println("Expected Exception: "+exp.getMessage()); + } + Assert.assertNotNull("Excpected GLException missing due to CPU Sourcing w/ GL3 core context", exp); + } + + public static void main(String args[]) { + for(int i=0; i Date: Fri, 1 Nov 2013 12:38:54 +0100 Subject: Bug 885 - GLMediaPlayer: Allow single threaded mode - Especially where multiple media textures (Android) or shared GL context are not usable. - GLMediaPlayer: - TEXTURE_COUNT_MIN is the new minimum: '1' - i.e. no multithreading, single threaded player - TEXTURE_COUNT_DEFAULT is '4' - multithreaded - GLMediaPlayerImpl: - Add Single threaded mode, but perform initStreamImpl(..) off-thread. - --- make/scripts/adb-launch-activity.sh | 3 +- make/scripts/tests.sh | 6 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 9 +- .../android/av/AndroidGLMediaPlayerAPI14.java | 32 +++-- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 152 +++++++++++++++------ .../jogamp/opengl/util/av/NullGLMediaPlayer.java | 4 +- .../test/junit/jogl/demos/es2/av/MovieCube.java | 100 +++++++------- 7 files changed, 194 insertions(+), 112 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/adb-launch-activity.sh b/make/scripts/adb-launch-activity.sh index 84399520e..401bd51a6 100644 --- a/make/scripts/adb-launch-activity.sh +++ b/make/scripts/adb-launch-activity.sh @@ -2,7 +2,8 @@ #ANAME="com.jogamp.opengl.test/com.jogamp.opengl.test.android.NEWTGenericActivity" #ANAME="com.jogamp.android.launcher/com.jogamp.android.launcher.NEWTLauncherActivity2" -ANAME="com.jogamp.opengl.test/com.jogamp.opengl.test.android.NEWTGearsES2ActivityLauncher" +#ANAME="com.jogamp.opengl.test/com.jogamp.opengl.test.android.NEWTGearsES2ActivityLauncher" +ANAME="com.jogamp.opengl.test/com.jogamp.opengl.test.android.MovieCubeActivityLauncher0" adb $* shell "setprop log.redirect-stdio true ; setprop log.redirect-stderr true ; \ am start -a android.intent.action.MAIN -n $ANAME" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index aa1450dc9..a93c2ed79 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -136,7 +136,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" - #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" @@ -328,7 +328,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # @@ -375,7 +375,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAONEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestCPUSourcingAPINEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestCPUSourcingAPINEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLExtensionQueryOffscreen $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 3f6b78d7e..f0864f949 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -186,8 +186,11 @@ public interface GLMediaPlayer extends TextureSequence { public static final boolean DEBUG = Debug.debug("GLMediaPlayer"); public static final boolean DEBUG_NATIVE = Debug.debug("GLMediaPlayer.Native"); - /** Minimum texture count, value {@value}. */ - public static final int TEXTURE_COUNT_MIN = 4; + /** Default texture count, value {@value}. */ + public static final int TEXTURE_COUNT_DEFAULT = 4; + + /** Minimum texture count, value {@value}. Using the minimum texture count disables multi-threaded decoding. */ + public static final int TEXTURE_COUNT_MIN = 1; /** Constant {@value} for mute or not available. See Audio and video Stream IDs. */ public static final int STREAM_ID_NONE = -2; @@ -350,7 +353,7 @@ public interface GLMediaPlayer extends TextureSequence { * @param vid video stream id, see audio and video Stream IDs * @param aid video stream id, see audio and video Stream IDs * @param textureCount desired number of buffered textures to be decoded off-thread, will be validated by implementation. - * The minimum value is {@link #TEXTURE_COUNT_MIN}. + * The minimum value is {@link #TEXTURE_COUNT_DEFAULT}. * Ignored if video is muted. * @throws IllegalStateException if not invoked in {@link State#Uninitialized} * @throws IllegalArgumentException if arguments are invalid diff --git a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java index 415ee65a2..25a0bc15d 100644 --- a/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java +++ b/src/jogl/classes/jogamp/opengl/android/av/AndroidGLMediaPlayerAPI14.java @@ -56,6 +56,11 @@ import android.view.Surface; * Android implementation utilizes API level 14 (4.0.? ICS) features * as listed below. *

      + * Implementation is single threaded only, since we are not able to utilize multiple textures. + * We would need to add an implementation for API level 16 using MediaCodec/MediaExtractor + * to expose multithreading on multiple surface/textures. + *

      + *

      * We utilize the {@link MediaPlayer} with direct to texture streaming. * The MediaPlayer uses libstagefright to access the OpenMAX AL implementation * for hardware decoding. @@ -248,8 +253,7 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { } @Override - protected final void initStreamImpl(int vid, int aid) throws IOException { - + protected final void initStreamImpl(final int vid, final int aid) throws IOException { if( null == streamLoc ) { return; } @@ -297,6 +301,21 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { mp.getVideoWidth(), mp.getVideoHeight(), 0, 0, 0, 0f, 0, 0, mp.getDuration(), icodec, icodec); + /** + mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { + @Override + public void onPrepared(final MediaPlayer mp) { + final int r_aid = GLMediaPlayer.STREAM_ID_NONE == aid ? GLMediaPlayer.STREAM_ID_NONE : 1; // fake + final String icodec = "android"; + updateAttributes(0, r_aid, // fake + mp.getVideoWidth(), mp.getVideoHeight(), 0, + 0, 0, 0f, + 0, 0, mp.getDuration(), icodec, icodec); + } + }); + mp.prepareAsync(); + * + */ } else if( null != cam ) { final String icodec = "android"; final int[] fpsRange = { 0, 0 }; @@ -336,23 +355,20 @@ public class AndroidGLMediaPlayerAPI14 extends GLMediaPlayerImpl { /** * {@inheritDoc} *

      - * Returns 2 - implementation duplicates single texture + * Returns {@link #TEXTURE_COUNT_MIN}, using a single texture *

      */ @Override protected int validateTextureCount(int desiredTextureCount) { - return 2; + return TEXTURE_COUNT_MIN; } @Override protected final int getNextTextureImpl(GL gl, TextureFrame nextFrame) { int pts = TimeFrameI.INVALID_PTS; if(null != mp || null != cam) { - final SurfaceTextureFrame sTexFrame = (SurfaceTextureFrame) nextFrame; + final SurfaceTextureFrame sTexFrame = null != nextFrame ? (SurfaceTextureFrame) nextFrame : singleSTexFrame; final SurfaceTexture surfTex = sTexFrame.surfaceTex; - if( sTexFrame != singleSTexFrame ) { - throw new InternalError("XXX: sTexFrame: "+sTexFrame+", singleSTexFrame "+singleSTexFrame); - } if( !sTexFrameAttached ) { sTexFrameAttached = true; final Surface surface; diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 1d73d1a44..91647394d 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -304,7 +304,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( null != audioSink ) { audioSink.play(); // cont. w/ new data } - streamWorker.doResume(); + if( null != streamWorker ) { + streamWorker.doResume(); + } changeState(0, State.Playing); } default: @@ -325,7 +327,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( State.Playing == state ) { event_mask = addStateEventMask(event_mask, GLMediaPlayer.State.Paused); state = State.Paused; - streamWorker.doPause(); + if( null != streamWorker ) { + streamWorker.doPause(); + } if( flush ) { resetAVPTSAndFlush(); } else if( null != audioSink ) { @@ -348,8 +352,10 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } private final State destroyImpl(GL gl, int event_mask) { synchronized( stateLock ) { - streamWorker.doStop(); - streamWorker = null; + if( null != streamWorker ) { + streamWorker.doStop(); + streamWorker = null; + } destroyImpl(gl); removeAllTextureFrames(gl); textureCount=0; @@ -369,14 +375,18 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { case Paused: final State _state = state; state = State.Paused; - streamWorker.doPause(); + if( null != streamWorker ) { + streamWorker.doPause(); + } pts1 = seekImpl(msec); resetAVPTSAndFlush(); if( null != audioSink && State.Playing == _state ) { audioSink.play(); // cont. w/ new data } System.err.println("SEEK XXX: "+getPerfString()); - streamWorker.doResume(); + if( null != streamWorker ) { + streamWorker.doResume(); + } state = _state; break; default: @@ -476,7 +486,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } @Override - public final void initStream(URI streamLoc, int vid, int aid, int reqTextureCount) throws IllegalStateException, IllegalArgumentException { + public final void initStream(URI streamLoc, final int vid, final int aid, int reqTextureCount) throws IllegalStateException, IllegalArgumentException { synchronized( stateLock ) { if(State.Uninitialized != state) { throw new IllegalStateException("Instance not in state unintialized: "+this); @@ -486,8 +496,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } if( STREAM_ID_NONE != vid ) { textureCount = validateTextureCount(reqTextureCount); - if( textureCount < 2 ) { - throw new InternalError("Validated texture count < 2: "+textureCount); + if( textureCount < TEXTURE_COUNT_MIN ) { + throw new InternalError("Validated texture count < "+TEXTURE_COUNT_MIN+": "+textureCount); } } else { textureCount = 0; @@ -515,8 +525,21 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.vid = vid; this.aid = aid; - if (this.streamLoc != null) { - streamWorker = new StreamWorker(); + if ( this.streamLoc != null ) { + if( TEXTURE_COUNT_MIN < textureCount ) { + streamWorker = new StreamWorker(); + } else { + new Thread() { + public void run() { + try { + initStreamImpl(vid, aid); + } catch (Throwable t) { + streamErr = new StreamException(t.getClass().getSimpleName()+" while initializing: "+GLMediaPlayerImpl.this.toString(), t); + changeState(GLMediaEventListener.EVENT_CHANGE_ERR, GLMediaPlayer.State.Uninitialized); + } // also initializes width, height, .. etc + } + }.start(); + } } } } @@ -537,13 +560,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { @Override public final StreamException getStreamException() { + final StreamException e; synchronized( stateLock ) { - if( null != streamWorker ) { - return streamWorker.getStreamErr(); - } else { - return null; - } + e = streamErr; + streamErr = null; } + return e; } @Override @@ -552,11 +574,13 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if(State.Initialized != state ) { throw new IllegalStateException("Stream not in state initialized: "+this); } - final StreamException streamInitErr = streamWorker.getStreamErr(); - if( null != streamInitErr ) { - streamWorker = null; // already terminated! - destroy(null); - throw streamInitErr; + if( null != streamWorker ) { + final StreamException streamInitErr = getStreamException(); + if( null != streamInitErr ) { + streamWorker = null; // already terminated! + destroy(null); + throw streamInitErr; + } } try { if( STREAM_ID_NONE != vid ) { @@ -566,10 +590,18 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { System.err.println("initGLImpl.X "+this); } videoFramesOrig = createTexFrames(gl, textureCount); - videoFramesFree = new LFRingbuffer(videoFramesOrig); - videoFramesDecoded = new LFRingbuffer(TextureFrame[].class, textureCount); - lastFrame = videoFramesFree.getBlocking( ); - streamWorker.initGL(gl); + if( TEXTURE_COUNT_MIN == textureCount ) { + videoFramesFree = null; + videoFramesDecoded = null; + lastFrame = videoFramesOrig[0]; + } else { + videoFramesFree = new LFRingbuffer(videoFramesOrig); + videoFramesDecoded = new LFRingbuffer(TextureFrame[].class, textureCount); + lastFrame = videoFramesFree.getBlocking( ); + } + if( null != streamWorker ) { + streamWorker.initGL(gl); + } } else { removeAllTextureFrames(null); initGLImpl(null); @@ -601,10 +633,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { /** * Returns the validated number of textures to be handled. *

      - * Default is {@link #TEXTURE_COUNT_MIN} minimum textures. + * Default is {@link #TEXTURE_COUNT_DEFAULT} minimum textures, if desiredTextureCount + * is < {@link #TEXTURE_COUNT_MIN}, {@link #TEXTURE_COUNT_MIN} is returned. *

      *

      - * Implementation must at least return a texture count of two, the last texture and the decoding texture. + * Implementation must at least return a texture count of {@link #TEXTURE_COUNT_MIN}, two, the last texture and the decoding texture. *

      */ protected int validateTextureCount(int desiredTextureCount) { @@ -737,7 +770,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { cachedFrame = null; presentedFrameCount--; } else if( STREAM_ID_NONE != vid ) { - nextFrame = videoFramesDecoded.get(); + if( null != videoFramesDecoded ) { // single threaded ? TEXTURE_COUNT_MIN == textureCount + nextFrame = videoFramesDecoded.get(); + } else { + nextFrame = getNextSingleThreaded(gl, lastFrame); + } } currentTimeMillis = Platform.currentTimeMillis(); if( null != nextFrame ) { @@ -785,7 +822,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( dt > maxVideoDelay ) { cachedFrame = nextFrame; nextFrame = null; - } else if ( !droppedFrame && dt < -maxVideoDelay && videoFramesDecoded.size() > 0 ) { + } else if ( !droppedFrame && dt < -maxVideoDelay && null != videoFramesDecoded && videoFramesDecoded.size() > 0 ) { // only drop if prev. frame has not been dropped and // frame is too late and one decoded frame is already available. dropFrame = true; @@ -802,7 +839,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } else if( DEBUG ) { System.err.println("Invalid PTS: "+nextFrame); } - if( null != nextFrame ) { + if( null != nextFrame && null != videoFramesFree ) { + // Had frame and not single threaded ? (TEXTURE_COUNT_MIN < textureCount) final TextureFrame _lastFrame = lastFrame; lastFrame = nextFrame; videoFramesFree.putBlocking(_lastFrame); @@ -857,6 +895,27 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { */ protected abstract int getNextTextureImpl(GL gl, TextureFrame nextFrame); + protected final TextureFrame getNextSingleThreaded(final GL gl, final TextureFrame nextFrame) throws InterruptedException { + if( STREAM_ID_NONE != vid ) { + preNextTextureImpl(gl); + final int vPTS = getNextTextureImpl(gl, nextFrame); + postNextTextureImpl(gl); + if( TimeFrameI.INVALID_PTS != vPTS ) { + newFrameAvailable(nextFrame, Platform.currentTimeMillis()); + return nextFrame; + } + } else { + // audio only + final int vPTS = getNextTextureImpl(null, null); + if( TimeFrameI.INVALID_PTS != vPTS && TimeFrameI.END_OF_STREAM_PTS == vPTS ) { + // state transition incl. notification + pauseImpl(true, GLMediaEventListener.EVENT_CHANGE_EOS); + } + } + return null; + } + + /** * {@inheritDoc} *

      @@ -887,8 +946,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { videoFramesFree.resetFull(videoFramesOrig); lastFrame = videoFramesFree.get(); if( null == lastFrame ) { throw new InternalError("XXX"); } - } - if( null != videoFramesDecoded ) { videoFramesDecoded.clear(); } cachedFrame = null; @@ -933,7 +990,6 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { private volatile boolean shallPause = true; private volatile boolean shallStop = false; - private volatile StreamException streamErr = null; private volatile GLContext sharedGLCtx = null; private boolean sharedGLCtxCurrent = false; private GLDrawable dummyDrawable = null; @@ -977,7 +1033,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } - public synchronized void initGL(GL gl) { + public final synchronized void initGL(GL gl) { final GLContext glCtx = gl.getContext(); final boolean glCtxCurrent = glCtx.isCurrent(); final GLProfile glp = gl.getGLProfile(); @@ -993,7 +1049,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { sharedGLCtx.release(); } } - public synchronized void doPause() { + public final synchronized void doPause() { if( isActive ) { shallPause = true; if( Thread.currentThread() != this ) { @@ -1010,7 +1066,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - public synchronized void doResume() { + public final synchronized void doResume() { if( isRunning && !isActive ) { shallPause = false; if( Thread.currentThread() != this ) { @@ -1025,7 +1081,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - public synchronized void doStop() { + public final synchronized void doStop() { if( isRunning ) { shallStop = true; if( Thread.currentThread() != this ) { @@ -1043,12 +1099,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } } - public boolean isRunning() { return isRunning; } - public boolean isActive() { return isActive; } - public StreamException getStreamErr() { return streamErr; } + public final boolean isRunning() { return isRunning; } + public final boolean isActive() { return isActive; } @Override - public void run() { + public final void run() { setName(getName()+"-StreamWorker_"+StreamWorkerInstanceId); StreamWorkerInstanceId++; @@ -1109,9 +1164,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( !shallStop ) { TextureFrame nextFrame = null; try { - final GL gl; isBlocked = true; - if( null != videoFramesFree ) { + final GL gl; + if( STREAM_ID_NONE != vid ) { nextFrame = videoFramesFree.getBlocking(); nextFrame.setPTS( TimeFrameI.INVALID_PTS ); // mark invalid until processed! gl = sharedGLCtx.getGL(); @@ -1178,6 +1233,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } static int StreamWorkerInstanceId = 0; private StreamWorker streamWorker = null; + private volatile StreamException streamErr = null; protected final int addStateEventMask(int event_mask, State newState) { if( state != newState ) { @@ -1396,8 +1452,14 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } else { audioSinkInfo = ""; } - final int freeVideoFrames = null != videoFramesFree ? videoFramesFree.size() : 0; - final int decVideoFrames = null != videoFramesDecoded ? videoFramesDecoded.size() : 0; + final int freeVideoFrames, decVideoFrames; + if( null != videoFramesFree ) { + freeVideoFrames = videoFramesFree.size(); + decVideoFrames = videoFramesDecoded.size(); + } else { + freeVideoFrames = 0; + decVideoFrames = 0; + } return state+", frames[(p "+presentedFrameCount+", d "+decodedFrameCount+") / "+videoFrames+", "+tt+" s], "+ "speed " + playSpeed+", dAV "+( d_vpts - d_apts )+", vSCR "+video_scr+", vpts "+video_pts+", dSCR["+d_vpts+", avrg "+video_dpts_avg_diff+"], "+ "aSCR "+audio_scr+", apts "+audio_pts+" ( "+d_apts+" ), "+audioSinkInfo+ diff --git a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java index 840149272..fc621a1dd 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/NullGLMediaPlayer.java @@ -150,12 +150,12 @@ public class NullGLMediaPlayer extends GLMediaPlayerImpl { /** * {@inheritDoc} *

      - * Returns 2 + * Returns {@link GLMediaPlayer#TEXTURE_COUNT_MIN}. *

      */ @Override protected int validateTextureCount(int desiredTextureCount) { - return 2; + return TEXTURE_COUNT_MIN; } @Override diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index fe11f6aca..a7636fce4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -58,7 +58,7 @@ import com.jogamp.opengl.util.av.GLMediaPlayerFactory; import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; /** - * Simple cube movie player w/ aspect ration true projection on a cube. + * Simple cube movie player w/ aspect ration true projection on a cube. */ public class MovieCube implements GLEventListener { private static boolean waitForKey = false; @@ -68,7 +68,7 @@ public class MovieCube implements GLEventListener { private int swapInterval = 1; private long lastPerfPos = 0; private volatile boolean resetGLState = false; - + /** Blender's Big Buck Bunny Trailer: 24f 640p VP8, Vorbis 44100Hz mono, WebM/Matroska Stream. */ public static final URI defURI; static { @@ -80,18 +80,18 @@ public class MovieCube implements GLEventListener { } defURI = _defURI; } - - /** - * Default constructor which also issues {@link #initStream(URI, int, int, int)} w/ default values + + /** + * Default constructor which also issues {@link #initStream(URI, int, int, int)} w/ default values * and polls until the {@link GLMediaPlayer} is {@link GLMediaPlayer.State#Initialized}. * If {@link GLMediaEventListener#EVENT_CHANGE_EOS} is reached, the stream is started over again. *

      * This default constructor is merely useful for some drop-in test, e.g. using an applet. - *

      + *

      */ public MovieCube() throws IOException, URISyntaxException { this(-2.3f, 0f, 0f); - + mPlayer.addEventListener(new GLMediaEventListener() { @Override public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } @@ -108,9 +108,9 @@ public class MovieCube implements GLEventListener { mPlayer.seek(0); mPlayer.play(); } - } + } }); - initStream(defURI, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, 3 /* textureCount */); + initStream(defURI, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.STREAM_ID_AUTO, GLMediaPlayer.TEXTURE_COUNT_DEFAULT); StreamException se = null; while( null == se && GLMediaPlayer.State.Initialized != mPlayer.getState() ) { try { @@ -123,7 +123,7 @@ public class MovieCube implements GLEventListener { throw new RuntimeException(se); } } - + /** Custom constructor, user needs to issue {@link #initStream(URI, int, int, int)} afterwards. */ public MovieCube(float zoom0, float rotx, float roty) throws IOException { this.zoom0 = zoom0; @@ -136,20 +136,20 @@ public class MovieCube implements GLEventListener { mPlayer.initStream(streamLoc, vid, aid, textureCount); System.out.println("pC.1b "+mPlayer); } - + public void setSwapInterval(int v) { this.swapInterval = v; } - + public GLMediaPlayer getGLMediaPlayer() { return mPlayer; } - + public void resetGLState() { resetGLState = true; } - + private final KeyListener keyAction = new KeyAdapter() { public void keyReleased(KeyEvent e) { if( e.isAutoRepeat() ) { return; - } + } System.err.println("MC "+e); int pts0 = mPlayer.getVideoPTS(); int pts1 = 0; @@ -175,7 +175,7 @@ public class MovieCube implements GLEventListener { break; } case KeyEvent.VK_MULTIPLY: - mPlayer.setPlaySpeed(1.0f); + mPlayer.setPlaySpeed(1.0f); break; case KeyEvent.VK_SUBTRACT: { float playSpeed = mPlayer.getPlaySpeed(); @@ -184,7 +184,7 @@ public class MovieCube implements GLEventListener { } else { playSpeed -= 0.1f; } - mPlayer.setPlaySpeed(playSpeed); + mPlayer.setPlaySpeed(playSpeed); } break; case KeyEvent.VK_ADD: { float playSpeed = mPlayer.getPlaySpeed(); @@ -193,7 +193,7 @@ public class MovieCube implements GLEventListener { } else { playSpeed += 0.1f; } - mPlayer.setPlaySpeed(playSpeed); + mPlayer.setPlaySpeed(playSpeed); } break; case KeyEvent.VK_M: { float audioVolume = mPlayer.getAudioVolume(); @@ -202,16 +202,16 @@ public class MovieCube implements GLEventListener { } else { audioVolume = 1f; } - mPlayer.setAudioVolume(audioVolume); + mPlayer.setAudioVolume(audioVolume); } break; } - + if( 0 != pts1 ) { mPlayer.seek(pts1); } - } + } }; - + @Override public void init(GLAutoDrawable drawable) { if(null == mPlayer) { @@ -224,16 +224,16 @@ public class MovieCube implements GLEventListener { // throw new IllegalStateException("mPlayer has no VID/stream selected: "+mPlayer); } resetGLState = false; - + GL2ES2 gl = drawable.getGL().getGL2ES2(); System.err.println(JoglVersion.getGLInfo(gl, null)); - cube = new TextureSequenceCubeES2(mPlayer, false, zoom0, rotx, roty); - + cube = new TextureSequenceCubeES2(mPlayer, false, zoom0, rotx, roty); + if(waitForKey) { UITestCase.waitForKey("Init>"); } - + if( GLMediaPlayer.State.Initialized == mPlayer.getState() ) { try { mPlayer.initGL(gl); @@ -252,11 +252,11 @@ public class MovieCube implements GLEventListener { boolean added; final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { + if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.addKeyListener(keyAction); added = true; - } else { added = false; } + } else { added = false; } System.err.println("MC.init: kl-added "+added+", "+drawable.getClass().getName()); } @@ -275,11 +275,11 @@ public class MovieCube implements GLEventListener { System.err.println(Thread.currentThread()+" MovieCube.dispose ... "); disposeImpl(drawable, true); } - + private void disposeImpl(GLAutoDrawable drawable, boolean disposePlayer) { if(null == mPlayer) { return; } final Object upstreamWidget = drawable.getUpstreamWidget(); - if (upstreamWidget instanceof Window) { + if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; window.removeKeyListener(keyAction); } @@ -289,14 +289,14 @@ public class MovieCube implements GLEventListener { mPlayer=null; } cube.dispose(drawable); - cube=null; + cube=null; } - + @Override public void display(GLAutoDrawable drawable) { if(null == mPlayer) { return; } - + if( resetGLState ) { resetGLState = false; System.err.println("XXX resetGLState"); @@ -304,11 +304,11 @@ public class MovieCube implements GLEventListener { init(drawable); reshape(drawable, 0, 0, drawable.getWidth(), drawable.getHeight()); } - + final long currentPos = System.currentTimeMillis(); if( currentPos - lastPerfPos > 2000 ) { System.err.println( mPlayer.getPerfString() ); - lastPerfPos = currentPos; + lastPerfPos = currentPos; } cube.display(drawable); } @@ -317,7 +317,7 @@ public class MovieCube implements GLEventListener { int swapInterval = 1; int width = 510; int height = 300; - int textureCount = 3; // default - threaded + int textureCount = GLMediaPlayer.TEXTURE_COUNT_DEFAULT; // default - threaded boolean forceES2 = false; boolean forceES3 = false; @@ -326,10 +326,10 @@ public class MovieCube implements GLEventListener { int vid = GLMediaPlayer.STREAM_ID_AUTO; int aid = GLMediaPlayer.STREAM_ID_AUTO; final boolean origSize; - + String url_s=null; { - boolean _origSize = false; + boolean _origSize = false; for(int i=0; i Date: Sat, 2 Nov 2013 16:26:02 +0100 Subject: GLContextImpl: Move sharedContextHandle check to makeCurrentWithinLock(..) and let it fail there instead of within impl. class, only pass the handle - simplifies and removes redundancy. --- make/scripts/tests.sh | 7 ++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 17 +++++---- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 11 ++---- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 32 +++++------------ .../opengl/macosx/cgl/MacOSXCGLDrawable.java | 5 ++- .../macosx/cgl/MacOSXExternalCGLContext.java | 3 +- .../opengl/windows/wgl/WindowsWGLContext.java | 40 ++++++++-------------- .../opengl/x11/glx/X11ExternalGLXContext.java | 3 +- .../jogamp/opengl/x11/glx/X11GLXContext.java | 33 +++++++----------- 9 files changed, 58 insertions(+), 93 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a93c2ed79..6fbba6adf 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -136,7 +136,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" - D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" @@ -304,6 +304,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelGridAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -328,7 +329,7 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # @@ -384,7 +385,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 3f6eb01a0..d43da2c3e 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -648,16 +648,19 @@ public abstract class GLContextImpl extends GLContext { } final GLContextImpl shareWith = (GLContextImpl) GLContextShareSet.getCreatedShare(this); + final long shareWithHandle; if (null != shareWith) { shareWith.getDrawableImpl().lockSurface(); - // FIXME: - // Contemplate whether we shall 'fail' creating this context - // if 0==shareWith.getHandle(), since at this point - // both context are locked and current values are available. + shareWithHandle = shareWith.getHandle(); + if (0 == shareWithHandle) { + throw new GLException("GLContextShareSet returned an invalid OpenGL context: "+this); + } + } else { + shareWithHandle = 0; } final boolean created; try { - created = createImpl(shareWith); // may throws exception if fails! + created = createImpl(shareWithHandle); // may throws exception if fails if( created && hasNoDefaultVAO() ) { final int[] tmp = new int[1]; final GL3ES3 gl3es3 = gl.getRootGL().getGL3ES3(); @@ -748,13 +751,13 @@ public abstract class GLContextImpl extends GLContext { * @return the valid and current context if successful, or null * @throws GLException */ - protected abstract boolean createImpl(GLContextImpl sharedWith) throws GLException ; + protected abstract boolean createImpl(long sharedWithHandle) throws GLException ; /** * Platform dependent but harmonized implementation of the ARB_create_context * mechanism to create a context.
      * - * This method is called from {@link #createContextARB}, {@link #createImpl(GLContextImpl)} .. {@link #makeCurrent()} .
      + * This method is called from {@link #createContextARB}, {@link #createImpl(long)} .. {@link #makeCurrent()} .
      * * The implementation shall verify this context with a * MakeContextCurrent call.
      diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 2eb277f3f..903a4c461 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -155,12 +155,12 @@ public class EGLContext extends GLContextImpl { } @Override - protected boolean createImpl(GLContextImpl shareWith) throws GLException { + protected boolean createImpl(final long shareWithHandle) throws GLException { final EGLGraphicsConfiguration config = (EGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); final long eglDisplay = config.getScreen().getDevice().getHandle(); final GLProfile glProfile = drawable.getGLProfile(); final long eglConfig = config.getNativeConfig(); - long shareWithHandle = EGL.EGL_NO_CONTEXT; + // 0 == EGL.EGL_NO_CONTEXT; if ( 0 == eglDisplay ) { throw new GLException("Error: attempted to create an OpenGL context without a display connection"); @@ -180,13 +180,6 @@ public class EGLContext extends GLContextImpl { } } - if (shareWith != null) { - shareWithHandle = shareWith.getHandle(); - if (shareWithHandle == 0) { - throw new GLException("GLContextShareSet returned an invalid OpenGL context"); - } - } - final IntBuffer contextAttrsNIO; final int contextVersionReq, contextVersionAttr; { diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 037aaca08..0d231b89d 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -286,35 +286,19 @@ public class MacOSXCGLContext extends GLContextImpl return false; } - protected long createImplPreset(GLContextImpl shareWith) throws GLException { - long share = 0; - if (shareWith != null) { - // Change our OpenGL mode to match that of any share context before we create ourselves - setOpenGLMode(((MacOSXCGLContext)shareWith).getOpenGLMode()); - share = shareWith.getHandle(); - if (share == 0) { - throw new GLException("GLContextShareSet returned a NULL OpenGL context"); - } - } - - MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); - GLCapabilitiesImmutable capabilitiesChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); - GLProfile glp = capabilitiesChosen.getGLProfile(); + @Override + protected boolean createImpl(final long shareWithHandle) throws GLException { + final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); + final GLCapabilitiesImmutable capabilitiesChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final GLProfile glp = capabilitiesChosen.getGLProfile(); if( glp.isGLES1() || glp.isGLES2() || glp.isGLES3() || ( glp.isGL3() && !isLionOrLater ) || ( glp.isGL4() && !isMavericksOrLater ) ) { throw new GLException("OpenGL profile not supported on MacOSX "+Platform.getOSVersionNumber()+": "+glp); } - - if (DEBUG) { - System.err.println("Share context is " + toHexString(share) + " for " + this); + if( 0 != shareWithHandle && GLBackendType.NSOPENGL != getOpenGLMode() ) { + throw new GLException("Context sharing only supported in mode "+GLBackendType.NSOPENGL+": "+this); } - return share; - } - - @Override - protected boolean createImpl(GLContextImpl shareWith) throws GLException { - long share = createImplPreset(shareWith); - contextHandle = createContextARB(share, true); + contextHandle = createContextARB(shareWithHandle, true); return 0 != contextHandle; } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index bb36a7219..448e3e221 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -84,7 +84,10 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { // GLPbuffer, a GLJPanel and a GLCanvas simultaneously) but should // be enough to get things off the ground. public enum GLBackendType { - NSOPENGL(0), CGL(1); + /** Default OpenGL Backend */ + NSOPENGL(0), + /** Alternative OpenGL Backend, only used for external context! */ + CGL(1); public final int id; diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index 5d036d45a..ebb0fc6d1 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -50,7 +50,6 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import jogamp.nativewindow.WrappedSurface; -import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLContextShareSet; import jogamp.opengl.macosx.cgl.MacOSXCGLDrawable.GLBackendType; @@ -118,7 +117,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { } @Override - protected boolean createImpl(GLContextImpl shareWith) throws GLException { + protected boolean createImpl(final long shareWithHandle) throws GLException { return true; } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java index b1e41624d..b214252c1 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLContext.java @@ -268,7 +268,7 @@ public class WindowsWGLContext extends GLContextImpl { * called by {@link #makeCurrentImpl()}. */ @Override - protected boolean createImpl(GLContextImpl shareWith) { + protected boolean createImpl(long shareWithHandle) { final AbstractGraphicsConfiguration config = drawable.getNativeSurface().getGraphicsConfiguration(); final AbstractGraphicsDevice device = config.getScreen().getDevice(); final WindowsWGLDrawableFactory factory = (WindowsWGLDrawableFactory)drawable.getFactoryImpl(); @@ -278,18 +278,7 @@ public class WindowsWGLContext extends GLContextImpl { isGLReadDrawableAvailable(); // trigger setup wglGLReadDrawableAvailable if (DEBUG) { - System.err.println(getThreadName() + ": createImpl: START "+glCaps+", share "+shareWith); - } - - // Windows can set up sharing of display lists after creation time - long share; - if ( null != shareWith ) { - share = shareWith.getHandle(); - if (share == 0) { - throw new GLException("GLContextShareSet returned an invalid OpenGL context"); - } - } else { - share = 0; + System.err.println(getThreadName() + ": createImpl: START "+glCaps+", share "+toHexString(shareWithHandle)); } boolean createContextARBTried = false; @@ -300,17 +289,17 @@ public class WindowsWGLContext extends GLContextImpl { if(GLContext.CONTEXT_NOT_CURRENT == sharedContext.makeCurrent()) { throw new GLException("Could not make Shared Context current: "+sharedContext); } - contextHandle = createContextARB(share, true); + contextHandle = createContextARB(shareWithHandle, true); sharedContext.release(); if (!wglMakeContextCurrent(drawable.getHandle(), drawableRead.getHandle(), contextHandle)) { throw new GLException("Cannot make previous verified context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError()); } } else { - contextHandle = createContextARB(share, true); + contextHandle = createContextARB(shareWithHandle, true); } createContextARBTried = true; if ( DEBUG && 0 != contextHandle ) { - System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+share); + System.err.println(getThreadName() + ": createImpl: OK (ARB, using sharedContext) share "+toHexString(shareWithHandle)); } } @@ -343,17 +332,17 @@ public class WindowsWGLContext extends GLContextImpl { } if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) { // initial ARB context creation - contextHandle = createContextARB(share, true); + contextHandle = createContextARB(shareWithHandle, true); createContextARBTried=true; if (DEBUG) { if( 0 != contextHandle ) { - System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+share); + System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+toHexString(shareWithHandle)); } else { - System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+share); + System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+toHexString(shareWithHandle)); } } } else if (DEBUG) { - System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+share+ + System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+toHexString(shareWithHandle)+ ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable); } } @@ -362,7 +351,7 @@ public class WindowsWGLContext extends GLContextImpl { } if( 0 != contextHandle ) { - share = 0; // mark as shared thx to the ARB create method + shareWithHandle = 0; // mark as shared thx to the ARB create method if( 0 != temp_ctx ) { WGL.wglMakeCurrent(0, 0); WGL.wglDeleteContext(temp_ctx); @@ -387,16 +376,17 @@ public class WindowsWGLContext extends GLContextImpl { WGL.wglDeleteContext(contextHandle); throw new GLException("Error making old context current: 0x" + toHexString(contextHandle) + ", werr: " + GDI.GetLastError()); } - if( 0 != share ) { + if( 0 != shareWithHandle ) { + // Windows can set up sharing of display lists after creation time if using GDI // Only utilize the classic GDI 'wglShareLists' shared context method // for traditional non ARB context. - if ( !WGL.wglShareLists(share, contextHandle) ) { - throw new GLException("wglShareLists(" + toHexString(share) + + if ( !WGL.wglShareLists(shareWithHandle, contextHandle) ) { + throw new GLException("wglShareLists(" + toHexString(shareWithHandle) + ", " + toHexString(contextHandle) + ") failed: werr " + GDI.GetLastError()); } } if (DEBUG) { - System.err.println(getThreadName() + ": createImpl: OK (old) share "+share); + System.err.println(getThreadName() + ": createImpl: OK (old) share "+toHexString(shareWithHandle)); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java index 9b7b0f5ae..ff9363ca0 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11ExternalGLXContext.java @@ -51,7 +51,6 @@ import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; import jogamp.nativewindow.WrappedSurface; -import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLContextShareSet; import com.jogamp.common.nio.Buffers; @@ -114,7 +113,7 @@ public class X11ExternalGLXContext extends X11GLXContext { } @Override - protected boolean createImpl(GLContextImpl shareWith) { + protected boolean createImpl(final long shareWithHandle) { return true; } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java index 10f21f0c3..94620c4fc 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXContext.java @@ -283,7 +283,7 @@ public class X11GLXContext extends GLContextImpl { } @Override - protected boolean createImpl(GLContextImpl shareWith) { + protected boolean createImpl(final long shareWithHandle) { boolean direct = true; // try direct always isDirect = false; // fall back @@ -293,15 +293,8 @@ public class X11GLXContext extends GLContextImpl { final X11GLXContext sharedContext = (X11GLXContext) factory.getOrCreateSharedContext(device); long display = device.getHandle(); - final long share; - if ( null != shareWith ) { - share = shareWith.getHandle(); - if (share == 0) { - throw new GLException("GLContextShareSet returned an invalid OpenGL context"); - } - direct = GLX.glXIsDirect(display, share); - } else { - share = 0; + if ( 0 != shareWithHandle ) { + direct = GLX.glXIsDirect(display, shareWithHandle); } final GLCapabilitiesImmutable glCaps = (GLCapabilitiesImmutable) config.getChosenCapabilities(); @@ -313,7 +306,7 @@ public class X11GLXContext extends GLContextImpl { if(glp.isGL3()) { throw new GLException(getThreadName()+": Unable to create OpenGL >= 3.1 context"); } - contextHandle = GLX.glXCreateContext(display, config.getXVisualInfo(), share, direct); + contextHandle = GLX.glXCreateContext(display, config.getXVisualInfo(), shareWithHandle, direct); if ( 0 == contextHandle ) { throw new GLException(getThreadName()+": Unable to create context(0)"); } @@ -325,7 +318,7 @@ public class X11GLXContext extends GLContextImpl { } isDirect = GLX.glXIsDirect(display, contextHandle); if (DEBUG) { - System.err.println(getThreadName() + ": createContextImpl: OK (old-1) share "+share+", direct "+isDirect+"/"+direct); + System.err.println(getThreadName() + ": createContextImpl: OK (old-1) share "+toHexString(shareWithHandle)+", direct "+isDirect+"/"+direct); } return true; } @@ -334,10 +327,10 @@ public class X11GLXContext extends GLContextImpl { // utilize the shared context's GLXExt in case it was using the ARB method and it already exists if( null != sharedContext && sharedContext.isCreatedWithARBMethod() ) { - contextHandle = createContextARB(share, direct); + contextHandle = createContextARB(shareWithHandle, direct); createContextARBTried = true; if ( DEBUG && 0 != contextHandle ) { - System.err.println(getThreadName() + ": createContextImpl: OK (ARB, using sharedContext) share "+share); + System.err.println(getThreadName() + ": createContextImpl: OK (ARB, using sharedContext) share "+toHexString(shareWithHandle)); } } @@ -345,7 +338,7 @@ public class X11GLXContext extends GLContextImpl { if( 0 == contextHandle ) { // To use GLX_ARB_create_context, we have to make a temp context current, // so we are able to use GetProcAddress - temp_ctx = GLX.glXCreateNewContext(display, config.getFBConfig(), GLX.GLX_RGBA_TYPE, share, direct); + temp_ctx = GLX.glXCreateNewContext(display, config.getFBConfig(), GLX.GLX_RGBA_TYPE, shareWithHandle, direct); if ( 0 == temp_ctx ) { throw new GLException(getThreadName()+": Unable to create temp OpenGL context(1)"); } @@ -360,17 +353,17 @@ public class X11GLXContext extends GLContextImpl { final boolean isExtARBCreateContextAvailable = isExtensionAvailable("GLX_ARB_create_context"); if ( isProcCreateContextAttribsARBAvailable && isExtARBCreateContextAvailable ) { // initial ARB context creation - contextHandle = createContextARB(share, direct); + contextHandle = createContextARB(shareWithHandle, direct); createContextARBTried=true; if (DEBUG) { if( 0 != contextHandle ) { - System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+share); + System.err.println(getThreadName() + ": createContextImpl: OK (ARB, initial) share "+toHexString(shareWithHandle)); } else { - System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+share); + System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - creation failed - share "+toHexString(shareWithHandle)); } } } else if (DEBUG) { - System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+share+ + System.err.println(getThreadName() + ": createContextImpl: NOT OK (ARB, initial) - extension not available - share "+toHexString(shareWithHandle)+ ", isProcCreateContextAttribsARBAvailable "+isProcCreateContextAttribsARBAvailable+", isExtGLXARBCreateContextAvailable "+isExtARBCreateContextAvailable); } } @@ -404,7 +397,7 @@ public class X11GLXContext extends GLContextImpl { throw new GLException(getThreadName()+": Error making context(1) current: display "+toHexString(display)+", context "+toHexString(contextHandle)+", drawable "+drawable); } if (DEBUG) { - System.err.println(getThreadName() + ": createContextImpl: OK (old-2) share "+share); + System.err.println(getThreadName() + ": createContextImpl: OK (old-2) share "+toHexString(shareWithHandle)); } } isDirect = GLX.glXIsDirect(display, contextHandle); -- cgit v1.2.3 From cf1163fc88976e7087d3a17524a49139e35a4708 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 5 Nov 2013 11:03:33 +0100 Subject: Bug 888 / Bug 891 - Enhance GLCapabilities-Query: Apply changes of commit 613e33ee8ffc1f2b9c5db1e1b5bb5253a159ed6d to EGL and WGL. Note: WGL config query is already performed as a bulk operation. Note: OSX does not perform such queries. --- make/config/jogl/egl-CustomCCode.c | 26 +++++ make/config/jogl/egl-CustomJavaCode.java | 45 +++++++ make/config/jogl/egl.cfg | 28 +---- make/config/jogl/eglext.cfg | 2 + make/scripts/java-win.bat | 3 +- make/scripts/tests-win.bat | 6 +- make/scripts/tests.sh | 5 +- .../jogamp/opengl/egl/EGLDrawableFactory.java | 2 +- .../opengl/egl/EGLGraphicsConfiguration.java | 129 +++++++++++++-------- .../egl/EGLGraphicsConfigurationFactory.java | 50 ++++++-- .../jogamp/opengl/egl/EGLUpstreamSurfaceHook.java | 2 +- .../wgl/WindowsWGLGraphicsConfiguration.java | 7 +- .../WindowsWGLGraphicsConfigurationFactory.java | 103 ++++++++++------ .../glx/X11GLXGraphicsConfigurationFactory.java | 4 +- 14 files changed, 276 insertions(+), 136 deletions(-) create mode 100644 make/config/jogl/egl-CustomCCode.c create mode 100644 make/config/jogl/egl-CustomJavaCode.java (limited to 'make/scripts') diff --git a/make/config/jogl/egl-CustomCCode.c b/make/config/jogl/egl-CustomCCode.c new file mode 100644 index 000000000..0163c6742 --- /dev/null +++ b/make/config/jogl/egl-CustomCCode.c @@ -0,0 +1,26 @@ +#include /* android */ +#include +#include +#include + +/* Java->C glue code: + * Java package: jogamp.opengl.egl.EGL + * Java method: void eglGetConfigAttributes(long dpy, long config, IntBuffer attributes, IntBuffer values) + */ +Java_jogamp_opengl_egl_EGL_dispatch_1eglGetConfigAttributes(JNIEnv *env, jclass _unused, jlong dpy, jlong config, jint attributeCount, jobject attributes, jint attributes_byte_offset, jobject values, jint values_byte_offset, jlong procAddress) { + typedef EGLBoolean (EGLAPIENTRY*_local_PFNEGLGETCONFIGATTRIBPROC)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint * value); + _local_PFNEGLGETCONFIGATTRIBPROC ptr_eglGetConfigAttrib = (_local_PFNEGLGETCONFIGATTRIBPROC) (intptr_t) procAddress; + assert(ptr_eglGetConfigAttrib != NULL); + + if ( attributeCount > 0 && NULL != attributes ) { + int i; + int * attributes_ptr = (int *) (((char*) (*env)->GetDirectBufferAddress(env, attributes)) + attributes_byte_offset); + EGLint * values_ptr = (EGLint *) (((char*) (*env)->GetDirectBufferAddress(env, values)) + values_byte_offset); + for(i=0; i + * Entry point to C language function: EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint * value);
      Part of EGL_VERSION_1_X + *

      + */ + public static void eglGetConfigAttributes(long dpy, long config, IntBuffer attributes, IntBuffer values) { + if( attributes == null || values == null ) { + throw new RuntimeException("arrays buffers are null"); + } + if( !Buffers.isDirect(attributes) || !Buffers.isDirect(values) ) { + throw new RuntimeException("arrays buffers are not direct"); + } + if( attributes.remaining() > values.remaining() ) { + throw new RuntimeException("not enough values "+values+" for attributes "+attributes); + } + final long __addr = _table._addressof_eglGetConfigAttrib; + dispatch_eglGetConfigAttributes(dpy, config, attributes.remaining(), attributes, Buffers.getDirectBufferByteOffset(attributes), + values, Buffers.getDirectBufferByteOffset(values), __addr); + } + private static native void dispatch_eglGetConfigAttributes(long dpy, long config, int attributeCount, Object attributes, int attributes_byte_offset, Object values, int valuesOffset, long procAddr); + diff --git a/make/config/jogl/egl.cfg b/make/config/jogl/egl.cfg index b30985076..94b67951d 100644 --- a/make/config/jogl/egl.cfg +++ b/make/config/jogl/egl.cfg @@ -25,31 +25,7 @@ GetProcAddressTableExpr _table ArgumentIsString eglGetProcAddress 0 ReturnsString eglQueryString -CustomCCode #include /* android */ -CustomCCode #include -CustomCCode #include -CustomCCode #include - -CustomJavaCode EGL private static EGLProcAddressTable _table = new EGLProcAddressTable(new GLProcAddressResolver()); -CustomJavaCode EGL public static void resetProcAddressTable(DynamicLookupHelper lookup) { -CustomJavaCode EGL _table.reset(lookup); -CustomJavaCode EGL } - -# There are some #defines in egl.h that GlueGen and PCPP don't currently handle -CustomJavaCode EGL public static final long EGL_DEFAULT_DISPLAY = 0; -CustomJavaCode EGL public static final long EGL_NO_CONTEXT = 0; -CustomJavaCode EGL public static final long EGL_NO_DISPLAY = 0; -CustomJavaCode EGL public static final long EGL_NO_SURFACE = 0; -CustomJavaCode EGL public static final int EGL_DONT_CARE = -1; -CustomJavaCode EGL public static final int EGL_UNKNOWN = -1; -CustomJavaCode EGL -CustomJavaCode EGL protected static long eglGetProcAddress(long eglGetProcAddressHandle, java.lang.String procname) -CustomJavaCode EGL { -CustomJavaCode EGL if (eglGetProcAddressHandle == 0) { -CustomJavaCode EGL throw new GLException("Passed null pointer for method \"eglGetProcAddress\""); -CustomJavaCode EGL } -CustomJavaCode EGL return dispatch_eglGetProcAddress0(procname, eglGetProcAddressHandle); -CustomJavaCode EGL } - +IncludeAs CustomJavaCode EGL egl-CustomJavaCode.java +IncludeAs CustomCCode egl-CustomCCode.c Import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver diff --git a/make/config/jogl/eglext.cfg b/make/config/jogl/eglext.cfg index a7fb45409..7fccce716 100644 --- a/make/config/jogl/eglext.cfg +++ b/make/config/jogl/eglext.cfg @@ -17,6 +17,8 @@ NIODirectOnly __ALL__ ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/jogamp/opengl/egl/EGL.java +IgnoreExtension EGL_VERSION_1_X + HierarchicalNativeOutput false # Use a ProcAddressTable so we dynamically look up the routines diff --git a/make/scripts/java-win.bat b/make/scripts/java-win.bat index 47b8184b2..2b45ae517 100755 --- a/make/scripts/java-win.bat +++ b/make/scripts/java-win.bat @@ -1,4 +1,5 @@ -%J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win.log 2>&1 +REM %J2RE_HOME%\bin\java -classpath %CP_ALL% "-Djava.library.path=%LIB_DIR%" %D_ARGS% %X_ARGS% %* > java-win.log 2>&1 +%J2RE_HOME%\bin\java -classpath %CP_ALL% %D_ARGS% %X_ARGS% %* > java-win.log 2>&1 tail java-win.log diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 0632c24b0..8de40e1f4 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -17,7 +17,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedConte REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT %* @@ -78,12 +78,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6fbba6adf..63a3fa8c6 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -304,7 +304,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelGridAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -385,7 +386,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2SWT3 $* diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 1a881ee8a..4202c7454 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -354,7 +354,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { final IntBuffer attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(caps); final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(caps); if( EGL.eglChooseConfig(eglDisplay.getHandle(), attrs, configs, configs.capacity(), numConfigs) && numConfigs.get(0) > 0) { - return EGLGraphicsConfigurationFactory.eglConfigs2GLCaps(eglDisplay, caps.getGLProfile(), configs, numConfigs.get(0), winattrmask, false /* forceTransparentFlag */); + return EGLGraphicsConfigurationFactory.eglConfigs2GLCaps(eglDisplay, caps.getGLProfile(), configs, numConfigs.get(0), winattrmask, false /* forceTransparentFlag */, false /* onlyFirstValid */); } } return new ArrayList(0); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index f3592c150..dd7bf99cb 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -185,31 +185,53 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple public static EGLGLCapabilities EGLConfig2Capabilities(EGLGraphicsDevice device, GLProfile glp, long config, int winattrmask, boolean forceTransparentFlag) { final long display = device.getHandle(); - final IntBuffer val = Buffers.newDirectIntBuffer(1); final int cfgID; final int rType; final int visualID; + final int _attributes[] = { + EGL.EGL_CONFIG_ID, // 0 + EGL.EGL_RENDERABLE_TYPE, + EGL.EGL_NATIVE_VISUAL_ID, + EGL.EGL_CONFIG_CAVEAT, + EGL.EGL_RED_SIZE, // 4 + EGL.EGL_GREEN_SIZE, + EGL.EGL_BLUE_SIZE, + EGL.EGL_ALPHA_SIZE, // 7 + EGL.EGL_STENCIL_SIZE, // 8 + EGL.EGL_DEPTH_SIZE, + EGL.EGL_TRANSPARENT_TYPE, // 10 + EGL.EGL_TRANSPARENT_RED_VALUE, + EGL.EGL_TRANSPARENT_GREEN_VALUE, + EGL.EGL_TRANSPARENT_BLUE_VALUE, + EGL.EGL_SAMPLES, // 14 + EGLExt.EGL_COVERAGE_BUFFERS_NV, // 15 + EGLExt.EGL_COVERAGE_SAMPLES_NV + }; + final IntBuffer attributes = Buffers.newDirectIntBuffer(_attributes); + final IntBuffer values = Buffers.newDirectIntBuffer(attributes.remaining()); + EGL.eglGetConfigAttributes(display, config, attributes, values); + // get the configID - if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_ID, val)) { + if( EGL.EGL_CONFIG_ID != attributes.get(0) ) { if(DEBUG) { // FIXME: this happens on a ATI PC Emulation .. System.err.println("EGL couldn't retrieve ConfigID for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError())); } return null; } - cfgID = val.get(0); + cfgID = values.get(0); - if(!EGL.eglGetConfigAttrib(display, config, EGL.EGL_RENDERABLE_TYPE, val)) { + if( EGL.EGL_RENDERABLE_TYPE != attributes.get(1) ) { if(DEBUG) { System.err.println("EGL couldn't retrieve EGL_RENDERABLE_TYPE for config "+toHexString(config)+", error "+toHexString(EGL.eglGetError())); } return null; } - rType = val.get(0); + rType = values.get(1); - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_NATIVE_VISUAL_ID, val)) { - visualID = val.get(0); + if( EGL.EGL_NATIVE_VISUAL_ID == attributes.get(2) ) { + visualID = values.get(2); } else { visualID = VisualIDHolder.VID_UNDEFINED; } @@ -234,64 +256,69 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple return null; } - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_CONFIG_CAVEAT, val)) { - if( EGL.EGL_SLOW_CONFIG == val.get(0) ) { + if( EGL.EGL_CONFIG_CAVEAT == attributes.get(3) ) { + if( EGL.EGL_SLOW_CONFIG == values.get(3) ) { caps.setHardwareAccelerated(false); } } - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_SAMPLES, val)) { - caps.setSampleBuffers(val.get(0)>0?true:false); - caps.setNumSamples(val.get(0)); + // ALPHA shall be set at last - due to it's auto setting by the above (!opaque / samples) + if( EGL.EGL_RED_SIZE == attributes.get(4) ) { + caps.setRedBits(values.get(4)); } - if(!caps.getSampleBuffers()) { - // try NV_coverage_sample extension - if(EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_BUFFERS_NV, val)) { - if(val.get(0)>0 && - EGL.eglGetConfigAttrib(display, config, EGLExt.EGL_COVERAGE_SAMPLES_NV, val)) { - caps.setSampleExtension(GLGraphicsConfigurationUtil.NV_coverage_sample); - caps.setSampleBuffers(true); - caps.setNumSamples(val.get(0)); - } - } + if( EGL.EGL_GREEN_SIZE == attributes.get(5) ) { + caps.setGreenBits(values.get(5)); + } + if( EGL.EGL_BLUE_SIZE == attributes.get(6) ) { + caps.setBlueBits(values.get(6)); + } + if( EGL.EGL_ALPHA_SIZE == attributes.get(7) ) { + caps.setAlphaBits(values.get(7)); + } + if( EGL.EGL_STENCIL_SIZE == attributes.get(8) ) { + caps.setStencilBits(values.get(8)); } - if(forceTransparentFlag) { + if( EGL.EGL_DEPTH_SIZE == attributes.get(9) ) { + caps.setDepthBits(values.get(9)); + } + if( forceTransparentFlag ) { caps.setBackgroundOpaque(false); - } else if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_TYPE, val)) { - caps.setBackgroundOpaque(val.get(0) != EGL.EGL_TRANSPARENT_RGB); + } else if( EGL.EGL_TRANSPARENT_TYPE == attributes.get(10) ) { + caps.setBackgroundOpaque(values.get(10) != EGL.EGL_TRANSPARENT_RGB); } if(!caps.isBackgroundOpaque()) { - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_RED_VALUE, val)) { - caps.setTransparentRedValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0)); + if( EGL.EGL_TRANSPARENT_RED_VALUE == attributes.get(11) ) { + final int v = values.get(11); + caps.setTransparentRedValue(EGL.EGL_DONT_CARE==v?-1:v); } - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_GREEN_VALUE, val)) { - caps.setTransparentGreenValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0)); + if( EGL.EGL_TRANSPARENT_GREEN_VALUE == attributes.get(12) ) { + final int v = values.get(12); + caps.setTransparentGreenValue(EGL.EGL_DONT_CARE==v?-1:v); } - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_BLUE_VALUE, val)) { - caps.setTransparentBlueValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0)); + if( EGL.EGL_TRANSPARENT_BLUE_VALUE == attributes.get(13) ) { + final int v = values.get(13); + caps.setTransparentBlueValue(EGL.EGL_DONT_CARE==v?-1:v); } /** Not defined in EGL - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_TRANSPARENT_ALPHA_VALUE, val)) { - caps.setTransparentAlphaValue(val.get(0)==EGL.EGL_DONT_CARE?-1:val.get(0)); + if( EGL.EGL_TRANSPARENT_ALPHA_VALUE == attributes.get(??) ) { + final int v = values.get(??); + caps.setTransparentAlphaValue(EGL.EGL_DONT_CARE==v?-1:v); } */ } - // ALPHA shall be set at last - due to it's auto setting by the above (!opaque / samples) - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_RED_SIZE, val)) { - caps.setRedBits(val.get(0)); - } - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_GREEN_SIZE, val)) { - caps.setGreenBits(val.get(0)); - } - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_BLUE_SIZE, val)) { - caps.setBlueBits(val.get(0)); - } - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_ALPHA_SIZE, val)) { - caps.setAlphaBits(val.get(0)); - } - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_STENCIL_SIZE, val)) { - caps.setStencilBits(val.get(0)); + if( EGL.EGL_SAMPLES == attributes.get(14) ) { + final int numSamples = values.get(14); + caps.setSampleBuffers(numSamples>0?true:false); + caps.setNumSamples(numSamples); } - if(EGL.eglGetConfigAttrib(display, config, EGL.EGL_DEPTH_SIZE, val)) { - caps.setDepthBits(val.get(0)); + if(!caps.getSampleBuffers()) { + // try NV_coverage_sample extension + if( EGLExt.EGL_COVERAGE_BUFFERS_NV == attributes.get(15) ) { + final boolean enabled = values.get(15) > 0; + if( enabled && EGLExt.EGL_COVERAGE_SAMPLES_NV == attributes.get(16) ) { + caps.setSampleExtension(GLGraphicsConfigurationUtil.NV_coverage_sample); + caps.setSampleBuffers(true); + caps.setNumSamples(values.get(16)); + } + } } // Since the passed GLProfile may be null, @@ -430,6 +457,6 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } - private GLCapabilitiesChooser chooser; + private final GLCapabilitiesChooser chooser; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 54510b51a..568fede45 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -42,7 +42,6 @@ import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.NativeWindowFactory; - import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; @@ -208,7 +207,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("Graphics configuration get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError())); } if (numConfigs.get(0) > 0) { - availableCaps = eglConfigs2GLCaps(eglDevice, null, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, false); + availableCaps = eglConfigs2GLCaps(eglDevice, null, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, false /* forceTransparentFlag */, false /* onlyFirstValid */); if( null != availableCaps && availableCaps.size() > 1) { Collections.sort(availableCaps, EglCfgIDComparator); } @@ -343,13 +342,14 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(0 == numConfigs.get(0)) { throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: Get maxConfigs (eglGetConfigs) no configs"); } + final int numEGLConfigs = numConfigs.get(0); if (DEBUG) { System.err.println("EGLGraphicsConfiguration.eglChooseConfig: eglChooseConfig eglDisplay "+toHexString(eglDisplay)+ ", nativeVisualID "+toHexString(nativeVisualID)+ ", capsChosen "+capsChosen+", winbits "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrmask).toString()+ ", fboAvail "+GLContext.isFBOAvailable(device, glp)+ ", device "+device+", "+device.getUniqueID()+ - ", numConfigs "+numConfigs.get(0)); + ", numEGLConfigs "+numEGLConfigs); } final IntBuffer attrs = EGLGraphicsConfiguration.GLCapabilities2AttribList(capsChosen); @@ -358,24 +358,42 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact // 1st choice: get GLCapabilities based on users GLCapabilities // setting recommendedIndex as preferred choice // skipped if nativeVisualID is given - if( VisualIDHolder.VID_UNDEFINED != nativeVisualID || !EGL.eglChooseConfig(eglDisplay, attrs, configs, configs.capacity(), numConfigs) ) { + final boolean hasEGLChosenCaps; + if( VisualIDHolder.VID_UNDEFINED == nativeVisualID ) { + if( !EGL.eglChooseConfig(eglDisplay, attrs, configs, configs.capacity(), numConfigs) ) { + if(DEBUG) { + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: false"); + } + numConfigs.put(0, 0); + hasEGLChosenCaps = false; + } else { + hasEGLChosenCaps = numConfigs.get(0)>0; + } + } else { if(DEBUG) { - System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: false"); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: Skipped due to given visualID: "+toHexString(nativeVisualID)); } - } else if (numConfigs.get(0) > 0) { - availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); + hasEGLChosenCaps = false; + } + final boolean useRecommendedIndex = hasEGLChosenCaps && !forceTransparentFlag && capsChosen.isBackgroundOpaque(); // only use recommended idx if not translucent + final boolean skipCapsChooser = null == chooser && useRecommendedIndex; // fast path: skip choosing if using recommended idx and null chooser is used + if( hasEGLChosenCaps ) { + availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag, skipCapsChooser /* onlyFirsValid */); if(availableCaps.size() > 0) { recommendedEGLConfig = configs.get(0); recommendedIndex = 0; if (DEBUG) { System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: recommended fbcfg " + toHexString(recommendedEGLConfig) + ", idx " + recommendedIndex); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser); System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 fbcfg caps " + availableCaps.get(recommendedIndex)); } } else if (DEBUG) { System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: no caps for recommended fbcfg " + toHexString(configs.get(0))); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser); } } else if (DEBUG) { System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 eglChooseConfig: no configs"); + System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #1 useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser); } // 2nd choice: get all GLCapabilities available, no preferred recommendedIndex available @@ -388,7 +406,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact throw new GLException("EGLGraphicsConfiguration.eglChooseConfig: #2 Get all configs (eglGetConfigs) call failed, error "+toHexString(EGL.eglGetError())); } if (numConfigs.get(0) > 0) { - availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag); + availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), winattrmask, forceTransparentFlag, false /* onlyFirsValid */); } } @@ -396,7 +414,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact if(DEBUG) { // FIXME: this happens on a ATI PC Emulation .. System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #2 Graphics configuration 1st choice and 2nd choice failed - no configs"); - availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag); + availableCaps = eglConfigs2GLCaps(device, glp, configs, numConfigs.get(0), GLGraphicsConfigurationUtil.ALL_BITS, forceTransparentFlag, false /* onlyFirsValid */); printCaps("AllCaps", availableCaps, System.err); } return null; @@ -409,7 +427,7 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } } - if( VisualIDHolder.VID_UNDEFINED != nativeVisualID ) { + if( VisualIDHolder.VID_UNDEFINED != nativeVisualID ) { // implies !hasEGLChosenCaps List removedCaps = new ArrayList(); for(int i=0; i chosenIndex ) { if (DEBUG) { System.err.println("EGLGraphicsConfiguration.eglChooseConfig: #2 chooseCapabilities failed"); @@ -452,12 +475,15 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact return res; } - static List eglConfigs2GLCaps(EGLGraphicsDevice device, GLProfile glp, PointerBuffer configs, int num, int winattrmask, boolean forceTransparentFlag) { + static List eglConfigs2GLCaps(EGLGraphicsDevice device, GLProfile glp, PointerBuffer configs, int num, int winattrmask, boolean forceTransparentFlag, boolean onlyFirstValid) { List bucket = new ArrayList(num); for(int i=0; i wglARBPFIDs2GLCapabilities(WindowsWGLDrawableFactory.SharedResource sharedResource, - AbstractGraphicsDevice device, GLProfile glp, long hdc, int[] pfdIDs, int winattrbits) { + AbstractGraphicsDevice device, GLProfile glp, long hdc, int[] pfdIDs, int winattrbits, boolean onlyFirstValid) { if (!sharedResource.hasARBPixelFormat()) { return null; } @@ -392,6 +392,9 @@ public class WindowsWGLGraphicsConfiguration extends MutableGraphicsConfiguratio final int j = bucket.size() - 1; System.err.println("wglARBPFIDs2GLCapabilities: bucket["+i+" -> "+j+"]: "+caps); } + if( onlyFirstValid ) { + break; + } } else if(DEBUG) { GLCapabilitiesImmutable skipped = AttribList2GLCapabilities(device, glp, hdc, pfdIDs[i], iattributes, niattribs, iresults, GLGraphicsConfigurationUtil.ALL_BITS); System.err.println("wglARBPFIDs2GLCapabilities: bucket["+i+" -> skip]: pfdID "+pfdIDs[i]+", "+skipped+", winattr "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString()); diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java index 961295208..67ead3827 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java @@ -112,7 +112,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } final AbstractGraphicsDevice absDevice = absScreen.getDevice(); capsChosen = GLGraphicsConfigurationUtil.fixGLCapabilities( capsChosen, GLDrawableFactory.getDesktopFactory(), absDevice); - return new WindowsWGLGraphicsConfiguration( absScreen, capsChosen, capsReq, (GLCapabilitiesChooser)chooser ); + return new WindowsWGLGraphicsConfiguration( absScreen, capsChosen, capsReq, chooser ); } protected static List getAvailableCapabilities(WindowsWGLDrawableFactory factory, AbstractGraphicsDevice device) { @@ -168,7 +168,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat final int pfdIDCount = WindowsWGLGraphicsConfiguration.wglARBPFDIDCount((WindowsWGLContext)sharedResource.getContext(), hdc); final int[] pformats = WindowsWGLGraphicsConfiguration.wglAllARBPFDIDs(pfdIDCount); return WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, - GLGraphicsConfigurationUtil.ALL_BITS & ~GLGraphicsConfigurationUtil.BITMAP_BIT); // w/o BITMAP + GLGraphicsConfigurationUtil.ALL_BITS & ~GLGraphicsConfigurationUtil.BITMAP_BIT, false); // w/o BITMAP } private static List getAvailableGLCapabilitiesGDI(AbstractGraphicsDevice device, GLProfile glProfile, long hdc, boolean bitmapOnly) { @@ -365,7 +365,6 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat pixelFormatCaps = (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(pixelFormatCaps, isOpaque); } else { int recommendedIndex = -1; // recommended index - if(null == pformats) { // No given PFD IDs // @@ -406,9 +405,10 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat return false; } } + final boolean skipCapsChooser = 0 <= recommendedIndex && null == chooser && capsChosen.isBackgroundOpaque(); // fast path: skip choosing if using recommended idx and null chooser is used and if not translucent - List availableCaps = - WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, winattrbits); + final List availableCaps = + WindowsWGLGraphicsConfiguration.wglARBPFIDs2GLCapabilities(sharedResource, device, glProfile, hdc, pformats, winattrbits, skipCapsChooser /* onlyFirstValid */); if( null == availableCaps || 0 == availableCaps.size() ) { if (DEBUG) { @@ -420,14 +420,19 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if (DEBUG) { System.err.println("updateGraphicsConfigurationARB: " + pformats.length + - " pfd ids, " + GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString() + ", " + availableCaps.size() + " glcaps"); + " pfd ids, skipCapsChooser " + skipCapsChooser + ", " + GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrbits).toString() + ", " + availableCaps.size() + " glcaps"); if(0 <= recommendedIndex) { System.err.println("updateGraphicsConfigurationARB: Used wglChoosePixelFormatARB to recommend pixel format " + pformats[recommendedIndex] + ", idx " + recommendedIndex +", "+availableCaps.get(recommendedIndex)); } } - int chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex); + final int chosenIndex; + if( skipCapsChooser ) { + chosenIndex = recommendedIndex; + } else { + chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex); + } if ( 0 > chosenIndex ) { if (DEBUG) { Thread.dumpStack(); @@ -438,12 +443,12 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat if( null == pixelFormatCaps) { throw new GLException("Null Capabilities with "+ " chosen pfdID: native recommended "+ (recommendedIndex+1) + - " chosen idx "+chosenIndex); + " chosen idx "+chosenIndex+", skipCapsChooser "+skipCapsChooser); } pixelFormatCaps = (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(pixelFormatCaps, isOpaque); if (DEBUG) { System.err.println("chosen pfdID (ARB): native recommended "+ (recommendedIndex+1) + - " chosen "+pixelFormatCaps); + " chosen "+pixelFormatCaps+", skipCapsChooser "+skipCapsChooser); } } @@ -457,7 +462,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat private static boolean updateGraphicsConfigurationGDI(WindowsWGLGraphicsConfiguration config, CapabilitiesChooser chooser, long hdc, boolean extHDC, int[] pformats) { - GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); + final GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); if( !capsChosen.isOnscreen() && capsChosen.isPBuffer() ) { if (DEBUG) { System.err.println("updateGraphicsConfigurationGDI: no pbuffer supported on GDI: " + capsChosen); @@ -473,7 +478,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat System.err.println("updateGraphicsConfigurationGDI: capsChosen "+capsChosen+", "+GLGraphicsConfigurationUtil.winAttributeBits2String(null, winattrmask).toString()); } - AbstractGraphicsDevice device = config.getScreen().getDevice(); + final AbstractGraphicsDevice device = config.getScreen().getDevice(); int pfdID; // chosen or preset PFD ID WGLGLCapabilities pixelFormatCaps = null; // chosen or preset PFD ID's caps boolean pixelFormatSet = false; // indicates a preset PFD ID [caps] @@ -498,43 +503,67 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat pformats = WindowsWGLGraphicsConfiguration.wglAllGDIPFIDs(hdc); } - List availableCaps = new ArrayList(); - for (int i = 0; i < pformats.length; i++) { - final WGLGLCapabilities caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pformats[i], winattrmask); - if(null != caps) { - availableCaps.add(caps); - if(DEBUG) { - final int j = availableCaps.size() - 1; - System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> "+j+"]: "+caps); - } - } else if(DEBUG) { - GLCapabilitiesImmutable skipped = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, hdc, pformats[i]); - System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> skip]: pfdID "+pformats[i]+", "+skipped); - } - } - // 1st choice: get GLCapabilities based on users GLCapabilities setting recommendedIndex as preferred choice + final List availableCaps = new ArrayList(); PIXELFORMATDESCRIPTOR pfd = WindowsWGLGraphicsConfiguration.createPixelFormatDescriptor(); pfd = WindowsWGLGraphicsConfiguration.GLCapabilities2PFD(capsChosen, pfd); pfdID = WGLUtil.ChoosePixelFormat(hdc, pfd); int recommendedIndex = -1 ; + final boolean skipCapsChooser; if( 1 <= pfdID ) { + final boolean _skipCapsChooser = null == chooser && capsChosen.isBackgroundOpaque(); // fast path: skip choosing if using recommended idx and null chooser is used and if not translucent // seek index .. in all formats _or_ in given formats! - for (recommendedIndex = availableCaps.size() - 1 ; - 0 <= recommendedIndex && pfdID != ((WGLGLCapabilities) availableCaps.get(recommendedIndex)).getPFDID(); - recommendedIndex--) - { /* nop */ } - if(DEBUG && 0 > recommendedIndex) { - final GLCapabilitiesImmutable reqPFDCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, pfd, pfdID); - final GLCapabilitiesImmutable chosenCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask); - System.err.println("Chosen PFDID "+pfdID+", but not found in available caps (use given pfdIDs "+givenPFormats+", reqPFDCaps "+reqPFDCaps+", chosenCaps: "+chosenCaps); + int i; + for (i = pformats.length - 1 ; 0 <= i && pfdID != pformats[i]; i--) { /* nop */ } + if( 0 <= i ) { + if( _skipCapsChooser ) { + final WGLGLCapabilities caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask); + availableCaps.add(caps); + recommendedIndex = 0; + skipCapsChooser = true; + } else { + recommendedIndex = i; + skipCapsChooser = false; + } + } else { + if(DEBUG) { + final GLCapabilitiesImmutable reqPFDCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, pfd, pfdID); + final GLCapabilitiesImmutable chosenCaps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdID, winattrmask); + System.err.println("Chosen PFDID "+pfdID+", but not found in available caps (use given pfdIDs "+givenPFormats+", reqPFDCaps "+reqPFDCaps+", chosenCaps: "+chosenCaps); + } + skipCapsChooser = false; } + } else { + skipCapsChooser = false; } if (DEBUG) { - System.err.println("updateGraphicsConfigurationGDI: ChoosePixelFormat(HDC " + toHexString(hdc) + ") = pfdID " + pfdID + ", idx " + recommendedIndex + " (LastError: " + GDI.GetLastError() + ")"); + System.err.println("updateGraphicsConfigurationGDI: ChoosePixelFormat(HDC " + toHexString(hdc) + ") = pfdID " + pfdID + ", skipCapsChooser "+skipCapsChooser+", idx " + recommendedIndex + " (LastError: " + GDI.GetLastError() + ")"); + } + + if( !skipCapsChooser ) { + for (int i = 0; i < pformats.length; i++) { + final int pfdid = pformats[i]; + final WGLGLCapabilities caps = WindowsWGLGraphicsConfiguration.PFD2GLCapabilities(device, glProfile, hdc, pfdid, winattrmask); + if(null != caps) { + availableCaps.add(caps); + if(DEBUG) { + final int j = availableCaps.size() - 1; + System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> "+j+"]: "+caps); + } + } else if(DEBUG) { + GLCapabilitiesImmutable skipped = WindowsWGLGraphicsConfiguration.PFD2GLCapabilitiesNoCheck(device, glProfile, hdc, pformats[i]); + System.err.println("updateGraphicsConfigurationGDI: availableCaps["+i+" -> skip]: pfdID "+pformats[i]+", "+skipped); + } + } } + // 2nd choice: if no preferred recommendedIndex available - int chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex); + final int chosenIndex; + if( skipCapsChooser ) { + chosenIndex = recommendedIndex; + } else { + chosenIndex = chooseCapabilities(chooser, capsChosen, availableCaps, recommendedIndex); + } if ( 0 > chosenIndex ) { if (DEBUG) { System.err.println("updateGraphicsConfigurationGDI: failed, return false"); @@ -544,7 +573,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat } pixelFormatCaps = (WGLGLCapabilities) availableCaps.get(chosenIndex); if (DEBUG) { - System.err.println("chosen pfdID (GDI): chosenIndex "+ chosenIndex + ", caps " + pixelFormatCaps + + System.err.println("chosen pfdID (GDI): chosenIndex "+ chosenIndex + ", skipCapsChooser "+skipCapsChooser+", caps " + pixelFormatCaps + " (" + WGLGLCapabilities.PFD2String(pixelFormatCaps.getPFD(), pixelFormatCaps.getPFDID()) +")"); } } diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java index 5c84597d5..1f92960bc 100644 --- a/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11GLXGraphicsConfigurationFactory.java @@ -306,11 +306,13 @@ public class X11GLXGraphicsConfigurationFactory extends GLGraphicsConfigurationF recommendedIndex = useRecommendedIndex ? 0 : -1; if (DEBUG) { System.err.println("glXChooseFBConfig recommended fbcfg " + toHexString(fbcfgsL.get(0)) + ", idx " + recommendedIndex); + System.err.println("useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser); System.err.println("user caps " + capsChosen); - System.err.println("fbcfg caps " + availableCaps.get(0)); + System.err.println("fbcfg caps " + fbcfgsL.limit()+", availCaps "+availableCaps.get(0)); } } else if (DEBUG) { System.err.println("glXChooseFBConfig no caps for recommended fbcfg " + toHexString(fbcfgsL.get(0))); + System.err.println("useRecommendedIndex "+useRecommendedIndex+", skipCapsChooser "+skipCapsChooser); System.err.println("user caps " + capsChosen); } } else { -- cgit v1.2.3 From 507113e471e165d151bc152989e687439312686a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 5 Nov 2013 12:58:36 +0100 Subject: Bug 888 / Bug 891- Enhance GLCapabilities-Query: Add perf. test case Even though the test case itself cannot show the proper initialization time, it can be used w/ an attached profiler i.e. Test w/ 50 X11GLXGraphicsConfigurationFactory.chooseGraphicsConfigurationFBConfig() invocations: - pre change: 1.708 ms - post change: 650 ms (613e33ee8ffc1f2b9c5db1e1b5bb5253a159ed6d) --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 8 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 7 +- .../junit/jogl/perf/TestPerfGLJPanel01AWT.java | 239 +++++++++++++++++++++ .../junit/jogl/perf/TestPerfGLJPanel02AWT.java | 239 +++++++++++++++++++++ 5 files changed, 490 insertions(+), 7 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel02AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 8de40e1f4..5aad3a54d 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -75,6 +75,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel02AWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* @@ -84,7 +87,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 63a3fa8c6..d50dd91f9 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -304,8 +304,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* @@ -333,6 +331,12 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf01AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +# +# performance tests +# +testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel02AWT $* + # # tile rendring / printing w/ & w/o AWT # diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index fdacc5bc4..1adafaf87 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -476,13 +476,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } if( isVisible() ) { - updater.setGraphics(g); - backend.doPaintComponent(g); + updater.setGraphics(g); + backend.doPaintComponent(g); } } } - /** Overridden to track when this component is added to a container. Subclasses which override this method must call super.addNotify() in their addNotify() method in order to @@ -1842,7 +1841,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public boolean preGL(Graphics g) { - GL2 gl = joglContext.getGL().getGL2(); + final GL2 gl = joglContext.getGL().getGL2(); // Set up needed state in JOGL context from Java2D context gl.glEnable(GL2.GL_SCISSOR_TEST); Rectangle r = Java2D.getOGLScissorBox(g); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java new file mode 100644 index 000000000..65b2914fb --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java @@ -0,0 +1,239 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.perf; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.common.os.Platform; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Multiple GLJPanels in a JFrame's Grid + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestPerfGLJPanel01AWT extends UITestCase { + + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(); + } + + public void test(final boolean useGears, final int width, final int height, final int rows, final int columns, + final boolean useGLJPanel, final boolean useAnim) { + final GLAnimatorControl animator = useAnim ? new Animator() : null; + + final JFrame frame; + final JPanel panel; + + panel = new JPanel(); + frame = new JFrame("DemoGLJPanelGridAWT"); + + panel.setLayout(new GridLayout(rows, columns)); + // panel.setBounds(0, 0, width, height); + final int panelCount = rows*columns; + final Dimension eSize = new Dimension(width/columns, height/rows); + final long[] t = new long[10]; + if( wait ) { + UITestCase.waitForKey("Pre-Init"); + } + System.err.println("INIT START"); + initCount = 0; + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + t[0] = Platform.currentTimeMillis(); + for(int i=0; i initCount ) { + try { + Thread.sleep(10); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + t[3] = Platform.currentTimeMillis(); + final double panelCountF = panelCount; + System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", + panelCount, + useGLJPanel?"GLJPanel":"GLCanvas", + t[1]-t[0], (t[1]-t[0])/panelCountF, + t[3]-t[1], (t[3]-t[1])/panelCountF, + t[3]-t[0], (t[3]-t[0])/panelCountF); + System.err.println("INIT END: "+initCount); + if( wait ) { + UITestCase.waitForKey("Post-Init"); + } + try { + Thread.sleep(duration); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + t[4] = Platform.currentTimeMillis(); + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.dispose(); + } } ); + } catch (Exception e1) { + e1.printStackTrace(); + } + final long ti_net = (t[4]-t[0])-duration; + System.err.printf("T: duration %d %d%n\ttotal-d\t%6d/t %6.2f/1%n\ttotal-i\t%6d/t %6.2f/1%n", + duration, t[4]-t[3], + t[4]-t[0], (t[4]-t[0])/panelCountF, + ti_net, ti_net/panelCountF); + System.err.println("Total: "+(t[4]-t[0])); + } + + private GLAutoDrawable createGLCanvas(boolean useGears, GLAnimatorControl anim, Dimension size) { + GLCanvas canvas = new GLCanvas(); + canvas.setSize(size); + canvas.setPreferredSize(size); + if( useGears ) { + canvas.addGLEventListener(new GearsES2()); + } + if( null != anim ) { + anim.add(canvas); + } + return canvas; + } + private GLAutoDrawable createGLJPanel(boolean useGears, GLAnimatorControl anim, Dimension size) { + GLJPanel canvas = new GLJPanel(); + canvas.setSize(size); + canvas.setPreferredSize(size); + if( useGears ) { + canvas.addGLEventListener(new GearsES2()); + } + if( null != anim ) { + anim.add(canvas); + } + return canvas; + } + + @Test + public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException { + final int width = 800, height = 600, rows = 5, cols = 5; + test(false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/); + } + + @Test + public void test02NopGLCanvas() throws InterruptedException, InvocationTargetException { + final int width = 800, height = 600, rows = 5, cols = 5; + test(false /*useGears*/, width, height, rows, cols, false /* useGLJPanel */, false /*useAnim*/); + } + + static long duration = 2000; // ms + static boolean wait = false; + + volatile int initCount = 0; + + public static void main(String[] args) { + int width = 800, height = 600, rows = 5, cols = 5; + boolean useGLJPanel = true, useGears = false, manual=false; + + for(int i=0; i initCount ) { + try { + Thread.sleep(10); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + t[3] = Platform.currentTimeMillis(); + final double panelCountF = frameCount; + System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", + frameCount, + useGLJPanel?"GLJPanel":"GLCanvas", + t[1]-t[0], (t[1]-t[0])/panelCountF, + t[3]-t[1], (t[3]-t[1])/panelCountF, + t[3]-t[0], (t[3]-t[0])/panelCountF); + + System.err.println("INIT END: "+initCount); + if( wait ) { + UITestCase.waitForKey("Post-Init"); + } + try { + Thread.sleep(duration); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + t[4] = Platform.currentTimeMillis(); + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + for(int i=0; i Date: Tue, 5 Nov 2013 16:52:29 +0100 Subject: Bug 888 / Bug 891- Enhance GLCapabilities-Query: Add raw perf. test case 'choose' only and 'full' offscreen-drawable w/ context test01ChooseOnly exposes X11/GLX perf. enhancement of 613e33ee8ffc1f2b9c5db1e1b5bb5253a159ed6d: PRE CHANGE: ++++ UITestCase.setUp: com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT - test01ChooseOnly INIT START #0 Run: 0, count 50/50 raw: choose 503/t 10.06/1 INIT END #0 INIT START #1 Run: 1, count 50/50 raw: choose 384/t 7.68/1 INIT END #1 INIT START #2 Run: 2, count 50/50 raw: choose 344/t 6.88/1 INIT END #2 POST CHANGE: ++++ UITestCase.setUp: com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT - test01ChooseOnly INIT START #0 Run: 0, count 50/50 raw: choose 49/t 0.98/1 INIT END #0 INIT START #1 Run: 1, count 50/50 raw: choose 43/t 0.86/1 INIT END #1 INIT START #2 Run: 2, count 50/50 raw: choose 38/t 0.76/1 INIT END #2 --- make/scripts/tests-win.bat | 5 +- make/scripts/tests.sh | 5 +- .../jogl/perf/TestPerf001GLJPanelInit01AWT.java | 239 +++++++++++++++++++++ .../jogl/perf/TestPerf001GLJPanelInit02AWT.java | 239 +++++++++++++++++++++ .../junit/jogl/perf/TestPerf001RawInit00NEWT.java | 233 ++++++++++++++++++++ .../junit/jogl/perf/TestPerfGLJPanel01AWT.java | 239 --------------------- .../junit/jogl/perf/TestPerfGLJPanel02AWT.java | 239 --------------------- 7 files changed, 717 insertions(+), 482 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001RawInit00NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel01AWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerfGLJPanel02AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 5aad3a54d..6550c45eb 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -75,8 +75,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel01AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel02AWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index d50dd91f9..69ad8c2aa 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -334,8 +334,9 @@ function testawtswt() { # # performance tests # -testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerfGLJPanel02AWT $* +testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* # # tile rendring / printing w/ & w/o AWT diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java new file mode 100644 index 000000000..d47058857 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java @@ -0,0 +1,239 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.perf; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.common.os.Platform; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +/** + * Multiple GLJPanels in a JFrame's Grid + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestPerf001GLJPanelInit01AWT extends UITestCase { + + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(); + } + + public void test(final boolean useGears, final int width, final int height, final int rows, final int columns, + final boolean useGLJPanel, final boolean useAnim) { + final GLAnimatorControl animator = useAnim ? new Animator() : null; + + final JFrame frame; + final JPanel panel; + + panel = new JPanel(); + frame = new JFrame("DemoGLJPanelGridAWT"); + + panel.setLayout(new GridLayout(rows, columns)); + // panel.setBounds(0, 0, width, height); + final int panelCount = rows*columns; + final Dimension eSize = new Dimension(width/columns, height/rows); + final long[] t = new long[10]; + if( wait ) { + UITestCase.waitForKey("Pre-Init"); + } + System.err.println("INIT START"); + initCount = 0; + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + t[0] = Platform.currentTimeMillis(); + for(int i=0; i initCount ) { + try { + Thread.sleep(10); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + t[3] = Platform.currentTimeMillis(); + final double panelCountF = panelCount; + System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", + panelCount, + useGLJPanel?"GLJPanel":"GLCanvas", + t[1]-t[0], (t[1]-t[0])/panelCountF, + t[3]-t[1], (t[3]-t[1])/panelCountF, + t[3]-t[0], (t[3]-t[0])/panelCountF); + System.err.println("INIT END: "+initCount); + if( wait ) { + UITestCase.waitForKey("Post-Init"); + } + try { + Thread.sleep(duration); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + t[4] = Platform.currentTimeMillis(); + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.dispose(); + } } ); + } catch (Exception e1) { + e1.printStackTrace(); + } + final long ti_net = (t[4]-t[0])-duration; + System.err.printf("T: duration %d %d%n\ttotal-d\t%6d/t %6.2f/1%n\ttotal-i\t%6d/t %6.2f/1%n", + duration, t[4]-t[3], + t[4]-t[0], (t[4]-t[0])/panelCountF, + ti_net, ti_net/panelCountF); + System.err.println("Total: "+(t[4]-t[0])); + } + + private GLAutoDrawable createGLCanvas(boolean useGears, GLAnimatorControl anim, Dimension size) { + GLCanvas canvas = new GLCanvas(); + canvas.setSize(size); + canvas.setPreferredSize(size); + if( useGears ) { + canvas.addGLEventListener(new GearsES2()); + } + if( null != anim ) { + anim.add(canvas); + } + return canvas; + } + private GLAutoDrawable createGLJPanel(boolean useGears, GLAnimatorControl anim, Dimension size) { + GLJPanel canvas = new GLJPanel(); + canvas.setSize(size); + canvas.setPreferredSize(size); + if( useGears ) { + canvas.addGLEventListener(new GearsES2()); + } + if( null != anim ) { + anim.add(canvas); + } + return canvas; + } + + @Test + public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException { + final int width = 800, height = 600, rows = 5, cols = 5; + test(false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/); + } + + @Test + public void test02NopGLCanvas() throws InterruptedException, InvocationTargetException { + final int width = 800, height = 600, rows = 5, cols = 5; + test(false /*useGears*/, width, height, rows, cols, false /* useGLJPanel */, false /*useAnim*/); + } + + static long duration = 2000; // ms + static boolean wait = false; + + volatile int initCount = 0; + + public static void main(String[] args) { + int width = 800, height = 600, rows = 5, cols = 5; + boolean useGLJPanel = true, useGears = false, manual=false; + + for(int i=0; i initCount ) { + try { + Thread.sleep(10); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + t[3] = Platform.currentTimeMillis(); + final double panelCountF = frameCount; + System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", + frameCount, + useGLJPanel?"GLJPanel":"GLCanvas", + t[1]-t[0], (t[1]-t[0])/panelCountF, + t[3]-t[1], (t[3]-t[1])/panelCountF, + t[3]-t[0], (t[3]-t[0])/panelCountF); + + System.err.println("INIT END: "+initCount); + if( wait ) { + UITestCase.waitForKey("Post-Init"); + } + try { + Thread.sleep(duration); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + t[4] = Platform.currentTimeMillis(); + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + for(int i=0; i= context.makeCurrent() ) { + // oops + glDrawables[i].setRealized(false); + glDrawables[i] = null; + glConti[i] = null; + continue; + } + glConti[i] = context; + context.release(); + } + t[3] = Platform.currentTimeMillis(); + // 2nd makeCurrent and release + for(int i=0; i= context.makeCurrent() ) { + // oops + glDrawables[i].setRealized(false); + glDrawables[i] = null; + glConti[i] = null; + continue; + } + context.release(); + } + t[4] = Platform.currentTimeMillis(); + + final double countF = count; + System.err.printf("Run: %d, count %d raw:%n\tglad-create\t%6d/t %6.2f/1%n"+ + "\tglad-realize\t%6d/t %6.2f/1%n"+ + "\tctx-create1\t%6d/t %6.2f/1%n"+ + "\tctx-curren2\t%6d/t %6.2f/1%n"+ + "\tglad-ctx-init\t%6d/t %6.2f/1%n", + runNum, count, + t[1]-t[0], (t[1]-t[0])/countF, // create + t[2]-t[1], (t[2]-t[1])/countF, // realize + t[3]-t[2], (t[3]-t[2])/countF, // context-create1 + t[4]-t[3], (t[4]-t[3])/countF, // context-curren2 + t[3]-t[0], (t[3]-t[0])/countF);// init total + System.err.println("INIT END #"+runNum); + if( wait && 2 == runNum ) { + UITestCase.waitForKey("Post-Init"); + } + + // destroy + for(int i=0; i initCount ) { - try { - Thread.sleep(10); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - } - t[3] = Platform.currentTimeMillis(); - final double panelCountF = panelCount; - System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", - panelCount, - useGLJPanel?"GLJPanel":"GLCanvas", - t[1]-t[0], (t[1]-t[0])/panelCountF, - t[3]-t[1], (t[3]-t[1])/panelCountF, - t[3]-t[0], (t[3]-t[0])/panelCountF); - System.err.println("INIT END: "+initCount); - if( wait ) { - UITestCase.waitForKey("Post-Init"); - } - try { - Thread.sleep(duration); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - t[4] = Platform.currentTimeMillis(); - try { - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.dispose(); - } } ); - } catch (Exception e1) { - e1.printStackTrace(); - } - final long ti_net = (t[4]-t[0])-duration; - System.err.printf("T: duration %d %d%n\ttotal-d\t%6d/t %6.2f/1%n\ttotal-i\t%6d/t %6.2f/1%n", - duration, t[4]-t[3], - t[4]-t[0], (t[4]-t[0])/panelCountF, - ti_net, ti_net/panelCountF); - System.err.println("Total: "+(t[4]-t[0])); - } - - private GLAutoDrawable createGLCanvas(boolean useGears, GLAnimatorControl anim, Dimension size) { - GLCanvas canvas = new GLCanvas(); - canvas.setSize(size); - canvas.setPreferredSize(size); - if( useGears ) { - canvas.addGLEventListener(new GearsES2()); - } - if( null != anim ) { - anim.add(canvas); - } - return canvas; - } - private GLAutoDrawable createGLJPanel(boolean useGears, GLAnimatorControl anim, Dimension size) { - GLJPanel canvas = new GLJPanel(); - canvas.setSize(size); - canvas.setPreferredSize(size); - if( useGears ) { - canvas.addGLEventListener(new GearsES2()); - } - if( null != anim ) { - anim.add(canvas); - } - return canvas; - } - - @Test - public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException { - final int width = 800, height = 600, rows = 5, cols = 5; - test(false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/); - } - - @Test - public void test02NopGLCanvas() throws InterruptedException, InvocationTargetException { - final int width = 800, height = 600, rows = 5, cols = 5; - test(false /*useGears*/, width, height, rows, cols, false /* useGLJPanel */, false /*useAnim*/); - } - - static long duration = 2000; // ms - static boolean wait = false; - - volatile int initCount = 0; - - public static void main(String[] args) { - int width = 800, height = 600, rows = 5, cols = 5; - boolean useGLJPanel = true, useGears = false, manual=false; - - for(int i=0; i initCount ) { - try { - Thread.sleep(10); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - } - t[3] = Platform.currentTimeMillis(); - final double panelCountF = frameCount; - System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", - frameCount, - useGLJPanel?"GLJPanel":"GLCanvas", - t[1]-t[0], (t[1]-t[0])/panelCountF, - t[3]-t[1], (t[3]-t[1])/panelCountF, - t[3]-t[0], (t[3]-t[0])/panelCountF); - - System.err.println("INIT END: "+initCount); - if( wait ) { - UITestCase.waitForKey("Post-Init"); - } - try { - Thread.sleep(duration); - } catch (InterruptedException e1) { - e1.printStackTrace(); - } - t[4] = Platform.currentTimeMillis(); - try { - SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - for(int i=0; i Date: Tue, 5 Nov 2013 18:47:56 +0100 Subject: Bug 888 / Bug 891- Enhance GLCapabilities-Query: Refine unit tests --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- .../junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java | 13 +++++++++---- .../junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java | 13 +++++++++---- .../test/junit/jogl/perf/TestPerf001RawInit00NEWT.java | 15 ++++++++------- 5 files changed, 30 insertions(+), 19 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 6550c45eb..7e40967c2 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -75,9 +75,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 69ad8c2aa..f2231a0de 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -334,9 +334,9 @@ function testawtswt() { # # performance tests # -testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* # # tile rendring / printing w/ & w/o AWT diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java index d47058857..24bd1b748 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java @@ -185,24 +185,23 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase { @Test public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException { - final int width = 800, height = 600, rows = 5, cols = 5; test(false /*useGears*/, width, height, rows, cols, true /* useGLJPanel */, false /*useAnim*/); } @Test public void test02NopGLCanvas() throws InterruptedException, InvocationTargetException { - final int width = 800, height = 600, rows = 5, cols = 5; test(false /*useGears*/, width, height, rows, cols, false /* useGLJPanel */, false /*useAnim*/); } - static long duration = 2000; // ms + static long duration = 0; // ms static boolean wait = false; + static int width = 800, height = 600, rows = 5, cols = 5; volatile int initCount = 0; public static void main(String[] args) { - int width = 800, height = 600, rows = 5, cols = 5; boolean useGLJPanel = true, useGears = false, manual=false; + boolean waitMain = false; for(int i=0; i Date: Wed, 6 Nov 2013 15:34:09 +0100 Subject: Bug 894 - GLJPanel: Expose 'initializeBackend(boolean offthread)' allowing user to trigger backend initialization eagerly and offthread (optional, !WINDOWS) TestPerf001GLJPanelInit02AWT compares all variations: no-gl, glcanvas, gljpanel and gljpanel-initMT (offthread) --- make/scripts/tests-win.bat | 1 + make/scripts/tests-x64-dbg.bat | 4 +- make/scripts/tests.sh | 2 + .../classes/javax/media/opengl/awt/GLJPanel.java | 118 +++++++++--- .../jogl/perf/TestPerf001GLJPanelInit01AWT.java | 33 ++-- .../jogl/perf/TestPerf001GLJPanelInit02AWT.java | 148 ++++++++++++--- .../jogl/perf/TestPerf001GLWindowInit03NEWT.java | 203 +++++++++++++++++++++ 7 files changed, 436 insertions(+), 73 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLWindowInit03NEWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 7e40967c2..94bc49c38 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -78,6 +78,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 726be54ba..a42c79254 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -24,7 +24,7 @@ REM set D_ARGS="-Djogamp.debug=all" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" +set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" @@ -53,7 +53,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.Til REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" -set D_ARGS="-Dnewt.debug.Window.MouseEvent" +REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" REM set D_ARGS="-Djogl.debug.GLDebugMessageHandler" "-Djogl.debug.DebugGL" "-Djogl.debug.TraceGL" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f2231a0de..53e4e22cd 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -176,6 +176,7 @@ function jrun() { #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnativewindow.debug.X11Util" + #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Dnativewindow.debug.X11Util" #D_ARGS="-Dnewt.debug.EDT -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator -Dnewt.debug.Display -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Window -Djogamp.common.utils.locks.Lock.timeout=600000" #D_ARGS="-Dnewt.debug=all -Djogamp.common.utils.locks.Lock.timeout=600000" @@ -337,6 +338,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # # tile rendring / printing w/ & w/o AWT diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 1adafaf87..2c805fa00 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -58,6 +58,7 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GL; @@ -338,6 +339,51 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.setFocusable(true); // allow keyboard input! } + /** + * Attempts to initialize the backend, if not initialized yet. + *

      + * If backend is already initialized method returns true. + *

      + *

      + * If offthread is true, initialization will kicked off + * on a short lived arbitrary thread and method returns immediately.
      + * If platform supports such arbitrary thread initialization method returns + * true, otherwise false. + *

      + *

      + * Due to threading restrictions, arbitrary thread initialization is not supported on: + *

        + *
      • {@link NativeWindowFactory.TYPE_WINDOWS}
      • + *
      + *

      + *

      + * If offthread is false, initialization be performed + * on the current thread and method returns after initialization.
      + * Method returns true if initialization was successful, otherwise false. + *

      + * @param offthread + */ + public final boolean initializeBackend(boolean offthread) { + if( offthread ) { + if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(true) ) { + return false; + } + new Thread(getThreadName()+"-GLJPanel_Init") { + public void run() { + if( !isInitialized ) { + initializeBackendImpl(); + } + } }.start(); + return true; + } else { + if( !isInitialized ) { + return initializeBackendImpl(); + } else { + return true; + } + } + } + @Override public final void setSharedContext(GLContext sharedContext) throws IllegalStateException { helper.setSharedContext(this.getContext(), sharedContext); @@ -457,8 +503,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return; } - if (backend == null || !isInitialized) { - createAndInitializeBackend(); + if( !isInitialized ) { + initializeBackendImpl(); } if (!isInitialized || printActive) { @@ -552,8 +598,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private final Runnable setupPrintOnEDT = new Runnable() { @Override public void run() { - if (backend == null || !isInitialized) { - createAndInitializeBackend(); + if( !isInitialized ) { + initializeBackendImpl(); } if (!isInitialized) { if(DEBUG) { @@ -1020,35 +1066,47 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // Internals only below this point // - private void createAndInitializeBackend() { - if ( 0 >= panelWidth || 0 >= panelHeight ) { - // See whether we have a non-zero size yet and can go ahead with - // initialization - if (0 >= reshapeWidth || 0 >= reshapeHeight ) { - return; - } + private final Object initSync = new Object(); + private boolean initializeBackendImpl() { + if( !isInitialized ) { + synchronized(initSync) { + if( !isInitialized ) { + if ( 0 >= panelWidth || 0 >= panelHeight ) { + // See whether we have a non-zero size yet and can go ahead with + // initialization + if (0 >= reshapeWidth || 0 >= reshapeHeight ) { + return false; + } - if (DEBUG) { - System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend: " +panelWidth+"x"+panelHeight + " -> " + reshapeWidth+"x"+reshapeHeight); - } - // Pull down reshapeWidth and reshapeHeight into panelWidth and - // panelHeight eagerly in order to complete initialization, and - // force a reshape later - panelWidth = reshapeWidth; - panelHeight = reshapeHeight; - } + if (DEBUG) { + System.err.println(getThreadName()+": GLJPanel.createAndInitializeBackend: " +panelWidth+"x"+panelHeight + " -> " + reshapeWidth+"x"+reshapeHeight); + } + // Pull down reshapeWidth and reshapeHeight into panelWidth and + // panelHeight eagerly in order to complete initialization, and + // force a reshape later + panelWidth = reshapeWidth; + panelHeight = reshapeHeight; + } - if ( null == backend ) { - if ( oglPipelineUsable() ) { - backend = new J2DOGLBackend(); - } else { - backend = new OffscreenBackend(glProfile, customPixelBufferProvider); - } - isInitialized = false; - } + if ( null == backend ) { + if ( oglPipelineUsable() ) { + backend = new J2DOGLBackend(); + } else { + backend = new OffscreenBackend(glProfile, customPixelBufferProvider); + } + isInitialized = false; + } - if (!isInitialized) { - backend.initialize(); + if (!isInitialized) { + backend.initialize(); + } + return isInitialized; + } else { + return true; + } + } + } else { + return true; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java index 24bd1b748..0472fdb31 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java @@ -34,6 +34,8 @@ import java.lang.reflect.InvocationTargetException; import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; @@ -65,8 +67,8 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase { GLProfile.initSingleton(); } - public void test(final boolean useGears, final int width, final int height, final int rows, final int columns, - final boolean useGLJPanel, final boolean useAnim) { + public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height, final int rows, + final int columns, final boolean useGLJPanel, final boolean useAnim) { final GLAnimatorControl animator = useAnim ? new Animator() : null; final JFrame frame; @@ -90,7 +92,7 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase { public void run() { t[0] = Platform.currentTimeMillis(); for(int i=0; i=width) { + x=32; + y+=eHeight+32; + } + } final JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); // panel.setBounds(0, 0, width, height); - final Dimension eSize = new Dimension(width, height); - final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(useGears, animator, eSize) : createGLCanvas(useGears, animator, eSize); - glad.addGLEventListener(new GLEventListener() { - @Override - public void init(GLAutoDrawable drawable) { - initCount++; - } - @Override - public void dispose(GLAutoDrawable drawable) {} - @Override - public void display(GLAutoDrawable drawable) {} - @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} - }); - panel.add((Component)glad); + final Dimension eSize = new Dimension(eWidth, eHeight); + final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(initMT, caps, useGears, animator, eSize) : ( useGLCanvas ? createGLCanvas(caps, useGears, animator, eSize) : null ); + if( null != glad ) { + glad.addGLEventListener(new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + initCount++; + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) {} + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }); + panel.add((Component)glad); + } else { + @SuppressWarnings("serial") + final JTextArea c = new JTextArea("area "+i) { + boolean initialized = false, added = false; + int reshapeWidth=0, reshapeHeight=0; + @Override + public void addNotify() { + added = true; + super.addNotify(); + } + @SuppressWarnings("deprecation") + @Override + public void reshape(int x, int y, int width, int height) { + super.reshape(x, y, width, height); + reshapeWidth = width; reshapeHeight = height; + } + @Override + protected void paintComponent(final Graphics g) { + super.paintComponent(g); + if( !initialized && added && reshapeWidth > 0 && reshapeHeight > 0 && isDisplayable() ) { + initialized = true; + initCount++; + } + } + }; + c.setEditable(false); + c.setSize(eSize); + c.setPreferredSize(eSize); + panel.add(c); + } frame[i].getContentPane().add(panel); // frame.validate(); @@ -124,9 +172,9 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { } t[3] = Platform.currentTimeMillis(); final double panelCountF = frameCount; - System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", + System.err.printf("P: %d %s%s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", frameCount, - useGLJPanel?"GLJPanel":"GLCanvas", + useGLJPanel?"GLJPanel":(useGLCanvas?"GLCanvas":"No_GL"), initMT?" (mt)":" (01)", t[1]-t[0], (t[1]-t[0])/panelCountF, t[3]-t[1], (t[3]-t[1])/panelCountF, t[3]-t[0], (t[3]-t[0])/panelCountF); @@ -160,8 +208,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { System.err.println("Total: "+(t[4]-t[0])); } - private GLAutoDrawable createGLCanvas(boolean useGears, GLAnimatorControl anim, Dimension size) { - GLCanvas canvas = new GLCanvas(); + private GLAutoDrawable createGLCanvas(GLCapabilitiesImmutable caps, boolean useGears, GLAnimatorControl anim, Dimension size) { + GLCanvas canvas = new GLCanvas(caps); canvas.setSize(size); canvas.setPreferredSize(size); if( useGears ) { @@ -172,8 +220,8 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { } return canvas; } - private GLAutoDrawable createGLJPanel(boolean useGears, GLAnimatorControl anim, Dimension size) { - GLJPanel canvas = new GLJPanel(); + private GLAutoDrawable createGLJPanel(boolean initMT, GLCapabilitiesImmutable caps, boolean useGears, GLAnimatorControl anim, Dimension size) { + GLJPanel canvas = new GLJPanel(caps); canvas.setSize(size); canvas.setPreferredSize(size); if( useGears ) { @@ -182,17 +230,50 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { if( null != anim ) { anim.add(canvas); } + if( initMT ) { + canvas.initializeBackend(true /* offthread */); + } return canvas; } + static GLCapabilitiesImmutable caps = null; + + @Test + public void test00NopNoGLDefGrid() throws InterruptedException, InvocationTargetException { + test(null, false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, + false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + } + + @Test + public void test01NopGLCanvasDefGrid() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, + true /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + } + @Test - public void test01NopGLJPanel() throws InterruptedException, InvocationTargetException { - test(false /*useGears*/, width, height, frameCount , true /* useGLJPanel */, false /*useAnim*/); + public void test02NopGLJPanelDefGridSingle() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, + false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); } @Test - public void test02NopGLCanvas() throws InterruptedException, InvocationTargetException { - test(false /*useGears*/, width, height, frameCount , false /* useGLJPanel */, false /*useAnim*/); + public void test03NopGLJPanelDefGridMT() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, true /* initMT */, true /* useGLJPanel */, + false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + } + + // @Test + public void test04NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, + false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + } + + // @Test + public void test05NopGLJPanelBitmapGridSingle() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(null); + caps.setBitmap(true); + test(caps, false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, + false /* useGLCanvas */, false /*useAnim*/, false); } static long duration = 0; // ms @@ -202,7 +283,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { volatile int initCount = 0; public static void main(String[] args) { - boolean useGLJPanel = true, useGears = false, manual=false; + boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useGears = false, manual=false; boolean waitMain = false; for(int i=0; i=width) { + x=32; + y+=eHeight+32; + } + frame[i].setSize(eWidth, eHeight); + if( useGears ) { + frame[i].addGLEventListener(new GearsES2()); + } + frame[i].addGLEventListener(new GLEventListener() { + @Override + public void init(GLAutoDrawable drawable) { + initCount++; + } + @Override + public void dispose(GLAutoDrawable drawable) {} + @Override + public void display(GLAutoDrawable drawable) {} + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {} + }); + } + t[1] = Platform.currentTimeMillis(); + for(int i=0; i initCount ) { + try { + Thread.sleep(10); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + } + t[3] = Platform.currentTimeMillis(); + final double panelCountF = frameCount; + System.err.printf("P: %d GLWindow:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", + frameCount, + t[1]-t[0], (t[1]-t[0])/panelCountF, + t[3]-t[1], (t[3]-t[1])/panelCountF, + t[3]-t[0], (t[3]-t[0])/panelCountF); + + System.err.println("INIT END: "+initCount); + if( wait ) { + UITestCase.waitForKey("Post-Init"); + } + try { + Thread.sleep(duration); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + t[4] = Platform.currentTimeMillis(); + for(int i=0; i Date: Thu, 7 Nov 2013 08:36:46 +0100 Subject: Bug 890 - Fix GLES3 Profile Mapping, i.e. GL2ES2 queries and mappings; Validate isGLES*() usage and definition ; Add and use ShaderCode.createExtensionDirective(..) - Fix GLES3 Profile Mapping, i.e. GL2ES2 queries and mappings - GLProfile: Add GL2ES2 -> ES3 mapping - EGLContext: Reuqest major '3' for ES3 - EGLGLCapabilities/EGLGraphicsConfiguration: Consider EGLExt.EGL_OPENGL_ES3_BIT_KHR - Validate isGLES*() usage and definition - Fix BuildComposablePipeline's isGLES() code - For GLSL related queries use isGLES() instead of isGLES2(), which would exclude ES3 - Add and use ShaderCode.createExtensionDirective(..) - Supporting creating GLSL extension directives while reusing strings from GLExtensions - Minor cleanup of GLContextImpl.setGLFuncAvail(..) --- make/scripts/tests.sh | 4 +- .../gluegen/opengl/BuildComposablePipeline.java | 2 +- .../com/jogamp/graph/curve/opengl/Renderer.java | 2 +- .../classes/com/jogamp/opengl/GLExtensions.java | 1 + .../com/jogamp/opengl/util/glsl/ShaderCode.java | 28 +++++++++++-- .../opengl/util/texture/TextureSequence.java | 1 - src/jogl/classes/javax/media/opengl/GLBase.java | 2 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 49 ++++++++++++---------- .../graph/curve/opengl/RegionRendererImpl01.java | 5 ++- .../graph/curve/opengl/TextRendererImpl01.java | 5 ++- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 34 ++++++++------- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 21 ++++++---- .../classes/jogamp/opengl/egl/EGLDrawable.java | 4 +- .../jogamp/opengl/egl/EGLDrawableFactory.java | 9 +--- .../jogamp/opengl/egl/EGLGLCapabilities.java | 7 +++- .../opengl/egl/EGLGraphicsConfiguration.java | 2 + .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 4 +- .../jogl/demos/es2/TextureSequenceCubeES2.java | 5 ++- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 5 ++- 19 files changed, 117 insertions(+), 73 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 53e4e22cd..029866d4e 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -308,7 +308,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -337,7 +337,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index b7a9c270e..df60d2f73 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -667,7 +667,7 @@ public class BuildComposablePipeline { if( 0 != (GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS & getMode() ) ) { output.println(" @Override"); output.println(" public final boolean isGLES() {"); - output.println(" return isGLES2() || isGLES1();"); + output.println(" return isGLES3() || isGLES2() || isGLES1();"); output.println(" }"); } else { emitGLIsMethod(output, "GLES"); diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java index c642fb652..8783906c2 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java @@ -279,7 +279,7 @@ public abstract class Renderer { public static final String es2_precision_fp = "\nprecision mediump float;\nprecision mediump int;\nprecision mediump sampler2D;\n"; protected String getFragmentShaderPrecision(GL2ES2 gl) { - if( gl.isGLES2() ) { + if( gl.isGLES() ) { return es2_precision_fp; } if( ShaderCode.requiresGL3DefaultPrecision(gl) ) { diff --git a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java index c7aadcd14..da9e08a32 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLExtensions.java +++ b/src/jogl/classes/com/jogamp/opengl/GLExtensions.java @@ -72,6 +72,7 @@ public class GLExtensions { public static final String OES_read_format = "GL_OES_read_format"; public static final String OES_single_precision = "GL_OES_single_precision"; public static final String OES_EGL_image_external = "GL_OES_EGL_image_external"; + public static final String OES_standard_derivatives = "GL_OES_standard_derivatives"; public static final String ARB_gpu_shader_fp64 = "GL_ARB_gpu_shader_fp64"; public static final String ARB_shader_objects = "GL_ARB_shader_objects"; diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java index 206aa0fd7..6a64edeb5 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java @@ -843,8 +843,28 @@ public class ShaderCode { /** Default precision of GLSL ≥ 1.30 as required until < 1.50 for {@link GL2ES2#GL_FRAGMENT_SHADER fragment-shader}: {@value #gl3_default_precision_fp}. See GLSL Spec 1.30-1.50 Section 4.5.3. */ public static final String gl3_default_precision_fp = "\nprecision highp float;\nprecision mediump int;\n/*precision mediump sampler2D;*/\n"; - /** Prefer enable over require, since it won't force a failure. */ - public static final String extOESDerivativesEnable = "#extension GL_OES_standard_derivatives : enable\n"; + /** Behavior for GLSL extension directive, see {@link #createExtensionDirective(String, String)}, value {@value}. */ + public static final String REQUIRE = "require"; + /** Behavior for GLSL extension directive, see {@link #createExtensionDirective(String, String)}, value {@value}. */ + public static final String ENABLE = "enable"; + /** Behavior for GLSL extension directive, see {@link #createExtensionDirective(String, String)}, value {@value}. */ + public static final String DISABLE = "disable"; + /** Behavior for GLSL extension directive, see {@link #createExtensionDirective(String, String)}, value {@value}. */ + public static final String WARN = "warn"; + + /** + * Creates a GLSL extension directive. + *

      + * Prefer {@link #ENABLE} over {@link #REQUIRE}, since the latter will force a failure if not supported. + *

      + * + * @param extensionName + * @param behavior shall be either {@link #REQUIRE}, {@link #ENABLE}, {@link #DISABLE} or {@link #WARN} + * @return the complete extension directive + */ + public static String createExtensionDirective(String extensionName, String behavior) { + return "#extension " + extensionName + " : " + behavior; + } /** * Add GLSL version at the head of this shader source code. @@ -915,7 +935,7 @@ public class ShaderCode { /** Returns true, if GLSL version requires default precision, i.e. ES2 or GLSL [1.30 .. 1.50[. */ public static final boolean requiresDefaultPrecision(GL2ES2 gl) { - if( gl.isGLES2() || gl.isGLES3() ) { + if( gl.isGLES() ) { return true; } return requiresGL3DefaultPrecision(gl); @@ -979,7 +999,7 @@ public class ShaderCode { } else { pos = 0; } - if( gl.isGLES2() && null != esDefaultPrecision ) { + if( gl.isGLES() && null != esDefaultPrecision ) { pos = insertShaderSource(0, pos, esDefaultPrecision); } else { pos = addDefaultShaderPrecision(gl, pos); diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index c34e019c2..6f1dd4c64 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -105,7 +105,6 @@ import com.jogamp.opengl.util.TimeFrameI; * */ public interface TextureSequence { - public static final String GL_OES_EGL_image_external_Required_Prelude = "#extension GL_OES_EGL_image_external : enable\n"; public static final String samplerExternalOES = "samplerExternalOES"; public static final String sampler2D = "sampler2D"; diff --git a/src/jogl/classes/javax/media/opengl/GLBase.java b/src/jogl/classes/javax/media/opengl/GLBase.java index e84dd7be9..a19a99196 100644 --- a/src/jogl/classes/javax/media/opengl/GLBase.java +++ b/src/jogl/classes/javax/media/opengl/GLBase.java @@ -150,7 +150,7 @@ public interface GLBase { /** * Indicates whether this GL object conforms to one of the OpenGL ES profiles, - * see {@link #isGLES1()} and {@link #isGLES2()}. + * see {@link #isGLES1()}, {@link #isGLES2()} and {@link #isGLES3()}. * @see GLContext#isGLES() */ public boolean isGLES(); diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index c04971176..64c8a6243 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -278,7 +278,7 @@ public class GLProfile { if(useIndent) { doIndent(sb, indent, indentCount).append("Natives"); indentCount++; - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4bc).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4bc+" ").append(indent); } else { sb.append("Natives["+GL4bc+" "); } @@ -291,7 +291,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4+" ").append(indent); } else { sb.append(", "+GL4+" "); } @@ -304,7 +304,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES3).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES3+" ").append(indent); } else { sb.append(", "+GLES3+" "); } @@ -317,7 +317,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3bc).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3bc+" ").append(indent); } else { sb.append(", "+GL3bc+" "); } @@ -330,7 +330,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL3+" ").append(indent); } else { sb.append(", "+GL3+" "); } @@ -343,7 +343,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2+" ").append(indent); } else { sb.append(", "+GL2+" "); } @@ -356,7 +356,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES2).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES2+" ").append(indent); } else { sb.append(", "+GLES2+" "); } @@ -369,7 +369,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES1).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GLES1+" ").append(indent); } else { sb.append(", "+GLES1+" "); } @@ -391,7 +391,7 @@ public class GLProfile { } if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4ES3).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL4ES3+" ").append(indent); } else { sb.append(", "+GL4ES3+" "); } @@ -399,7 +399,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2GL3).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2GL3+" ").append(indent); } else { sb.append(", "+GL2GL3+" "); } @@ -407,7 +407,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES2).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES2+" ").append(indent); } else { sb.append(", "+GL2ES2+" "); } @@ -415,7 +415,7 @@ public class GLProfile { allCount++; if(useIndent) { - doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES1).append(indent); + doIndent(sb.append(Platform.getNewline()), indent, indentCount).append(GL2ES1+" ").append(indent); } else { sb.append(", "+GL2ES1+" "); } @@ -438,7 +438,7 @@ public class GLProfile { if(useIndent) { doIndent(sb.append(Platform.getNewline()), indent, indentCount); } - sb.append(entry.getKey()+(useIndent?"\t":" ")+entry.getValue()); + sb.append(entry.getKey()+(useIndent?" \t":" ")+entry.getValue()); if(!useIndent) { sb.append(", "); } @@ -1208,17 +1208,17 @@ public class GLProfile { /** Indicates whether this profile uses the native OpenGL ES2 implementations. */ public final boolean usesNativeGLES2() { - return GLES3 == getImplName() || GLES2 == getImplName(); + return GLES2 == getImplName(); } - /** Indicates whether this profile uses the native OpenGL ES2 implementations. */ + /** Indicates whether this profile uses the native OpenGL ES3 implementations. */ public final boolean usesNativeGLES3() { return GLES3 == getImplName(); } /** Indicates whether this profile uses either of the native OpenGL ES implementations. */ public final boolean usesNativeGLES() { - return usesNativeGLES2() || usesNativeGLES1(); + return usesNativeGLES3() || usesNativeGLES2() || usesNativeGLES1(); } /** @@ -1945,33 +1945,40 @@ public class GLProfile { final boolean es2HardwareRasterizer[] = new boolean[1]; final boolean gles2Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES2Available(device, es2HardwareRasterizer) ); final boolean gles2HWAvailable = gles2Available && es2HardwareRasterizer[0] ; + final boolean es3HardwareRasterizer[] = new boolean[1]; + final boolean gles3Available = hasGLES3Impl && ( esCtxUndef || GLContext.isGLES3Available(device, es3HardwareRasterizer) ); + final boolean gles3HWAvailable = gles3Available && es3HardwareRasterizer[0] ; if(hasGL234Impl) { if(GLContext.isGL4Available(device, isHardwareRasterizer)) { - if(!gles2HWAvailable || isHardwareRasterizer[0]) { + if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) { return GL4; } } if(GLContext.isGL4bcAvailable(device, isHardwareRasterizer)) { - if(!gles2HWAvailable || isHardwareRasterizer[0]) { + if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) { return GL4bc; } } if(GLContext.isGL3Available(device, isHardwareRasterizer)) { - if(!gles2HWAvailable || isHardwareRasterizer[0]) { + if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) { return GL3; } } if(GLContext.isGL3bcAvailable(device, isHardwareRasterizer)) { - if(!gles2HWAvailable || isHardwareRasterizer[0]) { + if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) { return GL3bc; } } if(desktopCtxUndef || GLContext.isGL2Available(device, isHardwareRasterizer)) { - if(!gles2HWAvailable || isHardwareRasterizer[0]) { + if( (!gles3HWAvailable && !gles2HWAvailable ) || isHardwareRasterizer[0] ) { return GL2; } } } + if(gles3Available && ( !gles2HWAvailable || gles3HWAvailable ) ) { + isHardwareRasterizer[0] = es3HardwareRasterizer[0]; + return GLES3; + } if(gles2Available) { isHardwareRasterizer[0] = es2HardwareRasterizer[0]; return GLES2; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java index 012b1d1dd..31ad974d0 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RegionRendererImpl01.java @@ -36,6 +36,7 @@ import com.jogamp.graph.curve.Region; import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; @@ -57,8 +58,8 @@ public class RegionRendererImpl01 extends RegionRenderer { rsVp.defaultShaderCustomization(gl, true, true); // rsFp.defaultShaderCustomization(gl, true, true); int pos = rsFp.addGLSLVersion(gl); - if( gl.isGLES2() ) { - pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); + if( gl.isGLES() ) { + pos = rsFp.insertShaderSource(0, pos, ShaderCode.createExtensionDirective(GLExtensions.OES_standard_derivatives, ShaderCode.ENABLE)); } final String rsFpDefPrecision = getFragmentShaderPrecision(gl); if( null != rsFpDefPrecision ) { diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java index 60758b90b..4ec4d1d98 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/TextRendererImpl01.java @@ -36,6 +36,7 @@ import jogamp.graph.curve.text.GlyphString; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.curve.opengl.TextRenderer; import com.jogamp.graph.font.Font; +import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.glsl.ShaderProgram; import com.jogamp.opengl.util.glsl.ShaderState; @@ -56,8 +57,8 @@ public class TextRendererImpl01 extends TextRenderer { rsVp.defaultShaderCustomization(gl, true, true); // rsFp.defaultShaderCustomization(gl, true, true); int pos = rsFp.addGLSLVersion(gl); - if( gl.isGLES2() ) { - pos = rsFp.insertShaderSource(0, pos, ShaderCode.extOESDerivativesEnable); + if( gl.isGLES() ) { + pos = rsFp.insertShaderSource(0, pos, ShaderCode.createExtensionDirective(GLExtensions.OES_standard_derivatives, ShaderCode.ENABLE)); } final String rsFpDefPrecision = getFragmentShaderPrecision(gl); if( null != rsFpDefPrecision ) { diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index d43da2c3e..42c877ad5 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1305,11 +1305,8 @@ public abstract class GLContextImpl extends GLContext { *

      * If the GL query fails, major will be zero. *

      - *

      - * Note: Non ARB ctx is limited to GL 3.0. - *

      */ - private final boolean getGLIntVersion(int[] glIntMajor, int[] glIntMinor, int ctp) { + private final boolean getGLIntVersion(int[] glIntMajor, int[] glIntMinor) { glIntMajor[0] = 0; // clear final GLDynamicLookupHelper glDynLookupHelper = getDrawableImpl().getGLDynamicLookupHelper(); final long _glGetIntegerv = glDynLookupHelper.dynamicLookupFunction("glGetIntegerv"); @@ -1408,14 +1405,15 @@ public abstract class GLContextImpl extends GLContext { if (DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Pre version verification - expected "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+", strictMatch "+strictMatch+", glVersionsMapping " +withinGLVersionsMapping); } - boolean versionValidated = false; - boolean versionGL3IntFailed = false; + + final boolean versionGL3IntOK; { - // Validate the requested version w/ the GL-version from an integer query. + // Validate the requested version w/ the GL-version from an integer query, + // as supported by GL [ES] >= 3.0 implementation. final VersionNumber hasGLVersionByInt; { final int[] glIntMajor = new int[] { 0 }, glIntMinor = new int[] { 0 }; - final boolean getGLIntVersionOK = getGLIntVersion(glIntMajor, glIntMinor, ctxProfileBits); + final boolean getGLIntVersionOK = getGLIntVersion(glIntMajor, glIntMinor); if( !getGLIntVersionOK ) { final String errMsg = "Fetching GL Integer Version failed. "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, null); if( strictMatch ) { @@ -1432,7 +1430,7 @@ public abstract class GLContextImpl extends GLContext { hasGLVersionByInt = new VersionNumber(glIntMajor[0], glIntMinor[0], 0); } if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (Int): "+glVersion+", "+hasGLVersionByInt); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (Int): String "+glVersion+", Number "+hasGLVersionByInt); } // Only validate if a valid int version was fetched, otherwise cont. w/ version-string method -> 3.0 > Version || Version > MAX! @@ -1455,16 +1453,20 @@ public abstract class GLContextImpl extends GLContext { // Use returned GL version! major = hasGLVersionByInt.getMajor(); minor = hasGLVersionByInt.getMinor(); - versionValidated = true; + versionGL3IntOK = true; } else { - versionGL3IntFailed = true; + versionGL3IntOK = false; } } - if( !versionValidated ) { + final boolean versionValidated; + + if( versionGL3IntOK ) { + versionValidated = true; + } else { // Validate the requested version w/ the GL-version from the version string. final VersionNumber hasGLVersionByString = getGLVersionNumber(ctxProfileBits, glVersion); if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (String): "+glVersion+", "+hasGLVersionByString); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (String): String "+glVersion+", Number "+hasGLVersionByString); } // Only validate if a valid string version was fetched -> MIN > Version || Version > MAX! @@ -1484,7 +1486,7 @@ public abstract class GLContextImpl extends GLContext { } return false; } - if( strictMatch && versionGL3IntFailed && major >= 3 ) { + if( strictMatch && !versionGL3IntOK && major >= 3 ) { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL3/ES3 version Int failed, String: "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionByString); } @@ -1494,6 +1496,8 @@ public abstract class GLContextImpl extends GLContext { major = hasGLVersionByString.getMajor(); minor = hasGLVersionByString.getMinor(); versionValidated = true; + } else { + versionValidated = false; } } if( strictMatch && !versionValidated ) { @@ -1506,7 +1510,7 @@ public abstract class GLContextImpl extends GLContext { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Post version verification req "+ GLContext.getGLVersion(reqGLVersion.getMajor(), reqGLVersion.getMinor(), reqCtxProfileBits, null)+" -> has "+ GLContext.getGLVersion(major, minor, ctxProfileBits, null)+ - ", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntFailed "+versionGL3IntFailed); + ", strictMatch "+strictMatch+", versionValidated "+versionValidated+", versionGL3IntOK "+versionGL3IntOK); } if( major < 2 ) { // there is no ES2/3-compat for a profile w/ major < 2 diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 903a4c461..b2f06dce6 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -135,13 +135,7 @@ public class EGLContext extends GLContextImpl { @Override protected void destroyImpl() throws GLException { - if (!EGL.eglDestroyContext(drawable.getNativeSurface().getDisplayHandle(), contextHandle)) { - final int eglError = EGL.eglGetError(); - if(EGL.EGL_SUCCESS != eglError) { /* oops, Mesa EGL impl. may return false, but has no EGL error */ - throw new GLException("Error destroying OpenGL context " + toHexString(contextHandle) + - ": error code " + toHexString(eglError)); - } - } + destroyContextARBImpl(contextHandle); } @Override @@ -151,7 +145,13 @@ public class EGLContext extends GLContextImpl { @Override protected void destroyContextARBImpl(long _context) { - // FIXME + if (!EGL.eglDestroyContext(drawable.getNativeSurface().getDisplayHandle(), _context)) { + final int eglError = EGL.eglGetError(); + if(EGL.EGL_SUCCESS != eglError) { /* oops, Mesa EGL impl. may return false, but has no EGL error */ + throw new GLException("Error destroying OpenGL context " + toHexString(_context) + + ": error code " + toHexString(eglError)); + } + } } @Override @@ -180,12 +180,14 @@ public class EGLContext extends GLContextImpl { } } + // Cannot check extension 'EGL_KHR_create_context' before having one current! + final IntBuffer contextAttrsNIO; final int contextVersionReq, contextVersionAttr; { if ( glProfile.usesNativeGLES3() ) { contextVersionReq = 3; - contextVersionAttr = 2; + contextVersionAttr = 3; } else if ( glProfile.usesNativeGLES2() ) { contextVersionReq = 2; contextVersionAttr = 2; @@ -195,6 +197,7 @@ public class EGLContext extends GLContextImpl { } else { throw new GLException("Error creating OpenGL context - invalid GLProfile: "+glProfile); } + // EGLExt.EGL_CONTEXT_MAJOR_VERSION_KHR == EGL.EGL_CONTEXT_CLIENT_VERSION final int[] contextAttrs = new int[] { EGL.EGL_CONTEXT_CLIENT_VERSION, contextVersionAttr, EGL.EGL_NONE }; contextAttrsNIO = Buffers.newDirectIntBuffer(contextAttrs); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java index ab28fb3fb..f184edae3 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawable.java @@ -166,7 +166,9 @@ public abstract class EGLDrawable extends GLDrawableImpl { @Override public GLDynamicLookupHelper getGLDynamicLookupHelper() { - if (getGLProfile().usesNativeGLES2()) { + if (getGLProfile().usesNativeGLES3()) { + return getFactoryImpl().getGLDynamicLookupHelper(3); + } else if (getGLProfile().usesNativeGLES2()) { return getFactoryImpl().getGLDynamicLookupHelper(2); } else if (getGLProfile().usesNativeGLES1()) { return getFactoryImpl().getGLDynamicLookupHelper(1); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 4202c7454..1438107fe 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -615,12 +615,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } if( null != eglES2DynamicLookupHelper ) { madeCurrentES3 = mapAvailableEGLESConfig(adevice, 3, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); - if( madeCurrentES3 ) { - // Only support highest - FIXME: Proper ES2/ES3 profile selection - madeCurrentES2 = false; - } else { - madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); - } + madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); } else { madeCurrentES2 = false; madeCurrentES3 = false; @@ -668,7 +663,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { @Override public GLDynamicLookupHelper getGLDynamicLookupHelper(int esProfile) { - if (2==esProfile) { + if ( 2==esProfile || 3==esProfile ) { return eglES2DynamicLookupHelper; } else if (1==esProfile) { return eglES1DynamicLookupHelper; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java index b61624d79..e28b53235 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGLCapabilities.java @@ -101,7 +101,6 @@ public class EGLGLCapabilities extends GLCapabilities { if(null == glp) { return true; } - /** FIXME: EGLExt.EGL_OPENGL_ES3_BIT_KHR OK ? */ if(0 != (renderableType & EGLExt.EGL_OPENGL_ES3_BIT_KHR) && glp.usesNativeGLES3()) { return true; } @@ -118,6 +117,9 @@ public class EGLGLCapabilities extends GLCapabilities { } public static GLProfile getCompatible(EGLGraphicsDevice device, int renderableType) { + if(0 != (renderableType & EGLExt.EGL_OPENGL_ES3_BIT_KHR) && GLProfile.isAvailable(device, GLProfile.GLES3)) { + return GLProfile.get(device, GLProfile.GLES3); + } if(0 != (renderableType & EGL.EGL_OPENGL_ES2_BIT) && GLProfile.isAvailable(device, GLProfile.GLES2)) { return GLProfile.get(device, GLProfile.GLES2); } @@ -145,6 +147,9 @@ public class EGLGLCapabilities extends GLCapabilities { if(0 != (renderableType & EGL.EGL_OPENGL_ES2_BIT)) { if(!first) sink.append(", "); sink.append("GLES2"); first=false; } + if(0 != (renderableType & EGLExt.EGL_OPENGL_ES3_BIT_KHR)) { + if(!first) sink.append(", "); sink.append("GLES3"); first=false; + } if(0 != (renderableType & EGL.EGL_OPENVG_API)) { if(!first) sink.append(", "); sink.append("VG"); first=false; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index dd7bf99cb..789168b68 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -415,6 +415,8 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple attrs.put(idx++, EGL.EGL_OPENGL_ES_BIT); } else if(caps.getGLProfile().usesNativeGLES2()) { attrs.put(idx++, EGL.EGL_OPENGL_ES2_BIT); + } else if(caps.getGLProfile().usesNativeGLES3()) { + attrs.put(idx++, EGLExt.EGL_OPENGL_ES3_BIT_KHR); } else { attrs.put(idx++, EGL.EGL_OPENGL_BIT); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 91647394d..86e19c920 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -49,9 +49,11 @@ import com.jogamp.common.net.URIQueryProps; import com.jogamp.common.os.Platform; import com.jogamp.common.util.LFRingbuffer; import com.jogamp.common.util.Ringbuffer; +import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.util.TimeFrameI; import com.jogamp.opengl.util.av.AudioSink; import com.jogamp.opengl.util.av.GLMediaPlayer; +import com.jogamp.opengl.util.glsl.ShaderCode; import com.jogamp.opengl.util.texture.Texture; import com.jogamp.opengl.util.texture.TextureSequence; import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; @@ -221,7 +223,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { public String getRequiredExtensionsShaderStub() throws IllegalStateException { checkGLInit(); if(GLES2.GL_TEXTURE_EXTERNAL_OES == textureTarget) { - return TextureSequence.GL_OES_EGL_image_external_Required_Prelude; + return ShaderCode.createExtensionDirective(GLExtensions.OES_EGL_image_external, ShaderCode.ENABLE); } return ""; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java index e38b9c6e3..a2d3eb6bf 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/TextureSequenceCubeES2.java @@ -43,6 +43,7 @@ import com.jogamp.newt.Window; import com.jogamp.newt.event.MouseAdapter; import com.jogamp.newt.event.MouseEvent; import com.jogamp.newt.event.MouseListener; +import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.util.GLArrayDataServer; import com.jogamp.opengl.util.PMVMatrix; @@ -196,8 +197,8 @@ public class TextureSequenceCubeES2 implements GLEventListener { final Texture tex= frame.getTexture(); final boolean useExternalTexture = GLES2.GL_TEXTURE_EXTERNAL_OES == tex.getTarget(); - if(useExternalTexture && !gl.isExtensionAvailable("GL_OES_EGL_image_external")) { - throw new GLException("GL_OES_EGL_image_external requested but not available"); + if(useExternalTexture && !gl.isExtensionAvailable(GLExtensions.OES_EGL_image_external)) { + throw new GLException(GLExtensions.OES_EGL_image_external+" requested but not available"); } initShader(gl); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index d29381f35..a087e7e46 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -54,6 +54,7 @@ import com.jogamp.newt.event.MouseListener; import com.jogamp.newt.event.WindowAdapter; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.GLExtensions; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; @@ -386,8 +387,8 @@ public class MovieSimple implements GLEventListener { } tex = mPlayer.getLastTexture().getTexture(); useExternalTexture = GLES2.GL_TEXTURE_EXTERNAL_OES == tex.getTarget(); - if(useExternalTexture && !gl.isExtensionAvailable("GL_OES_EGL_image_external")) { - throw new GLException("GL_OES_EGL_image_external requested but not available"); + if(useExternalTexture && !gl.isExtensionAvailable(GLExtensions.OES_EGL_image_external)) { + throw new GLException(GLExtensions.OES_EGL_image_external+" requested but not available"); } if(!mPlayerShared) { mPlayer.setTextureMinMagFilter( new int[] { GL.GL_NEAREST, GL.GL_LINEAR } ); -- cgit v1.2.3 From 3e1924e73d583d344b45839bed3a7bd51751a019 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 7 Nov 2013 11:33:14 +0100 Subject: Bug 898: Apply best efford on Animator operation's finishLifecycleAction(..) in !blocking mode, i.e. notifyAll() if waitCondition holds and test again --- make/scripts/tests.sh | 3 +- .../com/jogamp/opengl/util/AnimatorBase.java | 60 +++++++--- .../junit/jogl/awt/Bug898AnimatorFromEDTAWT.java | 129 +++++++++++++++++++++ 3 files changed, 172 insertions(+), 20 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/Bug898AnimatorFromEDTAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 029866d4e..5a56a1ee4 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -308,7 +308,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -483,6 +483,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.Bug898AnimatorFromEDTAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index f6ee3376f..ee2754bdf 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -523,29 +523,51 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @return true if {@link Condition#eval() waitCondition.eval()} returned false, otherwise false. */ protected synchronized boolean finishLifecycleAction(Condition waitCondition, long pollPeriod) { - // It's hard to tell whether the thread which changes the lifecycle has - // dependencies on the Animator's internal thread. Currently we - // use a couple of heuristics to determine whether we should do - // the blocking wait(). + /** + * It's hard to tell whether the thread which changes the lifecycle has + * dependencies on the Animator's internal thread. Currently we + * use a couple of heuristics to determine whether we should do + * the blocking wait(). + */ initImpl(false); - final boolean blocking = impl.blockUntilDone(animThread); - long remaining = blocking ? TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION : 0; - if( 0 >= pollPeriod ) { - pollPeriod = remaining; - } - boolean nok = waitCondition.eval(); - while ( nok && remaining>0 ) { - final long t1 = System.currentTimeMillis(); - if( pollPeriod > remaining ) { pollPeriod = remaining; } - notifyAll(); - try { - wait(pollPeriod); - } catch (InterruptedException ie) { } - remaining -= System.currentTimeMillis() - t1 ; + final boolean blocking; + long remaining; + boolean nok; + if( impl.blockUntilDone(animThread) ) { + blocking = true; + remaining = TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION; + if( 0 >= pollPeriod ) { + pollPeriod = remaining; + } nok = waitCondition.eval(); + while ( nok && remaining>0 ) { + final long t1 = System.currentTimeMillis(); + if( pollPeriod > remaining ) { pollPeriod = remaining; } + notifyAll(); + try { + wait(pollPeriod); + } catch (InterruptedException ie) { } + remaining -= System.currentTimeMillis() - t1 ; + nok = waitCondition.eval(); + } + } else { + /** + * Even though we are not able to block until operation is completed at this point, + * best effort shall be made to preserve functionality. + * Here: Issue notifyAll() if waitCondition still holds and test again. + * + * Non blocking reason could be utilizing AWT Animator while operation is performed on AWT-EDT. + */ + blocking = false; + remaining = 0; + nok = waitCondition.eval(); + if( nok ) { + notifyAll(); + nok = waitCondition.eval(); + } } if(DEBUG || blocking && nok) { // Info only if DEBUG or ( blocking && not-ok ) ; !blocking possible if AWT - if( remaining<=0 && nok ) { + if( blocking && remaining<=0 && nok ) { System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): ++++++ timeout reached ++++++ " + getThreadName()); } stateSync.lock(); // avoid too many lock/unlock ops diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/Bug898AnimatorFromEDTAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/Bug898AnimatorFromEDTAWT.java new file mode 100644 index 000000000..66cdbc553 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/Bug898AnimatorFromEDTAWT.java @@ -0,0 +1,129 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.awt; + +import java.awt.BorderLayout; +import java.awt.Dimension; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.SwingUtilities; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.util.Animator; + +/** + * Manual test case to validate Animator pause/resume on AWT-EDT. + *

      + * Even though (AWT) Animator is not able to block until pause/resume is finished + * when issued on AWT-EDT, best effort shall be made to preserve functionality. + *

      + * Original Author: kosukek from JogAmp forum; Modifier a bit. + */ +@SuppressWarnings("serial") +public class Bug898AnimatorFromEDTAWT extends javax.swing.JFrame { + + public Bug898AnimatorFromEDTAWT() { + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + //Layout + setMinimumSize(new Dimension(640, 480)); + getContentPane().setLayout(new BorderLayout()); + GLCanvas panel = new GLCanvas(new GLCapabilities(GLProfile.getMaxProgrammable(true))); + getContentPane().add(panel, BorderLayout.CENTER); + pack(); + //Animator + final Animator animator = new Animator(); + animator.add(panel); + //GLEventListener + panel.addGLEventListener(new GearsES2(1)); + panel.addGLEventListener(new GLEventListener() { + long startTime = 0, lastTime = 0; + long step = 1; + + @Override + public void init(GLAutoDrawable glad) { + startTime = System.currentTimeMillis(); + } + + @Override + public void dispose(GLAutoDrawable glad) { + } + + @Override + public void display(GLAutoDrawable glad) { + long time = System.currentTimeMillis(); + if (animator.isAnimating() && step * 2000 < time - startTime) { + long td = time - lastTime; + lastTime = time; + animator.pause(); + System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.pause(): paused "+animator); + new Thread() { + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + long td = System.currentTimeMillis() - lastTime; + if (animator.isPaused()) { + animator.resume(); //Doesn't work on v2.0.2 or higher + System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): animating "+animator); + } else { + System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): Ooops - not paused! - animating "+animator); + } + } } ); + } + }.start(); + step++; + } + } + + @Override + public void reshape(GLAutoDrawable glad, int i, int i1, int i2, int i3) { + } + }); + //Start animation + animator.start(); + System.out.println("animator.start()"); + } + + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + new Bug898AnimatorFromEDTAWT().setVisible(true); + } + }); + } +} -- cgit v1.2.3 From d896598b0b0c79511b3a00b65467cad2aad41694 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 8 Nov 2013 15:51:57 +0100 Subject: TestPerf001GLJPanelInit02AWT: Add overlapping test .. --- make/scripts/tests.sh | 4 +-- .../jogl/perf/TestPerf001GLJPanelInit02AWT.java | 42 +++++++++++++++++++--- 2 files changed, 40 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 5a56a1ee4..809099a82 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -337,7 +337,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # @@ -483,7 +483,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.Bug898AnimatorFromEDTAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.Bug898AnimatorFromEDTAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java index 1c3accb67..38ed349b1 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java @@ -70,12 +70,19 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { } public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height, - final int frameCount, final boolean initMT, final boolean useGLJPanel, final boolean useGLCanvas, final boolean useAnim, final boolean overlap) { + final int frameCount, final boolean initMT, final boolean useGLJPanel, final boolean useGLCanvas, + final boolean useAnim, final boolean overlap) { final GLAnimatorControl animator = useAnim ? new Animator() : null; final int cols = (int)Math.round(Math.sqrt(frameCount)); final int rows = frameCount / cols; - final int eWidth = width/cols-32; - final int eHeight = height/rows-32; + final int eWidth, eHeight; + if( overlap ) { + eWidth = width; + eHeight = height; + } else { + eWidth = width/cols-32; + eHeight = height/rows-32; + } final JFrame[] frame = new JFrame[frameCount]; final long[] t = new long[10]; @@ -262,6 +269,30 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); } + @Test + public void test10NopNoGLDefOverlap() throws InterruptedException, InvocationTargetException { + test(null, false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, + false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + } + + @Test + public void test11NopGLCanvasDefOverlap() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, + true /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + } + + @Test + public void test12NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, + false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + } + + @Test + public void test13NopGLJPanelDefOverlapMT() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, true /* initMT */, true /* useGLJPanel */, + false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + } + // @Test public void test04NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException { test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, @@ -284,6 +315,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { public static void main(String[] args) { boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useGears = false, manual=false; + boolean overlap = false; boolean waitMain = false; for(int i=0; i Date: Sat, 9 Nov 2013 20:12:32 +0100 Subject: Tests: Add com/jogamp/opengl/test/junit/jogl/acore/anim Animator test package --- make/scripts/tests-win.bat | 95 ++++--- make/scripts/tests.sh | 55 ++-- .../jogl/acore/anim/Bug898AnimatorFromEDTAWT.java | 129 +++++++++ .../TestAWTCardLayoutAnimatorStartStopBug532.java | 228 ++++++++++++++++ .../jogl/acore/anim/TestAnimatorGLJPanel01AWT.java | 301 +++++++++++++++++++++ .../acore/anim/TestAnimatorGLWindow01NEWT.java | 267 ++++++++++++++++++ .../junit/jogl/awt/Bug898AnimatorFromEDTAWT.java | 129 --------- .../TestAWTCardLayoutAnimatorStartStopBug532.java | 228 ---------------- 8 files changed, 1009 insertions(+), 423 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/Bug898AnimatorFromEDTAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAnimatorGLJPanel01AWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAnimatorGLWindow01NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/Bug898AnimatorFromEDTAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWTCardLayoutAnimatorStartStopBug532.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 94bc49c38..f8a0b4ead 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -1,10 +1,45 @@ REM scripts\java-win.bat jogamp.newt.awt.opengl.VersionApplet REM scripts\java-win.bat com.jogamp.newt.opengl.GLWindow REM scripts\java-win.bat javax.media.opengl.awt.GLCanvas +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT %* @@ -21,11 +56,11 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedConte REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT $* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMix2DemosES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestFBOMRTNEWT01 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableDelegateOnOffscrnCapsNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLAutoDrawableGLWindowOnOffscrnCapsNEWT %* @@ -54,6 +89,12 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLCanvas01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT %* @@ -65,36 +106,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering2NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* - -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT %* - -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* - -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestGLSLSimple01NEWT -time 2000 @@ -107,11 +118,11 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCode REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* @@ -137,7 +148,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGe REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE @@ -153,10 +164,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aN REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02bNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.ManualScreenMode03sNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* - REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestCloseNewtAWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 809099a82..1f4ca9fc7 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -296,6 +296,19 @@ function testawtswt() { jrun 1 1 $* 2>&1 | tee -a java-run.log } +# +# Version +# +#testawt jogamp.newt.awt.opengl.VersionApplet $* +#testawt javax.media.opengl.awt.GLCanvas $* +#testnoawt com.jogamp.nativewindow.NativeWindowVersion $* +#testnoawt com.jogamp.opengl.JoglVersion $* +#testnoawt com.jogamp.newt.NewtVersion $* +#testnoawt com.jogamp.newt.opengl.GLWindow $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* + # # demos (any TK, more user driven tests) # @@ -337,7 +350,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # @@ -354,13 +367,8 @@ testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* # -# core/newt (testnoawt and testawt) +# CORE [NEWT + AWT] (testnoawt and testawt) # -#testnoawt com.jogamp.nativewindow.NativeWindowVersion $* -#testnoawt com.jogamp.opengl.JoglVersion $* -#testnoawt com.jogamp.newt.NewtVersion $* -#testnoawt com.jogamp.newt.opengl.GLWindow $* - #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix02NOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestPMVMatrix03NOUI $* @@ -369,8 +377,6 @@ testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary16NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* @@ -401,6 +407,11 @@ testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextNewtAWTBug523 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOnThreadSharedContext1DemoES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableFactoryNEWT $* @@ -446,10 +457,21 @@ testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLCanvas01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 $* +testawt com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT $* + +# +# NEWT +# + #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteWindow01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestRemoteGLWindows01NEWT $* @@ -474,16 +496,8 @@ testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowWarpPointer01NEWT $* # -# awt (testawt) +# AWT # -#testawt jogamp.newt.awt.opengl.VersionApplet $* -#testawt javax.media.opengl.awt.GLCanvas $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.Bug898AnimatorFromEDTAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT $* @@ -505,12 +519,9 @@ testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461FBOSupersamplingSwingAWT -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug461PBufferSupersamplingSwingAWT #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug694ScaleImageUnpackBufferSizeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug365TextureGenerateMipMaps $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* @@ -523,7 +534,7 @@ testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv4AWT $* # -# swt (testswt) +# SWT (testswt) # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/Bug898AnimatorFromEDTAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/Bug898AnimatorFromEDTAWT.java new file mode 100644 index 000000000..55e045d48 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/Bug898AnimatorFromEDTAWT.java @@ -0,0 +1,129 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.acore.anim; + +import java.awt.BorderLayout; +import java.awt.Dimension; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.SwingUtilities; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.util.Animator; + +/** + * Manual test case to validate Animator pause/resume on AWT-EDT. + *

      + * Even though (AWT) Animator is not able to block until pause/resume is finished + * when issued on AWT-EDT, best effort shall be made to preserve functionality. + *

      + * Original Author: kosukek from JogAmp forum; Modifier a bit. + */ +@SuppressWarnings("serial") +public class Bug898AnimatorFromEDTAWT extends javax.swing.JFrame { + + public Bug898AnimatorFromEDTAWT() { + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + //Layout + setMinimumSize(new Dimension(640, 480)); + getContentPane().setLayout(new BorderLayout()); + GLCanvas panel = new GLCanvas(new GLCapabilities(GLProfile.getMaxProgrammable(true))); + getContentPane().add(panel, BorderLayout.CENTER); + pack(); + //Animator + final Animator animator = new Animator(); + animator.add(panel); + //GLEventListener + panel.addGLEventListener(new GearsES2(1)); + panel.addGLEventListener(new GLEventListener() { + long startTime = 0, lastTime = 0; + long step = 1; + + @Override + public void init(GLAutoDrawable glad) { + startTime = System.currentTimeMillis(); + } + + @Override + public void dispose(GLAutoDrawable glad) { + } + + @Override + public void display(GLAutoDrawable glad) { + long time = System.currentTimeMillis(); + if (animator.isAnimating() && step * 2000 < time - startTime) { + long td = time - lastTime; + lastTime = time; + animator.pause(); + System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.pause(): paused "+animator); + new Thread() { + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + long td = System.currentTimeMillis() - lastTime; + if (animator.isPaused()) { + animator.resume(); //Doesn't work on v2.0.2 or higher + System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): animating "+animator); + } else { + System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): Ooops - not paused! - animating "+animator); + } + } } ); + } + }.start(); + step++; + } + } + + @Override + public void reshape(GLAutoDrawable glad, int i, int i1, int i2, int i3) { + } + }); + //Start animation + animator.start(); + System.out.println("animator.start()"); + } + + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + new Bug898AnimatorFromEDTAWT().setVisible(true); + } + }); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java new file mode 100644 index 000000000..7f861d89b --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java @@ -0,0 +1,228 @@ +package com.jogamp.opengl.test.junit.jogl.acore.anim; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLAnimatorControl; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.FPSAnimator; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { + static final String LABEL = "Label"; + static final String CANVAS = "GLCanvas"; + + public enum AnimatorControlBehavior { + StartStop, PauseResume, Continue; + } + + static long durationPerTest = 200*4; // ms + static boolean manual = false; + static volatile boolean shouldStop = false; + + private String selected = LABEL; + + @Test + public void testFPSAnimatorStartStop() throws InterruptedException, InvocationTargetException { + testImpl(AnimatorControlBehavior.StartStop, true); + } + + @Test + public void testFPSAnimatorResumePause() throws InterruptedException, InvocationTargetException { + testImpl(AnimatorControlBehavior.PauseResume, true); + } + + @Test + public void testFPSAnimatorContinue() throws InterruptedException, InvocationTargetException { + testImpl(AnimatorControlBehavior.Continue, true); + } + + @Test + public void testAnimatorStartStop() throws InterruptedException, InvocationTargetException { + testImpl(AnimatorControlBehavior.StartStop, false); + } + + @Test + public void testAnimatorResumePause() throws InterruptedException, InvocationTargetException { + testImpl(AnimatorControlBehavior.PauseResume, false); + } + + @Test + public void testAnimatorContinue() throws InterruptedException, InvocationTargetException { + testImpl(AnimatorControlBehavior.Continue, false); + } + + void testImpl(final AnimatorControlBehavior animCtrl, boolean useFPSAnimator) throws InterruptedException, InvocationTargetException { + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + final GLCanvas canvas = new GLCanvas(caps); + canvas.setPreferredSize(new Dimension(640, 480)); + + final GLAnimatorControl animatorCtrl = useFPSAnimator ? new FPSAnimator(canvas, 60) : new Animator(canvas); + animatorCtrl.setUpdateFPSFrames(60, null);// System.err); + switch (animCtrl) { + case PauseResume: + animatorCtrl.start(); + animatorCtrl.pause(); + break; + case Continue: + animatorCtrl.start(); + break; + default: + } + + canvas.addGLEventListener(new GearsES2(1)); + /* if(Platform.OS_TYPE == Platform.OSType.WINDOWS) { + canvas.addGLEventListener(new GLEventListener() { + public void init(GLAutoDrawable drawable) { } + public void dispose(GLAutoDrawable drawable) { } + public void display(GLAutoDrawable drawable) { + final NativeWindow win = (NativeWindow) drawable.getNativeSurface(); + long hdc = win.getSurfaceHandle(); + long hdw = win.getWindowHandle(); + long hdw_hdc = GDI.WindowFromDC(hdc); + System.err.println("*** hdc 0x"+Long.toHexString(hdc)+", hdw(hdc) 0x"+Long.toHexString(hdw_hdc)+", hdw 0x"+Long.toHexString(hdw) + " - " + Thread.currentThread().getName() + ", " + animatorCtrl); + // System.err.println(drawable.getNativeSurface().toString()); + } + public void reshape(GLAutoDrawable drawable, int x, int y, int width, + int height) { } + }); + } */ + + final JFrame frame = new JFrame(); + frame.setTitle(getSimpleTestName(" - ")); + frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + animatorCtrl.stop(); + shouldStop = true; + } + }); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + + final JPanel cards = new JPanel(new CardLayout()); + final JPanel comboBoxPanel = new JPanel(); // nicer look .. + final JComboBox comboBox = new JComboBox(new String[] { LABEL, CANVAS }); + comboBox.setEditable(false); + comboBox.addItemListener(new ItemListener() { + public void itemStateChanged(final ItemEvent evt) { + final CardLayout cl = (CardLayout)(cards.getLayout()); + final String newSelection = (String)evt.getItem(); + if(!newSelection.equals(selected)) { + final String oldSelected = selected; + if(newSelection.equals(CANVAS)) { + cl.show(cards, CANVAS); + switch (animCtrl) { + case StartStop: + animatorCtrl.start(); + break; + case PauseResume: + animatorCtrl.resume(); + break; + default: + } + selected = CANVAS; + } else if(newSelection.equals(LABEL)) { + switch (animCtrl) { + case StartStop: + animatorCtrl.stop(); + break; + case PauseResume: + animatorCtrl.pause(); + break; + default: + } + cl.show(cards, LABEL); + selected = LABEL; + } else { + throw new RuntimeException("oops .. unexpected item: "+evt); + } + System.err.println("Item Change: "+oldSelected+" -> "+selected+", "+animatorCtrl); + } else { + System.err.println("Item Stays: "+selected+", "+animatorCtrl); + } + } + }); + comboBoxPanel.add(comboBox); + + cards.add(new JLabel("A label to cover the canvas"), LABEL); + cards.add(canvas, CANVAS); + + frame.add(comboBoxPanel, BorderLayout.PAGE_START); + frame.add(cards, BorderLayout.CENTER); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.pack(); + frame.setVisible(true); + }}); + + if(manual) { + for(long w=durationPerTest; !shouldStop && w>0; w-=100) { + Thread.sleep(100); + } + } else { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + comboBox.setSelectedItem(LABEL); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + comboBox.setSelectedItem(CANVAS); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + comboBox.setSelectedItem(LABEL); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + comboBox.setSelectedItem(CANVAS); + }}); + Thread.sleep(durationPerTest/4); + } + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setVisible(false); + frame.dispose(); + }}); + + } + + public static void main(String args[]) { + for(int i=0; i - * Even though (AWT) Animator is not able to block until pause/resume is finished - * when issued on AWT-EDT, best effort shall be made to preserve functionality. - *

      - * Original Author: kosukek from JogAmp forum; Modifier a bit. - */ -@SuppressWarnings("serial") -public class Bug898AnimatorFromEDTAWT extends javax.swing.JFrame { - - public Bug898AnimatorFromEDTAWT() { - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - //Layout - setMinimumSize(new Dimension(640, 480)); - getContentPane().setLayout(new BorderLayout()); - GLCanvas panel = new GLCanvas(new GLCapabilities(GLProfile.getMaxProgrammable(true))); - getContentPane().add(panel, BorderLayout.CENTER); - pack(); - //Animator - final Animator animator = new Animator(); - animator.add(panel); - //GLEventListener - panel.addGLEventListener(new GearsES2(1)); - panel.addGLEventListener(new GLEventListener() { - long startTime = 0, lastTime = 0; - long step = 1; - - @Override - public void init(GLAutoDrawable glad) { - startTime = System.currentTimeMillis(); - } - - @Override - public void dispose(GLAutoDrawable glad) { - } - - @Override - public void display(GLAutoDrawable glad) { - long time = System.currentTimeMillis(); - if (animator.isAnimating() && step * 2000 < time - startTime) { - long td = time - lastTime; - lastTime = time; - animator.pause(); - System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.pause(): paused "+animator); - new Thread() { - public void run() { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - long td = System.currentTimeMillis() - lastTime; - if (animator.isPaused()) { - animator.resume(); //Doesn't work on v2.0.2 or higher - System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): animating "+animator); - } else { - System.out.println(Thread.currentThread().getName()+": #"+step+" "+td+" ms: animator.resume(): Ooops - not paused! - animating "+animator); - } - } } ); - } - }.start(); - step++; - } - } - - @Override - public void reshape(GLAutoDrawable glad, int i, int i1, int i2, int i3) { - } - }); - //Start animation - animator.start(); - System.out.println("animator.start()"); - } - - public static void main(String args[]) { - java.awt.EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - new Bug898AnimatorFromEDTAWT().setVisible(true); - } - }); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWTCardLayoutAnimatorStartStopBug532.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWTCardLayoutAnimatorStartStopBug532.java deleted file mode 100644 index d757d9522..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestAWTCardLayoutAnimatorStartStopBug532.java +++ /dev/null @@ -1,228 +0,0 @@ -package com.jogamp.opengl.test.junit.jogl.awt; - -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Dimension; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.lang.reflect.InvocationTargetException; - -import javax.media.opengl.GLAnimatorControl; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLProfile; -import javax.media.opengl.awt.GLCanvas; -import javax.swing.JComboBox; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JPanel; - -import org.junit.Test; -import org.junit.FixMethodOrder; -import org.junit.runners.MethodSorters; - -import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.FPSAnimator; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { - static final String LABEL = "Label"; - static final String CANVAS = "GLCanvas"; - - public enum AnimatorControlBehavior { - StartStop, PauseResume, Continue; - } - - static long durationPerTest = 200*4; // ms - static boolean manual = false; - static volatile boolean shouldStop = false; - - private String selected = LABEL; - - @Test - public void testFPSAnimatorStartStop() throws InterruptedException, InvocationTargetException { - testImpl(AnimatorControlBehavior.StartStop, true); - } - - @Test - public void testFPSAnimatorResumePause() throws InterruptedException, InvocationTargetException { - testImpl(AnimatorControlBehavior.PauseResume, true); - } - - @Test - public void testFPSAnimatorContinue() throws InterruptedException, InvocationTargetException { - testImpl(AnimatorControlBehavior.Continue, true); - } - - @Test - public void testAnimatorStartStop() throws InterruptedException, InvocationTargetException { - testImpl(AnimatorControlBehavior.StartStop, false); - } - - @Test - public void testAnimatorResumePause() throws InterruptedException, InvocationTargetException { - testImpl(AnimatorControlBehavior.PauseResume, false); - } - - @Test - public void testAnimatorContinue() throws InterruptedException, InvocationTargetException { - testImpl(AnimatorControlBehavior.Continue, false); - } - - void testImpl(final AnimatorControlBehavior animCtrl, boolean useFPSAnimator) throws InterruptedException, InvocationTargetException { - final GLProfile glp = GLProfile.get(GLProfile.GL2); - final GLCapabilities caps = new GLCapabilities(glp); - final GLCanvas canvas = new GLCanvas(caps); - canvas.setPreferredSize(new Dimension(640, 480)); - - final GLAnimatorControl animatorCtrl = useFPSAnimator ? new FPSAnimator(canvas, 60) : new Animator(canvas); - animatorCtrl.setUpdateFPSFrames(60, null);// System.err); - switch (animCtrl) { - case PauseResume: - animatorCtrl.start(); - animatorCtrl.pause(); - break; - case Continue: - animatorCtrl.start(); - break; - default: - } - - canvas.addGLEventListener(new GearsES2(1)); - /* if(Platform.OS_TYPE == Platform.OSType.WINDOWS) { - canvas.addGLEventListener(new GLEventListener() { - public void init(GLAutoDrawable drawable) { } - public void dispose(GLAutoDrawable drawable) { } - public void display(GLAutoDrawable drawable) { - final NativeWindow win = (NativeWindow) drawable.getNativeSurface(); - long hdc = win.getSurfaceHandle(); - long hdw = win.getWindowHandle(); - long hdw_hdc = GDI.WindowFromDC(hdc); - System.err.println("*** hdc 0x"+Long.toHexString(hdc)+", hdw(hdc) 0x"+Long.toHexString(hdw_hdc)+", hdw 0x"+Long.toHexString(hdw) + " - " + Thread.currentThread().getName() + ", " + animatorCtrl); - // System.err.println(drawable.getNativeSurface().toString()); - } - public void reshape(GLAutoDrawable drawable, int x, int y, int width, - int height) { } - }); - } */ - - final JFrame frame = new JFrame(); - frame.setTitle(getSimpleTestName(" - ")); - frame.addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - animatorCtrl.stop(); - shouldStop = true; - } - }); - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - final JPanel cards = new JPanel(new CardLayout()); - final JPanel comboBoxPanel = new JPanel(); // nicer look .. - final JComboBox comboBox = new JComboBox(new String[] { LABEL, CANVAS }); - comboBox.setEditable(false); - comboBox.addItemListener(new ItemListener() { - public void itemStateChanged(final ItemEvent evt) { - final CardLayout cl = (CardLayout)(cards.getLayout()); - final String newSelection = (String)evt.getItem(); - if(!newSelection.equals(selected)) { - final String oldSelected = selected; - if(newSelection.equals(CANVAS)) { - cl.show(cards, CANVAS); - switch (animCtrl) { - case StartStop: - animatorCtrl.start(); - break; - case PauseResume: - animatorCtrl.resume(); - break; - default: - } - selected = CANVAS; - } else if(newSelection.equals(LABEL)) { - switch (animCtrl) { - case StartStop: - animatorCtrl.stop(); - break; - case PauseResume: - animatorCtrl.pause(); - break; - default: - } - cl.show(cards, LABEL); - selected = LABEL; - } else { - throw new RuntimeException("oops .. unexpected item: "+evt); - } - System.err.println("Item Change: "+oldSelected+" -> "+selected+", "+animatorCtrl); - } else { - System.err.println("Item Stays: "+selected+", "+animatorCtrl); - } - } - }); - comboBoxPanel.add(comboBox); - - cards.add(new JLabel("A label to cover the canvas"), LABEL); - cards.add(canvas, CANVAS); - - frame.add(comboBoxPanel, BorderLayout.PAGE_START); - frame.add(cards, BorderLayout.CENTER); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.pack(); - frame.setVisible(true); - }}); - - if(manual) { - for(long w=durationPerTest; !shouldStop && w>0; w-=100) { - Thread.sleep(100); - } - } else { - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - comboBox.setSelectedItem(LABEL); - }}); - Thread.sleep(durationPerTest/4); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - comboBox.setSelectedItem(CANVAS); - }}); - Thread.sleep(durationPerTest/4); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - comboBox.setSelectedItem(LABEL); - }}); - Thread.sleep(durationPerTest/4); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - comboBox.setSelectedItem(CANVAS); - }}); - Thread.sleep(durationPerTest/4); - } - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setVisible(false); - frame.dispose(); - }}); - - } - - public static void main(String args[]) { - for(int i=0; i Date: Sun, 10 Nov 2013 07:19:04 +0100 Subject: Simplify Animator* Synchronization: Remove barrier 'stateSync' and favor simple 'synchronized' on Animator for field-get, which is already used in most methods Utilizing a 2nd synchronization object 'stateSync' besides the main sync object, Animator itself, is hard to maintain. It's performance advantages for querying states ae questionable and may even introduce bugs. Use synchronization on Animator instance for all field read/write access. Fix unsynchronized write access of 'animThread' in Animator.MainLoop.run(). --- make/scripts/tests.sh | 5 +- .../classes/com/jogamp/opengl/util/Animator.java | 94 ++---- .../com/jogamp/opengl/util/AnimatorBase.java | 92 ++--- .../com/jogamp/opengl/util/FPSAnimator.java | 57 ++-- .../awt/TestGLCanvasAWTActionDeadlock02AWT.java | 374 ++++++++++----------- 5 files changed, 260 insertions(+), 362 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 1f4ca9fc7..468672325 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -462,11 +462,10 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLCanvas01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 $* -testawt com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT $* # # NEWT diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java index 27b9427eb..799069292 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java @@ -110,7 +110,7 @@ public class Animator extends AnimatorBase { } @Override - protected String getBaseName(String prefix) { + protected final String getBaseName(String prefix) { return prefix + "Animator" ; } @@ -120,40 +120,28 @@ public class Animator extends AnimatorBase { * animation loop which prevents the CPU from getting swamped. * This method may not have an effect on subclasses. */ - public final void setRunAsFastAsPossible(boolean runFast) { - stateSync.lock(); - try { - runAsFastAsPossible = runFast; - } finally { - stateSync.unlock(); - } - } - - private final void setIsAnimatingSynced(boolean v) { - stateSync.lock(); - try { - isAnimating = v; - } finally { - stateSync.unlock(); - } + public final synchronized void setRunAsFastAsPossible(boolean runFast) { + runAsFastAsPossible = runFast; } class MainLoop implements Runnable { @Override public String toString() { - return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; + return "[started "+isStarted()+", animating "+isAnimating()+", paused "+isPaused()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; } @Override public void run() { try { - if(DEBUG) { - System.err.println("Animator start on " + getThreadName() + ": " + toString()); + synchronized (Animator.this) { + if(DEBUG) { + System.err.println("Animator start on " + getThreadName() + ": " + toString()); + } + fpsCounter.resetFPSCounter(); + animThread = Thread.currentThread(); + isAnimating = false; + // 'waitForStartedCondition' wake-up is handled below! } - fpsCounter.resetFPSCounter(); - animThread = Thread.currentThread(); - setIsAnimatingSynced(false); // barrier - // 'waitForStartedCondition' wake-up is handled below! while (!stopIssued) { synchronized (Animator.this) { @@ -172,7 +160,7 @@ public class Animator extends AnimatorBase { setDrawablesExclCtxState(false); display(); // propagate exclusive change! } - setIsAnimatingSynced(false); // barrier + isAnimating = false; Animator.this.notifyAll(); try { Animator.this.wait(); @@ -191,7 +179,7 @@ public class Animator extends AnimatorBase { // - and - // Resume from pause or drawablesEmpty, // implies !pauseIssued and !drawablesEmpty - setIsAnimatingSynced(true); // barrier + isAnimating = true; setDrawablesExclCtxState(exclusiveContext); Animator.this.notifyAll(); } @@ -221,37 +209,21 @@ public class Animator extends AnimatorBase { stopIssued = false; pauseIssued = false; animThread = null; - setIsAnimatingSynced(false); // barrier + isAnimating = false; Animator.this.notifyAll(); } } } } - private final boolean isAnimatingImpl() { - return animThread != null && isAnimating ; - } @Override - public final boolean isAnimating() { - stateSync.lock(); - try { - return animThread != null && isAnimating ; - } finally { - stateSync.unlock(); - } + public final synchronized boolean isAnimating() { + return animThread != null && isAnimating ; } - private final boolean isPausedImpl() { - return animThread != null && pauseIssued ; - } @Override - public final boolean isPaused() { - stateSync.lock(); - try { - return animThread != null && pauseIssued ; - } finally { - stateSync.unlock(); - } + public final synchronized boolean isPaused() { + return animThread != null && pauseIssued ; } /** @@ -260,16 +232,16 @@ public class Animator extends AnimatorBase { * @param tg the {@link ThreadGroup} * @throws GLException if the animator has already been started */ - public synchronized void setThreadGroup(ThreadGroup tg) throws GLException { - if ( isStartedImpl() ) { + public final synchronized void setThreadGroup(ThreadGroup tg) throws GLException { + if ( isStarted() ) { throw new GLException("Animator already started."); } threadGroup = tg; } @Override - public synchronized boolean start() { - if ( isStartedImpl() ) { + public final synchronized boolean start() { + if ( isStarted() ) { return false; } if (runnable == null) { @@ -294,12 +266,12 @@ public class Animator extends AnimatorBase { private final Condition waitForStartedCondition = new Condition() { @Override public boolean eval() { - return !isStartedImpl() || (!drawablesEmpty && !isAnimating) ; + return !isStarted() || (!drawablesEmpty && !isAnimating) ; } }; @Override - public synchronized boolean stop() { - if ( !isStartedImpl() ) { + public final synchronized boolean stop() { + if ( !isStarted() ) { return false; } stopIssued = true; @@ -308,12 +280,12 @@ public class Animator extends AnimatorBase { private final Condition waitForStoppedCondition = new Condition() { @Override public boolean eval() { - return isStartedImpl(); + return isStarted(); } }; @Override - public synchronized boolean pause() { - if ( !isStartedImpl() || pauseIssued ) { + public final synchronized boolean pause() { + if ( !isStarted() || pauseIssued ) { return false; } pauseIssued = true; @@ -323,12 +295,12 @@ public class Animator extends AnimatorBase { @Override public boolean eval() { // end waiting if stopped as well - return isStartedImpl() && isAnimating; + return isStarted() && isAnimating; } }; @Override - public synchronized boolean resume() { - if ( !isStartedImpl() || !pauseIssued ) { + public final synchronized boolean resume() { + if ( !isStarted() || !pauseIssued ) { return false; } pauseIssued = false; @@ -338,6 +310,6 @@ public class Animator extends AnimatorBase { @Override public boolean eval() { // end waiting if stopped as well - return isStartedImpl() && ( !drawablesEmpty && !isAnimating || drawablesEmpty && !pauseIssued ) ; + return isStarted() && ( !drawablesEmpty && !isAnimating || drawablesEmpty && !pauseIssued ) ; } }; } diff --git a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java index ee2754bdf..39643744a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java +++ b/src/jogl/classes/com/jogamp/opengl/util/AnimatorBase.java @@ -28,8 +28,6 @@ package com.jogamp.opengl.util; -import com.jogamp.common.util.locks.LockFactory; -import com.jogamp.common.util.locks.RecursiveLock; import jogamp.opengl.Debug; import jogamp.opengl.FPSCounterImpl; @@ -86,7 +84,6 @@ public abstract class AnimatorBase implements GLAnimatorControl { protected boolean exclusiveContext; protected Thread userExclusiveContextThread; protected FPSCounterImpl fpsCounter = new FPSCounterImpl(); - protected RecursiveLock stateSync = LockFactory.createRecursiveLock(); private final static Class awtAnimatorImplClazz; static { @@ -129,7 +126,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * * @throws GLException if Animator is {@link #isStarted()} */ - protected synchronized void initImpl(boolean force) { + protected final synchronized void initImpl(boolean force) { if( force || null == impl ) { if( useAWTAnimatorImpl( modeBits ) ) { try { @@ -157,7 +154,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @throws GLException if Animator is {@link #isStarted()} and {@link #MODE_EXPECT_AWT_RENDERING_THREAD} about to change * @see AnimatorBase#MODE_EXPECT_AWT_RENDERING_THREAD */ - public synchronized void setModeBits(boolean enable, int bitValues) throws GLException { + public final synchronized void setModeBits(boolean enable, int bitValues) throws GLException { final int _oldModeBits = modeBits; if(enable) { modeBits |= bitValues; @@ -175,7 +172,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { @Override - public synchronized void add(final GLAutoDrawable drawable) { + public final synchronized void add(final GLAutoDrawable drawable) { if(DEBUG) { System.err.println("Animator add: 0x"+Integer.toHexString(drawable.hashCode())+" - "+toString()+" - "+getThreadName()); } @@ -207,7 +204,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { } @Override - public synchronized void remove(final GLAutoDrawable drawable) { + public final synchronized void remove(final GLAutoDrawable drawable) { if(DEBUG) { System.err.println("Animator remove: 0x"+Integer.toHexString(drawable.hashCode())+" - "+toString()+" - "+getThreadName()); } @@ -270,17 +267,11 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @see #isExclusiveContextEnabled() */ // @Override - public final Thread setExclusiveContext(Thread t) { - final Thread old; + public final synchronized Thread setExclusiveContext(Thread t) { final boolean enable = null != t; - stateSync.lock(); - try { - old = userExclusiveContextThread; - if( enable && t != animThread ) { // disable: will be cleared at end after propagation && filter out own animThread usae - userExclusiveContextThread=t; - } - } finally { - stateSync.unlock(); + final Thread old = userExclusiveContextThread; + if( enable && t != animThread ) { // disable: will be cleared at end after propagation && filter out own animThread usae + userExclusiveContextThread=t; } setExclusiveContext(enable); return old; @@ -340,11 +331,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { pause(); } } - stateSync.lock(); - try { + synchronized(AnimatorBase.this) { userExclusiveContextThread=null; - } finally { - stateSync.unlock(); } } } @@ -361,13 +349,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @see #setExclusiveContext(Thread) */ // @Override - public final boolean isExclusiveContextEnabled() { - stateSync.lock(); - try { - return exclusiveContext; - } finally { - stateSync.unlock(); - } + public final synchronized boolean isExclusiveContextEnabled() { + return exclusiveContext; } /** @@ -384,13 +367,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { * @see #setExclusiveContext(Thread) */ // @Override - public final Thread getExclusiveContextThread() { - stateSync.lock(); - try { - return ( isStartedImpl() && exclusiveContext ) ? ( null != userExclusiveContextThread ? userExclusiveContextThread : animThread ) : null ; - } finally { - stateSync.unlock(); - } + public final synchronized Thread getExclusiveContextThread() { + return ( isStarted() && exclusiveContext ) ? ( null != userExclusiveContextThread ? userExclusiveContextThread : animThread ) : null ; } /** @@ -425,13 +403,8 @@ public abstract class AnimatorBase implements GLAnimatorControl { } @Override - public final Thread getThread() { - stateSync.lock(); - try { - return animThread; - } finally { - stateSync.unlock(); - } + public final synchronized Thread getThread() { + return animThread; } /** Called every frame to cause redrawing of all of the @@ -439,7 +412,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { this to get the most optimized painting behavior for the set of components this Animator manages, in particular when multiple lightweight widgets are continually being redrawn. */ - protected void display() { + protected final void display() { impl.display(drawables, ignoreExceptions, printExceptions); fpsCounter.tickFPS(); } @@ -497,7 +470,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { /** Sets a flag causing this Animator to ignore exceptions produced while redrawing the drawables. By default this flag is set to false, causing any exception thrown to halt the Animator. */ - public void setIgnoreExceptions(boolean ignoreExceptions) { + public final void setIgnoreExceptions(boolean ignoreExceptions) { this.ignoreExceptions = ignoreExceptions; } @@ -505,7 +478,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { this Animator (see {@link #setIgnoreExceptions}), to print the exceptions' stack traces for diagnostic information. Defaults to false. */ - public void setPrintExceptions(boolean printExceptions) { + public final void setPrintExceptions(boolean printExceptions) { this.printExceptions = printExceptions; } @@ -522,7 +495,7 @@ public abstract class AnimatorBase implements GLAnimatorControl { * if > 0, method will wait for the given pollPeriod in milliseconds. * @return true if {@link Condition#eval() waitCondition.eval()} returned false, otherwise false. */ - protected synchronized boolean finishLifecycleAction(Condition waitCondition, long pollPeriod) { + protected final synchronized boolean finishLifecycleAction(Condition waitCondition, long pollPeriod) { /** * It's hard to tell whether the thread which changes the lifecycle has * dependencies on the Animator's internal thread. Currently we @@ -570,16 +543,11 @@ public abstract class AnimatorBase implements GLAnimatorControl { if( blocking && remaining<=0 && nok ) { System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): ++++++ timeout reached ++++++ " + getThreadName()); } - stateSync.lock(); // avoid too many lock/unlock ops - try { - System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): OK "+(!nok)+ - "- pollPeriod "+pollPeriod+", blocking "+blocking+ - ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + - " - " + getThreadName()); - System.err.println(" - "+toString()); - } finally { - stateSync.unlock(); - } + System.err.println("finishLifecycleAction(" + waitCondition.getClass().getName() + "): OK "+(!nok)+ + "- pollPeriod "+pollPeriod+", blocking "+blocking+ + ", waited " + (blocking ? ( TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION - remaining ) : 0 ) + "/" + TO_WAIT_FOR_FINISH_LIFECYCLE_ACTION + + " - " + getThreadName()); + System.err.println(" - "+toString()); if(nok) { Thread.dumpStack(); } @@ -587,17 +555,9 @@ public abstract class AnimatorBase implements GLAnimatorControl { return !nok; } - protected final boolean isStartedImpl() { - return animThread != null ; - } @Override - public boolean isStarted() { - stateSync.lock(); - try { - return animThread != null ; - } finally { - stateSync.unlock(); - } + public synchronized boolean isStarted() { + return animThread != null ; } protected static String getThreadName() { return Thread.currentThread().getName(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java index 351c47e7e..65fed17f2 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java +++ b/src/jogl/classes/com/jogamp/opengl/util/FPSAnimator.java @@ -59,7 +59,7 @@ public class FPSAnimator extends AnimatorBase { private Timer timer = null; private MainTask task = null; private int fps; - private boolean scheduleAtFixedRate; + private final boolean scheduleAtFixedRate; private boolean isAnimating; // MainTask feedback private volatile boolean shouldRun; // MainTask trigger private volatile boolean shouldStop; // MainTask trigger @@ -107,7 +107,7 @@ public class FPSAnimator extends AnimatorBase { * @throws GLException if the animator has already been started */ public final synchronized void setFPS(int fps) throws GLException { - if ( isStartedImpl() ) { + if ( isStarted() ) { throw new GLException("Animator already started."); } this.fps = fps; @@ -131,7 +131,7 @@ public class FPSAnimator extends AnimatorBase { alreadyStopped = false; alreadyPaused = false; - final long period = 0 < fps ? (long) (1000.0f / (float) fps) : 1; // 0 -> 1: IllegalArgumentException: Non-positive period + final long period = 0 < fps ? (long) (1000.0f / fps) : 1; // 0 -> 1: IllegalArgumentException: Non-positive period if (scheduleAtFixedRate) { timer.scheduleAtFixedRate(this, 0, period); } else { @@ -142,8 +142,8 @@ public class FPSAnimator extends AnimatorBase { public boolean isActive() { return !alreadyStopped && !alreadyPaused; } @Override - public String toString() { - return "Task[thread "+animThread+", stopped "+alreadyStopped+", paused "+alreadyPaused+" shouldRun "+shouldRun+", shouldStop "+shouldStop+" -- started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; + public final String toString() { + return "Task[thread "+animThread+", stopped "+alreadyStopped+", paused "+alreadyPaused+" shouldRun "+shouldRun+", shouldStop "+shouldStop+" -- started "+isStarted()+", animating "+isAnimatingImpl()+", paused "+isPaused()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]"; } @Override @@ -212,33 +212,20 @@ public class FPSAnimator extends AnimatorBase { return animThread != null && isAnimating ; } @Override - public final boolean isAnimating() { - stateSync.lock(); - try { - return animThread != null && isAnimating ; - } finally { - stateSync.unlock(); - } + public final synchronized boolean isAnimating() { + return animThread != null && isAnimating ; } - private final boolean isPausedImpl() { - return animThread != null && ( !shouldRun && !shouldStop ) ; - } @Override - public final boolean isPaused() { - stateSync.lock(); - try { - return animThread != null && ( !shouldRun && !shouldStop ) ; - } finally { - stateSync.unlock(); - } + public final synchronized boolean isPaused() { + return animThread != null && ( !shouldRun && !shouldStop ) ; } static int timerNo = 0; @Override - public synchronized boolean start() { - if ( null != timer || null != task || isStartedImpl() ) { + public final synchronized boolean start() { + if ( null != timer || null != task || isStarted() ) { return false; } timer = new Timer( getThreadName()+"-"+baseName+"-Timer"+(timerNo++) ); @@ -262,20 +249,20 @@ public class FPSAnimator extends AnimatorBase { private final Condition waitForStartedAddedCondition = new Condition() { @Override public boolean eval() { - return !isStartedImpl() || !isAnimating ; + return !isStarted() || !isAnimating ; } }; private final Condition waitForStartedEmptyCondition = new Condition() { @Override public boolean eval() { - return !isStartedImpl() || isAnimating ; + return !isStarted() || isAnimating ; } }; /** Stops this FPSAnimator. Due to the implementation of the FPSAnimator it is not guaranteed that the FPSAnimator will be completely stopped by the time this method returns. */ @Override - public synchronized boolean stop() { - if ( null == timer || !isStartedImpl() ) { + public final synchronized boolean stop() { + if ( null == timer || !isStarted() ) { return false; } if(DEBUG) { @@ -308,12 +295,12 @@ public class FPSAnimator extends AnimatorBase { private final Condition waitForStoppedCondition = new Condition() { @Override public boolean eval() { - return isStartedImpl(); + return isStarted(); } }; @Override - public synchronized boolean pause() { - if ( !isStartedImpl() || ( null != task && isPausedImpl() ) ) { + public final synchronized boolean pause() { + if ( !isStarted() || ( null != task && isPaused() ) ) { return false; } if(DEBUG) { @@ -341,12 +328,12 @@ public class FPSAnimator extends AnimatorBase { @Override public boolean eval() { // end waiting if stopped as well - return isAnimating && isStartedImpl(); + return isAnimating && isStarted(); } }; @Override - public synchronized boolean resume() { - if ( null != task || !isStartedImpl() || !isPausedImpl() ) { + public final synchronized boolean resume() { + if ( null != task || !isStarted() || !isPaused() ) { return false; } if(DEBUG) { @@ -369,6 +356,6 @@ public class FPSAnimator extends AnimatorBase { @Override public boolean eval() { // end waiting if stopped as well - return !drawablesEmpty && !isAnimating && isStartedImpl(); + return !drawablesEmpty && !isAnimating && isStarted(); } }; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java index 2587f8d50..605f97fe3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLCanvasAWTActionDeadlock02AWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -63,12 +63,12 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; /** - * Sample program that relies on JOGL's mechanism to handle the OpenGL context + * Sample program that relies on JOGL's mechanism to handle the OpenGL context * and rendering loop when using an AWT canvas attached to an Applet. *

      - * BUG on OSX/CALayer w/ Java6: + * BUG on OSX/CALayer w/ Java6: * If frame.setTitle() is issued right after initialization the call hangs in - *

       
      + * 
        * at apple.awt.CWindow._setTitle(Native Method)
        *  at apple.awt.CWindow.setTitle(CWindow.java:765) [1.6.0_37, build 1.6.0_37-b06-434-11M3909]
        * 
      @@ -81,7 +81,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase; * e.g. setResizable*(). *

      *

      - * Users shall make sure all mutable AWT calls are performed on the EDT, even before 1st setVisible(true) ! + * Users shall make sure all mutable AWT calls are performed on the EDT, even before 1st setVisible(true) ! *

      */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @@ -90,89 +90,89 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { static class MiniPApplet extends Applet implements MouseMotionListener, KeyListener { private static final long serialVersionUID = 1L; - + ///////////////////////////////////////////////////////////// // - // Test parameters - + // Test parameters + public int frameRate = 120; public int numSamples = 4; - - public boolean fullScreen = false; + + public boolean fullScreen = false; public boolean useAnimator = true; public boolean resizeableFrame = true; - + public boolean restartCanvas = true; public int restartTimeout = 100; // in number of frames. - + public boolean printThreadInfo = false; public boolean printEventInfo = false; - + ///////////////////////////////////////////////////////////// // // Internal variables - + int width; int height; - - String OPENGL_VENDOR; + + String OPENGL_VENDOR; String OPENGL_RENDERER; - String OPENGL_VERSION; - String OPENGL_EXTENSIONS; - + String OPENGL_VERSION; + String OPENGL_EXTENSIONS; + int currentSamples = -1; - + private Frame frame; private GLProfile profile; private GLCapabilities capabilities; private GLCanvas canvas; - + private SimpleListener listener; private CustomAnimator animator; - + private long beforeTime; private long overSleepTime; - private long frameRatePeriod = 1000000000L / frameRate; - - private boolean initialized = false; + private final long frameRatePeriod = 1000000000L / frameRate; + + private boolean initialized = false; private boolean osxCALayerAWTModBug = false; boolean justInitialized = true; private double theta = 0; private double s = 0; - private double c = 0; - + private double c = 0; + private long millisOffset; private int fcount, lastm; private float frate; - private int fint = 3; - + private final int fint = 3; + private boolean setFramerate = false; private boolean restarted = false; - + private int frameCount = 0; - + void run() throws InterruptedException, InvocationTargetException { // Thread loop = new Thread("Animation Thread") { - // public void run() { + // public void run() { frameCount = 0; while ( frameCount < framesPerTest ) { if (!initialized) { - setup(); + setup(); } - + if (restartCanvas && restartTimeout == frameCount) { restart(); } - + if (useAnimator) { animator.requestRender(); } else { - canvas.display(); + canvas.display(); } - + clock(); - + frameCount++; if( null == frame ) { break; @@ -181,32 +181,32 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { dispose(); // } // }; - // loop.start(); + // loop.start(); } - + void setup() throws InterruptedException, InvocationTargetException { if (printThreadInfo) System.out.println("Current thread at setup(): " + Thread.currentThread()); - - millisOffset = System.currentTimeMillis(); - + + millisOffset = System.currentTimeMillis(); + final VersionNumber version170 = new VersionNumber(1, 7, 0); - osxCALayerAWTModBug = Platform.OSType.MACOS == Platform.getOSType() && + osxCALayerAWTModBug = Platform.OSType.MACOS == Platform.getOSType() && 0 > Platform.getJavaVersionNumber().compareTo(version170); System.err.println("OSX CALayer AWT-Mod Bug "+osxCALayerAWTModBug); System.err.println("OSType "+Platform.getOSType()); System.err.println("Java Version "+Platform.getJavaVersionNumber()); - + // Frame setup ---------------------------------------------------------- - + width = 300; - height = 300; + height = 300; final MiniPApplet applet = this; - + GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice displayDevice = environment.getDefaultScreenDevice(); frame = new Frame(displayDevice.getDefaultConfiguration()); - + final Rectangle fullScreenRect; if (fullScreen) { DisplayMode mode = displayDevice.getDisplayMode(); @@ -231,7 +231,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { } catch (Throwable t) { t.printStackTrace(); Assume.assumeNoException(t); - } + } } try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { @@ -252,25 +252,25 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { applet.width, applet.height); } else { Insets insets = frame.getInsets(); - + int windowW = applet.width + insets.left + insets.right; int windowH = applet.height + insets.top + insets.bottom; - int locationX = 100; + int locationX = 100; int locationY = 100; - + frame.setSize(windowW, windowH); frame.setLocation(locationX, locationY); - + int usableWindowH = windowH - insets.top - insets.bottom; - applet.setBounds((windowW - width)/2, insets.top + (usableWindowH - height)/2, width, height); + applet.setBounds((windowW - width)/2, insets.top + (usableWindowH - height)/2, width, height); } }}); } catch (Throwable t) { t.printStackTrace(); Assume.assumeNoException(t); } - - + + frame.add(this); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { @@ -280,63 +280,63 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { Assume.assumeNoException(ex); } } - }); - + }); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setVisible(true); } } ); - + // Canvas setup ---------------------------------------------------------- - + profile = GLProfile.getDefault(); - capabilities = new GLCapabilities(profile); + capabilities = new GLCapabilities(profile); capabilities.setSampleBuffers(true); capabilities.setNumSamples(numSamples); capabilities.setDepthBits(24); // capabilities.setStencilBits(8); // No Stencil on OSX w/ hw-accel ! capabilities.setAlphaBits(8); - + canvas = new GLCanvas(capabilities); canvas.setBounds(0, 0, width, height); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { MiniPApplet.this.setLayout(new BorderLayout()); MiniPApplet.this.add(canvas, BorderLayout.CENTER); MiniPApplet.this.validate(); } } ); - canvas.addMouseMotionListener(this); + canvas.addMouseMotionListener(this); canvas.addKeyListener(this); - + // Setting up animation listener = new SimpleListener(); canvas.addGLEventListener(listener); if (useAnimator) { animator = new CustomAnimator(canvas); animator.start(); - } - initialized = true; + } + initialized = true; } - + void restart() throws InterruptedException, InvocationTargetException { System.out.println("Restarting surface..."); - + // Stopping animation, removing current canvas. if (useAnimator) { animator.stop(); animator.remove(canvas); } canvas.disposeGLEventListener(listener, true); - this.remove(canvas); - - capabilities = new GLCapabilities(profile); + this.remove(canvas); + + capabilities = new GLCapabilities(profile); capabilities.setSampleBuffers(true); capabilities.setNumSamples(numSamples); - + canvas = new GLCanvas(capabilities); canvas.setBounds(0, 0, width, height); - + // Setting up animation again javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -346,24 +346,24 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { } } ); canvas.addMouseMotionListener(this); canvas.addKeyListener(this); - + canvas.addGLEventListener(listener); if (useAnimator) { animator.add(canvas); animator.start(); - } - + } + setFramerate = false; restarted = true; - + System.out.println("Done"); } - + void dispose() throws InterruptedException, InvocationTargetException { if( null == frame ) { return; } - + // Stopping animation, removing current canvas. if (useAnimator) { animator.stop(); @@ -387,7 +387,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { }}); } } - + void draw(GL2 gl) { if( !osxCALayerAWTModBug || !justInitialized ) { AWTEDTExecutor.singleton.invoke(true, new Runnable() { @@ -395,19 +395,19 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { frame.setTitle("frame " + frameCount); } } ); } - - if (printThreadInfo) System.out.println("Current thread at draw(): " + Thread.currentThread()); - + + if (printThreadInfo) System.out.println("Current thread at draw(): " + Thread.currentThread()); + if (OPENGL_VENDOR == null) { - OPENGL_VENDOR = gl.glGetString(GL.GL_VENDOR); + OPENGL_VENDOR = gl.glGetString(GL.GL_VENDOR); OPENGL_RENDERER = gl.glGetString(GL.GL_RENDERER); - OPENGL_VERSION = gl.glGetString(GL.GL_VERSION); + OPENGL_VERSION = gl.glGetString(GL.GL_VERSION); OPENGL_EXTENSIONS = gl.glGetString(GL.GL_EXTENSIONS); System.out.println(OPENGL_VENDOR); System.out.println(OPENGL_RENDERER); System.out.println(OPENGL_VERSION); System.out.println(OPENGL_EXTENSIONS); - + int[] temp = { 0 }; gl.glGetIntegerv(GL2.GL_MAX_SAMPLES, temp, 0); System.out.println("Maximum number of samples supported by the hardware: " + temp[0]); @@ -416,43 +416,43 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { System.out.println("GLCanvas: "+canvas); System.out.println("GLDrawable: "+canvas.getDelegatedDrawable()); } - + if (currentSamples == -1) { int[] temp = { 0 }; gl.glGetIntegerv(GL.GL_SAMPLES, temp, 0); currentSamples = temp[0]; if (numSamples != currentSamples) { System.err.println("Requested sampling level " + numSamples + " not supported. Using " + currentSamples + " samples instead."); - } + } } - - if (!setFramerate) { + + if (!setFramerate) { if (60 < frameRate) { // Disables vsync - gl.setSwapInterval(0); - } else if (30 < frameRate) { - gl.setSwapInterval(1); + gl.setSwapInterval(0); + } else if (30 < frameRate) { + gl.setSwapInterval(1); } else { gl.setSwapInterval(2); - } - setFramerate = true; + } + setFramerate = true; } - + if (restarted) { int[] temp = { 0 }; - gl.glGetIntegerv(GL.GL_SAMPLES, temp, 0); + gl.glGetIntegerv(GL.GL_SAMPLES, temp, 0); if (numSamples != temp[0]) { System.err.println("Multisampling level requested " + numSamples + " not supported. Using " + temp[0] + "samples instead."); - } + } } - + gl.glClearColor(0, 0, 0, 1); gl.glClear(GL.GL_COLOR_BUFFER_BIT); - + theta += 0.01; s = Math.sin(theta); - c = Math.cos(theta); - + c = Math.cos(theta); + gl.glBegin(GL.GL_TRIANGLES); gl.glColor3f(1, 0, 0); gl.glVertex2d(-c, -c); @@ -460,135 +460,125 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { gl.glVertex2d(0, c); gl.glColor3f(0, 0, 1); gl.glVertex2d(s, -s); - gl.glEnd(); - + gl.glEnd(); + gl.glFlush(); - + fcount += 1; int m = (int) (System.currentTimeMillis() - millisOffset); if (m - lastm > 1000 * fint) { frate = (float)(fcount) / fint; fcount = 0; lastm = m; - System.err.println("fps: " + frate); - } + System.err.println("fps: " + frate); + } } - + void clock() { long afterTime = System.nanoTime(); long timeDiff = afterTime - beforeTime; long sleepTime = (frameRatePeriod - timeDiff) - overSleepTime; - + if (sleepTime > 0) { // some time left in this cycle try { Thread.sleep(sleepTime / 1000000L, (int) (sleepTime % 1000000L)); } catch (InterruptedException ex) { } - + overSleepTime = (System.nanoTime() - afterTime) - sleepTime; - + } else { // sleepTime <= 0; the frame took longer than the period overSleepTime = 0L; } - - beforeTime = System.nanoTime(); - } - + + beforeTime = System.nanoTime(); + } + class SimpleListener implements GLEventListener { @Override public void display(GLAutoDrawable drawable) { draw(drawable.getGL().getGL2()); justInitialized = false; } - + @Override public void dispose(GLAutoDrawable drawable) { } - + @Override public void init(GLAutoDrawable drawable) { justInitialized = true; } - + @Override - public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { } + public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) { } } - + public void mouseDragged(MouseEvent ev) { if (printEventInfo) { System.err.println("Mouse dragged event: " + ev); } } - + public void mouseMoved(MouseEvent ev) { if (printEventInfo) { System.err.println("Mouse moved event: " + ev); } - } - - public void keyPressed(KeyEvent ev) { + } + + public void keyPressed(KeyEvent ev) { if (printEventInfo) { System.err.println("Key pressed event: " + ev); } } - - public void keyReleased(KeyEvent ev) { + + public void keyReleased(KeyEvent ev) { if (printEventInfo) { System.err.println("Key released event: " + ev); - } + } } - - public void keyTyped(KeyEvent ev) { + + public void keyTyped(KeyEvent ev) { if (printEventInfo) { System.err.println("Key typed event: " + ev); - } + } } - + /** An Animator subclass which renders one frame at the time - * upon calls to the requestRender() method. + * upon calls to the requestRender() method. **/ - public class CustomAnimator extends AnimatorBase { + public class CustomAnimator extends AnimatorBase { private Timer timer = null; private TimerTask task = null; private volatile boolean shouldRun; - + protected String getBaseName(String prefix) { return "Custom" + prefix + "Animator" ; } - - /** Creates an CustomAnimator with an initial drawable to + + /** Creates an CustomAnimator with an initial drawable to * animate. */ public CustomAnimator(GLAutoDrawable drawable) { if (drawable != null) { add(drawable); } } - + public synchronized void requestRender() { shouldRun = true; } - - public final boolean isStarted() { - stateSync.lock(); - try { - return (timer != null); - } finally { - stateSync.unlock(); - } + + public final synchronized boolean isStarted() { + return (timer != null); } - - public final boolean isAnimating() { - stateSync.lock(); - try { - return (timer != null) && (task != null); - } finally { - stateSync.unlock(); - } + + public final synchronized boolean isAnimating() { + return (timer != null) && (task != null); } - + private void startTask() { if(null != task) { return; } - + task = new TimerTask() { private boolean firstRun = true; public void run() { @@ -599,67 +589,57 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { if(CustomAnimator.this.shouldRun) { CustomAnimator.this.animThread = Thread.currentThread(); // display impl. uses synchronized block on the animator instance - display(); + display(); synchronized (this) { // done with current frame. shouldRun = false; - } + } } } }; - + fpsCounter.resetFPSCounter(); shouldRun = false; - + timer.schedule(task, 0, 1); } - + public synchronized boolean start() { if (timer != null) { return false; } - stateSync.lock(); - try { - timer = new Timer(); - startTask(); - } finally { - stateSync.unlock(); - } + timer = new Timer(); + startTask(); return true; } - + /** Stops this CustomAnimator. */ public synchronized boolean stop() { if (timer == null) { return false; } - stateSync.lock(); - try { - shouldRun = false; - if(null != task) { - task.cancel(); - task = null; - } - if(null != timer) { - timer.cancel(); - timer = null; - } - animThread = null; - try { - Thread.sleep(20); // ~ 1/60 hz wait, since we can't ctrl stopped threads - } catch (InterruptedException e) { } - } finally { - stateSync.unlock(); + shouldRun = false; + if(null != task) { + task.cancel(); + task = null; } + if(null != timer) { + timer.cancel(); + timer = null; + } + animThread = null; + try { + Thread.sleep(20); // ~ 1/60 hz wait, since we can't ctrl stopped threads + } catch (InterruptedException e) { } return true; } - - public final boolean isPaused() { return false; } + + public final synchronized boolean isPaused() { return false; } public synchronized boolean resume() { return false; } - public synchronized boolean pause() { return false; } + public synchronized boolean pause() { return false; } } } - + @Test public void test00() { TestGLCanvasAWTActionDeadlock02AWT.MiniPApplet mini; @@ -668,7 +648,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { mini = (TestGLCanvasAWTActionDeadlock02AWT.MiniPApplet) c.newInstance(); } catch (Exception e) { throw new RuntimeException(e); - } + } if (mini != null) { try { mini.run(); @@ -677,7 +657,7 @@ public class TestGLCanvasAWTActionDeadlock02AWT extends UITestCase { } } } - + public static void main(String args[]) { for(int i=0; i Date: Sun, 10 Nov 2013 10:03:30 +0100 Subject: Tests: Align NEWT parenting focus tests (package and class names) using NewtCanvasAWT --- make/scripts/tests-win.bat | 9 +- make/scripts/tests.sh | 14 +- .../test/junit/newt/TestFocus01SwingAWTRobot.java | 245 -------------- .../test/junit/newt/TestFocus02SwingAWTRobot.java | 318 ------------------- .../TestParentingFocus01SwingAWTRobot.java | 245 ++++++++++++++ .../TestParentingFocus02SwingAWTRobot.java | 318 +++++++++++++++++++ .../TestParentingFocus03KeyTraversalAWT.java | 351 +++++++++++++++++++++ .../TestParentingFocusTraversal01AWT.java | 345 -------------------- 8 files changed, 927 insertions(+), 918 deletions(-) delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestFocus02SwingAWTRobot.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocusTraversal01AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index f8a0b4ead..023e7dc6e 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -89,7 +89,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext11VSyncAnimNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.ect.TestExclusiveContext12FPSAnimNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLCanvas01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 %* @@ -130,7 +130,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT -time 50000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting03bAWT -time 100000 -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingOffscreenLayer01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aSWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT %* @@ -138,6 +137,10 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* @@ -149,8 +152,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.nativewindow.TestRecursiveToolkitLockCORE REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.mm.TestScreenMode00aNEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 468672325..08505aea1 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -462,7 +462,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestNEWTCloseX11DisplayBug565 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestAWTCloseX11DisplayBug565 $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT $* @@ -556,8 +556,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEW # #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug -#testawt com.jogamp.opengl.test.junit.newt.TestFocus01SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* @@ -595,7 +593,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEW # #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cSwingAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* @@ -608,6 +605,10 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEW #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* + # # Misc Utils # @@ -665,8 +666,9 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEW # # OSX bugs # -#testawt com.jogamp.opengl.test.junit.newt.TestFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocusTraversal01AWT $* + +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* # test rotation change #testnoawt com.jogamp.opengl.test.junit.newt.mm.TestScreenMode02aNEWT diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java deleted file mode 100644 index 5f3702340..000000000 --- a/src/test/com/jogamp/opengl/test/junit/newt/TestFocus01SwingAWTRobot.java +++ /dev/null @@ -1,245 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ - -package com.jogamp.opengl.test.junit.newt; - -import org.junit.Assert; -import org.junit.AfterClass; -import org.junit.Assume; - -import java.awt.AWTException; -import java.awt.BorderLayout; -import java.awt.Button; -import java.awt.Container; -import java.awt.Robot; -import java.lang.reflect.InvocationTargetException; - -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.swing.JFrame; - -import java.util.ArrayList; -import java.io.IOException; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.FixMethodOrder; -import org.junit.runners.MethodSorters; - -import com.jogamp.newt.awt.NewtCanvasAWT; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; - -import com.jogamp.opengl.test.junit.util.*; - -/** - * Testing focus traversal of an AWT component tree with {@link NewtCanvasAWT} attached. - *

      - * {@link JFrame} . {@link Container}+ . {@link NewtCanvasAWT} . {@link GLWindow} - *

      - *

      - * + Container is the JFrame's implicit root content pane
      - *

      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestFocus01SwingAWTRobot extends UITestCase { - static int width, height; - static long durationPerTest = 10; - static long awtWaitTimeout = 1000; - - static GLCapabilities glCaps; - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glCaps = new GLCapabilities(null); - } - - @AfterClass - public static void release() { - } - - @Test - public void testFocus01ProgrFocus() throws AWTException, InterruptedException, InvocationTargetException { - testFocus01ProgrFocusImpl(null); - } - - @Test - public void testFocus02RobotFocus() throws AWTException, InterruptedException, InvocationTargetException { - Robot robot = new Robot(); - robot.setAutoWaitForIdle(true); - testFocus01ProgrFocusImpl(robot); - } - - private void testFocus01ProgrFocusImpl(Robot robot) throws AWTException, - InvocationTargetException, InterruptedException { - ArrayList eventCountAdapters = new ArrayList(); - - // Create a window. - GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.setTitle("testNewtChildFocus"); - GLEventListener demo1 = new RedSquareES2(); - TestListenerCom01AWT.setDemoFields(demo1, glWindow1, false); - glWindow1.addGLEventListener(demo1); - NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); - glWindow1.addWindowListener(glWindow1FA); - - // Monitor NEWT focus and keyboard events. - NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); - eventCountAdapters.add(glWindow1KA); - glWindow1.addKeyListener(glWindow1KA); - - // Wrap the window in a canvas. - final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - // newtCanvasAWT.setShallUseOffscreenLayer(true); - - // Monitor AWT focus and keyboard events. - AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT"); - newtCanvasAWT.addKeyListener(newtCanvasAWTKA); - eventCountAdapters.add(newtCanvasAWTKA); - AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT"); - newtCanvasAWT.addFocusListener(newtCanvasAWTFA); - - // Add the canvas to a frame, and make it all visible. - final JFrame frame1 = new JFrame("Swing AWT Parent Frame: " - + glWindow1.getTitle()); - frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); - final Button button = new Button("Click me .."); - AWTFocusAdapter buttonFA = new AWTFocusAdapter("Button"); - button.addFocusListener(buttonFA); - AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button"); - button.addKeyListener(buttonKA); - eventCountAdapters.add(buttonKA); - AWTMouseAdapter buttonMA = new AWTMouseAdapter("Button"); - button.addMouseListener(buttonMA); - eventCountAdapters.add(buttonMA); - - frame1.getContentPane().add(button, BorderLayout.NORTH); - frame1.setSize(width, height); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setVisible(true); - } } ); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); - AWTRobotUtil.clearAWTFocus(robot); - Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); - - Thread.sleep(durationPerTest); // manual testing - - int wait=0; - while(wait - * {@link JFrame} . {@link JPanel}+ . {@link Container} . {@link NewtCanvasAWT} . {@link GLWindow} - *

      - *

      - * + JPanel is set as JFrame's root content pane
      - *

      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestFocus02SwingAWTRobot extends UITestCase { - static int width, height; - static long durationPerTest = 10; - static long awtWaitTimeout = 1000; - static GLCapabilities glCaps; - - @BeforeClass - public static void initClass() throws AWTException, InterruptedException, InvocationTargetException { - width = 640; - height = 480; - - final JFrame f = new JFrame(); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - f.setSize(100,100); - f.setVisible(true); - } } ); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - f.dispose(); - } } ); - - glCaps = new GLCapabilities(null); - } - - @AfterClass - public static void release() { - } - - private void testFocus01ProgrFocusImpl(Robot robot) - throws AWTException, InterruptedException, InvocationTargetException { - - ArrayList eventCountAdapters = new ArrayList(); - - GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); - GLEventListener demo1 = new GearsES2(); - glWindow1.addGLEventListener(demo1); - NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); - glWindow1.addWindowListener(glWindow1FA); - NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); - glWindow1.addKeyListener(glWindow1KA); - eventCountAdapters.add(glWindow1KA); - NEWTMouseAdapter glWindow1MA = new NEWTMouseAdapter("GLWindow1"); - glWindow1.addMouseListener(glWindow1MA); - eventCountAdapters.add(glWindow1MA); - - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT"); - newtCanvasAWT.addFocusListener(newtCanvasAWTFA); - AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT"); - newtCanvasAWT.addKeyListener(newtCanvasAWTKA); - eventCountAdapters.add(newtCanvasAWTKA); - AWTMouseAdapter newtCanvasAWTMA = new AWTMouseAdapter("NewtCanvasAWT"); - newtCanvasAWT.addMouseListener(newtCanvasAWTMA); - eventCountAdapters.add(newtCanvasAWTMA); - - Button buttonNorthInner = new Button("north"); - AWTFocusAdapter buttonNorthInnerFA = new AWTFocusAdapter("ButtonNorthInner"); - buttonNorthInner.addFocusListener(buttonNorthInnerFA); - AWTKeyAdapter buttonNorthInnerKA = new AWTKeyAdapter("ButtonNorthInner"); - buttonNorthInner.addKeyListener(buttonNorthInnerKA); - eventCountAdapters.add(buttonNorthInnerKA); - AWTMouseAdapter buttonNorthInnerMA = new AWTMouseAdapter("ButtonNorthInner"); - buttonNorthInner.addMouseListener(buttonNorthInnerMA); - eventCountAdapters.add(buttonNorthInnerMA); - final Container container1 = new Container(); - container1.setLayout(new BorderLayout()); - container1.add(buttonNorthInner, BorderLayout.NORTH); - container1.add(new Button("south"), BorderLayout.SOUTH); - container1.add(new Button("east"), BorderLayout.EAST); - container1.add(new Button("west"), BorderLayout.WEST); - container1.add(newtCanvasAWT, BorderLayout.CENTER); - - Button buttonNorthOuter = new Button("north"); - AWTFocusAdapter buttonNorthOuterFA = new AWTFocusAdapter("ButtonNorthOuter"); - buttonNorthOuter.addFocusListener(buttonNorthOuterFA); - AWTKeyAdapter buttonNorthOuterKA = new AWTKeyAdapter("ButtonNorthOuter"); - buttonNorthOuter.addKeyListener(buttonNorthOuterKA); - eventCountAdapters.add(buttonNorthOuterKA); - AWTMouseAdapter buttonNorthOuterMA = new AWTMouseAdapter("ButtonNorthOuter"); - buttonNorthOuter.addMouseListener(buttonNorthOuterMA); - eventCountAdapters.add(buttonNorthOuterMA); - final JPanel jPanel1 = new JPanel(); - jPanel1.setLayout(new BorderLayout()); - jPanel1.add(buttonNorthOuter, BorderLayout.NORTH); - jPanel1.add(new Button("south"), BorderLayout.SOUTH); - jPanel1.add(new Button("east"), BorderLayout.EAST); - jPanel1.add(new Button("west"), BorderLayout.WEST); - jPanel1.add(container1, BorderLayout.CENTER); - - final JFrame jFrame1 = new JFrame("Swing Parent JFrame"); - // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! - jFrame1.setContentPane(jPanel1); - jFrame1.setSize(width, height); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - jFrame1.setVisible(true); - } } ); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(jFrame1, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); - AWTRobotUtil.clearAWTFocus(robot); - Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, jFrame1)); - - int wait=0; - while(waitmouse-click and programmatic traversal of an AWT component tree with {@link NewtCanvasAWT} attached. + *

      + * {@link JFrame} . {@link Container}+ [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ] + *

      + *

      + * + Container is the JFrame's implicit root content pane
      + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestParentingFocus01SwingAWTRobot extends UITestCase { + static int width, height; + static long durationPerTest = 10; + static long awtWaitTimeout = 1000; + + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + @Test + public void testFocus01ProgrFocus() throws AWTException, InterruptedException, InvocationTargetException { + testFocus01ProgrFocusImpl(null); + } + + @Test + public void testFocus02RobotFocus() throws AWTException, InterruptedException, InvocationTargetException { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + testFocus01ProgrFocusImpl(robot); + } + + private void testFocus01ProgrFocusImpl(Robot robot) throws AWTException, + InvocationTargetException, InterruptedException { + ArrayList eventCountAdapters = new ArrayList(); + + // Create a window. + GLWindow glWindow1 = GLWindow.create(glCaps); + glWindow1.setTitle("testNewtChildFocus"); + GLEventListener demo1 = new RedSquareES2(); + TestListenerCom01AWT.setDemoFields(demo1, glWindow1, false); + glWindow1.addGLEventListener(demo1); + NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + glWindow1.addWindowListener(glWindow1FA); + + // Monitor NEWT focus and keyboard events. + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + eventCountAdapters.add(glWindow1KA); + glWindow1.addKeyListener(glWindow1KA); + + // Wrap the window in a canvas. + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + // newtCanvasAWT.setShallUseOffscreenLayer(true); + + // Monitor AWT focus and keyboard events. + AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT"); + newtCanvasAWT.addKeyListener(newtCanvasAWTKA); + eventCountAdapters.add(newtCanvasAWTKA); + AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT"); + newtCanvasAWT.addFocusListener(newtCanvasAWTFA); + + // Add the canvas to a frame, and make it all visible. + final JFrame frame1 = new JFrame("Swing AWT Parent Frame: " + + glWindow1.getTitle()); + frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); + final Button button = new Button("Click me .."); + AWTFocusAdapter buttonFA = new AWTFocusAdapter("Button"); + button.addFocusListener(buttonFA); + AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button"); + button.addKeyListener(buttonKA); + eventCountAdapters.add(buttonKA); + AWTMouseAdapter buttonMA = new AWTMouseAdapter("Button"); + button.addMouseListener(buttonMA); + eventCountAdapters.add(buttonMA); + + frame1.getContentPane().add(button, BorderLayout.NORTH); + frame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } } ); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); + AWTRobotUtil.clearAWTFocus(robot); + Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); + + Thread.sleep(durationPerTest); // manual testing + + int wait=0; + while(waitmouse-click and programmatic traversal of an AWT component tree with {@link NewtCanvasAWT} attached. + *

      + * {@link JFrame} . {@link JPanel}+ . {@link Container} [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ] + *

      + *

      + * + JPanel is set as JFrame's root content pane
      + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestParentingFocus02SwingAWTRobot extends UITestCase { + static int width, height; + static long durationPerTest = 10; + static long awtWaitTimeout = 1000; + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() throws AWTException, InterruptedException, InvocationTargetException { + width = 640; + height = 480; + + final JFrame f = new JFrame(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f.setSize(100,100); + f.setVisible(true); + } } ); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f.dispose(); + } } ); + + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + private void testFocus01ProgrFocusImpl(Robot robot) + throws AWTException, InterruptedException, InvocationTargetException { + + ArrayList eventCountAdapters = new ArrayList(); + + GLWindow glWindow1 = GLWindow.create(glCaps); + glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); + GLEventListener demo1 = new GearsES2(); + glWindow1.addGLEventListener(demo1); + NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + glWindow1.addWindowListener(glWindow1FA); + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1.addKeyListener(glWindow1KA); + eventCountAdapters.add(glWindow1KA); + NEWTMouseAdapter glWindow1MA = new NEWTMouseAdapter("GLWindow1"); + glWindow1.addMouseListener(glWindow1MA); + eventCountAdapters.add(glWindow1MA); + + NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT"); + newtCanvasAWT.addFocusListener(newtCanvasAWTFA); + AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT"); + newtCanvasAWT.addKeyListener(newtCanvasAWTKA); + eventCountAdapters.add(newtCanvasAWTKA); + AWTMouseAdapter newtCanvasAWTMA = new AWTMouseAdapter("NewtCanvasAWT"); + newtCanvasAWT.addMouseListener(newtCanvasAWTMA); + eventCountAdapters.add(newtCanvasAWTMA); + + Button buttonNorthInner = new Button("north"); + AWTFocusAdapter buttonNorthInnerFA = new AWTFocusAdapter("ButtonNorthInner"); + buttonNorthInner.addFocusListener(buttonNorthInnerFA); + AWTKeyAdapter buttonNorthInnerKA = new AWTKeyAdapter("ButtonNorthInner"); + buttonNorthInner.addKeyListener(buttonNorthInnerKA); + eventCountAdapters.add(buttonNorthInnerKA); + AWTMouseAdapter buttonNorthInnerMA = new AWTMouseAdapter("ButtonNorthInner"); + buttonNorthInner.addMouseListener(buttonNorthInnerMA); + eventCountAdapters.add(buttonNorthInnerMA); + final Container container1 = new Container(); + container1.setLayout(new BorderLayout()); + container1.add(buttonNorthInner, BorderLayout.NORTH); + container1.add(new Button("south"), BorderLayout.SOUTH); + container1.add(new Button("east"), BorderLayout.EAST); + container1.add(new Button("west"), BorderLayout.WEST); + container1.add(newtCanvasAWT, BorderLayout.CENTER); + + Button buttonNorthOuter = new Button("north"); + AWTFocusAdapter buttonNorthOuterFA = new AWTFocusAdapter("ButtonNorthOuter"); + buttonNorthOuter.addFocusListener(buttonNorthOuterFA); + AWTKeyAdapter buttonNorthOuterKA = new AWTKeyAdapter("ButtonNorthOuter"); + buttonNorthOuter.addKeyListener(buttonNorthOuterKA); + eventCountAdapters.add(buttonNorthOuterKA); + AWTMouseAdapter buttonNorthOuterMA = new AWTMouseAdapter("ButtonNorthOuter"); + buttonNorthOuter.addMouseListener(buttonNorthOuterMA); + eventCountAdapters.add(buttonNorthOuterMA); + final JPanel jPanel1 = new JPanel(); + jPanel1.setLayout(new BorderLayout()); + jPanel1.add(buttonNorthOuter, BorderLayout.NORTH); + jPanel1.add(new Button("south"), BorderLayout.SOUTH); + jPanel1.add(new Button("east"), BorderLayout.EAST); + jPanel1.add(new Button("west"), BorderLayout.WEST); + jPanel1.add(container1, BorderLayout.CENTER); + + final JFrame jFrame1 = new JFrame("Swing Parent JFrame"); + // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! + jFrame1.setContentPane(jPanel1); + jFrame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jFrame1.setVisible(true); + } } ); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(jFrame1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); + AWTRobotUtil.clearAWTFocus(robot); + Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, jFrame1)); + + int wait=0; + while(waitkey traversal of an AWT component tree with {@link NewtCanvasAWT} attached. + *

      + * {@link Frame} [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ] + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestParentingFocus03KeyTraversalAWT extends UITestCase { + static Dimension glSize, fSize; + static int numFocus = 8; + static long durationPerTest = numFocus * 200; + static GLCapabilities glCaps; + static boolean manual = false; + static boolean forceGL3 = false; + + @BeforeClass + public static void initClass() { + glSize = new Dimension(200,200); + fSize = new Dimension(300,300); + glCaps = new GLCapabilities( forceGL3 ? GLProfile.get(GLProfile.GL3) : null ); + } + + @Test + public void testWindowParentingAWTFocusTraversal01Onscreen() throws InterruptedException, InvocationTargetException, AWTException { + testWindowParentingAWTFocusTraversal(true); + } + + @Test + public void testWindowParentingAWTFocusTraversal02Offscreen() throws InterruptedException, InvocationTargetException, AWTException { + testWindowParentingAWTFocusTraversal(false); + } + + public void testWindowParentingAWTFocusTraversal(boolean onscreen) throws InterruptedException, InvocationTargetException, AWTException { + Robot robot = new Robot(); + + // Bug 4908075 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4908075 + // Bug 6463168 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6463168 + { + final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + final Set bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); + final AWTKeyStroke newBack = AWTKeyStroke.getAWTKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0, false); + Assert.assertNotNull(newBack); + final Set bwdKeys2 = new HashSet(bwdKeys); + bwdKeys2.add(newBack); + kfm.setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, bwdKeys2); + } + { + final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + final Set fwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); + final Set bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); + Iterator iter; + for(iter = fwdKeys.iterator(); iter.hasNext(); ) { + System.err.println("FTKL.fwd-keys: "+iter.next()); + } + for(iter = bwdKeys.iterator(); iter.hasNext(); ) { + System.err.println("FTKL.bwd-keys: "+iter.next()); + } + } + + final Frame frame1 = new Frame("AWT Parent Frame"); + final Button cWest = new Button("WEST"); + final Button cEast = new Button("EAST"); + final GLWindow glWindow1 = GLWindow.create(glCaps); + glWindow1.setUpdateFPSFrames(1, null); + final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); + newtCanvasAWT1.setPreferredSize(glSize); + newtCanvasAWT1.setShallUseOffscreenLayer(!onscreen); + newtCanvasAWT1.setFocusable(true); + + // Test FocusAdapter + NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + glWindow1.addWindowListener(glWindow1FA); + AWTFocusAdapter bWestFA = new AWTFocusAdapter("WEST"); + cWest.addFocusListener(bWestFA); + AWTFocusAdapter bEastFA = new AWTFocusAdapter("EAST"); + cEast.addFocusListener(bEastFA); + + // Test KeyAdapter + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1.addKeyListener(glWindow1KA); + AWTKeyAdapter bWestKA = new AWTKeyAdapter("West"); + cWest.addKeyListener(bWestKA); + AWTKeyAdapter bEastKA = new AWTKeyAdapter("East"); + cEast.addKeyListener(bEastKA); + + // demo .. + GLEventListener demo1 = new GearsES2(1); + setDemoFields(demo1, glWindow1, false); + glWindow1.addGLEventListener(demo1); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); + glWindow1.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } + if(e.getKeyChar()=='c') { + System.err.println("Focus Clear"); + if(glWindow1.getDelegatedWindow() instanceof DriverClearFocus) { + ((DriverClearFocus)glWindow1.getDelegatedWindow()).clearFocus(); + } + } else if(e.getKeyChar()=='e') { + System.err.println("Focus East"); + try { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + cEast.requestFocusInWindow(); + } + }); + } catch (Exception ex) { ex.printStackTrace(); } + } else if(e.getKeyChar()=='w') { + System.err.println("Focus West"); + try { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + cWest.requestFocusInWindow(); + } + }); + } catch (Exception ex) { ex.printStackTrace(); } + } + } + }); + GLAnimatorControl animator1 = new Animator(glWindow1); + animator1.start(); + + // make frame + frame1.setLayout(new BorderLayout()); + frame1.setLayout(new BorderLayout()); + frame1.add(cWest, BorderLayout.WEST); + frame1.add(newtCanvasAWT1, BorderLayout.CENTER); + frame1.add(cEast, BorderLayout.EAST); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setLocation(0, 0); + frame1.setSize(fSize); + frame1.validate(); + frame1.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); + Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); + AWTRobotUtil.clearAWTFocus(robot); + Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); + + Assert.assertEquals(true, animator1.isAnimating()); + // Assert.assertEquals(false, animator1.isPaused()); + Assert.assertNotNull(animator1.getThread()); + + if(manual) { + Thread.sleep(durationPerTest); + } else { + // + // initial focus on bWest + // + AWTRobotUtil.assertRequestFocusAndWait(robot, cWest, cWest, bWestFA, null); + Thread.sleep(durationPerTest/numFocus); + + // + // forth + // + + // bWest -> glWin + AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, cWest, null); + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + Assert.assertEquals(true, glWindow1FA.focusGained()); + Assert.assertEquals(true, bWestFA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + // glWin -> bEast + AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, glWindow1, null); + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cEast, bEastFA, glWindow1FA)); + Assert.assertEquals(true, bEastFA.focusGained()); + Assert.assertEquals(true, glWindow1FA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + // + // back (using custom back traversal key 'backspace') + // + // bEast -> glWin + AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, cEast, null); + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bEastFA)); + Assert.assertEquals(true, glWindow1FA.focusGained()); + Assert.assertEquals(true, bEastFA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, glWindow1, null); + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); + Assert.assertEquals(true, bWestFA.focusGained()); + Assert.assertEquals(true, glWindow1FA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + System.err.println("Test: Direct NewtCanvasAWT focus"); + try { + java.awt.EventQueue.invokeAndWait(new Runnable() { + public void run() { + newtCanvasAWT1.requestFocus(); + } + }); + } catch (Exception ex) { ex.printStackTrace(); } + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + Assert.assertEquals(true, glWindow1FA.focusGained()); + Assert.assertEquals(true, bWestFA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + System.err.println("Test: Direct AWT Button-West focus"); + try { + java.awt.EventQueue.invokeAndWait(new Runnable() { + public void run() { + cWest.requestFocus(); + } + }); + } catch (Exception ex) { ex.printStackTrace(); } + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); + Assert.assertEquals(true, bWestFA.focusGained()); + Assert.assertEquals(true, glWindow1FA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + System.err.println("Test: Direct NEWT-Child request focus"); + glWindow1.requestFocus(); + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + Assert.assertEquals(true, glWindow1FA.focusGained()); + Assert.assertEquals(true, bWestFA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + } + + animator1.stop(); + Assert.assertEquals(false, animator1.isAnimating()); + Assert.assertEquals(false, animator1.isPaused()); + Assert.assertEquals(null, animator1.getThread()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.dispose(); + } } ); + glWindow1.destroy(); + } + + public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { + Assert.assertNotNull(demo); + Assert.assertNotNull(glWindow); + Window window = glWindow.getDelegatedWindow(); + if(debug) { + MiscUtils.setFieldIfExists(demo, "glDebug", true); + MiscUtils.setFieldIfExists(demo, "glTrace", true); + } + if(!MiscUtils.setFieldIfExists(demo, "window", window)) { + MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); + } + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; i bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); - final AWTKeyStroke newBack = AWTKeyStroke.getAWTKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0, false); - Assert.assertNotNull(newBack); - final Set bwdKeys2 = new HashSet(bwdKeys); - bwdKeys2.add(newBack); - kfm.setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, bwdKeys2); - } - { - final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - final Set fwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); - final Set bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); - Iterator iter; - for(iter = fwdKeys.iterator(); iter.hasNext(); ) { - System.err.println("FTKL.fwd-keys: "+iter.next()); - } - for(iter = bwdKeys.iterator(); iter.hasNext(); ) { - System.err.println("FTKL.bwd-keys: "+iter.next()); - } - } - - final Frame frame1 = new Frame("AWT Parent Frame"); - final Button cWest = new Button("WEST"); - final Button cEast = new Button("EAST"); - final GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.setUpdateFPSFrames(1, null); - final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); - newtCanvasAWT1.setPreferredSize(glSize); - newtCanvasAWT1.setShallUseOffscreenLayer(!onscreen); - newtCanvasAWT1.setFocusable(true); - - // Test FocusAdapter - NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); - glWindow1.addWindowListener(glWindow1FA); - AWTFocusAdapter bWestFA = new AWTFocusAdapter("WEST"); - cWest.addFocusListener(bWestFA); - AWTFocusAdapter bEastFA = new AWTFocusAdapter("EAST"); - cEast.addFocusListener(bEastFA); - - // Test KeyAdapter - NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); - glWindow1.addKeyListener(glWindow1KA); - AWTKeyAdapter bWestKA = new AWTKeyAdapter("West"); - cWest.addKeyListener(bWestKA); - AWTKeyAdapter bEastKA = new AWTKeyAdapter("East"); - cEast.addKeyListener(bEastKA); - - // demo .. - GLEventListener demo1 = new GearsES2(1); - setDemoFields(demo1, glWindow1, false); - glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); - glWindow1.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent e) { - if( !e.isPrintableKey() || e.isAutoRepeat() ) { - return; - } - if(e.getKeyChar()=='c') { - System.err.println("Focus Clear"); - if(glWindow1.getDelegatedWindow() instanceof DriverClearFocus) { - ((DriverClearFocus)glWindow1.getDelegatedWindow()).clearFocus(); - } - } else if(e.getKeyChar()=='e') { - System.err.println("Focus East"); - try { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - cEast.requestFocusInWindow(); - } - }); - } catch (Exception ex) { ex.printStackTrace(); } - } else if(e.getKeyChar()=='w') { - System.err.println("Focus West"); - try { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - cWest.requestFocusInWindow(); - } - }); - } catch (Exception ex) { ex.printStackTrace(); } - } - } - }); - GLAnimatorControl animator1 = new Animator(glWindow1); - animator1.start(); - - // make frame - frame1.setLayout(new BorderLayout()); - frame1.setLayout(new BorderLayout()); - frame1.add(cWest, BorderLayout.WEST); - frame1.add(newtCanvasAWT1, BorderLayout.CENTER); - frame1.add(cEast, BorderLayout.EAST); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setLocation(0, 0); - frame1.setSize(fSize); - frame1.validate(); - frame1.setVisible(true); - }}); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); - Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); - AWTRobotUtil.clearAWTFocus(robot); - Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); - - Assert.assertEquals(true, animator1.isAnimating()); - // Assert.assertEquals(false, animator1.isPaused()); - Assert.assertNotNull(animator1.getThread()); - - if(manual) { - Thread.sleep(durationPerTest); - } else { - // - // initial focus on bWest - // - AWTRobotUtil.assertRequestFocusAndWait(robot, cWest, cWest, bWestFA, null); - Thread.sleep(durationPerTest/numFocus); - - // - // forth - // - - // bWest -> glWin - AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, cWest, null); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); - Assert.assertEquals(true, glWindow1FA.focusGained()); - Assert.assertEquals(true, bWestFA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - // glWin -> bEast - AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, glWindow1, null); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cEast, bEastFA, glWindow1FA)); - Assert.assertEquals(true, bEastFA.focusGained()); - Assert.assertEquals(true, glWindow1FA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - // - // back (using custom back traversal key 'backspace') - // - // bEast -> glWin - AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, cEast, null); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bEastFA)); - Assert.assertEquals(true, glWindow1FA.focusGained()); - Assert.assertEquals(true, bEastFA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, glWindow1, null); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); - Assert.assertEquals(true, bWestFA.focusGained()); - Assert.assertEquals(true, glWindow1FA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - System.err.println("Test: Direct NewtCanvasAWT focus"); - try { - java.awt.EventQueue.invokeAndWait(new Runnable() { - public void run() { - newtCanvasAWT1.requestFocus(); - } - }); - } catch (Exception ex) { ex.printStackTrace(); } - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); - Assert.assertEquals(true, glWindow1FA.focusGained()); - Assert.assertEquals(true, bWestFA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - System.err.println("Test: Direct AWT Button-West focus"); - try { - java.awt.EventQueue.invokeAndWait(new Runnable() { - public void run() { - cWest.requestFocus(); - } - }); - } catch (Exception ex) { ex.printStackTrace(); } - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); - Assert.assertEquals(true, bWestFA.focusGained()); - Assert.assertEquals(true, glWindow1FA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - System.err.println("Test: Direct NEWT-Child request focus"); - glWindow1.requestFocus(); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); - Assert.assertEquals(true, glWindow1FA.focusGained()); - Assert.assertEquals(true, bWestFA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - } - - animator1.stop(); - Assert.assertEquals(false, animator1.isAnimating()); - Assert.assertEquals(false, animator1.isPaused()); - Assert.assertEquals(null, animator1.getThread()); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.dispose(); - } } ); - glWindow1.destroy(); - } - - public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { - Assert.assertNotNull(demo); - Assert.assertNotNull(glWindow); - Window window = glWindow.getDelegatedWindow(); - if(debug) { - MiscUtils.setFieldIfExists(demo, "glDebug", true); - MiscUtils.setFieldIfExists(demo, "glTrace", true); - } - if(!MiscUtils.setFieldIfExists(demo, "window", window)) { - MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); - } - } - - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - - public static void main(String args[]) throws IOException { - for(int i=0; i Date: Sun, 10 Nov 2013 16:08:16 +0100 Subject: Add TestGLWindows03NEWTAnimResize: Test NEWT basic resize while holding position .. (to be refined) --- make/scripts/tests.sh | 3 +- .../junit/newt/TestGLWindows03NEWTAnimResize.java | 138 +++++++++++++++++++++ 2 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows03NEWTAnimResize.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 08505aea1..432f8f346 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -478,6 +478,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* +testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows03NEWTAnimResize $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT @@ -606,7 +607,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* # diff --git a/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows03NEWTAnimResize.java b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows03NEWTAnimResize.java new file mode 100644 index 000000000..026656607 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/TestGLWindows03NEWTAnimResize.java @@ -0,0 +1,138 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt; + + +import java.io.IOException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.newt.event.TraceWindowAdapter; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.Animator; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestGLWindows03NEWTAnimResize extends UITestCase { + static GLProfile glp; + static int step = 4; + static int width, height; + static long durationPerTest = step*500; // ms + + @BeforeClass + public static void initClass() { + width = 800; + height = 600; + glp = GLProfile.getDefault(); + } + + static void test(GLCapabilitiesImmutable caps, boolean undecorated) throws InterruptedException { + Assert.assertNotNull(caps); + + // + // Create native windowing resources .. X11/Win/OSX + // + final GLWindow glWindow = GLWindow.create(caps); + + glWindow.setUpdateFPSFrames(1, null); + Assert.assertNotNull(glWindow); + glWindow.setUndecorated(undecorated); + + GLEventListener demo = new GearsES2(1); + glWindow.addGLEventListener(demo); + glWindow.addWindowListener(new TraceWindowAdapter()); + Assert.assertEquals(false,glWindow.isNativeValid()); + + glWindow.setPosition(100, 100); + glWindow.setSize(width/step, height/step); + Assert.assertEquals(false,glWindow.isVisible()); + glWindow.setVisible(true); + Assert.assertEquals(true,glWindow.isVisible()); + Assert.assertEquals(true,glWindow.isNativeValid()); + + final Animator animator = new Animator(glWindow); + animator.setUpdateFPSFrames(1, null); + Assert.assertTrue(animator.start()); + + int step_i = 0; + for(int i=0; istep_i) { + final int w = width/step * j; + final int h = height/step * j; + System.err.println("resize: "+step_i+" -> "+j+" - "+w+"x"+h); + glWindow.setSize(w, h); + step_i = j; + } + } + Thread.sleep(50); + + animator.stop(); + glWindow.destroy(); + Assert.assertEquals(false, glWindow.isNativeValid()); + Assert.assertEquals(false, glWindow.isVisible()); + } + + @Test + public void test01WindowDecor() throws InterruptedException { + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + test(caps, false /* undecorated */); + } + + @Test + public void test02WindowUndecor() throws InterruptedException { + GLCapabilities caps = new GLCapabilities(glp); + Assert.assertNotNull(caps); + test(caps, true /* undecorated */); + } + + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Sun, 10 Nov 2013 20:59:03 +0100 Subject: Fix Bug 889 [Related: Bug 816, Bug 849, Bug 729] - GLCanvas disappear when moves between two JFrame When JAWTWindow's visibility tracker updates component's local visibility, it should read it's local visibility state instead 'trusting' the passed state. Make JAWTWindow's visibility tracker DEBUG output more brief for readability. --- make/scripts/tests.sh | 3 +- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 31 ++- .../TestBug816GLCanvasFrameHoppingB849B889AWT.java | 262 +++++++++++++++++++++ .../jogl/awt/TestBug816OSXCALayerPos01AWT.java | 87 ++++--- .../jogl/awt/TestBug816OSXCALayerPos02AWT.java | 43 ++-- .../awt/TestBug816OSXCALayerPos03aB729AWT.java | 35 ++- .../awt/TestBug816OSXCALayerPos03bB849AWT.java | 35 ++- .../awt/TestBug816OSXCALayerPos03cB849AWT.java | 37 ++- 8 files changed, 401 insertions(+), 132 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816GLCanvasFrameHoppingB849B889AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 432f8f346..b7db47e11 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -478,7 +478,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* -testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows03NEWTAnimResize $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows03NEWTAnimResize $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle02NEWT @@ -504,6 +504,7 @@ testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows03NEWTAnimResize $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index a99737613..87966c9c6 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -124,21 +124,32 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, private boolean globalVisibility = localVisibility; private boolean visibilityPropagation = false; - private String id(Object obj) { return "0x"+Integer.toHexString(obj.hashCode()); } + private String id(Object obj) { return "0x" + ( null!=obj ? Integer.toHexString(obj.hashCode()) : "nil" ); } + private String str(Object obj) { + if( null == obj ) { + return "null"; + } else if( obj instanceof Component ) { + final Component c = (Component)obj; + return c.getClass().getSimpleName()+"[visible "+c.isVisible()+", showing "+c.isShowing()+", valid "+c.isValid()+ + ", displayable "+c.isDisplayable()+", "+c.getX()+"/"+c.getY()+" "+c.getWidth()+"x"+c.getHeight()+"]"; + } else { + return obj.getClass().getSimpleName()+"[..]"; + } + } private String s(ComponentEvent e) { return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"],"+Platform.getNewline()+ - " ** COMP "+id(e.getComponent())+": "+e.getComponent()+Platform.getNewline()+ - " ** SOURCE "+id(e.getSource())+": "+e.getSource()+Platform.getNewline()+ - " ** THIS "+component; + " ** COMP "+id(e.getComponent())+": "+str(e.getComponent())+Platform.getNewline()+ + " ** SOURCE "+id(e.getSource())+": "+str(e.getSource())+Platform.getNewline()+ + " ** THIS "+id(component)+": "+str(component); } private String s(HierarchyEvent e) { return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"], changeBits 0x"+Long.toHexString(e.getChangeFlags())+Platform.getNewline()+ - " ** COMP "+id(e.getComponent())+": "+e.getComponent()+Platform.getNewline()+ - " ** SOURCE "+id(e.getSource())+": "+e.getSource()+Platform.getNewline()+ - " ** CHANGED "+id(e.getChanged())+": "+e.getChanged()+Platform.getNewline()+ - " ** CHANGEDPARENT "+id(e.getChangedParent())+": "+e.getChangedParent()+Platform.getNewline()+ - " ** THIS "+component; + " ** COMP "+id(e.getComponent())+": "+str(e.getComponent())+Platform.getNewline()+ + " ** SOURCE "+id(e.getSource())+": "+str(e.getSource())+Platform.getNewline()+ + " ** CHANGED "+id(e.getChanged())+": "+str(e.getChanged())+Platform.getNewline()+ + " ** CHANGEDPARENT "+id(e.getChangedParent())+": "+str(e.getChangedParent())+Platform.getNewline()+ + " ** THIS "+id(component)+": "+str(component); } @Override @@ -207,7 +218,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } else if( changed == component ) { // Update component's local visibility state if(!visibilityPropagation) { - localVisibility = showing; + localVisibility = component.isVisible(); } visibilityPropagation = false; if(DEBUG) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816GLCanvasFrameHoppingB849B889AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816GLCanvasFrameHoppingB849B889AWT.java new file mode 100644 index 000000000..51d00a5a1 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816GLCanvasFrameHoppingB849B889AWT.java @@ -0,0 +1,262 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.awt; + +import java.awt.BorderLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLCanvas; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.Assert; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.AWTRobotUtil; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Moving GLCanvas between 2 AWT JFrame + *

      + * Validates bugs: + *

        + *
      • Bug 816: OSX CALayer Positioning Bug
      • + *
      • Bug 729: OSX CALayer shall honor the Component's visibility state
      • + *
      • Bug 849: AWT GLAutoDrawables (JAWTWindow) shall honor it's parent visibility state
      • + *
      • Bug 878: JAWTWindow's HierarchyListener doesn't set component visible (again) on 'addNotify(..)' - GLCanvas in JtabbedPane disappear
      • + *
      • Bug 889: GLCanvas disappear when moves between two JFrame
      • + *
      + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestBug816GLCanvasFrameHoppingB849B889AWT extends UITestCase { + static long durationPerTest = 500*4; // ms + static boolean manual = false; + + @Test + public void test01AllVisible() throws InterruptedException, InvocationTargetException { + test(false); + } + + @Test + public void test02VisibleWithCanvas() throws InterruptedException, InvocationTargetException { + test(true); + } + + private void test(final boolean onlyVisibleWithCanvas) throws InterruptedException, InvocationTargetException { + final JFrame frame1 = new JFrame("Bug889 #1"); + final JPanel panel1 = new javax.swing.JPanel(); + panel1.setLayout(new BorderLayout()); + panel1.setSize(new java.awt.Dimension(640, 480)); + frame1.setContentPane(panel1); + frame1.setSize(640, 480); + frame1.setLocation(64, 64); + + final JFrame frame2 = new JFrame("Bug889 #2"); + final JPanel panel2 = new javax.swing.JPanel(); + panel2.setLayout(new BorderLayout()); + panel2.setSize(new java.awt.Dimension(640, 480)); + frame2.setContentPane(panel2); + frame2.setSize(640, 480); + frame2.setLocation(800, 64); + + GLProfile profile = GLProfile.get(GLProfile.GL2ES2); + GLCapabilities glCapabilities = new GLCapabilities(profile); + final GLCanvas glCanvas = new GLCanvas(glCapabilities); + glCanvas.setSize(new java.awt.Dimension(640, 480)); + glCanvas.addGLEventListener(new GearsES2(1)); + panel1.add(glCanvas, BorderLayout.CENTER); + + JButton bMoveP1toP2 = new JButton("Move to Panel2"); + bMoveP1toP2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(java.awt.event.ActionEvent evt) { + System.err.println("XXXX Move P1 -> P2 - START"); + dumpGLCanvasStats(glCanvas); + panel2.add(glCanvas, BorderLayout.CENTER); + if( onlyVisibleWithCanvas ) { + frame1.setVisible(false); + frame2.setVisible(true); + frame2.toFront(); + } else { + frame1.validate(); + frame2.validate(); + } + dumpGLCanvasStats(glCanvas); + System.err.println("XXXX Move P1 -> P2 - END"); + } + }); + panel1.add(bMoveP1toP2, BorderLayout.NORTH); + + JButton bMoveP2toP1 = new JButton("Move to Panel1"); + bMoveP2toP1.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + System.err.println("XXXX Move P2 -> P1 - START"); + dumpGLCanvasStats(glCanvas); + panel1.add(glCanvas, BorderLayout.CENTER); + if( onlyVisibleWithCanvas ) { + frame2.setVisible(false); + frame1.setVisible(true); + frame1.toFront(); + } else { + frame2.validate(); + frame1.validate(); + } + dumpGLCanvasStats(glCanvas); + System.err.println("XXXX Move P2 -> P1 - END"); + } + }); + panel2.add(bMoveP2toP1, BorderLayout.NORTH); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + // frame1.pack(); + System.err.println("XXX SetVisible ON XXX GLCanvas on Panel1("+id(panel1)+")"); + if( onlyVisibleWithCanvas ) { + frame1.setVisible(true); + } else { + frame1.setVisible(true); + frame2.setVisible(true); + } + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glCanvas, true)); + dumpGLCanvasStats(glCanvas); + + if(manual) { + for(long w=durationPerTest; w>0; w-=100) { + Thread.sleep(100); + } + } else { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + System.err.println("XXXX Add GLCanvas Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); + dumpGLCanvasStats(glCanvas); + panel2.add(glCanvas, BorderLayout.CENTER); + if( onlyVisibleWithCanvas ) { + frame1.setVisible(false); + frame2.setVisible(true); + frame2.toFront(); + } else { + frame1.validate(); + frame2.validate(); + } + dumpGLCanvasStats(glCanvas); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + System.err.println("XXXX Add GLCanvas Panel2("+id(panel2)+") -> Panel1("+id(panel1)+" START"); + dumpGLCanvasStats(glCanvas); + panel1.add(glCanvas, BorderLayout.CENTER); + if( onlyVisibleWithCanvas ) { + frame2.setVisible(false); + frame1.setVisible(true); + frame1.toFront(); + } else { + frame2.validate(); + frame1.validate(); + } + dumpGLCanvasStats(glCanvas); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + System.err.println("XXXX Add GLCanvas Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); + dumpGLCanvasStats(glCanvas); + panel2.add(glCanvas, BorderLayout.CENTER); + if( onlyVisibleWithCanvas ) { + frame1.setVisible(false); + frame2.setVisible(true); + frame2.toFront(); + } else { + frame1.validate(); + frame2.validate(); + } + dumpGLCanvasStats(glCanvas); + }}); + Thread.sleep(durationPerTest/4); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + System.err.println("XXXX Add GLCanvas Panel2("+id(panel2)+") -> Panel1("+id(panel1)+" START"); + dumpGLCanvasStats(glCanvas); + panel1.add(glCanvas, BorderLayout.CENTER); + if( onlyVisibleWithCanvas ) { + frame2.setVisible(false); + frame1.setVisible(true); + frame1.toFront(); + } else { + frame2.validate(); + frame1.validate(); + } + dumpGLCanvasStats(glCanvas); + }}); + Thread.sleep(durationPerTest/4); + } + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + System.err.println("XXX SetVisible OFF XXX"); + frame1.dispose(); + frame2.dispose(); + } }); + } + + private static String id(Object obj) { return "0x"+Integer.toHexString(obj.hashCode()); } + + static void dumpGLCanvasStats(GLCanvas glCanvas) { + System.err.println("XXXX GLCanvas: comp "+glCanvas+", visible "+glCanvas.isVisible()+", showing "+glCanvas.isShowing()+ + ", displayable "+glCanvas.isDisplayable()+", "+glCanvas.getWidth()+"x"+glCanvas.getHeight()); + } + + public static void main(String args[]) { + for(int i=0; i Date: Thu, 14 Nov 2013 13:52:43 +0100 Subject: Bug 904 - GLJPanel: Allow user to skip isGLOriented() based vertical flip of offscreen backend Add new GLJPanel method 'setSkipGLOrientationVerticalFlip(..)': /** * Set skipping {@link #isGLOriented()} based vertical flip, * which usually is required by the offscreen backend, * see details about vertical flip * and FBO / GLSL vertical flip. *

      * If set to true, user needs to flip the OpenGL rendered scene * if {@link #isGLOriented()} == true, e.g. via the PMV matrix.
      * See constraints of {@link #isGLOriented()}. *

      */ public final void setSkipGLOrientationVerticalFlip(boolean v) { GearsES2: Handles 'flipVerticalInGLOrientation' Unit test 'TestPerf001GLJPanelInit02AWT' validates and measures performance. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 113 +++++++++------ .../opengl/test/junit/jogl/demos/es2/GearsES2.java | 30 ++-- .../jogl/perf/TestPerf001GLJPanelInit02AWT.java | 153 +++++++++++++++------ 5 files changed, 213 insertions(+), 91 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 023e7dc6e..2fd401f00 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -24,7 +24,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT %* @@ -138,7 +138,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslu REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b7db47e11..bed169737 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -350,7 +350,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # @@ -504,7 +504,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 8dd335267..011b14321 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -121,16 +121,17 @@ import com.jogamp.opengl.util.texture.TextureState; using {@link GLDrawableFactory#createOffscreenDrawable(AbstractGraphicsDevice, GLCapabilitiesImmutable, GLCapabilitiesChooser, int, int) GLDrawableFactory.createOffscreenDrawable(..)}.

      - In case FBO is used and GLSL is available, a fragment shader is utilized - to flip the FBO texture vertically. This hardware-accelerated step can be disabled via system property jogl.gljpanel.noglsl. - See details here. + + In case the drawable {@link #isGLOriented()} and {@link #setSkipGLOrientationVerticalFlip(boolean) vertical flip is not skipped}, + this component performs the required vertical flip to bring the content from OpenGL's orientation into AWT's orientation. + See details about FBO and GLSL vertical flipping.

      The OpenGL path is concluded by copying the rendered pixels an {@link BufferedImage} via {@link GL#glReadPixels(int, int, int, int, int, int, java.nio.Buffer) glReadPixels(..)} for later Java2D composition.

      - In case the above mentioned GLSL vertical-flipping is not performed, + In case {@link #setSkipGLOrientationVerticalFlip(boolean) vertical-flip is not skipped} and GLSL based vertical-flip is not performed, {@link System#arraycopy(Object, int, Object, int, int) System.arraycopy(..)} is used line by line. This step causes more CPU load per frame and is not hardware-accelerated.

      @@ -143,8 +144,12 @@ import com.jogamp.opengl.util.texture.TextureState; *

      *
      FBO / GLSL Vertical Flip
      + In case FBO is used and GLSL is available and {@link #setSkipGLOrientationVerticalFlip(boolean) vertical flip is not skipped}, a fragment shader is utilized + to flip the FBO texture vertically. This hardware-accelerated step can be disabled via system property jogl.gljpanel.noglsl. +

      The FBO / GLSL code path uses one texture-unit and binds the FBO texture to it's active texture-target, see {@link #setTextureUnit(int)} and {@link #getTextureUnit()}. +

      The active and dedicated texture-unit's {@link GL#GL_TEXTURE_2D} state is preserved via {@link TextureState}. See also {@link Texture#textureCallOrder Order of Texture Commands}. @@ -248,6 +253,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // The backend in use private volatile Backend backend; + private boolean skipGLOrientationVerticalFlip = false; + // Used by all backends either directly or indirectly to hook up callbacks private final Updater updater = new Updater(); @@ -648,7 +655,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } - printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); + printAWTTiles.setIsGLOriented( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented() ); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { @@ -981,6 +988,15 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return oglPipelineUsable(); } + /** + * {@inheritDoc} + *

      + * Method returns a valid value only after + * the backend has been initialized, either {@link #initializeBackend(boolean) eagerly} + * or manually via the first display call.
      + * Method always returns a valid value when called from within a {@link GLEventListener}. + *

      + */ @Override public boolean isGLOriented() { final Backend b = backend; @@ -990,6 +1006,25 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return b.getDrawable().isGLOriented(); } + /** + * Set skipping {@link #isGLOriented()} based vertical flip, + * which usually is required by the offscreen backend, + * see details about vertical flip + * and FBO / GLSL vertical flip. + *

      + * If set to true, user needs to flip the OpenGL rendered scene + * if {@link #isGLOriented()} == true, e.g. via the PMV matrix.
      + * See constraints of {@link #isGLOriented()}. + *

      + */ + public final void setSkipGLOrientationVerticalFlip(boolean v) { + skipGLOrientationVerticalFlip = v; + } + /** See {@link #setSkipGLOrientationVerticalFlip(boolean)}. */ + public final boolean getSkipGLOrientationVerticalFlip() { + return skipGLOrientationVerticalFlip; + } + @Override public GLCapabilitiesImmutable getChosenGLCapabilities() { final Backend b = backend; @@ -1372,10 +1407,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public boolean isUsingOwnLifecycle() { return false; } + public final boolean isUsingOwnLifecycle() { return false; } @Override - public void initialize() { + public final void initialize() { if(DEBUG) { System.err.println(getThreadName()+": OffscreenBackend: initialize()"); } @@ -1395,7 +1430,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { isInitialized = true; final GL gl = offscreenContext.getGL(); - flipVertical = offscreenDrawable.isGLOriented(); + flipVertical = !GLJPanel.this.skipGLOrientationVerticalFlip && offscreenDrawable.isGLOriented(); final GLCapabilitiesImmutable chosenCaps = offscreenDrawable.getChosenGLCapabilities(); offscreenIsFBO = chosenCaps.isFBO(); final boolean glslCompliant = !offscreenContext.hasRendererQuirk(GLRendererQuirks.GLSLNonCompliant); @@ -1454,7 +1489,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void destroy() { + public final void destroy() { if(DEBUG) { System.err.println(getThreadName()+": OffscreenBackend: destroy() - offscreenContext: "+(null!=offscreenContext)+" - offscreenDrawable: "+(null!=offscreenDrawable)); } @@ -1502,7 +1537,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void setOpaque(boolean opaque) { + public final void setOpaque(boolean opaque) { if ( opaque != isOpaque() && !useSingletonBuffer ) { pixelBuffer.dispose(); pixelBuffer = null; @@ -1511,13 +1546,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public boolean preGL(Graphics g) { + public final boolean preGL(Graphics g) { // Empty in this implementation return true; } @Override - public void postGL(Graphics g, boolean isDisplay) { + public final void postGL(Graphics g, boolean isDisplay) { if (isDisplay) { final GL gl = offscreenContext.getGL(); @@ -1671,7 +1706,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public int getTextureUnit() { + public final int getTextureUnit() { if(null != glslTextureRaster && null != offscreenDrawable) { // implies flippedVertical return ((GLFBODrawable)offscreenDrawable).getTextureUnit(); } @@ -1679,7 +1714,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void doPaintComponent(Graphics g) { + public final void doPaintComponent(Graphics g) { helper.invokeGL(offscreenDrawable, offscreenContext, updaterDisplayAction, updaterInitAction); if ( null != alignedImage ) { @@ -1689,12 +1724,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void doPlainPaint() { + public final void doPlainPaint() { helper.invokeGL(offscreenDrawable, offscreenContext, updaterPlainDisplayAction, updaterInitAction); } @Override - public boolean handleReshape() { + public final boolean handleReshape() { GLDrawableImpl _drawable = offscreenDrawable; { final GLDrawableImpl _drawableNew = GLDrawableHelper.resizeOffscreenDrawable(_drawable, offscreenContext, panelWidth, panelHeight); @@ -1725,27 +1760,27 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public GLContext createContext(GLContext shareWith) { + public final GLContext createContext(GLContext shareWith) { return (null != offscreenDrawable) ? offscreenDrawable.createContext(shareWith) : null; } @Override - public void setContext(GLContext ctx) { + public final void setContext(GLContext ctx) { offscreenContext=(GLContextImpl)ctx; } @Override - public GLContext getContext() { + public final GLContext getContext() { return offscreenContext; } @Override - public GLDrawable getDrawable() { + public final GLDrawable getDrawable() { return offscreenDrawable; } @Override - public GLCapabilitiesImmutable getChosenGLCapabilities() { + public final GLCapabilitiesImmutable getChosenGLCapabilities() { if (offscreenDrawable == null) { return null; } @@ -1753,7 +1788,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public GLProfile getGLProfile() { + public final GLProfile getGLProfile() { if (offscreenDrawable == null) { return null; } @@ -1811,10 +1846,10 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private GraphicsConfiguration workaroundConfig; @Override - public boolean isUsingOwnLifecycle() { return true; } + public final boolean isUsingOwnLifecycle() { return true; } @Override - public void initialize() { + public final void initialize() { if(DEBUG) { System.err.println(getThreadName()+": J2DOGL: initialize()"); } @@ -1823,7 +1858,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void destroy() { + public final void destroy() { Java2D.invokeWithOGLContextCurrent(null, new Runnable() { @Override public void run() { @@ -1844,12 +1879,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void setOpaque(boolean opaque) { + public final void setOpaque(boolean opaque) { // Empty in this implementation } @Override - public GLContext createContext(GLContext shareWith) { + public final GLContext createContext(GLContext shareWith) { if(null != shareWith) { throw new GLException("J2DOGLBackend cannot create context w/ additional shared context, since it already needs to share the context w/ J2D."); } @@ -1857,43 +1892,43 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void setContext(GLContext ctx) { + public final void setContext(GLContext ctx) { joglContext=ctx; } @Override - public GLContext getContext() { + public final GLContext getContext() { return joglContext; } @Override - public GLDrawable getDrawable() { + public final GLDrawable getDrawable() { return joglDrawable; } @Override - public int getTextureUnit() { return -1; } + public final int getTextureUnit() { return -1; } @Override - public GLCapabilitiesImmutable getChosenGLCapabilities() { + public final GLCapabilitiesImmutable getChosenGLCapabilities() { // FIXME: should do better than this; is it possible to using only platform-independent code? return new GLCapabilities(null); } @Override - public GLProfile getGLProfile() { + public final GLProfile getGLProfile() { // FIXME: should do better than this; is it possible to using only platform-independent code? return GLProfile.getDefault(GLProfile.getDefaultDevice()); } @Override - public boolean handleReshape() { + public final boolean handleReshape() { // Empty in this implementation return true; } @Override - public boolean preGL(Graphics g) { + public final boolean preGL(Graphics g) { final GL2 gl = joglContext.getGL().getGL2(); // Set up needed state in JOGL context from Java2D context gl.glEnable(GL2.GL_SCISSOR_TEST); @@ -2030,7 +2065,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void postGL(Graphics g, boolean isDisplay) { + public final void postGL(Graphics g, boolean isDisplay) { // Cause OpenGL pipeline to flush its results because // otherwise it's possible we will buffer up multiple frames' // rendering results, resulting in apparent mouse lag @@ -2047,7 +2082,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void doPaintComponent(final Graphics g) { + public final void doPaintComponent(final Graphics g) { // This is a workaround for an issue in the Java 2D / JOGL // bridge (reported by an end user as JOGL Issue 274) where Java // 2D can occasionally leave its internal OpenGL context current @@ -2196,11 +2231,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void doPlainPaint() { + public final void doPlainPaint() { helper.invokeGL(joglDrawable, joglContext, updaterPlainDisplayAction, updaterInitAction); } - private void captureJ2DState(GL gl, Graphics g) { + private final void captureJ2DState(GL gl, Graphics g) { gl.glGetIntegerv(GL2.GL_DRAW_BUFFER, drawBuffer, 0); gl.glGetIntegerv(GL2.GL_READ_BUFFER, readBuffer, 0); if (Java2D.isFBOEnabled() && diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java index 3d7db0465..ff5de7cb0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/GearsES2.java @@ -61,6 +61,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL private GLUniformData pmvMatrixUniform = null; private GLUniformData colorU = null; private float view_rotx = 20.0f, view_roty = 30.0f; + private boolean flipVerticalInGLOrientation = false; private final float view_rotz = 0.0f; private float panX = 0.0f, panY = 0.0f, panZ=0.0f; @@ -119,6 +120,7 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void setDoRotation(boolean rotate) { this.doRotate = rotate; } public void setClearBuffers(boolean v) { clearBuffers = v; } public void setVerbose(boolean v) { verbose = v; } + public void setFlipVerticalInGLOrientation(boolean v) { flipVerticalInGLOrientation=v; } public void setPMVUseBackingArray(boolean pmvUseBackingArray) { this.pmvUseBackingArray = pmvUseBackingArray; @@ -186,10 +188,10 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL drawable.setGLEventListenerInitState(this, false); return; } - System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+": tileRendererInUse "+tileRendererInUse); final GL2ES2 gl = drawable.getGL().getGL2ES2(); if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+": tileRendererInUse "+tileRendererInUse); System.err.println("GearsES2 init "+sid()+" on "+Thread.currentThread()); System.err.println("Chosen GLCapabilities: " + drawable.getChosenGLCapabilities()); System.err.println("INIT GL IS: " + gl.getClass().getName()); @@ -307,7 +309,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL gl.glFinish(); // make sure .. for shared context (impacts OSX 10.9) isInit = true; - System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+" FIN "+this); + if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.init "+sid()+" FIN "+this); + } } public final boolean isInit() { return isInit; } @@ -343,7 +347,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL void reshapeImpl(GL2ES2 gl, int tileX, int tileY, int tileWidth, int tileHeight, int imageWidth, int imageHeight) { final boolean msaa = gl.getContext().getGLDrawable().getChosenGLCapabilities().getSampleBuffers(); - System.err.println(Thread.currentThread()+" GearsES2.reshape "+sid()+" "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); + if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.reshape "+sid()+" "+tileX+"/"+tileY+" "+tileWidth+"x"+tileHeight+" of "+imageWidth+"x"+imageHeight+", swapInterval "+swapInterval+", drawable 0x"+Long.toHexString(gl.getContext().getGLDrawable().getHandle())+", msaa "+msaa+", tileRendererInUse "+tileRendererInUse); + } if( !gl.hasGLSL() ) { return; @@ -388,6 +394,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL pmvMatrix.glMatrixMode(PMVMatrix.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0.0f, 0.0f, -40.0f); + if(flipVerticalInGLOrientation && gl.getContext().getGLDrawable().isGLOriented() ) { + pmvMatrix.glRotatef(180f, 1.0f, 0.0f, 0.0f); + } st.uniform(gl, pmvMatrixUniform); st.useProgram(gl, false); @@ -399,7 +408,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL public void dispose(GLAutoDrawable drawable) { if( !isInit ) { return; } isInit = false; - System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+": tileRendererInUse "+tileRendererInUse); + if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+": tileRendererInUse "+tileRendererInUse); + } final Object upstreamWidget = drawable.getUpstreamWidget(); if (upstreamWidget instanceof Window) { final Window window = (Window) upstreamWidget; @@ -425,7 +436,9 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.destroy(gl); st = null; - System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+" FIN"); + if(verbose) { + System.err.println(Thread.currentThread()+" GearsES2.dispose "+sid()+" FIN"); + } } @Override @@ -482,9 +495,10 @@ public class GearsES2 implements GLEventListener, TileRendererBase.TileRendererL st.useProgram(gl, true); pmvMatrix.glPushMatrix(); pmvMatrix.glTranslatef(panX, panY, panZ); - pmvMatrix.glRotatef(view_rotx, 1.0f, 0.0f, 0.0f); - pmvMatrix.glRotatef(view_roty, 0.0f, 1.0f, 0.0f); - pmvMatrix.glRotatef(view_rotz, 0.0f, 0.0f, 1.0f); + final float flipVF = ( flipVerticalInGLOrientation && drawable.isGLOriented() ) ? -1f : 1f; + pmvMatrix.glRotatef(flipVF*view_rotx, 1.0f, 0.0f, 0.0f); + pmvMatrix.glRotatef(flipVF*view_roty, 0.0f, 1.0f, 0.0f); + pmvMatrix.glRotatef(flipVF*view_rotz, 0.0f, 0.0f, 1.0f); gear1.draw(gl, -3.0f, -2.0f, 1f * angle - 0f); gear2.draw(gl, 3.1f, -2.0f, -2f * angle - 9.0f); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java index 18ec289d8..3133a449d 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java @@ -69,10 +69,16 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { GLProfile.initSingleton(); } - public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final int width, final int height, - final int frameCount, final boolean initMT, final boolean useGLJPanel, final boolean useGLCanvas, - final boolean useAnim, final boolean overlap) { - final GLAnimatorControl animator = useAnim ? new Animator() : null; + public void test(final GLCapabilitiesImmutable caps, final boolean useGears, final boolean skipGLOrientationVerticalFlip, final int width, + final int height, final int frameCount, final boolean initMT, final boolean useGLJPanel, + final boolean useSwingDoubleBuffer, final boolean useGLCanvas, final boolean useAnim, final boolean overlap) { + final GLAnimatorControl animator; + if( useAnim ) { + animator = new Animator(); + animator.start(); + } else { + animator = null; + } final int eWidth, eHeight; { final int cols = (int)Math.round(Math.sqrt(frameCount)); @@ -81,7 +87,7 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { eHeight = height/rows-32; } System.err.println("Frame size: "+width+"x"+height+" -> "+frameCount+" x "+eWidth+"x"+eHeight+", overlap "+overlap); - + System.err.println("SkipGLOrientationVerticalFlip "+skipGLOrientationVerticalFlip+", useGears "+useGears+", initMT "+initMT+", useAnim "+useAnim); final JFrame[] frame = new JFrame[frameCount]; final long[] t = new long[10]; if( wait ) { @@ -106,9 +112,10 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { } final JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); + panel.setDoubleBuffered(useSwingDoubleBuffer); // panel.setBounds(0, 0, width, height); final Dimension eSize = new Dimension(eWidth, eHeight); - final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(initMT, caps, useGears, animator, eSize) : ( useGLCanvas ? createGLCanvas(caps, useGears, animator, eSize) : null ); + final GLAutoDrawable glad = useGLJPanel ? createGLJPanel(initMT, useSwingDoubleBuffer, caps, useGears, skipGLOrientationVerticalFlip, animator, eSize) : ( useGLCanvas ? createGLCanvas(caps, useGears, animator, eSize) : null ); if( null != glad ) { glad.addGLEventListener(new GLEventListener() { @Override @@ -218,19 +225,26 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { canvas.setSize(size); canvas.setPreferredSize(size); if( useGears ) { - canvas.addGLEventListener(new GearsES2()); + final GearsES2 g = new GearsES2(0); + g.setVerbose(false); + canvas.addGLEventListener(g); } if( null != anim ) { anim.add(canvas); } return canvas; } - private GLAutoDrawable createGLJPanel(boolean initMT, GLCapabilitiesImmutable caps, boolean useGears, GLAnimatorControl anim, Dimension size) { + private GLAutoDrawable createGLJPanel(boolean initMT, boolean useSwingDoubleBuffer, GLCapabilitiesImmutable caps, boolean useGears, boolean skipGLOrientationVerticalFlip, GLAnimatorControl anim, Dimension size) { GLJPanel canvas = new GLJPanel(caps); canvas.setSize(size); canvas.setPreferredSize(size); + canvas.setDoubleBuffered(useSwingDoubleBuffer); + canvas.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); if( useGears ) { - canvas.addGLEventListener(new GearsES2()); + final GearsES2 g = new GearsES2(0); + g.setVerbose(false); + g.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + canvas.addGLEventListener(g); } if( null != anim ) { anim.add(canvas); @@ -243,66 +257,116 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { static GLCapabilitiesImmutable caps = null; + // + // NOP + // + @Test public void test00NopNoGLDefGrid() throws InterruptedException, InvocationTargetException { - test(null, false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); } @Test public void test01NopGLCanvasDefGrid() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, - true /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + } + + @Test + public void test02NopGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + } + + @Test + public void test03NopGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + } + + @Test + public void test04GearsGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + } + + // + // Gears + // + + @Test + public void test10GearsNoGLDefGrid() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + } + + @Test + public void test11GearsGLCanvasDefGrid() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + } + + @Test + public void test12GearsGLJPanelDefGridSingleAutoFlip() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), true /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); } @Test - public void test02NopGLJPanelDefGridSingle() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + public void test13GearsGLJPanelDefGridSingleManualFlip() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); } @Test - public void test03NopGLJPanelDefGridMT() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, true /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); + public void test14GearsGLJPanelDefGridMTManualFlip() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), true /*useGears*/, true /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false /* overlap */); } + + // + // Overlap + NOP + // + + @Test - public void test10NopNoGLDefOverlap() throws InterruptedException, InvocationTargetException { - test(null, false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + public void test20NopNoGLDefOverlap() throws InterruptedException, InvocationTargetException { + test(null, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); } @Test - public void test11NopGLCanvasDefOverlap() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, false /* useGLJPanel */, - true /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + public void test21NopGLCanvasDefOverlap() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + false /* useGLJPanel */, false /*useSwingDoubleBuffer*/, true /* useGLCanvas */, false /*useAnim*/, true /* overlap */); } @Test - public void test12NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + public void test22NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); } @Test - public void test13NopGLJPanelDefOverlapMT() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, true /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + public void test23NopGLJPanelDefOverlapMT() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, true /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); } // @Test - public void test04NopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException { - test(new GLCapabilities(null), false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); + public void testXXNopGLJPanelDefOverlapSingle() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, true /* overlap */); } // @Test - public void test05NopGLJPanelBitmapGridSingle() throws InterruptedException, InvocationTargetException { + public void testXXNopGLJPanelBitmapGridSingle() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(null); caps.setBitmap(true); - test(caps, false /*useGears*/, width, height , frameCount, false /* initMT */, true /* useGLJPanel */, - false /* useGLCanvas */, false /*useAnim*/, false); + test(caps, false /*useGears*/, false /*skipGLOrientationVerticalFlip*/, width , height, frameCount, false /* initMT */, + true /* useGLJPanel */, false /*useSwingDoubleBuffer*/, false /* useGLCanvas */, false /*useAnim*/, false); } static long duration = 0; // ms @@ -312,9 +376,11 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { volatile int initCount = 0; public static void main(String[] args) { - boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useGears = false, manual=false; - boolean overlap = false; + boolean manual=false; boolean waitMain = false; + boolean useGLJPanel = true, initMT = false, useGLCanvas = false, useSwingDoubleBuffer=false; + boolean useGears = false, skipGLOrientationVerticalFlip=false, useAnim = false; + boolean overlap = false; for(int i=0; i Date: Thu, 14 Nov 2013 14:57:14 +0100 Subject: Bug 904 - GLJPanel: Add property to skip isGLOriented() based vertical flip by default (2/2) Property 'jogl.gljpanel.noverticalflip' will set the skipGLOrientationVerticalFlip default to true - intended for perf. testing of existing applications --- make/scripts/tests-x64.bat | 3 +++ make/scripts/tests.sh | 1 + src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 8 ++++++-- .../opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java | 4 +++- 4 files changed, 13 insertions(+), 3 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index ac74f4c94..379bcf323 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -19,6 +19,9 @@ set LIB_DIR= set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\%BLD_SUB%\joal.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar echo CP_ALL %CP_ALL% +REM set D_ARGS="" +REM set D_ARGS="-Djogl.gljpanel.noverticalflip" + set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" scripts\tests-win.bat %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bed169737..97e524254 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -204,6 +204,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" + #D_ARGS="-Djogl.gljpanel.noverticalflip" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.ToolkitLock.TraceLock" diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 011b14321..bff8a1880 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -170,6 +170,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private static final boolean DEBUG; private static final boolean DEBUG_VIEWPORT; private static final boolean USE_GLSL_TEXTURE_RASTERIZER; + private static final boolean SKIP_VERTICAL_FLIP_DEFAULT; /** Indicates whether the Java 2D OpenGL pipeline is requested by user. */ private static final boolean java2dOGLEnabledByProp; @@ -185,7 +186,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing DEBUG = Debug.debug("GLJPanel"); DEBUG_VIEWPORT = Debug.isPropertyDefined("jogl.debug.GLJPanel.Viewport", true); USE_GLSL_TEXTURE_RASTERIZER = !Debug.isPropertyDefined("jogl.gljpanel.noglsl", true); - + SKIP_VERTICAL_FLIP_DEFAULT = Debug.isPropertyDefined("jogl.gljpanel.noverticalflip", true); boolean enabled = Debug.getBooleanProperty("sun.java2d.opengl", false); java2dOGLEnabledByProp = enabled && !Debug.isPropertyDefined("jogl.gljpanel.noogl", true); @@ -203,6 +204,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing useJava2DGLPipeline = enabled; java2DGLPipelineOK = enabled; if( DEBUG ) { + System.err.println("GLJPanel: DEBUG_VIEWPORT "+DEBUG_VIEWPORT); + System.err.println("GLJPanel: USE_GLSL_TEXTURE_RASTERIZER "+USE_GLSL_TEXTURE_RASTERIZER); + System.err.println("GLJPanel: SKIP_VERTICAL_FLIP_DEFAULT "+SKIP_VERTICAL_FLIP_DEFAULT); System.err.println("GLJPanel: java2dOGLEnabledByProp "+java2dOGLEnabledByProp); System.err.println("GLJPanel: useJava2DGLPipeline "+useJava2DGLPipeline); System.err.println("GLJPanel: java2DGLPipelineOK "+java2DGLPipelineOK); @@ -253,7 +257,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing // The backend in use private volatile Backend backend; - private boolean skipGLOrientationVerticalFlip = false; + private boolean skipGLOrientationVerticalFlip = SKIP_VERTICAL_FLIP_DEFAULT; // Used by all backends either directly or indirectly to hook up callbacks private final Updater updater = new Updater(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java index 3133a449d..8b19537f8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java @@ -239,7 +239,9 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { canvas.setSize(size); canvas.setPreferredSize(size); canvas.setDoubleBuffered(useSwingDoubleBuffer); - canvas.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); + if( skipGLOrientationVerticalFlip ) { // don't fiddle w/ default .. + canvas.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); + } if( useGears ) { final GearsES2 g = new GearsES2(0); g.setVerbose(false); -- cgit v1.2.3 From 88f6e0012b36ca69dedaadb4e403e2a424b20cbf Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Nov 2013 01:54:32 +0100 Subject: Bug 903 - NEWT: Support 'Continue Drag on Exit'; Consistent Mouse ENTER/EXIT - Support 'Continue Drag on Exit' - Track dragging operation, allow exterior dragging - Hence track EXIT (see below) - Windows: - Capture mouse for exterior dragging - Only 'NewtWindows_trackPointerLeave' if 'entering' - Simplify touch: No 'inside' check - Not required. - Consistent Mouse ENTER/EXIT - Track ENTER/EXIT and synthesize if required, drop duplicate - OSX benefits, since it never produced ENTER/EXIT events - AWT (or other TK) translated events beahve equal now. - Required for EXIT event after ending exterior dragging and final RELEASE Tests: Passed unit tests 'junit.run.newt.event' on - GNU/Linux - Windows7 - OSX 10.7 Tested exterior tracking manually w/ NEWT TestGearsES2NEWT and TestGearsES2NewtCanvasAWT: - GNU/Linux - Windows7 (mouse) - Windows8.1 (touch) - OSX 10.7 --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64.bat | 1 + make/scripts/tests.sh | 6 +- .../classes/com/jogamp/newt/event/MouseEvent.java | 2 + .../com/jogamp/newt/event/MouseListener.java | 2 + src/newt/classes/jogamp/newt/WindowImpl.java | 236 ++++++++++++++------- src/newt/native/InputEvent.h | 6 + src/newt/native/WindowsWindow.c | 132 ++++++++---- 8 files changed, 263 insertions(+), 126 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 2fd401f00..90e736188 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -24,7 +24,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT %* diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 379bcf323..2227396d3 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -21,6 +21,7 @@ echo CP_ALL %CP_ALL% REM set D_ARGS="" REM set D_ARGS="-Djogl.gljpanel.noverticalflip" +set D_ARGS="-Dnewt.debug.Window.MouseEvent" set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 97e524254..ed3a91f99 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -192,7 +192,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window.MouseEvent" + D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" @@ -319,7 +319,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -351,7 +351,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # diff --git a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java index 635bdba52..272e4beb0 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseEvent.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseEvent.java @@ -589,7 +589,9 @@ public class MouseEvent extends InputEvent private static final PointerType[] constMousePointerTypes = new PointerType[] { PointerType.Mouse }; public static final short EVENT_MOUSE_CLICKED = 200; + /** Only generated for {@link PointerType#Mouse} */ public static final short EVENT_MOUSE_ENTERED = 201; + /** Only generated for {@link PointerType#Mouse} */ public static final short EVENT_MOUSE_EXITED = 202; public static final short EVENT_MOUSE_PRESSED = 203; public static final short EVENT_MOUSE_RELEASED = 204; diff --git a/src/newt/classes/com/jogamp/newt/event/MouseListener.java b/src/newt/classes/com/jogamp/newt/event/MouseListener.java index 5378080b9..6e5142044 100644 --- a/src/newt/classes/com/jogamp/newt/event/MouseListener.java +++ b/src/newt/classes/com/jogamp/newt/event/MouseListener.java @@ -44,7 +44,9 @@ import com.jogamp.newt.event.MouseEvent.PointerType; public interface MouseListener extends NEWTEventListener { public void mouseClicked(MouseEvent e); + /** Only generated for {@link PointerType#Mouse} */ public void mouseEntered(MouseEvent e); + /** Only generated for {@link PointerType#Mouse} */ public void mouseExited(MouseEvent e); public void mousePressed(MouseEvent e); public void mouseReleased(MouseEvent e); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 246c288d0..99e863a0e 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -186,37 +186,45 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer /** from event passing: {@link WindowImpl#consumePointerEvent(MouseEvent)}. */ private static class PointerState0 { - /** mouse entered window - is inside the window (may be synthetic) */ + /** Pointer entered window - is inside the window (may be synthetic) */ boolean insideWindow = false; + /** Mouse EXIT has been sent (only for MOUSE type enter/exit)*/ + boolean exitSent = false; - /** last time when a mouse button was pressed */ + /** last time when a pointer button was pressed */ long lastButtonPressTime = 0; + /** Pointer in dragging mode */ + boolean dragging = false; + void clearButton() { lastButtonPressTime = 0; } + public String toString() { return "PState0[inside "+insideWindow+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+", dragging "+dragging+"]"; } } private final PointerState0 pState0 = new PointerState0(); /** from direct input: {@link WindowImpl#doPointerEvent(boolean, boolean, int[], short, int, int, boolean, short[], int[], int[], float[], float, float[], float)}. */ private static class PointerState1 extends PointerState0 { - /** current pressed mouse button number */ + /** Current pressed mouse button number */ short buttonPressed = (short)0; - /** current pressed mouse button modifier mask */ + /** Current pressed mouse button modifier mask */ int buttonPressedMask = 0; - /** last mouse button click count */ + /** Last mouse button click count */ short lastButtonClickCount = (short)0; @Override final void clearButton() { super.clearButton(); - lastButtonPressTime = 0; lastButtonClickCount = (short)0; - buttonPressed = 0; - buttonPressedMask = 0; + if( !dragging || 0 == buttonPressedMask ) { + buttonPressed = 0; + buttonPressedMask = 0; + dragging = false; + } } - /** last pointer-move position for 8 touch-down pointers */ + /** Last pointer-move position for 8 touch-down pointers */ final Point[] movePositions = new Point[] { new Point(), new Point(), new Point(), new Point(), new Point(), new Point(), new Point(), new Point() }; @@ -226,10 +234,12 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } return null; } + public final String toString() { return "PState1[inside "+insideWindow+", exitSent "+exitSent+", lastPress "+lastButtonPressTime+ + ", pressed [button "+buttonPressed+", mask "+buttonPressedMask+", dragging "+dragging+", clickCount "+lastButtonClickCount+"]"; } } private final PointerState1 pState1 = new PointerState1(); - /** pointer names -> pointer ID (consecutive index, starting w/ 0) */ + /** Pointer names -> pointer ID (consecutive index, starting w/ 0) */ private final ArrayHashSet pName2pID = new ArrayHashSet(); private boolean defaultGestureHandlerEnabled = true; @@ -2365,25 +2375,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Native MouseEvents pre-processed to be enqueued or consumed directly // - public final void sendMouseEvent(short eventType, int modifiers, - int x, int y, short button, float rotation) { + public final void sendMouseEvent(final short eventType, final int modifiers, + final int x, final int y, final short button, final float rotation) { doMouseEvent(false, false, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } - public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers, - int x, int y, short button, float rotation) { + public final void enqueueMouseEvent(final boolean wait, final short eventType, final int modifiers, + final int x, final int y, final short button, final float rotation) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } - protected final void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, - int x, int y, short button, float rotation) { + protected final void doMouseEvent(final boolean enqueue, final boolean wait, final short eventType, final int modifiers, + final int x, final int y, final short button, final float rotation) { doMouseEvent(enqueue, wait, eventType, modifiers, x, y, button, MouseEvent.getRotationXYZ(rotation, modifiers), 1f); } /** - public final void sendMouseEvent(short eventType, int modifiers, - int x, int y, short button, float[] rotationXYZ, float rotationScale) { + public final void sendMouseEvent(final short eventType, final int modifiers, + final int x, final int y, final short button, final float[] rotationXYZ, final float rotationScale) { doMouseEvent(false, false, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } - public final void enqueueMouseEvent(boolean wait, short eventType, int modifiers, - int x, int y, short button, float[] rotationXYZ, float rotationScale) { + public final void enqueueMouseEvent(final boolean wait, final short eventType, final int modifiers, + final int x, final int y, final short button, final float[] rotationXYZ, final float rotationScale) { doMouseEvent(true, wait, eventType, modifiers, x, y, button, rotationXYZ, rotationScale); } */ @@ -2394,8 +2404,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * otherwise {@link #consumeEvent(NEWTEvent) consumed} directly. * @param wait if true wait until {@link #consumeEvent(NEWTEvent) consumed}. */ - protected void doMouseEvent(boolean enqueue, boolean wait, short eventType, int modifiers, - int x, int y, short button, final float[] rotationXYZ, float rotationScale) { + protected void doMouseEvent(final boolean enqueue, final boolean wait, final short eventType, final int modifiers, + final int x, final int y, final short button, final float[] rotationXYZ, final float rotationScale) { if( 0 > button || button > MouseEvent.BUTTON_COUNT ) { throw new NativeWindowException("Invalid mouse button number" + button); } @@ -2437,10 +2447,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param pPressure Pressure for each pointer (multiple pointer) * @param maxPressure Maximum pointer pressure for all pointer */ - public final void doPointerEvent(boolean enqueue, boolean wait, - final PointerType[] pTypes, short eventType, int modifiers, - int actionIdx, boolean normalPNames, final int[] pNames, - final int[] pX, final int[] pY, float[] pPressure, + public final void doPointerEvent(final boolean enqueue, final boolean wait, + final PointerType[] pTypes, final short eventType, final int modifiers, + final int actionIdx, final boolean normalPNames, final int[] pNames, + final int[] pX, final int[] pY, final float[] pPressure, float maxPressure, final float[] rotationXYZ, final float rotationScale) { final int pCount = pNames.length; final short[] pIDs = new short[pCount]; @@ -2511,10 +2521,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer * @param pPressure Pressure for each pointer (multiple pointer) * @param maxPressure Maximum pointer pressure for all pointer */ - public final void doPointerEvent(boolean enqueue, boolean wait, - final PointerType[] pTypes, short eventType, int modifiers, - int pActionIdx, final short[] pID, final int[] pX, final int[] pY, final float[] pPressure, - float maxPressure, final float[] rotationXYZ, float rotationScale) { + public final void doPointerEvent(final boolean enqueue, final boolean wait, + final PointerType[] pTypes, final short eventType, int modifiers, + final int pActionIdx, final short[] pID, final int[] pX, final int[] pY, final float[] pPressure, + final float maxPressure, final float[] rotationXYZ, final float rotationScale) { final long when = System.currentTimeMillis(); final int pCount = pTypes.length; @@ -2565,9 +2575,19 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // int x = pX[0]; int y = pY[0]; + final boolean insideWindow = x >= 0 && y >= 0 && x < getWidth() && y < getHeight(); final Point movePositionP0 = pState1.getMovePosition(id); switch( eventType ) { case MouseEvent.EVENT_MOUSE_EXITED: + if( pState1.dragging ) { + // Drop mouse EXIT if dragging, i.e. due to exterior dragging outside of window. + // NOTE-1: X11 produces the 'premature' EXIT, however it also produces 'EXIT' after exterior dragging! + // NOTE-2: consumePointerEvent(MouseEvent) will synthesize a missing EXIT event! + if(DEBUG_MOUSE_EVENT) { + System.err.println("doPointerEvent: drop "+MouseEvent.getEventTypeString(eventType)+" due to dragging: "+pState1); + } + return; + } if( null != movePositionP0 ) { if( x==-1 && y==-1 ) { x = movePositionP0.getX(); @@ -2578,21 +2598,35 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Fall through intended! case MouseEvent.EVENT_MOUSE_ENTERED: + if( eventType == MouseEvent.EVENT_MOUSE_ENTERED ) { + pState1.insideWindow = true; + pState1.exitSent = false; + } else { + pState1.insideWindow = false; + pState1.exitSent = true; + } + pState1.clearButton(); + if( pTypes[0] != PointerType.Mouse ) { + // Drop !MOUSE ENTER/EXIT Events - Safeguard for non compliant implementations only. + if(DEBUG_MOUSE_EVENT) { + System.err.println("doPointerEvent: drop "+MouseEvent.getEventTypeString(eventType)+" due to !Mouse but "+pTypes[0]+": "+pState1); + } + return; + } // clip coordinates to window dimension x = Math.min(Math.max(x, 0), getWidth()-1); y = Math.min(Math.max(y, 0), getHeight()-1); - pState1.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; - pState1.clearButton(); break; case MouseEvent.EVENT_MOUSE_MOVED: case MouseEvent.EVENT_MOUSE_DRAGGED: if( null != movePositionP0 ) { - if( pState1.insideWindow && movePositionP0.getX() == x && movePositionP0.getY() == y ) { + if( movePositionP0.getX() == x && movePositionP0.getY() == y ) { + // Drop same position if(DEBUG_MOUSE_EVENT) { - System.err.println("doPointerEvent: skip "+MouseEvent.getEventTypeString(eventType)+" w/ same position: "+movePositionP0); + System.err.println("doPointerEvent: drop "+MouseEvent.getEventTypeString(eventType)+" w/ same position: "+movePositionP0+", "+pState1); } - return; // skip same position + return; } movePositionP0.set(x, y); } @@ -2600,25 +2634,30 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // Fall through intended ! default: - if(!pState1.insideWindow) { - pState1.insideWindow = true; + if( pState1.insideWindow != insideWindow ) { + // ENTER/EXIT! + pState1.insideWindow = insideWindow; + if( insideWindow ) { + pState1.exitSent = false; + } pState1.clearButton(); } } // - // Drop exterior events + // Drop exterior events if not dragging pointer and not EXIT event + // Safeguard for non compliant implementations! // - if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { + if( !pState1.dragging && !insideWindow && MouseEvent.EVENT_MOUSE_EXITED != eventType ) { if(DEBUG_MOUSE_EVENT) { System.err.println("doPointerEvent: drop: "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0+", insideWindow "+insideWindow+", "+pState1); } return; // .. invalid .. } if(DEBUG_MOUSE_EVENT) { System.err.println("doPointerEvent: enqueue "+enqueue+", wait "+wait+", "+MouseEvent.getEventTypeString(eventType)+ - ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0); + ", mod "+modifiers+", pos "+x+"/"+y+", button "+button+", lastMousePosition: "+movePositionP0+", "+pState1); } final int buttonMask = InputEvent.getButtonMask(button); @@ -2668,6 +2707,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } break; case MouseEvent.EVENT_MOUSE_RELEASED: + pState1.buttonPressedMask &= ~buttonMask; if( 1 == pCount ) { e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, pState1.lastButtonClickCount, rotationXYZ, rotationScale); @@ -2676,11 +2716,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pState1.lastButtonPressTime = 0; } pState1.buttonPressed = 0; + pState1.dragging = false; } else { e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)1, rotationXYZ, rotationScale); + if( 0 == pState1.buttonPressedMask ) { + pState1.clearButton(); + } } - pState1.buttonPressedMask &= ~buttonMask; if( null != movePositionP0 ) { movePositionP0.set(0, 0); } @@ -2689,6 +2732,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if ( 0 != pState1.buttonPressedMask ) { // any button or pointer move -> drag e = new MouseEvent(MouseEvent.EVENT_MOUSE_DRAGGED, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, pState1.buttonPressed, (short)1, rotationXYZ, rotationScale); + pState1.dragging = true; } else { e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, pX, pY, pPressure, maxPressure, button, (short)0, rotationXYZ, rotationScale); @@ -2698,6 +2742,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if( 0 >= pPressure[0] ) { pPressure[0] = maxPressure; } + pState1.dragging = true; // Fall through intended! default: e = new MouseEvent(eventType, this, when, modifiers, pTypes, pID, @@ -2831,7 +2876,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer *
        *
      • Validate
      • *
      • Handle gestures
      • - *
      • Synthesize events ENTERED, CLICK and gestures.
      • + *
      • Synthesize events [ENTERED, EXIT, CLICK] and gestures.
      • *
      • Drop exterior events
      • *
      • Dispatch event to listener
      • *
      @@ -2842,50 +2887,84 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer int y = pe.getY(); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.in: "+pe); + System.err.println("consumePointerEvent.in: "+pe+", "+pState0+", pos "+x+"/"+y+" clientSize["+getWidth()+"x"+getHeight()+"]"); } // // - Determine ENTERED/EXITED state - // - Synthesize ENTERED event + // - Synthesize ENTERED and EXIT event // - Reset states if applicable // final long when = pe.getWhen(); - int eventType = pe.getEventType(); - final MouseEvent eEntered; + final int eventType = pe.getEventType(); + final boolean insideWindow; + boolean eExitAllowed = false; + MouseEvent eEntered = null, eExited = null; switch( eventType ) { case MouseEvent.EVENT_MOUSE_EXITED: + if( pState0.exitSent || pState0.dragging ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumePointerEvent: drop "+(pState0.exitSent?"already sent":"due to dragging")+": "+pe+", "+pState0); + } + return; + } + // Fall through intended ! case MouseEvent.EVENT_MOUSE_ENTERED: // clip coordinates to window dimension x = Math.min(Math.max(x, 0), getWidth()-1); y = Math.min(Math.max(y, 0), getHeight()-1); - pState0.insideWindow = eventType == MouseEvent.EVENT_MOUSE_ENTERED; pState0.clearButton(); - eEntered = null; + if( eventType == MouseEvent.EVENT_MOUSE_ENTERED ) { + insideWindow = true; + pState0.insideWindow = true; + pState0.exitSent = false; + pState0.dragging = false; + } else { + insideWindow = false; + pState0.insideWindow = false; + pState0.exitSent = true; + } break; + case MouseEvent.EVENT_MOUSE_MOVED: + case MouseEvent.EVENT_MOUSE_RELEASED: + if( 1 >= pe.getButtonDownCount() ) { // MOVE or RELEASE last button + eExitAllowed = !pState0.exitSent; + pState0.dragging = false; + } + // Fall through intended ! + default: - if(!pState0.insideWindow) { - pState0.insideWindow = true; + insideWindow = x >= 0 && y >= 0 && x < getWidth() && y < getHeight(); + if( pe.getPointerType(0) == PointerType.Mouse ) { + if( !pState0.insideWindow && insideWindow ) { + // ENTER .. use clipped coordinates + eEntered = new MouseEvent(MouseEvent.EVENT_MOUSE_ENTERED, pe.getSource(), pe.getWhen(), pe.getModifiers(), + Math.min(Math.max(x, 0), getWidth()-1), + Math.min(Math.max(y, 0), getHeight()-1), + (short)0, (short)0, pe.getRotation(), pe.getRotationScale()); + pState0.exitSent = false; + } else if( !insideWindow && eExitAllowed ) { + // EXIT .. use clipped coordinates + eExited = new MouseEvent(MouseEvent.EVENT_MOUSE_EXITED, pe.getSource(), pe.getWhen(), pe.getModifiers(), + Math.min(Math.max(x, 0), getWidth()-1), + Math.min(Math.max(y, 0), getHeight()-1), + (short)0, (short)0, pe.getRotation(), pe.getRotationScale()); + pState0.exitSent = true; + } + } + if( pState0.insideWindow != insideWindow || null != eEntered || null != eExited) { pState0.clearButton(); - eEntered = pe.createVariant(MouseEvent.EVENT_MOUSE_ENTERED); - } else { - eEntered = null; } + pState0.insideWindow = insideWindow; } if( null != eEntered ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.send.0: "+eEntered); + System.err.println("consumePointerEvent.send.0: "+eEntered+", "+pState0); } dispatchMouseEvent(eEntered); - } else if( x < 0 || y < 0 || x >= getWidth() || y >= getHeight() ) { - // - // Drop exterior events - // - if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.drop: "+pe); - } - return; // .. invalid .. + } else if( DEBUG_MOUSE_EVENT && !insideWindow ) { + System.err.println("INFO consumePointerEvent.exterior: "+pState0+", "+pe); } // @@ -2906,7 +2985,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer scaledScrollSlop = Math.round(DoubleTapScrollGesture.SCROLL_SLOP_MM * pixPerMM); scaledDoubleTapSlop = Math.round(DoubleTapScrollGesture.DOUBLE_TAP_SLOP_MM * pixPerMM); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.gscroll: scrollSlop "+scaledScrollSlop+", doubleTapSlop "+scaledDoubleTapSlop+", pixPerMM "+pixPerMM+", "+monitor); + System.err.println("consumePointerEvent.gscroll: scrollSlop "+scaledScrollSlop+", doubleTapSlop "+scaledDoubleTapSlop+", pixPerMM "+pixPerMM+", "+monitor+", "+pState0); } } else { scaledScrollSlop = DoubleTapScrollGesture.SCROLL_SLOP_PIXEL; @@ -2919,7 +2998,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer pe = (MouseEvent) gesture2PtrTouchScroll.getGestureEvent(); gesture2PtrTouchScroll.clear(false); if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.gscroll: "+pe); + System.err.println("consumePointerEvent.gscroll: "+pe+", "+pState0); } dispatchMouseEvent(pe); return; @@ -2962,46 +3041,51 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // - Synthesize mouse CLICKED // - Ignore sent CLICKED // - final MouseEvent eClicked; + MouseEvent eClicked = null; switch( eventType ) { case MouseEvent.EVENT_MOUSE_PRESSED: if( 1 == pe.getPointerCount() ) { pState0.lastButtonPressTime = when; } - eClicked = null; break; case MouseEvent.EVENT_MOUSE_RELEASED: if( 1 == pe.getPointerCount() && when - pState0.lastButtonPressTime < MouseEvent.getClickTimeout() ) { eClicked = pe.createVariant(MouseEvent.EVENT_MOUSE_CLICKED); } else { - eClicked = null; pState0.lastButtonPressTime = 0; } break; case MouseEvent.EVENT_MOUSE_CLICKED: // ignore - synthesized here .. if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent: drop recv'ed (synth here) "+pe); + System.err.println("consumePointerEvent: drop recv'ed (synth here) "+pe+", "+pState0); } pe = null; - eClicked = null; break; - default: - eClicked = null; + + case MouseEvent.EVENT_MOUSE_DRAGGED: + pState0.dragging = true; + break; } if( null != pe ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.send.1: "+pe); + System.err.println("consumePointerEvent.send.1: "+pe+", "+pState0); } dispatchMouseEvent(pe); // actual mouse event } if( null != eClicked ) { if(DEBUG_MOUSE_EVENT) { - System.err.println("consumePointerEvent.send.2: "+eClicked); + System.err.println("consumePointerEvent.send.2: "+eClicked+", "+pState0); } dispatchMouseEvent(eClicked); } + if( null != eExited ) { + if(DEBUG_MOUSE_EVENT) { + System.err.println("consumePointerEvent.send.3: "+eExited+", "+pState0); + } + dispatchMouseEvent(eExited); + } } private final void dispatchMouseEvent(MouseEvent e) { @@ -3205,11 +3289,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer // @Override public void sendWindowEvent(int eventType) { - consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME + consumeWindowEvent( new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); } public void enqueueWindowEvent(boolean wait, int eventType) { - enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); // FIXME + enqueueEvent( wait, new WindowEvent((short)eventType, this, System.currentTimeMillis()) ); } @Override diff --git a/src/newt/native/InputEvent.h b/src/newt/native/InputEvent.h index 3fa7dbefe..2de46f82e 100644 --- a/src/newt/native/InputEvent.h +++ b/src/newt/native/InputEvent.h @@ -50,6 +50,12 @@ #define EVENT_BUTTON8_MASK (1 << 12) #define EVENT_BUTTON9_MASK (1 << 13) +/** 16 buttons */ +#define EVENT_BUTTONLAST_MASK (1 << 20) + +/** 16 buttons */ +#define EVENT_BUTTONALL_MASK ( 0xffff << 5 ) + #define EVENT_AUTOREPEAT_MASK (1 << 29) #define EVENT_CONFINED_MASK (1 << 30) #define EVENT_INVISIBLE_MASK (1 << 31) diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 884e538d3..692bb9d4f 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -186,7 +186,8 @@ typedef struct { int height; /** Tristate: -1 HIDE, 0 NOP, 1 SHOW */ int setPointerVisible; - int mouseInside; + int pointerCaptured; + int pointerInside; int touchDownCount; int touchDownLastUp; // mitigate LBUTTONUP after last TOUCH lift int supportsMTouch; @@ -985,11 +986,14 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP case WM_LBUTTONDOWN: { - DBG_PRINT("*** WindowsWindow: WM_LBUTTONDOWN %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_LBUTTONDOWN %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownLastUp && 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, @@ -1002,14 +1006,22 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_LBUTTONUP: { - DBG_PRINT("*** WindowsWindow: WM_LBUTTONUP %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_LBUTTONUP %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 < wud->touchDownLastUp ) { // mitigate LBUTTONUP after last TOUCH lift wud->touchDownLastUp = 0; } else if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + jint modifiers = GetModifiers(0); + if( wud->pointerCaptured && 0 == ( modifiers & EVENT_BUTTONALL_MASK ) ) { + wud->pointerCaptured = 0; + ReleaseCapture(); + } + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, GetModifiers( 0 ), @@ -1021,11 +1033,14 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MBUTTONDOWN: { - DBG_PRINT("*** WindowsWindow: WM_MBUTTONDOWN %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_MBUTTONDOWN %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, @@ -1038,11 +1053,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MBUTTONUP: { - DBG_PRINT("*** WindowsWindow: WM_MBUTTONUP %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_MBUTTONUP %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + jint modifiers = GetModifiers(0); + if( wud->pointerCaptured && 0 == ( modifiers & EVENT_BUTTONALL_MASK ) ) { + wud->pointerCaptured = 0; + ReleaseCapture(); + } + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, GetModifiers( 0 ), @@ -1054,11 +1077,14 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_RBUTTONDOWN: { - DBG_PRINT("*** WindowsWindow: WM_RBUTTONDOWN %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_RBUTTONDOWN %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_PRESSED, @@ -1071,11 +1097,19 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_RBUTTONUP: { - DBG_PRINT("*** WindowsWindow: WM_RBUTTONUP %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_RBUTTONUP %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 1; + jint modifiers = GetModifiers(0); + if( wud->pointerCaptured && 0 == ( modifiers & EVENT_BUTTONALL_MASK ) ) { + wud->pointerCaptured = 0; + ReleaseCapture(); + } + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_RELEASED, GetModifiers( 0 ), @@ -1087,15 +1121,22 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_MOUSEMOVE: { - DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_MOUSEMOVE %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownLastUp && 0 == wud->touchDownCount ) { - wud->mouseInside = 1; - NewtWindows_trackPointerLeave(wnd); + jint modifiers = GetModifiers(0); + if( 0 == wud->pointerCaptured && 0 != ( modifiers & EVENT_BUTTONALL_MASK ) ) { + wud->pointerCaptured = 1; + SetCapture(wnd); + } + if( 0 == wud->pointerInside ) { + wud->pointerInside = 1; + NewtWindows_trackPointerLeave(wnd); + } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, - GetModifiers( 0 ), + modifiers, (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), (jshort) 0, (jfloat) 0.0f); } @@ -1103,11 +1144,11 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP } break; case WM_MOUSELEAVE: { - DBG_PRINT("*** WindowsWindow: WM_MOUSELEAVE %d/%d [%dx%d] inside %d, tDown [c %d, lastUp %d]\n", + DBG_PRINT("*** WindowsWindow: WM_MOUSELEAVE %d/%d [%dx%d] inside %d, captured %d, tDown [c %d, lastUp %d]\n", (jint) GET_X_LPARAM(lParam), (jint) GET_Y_LPARAM(lParam), - wud->width, wud->height, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + wud->width, wud->height, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); if( 0 == wud->touchDownCount ) { - wud->mouseInside = 0; + wud->pointerInside = 0; (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_EXITED, 0, @@ -1203,7 +1244,6 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP int isPrim = pTi->dwFlags & TOUCHEVENTF_PRIMARY; int isNoCoalesc = pTi->dwFlags & TOUCHEVENTF_NOCOALESCE; - int isPInside; #ifdef VERBOSE_ON const char * touchAction; @@ -1223,8 +1263,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP eventPt.y = TOUCH_COORD_TO_PIXEL(pTi->y); ScreenToClient(wnd, &eventPt); - isPInside = 0 <= eventPt.x && 0 <= eventPt.y && eventPt.x < wud->width && eventPt.y < wud->height; - allPInside &= isPInside; + int pInside = 0 <= eventPt.x && 0 <= eventPt.y && eventPt.x < wud->width && eventPt.y < wud->height; + allPInside &= pInside; x[i] = (jint)eventPt.x; y[i] = (jint)eventPt.y; @@ -1252,16 +1292,16 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP #ifdef VERBOSE_ON DBG_PRINT("*** WindowsWindow: WM_TOUCH[%d/%d].%s name 0x%x, prim %d, nocoalsc %d, %d/%d [%dx%d] inside [%d/%d], tDown [c %d, lastUp %d]\n", (i+1), cInputs, touchAction, (int)(pTi->dwID), isPrim, isNoCoalesc, x[i], y[i], wud->width, wud->height, - isPInside, allPInside, wud->touchDownCount, wud->touchDownLastUp); + pInside, allPInside, wud->touchDownCount, wud->touchDownLastUp); #endif } - wud->mouseInside = allPInside; - if( sendFocus && allPInside ) { + wud->pointerInside = allPInside; + if( sendFocus ) { (*env)->CallVoidMethod(env, window, requestFocusID, JNI_FALSE); } int sentCount = 0, updownCount=0, moveCount=0; // Primary first, if available! - if( 0 <= actionIdx && allPInside ) { + if( 0 <= actionIdx ) { sendTouchScreenEvent(env, window, eventType[actionIdx], modifiers, actionIdx, cInputs, pointerNames, x, y, pressure, maxPressure); sentCount++; @@ -1270,7 +1310,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP for (i=0; i < cInputs; i++) { short et = eventType[i]; if( (jshort) EVENT_MOUSE_MOVED == et ) { - if( i != actionIdx && 0 == moveCount && allPInside ) { + if( i != actionIdx && 0 == moveCount ) { sendTouchScreenEvent(env, window, et, modifiers, i, cInputs, pointerNames, x, y, pressure, maxPressure); sentCount++; @@ -1282,7 +1322,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP for (i=0; i < cInputs; i++) { short et = eventType[i]; if( (jshort) EVENT_MOUSE_MOVED != et ) { - if( i != actionIdx && allPInside ) { + if( i != actionIdx ) { sendTouchScreenEvent(env, window, et, modifiers, i, cInputs, pointerNames, x, y, pressure, maxPressure); sentCount++; @@ -1290,8 +1330,8 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP updownCount++; } } - DBG_PRINT("*** WindowsWindow: WM_TOUCH.summary pCount %d, prim %d, updown %d, move %d, sent %d, inside %d, tDown [c %d, lastUp %d]\n", - cInputs, actionIdx, updownCount, moveCount, sentCount, wud->mouseInside, wud->touchDownCount, wud->touchDownLastUp); + DBG_PRINT("*** WindowsWindow: WM_TOUCH.summary pCount %d, prim %d, updown %d, move %d, sent %d, inside %d, captured %d, tDown [c %d, lastUp %d]\n", + cInputs, actionIdx, updownCount, moveCount, sentCount, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount, wud->touchDownLastUp); // Message processed - close it WinTouch_CloseTouchInputHandle(hTouch); @@ -1310,10 +1350,14 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP break; case WM_KILLFOCUS: - DBG_PRINT("*** WindowsWindow: WM_KILLFOCUS window %p, received %p, inside %d, tDown %d\n", - wnd, (HWND)wParam, wud->mouseInside, wud->touchDownCount); + DBG_PRINT("*** WindowsWindow: WM_KILLFOCUS window %p, received %p, inside %d, captured %d, tDown %d\n", + wnd, (HWND)wParam, wud->pointerInside, wud->pointerCaptured, wud->touchDownCount); if( wud->touchDownCount == 0 ) { - wud->mouseInside=0; + wud->pointerInside = 0; + if( wud->pointerCaptured ) { + wud->pointerCaptured = 0; + ReleaseCapture(); + } (*env)->CallVoidMethod(env, window, focusChangedID, JNI_FALSE, JNI_FALSE); useDefWindowProc = 1; } else { @@ -1963,7 +2007,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo wud->width = width; wud->height = height; wud->setPointerVisible = 0; - wud->mouseInside = 0; + wud->pointerCaptured = 0; + wud->pointerInside = 0; wud->touchDownCount = 0; wud->touchDownLastUp = 0; wud->supportsMTouch = 0; @@ -2214,12 +2259,9 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_windows_WindowDriver_confineP jboolean res; if(JNI_TRUE == confine) { - // SetCapture(hwnd); - // res = ( GetCapture() == hwnd ) ? JNI_TRUE : JNI_FALSE; RECT rect = { l, t, r, b }; res = ClipCursor(&rect) ? JNI_TRUE : JNI_FALSE; } else { - // res = ReleaseCapture() ? JNI_TRUE : JNI_FALSE; res = ClipCursor(NULL) ? JNI_TRUE : JNI_FALSE; } DBG_PRINT( "*** WindowsWindow: confinePointer0: %d, [ l %d t %d r %d b %d ], res %d\n", -- cgit v1.2.3 From 0be87f241c0f0b2f5881d9a602ce12378b8e453d Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Nov 2013 04:55:33 +0100 Subject: Fix Bug 879 - Threads deadlock in native keyboardfocus calls made form multiple threads; Fix Bug 892: Reduce Focus Hopping Since we manage focus key traversal ourselves w/o requiring the AWT component to have the focus[1], we simply can drop requesting the focus for 'focus hopping' NEWT -> AWT -> NEWT[2]. Further more, 'MenuSelectionManager.defaultManager().clearSelectedPath()' must be performed on AWT-EDT w/o blocking. Otherwise it may perform blocking tasks on AWT-EDT. [1] Commit cb7118fc875b6722803e4b11d5681671962a8d3a introduced function to query the next or previous 'to be focused' component: AWTMisc.getNextFocus(..) .. etc. [2] Focus hopping is also addressed in Bug 892 --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 8 ++++---- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 23 +++++++++++----------- 3 files changed, 17 insertions(+), 18 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 90e736188..8008e959f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -139,7 +139,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslu REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ed3a91f99..aab20980d 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -192,14 +192,14 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" - D_ARGS="-Dnewt.debug.Window.MouseEvent" + #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug.JAWT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -319,7 +319,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -610,7 +610,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* # # Misc Utils diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 70157fe4b..9611cc960 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -190,23 +190,22 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.FocusAction: "+Display.getThreadName()+", isOnscreen "+isOnscreen+", hasFocus "+hasFocus()+", isParent "+isParent+", isFS "+isFullscreen); } - if(isParent && !isFullscreen) { - // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. - if(!hasFocus()) { - // Acquire the AWT focus 1st for proper AWT traversal - NewtCanvasAWT.super.requestFocus(); - } - if(isOnscreen) { - // Remove the AWT focus in favor of the native NEWT focus - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); - } + if( isParent && !isFullscreen && isOnscreen ) { + // Remove the AWT focus in favor of the native NEWT focus + KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); } return false; // NEWT shall proceed requesting the native focus } } private final FocusAction focusAction = new FocusAction(); - WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { + /** Must run on AWT-EDT non-blocking, since it invokes tasks on AWT-EDT w/ waiting otherwise. */ + private final Runnable awtClearSelectedMenuPath = new Runnable() { + public void run() { + MenuSelectionManager.defaultManager().clearSelectedPath(); + } + }; + private final WindowListener clearAWTMenusOnNewtFocus = new WindowAdapter() { @Override public void windowResized(WindowEvent e) { updateLayoutSize(); @@ -214,7 +213,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void windowGainedFocus(WindowEvent arg0) { if( isParent() && !isFullscreen() ) { - MenuSelectionManager.defaultManager().clearSelectedPath(); + AWTEDTExecutor.singleton.invoke(false, awtClearSelectedMenuPath); } } }; -- cgit v1.2.3 From d04ca826bc3ca95eb32921e59c1845a1626f88e6 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 17 Nov 2013 17:29:37 +0100 Subject: Use 'gluegen-clang.properties' for generic clang and 'gluegen-xcode_clang.properties' for OSX xcode-clang ; Add GNU/Linux LLVM/clang build scripts --- make/scripts/make.jogl.all.linux-x86-clang.sh | 62 +++++++++++++++++++++++ make/scripts/make.jogl.all.linux-x86_64-clang.sh | 63 ++++++++++++++++++++++++ make/scripts/make.jogl.all.macosx-clang.sh | 4 +- 3 files changed, 127 insertions(+), 2 deletions(-) create mode 100755 make/scripts/make.jogl.all.linux-x86-clang.sh create mode 100755 make/scripts/make.jogl.all.linux-x86_64-clang.sh (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.linux-x86-clang.sh b/make/scripts/make.jogl.all.linux-x86-clang.sh new file mode 100755 index 000000000..b76997d1e --- /dev/null +++ b/make/scripts/make.jogl.all.linux-x86-clang.sh @@ -0,0 +1,62 @@ +#! /bin/sh + +SDIR=`dirname $0` + +if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh ] ; then + . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86.sh +fi + +if [ "$1" = "-libdir" ] ; then + shift + if [ -z "$1" ] ; then + echo libdir argument missing + print_usage + exit + fi + CUSTOMLIBDIR="-Dcustom.libdir=$1" + shift +fi + + +# -Dc.compiler.debug=true +# -Dsetup.addNativeOpenMAX=true \ +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxX86=true \ +# -DisX11=true \ + +#LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64 +#export LD_LIBRARY_PATH + +LOGF=make.jogl.all.linux-x86-clang.log +rm -f $LOGF + +# export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri +# export LIBGL_DEBUG=verbose +echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a $LOGF +echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $LOGF +echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF + +# -Dgluegen-cpptasks.file=`pwd`/../../gluegen/make/lib/gluegen-cpptasks-linux-32bit.xml \ +# + +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +export GLUEGEN_PROPERTIES_FILE="../../gluegen/make/lib/gluegen-clang.properties" +# or -Dgcc.compat.compiler=clang + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + + +ant \ + $CUSTOMLIBDIR \ + -Drootrel.build=build-x86-clang \ + -Dos.arch=x86 \ + -Dsetup.addNativeOpenMAX=true \ + -Dsetup.addNativeKD=true \ + $* 2>&1 | tee -a $LOGF + diff --git a/make/scripts/make.jogl.all.linux-x86_64-clang.sh b/make/scripts/make.jogl.all.linux-x86_64-clang.sh new file mode 100755 index 000000000..8a684b7d3 --- /dev/null +++ b/make/scripts/make.jogl.all.linux-x86_64-clang.sh @@ -0,0 +1,63 @@ +#! /bin/sh + +SDIR=`dirname $0` + +if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then + . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh +fi + +if [ "$1" = "-libdir" ] ; then + shift + if [ -z "$1" ] ; then + echo libdir argument missing + print_usage + exit + fi + CUSTOMLIBDIR="-Dcustom.libdir=$1" + shift +fi + +# -Dc.compiler.debug=true \ + +# -Dgluegen.cpptasks.detected.os=true \ +# -DisUnix=true \ +# -DisLinux=true \ +# -DisLinuxAMD64=true \ +# -DisX11=true \ +# +# -Dtarget.sourcelevel=1.6 \ +# -Dtarget.targetlevel=1.6 \ +# -Dtarget.rt.jar=/opt-share/jre1.6.0_30/lib/rt.jar \ +# +# -Dsetup.addNativeOpenMAX=true \ +# -Dsetup.addNativeKD=true \ + + +#LD_LIBRARY_PATH=/opt-linux-x86_64/mesa-7.8.1/lib64 +#export LD_LIBRARY_PATH + +LOGF=make.jogl.all.linux-x86_64-clang.log +rm -f $LOGF + +# export LIBGL_DRIVERS_PATH=/usr/lib/fglrx/dri:/usr/lib32/fglrx/dri +# export LIBGL_DEBUG=verbose +echo LIBXCB_ALLOW_SLOPPY_LOCK: $LIBXCB_ALLOW_SLOPPY_LOCK 2>&1 | tee -a $LOGF +echo LIBGL_DRIVERS_PATH: $LIBGL_DRIVERS_PATH 2>&1 | tee -a $LOGF +echo LIBGL_DEBUG: $LIBGL_DEBUG 2>&1 | tee -a $LOGF + +export SOURCE_LEVEL=1.6 +export TARGET_LEVEL=1.6 +export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar + +export GLUEGEN_PROPERTIES_FILE="../../gluegen/make/lib/gluegen-clang.properties" +# or -Dgcc.compat.compiler=clang + +#export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" +export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" + +# BUILD_ARCHIVE=true \ +ant \ + $CUSTOMLIBDIR \ + -Drootrel.build=build-x86_64-clang \ + $* 2>&1 | tee -a $LOGF + diff --git a/make/scripts/make.jogl.all.macosx-clang.sh b/make/scripts/make.jogl.all.macosx-clang.sh index eb633f5a6..b5f21c908 100755 --- a/make/scripts/make.jogl.all.macosx-clang.sh +++ b/make/scripts/make.jogl.all.macosx-clang.sh @@ -18,8 +18,8 @@ export SOURCE_LEVEL=1.6 export TARGET_LEVEL=1.6 export TARGET_RT_JAR=/opt-share/jre1.6.0_30/lib/rt.jar -export GLUEGEN_PROPERTIES_FILE="../../gluegen/make/lib/gluegen-clang.properties" -# or -Dgcc.compat.compiler=clang +export GLUEGEN_PROPERTIES_FILE="../../gluegen/make/lib/gluegen-xcode_clang.properties" +# or -Dgcc.compat.compiler=xcode.clang #export JOGAMP_JAR_CODEBASE="Codebase: *.jogamp.org" export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" -- cgit v1.2.3 From 23697c7921039e9655a5760e21d7029598b679d7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 01:11:15 +0100 Subject: Fix Bug 879 Regression (2/2) - NewtCanvasAWT.FocusAction must take focus when in offscreen-mode (OSX/CALayer) NewtCanvasAWT.FocusAction must take focus when in offscreen-mode (OSX/CALayer) since the NEWT window _is_ offscreen (no input events) and AWT events are translated to NEWT. Regression of commit 0be87f241c0f0b2f5881d9a602ce12378b8e453d --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests-x64-dbg.bat | 3 ++- make/scripts/tests-x64.bat | 4 ---- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 14 +++++++++++--- .../parenting/TestParentingFocus03KeyTraversalAWT.java | 10 +++++++++- 5 files changed, 24 insertions(+), 11 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 8008e959f..17362185e 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -13,7 +13,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGea REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* @@ -139,7 +139,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslu REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index a42c79254..822ad0e54 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -51,7 +51,8 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLContext" "-Djogl.debug.GLContext.TraceSwitch" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" -REM set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Djogl.gljpanel.noverticalflip" +set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" diff --git a/make/scripts/tests-x64.bat b/make/scripts/tests-x64.bat index 2227396d3..ac74f4c94 100755 --- a/make/scripts/tests-x64.bat +++ b/make/scripts/tests-x64.bat @@ -19,10 +19,6 @@ set LIB_DIR= set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\%BLD_SUB%\joal.jar;..\..\gluegen\%BLD_SUB%\gluegen-rt.jar;..\..\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86_64\swt-debug.jar echo CP_ALL %CP_ALL% -REM set D_ARGS="" -REM set D_ARGS="-Djogl.gljpanel.noverticalflip" -set D_ARGS="-Dnewt.debug.Window.MouseEvent" - set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" scripts\tests-win.bat %* diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 9611cc960..b8de1f596 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -190,9 +190,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto if(DEBUG) { System.err.println("NewtCanvasAWT.FocusAction: "+Display.getThreadName()+", isOnscreen "+isOnscreen+", hasFocus "+hasFocus()+", isParent "+isParent+", isFS "+isFullscreen); } - if( isParent && !isFullscreen && isOnscreen ) { - // Remove the AWT focus in favor of the native NEWT focus - KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + if( isParent && !isFullscreen ) { // must be parent of newtChild _and_ newtChild not fullscreen + if( isOnscreen ) { + // Remove the AWT focus in favor of the native NEWT focus + KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner(); + } else if( !isOnscreen ) { + // In offscreen mode we require the focus! + if( !hasFocus() ) { + // Newt-EDT -> AWT-EDT may freeze Window's native peer requestFocus. + NewtCanvasAWT.super.requestFocus(); + } + } } return false; // NEWT shall proceed requesting the native focus } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java index 1e6cf4a1d..e928b2a34 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java @@ -283,7 +283,15 @@ public class TestParentingFocus03KeyTraversalAWT extends UITestCase { System.err.println("Test: Direct NEWT-Child request focus"); glWindow1.requestFocus(); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + { + // Short: Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + // More verbose: + final boolean ok = AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA); + System.err.println("glWindow hasFocus "+glWindow1.hasFocus()); + System.err.println("glWindow1FA "+glWindow1FA); + System.err.println("bWestFA "+bWestFA); + Assert.assertTrue("Did not gain focus", ok); + } Assert.assertEquals(true, glWindow1FA.focusGained()); Assert.assertEquals(true, bWestFA.focusLost()); Thread.sleep(durationPerTest/numFocus); -- cgit v1.2.3 From b335cf086f8ee85985962b6f6676b99ab8141a77 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 13:03:58 +0100 Subject: NewtCanvasAWT: Use final AWT[Key|Mouse]Adapter and set downstream lazily; Consume AWT KeyEvents in downstream mode; Test respects 'consumed' key events. --- make/scripts/tests.sh | 4 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 51 ++++++++++++++-------- .../TestParentingFocus01SwingAWTRobot.java | 2 +- .../TestParentingFocus02SwingAWTRobot.java | 4 +- 4 files changed, 37 insertions(+), 24 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index aab20980d..9510734a3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -608,9 +608,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* # # Misc Utils diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index b8de1f596..f9f869781 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -101,9 +101,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private boolean newtChildAttached = false; private boolean isOnscreen = true; private WindowClosingMode newtChildCloseOp; - private AWTParentWindowAdapter awtAdapter = null; - private AWTAdapter awtMouseAdapter = null; - private AWTAdapter awtKeyAdapter = null; + private final AWTParentWindowAdapter awtAdapter; + private final AWTAdapter awtMouseAdapter; + private final AWTAdapter awtKeyAdapter; private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @@ -125,6 +125,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT() { super(); + awtMouseAdapter = new AWTMouseAdapter().addTo(this); + awtKeyAdapter = new AWTKeyAdapter().addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! } /** @@ -132,6 +136,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT(GraphicsConfiguration gc) { super(gc); + awtMouseAdapter = new AWTMouseAdapter().addTo(this); + awtKeyAdapter = new AWTKeyAdapter().addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! } /** @@ -139,6 +147,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT(Window child) { super(); + awtMouseAdapter = new AWTMouseAdapter().addTo(this); + awtKeyAdapter = new AWTKeyAdapter().addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! setNEWTChild(child); } @@ -147,6 +159,10 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto */ public NewtCanvasAWT(GraphicsConfiguration gc, Window child) { super(gc); + awtMouseAdapter = new AWTMouseAdapter().addTo(this); + awtKeyAdapter = new AWTKeyAdapter().addTo(this); + awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter().addTo(this); + awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! setNEWTChild(child); } @@ -671,18 +687,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } private final void configureNewtChild(boolean attach) { - if(null!=awtAdapter) { - awtAdapter.removeFrom(this); - awtAdapter=null; - } - if(null!=awtMouseAdapter) { - awtMouseAdapter.removeFrom(this); - awtMouseAdapter = null; - } - if(null!=awtKeyAdapter) { - awtKeyAdapter.removeFrom(this); - awtKeyAdapter = null; - } + awtAdapter.clear(); + awtMouseAdapter.clear(); + awtKeyAdapter.setConsumeAWTEvent(false); + awtMouseAdapter.clear(); + awtKeyAdapter.setConsumeAWTEvent(false); + if(null != keyboardFocusManager) { keyboardFocusManager.removePropertyChangeListener("focusOwner", focusPropertyChangeListener); keyboardFocusManager = null; @@ -695,8 +705,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto throw new InternalError("XXX"); } isOnscreen = jawtWindow.getGraphicsConfiguration().getChosenCapabilities().isOnscreen(); - awtAdapter = (AWTParentWindowAdapter) new AWTParentWindowAdapter(jawtWindow, newtChild).addTo(this); - awtAdapter.removeWindowClosingFrom(this); // we utilize AWTWindowClosingProtocol triggered destruction! + awtAdapter.setDownstream(jawtWindow, newtChild); newtChild.addWindowListener(clearAWTMenusOnNewtFocus); newtChild.setFocusAction(focusAction); // enable AWT focus traversal newtChildCloseOp = newtChild.setDefaultCloseOperation(WindowClosingMode.DO_NOTHING_ON_CLOSE); @@ -710,8 +719,12 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto newtChild.setKeyboardFocusHandler(newtFocusTraversalKeyListener); } else { // offscreen newt child requires AWT to fwd AWT key/mouse event - awtMouseAdapter = new AWTMouseAdapter(newtChild).addTo(this); - awtKeyAdapter = new AWTKeyAdapter(newtChild).addTo(this); + awtMouseAdapter.setDownstream(newtChild); + // We cannot consume AWT mouse click, since it would disable focus via mouse click! + // awtMouseAdapter.setConsumeAWTEvent(true); + awtKeyAdapter.setDownstream(newtChild); + // We manually transfer the focus via NEWT KeyListener, hence we can mark AWT keys as consumed! + awtKeyAdapter.setConsumeAWTEvent(true); } } else { newtChild.removeWindowListener(clearAWTMenusOnNewtFocus); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java index 29c3279aa..54842cd6e 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java @@ -193,7 +193,7 @@ public class TestParentingFocus01SwingAWTRobot extends UITestCase { } System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); - Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); + Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount()); // Remove listeners to avoid logging during dispose/destroy. glWindow1.removeKeyListener(glWindow1KA); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java index aa02e096b..3aa952e30 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java @@ -215,7 +215,7 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase { Assert.assertEquals(false, buttonNorthInnerFA.focusGained()); System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); - Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); + Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount()); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, glWindow1, glWindow1MA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, @@ -253,7 +253,7 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase { Assert.assertEquals(false, buttonNorthOuterFA.focusGained()); System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); - Assert.assertEquals("AWT parent canvas received keyboard events", 0, newtCanvasAWTKA.getCount()); + Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount()); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 1, glWindow1, glWindow1MA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, -- cgit v1.2.3 From ead9d65722ac8c647ac1dde654fd4e8250e4d572 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 13:36:54 +0100 Subject: NewtCanvasAWT: Add method of 'isAWTEventPassThrough()', used in unit tests to fix event validation for offscreen mode (OSX/CALayer) --- make/scripts/tests.sh | 4 ++-- src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 14 ++++++++++++++ .../newt/parenting/TestParentingFocus01SwingAWTRobot.java | 3 +++ .../newt/parenting/TestParentingFocus02SwingAWTRobot.java | 10 ++++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9510734a3..311bfd0a1 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -608,8 +608,8 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* # diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index f9f869781..5780f2540 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -735,6 +735,20 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto } } + /** + * Returns true if Key and Mouse input events will be passed through AWT, + * otherwise only the {@link #getNEWTChild() NEWT child} will receive them. + *

      + * Normally only the {@link #getNEWTChild() NEWT child} will receive Key and Mouse input events. + * In offscreen mode, e.g. OSX/CALayer, the AWT events will be received and translated into NEWT events + * and delivered to the NEWT child window.
      + * Note: AWT key events will {@link java.awt.event.InputEvent#consume() consumed} in pass-through mode. + *

      + */ + public final boolean isAWTEventPassThrough() { + return !isOnscreen; + } + private final void attachNewtChild() { if( null == newtChild || null == jawtWindow || newtChildAttached ) { return; // nop diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java index 54842cd6e..f45a48759 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java @@ -194,6 +194,9 @@ public class TestParentingFocus01SwingAWTRobot extends UITestCase { System.err.println("FOCUS NEWT Canvas/GLWindow sync"); AWTRobotUtil.assertKeyType(robot, java.awt.event.KeyEvent.VK_A, 2, glWindow1, glWindow1KA); Assert.assertEquals("AWT parent canvas received non consumed keyboard events", newtCanvasAWTKA.getConsumedCount(), newtCanvasAWTKA.getCount()); + if( !newtCanvasAWT.isAWTEventPassThrough() ) { + Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount()); + } // Remove listeners to avoid logging during dispose/destroy. glWindow1.removeKeyListener(glWindow1KA); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java index 3aa952e30..909fadda7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java @@ -220,7 +220,10 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase { glWindow1, glWindow1MA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, glWindow1, glWindow1MA); - Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount()); + if( !newtCanvasAWT.isAWTEventPassThrough() ) { + Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount()); + Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount()); + } // Button Inner Focus Thread.sleep(100); // allow event sync @@ -258,7 +261,10 @@ public class TestParentingFocus02SwingAWTRobot extends UITestCase { glWindow1, glWindow1MA); AWTRobotUtil.assertMouseClick(robot, java.awt.event.InputEvent.BUTTON1_MASK, 2, glWindow1, glWindow1MA); - Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount()); + if( !newtCanvasAWT.isAWTEventPassThrough() ) { + Assert.assertEquals("AWT parent canvas received consumed keyboard events", 0, newtCanvasAWTKA.getConsumedCount()); + Assert.assertEquals("AWT parent canvas received mouse events", 0, newtCanvasAWTMA.getCount()); + } animator1.stop(); Assert.assertEquals(false, animator1.isAnimating()); -- cgit v1.2.3 From a90185491d53bb79c98453b18c3e49768e51cec9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 13:41:35 +0100 Subject: NEWT Event Tests: Move TestParentingFocus* to event test package --- make/scripts/tests-win.bat | 7 +- make/scripts/tests.sh | 8 +- .../event/TestParentingFocus01SwingAWTRobot.java | 248 ++++++++++++++ .../event/TestParentingFocus02SwingAWTRobot.java | 324 +++++++++++++++++++ .../event/TestParentingFocus03KeyTraversalAWT.java | 360 +++++++++++++++++++++ .../TestParentingFocus01SwingAWTRobot.java | 248 -------------- .../TestParentingFocus02SwingAWTRobot.java | 324 ------------------- .../TestParentingFocus03KeyTraversalAWT.java | 359 -------------------- 8 files changed, 939 insertions(+), 939 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus01SwingAWTRobot.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus02SwingAWTRobot.java create mode 100644 src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus03KeyTraversalAWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus01SwingAWTRobot.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus02SwingAWTRobot.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParentingFocus03KeyTraversalAWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 17362185e..d0bae1b4b 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -123,6 +123,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventMo REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestParentingFocus01SwingAWTRobot %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestParentingFocus02SwingAWTRobot %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestParentingFocus03KeyTraversalAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenting02NEWT %* @@ -137,10 +140,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParenti REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT %* - REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTAccessor03AWTGLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 311bfd0a1..24c1e6f41 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -568,6 +568,10 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestParentingFocus01SwingAWTRobot $* +testawt com.jogamp.opengl.test.junit.newt.event.TestParentingFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestParentingFocus03KeyTraversalAWT $* + #testawt com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT #testawt com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleES1AWT $* @@ -608,10 +612,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentParentingAWT $* #testnoawt com.jogamp.opengl.test.junit.newt.parenting.TestTranslucentChildWindowBug632NEWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus01SwingAWTRobot $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus02SwingAWTRobot $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParentingFocus03KeyTraversalAWT $* - # # Misc Utils # diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus01SwingAWTRobot.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus01SwingAWTRobot.java new file mode 100644 index 000000000..d3c29cfac --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestParentingFocus01SwingAWTRobot.java @@ -0,0 +1,248 @@ +/** + * Copyright 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.opengl.test.junit.newt.event; + +import org.junit.Assert; +import org.junit.AfterClass; +import org.junit.Assume; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Container; +import java.awt.Robot; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.swing.JFrame; + +import java.util.ArrayList; +import java.io.IOException; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +import com.jogamp.newt.awt.NewtCanvasAWT; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; +import com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT; +import com.jogamp.opengl.test.junit.util.*; + +/** + * Testing focus mouse-click and programmatic traversal of an AWT component tree with {@link NewtCanvasAWT} attached. + *

      + * {@link JFrame} . {@link Container}+ [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ] + *

      + *

      + * + Container is the JFrame's implicit root content pane
      + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestParentingFocus01SwingAWTRobot extends UITestCase { + static int width, height; + static long durationPerTest = 10; + static long awtWaitTimeout = 1000; + + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() { + width = 640; + height = 480; + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + @Test + public void testFocus01ProgrFocus() throws AWTException, InterruptedException, InvocationTargetException { + testFocus01ProgrFocusImpl(null); + } + + @Test + public void testFocus02RobotFocus() throws AWTException, InterruptedException, InvocationTargetException { + Robot robot = new Robot(); + robot.setAutoWaitForIdle(true); + testFocus01ProgrFocusImpl(robot); + } + + private void testFocus01ProgrFocusImpl(Robot robot) throws AWTException, + InvocationTargetException, InterruptedException { + ArrayList eventCountAdapters = new ArrayList(); + + // Create a window. + GLWindow glWindow1 = GLWindow.create(glCaps); + glWindow1.setTitle("testNewtChildFocus"); + GLEventListener demo1 = new RedSquareES2(); + TestListenerCom01AWT.setDemoFields(demo1, glWindow1, false); + glWindow1.addGLEventListener(demo1); + NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + glWindow1.addWindowListener(glWindow1FA); + + // Monitor NEWT focus and keyboard events. + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + eventCountAdapters.add(glWindow1KA); + glWindow1.addKeyListener(glWindow1KA); + + // Wrap the window in a canvas. + final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + // newtCanvasAWT.setShallUseOffscreenLayer(true); + + // Monitor AWT focus and keyboard events. + AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT"); + newtCanvasAWT.addKeyListener(newtCanvasAWTKA); + eventCountAdapters.add(newtCanvasAWTKA); + AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT"); + newtCanvasAWT.addFocusListener(newtCanvasAWTFA); + + // Add the canvas to a frame, and make it all visible. + final JFrame frame1 = new JFrame("Swing AWT Parent Frame: " + + glWindow1.getTitle()); + frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); + final Button button = new Button("Click me .."); + AWTFocusAdapter buttonFA = new AWTFocusAdapter("Button"); + button.addFocusListener(buttonFA); + AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button"); + button.addKeyListener(buttonKA); + eventCountAdapters.add(buttonKA); + AWTMouseAdapter buttonMA = new AWTMouseAdapter("Button"); + button.addMouseListener(buttonMA); + eventCountAdapters.add(buttonMA); + + frame1.getContentPane().add(button, BorderLayout.NORTH); + frame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setVisible(true); + } } ); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); + AWTRobotUtil.clearAWTFocus(robot); + Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); + + Thread.sleep(durationPerTest); // manual testing + + int wait=0; + while(waitmouse-click and programmatic traversal of an AWT component tree with {@link NewtCanvasAWT} attached. + *

      + * {@link JFrame} . {@link JPanel}+ . {@link Container} [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ] + *

      + *

      + * + JPanel is set as JFrame's root content pane
      + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestParentingFocus02SwingAWTRobot extends UITestCase { + static int width, height; + static long durationPerTest = 10; + static long awtWaitTimeout = 1000; + static GLCapabilities glCaps; + + @BeforeClass + public static void initClass() throws AWTException, InterruptedException, InvocationTargetException { + width = 640; + height = 480; + + final JFrame f = new JFrame(); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f.setSize(100,100); + f.setVisible(true); + } } ); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + f.dispose(); + } } ); + + glCaps = new GLCapabilities(null); + } + + @AfterClass + public static void release() { + } + + private void testFocus01ProgrFocusImpl(Robot robot) + throws AWTException, InterruptedException, InvocationTargetException { + + ArrayList eventCountAdapters = new ArrayList(); + + GLWindow glWindow1 = GLWindow.create(glCaps); + glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); + GLEventListener demo1 = new GearsES2(); + glWindow1.addGLEventListener(demo1); + NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + glWindow1.addWindowListener(glWindow1FA); + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1.addKeyListener(glWindow1KA); + eventCountAdapters.add(glWindow1KA); + NEWTMouseAdapter glWindow1MA = new NEWTMouseAdapter("GLWindow1"); + glWindow1.addMouseListener(glWindow1MA); + eventCountAdapters.add(glWindow1MA); + + NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); + AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT"); + newtCanvasAWT.addFocusListener(newtCanvasAWTFA); + AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT"); + newtCanvasAWT.addKeyListener(newtCanvasAWTKA); + eventCountAdapters.add(newtCanvasAWTKA); + AWTMouseAdapter newtCanvasAWTMA = new AWTMouseAdapter("NewtCanvasAWT"); + newtCanvasAWT.addMouseListener(newtCanvasAWTMA); + eventCountAdapters.add(newtCanvasAWTMA); + + Button buttonNorthInner = new Button("north"); + AWTFocusAdapter buttonNorthInnerFA = new AWTFocusAdapter("ButtonNorthInner"); + buttonNorthInner.addFocusListener(buttonNorthInnerFA); + AWTKeyAdapter buttonNorthInnerKA = new AWTKeyAdapter("ButtonNorthInner"); + buttonNorthInner.addKeyListener(buttonNorthInnerKA); + eventCountAdapters.add(buttonNorthInnerKA); + AWTMouseAdapter buttonNorthInnerMA = new AWTMouseAdapter("ButtonNorthInner"); + buttonNorthInner.addMouseListener(buttonNorthInnerMA); + eventCountAdapters.add(buttonNorthInnerMA); + final Container container1 = new Container(); + container1.setLayout(new BorderLayout()); + container1.add(buttonNorthInner, BorderLayout.NORTH); + container1.add(new Button("south"), BorderLayout.SOUTH); + container1.add(new Button("east"), BorderLayout.EAST); + container1.add(new Button("west"), BorderLayout.WEST); + container1.add(newtCanvasAWT, BorderLayout.CENTER); + + Button buttonNorthOuter = new Button("north"); + AWTFocusAdapter buttonNorthOuterFA = new AWTFocusAdapter("ButtonNorthOuter"); + buttonNorthOuter.addFocusListener(buttonNorthOuterFA); + AWTKeyAdapter buttonNorthOuterKA = new AWTKeyAdapter("ButtonNorthOuter"); + buttonNorthOuter.addKeyListener(buttonNorthOuterKA); + eventCountAdapters.add(buttonNorthOuterKA); + AWTMouseAdapter buttonNorthOuterMA = new AWTMouseAdapter("ButtonNorthOuter"); + buttonNorthOuter.addMouseListener(buttonNorthOuterMA); + eventCountAdapters.add(buttonNorthOuterMA); + final JPanel jPanel1 = new JPanel(); + jPanel1.setLayout(new BorderLayout()); + jPanel1.add(buttonNorthOuter, BorderLayout.NORTH); + jPanel1.add(new Button("south"), BorderLayout.SOUTH); + jPanel1.add(new Button("east"), BorderLayout.EAST); + jPanel1.add(new Button("west"), BorderLayout.WEST); + jPanel1.add(container1, BorderLayout.CENTER); + + final JFrame jFrame1 = new JFrame("Swing Parent JFrame"); + // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! + jFrame1.setContentPane(jPanel1); + jFrame1.setSize(width, height); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + jFrame1.setVisible(true); + } } ); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(jFrame1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); + AWTRobotUtil.clearAWTFocus(robot); + Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, jFrame1)); + + int wait=0; + while(waitkey traversal of an AWT component tree with {@link NewtCanvasAWT} attached. + *

      + * {@link Frame} [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ] + *

      + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestParentingFocus03KeyTraversalAWT extends UITestCase { + static Dimension glSize, fSize; + static int numFocus = 8; + static long durationPerTest = numFocus * 200; + static GLCapabilities glCaps; + static boolean manual = false; + static boolean forceGL3 = false; + + @BeforeClass + public static void initClass() { + glSize = new Dimension(200,200); + fSize = new Dimension(300,300); + glCaps = new GLCapabilities( forceGL3 ? GLProfile.get(GLProfile.GL3) : null ); + } + + @Test + public void testWindowParentingAWTFocusTraversal01Onscreen() throws InterruptedException, InvocationTargetException, AWTException { + testWindowParentingAWTFocusTraversal(true); + } + + @Test + public void testWindowParentingAWTFocusTraversal02Offscreen() throws InterruptedException, InvocationTargetException, AWTException { + testWindowParentingAWTFocusTraversal(false); + } + + public void testWindowParentingAWTFocusTraversal(boolean onscreen) throws InterruptedException, InvocationTargetException, AWTException { + Robot robot = new Robot(); + + // Bug 4908075 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4908075 + // Bug 6463168 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6463168 + { + final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + final Set bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); + final AWTKeyStroke newBack = AWTKeyStroke.getAWTKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0, false); + Assert.assertNotNull(newBack); + final Set bwdKeys2 = new HashSet(bwdKeys); + bwdKeys2.add(newBack); + kfm.setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, bwdKeys2); + } + { + final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); + final Set fwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); + final Set bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); + Iterator iter; + for(iter = fwdKeys.iterator(); iter.hasNext(); ) { + System.err.println("FTKL.fwd-keys: "+iter.next()); + } + for(iter = bwdKeys.iterator(); iter.hasNext(); ) { + System.err.println("FTKL.bwd-keys: "+iter.next()); + } + } + + final Frame frame1 = new Frame("AWT Parent Frame"); + final Button cWest = new Button("WEST"); + final Button cEast = new Button("EAST"); + final GLWindow glWindow1 = GLWindow.create(glCaps); + glWindow1.setUpdateFPSFrames(1, null); + final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); + newtCanvasAWT1.setPreferredSize(glSize); + newtCanvasAWT1.setShallUseOffscreenLayer(!onscreen); + newtCanvasAWT1.setFocusable(true); + + // Test FocusAdapter + NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); + glWindow1.addWindowListener(glWindow1FA); + AWTFocusAdapter bWestFA = new AWTFocusAdapter("WEST"); + cWest.addFocusListener(bWestFA); + AWTFocusAdapter bEastFA = new AWTFocusAdapter("EAST"); + cEast.addFocusListener(bEastFA); + + // Test KeyAdapter + NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); + glWindow1.addKeyListener(glWindow1KA); + AWTKeyAdapter bWestKA = new AWTKeyAdapter("West"); + cWest.addKeyListener(bWestKA); + AWTKeyAdapter bEastKA = new AWTKeyAdapter("East"); + cEast.addKeyListener(bEastKA); + + // demo .. + GLEventListener demo1 = new GearsES2(1); + setDemoFields(demo1, glWindow1, false); + glWindow1.addGLEventListener(demo1); + glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); + glWindow1.addKeyListener(new KeyAdapter() { + public void keyReleased(KeyEvent e) { + if( !e.isPrintableKey() || e.isAutoRepeat() ) { + return; + } + if(e.getKeyChar()=='c') { + System.err.println("Focus Clear"); + if(glWindow1.getDelegatedWindow() instanceof DriverClearFocus) { + ((DriverClearFocus)glWindow1.getDelegatedWindow()).clearFocus(); + } + } else if(e.getKeyChar()=='e') { + System.err.println("Focus East"); + try { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + cEast.requestFocusInWindow(); + } + }); + } catch (Exception ex) { ex.printStackTrace(); } + } else if(e.getKeyChar()=='w') { + System.err.println("Focus West"); + try { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + cWest.requestFocusInWindow(); + } + }); + } catch (Exception ex) { ex.printStackTrace(); } + } + } + }); + GLAnimatorControl animator1 = new Animator(glWindow1); + animator1.start(); + + // make frame + frame1.setLayout(new BorderLayout()); + frame1.setLayout(new BorderLayout()); + frame1.add(cWest, BorderLayout.WEST); + frame1.add(newtCanvasAWT1, BorderLayout.CENTER); + frame1.add(cEast, BorderLayout.EAST); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.setLocation(0, 0); + frame1.setSize(fSize); + frame1.validate(); + frame1.setVisible(true); + }}); + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); + Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); + AWTRobotUtil.clearAWTFocus(robot); + Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); + + Assert.assertEquals(true, animator1.isAnimating()); + // Assert.assertEquals(false, animator1.isPaused()); + Assert.assertNotNull(animator1.getThread()); + + if(manual) { + Thread.sleep(durationPerTest); + } else { + // + // initial focus on bWest + // + AWTRobotUtil.assertRequestFocusAndWait(robot, cWest, cWest, bWestFA, null); + Thread.sleep(durationPerTest/numFocus); + + // + // forth + // + + // bWest -> glWin + AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, cWest, null); + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + Assert.assertEquals(true, glWindow1FA.focusGained()); + Assert.assertEquals(true, bWestFA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + // glWin -> bEast + AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, glWindow1, null); + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cEast, bEastFA, glWindow1FA)); + Assert.assertEquals(true, bEastFA.focusGained()); + Assert.assertEquals(true, glWindow1FA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + // + // back (using custom back traversal key 'backspace') + // + // bEast -> glWin + AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, cEast, null); + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bEastFA)); + Assert.assertEquals(true, glWindow1FA.focusGained()); + Assert.assertEquals(true, bEastFA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, glWindow1, null); + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); + Assert.assertEquals(true, bWestFA.focusGained()); + Assert.assertEquals(true, glWindow1FA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + System.err.println("Test: Direct NewtCanvasAWT focus"); + try { + java.awt.EventQueue.invokeAndWait(new Runnable() { + public void run() { + newtCanvasAWT1.requestFocus(); + } + }); + } catch (Exception ex) { ex.printStackTrace(); } + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + Assert.assertEquals(true, glWindow1FA.focusGained()); + Assert.assertEquals(true, bWestFA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + System.err.println("Test: Direct AWT Button-West focus"); + try { + java.awt.EventQueue.invokeAndWait(new Runnable() { + public void run() { + cWest.requestFocus(); + } + }); + } catch (Exception ex) { ex.printStackTrace(); } + Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); + Assert.assertEquals(true, bWestFA.focusGained()); + Assert.assertEquals(true, glWindow1FA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + + System.err.println("Test: Direct NEWT-Child request focus"); + glWindow1.requestFocus(); + { + // Short: Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); + // More verbose: + final boolean ok = AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA); + System.err.println("glWindow hasFocus "+glWindow1.hasFocus()); + System.err.println("glWindow1FA "+glWindow1FA); + System.err.println("bWestFA "+bWestFA); + Assert.assertTrue("Did not gain focus", ok); + } + Assert.assertEquals(true, glWindow1FA.focusGained()); + Assert.assertEquals(true, bWestFA.focusLost()); + Thread.sleep(durationPerTest/numFocus); + } + + animator1.stop(); + Assert.assertEquals(false, animator1.isAnimating()); + Assert.assertEquals(false, animator1.isPaused()); + Assert.assertEquals(null, animator1.getThread()); + + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame1.dispose(); + } } ); + glWindow1.destroy(); + } + + public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { + Assert.assertNotNull(demo); + Assert.assertNotNull(glWindow); + Window window = glWindow.getDelegatedWindow(); + if(debug) { + MiscUtils.setFieldIfExists(demo, "glDebug", true); + MiscUtils.setFieldIfExists(demo, "glTrace", true); + } + if(!MiscUtils.setFieldIfExists(demo, "window", window)) { + MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); + } + } + + static int atoi(String a) { + int i=0; + try { + i = Integer.parseInt(a); + } catch (Exception ex) { ex.printStackTrace(); } + return i; + } + + public static void main(String args[]) throws IOException { + for(int i=0; imouse-click and programmatic traversal of an AWT component tree with {@link NewtCanvasAWT} attached. - *

      - * {@link JFrame} . {@link Container}+ [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ] - *

      - *

      - * + Container is the JFrame's implicit root content pane
      - *

      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestParentingFocus01SwingAWTRobot extends UITestCase { - static int width, height; - static long durationPerTest = 10; - static long awtWaitTimeout = 1000; - - static GLCapabilities glCaps; - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - glCaps = new GLCapabilities(null); - } - - @AfterClass - public static void release() { - } - - @Test - public void testFocus01ProgrFocus() throws AWTException, InterruptedException, InvocationTargetException { - testFocus01ProgrFocusImpl(null); - } - - @Test - public void testFocus02RobotFocus() throws AWTException, InterruptedException, InvocationTargetException { - Robot robot = new Robot(); - robot.setAutoWaitForIdle(true); - testFocus01ProgrFocusImpl(robot); - } - - private void testFocus01ProgrFocusImpl(Robot robot) throws AWTException, - InvocationTargetException, InterruptedException { - ArrayList eventCountAdapters = new ArrayList(); - - // Create a window. - GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.setTitle("testNewtChildFocus"); - GLEventListener demo1 = new RedSquareES2(); - TestListenerCom01AWT.setDemoFields(demo1, glWindow1, false); - glWindow1.addGLEventListener(demo1); - NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); - glWindow1.addWindowListener(glWindow1FA); - - // Monitor NEWT focus and keyboard events. - NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); - eventCountAdapters.add(glWindow1KA); - glWindow1.addKeyListener(glWindow1KA); - - // Wrap the window in a canvas. - final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - // newtCanvasAWT.setShallUseOffscreenLayer(true); - - // Monitor AWT focus and keyboard events. - AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT"); - newtCanvasAWT.addKeyListener(newtCanvasAWTKA); - eventCountAdapters.add(newtCanvasAWTKA); - AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT"); - newtCanvasAWT.addFocusListener(newtCanvasAWTFA); - - // Add the canvas to a frame, and make it all visible. - final JFrame frame1 = new JFrame("Swing AWT Parent Frame: " - + glWindow1.getTitle()); - frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); - final Button button = new Button("Click me .."); - AWTFocusAdapter buttonFA = new AWTFocusAdapter("Button"); - button.addFocusListener(buttonFA); - AWTKeyAdapter buttonKA = new AWTKeyAdapter("Button"); - button.addKeyListener(buttonKA); - eventCountAdapters.add(buttonKA); - AWTMouseAdapter buttonMA = new AWTMouseAdapter("Button"); - button.addMouseListener(buttonMA); - eventCountAdapters.add(buttonMA); - - frame1.getContentPane().add(button, BorderLayout.NORTH); - frame1.setSize(width, height); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setVisible(true); - } } ); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); - AWTRobotUtil.clearAWTFocus(robot); - Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); - - Thread.sleep(durationPerTest); // manual testing - - int wait=0; - while(waitmouse-click and programmatic traversal of an AWT component tree with {@link NewtCanvasAWT} attached. - *

      - * {@link JFrame} . {@link JPanel}+ . {@link Container} [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ] - *

      - *

      - * + JPanel is set as JFrame's root content pane
      - *

      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestParentingFocus02SwingAWTRobot extends UITestCase { - static int width, height; - static long durationPerTest = 10; - static long awtWaitTimeout = 1000; - static GLCapabilities glCaps; - - @BeforeClass - public static void initClass() throws AWTException, InterruptedException, InvocationTargetException { - width = 640; - height = 480; - - final JFrame f = new JFrame(); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - f.setSize(100,100); - f.setVisible(true); - } } ); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - f.dispose(); - } } ); - - glCaps = new GLCapabilities(null); - } - - @AfterClass - public static void release() { - } - - private void testFocus01ProgrFocusImpl(Robot robot) - throws AWTException, InterruptedException, InvocationTargetException { - - ArrayList eventCountAdapters = new ArrayList(); - - GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); - GLEventListener demo1 = new GearsES2(); - glWindow1.addGLEventListener(demo1); - NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); - glWindow1.addWindowListener(glWindow1FA); - NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); - glWindow1.addKeyListener(glWindow1KA); - eventCountAdapters.add(glWindow1KA); - NEWTMouseAdapter glWindow1MA = new NEWTMouseAdapter("GLWindow1"); - glWindow1.addMouseListener(glWindow1MA); - eventCountAdapters.add(glWindow1MA); - - NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - AWTFocusAdapter newtCanvasAWTFA = new AWTFocusAdapter("NewtCanvasAWT"); - newtCanvasAWT.addFocusListener(newtCanvasAWTFA); - AWTKeyAdapter newtCanvasAWTKA = new AWTKeyAdapter("NewtCanvasAWT"); - newtCanvasAWT.addKeyListener(newtCanvasAWTKA); - eventCountAdapters.add(newtCanvasAWTKA); - AWTMouseAdapter newtCanvasAWTMA = new AWTMouseAdapter("NewtCanvasAWT"); - newtCanvasAWT.addMouseListener(newtCanvasAWTMA); - eventCountAdapters.add(newtCanvasAWTMA); - - Button buttonNorthInner = new Button("north"); - AWTFocusAdapter buttonNorthInnerFA = new AWTFocusAdapter("ButtonNorthInner"); - buttonNorthInner.addFocusListener(buttonNorthInnerFA); - AWTKeyAdapter buttonNorthInnerKA = new AWTKeyAdapter("ButtonNorthInner"); - buttonNorthInner.addKeyListener(buttonNorthInnerKA); - eventCountAdapters.add(buttonNorthInnerKA); - AWTMouseAdapter buttonNorthInnerMA = new AWTMouseAdapter("ButtonNorthInner"); - buttonNorthInner.addMouseListener(buttonNorthInnerMA); - eventCountAdapters.add(buttonNorthInnerMA); - final Container container1 = new Container(); - container1.setLayout(new BorderLayout()); - container1.add(buttonNorthInner, BorderLayout.NORTH); - container1.add(new Button("south"), BorderLayout.SOUTH); - container1.add(new Button("east"), BorderLayout.EAST); - container1.add(new Button("west"), BorderLayout.WEST); - container1.add(newtCanvasAWT, BorderLayout.CENTER); - - Button buttonNorthOuter = new Button("north"); - AWTFocusAdapter buttonNorthOuterFA = new AWTFocusAdapter("ButtonNorthOuter"); - buttonNorthOuter.addFocusListener(buttonNorthOuterFA); - AWTKeyAdapter buttonNorthOuterKA = new AWTKeyAdapter("ButtonNorthOuter"); - buttonNorthOuter.addKeyListener(buttonNorthOuterKA); - eventCountAdapters.add(buttonNorthOuterKA); - AWTMouseAdapter buttonNorthOuterMA = new AWTMouseAdapter("ButtonNorthOuter"); - buttonNorthOuter.addMouseListener(buttonNorthOuterMA); - eventCountAdapters.add(buttonNorthOuterMA); - final JPanel jPanel1 = new JPanel(); - jPanel1.setLayout(new BorderLayout()); - jPanel1.add(buttonNorthOuter, BorderLayout.NORTH); - jPanel1.add(new Button("south"), BorderLayout.SOUTH); - jPanel1.add(new Button("east"), BorderLayout.EAST); - jPanel1.add(new Button("west"), BorderLayout.WEST); - jPanel1.add(container1, BorderLayout.CENTER); - - final JFrame jFrame1 = new JFrame("Swing Parent JFrame"); - // jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - jFrame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); // equivalent to Frame, use windowClosing event! - jFrame1.setContentPane(jPanel1); - jFrame1.setSize(width, height); - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - jFrame1.setVisible(true); - } } ); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(jFrame1, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); - AWTRobotUtil.clearAWTFocus(robot); - Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, jFrame1)); - - int wait=0; - while(waitkey traversal of an AWT component tree with {@link NewtCanvasAWT} attached. - *

      - * {@link Frame} [ Button*, {@link NewtCanvasAWT} . {@link GLWindow} ] - *

      - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestParentingFocus03KeyTraversalAWT extends UITestCase { - static Dimension glSize, fSize; - static int numFocus = 8; - static long durationPerTest = numFocus * 200; - static GLCapabilities glCaps; - static boolean manual = false; - static boolean forceGL3 = false; - - @BeforeClass - public static void initClass() { - glSize = new Dimension(200,200); - fSize = new Dimension(300,300); - glCaps = new GLCapabilities( forceGL3 ? GLProfile.get(GLProfile.GL3) : null ); - } - - @Test - public void testWindowParentingAWTFocusTraversal01Onscreen() throws InterruptedException, InvocationTargetException, AWTException { - testWindowParentingAWTFocusTraversal(true); - } - - @Test - public void testWindowParentingAWTFocusTraversal02Offscreen() throws InterruptedException, InvocationTargetException, AWTException { - testWindowParentingAWTFocusTraversal(false); - } - - public void testWindowParentingAWTFocusTraversal(boolean onscreen) throws InterruptedException, InvocationTargetException, AWTException { - Robot robot = new Robot(); - - // Bug 4908075 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4908075 - // Bug 6463168 - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6463168 - { - final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - final Set bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); - final AWTKeyStroke newBack = AWTKeyStroke.getAWTKeyStroke(java.awt.event.KeyEvent.VK_BACK_SPACE, 0, false); - Assert.assertNotNull(newBack); - final Set bwdKeys2 = new HashSet(bwdKeys); - bwdKeys2.add(newBack); - kfm.setDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, bwdKeys2); - } - { - final KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - final Set fwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS); - final Set bwdKeys = kfm.getDefaultFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS); - Iterator iter; - for(iter = fwdKeys.iterator(); iter.hasNext(); ) { - System.err.println("FTKL.fwd-keys: "+iter.next()); - } - for(iter = bwdKeys.iterator(); iter.hasNext(); ) { - System.err.println("FTKL.bwd-keys: "+iter.next()); - } - } - - final Frame frame1 = new Frame("AWT Parent Frame"); - final Button cWest = new Button("WEST"); - final Button cEast = new Button("EAST"); - final GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.setUpdateFPSFrames(1, null); - final NewtCanvasAWT newtCanvasAWT1 = new NewtCanvasAWT(glWindow1); - newtCanvasAWT1.setPreferredSize(glSize); - newtCanvasAWT1.setShallUseOffscreenLayer(!onscreen); - newtCanvasAWT1.setFocusable(true); - - // Test FocusAdapter - NEWTFocusAdapter glWindow1FA = new NEWTFocusAdapter("GLWindow1"); - glWindow1.addWindowListener(glWindow1FA); - AWTFocusAdapter bWestFA = new AWTFocusAdapter("WEST"); - cWest.addFocusListener(bWestFA); - AWTFocusAdapter bEastFA = new AWTFocusAdapter("EAST"); - cEast.addFocusListener(bEastFA); - - // Test KeyAdapter - NEWTKeyAdapter glWindow1KA = new NEWTKeyAdapter("GLWindow1"); - glWindow1.addKeyListener(glWindow1KA); - AWTKeyAdapter bWestKA = new AWTKeyAdapter("West"); - cWest.addKeyListener(bWestKA); - AWTKeyAdapter bEastKA = new AWTKeyAdapter("East"); - cEast.addKeyListener(bEastKA); - - // demo .. - GLEventListener demo1 = new GearsES2(1); - setDemoFields(demo1, glWindow1, false); - glWindow1.addGLEventListener(demo1); - glWindow1.addKeyListener(new NewtAWTReparentingKeyAdapter(frame1, newtCanvasAWT1, glWindow1, null)); - glWindow1.addKeyListener(new KeyAdapter() { - public void keyReleased(KeyEvent e) { - if( !e.isPrintableKey() || e.isAutoRepeat() ) { - return; - } - if(e.getKeyChar()=='c') { - System.err.println("Focus Clear"); - if(glWindow1.getDelegatedWindow() instanceof DriverClearFocus) { - ((DriverClearFocus)glWindow1.getDelegatedWindow()).clearFocus(); - } - } else if(e.getKeyChar()=='e') { - System.err.println("Focus East"); - try { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - cEast.requestFocusInWindow(); - } - }); - } catch (Exception ex) { ex.printStackTrace(); } - } else if(e.getKeyChar()=='w') { - System.err.println("Focus West"); - try { - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - cWest.requestFocusInWindow(); - } - }); - } catch (Exception ex) { ex.printStackTrace(); } - } - } - }); - GLAnimatorControl animator1 = new Animator(glWindow1); - animator1.start(); - - // make frame - frame1.setLayout(new BorderLayout()); - frame1.setLayout(new BorderLayout()); - frame1.add(cWest, BorderLayout.WEST); - frame1.add(newtCanvasAWT1, BorderLayout.CENTER); - frame1.add(cEast, BorderLayout.EAST); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.setLocation(0, 0); - frame1.setSize(fSize); - frame1.validate(); - frame1.setVisible(true); - }}); - Assert.assertEquals(true, AWTRobotUtil.waitForVisible(glWindow1, true)); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow1, true)); - Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); - AWTRobotUtil.clearAWTFocus(robot); - Assert.assertTrue(AWTRobotUtil.toFrontAndRequestFocus(robot, frame1)); - - Assert.assertEquals(true, animator1.isAnimating()); - // Assert.assertEquals(false, animator1.isPaused()); - Assert.assertNotNull(animator1.getThread()); - - if(manual) { - Thread.sleep(durationPerTest); - } else { - // - // initial focus on bWest - // - AWTRobotUtil.assertRequestFocusAndWait(robot, cWest, cWest, bWestFA, null); - Thread.sleep(durationPerTest/numFocus); - - // - // forth - // - - // bWest -> glWin - AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, cWest, null); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); - Assert.assertEquals(true, glWindow1FA.focusGained()); - Assert.assertEquals(true, bWestFA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - // glWin -> bEast - AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_TAB, glWindow1, null); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cEast, bEastFA, glWindow1FA)); - Assert.assertEquals(true, bEastFA.focusGained()); - Assert.assertEquals(true, glWindow1FA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - // - // back (using custom back traversal key 'backspace') - // - // bEast -> glWin - AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, cEast, null); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bEastFA)); - Assert.assertEquals(true, glWindow1FA.focusGained()); - Assert.assertEquals(true, bEastFA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - AWTRobotUtil.keyType(0, robot, java.awt.event.KeyEvent.VK_BACK_SPACE, glWindow1, null); - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); - Assert.assertEquals(true, bWestFA.focusGained()); - Assert.assertEquals(true, glWindow1FA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - System.err.println("Test: Direct NewtCanvasAWT focus"); - try { - java.awt.EventQueue.invokeAndWait(new Runnable() { - public void run() { - newtCanvasAWT1.requestFocus(); - } - }); - } catch (Exception ex) { ex.printStackTrace(); } - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); - Assert.assertEquals(true, glWindow1FA.focusGained()); - Assert.assertEquals(true, bWestFA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - System.err.println("Test: Direct AWT Button-West focus"); - try { - java.awt.EventQueue.invokeAndWait(new Runnable() { - public void run() { - cWest.requestFocus(); - } - }); - } catch (Exception ex) { ex.printStackTrace(); } - Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(cWest, bWestFA, glWindow1FA)); - Assert.assertEquals(true, bWestFA.focusGained()); - Assert.assertEquals(true, glWindow1FA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - - System.err.println("Test: Direct NEWT-Child request focus"); - glWindow1.requestFocus(); - { - // Short: Assert.assertTrue("Did not gain focus", AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA)); - // More verbose: - final boolean ok = AWTRobotUtil.waitForFocus(glWindow1, glWindow1FA, bWestFA); - System.err.println("glWindow hasFocus "+glWindow1.hasFocus()); - System.err.println("glWindow1FA "+glWindow1FA); - System.err.println("bWestFA "+bWestFA); - Assert.assertTrue("Did not gain focus", ok); - } - Assert.assertEquals(true, glWindow1FA.focusGained()); - Assert.assertEquals(true, bWestFA.focusLost()); - Thread.sleep(durationPerTest/numFocus); - } - - animator1.stop(); - Assert.assertEquals(false, animator1.isAnimating()); - Assert.assertEquals(false, animator1.isPaused()); - Assert.assertEquals(null, animator1.getThread()); - - javax.swing.SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame1.dispose(); - } } ); - glWindow1.destroy(); - } - - public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { - Assert.assertNotNull(demo); - Assert.assertNotNull(glWindow); - Window window = glWindow.getDelegatedWindow(); - if(debug) { - MiscUtils.setFieldIfExists(demo, "glDebug", true); - MiscUtils.setFieldIfExists(demo, "glTrace", true); - } - if(!MiscUtils.setFieldIfExists(demo, "window", window)) { - MiscUtils.setFieldIfExists(demo, "glWindow", glWindow); - } - } - - static int atoi(String a) { - int i=0; - try { - i = Integer.parseInt(a); - } catch (Exception ex) { ex.printStackTrace(); } - return i; - } - - public static void main(String args[]) throws IOException { - for(int i=0; i Date: Mon, 18 Nov 2013 15:34:42 +0100 Subject: Bug 890 - GLContextImpl's Version Validation: Only validate Integer based Version if requested context or string-version is >= 3.0 .. otherwise, spec doesn't require integer based version to work! --- make/scripts/adb-logcat.sh | 2 +- make/scripts/tests.sh | 8 ++++---- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 24 ++++++++++++++++------- 3 files changed, 22 insertions(+), 12 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/adb-logcat.sh b/make/scripts/adb-logcat.sh index ea4be3d61..443011f84 100755 --- a/make/scripts/adb-logcat.sh +++ b/make/scripts/adb-logcat.sh @@ -1,4 +1,4 @@ sdir=`dirname $0` adb $* logcat -c -adb $* logcat +adb $* logcat 2>&1 | tee adb-logcat.log diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 24c1e6f41..2a97b42bc 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -106,7 +106,7 @@ function jrun() { #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" + D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" @@ -199,7 +199,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" - D_ARGS="-Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -305,7 +305,7 @@ function testawtswt() { #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* -#testnoawt com.jogamp.newt.opengl.GLWindow $* +testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* @@ -569,7 +569,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT $* #testawtswt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasSWTAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestParentingFocus01SwingAWTRobot $* -testawt com.jogamp.opengl.test.junit.newt.event.TestParentingFocus02SwingAWTRobot $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestParentingFocus02SwingAWTRobot $* #testawt com.jogamp.opengl.test.junit.newt.event.TestParentingFocus03KeyTraversalAWT $* diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 42c877ad5..8885c3220 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1378,6 +1378,7 @@ public abstract class GLContextImpl extends GLContext { final AbstractGraphicsDevice adevice = aconfig.getScreen().getDevice(); final int reqCtxProfileBits = ctxProfileBits; final VersionNumber reqGLVersion = new VersionNumber(major, minor, 0); + final VersionNumber hasGLVersionByString; { final boolean initGLRendererAndGLVersionStringsOK = initGLRendererAndGLVersionStrings(); if( !initGLRendererAndGLVersionStringsOK ) { @@ -1392,8 +1393,13 @@ public abstract class GLContextImpl extends GLContext { // unusable GL context - non query mode - hard fail! throw new GLException(errMsg); } - } else if(DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Given "+adevice+" - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)); + } else { + hasGLVersionByString = getGLVersionNumber(ctxProfileBits, glVersion); + if(DEBUG) { + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Given "+adevice+ + " - "+GLContext.getGLVersion(major, minor, ctxProfileBits, glVersion)+ + ", Number(Str) "+hasGLVersionByString); + } } } @@ -1430,11 +1436,16 @@ public abstract class GLContextImpl extends GLContext { hasGLVersionByInt = new VersionNumber(glIntMajor[0], glIntMinor[0], 0); } if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (Int): String "+glVersion+", Number "+hasGLVersionByInt); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (Int): String "+glVersion+", Number(Int) "+hasGLVersionByInt); } - // Only validate if a valid int version was fetched, otherwise cont. w/ version-string method -> 3.0 > Version || Version > MAX! - if ( GLContext.isValidGLVersion(ctxProfileBits, hasGLVersionByInt.getMajor(), hasGLVersionByInt.getMinor()) ) { + // Only validate integer based version if: + // - ctx >= 3.0 is requested _or_ string-version >= 3.0 + // - _and_ a valid int version was fetched, + // otherwise cont. w/ version-string method -> 3.0 > Version || Version > MAX! + // + if ( ( major >= 3 || hasGLVersionByString.compareTo(Version300) >= 0 ) && + GLContext.isValidGLVersion(ctxProfileBits, hasGLVersionByInt.getMajor(), hasGLVersionByInt.getMinor()) ) { // Strict Match (GLVersionMapping): // Relaxed match for versions ( !isES && major < 3 ) requests, last resort! // Otherwise: @@ -1464,9 +1475,8 @@ public abstract class GLContextImpl extends GLContext { versionValidated = true; } else { // Validate the requested version w/ the GL-version from the version string. - final VersionNumber hasGLVersionByString = getGLVersionNumber(ctxProfileBits, glVersion); if (DEBUG) { - System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (String): String "+glVersion+", Number "+hasGLVersionByString); + System.err.println(getThreadName() + ": GLContext.setGLFuncAvail: Version verification (String): String "+glVersion+", Number(Str) "+hasGLVersionByString); } // Only validate if a valid string version was fetched -> MIN > Version || Version > MAX! -- cgit v1.2.3 From d8f7418f170aba4703df2b11d5ae11598f71a796 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 18 Nov 2013 16:12:52 +0100 Subject: Fix Bug 893 - NewtCanvasAWT Lifecycle Race Condition (NPE on shutdown periodically) As suggested: Employ synchronization on lifecycle actions _and_ perform destroyImpl(..) always on AWT-EDT to avoid a deadlock. --- make/scripts/tests.sh | 8 +- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 347 +++++++++++---------- 2 files changed, 189 insertions(+), 166 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 2a97b42bc..157c8703a 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -106,7 +106,7 @@ function jrun() { #D_ARGS="-Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject -Djogl.debug.GLContext -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" - D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" @@ -199,7 +199,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" - #D_ARGS="-Dnewt.debug.Window" + D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" @@ -305,7 +305,7 @@ function testawtswt() { #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* -testnoawt com.jogamp.newt.opengl.GLWindow $* +#testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* @@ -319,7 +319,7 @@ testnoawt com.jogamp.newt.opengl.GLWindow $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 5780f2540..49bd0d778 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -95,6 +95,7 @@ import com.jogamp.opengl.util.TileRenderer; public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProtocol, OffscreenLayerOption, AWTPrintLifecycle { public static final boolean DEBUG = Debug.debug("Window"); + private final Object sync = new Object(); private JAWTWindow jawtWindow = null; private boolean shallUseOffscreenLayer = false; private Window newtChild = null; @@ -178,7 +179,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public final boolean isOffscreenLayerSurfaceEnabled() { - return jawtWindow.isOffscreenLayerSurfaceEnabled(); + final JAWTWindow w = jawtWindow; + return null != w && w.isOffscreenLayerSurfaceEnabled(); } /** @@ -187,7 +189,8 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * ie. before adding the component to the AWT tree and make it visible. */ public boolean isApplet() { - return jawtWindow.isApplet(); + final JAWTWindow w = jawtWindow; + return null != w && w.isApplet(); } boolean isParent() { @@ -353,29 +356,32 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * @return the previous attached newt child. */ public Window setNEWTChild(Window newChild) { - final Window prevChild = newtChild; - if(DEBUG) { - System.err.println("NewtCanvasAWT.setNEWTChild.0: win "+newtWinHandleToHexString(prevChild)+" -> "+newtWinHandleToHexString(newChild)); - } - final java.awt.Container cont = AWTMisc.getContainer(this); - // remove old one - if(null != newtChild) { - detachNewtChild( cont ); - newtChild = null; - } - // add new one, reparent only if ready - newtChild = newChild; + synchronized(sync) { + final Window prevChild = newtChild; + if(DEBUG) { + System.err.println("NewtCanvasAWT.setNEWTChild.0: win "+newtWinHandleToHexString(prevChild)+" -> "+newtWinHandleToHexString(newChild)); + } + final java.awt.Container cont = AWTMisc.getContainer(this); + // remove old one + if(null != newtChild) { + detachNewtChild( cont ); + newtChild = null; + } + // add new one, reparent only if ready + newtChild = newChild; - updateLayoutSize(); - // will be done later at paint/display/..: attachNewtChild(cont); + updateLayoutSize(); + // will be done later at paint/display/..: attachNewtChild(cont); - return prevChild; + return prevChild; + } } private final void updateLayoutSize() { - if( null != newtChild ) { + final Window w = newtChild; + if( null != w ) { // use NEWT child's size for min/pref size! - java.awt.Dimension minSize = new java.awt.Dimension(newtChild.getWidth(), newtChild.getHeight()); + java.awt.Dimension minSize = new java.awt.Dimension(w.getWidth(), w.getHeight()); setMinimumSize(minSize); setPreferredSize(minSize); } @@ -414,15 +420,17 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto // after native peer is valid: Windows disableBackgroundErase(); - jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); - jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); + synchronized(sync) { + jawtWindow = NewtFactoryAWT.getNativeWindow(this, null != newtChild ? newtChild.getRequestedCapabilities() : null); + jawtWindow.setShallUseOffscreenLayer(shallUseOffscreenLayer); - if(DEBUG) { - // if ( isShowing() == false ) -> Container was not visible yet. - // if ( isShowing() == true ) -> Container is already visible. - System.err.println("NewtCanvasAWT.addNotify: win "+newtWinHandleToHexString(newtChild)+ - ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+ - ", displayable "+isDisplayable()+", cont "+AWTMisc.getContainer(this)); + if(DEBUG) { + // if ( isShowing() == false ) -> Container was not visible yet. + // if ( isShowing() == true ) -> Container is already visible. + System.err.println("NewtCanvasAWT.addNotify: win "+newtWinHandleToHexString(newtChild)+ + ", comp "+this+", visible "+isVisible()+", showing "+isShowing()+ + ", displayable "+isDisplayable()+", cont "+AWTMisc.getContainer(this)); + } } } awtWindowClosingProtocol.addClosingListener(); @@ -451,38 +459,45 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto * @see Window#destroy() */ public final void destroy() { - destroyImpl(false /* removeNotify */, false /* windowClosing */); + AWTEDTExecutor.singleton.invoke(true, new Runnable() { + public void run() { + destroyImpl(false /* removeNotify */, false /* windowClosing */); + } } ); } private final void destroyImpl(boolean removeNotify, boolean windowClosing) { - if( null !=newtChild ) { - java.awt.Container cont = AWTMisc.getContainer(this); - if(DEBUG) { - System.err.println("NewtCanvasAWT.destroy(removeNotify "+removeNotify+", windowClosing "+windowClosing+"): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); - } - detachNewtChild(cont); - - if( !removeNotify ) { - final Window cWin = newtChild; - final Window dWin = cWin.getDelegatedWindow(); - newtChild=null; - if( windowClosing && dWin instanceof WindowImpl ) { - ((WindowImpl)dWin).windowDestroyNotify(true); - } else { - cWin.destroy(); + synchronized(sync) { + if( null !=newtChild ) { + java.awt.Container cont = AWTMisc.getContainer(this); + if(DEBUG) { + System.err.println("NewtCanvasAWT.destroy(removeNotify "+removeNotify+", windowClosing "+windowClosing+"): nw "+newtWinHandleToHexString(newtChild)+", from "+cont); + } + detachNewtChild(cont); + + if( !removeNotify ) { + final Window cWin = newtChild; + final Window dWin = cWin.getDelegatedWindow(); + newtChild=null; + if( windowClosing && dWin instanceof WindowImpl ) { + ((WindowImpl)dWin).windowDestroyNotify(true); + } else { + cWin.destroy(); + } } } - } - if( ( removeNotify || windowClosing ) && null!=jawtWindow ) { - NewtFactoryAWT.destroyNativeWindow(jawtWindow); - jawtWindow=null; + if( ( removeNotify || windowClosing ) && null!=jawtWindow ) { + NewtFactoryAWT.destroyNativeWindow(jawtWindow); + jawtWindow=null; + } } } @Override public void paint(Graphics g) { - if( validateComponent(true) && !printActive ) { - newtChild.windowRepaint(0, 0, getWidth(), getHeight()); + synchronized(sync) { + if( validateComponent(true) && !printActive ) { + newtChild.windowRepaint(0, 0, getWidth(), getHeight()); + } } } @Override @@ -494,12 +509,14 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto @Override public void reshape(int x, int y, int width, int height) { synchronized (getTreeLock()) { // super.reshape(..) claims tree lock, so we do extend it's lock over reshape - super.reshape(x, y, width, height); - if(DEBUG) { - System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); - } - if( validateComponent(true) ) { - // newtChild.setSize(width, height); + synchronized(sync) { + super.reshape(x, y, width, height); + if(DEBUG) { + System.err.println("NewtCanvasAWT.reshape: "+x+"/"+y+" "+width+"x"+height); + } + if( validateComponent(true) ) { + // newtChild.setSize(width, height); + } } } } @@ -527,73 +544,75 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final Runnable setupPrintOnEDT = new Runnable() { @Override public void run() { - if( !validateComponent(true) ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); + synchronized(sync) { + if( !validateComponent(true) ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable not valid yet"); + } + printActive = false; + return; // not yet available .. } - printActive = false; - return; // not yet available .. - } - if( !isVisible() ) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + if( !isVisible() ) { + if(DEBUG) { + System.err.println(getThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + } + printActive = false; + return; // not yet available .. } - printActive = false; - return; // not yet available .. - } - final GLAutoDrawable glad = getGLAD(); - if( null == glad ) { + final GLAutoDrawable glad = getGLAD(); + if( null == glad ) { + if( DEBUG ) { + System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); + } + printActive = false; + return; + } + printAnimator = glad.getAnimator(); + if( null != printAnimator ) { + printAnimator.remove(glad); + } + printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD + final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); + final int printNumSamples = printAWTTiles.getNumSamples(caps); + GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); + final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); + final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || + printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); + final boolean reqNewGLADOnscrn = caps.isOnscreen(); + + // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. + // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX + final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); if( DEBUG ) { - System.err.println("AWT print.setup exit, newtChild not a GLAutoDrawable: "+newtChild); + System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ + ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ + ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ + ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ + ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); } - printActive = false; - return; - } - printAnimator = glad.getAnimator(); - if( null != printAnimator ) { - printAnimator.remove(glad); - } - printGLAD = glad; // _not_ default, shall be replaced by offscreen GLAD - final GLCapabilities caps = (GLCapabilities)glad.getChosenGLCapabilities().cloneMutable(); - final int printNumSamples = printAWTTiles.getNumSamples(caps); - GLDrawable printDrawable = printGLAD.getDelegatedDrawable(); - final boolean reqNewGLADSamples = printNumSamples != caps.getNumSamples(); - final boolean reqNewGLADSize = printAWTTiles.customTileWidth != -1 && printAWTTiles.customTileWidth != printDrawable.getWidth() || - printAWTTiles.customTileHeight != -1 && printAWTTiles.customTileHeight != printDrawable.getHeight(); - final boolean reqNewGLADOnscrn = caps.isOnscreen(); - - // It is desired to use a new offscreen GLAD, however Bug 830 forbids this for AA onscreen context. - // Bug 830: swapGLContextAndAllGLEventListener and onscreen MSAA w/ NV/GLX - final boolean reqNewGLAD = !caps.getSampleBuffers() && ( reqNewGLADOnscrn || reqNewGLADSamples || reqNewGLADSize ); - if( DEBUG ) { - System.err.println("AWT print.setup: reqNewGLAD "+reqNewGLAD+"[ onscreen "+reqNewGLADOnscrn+", samples "+reqNewGLADSamples+", size "+reqNewGLADSize+"], "+ - ", drawableSize "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+ - ", customTileSize "+printAWTTiles.customTileWidth+"x"+printAWTTiles.customTileHeight+ - ", scaleMat "+printAWTTiles.scaleMatX+" x "+printAWTTiles.scaleMatY+ - ", numSamples "+printAWTTiles.customNumSamples+" -> "+printNumSamples+", printAnimator "+printAnimator); - } - if( reqNewGLAD ) { - caps.setDoubleBuffered(false); - caps.setOnscreen(false); - if( printNumSamples != caps.getNumSamples() ) { - caps.setSampleBuffers(0 < printNumSamples); - caps.setNumSamples(printNumSamples); + if( reqNewGLAD ) { + caps.setDoubleBuffered(false); + caps.setOnscreen(false); + if( printNumSamples != caps.getNumSamples() ) { + caps.setSampleBuffers(0 < printNumSamples); + caps.setNumSamples(printNumSamples); + } + final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); + printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, + printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, + printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); + GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); + printDrawable = printGLAD.getDelegatedDrawable(); + } + printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); + printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); + printAWTTiles.renderer.attachAutoDrawable(printGLAD); + if( DEBUG ) { + System.err.println("AWT print.setup "+printAWTTiles); + System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); + System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); + System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); } - final GLDrawableFactory factory = GLDrawableFactory.getFactory(caps.getGLProfile()); - printGLAD = factory.createOffscreenAutoDrawable(null, caps, null, - printAWTTiles.customTileWidth != -1 ? printAWTTiles.customTileWidth : DEFAULT_PRINT_TILE_SIZE, - printAWTTiles.customTileHeight != -1 ? printAWTTiles.customTileHeight : DEFAULT_PRINT_TILE_SIZE); - GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); - printDrawable = printGLAD.getDelegatedDrawable(); - } - printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); - printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); - printAWTTiles.renderer.attachAutoDrawable(printGLAD); - if( DEBUG ) { - System.err.println("AWT print.setup "+printAWTTiles); - System.err.println("AWT print.setup AA "+printNumSamples+", "+caps); - System.err.println("AWT print.setup printGLAD: "+printGLAD.getWidth()+"x"+printGLAD.getHeight()+", "+printGLAD); - System.err.println("AWT print.setup printDraw: "+printDrawable.getWidth()+"x"+printDrawable.getHeight()+", "+printDrawable); } } }; @@ -610,61 +629,65 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto private final Runnable releasePrintOnEDT = new Runnable() { @Override public void run() { - if( DEBUG ) { - System.err.println("AWT print.release "+printAWTTiles); - } - final GLAutoDrawable glad = getGLAD(); - printAWTTiles.dispose(); - printAWTTiles= null; - if( printGLAD != glad ) { - GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, glad); - printGLAD.destroy(); - } - printGLAD = null; - if( null != printAnimator ) { - printAnimator.add(glad); - printAnimator = null; + synchronized(sync) { + if( DEBUG ) { + System.err.println("AWT print.release "+printAWTTiles); + } + final GLAutoDrawable glad = getGLAD(); + printAWTTiles.dispose(); + printAWTTiles= null; + if( printGLAD != glad ) { + GLDrawableUtil.swapGLContextAndAllGLEventListener(printGLAD, glad); + printGLAD.destroy(); + } + printGLAD = null; + if( null != printAnimator ) { + printAnimator.add(glad); + printAnimator = null; + } + printActive = false; } - printActive = false; } }; @Override public void print(Graphics graphics) { - if( !printActive || null == printGLAD ) { - throw new IllegalStateException("setupPrint() not called"); - } - if(DEBUG && !EventQueue.isDispatchThread()) { - System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); - // we cannot dispatch print on AWT-EDT due to printing internal locking .. - } - - final Graphics2D g2d = (Graphics2D)graphics; - try { - printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); - final TileRenderer tileRenderer = printAWTTiles.renderer; - if( DEBUG ) { - System.err.println("AWT print.0: "+tileRenderer); + synchronized(sync) { + if( !printActive || null == printGLAD ) { + throw new IllegalStateException("setupPrint() not called"); } - if( !tileRenderer.eot() ) { - try { - do { - tileRenderer.display(); - } while ( !tileRenderer.eot() ); - if( DEBUG ) { - System.err.println("AWT print.1: "+printAWTTiles); + if(DEBUG && !EventQueue.isDispatchThread()) { + System.err.println(getThreadName()+": Warning: GLCanvas print - not called from AWT-EDT"); + // we cannot dispatch print on AWT-EDT due to printing internal locking .. + } + + final Graphics2D g2d = (Graphics2D)graphics; + try { + printAWTTiles.setupGraphics2DAndClipBounds(g2d, getWidth(), getHeight()); + final TileRenderer tileRenderer = printAWTTiles.renderer; + if( DEBUG ) { + System.err.println("AWT print.0: "+tileRenderer); + } + if( !tileRenderer.eot() ) { + try { + do { + tileRenderer.display(); + } while ( !tileRenderer.eot() ); + if( DEBUG ) { + System.err.println("AWT print.1: "+printAWTTiles); + } + tileRenderer.reset(); + } finally { + printAWTTiles.resetGraphics2D(); } - tileRenderer.reset(); - } finally { - printAWTTiles.resetGraphics2D(); } + } catch (NoninvertibleTransformException nte) { + System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); + nte.printStackTrace(); + } + if( DEBUG ) { + System.err.println("AWT print.X: "+printAWTTiles); } - } catch (NoninvertibleTransformException nte) { - System.err.println("Catched: Inversion failed of: "+g2d.getTransform()); - nte.printStackTrace(); - } - if( DEBUG ) { - System.err.println("AWT print.X: "+printAWTTiles); } } -- cgit v1.2.3 From 94f3c1b5d3af65cf9d985833b2c8e40ec1af4592 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 21 Nov 2013 01:42:54 +0100 Subject: Bug 909 - Reccreate GLJPanel's BufferedImage is no more sourced by singleton AWTGLPixelBuffer GLJPanel must validate whether it's local BufferedImage's DataBuffer is sourced by the current singleton AWTGLPixelBuffer. Case: GLJPanel-B has created a new singleton AWTGLPixelBuffer w/ increased size. Previous created GLJPanel-A's local BufferedImage's DataBuffer is no more sourced by the singleton AWTGLPixelBuffer and hence must be re-created. --- make/scripts/tests.sh | 6 +- .../jogamp/opengl/util/awt/AWTGLPixelBuffer.java | 30 +-- .../classes/javax/media/opengl/awt/GLJPanel.java | 18 +- .../junit/jogl/awt/TestGLJPanelResize01AWT.java | 209 +++++++++++++++++++++ 4 files changed, 240 insertions(+), 23 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelResize01AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 157c8703a..809aceb0c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -199,11 +199,12 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" - D_ARGS="-Dnewt.debug.Window" + #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" + D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL" #D_ARGS="-Djogl.gljpanel.noverticalflip" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" @@ -319,7 +320,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -528,6 +529,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java index 77b14b424..a33356067 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLPixelBuffer.java @@ -101,20 +101,24 @@ public class AWTGLPixelBuffer extends GLPixelBuffer { if( width * height > image.getWidth() * image.getHeight() ) { throw new IllegalArgumentException("Requested size exceeds image size: "+width+"x"+height+" > "+image.getWidth()+"x"+image.getHeight()); } - if( width == image.getWidth() ) { - if( height == image.getHeight() ) { - return image; - } - return image.getSubimage(0, 0, width, height); + if( width == image.getWidth() && height == image.getHeight() ) { + return image; + } else { + final ColorModel cm = image.getColorModel(); + final WritableRaster raster0 = image.getRaster(); + final DataBuffer dataBuffer = raster0.getDataBuffer(); + final SinglePixelPackedSampleModel sppsm0 = (SinglePixelPackedSampleModel) raster0.getSampleModel(); + final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), + width, height, width /* scanLineStride */, sppsm0.getBitMasks()); + final WritableRaster raster1 = WritableRaster.createWritableRaster(sppsm1, dataBuffer, null); + return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null); } - final ColorModel cm = image.getColorModel(); - final WritableRaster raster = image.getRaster(); - final DataBuffer dataBuffer = raster.getDataBuffer(); - final SinglePixelPackedSampleModel sppsm0 = (SinglePixelPackedSampleModel) raster.getSampleModel(); - final SinglePixelPackedSampleModel sppsm1 = new SinglePixelPackedSampleModel(dataBuffer.getDataType(), - width, height, width /* scanLineStride */, sppsm0.getBitMasks()); - final WritableRaster raster1 = WritableRaster.createWritableRaster(sppsm1, dataBuffer, null); - return new BufferedImage (cm, raster1, cm.isAlphaPremultiplied(), null); + } + + public final boolean isDataBufferSource(BufferedImage imageU) { + final DataBuffer dataBuffer0 = image.getRaster().getDataBuffer(); + final DataBuffer dataBufferU = imageU.getRaster().getDataBuffer(); + return dataBufferU == dataBuffer0; } @Override diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index bff8a1880..70dd8b99d 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -580,7 +580,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing super.reshape(x, y, width, height); if( DEBUG ) { - System.err.println(getThreadName()+": GLJPanel.reshape resize"+(printActive?"WithinPrint":"")+" [ panel "+ + System.err.println(getThreadName()+": GLJPanel.reshape.0 "+this.getName()+" resize"+(printActive?"WithinPrint":"")+" [ this "+getWidth()+"x"+getHeight()+", panel "+ panelWidth+"x"+panelHeight + ", reshape: " +reshapeWidth+"x"+reshapeHeight + "] -> "+(printActive?"skipped":"") + width+"x"+height); @@ -1588,19 +1588,21 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } pixelBuffer = pixelBufferProvider.allocate(gl, pixelAttribs, panelWidth, panelHeight, 1, true, 0); if(DEBUG) { - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBufferProvider isSingletonBufferProvider "+useSingletonBuffer+", 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName()); - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: pixelBuffer 0x"+Integer.toHexString(pixelBuffer.hashCode())+", "+pixelBuffer+", alignment "+alignment); - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)); - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: panelSize "+panelWidth+"x"+panelHeight); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBufferProvider isSingletonBufferProvider "+useSingletonBuffer+", 0x"+Integer.toHexString(pixelBufferProvider.hashCode())+", "+pixelBufferProvider.getClass().getSimpleName()); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" pixelBuffer 0x"+Integer.toHexString(pixelBuffer.hashCode())+", "+pixelBuffer+", alignment "+alignment); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" flippedVertical "+flipVertical+", glslTextureRaster "+(null!=glslTextureRaster)); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" panelSize "+panelWidth+"x"+panelHeight); } } if( offscreenDrawable.getWidth() != panelWidth || offscreenDrawable.getHeight() != panelHeight ) { throw new InternalError("OffscreenDrawable panelSize mismatch (reshape missed): panelSize "+panelWidth+"x"+panelHeight+" != drawable "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()+", on thread "+getThreadName()); } - if( null == alignedImage || panelWidth != alignedImage.getWidth() || panelHeight != alignedImage.getHeight() ) { + if( null == alignedImage || + panelWidth != alignedImage.getWidth() || panelHeight != alignedImage.getHeight() || + !pixelBuffer.isDataBufferSource(alignedImage) ) { alignedImage = pixelBuffer.getAlignedImage(panelWidth, panelHeight); if(DEBUG) { - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: alignedImage "+alignedImage.getWidth()+"x"+alignedImage.getHeight()+", pixelBuffer "+pixelBuffer.width+"x"+pixelBuffer.height); + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL.0: "+GLJPanel.this.getName()+" new alignedImage "+alignedImage.getWidth()+"x"+alignedImage.getHeight()+", "+alignedImage+", pixelBuffer "+pixelBuffer.width+"x"+pixelBuffer.height+", "+pixelBuffer); } } final IntBuffer readBackInts; @@ -1652,7 +1654,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing viewportChange = 0 != usrViewport[0] || 0 != usrViewport[1] || offscreenDrawable.getWidth() != usrViewport[2] || offscreenDrawable.getHeight() != usrViewport[3]; if( DEBUG_VIEWPORT ) { - System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: Viewport: change "+viewportChange+ + System.err.println(getThreadName()+": GLJPanel.OffscreenBackend.postGL: "+GLJPanel.this.getName()+" Viewport: change "+viewportChange+ ", "+usrViewport[0]+"/"+usrViewport[1]+" "+usrViewport[2]+"x"+usrViewport[3]+ " -> 0/0 "+offscreenDrawable.getWidth()+"x"+offscreenDrawable.getHeight()); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelResize01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelResize01AWT.java new file mode 100644 index 000000000..2133d62a2 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelResize01AWT.java @@ -0,0 +1,209 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.awt; + +import java.awt.Dimension; +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Multiple GLJPanels in a JFrame + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestGLJPanelResize01AWT extends UITestCase { + + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(); + } + + static Dimension[] esize00 = { + new Dimension(281, 151), + new Dimension(282, 151), + new Dimension(283, 151), + new Dimension(284, 151), + + new Dimension(284, 152), + new Dimension(283, 152), + new Dimension(282, 152), + new Dimension(281, 152), + + new Dimension(291, 153), + new Dimension(292, 153), + new Dimension(293, 153), + new Dimension(294, 153), + + new Dimension(281, 154), + new Dimension(282, 154), + new Dimension(283, 154), + new Dimension(284, 154) + }; + static Dimension[] esize01 = { + new Dimension(283, 154), // #3: new sub-aligned image in pixelBuffer-1 + new Dimension(291, 154), // #2: new pixelBuffer-1 + new Dimension(282, 154), // #1: new pixelBuffer-0 + }; + static Dimension[] esize02 = { + new Dimension(291, 154), // #2: new pixelBuffer-1 + new Dimension(282, 154), // #1: new pixelBuffer-0 + }; + + public void test(final GLCapabilitiesImmutable caps, final Dimension[] dims, final boolean useSwingDoubleBuffer) { + final int cols = 4; + final int rows = dims.length / cols + ( dims.length % cols > 0 ? 1 : 0 ); + final JFrame[] frame = new JFrame[] { null }; + + System.err.println("Frame size: cols x rows "+cols+"x"+rows); + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame[0] = new JFrame(); + frame[0].setLocation(64, 64); + final JPanel panel = new JPanel(); + panel.setLayout(null); // new BorderLayout()); + panel.setDoubleBuffered(useSwingDoubleBuffer); + frame[0].getContentPane().add(panel); + + final int x0 = 4; + int x = x0, y = 4; + int maxRowWidth = 0; + for(int i=0; i= dims.length ) { break; } + final Dimension d = dims[idx]; + if( d.height > maxColHeight ) { + maxColHeight = d.height; + } + final GLJPanel glad = createGLJPanel(useSwingDoubleBuffer, caps, d, "[r "+i+", c "+j+"]"); + panel.add(glad); + glad.setLocation(x, y); + x+=d.width+4; + } + if( x > maxRowWidth ) { + maxRowWidth = x; + } + x = x0; + y += maxColHeight+4; + } + frame[0].setSize(maxRowWidth+4+64, y+4+64); + // frame[0].pack(); + frame[0].setVisible(true); + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + try { + Thread.sleep(duration); + } catch (InterruptedException e1) { + e1.printStackTrace(); + } + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame[0].dispose(); + } } ); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + private GLJPanel createGLJPanel(final boolean useSwingDoubleBuffer, final GLCapabilitiesImmutable caps, final Dimension size, final String name) { + final GLJPanel canvas = new GLJPanel(caps); + canvas.setName(name); + canvas.setSize(size); + canvas.setPreferredSize(size); + canvas.setMinimumSize(size); + canvas.setDoubleBuffered(useSwingDoubleBuffer); + final GearsES2 g = new GearsES2(0); + g.setVerbose(false); + canvas.addGLEventListener(g); + return canvas; + } + + static GLCapabilitiesImmutable caps = null; + + // @Test + public void test00() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), esize00, false /*useSwingDoubleBuffer*/); + } + + @Test + public void test01() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), esize01, false /*useSwingDoubleBuffer*/); + } + + @Test + public void test02() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), esize02, false /*useSwingDoubleBuffer*/); + } + + static long duration = 600; // ms + + public static void main(String[] args) { + boolean useSwingDoubleBuffer=false, manual=false; + + for(int i=0; i Date: Mon, 25 Nov 2013 04:25:04 +0100 Subject: Bug 672 (NewtCanvasSWT): Reuse SWTAccessor.isOS_TYPE ; Impl NW.getLocationOnScreen(..) for X11 and Windows ; Allow unit test to run on all platforms. - Reuse SWTAccessor.isOS_TYPE (public now) - Impl NW.getLocationOnScreen(..) for X11 and Windows reusing existing native code - Allow unit test to run on all platforms. Note: NewtCanvasSWT unit tests require a 'wait for realized' while SWT dispatching. Otherwise the 'sash unit test' will fail since realiziation happens later, at least on X11. Hence extended AWTRobotUtil.waitForRealized(..) to use a 'waitAction' which is used here w/ special SWT dispatch Runnable. AWTRobotUtil.waitForRealized(..) operates on time-delta instead of iteration-counter, allowing above 'waitAction' Runnable. AWTRobotUtil.waitForRealized(..) removed 2nd 'glad.isRealized()' loop .. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 8 +- .../com/jogamp/nativewindow/swt/SWTAccessor.java | 8 +- .../classes/com/jogamp/newt/swt/NewtCanvasSWT.java | 42 ++-- .../jogl/swt/TestBug672NewtCanvasSWTSashForm.java | 210 +++++++------------- .../TestBug672NewtCanvasSWTSashFormComposite.java | 219 ++++++++------------- .../TestNewtCanvasSWTBug628ResizeDeadlockAWT.java | 20 +- .../test/junit/jogl/swt/TestNewtCanvasSWTGLn.java | 74 ++++--- .../opengl/test/junit/util/AWTRobotUtil.java | 82 ++++++-- 9 files changed, 320 insertions(+), 347 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index d0bae1b4b..a8ef44cce 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -13,7 +13,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGea REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* @@ -146,6 +146,8 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashForm %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashFormComposite %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 809aceb0c..a27def007 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -204,7 +204,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" - D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL" + #D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL" #D_ARGS="-Djogl.gljpanel.noverticalflip" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.X11Util.XSync" @@ -529,7 +529,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* @@ -542,7 +542,9 @@ testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $* # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -#testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashForm $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashFormComposite $* # # awtswt (testawtswt) diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java index 361d61c65..36bf646d5 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/swt/SWTAccessor.java @@ -63,10 +63,10 @@ public class SWTAccessor { private static Field swt_osx_view_id = null; private static final String nwt; - private static final boolean isOSX; - private static final boolean isWindows; - private static final boolean isX11; - private static final boolean isX11GTK; + public static final boolean isOSX; + public static final boolean isWindows; + public static final boolean isX11; + public static final boolean isX11GTK; // X11/GTK, Windows/GDI, .. private static final String str_handle = "handle"; diff --git a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java index 029cee3da..5ed8d9e63 100644 --- a/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java +++ b/src/newt/classes/com/jogamp/newt/swt/NewtCanvasSWT.java @@ -46,6 +46,8 @@ import javax.media.nativewindow.util.Point; import javax.media.opengl.GLCapabilities; import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.nativewindow.windows.GDIUtil; +import jogamp.nativewindow.x11.X11Lib; import jogamp.newt.Debug; import jogamp.newt.swt.SWTEDTUtil; @@ -70,7 +72,6 @@ import com.jogamp.newt.util.EDTUtil; */ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { private static final boolean DEBUG = Debug.debug("Window"); - private static final boolean isOSX = NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false); private final AbstractGraphicsScreen screen; @@ -145,7 +146,9 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { newtChild.setSize(clientArea.width, clientArea.height); postSetSize = false; } - if( isOSX ) newtChild.setPosition(parent.getLocation().x,parent.getLocation().y); + if( SWTAccessor.isOSX ) { + newtChild.setPosition(parent.getLocation().x,parent.getLocation().y); + } newtChild.windowRepaint(0, 0, clientArea.width, clientArea.height); } } @@ -398,7 +401,7 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { public SWTNativeWindow(AbstractGraphicsConfiguration config, long nativeWindowHandle) { this.config = config; this.nativeWindowHandle = nativeWindowHandle; - if(isOSX) { + if( SWTAccessor.isOSX ) { this.insets = OSXUtil.GetInsets(nativeWindowHandle); } else { this.insets = new Insets(0, 0, 0, 0); @@ -501,22 +504,25 @@ public class NewtCanvasSWT extends Canvas implements WindowClosingProtocol { @Override public Point getLocationOnScreen(Point point) { - if( isOSX ) { - final Point los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); - // top-level position -> client window position - final Rectangle swtCanvasPosition = getSWTCanvasPosition(); - los.set(swtCanvasPosition.x + los.getX() + insets.getLeftWidth(), swtCanvasPosition.y + los.getY() + insets.getTopHeight()); - if(null!=point) { - return point.translate(los); - } else { - return los; - } + final Point los; // client window location on screen + if( SWTAccessor.isOSX ) { + los = OSXUtil.GetLocationOnScreen(nativeWindowHandle, false, 0, 0); + // top-level position -> client window position: OSX needs to add SWT parent position incl. insets + final Rectangle swtCanvasPosition = getSWTCanvasPosition(); + los.translate(swtCanvasPosition.x + insets.getLeftWidth(), swtCanvasPosition.y + insets.getTopHeight()); + } else if (SWTAccessor.isX11) { + final AbstractGraphicsScreen s = config.getScreen(); + los = X11Lib.GetRelativeLocation(s.getDevice().getHandle(), s.getIndex(), nativeWindowHandle, 0 /*root win*/, 0, 0); + } else if (SWTAccessor.isWindows) { + los = GDIUtil.GetRelativeLocation( nativeWindowHandle, 0 /*root win*/, 0, 0); } else { - // client position on 'normal' windowing systems is 0/0 - if(null == point) { - point = new Point(0, 0); - } - return point; + // fall-back to 0/0 + los = new Point(0, 0); + } + if(null!=point) { + return point.translate(los); + } else { + return los; } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java index f6f8918a3..4b7537655 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/swt/TestBug672NewtCanvasSWTSashForm.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.swt; import java.io.IOException; @@ -43,17 +43,13 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; - import com.jogamp.opengl.util.Animator; - import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.DimensionImmutable; - import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLProfile; @@ -75,28 +71,15 @@ import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestBug672NewtCanvasSWTSashForm extends UITestCase { +public class TestBug672NewtCanvasSWTSashForm extends UITestCase { static int screenIdx = 0; static PointImmutable wpos; static DimensionImmutable wsize, rwsize = null; static long duration = 500; // ms - static boolean opaque = true; - static int forceAlpha = -1; - static boolean fullscreen = false; - static boolean pmvUseBackingArray = true; - static int swapInterval = 1; - static boolean showFPS = false; - static int loops = 1; - static boolean loop_shutdown = false; - static boolean forceES2 = false; - static boolean forceGL3 = false; - static boolean mainRun = false; - static boolean exclusiveContext = false; - + @BeforeClass public static void initClass() { - setTestSupported(NativeWindowFactory.TYPE_MACOSX == NativeWindowFactory.getNativeWindowType(false)); if(null == wsize) { wsize = new Dimension(640, 480); } @@ -109,23 +92,28 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { Display display = null; Shell shell = null; Composite composite = null; + SashForm sash = null; com.jogamp.newt.Display swtNewtDisplay = null; - + @Before public void init() { SWTAccessor.invoke(true, new Runnable() { - public void run() { + public void run() { display = new Display(); Assert.assertNotNull( display ); }}); display.syncExec(new Runnable() { - public void run() { + public void run() { shell = new Shell( display ); Assert.assertNotNull( shell ); shell.setLayout( new FillLayout() ); composite = new Composite( shell, SWT.NONE ); composite.setLayout( new FillLayout() ); Assert.assertNotNull( composite ); + sash = new SashForm(composite, SWT.NONE); + Assert.assertNotNull( sash ); + final org.eclipse.swt.widgets.Label c = new org.eclipse.swt.widgets.Label(sash, SWT.NONE); + c.setText("Left cell"); }}); swtNewtDisplay = NewtFactory.createDisplay(null, false); // no-reuse } @@ -135,9 +123,11 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { Assert.assertNotNull( display ); Assert.assertNotNull( shell ); Assert.assertNotNull( composite ); + Assert.assertNotNull( sash ); try { display.syncExec(new Runnable() { public void run() { + sash.dispose(); composite.dispose(); shell.dispose(); }}); @@ -154,22 +144,38 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { display = null; shell = null; composite = null; + sash = null; + } + + class WaitAction implements Runnable { + private final long sleepMS; + + WaitAction(long sleepMS) { + this.sleepMS = sleepMS; + } + public void run() { + if( !display.readAndDispatch() ) { + // blocks on linux .. display.sleep(); + try { + Thread.sleep(sleepMS); + } catch (InterruptedException e) { } + } + } } - + final WaitAction awtRobotWaitAction = new WaitAction(AWTRobotUtil.TIME_SLICE); + final WaitAction generalWaitAction = new WaitAction(10); + protected void runTestGL(GLCapabilitiesImmutable caps) throws InterruptedException, InvocationTargetException { - System.err.println("requested: vsync "+swapInterval+", "+caps); com.jogamp.newt.Screen screen = NewtFactory.createScreen(swtNewtDisplay, screenIdx); final GLWindow glWindow = GLWindow.create(screen, caps); Assert.assertNotNull(glWindow); - - final GearsES2 demo = new GearsES2(swapInterval); - demo.setPMVUseBackingArray(pmvUseBackingArray); + + final GearsES2 demo = new GearsES2(1); glWindow.addGLEventListener(demo); - + Animator animator = new Animator(); animator.setModeBits(false, Animator.MODE_EXPECT_AWT_RENDERING_THREAD); - animator.setExclusiveContext(exclusiveContext); - + QuitAdapter quitAdapter = new QuitAdapter(); //glWindow.addKeyListener(new TraceKeyAdapter(quitAdapter)); //glWindow.addWindowListener(new TraceWindowAdapter(quitAdapter)); @@ -182,14 +188,14 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { } public void windowMoved(WindowEvent e) { System.err.println("window moved: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()); - } + } }); - + glWindow.addKeyListener(new KeyAdapter() { public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; - } + } if(e.getKeyChar()=='f') { new Thread() { public void run() { @@ -207,10 +213,7 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { animator.start(); Assert.assertTrue(animator.isStarted()); Assert.assertTrue(animator.isAnimating()); - Assert.assertEquals(exclusiveContext ? animator.getThread() : null, glWindow.getExclusiveContextThread()); - final SashForm sash = new SashForm(composite, SWT.NONE); - org.eclipse.swt.widgets.Label c = new org.eclipse.swt.widgets.Label(sash, SWT.NONE); - c.setText("Left cell"); + animator.setUpdateFPSFrames(60, null); final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( sash, 0, glWindow ); Assert.assertNotNull( canvas1 ); @@ -224,116 +227,68 @@ public class TestBug672NewtCanvasSWTSashForm extends UITestCase { shell.open(); } }); - - animator.setUpdateFPSFrames(60, showFPS ? System.err : null); - + Assert.assertTrue("GLWindow didn't become visible natively!", AWTRobotUtil.waitForRealized(glWindow, awtRobotWaitAction, true)); + Assert.assertNotNull( canvas1.getNativeWindow() ); + System.err.println("NW chosen: "+glWindow.getDelegatedWindow().getChosenCapabilities()); System.err.println("GL chosen: "+glWindow.getChosenCapabilities()); - System.err.println("window pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); - + System.err.println("window pos/siz.0: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + System.err.println("GLWindow LOS.0: "+glWindow.getLocationOnScreen(null)); + System.err.println("NewtCanvasSWT LOS.0: "+canvas1.getNativeWindow().getLocationOnScreen(null)); + if( null != rwsize ) { for(int i=0; i<50; i++) { // 500 ms dispatched delay - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } + generalWaitAction.run(); } display.syncExec( new Runnable() { public void run() { shell.setSize( rwsize.getWidth(), rwsize.getHeight() ); } }); - System.err.println("window resize pos/siz: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + System.err.println("window resize pos/siz.1: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); + System.err.println("GLWindow LOS.1: "+glWindow.getLocationOnScreen(null)); + System.err.println("NewtCanvasSWT LOS.1: "+canvas1.getNativeWindow().getLocationOnScreen(null)); } - - Assert.assertNotNull( canvas1.getNativeWindow() ); - Assert.assertNotEquals( canvas1.getNativeWindow().getLocationOnScreen(null), 0 ); - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()= sash-right "+pSashRightClient, pNatWinLOS.compareTo(pSashRightClient) >= 0 ); + Assert.assertTrue( "GLWindow LOS "+pGLWinLOS+" not >= sash-right "+pSashRightClient, pGLWinLOS.compareTo(pSashRightClient) >= 0 ); + + while( !quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() 0 ); - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration()= sash-right "+pSashRightClient, pNatWinLOS.compareTo(pSashRightClient) >= 0 ); + Assert.assertTrue( "GLWindow LOS "+pGLWinLOS+" not >= sash-right "+pSashRightClient, pGLWinLOS.compareTo(pSashRightClient) >= 0 ); + + while( !quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() + * _and_ custom GLCapabilities. + *

      * Uses JOGL's NewtCanvasSWT, which allows to be a native container of a NEWT Window.
      * This method allows utilizing custom GLCapability settings, * independent from the already instantiated SWT visual. *

      *

      - * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ + * Note that {@link SWTAccessor#invoke(boolean, Runnable)} is still used to comply w/ * SWT running on Mac OSX, i.e. to enforce UI action on the main thread. *

      */ @@ -87,7 +87,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { Shell shell = null; Composite composite = null; com.jogamp.newt.Display swtNewtDisplay = null; - + @BeforeClass public static void startup() { System.out.println( "GLProfile " + GLProfile.glAvailabilityToString() ); @@ -96,12 +96,12 @@ public class TestNewtCanvasSWTGLn extends UITestCase { @Before public void init() { SWTAccessor.invoke(true, new Runnable() { - public void run() { + public void run() { display = new Display(); Assert.assertNotNull( display ); }}); display.syncExec(new Runnable() { - public void run() { + public void run() { shell = new Shell( display ); Assert.assertNotNull( shell ); shell.setLayout( new FillLayout() ); @@ -138,10 +138,28 @@ public class TestNewtCanvasSWTGLn extends UITestCase { composite = null; } - protected void runTestAGL( GLCapabilitiesImmutable caps, GLEventListener demo, + class WaitAction implements Runnable { + private final long sleepMS; + + WaitAction(long sleepMS) { + this.sleepMS = sleepMS; + } + public void run() { + if( !display.readAndDispatch() ) { + // blocks on linux .. display.sleep(); + try { + Thread.sleep(sleepMS); + } catch (InterruptedException e) { } + } + } + } + final WaitAction awtRobotWaitAction = new WaitAction(AWTRobotUtil.TIME_SLICE); + final WaitAction generalWaitAction = new WaitAction(10); + + protected void runTestAGL( GLCapabilitiesImmutable caps, GLEventListener demo, boolean postAttach, boolean useAnimator ) throws InterruptedException { final GLReadBufferUtil screenshot = new GLReadBufferUtil(false, false); - + final Screen screen = NewtFactory.createScreen(swtNewtDisplay, 0); final GLWindow glWindow1 = GLWindow.create(screen, caps); Assert.assertNotNull(glWindow1); @@ -151,7 +169,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { glWindow1.addGLEventListener(demo); glWindow1.addGLEventListener(new GLEventListener() { int displayCount = 0; - public void init(final GLAutoDrawable drawable) { } + public void init(final GLAutoDrawable drawable) { } public void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height) { } public void display(final GLAutoDrawable drawable) { if(displayCount < 3) { @@ -159,8 +177,8 @@ public class TestNewtCanvasSWTGLn extends UITestCase { } } public void dispose(final GLAutoDrawable drawable) { } - }); - + }); + final NewtCanvasSWT canvas1 = NewtCanvasSWT.create( composite, 0, postAttach ? null : glWindow1 ); Assert.assertNotNull( canvas1 ); @@ -171,13 +189,18 @@ public class TestNewtCanvasSWTGLn extends UITestCase { shell.open(); } }); - + if(postAttach) { canvas1.setNEWTChild(glWindow1); } - + + Assert.assertTrue("GLWindow didn't become visible natively!", AWTRobotUtil.waitForRealized(glWindow1, awtRobotWaitAction, true)); + + System.err.println("GLWindow LOS.0: "+glWindow1.getLocationOnScreen(null)); + System.err.println("NewtCanvasSWT LOS.0: "+canvas1.getNativeWindow().getLocationOnScreen(null)); + // canvas1.update(); - + Animator anim; if(useAnimator) { anim = new Animator(glWindow1); @@ -185,15 +208,12 @@ public class TestNewtCanvasSWTGLn extends UITestCase { } else { anim = null; } - + long lStartTime = System.currentTimeMillis(); long lEndTime = lStartTime + duration; try { while( (System.currentTimeMillis() < lEndTime) && !canvas1.isDisposed() ) { - if( !display.readAndDispatch() ) { - // blocks on linux .. display.sleep(); - Thread.sleep(10); - } + generalWaitAction.run(); } } catch( Throwable throwable ) { throwable.printStackTrace(); @@ -202,7 +222,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { if(null != anim) { anim.stop(); } - + canvas1.dispose(); } @@ -220,7 +240,7 @@ public class TestNewtCanvasSWTGLn extends UITestCase { public void postAttach_WithAnimator() throws InterruptedException { runTestAGL( new GLCapabilities(GLProfile.getGL2ES2()), new GearsES2(), true /* postAttach */, true /* animator */); } - + @Test public void test_MultisampleAndAlpha() throws InterruptedException { GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index cd14835bb..657936adc 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -682,53 +682,97 @@ public class AWTRobotUtil { } /** + * @param obj the component to wait for + * @param realized true if waiting for component to become realized, otherwise false * @return True if the Component becomes realized (not displayable, native invalid) within TIME_OUT + * @throws InterruptedException */ public static boolean waitForRealized(Object obj, boolean realized) throws InterruptedException { - int wait; + return waitForRealized(obj, null, realized); + } + + /** + * @param obj the component to wait for + * @param waitAction if not null, Runnable shall wait {@link #TIME_SLICE} ms, if appropriate + * @param realized true if waiting for component to become realized, otherwise false + * @return True if the Component becomes realized (not displayable, native invalid) within TIME_OUT + * @throws InterruptedException + */ + public static boolean waitForRealized(Object obj, Runnable waitAction, boolean realized) throws InterruptedException { + long t0 = System.currentTimeMillis(); + long t1 = t0; if(obj instanceof com.jogamp.newt.Screen) { com.jogamp.newt.Screen screen = (com.jogamp.newt.Screen) obj; - for (wait=0; wait drawable.setRealized(true); - if(wait=POLL_DIVIDER) { + if( (t1-t0) >= TIME_OUT ) { // for some reason GLCanvas hasn't been painted yet, force it! System.err.println("XXX: FORCE REPAINT PRE - glad: "+glad); comp.repaint(); - for (wait=0; wait Date: Thu, 28 Nov 2013 13:43:32 +0100 Subject: Fix Bug 902: FFMPEGMediaPlayer uses IOUtil.decodeURIIfFilePath(uri) to decode proper file-scheme if applicable - otherwise encoded ASCII URI. --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests-x64-dbg.bat | 7 ++++--- make/scripts/tests.sh | 6 +++--- .../opengl/util/av/impl/FFMPEGMediaPlayer.java | 9 +++++++-- .../test/junit/jogl/demos/es2/av/MovieCube.java | 17 ++++++++++++---- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 23 ++++++++++++++++++---- 6 files changed, 48 insertions(+), 18 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index a8ef44cce..fb224c882 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -18,7 +18,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLa REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* @@ -146,7 +146,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTBug628ResizeDeadlock %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestSWTBug643AsyncExec %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashForm %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashForm %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashFormComposite %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestWindows01NEWT diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 822ad0e54..851c1dbec 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -24,12 +24,13 @@ REM set D_ARGS="-Djogamp.debug=all" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" -set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" +REM set D_ARGS="-Djogamp.debug.IOUtil" REM set D_ARGS="-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" -REM set D_ARGS="-Djogl.debug.GLMediaPlayer" +set D_ARGS="-Djogl.debug.GLMediaPlayer" REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.AudioSink" REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.GLMediaPlayer.Native" REM set D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25" "-Djogl.debug.GLMediaPlayer" @@ -52,7 +53,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Djogl.gljpanel.noverticalflip" -set D_ARGS="-Dnewt.debug.Window" +REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a27def007..ce8005821 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -137,7 +137,7 @@ function jrun() { #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" - #D_ARGS="-Djogl.debug.GLMediaPlayer" + D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.AudioSink" @@ -345,7 +345,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests @@ -542,7 +542,7 @@ function testawtswt() { # #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTEclipseGLCanvas01GLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestSWTJOGLGLCanvas01GLn $* -testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* +#testswt com.jogamp.opengl.test.junit.jogl.swt.TestNewtCanvasSWTGLn $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashForm $* #testswt com.jogamp.opengl.test.junit.jogl.swt.TestBug672NewtCanvasSWTSashFormComposite $* diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index d2ef026bd..034b9457e 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -232,7 +232,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { private int vBytesPerPixelPerPlane = 0; private int texWidth, texHeight; // overall (stuffing planes in one texture) private String singleTexComp = "r"; - private GLPixelStorageModes psm; + private final GLPixelStorageModes psm; // // Audio @@ -280,7 +280,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { System.err.println("initStream: p1 "+this); } - final String streamLocS=IOUtil.decodeFromURI(streamLoc.toString()); + final String streamLocS = IOUtil.decodeURIIfFilePath(streamLoc); destroyAudioSink(); if( GLMediaPlayer.STREAM_ID_NONE == aid ) { audioSink = AudioSinkFactory.createNull(); @@ -331,6 +331,11 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { final int aMaxChannelCount = audioSink.getMaxSupportedChannels(); final int aPrefSampleRate = preferredAudioFormat.sampleRate; // setStream(..) issues updateAttributes*(..), and defines avChosenAudioFormat, vid, aid, .. etc + if(DEBUG) { + System.err.println("initStream: p3 cameraPath "+cameraPath+", isCameraInput "+isCameraInput); + System.err.println("initStream: p3 stream "+streamLoc+" -> "+streamLocS+" -> "+resStreamLocS); + System.err.println("initStream: p3 vid "+vid+", sizes "+sizes+", reqVideo "+rw+"x"+rh+"@"+rr+", aid "+aid+", aMaxChannelCount "+aMaxChannelCount+", aPrefSampleRate "+aPrefSampleRate); + } natives.setStream0(moviePtr, resStreamLocS, isCameraInput, vid, sizes, rw, rh, rr, aid, aMaxChannelCount, aPrefSampleRate); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index a7636fce4..8f27e19c4 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -28,6 +28,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.av; +import java.io.File; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; @@ -39,6 +40,7 @@ import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import com.jogamp.common.util.IOUtil; import com.jogamp.newt.Window; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -327,7 +329,7 @@ public class MovieCube implements GLEventListener { int aid = GLMediaPlayer.STREAM_ID_AUTO; final boolean origSize; - String url_s=null; + String url_s=null, file_s=null; { boolean _origSize = false; for(int i=0; i Date: Fri, 29 Nov 2013 02:24:01 +0100 Subject: Bug 907 - Refine DummyDispatchThread (DDT) Handling: Proper OO integration in RegisteredClass; Safe DDT Post/WaitForReady handling and error cases ; ... Proper OO integration of DDT in RegisteredClass - DDT is optional to RegisteredClass[Factory], i.e. NEWT without DDT and DummyWindow with DDT. - Using native type DummyThreadContext per DDT passed as DDT handle to java referenced in RegisteredClass - Passing DDT handle to related native methods, if not null use DDT - otherwise work on current thread. The latter impacts CreateDummyWindow0 and DestroyWindow0. Safe DDT Post/WaitForReady handling and error cases ; ... - Wait until command it complete using a 3s timeout - Terminate thread if errors occur and throw an exception +++ Discussion: DDT Native Implementation Due to original code, the DDT is implemented in native code. Usually we should favor running the DDT from a java thread. However, since it's main purpose is _not_ to interact w/ java and the native implementation has less footprint (performance and memory) we shall be OK w/ it for now - as long the implementation IS SAFE. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 8 +- make/scripts/tests.sh | 27 +- .../jogamp/nativewindow/windows/GDIUtil.java | 21 +- .../nativewindow/windows/RegisteredClass.java | 17 +- .../windows/RegisteredClassFactory.java | 30 +- src/nativewindow/native/NativewindowCommon.c | 7 + src/nativewindow/native/NativewindowCommon.h | 3 + src/nativewindow/native/win32/GDImisc.c | 446 ++++++++++++++------- .../jogamp/newt/driver/windows/DisplayDriver.java | 2 +- 10 files changed, 373 insertions(+), 192 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index fb224c882..d95b0025f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -18,7 +18,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLa REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 851c1dbec..3e56a31a6 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -21,16 +21,18 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\% echo CP_ALL %CP_ALL% REM set D_ARGS="-Djogamp.debug=all" +set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" +REM set D_ARGS="-Dnativewindow.debug.GDIUtil" "-Dnativewindow.debug.RegisteredClass" REM set D_ARGS="-Djogl.debug.GLContext" "-Djogl.debug.FBObject" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.EGLDrawableFactory.QueryNativeTK" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug.GLDrawable" "-Djogl.debug.GLContext" "-Djogl.debug.GLCanvas" -REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser -Djogl.debug.GLProfile" REM set D_ARGS="-Djogamp.debug.IOUtil" REM set D_ARGS="-Djogl.debug.GLSLCode" "-Djogl.debug.GLMediaPlayer" -set D_ARGS="-Djogl.debug.GLMediaPlayer" +REM set D_ARGS="-Djogl.debug.GLMediaPlayer" REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.AudioSink" REM set D_ARGS="-Djogl.debug.GLMediaPlayer" "-Djogl.debug.GLMediaPlayer.Native" REM set D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25" "-Djogl.debug.GLMediaPlayer" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ce8005821..56a07e768 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -84,6 +84,17 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL" + + #D_ARGS="-Djogamp.debug=all" + #D_ARGS="-Dnativewindow.debug=all" + #D_ARGS="-Djogl.debug=all" + #D_ARGS="-Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" + D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" + #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" + #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG" #D_ARGS="-Djogl.disable.opengles" @@ -93,7 +104,7 @@ function jrun() { #D_ARGS="-Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" - #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" + #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" @@ -110,10 +121,6 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Djogl.debug.GLContext" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" - #D_ARGS="-Djogamp.debug=all" - #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.Animator -Djogl.debug.GLDrawable -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" @@ -122,8 +129,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLEventListenerState" #D_ARGS="-Djogl.fbo.force.none" - #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" - #D_ARGS="-Djogl.debug=all" #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDebugMessageHandler" @@ -137,7 +142,7 @@ function jrun() { #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" - D_ARGS="-Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.AudioSink" @@ -201,7 +206,6 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" - #D_ARGS="-Dnativewindow.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" #D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL" @@ -225,7 +229,6 @@ function jrun() { #D_ARGS="-Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=10000" #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" - #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" #D_ARGS="-Djogl.debug.PNGImage" @@ -322,7 +325,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -345,7 +348,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java index bab4b5c6e..a872e63d8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/GDIUtil.java @@ -59,7 +59,7 @@ public class GDIUtil implements ToolkitProperties { if( !initIDs0() ) { throw new NativeWindowException("GDI: Could not initialized native stub"); } - dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0()); + dummyWindowClassFactory = new RegisteredClassFactory(dummyWindowClassNameBase, getDummyWndProc0(), true /* useDummyDispatchThread */); if(DEBUG) { System.out.println("GDI.initSingleton() dummyWindowClassFactory "+dummyWindowClassFactory); } @@ -98,8 +98,7 @@ public class GDIUtil implements ToolkitProperties { System.out.println("GDI.CreateDummyWindow() dummyWindowClassFactory "+dummyWindowClassFactory); System.out.println("GDI.CreateDummyWindow() dummyWindowClass "+dummyWindowClass); } - // FIXME return CreateDummyWindow0(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); - return CreateDummyWindowAndMessageLoop(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getName(), x, y, width, height); + return CreateDummyWindow0(dummyWindowClass.getHInstance(), dummyWindowClass.getName(), dummyWindowClass.getHDispThreadContext(), dummyWindowClass.getName(), x, y, width, height); } } @@ -109,8 +108,7 @@ public class GDIUtil implements ToolkitProperties { if( null == dummyWindowClass ) { throw new InternalError("GDI Error ("+dummyWindowClassFactory.getSharedRefCount()+"): SharedClass is null"); } - // FIXME res = GDI.DestroyWindow(hwnd); - res = SendCloseMessage(hwnd); + res = DestroyWindow0(dummyWindowClass.getHDispThreadContext(), hwnd); dummyWindowClassFactory.releaseSharedClass(); } return res; @@ -128,8 +126,11 @@ public class GDIUtil implements ToolkitProperties { return IsChild0(win); } - public static native boolean CreateWindowClass(long hInstance, String clazzName, long wndProc); - public static native boolean DestroyWindowClass(long hInstance, String className); + private static final void dumpStack() { Thread.dumpStack(); } // Callback for JNI + + static native boolean CreateWindowClass0(long hInstance, String clazzName, long wndProc); + static native boolean DestroyWindowClass0(long hInstance, String className, long dispThreadCtx); + static native long CreateDummyDispatchThread0(); private static native boolean initIDs0(); private static native long getDummyWndProc0(); @@ -137,8 +138,6 @@ public class GDIUtil implements ToolkitProperties { private static native boolean IsChild0(long win); private static native boolean IsUndecorated0(long win); - private static native long CreateDummyWindow0(long hInstance, String className, String windowName, int x, int y, int width, int height); - - private static native long CreateDummyWindowAndMessageLoop(long hInstance, String className, String windowName, int x, int y, int width, int height); - private static native boolean SendCloseMessage(long win); + private static native long CreateDummyWindow0(long hInstance, String className, long dispThreadCtx, String windowName, int x, int y, int width, int height); + private static native boolean DestroyWindow0(long dispThreadCtx, long win); } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java index 976693e3a..1f6cb7c05 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClass.java @@ -29,12 +29,14 @@ package jogamp.nativewindow.windows; public class RegisteredClass { - long hInstance; - String className; + private final long hInstance; + private final String className; + private final long hDDTCtx; - RegisteredClass(long hInst, String name) { - hInstance = hInst; - className = name; + RegisteredClass(long hInst, String name, long hDispatchThreadCtx) { + this.hInstance = hInst; + this.className = name; + this.hDDTCtx = hDispatchThreadCtx; } /** Application handle, same as {@link RegisteredClassFactory#getHInstance()}. */ @@ -43,6 +45,9 @@ public class RegisteredClass { /** Unique Window Class Name */ public final String getName() { return className; } + /** Unique associated dispatch thread context for this Window Class, or 0 for none. */ + public final long getHDispThreadContext() { return hDDTCtx; } + @Override - public final String toString() { return "RegisteredClass[handle 0x"+Long.toHexString(hInstance)+", "+className+"]"; } + public final String toString() { return "RegisteredClass[handle 0x"+Long.toHexString(hInstance)+", "+className+", dtx 0x"+Long.toHexString(hDDTCtx)+"]"; } } diff --git a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java index 19a48d3bf..ee41fe192 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java +++ b/src/nativewindow/classes/jogamp/nativewindow/windows/RegisteredClassFactory.java @@ -49,6 +49,7 @@ public class RegisteredClassFactory { private final String classBaseName; private final long wndProc; + private final boolean useDummyDispatchThread; private RegisteredClass sharedClass = null; private int classIter = 0; @@ -59,24 +60,29 @@ public class RegisteredClassFactory { @Override public final String toString() { return "RegisteredClassFactory[moduleHandle "+toHexString(hInstance)+", "+classBaseName+ - ", wndProc "+toHexString(wndProc)+", shared[refCount "+sharedRefCount+", class "+sharedClass+"]]"; } + ", wndProc "+toHexString(wndProc)+", useDDT "+useDummyDispatchThread+", shared[refCount "+sharedRefCount+", class "+sharedClass+"]]"; } /** * Release the {@link RegisteredClass} of all {@link RegisteredClassFactory}. */ public static void shutdownSharedClasses() { synchronized(registeredFactories) { + if( DEBUG ) { + System.err.println("RegisteredClassFactory.shutdownSharedClasses: "+registeredFactories.size()); + } for(int j=0; j +#include static const char * const ClazzNameRuntimeException = "java/lang/RuntimeException"; static jclass runtimeExceptionClz=NULL; @@ -106,3 +107,9 @@ JNIEnv* NativewindowCommon_GetJNIEnv (JavaVM * jvmHandle, int jvmVersion, int as return curEnv; } +int64_t NativewindowCommon_CurrentTimeMillis() { + struct timeval tv; + gettimeofday(&tv,NULL); + return (int64_t)tv.tv_sec * 1000 + tv.tv_usec / 1000; +} + diff --git a/src/nativewindow/native/NativewindowCommon.h b/src/nativewindow/native/NativewindowCommon.h index a2975f3fd..a23fad9fd 100644 --- a/src/nativewindow/native/NativewindowCommon.h +++ b/src/nativewindow/native/NativewindowCommon.h @@ -4,6 +4,7 @@ #include #include +#include int NativewindowCommon_init(JNIEnv *env); @@ -15,4 +16,6 @@ void NativewindowCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, . JNIEnv* NativewindowCommon_GetJNIEnv (JavaVM * jvmHandle, int jvmVersion, int asDaemon, int * shallBeDetached); +int64_t NativewindowCommon_CurrentTimeMillis(); + #endif diff --git a/src/nativewindow/native/win32/GDImisc.c b/src/nativewindow/native/win32/GDImisc.c index d3ac3873c..b55988c11 100644 --- a/src/nativewindow/native/win32/GDImisc.c +++ b/src/nativewindow/native/win32/GDImisc.c @@ -20,8 +20,10 @@ #ifdef VERBOSE_ON #define DBG_PRINT(args...) fprintf(stderr, args); + #define DBG_PRINT_FLUSH(args...) fprintf(stderr, args); fflush(stderr); #else #define DBG_PRINT(args...) + #define DBG_PRINT_FLUSH(args...) #endif static const char * const ClazzNamePoint = "javax/media/nativewindow/util/Point"; @@ -30,12 +32,17 @@ static const char * const ClazzNamePointCstrSignature = "(II)V"; static jclass pointClz = NULL; static jmethodID pointCstr = NULL; +static jmethodID dumpStackID = NULL; -static volatile DWORD threadid = 0; +typedef struct { + HANDLE threadHandle; + DWORD threadId; + volatile BOOL threadReady; + volatile BOOL threadDead; +} DummyThreadContext; -typedef struct ThreadParam_s -{ - jlong jHInstance; +typedef struct { + HINSTANCE hInstance; const TCHAR* wndClassName; const TCHAR* wndName; jint x; @@ -44,17 +51,88 @@ typedef struct ThreadParam_s jint height; volatile HWND hWnd; volatile BOOL threadReady; -} ThreadParam; +} DummyThreadCommand; #define TM_OPENWIN WM_APP+1 #define TM_CLOSEWIN WM_APP+2 #define TM_STOP WM_APP+3 -DWORD WINAPI ThreadFunc(LPVOID param) +static const char * sTM_OPENWIN = "TM_OPENWIN"; +static const char * sTM_CLOSEWIN = "TM_CLOSEWIN"; +static const char * sTM_STOP = "TM_STOP"; + +/** 3s timeout */ +static const int64_t TIME_OUT = 3000000; + +static jboolean DDT_CheckAlive(JNIEnv *env, const char *msg, DummyThreadContext *ctx) { + if( ctx->threadDead ) { + NativewindowCommon_throwNewRuntimeException(env, "DDT is dead at %s", msg); + return JNI_FALSE; + } else { + DBG_PRINT_FLUSH("*** DDT-Check ALIVE @ %s\n", msg); + return JNI_TRUE; + } +} + +static jboolean DDT_WaitUntilCreated(JNIEnv *env, DummyThreadContext *ctx, BOOL created) { + const int64_t t0 = NativewindowCommon_CurrentTimeMillis(); + int64_t t1 = t0; + if( created ) { + while( !ctx->threadReady && t1-t0 < TIME_OUT ) { + t1 = NativewindowCommon_CurrentTimeMillis(); + } + if( !ctx->threadReady ) { + NativewindowCommon_throwNewRuntimeException(env, "TIMEOUT (%d ms) while waiting for DDT CREATED", (int)(t1-t0)); + return JNI_FALSE; + } + DBG_PRINT_FLUSH("*** DDT-Check CREATED\n"); + } else { + while( !ctx->threadDead && t1-t0 < TIME_OUT ) { + t1 = NativewindowCommon_CurrentTimeMillis(); + } + if( !ctx->threadDead ) { + NativewindowCommon_throwNewRuntimeException(env, "TIMEOUT (%d ms) while waiting for DDT DESTROYED", (int)(t1-t0)); + return JNI_FALSE; + } + DBG_PRINT_FLUSH("*** DDT-Check DEAD\n"); + } + return JNI_TRUE; +} + +static jboolean DDT_WaitUntilReady(JNIEnv *env, const char *msg, DummyThreadCommand *cmd) { + const int64_t t0 = NativewindowCommon_CurrentTimeMillis(); + int64_t t1 = t0; + while( !cmd->threadReady && t1-t0 < TIME_OUT ) { + t1 = NativewindowCommon_CurrentTimeMillis(); + } + if( !cmd->threadReady ) { + NativewindowCommon_throwNewRuntimeException(env, "TIMEOUT (%d ms) while waiting for DDT %s", (int)(t1-t0), msg); + return JNI_FALSE; + } + DBG_PRINT_FLUSH("*** DDT-Check READY @ %s\n", msg); + return JNI_TRUE; +} + +static HWND DummyWindowCreate + (HINSTANCE hInstance, const TCHAR* wndClassName, const TCHAR* wndName, jint x, jint y, jint width, jint height) +{ + DWORD dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; + DWORD dwStyle = WS_OVERLAPPEDWINDOW; + HWND hWnd = CreateWindowEx( dwExStyle, + wndClassName, + wndName, + dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + x, y, width, height, + NULL, NULL, hInstance, NULL ); + return hWnd; +} + +static DWORD WINAPI DummyDispatchThreadFunc(LPVOID param) { MSG msg; BOOL bRet; - ThreadParam *startupThreadParam = (ThreadParam*)param; + BOOL bEOL=FALSE; + DummyThreadContext *threadContext = (DummyThreadContext*)param; /* there can not be any messages for us now, as the creator waits for threadReady before continuing, but we must use this PeekMessage() to @@ -62,42 +140,40 @@ DWORD WINAPI ThreadFunc(LPVOID param) PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); /* now we can safely say: we have a qeue and are ready to receive messages */ - startupThreadParam->threadReady = TRUE; - - while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) { - if (bRet == -1) { - return 0; + // threadContext->threadId = GetCurrentThreadId(); + threadContext->threadDead = FALSE; + threadContext->threadReady = TRUE; + + while( !bEOL && (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0 ) { + if ( -1 == bRet ) { + fprintf(stderr, "DummyDispatchThread (id %d): GetMessage Error %d, werr %d\n", + (int)threadContext->threadId, (int)bRet, (int)GetLastError()); + fflush(stderr); + bEOL = TRUE; + break; // EOL } else { switch(msg.message) { case TM_OPENWIN: { - ThreadParam *tParam = (ThreadParam*)msg.wParam; - HINSTANCE hInstance = (HINSTANCE) (intptr_t) tParam->jHInstance; - DWORD dwExStyle; - DWORD dwStyle; - - dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - dwStyle = WS_OVERLAPPEDWINDOW; - - HWND hwnd = CreateWindowEx( dwExStyle, - tParam->wndClassName, - tParam->wndName, - dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - tParam->x, tParam->y, tParam->width, tParam->height, - NULL, NULL, hInstance, NULL ); - - tParam->hWnd = hwnd; + DummyThreadCommand *tParam = (DummyThreadCommand*)msg.wParam; + DBG_PRINT_FLUSH("*** DDT-Dispatch OPENWIN\n"); + tParam->hWnd = DummyWindowCreate(tParam->hInstance, tParam->wndClassName, tParam->wndName, tParam->x, tParam->y, tParam->width, tParam->height); tParam->threadReady = TRUE; } break; case TM_CLOSEWIN: { - ThreadParam *tParam = (ThreadParam*)msg.wParam; - HWND hwnd = tParam->hWnd; - DestroyWindow(hwnd); + DummyThreadCommand *tParam = (DummyThreadCommand*)msg.wParam; + DBG_PRINT_FLUSH("*** DDT-Dispatch CLOSEWIN\n"); + DestroyWindow(tParam->hWnd); tParam->threadReady = TRUE; } break; - case TM_STOP: - return 0; + case TM_STOP: { + DummyThreadCommand *tParam = (DummyThreadCommand*)msg.wParam; + DBG_PRINT_FLUSH("*** DDT-Dispatch STOP -> DEAD\n"); + tParam->threadReady = TRUE; + bEOL = TRUE; + } + break; // EOL default: TranslateMessage(&msg); DispatchMessage(&msg); @@ -105,8 +181,12 @@ DWORD WINAPI ThreadFunc(LPVOID param) } } } + /* dead */ + DBG_PRINT_FLUSH("*** DDT-Dispatch DEAD\n"); + threadContext->threadDead = TRUE; + ExitThread(0); return 0; -} /* ThreadFunc */ +} HINSTANCE GetApplicationHandle() { @@ -115,11 +195,48 @@ HINSTANCE GetApplicationHandle() { /* Java->C glue code: * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: boolean CreateWindowClass(long hInstance, java.lang.String clazzName, long wndProc) - * C function: BOOL CreateWindowClass(HANDLE hInstance, LPCSTR clazzName, HANDLE wndProc); + * Java method: long CreateDummyDispatchThread0() + */ +JNIEXPORT jlong JNICALL +Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyDispatchThread0 + (JNIEnv *env, jclass _unused) +{ + DWORD threadId = 0; + DummyThreadContext * dispThreadCtx = calloc(1, sizeof(DummyThreadContext)); + + dispThreadCtx->threadHandle = CreateThread(NULL, 0, DummyDispatchThreadFunc, (LPVOID)dispThreadCtx, 0, &threadId); + if( NULL == dispThreadCtx->threadHandle || 0 == threadId ) { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT CREATE failed handle %p, id %d, werr %d", + (void*)threadHandle, (int)threadId, (int)GetLastError()); + return (jlong)0; + } + if( JNI_FALSE == DDT_WaitUntilCreated(env, dispThreadCtx, TRUE) ) { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT CREATE (ack) failed handle %p, id %d, werr %d", + (void*)threadHandle, (int)threadId, (int)GetLastError()); + return (jlong)0; + } + DBG_PRINT_FLUSH("*** DDT Created %d\n", (int)threadId); + dispThreadCtx->threadId = threadId; + return (jlong) (intptr_t) dispThreadCtx; +} + +/* Java->C glue code: + * Java package: jogamp.nativewindow.windows.GDIUtil + * Java method: boolean CreateWindowClass0(long hInstance, java.lang.String clazzName, long wndProc) + * C function: BOOL CreateWindowClass0(HANDLE hInstance, LPCSTR clazzName, HANDLE wndProc); */ JNIEXPORT jboolean JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass +Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass0 (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName, jlong wndProc) { HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; @@ -127,11 +244,6 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass WNDCLASS wc; jboolean res; - if( 0 != threadid ) { - NativewindowCommon_throwNewRuntimeException(env, "Native threadid already created 0x%X", (int)threadid); - return JNI_FALSE; - } - #ifdef UNICODE clazzName = NewtCommon_GetNullTerminatedStringChars(env, jClazzName); #else @@ -164,31 +276,20 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass (*env)->ReleaseStringUTFChars(env, jClazzName, clazzName); #endif - if( JNI_TRUE == res ) { - ThreadParam tParam = {0}; - - CreateThread(NULL, 0, ThreadFunc, (LPVOID)&tParam, 0, (DWORD *)&threadid); - if(threadid) { - while(!tParam.threadReady) { /* nop */ } - } else { - res = JNI_FALSE; - } - } - return res; } /* Java->C glue code: * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: boolean DestroyWindowClass(long hInstance, java.lang.String className) - * C function: BOOL DestroyWindowClass(HANDLE hInstance, LPCSTR className); + * Java method: boolean DestroyWindowClass0(long hInstance, java.lang.String className, long dispThreadCtx) */ JNIEXPORT jboolean JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindowClass - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jClazzName) +Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindowClass0 + (JNIEnv *env, jclass gdiClazz, jlong jHInstance, jstring jClazzName, jlong jDispThreadCtx) { HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; const TCHAR* clazzName = NULL; + DummyThreadContext * dispThreadCtx = (DummyThreadContext *) (intptr_t) jDispThreadCtx; jboolean res; #ifdef UNICODE @@ -205,39 +306,73 @@ Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindowClass (*env)->ReleaseStringUTFChars(env, jClazzName, clazzName); #endif - if( 0 == threadid ) { - NativewindowCommon_throwNewRuntimeException(env, "Native threadid zero 0x%X", (int)threadid); - return JNI_FALSE; - } + if( NULL != dispThreadCtx) { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + const DWORD threadId = dispThreadCtx->threadId; + DummyThreadCommand tParam = {0}; + tParam.threadReady = FALSE; + DBG_PRINT_FLUSH("*** DDT Destroy %d\n", (int)threadId); +#ifdef VERBOSE_ON + (*env)->CallStaticVoidMethod(env, gdiClazz, dumpStackID); +#endif - PostThreadMessage(threadid, TM_STOP, 0, 0); + if( JNI_FALSE == DDT_CheckAlive(env, sTM_STOP, dispThreadCtx) ) { + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT %s (alive) failed handle %p, id %d, werr %d", + sTM_STOP, (void*)threadHandle, (int)threadId, (int)GetLastError()); + return JNI_FALSE; + } + if ( 0 != PostThreadMessage(dispThreadCtx->threadId, TM_STOP, (WPARAM)&tParam, 0) ) { + if( JNI_FALSE == DDT_WaitUntilReady(env, sTM_STOP, &tParam) ) { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s (ack) failed handle %p, id %d, werr %d", + sTM_STOP, (void*)threadHandle, (int)threadId, (int)GetLastError()); + return JNI_FALSE; + } + if( JNI_FALSE == DDT_WaitUntilCreated(env, dispThreadCtx, FALSE) ) { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT KILL %s (ack) failed handle %p, id %d, werr %d", + sTM_STOP, (void*)threadHandle, (int)threadId, (int)GetLastError()); + return JNI_FALSE; + } + free(dispThreadCtx); // free after proper DDT shutdown! + } else { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s failed handle %p, id %d, werr %d", + sTM_STOP, (void*)threadHandle, (int)threadId, (int)GetLastError()); + return JNI_FALSE; + } + } return res; } /* Java->C glue code: * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: long CreateDummyWindowAndMessageLoop(long hInstance, java.lang.String className, java.lang.String windowName, int x, int y, int width, int height) - * C function: HANDLE CreateDummyWindowAndMessageLoop(HANDLE hInstance, LPCSTR className, LPCSTR windowName, int x, int y, int width, int height); + * Java method: long CreateDummyWindow0(long hInstance, java.lang.String className, jlong dispThreadCtx, java.lang.String windowName, int x, int y, int width, int height) */ JNIEXPORT jlong JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindowAndMessageLoop - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jWndClassName, jstring jWndName, jint x, jint y, jint width, jint height) +Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindow0 + (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jWndClassName, jlong jDispThreadCtx, jstring jWndName, jint x, jint y, jint width, jint height) { - volatile HWND hWnd = 0; - ThreadParam tParam = {0}; - - if( 0 == threadid ) { - NativewindowCommon_throwNewRuntimeException(env, "Native threadid zero 0x%X", (int)threadid); - return JNI_FALSE; - } + DummyThreadContext * dispThreadCtx = (DummyThreadContext *) (intptr_t) jDispThreadCtx; + DummyThreadCommand tParam = {0}; - tParam.jHInstance = jHInstance; + tParam.hInstance = (HINSTANCE) (intptr_t) jHInstance; tParam.x = x; tParam.y = y; tParam.width = width; tParam.height = height; - tParam.hWnd = hWnd; + tParam.hWnd = 0; tParam.threadReady = FALSE; #ifdef UNICODE @@ -248,9 +383,37 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindowAndMessageLoop tParam.wndName = (*env)->GetStringUTFChars(env, jWndName, NULL); #endif - PostThreadMessage(threadid, TM_OPENWIN, (WPARAM)&tParam, 0); - - while(!tParam.threadReady) { /* nop */ } + if( NULL == dispThreadCtx ) { + tParam.hWnd = DummyWindowCreate(tParam.hInstance, tParam.wndClassName, tParam.wndName, tParam.x, tParam.y, tParam.width, tParam.height); + } else { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + const DWORD threadId = dispThreadCtx->threadId; + if( JNI_FALSE == DDT_CheckAlive(env, sTM_OPENWIN, dispThreadCtx) ) { + free(dispThreadCtx); + NativewindowCommon_throwNewRuntimeException(env, "DDT %s (alive) failed handle %p, id %d, werr %d", + sTM_OPENWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } else { + if( 0 != PostThreadMessage(dispThreadCtx->threadId, TM_OPENWIN, (WPARAM)&tParam, 0) ) { + if( JNI_FALSE == DDT_WaitUntilReady(env, sTM_OPENWIN, &tParam) ) { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + tParam.hWnd = 0; + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s (ack) failed handle %p, id %d, werr %d", + sTM_OPENWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } + } else { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + tParam.hWnd = 0; + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s to handle %p, id %d failed, werr %d", + sTM_OPENWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } + } + } #ifdef UNICODE free((void*) tParam.wndClassName); @@ -260,62 +423,66 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindowAndMessageLoop (*env)->ReleaseStringUTFChars(env, jWndName, tParam.wndName); #endif - return (jlong) (intptr_t) hWnd; + return (jlong) (intptr_t) tParam.hWnd; } -/* Java->C glue code: - * Java package: jogamp.nativewindow.windows.GDIUtil - * Java method: long CreateDummyWindow0(long hInstance, java.lang.String className, java.lang.String windowName, int x, int y, int width, int height) - * C function: HANDLE CreateDummyWindow0(HANDLE hInstance, LPCSTR className, LPCSTR windowName, int x, int y, int width, int height); +/* + * Class: jogamp_nativewindow_windows_GDIUtil + * Method: DestroyWindow0 */ -JNIEXPORT jlong JNICALL -Java_jogamp_nativewindow_windows_GDIUtil_CreateDummyWindow0 - (JNIEnv *env, jclass _unused, jlong jHInstance, jstring jWndClassName, jstring jWndName, jint x, jint y, jint width, jint height) +JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_DestroyWindow0 +(JNIEnv *env, jclass unused, jlong jDispThreadCtx, jlong jwin) { - HINSTANCE hInstance = (HINSTANCE) (intptr_t) jHInstance; - const TCHAR* wndClassName = NULL; - const TCHAR* wndName = NULL; - DWORD dwExStyle; - DWORD dwStyle; - HWND hWnd; - -#ifdef UNICODE - wndClassName = NewtCommon_GetNullTerminatedStringChars(env, jWndClassName); - wndName = NewtCommon_GetNullTerminatedStringChars(env, jWndName); -#else - wndClassName = (*env)->GetStringUTFChars(env, jWndClassName, NULL); - wndName = (*env)->GetStringUTFChars(env, jWndName, NULL); -#endif - - dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; - dwStyle = WS_OVERLAPPEDWINDOW; - - hWnd = CreateWindowEx( dwExStyle, - wndClassName, - wndName, - dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - x, y, width, height, - NULL, NULL, hInstance, NULL ); + jboolean res = JNI_TRUE; + DummyThreadContext * dispThreadCtx = (DummyThreadContext *) (intptr_t) jDispThreadCtx; + HWND hWnd = (HWND) (intptr_t) jwin; + if( NULL == dispThreadCtx ) { + DestroyWindow(hWnd); + } else { + const HANDLE threadHandle = dispThreadCtx->threadHandle; + const DWORD threadId = dispThreadCtx->threadId; + DummyThreadCommand tParam = {0}; -#ifdef UNICODE - free((void*) wndClassName); - free((void*) wndName); -#else - (*env)->ReleaseStringUTFChars(env, jWndClassName, wndClassName); - (*env)->ReleaseStringUTFChars(env, jWndName, wndName); -#endif + tParam.hWnd = hWnd; + tParam.threadReady = FALSE; - return (jlong) (intptr_t) hWnd; + if( JNI_FALSE == DDT_CheckAlive(env, sTM_CLOSEWIN, dispThreadCtx) ) { + free(dispThreadCtx); + res = JNI_FALSE; + NativewindowCommon_throwNewRuntimeException(env, "DDT %s (alive) failed handle %p, id %d, werr %d", + sTM_CLOSEWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } else { + if ( 0 != PostThreadMessage(dispThreadCtx->threadId, TM_CLOSEWIN, (WPARAM)&tParam, 0) ) { + if( JNI_FALSE == DDT_WaitUntilReady(env, sTM_CLOSEWIN, &tParam) ) { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + res = JNI_FALSE; + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s (ack) failed handle %p, id %d, werr %d", + sTM_CLOSEWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } + } else { + if( NULL != threadHandle ) { + TerminateThread(threadHandle, 0); + } + free(dispThreadCtx); + res = JNI_FALSE; + NativewindowCommon_throwNewRuntimeException(env, "DDT Post %s to handle %p, id %d failed, werr %d", + sTM_CLOSEWIN, (void*)threadHandle, (int)threadId, (int)GetLastError()); + } + } + } + return res; } - /* * Class: jogamp_nativewindow_windows_GDIUtil * Method: initIDs0 * Signature: ()Z */ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_initIDs0 - (JNIEnv *env, jclass clazz) + (JNIEnv *env, jclass gdiClazz) { if(NativewindowCommon_init(env)) { jclass c = (*env)->FindClass(env, ClazzNamePoint); @@ -332,11 +499,15 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_initIDs0 NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't fetch %s.%s %s", ClazzNamePoint, ClazzAnyCstrName, ClazzNamePointCstrSignature); } + dumpStackID = (*env)->GetStaticMethodID(env, gdiClazz, "dumpStack", "()V"); + if(NULL==dumpStackID) { + NativewindowCommon_FatalError(env, "FatalError jogamp_nativewindow_windows_GDIUtil: can't get method dumpStack"); + } } return JNI_TRUE; } -LRESULT CALLBACK DummyWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { +static LRESULT CALLBACK DummyWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return DefWindowProc(hWnd,uMsg,wParam,lParam); } @@ -379,8 +550,8 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_windows_GDIUtil_GetRelativeLo JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsChild0 (JNIEnv *env, jclass unused, jlong jwin) { - HWND hwnd = (HWND) (intptr_t) jwin; - LONG style = GetWindowLong(hwnd, GWL_STYLE); + HWND hWnd = (HWND) (intptr_t) jwin; + LONG style = GetWindowLong(hWnd, GWL_STYLE); BOOL bIsChild = 0 != (style & WS_CHILD) ; return bIsChild ? JNI_TRUE : JNI_FALSE; } @@ -392,34 +563,9 @@ JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsChild0 JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_IsUndecorated0 (JNIEnv *env, jclass unused, jlong jwin) { - HWND hwnd = (HWND) (intptr_t) jwin; - LONG style = GetWindowLong(hwnd, GWL_STYLE); + HWND hWnd = (HWND) (intptr_t) jwin; + LONG style = GetWindowLong(hWnd, GWL_STYLE); BOOL bIsUndecorated = 0 != (style & (WS_CHILD|WS_POPUP)) ; return bIsUndecorated ? JNI_TRUE : JNI_FALSE; } -/* - * Class: jogamp_nativewindow_windows_GDIUtil - * Method: SendCloseMessage - */ -JNIEXPORT jboolean JNICALL Java_jogamp_nativewindow_windows_GDIUtil_SendCloseMessage -(JNIEnv *env, jclass unused, jlong jwin) -{ - ThreadParam tParam = {0}; - volatile HWND hwnd = (HWND) (intptr_t) jwin; - - if( 0 == threadid ) { - NativewindowCommon_throwNewRuntimeException(env, "Native threadid zero 0x%X", (int)threadid); - return JNI_FALSE; - } - - tParam.hWnd = hwnd; - tParam.threadReady = FALSE; - - PostThreadMessage(threadid, TM_CLOSEWIN, (WPARAM)&tParam, 0); - - while(!tParam.threadReady) { /* nop */ } - - return JNI_TRUE; -} - diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index d8ff7ecb5..c4cfd98b3 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -51,7 +51,7 @@ public class DisplayDriver extends DisplayImpl { static { NEWTJNILibLoader.loadNEWT(); - sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0()); + sharedClassFactory = new RegisteredClassFactory(newtClassBaseName, WindowDriver.getNewtWndProc0(), false /* useDummyDispatchThread */); if (!WindowDriver.initIDs0(RegisteredClassFactory.getHInstance())) { throw new NativeWindowException("Failed to initialize WindowsWindow jmethodIDs"); -- cgit v1.2.3 From 11a4a3a7b120c6f7c34a717828da49e3a13f4a3b Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 1 Dec 2013 20:05:01 +0100 Subject: GLJPanel.initializeBackend(offthread=true): Enable on Windows, thanks to Bug 907 impl. DummyDispatchThread (DDT) Bug 907 implemented DDT used to create and destroy offscreen surface's dummy drawable on Windows. This enables offscreen initialization on Windows running from a short lived arbitrary thread. --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/jogl/classes/javax/media/opengl/awt/GLJPanel.java | 10 ---------- 3 files changed, 4 insertions(+), 14 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index d95b0025f..d0c3f5d2e 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -24,7 +24,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 56a07e768..601ede4e4 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -325,7 +325,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -355,7 +355,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 70dd8b99d..8670c3746 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -58,7 +58,6 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.opengl.GL; import javax.media.opengl.GL2; @@ -361,12 +360,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing * true, otherwise false. *

      *

      - * Due to threading restrictions, arbitrary thread initialization is not supported on: - *

        - *
      • {@link NativeWindowFactory.TYPE_WINDOWS}
      • - *
      - *

      - *

      * If offthread is false, initialization be performed * on the current thread and method returns after initialization.
      * Method returns true if initialization was successful, otherwise false. @@ -375,9 +368,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing */ public final boolean initializeBackend(boolean offthread) { if( offthread ) { - if( NativeWindowFactory.TYPE_WINDOWS == NativeWindowFactory.getNativeWindowType(true) ) { - return false; - } new Thread(getThreadName()+"-GLJPanel_Init") { public void run() { if( !isInitialized ) { -- cgit v1.2.3 From 4cb35d98a1b25fb8347584b0ab6534c7cfc5946c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 1 Dec 2013 23:22:17 +0100 Subject: Bug 914 - Don't allow 'alwaysontop' in fullscreen mode, always allow switching to other applications via ALT-TAB As described @ , we shall not steal the desktop in fullscreen mode via 'alwaysontop'. Latest tests on X11/GNU/Linux and Windows7 - before this patch: With default settings, i.e. alwaysontop (atop) disabled, it works as expected here, i.e.: - ALT-TAB triggers WM dialog, switching between apps. - ALT-TAB can actually switch to other apps. However, with enabled atop: - ALT-TAB triggers WM dialog, switching between apps. - ALT-TAB does _not_ switch to other apps. (*) I consider this a serious issue, since we shall not steal the desktop in fullscreen mode. This patch disables atop in fullscreen mode, i.e. (*) will switch to other apps again! --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 4 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 25 +++++++++++++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index d0c3f5d2e..d95b0025f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -24,7 +24,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.TexCubeES2 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRendering1GL2NEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 601ede4e4..56a07e768 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -325,7 +325,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -355,7 +355,7 @@ function testawtswt() { # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* # diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 51740cb8d..d62a19f44 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -164,6 +164,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private boolean autoPosition = true; // default: true (allow WM to choose top-level position, if not set by user) private int nfs_width, nfs_height, nfs_x, nfs_y; // non fullscreen client-area size/pos w/o insets + private boolean nfs_alwaysOnTop; // non fullscreen alwaysOnTop setting private NativeWindow nfs_parent = null; // non fullscreen parent, in case explicit reparenting is performed (offscreen) private String title = "Newt Window"; private boolean undecorated = false; @@ -1610,7 +1611,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final void setAlwaysOnTop(boolean value) { - runOnEDTIfAvail(true, new AlwaysOnTopAction(value)); + if( isFullscreen() ) { + nfs_alwaysOnTop = value; + } else { + runOnEDTIfAvail(true, new AlwaysOnTopAction(value)); + } } @Override @@ -2012,6 +2017,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RectangleImmutable sviewport = screen.getViewport(); final RectangleImmutable viewport; final int fs_span_flag; + final boolean alwaysOnTopChange; if(fullscreen) { if( null == fullscreenMonitors ) { if( fullscreenUseMainMonitor ) { @@ -2032,10 +2038,13 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer nfs_y = oldY; nfs_width = oldWidth; nfs_height = oldHeight; + nfs_alwaysOnTop = alwaysOnTop; x = viewport.getX(); y = viewport.getY(); w = viewport.getWidth(); h = viewport.getHeight(); + alwaysOnTop = false; + alwaysOnTopChange = nfs_alwaysOnTop != alwaysOnTop; } else { fullscreenUseMainMonitor = true; fullscreenMonitors = null; @@ -2045,6 +2054,8 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer y = nfs_y; w = nfs_width; h = nfs_height; + alwaysOnTopChange = nfs_alwaysOnTop != alwaysOnTop; + alwaysOnTop = nfs_alwaysOnTop; if(null!=parentWindow) { // reset position to 0/0 within parent space @@ -2063,7 +2074,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+ - ", spanning "+(0!=fs_span_flag)+" @ "+Thread.currentThread().getName()); + ", spanning "+(0!=fs_span_flag)+ + ", alwaysOnTop "+alwaysOnTop+(alwaysOnTopChange?"*":"")+ + " @ "+Thread.currentThread().getName()); } final DisplayImpl display = (DisplayImpl) screen.getDisplay(); @@ -2090,9 +2103,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer parentWindowLocked = null; } try { + if(alwaysOnTopChange && fullscreen) { + // Enter fullscreen - Disable alwaysOnTop + reconfigureWindowImpl(nfs_x, nfs_y, nfs_width, nfs_height, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); + } reconfigureWindowImpl(x, y, w, h, getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, isVisible()) ); + if(alwaysOnTopChange && !fullscreen) { + // Leave fullscreen - Restore alwaysOnTop + reconfigureWindowImpl(x, y, w, h, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); + } } finally { if(null!=parentWindowLocked) { parentWindowLocked.unlockSurface(); -- cgit v1.2.3 From 69c334448cfe8af553fd97689137ecf8f996b378 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 2 Dec 2013 05:39:01 +0100 Subject: Bug 914: Newt OSX: Don't use exclusive fullscreen mode (captured display) in favor of proper WM incl. ALT-TAB app-switching --- make/scripts/tests.sh | 2 +- src/newt/native/MacWindow.m | 13 +++++++++++++ src/newt/native/NewtMacWindow.h | 3 +++ src/newt/native/NewtMacWindow.m | 21 +++++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 56a07e768..915752bef 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -90,7 +90,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all" #D_ARGS="-Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" - D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" + #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index f0ed170f0..3e8935787 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -827,8 +827,21 @@ NS_ENDHANDLER NS_DURING // Available >= 10.5 - Makes the menubar disapear if( fullscreen ) { + /** + * See Bug 914: We don't use exclusive fullscreen anymore (capturing display) + * allowing ALT-TAB to allow process/app switching! + * Shall have no penalty on modern GPU and is also recommended, see bottom box @ + * + * if ( [myView respondsToSelector:@selector(enterFullScreenMode:withOptions:)] ) { [myView enterFullScreenMode: myScreen withOptions:NULL]; + } */ + if ( 0 != myView->fullscreenPresentationOptions ) { + [NSApp setPresentationOptions: myView->fullscreenPresentationOptions]; + } + } else { + if ( 0 != myView->defaultPresentationOptions ) { + [NSApp setPresentationOptions: myView->defaultPresentationOptions]; } } NS_HANDLER diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index c9d53f53b..a3bd5c41b 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -64,6 +64,9 @@ volatile NSTrackingRectTag ptrTrackingTag; NSRect ptrRect; NSCursor * myCursor; +@public + NSUInteger defaultPresentationOptions; + NSUInteger fullscreenPresentationOptions; } - (id)initWithFrame:(NSRect)frameRect; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 686e5d2b0..266b63081 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -129,6 +129,27 @@ static jmethodID windowRepaintID = NULL; */ myCursor = NULL; + // OSX 10.6 + if ( [NSApp respondsToSelector:@selector(currentSystemPresentationOptions)] && + [NSApp respondsToSelector:@selector(setPresentationOptions:)] ) { + defaultPresentationOptions = [NSApp currentSystemPresentationOptions]; + fullscreenPresentationOptions = + // NSApplicationPresentationDefault| + // NSApplicationPresentationAutoHideDock| + NSApplicationPresentationHideDock| + // NSApplicationPresentationAutoHideMenuBar| + NSApplicationPresentationHideMenuBar| + NSApplicationPresentationDisableAppleMenu| + // NSApplicationPresentationDisableProcessSwitching| + // NSApplicationPresentationDisableSessionTermination| + NSApplicationPresentationDisableHideApplication| + // NSApplicationPresentationDisableMenuBarTransparency| + 0 ; + } else { + defaultPresentationOptions = 0; + fullscreenPresentationOptions = 0; + } + DBG_PRINT("NewtView::create: %p (refcnt %d)\n", res, (int)[res retainCount]); return res; } -- cgit v1.2.3 From 8512777873461ee33d8ed913ee26bafc00a08a02 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 4 Dec 2013 07:51:30 +0100 Subject: Bug 919 - TestNewtKeyCodesAWT w/ NewtCanvasAWT Fails on Windows Due to Clogged Key-Release Event by AWT Robot Impact: Only unit test code - TestNewtKeyCodesAWT: Fix Bug 919 - Move mouse bacl/forth while waiting for events .. - Use common wait for key timeout/polling using constants in NEWTKeyUtil - InputEventCountAdapter: 'getQueued()' -> 'copyQueue()' - ensuring queue is copied while instance is locked. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 3 +- make/scripts/tests.sh | 6 +- src/newt/native/WindowsWindow.c | 4 +- .../junit/newt/event/BaseNewtEventModifiers.java | 204 ++++++++++----------- .../newt/event/TestNewtKeyCodeModifiersAWT.java | 4 +- .../test/junit/newt/event/TestNewtKeyCodesAWT.java | 81 ++++---- .../newt/event/TestNewtKeyEventAutoRepeatAWT.java | 107 ++++++----- .../junit/newt/event/TestNewtKeyEventOrderAWT.java | 2 +- .../opengl/test/junit/util/AWTKeyAdapter.java | 6 +- .../opengl/test/junit/util/AWTMouseAdapter.java | 6 +- .../opengl/test/junit/util/AWTRobotUtil.java | 32 ++-- .../test/junit/util/InputEventCountAdapter.java | 2 +- .../opengl/test/junit/util/NEWTKeyAdapter.java | 8 +- .../jogamp/opengl/test/junit/util/NEWTKeyUtil.java | 70 +++---- .../opengl/test/junit/util/NEWTMouseAdapter.java | 6 +- 16 files changed, 275 insertions(+), 270 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index d95b0025f..157d06611 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -117,7 +117,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEven REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 3e56a31a6..6e8407f3e 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -21,7 +21,7 @@ set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;..\..\joal\% echo CP_ALL %CP_ALL% REM set D_ARGS="-Djogamp.debug=all" -set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" +REM set D_ARGS="-Djogl.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" REM set D_ARGS="-Djogl.debug=all" "-Dnewt.debug=all" "-Dnativewindow.debug=all" "-Djogamp.debug=all" "-Djogl.debug.EGLDrawableFactory.DontQuery" REM set D_ARGS="-Dnativewindow.debug.GDIUtil" "-Dnativewindow.debug.RegisteredClass" @@ -57,6 +57,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.Til REM set D_ARGS="-Djogl.gljpanel.noverticalflip" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" +set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.EDT" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 915752bef..7c5fdbb89 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -196,7 +196,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - #D_ARGS="-Dnewt.debug.Window.KeyEvent" + D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -325,7 +325,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* @@ -569,7 +569,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 18bff1997..dd0150e78 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -487,8 +487,8 @@ static void ParseWmVKeyAndScanCode(USHORT winVKey, BYTE winScanCode, BYTE flags, *outJavaVKeyXX = javaVKeyXX; #ifdef DEBUG_KEYS - STD_PRINT("*** WindowsWindow: ParseWmVKeyAndScanCode winVKey 0x%X, winScanCode 0x%X, winScanCodeExt 0x%X, flags 0x%X -> UTF(0x%X, %c, res %d, sizeof %d), vKeys( US(win 0x%X, java 0x%X), XX(win 0x%X, java 0x%X))\n", - (int)winVKey, (int)winScanCode, winScanCodeExt, (int)flags, + STD_PRINT("*** WindowsWindow: ParseWmVKeyAndScanCode winVKey 0x%X, winScanCode 0x%X, flags 0x%X -> UTF(0x%X, %c, res %d, sizeof %d), vKeys( US(win 0x%X, java 0x%X), XX(win 0x%X, java 0x%X))\n", + (int)winVKey, (int)winScanCode, (int)flags, *outUTF16Char, *outUTF16Char, nUniChars, sizeof(uniChars[0]), winVKeyUS, javaVKeyUS, winVKey, javaVKeyXX); #endif diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java index 44d6a2dec..a46e21b23 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/BaseNewtEventModifiers.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.event ; import java.io.PrintStream ; @@ -66,15 +66,15 @@ public abstract class BaseNewtEventModifiers extends UITestCase { protected static final int MS_ROBOT_KEY_PRESS_DELAY = 50 ; protected static final int MS_ROBOT_KEY_RELEASE_DELAY = 50 ; protected static final int MS_ROBOT_MOUSE_MOVE_DELAY = 200 ; - - protected static final int MS_ROBOT_AUTO_DELAY = 50 ; + + protected static final int MS_ROBOT_AUTO_DELAY = 50 ; protected static final int MS_ROBOT_POST_TEST_DELAY = 100; - + protected static final boolean _debug = true ; protected static PrintStream _debugPrintStream = System.err ; - + //////////////////////////////////////////////////////////////////////////// - + static { GLProfile.initSingleton() ; @@ -96,7 +96,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { public synchronized boolean modifierCheckEnabled() { return _modifierCheckEnabled ; } - + /** * Sets the modifiers the listener should expect, and clears * out any existing accumulated failures. Normally this kind @@ -108,20 +108,20 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _expectedModifiers = value ; clear(); } - + public synchronized ArrayList clear() { ArrayList old = _failures; - + _eventCount = 0; // Assume we will have a failure due to no event delivery. // If an event is delivered and it's good this assumed - // failure will get cleared out. + // failure will get cleared out. _failures = new ArrayList(); _failures.add( NO_EVENT_DELIVERY ); return old; } - + public ArrayList getFailures(int waitEventCount) { int j; for(j=0; j < 20 && _eventCount < waitEventCount; j++) { // wait until events are collected @@ -132,14 +132,14 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } return clear(); } - + private synchronized void _checkModifiers( com.jogamp.newt.event.MouseEvent hasEvent ) { if( _modifierCheckEnabled ) { - final MouseEvent expEvent = new MouseEvent(hasEvent.getEventType(), hasEvent.getSource(), hasEvent.getWhen(), _expectedModifiers, - hasEvent.getX(), hasEvent.getY(), hasEvent.getClickCount(), hasEvent.getButton(), + final MouseEvent expEvent = new MouseEvent(hasEvent.getEventType(), hasEvent.getSource(), hasEvent.getWhen(), _expectedModifiers, + hasEvent.getX(), hasEvent.getY(), hasEvent.getClickCount(), hasEvent.getButton(), hasEvent.getRotation(), hasEvent.getRotationScale()); - + _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.SHIFT_MASK, "shift" ) ; _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.CTRL_MASK, "ctrl" ) ; _checkModifierMask( expEvent, hasEvent, com.jogamp.newt.event.InputEvent.META_MASK, "meta" ) ; @@ -180,7 +180,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _eventCount++; if( _debug ) { _debugPrintStream.println( "MousePressed "+_eventCount+": "+event); - } + } _checkModifiers( event ) ; } @@ -188,7 +188,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _eventCount++; if( _debug ) { _debugPrintStream.println( "MouseReleased "+_eventCount+": "+event); - } + } _checkModifiers( event ) ; } @@ -196,29 +196,29 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _eventCount++; if( _debug ) { _debugPrintStream.println( "MouseDragged "+_eventCount+": "+event); - } + } _checkModifiers( event ) ; } // - // IGNORED - // - - public synchronized void mouseMoved( com.jogamp.newt.event.MouseEvent event ) { + // IGNORED + // + + public synchronized void mouseMoved( com.jogamp.newt.event.MouseEvent event ) { // Ignored, since mouse MOVE doesn't hold mouse button, we look for DRAGGED! // _eventCount++; if( _debug ) { _debugPrintStream.println( "MouseMoved ignored: "+event); - } + } // _checkModifiers( event ) ; } - + public synchronized void mouseClicked( com.jogamp.newt.event.MouseEvent event ) { // Ignored, since we look for PRESS/RELEASE only! // _eventCount++; if( _debug ) { _debugPrintStream.println( "MouseClicked ignored: "+event); - } + } // _checkModifiers( event ) ; } @@ -226,23 +226,23 @@ public abstract class BaseNewtEventModifiers extends UITestCase { // _eventCount++; if( _debug ) { _debugPrintStream.println( "MouseWheeleMoved ignored: "+event); - } + } // _checkModifiers( event ) ; } - + public synchronized void mouseEntered( com.jogamp.newt.event.MouseEvent event ) { // _eventCount++; if( _debug ) { _debugPrintStream.println( "MouseEntered ignored: "+event); - } + } // _checkModifiers( event ) ; } - + public synchronized void mouseExited( com.jogamp.newt.event.MouseEvent event ) { // _eventCount++; if( _debug ) { _debugPrintStream.println( "MouseExited ignored: "+event); - } + } // _checkModifiers( event ) ; } @@ -261,7 +261,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { public static int getAWTButtonMask(int button) { // Java7: java.awt.event.InputEvent.getMaskForButton( n + 1 ) ; -> using InputEvent.BUTTON1_DOWN_MASK .. etc - // Java6: Only use BUTTON1_MASK, .. + // Java6: Only use BUTTON1_MASK, .. int m; switch(button) { case 1 : m = java.awt.event.InputEvent.BUTTON1_MASK; break; @@ -271,14 +271,14 @@ public abstract class BaseNewtEventModifiers extends UITestCase { } return m; } - + @BeforeClass public static void baseBeforeClass() throws Exception { // Who know how many buttons the AWT will say exist on given platform. // We'll test the smaller of what NEWT supports and what the // AWT says is available. - /** Java7: + /** Java7: if( java.awt.Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled() ) { _numButtonsToTest = java.awt.MouseInfo.getNumberOfButtons() ; } else { @@ -300,7 +300,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _numButtonsToTest = 3 ; { - if( _numButtonsToTest > com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { + if( _numButtonsToTest > com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ) { _numButtonsToTest = com.jogamp.newt.event.MouseEvent.BUTTON_COUNT ; } @@ -309,10 +309,10 @@ public abstract class BaseNewtEventModifiers extends UITestCase { // either array. _awtButtonMasks = new int[_numButtonsToTest] ; - + for( int n = 0 ; n < _awtButtonMasks.length ; ++n ) { _awtButtonMasks[n] = getAWTButtonMask( n + 1 ); - } + } } _robot = new java.awt.Robot() ; @@ -326,23 +326,23 @@ public abstract class BaseNewtEventModifiers extends UITestCase { // to run the SWT event dispatch on the TK thread - which must be the main thread on OSX. // We spawn off the actual test-action into another thread, // while dispatching the events until the test-action is completed. - // YES: This is sort of ideal - NOT :) - - protected void eventDispatch() { + // YES: This is sort of ideal - NOT :) + + protected void eventDispatch() { try { Thread.sleep(100); - } catch (InterruptedException e) { } + } catch (InterruptedException e) { } } - + private void execOffThreadWithOnThreadEventDispatch(Runnable testAction) throws Exception { - _testMouseListener.setModifierCheckEnabled( false ) ; + _testMouseListener.setModifierCheckEnabled( false ) ; _robot.setAutoDelay( MS_ROBOT_AUTO_DELAY ) ; - { + { // Make sure all the buttons and modifier keys are released. clearKeyboadAndMouse(); } _testMouseListener.setModifierCheckEnabled( true ) ; - + Throwable throwable = null; // final Object sync = new Object(); final RunnableTask rt = new RunnableTask( testAction, null, true, System.err ); @@ -361,13 +361,13 @@ public abstract class BaseNewtEventModifiers extends UITestCase { throw new RuntimeException(throwable); } // } - } finally { + } finally { System.err.println("WAIT-till-done: DONE"); - _testMouseListener.setModifierCheckEnabled( false ) ; + _testMouseListener.setModifierCheckEnabled( false ) ; clearKeyboadAndMouse(); } } - + //////////////////////////////////////////////////////////////////////////// // The approach on all these tests is to tell the test mouse listener what @@ -390,59 +390,59 @@ public abstract class BaseNewtEventModifiers extends UITestCase { @Test(timeout=180000) // TO 3 min public void testSingleButtonPressAndRelease() throws Exception { - execOffThreadWithOnThreadEventDispatch(new Runnable() { - public void run() { - try { - _doSingleButtonPressAndRelease( 0, 0 ); - } catch (Exception e) { throw new RuntimeException(e); } + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { + _doSingleButtonPressAndRelease( 0, 0 ); + } catch (Exception e) { throw new RuntimeException(e); } } } ); } @Test(timeout=180000) // TO 3 min public void testSingleButtonPressAndReleaseWithShift() throws Exception { - execOffThreadWithOnThreadEventDispatch(new Runnable() { - public void run() { - try { + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_SHIFT, java.awt.event.InputEvent.SHIFT_DOWN_MASK ) ; - } catch (Exception e) { throw new RuntimeException(e); } + } catch (Exception e) { throw new RuntimeException(e); } } } ); } @Test(timeout=180000) // TO 3 min public void testSingleButtonPressAndReleaseWithCtrl() throws Exception { - execOffThreadWithOnThreadEventDispatch(new Runnable() { - public void run() { - try { + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_CONTROL, java.awt.event.InputEvent.CTRL_DOWN_MASK ) ; - } catch (Exception e) { throw new RuntimeException(e); } + } catch (Exception e) { throw new RuntimeException(e); } } } ); } /** * The META and ALT tests get too tied up with functions of the window system on X11, - * so it's probably best to leave them commented out. + * so it's probably best to leave them commented out. @Test(timeout=180000) // TO 3 min public void testSingleButtonPressAndReleaseWithMeta() throws Exception { - execOffThreadWithOnThreadEventDispatch(new Runnable() { - public void run() { - try { + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_META, java.awt.event.InputEvent.META_DOWN_MASK ) ; - } catch (Exception e) { throw new RuntimeException(e); } + } catch (Exception e) { throw new RuntimeException(e); } } } ); } - + @Test(timeout=180000) // TO 3 min public void testSingleButtonPressAndReleaseWithAlt() throws Exception { - execOffThreadWithOnThreadEventDispatch(new Runnable() { - public void run() { - try { + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT, java.awt.event.InputEvent.ALT_DOWN_MASK ) ; - } catch (Exception e) { throw new RuntimeException(e); } + } catch (Exception e) { throw new RuntimeException(e); } } } ); } */ - /** + /** * FIXME - not sure yet what's up with ALT_GRAPH. It appears that this * modifier didn't make it through, so I had to disable this test else it would always fail. * @@ -450,11 +450,11 @@ public abstract class BaseNewtEventModifiers extends UITestCase { * enough to not let this modifier slip through (?). @Test public void testSingleButtonPressAndReleaseWithAltGraph() throws Exception { - execOffThreadWithOnThreadEventDispatch(new Runnable() { - public void run() { - try { + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { _doSingleButtonPressAndRelease( java.awt.event.KeyEvent.VK_ALT_GRAPH, java.awt.event.InputEvent.ALT_GRAPH_DOWN_MASK ) ; - } catch (Exception e) { throw new RuntimeException(e); } + } catch (Exception e) { throw new RuntimeException(e); } } } ); } */ @@ -463,31 +463,31 @@ public abstract class BaseNewtEventModifiers extends UITestCase { @Test(timeout=180000) // TO 3 min public void testHoldOneButtonAndPressAnother() throws Exception { - execOffThreadWithOnThreadEventDispatch(new Runnable() { - public void run() { - try { + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { _doHoldOneButtonAndPressAnother( 0, 0 ) ; - } catch (Exception e) { throw new RuntimeException(e); } + } catch (Exception e) { throw new RuntimeException(e); } } } ); } - + @Test(timeout=180000) // TO 3 min public void testPressAllButtonsInSequence() throws Exception { - execOffThreadWithOnThreadEventDispatch(new Runnable() { - public void run() { - try { + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { _doPressAllButtonsInSequence( 0, 0 ) ; - } catch (Exception e) { throw new RuntimeException(e); } + } catch (Exception e) { throw new RuntimeException(e); } } } ); } @Test(timeout=180000) // TO 3 min public void testSingleButtonClickAndDrag() throws Exception { - execOffThreadWithOnThreadEventDispatch(new Runnable() { - public void run() { - try { + execOffThreadWithOnThreadEventDispatch(new Runnable() { + public void run() { + try { _doSingleButtonClickAndDrag( 0, 0 ) ; - } catch (Exception e) { throw new RuntimeException(e); } + } catch (Exception e) { throw new RuntimeException(e); } } } ); } @@ -522,7 +522,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { private void _doHoldOneButtonAndPressAnother( final int keyCode, final int keyModifierMask ) throws Exception { if( _debug ) { _debugPrintStream.println( "\n>>>> _doHoldOneButtonAndPressAnother" ) ; } - + _doKeyPress( keyCode ) ; for (int n = 0 ; n < _numButtonsToTest ; ++n) { @@ -533,7 +533,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | awtButtonMask ) ) ; _robot.mousePress( awtButtonMask ) ; _checkFailures("mouse-press("+(n+1)+")", 1) ; - + for (int m = 0 ; m < _numButtonsToTest ; ++m) { if( n != m ) { @@ -564,12 +564,12 @@ public abstract class BaseNewtEventModifiers extends UITestCase { private void _doPressAllButtonsInSequence( final int keyCode, final int keyModifierMask ) throws Exception { if( _debug ) { _debugPrintStream.println( "\n>>>> _doPressAllButtonsInSequence" ) ; } - + _doKeyPress( keyCode ) ; { int cumulativeAwtModifiers = 0 ; - + for (int n = 0 ; n < _numButtonsToTest ; ++n) { cumulativeAwtModifiers |= _awtButtonMasks[n] ; @@ -586,7 +586,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _testMouseListener.setExpectedModifiers( _getNewtModifiersForAwtExtendedModifiers( keyModifierMask | cumulativeAwtModifiers ) ) ; _robot.mouseRelease( _awtButtonMasks[n] ) ; _checkFailures("mouse-release("+(n+1)+")", 1) ; - + cumulativeAwtModifiers &= ~_awtButtonMasks[n] ; } } @@ -627,7 +627,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { _testMouseListener.setModifierCheckEnabled( false ) ; _robot.mouseMove( INITIAL_MOUSE_X, INITIAL_MOUSE_Y ) ; - _robot.delay(MS_ROBOT_MOUSE_MOVE_DELAY); + _robot.delay(MS_ROBOT_MOUSE_MOVE_DELAY); _testMouseListener.setModifierCheckEnabled( true ) ; } @@ -637,7 +637,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { //////////////////////////////////////////////////////////////////////////// private void _doKeyPress( int keyCode ) { - AWTRobotUtil.validateAWTEDTIsAlive(); + AWTRobotUtil.validateAWTEDTIsAlive(); if( keyCode != 0 ) { boolean modifierCheckEnabled = _testMouseListener.modifierCheckEnabled() ; _testMouseListener.setModifierCheckEnabled( false ) ; @@ -686,9 +686,9 @@ public abstract class BaseNewtEventModifiers extends UITestCase { eventDispatch(); eventDispatch(); eventDispatch(); Thread.sleep( MS_ROBOT_POST_TEST_DELAY ) ; eventDispatch(); eventDispatch(); eventDispatch(); - _testMouseListener.clear(); + _testMouseListener.clear(); } - + public void clearKeyboadAndMouse() throws Exception { // Make sure all modifiers are released, otherwise the user's // desktop can get locked up (ask me how I know this). @@ -745,7 +745,7 @@ public abstract class BaseNewtEventModifiers extends UITestCase { * @return * The equivalent NEWT modifiers. */ - + private int _getNewtModifiersForAwtExtendedModifiers( int awtExtendedModifiers ) { int mask = 0 ; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java index 4be819261..2516fc536 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodeModifiersAWT.java @@ -186,7 +186,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { 3 /* press-SI */, 3 /* release-SI */, 0 /* press-AR */, 0 /* release-AR */ ); - final List queue = keyAdapter.getQueued(); + final List queue = keyAdapter.copyQueue(); int i=0; NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, 0, keyCode, keyCharOnly); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_RELEASED, 0, keyCode, keyCharOnly); @@ -226,7 +226,7 @@ public class TestNewtKeyCodeModifiersAWT extends UITestCase { 4 /* press-SI */, 4 /* release-SI */, 0 /* press-AR */, 0 /* release-AR */ ); - final List queue = keyAdapter.getQueued(); + final List queue = keyAdapter.copyQueue(); int i=0; NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m, m1k, KeyEvent.NULL_CHAR); NEWTKeyUtil.validateKeyEvent((KeyEvent) queue.get(i++), KeyEvent.EVENT_KEY_PRESSED, m1m|m2m, m2k, KeyEvent.NULL_CHAR); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java index 4778b4feb..71778c611 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyCodesAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.event; import org.junit.After; @@ -60,7 +60,6 @@ import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; - import com.jogamp.opengl.test.junit.util.*; import com.jogamp.opengl.test.junit.util.NEWTKeyUtil.CodeSeg; @@ -85,35 +84,35 @@ public class TestNewtKeyCodesAWT extends UITestCase { @AfterClass public static void release() { } - + @Before - public void initTest() { + public void initTest() { } @After - public void releaseTest() { + public void releaseTest() { } - + @Test(timeout=180000) // TO 3 min public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { GLWindow glWindow = GLWindow.create(glCaps); glWindow.setSize(width, height); glWindow.setVisible(true); - + testImpl(glWindow); - + glWindow.destroy(); } - + private void testNewtCanvasAWT_Impl(boolean onscreen) throws AWTException, InterruptedException, InvocationTargetException { GLWindow glWindow = GLWindow.create(glCaps); - + // Wrap the window in a canvas. final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); if( !onscreen ) { newtCanvasAWT.setShallUseOffscreenLayer(true); } - + // Add the canvas to a frame, and make it all visible. final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); @@ -122,11 +121,11 @@ public class TestNewtKeyCodesAWT extends UITestCase { frame1.setSize(width, height); frame1.setVisible(true); } } ); - + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); - + testImpl(glWindow); - + try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -136,10 +135,10 @@ public class TestNewtKeyCodesAWT extends UITestCase { } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } glWindow.destroy(); } - + @Test(timeout=180000) // TO 3 min public void test02NewtCanvasAWT_Onscreen() throws AWTException, InterruptedException, InvocationTargetException { if( JAWTUtil.isOffscreenLayerRequired() ) { @@ -148,7 +147,7 @@ public class TestNewtKeyCodesAWT extends UITestCase { } testNewtCanvasAWT_Impl(true); } - + @Test(timeout=180000) // TO 3 min public void test03NewtCanvasAWT_Offsccreen() throws AWTException, InterruptedException, InvocationTargetException { if( !JAWTUtil.isOffscreenLayerSupported() ) { @@ -157,7 +156,7 @@ public class TestNewtKeyCodesAWT extends UITestCase { } testNewtCanvasAWT_Impl(false); } - + /** Almost all keyCodes reachable w/o modifiers [shift, alt, ..] on US keyboard! */ static CodeSeg[] codeSegments = new CodeSeg[] { // new CodeSeg(KeyEvent.VK_HOME, KeyEvent.VK_PRINTSCREEN, "home, end, final, prnt"), @@ -188,16 +187,19 @@ public class TestNewtKeyCodesAWT extends UITestCase { new CodeSeg(KeyEvent.VK_LEFT, KeyEvent.VK_DOWN, "cursor arrows"), // new CodeSeg(KeyEvent.VK_WINDOWS, KeyEvent.VK_HELP, "windows, meta, hlp"), }; - - static void testKeyCodes(Robot robot, NEWTKeyAdapter keyAdapter) { + + static void testKeyCodes(Robot robot, Object obj, NEWTKeyAdapter keyAdapter) throws InterruptedException, InvocationTargetException { final List> cse = new ArrayList>(); - + + keyAdapter.setVerbose(true); // FIXME + final int[] objCenter = AWTRobotUtil.getCenterLocation(obj, false /* onTitleBarIfWindow */); + for(int i=0; i events = new ArrayList(keyAdapter.getQueued()); - cse.add(events); + AWTRobotUtil.awtRobotMouseMove(robot, objCenter[0], objCenter[1]); // Bug 919: Reset mouse position + cse.add(keyAdapter.copyQueue()); } - Assert.assertEquals("KeyCode impl. incomplete", true, NEWTKeyUtil.validateKeyCodes(codeSegments, cse, true)); + Assert.assertEquals("KeyCode impl. incomplete", true, NEWTKeyUtil.validateKeyCodes(codeSegments, cse, true)); } - + void testImpl(GLWindow glWindow) throws AWTException, InterruptedException, InvocationTargetException { final Robot robot = new Robot(); robot.setAutoWaitForIdle(true); @@ -238,20 +243,20 @@ public class TestNewtKeyCodesAWT extends UITestCase { glWindow1KA.setVerbose(false); glWindow.addKeyListener(glWindow1KA); - Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); + Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glWindow, true)); // Continuous animation .. Animator animator = new Animator(glWindow); animator.start(); Thread.sleep(durationPerTest); // manual testing - + AWTRobotUtil.assertRequestFocusAndWait(null, glWindow, glWindow, null, null); // programmatic AWTRobotUtil.requestFocus(robot, glWindow, false); // within unit framework, prev. tests (TestFocus02SwingAWTRobot) 'confuses' Windows keyboard input - glWindow1KA.reset(); + glWindow1KA.reset(); + + testKeyCodes(robot, glWindow, glWindow1KA); - testKeyCodes(robot, glWindow1KA); - // Remove listeners to avoid logging during dispose/destroy. glWindow.removeKeyListener(glWindow1KA); @@ -276,7 +281,7 @@ public class TestNewtKeyCodesAWT extends UITestCase { /** BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); System.err.println("Press enter to continue"); - System.err.println(stdin.readLine()); + System.err.println(stdin.readLine()); */ System.out.println("durationPerTest: "+durationPerTest); String tstname = TestNewtKeyCodesAWT.class.getName(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index 34e81c033..3ef96edc2 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.event; import org.junit.After; @@ -59,12 +59,11 @@ import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.test.junit.jogl.demos.es2.RedSquareES2; - import com.jogamp.opengl.test.junit.util.*; /** * Testing key event order incl. auto-repeat (Bug 601) - * + * *

      * Note Event order: *

        @@ -102,33 +101,33 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { @AfterClass public static void release() { } - + @Before - public void initTest() { + public void initTest() { } @After - public void releaseTest() { + public void releaseTest() { } - + @Test(timeout=180000) // TO 3 min public void test01NEWT() throws AWTException, InterruptedException, InvocationTargetException { GLWindow glWindow = GLWindow.create(glCaps); glWindow.setSize(width, height); glWindow.setVisible(true); - + testImpl(glWindow); - + glWindow.destroy(); } - + @Test(timeout=180000) // TO 3 min public void test02NewtCanvasAWT() throws AWTException, InterruptedException, InvocationTargetException { GLWindow glWindow = GLWindow.create(glCaps); - + // Wrap the window in a canvas. final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow); - + // Add the canvas to a frame, and make it all visible. final JFrame frame1 = new JFrame("Swing AWT Parent Frame: "+ glWindow.getTitle()); frame1.getContentPane().add(newtCanvasAWT, BorderLayout.CENTER); @@ -137,11 +136,11 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { public void run() { frame1.setVisible(true); } } ); - + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame1, true)); - + testImpl(glWindow); - + try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -151,15 +150,15 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); - } + } glWindow.destroy(); } - + static void testKeyEventAutoRepeat(Robot robot, NEWTKeyAdapter keyAdapter, int loops, int pressDurationMS) { System.err.println("KEY Event Auto-Repeat Test: "+loops); EventObject[][] first = new EventObject[loops][2]; EventObject[][] last = new EventObject[loops][2]; - + keyAdapter.reset(); int firstIdx = 0; for(int i=0; i keyEvents = keyAdapter.copyQueue(); + Assert.assertTrue("AR Test didn't collect enough key events: required min "+minCodeCount+", received "+(keyAdapter.getQueueSize()-firstIdx)+", "+keyEvents, keyAdapter.getQueueSize() >= minCodeCount ); - final List keyEvents = keyAdapter.getQueued(); - first[i][0] = (KeyEvent) keyEvents.get(firstIdx+0); - first[i][1] = (KeyEvent) keyEvents.get(firstIdx+1); + first[i][0] = keyEvents.get(firstIdx+0); + first[i][1] = keyEvents.get(firstIdx+1); firstIdx = keyEvents.size() - 2; - last[i][0] = (KeyEvent) keyEvents.get(firstIdx+0); - last[i][1] = (KeyEvent) keyEvents.get(firstIdx+1); + last[i][0] = keyEvents.get(firstIdx+0); + last[i][1] = keyEvents.get(firstIdx+1); System.err.println("+++ KEY Event Auto-Repeat END Input Loop: "+i); - + // add a pair of normal press/release in between auto-repeat! firstIdx = keyEvents.size(); AWTRobotUtil.waitForIdle(robot); AWTRobotUtil.keyPress(0, robot, true, java.awt.event.KeyEvent.VK_B, 10); AWTRobotUtil.keyPress(0, robot, false, java.awt.event.KeyEvent.VK_B, 250); AWTRobotUtil.waitForIdle(robot); - for(int j=0; j < 20 && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected - robot.delay(100); + for(int j=0; j < NEWTKeyUtil.POLL_DIVIDER && keyAdapter.getQueueSize() < firstIdx+3; j++) { // wait until events are collected + robot.delay(NEWTKeyUtil.TIME_SLICE); } firstIdx = keyEvents.size(); } // dumpKeyEvents(keyEvents); - final List keyEvents = keyAdapter.getQueued(); + final List keyEvents = keyAdapter.copyQueue(); NEWTKeyUtil.validateKeyEventOrder(keyEvents); - + final boolean hasAR = 0 < keyAdapter.getKeyPressedCount(true) ; - + { final int perLoopSI = 2; // per loop: 1 non AR event and 1 for non AR 'B' final int expSI, expAR; @@ -208,48 +207,48 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { expAR = ( keyEvents.size() - expSI*2 ) / 2; // auto-repeat release } else { expSI = keyEvents.size() / 2; // all released events - expAR = 0; + expAR = 0; } - - NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, - expSI /* press-SI */, expSI /* release-SI */, - expAR /* press-AR */, expAR /* release-AR */ ); + + NEWTKeyUtil.validateKeyAdapterStats(keyAdapter, + expSI /* press-SI */, expSI /* release-SI */, + expAR /* press-AR */, expAR /* release-AR */ ); } - + if( !hasAR ) { System.err.println("No AUTO-REPEAT triggered by AWT Robot .. aborting test analysis"); return; } - + for(int i=0; i getQueued() { - return queue; + public synchronized List copyQueue() { + return new ArrayList(queue); } public synchronized int getQueueSize() { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java index f6cbd0a04..c1bec79f5 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTMouseAdapter.java @@ -46,7 +46,7 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu reset(); } - public synchronized void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = v; } public synchronized boolean isPressed() { return pressed; @@ -60,8 +60,8 @@ public class AWTMouseAdapter extends java.awt.event.MouseAdapter implements Inpu return consumed; } - public synchronized List getQueued() { - return queue; + public synchronized List copyQueue() { + return new ArrayList(queue); } public synchronized int getQueueSize() { diff --git a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java index 657936adc..cf58ae257 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/AWTRobotUtil.java @@ -59,9 +59,6 @@ public class AWTRobotUtil { public static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ; public static Integer AWT_CLICK_TO = null; - static Object awtEDTAliveSync = new Object(); - static volatile boolean awtEDTAliveFlag = false; - static class OurUncaughtExceptionHandler implements UncaughtExceptionHandler { @Override public void uncaughtException(Thread t, Throwable e) { @@ -82,12 +79,7 @@ public class AWTRobotUtil { } synchronized ( awtEDTAliveSync ) { awtEDTAliveFlag = false; - EventQueue.invokeLater(new Runnable() { - @Override - public void run() { - awtEDTAliveFlag = true; - } - }); + EventQueue.invokeLater(aliveRun); for (int wait=0; wait getQueued(); + public List copyQueue(); public int getQueueSize(); } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java index 5242da637..0e86afd93 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyAdapter.java @@ -51,7 +51,7 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { reset(); } - public synchronized void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = v; } public synchronized boolean isPressed() { return pressed; @@ -73,8 +73,8 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { return autoRepeatOnly ? keyReleasedAR: keyReleased; } - public synchronized List getQueued() { - return queue; + public synchronized List copyQueue() { + return new ArrayList(queue); } public synchronized int getQueueSize() { @@ -118,6 +118,6 @@ public class NEWTKeyAdapter extends KeyAdapter implements KeyEventCountAdapter { } } - public String toString() { return prefix+"[pressed "+pressed+", keyReleased "+keyReleased+", consumed "+consumed+"]"; } + public String toString() { return prefix+"[pressed "+pressed+", keysPressed "+keyPressed+" (AR "+keyPressedAR+"), keyReleased "+keyReleased+" (AR "+keyReleasedAR+"), consumed "+consumed+"]"; } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java index 990930994..89bafbd8c 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTKeyUtil.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -37,11 +37,15 @@ import com.jogamp.common.util.IntIntHashMap; import com.jogamp.newt.event.KeyEvent; public class NEWTKeyUtil { + public static final int TIME_OUT = 2000; // 2s + public static final int POLL_DIVIDER = 20; // TO/20 + public static final int TIME_SLICE = TIME_OUT / POLL_DIVIDER ; + public static class CodeSeg { public final short min; public final short max; public final String description; - + public CodeSeg(int min, int max, String description) { this.min = (short)min; this.max = (short)max; @@ -52,23 +56,23 @@ public class NEWTKeyUtil { public final short code; public final String description; public final KeyEvent event; - + public CodeEvent(short code, String description, KeyEvent event) { this.code = code; this.description = description; this.event = event; } public String toString() { - return "Code 0x"+Integer.toHexString( (int)code & 0x0000FFFF )+" != "+event+" // "+description; + return "Code 0x"+Integer.toHexString( code & 0x0000FFFF )+" != "+event+" // "+description; } } - + public static void dumpKeyEvents(List keyEvents) { for(int i=0; i> keyEventsList, boolean verbose) { final List missCodes = new ArrayList(); int totalCodeCount = 0; @@ -78,7 +82,7 @@ public class NEWTKeyUtil { totalCodeCount += codeSeg.max - codeSeg.min + 1; final List keyEvents = keyEventsList.get(i); res &= validateKeyCodes(missCodes, codeSeg, keyEvents, verbose); - } + } if(verbose) { System.err.println("*** Total KeyCode Misses "+missCodes.size()+" / "+totalCodeCount+", valid "+res); for(int i=0; i keyEvents) { - IntIntHashMap keyCode2NextEvent = new IntIntHashMap(); + IntIntHashMap keyCode2NextEvent = new IntIntHashMap(); for(int i=0; i keyEvents = keyAdapter.getQueued(); - + + final List keyEvents = keyAdapter.copyQueue(); + Assert.assertEquals("Key pressRelease count failure (ALL) w/ list sum ", expPressReleaseCountALL, pressReleaseCountALL); Assert.assertEquals("Key total count failure (ALL) w/ list size ", pressReleaseCountALL, keyEvents.size()); - } + } } diff --git a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java index 6850fcf47..22e241f71 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/util/NEWTMouseAdapter.java @@ -49,7 +49,7 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda reset(); } - public synchronized void setVerbose(boolean v) { verbose = false; } + public synchronized void setVerbose(boolean v) { verbose = v; } public synchronized boolean isPressed() { return pressed; @@ -63,8 +63,8 @@ public class NEWTMouseAdapter extends MouseAdapter implements InputEventCountAda return consumed; } - public synchronized List getQueued() { - return queue; + public synchronized List copyQueue() { + return new ArrayList(queue); } public synchronized int getQueueSize() { -- cgit v1.2.3 From e2b74932a334b4a0bb9fedc12b0bc51095d35d6a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 4 Dec 2013 15:59:59 +0100 Subject: TestNewtKeyEventAutoRepeatAWT: Fix regression of commit 8512777873461ee33d8ed913ee26bafc00a08a02 --- make/scripts/tests-win.bat | 4 ++-- make/scripts/tests.sh | 6 +++--- .../opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 157d06611..22d474e7f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -115,9 +115,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNewtCanvasAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 7c5fdbb89..bdc67a5fa 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -196,7 +196,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" - D_ARGS="-Dnewt.debug.Window.KeyEvent" + #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window -Dnativewindow.debug=all" @@ -567,9 +567,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* -#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* +testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersAWTCanvas $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java index 3ef96edc2..c374f1efe 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/event/TestNewtKeyEventAutoRepeatAWT.java @@ -161,6 +161,7 @@ public class TestNewtKeyEventAutoRepeatAWT extends UITestCase { keyAdapter.reset(); int firstIdx = 0; + // final ArrayList keyEvents = new ArrayList(); for(int i=0; i keyEvents = keyAdapter.copyQueue(); -- cgit v1.2.3 From f8c2a90129736844a12b76d658cb339a7c36cd9a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 10 Dec 2013 21:27:14 +0100 Subject: Bug 904: 'User Vertical Flip' for GLJPanel w/o vertical flip must be considered in AWTTilePainter: 'Origin of GL image is still on Bottom' --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- .../classes/javax/media/opengl/awt/GLCanvas.java | 2 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 2 +- .../classes/jogamp/opengl/awt/AWTTilePainter.java | 21 ++- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 2 +- .../jogl/tile/TestTiledPrintingGearsSwingAWT.java | 77 ++++++++-- .../jogl/tile/TestTiledPrintingGearsSwingAWT2.java | 161 +++++++++++++++------ 8 files changed, 201 insertions(+), 72 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 22d474e7f..6d79c596c 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -32,7 +32,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRenderi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* @@ -115,7 +115,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.TestListenerCom01AWT REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.newt.event.TestNewtEventModifiersNEWTWindowAWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bdc67a5fa..26b70cbd0 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -366,7 +366,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -567,7 +567,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 $* #testawt com.jogamp.opengl.test.junit.newt.TestEventSourceNotAWTBug #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventOrderAWT $* -testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* +#testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyEventAutoRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyPressReleaseUnmaskRepeatAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodesAWT $* #testawt com.jogamp.opengl.test.junit.newt.event.TestNewtKeyCodeModifiersAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 36c0144a9..0bc002f8e 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -858,7 +858,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing GLDrawableUtil.swapGLContextAndAllGLEventListener(GLCanvas.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } - printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); + printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 8670c3746..a71b47c64 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -649,7 +649,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing GLDrawableUtil.swapGLContextAndAllGLEventListener(GLJPanel.this, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } - printAWTTiles.setIsGLOriented( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented() ); + printAWTTiles.setGLOrientation( !GLJPanel.this.skipGLOrientationVerticalFlip && printGLAD.isGLOriented(), printGLAD.isGLOriented() ); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { diff --git a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java index ff07b04d0..1c1d2350a 100644 --- a/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java +++ b/src/jogl/classes/jogamp/opengl/awt/AWTTilePainter.java @@ -74,7 +74,10 @@ public class AWTTilePainter { public final int customTileWidth, customTileHeight, customNumSamples; public final boolean verbose; + /** Default for OpenGL: True */ public boolean flipVertical; + /** Default for OpenGL: True */ + public boolean originBottomLeft; private AWTGLPixelBuffer tBuffer = null; private BufferedImage vFlipImage = null; private Graphics2D g2d = null; @@ -148,10 +151,18 @@ public class AWTTilePainter { } @Override - public String toString() { return renderer.toString(); } + public String toString() { + return "AWTTilePainter[flipVertical "+flipVertical+", startFromBottom "+originBottomLeft+", "+ + renderer.toString()+"]"; + } - public void setIsGLOriented(boolean v) { - flipVertical = v; + /** + * @param flipVertical if true, the image will be flipped vertically (Default for OpenGL). + * @param originBottomLeft if true, the image's origin is on the bottom left (Default for OpenGL). + */ + public void setGLOrientation(boolean flipVertical, boolean originBottomLeft) { + this.flipVertical = flipVertical; + this.originBottomLeft = originBottomLeft; } private static Rectangle2D getClipBounds2D(Graphics2D g) { @@ -307,7 +318,7 @@ public class AWTTilePainter { final int tHeight = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_HEIGHT); final int tY = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_Y_POS); final int tYOff = renderer.getParam(TileRenderer.TR_TILE_Y_OFFSET); - final int imgYOff = flipVertical ? 0 : renderer.getParam(TileRenderer.TR_TILE_HEIGHT) - tHeight; // imgYOff will be cut-off via sub-image + final int imgYOff = originBottomLeft ? 0 : renderer.getParam(TileRenderer.TR_TILE_HEIGHT) - tHeight; // imgYOff will be cut-off via sub-image final int pX = renderer.getParam(TileRendererBase.TR_CURRENT_TILE_X_POS); // tileX == pX final int pY = cis.getHeight() - ( tY - tYOff + tHeight ) + scaledYOffset; @@ -380,7 +391,7 @@ public class AWTTilePainter { System.err.println("XXX tile-post.X "+renderer); System.err.println("XXX tile-post.X dst-img "+dstImage.getWidth()+"x"+dstImage.getHeight()); System.err.println("XXX tile-post.X out-img "+outImage.getWidth()+"x"+outImage.getHeight()); - System.err.println("XXX tile-post.X y-flip "+flipVertical+" -> "+pX+"/"+pY+", drawDone "+drawDone); + System.err.println("XXX tile-post.X y-flip "+flipVertical+", originBottomLeft "+originBottomLeft+" -> "+pX+"/"+pY+", drawDone "+drawDone); } } @Override diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index b6b8cf9e8..d0ec8ae36 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -673,7 +673,7 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto GLDrawableUtil.swapGLContextAndAllGLEventListener(glad, printGLAD); printDrawable = printGLAD.getDelegatedDrawable(); } - printAWTTiles.setIsGLOriented(printGLAD.isGLOriented()); + printAWTTiles.setGLOrientation(printGLAD.isGLOriented(), printGLAD.isGLOriented()); printAWTTiles.renderer.setTileSize(printDrawable.getWidth(), printDrawable.getHeight(), 0); printAWTTiles.renderer.attachAutoDrawable(printGLAD); if( DEBUG ) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java index e0d0e00dc..3dd3a83c8 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT.java @@ -100,11 +100,12 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { public static void releaseClass() { } - protected void runTestGL(GLCapabilities caps, boolean layered) throws InterruptedException, InvocationTargetException { + protected void runTestGL(GLCapabilities caps, boolean layered, boolean skipGLOrientationVerticalFlip) throws InterruptedException, InvocationTargetException { final int layerStepX = width/6, layerStepY = height/6; final Dimension glc_sz = new Dimension(layered ? width - 2*layerStepX : width/2, layered ? height - 2*layerStepY : height); final GLJPanel glJPanel1 = new GLJPanel(caps); Assert.assertNotNull(glJPanel1); + glJPanel1.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); glJPanel1.setMinimumSize(glc_sz); glJPanel1.setPreferredSize(glc_sz); if( layered ) { @@ -112,10 +113,15 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { } else { glJPanel1.setBounds(0, 0, glc_sz.width, glc_sz.height); } - glJPanel1.addGLEventListener(new Gears()); + { + final Gears demo = new Gears(); + demo.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + glJPanel1.addGLEventListener(demo); + } final GLJPanel glJPanel2 = new GLJPanel(caps); Assert.assertNotNull(glJPanel2); + glJPanel2.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); glJPanel2.setMinimumSize(glc_sz); glJPanel2.setPreferredSize(glc_sz); if( layered ) { @@ -123,8 +129,11 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { } else { glJPanel2.setBounds(0, 0, glc_sz.width, glc_sz.height); } - glJPanel2.addGLEventListener(new RedSquareES1()); - // glJPanel2.addGLEventListener(new Gears()); + { + final RedSquareES1 demo = new RedSquareES1(); + demo.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + glJPanel2.addGLEventListener(demo); + } final JComponent demoPanel; if( layered ) { @@ -293,43 +302,83 @@ public class TestTiledPrintingGearsSwingAWT extends TiledPrintingAWTBase { } @Test - public void test01_aa0() throws InterruptedException, InvocationTargetException { + public void test01_flip1_aa0() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, false, false); + } + + @Test + public void test01_flip1_aa0_layered() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + caps.setAlphaBits(8); + runTestGL(caps, true, false); + } + + @Test + public void test01_flip1_aa0_bitmap() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS == Platform.getOSType() ) { + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, false, false); + } // issues w/ AMD catalyst driver and pixmap surface .. + } + + @Test + public void test01_flip1_aa0_bitmap_layered() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS == Platform.getOSType() ) { + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + caps.setAlphaBits(8); + runTestGL(caps, true, false); + } // issues w/ AMD catalyst driver and pixmap surface .. + } + + @Test + public void test02_flip1_aa8() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + caps.setSampleBuffers(true); + caps.setNumSamples(8); + runTestGL(caps, false, false); + } + + @Test + public void test11_flip0_aa0() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, false); + runTestGL(caps, false, true); } @Test - public void test01_aa0_layered() throws InterruptedException, InvocationTargetException { + public void test11_flip0_aa0_layered() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); caps.setAlphaBits(8); - runTestGL(caps, true); + runTestGL(caps, true, true); } @Test - public void test01_aa0_bitmap() throws InterruptedException, InvocationTargetException { + public void test11_flip0_aa0_bitmap() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS == Platform.getOSType() ) { GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, false); + runTestGL(caps, false, true); } // issues w/ AMD catalyst driver and pixmap surface .. } @Test - public void test01_aa0_bitmap_layered() throws InterruptedException, InvocationTargetException { + public void test11_flip0_aa0_bitmap_layered() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS == Platform.getOSType() ) { GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); caps.setAlphaBits(8); - runTestGL(caps, true); + runTestGL(caps, true, true); } // issues w/ AMD catalyst driver and pixmap surface .. } @Test - public void test02_aa8() throws InterruptedException, InvocationTargetException { + public void test12_flip0_aa8() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); caps.setSampleBuffers(true); caps.setNumSamples(8); - runTestGL(caps, false); + runTestGL(caps, false, true); } static long duration = 500; // ms diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java index 2d4973d6b..29bf8a6c3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/tile/TestTiledPrintingGearsSwingAWT2.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.tile; import java.awt.BorderLayout; @@ -77,7 +77,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { static boolean waitForKey = false; static GLProfile glp; static int width, height; - + @BeforeClass public static void initClass() { if(GLProfile.isAvailable(GLProfile.GL2)) { @@ -95,16 +95,21 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { @AfterClass public static void releaseClass() { } - - protected void runTestGL(GLCapabilities caps, final boolean addLayout, boolean layered, boolean useAnim) throws InterruptedException, InvocationTargetException { + + protected void runTestGL(GLCapabilities caps, final boolean addLayout, boolean layered, boolean skipGLOrientationVerticalFlip, boolean useAnim) throws InterruptedException, InvocationTargetException { final Dimension glc_sz = new Dimension(width, height); final GLJPanel glJPanel1 = new GLJPanel(caps); - Assert.assertNotNull(glJPanel1); + Assert.assertNotNull(glJPanel1); + glJPanel1.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); glJPanel1.setMinimumSize(glc_sz); glJPanel1.setPreferredSize(glc_sz); glJPanel1.setBounds(0, 0, glc_sz.width, glc_sz.height); - glJPanel1.addGLEventListener(new Gears()); - + { + final Gears demo = new Gears(); + demo.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + glJPanel1.addGLEventListener(demo); + } + final JComponent tPanel, demoPanel; if( layered ) { glJPanel1.setOpaque(true); @@ -133,13 +138,13 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { demoPanel = new JPanel(); demoPanel.add(glJPanel1); } else { - demoPanel = glJPanel1; + demoPanel = glJPanel1; } } - + final JFrame frame = new JFrame("Swing Print"); Assert.assertNotNull(frame); - + final ActionListener print72DPIAction = new ActionListener() { public void actionPerformed(ActionEvent e) { doPrintManual(frame, 72, 0, -1, -1); @@ -158,7 +163,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { print150DPIButton.addActionListener(print150DPIAction); final Button print300DPIButton = new Button("300dpi"); print300DPIButton.addActionListener(print300DPIAction); - + final JPanel printPanel = new JPanel(); printPanel.add(print72DPIButton); printPanel.add(print150DPIButton); @@ -169,7 +174,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { eastPanel.add(new Label("East")); final JPanel westPanel = new JPanel(); westPanel.add(new Label("West")); - + final Animator animator = useAnim ? new Animator() : null; if( null != animator ) { animator.add(glJPanel1); @@ -181,7 +186,7 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { SwingUtilities.invokeAndWait(new Runnable() { public void run() { - final Container fcont = frame.getContentPane(); + final Container fcont = frame.getContentPane(); if( addLayout ) { fcont.setLayout(new BorderLayout()); fcont.add(printPanel, BorderLayout.NORTH); @@ -201,12 +206,12 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { } frame.setVisible(true); } } ) ; - + Assert.assertEquals(true, AWTRobotUtil.waitForVisible(frame, true)); Assert.assertEquals(true, AWTRobotUtil.waitForRealized(glJPanel1, true)); - + if( null != animator ) { - animator.setUpdateFPSFrames(60, System.err); + animator.setUpdateFPSFrames(60, System.err); animator.start(); Assert.assertEquals(true, animator.isAnimating()); } @@ -226,11 +231,11 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { } t1 = System.currentTimeMillis(); } - + Assert.assertNotNull(frame); Assert.assertNotNull(glJPanel1); - if( null != animator ) { + if( null != animator ) { animator.stop(); Assert.assertEquals(false, animator.isAnimating()); } @@ -248,69 +253,133 @@ public class TestTiledPrintingGearsSwingAWT2 extends TiledPrintingAWTBase { } @Test - public void test01_norm_layout0_layered0() throws InterruptedException, InvocationTargetException { + public void test001_flip1_norm_layout0_layered0() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, false /* addLayout */, false /* layered */, false /* useAnim */); + runTestGL(caps, false /* addLayout */, false /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test02_norm_layout1_layered0() throws InterruptedException, InvocationTargetException { + public void test002_flip1_norm_layout1_layered0() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, true /* addLayout */, false /* layered */, false /* useAnim */); + runTestGL(caps, true /* addLayout */, false /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test03_norm_layout0_layered1() throws InterruptedException, InvocationTargetException { + public void test003_flip1_norm_layout0_layered1() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, false /* addLayout */, true /* layered */, false /* useAnim */); + runTestGL(caps, false /* addLayout */, true /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test04_norm_layout1_layered1() throws InterruptedException, InvocationTargetException { + public void test004_flip1_norm_layout1_layered1() throws InterruptedException, InvocationTargetException { GLCapabilities caps = new GLCapabilities(glp); - runTestGL(caps, true /* addLayout */, true /* layered */, false /* useAnim */); + runTestGL(caps, true /* addLayout */, true /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test11_bitm_layout0_layered0() throws InterruptedException, InvocationTargetException { + public void test011_flip1_bitm_layout0_layered0() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS != Platform.getOSType() ) { return; } GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, false /* addLayout */, false /* layered */, false /* useAnim */); + runTestGL(caps, false /* addLayout */, false /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test12_bitm_layout1_layered0() throws InterruptedException, InvocationTargetException { + public void test012_flip1_bitm_layout1_layered0() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS != Platform.getOSType() ) { return; } GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, true /* addLayout */, false /* layered */, false /* useAnim */); + runTestGL(caps, true /* addLayout */, false /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test13_bitm_layout0_layered1() throws InterruptedException, InvocationTargetException { + public void test013_flip1_bitm_layout0_layered1() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS != Platform.getOSType() ) { return; } GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, false /* addLayout */, true /* layered */, false /* useAnim */); + runTestGL(caps, false /* addLayout */, true /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + @Test - public void test14_bitm_layout1_layered1() throws InterruptedException, InvocationTargetException { + public void test014_flip1_bitm_layout1_layered1() throws InterruptedException, InvocationTargetException { if( Platform.OSType.WINDOWS != Platform.getOSType() ) { return; } GLCapabilities caps = new GLCapabilities(glp); caps.setBitmap(true); - runTestGL(caps, true /* addLayout */, true /* layered */, false /* useAnim */); + runTestGL(caps, true /* addLayout */, true /* layered */, false /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test101_flip1_norm_layout0_layered0() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, false /* addLayout */, false /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test102_flip1_norm_layout1_layered0() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, true /* addLayout */, false /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test103_flip1_norm_layout0_layered1() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, false /* addLayout */, true /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); } - + + @Test + public void test104_flip1_norm_layout1_layered1() throws InterruptedException, InvocationTargetException { + GLCapabilities caps = new GLCapabilities(glp); + runTestGL(caps, true /* addLayout */, true /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test111_flip1_bitm_layout0_layered0() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS != Platform.getOSType() ) { + return; + } + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, false /* addLayout */, false /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test112_flip1_bitm_layout1_layered0() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS != Platform.getOSType() ) { + return; + } + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, true /* addLayout */, false /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test113_flip1_bitm_layout0_layered1() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS != Platform.getOSType() ) { + return; + } + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, false /* addLayout */, true /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + + @Test + public void test114_flip1_bitm_layout1_layered1() throws InterruptedException, InvocationTargetException { + if( Platform.OSType.WINDOWS != Platform.getOSType() ) { + return; + } + GLCapabilities caps = new GLCapabilities(glp); + caps.setBitmap(true); + runTestGL(caps, true /* addLayout */, true /* layered */, true /* skipGLOrientationVerticalFlip */, false /* useAnim */); + } + static long duration = 500; // ms public static void main(String args[]) { -- cgit v1.2.3 From 085d7bf429f5640eb540dff4e66f25b69e2c7671 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 10 Dec 2013 22:05:17 +0100 Subject: TestShutdownCompleteNEWT: Enhance profiling via '-wait -initOnly' ; Use Platform.currentTimeMicros() for accuracy ReflectionUtil usage: TestShutdownCompleteNEWT -wait -initOnly Hotspots: - MakeCurrent 5.3% - Called 52 times - ClassLoader.findClass(..) 3.1% - Called 486 times . - ReflectionUtil: 13 times ~ 0.3% --- make/scripts/tests.sh | 4 +- .../junit/jogl/acore/TestShutdownCompleteNEWT.java | 72 +++++++++++----------- 2 files changed, 37 insertions(+), 39 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 26b70cbd0..fe09a427b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -366,7 +366,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT $* #testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT $* @@ -384,7 +384,7 @@ testawt com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java index 881d6c8de..a0e7f515c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteNEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,26 +20,26 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +import com.jogamp.common.os.Platform; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; @@ -50,12 +50,12 @@ import com.jogamp.opengl.util.Animator; public class TestShutdownCompleteNEWT extends UITestCase { static long duration = 300; // ms - + protected void runTestGL(boolean onscreen) throws InterruptedException { GLCapabilities caps = new GLCapabilities(GLProfile.getGL2ES2()); caps.setOnscreen(onscreen); caps.setPBuffer(!onscreen); - + GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("Gears NEWT Test"); @@ -81,29 +81,36 @@ public class TestShutdownCompleteNEWT extends UITestCase { glWindow.destroy(); } + @AfterClass + public static void afterAll() { + if(waitForKey) { + UITestCase.waitForKey("Exit"); + } + } + protected void oneLife(boolean glInfo) throws InterruptedException { if(waitForEach) { - waitForEnter(); + UITestCase.waitForKey("Start One Life"); } - long t0 = System.nanoTime(); + long t0 = Platform.currentTimeMicros(); GLProfile.initSingleton(); - long t1 = System.nanoTime(); + long t1 = Platform.currentTimeMicros(); if(!initOnly) { runTestGL(true); } - long t2 = System.nanoTime(); + long t2 = Platform.currentTimeMicros(); if(glInfo) { System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false).toString()); } - long t3 = System.nanoTime(); - GLProfile.shutdown(); - long t4 = System.nanoTime(); - System.err.println("Total: "+ (t3-t0)/1e6 +"ms"); - System.err.println(" GLProfile.initSingleton(): "+ (t1-t0)/1e6 +"ms"); - System.err.println(" Demo Code: "+ (t2-t1)/1e6 +"ms"); - System.err.println(" GLProfile.shutdown(): "+ (t4-t3)/1e6 +"ms"); + long t3 = Platform.currentTimeMicros(); + GLProfile.shutdown(); + long t4 = Platform.currentTimeMicros(); + System.err.println("Total: "+ (t3-t0)/1e3 +"ms"); + System.err.println(" GLProfile.initSingleton(): "+ (t1-t0)/1e3 +"ms"); + System.err.println(" Demo Code: "+ (t2-t1)/1e3 +"ms"); + System.err.println(" GLProfile.shutdown(): "+ (t4-t3)/1e3 +"ms"); } - + @Test public void test01OneLife() throws InterruptedException { oneLife(true); @@ -113,27 +120,18 @@ public class TestShutdownCompleteNEWT extends UITestCase { public void test01AnotherLife() throws InterruptedException { oneLife(false); } - + @Test public void test01TwoLifes() throws InterruptedException { oneLife(false); oneLife(false); } - + static boolean initOnly = false; static boolean waitForEach = false; - - static void waitForEnter() { - BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); - System.err.println("Press enter to continue"); - try { - System.err.println(stdin.readLine()); - } catch (IOException e) { } - } - + static boolean waitForKey = false; + public static void main(String args[]) throws IOException { - boolean waitForKey = false; - for(int i=0; i Date: Tue, 10 Dec 2013 22:53:11 +0100 Subject: TestShutdownCompleteNEWT/AWT: Align both tests and account for GLInfo. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- .../junit/jogl/acore/TestShutdownCompleteAWT.java | 92 +++++++++++++++------- .../junit/jogl/acore/TestShutdownCompleteNEWT.java | 24 +++--- 4 files changed, 83 insertions(+), 41 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 6d79c596c..f5417bf7a 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -32,14 +32,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledRenderi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering2GL2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestRandomTiledRendering3GL2AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsAWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsSwingAWT2 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingGearsNewtAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index fe09a427b..6cf493de2 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -384,7 +384,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* @@ -414,7 +414,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java index 4e2e91320..9f367ef0b 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestShutdownCompleteAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.awt.Frame; @@ -36,11 +36,14 @@ import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLProfile; import javax.media.opengl.awt.GLCanvas; +import org.junit.AfterClass; import org.junit.Assert; import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; +import com.jogamp.common.os.Platform; +import com.jogamp.opengl.JoglVersion; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; @@ -49,7 +52,7 @@ import com.jogamp.opengl.util.Animator; public class TestShutdownCompleteAWT extends UITestCase { static long duration = 300; // ms - + protected void runTestGL() throws InterruptedException, InvocationTargetException { final Frame frame = new Frame("Gears AWT Test"); Assert.assertNotNull(frame); @@ -67,8 +70,8 @@ public class TestShutdownCompleteAWT extends UITestCase { frame.setSize(256, 256); frame.setVisible(true); }}); - - animator.setUpdateFPSFrames(60, System.err); + + animator.setUpdateFPSFrames(60, System.err); animator.start(); Assert.assertEquals(true, animator.isAnimating()); Assert.assertEquals(true, glCanvas.isVisible()); @@ -93,37 +96,70 @@ public class TestShutdownCompleteAWT extends UITestCase { }}); } - protected void oneLife() throws InterruptedException, InvocationTargetException { - long t0 = System.nanoTime(); + @AfterClass + public static void afterAll() { + if(waitForKey) { + UITestCase.waitForKey("Exit"); + } + } + + protected void oneLife(boolean glInfo) throws InterruptedException, InvocationTargetException { + final long t0 = Platform.currentTimeMicros(); GLProfile.initSingleton(); - long t1 = System.nanoTime(); - runTestGL(); - long t2 = System.nanoTime(); - GLProfile.shutdown(); - long t3 = System.nanoTime(); - System.err.println("Total: "+ (t3-t0)/1e6 +"ms"); - System.err.println(" GLProfile.initSingleton(): "+ (t1-t0)/1e6 +"ms"); - System.err.println(" Demo Code: "+ (t2-t1)/1e6 +"ms"); - System.err.println(" GLProfile.shutdown(): "+ (t3-t2)/1e6 +"ms"); + final long t1 = Platform.currentTimeMicros(); + if(!initOnly) { + runTestGL(); + } + final long t2 = Platform.currentTimeMicros(); + if(glInfo) { + System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, false).toString()); + } + final long t3 = Platform.currentTimeMicros(); + GLProfile.shutdown(); + final long t4 = Platform.currentTimeMicros(); + System.err.println("Total: "+ (t4-t0)/1e3 +"ms"); + System.err.println(" GLProfile.initSingleton(): "+ (t1-t0)/1e3 +"ms"); + System.err.println(" Demo Code: "+ (t2-t1)/1e3 +"ms"); + System.err.println(" GLInfo: "+ (t3-t2)/1e3 +"ms"); + System.err.println(" GLProfile.shutdown(): "+ (t4-t3)/1e3 +"ms"); } - + @Test public void test01OneLife() throws InterruptedException, InvocationTargetException { - oneLife(); + oneLife(false); + } + + @Test + public void test02AnotherLifeWithGLInfo() throws InterruptedException, InvocationTargetException { + oneLife(true); } @Test - public void test01AnotherLife() throws InterruptedException, InvocationTargetException { - oneLife(); + public void test03AnotherLife() throws InterruptedException, InvocationTargetException { + oneLife(true); } - + @Test - public void test01TwoLifes() throws InterruptedException, InvocationTargetException { - oneLife(); - oneLife(); + public void test03TwoLifes() throws InterruptedException, InvocationTargetException { + oneLife(false); + oneLife(false); } - + + static boolean initOnly = false; + static boolean waitForKey = false; + public static void main(String args[]) throws IOException { + for(int i=0; i Date: Wed, 11 Dec 2013 05:23:31 +0100 Subject: Bug 922 (1/2): NEWT Window.reparentWindow(..): Provide REPARENT_HINT_BECOMES_VISIBLE hint via new method variant using hints; Deprecate other reparentWindow(..) variants w/o hints. NEWT Window.reparentWindow(..): Provide REPARENT_HINT_BECOMES_VISIBLE hint via new method variant using hints: - Add REPARENT_HINT_FORCE_RECREATION, covering 'old' forceDestroyCreate boolean argument - Add REPARENT_HINT_BECOMES_VISIBLE, Claim window becomes visible after reparenting, which is important for e.g. preserving the GL-states in case window is invisible while reparenting. Deprecate other reparentWindow(..) variants w/o hints. Use only new variant using hints w/o semantical change. --- make/scripts/tests.sh | 6 +- src/newt/classes/com/jogamp/newt/Window.java | 25 +++++++- .../classes/com/jogamp/newt/opengl/GLWindow.java | 5 ++ src/newt/classes/jogamp/newt/WindowImpl.java | 55 ++++++++++++------ .../parenting/NewtAWTReparentingKeyAdapter.java | 28 ++++----- .../junit/newt/parenting/TestParenting01NEWT.java | 64 +++++++++++---------- .../junit/newt/parenting/TestParenting01aAWT.java | 66 +++++++++------------- .../junit/newt/parenting/TestParenting01bAWT.java | 30 +++++----- .../junit/newt/parenting/TestParenting01cAWT.java | 4 +- .../newt/parenting/TestParenting01cSwingAWT.java | 4 +- .../junit/newt/parenting/TestParenting02AWT.java | 24 ++++---- .../junit/newt/parenting/TestParenting02NEWT.java | 20 +++---- .../junit/newt/parenting/TestParenting03AWT.java | 30 +++++----- .../junit/newt/parenting/TestParenting04AWT.java | 4 +- .../junit/newt/parenting/TestParenting04SWT.java | 4 +- 15 files changed, 206 insertions(+), 163 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6cf493de2..9b7d43453 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -147,10 +147,8 @@ function jrun() { #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" - #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" - #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.test.Screen.disableRandR13" @@ -163,7 +161,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" @@ -414,7 +411,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOAutoDrawableDeadlockAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestPBufferDeadlockAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.x11.TestGLXCallsOnAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestFBOOffThreadSharedContextMix2DemosES2NEWT $* @@ -611,6 +608,7 @@ testawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 869b56331..5c3bb7889 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -353,6 +353,11 @@ public interface Window extends NativeWindow, WindowClosingProtocol { ACTION_NATIVE_CREATION_PENDING; } + /** Reparenting hint (bitfield value): Force destroy and hence {@link ReparentOperation#ACTION_NATIVE_CREATION re-creating} the window. */ + public static final int REPARENT_HINT_FORCE_RECREATION = 1 << 0; + /** Reparenting hint (bitfield value): Claim window becomes visible after reparenting, which is important for e.g. preserving the GL-states in case window is invisible while reparenting. */ + public static final int REPARENT_HINT_BECOMES_VISIBLE = 1 << 1; + /** * Change this window's parent window.
        *

        @@ -365,6 +370,7 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * * @return The issued reparent action type (strategy) as defined in Window.ReparentAction * @see #reparentWindow(NativeWindow, int, int, boolean) + * @deprecated Use {@link #reparentWindow(NativeWindow, int, int, int)} */ ReparentOperation reparentWindow(NativeWindow newParent); @@ -382,10 +388,27 @@ public interface Window extends NativeWindow, WindowClosingProtocol { * @param forceDestroyCreate if true, uses re-creation strategy for reparenting, default is false. * * @return The issued reparent action type (strategy) as defined in Window.ReparentAction - * @see #reparentWindow(NativeWindow) + * @deprecated Use {@link #reparentWindow(NativeWindow, int, int, int)} */ ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate); + /** + * Change this window's parent window.
        + *

        + * In case the old parent is not null and a Window, + * this window is removed from it's list of children.
        + * In case the new parent is not null and a Window, + * this window is added to it's list of children.

        + * + * @param newParent The new parent NativeWindow. If null, this Window becomes a top level window. + * @param x new top-level position, use -1 for default position. + * @param y new top-level position, use -1 for default position. + * @param hints May contain hints (bitfield values) like {@link #REPARENT_HINT_FORCE_RECREATION} or {@link #REPARENT_HINT_BECOMES_VISIBLE}. + * + * @return The issued reparent action type (strategy) as defined in Window.ReparentAction + */ + ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints); + /** * Enable or disable fullscreen mode for this window. *

        diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 52f19f783..208602aa1 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -396,6 +396,11 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind return window.reparentWindow(newParent, x, y, forceDestroyCreate); } + @Override + public final ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints) { + return window.reparentWindow(newParent, x, y, hints); + } + @Override public final boolean removeChild(NativeWindow win) { return window.removeChild(win); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 21343b263..ae4cb9924 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1186,14 +1186,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private class ReparentAction implements Runnable { final NativeWindow newParentWindow; final int topLevelX, topLevelY; - boolean forceDestroyCreate; + final int hints; ReparentOperation operation; - private ReparentAction(NativeWindow newParentWindow, int topLevelX, int topLevelY, boolean forceDestroyCreate) { + private ReparentAction(NativeWindow newParentWindow, int topLevelX, int topLevelY, int hints) { this.newParentWindow = newParentWindow; this.topLevelX = topLevelX; this.topLevelY = topLevelY; - this.forceDestroyCreate = forceDestroyCreate | DEBUG_TEST_REPARENT_INCOMPATIBLE; + if( DEBUG_TEST_REPARENT_INCOMPATIBLE ) { + hints |= REPARENT_HINT_FORCE_RECREATION; + } + this.hints = hints; this.operation = ReparentOperation.ACTION_INVALID; // ensure it's set } @@ -1227,17 +1230,25 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final int x, y; int width = oldWidth; int height = oldHeight; - boolean wasVisible; + + final boolean wasVisible; + final boolean becomesVisible; + final boolean forceDestroyCreate; final RecursiveLock _lock = windowLock; _lock.lock(); try { - if(isNativeValid()) { - // force recreation if offscreen, since it may become onscreen - forceDestroyCreate |= isOffscreenInstance(WindowImpl.this, newParentWindow); + { + boolean v = 0 != ( REPARENT_HINT_FORCE_RECREATION & hints ); + if(isNativeValid()) { + // force recreation if offscreen, since it may become onscreen + v |= isOffscreenInstance(WindowImpl.this, newParentWindow); + } + forceDestroyCreate = v; } wasVisible = isVisible(); + becomesVisible = wasVisible || 0 != ( REPARENT_HINT_BECOMES_VISIBLE & hints ); Window newParentWindowNEWT = null; if(newParentWindow instanceof Window) { @@ -1246,8 +1257,15 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer long newParentWindowHandle = 0 ; - if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+", visible "+wasVisible+", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow)+", forceDestroyCreate "+forceDestroyCreate); + if( DEBUG_IMPLEMENTATION) { + System.err.println("Window.reparent: START ("+getThreadName()+") valid "+isNativeValid()+ + ", windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+ + ", visible "+wasVisible+", becomesVisible "+becomesVisible+ + ", forceDestroyCreate "+forceDestroyCreate+ + ", HINT_FORCE_RECREATION "+( 0 != ( REPARENT_HINT_FORCE_RECREATION & hints ) )+ + ", HINT_BECOMES_VISIBLE "+( 0 != ( REPARENT_HINT_BECOMES_VISIBLE & hints ) ) + + ", old parentWindow: "+Display.hashCodeNullSafe(parentWindow)+ + ", new parentWindow: "+Display.hashCodeNullSafe(newParentWindow) ); } if(null!=newParentWindow) { @@ -1274,7 +1292,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } // Destroy this window and use parent's Screen. // It may be created properly when the parent is made visible. - destroy( false ); + destroy( becomesVisible ); setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); operation = ReparentOperation.ACTION_NATIVE_CREATION_PENDING; } else if(newParentWindow != getParent()) { @@ -1298,7 +1316,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } else if ( forceDestroyCreate || !NewtFactory.isScreenCompatible(newParentWindow, screen) ) { // Destroy this window, may create a new compatible Screen/Display, while trying to preserve resources if becoming visible again. - destroy( wasVisible ); + destroy( becomesVisible ); if(null!=newParentWindowNEWT) { setScreen( (ScreenImpl) newParentWindowNEWT.getScreen() ); } else { @@ -1336,7 +1354,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } else if( !isNativeValid() || forceDestroyCreate ) { // Destroy this window and mark it for [pending] creation. // If isNativeValid() and becoming visible again - try to preserve resources, i.e. b/c on-/offscreen switch. - destroy( isNativeValid() && wasVisible ); + destroy( becomesVisible ); if( 0 < width && 0 < height ) { operation = ReparentOperation.ACTION_NATIVE_CREATION; } else { @@ -1437,7 +1455,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer if(DEBUG_IMPLEMENTATION) { System.err.println("Window.reparent: native reparenting failed ("+getThreadName()+") windowHandle "+toHexString(windowHandle)+" parentWindowHandle "+toHexString(parentWindowHandle)+" -> "+toHexString(newParentWindowHandle)+" - Trying recreation"); } - destroy( wasVisible ); + destroy( becomesVisible ); operation = ReparentOperation.ACTION_NATIVE_CREATION ; } } else { @@ -1500,12 +1518,17 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final ReparentOperation reparentWindow(NativeWindow newParent) { - return reparentWindow(newParent, -1, -1, false); + return reparentWindow(newParent, -1, -1, 0); } @Override public ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate) { - final ReparentAction reparentAction = new ReparentAction(newParent, x, y, forceDestroyCreate); + return reparentWindow(newParent, x, y, forceDestroyCreate ? REPARENT_HINT_FORCE_RECREATION : 0); + } + + @Override + public ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints) { + final ReparentAction reparentAction = new ReparentAction(newParent, x, y, hints); runOnEDTIfAvail(true, reparentAction); return reparentAction.getOp(); } @@ -2161,7 +2184,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer fullscreenMonitors = monitors; fullscreenUseMainMonitor = useMainMonitor; if( fullScreenAction.init(fullscreen) ) { - if(fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow)) { + if( fullScreenAction.fsOn() && isOffscreenInstance(WindowImpl.this, parentWindow) ) { // enable fullscreen on offscreen instance if(null != parentWindow) { nfs_parent = parentWindow; diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 4bf1f95c3..f7fbc7332 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -42,24 +42,24 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final NewtCanvasAWT newtCanvasAWT; final GLWindow glWindow; final QuitAdapter quitAdapter; - + public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) { this.frame = frame; this.newtCanvasAWT = newtCanvasAWT; this.glWindow = glWindow; this.quitAdapter = quitAdapter; } - + public void keyReleased(KeyEvent e) { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; - } + } if( e.getKeySymbol() == KeyEvent.VK_I ) { System.err.println(glWindow); } else if( e.getKeySymbol() == KeyEvent.VK_L ) { javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null); javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null); - System.err.println("NewtCanvasAWT position: "+p0+", "+p1); + System.err.println("NewtCanvasAWT position: "+p0+", "+p1); } else if( e.getKeySymbol() == KeyEvent.VK_D ) { glWindow.setUndecorated(!glWindow.isUndecorated()); } else if( e.getKeySymbol() == KeyEvent.VK_S ) { @@ -68,7 +68,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { glWindow.setPosition(100, 100); } else { System.err.println("XXX glWin to 0/0"); - glWindow.setPosition(0, 0); + glWindow.setPosition(0, 0); } } else if( e.getKeySymbol() == KeyEvent.VK_F ) { if( null != quitAdapter ) { @@ -92,8 +92,8 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { if(glWindow.getAnimator().isPaused()) { glWindow.getAnimator().resume(); } else { - glWindow.getAnimator().pause(); - } + glWindow.getAnimator().pause(); + } } }.run(); } else if( e.getKeySymbol() == KeyEvent.VK_R ) { @@ -105,7 +105,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final Thread t = glWindow.setExclusiveContextThread(null); if(glWindow.getParent()==null) { System.err.println("XXX glWin to HOME"); - glWindow.reparentWindow(newtCanvasAWT.getNativeWindow()); + glWindow.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, 0 /* hints */); } else { if( null != frame ) { final InsetsImmutable nInsets = glWindow.getInsets(); @@ -121,10 +121,10 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final int topLevelX = frame.getX()+frame.getWidth()+dx; final int topLevelY = frame.getY()+dy; System.err.println("XXX glWin to TOP.1 "+topLevelX+"/"+topLevelY+" - insets " + nInsets + ", " + aInsets); - glWindow.reparentWindow(null, topLevelX, topLevelY, false); + glWindow.reparentWindow(null, topLevelX, topLevelY, 0 /* hint */); } else { System.err.println("XXX glWin to TOP.0"); - glWindow.reparentWindow(null); + glWindow.reparentWindow(null, -1, -1, 0 /* hints */); } } glWindow.requestFocus(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java index 1f19241d8..7beceb291 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; @@ -62,7 +62,7 @@ public class TestParenting01NEWT extends UITestCase { } @Test - public void testWindowParenting01CreateVisibleDestroy() throws InterruptedException { + public void test01CreateVisibleDestroy() throws InterruptedException { Assert.assertEquals(0,Display.getActiveDisplayNumber()); Display display = null; Screen screen = null; @@ -82,7 +82,7 @@ public class TestParenting01NEWT extends UITestCase { Assert.assertEquals(false,screen.isNativeValid()); Assert.assertEquals(0,Display.getActiveDisplayNumber()); - glWindow1.setTitle("testWindowParenting01CreateVisibleDestroy"); + glWindow1.setTitle("test01CreateVisibleDestroy"); glWindow1.setSize(640, 480); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, glWindow1, false); @@ -151,13 +151,13 @@ public class TestParenting01NEWT extends UITestCase { glWindow1.resetFPSCounter(); glWindow2.resetFPSCounter(); Animator animator1 = new Animator(glWindow1); - animator1.setUpdateFPSFrames(1, null); + animator1.setUpdateFPSFrames(1, null); animator1.start(); Assert.assertEquals(true, animator1.isAnimating()); Assert.assertEquals(false, animator1.isPaused()); Assert.assertNotNull(animator1.getThread()); Animator animator2 = new Animator(glWindow2); - animator2.setUpdateFPSFrames(1, null); + animator2.setUpdateFPSFrames(1, null); animator2.start(); Assert.assertEquals(true, animator2.isAnimating()); Assert.assertEquals(false, animator2.isPaused()); @@ -286,25 +286,27 @@ public class TestParenting01NEWT extends UITestCase { } @Test - public void testWindowParenting02ReparentTop2WinReparentRecreate() throws InterruptedException { - testWindowParenting02ReparentTop2WinImpl(true); + public void test02aReparentTop2WinReparentRecreate() throws InterruptedException { + test02ReparentTop2WinImpl(true); } @Test - public void testWindowParenting02ReparentTop2WinReparentNative() throws InterruptedException { - testWindowParenting02ReparentTop2WinImpl(false); + public void test02bReparentTop2WinReparentNative() throws InterruptedException { + test02ReparentTop2WinImpl(false); } /** * @param reparentRecreate true, if the followup reparent should utilize destroy/create, instead of native reparenting */ - protected void testWindowParenting02ReparentTop2WinImpl(boolean reparentRecreate) throws InterruptedException { + protected void test02ReparentTop2WinImpl(final boolean reparentRecreate) throws InterruptedException { + final int reparentHints = reparentRecreate ? Window.REPARENT_HINT_FORCE_RECREATION : 0; + Assert.assertEquals(0,Display.getActiveDisplayNumber()); Display display1 = null; Screen screen1 = null; GLWindow glWindow1 = GLWindow.create(glCaps); - glWindow1.setTitle("testWindowParenting02ReparentTop2Win"); + glWindow1.setTitle("test02ReparentTop2Win"); glWindow1.setSize(640, 480); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, glWindow1, false); @@ -379,7 +381,7 @@ public class TestParenting01NEWT extends UITestCase { // glWindow2 -- child --> glWindow1: compatible Assert.assertEquals(true, glWindow2.isVisible()); System.err.println("Frames(1) "+glWindow2.getTotalFPSFrames()); - reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentHints); System.err.println("Frames(2) "+glWindow2.getTotalFPSFrames()); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); @@ -405,7 +407,7 @@ public class TestParenting01NEWT extends UITestCase { // glWindow2 --> top Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentHints); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); @@ -484,16 +486,18 @@ public class TestParenting01NEWT extends UITestCase { } @Test - public void testWindowParenting03ReparentWin2TopReparentRecreate() throws InterruptedException { - testWindowParenting03ReparentWin2TopImpl(true); + public void test03aReparentWin2TopReparentRecreate() throws InterruptedException { + test03ReparentWin2TopImpl(true); } @Test - public void testWindowParenting03ReparentWin2TopReparentNative() throws InterruptedException { - testWindowParenting03ReparentWin2TopImpl(false); + public void test03bReparentWin2TopReparentNative() throws InterruptedException { + test03ReparentWin2TopImpl(false); } - protected void testWindowParenting03ReparentWin2TopImpl(boolean reparentRecreate) throws InterruptedException { + protected void test03ReparentWin2TopImpl(final boolean reparentRecreate) throws InterruptedException { + final int reparentHints = reparentRecreate ? Window.REPARENT_HINT_FORCE_RECREATION : 0; + Assert.assertEquals(0,Display.getActiveDisplayNumber()); Display display1 = null; Screen screen1 = null; @@ -503,7 +507,7 @@ public class TestParenting01NEWT extends UITestCase { GLWindow glWindow1 = GLWindow.create(glCaps); screen1 = glWindow1.getScreen(); display1 = screen1.getDisplay(); - glWindow1.setTitle("testWindowParenting03ReparentWin2Top"); + glWindow1.setTitle("test03ReparentWin2Top"); glWindow1.setSize(640, 480); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, glWindow1, false); @@ -567,14 +571,14 @@ public class TestParenting01NEWT extends UITestCase { switch(state) { case 0: Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(null, -1, -1, reparentHints); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); Thread.sleep(20*16); // Wait for a few frames since counter could be reset - 20 frames at 60Hz System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B2: "+glWindow2.getTotalFPSFrames()); Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); - + Assert.assertNull(glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); @@ -582,14 +586,14 @@ public class TestParenting01NEWT extends UITestCase { break; case 1: Assert.assertEquals(true, glWindow2.isVisible()); - reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentRecreate); + reparentAction = glWindow2.reparentWindow(glWindow1, -1, -1, reparentHints); Assert.assertTrue(Window.ReparentOperation.ACTION_INVALID != reparentAction); Assert.assertEquals(true, glWindow2.isVisible()); Assert.assertEquals(true, glWindow2.isNativeValid()); Thread.sleep(20*16); // Wait for a few frames since counter could be reset - 20 frames at 60Hz System.err.println("Frames for reparentWindow(parent, "+reparentRecreate+"): "+reparentAction+", B3 "+glWindow2.getTotalFPSFrames()); Assert.assertTrue(0 < glWindow2.getTotalFPSFrames()); - + Assert.assertSame(glWindow1,glWindow2.getParent()); Assert.assertSame(screen1,glWindow2.getScreen()); Assert.assertSame(display1,glWindow2.getScreen().getDisplay()); @@ -657,7 +661,7 @@ public class TestParenting01NEWT extends UITestCase { public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { Assert.assertNotNull(demo); - Assert.assertNotNull(glWindow); + Assert.assertNotNull(glWindow); if(debug) { MiscUtils.setFieldIfExists(demo, "glDebug", true); MiscUtils.setFieldIfExists(demo, "glTrace", true); @@ -689,8 +693,8 @@ public class TestParenting01NEWT extends UITestCase { try { TestParenting01NEWT.initClass(); TestParenting01NEWT m = new TestParenting01NEWT(); - m.testWindowParenting02ReparentTop2WinReparentRecreate(); - m.testWindowParenting01CreateVisibleDestroy(); + m.test02aReparentTop2WinReparentRecreate(); + m.test01CreateVisibleDestroy(); } catch (Throwable t ) { t.printStackTrace(); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java index 6de24d1ea..420a39cb2 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01aAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,7 +20,7 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. @@ -68,7 +68,7 @@ public class TestParenting01aAWT extends UITestCase { } @Test - public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { + public void test01WindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { final GLWindow glWindow1 = GLWindow.create(glCaps); Assert.assertNotNull(glWindow1); Assert.assertEquals(false, glWindow1.isVisible()); @@ -112,11 +112,11 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); final Animator animator1 = new Animator(glWindow1); - animator1.setUpdateFPSFrames(1, null); + animator1.setUpdateFPSFrames(1, null); animator1.start(); Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow1, true)); - + while(animator1.isAnimating() && animator1.getTotalFPSDuration() TOP: "+glWindow1.reparentWindow(null, -1, -1, 0 /* hints */)); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); break; case 1: - glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow()); + System.err.println("Reparent TOP -> CHILD: "+glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, 0 /* hints */)); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); break; @@ -315,7 +315,7 @@ public class TestParenting01aAWT extends UITestCase { } @Test - public void testWindowParenting04ReparentNewtWin2TopLayouted() throws InterruptedException, InvocationTargetException { + public void test05WindowParenting04ReparentNewtWin2TopLayouted() throws InterruptedException, InvocationTargetException { GLWindow glWindow1 = GLWindow.create(glCaps); GLEventListener demo1 = new RedSquareES2(); setDemoFields(demo1, glWindow1, false); @@ -329,7 +329,7 @@ public class TestParenting01aAWT extends UITestCase { frame.add(new Button("South"), BorderLayout.SOUTH); frame.add(new Button("East"), BorderLayout.EAST); frame.add(new Button("West"), BorderLayout.WEST); - + SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setSize(width, height); @@ -344,11 +344,11 @@ public class TestParenting01aAWT extends UITestCase { frame.validate(); } }); - + Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); - animator1.setUpdateFPSFrames(1, null); + animator1.setUpdateFPSFrames(1, null); animator1.start(); int state = 0; @@ -356,12 +356,12 @@ public class TestParenting01aAWT extends UITestCase { Thread.sleep(durationPerTest); switch(state) { case 0: - glWindow1.reparentWindow(null); + System.err.println("Reparent CHILD -> TOP: "+glWindow1.reparentWindow(null, -1, -1, 0 /* hints */)); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertNull(glWindow1.getParent()); break; case 1: - glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow()); + System.err.println("Reparent TOP -> CHILD: "+glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, 0 /* hints */)); Assert.assertEquals(true, glWindow1.isNativeValid()); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); break; @@ -380,7 +380,7 @@ public class TestParenting01aAWT extends UITestCase { } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { + public void test06WindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); GLEventListener demo1 = new RedSquareES2(); @@ -427,7 +427,7 @@ public class TestParenting01aAWT extends UITestCase { Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); Animator animator1 = new Animator(glWindow1); - animator1.setUpdateFPSFrames(1, null); + animator1.setUpdateFPSFrames(1, null); animator1.start(); int state = 0; @@ -442,7 +442,7 @@ public class TestParenting01aAWT extends UITestCase { frame1.validate(); frame2.validate(); } - }); + }); break; case 1: SwingUtilities.invokeAndWait(new Runnable() { @@ -452,7 +452,7 @@ public class TestParenting01aAWT extends UITestCase { frame2.validate(); frame1.validate(); } - }); + }); break; } state++; @@ -471,7 +471,7 @@ public class TestParenting01aAWT extends UITestCase { public static void setDemoFields(GLEventListener demo, GLWindow glWindow, boolean debug) { Assert.assertNotNull(demo); - Assert.assertNotNull(glWindow); + Assert.assertNotNull(glWindow); if(debug) { MiscUtils.setFieldIfExists(demo, "glDebug", true); MiscUtils.setFieldIfExists(demo, "glTrace", true); @@ -498,17 +498,7 @@ public class TestParenting01aAWT extends UITestCase { } } String tstname = TestParenting01aAWT.class.getName(); - org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(new String[] { - tstname, - "filtertrace=true", - "haltOnError=false", - "haltOnFailure=false", - "showoutput=true", - "outputtoformatters=true", - "logfailedtests=true", - "logtestlistenerevents=true", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.PlainJUnitResultFormatter", - "formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,TEST-"+tstname+".xml" } ); + org.junit.runner.JUnitCore.main(tstname); } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java index 45612eb1a..598e5f10f 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01bAWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; import org.junit.Assert; @@ -68,16 +68,16 @@ public class TestParenting01bAWT extends UITestCase { } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2FrameFPS25Animator() throws InterruptedException, InvocationTargetException { - testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(25); + public void test01AWTWinHopFrame2FrameFPS25Animator() throws InterruptedException, InvocationTargetException { + testAWTWinHopFrame2FrameImpl(25); } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2FrameStdAnimator() throws InterruptedException, InvocationTargetException { - testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(0); + public void test02AWTWinHopFrame2FrameStdAnimator() throws InterruptedException, InvocationTargetException { + testAWTWinHopFrame2FrameImpl(0); } - public void testWindowParenting05ReparentAWTWinHopFrame2FrameImpl(int fps) throws InterruptedException, InvocationTargetException { + public void testAWTWinHopFrame2FrameImpl(int fps) throws InterruptedException, InvocationTargetException { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); GLEventListener demo1 = new RedSquareES2(); @@ -85,7 +85,7 @@ public class TestParenting01bAWT extends UITestCase { glWindow1.addGLEventListener(demo1); final NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); - + final Frame frame1 = new Frame("AWT Parent Frame"); frame1.setLayout(new BorderLayout()); frame1.add(new Button("North"), BorderLayout.NORTH); @@ -96,7 +96,7 @@ public class TestParenting01bAWT extends UITestCase { public void run() { frame1.setSize(width, height); frame1.setLocation(0, 0); - frame1.setVisible(true); + frame1.setVisible(true); } }); @@ -110,7 +110,7 @@ public class TestParenting01bAWT extends UITestCase { public void run() { frame2.setSize(width, height); frame2.setLocation(640, 480); - frame2.setVisible(true); + frame2.setVisible(true); } }); @@ -142,7 +142,7 @@ public class TestParenting01bAWT extends UITestCase { frame1.validate(); frame2.validate(); } - }); + }); break; case 1: SwingUtilities.invokeAndWait(new Runnable() { @@ -152,7 +152,7 @@ public class TestParenting01bAWT extends UITestCase { frame2.validate(); frame1.validate(); } - }); + }); break; } } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java index dd5d6eb13..1d7401728 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cAWT.java @@ -66,7 +66,7 @@ public class TestParenting01cAWT extends UITestCase { } @Test - public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { + public void test01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { int i; GLWindow glWindow1 = GLWindow.create(glCaps); @@ -154,7 +154,7 @@ public class TestParenting01cAWT extends UITestCase { } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { + public void test02AWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUndecorated(true); GLEventListener demo1 = new RedSquareES2(); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java index 375f676f4..4d5c3b25d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01cSwingAWT.java @@ -121,7 +121,7 @@ public class TestParenting01cSwingAWT extends UITestCase { } @Test - public void testWindowParenting01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { + public void test01CreateVisibleDestroy1() throws InterruptedException, InvocationTargetException { /** * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow */ @@ -236,7 +236,7 @@ public class TestParenting01cSwingAWT extends UITestCase { } @Test - public void testWindowParenting05ReparentAWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { + public void test02AWTWinHopFrame2Frame() throws InterruptedException, InvocationTargetException { /** * JFrame . JPanel . Container . NewtCanvasAWT . GLWindow */ diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java index d79bdcaf6..b304a2ce7 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02AWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; import org.junit.Assert; @@ -65,22 +65,22 @@ public class TestParenting02AWT extends UITestCase { } @Test - public void testWindowParenting01NewtChildOnAWTParentLayouted() throws InterruptedException, InvocationTargetException { + public void test01NewtChildOnAWTParentLayouted() throws InterruptedException, InvocationTargetException { runNewtChildOnAWTParent(true, false); } @Test - public void testWindowParenting02NewtChildOnAWTParentLayoutedDef() throws InterruptedException, InvocationTargetException { + public void test02NewtChildOnAWTParentLayoutedDef() throws InterruptedException, InvocationTargetException { runNewtChildOnAWTParent(true, true); } @Test - public void testWindowParenting03NewtChildOnAWTParentDirect() throws InterruptedException, InvocationTargetException { + public void test03NewtChildOnAWTParentDirect() throws InterruptedException, InvocationTargetException { runNewtChildOnAWTParent(false, false); } @Test - public void testWindowParenting04NewtChildOnAWTParentDirectDef() throws InterruptedException, InvocationTargetException { + public void test04NewtChildOnAWTParentDirectDef() throws InterruptedException, InvocationTargetException { runNewtChildOnAWTParent(false, true); } @@ -152,7 +152,7 @@ public class TestParenting02AWT extends UITestCase { } while(!glWindow.isNativeValid()) ; final boolean wasOnscreen = glWindow.getChosenCapabilities().isOnscreen(); - + Assert.assertEquals(true, glWindow.isNativeValid()); Assert.assertNotNull(glWindow.getParent()); if(verbose) { @@ -203,7 +203,7 @@ public class TestParenting02AWT extends UITestCase { Thread.sleep(step); duration -= step; - while( null != ( event = (NEWTEvent) eventFifo.get() ) ) { + while( null != ( event = eventFifo.get() ) ) { Window source = (Window) event.getSource(); if(event instanceof KeyEvent) { KeyEvent keyEvent = (KeyEvent) event; @@ -215,7 +215,7 @@ public class TestParenting02AWT extends UITestCase { source.setFullscreen(!source.isFullscreen()); break; } - } + } } } if(verbose) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java index 6294483f0..9f56ecdbf 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting02NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; @@ -92,7 +92,7 @@ public class TestParenting02NEWT extends UITestCase { } @Test - public void testWindowParenting01NewtOnNewtParentChildDraw() throws InterruptedException { + public void test01NewtOnNewtParentChildDraw() throws InterruptedException { GLCapabilities caps = new GLCapabilities(null); Assert.assertNotNull(caps); Display display = NewtFactory.createDisplay(null); // local display @@ -112,7 +112,7 @@ public class TestParenting02NEWT extends UITestCase { glWindow1.setSize(width, height); Assert.assertEquals(width,glWindow1.getWidth()); Assert.assertEquals(height,glWindow1.getHeight()); - glWindow1.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - PARENT"); + glWindow1.setTitle("test01NewtOnNewtParentChildDraw - PARENT"); glWindow1.setPosition(x,y); //glWindow1.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); //glWindow1.addWindowListener(new TraceWindowAdapter()); @@ -133,7 +133,7 @@ public class TestParenting02NEWT extends UITestCase { glWindow2.setSize(width/2, height/2); //Assert.assertEquals(width/2,glWindow2.getWidth()); //Assert.assertEquals(height/2,glWindow2.getHeight()); - glWindow2.setTitle("testWindowParenting01NewtOnNewtParentChildDraw - CHILD"); + glWindow2.setTitle("test01NewtOnNewtParentChildDraw - CHILD"); glWindow2.setPosition(glWindow1.getWidth()/2, glWindow1.getHeight()/2); //glWindow2.addKeyListener(new TraceKeyAdapter(new KeyAction(eventFifo))); //glWindow2.addWindowListener(new TraceWindowAdapter(new WindowAction(eventFifo))); @@ -166,7 +166,7 @@ public class TestParenting02NEWT extends UITestCase { glWindow2.setPosition(glWindow1.getWidth()/2,glWindow1.getHeight()/2-y); Thread.sleep(step); - while( null != ( event = (NEWTEvent) eventFifo.get() ) ) { + while( null != ( event = eventFifo.get() ) ) { Window source = (Window) event.getSource(); if(WindowEvent.EVENT_WINDOW_DESTROY_NOTIFY == event.getEventType()) { shouldQuit = true; @@ -180,7 +180,7 @@ public class TestParenting02NEWT extends UITestCase { source.setFullscreen(!source.isFullscreen()); break; } - } + } } } destroyWindow(null, null, window2, glWindow2); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java index 30ee0f129..b7497196c 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting03AWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.newt.parenting; import java.lang.reflect.*; @@ -69,16 +69,16 @@ public class TestParenting03AWT extends UITestCase { } @Test - public void testWindowParenting1AWTOneNewtChilds01() throws InterruptedException, InvocationTargetException { - testWindowParenting1AWT(false); + public void test01AWTOneNewtChilds01() throws InterruptedException, InvocationTargetException { + testImpl(false); } @Test - public void testWindowParenting1AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException { - testWindowParenting1AWT(true); + public void test02AWTTwoNewtChilds01() throws InterruptedException, InvocationTargetException { + testImpl(true); } - - public void testWindowParenting1AWT(boolean use2nd) throws InterruptedException, InvocationTargetException { + + public void testImpl(boolean use2nd) throws InterruptedException, InvocationTargetException { final Frame frame1 = new Frame("AWT Parent Frame"); GLWindow glWindow1 = GLWindow.create(glCaps); glWindow1.setUpdateFPSFrames(1, null); @@ -100,7 +100,7 @@ public class TestParenting03AWT extends UITestCase { glWindow2.setUpdateFPSFrames(1, null); newtCanvasAWT2 = new NewtCanvasAWT(glWindow2); newtCanvasAWT2.setPreferredSize(glSize); - + GLEventListener demo2 = new GearsES2(1); setDemoFields(demo2, glWindow2, false); glWindow2.addGLEventListener(demo2); @@ -141,12 +141,12 @@ public class TestParenting03AWT extends UITestCase { System.err.println("******* Frame setVisible"); frame1.setLocation(0, 0); frame1.setSize(fSize); - frame1.validate(); + frame1.validate(); frame1.setVisible(true); }}); Assert.assertEquals(newtCanvasAWT1.getNativeWindow(),glWindow1.getParent()); - + Assert.assertEquals(true, animator1.isAnimating()); Assert.assertEquals(false, animator1.isPaused()); Assert.assertNotNull(animator1.getThread()); @@ -157,7 +157,7 @@ public class TestParenting03AWT extends UITestCase { Assert.assertNotNull(animator2.getThread()); Thread.sleep(waitAdd2nd); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame1.add(cont2, BorderLayout.WEST); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java index 827ac525a..126aaaffa 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04AWT.java @@ -70,13 +70,13 @@ public class TestParenting04AWT extends UITestCase { } @Test - public void winHopFrame2FrameDirectHop() throws InterruptedException, InvocationTargetException { + public void test01WinHopFrame2FrameDirectHop() throws InterruptedException, InvocationTargetException { // Will produce some artifacts .. resizing etc winHopFrame2Frame(false); } @Test - public void winHopFrame2FrameDetachFirst() throws InterruptedException, InvocationTargetException { + public void test02WinHopFrame2FrameDetachFirst() throws InterruptedException, InvocationTargetException { // Note: detaching first setNEWTChild(null) is much cleaner visually winHopFrame2Frame(true); } diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java index 78b3bc464..586db8a2b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting04SWT.java @@ -136,13 +136,13 @@ public class TestParenting04SWT extends UITestCase { } @Test - public void winHopFrame2FrameDirectHop() throws InterruptedException, InvocationTargetException { + public void test01WinHopFrame2FrameDirectHop() throws InterruptedException, InvocationTargetException { // Will produce some artifacts .. resizing etc winHopFrame2Frame(false); } @Test - public void winHopFrame2FrameDetachFirst() throws InterruptedException, InvocationTargetException { + public void test02WinHopFrame2FrameDetachFirst() throws InterruptedException, InvocationTargetException { // Note: detaching first setNEWTChild(null) is much cleaner visually winHopFrame2Frame(true); } -- cgit v1.2.3 From c6ab1bc932d9a0b3897b24d289e4d561bf8bb65c Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 11 Dec 2013 06:21:42 +0100 Subject: Bug 918 (1/2): Use StreamWorker in 'Audio Only' mode, since no 'getNextTexture(..)' is issued here! Thanks to Xerxes to analyze this issue thoroughly. TODO: Implement EOS for 'Audio Only' and test seek, pause, etc .. - Apply manual tests in MovieSimple --- make/scripts/tests.sh | 6 +++--- src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java | 2 +- src/jogl/native/libav/ffmpeg_impl_template.c | 7 +------ 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9b7d43453..e9d612f64 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -141,7 +141,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" - #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" @@ -345,7 +345,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests @@ -608,7 +608,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index 86e19c920..04a8beb48 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -528,7 +528,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.vid = vid; this.aid = aid; if ( this.streamLoc != null ) { - if( TEXTURE_COUNT_MIN < textureCount ) { + if( TEXTURE_COUNT_MIN < textureCount || STREAM_ID_NONE == vid ) { // Enable StreamWorker for 'audio only' as well (Bug 918). streamWorker = new StreamWorker(); } else { new Thread() { diff --git a/src/jogl/native/libav/ffmpeg_impl_template.c b/src/jogl/native/libav/ffmpeg_impl_template.c index 24fddd2c0..b46586acc 100644 --- a/src/jogl/native/libav/ffmpeg_impl_template.c +++ b/src/jogl/native/libav/ffmpeg_impl_template.c @@ -846,14 +846,9 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) pAV->frames_audio = pAV->pAStream->nb_frames; pAV->aSinkSupport = _isAudioFormatSupported(env, pAV->ffmpegMediaPlayer, pAV->aSampleFmt, pAV->aSampleRate, pAV->aChannels); if( pAV->verbose ) { - fprintf(stderr, "A channels %d [l %"PRId64"], sample_rate %d, frame_size %d, frame_number %d, [afps %f, rfps %f, cfps %f, sfps %f], nb_frames %"PRId64", [maxChan %d, prefRate %d, req_chan_layout %"PRId64", req_chan %d], sink-support %d \n", + fprintf(stderr, "A channels %d [l %"PRId64"], sample_rate %d, frame_size %d, frame_number %d, [afps %f, cfps %f, sfps %f], nb_frames %"PRId64", [maxChan %d, prefRate %d, req_chan_layout %"PRId64", req_chan %d], sink-support %d \n", pAV->aChannels, pAV->pACodecCtx->channel_layout, pAV->aSampleRate, pAV->aFrameSize, pAV->pACodecCtx->frame_number, my_av_q2f(pAV->pAStream->avg_frame_rate), - #if LIBAVCODEC_VERSION_MAJOR < 55 - my_av_q2f(pAV->pVStream->r_frame_rate), - #else - 0.0f, - #endif my_av_q2f_r(pAV->pAStream->codec->time_base), my_av_q2f_r(pAV->pAStream->time_base), pAV->pAStream->nb_frames, -- cgit v1.2.3 From 8a8ed735f6631b2da7bf605c5c3dda4e0fc13905 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 11 Dec 2013 20:46:04 +0100 Subject: Bug 918 (2/2): Determine StreamWorker usage after stream-init ; Fix seek(..) ; Fallback for EOS Detection ; MovieSimple uses full GLEventListener for 'Audio Only' as well to test seek Determine StreamWorker usage after init - To support audio only files, we need to determine to use StreamWorker after completion of stream-init. Fix seek(..) - FFMPeg: pos0 needs to use aPTS for audio-only - Clip target time [0..duration[ Fallback for EOS Detection In case the backend does not report proper EOS: - Utilize 'nullFramesCount >= MAX' -> EOS, where MAX is number of frames for 3s play duraction and where 'nullFramesCount' is increased if no valid packet is available and no decoded-video or -audio in the queue. - Utilize pts > duration -> EOS MovieSimple uses full GLEventListener for 'Audio Only' as well to test seek - Matroska seek for audio-only leads to EOS .. http://video.webmfiles.org/big-buck-bunny_trailer.webm - MP4 audio-only seek works http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4 MovieSimple/MovieCube: - Use audio-pts in audio-only to calc target time Tested: - A, V and A+V - Pause, Stop and Seek - GNU/Linux --- make/scripts/tests.sh | 2 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 5 +- .../jogamp/opengl/util/av/GLMediaPlayerImpl.java | 261 ++++++++++++++------- src/jogl/native/libav/ffmpeg_impl_template.c | 16 +- .../test/junit/jogl/demos/es2/av/MovieCube.java | 2 +- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 193 +++++++++------ 6 files changed, 310 insertions(+), 169 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index e9d612f64..cb60028aa 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -141,7 +141,7 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" - D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index b0a645cbb..22a5cfb32 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -358,7 +358,10 @@ public interface GLMediaPlayer extends TextureSequence { public void initStream(URI streamLoc, int vid, int aid, int textureCount) throws IllegalStateException, IllegalArgumentException; /** - * Returns the {@link StreamException} caught in the decoder thread, or null. + * Returns the {@link StreamException} caught in the decoder thread, or null if none occured. + *

        + * Method clears the cached {@link StreamException}, hence an immediate subsequent call will return null. + *

        * @see GLMediaEventListener#EVENT_CHANGE_ERR * @see StreamException */ diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index ae3f901a1..e6a0012d3 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -138,6 +138,18 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected int displayedFrameCount = 0; protected volatile int video_pts_last = 0; + /** + * Help detect EOS, limit is {@link #MAX_FRAMELESS_MS_UNTIL_EOS}. + * To be used either by getNextTexture(..) or StreamWorker for audio-only. + */ + private int nullFrameCount = 0; + private int maxNullFrameCountUntilEOS = 0; + /** + * Help detect EOS, limit {@value} milliseconds without a valid frame. + */ + private static final int MAX_FRAMELESS_MS_UNTIL_EOS = 5000; + private static final int MAX_FRAMELESS_UNTIL_EOS_DEFAULT = MAX_FRAMELESS_MS_UNTIL_EOS / 30; // default value assuming 30fps + /** See {@link #getAudioSink()}. Set by implementation if used from within {@link #initStreamImpl(int, int)}! */ protected AudioSink audioSink = null; protected boolean audioSinkPlaySpeedSet = false; @@ -380,6 +392,12 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( null != streamWorker ) { streamWorker.doPause(); } + // Adjust target .. + if( msec >= duration ) { + msec = duration - (int)Math.floor(frame_duration); + } else if( msec < 0 ) { + msec = 0; + } pts1 = seekImpl(msec); resetAVPTSAndFlush(); if( null != audioSink && State.Playing == _state ) { @@ -509,6 +527,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { decodedFrameCount = 0; presentedFrameCount = 0; displayedFrameCount = 0; + nullFrameCount = 0; + maxNullFrameCountUntilEOS = MAX_FRAMELESS_UNTIL_EOS_DEFAULT; this.streamLoc = streamLoc; // Pre-parse for camera-input scheme @@ -530,20 +550,17 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { this.vid = vid; this.aid = aid; if ( this.streamLoc != null ) { - if( TEXTURE_COUNT_MIN < textureCount || STREAM_ID_NONE == vid ) { // Enable StreamWorker for 'audio only' as well (Bug 918). - streamWorker = new StreamWorker(); - } else { - new Thread() { - public void run() { - try { - initStreamImpl(vid, aid); - } catch (Throwable t) { - streamErr = new StreamException(t.getClass().getSimpleName()+" while initializing: "+GLMediaPlayerImpl.this.toString(), t); - changeState(GLMediaEventListener.EVENT_CHANGE_ERR, GLMediaPlayer.State.Uninitialized); - } // also initializes width, height, .. etc - } - }.start(); - } + new Thread() { + public void run() { + try { + // StreamWorker may be used, see API-doc of StreamWorker + initStreamImpl(vid, aid); + } catch (Throwable t) { + streamErr = new StreamException(t.getClass().getSimpleName()+" while initializing: "+GLMediaPlayerImpl.this.toString(), t); + changeState(GLMediaEventListener.EVENT_CHANGE_ERR, GLMediaPlayer.State.Uninitialized); + } // also initializes width, height, .. etc + } + }.start(); } } } @@ -748,6 +765,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { protected TextureFrame cachedFrame = null; protected long lastTimeMillis = 0; + private final boolean[] stGotVFrame = { false }; + @Override public final TextureFrame getNextTexture(GL gl) throws IllegalStateException { synchronized( stateLock ) { @@ -755,12 +774,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { throw new IllegalStateException("Instance not paused or playing: "+this); } if(State.Playing == state) { - TextureFrame nextFrame = null; boolean dropFrame = false; try { do { - final long currentTimeMillis; - final boolean playCached = null != cachedFrame; final boolean droppedFrame; if( dropFrame ) { presentedFrameCount--; @@ -769,24 +785,69 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } else { droppedFrame = false; } + final boolean playCached = null != cachedFrame; + final int video_pts; + final boolean hasVideoFrame; + TextureFrame nextFrame; if( playCached ) { nextFrame = cachedFrame; cachedFrame = null; presentedFrameCount--; - } else if( STREAM_ID_NONE != vid ) { - if( null != videoFramesDecoded ) { // single threaded ? TEXTURE_COUNT_MIN == textureCount + video_pts = nextFrame.getPTS(); + hasVideoFrame = true; + } else { + if( null != videoFramesDecoded ) { + // multi-threaded and video available nextFrame = videoFramesDecoded.get(); + if( null != nextFrame ) { + video_pts = nextFrame.getPTS(); + hasVideoFrame = true; + } else { + video_pts = TimeFrameI.INVALID_PTS; + hasVideoFrame = false; + } } else { - nextFrame = getNextSingleThreaded(gl, lastFrame); + // single-threaded or audio-only + video_pts = getNextSingleThreaded(gl, lastFrame, stGotVFrame); + nextFrame = lastFrame; + hasVideoFrame = stGotVFrame[0]; } } - currentTimeMillis = Platform.currentTimeMillis(); - if( null != nextFrame ) { - presentedFrameCount++; - final int video_pts = nextFrame.getPTS(); - if( video_pts == TimeFrameI.END_OF_STREAM_PTS ) { - pauseImpl(true, GLMediaEventListener.EVENT_CHANGE_EOS); - } else if( video_pts != TimeFrameI.INVALID_PTS ) { + final long currentTimeMillis = Platform.currentTimeMillis(); + + if( TimeFrameI.END_OF_STREAM_PTS == video_pts || + duration <= video_pts || maxNullFrameCountUntilEOS <= nullFrameCount ) + { + // EOS + if( DEBUG ) { + System.err.println( "AV-EOS (getNextTexture): EOS_PTS "+(TimeFrameI.END_OF_STREAM_PTS == video_pts)+", "+this); + } + pauseImpl(true, GLMediaEventListener.EVENT_CHANGE_EOS); + + } else if( TimeFrameI.INVALID_PTS == video_pts ) { // no audio or video frame + if( null == videoFramesDecoded || !videoFramesDecoded.isEmpty() ) { + nullFrameCount++; + } + if( DEBUG ) { + final int audio_pts = getAudioPTSImpl(); + final int audio_scr = (int) ( ( currentTimeMillis - audio_scr_t0 ) * playSpeed ); + final int d_apts; + if( audio_pts != TimeFrameI.INVALID_PTS ) { + d_apts = audio_pts - audio_scr; + } else { + d_apts = 0; + } + final int video_scr = video_scr_pts + (int) ( ( currentTimeMillis - video_scr_t0 ) * playSpeed ); + final int d_vpts = video_pts - video_scr; + System.err.println( "AV~: dT "+(currentTimeMillis-lastTimeMillis)+", nullFrames "+nullFrameCount+ + getPerfStringImpl( video_scr, video_pts, d_vpts, audio_scr, audio_pts, d_apts, 0 ) + ", droppedFrame "+droppedFrame); + } + } else { // valid pts: has audio or video frame + nullFrameCount=0; + + if( hasVideoFrame ) { // has video frame + presentedFrameCount++; + final int audio_pts = getAudioPTSImpl(); final int audio_scr = (int) ( ( currentTimeMillis - audio_scr_t0 ) * playSpeed ); final int d_apts; @@ -840,29 +901,16 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { ", avg dpy-fps "+avg_dpy_duration+" ms/f, maxD "+maxVideoDelay+" ms, "+_nextFrame+", playCached " + playCached + ", dropFrame "+dropFrame); } } - } else if( DEBUG ) { - System.err.println("Invalid PTS: "+nextFrame); - } - if( null != nextFrame && null != videoFramesFree ) { - // Had frame and not single threaded ? (TEXTURE_COUNT_MIN < textureCount) - final TextureFrame _lastFrame = lastFrame; - lastFrame = nextFrame; + } // has video frame + } // has audio or video frame + + if( null != videoFramesFree && null != nextFrame ) { + // Had frame and not single threaded ? (TEXTURE_COUNT_MIN < textureCount) + final TextureFrame _lastFrame = lastFrame; + lastFrame = nextFrame; + if( null != _lastFrame ) { videoFramesFree.putBlocking(_lastFrame); } - } else if( DEBUG ) { - final int video_pts = lastFrame.getPTS(); - final int audio_pts = getAudioPTSImpl(); - final int audio_scr = (int) ( ( currentTimeMillis - audio_scr_t0 ) * playSpeed ); - final int d_apts; - if( audio_pts != TimeFrameI.INVALID_PTS ) { - d_apts = audio_pts - audio_scr; - } else { - d_apts = 0; - } - final int video_scr = video_scr_pts + (int) ( ( currentTimeMillis - video_scr_t0 ) * playSpeed ); - final int d_vpts = video_pts - video_scr; - System.err.println( "AV~: dT "+(currentTimeMillis-lastTimeMillis)+", "+ - getPerfStringImpl( video_scr, video_pts, d_vpts, audio_scr, audio_pts, d_apts, 0 ) + ", droppedFrame "+droppedFrame); } lastTimeMillis = currentTimeMillis; } while( dropFrame ); @@ -899,24 +947,24 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { */ protected abstract int getNextTextureImpl(GL gl, TextureFrame nextFrame); - protected final TextureFrame getNextSingleThreaded(final GL gl, final TextureFrame nextFrame) throws InterruptedException { + protected final int getNextSingleThreaded(final GL gl, final TextureFrame nextFrame, boolean[] gotVFrame) throws InterruptedException { + final int pts; if( STREAM_ID_NONE != vid ) { preNextTextureImpl(gl); - final int vPTS = getNextTextureImpl(gl, nextFrame); + pts = getNextTextureImpl(gl, nextFrame); postNextTextureImpl(gl); - if( TimeFrameI.INVALID_PTS != vPTS ) { + if( TimeFrameI.INVALID_PTS != pts ) { newFrameAvailable(nextFrame, Platform.currentTimeMillis()); - return nextFrame; + gotVFrame[0] = true; + } else { + gotVFrame[0] = false; } } else { // audio only - final int vPTS = getNextTextureImpl(null, null); - if( TimeFrameI.INVALID_PTS != vPTS && TimeFrameI.END_OF_STREAM_PTS == vPTS ) { - // state transition incl. notification - pauseImpl(true, GLMediaEventListener.EVENT_CHANGE_EOS); - } + pts = getNextTextureImpl(null, null); + gotVFrame[0] = false; } - return null; + return pts; } @@ -964,6 +1012,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } private void resetAVPTS() { + nullFrameCount = 0; presentedFrameCount = 0; displayedFrameCount = 0; decodedFrameCount = 0; @@ -986,6 +1035,11 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } + /** + * After {@link GLMediaPlayerImpl#initStreamImpl(int, int) initStreamImpl(..)} is completed via + * {@link GLMediaPlayerImpl#updateAttributes(int, int, int, int, int, int, int, float, int, int, int, String, String) updateAttributes(..)}, + * the latter decides whether StreamWorker is being used. + */ class StreamWorker extends Thread { private volatile boolean isRunning = false; private volatile boolean isActive = false; @@ -1000,14 +1054,23 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { /** * Starts this daemon thread, - * which initializes the stream first via {@link GLMediaPlayerImpl#initStreamImpl(int, int)} first. *

        - * After stream initialization, this thread pauses! + * This thread pauses after it's started! *

        **/ StreamWorker() { setDaemon(true); - start(); + synchronized(this) { + start(); + while( !isRunning ) { + this.notifyAll(); // wake-up startup-block + try { + this.wait(); // wait until started + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } } private void makeCurrent(GLContext ctx) { @@ -1113,17 +1176,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { synchronized ( this ) { isRunning = true; - try { - isBlocked = true; - initStreamImpl(vid, aid); - isBlocked = false; - } catch (Throwable t) { - streamErr = new StreamException(t.getClass().getSimpleName()+" while initializing: "+GLMediaPlayerImpl.this.toString(), t); - isBlocked = false; - isRunning = false; - changeState(GLMediaEventListener.EVENT_CHANGE_ERR, GLMediaPlayer.State.Uninitialized); - return; // end of thread! - } // also initializes width, height, .. etc + this.notifyAll(); // wake-up ctor() } while( !shallStop ){ @@ -1179,6 +1232,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } isBlocked = false; final int vPTS = getNextTextureImpl(gl, nextFrame); + boolean audioEOS = false; if( TimeFrameI.INVALID_PTS != vPTS ) { if( null != nextFrame ) { if( STREAM_WORKER_DELAY > 0 ) { @@ -1191,16 +1245,30 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { nextFrame = null; } else { // audio only - if( TimeFrameI.END_OF_STREAM_PTS == vPTS ) { - // state transition incl. notification - synchronized ( this ) { - shallPause = true; - isActive = false; - this.notifyAll(); // wake-up potential do*() - } - pauseImpl(true, GLMediaEventListener.EVENT_CHANGE_EOS); + if( TimeFrameI.END_OF_STREAM_PTS == vPTS || duration < vPTS ) { + audioEOS = true; + } else { + nullFrameCount = 0; } } + } else if( null == nextFrame ) { + // audio only + audioEOS = maxNullFrameCountUntilEOS <= nullFrameCount; + if( null == audioSink || 0 == audioSink.getEnqueuedFrameCount() ) { + nullFrameCount++; + } + } + if( audioEOS ) { + // state transition incl. notification + synchronized ( this ) { + shallPause = true; + isActive = false; + this.notifyAll(); // wake-up potential do*() + } + if( DEBUG ) { + System.err.println( "AV-EOS (StreamWorker): EOS_PTS "+(TimeFrameI.END_OF_STREAM_PTS == vPTS)+", "+GLMediaPlayerImpl.this); + } + pauseImpl(true, GLMediaEventListener.EVENT_CHANGE_EOS); } } catch (InterruptedException e) { isBlocked = false; @@ -1242,7 +1310,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } static int StreamWorkerInstanceId = 0; - private StreamWorker streamWorker = null; + private volatile StreamWorker streamWorker = null; private volatile StreamException streamErr = null; protected final int addStateEventMask(int event_mask, State newState) { @@ -1288,7 +1356,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { int bps_video, int bps_audio, float fps, int videoFrames, int audioFrames, int duration, String vcodec, String acodec) { int event_mask = 0; - if( state == State.Uninitialized ) { + final boolean wasUninitialized = state == State.Uninitialized; + + if( wasUninitialized ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_INIT; state = State.Initialized; } @@ -1314,7 +1384,13 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if( this.fps != fps ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_FPS; this.fps = fps; - this.frame_duration = 1000f / fps; + if( 0 != fps ) { + this.frame_duration = 1000f / fps; + this.maxNullFrameCountUntilEOS = MAX_FRAMELESS_MS_UNTIL_EOS / (int)this.frame_duration; + } else { + this.frame_duration = 0; + this.maxNullFrameCountUntilEOS = MAX_FRAMELESS_UNTIL_EOS_DEFAULT; + } } if( this.bps_stream != bps_stream || this.bps_video != bps_video || this.bps_audio != bps_audio ) { event_mask |= GLMediaEventListener.EVENT_CHANGE_BPS; @@ -1339,6 +1415,17 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { if(0==event_mask) { return; } + if( wasUninitialized ) { + if( null != streamWorker ) { + throw new InternalError("XXX: StreamWorker not null - "+this); + } + if( TEXTURE_COUNT_MIN < textureCount || STREAM_ID_NONE == vid ) { // Enable StreamWorker for 'audio only' as well (Bug 918). + streamWorker = new StreamWorker(); + } + if( DEBUG ) { + System.err.println("XXX Initialize @ updateAttributes: "+this); + } + } attributesUpdated(event_mask); } @@ -1434,9 +1521,9 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { final int decVideoFrames = null != videoFramesDecoded ? videoFramesDecoded.size() : 0; final int video_scr = video_scr_pts + (int) ( ( Platform.currentTimeMillis() - video_scr_t0 ) * playSpeed ); final String camPath = null != cameraPath ? ", camera: "+cameraPath : ""; - return "GLMediaPlayer["+state+", vSCR "+video_scr+", frames[p "+presentedFrameCount+", d "+decodedFrameCount+", t "+videoFrames+" ("+tt+" s)], "+ - "speed "+playSpeed+", "+bps_stream+" bps, "+ - "Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+", tagt "+toHexString(textureTarget)+", ifmt "+toHexString(textureInternalFormat)+", fmt "+toHexString(textureFormat)+", type "+toHexString(textureType)+"], "+ + return "GLMediaPlayer["+state+", vSCR "+video_scr+", frames[p "+presentedFrameCount+", d "+decodedFrameCount+", t "+videoFrames+" ("+tt+" s), z "+nullFrameCount+" / "+maxNullFrameCountUntilEOS+"], "+ + "speed "+playSpeed+", "+bps_stream+" bps, hasSW "+(null!=streamWorker)+ + ", Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+", tagt "+toHexString(textureTarget)+", ifmt "+toHexString(textureInternalFormat)+", fmt "+toHexString(textureFormat)+", type "+toHexString(textureType)+"], "+ "Video[id "+vid+", <"+vcodec+">, "+width+"x"+height+", glOrient "+isInGLOrientation+", "+fps+" fps, "+frame_duration+" fdur, "+bps_video+" bps], "+ "Audio[id "+aid+", <"+acodec+">, "+bps_audio+" bps, "+audioFrames+" frames], uri "+loc+camPath+"]"; } @@ -1470,7 +1557,7 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { freeVideoFrames = 0; decVideoFrames = 0; } - return state+", frames[(p "+presentedFrameCount+", d "+decodedFrameCount+") / "+videoFrames+", "+tt+" s], "+ + return state+", frames[(p "+presentedFrameCount+", d "+decodedFrameCount+") / "+videoFrames+", "+tt+" s, z "+nullFrameCount+" / "+maxNullFrameCountUntilEOS+"], "+ "speed " + playSpeed+", dAV "+( d_vpts - d_apts )+", vSCR "+video_scr+", vpts "+video_pts+", dSCR["+d_vpts+", avrg "+video_dpts_avg_diff+"], "+ "aSCR "+audio_scr+", apts "+audio_pts+" ( "+d_apts+" ), "+audioSinkInfo+ ", Texture[count "+textureCount+", free "+freeVideoFrames+", dec "+decVideoFrames+"]"; diff --git a/src/jogl/native/libav/ffmpeg_impl_template.c b/src/jogl/native/libav/ffmpeg_impl_template.c index b46586acc..44acfe46a 100644 --- a/src/jogl/native/libav/ffmpeg_impl_template.c +++ b/src/jogl/native/libav/ffmpeg_impl_template.c @@ -1144,6 +1144,11 @@ JNIEXPORT jint JNICALL FF_FUNC(readNextPacket0) pkt_odata = packet.data; pkt_osize = packet.size; if( AVERROR_EOF == avRes || ( pAV->pFormatCtx->pb && pAV->pFormatCtx->pb->eof_reached ) ) { + if( pAV->verbose ) { + fprintf(stderr, "EOS: avRes[res %d, eos %d], pb-EOS %d\n", + avRes, AVERROR_EOF == avRes, + ( pAV->pFormatCtx->pb && pAV->pFormatCtx->pb->eof_reached ) ); + } resPTS = END_OF_STREAM_PTS; } else if( 0 <= avRes ) { if( pAV->verbose ) { @@ -1475,15 +1480,16 @@ JNIEXPORT jint JNICALL FF_FUNC(seek0) (JNIEnv *env, jobject instance, jlong ptr, jint pos1) { const FFMPEGToolBasicAV_t *pAV = (FFMPEGToolBasicAV_t *)((void *)((intptr_t)ptr)); - const int64_t pos0 = pAV->vPTS; - int64_t pts0; + int64_t pos0, pts0; int streamID; AVRational time_base; if( pAV->vid >= 0 ) { + pos0 = pAV->vPTS; streamID = pAV->vid; time_base = pAV->pVStream->time_base; pts0 = pAV->pVFrame->pkt_pts; } else if( pAV->aid >= 0 ) { + pos0 = pAV->aPTS; streamID = pAV->aid; time_base = pAV->pAStream->time_base; pts0 = pAV->pAFrames[pAV->aFrameCurrent]->pkt_pts; @@ -1493,16 +1499,16 @@ JNIEXPORT jint JNICALL FF_FUNC(seek0) int64_t pts1 = (int64_t) (pos1 * (int64_t) time_base.den) / (1000 * (int64_t) time_base.num); if(pAV->verbose) { - fprintf(stderr, "SEEK: vid %d, aid %d, pos1 %d, pts: %"PRId64" -> %"PRId64"\n", pAV->vid, pAV->aid, pos1, pts0, pts1); + fprintf(stderr, "SEEK: vid %d, aid %d, pos0 %d, pos1 %d, pts: %"PRId64" -> %"PRId64"\n", pAV->vid, pAV->aid, pos0, pos1, pts0, pts1); } int flags = 0; if(pos1 < pos0) { flags |= AVSEEK_FLAG_BACKWARD; } - int res; + int res = -2; if(HAS_FUNC(sp_av_seek_frame)) { if(pAV->verbose) { - fprintf(stderr, "SEEK.0: pre : s %"PRId64" / %"PRId64" -> t %d / %"PRId64"\n", pos0, pts0, pos1, pts1); + fprintf(stderr, "SEEK.0: pre : s %d / %"PRId64" -> t %d / %"PRId64"\n", pos0, pts0, pos1, pts1); } sp_av_seek_frame(pAV->pFormatCtx, streamID, pts1, flags); } else if(HAS_FUNC(sp_avformat_seek_file)) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index 8f27e19c4..c1ccf7c39 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -153,7 +153,7 @@ public class MovieCube implements GLEventListener { return; } System.err.println("MC "+e); - int pts0 = mPlayer.getVideoPTS(); + final int pts0 = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID() ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS(); int pts1 = 0; switch(e.getKeyCode()) { case KeyEvent.VK_RIGHT: pts1 = pts0 + 1000; break; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index 1a9914bb7..ddf5c709c 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -150,7 +150,8 @@ public class MovieSimple implements GLEventListener { if(y>winHeight/2) { final float dp = (float)(x-prevMouseX)/(float)winWidth; - mPlayer.seek(mPlayer.getVideoPTS() + (int) (mPlayer.getDuration() * dp)); + final int pts0 = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID() ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS(); + mPlayer.seek(pts0 + (int) (mPlayer.getDuration() * dp)); } else { mPlayer.play(); rotate = 1; @@ -174,7 +175,7 @@ public class MovieSimple implements GLEventListener { return; } System.err.println("MC "+e); - int pts0 = mPlayer.getVideoPTS(); + final int pts0 = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID() ? mPlayer.getVideoPTS() : mPlayer.getAudioPTS(); int pts1 = 0; switch(e.getKeyCode()) { case KeyEvent.VK_RIGHT: pts1 = pts0 + 1000; break; @@ -372,9 +373,7 @@ public class MovieSimple implements GLEventListener { if( GLMediaPlayer.State.Uninitialized == mPlayer.getState() ) { throw new IllegalStateException("mPlayer in uninitialized state: "+mPlayer); } - if( GLMediaPlayer.STREAM_ID_NONE == mPlayer.getVID() ) { - throw new IllegalStateException("mPlayer has no VID/stream selected: "+mPlayer); - } + final boolean hasVideo = GLMediaPlayer.STREAM_ID_NONE != mPlayer.getVID(); resetGLState = false; zoom0 = orthoProjection ? 0f : -2.5f; @@ -397,10 +396,20 @@ public class MovieSimple implements GLEventListener { } System.out.println("p1 "+mPlayer+", shared "+mPlayerShared); final TextureFrame frame = mPlayer.getLastTexture(); - if( null == frame ) { - throw new InternalError("XXX: "+mPlayer); + if( null != frame ) { + if( !hasVideo ) { + throw new InternalError("XXX: "+mPlayer); + } + tex = frame.getTexture(); + if( null == tex ) { + throw new InternalError("XXX: "+mPlayer); + } + } else { + tex = null; + if( hasVideo ) { + throw new InternalError("XXX: "+mPlayer); + } } - tex = mPlayer.getLastTexture().getTexture(); if(!mPlayerShared) { mPlayer.setTextureMinMagFilter( new int[] { GL.GL_NEAREST, GL.GL_LINEAR } ); } @@ -413,74 +422,76 @@ public class MovieSimple implements GLEventListener { throw new GLException(glex); } - initShader(gl); + if( hasVideo ) { + initShader(gl); - // Push the 1st uniform down the path - st.useProgram(gl, true); + // Push the 1st uniform down the path + st.useProgram(gl, true); - int[] viewPort = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight()}; - pmvMatrix = new PMVMatrix(); - reshapePMV(viewPort[2], viewPort[3]); - pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); - if(!st.uniform(gl, pmvMatrixUniform)) { - throw new GLException("Error setting PMVMatrix in shader: "+st); - } - if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", mPlayer.getTextureUnit()))) { - throw new GLException("Error setting mgl_ActiveTexture in shader: "+st); - } + int[] viewPort = new int[] { 0, 0, drawable.getWidth(), drawable.getHeight()}; + pmvMatrix = new PMVMatrix(); + reshapePMV(viewPort[2], viewPort[3]); + pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); + if(!st.uniform(gl, pmvMatrixUniform)) { + throw new GLException("Error setting PMVMatrix in shader: "+st); + } + if(!st.uniform(gl, new GLUniformData("mgl_ActiveTexture", mPlayer.getTextureUnit()))) { + throw new GLException("Error setting mgl_ActiveTexture in shader: "+st); + } - float dWidth = drawable.getWidth(); - float dHeight = drawable.getHeight(); - float mWidth = mPlayer.getWidth(); - float mHeight = mPlayer.getHeight(); - float mAspect = mWidth/mHeight; - System.err.println("XXX0: mov aspect: "+mAspect); - float xs, ys; - if(orthoProjection) { - if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) { - xs = mWidth/2f; ys = xs / mAspect; + float dWidth = drawable.getWidth(); + float dHeight = drawable.getHeight(); + float mWidth = mPlayer.getWidth(); + float mHeight = mPlayer.getHeight(); + float mAspect = mWidth/mHeight; + System.err.println("XXX0: mov aspect: "+mAspect); + float xs, ys; + if(orthoProjection) { + if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) { + xs = mWidth/2f; ys = xs / mAspect; + } else { + xs = dWidth/2f; ys = xs / mAspect; // w>h + } } else { - xs = dWidth/2f; ys = xs / mAspect; // w>h + if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) { + xs = mAspect * ( mWidth / dWidth ) ; ys = xs / mAspect ; + } else { + xs = mAspect; ys = 1f; // b>h + } } - } else { - if(mPlayerScaleOrig && mWidth < dWidth && mHeight < dHeight) { - xs = mAspect * ( mWidth / dWidth ) ; ys = xs / mAspect ; - } else { - xs = mAspect; ys = 1f; // b>h + verts = new float[] { -1f*xs, -1f*ys, 0f, // LB + 1f*xs, 1f*ys, 0f // RT + }; + { + System.err.println("XXX0: pixel LB: "+verts[0]+", "+verts[1]+", "+verts[2]); + System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]); + float[] winLB = new float[3]; + float[] winRT = new float[3]; + pmvMatrix.gluProject(verts[0], verts[1], verts[2], viewPort, 0, winLB, 0); + pmvMatrix.gluProject(verts[3], verts[4], verts[5], viewPort, 0, winRT, 0); + System.err.println("XXX0: win LB: "+winLB[0]+", "+winLB[1]+", "+winLB[2]); + System.err.println("XXX0: win RT: "+winRT[0]+", "+winRT[1]+", "+winRT[2]); } - } - verts = new float[] { -1f*xs, -1f*ys, 0f, // LB - 1f*xs, 1f*ys, 0f // RT - }; - { - System.err.println("XXX0: pixel LB: "+verts[0]+", "+verts[1]+", "+verts[2]); - System.err.println("XXX0: pixel RT: "+verts[3]+", "+verts[4]+", "+verts[5]); - float[] winLB = new float[3]; - float[] winRT = new float[3]; - pmvMatrix.gluProject(verts[0], verts[1], verts[2], viewPort, 0, winLB, 0); - pmvMatrix.gluProject(verts[3], verts[4], verts[5], viewPort, 0, winRT, 0); - System.err.println("XXX0: win LB: "+winLB[0]+", "+winLB[1]+", "+winLB[2]); - System.err.println("XXX0: win RT: "+winRT[0]+", "+winRT[1]+", "+winRT[2]); - } - interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW); - { - interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER); - interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER); - interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER); - } - updateInterleavedVBO(gl, tex); + interleavedVBO = GLArrayDataServer.createGLSLInterleaved(3+4+2, GL.GL_FLOAT, false, 3*4, GL.GL_STATIC_DRAW); + { + interleavedVBO.addGLSLSubArray("mgl_Vertex", 3, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_Color", 4, GL.GL_ARRAY_BUFFER); + interleavedVBO.addGLSLSubArray("mgl_MultiTexCoord", 2, GL.GL_ARRAY_BUFFER); + } + updateInterleavedVBO(gl, tex); - st.ownAttribute(interleavedVBO, true); - gl.glClearColor(0.3f, 0.3f, 0.3f, 0.3f); + st.ownAttribute(interleavedVBO, true); + gl.glClearColor(0.3f, 0.3f, 0.3f, 0.3f); - gl.glEnable(GL2ES2.GL_DEPTH_TEST); + gl.glEnable(GL2ES2.GL_DEPTH_TEST); - st.useProgram(gl, false); + st.useProgram(gl, false); - // Let's show the completed shader state .. - System.out.println("iVBO: "+interleavedVBO); - System.out.println(st); + // Let's show the completed shader state .. + System.out.println("iVBO: "+interleavedVBO); + System.out.println(st); + } if(!mPlayerShared) { mPlayer.play(); @@ -697,6 +708,7 @@ public class MovieSimple implements GLEventListener { int textureCount = 3; // default - threaded boolean ortho = true; boolean zoom = false; + boolean _loopEOS = false; boolean forceES2 = false; boolean forceES3 = false; @@ -742,6 +754,8 @@ public class MovieSimple implements GLEventListener { ortho=false; } else if(args[i].equals("-zoom")) { zoom=true; + } else if(args[i].equals("-loop")) { + _loopEOS=true; } else if(args[i].equals("-url")) { i++; url_s = args[i]; @@ -757,6 +771,7 @@ public class MovieSimple implements GLEventListener { } origSize = _origSize; } + final boolean loopEOS = _loopEOS; final URI streamLoc; if( null != url_s ) { streamLoc = new URI(url_s); @@ -827,6 +842,7 @@ public class MovieSimple implements GLEventListener { System.err.println("MovieSimple AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); System.err.println("MovieSimple State: "+mp); if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { + System.err.println("MovieSimple State: CHANGE_SIZE"); if( origSize ) { window.setSize(mp.getWidth(), mp.getHeight()); } @@ -834,11 +850,14 @@ public class MovieSimple implements GLEventListener { ms.resetGLState(); } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { - if( GLMediaPlayer.STREAM_ID_NONE != ms.mPlayer.getVID() ) { - window.addGLEventListener(ms); - anim.setUpdateFPSFrames(60, System.err); - anim.resetFPSCounter(); - } else { + System.err.println("MovieSimple State: INIT"); + // Use GLEventListener in all cases [A+V, V, A] + window.addGLEventListener(ms); + anim.setUpdateFPSFrames(60, System.err); + anim.resetFPSCounter(); + /** + * Kick off player w/o GLEventListener, i.e. for audio only. + * try { ms.mPlayer.initGL(null); } catch (Exception e) { @@ -848,12 +867,38 @@ public class MovieSimple implements GLEventListener { } ms.mPlayer.play(); System.out.println("play.1 "+ms.mPlayer); + */ + } + boolean destroy = false; + Throwable err = null; + + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { + err = ms.mPlayer.getStreamException(); + if( null != err ) { + System.err.println("MovieSimple State: EOS + Exception"); + destroy = true; + } else { + System.err.println("MovieSimple State: EOS"); + if( loopEOS ) { + ms.mPlayer.seek(0); + ms.mPlayer.play(); + } else { + destroy = true; + } + } + } + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_ERR & event_mask ) ) { + err = ms.mPlayer.getStreamException(); + if( null != err ) { + System.err.println("MovieSimple State: ERR + Exception"); + } else { + System.err.println("MovieSimple State: ERR"); } + destroy = true; } - if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { - final StreamException se = ms.mPlayer.getStreamException(); - if( null != se ) { - se.printStackTrace(); + if( destroy ) { + if( null != err ) { + err.printStackTrace(); } destroyWindow(); } -- cgit v1.2.3 From 166e5da5298b16b0acbf900004964d370cd0aa29 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 18 Dec 2013 21:59:39 +0100 Subject: Bug 928 - JAWTWindow's JAWTComponentListener _not_ attached and original visibility state not restored @ detach Commit ebed9f0322e2a2279a525e04ee3875c9034a7f45 (fix for Bug 906) causes a regression to fix for Bug 816, Bug 849 and Bug 889 (OSX CALayer Positioning and JAWTWindow visibility). The commit adds the JAWTComponentListener instance 'jawtComponentListener' to the component before it's assignment (duh!). +++ Further more, detaching the JAWTComponentListener shall restore the component's original 'local visibility state', which might got overridden by it's 'hierarchyChanged' implementation. +++ --- make/scripts/tests.sh | 8 ++++---- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 22 ++++++++++++++-------- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index cb60028aa..746985d83 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -192,7 +192,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" - #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" + D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" @@ -345,7 +345,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests @@ -505,8 +505,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* +##testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 9a19a7f7a..3c660b41b 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -159,20 +159,21 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, " ** THREAD "+getThreadName(); } - public JAWTComponentListener() { + private JAWTComponentListener() { if(DEBUG) { - System.err.println(jawtStr()+".attach: "+toString()); + System.err.println(jawtStr()+".attach @ Thread "+getThreadName()+": "+toString()); } - component.addComponentListener(jawtComponentListener); - component.addHierarchyListener(jawtComponentListener); + component.addComponentListener(this); + component.addHierarchyListener(this); } - public final void detach() { + private final void detach() { if(DEBUG) { - System.err.println(jawtStr()+".detach: "+toString()); + System.err.println(jawtStr()+".detach @ Thread "+getThreadName()+": "+toString()); } - component.removeComponentListener(jawtComponentListener); - component.removeHierarchyListener(jawtComponentListener); + component.removeComponentListener(this); + component.removeHierarchyListener(this); + component.setVisible(localVisibility); // restore component's original local state } @Override @@ -251,6 +252,11 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } else if(DEBUG) { System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (x): showing "+showing+" -> visible "+(showing && localVisibility)+", "+s(e)); } + } else if(DEBUG) { + final boolean displayable = changed.isDisplayable(); + final boolean _visible = displayable && localVisibility; + final boolean showing = changed.isShowing(); + System.err.println(jawtStr()+".hierarchyChanged OTHER: displayable "+displayable+", showing "+showing+" -> visible "+_visible+", "+s(e)); } } } -- cgit v1.2.3 From 0f1ddc82329835b903e31e301fcf134d1d7337be Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 19 Dec 2013 12:59:05 +0100 Subject: Bug 924: More robost Fullscreen Exit - 'tempInvisible' shall be also performed for top windows, solves Unity-WM background refresh issue - Rename local field 'fullscreen' -> '_fullscreen' to avoid confusion - Proper insets handling: Set 'WindowImpl.this.fullscreen = _fullscreen' only before reconfiguring, otherwise wrong position maybe used due to wrong insets value. Tested w/ WMs: KWin + Unity --- make/scripts/tests.sh | 7 ++-- src/newt/classes/jogamp/newt/WindowImpl.java | 50 +++++++++++++++------------- 2 files changed, 30 insertions(+), 27 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 746985d83..b680d2b25 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -93,6 +93,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" + D_ARGS="-Dnativewindow.debug=all -Dnewt.debug=all" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" @@ -192,7 +193,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" - D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" + #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" @@ -320,7 +321,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -506,7 +507,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* ##testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index aa2d264af..437179f12 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -2018,27 +2018,24 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } private class FullScreenAction implements Runnable { - boolean fullscreen; + boolean _fullscreen; private boolean init(boolean fullscreen) { if(isNativeValid()) { - this.fullscreen = fullscreen; + this._fullscreen = fullscreen; return isFullscreen() != fullscreen; } else { WindowImpl.this.fullscreen = fullscreen; // set current state for createNative(..) return false; } } - public boolean fsOn() { return fullscreen; } + public boolean fsOn() { return _fullscreen; } @Override public final void run() { final RecursiveLock _lock = windowLock; _lock.lock(); try { - // set current state - WindowImpl.this.fullscreen = fullscreen; - final int oldX = getX(); final int oldY = getY(); final int oldWidth = getWidth(); @@ -2050,7 +2047,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final RectangleImmutable viewport; final int fs_span_flag; final boolean alwaysOnTopChange; - if(fullscreen) { + if(_fullscreen) { if( null == fullscreenMonitors ) { if( fullscreenUseMainMonitor ) { fullscreenMonitors = new ArrayList(); @@ -2103,30 +2100,33 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } + + final DisplayImpl display = (DisplayImpl) screen.getDisplay(); + display.dispatchMessagesNative(); // status up2date + final boolean wasVisible = isVisible(); + final boolean tempInvisible = !_fullscreen && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true); + if(DEBUG_IMPLEMENTATION) { - System.err.println("Window fs: "+fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ + System.err.println("Window fs: "+_fullscreen+" "+x+"/"+y+" "+w+"x"+h+", "+isUndecorated()+ ", virtl-screenSize: "+sviewport+", monitorsViewport "+viewport+ ", spanning "+(0!=fs_span_flag)+ ", alwaysOnTop "+alwaysOnTop+(alwaysOnTopChange?"*":"")+ + ", wasVisible "+wasVisible+", tempInvisible "+tempInvisible+ + ", hasParent "+(null!=parentWindow)+ " @ "+Thread.currentThread().getName()); } - final DisplayImpl display = (DisplayImpl) screen.getDisplay(); - display.dispatchMessagesNative(); // status up2date - final boolean wasVisible = isVisible(); + // fullscreen off: !visible first (fixes X11 unsuccessful return to parent window _and_ wrong window size propagation) + if( tempInvisible ) { + setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); + WindowImpl.this.waitForVisible(false, false); + try { Thread.sleep(100); } catch (InterruptedException e) { } + display.dispatchMessagesNative(); // status up2date + } // Lock parentWindow only during reparenting (attempt) final NativeWindow parentWindowLocked; if( null != parentWindow ) { - // fullscreen off: !visible first (fixes X11 unsuccessful return to parent window) - if( !fullscreen && wasVisible && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { - setVisibleImpl(false, oldX, oldY, oldWidth, oldHeight); - WindowImpl.this.waitForVisible(false, false); - // FIXME: Some composite WM behave slacky .. give 'em chance to change state -> invisible, - // even though we do exactly that (KDE+Composite) - try { Thread.sleep(100); } catch (InterruptedException e) { } - display.dispatchMessagesNative(); // status up2date - } parentWindowLocked = parentWindow; if( NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindowLocked.lockSurface() ) { throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow); @@ -2135,14 +2135,16 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer parentWindowLocked = null; } try { - if(alwaysOnTopChange && fullscreen) { + if(alwaysOnTopChange && _fullscreen) { // Enter fullscreen - Disable alwaysOnTop - reconfigureWindowImpl(nfs_x, nfs_y, nfs_width, nfs_height, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); + reconfigureWindowImpl(oldX, oldY, oldWidth, oldHeight, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); } + + WindowImpl.this.fullscreen = _fullscreen; reconfigureWindowImpl(x, y, w, h, getReconfigureFlags( ( ( null != parentWindowLocked ) ? FLAG_CHANGE_PARENTING : 0 ) | fs_span_flag | FLAG_CHANGE_FULLSCREEN | FLAG_CHANGE_DECORATION, isVisible()) ); - if(alwaysOnTopChange && !fullscreen) { + if(alwaysOnTopChange && !_fullscreen) { // Leave fullscreen - Restore alwaysOnTop reconfigureWindowImpl(x, y, w, h, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); } @@ -2164,7 +2166,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer WindowImpl.this.waitForPosition(true, x, y, TIMEOUT_NATIVEWINDOW); } if(ok) { - requestFocusInt(fullscreen /* skipFocusAction if fullscreen */); + requestFocusInt(_fullscreen /* skipFocusAction if fullscreen */); display.dispatchMessagesNative(); // status up2date } if(DEBUG_IMPLEMENTATION) { -- cgit v1.2.3 From 904adbe63a806ff73ea654da6cc964277bbbb8d3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 20 Dec 2013 08:49:05 +0100 Subject: Bug 924: Make ALWAYS_ON_TOP Persistent when Reparenting (child -> top) (2nd attempt) Commit c8726ef04b94ad8e66e1191a06ff793b908d130c reinforced ALWAYS_ON_TOP in native reconfig code issued at reparenting call, which might be too early for the WM. Perform ALWAYS_ON_TOP reinforcement from java side when reparenting CHILD -> TOP was successful and visibility is reached. X11 only! NewtAWTReparentingKeyAdapter: Add 'a' alwaysOnTop toggle to test w/o applet code. --- make/scripts/tests.sh | 2 +- src/newt/classes/jogamp/newt/WindowImpl.java | 4 ++++ src/newt/native/X11Window.c | 4 ---- .../test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java | 6 ++++++ 4 files changed, 11 insertions(+), 5 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b680d2b25..57b13ab3b 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -93,7 +93,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - D_ARGS="-Dnativewindow.debug=all -Dnewt.debug=all" + D_ARGS="-Dnativewindow.debug=all -Dnewt.debug.Window" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 437179f12..d63104c71 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -1440,6 +1440,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer setVisibleImpl(true, x, y, width, height); ok = 0 <= WindowImpl.this.waitForVisible(true, false); if(ok) { + if( isAlwaysOnTop() && 0 == parentWindowHandle && NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true) ) { + // Reinforce ALWAYSONTOP when CHILD -> TOP reparenting, since reparenting itself cause X11 WM to loose it's state. + reconfigureWindowImpl(x, y, width, height, getReconfigureFlags(FLAG_CHANGE_ALWAYSONTOP, isVisible())); + } ok = WindowImpl.this.waitForSize(width, height, false, TIMEOUT_NATIVEWINDOW); } if(ok) { diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index ad17f970b..5f5dddbe0 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -822,10 +822,6 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_reconfigureWindo XSetWMProtocols(dpy, w, &wm_delete_atom, 1); // windowDeleteAtom // Fix for Unity WM, i.e. _remove_ persistent previous states NewtWindows_setStackingEWMHFlags(dpy, root, w, fsEWMHFlags, isVisible, False); - if( TST_FLAG_IS_ALWAYSONTOP(flags) ) { - // Reinforce always-on-top, lost by WM during reparenting - NewtWindows_setStackingEWMHFlags(dpy, root, w, _NET_WM_STATE_FLAG_ABOVE, isVisible, True); - } } if( TST_FLAG_CHANGE_DECORATION(flags) ) { diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index f7fbc7332..189645d3d 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -96,6 +96,12 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } } }.run(); + } else if( e.getKeySymbol() == KeyEvent.VK_A ) { + new Thread() { + public void run() { + glWindow.setAlwaysOnTop(!glWindow.isAlwaysOnTop()); + } + }.run(); } else if( e.getKeySymbol() == KeyEvent.VK_R ) { if( null != quitAdapter ) { quitAdapter.enable(false); -- cgit v1.2.3 From 972feb4be95d1c16c71b84694729952e91dda668 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 21 Dec 2013 14:40:36 +0100 Subject: Bug 925 - Accept an ES3 Context, if reported via GL-Version-String w/o EGL_OPENGL_ES3_BIT_KHR Add Quirk 'GLES3ViaEGLES2Config': ES3 Context is used via EGL_OPENGL_ES2_BIT and 'version 2' for create context attributes. - GLContextImpl.setGLFunctionAvailability(..)'s ES version validation only fails if requested major version == 1 and doesn't match. Hence requesting major==2 and having version 3 is tolerated. - GLContextImpl.setGLFunctionAvailability(..)'s Quirks: requested-major < has-major -> Adding GLES3ViaEGLES2Config - EGLDrawableFactory.mapAvailableEGLESConfig(..): Reflects has-major version, i.e. GLES3ViaEGLES2Config situation where an ES2 request leads to an ES3 version. Note: All workarounds can be found via lookup of GLES3ViaEGLES2Config (as usual when using quirks). --- make/scripts/tests.sh | 10 ++--- .../com/jogamp/opengl/GLRendererQuirks.java | 35 +++++++++++++++- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 42 ++++++++++++++++--- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 7 +++- .../jogamp/opengl/egl/EGLDrawableFactory.java | 47 +++++++++++++--------- .../opengl/egl/EGLGraphicsConfiguration.java | 27 ++++++++++--- .../egl/EGLGraphicsConfigurationFactory.java | 4 +- 7 files changed, 133 insertions(+), 39 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 57b13ab3b..682d05a54 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -93,7 +93,7 @@ function jrun() { #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all" #D_ARGS="-Djogamp.debug=all -Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" #D_ARGS="-Dnativewindow.debug=all -Djogl.debug=all -Dnewt.debug=all" - D_ARGS="-Dnativewindow.debug=all -Dnewt.debug.Window" + #D_ARGS="-Dnativewindow.debug=all -Dnewt.debug.Window" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" @@ -120,7 +120,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration" - #D_ARGS="-Djogl.debug.GLContext" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext.NoProfileAliasing" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.Animator -Djogl.debug.GLDrawable -Dnativewindow.debug.NativeWindow" @@ -307,7 +307,7 @@ function testawtswt() { #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* -#testnoawt com.jogamp.newt.opengl.GLWindow $* +testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* @@ -321,7 +321,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* @@ -506,7 +506,7 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* -##testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 95f87be29..daa0d94dd 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -31,6 +31,9 @@ import java.util.IdentityHashMap; import javax.media.nativewindow.AbstractGraphicsDevice; +import jogamp.opengl.egl.EGL; +import jogamp.opengl.egl.EGLExt; + /** * GLRendererQuirks contains information of known bugs of various GL renderer. * This information allows us to workaround them. @@ -235,15 +238,33 @@ public class GLRendererQuirks { */ public static final int GLSharedContextBuggy = 14; + /** + * Bug 925 - Accept an ES3 Context, if reported via GL-Version-String w/o {@link EGLExt#EGL_OPENGL_ES3_BIT_KHR}. + *

        + * The ES3 Context can be used via {@link EGL#EGL_OPENGL_ES2_BIT}. + *

        + *

        + * The ES3 Context {@link EGL#eglCreateContext(long, long, long, java.nio.IntBuffer) must be created} with version attributes: + *

        +     *  EGL.EGL_CONTEXT_CLIENT_VERSION, 2, ..
        +     * 
        + *

        + *
          + *
        • Mesa/AMD >= 9.2.1
        • + *
        • Some Android ES3 drivers ..
        • + *
        + */ + public static final int GLES3ViaEGLES2Config = 15; + /** Number of quirks known. */ - public static final int COUNT = 15; + public static final int COUNT = 16; private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", "GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display", "NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext", "NoFullFBOSupport", "GLSLNonCompliant", "GL4NeedsGL3Request", - "GLSharedContextBuggy" + "GLSharedContextBuggy", "GLES3ViaEGLES2Config" }; private static final IdentityHashMap stickyDeviceQuirks = new IdentityHashMap(); @@ -277,6 +298,16 @@ public class GLRendererQuirks { final GLRendererQuirks sq = getStickyDeviceQuirks(device); sq.addQuirks(quirks, offset, len); } + /** + * {@link #addQuirks(GLRendererQuirks) Adding given quirks} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}. + *

        + * Not thread safe. + *

        + */ + public static void addStickyDeviceQuirks(AbstractGraphicsDevice device, GLRendererQuirks quirks) throws IllegalArgumentException { + final GLRendererQuirks sq = getStickyDeviceQuirks(device); + sq.addQuirks(quirks); + } /** * {@link #exist(int) Query} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}. *

        diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 083a88c51..d081c4adf 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -74,6 +74,7 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLDebugListener; import javax.media.opengl.GLDebugMessage; import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLPipelineFactory; import javax.media.opengl.GLProfile; @@ -1452,12 +1453,12 @@ public abstract class GLContextImpl extends GLContext { // Strict Match (GLVersionMapping): // Relaxed match for versions ( !isES && major < 3 ) requests, last resort! // Otherwise: - // - fail if hasVersion < reqVersion - // - fail if ES major-version mismatch + // - fail if hasVersion < reqVersion (desktop and ES) + // - fail if ES 1.0 major-version mismatch // if( strictMatch && ( ( ( isES || major >= 3 ) && hasGLVersionByInt.compareTo(reqGLVersion) < 0 ) || - ( isES && major != hasGLVersionByInt.getMajor() ) + ( isES && 1 == major && major != hasGLVersionByInt.getMajor() ) ) ) { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (Int): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionByInt); @@ -1487,12 +1488,12 @@ public abstract class GLContextImpl extends GLContext { // Strict Match (GLVersionMapping): // Relaxed match for versions ( !isES && major < 3 ) requests, last resort! // Otherwise: - // - fail if hasVersion < reqVersion - // - fail if ES major-version mismatch + // - fail if hasVersion < reqVersion (desktop and ES) + // - fail if ES 1.0 major-version mismatch // if( strictMatch && ( ( ( isES || major >= 3 ) && hasGLVersionByString.compareTo(reqGLVersion) < 0 ) || - ( isES && major != hasGLVersionByString.getMajor() ) + ( isES && 1 == major && major != hasGLVersionByString.getMajor() ) ) ) { if(DEBUG) { System.err.println(getThreadName() + ": GLContext.setGLFuncAvail.X: FAIL, GL version mismatch (String): "+GLContext.getGLVersion(major, minor, ctxProfileBits, null)+" -> "+glVersion+", "+hasGLVersionByString); @@ -1661,12 +1662,41 @@ public abstract class GLContextImpl extends GLContext { final String MesaRendererIntelsp = "Intel(R)"; final boolean hwAccel = 0 == ( ctp & GLContext.CTX_IMPL_ACCEL_SOFT ); final boolean compatCtx = 0 != ( ctp & GLContext.CTX_PROFILE_COMPAT ); + final boolean esCtx = 0 != ( ctp & GLContext.CTX_PROFILE_ES ); final boolean isX11 = NativeWindowFactory.TYPE_X11 == NativeWindowFactory.getNativeWindowType(true); final boolean isWindows = Platform.getOSType() == Platform.OSType.WINDOWS; final boolean isDriverMesa = glRenderer.contains(MesaSP) || glRenderer.contains("Gallium "); final boolean isDriverATICatalyst = !isDriverMesa && ( glVendor.contains("ATI Technologies") || glRenderer.startsWith("ATI ") ); final boolean isDriverNVIDIAGeForce = !isDriverMesa && ( glVendor.contains("NVIDIA Corporation") || glRenderer.contains("NVIDIA ") ); + // + // General Quirks + // + if( esCtx ) { + final int quirk = GLRendererQuirks.GLES3ViaEGLES2Config; + if( GLRendererQuirks.existStickyDeviceQuirk( GLDrawableFactory.getEGLFactory().getDefaultDevice(), GLRendererQuirks.GLES3ViaEGLES2Config) ) { + // Merge default sticky quirk! + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Default EGL Device"); + } + quirks[i++] = quirk; + } else if( 2 == reqMajor && 2 < major ) { + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: ES req "+reqMajor+" and 2 < "+major); + } + quirks[i++] = quirk; + if( withinGLVersionsMapping ) { + // Thread safe due to single threaded initialization! + GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1); + } else { + // FIXME: Remove when moving EGL/ES to ARB ctx creation + synchronized(GLContextImpl.class) { + GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1); + } + } + } + } + // // OS related quirks // diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index b2f06dce6..967b88358 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -44,6 +44,7 @@ import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -187,7 +188,11 @@ public class EGLContext extends GLContextImpl { { if ( glProfile.usesNativeGLES3() ) { contextVersionReq = 3; - contextVersionAttr = 3; + if( GLRendererQuirks.existStickyDeviceQuirk( GLDrawableFactory.getEGLFactory().getDefaultDevice(), GLRendererQuirks.GLES3ViaEGLES2Config) ) { + contextVersionAttr = 2; + } else { + contextVersionAttr = 3; + } } else if ( glProfile.usesNativeGLES2() ) { contextVersionReq = 2; contextVersionAttr = 2; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index f7799f1ec..3c8531730 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -362,10 +362,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return new ArrayList(0); } - private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, int esProfile, + private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, int[] esProfile, boolean[] hasPBuffer, GLRendererQuirks[] rendererQuirks, int[] ctp) { final String profileString; - switch( esProfile ) { + switch( esProfile[0] ) { case 3: profileString = GLProfile.GLES3; break; case 2: @@ -413,7 +413,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if(null == defaultSharedResource) { return false; } - switch(esProfile) { + switch(esProfile[0]) { case 3: if( !defaultSharedResource.wasES3ContextCreated ) { return false; @@ -436,7 +436,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { ctp[0] = defaultSharedResource.ctpES1; break; } - EGLContext.mapStaticGLVersion(adevice, esProfile, 0, ctp[0]); + if( null != rendererQuirks[0] ) { + GLRendererQuirks.addStickyDeviceQuirks(adevice, rendererQuirks[0]); + } + EGLContext.mapStaticGLVersion(adevice, esProfile[0], 0, ctp[0]); return true; } @@ -491,6 +494,7 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } rendererQuirks[0] = context.getRendererQuirks(); ctp[0] = context.getContextOptions(); + esProfile[0] = context.getGLVersionNumber().getMajor(); success = true; } else { // Oops .. something is wrong @@ -499,10 +503,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } } } - } catch (GLException gle) { + } catch (Throwable t) { if (DEBUG) { System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: INFO: context create/makeCurrent failed"); - gle.printStackTrace(); + t.printStackTrace(); } } finally { context.destroy(); @@ -594,8 +598,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { private SharedResource createEGLSharedResourceImpl(AbstractGraphicsDevice adevice) { final boolean madeCurrentES1; - final boolean madeCurrentES2; - final boolean madeCurrentES3; boolean[] hasPBufferES1 = new boolean[] { false }; boolean[] hasPBufferES3ES2 = new boolean[] { false }; // EGLContext[] eglCtxES1 = new EGLContext[] { null }; @@ -611,18 +613,27 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } if( null != eglES1DynamicLookupHelper ) { - madeCurrentES1 = mapAvailableEGLESConfig(adevice, 1, hasPBufferES1, rendererQuirksES1, ctpES1); + final int[] esProfile = { 1 }; + madeCurrentES1 = mapAvailableEGLESConfig(adevice, esProfile, hasPBufferES1, rendererQuirksES1, ctpES1) && 1 == esProfile[0]; } else { madeCurrentES1 = false; } + boolean madeCurrentES2 = false; + boolean madeCurrentES3 = false; if( null != eglES2DynamicLookupHelper ) { - madeCurrentES3 = mapAvailableEGLESConfig(adevice, 3, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); - madeCurrentES2 = mapAvailableEGLESConfig(adevice, 2, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2); - } else { - madeCurrentES2 = false; - madeCurrentES3 = false; + // ES3 Query + final int[] esProfile = { 3 }; + madeCurrentES3 = mapAvailableEGLESConfig(adevice, esProfile, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2) && 3 == esProfile[0]; + // ES2 Query, may result in ES3 + esProfile[0] = 2; + if( mapAvailableEGLESConfig(adevice, esProfile, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2) ) { + switch( esProfile[0] ) { + case 2: madeCurrentES2 = true; break; + case 3: madeCurrentES3 = true; break; + default: throw new InternalError("XXXX Got "+esProfile[0]); + } + } } - if( !EGLContext.getAvailableGLVersionsSet(adevice) ) { // Even though we override the non EGL native mapping intentionally, // avoid exception due to double 'set' - carefull exception of the rule. @@ -640,9 +651,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } if (DEBUG) { System.err.println("EGLDrawableFactory.createShared: devices: queried nativeTK "+QUERY_EGL_ES_NATIVE_TK+", adevice " + adevice + ", defaultDevice " + defaultDevice); - System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]); - System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES3ES2[0]); - System.err.println("EGLDrawableFactory.createShared: context ES3: " + madeCurrentES3 + ", hasPBuffer "+hasPBufferES3ES2[0]); + System.err.println("EGLDrawableFactory.createShared: context ES1: " + madeCurrentES1 + ", hasPBuffer "+hasPBufferES1[0]+", quirks "+rendererQuirksES1[0]); + System.err.println("EGLDrawableFactory.createShared: context ES2: " + madeCurrentES2 + ", hasPBuffer "+hasPBufferES3ES2[0]+", quirks "+rendererQuirksES3ES2[0]); + System.err.println("EGLDrawableFactory.createShared: context ES3: " + madeCurrentES3 + ", hasPBuffer "+hasPBufferES3ES2[0]+", quirks "+rendererQuirksES3ES2[0]); dumpMap(); } return sr; diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java index 0e5551b8e..88ed0be92 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfiguration.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.VisualIDHolder; import javax.media.opengl.DefaultGLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesChooser; import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; @@ -55,6 +56,7 @@ import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.nativewindow.MutableGraphicsConfiguration; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.opengl.GLRendererQuirks; public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration implements Cloneable { @@ -94,8 +96,9 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } final long cfg = EGLConfigId2EGLConfig(dpy, eglConfigID); if(0 < cfg) { + final GLRendererQuirks defaultQuirks = GLRendererQuirks.getStickyDeviceQuirks( GLDrawableFactory.getEGLFactory().getDefaultDevice() ); final int winattrmask = GLGraphicsConfigurationUtil.getExclusiveWinAttributeBits(capsRequested); - final EGLGLCapabilities caps = EGLConfig2Capabilities((EGLGraphicsDevice)absDevice, capsRequested.getGLProfile(), cfg, winattrmask, false); + final EGLGLCapabilities caps = EGLConfig2Capabilities(defaultQuirks, (EGLGraphicsDevice)absDevice, capsRequested.getGLProfile(), cfg, winattrmask, false); return new EGLGraphicsConfiguration(absScreen, caps, capsRequested, new DefaultGLCapabilitiesChooser()); } return null; @@ -179,6 +182,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } /** + * @param defaultQuirks GLRendererQuirks of the EGLDrawableFactory's defaultDevice * @param device * @param glp desired GLProfile, may be null * @param config @@ -186,8 +190,8 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple * @param forceTransparentFlag * @return */ - public static EGLGLCapabilities EGLConfig2Capabilities(EGLGraphicsDevice device, GLProfile glp, long config, - int winattrmask, boolean forceTransparentFlag) { + public static EGLGLCapabilities EGLConfig2Capabilities(GLRendererQuirks defaultQuirks, EGLGraphicsDevice device, GLProfile glp, + long config, int winattrmask, boolean forceTransparentFlag) { final long display = device.getHandle(); final int cfgID; final int rType; @@ -232,7 +236,14 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } return null; } - rType = values.get(1); + { + final int rTypeOrig = values.get(1); + if( defaultQuirks.exist(GLRendererQuirks.GLES3ViaEGLES2Config) && 0 != ( EGL.EGL_OPENGL_ES2_BIT & rTypeOrig ) ) { + rType = rTypeOrig | EGLExt.EGL_OPENGL_ES3_BIT_KHR; + } else { + rType = rTypeOrig; + } + } if( EGL.EGL_NATIVE_VISUAL_ID == attributes.get(2) ) { visualID = values.get(2); @@ -251,7 +262,7 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple if(!EGLGLCapabilities.isCompatible(glp, rType)) { if(DEBUG) { System.err.println("config "+toHexString(config)+": Requested GLProfile "+glp+ - " not compatible with EGL-RenderableType["+EGLGLCapabilities.renderableTypeToString(null, rType)+"]"); + " with quirks "+defaultQuirks+" not compatible with EGL-RenderableType["+EGLGLCapabilities.renderableTypeToString(null, rType)+"]"); } return null; } @@ -453,7 +464,11 @@ public class EGLGraphicsConfiguration extends MutableGraphicsConfiguration imple } else if(caps.getGLProfile().usesNativeGLES2()) { attrs.put(idx++, EGL.EGL_OPENGL_ES2_BIT); } else if(caps.getGLProfile().usesNativeGLES3()) { - attrs.put(idx++, EGLExt.EGL_OPENGL_ES3_BIT_KHR); + if( GLRendererQuirks.existStickyDeviceQuirk(GLDrawableFactory.getEGLFactory().getDefaultDevice(), GLRendererQuirks.GLES3ViaEGLES2Config) ) { + attrs.put(idx++, EGL.EGL_OPENGL_ES2_BIT); + } else { + attrs.put(idx++, EGLExt.EGL_OPENGL_ES3_BIT_KHR); + } } else { attrs.put(idx++, EGL.EGL_OPENGL_BIT); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java index 568fede45..8802c3c7d 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLGraphicsConfigurationFactory.java @@ -53,6 +53,7 @@ import javax.media.opengl.GLDrawableFactory; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.opengl.GLRendererQuirks; import jogamp.opengl.GLGraphicsConfigurationFactory; import jogamp.opengl.GLGraphicsConfigurationUtil; @@ -476,9 +477,10 @@ public class EGLGraphicsConfigurationFactory extends GLGraphicsConfigurationFact } static List eglConfigs2GLCaps(EGLGraphicsDevice device, GLProfile glp, PointerBuffer configs, int num, int winattrmask, boolean forceTransparentFlag, boolean onlyFirstValid) { + final GLRendererQuirks defaultQuirks = GLRendererQuirks.getStickyDeviceQuirks( GLDrawableFactory.getEGLFactory().getDefaultDevice() ); List bucket = new ArrayList(num); for(int i=0; i Date: Sat, 21 Dec 2013 22:03:47 +0100 Subject: Bug 929 - Reflect ES3 Compatibility with ES2 - Map ES2 -> ES3 GLProfile, if available - EGLDrawableFactory: Don't query ES2 if ES3 is available - Fix queries and get methods (GL, GLContext and GLProfile): - glES3.isGLES2()==true and glES3.getGLES2()!=null - ctxES3.isGLES2()==true, - glES3Profile.isGLES2()==true - Enhance Unit test: TestGLProfile01NEWT - Test all GLProfile availability combinations based on implementing GLProfile - Test all GLProfile's isGL*() based on highest GLProfile identity - Test all GL's isGL*() based on highest GL identity. --- make/config/jogl/gl-impl-CustomJavaCode-gles3.java | 2 +- make/scripts/tests.sh | 7 +- src/jogl/classes/javax/media/opengl/GLContext.java | 10 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 6 +- src/jogl/classes/jogamp/opengl/egl/EGLContext.java | 28 +-- .../jogamp/opengl/egl/EGLDrawableFactory.java | 16 +- .../jogamp/opengl/macosx/cgl/MacOSXCGLContext.java | 2 +- .../test/junit/jogl/acore/TestGLProfile01NEWT.java | 277 ++++++++++++++++----- 8 files changed, 256 insertions(+), 92 deletions(-) (limited to 'make/scripts') diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java index 1a1d7abe3..d5ad16873 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -48,7 +48,7 @@ public final boolean isGLES1() { @Override public final boolean isGLES2() { - return !_isES3; + return true; } @Override diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 682d05a54..6cb1966d1 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -307,10 +307,12 @@ function testawtswt() { #testnoawt com.jogamp.nativewindow.NativeWindowVersion $* #testnoawt com.jogamp.opengl.JoglVersion $* #testnoawt com.jogamp.newt.NewtVersion $* -testnoawt com.jogamp.newt.opengl.GLWindow $* +#testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLVersionParsing00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* # # demos (any TK, more user driven tests) @@ -324,7 +326,6 @@ testnoawt com.jogamp.newt.opengl.GLWindow $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -380,8 +381,6 @@ testnoawt com.jogamp.newt.opengl.GLWindow $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary16NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index deb1d7587..bec62c30d 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -1109,11 +1109,15 @@ public abstract class GLContext { } /** - * Indicates whether this GLContext is capable of GLES2.

        Includes [ GLES2 ].

        + * Indicates whether this GLContext is capable of GLES2.

        Includes [ GLES2, GLES3 ].

        * @see GLProfile#isGLES2() */ public final boolean isGLES2() { - return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 2 ; + if( 0 != ( ctxOptions & CTX_PROFILE_ES ) ) { + final int major = ctxVersion.getMajor(); + return 2 == major || 3 == major; + } + return false; } /** @@ -1121,7 +1125,7 @@ public abstract class GLContext { * @see GLProfile#isGLES3() */ public final boolean isGLES3() { - return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() >= 3 ; + return 0 != ( ctxOptions & CTX_PROFILE_ES ) && ctxVersion.getMajor() == 3 ; } /** diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index 64c8a6243..1f9460f5d 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -1147,9 +1147,9 @@ public class GLProfile { return GLES1 == profile; } - /** Indicates whether this profile is capable of GLES2.

        Includes [ GLES2 ].

        */ + /** Indicates whether this profile is capable of GLES2.

        Includes [ GLES2, GLES3 ].

        */ public final boolean isGLES2() { - return GLES2 == profile; + return isGLES3() || GLES2 == profile; } /** Indicates whether this profile is capable of GLES3.

        Includes [ GLES3 ].

        */ @@ -1157,7 +1157,7 @@ public class GLProfile { return GLES3 == profile; } - /** Indicates whether this profile is capable of GLES.

        Includes [ GLES3, GLES1, GLES2 ].

        */ + /** Indicates whether this profile is capable of GLES.

        Includes [ GLES1, GLES2, GLES3 ].

        */ public final boolean isGLES() { return GLES3 == profile || GLES2 == profile || GLES1 == profile; } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java index 967b88358..f89ded4f6 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLContext.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLContext.java @@ -319,27 +319,23 @@ public class EGLContext extends GLContextImpl { } mapStaticGLVersion(device, reqMajorCTP[0], 0, reqMajorCTP[1]); } - /* pp */ static void mapStaticGLESVersion(AbstractGraphicsDevice device, final int major) { - int ctp = GLContext.CTX_PROFILE_ES; - if( major >= 3 ) { - ctp |= GLContext.CTX_IMPL_ES3_COMPAT | GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; - } else if( major >= 2 ) { - ctp |= GLContext.CTX_IMPL_ES2_COMPAT | GLContext.CTX_IMPL_FBO ; - } - mapStaticGLVersion(device, major, 0, ctp); - } /* pp */ static void mapStaticGLVersion(AbstractGraphicsDevice device, int major, int minor, int ctp) { if( 0 != ( ctp & GLContext.CTX_PROFILE_ES) ) { - // ES1 or ES2 - final int reqMajor = major; - final int reqProfile = GLContext.CTX_PROFILE_ES; - GLContext.mapAvailableGLVersion(device, reqMajor, reqProfile, major, minor, ctp); - if(! ( device instanceof EGLGraphicsDevice ) ) { - final EGLGraphicsDevice eglDevice = new EGLGraphicsDevice(device.getHandle(), EGL.EGL_NO_DISPLAY, device.getConnection(), device.getUnitID(), null); - GLContext.mapAvailableGLVersion(eglDevice, reqMajor, reqProfile, major, minor, ctp); + // ES1, ES2, ES3, .. + mapStaticGLVersion(device, major /* reqMajor */, major, minor, ctp); + if( 3 == major ) { + // map ES2 -> ES3 + mapStaticGLVersion(device, 2 /* reqMajor */, major, minor, ctp); } } } + private static void mapStaticGLVersion(AbstractGraphicsDevice device, int reqMajor, int major, int minor, int ctp) { + GLContext.mapAvailableGLVersion(device, reqMajor, GLContext.CTX_PROFILE_ES, major, minor, ctp); + if(! ( device instanceof EGLGraphicsDevice ) ) { + final EGLGraphicsDevice eglDevice = new EGLGraphicsDevice(device.getHandle(), EGL.EGL_NO_DISPLAY, device.getConnection(), device.getUnitID(), null); + GLContext.mapAvailableGLVersion(eglDevice, reqMajor, GLContext.CTX_PROFILE_ES, major, minor, ctp); + } + } protected static String getGLVersion(int major, int minor, int ctp, String gl_version) { return GLContext.getGLVersion(major, minor, ctp, gl_version); } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 3c8531730..1ff16fff8 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -624,13 +624,15 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // ES3 Query final int[] esProfile = { 3 }; madeCurrentES3 = mapAvailableEGLESConfig(adevice, esProfile, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2) && 3 == esProfile[0]; - // ES2 Query, may result in ES3 - esProfile[0] = 2; - if( mapAvailableEGLESConfig(adevice, esProfile, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2) ) { - switch( esProfile[0] ) { - case 2: madeCurrentES2 = true; break; - case 3: madeCurrentES3 = true; break; - default: throw new InternalError("XXXX Got "+esProfile[0]); + if( !madeCurrentES3 ) { + // ES2 Query, may result in ES3 + esProfile[0] = 2; + if( mapAvailableEGLESConfig(adevice, esProfile, hasPBufferES3ES2, rendererQuirksES3ES2, ctpES3ES2) ) { + switch( esProfile[0] ) { + case 2: madeCurrentES2 = true; break; + case 3: madeCurrentES3 = true; break; + default: throw new InternalError("XXXX Got "+esProfile[0]); + } } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 0d231b89d..259c70641 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -291,7 +291,7 @@ public class MacOSXCGLContext extends GLContextImpl final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) drawable.getNativeSurface().getGraphicsConfiguration(); final GLCapabilitiesImmutable capabilitiesChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities(); final GLProfile glp = capabilitiesChosen.getGLProfile(); - if( glp.isGLES1() || glp.isGLES2() || glp.isGLES3() || + if( glp.isGLES() || ( glp.isGL3() && !isLionOrLater ) || ( glp.isGL4() && !isMavericksOrLater ) ) { throw new GLException("OpenGL profile not supported on MacOSX "+Platform.getOSVersionNumber()+": "+glp); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java index 462934c92..42fde4b49 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLProfile01NEWT.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,184 +20,347 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.jogl.acore; import java.io.IOException; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLContext; +import javax.media.opengl.GLDrawableFactory; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + import org.junit.Assert; -import org.junit.Test; import org.junit.FixMethodOrder; +import org.junit.Test; import org.junit.runners.MethodSorters; -import javax.media.opengl.*; - import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; import com.jogamp.nativewindow.NativeWindowVersion; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.test.junit.util.DumpGLInfo; +import com.jogamp.newt.NewtVersion; +import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.JoglVersion; -import com.jogamp.newt.opengl.*; -import com.jogamp.newt.*; +import com.jogamp.opengl.test.junit.util.UITestCase; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestGLProfile01NEWT extends UITestCase { @Test - public void testVersion() throws InterruptedException { + public void test00Version() throws InterruptedException { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); System.err.println(NativeWindowVersion.getInstance()); System.err.println(JoglVersion.getInstance()); System.err.println(NewtVersion.getInstance()); - System.err.println(JoglVersion.getDefaultOpenGLInfo(null, null, true).toString()); + System.err.println(JoglVersion.getDefaultOpenGLInfo(GLDrawableFactory.getDesktopFactory().getDefaultDevice(), null, true).toString()); + System.err.println(JoglVersion.getDefaultOpenGLInfo(GLDrawableFactory.getEGLFactory().getDefaultDevice(), null, true).toString()); } - @Test - public void testGLProfileDefault() throws InterruptedException { - System.out.println("GLProfile "+GLProfile.glAvailabilityToString()); - System.out.println("GLProfile.getDefaultDevice(): "+GLProfile.getDefaultDevice()); - GLProfile glp = GLProfile.getDefault(); - System.out.println("GLProfile.getDefault(): "+glp); - if(glp.getName().equals(GLProfile.GL4bc)) { + static void validate(GLProfile glp) { + if( glp.getImplName().equals(GLProfile.GL4bc) ) { Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4bc)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL3bc)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2GL3)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4ES3)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES1)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); - } else if(glp.getName().equals(GLProfile.GL3bc)) { + } else if(glp.getImplName().equals(GLProfile.GL3bc)) { Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL3bc)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL3)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2GL3)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES1)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); - } else if(glp.getName().equals(GLProfile.GL2)) { + } else if(glp.getImplName().equals(GLProfile.GL2)) { Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2GL3)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES1)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); - } else if(glp.getName().equals(GLProfile.GL2ES1)) { + } else if(glp.getImplName().equals(GLProfile.GL4)) { + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL3)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2GL3)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4ES3)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); + } else if(glp.getImplName().equals(GLProfile.GL3)) { + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL3)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2GL3)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); + } else if(glp.getImplName().equals(GLProfile.GLES3)) { + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GLES3)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4ES3)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); + } else if(glp.getImplName().equals(GLProfile.GLES2)) { + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GLES2)); + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); + } else if(glp.getImplName().equals(GLProfile.GLES1)) { + Assert.assertTrue(GLProfile.isAvailable(GLProfile.GLES1)); Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES1)); } + if( glp.isGL4bc() ) { + Assert.assertTrue(glp.isGL4()); + Assert.assertTrue(glp.isGL3bc()); + Assert.assertTrue(glp.isGL3()); + Assert.assertTrue(glp.isGL2()); + Assert.assertTrue(glp.isGL2GL3()); + Assert.assertTrue(glp.isGL4ES3()); + Assert.assertTrue(glp.isGL3ES3()); + Assert.assertTrue(glp.isGL2ES1()); + Assert.assertTrue(glp.isGL2ES2()); + } else if(glp.isGL3bc()) { + Assert.assertTrue(glp.isGL3()); + Assert.assertTrue(glp.isGL2()); + Assert.assertTrue(glp.isGL2GL3()); + Assert.assertTrue(glp.isGL2ES1()); + Assert.assertTrue(glp.isGL2ES2()); + } else if(glp.isGL2()) { + Assert.assertTrue(glp.isGL2GL3()); + Assert.assertTrue(glp.isGL2ES1()); + Assert.assertTrue(glp.isGL2ES2()); + } else if(glp.isGL4()) { + Assert.assertTrue(glp.isGL3()); + Assert.assertTrue(glp.isGL2GL3()); + Assert.assertTrue(glp.isGL4ES3()); + Assert.assertTrue(glp.isGL3ES3()); + Assert.assertTrue(glp.isGL2ES2()); + } else if(glp.isGL3()) { + Assert.assertTrue(glp.isGL2GL3()); + Assert.assertTrue(glp.isGL3ES3()); + Assert.assertTrue(glp.isGL2ES2()); + } else if(glp.isGLES3()) { + Assert.assertTrue(glp.isGL4ES3()); + Assert.assertTrue(glp.isGL3ES3()); + Assert.assertTrue(glp.isGL2ES2()); + } else if(glp.isGLES2()) { + Assert.assertTrue(glp.isGL2ES2()); + } else if(glp.isGLES1()) { + Assert.assertTrue(glp.isGL2ES1()); + } + } + + static void validate(GL gl) { + if( gl.isGL4bc() ) { + Assert.assertTrue(gl.isGL4()); + Assert.assertTrue(gl.isGL3bc()); + Assert.assertTrue(gl.isGL3()); + Assert.assertTrue(gl.isGL2()); + Assert.assertTrue(gl.isGL2GL3()); + Assert.assertTrue(gl.isGL4ES3()); + Assert.assertTrue(gl.isGL3ES3()); + Assert.assertTrue(gl.isGL2ES1()); + Assert.assertTrue(gl.isGL2ES2()); + } else if(gl.isGL3bc()) { + Assert.assertTrue(gl.isGL3()); + Assert.assertTrue(gl.isGL2()); + Assert.assertTrue(gl.isGL2GL3()); + Assert.assertTrue(gl.isGL2ES1()); + Assert.assertTrue(gl.isGL2ES2()); + } else if(gl.isGL2()) { + Assert.assertTrue(gl.isGL2GL3()); + Assert.assertTrue(gl.isGL2ES1()); + Assert.assertTrue(gl.isGL2ES2()); + } else if(gl.isGL4()) { + Assert.assertTrue(gl.isGL3()); + Assert.assertTrue(gl.isGL2GL3()); + Assert.assertTrue(gl.isGL4ES3()); + Assert.assertTrue(gl.isGL3ES3()); + Assert.assertTrue(gl.isGL2ES2()); + } else if(gl.isGL3()) { + Assert.assertTrue(gl.isGL2GL3()); + Assert.assertTrue(gl.isGL3ES3()); + Assert.assertTrue(gl.isGL2ES2()); + } else if(gl.isGLES3()) { + Assert.assertTrue(gl.isGL4ES3()); + Assert.assertTrue(gl.isGL3ES3()); + Assert.assertTrue(gl.isGL2ES2()); + } else if(gl.isGLES2()) { + Assert.assertTrue(gl.isGL2ES2()); + } else if(gl.isGLES1()) { + Assert.assertTrue(gl.isGL2ES1()); + } + + final GLContext ctx = gl.getContext(); + if( ctx.isGL4bc() ) { + Assert.assertTrue(ctx.isGL4()); + Assert.assertTrue(ctx.isGL3bc()); + Assert.assertTrue(ctx.isGL3()); + Assert.assertTrue(ctx.isGL2()); + Assert.assertTrue(ctx.isGL2GL3()); + Assert.assertTrue(ctx.isGL4ES3()); + Assert.assertTrue(ctx.isGL3ES3()); + Assert.assertTrue(ctx.isGL2ES1()); + Assert.assertTrue(ctx.isGL2ES2()); + } else if(ctx.isGL3bc()) { + Assert.assertTrue(ctx.isGL3()); + Assert.assertTrue(ctx.isGL2()); + Assert.assertTrue(ctx.isGL2GL3()); + Assert.assertTrue(ctx.isGL2ES1()); + Assert.assertTrue(ctx.isGL2ES2()); + } else if(ctx.isGL2()) { + Assert.assertTrue(ctx.isGL2GL3()); + Assert.assertTrue(ctx.isGL2ES1()); + Assert.assertTrue(ctx.isGL2ES2()); + } else if(ctx.isGL4()) { + Assert.assertTrue(ctx.isGL3()); + Assert.assertTrue(ctx.isGL2GL3()); + Assert.assertTrue(ctx.isGL4ES3()); + Assert.assertTrue(ctx.isGL3ES3()); + Assert.assertTrue(ctx.isGL2ES2()); + } else if(ctx.isGL3()) { + Assert.assertTrue(ctx.isGL2GL3()); + Assert.assertTrue(ctx.isGL3ES3()); + Assert.assertTrue(ctx.isGL2ES2()); + } else if(ctx.isGLES3()) { + Assert.assertTrue(ctx.isGL4ES3()); + Assert.assertTrue(ctx.isGL3ES3()); + Assert.assertTrue(ctx.isGL2ES2()); + } else if(ctx.isGLES2()) { + Assert.assertTrue(ctx.isGL2ES2()); + } else if(ctx.isGLES1()) { + Assert.assertTrue(ctx.isGL2ES1()); + } + } + + @Test + public void test01GLProfileDefault() throws InterruptedException { + System.out.println("GLProfile "+GLProfile.glAvailabilityToString()); + System.out.println("GLProfile.getDefaultDevice(): "+GLProfile.getDefaultDevice()); + GLProfile glp = GLProfile.getDefault(); + System.out.println("GLProfile.getDefault(): "+glp); + validate(glp); dumpVersion(glp); } @Test - public void testGLProfileMaxProgrammable() throws InterruptedException { + public void test02GLProfileMaxProgrammable() throws InterruptedException { // Assuming at least one programmable profile is available GLProfile glp = GLProfile.getMaxProgrammable(true); System.out.println("GLProfile.getMaxProgrammable(): "+glp); - if(glp.getName().equals(GLProfile.GL4)) { - Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL4)); - Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL3)); - Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); - } else if(glp.getName().equals(GLProfile.GL3)) { - Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL3)); - Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); - } else if(glp.getName().equals(GLProfile.GL2ES2)) { - Assert.assertTrue(GLProfile.isAvailable(GLProfile.GL2ES2)); - } + validate(glp); dumpVersion(glp); } @Test - public void testGLProfileGL2ES1() throws InterruptedException { + public void test03GLProfileMaxFixedFunc() throws InterruptedException { + // Assuming at least one fixed function profile is available + GLProfile glp = GLProfile.getMaxFixedFunc(true); + System.out.println("GLProfile.getMaxFixedFunc(): "+glp); + validate(glp); + dumpVersion(glp); + } + + @Test + public void test04GLProfileGL2ES1() throws InterruptedException { if(!GLProfile.isAvailable(GLProfile.GL2ES1)) { System.out.println("GLProfile GL2ES1 n/a"); return; } GLProfile glp = GLProfile.getGL2ES1(); System.out.println("GLProfile GL2ES1: "+glp); + validate(glp); dumpVersion(glp); } @Test - public void testGLProfileGL2ES2() throws InterruptedException { + public void test05GLProfileGL2ES2() throws InterruptedException { if(!GLProfile.isAvailable(GLProfile.GL2ES2)) { System.out.println("GLProfile GL2ES2 n/a"); return; } GLProfile glp = GLProfile.getGL2ES2(); System.out.println("GLProfile GL2ES2: "+glp); + validate(glp); dumpVersion(glp); } @Test - public void testGLProfileGL4ES3() throws InterruptedException { + public void test06GLProfileGL4ES3() throws InterruptedException { if(!GLProfile.isAvailable(GLProfile.GL4ES3)) { System.out.println("GLProfile GL4ES3 n/a"); return; } GLProfile glp = GLProfile.getGL4ES3(); System.out.println("GLProfile GL4ES3: "+glp); + validate(glp); dumpVersion(glp); } - + void testSpecificProfile(String glps) throws InterruptedException { if(GLProfile.isAvailable(glps)) { GLProfile glp = GLProfile.get(glps); + validate(glp); dumpVersion(glp); } else { System.err.println("Profile "+glps+" n/a"); } } - + @Test - public void testGL4bc() throws InterruptedException { + public void test10_GL4bc() throws InterruptedException { testSpecificProfile(GLProfile.GL4bc); } @Test - public void testGL3bc() throws InterruptedException { + public void test11_GL3bc() throws InterruptedException { testSpecificProfile(GLProfile.GL3bc); } @Test - public void testGL2() throws InterruptedException { + public void test12_GL2() throws InterruptedException { testSpecificProfile(GLProfile.GL2); } - + @Test - public void testGL4() throws InterruptedException { + public void test13_GL4() throws InterruptedException { testSpecificProfile(GLProfile.GL4); } @Test - public void testGL3() throws InterruptedException { + public void test14_GL3() throws InterruptedException { testSpecificProfile(GLProfile.GL3); } @Test - public void testGLES1() throws InterruptedException { + public void test15_GLES1() throws InterruptedException { testSpecificProfile(GLProfile.GLES1); } @Test - public void testGLES2() throws InterruptedException { + public void test16_GLES2() throws InterruptedException { testSpecificProfile(GLProfile.GLES2); } - + @Test - public void testGLES3() throws InterruptedException { + public void test17_GLES3() throws InterruptedException { testSpecificProfile(GLProfile.GLES3); } - + protected void dumpVersion(GLProfile glp) throws InterruptedException { - GLCapabilities caps = new GLCapabilities(glp); + GLCapabilities caps = new GLCapabilities(glp); GLWindow glWindow = GLWindow.create(caps); Assert.assertNotNull(glWindow); glWindow.setTitle("TestGLProfile01NEWT"); - glWindow.addGLEventListener(new DumpGLInfo()); glWindow.addGLEventListener(new GLEventListener() { - + public void init(GLAutoDrawable drawable) { final GL gl = drawable.getGL(); + System.err.println(JoglVersion.getGLStrings(gl, null, false)); + + validate(gl); + final GLProfile glp = gl.getGLProfile(); System.err.println("GL impl. class "+gl.getClass().getName()); if( gl.isGL4() ) { @@ -237,13 +400,13 @@ public class TestGLProfile01NEWT extends UITestCase { System.err.println("GL Mapping "+glp+" -> GL2ES1"); } } - + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } - + public void display(GLAutoDrawable drawable) { } - + public void dispose(GLAutoDrawable drawable) { } }); -- cgit v1.2.3 From d066602cf50f54f83b22b1b2c214100f1c34cc35 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 30 Dec 2013 21:30:04 +0100 Subject: OSX Test Scripts: Use dedicated location for libav/ffmpeg libraries for DYLD_LIBRARY_PATH '/usr/local/lib' may cause hacoc w/ other preinstalled libs, see: http://forum.jogamp.org/JTabbedPane-Canvas3D-bug-tp4030983p4031081.html --- make/scripts/tests-osx-x64-custom.sh | 2 +- make/scripts/tests-osx-x64-java6.sh | 2 +- make/scripts/tests-osx-x64.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-osx-x64-custom.sh b/make/scripts/tests-osx-x64-custom.sh index 88587f086..16a56285b 100755 --- a/make/scripts/tests-osx-x64-custom.sh +++ b/make/scripts/tests-osx-x64-custom.sh @@ -1,6 +1,6 @@ #! /bin/bash -export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=/usr/local/libav:$DYLD_LIBRARY_PATH spath=`dirname $0` diff --git a/make/scripts/tests-osx-x64-java6.sh b/make/scripts/tests-osx-x64-java6.sh index fe2d2c4ec..b8190f0d7 100755 --- a/make/scripts/tests-osx-x64-java6.sh +++ b/make/scripts/tests-osx-x64-java6.sh @@ -1,6 +1,6 @@ #! /bin/bash -export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=/usr/local/libav:$DYLD_LIBRARY_PATH JAVA_HOME=`/usr/libexec/java_home -version 1.6` PATH=$JAVA_HOME/bin:$PATH diff --git a/make/scripts/tests-osx-x64.sh b/make/scripts/tests-osx-x64.sh index 1204b8a7b..5d9cd6f66 100755 --- a/make/scripts/tests-osx-x64.sh +++ b/make/scripts/tests-osx-x64.sh @@ -1,6 +1,6 @@ #! /bin/bash -export DYLD_LIBRARY_PATH=/usr/local/lib:$DYLD_LIBRARY_PATH +export DYLD_LIBRARY_PATH=/usr/local/libav:$DYLD_LIBRARY_PATH JAVA_HOME=`/usr/libexec/java_home -version 1.7` #JAVA_HOME=`/usr/libexec/java_home -version 1.7.0_25` -- cgit v1.2.3 From e7ffa68bce9bb707005be72530b207c732f62c31 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 31 Dec 2013 08:14:21 +0100 Subject: Bug 934, Bug 935: NEWT: Add support for custom Application/Window and Pointer Icons - Utilizing JOGL's PNG decoder for all icons, if available. - Application/window icons: - Providing default application/window icons in 16x16 and 32x32 size - NewtFactory.setWindowIcons(..) or property 'newt.window.icons' maybe used to override default icons. - Using icons at application/window instantiation - Display.PointerIcons: - NativeWindow Win32 WindowClass no more references a default cursor in favor of fine grained cursor control [in NEWT] - Display provides create/destroy methods, where display destruction also releases open PointerIcon references. - Window.setPointerIcon(..) sets custom PointerIcon - Implemented Platforms - X11 - Windows - OSX - Manual Test: TestGearsES2NEWT (Press 'c') --- make/build-jogl.xml | 2 +- make/build-newt.xml | 12 +- .../resources/assets-test/jogamp-pointer-64x64.png | Bin 0 -> 2843 bytes make/resources/assets/newt/data/jogamp-16x16.png | Bin 0 -> 549 bytes make/resources/assets/newt/data/jogamp-32x32.png | Bin 0 -> 1020 bytes make/resources/misc/jogamp-48x48.png | Bin 0 -> 1278 bytes make/resources/misc/jogamp-64x64.png | Bin 0 -> 1833 bytes make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 3 +- make/scripts/tests.sh | 5 +- src/nativewindow/native/win32/GDImisc.c | 2 +- src/newt/classes/com/jogamp/newt/Display.java | 50 +++++++- src/newt/classes/com/jogamp/newt/NewtFactory.java | 33 +++++ src/newt/classes/com/jogamp/newt/Window.java | 15 +++ .../classes/com/jogamp/newt/opengl/GLWindow.java | 11 ++ src/newt/classes/jogamp/newt/DisplayImpl.java | 68 +++++++++- src/newt/classes/jogamp/newt/WindowImpl.java | 22 ++++ src/newt/classes/jogamp/newt/driver/PNGIcon.java | 102 +++++++++++++++ .../jogamp/newt/driver/macosx/DisplayDriver.java | 51 ++++++++ .../jogamp/newt/driver/macosx/WindowDriver.java | 11 ++ .../jogamp/newt/driver/opengl/JoglUtilPNGIcon.java | 139 +++++++++++++++++++++ .../jogamp/newt/driver/windows/DisplayDriver.java | 38 ++++++ .../jogamp/newt/driver/windows/WindowDriver.java | 56 +++++++-- .../jogamp/newt/driver/x11/DisplayDriver.java | 46 +++++++ .../jogamp/newt/driver/x11/WindowDriver.java | 51 +++++++- src/newt/native/MacWindow.m | 73 ++++++++++- src/newt/native/NewtMacWindow.h | 4 +- src/newt/native/NewtMacWindow.m | 41 ++++-- src/newt/native/WindowsWindow.c | 115 ++++++++++++++++- src/newt/native/X11Display.c | 52 ++++++++ src/newt/native/X11Window.c | 35 +++++- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 29 ++++- 32 files changed, 1027 insertions(+), 43 deletions(-) create mode 100644 make/resources/assets-test/jogamp-pointer-64x64.png create mode 100644 make/resources/assets/newt/data/jogamp-16x16.png create mode 100644 make/resources/assets/newt/data/jogamp-32x32.png create mode 100644 make/resources/misc/jogamp-48x48.png create mode 100644 make/resources/misc/jogamp-64x64.png create mode 100644 src/newt/classes/jogamp/newt/driver/PNGIcon.java create mode 100644 src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java (limited to 'make/scripts') diff --git a/make/build-jogl.xml b/make/build-jogl.xml index 28b738b10..4cdb93f4d 100644 --- a/make/build-jogl.xml +++ b/make/build-jogl.xml @@ -1833,7 +1833,7 @@ - + + value="com/jogamp/newt/opengl/** jogamp/newt/driver/opengl/**"/> @@ -277,12 +277,14 @@ + + @@ -302,6 +304,7 @@ + @@ -309,6 +312,7 @@ + @@ -316,6 +320,7 @@ + @@ -323,6 +328,7 @@ + @@ -332,18 +338,21 @@ + + + @@ -798,6 +807,7 @@ + diff --git a/make/resources/assets-test/jogamp-pointer-64x64.png b/make/resources/assets-test/jogamp-pointer-64x64.png new file mode 100644 index 000000000..a965dcab1 Binary files /dev/null and b/make/resources/assets-test/jogamp-pointer-64x64.png differ diff --git a/make/resources/assets/newt/data/jogamp-16x16.png b/make/resources/assets/newt/data/jogamp-16x16.png new file mode 100644 index 000000000..02df8997f Binary files /dev/null and b/make/resources/assets/newt/data/jogamp-16x16.png differ diff --git a/make/resources/assets/newt/data/jogamp-32x32.png b/make/resources/assets/newt/data/jogamp-32x32.png new file mode 100644 index 000000000..ab21c6e1b Binary files /dev/null and b/make/resources/assets/newt/data/jogamp-32x32.png differ diff --git a/make/resources/misc/jogamp-48x48.png b/make/resources/misc/jogamp-48x48.png new file mode 100644 index 000000000..216f8c0b7 Binary files /dev/null and b/make/resources/misc/jogamp-48x48.png differ diff --git a/make/resources/misc/jogamp-64x64.png b/make/resources/misc/jogamp-64x64.png new file mode 100644 index 000000000..9936616ca Binary files /dev/null and b/make/resources/misc/jogamp-64x64.png differ diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index f5417bf7a..d95b0025f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,7 +6,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 @@ -39,7 +39,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index 6e8407f3e..ce2df922c 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -55,9 +55,10 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Djogl.gljpanel.noverticalflip" +set D_ARGS="-Dnewt.debug=all" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" -set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.EDT" +REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.EDT" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" REM set D_ARGS="-Dnewt.debug.Window.MouseEvent" "-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6cb1966d1..4c084d705 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -312,7 +312,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLCanvasAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile00NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* # # demos (any TK, more user driven tests) @@ -325,7 +325,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -636,6 +636,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.ToolPNG2CSource $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* diff --git a/src/nativewindow/native/win32/GDImisc.c b/src/nativewindow/native/win32/GDImisc.c index b55988c11..25b98acf3 100644 --- a/src/nativewindow/native/win32/GDImisc.c +++ b/src/nativewindow/native/win32/GDImisc.c @@ -263,7 +263,7 @@ Java_jogamp_nativewindow_windows_GDIUtil_CreateWindowClass0 wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = NULL; - wc.hCursor = LoadCursor( NULL, IDC_ARROW); + wc.hCursor = NULL; wc.hbrBackground = NULL; // no background paint - GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = clazzName; diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 4469189a8..ee6dfd080 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -28,15 +28,21 @@ package com.jogamp.newt; -import com.jogamp.newt.util.EDTUtil; -import jogamp.newt.Debug; - +import java.io.IOException; import java.lang.ref.WeakReference; -import java.util.*; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import jogamp.newt.Debug; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.newt.util.EDTUtil; + public abstract class Display { public static final boolean DEBUG = Debug.debug("Display"); @@ -55,6 +61,42 @@ public abstract class Display { return false; } + /** + * Native PointerIcon handle. + *

        + * Instances can be created via {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int)} + * and released via {@link Display#destroyPointerIcon(PointerIcon)}. + *

        + *

        + * PointerIcons can be used via {@link Window#setPointerIcon(PointerIcon)}. + *

        + */ + public static interface PointerIcon { } + + /** + * Returns the created {@link PointerIcon} or null if not implemented on platform. + * + * @param pngResource PNG resource + * @param hotX pointer hotspot x-coord, origin is upper-left corner + * @param hotY pointer hotspot y-coord, origin is upper-left corner + * @throws MalformedURLException + * @throws InterruptedException + * @throws IOException + * + * @see PointerIcon + * @see #destroyPointerIcon(PointerIcon) + * @see Window#setPointerIcon(PointerIcon) + */ + + public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException; + + /** + * @param pi + * + * @see #createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) + */ + public abstract void destroyPointerIcon(PointerIcon pi); + /** * Manual trigger the native creation, if it is not done yet.
        * This is useful to be able to request the {@link javax.media.nativewindow.AbstractGraphicsDevice}, via diff --git a/src/newt/classes/com/jogamp/newt/NewtFactory.java b/src/newt/classes/com/jogamp/newt/NewtFactory.java index 157e2bb3c..92339ea73 100644 --- a/src/newt/classes/com/jogamp/newt/NewtFactory.java +++ b/src/newt/classes/com/jogamp/newt/NewtFactory.java @@ -36,6 +36,7 @@ package com.jogamp.newt; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.Arrays; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -44,6 +45,8 @@ import javax.media.nativewindow.CapabilitiesImmutable; import javax.media.nativewindow.NativeWindow; import javax.media.nativewindow.NativeWindowFactory; +import com.jogamp.common.util.IOUtil; + import jogamp.newt.Debug; import jogamp.newt.DisplayImpl; import jogamp.newt.ScreenImpl; @@ -54,15 +57,45 @@ public class NewtFactory { public static final String DRIVER_DEFAULT_ROOT_PACKAGE = "jogamp.newt.driver"; + private static IOUtil.ClassResources defaultWindowIcons; + static { AccessController.doPrivileged(new PrivilegedAction() { @Override public Object run() { NativeWindowFactory.initSingleton(); // last resort .. + { + final String[] paths = Debug.getProperty("newt.window.icons", true, "newt/data/jogamp-16x16.png newt/data/jogamp-32x32.png").split("\\s"); + if( paths.length < 2 ) { + throw new IllegalArgumentException("Property 'newt.window.icons' did not specify at least two PNG icons, but "+Arrays.toString(paths)); + } + final Class clazz = NewtFactory.class; + defaultWindowIcons = new IOUtil.ClassResources(clazz, paths); + } return null; } } ); } + /** + * Returns the application window icon resources to be used. + *

        + * Property newt.window.icons may define a list of PNG icons separated by a whitespace character. + * Shall reference at least two PNG icons, from lower (16x16) to higher (>= 32x32) resolution. + *

        + *

        + * Users may also specify application window icons using {@link #setWindowIcons(com.jogamp.common.util.IOUtil.ClassResources)}. + *

        + */ + public static IOUtil.ClassResources getWindowIcons() { return defaultWindowIcons; } + + /** + * Allow user to set custom window icons, only applicable at application start before creating any NEWT instance. + *

        + * Shall reference at least two PNG icons, from lower (16x16) to higher (>= 32x32) resolution. + *

        + */ + public static void setWindowIcons(IOUtil.ClassResources cres) { defaultWindowIcons = cres; } + public static Class getCustomClass(String packageName, String classBaseName) { Class clazz = null; if(packageName!=null && classBaseName!=null) { diff --git a/src/newt/classes/com/jogamp/newt/Window.java b/src/newt/classes/com/jogamp/newt/Window.java index 5c3bb7889..8e73ba1d2 100644 --- a/src/newt/classes/com/jogamp/newt/Window.java +++ b/src/newt/classes/com/jogamp/newt/Window.java @@ -30,6 +30,7 @@ package com.jogamp.newt; import java.util.List; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.WindowEvent; import com.jogamp.newt.event.WindowListener; @@ -307,6 +308,20 @@ public interface Window extends NativeWindow, WindowClosingProtocol { */ void setPointerVisible(boolean pointerVisible); + /** + * Returns the current {@link PointerIcon}, which maybe null for the default. + * @see #setPointerIcon(PointerIcon) + */ + PointerIcon getPointerIcon(); + + /** + * @param pi Valid {@link PointerIcon} reference or null to reset the pointer icon to default. + * + * @see PointerIcon + * @see Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) + */ + void setPointerIcon(final PointerIcon pi); + /** @see #confinePointer(boolean) */ boolean isPointerConfined(); diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 208602aa1..ca8ab6733 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -77,6 +77,7 @@ import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.Window; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.event.GestureHandler; import com.jogamp.newt.event.KeyListener; import com.jogamp.newt.event.MouseListener; @@ -267,6 +268,16 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind window.setPointerVisible(mouseVisible); } + @Override + public final PointerIcon getPointerIcon() { + return window.getPointerIcon(); + } + + @Override + public final void setPointerIcon(final PointerIcon pi) { + window.setPointerIcon(pi); + } + @Override public final boolean isPointerConfined() { return window.isPointerConfined(); diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 0c29d772a..4e9b8b441 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -34,14 +34,18 @@ package jogamp.newt; +import com.jogamp.common.util.IOUtil; import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.NEWTEvent; import com.jogamp.newt.event.NEWTEventConsumer; import jogamp.newt.event.NEWTEventTask; + import com.jogamp.newt.util.EDTUtil; +import java.io.IOException; +import java.net.MalformedURLException; import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -62,6 +66,67 @@ public abstract class DisplayImpl extends Display { }); } + public static class PointerIconImpl implements PointerIcon { + public final long handle; + public PointerIconImpl(long handle) { + this.handle=handle; + } + } + + private void addPointerIconToList(final PointerIcon pi) { + synchronized(pointerIconList) { + pointerIconList.add(pi); + } + } + private void delPointerIconFromList(final PointerIcon pi) { + synchronized(pointerIconList) { + pointerIconList.remove(pi); + } + } + private final ArrayList pointerIconList = new ArrayList(); + + /** Executed from EDT! */ + private void destroyAllPointerIconFromList(final long dpy) { + synchronized(pointerIconList) { + for( int i=0; i < pointerIconList.size(); i++ ) { + final PointerIcon item = pointerIconList.get(i); + if( null != item ) { + // destroy! + destroyPointerIconImpl(dpy, item); + } + } + pointerIconList.clear(); + } + } + + @Override + public final PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + final PointerIcon res = createPointerIconImpl(pngResource, hotX, hotY); + addPointerIconToList(res); + return res; + } + protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + return null; + } + + @Override + public final void destroyPointerIcon(final PointerIcon pi) { + delPointerIconFromList(pi); + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override + public Object run(long dpy) { + try { + destroyPointerIconImpl(dpy, pi); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + }); + } + /** Executed from EDT! */ + protected void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { } + /** Ensure static init has been run. */ /* pp */static void initSingleton() { } @@ -283,6 +348,7 @@ public abstract class DisplayImpl extends Display { @Override public void run() { if ( null != f_aDevice ) { + f_dpy.destroyAllPointerIconFromList(f_aDevice.getHandle()); f_dpy.closeNativeImpl(f_aDevice); } } @@ -453,7 +519,7 @@ public abstract class DisplayImpl extends Display { /** Dispatch native Toolkit messageges */ protected abstract void dispatchMessagesNative(); - private Object eventsLock = new Object(); + private final Object eventsLock = new Object(); private ArrayList events = new ArrayList(); private volatile boolean haveEvents = false; diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 7a7e69e48..d078caa3b 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -42,6 +42,7 @@ import java.lang.reflect.Method; import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.IntBitfield; import com.jogamp.common.util.ReflectionUtil; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.MonitorDevice; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Display; @@ -83,6 +84,7 @@ import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; import jogamp.nativewindow.SurfaceUpdatedHelper; +import jogamp.newt.DisplayImpl.PointerIconImpl; public abstract class WindowImpl implements Window, NEWTEventConsumer { @@ -170,6 +172,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private String title = "Newt Window"; private boolean undecorated = false; private boolean alwaysOnTop = false; + private PointerIcon pointerIcon = null; private boolean pointerVisible = true; private boolean pointerConfined = false; private LifecycleHook lifecycleHook = null; @@ -436,6 +439,9 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer createNativeImpl(); screen.addMonitorModeListener(monitorModeListenerImpl); setTitleImpl(title); + if( null != pointerIcon ) { + setPointerIcon(pointerIcon); + } setPointerVisibleImpl(pointerVisible); confinePointerImpl(pointerConfined); setKeyboardVisible(keyboardVisible); @@ -725,6 +731,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer protected boolean setPointerVisibleImpl(boolean pointerVisible) { return false; } protected boolean confinePointerImpl(boolean confine) { return false; } protected void warpPointerImpl(int x, int y) { } + protected void setPointerIconImpl(final PointerIconImpl pi) { } //---------------------------------------------------------------------- // NativeSurface @@ -1675,6 +1682,21 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } } } + + @Override + public final PointerIcon getPointerIcon() { return pointerIcon; } + + @Override + public final void setPointerIcon(final PointerIcon pi) { + if( this.pointerIcon != pi ) { + setPointerIcon(pointerIcon); + if( isNativeValid() ) { + setPointerIconImpl((PointerIconImpl)pi); + } + this.pointerIcon = pi; + } + } + @Override public final boolean isPointerConfined() { return pointerConfined; diff --git a/src/newt/classes/jogamp/newt/driver/PNGIcon.java b/src/newt/classes/jogamp/newt/driver/PNGIcon.java new file mode 100644 index 000000000..c958f6ec2 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/PNGIcon.java @@ -0,0 +1,102 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.nio.ByteBuffer; + +import jogamp.newt.Debug; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.common.util.ReflectionUtil; + +public class PNGIcon { + private static final String err0 = "PNG decoder not implemented."; + + private static final boolean avail; + + static { + Debug.initSingleton(); + + final ClassLoader cl = PNGIcon.class.getClassLoader(); + avail = ReflectionUtil.isClassAvailable("jogamp.newt.driver.opengl.JoglUtilPNGIcon", cl) && + ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.texture.spi.PNGImage", cl); + } + + /** Returns true if PNG decoder is available. */ + public static boolean isAvailable() { + return avail; + } + + /** + * Implemented for X11. + * @param resources + * @param data_size + * @param elem_bytesize + * + * @return BGRA8888 bytes with origin at upper-left corner where component B is located on the lowest 8-bit and component A is located on the highest 8-bit. + * + * @throws UnsupportedOperationException if not implemented + * @throws InterruptedException + * @throws IOException + * @throws MalformedURLException + */ + public static ByteBuffer arrayToX11BGRAImages(IOUtil.ClassResources resources, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + if( avail ) { + return jogamp.newt.driver.opengl.JoglUtilPNGIcon.arrayToX11BGRAImages(resources, data_size, elem_bytesize); + } + throw new UnsupportedOperationException(err0); + } + + /** + * Implemented for Windows. + * @param resources + * @param toBGRA if true, arranges stores in BGRA888 order, otherwise RGBA888 + * @param width + * @param height + * @param data_size + * @param elem_bytesize + * @param resourcesIdx + * @return pixels with origin at upper-left corner. + * If storing RGBA8888, component R is located on the lowest 8-bit. + * If storing BGRA8888, component B is located on the lowest 8-bit. + * Component A is located on the highest 8-bit. + * + * @throws UnsupportedOperationException if not implemented + * @throws InterruptedException + * @throws IOException + * @throws MalformedURLException + */ + public static ByteBuffer singleToRGBAImage(IOUtil.ClassResources resources, int resourceIdx, boolean toBGRA, int[] width, int[] height, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + if( avail ) { + return jogamp.newt.driver.opengl.JoglUtilPNGIcon.singleToRGBAImage(resources, resourceIdx, toBGRA, width, height, data_size, elem_bytesize); + } + throw new UnsupportedOperationException(err0); + } +} diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index c44685dc8..86c8464a8 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -34,15 +34,26 @@ package jogamp.newt.driver.macosx; +import java.io.IOException; +import java.net.MalformedURLException; +import java.nio.Buffer; +import java.nio.ByteBuffer; + import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import com.jogamp.common.util.IOUtil; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; +import com.jogamp.newt.NewtFactory; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.driver.PNGIcon; public class DisplayDriver extends DisplayImpl { + private static final int defaultIconWidth, defaultIconHeight; + private static final Buffer defaultIconData; + static { NEWTJNILibLoader.loadNEWT(); @@ -52,6 +63,25 @@ public class DisplayDriver extends DisplayImpl { if(!WindowDriver.initIDs0()) { throw new NativeWindowException("Failed to initialize jmethodIDs"); } + { + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + Buffer data=null; + if( PNGIcon.isAvailable() ) { + try { + final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); + data = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, false /* toBGRA */, width, height, data_size, elem_bytesize); + } catch (Exception e) { + e.printStackTrace(); + } + } + defaultIconWidth = width[0]; + defaultIconHeight = height[0]; + defaultIconData = data; + if( null != defaultIconData ) { + DisplayDriver.setAppIcon0(defaultIconData, defaultIconWidth, defaultIconHeight); + } + } + if(DEBUG) { System.err.println("MacDisplay.init App and IDs OK "+Thread.currentThread().getName()); } @@ -79,6 +109,23 @@ public class DisplayDriver extends DisplayImpl { aDevice.close(); } + @Override + protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + if( PNGIcon.isAvailable() ) { + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + if( null != pngResource && 0 < pngResource.resourceCount() ) { + final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size, elem_bytesize); + return new PointerIconImpl( createPointerIcon0(data, width[0], height[0], hotX, hotY) ); + } + } + return null; + } + + @Override + protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { + destroyPointerIcon0(((PointerIconImpl)pi).handle); + } + public static void runNSApplication() { runNSApplication0(); } @@ -89,5 +136,9 @@ public class DisplayDriver extends DisplayImpl { private static native boolean initNSApplication0(); private static native void runNSApplication0(); private static native void stopNSApplication0(); + /* pp */ static native void setAppIcon0(Object iconData, int iconWidth, int iconHeight); + private static native long createPointerIcon0(Object iconData, int iconWidth, int iconHeight, int hotX, int hotY); + private static native long destroyPointerIcon0(long handle); + } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index 641d7437c..a55fa915a 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -46,6 +46,7 @@ import javax.media.nativewindow.util.PointImmutable; import jogamp.nativewindow.macosx.OSXUtil; import jogamp.newt.WindowImpl; +import jogamp.newt.DisplayImpl.PointerIconImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; @@ -391,6 +392,15 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl } } + @Override + protected void setPointerIconImpl(final PointerIconImpl pi) { + OSXUtil.RunOnMainThread(false, new Runnable() { + @Override + public void run() { + setPointerIcon0(getWindowHandle(), null != pi ? pi.handle : 0); + } } ); + } + @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { if( !isOffscreenInstance ) { @@ -568,6 +578,7 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); private static native boolean confinePointer0(long windowHandle, boolean confine); private static native void warpPointer0(long windowHandle, int x, int y); + private static native void setPointerIcon0(long windowHandle, long handle); // Window styles private static final int NSBorderlessWindowMask = 0; diff --git a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java new file mode 100644 index 000000000..ea9029006 --- /dev/null +++ b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java @@ -0,0 +1,139 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt.driver.opengl; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URLConnection; +import java.nio.ByteBuffer; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.texture.spi.PNGImage; + +public class JoglUtilPNGIcon { + + public static ByteBuffer arrayToX11BGRAImages(IOUtil.ClassResources resources, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { + final PNGImage[] images = new PNGImage[resources.resourceCount()]; + data_size[0] = 0; + for(int i=0; inull if !{@link #isNativeValid()}, otherwise the Boolean value of {@link X11GraphicsDevice#isXineramaEnabled()}. */ protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; } + @Override + protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + if( PNGIcon.isAvailable() ) { + final int[] width = { 0 }, height = { 0 }, data_size = { 0 }, elem_bytesize = { 0 }; + if( null != pngResource && 0 < pngResource.resourceCount() ) { + final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, false /* toBGRA */, width, height, data_size, elem_bytesize); + final long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override + public Long run(long dpy) { + long h = 0; + try { + h = createPointerIcon0(dpy, data, width[0], height[0], hotX, hotY); + } catch (Exception e) { + e.printStackTrace(); + } + return Long.valueOf(h); + } + }).longValue(); + return new PointerIconImpl(handle); + } + } + return null; + } + + @Override + protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { + destroyPointerIcon0(displayHandle, ((PointerIconImpl)pi).handle); + } + //---------------------------------------------------------------------- // Internals only // @@ -137,6 +174,15 @@ public class DisplayDriver extends DisplayImpl { private native void DispatchMessages0(long display, long javaObjectAtom, long windowDeleteAtom /* , long kbdHandle */); // XKB disabled for now + static long createPointerIcon0(long display, Buffer data, int width, int height, int hotX, int hotY) { + if( !Buffers.isDirect(data) ) { + throw new IllegalArgumentException("data buffer is not direct "+data); + } + return createPointerIcon0(display, data, Buffers.getDirectBufferByteOffset(data), width, height, hotX, hotY); + } + private static native long createPointerIcon0(long display, Object data, int data_offset, int width, int height, int hotX, int hotY); + static native void destroyPointerIcon0(long display, long handle); + /** X11 Window delete atom marker used on EDT */ private long windowDeleteAtom; diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index f2a27b0c9..0ea2c5358 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -34,11 +34,16 @@ package jogamp.newt.driver.x11; +import java.nio.Buffer; + import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; +import jogamp.newt.DisplayImpl.PointerIconImpl; import jogamp.newt.WindowImpl; +import jogamp.newt.driver.PNGIcon; + import javax.media.nativewindow.*; import javax.media.nativewindow.VisualIDHolder.VIDType; import javax.media.nativewindow.util.Insets; @@ -47,6 +52,7 @@ import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.x11.X11GraphicsDevice; import com.jogamp.nativewindow.x11.X11GraphicsScreen; +import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.InputEvent; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.event.MouseEvent; @@ -58,8 +64,29 @@ public class WindowDriver extends WindowImpl { private static final int X11_WHEEL_TWO_UP_BUTTON = 6; private static final int X11_WHEEL_TWO_DOWN_BUTTON = 7; + private static final int defaultIconDataSize; + private static final Buffer defaultIconData; + static { ScreenDriver.initSingleton(); + + int _icon_data_size=0, _icon_elem_bytesize=0; + Buffer _icon_data=null; + if( PNGIcon.isAvailable() ) { + try { + final int[] data_size = { 0 }, elem_bytesize = { 0 }; + _icon_data = PNGIcon.arrayToX11BGRAImages(NewtFactory.getWindowIcons(), data_size, elem_bytesize); + _icon_data_size = data_size[0]; + _icon_elem_bytesize = elem_bytesize[0]; + } catch (Exception e) { + e.printStackTrace(); + } + } + defaultIconDataSize = _icon_data_size; + defaultIconData = _icon_data; + if(DEBUG_IMPLEMENTATION) { + System.err.println("Def. Icon: data_size "+defaultIconDataSize+" * elem_size "+_icon_elem_bytesize+" = data "+defaultIconData); + } } public WindowDriver() { @@ -100,7 +127,8 @@ public class WindowDriver extends WindowImpl { setWindowHandle(CreateWindow0(getParentWindowHandle(), edtDevice.getHandle(), screen.getIndex(), visualID, display.getJavaObjectAtom(), display.getWindowDeleteAtom(), - getX(), getY(), getWidth(), getHeight(), autoPosition(), flags)); + getX(), getY(), getWidth(), getHeight(), autoPosition(), flags, + defaultIconDataSize, defaultIconData)); } finally { edtDevice.unlock(); } @@ -245,6 +273,21 @@ public class WindowDriver extends WindowImpl { }); } + @Override + protected void setPointerIconImpl(final PointerIconImpl pi) { + runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { + @Override + public Object run(long dpy) { + try { + setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.handle : 0); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + }); + } + @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { @@ -381,13 +424,17 @@ public class WindowDriver extends WindowImpl { private native long CreateWindow0(long parentWindowHandle, long display, int screen_index, int visualID, long javaObjectAtom, long windowDeleteAtom, - int x, int y, int width, int height, boolean autoPosition, int flags); + int x, int y, int width, int height, boolean autoPosition, int flags, + int iconDataSize, Object iconData); private native void CloseWindow0(long display, long windowHandle, long javaObjectAtom, long windowDeleteAtom /*, long kbdHandle*/ ); // XKB disabled for now private native void reconfigureWindow0(long display, int screen_index, long parentWindowHandle, long windowHandle, long windowDeleteAtom, int x, int y, int width, int height, int flags); private native void requestFocus0(long display, long windowHandle, boolean force); private static native void setTitle0(long display, long windowHandle, String title); + + private static native void setPointerIcon0(long display, long windowHandle, long handle); + private static native long getParentWindow0(long display, long windowHandle); private static native boolean setPointerVisible0(long display, long windowHandle, boolean visible); private static native boolean confinePointer0(long display, long windowHandle, boolean grab); diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 30d3458ad..16e9814ef 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -285,6 +285,76 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_stopNSApplic [pool release]; } +static NSImage * createNSImageFromData(JNIEnv *env, jobject jiconData, jint jiconWidth, jint jiconHeight) { + if( NULL != jiconData ) { + unsigned char * iconData = (unsigned char *) (*env)->GetDirectBufferAddress(env, jiconData); + NSInteger iconWidth = (NSInteger) jiconWidth; + NSInteger iconHeight = (NSInteger) jiconHeight; + const NSInteger bpc = 8 /* bits per component */, spp=4 /* RGBA */, bpp = bpc * spp; + const NSBitmapFormat bfmt = NSAlphaNonpremultipliedBitmapFormat; + const BOOL hasAlpha = YES; + + NSBitmapImageRep* bir = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: &iconData + pixelsWide: iconWidth + pixelsHigh: iconHeight + bitsPerSample: bpc + samplesPerPixel: spp + hasAlpha: hasAlpha + isPlanar: NO + colorSpaceName: NSCalibratedRGBColorSpace + bitmapFormat: bfmt + bytesPerRow: iconWidth*4 + bitsPerPixel: bpp]; + [bir autorelease]; + NSImage* nsImage = [[NSImage alloc] initWithCGImage: [bir CGImage] size:NSZeroSize]; + return nsImage; + } + return NULL; +} + +/* + * Class: jogamp_newt_driver_macosx_DisplayDriver + * Method: setAppIcon0 + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_setAppIcon0 + (JNIEnv *env, jobject unused, jobject jiconData, jint jiconWidth, jint jiconHeight) +{ + NSImage * nsImage = createNSImageFromData(env, jiconData, jiconWidth, jiconHeight); + if( NULL != nsImage ) { + [nsImage autorelease]; + [NSApp setApplicationIconImage: nsImage]; + } +} + +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_createPointerIcon0 + (JNIEnv *env, jobject unused, jobject jiconData, jint jiconWidth, jint jiconHeight, jint hotX, jint hotY) +{ + NSImage * nsImage = createNSImageFromData(env, jiconData, jiconWidth, jiconHeight); + if( NULL != nsImage ) { + [nsImage autorelease]; + NSPoint hotP = { hotX, hotY }; + NSCursor * c = [[NSCursor alloc] initWithImage: nsImage hotSpot: hotP]; + return (jlong) (intptr_t) c; + } + return 0; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_destroyPointerIcon0 + (JNIEnv *env, jobject unused, jlong handle) +{ + NSCursor * c = (NSCursor*) (intptr_t) handle ; + [c release]; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0 + (JNIEnv *env, jobject unused, jlong window, jlong handle) +{ + NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) window; + NSCursor * c = (NSCursor*) (intptr_t) handle ; + + [mWin setCustomCursor: c]; +} + static NSScreen * NewtScreen_getNSScreenByIndex(int screen_idx, BOOL cap) { NSArray *screens = [NSScreen screens]; if( screen_idx<0 || screen_idx>=[screens count] ) { @@ -632,7 +702,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 [pool release]; - return (jlong) ((intptr_t) myView); + return (jlong) (intptr_t) myView; } /** @@ -674,7 +744,6 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow backing: (NSBackingStoreType) bufferingType defer: YES isFullscreenWindow: fullscreen]; - // DBG_PRINT( "createWindow0.1 - %p, isVisible %d\n", myWindow, [myWindow isVisible]); DBG_PRINT( "createWindow0.X - %p, isVisible %d\n", myWindow, [myWindow isVisible]); diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index ba60b5665..1f907f30e 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -114,6 +114,7 @@ BOOL mouseVisible; BOOL mouseInside; BOOL cursorIsHidden; + NSCursor * customCursor; BOOL realized; BOOL modsDown[4]; // shift, ctrl, alt/option, win/command NSPoint lastInsideMousePosition; @@ -151,7 +152,8 @@ - (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p; - (BOOL) isMouseInside; -- (void) cursorHide:(BOOL)v; +- (void) cursorHide:(BOOL)v enter:(int)enterState; +- (void) setCustomCursor:(NSCursor*)c; - (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus; - (void) setMouseConfined:(BOOL)v; - (void) setMousePosition:(NSPoint)p; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 4b0198c7e..a7bab9b9d 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -41,6 +41,8 @@ #include +#define PRINTF(...) NSLog(@ __VA_ARGS__) + static jfloat GetDelta(NSEvent *event, jint javaMods[]) { CGEventRef cgEvent = [event CGEvent]; CGFloat deltaY = 0.0; @@ -468,6 +470,7 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { defaultPresentationOptions = 0; fullscreenPresentationOptions = 0; } + isFullscreenWindow = isfs; // Why is this necessary? Without it we don't get any of the // delegate methods like resizing and window movement. @@ -484,6 +487,7 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { mouseVisible = YES; mouseInside = NO; cursorIsHidden = NO; + customCursor = NULL; realized = YES; DBG_PRINT("NewtWindow::create: %p, realized %d, hasPresentationSwitch %d[defaultOptions 0x%X, fullscreenOptions 0x%X], (refcnt %d)\n", res, realized, (int)hasPresentationSwitch, (int)defaultPresentationOptions, (int)fullscreenPresentationOptions, (int)[res retainCount]); @@ -678,13 +682,36 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { DBG_PRINT( "setMouseVisible: confined %d, visible %d (current: %d), mouseInside %d, hasFocus %d\n", mouseConfined, mouseVisible, !cursorIsHidden, mouseInside, focus); if(YES == focus && YES == mouseInside) { - [self cursorHide: !mouseVisible]; + [self cursorHide: !mouseVisible enter: 0]; + } +} + +- (void) setCustomCursor:(NSCursor*)c +{ + if(YES == mouseInside) { + if( NULL != c ) { + DBG_PRINT( "setCustomCursor push: %p\n", c); + [c push]; + } else if( NULL != customCursor && [NSCursor currentCursor] == customCursor ) { + DBG_PRINT( "setCustomCursor pop: %p\n", customCursor); + [customCursor pop]; + } } + customCursor = c; } -- (void) cursorHide:(BOOL)v +- (void) cursorHide:(BOOL)v enter:(int)enterState { - DBG_PRINT( "cursorHide: %d -> %d\n", cursorIsHidden, v); + DBG_PRINT( "cursorHide: %d -> %d, enter %d\n", cursorIsHidden, v, enterState); + if( NULL != customCursor ) { + if( 1 == enterState && [NSCursor currentCursor] != customCursor ) { + DBG_PRINT( "cursorHide.customCursor push: %p\n", customCursor); + [customCursor push]; + } else if( -1 == enterState && [NSCursor currentCursor] == customCursor ) { + DBG_PRINT( "cursorHide.customCursor pop: %p\n", customCursor); + [customCursor pop]; + } + } if(v) { if(!cursorIsHidden) { [NSCursor hide]; @@ -941,7 +968,7 @@ static jint mods2JavaMods(NSUInteger mods) DBG_PRINT( "*************** windowDidBecomeKey\n"); mouseInside = [self isMouseInside]; if(YES == mouseInside) { - [self cursorHide: !mouseVisible]; + [self cursorHide: !mouseVisible enter: 0]; } [self focusChanged: YES]; } @@ -995,7 +1022,7 @@ static jint mods2JavaMods(NSUInteger mods) { DBG_PRINT( "mouseEntered: confined %d, visible %d\n", mouseConfined, mouseVisible); mouseInside = YES; - [self cursorHide: !mouseVisible]; + [self cursorHide: !mouseVisible enter: 1]; if(NO == mouseConfined) { [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED]; } @@ -1006,7 +1033,7 @@ static jint mods2JavaMods(NSUInteger mods) DBG_PRINT( "mouseExited: confined %d, visible %d\n", mouseConfined, mouseVisible); if(NO == mouseConfined) { mouseInside = NO; - [self cursorHide: NO]; + [self cursorHide: NO enter: -1]; [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED]; } else { [self setMousePosition: lastInsideMousePosition]; @@ -1160,7 +1187,7 @@ static jint mods2JavaMods(NSUInteger mods) jboolean closed = JNI_FALSE; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [self cursorHide: NO]; + [self cursorHide: NO enter: -1]; NSView* nsview = [self contentView]; if( ! [nsview isKindOfClass:[NewtView class]] ) { diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index dd0150e78..2a16dce57 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -139,7 +139,7 @@ #include "NewtCommon.h" -// #define VERBOSE_ON 1 +#define VERBOSE_ON 1 // #define DEBUG_KEYS 1 #ifdef VERBOSE_ON @@ -186,6 +186,10 @@ typedef struct { int height; /** Tristate: -1 HIDE, 0 NOP, 1 SHOW */ int setPointerVisible; + /** Tristate: -1 RESET, 0 NOP, 1 SET-NEW */ + int setPointerAction; + HCURSOR setPointerHandle; + HCURSOR defPointerHandle; /** Bool: 0 NOP, 1 FULLSCREEN */ int setFullscreen; int pointerCaptured; @@ -1023,10 +1027,22 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP } else /* -1 == wud->setPointerVisible */ { visibilityChangeSuccessful = SafeShowCursor(FALSE); } - useDefWindowProc = visibilityChangeSuccessful ? 1 : 0; DBG_PRINT("*** WindowsWindow: WM_SETCURSOR requested visibility: %d success: %d\n", wud->setPointerVisible, visibilityChangeSuccessful); wud->setPointerVisible = 0; - // own signal, consumed + // own signal, consumed, no further processing + useDefWindowProc = 0; + res = 1; + } else if( 0 != wud->setPointerAction ) { + if( -1 == wud->setPointerAction ) { + wud->setPointerHandle = wud->defPointerHandle; + } + HCURSOR preHandle = SetCursor(wud->setPointerHandle); + DBG_PRINT("*** WindowsWindow: WM_SETCURSOR requested change %d: pre %p -> set %p, def %p\n", + wud->setPointerAction, (void*)preHandle, (void*)wud->setPointerHandle, (void*)wud->defPointerHandle); + wud->setPointerAction = 0; + // own signal, consumed, no further processing + useDefWindowProc = 0; + res = 1; } else { useDefWindowProc = 1; // NOP for us, allow parent to act } @@ -1246,6 +1262,7 @@ static LRESULT CALLBACK wndProc(HWND wnd, UINT message, WPARAM wParam, LPARAM lP if( 0 == wud->pointerInside ) { wud->pointerInside = 1; NewtWindows_trackPointerLeave(wnd); + SetCursor(wud->setPointerHandle); } (*env)->CallVoidMethod(env, window, sendMouseEventID, (jshort) EVENT_MOUSE_MOVED, @@ -1997,7 +2014,8 @@ static void NewtWindow_setVisiblePosSize(HWND hwnd, BOOL atop, BOOL visible, JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong hInstance, jstring jWndClassName, jstring jWndName, jint winMajor, jint winMinor, - jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags) + jlong parent, jint jx, jint jy, jint defaultWidth, jint defaultHeight, jboolean autoPosition, jint flags, + jlong iconSmallHandle, jlong iconBigHandle) { HWND parentWindow = (HWND) (intptr_t) parent; const TCHAR* wndClassName = NULL; @@ -2054,6 +2072,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo wud->width = width; wud->height = height; wud->setPointerVisible = 0; + wud->setPointerAction = 0; + wud->defPointerHandle = LoadCursor( NULL, IDC_ARROW); + wud->setPointerHandle = wud->defPointerHandle; wud->setFullscreen = 0; wud->pointerCaptured = 0; wud->pointerInside = 0; @@ -2083,6 +2104,12 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_WindowDriver_CreateWindo RECT rc; RECT * insets; + if( 0 != iconSmallHandle ) { + SendMessage(window, WM_SETICON, ICON_SMALL, (LPARAM) iconSmallHandle ); + } + if( 0 != iconBigHandle ) { + SendMessage(window, WM_SETICON, ICON_BIG, (LPARAM) iconBigHandle ); + } ShowWindow(window, SW_SHOW); // send insets before visibility, allowing java code a proper sync point! @@ -2321,3 +2348,83 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_warpPointer0 SetCursorPos(x, y); } +JNIEXPORT jlong JNICALL +Java_jogamp_newt_driver_windows_DisplayDriver_createBGRA8888Icon0(JNIEnv *env, jobject _unused, + jobject data, jint data_offset, jint width, jint height, jboolean isCursor, jint hotX, jint hotY) { + + const unsigned char * data_ptr = (const unsigned char *) (*env)->GetDirectBufferAddress(env, data) + data_offset; + const int bytes = 4 * width * height; // BGRA8888 + + DWORD dwWidth, dwHeight; + BITMAPV5HEADER bi; + HBITMAP hBitmap; + void *lpBits; + HICON handle = NULL; + + dwWidth = width; // width of cursor + dwHeight = height; // height of cursor + + ZeroMemory(&bi,sizeof(BITMAPV5HEADER)); + bi.bV5Size = sizeof(BITMAPV5HEADER); + bi.bV5Width = dwWidth; + bi.bV5Height = -1 * dwHeight; + bi.bV5Planes = 1; + bi.bV5BitCount = 32; + bi.bV5Compression = BI_BITFIELDS; + // The following mask specification specifies a supported 32 BPP + // alpha format for Windows XP. + bi.bV5RedMask = 0x00FF0000; + bi.bV5GreenMask = 0x0000FF00; + bi.bV5BlueMask = 0x000000FF; + bi.bV5AlphaMask = 0xFF000000; + + HDC hdc; + hdc = GetDC(NULL); + + // Create the DIB section with an alpha channel. + hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, + (void **)&lpBits, NULL, (DWORD)0); + + memcpy(lpBits, data_ptr, bytes); + + ReleaseDC(NULL,hdc); + + // Create an empty mask bitmap. + HBITMAP hMonoBitmap = CreateBitmap(dwWidth,dwHeight,1,1,NULL); + + ICONINFO ii; + ii.fIcon = isCursor ? FALSE : TRUE; + ii.xHotspot = hotX; + ii.yHotspot = hotY; + ii.hbmMask = hMonoBitmap; + ii.hbmColor = hBitmap; + + // Create the alpha cursor with the alpha DIB section. + handle = CreateIconIndirect(&ii); + + DeleteObject(hBitmap); + DeleteObject(hMonoBitmap); + + return (jlong) (intptr_t) handle; +} + +JNIEXPORT void JNICALL +Java_jogamp_newt_driver_windows_DisplayDriver_destroyIcon0(JNIEnv *env, jobject _unused, jlong jhandle) { + HICON handle = (HICON) (intptr_t) jhandle; + DestroyIcon(handle); +} + +JNIEXPORT void JNICALL +Java_jogamp_newt_driver_windows_WindowDriver_setPointerIcon0(JNIEnv *env, jobject _unused, jlong window, jlong iconHandle) { + HWND hwnd = (HWND) (intptr_t) window; + WindowUserData * wud; +#if !defined(__MINGW64__) && ( defined(UNDER_CE) || _MSC_VER <= 1200 ) + wud = (WindowUserData *) GetWindowLong(hwnd, GWL_USERDATA); +#else + wud = (WindowUserData *) GetWindowLongPtr(hwnd, GWLP_USERDATA); +#endif + wud->setPointerAction = 0 != iconHandle ? 1 : -1; + wud->setPointerHandle = (HCURSOR) (intptr_t) iconHandle; + SendMessage(hwnd, WM_SETCURSOR, 0, 0); +} + diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index e2392a113..19e733111 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -28,6 +28,8 @@ #include "X11Common.h" +#include + // #include // XKB disabled for now jclass X11NewtWindowClazz = NULL; @@ -670,4 +672,54 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage } } +/* + * Class: Java_jogamp_newt_driver_x11_DisplayDriver + * Method: createPointerIcon0 + * Signature: (JJILjava/lang/Object;I)V + */ +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_createPointerIcon0 + (JNIEnv *env, jclass clazz, jlong display, jobject data, jint data_offset, jint width, jint height, jint hotX, jint hotY) +{ + Cursor c; + + if( 0 != data ) { + Display * dpy = (Display *) (intptr_t) display; + char * data_ptr = (char *) (*env)->GetDirectBufferAddress(env, data) + data_offset; + XcursorImage ci; + ci.version = 1; // XCURSOR_IMAGE_VERSION; + ci.size = width; // nominal size (assume square ..) + ci.width = width; + ci.height = height; + ci.xhot = hotX; + ci.yhot = hotY; + ci.delay = 0; + ci.pixels = (XcursorPixel *)(intptr_t)data_ptr; + + c = XcursorImageLoadCursor (dpy, &ci); + + DBG_PRINT( "X11: createPointerIcon0: %p %dx%d %d/%d -> %p\n", data_ptr, width, height, hotX, hotY, (void *)c); + + } else { + c = 0; + } + return (jlong) (intptr_t) c; +} + +/* + * Class: Java_jogamp_newt_driver_x11_DisplayDriver + * Method: destroyPointerIcon0 + * Signature: (JJILjava/lang/Object;I)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_destroyPointerIcon0 + (JNIEnv *env, jclass clazz, jlong display, jlong handle) +{ + Display * dpy = (Display *) (intptr_t) display; + + if( 0 != handle ) { + Cursor c = (Cursor) (intptr_t) handle; + DBG_PRINT( "X11: destroyPointerIcon0: %p\n", (void *)c); + XFreeCursor(dpy, c); + } +} + diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index 5f5dddbe0..da2778004 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -497,6 +497,12 @@ static void NewtWindows_setPosSize(Display *dpy, Window w, jint x, jint y, jint } } +static void NewtWindows_setIcon(Display *dpy, Window w, int data_size, const unsigned char * data_ptr) { + Atom _NET_WM_ICON = XInternAtom(dpy, "_NET_WM_ICON", False); + Atom CARDINAL = XInternAtom(dpy, "CARDINAL", False); + XChangeProperty(dpy, w, _NET_WM_ICON, CARDINAL, 32, PropModeReplace, data_ptr, data_size); +} + /* * Class: jogamp_newt_driver_x11_WindowDriver * Method: CreateWindow @@ -505,7 +511,8 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 (JNIEnv *env, jobject obj, jlong parent, jlong display, jint screen_index, jint visualID, jlong javaObjectAtom, jlong windowDeleteAtom, - jint x, jint y, jint width, jint height, jboolean autoPosition, int flags) + jint x, jint y, jint width, jint height, jboolean autoPosition, int flags, + jint iconDataSize, jobject iconData) { Display * dpy = (Display *)(intptr_t)display; Atom wm_delete_atom = (Atom)windowDeleteAtom; @@ -626,6 +633,11 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 XEvent event; int left=0, right=0, top=0, bottom=0; + if( 0 < iconDataSize && NULL != iconData ) { + const unsigned char * iconDataPtr = (const unsigned char *) (*env)->GetDirectBufferAddress(env, iconData); + NewtWindows_setIcon(dpy, window, (int)iconDataSize, iconDataPtr); + } + XMapWindow(dpy, window); XIfEvent( dpy, &event, WaitForMapNotify, (XPointer) window ); // wait to get proper insets values @@ -944,6 +956,27 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_setTitle0 #endif } +/* + * Class: Java_jogamp_newt_driver_x11_WindowDriver + * Method: setPointerIcon0 + * Signature: (JJILjava/lang/Object;I)V + */ +JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_WindowDriver_setPointerIcon0 + (JNIEnv *env, jclass clazz, jlong display, jlong window, jlong handle) +{ + Display * dpy = (Display *) (intptr_t) display; + Window w = (Window)window; + + if( 0 == handle ) { + DBG_PRINT( "X11: setPointerIcon0: reset\n"); + XUndefineCursor(dpy, w); + } else { + Cursor c = (Cursor) (intptr_t) handle; + DBG_PRINT( "X11: setPointerIcon0: %p\n", (void*)c); + XDefineCursor(dpy, w, c); + } +} + /* * Class: Java_jogamp_newt_driver_x11_WindowDriver * Method: setPointerVisible0 diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index b54a2cd19..efec961de 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -30,7 +30,9 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; import java.io.IOException; +import com.jogamp.common.util.IOUtil; import com.jogamp.newt.Display; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.Screen; import com.jogamp.newt.event.KeyAdapter; @@ -44,9 +46,7 @@ import com.jogamp.opengl.test.junit.util.AWTRobotUtil; import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; - import com.jogamp.opengl.util.Animator; - import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import javax.media.nativewindow.NativeWindowFactory; @@ -54,7 +54,6 @@ import javax.media.nativewindow.util.Dimension; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.DimensionImmutable; - import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; @@ -171,6 +170,20 @@ public class TestGearsES2NEWT extends UITestCase { } }); + final PointerIcon pointerIconOne; + { + PointerIcon _pointerIconOne = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); + final Display disp = glWindow.getScreen().getDisplay(); + disp.createNative(); + try { + _pointerIconOne = disp.createPointerIcon(res, 32, 0); + } catch (Exception e) { + e.printStackTrace(); + } + pointerIconOne = _pointerIconOne; + } + glWindow.addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { @@ -203,6 +216,16 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("[set alwaysontop post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); + } else if(e.getKeyChar()=='c') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set pointer-icon pre]"); + final PointerIcon currentPI = glWindow.getPointerIcon(); + glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); + System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); + glWindow.setExclusiveContextThread(t); + } }.start(); } else if(e.getKeyChar()=='d') { new Thread() { public void run() { -- cgit v1.2.3 From fcc0e7397bb6f3ceb1fe143667f8c59b5bf63874 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 4 Jan 2014 17:15:04 +0100 Subject: Bug 935: NEWT PointerIcon: Refine Spec and Implementation / Fix OSX Crash and Issues - Refine Display.PointerIcon: Complete type allowing re-creation - Add associated Display reference - Add used IOUtil.ClassResources reference - Add isValid()/validate() methods for recreation - Refine API doc - Move Display.destroyPointerIcon(PointerIcon) -> PointerIcon.destroy() - Move DisplayImpl.PointerIconImpl -> PointerIconImpl (own source file) - Creation/Destruction and setting of PointerIcon happens on EDT - DisplayImpl.shutdownAll() and Display.destroy() calls destroyAllPointerIconFromList - WindowDriver.setPointerIconImpl: Validates PointerIconImpl (i.e. re-creates if required) - Fix 'initial' window.setPointerIcon(..) before createNative(..), tested w/ TestGearsES2NEWT - OSX Native Code: - Move mouse and pointer-state handling from NewtMacWindow -> NewtView class to retain states (pointer handle, pointer visibility, etc) when reparenting. Reparenting will move an exisiting NewtView into a new NewtMacWindow. - Enable all mouse move events: - NewtView::mouseEnter [nsWin makeFirstResponder: nsView]; - NewtView::mouseExited if( !mouseConfined ) { [nsView resignFirstResponder]; } - NewtView::mouseMoved issued [myCurser set] if required, fixing OSX issue not updating NSCursor properly. - MacWindow: - Test NewtMacWindow, NewtView and NSCursor handles before usage - Fix DBG_PRINT(..) warnings --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- src/newt/classes/com/jogamp/newt/Display.java | 67 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 91 +- src/newt/classes/jogamp/newt/PointerIconImpl.java | 126 ++ src/newt/classes/jogamp/newt/WindowImpl.java | 9 +- .../jogamp/newt/driver/macosx/DisplayDriver.java | 11 +- .../jogamp/newt/driver/macosx/WindowDriver.java | 34 +- .../jogamp/newt/driver/windows/DisplayDriver.java | 11 +- .../jogamp/newt/driver/windows/WindowDriver.java | 4 +- .../jogamp/newt/driver/x11/DisplayDriver.java | 22 +- .../jogamp/newt/driver/x11/WindowDriver.java | 14 +- src/newt/native/MacWindow.m | 113 +- src/newt/native/NewtMacWindow.h | 86 +- src/newt/native/NewtMacWindow.m | 1237 ++++++++++---------- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 28 +- .../parenting/NewtAWTReparentingKeyAdapter.java | 53 +- 17 files changed, 1106 insertions(+), 808 deletions(-) create mode 100644 src/newt/classes/jogamp/newt/PointerIconImpl.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index d95b0025f..1158abdbb 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -6,14 +6,14 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMainVersion REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNewtAWTWrapper %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.newt.TestGearsNEWT -time 30000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es1.newt.TestGearsES1NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 4000 -x 10 -y 10 -width 100 -height 100 -screen 0 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -vsync -time 40000 -width 100 -height 100 -screen 0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGearsAWT -time 5000 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 4c084d705..db852ce42 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -323,9 +323,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index cf1099c85..8d1445f80 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -66,16 +66,60 @@ public abstract class Display { /** * Native PointerIcon handle. *

        - * Instances can be created via {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int)} - * and released via {@link Display#destroyPointerIcon(PointerIcon)}. + * Instances can be created via {@link Display}'s {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) createPointerIcon(..)}. + *

        + *

        + * Instance is {@link #destroy()}'ed automatically if it's {@link #getDisplay() associated Display} is destroyed. + *

        + *

        + * Instance can be re-validated after destruction via {@link #validate()}. + *

        + *

        + * {@link PointerIcon} may be {@link #destroy() destroyed} manually after use, + * i.e. when no {@link Window} {@link Window#setPointerIcon(PointerIcon) uses them} anymore. *

        *

        * PointerIcons can be used via {@link Window#setPointerIcon(PointerIcon)}. *

        */ public static interface PointerIcon { + /** + * @return the associated Display + */ + Display getDisplay(); + + /** + * @return the single {@link IOUtil.ClassResources}. + */ + IOUtil.ClassResources getResource(); + + /** + * Returns true if valid, otherwise false. + *

        + * A PointerIcon instance becomes invalid if it's {@link #getDisplay() associated Display} is destroyed. + *

        + */ + boolean isValid(); + + /** + * Returns true if instance {@link #isValid()} or validation was successful, otherwise false. + *

        + * Validation, i.e. recreation, is required if instance became invalid, see {@link #isValid()}. + *

        + */ + boolean validate(); + + /** + * Destroys this instance. + *

        + * Will be called automatically if it's {@link #getDisplay() associated Display} is destroyed. + *

        + */ + void destroy(); + /** Returns the size, i.e. width and height. */ DimensionImmutable getSize(); + /** Returns the hotspot. */ PointImmutable getHotspot(); @@ -84,28 +128,23 @@ public abstract class Display { } /** - * Returns the created {@link PointerIcon} or null if not implemented on platform. + * Returns the newly created {@link PointerIcon} or null if not implemented on platform. + *

        + * See {@link PointerIcon} for lifecycle semantics. + *

        * - * @param pngResource PNG resource + * @param pngResource single PNG resource, only the first entry of {@link IOUtil.ClassResources#resourcePaths} is used. * @param hotX pointer hotspot x-coord, origin is upper-left corner * @param hotY pointer hotspot y-coord, origin is upper-left corner + * @throws IllegalStateException if this Display instance is not {@link #isNativeValid() valid yet}. * @throws MalformedURLException * @throws InterruptedException * @throws IOException * * @see PointerIcon - * @see #destroyPointerIcon(PointerIcon) * @see Window#setPointerIcon(PointerIcon) */ - - public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException; - - /** - * @param pi - * - * @see #createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) - */ - public abstract void destroyPointerIcon(PointerIcon pi); + public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws IllegalStateException, MalformedURLException, InterruptedException, IOException; /** * Manual trigger the native creation, if it is not done yet.
        diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index dc3705daa..346c03b15 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -51,8 +51,6 @@ import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; -import javax.media.nativewindow.util.DimensionImmutable; -import javax.media.nativewindow.util.PointImmutable; public abstract class DisplayImpl extends Display { private static int serialno = 1; @@ -68,49 +66,19 @@ public abstract class DisplayImpl extends Display { }); } - public static class PointerIconImpl implements PointerIcon { - public final long handle; - private final DimensionImmutable size; - private final PointImmutable hotspot; - public PointerIconImpl(final long handle, final DimensionImmutable size, final PointImmutable hotspot) { - this.handle=handle; - this.size = size; - this.hotspot = hotspot; - } - @Override - public final DimensionImmutable getSize() { - return size; - } - @Override - public final PointImmutable getHotspot() { - return hotspot; - } - @Override - public final String toString() { - return "PointerIcon[0x"+Long.toHexString(handle)+", "+size+", "+hotspot+"]"; - } - } - - private void addPointerIconToList(final PointerIcon pi) { - synchronized(pointerIconList) { - pointerIconList.add(pi); - } - } - private void delPointerIconFromList(final PointerIcon pi) { - synchronized(pointerIconList) { - pointerIconList.remove(pi); - } - } - private final ArrayList pointerIconList = new ArrayList(); + final ArrayList pointerIconList = new ArrayList(); /** Executed from EDT! */ private void destroyAllPointerIconFromList(final long dpy) { synchronized(pointerIconList) { - for( int i=0; i < pointerIconList.size(); i++ ) { - final PointerIcon item = pointerIconList.get(i); - if( null != item ) { - // destroy! - destroyPointerIconImpl(dpy, item); + final int count = pointerIconList.size(); + for( int i=0; i < count; i++ ) { + final PointerIconImpl item = pointerIconList.get(i); + if(DEBUG) { + System.err.println("destroyAllPointerIconFromList: dpy "+toHexString(dpy)+", # "+i+"/"+count+": "+item+" @ "+getThreadName()); + } + if( null != item && item.isValid() ) { + item.destroyOnEDT(dpy); } } pointerIconList.clear(); @@ -119,31 +87,37 @@ public abstract class DisplayImpl extends Display { @Override public final PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - final PointerIcon res = createPointerIconImpl(pngResource, hotX, hotY); - addPointerIconToList(res); - return res; - } - protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - return null; + return createPointerIcon(false /* isTemp */, pngResource, hotX, hotY); } - - @Override - public final void destroyPointerIcon(final PointerIcon pi) { - delPointerIconFromList(pi); - runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - @Override - public Object run(long dpy) { + PointerIcon createPointerIcon(final boolean isTemp, final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + if( !isNativeValid() ) { + throw new IllegalStateException("Display.createPointerIcon(1): Display invalid "+this); + } + final PointerIconImpl[] res = { null }; + runOnEDTIfAvail(true, new Runnable() { + public void run() { try { - destroyPointerIconImpl(dpy, pi); + if( !DisplayImpl.this.isNativeValid() ) { + throw new IllegalStateException("Display.createPointerIcon(2): Display invalid "+DisplayImpl.this); + } + res[0] = createPointerIconImpl(pngResource, hotX, hotY); } catch (Exception e) { e.printStackTrace(); } - return null; + } } ); + if( !isTemp ) { + synchronized(pointerIconList) { + pointerIconList.add(res[0]); } - }); + } + return res[0]; + } + /** Executed from EDT! */ + protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + return null; } /** Executed from EDT! */ - protected void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { } + protected void destroyPointerIconImpl(final long displayHandle, long piHandle) { } /** Ensure static init has been run. */ /* pp */static void initSingleton() { } @@ -399,6 +373,7 @@ public abstract class DisplayImpl extends Display { @Override public void run() { if ( null != d.getGraphicsDevice() ) { + d.destroyAllPointerIconFromList(f_aDevice.getHandle()); d.closeNativeImpl(f_aDevice); } } diff --git a/src/newt/classes/jogamp/newt/PointerIconImpl.java b/src/newt/classes/jogamp/newt/PointerIconImpl.java new file mode 100644 index 000000000..e2388be67 --- /dev/null +++ b/src/newt/classes/jogamp/newt/PointerIconImpl.java @@ -0,0 +1,126 @@ +/** + * Copyright 2013 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package jogamp.newt; + +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PointImmutable; + +import com.jogamp.common.util.IOUtil; +import com.jogamp.common.util.IOUtil.ClassResources; +import com.jogamp.newt.Display; +import com.jogamp.newt.Display.PointerIcon; + +public class PointerIconImpl implements PointerIcon { + private final DisplayImpl display; + private final IOUtil.ClassResources resource; + private final DimensionImmutable size; + private final PointImmutable hotspot; + private long handle; + public PointerIconImpl(DisplayImpl display, ClassResources resource, final DimensionImmutable size, final PointImmutable hotspot, final long handle) { + this.display = display; + this.resource = resource; + this.size = size; + this.hotspot = hotspot; + this.handle=handle; + } + public synchronized final long getHandle() { return handle; } + public synchronized final long validatedHandle() { + synchronized(display.pointerIconList) { + if( !display.pointerIconList.contains(this) ) { + display.pointerIconList.add(this); + } + } + if( 0 == handle ) { + try { + final PointerIconImpl temp = (PointerIconImpl) display.createPointerIcon(true /* isTemp */, resource, hotspot.getX(), hotspot.getY()); + handle = temp.handle; + return handle; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } else { + return handle; + } + } + @Override + public final Display getDisplay() { return display; } + @Override + public final IOUtil.ClassResources getResource() { return resource; } + @Override + public synchronized final boolean isValid() { return 0 != handle; } + @Override + public synchronized final boolean validate() { + if( 0 == handle ) { + return 0 != validatedHandle(); + } + return true; + } + + @Override + public synchronized void destroy() { + if(DisplayImpl.DEBUG) { + System.err.println("PointerIcon.destroy: "+this+", "+display+", "+DisplayImpl.getThreadName()); + } + if( 0 != handle ) { + synchronized(display.pointerIconList) { + display.pointerIconList.remove(this); + } + display.runOnEDTIfAvail(false, new Runnable() { + public void run() { + if( display.isNativeValid() ) { + destroyOnEDT(display.getHandle()); + } + } } ); + } + } + + /** No checks, assume execution on EDT */ + synchronized void destroyOnEDT(final long dpy) { + final long h = handle; + handle = 0; + try { + display.destroyPointerIconImpl(dpy, h); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public final DimensionImmutable getSize() { + return size; + } + @Override + public final PointImmutable getHotspot() { + return hotspot; + } + @Override + public final String toString() { + return "PointerIcon["+DisplayImpl.toHexString(super.hashCode())+", "+display.getFQName()+", "+resource.resourcePaths[0]+", 0x"+Long.toHexString(handle)+", "+size+", "+hotspot+"]"; + } +} \ No newline at end of file diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index d078caa3b..8d9fb8d7e 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -84,7 +84,6 @@ import javax.media.nativewindow.util.Rectangle; import javax.media.nativewindow.util.RectangleImmutable; import jogamp.nativewindow.SurfaceUpdatedHelper; -import jogamp.newt.DisplayImpl.PointerIconImpl; public abstract class WindowImpl implements Window, NEWTEventConsumer { @@ -440,7 +439,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer screen.addMonitorModeListener(monitorModeListenerImpl); setTitleImpl(title); if( null != pointerIcon ) { - setPointerIcon(pointerIcon); + setPointerIconImpl((PointerIconImpl)pointerIcon); } setPointerVisibleImpl(pointerVisible); confinePointerImpl(pointerConfined); @@ -1689,9 +1688,11 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer @Override public final void setPointerIcon(final PointerIcon pi) { if( this.pointerIcon != pi ) { - setPointerIcon(pointerIcon); if( isNativeValid() ) { - setPointerIconImpl((PointerIconImpl)pi); + runOnEDTIfAvail(true, new Runnable() { + public void run() { + setPointerIconImpl((PointerIconImpl)pi); + } } ); } this.pointerIcon = pi; } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index f0f0a955a..30583c48c 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -50,6 +50,7 @@ import com.jogamp.newt.NewtFactory; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.PointerIconImpl; import jogamp.newt.driver.PNGIcon; public class DisplayDriver extends DisplayImpl { @@ -112,21 +113,21 @@ public class DisplayDriver extends DisplayImpl { } @Override - protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { if( PNGIcon.isAvailable() ) { final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { - return new PointerIconImpl( createPointerIcon0(data, width[0], height[0], hotX, hotY), - new Dimension(width[0], height[0]), new Point(hotX, hotY)); final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size); + return new PointerIconImpl( this, pngResource, new Dimension(width[0], height[0]), + new Point(hotX, hotY), createPointerIcon0(data, width[0], height[0], hotX, hotY)); } } return null; } @Override - protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { - destroyPointerIcon0(((PointerIconImpl)pi).handle); + protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + destroyPointerIcon0(piHandle); } public static void runNSApplication() { diff --git a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java index a55fa915a..6f3c95570 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/WindowDriver.java @@ -45,8 +45,8 @@ import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import jogamp.nativewindow.macosx.OSXUtil; +import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; -import jogamp.newt.DisplayImpl.PointerIconImpl; import jogamp.newt.driver.DriverClearFocus; import jogamp.newt.driver.DriverUpdatePosition; @@ -394,17 +394,29 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void setPointerIconImpl(final PointerIconImpl pi) { - OSXUtil.RunOnMainThread(false, new Runnable() { - @Override - public void run() { - setPointerIcon0(getWindowHandle(), null != pi ? pi.handle : 0); - } } ); + if( !isOffscreenInstance ) { + final long piHandle = null != pi ? pi.validatedHandle() : 0; + OSXUtil.RunOnMainThread(true, new Runnable() { // waitUntildone due to PointerIconImpl's Lifecycle ! + @Override + public void run() { + if( !setPointerIcon0(getWindowHandle(), piHandle) ) { + throw new RuntimeException("Failed: "+pi+", "+WindowDriver.this); + } + } } ); + } // else may need offscreen solution ? FIXME } @Override protected boolean setPointerVisibleImpl(final boolean pointerVisible) { if( !isOffscreenInstance ) { - return setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible); + OSXUtil.RunOnMainThread(false, new Runnable() { + @Override + public void run() { + if( !setPointerVisible0(getWindowHandle(), hasFocus(), pointerVisible) ) { + throw new RuntimeException("Failed"); + } + } } ); + return true; // setPointerVisible0 always returns true .. } // else may need offscreen solution ? FIXME return false; } @@ -420,7 +432,9 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl @Override protected void warpPointerImpl(final int x, final int y) { if( !isOffscreenInstance ) { - warpPointer0(getWindowHandle(), x, y); + if( !warpPointer0(getWindowHandle(), x, y) ) { + throw new RuntimeException("Failed"); + } } // else may need offscreen solution ? FIXME } @@ -575,10 +589,10 @@ public class WindowDriver extends WindowImpl implements MutableSurface, DriverCl /** Must be called on Main-Thread */ private native void setAlwaysOnTop0(long window, boolean atop); private static native Object getLocationOnScreen0(long windowHandle, int src_x, int src_y); + private static native boolean setPointerIcon0(long windowHandle, long handle); private static native boolean setPointerVisible0(long windowHandle, boolean hasFocus, boolean visible); private static native boolean confinePointer0(long windowHandle, boolean confine); - private static native void warpPointer0(long windowHandle, int x, int y); - private static native void setPointerIcon0(long windowHandle, long handle); + private static native boolean warpPointer0(long windowHandle, int x, int y); // Window styles private static final int NSBorderlessWindowMask = 0; diff --git a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java index 39b2efd15..1e9c78a5d 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/DisplayDriver.java @@ -43,6 +43,7 @@ import jogamp.nativewindow.windows.RegisteredClass; import jogamp.nativewindow.windows.RegisteredClassFactory; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.PointerIconImpl; import jogamp.newt.driver.PNGIcon; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -104,21 +105,21 @@ public class DisplayDriver extends DisplayImpl { } @Override - protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { if( PNGIcon.isAvailable() ) { final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { - return new PointerIconImpl( createBGRA8888Icon0(data, width[0], height[0], true, hotX, hotY), - new Dimension(width[0], height[0]), new Point(hotX, hotY)); final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size); + return new PointerIconImpl( this, pngResource, new Dimension(width[0], height[0]), + new Point(hotX, hotY), createBGRA8888Icon0(data, width[0], height[0], true, hotX, hotY)); } } return null; } @Override - protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { - destroyIcon0(((PointerIconImpl)pi).handle); + protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + destroyIcon0(piHandle); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java index 764d4fdab..c8d7c65cc 100644 --- a/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/windows/WindowDriver.java @@ -38,8 +38,8 @@ import java.nio.ByteBuffer; import jogamp.nativewindow.windows.GDI; import jogamp.nativewindow.windows.GDIUtil; +import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; -import jogamp.newt.DisplayImpl.PointerIconImpl; import jogamp.newt.driver.PNGIcon; import javax.media.nativewindow.AbstractGraphicsConfiguration; @@ -252,7 +252,7 @@ public class WindowDriver extends WindowImpl { @Override protected void setPointerIconImpl(final PointerIconImpl pi) { - setPointerIcon0(getWindowHandle(), null != pi ? pi.handle : 0); + setPointerIcon0(getWindowHandle(), null != pi ? pi.validatedHandle() : 0); } @Override diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index c377e7f85..150337df4 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -51,6 +51,7 @@ import com.jogamp.nativewindow.x11.X11GraphicsDevice; import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.PointerIconImpl; import jogamp.newt.driver.PNGIcon; public class DisplayDriver extends DisplayImpl { @@ -131,32 +132,21 @@ public class DisplayDriver extends DisplayImpl { protected Boolean isXineramaEnabled() { return isNativeValid() ? Boolean.valueOf(((X11GraphicsDevice)aDevice).isXineramaEnabled()) : null; } @Override - protected PointerIcon createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { if( PNGIcon.isAvailable() ) { final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; if( null != pngResource && 0 < pngResource.resourceCount() ) { final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, false /* toBGRA */, width, height, data_size); - final long handle = runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { - @Override - public Long run(long dpy) { - long h = 0; - try { - h = createPointerIcon0(dpy, data, width[0], height[0], hotX, hotY); - } catch (Exception e) { - e.printStackTrace(); - } - return Long.valueOf(h); - } - }).longValue(); - return new PointerIconImpl(handle, new Dimension(width[0], height[0]), new Point(hotX, hotY)); + final long handle = createPointerIcon0(getHandle(), data, width[0], height[0], hotX, hotY); + return new PointerIconImpl(DisplayDriver.this, pngResource, new Dimension(width[0], height[0]), new Point(hotX, hotY), handle); } } return null; } @Override - protected final void destroyPointerIconImpl(final long displayHandle, final PointerIcon pi) { - destroyPointerIcon0(displayHandle, ((PointerIconImpl)pi).handle); + protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + destroyPointerIcon0(displayHandle, piHandle); } //---------------------------------------------------------------------- diff --git a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java index 0ea2c5358..ad1744f2e 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/WindowDriver.java @@ -40,7 +40,7 @@ import jogamp.nativewindow.x11.X11Lib; import jogamp.nativewindow.x11.X11Util; import jogamp.newt.DisplayImpl; import jogamp.newt.DisplayImpl.DisplayRunnable; -import jogamp.newt.DisplayImpl.PointerIconImpl; +import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; import jogamp.newt.driver.PNGIcon; @@ -279,7 +279,7 @@ public class WindowDriver extends WindowImpl { @Override public Object run(long dpy) { try { - setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.handle : 0); + setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.validatedHandle() : 0); } catch (Exception e) { e.printStackTrace(); } @@ -293,7 +293,15 @@ public class WindowDriver extends WindowImpl { return runWithLockedDisplayDevice( new DisplayImpl.DisplayRunnable() { @Override public Boolean run(long dpy) { - return Boolean.valueOf(setPointerVisible0(dpy, getWindowHandle(), pointerVisible)); + final PointerIconImpl pi = (PointerIconImpl)getPointerIcon(); + final boolean res; + if( pointerVisible && null != pi ) { + setPointerIcon0(dpy, getWindowHandle(), null != pi ? pi.validatedHandle() : 0); + res = true; + } else { + res = setPointerVisible0(dpy, getWindowHandle(), pointerVisible); + } + return Boolean.valueOf(res); } }).booleanValue(); } diff --git a/src/newt/native/MacWindow.m b/src/newt/native/MacWindow.m index 1be3a6ed5..eb5913706 100644 --- a/src/newt/native/MacWindow.m +++ b/src/newt/native/MacWindow.m @@ -347,30 +347,14 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_createPoint JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_destroyPointerIcon0 (JNIEnv *env, jobject unused, jlong handle) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NSCursor * c = (NSCursor*) (intptr_t) handle ; - if( NULL != c ) { - if ( NO == [c isKindOfClass:[NSCursor class]] ) { - DBG_PRINT( "destroyPointerIcon0 NSCursor %p - is of invalid type\n", c); - } else { - DBG_PRINT( "destroyPointerIcon0 %p\n", c); - [c release]; - } + if( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) { + DBG_PRINT( "Not a NSCursor %p\n", c); + return; } - [pool release]; -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0 - (JNIEnv *env, jobject unused, jlong window, jlong handle) -{ + DBG_PRINT( "destroyPointerIcon0 %p\n", c); NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) window; - NSCursor * c = (NSCursor*) (intptr_t) handle ; - if ( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) { - DBG_PRINT( "setPointerIcon0 NSCursor %p - is of invalid type (1)\n", c); - } else { - [mWin setPointerIcon: c]; - } + [c release]; [pool release]; } @@ -717,7 +701,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createView0 NSRect rectView = NSMakeRect(0, 0, w, h); NewtView *myView = [[NewtView alloc] initWithFrame: rectView] ; - DBG_PRINT( "createView0.X.%d - new view: %p\n", myView); + DBG_PRINT( "createView0.X - new view: %p\n", myView); [pool release]; @@ -738,7 +722,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_createWindow NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* myView = (NewtView*) (intptr_t) jview ; - DBG_PRINT( "createWindow0 - %p (this), %d/%d %dx%d, fs %d, style %X, buffType %X, screenidx %d, view %p (START)\n", + DBG_PRINT( "createWindow0 - %p (this), %d/%d %dx%d, fs %d, style %X, buffType %X, view %p (START)\n", (void*)(intptr_t)jthis, (int)x, (int)y, (int)w, (int)h, (int)fullscreen, (int)styleMask, (int)bufferingType, myView); (void)myView; @@ -865,6 +849,7 @@ NS_ENDHANDLER // Set the content view changeContentView(env, jthis, parentView, myWindow, myView, NO); + [myWindow setInitialFirstResponder: myView]; DBG_PRINT( "initWindow0.%d - %p view %p, isVisible %d\n", dbgIdx++, myWindow, myView, [myWindow isVisible]); @@ -965,7 +950,6 @@ NS_ENDHANDLER JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 (JNIEnv *env, jobject unused, jlong window) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow* mWin = (NewtMacWindow*) ((intptr_t) window); if( NULL == mWin ) { DBG_PRINT( "windowClose.0 - NULL NEWT win - abort\n"); @@ -979,6 +963,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_close0 DBG_PRINT( "windowClose.0 - Not a NEWT win - abort\n"); return; } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtView* mView = (NewtView *)[mWin contentView]; BOOL fullscreen = mWin->isFullscreenWindow; BOOL destroyNotifySent, isNSView, isNewtView; @@ -1093,6 +1078,7 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_requestFocus0 #endif DBG_PRINT( "requestFocus - window: %p, force %d, hasFocus %d (START)\n", mWin, force, hasFocus); + [mWin setAcceptsMouseMovedEvents: YES]; [mWin makeFirstResponder: nil]; [mWin orderFrontRegardless]; [mWin makeKeyWindow]; @@ -1331,18 +1317,39 @@ JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_getLocatio (JNIEnv *env, jclass unused, jlong win, jint src_x, jint src_y) { NSObject *nsObj = (NSObject*) ((intptr_t) win); - NewtMacWindow * mWin = NULL; - - if( [nsObj isKindOfClass:[NewtMacWindow class]] ) { - mWin = (NewtMacWindow*) nsObj; - } else { - NewtCommon_throwNewRuntimeException(env, "not NewtMacWindow %p\n", nsObj); + NewtMacWindow * mWin = (NewtMacWindow*) nsObj; + if( ![mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", nsObj); + return NULL; } - NSPoint p0 = [mWin getLocationOnScreen: NSMakePoint(src_x, src_y)]; return (*env)->NewObject(env, pointClz, pointCstr, (jint)p0.x, (jint)p0.y); } +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerIcon0 + (JNIEnv *env, jobject unused, jlong window, jlong handle) +{ + NSCursor *c = (NSCursor*) (intptr_t) handle ; + if ( NULL != c && NO == [c isKindOfClass:[NSCursor class]] ) { + DBG_PRINT("Not a NSCursor %p\n", c); + return JNI_FALSE; + } + NewtMacWindow *mWin = (NewtMacWindow*) (intptr_t) window; + if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", mWin); + return JNI_FALSE; + } + NewtView* nView = (NewtView *) [mWin contentView]; + if( ! [nView isKindOfClass:[NewtView class]] ) { + DBG_PRINT("Not a NewtView %p\n", nView); + return JNI_FALSE; + } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [nView setPointerIcon: c]; + [pool release]; + return JNI_TRUE; +} + /* * Class: Java_jogamp_newt_driver_macosx_WindowDriver * Method: setPointerVisible0 @@ -1351,10 +1358,19 @@ JNIEXPORT jobject JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_getLocatio JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointerVisible0 (JNIEnv *env, jclass clazz, jlong window, jboolean hasFocus, jboolean mouseVisible) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); - [mWin setMouseVisible: ( JNI_TRUE == mouseVisible ) ? YES : NO - hasFocus: ( JNI_TRUE == hasFocus ) ? YES : NO]; + if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", mWin); + return JNI_FALSE; + } + NewtView* nView = (NewtView *) [mWin contentView]; + if( ! [nView isKindOfClass:[NewtView class]] ) { + DBG_PRINT("Not a NewtView %p\n", nView); + return JNI_FALSE; + } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [nView setMouseVisible: ( JNI_TRUE == mouseVisible ) ? YES : NO + hasFocus: ( JNI_TRUE == hasFocus ) ? YES : NO]; [pool release]; return JNI_TRUE; } @@ -1367,9 +1383,18 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_setPointe JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePointer0 (JNIEnv *env, jclass clazz, jlong window, jboolean confine) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); - [mWin setMouseConfined: ( JNI_TRUE == confine ) ? YES : NO]; + if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", mWin); + return JNI_FALSE; + } + NewtView* nView = (NewtView *) [mWin contentView]; + if( ! [nView isKindOfClass:[NewtView class]] ) { + DBG_PRINT("Not a NewtView %p\n", nView); + return JNI_FALSE; + } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [nView setMouseConfined: ( JNI_TRUE == confine ) ? YES : NO]; [pool release]; return JNI_TRUE; } @@ -1379,12 +1404,22 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_confinePo * Method: warpPointer0 * Signature: (JJII)V */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0 +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_macosx_WindowDriver_warpPointer0 (JNIEnv *env, jclass clazz, jlong window, jint x, jint y) { - NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; NewtMacWindow *mWin = (NewtMacWindow*) ((intptr_t) window); - [mWin setMousePosition: [mWin newtRelClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y)]]; + if( ! [mWin isKindOfClass:[NewtMacWindow class]] ) { + DBG_PRINT("Not a NewtMacWindow %p\n", mWin); + return JNI_FALSE; + } + NewtView* nView = (NewtView *) [mWin contentView]; + if( ! [nView isKindOfClass:[NewtView class]] ) { + DBG_PRINT("Not a NewtView %p\n", nView); + return JNI_FALSE; + } + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + [nView setMousePosition: [mWin newtRelClientTLWinPos2AbsBLScreenPos: NSMakePoint(x, y)]]; [pool release]; + return JNI_TRUE; } diff --git a/src/newt/native/NewtMacWindow.h b/src/newt/native/NewtMacWindow.h index 2728c2201..daf75bec7 100644 --- a/src/newt/native/NewtMacWindow.h +++ b/src/newt/native/NewtMacWindow.h @@ -63,6 +63,14 @@ volatile NSTrackingRectTag ptrTrackingTag; NSRect ptrRect; + NSCursor * myCursor; + BOOL modsDown[4]; // shift, ctrl, alt/option, win/command + + BOOL mouseConfined; + BOOL mouseInside; + BOOL mouseVisible; + BOOL cursorIsHidden; + NSPoint lastInsideMousePosition; } - (id)initWithFrame:(NSRect)frameRect; @@ -83,9 +91,6 @@ - (void) setJavaWindowObject: (jobject) javaWindowObj; - (jobject) getJavaWindowObject; -- (void) rightMouseDown: (NSEvent*) theEvent; -- (void) resetCursorRects; - - (void) setDestroyNotifySent: (BOOL) v; - (BOOL) getDestroyNotifySent; @@ -99,6 +104,41 @@ - (void) viewDidHide; - (void) viewDidUnhide; - (BOOL) acceptsFirstResponder; +- (BOOL) becomeFirstResponder; +- (BOOL) resignFirstResponder; + +- (void) removeCursorRects; +- (void) addCursorRects; +- (void) removeMyCursor; +- (void) resetCursorRects; +- (void) setPointerIcon: (NSCursor*)c; +- (void) mouseEntered: (NSEvent*) theEvent; +- (void) mouseExited: (NSEvent*) theEvent; +- (BOOL) updateMouseInside; +- (void) cursorHide:(BOOL)v enter:(int)enterState; +- (void) setPointerIcon:(NSCursor*)c; +- (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus; +- (BOOL) isMouseVisible; +- (void) setMouseConfined:(BOOL)v; +- (void) setMousePosition:(NSPoint)p; +- (void) mouseMoved: (NSEvent*) theEvent; +- (void) scrollWheel: (NSEvent*) theEvent; +- (void) mouseDown: (NSEvent*) theEvent; +- (void) mouseDragged: (NSEvent*) theEvent; +- (void) mouseUp: (NSEvent*) theEvent; +- (void) rightMouseDown: (NSEvent*) theEvent; +- (void) rightMouseDragged: (NSEvent*) theEvent; +- (void) rightMouseUp: (NSEvent*) theEvent; +- (void) otherMouseDown: (NSEvent*) theEvent; +- (void) otherMouseDragged: (NSEvent*) theEvent; +- (void) otherMouseUp: (NSEvent*) theEvent; +- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType; +- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p; + +- (void) handleFlagsChanged:(NSUInteger) mods; +- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods; +- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType; +- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType; @end @@ -108,14 +148,7 @@ @interface NewtMacWindow : NSWindow #endif { - BOOL mouseConfined; - BOOL mouseVisible; - BOOL mouseInside; - BOOL cursorIsHidden; - NSCursor * customCursor; BOOL realized; - BOOL modsDown[4]; // shift, ctrl, alt/option, win/command - NSPoint lastInsideMousePosition; @public BOOL hasPresentationSwitch; NSUInteger defaultPresentationOptions; @@ -147,20 +180,14 @@ - (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p; - (NSSize) newtClientSize2TLSize: (NSSize) nsz; - (NSPoint) getLocationOnScreen: (NSPoint) p; -- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p; -- (BOOL) isMouseInside; -- (void) cursorHide:(BOOL)v enter:(int)enterState; -- (void) setPointerIcon:(NSCursor*)c; -- (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus; -- (void) setMouseConfined:(BOOL)v; -- (void) setMousePosition:(NSPoint)p; - -- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType; -- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType; -- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType; - (void) focusChanged: (BOOL) gained; +- (void) keyDown: (NSEvent*) theEvent; +- (void) keyUp: (NSEvent*) theEvent; +- (void) flagsChanged: (NSEvent *) theEvent; +- (BOOL) acceptsMouseMovedEvents; +- (BOOL) acceptsFirstResponder; - (BOOL) becomeFirstResponder; - (BOOL) resignFirstResponder; - (BOOL) canBecomeKeyWindow; @@ -168,22 +195,7 @@ - (void) resignKeyWindow; - (void) windowDidBecomeKey: (NSNotification *) notification; - (void) windowDidResignKey: (NSNotification *) notification; -- (void) keyDown: (NSEvent*) theEvent; -- (void) keyUp: (NSEvent*) theEvent; -- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods; -- (void) flagsChanged: (NSEvent *) theEvent; -- (void) mouseEntered: (NSEvent*) theEvent; -- (void) mouseExited: (NSEvent*) theEvent; -- (void) mouseMoved: (NSEvent*) theEvent; -- (void) scrollWheel: (NSEvent*) theEvent; -- (void) mouseDown: (NSEvent*) theEvent; -- (void) mouseDragged: (NSEvent*) theEvent; -- (void) mouseUp: (NSEvent*) theEvent; -- (void) rightMouseDown: (NSEvent*) theEvent; -- (void) rightMouseDragged: (NSEvent*) theEvent; -- (void) rightMouseUp: (NSEvent*) theEvent; -- (void) otherMouseDown: (NSEvent*) theEvent; -- (void) otherMouseUp: (NSEvent*) theEvent; + - (void) windowDidResize: (NSNotification*) notification; - (void) windowDidMove: (NSNotification*) notification; - (BOOL) windowClosingImpl: (BOOL) force; diff --git a/src/newt/native/NewtMacWindow.m b/src/newt/native/NewtMacWindow.m index 96965b67a..5ccd9c658 100644 --- a/src/newt/native/NewtMacWindow.m +++ b/src/newt/native/NewtMacWindow.m @@ -86,6 +86,88 @@ static jfloat GetDelta(NSEvent *event, jint javaMods[]) { return (jfloat) delta; } +#define kVK_Shift 0x38 +#define kVK_Option 0x3A +#define kVK_Control 0x3B +#define kVK_Command 0x37 + +static jint mods2JavaMods(NSUInteger mods) +{ + int javaMods = 0; + if (mods & NSShiftKeyMask) { + javaMods |= EVENT_SHIFT_MASK; + } + if (mods & NSControlKeyMask) { + javaMods |= EVENT_CTRL_MASK; + } + if (mods & NSCommandKeyMask) { + javaMods |= EVENT_META_MASK; + } + if (mods & NSAlternateKeyMask) { + javaMods |= EVENT_ALT_MASK; + } + return javaMods; +} + +static CFStringRef CKCH_CreateStringForKey(CGKeyCode keyCode, const UCKeyboardLayout *keyboardLayout) { + UInt32 keysDown = 0; + UniChar chars[4]; + UniCharCount realLength; + + UCKeyTranslate(keyboardLayout, keyCode, + kUCKeyActionDisplay, 0, + LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, + &keysDown, sizeof(chars) / sizeof(chars[0]), &realLength, chars); + + return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1); +} + +static CFMutableDictionaryRef CKCH_CreateCodeToCharDict(TISInputSourceRef keyboard) { + CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(keyboard, kTISPropertyUnicodeKeyLayoutData); + const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); + + CFMutableDictionaryRef codeToCharDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 128, NULL, NULL); + if ( NULL != codeToCharDict ) { + intptr_t i; + for (i = 0; i < 128; ++i) { + CFStringRef string = CKCH_CreateStringForKey((CGKeyCode)i, keyboardLayout); + if( NULL != string ) { + CFIndex stringLen = CFStringGetLength (string); + if ( 0 < stringLen ) { + UniChar character = CFStringGetCharacterAtIndex(string, 0); + DBG_PRINT("CKCH: MAP 0x%X -> %c\n", (int)i, character); + CFDictionaryAddValue(codeToCharDict, (const void *)i, (const void *)(intptr_t)character); + } + CFRelease(string); + } + } + } + return codeToCharDict; +} + +static CFMutableDictionaryRef CKCH_USCodeToNNChar = NULL; + +static void CKCH_CreateDictionaries() { + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(currentKeyboard); + CFRelease(currentKeyboard); +} + +static UniChar CKCH_CharForKeyCode(jshort keyCode) { + UniChar rChar = 0; + + if ( NULL != CKCH_USCodeToNNChar ) { + intptr_t code = (intptr_t) keyCode; + intptr_t character = 0; + + if ( CFDictionaryGetValueIfPresent(CKCH_USCodeToNNChar, (void *)code, (const void **)&character) ) { + rChar = (UniChar) character; + DBG_PRINT("CKCH: OK 0x%X -> 0x%X\n", (int)keyCode, (int)rChar); + } + } + return rChar; +} + static jmethodID enqueueMouseEventID = NULL; static jmethodID enqueueKeyEventID = NULL; static jmethodID requestFocusID = NULL; @@ -122,6 +204,16 @@ static jmethodID windowRepaintID = NULL; pthread_mutex_init(&softLockSync, &softLockSyncAttr); // recursive ptrTrackingTag = 0; + myCursor = NULL; + + modsDown[0] = NO; // shift + modsDown[1] = NO; // ctrl + modsDown[2] = NO; // alt + modsDown[3] = NO; // win + mouseConfined = NO; + mouseVisible = YES; + mouseInside = NO; + cursorIsHidden = NO; DBG_PRINT("NewtView::create: %p (refcnt %d)\n", res, (int)[res retainCount]); return res; @@ -144,10 +236,9 @@ static jmethodID windowRepaintID = NULL; if( 0 < softLockCount ) { NSLog(@"NewtView::dealloc: softLock still hold @ dealloc!\n"); } - if(0 != ptrTrackingTag) { - [self removeTrackingRect: ptrTrackingTag]; - ptrTrackingTag = 0; - } + [self removeCursorRects]; + [self removeMyCursor]; + pthread_mutex_destroy(&softLockSync); DBG_PRINT("NewtView::dealloc.X: %p\n", self); [super dealloc]; @@ -182,26 +273,6 @@ static jmethodID windowRepaintID = NULL; return javaWindowObject; } -- (void) rightMouseDown: (NSEvent*) theEvent -{ - NSResponder* next = [self nextResponder]; - if (next != nil) { - [next rightMouseDown: theEvent]; - } -} - -- (void) resetCursorRects -{ - [super resetCursorRects]; - - if(0 != ptrTrackingTag) { - [self removeTrackingRect: ptrTrackingTag]; - ptrTrackingTag = 0; - } - ptrRect = [self bounds]; - ptrTrackingTag = [self addTrackingRect: ptrRect owner: self userData: nil assumeInside: NO]; -} - - (void) setDestroyNotifySent: (BOOL) v { destroyNotifySent = v; @@ -337,141 +408,462 @@ static jmethodID windowRepaintID = NULL; return YES; } -@end - -static CFStringRef CKCH_CreateStringForKey(CGKeyCode keyCode, const UCKeyboardLayout *keyboardLayout) { - UInt32 keysDown = 0; - UniChar chars[4]; - UniCharCount realLength; - - UCKeyTranslate(keyboardLayout, keyCode, - kUCKeyActionDisplay, 0, - LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, - &keysDown, sizeof(chars) / sizeof(chars[0]), &realLength, chars); - - return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1); +- (BOOL) becomeFirstResponder +{ + DBG_PRINT( "*************** View.becomeFirstResponder\n"); + return [super becomeFirstResponder]; } -static CFMutableDictionaryRef CKCH_CreateCodeToCharDict(TISInputSourceRef keyboard) { - CFDataRef layoutData = (CFDataRef) TISGetInputSourceProperty(keyboard, kTISPropertyUnicodeKeyLayoutData); - const UCKeyboardLayout *keyboardLayout = (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); +- (BOOL) resignFirstResponder +{ + DBG_PRINT( "*************** View.resignFirstResponder\n"); + return [super resignFirstResponder]; +} - CFMutableDictionaryRef codeToCharDict = CFDictionaryCreateMutable(kCFAllocatorDefault, 128, NULL, NULL); - if ( NULL != codeToCharDict ) { - intptr_t i; - for (i = 0; i < 128; ++i) { - CFStringRef string = CKCH_CreateStringForKey((CGKeyCode)i, keyboardLayout); - if( NULL != string ) { - CFIndex stringLen = CFStringGetLength (string); - if ( 0 < stringLen ) { - UniChar character = CFStringGetCharacterAtIndex(string, 0); - DBG_PRINT("CKCH: MAP 0x%X -> %c\n", (int)i, character); - CFDictionaryAddValue(codeToCharDict, (const void *)i, (const void *)(intptr_t)character); - } - CFRelease(string); - } +- (void) removeCursorRects +{ + if(0 != ptrTrackingTag) { + if(NULL != myCursor) { + [self removeCursorRect: ptrRect cursor: myCursor]; } + [self removeTrackingRect: ptrTrackingTag]; + ptrTrackingTag = 0; } - return codeToCharDict; } -static CFMutableDictionaryRef CKCH_USCodeToNNChar = NULL; +- (void) addCursorRects +{ + ptrRect = [self bounds]; + if(NULL != myCursor) { + [self addCursorRect: ptrRect cursor: myCursor]; + } + ptrTrackingTag = [self addTrackingRect: ptrRect owner: self userData: nil assumeInside: NO]; +} -static void CKCH_CreateDictionaries() { - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); - CKCH_USCodeToNNChar = CKCH_CreateCodeToCharDict(currentKeyboard); - CFRelease(currentKeyboard); +- (void) removeMyCursor +{ + if(NULL != myCursor) { + [myCursor release]; + myCursor = NULL; + } } -static UniChar CKCH_CharForKeyCode(jshort keyCode) { - UniChar rChar = 0; +- (void) resetCursorRects +{ + [super resetCursorRects]; - if ( NULL != CKCH_USCodeToNNChar ) { - intptr_t code = (intptr_t) keyCode; - intptr_t character = 0; + [self removeCursorRects]; + [self addCursorRects]; +} - if ( CFDictionaryGetValueIfPresent(CKCH_USCodeToNNChar, (void *)code, (const void **)&character) ) { - rChar = (UniChar) character; - DBG_PRINT("CKCH: OK 0x%X -> 0x%X\n", (int)keyCode, (int)rChar); +- (void) setPointerIcon: (NSCursor*)c +{ + DBG_PRINT( "setPointerIcon: %p -> %p, top %p, mouseInside %d\n", myCursor, c, [NSCursor currentCursor], (int)mouseInside); + if( c != myCursor ) { + [self removeCursorRects]; + [self removeMyCursor]; + myCursor = c; + if( NULL != myCursor ) { + [myCursor retain]; } } - return rChar; + NSWindow* nsWin = [self window]; + if( NULL != nsWin ) { + [nsWin invalidateCursorRectsForView: self]; + } } -@implementation NewtMacWindow - -+ (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz +- (void) mouseEntered: (NSEvent*) theEvent { - enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZSIIISF)V"); - enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISCC)V"); - sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); - visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); - insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); - positionChangedID = (*env)->GetMethodID(env, clazz, "screenPositionChanged", "(ZII)V"); - focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); - windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); - requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V"); - if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID && - positionChangedID && focusChangedID && windowDestroyNotifyID && requestFocusID && windowRepaintID) - { - CKCH_CreateDictionaries(); - return YES; + DBG_PRINT( "mouseEntered: confined %d, visible %d, PointerIcon %p, top %p\n", mouseConfined, mouseVisible, myCursor, [NSCursor currentCursor]); + mouseInside = YES; + [self cursorHide: !mouseVisible enter: 1]; + if(NO == mouseConfined) { + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED]; + } + NSWindow* nsWin = [self window]; + if( NULL != nsWin ) { + [nsWin makeFirstResponder: self]; } - return NO; } -- (id) initWithContentRect: (NSRect) contentRect - styleMask: (NSUInteger) windowStyle - backing: (NSBackingStoreType) bufferingType - defer: (BOOL) deferCreation - isFullscreenWindow:(BOOL)isfs +- (void) mouseExited: (NSEvent*) theEvent { - id res = [super initWithContentRect: contentRect - styleMask: windowStyle - backing: bufferingType - defer: deferCreation]; - // OSX 10.6 - if ( [NSApp respondsToSelector:@selector(currentSystemPresentationOptions)] && - [NSApp respondsToSelector:@selector(setPresentationOptions:)] ) { - hasPresentationSwitch = YES; - defaultPresentationOptions = [NSApp currentSystemPresentationOptions]; - fullscreenPresentationOptions = - // NSApplicationPresentationDefault| - // NSApplicationPresentationAutoHideDock| - NSApplicationPresentationHideDock| - // NSApplicationPresentationAutoHideMenuBar| - NSApplicationPresentationHideMenuBar| - NSApplicationPresentationDisableAppleMenu| - // NSApplicationPresentationDisableProcessSwitching| - // NSApplicationPresentationDisableSessionTermination| - NSApplicationPresentationDisableHideApplication| - // NSApplicationPresentationDisableMenuBarTransparency| - // NSApplicationPresentationFullScreen| // OSX 10.7 - 0 ; + DBG_PRINT( "mouseExited: confined %d, visible %d, PointerIcon %p, top %p\n", mouseConfined, mouseVisible, myCursor, [NSCursor currentCursor]); + if(NO == mouseConfined) { + mouseInside = NO; + [self cursorHide: NO enter: -1]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED]; + [self resignFirstResponder]; } else { - hasPresentationSwitch = NO; - defaultPresentationOptions = 0; - fullscreenPresentationOptions = 0; + [self setMousePosition: lastInsideMousePosition]; } +} - isFullscreenWindow = isfs; - // Why is this necessary? Without it we don't get any of the - // delegate methods like resizing and window movement. - [self setDelegate: self]; - cachedInsets[0] = 0; // l - cachedInsets[1] = 0; // r - cachedInsets[2] = 0; // t - cachedInsets[3] = 0; // b - modsDown[0] = NO; // shift - modsDown[1] = NO; // ctrl - modsDown[2] = NO; // alt - modsDown[3] = NO; // win - mouseConfined = NO; - mouseVisible = YES; - mouseInside = NO; - cursorIsHidden = NO; - customCursor = NULL; +- (void) setMousePosition:(NSPoint)p +{ + NSWindow* nsWin = [self window]; + if( NULL != nsWin ) { + NSScreen* screen = [nsWin screen]; + NSRect screenRect = [screen frame]; + + CGPoint pt = { p.x, screenRect.size.height - p.y }; // y-flip (CG is top-left origin) + CGEventRef ev = CGEventCreateMouseEvent (NULL, kCGEventMouseMoved, pt, kCGMouseButtonLeft); + CGEventPost (kCGHIDEventTap, ev); + } +} + +- (BOOL) updateMouseInside +{ + NSRect viewFrame = [self frame]; + NSPoint l1 = [NSEvent mouseLocation]; + NSPoint l0 = [self screenPos2NewtClientWinPos: l1]; + mouseInside = viewFrame.origin.x <= l0.x && l0.x < (viewFrame.origin.x+viewFrame.size.width) && + viewFrame.origin.y <= l0.y && l0.y < (viewFrame.origin.y+viewFrame.size.height) ; + return mouseInside; +} + +- (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus +{ + mouseVisible = v; + [self updateMouseInside]; + DBG_PRINT( "setMouseVisible: confined %d, visible %d (current: %d), mouseInside %d, hasFocus %d\n", + mouseConfined, mouseVisible, !cursorIsHidden, mouseInside, focus); + if(YES == focus && YES == mouseInside) { + [self cursorHide: !mouseVisible enter: 0]; + } +} +- (BOOL) isMouseVisible +{ + return mouseVisible; +} + +- (void) cursorHide:(BOOL)v enter:(int)enterState +{ + DBG_PRINT( "cursorHide: %d -> %d, enter %d; PointerIcon: %p, top %p\n", + cursorIsHidden, v, enterState, myCursor, [NSCursor currentCursor]); + if(v) { + if(!cursorIsHidden) { + [NSCursor hide]; + cursorIsHidden = YES; + } + } else { + if(cursorIsHidden) { + [NSCursor unhide]; + cursorIsHidden = NO; + } + } +} + +- (void) setMouseConfined:(BOOL)v +{ + mouseConfined = v; + DBG_PRINT( "setMouseConfined: confined %d, visible %d\n", mouseConfined, mouseVisible); +} + +- (void) mouseMoved: (NSEvent*) theEvent +{ + if( mouseInside ) { + NSCursor * currentCursor = [NSCursor currentCursor]; + BOOL setCursor = NULL != myCursor && NO == cursorIsHidden && currentCursor != myCursor; + DBG_PRINT( "mouseMoved.set: %d; mouseInside %d, CursorHidden %d, PointerIcon: %p, top %p\n", + setCursor, mouseInside, cursorIsHidden, myCursor, currentCursor); + if( setCursor ) { + // FIXME: Workaround missing NSCursor update for 'fast moving' pointer + [myCursor set]; + } + lastInsideMousePosition = [NSEvent mouseLocation]; + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; + } +} + +- (void) scrollWheel: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_WHEEL_MOVED]; +} + +- (void) mouseDown: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; +} + +- (void) mouseDragged: (NSEvent*) theEvent +{ + lastInsideMousePosition = [NSEvent mouseLocation]; + // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; +} + +- (void) mouseUp: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; +} + +- (void) rightMouseDown: (NSEvent*) theEvent +{ + NSResponder* next = [self nextResponder]; + if (next != nil) { + [next rightMouseDown: theEvent]; + } + // FIXME: ^^ OR [super rightMouseDown: theEvent] ? + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; +} + +- (void) rightMouseDragged: (NSEvent*) theEvent +{ + lastInsideMousePosition = [NSEvent mouseLocation]; + // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; +} + +- (void) rightMouseUp: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; +} + +- (void) otherMouseDown: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; +} + +- (void) otherMouseDragged: (NSEvent*) theEvent +{ + lastInsideMousePosition = [NSEvent mouseLocation]; + // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; +} + +- (void) otherMouseUp: (NSEvent*) theEvent +{ + [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; +} + +- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType +{ + if (javaWindowObject == NULL) { + DBG_PRINT("sendMouseEvent: null javaWindowObject\n"); + return; + } + int shallBeDetached = 0; + JNIEnv* env; + if( NULL != jvmHandle ) { + env = NewtCommon_GetJNIEnv(jvmHandle, [self getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + } else { + env = NULL; + } + if(NULL==env) { + DBG_PRINT("sendMouseEvent: JVM %p JNIEnv %p\n", jvmHandle, env); + return; + } + jint javaMods[] = { 0 } ; + javaMods[0] = mods2JavaMods([event modifierFlags]); + + // convert to 1-based button number (or use zero if no button is involved) + // TODO: detect mouse button when mouse wheel scrolled + jshort javaButtonNum = 0; + jfloat scrollDeltaY = 0.0f; + switch ([event type]) { + case NSScrollWheel: { + scrollDeltaY = GetDelta(event, javaMods); + javaButtonNum = 1; + break; + } + case NSLeftMouseDown: + case NSLeftMouseUp: + case NSLeftMouseDragged: + javaButtonNum = 1; + break; + case NSRightMouseDown: + case NSRightMouseUp: + case NSRightMouseDragged: + javaButtonNum = 3; + break; + case NSOtherMouseDown: + case NSOtherMouseUp: + case NSOtherMouseDragged: + javaButtonNum = 2; + break; + } + + if (evType == EVENT_MOUSE_WHEEL_MOVED && scrollDeltaY == 0) { + // ignore 0 increment wheel scroll events + return; + } + if (evType == EVENT_MOUSE_PRESSED) { + (*env)->CallVoidMethod(env, javaWindowObject, requestFocusID, JNI_FALSE); + } + + NSPoint location = [self screenPos2NewtClientWinPos: [NSEvent mouseLocation]]; + + (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID, JNI_FALSE, + evType, javaMods[0], + (jint) location.x, (jint) location.y, + javaButtonNum, scrollDeltaY); + + /* if (shallBeDetached) { + (*jvmHandle)->DetachCurrentThread(jvmHandle); + } */ +} + +- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p +{ + NSRect viewFrame = [self frame]; + + NSRect r; + r.origin.x = p.x; + r.origin.y = p.y; + r.size.width = 0; + r.size.height = 0; + // NSRect rS = [[self window] convertRectFromScreen: r]; // 10.7 + NSPoint oS = [[self window] convertScreenToBase: r.origin]; + oS.y = viewFrame.size.height - oS.y; // y-flip + return oS; +} + +- (void) handleFlagsChanged:(NSUInteger) mods +{ + [self handleFlagsChanged: NSShiftKeyMask keyIndex: 0 keyCode: kVK_Shift modifiers: mods]; + [self handleFlagsChanged: NSControlKeyMask keyIndex: 1 keyCode: kVK_Control modifiers: mods]; + [self handleFlagsChanged: NSAlternateKeyMask keyIndex: 2 keyCode: kVK_Option modifiers: mods]; + [self handleFlagsChanged: NSCommandKeyMask keyIndex: 3 keyCode: kVK_Command modifiers: mods]; +} + +- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods +{ + if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { + modsDown[keyIdx] = YES; + [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_PRESSED]; + } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { + modsDown[keyIdx] = NO; + [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_RELEASED]; + } +} + +- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType +{ + jshort keyCode = (jshort) [event keyCode]; + NSString* chars = [event charactersIgnoringModifiers]; + NSUInteger mods = [event modifierFlags]; + [self sendKeyEvent: keyCode characters: chars modifiers: mods eventType: evType]; +} + +- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType +{ + if (javaWindowObject == NULL) { + DBG_PRINT("sendKeyEvent: null javaWindowObject\n"); + return; + } + int shallBeDetached = 0; + JNIEnv* env; + if( NULL != jvmHandle ) { + env = NewtCommon_GetJNIEnv(jvmHandle, [self getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + } else { + env = NULL; + } + if(NULL==env) { + DBG_PRINT("sendKeyEvent: JVM %p JNIEnv %p\n", jvmHandle, env); + return; + } + + int i; + int len = NULL != chars ? [chars length] : 0; + jint javaMods = mods2JavaMods(mods); + + if(len > 0) { + // printable chars + for (i = 0; i < len; i++) { + // Note: the key code in the NSEvent does not map to anything we can use + UniChar keyChar = (UniChar) [chars characterAtIndex: i]; + UniChar keySymChar = CKCH_CharForKeyCode(keyCode); + + DBG_PRINT("sendKeyEvent: %d/%d code 0x%X, char 0x%X, mods 0x%X/0x%X -> keySymChar 0x%X\n", i, len, (int)keyCode, (int)keyChar, + (int)mods, (int)javaMods, (int)keySymChar); + + (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, + evType, javaMods, keyCode, (jchar)keyChar, (jchar)keySymChar); + } + } else { + // non-printable chars + jchar keyChar = (jchar) 0; + + DBG_PRINT("sendKeyEvent: code 0x%X\n", (int)keyCode); + + (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, + evType, javaMods, keyCode, keyChar, keyChar); + } + + /* if (shallBeDetached) { + (*jvmHandle)->DetachCurrentThread(jvmHandle); + } */ +} + +@end + +@implementation NewtMacWindow + ++ (BOOL) initNatives: (JNIEnv*) env forClass: (jclass) clazz +{ + enqueueMouseEventID = (*env)->GetMethodID(env, clazz, "enqueueMouseEvent", "(ZSIIISF)V"); + enqueueKeyEventID = (*env)->GetMethodID(env, clazz, "enqueueKeyEvent", "(ZSISCC)V"); + sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); + insetsChangedID = (*env)->GetMethodID(env, clazz, "insetsChanged", "(ZIIII)V"); + positionChangedID = (*env)->GetMethodID(env, clazz, "screenPositionChanged", "(ZII)V"); + focusChangedID = (*env)->GetMethodID(env, clazz, "focusChanged", "(ZZ)V"); + windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); + windowRepaintID = (*env)->GetMethodID(env, clazz, "windowRepaint", "(ZIIII)V"); + requestFocusID = (*env)->GetMethodID(env, clazz, "requestFocus", "(Z)V"); + if (enqueueMouseEventID && enqueueKeyEventID && sizeChangedID && visibleChangedID && insetsChangedID && + positionChangedID && focusChangedID && windowDestroyNotifyID && requestFocusID && windowRepaintID) + { + CKCH_CreateDictionaries(); + return YES; + } + return NO; +} + +- (id) initWithContentRect: (NSRect) contentRect + styleMask: (NSUInteger) windowStyle + backing: (NSBackingStoreType) bufferingType + defer: (BOOL) deferCreation + isFullscreenWindow:(BOOL)isfs +{ + id res = [super initWithContentRect: contentRect + styleMask: windowStyle + backing: bufferingType + defer: deferCreation]; + // OSX 10.6 + if ( [NSApp respondsToSelector:@selector(currentSystemPresentationOptions)] && + [NSApp respondsToSelector:@selector(setPresentationOptions:)] ) { + hasPresentationSwitch = YES; + defaultPresentationOptions = [NSApp currentSystemPresentationOptions]; + fullscreenPresentationOptions = + // NSApplicationPresentationDefault| + // NSApplicationPresentationAutoHideDock| + NSApplicationPresentationHideDock| + // NSApplicationPresentationAutoHideMenuBar| + NSApplicationPresentationHideMenuBar| + NSApplicationPresentationDisableAppleMenu| + // NSApplicationPresentationDisableProcessSwitching| + // NSApplicationPresentationDisableSessionTermination| + NSApplicationPresentationDisableHideApplication| + // NSApplicationPresentationDisableMenuBarTransparency| + // NSApplicationPresentationFullScreen| // OSX 10.7 + 0 ; + } else { + hasPresentationSwitch = NO; + defaultPresentationOptions = 0; + fullscreenPresentationOptions = 0; + } + + isFullscreenWindow = isfs; + // Why is this necessary? Without it we don't get any of the + // delegate methods like resizing and window movement. + [self setDelegate: self]; + cachedInsets[0] = 0; // l + cachedInsets[1] = 0; // r + cachedInsets[2] = 0; // t + cachedInsets[3] = 0; // b realized = YES; DBG_PRINT("NewtWindow::create: %p, realized %d, hasPresentationSwitch %d[defaultOptions 0x%X, fullscreenOptions 0x%X], (refcnt %d)\n", res, realized, (int)hasPresentationSwitch, (int)defaultPresentationOptions, (int)fullscreenPresentationOptions, (int)[res retainCount]); @@ -577,343 +969,79 @@ static UniChar CKCH_CharForKeyCode(jshort keyCode) { NSScreen* screen = [self screen]; NSRect screenFrame = [screen frame]; - DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: screen %d/%d %dx%d\n", - (int)screenFrame.origin.x, (int)screenFrame.origin.y, (int)screenFrame.size.width, (int)screenFrame.size.height); - - NSPoint r = NSMakePoint(screenFrame.origin.x + p.x, - screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight); - - DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: result %d/%d\n", (int)r.x, (int)r.y); - - return r; -} - -/** - * p rel client window position w/ top-left origin - * returns: abs screen position w/ bottom-left origin - */ -- (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p -{ - NSRect winFrame = [self frame]; - - NSView* mView = [self contentView]; - NSRect mViewFrame = [mView frame]; - - return NSMakePoint(winFrame.origin.x + p.x, - winFrame.origin.y + ( mViewFrame.size.height - p.y ) ); // y-flip in view -} - -- (NSSize) newtClientSize2TLSize: (NSSize) nsz -{ - NSSize topSZ = { nsz.width, nsz.height + cachedInsets[2] + cachedInsets[3] }; // height + insets.top + insets.bottom - return topSZ; -} - -/** - * y-flips input / output - * p rel client window position w/ top-left origin - * returns: location in 0/0 top-left space. - */ -- (NSPoint) getLocationOnScreen: (NSPoint) p -{ - NSScreen* screen = [self screen]; - NSRect screenRect = [screen frame]; - - NSView* view = [self contentView]; - NSRect viewFrame = [view frame]; - - NSRect r; - r.origin.x = p.x; - r.origin.y = viewFrame.size.height - p.y; // y-flip - r.size.width = 0; - r.size.height = 0; - // NSRect rS = [win convertRectToScreen: r]; // 10.7 - NSPoint oS = [self convertBaseToScreen: r.origin]; - oS.y = screenRect.origin.y + screenRect.size.height - oS.y; - return oS; -} - -- (NSPoint) screenPos2NewtClientWinPos: (NSPoint) p -{ - NSView* view = [self contentView]; - NSRect viewFrame = [view frame]; - - NSRect r; - r.origin.x = p.x; - r.origin.y = p.y; - r.size.width = 0; - r.size.height = 0; - // NSRect rS = [win convertRectFromScreen: r]; // 10.7 - NSPoint oS = [self convertScreenToBase: r.origin]; - oS.y = viewFrame.size.height - oS.y; // y-flip - return oS; -} - -- (BOOL) isMouseInside -{ - NSView* view = [self contentView]; - NSRect viewFrame = [view frame]; - NSPoint l1 = [NSEvent mouseLocation]; - NSPoint l0 = [self screenPos2NewtClientWinPos: l1]; - return viewFrame.origin.x <= l0.x && l0.x < (viewFrame.origin.x+viewFrame.size.width) && - viewFrame.origin.y <= l0.y && l0.y < (viewFrame.origin.y+viewFrame.size.height) ; -} - -- (void) setMouseVisible:(BOOL)v hasFocus:(BOOL)focus -{ - mouseVisible = v; - mouseInside = [self isMouseInside]; - DBG_PRINT( "setMouseVisible: confined %d, visible %d (current: %d), mouseInside %d, hasFocus %d\n", - mouseConfined, mouseVisible, !cursorIsHidden, mouseInside, focus); - if(YES == focus && YES == mouseInside) { - [self cursorHide: !mouseVisible enter: 0]; - } -} - -- (void) setPointerIcon:(NSCursor*)c -{ - DBG_PRINT( "setPointerIcon: mouseInside cursor: %p -> %p (glob %p), mouseInside %d\n", customCursor, c, [NSCursor currentCursor], (int)mouseInside); - if(YES == mouseInside) { - if( NULL != c ) { - DBG_PRINT( "setPointerIcon push: %p\n", c); - [c push]; - } else if( NULL != customCursor ) { - if ( NO == [customCursor isKindOfClass:[NSCursor class]] ) { - DBG_PRINT( "setPointerIcon0 NSCursor %p - is of invalid type (2)\n", customCursor); - if( [NSCursor currentCursor] == customCursor ) { - [NSCursor pop]; - } - } else if( [NSCursor currentCursor] == customCursor ) { - DBG_PRINT( "setPointerIcon pop: %p\n", customCursor); - [customCursor pop]; - } - } - } - customCursor = c; -} - -- (void) cursorHide:(BOOL)v enter:(int)enterState -{ - DBG_PRINT( "cursorHide: %d -> %d, enter %d\n", cursorIsHidden, v, enterState); - if( NULL != customCursor ) { - if ( NO == [customCursor isKindOfClass:[NSCursor class]] ) { - DBG_PRINT( "setPointerIcon0 NSCursor %p - is of invalid type (3)\n", customCursor); - if( [NSCursor currentCursor] == customCursor ) { - [NSCursor pop]; - } - } else { - if( 1 == enterState && [NSCursor currentCursor] != customCursor ) { - DBG_PRINT( "cursorHide.PointerIcon push: %p\n", customCursor); - [customCursor push]; - } else if( -1 == enterState && [NSCursor currentCursor] == customCursor ) { - DBG_PRINT( "cursorHide.PointerIcon pop: %p\n", customCursor); - [customCursor pop]; - } - } - } - if(v) { - if(!cursorIsHidden) { - [NSCursor hide]; - cursorIsHidden = YES; - } - } else { - if(cursorIsHidden) { - [NSCursor unhide]; - cursorIsHidden = NO; - } - } -} - -- (void) setMouseConfined:(BOOL)v -{ - mouseConfined = v; - DBG_PRINT( "setMouseConfined: confined %d, visible %d\n", mouseConfined, mouseVisible); -} - -- (void) setMousePosition:(NSPoint)p -{ - NSScreen* screen = [self screen]; - NSRect screenRect = [screen frame]; - - CGPoint pt = { p.x, screenRect.size.height - p.y }; // y-flip (CG is top-left origin) - CGEventRef ev = CGEventCreateMouseEvent (NULL, kCGEventMouseMoved, pt, kCGMouseButtonLeft); - CGEventPost (kCGHIDEventTap, ev); -} - -static jint mods2JavaMods(NSUInteger mods) -{ - int javaMods = 0; - if (mods & NSShiftKeyMask) { - javaMods |= EVENT_SHIFT_MASK; - } - if (mods & NSControlKeyMask) { - javaMods |= EVENT_CTRL_MASK; - } - if (mods & NSCommandKeyMask) { - javaMods |= EVENT_META_MASK; - } - if (mods & NSAlternateKeyMask) { - javaMods |= EVENT_ALT_MASK; - } - return javaMods; -} - -- (void) sendKeyEvent: (NSEvent*) event eventType: (jshort) evType -{ - jshort keyCode = (jshort) [event keyCode]; - NSString* chars = [event charactersIgnoringModifiers]; - NSUInteger mods = [event modifierFlags]; - [self sendKeyEvent: keyCode characters: chars modifiers: mods eventType: evType]; -} - -- (void) sendKeyEvent: (jshort) keyCode characters: (NSString*) chars modifiers: (NSUInteger)mods eventType: (jshort) evType -{ - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { - return; - } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; - if (javaWindowObject == NULL) { - DBG_PRINT("sendKeyEvent: null javaWindowObject\n"); - return; - } - int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; - JNIEnv* env; - if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); - } else { - env = NULL; - } - if(NULL==env) { - DBG_PRINT("sendKeyEvent: JVM %p JNIEnv %p\n", jvmHandle, env); - return; - } - - int i; - int len = NULL != chars ? [chars length] : 0; - jint javaMods = mods2JavaMods(mods); - - if(len > 0) { - // printable chars - for (i = 0; i < len; i++) { - // Note: the key code in the NSEvent does not map to anything we can use - UniChar keyChar = (UniChar) [chars characterAtIndex: i]; - UniChar keySymChar = CKCH_CharForKeyCode(keyCode); - - DBG_PRINT("sendKeyEvent: %d/%d code 0x%X, char 0x%X -> keySymChar 0x%X\n", i, len, (int)keyCode, (int)keyChar, (int)keySymChar); - - (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, (jchar)keyChar, (jchar)keySymChar); - } - } else { - // non-printable chars - jchar keyChar = (jchar) 0; + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: screen %d/%d %dx%d\n", + (int)screenFrame.origin.x, (int)screenFrame.origin.y, (int)screenFrame.size.width, (int)screenFrame.size.height); - DBG_PRINT("sendKeyEvent: code 0x%X\n", (int)keyCode); + NSPoint r = NSMakePoint(screenFrame.origin.x + p.x, + screenFrame.origin.y + screenFrame.size.height - p.y - totalHeight); - (*env)->CallVoidMethod(env, javaWindowObject, enqueueKeyEventID, JNI_FALSE, - evType, javaMods, keyCode, keyChar, keyChar); - } + DBG_PRINT( "newtAbsClientTLWinPos2AbsBLScreenPos: result %d/%d\n", (int)r.x, (int)r.y); - /* if (shallBeDetached) { - (*jvmHandle)->DetachCurrentThread(jvmHandle); - } */ + return r; } -- (void) sendMouseEvent: (NSEvent*) event eventType: (jshort) evType +/** + * p rel client window position w/ top-left origin + * returns: abs screen position w/ bottom-left origin + */ +- (NSPoint) newtRelClientTLWinPos2AbsBLScreenPos: (NSPoint) p { - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { - return; - } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; - if (javaWindowObject == NULL) { - DBG_PRINT("sendMouseEvent: null javaWindowObject\n"); - return; - } - int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; - JNIEnv* env; - if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); - } else { - env = NULL; - } - if(NULL==env) { - DBG_PRINT("sendMouseEvent: JVM %p JNIEnv %p\n", jvmHandle, env); - return; - } - jint javaMods[] = { 0 } ; - javaMods[0] = mods2JavaMods([event modifierFlags]); + NSRect winFrame = [self frame]; - // convert to 1-based button number (or use zero if no button is involved) - // TODO: detect mouse button when mouse wheel scrolled - jshort javaButtonNum = 0; - jfloat scrollDeltaY = 0.0f; - switch ([event type]) { - case NSScrollWheel: { - scrollDeltaY = GetDelta(event, javaMods); - javaButtonNum = 1; - break; - } - case NSLeftMouseDown: - case NSLeftMouseUp: - case NSLeftMouseDragged: - javaButtonNum = 1; - break; - case NSRightMouseDown: - case NSRightMouseUp: - case NSRightMouseDragged: - javaButtonNum = 3; - break; - case NSOtherMouseDown: - case NSOtherMouseUp: - case NSOtherMouseDragged: - javaButtonNum = 2; - break; - } + NSView* mView = [self contentView]; + NSRect mViewFrame = [mView frame]; - if (evType == EVENT_MOUSE_WHEEL_MOVED && scrollDeltaY == 0) { - // ignore 0 increment wheel scroll events - return; - } - if (evType == EVENT_MOUSE_PRESSED) { - (*env)->CallVoidMethod(env, javaWindowObject, requestFocusID, JNI_FALSE); - } + return NSMakePoint(winFrame.origin.x + p.x, + winFrame.origin.y + ( mViewFrame.size.height - p.y ) ); // y-flip in view +} - NSPoint location = [self screenPos2NewtClientWinPos: [NSEvent mouseLocation]]; +- (NSSize) newtClientSize2TLSize: (NSSize) nsz +{ + NSSize topSZ = { nsz.width, nsz.height + cachedInsets[2] + cachedInsets[3] }; // height + insets.top + insets.bottom + return topSZ; +} - (*env)->CallVoidMethod(env, javaWindowObject, enqueueMouseEventID, JNI_FALSE, - evType, javaMods[0], - (jint) location.x, (jint) location.y, - javaButtonNum, scrollDeltaY); +/** + * y-flips input / output + * p rel client window position w/ top-left origin + * returns: location in 0/0 top-left space. + */ +- (NSPoint) getLocationOnScreen: (NSPoint) p +{ + NSScreen* screen = [self screen]; + NSRect screenRect = [screen frame]; - /* if (shallBeDetached) { - (*jvmHandle)->DetachCurrentThread(jvmHandle); - } */ + NSView* view = [self contentView]; + NSRect viewFrame = [view frame]; + + NSRect r; + r.origin.x = p.x; + r.origin.y = viewFrame.size.height - p.y; // y-flip + r.size.width = 0; + r.size.height = 0; + // NSRect rS = [win convertRectToScreen: r]; // 10.7 + NSPoint oS = [self convertBaseToScreen: r.origin]; + oS.y = screenRect.origin.y + screenRect.size.height - oS.y; + return oS; } - (void) focusChanged: (BOOL) gained { DBG_PRINT( "focusChanged: gained %d\n", gained); - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { + NewtView* newtView = (NewtView *) [self contentView]; + if( ! [newtView isKindOfClass:[NewtView class]] ) { return; } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; + jobject javaWindowObject = [newtView getJavaWindowObject]; if (javaWindowObject == NULL) { DBG_PRINT("focusChanged: null javaWindowObject\n"); return; } int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; + JavaVM *jvmHandle = [newtView getJVMHandle]; JNIEnv* env; if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + env = NewtCommon_GetJNIEnv(jvmHandle, [newtView getJVMVersion], 1 /* asDaemon */, &shallBeDetached); } else { env = NULL; } @@ -929,15 +1057,50 @@ static jint mods2JavaMods(NSUInteger mods) } */ } +- (void) keyDown: (NSEvent*) theEvent +{ + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + [newtView sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_PRESSED]; + } +} + +- (void) keyUp: (NSEvent*) theEvent +{ + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + [newtView sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_RELEASED]; + } +} + +- (void) flagsChanged:(NSEvent *) theEvent +{ + NSUInteger mods = [theEvent modifierFlags]; + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + [newtView handleFlagsChanged: mods]; + } +} + +- (BOOL) acceptsMouseMovedEvents +{ + return YES; +} + +- (BOOL) acceptsFirstResponder +{ + return YES; +} + - (BOOL) becomeFirstResponder { - DBG_PRINT( "*************** becomeFirstResponder\n"); + DBG_PRINT( "*************** Win.becomeFirstResponder\n"); return [super becomeFirstResponder]; } - (BOOL) resignFirstResponder { - DBG_PRINT( "*************** resignFirstResponder\n"); + DBG_PRINT( "*************** Win.resignFirstResponder\n"); return [super resignFirstResponder]; } @@ -965,9 +1128,12 @@ static jint mods2JavaMods(NSUInteger mods) - (void) windowDidBecomeKey: (NSNotification *) notification { DBG_PRINT( "*************** windowDidBecomeKey\n"); - mouseInside = [self isMouseInside]; - if(YES == mouseInside) { - [self cursorHide: !mouseVisible enter: 0]; + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + BOOL mouseInside = [newtView updateMouseInside]; + if(YES == mouseInside) { + [newtView cursorHide: ![newtView isMouseVisible] enter: 1]; + } } [self focusChanged: YES]; } @@ -979,128 +1145,6 @@ static jint mods2JavaMods(NSUInteger mods) [self focusChanged: NO]; } -- (void) keyDown: (NSEvent*) theEvent -{ - [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_PRESSED]; -} - -- (void) keyUp: (NSEvent*) theEvent -{ - [self sendKeyEvent: theEvent eventType: (jshort)EVENT_KEY_RELEASED]; -} - -#define kVK_Shift 0x38 -#define kVK_Option 0x3A -#define kVK_Control 0x3B -#define kVK_Command 0x37 - -- (void) handleFlagsChanged:(int) keyMask keyIndex: (int) keyIdx keyCode: (int) keyCode modifiers: (NSUInteger) mods -{ - if ( NO == modsDown[keyIdx] && 0 != ( mods & keyMask ) ) { - modsDown[keyIdx] = YES; - [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_PRESSED]; - } else if ( YES == modsDown[keyIdx] && 0 == ( mods & keyMask ) ) { - modsDown[keyIdx] = NO; - [self sendKeyEvent: (jshort)keyCode characters: NULL modifiers: mods|keyMask eventType: (jshort)EVENT_KEY_RELEASED]; - } -} - -- (void) flagsChanged:(NSEvent *) theEvent -{ - NSUInteger mods = [theEvent modifierFlags]; - - // BOOL modsDown[4]; // shift, ctrl, alt/option, win/command - - [self handleFlagsChanged: NSShiftKeyMask keyIndex: 0 keyCode: kVK_Shift modifiers: mods]; - [self handleFlagsChanged: NSControlKeyMask keyIndex: 1 keyCode: kVK_Control modifiers: mods]; - [self handleFlagsChanged: NSAlternateKeyMask keyIndex: 2 keyCode: kVK_Option modifiers: mods]; - [self handleFlagsChanged: NSCommandKeyMask keyIndex: 3 keyCode: kVK_Command modifiers: mods]; -} - -- (void) mouseEntered: (NSEvent*) theEvent -{ - DBG_PRINT( "mouseEntered: confined %d, visible %d\n", mouseConfined, mouseVisible); - mouseInside = YES; - [self cursorHide: !mouseVisible enter: 1]; - if(NO == mouseConfined) { - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_ENTERED]; - } -} - -- (void) mouseExited: (NSEvent*) theEvent -{ - DBG_PRINT( "mouseExited: confined %d, visible %d\n", mouseConfined, mouseVisible); - if(NO == mouseConfined) { - mouseInside = NO; - [self cursorHide: NO enter: -1]; - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_EXITED]; - } else { - [self setMousePosition: lastInsideMousePosition]; - } -} - -- (void) mouseMoved: (NSEvent*) theEvent -{ - lastInsideMousePosition = [NSEvent mouseLocation]; - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; -} - -- (void) scrollWheel: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_WHEEL_MOVED]; -} - -- (void) mouseDown: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; -} - -- (void) mouseDragged: (NSEvent*) theEvent -{ - lastInsideMousePosition = [NSEvent mouseLocation]; - // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; -} - -- (void) mouseUp: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; -} - -- (void) rightMouseDown: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; -} - -- (void) rightMouseDragged: (NSEvent*) theEvent -{ - lastInsideMousePosition = [NSEvent mouseLocation]; - // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; -} - -- (void) rightMouseUp: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; -} - -- (void) otherMouseDown: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_PRESSED]; -} - -- (void) otherMouseDragged: (NSEvent*) theEvent -{ - lastInsideMousePosition = [NSEvent mouseLocation]; - // Note use of MOUSE_MOVED event type because mouse dragged events are synthesized by Java - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_MOVED]; -} - -- (void) otherMouseUp: (NSEvent*) theEvent -{ - [self sendMouseEvent: theEvent eventType: EVENT_MOUSE_RELEASED]; -} - - (void)windowDidResize: (NSNotification*) notification { JNIEnv* env = NULL; @@ -1108,14 +1152,13 @@ static jint mods2JavaMods(NSUInteger mods) int shallBeDetached = 0; JavaVM *jvmHandle = NULL; - NSView* nsview = [self contentView]; - if( [nsview isKindOfClass:[NewtView class]] ) { - NewtView* view = (NewtView *) nsview; - javaWindowObject = [view getJavaWindowObject]; + NewtView* newtView = (NewtView *) [self contentView]; + if( [newtView isKindOfClass:[NewtView class]] ) { + javaWindowObject = [newtView getJavaWindowObject]; if (javaWindowObject != NULL) { - jvmHandle = [view getJVMHandle]; + jvmHandle = [newtView getJVMHandle]; if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + env = NewtCommon_GetJNIEnv(jvmHandle, [newtView getJVMVersion], 1 /* asDaemon */, &shallBeDetached); } } } @@ -1139,21 +1182,20 @@ static jint mods2JavaMods(NSUInteger mods) - (void)windowDidMove: (NSNotification*) notification { - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { + NewtView* newtView = (NewtView *) [self contentView]; + if( ! [newtView isKindOfClass:[NewtView class]] ) { return; } - NewtView* view = (NewtView *) nsview; - jobject javaWindowObject = [view getJavaWindowObject]; + jobject javaWindowObject = [newtView getJavaWindowObject]; if (javaWindowObject == NULL) { DBG_PRINT("windowDidMove: null javaWindowObject\n"); return; } int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; + JavaVM *jvmHandle = [newtView getJVMHandle]; JNIEnv* env; if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + env = NewtCommon_GetJNIEnv(jvmHandle, [newtView getJVMVersion], 1 /* asDaemon */, &shallBeDetached); } else { env = NULL; } @@ -1186,32 +1228,31 @@ static jint mods2JavaMods(NSUInteger mods) jboolean closed = JNI_FALSE; NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - [self cursorHide: NO enter: -1]; - - NSView* nsview = [self contentView]; - if( ! [nsview isKindOfClass:[NewtView class]] ) { + NewtView* newtView = (NewtView *) [self contentView]; + if( ! [newtView isKindOfClass:[NewtView class]] ) { return NO; } - NewtView* view = (NewtView *) nsview; - if( false == [view getDestroyNotifySent] ) { - jobject javaWindowObject = [view getJavaWindowObject]; + [newtView cursorHide: NO enter: -1]; + + if( false == [newtView getDestroyNotifySent] ) { + jobject javaWindowObject = [newtView getJavaWindowObject]; DBG_PRINT( "*************** windowWillClose.0: %p\n", (void *)(intptr_t)javaWindowObject); if (javaWindowObject == NULL) { DBG_PRINT("windowWillClose: null javaWindowObject\n"); return NO; } int shallBeDetached = 0; - JavaVM *jvmHandle = [view getJVMHandle]; + JavaVM *jvmHandle = [newtView getJVMHandle]; JNIEnv* env = NULL; NS_DURING if( NULL != jvmHandle ) { - env = NewtCommon_GetJNIEnv(jvmHandle, [view getJVMVersion], 1 /* asDaemon */, &shallBeDetached); + env = NewtCommon_GetJNIEnv(jvmHandle, [newtView getJVMVersion], 1 /* asDaemon */, &shallBeDetached); } NS_HANDLER jvmHandle = NULL; env = NULL; - [view setJVMHandle: NULL]; + [newtView setJVMHandle: NULL]; DBG_PRINT("windowWillClose: JVMHandler Exception\n"); NS_ENDHANDLER DBG_PRINT("windowWillClose: JVM %p JNIEnv %p\n", jvmHandle, env); @@ -1219,11 +1260,11 @@ NS_ENDHANDLER return NO; } - [view setDestroyNotifySent: true]; // earmark assumption of being closed + [newtView setDestroyNotifySent: true]; // earmark assumption of being closed closed = (*env)->CallBooleanMethod(env, javaWindowObject, windowDestroyNotifyID, force ? JNI_TRUE : JNI_FALSE); if(!force && !closed) { // not closed on java side, not force -> clear flag - [view setDestroyNotifySent: false]; + [newtView setDestroyNotifySent: false]; } /* if (shallBeDetached) { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index efec961de..8cc676291 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -85,6 +85,7 @@ public class TestGearsES2NEWT extends UITestCase { static boolean waitForKey = false; static boolean mouseVisible = true; static boolean mouseConfined = false; + static boolean setPointerIcon = false; static boolean showFPS = false; static int loops = 1; static boolean loop_shutdown = false; @@ -183,6 +184,10 @@ public class TestGearsES2NEWT extends UITestCase { } pointerIconOne = _pointerIconOne; } + if( setPointerIcon ) { + glWindow.setPointerIcon(pointerIconOne); + System.err.println("Set PointerIcon: "+glWindow.getPointerIcon()); + } glWindow.addKeyListener(new KeyAdapter() { @Override @@ -216,16 +221,6 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("[set alwaysontop post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", f "+glWindow.isFullscreen()+", a "+glWindow.isAlwaysOnTop()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); - } else if(e.getKeyChar()=='c') { - new Thread() { - public void run() { - final Thread t = glWindow.setExclusiveContextThread(null); - System.err.println("[set pointer-icon pre]"); - final PointerIcon currentPI = glWindow.getPointerIcon(); - glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); - System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); - glWindow.setExclusiveContextThread(t); - } }.start(); } else if(e.getKeyChar()=='d') { new Thread() { public void run() { @@ -245,6 +240,16 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("[set position post]: "+glWindow.getX()+"/"+glWindow.getY()+" "+glWindow.getWidth()+"x"+glWindow.getHeight()+", "+glWindow.getInsets()); glWindow.setExclusiveContextThread(t); } }.start(); + } else if(e.getKeyChar()=='c') { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set pointer-icon pre]"); + final PointerIcon currentPI = glWindow.getPointerIcon(); + glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); + System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); + glWindow.setExclusiveContextThread(t); + } }.start(); } else if(e.getKeyChar()=='i') { new Thread() { public void run() { @@ -482,6 +487,8 @@ public class TestGearsES2NEWT extends UITestCase { mouseVisible = false; } else if(args[i].equals("-mouseConfine")) { mouseConfined = true; + } else if(args[i].equals("-pointerIcon")) { + setPointerIcon = true; } else if(args[i].equals("-showFPS")) { showFPS = true; } else if(args[i].equals("-width")) { @@ -537,6 +544,7 @@ public class TestGearsES2NEWT extends UITestCase { System.err.println("pmvDirect "+(!pmvUseBackingArray)); System.err.println("mouseVisible "+mouseVisible); System.err.println("mouseConfined "+mouseConfined); + System.err.println("pointerIcon "+setPointerIcon); System.err.println("loops "+loops); System.err.println("loop shutdown "+loop_shutdown); System.err.println("forceES2 "+forceES2); diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 189645d3d..69874df6b 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -31,6 +31,10 @@ import java.awt.Frame; import javax.media.nativewindow.util.InsetsImmutable; +import com.jogamp.common.util.IOUtil; +import com.jogamp.newt.Display; +import com.jogamp.newt.Window; +import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; @@ -42,6 +46,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final NewtCanvasAWT newtCanvasAWT; final GLWindow glWindow; final QuitAdapter quitAdapter; + PointerIcon pointerIconTest = null; public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) { this.frame = frame; @@ -54,9 +59,7 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { if( !e.isPrintableKey() || e.isAutoRepeat() ) { return; } - if( e.getKeySymbol() == KeyEvent.VK_I ) { - System.err.println(glWindow); - } else if( e.getKeySymbol() == KeyEvent.VK_L ) { + if( e.getKeySymbol() == KeyEvent.VK_L ) { javax.media.nativewindow.util.Point p0 = newtCanvasAWT.getNativeWindow().getLocationOnScreen(null); javax.media.nativewindow.util.Point p1 = glWindow.getLocationOnScreen(null); System.err.println("NewtCanvasAWT position: "+p0+", "+p1); @@ -140,6 +143,50 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { quitAdapter.enable(true); } } }.start(); + } else if(e.getKeySymbol() == KeyEvent.VK_C ) { + if( null == pointerIconTest ) { + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/jogamp-32x32.png" } ); + final Display disp = glWindow.getScreen().getDisplay(); + try { + pointerIconTest = disp.createPointerIcon(res, 16, 0); + } catch (Exception err) { + err.printStackTrace(); + } + } + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set pointer-icon pre]"); + final PointerIcon currentPI = glWindow.getPointerIcon(); + glWindow.setPointerIcon( currentPI == pointerIconTest ? null : pointerIconTest); + System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if( e.getKeySymbol() == KeyEvent.VK_I ) { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set mouse visible pre]: "+glWindow.isPointerVisible()); + glWindow.setPointerVisible(!glWindow.isPointerVisible()); + System.err.println("[set mouse visible post]: "+glWindow.isPointerVisible()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if(e.getKeySymbol() == KeyEvent.VK_J ) { + new Thread() { + public void run() { + final Thread t = glWindow.setExclusiveContextThread(null); + System.err.println("[set mouse confined pre]: "+glWindow.isPointerConfined()); + glWindow.confinePointer(!glWindow.isPointerConfined()); + System.err.println("[set mouse confined post]: "+glWindow.isPointerConfined()); + glWindow.setExclusiveContextThread(t); + } }.start(); + } else if(e.getKeySymbol() == KeyEvent.VK_W ) { + new Thread() { + public void run() { + System.err.println("[set mouse pos pre]"); + glWindow.warpPointer(glWindow.getWidth()/2, glWindow.getHeight()/2); + System.err.println("[set mouse pos post]"); + } }.start(); } } } \ No newline at end of file -- cgit v1.2.3 From bd98b927b910d9421e63cf0dbc2b746eec019f80 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 8 Jan 2014 21:56:26 +0100 Subject: Bug 935: NEWT PointerIcon: Utilize Toolkit Agnostic PixelFormat and Conversion Utilities (Allowing 'arbitrary' PointerIcon data input) Commit fe28bc125429b38cdcd016746081f4a6d521c6fd added the notion of toolkit agnostic PixelFormat and conversion utilities, utilized and further tested by this patch. +++ - PointerIcon is a PixelRectangle and hence holds the decoded data. This allows on-the-fly conversion if required as well as recreation w/o PNG re-decoding. - Using array-backed PointerIcon data where possible, allowing better performance when converting PixelFormat etc. - NEWT Display adds 'createPointerIcon(final IOUtil.ClassResources pngResource...' method to support agnostic PointerIcon creation. - NEWT Display adds methods to allow users to avoid PixelFormat and Buffer NIO type forced conversion: - PixelFormat getNativePointerIconPixelFormat() - boolean getNativePointerIconForceDirectNIO() +++ PNGImage -> PNGPixelRect Deleted: com.jogamp.opengl.util.texture.spi.PNGImage Added: com.jogamp.opengl.util.PNGPixelRect (We hope nobody was using PNGImage directly since it was a service-plugin for TextureIO) PNGPixelRect is a PixelRectangle PNGPixelRect actually is implemented OpenGL agnostic, however - since our PNGJ support lives under package 'jogamp.opengl.util.pngj' it cannot be moved up (yet). PNGPixelRect now handles all PixelFormat for the target format and also added support for grayscale+alpha (2 channels). The latter is force-converted to RGB* - similar to paletted. Further more, PNGPixelRect allows simply passing an OutputStream to write the PNG data. Used by: TextureIO and NEWT +++ - OffscreenSurfaceLayer's setCursor(..) uses the agnostic PixelRectangle instead of a PNG resource. - AWTMisc uses the PixelRectangle to produce the AWT Cursor and converts it to the required format. Hence same pixels are used for NEWT and AWT pointer/cursor icon. - TestGearsES2Newt and NewtAWTReparentingKeyAdapter 'tests' iterate over 3 custom PointerIcon when pressed 'c'. - JOGLNewtAppletBase uses the new custom PointerIcon 'newt/data/crosshair-lumina-trans-32x32.png', which is included in NEWT (213 bytes only). - --- .../assets-test/crosshair-lumina-trans-64x64.png | Bin 0 -> 424 bytes .../newt/data/crosshair-lumina-trans-32x32.png | Bin 0 -> 213 bytes make/scripts/tests.sh | 9 +- .../com/jogamp/opengl/util/PNGPixelRect.java | 335 +++++++++++++++++++++ .../com/jogamp/opengl/util/texture/TextureIO.java | 63 ++-- .../jogamp/opengl/util/texture/spi/PNGImage.java | 319 -------------------- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 17 +- .../media/nativewindow/OffscreenLayerSurface.java | 10 +- .../classes/jogamp/nativewindow/awt/AWTMisc.java | 48 ++- src/newt/classes/com/jogamp/newt/Display.java | 119 ++++++-- .../jogamp/newt/awt/applet/JOGLNewtAppletBase.java | 4 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 156 +++++++++- src/newt/classes/jogamp/newt/PointerIconImpl.java | 63 +++- src/newt/classes/jogamp/newt/WindowImpl.java | 8 +- src/newt/classes/jogamp/newt/driver/PNGIcon.java | 35 +-- .../jogamp/newt/driver/macosx/DisplayDriver.java | 58 ++-- .../jogamp/newt/driver/opengl/JoglUtilPNGIcon.java | 92 ++---- .../jogamp/newt/driver/windows/DisplayDriver.java | 50 ++- .../jogamp/newt/driver/x11/DisplayDriver.java | 38 +-- .../jogamp/newt/driver/x11/WindowDriver.java | 20 +- src/newt/native/MacWindow.m | 32 +- src/newt/native/WindowsWindow.c | 16 +- src/newt/native/X11Display.c | 15 +- src/newt/native/X11Window.c | 20 +- .../jogl/demos/es2/newt/TestGearsES2NEWT.java | 59 +++- .../test/junit/jogl/util/texture/PNGTstFiles.java | 54 ++++ .../jogl/util/texture/TestPNGImage00NEWT.java | 92 ------ .../jogl/util/texture/TestPNGImage01NEWT.java | 182 ----------- .../jogl/util/texture/TestPNGPixelRect00NEWT.java | 224 ++++++++++++++ .../jogl/util/texture/TestPNGPixelRect01NEWT.java | 198 ++++++++++++ .../util/texture/TestPixelFormatUtil01NEWT.java | 105 +++++++ .../util/texture/crosshair-lumina-trans-32x32.png | Bin 0 -> 213 bytes .../util/texture/crosshair-lumina-trans-64x64.png | Bin 0 -> 424 bytes .../parenting/NewtAWTReparentingKeyAdapter.java | 62 +++- 34 files changed, 1573 insertions(+), 930 deletions(-) create mode 100644 make/resources/assets-test/crosshair-lumina-trans-64x64.png create mode 100644 make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png create mode 100644 src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java delete mode 100644 src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect00NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPixelFormatUtil01NEWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png (limited to 'make/scripts') diff --git a/make/resources/assets-test/crosshair-lumina-trans-64x64.png b/make/resources/assets-test/crosshair-lumina-trans-64x64.png new file mode 100644 index 000000000..9be285335 Binary files /dev/null and b/make/resources/assets-test/crosshair-lumina-trans-64x64.png differ diff --git a/make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png b/make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png new file mode 100644 index 000000000..92279640b Binary files /dev/null and b/make/resources/assets/newt/data/crosshair-lumina-trans-32x32.png differ diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index db852ce42..55973eb12 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -229,7 +229,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" - #D_ARGS="-Djogl.debug.PNGImage" + #D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" @@ -634,9 +634,10 @@ testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasA #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTCompareNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGJoglAWTBenchmarkNewtAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestJPEGTextureFromFileNEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage00NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGImage01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.ToolPNG2CSource $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGPixelRect00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGPixelRect01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPixelFormatUtil00NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPixelFormatUtil01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.util.texture.TestPNGTextureFromFileNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.util.texture.TestGLReadBufferUtilTextureIOWrite01AWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java b/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java new file mode 100644 index 000000000..1bbc12f32 --- /dev/null +++ b/src/jogl/classes/com/jogamp/opengl/util/PNGPixelRect.java @@ -0,0 +1,335 @@ +/** + * Copyright 2012 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.util; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.nio.ByteBuffer; + +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PixelFormat; +import javax.media.nativewindow.util.PixelRectangle; +import javax.media.nativewindow.util.PixelFormatUtil; + +import jogamp.opengl.Debug; +import jogamp.opengl.util.pngj.ImageInfo; +import jogamp.opengl.util.pngj.ImageLine; +import jogamp.opengl.util.pngj.ImageLineHelper; +import jogamp.opengl.util.pngj.PngReader; +import jogamp.opengl.util.pngj.PngWriter; +import jogamp.opengl.util.pngj.chunks.PngChunkPLTE; +import jogamp.opengl.util.pngj.chunks.PngChunkTRNS; +import jogamp.opengl.util.pngj.chunks.PngChunkTextVar; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.common.util.IOUtil; + +public class PNGPixelRect extends PixelRectangle.GenericPixelRect { + private static final boolean DEBUG = Debug.debug("PNG"); + + /** + * Reads a PNG image from the specified InputStream. + *

        + * Implicitly converts the image to match the desired: + *

          + *
        • {@link PixelFormat}, see {@link #getPixelformat()}
        • + *
        • destStrideInBytes, see {@link #getStride()}
        • + *
        • destIsGLOriented, see {@link #isGLOriented()}
        • + *
        + *

        + * + * @param in input stream + * @param destFmt desired destination {@link PixelFormat} incl. conversion, maybe null to use source {@link PixelFormat} + * @param destDirectBuffer if true, using a direct NIO buffer, otherwise an array backed buffer + * @param destMinStrideInBytes used if greater than PNG's stride, otherwise using PNG's stride. Stride is width * bytes-per-pixel. + * @param destIsGLOriented + * @return the newly created PNGPixelRect instance + * @throws IOException + */ + public static PNGPixelRect read(final InputStream in, + final PixelFormat ddestFmt, final boolean destDirectBuffer, final int destMinStrideInBytes, + final boolean destIsGLOriented) throws IOException { + final PngReader pngr = new PngReader(new BufferedInputStream(in), null); + final ImageInfo imgInfo = pngr.imgInfo; + final PngChunkPLTE plte = pngr.getMetadata().getPLTE(); + final PngChunkTRNS trns = pngr.getMetadata().getTRNS(); + final boolean indexed = imgInfo.indexed; + final boolean hasAlpha = indexed ? ( trns != null ) : imgInfo.alpha ; + + if(DEBUG) { + System.err.println("PNGPixelRect: "+imgInfo); + } + final int channels = indexed ? ( hasAlpha ? 4 : 3 ) : imgInfo.channels ; + final boolean isGrayAlpha = 2 == channels && imgInfo.greyscale && imgInfo.alpha; + if ( ! ( 1 == channels || 3 == channels || 4 == channels || isGrayAlpha ) ) { + throw new RuntimeException("PNGPixelRect can only handle Lum/RGB/RGBA [1/3/4 channels] or Lum+A (GA) images for now. Channels "+channels + " Paletted: " + indexed); + } + final int bytesPerPixel = indexed ? channels : imgInfo.bytesPixel ; + if ( ! ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel || isGrayAlpha ) ) { + throw new RuntimeException("PNGPixelRect can only handle Lum/RGB/RGBA [1/3/4 bpp] images for now. BytesPerPixel "+bytesPerPixel); + } + if( channels != bytesPerPixel ) { + throw new RuntimeException("PNGPixelRect currently only handles Channels [1/3/4] == BytePerPixel [1/3/4], channels: "+channels+", bytesPerPixel "+bytesPerPixel); + } + final int width = imgInfo.cols; + final int height = imgInfo.rows; + final double dpiX, dpiY; + { + final double[] dpi = pngr.getMetadata().getDpi(); + dpiX = dpi[0]; + dpiY = dpi[1]; + } + final PixelFormat srcFmt; + if ( indexed ) { + if ( hasAlpha ) { + srcFmt = PixelFormat.RGBA8888; + } else { + srcFmt = PixelFormat.RGB888; + } + } else { + switch( channels ) { + case 1: srcFmt = PixelFormat.LUMINANCE; break; + case 2: srcFmt = isGrayAlpha ? PixelFormat.LUMINANCE : null; break; + case 3: srcFmt = PixelFormat.RGB888; break; + case 4: srcFmt = PixelFormat.RGBA8888; break; + default: srcFmt = null; + } + if( null == srcFmt ) { + throw new InternalError("XXX: channels: "+channels+", bytesPerPixel "+bytesPerPixel); + } + } + final PixelFormat destFmt; + if( null == ddestFmt ) { + if( isGrayAlpha ) { + destFmt = PixelFormat.BGRA8888; // save alpha value on gray-alpha + } else { + destFmt = srcFmt; // 1:1 + } + } else { + destFmt = ddestFmt; // user choice + } + final int destStrideInBytes = Math.max(destMinStrideInBytes, destFmt.bytesPerPixel() * width); + final ByteBuffer destPixels = destDirectBuffer ? Buffers.newDirectByteBuffer(destStrideInBytes * height) : + ByteBuffer.allocate(destStrideInBytes * height); + { + final int reqBytes = destStrideInBytes * height; + if( destPixels.limit() < reqBytes ) { + throw new IndexOutOfBoundsException("Dest buffer has insufficient bytes left, needs "+reqBytes+": "+destPixels); + } + } + final boolean vert_flip = destIsGLOriented; + + int[] rgbaScanline = indexed ? new int[width * channels] : null; + if(DEBUG) { + System.err.println("PNGPixelRect: indexed "+indexed+", alpha "+hasAlpha+", grayscale "+imgInfo.greyscale+", channels "+channels+"/"+imgInfo.channels+ + ", bytesPerPixel "+bytesPerPixel+"/"+imgInfo.bytesPixel+ + ", grayAlpha "+isGrayAlpha+", pixels "+width+"x"+height+", dpi "+dpiX+"x"+dpiY+", format "+srcFmt); + System.err.println("PNGPixelRect: destFormat "+destFmt+" ("+ddestFmt+", bytesPerPixel "+destFmt.bytesPerPixel()+", fast-path "+(destFmt==srcFmt)+"), destDirectBuffer "+destDirectBuffer+", destIsGLOriented (flip) "+destIsGLOriented); + System.err.println("PNGPixelRect: destStrideInBytes "+destStrideInBytes+" (destMinStrideInBytes "+destMinStrideInBytes+")"); + } + + for (int row = 0; row < height; row++) { + final ImageLine l1 = pngr.readRow(row); + int lineOff = 0; + int dataOff = vert_flip ? ( height - 1 - row ) * destStrideInBytes : row * destStrideInBytes; + if( indexed ) { + for (int j = width - 1; j >= 0; j--) { + rgbaScanline = ImageLineHelper.palette2rgb(l1, plte, trns, rgbaScanline); // reuse rgbaScanline and update if resized + dataOff = getPixelRGBA8ToAny(destFmt, destPixels, dataOff, rgbaScanline, lineOff, hasAlpha); + lineOff += bytesPerPixel; + } + } else if( 1 == channels ) { + for (int j = width - 1; j >= 0; j--) { + dataOff = getPixelLUMToAny(destFmt, destPixels, dataOff, (byte)l1.scanline[lineOff++], (byte)0xff); // Luminance, 1 bytesPerPixel + } + } else if( isGrayAlpha ) { + for (int j = width - 1; j >= 0; j--) { + dataOff = getPixelLUMToAny(destFmt, destPixels, dataOff, (byte)l1.scanline[lineOff++], (byte)l1.scanline[lineOff++]); // Luminance+Alpha, 2 bytesPerPixel + } + } else if( srcFmt == destFmt ) { // fast-path + for (int j = width - 1; j >= 0; j--) { + dataOff = getPixelRGBSame(destPixels, dataOff, l1.scanline, lineOff, bytesPerPixel); + lineOff += bytesPerPixel; + } + } else { + for (int j = width - 1; j >= 0; j--) { + dataOff = getPixelRGBA8ToAny(destFmt, destPixels, dataOff, l1.scanline, lineOff, hasAlpha); + lineOff += bytesPerPixel; + } + } + } + pngr.end(); + + return new PNGPixelRect(destFmt, new Dimension(width, height), destStrideInBytes, destIsGLOriented, destPixels, dpiX, dpiY); + } + + private static final int getPixelLUMToAny(PixelFormat dest_fmt, ByteBuffer d, int dOff, byte lum, byte alpha) { + switch(dest_fmt) { + case LUMINANCE: + d.put(dOff++, lum); + break; + case BGR888: + case RGB888: + d.put(dOff++, lum); + d.put(dOff++, lum); + d.put(dOff++, lum); + break; + case ABGR8888: + case ARGB8888: + d.put(dOff++, alpha); // A + d.put(dOff++, lum); + d.put(dOff++, lum); + d.put(dOff++, lum); + break; + case BGRA8888: + case RGBA8888: + d.put(dOff++, lum); + d.put(dOff++, lum); + d.put(dOff++, lum); + d.put(dOff++, alpha); // A + break; + default: + throw new InternalError("Unhandled format "+dest_fmt); + } + return dOff; + } + private static final int getPixelRGBA8ToAny(final PixelFormat dest_fmt, final ByteBuffer d, int dOff, final int[] scanline, final int lineOff, final boolean srcHasAlpha) { + final int p = PixelFormatUtil.convertToInt32(dest_fmt, (byte)scanline[lineOff], // R + (byte)scanline[lineOff+1], // G + (byte)scanline[lineOff+2], // B + srcHasAlpha ? (byte)scanline[lineOff+3] : (byte)0xff); // A + final int dbpp = dest_fmt.bytesPerPixel(); + d.put(dOff++, (byte) ( p )); // 1 + if( 1 < dbpp ) { + d.put(dOff++, (byte) ( p >>> 8 )); // 2 + d.put(dOff++, (byte) ( p >>> 16 )); // 3 + if( 4 == dbpp ) { + d.put(dOff++, (byte) ( p >>> 24 )); // 4 + } + } + return dOff; + } + private static final int getPixelRGBSame(final ByteBuffer d, int dOff, final int[] scanline, final int lineOff, final int bpp) { + d.put(dOff++, (byte)scanline[lineOff]); // R + if( 1 < bpp ) { + d.put(dOff++, (byte)scanline[lineOff + 1]); // G + d.put(dOff++, (byte)scanline[lineOff + 2]); // B + if( 4 == bpp ) { + d.put(dOff++, (byte)scanline[lineOff + 3]); // A + } + } + return dOff; + } + private int setPixelRGBA8(final ImageLine line, final int lineOff, final ByteBuffer d, final int dOff, final int bytesPerPixel, final boolean hasAlpha) { + final int b = hasAlpha ? 4-1 : 3-1; + if( d.limit() <= dOff + b ) { + throw new IndexOutOfBoundsException("Buffer has unsufficient bytes left, needs ["+dOff+".."+(dOff+b)+"]: "+d); + } + final int p = PixelFormatUtil.convertToInt32(hasAlpha ? PixelFormat.RGBA8888 : PixelFormat.RGB888, pixelformat, d, dOff); + line.scanline[lineOff ] = 0xff & p; // R + line.scanline[lineOff + 1] = 0xff & ( p >>> 8 ); // G + line.scanline[lineOff + 2] = 0xff & ( p >>> 16 ); // B + if(hasAlpha) { + line.scanline[lineOff + 3] = 0xff & ( p >>> 24 ); // A + } + return dOff + pixelformat.bytesPerPixel(); + } + + /** + * Creates a PNGPixelRect from data supplied by the end user. Shares + * data with the passed ByteBuffer. + * + * @param pixelformat + * @param size + * @param strideInBytes + * @param isGLOriented see {@link #isGLOriented()}. + * @param pixels + * @param dpiX + * @param dpiY + */ + public PNGPixelRect(final PixelFormat pixelformat, final DimensionImmutable size, + final int strideInBytes, final boolean isGLOriented, final ByteBuffer pixels, + final double dpiX, final double dpiY) { + super(pixelformat, size, strideInBytes, isGLOriented, pixels); + this.dpi = new double[] { dpiX, dpiY }; + } + public PNGPixelRect(final PixelRectangle src, final double dpiX, final double dpiY) { + super(src); + this.dpi = new double[] { dpiX, dpiY }; + } + private final double[] dpi; + + /** Returns the dpi of the image. */ + public double[] getDpi() { return dpi; } + + public void write(final OutputStream outstream, final boolean closeOutstream) throws IOException { + final int width = size.getWidth(); + final int height = size.getHeight(); + final int bytesPerPixel = pixelformat.bytesPerPixel(); + final ImageInfo imi = new ImageInfo(width, height, 8 /* bitdepth */, + (4 == bytesPerPixel) ? true : false /* alpha */, + (1 == bytesPerPixel) ? true : false /* grayscale */, + false /* indexed */); + + // open image for writing to a output stream + try { + final PngWriter png = new PngWriter(outstream, imi); + // add some optional metadata (chunks) + png.getMetadata().setDpi(dpi[0], dpi[1]); + png.getMetadata().setTimeNow(0); // 0 seconds fron now = now + png.getMetadata().setText(PngChunkTextVar.KEY_Title, "JogAmp PNGPixelRect"); + // png.getMetadata().setText("my key", "my text"); + final boolean hasAlpha = 4 == bytesPerPixel; + + final ImageLine l1 = new ImageLine(imi); + for (int row = 0; row < height; row++) { + int dataOff = isGLOriented ? ( height - 1 - row ) * strideInBytes : row * strideInBytes; + int lineOff = 0; + if(1 == bytesPerPixel) { + for (int j = width - 1; j >= 0; j--) { + l1.scanline[lineOff++] = pixels.get(dataOff++); // // Luminance, 1 bytesPerPixel + } + } else { + for (int j = width - 1; j >= 0; j--) { + dataOff = setPixelRGBA8(l1, lineOff, pixels, dataOff, bytesPerPixel, hasAlpha); + lineOff += bytesPerPixel; + } + } + png.writeRow(l1, row); + } + png.end(); + } finally { + if( closeOutstream ) { + IOUtil.close(outstream, false); + } + } + } +} diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java index 67ab5176d..0cde24db4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureIO.java @@ -41,10 +41,12 @@ package com.jogamp.opengl.util.texture; import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.net.URL; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -52,9 +54,10 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import javax.media.nativewindow.util.Dimension; +import javax.media.nativewindow.util.PixelFormat; import javax.media.opengl.GL; import javax.media.opengl.GL2; -import javax.media.opengl.GL2ES2; import javax.media.opengl.GL2GL3; import javax.media.opengl.GLContext; import javax.media.opengl.GLException; @@ -63,11 +66,11 @@ import javax.media.opengl.GLProfile; import jogamp.opengl.Debug; import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.PNGPixelRect; import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; import com.jogamp.opengl.util.texture.spi.DDSImage; import com.jogamp.opengl.util.texture.spi.JPEGImage; import com.jogamp.opengl.util.texture.spi.NetPbmTextureWriter; -import com.jogamp.opengl.util.texture.spi.PNGImage; import com.jogamp.opengl.util.texture.spi.SGIImage; import com.jogamp.opengl.util.texture.spi.TGAImage; import com.jogamp.opengl.util.texture.spi.TextureProvider; @@ -1166,27 +1169,29 @@ public class TextureIO { boolean mipmap, String fileSuffix) throws IOException { if (PNG.equals(fileSuffix)) { - PNGImage image = PNGImage.read(/*glp, */ stream); - if (pixelFormat == 0) { - pixelFormat = image.getGLFormat(); - } - if (internalFormat == 0) { + final PNGPixelRect image = PNGPixelRect.read(stream, null, true /* directBuffer */, 0 /* destMinStrideInBytes */, true /* destIsGLOriented */); + final GLPixelAttributes glpa = GLPixelAttributes.convert(image.getPixelformat(), glp); + if ( 0 == pixelFormat ) { + pixelFormat = glpa.format; + } // else FIXME: Actually not supported w/ preset pixelFormat! + if ( 0 == internalFormat ) { + final boolean hasAlpha = 4 == glpa.bytesPerPixel; if(glp.isGL2ES3()) { - internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA8:GL.GL_RGB8; + internalFormat = hasAlpha ? GL.GL_RGBA8 : GL.GL_RGB8; } else { - internalFormat = (image.getBytesPerPixel()==4)?GL.GL_RGBA:GL.GL_RGB; + internalFormat = hasAlpha ? GL.GL_RGBA : GL.GL_RGB; } } return new TextureData(glp, internalFormat, - image.getWidth(), - image.getHeight(), + image.getSize().getWidth(), + image.getSize().getHeight(), 0, pixelFormat, - image.getGLType(), + glpa.type, mipmap, false, false, - image.getData(), + image.getPixels(), null); } @@ -1392,29 +1397,7 @@ public class TextureIO { final int pixelFormat = pixelAttribs.format; final int pixelType = pixelAttribs.type; final int bytesPerPixel = pixelAttribs.bytesPerPixel; - final boolean reversedChannels; - switch(pixelFormat) { - case GL.GL_ALPHA: - case GL.GL_LUMINANCE: - case GL2ES2.GL_RED: - reversedChannels=false; - break; - case GL.GL_RGB: - reversedChannels=false; - break; - case GL.GL_RGBA: - reversedChannels=false; - break; - case GL2.GL_BGR: - reversedChannels=true; - break; - case GL.GL_BGRA: - reversedChannels=true; - break; - default: - reversedChannels=false; - break; - } + final PixelFormat pixFmt = pixelAttribs.getPixelFormat(); if ( ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel) && ( pixelType == GL.GL_BYTE || pixelType == GL.GL_UNSIGNED_BYTE)) { ByteBuffer buf = (ByteBuffer) data.getBuffer(); @@ -1423,9 +1406,11 @@ public class TextureIO { } buf.rewind(); - PNGImage image = PNGImage.createFromData(data.getWidth(), data.getHeight(), -1f, -1f, - bytesPerPixel, reversedChannels, !data.getMustFlipVertically(), buf); - image.write(file, true); + final PNGPixelRect image = new PNGPixelRect(pixFmt, new Dimension(data.getWidth(), data.getHeight()), + 0 /* stride */, true /* isGLOriented */, buf /* pixels */, + -1f, -1f); + final OutputStream outs = new BufferedOutputStream(IOUtil.getFileOutputStream(file, true /* allowOverwrite */)); + image.write(outs, true /* close */); return true; } throw new IOException("PNG writer doesn't support this pixel format 0x"+Integer.toHexString(pixelFormat)+ diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java b/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java deleted file mode 100644 index 71cbbf97e..000000000 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/spi/PNGImage.java +++ /dev/null @@ -1,319 +0,0 @@ -/** - * Copyright 2012 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.util.texture.spi; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.ByteBuffer; - -import javax.media.opengl.GL; - -import jogamp.opengl.Debug; -import jogamp.opengl.util.pngj.ImageInfo; -import jogamp.opengl.util.pngj.ImageLine; -import jogamp.opengl.util.pngj.ImageLineHelper; -import jogamp.opengl.util.pngj.PngReader; -import jogamp.opengl.util.pngj.PngWriter; -import jogamp.opengl.util.pngj.chunks.PngChunkPLTE; -import jogamp.opengl.util.pngj.chunks.PngChunkTRNS; -import jogamp.opengl.util.pngj.chunks.PngChunkTextVar; - -import com.jogamp.common.nio.Buffers; -import com.jogamp.common.util.IOUtil; - -public class PNGImage { - private static final boolean DEBUG = Debug.debug("PNGImage"); - - /** - * Creates a PNGImage from data supplied by the end user. Shares - * data with the passed ByteBuffer. Assumes the data is already in - * the correct byte order for writing to disk, i.e., LUMINANCE, RGB or RGBA. - * Orientation is bottom-to-top (OpenGL coord. default) - * or top-to-bottom depending on isGLOriented. - * - * @param width - * @param height - * @param dpiX - * @param dpiY - * @param bytesPerPixel - * @param reversedChannels - * @param isGLOriented see {@link #isGLOriented()}. - * @param data - * @return - */ - public static PNGImage createFromData(int width, int height, double dpiX, double dpiY, - int bytesPerPixel, boolean reversedChannels, boolean isGLOriented, ByteBuffer data) { - return new PNGImage(width, height, dpiX, dpiY, bytesPerPixel, reversedChannels, isGLOriented, data); - } - - /** - * Reads a PNG image from the specified InputStream. - *

        - * Implicitly flip image to GL orientation, see {@link #isGLOriented()}. - *

        - */ - public static PNGImage read(InputStream in) throws IOException { - return new PNGImage(in); - } - - /** Reverse read and store, implicitly flip image to GL orientation, see {@link #isGLOriented()}. */ - private static final int getPixelRGBA8(ByteBuffer d, int dOff, int[] scanline, int lineOff, boolean hasAlpha) { - final int b = hasAlpha ? 4-1 : 3-1; - if( d.limit() <= dOff || dOff - b < 0 ) { - throw new IndexOutOfBoundsException("Buffer has unsufficient bytes left, needs ["+(dOff-b)+".."+dOff+"]: "+d); - } - if(hasAlpha) { - d.put(dOff--, (byte)scanline[lineOff + 3]); // A - } - d.put(dOff--, (byte)scanline[lineOff + 2]); // B - d.put(dOff--, (byte)scanline[lineOff + 1]); // G - d.put(dOff--, (byte)scanline[lineOff ]); // R - return dOff; - } - - /** Reverse write and store, implicitly flip image from current orientation, see {@link #isGLOriented()}. Handle reversed channels (BGR[A]). */ - private int setPixelRGBA8(ImageLine line, int lineOff, ByteBuffer d, int dOff, boolean hasAlpha) { - final int b = hasAlpha ? 4-1 : 3-1; - if( d.limit() <= dOff + b ) { - throw new IndexOutOfBoundsException("Buffer has unsufficient bytes left, needs ["+dOff+".."+(dOff+b)+"]: "+d); - } - if( reversedChannels ) { - if(hasAlpha) { - line.scanline[lineOff + 3] = d.get(dOff++); // A - } - line.scanline[lineOff + 2] = d.get(dOff++); // R - line.scanline[lineOff + 1] = d.get(dOff++); // G - line.scanline[lineOff ] = d.get(dOff++); // B - } else { - line.scanline[lineOff ] = d.get(dOff++); // R - line.scanline[lineOff + 1] = d.get(dOff++); // G - line.scanline[lineOff + 2] = d.get(dOff++); // B - if(hasAlpha) { - line.scanline[lineOff + 3] = d.get(dOff++); // A - } - } - return isGLOriented ? dOff - bytesPerPixel - bytesPerPixel : dOff; - } - - private PNGImage(int width, int height, double dpiX, double dpiY, int bytesPerPixel, boolean reversedChannels, boolean isGLOriented, ByteBuffer data) { - pixelWidth=width; - pixelHeight=height; - dpi = new double[] { dpiX, dpiY }; - if(4 == bytesPerPixel) { - glFormat = GL.GL_RGBA; - } else if (3 == bytesPerPixel) { - glFormat = GL.GL_RGB; - } else { - throw new InternalError("XXX: bytesPerPixel "+bytesPerPixel); - } - this.bytesPerPixel = bytesPerPixel; - this.reversedChannels = reversedChannels; - this.isGLOriented = isGLOriented; - this.data = data; - } - - private PNGImage(InputStream in) { - final PngReader pngr = new PngReader(new BufferedInputStream(in), null); - final ImageInfo imgInfo = pngr.imgInfo; - final PngChunkPLTE plte = pngr.getMetadata().getPLTE(); - final PngChunkTRNS trns = pngr.getMetadata().getTRNS(); - final boolean indexed = imgInfo.indexed; - final boolean hasAlpha = indexed ? ( trns != null ) : imgInfo.alpha ; - - final int channels = indexed ? ( hasAlpha ? 4 : 3 ) : imgInfo.channels ; - if ( ! ( 1 == channels || 3 == channels || 4 == channels ) ) { - throw new RuntimeException("PNGImage can only handle Lum/RGB/RGBA [1/3/4 channels] images for now. Channels "+channels + " Paletted: " + indexed); - } - - bytesPerPixel = indexed ? channels : imgInfo.bytesPixel ; - if ( ! ( 1 == bytesPerPixel || 3 == bytesPerPixel || 4 == bytesPerPixel ) ) { - throw new RuntimeException("PNGImage can only handle Lum/RGB/RGBA [1/3/4 bpp] images for now. BytesPerPixel "+bytesPerPixel); - } - if( channels != bytesPerPixel ) { - throw new RuntimeException("PNGImage currently only handles Channels [1/3/4] == BytePerPixel [1/3/4], channels: "+channels+", bytesPerPixel "+bytesPerPixel); - } - pixelWidth = imgInfo.cols; - pixelHeight = imgInfo.rows; - dpi = new double[2]; - { - final double[] dpi2 = pngr.getMetadata().getDpi(); - dpi[0]=dpi2[0]; - dpi[1]=dpi2[1]; - } - if ( indexed ) { - if ( hasAlpha ) { - glFormat = GL.GL_RGBA; - } else { - glFormat = GL.GL_RGB; - } - } else { - switch( channels ) { - case 1: glFormat = GL.GL_LUMINANCE; break; - case 3: glFormat = GL.GL_RGB; break; - case 4: glFormat = GL.GL_RGBA; break; - default: throw new InternalError("XXX: channels: "+channels+", bytesPerPixel "+bytesPerPixel); - } - } - if(DEBUG) { - System.err.println("PNGImage: "+imgInfo); - System.err.println("PNGImage: indexed "+indexed+", alpha "+hasAlpha+", channels "+channels+"/"+imgInfo.channels+ - ", bytesPerPixel "+bytesPerPixel+"/"+imgInfo.bytesPixel+ - ", pixels "+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+"x"+dpi[1]+", glFormat 0x"+Integer.toHexString(glFormat)); - } - - data = Buffers.newDirectByteBuffer(bytesPerPixel * pixelWidth * pixelHeight); - reversedChannels = false; // RGB[A] - isGLOriented = true; - int dataOff = bytesPerPixel * pixelWidth * pixelHeight - 1; // start at end-of-buffer, reverse store - - int[] rgbaScanline = indexed ? new int[imgInfo.cols * channels] : null; - - for (int row = 0; row < pixelHeight; row++) { - final ImageLine l1 = pngr.readRow(row); - int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse read (PNG top-left -> OpenGL bottom-left origin) - if( indexed ) { - for (int j = pixelWidth - 1; j >= 0; j--) { - rgbaScanline = ImageLineHelper.palette2rgb(l1, plte, trns, rgbaScanline); // reuse rgbaScanline and update if resized - dataOff = getPixelRGBA8(data, dataOff, rgbaScanline, lineOff, hasAlpha); - lineOff -= bytesPerPixel; - } - } else if( 1 == channels ) { - for (int j = pixelWidth - 1; j >= 0; j--) { - data.put(dataOff--, (byte)l1.scanline[lineOff--]); // Luminance, 1 bytesPerPixel - } - } else { - for (int j = pixelWidth - 1; j >= 0; j--) { - dataOff = getPixelRGBA8(data, dataOff, l1.scanline, lineOff, hasAlpha); - lineOff -= bytesPerPixel; - } - } - } - pngr.end(); - } - private final int pixelWidth, pixelHeight, glFormat, bytesPerPixel; - private final boolean reversedChannels; - private final boolean isGLOriented; - private final double[] dpi; - private final ByteBuffer data; - - /** Returns the width of the image. */ - public int getWidth() { return pixelWidth; } - - /** Returns the height of the image. */ - public int getHeight() { return pixelHeight; } - - /** Returns true if data has the channels reversed to BGR or BGRA, otherwise RGB or RGBA is expected. */ - public boolean getHasReversedChannels() { return reversedChannels; } - - /** - * Returns true if the drawable is rendered in - * OpenGL's coordinate system, origin at bottom left. - * Otherwise returns false, i.e. origin at top left. - *

        - * Default impl. is true, i.e. OpenGL coordinate system. - *

        - */ - public boolean isGLOriented() { return isGLOriented; } - - /** Returns the dpi of the image. */ - public double[] getDpi() { return dpi; } - - /** Returns the OpenGL format for this texture; e.g. GL.GL_LUMINANCE, GL.GL_RGB or GL.GL_RGBA. */ - public int getGLFormat() { return glFormat; } - - /** Returns the OpenGL data type: GL.GL_UNSIGNED_BYTE. */ - public int getGLType() { return GL.GL_UNSIGNED_BYTE; } - - /** Returns the bytes per pixel */ - public int getBytesPerPixel() { return bytesPerPixel; } - - /** Returns the raw data for this texture in the correct - (bottom-to-top) order for calls to glTexImage2D. */ - public ByteBuffer getData() { return data; } - - public void write(File out, boolean allowOverwrite) throws IOException { - final ImageInfo imi = new ImageInfo(pixelWidth, pixelHeight, 8, (4 == bytesPerPixel) ? true : false); // 8 bits per channel, no alpha - // open image for writing to a output stream - final OutputStream outs = new BufferedOutputStream(IOUtil.getFileOutputStream(out, allowOverwrite)); - try { - final PngWriter png = new PngWriter(outs, imi); - // add some optional metadata (chunks) - png.getMetadata().setDpi(dpi[0], dpi[1]); - png.getMetadata().setTimeNow(0); // 0 seconds fron now = now - png.getMetadata().setText(PngChunkTextVar.KEY_Title, "JogAmp PNGImage"); - // png.getMetadata().setText("my key", "my text"); - final boolean hasAlpha = 4 == bytesPerPixel; - final ImageLine l1 = new ImageLine(imi); - if( isGLOriented ) { - // start at last pixel at end-of-buffer, reverse read (OpenGL bottom-left -> PNG top-left origin) - int dataOff = ( pixelWidth * bytesPerPixel * ( pixelHeight - 1 ) ) + // full lines - 1 line - ( ( pixelWidth - 1 ) * bytesPerPixel ); // one line - 1 pixel - for (int row = 0; row < pixelHeight; row++) { - int lineOff = ( pixelWidth - 1 ) * bytesPerPixel ; // start w/ last pixel in line, reverse store (OpenGL bottom-left -> PNG top-left origin) - if(1 == bytesPerPixel) { - for (int j = pixelWidth - 1; j >= 0; j--) { - l1.scanline[lineOff--] = data.get(dataOff--); // // Luminance, 1 bytesPerPixel - } - } else { - for (int j = pixelWidth - 1; j >= 0; j--) { - dataOff = setPixelRGBA8(l1, lineOff, data, dataOff, hasAlpha); - lineOff -= bytesPerPixel; - } - } - png.writeRow(l1, row); - } - } else { - int dataOff = 0; // start at first pixel at start-of-buffer, normal read (same origin: top-left) - for (int row = 0; row < pixelHeight; row++) { - int lineOff = 0; // start w/ first pixel in line, normal store (same origin: top-left) - if(1 == bytesPerPixel) { - for (int j = pixelWidth - 1; j >= 0; j--) { - l1.scanline[lineOff++] = data.get(dataOff++); // // Luminance, 1 bytesPerPixel - } - } else { - for (int j = pixelWidth - 1; j >= 0; j--) { - dataOff = setPixelRGBA8(l1, lineOff, data, dataOff, hasAlpha); - lineOff += bytesPerPixel; - } - } - png.writeRow(l1, row); - } - } - png.end(); - } finally { - IOUtil.close(outs, false); - } - } - - @Override - public String toString() { return "PNGImage["+pixelWidth+"x"+pixelHeight+", dpi "+dpi[0]+" x "+dpi[1]+", bytesPerPixel "+bytesPerPixel+", reversedChannels "+reversedChannels+", "+data+"]"; } -} diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index b947505cb..ddf513180 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -38,7 +38,6 @@ package com.jogamp.nativewindow.awt; import com.jogamp.common.os.Platform; -import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.awt.AWTEDTExecutor; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveLock; @@ -53,7 +52,6 @@ import java.awt.event.ComponentListener; import java.awt.event.HierarchyEvent; import java.awt.event.HierarchyListener; import java.applet.Applet; -import java.io.IOException; import javax.media.nativewindow.AbstractGraphicsConfiguration; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -66,6 +64,7 @@ import javax.media.nativewindow.OffscreenLayerSurface; import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.PixelRectangle; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.Rectangle; @@ -433,19 +432,19 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public final boolean setCursor(final IOUtil.ClassResources resources, final PointImmutable hotSpot) throws IOException { + public final boolean setCursor(final PixelRectangle pixelrect, final PointImmutable hotSpot) { AWTEDTExecutor.singleton.invoke(false, new Runnable() { public void run() { Cursor c = null; - if( null == resources || null == hotSpot ) { + if( null == pixelrect || null == hotSpot ) { c = Cursor.getDefaultCursor(); } else { final java.awt.Point awtHotspot = new java.awt.Point(hotSpot.getX(), hotSpot.getY()); try { - c = AWTMisc.getCursor(resources, awtHotspot); - } catch (IOException e) { - e.printStackTrace(); - } + c = AWTMisc.getCursor(pixelrect, awtHotspot); + } catch (Exception e) { + e.printStackTrace(); + } } if( null != c ) { component.setCursor(c); @@ -455,7 +454,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override - public boolean hideCursor() { + public final boolean hideCursor() { AWTEDTExecutor.singleton.invoke(false, new Runnable() { public void run() { component.setCursor(AWTMisc.getNullCursor()); diff --git a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java index 81983a7c2..cf8cf89d2 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java +++ b/src/nativewindow/classes/javax/media/nativewindow/OffscreenLayerSurface.java @@ -27,11 +27,9 @@ */ package javax.media.nativewindow; -import java.io.IOException; - +import javax.media.nativewindow.util.PixelRectangle; import javax.media.nativewindow.util.PointImmutable; -import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.locks.RecursiveLock; /** @@ -73,12 +71,12 @@ public interface OffscreenLayerSurface { /** * Optional method setting cursor in the corresponding on-screen surface/window, if exists. * - * @param resources maybe null for default cursor + * @param pixelrect cursor pixels, maybe null for default cursor * @param hotSpot maybe null for default cursor * @return true if successful, i.e. on-screen surface/window w/ cursor capabilities exists. Otherwise false. - * @throws IOException */ - public boolean setCursor(IOUtil.ClassResources resources, PointImmutable hotSpot) throws IOException; + public boolean setCursor(PixelRectangle pixelrect, PointImmutable hotSpot); + /** * Optional method hiding the cursor in the corresponding on-screen surface/window, if exists. * diff --git a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java index b690aff4d..069cffeb8 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java +++ b/src/nativewindow/classes/jogamp/nativewindow/awt/AWTMisc.java @@ -37,21 +37,19 @@ import java.awt.Component; import java.awt.Container; import java.awt.Frame; import java.awt.image.BufferedImage; -import java.io.IOException; -import java.net.URLConnection; import java.util.HashMap; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JRootPane; import javax.swing.WindowConstants; -import javax.imageio.ImageIO; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.WindowClosingProtocol; +import javax.media.nativewindow.util.PixelRectangle; +import javax.media.nativewindow.util.PixelFormat; +import javax.media.nativewindow.util.PixelFormatUtil; import javax.swing.MenuSelectionManager; -import com.jogamp.common.util.IOUtil; - public class AWTMisc { public static JFrame getJFrame(Component c) { @@ -173,7 +171,7 @@ public class AWTMisc { MenuSelectionManager.defaultManager().clearSelectedPath(); } - static final HashMap cursorMap = new HashMap(); + static final HashMap cursorMap = new HashMap(); static final Cursor nulCursor; static { final Toolkit toolkit = Toolkit.getDefaultToolkit(); @@ -183,21 +181,43 @@ public class AWTMisc { public static synchronized Cursor getNullCursor() { return nulCursor; } - public static synchronized Cursor getCursor(IOUtil.ClassResources resources, Point hotSpot) throws IOException { - final String key = resources.getClass().getName()+":"+resources.resourcePaths[0]; + public static synchronized Cursor getCursor(PixelRectangle pixelrect, Point hotSpot) { + // 31 * x == (x << 5) - x + int hash = 31 + pixelrect.hashCode(); + hash = ((hash << 5) - hash) + hotSpot.hashCode(); + final Integer key = Integer.valueOf(hash); + Cursor cursor = cursorMap.get(key); if( null == cursor ) { - cursor = createAWTCursor(resources, hotSpot); + cursor = createCursor(pixelrect, hotSpot); cursorMap.put(key, cursor); } return cursor; } - private static synchronized Cursor createAWTCursor(IOUtil.ClassResources resources, Point hotSpot) throws IOException { - final URLConnection urlConn = resources.resolve(0); - final BufferedImage img = ImageIO.read(urlConn.getInputStream()); - + private static synchronized Cursor createCursor(PixelRectangle pixelrect, Point hotSpot) { + final int width = pixelrect.getSize().getWidth(); + final int height = pixelrect.getSize().getHeight(); + final BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); // PixelFormat.BGRA8888 + final PixelFormatUtil.PixelSink32 imgSink = new PixelFormatUtil.PixelSink32() { + public void store(int x, int y, int pixel) { + img.setRGB(x, y, pixel); + } + @Override + public final PixelFormat getPixelformat() { + return PixelFormat.BGRA8888; + } + @Override + public int getStride() { + return width*4; + } + @Override + public final boolean isGLOriented() { + return false; + } + }; + PixelFormatUtil.convert32(imgSink, pixelrect); final Toolkit toolkit = Toolkit.getDefaultToolkit(); - return toolkit.createCustomCursor(img, hotSpot, resources.resourcePaths[0]); + return toolkit.createCustomCursor(img, hotSpot, pixelrect.toString()); } public static WindowClosingProtocol.WindowClosingMode AWT2NWClosingOperation(int awtClosingOperation) { diff --git a/src/newt/classes/com/jogamp/newt/Display.java b/src/newt/classes/com/jogamp/newt/Display.java index 8d1445f80..4b38fcca5 100644 --- a/src/newt/classes/com/jogamp/newt/Display.java +++ b/src/newt/classes/com/jogamp/newt/Display.java @@ -30,14 +30,14 @@ package com.jogamp.newt; import java.io.IOException; import java.lang.ref.WeakReference; -import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PixelRectangle; +import javax.media.nativewindow.util.PixelFormat; import javax.media.nativewindow.util.PointImmutable; import jogamp.newt.Debug; @@ -47,6 +47,7 @@ import com.jogamp.newt.util.EDTUtil; public abstract class Display { public static final boolean DEBUG = Debug.debug("Display"); + protected static final boolean DEBUG_POINTER_ICON = Debug.debug("Display.PointerIcon"); /** return precomputed hashCode from FQN {@link #getFQName()} */ @Override @@ -66,7 +67,9 @@ public abstract class Display { /** * Native PointerIcon handle. *

        - * Instances can be created via {@link Display}'s {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) createPointerIcon(..)}. + * Instances can be created via {@link Display}'s + * {@link Display#createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int) createPointerIcon(pngResource, ..)} + * or {@link Display#createPointerIcon(PixelRectangle, int, int) createPointerIcon(pixelrect, ..)}. *

        *

        * Instance is {@link #destroy()}'ed automatically if it's {@link #getDisplay() associated Display} is destroyed. @@ -75,23 +78,65 @@ public abstract class Display { * Instance can be re-validated after destruction via {@link #validate()}. *

        *

        + * {@link PointerIcon} must not be {@link #destroy() destroyed} while in use! + *

        + *

        * {@link PointerIcon} may be {@link #destroy() destroyed} manually after use, * i.e. when no {@link Window} {@link Window#setPointerIcon(PointerIcon) uses them} anymore. + * However, this is not required. *

        *

        * PointerIcons can be used via {@link Window#setPointerIcon(PointerIcon)}. *

        */ - public static interface PointerIcon { + public static interface PointerIcon extends PixelRectangle { /** - * @return the associated Display + * Always neatly packed, i.e. width * bytes_per_pixel. + *

        + * {@inheritDoc} + *

        */ - Display getDisplay(); + @Override + int getStride(); + + /** + * Always false, i.e. origin is TOP-LEFT. + *

        + * {@inheritDoc} + *

        + */ + boolean isGLOriented(); + + /** + * Computes a hash code over: + *
          + *
        • display
        • + *
        • pixelformat
        • + *
        • size
        • + *
        • stride
        • + *
        • isGLOriented
        • + *
        • pixels
        • + *
        • hotspot
        • + *
        + * Dismissing the native handle! + *

        + * The hashCode shall be computed only once with first call + * and stored for later retrieval to enhance performance. + *

        + *

        + * {@inheritDoc} + *

        + */ + @Override + int hashCode(); /** - * @return the single {@link IOUtil.ClassResources}. + * @return the associated Display */ - IOUtil.ClassResources getResource(); + Display getDisplay(); + + /** Returns the hotspot. */ + PointImmutable getHotspot(); /** * Returns true if valid, otherwise false. @@ -116,35 +161,69 @@ public abstract class Display { *

        */ void destroy(); + } - /** Returns the size, i.e. width and height. */ - DimensionImmutable getSize(); + /** + * Returns the native platform's {@link PointerIcon.PixelFormat} for pointer-icon pixel data. + *

        + * Using this value will avoid conversion within {@link #createPointerIcon(PixelRectangle, int, int)}. + *

        + */ + public abstract PixelFormat getNativePointerIconPixelFormat(); - /** Returns the hotspot. */ - PointImmutable getHotspot(); + /** + * Returns the native platform's direct NIO buffer requirement pointer-icon pixel data. + *

        + * Using this value will avoid conversion within {@link #createPointerIcon(PixelRectangle, int, int)}. + *

        + */ + public abstract boolean getNativePointerIconForceDirectNIO(); - @Override - String toString(); - } + /** + * Returns the newly created {@link PointerIcon} or null if not implemented on platform. + *

        + * See {@link PointerIcon} for lifecycle semantics. + *

        + * + * @param pngResource single PNG resource for the {@link PointerIcon}. Only the first entry of {@link IOUtil.ClassResources#resourcePaths} is used. + * @param hotX pointer hotspot x-coord, origin is upper-left corner + * @param hotY pointer hotspot y-coord, origin is upper-left corner + * + * @throws IllegalArgumentException if pngResource is null or invalid + * @throws IllegalStateException if this Display instance is not {@link #isNativeValid() valid yet}. + * @throws IOException if the pngResource could not be {@link IOUtil.ClassResources#resolve(int) resolved} + * or via the PNG parser processing the input stream. + * + * @see PointerIcon + * @see Window#setPointerIcon(PointerIcon) + */ + public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) + throws IllegalArgumentException, IllegalStateException, IOException; /** * Returns the newly created {@link PointerIcon} or null if not implemented on platform. *

        * See {@link PointerIcon} for lifecycle semantics. *

        + *

        + * In case {@link #getNativePointerIconPixelFormat()} or {@link #getNativePointerIconForceDirectNIO()} + * is not matched by the given pixelrect, the pixelrect is converted + * into the required {@link PixelFormat} and NIO type. + *

        * - * @param pngResource single PNG resource, only the first entry of {@link IOUtil.ClassResources#resourcePaths} is used. + * @param pixelrect {@link PixelRectangle} source for the {@link PointerIcon} * @param hotX pointer hotspot x-coord, origin is upper-left corner * @param hotY pointer hotspot y-coord, origin is upper-left corner + * + * @throws IllegalArgumentException if pixelrect is null. * @throws IllegalStateException if this Display instance is not {@link #isNativeValid() valid yet}. - * @throws MalformedURLException - * @throws InterruptedException - * @throws IOException * * @see PointerIcon * @see Window#setPointerIcon(PointerIcon) + * @see #getNativePointerIconPixelFormat() + * @see #getNativePointerIconForceDirectNIO() */ - public abstract PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws IllegalStateException, MalformedURLException, InterruptedException, IOException; + public abstract PointerIcon createPointerIcon(final PixelRectangle pixelrect, final int hotX, final int hotY) throws IllegalArgumentException, IllegalStateException; /** * Manual trigger the native creation, if it is not done yet.
        diff --git a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java index 7ffbc2e83..472672fd9 100644 --- a/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java +++ b/src/newt/classes/com/jogamp/newt/awt/applet/JOGLNewtAppletBase.java @@ -235,10 +235,10 @@ public class JOGLNewtAppletBase implements KeyListener, GLEventListener { glWindow.setVisible(true); glWindow.sendWindowEvent(WindowEvent.EVENT_WINDOW_RESIZED); if( null == pointerIconTest ) { - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/jogamp-32x32.png" } ); + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/crosshair-lumina-trans-32x32.png" } ); final Display disp = glWindow.getScreen().getDisplay(); try { - pointerIconTest = disp.createPointerIcon(res, 16, 0); + pointerIconTest = disp.createPointerIcon(res, 16, 16); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index 346c03b15..4c7169ec4 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -34,7 +34,9 @@ package jogamp.newt; +import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; +import com.jogamp.common.util.ReflectionUtil; import com.jogamp.newt.Display; import com.jogamp.newt.NewtFactory; import com.jogamp.newt.event.NEWTEvent; @@ -43,17 +45,25 @@ import com.jogamp.newt.event.NEWTEventConsumer; import jogamp.newt.event.NEWTEventTask; import com.jogamp.newt.util.EDTUtil; +import com.jogamp.opengl.util.PNGPixelRect; import java.io.IOException; -import java.net.MalformedURLException; +import java.net.URLConnection; +import java.nio.ByteBuffer; import java.util.ArrayList; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.NativeWindowFactory; +import javax.media.nativewindow.util.PixelFormatUtil; +import javax.media.nativewindow.util.PixelRectangle; +import javax.media.nativewindow.util.PixelFormat; +import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PointImmutable; public abstract class DisplayImpl extends Display { private static int serialno = 1; + private static final boolean pngUtilAvail; static { NativeWindowFactory.addCustomShutdownHook(true /* head */, new Runnable() { @@ -64,8 +74,14 @@ public abstract class DisplayImpl extends Display { DisplayImpl.shutdownAll(); } }); + + final ClassLoader cl = DisplayImpl.class.getClassLoader(); + pngUtilAvail = ReflectionUtil.isClassAvailable("jogamp.opengl.util.pngj.PngReader", cl) && + ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.PNGPixelRect", cl); } + public static final boolean isPNGUtilAvailable() { return pngUtilAvail; } + final ArrayList pointerIconList = new ArrayList(); /** Executed from EDT! */ @@ -86,13 +102,94 @@ public abstract class DisplayImpl extends Display { } @Override - public final PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - return createPointerIcon(false /* isTemp */, pngResource, hotX, hotY); + public PixelFormat getNativePointerIconPixelFormat() { return PixelFormat.BGRA8888; } + @Override + public boolean getNativePointerIconForceDirectNIO() { return false; } + + @Override + public final PointerIcon createPointerIcon(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) + throws IllegalArgumentException, IllegalStateException, IOException + { + if( !isNativeValid() ) { + throw new IllegalStateException("Display.createPointerIcon(1): Display invalid "+this); + } + if( null == pngResource || 0 >= pngResource.resourceCount() ) { + throw new IllegalArgumentException("Null or invalid pngResource "+pngResource); + } + if( !pngUtilAvail ) { + return null; + } + final PointerIconImpl[] res = { null }; + runOnEDTIfAvail(true, new Runnable() { + public void run() { + try { + if( !DisplayImpl.this.isNativeValid() ) { + throw new IllegalStateException("Display.createPointerIcon(2): Display invalid "+DisplayImpl.this); + } + final URLConnection urlConn = pngResource.resolve(0); + if( null == urlConn ) { + throw new IOException("Could not resolve "+pngResource.resourcePaths[0]); + } + final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), + getNativePointerIconPixelFormat(), + getNativePointerIconForceDirectNIO(), + 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); + final long handle = createPointerIconImplChecked(image.getPixelformat(), image.getSize().getWidth(), image.getSize().getHeight(), + image.getPixels(), hotX, hotY); + final PointImmutable hotspot = new Point(hotX, hotY); + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconPNG.0: "+image+", handle: "+toHexString(handle)+", hot "+hotspot); + } + if( 0 != handle ) { + res[0] = new PointerIconImpl(DisplayImpl.this, image, hotspot, handle); + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconPNG.0: "+res[0]); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } } ); + if( null != res[0] ) { + synchronized(pointerIconList) { + pointerIconList.add(res[0]); + } + } + return res[0]; } - PointerIcon createPointerIcon(final boolean isTemp, final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { + + @Override + public final PointerIcon createPointerIcon(final PixelRectangle pixelrect, final int hotX, final int hotY) + throws IllegalArgumentException, IllegalStateException + { if( !isNativeValid() ) { throw new IllegalStateException("Display.createPointerIcon(1): Display invalid "+this); } + if( null == pixelrect ) { + throw new IllegalArgumentException("Null or pixelrect"); + } + final PixelRectangle fpixelrect; + if( getNativePointerIconPixelFormat() != pixelrect.getPixelformat() || pixelrect.isGLOriented() ) { + // conversion ! + fpixelrect = PixelFormatUtil.convert32(pixelrect, getNativePointerIconPixelFormat(), + 0 /* ddestStride */, false /* isGLOriented */, getNativePointerIconForceDirectNIO() ); + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconRES.0: Conversion-FMT "+pixelrect+" -> "+fpixelrect); + } + } else if( getNativePointerIconForceDirectNIO() && !Buffers.isDirect(pixelrect.getPixels()) ) { + // transfer to direct NIO + final ByteBuffer sBB = pixelrect.getPixels(); + final ByteBuffer dBB = Buffers.newDirectByteBuffer(sBB.array(), sBB.arrayOffset()); + fpixelrect = new PixelRectangle.GenericPixelRect(pixelrect.getPixelformat(), pixelrect.getSize(), pixelrect.getStride(), pixelrect.isGLOriented(), dBB); + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconRES.0: Conversion-NIO "+pixelrect+" -> "+fpixelrect); + } + } else { + fpixelrect = pixelrect; + if( DEBUG_POINTER_ICON ) { + System.err.println("createPointerIconRES.0: No conversion "+fpixelrect); + } + } final PointerIconImpl[] res = { null }; runOnEDTIfAvail(true, new Runnable() { public void run() { @@ -100,22 +197,63 @@ public abstract class DisplayImpl extends Display { if( !DisplayImpl.this.isNativeValid() ) { throw new IllegalStateException("Display.createPointerIcon(2): Display invalid "+DisplayImpl.this); } - res[0] = createPointerIconImpl(pngResource, hotX, hotY); + if( null != fpixelrect ) { + final long handle = createPointerIconImplChecked(fpixelrect.getPixelformat(), + fpixelrect.getSize().getWidth(), + fpixelrect.getSize().getHeight(), + fpixelrect.getPixels(), hotX, hotY); + if( 0 != handle ) { + res[0] = new PointerIconImpl(DisplayImpl.this, fpixelrect, new Point(hotX, hotY), handle); + } + } } catch (Exception e) { e.printStackTrace(); } } } ); - if( !isTemp ) { + if( null != res[0] ) { synchronized(pointerIconList) { pointerIconList.add(res[0]); } } return res[0]; } - /** Executed from EDT! */ - protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - return null; + + /** + * Executed from EDT! + * + * @param pixelformat the pixels's format + * @param width the pixels's width + * @param height the pixels's height + * @param pixels the pixels + * @param hotX the PointerIcon's hot-spot x-coord + * @param hotY the PointerIcon's hot-spot x-coord + * @return if successful a valid handle (not null), otherwise null. + */ + protected final long createPointerIconImplChecked(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + if( getNativePointerIconPixelFormat() != pixelformat ) { + throw new IllegalArgumentException("Pixelformat no "+getNativePointerIconPixelFormat()+", but "+pixelformat); + } + if( getNativePointerIconForceDirectNIO() && !Buffers.isDirect(pixels) ) { + throw new IllegalArgumentException("pixel buffer is not direct "+pixels); + } + return createPointerIconImpl(pixelformat, width, height, pixels, hotX, hotY); + } + + /** + * Executed from EDT! + * + * @param pixelformat the pixels's format + * @param width the pixels's width + * @param height the pixels's height + * @param pixels the pixels + * @param hotX the PointerIcon's hot-spot x-coord + * @param hotY the PointerIcon's hot-spot x-coord + * @return if successful a valid handle (not null), otherwise null. + */ + protected long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + return 0; } + /** Executed from EDT! */ protected void destroyPointerIconImpl(final long displayHandle, long piHandle) { } diff --git a/src/newt/classes/jogamp/newt/PointerIconImpl.java b/src/newt/classes/jogamp/newt/PointerIconImpl.java index e2388be67..7c8535f20 100644 --- a/src/newt/classes/jogamp/newt/PointerIconImpl.java +++ b/src/newt/classes/jogamp/newt/PointerIconImpl.java @@ -27,27 +27,63 @@ */ package jogamp.newt; +import java.nio.ByteBuffer; + import javax.media.nativewindow.util.DimensionImmutable; +import javax.media.nativewindow.util.PixelFormat; +import javax.media.nativewindow.util.PixelRectangle; import javax.media.nativewindow.util.PointImmutable; -import com.jogamp.common.util.IOUtil; -import com.jogamp.common.util.IOUtil.ClassResources; import com.jogamp.newt.Display; import com.jogamp.newt.Display.PointerIcon; public class PointerIconImpl implements PointerIcon { private final DisplayImpl display; - private final IOUtil.ClassResources resource; + private final PixelFormat pixelformat; private final DimensionImmutable size; + private final ByteBuffer pixels; private final PointImmutable hotspot; private long handle; - public PointerIconImpl(DisplayImpl display, ClassResources resource, final DimensionImmutable size, final PointImmutable hotspot, final long handle) { + private int hashCode = 0; + private volatile boolean hashCodeComputed = false; + + public PointerIconImpl(final DisplayImpl display, final PixelFormat pixelformat, final DimensionImmutable size, final ByteBuffer pixels, final PointImmutable hotspot, final long handle) { this.display = display; - this.resource = resource; + this.pixelformat = pixelformat; this.size = size; + this.pixels = pixels; this.hotspot = hotspot; + this.handle=handle; } + public PointerIconImpl(final DisplayImpl display, final PixelRectangle pixelrect, final PointImmutable hotspot, final long handle) { + this.display = display; + this.pixelformat = pixelrect.getPixelformat(); + this.size = pixelrect.getSize(); + this.pixels = pixelrect.getPixels(); + this.hotspot = hotspot; + this.handle=handle; + } + + @Override + public int hashCode() { + if( !hashCodeComputed ) { // DBL CHECKED OK VOLATILE + synchronized (this) { + if( !hashCodeComputed ) { + // 31 * x == (x << 5) - x + int hash = 31 + display.getFQName().hashCode(); + hash = ((hash << 5) - hash) + pixelformat.hashCode(); + hash = ((hash << 5) - hash) + size.hashCode(); + hash = ((hash << 5) - hash) + getStride(); + hash = ((hash << 5) - hash) + ( isGLOriented() ? 1 : 0); + hash = ((hash << 5) - hash) + pixels.hashCode(); + hashCode = ((hash << 5) - hash) + hotspot.hashCode(); + } + } + } + return hashCode; + } + public synchronized final long getHandle() { return handle; } public synchronized final long validatedHandle() { synchronized(display.pointerIconList) { @@ -57,8 +93,7 @@ public class PointerIconImpl implements PointerIcon { } if( 0 == handle ) { try { - final PointerIconImpl temp = (PointerIconImpl) display.createPointerIcon(true /* isTemp */, resource, hotspot.getX(), hotspot.getY()); - handle = temp.handle; + handle = display.createPointerIconImpl(pixelformat, size.getWidth(), size.getHeight(), pixels, hotspot.getX(), hotspot.getY()); return handle; } catch (Exception e) { e.printStackTrace(); @@ -71,7 +106,9 @@ public class PointerIconImpl implements PointerIcon { @Override public final Display getDisplay() { return display; } @Override - public final IOUtil.ClassResources getResource() { return resource; } + public final PixelFormat getPixelformat() { return pixelformat; } + @Override + public final ByteBuffer getPixels() { return pixels; } @Override public synchronized final boolean isValid() { return 0 != handle; } @Override @@ -116,11 +153,19 @@ public class PointerIconImpl implements PointerIcon { return size; } @Override + public final int getStride() { + return size.getWidth() * pixelformat.bytesPerPixel(); + } + @Override + public final boolean isGLOriented() { + return false; + } + @Override public final PointImmutable getHotspot() { return hotspot; } @Override public final String toString() { - return "PointerIcon["+DisplayImpl.toHexString(super.hashCode())+", "+display.getFQName()+", "+resource.resourcePaths[0]+", 0x"+Long.toHexString(handle)+", "+size+", "+hotspot+"]"; + return "PointerIcon[obj 0x"+Integer.toHexString(super.hashCode())+", "+display.getFQName()+", 0x"+Long.toHexString(handle)+", "+pixelformat+", "+size+", "+hotspot+", pixels "+pixels+"]"; } } \ No newline at end of file diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 50f30f04d..dc9affd63 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -53,6 +53,7 @@ import javax.media.nativewindow.WindowClosingProtocol; import javax.media.nativewindow.util.DimensionImmutable; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.InsetsImmutable; +import javax.media.nativewindow.util.PixelRectangle; import javax.media.nativewindow.util.Point; import javax.media.nativewindow.util.PointImmutable; import javax.media.nativewindow.util.Rectangle; @@ -61,7 +62,6 @@ import javax.media.nativewindow.util.RectangleImmutable; import jogamp.nativewindow.SurfaceUpdatedHelper; import com.jogamp.common.util.ArrayHashSet; -import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.IntBitfield; import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.locks.LockFactory; @@ -1700,7 +1700,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** * Helper method to delegate {@link #setPointerVisibleImpl(boolean)} to - * {@link OffscreenLayerSurface#hideCursor()} or {@link OffscreenLayerSurface#setCursor(IOUtil.ClassResources, PointImmutable)}. + * {@link OffscreenLayerSurface#hideCursor()} or {@link OffscreenLayerSurface#setCursor(PixelRectangle, PointImmutable)}. *

        * Note: JAWTWindow is an OffscreenLayerSurface. *

        @@ -1755,7 +1755,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer } /** * Helper method to delegate {@link #setPointerIconIntern(PointerIconImpl)} to - * {@link OffscreenLayerSurface#setCursor(IOUtil.ClassResources, PointImmutable)}. + * {@link OffscreenLayerSurface#setCursor(PixelRectangle, PointImmutable)} *

        * Note: JAWTWindow is an OffscreenLayerSurface. *

        @@ -1777,7 +1777,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer final OffscreenLayerSurface ols = (OffscreenLayerSurface) parent; try { if( null != pi ) { - return ols.setCursor(pi.getResource(), pi.getHotspot()); + return ols.setCursor(pi, pi.getHotspot()); } else { return ols.setCursor(null, null); // default } diff --git a/src/newt/classes/jogamp/newt/driver/PNGIcon.java b/src/newt/classes/jogamp/newt/driver/PNGIcon.java index ffa62978f..967acd413 100644 --- a/src/newt/classes/jogamp/newt/driver/PNGIcon.java +++ b/src/newt/classes/jogamp/newt/driver/PNGIcon.java @@ -32,6 +32,7 @@ import java.net.MalformedURLException; import java.nio.ByteBuffer; import jogamp.newt.Debug; +import jogamp.newt.DisplayImpl; import com.jogamp.common.util.IOUtil; import com.jogamp.common.util.ReflectionUtil; @@ -45,8 +46,7 @@ public class PNGIcon { Debug.initSingleton(); final ClassLoader cl = PNGIcon.class.getClassLoader(); - avail = ReflectionUtil.isClassAvailable("jogamp.newt.driver.opengl.JoglUtilPNGIcon", cl) && - ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.texture.spi.PNGImage", cl); + avail = DisplayImpl.isPNGUtilAvailable() && ReflectionUtil.isClassAvailable("jogamp.newt.driver.opengl.JoglUtilPNGIcon", cl); } /** Returns true if PNG decoder is available. */ @@ -55,7 +55,11 @@ public class PNGIcon { } /** - * Implemented for X11. + * Special implementation for X11 Window Icons + *

        + * The returned byte buffer is a direct buffer! + *

        + * * @param resources * @param data_size * @param elem_bytesize @@ -73,29 +77,4 @@ public class PNGIcon { } throw new UnsupportedOperationException(err0); } - - /** - * Implemented for Windows. - * @param resources - * @param toBGRA if true, arranges stores in BGRA888 order, otherwise RGBA888 - * @param width - * @param height - * @param data_size - * @param resourcesIdx - * @return pixels with origin at upper-left corner. - * If storing RGBA8888, component R is located on the lowest 8-bit. - * If storing BGRA8888, component B is located on the lowest 8-bit. - * Component A is located on the highest 8-bit. - * - * @throws UnsupportedOperationException if not implemented - * @throws InterruptedException - * @throws IOException - * @throws MalformedURLException - */ - public static ByteBuffer singleToRGBAImage(IOUtil.ClassResources resources, int resourceIdx, boolean toBGRA, int[] width, int[] height, int[] data_size) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { - if( avail ) { - return jogamp.newt.driver.opengl.JoglUtilPNGIcon.singleToRGBAImage(resources, resourceIdx, toBGRA, width, height, data_size); - } - throw new UnsupportedOperationException(err0); - } } diff --git a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java index 30583c48c..d850a18af 100644 --- a/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/macosx/DisplayDriver.java @@ -34,28 +34,25 @@ package jogamp.newt.driver.macosx; -import java.io.IOException; -import java.net.MalformedURLException; +import java.net.URLConnection; import java.nio.Buffer; import java.nio.ByteBuffer; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; -import javax.media.nativewindow.util.Dimension; -import javax.media.nativewindow.util.Point; +import javax.media.nativewindow.util.PixelFormat; +import com.jogamp.common.nio.Buffers; import com.jogamp.common.util.IOUtil; import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice; import com.jogamp.newt.NewtFactory; +import com.jogamp.opengl.util.PNGPixelRect; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; -import jogamp.newt.PointerIconImpl; -import jogamp.newt.driver.PNGIcon; public class DisplayDriver extends DisplayImpl { - private static final int defaultIconWidth, defaultIconHeight; - private static final Buffer defaultIconData; + private static final PNGPixelRect defaultIconData; static { NEWTJNILibLoader.loadNEWT(); @@ -67,21 +64,23 @@ public class DisplayDriver extends DisplayImpl { throw new NativeWindowException("Failed to initialize jmethodIDs"); } { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; - Buffer data=null; - if( PNGIcon.isAvailable() ) { + PNGPixelRect image=null; + if( DisplayImpl.isPNGUtilAvailable() ) { try { + // NOTE: MUST BE DIRECT BUFFER, since NSBitmapImageRep uses buffer directly! final IOUtil.ClassResources iconRes = NewtFactory.getWindowIcons(); - data = PNGIcon.singleToRGBAImage(iconRes, iconRes.resourceCount()-1, false /* toBGRA */, width, height, data_size); + final URLConnection urlConn = iconRes.resolve(iconRes.resourceCount()-1); + image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.BGRA8888, true /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); } catch (Exception e) { e.printStackTrace(); } } - defaultIconWidth = width[0]; - defaultIconHeight = height[0]; - defaultIconData = data; + defaultIconData = image; if( null != defaultIconData ) { - DisplayDriver.setAppIcon0(defaultIconData, defaultIconWidth, defaultIconHeight); + final Buffer pixels = defaultIconData.getPixels(); + DisplayDriver.setAppIcon0( + pixels, Buffers.getDirectBufferByteOffset(pixels), true /* pixels_is_direct */, + defaultIconData.getSize().getWidth(), defaultIconData.getSize().getHeight()); } } @@ -112,17 +111,20 @@ public class DisplayDriver extends DisplayImpl { aDevice.close(); } + /** + * {@inheritDoc} + *

        + * NOTE: MUST BE DIRECT BUFFER, since NSBitmapImageRep uses buffer directly! + *

        + */ @Override - protected PointerIconImpl createPointerIconImpl(final IOUtil.ClassResources pngResource, final int hotX, final int hotY) throws MalformedURLException, InterruptedException, IOException { - if( PNGIcon.isAvailable() ) { - final int[] width = { 0 }, height = { 0 }, data_size = { 0 }; - if( null != pngResource && 0 < pngResource.resourceCount() ) { - final ByteBuffer data = PNGIcon.singleToRGBAImage(pngResource, 0, true /* toBGRA */, width, height, data_size); - return new PointerIconImpl( this, pngResource, new Dimension(width[0], height[0]), - new Point(hotX, hotY), createPointerIcon0(data, width[0], height[0], hotX, hotY)); - } - } - return null; + public final boolean getNativePointerIconForceDirectNIO() { return true; } + + @Override + protected final long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + return createPointerIcon0( + pixels, Buffers.getDirectBufferByteOffset(pixels), true /* pixels_is_direct */, + width, height, hotX, hotY); } @Override @@ -140,8 +142,8 @@ public class DisplayDriver extends DisplayImpl { private static native boolean initNSApplication0(); private static native void runNSApplication0(); private static native void stopNSApplication0(); - /* pp */ static native void setAppIcon0(Object iconData, int iconWidth, int iconHeight); - private static native long createPointerIcon0(Object iconData, int iconWidth, int iconHeight, int hotX, int hotY); + /* pp */ static native void setAppIcon0(Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height); + private static native long createPointerIcon0(Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY); private static native long destroyPointerIcon0(long handle); } diff --git a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java index 216a0cb20..551929b8d 100644 --- a/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java +++ b/src/newt/classes/jogamp/newt/driver/opengl/JoglUtilPNGIcon.java @@ -32,20 +32,22 @@ import java.net.MalformedURLException; import java.net.URLConnection; import java.nio.ByteBuffer; +import javax.media.nativewindow.util.PixelFormat; + import com.jogamp.common.nio.Buffers; import com.jogamp.common.os.Platform; import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.util.texture.spi.PNGImage; +import com.jogamp.opengl.util.PNGPixelRect; public class JoglUtilPNGIcon { public static ByteBuffer arrayToX11BGRAImages(IOUtil.ClassResources resources, int[] data_size, int[] elem_bytesize) throws UnsupportedOperationException, InterruptedException, IOException, MalformedURLException { - final PNGImage[] images = new PNGImage[resources.resourceCount()]; + final PNGPixelRect[] images = new PNGPixelRect[resources.resourceCount()]; data_size[0] = 0; for(int i=0; iGetDirectBufferAddress(env, jiconData); +static NSImage * createNSImageFromData(JNIEnv *env, unsigned char * iconData, jint jiconWidth, jint jiconHeight) { + if( NULL != iconData ) { NSInteger iconWidth = (NSInteger) jiconWidth; NSInteger iconHeight = (NSInteger) jiconHeight; const NSInteger bpc = 8 /* bits per component */, spp=4 /* RGBA */, bpp = bpc * spp; @@ -319,28 +318,47 @@ static NSImage * createNSImageFromData(JNIEnv *env, jobject jiconData, jint jico * Method: setAppIcon0 */ JNIEXPORT void JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_setAppIcon0 - (JNIEnv *env, jobject unused, jobject jiconData, jint jiconWidth, jint jiconHeight) + (JNIEnv *env, jobject unused, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height) { + if( 0 == pixels ) { + return; + } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSImage * nsImage = createNSImageFromData(env, jiconData, jiconWidth, jiconHeight); + // NOTE: MUST BE DIRECT BUFFER, since NSBitmapImageRep uses buffer directly! + unsigned char * pixelPtr = (unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); + NSImage * nsImage = createNSImageFromData(env, pixelPtr + pixels_byte_offset, width, height); if( NULL != nsImage ) { [nsImage autorelease]; [NSApp setApplicationIconImage: nsImage]; } + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } [pool release]; } JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_macosx_DisplayDriver_createPointerIcon0 - (JNIEnv *env, jobject unused, jobject jiconData, jint jiconWidth, jint jiconHeight, jint hotX, jint hotY) + (JNIEnv *env, jobject unused, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height, jint hotX, jint hotY) { + if( 0 == pixels ) { + return 0; + } NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; - NSImage * nsImage = createNSImageFromData(env, jiconData, jiconWidth, jiconHeight); + unsigned char * pixelPtr = (unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); + NSImage * nsImage = createNSImageFromData(env, pixelPtr + pixels_byte_offset, width, height); NSCursor * res = NULL; if( NULL != nsImage ) { [nsImage autorelease]; NSPoint hotP = { hotX, hotY }; res = [[NSCursor alloc] initWithImage: nsImage hotSpot: hotP]; } + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } [pool release]; DBG_PRINT( "createPointerIcon0 %p\n", res); return (jlong) (intptr_t) res; diff --git a/src/newt/native/WindowsWindow.c b/src/newt/native/WindowsWindow.c index 1fd8d0039..c20e156c1 100644 --- a/src/newt/native/WindowsWindow.c +++ b/src/newt/native/WindowsWindow.c @@ -2368,9 +2368,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_windows_WindowDriver_warpPointer0 JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_windows_DisplayDriver_createBGRA8888Icon0(JNIEnv *env, jobject _unused, - jobject data, jint data_offset, jint width, jint height, jboolean isCursor, jint hotX, jint hotY) { + jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height, jboolean isCursor, jint hotX, jint hotY) { - const unsigned char * data_ptr = (const unsigned char *) (*env)->GetDirectBufferAddress(env, data) + data_offset; + if( 0 == pixels ) { + return 0; + } + + const unsigned char * pixelPtr = (const unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); const int bytes = 4 * width * height; // BGRA8888 DWORD dwWidth, dwHeight; @@ -2403,10 +2409,14 @@ Java_jogamp_newt_driver_windows_DisplayDriver_createBGRA8888Icon0(JNIEnv *env, j hBitmap = CreateDIBSection(hdc, (BITMAPINFO *)&bi, DIB_RGB_COLORS, (void **)&lpBits, NULL, (DWORD)0); - memcpy(lpBits, data_ptr, bytes); + memcpy(lpBits, pixelPtr + pixels_byte_offset, bytes); ReleaseDC(NULL,hdc); + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } + // Create an empty mask bitmap. HBITMAP hMonoBitmap = CreateBitmap(dwWidth,dwHeight,1,1,NULL); diff --git a/src/newt/native/X11Display.c b/src/newt/native/X11Display.c index 19e733111..b62a9b234 100644 --- a/src/newt/native/X11Display.c +++ b/src/newt/native/X11Display.c @@ -678,13 +678,15 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_DispatchMessage * Signature: (JJILjava/lang/Object;I)V */ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_createPointerIcon0 - (JNIEnv *env, jclass clazz, jlong display, jobject data, jint data_offset, jint width, jint height, jint hotX, jint hotY) + (JNIEnv *env, jclass clazz, jlong display, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height, jint hotX, jint hotY) { Cursor c; - if( 0 != data ) { + if( 0 != pixels ) { Display * dpy = (Display *) (intptr_t) display; - char * data_ptr = (char *) (*env)->GetDirectBufferAddress(env, data) + data_offset; + const unsigned char * pixelPtr = (const unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); XcursorImage ci; ci.version = 1; // XCURSOR_IMAGE_VERSION; ci.size = width; // nominal size (assume square ..) @@ -693,11 +695,14 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_DisplayDriver_createPointerI ci.xhot = hotX; ci.yhot = hotY; ci.delay = 0; - ci.pixels = (XcursorPixel *)(intptr_t)data_ptr; + ci.pixels = (XcursorPixel *)(intptr_t)(pixelPtr + pixels_byte_offset); c = XcursorImageLoadCursor (dpy, &ci); - DBG_PRINT( "X11: createPointerIcon0: %p %dx%d %d/%d -> %p\n", data_ptr, width, height, hotX, hotY, (void *)c); + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } + DBG_PRINT( "X11: createPointerIcon0: %p %dx%d %d/%d -> %p\n", (pixelPtr+pixels_byte_offset), width, height, hotX, hotY, (void *)c); } else { c = 0; diff --git a/src/newt/native/X11Window.c b/src/newt/native/X11Window.c index da2778004..54b85c243 100644 --- a/src/newt/native/X11Window.c +++ b/src/newt/native/X11Window.c @@ -512,7 +512,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 jint visualID, jlong javaObjectAtom, jlong windowDeleteAtom, jint x, jint y, jint width, jint height, jboolean autoPosition, int flags, - jint iconDataSize, jobject iconData) + jint pixelDataSize, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct) { Display * dpy = (Display *)(intptr_t)display; Atom wm_delete_atom = (Atom)windowDeleteAtom; @@ -632,10 +632,16 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 { XEvent event; int left=0, right=0, top=0, bottom=0; - - if( 0 < iconDataSize && NULL != iconData ) { - const unsigned char * iconDataPtr = (const unsigned char *) (*env)->GetDirectBufferAddress(env, iconData); - NewtWindows_setIcon(dpy, window, (int)iconDataSize, iconDataPtr); + const unsigned char * pixelPtr = NULL; + + // NOTE: MUST BE DIRECT BUFFER, since _NET_WM_ICON Atom uses buffer directly! + DBG_PRINT("X11: CreateWindow icon: size %d, pixels %p, offset %d, direct %d\n", pixelDataSize, (void*)pixels, pixels_byte_offset, pixels_is_direct); + if( 0 < pixelDataSize && NULL != pixels ) { + pixelPtr = (const unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); + DBG_PRINT("X11: CreateWindow icon: NIO %p\n", pixelPtr); + NewtWindows_setIcon(dpy, window, (int)pixelDataSize, pixelPtr+pixels_byte_offset); } XMapWindow(dpy, window); @@ -643,6 +649,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_WindowDriver_CreateWindow0 XSync(dpy, False); + if( JNI_FALSE == pixels_is_direct && NULL != pixelPtr ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } + // send insets before visibility, allowing java code a proper sync point! NewtWindows_updateInsets(env, jwindow, dpy, window, &left, &right, &top, &bottom); (*env)->CallVoidMethod(env, jwindow, visibleChangedID, JNI_FALSE, JNI_TRUE); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java index 8cc676291..780338492 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java @@ -29,6 +29,7 @@ package com.jogamp.opengl.test.junit.jogl.demos.es2.newt; import java.io.IOException; +import java.net.URLConnection; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.Display; @@ -47,6 +48,7 @@ import com.jogamp.opengl.test.junit.util.MiscUtils; import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.test.junit.util.QuitAdapter; import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.PNGPixelRect; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import javax.media.nativewindow.NativeWindowFactory; @@ -171,25 +173,55 @@ public class TestGearsES2NEWT extends UITestCase { } }); - final PointerIcon pointerIconOne; + final PointerIcon[] pointerIcons = { null, null, null }; { - PointerIcon _pointerIconOne = null; - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); final Display disp = glWindow.getScreen().getDisplay(); disp.createNative(); - try { - _pointerIconOne = disp.createPointerIcon(res, 32, 0); - } catch (Exception e) { - e.printStackTrace(); + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/crosshair-lumina-trans-32x32.png" } ); + try { + _pointerIcon = disp.createPointerIcon(res, 16, 16); + System.err.println("Create PointerIcon #01: "+_pointerIcon); + } catch (Exception e) { + e.printStackTrace(); + } + pointerIcons[0] = _pointerIcon; + } + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); + try { + _pointerIcon = disp.createPointerIcon(res, 32, 0); + System.err.println("Create PointerIcon #02: "+_pointerIcon); + } catch (Exception e) { + e.printStackTrace(); + } + pointerIcons[1] = _pointerIcon; + } + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "crosshair-lumina-trans-64x64.png" } ); + try { + final URLConnection urlConn = res.resolve(0); + final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); + System.err.println("Create PointerIcon #03: "+image); + _pointerIcon = disp.createPointerIcon(image, 32, 32); + System.err.println("Create PointerIcon #03: "+_pointerIcon); + } catch (Exception e) { + e.printStackTrace(); + } + pointerIcons[2] = _pointerIcon; } - pointerIconOne = _pointerIconOne; } if( setPointerIcon ) { - glWindow.setPointerIcon(pointerIconOne); + glWindow.setPointerIcon(pointerIcons[0]); System.err.println("Set PointerIcon: "+glWindow.getPointerIcon()); } glWindow.addKeyListener(new KeyAdapter() { + int pointerIconIdx = 0; + @Override public void keyPressed(final KeyEvent e) { if( e.isAutoRepeat() ) { @@ -246,7 +278,14 @@ public class TestGearsES2NEWT extends UITestCase { final Thread t = glWindow.setExclusiveContextThread(null); System.err.println("[set pointer-icon pre]"); final PointerIcon currentPI = glWindow.getPointerIcon(); - glWindow.setPointerIcon( currentPI == pointerIconOne ? null : pointerIconOne); + final PointerIcon newPI; + if( pointerIconIdx >= pointerIcons.length ) { + newPI=null; + pointerIconIdx=0; + } else { + newPI=pointerIcons[pointerIconIdx++]; + } + glWindow.setPointerIcon( newPI ); System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); glWindow.setExclusiveContextThread(t); } }.start(); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java new file mode 100644 index 000000000..bb9bc42a8 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java @@ -0,0 +1,54 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.util.texture; + +public class PNGTstFiles { + static public final String[] allBasenames = { + "test-ntscN_3-01-160x90", + "test-ntscN_4-01-160x90", + "test-ntscNG4-01-160x90", + "test-ntscI_3-01-160x90", + "test-ntscI_4-01-160x90", + "test-ntscIG3-01-160x90", + "test-ntscIG4-01-160x90", + "test-ntscP_3-01-160x90", + "test-ntscP_4-01-160x90", + "grayscale_texture", + "bug724-transparent-grey_orig", + "bug724-transparent-grey_gimpexp", + "crosshair-lumina-trans-32x32", + "crosshair-lumina-trans-64x64", + }; + static public final String[] greyBasenames = { + "grayscale_texture", + "bug724-transparent-grey_orig", + "bug724-transparent-grey_gimpexp", + "crosshair-lumina-trans-32x32", + "crosshair-lumina-trans-64x64", + }; +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java deleted file mode 100644 index 3ace5ab6a..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage00NEWT.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.jogl.util.texture; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URLConnection; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.FixMethodOrder; -import org.junit.runners.MethodSorters; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.texture.spi.PNGImage; - -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestPNGImage00NEWT extends UITestCase { - @Test - public void testPNGReadWriteAndCompare() throws InterruptedException, IOException, MalformedURLException { - final File out1_f=new File(getSimpleTestName(".")+"-PNGImageTest1.png"); - final File out2_f=new File(getSimpleTestName(".")+"-PNGImageTest2.png"); - final File out2F_f=new File(getSimpleTestName(".")+"-PNGImageTest2Flipped.png"); - final File out2R_f=new File(getSimpleTestName(".")+"-PNGImageTest2Reversed.png"); - final File out2RF_f=new File(getSimpleTestName(".")+"-PNGImageTest2ReversedFlipped.png"); - final String url_s="jogl/util/data/av/test-ntsc01-57x32.png"; - URLConnection urlConn = IOUtil.getResource(url_s, this.getClass().getClassLoader()); - PNGImage image1 = PNGImage.read(urlConn.getInputStream()); - System.err.println("PNGImage - Orig: "+image1); - image1.write(out1_f, true); - { - Assert.assertEquals(image1.getData(), PNGImage.read(out1_f.toURI().toURL().openStream()).getData()); - } - - final PNGImage image2 = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), false /* reverseChannels */, image1.isGLOriented(), image1.getData()); - image2.write(out2_f, true); - { - Assert.assertEquals(image1.getData(), PNGImage.read(out2_f.toURI().toURL().openStream()).getData()); - } - - // flipped - final PNGImage image2F = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), false /* reverseChannels */, !image1.isGLOriented(), image1.getData()); - image2F.write(out2F_f, true); - - // reversed channels - final PNGImage image2R = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), true /* reverseChannels */, image1.isGLOriented(), image1.getData()); - image2R.write(out2R_f, true); - - // reversed channels and flipped - final PNGImage image2RF = PNGImage.createFromData(image1.getWidth(), image1.getHeight(), - image1.getDpi()[0], image1.getDpi()[1], - image1.getBytesPerPixel(), true /* reverseChannels */, !image1.isGLOriented(), image1.getData()); - image2RF.write(out2RF_f, true); - } - - public static void main(String args[]) { - org.junit.runner.JUnitCore.main(TestPNGImage00NEWT.class.getName()); - } -} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java deleted file mode 100644 index 29e041908..000000000 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGImage01NEWT.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Copyright 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package com.jogamp.opengl.test.junit.jogl.util.texture; - -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URLConnection; - -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.FixMethodOrder; -import org.junit.runners.MethodSorters; - -import com.jogamp.common.util.IOUtil; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.test.junit.jogl.demos.TextureDraw01Accessor; -import com.jogamp.opengl.test.junit.jogl.demos.es2.TextureDraw01ES2Listener; -import com.jogamp.opengl.test.junit.util.MiscUtils; -import com.jogamp.opengl.test.junit.util.QuitAdapter; -import com.jogamp.opengl.test.junit.util.UITestCase; -import com.jogamp.opengl.util.Animator; -import com.jogamp.opengl.util.GLReadBufferUtil; -import com.jogamp.opengl.util.GLPixelBuffer.GLPixelAttributes; -import com.jogamp.opengl.util.texture.TextureData; -import com.jogamp.opengl.util.texture.TextureIO; -import com.jogamp.opengl.util.texture.spi.PNGImage; - -/** - * Test reading and displaying a PNG image. - *

        - * Main function accepts arbitrary PNG file name for manual tests. - *

        - */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class TestPNGImage01NEWT extends UITestCase { - - static boolean showFPS = false; - static long duration = 200; // ms - - public void testImpl(final InputStream istream) throws InterruptedException, IOException { - final PNGImage image = PNGImage.read(istream); - Assert.assertNotNull(image); - final boolean hasAlpha = 4 == image.getBytesPerPixel(); - System.err.println("PNGImage: "+image); - - final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); - final GLProfile glp = GLProfile.getGL2ES2(); - final GLCapabilities caps = new GLCapabilities(glp); - if( hasAlpha ) { - caps.setAlphaBits(1); - } - - final int internalFormat; - if(glp.isGL2ES3()) { - internalFormat = hasAlpha ? GL.GL_RGBA8 : GL.GL_RGB8; - } else { - internalFormat = hasAlpha ? GL.GL_RGBA : GL.GL_RGB; - } - final TextureData texData = new TextureData(glp, internalFormat, - image.getWidth(), - image.getHeight(), - 0, - new GLPixelAttributes(image.getGLFormat(), image.getGLType()), - false /* mipmap */, - false /* compressed */, - false /* must flip-vert */, - image.getData(), - null); - - // final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG); - System.err.println("TextureData: "+texData); - - final GLWindow glad = GLWindow.create(caps); - glad.setTitle("TestPNGImage01NEWT"); - // Size OpenGL to Video Surface - glad.setSize(texData.getWidth(), texData.getHeight()); - - // load texture from file inside current GL context to match the way - // the bug submitter was doing it - final TextureDraw01ES2Listener gle = new TextureDraw01ES2Listener( texData, 0 ) ; - // gle.setClearColor(new float[] { 1.0f, 0.0f, 0.0f, 1.0f } ); - - glad.addGLEventListener(gle); - glad.addGLEventListener(new GLEventListener() { - boolean shot = false; - - @Override public void init(GLAutoDrawable drawable) { - System.err.println("Chosen Caps: " + drawable.getChosenGLCapabilities()); - System.err.println("GL ctx: " + drawable.getGL().getContext()); - } - - @Override public void display(GLAutoDrawable drawable) { - // 1 snapshot - if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { - shot = true; - snapshot(0, null, drawable.getGL(), screenshot, TextureIO.PNG, null); - } - } - - @Override public void dispose(GLAutoDrawable drawable) { } - @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } - }); - - Animator animator = new Animator(glad); - animator.setUpdateFPSFrames(60, showFPS ? System.err : null); - QuitAdapter quitAdapter = new QuitAdapter(); - glad.addKeyListener(quitAdapter); - glad.addWindowListener(quitAdapter); - glad.setVisible(true); - animator.start(); - - while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() + * Main function accepts arbitrary PNG file name for manual tests. + *

        + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestPNGPixelRect01NEWT extends UITestCase { + static boolean showFPS = false; + static long duration = 200; // ms + + public void testImpl(final int num, final String basename, final InputStream istream, final PixelFormat destFmt) throws InterruptedException, IOException { + final GLProfile glp = GLProfile.getGL2ES2(); + final PNGPixelRect image = PNGPixelRect.read(istream, destFmt, true /* directBuffer */, 0 /* destMinStrideInBytes */, true /* destIsGLOriented */); + Assert.assertNotNull(image); + final GLPixelAttributes glpa = GLPixelAttributes.convert(image.getPixelformat(), glp); + final boolean hasAlpha = 4 == glpa.bytesPerPixel; + System.err.println("PNGPixelRect: "+basename+", "+image+", glpa "+glpa); + + final GLReadBufferUtil screenshot = new GLReadBufferUtil(true, false); + final GLCapabilities caps = new GLCapabilities(glp); + if( hasAlpha ) { + caps.setAlphaBits(1); + } + + final int internalFormat; + if(glp.isGL2ES3()) { + internalFormat = hasAlpha ? GL.GL_RGBA8 : GL.GL_RGB8; + } else { + internalFormat = hasAlpha ? GL.GL_RGBA : GL.GL_RGB; + } + final TextureData texData = new TextureData(glp, internalFormat, + image.getSize().getWidth(), + image.getSize().getHeight(), + 0, + glpa, + false /* mipmap */, + false /* compressed */, + false /* must flip-vert */, + image.getPixels(), + null); + + // final TextureData texData = TextureIO.newTextureData(glp, istream, false /* mipmap */, TextureIO.PNG); + System.err.println("TextureData: "+texData); + + final GLWindow glad = GLWindow.create(caps); + glad.setTitle(this.getSimpleTestName(".")); + // Size OpenGL to Video Surface + glad.setSize(texData.getWidth(), texData.getHeight()); + + // load texture from file inside current GL context to match the way + // the bug submitter was doing it + final TextureDraw01ES2Listener gle = new TextureDraw01ES2Listener( texData, 0 ) ; + // gle.setClearColor(new float[] { 1.0f, 0.0f, 0.0f, 1.0f } ); + + glad.addGLEventListener(gle); + glad.addGLEventListener(new GLEventListener() { + boolean shot = false; + + @Override public void init(GLAutoDrawable drawable) { + System.err.println("Chosen Caps: " + drawable.getChosenGLCapabilities()); + System.err.println("GL ctx: " + drawable.getGL().getContext()); + } + + @Override public void display(GLAutoDrawable drawable) { + // 1 snapshot + if(null!=((TextureDraw01Accessor)gle).getTexture() && !shot) { + shot = true; + snapshot(num, basename, drawable.getGL(), screenshot, TextureIO.PNG, null); + } + } + + @Override public void dispose(GLAutoDrawable drawable) { } + @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + }); + + Animator animator = new Animator(glad); + animator.setUpdateFPSFrames(60, showFPS ? System.err : null); + QuitAdapter quitAdapter = new QuitAdapter(); + glad.addKeyListener(quitAdapter); + glad.addWindowListener(quitAdapter); + glad.setVisible(true); + animator.start(); + + while(!quitAdapter.shouldQuit() && animator.isAnimating() && animator.getTotalFPSDuration() "+destFmt); + final PixelRectangle imageConv1 = PixelFormatUtil.convert32(image1, destFmt, destMinStrideInBytes, destIsGLOriented, false /* nio */); + System.err.println("PNGPixelRect - Conv1: "+imageConv1); + final PixelRectangle imageConv2 = PixelFormatUtil.convert32(imageConv1, image1.getPixelformat(), image1.getStride(), image1.isGLOriented(), false /* nio */); + System.err.println("PNGPixelRect - Conv2: "+imageConv2); + Assert.assertEquals(image1.getPixels(), imageConv2.getPixels()); + } + } + + public static void main(String args[]) { + org.junit.runner.JUnitCore.main(TestPixelFormatUtil01NEWT.class.getName()); + } +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png new file mode 100644 index 000000000..92279640b Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-32x32.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png new file mode 100644 index 000000000..9be285335 Binary files /dev/null and b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/crosshair-lumina-trans-64x64.png differ diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java index 69874df6b..70d01ae66 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/NewtAWTReparentingKeyAdapter.java @@ -28,25 +28,27 @@ package com.jogamp.opengl.test.junit.newt.parenting; import java.awt.Frame; +import java.net.URLConnection; import javax.media.nativewindow.util.InsetsImmutable; import com.jogamp.common.util.IOUtil; import com.jogamp.newt.Display; -import com.jogamp.newt.Window; import com.jogamp.newt.Display.PointerIcon; import com.jogamp.newt.awt.NewtCanvasAWT; import com.jogamp.newt.event.KeyAdapter; import com.jogamp.newt.event.KeyEvent; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.util.QuitAdapter; +import com.jogamp.opengl.util.PNGPixelRect; public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final Frame frame; final NewtCanvasAWT newtCanvasAWT; final GLWindow glWindow; final QuitAdapter quitAdapter; - PointerIcon pointerIconTest = null; + PointerIcon[] pointerIcons = null; + int pointerIconIdx = 0; public NewtAWTReparentingKeyAdapter(Frame frame, NewtCanvasAWT newtCanvasAWT, GLWindow glWindow, QuitAdapter quitAdapter) { this.frame = frame; @@ -144,13 +146,46 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { } } }.start(); } else if(e.getKeySymbol() == KeyEvent.VK_C ) { - if( null == pointerIconTest ) { - final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/jogamp-32x32.png" } ); - final Display disp = glWindow.getScreen().getDisplay(); - try { - pointerIconTest = disp.createPointerIcon(res, 16, 0); - } catch (Exception err) { - err.printStackTrace(); + if( null == pointerIcons ) { + { + pointerIcons = new PointerIcon[3]; + final Display disp = glWindow.getScreen().getDisplay(); + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "newt/data/crosshair-lumina-trans-32x32.png" } ); + try { + _pointerIcon = disp.createPointerIcon(res, 16, 16); + System.err.println("Create PointerIcon #01: "+_pointerIcon); + } catch (Exception ex) { + ex.printStackTrace(); + } + pointerIcons[0] = _pointerIcon; + } + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "jogamp-pointer-64x64.png" } ); + try { + _pointerIcon = disp.createPointerIcon(res, 32, 0); + System.err.println("Create PointerIcon #02: "+_pointerIcon); + } catch (Exception ex) { + ex.printStackTrace(); + } + pointerIcons[1] = _pointerIcon; + } + { + PointerIcon _pointerIcon = null; + final IOUtil.ClassResources res = new IOUtil.ClassResources(glWindow.getClass(), new String[] { "crosshair-lumina-trans-64x64.png" } ); + try { + final URLConnection urlConn = res.resolve(0); + final PNGPixelRect image = PNGPixelRect.read(urlConn.getInputStream(), null, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); + System.err.println("Create PointerIcon #03: "+image); + _pointerIcon = disp.createPointerIcon(image, 32, 32); + System.err.println("Create PointerIcon #03: "+_pointerIcon); + } catch (Exception ex) { + ex.printStackTrace(); + } + pointerIcons[2] = _pointerIcon; + } } } new Thread() { @@ -158,7 +193,14 @@ public class NewtAWTReparentingKeyAdapter extends KeyAdapter { final Thread t = glWindow.setExclusiveContextThread(null); System.err.println("[set pointer-icon pre]"); final PointerIcon currentPI = glWindow.getPointerIcon(); - glWindow.setPointerIcon( currentPI == pointerIconTest ? null : pointerIconTest); + final PointerIcon newPI; + if( pointerIconIdx >= pointerIcons.length ) { + newPI=null; + pointerIconIdx=0; + } else { + newPI=pointerIcons[pointerIconIdx++]; + } + glWindow.setPointerIcon( newPI ); System.err.println("[set pointer-icon post] "+currentPI+" -> "+glWindow.getPointerIcon()); glWindow.setExclusiveContextThread(t); } }.start(); -- cgit v1.2.3 From bf0e93260dbd6cb8b6ee0cd10d81341906e62da9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 Jan 2014 18:44:35 +0100 Subject: Bug 676 - Add support for native Mouse Pointer rendering (Rasp.-Pi.) - Utilizing layer element 2000 for PointerIcon - Using NEWT PointerIcon code - Using MouseListener to update PointerIcon position - FIXME: Check whether we shall intercept sendMouseEvent directly (lag) Misc: - Properly open, assign and close the BCM display handle - Properly destroy the window (BCM element) - Prepare for multiple windows, set position and size --- make/scripts/tests.sh | 6 +- .../newt/driver/bcm/vc/iv/DisplayDriver.java | 131 ++++++++- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 78 ++++- .../newt/driver/linux/LinuxMouseTracker.java | 12 +- .../jogamp/newt/driver/x11/DisplayDriver.java | 2 +- src/newt/native/bcm_vc_iv.c | 325 +++++++++++++++++++-- src/newt/native/bcm_vc_iv.h | 125 +++++++- 7 files changed, 620 insertions(+), 59 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 55973eb12..c1cdaeb5a 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -229,7 +229,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" - #D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon" + D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" @@ -323,9 +323,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* -testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java index d8d93f123..3d563d88f 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/DisplayDriver.java @@ -28,15 +28,28 @@ package jogamp.newt.driver.bcm.vc.iv; +import java.net.URLConnection; +import java.nio.Buffer; +import java.nio.ByteBuffer; + import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowException; +import javax.media.nativewindow.util.PixelFormat; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.common.util.IOUtil; +import com.jogamp.opengl.util.PNGPixelRect; import jogamp.newt.DisplayImpl; import jogamp.newt.NEWTJNILibLoader; +import jogamp.newt.PointerIconImpl; +import jogamp.newt.driver.linux.LinuxMouseTracker; import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLDisplayUtil; public class DisplayDriver extends DisplayImpl { + static final PNGPixelRect defaultPointerIconImage; + static { NEWTJNILibLoader.loadNEWT(); @@ -49,6 +62,18 @@ public class DisplayDriver extends DisplayImpl { if (!WindowDriver.initIDs()) { throw new NativeWindowException("Failed to initialize bcm.vc.iv Window jmethodIDs"); } + + PNGPixelRect image = null; + if( DisplayImpl.isPNGUtilAvailable() ) { + final IOUtil.ClassResources res = new IOUtil.ClassResources(DisplayDriver.class, new String[] { "newt/data/pointer-grey-alpha-16x24.png" } ); + try { + final URLConnection urlConn = res.resolve(0); + image = PNGPixelRect.read(urlConn.getInputStream(), PixelFormat.BGRA8888, false /* directBuffer */, 0 /* destMinStrideInBytes */, false /* destIsGLOriented */); + } catch (Exception e) { + e.printStackTrace(); + } + } + defaultPointerIconImage = image; } public static void initSingleton() { @@ -57,25 +82,127 @@ public class DisplayDriver extends DisplayImpl { public DisplayDriver() { + bcmHandle = 0; + activePointerIcon = 0; + activePointerIconVisible = false; } @Override protected void createNativeImpl() { // FIXME: map name to EGL_*_DISPLAY + bcmHandle = OpenBCMDisplay0(); aDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(EGL.EGL_DEFAULT_DISPLAY, AbstractGraphicsDevice.DEFAULT_CONNECTION, AbstractGraphicsDevice.DEFAULT_UNIT); + + defaultPointerIcon = (PointerIconImpl) createPointerIcon(defaultPointerIconImage, 0, 0); + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.createDefault: "+defaultPointerIcon); + } + if( null != defaultPointerIcon ) { + final LinuxMouseTracker lmt = LinuxMouseTracker.getSingleton(); + setPointerIconActive(defaultPointerIcon.getHandle(), lmt.getLastX(), lmt.getLastY()); + } } + private PointerIconImpl defaultPointerIcon = null; @Override protected void closeNativeImpl(AbstractGraphicsDevice aDevice) { aDevice.close(); + CloseBCMDisplay0(bcmHandle); + bcmHandle = 0; } + /* pp */ final long getBCMHandle() { return bcmHandle; } + @Override protected void dispatchMessagesNative() { - DispatchMessages(); + DispatchMessages0(); + } + + // @Override + // public final PixelFormat getNativePointerIconPixelFormat() { return PixelFormat.BGRA8888; } + + @Override + protected final long createPointerIconImpl(PixelFormat pixelformat, int width, int height, final ByteBuffer pixels, final int hotX, final int hotY) { + return CreatePointerIcon(bcmHandle, pixels, width, height, hotX, hotY); + } + + @Override + protected final void destroyPointerIconImpl(final long displayHandle, long piHandle) { + DestroyPointerIcon0(piHandle); + } + + /* pp */ void setPointerIconActive(long piHandle, final int x, final int y) { + synchronized(pointerIconSync) { + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.set.0: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"] -> "+toHexString(piHandle)); + } + if( 0 != activePointerIcon && activePointerIconVisible ) { + SetPointerIcon0(bcmHandle, activePointerIcon, false, x, y); + } + if( 0 == piHandle && null != defaultPointerIcon ) { + piHandle = defaultPointerIcon.getHandle(); + } + if( 0 != piHandle ) { + SetPointerIcon0(bcmHandle, piHandle, true, x, y); + activePointerIconVisible = true; + } else { + activePointerIconVisible = false; + } + activePointerIcon = piHandle; + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.set.X: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"]"); + } + } + } + /* pp */ void setActivePointerIconVisible(final boolean visible, final int x, final int y) { + synchronized(pointerIconSync) { + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.visible: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"] -> visible "+visible); + } + if( activePointerIconVisible != visible ) { + if( 0 != activePointerIcon ) { + SetPointerIcon0(bcmHandle, activePointerIcon, visible, x, y); + } + activePointerIconVisible = visible; + } + } + } + /* pp */ void moveActivePointerIcon(final int x, final int y) { + synchronized(pointerIconSync) { + if( DEBUG_POINTER_ICON ) { + System.err.println("Display.PointerIcon.move: active ["+toHexString(activePointerIcon)+", visible "+activePointerIconVisible+"], "+x+"/"+y); + } + if( 0 != activePointerIcon && activePointerIconVisible ) { + MovePointerIcon0(activePointerIcon, x, y); + } + } } + //---------------------------------------------------------------------- + // Internals only + // + protected static native boolean initIDs(); - private native void DispatchMessages(); + private static native long OpenBCMDisplay0(); + private static native void CloseBCMDisplay0(long handle); + + private static long CreatePointerIcon(long bcmHandle, Buffer pixels, int width, int height, int hotX, int hotY) { + final boolean pixels_is_direct = Buffers.isDirect(pixels); + return CreatePointerIcon0(pixels_is_direct ? pixels : Buffers.getArray(pixels), + pixels_is_direct ? Buffers.getDirectBufferByteOffset(pixels) : Buffers.getIndirectBufferByteOffset(pixels), + pixels_is_direct, + width, height, hotX, hotY); + } + private static native long CreatePointerIcon0(Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY); + private static native void DestroyPointerIcon0(long handle); + private static native void SetPointerIcon0(long bcmHandle, long handle, boolean enable, int x, int y); + private static native void MovePointerIcon0(long handle, int x, int y); + + private static native void DispatchMessages0(); + + private long bcmHandle; + private long activePointerIcon; + private boolean activePointerIconVisible; + private final Object pointerIconSync = new Object(); } diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index 4d4977776..5109d0fbb 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -39,7 +39,10 @@ import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; +import com.jogamp.newt.event.MouseListener; +import com.jogamp.newt.event.MouseAdapter; +import jogamp.newt.PointerIconImpl; import jogamp.newt.WindowImpl; import jogamp.newt.driver.linux.LinuxEventDeviceTracker; import jogamp.newt.driver.linux.LinuxMouseTracker; @@ -53,6 +56,8 @@ public class WindowDriver extends WindowImpl { } public WindowDriver() { + linuxMouseTracker = LinuxMouseTracker.getSingleton(); + linuxEventDeviceTracker = LinuxEventDeviceTracker.getSingleton(); } @Override @@ -60,9 +65,12 @@ public class WindowDriver extends WindowImpl { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } + final ScreenDriver screen = (ScreenDriver) getScreen(); + final DisplayDriver display = (DisplayDriver) screen.getDisplay(); + // Create own screen/device resource instance allowing independent ownership, // while still utilizing shared EGL resources. - final AbstractGraphicsScreen aScreen = getScreen().getGraphicsScreen(); + final AbstractGraphicsScreen aScreen = screen.getGraphicsScreen(); final EGLGraphicsDevice aDevice = (EGLGraphicsDevice) aScreen.getDevice(); final EGLGraphicsDevice eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(aDevice.getNativeDisplayID(), aDevice.getConnection(), aDevice.getUnitID()); final DefaultGraphicsScreen eglScreen = new DefaultGraphicsScreen(eglDevice, aScreen.getIndex()); @@ -78,7 +86,8 @@ public class WindowDriver extends WindowImpl { chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque()); } setGraphicsConfiguration(cfg); - nativeWindowHandle = CreateWindow(getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); + nativeWindowHandle = CreateWindow0(display.getBCMHandle(), getX(), getY(), getWidth(), getHeight(), + chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); if (nativeWindowHandle == 0) { throw new NativeWindowException("Error creating egl window: "+cfg); } @@ -88,21 +97,37 @@ public class WindowDriver extends WindowImpl { throw new NativeWindowException("Error native Window Handle is null"); } windowHandleClose = nativeWindowHandle; - addWindowListener(LinuxMouseTracker.getSingleton()); - addWindowListener(LinuxEventDeviceTracker.getSingleton()); + + addWindowListener(linuxEventDeviceTracker); + addWindowListener(linuxMouseTracker); + addMouseListener(mousePointerTracker); focusChanged(false, true); } + final MouseListener mousePointerTracker = new MouseAdapter() { + @Override + public void mouseMoved(com.jogamp.newt.event.MouseEvent e) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.moveActivePointerIcon(e.getX(), e.getY()); + } + + @Override + public void mouseDragged(com.jogamp.newt.event.MouseEvent e) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.moveActivePointerIcon(e.getX(), e.getY()); + } + }; @Override protected void closeNativeImpl() { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); final EGLGraphicsDevice eglDevice = (EGLGraphicsDevice) getGraphicsConfiguration().getScreen().getDevice(); - removeWindowListener(LinuxMouseTracker.getSingleton()); - removeWindowListener(LinuxEventDeviceTracker.getSingleton()); + removeMouseListener(mousePointerTracker); + removeWindowListener(linuxMouseTracker); + removeWindowListener(linuxEventDeviceTracker); if(0!=windowHandleClose) { - CloseWindow(windowHandleClose, windowUserData); - windowUserData=0; + CloseWindow0(display.getBCMHandle(), windowHandleClose); } eglDevice.close(); @@ -157,23 +182,44 @@ public class WindowDriver extends WindowImpl { // nop .. } + /** + @Override + public final void sendMouseEvent(final short eventType, final int modifiers, + final int x, final int y, final short button, final float rotation) { + if( MouseEvent.MOUSE_MOVED == eventType ) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.moveActivePointerIcon(x, y); + } + super.sendMouseEvent(eventType, modifiers, x, y, button, rotation); + } */ + + @Override + protected void setPointerIconImpl(final PointerIconImpl pi) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.setPointerIconActive(null != pi ? pi.validatedHandle() : 0, linuxMouseTracker.getLastX(), linuxMouseTracker.getLastY()); + } + + @Override + protected boolean setPointerVisibleImpl(final boolean pointerVisible) { + final DisplayDriver display = (DisplayDriver) getScreen().getDisplay(); + display.setActivePointerIconVisible(pointerVisible, linuxMouseTracker.getLastX(), linuxMouseTracker.getLastY()); + return true; + } + //---------------------------------------------------------------------- // Internals only // + private final LinuxMouseTracker linuxMouseTracker; + private final LinuxEventDeviceTracker linuxEventDeviceTracker; protected static native boolean initIDs(); - private native long CreateWindow(int width, int height, boolean opaque, int alphaBits); - private native long RealizeWindow(long eglWindowHandle); - private native int CloseWindow(long eglWindowHandle, long userData); + private native long CreateWindow0(long bcmDisplay, int x, int y, int width, int height, boolean opaque, int alphaBits); + private native void CloseWindow0(long bcmDisplay, long eglWindowHandle); private native void setVisible0(long eglWindowHandle, boolean visible); + private native void setPos0(long eglWindowHandle, int x, int y); private native void setSize0(long eglWindowHandle, int width, int height); private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); - private void windowCreated(long userData) { - windowUserData=userData; - } - private long nativeWindowHandle; private long windowHandleClose; - private long windowUserData; } diff --git a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java index 1e314b7f4..9d7b8931b 100644 --- a/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java +++ b/src/newt/classes/jogamp/newt/driver/linux/LinuxMouseTracker.java @@ -68,9 +68,14 @@ public class LinuxMouseTracker implements WindowListener { private short buttonDown = 0; private int old_x = 0; private int old_y = 0; + private volatile int lastFocusedX = 0; + private volatile int lastFocusedY = 0; private short old_buttonDown = 0; private WindowImpl focusedWindow = null; - private MouseDevicePoller mouseDevicePoller = new MouseDevicePoller(); + private final MouseDevicePoller mouseDevicePoller = new MouseDevicePoller(); + + public final int getLastX() { return lastFocusedX; } + public final int getLastY() { return lastFocusedY; } @Override public void windowResized(WindowEvent e) { } @@ -179,10 +184,11 @@ public class LinuxMouseTracker implements WindowListener { if( y >= focusedWindow.getScreen().getHeight() ) { y = focusedWindow.getScreen().getHeight() - 1; } - int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY(); - + final int wx = x - focusedWindow.getX(), wy = y - focusedWindow.getY(); if(old_x != x || old_y != y) { // mouse moved + lastFocusedX = wx; + lastFocusedY = wy; focusedWindow.sendMouseEvent(MouseEvent.EVENT_MOUSE_MOVED, 0, wx, wy, (short)0, 0 ); } diff --git a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java index 4d1388eec..391b8b19d 100644 --- a/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java +++ b/src/newt/classes/jogamp/newt/driver/x11/DisplayDriver.java @@ -165,7 +165,7 @@ public class DisplayDriver extends DisplayImpl { } private static native long createPointerIcon0(long display, Object pixels, int pixels_byte_offset, boolean pixels_is_direct, int width, int height, int hotX, int hotY); - static native void destroyPointerIcon0(long display, long handle); + private static native void destroyPointerIcon0(long display, long handle); /** X11 Window delete atom marker used on EDT */ private long windowDeleteAtom; diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index f3474ee34..50f0c140a 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -39,15 +39,36 @@ #define VERBOSE_ON 1 #ifdef VERBOSE_ON - #define DBG_PRINT(...) fprintf(stdout, __VA_ARGS__) + #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) #else #define DBG_PRINT(...) #endif +typedef struct { + DISPMANX_ELEMENT_HANDLE_T handle; // magic BCM EGL position (EGL_DISPMANX_WINDOW_T) + int width; // magic BCM EGL position (EGL_DISPMANX_WINDOW_T) + int height; // magic BCM EGL position (EGL_DISPMANX_WINDOW_T) + int x; + int y; + int32_t layer; +} BCM_ELEMENT_T; + +typedef struct { + DISPMANX_RESOURCE_HANDLE_T handle; + VC_IMAGE_TYPE_T type; + uint32_t native_image_handle; +} BCM_RESOURCE_T; + +typedef struct { + BCM_ELEMENT_T element; + BCM_RESOURCE_T resource; + int hotX, hotY; +} POINTER_ICON_T; + static jmethodID setScreenSizeID = NULL; -static jmethodID windowCreatedID = NULL; static jmethodID sizeChangedID = NULL; +static jmethodID positionChangedID = NULL; static jmethodID visibleChangedID = NULL; static jmethodID windowDestroyNotifyID = NULL; @@ -64,11 +85,210 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_initI return JNI_TRUE; } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DispatchMessages - (JNIEnv *env, jobject obj) +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_OpenBCMDisplay0 + (JNIEnv *env, jclass clazz) +{ + DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */); + DBG_PRINT( "BCM.Display Open %p\n", (void*)(intptr_t)dispman_display); + return (jlong) (intptr_t) dispman_display; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_CloseBCMDisplay0 + (JNIEnv *env, jclass clazz, jlong display) +{ + DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; + DBG_PRINT( "BCM.Display Close %p\n", (void*)(intptr_t)dispman_display); + vc_dispmanx_display_close( dispman_display ); +} + + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DispatchMessages0 + (JNIEnv *env, jclass clazz) { } +static void bcm_moveTo(DISPMANX_ELEMENT_HANDLE_T element, uint32_t layer, int x, int y, int width, int height) { + VC_RECT_T src_rect; + VC_RECT_T dst_rect; + uint32_t change_flags = DISPMANX_ELEMENT_CHANGE_DEST_RECT | DISPMANX_ELEMENT_CHANGE_SRC_RECT; + DISPMANX_RESOURCE_HANDLE_T mask = 0; + DISPMANX_TRANSFORM_T transform = 0; + + uint8_t opacity = 0; // NOP + + dst_rect.x = x; + dst_rect.y = y; + dst_rect.width = width; + dst_rect.height = height; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = width << 16; + src_rect.height = height << 16; + + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + vc_dispmanx_element_change_attributes( dispman_update, + element, + change_flags, + layer, + opacity, + &dst_rect, + &src_rect, + mask, + transform ); + vc_dispmanx_update_submit_sync( dispman_update ); +} + +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_CreatePointerIcon0 + (JNIEnv *env, jclass clazz, jobject pixels, jint pixels_byte_offset, jboolean pixels_is_direct, jint width, jint height, jint hotX, jint hotY) +{ + if( 0 == pixels ) { + return 0; + } + int32_t success = 0; + VC_RECT_T dst_rect; + VC_RECT_T src_rect; + int x = 0; + int y = 0; + int pitch = width * 4; // RGBA + + const unsigned char * pixelPtr = (const unsigned char *) ( JNI_TRUE == pixels_is_direct ? + (*env)->GetDirectBufferAddress(env, pixels) : + (*env)->GetPrimitiveArrayCritical(env, pixels, NULL) ); + + POINTER_ICON_T * p = calloc(1, sizeof(POINTER_ICON_T)); + p->hotX = hotX; + p->hotY = hotY; + p->element.layer = 2000; + p->element.x = x; + p->element.y = y; + p->element.width = width; + p->element.height = height; + p->resource.type = VC_IMAGE_ARGB8888; /* 32bpp with 8bit alpha at MS byte, with R, G, B (LS byte) */ + p->resource.handle = vc_dispmanx_resource_create( p->resource.type, + width, + height, + &(p->resource.native_image_handle) ); + + dst_rect.x = x; + dst_rect.y = y; + dst_rect.width = width; + dst_rect.height = height; + + vc_dispmanx_resource_write_data( p->resource.handle, + p->resource.type, + pitch, + (void*)(intptr_t)(pixelPtr + pixels_byte_offset), + &dst_rect ); + + if ( JNI_FALSE == pixels_is_direct ) { + (*env)->ReleasePrimitiveArrayCritical(env, pixels, (void*)pixelPtr, JNI_ABORT); + } + + DBG_PRINT( "BCM.Display PointerIcon.Create PI %p, resource %p\n", p, (void*)(intptr_t)p->resource.handle); + return (jlong) (intptr_t) p; +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_DestroyPointerIcon0 + (JNIEnv *env, jclass clazz, jlong handle) +{ + POINTER_ICON_T * p = (POINTER_ICON_T *) (intptr_t) handle ; + if( 0 == p ) { + return; + } + + DBG_PRINT( "BCM.Display PointerIcon.Destroy.0 PI %p, resource %p, element %p\n", + p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle); + + if( 0 != p->element.handle ) { + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + vc_dispmanx_element_remove( dispman_update, p->element.handle ); + p->element.handle = 0; + vc_dispmanx_update_submit_sync( dispman_update ); + } + if( 0 != p->resource.handle ) { + vc_dispmanx_resource_delete( p->resource.handle ); + p->resource.handle = 0; + } + free( p ); +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_SetPointerIcon0 + (JNIEnv *env, jclass clazz, jlong display, jlong handle, jboolean enable, jint x, jint y) +{ + DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; + POINTER_ICON_T * p = (POINTER_ICON_T *) (intptr_t) handle ; + VC_RECT_T dst_rect; + VC_RECT_T src_rect; + + if( 0 == dispman_display || NULL == p || 0 == p->resource.handle ) { + return; + } + + DBG_PRINT( "BCM.Display PointerIcon.Set.0 %p, PI %p, resource %p, element %p - enable %d - %d/%d\n", + (void*)(intptr_t)display, p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle, enable, x, y); + + if( enable ) { + if( 0 != p->element.handle ) { + return; + } + + p->element.x = x; + p->element.y = y; + dst_rect.x = p->element.x - p->hotX; + dst_rect.y = p->element.y - p->hotY; + dst_rect.width = p->element.width; + dst_rect.height = p->element.height; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = p->element.width << 16; + src_rect.height = p->element.height << 16; + + VC_DISPMANX_ALPHA_T dispman_alpha; + memset(&dispman_alpha, 0x0, sizeof(VC_DISPMANX_ALPHA_T)); + dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE ; + dispman_alpha.opacity = 0xFF; + dispman_alpha.mask = 0xFF; + + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + p->element.handle = vc_dispmanx_element_add ( dispman_update, dispman_display, + p->element.layer, &dst_rect, + p->resource.handle /*src*/, + &src_rect, DISPMANX_PROTECTION_NONE, + &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); + vc_dispmanx_update_submit_sync( dispman_update ); + } else { + // DISABLE + if( 0 == p->element.handle ) { + return; + } + p->element.x = x; + p->element.y = y; + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + vc_dispmanx_element_remove( dispman_update, p->element.handle ); + p->element.handle = 0; + vc_dispmanx_update_submit_sync( dispman_update ); + } + DBG_PRINT( "BCM.Display PointerIcon.Set.X %p, PI %p, resource %p, element %p - enable %d - %d/%d\n", + (void*)(intptr_t)display, p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle, enable, x, y); +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_DisplayDriver_MovePointerIcon0 + (JNIEnv *env, jclass clazz, jlong handle, jint x, jint y) +{ + POINTER_ICON_T * p = (POINTER_ICON_T *) (intptr_t) handle ; + + if( NULL == p || 0 == p->element.handle ) { + return; + } + DBG_PRINT( "BCM.Display PointerIcon.Move.0 PI %p, resource %p, element %p - %d/%d\n", + p, (void*)(intptr_t)p->resource.handle, (void*)(intptr_t)p->element.handle, x, y); + p->element.x = x; + p->element.y = y; + bcm_moveTo( p->element.handle, p->element.layer, p->element.x - p->hotX, p->element.y - p->hotY, p->element.width, p->element.height); +} + /** * Screen */ @@ -111,12 +331,12 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initIDs (JNIEnv *env, jclass clazz) { - windowCreatedID = (*env)->GetMethodID(env, clazz, "windowCreated", "(J)V"); sizeChangedID = (*env)->GetMethodID(env, clazz, "sizeChanged", "(ZIIZ)V"); + positionChangedID = (*env)->GetMethodID(env, clazz, "positionChanged", "(ZII)V"); visibleChangedID = (*env)->GetMethodID(env, clazz, "visibleChanged", "(ZZ)V"); windowDestroyNotifyID = (*env)->GetMethodID(env, clazz, "windowDestroyNotify", "(Z)Z"); - if (windowCreatedID == NULL || - sizeChangedID == NULL || + if (sizeChangedID == NULL || + positionChangedID == NULL || visibleChangedID == NULL || windowDestroyNotifyID == NULL) { DBG_PRINT( "initIDs failed\n" ); @@ -126,20 +346,23 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID return JNI_TRUE; } -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow - (JNIEnv *env, jobject obj, jint width, jint height, jboolean opaque, jint alphaBits) +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow0 + (JNIEnv *env, jobject obj, jlong display, jint x, jint y, jint width, jint height, jboolean opaque, jint alphaBits) { int32_t success = 0; VC_RECT_T dst_rect; VC_RECT_T src_rect; + if( 0 == display ) { + return; + } dst_rect.x = 0; dst_rect.y = 0; dst_rect.width = width; dst_rect.height = height; - src_rect.x = 0; - src_rect.y = 0; + src_rect.x = x; + src_rect.y = y; src_rect.width = width << 16; src_rect.height = height << 16; @@ -156,37 +379,52 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin dispman_alpha.mask = 0xFF; } - DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */); + DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; + + DBG_PRINT( "BCM.Display Window.Create.0 %p, %d/%d %dx%d, opaque %d, alphaBits %d\n", + (void*)(intptr_t)dispman_display, x, y, width, height, opaque, alphaBits); + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display, 0/*layer*/, &dst_rect, 0/*src*/, &src_rect, DISPMANX_PROTECTION_NONE, &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); - EGL_DISPMANX_WINDOW_T * nativeWindowPtr = calloc(1, sizeof(EGL_DISPMANX_WINDOW_T)); - nativeWindowPtr->element = dispman_element; - nativeWindowPtr->width = width; - nativeWindowPtr->height = height; + BCM_ELEMENT_T * p = calloc(1, sizeof(BCM_ELEMENT_T)); + p->handle = dispman_element; + p->layer = 0; + p->x = x; + p->y = y; + p->width = width; + p->height = height; vc_dispmanx_update_submit_sync( dispman_update ); (*env)->CallVoidMethod(env, obj, visibleChangedID, JNI_FALSE, JNI_TRUE); // FIXME: or defer=true ? - return (jlong) (intptr_t) nativeWindowPtr; -} + DBG_PRINT( "BCM.Display Window.Create.X %p, element %p\n", + (void*)(intptr_t)dispman_display, (void*)(intptr_t)p->handle); -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_RealizeWindow - (JNIEnv *env, jobject obj, jlong window) -{ - return (jlong) (intptr_t) 0; + return (jlong) (intptr_t) p; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindow - (JNIEnv *env, jobject obj, jlong window, jlong juserData) +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindow0 + (JNIEnv *env, jobject obj, jlong display, jlong window) { - EGL_DISPMANX_WINDOW_T * nativeWindowPtr = (EGL_DISPMANX_WINDOW_T *) (intptr_t) window ; - free( nativeWindowPtr ); - return 0; + DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; + BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; + + DBG_PRINT( "BCM.Display Window.Close %p, element %p\n", + (void*)(intptr_t)dispman_display, (void*)(intptr_t)p->handle); + + if( 0 == dispman_display || NULL == p || 0 == p->handle ) { + return; + } + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + vc_dispmanx_element_remove( dispman_update, p->handle ); + p->handle = 0; + vc_dispmanx_update_submit_sync( dispman_update ); + free( p ); } /* @@ -204,10 +442,41 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setFullScr { } +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setPos0 + (JNIEnv *env, jobject obj, jlong window, jint x, jint y) +{ + BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; + + if( NULL == p || 0 == p->handle ) { + return; + } + p->x = x; + p->y = y; + + DBG_PRINT( "BCM.Display Window.Pos %p, element %p - %d/%d %dx%d\n", + p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); + + bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); + (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); +} + + JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setSize0 (JNIEnv *env, jobject obj, jlong window, jint width, jint height) { - // FIXME RESIZE (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); + BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; + + if( NULL == p || 0 == p->handle ) { + return; + } + p->width = width; + p->height = height; + + DBG_PRINT( "BCM.Display Window.Resize %p, element %p - %d/%d %dx%d\n", + p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); + + bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); + (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); } diff --git a/src/newt/native/bcm_vc_iv.h b/src/newt/native/bcm_vc_iv.h index b43483c10..f98700e4e 100644 --- a/src/newt/native/bcm_vc_iv.h +++ b/src/newt/native/bcm_vc_iv.h @@ -150,12 +150,6 @@ typedef struct { } DISPMANX_CLAMP_T; -typedef struct { - DISPMANX_ELEMENT_HANDLE_T element; - int width; /* This is necessary because dispmanx elements are not queriable. */ - int height; -} EGL_DISPMANX_WINDOW_T; - typedef struct tag_VC_RECT_T { int32_t x; int32_t y; @@ -163,6 +157,102 @@ typedef struct tag_VC_RECT_T { int32_t height; } VC_RECT_T; +/* Types of image supported. */ +/* Please add any new types to the *end* of this list. Also update + * case_VC_IMAGE_ANY_xxx macros (below), and the vc_image_type_info table in + * vc_image/vc_image_helper.c. + */ +typedef enum +{ + VC_IMAGE_MIN = 0, //bounds for error checking + + VC_IMAGE_RGB565 = 1, + VC_IMAGE_1BPP, + VC_IMAGE_YUV420, + VC_IMAGE_48BPP, + VC_IMAGE_RGB888, + VC_IMAGE_8BPP, + VC_IMAGE_4BPP, // 4bpp palettised image + VC_IMAGE_3D32, /* A separated format of 16 colour/light shorts followed by 16 z values */ + VC_IMAGE_3D32B, /* 16 colours followed by 16 z values */ + VC_IMAGE_3D32MAT, /* A separated format of 16 material/colour/light shorts followed by 16 z values */ + VC_IMAGE_RGB2X9, /* 32 bit format containing 18 bits of 6.6.6 RGB, 9 bits per short */ + VC_IMAGE_RGB666, /* 32-bit format holding 18 bits of 6.6.6 RGB */ + VC_IMAGE_PAL4_OBSOLETE, // 4bpp palettised image with embedded palette + VC_IMAGE_PAL8_OBSOLETE, // 8bpp palettised image with embedded palette + VC_IMAGE_RGBA32, /* RGB888 with an alpha byte after each pixel */ /* xxx: isn't it BEFORE each pixel? */ + VC_IMAGE_YUV422, /* a line of Y (32-byte padded), a line of U (16-byte padded), and a line of V (16-byte padded) */ + VC_IMAGE_RGBA565, /* RGB565 with a transparent patch */ + VC_IMAGE_RGBA16, /* Compressed (4444) version of RGBA32 */ + VC_IMAGE_YUV_UV, /* VCIII codec format */ + VC_IMAGE_TF_RGBA32, /* VCIII T-format RGBA8888 */ + VC_IMAGE_TF_RGBX32, /* VCIII T-format RGBx8888 */ + VC_IMAGE_TF_FLOAT, /* VCIII T-format float */ + VC_IMAGE_TF_RGBA16, /* VCIII T-format RGBA4444 */ + VC_IMAGE_TF_RGBA5551, /* VCIII T-format RGB5551 */ + VC_IMAGE_TF_RGB565, /* VCIII T-format RGB565 */ + VC_IMAGE_TF_YA88, /* VCIII T-format 8-bit luma and 8-bit alpha */ + VC_IMAGE_TF_BYTE, /* VCIII T-format 8 bit generic sample */ + VC_IMAGE_TF_PAL8, /* VCIII T-format 8-bit palette */ + VC_IMAGE_TF_PAL4, /* VCIII T-format 4-bit palette */ + VC_IMAGE_TF_ETC1, /* VCIII T-format Ericsson Texture Compressed */ + VC_IMAGE_BGR888, /* RGB888 with R & B swapped */ + VC_IMAGE_BGR888_NP, /* RGB888 with R & B swapped, but with no pitch, i.e. no padding after each row of pixels */ + VC_IMAGE_BAYER, /* Bayer image, extra defines which variant is being used */ + VC_IMAGE_CODEC, /* General wrapper for codec images e.g. JPEG from camera */ + VC_IMAGE_YUV_UV32, /* VCIII codec format */ + VC_IMAGE_TF_Y8, /* VCIII T-format 8-bit luma */ + VC_IMAGE_TF_A8, /* VCIII T-format 8-bit alpha */ + VC_IMAGE_TF_SHORT,/* VCIII T-format 16-bit generic sample */ + VC_IMAGE_TF_1BPP, /* VCIII T-format 1bpp black/white */ + VC_IMAGE_OPENGL, + VC_IMAGE_YUV444I, /* VCIII-B0 HVS YUV 4:4:4 interleaved samples */ + VC_IMAGE_YUV422PLANAR, /* Y, U, & V planes separately (VC_IMAGE_YUV422 has them interleaved on a per line basis) */ + VC_IMAGE_ARGB8888, /* 32bpp with 8bit alpha at MS byte, with R, G, B (LS byte) */ + VC_IMAGE_XRGB8888, /* 32bpp with 8bit unused at MS byte, with R, G, B (LS byte) */ + + VC_IMAGE_YUV422YUYV, /* interleaved 8 bit samples of Y, U, Y, V */ + VC_IMAGE_YUV422YVYU, /* interleaved 8 bit samples of Y, V, Y, U */ + VC_IMAGE_YUV422UYVY, /* interleaved 8 bit samples of U, Y, V, Y */ + VC_IMAGE_YUV422VYUY, /* interleaved 8 bit samples of V, Y, U, Y */ + + VC_IMAGE_RGBX32, /* 32bpp like RGBA32 but with unused alpha */ + VC_IMAGE_RGBX8888, /* 32bpp, corresponding to RGBA with unused alpha */ + VC_IMAGE_BGRX8888, /* 32bpp, corresponding to BGRA with unused alpha */ + + VC_IMAGE_YUV420SP, /* Y as a plane, then UV byte interleaved in plane with with same pitch, half height */ + + VC_IMAGE_YUV444PLANAR, /* Y, U, & V planes separately 4:4:4 */ + + VC_IMAGE_MAX, //bounds for error checking + VC_IMAGE_FORCE_ENUM_16BIT = 0xffff, +} VC_IMAGE_TYPE_T; + +/** + * From https://github.com/raspberrypi/userland/blob/master/interface/vmcs_host/vc_vchi_dispmanx.h + */ +typedef enum { + DISPMANX_ELEMENT_CHANGE_LAYER = (1<<0), + DISPMANX_ELEMENT_CHANGE_OPACITY = (1<<1), + DISPMANX_ELEMENT_CHANGE_DEST_RECT = (1<<2), + DISPMANX_ELEMENT_CHANGE_SRC_RECT = (1<<3), + DISPMANX_ELEMENT_CHANGE_MASK_RESOURCE = (1<<4), + DISPMANX_ELEMENT_CHANGE_TRANSFORM = (1<<5) +/** + * Not working /validated ! + DISPMANX_ELEMENT_CHANGE_MIN = 0x00, + DISPMANX_ELEMENT_CHANGE_SOURCE = 0x01, + DISPMANX_ELEMENT_INSERT_ABOVE = 0x80, + DISPMANX_ELEMENT_CHANGE_FLAGS = 0x100, + DISPMANX_ELEMENT_CHANGE_NOTHING = 0x200, + DISPMANX_ELEMENT_CHANGE_ALPHA_FLAGS = 0x400, + DISPMANX_ELEMENT_CHANGE_PROTECTION = 0x800, + DISPMANX_ELEMENT_CHANGE_MAX = 0x1000 + */ +} DISPMANX_ELEMENT_CHANGE_T; + + + extern void bcm_host_init(void); extern void bcm_host_deinit(void); @@ -171,15 +261,38 @@ extern int32_t graphics_get_display_size( const uint16_t display_number, uint32_t *height); extern DISPMANX_DISPLAY_HANDLE_T vc_dispmanx_display_open( uint32_t device ); +extern int vc_dispmanx_display_close( DISPMANX_DISPLAY_HANDLE_T display ); + +extern DISPMANX_RESOURCE_HANDLE_T vc_dispmanx_resource_create(VC_IMAGE_TYPE_T type, uint32_t width, uint32_t height, uint32_t *native_image_handle); +extern int vc_dispmanx_resource_write_data( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, void * src_address, const VC_RECT_T * rect ); +//extern int vc_dispmanx_resource_write_data_handle( DISPMANX_RESOURCE_HANDLE_T res, VC_IMAGE_TYPE_T src_type, int src_pitch, +// VCHI_MEM_HANDLE_T handle, uint32_t offset, const VC_RECT_T * rect ); +extern int vc_dispmanx_resource_delete( DISPMANX_RESOURCE_HANDLE_T res ); + + + extern DISPMANX_UPDATE_HANDLE_T vc_dispmanx_update_start( int32_t priority ); extern DISPMANX_ELEMENT_HANDLE_T vc_dispmanx_element_add ( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_DISPLAY_HANDLE_T display, int32_t layer, const VC_RECT_T *dest_rect, DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, DISPMANX_PROTECTION_T protection, VC_DISPMANX_ALPHA_T *alpha, DISPMANX_CLAMP_T *clamp, DISPMANX_TRANSFORM_T transform ); +extern int vc_dispmanx_element_remove( DISPMANX_UPDATE_HANDLE_T update, DISPMANX_ELEMENT_HANDLE_T element ); + extern int vc_dispmanx_update_submit_sync( DISPMANX_UPDATE_HANDLE_T update ); +//New function added to VCHI to change attributes, set_opacity does not work there. +extern int vc_dispmanx_element_change_attributes( DISPMANX_UPDATE_HANDLE_T update, + DISPMANX_ELEMENT_HANDLE_T element, + uint32_t change_flags, + int32_t layer, + uint8_t opacity, + const VC_RECT_T *dest_rect, + const VC_RECT_T *src_rect, + DISPMANX_RESOURCE_HANDLE_T mask, + DISPMANX_TRANSFORM_T transform ); + #ifdef __cplusplus } #endif -- cgit v1.2.3 From c828726693038011cce502eb95120ce3a7573732 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 Jan 2014 18:56:47 +0100 Subject: NEWT bcm_vc_iv.c: Disable VERBOSE_ON --- make/scripts/tests.sh | 2 +- src/newt/native/bcm_vc_iv.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c1cdaeb5a..bf9eba958 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -229,7 +229,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnewt.debug=all" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" - D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon" + #D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon" #D_ARGS="-Djogl.debug.JPEGImage" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index 50f0c140a..ea225772f 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -36,10 +36,10 @@ #include "jogamp_newt_driver_bcm_vc_iv_ScreenDriver.h" #include "jogamp_newt_driver_bcm_vc_iv_WindowDriver.h" -#define VERBOSE_ON 1 +// #define VERBOSE_ON 1 #ifdef VERBOSE_ON - #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) + #define DBG_PRINT(...) fprintf(stderr, __VA_ARGS__); fflush(stderr) #else #define DBG_PRINT(...) #endif -- cgit v1.2.3 From 4e9fb8d0fd1b73c592840d6ba34b91da5cca9c18 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 Jan 2014 20:45:28 +0100 Subject: NEWT Rasp.Pi: Add Support for multiple Windows, dynamic set size and position Impl. manages up-to 32 windows (BCM layer elements) - dunno whether this is a proper value. Note: Layer 2000 is reserved for out PointerIcon. Removed 'dead code'. --- make/scripts/tests.sh | 4 +- .../jogamp/newt/driver/bcm/vc/iv/WindowDriver.java | 78 ++++++++++---------- src/newt/native/bcm_vc_iv.c | 82 ++++++++-------------- 3 files changed, 74 insertions(+), 90 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bf9eba958..10cd3f17c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -325,7 +325,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -479,7 +479,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* +testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows03NEWTAnimResize $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java index c05d8d1e8..e91c67813 100644 --- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java +++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java @@ -38,6 +38,7 @@ import javax.media.nativewindow.VisualIDHolder; import javax.media.nativewindow.util.Insets; import javax.media.nativewindow.util.Point; +import com.jogamp.common.util.IntBitfield; import com.jogamp.nativewindow.egl.EGLGraphicsDevice; import com.jogamp.newt.event.MouseEvent; @@ -57,6 +58,9 @@ public class WindowDriver extends WindowImpl { public WindowDriver() { linuxMouseTracker = LinuxMouseTracker.getSingleton(); linuxEventDeviceTracker = LinuxEventDeviceTracker.getSingleton(); + layer = -1; + nativeWindowHandle = 0; + windowHandleClose = 0; } @Override @@ -64,6 +68,26 @@ public class WindowDriver extends WindowImpl { if(0!=getParentWindowHandle()) { throw new RuntimeException("Window parenting not supported (yet)"); } + synchronized( layerSync ) { + if( layerCount >= MAX_LAYERS ) { + throw new RuntimeException("Max windows reached: "+layerCount+" ( "+MAX_LAYERS+" )"); + } + for(int i=0; 0 > layer && i layer ) { + throw new InternalError("Could not find a free layer: count "+layerCount+", max "+MAX_LAYERS); + } final ScreenDriver screen = (ScreenDriver) getScreen(); final DisplayDriver display = (DisplayDriver) screen.getDisplay(); @@ -85,12 +109,11 @@ public class WindowDriver extends WindowImpl { chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque()); } setGraphicsConfiguration(cfg); - nativeWindowHandle = CreateWindow0(display.getBCMHandle(), getX(), getY(), getWidth(), getHeight(), + nativeWindowHandle = CreateWindow0(display.getBCMHandle(), layer, getX(), getY(), getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits()); if (nativeWindowHandle == 0) { throw new NativeWindowException("Error creating egl window: "+cfg); } - setVisible0(nativeWindowHandle, false); setWindowHandle(nativeWindowHandle); if (0 == getWindowHandle()) { throw new NativeWindowException("Error native Window Handle is null"); @@ -115,6 +138,13 @@ public class WindowDriver extends WindowImpl { } eglDevice.close(); + + synchronized( layerSync ) { + usedLayers.put(layer, false); + layerCount--; + layer = -1; + // System.err.println("XXX.Close capacity "+usedLayers.capacity()+", count "+usedLayers.getBitCount()); + } } @Override @@ -124,35 +154,7 @@ public class WindowDriver extends WindowImpl { @Override protected boolean reconfigureWindowImpl(int x, int y, int width, int height, int flags) { - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - setVisible0(nativeWindowHandle, 0 != ( FLAG_IS_VISIBLE & flags)); - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - - if(0!=nativeWindowHandle) { - if(0 != ( FLAG_CHANGE_FULLSCREEN & flags)) { - final boolean fs = 0 != ( FLAG_IS_FULLSCREEN & flags) ; - setFullScreen0(nativeWindowHandle, fs); - if(fs) { - return true; - } - } - // int _x=(x>=0)?x:this.x; - // int _y=(x>=0)?y:this.y; - width=(width>0)?width:getWidth(); - height=(height>0)?height:getHeight(); - if(width>0 || height>0) { - setSize0(nativeWindowHandle, width, height); - } - if(x>=0 || y>=0) { - System.err.println("setPosition n/a in KD"); - } - } - - if( 0 != ( FLAG_CHANGE_VISIBILITY & flags) ) { - visibleChanged(false, 0 != ( FLAG_IS_VISIBLE & flags)); - } - + reconfigure0(nativeWindowHandle, x, y, width, height, flags); return true; } @@ -196,13 +198,17 @@ public class WindowDriver extends WindowImpl { private final LinuxEventDeviceTracker linuxEventDeviceTracker; protected static native boolean initIDs(); - private native long CreateWindow0(long bcmDisplay, int x, int y, int width, int height, boolean opaque, int alphaBits); + private native long CreateWindow0(long bcmDisplay, int layer, int x, int y, int width, int height, boolean opaque, int alphaBits); private native void CloseWindow0(long bcmDisplay, long eglWindowHandle); - private native void setVisible0(long eglWindowHandle, boolean visible); - private native void setPos0(long eglWindowHandle, int x, int y); - private native void setSize0(long eglWindowHandle, int width, int height); - private native void setFullScreen0(long eglWindowHandle, boolean fullscreen); + private native void reconfigure0(long eglWindowHandle, int x, int y, int width, int height, int flags); + private int layer; private long nativeWindowHandle; private long windowHandleClose; + + private static int nextLayer = 0; + private static int layerCount = 0; + private static final int MAX_LAYERS = 32; + private static final IntBitfield usedLayers = new IntBitfield(MAX_LAYERS); + private static final Object layerSync = new Object(); } diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c index ea225772f..3a802650a 100644 --- a/src/newt/native/bcm_vc_iv.c +++ b/src/newt/native/bcm_vc_iv.c @@ -347,7 +347,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID } JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow0 - (JNIEnv *env, jobject obj, jlong display, jint x, jint y, jint width, jint height, jboolean opaque, jint alphaBits) + (JNIEnv *env, jobject obj, jlong display, jint layer, jint x, jint y, jint width, jint height, jboolean opaque, jint alphaBits) { int32_t success = 0; VC_RECT_T dst_rect; @@ -356,13 +356,13 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin if( 0 == display ) { return; } - dst_rect.x = 0; - dst_rect.y = 0; + dst_rect.x = x; + dst_rect.y = y; dst_rect.width = width; dst_rect.height = height; - src_rect.x = x; - src_rect.y = y; + src_rect.x = 0; + src_rect.y = 0; src_rect.width = width << 16; src_rect.height = height << 16; @@ -381,22 +381,20 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin DISPMANX_DISPLAY_HANDLE_T dispman_display = (DISPMANX_DISPLAY_HANDLE_T) (intptr_t) display; - DBG_PRINT( "BCM.Display Window.Create.0 %p, %d/%d %dx%d, opaque %d, alphaBits %d\n", - (void*)(intptr_t)dispman_display, x, y, width, height, opaque, alphaBits); - - DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); - DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display, - 0/*layer*/, &dst_rect, 0/*src*/, - &src_rect, DISPMANX_PROTECTION_NONE, - &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); + DBG_PRINT( "BCM.Display Window.Create.0 %p, %d/%d %dx%d, opaque %d, alphaBits %d, layer %d\n", + (void*)(intptr_t)dispman_display, x, y, width, height, opaque, alphaBits, layer); BCM_ELEMENT_T * p = calloc(1, sizeof(BCM_ELEMENT_T)); - p->handle = dispman_element; - p->layer = 0; + DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 ); + p->layer = layer; p->x = x; p->y = y; p->width = width; p->height = height; + p->handle = vc_dispmanx_element_add ( dispman_update, dispman_display, + p->layer, &dst_rect, 0/*src*/, + &src_rect, DISPMANX_PROTECTION_NONE, + &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/); vc_dispmanx_update_submit_sync( dispman_update ); @@ -427,56 +425,36 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CloseWindo free( p ); } -/* - * Class: jogamp_newt_driver_bcm_vc_iv_WindowDriver - * Method: setVisible0 - * Signature: (JJZ)V - */ -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setVisible0 - (JNIEnv *env, jobject obj, jlong window, jboolean visible) -{ -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setFullScreen0 - (JNIEnv *env, jobject obj, jlong window, jboolean fullscreen) -{ -} - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setPos0 - (JNIEnv *env, jobject obj, jlong window, jint x, jint y) +JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_reconfigure0 + (JNIEnv *env, jobject obj, jlong window, jint x, jint y, jint width, jint height, jint flags) { BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; if( NULL == p || 0 == p->handle ) { return; } + /*** + int isVisible = !TST_FLAG_CHANGE_VISIBILITY(flags) && TST_FLAG_IS_VISIBLE(flags) ; + ... + see X11Window.c + */ + + int posChanged = p->x != x || p->y != y; + int sizeChanged = p->width != width || p->height != height; p->x = x; p->y = y; - - DBG_PRINT( "BCM.Display Window.Pos %p, element %p - %d/%d %dx%d\n", - p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); - - bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); - (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); -} - - -JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_setSize0 - (JNIEnv *env, jobject obj, jlong window, jint width, jint height) -{ - BCM_ELEMENT_T * p = (BCM_ELEMENT_T *) (intptr_t) window ; - - if( NULL == p || 0 == p->handle ) { - return; - } p->width = width; p->height = height; - DBG_PRINT( "BCM.Display Window.Resize %p, element %p - %d/%d %dx%d\n", + DBG_PRINT( "BCM.Display Window.Reconfig %p, element %p - %d/%d %dx%d\n", p, (void*)(intptr_t)p->handle, p->x, p->y, p->width, p->height); bcm_moveTo( p->handle, p->layer, p->x, p->y, p->width, p->height); - (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); + if( posChanged ) { + (*env)->CallVoidMethod(env, obj, positionChangedID, JNI_FALSE, x, y); + } + if( sizeChanged ) { + (*env)->CallVoidMethod(env, obj, sizeChangedID, JNI_FALSE, (jint) width, (jint) height, JNI_FALSE); + } } - -- cgit v1.2.3 From 42d3b31d1becd8eb8e2847c87e14e47e15e730cd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 9 Jan 2014 22:08:10 +0100 Subject: Fix PNGTstFiles: Typo of new PNG icons .. used AE's 'gray' instead of BE's 'grey', which is used for the filename --- make/scripts/tests.sh | 4 ++-- .../jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java | 8 ++++---- .../test/junit/jogl/util/texture/TestPNGPixelRect00NEWT.java | 4 +++- .../test/junit/jogl/util/texture/TestPNGPixelRect01NEWT.java | 9 +++++++++ 4 files changed, 18 insertions(+), 7 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 10cd3f17c..bf9eba958 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -325,7 +325,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -479,7 +479,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.newt.TestWindows01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestWindowClosingProtocol02NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows01NEWT $* -testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* +#testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows02NEWTAnimated $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindows03NEWTAnimResize $* #testnoawt com.jogamp.opengl.test.junit.newt.TestGLWindowInvisiblePointer01NEWT $* #testnoawt com.jogamp.opengl.test.junit.newt.TestDisplayLifecycle01NEWT diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java index e3ad7fc03..0d5d74a97 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/PNGTstFiles.java @@ -41,14 +41,14 @@ public class PNGTstFiles { "grayscale_texture", "bug724-transparent-grey_orig", "bug724-transparent-grey_gimpexp", - "cross-gray-alpha-16x16", - "pointer-gray-alpha-16x24", + "cross-grey-alpha-16x16", + "pointer-grey-alpha-16x24", }; static public final String[] greyBasenames = { "grayscale_texture", "bug724-transparent-grey_orig", "bug724-transparent-grey_gimpexp", - "cross-gray-alpha-16x16", - "pointer-gray-alpha-16x24", + "cross-grey-alpha-16x16", + "pointer-grey-alpha-16x24", }; } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect00NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect00NEWT.java index fc97c56fa..c2b39f0f3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect00NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect00NEWT.java @@ -129,7 +129,9 @@ public class TestPNGPixelRect00NEWT extends UITestCase { final File out2R_f=new File(getSimpleTestName(".")+"-03-"+basename+"-reversed.png"); final File out2RF_f=new File(getSimpleTestName(".")+"-04-"+basename+"-reversed_flipped.png"); URLConnection urlConn = IOUtil.getResource(this.getClass(), pathname+basename+".png"); - + if( null == urlConn ) { + throw new IOException("Cannot find "+pathname+basename+".png"); + } final PNGPixelRect image1 = PNGPixelRect.read(urlConn.getInputStream(), destFmt, false /* directBuffer */, destMinStrideInBytes, destIsGLOriented); System.err.println("PNGPixelRect - Orig: "+image1); { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect01NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect01NEWT.java index 0e92db48e..3b1d9fbb0 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect01NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/util/texture/TestPNGPixelRect01NEWT.java @@ -156,6 +156,9 @@ public class TestPNGPixelRect01NEWT extends UITestCase { return; } final URLConnection urlConn = IOUtil.getResource(this.getClass(), _fname); + if( null == urlConn ) { + throw new IOException("Cannot find "+_fname+".png"); + } testImpl(0, _fname, urlConn.getInputStream(), null); } @@ -167,6 +170,9 @@ public class TestPNGPixelRect01NEWT extends UITestCase { for(int i=0; i Date: Sun, 12 Jan 2014 07:27:55 +0100 Subject: Bug 937 - JAWTWindow: Unsatisfying Visibility Computation Simplify JAWTComponentListener's HierarchyListener: - Don't interfere w/ Component's visibility anymore! This shall reduce sideeffects. Utilize 'isShowing' in each Component specialization, i.e. GLCanvas. - On SHOWING_CHANGED if a parent caused a change of the tracked components showing state, propagate it to the offscreen-layer! - Remove all other complicated states! GLCanvas, GLJPanel: - Instead of 'isVisible()' use 'showing state', since only the 'showing state' reflects 'true' visibility throughout the hierarchy. - Add HierarchyListener and track volatile showing state to be used instead of 'isVisible'. Using a cached showing state is more efficient than quering 'isShowing()' all the time! NewtCanvasAWT: - Use 'isShowing()' instead of 'isVisible(), see above --- make/scripts/tests.sh | 50 +++++++++-- .../classes/javax/media/opengl/awt/GLCanvas.java | 30 ++++--- .../classes/javax/media/opengl/awt/GLJPanel.java | 20 ++++- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 78 +++++------------- .../classes/com/jogamp/newt/awt/NewtCanvasAWT.java | 4 +- .../TestAWTCardLayoutAnimatorStartStopBug532.java | 92 +++++++++++++-------- .../awt/TestBug664GLCanvasSetVisibleSwingAWT.java | 96 +++++++++++----------- ...estBug816JTabbedPanelVisibilityB849B878AWT.java | 47 +++++++---- .../awt/TestBug816OSXCALayerPos03aB729AWT.java | 6 +- .../awt/TestBug816OSXCALayerPos03bB849AWT.java | 6 +- .../awt/TestBug816OSXCALayerPos03cB849AWT.java | 6 +- 11 files changed, 249 insertions(+), 186 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index bf9eba958..b99f7866c 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -107,6 +107,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" + #D_ARGS="-Dnativewindow.debug.JAWT -Djogl.debug.GLCanvas" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" @@ -193,7 +194,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" - #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" + D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" @@ -325,7 +326,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -466,7 +467,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLWindow01NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT $* # @@ -500,15 +500,52 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # # AWT # -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* + +# +# OSX CALayer Position and Visibility (OSX CALayer, ..) +# +# + +# +# Simple GLCanvas setVisible on/off +# OK (X11, OSX) +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* + +# +# GLCanvas moving between CardLayout's JPanels +# OK (X11, OSX) +#testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 $* + +# +# GLCanvas moving between JTabbedPanel's tabs +# OK (X11, OSX) +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* + +# +# GLCanvas/AWT Checkbox Visibility +# OK (X11, OSX) #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT $* + +# +# GLCanvas/AWT Checkbox Visibility (on parent's Panel) +# OK (X11, OSX) #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT $* +# +# GLCanvas/Swing Checkbox Visibility (on parent's JPanel) +# OK (X11, OSX) #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* + +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT $* + +# +# OSX CALayer Position and Visibility (OSX CALayer, ..) +# +# + #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug675BeansInDesignTimeAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug551AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug572AWT $* @@ -519,7 +556,6 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestAWT02WindowClosing #testawt com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug664GLCanvasSetVisibleSwingAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.text.TestAWTTextRendererUseVertexArrayBug464 #testawt com.jogamp.opengl.test.junit.jogl.glu.TestBug463ScaleImageMemoryAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java index 0bc002f8e..7ea216dd9 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLCanvas.java @@ -52,6 +52,8 @@ import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Rectangle2D; import java.awt.EventQueue; @@ -173,6 +175,14 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing private final GraphicsDevice device; private boolean shallUseOffscreenLayer = false; + private volatile boolean isShowing; + private final HierarchyListener hierarchyListener = new HierarchyListener() { + @Override + public void hierarchyChanged(HierarchyEvent e) { + isShowing = GLCanvas.this.isShowing(); + } + }; + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override @@ -294,6 +304,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing helper.setSharedContext(null, shareWith); } this.device = device; + + this.addHierarchyListener(hierarchyListener); + this.isShowing = isShowing(); } @Override @@ -524,7 +537,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } return; // not yet available .. } - if( isVisible() && !printActive ) { + if( isShowing && !printActive ) { Threading.invoke(true, displayOnEDTAction, getTreeLock()); } } @@ -583,15 +596,6 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing } } - @Override - public void setVisible(boolean b) { - if(DEBUG) { - System.err.println(getThreadName()+": Info: setVisible("+b+")"); - Thread.dumpStack(); - } - super.setVisible(b); - } - /** Overridden to track when this component is added to a container. Subclasses which override this method must call super.addNotify() in their addNotify() method in order to @@ -814,9 +818,9 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing printActive = false; return; // not yet available .. } - if( !isVisible() ) { + if( !isShowing ) { if(DEBUG) { - System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable visible"); + System.err.println(getThreadName()+": Info: GLCanvas setupPrint - skipped GL render, drawable valid, canvas not showing"); } printActive = false; return; // not yet available .. @@ -1148,7 +1152,7 @@ public class GLCanvas extends Canvas implements AWTGLAutoDrawable, WindowClosing ",\n\thandle 0x"+Long.toHexString(getHandle())+ ",\n\tDrawable size "+dw+"x"+dh+ ",\n\tAWT pos "+getX()+"/"+getY()+", size "+getWidth()+"x"+getHeight()+ - ",\n\tvisible "+isVisible()+", displayable "+isDisplayable()+ + ",\n\tvisible "+isVisible()+", displayable "+isDisplayable()+", showing "+isShowing+ ",\n\t"+awtConfig+"]"; } diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index a71b47c64..f7200186b 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -48,6 +48,8 @@ import java.awt.Graphics2D; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; import java.awt.geom.NoninvertibleTransformException; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; @@ -265,6 +267,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return null == customPixelBufferProvider && useJava2DGLPipeline && java2DGLPipelineOK; } + private volatile boolean isShowing; + private final HierarchyListener hierarchyListener = new HierarchyListener() { + @Override + public void hierarchyChanged(HierarchyEvent e) { + isShowing = GLJPanel.this.isShowing(); + } + }; + private final AWTWindowClosingProtocol awtWindowClosingProtocol = new AWTWindowClosingProtocol(this, new Runnable() { @Override @@ -346,6 +356,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing helper.setSharedContext(null, shareWith); } this.setFocusable(true); // allow keyboard input! + this.addHierarchyListener(hierarchyListener); + this.isShowing = isShowing(); } /** @@ -418,7 +430,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void display() { - if( isVisible() ) { + if( isShowing ) { if (EventQueue.isDispatchThread()) { // Want display() to be synchronous, so call paintImmediately() paintImmediately(0, 0, getWidth(), getHeight()); @@ -521,7 +533,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing sendReshape = handleReshape(); } - if( isVisible() ) { + if( isShowing ) { updater.setGraphics(g); backend.doPaintComponent(g); } @@ -608,9 +620,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing printActive = false; return; // not yet available .. } - if( !isVisible() ) { + if( !isShowing ) { if(DEBUG) { - System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable visible"); + System.err.println(getThreadName()+": Info: GLJPanel setupPrint - skipped GL render, drawable valid, panel not showing"); } printActive = false; return; // not yet available .. diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index ed25a497f..4b0ae5d20 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -125,9 +125,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, private String jawtStr() { return "JAWTWindow["+id(JAWTWindow.this)+"]"; } private class JAWTComponentListener implements ComponentListener, HierarchyListener { - private boolean localVisibility = component.isVisible(); - private boolean globalVisibility = localVisibility; - private boolean visibilityPropagation = false; + private boolean isShowing; private String str(Object obj) { if( null == obj ) { @@ -141,14 +139,14 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } } private String s(ComponentEvent e) { - return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"],"+Platform.getNewline()+ + return "visible[isShowing "+isShowing+"],"+Platform.getNewline()+ " ** COMP "+str(e.getComponent())+Platform.getNewline()+ " ** SOURCE "+str(e.getSource())+Platform.getNewline()+ " ** THIS "+str(component)+Platform.getNewline()+ " ** THREAD "+getThreadName(); } private String s(HierarchyEvent e) { - return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"], changeBits 0x"+Long.toHexString(e.getChangeFlags())+Platform.getNewline()+ + return "visible[isShowing "+isShowing+"], changeBits 0x"+Long.toHexString(e.getChangeFlags())+Platform.getNewline()+ " ** COMP "+str(e.getComponent())+Platform.getNewline()+ " ** SOURCE "+str(e.getSource())+Platform.getNewline()+ " ** CHANGED "+str(e.getChanged())+Platform.getNewline()+ @@ -158,12 +156,13 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } @Override public final String toString() { - return "visible[local "+localVisibility+", global "+globalVisibility+", propag. "+visibilityPropagation+"],"+Platform.getNewline()+ + return "visible[isShowing "+isShowing+"],"+Platform.getNewline()+ " ** THIS "+str(component)+Platform.getNewline()+ " ** THREAD "+getThreadName(); } private JAWTComponentListener() { + isShowing = component.isShowing(); if(DEBUG) { System.err.println(jawtStr()+".attach @ Thread "+getThreadName()+": "+toString()); } @@ -177,7 +176,6 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, } component.removeComponentListener(this); component.removeHierarchyListener(this); - component.setVisible(localVisibility); // restore component's original local state } @Override @@ -185,7 +183,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println(jawtStr()+".componentResized: "+s(e)); } - layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); + layoutSurfaceLayerIfEnabled(isShowing); } @Override @@ -193,7 +191,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println(jawtStr()+".componentMoved: "+s(e)); } - layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); + layoutSurfaceLayerIfEnabled(isShowing); } @Override @@ -201,7 +199,7 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println(jawtStr()+".componentShown: "+s(e)); } - layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); + layoutSurfaceLayerIfEnabled(isShowing); } @Override @@ -209,59 +207,27 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if(DEBUG) { System.err.println(jawtStr()+".componentHidden: "+s(e)); } - layoutSurfaceLayerIfEnabled(globalVisibility && localVisibility); + layoutSurfaceLayerIfEnabled(isShowing); } @Override public final void hierarchyChanged(HierarchyEvent e) { - final long bits = e.getChangeFlags(); - final java.awt.Component changed = e.getChanged(); - final boolean compIsVisible = component.isVisible(); - if( 0 != ( java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED & bits ) ) { - final boolean displayable = changed.isDisplayable(); - final boolean propagateDisplayability = changed == component && ( displayable && localVisibility ) != compIsVisible; - final boolean visible = displayable && localVisibility; - final boolean propagateDisplayability = changed == component && visible != compIsVisible; - if( propagateDisplayability ) { - // Propagate parent's displayability, i.e. 'removeNotify()' and 'addNotify()' - visibilityPropagation = true; - globalVisibility = displayable; - if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged DISPLAYABILITY_CHANGED (1): displayable "+displayable+" -> visible "+visible+", "+s(e)); - } - component.setVisible(visible); - } else if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged DISPLAYABILITY_CHANGED (x): displayable "+displayable+", "+s(e)); + final boolean wasAWTCompShowing = isShowing; + isShowing = component.isShowing(); + int action = 0; + if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & e.getChangeFlags() ) ) { + if( e.getChanged() != component && wasAWTCompShowing != isShowing ) { + // A parent component changed and caused a 'showing' state change, + // propagate to offscreen-layer! + layoutSurfaceLayerIfEnabled(isShowing); + action = 1; } - } else if( 0 != ( java.awt.event.HierarchyEvent.SHOWING_CHANGED & bits ) ) { - final boolean showing = changed.isShowing(); - final boolean visible = showing && localVisibility; - final boolean propagateVisibility = changed != component && visible != compIsVisible; - if( propagateVisibility ) { - // Propagate parent's visibility - visibilityPropagation = true; - globalVisibility = showing; - if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (1): showing "+showing+" -> visible "+visible+", "+s(e)); - } - component.setVisible(visible); - } else if( changed == component ) { - // Update component's local visibility state - if(!visibilityPropagation) { - localVisibility = compIsVisible; - } - visibilityPropagation = false; - if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (0): showing "+showing+" -> visible "+visible+", "+s(e)); - } - } else if(DEBUG) { - System.err.println(jawtStr()+".hierarchyChanged SHOWING_CHANGED (x): showing "+showing+" -> visible "+visible+", "+s(e)); - } - } else if(DEBUG) { + } + if(DEBUG) { + final java.awt.Component changed = e.getChanged(); final boolean displayable = changed.isDisplayable(); - final boolean _visible = displayable && localVisibility; final boolean showing = changed.isShowing(); - System.err.println(jawtStr()+".hierarchyChanged OTHER: displayable "+displayable+", showing "+showing+" -> visible "+_visible+", "+s(e)); + System.err.println(jawtStr()+".hierarchyChanged: action "+action+", displayable "+displayable+", showing [changed "+showing+", comp "+isShowing+"], "+s(e)); } } } diff --git a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java index 00c3f1eb7..1ed628435 100644 --- a/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java +++ b/src/newt/classes/com/jogamp/newt/awt/NewtCanvasAWT.java @@ -621,9 +621,9 @@ public class NewtCanvasAWT extends java.awt.Canvas implements WindowClosingProto printActive = false; return; // not yet available .. } - if( !isVisible() ) { + if( !isShowing() ) { if(DEBUG) { - System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable visible"); + System.err.println(currentThreadName()+": Info: NewtCanvasAWT setupPrint - skipped GL render, drawable valid, canvas not showing"); } printActive = false; return; // not yet available .. diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java index 7f861d89b..3790a87f7 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/anim/TestAWTCardLayoutAnimatorStartStopBug532.java @@ -2,6 +2,7 @@ package com.jogamp.opengl.test.junit.jogl.acore.anim; import java.awt.BorderLayout; import java.awt.CardLayout; +import java.awt.Component; import java.awt.Dimension; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; @@ -30,55 +31,60 @@ import com.jogamp.opengl.util.FPSAnimator; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { - static final String LABEL = "Label"; + static final String LABEL = "Label"; static final String CANVAS = "GLCanvas"; - + public enum AnimatorControlBehavior { StartStop, PauseResume, Continue; } - - static long durationPerTest = 200*4; // ms + + static long durationPerTest = 200*4; // ms static boolean manual = false; static volatile boolean shouldStop = false; - + private String selected = LABEL; - + @Test public void testFPSAnimatorStartStop() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.StartStop, true); } - + @Test public void testFPSAnimatorResumePause() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.PauseResume, true); } - + @Test public void testFPSAnimatorContinue() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.Continue, true); } - + @Test public void testAnimatorStartStop() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.StartStop, false); } - + @Test public void testAnimatorResumePause() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.PauseResume, false); } - + @Test public void testAnimatorContinue() throws InterruptedException, InvocationTargetException { testImpl(AnimatorControlBehavior.Continue, false); } - + + private static String id(Object obj) { return "0x" + ( null!=obj ? Integer.toHexString(obj.hashCode()) : "nil" ); } + private static String str(Component c) { + return id(c)+": "+c.getClass().getSimpleName()+"[visible "+c.isVisible()+", showing "+c.isShowing()+", valid "+c.isValid()+ + ", displayable "+c.isDisplayable()+", "+c.getX()+"/"+c.getY()+" "+c.getWidth()+"x"+c.getHeight()+"]"; + } void testImpl(final AnimatorControlBehavior animCtrl, boolean useFPSAnimator) throws InterruptedException, InvocationTargetException { - final GLProfile glp = GLProfile.get(GLProfile.GL2); - final GLCapabilities caps = new GLCapabilities(glp); - final GLCanvas canvas = new GLCanvas(caps); + final GLProfile glp = GLProfile.get(GLProfile.GL2); + final GLCapabilities caps = new GLCapabilities(glp); + final GLCanvas canvas = new GLCanvas(caps); canvas.setPreferredSize(new Dimension(640, 480)); - + final GLAnimatorControl animatorCtrl = useFPSAnimator ? new FPSAnimator(canvas, 60) : new Animator(canvas); animatorCtrl.setUpdateFPSFrames(60, null);// System.err); switch (animCtrl) { @@ -95,7 +101,7 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { canvas.addGLEventListener(new GearsES2(1)); /* if(Platform.OS_TYPE == Platform.OSType.WINDOWS) { canvas.addGLEventListener(new GLEventListener() { - public void init(GLAutoDrawable drawable) { } + public void init(GLAutoDrawable drawable) { } public void dispose(GLAutoDrawable drawable) { } public void display(GLAutoDrawable drawable) { final NativeWindow win = (NativeWindow) drawable.getNativeSurface(); @@ -112,15 +118,17 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { final JFrame frame = new JFrame(); frame.setTitle(getSimpleTestName(" - ")); - frame.addWindowListener(new WindowAdapter() { + frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { animatorCtrl.stop(); shouldStop = true; - } + } }); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - - final JPanel cards = new JPanel(new CardLayout()); + + final JLabel label = new JLabel("A label to cover the canvas"); + + final JPanel cards = new JPanel(new CardLayout()); final JPanel comboBoxPanel = new JPanel(); // nicer look .. final JComboBox comboBox = new JComboBox(new String[] { LABEL, CANVAS }); comboBox.setEditable(false); @@ -131,7 +139,13 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { if(!newSelection.equals(selected)) { final String oldSelected = selected; if(newSelection.equals(CANVAS)) { - cl.show(cards, CANVAS); + System.err.println("XXX Card.SHOW Canvas PRE: "); + System.err.println(" CANVAS "+str(canvas)); + System.err.println(" LABEL "+str(label)); + cl.show(cards, CANVAS); + System.err.println("XXX Card.SHOW Canvas POST: "); + System.err.println(" CANVAS "+str(canvas)); + System.err.println(" LABEL "+str(label)); switch (animCtrl) { case StartStop: animatorCtrl.start(); @@ -152,31 +166,37 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { break; default: } - cl.show(cards, LABEL); + System.err.println("XXX Card.SHOW Label PRE: "); + System.err.println(" CANVAS "+str(canvas)); + System.err.println(" LABEL "+str(label)); + cl.show(cards, LABEL); + System.err.println("XXX Card.SHOW Label POST: "); + System.err.println(" CANVAS "+str(canvas)); + System.err.println(" LABEL "+str(label)); selected = LABEL; } else { throw new RuntimeException("oops .. unexpected item: "+evt); } - System.err.println("Item Change: "+oldSelected+" -> "+selected+", "+animatorCtrl); + System.err.println("Item Change: "+oldSelected+" -> "+selected+", "+animatorCtrl); } else { System.err.println("Item Stays: "+selected+", "+animatorCtrl); } } }); - comboBoxPanel.add(comboBox); + comboBoxPanel.add(comboBox); - cards.add(new JLabel("A label to cover the canvas"), LABEL); + cards.add(label, LABEL); cards.add(canvas, CANVAS); - + frame.add(comboBoxPanel, BorderLayout.PAGE_START); frame.add(cards, BorderLayout.CENTER); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - frame.pack(); + frame.pack(); frame.setVisible(true); }}); - + if(manual) { for(long w=durationPerTest; !shouldStop && w>0; w-=100) { Thread.sleep(100); @@ -187,34 +207,34 @@ public class TestAWTCardLayoutAnimatorStartStopBug532 extends UITestCase { comboBox.setSelectedItem(LABEL); }}); Thread.sleep(durationPerTest/4); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { comboBox.setSelectedItem(CANVAS); }}); Thread.sleep(durationPerTest/4); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { comboBox.setSelectedItem(LABEL); }}); Thread.sleep(durationPerTest/4); - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { comboBox.setSelectedItem(CANVAS); }}); Thread.sleep(durationPerTest/4); } - + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.setVisible(false); frame.dispose(); }}); - + } - + public static void main(String args[]) { for(int i=0; i= frameCountT1 - frameCountT0); - + + System.err.println("XXXX Visible Part 3/3"); setComponentVisible(glc, true); Assert.assertTrue("Component didn't become visible", AWTRobotUtil.waitForVisible(glc, true)); anim.resetFPSCounter(); - System.err.println("Visible Part 3/3"); - + while( anim.getTotalFPSDuration() < durationPerTest ) { Thread.sleep(60); } - + System.err.println("GLCanvas isOffscreenLayerSurfaceEnabled: "+glc.isOffscreenLayerSurfaceEnabled()+": "+glc.getChosenGLCapabilities()); - - dispose(top[0]); + + dispose(top[0]); } } @@ -258,7 +258,7 @@ public class TestBug664GLCanvasSetVisibleSwingAWT extends UITestCase { } runTestGL(false, caps); } - + public static void main(String args[]) throws IOException { for(int i=0; i Panel1("+id(panel1)+") START"); dumpGLCanvasStats(glCanvas); panel1.add(glCanvas, BorderLayout.CENTER); dumpGLCanvasStats(glCanvas); - } else { + } else if (tabbedPanel.getSelectedIndex() == 1) { System.err.println("XXXX Add GLCanvas Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); dumpGLCanvasStats(glCanvas); panel2.add(glCanvas, BorderLayout.CENTER); dumpGLCanvasStats(glCanvas); + } else { + System.err.println("XXXX NOP"); + dumpGLCanvasStats(glCanvas); } } }); @@ -119,33 +127,44 @@ public class TestBug816JTabbedPanelVisibilityB849B878AWT extends UITestCase { Thread.sleep(100); } } else { + Thread.sleep(durationPerTest/6); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.err.println("XXXX Add GLCanvas Panel2("+id(panel2)+") -> Panel1("+id(panel1)+" START"); - tabbedPanel.setSelectedIndex(0); + System.err.println("XXXX Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); + tabbedPanel.setSelectedIndex(1); }}); - Thread.sleep(durationPerTest/4); + Thread.sleep(durationPerTest/6); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.err.println("XXXX Add GLCanvas Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); - tabbedPanel.setSelectedIndex(1); + System.err.println("XXXX Panel2("+id(panel2)+") -> Panel3("+id(panel3)+" START"); + tabbedPanel.setSelectedIndex(2); }}); - Thread.sleep(durationPerTest/4); + Thread.sleep(durationPerTest/6); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.err.println("XXXX Add GLCanvas Panel2("+id(panel2)+") -> Panel1("+id(panel1)+" START"); + System.err.println("XXXX Panel3("+id(panel3)+") -> Panel1("+id(panel1)+" START"); tabbedPanel.setSelectedIndex(0); }}); - Thread.sleep(durationPerTest/4); + // one loop done + + Thread.sleep(durationPerTest/6); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { - System.err.println("XXXX Add GLCanvas Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); + System.err.println("XXXX Panel1("+id(panel1)+" -> Panel2("+id(panel2)+") START"); tabbedPanel.setSelectedIndex(1); }}); - Thread.sleep(durationPerTest/4); + + Thread.sleep(durationPerTest/6); + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + System.err.println("XXXX Panel2("+id(panel2)+") -> Panel1("+id(panel1)+" START"); + tabbedPanel.setSelectedIndex(0); + }}); + + Thread.sleep(durationPerTest/6); } SwingUtilities.invokeLater(new Runnable() { diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java index e1a0944e1..29dc9a190 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03aB729AWT.java @@ -95,8 +95,10 @@ public class TestBug816OSXCALayerPos03aB729AWT extends UITestCase { final Checkbox checkbox = new Checkbox("Visible canvas", true); checkbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { - glCanvas1.setVisible(checkbox.getState()); - System.out.println("Canvas visible: "+glCanvas1.isVisible()); + final boolean visible = checkbox.getState(); + System.err.println("XXXX Canvas setVisible "+visible); + glCanvas1.setVisible(visible); + System.err.println("XXXX Canvas visible: "+glCanvas1.isVisible()); if( glCanvas1.isVisible() ) { frame.validate(); // take care of resized frame while hidden } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java index b9ee6a4f6..3e60c8b47 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03bB849AWT.java @@ -101,8 +101,10 @@ public class TestBug816OSXCALayerPos03bB849AWT extends UITestCase { final Checkbox checkbox = new Checkbox("Visible canvas", true); checkbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { - panel.setVisible(checkbox.getState()); - System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); + final boolean visible = checkbox.getState(); + System.err.println("XXXX Panel setVisible "+visible); + panel.setVisible(visible); + System.err.println("XXXX Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); if( panel.isVisible() ) { frame.validate(); // take care of resized frame while hidden } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java index 9a536d50c..24f9de961 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos03cB849AWT.java @@ -103,8 +103,10 @@ public class TestBug816OSXCALayerPos03cB849AWT extends UITestCase { final JCheckBox checkbox = new JCheckBox("Visible canvas", true); checkbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { - panel.setVisible(checkbox.getSelectedObjects()!=null); - System.out.println("Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); + final boolean visible = checkbox.getSelectedObjects()!=null; + System.err.println("XXXX Panel setVisible "+visible); + panel.setVisible(visible); + System.err.println("XXXX Visible: [panel "+panel.isVisible()+", canvas "+glCanvas1.isVisible()+"]; Displayable: [panel "+panel.isDisplayable()+", canvas "+glCanvas1.isDisplayable()+"]"); if( panel.isVisible() ) { frame.validate(); // take care of resized frame while hidden } -- cgit v1.2.3 From 41be8824318d709459c08669218696d196719c90 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 13 Jan 2014 19:31:18 +0100 Subject: TestParenting01dAWT: Add waitForVisible after toggling NEWT child window visibility helping robostness of test case. --- make/scripts/tests.sh | 6 +++--- .../opengl/test/junit/newt/parenting/TestParenting01dAWT.java | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index b99f7866c..ed8b8b395 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -194,7 +194,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.EDT" #D_ARGS="-Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.GLContext" #D_ARGS="-Dnewt.debug.Window -Djogl.debug.Animator -Dnewt.debug.Screen" - D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" + #D_ARGS="-Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Window.KeyEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent" #D_ARGS="-Dnewt.debug.Window.MouseEvent -Dnewt.debug.Window.KeyEvent" @@ -519,7 +519,7 @@ function testawtswt() { # # GLCanvas moving between JTabbedPanel's tabs # OK (X11, OSX) -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT $* # # GLCanvas/AWT Checkbox Visibility @@ -644,7 +644,7 @@ testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB8 #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $* -#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $* +testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01dAWT.java b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01dAWT.java index 00b32ac35..288918e48 100644 --- a/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01dAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/newt/parenting/TestParenting01dAWT.java @@ -145,8 +145,8 @@ public class TestParenting01dAWT extends UITestCase { }); Assert.assertEquals(newtCanvasAWT.getNativeWindow(),glWindow1.getParent()); - Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow1, true)); Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow1, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow1, true)); glWindow1.display(); Assert.assertEquals("Init Counter Invalid "+glelCounter, 1, glelCounter.initCount); Assert.assertEquals("Dispose Counter Invalid "+glelCounter, 0, glelCounter.disposeCount); @@ -172,11 +172,14 @@ public class TestParenting01dAWT extends UITestCase { // GL state shall be preserved! // glWindow1.setVisible(false); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow1, false)); System.err.println(getSimpleTestName(".")+": Start Reparent #2"); final Window.ReparentOperation rop2 = glWindow1.reparentWindow(newtCanvasAWT.getNativeWindow(), -1, -1, reparentingHints); System.err.println(getSimpleTestName(".")+": Result Reparent #2: "+rop2); Assert.assertEquals(Window.ReparentOperation.ACTION_NATIVE_CREATION, rop2); glWindow1.setVisible(true); + Assert.assertTrue(AWTRobotUtil.waitForVisible(glWindow1, true)); + Assert.assertTrue(AWTRobotUtil.waitForRealized(glWindow1, true)); glWindow1.display(); if( triggerPreserveGLState ) { Assert.assertEquals("Init Counter Invalid (Preserve Failed 2) "+glelCounter, 1, glelCounter.initCount); -- cgit v1.2.3 From 6c971f91fbe6a7e3bc45563d80d42a753586d629 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 14 Jan 2014 05:22:15 +0100 Subject: Bug 938 - MemoryObject.java has no more equals() method Re-adding 'equals(..)' method erroneously removed with commit 8457bf35fee253d9af29ff1150a9671f6896fc17. 'equals(..)' is important to allow the HashMap<> for glMapBuffer(..) work properly! --- make/scripts/tests.sh | 4 ++-- src/jogl/classes/jogamp/opengl/MemoryObject.java | 28 +++++++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ed8b8b395..3c79e3209 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -389,7 +389,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAONEWT $* @@ -644,7 +644,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $* -testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $* +#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $* #testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $* diff --git a/src/jogl/classes/jogamp/opengl/MemoryObject.java b/src/jogl/classes/jogamp/opengl/MemoryObject.java index d10747690..ac02e0bca 100644 --- a/src/jogl/classes/jogamp/opengl/MemoryObject.java +++ b/src/jogl/classes/jogamp/opengl/MemoryObject.java @@ -37,9 +37,9 @@ import com.jogamp.common.util.HashUtil; * */ public class MemoryObject { - private long addr; - private long size; - private int hash; + private final long addr; + private final long size; + private final int hash; private ByteBuffer buffer=null; public MemoryObject(long addr, long size) { @@ -69,18 +69,34 @@ public class MemoryObject { return "MemoryObject[addr 0x"+Long.toHexString(addr)+", size 0x"+Long.toHexString(size)+", hash32: 0x"+Integer.toHexString(hash)+"]"; } + /** + * Ignores the optional attached ByteBuffer intentionally.
        + * + * @return true of reference is equal or obj is of type MemoryObject + * and addr and size is equal.
        + */ + public boolean equals(Object obj) { + if(this == obj) { return true; } + if(obj instanceof MemoryObject) { + final MemoryObject m = (MemoryObject) obj; + return addr == m.addr && size == m.size ; + } + return false; + } + /** * @param map the identity HashMap, MemoryObject to MemoryObject * @param obj0 the MemoryObject * @return either the already mapped MemoryObject - not changing the map, or the newly mapped one. */ public static MemoryObject getOrAddSafe(HashMap map, MemoryObject obj0) { - MemoryObject obj1 = map.get(obj0); // get identity (fast) + final MemoryObject obj1 = map.get(obj0); // get identity (fast) if(null == obj1) { map.put(obj0, obj0); - obj1 = obj0; + return obj0; + } else { + return obj1; } - return obj1; } } \ No newline at end of file -- cgit v1.2.3 From 961930f9e2cd40dc4de736201bcfa68c1ff09909 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 14 Jan 2014 19:18:52 +0100 Subject: JAWTWindow DEBUG: Dump all JAVA_VERSION* information --- make/scripts/tests.sh | 5 +-- .../com/jogamp/nativewindow/awt/JAWTWindow.java | 3 ++ .../jogl/awt/TestBug816OSXCALayerPos01AWT.java | 41 +++++++++------------- 3 files changed, 22 insertions(+), 27 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 3c79e3209..649256393 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -109,6 +109,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogl.debug.GLCanvas" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" + D_ARGS="-Dnativewindow.debug.JAWT" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" @@ -389,7 +390,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAONEWT $* @@ -535,7 +536,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* # OK (X11, OSX) #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* -#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java index 8765f58d0..a4dfe1c04 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/JAWTWindow.java @@ -730,6 +730,9 @@ public abstract class JAWTWindow implements NativeWindow, OffscreenLayerSurface, if( null == sb ) { sb = new StringBuilder(); } + sb.append("JVM version: ").append(Platform.JAVA_VERSION).append(" ("). + append(Platform.JAVA_VERSION_NUMBER). + append(" update ").append(Platform.JAVA_VERSION_UPDATE).append(")").append(Platform.getNewline()); if(null != jawt) { sb.append("JAWT version: 0x").append(Integer.toHexString(jawt.getCachedVersion())). append(", CA_LAYER: ").append(JAWTUtil.isJAWTUsingOffscreenLayer(jawt)). diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java index 5a7c5c9eb..ace578e7a 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestBug816OSXCALayerPos01AWT.java @@ -63,8 +63,6 @@ import java.lang.reflect.InvocationTargetException; import org.junit.Assert; import org.junit.Assume; -import org.junit.BeforeClass; -import org.junit.AfterClass; import org.junit.Test; import org.junit.FixMethodOrder; import org.junit.runners.MethodSorters; @@ -80,23 +78,12 @@ public class TestBug816OSXCALayerPos01AWT extends UITestCase { public enum FrameLayout { None, Flow, DoubleBorderCenterSurrounded, Box, Split }; static long duration = 1600; // ms - static int width, height; + static final int width = 640, height = 480; static boolean forceES2 = false; static boolean forceGL3 = false; static int swapInterval = 1; - static java.awt.Dimension rwsize; - - @BeforeClass - public static void initClass() { - width = 640; - height = 480; - rwsize = new Dimension(800, 600); - } - - @AfterClass - public static void releaseClass() { - } + static java.awt.Dimension rwsize = new Dimension(800, 600); static void setComponentSize(final Frame frame, final Component comp1, final java.awt.Dimension new_sz1, final Component comp2, final java.awt.Dimension new_sz2) { try { @@ -278,16 +265,18 @@ public class TestBug816OSXCALayerPos01AWT extends UITestCase { } Thread.sleep(Math.max(1000, duration/2)); - final Dimension compRSizeHalf = new Dimension(rwsize.width/2, rwsize.height); - final Dimension frameRSizeHalf = new Dimension(twoCanvas ? rwsize.width + 64: rwsize.width/2 + 64, rwsize.height + 64); - if( resizeByComp ) { - setComponentSize(frame, glCanvas1, compRSizeHalf, glCanvas2, compRSizeHalf); - } else { - setFrameSize(frame, true, frameRSizeHalf); - } - System.err.println("resize canvas1 pos/siz: "+glCanvas1.getX()+"/"+glCanvas1.getY()+" "+glCanvas1.getWidth()+"x"+glCanvas1.getHeight()); - if( twoCanvas ) { - System.err.println("resize canvas2 pos/siz: "+glCanvas2.getX()+"/"+glCanvas2.getY()+" "+glCanvas2.getWidth()+"x"+glCanvas2.getHeight()); + if( null != rwsize ) { + final Dimension compRSizeHalf = new Dimension(rwsize.width/2, rwsize.height); + final Dimension frameRSizeHalf = new Dimension(twoCanvas ? rwsize.width + 64: rwsize.width/2 + 64, rwsize.height + 64); + if( resizeByComp ) { + setComponentSize(frame, glCanvas1, compRSizeHalf, glCanvas2, compRSizeHalf); + } else { + setFrameSize(frame, true, frameRSizeHalf); + } + System.err.println("resize canvas1 pos/siz: "+glCanvas1.getX()+"/"+glCanvas1.getY()+" "+glCanvas1.getWidth()+"x"+glCanvas1.getHeight()); + if( twoCanvas ) { + System.err.println("resize canvas2 pos/siz: "+glCanvas2.getX()+"/"+glCanvas2.getY()+" "+glCanvas2.getWidth()+"x"+glCanvas2.getHeight()); + } } final long t0 = System.currentTimeMillis(); @@ -465,6 +454,8 @@ public class TestBug816OSXCALayerPos01AWT extends UITestCase { } else if(args[i].equals("-test")) { i++; testNum = MiscUtils.atoi(args[i], 0); + } else if(args[i].equals("-noresize")) { + rwsize = null; } else if(args[i].equals("-es2")) { forceES2 = true; } else if(args[i].equals("-gl3")) { -- cgit v1.2.3 From 09fc7aa5539731bb0fba835caee61f6eb837ecff Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 21 Jan 2014 18:16:22 +0100 Subject: Bug 942: GLBufferObjectTracker: Tracking GLBufferStorage accurately, synchronized and secure [1/2] GLBufferSizeTracker becomes GLBufferObjectTracker and tracks the buffer's data store, GLBufferStorage, accurately, synchronized and secure. Synchronization is required, since the GLBufferStorage can be shared across many GLContext on multiple threads. This requires all GLBufferStorage lifecycle affecting GL functions to utilize synchronized GLBufferObjectTracker methods while passing a native GL-func callback. These GL functions are: - glBufferData, glBufferStorage (GL 4.4), glNamedBufferDataEXT Creating the GLBufferStorage object - glMapBuffer, glMapBufferRange, and their *Named*EXT variants - glUnmapBuffer, glUnmapNamedBufferEXT 'glDeleteBuffers' can simply notify the GLBufferObjectTracker No more HashMap is required to associate the mapped buffer address to the mapped ByteBuffer. GLBufferObjectTracker simply utilizes a buffer-name (int) -> GLBufferStorage map. +++ The security aspect shall be implemented by validating all arguments whether they match the required GL constraints, as well as validating tracked states like 'size'. The following functions will throw an GLException accordingly: - glBufferData, glNamedBufferDataEXT * @throws GLException if size is less-than zero * @throws GLException if a native GL-Error occurs - glBufferStorage (GL 4.4) * @throws GLException if size is less-or-eqaul zero * @throws GLException if a native GL-Error occurs - glMapBuffer, and it's *Named*EXT variant * @throws GLException if buffer is not bound to target * @throws GLException if buffer is not tracked * @throws GLException if buffer is already mapped * @throws GLException if buffer has invalid store size, i.e. less-than zero - glMapBufferRange, and it's *Named*EXT variant * @throws GLException if buffer is not bound to target * @throws GLException if buffer is not tracked * @throws GLException if buffer is already mapped * @throws GLException if buffer has invalid store size, i.e. less-than zero * @throws GLException if buffer mapping range does not fit, incl. offset - glMapBufferRange, and it's *Named*EXT variant Only clear mapped buffer reference of GLBufferStorage if native unmap was successful. Further more special error handling shall be applied to: - glMapBuffer, and it's *Named*EXT variant, glMapBuffer, and it's *Named*EXT variant - A zero GLBufferStorage size will avoid a native call and returns null - A null native mapping result indicating an error will not cause a GLException but returns null This allows the user to handle this case. --- make/config/jogl/gl-common.cfg | 79 ++- make/config/jogl/gl-gl4bc.cfg | 47 +- make/config/jogl/gl-if-CustomJavaCode-es3.java | 4 + make/config/jogl/gl-if-gl2.cfg | 1 + make/config/jogl/gl-impl-CustomCCode-gl4bc.c | 91 +++- make/config/jogl/gl-impl-CustomCCode-gles1.c | 35 ++ make/config/jogl/gl-impl-CustomCCode-gles3.c | 36 ++ .../config/jogl/gl-impl-CustomJavaCode-common.java | 165 +++---- make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java | 238 +++++++-- make/config/jogl/gl-impl-CustomJavaCode-gles1.java | 59 ++- make/config/jogl/gl-impl-CustomJavaCode-gles3.java | 67 ++- make/scripts/tests.sh | 15 +- .../gluegen/opengl/BuildComposablePipeline.java | 19 +- src/jogl/classes/javax/media/opengl/GLBase.java | 85 +++- .../javax/media/opengl/GLBufferStorage.java | 150 ++++++ src/jogl/classes/javax/media/opengl/GLContext.java | 8 +- .../jogamp/opengl/GLBufferObjectTracker.java | 532 +++++++++++++++++++++ .../classes/jogamp/opengl/GLBufferSizeTracker.java | 209 -------- .../jogamp/opengl/GLBufferStateTracker.java | 135 ++++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 18 +- src/jogl/classes/jogamp/opengl/MemoryObject.java | 5 +- .../opengl/util/glsl/fixedfunc/FixedFuncHook.java | 24 +- 22 files changed, 1539 insertions(+), 483 deletions(-) create mode 100644 src/jogl/classes/javax/media/opengl/GLBufferStorage.java create mode 100644 src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java delete mode 100644 src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java (limited to 'make/scripts') diff --git a/make/config/jogl/gl-common.cfg b/make/config/jogl/gl-common.cfg index e9996c64b..74ead0498 100644 --- a/make/config/jogl/gl-common.cfg +++ b/make/config/jogl/gl-common.cfg @@ -56,12 +56,66 @@ Ignore glDebugMessageCallbackARB Ignore glDebugMessageCallbackKHR Ignore glDebugMessageCallback -# Manually implement glMapBuffer and glMapBufferRange as the size of the returned buffer -# can only be computed by calling another routine +# +# Manually implement following GL functions to be redirected +# to GLBufferObjectTracker. +# +ManuallyImplement glBufferData +ForceProcAddressGen glBufferData +MethodJavadoc glBufferData *

        +MethodJavadoc glBufferData * Throws a {@link GLException} if GL-function constraints are not met or the native GL-function fails. +MethodJavadoc glBufferData *

        +MethodJavadoc glBufferData *

        +MethodJavadoc glBufferData * @throws GLException if buffer is not bound to target +MethodJavadoc glBufferData * @throws GLException if size is less-than zero +MethodJavadoc glBufferData * @throws GLException if a native GL-Error occurs +MethodJavadoc glBufferData *

        + +# FIXME: Add for OpenGL 4.4 +#Ignore glBufferStorage +#ManuallyImplement glBufferStorage +#ForceProcAddressGen glBufferStorage +#MethodJavadoc glBufferStorage *

        +#MethodJavadoc glBufferStorage * Throws a {@link GLException} if GL-function constraints are not met or the native GL-function fails. +#MethodJavadoc glBufferStorage *

        +#MethodJavadoc glBufferStorage *

        +#MethodJavadoc glBufferStorage * @throws GLException if buffer is not bound to target +#MethodJavadoc glBufferStorage * @throws GLException if size is less-or-equal zero +#MethodJavadoc glBufferStorage * @throws GLException if a native GL-Error occurs +#MethodJavadoc glBufferStorage *

        + ManuallyImplement glMapBuffer ForceProcAddressGen glMapBuffer +MethodJavadoc glMapBuffer *

        +MethodJavadoc glMapBuffer * Throws a {@link GLException} if GL-function constraints are not met. +MethodJavadoc glMapBuffer *

        +MethodJavadoc glMapBuffer *

        +MethodJavadoc glMapBuffer * Returns {@link GL#mapBuffer(int, int)}'s {@link GLBufferStorage#getMappedBuffer()}. +MethodJavadoc glMapBuffer *

        +MethodJavadoc glMapBuffer * @throws GLException if buffer is not bound to target +MethodJavadoc glMapBuffer * @throws GLException if buffer is not tracked +MethodJavadoc glMapBuffer * @throws GLException if buffer is already mapped +MethodJavadoc glMapBuffer * @throws GLException if buffer has invalid store size, i.e. less-than zero +MethodJavadoc glMapBuffer *

        + ManuallyImplement glMapBufferRange ForceProcAddressGen glMapBufferRange +MethodJavadoc glMapBufferRange *

        +MethodJavadoc glMapBufferRange * Throws a {@link GLException} if GL-function constraints are not met. +MethodJavadoc glMapBufferRange *

        +MethodJavadoc glMapBufferRange *

        +MethodJavadoc glMapBufferRange * Returns {@link GL#mapBufferRange(int, long, long, int)}'s {@link GLBufferStorage#getMappedBuffer()}. +MethodJavadoc glMapBufferRange *

        +MethodJavadoc glMapBufferRange *

        +MethodJavadoc glMapBufferRange * @throws GLException if buffer is not bound to target +MethodJavadoc glMapBufferRange * @throws GLException if buffer is not tracked +MethodJavadoc glMapBufferRange * @throws GLException if buffer is already mapped +MethodJavadoc glMapBufferRange * @throws GLException if buffer has invalid store size, i.e. less-than zero +MethodJavadoc glMapBufferRange * @throws GLException if buffer mapping range does not fit, incl. offset +MethodJavadoc glMapBufferRange *

        + +ManuallyImplement glUnmapBuffer +ForceProcAddressGen glUnmapBuffer # Ignore the ATI_map_object_buffer extension for now unless someone # claims they need it, as it will undoubtedly require a similar @@ -550,15 +604,18 @@ JavaEpilogue glBindFramebuffer _context.setBoundFramebuffer(target, framebuffer # JavaPrologue glBegin inBeginEndPair = true; JavaEpilogue glEnd inBeginEndPair = false; -JavaEpilogue glBindBuffer bufferStateTracker.setBoundBufferObject({0}, {1}); -JavaEpilogue glBindBufferARB bufferStateTracker.setBoundBufferObject({0}, {1}); -JavaEpilogue glBindVertexArray bufferStateTracker.setBoundBufferObject(GL2GL3.GL_VERTEX_ARRAY_BINDING, {0}); -JavaEpilogue glPushClientAttrib bufferStateTracker.clearBufferObjectState(); -JavaEpilogue glPushClientAttrib glStateTracker.pushAttrib(mask); -JavaEpilogue glPopClientAttrib bufferStateTracker.clearBufferObjectState(); -JavaEpilogue glPopClientAttrib glStateTracker.popAttrib(); -JavaPrologue glBufferData synchronized(bufferSizeTracker) { -JavaEpilogue glBufferData bufferSizeTracker.setBufferSize(bufferStateTracker, {0}, this, {1}); } + +JavaEpilogue glBindBuffer bufferStateTracker.setBoundBufferObject({0}, {1}); +JavaEpilogue glBindBufferARB bufferStateTracker.setBoundBufferObject({0}, {1}); +JavaEpilogue glBindBufferBase bufferStateTracker.setBoundBufferObject({0}, {2}); +JavaEpilogue glBindBufferRange bufferStateTracker.setBoundBufferObject({0}, {2}); +JavaEpilogue glBindVertexArray bufferStateTracker.setBoundBufferObject(GL2GL3.GL_VERTEX_ARRAY_BINDING, {0}); +JavaEpilogue glPushClientAttrib bufferStateTracker.clear(); +JavaEpilogue glPushClientAttrib glStateTracker.pushAttrib(mask); +JavaEpilogue glPopClientAttrib bufferStateTracker.clear(); +JavaEpilogue glPopClientAttrib glStateTracker.popAttrib(); + +JavaPrologue glDeleteBuffers bufferObjectTracker.notifyBuffersDeleted({0}, {1}); BufferObjectKind Array glColorPointer BufferObjectKind Array glEdgeFlagPointer diff --git a/make/config/jogl/gl-gl4bc.cfg b/make/config/jogl/gl-gl4bc.cfg index 48ecb7378..6ccbace44 100644 --- a/make/config/jogl/gl-gl4bc.cfg +++ b/make/config/jogl/gl-gl4bc.cfg @@ -55,12 +55,51 @@ Include gl3-desktop.cfg Include gl3-common.cfg Include gl2_es2-CustomJavaCode.cfg -# Manually implement glMapNamedBufferEXT as the size of the returned buffer -# can only be computed by calling another routine +# +# Manually implement following GL functions to be redirected +# to GLBufferObjectTracker. +# +ManuallyImplement glNamedBufferDataEXT +ForceProcAddressGen glNamedBufferDataEXT +MethodJavadoc glNamedBufferDataEXT *

        +MethodJavadoc glNamedBufferDataEXT * Throws a {@link GLException} if GL-function constraints are not met or the native GL-function fails. +MethodJavadoc glNamedBufferDataEXT *

        +MethodJavadoc glNamedBufferDataEXT *

        +MethodJavadoc glNamedBufferDataEXT * @throws GLException if size is less-than zero +MethodJavadoc glNamedBufferDataEXT * @throws GLException if a native GL-Error occurs +MethodJavadoc glNamedBufferDataEXT *

        + ManuallyImplement glMapNamedBufferEXT ForceProcAddressGen glMapNamedBufferEXT -JavaPrologue glNamedBufferDataEXT synchronized(bufferSizeTracker) { -JavaEpilogue glNamedBufferDataEXT bufferSizeTracker.setDirectStateBufferSize({0}, this, {1}); } +MethodJavadoc glMapNamedBufferEXT *

        +MethodJavadoc glMapNamedBufferEXT * Throws a {@link GLException} if GL-function constraints are not met. +MethodJavadoc glMapNamedBufferEXT *

        +MethodJavadoc glMapNamedBufferEXT *

        +MethodJavadoc glMapNamedBufferEXT * Returns {@link GL2#mapNamedBuffer(int, int)}'s {@link GLBufferStorage#getMappedBuffer()}. +MethodJavadoc glMapNamedBufferEXT *

        +MethodJavadoc glMapNamedBufferEXT *

        +MethodJavadoc glMapNamedBufferEXT * @throws GLException if buffer is not tracked +MethodJavadoc glMapNamedBufferEXT * @throws GLException if buffer is already mapped +MethodJavadoc glMapNamedBufferEXT * @throws GLException if buffer has invalid store size, i.e. less-than zero +MethodJavadoc glMapNamedBufferEXT *

        + +ManuallyImplement glMapNamedBufferRangeEXT +ForceProcAddressGen glMapNamedBufferRangeEXT +MethodJavadoc glMapNamedBufferRangeEXT *

        +MethodJavadoc glMapNamedBufferRangeEXT * Throws a {@link GLException} if GL-function constraints are not met. +MethodJavadoc glMapNamedBufferRangeEXT *

        +MethodJavadoc glMapNamedBufferRangeEXT *

        +MethodJavadoc glMapNamedBufferRangeEXT * Returns {@link GL2#mapNamedBufferRange(int, long, long, int)}'s {@link GLBufferStorage#getMappedBuffer()}. +MethodJavadoc glMapNamedBufferRangeEXT *

        +MethodJavadoc glMapNamedBufferRangeEXT *

        +MethodJavadoc glMapNamedBufferRangeEXT * @throws GLException if buffer is not tracked +MethodJavadoc glMapNamedBufferRangeEXT * @throws GLException if buffer is already mapped +MethodJavadoc glMapNamedBufferRangeEXT * @throws GLException if buffer has invalid store size, i.e. less-than zero +MethodJavadoc glMapNamedBufferRangeEXT * @throws GLException if buffer mapping range does not fit, incl. offset +MethodJavadoc glMapNamedBufferRangeEXT *

        + +ManuallyImplement glUnmapNamedBufferEXT +ForceProcAddressGen glUnmapNamedBufferEXT # Manuall implement glDebugMessageCallback* using the proc address resolver ForceProcAddressGen glDebugMessageCallback diff --git a/make/config/jogl/gl-if-CustomJavaCode-es3.java b/make/config/jogl/gl-if-CustomJavaCode-es3.java index b68b5123a..3f976d514 100644 --- a/make/config/jogl/gl-if-CustomJavaCode-es3.java +++ b/make/config/jogl/gl-if-CustomJavaCode-es3.java @@ -8,7 +8,11 @@ public static final long GL_TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFFL ; /** Part of GL_ARB_shader_image_load_store */ public static final int GL_ALL_BARRIER_BITS = 0xFFFFFFFF ; +/** @deprecated Avoid original GL API namespace conflict. Use {@link #isPBOPackBound()} */ public boolean glIsPBOPackBound(); +public boolean isPBOPackBound(); +/** @deprecated Avoid original GL API namespace conflict. Use {@link #isPBOUnpackBound()} */ public boolean glIsPBOUnpackBound(); +public boolean isPBOUnpackBound(); diff --git a/make/config/jogl/gl-if-gl2.cfg b/make/config/jogl/gl-if-gl2.cfg index 37f7b6feb..0120bd674 100644 --- a/make/config/jogl/gl-if-gl2.cfg +++ b/make/config/jogl/gl-if-gl2.cfg @@ -26,6 +26,7 @@ Include gl-desktop.cfg Include gl-if-gl3-ignores.cfg Include gl-if-gl4-ignores.cfg +IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl2.java IncludeAs CustomJavaCode GL2 gl-if-CustomJavaCode-gl_compat.java IncludeAs CustomJavaCode GL2 gl2_es2-common-cpubufferJavaCode.java IncludeAs CustomJavaCode GL2 gl2-common-cpubufferJavaCode.java diff --git a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c index 4ddc27bf2..42e5700ab 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gl4bc.c +++ b/make/config/jogl/gl-impl-CustomCCode-gl4bc.c @@ -1,6 +1,77 @@ /* Java->C glue code: * Java package: jogamp.opengl.gl4.GL4bcImpl - * Java method: long dispatch_glMapBuffer(int target, int access) + * Java method: void dispatch_glBufferData(int target, long size, java.nio.Buffer data, int usage) + * C function: void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); + */ +JNIEXPORT void JNICALL +Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glBufferData(JNIEnv *env, jobject _unused, jint target, jlong size, jobject data, jint data_byte_offset, jboolean data_is_nio, jint usage, jlong procAddress) { + typedef void (APIENTRY*_local_PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); + _local_PFNGLBUFFERDATAPROC ptr_glBufferData; + GLvoid * _data_ptr = NULL; + if ( NULL != data ) { + _data_ptr = (GLvoid *) ( JNI_TRUE == data_is_nio ? (*env)->GetDirectBufferAddress(env, data) : (*env)->GetPrimitiveArrayCritical(env, data, NULL) ); } + ptr_glBufferData = (_local_PFNGLBUFFERDATAPROC) (intptr_t) procAddress; + assert(ptr_glBufferData != NULL); + (* ptr_glBufferData) ((GLenum) target, (GLsizeiptr) size, (GLvoid *) (((char *) _data_ptr) + data_byte_offset), (GLenum) usage); + if ( JNI_FALSE == data_is_nio && NULL != data ) { + (*env)->ReleasePrimitiveArrayCritical(env, data, _data_ptr, JNI_ABORT); } +} + +/** FIXME Add for OpenGL 4.4: glBufferStorage */ + +/* Java->C glue code: + * Java package: jogamp.opengl.gl4.GL4bcImpl + * Java method: void dispatch_glNamedBufferDataEXT(int buffer, long size, java.nio.Buffer data, int usage) + * C function: void glNamedBufferDataEXT(GLuint buffer, GLsizeiptr size, const GLvoid * data, GLenum usage); + */ +JNIEXPORT void JNICALL +Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glNamedBufferDataEXT(JNIEnv *env, jobject _unused, jint buffer, jlong size, jobject data, jint data_byte_offset, jboolean data_is_nio, jint usage, jlong procAddress) { + typedef void (APIENTRY*_local_PFNGLNAMEDBUFFERDATAEXTPROC)(GLuint buffer, GLsizeiptr size, const GLvoid * data, GLenum usage); + _local_PFNGLNAMEDBUFFERDATAEXTPROC ptr_glNamedBufferDataEXT; + GLvoid * _data_ptr = NULL; + if ( NULL != data ) { + _data_ptr = (GLvoid *) ( JNI_TRUE == data_is_nio ? (*env)->GetDirectBufferAddress(env, data) : (*env)->GetPrimitiveArrayCritical(env, data, NULL) ); } + ptr_glNamedBufferDataEXT = (_local_PFNGLNAMEDBUFFERDATAEXTPROC) (intptr_t) procAddress; + assert(ptr_glNamedBufferDataEXT != NULL); + (* ptr_glNamedBufferDataEXT) ((GLuint) buffer, (GLsizeiptr) size, (GLvoid *) (((char *) _data_ptr) + data_byte_offset), (GLenum) usage); + if ( JNI_FALSE == data_is_nio && NULL != data ) { + (*env)->ReleasePrimitiveArrayCritical(env, data, _data_ptr, JNI_ABORT); } +} + +/* Java->C glue code: + * Java package: jogamp.opengl.gl4.GL4bcImpl + * Java method: boolean dispatch_glUnmapBuffer(int target) + * C function: GLboolean glUnmapBuffer(GLenum target); + */ +JNIEXPORT jboolean JNICALL +Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glUnmapBuffer(JNIEnv *env, jobject _unused, jint target, jlong procAddress) { + typedef GLboolean (APIENTRY*_local_PFNGLUNMAPBUFFERPROC)(GLenum target); + _local_PFNGLUNMAPBUFFERPROC ptr_glUnmapBuffer; + GLboolean _res; + ptr_glUnmapBuffer = (_local_PFNGLUNMAPBUFFERPROC) (intptr_t) procAddress; + assert(ptr_glUnmapBuffer != NULL); + _res = (* ptr_glUnmapBuffer) ((GLenum) target); + return _res; +} + +/* Java->C glue code: + * Java package: jogamp.opengl.gl4.GL4bcImpl + * Java method: boolean dispatch_glUnmapNamedBufferEXT(int buffer) + * C function: GLboolean glUnmapNamedBufferEXT(GLuint buffer); + */ +JNIEXPORT jboolean JNICALL +Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glUnmapNamedBufferEXT(JNIEnv *env, jobject _unused, jint buffer, jlong procAddress) { + typedef GLboolean (APIENTRY*_local_PFNGLUNMAPNAMEDBUFFEREXTPROC)(GLuint buffer); + _local_PFNGLUNMAPNAMEDBUFFEREXTPROC ptr_glUnmapNamedBufferEXT; + GLboolean _res; + ptr_glUnmapNamedBufferEXT = (_local_PFNGLUNMAPNAMEDBUFFEREXTPROC) (intptr_t) procAddress; + assert(ptr_glUnmapNamedBufferEXT != NULL); + _res = (* ptr_glUnmapNamedBufferEXT) ((GLuint) buffer); + return _res; +} + +/* Java->C glue code: + * Java package: jogamp.opengl.gl4.GL4bcImpl * Java method: long dispatch_glMapBuffer(int target, int access) * C function: void * glMapBuffer(GLenum target, GLenum access); */ JNIEXPORT jlong JNICALL @@ -40,10 +111,26 @@ Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glMapNamedBufferEXT(JNIEnv *env, jobj void * _res; ptr_glMapNamedBufferEXT = (PFNGLMAPNAMEDBUFFEREXTPROC) (intptr_t) glProcAddress; assert(ptr_glMapNamedBufferEXT != NULL); - _res = (* ptr_glMapNamedBufferEXT) ((GLenum) target, (GLenum) access); + _res = (* ptr_glMapNamedBufferEXT) ((GLuint) target, (GLenum) access); + return (jlong) (intptr_t) _res; +} + +/* Java->C glue code: + * Java package: jogamp.opengl.gl4.GL4bcImpl + * Java method: java.nio.ByteBuffer dispatch_glMapNamedBufferRangeEXT(int buffer, long offset, long length, int access) + * C function: void * glMapNamedBufferRangeEXT(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); + */ +JNIEXPORT jlong JNICALL +Java_jogamp_opengl_gl4_GL4bcImpl_dispatch_1glMapNamedBufferRangeEXT(JNIEnv *env, jobject _unused, jint buffer, jlong offset, jlong length, jint access, jlong procAddress) { + PFNGLMAPNAMEDBUFFERRANGEEXTPROC ptr_glMapNamedBufferRangeEXT; + void * _res; + ptr_glMapNamedBufferRangeEXT = (PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (intptr_t) procAddress; + assert(ptr_glMapNamedBufferRangeEXT != NULL); + _res = (* ptr_glMapNamedBufferRangeEXT) ((GLuint) buffer, (GLintptr) offset, (GLsizeiptr) length, (GLbitfield) access); return (jlong) (intptr_t) _res; } + /* Java->C glue code: * Java package: jogamp.opengl.gl4.GL4bcImpl * Java method: ByteBuffer newDirectByteBuffer(long addr, long capacity); diff --git a/make/config/jogl/gl-impl-CustomCCode-gles1.c b/make/config/jogl/gl-impl-CustomCCode-gles1.c index 88cfe4418..83b8c7586 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gles1.c +++ b/make/config/jogl/gl-impl-CustomCCode-gles1.c @@ -1,3 +1,38 @@ +/* Java->C glue code: + * Java package: jogamp.opengl.es1.GLES1Impl + * Java method: void dispatch_glBufferData(int target, long size, java.nio.Buffer data, int usage) + * C function: void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); + */ +JNIEXPORT void JNICALL +Java_jogamp_opengl_es1_GLES1Impl_dispatch_1glBufferData(JNIEnv *env, jobject _unused, jint target, jlong size, jobject data, jint data_byte_offset, jboolean data_is_nio, jint usage, jlong procAddress) { + typedef void (GL_APIENTRY*_local_PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); + _local_PFNGLBUFFERDATAPROC ptr_glBufferData; + GLvoid * _data_ptr = NULL; + if ( NULL != data ) { + _data_ptr = (GLvoid *) ( JNI_TRUE == data_is_nio ? (*env)->GetDirectBufferAddress(env, data) : (*env)->GetPrimitiveArrayCritical(env, data, NULL) ); } + ptr_glBufferData = (_local_PFNGLBUFFERDATAPROC) (intptr_t) procAddress; + assert(ptr_glBufferData != NULL); + (* ptr_glBufferData) ((GLenum) target, (GLsizeiptr) size, (GLvoid *) (((char *) _data_ptr) + data_byte_offset), (GLenum) usage); + if ( JNI_FALSE == data_is_nio && NULL != data ) { + (*env)->ReleasePrimitiveArrayCritical(env, data, _data_ptr, JNI_ABORT); } +} + +/* Java->C glue code: + * Java package: jogamp.opengl.es1.GLES1Impl + * Java method: boolean dispatch_glUnmapBuffer(int target) + * C function: GLboolean glUnmapBufferOES(GLenum target); + */ +JNIEXPORT jboolean JNICALL +Java_jogamp_opengl_es1_GLES1Impl_dispatch_1glUnmapBuffer(JNIEnv *env, jobject _unused, jint target, jlong procAddress) { + typedef GLboolean (GL_APIENTRY*_local_PFNGLUNMAPBUFFEROESPROC)(GLenum target); + _local_PFNGLUNMAPBUFFEROESPROC ptr_glUnmapBufferOES; + GLboolean _res; + ptr_glUnmapBufferOES = (_local_PFNGLUNMAPBUFFEROESPROC) (intptr_t) procAddress; + assert(ptr_glUnmapBufferOES != NULL); + _res = (* ptr_glUnmapBufferOES) ((GLenum) target); + return _res; +} + typedef GLvoid* (GL_APIENTRY* PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); /* Java->C glue code: * Java package: jogamp.opengl.es1.GLES1Impl diff --git a/make/config/jogl/gl-impl-CustomCCode-gles3.c b/make/config/jogl/gl-impl-CustomCCode-gles3.c index 2f3329bfa..ff1d42e23 100644 --- a/make/config/jogl/gl-impl-CustomCCode-gles3.c +++ b/make/config/jogl/gl-impl-CustomCCode-gles3.c @@ -1,4 +1,40 @@ +/* Java->C glue code: + * Java package: jogamp.opengl.es3.GLES3Impl + * Java method: void dispatch_glBufferData(int target, long size, java.nio.Buffer data, int usage) + * C function: void glBufferData(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); + */ +JNIEXPORT void JNICALL +Java_jogamp_opengl_es3_GLES3Impl_dispatch_1glBufferData(JNIEnv *env, jobject _unused, jint target, jlong size, jobject data, jint data_byte_offset, jboolean data_is_nio, jint usage, jlong procAddress) { + typedef void (GL_APIENTRY*_local_PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage); + _local_PFNGLBUFFERDATAPROC ptr_glBufferData; + GLvoid * _data_ptr = NULL; + if ( NULL != data ) { + _data_ptr = (GLvoid *) ( JNI_TRUE == data_is_nio ? (*env)->GetDirectBufferAddress(env, data) : (*env)->GetPrimitiveArrayCritical(env, data, NULL) ); } + ptr_glBufferData = (_local_PFNGLBUFFERDATAPROC) (intptr_t) procAddress; + assert(ptr_glBufferData != NULL); + (* ptr_glBufferData) ((GLenum) target, (GLsizeiptr) size, (GLvoid *) (((char *) _data_ptr) + data_byte_offset), (GLenum) usage); + if ( JNI_FALSE == data_is_nio && NULL != data ) { + (*env)->ReleasePrimitiveArrayCritical(env, data, _data_ptr, JNI_ABORT); } +} + +/* Java->C glue code: + * Java package: jogamp.opengl.es3.GLES3Impl + * Java method: boolean dispatch_glUnmapBuffer(int target) + * C function: GLboolean glUnmapBuffer(GLenum target); + */ +JNIEXPORT jboolean JNICALL +Java_jogamp_opengl_es3_GLES3Impl_dispatch_1glUnmapBuffer(JNIEnv *env, jobject _unused, jint target, jlong procAddress) { + typedef GLboolean (GL_APIENTRY*_local_PFNGLUNMAPBUFFERPROC)(GLenum target); + _local_PFNGLUNMAPBUFFERPROC ptr_glUnmapBuffer; + GLboolean _res; + ptr_glUnmapBuffer = (_local_PFNGLUNMAPBUFFERPROC) (intptr_t) procAddress; + assert(ptr_glUnmapBuffer != NULL); + _res = (* ptr_glUnmapBuffer) ((GLenum) target); + return _res; +} + typedef GLvoid* (GL_APIENTRY* PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); + /* Java->C glue code: * Java package: jogamp.opengl.es3.GLES3Impl * Java method: long dispatch_glMapBuffer(int target, int access) diff --git a/make/config/jogl/gl-impl-CustomJavaCode-common.java b/make/config/jogl/gl-impl-CustomJavaCode-common.java index 4b1fc0977..f0246355e 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-common.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-common.java @@ -6,23 +6,37 @@ @Override public final int glGetBoundBuffer(int target) { + return getBoundBuffer(target); + } + @Override + public final int getBoundBuffer(int target) { return bufferStateTracker.getBoundBufferObject(target, this); } @Override - public final long glGetBufferSize(int buffer) { - synchronized(bufferSizeTracker) { - return bufferSizeTracker.getDirectStateBufferSize(buffer, this); - } + public final long glGetBufferSize(int bufferName) { + return bufferObjectTracker.getBufferSize(bufferName); + } + @Override + public final GLBufferStorage getBufferStorage(int bufferName) { + return bufferObjectTracker.getBufferStorage(bufferName); } @Override public final boolean glIsVBOArrayBound() { + return isVBOArrayBound(); + } + @Override + public final boolean isVBOArrayBound() { return checkArrayVBOBound(false); } @Override public final boolean glIsVBOElementArrayBound() { + return isVBOElementArrayBound(); + } + @Override + public final boolean isVBOElementArrayBound() { return checkElementVBOBound(false); } @@ -130,101 +144,60 @@ return _context.getDefaultReadBuffer(); } - private final HashMap arbMemCache = new HashMap(); - - /** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
        Part of GL_VERSION_1_5; GL_OES_mapbuffer */ - private final java.nio.ByteBuffer glMapBufferImpl(int target, boolean useRange, long offset, long length, int access, long glProcAddress) { - if (glProcAddress == 0) { - throw new GLException("Method \""+(useRange?"glMapBufferRange":"glMapBuffer")+"\" not available"); - } - final long addr, sz; - synchronized(bufferSizeTracker) { - sz = bufferSizeTracker.getBufferSize(bufferStateTracker, target, this); - if (0 == sz) { - return null; - } - if( !useRange ) { - length = sz; - offset = 0; - } else { - if( length + offset > sz ) { - throw new GLException("Out of range: offset "+offset+" + length "+length+" > size "+sz); - } - if( 0 > length || 0 > offset ) { - throw new GLException("Invalid values: offset "+offset+", length "+length); + private final GLStateTracker glStateTracker; + + // + // GLBufferObjectTracker Redirects + // + private final GLBufferObjectTracker bufferObjectTracker; + private final GLBufferStateTracker bufferStateTracker; + + private final jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch createBoundMutableStorageDispatch = + new jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch() { + public final void create(final int target, final long size, final Buffer data, final int mutableUsage, final long glProcAddress) { + final boolean data_is_direct = Buffers.isDirect(data); + dispatch_glBufferData(target, size, + data_is_direct ? data : Buffers.getArray(data), + data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data), + data_is_direct, mutableUsage, glProcAddress); } - if( 0 == length ) { - return null; + }; + private native void dispatch_glBufferData(int target, long size, Object data, int data_byte_offset, boolean data_is_direct, int usage, long procAddress); + + private final jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch unmapBoundBufferDispatch = + new jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch() { + public final boolean unmap(final int target, final long glProcAddress) { + return dispatch_glUnmapBuffer(target, glProcAddress); } - } - addr = useRange ? dispatch_glMapBufferRange(target, offset, length, access, glProcAddress) : - dispatch_glMapBuffer(target, access, glProcAddress); - } - if (0 == addr) { - return null; - } - final ByteBuffer buffer; - final MemoryObject memObj0 = new MemoryObject(addr, length); // object and key - final MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, length); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; + }; + private native boolean dispatch_glUnmapBuffer(int target, long procAddress); + + @Override + public final java.nio.ByteBuffer glMapBuffer(int target, int access) { + return mapBuffer(target, access).getMappedBuffer(); + } + + @Override + public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { + return mapBufferRange(target, offset, length, access).getMappedBuffer(); } + + private final jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch mapBoundBufferAllDispatch = + new jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch() { + public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); } + public final long mapBuffer(final int target, final int access, final long glProcAddress) { + return dispatch_glMapBuffer(target, access, glProcAddress); + } + }; private native long dispatch_glMapBuffer(int target, int access, long glProcAddress); - private native long dispatch_glMapBufferRange(int target, long offset, long length, int access, long procAddress); - - - /** Entry point to C language function: GLvoid * {@native glMapNamedBufferEXT}(GLuint buffer, GLenum access);
        Part of GL_EXT_direct_state_access */ - private final java.nio.ByteBuffer glMapNamedBufferImpl(int bufferName, int access, long glProcAddress) { - if (glProcAddress == 0) { - throw new GLException("Method \"glMapNamedBufferEXT\" not available"); - } - final long addr, sz; - synchronized(bufferSizeTracker) { - sz = bufferSizeTracker.getDirectStateBufferSize(bufferName, this); - if (0 == sz) { - return null; - } - addr = dispatch_glMapNamedBufferEXT(bufferName, access, glProcAddress); - } - if (0 == addr) { - return null; - } - final ByteBuffer buffer; - final MemoryObject memObj0 = new MemoryObject(addr, sz); // object and key - final MemoryObject memObj1 = MemoryObject.getOrAddSafe(arbMemCache, memObj0); - if(memObj0 == memObj1) { - // just added .. - if(null != memObj0.getBuffer()) { - throw new InternalError(); - } - buffer = newDirectByteBuffer(addr, sz); - Buffers.nativeOrder(buffer); - memObj0.setBuffer(buffer); - } else { - // already mapped - buffer = memObj1.getBuffer(); - if(null == buffer) { - throw new InternalError(); - } - } - buffer.position(0); - return buffer; - } - private native long dispatch_glMapNamedBufferEXT(int buffer, int access, long procAddress); + + private final jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch mapBoundBufferRangeDispatch = + new jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch() { + public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); } + public final long mapBuffer(final int target, final long offset, final long length, final int access, final long glProcAddress) { + return dispatch_glMapBufferRange(target, offset, length, access, glProcAddress); + } + }; + private native long dispatch_glMapBufferRange(int target, long offset, long length, int access, long glProcAddress); private native ByteBuffer newDirectByteBuffer(long addr, long capacity); diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java index e7389de10..f0adb5328 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gl4bc.java @@ -18,11 +18,11 @@ public void setObjectTracker(GLObjectTracker tracker) { public GL4bcImpl(GLProfile glp, GLContextImpl context) { this._context = context; if(null != context) { - this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferObjectTracker = context.getBufferObjectTracker(); this.bufferStateTracker = context.getBufferStateTracker(); this.glStateTracker = context.getGLStateTracker(); } else { - this.bufferSizeTracker = null; + this.bufferObjectTracker = null; this.bufferStateTracker = null; this.glStateTracker = null; } @@ -280,10 +280,6 @@ public final void glFreeMemoryNV(java.nio.ByteBuffer pointer) { // Helpers for ensuring the correct amount of texture data // -private final GLBufferSizeTracker bufferSizeTracker; -private final GLBufferStateTracker bufferStateTracker; -private final GLStateTracker glStateTracker; - private boolean haveARBPixelBufferObject; private boolean haveEXTPixelBufferObject; private boolean haveGL15; @@ -431,67 +427,207 @@ private final boolean checkPackPBOBound(boolean throwException) { @Override public final boolean glIsPBOPackBound() { + return isPBOPackBound(); +} +@Override +public final boolean isPBOPackBound() { return checkPackPBOBound(false); } @Override public final boolean glIsPBOUnpackBound() { + return isPBOUnpackBound(); +} +@Override +public final boolean isPBOUnpackBound() { return checkUnpackPBOBound(false); } -/** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
        Part of GL_VERSION_1_5; GL_OES_mapbuffer */ -public final java.nio.ByteBuffer glMapBuffer(int target, int access) { - return glMapBufferImpl(target, false, 0, 0, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); +@Override +public final void glVertexPointer(GLArrayData array) { + if(array.getComponentCount()==0) return; + if(array.isVBO()) { + glVertexPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset()); + } else { + glVertexPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer()); + } } +@Override +public final void glColorPointer(GLArrayData array) { + if(array.getComponentCount()==0) return; + if(array.isVBO()) { + glColorPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset()); + } else { + glColorPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer()); + } -/** Entry point to C language function: void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
        Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_map_buffer_range */ -public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { - return glMapBufferImpl(target, true, offset, length, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); } - -/** Entry point to C language function: GLvoid * {@native glMapNamedBufferEXT}(GLuint buffer, GLenum access);
        Part of GL_EXT_direct_state_access */ -public final java.nio.ByteBuffer glMapNamedBufferEXT(int bufferName, int access) { - return glMapNamedBufferImpl(bufferName, access, ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT); +@Override +public final void glNormalPointer(GLArrayData array) { + if(array.getComponentCount()==0) return; + if(array.getComponentCount()!=3) { + throw new GLException("Only 3 components per normal allowed"); + } + if(array.isVBO()) { + glNormalPointer(array.getComponentType(), array.getStride(), array.getVBOOffset()); + } else { + glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer()); + } +} +@Override +public final void glTexCoordPointer(GLArrayData array) { + if(array.getComponentCount()==0) return; + if(array.isVBO()) { + glTexCoordPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset()); + } else { + glTexCoordPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer()); + } } - @Override - public final void glVertexPointer(GLArrayData array) { - if(array.getComponentCount()==0) return; - if(array.isVBO()) { - glVertexPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset()); - } else { - glVertexPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer()); - } +// +// GLBufferObjectTracker Redirects +// + +@Override +public final void glBufferData(int target, long size, Buffer data, int usage) { + final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glBufferData; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glBufferData")); + } + bufferObjectTracker.createBufferStorage(bufferStateTracker, this, + target, size, data, usage, 0 /* immutableFlags */, + createBoundMutableStorageDispatch, glProcAddress); +} +/** FIXME Add for OpenGL 4.4 +@Override +public final void glBufferStorage(int target, long size, Buffer data, int flags) { + final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glBufferStorage; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glBufferStorage")); } - @Override - public final void glColorPointer(GLArrayData array) { - if(array.getComponentCount()==0) return; - if(array.isVBO()) { - glColorPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset()); - } else { - glColorPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer()); - } + bufferObjectTracker.createBufferStorage(bufferStateTracker, this, + target, size, data, 0 * mutableUsage *, flags, + createBoundImmutableStorageDispatch, glProcAddress); +} +private final jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch createBoundImmutableStorageDispatch = + new jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch() { + public final void create(final int target, final long size, final Buffer data, final int immutableFlags, final long glProcAddress) { + final boolean data_is_direct = Buffers.isDirect(data); + dispatch_glBufferStorage(target, size, + data_is_direct ? data : Buffers.getArray(data), + data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data), + data_is_direct, immutableFlags, glProcAddress); + } + }; +private native void dispatch_glBufferStorage(int target, long size, Object data, int data_byte_offset, boolean data_is_direct, int flags, long procAddress); + */ +@Override +public final void glNamedBufferDataEXT(int buffer, long size, Buffer data, int usage) { + final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glNamedBufferDataEXT; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glNamedBufferDataEXT")); } - @Override - public final void glNormalPointer(GLArrayData array) { - if(array.getComponentCount()==0) return; - if(array.getComponentCount()!=3) { - throw new GLException("Only 3 components per normal allowed"); - } - if(array.isVBO()) { - glNormalPointer(array.getComponentType(), array.getStride(), array.getVBOOffset()); - } else { - glNormalPointer(array.getComponentType(), array.getStride(), array.getBuffer()); - } + bufferObjectTracker.createBufferStorage(this, + buffer, size, data, usage, 0 /* immutableFlags */, + createNamedStorageDispatch, glProcAddress); +} +private final jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch createNamedStorageDispatch = + new jogamp.opengl.GLBufferObjectTracker.CreateStorageDispatch() { + public final void create(final int buffer, final long size, final Buffer data, final int mutableUsage, final long glProcAddress) { + final boolean data_is_direct = Buffers.isDirect(data); + dispatch_glNamedBufferDataEXT(buffer, size, + data_is_direct ? data : Buffers.getArray(data), + data_is_direct ? Buffers.getDirectBufferByteOffset(data) : Buffers.getIndirectBufferByteOffset(data), + data_is_direct, mutableUsage, glProcAddress); + } + }; +private native void dispatch_glNamedBufferDataEXT(int buffer, long size, Object data, int data_byte_offset, boolean data_is_direct, int usage, long procAddress); + +@Override +public boolean glUnmapBuffer(int target) { + final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glUnmapBuffer; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glUnmapBuffer")); } - @Override - public final void glTexCoordPointer(GLArrayData array) { - if(array.getComponentCount()==0) return; - if(array.isVBO()) { - glTexCoordPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getVBOOffset()); - } else { - glTexCoordPointer(array.getComponentCount(), array.getComponentType(), array.getStride(), array.getBuffer()); - } + return bufferObjectTracker.unmapBuffer(bufferStateTracker, this, target, unmapBoundBufferDispatch, glProcAddress); +} + +@Override +public boolean glUnmapNamedBufferEXT(int buffer) { + final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glUnmapNamedBufferEXT; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glUnmapNamedBufferEXT")); } + return bufferObjectTracker.unmapBuffer(buffer, unmapNamedBufferDispatch, glProcAddress); +} +private final jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch unmapNamedBufferDispatch = + new jogamp.opengl.GLBufferObjectTracker.UnmapBufferDispatch() { + public final boolean unmap(final int buffer, final long glProcAddress) { + return dispatch_glUnmapNamedBufferEXT(buffer, glProcAddress); + } + }; +private native boolean dispatch_glUnmapNamedBufferEXT(int buffer, long procAddress); + +@Override +public final GLBufferStorage mapBuffer(final int target, final int access) { + final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapBuffer\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, access, mapBoundBufferAllDispatch, glProcAddress); +} +@Override +public final GLBufferStorage mapBufferRange(final int target, final long offset, final long length, final int access) { + final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapBufferRange\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, offset, length, access, mapBoundBufferRangeDispatch, glProcAddress); +} + +@Override +public final GLBufferStorage mapNamedBuffer(final int bufferName, final int access) { + final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferEXT; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapNamedBufferEXT\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferName, access, mapNamedBufferAllDispatch, glProcAddress); +} +private final jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch mapNamedBufferAllDispatch = + new jogamp.opengl.GLBufferObjectTracker.MapBufferAllDispatch() { + public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); } + public final long mapBuffer(final int bufferName, final int access, final long glProcAddress) { + return dispatch_glMapNamedBufferEXT(bufferName, access, glProcAddress); + } + }; +private native long dispatch_glMapNamedBufferEXT(int buffer, int access, long glProcAddress); + +@Override +public final GLBufferStorage mapNamedBufferRange(final int bufferName, final long offset, final long length, final int access) { + final long glProcAddress = ((GL4bcProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapNamedBufferRangeEXT; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapNamedBufferRangeEXT\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferName, offset, length, access, mapNamedBufferRangeDispatch, glProcAddress); +} +private final jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch mapNamedBufferRangeDispatch = + new jogamp.opengl.GLBufferObjectTracker.MapBufferRangeDispatch() { + public final ByteBuffer allocNioByteBuffer(final long addr, final long length) { return newDirectByteBuffer(addr, length); } + public final long mapBuffer(final int bufferName, final long offset, final long length, final int access, final long glProcAddress) { + return dispatch_glMapNamedBufferRangeEXT(bufferName, offset, length, access, glProcAddress); + } + }; +private native long dispatch_glMapNamedBufferRangeEXT(int buffer, long offset, long length, int access, long procAddress); + +@Override +public final java.nio.ByteBuffer glMapNamedBufferEXT(int bufferName, int access) { + return mapNamedBuffer(bufferName, access).getMappedBuffer(); +} + +@Override +public final ByteBuffer glMapNamedBufferRangeEXT(int bufferName, long offset, long length, int access) { + return mapNamedBufferRange(bufferName, offset, length, access).getMappedBuffer(); +} + diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java index 8d5dcc7a5..6a7e12ca1 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles1.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles1.java @@ -1,11 +1,11 @@ public GLES1Impl(GLProfile glp, GLContextImpl context) { this._context = context; if(null != context) { - this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferObjectTracker = context.getBufferObjectTracker(); this.bufferStateTracker = context.getBufferStateTracker(); this.glStateTracker = context.getGLStateTracker(); } else { - this.bufferSizeTracker = null; + this.bufferObjectTracker = null; this.bufferStateTracker = null; this.glStateTracker = null; } @@ -199,10 +199,6 @@ public final GL2GL3 getGL2GL3() throws GLException { // Helpers for ensuring the correct amount of texture data // -private final GLBufferSizeTracker bufferSizeTracker; -private final GLBufferStateTracker bufferStateTracker; -private final GLStateTracker glStateTracker; - private final boolean checkBufferObject(boolean bound, int state, String kind, boolean throwException) { @@ -269,16 +265,6 @@ private final boolean checkPackPBOBound(boolean throwException) { return false; } -/** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
        Part of GL_VERSION_1_5; GL_OES_mapbuffer */ -public final java.nio.ByteBuffer glMapBuffer(int target, int access) { - return glMapBufferImpl(target, false, 0, 0, access, ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); -} - -/** Entry point to C language function: void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
        Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_map_buffer_range */ -public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { - return glMapBufferImpl(target, true, offset, length, access, ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); -} - @Override public final void glVertexPointer(GLArrayData array) { if(array.getComponentCount()==0) return; @@ -320,3 +306,44 @@ public final void glTexCoordPointer(GLArrayData array) { } } +// +// GLBufferObjectTracker Redirects +// + +@Override +public final void glBufferData(int target, long size, Buffer data, int usage) { + final long glProcAddress = ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glBufferData; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glBufferData")); + } + bufferObjectTracker.createBufferStorage(bufferStateTracker, this, + target, size, data, usage, 0 /* immutableFlags */, + createBoundMutableStorageDispatch, glProcAddress); +} + +@Override +public boolean glUnmapBuffer(int target) { + final long glProcAddress = ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glUnmapBuffer; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glUnmapBuffer")); + } + return bufferObjectTracker.unmapBuffer(bufferStateTracker, this, target, unmapBoundBufferDispatch, glProcAddress); +} + +@Override +public final GLBufferStorage mapBuffer(final int target, final int access) { + final long glProcAddress = ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapBuffer\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, access, mapBoundBufferAllDispatch, glProcAddress); +} +@Override +public final GLBufferStorage mapBufferRange(final int target, final long offset, final long length, final int access) { + final long glProcAddress = ((GLES1ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapBufferRange\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, offset, length, access, mapBoundBufferRangeDispatch, glProcAddress); +} + diff --git a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java index d5ad16873..a5c0d1998 100644 --- a/make/config/jogl/gl-impl-CustomJavaCode-gles3.java +++ b/make/config/jogl/gl-impl-CustomJavaCode-gles3.java @@ -2,11 +2,11 @@ public GLES3Impl(GLProfile glp, GLContextImpl context) { this._context = context; if(null != context) { - this.bufferSizeTracker = context.getBufferSizeTracker(); + this.bufferObjectTracker = context.getBufferObjectTracker(); this.bufferStateTracker = context.getBufferStateTracker(); this.glStateTracker = context.getGLStateTracker(); } else { - this.bufferSizeTracker = null; + this.bufferObjectTracker = null; this.bufferStateTracker = null; this.glStateTracker = null; } @@ -211,9 +211,6 @@ public final GL2GL3 getGL2GL3() throws GLException { // private final boolean _isES3; -private final GLBufferSizeTracker bufferSizeTracker; -private final GLBufferStateTracker bufferStateTracker; -private final GLStateTracker glStateTracker; private final boolean checkBufferObject(boolean extensionAvail, boolean allowVAO, @@ -333,22 +330,20 @@ private final boolean checkPackPBOBound(boolean throwException) { @Override public final boolean glIsPBOPackBound() { + return isPBOPackBound(); +} +@Override +public final boolean isPBOPackBound() { return checkPackPBOBound(false); } @Override public final boolean glIsPBOUnpackBound() { - return checkUnpackPBOBound(false); + return isPBOUnpackBound(); } - -/** Entry point to C language function: void * {@native glMapBuffer}(GLenum target, GLenum access);
        Part of GL_VERSION_1_5; GL_OES_mapbuffer */ -public final java.nio.ByteBuffer glMapBuffer(int target, int access) { - return glMapBufferImpl(target, false, 0, 0, access, ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer); -} - -/** Entry point to C language function: void * {@native glMapBufferRange}(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
        Part of GL_ES_VERSION_3_0, GL_VERSION_3_0; GL_EXT_map_buffer_range */ -public final ByteBuffer glMapBufferRange(int target, long offset, long length, int access) { - return glMapBufferImpl(target, true, offset, length, access, ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange); +@Override +public final boolean isPBOUnpackBound() { + return checkUnpackPBOBound(false); } @Override @@ -361,3 +356,45 @@ public final void glDepthRange(double zNear, double zFar) { glDepthRangef((float)zNear, (float)zFar); } +// +// GLBufferObjectTracker Redirects +// + +@Override +public final void glBufferData(int target, long size, Buffer data, int usage) { + final long glProcAddress = ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glBufferData; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glBufferData")); + } + bufferObjectTracker.createBufferStorage(bufferStateTracker, this, + target, size, data, usage, 0 /* immutableFlags */, + createBoundMutableStorageDispatch, glProcAddress); +} + +@Override +public boolean glUnmapBuffer(int target) { + final long glProcAddress = ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glUnmapBuffer; + if ( 0 == glProcAddress ) { + throw new GLException(String.format("Method \"%s\" not available", "glUnmapBuffer")); + } + return bufferObjectTracker.unmapBuffer(bufferStateTracker, this, target, unmapBoundBufferDispatch, glProcAddress); +} + +@Override +public final GLBufferStorage mapBuffer(final int target, final int access) { + final long glProcAddress = ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBuffer; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapBuffer\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, access, mapBoundBufferAllDispatch, glProcAddress); +} +@Override +public final GLBufferStorage mapBufferRange(final int target, final long offset, final long length, final int access) { + final long glProcAddress = ((GLES3ProcAddressTable)_context.getGLProcAddressTable())._addressof_glMapBufferRange; + if ( 0 == glProcAddress ) { + throw new GLException("Method \"glMapBufferRange\" not available"); + } + return bufferObjectTracker.mapBuffer(bufferStateTracker, this, target, offset, length, access, mapBoundBufferRangeDispatch, glProcAddress); +} + + diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 649256393..6bc1d4eb3 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -103,13 +103,17 @@ function jrun() { #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.FBObject" #D_ARGS="-Djogl.debug.FBObject -Djogl.debug.TraceGL -Djogl.debug.GLBufferStateTracker" #D_ARGS="-Djogl.debug.FBObject" + #D_ARGS="-Djogl.debug.GLBufferStateTracker -Djogl.debug.GLBufferObjectTracker -Djogamp.debug.Lock -Djogamp.common.utils.locks.Lock.timeout=600000 -Dnewt.debug.EDT" + #D_ARGS="-Djogl.debug.GLBufferStateTracker -Djogl.debug.GLBufferObjectTracker" + #D_ARGS="-Djogl.debug.GLBufferObjectTracker" + #D_ARGS="-Djogl.debug.GLBufferObjectTracker -Djogl.debug.GLArrayData -Djogl.debug.TraceGL -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogl.debug.GLCanvas" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" - D_ARGS="-Dnativewindow.debug.JAWT" + #D_ARGS="-Dnativewindow.debug.JAWT" #D_ARGS="-Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.FixedFuncPipeline -Djogl.debug.GLSLCode" @@ -208,6 +212,7 @@ function jrun() { #D_ARGS="-Xprof" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl -Djogl.gljpanel.awtverticalflip" #D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL" #D_ARGS="-Djogl.gljpanel.noverticalflip" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator" @@ -390,7 +395,13 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAONEWT $* @@ -536,7 +547,7 @@ function testawtswt() { # OK (X11, OSX) #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT $* diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index df60d2f73..023913d7b 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -41,6 +41,7 @@ package com.jogamp.gluegen.opengl; import com.jogamp.gluegen.CodeGenUtils; import com.jogamp.gluegen.JavaType; + import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -50,6 +51,7 @@ import java.lang.reflect.Method; import java.nio.Buffer; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -82,6 +84,16 @@ public class BuildComposablePipeline { */ public static final int GEN_GL_IDENTITY_BY_ASSIGNABLE_CLASS = 1 << 4; + private static final HashMap addedGLHooks = new HashMap(); + private static final String[] addedGLHookMethodNames = new String[] { + "mapBuffer", "mapBufferRange", + "mapNamedBuffer", "mapNamedBufferRange" }; + static { + for(int i=0; i + * Throws a {@link GLException} if GL-function constraints are not met. + *

        + *

        + * {@link GL#glMapBuffer(int, int)} wrapper calls this method and returns {@link GLBufferStorage#getMappedBuffer()}. + *

        + *

        + * A zero {@link GLBufferStorage#getSize()} will avoid a native call and returns the unmapped {@link GLBufferStorage}. + *

        + *

        + * A null native mapping result indicating an error will + * not cause a GLException but returns the unmapped {@link GLBufferStorage}. + * This allows the user to handle this case. + *

        + * @param target denotes the buffer via it's bound target + * @param access the mapping access mode + * @throws GLException if buffer is not bound to target + * @throws GLException if buffer is not tracked + * @throws GLException if buffer is already mapped + * @throws GLException if buffer has invalid store size, i.e. less-than zero + */ + public GLBufferStorage mapBuffer(int target, int access) throws GLException; + + /** + * Returns the {@link GLBufferStorage} instance as mapped via OpenGL's native {@link GL#glMapBufferRange(int, long, long, int) glMapBufferRange(..)} implementation. + *

        + * Throws a {@link GLException} if GL-function constraints are not met. + *

        + *

        + * {@link GL#glMapBufferRange(int, long, long, int)} wrapper calls this method and returns {@link GLBufferStorage#getMappedBuffer()}. + *

        + *

        + * A zero {@link GLBufferStorage#getSize()} will avoid a native call and returns the unmapped {@link GLBufferStorage}. + *

        + *

        + * A null native mapping result indicating an error will + * not cause a GLException but returns the unmapped {@link GLBufferStorage}. + * This allows the user to handle this case. + *

        + * @param target denotes the buffer via it's bound target + * @param offset offset of the mapped buffer's storage + * @param length length of the mapped buffer's storage + * @param access the mapping access mode + * @throws GLException if buffer is not bound to target + * @throws GLException if buffer is not tracked + * @throws GLException if buffer is already mapped + * @throws GLException if buffer has invalid store size, i.e. less-than zero + * @throws GLException if buffer mapping range does not fit, incl. offset + */ + public GLBufferStorage mapBufferRange(final int target, final long offset, final long length, final int access) throws GLException; + + /** + * @deprecated Avoid original GL API namespace conflict. Use {@link #isVBOArrayBound()} */ public boolean glIsVBOArrayBound(); + /** + * @return true if a VBO is bound to {@link GL#GL_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false + */ + public boolean isVBOArrayBound(); /** - * @return true if a VBO is bound to {@link GL#GL_ELEMENT_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false + * @deprecated Avoid original GL API namespace conflict. Use {@link #isVBOElementArrayBound()} */ public boolean glIsVBOElementArrayBound(); + /** + * @return true if a VBO is bound to {@link GL#GL_ELEMENT_ARRAY_BUFFER} via {@link GL#glBindBuffer(int, int)}, otherwise false + */ + public boolean isVBOElementArrayBound(); /** * Return the framebuffer name bound to this context, diff --git a/src/jogl/classes/javax/media/opengl/GLBufferStorage.java b/src/jogl/classes/javax/media/opengl/GLBufferStorage.java new file mode 100644 index 000000000..929ecf60a --- /dev/null +++ b/src/jogl/classes/javax/media/opengl/GLBufferStorage.java @@ -0,0 +1,150 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package javax.media.opengl; + +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +/** + * OpenGL buffer storage object reflecting it's + *
          + *
        • storage size
        • + *
        • storage memory if mapped
        • + *
        • mutable usage or immutable flags
        • + *
        + *

        + * Buffer storage is created via: + *

          + *
        • glBufferStorage - storage creation with target
        • + *
        • {@link GL#glBufferData(int, long, java.nio.Buffer, int)} - storage recreation with target
        • + *
        • {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} - storage recreation, direct
        • + *
        + * Note that storage recreation as mentioned above also invalidate a previous storage instance, + * i.e. disposed the buffer's current storage if exist and attaches a new storage instance. + *

        + *

        + * Buffer storage is disposed via: + *

          + *
        • {@link GL#glDeleteBuffers(int, IntBuffer)} - explicit, direct, via {@link #notifyBuffersDeleted(int, IntBuffer)} or {@link #notifyBuffersDeleted(int, int[], int)}
        • + *
        • {@link GL#glBufferData(int, long, java.nio.Buffer, int)} - storage recreation via target
        • + *
        • {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} - storage recreation, direct
        • + *
        + *

        + *

        + * GL buffer storage is mapped via + *

          + * + *
        • {@link GL#mapBuffer(int, int)}
        • + *
        • {@link GL#mapBufferRange(int, long, long, int)}
        • + *
        • {@link GL2#mapNamedBuffer(int, int)}
        • + *
        • {@link GL2#mapNamedBufferRange(int, long, long, int)}
        • + *
        + *

        + *

        + * GL buffer storage is unmapped via + *

          + *
        • {@link GL#glUnmapBuffer(int)} - explicit via target
        • + *
        • {@link GL2#glUnmapNamedBufferEXT(int)} - explicit direct
        • + *
        • {@link GL#glBufferData(int, long, java.nio.Buffer, int)} - storage recreation via target
        • + *
        • {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} - storage recreation, direct
        • + *
        • {@link GL#glDeleteBuffers(int, IntBuffer)} - buffer deletion
        • + *
        + *

        + */ +public abstract class GLBufferStorage { + private final int name; + private final long size; + private final int mutableUsage; + private final int immutableFlags; + protected ByteBuffer mappedBuffer; + + protected GLBufferStorage(final int name, final long size, final int mutableUsage, final int immutableFlags) { + this.name = name; + this.size = size; + this.mutableUsage = mutableUsage; + this.immutableFlags = immutableFlags; + this.mappedBuffer = null; + } + + /** Return the buffer name */ + public final int getName() { return name; } + + /** Return the buffer's storage size. */ + public final long getSize() { return size; } + + /** + * Returns true if buffer's storage is mutable, i.e. + * created via {@link GL#glBufferData(int, long, java.nio.Buffer, int)}. + *

        + * Returns false if buffer's storage is immutable, i.e. + * created via glBufferStorage. FIXME: Add GL 4.4 support! + *

        + * @return + */ + public final boolean isMutableStorage() { return 0 != mutableUsage; } + + /** + * Returns the mutable storage usage or 0 if storage is not {@link #isMutableStorage() mutable}. + */ + public final int getMutableUsage() { return mutableUsage; } + + /** + * Returns the immutable storage flags, invalid if storage is {@link #isMutableStorage() mutable}. + */ + public final int getImmutableFlags() { return immutableFlags; } + + /** + * Returns the mapped ByteBuffer, or null if not mapped. + * Mapping may occur via: + *
          + *
        • {@link GL#glMapBuffer(int, int)}
        • + *
        • {@link GL#glMapBufferRange(int, long, long, int)}
        • + *
        • {@link GL2#glMapNamedBufferEXT(int, int)}
        • + *
        • {@link GL2#glMapNamedBufferRangeEXT(int, long, long, int)} + *
        + */ + public final ByteBuffer getMappedBuffer() { return mappedBuffer; } + + public final String toString() { + return toString(false); + } + public final String toString(final boolean skipMappedBuffer) { + final String s0; + if( isMutableStorage() ) { + s0 = String.format("%s[name %s, size %d, mutable usage 0x%X", msgClazzName, name, size, mutableUsage); + } else { + s0 = String.format("%s[name %s, size %d, immutable flags 0x%X", msgClazzName, name, size, immutableFlags); + } + if(skipMappedBuffer) { + return s0+"]"; + } else { + return s0+", mapped "+mappedBuffer+"]"; + } + } + private final String msgClazzName = "GLBufferStorage"; +} diff --git a/src/jogl/classes/javax/media/opengl/GLContext.java b/src/jogl/classes/javax/media/opengl/GLContext.java index bec62c30d..0b0ed8e0d 100644 --- a/src/jogl/classes/javax/media/opengl/GLContext.java +++ b/src/jogl/classes/javax/media/opengl/GLContext.java @@ -1622,8 +1622,8 @@ public abstract class GLContext { final Integer valI = deviceVersionAvailable.get(key); if(null != valI) { final int bits32 = valI.intValue(); - final int major = ( bits32 & 0xFF000000 ) >> 24 ; - final int minor = ( bits32 & 0x00FF0000 ) >> 16 ; + final int major = ( bits32 & 0xFF000000 ) >>> 24 ; + final int minor = ( bits32 & 0x00FF0000 ) >>> 16 ; final int ctp = ( bits32 & 0x0000FFFF ) ; sb.append(GLContext.getGLVersion(major, minor, ctp, null)); } else { @@ -1668,10 +1668,10 @@ public abstract class GLContext { final int bits32 = valI.intValue(); if(null!=major) { - major[0] = ( bits32 & 0xFF000000 ) >> 24 ; + major[0] = ( bits32 & 0xFF000000 ) >>> 24 ; } if(null!=minor) { - minor[0] = ( bits32 & 0x00FF0000 ) >> 16 ; + minor[0] = ( bits32 & 0x00FF0000 ) >>> 16 ; } if(null!=ctp) { ctp[0] = ( bits32 & 0x0000FFFF ) ; diff --git a/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java new file mode 100644 index 000000000..289884b5c --- /dev/null +++ b/src/jogl/classes/jogamp/opengl/GLBufferObjectTracker.java @@ -0,0 +1,532 @@ +/* + * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 2010 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any kind. ALL + * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, + * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A + * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN + * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR + * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR + * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR + * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE + * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, + * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF + * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed or intended for use + * in the design, construction, operation or maintenance of any nuclear + * facility. + * + * Sun gratefully acknowledges that this software was originally authored + * and developed by Kenneth Bradley Russell and Christopher John Kline. + */ + +package jogamp.opengl; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; + +import javax.media.opengl.*; + +import com.jogamp.common.nio.Buffers; +import com.jogamp.common.util.IntObjectHashMap; + +/** + * Tracking of {@link GLBufferStorage} instances via GL API callbacks. + *

        + * See {@link GLBufferStorage} for generic details. + *

        + *

        + * Buffer storage is created via + *

          + *
        • glBufferStorage - storage creation with target via {@link #createBufferStorage(GLBufferStateTracker, GL, int, long, Buffer, int, int, CreateStorageDispatch, long)}
        • + *
        • {@link GL#glBufferData(int, long, java.nio.Buffer, int)} - storage recreation with target via {@link #createBufferStorage(GLBufferStateTracker, GL, int, long, Buffer, int, int, CreateStorageDispatch, long)}
        • + *
        • {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} - storage recreation, direct, via {@link #createBufferStorage(GL, int, long, Buffer, int, CreateStorageDispatch, long)}
        • + *
        + * Note that storage recreation as mentioned above also invalidate a previous storage instance, + * i.e. disposed the buffer's current storage if exist and attaches a new storage instance. + *

        + *

        + * Buffers storage is disposed via + *

          + *
        • {@link GL#glDeleteBuffers(int, IntBuffer)} - explicit, direct, via {@link #notifyBuffersDeleted(int, IntBuffer)} or {@link #notifyBuffersDeleted(int, int[], int)}
        • + *
        • {@link GL#glBufferData(int, long, java.nio.Buffer, int)} - storage recreation via target
        • + *
        • {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)} - storage recreation, direct
        • + *
        + *

        + * + *

        + * Implementation throws a {@link GLException} in all construction methods as listed below, + * if GL-function constraints are not met. createBufferStorage also throws an exception + * if the native GL-function fails. + *

          + *
        • {@link #createBufferStorage(GLBufferStateTracker, GL, int, long, Buffer, int, int, CreateStorageDispatch, long)}, etc ..
        • + *
        • {@link #mapBuffer(GLBufferStateTracker, GL, int, int, MapBufferAllDispatch, long)}, etc ..
        • + *
        + * In destruction and informal methods, i.e. all others, implementation only issues a WARNING debug message, if enabled. + *

        + * + *

        + * Buffer mapping methods like {@link GL#mapBuffer(int, int)} ..., + * require knowledge of the buffer's storage size as determined via it's creation with + * {@link GL#glBufferData(int, long, java.nio.Buffer, int)} .... + *

        + *

        + * Hence we track the OpenGL buffer's {@link GLBufferStorage} to be able to + * access the buffer's storage size. The tracked {@link GLBufferStorage} instances + * also allow users to conveniently access details of their created and maybe mapped buffer storage. + *

        + *

        + * The {@link GLBufferObjectTracker} and it's tracked {@link GLBufferStorage} instances + * maybe shared across multiple OpenGL context, hence this class is thread safe and employs synchronization. + *

        + *

        + * Implementation requires and utilizes a local {@link GLBufferStateTracker} + * to resolve the actual buffer-name bound to the given target. + *

        + *

        + * Note: This tracker requires to be notified about all OpenGL buffer storage operations, + * as well as the local {@link GLBufferStateTracker} to be notified about all + * OpenGL buffer binding operations. + * Hence buffer storage cannot be accessed properly if managed via native code. + *

        + */ +public class GLBufferObjectTracker { + protected static final boolean DEBUG; + + static { + Debug.initSingleton(); + DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferObjectTracker", true); + } + + static final class GLBufferStorageImpl extends GLBufferStorage { + GLBufferStorageImpl(final int name, final long size, final int mutableUsage, final int immutableFlags) { + super(name, size, mutableUsage, immutableFlags); + } + final void setMappedBuffer(final ByteBuffer bb) { + if (DEBUG) { + System.err.printf("%s.GLBufferStorage.setMappedBuffer: %s: %s -> %s%n", msgClazzName, toString(true), mappedBuffer, bb); + } + mappedBuffer = bb; + } + } + + /** + * Map from buffer names to GLBufferObject. + */ + private final IntObjectHashMap bufferName2StorageMap; + + public GLBufferObjectTracker() { + bufferName2StorageMap = new IntObjectHashMap(); + bufferName2StorageMap.setKeyNotFoundValue(null); + } + + public static interface CreateStorageDispatch { + void create(final int targetOrBufferName, final long size, final Buffer data, final int mutableUsageOrImmutableFlags, final long glProcAddress); + } + + /** + * Must be called when [re]creating the GL buffer object via glBufferStorage and {@link GL#glBufferData(int, long, java.nio.Buffer, int)}, + * i.e. implies destruction of the buffer. + * + * @param bufferStateTracker + * @param caller + * @param target + * @param size + * @param mutableUsage glBufferData, glNamedBufferDataEXT usage + * @param immutableFlags glBufferStorage flags + * @throws GLException if buffer is not bound to target + * @throws GLException if size is less-or-eqaul zero for glBufferStorage, or size is less-than zero otherwise + * @throws GLException if a native GL-Error occurs + */ + public synchronized final void createBufferStorage(final GLBufferStateTracker bufferStateTracker, final GL caller, + final int target, final long size, final Buffer data, int mutableUsage, int immutableFlags, + final CreateStorageDispatch dispatch, final long glProcAddress) throws GLException { + final int glerrPre = caller.glGetError(); // clear + if (DEBUG && GL.GL_NO_ERROR != glerrPre) { + System.err.printf("%s.%s glerr-pre 0x%X%n", msgClazzName, msgCreateBound, glerrPre); + } + final int bufferName = bufferStateTracker.getBoundBufferObject(target, caller); + if ( 0 == bufferName ) { + throw new GLException(String.format("%s: Buffer for target 0x%X not bound", GL_INVALID_OPERATION, target)); + } + final boolean mutableBuffer = 0 != mutableUsage; + final boolean invalidSize = ( mutableBuffer && 0 > size ) // glBufferData, glNamedBufferDataEXT + || ( !mutableBuffer && 0 >= size ); // glBufferStorage + if( invalidSize ) { + throw new GLException(String.format("%s: Invalid size %d for buffer %d on target 0x%X", GL_INVALID_VALUE, size, bufferName, target)); + } + + dispatch.create(target, size, data, mutableBuffer ? mutableUsage : immutableFlags, glProcAddress); + final int glerrPost = caller.glGetError(); // be safe, catch failure! + if(GL.GL_NO_ERROR != glerrPost) { + throw new GLException(String.format("GL-Error 0x%X while creating %s storage for target 0x%X -> buffer %d of size %d with data %s", + glerrPost, mutableBuffer ? "mutable" : "immutable", target, bufferName, size, data)); + } + final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, immutableFlags); + final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.put(bufferName, objNew); + if (DEBUG) { + System.err.printf("%s.%s target: 0x%X -> %d: %s -> %s%n", msgClazzName, msgCreateBound, target, bufferName, objOld, objNew); + } + if( null != objOld ) { + objOld.setMappedBuffer(null); + } + } + + /** + * Must be called when [re]creating the GL buffer object via {@link GL2#glNamedBufferDataEXT(int, long, java.nio.Buffer, int)}, + * i.e. implies destruction of the buffer. + * + * @param bufferName + * @param size + * @param mutableUsage + * @throws GLException if size is less-than zero + * @throws GLException if a native GL-Error occurs + */ + public synchronized final void createBufferStorage(final GL caller, + final int bufferName, final long size, final Buffer data, final int mutableUsage, int immutableFlags, + final CreateStorageDispatch dispatch, final long glProcAddress) throws GLException { + final int glerrPre = caller.glGetError(); // clear + if (DEBUG && GL.GL_NO_ERROR != glerrPre) { + System.err.printf("%s.%s glerr-pre 0x%X%n", msgClazzName, msgCreateNamed, glerrPre); + } + if ( 0 > size ) { // glBufferData, glNamedBufferDataEXT + throw new GLException(String.format("%s: Invalid size %d for buffer %d", GL_INVALID_VALUE, size, bufferName)); + } + final boolean mutableBuffer = 0 != mutableUsage; + if( !mutableBuffer ) { + throw new InternalError("Immutable glNamedBufferStorageEXT not supported yet"); + } + dispatch.create(bufferName, size, data, mutableUsage, glProcAddress); + final int glerrPost = caller.glGetError(); // be safe, catch failure! + if(GL.GL_NO_ERROR != glerrPost) { + throw new GLException(String.format("GL-Error 0x%X while creating %s storage for buffer %d of size %d with data %s", + glerrPost, "mutable", bufferName, size, data)); + } + final GLBufferStorageImpl objNew = new GLBufferStorageImpl(bufferName, size, mutableUsage, 0 /* immutableFlags */); + final GLBufferStorageImpl objOld = (GLBufferStorageImpl) bufferName2StorageMap.put(bufferName, objNew); + if (DEBUG) { + System.err.printf("%s.%s direct: %d: %s -> %s%n", msgClazzName, msgCreateNamed, bufferName, objOld, objNew); + } + if( null != objOld ) { + objOld.setMappedBuffer(null); + } + } + + /** + * Must be called when deleting GL buffer objects vis glDeleteBuffers. + * @param count + * @param bufferNames + * @param offset + */ + public synchronized final void notifyBuffersDeleted(final int count, final int[] bufferNames, final int offset) { + for(int i=0; iglDeleteBuffers. + * @param n + * @param bufferNames + */ + public synchronized final void notifyBuffersDeleted(final int n, final IntBuffer bufferNames) { + final int offset = bufferNames.position(); + for(int i=0; i null%n", msgClazzName, i+1, count, bufferName, objOld); + } + if( null == objOld ) { + if (DEBUG) { + System.err.printf("%s: %s.notifyBuffersDeleted()[%d/%d]: Buffer %d not tracked%n", warning, msgClazzName, i+1, count, bufferName); + Thread.dumpStack(); + } + return; + } + objOld.setMappedBuffer(null); + } + + public static interface MapBufferDispatch { + ByteBuffer allocNioByteBuffer(final long addr, final long length); + } + public static interface MapBufferRangeDispatch extends MapBufferDispatch { + long mapBuffer(final int targetOrBufferName, final long offset, final long length, final int access, final long glProcAddress); + } + public static interface MapBufferAllDispatch extends MapBufferDispatch { + long mapBuffer(final int targetOrBufferName, final int access, final long glProcAddress); + } + + private static final String GL_INVALID_OPERATION = "GL_INVALID_OPERATION"; + private static final String GL_INVALID_VALUE = "GL_INVALID_VALUE"; + + /** + * Must be called when mapping GL buffer objects via {@link GL#mapBuffer(int, int)}. + * @throws GLException if buffer is not bound to target + * @throws GLException if buffer is not tracked + * @throws GLException if buffer is already mapped + * @throws GLException if buffer has invalid store size, i.e. less-than zero + */ + public synchronized final GLBufferStorage mapBuffer(final GLBufferStateTracker bufferStateTracker, + final GL caller, final int target, final int access, + final MapBufferAllDispatch dispatch, final long glProcAddress) throws GLException { + return this.mapBufferImpl(bufferStateTracker, caller, target, false /* useRange */, 0 /* offset */, 0 /* length */, access, dispatch, glProcAddress); + } + /** + * Must be called when mapping GL buffer objects via {@link GL#mapBufferRange(int, long, long, int)}. + * @throws GLException if buffer is not bound to target + * @throws GLException if buffer is not tracked + * @throws GLException if buffer is already mapped + * @throws GLException if buffer has invalid store size, i.e. less-than zero + * @throws GLException if buffer mapping range does not fit, incl. offset + */ + public synchronized final GLBufferStorage mapBuffer(final GLBufferStateTracker bufferStateTracker, + final GL caller, final int target, final long offset, final long length, final int access, + final MapBufferRangeDispatch dispatch, final long glProcAddress) throws GLException { + return this.mapBufferImpl(bufferStateTracker, caller, target, true /* useRange */, length, access, access, dispatch, glProcAddress); + } + /** + * Must be called when mapping GL buffer objects via {@link GL2#mapNamedBuffer(int, int)}. + * @throws GLException if buffer is not tracked + * @throws GLException if buffer is already mapped + * @throws GLException if buffer has invalid store size, i.e. less-than zero + */ + public synchronized final GLBufferStorage mapBuffer(final int bufferName, final int access, final MapBufferAllDispatch dispatch, + final long glProcAddress) throws GLException { + return this.mapBufferImpl(0 /* target */, bufferName, true /* isNamedBuffer */, false /* useRange */, 0 /* offset */, 0 /* length */, access, dispatch, glProcAddress); + } + /** + * Must be called when mapping GL buffer objects via {@link GL2#mapNamedBufferRange(int, long, long, int)}. + * @throws GLException if buffer is not tracked + * @throws GLException if buffer is already mapped + * @throws GLException if buffer has invalid store size, i.e. less-than zero + * @throws GLException if buffer mapping range does not fit, incl. offset + */ + public synchronized final GLBufferStorage mapBuffer(final int bufferName, final long offset, final long length, final int access, final MapBufferRangeDispatch dispatch, + final long glProcAddress) throws GLException { + return this.mapBufferImpl(0 /* target */, bufferName, true /* isNamedBuffer */, false /* useRange */, 0 /* offset */, 0 /* length */, access, dispatch, glProcAddress); + } + /** + * @throws GLException if buffer is not bound to target + * @throws GLException if buffer is not tracked + * @throws GLException if buffer is already mapped + * @throws GLException if buffer has invalid store size, i.e. less-than zero + * @throws GLException if buffer mapping range does not fit, incl. optional offset + */ + private synchronized final GLBufferStorage mapBufferImpl(final GLBufferStateTracker bufferStateTracker, + final GL caller, final int target, final boolean useRange, + long offset, long length, final int access, + final MapBufferDispatch dispatch, final long glProcAddress) throws GLException { + final int bufferName = bufferStateTracker.getBoundBufferObject(target, caller); + if( 0 == bufferName ) { + throw new GLException(String.format("%s.%s: %s Buffer for target 0x%X not bound", msgClazzName, msgMapBuffer, GL_INVALID_OPERATION, target)); + } + return this.mapBufferImpl(target, bufferName, false /* isNamedBuffer */, useRange, offset, length, access, dispatch, glProcAddress); + } + /** + *

        + * A zero store size will avoid a native call and returns the unmapped {@link GLBufferStorage}. + *

        + *

        + * A null native mapping result indicating an error will + * not cause a GLException but returns the unmapped {@link GLBufferStorage}. + * This allows the user to handle this case. + *

        + * @throws GLException if buffer is not tracked + * @throws GLException if buffer is already mapped + * @throws GLException if buffer has invalid store size, i.e. less-than zero + * @throws GLException if buffer mapping range does not fit, incl. optional offset + */ + private synchronized final GLBufferStorage mapBufferImpl(final int target, final int bufferName, final boolean isNamedBuffer, final boolean useRange, long offset, + long length, final int access, final MapBufferDispatch dispatch, + final long glProcAddress) throws GLException { + final GLBufferStorageImpl store = (GLBufferStorageImpl)bufferName2StorageMap.get(bufferName); + if ( null == store ) { + throw new GLException("Buffer with name "+bufferName+" not tracked"); + } + if( null != store.getMappedBuffer() ) { + throw new GLException(String.format("%s.%s: %s Buffer storage of target 0x%X -> %d: %s is already mapped", msgClazzName, msgMapBuffer, GL_INVALID_OPERATION, target, bufferName, store)); + } + final long storeSize = store.getSize(); + if ( 0 > storeSize ) { + throw new GLException(String.format("%s.%s: %s Buffer storage of target 0x%X -> %d: %s is of less-than zero", msgClazzName, msgMapBuffer, GL_INVALID_OPERATION, target, bufferName, store)); + } + if( !useRange ) { + length = storeSize; + offset = 0; + } + if( length + offset > storeSize ) { + throw new GLException(String.format("%s.%s: %s Out of range: offset %d, length %d, buffer storage of target 0x%X -> %d: %s", msgClazzName, msgMapBuffer, GL_INVALID_VALUE, offset, length, target, bufferName, store)); + } + if( 0 >= length || 0 > offset ) { + throw new GLException(String.format("%s.%s: %s Invalid values: offset %d, length %d, buffer storage of target 0x%X -> %d: %s", msgClazzName, msgMapBuffer, GL_INVALID_VALUE, offset, length, target, bufferName, store)); + } + if( 0 == storeSize ) { + return store; + } + final long addr; + if( isNamedBuffer ) { + if( useRange ) { + addr = ((MapBufferRangeDispatch)dispatch).mapBuffer(bufferName, offset, length, access, glProcAddress); + } else { + addr = ((MapBufferAllDispatch)dispatch).mapBuffer(bufferName, access, glProcAddress); + } + } else { + if( useRange ) { + addr = ((MapBufferRangeDispatch)dispatch).mapBuffer(target, offset, length, access, glProcAddress); + } else { + addr = ((MapBufferAllDispatch)dispatch).mapBuffer(target, access, glProcAddress); + } + } + // GL's map-buffer implementation always returns NULL on error, + // user shall validate the result and the corresponding getGLError() value! + if ( 0 == addr ) { + if( DEBUG ) { + System.err.printf("%s.%s: %s MapBuffer null result for target 0x%X -> %d: %s, off %d, len %d, acc 0x%X%n", msgClazzName, msgMapBuffer, warning, target, bufferName, store, offset, length, access); + Thread.dumpStack(); + } + // User shall handle the glError ! + } else { + final ByteBuffer buffer = dispatch.allocNioByteBuffer(addr, length); + Buffers.nativeOrder(buffer); + if( DEBUG ) { + System.err.printf("%s.%s: Target 0x%X -> %d: %s, off %d, len %d, acc 0x%X%n", msgClazzName, msgClazzName, target, bufferName, store.toString(false), offset, length, access); + } + store.setMappedBuffer(buffer); + } + return store; + } + + public static interface UnmapBufferDispatch { + boolean unmap(final int targetOrBufferName, final long glProcAddress); + } + + /** + * Must be called when unmapping GL buffer objects via {@link GL#glUnmapBuffer(int)}. + *

        + * Only clear mapped buffer reference of {@link GLBufferStorage} + * if native unmapping was successful. + *

        + */ + public synchronized final boolean unmapBuffer(final GLBufferStateTracker bufferStateTracker, final GL caller, + final int target, + final UnmapBufferDispatch dispatch, final long glProcAddress) { + final int bufferName = bufferStateTracker.getBoundBufferObject(target, caller); + final GLBufferStorageImpl store; + if( 0 == bufferName ) { + if (DEBUG) { + System.err.printf("%s: %s.%s: Buffer for target 0x%X not bound%n", warning, msgClazzName, msgUnmapped, target); + Thread.dumpStack(); + } + store = null; + } else { + store = (GLBufferStorageImpl) bufferName2StorageMap.get(bufferName); + if( DEBUG && null == store ) { + System.err.printf("%s: %s.%s: Buffer %d not tracked%n", warning, msgClazzName, msgUnmapped, bufferName); + Thread.dumpStack(); + } + } + final boolean res = dispatch.unmap(target, glProcAddress); + if( res && null != store ) { + store.setMappedBuffer(null); + } + if( DEBUG ) { + System.err.printf("%s.%s %s target: 0x%X -> %d: %s%n", msgClazzName, msgUnmapped, res ? "OK" : "Failed", target, bufferName, store.toString(false)); + if(!res) { + Thread.dumpStack(); + } + } + return res; + } + /** + * Must be called when unmapping GL buffer objects via {@link GL2#glUnmapNamedBufferEXT(int)}. + *

        + * Only clear mapped buffer reference of {@link GLBufferStorage} + * if native unmapping was successful. + *

        + */ + public synchronized final boolean unmapBuffer(final int bufferName, + final UnmapBufferDispatch dispatch, final long glProcAddress) { + final GLBufferStorageImpl store = (GLBufferStorageImpl) bufferName2StorageMap.get(bufferName); + if (DEBUG && null == store ) { + System.err.printf("%s: %s.%s: Buffer %d not tracked%n", warning, msgClazzName, msgUnmapped, bufferName); + Thread.dumpStack(); + } + final boolean res = dispatch.unmap(bufferName, glProcAddress); + if( res && null != store ) { + store.setMappedBuffer(null); + } + if (DEBUG) { + System.err.printf("%s.%s %s %d: %s%n", msgClazzName, msgUnmapped, res ? "OK" : "Failed", bufferName, store.toString(false)); + if(!res) { + Thread.dumpStack(); + } + } + return res; + } + + public synchronized final long getBufferSize(final int bufferName) { + final GLBufferStorageImpl store = (GLBufferStorageImpl)bufferName2StorageMap.get(bufferName); + if ( null == store ) { + if (DEBUG) { + System.err.printf("%s: %s.getBufferSize(): Buffer %d not tracked%n", warning, msgClazzName, bufferName); + Thread.dumpStack(); + } + return 0; + } + return store.getSize(); + } + + public synchronized final GLBufferStorage getBufferStorage(final int bufferName) { + return (GLBufferStorageImpl)bufferName2StorageMap.get(bufferName); + } + + /** + * Clear all tracked buffer object knowledge. + *

        + * Shall only be called at GLContext destruction iff + * there are no other shared GLContext instances left. + *

        + */ + public synchronized final void clear() { + if (DEBUG) { + System.err.printf("%s.clear() - Thread %s%n", msgClazzName, Thread.currentThread().getName()); + // Thread.dumpStack(); + } + bufferName2StorageMap.clear(); + } + + private static final String warning = "WARNING"; + private static final String msgClazzName = "GLBufferObjectTracker"; + private static final String msgUnmapped = "notifyBufferUnmapped()"; + private static final String msgCreateBound = "createBoundBufferStorage()"; + private static final String msgCreateNamed = "createNamedBufferStorage()"; + private static final String msgMapBuffer = "mapBuffer()"; +} diff --git a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java deleted file mode 100644 index b6d9b5682..000000000 --- a/src/jogl/classes/jogamp/opengl/GLBufferSizeTracker.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. - * Copyright (c) 2010 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, - * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A - * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN - * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR - * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR - * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR - * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR - * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE - * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, - * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF - * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed or intended for use - * in the design, construction, operation or maintenance of any nuclear - * facility. - * - * Sun gratefully acknowledges that this software was originally authored - * and developed by Kenneth Bradley Russell and Christopher John Kline. - */ - -package jogamp.opengl; - -import javax.media.opengl.*; -import com.jogamp.common.util.IntLongHashMap; - -/** - * Tracks as closely as possible the sizes of allocated OpenGL buffer - * objects. - *

        - * glMapBuffer or glMapBufferRange etc - * returns a java.nio.ByteBuffer - * instance reflecting the returned native address of respective calls - * and the actual buffer size. - *

        - *

        - * In case the buffer size is unknown, we need to compute this size by using - * glGetBufferParameteriv with a pname of GL_BUFFER_SIZE. - * The latter appears to be problematic due to the returned int value, - * where size should be of type long. - * Further more, this query appears to be costly for each glMapBuffer call - * at for Apple's new multithreaded OpenGL implementation. - *

        - *

        - * The buffer size state is shared across all shared OpenGL context, - * hence we share the GLBufferSizeTracker instance across all shared GLContexts. - * Hence utilizing this instance must be synchronized to be thread safe due to multithreading usage. - *

        - *

        - * We track the sizes of allocated buffer objects. - * We track calls to glBindBuffer etc to see which buffer is bound to - * which target and to glBufferData to see how large the buffer's - * allocated size is. When glMapBuffer is called, we consult our table - * of buffer sizes to see if we can return an answer without a glGet - * call. - *

        - *

        - * In the face of calls to glPushClientAttrib / glPopClientAttrib we currently punt - * and re-fetch the bound buffer object for the state in question; - * see, for example, glVertexPointer and the calls down to - * GLBufferStateTracker.getBoundBufferObject(). Note that we currently - * ignore new binding targets such as GL_TRANSFORM_FEEDBACK_BUFFER_NV; - * the fact that new binding targets may be added in the future makes - * it impossible to cache state for these new targets. - *

        - *

        - * Ignoring new binding targets, the primary situation in which we may - * not be able to return a cached answer is in the case of an error, - * where glBindBuffer may not have been called before trying to call - * glBufferData. Also, if external native code modifies a buffer - * object, we may return an incorrect answer. (FIXME: this case - * requires more thought, and perhaps stochastic and - * exponential-fallback checking. However, note that it can only occur - * in the face of external native code which requires that the - * application be signed anyway, so there is no security risk in this - * area.) - *

        - */ -public class GLBufferSizeTracker { - protected static final boolean DEBUG; - - static { - Debug.initSingleton(); - DEBUG = Debug.isPropertyDefined("jogl.debug.GLBufferSizeTracker", true); - } - - // Map from buffer names to sizes. - // Note: should probably have some way of shrinking this map, but - // can't just make it a WeakHashMap because nobody holds on to the - // keys; would have to always track creation and deletion of buffer - // objects, which is probably sub-optimal. The expected usage - // pattern of buffer objects indicates that the fact that this map - // never shrinks is probably not that bad. - private final IntLongHashMap bufferSizeMap; - private final long sizeNotFount = 0xFFFFFFFFFFFFFFFFL; - - public GLBufferSizeTracker() { - bufferSizeMap = new IntLongHashMap(); - bufferSizeMap.setKeyNotFoundValue(sizeNotFount); - } - - public final void setBufferSize(GLBufferStateTracker bufferStateTracker, - int target, GL caller, long size) { - // Need to do some similar queries to getBufferSize below - int buffer = bufferStateTracker.getBoundBufferObject(target, caller); - if (buffer != 0) { - setDirectStateBufferSize(buffer, caller, size); - } - // We don't know the current buffer state. Note that the buffer - // state tracker will have made the appropriate OpenGL query if it - // didn't know what was going on, so at this point we have nothing - // left to do except drop this piece of information on the floor. - } - - public final void setDirectStateBufferSize(int buffer, GL caller, long size) { - bufferSizeMap.put(buffer, size); - } - - public final long getBufferSize(GLBufferStateTracker bufferStateTracker, - int target, - GL caller) { - // See whether we know what buffer is currently bound to the given - // state - final int buffer = bufferStateTracker.getBoundBufferObject(target, caller); - if (0 != buffer) { - return getBufferSizeImpl(target, buffer, caller); - } - // We don't know what's going on in this case; query the GL for an answer - // FIXME: both functions return 'int' types, which is not suitable, - // since buffer lenght is 64bit ? - int[] tmp = new int[1]; - caller.glGetBufferParameteriv(target, GL.GL_BUFFER_SIZE, tmp, 0); - if (DEBUG) { - System.err.println("GLBufferSizeTracker.getBufferSize(): no cached buffer information"); - } - return tmp[0]; - } - - public final long getDirectStateBufferSize(int buffer, GL caller) { - return getBufferSizeImpl(0, buffer, caller); - } - - private final long getBufferSizeImpl(int target, int buffer, GL caller) { - // See whether we know the size of this buffer object; at this - // point we almost certainly should if the application is - // written correctly - long sz = bufferSizeMap.get(buffer); - if (sizeNotFount == sz) { - // For robustness, try to query this value from the GL as we used to - // FIXME: both functions return 'int' types, which is not suitable, - // since buffer lenght is 64bit ? - int[] tmp = new int[1]; - if(0==target) { - // DirectState .. - if(caller.isFunctionAvailable("glGetNamedBufferParameterivEXT")) { - caller.getGL2().glGetNamedBufferParameterivEXT(buffer, GL.GL_BUFFER_SIZE, tmp, 0); - } else { - throw new GLException("Error: getDirectStateBufferSize called with unknown state and GL function 'glGetNamedBufferParameterivEXT' n/a to query size"); - } - } else { - caller.glGetBufferParameteriv(target, GL.GL_BUFFER_SIZE, tmp, 0); - } - if (tmp[0] == 0) { - // Assume something is wrong rather than silently going along - throw new GLException("Error: buffer size returned by "+ - ((0==target)?"glGetNamedBufferParameterivEXT":"glGetBufferParameteriv")+ - " was zero; probably application error"); - } - // Assume we just don't know what's happening - sz = tmp[0]; - bufferSizeMap.put(buffer, sz); - if (DEBUG) { - System.err.println("GLBufferSizeTracker.getBufferSize(): made slow query to cache size " + - sz + - " for buffer " + - buffer); - } - } - return sz; - } - - // This should be called on any major event where we might start - // producing wrong answers, such as OpenGL context creation and - // destruction if we don't know whether there are other currently- - // created contexts that might be keeping the buffer objects alive - // that we're dealing with - public final void clearCachedBufferSizes() { - bufferSizeMap.clear(); - } -} diff --git a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java index 304c8ec32..511c1b9b9 100644 --- a/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java +++ b/src/jogl/classes/jogamp/opengl/GLBufferStateTracker.java @@ -102,14 +102,92 @@ public class GLBufferStateTracker { // Start with known unbound targets for known keys // setBoundBufferObject(GL2ES3.GL_VERTEX_ARRAY_BINDING, 0); // not using default VAO (removed in GL3 core) - only explicit setBoundBufferObject(GL.GL_ARRAY_BUFFER, 0); + setBoundBufferObject(GL4.GL_DRAW_INDIRECT_BUFFER, 0); setBoundBufferObject(GL.GL_ELEMENT_ARRAY_BUFFER, 0); setBoundBufferObject(GL2.GL_PIXEL_PACK_BUFFER, 0); setBoundBufferObject(GL2.GL_PIXEL_UNPACK_BUFFER, 0); - setBoundBufferObject(GL4.GL_DRAW_INDIRECT_BUFFER, 0); } - public final void setBoundBufferObject(int target, int value) { - bindingMap.put(target, value); + + /** + * GL_ARRAY_BUFFER​, + * GL_ATOMIC_COUNTER_BUFFER​, + * GL_COPY_READ_BUFFER​, + * GL_COPY_WRITE_BUFFER​, + * GL_DRAW_INDIRECT_BUFFER​, + * GL_DISPATCH_INDIRECT_BUFFER​, + * GL_ELEMENT_ARRAY_BUFFER​, + * GL_PIXEL_PACK_BUFFER​, + * GL_PIXEL_UNPACK_BUFFER​, + * GL_SHADER_STORAGE_BUFFER​, + * GL_TEXTURE_BUFFER​, + * GL_TRANSFORM_FEEDBACK_BUFFER​ or + * GL_UNIFORM_BUFFER​. + * + * GL_VERTEX_ARRAY_BINDING + * + */ + private static final int getQueryName(final int target) { + switch (target) { + case GL.GL_ARRAY_BUFFER: return GL.GL_ARRAY_BUFFER_BINDING; + case GL4.GL_ATOMIC_COUNTER_BUFFER: return GL4.GL_ATOMIC_COUNTER_BUFFER_BINDING; + case GL2ES3.GL_COPY_READ_BUFFER: return GL2ES3.GL_COPY_READ_BUFFER_BINDING; + case GL2ES3.GL_COPY_WRITE_BUFFER: return GL2ES3.GL_COPY_WRITE_BUFFER_BINDING; + case GL4.GL_DRAW_INDIRECT_BUFFER: return GL4.GL_DRAW_INDIRECT_BUFFER_BINDING; + case GL4.GL_DISPATCH_INDIRECT_BUFFER: return GL4.GL_DISPATCH_INDIRECT_BUFFER_BINDING; + case GL.GL_ELEMENT_ARRAY_BUFFER: return GL.GL_ELEMENT_ARRAY_BUFFER_BINDING; + case GL2.GL_PIXEL_PACK_BUFFER: return GL2.GL_PIXEL_PACK_BUFFER_BINDING; + case GL2.GL_PIXEL_UNPACK_BUFFER: return GL2.GL_PIXEL_UNPACK_BUFFER_BINDING; + // FIXME case GL4.GL_QUERY_BUFFER: return GL4.GL_QUERY_BUFFER_BINDING; + case GL4.GL_SHADER_STORAGE_BUFFER: return GL4.GL_SHADER_STORAGE_BUFFER_BINDING; + case GL2GL3.GL_TEXTURE_BUFFER: return GL2GL3.GL_TEXTURE_BINDING_BUFFER; + case GL2ES3.GL_TRANSFORM_FEEDBACK_BUFFER: return GL2ES3.GL_TRANSFORM_FEEDBACK_BUFFER_BINDING; + case GL2ES3.GL_UNIFORM_BUFFER: return GL2ES3.GL_UNIFORM_BUFFER_BINDING; + + case GL2ES3.GL_VERTEX_ARRAY_BINDING: return GL2ES3.GL_VERTEX_ARRAY_BINDING; + + default: + throw new GLException(String.format("GL_INVALID_ENUM​: Invalid binding target 0x%X", target)); + } + } + private static final void checkTargetName(final int target) { + switch (target) { + case GL.GL_ARRAY_BUFFER: + case GL4.GL_ATOMIC_COUNTER_BUFFER: + case GL2ES3.GL_COPY_READ_BUFFER: + case GL2ES3.GL_COPY_WRITE_BUFFER: + case GL4.GL_DRAW_INDIRECT_BUFFER: + case GL4.GL_DISPATCH_INDIRECT_BUFFER: + case GL.GL_ELEMENT_ARRAY_BUFFER: + case GL2.GL_PIXEL_PACK_BUFFER: + case GL2.GL_PIXEL_UNPACK_BUFFER: + // FIXME case GL4.GL_QUERY_BUFFER: + case GL4.GL_SHADER_STORAGE_BUFFER: + case GL2GL3.GL_TEXTURE_BUFFER: + case GL2ES3.GL_TRANSFORM_FEEDBACK_BUFFER: + case GL2ES3.GL_UNIFORM_BUFFER: + + case GL2ES3.GL_VERTEX_ARRAY_BINDING: + return; + + default: + throw new GLException(String.format("GL_INVALID_ENUM​: Invalid binding target 0x%X", target)); + } + } + + /** + * Must be called when binding a buffer, e.g.: + *
          + *
        • glBindBuffer
        • + *
        • glBindBufferBase
        • + *
        • glBindBufferRange
        • + *
        + * @param target + * @param bufferName + */ + public final void setBoundBufferObject(int target, int bufferName) { + checkTargetName(target); + final int oldBufferName = bindingMap.put(target, bufferName); /*** * Test for clearing bound buffer states when unbinding VAO, * Bug 692 Comment 5 is invalid, i.e. . @@ -117,8 +195,8 @@ public class GLBufferStateTracker { * after unbinding a VAO w/o unbinding the VBOs resulted to no visible image. * Leaving code in here for discussion - in case I am wrong. * - final int pre = bindingMap.put(target, value); - if( GL2ES3.GL_VERTEX_ARRAY_BINDING == target && keyNotFound != pre && 0 == value ) { + final int pre = bindingMap.put(target, bufferName); + if( GL2ES3.GL_VERTEX_ARRAY_BINDING == target && keyNotFound != pre && 0 == bufferName ) { // Unbinding a previous bound VAO leads to unbinding of all buffers! bindingMap.put(GL.GL_ARRAY_BUFFER, 0); bindingMap.put(GL.GL_ELEMENT_ARRAY_BUFFER, 0); @@ -127,38 +205,12 @@ public class GLBufferStateTracker { bindingMap.put(GL4.GL_DRAW_INDIRECT_BUFFER, 0); } */ if (DEBUG) { - System.err.println("GLBufferStateTracker.setBoundBufferObject() target 0x" + - Integer.toHexString(target) + " -> mapped bound buffer 0x" + - Integer.toHexString(value)); + System.err.println("GLBufferStateTracker.setBoundBufferObject() target " + + toHexString(target) + ": " + toHexString(oldBufferName) + " -> " + toHexString(bufferName)); // Thread.dumpStack(); } } - public static final int getQueryName(final int target) { - switch (target) { - case GL.GL_ARRAY_BUFFER: return GL.GL_ARRAY_BUFFER_BINDING; - case GL.GL_ELEMENT_ARRAY_BUFFER: return GL.GL_ELEMENT_ARRAY_BUFFER_BINDING; - - case GL2ES3.GL_VERTEX_ARRAY_BINDING: return GL2ES3.GL_VERTEX_ARRAY_BINDING; - case GL2ES3.GL_COPY_READ_BUFFER: return GL2ES3.GL_COPY_READ_BUFFER_BINDING; - case GL2ES3.GL_COPY_WRITE_BUFFER: return GL2ES3.GL_COPY_WRITE_BUFFER_BINDING; - case GL2ES3.GL_TRANSFORM_FEEDBACK_BUFFER: return GL2ES3.GL_TRANSFORM_FEEDBACK_BUFFER_BINDING; - case GL2ES3.GL_UNIFORM_BUFFER: return GL2ES3.GL_UNIFORM_BUFFER_BINDING; - - case GL2GL3.GL_TEXTURE_BUFFER: return GL2GL3.GL_TEXTURE_BINDING_BUFFER; - - case GL2.GL_PIXEL_PACK_BUFFER: return GL2.GL_PIXEL_PACK_BUFFER_BINDING; - case GL2.GL_PIXEL_UNPACK_BUFFER: return GL2.GL_PIXEL_UNPACK_BUFFER_BINDING; - - case GL4.GL_DRAW_INDIRECT_BUFFER: return GL4.GL_DRAW_INDIRECT_BUFFER_BINDING; - case GL4.GL_ATOMIC_COUNTER_BUFFER: return GL4.GL_ATOMIC_COUNTER_BUFFER_BINDING; - case GL4.GL_DISPATCH_INDIRECT_BUFFER: return GL4.GL_DISPATCH_INDIRECT_BUFFER_BINDING; - case GL4.GL_SHADER_STORAGE_BUFFER: return GL4.GL_SHADER_STORAGE_BUFFER_BINDING; - // case GL4.GL_QUERY_BUFFER: return GL4.GL_QUERY_BUFFER_BINDING; - default: return 0; - } - } - /** Note: returns an unspecified value if the binding for the specified target (e.g. GL_ARRAY_BUFFER) is currently unknown. You must use isBoundBufferObjectKnown() to see whether the @@ -180,9 +232,9 @@ public class GLBufferStateTracker { value = 0; } if (DEBUG) { - System.err.println("GLBufferStateTracker.getBoundBufferObject() glerr[pre 0x"+Integer.toHexString(glerrPre)+", post 0x"+Integer.toHexString(glerrPost)+"], [queried value]: target 0x" + - Integer.toHexString(target) + " / query 0x"+Integer.toHexString(queryTarget)+ - " -> mapped bound buffer 0x" + Integer.toHexString(value)); + System.err.println("GLBufferStateTracker.getBoundBufferObject() glerr[pre "+toHexString(glerrPre)+", post "+toHexString(glerrPost)+"], [queried value]: target " + + toHexString(target) + " / query "+toHexString(queryTarget)+ + " -> mapped bound buffer " + toHexString(value)); } setBoundBufferObject(target, value); return value; @@ -204,11 +256,12 @@ public class GLBufferStateTracker { from GLContext.makeCurrent() in the future to possibly increase the robustness of these caches in the face of external native code manipulating OpenGL state. */ - public final void clearBufferObjectState() { + public final void clear() { + if (DEBUG) { + System.err.println("GLBufferStateTracker.clear() - Thread "+Thread.currentThread().getName()); + // Thread.dumpStack(); + } bindingMap.clear(); - if (DEBUG) { - System.err.println("GLBufferStateTracker.clearBufferObjectState()"); - //Thread.dumpStack(); - } } + private final String toHexString(int i) { return Integer.toHexString(i); } } diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 66eed9d96..ee9f315c8 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -100,9 +100,9 @@ public abstract class GLContextImpl extends GLContext { private String glRendererLowerCase; private String glVersion; - // Tracks creation and initialization of buffer objects to avoid + // Tracks lifecycle of buffer objects to avoid // repeated glGet calls upon glMapBuffer operations - private final GLBufferSizeTracker bufferSizeTracker; + private final GLBufferObjectTracker bufferObjectTracker; private final GLBufferStateTracker bufferStateTracker; private final GLStateTracker glStateTracker = new GLStateTracker(); private GLDebugMessageHandler glDebugHandler = null; @@ -141,10 +141,10 @@ public abstract class GLContextImpl extends GLContext { bufferStateTracker = new GLBufferStateTracker(); if ( null != shareWith ) { GLContextShareSet.registerSharing(this, shareWith); - bufferSizeTracker = ((GLContextImpl)shareWith).getBufferSizeTracker(); - assert (bufferSizeTracker != null) : "shared context hash null bufferSizeTracker: "+shareWith; + bufferObjectTracker = ((GLContextImpl)shareWith).getBufferObjectTracker(); + assert (bufferObjectTracker != null) : "shared context hash null GLBufferObjectTracker: "+shareWith; } else { - bufferSizeTracker = new GLBufferSizeTracker(); + bufferObjectTracker = new GLBufferObjectTracker(); } this.drawable = drawable; @@ -155,9 +155,9 @@ public abstract class GLContextImpl extends GLContext { private final void clearStates() { if( !GLContextShareSet.hasCreatedSharedLeft(this) ) { - bufferSizeTracker.clearCachedBufferSizes(); + bufferObjectTracker.clear(); } - bufferStateTracker.clearBufferObjectState(); + bufferStateTracker.clear(); glStateTracker.setEnabled(false); glStateTracker.clearStates(); } @@ -2122,8 +2122,8 @@ public abstract class GLContextImpl extends GLContext { //---------------------------------------------------------------------- // Helpers for buffer object optimizations - public final GLBufferSizeTracker getBufferSizeTracker() { - return bufferSizeTracker; + public final GLBufferObjectTracker getBufferObjectTracker() { + return bufferObjectTracker; } public final GLBufferStateTracker getBufferStateTracker() { diff --git a/src/jogl/classes/jogamp/opengl/MemoryObject.java b/src/jogl/classes/jogamp/opengl/MemoryObject.java index ac02e0bca..6ebefc517 100644 --- a/src/jogl/classes/jogamp/opengl/MemoryObject.java +++ b/src/jogl/classes/jogamp/opengl/MemoryObject.java @@ -31,17 +31,18 @@ package jogamp.opengl; import java.nio.ByteBuffer; import java.util.HashMap; +import javax.media.opengl.GLBufferStorage; + import com.jogamp.common.util.HashUtil; /** - * + * @deprecated No more used for GL buffer storage tracking, see {@link GLBufferStorage} and {@link GLBufferObjectTracker}. */ public class MemoryObject { private final long addr; private final long size; private final int hash; private ByteBuffer buffer=null; - public MemoryObject(long addr, long size) { this.addr = addr; this.size = size; diff --git a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java index c329945c4..458a9c94f 100644 --- a/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java +++ b/src/jogl/classes/jogamp/opengl/util/glsl/fixedfunc/FixedFuncHook.java @@ -352,11 +352,11 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun @Override public void glVertexPointer(GLArrayData array) { if(array.isVBO()) { - if(!gl.glIsVBOArrayBound()) { + if(!gl.isVBOArrayBound()) { throw new GLException("VBO array is not enabled: "+array); } } else { - if(gl.glIsVBOArrayBound()) { + if(gl.isVBOArrayBound()) { throw new GLException("VBO array is not disabled: "+array); } Buffers.rangeCheck(array.getBuffer(), 1); @@ -373,7 +373,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun } @Override public void glVertexPointer(int size, int type, int stride, long pointer_buffer_offset) { - int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER); + int vboName = gl.getBoundBuffer(GL.GL_ARRAY_BUFFER); if(vboName==0) { throw new GLException("no GL_ARRAY_BUFFER VBO bound"); } @@ -384,11 +384,11 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun @Override public void glColorPointer(GLArrayData array) { if(array.isVBO()) { - if(!gl.glIsVBOArrayBound()) { + if(!gl.isVBOArrayBound()) { throw new GLException("VBO array is not enabled: "+array); } } else { - if(gl.glIsVBOArrayBound()) { + if(gl.isVBOArrayBound()) { throw new GLException("VBO array is not disabled: "+array); } Buffers.rangeCheck(array.getBuffer(), 1); @@ -404,7 +404,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun } @Override public void glColorPointer(int size, int type, int stride, long pointer_buffer_offset) { - int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER); + int vboName = gl.getBoundBuffer(GL.GL_ARRAY_BUFFER); if(vboName==0) { throw new GLException("no GL_ARRAY_BUFFER VBO bound"); } @@ -418,11 +418,11 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun throw new GLException("Only 3 components per normal allowed"); } if(array.isVBO()) { - if(!gl.glIsVBOArrayBound()) { + if(!gl.isVBOArrayBound()) { throw new GLException("VBO array is not enabled: "+array); } } else { - if(gl.glIsVBOArrayBound()) { + if(gl.isVBOArrayBound()) { throw new GLException("VBO array is not disabled: "+array); } Buffers.rangeCheck(array.getBuffer(), 1); @@ -438,7 +438,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun } @Override public void glNormalPointer(int type, int stride, long pointer_buffer_offset) { - int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER); + int vboName = gl.getBoundBuffer(GL.GL_ARRAY_BUFFER); if(vboName==0) { throw new GLException("no GL_ARRAY_BUFFER VBO bound"); } @@ -449,11 +449,11 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun @Override public void glTexCoordPointer(GLArrayData array) { if(array.isVBO()) { - if(!gl.glIsVBOArrayBound()) { + if(!gl.isVBOArrayBound()) { throw new GLException("VBO array is not enabled: "+array); } } else { - if(gl.glIsVBOArrayBound()) { + if(gl.isVBOArrayBound()) { throw new GLException("VBO array is not disabled: "+array); } Buffers.rangeCheck(array.getBuffer(), 1); @@ -470,7 +470,7 @@ public class FixedFuncHook implements GLLightingFunc, GLMatrixFunc, GLPointerFun } @Override public void glTexCoordPointer(int size, int type, int stride, long pointer_buffer_offset) { - int vboName = gl.glGetBoundBuffer(GL.GL_ARRAY_BUFFER); + int vboName = gl.getBoundBuffer(GL.GL_ARRAY_BUFFER); if(vboName==0) { throw new GLException("no GL_ARRAY_BUFFER VBO bound"); } -- cgit v1.2.3 From 1884e80891219f8d213d67f4da0b3b0aa31b86cc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 21 Jan 2014 20:06:00 +0100 Subject: windows test script --- make/scripts/tests-win.bat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 1158abdbb..5642cca6f 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -13,7 +13,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl2.awt.TestGea REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.awt.DemoGLJPanelPerf02AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.demos.gl3.newt.TestGeomShader01TextureGL3NEWT %* @@ -44,11 +44,13 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscre REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 %* + +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT %* -- cgit v1.2.3 From dff056e512f2ec732fadb24c3ed8176626ab5c27 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 22 Jan 2014 20:15:23 +0100 Subject: Bug 945 - Add test script to launch unit test from samba share on windows --- make/scripts/test-win32-smb_share.bat | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 make/scripts/test-win32-smb_share.bat (limited to 'make/scripts') diff --git a/make/scripts/test-win32-smb_share.bat b/make/scripts/test-win32-smb_share.bat new file mode 100755 index 000000000..d0166768a --- /dev/null +++ b/make/scripts/test-win32-smb_share.bat @@ -0,0 +1,33 @@ + +set SMB_ROOT=\\risa.goethel.localnet\deployment\test\jogamp + +set BLD_SUB=build-win32 +set J2RE_HOME=c:\jre1.7.0_45_x32 +set JAVA_HOME=c:\jdk1.7.0_45_x32 +set ANT_PATH=C:\apache-ant-1.8.2 + +set PROJECT_ROOT=%SMB_ROOT%\jogl +set BLD_DIR=%PROJECT_ROOT%\%BLD_SUB% + +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc53_lavf53_lavu51-ffmpeg\x32 +set FFMPEG_LIB=C:\ffmpeg_libav\lavc55_lavf55_lavu52-ffmpeg\x32 +REM set FFMPEG_LIB=C:\ffmpeg_libav\lavc54_lavf54_lavu52_lavr01-libav\x32 + +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20120127;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\angle\win32\20121010-chrome;%PATH% +REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%PROJECT_ROOT%\make\lib\external\PVRVFrame\OGLES-2.0\Windows_x86_32;%PATH% +set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;%FFMPEG_LIB%;%PATH% + +set D_ARGS="-Djogamp.debug=all" + +REM set LIB_DIR=..\..\gluegen\%BLD_SUB%\obj;%BLD_DIR%\lib +set LIB_DIR= + +set CP_ALL=.;%BLD_DIR%\jar\jogl-all.jar;%BLD_DIR%\jar\jogl-test.jar;%SMB_ROOT%\gluegen\%BLD_SUB%\gluegen-rt.jar;%SMB_ROOT%\gluegen\make\lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;%BLD_DIR%\..\make\lib\swt\win32-win32-x86\swt-debug.jar + +echo CP_ALL %CP_ALL% + +%J2RE_HOME%\bin\java -classpath %CP_ALL% %D_ARGS% %X_ARGS% com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT -time 3000 > java-win.log 2>&1 +tail java-win.log + -- cgit v1.2.3 From fbe00e6f5dca8043b40dd96f096fecc9424e0cc3 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 24 Jan 2014 05:16:05 +0100 Subject: Bug 948 - NVIDIA 331.38 (Linux X11) EGL impl. only supports _one_ EGL Display via eglGetDisplay(..) NVIDIA 331.38 (Linux X11) EGL impl. only supports _one_ EGL Display via eglGetDisplay. - Subsequent eglGetDisplay(..) calls fail. - Using the same 'global' egl-display does work though Remedy: Add 'GLRendererQuirks.SingletonEGLDisplayOnly' Detection of quirk is done as usual in GLContextImpl.setRendererQuirks(..), and EGLDrawableFactory passes the quirk, if detected, down to EGLDisplayUtil. The latter implements the singleton eglDisplay handle. EGLDisplayUtil: Cleaned up .. - EGLDisplayRef employs the reference handling incl. eglInitialize(..) and eglTerminate(), as well as the new singleton quirk. - Mark all internal methods 'private', to remove possible [untested] sideffects. --- make/scripts/tests.sh | 35 ++-- .../com/jogamp/opengl/GLRendererQuirks.java | 51 +++++- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 54 ++++-- .../classes/jogamp/opengl/egl/EGLDisplayUtil.java | 184 ++++++++++++--------- .../jogamp/opengl/egl/EGLDrawableFactory.java | 18 ++ .../media/nativewindow/DefaultGraphicsDevice.java | 2 +- 6 files changed, 234 insertions(+), 110 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 6bc1d4eb3..1b93ff7ae 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -109,7 +109,6 @@ function jrun() { #D_ARGS="-Djogl.debug.GLBufferObjectTracker -Djogl.debug.GLArrayData -Djogl.debug.TraceGL -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.GLSLCode" #D_ARGS="-Djogl.debug.GLSLCode -Djogl.debug.DebugGL" - #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLContext -Dnativewindow.debug.JAWT -Dnewt.debug.Window" #D_ARGS="-Dnativewindow.debug.JAWT -Djogl.debug.GLCanvas" #D_ARGS="-Dnativewindow.debug.JAWT -Djogamp.debug.TaskBase.TraceSource" @@ -131,13 +130,10 @@ function jrun() { #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.X11Util -Dnativewindow.debug.NativeWindow -Dnewt.debug.Display -Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Djogl.debug.Animator -Djogl.debug.GLDrawable -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug=all -Dnewt.debug=all" - #D_ARGS="-Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLCanvas" #D_ARGS="-Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLEventListenerState" #D_ARGS="-Djogl.fbo.force.none" - #D_ARGS="-Djogl.debug.EGLDrawableFactory.DontQuery -Djogl.debug.GLDrawable" - #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" #D_ARGS="-Djogl.debug.GLDebugMessageHandler" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.DebugGL" #D_ARGS="-Djogl.debug.GLDebugMessageHandler -Djogl.debug.TraceGL -Djogl.debug.DebugGL -Djogl.debug.GLSLCode -Djogl.debug.GLSLState" @@ -146,30 +142,29 @@ function jrun() { #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" - #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" - #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" - #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" - #D_ARGS="-Djogl.debug.GLMediaPlayer" - #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" - #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" - #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" - #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Screen" #D_ARGS="-Dnewt.test.Screen.disableRandR13" #D_ARGS="-Dnewt.test.Screen.disableScreenMode -Dnewt.debug.Screen" #D_ARGS="-Dnewt.debug.Screen -Djogl.debug.Animator" #D_ARGS="-Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" + #D_ARGS="-Djogl.debug.GLProfile" #D_ARGS="-Djogl.debug.GLContext -Djogamp.debug.NativeLibrary -Djogamp.debug.JNILibLoader -Djogl.debug.DebugGL -Djogl.debug.GLDebugMessageHandler" #D_ARGS="-Dnewt.debug.MainThread" #D_ARGS="-Dnativewindow.debug.GraphicsConfiguration -Dnativewindow.debug.NativeWindow" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Animator -Djogl.debug.GLDrawable -Djogl.debug.GLContext -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.ExtensionAvailabilityCache" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil" - #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile" - #D_ARGS="-Djogl.debug.GLProfile" + #D_ARGS="-Djogl.debug.EGLDrawableFactory.QueryNativeTK -Djogl.debug.GLDrawable" + #D_ARGS="-Djogamp.debug.ProcAddressHelper -Djogamp.debug.NativeLibrary -Djogamp.debug.NativeLibrary.Lookup -Djogamp.debug.JNILibLoader -Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsDevice" + #D_ARGS="-Djogl.debug.GLContext -Djogl.debug.GLProfile -Djogl.debug.GLDrawable -Djogl.debug.EGLDisplayUtil -Djogl.debug.EGLDrawableFactory.QueryNativeTK" + #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.GLDrawable" + #D_ARGS="-Djogl.debug.EGLDisplayUtil -Dnativewindow.debug.X11Util" + #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.TraceDisplayLifecycle -Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" + #D_ARGS="-Djogl.debug.EGLDisplayUtil -Djogl.debug.GLDrawable" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnewt.debug.Window -Dnewt.debug.Screen -Dnewt.debug.Display" #D_ARGS="-Djogl.debug.GLCanvas -Dnewt.debug.Window -Dnewt.debug.Display -Dnewt.debug.EDT -Djogl.debug.Animator" #D_ARGS="-Dnewt.debug.Display -Dnewt.debug.EDT -Dnewt.debug.Window" @@ -244,6 +239,12 @@ function jrun() { #X_ARGS="-verbose:jni" #X_ARGS="-Xrs" #X_ARGS="-Dsun.awt.disableMixing=true" + #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" + #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" + #D_ARGS="-Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" if [ $awton -eq 1 ] ; then export CLASSPATH=$JOGAMP_ALL_AWT_CLASSPATH @@ -332,7 +333,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -400,7 +401,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestRedSquareES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index daa0d94dd..0ac0c0f03 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -31,6 +31,8 @@ import java.util.IdentityHashMap; import javax.media.nativewindow.AbstractGraphicsDevice; +import com.jogamp.common.os.Platform; + import jogamp.opengl.egl.EGL; import jogamp.opengl.egl.EGLExt; @@ -70,7 +72,13 @@ public class GLRendererQuirks { /** SIGSEGV on setSwapInterval() after changing the context's drawable w/ 'Mesa 8.0.4' dri2SetSwapInterval/DRI2 (soft & intel) */ public static final int NoSetSwapIntervalPostRetarget = 4; - /** GLSL discard command leads to undefined behavior or won't get compiled if being used. Appears to have happened on Nvidia Tegra2, but seems to be fine now. FIXME: Constrain version. */ + /** + * GLSL discard command leads to undefined behavior or won't get compiled if being used. + *

        + * Appears to have happened on Nvidia Tegra2, but seems to be fine now.
        + * FIXME: Constrain version. + *

        + */ public static final int GLSLBuggyDiscard = 5; /** @@ -256,15 +264,36 @@ public class GLRendererQuirks { */ public static final int GLES3ViaEGLES2Config = 15; + /** + * Bug 948 - NVIDIA 331.38 (Linux X11) EGL impl. only supports _one_ EGL Device via {@link EGL#eglGetDisplay(long)}. + *

        + * Subsequent calls to {@link EGL#eglGetDisplay(long)} fail. + *

        + *

        + * Reusing global EGL display works. + *

        + *
          + *
        • EGL_VENDOR NVIDIA
        • + *
        • EGL_VERSION 1.4
        • + *
        • GL_VENDOR NVIDIA Corporation
        • + *
        • Platform X11
        • + *
        • CPU Family {@link Platform.CPUFamily#X86}
        • + *
        + *

        + * FIXME: Constrain driver version. + *

        + */ + public static final int SingletonEGLDisplayOnly = 16; + /** Number of quirks known. */ - public static final int COUNT = 16; + public static final int COUNT = 17; private static final String[] _names = new String[] { "NoDoubleBufferedPBuffer", "NoDoubleBufferedBitmap", "NoSetSwapInterval", "NoOffscreenBitmap", "NoSetSwapIntervalPostRetarget", "GLSLBuggyDiscard", "GLNonCompliant", "GLFlushBeforeRelease", "DontCloseX11Display", "NeedCurrCtx4ARBPixFmtQueries", "NeedCurrCtx4ARBCreateContext", "NoFullFBOSupport", "GLSLNonCompliant", "GL4NeedsGL3Request", - "GLSharedContextBuggy", "GLES3ViaEGLES2Config" + "GLSharedContextBuggy", "GLES3ViaEGLES2Config", "SingletonEGLDisplayOnly" }; private static final IdentityHashMap stickyDeviceQuirks = new IdentityHashMap(); @@ -272,8 +301,12 @@ public class GLRendererQuirks { /** * Retrieval of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}. *

        + * The {@link AbstractGraphicsDevice}s are mapped via their {@link AbstractGraphicsDevice#getUniqueID()}. + *

        + *

        * Not thread safe. *

        + * @see #areSameStickyDevice(AbstractGraphicsDevice, AbstractGraphicsDevice) */ public static GLRendererQuirks getStickyDeviceQuirks(AbstractGraphicsDevice device) { final String key = device.getUniqueID(); @@ -288,11 +321,20 @@ public class GLRendererQuirks { return res; } + /** + * Returns true if both devices have the same {@link AbstractGraphicsDevice#getUniqueID()}, + * otherwise false. + */ + public static boolean areSameStickyDevice(AbstractGraphicsDevice device1, AbstractGraphicsDevice device2) { + return device1.getUniqueID() == device2.getUniqueID(); + } + /** * {@link #addQuirks(int[], int, int) Adding given quirks} of sticky {@link AbstractGraphicsDevice}'s {@link GLRendererQuirks}. *

        * Not thread safe. *

        + * @see #getStickyDeviceQuirks(AbstractGraphicsDevice) */ public static void addStickyDeviceQuirks(AbstractGraphicsDevice device, int[] quirks, int offset, int len) throws IllegalArgumentException { final GLRendererQuirks sq = getStickyDeviceQuirks(device); @@ -303,6 +345,7 @@ public class GLRendererQuirks { *

        * Not thread safe. *

        + * @see #getStickyDeviceQuirks(AbstractGraphicsDevice) */ public static void addStickyDeviceQuirks(AbstractGraphicsDevice device, GLRendererQuirks quirks) throws IllegalArgumentException { final GLRendererQuirks sq = getStickyDeviceQuirks(device); @@ -313,6 +356,7 @@ public class GLRendererQuirks { *

        * Not thread safe. However, use after changing the sticky quirks is safe. *

        + * @see #getStickyDeviceQuirks(AbstractGraphicsDevice) */ public static boolean existStickyDeviceQuirk(AbstractGraphicsDevice device, int quirk) { return getStickyDeviceQuirks(device).exist(quirk); @@ -323,6 +367,7 @@ public class GLRendererQuirks { *

        * Not thread safe. However, use after changing the sticky quirks is safe. *

        + * @see #getStickyDeviceQuirks(AbstractGraphicsDevice) */ public static void pushStickyDeviceQuirks(AbstractGraphicsDevice device, GLRendererQuirks dest) { dest.addQuirks(getStickyDeviceQuirks(device)); diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 417dbd011..652fc6ba9 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1548,7 +1548,9 @@ public abstract class GLContextImpl extends GLContext { final VersionNumberString vendorVersion = GLVersionNumber.createVendorVersion(glVersion); - setRendererQuirks(adevice, reqGLVersion.getMajor(), reqGLVersion.getMinor(), reqCtxProfileBits, major, minor, ctxProfileBits, vendorVersion, withinGLVersionsMapping); + setRendererQuirks(adevice, getDrawableImpl().getFactoryImpl(), + reqGLVersion.getMajor(), reqGLVersion.getMinor(), reqCtxProfileBits, + major, minor, ctxProfileBits, vendorVersion, withinGLVersionsMapping); if( strictMatch && glRendererQuirks.exist(GLRendererQuirks.GLNonCompliant) ) { if(DEBUG) { @@ -1665,7 +1667,7 @@ public abstract class GLContextImpl extends GLContext { return true; } - private final void setRendererQuirks(final AbstractGraphicsDevice adevice, + private final void setRendererQuirks(final AbstractGraphicsDevice adevice, final GLDrawableFactoryImpl factory, int reqMajor, int reqMinor, int reqCTP, int major, int minor, int ctp, final VersionNumberString vendorVersion, boolean withinGLVersionsMapping) { @@ -1688,16 +1690,26 @@ public abstract class GLContextImpl extends GLContext { // General Quirks // if( esCtx ) { - final int quirk = GLRendererQuirks.GLES3ViaEGLES2Config; - if( GLRendererQuirks.existStickyDeviceQuirk( GLDrawableFactory.getEGLFactory().getDefaultDevice(), GLRendererQuirks.GLES3ViaEGLES2Config) ) { - // Merge default sticky quirk! + if( 2 == reqMajor && 2 < major ) { + final int quirk = GLRendererQuirks.GLES3ViaEGLES2Config; if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: Default EGL Device"); + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: ES req "+reqMajor+" and 2 < "+major); } quirks[i++] = quirk; - } else if( 2 == reqMajor && 2 < major ) { + if( withinGLVersionsMapping ) { + // Thread safe due to single threaded initialization! + GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1); + } else { + // FIXME: Remove when moving EGL/ES to ARB ctx creation + synchronized(GLContextImpl.class) { + GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1); + } + } + } + if( isX11 && isDriverNVIDIAGeForce && Platform.CPUFamily.X86 == Platform.getCPUFamily() ) { + final int quirk = GLRendererQuirks.SingletonEGLDisplayOnly; if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: ES req "+reqMajor+" and 2 < "+major); + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: ES, X11, CPUFamily AMD/Intel, [Vendor "+glVendor+" or Renderer "+glRenderer+"]"); } quirks[i++] = quirk; if( withinGLVersionsMapping ) { @@ -1794,14 +1806,14 @@ public abstract class GLContextImpl extends GLContext { if( glRenderer.contains("PowerVR") ) { final int quirk = GLRendererQuirks.NoSetSwapInterval; if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + " / Renderer " + glRenderer); + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + ", Renderer " + glRenderer); } quirks[i++] = quirk; } if( glRenderer.contains("Immersion.16") ) { final int quirk = GLRendererQuirks.GLSharedContextBuggy; if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + " / Renderer " + glRenderer); + System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: OS "+Platform.getOSType() + ", Renderer " + glRenderer); } quirks[i++] = quirk; } @@ -1906,9 +1918,27 @@ public abstract class GLContextImpl extends GLContext { } glRendererQuirks = new GLRendererQuirks(quirks, 0, i); - GLRendererQuirks.pushStickyDeviceQuirks(adevice, glRendererQuirks); // Thread safe due to single threaded initialization! if(DEBUG) { - System.err.println("Quirks local: "+glRendererQuirks); + System.err.println("Quirks local.0: "+glRendererQuirks); + } + { + // Merge sticky quirks, thread safe due to single threaded initialization! + GLRendererQuirks.pushStickyDeviceQuirks(adevice, glRendererQuirks); + + final AbstractGraphicsDevice factoryDefaultDevice = factory.getDefaultDevice(); + if( !GLRendererQuirks.areSameStickyDevice(factoryDefaultDevice, adevice) ) { + GLRendererQuirks.pushStickyDeviceQuirks(factoryDefaultDevice, glRendererQuirks); + } + if( esCtx ) { + final AbstractGraphicsDevice eglFactoryDefaultDevice = GLDrawableFactory.getEGLFactory().getDefaultDevice(); + if( !GLRendererQuirks.areSameStickyDevice(eglFactoryDefaultDevice, adevice) && + !GLRendererQuirks.areSameStickyDevice(eglFactoryDefaultDevice, factoryDefaultDevice) ) { + GLRendererQuirks.pushStickyDeviceQuirks(eglFactoryDefaultDevice, glRendererQuirks); + } + } + } + if(DEBUG) { + System.err.println("Quirks local.X: "+glRendererQuirks); System.err.println("Quirks sticky on "+adevice+": "+GLRendererQuirks.getStickyDeviceQuirks(adevice)); } } diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java index a1899e032..c5f76f667 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDisplayUtil.java @@ -49,57 +49,120 @@ import com.jogamp.nativewindow.egl.EGLGraphicsDevice; * and eglTerminate(..) is issued only for the last call. *

        * This class is required, due to implementation bugs within EGL where {@link EGL#eglTerminate(long)} - * does not mark the resource for deletion when still in use, bug releases them immediatly. + * does not mark the resource for deletion when still in use, bug releases them immediately. *

        */ public class EGLDisplayUtil { - protected static final boolean DEBUG = Debug.debug("EGLDisplayUtil"); + private static final boolean DEBUG = Debug.debug("EGLDisplayUtil"); + private static boolean useSingletonEGLDisplay = false; + private static EGLDisplayRef singletonEGLDisplay = null; - private static class DpyCounter { + private static class EGLDisplayRef { final long eglDisplay; final Throwable createdStack; - int refCount; + int initRefCount; - private DpyCounter(long eglDisplay) { + /** + * Returns an already opened {@link EGLDisplayRef} or opens a new {@link EGLDisplayRef}. + *

        + * Opened {@link EGLDisplayRef}s are mapped against their eglDisplay handle. + *

        + *

        + * Method utilizes {@link EGLDisplayRef}'s reference counter, i.e. increases it. + *

        + *

        + * An {@link EGLDisplayRef} is opened via {@link EGL#eglInitialize(long, IntBuffer, IntBuffer)}. + *

        + */ + static EGLDisplayRef getOrCreateOpened(final long eglDisplay, final IntBuffer major, final IntBuffer minor) { + EGLDisplayRef o = (EGLDisplayRef) openEGLDisplays.get(eglDisplay); + if( null == o ) { + if( EGL.eglInitialize(eglDisplay, major, minor) ) { + final EGLDisplayRef n = new EGLDisplayRef(eglDisplay); + openEGLDisplays.put(eglDisplay, n); + n.initRefCount++; + if( null == singletonEGLDisplay ) { + singletonEGLDisplay = n; + } + return n; + } else { + return null; + } + } else { + o.initRefCount++; + return o; + } + } + + /** + * Closes an already opened {@link EGLDisplayRef}. + *

        + * Method decreases a reference counter and closes the {@link EGLDisplayRef} if it reaches zero. + *

        + *

        + * An {@link EGLDisplayRef} is closed via {@link EGL#eglTerminate(long)}. + *

        + */ + static EGLDisplayRef closeOpened(final long eglDisplay, final boolean[] res) { + final EGLDisplayRef o = (EGLDisplayRef) openEGLDisplays.get(eglDisplay); + res[0] = true; + if( null != o ) { + if( 0 < o.initRefCount ) { // no negative refCount + o.initRefCount--; + if( 0 == o.initRefCount ) { + res[0] = EGL.eglTerminate(eglDisplay); + if( o == singletonEGLDisplay ) { + singletonEGLDisplay = null; + } + } + } + if( 0 >= o.initRefCount ) { + openEGLDisplays.remove(eglDisplay); + } + } + return o; + } + + private EGLDisplayRef(long eglDisplay) { this.eglDisplay = eglDisplay; - this.refCount = 0; + this.initRefCount = 0; this.createdStack = DEBUG ? new Throwable() : null; } @Override public String toString() { - return "EGLDisplay[0x"+Long.toHexString(eglDisplay)+": refCnt "+refCount+"]"; + return "EGLDisplayRef[0x"+Long.toHexString(eglDisplay)+": refCnt "+initRefCount+"]"; } } - static final LongObjectHashMap eglDisplayCounter; + private static final LongObjectHashMap openEGLDisplays; static { - eglDisplayCounter = new LongObjectHashMap(); - eglDisplayCounter.setKeyNotFoundValue(null); + openEGLDisplays = new LongObjectHashMap(); + openEGLDisplays.setKeyNotFoundValue(null); } /** * @return number of unclosed EGL Displays.
        */ public static int shutdown(boolean verbose) { - if(DEBUG || verbose || eglDisplayCounter.size() > 0 ) { - System.err.println("EGLDisplayUtil.EGLDisplays: Shutdown (open: "+eglDisplayCounter.size()+")"); + if(DEBUG || verbose || openEGLDisplays.size() > 0 ) { + System.err.println("EGLDisplayUtil.EGLDisplays: Shutdown (open: "+openEGLDisplays.size()+")"); if(DEBUG) { Thread.dumpStack(); } - if( eglDisplayCounter.size() > 0) { + if( openEGLDisplays.size() > 0) { dumpOpenDisplayConnections(); } } - return eglDisplayCounter.size(); + return openEGLDisplays.size(); } public static void dumpOpenDisplayConnections() { - System.err.println("EGLDisplayUtil: Open EGL Display Connections: "+eglDisplayCounter.size()); + System.err.println("EGLDisplayUtil: Open EGL Display Connections: "+openEGLDisplays.size()); int i=0; - for(Iterator iter = eglDisplayCounter.iterator(); iter.hasNext(); i++) { + for(Iterator iter = openEGLDisplays.iterator(); iter.hasNext(); i++) { final LongObjectHashMap.Entry e = iter.next(); - final DpyCounter v = (DpyCounter) e.value; + final EGLDisplayRef v = (EGLDisplayRef) e.value; System.err.println("EGLDisplayUtil: Open["+i+"]: 0x"+Long.toHexString(e.key)+": "+v); if(null != v.createdStack) { v.createdStack.printStackTrace(); @@ -107,12 +170,22 @@ public class EGLDisplayUtil { } } - public static long eglGetDisplay(long nativeDisplay_id) { + /* pp */ static synchronized void setSingletonEGLDisplayOnly(boolean v) { useSingletonEGLDisplay = v; } + + private static synchronized long eglGetDisplay(long nativeDisplay_id) { + if( useSingletonEGLDisplay && null != singletonEGLDisplay ) { + if(DEBUG) { + System.err.println("EGLDisplayUtil.eglGetDisplay.s: eglDisplay("+EGLContext.toHexString(nativeDisplay_id)+"): "+ + EGLContext.toHexString(singletonEGLDisplay.eglDisplay)+ + ", "+((EGL.EGL_NO_DISPLAY != singletonEGLDisplay.eglDisplay)?"OK":"Failed")+", singletonEGLDisplay "+singletonEGLDisplay+" (use "+useSingletonEGLDisplay+")"); + } + return singletonEGLDisplay.eglDisplay; + } final long eglDisplay = EGL.eglGetDisplay(nativeDisplay_id); if(DEBUG) { - System.err.println("EGLDisplayUtil.eglGetDisplay(): eglDisplay("+EGLContext.toHexString(nativeDisplay_id)+"): "+ + System.err.println("EGLDisplayUtil.eglGetDisplay.X: eglDisplay("+EGLContext.toHexString(nativeDisplay_id)+"): "+ EGLContext.toHexString(eglDisplay)+ - ", "+((EGL.EGL_NO_DISPLAY != eglDisplay)?"OK":"Failed")); + ", "+((EGL.EGL_NO_DISPLAY != eglDisplay)?"OK":"Failed")+", singletonEGLDisplay "+singletonEGLDisplay+" (use "+useSingletonEGLDisplay+")"); } return eglDisplay; } @@ -125,39 +198,16 @@ public class EGLDisplayUtil { * * @see EGL#eglInitialize(long, IntBuffer, IntBuffer) */ - public static synchronized boolean eglInitialize(long eglDisplay, IntBuffer major, IntBuffer minor) { + private static synchronized boolean eglInitialize(long eglDisplay, IntBuffer major, IntBuffer minor) { if( EGL.EGL_NO_DISPLAY == eglDisplay) { return false; } - final int refCnt; - final DpyCounter d; - { - DpyCounter _d = (DpyCounter) eglDisplayCounter.get(eglDisplay); - if(null == _d) { - _d = new DpyCounter(eglDisplay); - refCnt = 1; // 1st init - } else { - refCnt = _d.refCount + 1; - } - d = _d; - } - final boolean res; - if(1==refCnt) { // only initialize once - res = EGL.eglInitialize(eglDisplay, major, minor); - } else { - res = true; - } - if(res) { // update refCount and map if successfully initialized, only - d.refCount = refCnt; - if(1 == refCnt) { - eglDisplayCounter.put(eglDisplay, d); - } - } + final EGLDisplayRef d = EGLDisplayRef.getOrCreateOpened(eglDisplay, major, minor); if(DEBUG) { - System.err.println("EGLDisplayUtil.eglInitialize("+EGLContext.toHexString(eglDisplay)+" ...): #"+refCnt+", "+d+" = "+res); + System.err.println("EGLDisplayUtil.eglInitialize("+EGLContext.toHexString(eglDisplay)+" ...): "+d+" = "+(null != d)+", singletonEGLDisplay "+singletonEGLDisplay+" (use "+useSingletonEGLDisplay+")"); // Thread.dumpStack(); } - return res; + return null != d; } /** @@ -172,14 +222,14 @@ public class EGLDisplayUtil { * @see #eglGetDisplay(long) * @see #eglInitialize(long, IntBuffer, IntBuffer) */ - public static synchronized int eglGetDisplayAndInitialize(long nativeDisplayID, long[] eglDisplay, int[] eglErr, IntBuffer major, IntBuffer minor) { + private static synchronized int eglGetDisplayAndInitialize(long nativeDisplayID, long[] eglDisplay, int[] eglErr, IntBuffer major, IntBuffer minor) { eglDisplay[0] = EGL.EGL_NO_DISPLAY; - final long _eglDisplay = EGLDisplayUtil.eglGetDisplay( nativeDisplayID ); + final long _eglDisplay = eglGetDisplay( nativeDisplayID ); if ( EGL.EGL_NO_DISPLAY == _eglDisplay ) { eglErr[0] = EGL.eglGetError(); return EGL.EGL_BAD_DISPLAY; } - if ( !EGLDisplayUtil.eglInitialize( _eglDisplay, major, minor) ) { + if ( !eglInitialize( _eglDisplay, major, minor) ) { eglErr[0] = EGL.eglGetError(); return EGL.EGL_NOT_INITIALIZED; } @@ -197,7 +247,7 @@ public class EGLDisplayUtil { * @return the initialized EGL display ID * @throws GLException if not successful */ - public static synchronized long eglGetDisplayAndInitialize(long[] nativeDisplayID) { + private static synchronized long eglGetDisplayAndInitialize(long[] nativeDisplayID) { final long[] eglDisplay = new long[1]; final int[] eglError = new int[1]; int eglRes = EGLDisplayUtil.eglGetDisplayAndInitialize(nativeDisplayID[0], eglDisplay, eglError, null, null); @@ -221,40 +271,20 @@ public class EGLDisplayUtil { * @param eglDisplay the EGL display handle * @return true if the eglDisplay is valid and it's reference counter becomes zero and {@link EGL#eglTerminate(long)} was successful, otherwise false */ - public static synchronized boolean eglTerminate(long eglDisplay) { + private static synchronized boolean eglTerminate(long eglDisplay) { if( EGL.EGL_NO_DISPLAY == eglDisplay) { return false; } - final boolean res; - final int refCnt; - final DpyCounter d; - { - DpyCounter _d = (DpyCounter) eglDisplayCounter.get(eglDisplay); - if(null == _d) { - _d = null; - refCnt = -1; // n/a - } else { - refCnt = _d.refCount - 1; // 1 - 1 = 0 -> final terminate - } - d = _d; - } - if( 0 == refCnt ) { // no terminate if still in use or already terminated - res = EGL.eglTerminate(eglDisplay); - eglDisplayCounter.remove(eglDisplay); - } else { - if(0 < refCnt) { // no negative refCount - d.refCount = refCnt; - } - res = true; - } + final boolean[] res = new boolean[1]; + final EGLDisplayRef d = EGLDisplayRef.closeOpened(eglDisplay, res); if(DEBUG) { - System.err.println("EGLDisplayUtil.eglTerminate("+EGLContext.toHexString(eglDisplay)+" ...): #"+refCnt+" = "+res); + System.err.println("EGLDisplayUtil.eglTerminate.X("+EGLContext.toHexString(eglDisplay)+" ...): "+d+" = "+res[0]+", singletonEGLDisplay "+singletonEGLDisplay+" (use "+useSingletonEGLDisplay+")"); // Thread.dumpStack(); } - return res; + return res[0]; } - public static final EGLGraphicsDevice.EGLDisplayLifecycleCallback eglLifecycleCallback = new EGLGraphicsDevice.EGLDisplayLifecycleCallback() { + private static final EGLGraphicsDevice.EGLDisplayLifecycleCallback eglLifecycleCallback = new EGLGraphicsDevice.EGLDisplayLifecycleCallback() { @Override public long eglGetAndInitDisplay(long[] nativeDisplayID) { return eglGetDisplayAndInitialize(nativeDisplayID); diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 3651d71a9..65ce98e07 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -361,6 +361,13 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { return new ArrayList(0); } + private static void dumpEGLInfo(final String prefix, final long eglDisplay) { + final String eglVendor = EGL.eglQueryString(eglDisplay, EGL.EGL_VENDOR); + final String eglClientAPIs = EGL.eglQueryString(eglDisplay, EGL.EGL_CLIENT_APIS); + final String eglVersion = EGL.eglQueryString(eglDisplay, EGL.EGL_VERSION); + System.err.println(prefix+"EGL vendor "+eglVendor+", version "+eglVersion+", clientAPIs "+eglClientAPIs); + } + private boolean mapAvailableEGLESConfig(AbstractGraphicsDevice adevice, int[] esProfile, boolean[] hasPBuffer, GLRendererQuirks[] rendererQuirks, int[] ctp) { final String profileString; @@ -404,6 +411,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { // In this branch, any non EGL device is mapped to EGL default shared resources (default behavior). // Only one default shared resource instance is ever be created. defaultDevice.open(); + if( DEBUG ) { + dumpEGLInfo("EGLDrawableFactory.mapAvailableEGLESConfig: ", defaultDevice.getHandle()); + } + final GLCapabilitiesImmutable reqCapsPBuffer = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities(reqCapsAny); final List availablePBufferCapsL = getAvailableEGLConfigs(defaultDevice, reqCapsPBuffer); hasPBuffer[0] = availablePBufferCapsL.size() > 0; @@ -475,6 +486,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { surface = upstreamSurface; eglDevice = EGLDisplayUtil.eglCreateEGLGraphicsDevice(surface); eglDevice.open(); + if( DEBUG ) { + dumpEGLInfo("EGLDrawableFactory.mapAvailableEGLESConfig: ", eglDevice.getHandle()); + } hasPBuffer[0] = true; } @@ -533,6 +547,10 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } } } + if( null != rendererQuirks[0] && rendererQuirks[0].exist(GLRendererQuirks.SingletonEGLDisplayOnly) ) { + EGLDisplayUtil.setSingletonEGLDisplayOnly(true); + } + return success; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java index f916a8ef3..15ff2b1ac 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java +++ b/src/nativewindow/classes/javax/media/nativewindow/DefaultGraphicsDevice.java @@ -247,7 +247,7 @@ public class DefaultGraphicsDevice implements Cloneable, AbstractGraphicsDevice * Returns a unique String object using {@link String#intern()} for the given arguments, * which object reference itself can be used as a key. */ - protected static String getUniqueID(String type, String connection, int unitID) { + private static String getUniqueID(String type, String connection, int unitID) { final String r = (type + separator + connection + separator + unitID).intern(); return r.intern(); } -- cgit v1.2.3 From eee9c2cbaf5984e7036a790feb3b8db9f63096f0 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 24 Jan 2014 05:23:34 +0100 Subject: Add 'make/scripts/create-i386-libs-symlinks.sh' to setup missing 'a.so -> a.so.N' symlinks for debian i386 libs on x86_64 --- make/scripts/create-i386-libs-symlinks.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 make/scripts/create-i386-libs-symlinks.sh (limited to 'make/scripts') diff --git a/make/scripts/create-i386-libs-symlinks.sh b/make/scripts/create-i386-libs-symlinks.sh new file mode 100644 index 000000000..0eb5a14ea --- /dev/null +++ b/make/scripts/create-i386-libs-symlinks.sh @@ -0,0 +1,10 @@ +ls -la libX11.so* libXxf86vm.so* libXrender.so* libXrandr.so* libXinerama.so* libXcursor.so* + +ln -s libX11.so.6 libX11.so +ln -s libXxf86vm.so.1 libXxf86vm.so +ln -s libXrender.so.1 libXrender.so +ln -s libXrandr.so.2 libXrandr.so +ln -s libXinerama.so.1 libXinerama.so +ln -s libXcursor.so.1 libXcursor.so + +ls -la libX11.so* libXxf86vm.so* libXrender.so* libXrandr.so* libXinerama.so* libXcursor.so* -- cgit v1.2.3 From f1af72e1d93e8b928409c7bd8da0acb2b41cd345 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 24 Jan 2014 19:33:24 +0100 Subject: Bug 948 - Autodetect GLRendererQuirks.SingletonEGLDisplayOnly Refines commit fbe00e6f5dca8043b40dd96f096fecc9424e0cc3 Instead of querying driver artifacts (vendor, platform, version ..) we simply can autodetect this quirk by trying to get a second egl-display handle when initializing the EGLDrawablFactory's default device: EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY) --- make/scripts/tests.sh | 2 +- .../com/jogamp/opengl/GLRendererQuirks.java | 8 ++++++-- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 16 --------------- .../jogamp/opengl/egl/EGLDrawableFactory.java | 23 ++++++++++++++++------ 4 files changed, 24 insertions(+), 25 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 1b93ff7ae..14a5548a8 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -174,7 +174,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.X11Util.TraceDisplayLifecycle" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnewt.debug.Window" - #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" + D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnativewindow.debug.X11Util" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Dnativewindow.debug.ToolkitLock.TraceLock" diff --git a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java index 57c5446f1..a643d81a9 100644 --- a/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java +++ b/src/jogl/classes/com/jogamp/opengl/GLRendererQuirks.java @@ -272,15 +272,19 @@ public class GLRendererQuirks { *

        * Reusing global EGL display works. *

        + *

        + * The quirk is autodetected within EGLDrawableFactory's initial default device setup! + *

        + *

        + * Appears on: *

          *
        • EGL_VENDOR NVIDIA
        • *
        • EGL_VERSION 1.4
        • *
        • GL_VENDOR NVIDIA Corporation
        • + *
        • GL_VERSION OpenGL ES 3.0 331.38 (probably w/ 1st NV EGL lib on x86)
        • *
        • Platform X11
        • *
        • CPU Family {@link Platform.CPUFamily#X86}
        • *
        - *

        - * FIXME: Constrain driver version. *

        */ public static final int SingletonEGLDisplayOnly = 16; diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 652fc6ba9..431bba6de 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -1706,22 +1706,6 @@ public abstract class GLContextImpl extends GLContext { } } } - if( isX11 && isDriverNVIDIAGeForce && Platform.CPUFamily.X86 == Platform.getCPUFamily() ) { - final int quirk = GLRendererQuirks.SingletonEGLDisplayOnly; - if(DEBUG) { - System.err.println("Quirk: "+GLRendererQuirks.toString(quirk)+": cause: ES, X11, CPUFamily AMD/Intel, [Vendor "+glVendor+" or Renderer "+glRenderer+"]"); - } - quirks[i++] = quirk; - if( withinGLVersionsMapping ) { - // Thread safe due to single threaded initialization! - GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1); - } else { - // FIXME: Remove when moving EGL/ES to ARB ctx creation - synchronized(GLContextImpl.class) { - GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, i-1, 1); - } - } - } } // diff --git a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java index 65ce98e07..9ee0134f1 100644 --- a/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/egl/EGLDrawableFactory.java @@ -389,7 +389,9 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } final GLProfile glp = GLProfile.get(adevice, profileString) ; final GLDrawableFactoryImpl desktopFactory = (GLDrawableFactoryImpl) GLDrawableFactory.getDesktopFactory(); - final boolean mapsADeviceToDefaultDevice = !QUERY_EGL_ES_NATIVE_TK || null == desktopFactory || adevice instanceof EGLGraphicsDevice ; + final boolean initDefaultDevice = 0 == defaultDevice.getHandle(); // Note: GLProfile always triggers EGL device initialization first! + final boolean mapsADeviceToDefaultDevice = !QUERY_EGL_ES_NATIVE_TK || initDefaultDevice || + null == desktopFactory || adevice instanceof EGLGraphicsDevice ; if( DEBUG ) { System.err.println("EGLDrawableFactory.mapAvailableEGLESConfig: "+profileString+" ( "+esProfile+" ), "+ "defaultSharedResourceSet "+(null!=defaultSharedResource)+", mapsADeviceToDefaultDevice "+mapsADeviceToDefaultDevice+ @@ -410,7 +412,20 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { if( mapsADeviceToDefaultDevice ) { // In this branch, any non EGL device is mapped to EGL default shared resources (default behavior). // Only one default shared resource instance is ever be created. - defaultDevice.open(); + if( initDefaultDevice ) { + defaultDevice.open(); + + // Probe for GLRendererQuirks.SingletonEGLDisplayOnly + final long secondEGLDisplay = EGL.eglGetDisplay(EGL.EGL_DEFAULT_DISPLAY); + if ( EGL.EGL_NO_DISPLAY == secondEGLDisplay ) { + final int[] quirks = { GLRendererQuirks.SingletonEGLDisplayOnly }; + GLRendererQuirks.addStickyDeviceQuirks(adevice, quirks, 0, 1); + EGLDisplayUtil.setSingletonEGLDisplayOnly(true); + if(DEBUG) { + System.err.println("Quirk: "+GLRendererQuirks.toString(quirks[0])+": cause: Second eglGetDisplay(EGL_DEFAULT_DISPLAY) failed"); + } + } + } if( DEBUG ) { dumpEGLInfo("EGLDrawableFactory.mapAvailableEGLESConfig: ", defaultDevice.getHandle()); } @@ -547,10 +562,6 @@ public class EGLDrawableFactory extends GLDrawableFactoryImpl { } } } - if( null != rendererQuirks[0] && rendererQuirks[0].exist(GLRendererQuirks.SingletonEGLDisplayOnly) ) { - EGLDisplayUtil.setSingletonEGLDisplayOnly(true); - } - return success; } -- cgit v1.2.3 From ec014b2bc5828c9efc3047fe2c148f11335e944f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 25 Jan 2014 00:05:28 +0100 Subject: TestPerf001*Init0*: Add INIT_TIMEOUT for perf. loop (10s) --- make/scripts/tests.sh | 6 +++--- .../junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java | 15 ++++++++++----- .../junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java | 15 ++++++++++----- .../junit/jogl/perf/TestPerf001GLWindowInit03NEWT.java | 15 ++++++++++----- 4 files changed, 33 insertions(+), 18 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 14a5548a8..c687c01a0 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -174,7 +174,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.X11Util -Dnativewindow.debug.X11Util.XSync" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnativewindow.debug.X11Util.TraceDisplayLifecycle" #D_ARGS="-Dnativewindow.debug.X11Util.XSync -Dnewt.debug.Window" - D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" + #D_ARGS="-Djogl.debug.GLDrawable -Djogl.debug.GLContext" #D_ARGS="-Dnativewindow.debug.NativeWindow -Dnativewindow.debug.X11Util" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Djogl.debug.GLContext.TraceSwitch" #D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=3000 -Djogamp.debug.Lock -Dnativewindow.debug.ToolkitLock.TraceLock" @@ -333,7 +333,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelsAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasAWT $* #testawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NewtCanvasAWT $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestLandscapeES2NEWT $* #testawtswt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NewtCanvasSWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestElektronenMultipliziererNEWT $* @@ -361,7 +361,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.newt.TestGearsES2NEWT $* # performance tests # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* -#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java index 0472fdb31..0ca84e4c3 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit01AWT.java @@ -61,6 +61,7 @@ import com.jogamp.opengl.util.Animator; */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestPerf001GLJPanelInit01AWT extends UITestCase { + final long INIT_TIMEOUT = 10L*1000L; // 10s @BeforeClass public static void initClass() { @@ -119,22 +120,26 @@ public class TestPerf001GLJPanelInit01AWT extends UITestCase { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } - while( panelCount > initCount ) { + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while( panelCount > initCount && INIT_TIMEOUT > t1 - t0 ) { try { - Thread.sleep(10); + Thread.sleep(100); + System.err.println("Sleep initialized: "+initCount+"/"+panelCount); } catch (InterruptedException e1) { e1.printStackTrace(); } + t1 = System.currentTimeMillis(); } t[3] = Platform.currentTimeMillis(); - final double panelCountF = panelCount; + final double panelCountF = initCount; System.err.printf("P: %d %s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", - panelCount, + initCount, useGLJPanel?"GLJPanel":"GLCanvas", t[1]-t[0], (t[1]-t[0])/panelCountF, t[3]-t[1], (t[3]-t[1])/panelCountF, t[3]-t[0], (t[3]-t[0])/panelCountF); - System.err.println("INIT END: "+initCount); + System.err.println("INIT END: "+initCount+"/"+panelCount); if( wait ) { UITestCase.waitForKey("Post-Init"); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java index b513af9a0..2b1dc411f 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLJPanelInit02AWT.java @@ -63,6 +63,7 @@ import com.jogamp.opengl.util.Animator; */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestPerf001GLJPanelInit02AWT extends UITestCase { + final long INIT_TIMEOUT = 10L*1000L; // 10s @BeforeClass public static void initClass() { @@ -175,23 +176,27 @@ public class TestPerf001GLJPanelInit02AWT extends UITestCase { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } - while( frameCount > initCount ) { + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while( frameCount > initCount && INIT_TIMEOUT > t1 - t0 ) { try { - Thread.sleep(10); + Thread.sleep(100); + System.err.println("Sleep initialized: "+initCount+"/"+frameCount); } catch (InterruptedException e1) { e1.printStackTrace(); } + t1 = System.currentTimeMillis(); } t[3] = Platform.currentTimeMillis(); - final double panelCountF = frameCount; + final double panelCountF = initCount; System.err.printf("P: %d %s%s:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", - frameCount, + initCount, useGLJPanel?"GLJPanel":(useGLCanvas?"GLCanvas":"No_GL"), initMT?" (mt)":" (01)", t[1]-t[0], (t[1]-t[0])/panelCountF, t[3]-t[1], (t[3]-t[1])/panelCountF, t[3]-t[0], (t[3]-t[0])/panelCountF); - System.err.println("INIT END: "+initCount); + System.err.println("INIT END: "+initCount+"/"+frameCount); if( wait ) { UITestCase.waitForKey("Post-Init"); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLWindowInit03NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLWindowInit03NEWT.java index 4915cffa6..18b3d5454 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLWindowInit03NEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/perf/TestPerf001GLWindowInit03NEWT.java @@ -53,6 +53,7 @@ import com.jogamp.opengl.test.junit.util.UITestCase; */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TestPerf001GLWindowInit03NEWT extends UITestCase { + final long INIT_TIMEOUT = 10L*1000L; // 10s @BeforeClass public static void initClass() { @@ -108,22 +109,26 @@ public class TestPerf001GLWindowInit03NEWT extends UITestCase { } t[2] = Platform.currentTimeMillis(); - while( frameCount > initCount ) { + final long t0 = System.currentTimeMillis(); + long t1 = t0; + while( frameCount > initCount && INIT_TIMEOUT > t1 - t0 ) { try { - Thread.sleep(10); + Thread.sleep(100); + System.err.println("Sleep initialized: "+initCount+"/"+frameCount); } catch (InterruptedException e1) { e1.printStackTrace(); } + t1 = System.currentTimeMillis(); } t[3] = Platform.currentTimeMillis(); - final double panelCountF = frameCount; + final double panelCountF = initCount; System.err.printf("P: %d GLWindow:%n\tctor\t%6d/t %6.2f/1%n\tvisible\t%6d/t %6.2f/1%n\tsum-i\t%6d/t %6.2f/1%n", - frameCount, + initCount, t[1]-t[0], (t[1]-t[0])/panelCountF, t[3]-t[1], (t[3]-t[1])/panelCountF, t[3]-t[0], (t[3]-t[0])/panelCountF); - System.err.println("INIT END: "+initCount); + System.err.println("INIT END: "+initCount+"/"+frameCount); if( wait ) { UITestCase.waitForKey("Post-Init"); } -- cgit v1.2.3 From 87135467c4f292f7e43bc3957784b0e43769c9cc Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 26 Jan 2014 02:59:12 +0100 Subject: Script: Correct joal.jar path; Remove redundant NewtDebugActivity (Debug is on for NewtVersionActivity) --- make/resources/android/AndroidManifest-jogl.xml | 12 --- make/resources/android/res-jogl/values/strings.xml | 2 - make/scripts/make.jogl.all.android-armv6-cross.sh | 2 + make/scripts/setenv-jogl.sh | 2 +- .../newt/driver/android/NewtDebugActivity.java | 38 ------- .../driver/android/NewtDebugActivityLauncher.java | 21 ---- .../newt/driver/android/NewtVersionActivity.java | 88 ++++++++++++++- .../android/NewtVersionActivityLauncher.java | 2 +- .../driver/android/NewtVersionBaseActivity.java | 120 --------------------- 9 files changed, 90 insertions(+), 197 deletions(-) delete mode 100644 src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java delete mode 100644 src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java delete mode 100644 src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java (limited to 'make/scripts') diff --git a/make/resources/android/AndroidManifest-jogl.xml b/make/resources/android/AndroidManifest-jogl.xml index d9a9ac819..1b6c46356 100644 --- a/make/resources/android/AndroidManifest-jogl.xml +++ b/make/resources/android/AndroidManifest-jogl.xml @@ -28,18 +28,6 @@ - - - - - - diff --git a/make/resources/android/res-jogl/values/strings.xml b/make/resources/android/res-jogl/values/strings.xml index ae4816665..e88a0a4e0 100644 --- a/make/resources/android/res-jogl/values/strings.xml +++ b/make/resources/android/res-jogl/values/strings.xml @@ -5,6 +5,4 @@ Contains Dalvik and native code, supporting native bindings. Jogl\'s Version Shows the version of the JOGL Library and runtime GL infos. - Jogl Debug - Debug output of JOGL\'s initialization. diff --git a/make/scripts/make.jogl.all.android-armv6-cross.sh b/make/scripts/make.jogl.all.android-armv6-cross.sh index 2b8f9a30e..1b5f5bf44 100755 --- a/make/scripts/make.jogl.all.android-armv6-cross.sh +++ b/make/scripts/make.jogl.all.android-armv6-cross.sh @@ -1,5 +1,7 @@ #! /bin/sh +SDIR=`dirname $0` + if [ -e $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh ] ; then . $SDIR/../../../gluegen/make/scripts/setenv-build-jogl-x86_64.sh fi diff --git a/make/scripts/setenv-jogl.sh b/make/scripts/setenv-jogl.sh index 186da5505..dc121a596 100755 --- a/make/scripts/setenv-jogl.sh +++ b/make/scripts/setenv-jogl.sh @@ -73,7 +73,7 @@ if [ ! -e "$JOAL_BUILDDIR" ] ; then print_usage exit fi -JOAL_JAR="$JOAL_BUILDDIR"/joal.jar +JOAL_JAR="$JOAL_BUILDDIR"/jar/joal.jar if [ -z "$ANT_PATH" ] ; then ANT_PATH=$(dirname $(dirname $(which ant))) diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java deleted file mode 100644 index 40a6ec6dc..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivity.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright 2013 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package jogamp.newt.driver.android; - -import android.os.Bundle; - -public class NewtDebugActivity extends NewtVersionBaseActivity { - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate("NewtDebugActivity - DEBUG MODE", savedInstanceState); - } -} diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java deleted file mode 100644 index 9d16fdec5..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/NewtDebugActivityLauncher.java +++ /dev/null @@ -1,21 +0,0 @@ -package jogamp.newt.driver.android; - -import android.app.Activity; -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.util.Log; - -public class NewtDebugActivityLauncher extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtDebugActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test&jogamp.debug=all&nativewindow.debug=all&jogl.debug=all&newt.debug=all"); - final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri); - Log.d(getClass().getSimpleName(), "Launching Activity: "+intent); - startActivity (intent); - - finish(); // done - } -} diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java index 8a7f3af87..259acb8f3 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivity.java @@ -27,11 +27,95 @@ */ package jogamp.newt.driver.android; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.os.Platform; +import com.jogamp.common.util.VersionUtil; +import com.jogamp.newt.opengl.GLWindow; +import com.jogamp.opengl.JoglVersion; + import android.os.Bundle; +import android.util.Log; +import android.view.Gravity; +import android.view.ViewGroup.LayoutParams; +import android.widget.ScrollView; +import android.widget.TextView; + +public class NewtVersionActivity extends NewtBaseActivity { -public class NewtVersionActivity extends NewtVersionBaseActivity { @Override public void onCreate(Bundle savedInstanceState) { - super.onCreate("NewtVersionActivity - NORMAL MODE", savedInstanceState); + super.onCreate(savedInstanceState); + + setFullscreenFeature(getWindow(), true); + + final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); + getWindow().setContentView(viewGroup); + + final TextView tv = new TextView(getActivity()); + final ScrollView scroller = new ScrollView(getActivity()); + scroller.addView(tv); + viewGroup.addView(scroller, new android.widget.FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.TOP|Gravity.LEFT)); + + final String info1 = "JOGL Version Info"+Platform.NEWLINE+VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE; + Log.d(MD.TAG, info1); + tv.setText(info1); + + final GLProfile glp; + if( GLProfile.isAvailable(GLProfile.GL2ES2) ) { + glp = GLProfile.get(GLProfile.GL2ES2); + } else if( GLProfile.isAvailable(GLProfile.GL2ES1) ) { + glp = GLProfile.get(GLProfile.GL2ES1); + } else { + glp = null; + tv.append("No GLProfile GL2ES2 nor GL2ES1 available!"); + } + if( null != glp ) { + // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) + GLCapabilities caps = new GLCapabilities(glp); + GLWindow glWindow = GLWindow.create(caps); + glWindow.setUndecorated(true); + glWindow.setSize(32, 32); + glWindow.setPosition(0, 0); + final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); + viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); + registerNEWTWindow(glWindow); + + glWindow.addGLEventListener(new GLEventListener() { + public void init(GLAutoDrawable drawable) { + GL gl = drawable.getGL(); + final StringBuilder sb = new StringBuilder(); + sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); + sb.append("Requested: ").append(Platform.NEWLINE); + sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + sb.append("Chosen: ").append(Platform.NEWLINE); + sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); + final String info2 = sb.toString(); + // Log.d(MD.TAG, info2); // too big! + System.err.println(info2); + viewGroup.post(new Runnable() { + public void run() { + tv.append(info2); + viewGroup.removeView(androidGLView); + } } ); + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + } + + public void display(GLAutoDrawable drawable) { + } + + public void dispose(GLAutoDrawable drawable) { + } + }); + glWindow.setVisible(true); + } + Log.d(MD.TAG, "onCreate - X"); } } diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java index 3374e4184..553900f6a 100644 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java +++ b/src/newt/classes/jogamp/newt/driver/android/NewtVersionActivityLauncher.java @@ -11,7 +11,7 @@ public class NewtVersionActivityLauncher extends Activity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test"); + final Uri uri = Uri.parse("launch://jogamp.org/jogamp.newt.driver.android.NewtVersionActivity?sys=com.jogamp.common&sys=javax.media.opengl&pkg=com.jogamp.opengl.test&jogamp.debug=all&nativewindow.debug=all&jogl.debug=all&newt.debug=all"); final Intent intent = new Intent("org.jogamp.launcher.action.LAUNCH_ACTIVITY_NORMAL", uri); Log.d(getClass().getSimpleName(), "Launching Activity: "+intent); startActivity (intent); diff --git a/src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java b/src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java deleted file mode 100644 index f24fb20ac..000000000 --- a/src/newt/classes/jogamp/newt/driver/android/NewtVersionBaseActivity.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright 2011 JogAmp Community. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, are - * permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this list of - * conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation are those of the - * authors and should not be interpreted as representing official policies, either expressed - * or implied, of JogAmp Community. - */ -package jogamp.newt.driver.android; - -import javax.media.opengl.GL; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLProfile; - -import com.jogamp.common.GlueGenVersion; -import com.jogamp.common.os.Platform; -import com.jogamp.common.util.VersionUtil; -import com.jogamp.newt.opengl.GLWindow; -import com.jogamp.opengl.JoglVersion; - -import android.os.Bundle; -import android.util.Log; -import android.view.Gravity; -import android.view.ViewGroup.LayoutParams; -import android.widget.ScrollView; -import android.widget.TextView; - -public class NewtVersionBaseActivity extends NewtBaseActivity { - - public void onCreate(String prefix, Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setFullscreenFeature(getWindow(), true); - - final android.view.ViewGroup viewGroup = new android.widget.FrameLayout(getActivity().getApplicationContext()); - getWindow().setContentView(viewGroup); - - final TextView tv = new TextView(getActivity()); - final ScrollView scroller = new ScrollView(getActivity()); - scroller.addView(tv); - viewGroup.addView(scroller, new android.widget.FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.TOP|Gravity.LEFT)); - - final String info1 = prefix+Platform.NEWLINE+VersionUtil.getPlatformInfo()+Platform.NEWLINE+GlueGenVersion.getInstance()+Platform.NEWLINE+JoglVersion.getInstance()+Platform.NEWLINE; - Log.d(MD.TAG, info1); - tv.setText(info1); - - final GLProfile glp; - if( GLProfile.isAvailable(GLProfile.GL2ES2) ) { - glp = GLProfile.get(GLProfile.GL2ES2); - } else if( GLProfile.isAvailable(GLProfile.GL2ES1) ) { - glp = GLProfile.get(GLProfile.GL2ES1); - } else { - glp = null; - tv.append("No GLProfile GL2ES2 nor GL2ES1 available!"); - } - if( null != glp ) { - // create GLWindow (-> incl. underlying NEWT Display, Screen & Window) - GLCapabilities caps = new GLCapabilities(glp); - GLWindow glWindow = GLWindow.create(caps); - glWindow.setUndecorated(true); - glWindow.setSize(32, 32); - glWindow.setPosition(0, 0); - final android.view.View androidGLView = ((WindowDriver)glWindow.getDelegatedWindow()).getAndroidView(); - viewGroup.addView(androidGLView, new android.widget.FrameLayout.LayoutParams(glWindow.getWidth(), glWindow.getHeight(), Gravity.BOTTOM|Gravity.RIGHT)); - registerNEWTWindow(glWindow); - - glWindow.addGLEventListener(new GLEventListener() { - public void init(GLAutoDrawable drawable) { - GL gl = drawable.getGL(); - final StringBuilder sb = new StringBuilder(); - sb.append(JoglVersion.getGLInfo(gl, null, true)).append(Platform.NEWLINE); - sb.append("Requested: ").append(Platform.NEWLINE); - sb.append(drawable.getNativeSurface().getGraphicsConfiguration().getRequestedCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); - sb.append("Chosen: ").append(Platform.NEWLINE); - sb.append(drawable.getChosenGLCapabilities()).append(Platform.NEWLINE).append(Platform.NEWLINE); - final String info2 = sb.toString(); - // Log.d(MD.TAG, info2); // too big! - System.err.println(info2); - viewGroup.post(new Runnable() { - public void run() { - tv.append(info2); - viewGroup.removeView(androidGLView); - } } ); - } - - public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { - } - - public void display(GLAutoDrawable drawable) { - } - - public void dispose(GLAutoDrawable drawable) { - } - }); - glWindow.setVisible(true); - } - Log.d(MD.TAG, "onCreate - X"); - } -} -- cgit v1.2.3 From b92a813063212130d6205a25b1f84662e8c4c0f9 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 26 Jan 2014 04:55:37 +0100 Subject: Bug 927 - Enhance GLMediaPlayer/FFMPEGMediaPlayer MovieSimple to run multiple instances in parallel Tested on GNU/Linux x86_64, Result: Plays well here audio and video, i.e. audio is actually mixed from both movies. Even if one movie (below) stops and restarts (AL buffer reset), it didn't crash. +++ LIB_AV Codec : 54.92.100 [cc 54] LIB_AV Format : 54.63.104 [cc 54] LIB_AV Util : 52.18.100 [cc 52] LIB_AV Resample: 1.0.1 [cc 1, loaded true] LIB_SW Resample: 0.17.102 [cc 0, loaded true] LIB_AV Device : [loaded true] LIB_AV Class : FFMPEGv09Natives +++ (enable MovieSimple in scripts/tests.sh) bash scripts/tests-x64.sh -loop -windows 2 \ -urlN 0 http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_720p_surround.avi \ -urlN 1 http://video.webmfiles.org/elephants-dream.webm +++ 2 Streaming threads, i.e. decoder threads: "Thread-5-StreamWorker_1" daemon prio=10 tid=0x00007f994c102000 nid=0x5826 in Object.wait() [0x00007f996fa37000] at jogamp.opengl.util.av.GLMediaPlayerImpl$StreamWorker.run(GLMediaPlayerImpl.java:1231) "Thread-4-StreamWorker_0" daemon prio=10 tid=0x00007f99600ed000 nid=0x5825 in Object.wait() [0x00007f996cd09000] at jogamp.opengl.util.av.GLMediaPlayerImpl$StreamWorker.run(GLMediaPlayerImpl.java:1231) --- make/scripts/tests.sh | 6 +- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 287 ++++++++++++--------- 2 files changed, 169 insertions(+), 124 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c687c01a0..85eb14252 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -242,7 +242,7 @@ function jrun() { #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" - #D_ARGS="-Djogl.debug.GLMediaPlayer" + D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" @@ -355,13 +355,13 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests # #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001RawInit00NEWT $* -testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* +#testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLJPanelInit02AWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.perf.TestPerf001GLWindowInit03NEWT $* diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index ddf5c709c..fcf1cd2ef 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -36,6 +36,7 @@ import java.nio.FloatBuffer; import javax.media.opengl.GL; import javax.media.opengl.GL2ES2; +import javax.media.opengl.GLAnimatorControl; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLES2; @@ -84,6 +85,9 @@ public class MovieSimple implements GLEventListener { public static final int EFFECT_GRADIENT_BOTTOM2TOP = 1<<1; public static final int EFFECT_TRANSPARENT = 1<<3; + private static final String WINDOW_KEY = "window"; + private static final String PLAYER = "player"; + private static boolean waitForKey = false; private int winWidth, winHeight; private int prevMouseX; // , prevMouseY; @@ -286,6 +290,7 @@ public class MovieSimple implements GLEventListener { mPlayerShared = null != mPlayer; if( !mPlayerShared ) { mPlayer = GLMediaPlayerFactory.createDefault(); + mPlayer.attachObject(PLAYER, this); } System.out.println("pC.1a shared "+mPlayerShared+", "+mPlayer); } @@ -701,6 +706,94 @@ public class MovieSimple implements GLEventListener { st.useProgram(gl, false); } + static class MyGLMediaEventListener implements GLMediaEventListener { + void destroyWindow(final Window window) { + new Thread() { + public void run() { + window.destroy(); + } }.start(); + } + + @Override + public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { + } + + @Override + public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { + System.err.println("MovieSimple AttributesChanges: events_mask 0x"+Integer.toHexString(event_mask)+", when "+when); + System.err.println("MovieSimple State: "+mp); + final GLWindow window = (GLWindow) mp.getAttachedObject(WINDOW_KEY); + final MovieSimple ms = (MovieSimple)mp.getAttachedObject(PLAYER); + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_SIZE & event_mask ) ) { + System.err.println("MovieSimple State: CHANGE_SIZE"); + if( origSize ) { + window.setSize(mp.getWidth(), mp.getHeight()); + } + // window.disposeGLEventListener(ms, false /* remove */ ); + ms.resetGLState(); + } + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_INIT & event_mask ) ) { + System.err.println("MovieSimple State: INIT"); + // Use GLEventListener in all cases [A+V, V, A] + window.addGLEventListener(ms); + final GLAnimatorControl anim = window.getAnimator(); + anim.setUpdateFPSFrames(60, System.err); + anim.resetFPSCounter(); + + /** + * Kick off player w/o GLEventListener, i.e. for audio only. + * + try { + ms.mPlayer.initGL(null); + } catch (Exception e) { + e.printStackTrace(); + destroyWindow(); + return; + } + ms.mPlayer.play(); + System.out.println("play.1 "+ms.mPlayer); + */ + } + boolean destroy = false; + Throwable err = null; + + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { + err = ms.mPlayer.getStreamException(); + if( null != err ) { + System.err.println("MovieSimple State: EOS + Exception"); + destroy = true; + } else { + System.err.println("MovieSimple State: EOS"); + if( loopEOS ) { + ms.mPlayer.seek(0); + ms.mPlayer.play(); + } else { + destroy = true; + } + } + } + if( 0 != ( GLMediaEventListener.EVENT_CHANGE_ERR & event_mask ) ) { + err = ms.mPlayer.getStreamException(); + if( null != err ) { + System.err.println("MovieSimple State: ERR + Exception"); + } else { + System.err.println("MovieSimple State: ERR"); + } + destroy = true; + } + if( destroy ) { + if( null != err ) { + err.printStackTrace(); + } + destroyWindow(window); + } + } + }; + final static MyGLMediaEventListener myGLMediaEventListener = new MyGLMediaEventListener(); + + static boolean loopEOS = false; + static boolean origSize; + public static void main(String[] args) throws IOException, URISyntaxException { int swapInterval = 1; int width = 640; @@ -708,7 +801,6 @@ public class MovieSimple implements GLEventListener { int textureCount = 3; // default - threaded boolean ortho = true; boolean zoom = false; - boolean _loopEOS = false; boolean forceES2 = false; boolean forceES3 = false; @@ -716,9 +808,20 @@ public class MovieSimple implements GLEventListener { boolean forceGLDef = false; int vid = GLMediaPlayer.STREAM_ID_AUTO; int aid = GLMediaPlayer.STREAM_ID_AUTO; - final boolean origSize; - String url_s=null, file_s1=null, file_s2=null; + final int windowCount; + { + int _windowCount = 1; + for(int i=0; i Date: Wed, 12 Feb 2014 02:48:08 +0100 Subject: Bug 972 - Reduce ClassLoader Lookup, i.e. Class.forName(..): GLProfile, GLContextImpl, DisplayImpl GLProfile, GLContextImpl: - ReflectionUtil.DEBUG_STATS_FORNAME: Dump forName stats if set - Cache GL*Impl and GL*ProcAddressTable Constructor for GLContextImpl's createInstance(..) - Remove off-thread early classloading thread which only adds complications DisplayImpl: - Remove one redundant availability test --- make/scripts/tests-win.bat | 4 +- make/scripts/tests-x64-dbg.bat | 5 +- make/scripts/tests.sh | 10 +- src/jogl/classes/javax/media/opengl/GLProfile.java | 141 ++++++++++++++++----- src/jogl/classes/jogamp/opengl/GLContextImpl.java | 12 +- src/newt/classes/jogamp/newt/DisplayImpl.java | 3 +- 6 files changed, 129 insertions(+), 46 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index 5642cca6f..f4db03a15 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -38,7 +38,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* -REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 @@ -50,7 +50,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedConte REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT0 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT1 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2AWT3b %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextWithJTabbedPaneAWT %* diff --git a/make/scripts/tests-x64-dbg.bat b/make/scripts/tests-x64-dbg.bat index ce2df922c..b3ebc03c2 100755 --- a/make/scripts/tests-x64-dbg.bat +++ b/make/scripts/tests-x64-dbg.bat @@ -55,7 +55,7 @@ REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.Animator" "-Djogl.debug.GLC REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" "-Djogl.debug.TileRenderer.PNG" REM set D_ARGS="-Djogl.debug.GLCanvas" "-Djogl.debug.GLJPanel" "-Djogl.debug.TileRenderer" REM set D_ARGS="-Djogl.gljpanel.noverticalflip" -set D_ARGS="-Dnewt.debug=all" +REM set D_ARGS="-Dnewt.debug=all" REM set D_ARGS="-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window.KeyEvent" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Window.KeyEvent" "-Dnewt.debug.EDT" @@ -74,6 +74,9 @@ REM set D_ARGS="-Dnewt.debug.Screen" REM set D_ARGS="-Dnewt.debug.Screen" "-Dnewt.debug.Window" REM set D_ARGS="-Dnewt.debug.Window" "-Dnewt.debug.Display" "-Dnewt.test.Window.reparent.incompatible=true" +REM set D_ARGS="-Djogamp.debug.ReflectionUtil" "-Djogamp.debug.ReflectionUtil.forNameStats" +REM set D_ARGS="-Djogamp.debug.ReflectionUtil.forNameStats" + REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=false" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" REM set X_ARGS="-Dsun.java2d.noddraw=true" "-Dsun.java2d.d3d=false" "-Dsun.java2d.ddoffscreen=false" "-Dsun.java2d.gdiblit=false" "-Dsun.java2d.opengl=true" "-Dsun.awt.noerasebackground=true" "-Xms512m" "-Xmx1024m" diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 85eb14252..cd9a2bb2e 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -96,6 +96,9 @@ function jrun() { #D_ARGS="-Dnativewindow.debug=all -Dnewt.debug.Window" #D_ARGS="-Djogl.debug=all -Dnativewindow.debug=all -Dnewt.debug=all -Djogamp.debug.Lock" + #D_ARGS="-Djogamp.debug.ReflectionUtil -Djogamp.debug.ReflectionUtil.forNameStats" + #D_ARGS="-Djogamp.debug.ReflectionUtil.forNameStats" + #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_XCLOSEDISPLAY_BUG" #D_ARGS="-Dnativewindow.debug.X11Util.ATI_HAS_NO_MULTITHREADING_BUG" #D_ARGS="-Djogl.disable.opengles" @@ -242,7 +245,7 @@ function jrun() { #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" - D_ARGS="-Djogl.debug.GLMediaPlayer" + #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.Native" @@ -355,7 +358,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests @@ -389,7 +392,8 @@ testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary16NOUI $* -#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* +testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* + #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* diff --git a/src/jogl/classes/javax/media/opengl/GLProfile.java b/src/jogl/classes/javax/media/opengl/GLProfile.java index a43ddee07..80f46955d 100644 --- a/src/jogl/classes/javax/media/opengl/GLProfile.java +++ b/src/jogl/classes/javax/media/opengl/GLProfile.java @@ -39,7 +39,6 @@ package javax.media.opengl; import jogamp.nativewindow.NWJNILibLoader; import jogamp.opengl.Debug; -import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.DesktopGLDynamicLookupHelper; @@ -51,6 +50,7 @@ import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.cache.TempJarCache; import com.jogamp.common.util.locks.LockFactory; import com.jogamp.common.util.locks.RecursiveThreadGroupLock; +import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.nativewindow.NativeWindowVersion; import com.jogamp.opengl.JoglVersion; @@ -58,6 +58,7 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeWindowFactory; import javax.media.opengl.fixedfunc.GLPointerFunc; +import java.lang.reflect.Constructor; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; @@ -110,7 +111,7 @@ public class GLProfile { final boolean justInitialized; initLock.lock(); try { - if(!initialized) { // volatile: ok + if(!initialized) { initialized = true; justInitialized = true; if(DEBUG) { @@ -118,6 +119,10 @@ public class GLProfile { Thread.dumpStack(); } + if(ReflectionUtil.DEBUG_STATS_FORNAME) { + ReflectionUtil.resetForNameCount(); + } + // run the whole static initialization privileged to speed up, // since this skips checking further access AccessController.doPrivileged(new PrivilegedAction() { @@ -125,24 +130,6 @@ public class GLProfile { public Object run() { Platform.initSingleton(); - // Performance hack to trigger classloading of the GL classes impl, which makes up to 12%, 800ms down to 700ms - new Thread(new Runnable() { - @Override - public void run() { - final ClassLoader cl = GLProfile.class.getClassLoader(); - try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GL4bc)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); - } catch (Throwable t) {} - try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GLES3)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); - } catch (Throwable t) {} - try { - ReflectionUtil.createInstance(getGLImplBaseClassName(GLES1)+"Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { null, null }, cl); - } catch (Throwable t) {} - } - }, "GLProfile-GL_Bootstrapping").start(); - - if(TempJarCache.isInitialized()) { final ClassLoader cl = GLProfile.class.getClassLoader(); final String newtFactoryClassName = "com.jogamp.newt.NewtFactory"; @@ -156,6 +143,11 @@ public class GLProfile { return null; } }); + if( ReflectionUtil.DEBUG_STATS_FORNAME ) { + if( justInitialized ) { + System.err.println(ReflectionUtil.getForNameStats(null).toString()); + } + } } else { justInitialized = false; } @@ -191,7 +183,7 @@ public class GLProfile { public static void shutdown() { initLock.lock(); try { - if(initialized) { // volatile: ok + if(initialized) { initialized = false; if(DEBUG) { System.err.println("GLProfile.shutdown() - thread "+Thread.currentThread().getName()); @@ -1045,7 +1037,6 @@ public class GLProfile { public final String getGLImplBaseClassName() { return getGLImplBaseClassName(getImplName()); } - private static final String getGLImplBaseClassName(String profileImpl) { if( GLES2 == profileImpl || GLES3 == profileImpl ) { return "jogamp.opengl.es3.GLES3"; @@ -1062,6 +1053,25 @@ public class GLProfile { } } + public final Constructor getGLCtor(boolean glObject) { + return getGLCtor(getImplName(), glObject); + } + private static final Constructor getGLCtor(String profileImpl, boolean glObject) { + if( GLES2 == profileImpl || GLES3 == profileImpl ) { + return glObject ? ctorGLES3Impl : ctorGLES3ProcAddr; + } else if( GLES1 == profileImpl ) { + return glObject ? ctorGLES1Impl : ctorGLES1ProcAddr; + } else if ( GL4bc == profileImpl || + GL4 == profileImpl || + GL3bc == profileImpl || + GL3 == profileImpl || + GL2 == profileImpl ) { + return glObject ? ctorGL234Impl : ctorGL234ProcAddr; + } else { + throw new GLException("unsupported profile \"" + profileImpl + "\""); + } + } + /** * @param o GLProfile object to compare with * @return true if given Object is a GLProfile and @@ -1530,13 +1540,87 @@ public class GLProfile { private static /*final*/ boolean hasEGLFactory; private static /*final*/ boolean hasGLES3Impl; private static /*final*/ boolean hasGLES1Impl; + private static /*final*/ Constructor ctorGL234Impl; + private static /*final*/ Constructor ctorGLES3Impl; + private static /*final*/ Constructor ctorGLES1Impl; + private static /*final*/ Constructor ctorGL234ProcAddr; + private static /*final*/ Constructor ctorGLES3ProcAddr; + private static /*final*/ Constructor ctorGLES1ProcAddr; private static /*final*/ GLDrawableFactoryImpl eglFactory = null; private static /*final*/ GLDrawableFactoryImpl desktopFactory = null; private static /*final*/ AbstractGraphicsDevice defaultDevice = null; - private static volatile boolean initialized = false; - private static RecursiveThreadGroupLock initLock = LockFactory.createRecursiveThreadGroupLock(); + private static boolean initialized = false; + private static final RecursiveThreadGroupLock initLock = LockFactory.createRecursiveThreadGroupLock(); + + private static final Class[] ctorGLArgs = new Class[] { GLProfile.class, jogamp.opengl.GLContextImpl.class }; + private static final Class[] ctorProcArgs = new Class[] { FunctionAddressResolver.class }; + private static final String GL4bcImplClassName = "jogamp.opengl.gl4.GL4bcImpl"; + private static final String GL4bcProcClassName = "jogamp.opengl.gl4.GL4bcProcAddressTable"; + private static final String GLES1ImplClassName = "jogamp.opengl.es1.GLES1Impl"; + private static final String GLES1ProcClassName = "jogamp.opengl.es1.GLES1ProcAddressTable"; + private static final String GLES3ImplClassName = "jogamp.opengl.es3.GLES3Impl"; + private static final String GLES3ProcClassName = "jogamp.opengl.es3.GLES3ProcAddressTable"; + + private static final Constructor getCtor(final String clazzName, final boolean glObject, final ClassLoader cl) { + try { + return ReflectionUtil.getConstructor(clazzName, glObject ? ctorGLArgs : ctorProcArgs, cl); + } catch (Throwable t) { + if( DEBUG ) { + System.err.println("Catched: "+t.getMessage()); + t.printStackTrace(); + } + return null; + } + } + + private static final void initGLCtorImpl() { + final ClassLoader classloader = GLProfile.class.getClassLoader(); + + // depends on hasDesktopGLFactory + { + final Constructor ctorGL = getCtor(GL4bcImplClassName, true, classloader); + final Constructor ctorProc = null != ctorGL ? getCtor(GL4bcProcClassName, false, classloader) : null; + if( null != ctorProc ) { + hasGL234Impl = true; + ctorGL234Impl = ctorGL; + ctorGL234ProcAddr = ctorProc; + } else { + hasGL234Impl = false; + ctorGL234Impl = null; + ctorGL234ProcAddr = null; + } + } + + // depends on hasEGLFactory + { + final Constructor ctorGL = getCtor(GLES1ImplClassName, true, classloader); + final Constructor ctorProc = null != ctorGL ? getCtor(GLES1ProcClassName, false, classloader) : null; + if( null != ctorProc ) { + hasGLES1Impl = true; + ctorGLES1Impl = ctorGL; + ctorGLES1ProcAddr = ctorProc; + } else { + hasGLES1Impl = false; + ctorGLES1Impl = null; + ctorGLES1ProcAddr = null; + } + } + { + final Constructor ctorGL = getCtor(GLES3ImplClassName, true, classloader); + final Constructor ctorProc = null != ctorGL ? getCtor(GLES3ProcClassName, false, classloader) : null; + if( null != ctorProc ) { + hasGLES3Impl = true; + ctorGLES3Impl = ctorGL; + ctorGLES3ProcAddr = ctorProc; + } else { + hasGLES3Impl = false; + ctorGLES3Impl = null; + ctorGLES3ProcAddr = null; + } + } + } /** * Tries the profiles implementation and native libraries. @@ -1551,17 +1635,12 @@ public class GLProfile { System.err.println(JoglVersion.getInstance()); } - ClassLoader classloader = GLProfile.class.getClassLoader(); + final ClassLoader classloader = GLProfile.class.getClassLoader(); isAWTAvailable = NativeWindowFactory.isAWTAvailable() && ReflectionUtil.isClassAvailable("javax.media.opengl.awt.GLCanvas", classloader) ; // JOGL - // depends on hasDesktopGLFactory - hasGL234Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.gl4.GL4bcImpl", classloader); - - // depends on hasEGLFactory - hasGLES1Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es1.GLES1Impl", classloader); - hasGLES3Impl = ReflectionUtil.isClassAvailable("jogamp.opengl.es3.GLES3Impl", classloader); + initGLCtorImpl(); // // Iteration of desktop GL availability detection diff --git a/src/jogl/classes/jogamp/opengl/GLContextImpl.java b/src/jogl/classes/jogamp/opengl/GLContextImpl.java index 431bba6de..b133fc017 100644 --- a/src/jogl/classes/jogamp/opengl/GLContextImpl.java +++ b/src/jogl/classes/jogamp/opengl/GLContextImpl.java @@ -54,7 +54,6 @@ import com.jogamp.common.util.ReflectionUtil; import com.jogamp.common.util.VersionNumber; import com.jogamp.common.util.VersionNumberString; import com.jogamp.common.util.locks.RecursiveLock; -import com.jogamp.gluegen.runtime.FunctionAddressResolver; import com.jogamp.gluegen.runtime.ProcAddressTable; import com.jogamp.gluegen.runtime.opengl.GLNameResolver; import com.jogamp.gluegen.runtime.opengl.GLProcAddressResolver; @@ -1127,17 +1126,17 @@ public abstract class GLContextImpl extends GLContext { // Helpers for various context implementations // - private Object createInstance(GLProfile glp, String suffix, Class[] cstrArgTypes, Object[] cstrArgs) { - return ReflectionUtil.createInstance(glp.getGLImplBaseClassName()+suffix, cstrArgTypes, cstrArgs, getClass().getClassLoader()); + private Object createInstance(GLProfile glp, boolean glObject, Object[] cstrArgs) { + return ReflectionUtil.createInstance(glp.getGLCtor(glObject), cstrArgs); } private boolean verifyInstance(GLProfile glp, String suffix, Object instance) { - return ReflectionUtil.instanceOf(instance, glp.getGLImplBaseClassName()+suffix); + return ReflectionUtil.instanceOf(instance, glp.getGLImplBaseClassName()+suffix); } /** Create the GL for this context. */ protected GL createGL(GLProfile glp) { - final GL gl = (GL) createInstance(glp, "Impl", new Class[] { GLProfile.class, GLContextImpl.class }, new Object[] { glp, this } ); + final GL gl = (GL) createInstance(glp, true, new Object[] { glp, this } ); /* FIXME: refactor dependence on Java 2D / JOGL bridge if (tracker != null) { @@ -1585,8 +1584,7 @@ public abstract class GLContextImpl extends GLContext { System.err.println(getThreadName() + ": GLContext GL ProcAddressTable reusing key("+contextFQN+") -> "+toHexString(table.hashCode())); } } else { - glProcAddressTable = (ProcAddressTable) createInstance(gl.getGLProfile(), "ProcAddressTable", - new Class[] { FunctionAddressResolver.class } , + glProcAddressTable = (ProcAddressTable) createInstance(gl.getGLProfile(), false, new Object[] { new GLProcAddressResolver() } ); resetProcAddressTable(getGLProcAddressTable()); synchronized(mappedContextTypeObjectLock) { diff --git a/src/newt/classes/jogamp/newt/DisplayImpl.java b/src/newt/classes/jogamp/newt/DisplayImpl.java index b485a4763..952e611f2 100644 --- a/src/newt/classes/jogamp/newt/DisplayImpl.java +++ b/src/newt/classes/jogamp/newt/DisplayImpl.java @@ -76,8 +76,7 @@ public abstract class DisplayImpl extends Display { }); final ClassLoader cl = DisplayImpl.class.getClassLoader(); - pngUtilAvail = ReflectionUtil.isClassAvailable("jogamp.opengl.util.pngj.PngReader", cl) && - ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.PNGPixelRect", cl); + pngUtilAvail = ReflectionUtil.isClassAvailable("com.jogamp.opengl.util.PNGPixelRect", cl); } public static final boolean isPNGUtilAvailable() { return pngUtilAvail; } -- cgit v1.2.3 From 1d2515da352a79c239efecdfa3e0fade47779781 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 13 Feb 2014 01:04:47 +0100 Subject: Bug 962 - AWTGLReadBufferUtil should use aligned BufferedImage [for resized images]; Fix GLReadBufferUtil GL_PACK_ROW_LENGTH AWTGLPixelBuffer is being reused when used via AWTGLPixelBufferProvider even when resized. AWTGLPixelBufferProvider uses GLPixelBufferProvider's requiresNewBuffer(..) which returns true if - allowRowStride==true and pixel-buffer size < required-size, or - allowRowStride==false and pixel-buffer size < required _or_ width doesn't match otherwise it returns true, i.e. the AWTGLPixelBuffer is reused. Hence the used BufferedImage might need to be aligned, i.e. using AWTGLPixelBuffer's getAlignedImage(..). +++ GLReadBufferUtil shall use current texture-data width for GL_PACK_ROW_LENGTH, not the static GLPixelBuffer's width, which may not reflect image dimension (resize) +++ --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- .../com/jogamp/opengl/util/GLPixelBuffer.java | 14 +- .../com/jogamp/opengl/util/GLReadBufferUtil.java | 30 +-- .../opengl/util/awt/AWTGLReadBufferUtil.java | 46 ++++- .../junit/jogl/awt/TestGLJPanelResize02AWT.java | 204 +++++++++++++++++++++ 6 files changed, 283 insertions(+), 19 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelResize02AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index f4db03a15..c87226784 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -38,7 +38,7 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintin REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.tile.TestTiledPrintingNIOImageSwingAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLCapabilities01NEWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteAWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen01GLPBufferNEWT -time 5000 @@ -107,6 +107,8 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestAWTCardLayout REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMixHwLw01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index cd9a2bb2e..a174f4322 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -392,8 +392,7 @@ function testawtswt() { #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestFloatUtil01MatrixMatrixMultNOUI $* #testnoawt com.jogamp.opengl.test.junit.jogl.math.TestBinary16NOUI $* -testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* - +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent01NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrent02NEWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLContextSurfaceLockNEWT $* @@ -583,6 +582,7 @@ testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $* +testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize02AWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java index a921a2818..223c23ebb 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLPixelBuffer.java @@ -324,9 +324,19 @@ public class GLPixelBuffer { /** The {@link GLPixelAttributes}. */ public final GLPixelAttributes pixelAttributes; - /** Width in pixels. */ + /** + * Width in pixels, representing {@link #buffer}'s {@link #byteSize}. + *

        + * May not represent actual image width as user may re-use buffer for different dimensions, see {@link #requiresNewBuffer(GL, int, int, int)}. + *

        + */ public final int width; - /** Height in pixels. */ + /** + * Height in pixels, representing {@link #buffer}'s {@link #byteSize}. + *

        + * May not represent actual image height as user may re-use buffer for different dimensions, see {@link #requiresNewBuffer(GL, int, int, int)}. + *

        + */ public final int height; /** Depth in pixels. */ public final int depth; diff --git a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java index b942c9ab2..b7d2980df 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/GLReadBufferUtil.java @@ -151,17 +151,6 @@ public class GLReadBufferUtil { * @see #GLReadBufferUtil(boolean, boolean) */ public boolean readPixels(GL gl, int inX, int inY, int inWidth, int inHeight, boolean mustFlipVertically) { - final int glerr0 = gl.glGetError(); - if(GL.GL_NO_ERROR != glerr0) { - System.err.println("Info: GLReadBufferUtil.readPixels: pre-exisiting GL error 0x"+Integer.toHexString(glerr0)); - } - final GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); - final int internalFormat; - if(gl.isGL2GL3() && 3 == componentCount) { - internalFormat = GL.GL_RGB; - } else { - internalFormat = (4 == componentCount) ? GL.GL_RGBA : GL.GL_RGB; - } final GLDrawable drawable = gl.getContext().getGLReadDrawable(); final int width, height; if( 0 >= inWidth || drawable.getWidth() < inWidth ) { @@ -174,6 +163,23 @@ public class GLReadBufferUtil { } else { height= inHeight; } + return readPixelsImpl(drawable, gl, inX, inY, width, height, mustFlipVertically); + } + + protected boolean readPixelsImpl(final GLDrawable drawable, final GL gl, + final int inX, final int inY, final int width, final int height, + final boolean mustFlipVertically) { + final int glerr0 = gl.glGetError(); + if(GL.GL_NO_ERROR != glerr0) { + System.err.println("Info: GLReadBufferUtil.readPixels: pre-exisiting GL error 0x"+Integer.toHexString(glerr0)); + } + final GLPixelAttributes pixelAttribs = pixelBufferProvider.getAttributes(gl, componentCount); + final int internalFormat; + if(gl.isGL2GL3() && 3 == componentCount) { + internalFormat = GL.GL_RGB; + } else { + internalFormat = (4 == componentCount) ? GL.GL_RGBA : GL.GL_RGB; + } final boolean flipVertically; if( drawable.isGLOriented() ) { @@ -216,7 +222,7 @@ public class GLReadBufferUtil { if(res) { psm.setAlignment(gl, alignment, alignment); if(gl.isGL2GL3()) { - gl.getGL2GL3().glPixelStorei(GL2GL3.GL_PACK_ROW_LENGTH, readPixelBuffer.width); + gl.getGL2GL3().glPixelStorei(GL2GL3.GL_PACK_ROW_LENGTH, width); } readPixelBuffer.clear(); try { diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java index f5d31a132..9490e041b 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/AWTGLReadBufferUtil.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.util.awt; import java.awt.image.BufferedImage; import javax.media.opengl.GL; +import javax.media.opengl.GLDrawable; import javax.media.opengl.GLProfile; import com.jogamp.opengl.util.GLReadBufferUtil; @@ -51,12 +52,53 @@ public class AWTGLReadBufferUtil extends GLReadBufferUtil { public AWTGLPixelBuffer getAWTGLPixelBuffer() { return (AWTGLPixelBuffer)this.getPixelBuffer(); } + /** + * Read the drawable's pixels to TextureData and Texture, if requested at construction, + * and returns an aligned {@link BufferedImage}. + * + * @param gl the current GL context object. It's read drawable is being used as the pixel source. + * @param awtOrientation flips the data vertically if true. + * The context's drawable {@link GLDrawable#isGLOriented()} state + * is taken into account. + * Vertical flipping is propagated to TextureData + * and handled in a efficient manner there (TextureCoordinates and TextureIO writer). + * @see #AWTGLReadBufferUtil(GLProfile, boolean) + */ public BufferedImage readPixelsToBufferedImage(GL gl, boolean awtOrientation) { return readPixelsToBufferedImage(gl, 0, 0, 0, 0, awtOrientation); } + + /** + * Read the drawable's pixels to TextureData and Texture, if requested at construction, + * and returns an aligned {@link BufferedImage}. + * + * @param gl the current GL context object. It's read drawable is being used as the pixel source. + * @param inX readPixel x offset + * @param inY readPixel y offset + * @param inWidth optional readPixel width value, used if [1 .. drawable.width], otherwise using drawable.width + * @param inHeight optional readPixel height, used if [1 .. drawable.height], otherwise using drawable.height + * @param awtOrientation flips the data vertically if true. + * The context's drawable {@link GLDrawable#isGLOriented()} state + * is taken into account. + * Vertical flipping is propagated to TextureData + * and handled in a efficient manner there (TextureCoordinates and TextureIO writer). + * @see #AWTGLReadBufferUtil(GLProfile, boolean) + */ public BufferedImage readPixelsToBufferedImage(GL gl, int inX, int inY, int inWidth, int inHeight, boolean awtOrientation) { - if( readPixels(gl, inX, inY, inWidth, inHeight, awtOrientation) ) { - final BufferedImage image = getAWTGLPixelBuffer().image; + final GLDrawable drawable = gl.getContext().getGLReadDrawable(); + final int width, height; + if( 0 >= inWidth || drawable.getWidth() < inWidth ) { + width = drawable.getWidth(); + } else { + width = inWidth; + } + if( 0 >= inHeight || drawable.getHeight() < inHeight ) { + height = drawable.getHeight(); + } else { + height= inHeight; + } + if( readPixelsImpl(drawable, gl, inX, inY, width, height, awtOrientation) ) { + final BufferedImage image = getAWTGLPixelBuffer().getAlignedImage(width, height); if( getTextureData().getMustFlipVertically() ) { ImageUtil.flipImageVertically(image); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelResize02AWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelResize02AWT.java new file mode 100644 index 000000000..dabfb737a --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelResize02AWT.java @@ -0,0 +1,204 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.awt; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +import javax.imageio.ImageIO; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; + +/** + * Multiple GLJPanels in a JFrame + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestGLJPanelResize02AWT extends UITestCase { + + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(); + } + + public void test(final GLCapabilitiesImmutable caps, final boolean useSwingDoubleBuffer) { + final AWTGLReadBufferUtil awtGLReadBufferUtil = new AWTGLReadBufferUtil(caps.getGLProfile(), false); + final JFrame frame = new JFrame(); + final Dimension d = new Dimension(320, 240); + + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setLocation(64, 64); + final JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.setDoubleBuffered(useSwingDoubleBuffer); + frame.getContentPane().add(panel); + + final GLJPanel glad = createGLJPanel(useSwingDoubleBuffer, caps, d); + final GearsES2 gears = new GearsES2(0); + gears.setVerbose(false); + glad.addGLEventListener(gears); + glad.addGLEventListener(new SnapshotGLEL(awtGLReadBufferUtil)); + panel.add(glad); + frame.pack(); + frame.setVisible(true); + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + final Dimension size0 = frame.getSize(); + final Dimension size1 = new Dimension(size0.width+30, size0.height+30); + final Dimension size2 = new Dimension(size0.width-30, size0.height-30); + try { + try { Thread.sleep(duration); } catch (InterruptedException e) { } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(size1); + frame.validate(); + } } ); + try { Thread.sleep(duration); } catch (InterruptedException e) { } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(size2); + frame.validate(); + } } ); + try { Thread.sleep(duration); } catch (InterruptedException e) { } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(size0); + frame.validate(); + } } ); + try { Thread.sleep(duration); } catch (InterruptedException e) { } + } catch (Exception e1) { + e1.printStackTrace(); + } + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.dispose(); + } } ); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + private class SnapshotGLEL implements GLEventListener { + final AWTGLReadBufferUtil glReadBufferUtil; + int i; + + SnapshotGLEL(final AWTGLReadBufferUtil glReadBufferUtil) { + this.glReadBufferUtil = glReadBufferUtil; + i = 0; + } + + @Override + public void init(GLAutoDrawable drawable) { } + @Override + public void dispose(GLAutoDrawable drawable) { } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + @Override + public void display(GLAutoDrawable drawable) { + snapshot(i++, drawable.getGL(), TextureIO.PNG, null); + } + public void snapshot(int sn, GL gl, String fileSuffix, String destPath) { + final GLDrawable drawable = gl.getContext().getGLReadDrawable(); + final String filenameAWT = getSnapshotFilename(sn, "awt", + drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), + glReadBufferUtil.hasAlpha(), fileSuffix, destPath); + final String filenameJGL = getSnapshotFilename(sn, "jgl", + drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), + glReadBufferUtil.hasAlpha(), fileSuffix, destPath); + System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filenameAWT+", "+filenameJGL); + gl.glFinish(); // just make sure rendering finished .. + final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, true /* awtOrientation */); + final File fout = new File(filenameAWT); + try { + ImageIO.write(image, "png", fout); + } catch (IOException e) { + e.printStackTrace(); + } + glReadBufferUtil.write(new File(filenameJGL)); + } + }; + + private GLJPanel createGLJPanel(final boolean useSwingDoubleBuffer, final GLCapabilitiesImmutable caps, final Dimension size) { + final GLJPanel canvas = new GLJPanel(caps); + canvas.setSize(size); + canvas.setPreferredSize(size); + canvas.setMinimumSize(size); + canvas.setDoubleBuffered(useSwingDoubleBuffer); + return canvas; + } + + static GLCapabilitiesImmutable caps = null; + + @Test + public void test00() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useSwingDoubleBuffer*/); + } + + static long duration = 500; // ms + + public static void main(String[] args) { + for(int i=0; i Date: Thu, 13 Feb 2014 21:32:36 +0100 Subject: Bug 975 - GLJPanel's OffscreenDrawable shall not double swap (custom swap by GLEventListener using [AWT]GLReadBufferUtil) When utilizing [AWT]GLReadBufferUtil it is usually desired to read from the front-buffer instead the back-buffer. The latter may not be defined, e.g. when using MSAA. A GLEventListener utilizing [AWT]GLReadBufferUtil, must perform the drawable.swapBuffers() to be able to read from the front-buffer. Usually GLAutoDrawable.setAutoSwapBuffer(false) should be called here, to avoid a double swap - however GLJPanel does not support toggling auto-swap since it requires to control swap for it's own read-pixels. Remedy for GLJPanel: - GLJPanel issues helper.setAutoSwapBufferMode(false) - immutable - Enable GLJPanel.swapBuffer() if initializes This was previously disabled. - GLJPanel's OffscreenBackend listens to surfaceUpdated, to be notified whether postGL needs to swap buffer or the drawable.swapBuffer() was already called between preGL and postGL. See unit tests adding/removing a snapshot GLEventListener performing swapBuffers() and setting auto-swap accordingly. --- make/scripts/tests-win.bat | 4 +- make/scripts/tests.sh | 4 +- .../classes/javax/media/opengl/awt/GLJPanel.java | 74 ++++--- .../test/junit/jogl/acore/GLReadBuffer00Base.java | 97 ++++++++++ .../jogl/acore/TestGLReadBuffer01GLJPanelAWT.java | 214 +++++++++++++++++++++ .../jogl/acore/TestGLReadBuffer01GLWindowNEWT.java | 158 +++++++++++++++ .../junit/jogl/awt/TestGLJPanelResize02AWT.java | 204 -------------------- 7 files changed, 524 insertions(+), 231 deletions(-) create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java create mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java delete mode 100644 src/test/com/jogamp/opengl/test/junit/jogl/awt/TestGLJPanelResize02AWT.java (limited to 'make/scripts') diff --git a/make/scripts/tests-win.bat b/make/scripts/tests-win.bat index c87226784..df5ec492a 100755 --- a/make/scripts/tests-win.bat +++ b/make/scripts/tests-win.bat @@ -97,6 +97,9 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimat REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.TestAWTCardLayoutAnimatorStartStopBug532 %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT %* +scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLReadBuffer01GLJPanelAWT %* +REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.acore.TestGLReadBuffer01GLWindowNEWT %* + REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestSwingAWT01GLn REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock00AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT %* @@ -108,7 +111,6 @@ REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestJScrollPaneMi REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestBug642JSplitPaneMixHwLw01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestIsRealizedConcurrency01AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT %* -scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize02AWT %* REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.newt.TestSwingAWTRobotUsageBeforeJOGLInitBug411 REM scripts\java-win.bat com.jogamp.opengl.test.junit.jogl.glsl.TestTransformFeedbackVaryingsBug407NEWT diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index a174f4322..ae8075994 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -485,6 +485,9 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT $* +testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLReadBuffer01GLJPanelAWT $* +#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLReadBuffer01GLWindowNEWT $* + # # NEWT # @@ -582,7 +585,6 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLCanvasAWTActionDeadlock02AWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelTextureStateAWT $* #testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize01AWT $* -testawt com.jogamp.opengl.test.junit.jogl.awt.TestGLJPanelResize02AWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv0AppletAWT $* #testawt com.jogamp.opengl.test.bugs.Bug735Inv1AppletAWT $* diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 522585f16..66a757d10 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -60,6 +60,7 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.opengl.GL; import javax.media.opengl.GL2; @@ -222,7 +223,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return singleAWTGLPixelBufferProvider; } - private final GLDrawableHelper helper = new GLDrawableHelper(); + private final GLDrawableHelper helper; private volatile boolean isInitialized; // @@ -352,9 +353,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.glProfile = offscreenCaps.getGLProfile(); this.factory = GLDrawableFactoryImpl.getFactoryImpl(glProfile); this.chooser = chooser; + + helper = new GLDrawableHelper(); + helper.setAutoSwapBufferMode(false); /** Always handles buffer swapping in Backend! */ if( null != shareWith ) { helper.setSharedContext(null, shareWith); } + this.setFocusable(true); // allow keyboard input! this.addHierarchyListener(hierarchyListener); this.isShowing = isShowing(); @@ -941,34 +946,25 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public void setAutoSwapBufferMode(boolean onOrOff) { - // In the current implementation this is a no-op. Both the pbuffer - // and pixmap based rendering paths use a single-buffered surface - // so swapping the buffers doesn't do anything. We also don't - // currently have the provision to skip copying the data to the - // Swing portion of the GLJPanel in any of the rendering paths. + // In the current implementation this is a no-op. + // All Backend's require control of buffer swapping, + // i.e. as required for MSAA offscreen FBO buffer. } @Override public boolean getAutoSwapBufferMode() { - // In the current implementation this is a no-op. Both the pbuffer - // and pixmap based rendering paths use a single-buffered surface - // so swapping the buffers doesn't do anything. We also don't - // currently have the provision to skip copying the data to the - // Swing portion of the GLJPanel in any of the rendering paths. + // In the current implementation this is a no-op. + // All Backend's require control of buffer swapping, + // i.e. as required for MSAA offscreen FBO buffer. return true; } @Override public void swapBuffers() { - // In the current implementation this is a no-op. Both the pbuffer - // and pixmap based rendering paths use a single-buffered surface - // so swapping the buffers doesn't do anything. We also don't - // currently have the provision to skip copying the data to the - // Swing portion of the GLJPanel in any of the rendering paths. - if( printActive && isInitialized) { + if( isInitialized ) { final Backend b = backend; if ( null != b ) { - b.getDrawable().swapBuffers(); + b.swapBuffers(); } } } @@ -1365,6 +1361,11 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing */ public boolean preGL(Graphics g); + /** + * Shall invoke underlying drawable's swapBuffer. + */ + public void swapBuffers(); + /** * Called after the OpenGL work is done in init() and display(). * The isDisplay argument indicates whether this was called on @@ -1401,6 +1402,8 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private volatile GLContextImpl offscreenContext; // volatile: avoid locking for read-only access private boolean flipVertical; + private boolean needsSwapBuffers = true; + // For saving/restoring of OpenGL state during ReadPixels private final GLPixelStorageModes psm = new GLPixelStorageModes(); @@ -1436,6 +1439,12 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing chooser, panelWidth, panelHeight); offscreenDrawable.setRealized(true); + offscreenDrawable.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { + @Override + public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { + needsSwapBuffers = false; + } } ); + offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith[0]); offscreenContext.setContextCreationFlags(additionalCtxCreationFlags); if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { @@ -1453,8 +1462,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing ", isGL2ES2 " + gl.isGL2ES2()+"]"); } if( useGLSLFlip ) { - final boolean _autoSwapBufferMode = helper.getAutoSwapBufferMode(); - helper.setAutoSwapBufferMode(false); final GLFBODrawable fboDrawable = (GLFBODrawable) offscreenDrawable; fboDrawable.setTextureUnit( GLJPanel.this.requestedTextureUnit ); try { @@ -1475,7 +1482,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing fboFlipped.destroy(gl); fboFlipped = null; } - helper.setAutoSwapBufferMode(_autoSwapBufferMode); } } else { fboFlipped = null; @@ -1558,10 +1564,18 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public final boolean preGL(Graphics g) { - // Empty in this implementation + needsSwapBuffers = true; return true; } + @Override + public final void swapBuffers() { + final GLDrawable d = offscreenDrawable; + if( null != d ) { + d.swapBuffers(); + } + } + @Override public final void postGL(Graphics g, boolean isDisplay) { if (isDisplay) { @@ -1652,7 +1666,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer()); } - offscreenDrawable.swapBuffers(); + if( needsSwapBuffers ) { + offscreenDrawable.swapBuffers(); + } if(null != glslTextureRaster) { // implies flippedVertical final boolean viewportChange; @@ -1924,13 +1940,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public final GLCapabilitiesImmutable getChosenGLCapabilities() { - // FIXME: should do better than this; is it possible to using only platform-independent code? + // FIXME: should do better than this; is it possible to query J2D Caps ? return new GLCapabilities(null); } @Override public final GLProfile getGLProfile() { - // FIXME: should do better than this; is it possible to using only platform-independent code? + // FIXME: should do better than this; is it possible to query J2D's Profile ? return GLProfile.getDefault(GLProfile.getDefaultDevice()); } @@ -2077,6 +2093,14 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing return true; } + @Override + public final void swapBuffers() { + final GLDrawable d = joglDrawable; + if( null != d ) { + d.swapBuffers(); + } + } + @Override public final void postGL(Graphics g, boolean isDisplay) { // Cause OpenGL pipeline to flush its results because diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java new file mode 100644 index 000000000..c5885d6b4 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java @@ -0,0 +1,97 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.lang.reflect.InvocationTargetException; + +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilities; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; + +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import com.jogamp.opengl.test.junit.util.UITestCase; + +/** + * Multiple GLJPanels in a JFrame + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public abstract class GLReadBuffer00Base extends UITestCase { + + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(); + } + + protected abstract void test(final GLCapabilitiesImmutable caps, final boolean useSwingDoubleBuffer, final boolean skipGLOrientationVerticalFlip); + + private boolean defAutoSwapBufferMode = true; + protected void addSnapshotGLEL(final GLAutoDrawable glad, final GLEventListener snapshotGLEL) { + defAutoSwapBufferMode = glad.getAutoSwapBufferMode(); + glad.setAutoSwapBufferMode(false); + glad.addGLEventListener(snapshotGLEL); + } + protected void removeSnapshotGLEL(final GLAutoDrawable glad, final GLEventListener snapshotGLEL) { + glad.removeGLEventListener(snapshotGLEL); + glad.setAutoSwapBufferMode(defAutoSwapBufferMode); + } + + + @Test + public void test00_MSAA0_DefFlip() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useSwingDoubleBuffer*/, false /* skipGLOrientationVerticalFlip */); + } + + @Test + public void test01_MSAA0_UsrFlip() throws InterruptedException, InvocationTargetException { + test(new GLCapabilities(null), false /*useSwingDoubleBuffer*/, true /* skipGLOrientationVerticalFlip */); + } + + @Test + public void test10_MSAA4_DefFlip() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(null); + caps.setNumSamples(4); + caps.setSampleBuffers(true); + test(caps, false /*useSwingDoubleBuffer*/, false /* skipGLOrientationVerticalFlip */); + } + + @Test + public void test11_MSAA4_UsrFlip() throws InterruptedException, InvocationTargetException { + final GLCapabilities caps = new GLCapabilities(null); + caps.setNumSamples(4); + caps.setSampleBuffers(true); + test(caps, false /*useSwingDoubleBuffer*/, true /* skipGLOrientationVerticalFlip */); + } + + static long duration = 500; // ms +} diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java new file mode 100644 index 000000000..4ad84aa73 --- /dev/null +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java @@ -0,0 +1,214 @@ +/** + * Copyright 2014 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ +package com.jogamp.opengl.test.junit.jogl.acore; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; +import javax.media.opengl.GL; +import javax.media.opengl.GLAutoDrawable; +import javax.media.opengl.GLCapabilitiesImmutable; +import javax.media.opengl.GLDrawable; +import javax.media.opengl.GLEventListener; +import javax.media.opengl.GLProfile; +import javax.media.opengl.awt.GLJPanel; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.junit.Assume; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; +import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.util.Animator; +import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil; +import com.jogamp.opengl.util.texture.TextureIO; + +/** + * Multiple GLJPanels in a JFrame + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { + + @BeforeClass + public static void initClass() { + GLProfile.initSingleton(); + } + + public void test(final GLCapabilitiesImmutable caps, final boolean useSwingDoubleBuffer, final boolean skipGLOrientationVerticalFlip) { + final AWTGLReadBufferUtil awtGLReadBufferUtil = new AWTGLReadBufferUtil(caps.getGLProfile(), false); + final JFrame frame = new JFrame(); + final Dimension d = new Dimension(320, 240); + final GLJPanel glad = createGLJPanel(skipGLOrientationVerticalFlip, useSwingDoubleBuffer, caps, d); + try { + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setLocation(64, 64); + final JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.setDoubleBuffered(useSwingDoubleBuffer); + frame.getContentPane().add(panel); + + final GearsES2 gears = new GearsES2(0); + gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + gears.setVerbose(false); + glad.addGLEventListener(gears); + panel.add(glad); + frame.pack(); + frame.setVisible(true); + } } ); + } catch( Throwable throwable ) { + throwable.printStackTrace(); + Assume.assumeNoException( throwable ); + } + final GLEventListener snapshotGLEL = new SnapshotGLEL(awtGLReadBufferUtil, skipGLOrientationVerticalFlip); + final Dimension size0 = frame.getSize(); + final Dimension size1 = new Dimension(size0.width+100, size0.height+100); + final Dimension size2 = new Dimension(size0.width-100, size0.height-100); + try { + final Animator anim = new Animator(glad); + anim.start(); + try { Thread.sleep(2*duration); } catch (InterruptedException e) { } + anim.stop(); + addSnapshotGLEL(glad, snapshotGLEL); + glad.display(); + + try { Thread.sleep(duration); } catch (InterruptedException e) { } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(size1); + frame.validate(); + } } ); + try { Thread.sleep(duration); } catch (InterruptedException e) { } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(size2); + frame.validate(); + } } ); + try { Thread.sleep(duration); } catch (InterruptedException e) { } + javax.swing.SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(size0); + frame.validate(); + } } ); + try { Thread.sleep(duration); } catch (InterruptedException e) { } + + removeSnapshotGLEL(glad, snapshotGLEL); + anim.start(); + try { Thread.sleep(2*duration); } catch (InterruptedException e) { } + anim.stop(); + } catch (Exception e1) { + e1.printStackTrace(); + } + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.dispose(); + } } ); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + private GLJPanel createGLJPanel(final boolean skipGLOrientationVerticalFlip, final boolean useSwingDoubleBuffer, final GLCapabilitiesImmutable caps, final Dimension size) { + final GLJPanel canvas = new GLJPanel(caps); + canvas.setSize(size); + canvas.setPreferredSize(size); + canvas.setMinimumSize(size); + canvas.setDoubleBuffered(useSwingDoubleBuffer); + canvas.setSkipGLOrientationVerticalFlip(skipGLOrientationVerticalFlip); + return canvas; + } + + private class SnapshotGLEL implements GLEventListener { + final AWTGLReadBufferUtil glReadBufferUtil; + final boolean skipGLOrientationVerticalFlip; + int i; + + SnapshotGLEL(final AWTGLReadBufferUtil glReadBufferUtil, final boolean skipGLOrientationVerticalFlip) { + this.glReadBufferUtil = glReadBufferUtil; + this.skipGLOrientationVerticalFlip = skipGLOrientationVerticalFlip; + i = 0; + } + + @Override + public void init(GLAutoDrawable drawable) { } + @Override + public void dispose(GLAutoDrawable drawable) { } + @Override + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } + @Override + public void display(GLAutoDrawable drawable) { + snapshot(i++, drawable.getGL(), TextureIO.PNG, null); + } + public void snapshot(int sn, GL gl, String fileSuffix, String destPath) { + final GLDrawable drawable = gl.getContext().getGLReadDrawable(); + final String filenameAWT = getSnapshotFilename(sn, "awt", + drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), + glReadBufferUtil.hasAlpha(), fileSuffix, destPath); + // gl.glFinish(); // just make sure rendering finished .. + drawable.swapBuffers(); + final boolean awtOrientation = !( drawable.isGLOriented() && skipGLOrientationVerticalFlip ); + System.err.println(Thread.currentThread().getName()+": ** screenshot: awtOrient/v-flip "+awtOrientation+", "+filenameAWT); + + final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, awtOrientation); + final File fout = new File(filenameAWT); + try { + ImageIO.write(image, "png", fout); + } catch (IOException e) { + e.printStackTrace(); + } + /** + final String filenameJGL = getSnapshotFilename(sn, "jgl", + drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), + glReadBufferUtil.hasAlpha(), fileSuffix, destPath); + glReadBufferUtil.write(new File(filenameJGL)); + */ + } + }; + + static GLCapabilitiesImmutable caps = null; + + public static void main(String[] args) { + for(int i=0; i Date: Fri, 14 Feb 2014 06:37:13 +0100 Subject: Bug 975 - GLJPanel's OffscreenDrawable shall not double swap - Use default auto-swap mechanims Refines commit 908ebd99d1eb57ce773a1fdd67c76886da86b9e6 Note that the test case decide whether to auto-swap (after read-pixels) or not auto-swap (manual swap before read-pixels). See UITestCase.swapBuffersBeforeRead(GLCapabilitiesImmutable chosenCaps): Determines whether the chosen GLCapabilitiesImmutable requires a swap-buffers before reading pixels. Usually one uses the default-read-buffer, i.e. GL.GL_FRONT for single-buffer and GL.GL_BACK for double-buffer GLDrawables and GL.GL_COLOR_ATTACHMENT0 for offscreen framebuffer objects. Here swap-buffers shall happen after calling reading pixels, the default. However, multisampling offscreen GLFBODrawables utilize swap-buffers to downsample the multisamples into the readable sampling sink. In this case, we require a swap-buffers before reading pixels. Returns: chosenCaps.isFBO() && chosenCaps.getSampleBuffers() +++ - GLJPanel: - Remove SurfaceUpdatedListener mechanism in favor of default auto-swap-buffer via GLDrawableHelper. This removes complexity. - postGL does not need to perform explicit swapBuffer operation, but rely on GLDrawableHelper and the default mechanism. This is also compatible w/ J2D backend. - Use GLDrawableHelper for setAutoSwapBufferMode(..) and getAutoSwapBufferMode() +++ UnitTests: - UITestCase: - Add 'boolean swapBuffersBeforeRead(GLCapabilitiesImmutable chosenCaps)' to determine whether swapBuffers() must occure before read-pixels. See above. - GLReadBuffer00Base* - remove explicit addSnapshotGLEL/removeSnapshotGLEL - add TextRendererGLEL, to display frame-count and -dimension - SnapshotGLEL* - simply toggle auto-swap in their init(..) and dispose(..) method! - clear back-buffer if 'swapBuffersBeforeRead' to test whether the right buffer is being used for read-pixels. --- make/scripts/tests.sh | 2 + .../classes/javax/media/opengl/awt/GLJPanel.java | 30 +---- .../test/junit/jogl/acore/GLReadBuffer00Base.java | 146 ++++++++++++++++++--- .../jogl/acore/TestGLReadBuffer01GLJPanelAWT.java | 51 ++++--- .../jogl/acore/TestGLReadBuffer01GLWindowNEWT.java | 52 +++++--- .../jogamp/opengl/test/junit/util/UITestCase.java | 99 ++++++++------ 6 files changed, 267 insertions(+), 113 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index ae8075994..49b1b46ef 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -209,6 +209,7 @@ function jrun() { #D_ARGS="-Dnewt.debug.Window" #D_ARGS="-Xprof" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel" + #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.debug.GLJPanel.Viewport" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.Java2D -Djogl.debug.GLJPanel -Djogl.gljpanel.noglsl -Djogl.gljpanel.awtverticalflip" #D_ARGS="-Djogl.debug.GLJPanel -Djogl.debug.DebugGL" @@ -219,6 +220,7 @@ function jrun() { #D_ARGS="-Dnativewindow.debug.NativeWindow" #D_ARGS="-Dnativewindow.osx.calayer.bugfree" #D_ARGS="-Dnativewindow.debug.ToolkitLock" + #D_ARGS="-Djogl.debug.graph.curve" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLCode -Djogl.debug.TraceGL" #D_ARGS="-Djogl.debug.graph.curve -Djogl.debug.GLSLState" #D_ARGS="-Djogamp.debug.TempJarCache -Djogamp.debug.JarUtil -Djogamp.debug.IOUtil" diff --git a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java index 66a757d10..c80b405b5 100644 --- a/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java +++ b/src/jogl/classes/javax/media/opengl/awt/GLJPanel.java @@ -60,7 +60,6 @@ import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; -import javax.media.nativewindow.SurfaceUpdatedListener; import javax.media.nativewindow.WindowClosingProtocol; import javax.media.opengl.GL; import javax.media.opengl.GL2; @@ -355,7 +354,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing this.chooser = chooser; helper = new GLDrawableHelper(); - helper.setAutoSwapBufferMode(false); /** Always handles buffer swapping in Backend! */ if( null != shareWith ) { helper.setSharedContext(null, shareWith); } @@ -945,18 +943,13 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing } @Override - public void setAutoSwapBufferMode(boolean onOrOff) { - // In the current implementation this is a no-op. - // All Backend's require control of buffer swapping, - // i.e. as required for MSAA offscreen FBO buffer. + public void setAutoSwapBufferMode(boolean enable) { + helper.setAutoSwapBufferMode(enable); } @Override public boolean getAutoSwapBufferMode() { - // In the current implementation this is a no-op. - // All Backend's require control of buffer swapping, - // i.e. as required for MSAA offscreen FBO buffer. - return true; + return helper.getAutoSwapBufferMode(); } @Override @@ -1402,8 +1395,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing private volatile GLContextImpl offscreenContext; // volatile: avoid locking for read-only access private boolean flipVertical; - private boolean needsSwapBuffers = true; - // For saving/restoring of OpenGL state during ReadPixels private final GLPixelStorageModes psm = new GLPixelStorageModes(); @@ -1439,12 +1430,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing chooser, panelWidth, panelHeight); offscreenDrawable.setRealized(true); - offscreenDrawable.getNativeSurface().addSurfaceUpdatedListener(new SurfaceUpdatedListener() { - @Override - public final void surfaceUpdated(Object updater, NativeSurface ns, long when) { - needsSwapBuffers = false; - } } ); - offscreenContext = (GLContextImpl) offscreenDrawable.createContext(shareWith[0]); offscreenContext.setContextCreationFlags(additionalCtxCreationFlags); if( GLContext.CONTEXT_NOT_CURRENT < offscreenContext.makeCurrent() ) { @@ -1564,7 +1549,7 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public final boolean preGL(Graphics g) { - needsSwapBuffers = true; + // Empty in this implementation return true; } @@ -1579,6 +1564,9 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing @Override public final void postGL(Graphics g, boolean isDisplay) { if (isDisplay) { + // offscreenDrawable is already swapped, + // either by GLDrawableHelper.invoke or user's GLEL according to auto-swap-buffer-mode. + final GL gl = offscreenContext.getGL(); final int componentCount; @@ -1666,10 +1654,6 @@ public class GLJPanel extends JPanel implements AWTGLAutoDrawable, WindowClosing gl2es3.glReadBuffer(gl2es3.getDefaultReadBuffer()); } - if( needsSwapBuffers ) { - offscreenDrawable.swapBuffers(); - } - if(null != glslTextureRaster) { // implies flippedVertical final boolean viewportChange; final int[] usrViewport = new int[] { 0, 0, 0, 0 }; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java index c5885d6b4..2ad622d14 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/GLReadBuffer00Base.java @@ -27,8 +27,10 @@ */ package com.jogamp.opengl.test.junit.jogl.acore; +import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import javax.media.opengl.GL2ES2; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilities; import javax.media.opengl.GLCapabilitiesImmutable; @@ -40,7 +42,15 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runners.MethodSorters; +import com.jogamp.graph.curve.Region; +import com.jogamp.graph.curve.opengl.RenderState; +import com.jogamp.graph.curve.opengl.TextRenderer; +import com.jogamp.graph.font.Font; +import com.jogamp.graph.font.FontFactory; +import com.jogamp.graph.geom.opengl.SVertex; +import com.jogamp.opengl.math.geom.AABBox; import com.jogamp.opengl.test.junit.util.UITestCase; +import com.jogamp.opengl.util.glsl.ShaderState; /** * Multiple GLJPanels in a JFrame @@ -48,24 +58,128 @@ import com.jogamp.opengl.test.junit.util.UITestCase; @FixMethodOrder(MethodSorters.NAME_ASCENDING) public abstract class GLReadBuffer00Base extends UITestCase { - @BeforeClass - public static void initClass() { - GLProfile.initSingleton(); + public static abstract class TextRendererGLELBase implements GLEventListener { + final float[] textPosition = new float[] {0,0,0}; + final int[] texSize = new int[] { 0 }; + final int fontSize = 24; + + final Font font; + final RenderState rs; + final TextRenderer renderer; + + boolean flipVerticalInGLOrientation = false; + + public TextRendererGLELBase() { + { + Font _font = null; + try { + _font = FontFactory.get(FontFactory.UBUNTU).getDefault(); + } catch (IOException e) { + e.printStackTrace(); + } + this.font = _font; + } + if( null != font ) { + this.rs = RenderState.createRenderState(new ShaderState(), SVertex.factory()); + this.renderer = TextRenderer.create(rs, Region.VBAA_RENDERING_BIT); + } else { + this.rs = null; + this.renderer = null; + } + } + + public void setFlipVerticalInGLOrientation(boolean v) { flipVerticalInGLOrientation=v; } + public final TextRenderer getRenderer() { return renderer; } + + public void init(GLAutoDrawable drawable) { + if( null != renderer ) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + renderer.init(gl); + renderer.setAlpha(gl, 0.99f); + renderer.setColorStatic(gl, 1.0f, 1.0f, 1.0f); + final ShaderState st = rs.getShaderState(); + st.useProgram(gl, false); + } + } + + public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { + if( null != renderer ) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + final ShaderState st = rs.getShaderState(); + st.useProgram(gl, true); + // renderer.reshapePerspective(gl, 45.0f, width, height, 0.1f, 1000.0f); + renderer.reshapeOrtho(gl, width, height, 0.1f, 1000.0f); + st.useProgram(gl, false); + texSize[0] = width * 2; + } + } + + public abstract void display(GLAutoDrawable drawable); + + public void dispose(GLAutoDrawable drawable) { + if( null != renderer ) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + renderer.destroy(gl); + } + } + + int lastRow = -1; + + public void renderString(GLAutoDrawable drawable, String text, int column, int row, int z0) { + if( null != renderer ) { + final GL2ES2 gl = drawable.getGL().getGL2ES2(); + final int height = drawable.getHeight(); + + int dx = 0; + int dy = height; + if(0>row) { + row = lastRow + 1; + } + AABBox textBox = font.getStringBounds(text, fontSize); + dx += font.getAdvanceWidth('X', fontSize) * column; + dy -= (int)textBox.getHeight() * ( row + 1 ); + + final ShaderState st = rs.getShaderState(); + st.useProgram(gl, true); + gl.glEnable(GL2ES2.GL_BLEND); + renderer.resetModelview(null); + renderer.translate(gl, dx, dy, z0); + if( flipVerticalInGLOrientation && drawable.isGLOriented() ) { + renderer.scale(gl, 1f, -1f, 1f); + } + renderer.drawString3D(gl, font, text, textPosition, fontSize, texSize); + st.useProgram(gl, false); + gl.glDisable(GL2ES2.GL_BLEND); + + lastRow = row; + } + } } + public static class TextRendererGLEL extends TextRendererGLELBase { + int frameNo = 0; - protected abstract void test(final GLCapabilitiesImmutable caps, final boolean useSwingDoubleBuffer, final boolean skipGLOrientationVerticalFlip); + public TextRendererGLEL() { + super(); + } - private boolean defAutoSwapBufferMode = true; - protected void addSnapshotGLEL(final GLAutoDrawable glad, final GLEventListener snapshotGLEL) { - defAutoSwapBufferMode = glad.getAutoSwapBufferMode(); - glad.setAutoSwapBufferMode(false); - glad.addGLEventListener(snapshotGLEL); + @Override + public void display(GLAutoDrawable drawable) { + frameNo++; + final String text = String.format("Frame %04d: %04dx%04d", frameNo, drawable.getWidth(), drawable.getHeight()); + if( null != renderer ) { + renderString(drawable, text, 0, 0, -1); + } else { + System.err.println(text); + } + } } - protected void removeSnapshotGLEL(final GLAutoDrawable glad, final GLEventListener snapshotGLEL) { - glad.removeGLEventListener(snapshotGLEL); - glad.setAutoSwapBufferMode(defAutoSwapBufferMode); + + @BeforeClass + public static void initClass() throws IOException { + GLProfile.initSingleton(); } + protected abstract void test(final GLCapabilitiesImmutable caps, final boolean useSwingDoubleBuffer, final boolean skipGLOrientationVerticalFlip); @Test public void test00_MSAA0_DefFlip() throws InterruptedException, InvocationTargetException { @@ -78,17 +192,17 @@ public abstract class GLReadBuffer00Base extends UITestCase { } @Test - public void test10_MSAA4_DefFlip() throws InterruptedException, InvocationTargetException { + public void test10_MSAA8_DefFlip() throws InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(null); - caps.setNumSamples(4); + caps.setNumSamples(8); caps.setSampleBuffers(true); test(caps, false /*useSwingDoubleBuffer*/, false /* skipGLOrientationVerticalFlip */); } @Test - public void test11_MSAA4_UsrFlip() throws InterruptedException, InvocationTargetException { + public void test11_MSAA8_UsrFlip() throws InterruptedException, InvocationTargetException { final GLCapabilities caps = new GLCapabilities(null); - caps.setNumSamples(4); + caps.setNumSamples(8); caps.setSampleBuffers(true); test(caps, false /*useSwingDoubleBuffer*/, true /* skipGLOrientationVerticalFlip */); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java index 4ad84aa73..ee9eea725 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLJPanelAWT.java @@ -52,6 +52,7 @@ import org.junit.runners.MethodSorters; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil; import com.jogamp.opengl.util.texture.TextureIO; @@ -72,6 +73,7 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { final JFrame frame = new JFrame(); final Dimension d = new Dimension(320, 240); final GLJPanel glad = createGLJPanel(skipGLOrientationVerticalFlip, useSwingDoubleBuffer, caps, d); + final SnapshotGLELAWT snapshotGLEL = new SnapshotGLELAWT(awtGLReadBufferUtil, skipGLOrientationVerticalFlip); try { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -81,10 +83,14 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { panel.setDoubleBuffered(useSwingDoubleBuffer); frame.getContentPane().add(panel); - final GearsES2 gears = new GearsES2(0); + final GearsES2 gears = new GearsES2(1); gears.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); gears.setVerbose(false); glad.addGLEventListener(gears); + final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(); + textRendererGLEL.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + glad.addGLEventListener(textRendererGLEL); + glad.addGLEventListener(snapshotGLEL); panel.add(glad); frame.pack(); frame.setVisible(true); @@ -93,18 +99,11 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } - final GLEventListener snapshotGLEL = new SnapshotGLEL(awtGLReadBufferUtil, skipGLOrientationVerticalFlip); + glad.display(); // trigger initialization to get chosen-caps! final Dimension size0 = frame.getSize(); final Dimension size1 = new Dimension(size0.width+100, size0.height+100); final Dimension size2 = new Dimension(size0.width-100, size0.height-100); try { - final Animator anim = new Animator(glad); - anim.start(); - try { Thread.sleep(2*duration); } catch (InterruptedException e) { } - anim.stop(); - addSnapshotGLEL(glad, snapshotGLEL); - glad.display(); - try { Thread.sleep(duration); } catch (InterruptedException e) { } javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { @@ -125,7 +124,8 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { } } ); try { Thread.sleep(duration); } catch (InterruptedException e) { } - removeSnapshotGLEL(glad, snapshotGLEL); + glad.disposeGLEventListener(snapshotGLEL, true /* remove */); + final Animator anim = new Animator(glad); anim.start(); try { Thread.sleep(2*duration); } catch (InterruptedException e) { } anim.stop(); @@ -152,21 +152,31 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { return canvas; } - private class SnapshotGLEL implements GLEventListener { + private class SnapshotGLELAWT implements GLEventListener { final AWTGLReadBufferUtil glReadBufferUtil; final boolean skipGLOrientationVerticalFlip; + boolean defAutoSwapMode; + boolean swapBuffersBeforeRead; int i; - SnapshotGLEL(final AWTGLReadBufferUtil glReadBufferUtil, final boolean skipGLOrientationVerticalFlip) { + SnapshotGLELAWT(final AWTGLReadBufferUtil glReadBufferUtil, final boolean skipGLOrientationVerticalFlip) { this.glReadBufferUtil = glReadBufferUtil; this.skipGLOrientationVerticalFlip = skipGLOrientationVerticalFlip; + this.defAutoSwapMode = true; + this.swapBuffersBeforeRead = false; i = 0; } @Override - public void init(GLAutoDrawable drawable) { } + public void init(GLAutoDrawable drawable) { + defAutoSwapMode = drawable.getAutoSwapBufferMode(); + swapBuffersBeforeRead = UITestCase.swapBuffersBeforeRead(drawable.getChosenGLCapabilities()); + drawable.setAutoSwapBufferMode( !swapBuffersBeforeRead ); + } @Override - public void dispose(GLAutoDrawable drawable) { } + public void dispose(GLAutoDrawable drawable) { + drawable.setAutoSwapBufferMode( defAutoSwapMode ); + } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } @Override @@ -178,10 +188,17 @@ public class TestGLReadBuffer01GLJPanelAWT extends GLReadBuffer00Base { final String filenameAWT = getSnapshotFilename(sn, "awt", drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), glReadBufferUtil.hasAlpha(), fileSuffix, destPath); - // gl.glFinish(); // just make sure rendering finished .. - drawable.swapBuffers(); + if( swapBuffersBeforeRead ) { + drawable.swapBuffers(); + // Just to test whether we use the right buffer, + // i.e. back-buffer shall no more be required .. + gl.glClear(GL.GL_COLOR_BUFFER_BIT); + } else { + gl.glFinish(); // just make sure rendering finished .. + } + final boolean awtOrientation = !( drawable.isGLOriented() && skipGLOrientationVerticalFlip ); - System.err.println(Thread.currentThread().getName()+": ** screenshot: awtOrient/v-flip "+awtOrientation+", "+filenameAWT); + System.err.println(Thread.currentThread().getName()+": ** screenshot: awtOrient/v-flip "+awtOrientation+", swapBuffersBeforeRead "+swapBuffersBeforeRead+", "+filenameAWT); final BufferedImage image = glReadBufferUtil.readPixelsToBufferedImage(gl, awtOrientation); final File fout = new File(filenameAWT); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java index 598ec1021..dde4c32fa 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/acore/TestGLReadBuffer01GLWindowNEWT.java @@ -34,7 +34,6 @@ import javax.media.nativewindow.util.DimensionImmutable; import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCapabilitiesImmutable; -import javax.media.opengl.GLDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.GLProfile; @@ -46,6 +45,7 @@ import org.junit.runners.MethodSorters; import com.jogamp.newt.opengl.GLWindow; import com.jogamp.opengl.test.junit.jogl.demos.es2.GearsES2; import com.jogamp.opengl.test.junit.util.MiscUtils; +import com.jogamp.opengl.test.junit.util.UITestCase; import com.jogamp.opengl.util.Animator; import com.jogamp.opengl.util.GLReadBufferUtil; import com.jogamp.opengl.util.texture.TextureIO; @@ -67,29 +67,26 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base { } final GLReadBufferUtil glReadBufferUtil = new GLReadBufferUtil(false, false); final GLWindow glad= GLWindow.create(caps); + final SnapshotGLEL snapshotGLEL = new SnapshotGLEL(glReadBufferUtil); try { glad.setPosition(64, 64); glad.setSize(320, 240); - final GearsES2 gears = new GearsES2(0); + final GearsES2 gears = new GearsES2(1); gears.setVerbose(false); glad.addGLEventListener(gears); + final TextRendererGLEL textRendererGLEL = new TextRendererGLEL(); + textRendererGLEL.setFlipVerticalInGLOrientation(skipGLOrientationVerticalFlip); + glad.addGLEventListener(textRendererGLEL); + glad.addGLEventListener(snapshotGLEL); glad.setVisible(true); } catch( Throwable throwable ) { throwable.printStackTrace(); Assume.assumeNoException( throwable ); } - final GLEventListener snapshotGLEL = new SnapshotGLEL(glReadBufferUtil); final DimensionImmutable size0 = new Dimension(glad.getWidth(), glad.getHeight()); final DimensionImmutable size1 = new Dimension(size0.getWidth()+100, size0.getHeight()+100); final DimensionImmutable size2 = new Dimension(size0.getWidth()-100, size0.getHeight()-100); try { - final Animator anim = new Animator(glad); - anim.start(); - try { Thread.sleep(2*duration); } catch (InterruptedException e) { } - anim.stop(); - addSnapshotGLEL(glad, snapshotGLEL); - glad.display(); - try { Thread.sleep(duration); } catch (InterruptedException e) { } glad.setSize(size1.getWidth(), size1.getHeight()); try { Thread.sleep(duration); } catch (InterruptedException e) { } @@ -98,7 +95,8 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base { glad.setSize(size0.getWidth(), size0.getHeight()); try { Thread.sleep(duration); } catch (InterruptedException e) { } - removeSnapshotGLEL(glad, snapshotGLEL); + glad.disposeGLEventListener(snapshotGLEL, true /* remove */); + final Animator anim = new Animator(glad); anim.start(); try { Thread.sleep(2*duration); } catch (InterruptedException e) { } anim.stop(); @@ -110,32 +108,48 @@ public class TestGLReadBuffer01GLWindowNEWT extends GLReadBuffer00Base { private class SnapshotGLEL implements GLEventListener { final GLReadBufferUtil glReadBufferUtil; + boolean defAutoSwapMode; + boolean swapBuffersBeforeRead; int i; SnapshotGLEL(final GLReadBufferUtil glReadBufferUtil) { this.glReadBufferUtil = glReadBufferUtil; + this.defAutoSwapMode = true; + this.swapBuffersBeforeRead = false; i = 0; } @Override - public void init(GLAutoDrawable drawable) { } + public void init(GLAutoDrawable drawable) { + defAutoSwapMode = drawable.getAutoSwapBufferMode(); + swapBuffersBeforeRead = UITestCase.swapBuffersBeforeRead(drawable.getChosenGLCapabilities()); + drawable.setAutoSwapBufferMode( !swapBuffersBeforeRead ); + } @Override - public void dispose(GLAutoDrawable drawable) { } + public void dispose(GLAutoDrawable drawable) { + drawable.setAutoSwapBufferMode( defAutoSwapMode ); + } @Override public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { } @Override public void display(GLAutoDrawable drawable) { - snapshot(i++, drawable.getGL(), TextureIO.PNG, null); + snapshot(i++, drawable, TextureIO.PNG, null); } - public void snapshot(int sn, GL gl, String fileSuffix, String destPath) { - final GLDrawable drawable = gl.getContext().getGLReadDrawable(); + public void snapshot(int sn, GLAutoDrawable drawable, String fileSuffix, String destPath) { + final GL gl = drawable.getGL(); final String filenameJGL = getSnapshotFilename(sn, "jgl", drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), glReadBufferUtil.hasAlpha(), fileSuffix, destPath); - // gl.glFinish(); // just make sure rendering finished .. - drawable.swapBuffers(); + if( swapBuffersBeforeRead ) { + drawable.swapBuffers(); + // Just to test whether we use the right buffer, + // i.e. back-buffer shall no more be required .. + gl.glClear(GL.GL_COLOR_BUFFER_BIT); + } else { + gl.glFinish(); // just make sure rendering finished .. + } final boolean mustFlipVertically = !drawable.isGLOriented(); - System.err.println(Thread.currentThread().getName()+": ** screenshot: v-flip "+mustFlipVertically+", "+filenameJGL); + System.err.println(Thread.currentThread().getName()+": ** screenshot: v-flip "+mustFlipVertically+", swapBuffersBeforeRead "+swapBuffersBeforeRead+", "+filenameJGL); if(glReadBufferUtil.readPixels(gl, mustFlipVertically)) { glReadBufferUtil.write(new File(filenameJGL)); diff --git a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java index 82247a59b..79c76e49f 100644 --- a/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java +++ b/src/test/com/jogamp/opengl/test/junit/util/UITestCase.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.opengl.test.junit.util; import java.io.BufferedReader; @@ -69,15 +69,15 @@ public abstract class UITestCase { public static final String SINGLE_INSTANCE_LOCK_FILE = "UITestCase.lock"; public static final int SINGLE_INSTANCE_LOCK_PORT = 59999; - + public static final long SINGLE_INSTANCE_LOCK_TO = 6*60*1000; // wait up to 6 mins public static final long SINGLE_INSTANCE_LOCK_POLL = 1000; // poll every 1s private static volatile SingletonInstance singletonInstance; - + private static volatile boolean testSupported = true; private static volatile boolean resetXRandRIfX11AfterClass = false; - + private static volatile int maxMethodNameLen = 0; private static final synchronized void initSingletonInstance() { @@ -89,11 +89,11 @@ public abstract class UITestCase { } } } - + public static boolean isTestSupported() { return testSupported; } - + public static void setTestSupported(boolean v) { System.err.println("setTestSupported: "+v); testSupported = v; @@ -102,13 +102,13 @@ public abstract class UITestCase { public static void setResetXRandRIfX11AfterClass() { resetXRandRIfX11AfterClass = true; } - + /** * Iterates through all outputs and sets the preferred mode and normal rotation using RandR 1.3. *

        * With NV drivers, one need to add the Modes in proper order to the Screen's Subsection "Display", * otherwise they are either in unsorted resolution order or even n/a! - *

        + *

        */ @SuppressWarnings("unused") public static void resetXRandRIfX11() { @@ -122,7 +122,7 @@ public abstract class UITestCase { final ProcessBuilder pb = new ProcessBuilder("xrandr", "-q"); pb.redirectErrorStream(true); System.err.println("XRandR Query: "+pb.command()); - final Process p = pb.start(); + final Process p = pb.start(); final MiscUtils.StreamDump dump = new MiscUtils.StreamDump( out, p.getInputStream(), ioSync ); dump.start(); while( !dump.eos() ) { @@ -185,7 +185,7 @@ public abstract class UITestCase { } return null; } - + public static int processCommand(String[] cmdline, OutputStream outstream, String outPrefix) { int errorCode = 0; final Object ioSync = new Object(); @@ -207,9 +207,9 @@ public abstract class UITestCase { e.printStackTrace(); errorCode = Integer.MIN_VALUE; } - return errorCode; + return errorCode; } - + public int getMaxTestNameLen() { if(0 == maxMethodNameLen) { int ml = 0; @@ -221,13 +221,13 @@ public abstract class UITestCase { } maxMethodNameLen = ml; } - return maxMethodNameLen; + return maxMethodNameLen; } - + public final String getTestMethodName() { return _unitTestName.getMethodName(); } - + public final String getSimpleTestName(String separator) { return getClass().getSimpleName()+separator+getTestMethodName(); } @@ -235,10 +235,10 @@ public abstract class UITestCase { public final String getFullTestName(String separator) { return getClass().getName()+separator+getTestMethodName(); } - + @BeforeClass public static void oneTimeSetUp() { - // one-time initialization code + // one-time initialization code initSingletonInstance(); } @@ -259,14 +259,14 @@ public abstract class UITestCase { System.err.println(" - "+unsupportedTestMsg); Assume.assumeTrue(testSupported); // abort } - System.err.println(); + System.err.println(); } @After public void tearDown() { System.err.println("++++ UITestCase.tearDown: "+getFullTestName(" - ")); } - + public static void waitForKey(String preMessage) { BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); System.err.println(preMessage+"> Press enter to continue"); @@ -274,9 +274,32 @@ public abstract class UITestCase { System.err.println(stdin.readLine()); } catch (IOException e) { } } - + static final String unsupportedTestMsg = "Test not supported on this platform."; + /** + * Determines whether the chosen {@link GLCapabilitiesImmutable} + * requires a {@link GLDrawable#swapBuffers() swap-buffers} + * before reading pixels. + *

        + * Usually one uses the {@link GL#getDefaultReadBuffer() default-read-buffer}, i.e. + * {@link GL#GL_FRONT} for single-buffer and {@link GL#GL_BACK} for double-buffer {@link GLDrawable}s + * and {@link GL#GL_COLOR_ATTACHMENT0} for offscreen framebuffer objects.
        + * Here {@link GLDrawable#swapBuffers() swap-buffers} shall happen after calling reading pixels, the default. + *

        + *

        + * However, multisampling offscreen {@link javax.media.opengl.GLFBODrawable}s + * utilize {@link GLDrawable#swapBuffers() swap-buffers} to downsample + * the multisamples into the readable sampling sink. + * In this case, we require a {@link GLDrawable#swapBuffers() swap-buffers} before reading pixels. + *

        + * @param chosenCaps the chosen {@link GLCapabilitiesImmutable} + * @return chosenCaps.isFBO() && chosenCaps.getSampleBuffers() + */ + public static final boolean swapBuffersBeforeRead(GLCapabilitiesImmutable chosenCaps) { + return chosenCaps.isFBO() && chosenCaps.getSampleBuffers(); + } + public String getSnapshotFilename(int sn, String postSNDetail, GLCapabilitiesImmutable caps, int width, int height, boolean sinkHasAlpha, String fileSuffix, String destPath) { if(null == fileSuffix) { fileSuffix = TextureIO.PNG; @@ -284,7 +307,7 @@ public abstract class UITestCase { final int maxSimpleTestNameLen = getMaxTestNameLen()+getClass().getSimpleName().length()+1; final String simpleTestName = this.getSimpleTestName("."); final String filenameBaseName; - { + { final String accel = caps.getHardwareAccelerated() ? "hw" : "sw" ; final String scrnm; if(caps.isOnscreen()) { @@ -307,22 +330,22 @@ public abstract class UITestCase { final String aaext = caps.getSampleExtension(); postSNDetail = null != postSNDetail ? "-"+postSNDetail : ""; - filenameBaseName = String.format("%-"+maxSimpleTestNameLen+"s-n%04d%s-%-6s-%s-%s-B%s-F%s_I%s-D%02d-St%02d-Sa%02d_%s-%04dx%04d.%s", - simpleTestName, sn, postSNDetail, caps.getGLProfile().getName(), accel, - scrnm, dblb, F_pfmt, pfmt, depthBits, stencilBits, samples, aaext, + filenameBaseName = String.format("%-"+maxSimpleTestNameLen+"s-n%04d%s-%-6s-%s-%s-B%s-F%s_I%s-D%02d-St%02d-Sa%02d_%s-%04dx%04d.%s", + simpleTestName, sn, postSNDetail, caps.getGLProfile().getName(), accel, + scrnm, dblb, F_pfmt, pfmt, depthBits, stencilBits, samples, aaext, width, height, fileSuffix).replace(' ', '_'); } - return null != destPath ? destPath + File.separator + filenameBaseName : filenameBaseName; + return null != destPath ? destPath + File.separator + filenameBaseName : filenameBaseName; } - + /** - * Takes a snapshot of the drawable's current front framebuffer. Example filenames: + * Takes a snapshot of the drawable's current front framebuffer. Example filenames: *
              * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenFBOSglBuf____-n0001-msaa0-GLES2_-sw-fbobject-Bdbl-Frgb__Irgba8888_-D24-St00-Sa00_default-0400x0300.png
              * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testES2OffScreenPbufferDblBuf-n0003-msaa0-GLES2_-sw-pbuffer_-Bdbl-Frgb__Irgba8880-D24-St00-Sa00_default-0200x0150.png
              * TestGLDrawableAutoDelegateOnOffscrnCapsNEWT.testGL2OffScreenPbufferSglBuf-n0003-msaa0-GL2___-hw-pbuffer_-Bone-Frgb__Irgba5551-D24-St00-Sa00_default-0200x0150.png
              * 
        - * @param sn sequential number + * @param sn sequential number * @param postSNDetail optional detail to be added to the filename after sn * @param gl the current GL context object. It's read drawable is being used as the pixel source and to gather some details which will end up in the filename. * @param readBufferUtil the {@link GLReadBufferUtil} to be used to read the pixels for the screenshot. @@ -330,20 +353,20 @@ public abstract class UITestCase { * If null the "png" as defined in {@link TextureIO#PNG} is being used. * @param destPath Optional platform dependent file path. It shall use {@link File#separatorChar} as is directory separator. * It shall not end with a directory separator, {@link File#separatorChar}. - * If null the current working directory is being used. + * If null the current working directory is being used. */ public void snapshot(int sn, String postSNDetail, GL gl, GLReadBufferUtil readBufferUtil, String fileSuffix, String destPath) { final GLDrawable drawable = gl.getContext().getGLReadDrawable(); - final String filename = getSnapshotFilename(sn, postSNDetail, - drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), + final String filename = getSnapshotFilename(sn, postSNDetail, + drawable.getChosenGLCapabilities(), drawable.getWidth(), drawable.getHeight(), readBufferUtil.hasAlpha(), fileSuffix, destPath); System.err.println(Thread.currentThread().getName()+": ** screenshot: "+filename); gl.glFinish(); // just make sure rendering finished .. if(readBufferUtil.readPixels(gl, false)) { readBufferUtil.write(new File(filename)); - } + } } - + public class SnapshotGLEventListener implements GLEventListener { private final GLReadBufferUtil screenshot; private volatile boolean makeShot = false; @@ -394,6 +417,6 @@ public abstract class UITestCase { postSNDetail = v; } }; - + } -- cgit v1.2.3 From 938fbc9e4cb58c1ab6a6f66f128189ed7b634955 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 15 Feb 2014 09:12:30 +0100 Subject: Bug 927 - Multithreading (MT) issues with ALAudioSink (openal-soft) - Using update openal-soft (commit 7297c3214a4c648aaee81a9877da15b88f798197) - Analyzed openal-soft threading issues: - a global-lock would have removed the issue - turns out that using ALC_EXT_thread_local_context's alcSetThreadContext(..) instead of alcMakeContextCurrent(..) solves the issue - Cleaned up al*GetError() queries and handling - Simplified flush/dequeue buffers --- make/scripts/tests.sh | 16 ++- .../jogamp/opengl/openal/av/ALAudioSink.java | 133 ++++++++++++++++----- 2 files changed, 114 insertions(+), 35 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 49b1b46ef..c69c72f46 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -63,6 +63,13 @@ fi #export INTEL_DEBUG="buf bat" #export INTEL_STRICT_CONFORMANCE=1 +# export ALSOFT_LOGLEVEL=[0..4] +export ALSOFT_LOGLEVEL=3 +#export ALSOFT_TRAP_ERROR=true +#export ALSOFT_TRAP_AL_ERROR=true +#export ALSOFT_TRAP_ALC_ERROR=true +#export ALSOFT_LOGFILE=openal-soft.log + which "$javaexe" 2>&1 | tee -a java-run.log "$javaexe" -version 2>&1 | tee -a java-run.log echo LD_LIBRARY_PATH $LD_LIBRARY_PATH 2>&1 | tee -a java-run.log @@ -145,7 +152,7 @@ function jrun() { #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" - #D_ARGS="-Djogl.debug.AudioSink" + D_ARGS="-Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Screen" @@ -245,7 +252,8 @@ function jrun() { #X_ARGS="-Xrs" #X_ARGS="-Dsun.awt.disableMixing=true" #D_ARGS="-Djogamp.debug.IOUtil -Djogl.debug.GLSLCode -Djogl.debug.GLMediaPlayer" - #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.AudioSink" + #D_ARGS="-Djogl.debug.AudioSink" + #D_ARGS="-Djogl.debug.AudioSink.trace" #D_ARGS="-Djogl.debug.GLMediaPlayer -Djogl.debug.GLMediaPlayer.Native" #D_ARGS="-Djogl.debug.GLMediaPlayer" #D_ARGS="-Djogl.debug.GLMediaPlayer.StreamWorker.delay=25 -Djogl.debug.GLMediaPlayer" @@ -360,7 +368,7 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests @@ -487,7 +495,7 @@ function testawtswt() { #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.TestAnimatorGLJPanel01AWT $* #testawt com.jogamp.opengl.test.junit.jogl.acore.anim.Bug898AnimatorFromEDTAWT $* -testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLReadBuffer01GLJPanelAWT $* +#testawt com.jogamp.opengl.test.junit.jogl.acore.TestGLReadBuffer01GLJPanelAWT $* #testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLReadBuffer01GLWindowNEWT $* # diff --git a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java index 8b12f8a28..287b3081c 100644 --- a/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java +++ b/src/jogl/classes/jogamp/opengl/openal/av/ALAudioSink.java @@ -31,6 +31,8 @@ package jogamp.opengl.openal.av; import java.nio.ByteBuffer; import java.util.Arrays; +import jogamp.opengl.Debug; + import com.jogamp.common.util.LFRingbuffer; import com.jogamp.common.util.Ringbuffer; import com.jogamp.common.util.locks.LockFactory; @@ -50,6 +52,8 @@ import com.jogamp.opengl.util.av.AudioSink; public class ALAudioSink implements AudioSink { private static final String AL_SOFT_buffer_samples = "AL_SOFT_buffer_samples"; + private static final String ALC_EXT_thread_local_context = "ALC_EXT_thread_local_context"; + private static final boolean DEBUG_TRACE; private static final ALC alc; private static final AL al; private static final ALExt alExt; @@ -58,6 +62,7 @@ public class ALAudioSink implements AudioSink { private String deviceSpecifier; private ALCdevice device; private boolean hasSOFTBufferSamples; + private boolean hasALC_thread_local_context; private AudioFormat preferredAudioFormat; private ALCcontext context; private final RecursiveLock lock = LockFactory.createRecursiveLock(); @@ -106,6 +111,9 @@ public class ALAudioSink implements AudioSink { private volatile boolean playRequested = false; static { + Debug.initSingleton(); + DEBUG_TRACE = Debug.isPropertyDefined("jogl.debug.AudioSink.trace", true); + ALC _alc = null; AL _al = null; ALExt _alExt = null; @@ -160,12 +168,15 @@ public class ALAudioSink implements AudioSink { } hasSOFTBufferSamples = al.alIsExtensionPresent(AL_SOFT_buffer_samples); + hasALC_thread_local_context = alc.alcIsExtensionPresent(null, ALC_EXT_thread_local_context) || + alc.alcIsExtensionPresent(device, ALC_EXT_thread_local_context) ; preferredAudioFormat = queryPreferredAudioFormat(); if( DEBUG ) { System.out.println("ALAudioSink: OpenAL Extensions:"+al.alGetString(AL.AL_EXTENSIONS)); System.out.println("ALAudioSink: Null device OpenAL Extensions:"+alc.alcGetString(null, ALC.ALC_EXTENSIONS)); System.out.println("ALAudioSink: Device "+deviceSpecifier+" OpenAL Extensions:"+alc.alcGetString(device, ALC.ALC_EXTENSIONS)); System.out.println("ALAudioSink: hasSOFTBufferSamples "+hasSOFTBufferSamples); + System.out.println("ALAudioSink: hasALC_thread_local_context "+hasALC_thread_local_context); System.out.println("ALAudioSink: preferredAudioFormat "+preferredAudioFormat); } @@ -174,7 +185,7 @@ public class ALAudioSink implements AudioSink { alSource = new int[1]; al.alGenSources(1, alSource, 0); final int err = al.alGetError(); - if( err != AL.AL_NO_ERROR ) { + if( AL.AL_NO_ERROR != err ) { alSource = null; throw new RuntimeException("ALAudioSink: Error generating Source: 0x"+Integer.toHexString(err)); } @@ -208,10 +219,31 @@ public class ALAudioSink implements AudioSink { private final void lockContext() { lock.lock(); - alc.alcMakeContextCurrent(context); + if( hasALC_thread_local_context ) { + alExt.alcSetThreadContext(context); + } else { + alc.alcMakeContextCurrent(context); + } + final int alcErr = alc.alcGetError(null); + if( ALC.ALC_NO_ERROR != alcErr ) { + final String err = "ALCError "+toHexString(alcErr)+" while makeCurrent. "+this; + System.err.println(err); + Thread.dumpStack(); + lock.unlock(); + throw new RuntimeException(err); + } + final int alErr = al.alGetError(); + if( ALC.ALC_NO_ERROR != alErr ) { + System.err.println("Prev - ALError "+toHexString(alErr)+" @ makeCurrent. "+this); + Thread.dumpStack(); + } } private final void unlockContext() { - alc.alcMakeContextCurrent(null); + if( hasALC_thread_local_context ) { + alExt.alcSetThreadContext(null); + } else { + alc.alcMakeContextCurrent(null); + } lock.unlock(); } private final void destroyContext() { @@ -251,6 +283,14 @@ public class ALAudioSink implements AudioSink { "queue[g "+frameGrowAmount+", l "+frameLimit+"]"; } + private final String shortString() { + final int alSrcName = null != alSource ? alSource[0] : 0; + final int ctxHash = context != null ? context.hashCode() : 0; + return "[ctx "+toHexString(ctxHash)+", playReq "+playRequested+", alSrc "+alSrcName+ + ", queued["+alFramesPlaying.size()+", " + alBufferBytesQueued+" bytes], "+ + "queue[g "+frameGrowAmount+", l "+frameLimit+"]"; + } + public final String getPerfString() { final int alBuffersLen = null != alBufferNames ? alBufferNames.length : 0; return "Play [buffer "+alFramesPlaying.size()+"/"+alBuffersLen+", apts "+getPTS()+", "+getQueuedTime() + " ms, " + alBufferBytesQueued+" bytes]"; @@ -325,7 +365,7 @@ public class ALAudioSink implements AudioSink { alBufferNames = new int[initialFrameCount]; al.alGenBuffers(initialFrameCount, alBufferNames, 0); final int err = al.alGetError(); - if( err != AL.AL_NO_ERROR ) { + if( AL.AL_NO_ERROR != err ) { alBufferNames = null; throw new RuntimeException("ALAudioSink: Error generating Buffers: 0x"+Integer.toHexString(err)); } @@ -340,6 +380,10 @@ public class ALAudioSink implements AudioSink { queueGrowAmount > 0 ? queueGrowAmount : AudioSink.DefaultQueueGrowAmount, useFrameDuration); this.frameLimit = requestedFormat.getFrameCount( queueLimit > 0 ? queueLimit : AudioSink.DefaultQueueLimitWithVideo, useFrameDuration); + if( DEBUG_TRACE ) { + alFramesAvail.dump(System.err, "Avail-init"); + alFramesPlaying.dump(System.err, "Playi-init"); + } } } finally { unlockContext(); @@ -375,7 +419,7 @@ public class ALAudioSink implements AudioSink { final int[] newALBufferNames = new int[frameGrowAmount]; al.alGenBuffers(frameGrowAmount, newALBufferNames, 0); final int err = al.alGetError(); - if( err != AL.AL_NO_ERROR ) { + if( AL.AL_NO_ERROR != err ) { if( DEBUG ) { System.err.println(getThreadName()+": ALAudioSink.growBuffers: Error generating "+frameGrowAmount+" new Buffers: 0x"+Integer.toHexString(err)); } @@ -397,6 +441,10 @@ public class ALAudioSink implements AudioSink { if( DEBUG ) { System.err.println(getThreadName()+": ALAudioSink: Buffer grown "+frameGrowAmount+": Avail "+alFramesAvail+", playing "+alFramesPlaying); } + if( DEBUG_TRACE ) { + alFramesAvail.dump(System.err, "Avail-grow"); + alFramesPlaying.dump(System.err, "Playi-grow"); + } return true; } @@ -469,7 +517,7 @@ public class ALAudioSink implements AudioSink { return initialized; } - private final int dequeueBuffer(boolean wait) { + private final int dequeueBuffer(final boolean wait, final boolean ignoreBufferInconsistency) { int alErr = AL.AL_NO_ERROR; final int releaseBufferCount; if( alBufferBytesQueued > 0 ) { @@ -505,7 +553,7 @@ public class ALAudioSink implements AudioSink { } if( releaseBufferCount > 0 ) { - int[] buffers=new int[releaseBufferCount]; + final int[] buffers = new int[releaseBufferCount]; al.alSourceUnqueueBuffers(alSource[0], releaseBufferCount, buffers, 0); alErr = al.alGetError(); if( AL.AL_NO_ERROR != alErr ) { @@ -514,22 +562,42 @@ public class ALAudioSink implements AudioSink { for ( int i=0; i "+alFrame.alBuffer+" -> "+shortString()+" @ "+getThreadName()); + } + al.alSourceQueueBuffers(alSource[0], 1, alBufferNames, 0); - alErr = al.alGetError(); - if(al.alGetError() != AL.AL_NO_ERROR) { + final int alErr = al.alGetError(); + if( AL.AL_NO_ERROR != alErr ) { throw new RuntimeException("ALError "+toHexString(alErr)+" while queueing buffer "+toHexString(alBufferNames[0])+". "+this); } alBufferBytesQueued += byteCount; enqueuedFrameCount++; + if(DEBUG_TRACE) { + System.err.println(">> "+alFrame.alBuffer+" -> "+shortString()+" @ "+getThreadName()); + } + playImpl(); // continue playing, fixes issue where we ran out of enqueued data! } finally { unlockContext(); @@ -664,7 +736,7 @@ public class ALAudioSink implements AudioSink { final int[] val = new int[1]; al.alGetSourcei(alSource[0], AL.AL_SOURCE_STATE, val, 0); final int alErr = al.alGetError(); - if(al.alGetError() != AL.AL_NO_ERROR) { + if( AL.AL_NO_ERROR != alErr ) { throw new RuntimeException("ALError "+toHexString(alErr)+" while querying SOURCE_STATE. "+this); } return val[0]; @@ -690,7 +762,7 @@ public class ALAudioSink implements AudioSink { if( playRequested && AL.AL_PLAYING != getSourceState() ) { al.alSourcePlay(alSource[0]); final int alErr = al.alGetError(); - if(al.alGetError() != AL.AL_NO_ERROR) { + if( AL.AL_NO_ERROR != alErr ) { throw new RuntimeException("ALError "+toHexString(alErr)+" while start playing. "+this); } } @@ -718,7 +790,7 @@ public class ALAudioSink implements AudioSink { playRequested = false; al.alSourcePause(alSource[0]); final int alErr = al.alGetError(); - if(al.alGetError() != AL.AL_NO_ERROR) { + if( AL.AL_NO_ERROR != alErr ) { throw new RuntimeException("ALError "+toHexString(alErr)+" while pausing. "+this); } } @@ -728,7 +800,7 @@ public class ALAudioSink implements AudioSink { playRequested = false; al.alSourceStop(alSource[0]); final int alErr = al.alGetError(); - if(al.alGetError() != AL.AL_NO_ERROR) { + if( AL.AL_NO_ERROR != alErr ) { throw new RuntimeException("ALError "+toHexString(alErr)+" while pausing. "+this); } } @@ -795,8 +867,7 @@ public class ALAudioSink implements AudioSink { try { // pauseImpl(); stopImpl(); - al.alSourcei(alSource[0], AL.AL_BUFFER, 0); // explicit force zero buffer! - dequeueBuffer( false /* wait */ ); + // Redundant: dequeueBuffer( false /* wait */, true /* ignoreBufferInconsistency */); dequeueForceAll(); if( alBufferNames.length != alFramesAvail.size() || alFramesPlaying.size() != 0 ) { throw new InternalError("XXX: "+this); -- cgit v1.2.3 From 1e1b408ba1527edc2ee5ceede92816ee87e4c461 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 15 Feb 2014 23:28:25 +0100 Subject: Graph: RendereState: Create own PMVMatrix if passed value is null; Renderer: Add reshapeNotify(..) for NOP PMV reshape notification --- make/scripts/tests.sh | 6 +++--- src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java | 6 +++--- src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java | 8 ++++++++ src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java | 4 ---- 4 files changed, 14 insertions(+), 10 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index c69c72f46..9365a6bce 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -152,7 +152,7 @@ function jrun() { #D_ARGS="-Djogl.1thread=false -Djogl.debug.Threading" #D_ARGS="-Djogl.1thread=true -Djogl.debug.Threading" #D_ARGS="-Djogl.debug.DebugGL -Djogl.debug.TraceGL -Djogl.debug.GLContext.TraceSwitch -Djogl.debug=all" - D_ARGS="-Djogl.debug.AudioSink" + #D_ARGS="-Djogl.debug.AudioSink" #D_ARGS="-Djogl.debug.GLArrayData" #D_ARGS="-Dnewt.debug.Screen -Dnewt.debug.Window" #D_ARGS="-Dnewt.debug.Screen" @@ -367,8 +367,8 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java index 6a8fb6a67..9b0f32ef6 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/RenderState.java @@ -42,7 +42,7 @@ public abstract class RenderState { private static final String thisKey = "jogamp.graph.curve.RenderState" ; public static RenderState createRenderState(ShaderState st, Vertex.Factory pointFactory) { - return new RenderStateImpl(st, pointFactory); + return new RenderStateImpl(st, pointFactory, null); } public static RenderState createRenderState(ShaderState st, Vertex.Factory pointFactory, PMVMatrix pmvMatrix) { @@ -61,8 +61,8 @@ public abstract class RenderState { protected RenderState(ShaderState st, Vertex.Factory vertexFactory, PMVMatrix pmvMatrix) { this.st = st; this.vertexFactory = vertexFactory; - this.pmvMatrix = pmvMatrix; - this.gcu_PMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, pmvMatrix.glGetPMvMatrixf()); + this.pmvMatrix = null != pmvMatrix ? pmvMatrix : new PMVMatrix(); + this.gcu_PMVMatrix = new GLUniformData(UniformNames.gcu_PMVMatrix, 4, 4, this.pmvMatrix.glGetPMvMatrixf()); st.ownUniform(gcu_PMVMatrix); } diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java index 8783906c2..029286601 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java @@ -241,6 +241,14 @@ public abstract class Renderer { } } + /** No PMVMatrix operation is performed here. PMVMatrix will be updated if gl is not null. */ + public boolean reshapeNotify(GL2ES2 gl, int width, int height) { + this.vp_width = width; + this.vp_height = height; + updateMatrix(gl); + return true; + } + public boolean reshapePerspective(GL2ES2 gl, float angle, int width, int height, float near, float far) { this.vp_width = width; this.vp_height = height; diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java index fe2dd7363..68f926b0a 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java +++ b/src/jogl/classes/jogamp/graph/curve/opengl/RenderStateImpl.java @@ -61,10 +61,6 @@ public class RenderStateImpl extends RenderState { // st.ownUniform(gcu_Strength); } - public RenderStateImpl(ShaderState st, Vertex.Factory pointFactory) { - this(st, pointFactory, new PMVMatrix()); - } - @Override public final GLUniformData getWeight() { return gcu_Weight; } @Override -- cgit v1.2.3 From a6acce1be19060a6a4801582f0534e0d6887467a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 15 Feb 2014 23:36:19 +0100 Subject: Add make/scripts/make.jogl.all.macosx-clang.sh --- make/scripts/make.jogl.all.macosx-clang.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'make/scripts') diff --git a/make/scripts/make.jogl.all.macosx-clang.sh b/make/scripts/make.jogl.all.macosx-clang.sh index b5f21c908..6b253964a 100755 --- a/make/scripts/make.jogl.all.macosx-clang.sh +++ b/make/scripts/make.jogl.all.macosx-clang.sh @@ -25,5 +25,6 @@ export GLUEGEN_PROPERTIES_FILE="../../gluegen/make/lib/gluegen-xcode_clang.prope export JOGAMP_JAR_CODEBASE="Codebase: *.goethel.localnet" ant \ + -Dc.compiler.debug=true \ -Drootrel.build=build-macosx \ $* 2>&1 | tee make.jogl.all.macosx.log -- cgit v1.2.3 From e685f79ec7071e266a1bd3d3ce3e742397b5372e Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 16 Feb 2014 06:12:45 +0100 Subject: Bug 927: Fix minor MT issues w/ libav/ffmpeg Issue: [NULL @ 0x35bde60] insufficient thread locking around avcodec_open/close() Decorating said libav functions w/ mutex lock/release. Abstract impl. to either use pthread or JNI Monitor, but using the latter to reduce dependencies (ming64 windows). FFMPEGNatives is now an abstract class containing the 'static final Object mutex_avcodec_openclose' --- make/scripts/tests.sh | 4 +- .../jogamp/opengl/util/av/impl/FFMPEGNatives.java | 44 ++++++------ .../opengl/util/av/impl/FFMPEGv08Natives.java | 34 +++++----- .../opengl/util/av/impl/FFMPEGv09Natives.java | 34 +++++----- .../opengl/util/av/impl/FFMPEGv10Natives.java | 34 +++++----- src/jogl/native/libav/ffmpeg_impl_template.c | 79 ++++++++++++++++------ src/jogl/native/libav/ffmpeg_tool.h | 15 ++++ 7 files changed, 152 insertions(+), 92 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index 9365a6bce..f6e3ab244 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -367,8 +367,8 @@ function testawtswt() { # av demos # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* # # performance tests diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java index bc0865aa9..c3fc2898f 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGNatives.java @@ -29,17 +29,23 @@ package jogamp.opengl.util.av.impl; import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; -interface FFMPEGNatives { +/* pp */ abstract class FFMPEGNatives { - boolean initSymbols0(long[] symbols, int count); - int getAvUtilMajorVersionCC0(); - int getAvFormatMajorVersionCC0(); - int getAvCodecMajorVersionCC0(); - int getAvResampleMajorVersionCC0(); - int getSwResampleMajorVersionCC0(); + private static final Object mutex_avcodec_openclose = new Object(); - long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose); - void destroyInstance0(long moviePtr); + abstract boolean initSymbols0(long[] symbols, int count); + abstract int getAvUtilMajorVersionCC0(); + abstract int getAvFormatMajorVersionCC0(); + abstract int getAvCodecMajorVersionCC0(); + abstract int getAvResampleMajorVersionCC0(); + abstract int getSwResampleMajorVersionCC0(); + + final long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose) { + return createInstance0(mutex_avcodec_openclose, upstream, verbose); + } + abstract long createInstance0(Object mutex_avcodec_openclose, FFMPEGMediaPlayer upstream, boolean verbose); + + abstract void destroyInstance0(long moviePtr); /** * Issues {@link #updateAttributes(int, int, int, int, int, int, int, float, int, int, String, String)} @@ -56,24 +62,24 @@ interface FFMPEGNatives { * @param aPrefSampleRate * @param aPrefChannelCount */ - void setStream0(long moviePtr, String url, boolean isCameraInput, - int vid, String sizes, int vWidth, int vHeight, - int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); + abstract void setStream0(long moviePtr, String url, boolean isCameraInput, + int vid, String sizes, int vWidth, int vHeight, + int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); - void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); + abstract void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); - int getVideoPTS0(long moviePtr); + abstract int getVideoPTS0(long moviePtr); - int getAudioPTS0(long moviePtr); + abstract int getAudioPTS0(long moviePtr); /** * @return resulting current video PTS, or {@link TextureFrame#INVALID_PTS} */ - int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); + abstract int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); - int play0(long moviePtr); - int pause0(long moviePtr); - int seek0(long moviePtr, int position); + abstract int play0(long moviePtr); + abstract int pause0(long moviePtr); + abstract int seek0(long moviePtr, int position); /** FFMPEG/libAV Audio Sample Format */ public static enum SampleFormat { diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java index 4b013c1b3..6ca0ea311 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv08Natives.java @@ -27,52 +27,52 @@ */ package jogamp.opengl.util.av.impl; -class FFMPEGv08Natives implements FFMPEGNatives { +class FFMPEGv08Natives extends FFMPEGNatives { @Override - public native boolean initSymbols0(long[] symbols, int count); + native boolean initSymbols0(long[] symbols, int count); @Override - public native int getAvUtilMajorVersionCC0(); + native int getAvUtilMajorVersionCC0(); @Override - public native int getAvFormatMajorVersionCC0(); + native int getAvFormatMajorVersionCC0(); @Override - public native int getAvCodecMajorVersionCC0(); + native int getAvCodecMajorVersionCC0(); @Override - public native int getAvResampleMajorVersionCC0(); + native int getAvResampleMajorVersionCC0(); @Override - public native int getSwResampleMajorVersionCC0(); + native int getSwResampleMajorVersionCC0(); @Override - public native long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose); + native long createInstance0(Object mutex_avcodec_openclose, FFMPEGMediaPlayer upstream, boolean verbose); @Override - public native void destroyInstance0(long moviePtr); + native void destroyInstance0(long moviePtr); @Override - public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); + native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); @Override - public native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); + native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); @Override - public native int getVideoPTS0(long moviePtr); + native int getVideoPTS0(long moviePtr); @Override - public native int getAudioPTS0(long moviePtr); + native int getAudioPTS0(long moviePtr); @Override - public native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); + native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); @Override - public native int play0(long moviePtr); + native int play0(long moviePtr); @Override - public native int pause0(long moviePtr); + native int pause0(long moviePtr); @Override - public native int seek0(long moviePtr, int position); + native int seek0(long moviePtr, int position); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java index d69763287..1d9f7f5fa 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv09Natives.java @@ -27,52 +27,52 @@ */ package jogamp.opengl.util.av.impl; -class FFMPEGv09Natives implements FFMPEGNatives { +class FFMPEGv09Natives extends FFMPEGNatives { @Override - public native boolean initSymbols0(long[] symbols, int count); + native boolean initSymbols0(long[] symbols, int count); @Override - public native int getAvUtilMajorVersionCC0(); + native int getAvUtilMajorVersionCC0(); @Override - public native int getAvFormatMajorVersionCC0(); + native int getAvFormatMajorVersionCC0(); @Override - public native int getAvCodecMajorVersionCC0(); + native int getAvCodecMajorVersionCC0(); @Override - public native int getAvResampleMajorVersionCC0(); + native int getAvResampleMajorVersionCC0(); @Override - public native int getSwResampleMajorVersionCC0(); + native int getSwResampleMajorVersionCC0(); @Override - public native long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose); + native long createInstance0(Object mutex_avcodec_openclose, FFMPEGMediaPlayer upstream, boolean verbose); @Override - public native void destroyInstance0(long moviePtr); + native void destroyInstance0(long moviePtr); @Override - public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); + native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); @Override - public native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); + native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); @Override - public native int getVideoPTS0(long moviePtr); + native int getVideoPTS0(long moviePtr); @Override - public native int getAudioPTS0(long moviePtr); + native int getAudioPTS0(long moviePtr); @Override - public native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); + native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); @Override - public native int play0(long moviePtr); + native int play0(long moviePtr); @Override - public native int pause0(long moviePtr); + native int pause0(long moviePtr); @Override - public native int seek0(long moviePtr, int position); + native int seek0(long moviePtr, int position); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java index 0b5f70d7c..19bc10f5f 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGv10Natives.java @@ -27,52 +27,52 @@ */ package jogamp.opengl.util.av.impl; -class FFMPEGv10Natives implements FFMPEGNatives { +class FFMPEGv10Natives extends FFMPEGNatives { @Override - public native boolean initSymbols0(long[] symbols, int count); + native boolean initSymbols0(long[] symbols, int count); @Override - public native int getAvUtilMajorVersionCC0(); + native int getAvUtilMajorVersionCC0(); @Override - public native int getAvFormatMajorVersionCC0(); + native int getAvFormatMajorVersionCC0(); @Override - public native int getAvCodecMajorVersionCC0(); + native int getAvCodecMajorVersionCC0(); @Override - public native int getAvResampleMajorVersionCC0(); + native int getAvResampleMajorVersionCC0(); @Override - public native int getSwResampleMajorVersionCC0(); + native int getSwResampleMajorVersionCC0(); @Override - public native long createInstance0(FFMPEGMediaPlayer upstream, boolean verbose); + native long createInstance0(Object mutex_avcodec_openclose, FFMPEGMediaPlayer upstream, boolean verbose); @Override - public native void destroyInstance0(long moviePtr); + native void destroyInstance0(long moviePtr); @Override - public native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); + native void setStream0(long moviePtr, String url, boolean isCameraInput, int vid, String sizes, int vWidth, int vHeight, int vRate, int aid, int aMaxChannelCount, int aPrefSampleRate); @Override - public native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); + native void setGLFuncs0(long moviePtr, long procAddrGLTexSubImage2D, long procAddrGLGetError, long procAddrGLFlush, long procAddrGLFinish); @Override - public native int getVideoPTS0(long moviePtr); + native int getVideoPTS0(long moviePtr); @Override - public native int getAudioPTS0(long moviePtr); + native int getAudioPTS0(long moviePtr); @Override - public native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); + native int readNextPacket0(long moviePtr, int texTarget, int texFmt, int texType); @Override - public native int play0(long moviePtr); + native int play0(long moviePtr); @Override - public native int pause0(long moviePtr); + native int pause0(long moviePtr); @Override - public native int seek0(long moviePtr, int position); + native int seek0(long moviePtr, int position); } diff --git a/src/jogl/native/libav/ffmpeg_impl_template.c b/src/jogl/native/libav/ffmpeg_impl_template.c index e86b2a542..274eb37a5 100644 --- a/src/jogl/native/libav/ffmpeg_impl_template.c +++ b/src/jogl/native/libav/ffmpeg_impl_template.c @@ -344,6 +344,14 @@ static void _setIsGLOriented(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { } } +#ifdef USE_PTHREAD_LOCKING + #define MY_MUTEX_LOCK(e,s) pthread_mutex_lock(&(s)) + #define MY_MUTEX_UNLOCK(e,s) pthread_mutex_unlock(&(s)) +#else + #define MY_MUTEX_LOCK(e,s) (*e)->MonitorEnter(e, s) + #define MY_MUTEX_UNLOCK(e,s) (*e)->MonitorExit(e, s) +#endif + static void freeInstance(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { int i; if(NULL != pAV) { @@ -361,19 +369,23 @@ static void freeInstance(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { pAV->aResampleBuffer = NULL; } - // Close the V codec - if(NULL != pAV->pVCodecCtx) { - sp_avcodec_close(pAV->pVCodecCtx); - pAV->pVCodecCtx = NULL; - } - pAV->pVCodec=NULL; + MY_MUTEX_LOCK(env, pAV->mutex_avcodec_openclose); + { + // Close the V codec + if(NULL != pAV->pVCodecCtx) { + sp_avcodec_close(pAV->pVCodecCtx); + pAV->pVCodecCtx = NULL; + } + pAV->pVCodec=NULL; - // Close the A codec - if(NULL != pAV->pACodecCtx) { - sp_avcodec_close(pAV->pACodecCtx); - pAV->pACodecCtx = NULL; + // Close the A codec + if(NULL != pAV->pACodecCtx) { + sp_avcodec_close(pAV->pACodecCtx); + pAV->pACodecCtx = NULL; + } + pAV->pACodec=NULL; } - pAV->pACodec=NULL; + MY_MUTEX_UNLOCK(env, pAV->mutex_avcodec_openclose); // Close the frames if(NULL != pAV->pVFrame) { @@ -421,6 +433,14 @@ static void freeInstance(JNIEnv *env, FFMPEGToolBasicAV_t* pAV) { (*env)->DeleteGlobalRef(env, pAV->ffmpegMediaPlayer); pAV->ffmpegMediaPlayer = NULL; } + + #ifdef USE_PTHREAD_LOCKING + pthread_mutex_unlock(&pAV->mutex_avcodec_openclose); + pthread_mutex_destroy(&pAV->mutex_avcodec_openclose); + #else + (*env)->DeleteGlobalRef(env, pAV->mutex_avcodec_openclose); + #endif + free(pAV); } } @@ -488,8 +508,11 @@ JNIEXPORT jint JNICALL FF_FUNC(getSwResampleMajorVersionCC0) } JNIEXPORT jlong JNICALL FF_FUNC(createInstance0) - (JNIEnv *env, jobject instance, jobject ffmpegMediaPlayer, jboolean verbose) + (JNIEnv *env, jobject instance, jobject mutex_avcodec_openclose, jobject ffmpegMediaPlayer, jboolean verbose) { + #ifdef USE_PTHREAD_LOCKING + pthread_mutexattr_t renderLockAttr; + #endif FFMPEGToolBasicAV_t * pAV = calloc(1, sizeof(FFMPEGToolBasicAV_t)); if(NULL==pAV) { JoglCommon_throwNewRuntimeException(env, "Couldn't alloc instance"); @@ -524,6 +547,14 @@ JNIEXPORT jlong JNICALL FF_FUNC(createInstance0) pAV->vid=AV_STREAM_ID_AUTO; pAV->aid=AV_STREAM_ID_AUTO; + #ifdef USE_PTHREAD_LOCKING + pthread_mutexattr_init(&renderLockAttr); + pthread_mutexattr_settype(&renderLockAttr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&pAV->mutex_avcodec_openclose, &renderLockAttr); // recursive + #else + pAV->mutex_avcodec_openclose = (*env)->NewGlobalRef(env, mutex_avcodec_openclose); + #endif + if(pAV->verbose) { fprintf(stderr, "Info: Use avresample %d, swresample %d, device %d, refCount %d\n", AV_HAS_API_AVRESAMPLE(pAV), AV_HAS_API_SWRESAMPLE(pAV), HAS_FUNC(sp_avdevice_register_all), pAV->useRefCountedFrames); @@ -824,10 +855,14 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) } // Open codec - #if LIBAVCODEC_VERSION_MAJOR >= 55 - pAV->pACodecCtx->refcounted_frames = pAV->useRefCountedFrames; - #endif - res = sp_avcodec_open2(pAV->pACodecCtx, pAV->pACodec, NULL); + MY_MUTEX_LOCK(env, pAV->mutex_avcodec_openclose); + { + #if LIBAVCODEC_VERSION_MAJOR >= 55 + pAV->pACodecCtx->refcounted_frames = pAV->useRefCountedFrames; + #endif + res = sp_avcodec_open2(pAV->pACodecCtx, pAV->pACodec, NULL); + } + MY_MUTEX_UNLOCK(env, pAV->mutex_avcodec_openclose); if(res<0) { JoglCommon_throwNewRuntimeException(env, "Couldn't open audio codec %d, %s", pAV->pACodecCtx->codec_id, pAV->acodec); return; @@ -982,10 +1017,14 @@ JNIEXPORT void JNICALL FF_FUNC(setStream0) } // Open codec - #if LIBAVCODEC_VERSION_MAJOR >= 55 - pAV->pVCodecCtx->refcounted_frames = pAV->useRefCountedFrames; - #endif - res = sp_avcodec_open2(pAV->pVCodecCtx, pAV->pVCodec, NULL); + MY_MUTEX_LOCK(env, pAV->mutex_avcodec_openclose); + { + #if LIBAVCODEC_VERSION_MAJOR >= 55 + pAV->pVCodecCtx->refcounted_frames = pAV->useRefCountedFrames; + #endif + res = sp_avcodec_open2(pAV->pVCodecCtx, pAV->pVCodec, NULL); + } + MY_MUTEX_UNLOCK(env, pAV->mutex_avcodec_openclose); if(res<0) { JoglCommon_throwNewRuntimeException(env, "Couldn't open video codec %d, %s", pAV->pVCodecCtx->codec_id, pAV->vcodec); return; diff --git a/src/jogl/native/libav/ffmpeg_tool.h b/src/jogl/native/libav/ffmpeg_tool.h index 97e60afce..66c3519e6 100644 --- a/src/jogl/native/libav/ffmpeg_tool.h +++ b/src/jogl/native/libav/ffmpeg_tool.h @@ -64,6 +64,15 @@ typedef struct SwrContext SwrContext; #include #include +// We use JNI Monitor Locking, since this removes the need +// to statically link-in pthreads on window .. +// #define USE_PTHREAD_LOCKING 1 +// +#ifdef USE_PTHREAD_LOCKING + #include + #error PTHREAD path not tested yet +#endif + #include typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); @@ -148,6 +157,12 @@ typedef struct { PFNGLFLUSH procAddrGLFlush; PFNGLFINISH procAddrGLFinish; + #ifdef USE_PTHREAD_LOCKING + pthread_mutex_t mutex_avcodec_openclose; + #else + jobject mutex_avcodec_openclose; + #endif + AVFormatContext* pFormatCtx; int32_t vid; AVStream* pVStream; -- cgit v1.2.3 From c67de337a8aaf52e36104c3f13e273aa19d21f1f Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 22 Feb 2014 08:05:42 +0100 Subject: Bug 927 - Multithreading (MT) - GLMediaPlayer.GLMediaEventListener: Remind that commands shall be off-loaded on another thread! --- make/scripts/tests.sh | 8 +- .../com/jogamp/opengl/util/av/GLMediaPlayer.java | 8 +- .../opengl/util/texture/TextureSequence.java | 12 +-- .../junit/jogl/demos/es2/av/CrossFadePlayer.java | 85 +++++++++++----------- .../test/junit/jogl/demos/es2/av/MovieCube.java | 9 ++- .../test/junit/jogl/demos/es2/av/MovieSimple.java | 43 +++++++---- 6 files changed, 96 insertions(+), 69 deletions(-) (limited to 'make/scripts') diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh index f6e3ab244..4381f5780 100644 --- a/make/scripts/tests.sh +++ b/make/scripts/tests.sh @@ -64,7 +64,8 @@ fi #export INTEL_STRICT_CONFORMANCE=1 # export ALSOFT_LOGLEVEL=[0..4] -export ALSOFT_LOGLEVEL=3 +# export ALSOFT_LOGLEVEL=3 +# export ALSOFT_LOGLEVEL=3 #export ALSOFT_TRAP_ERROR=true #export ALSOFT_TRAP_AL_ERROR=true #export ALSOFT_TRAP_ALC_ERROR=true @@ -244,7 +245,7 @@ function jrun() { #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer -Djogl.debug.TileRenderer.PNG" #D_ARGS="-Djogl.debug.GLCanvas -Djogl.debug.GLJPanel -Djogl.debug.TileRenderer" #D_ARGS="-Djogl.debug.PNG -Dnewt.debug.Display.PointerIcon" - #D_ARGS="-Djogl.debug.JPEGImage" + #D_ARGS="-Djogl.debug.JPEGImage -Djogamp.debug.Bitstream" #D_ARGS="-Djogl.debug.GLDrawable -Dnativewindow.debug.GraphicsConfiguration -Djogl.debug.CapabilitiesChooser" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=True -Dsun.java2d.xrender=false" #X_ARGS="-Dsun.java2d.noddraw=True -Dsun.java2d.opengl=false -Dsun.java2d.xrender=false" @@ -368,7 +369,8 @@ function testawtswt() { # #testnoawt jogamp.opengl.openal.av.ALDummyUsage $* #testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieCube $* -testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +#testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.MovieSimple $* +testnoawt com.jogamp.opengl.test.junit.jogl.demos.es2.av.CrossFadePlayer $* # # performance tests diff --git a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java index 9957f2093..5a455c8bd 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/av/GLMediaPlayer.java @@ -30,6 +30,7 @@ package com.jogamp.opengl.util.av; import java.net.URI; import javax.media.opengl.GL; +import javax.media.opengl.GLEventListener; import javax.media.opengl.GLException; import jogamp.opengl.Debug; @@ -255,7 +256,12 @@ public interface GLMediaPlayer extends TextureSequence { /** * {@inheritDoc} *

        - * See {@link TexSeqEventListener} for semantics and usage. + * As the contract of {@link TexSeqEventListener} requests, + * implementations of {@link GLMediaEventListener} shall also: + *

          + *
        • off-load complex or {@link GLMediaPlayer} commands on another thread, or
        • + *
        • simply changing a volatile state of their {@link GLEventListener} implementation.
        • + *
        *

        */ public interface GLMediaEventListener extends TexSeqEventListener { diff --git a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java index 6c2949c2b..ab9d1f8f0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java +++ b/src/jogl/classes/com/jogamp/opengl/util/texture/TextureSequence.java @@ -31,6 +31,7 @@ import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLRunnable; import javax.media.opengl.GLEventListener; + import com.jogamp.opengl.util.TimeFrameI; /** @@ -133,17 +134,16 @@ public interface TextureSequence { /** * Event listener to notify users of updates regarding the {@link TextureSequence}. *

        - * The implementation sending the events, and hence calling down to all listeners, - * does not necessarily make the user's OpenGL context current. + * Implementations sending events down to all listeners, + * while not necessarily making the user's OpenGL context current. *

        *

        - * Further more, the call may happen off-thread, possibly holding another, possibly shared, OpenGL context current. - *

        + * Events may be sent from a 3rd-party thread, possibly holding another, maybe shared, OpenGL context current.
        * Hence a user shall not issue any OpenGL, time consuming - * or {@link TextureSequence} lifecycle operations directly.
        + * or {@link TextureSequence} operations directly.
        * Instead, the user shall: *
          - *
        • issue commands off-thread via spawning off another thread, or
        • + *
        • off-load complex or {@link TextureSequence} commands on another thread, or
        • *
        • injecting {@link GLRunnable} objects via {@link GLAutoDrawable#invoke(boolean, GLRunnable)}, or
        • *
        • simply changing a volatile state of their {@link GLEventListener} implementation.
        • *
        diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java index c656663ee..02f62c415 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/CrossFadePlayer.java @@ -35,10 +35,6 @@ import com.jogamp.opengl.util.av.GLMediaPlayer.StreamException; import com.jogamp.opengl.util.av.GLMediaPlayerFactory; import com.jogamp.opengl.util.texture.TextureSequence.TextureFrame; -import javax.media.opengl.GLAutoDrawable; -import javax.media.opengl.GLEventListener; -import javax.media.opengl.GLException; - import java.io.File; import java.net.URI; @@ -48,7 +44,7 @@ import java.net.URI; */ public class CrossFadePlayer { - static GLMediaPlayer[] player; + static GLMediaPlayer[] player; static volatile boolean stop = false; public static void main(String[] args) @@ -63,13 +59,11 @@ public class CrossFadePlayer GLMediaEventListener mediaEventListener = new GLMediaEventListener() { - @Override - public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, - long when) { } + public void newFrameAvailable(GLMediaPlayer ts, TextureFrame newFrame, long when) { } @Override - public void attributesChanged(GLMediaPlayer mp, int event_mask, long when) + public void attributesChanged(final GLMediaPlayer mp, int event_mask, long when) { System.out.println("\n***\nEvent mask changed: " + event_mask); System.out.println("Timestamp: "+ when); @@ -78,32 +72,41 @@ public class CrossFadePlayer if ((event_mask & GLMediaEventListener.EVENT_CHANGE_INIT) !=0) { System.out.println("Duration: " + mp.getDuration() + "ms"); System.out.println("Volume: " + mp.getAudioVolume()); - try { - System.out.println("player.initGL()..."); - mp.initGL(null); - } - catch (IllegalStateException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - catch (GLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - catch (StreamException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - }else if ((event_mask & GLMediaEventListener.EVENT_CHANGE_PAUSE) !=0) { - System.out.println("player.play()..."); - System.out.println("mp.setPlaySpeed(1f) returned: " + mp.setPlaySpeed(1f)); - mp.seek(0); - mp.play(); - }else if ((event_mask & GLMediaEventListener.EVENT_CHANGE_PLAY) !=0) { + System.out.println("player.initGL()..."); + new Thread() { + public void run() { + try { + mp.initGL(null); + if ( GLMediaPlayer.State.Paused == mp.getState() ) { // init OK + mp.play(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }.start(); + } else if ((event_mask & GLMediaEventListener.EVENT_CHANGE_PAUSE) !=0) { + System.out.println("player.paused()..."); + } else if ((event_mask & GLMediaEventListener.EVENT_CHANGE_PLAY) !=0) { System.out.println("playing..."); System.out.println(mp.toString()); System.out.println(mp.getAudioSink().toString()); - } + } else if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { + final StreamException se = mp.getStreamException(); + if( null != se ) { + System.err.println("Player State: EOS + Exception"); + stop = true; + } else { + System.err.println("Player State: EOS"); + new Thread() { + public void run() { + System.out.println("mp.setPlaySpeed(1f) returned: " + mp.setPlaySpeed(1f)); + mp.seek(0); + mp.play(); + } + }.start(); + } + } if( 0 != ( ( GLMediaEventListener.EVENT_CHANGE_ERR | GLMediaEventListener.EVENT_CHANGE_EOS ) & event_mask ) ) { final StreamException se = mp.getStreamException(); if( null != se ) { @@ -111,7 +114,7 @@ public class CrossFadePlayer } new Thread() { public void run() { - System.out.println("terminating..."); + System.out.println("terminating..."); stop = true; } }.start(); @@ -123,13 +126,13 @@ public class CrossFadePlayer // Initialize media players player = new GLMediaPlayer[args.length]; int i=0; - for( String arg: args) { + for( String arg: args ) { player[i] = GLMediaPlayerFactory.createDefault(); if(player[i]!=null){ System.out.println("Created CrossFade player: "+ i + " " + player[i].getClass().getName()); player[i].addEventListener(mediaEventListener); try { - String filename = args[i]; + final String filename = arg; if(filename.equals("")){ System.out.println("No file selected: arg " + i +" = "+ filename); player[i]=null; @@ -157,7 +160,7 @@ public class CrossFadePlayer // Main thread CrossFade until playback is done long startTime = com.jogamp.common.os.Platform.currentTimeMillis(); - double piPlayers = Math.PI*2.0f/(double)args.length; + double piPlayers = Math.PI*2.0f/args.length; StreamException se = null; while( null == se && stop == false ) { try { @@ -173,18 +176,18 @@ public class CrossFadePlayer } } } - + // tune the volume on players to crossfade! - float progress = (float)(com.jogamp.common.os.Platform.currentTimeMillis()-startTime)/maxDuration; + float progress = (com.jogamp.common.os.Platform.currentTimeMillis()-startTime)/maxDuration; i = 0; for(GLMediaPlayer p: player){ if(p!=null){ AudioSink sink = p.getAudioSink(); if(sink != null){ - float volume = (float) (0.5f+(0.5f*(Math.cos(40.0f*progress+(piPlayers*(float)i))))); - float playbacktime = (float)(com.jogamp.common.os.Platform.currentTimeMillis()-startTime); - System.out.println("player: "+ i +" volume = " + volume +" progress = "+ progress +" time = "+ playbacktime + " / duration = " + maxDuration); + float volume = (float) (0.5f+(0.5f*(Math.cos(40.0f*progress+(piPlayers*i))))); + float playbacktime = com.jogamp.common.os.Platform.currentTimeMillis()-startTime; + // System.out.println("player: "+ i +" volume = " + volume +" progress = "+ progress +" time = "+ playbacktime + " / duration = " + maxDuration); sink.setVolume(volume); } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index daa09c3b1..b148ebabd 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -112,9 +112,12 @@ public class MovieCube implements GLEventListener { resetGLState(); } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { - // loop for-ever .. - mPlayer.seek(0); - mPlayer.play(); + new Thread() { + public void run() { + // loop for-ever .. + mPlayer.seek(0); + mPlayer.play(); + } }.start(); } } }); diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index e609dde55..787dbab78 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -321,9 +321,12 @@ public class MovieSimple implements GLEventListener { resetGLState(); } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_EOS & event_mask ) ) { - // loop for-ever .. - mPlayer.seek(0); - mPlayer.play(); + new Thread() { + public void run() { + // loop for-ever .. + mPlayer.seek(0); + mPlayer.play(); + } }.start(); } } }); @@ -801,19 +804,24 @@ public class MovieSimple implements GLEventListener { final GLAnimatorControl anim = window.getAnimator(); anim.setUpdateFPSFrames(60, null); anim.resetFPSCounter(); - /** * Kick off player w/o GLEventListener, i.e. for audio only. * - try { - ms.mPlayer.initGL(null); - } catch (Exception e) { - e.printStackTrace(); - destroyWindow(); - return; - } - ms.mPlayer.play(); - System.out.println("play.1 "+ms.mPlayer); + new Thread() { + public void run() { + try { + mp.initGL(null); + if ( GLMediaPlayer.State.Paused == mp.getState() ) { // init OK + mp.play(); + } + System.out.println("play.1 "+mp); + } catch (Exception e) { + e.printStackTrace(); + destroyWindow(); + return; + } + } + }.start(); */ } if( 0 != ( GLMediaEventListener.EVENT_CHANGE_PLAY & event_mask ) ) { @@ -831,8 +839,13 @@ public class MovieSimple implements GLEventListener { } else { System.err.println("MovieSimple State: EOS"); if( loopEOS ) { - ms.mPlayer.seek(0); - ms.mPlayer.play(); + new Thread() { + public void run() { + mp.setPlaySpeed(1f); + mp.seek(0); + mp.play(); + } + }.start(); } else { destroy = true; } -- cgit v1.2.3